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

//! Generated bindings for the `app.beaconbits.beacon` Lexicon namespace/module.
pub mod like;


#[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::{Did, 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::com_atproto::repo::strong_ref::StrongRef;
use crate::community_lexicon::location::address::Address;
use crate::community_lexicon::location::geo::Geo;
/// A location-based check-in record

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "app.beaconbits.beacon",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Beacon<S: BosStr = DefaultStr> {
    ///Structured address using community lexicon
    #[serde(skip_serializing_if = "Option::is_none")]
    pub address_details: Option<Address<S>>,
    ///Chain emoji (root beacon only)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub chain_emoji: Option<S>,
    ///Custom chain name (root beacon only)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub chain_name: Option<S>,
    ///Timestamp when the beacon was created
    pub created_at: Datetime,
    ///Structured location using community lexicon
    #[serde(skip_serializing_if = "Option::is_none")]
    pub location: Option<Geo<S>>,
    ///DIDs of users mentioned in the beacon
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mentions: Option<Vec<Did<S>>>,
    ///Reference to parent beacon for chaining
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parent_beacon: Option<StrongRef<S>>,
    ///Reference to associated Bluesky post
    #[serde(skip_serializing_if = "Option::is_none")]
    pub post: Option<StrongRef<S>>,
    ///Star rating (1-5)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub rating: Option<i64>,
    ///ISO timestamp when beacon becomes visible (delayed reveal)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reveal_at: Option<Datetime>,
    ///User comment or caption
    #[serde(skip_serializing_if = "Option::is_none")]
    pub shout: Option<S>,
    ///Reference to root post for threading
    #[serde(skip_serializing_if = "Option::is_none")]
    pub thread_root: Option<StrongRef<S>>,
    ///Human-readable address
    #[serde(skip_serializing_if = "Option::is_none")]
    pub venue_address: Option<S>,
    ///Category classification (bar, cafe, restaurant, etc.)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub venue_category: Option<S>,
    ///Display name of the venue
    pub venue_name: S,
    ///OSM URI identifier (osm://node/123 or osm://way/456)
    pub venue_uri: S,
    ///Visibility setting for the beacon
    pub visibility: BeaconVisibility<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Visibility setting for the beacon

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum BeaconVisibility<S: BosStr = DefaultStr> {
    Public,
    Followers,
    Mutuals,
    Hidden,
    Other(S),
}

impl<S: BosStr> BeaconVisibility<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Public => "public",
            Self::Followers => "followers",
            Self::Mutuals => "mutuals",
            Self::Hidden => "hidden",
            Self::Other(s) => s.as_ref(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "public" => Self::Public,
            "followers" => Self::Followers,
            "mutuals" => Self::Mutuals,
            "hidden" => Self::Hidden,
            _ => Self::Other(s),
        }
    }
}

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

impl<S: BosStr> AsRef<str> for BeaconVisibility<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for BeaconVisibility<S> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = S::deserialize(deserializer)?;
        Ok(Self::from_value(s))
    }
}

impl<S: BosStr + Default> Default for BeaconVisibility<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for BeaconVisibility<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = BeaconVisibility<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            BeaconVisibility::Public => BeaconVisibility::Public,
            BeaconVisibility::Followers => BeaconVisibility::Followers,
            BeaconVisibility::Mutuals => BeaconVisibility::Mutuals,
            BeaconVisibility::Hidden => BeaconVisibility::Hidden,
            BeaconVisibility::Other(v) => BeaconVisibility::Other(v.into_static()),
        }
    }
}

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

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

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

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

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

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

impl<S: BosStr> Collection for Beacon<S> {
    const NSID: &'static str = "app.beaconbits.beacon";
    type Record = BeaconRecord;
}

impl Collection for BeaconRecord {
    const NSID: &'static str = "app.beaconbits.beacon";
    type Record = BeaconRecord;
}

