// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: net.anisota.harvest.minigame
//
// 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::{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::harvest::minigame;
/// A record of a harvest minigame round played by a user

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "net.anisota.harvest.minigame",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Minigame<S: BosStr = DefaultStr> {
    ///Version of the Anisota client
    #[serde(skip_serializing_if = "Option::is_none")]
    pub client_version: Option<S>,
    ///When the record was created
    #[serde(skip_serializing_if = "Option::is_none")]
    pub created_at: Option<Datetime>,
    ///Number of shapes harvested early (during growth phase)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub early_harvests: Option<i64>,
    ///Bonus points awarded for harvest efficiency (percentage of shapes collected)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub efficiency_bonus: Option<i64>,
    ///Final score achieved in the round
    pub final_score: i64,
    ///Where the game was played: dedicated minigame page or harvest loading screen
    pub game_context: S,
    ///Number of shapes harvested late (during decay phase)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub late_harvests: Option<i64>,
    ///Percentage indicating how close on average the user harvested at peak timing (scaled by 100, so 9550 = 95.50%)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub peak_harvest_rate: Option<i64>,
    ///Bonus points awarded for achieving high peak harvest rate
    #[serde(skip_serializing_if = "Option::is_none")]
    pub peak_rate_bonus: Option<i64>,
    ///Number of shapes harvested at perfect (peak) timing
    #[serde(skip_serializing_if = "Option::is_none")]
    pub perfect_harvests: Option<i64>,
    ///When the game round was played (ISO 8601)
    pub played_at: Datetime,
    ///Average rate of points scored per second (scaled by 100, so 123 = 1.23 points/second)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub points_per_second: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub rarity_breakdown: Option<minigame::RarityBreakdown<S>>,
    ///Duration of the round in seconds
    pub round_duration: i64,
    ///Total number of shapes collected/harvested
    pub shapes_collected: i64,
    ///Total number of shapes that expired without being harvested
    #[serde(skip_serializing_if = "Option::is_none")]
    pub shapes_missed: Option<i64>,
    ///Total number of shapes spawned during the round (collected + missed)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_shapes_spawned: Option<i64>,
    #[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 MinigameGetRecordOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    pub uri: AtUri<S>,
    pub value: Minigame<S>,
}

