// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: app.bsky.contact.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.contact` Lexicon namespace/module.
pub mod dismiss_match;
pub mod get_matches;
pub mod get_sync_status;
pub mod import_contacts;
pub mod remove_data;
pub mod send_notification;
pub mod start_phone_verification;
pub mod verify_phone;


#[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::{Did, 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;
/// Associates a profile with the positional index of the contact import input in the call to `app.bsky.contact.importContacts`, so clients can know which phone caused a particular match.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct MatchAndContactIndex<S: BosStr = DefaultStr> {
    ///The index of this match in the import contact input.
    pub contact_index: i64,
    ///Profile of the matched user.
    pub r#match: ProfileView<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// A stash object to be sent via bsync representing a notification to be created.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Notification<S: BosStr = DefaultStr> {
    ///The DID of who this notification comes from.
    pub from: Did<S>,
    ///The DID of who this notification should go to.
    pub to: Did<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 SyncStatus<S: BosStr = DefaultStr> {
    ///Number of existing contact matches resulting of the user imports and of their imported contacts having imported the user. Matches stop being counted when the user either follows the matched contact or dismisses the match.
    pub matches_count: i64,
    ///Last date when contacts where imported.
    pub synced_at: Datetime,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for MatchAndContactIndex<S> {
    fn nsid() -> &'static str {
        "app.bsky.contact.defs"
    }
    fn def_name() -> &'static str {
        "matchAndContactIndex"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_contact_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.contact_index;
            if *value > 999i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("contact_index"),
                    max: 999i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.contact_index;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("contact_index"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

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

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

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

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

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

impl<S: BosStr> MatchAndContactIndex<S> {
    /// Create a new builder for this type
    pub fn builder() -> MatchAndContactIndexBuilder<
        match_and_contact_index_state::Empty,
        S,
    > {
        MatchAndContactIndexBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> MatchAndContactIndexBuilder<St, S>
where
    St: match_and_contact_index_state::State,
    St::ContactIndex: match_and_contact_index_state::IsUnset,
{
    /// Set the `contactIndex` field (required)
    pub fn contact_index(
        mut self,
        value: impl Into<i64>,
    ) -> MatchAndContactIndexBuilder<
        match_and_contact_index_state::SetContactIndex<St>,
        S,
    > {
        self._fields.0 = Option::Some(value.into());
        MatchAndContactIndexBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> MatchAndContactIndexBuilder<St, S>
where
    St: match_and_contact_index_state::State,
    St::Match: match_and_contact_index_state::IsUnset,
{
    /// Set the `match` field (required)
    pub fn r#match(
        mut self,
        value: impl Into<ProfileView<S>>,
    ) -> MatchAndContactIndexBuilder<match_and_contact_index_state::SetMatch<St>, S> {
        self._fields.1 = Option::Some(value.into());
        MatchAndContactIndexBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> MatchAndContactIndexBuilder<St, S>
where
    St: match_and_contact_index_state::State,
    St::ContactIndex: match_and_contact_index_state::IsSet,
    St::Match: match_and_contact_index_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> MatchAndContactIndex<S> {
        MatchAndContactIndex {
            contact_index: self._fields.0.unwrap(),
            r#match: 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>>,
    ) -> MatchAndContactIndex<S> {
        MatchAndContactIndex {
            contact_index: self._fields.0.unwrap(),
            r#match: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_app_bsky_contact_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.contact.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("matchAndContactIndex"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Associates a profile with the positional index of the contact import input in the call to `app.bsky.contact.importContacts`, so clients can know which phone caused a particular match.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("match"),
                            SmolStr::new_static("contactIndex")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("contactIndex"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                maximum: Some(999i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("match"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "app.bsky.actor.defs#profileView",
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("notification"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A stash object to be sent via bsync representing a notification to be created.",
                        ),
                    ),
                    required: Some(
                        vec![SmolStr::new_static("from"), SmolStr::new_static("to")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("from"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The DID of who this notification comes from.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("to"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The DID of who this notification should go to.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("syncStatus"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("syncedAt"),
                            SmolStr::new_static("matchesCount")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("matchesCount"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("syncedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Last date when contacts where imported.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

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

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

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

impl<S: BosStr> Notification<S> {
    /// Create a new builder for this type
    pub fn builder() -> NotificationBuilder<notification_state::Empty, S> {
        NotificationBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> NotificationBuilder<St, S>
where
    St: notification_state::State,
    St::From: notification_state::IsUnset,
{
    /// Set the `from` field (required)
    pub fn from(
        mut self,
        value: impl Into<Did<S>>,
    ) -> NotificationBuilder<notification_state::SetFrom<St>, S> {
        self._fields.0 = Option::Some(value.into());
        NotificationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> NotificationBuilder<St, S>
where
    St: notification_state::State,
    St::To: notification_state::IsUnset,
{
    /// Set the `to` field (required)
    pub fn to(
        mut self,
        value: impl Into<Did<S>>,
    ) -> NotificationBuilder<notification_state::SetTo<St>, S> {
        self._fields.1 = Option::Some(value.into());
        NotificationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> NotificationBuilder<St, S>
where
    St: notification_state::State,
    St::From: notification_state::IsSet,
    St::To: notification_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Notification<S> {
        Notification {
            from: self._fields.0.unwrap(),
            to: 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>>,
    ) -> Notification<S> {
        Notification {
            from: self._fields.0.unwrap(),
            to: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

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

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

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

impl<S: BosStr> SyncStatus<S> {
    /// Create a new builder for this type
    pub fn builder() -> SyncStatusBuilder<sync_status_state::Empty, S> {
        SyncStatusBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> SyncStatusBuilder<St, S>
where
    St: sync_status_state::State,
    St::MatchesCount: sync_status_state::IsUnset,
{
    /// Set the `matchesCount` field (required)
    pub fn matches_count(
        mut self,
        value: impl Into<i64>,
    ) -> SyncStatusBuilder<sync_status_state::SetMatchesCount<St>, S> {
        self._fields.0 = Option::Some(value.into());
        SyncStatusBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SyncStatusBuilder<St, S>
where
    St: sync_status_state::State,
    St::SyncedAt: sync_status_state::IsUnset,
{
    /// Set the `syncedAt` field (required)
    pub fn synced_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> SyncStatusBuilder<sync_status_state::SetSyncedAt<St>, S> {
        self._fields.1 = Option::Some(value.into());
        SyncStatusBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SyncStatusBuilder<St, S>
where
    St: sync_status_state::State,
    St::MatchesCount: sync_status_state::IsSet,
    St::SyncedAt: sync_status_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> SyncStatus<S> {
        SyncStatus {
            matches_count: self._fields.0.unwrap(),
            synced_at: 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>>,
    ) -> SyncStatus<S> {
        SyncStatus {
            matches_count: self._fields.0.unwrap(),
            synced_at: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}