// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: app.dropanchor.checkin
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

#[allow(unused_imports)]
use alloc::collections::BTreeMap;

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::blob::BlobRef;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::app_dropanchor::checkin;
/// Street address (based on community.lexicon.location.address)

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Address<S: BosStr = DefaultStr> {
    ///The ISO 3166 country code (preferably 2-letter)
    pub country: S,
    ///The locality (city, town, etc.)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub locality: Option<S>,
    ///The name of the location
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<S>,
    ///The postal code
    #[serde(skip_serializing_if = "Option::is_none")]
    pub postal_code: Option<S>,
    ///The administrative region (state, province, etc.)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub region: Option<S>,
    ///The street address
    #[serde(skip_serializing_if = "Option::is_none")]
    pub street: Option<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Image attachment with thumbnail and full-size versions

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct CheckinImage<S: BosStr = DefaultStr> {
    ///Alt text for accessibility
    #[serde(skip_serializing_if = "Option::is_none")]
    pub alt: Option<S>,
    ///Full-size version (max 2000px width, ~2MB)
    pub fullsize: BlobRef<S>,
    ///Thumbnail version (max 800px width, ~300KB)
    pub thumb: BlobRef<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Foursquare venue data (based on community.lexicon.location.fsq)

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct FsqPlace<S: BosStr = DefaultStr> {
    ///The unique identifier of a Foursquare POI
    pub fsq_place_id: S,
    ///Latitude in decimal degrees
    #[serde(skip_serializing_if = "Option::is_none")]
    pub latitude: Option<S>,
    ///Longitude in decimal degrees
    #[serde(skip_serializing_if = "Option::is_none")]
    pub longitude: Option<S>,
    ///The name of the location
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Geographic coordinates in WGS84 (based on community.lexicon.location.geo)

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Geo<S: BosStr = DefaultStr> {
    ///Altitude in meters
    #[serde(skip_serializing_if = "Option::is_none")]
    pub altitude: Option<S>,
    ///Latitude in decimal degrees (range: -90 to 90)
    pub latitude: S,
    ///Longitude in decimal degrees (range: -180 to 180)
    pub longitude: S,
    ///Name of the location
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// A location check-in record for the Anchor app

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "app.dropanchor.checkin",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Checkin<S: BosStr = DefaultStr> {
    ///Address of the check-in location (based on community.lexicon.location.address)
    pub address: checkin::Address<S>,
    ///Place category (e.g., cafe, restaurant)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub category: Option<S>,
    ///Category group for organization
    #[serde(skip_serializing_if = "Option::is_none")]
    pub category_group: Option<S>,
    ///Emoji icon for the category
    #[serde(skip_serializing_if = "Option::is_none")]
    pub category_icon: Option<S>,
    ///When the check-in was created
    pub created_at: Datetime,
    ///Optional Foursquare venue data (based on community.lexicon.location.fsq)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub fsq: Option<checkin::FsqPlace<S>>,
    ///Geographic coordinates of the check-in (based on community.lexicon.location.geo)
    pub geo: checkin::Geo<S>,
    ///Optional image attachment for the check-in
    #[serde(skip_serializing_if = "Option::is_none")]
    pub image: Option<checkin::CheckinImage<S>>,
    ///The check-in message or note
    pub text: 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 CheckinGetRecordOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    pub uri: AtUri<S>,
    pub value: Checkin<S>,
}

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

impl<S: BosStr> LexiconSchema for Address<S> {
    fn nsid() -> &'static str {
        "app.dropanchor.checkin"
    }
    fn def_name() -> &'static str {
        "address"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_dropanchor_checkin()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.country;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 10usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("country"),
                    max: 10usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.country;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) < 2usize {
                return Err(ConstraintError::MinLength {
                    path: ValidationPath::from_field("country"),
                    min: 2usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.locality {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 200usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("locality"),
                    max: 200usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.name {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 500usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("name"),
                    max: 500usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.postal_code {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 20usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("postal_code"),
                    max: 20usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.region {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 200usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("region"),
                    max: 200usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.street {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 500usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("street"),
                    max: 500usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for CheckinImage<S> {
    fn nsid() -> &'static str {
        "app.dropanchor.checkin"
    }
    fn def_name() -> &'static str {
        "checkinImage"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_dropanchor_checkin()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.alt {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 1000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("alt"),
                    max: 1000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.fullsize;
            {
                let size = value.blob().size;
                if size > 2000000usize {
                    return Err(ConstraintError::BlobTooLarge {
                        path: ValidationPath::from_field("fullsize"),
                        max: 2000000usize,
                        actual: size,
                    });
                }
            }
        }
        {
            let value = &self.fullsize;
            {
                let mime = value.blob().mime_type.as_str();
                let accepted: &[&str] = &["image/jpeg", "image/png", "image/webp"];
                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("fullsize"),
                        accepted: vec![
                            "image/jpeg".to_string(), "image/png".to_string(),
                            "image/webp".to_string()
                        ],
                        actual: mime.to_string(),
                    });
                }
            }
        }
        {
            let value = &self.thumb;
            {
                let size = value.blob().size;
                if size > 300000usize {
                    return Err(ConstraintError::BlobTooLarge {
                        path: ValidationPath::from_field("thumb"),
                        max: 300000usize,
                        actual: size,
                    });
                }
            }
        }
        {
            let value = &self.thumb;
            {
                let mime = value.blob().mime_type.as_str();
                let accepted: &[&str] = &["image/jpeg", "image/png", "image/webp"];
                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("thumb"),
                        accepted: vec![
                            "image/jpeg".to_string(), "image/png".to_string(),
                            "image/webp".to_string()
                        ],
                        actual: mime.to_string(),
                    });
                }
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for FsqPlace<S> {
    fn nsid() -> &'static str {
        "app.dropanchor.checkin"
    }
    fn def_name() -> &'static str {
        "fsqPlace"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_dropanchor_checkin()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.fsq_place_id;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("fsq_place_id"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.latitude {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 32usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("latitude"),
                    max: 32usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.longitude {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 32usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("longitude"),
                    max: 32usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.name {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 500usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("name"),
                    max: 500usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for Geo<S> {
    fn nsid() -> &'static str {
        "app.dropanchor.checkin"
    }
    fn def_name() -> &'static str {
        "geo"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_dropanchor_checkin()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.altitude {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 32usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("altitude"),
                    max: 32usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.latitude;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 32usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("latitude"),
                    max: 32usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.longitude;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 32usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("longitude"),
                    max: 32usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.name {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 500usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("name"),
                    max: 500usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

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

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

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

impl<S: BosStr> Collection for Checkin<S> {
    const NSID: &'static str = "app.dropanchor.checkin";
    type Record = CheckinRecord;
}

impl Collection for CheckinRecord {
    const NSID: &'static str = "app.dropanchor.checkin";
    type Record = CheckinRecord;
}

impl<S: BosStr> LexiconSchema for Checkin<S> {
    fn nsid() -> &'static str {
        "app.dropanchor.checkin"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_dropanchor_checkin()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.category {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("category"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.category_group {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("category_group"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.category_icon {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 10usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("category_icon"),
                    max: 10usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.text;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 3000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("text"),
                    max: 3000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

fn lexicon_doc_app_dropanchor_checkin() -> 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("app.dropanchor.checkin"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("address"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Street address (based on community.lexicon.location.address)",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("country")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("country"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The ISO 3166 country code (preferably 2-letter)",
                                    ),
                                ),
                                min_length: Some(2usize),
                                max_length: Some(10usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("locality"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The locality (city, town, etc.)"),
                                ),
                                max_length: Some(200usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The name of the location"),
                                ),
                                max_length: Some(500usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("postalCode"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("The postal code")),
                                max_length: Some(20usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("region"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The administrative region (state, province, etc.)",
                                    ),
                                ),
                                max_length: Some(200usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("street"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("The street address")),
                                max_length: Some(500usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("checkinImage"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Image attachment with thumbnail and full-size versions",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("thumb"), SmolStr::new_static("fullsize")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("alt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Alt text for accessibility"),
                                ),
                                max_length: Some(1000usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("fullsize"),
                            LexObjectProperty::Blob(LexBlob { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("thumb"),
                            LexObjectProperty::Blob(LexBlob { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("fsqPlace"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Foursquare venue data (based on community.lexicon.location.fsq)",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("fsqPlaceId")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("fsqPlaceId"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The unique identifier of a Foursquare POI",
                                    ),
                                ),
                                max_length: Some(100usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("latitude"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Latitude in decimal degrees"),
                                ),
                                max_length: Some(32usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("longitude"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Longitude in decimal degrees"),
                                ),
                                max_length: Some(32usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The name of the location"),
                                ),
                                max_length: Some(500usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("geo"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Geographic coordinates in WGS84 (based on community.lexicon.location.geo)",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("latitude"),
                            SmolStr::new_static("longitude")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("altitude"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("Altitude in meters")),
                                max_length: Some(32usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("latitude"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Latitude in decimal degrees (range: -90 to 90)",
                                    ),
                                ),
                                max_length: Some(32usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("longitude"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Longitude in decimal degrees (range: -180 to 180)",
                                    ),
                                ),
                                max_length: Some(32usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Name of the location"),
                                ),
                                max_length: Some(500usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static(
                            "A location check-in record for the Anchor app",
                        ),
                    ),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("text"),
                                SmolStr::new_static("createdAt"),
                                SmolStr::new_static("address"), SmolStr::new_static("geo")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("address"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("#address"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("category"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Place category (e.g., cafe, restaurant)",
                                        ),
                                    ),
                                    max_length: Some(100usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("categoryGroup"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Category group for organization"),
                                    ),
                                    max_length: Some(100usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("categoryIcon"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Emoji icon for the category"),
                                    ),
                                    max_length: Some(10usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("When the check-in was created"),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("fsq"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("#fsqPlace"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("geo"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("#geo"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("image"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("#checkinImage"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("text"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("The check-in message or note"),
                                    ),
                                    max_length: Some(3000usize),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod checkin_image_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 Fullsize;
        type Thumb;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Fullsize = Unset;
        type Thumb = Unset;
    }
    ///State transition - sets the `fullsize` field to Set
    pub struct SetFullsize<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetFullsize<St> {}
    impl<St: State> State for SetFullsize<St> {
        type Fullsize = Set<members::fullsize>;
        type Thumb = St::Thumb;
    }
    ///State transition - sets the `thumb` field to Set
    pub struct SetThumb<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetThumb<St> {}
    impl<St: State> State for SetThumb<St> {
        type Fullsize = St::Fullsize;
        type Thumb = Set<members::thumb>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `fullsize` field
        pub struct fullsize(());
        ///Marker type for the `thumb` field
        pub struct thumb(());
    }
}

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

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

impl<S: BosStr> CheckinImage<S> {
    /// Create a new builder for this type
    pub fn builder() -> CheckinImageBuilder<checkin_image_state::Empty, S> {
        CheckinImageBuilder::builder()
    }
}

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

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

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

impl<St, S: BosStr> CheckinImageBuilder<St, S>
where
    St: checkin_image_state::State,
    St::Fullsize: checkin_image_state::IsUnset,
{
    /// Set the `fullsize` field (required)
    pub fn fullsize(
        mut self,
        value: impl Into<BlobRef<S>>,
    ) -> CheckinImageBuilder<checkin_image_state::SetFullsize<St>, S> {
        self._fields.1 = Option::Some(value.into());
        CheckinImageBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> CheckinImageBuilder<St, S>
where
    St: checkin_image_state::State,
    St::Thumb: checkin_image_state::IsUnset,
{
    /// Set the `thumb` field (required)
    pub fn thumb(
        mut self,
        value: impl Into<BlobRef<S>>,
    ) -> CheckinImageBuilder<checkin_image_state::SetThumb<St>, S> {
        self._fields.2 = Option::Some(value.into());
        CheckinImageBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> CheckinImageBuilder<St, S>
where
    St: checkin_image_state::State,
    St::Fullsize: checkin_image_state::IsSet,
    St::Thumb: checkin_image_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> CheckinImage<S> {
        CheckinImage {
            alt: self._fields.0,
            fullsize: self._fields.1.unwrap(),
            thumb: self._fields.2.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> CheckinImage<S> {
        CheckinImage {
            alt: self._fields.0,
            fullsize: self._fields.1.unwrap(),
            thumb: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod checkin_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 Address;
        type CreatedAt;
        type Geo;
        type Text;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Address = Unset;
        type CreatedAt = Unset;
        type Geo = Unset;
        type Text = Unset;
    }
    ///State transition - sets the `address` field to Set
    pub struct SetAddress<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetAddress<St> {}
    impl<St: State> State for SetAddress<St> {
        type Address = Set<members::address>;
        type CreatedAt = St::CreatedAt;
        type Geo = St::Geo;
        type Text = St::Text;
    }
    ///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 Address = St::Address;
        type CreatedAt = Set<members::created_at>;
        type Geo = St::Geo;
        type Text = St::Text;
    }
    ///State transition - sets the `geo` field to Set
    pub struct SetGeo<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetGeo<St> {}
    impl<St: State> State for SetGeo<St> {
        type Address = St::Address;
        type CreatedAt = St::CreatedAt;
        type Geo = Set<members::geo>;
        type Text = St::Text;
    }
    ///State transition - sets the `text` field to Set
    pub struct SetText<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetText<St> {}
    impl<St: State> State for SetText<St> {
        type Address = St::Address;
        type CreatedAt = St::CreatedAt;
        type Geo = St::Geo;
        type Text = Set<members::text>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `address` field
        pub struct address(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `geo` field
        pub struct geo(());
        ///Marker type for the `text` field
        pub struct text(());
    }
}

/// Builder for constructing an instance of this type.
pub struct CheckinBuilder<St: checkin_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<checkin::Address<S>>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<Datetime>,
        Option<checkin::FsqPlace<S>>,
        Option<checkin::Geo<S>>,
        Option<checkin::CheckinImage<S>>,
        Option<S>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> Checkin<S> {
    /// Create a new builder for this type
    pub fn builder() -> CheckinBuilder<checkin_state::Empty, S> {
        CheckinBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> CheckinBuilder<St, S>
where
    St: checkin_state::State,
    St::Address: checkin_state::IsUnset,
{
    /// Set the `address` field (required)
    pub fn address(
        mut self,
        value: impl Into<checkin::Address<S>>,
    ) -> CheckinBuilder<checkin_state::SetAddress<St>, S> {
        self._fields.0 = Option::Some(value.into());
        CheckinBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St: checkin_state::State, S: BosStr> CheckinBuilder<St, S> {
    /// Set the `categoryGroup` field (optional)
    pub fn category_group(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `categoryGroup` field to an Option value (optional)
    pub fn maybe_category_group(mut self, value: Option<S>) -> Self {
        self._fields.2 = value;
        self
    }
}

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

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

impl<St: checkin_state::State, S: BosStr> CheckinBuilder<St, S> {
    /// Set the `fsq` field (optional)
    pub fn fsq(mut self, value: impl Into<Option<checkin::FsqPlace<S>>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `fsq` field to an Option value (optional)
    pub fn maybe_fsq(mut self, value: Option<checkin::FsqPlace<S>>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St, S: BosStr> CheckinBuilder<St, S>
where
    St: checkin_state::State,
    St::Geo: checkin_state::IsUnset,
{
    /// Set the `geo` field (required)
    pub fn geo(
        mut self,
        value: impl Into<checkin::Geo<S>>,
    ) -> CheckinBuilder<checkin_state::SetGeo<St>, S> {
        self._fields.6 = Option::Some(value.into());
        CheckinBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: checkin_state::State, S: BosStr> CheckinBuilder<St, S> {
    /// Set the `image` field (optional)
    pub fn image(mut self, value: impl Into<Option<checkin::CheckinImage<S>>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `image` field to an Option value (optional)
    pub fn maybe_image(mut self, value: Option<checkin::CheckinImage<S>>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<St, S: BosStr> CheckinBuilder<St, S>
where
    St: checkin_state::State,
    St::Text: checkin_state::IsUnset,
{
    /// Set the `text` field (required)
    pub fn text(
        mut self,
        value: impl Into<S>,
    ) -> CheckinBuilder<checkin_state::SetText<St>, S> {
        self._fields.8 = Option::Some(value.into());
        CheckinBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> CheckinBuilder<St, S>
where
    St: checkin_state::State,
    St::Address: checkin_state::IsSet,
    St::CreatedAt: checkin_state::IsSet,
    St::Geo: checkin_state::IsSet,
    St::Text: checkin_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Checkin<S> {
        Checkin {
            address: self._fields.0.unwrap(),
            category: self._fields.1,
            category_group: self._fields.2,
            category_icon: self._fields.3,
            created_at: self._fields.4.unwrap(),
            fsq: self._fields.5,
            geo: self._fields.6.unwrap(),
            image: self._fields.7,
            text: self._fields.8.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Checkin<S> {
        Checkin {
            address: self._fields.0.unwrap(),
            category: self._fields.1,
            category_group: self._fields.2,
            category_icon: self._fields.3,
            created_at: self._fields.4.unwrap(),
            fsq: self._fields.5,
            geo: self._fields.6.unwrap(),
            image: self._fields.7,
            text: self._fields.8.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}