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

//! Generated bindings for the `space.polymodel.actor` Lexicon namespace/module.
pub mod bootstrap_profile;
pub mod get_profile;
pub mod get_session;
pub mod profile;


#[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::string::{Did, AtUri, Cid, Datetime, UriValue};
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
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_bsky::actor::ProfileViewDetailed;
use crate::space_polymodel::library::ActorViewerState;
use crate::space_polymodel::actor;
/// A list authored by the profile actor, with enough metadata for profile tabs and links into space.polymodel.graph.getList.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ProfileListView<S: BosStr = DefaultStr> {
    pub cid: Cid<S>,
    pub created_at: Datetime,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<S>,
    pub item_count: i64,
    pub name: S,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub purpose: Option<S>,
    pub uri: AtUri<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Polymodel actor profile view (union variant). Hydrated from the space.polymodel.actor.profile record plus SQLite-derived stats and viewer relationship state. Returned when the actor authored a polymodel profile record; otherwise getProfile returns the app.bsky.actor.defs#profileViewDetailed variant.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ProfileView<S: BosStr = DefaultStr> {
    ///Resolved avatar URL (CDN). Null until the app view resolves the polymodel profile avatar blob.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub avatar: Option<UriValue<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub default_license: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<S>,
    pub did: Did<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub display_name: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub follower_count: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub following_count: Option<i64>,
    pub handle: S,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub indexed_at: Option<Datetime>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub links: Option<Vec<UriValue<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub lists: Option<Vec<actor::ProfileListView<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub printers: Option<Vec<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub pronouns: Option<S>,
    ///The raw space.polymodel.actor.profile record.
    pub record: Data<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub thing_count: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_likes: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub viewer: Option<ActorViewerState<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

///Discriminates a polymodel-native actor (space.polymodel.actor.defs#profileView, hydrated from the local profile record + stats) from a bluesky-only actor (app.bsky.actor.defs#profileViewDetailed, fetched from the public AppView). Clients render based on $type.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum ProfileViewUnion<S: BosStr = DefaultStr> {
    #[serde(rename = "space.polymodel.actor.defs#profileView")]
    ProfileView(Box<actor::ProfileView<S>>),
    #[serde(rename = "app.bsky.actor.defs#profileViewDetailed")]
    ProfileViewDetailed(Box<ProfileViewDetailed<S>>),
}

