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

//! Generated bindings for the `sh.weaver.collab` Lexicon namespace/module.
pub mod accept;
pub mod get_collaboration_state;
pub mod get_invites;
pub mod get_resource_participants;
pub mod get_resource_sessions;
pub mod invite;
pub mod session;


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

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};

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

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::com_atproto::repo::strong_ref::StrongRef;
use crate::sh_weaver::actor::ProfileViewBasic;
use crate::sh_weaver::notebook::PublishedVersionView;
use crate::sh_weaver::collab;
/// Collaboration scoped to a chapter.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Chapter;
impl core::fmt::Display for Chapter {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "chapter")
    }
}

/// Full state of a collaboration relationship including version reconciliation. Tracks both current and former collaborators.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct CollaborationStateView<S: BosStr = DefaultStr> {
    ///The 'canonical' version URI (usually owner's)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub canonical_uri: Option<AtUri<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub created_at: Option<Datetime>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub first_collaborator_added_at: Option<Datetime>,
    ///People who used to collaborate but relationship ended
    #[serde(skip_serializing_if = "Option::is_none")]
    pub former_participants: Option<Vec<collab::FormerCollaboratorView<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub has_divergence: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub has_former_collaborators: Option<bool>,
    ///Published versions from former collaborators still exist
    #[serde(skip_serializing_if = "Option::is_none")]
    pub has_orphaned_versions: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub last_synced_at: Option<Datetime>,
    ///Current active + invited participants
    pub participants: Vec<collab::ParticipantStateView<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub published_versions: Option<Vec<PublishedVersionView<S>>>,
    pub resource: StrongRef<S>,
    ///active=normal, broken=all invites revoked/expired, diverged=versions differ, reconciled=was diverged but resolved
    pub status: CollaborationStateViewStatus<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// active=normal, broken=all invites revoked/expired, diverged=versions differ, reconciled=was diverged but resolved

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum CollaborationStateViewStatus<S: BosStr = DefaultStr> {
    Active,
    Broken,
    Diverged,
    Reconciled,
    Other(S),
}

impl<S: BosStr> CollaborationStateViewStatus<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Active => "active",
            Self::Broken => "broken",
            Self::Diverged => "diverged",
            Self::Reconciled => "reconciled",
            Self::Other(s) => s.as_ref(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "active" => Self::Active,
            "broken" => Self::Broken,
            "diverged" => Self::Diverged,
            "reconciled" => Self::Reconciled,
            _ => Self::Other(s),
        }
    }
}

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

impl<S: BosStr> AsRef<str> for CollaborationStateViewStatus<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de>
for CollaborationStateViewStatus<S> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = S::deserialize(deserializer)?;
        Ok(Self::from_value(s))
    }
}

impl<S: BosStr + Default> Default for CollaborationStateViewStatus<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for CollaborationStateViewStatus<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = CollaborationStateViewStatus<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            CollaborationStateViewStatus::Active => CollaborationStateViewStatus::Active,
            CollaborationStateViewStatus::Broken => CollaborationStateViewStatus::Broken,
            CollaborationStateViewStatus::Diverged => {
                CollaborationStateViewStatus::Diverged
            }
            CollaborationStateViewStatus::Reconciled => {
                CollaborationStateViewStatus::Reconciled
            }
            CollaborationStateViewStatus::Other(v) => {
                CollaborationStateViewStatus::Other(v.into_static())
            }
        }
    }
}

/// Collaboration scoped to a single entry.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Entry;
impl core::fmt::Display for Entry {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "entry")
    }
}

/// Lightweight view for 'this person used to collaborate but doesn't anymore'.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct FormerCollaboratorView<S: BosStr = DefaultStr> {
    ///Number of diffs they created while active
    #[serde(skip_serializing_if = "Option::is_none")]
    pub contribution_count: Option<i64>,
    pub end_reason: FormerCollaboratorViewEndReason<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub has_published_version: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub published_version_uri: Option<AtUri<S>>,
    pub user: ProfileViewBasic<S>,
    pub was_active_from: Datetime,
    pub was_active_until: Datetime,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum FormerCollaboratorViewEndReason<S: BosStr = DefaultStr> {
    VoluntaryLeave,
    InviteRevoked,
    InviteExpired,
    OwnerDeletedResource,
    Other(S),
}

impl<S: BosStr> FormerCollaboratorViewEndReason<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::VoluntaryLeave => "voluntary_leave",
            Self::InviteRevoked => "invite_revoked",
            Self::InviteExpired => "invite_expired",
            Self::OwnerDeletedResource => "owner_deleted_resource",
            Self::Other(s) => s.as_ref(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "voluntary_leave" => Self::VoluntaryLeave,
            "invite_revoked" => Self::InviteRevoked,
            "invite_expired" => Self::InviteExpired,
            "owner_deleted_resource" => Self::OwnerDeletedResource,
            _ => Self::Other(s),
        }
    }
}

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

impl<S: BosStr> AsRef<str> for FormerCollaboratorViewEndReason<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de>
for FormerCollaboratorViewEndReason<S> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = S::deserialize(deserializer)?;
        Ok(Self::from_value(s))
    }
}

impl<S: BosStr + Default> Default for FormerCollaboratorViewEndReason<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for FormerCollaboratorViewEndReason<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = FormerCollaboratorViewEndReason<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            FormerCollaboratorViewEndReason::VoluntaryLeave => {
                FormerCollaboratorViewEndReason::VoluntaryLeave
            }
            FormerCollaboratorViewEndReason::InviteRevoked => {
                FormerCollaboratorViewEndReason::InviteRevoked
            }
            FormerCollaboratorViewEndReason::InviteExpired => {
                FormerCollaboratorViewEndReason::InviteExpired
            }
            FormerCollaboratorViewEndReason::OwnerDeletedResource => {
                FormerCollaboratorViewEndReason::OwnerDeletedResource
            }
            FormerCollaboratorViewEndReason::Other(v) => {
                FormerCollaboratorViewEndReason::Other(v.into_static())
            }
        }
    }
}

/// Hydrated view of a collaboration invite with status.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct InviteView<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub accept_uri: Option<AtUri<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub accepted_at: Option<Datetime>,
    pub cid: Cid<S>,
    pub created_at: Datetime,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub expires_at: Option<Datetime>,
    pub invitee: ProfileViewBasic<S>,
    pub inviter: ProfileViewBasic<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub message: Option<S>,
    pub resource: StrongRef<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub resource_title: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub scope: Option<InviteViewScope<S>>,
    pub status: InviteViewStatus<S>,
    pub uri: AtUri<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum InviteViewScope<S: BosStr = DefaultStr> {
    Notebook,
    Entry,
    Chapter,
    Other(S),
}

impl<S: BosStr> InviteViewScope<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Notebook => "notebook",
            Self::Entry => "entry",
            Self::Chapter => "chapter",
            Self::Other(s) => s.as_ref(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "notebook" => Self::Notebook,
            "entry" => Self::Entry,
            "chapter" => Self::Chapter,
            _ => Self::Other(s),
        }
    }
}

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

