// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: garden.goals.goal
//
// 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, UriValue};
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 goal to track daily completions for a year.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Goal<'a> {
    ///Preset name or hex color for incomplete state
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub accent_color: Option<CowStr<'a>>,
    ///Array of category UUIDs this goal belongs to
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub categories: Option<Vec<CowStr<'a>>>,
    ///Preset name or hex color for complete state
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub completed_accent_color: Option<CowStr<'a>>,
    ///Shape name or emoji for complete state
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub completed_piece: Option<CowStr<'a>>,
    ///Uploaded image for complete state
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub completed_piece_blob: Option<BlobRef<'a>>,
    ///Favicon URL for complete state
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub completed_piece_url: Option<UriValue<'a>>,
    ///Timestamp when the goal was created
    pub created_at: Datetime,
    ///Optional description of the goal
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub description: Option<CowStr<'a>>,
    ///Unique identifier for the goal (UUID)
    #[serde(borrow)]
    pub goal_id: CowStr<'a>,
    ///Display name of the goal
    #[serde(borrow)]
    pub name: CowStr<'a>,
    ///Shape name or emoji for incomplete state
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub piece: Option<CowStr<'a>>,
    ///Uploaded image for incomplete state
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub piece_blob: Option<BlobRef<'a>>,
    ///Favicon URL for incomplete state
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub piece_url: Option<UriValue<'a>>,
    ///Target count for countable goals
    #[serde(skip_serializing_if = "Option::is_none")]
    pub target_count: Option<i64>,
    ///Year this goal is tracked for
    pub year: i64,
}

/// 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 GoalGetRecordOutput<'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: Goal<'a>,
}

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

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

#[derive(Debug, Serialize, Deserialize)]
pub struct GoalRecord;
impl XrpcResp for GoalRecord {
    const NSID: &'static str = "garden.goals.goal";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = GoalGetRecordOutput<'de>;
    type Err<'de> = RecordError<'de>;
}

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

impl Collection for Goal<'_> {
    const NSID: &'static str = "garden.goals.goal";
    type Record = GoalRecord;
}

impl Collection for GoalRecord {
    const NSID: &'static str = "garden.goals.goal";
    type Record = GoalRecord;
}

