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

pub mod facet;


#[allow(unused_imports)]
use alloc::collections::BTreeMap;

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_derive::{IntoStatic, lexicon, 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::com_deckbelcher::richtext::facet::Facet;
use crate::com_deckbelcher::richtext;
/// An unordered (bullet) list.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct BulletListBlock<'a> {
    ///The list items.
    #[serde(borrow)]
    pub items: Vec<richtext::ListItem<'a>>,
}

/// A code block with optional language hint.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct CodeBlock<'a> {
    ///Optional language identifier for syntax highlighting.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub language: Option<CowStr<'a>>,
    ///The code content (plain text, no facets).
    #[serde(borrow)]
    pub text: CowStr<'a>,
}

/** A multi-block rich text document.
Used for primers and other long-form content.*/

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Document<'a> {
    ///Array of blocks (paragraphs, headings, etc).
    #[serde(borrow)]
    pub content: Vec<DocumentContentItem<'a>>,
}


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum DocumentContentItem<'a> {
    #[serde(rename = "com.deckbelcher.richtext#paragraphBlock")]
    ParagraphBlock(Box<richtext::ParagraphBlock<'a>>),
    #[serde(rename = "com.deckbelcher.richtext#headingBlock")]
    HeadingBlock(Box<richtext::HeadingBlock<'a>>),
    #[serde(rename = "com.deckbelcher.richtext#codeBlock")]
    CodeBlock(Box<richtext::CodeBlock<'a>>),
    #[serde(rename = "com.deckbelcher.richtext#bulletListBlock")]
    BulletListBlock(Box<richtext::BulletListBlock<'a>>),
    #[serde(rename = "com.deckbelcher.richtext#orderedListBlock")]
    OrderedListBlock(Box<richtext::OrderedListBlock<'a>>),
    #[serde(rename = "com.deckbelcher.richtext#horizontalRuleBlock")]
    HorizontalRuleBlock(Box<richtext::HorizontalRuleBlock<'a>>),
}

/// A heading block with level, text, and optional facets.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct HeadingBlock<'a> {
    ///Annotations of text (formatting, mentions, links, etc).
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub facets: Option<Vec<Facet<'a>>>,
    ///Heading level (1-6).
    pub level: i64,
    ///The plain text content (no markdown symbols).
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub text: Option<CowStr<'a>>,
}

/// A horizontal rule (thematic break).

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct HorizontalRuleBlock<'a> {}
/// A single list item with text, optional facets, and optional sublist.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct ListItem<'a> {
    ///Annotations of text (formatting, mentions, links, etc).
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub facets: Option<Vec<Facet<'a>>>,
    ///Optional nested sublist (bullet or ordered).
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub sublist: Option<ListItemSublist<'a>>,
    ///The plain text content (no markdown symbols).
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub text: Option<CowStr<'a>>,
}


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum ListItemSublist<'a> {
    #[serde(rename = "com.deckbelcher.richtext#bulletListBlock")]
    BulletListBlock(Box<richtext::BulletListBlock<'a>>),
    #[serde(rename = "com.deckbelcher.richtext#orderedListBlock")]
    OrderedListBlock(Box<richtext::OrderedListBlock<'a>>),
}

/** A single paragraph of rich text with optional facet annotations.
Used for descriptions and other short formatted text.*/

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Richtext<'a> {
    ///Annotations of text (mentions, URLs, hashtags, formatting, etc).
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub facets: Option<Vec<Facet<'a>>>,
    ///The plain text content (no markdown symbols).
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub text: Option<CowStr<'a>>,
}

/// An ordered (numbered) list.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct OrderedListBlock<'a> {
    ///The list items.
    #[serde(borrow)]
    pub items: Vec<richtext::ListItem<'a>>,
    ///Starting number (default 1).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub start: Option<i64>,
}

/// A paragraph block with text and optional facets.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct ParagraphBlock<'a> {
    ///Annotations of text (formatting, mentions, links, etc).
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub facets: Option<Vec<Facet<'a>>>,
    ///The plain text content (no markdown symbols).
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub text: Option<CowStr<'a>>,
}

impl<'a> LexiconSchema for BulletListBlock<'a> {
    fn nsid() -> &'static str {
        "com.deckbelcher.richtext"
    }
    fn def_name() -> &'static str {
        "bulletListBlock"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_com_deckbelcher_richtext()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for CodeBlock<'a> {
    fn nsid() -> &'static str {
        "com.deckbelcher.richtext"
    }
    fn def_name() -> &'static str {
        "codeBlock"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_com_deckbelcher_richtext()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.language {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 50usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("language"),
                    max: 50usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.text;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("text"),
                    max: 100000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for Document<'a> {
    fn nsid() -> &'static str {
        "com.deckbelcher.richtext"
    }
    fn def_name() -> &'static str {
        "document"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_com_deckbelcher_richtext()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for HeadingBlock<'a> {
    fn nsid() -> &'static str {
        "com.deckbelcher.richtext"
    }
    fn def_name() -> &'static str {
        "headingBlock"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_com_deckbelcher_richtext()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.level;
            if *value > 6i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("level"),
                    max: 6i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.level;
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("level"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.text {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 10000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("text"),
                    max: 10000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.text {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 1000usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("text"),
                        max: 1000usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for HorizontalRuleBlock<'a> {
    fn nsid() -> &'static str {
        "com.deckbelcher.richtext"
    }
    fn def_name() -> &'static str {
        "horizontalRuleBlock"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_com_deckbelcher_richtext()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for ListItem<'a> {
    fn nsid() -> &'static str {
        "com.deckbelcher.richtext"
    }
    fn def_name() -> &'static str {
        "listItem"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_com_deckbelcher_richtext()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.text {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("text"),
                    max: 100000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.text {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 10000usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("text"),
                        max: 10000usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for Richtext<'a> {
    fn nsid() -> &'static str {
        "com.deckbelcher.richtext"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_com_deckbelcher_richtext()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.text {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 500000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("text"),
                    max: 500000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.text {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 50000usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("text"),
                        max: 50000usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for OrderedListBlock<'a> {
    fn nsid() -> &'static str {
        "com.deckbelcher.richtext"
    }
    fn def_name() -> &'static str {
        "orderedListBlock"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_com_deckbelcher_richtext()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for ParagraphBlock<'a> {
    fn nsid() -> &'static str {
        "com.deckbelcher.richtext"
    }
    fn def_name() -> &'static str {
        "paragraphBlock"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_com_deckbelcher_richtext()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.text {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 500000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("text"),
                    max: 500000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.text {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 50000usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("text"),
                        max: 50000usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

pub mod bullet_list_block_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Items;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Items = Unset;
    }
    ///State transition - sets the `items` field to Set
    pub struct SetItems<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetItems<S> {}
    impl<S: State> State for SetItems<S> {
        type Items = Set<members::items>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `items` field
        pub struct items(());
    }
}

/// Builder for constructing an instance of this type
pub struct BulletListBlockBuilder<'a, S: bullet_list_block_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<Vec<richtext::ListItem<'a>>>,),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> BulletListBlock<'a> {
    /// Create a new builder for this type
    pub fn new() -> BulletListBlockBuilder<'a, bullet_list_block_state::Empty> {
        BulletListBlockBuilder::new()
    }
}