impl<S: BosStr> LexiconSchema for Beacon<S> {
    fn nsid() -> &'static str {
        "app.beaconbits.beacon"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_beaconbits_beacon()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.chain_emoji {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 8usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("chain_emoji"),
                        max: 8usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.chain_name {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("chain_name"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.rating {
            if *value > 5i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("rating"),
                    max: 5i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.rating {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("rating"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.shout {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 280usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("shout"),
                        max: 280usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.venue_address {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("venue_address"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.venue_category {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("venue_category"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.venue_name;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 128usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("venue_name"),
                        max: 128usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.venue_uri;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 512usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("venue_uri"),
                        max: 512usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.visibility;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 32usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("visibility"),
                        max: 32usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

pub mod beacon_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 CreatedAt;
        type VenueName;
        type VenueUri;
        type Visibility;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type CreatedAt = Unset;
        type VenueName = Unset;
        type VenueUri = Unset;
        type Visibility = Unset;
    }
    ///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 CreatedAt = Set<members::created_at>;
        type VenueName = St::VenueName;
        type VenueUri = St::VenueUri;
        type Visibility = St::Visibility;
    }
    ///State transition - sets the `venue_name` field to Set
    pub struct SetVenueName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetVenueName<St> {}
    impl<St: State> State for SetVenueName<St> {
        type CreatedAt = St::CreatedAt;
        type VenueName = Set<members::venue_name>;
        type VenueUri = St::VenueUri;
        type Visibility = St::Visibility;
    }
    ///State transition - sets the `venue_uri` field to Set
    pub struct SetVenueUri<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetVenueUri<St> {}
    impl<St: State> State for SetVenueUri<St> {
        type CreatedAt = St::CreatedAt;
        type VenueName = St::VenueName;
        type VenueUri = Set<members::venue_uri>;
        type Visibility = St::Visibility;
    }
    ///State transition - sets the `visibility` field to Set
    pub struct SetVisibility<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetVisibility<St> {}
    impl<St: State> State for SetVisibility<St> {
        type CreatedAt = St::CreatedAt;
        type VenueName = St::VenueName;
        type VenueUri = St::VenueUri;
        type Visibility = Set<members::visibility>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `venue_name` field
        pub struct venue_name(());
        ///Marker type for the `venue_uri` field
        pub struct venue_uri(());
        ///Marker type for the `visibility` field
        pub struct visibility(());
    }
}

/// Builder for constructing an instance of this type.
pub struct BeaconBuilder<St: beacon_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<Address<S>>,
        Option<S>,
        Option<S>,
        Option<Datetime>,
        Option<Geo<S>>,
        Option<Vec<Did<S>>>,
        Option<StrongRef<S>>,
        Option<StrongRef<S>>,
        Option<i64>,
        Option<Datetime>,
        Option<S>,
        Option<StrongRef<S>>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<BeaconVisibility<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> Beacon<S> {
    /// Create a new builder for this type
    pub fn builder() -> BeaconBuilder<beacon_state::Empty, S> {
        BeaconBuilder::builder()
    }
}

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

impl<St: beacon_state::State, S: BosStr> BeaconBuilder<St, S> {
    /// Set the `addressDetails` field (optional)
    pub fn address_details(mut self, value: impl Into<Option<Address<S>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `addressDetails` field to an Option value (optional)
    pub fn maybe_address_details(mut self, value: Option<Address<S>>) -> Self {
        self._fields.0 = value;
        self
    }
}

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

impl<St: beacon_state::State, S: BosStr> BeaconBuilder<St, S> {
    /// Set the `chainName` field (optional)
    pub fn chain_name(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `chainName` field to an Option value (optional)
    pub fn maybe_chain_name(mut self, value: Option<S>) -> Self {
        self._fields.2 = value;
        self
    }
}

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

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

impl<St: beacon_state::State, S: BosStr> BeaconBuilder<St, S> {
    /// Set the `mentions` field (optional)
    pub fn mentions(mut self, value: impl Into<Option<Vec<Did<S>>>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `mentions` field to an Option value (optional)
    pub fn maybe_mentions(mut self, value: Option<Vec<Did<S>>>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St: beacon_state::State, S: BosStr> BeaconBuilder<St, S> {
    /// Set the `parentBeacon` field (optional)
    pub fn parent_beacon(mut self, value: impl Into<Option<StrongRef<S>>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `parentBeacon` field to an Option value (optional)
    pub fn maybe_parent_beacon(mut self, value: Option<StrongRef<S>>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<St: beacon_state::State, S: BosStr> BeaconBuilder<St, S> {
    /// Set the `post` field (optional)
    pub fn post(mut self, value: impl Into<Option<StrongRef<S>>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `post` field to an Option value (optional)
    pub fn maybe_post(mut self, value: Option<StrongRef<S>>) -> Self {
        self._fields.7 = value;
        self
    }
}

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

impl<St: beacon_state::State, S: BosStr> BeaconBuilder<St, S> {
    /// Set the `revealAt` field (optional)
    pub fn reveal_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `revealAt` field to an Option value (optional)
    pub fn maybe_reveal_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.9 = value;
        self
    }
}

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

impl<St: beacon_state::State, S: BosStr> BeaconBuilder<St, S> {
    /// Set the `threadRoot` field (optional)
    pub fn thread_root(mut self, value: impl Into<Option<StrongRef<S>>>) -> Self {
        self._fields.11 = value.into();
        self
    }
    /// Set the `threadRoot` field to an Option value (optional)
    pub fn maybe_thread_root(mut self, value: Option<StrongRef<S>>) -> Self {
        self._fields.11 = value;
        self
    }
}

impl<St: beacon_state::State, S: BosStr> BeaconBuilder<St, S> {
    /// Set the `venueAddress` field (optional)
    pub fn venue_address(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.12 = value.into();
        self
    }
    /// Set the `venueAddress` field to an Option value (optional)
    pub fn maybe_venue_address(mut self, value: Option<S>) -> Self {
        self._fields.12 = value;
        self
    }
}

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

impl<St, S: BosStr> BeaconBuilder<St, S>
where
    St: beacon_state::State,
    St::VenueName: beacon_state::IsUnset,
{
    /// Set the `venueName` field (required)
    pub fn venue_name(
        mut self,
        value: impl Into<S>,
    ) -> BeaconBuilder<beacon_state::SetVenueName<St>, S> {
        self._fields.14 = Option::Some(value.into());
        BeaconBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> BeaconBuilder<St, S>
where
    St: beacon_state::State,
    St::VenueUri: beacon_state::IsUnset,
{
    /// Set the `venueUri` field (required)
    pub fn venue_uri(
        mut self,
        value: impl Into<S>,
    ) -> BeaconBuilder<beacon_state::SetVenueUri<St>, S> {
        self._fields.15 = Option::Some(value.into());
        BeaconBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> BeaconBuilder<St, S>
where
    St: beacon_state::State,
    St::Visibility: beacon_state::IsUnset,
{
    /// Set the `visibility` field (required)
    pub fn visibility(
        mut self,
        value: impl Into<BeaconVisibility<S>>,
    ) -> BeaconBuilder<beacon_state::SetVisibility<St>, S> {
        self._fields.16 = Option::Some(value.into());
        BeaconBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> BeaconBuilder<St, S>
where
    St: beacon_state::State,
    St::CreatedAt: beacon_state::IsSet,
    St::VenueName: beacon_state::IsSet,
    St::VenueUri: beacon_state::IsSet,
    St::Visibility: beacon_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Beacon<S> {
        Beacon {
            address_details: self._fields.0,
            chain_emoji: self._fields.1,
            chain_name: self._fields.2,
            created_at: self._fields.3.unwrap(),
            location: self._fields.4,
            mentions: self._fields.5,
            parent_beacon: self._fields.6,
            post: self._fields.7,
            rating: self._fields.8,
            reveal_at: self._fields.9,
            shout: self._fields.10,
            thread_root: self._fields.11,
            venue_address: self._fields.12,
            venue_category: self._fields.13,
            venue_name: self._fields.14.unwrap(),
            venue_uri: self._fields.15.unwrap(),
            visibility: self._fields.16.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>>) -> Beacon<S> {
        Beacon {
            address_details: self._fields.0,
            chain_emoji: self._fields.1,
            chain_name: self._fields.2,
            created_at: self._fields.3.unwrap(),
            location: self._fields.4,
            mentions: self._fields.5,
            parent_beacon: self._fields.6,
            post: self._fields.7,
            rating: self._fields.8,
            reveal_at: self._fields.9,
            shout: self._fields.10,
            thread_root: self._fields.11,
            venue_address: self._fields.12,
            venue_category: self._fields.13,
            venue_name: self._fields.14.unwrap(),
            venue_uri: self._fields.15.unwrap(),
            visibility: self._fields.16.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_app_beaconbits_beacon() -> 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.beaconbits.beacon"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static("A location-based check-in record"),
                    ),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("venueUri"),
                                SmolStr::new_static("venueName"),
                                SmolStr::new_static("visibility"),
                                SmolStr::new_static("createdAt")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("addressDetails"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static(
                                        "community.lexicon.location.address",
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("chainEmoji"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Chain emoji (root beacon only)"),
                                    ),
                                    max_graphemes: Some(8usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("chainName"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Custom chain name (root beacon only)"),
                                    ),
                                    max_graphemes: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Timestamp when the beacon was created"),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("location"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("community.lexicon.location.geo"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("mentions"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(
                                        CowStr::new_static("DIDs of users mentioned in the beacon"),
                                    ),
                                    items: LexArrayItem::String(LexString {
                                        format: Some(LexStringFormat::Did),
                                        ..Default::default()
                                    }),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("parentBeacon"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("post"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("rating"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    maximum: Some(5i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("revealAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "ISO timestamp when beacon becomes visible (delayed reveal)",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("shout"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("User comment or caption"),
                                    ),
                                    max_graphemes: Some(280usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("threadRoot"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("venueAddress"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Human-readable address"),
                                    ),
                                    max_graphemes: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("venueCategory"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Category classification (bar, cafe, restaurant, etc.)",
                                        ),
                                    ),
                                    max_graphemes: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("venueName"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Display name of the venue"),
                                    ),
                                    max_graphemes: Some(128usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("venueUri"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "OSM URI identifier (osm://node/123 or osm://way/456)",
                                        ),
                                    ),
                                    max_graphemes: Some(512usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("visibility"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Visibility setting for the beacon"),
                                    ),
                                    max_graphemes: Some(32usize),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}