// @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;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
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::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).

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Sprite<'a> {
    ///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.
    #[serde(borrow)]
    pub engine: SpriteEngine<'a>,
    ///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")]
    #[serde(borrow)]
    pub name: Option<CowStr<'a>>,
    ///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.
    #[serde(borrow)]
    pub sprite_sheet: BlobRef<'a>,
    ///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>,
}

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

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum SpriteEngine<'a> {
    Rmmz,
    Rmmv,
    Rpgmaker2003,
    Custom,
    Other(CowStr<'a>),
}

impl<'a> SpriteEngine<'a> {
    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(),
        }
    }
}

impl<'a> From<&'a str> for SpriteEngine<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "rmmz" => Self::Rmmz,
            "rmmv" => Self::Rmmv,
            "rpgmaker2003" => Self::Rpgmaker2003,
            "custom" => Self::Custom,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for SpriteEngine<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "rmmz" => Self::Rmmz,
            "rmmv" => Self::Rmmv,
            "rpgmaker2003" => Self::Rpgmaker2003,
            "custom" => Self::Custom,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

impl<'a> AsRef<str> for SpriteEngine<'a> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

impl<'de, 'a> serde::Deserialize<'de> for SpriteEngine<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for SpriteEngine<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for SpriteEngine<'_> {
    type Output = SpriteEngine<'static>;
    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<'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: Sprite<'a>,
}

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

/// 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<'de> = SpriteGetRecordOutput<'de>;
    type Err<'de> = RecordError<'de>;
}

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

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

/// Builder for constructing an instance of this type
pub struct SpriteBuilder<'a, S: sprite_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<i64>,
        Option<i64>,
        Option<Datetime>,
        Option<SpriteEngine<'a>>,
        Option<i64>,
        Option<i64>,
        Option<i64>,
        Option<i64>,
        Option<CowStr<'a>>,
        Option<i64>,
        Option<BlobRef<'a>>,
        Option<Datetime>,
        Option<i64>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

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

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

impl<'a, S: sprite_state::State> SpriteBuilder<'a, 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<'a, S: sprite_state::State> SpriteBuilder<'a, 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<'a, S> SpriteBuilder<'a, S>
where
    S: sprite_state::State,
    S::CreatedAt: sprite_state::IsUnset,
{
    /// Set the `createdAt` field (required)
    pub fn created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> SpriteBuilder<'a, sprite_state::SetCreatedAt<S>> {
        self._fields.2 = Option::Some(value.into());
        SpriteBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

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

impl<'a, S: sprite_state::State> SpriteBuilder<'a, 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<'a, S: sprite_state::State> SpriteBuilder<'a, 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<'a, S: sprite_state::State> SpriteBuilder<'a, 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<'a, S: sprite_state::State> SpriteBuilder<'a, 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<'a, S: sprite_state::State> SpriteBuilder<'a, S> {
    /// Set the `name` field (optional)
    pub fn name(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `name` field to an Option value (optional)
    pub fn maybe_name(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<'a, S: sprite_state::State> SpriteBuilder<'a, 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<'a, S> SpriteBuilder<'a, S>
where
    S: sprite_state::State,
    S::SpriteSheet: sprite_state::IsUnset,
{
    /// Set the `spriteSheet` field (required)
    pub fn sprite_sheet(
        mut self,
        value: impl Into<BlobRef<'a>>,
    ) -> SpriteBuilder<'a, sprite_state::SetSpriteSheet<S>> {
        self._fields.10 = Option::Some(value.into());
        SpriteBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: sprite_state::State> SpriteBuilder<'a, 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<'a, S: sprite_state::State> SpriteBuilder<'a, 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<'a, S> SpriteBuilder<'a, S>
where
    S: sprite_state::State,
    S::Engine: sprite_state::IsSet,
    S::CreatedAt: sprite_state::IsSet,
    S::SpriteSheet: sprite_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Sprite<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> Sprite<'a> {
        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()
    }
}