// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: sh.weaver.notebook.theme
//
// 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;

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, 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::blob::BlobRef;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{Did, AtUri, Cid};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
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_atproto::repo::strong_ref::StrongRef;
use crate::sh_weaver::notebook::theme;
/// Custom syntax highlighting theme file (sublime text/textmate theme format)

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct CodeThemeFile<S: BosStr = DefaultStr> {
    pub content: BlobRef<S>,
    pub did: Did<S>,
    pub name: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

pub type CodeThemeName<S = DefaultStr> = S;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Font<S: BosStr = DefaultStr> {
    ///Font for a notebook
    pub value: FontValue<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 FontValue<S: BosStr = DefaultStr> {
    #[serde(rename = "sh.weaver.notebook.theme#fontName")]
    FontName(Box<theme::FontName<S>>),
    #[serde(rename = "sh.weaver.notebook.theme#fontFile")]
    FontFile(Box<theme::FontFile<S>>),
}

/// Custom woff(2) or ttf font file

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct FontFile<S: BosStr = DefaultStr> {
    pub content: BlobRef<S>,
    pub did: Did<S>,
    pub name: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

pub type FontName<S = DefaultStr> = S;
/// Theme for a notebook

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "sh.weaver.notebook.theme",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Theme<S: BosStr = DefaultStr> {
    ///Syntax highlighting theme for dark mode
    pub dark_code_theme: ThemeDarkCodeTheme<S>,
    ///Reference to a dark colour scheme
    pub dark_scheme: StrongRef<S>,
    /// Defaults to `"auto"`.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default = "_default_theme_default_theme")]
    pub default_theme: Option<S>,
    ///Fonts to be used in the notebook. Can specify a name or list of names (will load if available) or a file or list of files for each. Empty lists will use site defaults.
    pub fonts: ThemeFonts<S>,
    ///Syntax highlighting theme for light mode
    pub light_code_theme: ThemeLightCodeTheme<S>,
    ///Reference to a light colour scheme
    pub light_scheme: StrongRef<S>,
    pub spacing: ThemeSpacing<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 ThemeDarkCodeTheme<S: BosStr = DefaultStr> {
    #[serde(rename = "sh.weaver.notebook.theme#codeThemeName")]
    CodeThemeName(Box<theme::CodeThemeName<S>>),
    #[serde(rename = "sh.weaver.notebook.theme#codeThemeFile")]
    CodeThemeFile(Box<theme::CodeThemeFile<S>>),
}

/// Fonts to be used in the notebook. Can specify a name or list of names (will load if available) or a file or list of files for each. Empty lists will use site defaults.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ThemeFonts<S: BosStr = DefaultStr> {
    pub body: Vec<crate::sh_weaver::notebook::theme::Font<S>>,
    pub heading: Vec<crate::sh_weaver::notebook::theme::Font<S>>,
    pub monospace: Vec<crate::sh_weaver::notebook::theme::Font<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 ThemeLightCodeTheme<S: BosStr = DefaultStr> {
    #[serde(rename = "sh.weaver.notebook.theme#codeThemeName")]
    CodeThemeName(Box<theme::CodeThemeName<S>>),
    #[serde(rename = "sh.weaver.notebook.theme#codeThemeFile")]
    CodeThemeFile(Box<theme::CodeThemeFile<S>>),
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ThemeSpacing<S: BosStr = DefaultStr> {
    pub base_size: S,
    pub line_height: S,
    pub scale: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Typed wrapper for GetRecord response with this collection's record type.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ThemeGetRecordOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    pub uri: AtUri<S>,
    pub value: Theme<S>,
}

impl<S: BosStr> Theme<S> {
    pub fn uri(uri: S) -> Result<RecordUri<S, ThemeRecord>, UriError> {
        RecordUri::try_from_uri(AtUri::new(uri)?)
    }
}

impl<S: BosStr> LexiconSchema for CodeThemeFile<S> {
    fn nsid() -> &'static str {
        "sh.weaver.notebook.theme"
    }
    fn def_name() -> &'static str {
        "codeThemeFile"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_notebook_theme()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.content;
            {
                let size = value.blob().size;
                if size > 20000usize {
                    return Err(ConstraintError::BlobTooLarge {
                        path: ValidationPath::from_field("content"),
                        max: 20000usize,
                        actual: size,
                    });
                }
            }
        }
        {
            let value = &self.content;
            {
                let mime = value.blob().mime_type.as_str();
                let accepted: &[&str] = &["*/*"];
                let matched = accepted
                    .iter()
                    .any(|pattern| {
                        if *pattern == "*/*" {
                            true
                        } else if pattern.ends_with("/*") {
                            let prefix = &pattern[..pattern.len() - 2];
                            mime.starts_with(prefix)
                                && mime.as_bytes().get(prefix.len()) == Some(&b'/')
                        } else {
                            mime == *pattern
                        }
                    });
                if !matched {
                    return Err(ConstraintError::BlobMimeTypeNotAccepted {
                        path: ValidationPath::from_field("content"),
                        accepted: vec!["*/*".to_string()],
                        actual: mime.to_string(),
                    });
                }
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for Font<S> {
    fn nsid() -> &'static str {
        "sh.weaver.notebook.theme"
    }
    fn def_name() -> &'static str {
        "font"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_notebook_theme()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for FontFile<S> {
    fn nsid() -> &'static str {
        "sh.weaver.notebook.theme"
    }
    fn def_name() -> &'static str {
        "fontFile"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_notebook_theme()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.content;
            {
                let size = value.blob().size;
                if size > 20000usize {
                    return Err(ConstraintError::BlobTooLarge {
                        path: ValidationPath::from_field("content"),
                        max: 20000usize,
                        actual: size,
                    });
                }
            }
        }
        {
            let value = &self.content;
            {
                let mime = value.blob().mime_type.as_str();
                let accepted: &[&str] = &["*/*"];
                let matched = accepted
                    .iter()
                    .any(|pattern| {
                        if *pattern == "*/*" {
                            true
                        } else if pattern.ends_with("/*") {
                            let prefix = &pattern[..pattern.len() - 2];
                            mime.starts_with(prefix)
                                && mime.as_bytes().get(prefix.len()) == Some(&b'/')
                        } else {
                            mime == *pattern
                        }
                    });
                if !matched {
                    return Err(ConstraintError::BlobMimeTypeNotAccepted {
                        path: ValidationPath::from_field("content"),
                        accepted: vec!["*/*".to_string()],
                        actual: mime.to_string(),
                    });
                }
            }
        }
        Ok(())
    }
}

/// Marker type for deserializing records from this collection.

#[derive(Debug, Serialize, Deserialize)]
pub struct ThemeRecord;
impl XrpcResp for ThemeRecord {
    const NSID: &'static str = "sh.weaver.notebook.theme";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = ThemeGetRecordOutput<S>;
    type Err = RecordError;
}

impl<S: BosStr> From<ThemeGetRecordOutput<S>> for Theme<S> {
    fn from(output: ThemeGetRecordOutput<S>) -> Self {
        output.value
    }
}

impl<S: BosStr> Collection for Theme<S> {
    const NSID: &'static str = "sh.weaver.notebook.theme";
    type Record = ThemeRecord;
}

impl Collection for ThemeRecord {
    const NSID: &'static str = "sh.weaver.notebook.theme";
    type Record = ThemeRecord;
}

impl<S: BosStr> LexiconSchema for Theme<S> {
    fn nsid() -> &'static str {
        "sh.weaver.notebook.theme"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_notebook_theme()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod code_theme_file_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;
        type Did;
        type Name;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Content = Unset;
        type Did = Unset;
        type Name = Unset;
    }
    ///State transition - sets the `content` field to Set
    pub struct SetContent<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetContent<St> {}
    impl<St: State> State for SetContent<St> {
        type Content = Set<members::content>;
        type Did = St::Did;
        type Name = St::Name;
    }
    ///State transition - sets the `did` field to Set
    pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDid<St> {}
    impl<St: State> State for SetDid<St> {
        type Content = St::Content;
        type Did = Set<members::did>;
        type Name = St::Name;
    }
    ///State transition - sets the `name` field to Set
    pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetName<St> {}
    impl<St: State> State for SetName<St> {
        type Content = St::Content;
        type Did = St::Did;
        type Name = Set<members::name>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `content` field
        pub struct content(());
        ///Marker type for the `did` field
        pub struct did(());
        ///Marker type for the `name` field
        pub struct name(());
    }
}

/// Builder for constructing an instance of this type.
pub struct CodeThemeFileBuilder<
    St: code_theme_file_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<BlobRef<S>>, Option<Did<S>>, Option<S>),
    _type: PhantomData<fn() -> S>,
}