impl<'a> LexiconSchema for Goal<'a> {
    fn nsid() -> &'static str {
        "garden.goals.goal"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_garden_goals_goal()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.accent_color {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 50usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("accent_color"),
                    max: 50usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.completed_accent_color {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 50usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("completed_accent_color"),
                    max: 50usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.completed_piece {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("completed_piece"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.completed_piece_blob {
            {
                let size = value.blob().size;
                if size > 1000000usize {
                    return Err(ConstraintError::BlobTooLarge {
                        path: ValidationPath::from_field("completed_piece_blob"),
                        max: 1000000usize,
                        actual: size,
                    });
                }
            }
        }
        if let Some(ref value) = self.completed_piece_blob {
            {
                let mime = value.blob().mime_type.as_str();
                let accepted: &[&str] = &["image/*"];
                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("completed_piece_blob"),
                        accepted: vec!["image/*".to_string()],
                        actual: mime.to_string(),
                    });
                }
            }
        }
        if let Some(ref value) = self.description {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 500usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("description"),
                    max: 500usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.goal_id;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 64usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("goal_id"),
                    max: 64usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let 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.piece {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("piece"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.piece_blob {
            {
                let size = value.blob().size;
                if size > 1000000usize {
                    return Err(ConstraintError::BlobTooLarge {
                        path: ValidationPath::from_field("piece_blob"),
                        max: 1000000usize,
                        actual: size,
                    });
                }
            }
        }
        if let Some(ref value) = self.piece_blob {
            {
                let mime = value.blob().mime_type.as_str();
                let accepted: &[&str] = &["image/*"];
                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("piece_blob"),
                        accepted: vec!["image/*".to_string()],
                        actual: mime.to_string(),
                    });
                }
            }
        }
        if let Some(ref value) = self.target_count {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("target_count"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.year;
            if *value < 1970i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("year"),
                    min: 1970i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

pub mod goal_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 Year;
        type CreatedAt;
        type Name;
        type GoalId;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Year = Unset;
        type CreatedAt = Unset;
        type Name = Unset;
        type GoalId = Unset;
    }
    ///State transition - sets the `year` field to Set
    pub struct SetYear<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetYear<S> {}
    impl<S: State> State for SetYear<S> {
        type Year = Set<members::year>;
        type CreatedAt = S::CreatedAt;
        type Name = S::Name;
        type GoalId = S::GoalId;
    }
    ///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 Year = S::Year;
        type CreatedAt = Set<members::created_at>;
        type Name = S::Name;
        type GoalId = S::GoalId;
    }
    ///State transition - sets the `name` field to Set
    pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetName<S> {}
    impl<S: State> State for SetName<S> {
        type Year = S::Year;
        type CreatedAt = S::CreatedAt;
        type Name = Set<members::name>;
        type GoalId = S::GoalId;
    }
    ///State transition - sets the `goal_id` field to Set
    pub struct SetGoalId<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetGoalId<S> {}
    impl<S: State> State for SetGoalId<S> {
        type Year = S::Year;
        type CreatedAt = S::CreatedAt;
        type Name = S::Name;
        type GoalId = Set<members::goal_id>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `year` field
        pub struct year(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `name` field
        pub struct name(());
        ///Marker type for the `goal_id` field
        pub struct goal_id(());
    }
}

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

impl<'a> Goal<'a> {
    /// Create a new builder for this type
    pub fn new() -> GoalBuilder<'a, goal_state::Empty> {
        GoalBuilder::new()
    }
}

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

impl<'a, S: goal_state::State> GoalBuilder<'a, S> {
    /// Set the `accentColor` field (optional)
    pub fn accent_color(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `accentColor` field to an Option value (optional)
    pub fn maybe_accent_color(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S: goal_state::State> GoalBuilder<'a, S> {
    /// Set the `categories` field (optional)
    pub fn categories(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `categories` field to an Option value (optional)
    pub fn maybe_categories(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S: goal_state::State> GoalBuilder<'a, S> {
    /// Set the `completedAccentColor` field (optional)
    pub fn completed_accent_color(
        mut self,
        value: impl Into<Option<CowStr<'a>>>,
    ) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `completedAccentColor` field to an Option value (optional)
    pub fn maybe_completed_accent_color(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<'a, S: goal_state::State> GoalBuilder<'a, S> {
    /// Set the `completedPiece` field (optional)
    pub fn completed_piece(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `completedPiece` field to an Option value (optional)
    pub fn maybe_completed_piece(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<'a, S: goal_state::State> GoalBuilder<'a, S> {
    /// Set the `completedPieceBlob` field (optional)
    pub fn completed_piece_blob(
        mut self,
        value: impl Into<Option<BlobRef<'a>>>,
    ) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `completedPieceBlob` field to an Option value (optional)
    pub fn maybe_completed_piece_blob(mut self, value: Option<BlobRef<'a>>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<'a, S: goal_state::State> GoalBuilder<'a, S> {
    /// Set the `completedPieceUrl` field (optional)
    pub fn completed_piece_url(
        mut self,
        value: impl Into<Option<UriValue<'a>>>,
    ) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `completedPieceUrl` field to an Option value (optional)
    pub fn maybe_completed_piece_url(mut self, value: Option<UriValue<'a>>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<'a, S> GoalBuilder<'a, S>
where
    S: goal_state::State,
    S::CreatedAt: goal_state::IsUnset,
{
    /// Set the `createdAt` field (required)
    pub fn created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> GoalBuilder<'a, goal_state::SetCreatedAt<S>> {
        self._fields.6 = Option::Some(value.into());
        GoalBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: goal_state::State> GoalBuilder<'a, S> {
    /// Set the `description` field (optional)
    pub fn description(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `description` field to an Option value (optional)
    pub fn maybe_description(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<'a, S> GoalBuilder<'a, S>
where
    S: goal_state::State,
    S::GoalId: goal_state::IsUnset,
{
    /// Set the `goalId` field (required)
    pub fn goal_id(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> GoalBuilder<'a, goal_state::SetGoalId<S>> {
        self._fields.8 = Option::Some(value.into());
        GoalBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> GoalBuilder<'a, S>
where
    S: goal_state::State,
    S::Name: goal_state::IsUnset,
{
    /// Set the `name` field (required)
    pub fn name(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> GoalBuilder<'a, goal_state::SetName<S>> {
        self._fields.9 = Option::Some(value.into());
        GoalBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: goal_state::State> GoalBuilder<'a, S> {
    /// Set the `piece` field (optional)
    pub fn piece(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `piece` field to an Option value (optional)
    pub fn maybe_piece(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<'a, S: goal_state::State> GoalBuilder<'a, S> {
    /// Set the `pieceBlob` field (optional)
    pub fn piece_blob(mut self, value: impl Into<Option<BlobRef<'a>>>) -> Self {
        self._fields.11 = value.into();
        self
    }
    /// Set the `pieceBlob` field to an Option value (optional)
    pub fn maybe_piece_blob(mut self, value: Option<BlobRef<'a>>) -> Self {
        self._fields.11 = value;
        self
    }
}

impl<'a, S: goal_state::State> GoalBuilder<'a, S> {
    /// Set the `pieceUrl` field (optional)
    pub fn piece_url(mut self, value: impl Into<Option<UriValue<'a>>>) -> Self {
        self._fields.12 = value.into();
        self
    }
    /// Set the `pieceUrl` field to an Option value (optional)
    pub fn maybe_piece_url(mut self, value: Option<UriValue<'a>>) -> Self {
        self._fields.12 = value;
        self
    }
}

impl<'a, S: goal_state::State> GoalBuilder<'a, S> {
    /// Set the `targetCount` field (optional)
    pub fn target_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.13 = value.into();
        self
    }
    /// Set the `targetCount` field to an Option value (optional)
    pub fn maybe_target_count(mut self, value: Option<i64>) -> Self {
        self._fields.13 = value;
        self
    }
}

impl<'a, S> GoalBuilder<'a, S>
where
    S: goal_state::State,
    S::Year: goal_state::IsUnset,
{
    /// Set the `year` field (required)
    pub fn year(
        mut self,
        value: impl Into<i64>,
    ) -> GoalBuilder<'a, goal_state::SetYear<S>> {
        self._fields.14 = Option::Some(value.into());
        GoalBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> GoalBuilder<'a, S>
where
    S: goal_state::State,
    S::Year: goal_state::IsSet,
    S::CreatedAt: goal_state::IsSet,
    S::Name: goal_state::IsSet,
    S::GoalId: goal_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Goal<'a> {
        Goal {
            accent_color: self._fields.0,
            categories: self._fields.1,
            completed_accent_color: self._fields.2,
            completed_piece: self._fields.3,
            completed_piece_blob: self._fields.4,
            completed_piece_url: self._fields.5,
            created_at: self._fields.6.unwrap(),
            description: self._fields.7,
            goal_id: self._fields.8.unwrap(),
            name: self._fields.9.unwrap(),
            piece: self._fields.10,
            piece_blob: self._fields.11,
            piece_url: self._fields.12,
            target_count: self._fields.13,
            year: self._fields.14.unwrap(),
            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>,
        >,
    ) -> Goal<'a> {
        Goal {
            accent_color: self._fields.0,
            categories: self._fields.1,
            completed_accent_color: self._fields.2,
            completed_piece: self._fields.3,
            completed_piece_blob: self._fields.4,
            completed_piece_url: self._fields.5,
            created_at: self._fields.6.unwrap(),
            description: self._fields.7,
            goal_id: self._fields.8.unwrap(),
            name: self._fields.9.unwrap(),
            piece: self._fields.10,
            piece_blob: self._fields.11,
            piece_url: self._fields.12,
            target_count: self._fields.13,
            year: self._fields.14.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_garden_goals_goal() -> 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("garden.goals.goal"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static(
                            "A goal to track daily completions for a year.",
                        ),
                    ),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("goalId"), SmolStr::new_static("name"),
                                SmolStr::new_static("year"),
                                SmolStr::new_static("createdAt")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("accentColor"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Preset name or hex color for incomplete state",
                                        ),
                                    ),
                                    max_length: Some(50usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("categories"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(
                                        CowStr::new_static(
                                            "Array of category UUIDs this goal belongs to",
                                        ),
                                    ),
                                    items: LexArrayItem::String(LexString {
                                        max_length: Some(64usize),
                                        ..Default::default()
                                    }),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("completedAccentColor"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Preset name or hex color for complete state",
                                        ),
                                    ),
                                    max_length: Some(50usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("completedPiece"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Shape name or emoji for complete state"),
                                    ),
                                    max_length: Some(100usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("completedPieceBlob"),
                                LexObjectProperty::Blob(LexBlob { ..Default::default() }),
                            );
                            map.insert(
                                SmolStr::new_static("completedPieceUrl"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Favicon URL for complete state"),
                                    ),
                                    format: Some(LexStringFormat::Uri),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Timestamp when the goal was created"),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("description"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Optional description of the goal"),
                                    ),
                                    max_length: Some(500usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("goalId"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Unique identifier for the goal (UUID)"),
                                    ),
                                    max_length: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("name"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Display name of the goal"),
                                    ),
                                    max_length: Some(100usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("piece"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Shape name or emoji for incomplete state",
                                        ),
                                    ),
                                    max_length: Some(100usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("pieceBlob"),
                                LexObjectProperty::Blob(LexBlob { ..Default::default() }),
                            );
                            map.insert(
                                SmolStr::new_static("pieceUrl"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Favicon URL for incomplete state"),
                                    ),
                                    format: Some(LexStringFormat::Uri),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("targetCount"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("year"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1970i64),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}