impl<'a> BulletListBlockBuilder<'a, bullet_list_block_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        BulletListBlockBuilder {
            _state: PhantomData,
            _fields: (None,),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> BulletListBlockBuilder<'a, S>
where
    S: bullet_list_block_state::State,
    S::Items: bullet_list_block_state::IsUnset,
{
    /// Set the `items` field (required)
    pub fn items(
        mut self,
        value: impl Into<Vec<richtext::ListItem<'a>>>,
    ) -> BulletListBlockBuilder<'a, bullet_list_block_state::SetItems<S>> {
        self._fields.0 = Option::Some(value.into());
        BulletListBlockBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> BulletListBlockBuilder<'a, S>
where
    S: bullet_list_block_state::State,
    S::Items: bullet_list_block_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> BulletListBlock<'a> {
        BulletListBlock {
            items: self._fields.0.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> BulletListBlock<'a> {
        BulletListBlock {
            items: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_com_deckbelcher_richtext() -> 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("com.deckbelcher.richtext"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("bulletListBlock"),
                LexUserType::Object(LexObject {
                    description: Some(CowStr::new_static("An unordered (bullet) list.")),
                    required: Some(vec![SmolStr::new_static("items")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("items"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(CowStr::new_static("The list items.")),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#listItem"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("codeBlock"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("A code block with optional language hint."),
                    ),
                    required: Some(vec![SmolStr::new_static("text")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("language"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Optional language identifier for syntax highlighting.",
                                    ),
                                ),
                                max_length: Some(50usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("text"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The code content (plain text, no facets).",
                                    ),
                                ),
                                max_length: Some(100000usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("document"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A multi-block rich text document.\nUsed for primers and other long-form content.",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("content")]),
                    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 blocks (paragraphs, headings, etc).",
                                    ),
                                ),
                                items: LexArrayItem::Union(LexRefUnion {
                                    refs: vec![
                                        CowStr::new_static("#paragraphBlock"),
                                        CowStr::new_static("#headingBlock"),
                                        CowStr::new_static("#codeBlock"),
                                        CowStr::new_static("#bulletListBlock"),
                                        CowStr::new_static("#orderedListBlock"),
                                        CowStr::new_static("#horizontalRuleBlock")
                                    ],
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("headingBlock"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A heading block with level, text, and optional facets.",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("level")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("facets"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Annotations of text (formatting, mentions, links, etc).",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("com.deckbelcher.richtext.facet"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("level"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(1i64),
                                maximum: Some(6i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("text"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The plain text content (no markdown symbols).",
                                    ),
                                ),
                                max_length: Some(10000usize),
                                max_graphemes: Some(1000usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("horizontalRuleBlock"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("A horizontal rule (thematic break)."),
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("listItem"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A single list item with text, optional facets, and optional sublist.",
                        ),
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("facets"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Annotations of text (formatting, mentions, links, etc).",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("com.deckbelcher.richtext.facet"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("sublist"),
                            LexObjectProperty::Union(LexRefUnion {
                                description: Some(
                                    CowStr::new_static(
                                        "Optional nested sublist (bullet or ordered).",
                                    ),
                                ),
                                refs: vec![
                                    CowStr::new_static("#bulletListBlock"),
                                    CowStr::new_static("#orderedListBlock")
                                ],
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("text"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The plain text content (no markdown symbols).",
                                    ),
                                ),
                                max_length: Some(100000usize),
                                max_graphemes: Some(10000usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A single paragraph of rich text with optional facet annotations.\nUsed for descriptions and other short formatted text.",
                        ),
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("facets"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Annotations of text (mentions, URLs, hashtags, formatting, etc).",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("com.deckbelcher.richtext.facet"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("text"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The plain text content (no markdown symbols).",
                                    ),
                                ),
                                max_length: Some(500000usize),
                                max_graphemes: Some(50000usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("orderedListBlock"),
                LexUserType::Object(LexObject {
                    description: Some(CowStr::new_static("An ordered (numbered) list.")),
                    required: Some(vec![SmolStr::new_static("items")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("items"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(CowStr::new_static("The list items.")),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#listItem"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("start"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("paragraphBlock"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A paragraph block with text and optional facets.",
                        ),
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("facets"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Annotations of text (formatting, mentions, links, etc).",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("com.deckbelcher.richtext.facet"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("text"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The plain text content (no markdown symbols).",
                                    ),
                                ),
                                max_length: Some(500000usize),
                                max_graphemes: Some(50000usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod document_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Content;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Content = Unset;
    }
    ///State transition - sets the `content` field to Set
    pub struct SetContent<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetContent<S> {}
    impl<S: State> State for SetContent<S> {
        type Content = Set<members::content>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `content` field
        pub struct content(());
    }
}

/// Builder for constructing an instance of this type
pub struct DocumentBuilder<'a, S: document_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<Vec<DocumentContentItem<'a>>>,),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> Document<'a> {
    /// Create a new builder for this type
    pub fn new() -> DocumentBuilder<'a, document_state::Empty> {
        DocumentBuilder::new()
    }
}

impl<'a> DocumentBuilder<'a, document_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        DocumentBuilder {
            _state: PhantomData,
            _fields: (None,),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> DocumentBuilder<'a, S>
where
    S: document_state::State,
    S::Content: document_state::IsUnset,
{
    /// Set the `content` field (required)
    pub fn content(
        mut self,
        value: impl Into<Vec<DocumentContentItem<'a>>>,
    ) -> DocumentBuilder<'a, document_state::SetContent<S>> {
        self._fields.0 = Option::Some(value.into());
        DocumentBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> DocumentBuilder<'a, S>
where
    S: document_state::State,
    S::Content: document_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Document<'a> {
        Document {
            content: self._fields.0.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> Document<'a> {
        Document {
            content: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod heading_block_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Level;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Level = Unset;
    }
    ///State transition - sets the `level` field to Set
    pub struct SetLevel<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetLevel<S> {}
    impl<S: State> State for SetLevel<S> {
        type Level = Set<members::level>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `level` field
        pub struct level(());
    }
}

/// Builder for constructing an instance of this type
pub struct HeadingBlockBuilder<'a, S: heading_block_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<Vec<Facet<'a>>>, Option<i64>, Option<CowStr<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> HeadingBlock<'a> {
    /// Create a new builder for this type
    pub fn new() -> HeadingBlockBuilder<'a, heading_block_state::Empty> {
        HeadingBlockBuilder::new()
    }
}

impl<'a> HeadingBlockBuilder<'a, heading_block_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        HeadingBlockBuilder {
            _state: PhantomData,
            _fields: (None, None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: heading_block_state::State> HeadingBlockBuilder<'a, S> {
    /// Set the `facets` field (optional)
    pub fn facets(mut self, value: impl Into<Option<Vec<Facet<'a>>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `facets` field to an Option value (optional)
    pub fn maybe_facets(mut self, value: Option<Vec<Facet<'a>>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S> HeadingBlockBuilder<'a, S>
where
    S: heading_block_state::State,
    S::Level: heading_block_state::IsUnset,
{
    /// Set the `level` field (required)
    pub fn level(
        mut self,
        value: impl Into<i64>,
    ) -> HeadingBlockBuilder<'a, heading_block_state::SetLevel<S>> {
        self._fields.1 = Option::Some(value.into());
        HeadingBlockBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: heading_block_state::State> HeadingBlockBuilder<'a, S> {
    /// Set the `text` field (optional)
    pub fn text(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `text` field to an Option value (optional)
    pub fn maybe_text(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<'a, S> HeadingBlockBuilder<'a, S>
where
    S: heading_block_state::State,
    S::Level: heading_block_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> HeadingBlock<'a> {
        HeadingBlock {
            facets: self._fields.0,
            level: self._fields.1.unwrap(),
            text: self._fields.2,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> HeadingBlock<'a> {
        HeadingBlock {
            facets: self._fields.0,
            level: self._fields.1.unwrap(),
            text: self._fields.2,
            extra_data: Some(extra_data),
        }
    }
}

pub mod ordered_list_block_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Items;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Items = Unset;
    }
    ///State transition - sets the `items` field to Set
    pub struct SetItems<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetItems<S> {}
    impl<S: State> State for SetItems<S> {
        type Items = Set<members::items>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `items` field
        pub struct items(());
    }
}

/// Builder for constructing an instance of this type
pub struct OrderedListBlockBuilder<'a, S: ordered_list_block_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<Vec<richtext::ListItem<'a>>>, Option<i64>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> OrderedListBlock<'a> {
    /// Create a new builder for this type
    pub fn new() -> OrderedListBlockBuilder<'a, ordered_list_block_state::Empty> {
        OrderedListBlockBuilder::new()
    }
}

impl<'a> OrderedListBlockBuilder<'a, ordered_list_block_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        OrderedListBlockBuilder {
            _state: PhantomData,
            _fields: (None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> OrderedListBlockBuilder<'a, S>
where
    S: ordered_list_block_state::State,
    S::Items: ordered_list_block_state::IsUnset,
{
    /// Set the `items` field (required)
    pub fn items(
        mut self,
        value: impl Into<Vec<richtext::ListItem<'a>>>,
    ) -> OrderedListBlockBuilder<'a, ordered_list_block_state::SetItems<S>> {
        self._fields.0 = Option::Some(value.into());
        OrderedListBlockBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: ordered_list_block_state::State> OrderedListBlockBuilder<'a, S> {
    /// Set the `start` field (optional)
    pub fn start(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `start` field to an Option value (optional)
    pub fn maybe_start(mut self, value: Option<i64>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S> OrderedListBlockBuilder<'a, S>
where
    S: ordered_list_block_state::State,
    S::Items: ordered_list_block_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> OrderedListBlock<'a> {
        OrderedListBlock {
            items: self._fields.0.unwrap(),
            start: self._fields.1,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> OrderedListBlock<'a> {
        OrderedListBlock {
            items: self._fields.0.unwrap(),
            start: self._fields.1,
            extra_data: Some(extra_data),
        }
    }
}