impl<S: BosStr> LexiconSchema for ProfileListView<S> {
    fn nsid() -> &'static str {
        "space.polymodel.actor.defs"
    }
    fn def_name() -> &'static str {
        "profileListView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_space_polymodel_actor_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ProfileView<S> {
    fn nsid() -> &'static str {
        "space.polymodel.actor.defs"
    }
    fn def_name() -> &'static str {
        "profileView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_space_polymodel_actor_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod profile_list_view_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 Cid;
        type CreatedAt;
        type ItemCount;
        type Name;
        type Uri;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Cid = Unset;
        type CreatedAt = Unset;
        type ItemCount = Unset;
        type Name = Unset;
        type Uri = Unset;
    }
    ///State transition - sets the `cid` field to Set
    pub struct SetCid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCid<St> {}
    impl<St: State> State for SetCid<St> {
        type Cid = Set<members::cid>;
        type CreatedAt = St::CreatedAt;
        type ItemCount = St::ItemCount;
        type Name = St::Name;
        type Uri = St::Uri;
    }
    ///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 Cid = St::Cid;
        type CreatedAt = Set<members::created_at>;
        type ItemCount = St::ItemCount;
        type Name = St::Name;
        type Uri = St::Uri;
    }
    ///State transition - sets the `item_count` field to Set
    pub struct SetItemCount<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetItemCount<St> {}
    impl<St: State> State for SetItemCount<St> {
        type Cid = St::Cid;
        type CreatedAt = St::CreatedAt;
        type ItemCount = Set<members::item_count>;
        type Name = St::Name;
        type Uri = St::Uri;
    }
    ///State transition - sets the `name` field to Set
    pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetName<St> {}
    impl<St: State> State for SetName<St> {
        type Cid = St::Cid;
        type CreatedAt = St::CreatedAt;
        type ItemCount = St::ItemCount;
        type Name = Set<members::name>;
        type Uri = St::Uri;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUri<St> {}
    impl<St: State> State for SetUri<St> {
        type Cid = St::Cid;
        type CreatedAt = St::CreatedAt;
        type ItemCount = St::ItemCount;
        type Name = St::Name;
        type Uri = Set<members::uri>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `cid` field
        pub struct cid(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `item_count` field
        pub struct item_count(());
        ///Marker type for the `name` field
        pub struct name(());
        ///Marker type for the `uri` field
        pub struct uri(());
    }
}

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

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

impl<S: BosStr> ProfileListView<S> {
    /// Create a new builder for this type
    pub fn builder() -> ProfileListViewBuilder<profile_list_view_state::Empty, S> {
        ProfileListViewBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> ProfileListViewBuilder<St, S>
where
    St: profile_list_view_state::State,
    St::Cid: profile_list_view_state::IsUnset,
{
    /// Set the `cid` field (required)
    pub fn cid(
        mut self,
        value: impl Into<Cid<S>>,
    ) -> ProfileListViewBuilder<profile_list_view_state::SetCid<St>, S> {
        self._fields.0 = Option::Some(value.into());
        ProfileListViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

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

impl<St, S: BosStr> ProfileListViewBuilder<St, S>
where
    St: profile_list_view_state::State,
    St::ItemCount: profile_list_view_state::IsUnset,
{
    /// Set the `itemCount` field (required)
    pub fn item_count(
        mut self,
        value: impl Into<i64>,
    ) -> ProfileListViewBuilder<profile_list_view_state::SetItemCount<St>, S> {
        self._fields.3 = Option::Some(value.into());
        ProfileListViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ProfileListViewBuilder<St, S>
where
    St: profile_list_view_state::State,
    St::Name: profile_list_view_state::IsUnset,
{
    /// Set the `name` field (required)
    pub fn name(
        mut self,
        value: impl Into<S>,
    ) -> ProfileListViewBuilder<profile_list_view_state::SetName<St>, S> {
        self._fields.4 = Option::Some(value.into());
        ProfileListViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: profile_list_view_state::State, S: BosStr> ProfileListViewBuilder<St, S> {
    /// Set the `purpose` field (optional)
    pub fn purpose(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `purpose` field to an Option value (optional)
    pub fn maybe_purpose(mut self, value: Option<S>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St, S: BosStr> ProfileListViewBuilder<St, S>
where
    St: profile_list_view_state::State,
    St::Uri: profile_list_view_state::IsUnset,
{
    /// Set the `uri` field (required)
    pub fn uri(
        mut self,
        value: impl Into<AtUri<S>>,
    ) -> ProfileListViewBuilder<profile_list_view_state::SetUri<St>, S> {
        self._fields.6 = Option::Some(value.into());
        ProfileListViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ProfileListViewBuilder<St, S>
where
    St: profile_list_view_state::State,
    St::Cid: profile_list_view_state::IsSet,
    St::CreatedAt: profile_list_view_state::IsSet,
    St::ItemCount: profile_list_view_state::IsSet,
    St::Name: profile_list_view_state::IsSet,
    St::Uri: profile_list_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ProfileListView<S> {
        ProfileListView {
            cid: self._fields.0.unwrap(),
            created_at: self._fields.1.unwrap(),
            description: self._fields.2,
            item_count: self._fields.3.unwrap(),
            name: self._fields.4.unwrap(),
            purpose: self._fields.5,
            uri: self._fields.6.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>>,
    ) -> ProfileListView<S> {
        ProfileListView {
            cid: self._fields.0.unwrap(),
            created_at: self._fields.1.unwrap(),
            description: self._fields.2,
            item_count: self._fields.3.unwrap(),
            name: self._fields.4.unwrap(),
            purpose: self._fields.5,
            uri: self._fields.6.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_space_polymodel_actor_defs() -> 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("space.polymodel.actor.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("profileListView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A list authored by the profile actor, with enough metadata for profile tabs and links into space.polymodel.graph.getList.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("uri"), SmolStr::new_static("cid"),
                            SmolStr::new_static("name"),
                            SmolStr::new_static("itemCount"),
                            SmolStr::new_static("createdAt")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("cid"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Cid),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("description"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("itemCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("purpose"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("profileView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Polymodel actor profile view (union variant). Hydrated from the space.polymodel.actor.profile record plus SQLite-derived stats and viewer relationship state. Returned when the actor authored a polymodel profile record; otherwise getProfile returns the app.bsky.actor.defs#profileViewDetailed variant.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("did"), SmolStr::new_static("handle"),
                            SmolStr::new_static("record")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("avatar"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Resolved avatar URL (CDN). Null until the app view resolves the polymodel profile avatar blob.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("defaultLicense"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("description"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("did"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("displayName"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("followerCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("followingCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("handle"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("indexedAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("links"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::String(LexString {
                                    format: Some(LexStringFormat::Uri),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("lists"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static(
                                        "space.polymodel.actor.defs#profileListView",
                                    ),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("printers"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::String(LexString {
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("pronouns"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("record"),
                            LexObjectProperty::Unknown(LexUnknown {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("thingCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("totalLikes"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("viewer"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "space.polymodel.library.defs#actorViewerState",
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("profileViewUnion"),
                LexUserType::Union(LexRefUnion {
                    refs: vec![
                        CowStr::new_static("space.polymodel.actor.defs#profileView"),
                        CowStr::new_static("app.bsky.actor.defs#profileViewDetailed")
                    ],
                    closed: Some(true),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod profile_view_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 Did;
        type Handle;
        type Record;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Did = Unset;
        type Handle = Unset;
        type Record = Unset;
    }
    ///State transition - sets the `did` field to Set
    pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDid<St> {}
    impl<St: State> State for SetDid<St> {
        type Did = Set<members::did>;
        type Handle = St::Handle;
        type Record = St::Record;
    }
    ///State transition - sets the `handle` field to Set
    pub struct SetHandle<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetHandle<St> {}
    impl<St: State> State for SetHandle<St> {
        type Did = St::Did;
        type Handle = Set<members::handle>;
        type Record = St::Record;
    }
    ///State transition - sets the `record` field to Set
    pub struct SetRecord<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRecord<St> {}
    impl<St: State> State for SetRecord<St> {
        type Did = St::Did;
        type Handle = St::Handle;
        type Record = Set<members::record>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `did` field
        pub struct did(());
        ///Marker type for the `handle` field
        pub struct handle(());
        ///Marker type for the `record` field
        pub struct record(());
    }
}

/// Builder for constructing an instance of this type.
pub struct ProfileViewBuilder<St: profile_view_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<UriValue<S>>,
        Option<S>,
        Option<S>,
        Option<Did<S>>,
        Option<S>,
        Option<i64>,
        Option<i64>,
        Option<S>,
        Option<Datetime>,
        Option<Vec<UriValue<S>>>,
        Option<Vec<actor::ProfileListView<S>>>,
        Option<Vec<S>>,
        Option<S>,
        Option<Data<S>>,
        Option<i64>,
        Option<i64>,
        Option<ActorViewerState<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> ProfileView<S> {
    /// Create a new builder for this type
    pub fn builder() -> ProfileViewBuilder<profile_view_state::Empty, S> {
        ProfileViewBuilder::builder()
    }
}

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

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

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

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

impl<St, S: BosStr> ProfileViewBuilder<St, S>
where
    St: profile_view_state::State,
    St::Did: profile_view_state::IsUnset,
{
    /// Set the `did` field (required)
    pub fn did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> ProfileViewBuilder<profile_view_state::SetDid<St>, S> {
        self._fields.3 = Option::Some(value.into());
        ProfileViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: profile_view_state::State, S: BosStr> ProfileViewBuilder<St, S> {
    /// Set the `displayName` field (optional)
    pub fn display_name(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `displayName` field to an Option value (optional)
    pub fn maybe_display_name(mut self, value: Option<S>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<St: profile_view_state::State, S: BosStr> ProfileViewBuilder<St, S> {
    /// Set the `followerCount` field (optional)
    pub fn follower_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `followerCount` field to an Option value (optional)
    pub fn maybe_follower_count(mut self, value: Option<i64>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St: profile_view_state::State, S: BosStr> ProfileViewBuilder<St, S> {
    /// Set the `followingCount` field (optional)
    pub fn following_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `followingCount` field to an Option value (optional)
    pub fn maybe_following_count(mut self, value: Option<i64>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<St, S: BosStr> ProfileViewBuilder<St, S>
where
    St: profile_view_state::State,
    St::Handle: profile_view_state::IsUnset,
{
    /// Set the `handle` field (required)
    pub fn handle(
        mut self,
        value: impl Into<S>,
    ) -> ProfileViewBuilder<profile_view_state::SetHandle<St>, S> {
        self._fields.7 = Option::Some(value.into());
        ProfileViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: profile_view_state::State, S: BosStr> ProfileViewBuilder<St, S> {
    /// Set the `indexedAt` field (optional)
    pub fn indexed_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `indexedAt` field to an Option value (optional)
    pub fn maybe_indexed_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<St: profile_view_state::State, S: BosStr> ProfileViewBuilder<St, S> {
    /// Set the `links` field (optional)
    pub fn links(mut self, value: impl Into<Option<Vec<UriValue<S>>>>) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `links` field to an Option value (optional)
    pub fn maybe_links(mut self, value: Option<Vec<UriValue<S>>>) -> Self {
        self._fields.9 = value;
        self
    }
}

impl<St: profile_view_state::State, S: BosStr> ProfileViewBuilder<St, S> {
    /// Set the `lists` field (optional)
    pub fn lists(
        mut self,
        value: impl Into<Option<Vec<actor::ProfileListView<S>>>>,
    ) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `lists` field to an Option value (optional)
    pub fn maybe_lists(mut self, value: Option<Vec<actor::ProfileListView<S>>>) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<St: profile_view_state::State, S: BosStr> ProfileViewBuilder<St, S> {
    /// Set the `printers` field (optional)
    pub fn printers(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
        self._fields.11 = value.into();
        self
    }
    /// Set the `printers` field to an Option value (optional)
    pub fn maybe_printers(mut self, value: Option<Vec<S>>) -> Self {
        self._fields.11 = value;
        self
    }
}

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

impl<St, S: BosStr> ProfileViewBuilder<St, S>
where
    St: profile_view_state::State,
    St::Record: profile_view_state::IsUnset,
{
    /// Set the `record` field (required)
    pub fn record(
        mut self,
        value: impl Into<Data<S>>,
    ) -> ProfileViewBuilder<profile_view_state::SetRecord<St>, S> {
        self._fields.13 = Option::Some(value.into());
        ProfileViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: profile_view_state::State, S: BosStr> ProfileViewBuilder<St, S> {
    /// Set the `thingCount` field (optional)
    pub fn thing_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.14 = value.into();
        self
    }
    /// Set the `thingCount` field to an Option value (optional)
    pub fn maybe_thing_count(mut self, value: Option<i64>) -> Self {
        self._fields.14 = value;
        self
    }
}

impl<St: profile_view_state::State, S: BosStr> ProfileViewBuilder<St, S> {
    /// Set the `totalLikes` field (optional)
    pub fn total_likes(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.15 = value.into();
        self
    }
    /// Set the `totalLikes` field to an Option value (optional)
    pub fn maybe_total_likes(mut self, value: Option<i64>) -> Self {
        self._fields.15 = value;
        self
    }
}

impl<St: profile_view_state::State, S: BosStr> ProfileViewBuilder<St, S> {
    /// Set the `viewer` field (optional)
    pub fn viewer(mut self, value: impl Into<Option<ActorViewerState<S>>>) -> Self {
        self._fields.16 = value.into();
        self
    }
    /// Set the `viewer` field to an Option value (optional)
    pub fn maybe_viewer(mut self, value: Option<ActorViewerState<S>>) -> Self {
        self._fields.16 = value;
        self
    }
}

impl<St, S: BosStr> ProfileViewBuilder<St, S>
where
    St: profile_view_state::State,
    St::Did: profile_view_state::IsSet,
    St::Handle: profile_view_state::IsSet,
    St::Record: profile_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ProfileView<S> {
        ProfileView {
            avatar: self._fields.0,
            default_license: self._fields.1,
            description: self._fields.2,
            did: self._fields.3.unwrap(),
            display_name: self._fields.4,
            follower_count: self._fields.5,
            following_count: self._fields.6,
            handle: self._fields.7.unwrap(),
            indexed_at: self._fields.8,
            links: self._fields.9,
            lists: self._fields.10,
            printers: self._fields.11,
            pronouns: self._fields.12,
            record: self._fields.13.unwrap(),
            thing_count: self._fields.14,
            total_likes: self._fields.15,
            viewer: self._fields.16,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> ProfileView<S> {
        ProfileView {
            avatar: self._fields.0,
            default_license: self._fields.1,
            description: self._fields.2,
            did: self._fields.3.unwrap(),
            display_name: self._fields.4,
            follower_count: self._fields.5,
            following_count: self._fields.6,
            handle: self._fields.7.unwrap(),
            indexed_at: self._fields.8,
            links: self._fields.9,
            lists: self._fields.10,
            printers: self._fields.11,
            pronouns: self._fields.12,
            record: self._fields.13.unwrap(),
            thing_count: self._fields.14,
            total_likes: self._fields.15,
            viewer: self._fields.16,
            extra_data: Some(extra_data),
        }
    }
}