// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: blog.pckt.block.paragraph
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

#[allow(unused_imports)]
use alloc::collections::BTreeMap;
use jacquard_common::{BosStr, DefaultStr, FromStaticStr};

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::blog_pckt::block::hard_break::HardBreak;
use crate::blog_pckt::block::mention::Mention;
use crate::blog_pckt::block::text::Text;
use crate::blog_pckt::richtext::facet::Facet;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Paragraph<S: BosStr = DefaultStr> {
    ///Array of inline content nodes (text, hard breaks, and mentions)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub content: Option<Vec<ParagraphContentItem<S>>>,
    ///Facets for text formatting and features within this paragraph
    #[serde(skip_serializing_if = "Option::is_none")]
    pub facets: Option<Vec<Facet<S>>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum ParagraphContentItem<S: BosStr = DefaultStr> {
    #[serde(rename = "blog.pckt.block.text")]
    Text(Box<Text<S>>),
    #[serde(rename = "blog.pckt.block.hardBreak")]
    HardBreak(Box<HardBreak<S>>),
    #[serde(rename = "blog.pckt.block.mention")]
    Mention(Box<Mention<S>>),
}

impl<S: BosStr> LexiconSchema for Paragraph<S> {
    fn nsid() -> &'static str {
        "blog.pckt.block.paragraph"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_blog_pckt_block_paragraph()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

fn lexicon_doc_blog_pckt_block_paragraph() -> LexiconDoc<'static> {
    #[allow(unused_imports)]
    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
    use jacquard_lexicon::lexicon::*;
    use alloc::collections::BTreeMap;
    LexiconDoc {
        lexicon: Lexicon::Lexicon1,
        id: CowStr::new_static("blog.pckt.block.paragraph"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Object(LexObject {
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("content"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Array of inline content nodes (text, hard breaks, and mentions)",
                                    ),
                                ),
                                items: LexArrayItem::Union(LexRefUnion {
                                    refs: vec![
                                        CowStr::new_static("blog.pckt.block.text"),
                                        CowStr::new_static("blog.pckt.block.hardBreak"),
                                        CowStr::new_static("blog.pckt.block.mention")
                                    ],
                                    closed: Some(false),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("facets"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Facets for text formatting and features within this paragraph",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("blog.pckt.richtext.facet"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}