impl<S: BosStr> AsRef<str> for InviteViewScope<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for InviteViewScope<S> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = S::deserialize(deserializer)?;
        Ok(Self::from_value(s))
    }
}

impl<S: BosStr + Default> Default for InviteViewScope<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for InviteViewScope<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = InviteViewScope<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            InviteViewScope::Notebook => InviteViewScope::Notebook,
            InviteViewScope::Entry => InviteViewScope::Entry,
            InviteViewScope::Chapter => InviteViewScope::Chapter,
            InviteViewScope::Other(v) => InviteViewScope::Other(v.into_static()),
        }
    }
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum InviteViewStatus<S: BosStr = DefaultStr> {
    Pending,
    Accepted,
    Expired,
    Revoked,
    Other(S),
}

impl<S: BosStr> InviteViewStatus<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Pending => "pending",
            Self::Accepted => "accepted",
            Self::Expired => "expired",
            Self::Revoked => "revoked",
            Self::Other(s) => s.as_ref(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "pending" => Self::Pending,
            "accepted" => Self::Accepted,
            "expired" => Self::Expired,
            "revoked" => Self::Revoked,
            _ => Self::Other(s),
        }
    }
}

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

impl<S: BosStr> AsRef<str> for InviteViewStatus<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for InviteViewStatus<S> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = S::deserialize(deserializer)?;
        Ok(Self::from_value(s))
    }
}

impl<S: BosStr + Default> Default for InviteViewStatus<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for InviteViewStatus<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = InviteViewStatus<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            InviteViewStatus::Pending => InviteViewStatus::Pending,
            InviteViewStatus::Accepted => InviteViewStatus::Accepted,
            InviteViewStatus::Expired => InviteViewStatus::Expired,
            InviteViewStatus::Revoked => InviteViewStatus::Revoked,
            InviteViewStatus::Other(v) => InviteViewStatus::Other(v.into_static()),
        }
    }
}

/// Collaboration scoped to an entire notebook.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Notebook;
impl core::fmt::Display for Notebook {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "notebook")
    }
}

/// Individual participant's state in a collaboration. Distinguishes 'was collaborator' vs 'never was'.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ParticipantStateView<S: BosStr = DefaultStr> {
    ///If they accepted (even if later broken)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub accept_uri: Option<AtUri<S>>,
    ///Why the relationship ended, if applicable
    #[serde(skip_serializing_if = "Option::is_none")]
    pub end_reason: Option<ParticipantStateViewEndReason<S>>,
    ///When they first contributed
    #[serde(skip_serializing_if = "Option::is_none")]
    pub first_edit_at: Option<Datetime>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub invite_uri: Option<AtUri<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub last_edit_at: Option<Datetime>,
    ///Their published copy if any
    #[serde(skip_serializing_if = "Option::is_none")]
    pub published_version: Option<StrongRef<S>>,
    ///When left/removed/expired
    #[serde(skip_serializing_if = "Option::is_none")]
    pub relationship_ended_at: Option<Datetime>,
    pub role: ParticipantStateViewRole<S>,
    ///active=can edit, invited=pending, left=voluntarily departed, removed=invite revoked, expired=invite timed out
    pub status: ParticipantStateViewStatus<S>,
    pub user: ProfileViewBasic<S>,
    ///True if they ever had active collaboration status
    #[serde(skip_serializing_if = "Option::is_none")]
    pub was_collaborator: Option<bool>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Why the relationship ended, if applicable

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ParticipantStateViewEndReason<S: BosStr = DefaultStr> {
    VoluntaryLeave,
    InviteRevoked,
    InviteExpired,
    OwnerDeletedResource,
    Other(S),
}

impl<S: BosStr> ParticipantStateViewEndReason<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::VoluntaryLeave => "voluntary_leave",
            Self::InviteRevoked => "invite_revoked",
            Self::InviteExpired => "invite_expired",
            Self::OwnerDeletedResource => "owner_deleted_resource",
            Self::Other(s) => s.as_ref(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "voluntary_leave" => Self::VoluntaryLeave,
            "invite_revoked" => Self::InviteRevoked,
            "invite_expired" => Self::InviteExpired,
            "owner_deleted_resource" => Self::OwnerDeletedResource,
            _ => Self::Other(s),
        }
    }
}

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

impl<S: BosStr> AsRef<str> for ParticipantStateViewEndReason<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de>
for ParticipantStateViewEndReason<S> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = S::deserialize(deserializer)?;
        Ok(Self::from_value(s))
    }
}

impl<S: BosStr + Default> Default for ParticipantStateViewEndReason<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for ParticipantStateViewEndReason<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = ParticipantStateViewEndReason<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            ParticipantStateViewEndReason::VoluntaryLeave => {
                ParticipantStateViewEndReason::VoluntaryLeave
            }
            ParticipantStateViewEndReason::InviteRevoked => {
                ParticipantStateViewEndReason::InviteRevoked
            }
            ParticipantStateViewEndReason::InviteExpired => {
                ParticipantStateViewEndReason::InviteExpired
            }
            ParticipantStateViewEndReason::OwnerDeletedResource => {
                ParticipantStateViewEndReason::OwnerDeletedResource
            }
            ParticipantStateViewEndReason::Other(v) => {
                ParticipantStateViewEndReason::Other(v.into_static())
            }
        }
    }
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ParticipantStateViewRole<S: BosStr = DefaultStr> {
    Owner,
    Collaborator,
    FormerCollaborator,
    Other(S),
}

impl<S: BosStr> ParticipantStateViewRole<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Owner => "owner",
            Self::Collaborator => "collaborator",
            Self::FormerCollaborator => "former_collaborator",
            Self::Other(s) => s.as_ref(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "owner" => Self::Owner,
            "collaborator" => Self::Collaborator,
            "former_collaborator" => Self::FormerCollaborator,
            _ => Self::Other(s),
        }
    }
}

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

impl<S: BosStr> AsRef<str> for ParticipantStateViewRole<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de>
for ParticipantStateViewRole<S> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = S::deserialize(deserializer)?;
        Ok(Self::from_value(s))
    }
}

impl<S: BosStr + Default> Default for ParticipantStateViewRole<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for ParticipantStateViewRole<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = ParticipantStateViewRole<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            ParticipantStateViewRole::Owner => ParticipantStateViewRole::Owner,
            ParticipantStateViewRole::Collaborator => {
                ParticipantStateViewRole::Collaborator
            }
            ParticipantStateViewRole::FormerCollaborator => {
                ParticipantStateViewRole::FormerCollaborator
            }
            ParticipantStateViewRole::Other(v) => {
                ParticipantStateViewRole::Other(v.into_static())
            }
        }
    }
}

/// active=can edit, invited=pending, left=voluntarily departed, removed=invite revoked, expired=invite timed out

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ParticipantStateViewStatus<S: BosStr = DefaultStr> {
    Active,
    Invited,
    Left,
    Removed,
    Expired,
    Other(S),
}

