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

pub mod get_services;
pub mod service;


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

#[allow(unused_imports)]
use core::marker::PhantomData;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::{AtUri, Nsid, Cid, Datetime};
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::app_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;

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct LabelerPolicies<'a> {
    ///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")]
    #[serde(borrow)]
    pub label_value_definitions: Option<Vec<LabelValueDefinition<'a>>>,
    ///The label values which this labeler publishes. May include global or custom labels.
    #[serde(borrow)]
    pub label_values: Vec<LabelValue<'a>>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct LabelerView<'a> {
    #[serde(borrow)]
    pub cid: Cid<'a>,
    #[serde(borrow)]
    pub creator: ProfileView<'a>,
    pub indexed_at: Datetime,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub labels: Option<Vec<Label<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub like_count: Option<i64>,
    #[serde(borrow)]
    pub uri: AtUri<'a>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub viewer: Option<labeler::LabelerViewerState<'a>>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct LabelerViewDetailed<'a> {
    #[serde(borrow)]
    pub cid: Cid<'a>,
    #[serde(borrow)]
    pub creator: ProfileView<'a>,
    pub indexed_at: Datetime,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub labels: Option<Vec<Label<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub like_count: Option<i64>,
    #[serde(borrow)]
    pub policies: labeler::LabelerPolicies<'a>,
    ///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")]
    #[serde(borrow)]
    pub reason_types: Option<Vec<ReasonType<'a>>>,
    ///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")]
    #[serde(borrow)]
    pub subject_collections: Option<Vec<Nsid<'a>>>,
    ///The set of subject types (account, record, etc) this service accepts reports on.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub subject_types: Option<Vec<SubjectType<'a>>>,
    #[serde(borrow)]
    pub uri: AtUri<'a>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub viewer: Option<labeler::LabelerViewerState<'a>>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct LabelerViewerState<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub like: Option<AtUri<'a>>,
}

