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

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
/// A colour palette for notebook theming

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ColourScheme<'a> {
    #[serde(borrow)]
    pub colours: ColourSchemeColours<'a>,
    ///Human-readable name for the colour scheme
    #[serde(borrow)]
    pub name: CowStr<'a>,
    ///Whether this is a dark or light colour scheme
    #[serde(borrow)]
    pub variant: CowStr<'a>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct ColourSchemeColours<'a> {
    ///Primary background for page/frame
    #[serde(borrow)]
    pub base: CowStr<'a>,
    ///Border/divider colour
    #[serde(borrow)]
    pub border: CowStr<'a>,
    ///Emphasized text (bold, important)
    #[serde(borrow)]
    pub emphasis: CowStr<'a>,
    ///Error state colour
    #[serde(borrow)]
    pub error: CowStr<'a>,
    ///Selection/highlight colour
    #[serde(borrow)]
    pub highlight: CowStr<'a>,
    ///Hyperlink colour
    #[serde(borrow)]
    pub link: CowStr<'a>,
    ///De-emphasized text (disabled, metadata)
    #[serde(borrow)]
    pub muted: CowStr<'a>,
    ///Tertiary background for popovers/dialogs
    #[serde(borrow)]
    pub overlay: CowStr<'a>,
    ///Primary brand/accent colour
    #[serde(borrow)]
    pub primary: CowStr<'a>,
    ///Secondary accent colour
    #[serde(borrow)]
    pub secondary: CowStr<'a>,
    ///Medium emphasis text (comments, labels)
    #[serde(borrow)]
    pub subtle: CowStr<'a>,
    ///Success state colour
    #[serde(borrow)]
    pub success: CowStr<'a>,
    ///Secondary background for panels/cards
    #[serde(borrow)]
    pub surface: CowStr<'a>,
    ///Tertiary accent colour
    #[serde(borrow)]
    pub tertiary: CowStr<'a>,
    ///Primary readable text colour
    #[serde(borrow)]
    pub text: CowStr<'a>,
    ///Warning state colour
    #[serde(borrow)]
    pub warning: CowStr<'a>,
}

/// 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 ColourSchemeGetRecordOutput<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub cid: Option<Cid<'a>>,
    #[serde(borrow)]
    pub uri: AtUri<'a>,
    #[serde(borrow)]
    pub value: ColourScheme<'a>,
}

impl<'a> ColourScheme<'a> {
    pub fn uri(
        uri: impl Into<CowStr<'a>>,
    ) -> Result<RecordUri<'a, ColourSchemeRecord>, UriError> {
        RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
    }
}

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

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

impl From<ColourSchemeGetRecordOutput<'_>> for ColourScheme<'_> {
    fn from(output: ColourSchemeGetRecordOutput<'_>) -> Self {
        use jacquard_common::IntoStatic;
        output.value.into_static()
    }
}

impl Collection for ColourScheme<'_> {
    const NSID: &'static str = "sh.weaver.notebook.colourScheme";
    type Record = ColourSchemeRecord;
}

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

impl<'a> LexiconSchema for ColourScheme<'a> {
    fn nsid() -> &'static str {
        "sh.weaver.notebook.colourScheme"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_notebook_colourScheme()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for ColourSchemeColours<'a> {
    fn nsid() -> &'static str {
        "sh.weaver.notebook.colourScheme"
    }
    fn def_name() -> &'static str {
        "ColourSchemeColours"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_notebook_colourScheme()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