impl CodeThemeFile<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> CodeThemeFileBuilder<code_theme_file_state::Empty, DefaultStr> {
        CodeThemeFileBuilder::new()
    }
}

impl<S: BosStr> CodeThemeFile<S> {
    /// Create a new builder for this type
    pub fn builder() -> CodeThemeFileBuilder<code_theme_file_state::Empty, S> {
        CodeThemeFileBuilder::builder()
    }
}

impl CodeThemeFileBuilder<code_theme_file_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        CodeThemeFileBuilder {
            _state: PhantomData,
            _fields: (None, None, None),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> CodeThemeFileBuilder<code_theme_file_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        CodeThemeFileBuilder {
            _state: PhantomData,
            _fields: (None, None, None),
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> CodeThemeFileBuilder<St, S>
where
    St: code_theme_file_state::State,
    St::Content: code_theme_file_state::IsUnset,
{
    /// Set the `content` field (required)
    pub fn content(
        mut self,
        value: impl Into<BlobRef<S>>,
    ) -> CodeThemeFileBuilder<code_theme_file_state::SetContent<St>, S> {
        self._fields.0 = Option::Some(value.into());
        CodeThemeFileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> CodeThemeFileBuilder<St, S>
where
    St: code_theme_file_state::State,
    St::Did: code_theme_file_state::IsUnset,
{
    /// Set the `did` field (required)
    pub fn did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> CodeThemeFileBuilder<code_theme_file_state::SetDid<St>, S> {
        self._fields.1 = Option::Some(value.into());
        CodeThemeFileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> CodeThemeFileBuilder<St, S>
where
    St: code_theme_file_state::State,
    St::Name: code_theme_file_state::IsUnset,
{
    /// Set the `name` field (required)
    pub fn name(
        mut self,
        value: impl Into<S>,
    ) -> CodeThemeFileBuilder<code_theme_file_state::SetName<St>, S> {
        self._fields.2 = Option::Some(value.into());
        CodeThemeFileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> CodeThemeFileBuilder<St, S>
where
    St: code_theme_file_state::State,
    St::Content: code_theme_file_state::IsSet,
    St::Did: code_theme_file_state::IsSet,
    St::Name: code_theme_file_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> CodeThemeFile<S> {
        CodeThemeFile {
            content: self._fields.0.unwrap(),
            did: self._fields.1.unwrap(),
            name: self._fields.2.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> CodeThemeFile<S> {
        CodeThemeFile {
            content: self._fields.0.unwrap(),
            did: self._fields.1.unwrap(),
            name: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_sh_weaver_notebook_theme() -> 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("sh.weaver.notebook.theme"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("codeThemeFile"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Custom syntax highlighting theme file (sublime text/textmate theme format)",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("name"), SmolStr::new_static("did"),
                            SmolStr::new_static("content")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("content"),
                            LexObjectProperty::Blob(LexBlob { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("did"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("codeThemeName"),
                LexUserType::String(LexString { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("font"),
                LexUserType::Object(LexObject {
                    required: Some(vec![SmolStr::new_static("value")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("value"),
                            LexObjectProperty::Union(LexRefUnion {
                                description: Some(
                                    CowStr::new_static("Font for a notebook"),
                                ),
                                refs: vec![
                                    CowStr::new_static("#fontName"),
                                    CowStr::new_static("#fontFile")
                                ],
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("fontFile"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Custom woff(2) or ttf font file"),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("name"), SmolStr::new_static("did"),
                            SmolStr::new_static("content")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("content"),
                            LexObjectProperty::Blob(LexBlob { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("did"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("fontName"),
                LexUserType::String(LexString { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(CowStr::new_static("Theme for a notebook")),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("darkScheme"),
                                SmolStr::new_static("lightScheme"),
                                SmolStr::new_static("fonts"),
                                SmolStr::new_static("spacing"),
                                SmolStr::new_static("darkCodeTheme"),
                                SmolStr::new_static("lightCodeTheme")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("darkCodeTheme"),
                                LexObjectProperty::Union(LexRefUnion {
                                    description: Some(
                                        CowStr::new_static(
                                            "Syntax highlighting theme for dark mode",
                                        ),
                                    ),
                                    refs: vec![
                                        CowStr::new_static("#codeThemeName"),
                                        CowStr::new_static("#codeThemeFile")
                                    ],
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("darkScheme"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("defaultTheme"),
                                LexObjectProperty::String(LexString {
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("fonts"),
                                LexObjectProperty::Object(LexObject {
                                    description: Some(
                                        CowStr::new_static(
                                            "Fonts to be used in the notebook. Can specify a name or list of names (will load if available) or a file or list of files for each. Empty lists will use site defaults.",
                                        ),
                                    ),
                                    required: Some(
                                        vec![
                                            SmolStr::new_static("body"), SmolStr::new_static("heading"),
                                            SmolStr::new_static("monospace")
                                        ],
                                    ),
                                    properties: {
                                        #[allow(unused_mut)]
                                        let mut map = BTreeMap::new();
                                        map.insert(
                                            SmolStr::new_static("body"),
                                            LexObjectProperty::Array(LexArray {
                                                items: LexArrayItem::Ref(LexRef {
                                                    r#ref: CowStr::new_static("#font"),
                                                    ..Default::default()
                                                }),
                                                ..Default::default()
                                            }),
                                        );
                                        map.insert(
                                            SmolStr::new_static("heading"),
                                            LexObjectProperty::Array(LexArray {
                                                items: LexArrayItem::Ref(LexRef {
                                                    r#ref: CowStr::new_static("#font"),
                                                    ..Default::default()
                                                }),
                                                ..Default::default()
                                            }),
                                        );
                                        map.insert(
                                            SmolStr::new_static("monospace"),
                                            LexObjectProperty::Array(LexArray {
                                                items: LexArrayItem::Ref(LexRef {
                                                    r#ref: CowStr::new_static("#font"),
                                                    ..Default::default()
                                                }),
                                                ..Default::default()
                                            }),
                                        );
                                        map
                                    },
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("lightCodeTheme"),
                                LexObjectProperty::Union(LexRefUnion {
                                    description: Some(
                                        CowStr::new_static(
                                            "Syntax highlighting theme for light mode",
                                        ),
                                    ),
                                    refs: vec![
                                        CowStr::new_static("#codeThemeName"),
                                        CowStr::new_static("#codeThemeFile")
                                    ],
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("lightScheme"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("spacing"),
                                LexObjectProperty::Object(LexObject {
                                    required: Some(
                                        vec![
                                            SmolStr::new_static("baseSize"),
                                            SmolStr::new_static("lineHeight"),
                                            SmolStr::new_static("scale")
                                        ],
                                    ),
                                    properties: {
                                        #[allow(unused_mut)]
                                        let mut map = BTreeMap::new();
                                        map.insert(
                                            SmolStr::new_static("baseSize"),
                                            LexObjectProperty::String(LexString {
                                                ..Default::default()
                                            }),
                                        );
                                        map.insert(
                                            SmolStr::new_static("lineHeight"),
                                            LexObjectProperty::String(LexString {
                                                ..Default::default()
                                            }),
                                        );
                                        map.insert(
                                            SmolStr::new_static("scale"),
                                            LexObjectProperty::String(LexString {
                                                ..Default::default()
                                            }),
                                        );
                                        map
                                    },
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod font_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 Value;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Value = Unset;
    }
    ///State transition - sets the `value` field to Set
    pub struct SetValue<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetValue<St> {}
    impl<St: State> State for SetValue<St> {
        type Value = Set<members::value>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `value` field
        pub struct value(());
    }
}

/// Builder for constructing an instance of this type.
pub struct FontBuilder<St: font_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<FontValue<S>>,),
    _type: PhantomData<fn() -> S>,
}

impl Font<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> FontBuilder<font_state::Empty, DefaultStr> {
        FontBuilder::new()
    }
}

impl<S: BosStr> Font<S> {
    /// Create a new builder for this type
    pub fn builder() -> FontBuilder<font_state::Empty, S> {
        FontBuilder::builder()
    }
}

impl FontBuilder<font_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        FontBuilder {
            _state: PhantomData,
            _fields: (None,),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> FontBuilder<font_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        FontBuilder {
            _state: PhantomData,
            _fields: (None,),
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> FontBuilder<St, S>
where
    St: font_state::State,
    St::Value: font_state::IsUnset,
{
    /// Set the `value` field (required)
    pub fn value(
        mut self,
        value: impl Into<FontValue<S>>,
    ) -> FontBuilder<font_state::SetValue<St>, S> {
        self._fields.0 = Option::Some(value.into());
        FontBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> FontBuilder<St, S>
where
    St: font_state::State,
    St::Value: font_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Font<S> {
        Font {
            value: 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<SmolStr, Data<S>>) -> Font<S> {
        Font {
            value: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod font_file_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;
        type Did;
        type Name;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Content = Unset;
        type Did = Unset;
        type Name = Unset;
    }
    ///State transition - sets the `content` field to Set
    pub struct SetContent<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetContent<St> {}
    impl<St: State> State for SetContent<St> {
        type Content = Set<members::content>;
        type Did = St::Did;
        type Name = St::Name;
    }
    ///State transition - sets the `did` field to Set
    pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDid<St> {}
    impl<St: State> State for SetDid<St> {
        type Content = St::Content;
        type Did = Set<members::did>;
        type Name = St::Name;
    }
    ///State transition - sets the `name` field to Set
    pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetName<St> {}
    impl<St: State> State for SetName<St> {
        type Content = St::Content;
        type Did = St::Did;
        type Name = Set<members::name>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `content` field
        pub struct content(());
        ///Marker type for the `did` field
        pub struct did(());
        ///Marker type for the `name` field
        pub struct name(());
    }
}

/// Builder for constructing an instance of this type.
pub struct FontFileBuilder<St: font_file_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<BlobRef<S>>, Option<Did<S>>, Option<S>),
    _type: PhantomData<fn() -> S>,
}

impl FontFile<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> FontFileBuilder<font_file_state::Empty, DefaultStr> {
        FontFileBuilder::new()
    }
}

impl<S: BosStr> FontFile<S> {
    /// Create a new builder for this type
    pub fn builder() -> FontFileBuilder<font_file_state::Empty, S> {
        FontFileBuilder::builder()
    }
}

impl FontFileBuilder<font_file_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        FontFileBuilder {
            _state: PhantomData,
            _fields: (None, None, None),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> FontFileBuilder<font_file_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        FontFileBuilder {
            _state: PhantomData,
            _fields: (None, None, None),
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> FontFileBuilder<St, S>
where
    St: font_file_state::State,
    St::Content: font_file_state::IsUnset,
{
    /// Set the `content` field (required)
    pub fn content(
        mut self,
        value: impl Into<BlobRef<S>>,
    ) -> FontFileBuilder<font_file_state::SetContent<St>, S> {
        self._fields.0 = Option::Some(value.into());
        FontFileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> FontFileBuilder<St, S>
where
    St: font_file_state::State,
    St::Did: font_file_state::IsUnset,
{
    /// Set the `did` field (required)
    pub fn did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> FontFileBuilder<font_file_state::SetDid<St>, S> {
        self._fields.1 = Option::Some(value.into());
        FontFileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> FontFileBuilder<St, S>
where
    St: font_file_state::State,
    St::Name: font_file_state::IsUnset,
{
    /// Set the `name` field (required)
    pub fn name(
        mut self,
        value: impl Into<S>,
    ) -> FontFileBuilder<font_file_state::SetName<St>, S> {
        self._fields.2 = Option::Some(value.into());
        FontFileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> FontFileBuilder<St, S>
where
    St: font_file_state::State,
    St::Content: font_file_state::IsSet,
    St::Did: font_file_state::IsSet,
    St::Name: font_file_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> FontFile<S> {
        FontFile {
            content: self._fields.0.unwrap(),
            did: self._fields.1.unwrap(),
            name: self._fields.2.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> FontFile<S> {
        FontFile {
            content: self._fields.0.unwrap(),
            did: self._fields.1.unwrap(),
            name: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn _default_theme_default_theme<S: FromStaticStr>() -> ::core::option::Option<S> {
    Some(S::from_static("auto"))
}

impl<S: BosStr> LexiconSchema for ThemeFonts<S> {
    fn nsid() -> &'static str {
        "sh.weaver.notebook.theme"
    }
    fn def_name() -> &'static str {
        "ThemeFonts"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_notebook_theme()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod theme_fonts_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 Body;
        type Heading;
        type Monospace;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Body = Unset;
        type Heading = Unset;
        type Monospace = Unset;
    }
    ///State transition - sets the `body` field to Set
    pub struct SetBody<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetBody<St> {}
    impl<St: State> State for SetBody<St> {
        type Body = Set<members::body>;
        type Heading = St::Heading;
        type Monospace = St::Monospace;
    }
    ///State transition - sets the `heading` field to Set
    pub struct SetHeading<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetHeading<St> {}
    impl<St: State> State for SetHeading<St> {
        type Body = St::Body;
        type Heading = Set<members::heading>;
        type Monospace = St::Monospace;
    }
    ///State transition - sets the `monospace` field to Set
    pub struct SetMonospace<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetMonospace<St> {}
    impl<St: State> State for SetMonospace<St> {
        type Body = St::Body;
        type Heading = St::Heading;
        type Monospace = Set<members::monospace>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `body` field
        pub struct body(());
        ///Marker type for the `heading` field
        pub struct heading(());
        ///Marker type for the `monospace` field
        pub struct monospace(());
    }
}

/// Builder for constructing an instance of this type.
pub struct ThemeFontsBuilder<St: theme_fonts_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<Vec<crate::sh_weaver::notebook::theme::Font<S>>>,
        Option<Vec<crate::sh_weaver::notebook::theme::Font<S>>>,
        Option<Vec<crate::sh_weaver::notebook::theme::Font<S>>>,
    ),
    _type: PhantomData<fn() -> S>,
}

impl ThemeFonts<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> ThemeFontsBuilder<theme_fonts_state::Empty, DefaultStr> {
        ThemeFontsBuilder::new()
    }
}

impl<S: BosStr> ThemeFonts<S> {
    /// Create a new builder for this type
    pub fn builder() -> ThemeFontsBuilder<theme_fonts_state::Empty, S> {
        ThemeFontsBuilder::builder()
    }
}

impl ThemeFontsBuilder<theme_fonts_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        ThemeFontsBuilder {
            _state: PhantomData,
            _fields: (None, None, None),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> ThemeFontsBuilder<theme_fonts_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        ThemeFontsBuilder {
            _state: PhantomData,
            _fields: (None, None, None),
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ThemeFontsBuilder<St, S>
where
    St: theme_fonts_state::State,
    St::Body: theme_fonts_state::IsUnset,
{
    /// Set the `body` field (required)
    pub fn body(
        mut self,
        value: impl Into<Vec<crate::sh_weaver::notebook::theme::Font<S>>>,
    ) -> ThemeFontsBuilder<theme_fonts_state::SetBody<St>, S> {
        self._fields.0 = Option::Some(value.into());
        ThemeFontsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ThemeFontsBuilder<St, S>
where
    St: theme_fonts_state::State,
    St::Heading: theme_fonts_state::IsUnset,
{
    /// Set the `heading` field (required)
    pub fn heading(
        mut self,
        value: impl Into<Vec<crate::sh_weaver::notebook::theme::Font<S>>>,
    ) -> ThemeFontsBuilder<theme_fonts_state::SetHeading<St>, S> {
        self._fields.1 = Option::Some(value.into());
        ThemeFontsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ThemeFontsBuilder<St, S>
where
    St: theme_fonts_state::State,
    St::Monospace: theme_fonts_state::IsUnset,
{
    /// Set the `monospace` field (required)
    pub fn monospace(
        mut self,
        value: impl Into<Vec<crate::sh_weaver::notebook::theme::Font<S>>>,
    ) -> ThemeFontsBuilder<theme_fonts_state::SetMonospace<St>, S> {
        self._fields.2 = Option::Some(value.into());
        ThemeFontsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ThemeFontsBuilder<St, S>
where
    St: theme_fonts_state::State,
    St::Body: theme_fonts_state::IsSet,
    St::Heading: theme_fonts_state::IsSet,
    St::Monospace: theme_fonts_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ThemeFonts<S> {
        ThemeFonts {
            body: self._fields.0.unwrap(),
            heading: self._fields.1.unwrap(),
            monospace: self._fields.2.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> ThemeFonts<S> {
        ThemeFonts {
            body: self._fields.0.unwrap(),
            heading: self._fields.1.unwrap(),
            monospace: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

impl<S: BosStr> LexiconSchema for ThemeSpacing<S> {
    fn nsid() -> &'static str {
        "sh.weaver.notebook.theme"
    }
    fn def_name() -> &'static str {
        "ThemeSpacing"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_notebook_theme()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod theme_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 DarkCodeTheme;
        type DarkScheme;
        type Fonts;
        type LightCodeTheme;
        type LightScheme;
        type Spacing;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type DarkCodeTheme = Unset;
        type DarkScheme = Unset;
        type Fonts = Unset;
        type LightCodeTheme = Unset;
        type LightScheme = Unset;
        type Spacing = Unset;
    }
    ///State transition - sets the `dark_code_theme` field to Set
    pub struct SetDarkCodeTheme<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDarkCodeTheme<St> {}
    impl<St: State> State for SetDarkCodeTheme<St> {
        type DarkCodeTheme = Set<members::dark_code_theme>;
        type DarkScheme = St::DarkScheme;
        type Fonts = St::Fonts;
        type LightCodeTheme = St::LightCodeTheme;
        type LightScheme = St::LightScheme;
        type Spacing = St::Spacing;
    }
    ///State transition - sets the `dark_scheme` field to Set
    pub struct SetDarkScheme<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDarkScheme<St> {}
    impl<St: State> State for SetDarkScheme<St> {
        type DarkCodeTheme = St::DarkCodeTheme;
        type DarkScheme = Set<members::dark_scheme>;
        type Fonts = St::Fonts;
        type LightCodeTheme = St::LightCodeTheme;
        type LightScheme = St::LightScheme;
        type Spacing = St::Spacing;
    }
    ///State transition - sets the `fonts` field to Set
    pub struct SetFonts<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetFonts<St> {}
    impl<St: State> State for SetFonts<St> {
        type DarkCodeTheme = St::DarkCodeTheme;
        type DarkScheme = St::DarkScheme;
        type Fonts = Set<members::fonts>;
        type LightCodeTheme = St::LightCodeTheme;
        type LightScheme = St::LightScheme;
        type Spacing = St::Spacing;
    }
    ///State transition - sets the `light_code_theme` field to Set
    pub struct SetLightCodeTheme<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetLightCodeTheme<St> {}
    impl<St: State> State for SetLightCodeTheme<St> {
        type DarkCodeTheme = St::DarkCodeTheme;
        type DarkScheme = St::DarkScheme;
        type Fonts = St::Fonts;
        type LightCodeTheme = Set<members::light_code_theme>;
        type LightScheme = St::LightScheme;
        type Spacing = St::Spacing;
    }
    ///State transition - sets the `light_scheme` field to Set
    pub struct SetLightScheme<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetLightScheme<St> {}
    impl<St: State> State for SetLightScheme<St> {
        type DarkCodeTheme = St::DarkCodeTheme;
        type DarkScheme = St::DarkScheme;
        type Fonts = St::Fonts;
        type LightCodeTheme = St::LightCodeTheme;
        type LightScheme = Set<members::light_scheme>;
        type Spacing = St::Spacing;
    }
    ///State transition - sets the `spacing` field to Set
    pub struct SetSpacing<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSpacing<St> {}
    impl<St: State> State for SetSpacing<St> {
        type DarkCodeTheme = St::DarkCodeTheme;
        type DarkScheme = St::DarkScheme;
        type Fonts = St::Fonts;
        type LightCodeTheme = St::LightCodeTheme;
        type LightScheme = St::LightScheme;
        type Spacing = Set<members::spacing>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `dark_code_theme` field
        pub struct dark_code_theme(());
        ///Marker type for the `dark_scheme` field
        pub struct dark_scheme(());
        ///Marker type for the `fonts` field
        pub struct fonts(());
        ///Marker type for the `light_code_theme` field
        pub struct light_code_theme(());
        ///Marker type for the `light_scheme` field
        pub struct light_scheme(());
        ///Marker type for the `spacing` field
        pub struct spacing(());
    }
}

/// Builder for constructing an instance of this type.
pub struct ThemeBuilder<St: theme_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<ThemeDarkCodeTheme<S>>,
        Option<StrongRef<S>>,
        Option<S>,
        Option<ThemeFonts<S>>,
        Option<ThemeLightCodeTheme<S>>,
        Option<StrongRef<S>>,
        Option<ThemeSpacing<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

impl Theme<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> ThemeBuilder<theme_state::Empty, DefaultStr> {
        ThemeBuilder::new()
    }
}

impl<S: BosStr> Theme<S> {
    /// Create a new builder for this type
    pub fn builder() -> ThemeBuilder<theme_state::Empty, S> {
        ThemeBuilder::builder()
    }
}

impl ThemeBuilder<theme_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        ThemeBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None, None, None),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> ThemeBuilder<theme_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        ThemeBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None, None, None),
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ThemeBuilder<St, S>
where
    St: theme_state::State,
    St::DarkCodeTheme: theme_state::IsUnset,
{
    /// Set the `darkCodeTheme` field (required)
    pub fn dark_code_theme(
        mut self,
        value: impl Into<ThemeDarkCodeTheme<S>>,
    ) -> ThemeBuilder<theme_state::SetDarkCodeTheme<St>, S> {
        self._fields.0 = Option::Some(value.into());
        ThemeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ThemeBuilder<St, S>
where
    St: theme_state::State,
    St::DarkScheme: theme_state::IsUnset,
{
    /// Set the `darkScheme` field (required)
    pub fn dark_scheme(
        mut self,
        value: impl Into<StrongRef<S>>,
    ) -> ThemeBuilder<theme_state::SetDarkScheme<St>, S> {
        self._fields.1 = Option::Some(value.into());
        ThemeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: theme_state::State, S: BosStr> ThemeBuilder<St, S> {
    /// Set the `defaultTheme` field (optional)
    pub fn default_theme(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `defaultTheme` field to an Option value (optional)
    pub fn maybe_default_theme(mut self, value: Option<S>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St, S: BosStr> ThemeBuilder<St, S>
where
    St: theme_state::State,
    St::Fonts: theme_state::IsUnset,
{
    /// Set the `fonts` field (required)
    pub fn fonts(
        mut self,
        value: impl Into<ThemeFonts<S>>,
    ) -> ThemeBuilder<theme_state::SetFonts<St>, S> {
        self._fields.3 = Option::Some(value.into());
        ThemeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ThemeBuilder<St, S>
where
    St: theme_state::State,
    St::LightCodeTheme: theme_state::IsUnset,
{
    /// Set the `lightCodeTheme` field (required)
    pub fn light_code_theme(
        mut self,
        value: impl Into<ThemeLightCodeTheme<S>>,
    ) -> ThemeBuilder<theme_state::SetLightCodeTheme<St>, S> {
        self._fields.4 = Option::Some(value.into());
        ThemeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ThemeBuilder<St, S>
where
    St: theme_state::State,
    St::LightScheme: theme_state::IsUnset,
{
    /// Set the `lightScheme` field (required)
    pub fn light_scheme(
        mut self,
        value: impl Into<StrongRef<S>>,
    ) -> ThemeBuilder<theme_state::SetLightScheme<St>, S> {
        self._fields.5 = Option::Some(value.into());
        ThemeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ThemeBuilder<St, S>
where
    St: theme_state::State,
    St::Spacing: theme_state::IsUnset,
{
    /// Set the `spacing` field (required)
    pub fn spacing(
        mut self,
        value: impl Into<ThemeSpacing<S>>,
    ) -> ThemeBuilder<theme_state::SetSpacing<St>, S> {
        self._fields.6 = Option::Some(value.into());
        ThemeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ThemeBuilder<St, S>
where
    St: theme_state::State,
    St::DarkCodeTheme: theme_state::IsSet,
    St::DarkScheme: theme_state::IsSet,
    St::Fonts: theme_state::IsSet,
    St::LightCodeTheme: theme_state::IsSet,
    St::LightScheme: theme_state::IsSet,
    St::Spacing: theme_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Theme<S> {
        Theme {
            dark_code_theme: self._fields.0.unwrap(),
            dark_scheme: self._fields.1.unwrap(),
            default_theme: self._fields.2.or_else(|| Some(S::from_static("auto"))),
            fonts: self._fields.3.unwrap(),
            light_code_theme: self._fields.4.unwrap(),
            light_scheme: self._fields.5.unwrap(),
            spacing: self._fields.6.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Theme<S> {
        Theme {
            dark_code_theme: self._fields.0.unwrap(),
            dark_scheme: self._fields.1.unwrap(),
            default_theme: self._fields.2.or_else(|| Some(S::from_static("auto"))),
            fonts: self._fields.3.unwrap(),
            light_code_theme: self._fields.4.unwrap(),
            light_scheme: self._fields.5.unwrap(),
            spacing: self._fields.6.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}