impl<'a> LexiconSchema for LabelerPolicies<'a> {
    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<'a> LexiconSchema for LabelerView<'a> {
    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<'a> LexiconSchema for LabelerViewDetailed<'a> {
    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<'a> LexiconSchema for LabelerViewerState<'a> {
    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<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetLabelValues<S> {}
    impl<S: State> State for SetLabelValues<S> {
        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<'a, S: labeler_policies_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<Vec<LabelValueDefinition<'a>>>, Option<Vec<LabelValue<'a>>>),
    _lifetime: PhantomData<&'a ()>,
}

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

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

impl<'a, S: labeler_policies_state::State> LabelerPoliciesBuilder<'a, S> {
    /// Set the `labelValueDefinitions` field (optional)
    pub fn label_value_definitions(
        mut self,
        value: impl Into<Option<Vec<LabelValueDefinition<'a>>>>,
    ) -> 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<'a>>>,
    ) -> Self {
        self._fields.0 = value;
        self
    }
}

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

impl<'a, S> LabelerPoliciesBuilder<'a, S>
where
    S: labeler_policies_state::State,
    S::LabelValues: labeler_policies_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> LabelerPolicies<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> LabelerPolicies<'a> {
        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 Uri;
        type Cid;
        type IndexedAt;
        type Creator;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Uri = Unset;
        type Cid = Unset;
        type IndexedAt = Unset;
        type Creator = Unset;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetUri<S> {}
    impl<S: State> State for SetUri<S> {
        type Uri = Set<members::uri>;
        type Cid = S::Cid;
        type IndexedAt = S::IndexedAt;
        type Creator = S::Creator;
    }
    ///State transition - sets the `cid` field to Set
    pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCid<S> {}
    impl<S: State> State for SetCid<S> {
        type Uri = S::Uri;
        type Cid = Set<members::cid>;
        type IndexedAt = S::IndexedAt;
        type Creator = S::Creator;
    }
    ///State transition - sets the `indexed_at` field to Set
    pub struct SetIndexedAt<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetIndexedAt<S> {}
    impl<S: State> State for SetIndexedAt<S> {
        type Uri = S::Uri;
        type Cid = S::Cid;
        type IndexedAt = Set<members::indexed_at>;
        type Creator = S::Creator;
    }
    ///State transition - sets the `creator` field to Set
    pub struct SetCreator<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCreator<S> {}
    impl<S: State> State for SetCreator<S> {
        type Uri = S::Uri;
        type Cid = S::Cid;
        type IndexedAt = S::IndexedAt;
        type Creator = Set<members::creator>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `uri` field
        pub struct uri(());
        ///Marker type for the `cid` field
        pub struct cid(());
        ///Marker type for the `indexed_at` field
        pub struct indexed_at(());
        ///Marker type for the `creator` field
        pub struct creator(());
    }
}

/// Builder for constructing an instance of this type
pub struct LabelerViewBuilder<'a, S: labeler_view_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<Cid<'a>>,
        Option<ProfileView<'a>>,
        Option<Datetime>,
        Option<Vec<Label<'a>>>,
        Option<i64>,
        Option<AtUri<'a>>,
        Option<labeler::LabelerViewerState<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

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

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

impl<'a, S: labeler_view_state::State> LabelerViewBuilder<'a, S> {
    /// Set the `labels` field (optional)
    pub fn labels(mut self, value: impl Into<Option<Vec<Label<'a>>>>) -> 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<'a>>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<'a, S: labeler_view_state::State> LabelerViewBuilder<'a, 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<'a, S> LabelerViewBuilder<'a, S>
where
    S: labeler_view_state::State,
    S::Uri: labeler_view_state::IsUnset,
{
    /// Set the `uri` field (required)
    pub fn uri(
        mut self,
        value: impl Into<AtUri<'a>>,
    ) -> LabelerViewBuilder<'a, labeler_view_state::SetUri<S>> {
        self._fields.5 = Option::Some(value.into());
        LabelerViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: labeler_view_state::State> LabelerViewBuilder<'a, S> {
    /// Set the `viewer` field (optional)
    pub fn viewer(
        mut self,
        value: impl Into<Option<labeler::LabelerViewerState<'a>>>,
    ) -> 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<'a>>,
    ) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<'a, S> LabelerViewBuilder<'a, S>
where
    S: labeler_view_state::State,
    S::Uri: labeler_view_state::IsSet,
    S::Cid: labeler_view_state::IsSet,
    S::IndexedAt: labeler_view_state::IsSet,
    S::Creator: labeler_view_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> LabelerView<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> LabelerView<'a> {
        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 Uri;
        type Creator;
        type Policies;
        type Cid;
        type IndexedAt;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Uri = Unset;
        type Creator = Unset;
        type Policies = Unset;
        type Cid = Unset;
        type IndexedAt = Unset;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetUri<S> {}
    impl<S: State> State for SetUri<S> {
        type Uri = Set<members::uri>;
        type Creator = S::Creator;
        type Policies = S::Policies;
        type Cid = S::Cid;
        type IndexedAt = S::IndexedAt;
    }
    ///State transition - sets the `creator` field to Set
    pub struct SetCreator<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCreator<S> {}
    impl<S: State> State for SetCreator<S> {
        type Uri = S::Uri;
        type Creator = Set<members::creator>;
        type Policies = S::Policies;
        type Cid = S::Cid;
        type IndexedAt = S::IndexedAt;
    }
    ///State transition - sets the `policies` field to Set
    pub struct SetPolicies<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetPolicies<S> {}
    impl<S: State> State for SetPolicies<S> {
        type Uri = S::Uri;
        type Creator = S::Creator;
        type Policies = Set<members::policies>;
        type Cid = S::Cid;
        type IndexedAt = S::IndexedAt;
    }
    ///State transition - sets the `cid` field to Set
    pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCid<S> {}
    impl<S: State> State for SetCid<S> {
        type Uri = S::Uri;
        type Creator = S::Creator;
        type Policies = S::Policies;
        type Cid = Set<members::cid>;
        type IndexedAt = S::IndexedAt;
    }
    ///State transition - sets the `indexed_at` field to Set
    pub struct SetIndexedAt<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetIndexedAt<S> {}
    impl<S: State> State for SetIndexedAt<S> {
        type Uri = S::Uri;
        type Creator = S::Creator;
        type Policies = S::Policies;
        type Cid = S::Cid;
        type IndexedAt = Set<members::indexed_at>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `uri` field
        pub struct uri(());
        ///Marker type for the `creator` field
        pub struct creator(());
        ///Marker type for the `policies` field
        pub struct policies(());
        ///Marker type for the `cid` field
        pub struct cid(());
        ///Marker type for the `indexed_at` field
        pub struct indexed_at(());
    }
}

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

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

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

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

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

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

impl<'a, S: labeler_view_detailed_state::State> LabelerViewDetailedBuilder<'a, S> {
    /// Set the `labels` field (optional)
    pub fn labels(mut self, value: impl Into<Option<Vec<Label<'a>>>>) -> 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<'a>>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<'a, S: labeler_view_detailed_state::State> LabelerViewDetailedBuilder<'a, 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<'a, S> LabelerViewDetailedBuilder<'a, S>
where
    S: labeler_view_detailed_state::State,
    S::Policies: labeler_view_detailed_state::IsUnset,
{
    /// Set the `policies` field (required)
    pub fn policies(
        mut self,
        value: impl Into<labeler::LabelerPolicies<'a>>,
    ) -> LabelerViewDetailedBuilder<'a, labeler_view_detailed_state::SetPolicies<S>> {
        self._fields.5 = Option::Some(value.into());
        LabelerViewDetailedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: labeler_view_detailed_state::State> LabelerViewDetailedBuilder<'a, S> {
    /// Set the `reasonTypes` field (optional)
    pub fn reason_types(
        mut self,
        value: impl Into<Option<Vec<ReasonType<'a>>>>,
    ) -> 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<'a>>>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<'a, S: labeler_view_detailed_state::State> LabelerViewDetailedBuilder<'a, S> {
    /// Set the `subjectCollections` field (optional)
    pub fn subject_collections(
        mut self,
        value: impl Into<Option<Vec<Nsid<'a>>>>,
    ) -> 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<'a>>>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<'a, S: labeler_view_detailed_state::State> LabelerViewDetailedBuilder<'a, S> {
    /// Set the `subjectTypes` field (optional)
    pub fn subject_types(
        mut self,
        value: impl Into<Option<Vec<SubjectType<'a>>>>,
    ) -> 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<'a>>>) -> Self {
        self._fields.8 = value;
        self
    }
}

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

impl<'a, S: labeler_view_detailed_state::State> LabelerViewDetailedBuilder<'a, S> {
    /// Set the `viewer` field (optional)
    pub fn viewer(
        mut self,
        value: impl Into<Option<labeler::LabelerViewerState<'a>>>,
    ) -> 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<'a>>,
    ) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<'a, S> LabelerViewDetailedBuilder<'a, S>
where
    S: labeler_view_detailed_state::State,
    S::Uri: labeler_view_detailed_state::IsSet,
    S::Creator: labeler_view_detailed_state::IsSet,
    S::Policies: labeler_view_detailed_state::IsSet,
    S::Cid: labeler_view_detailed_state::IsSet,
    S::IndexedAt: labeler_view_detailed_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> LabelerViewDetailed<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> LabelerViewDetailed<'a> {
        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),
        }
    }
}