fn lexicon_doc_sh_weaver_notebook_colourScheme() -> 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.colourScheme"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static("A colour palette for notebook theming"),
                    ),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("name"), SmolStr::new_static("variant"),
                                SmolStr::new_static("colours")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("colours"),
                                LexObjectProperty::Object(LexObject {
                                    required: Some(
                                        vec![
                                            SmolStr::new_static("base"), SmolStr::new_static("surface"),
                                            SmolStr::new_static("overlay"), SmolStr::new_static("text"),
                                            SmolStr::new_static("muted"), SmolStr::new_static("subtle"),
                                            SmolStr::new_static("emphasis"),
                                            SmolStr::new_static("primary"),
                                            SmolStr::new_static("secondary"),
                                            SmolStr::new_static("tertiary"),
                                            SmolStr::new_static("error"),
                                            SmolStr::new_static("warning"),
                                            SmolStr::new_static("success"),
                                            SmolStr::new_static("border"), SmolStr::new_static("link"),
                                            SmolStr::new_static("highlight")
                                        ],
                                    ),
                                    properties: {
                                        #[allow(unused_mut)]
                                        let mut map = BTreeMap::new();
                                        map.insert(
                                            SmolStr::new_static("base"),
                                            LexObjectProperty::String(LexString {
                                                description: Some(
                                                    CowStr::new_static("Primary background for page/frame"),
                                                ),
                                                ..Default::default()
                                            }),
                                        );
                                        map.insert(
                                            SmolStr::new_static("border"),
                                            LexObjectProperty::String(LexString {
                                                description: Some(
                                                    CowStr::new_static("Border/divider colour"),
                                                ),
                                                ..Default::default()
                                            }),
                                        );
                                        map.insert(
                                            SmolStr::new_static("emphasis"),
                                            LexObjectProperty::String(LexString {
                                                description: Some(
                                                    CowStr::new_static("Emphasized text (bold, important)"),
                                                ),
                                                ..Default::default()
                                            }),
                                        );
                                        map.insert(
                                            SmolStr::new_static("error"),
                                            LexObjectProperty::String(LexString {
                                                description: Some(CowStr::new_static("Error state colour")),
                                                ..Default::default()
                                            }),
                                        );
                                        map.insert(
                                            SmolStr::new_static("highlight"),
                                            LexObjectProperty::String(LexString {
                                                description: Some(
                                                    CowStr::new_static("Selection/highlight colour"),
                                                ),
                                                ..Default::default()
                                            }),
                                        );
                                        map.insert(
                                            SmolStr::new_static("link"),
                                            LexObjectProperty::String(LexString {
                                                description: Some(CowStr::new_static("Hyperlink colour")),
                                                ..Default::default()
                                            }),
                                        );
                                        map.insert(
                                            SmolStr::new_static("muted"),
                                            LexObjectProperty::String(LexString {
                                                description: Some(
                                                    CowStr::new_static(
                                                        "De-emphasized text (disabled, metadata)",
                                                    ),
                                                ),
                                                ..Default::default()
                                            }),
                                        );
                                        map.insert(
                                            SmolStr::new_static("overlay"),
                                            LexObjectProperty::String(LexString {
                                                description: Some(
                                                    CowStr::new_static(
                                                        "Tertiary background for popovers/dialogs",
                                                    ),
                                                ),
                                                ..Default::default()
                                            }),
                                        );
                                        map.insert(
                                            SmolStr::new_static("primary"),
                                            LexObjectProperty::String(LexString {
                                                description: Some(
                                                    CowStr::new_static("Primary brand/accent colour"),
                                                ),
                                                ..Default::default()
                                            }),
                                        );
                                        map.insert(
                                            SmolStr::new_static("secondary"),
                                            LexObjectProperty::String(LexString {
                                                description: Some(
                                                    CowStr::new_static("Secondary accent colour"),
                                                ),
                                                ..Default::default()
                                            }),
                                        );
                                        map.insert(
                                            SmolStr::new_static("subtle"),
                                            LexObjectProperty::String(LexString {
                                                description: Some(
                                                    CowStr::new_static(
                                                        "Medium emphasis text (comments, labels)",
                                                    ),
                                                ),
                                                ..Default::default()
                                            }),
                                        );
                                        map.insert(
                                            SmolStr::new_static("success"),
                                            LexObjectProperty::String(LexString {
                                                description: Some(
                                                    CowStr::new_static("Success state colour"),
                                                ),
                                                ..Default::default()
                                            }),
                                        );
                                        map.insert(
                                            SmolStr::new_static("surface"),
                                            LexObjectProperty::String(LexString {
                                                description: Some(
                                                    CowStr::new_static("Secondary background for panels/cards"),
                                                ),
                                                ..Default::default()
                                            }),
                                        );
                                        map.insert(
                                            SmolStr::new_static("tertiary"),
                                            LexObjectProperty::String(LexString {
                                                description: Some(
                                                    CowStr::new_static("Tertiary accent colour"),
                                                ),
                                                ..Default::default()
                                            }),
                                        );
                                        map.insert(
                                            SmolStr::new_static("text"),
                                            LexObjectProperty::String(LexString {
                                                description: Some(
                                                    CowStr::new_static("Primary readable text colour"),
                                                ),
                                                ..Default::default()
                                            }),
                                        );
                                        map.insert(
                                            SmolStr::new_static("warning"),
                                            LexObjectProperty::String(LexString {
                                                description: Some(
                                                    CowStr::new_static("Warning state colour"),
                                                ),
                                                ..Default::default()
                                            }),
                                        );
                                        map
                                    },
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("name"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Human-readable name for the colour scheme",
                                        ),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("variant"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Whether this is a dark or light colour scheme",
                                        ),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod colour_scheme_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 Colours;
        type Name;
        type Variant;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Colours = Unset;
        type Name = Unset;
        type Variant = Unset;
    }
    ///State transition - sets the `colours` field to Set
    pub struct SetColours<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetColours<S> {}
    impl<S: State> State for SetColours<S> {
        type Colours = Set<members::colours>;
        type Name = S::Name;
        type Variant = S::Variant;
    }
    ///State transition - sets the `name` field to Set
    pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetName<S> {}
    impl<S: State> State for SetName<S> {
        type Colours = S::Colours;
        type Name = Set<members::name>;
        type Variant = S::Variant;
    }
    ///State transition - sets the `variant` field to Set
    pub struct SetVariant<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetVariant<S> {}
    impl<S: State> State for SetVariant<S> {
        type Colours = S::Colours;
        type Name = S::Name;
        type Variant = Set<members::variant>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `colours` field
        pub struct colours(());
        ///Marker type for the `name` field
        pub struct name(());
        ///Marker type for the `variant` field
        pub struct variant(());
    }
}

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

