// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: actor.rpg.sprite
//
// 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::{AtUri, Cid, Datetime};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
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 user's RPG character sprite. One record per user (rkey: self).

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "actor.rpg.sprite",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Sprite<S: BosStr = DefaultStr> {
    ///Milliseconds per frame for animation playback  Defaults to `200`.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default = "_default_sprite_animation_speed")]
    pub animation_speed: Option<i64>,
    ///Number of columns per animation cycle
    #[serde(skip_serializing_if = "Option::is_none")]
    pub columns: Option<i64>,
    ///When this record was first created
    pub created_at: Datetime,
    ///The game engine format this sprite is designed for. Determines animation interpretation.
    pub engine: SpriteEngine<S>,
    ///Height of a single frame in pixels (if not auto-calculated from height/rows)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub frame_height: Option<i64>,
    ///Width of a single frame in pixels (if not auto-calculated from width/columns)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub frame_width: Option<i64>,
    ///Total number of animation frames
    #[serde(skip_serializing_if = "Option::is_none")]
    pub frames: Option<i64>,
    ///Total height of the sprite sheet in pixels
    #[serde(skip_serializing_if = "Option::is_none")]
    pub height: Option<i64>,
    ///Display name for the character (optional, can differ from Bluesky display name)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<S>,
    ///Number of rows in the sprite sheet (typically 4 for directional sprites: down, left, right, up)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub rows: Option<i64>,
    ///The sprite sheet image (PNG only). Max 10MB.
    pub sprite_sheet: BlobRef<S>,
    ///When this record was last modified
    #[serde(skip_serializing_if = "Option::is_none")]
    pub updated_at: Option<Datetime>,
    ///Total width of the sprite sheet in pixels
    #[serde(skip_serializing_if = "Option::is_none")]
    pub width: Option<i64>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// The game engine format this sprite is designed for. Determines animation interpretation.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum SpriteEngine<S: BosStr = DefaultStr> {
    Rmmz,
    Rmmv,
    Rpgmaker2003,
    Custom,
    Other(S),
}

impl<S: BosStr> SpriteEngine<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Rmmz => "rmmz",
            Self::Rmmv => "rmmv",
            Self::Rpgmaker2003 => "rpgmaker2003",
            Self::Custom => "custom",
            Self::Other(s) => s.as_ref(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "rmmz" => Self::Rmmz,
            "rmmv" => Self::Rmmv,
            "rpgmaker2003" => Self::Rpgmaker2003,
            "custom" => Self::Custom,
            _ => Self::Other(s),
        }
    }
}

impl<S: BosStr> core::fmt::Display for SpriteEngine<S> {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "{}", self.as_str())
    }
}

impl<S: BosStr> AsRef<str> for SpriteEngine<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl<S: BosStr> Serialize for SpriteEngine<S> {
    fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
    where
        Ser: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for SpriteEngine<S> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = S::deserialize(deserializer)?;
        Ok(Self::from_value(s))
    }
}

impl<S: BosStr + Default> Default for SpriteEngine<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for SpriteEngine<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = SpriteEngine<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            SpriteEngine::Rmmz => SpriteEngine::Rmmz,
            SpriteEngine::Rmmv => SpriteEngine::Rmmv,
            SpriteEngine::Rpgmaker2003 => SpriteEngine::Rpgmaker2003,
            SpriteEngine::Custom => SpriteEngine::Custom,
            SpriteEngine::Other(v) => SpriteEngine::Other(v.into_static()),
        }
    }
}

/// 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 SpriteGetRecordOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    pub uri: AtUri<S>,
    pub value: Sprite<S>,
}

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

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

#[derive(Debug, Serialize, Deserialize)]
pub struct SpriteRecord;
impl XrpcResp for SpriteRecord {
    const NSID: &'static str = "actor.rpg.sprite";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = SpriteGetRecordOutput<S>;
    type Err = RecordError;
}

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

impl<S: BosStr> Collection for Sprite<S> {
    const NSID: &'static str = "actor.rpg.sprite";
    type Record = SpriteRecord;
}

impl Collection for SpriteRecord {
    const NSID: &'static str = "actor.rpg.sprite";
    type Record = SpriteRecord;
}