impl<S: BosStr> ParticipantStateViewStatus<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Active => "active",
            Self::Invited => "invited",
            Self::Left => "left",
            Self::Removed => "removed",
            Self::Expired => "expired",
            Self::Other(s) => s.as_ref(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "active" => Self::Active,
            "invited" => Self::Invited,
            "left" => Self::Left,
            "removed" => Self::Removed,
            "expired" => Self::Expired,
            _ => Self::Other(s),
        }
    }
}

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

impl<S: BosStr> AsRef<str> for ParticipantStateViewStatus<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de>
for ParticipantStateViewStatus<S> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = S::deserialize(deserializer)?;
        Ok(Self::from_value(s))
    }
}

impl<S: BosStr + Default> Default for ParticipantStateViewStatus<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for ParticipantStateViewStatus<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = ParticipantStateViewStatus<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            ParticipantStateViewStatus::Active => ParticipantStateViewStatus::Active,
            ParticipantStateViewStatus::Invited => ParticipantStateViewStatus::Invited,
            ParticipantStateViewStatus::Left => ParticipantStateViewStatus::Left,
            ParticipantStateViewStatus::Removed => ParticipantStateViewStatus::Removed,
            ParticipantStateViewStatus::Expired => ParticipantStateViewStatus::Expired,
            ParticipantStateViewStatus::Other(v) => {
                ParticipantStateViewStatus::Other(v.into_static())
            }
        }
    }
}

/// Active real-time collaboration session.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SessionView<S: BosStr = DefaultStr> {
    pub created_at: Datetime,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub expires_at: Option<Datetime>,
    pub node_id: S,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub relay_url: Option<UriValue<S>>,
    pub resource: StrongRef<S>,
    pub uri: AtUri<S>,
    pub user: ProfileViewBasic<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for CollaborationStateView<S> {
    fn nsid() -> &'static str {
        "sh.weaver.collab.defs"
    }
    fn def_name() -> &'static str {
        "collaborationStateView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_collab_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for FormerCollaboratorView<S> {
    fn nsid() -> &'static str {
        "sh.weaver.collab.defs"
    }
    fn def_name() -> &'static str {
        "formerCollaboratorView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_collab_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for InviteView<S> {
    fn nsid() -> &'static str {
        "sh.weaver.collab.defs"
    }
    fn def_name() -> &'static str {
        "inviteView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_collab_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ParticipantStateView<S> {
    fn nsid() -> &'static str {
        "sh.weaver.collab.defs"
    }
    fn def_name() -> &'static str {
        "participantStateView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_collab_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for SessionView<S> {
    fn nsid() -> &'static str {
        "sh.weaver.collab.defs"
    }
    fn def_name() -> &'static str {
        "sessionView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_collab_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod collaboration_state_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 Participants;
        type Resource;
        type Status;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Participants = Unset;
        type Resource = Unset;
        type Status = Unset;
    }
    ///State transition - sets the `participants` field to Set
    pub struct SetParticipants<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetParticipants<St> {}
    impl<St: State> State for SetParticipants<St> {
        type Participants = Set<members::participants>;
        type Resource = St::Resource;
        type Status = St::Status;
    }
    ///State transition - sets the `resource` field to Set
    pub struct SetResource<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetResource<St> {}
    impl<St: State> State for SetResource<St> {
        type Participants = St::Participants;
        type Resource = Set<members::resource>;
        type Status = St::Status;
    }
    ///State transition - sets the `status` field to Set
    pub struct SetStatus<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetStatus<St> {}
    impl<St: State> State for SetStatus<St> {
        type Participants = St::Participants;
        type Resource = St::Resource;
        type Status = Set<members::status>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `participants` field
        pub struct participants(());
        ///Marker type for the `resource` field
        pub struct resource(());
        ///Marker type for the `status` field
        pub struct status(());
    }
}

/// Builder for constructing an instance of this type.
pub struct CollaborationStateViewBuilder<
    St: collaboration_state_view_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<AtUri<S>>,
        Option<Datetime>,
        Option<Datetime>,
        Option<Vec<collab::FormerCollaboratorView<S>>>,
        Option<bool>,
        Option<bool>,
        Option<bool>,
        Option<Datetime>,
        Option<Vec<collab::ParticipantStateView<S>>>,
        Option<Vec<PublishedVersionView<S>>>,
        Option<StrongRef<S>>,
        Option<CollaborationStateViewStatus<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> CollaborationStateView<S> {
    /// Create a new builder for this type
    pub fn builder() -> CollaborationStateViewBuilder<
        collaboration_state_view_state::Empty,
        S,
    > {
        CollaborationStateViewBuilder::builder()
    }
}

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

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

impl<
    St: collaboration_state_view_state::State,
    S: BosStr,