/// Count of each rarity level collected

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct RarityBreakdown<S: BosStr = DefaultStr> {
    ///Number of common (triangle) shapes collected
    #[serde(skip_serializing_if = "Option::is_none")]
    pub common: Option<i64>,
    ///Number of rare (star) shapes collected
    #[serde(skip_serializing_if = "Option::is_none")]
    pub rare: Option<i64>,
    ///Number of uncommon (diamond) shapes collected
    #[serde(skip_serializing_if = "Option::is_none")]
    pub uncommon: Option<i64>,
    ///Number of very common (circle) shapes collected
    #[serde(skip_serializing_if = "Option::is_none")]
    pub very_common: Option<i64>,
    ///Number of very rare (sparkle) shapes collected
    #[serde(skip_serializing_if = "Option::is_none")]
    pub very_rare: Option<i64>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

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

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

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

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

impl<S: BosStr> Collection for Minigame<S> {
    const NSID: &'static str = "net.anisota.harvest.minigame";
    type Record = MinigameRecord;
}

impl Collection for MinigameRecord {
    const NSID: &'static str = "net.anisota.harvest.minigame";
    type Record = MinigameRecord;
}

impl<S: BosStr> LexiconSchema for Minigame<S> {
    fn nsid() -> &'static str {
        "net.anisota.harvest.minigame"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_net_anisota_harvest_minigame()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.early_harvests {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("early_harvests"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.efficiency_bonus {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("efficiency_bonus"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.final_score;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("final_score"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.late_harvests {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("late_harvests"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.peak_harvest_rate {
            if *value > 10000i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("peak_harvest_rate"),
                    max: 10000i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.peak_harvest_rate {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("peak_harvest_rate"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.peak_rate_bonus {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("peak_rate_bonus"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.perfect_harvests {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("perfect_harvests"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.points_per_second {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("points_per_second"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.round_duration;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("round_duration"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.shapes_collected;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("shapes_collected"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.shapes_missed {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("shapes_missed"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.total_shapes_spawned {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("total_shapes_spawned"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for RarityBreakdown<S> {
    fn nsid() -> &'static str {
        "net.anisota.harvest.minigame"
    }
    fn def_name() -> &'static str {
        "rarityBreakdown"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_net_anisota_harvest_minigame()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.common {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("common"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.rare {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("rare"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.uncommon {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("uncommon"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.very_common {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("very_common"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.very_rare {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("very_rare"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

pub mod minigame_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 FinalScore;
        type GameContext;
        type PlayedAt;
        type RoundDuration;
        type ShapesCollected;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type FinalScore = Unset;
        type GameContext = Unset;
        type PlayedAt = Unset;
        type RoundDuration = Unset;
        type ShapesCollected = Unset;
    }
    ///State transition - sets the `final_score` field to Set
    pub struct SetFinalScore<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetFinalScore<St> {}
    impl<St: State> State for SetFinalScore<St> {
        type FinalScore = Set<members::final_score>;
        type GameContext = St::GameContext;
        type PlayedAt = St::PlayedAt;
        type RoundDuration = St::RoundDuration;
        type ShapesCollected = St::ShapesCollected;
    }
    ///State transition - sets the `game_context` field to Set
    pub struct SetGameContext<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetGameContext<St> {}
    impl<St: State> State for SetGameContext<St> {
        type FinalScore = St::FinalScore;
        type GameContext = Set<members::game_context>;
        type PlayedAt = St::PlayedAt;
        type RoundDuration = St::RoundDuration;
        type ShapesCollected = St::ShapesCollected;
    }
    ///State transition - sets the `played_at` field to Set
    pub struct SetPlayedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetPlayedAt<St> {}
    impl<St: State> State for SetPlayedAt<St> {
        type FinalScore = St::FinalScore;
        type GameContext = St::GameContext;
        type PlayedAt = Set<members::played_at>;
        type RoundDuration = St::RoundDuration;
        type ShapesCollected = St::ShapesCollected;
    }
    ///State transition - sets the `round_duration` field to Set
    pub struct SetRoundDuration<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRoundDuration<St> {}
    impl<St: State> State for SetRoundDuration<St> {
        type FinalScore = St::FinalScore;
        type GameContext = St::GameContext;
        type PlayedAt = St::PlayedAt;
        type RoundDuration = Set<members::round_duration>;
        type ShapesCollected = St::ShapesCollected;
    }
    ///State transition - sets the `shapes_collected` field to Set
    pub struct SetShapesCollected<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetShapesCollected<St> {}
    impl<St: State> State for SetShapesCollected<St> {
        type FinalScore = St::FinalScore;
        type GameContext = St::GameContext;
        type PlayedAt = St::PlayedAt;
        type RoundDuration = St::RoundDuration;
        type ShapesCollected = Set<members::shapes_collected>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `final_score` field
        pub struct final_score(());
        ///Marker type for the `game_context` field
        pub struct game_context(());
        ///Marker type for the `played_at` field
        pub struct played_at(());
        ///Marker type for the `round_duration` field
        pub struct round_duration(());
        ///Marker type for the `shapes_collected` field
        pub struct shapes_collected(());
    }
}

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

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

impl<S: BosStr> Minigame<S> {
    /// Create a new builder for this type
    pub fn builder() -> MinigameBuilder<minigame_state::Empty, S> {
        MinigameBuilder::builder()
    }
}

impl MinigameBuilder<minigame_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        MinigameBuilder {
            _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> MinigameBuilder<minigame_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        MinigameBuilder {
            _state: PhantomData,
            _fields: (
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
            ),
            _type: PhantomData,
        }
    }
}

impl<St: minigame_state::State, S: BosStr> MinigameBuilder<St, S> {
    /// Set the `clientVersion` field (optional)
    pub fn client_version(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `clientVersion` field to an Option value (optional)
    pub fn maybe_client_version(mut self, value: Option<S>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St: minigame_state::State, S: BosStr> MinigameBuilder<St, S> {
    /// Set the `createdAt` field (optional)
    pub fn created_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `createdAt` field to an Option value (optional)
    pub fn maybe_created_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St: minigame_state::State, S: BosStr> MinigameBuilder<St, S> {
    /// Set the `earlyHarvests` field (optional)
    pub fn early_harvests(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `earlyHarvests` field to an Option value (optional)
    pub fn maybe_early_harvests(mut self, value: Option<i64>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St: minigame_state::State, S: BosStr> MinigameBuilder<St, S> {
    /// Set the `efficiencyBonus` field (optional)
    pub fn efficiency_bonus(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `efficiencyBonus` field to an Option value (optional)
    pub fn maybe_efficiency_bonus(mut self, value: Option<i64>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St, S: BosStr> MinigameBuilder<St, S>
where
    St: minigame_state::State,
    St::FinalScore: minigame_state::IsUnset,
{
    /// Set the `finalScore` field (required)
    pub fn final_score(
        mut self,
        value: impl Into<i64>,
    ) -> MinigameBuilder<minigame_state::SetFinalScore<St>, S> {
        self._fields.4 = Option::Some(value.into());
        MinigameBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> MinigameBuilder<St, S>
where
    St: minigame_state::State,
    St::GameContext: minigame_state::IsUnset,
{
    /// Set the `gameContext` field (required)
    pub fn game_context(
        mut self,
        value: impl Into<S>,
    ) -> MinigameBuilder<minigame_state::SetGameContext<St>, S> {
        self._fields.5 = Option::Some(value.into());
        MinigameBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

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

impl<St: minigame_state::State, S: BosStr> MinigameBuilder<St, S> {
    /// Set the `peakRateBonus` field (optional)
    pub fn peak_rate_bonus(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `peakRateBonus` field to an Option value (optional)
    pub fn maybe_peak_rate_bonus(mut self, value: Option<i64>) -> Self {
        self._fields.8 = value;
        self
    }
}

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

impl<St, S: BosStr> MinigameBuilder<St, S>
where
    St: minigame_state::State,
    St::PlayedAt: minigame_state::IsUnset,
{
    /// Set the `playedAt` field (required)
    pub fn played_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> MinigameBuilder<minigame_state::SetPlayedAt<St>, S> {
        self._fields.10 = Option::Some(value.into());
        MinigameBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: minigame_state::State, S: BosStr> MinigameBuilder<St, S> {
    /// Set the `pointsPerSecond` field (optional)
    pub fn points_per_second(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.11 = value.into();
        self
    }
    /// Set the `pointsPerSecond` field to an Option value (optional)
    pub fn maybe_points_per_second(mut self, value: Option<i64>) -> Self {
        self._fields.11 = value;
        self
    }
}

impl<St: minigame_state::State, S: BosStr> MinigameBuilder<St, S> {
    /// Set the `rarityBreakdown` field (optional)
    pub fn rarity_breakdown(
        mut self,
        value: impl Into<Option<minigame::RarityBreakdown<S>>>,
    ) -> Self {
        self._fields.12 = value.into();
        self
    }
    /// Set the `rarityBreakdown` field to an Option value (optional)
    pub fn maybe_rarity_breakdown(
        mut self,
        value: Option<minigame::RarityBreakdown<S>>,
    ) -> Self {
        self._fields.12 = value;
        self
    }
}

impl<St, S: BosStr> MinigameBuilder<St, S>
where
    St: minigame_state::State,
    St::RoundDuration: minigame_state::IsUnset,
{
    /// Set the `roundDuration` field (required)
    pub fn round_duration(
        mut self,
        value: impl Into<i64>,
    ) -> MinigameBuilder<minigame_state::SetRoundDuration<St>, S> {
        self._fields.13 = Option::Some(value.into());
        MinigameBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> MinigameBuilder<St, S>
where
    St: minigame_state::State,
    St::ShapesCollected: minigame_state::IsUnset,
{
    /// Set the `shapesCollected` field (required)
    pub fn shapes_collected(
        mut self,
        value: impl Into<i64>,
    ) -> MinigameBuilder<minigame_state::SetShapesCollected<St>, S> {
        self._fields.14 = Option::Some(value.into());
        MinigameBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: minigame_state::State, S: BosStr> MinigameBuilder<St, S> {
    /// Set the `shapesMissed` field (optional)
    pub fn shapes_missed(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.15 = value.into();
        self
    }
    /// Set the `shapesMissed` field to an Option value (optional)
    pub fn maybe_shapes_missed(mut self, value: Option<i64>) -> Self {
        self._fields.15 = value;
        self
    }
}

impl<St: minigame_state::State, S: BosStr> MinigameBuilder<St, S> {
    /// Set the `totalShapesSpawned` field (optional)
    pub fn total_shapes_spawned(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.16 = value.into();
        self
    }
    /// Set the `totalShapesSpawned` field to an Option value (optional)
    pub fn maybe_total_shapes_spawned(mut self, value: Option<i64>) -> Self {
        self._fields.16 = value;
        self
    }
}

impl<St, S: BosStr> MinigameBuilder<St, S>
where
    St: minigame_state::State,
    St::FinalScore: minigame_state::IsSet,
    St::GameContext: minigame_state::IsSet,
    St::PlayedAt: minigame_state::IsSet,
    St::RoundDuration: minigame_state::IsSet,
    St::ShapesCollected: minigame_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Minigame<S> {
        Minigame {
            client_version: self._fields.0,
            created_at: self._fields.1,
            early_harvests: self._fields.2,
            efficiency_bonus: self._fields.3,
            final_score: self._fields.4.unwrap(),
            game_context: self._fields.5.unwrap(),
            late_harvests: self._fields.6,
            peak_harvest_rate: self._fields.7,
            peak_rate_bonus: self._fields.8,
            perfect_harvests: self._fields.9,
            played_at: self._fields.10.unwrap(),
            points_per_second: self._fields.11,
            rarity_breakdown: self._fields.12,
            round_duration: self._fields.13.unwrap(),
            shapes_collected: self._fields.14.unwrap(),
            shapes_missed: self._fields.15,
            total_shapes_spawned: 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>>) -> Minigame<S> {
        Minigame {
            client_version: self._fields.0,
            created_at: self._fields.1,
            early_harvests: self._fields.2,
            efficiency_bonus: self._fields.3,
            final_score: self._fields.4.unwrap(),
            game_context: self._fields.5.unwrap(),
            late_harvests: self._fields.6,
            peak_harvest_rate: self._fields.7,
            peak_rate_bonus: self._fields.8,
            perfect_harvests: self._fields.9,
            played_at: self._fields.10.unwrap(),
            points_per_second: self._fields.11,
            rarity_breakdown: self._fields.12,
            round_duration: self._fields.13.unwrap(),
            shapes_collected: self._fields.14.unwrap(),
            shapes_missed: self._fields.15,
            total_shapes_spawned: self._fields.16,
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_net_anisota_harvest_minigame() -> 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.harvest.minigame"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static(
                            "A record of a harvest minigame round played by a user",
                        ),
                    ),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("playedAt"),
                                SmolStr::new_static("roundDuration"),
                                SmolStr::new_static("gameContext"),
                                SmolStr::new_static("finalScore"),
                                SmolStr::new_static("shapesCollected")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("clientVersion"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Version of the Anisota client"),
                                    ),
                                    ..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("earlyHarvests"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("efficiencyBonus"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("finalScore"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("gameContext"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Where the game was played: dedicated minigame page or harvest loading screen",
                                        ),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("lateHarvests"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("peakHarvestRate"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    maximum: Some(10000i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("peakRateBonus"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("perfectHarvests"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("playedAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "When the game round was played (ISO 8601)",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("pointsPerSecond"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("rarityBreakdown"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("#rarityBreakdown"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("roundDuration"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("shapesCollected"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("shapesMissed"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("totalShapesSpawned"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("rarityBreakdown"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Count of each rarity level collected"),
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("common"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("rare"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("uncommon"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("veryCommon"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("veryRare"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}