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

//! Generated bindings for the `app.bsky.labeler` Lexicon namespace/module.
pub mod get_services;
pub mod service;


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

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{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::{AtUri, Nsid, Cid, Datetime};
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::ProfileView;
use crate::com_atproto::label::Label;
use crate::com_atproto::label::LabelValue;
use crate::com_atproto::label::LabelValueDefinition;
use crate::com_atproto::moderation::ReasonType;
use crate::com_atproto::moderation::SubjectType;
use crate::app_bsky::labeler;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct LabelerPolicies<S: BosStr = DefaultStr> {
    ///Label values created by this labeler and scoped exclusively to it. Labels defined here will override global label definitions for this labeler.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub label_value_definitions: Option<Vec<LabelValueDefinition<S>>>,
    ///The label values which this labeler publishes. May include global or custom labels.
    pub label_values: Vec<LabelValue<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct LabelerView<S: BosStr = DefaultStr> {
    pub cid: Cid<S>,
    pub creator: ProfileView<S>,
    pub indexed_at: Datetime,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub labels: Option<Vec<Label<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub like_count: Option<i64>,
    pub uri: AtUri<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub viewer: Option<labeler::LabelerViewerState<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct LabelerViewDetailed<S: BosStr = DefaultStr> {
    pub cid: Cid<S>,
    pub creator: ProfileView<S>,
    pub indexed_at: Datetime,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub labels: Option<Vec<Label<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub like_count: Option<i64>,
    pub policies: labeler::LabelerPolicies<S>,
    ///The set of report reason 'codes' which are in-scope for this service to review and action. These usually align to policy categories. If not defined (distinct from empty array), all reason types are allowed.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reason_types: Option<Vec<ReasonType<S>>>,
    ///Set of record types (collection NSIDs) which can be reported to this service. If not defined (distinct from empty array), default is any record type.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub subject_collections: Option<Vec<Nsid<S>>>,
    ///The set of subject types (account, record, etc) this service accepts reports on.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub subject_types: Option<Vec<SubjectType<S>>>,
    pub uri: AtUri<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub viewer: Option<labeler::LabelerViewerState<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct LabelerViewerState<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub like: Option<AtUri<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for LabelerPolicies<S> {
    fn nsid() -> &'static str {
        "app.bsky.labeler.defs"
    }
    fn def_name() -> &'static str {
        "labelerPolicies"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_labeler_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for LabelerView<S> {
    fn nsid() -> &'static str {
        "app.bsky.labeler.defs"
    }
    fn def_name() -> &'static str {
        "labelerView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_labeler_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.like_count {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("like_count"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for LabelerViewDetailed<S> {
    fn nsid() -> &'static str {
        "app.bsky.labeler.defs"
    }
    fn def_name() -> &'static str {
        "labelerViewDetailed"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_labeler_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.like_count {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("like_count"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for LabelerViewerState<S> {
    fn nsid() -> &'static str {
        "app.bsky.labeler.defs"
    }
    fn def_name() -> &'static str {
        "labelerViewerState"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_labeler_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

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

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

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

impl<S: BosStr> LabelerPolicies<S> {
    /// Create a new builder for this type
    pub fn builder() -> LabelerPoliciesBuilder<labeler_policies_state::Empty, S> {
        LabelerPoliciesBuilder::builder()
    }
}

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

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

impl<St: labeler_policies_state::State, S: BosStr> LabelerPoliciesBuilder<St, S> {
    /// Set the `labelValueDefinitions` field (optional)
    pub fn label_value_definitions(
        mut self,
        value: impl Into<Option<Vec<LabelValueDefinition<S>>>>,
    ) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `labelValueDefinitions` field to an Option value (optional)
    pub fn maybe_label_value_definitions(
        mut self,
        value: Option<Vec<LabelValueDefinition<S>>>,
    ) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St, S: BosStr> LabelerPoliciesBuilder<St, S>
where
    St: labeler_policies_state::State,
    St::LabelValues: labeler_policies_state::IsUnset,
{
    /// Set the `labelValues` field (required)
    pub fn label_values(
        mut self,
        value: impl Into<Vec<LabelValue<S>>>,
    ) -> LabelerPoliciesBuilder<labeler_policies_state::SetLabelValues<St>, S> {
        self._fields.1 = Option::Some(value.into());
        LabelerPoliciesBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> LabelerPoliciesBuilder<St, S>
where
    St: labeler_policies_state::State,
    St::LabelValues: labeler_policies_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> LabelerPolicies<S> {
        LabelerPolicies {
            label_value_definitions: self._fields.0,
            label_values: self._fields.1.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>>,
    ) -> LabelerPolicies<S> {
        LabelerPolicies {
            label_value_definitions: self._fields.0,
            label_values: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_app_bsky_labeler_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("app.bsky.labeler.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("labelerPolicies"),
                LexUserType::Object(LexObject {
                    required: Some(vec![SmolStr::new_static("labelValues")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("labelValueDefinitions"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Label values created by this labeler and scoped exclusively to it. Labels defined here will override global label definitions for this labeler.",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static(
                                        "com.atproto.label.defs#labelValueDefinition",
                                    ),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("labelValues"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "The label values which this labeler publishes. May include global or custom labels.",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static(
                                        "com.atproto.label.defs#labelValue",
                                    ),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("labelerView"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("uri"), SmolStr::new_static("cid"),
                            SmolStr::new_static("creator"),
                            SmolStr::new_static("indexedAt")
                        ],
                    ),
                    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("creator"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "app.bsky.actor.defs#profileView",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("indexedAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("labels"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("com.atproto.label.defs#label"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("likeCount"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("viewer"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#labelerViewerState"),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("labelerViewDetailed"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("uri"), SmolStr::new_static("cid"),
                            SmolStr::new_static("creator"),
                            SmolStr::new_static("policies"),
                            SmolStr::new_static("indexedAt")
                        ],
                    ),
                    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("creator"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "app.bsky.actor.defs#profileView",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("indexedAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("labels"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("com.atproto.label.defs#label"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("likeCount"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("policies"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "app.bsky.labeler.defs#labelerPolicies",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("reasonTypes"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "The set of report reason 'codes' which are in-scope for this service to review and action. These usually align to policy categories. If not defined (distinct from empty array), all reason types are allowed.",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static(
                                        "com.atproto.moderation.defs#reasonType",
                                    ),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("subjectCollections"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Set of record types (collection NSIDs) which can be reported to this service. If not defined (distinct from empty array), default is any record type.",
                                    ),
                                ),
                                items: LexArrayItem::String(LexString {
                                    format: Some(LexStringFormat::Nsid),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("subjectTypes"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "The set of subject types (account, record, etc) this service accepts reports on.",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static(
                                        "com.atproto.moderation.defs#subjectType",
                                    ),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("viewer"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#labelerViewerState"),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("labelerViewerState"),
                LexUserType::Object(LexObject {
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("like"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod labeler_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 Creator;
        type IndexedAt;
        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 Creator = Unset;
        type IndexedAt = 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 Creator = St::Creator;
        type IndexedAt = St::IndexedAt;
        type Uri = St::Uri;
    }
    ///State transition - sets the `creator` field to Set
    pub struct SetCreator<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCreator<St> {}
    impl<St: State> State for SetCreator<St> {
        type Cid = St::Cid;
        type Creator = Set<members::creator>;
        type IndexedAt = St::IndexedAt;
        type Uri = St::Uri;
    }
    ///State transition - sets the `indexed_at` field to Set
    pub struct SetIndexedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetIndexedAt<St> {}
    impl<St: State> State for SetIndexedAt<St> {
        type Cid = St::Cid;
        type Creator = St::Creator;
        type IndexedAt = Set<members::indexed_at>;
        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 Creator = St::Creator;
        type IndexedAt = St::IndexedAt;
        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 `creator` field
        pub struct creator(());
        ///Marker type for the `indexed_at` field
        pub struct indexed_at(());
        ///Marker type for the `uri` field
        pub struct uri(());
    }
}

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

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

impl<S: BosStr> LabelerView<S> {
    /// Create a new builder for this type
    pub fn builder() -> LabelerViewBuilder<labeler_view_state::Empty, S> {
        LabelerViewBuilder::builder()
    }
}

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

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

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

impl<St, S: BosStr> LabelerViewBuilder<St, S>
where
    St: labeler_view_state::State,
    St::Creator: labeler_view_state::IsUnset,
{
    /// Set the `creator` field (required)
    pub fn creator(
        mut self,
        value: impl Into<ProfileView<S>>,
    ) -> LabelerViewBuilder<labeler_view_state::SetCreator<St>, S> {
        self._fields.1 = Option::Some(value.into());
        LabelerViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> LabelerViewBuilder<St, S>
where
    St: labeler_view_state::State,
    St::IndexedAt: labeler_view_state::IsUnset,
{
    /// Set the `indexedAt` field (required)
    pub fn indexed_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> LabelerViewBuilder<labeler_view_state::SetIndexedAt<St>, S> {
        self._fields.2 = Option::Some(value.into());
        LabelerViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: labeler_view_state::State, S: BosStr> LabelerViewBuilder<St, S> {
    /// Set the `labels` field (optional)
    pub fn labels(mut self, value: impl Into<Option<Vec<Label<S>>>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `labels` field to an Option value (optional)
    pub fn maybe_labels(mut self, value: Option<Vec<Label<S>>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St: labeler_view_state::State, S: BosStr> LabelerViewBuilder<St, S> {
    /// Set the `likeCount` field (optional)
    pub fn like_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `likeCount` field to an Option value (optional)
    pub fn maybe_like_count(mut self, value: Option<i64>) -> Self {
        self._fields.4 = value;
        self
    }
}

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

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

impl<St, S: BosStr> LabelerViewBuilder<St, S>
where
    St: labeler_view_state::State,
    St::Cid: labeler_view_state::IsSet,
    St::Creator: labeler_view_state::IsSet,
    St::IndexedAt: labeler_view_state::IsSet,
    St::Uri: labeler_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> LabelerView<S> {
        LabelerView {
            cid: self._fields.0.unwrap(),
            creator: self._fields.1.unwrap(),
            indexed_at: self._fields.2.unwrap(),
            labels: self._fields.3,
            like_count: self._fields.4,
            uri: self._fields.5.unwrap(),
            viewer: self._fields.6,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> LabelerView<S> {
        LabelerView {
            cid: self._fields.0.unwrap(),
            creator: self._fields.1.unwrap(),
            indexed_at: self._fields.2.unwrap(),
            labels: self._fields.3,
            like_count: self._fields.4,
            uri: self._fields.5.unwrap(),
            viewer: self._fields.6,
            extra_data: Some(extra_data),
        }
    }
}

pub mod labeler_view_detailed_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 Creator;
        type IndexedAt;
        type Policies;
        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 Creator = Unset;
        type IndexedAt = Unset;
        type Policies = 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 Creator = St::Creator;
        type IndexedAt = St::IndexedAt;
        type Policies = St::Policies;
        type Uri = St::Uri;
    }
    ///State transition - sets the `creator` field to Set
    pub struct SetCreator<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCreator<St> {}
    impl<St: State> State for SetCreator<St> {
        type Cid = St::Cid;
        type Creator = Set<members::creator>;
        type IndexedAt = St::IndexedAt;
        type Policies = St::Policies;
        type Uri = St::Uri;
    }
    ///State transition - sets the `indexed_at` field to Set
    pub struct SetIndexedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetIndexedAt<St> {}
    impl<St: State> State for SetIndexedAt<St> {
        type Cid = St::Cid;
        type Creator = St::Creator;
        type IndexedAt = Set<members::indexed_at>;
        type Policies = St::Policies;
        type Uri = St::Uri;
    }
    ///State transition - sets the `policies` field to Set
    pub struct SetPolicies<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetPolicies<St> {}
    impl<St: State> State for SetPolicies<St> {
        type Cid = St::Cid;
        type Creator = St::Creator;
        type IndexedAt = St::IndexedAt;
        type Policies = Set<members::policies>;
        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 Creator = St::Creator;
        type IndexedAt = St::IndexedAt;
        type Policies = St::Policies;
        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 `creator` field
        pub struct creator(());
        ///Marker type for the `indexed_at` field
        pub struct indexed_at(());
        ///Marker type for the `policies` field
        pub struct policies(());
        ///Marker type for the `uri` field
        pub struct uri(());
    }
}

/// Builder for constructing an instance of this type.
pub struct LabelerViewDetailedBuilder<
    St: labeler_view_detailed_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<Cid<S>>,
        Option<ProfileView<S>>,
        Option<Datetime>,
        Option<Vec<Label<S>>>,
        Option<i64>,
        Option<labeler::LabelerPolicies<S>>,
        Option<Vec<ReasonType<S>>>,
        Option<Vec<Nsid<S>>>,
        Option<Vec<SubjectType<S>>>,
        Option<AtUri<S>>,
        Option<labeler::LabelerViewerState<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> LabelerViewDetailed<S> {
    /// Create a new builder for this type
    pub fn builder() -> LabelerViewDetailedBuilder<
        labeler_view_detailed_state::Empty,
        S,
    > {
        LabelerViewDetailedBuilder::builder()
    }
}

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

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

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

impl<St, S: BosStr> LabelerViewDetailedBuilder<St, S>
where
    St: labeler_view_detailed_state::State,
    St::Creator: labeler_view_detailed_state::IsUnset,
{
    /// Set the `creator` field (required)
    pub fn creator(
        mut self,
        value: impl Into<ProfileView<S>>,
    ) -> LabelerViewDetailedBuilder<labeler_view_detailed_state::SetCreator<St>, S> {
        self._fields.1 = Option::Some(value.into());
        LabelerViewDetailedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> LabelerViewDetailedBuilder<St, S>
where
    St: labeler_view_detailed_state::State,
    St::IndexedAt: labeler_view_detailed_state::IsUnset,
{
    /// Set the `indexedAt` field (required)
    pub fn indexed_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> LabelerViewDetailedBuilder<labeler_view_detailed_state::SetIndexedAt<St>, S> {
        self._fields.2 = Option::Some(value.into());
        LabelerViewDetailedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<
    St: labeler_view_detailed_state::State,
    S: BosStr,
> LabelerViewDetailedBuilder<St, S> {
    /// Set the `labels` field (optional)
    pub fn labels(mut self, value: impl Into<Option<Vec<Label<S>>>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `labels` field to an Option value (optional)
    pub fn maybe_labels(mut self, value: Option<Vec<Label<S>>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<
    St: labeler_view_detailed_state::State,
    S: BosStr,
> LabelerViewDetailedBuilder<St, S> {
    /// Set the `likeCount` field (optional)
    pub fn like_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `likeCount` field to an Option value (optional)
    pub fn maybe_like_count(mut self, value: Option<i64>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<St, S: BosStr> LabelerViewDetailedBuilder<St, S>
where
    St: labeler_view_detailed_state::State,
    St::Policies: labeler_view_detailed_state::IsUnset,
{
    /// Set the `policies` field (required)
    pub fn policies(
        mut self,
        value: impl Into<labeler::LabelerPolicies<S>>,
    ) -> LabelerViewDetailedBuilder<labeler_view_detailed_state::SetPolicies<St>, S> {
        self._fields.5 = Option::Some(value.into());
        LabelerViewDetailedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<
    St: labeler_view_detailed_state::State,
    S: BosStr,
> LabelerViewDetailedBuilder<St, S> {
    /// Set the `reasonTypes` field (optional)
    pub fn reason_types(mut self, value: impl Into<Option<Vec<ReasonType<S>>>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `reasonTypes` field to an Option value (optional)
    pub fn maybe_reason_types(mut self, value: Option<Vec<ReasonType<S>>>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<
    St: labeler_view_detailed_state::State,
    S: BosStr,
> LabelerViewDetailedBuilder<St, S> {
    /// Set the `subjectCollections` field (optional)
    pub fn subject_collections(
        mut self,
        value: impl Into<Option<Vec<Nsid<S>>>>,
    ) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `subjectCollections` field to an Option value (optional)
    pub fn maybe_subject_collections(mut self, value: Option<Vec<Nsid<S>>>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<
    St: labeler_view_detailed_state::State,
    S: BosStr,
> LabelerViewDetailedBuilder<St, S> {
    /// Set the `subjectTypes` field (optional)
    pub fn subject_types(
        mut self,
        value: impl Into<Option<Vec<SubjectType<S>>>>,
    ) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `subjectTypes` field to an Option value (optional)
    pub fn maybe_subject_types(mut self, value: Option<Vec<SubjectType<S>>>) -> Self {
        self._fields.8 = value;
        self
    }
}

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

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

impl<St, S: BosStr> LabelerViewDetailedBuilder<St, S>
where
    St: labeler_view_detailed_state::State,
    St::Cid: labeler_view_detailed_state::IsSet,
    St::Creator: labeler_view_detailed_state::IsSet,
    St::IndexedAt: labeler_view_detailed_state::IsSet,
    St::Policies: labeler_view_detailed_state::IsSet,
    St::Uri: labeler_view_detailed_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> LabelerViewDetailed<S> {
        LabelerViewDetailed {
            cid: self._fields.0.unwrap(),
            creator: self._fields.1.unwrap(),
            indexed_at: self._fields.2.unwrap(),
            labels: self._fields.3,
            like_count: self._fields.4,
            policies: self._fields.5.unwrap(),
            reason_types: self._fields.6,
            subject_collections: self._fields.7,
            subject_types: self._fields.8,
            uri: self._fields.9.unwrap(),
            viewer: self._fields.10,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> LabelerViewDetailed<S> {
        LabelerViewDetailed {
            cid: self._fields.0.unwrap(),
            creator: self._fields.1.unwrap(),
            indexed_at: self._fields.2.unwrap(),
            labels: self._fields.3,
            like_count: self._fields.4,
            policies: self._fields.5.unwrap(),
            reason_types: self._fields.6,
            subject_collections: self._fields.7,
            subject_types: self._fields.8,
            uri: self._fields.9.unwrap(),
            viewer: self._fields.10,
            extra_data: Some(extra_data),
        }
    }
}