impl<S: BosStr> LexiconSchema for Sprite<S> {
    fn nsid() -> &'static str {
        "actor.rpg.sprite"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_actor_rpg_sprite()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.animation_speed {
            if *value > 2000i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("animation_speed"),
                    max: 2000i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.animation_speed {
            if *value < 50i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("animation_speed"),
                    min: 50i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.columns {
            if *value > 16i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("columns"),
                    max: 16i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.columns {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("columns"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.frame_height {
            if *value > 512i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("frame_height"),
                    max: 512i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.frame_height {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("frame_height"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.frame_width {
            if *value > 512i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("frame_width"),
                    max: 512i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.frame_width {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("frame_width"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.frames {
            if *value > 64i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("frames"),
                    max: 64i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.frames {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("frames"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.height {
            if *value > 4096i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("height"),
                    max: 4096i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.height {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("height"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.name {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("name"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.name {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 50usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("name"),
                        max: 50usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.rows {
            if *value > 16i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("rows"),
                    max: 16i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.rows {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("rows"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.sprite_sheet;
            {
                let size = value.blob().size;
                if size > 10000000usize {
                    return Err(ConstraintError::BlobTooLarge {
                        path: ValidationPath::from_field("sprite_sheet"),
                        max: 10000000usize,
                        actual: size,
                    });
                }
            }
        }
        {
            let value = &self.sprite_sheet;
            {
                let mime = value.blob().mime_type.as_str();
                let accepted: &[&str] = &["image/png"];
                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("sprite_sheet"),
                        accepted: vec!["image/png".to_string()],
                        actual: mime.to_string(),
                    });
                }
            }
        }
        if let Some(ref value) = self.width {
            if *value > 4096i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("width"),
                    max: 4096i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.width {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("width"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

fn _default_sprite_animation_speed() -> Option<i64> {
    Some(200i64)
}

pub mod sprite_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 CreatedAt;
        type Engine;
        type SpriteSheet;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type CreatedAt = Unset;
        type Engine = Unset;
        type SpriteSheet = Unset;
    }
    ///State transition - sets the `created_at` field to Set
    pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
    impl<St: State> State for SetCreatedAt<St> {
        type CreatedAt = Set<members::created_at>;
        type Engine = St::Engine;
        type SpriteSheet = St::SpriteSheet;
    }
    ///State transition - sets the `engine` field to Set
    pub struct SetEngine<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetEngine<St> {}
    impl<St: State> State for SetEngine<St> {
        type CreatedAt = St::CreatedAt;
        type Engine = Set<members::engine>;
        type SpriteSheet = St::SpriteSheet;
    }
    ///State transition - sets the `sprite_sheet` field to Set
    pub struct SetSpriteSheet<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSpriteSheet<St> {}
    impl<St: State> State for SetSpriteSheet<St> {
        type CreatedAt = St::CreatedAt;
        type Engine = St::Engine;
        type SpriteSheet = Set<members::sprite_sheet>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `engine` field
        pub struct engine(());
        ///Marker type for the `sprite_sheet` field
        pub struct sprite_sheet(());
    }
}

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

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

impl<S: BosStr> Sprite<S> {
    /// Create a new builder for this type
    pub fn builder() -> SpriteBuilder<sprite_state::Empty, S> {
        SpriteBuilder::builder()
    }
}

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

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

impl<St: sprite_state::State, S: BosStr> SpriteBuilder<St, S> {
    /// Set the `animationSpeed` field (optional)
    pub fn animation_speed(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `animationSpeed` field to an Option value (optional)
    pub fn maybe_animation_speed(mut self, value: Option<i64>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St: sprite_state::State, S: BosStr> SpriteBuilder<St, S> {
    /// Set the `columns` field (optional)
    pub fn columns(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `columns` field to an Option value (optional)
    pub fn maybe_columns(mut self, value: Option<i64>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St, S: BosStr> SpriteBuilder<St, S>
where
    St: sprite_state::State,
    St::CreatedAt: sprite_state::IsUnset,
{
    /// Set the `createdAt` field (required)
    pub fn created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> SpriteBuilder<sprite_state::SetCreatedAt<St>, S> {
        self._fields.2 = Option::Some(value.into());
        SpriteBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SpriteBuilder<St, S>
where
    St: sprite_state::State,
    St::Engine: sprite_state::IsUnset,
{
    /// Set the `engine` field (required)
    pub fn engine(
        mut self,
        value: impl Into<SpriteEngine<S>>,
    ) -> SpriteBuilder<sprite_state::SetEngine<St>, S> {
        self._fields.3 = Option::Some(value.into());
        SpriteBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: sprite_state::State, S: BosStr> SpriteBuilder<St, S> {
    /// Set the `frameHeight` field (optional)
    pub fn frame_height(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `frameHeight` field to an Option value (optional)
    pub fn maybe_frame_height(mut self, value: Option<i64>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<St: sprite_state::State, S: BosStr> SpriteBuilder<St, S> {
    /// Set the `frameWidth` field (optional)
    pub fn frame_width(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `frameWidth` field to an Option value (optional)
    pub fn maybe_frame_width(mut self, value: Option<i64>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St: sprite_state::State, S: BosStr> SpriteBuilder<St, S> {
    /// Set the `frames` field (optional)
    pub fn frames(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `frames` field to an Option value (optional)
    pub fn maybe_frames(mut self, value: Option<i64>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<St: sprite_state::State, S: BosStr> SpriteBuilder<St, S> {
    /// Set the `height` field (optional)
    pub fn height(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `height` field to an Option value (optional)
    pub fn maybe_height(mut self, value: Option<i64>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<St: sprite_state::State, S: BosStr> SpriteBuilder<St, S> {
    /// Set the `name` field (optional)
    pub fn name(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `name` field to an Option value (optional)
    pub fn maybe_name(mut self, value: Option<S>) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<St: sprite_state::State, S: BosStr> SpriteBuilder<St, S> {
    /// Set the `rows` field (optional)
    pub fn rows(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `rows` field to an Option value (optional)
    pub fn maybe_rows(mut self, value: Option<i64>) -> Self {
        self._fields.9 = value;
        self
    }
}

impl<St, S: BosStr> SpriteBuilder<St, S>
where
    St: sprite_state::State,
    St::SpriteSheet: sprite_state::IsUnset,
{
    /// Set the `spriteSheet` field (required)
    pub fn sprite_sheet(
        mut self,
        value: impl Into<BlobRef<S>>,
    ) -> SpriteBuilder<sprite_state::SetSpriteSheet<St>, S> {
        self._fields.10 = Option::Some(value.into());
        SpriteBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: sprite_state::State, S: BosStr> SpriteBuilder<St, S> {
    /// Set the `updatedAt` field (optional)
    pub fn updated_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.11 = value.into();
        self
    }
    /// Set the `updatedAt` field to an Option value (optional)
    pub fn maybe_updated_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.11 = value;
        self
    }
}

impl<St: sprite_state::State, S: BosStr> SpriteBuilder<St, S> {
    /// Set the `width` field (optional)
    pub fn width(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.12 = value.into();
        self
    }
    /// Set the `width` field to an Option value (optional)
    pub fn maybe_width(mut self, value: Option<i64>) -> Self {
        self._fields.12 = value;
        self
    }
}

impl<St, S: BosStr> SpriteBuilder<St, S>
where
    St: sprite_state::State,
    St::CreatedAt: sprite_state::IsSet,
    St::Engine: sprite_state::IsSet,
    St::SpriteSheet: sprite_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Sprite<S> {
        Sprite {
            animation_speed: self._fields.0.or_else(|| Some(200i64)),
            columns: self._fields.1,
            created_at: self._fields.2.unwrap(),
            engine: self._fields.3.unwrap(),
            frame_height: self._fields.4,
            frame_width: self._fields.5,
            frames: self._fields.6,
            height: self._fields.7,
            name: self._fields.8,
            rows: self._fields.9,
            sprite_sheet: self._fields.10.unwrap(),
            updated_at: self._fields.11,
            width: self._fields.12,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Sprite<S> {
        Sprite {
            animation_speed: self._fields.0.or_else(|| Some(200i64)),
            columns: self._fields.1,
            created_at: self._fields.2.unwrap(),
            engine: self._fields.3.unwrap(),
            frame_height: self._fields.4,
            frame_width: self._fields.5,
            frames: self._fields.6,
            height: self._fields.7,
            name: self._fields.8,
            rows: self._fields.9,
            sprite_sheet: self._fields.10.unwrap(),
            updated_at: self._fields.11,
            width: self._fields.12,
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_actor_rpg_sprite() -> 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("actor.rpg.sprite"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static(
                            "A user's RPG character sprite. One record per user (rkey: self).",
                        ),
                    ),
                    key: Some(CowStr::new_static("literal:self")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("spriteSheet"),
                                SmolStr::new_static("engine"),
                                SmolStr::new_static("createdAt")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("animationSpeed"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(50i64),
                                    maximum: Some(2000i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("columns"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    maximum: Some(16i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("When this record was first created"),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("engine"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The game engine format this sprite is designed for. Determines animation interpretation.",
                                        ),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("frameHeight"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    maximum: Some(512i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("frameWidth"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    maximum: Some(512i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("frames"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    maximum: Some(64i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("height"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    maximum: Some(4096i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("name"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Display name for the character (optional, can differ from Bluesky display name)",
                                        ),
                                    ),
                                    max_length: Some(100usize),
                                    max_graphemes: Some(50usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("rows"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    maximum: Some(16i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("spriteSheet"),
                                LexObjectProperty::Blob(LexBlob { ..Default::default() }),
                            );
                            map.insert(
                                SmolStr::new_static("updatedAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("When this record was last modified"),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("width"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    maximum: Some(4096i64),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}