> CollaborationStateViewBuilder<St, S> {
    /// Set the `canonicalUri` field (optional)
    pub fn canonical_uri(mut self, value: impl Into<Option<AtUri<S>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `canonicalUri` field to an Option value (optional)
    pub fn maybe_canonical_uri(mut self, value: Option<AtUri<S>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<
    St: collaboration_state_view_state::State,
    S: BosStr,
> CollaborationStateViewBuilder<St, S> {
    /// Set the `createdAt` field (optional)
    pub fn created_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `createdAt` field to an Option value (optional)
    pub fn maybe_created_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<
    St: collaboration_state_view_state::State,
    S: BosStr,
> CollaborationStateViewBuilder<St, S> {
    /// Set the `firstCollaboratorAddedAt` field (optional)
    pub fn first_collaborator_added_at(
        mut self,
        value: impl Into<Option<Datetime>>,
    ) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `firstCollaboratorAddedAt` field to an Option value (optional)
    pub fn maybe_first_collaborator_added_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<
    St: collaboration_state_view_state::State,
    S: BosStr,
> CollaborationStateViewBuilder<St, S> {
    /// Set the `formerParticipants` field (optional)
    pub fn former_participants(
        mut self,
        value: impl Into<Option<Vec<collab::FormerCollaboratorView<S>>>>,
    ) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `formerParticipants` field to an Option value (optional)
    pub fn maybe_former_participants(
        mut self,
        value: Option<Vec<collab::FormerCollaboratorView<S>>>,
    ) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<
    St: collaboration_state_view_state::State,
    S: BosStr,
> CollaborationStateViewBuilder<St, S> {
    /// Set the `hasDivergence` field (optional)
    pub fn has_divergence(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `hasDivergence` field to an Option value (optional)
    pub fn maybe_has_divergence(mut self, value: Option<bool>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<
    St: collaboration_state_view_state::State,
    S: BosStr,
> CollaborationStateViewBuilder<St, S> {
    /// Set the `hasFormerCollaborators` field (optional)
    pub fn has_former_collaborators(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `hasFormerCollaborators` field to an Option value (optional)
    pub fn maybe_has_former_collaborators(mut self, value: Option<bool>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<
    St: collaboration_state_view_state::State,
    S: BosStr,
> CollaborationStateViewBuilder<St, S> {
    /// Set the `hasOrphanedVersions` field (optional)
    pub fn has_orphaned_versions(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `hasOrphanedVersions` field to an Option value (optional)
    pub fn maybe_has_orphaned_versions(mut self, value: Option<bool>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<
    St: collaboration_state_view_state::State,
    S: BosStr,
> CollaborationStateViewBuilder<St, S> {
    /// Set the `lastSyncedAt` field (optional)
    pub fn last_synced_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `lastSyncedAt` field to an Option value (optional)
    pub fn maybe_last_synced_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<St, S: BosStr> CollaborationStateViewBuilder<St, S>
where
    St: collaboration_state_view_state::State,
    St::Participants: collaboration_state_view_state::IsUnset,
{
    /// Set the `participants` field (required)
    pub fn participants(
        mut self,
        value: impl Into<Vec<collab::ParticipantStateView<S>>>,
    ) -> CollaborationStateViewBuilder<
        collaboration_state_view_state::SetParticipants<St>,
        S,
    > {
        self._fields.8 = Option::Some(value.into());
        CollaborationStateViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<
    St: collaboration_state_view_state::State,
    S: BosStr,
> CollaborationStateViewBuilder<St, S> {
    /// Set the `publishedVersions` field (optional)
    pub fn published_versions(
        mut self,
        value: impl Into<Option<Vec<PublishedVersionView<S>>>>,
    ) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `publishedVersions` field to an Option value (optional)
    pub fn maybe_published_versions(
        mut self,
        value: Option<Vec<PublishedVersionView<S>>>,
    ) -> Self {
        self._fields.9 = value;
        self
    }
}

impl<St, S: BosStr> CollaborationStateViewBuilder<St, S>
where
    St: collaboration_state_view_state::State,
    St::Resource: collaboration_state_view_state::IsUnset,
{
    /// Set the `resource` field (required)
    pub fn resource(
        mut self,
        value: impl Into<StrongRef<S>>,
    ) -> CollaborationStateViewBuilder<
        collaboration_state_view_state::SetResource<St>,
        S,
    > {
        self._fields.10 = Option::Some(value.into());
        CollaborationStateViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> CollaborationStateViewBuilder<St, S>
where
    St: collaboration_state_view_state::State,
    St::Status: collaboration_state_view_state::IsUnset,
{
    /// Set the `status` field (required)
    pub fn status(
        mut self,
        value: impl Into<CollaborationStateViewStatus<S>>,
    ) -> CollaborationStateViewBuilder<
        collaboration_state_view_state::SetStatus<St>,
        S,
    > {
        self._fields.11 = Option::Some(value.into());
        CollaborationStateViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> CollaborationStateViewBuilder<St, S>
where
    St: collaboration_state_view_state::State,
    St::Participants: collaboration_state_view_state::IsSet,
    St::Resource: collaboration_state_view_state::IsSet,
    St::Status: collaboration_state_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> CollaborationStateView<S> {
        CollaborationStateView {
            canonical_uri: self._fields.0,
            created_at: self._fields.1,
            first_collaborator_added_at: self._fields.2,
            former_participants: self._fields.3,
            has_divergence: self._fields.4,
            has_former_collaborators: self._fields.5,
            has_orphaned_versions: self._fields.6,
            last_synced_at: self._fields.7,
            participants: self._fields.8.unwrap(),
            published_versions: self._fields.9,
            resource: self._fields.10.unwrap(),
            status: self._fields.11.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>>,
    ) -> CollaborationStateView<S> {
        CollaborationStateView {
            canonical_uri: self._fields.0,
            created_at: self._fields.1,
            first_collaborator_added_at: self._fields.2,
            former_participants: self._fields.3,
            has_divergence: self._fields.4,
            has_former_collaborators: self._fields.5,
            has_orphaned_versions: self._fields.6,
            last_synced_at: self._fields.7,
            participants: self._fields.8.unwrap(),
            published_versions: self._fields.9,
            resource: self._fields.10.unwrap(),
            status: self._fields.11.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_sh_weaver_collab_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("sh.weaver.collab.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("chapter"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("collaborationStateView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Full state of a collaboration relationship including version reconciliation. Tracks both current and former collaborators.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("resource"),
                            SmolStr::new_static("status"),
                            SmolStr::new_static("participants")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("canonicalUri"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The 'canonical' version URI (usually owner's)",
                                    ),
                                ),
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("firstCollaboratorAddedAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("formerParticipants"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "People who used to collaborate but relationship ended",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#formerCollaboratorView"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("hasDivergence"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("hasFormerCollaborators"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("hasOrphanedVersions"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("lastSyncedAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("participants"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static("Current active + invited participants"),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#participantStateView"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("publishedVersions"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static(
                                        "sh.weaver.notebook.defs#publishedVersionView",
                                    ),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("resource"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("status"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "active=normal, broken=all invites revoked/expired, diverged=versions differ, reconciled=was diverged but resolved",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("entry"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("formerCollaboratorView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Lightweight view for 'this person used to collaborate but doesn't anymore'.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("user"),
                            SmolStr::new_static("wasActiveFrom"),
                            SmolStr::new_static("wasActiveUntil"),
                            SmolStr::new_static("endReason")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("contributionCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("endReason"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("hasPublishedVersion"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("publishedVersionUri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("user"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "sh.weaver.actor.defs#profileViewBasic",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("wasActiveFrom"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("wasActiveUntil"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("inviteView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Hydrated view of a collaboration invite with status.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("uri"), SmolStr::new_static("cid"),
                            SmolStr::new_static("inviter"),
                            SmolStr::new_static("invitee"),
                            SmolStr::new_static("resource"),
                            SmolStr::new_static("createdAt"),
                            SmolStr::new_static("status")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("acceptUri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("acceptedAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("cid"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Cid),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("expiresAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("invitee"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "sh.weaver.actor.defs#profileViewBasic",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("inviter"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "sh.weaver.actor.defs#profileViewBasic",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("message"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("resource"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("resourceTitle"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("scope"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("status"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("notebook"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("participantStateView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Individual participant's state in a collaboration. Distinguishes 'was collaborator' vs 'never was'.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("user"), SmolStr::new_static("role"),
                            SmolStr::new_static("status")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("acceptUri"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "If they accepted (even if later broken)",
                                    ),
                                ),
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("endReason"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Why the relationship ended, if applicable",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("firstEditAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("When they first contributed"),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("inviteUri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("lastEditAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("publishedVersion"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("relationshipEndedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("When left/removed/expired"),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("role"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("status"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "active=can edit, invited=pending, left=voluntarily departed, removed=invite revoked, expired=invite timed out",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("user"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "sh.weaver.actor.defs#profileViewBasic",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("wasCollaborator"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("sessionView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Active real-time collaboration session."),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("uri"), SmolStr::new_static("user"),
                            SmolStr::new_static("resource"),
                            SmolStr::new_static("nodeId"),
                            SmolStr::new_static("createdAt")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("expiresAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("nodeId"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("relayUrl"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("resource"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("user"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "sh.weaver.actor.defs#profileViewBasic",
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod former_collaborator_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 EndReason;
        type User;
        type WasActiveFrom;
        type WasActiveUntil;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type EndReason = Unset;
        type User = Unset;
        type WasActiveFrom = Unset;
        type WasActiveUntil = Unset;
    }
    ///State transition - sets the `end_reason` field to Set
    pub struct SetEndReason<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetEndReason<St> {}
    impl<St: State> State for SetEndReason<St> {
        type EndReason = Set<members::end_reason>;
        type User = St::User;
        type WasActiveFrom = St::WasActiveFrom;
        type WasActiveUntil = St::WasActiveUntil;
    }
    ///State transition - sets the `user` field to Set
    pub struct SetUser<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUser<St> {}
    impl<St: State> State for SetUser<St> {
        type EndReason = St::EndReason;
        type User = Set<members::user>;
        type WasActiveFrom = St::WasActiveFrom;
        type WasActiveUntil = St::WasActiveUntil;
    }
    ///State transition - sets the `was_active_from` field to Set
    pub struct SetWasActiveFrom<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetWasActiveFrom<St> {}
    impl<St: State> State for SetWasActiveFrom<St> {
        type EndReason = St::EndReason;
        type User = St::User;
        type WasActiveFrom = Set<members::was_active_from>;
        type WasActiveUntil = St::WasActiveUntil;
    }
    ///State transition - sets the `was_active_until` field to Set
    pub struct SetWasActiveUntil<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetWasActiveUntil<St> {}
    impl<St: State> State for SetWasActiveUntil<St> {
        type EndReason = St::EndReason;
        type User = St::User;
        type WasActiveFrom = St::WasActiveFrom;
        type WasActiveUntil = Set<members::was_active_until>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `end_reason` field
        pub struct end_reason(());
        ///Marker type for the `user` field
        pub struct user(());
        ///Marker type for the `was_active_from` field
        pub struct was_active_from(());
        ///Marker type for the `was_active_until` field
        pub struct was_active_until(());
    }
}

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

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

impl<S: BosStr> FormerCollaboratorView<S> {
    /// Create a new builder for this type
    pub fn builder() -> FormerCollaboratorViewBuilder<
        former_collaborator_view_state::Empty,
        S,
    > {
        FormerCollaboratorViewBuilder::builder()
    }
}

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

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

impl<
    St: former_collaborator_view_state::State,
    S: BosStr,
> FormerCollaboratorViewBuilder<St, S> {
    /// Set the `contributionCount` field (optional)
    pub fn contribution_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `contributionCount` field to an Option value (optional)
    pub fn maybe_contribution_count(mut self, value: Option<i64>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St, S: BosStr> FormerCollaboratorViewBuilder<St, S>
where
    St: former_collaborator_view_state::State,
    St::EndReason: former_collaborator_view_state::IsUnset,
{
    /// Set the `endReason` field (required)
    pub fn end_reason(
        mut self,
        value: impl Into<FormerCollaboratorViewEndReason<S>>,
    ) -> FormerCollaboratorViewBuilder<
        former_collaborator_view_state::SetEndReason<St>,
        S,
    > {
        self._fields.1 = Option::Some(value.into());
        FormerCollaboratorViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<
    St: former_collaborator_view_state::State,
    S: BosStr,
> FormerCollaboratorViewBuilder<St, S> {
    /// Set the `hasPublishedVersion` field (optional)
    pub fn has_published_version(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `hasPublishedVersion` field to an Option value (optional)
    pub fn maybe_has_published_version(mut self, value: Option<bool>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<
    St: former_collaborator_view_state::State,
    S: BosStr,
> FormerCollaboratorViewBuilder<St, S> {
    /// Set the `publishedVersionUri` field (optional)
    pub fn published_version_uri(mut self, value: impl Into<Option<AtUri<S>>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `publishedVersionUri` field to an Option value (optional)
    pub fn maybe_published_version_uri(mut self, value: Option<AtUri<S>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St, S: BosStr> FormerCollaboratorViewBuilder<St, S>
where
    St: former_collaborator_view_state::State,
    St::User: former_collaborator_view_state::IsUnset,
{
    /// Set the `user` field (required)
    pub fn user(
        mut self,
        value: impl Into<ProfileViewBasic<S>>,
    ) -> FormerCollaboratorViewBuilder<former_collaborator_view_state::SetUser<St>, S> {
        self._fields.4 = Option::Some(value.into());
        FormerCollaboratorViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> FormerCollaboratorViewBuilder<St, S>
where
    St: former_collaborator_view_state::State,
    St::WasActiveFrom: former_collaborator_view_state::IsUnset,
{
    /// Set the `wasActiveFrom` field (required)
    pub fn was_active_from(
        mut self,
        value: impl Into<Datetime>,
    ) -> FormerCollaboratorViewBuilder<
        former_collaborator_view_state::SetWasActiveFrom<St>,
        S,
    > {
        self._fields.5 = Option::Some(value.into());
        FormerCollaboratorViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> FormerCollaboratorViewBuilder<St, S>
where
    St: former_collaborator_view_state::State,
    St::WasActiveUntil: former_collaborator_view_state::IsUnset,
{
    /// Set the `wasActiveUntil` field (required)
    pub fn was_active_until(
        mut self,
        value: impl Into<Datetime>,
    ) -> FormerCollaboratorViewBuilder<
        former_collaborator_view_state::SetWasActiveUntil<St>,
        S,
    > {
        self._fields.6 = Option::Some(value.into());
        FormerCollaboratorViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> FormerCollaboratorViewBuilder<St, S>
where
    St: former_collaborator_view_state::State,
    St::EndReason: former_collaborator_view_state::IsSet,
    St::User: former_collaborator_view_state::IsSet,
    St::WasActiveFrom: former_collaborator_view_state::IsSet,
    St::WasActiveUntil: former_collaborator_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> FormerCollaboratorView<S> {
        FormerCollaboratorView {
            contribution_count: self._fields.0,
            end_reason: self._fields.1.unwrap(),
            has_published_version: self._fields.2,
            published_version_uri: self._fields.3,
            user: self._fields.4.unwrap(),
            was_active_from: self._fields.5.unwrap(),
            was_active_until: self._fields.6.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> FormerCollaboratorView<S> {
        FormerCollaboratorView {
            contribution_count: self._fields.0,
            end_reason: self._fields.1.unwrap(),
            has_published_version: self._fields.2,
            published_version_uri: self._fields.3,
            user: self._fields.4.unwrap(),
            was_active_from: self._fields.5.unwrap(),
            was_active_until: self._fields.6.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod invite_view_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Cid;
        type CreatedAt;
        type Invitee;
        type Inviter;
        type Resource;
        type Status;
        type Uri;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Cid = Unset;
        type CreatedAt = Unset;
        type Invitee = Unset;
        type Inviter = Unset;
        type Resource = Unset;
        type Status = Unset;
        type Uri = Unset;
    }
    ///State transition - sets the `cid` field to Set
    pub struct SetCid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCid<St> {}
    impl<St: State> State for SetCid<St> {
        type Cid = Set<members::cid>;
        type CreatedAt = St::CreatedAt;
        type Invitee = St::Invitee;
        type Inviter = St::Inviter;
        type Resource = St::Resource;
        type Status = St::Status;
        type Uri = St::Uri;
    }
    ///State transition - sets the `created_at` field to Set
    pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
    impl<St: State> State for SetCreatedAt<St> {
        type Cid = St::Cid;
        type CreatedAt = Set<members::created_at>;
        type Invitee = St::Invitee;
        type Inviter = St::Inviter;
        type Resource = St::Resource;
        type Status = St::Status;
        type Uri = St::Uri;
    }
    ///State transition - sets the `invitee` field to Set
    pub struct SetInvitee<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetInvitee<St> {}
    impl<St: State> State for SetInvitee<St> {
        type Cid = St::Cid;
        type CreatedAt = St::CreatedAt;
        type Invitee = Set<members::invitee>;
        type Inviter = St::Inviter;
        type Resource = St::Resource;
        type Status = St::Status;
        type Uri = St::Uri;
    }
    ///State transition - sets the `inviter` field to Set
    pub struct SetInviter<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetInviter<St> {}
    impl<St: State> State for SetInviter<St> {
        type Cid = St::Cid;
        type CreatedAt = St::CreatedAt;
        type Invitee = St::Invitee;
        type Inviter = Set<members::inviter>;
        type Resource = St::Resource;
        type Status = St::Status;
        type Uri = St::Uri;
    }
    ///State transition - sets the `resource` field to Set
    pub struct SetResource<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetResource<St> {}
    impl<St: State> State for SetResource<St> {
        type Cid = St::Cid;
        type CreatedAt = St::CreatedAt;
        type Invitee = St::Invitee;
        type Inviter = St::Inviter;
        type Resource = Set<members::resource>;
        type Status = St::Status;
        type Uri = St::Uri;
    }
    ///State transition - sets the `status` field to Set
    pub struct SetStatus<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetStatus<St> {}
    impl<St: State> State for SetStatus<St> {
        type Cid = St::Cid;
        type CreatedAt = St::CreatedAt;
        type Invitee = St::Invitee;
        type Inviter = St::Inviter;
        type Resource = St::Resource;
        type Status = Set<members::status>;
        type Uri = St::Uri;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUri<St> {}
    impl<St: State> State for SetUri<St> {
        type Cid = St::Cid;
        type CreatedAt = St::CreatedAt;
        type Invitee = St::Invitee;
        type Inviter = St::Inviter;
        type Resource = St::Resource;
        type Status = St::Status;
        type Uri = Set<members::uri>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `cid` field
        pub struct cid(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `invitee` field
        pub struct invitee(());
        ///Marker type for the `inviter` field
        pub struct inviter(());
        ///Marker type for the `resource` field
        pub struct resource(());
        ///Marker type for the `status` field
        pub struct status(());
        ///Marker type for the `uri` field
        pub struct uri(());
    }
}

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

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

impl<S: BosStr> InviteView<S> {
    /// Create a new builder for this type
    pub fn builder() -> InviteViewBuilder<invite_view_state::Empty, S> {
        InviteViewBuilder::builder()
    }
}

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

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

impl<St: invite_view_state::State, S: BosStr> InviteViewBuilder<St, S> {
    /// Set the `acceptUri` field (optional)
    pub fn accept_uri(mut self, value: impl Into<Option<AtUri<S>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `acceptUri` field to an Option value (optional)
    pub fn maybe_accept_uri(mut self, value: Option<AtUri<S>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St: invite_view_state::State, S: BosStr> InviteViewBuilder<St, S> {
    /// Set the `acceptedAt` field (optional)
    pub fn accepted_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `acceptedAt` field to an Option value (optional)
    pub fn maybe_accepted_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.1 = value;
        self
    }
}

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

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

impl<St: invite_view_state::State, S: BosStr> InviteViewBuilder<St, S> {
    /// Set the `expiresAt` field (optional)
    pub fn expires_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `expiresAt` field to an Option value (optional)
    pub fn maybe_expires_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<St, S: BosStr> InviteViewBuilder<St, S>
where
    St: invite_view_state::State,
    St::Invitee: invite_view_state::IsUnset,
{
    /// Set the `invitee` field (required)
    pub fn invitee(
        mut self,
        value: impl Into<ProfileViewBasic<S>>,
    ) -> InviteViewBuilder<invite_view_state::SetInvitee<St>, S> {
        self._fields.5 = Option::Some(value.into());
        InviteViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> InviteViewBuilder<St, S>
where
    St: invite_view_state::State,
    St::Inviter: invite_view_state::IsUnset,
{
    /// Set the `inviter` field (required)
    pub fn inviter(
        mut self,
        value: impl Into<ProfileViewBasic<S>>,
    ) -> InviteViewBuilder<invite_view_state::SetInviter<St>, S> {
        self._fields.6 = Option::Some(value.into());
        InviteViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: invite_view_state::State, S: BosStr> InviteViewBuilder<St, S> {
    /// Set the `message` field (optional)
    pub fn message(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `message` field to an Option value (optional)
    pub fn maybe_message(mut self, value: Option<S>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<St, S: BosStr> InviteViewBuilder<St, S>
where
    St: invite_view_state::State,
    St::Resource: invite_view_state::IsUnset,
{
    /// Set the `resource` field (required)
    pub fn resource(
        mut self,
        value: impl Into<StrongRef<S>>,
    ) -> InviteViewBuilder<invite_view_state::SetResource<St>, S> {
        self._fields.8 = Option::Some(value.into());
        InviteViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: invite_view_state::State, S: BosStr> InviteViewBuilder<St, S> {
    /// Set the `resourceTitle` field (optional)
    pub fn resource_title(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `resourceTitle` field to an Option value (optional)
    pub fn maybe_resource_title(mut self, value: Option<S>) -> Self {
        self._fields.9 = value;
        self
    }
}

impl<St: invite_view_state::State, S: BosStr> InviteViewBuilder<St, S> {
    /// Set the `scope` field (optional)
    pub fn scope(mut self, value: impl Into<Option<InviteViewScope<S>>>) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `scope` field to an Option value (optional)
    pub fn maybe_scope(mut self, value: Option<InviteViewScope<S>>) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<St, S: BosStr> InviteViewBuilder<St, S>
where
    St: invite_view_state::State,
    St::Status: invite_view_state::IsUnset,
{
    /// Set the `status` field (required)
    pub fn status(
        mut self,
        value: impl Into<InviteViewStatus<S>>,
    ) -> InviteViewBuilder<invite_view_state::SetStatus<St>, S> {
        self._fields.11 = Option::Some(value.into());
        InviteViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> InviteViewBuilder<St, S>
where
    St: invite_view_state::State,
    St::Cid: invite_view_state::IsSet,
    St::CreatedAt: invite_view_state::IsSet,
    St::Invitee: invite_view_state::IsSet,
    St::Inviter: invite_view_state::IsSet,
    St::Resource: invite_view_state::IsSet,
    St::Status: invite_view_state::IsSet,
    St::Uri: invite_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> InviteView<S> {
        InviteView {
            accept_uri: self._fields.0,
            accepted_at: self._fields.1,
            cid: self._fields.2.unwrap(),
            created_at: self._fields.3.unwrap(),
            expires_at: self._fields.4,
            invitee: self._fields.5.unwrap(),
            inviter: self._fields.6.unwrap(),
            message: self._fields.7,
            resource: self._fields.8.unwrap(),
            resource_title: self._fields.9,
            scope: self._fields.10,
            status: self._fields.11.unwrap(),
            uri: self._fields.12.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>>,
    ) -> InviteView<S> {
        InviteView {
            accept_uri: self._fields.0,
            accepted_at: self._fields.1,
            cid: self._fields.2.unwrap(),
            created_at: self._fields.3.unwrap(),
            expires_at: self._fields.4,
            invitee: self._fields.5.unwrap(),
            inviter: self._fields.6.unwrap(),
            message: self._fields.7,
            resource: self._fields.8.unwrap(),
            resource_title: self._fields.9,
            scope: self._fields.10,
            status: self._fields.11.unwrap(),
            uri: self._fields.12.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod participant_state_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 Role;
        type Status;
        type User;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Role = Unset;
        type Status = Unset;
        type User = Unset;
    }
    ///State transition - sets the `role` field to Set
    pub struct SetRole<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRole<St> {}
    impl<St: State> State for SetRole<St> {
        type Role = Set<members::role>;
        type Status = St::Status;
        type User = St::User;
    }
    ///State transition - sets the `status` field to Set
    pub struct SetStatus<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetStatus<St> {}
    impl<St: State> State for SetStatus<St> {
        type Role = St::Role;
        type Status = Set<members::status>;
        type User = St::User;
    }
    ///State transition - sets the `user` field to Set
    pub struct SetUser<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUser<St> {}
    impl<St: State> State for SetUser<St> {
        type Role = St::Role;
        type Status = St::Status;
        type User = Set<members::user>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `role` field
        pub struct role(());
        ///Marker type for the `status` field
        pub struct status(());
        ///Marker type for the `user` field
        pub struct user(());
    }
}

/// Builder for constructing an instance of this type.
pub struct ParticipantStateViewBuilder<
    St: participant_state_view_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<AtUri<S>>,
        Option<ParticipantStateViewEndReason<S>>,
        Option<Datetime>,
        Option<AtUri<S>>,
        Option<Datetime>,
        Option<StrongRef<S>>,
        Option<Datetime>,
        Option<ParticipantStateViewRole<S>>,
        Option<ParticipantStateViewStatus<S>>,
        Option<ProfileViewBasic<S>>,
        Option<bool>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> ParticipantStateView<S> {
    /// Create a new builder for this type
    pub fn builder() -> ParticipantStateViewBuilder<
        participant_state_view_state::Empty,
        S,
    > {
        ParticipantStateViewBuilder::builder()
    }
}

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

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

impl<
    St: participant_state_view_state::State,
    S: BosStr,
> ParticipantStateViewBuilder<St, S> {
    /// Set the `acceptUri` field (optional)
    pub fn accept_uri(mut self, value: impl Into<Option<AtUri<S>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `acceptUri` field to an Option value (optional)
    pub fn maybe_accept_uri(mut self, value: Option<AtUri<S>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<
    St: participant_state_view_state::State,
    S: BosStr,
> ParticipantStateViewBuilder<St, S> {
    /// Set the `endReason` field (optional)
    pub fn end_reason(
        mut self,
        value: impl Into<Option<ParticipantStateViewEndReason<S>>>,
    ) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `endReason` field to an Option value (optional)
    pub fn maybe_end_reason(
        mut self,
        value: Option<ParticipantStateViewEndReason<S>>,
    ) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<
    St: participant_state_view_state::State,
    S: BosStr,
> ParticipantStateViewBuilder<St, S> {
    /// Set the `firstEditAt` field (optional)
    pub fn first_edit_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `firstEditAt` field to an Option value (optional)
    pub fn maybe_first_edit_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<
    St: participant_state_view_state::State,
    S: BosStr,
> ParticipantStateViewBuilder<St, S> {
    /// Set the `inviteUri` field (optional)
    pub fn invite_uri(mut self, value: impl Into<Option<AtUri<S>>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `inviteUri` field to an Option value (optional)
    pub fn maybe_invite_uri(mut self, value: Option<AtUri<S>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<
    St: participant_state_view_state::State,
    S: BosStr,
> ParticipantStateViewBuilder<St, S> {
    /// Set the `lastEditAt` field (optional)
    pub fn last_edit_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `lastEditAt` field to an Option value (optional)
    pub fn maybe_last_edit_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<
    St: participant_state_view_state::State,
    S: BosStr,
> ParticipantStateViewBuilder<St, S> {
    /// Set the `publishedVersion` field (optional)
    pub fn published_version(mut self, value: impl Into<Option<StrongRef<S>>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `publishedVersion` field to an Option value (optional)
    pub fn maybe_published_version(mut self, value: Option<StrongRef<S>>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<
    St: participant_state_view_state::State,
    S: BosStr,
> ParticipantStateViewBuilder<St, S> {
    /// Set the `relationshipEndedAt` field (optional)
    pub fn relationship_ended_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `relationshipEndedAt` field to an Option value (optional)
    pub fn maybe_relationship_ended_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<St, S: BosStr> ParticipantStateViewBuilder<St, S>
where
    St: participant_state_view_state::State,
    St::Role: participant_state_view_state::IsUnset,
{
    /// Set the `role` field (required)
    pub fn role(
        mut self,
        value: impl Into<ParticipantStateViewRole<S>>,
    ) -> ParticipantStateViewBuilder<participant_state_view_state::SetRole<St>, S> {
        self._fields.7 = Option::Some(value.into());
        ParticipantStateViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ParticipantStateViewBuilder<St, S>
where
    St: participant_state_view_state::State,
    St::Status: participant_state_view_state::IsUnset,
{
    /// Set the `status` field (required)
    pub fn status(
        mut self,
        value: impl Into<ParticipantStateViewStatus<S>>,
    ) -> ParticipantStateViewBuilder<participant_state_view_state::SetStatus<St>, S> {
        self._fields.8 = Option::Some(value.into());
        ParticipantStateViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ParticipantStateViewBuilder<St, S>
where
    St: participant_state_view_state::State,
    St::User: participant_state_view_state::IsUnset,
{
    /// Set the `user` field (required)
    pub fn user(
        mut self,
        value: impl Into<ProfileViewBasic<S>>,
    ) -> ParticipantStateViewBuilder<participant_state_view_state::SetUser<St>, S> {
        self._fields.9 = Option::Some(value.into());
        ParticipantStateViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<
    St: participant_state_view_state::State,
    S: BosStr,
> ParticipantStateViewBuilder<St, S> {
    /// Set the `wasCollaborator` field (optional)
    pub fn was_collaborator(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `wasCollaborator` field to an Option value (optional)
    pub fn maybe_was_collaborator(mut self, value: Option<bool>) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<St, S: BosStr> ParticipantStateViewBuilder<St, S>
where
    St: participant_state_view_state::State,
    St::Role: participant_state_view_state::IsSet,
    St::Status: participant_state_view_state::IsSet,
    St::User: participant_state_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ParticipantStateView<S> {
        ParticipantStateView {
            accept_uri: self._fields.0,
            end_reason: self._fields.1,
            first_edit_at: self._fields.2,
            invite_uri: self._fields.3,
            last_edit_at: self._fields.4,
            published_version: self._fields.5,
            relationship_ended_at: self._fields.6,
            role: self._fields.7.unwrap(),
            status: self._fields.8.unwrap(),
            user: self._fields.9.unwrap(),
            was_collaborator: 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>>,
    ) -> ParticipantStateView<S> {
        ParticipantStateView {
            accept_uri: self._fields.0,
            end_reason: self._fields.1,
            first_edit_at: self._fields.2,
            invite_uri: self._fields.3,
            last_edit_at: self._fields.4,
            published_version: self._fields.5,
            relationship_ended_at: self._fields.6,
            role: self._fields.7.unwrap(),
            status: self._fields.8.unwrap(),
            user: self._fields.9.unwrap(),
            was_collaborator: self._fields.10,
            extra_data: Some(extra_data),
        }
    }
}

pub mod session_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 CreatedAt;
        type NodeId;
        type Resource;
        type Uri;
        type User;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type CreatedAt = Unset;
        type NodeId = Unset;
        type Resource = Unset;
        type Uri = Unset;
        type User = Unset;
    }
    ///State transition - sets the `created_at` field to Set
    pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
    impl<St: State> State for SetCreatedAt<St> {
        type CreatedAt = Set<members::created_at>;
        type NodeId = St::NodeId;
        type Resource = St::Resource;
        type Uri = St::Uri;
        type User = St::User;
    }
    ///State transition - sets the `node_id` field to Set
    pub struct SetNodeId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetNodeId<St> {}
    impl<St: State> State for SetNodeId<St> {
        type CreatedAt = St::CreatedAt;
        type NodeId = Set<members::node_id>;
        type Resource = St::Resource;
        type Uri = St::Uri;
        type User = St::User;
    }
    ///State transition - sets the `resource` field to Set
    pub struct SetResource<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetResource<St> {}
    impl<St: State> State for SetResource<St> {
        type CreatedAt = St::CreatedAt;
        type NodeId = St::NodeId;
        type Resource = Set<members::resource>;
        type Uri = St::Uri;
        type User = St::User;
    }
    ///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 CreatedAt = St::CreatedAt;
        type NodeId = St::NodeId;
        type Resource = St::Resource;
        type Uri = Set<members::uri>;
        type User = St::User;
    }
    ///State transition - sets the `user` field to Set
    pub struct SetUser<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUser<St> {}
    impl<St: State> State for SetUser<St> {
        type CreatedAt = St::CreatedAt;
        type NodeId = St::NodeId;
        type Resource = St::Resource;
        type Uri = St::Uri;
        type User = Set<members::user>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `node_id` field
        pub struct node_id(());
        ///Marker type for the `resource` field
        pub struct resource(());
        ///Marker type for the `uri` field
        pub struct uri(());
        ///Marker type for the `user` field
        pub struct user(());
    }
}

/// Builder for constructing an instance of this type.
pub struct SessionViewBuilder<St: session_view_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<Datetime>,
        Option<Datetime>,
        Option<S>,
        Option<UriValue<S>>,
        Option<StrongRef<S>>,
        Option<AtUri<S>>,
        Option<ProfileViewBasic<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> SessionView<S> {
    /// Create a new builder for this type
    pub fn builder() -> SessionViewBuilder<session_view_state::Empty, S> {
        SessionViewBuilder::builder()
    }
}

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

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

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

impl<St: session_view_state::State, S: BosStr> SessionViewBuilder<St, S> {
    /// Set the `expiresAt` field (optional)
    pub fn expires_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `expiresAt` field to an Option value (optional)
    pub fn maybe_expires_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St, S: BosStr> SessionViewBuilder<St, S>
where
    St: session_view_state::State,
    St::NodeId: session_view_state::IsUnset,
{
    /// Set the `nodeId` field (required)
    pub fn node_id(
        mut self,
        value: impl Into<S>,
    ) -> SessionViewBuilder<session_view_state::SetNodeId<St>, S> {
        self._fields.2 = Option::Some(value.into());
        SessionViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: session_view_state::State, S: BosStr> SessionViewBuilder<St, S> {
    /// Set the `relayUrl` field (optional)
    pub fn relay_url(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `relayUrl` field to an Option value (optional)
    pub fn maybe_relay_url(mut self, value: Option<UriValue<S>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St, S: BosStr> SessionViewBuilder<St, S>
where
    St: session_view_state::State,
    St::Resource: session_view_state::IsUnset,
{
    /// Set the `resource` field (required)
    pub fn resource(
        mut self,
        value: impl Into<StrongRef<S>>,
    ) -> SessionViewBuilder<session_view_state::SetResource<St>, S> {
        self._fields.4 = Option::Some(value.into());
        SessionViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> SessionViewBuilder<St, S>
where
    St: session_view_state::State,
    St::User: session_view_state::IsUnset,
{
    /// Set the `user` field (required)
    pub fn user(
        mut self,
        value: impl Into<ProfileViewBasic<S>>,
    ) -> SessionViewBuilder<session_view_state::SetUser<St>, S> {
        self._fields.6 = Option::Some(value.into());
        SessionViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SessionViewBuilder<St, S>
where
    St: session_view_state::State,
    St::CreatedAt: session_view_state::IsSet,
    St::NodeId: session_view_state::IsSet,
    St::Resource: session_view_state::IsSet,
    St::Uri: session_view_state::IsSet,
    St::User: session_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> SessionView<S> {
        SessionView {
            created_at: self._fields.0.unwrap(),
            expires_at: self._fields.1,
            node_id: self._fields.2.unwrap(),
            relay_url: self._fields.3,
            resource: self._fields.4.unwrap(),
            uri: self._fields.5.unwrap(),
            user: self._fields.6.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> SessionView<S> {
        SessionView {
            created_at: self._fields.0.unwrap(),
            expires_at: self._fields.1,
            node_id: self._fields.2.unwrap(),
            relay_url: self._fields.3,
            resource: self._fields.4.unwrap(),
            uri: self._fields.5.unwrap(),
            user: self._fields.6.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}