// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: net.anisota.beta.game.collection
//
// 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::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};
use crate::net_anisota::beta::game::collection;
/// Beta version: Record representing a collected specimen in a player's collection

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "net.anisota.beta.game.collection",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Collection<S: BosStr = DefaultStr> {
    ///When the specimen was first acquired
    pub acquired_at: Datetime,
    ///Common name of the specimen
    #[serde(skip_serializing_if = "Option::is_none")]
    pub common_name: Option<S>,
    ///When the record was created
    pub created_at: Datetime,
    ///Taxonomic family
    #[serde(skip_serializing_if = "Option::is_none")]
    pub family: Option<S>,
    ///Taxonomic genus
    #[serde(skip_serializing_if = "Option::is_none")]
    pub genus: Option<S>,
    ///When the record was last modified
    #[serde(skip_serializing_if = "Option::is_none")]
    pub last_modified: Option<Datetime>,
    ///When the specimen was last encountered
    #[serde(skip_serializing_if = "Option::is_none")]
    pub last_seen: Option<Datetime>,
    ///URI of the game.log record that documents the acquisition of this specimen
    #[serde(skip_serializing_if = "Option::is_none")]
    pub log_record_uri: Option<S>,
    ///Number of specimens collected
    pub quantity: i64,
    ///Rarity level of the specimen
    #[serde(skip_serializing_if = "Option::is_none")]
    pub rarity: Option<S>,
    ///Scientific name of the specimen
    #[serde(skip_serializing_if = "Option::is_none")]
    pub scientific_name: Option<S>,
    ///How the specimen was acquired
    #[serde(skip_serializing_if = "Option::is_none")]
    pub source: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub source_details: Option<collection::SourceDetails<S>>,
    ///Taxonomic species
    #[serde(skip_serializing_if = "Option::is_none")]
    pub species: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub specimen_data: Option<collection::SpecimenData<S>>,
    ///Unique identifier for the specimen
    pub specimen_id: S,
    ///Collection status of this specimen
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status: Option<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

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

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

/// Additional details about how the specimen was acquired

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SourceDetails<S: BosStr = DefaultStr> {
    ///Number of attempts before successful capture
    #[serde(skip_serializing_if = "Option::is_none")]
    pub attempts: Option<i64>,
    ///Probability used when catching this specimen (decimal string, e.g. '0.75')
    #[serde(skip_serializing_if = "Option::is_none")]
    pub catch_probability: Option<S>,
    ///URI of the game card that provided this specimen
    #[serde(skip_serializing_if = "Option::is_none")]
    pub game_card_uri: Option<S>,
    ///Location where specimen was found or observed
    #[serde(skip_serializing_if = "Option::is_none")]
    pub location: Option<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Complete specimen information

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SpecimenData<S: BosStr = DefaultStr> {
    ///Scientific authorship of the species
    #[serde(skip_serializing_if = "Option::is_none")]
    pub authorship: Option<S>,
    ///Detailed description of the specimen
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

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

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

#[derive(Debug, Serialize, Deserialize)]
pub struct CollectionRecord;
impl XrpcResp for CollectionRecord {
    const NSID: &'static str = "net.anisota.beta.game.collection";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = CollectionGetRecordOutput<S>;
    type Err = RecordError;
}

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

impl<S: BosStr> jacquard_common::types::collection::Collection for Collection<S> {
    const NSID: &'static str = "net.anisota.beta.game.collection";
    type Record = CollectionRecord;
}

impl jacquard_common::types::collection::Collection for CollectionRecord {
    const NSID: &'static str = "net.anisota.beta.game.collection";
    type Record = CollectionRecord;
}

impl<S: BosStr> LexiconSchema for Collection<S> {
    fn nsid() -> &'static str {
        "net.anisota.beta.game.collection"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_net_anisota_beta_game_collection()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.common_name {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 200usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("common_name"),
                    max: 200usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.family {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("family"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.genus {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("genus"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.quantity;
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("quantity"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.scientific_name {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 200usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("scientific_name"),
                    max: 200usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.species {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("species"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.specimen_id;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("specimen_id"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for SourceDetails<S> {
    fn nsid() -> &'static str {
        "net.anisota.beta.game.collection"
    }
    fn def_name() -> &'static str {
        "sourceDetails"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_net_anisota_beta_game_collection()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for SpecimenData<S> {
    fn nsid() -> &'static str {
        "net.anisota.beta.game.collection"
    }
    fn def_name() -> &'static str {
        "specimenData"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_net_anisota_beta_game_collection()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod collection_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 AcquiredAt;
        type CreatedAt;
        type Quantity;
        type SpecimenId;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type AcquiredAt = Unset;
        type CreatedAt = Unset;
        type Quantity = Unset;
        type SpecimenId = Unset;
    }
    ///State transition - sets the `acquired_at` field to Set
    pub struct SetAcquiredAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetAcquiredAt<St> {}
    impl<St: State> State for SetAcquiredAt<St> {
        type AcquiredAt = Set<members::acquired_at>;
        type CreatedAt = St::CreatedAt;
        type Quantity = St::Quantity;
        type SpecimenId = St::SpecimenId;
    }
    ///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 AcquiredAt = St::AcquiredAt;
        type CreatedAt = Set<members::created_at>;
        type Quantity = St::Quantity;
        type SpecimenId = St::SpecimenId;
    }
    ///State transition - sets the `quantity` field to Set
    pub struct SetQuantity<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetQuantity<St> {}
    impl<St: State> State for SetQuantity<St> {
        type AcquiredAt = St::AcquiredAt;
        type CreatedAt = St::CreatedAt;
        type Quantity = Set<members::quantity>;
        type SpecimenId = St::SpecimenId;
    }
    ///State transition - sets the `specimen_id` field to Set
    pub struct SetSpecimenId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSpecimenId<St> {}
    impl<St: State> State for SetSpecimenId<St> {
        type AcquiredAt = St::AcquiredAt;
        type CreatedAt = St::CreatedAt;
        type Quantity = St::Quantity;
        type SpecimenId = Set<members::specimen_id>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `acquired_at` field
        pub struct acquired_at(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `quantity` field
        pub struct quantity(());
        ///Marker type for the `specimen_id` field
        pub struct specimen_id(());
    }
}

/// Builder for constructing an instance of this type.
pub struct CollectionBuilder<St: collection_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<Datetime>,
        Option<S>,
        Option<Datetime>,
        Option<S>,
        Option<S>,
        Option<Datetime>,
        Option<Datetime>,
        Option<S>,
        Option<i64>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<collection::SourceDetails<S>>,
        Option<S>,
        Option<collection::SpecimenData<S>>,
        Option<S>,
        Option<S>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> Collection<S> {
    /// Create a new builder for this type
    pub fn builder() -> CollectionBuilder<collection_state::Empty, S> {
        CollectionBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> CollectionBuilder<St, S>
where
    St: collection_state::State,
    St::AcquiredAt: collection_state::IsUnset,
{
    /// Set the `acquiredAt` field (required)
    pub fn acquired_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> CollectionBuilder<collection_state::SetAcquiredAt<St>, S> {
        self._fields.0 = Option::Some(value.into());
        CollectionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: collection_state::State, S: BosStr> CollectionBuilder<St, S> {
    /// Set the `commonName` field (optional)
    pub fn common_name(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `commonName` field to an Option value (optional)
    pub fn maybe_common_name(mut self, value: Option<S>) -> Self {
        self._fields.1 = value;
        self
    }
}

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

impl<St: collection_state::State, S: BosStr> CollectionBuilder<St, S> {
    /// Set the `family` field (optional)
    pub fn family(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `family` field to an Option value (optional)
    pub fn maybe_family(mut self, value: Option<S>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St: collection_state::State, S: BosStr> CollectionBuilder<St, S> {
    /// Set the `genus` field (optional)
    pub fn genus(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `genus` field to an Option value (optional)
    pub fn maybe_genus(mut self, value: Option<S>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<St: collection_state::State, S: BosStr> CollectionBuilder<St, S> {
    /// Set the `lastModified` field (optional)
    pub fn last_modified(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `lastModified` field to an Option value (optional)
    pub fn maybe_last_modified(mut self, value: Option<Datetime>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St: collection_state::State, S: BosStr> CollectionBuilder<St, S> {
    /// Set the `lastSeen` field (optional)
    pub fn last_seen(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `lastSeen` field to an Option value (optional)
    pub fn maybe_last_seen(mut self, value: Option<Datetime>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<St: collection_state::State, S: BosStr> CollectionBuilder<St, S> {
    /// Set the `logRecordUri` field (optional)
    pub fn log_record_uri(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `logRecordUri` field to an Option value (optional)
    pub fn maybe_log_record_uri(mut self, value: Option<S>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<St, S: BosStr> CollectionBuilder<St, S>
where
    St: collection_state::State,
    St::Quantity: collection_state::IsUnset,
{
    /// Set the `quantity` field (required)
    pub fn quantity(
        mut self,
        value: impl Into<i64>,
    ) -> CollectionBuilder<collection_state::SetQuantity<St>, S> {
        self._fields.8 = Option::Some(value.into());
        CollectionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St: collection_state::State, S: BosStr> CollectionBuilder<St, S> {
    /// Set the `scientificName` field (optional)
    pub fn scientific_name(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `scientificName` field to an Option value (optional)
    pub fn maybe_scientific_name(mut self, value: Option<S>) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<St: collection_state::State, S: BosStr> CollectionBuilder<St, S> {
    /// Set the `source` field (optional)
    pub fn source(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.11 = value.into();
        self
    }
    /// Set the `source` field to an Option value (optional)
    pub fn maybe_source(mut self, value: Option<S>) -> Self {
        self._fields.11 = value;
        self
    }
}

impl<St: collection_state::State, S: BosStr> CollectionBuilder<St, S> {
    /// Set the `sourceDetails` field (optional)
    pub fn source_details(
        mut self,
        value: impl Into<Option<collection::SourceDetails<S>>>,
    ) -> Self {
        self._fields.12 = value.into();
        self
    }
    /// Set the `sourceDetails` field to an Option value (optional)
    pub fn maybe_source_details(
        mut self,
        value: Option<collection::SourceDetails<S>>,
    ) -> Self {
        self._fields.12 = value;
        self
    }
}

impl<St: collection_state::State, S: BosStr> CollectionBuilder<St, S> {
    /// Set the `species` field (optional)
    pub fn species(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.13 = value.into();
        self
    }
    /// Set the `species` field to an Option value (optional)
    pub fn maybe_species(mut self, value: Option<S>) -> Self {
        self._fields.13 = value;
        self
    }
}

impl<St: collection_state::State, S: BosStr> CollectionBuilder<St, S> {
    /// Set the `specimenData` field (optional)
    pub fn specimen_data(
        mut self,
        value: impl Into<Option<collection::SpecimenData<S>>>,
    ) -> Self {
        self._fields.14 = value.into();
        self
    }
    /// Set the `specimenData` field to an Option value (optional)
    pub fn maybe_specimen_data(
        mut self,
        value: Option<collection::SpecimenData<S>>,
    ) -> Self {
        self._fields.14 = value;
        self
    }
}

impl<St, S: BosStr> CollectionBuilder<St, S>
where
    St: collection_state::State,
    St::SpecimenId: collection_state::IsUnset,
{
    /// Set the `specimenId` field (required)
    pub fn specimen_id(
        mut self,
        value: impl Into<S>,
    ) -> CollectionBuilder<collection_state::SetSpecimenId<St>, S> {
        self._fields.15 = Option::Some(value.into());
        CollectionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: collection_state::State, S: BosStr> CollectionBuilder<St, S> {
    /// Set the `status` field (optional)
    pub fn status(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.16 = value.into();
        self
    }
    /// Set the `status` field to an Option value (optional)
    pub fn maybe_status(mut self, value: Option<S>) -> Self {
        self._fields.16 = value;
        self
    }
}

impl<St, S: BosStr> CollectionBuilder<St, S>
where
    St: collection_state::State,
    St::AcquiredAt: collection_state::IsSet,
    St::CreatedAt: collection_state::IsSet,
    St::Quantity: collection_state::IsSet,
    St::SpecimenId: collection_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Collection<S> {
        Collection {
            acquired_at: self._fields.0.unwrap(),
            common_name: self._fields.1,
            created_at: self._fields.2.unwrap(),
            family: self._fields.3,
            genus: self._fields.4,
            last_modified: self._fields.5,
            last_seen: self._fields.6,
            log_record_uri: self._fields.7,
            quantity: self._fields.8.unwrap(),
            rarity: self._fields.9,
            scientific_name: self._fields.10,
            source: self._fields.11,
            source_details: self._fields.12,
            species: self._fields.13,
            specimen_data: self._fields.14,
            specimen_id: self._fields.15.unwrap(),
            status: self._fields.16,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> Collection<S> {
        Collection {
            acquired_at: self._fields.0.unwrap(),
            common_name: self._fields.1,
            created_at: self._fields.2.unwrap(),
            family: self._fields.3,
            genus: self._fields.4,
            last_modified: self._fields.5,
            last_seen: self._fields.6,
            log_record_uri: self._fields.7,
            quantity: self._fields.8.unwrap(),
            rarity: self._fields.9,
            scientific_name: self._fields.10,
            source: self._fields.11,
            source_details: self._fields.12,
            species: self._fields.13,
            specimen_data: self._fields.14,
            specimen_id: self._fields.15.unwrap(),
            status: self._fields.16,
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_net_anisota_beta_game_collection() -> 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("net.anisota.beta.game.collection"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static(
                            "Beta version: Record representing a collected specimen in a player's collection",
                        ),
                    ),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("specimenId"),
                                SmolStr::new_static("quantity"),
                                SmolStr::new_static("acquiredAt"),
                                SmolStr::new_static("createdAt")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("acquiredAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("When the specimen was first acquired"),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("commonName"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Common name of the specimen"),
                                    ),
                                    max_length: Some(200usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("When the record was created"),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("family"),
                                LexObjectProperty::String(LexString {
                                    description: Some(CowStr::new_static("Taxonomic family")),
                                    max_length: Some(100usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("genus"),
                                LexObjectProperty::String(LexString {
                                    description: Some(CowStr::new_static("Taxonomic genus")),
                                    max_length: Some(100usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("lastModified"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("When the record was last modified"),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("lastSeen"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("When the specimen was last encountered"),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("logRecordUri"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "URI of the game.log record that documents the acquisition of this specimen",
                                        ),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("quantity"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("rarity"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Rarity level of the specimen"),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("scientificName"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Scientific name of the specimen"),
                                    ),
                                    max_length: Some(200usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("source"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("How the specimen was acquired"),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("sourceDetails"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("#sourceDetails"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("species"),
                                LexObjectProperty::String(LexString {
                                    description: Some(CowStr::new_static("Taxonomic species")),
                                    max_length: Some(100usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("specimenData"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("#specimenData"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("specimenId"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Unique identifier for the specimen"),
                                    ),
                                    max_length: Some(100usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("status"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Collection status of this specimen"),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("sourceDetails"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Additional details about how the specimen was acquired",
                        ),
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("attempts"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("catchProbability"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Probability used when catching this specimen (decimal string, e.g. '0.75')",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("gameCardUri"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "URI of the game card that provided this specimen",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("location"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Location where specimen was found or observed",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("specimenData"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Complete specimen information"),
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("authorship"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Scientific authorship of the species"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("description"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Detailed description of the specimen"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}