// @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.

pub mod like;


#[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::collection::{Collection, RecordError};
use jacquard_common::types::string::{Did, AtUri, Cid, Datetime};
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};
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

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Beacon<'a> {
    ///Structured address using community lexicon
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub address_details: Option<Address<'a>>,
    ///Chain emoji (root beacon only)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub chain_emoji: Option<CowStr<'a>>,
    ///Custom chain name (root beacon only)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub chain_name: Option<CowStr<'a>>,
    ///Timestamp when the beacon was created
    pub created_at: Datetime,
    ///Structured location using community lexicon
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub location: Option<Geo<'a>>,
    ///DIDs of users mentioned in the beacon
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub mentions: Option<Vec<Did<'a>>>,
    ///Reference to parent beacon for chaining
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub parent_beacon: Option<StrongRef<'a>>,
    ///Reference to associated Bluesky post
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub post: Option<StrongRef<'a>>,
    ///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")]
    #[serde(borrow)]
    pub shout: Option<CowStr<'a>>,
    ///Reference to root post for threading
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub thread_root: Option<StrongRef<'a>>,
    ///Human-readable address
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub venue_address: Option<CowStr<'a>>,
    ///Category classification (bar, cafe, restaurant, etc.)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub venue_category: Option<CowStr<'a>>,
    ///Display name of the venue
    #[serde(borrow)]
    pub venue_name: CowStr<'a>,
    ///OSM URI identifier (osm://node/123 or osm://way/456)
    #[serde(borrow)]
    pub venue_uri: CowStr<'a>,
    ///Visibility setting for the beacon
    #[serde(borrow)]
    pub visibility: BeaconVisibility<'a>,
}

/// Visibility setting for the beacon

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum BeaconVisibility<'a> {
    Public,
    Followers,
    Mutuals,
    Hidden,
    Other(CowStr<'a>),
}

impl<'a> BeaconVisibility<'a> {
    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(),
        }
    }
}

impl<'a> From<&'a str> for BeaconVisibility<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "public" => Self::Public,
            "followers" => Self::Followers,
            "mutuals" => Self::Mutuals,
            "hidden" => Self::Hidden,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for BeaconVisibility<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "public" => Self::Public,
            "followers" => Self::Followers,
            "mutuals" => Self::Mutuals,
            "hidden" => Self::Hidden,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

impl<'a> AsRef<str> for BeaconVisibility<'a> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

impl<'de, 'a> serde::Deserialize<'de> for BeaconVisibility<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for BeaconVisibility<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for BeaconVisibility<'_> {
    type Output = BeaconVisibility<'static>;
    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<'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: Beacon<'a>,
}

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

/// 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<'de> = BeaconGetRecordOutput<'de>;
    type Err<'de> = RecordError<'de>;
}

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

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

/// Builder for constructing an instance of this type
pub struct BeaconBuilder<'a, S: beacon_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<Address<'a>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<Datetime>,
        Option<Geo<'a>>,
        Option<Vec<Did<'a>>>,
        Option<StrongRef<'a>>,
        Option<StrongRef<'a>>,
        Option<i64>,
        Option<Datetime>,
        Option<CowStr<'a>>,
        Option<StrongRef<'a>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<BeaconVisibility<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

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

impl<'a> BeaconBuilder<'a, beacon_state::Empty> {
    /// Create a new builder with all fields unset
    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,
            ),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: beacon_state::State> BeaconBuilder<'a, S> {
    /// Set the `addressDetails` field (optional)
    pub fn address_details(mut self, value: impl Into<Option<Address<'a>>>) -> 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<'a>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S: beacon_state::State> BeaconBuilder<'a, S> {
    /// Set the `chainEmoji` field (optional)
    pub fn chain_emoji(mut self, value: impl Into<Option<CowStr<'a>>>) -> 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<CowStr<'a>>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S: beacon_state::State> BeaconBuilder<'a, S> {
    /// Set the `chainName` field (optional)
    pub fn chain_name(mut self, value: impl Into<Option<CowStr<'a>>>) -> 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<CowStr<'a>>) -> Self {
        self._fields.2 = value;
        self
    }
}

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

impl<'a, S: beacon_state::State> BeaconBuilder<'a, S> {
    /// Set the `location` field (optional)
    pub fn location(mut self, value: impl Into<Option<Geo<'a>>>) -> 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<'a>>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<'a, S: beacon_state::State> BeaconBuilder<'a, S> {
    /// Set the `mentions` field (optional)
    pub fn mentions(mut self, value: impl Into<Option<Vec<Did<'a>>>>) -> 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<'a>>>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<'a, S: beacon_state::State> BeaconBuilder<'a, S> {
    /// Set the `parentBeacon` field (optional)
    pub fn parent_beacon(mut self, value: impl Into<Option<StrongRef<'a>>>) -> 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<'a>>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<'a, S: beacon_state::State> BeaconBuilder<'a, S> {
    /// Set the `post` field (optional)
    pub fn post(mut self, value: impl Into<Option<StrongRef<'a>>>) -> 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<'a>>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<'a, S: beacon_state::State> BeaconBuilder<'a, 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<'a, S: beacon_state::State> BeaconBuilder<'a, 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<'a, S: beacon_state::State> BeaconBuilder<'a, S> {
    /// Set the `shout` field (optional)
    pub fn shout(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `shout` field to an Option value (optional)
    pub fn maybe_shout(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<'a, S: beacon_state::State> BeaconBuilder<'a, S> {
    /// Set the `threadRoot` field (optional)
    pub fn thread_root(mut self, value: impl Into<Option<StrongRef<'a>>>) -> 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<'a>>) -> Self {
        self._fields.11 = value;
        self
    }
}

impl<'a, S: beacon_state::State> BeaconBuilder<'a, S> {
    /// Set the `venueAddress` field (optional)
    pub fn venue_address(mut self, value: impl Into<Option<CowStr<'a>>>) -> 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<CowStr<'a>>) -> Self {
        self._fields.12 = value;
        self
    }
}

impl<'a, S: beacon_state::State> BeaconBuilder<'a, S> {
    /// Set the `venueCategory` field (optional)
    pub fn venue_category(mut self, value: impl Into<Option<CowStr<'a>>>) -> 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<CowStr<'a>>) -> Self {
        self._fields.13 = value;
        self
    }
}

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

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

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

impl<'a, S> BeaconBuilder<'a, S>
where
    S: beacon_state::State,
    S::VenueName: beacon_state::IsSet,
    S::VenueUri: beacon_state::IsSet,
    S::CreatedAt: beacon_state::IsSet,
    S::Visibility: beacon_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Beacon<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> Beacon<'a> {
        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()
    }
}