impl<'a> ColourScheme<'a> {
    /// Create a new builder for this type
    pub fn new() -> ColourSchemeBuilder<'a, colour_scheme_state::Empty> {
        ColourSchemeBuilder::new()
    }
}

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

impl<'a, S> ColourSchemeBuilder<'a, S>
where
    S: colour_scheme_state::State,
    S::Colours: colour_scheme_state::IsUnset,
{
    /// Set the `colours` field (required)
    pub fn colours(
        mut self,
        value: impl Into<ColourSchemeColours<'a>>,
    ) -> ColourSchemeBuilder<'a, colour_scheme_state::SetColours<S>> {
        self._fields.0 = Option::Some(value.into());
        ColourSchemeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ColourSchemeBuilder<'a, S>
where
    S: colour_scheme_state::State,
    S::Name: colour_scheme_state::IsUnset,
{
    /// Set the `name` field (required)
    pub fn name(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> ColourSchemeBuilder<'a, colour_scheme_state::SetName<S>> {
        self._fields.1 = Option::Some(value.into());
        ColourSchemeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ColourSchemeBuilder<'a, S>
where
    S: colour_scheme_state::State,
    S::Variant: colour_scheme_state::IsUnset,
{
    /// Set the `variant` field (required)
    pub fn variant(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> ColourSchemeBuilder<'a, colour_scheme_state::SetVariant<S>> {
        self._fields.2 = Option::Some(value.into());
        ColourSchemeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ColourSchemeBuilder<'a, S>
where
    S: colour_scheme_state::State,
    S::Colours: colour_scheme_state::IsSet,
    S::Name: colour_scheme_state::IsSet,
    S::Variant: colour_scheme_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> ColourScheme<'a> {
        ColourScheme {
            colours: self._fields.0.unwrap(),
            name: self._fields.1.unwrap(),
            variant: 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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> ColourScheme<'a> {
        ColourScheme {
            colours: self._fields.0.unwrap(),
            name: self._fields.1.unwrap(),
            variant: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}