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

//! Generated bindings for the `org.simocracy` Lexicon namespace/module.
pub mod agents;
pub mod event;
pub mod interview;
pub mod senate;
pub mod sim;
pub mod skill;
pub mod style;
pub mod vote;


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

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{BosStr, DefaultStr, FromStaticStr};

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

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SpriteSettings<S: BosStr = DefaultStr> {
    ///0=right, 1=back, 2=left, 3=front
    #[serde(skip_serializing_if = "Option::is_none")]
    pub current_anim_direction: Option<i64>,
    ///Map of part name -> {red, green, blue, alpha}
    #[serde(skip_serializing_if = "Option::is_none")]
    pub part_color_settings: Option<Data<S>>,
    ///Map of part name -> sprite path
    pub selected_options: Data<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for SpriteSettings<S> {
    fn nsid() -> &'static str {
        "org.simocracy.defs"
    }
    fn def_name() -> &'static str {
        "spriteSettings"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_org_simocracy_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

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

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

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

impl<S: BosStr> SpriteSettings<S> {
    /// Create a new builder for this type
    pub fn builder() -> SpriteSettingsBuilder<sprite_settings_state::Empty, S> {
        SpriteSettingsBuilder::builder()
    }
}

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

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

impl<St: sprite_settings_state::State, S: BosStr> SpriteSettingsBuilder<St, S> {
    /// Set the `currentAnimDirection` field (optional)
    pub fn current_anim_direction(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `currentAnimDirection` field to an Option value (optional)
    pub fn maybe_current_anim_direction(mut self, value: Option<i64>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St: sprite_settings_state::State, S: BosStr> SpriteSettingsBuilder<St, S> {
    /// Set the `partColorSettings` field (optional)
    pub fn part_color_settings(mut self, value: impl Into<Option<Data<S>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `partColorSettings` field to an Option value (optional)
    pub fn maybe_part_color_settings(mut self, value: Option<Data<S>>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St, S: BosStr> SpriteSettingsBuilder<St, S>
where
    St: sprite_settings_state::State,
    St::SelectedOptions: sprite_settings_state::IsUnset,
{
    /// Set the `selectedOptions` field (required)
    pub fn selected_options(
        mut self,
        value: impl Into<Data<S>>,
    ) -> SpriteSettingsBuilder<sprite_settings_state::SetSelectedOptions<St>, S> {
        self._fields.2 = Option::Some(value.into());
        SpriteSettingsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SpriteSettingsBuilder<St, S>
where
    St: sprite_settings_state::State,
    St::SelectedOptions: sprite_settings_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> SpriteSettings<S> {
        SpriteSettings {
            current_anim_direction: self._fields.0,
            part_color_settings: self._fields.1,
            selected_options: 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>>,
    ) -> SpriteSettings<S> {
        SpriteSettings {
            current_anim_direction: self._fields.0,
            part_color_settings: self._fields.1,
            selected_options: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_org_simocracy_defs() -> 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("org.simocracy.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("spriteSettings"),
                LexUserType::Object(LexObject {
                    required: Some(vec![SmolStr::new_static("selectedOptions")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("currentAnimDirection"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("partColorSettings"),
                            LexObjectProperty::Unknown(LexUnknown {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("selectedOptions"),
                            LexObjectProperty::Unknown(LexUnknown {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}