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

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

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

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::{Did, Datetime};
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, open_union};
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::chat_bsky::moderation::subscribe_mod_events;
/// Fired when a user accepts a chat convo, either explicitly or by sending a message.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct EventChatAccepted<S: BosStr = DefaultStr> {
    ///The DID of the person accepting the convo.
    pub actor_did: Did<S>,
    ///When the convo was originally created.
    pub convo_created_at: Datetime,
    pub convo_id: S,
    pub created_at: Datetime,
    ///Current member count at the time of the event. Only present for group convos.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub group_member_count: Option<i64>,
    ///The name of the group chat. Only present for group convos.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub group_name: Option<S>,
    ///How the convo was accepted.
    pub method: EventChatAcceptedMethod<S>,
    ///The DID of the group chat owner. Only present for group convos.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub owner_did: Option<Did<S>>,
    pub rev: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// How the convo was accepted.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum EventChatAcceptedMethod<S: BosStr = DefaultStr> {
    Explicit,
    Message,
    Other(S),
}

impl<S: BosStr> EventChatAcceptedMethod<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Explicit => "explicit",
            Self::Message => "message",
            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() {
            "explicit" => Self::Explicit,
            "message" => Self::Message,
            _ => Self::Other(s),
        }
    }
}

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

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

impl<S: BosStr> Serialize for EventChatAcceptedMethod<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 EventChatAcceptedMethod<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 EventChatAcceptedMethod<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

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

/// Fired when the first message was sent on a convo.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct EventConvoFirstMessage<S: BosStr = DefaultStr> {
    pub convo_id: S,
    pub created_at: Datetime,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub message_id: Option<S>,
    ///The list of DIDs message recipients. Does not include the sender, which is in the `user` field
    pub recipients: Vec<Did<S>>,
    pub rev: S,
    ///The DID of the message author.
    pub user: Did<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Fire when a group chat is created.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct EventGroupChatCreated<S: BosStr = DefaultStr> {
    ///The DID of the actor performing the action. For this event, same as ownerDid.
    pub actor_did: Did<S>,
    ///When the group was originally created.
    pub convo_created_at: Datetime,
    pub convo_id: S,
    pub created_at: Datetime,
    ///Current member count at the time of the event.
    pub group_member_count: i64,
    ///The name set at creation time.
    pub group_name: S,
    ///DIDs of everyone added at creation time.
    pub initial_member_dids: Vec<Did<S>>,
    ///The DID of the group chat owner.
    pub owner_did: Did<S>,
    pub rev: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Fired when a user requests to join a group chat via an join link that requires approval.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct EventGroupChatJoinRequest<S: BosStr = DefaultStr> {
    ///The DID of the person requesting to join.
    pub actor_did: Did<S>,
    ///When the group was originally created.
    pub convo_created_at: Datetime,
    pub convo_id: S,
    pub created_at: Datetime,
    ///Current member count at the time of the event.
    pub group_member_count: i64,
    pub group_name: S,
    ///The code of the join link used to request joining.
    pub join_link_code: S,
    ///The DID of the group chat owner.
    pub owner_did: Did<S>,
    pub rev: S,
    ///Whether the requesting member follows the group owner.
    pub subject_follows_owner: bool,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Fired when a join request is approved by the group owner.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct EventGroupChatJoinRequestApproved<S: BosStr = DefaultStr> {
    ///The DID of the owner approving the request.
    pub actor_did: Did<S>,
    ///When the group was originally created.
    pub convo_created_at: Datetime,
    pub convo_id: S,
    pub created_at: Datetime,
    ///Current member count at the time of the event.
    pub group_member_count: i64,
    pub group_name: S,
    ///The DID of the group chat owner.
    pub owner_did: Did<S>,
    pub rev: S,
    ///The DID of the member whose request was approved.
    pub subject_did: Did<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Fired when a join request is rejected by the group owner.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct EventGroupChatJoinRequestRejected<S: BosStr = DefaultStr> {
    ///The DID of the owner rejecting the request.
    pub actor_did: Did<S>,
    ///When the group was originally created.
    pub convo_created_at: Datetime,
    pub convo_id: S,
    pub created_at: Datetime,
    ///Current member count at the time of the event.
    pub group_member_count: i64,
    pub group_name: S,
    ///The DID of the group chat owner.
    pub owner_did: Did<S>,
    pub rev: S,
    ///The DID of the member whose request was rejected.
    pub subject_did: Did<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Fired when a member is added to a group chat. Note that members are added in the 'request' state.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct EventGroupChatMemberAdded<S: BosStr = DefaultStr> {
    ///The DID of the actor performing the action. For this event, same as ownerDid.
    pub actor_did: Did<S>,
    ///When the group was originally created.
    pub convo_created_at: Datetime,
    pub convo_id: S,
    pub created_at: Datetime,
    ///Current member count at the time of the event.
    pub group_member_count: i64,
    pub group_name: S,
    ///The DID of the group chat owner.
    pub owner_did: Did<S>,
    ///The number of members who have not yet accepted the convo.
    pub request_members_count: i64,
    pub rev: S,
    ///The DID of the member who was added.
    pub subject_did: Did<S>,
    ///Whether the added member follows the group owner.
    pub subject_follows_owner: bool,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Fired when a member joins a group chat via an join link that does not require approval.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct EventGroupChatMemberJoined<S: BosStr = DefaultStr> {
    ///The DID of the person joining.
    pub actor_did: Did<S>,
    ///When the group was originally created.
    pub convo_created_at: Datetime,
    pub convo_id: S,
    pub created_at: Datetime,
    ///Current member count at the time of the event.
    pub group_member_count: i64,
    pub group_name: S,
    ///The code of the join link used to join.
    pub join_link_code: S,
    ///The DID of the group chat owner.
    pub owner_did: Did<S>,
    pub rev: S,
    ///Whether the joining member follows the group owner.
    pub subject_follows_owner: bool,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Fired when a member leaves or is removed from a group chat.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct EventGroupChatMemberLeft<S: BosStr = DefaultStr> {
    ///The DID of the actor. For voluntary: the person leaving. For kicked: the owner.
    pub actor_did: Did<S>,
    ///When the group was originally created.
    pub convo_created_at: Datetime,
    pub convo_id: S,
    pub created_at: Datetime,
    ///Current member count at the time of the event.
    pub group_member_count: i64,
    pub group_name: S,
    ///How the member left.
    pub leave_method: EventGroupChatMemberLeftLeaveMethod<S>,
    ///The DID of the group chat owner.
    pub owner_did: Did<S>,
    pub rev: S,
    ///The DID of the member who left or was removed.
    pub subject_did: Did<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// How the member left.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum EventGroupChatMemberLeftLeaveMethod<S: BosStr = DefaultStr> {
    Voluntary,
    Kicked,
    Other(S),
}

impl<S: BosStr> EventGroupChatMemberLeftLeaveMethod<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Voluntary => "voluntary",
            Self::Kicked => "kicked",
            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" => Self::Voluntary,
            "kicked" => Self::Kicked,
            _ => Self::Other(s),
        }
    }
}

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

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

impl<S: BosStr> Serialize for EventGroupChatMemberLeftLeaveMethod<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 EventGroupChatMemberLeftLeaveMethod<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 EventGroupChatMemberLeftLeaveMethod<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

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

/// Fired when a group chat's metadata or status changes.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct EventGroupChatUpdated<S: BosStr = DefaultStr> {
    ///The DID of the actor performing the action (the owner).
    pub actor_did: Did<S>,
    ///When the group was originally created.
    pub convo_created_at: Datetime,
    pub convo_id: S,
    pub created_at: Datetime,
    ///Current member count at the time of the event.
    pub group_member_count: i64,
    ///Current group name.
    pub group_name: S,
    ///The code of the join link. Only present when updateType is join-link-related.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub join_link_code: Option<S>,
    ///Whether the join link is restricted to followers of the owner. Only present when updateType is join-link-related.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub join_link_followers_only: Option<bool>,
    ///Whether the join link requires owner approval to join. Only present when updateType is join-link-related.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub join_link_requires_approval: Option<bool>,
    ///Why the group was locked. Only present when updateType is 'locked'.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub lock_reason: Option<EventGroupChatUpdatedLockReason<S>>,
    ///The new group name. Only present when updateType is 'name_changed'.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub new_name: Option<S>,
    ///The previous group name. Only present when updateType is 'name_changed'.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub old_name: Option<S>,
    ///The DID of the group chat owner.
    pub owner_did: Did<S>,
    pub rev: S,
    ///What changed.
    pub update_type: EventGroupChatUpdatedUpdateType<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Why the group was locked. Only present when updateType is 'locked'.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum EventGroupChatUpdatedLockReason<S: BosStr = DefaultStr> {
    OwnerAction,
    OwnerLeft,
    OwnerDeactivated,
    OwnerDeleted,
    OwnerSuspended,
    OwnerTakenDown,
    LabelApplied,
    ConvoTakenDown,
    Other(S),
}

impl<S: BosStr> EventGroupChatUpdatedLockReason<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::OwnerAction => "owner_action",
            Self::OwnerLeft => "owner_left",
            Self::OwnerDeactivated => "owner_deactivated",
            Self::OwnerDeleted => "owner_deleted",
            Self::OwnerSuspended => "owner_suspended",
            Self::OwnerTakenDown => "owner_taken_down",
            Self::LabelApplied => "label_applied",
            Self::ConvoTakenDown => "convo_taken_down",
            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_action" => Self::OwnerAction,
            "owner_left" => Self::OwnerLeft,
            "owner_deactivated" => Self::OwnerDeactivated,
            "owner_deleted" => Self::OwnerDeleted,
            "owner_suspended" => Self::OwnerSuspended,
            "owner_taken_down" => Self::OwnerTakenDown,
            "label_applied" => Self::LabelApplied,
            "convo_taken_down" => Self::ConvoTakenDown,
            _ => Self::Other(s),
        }
    }
}

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

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

impl<S: BosStr> Serialize for EventGroupChatUpdatedLockReason<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 EventGroupChatUpdatedLockReason<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 EventGroupChatUpdatedLockReason<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for EventGroupChatUpdatedLockReason<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = EventGroupChatUpdatedLockReason<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            EventGroupChatUpdatedLockReason::OwnerAction => {
                EventGroupChatUpdatedLockReason::OwnerAction
            }
            EventGroupChatUpdatedLockReason::OwnerLeft => {
                EventGroupChatUpdatedLockReason::OwnerLeft
            }
            EventGroupChatUpdatedLockReason::OwnerDeactivated => {
                EventGroupChatUpdatedLockReason::OwnerDeactivated
            }
            EventGroupChatUpdatedLockReason::OwnerDeleted => {
                EventGroupChatUpdatedLockReason::OwnerDeleted
            }
            EventGroupChatUpdatedLockReason::OwnerSuspended => {
                EventGroupChatUpdatedLockReason::OwnerSuspended
            }
            EventGroupChatUpdatedLockReason::OwnerTakenDown => {
                EventGroupChatUpdatedLockReason::OwnerTakenDown
            }
            EventGroupChatUpdatedLockReason::LabelApplied => {
                EventGroupChatUpdatedLockReason::LabelApplied
            }
            EventGroupChatUpdatedLockReason::ConvoTakenDown => {
                EventGroupChatUpdatedLockReason::ConvoTakenDown
            }
            EventGroupChatUpdatedLockReason::Other(v) => {
                EventGroupChatUpdatedLockReason::Other(v.into_static())
            }
        }
    }
}

/// What changed.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum EventGroupChatUpdatedUpdateType<S: BosStr = DefaultStr> {
    NameChanged,
    Locked,
    LockedPermanently,
    Unlocked,
    JoinLinkCreated,
    JoinLinkDisabled,
    JoinLinkSettingsChanged,
    Other(S),
}

impl<S: BosStr> EventGroupChatUpdatedUpdateType<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::NameChanged => "name_changed",
            Self::Locked => "locked",
            Self::LockedPermanently => "locked_permanently",
            Self::Unlocked => "unlocked",
            Self::JoinLinkCreated => "join_link_created",
            Self::JoinLinkDisabled => "join_link_disabled",
            Self::JoinLinkSettingsChanged => "join_link_settings_changed",
            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() {
            "name_changed" => Self::NameChanged,
            "locked" => Self::Locked,
            "locked_permanently" => Self::LockedPermanently,
            "unlocked" => Self::Unlocked,
            "join_link_created" => Self::JoinLinkCreated,
            "join_link_disabled" => Self::JoinLinkDisabled,
            "join_link_settings_changed" => Self::JoinLinkSettingsChanged,
            _ => Self::Other(s),
        }
    }
}

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

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

impl<S: BosStr> Serialize for EventGroupChatUpdatedUpdateType<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 EventGroupChatUpdatedUpdateType<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 EventGroupChatUpdatedUpdateType<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for EventGroupChatUpdatedUpdateType<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = EventGroupChatUpdatedUpdateType<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            EventGroupChatUpdatedUpdateType::NameChanged => {
                EventGroupChatUpdatedUpdateType::NameChanged
            }
            EventGroupChatUpdatedUpdateType::Locked => {
                EventGroupChatUpdatedUpdateType::Locked
            }
            EventGroupChatUpdatedUpdateType::LockedPermanently => {
                EventGroupChatUpdatedUpdateType::LockedPermanently
            }
            EventGroupChatUpdatedUpdateType::Unlocked => {
                EventGroupChatUpdatedUpdateType::Unlocked
            }
            EventGroupChatUpdatedUpdateType::JoinLinkCreated => {
                EventGroupChatUpdatedUpdateType::JoinLinkCreated
            }
            EventGroupChatUpdatedUpdateType::JoinLinkDisabled => {
                EventGroupChatUpdatedUpdateType::JoinLinkDisabled
            }
            EventGroupChatUpdatedUpdateType::JoinLinkSettingsChanged => {
                EventGroupChatUpdatedUpdateType::JoinLinkSettingsChanged
            }
            EventGroupChatUpdatedUpdateType::Other(v) => {
                EventGroupChatUpdatedUpdateType::Other(v.into_static())
            }
        }
    }
}

/// Fired when a user exceeds a rate limit.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct EventRateLimitExceeded<S: BosStr = DefaultStr> {
    ///The DID of the user who hit the rate limit.
    pub actor_did: Did<S>,
    pub created_at: Datetime,
    ///The NSID of the endpoint that was rate limited.
    pub endpoint: S,
    pub rev: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SubscribeModEvents<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cursor: Option<S>,
}


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum SubscribeModEventsMessage<S: BosStr = DefaultStr> {
    #[serde(rename = "#eventConvoFirstMessage")]
    EventConvoFirstMessage(Box<subscribe_mod_events::EventConvoFirstMessage<S>>),
    #[serde(rename = "#eventGroupChatCreated")]
    EventGroupChatCreated(Box<subscribe_mod_events::EventGroupChatCreated<S>>),
    #[serde(rename = "#eventGroupChatMemberAdded")]
    EventGroupChatMemberAdded(Box<subscribe_mod_events::EventGroupChatMemberAdded<S>>),
    #[serde(rename = "#eventGroupChatMemberJoined")]
    EventGroupChatMemberJoined(Box<subscribe_mod_events::EventGroupChatMemberJoined<S>>),
    #[serde(rename = "#eventGroupChatJoinRequest")]
    EventGroupChatJoinRequest(Box<subscribe_mod_events::EventGroupChatJoinRequest<S>>),
    #[serde(rename = "#eventGroupChatJoinRequestApproved")]
    EventGroupChatJoinRequestApproved(
        Box<subscribe_mod_events::EventGroupChatJoinRequestApproved<S>>,
    ),
    #[serde(rename = "#eventGroupChatJoinRequestRejected")]
    EventGroupChatJoinRequestRejected(
        Box<subscribe_mod_events::EventGroupChatJoinRequestRejected<S>>,
    ),
    #[serde(rename = "#eventChatAccepted")]
    EventChatAccepted(Box<subscribe_mod_events::EventChatAccepted<S>>),
    #[serde(rename = "#eventGroupChatMemberLeft")]
    EventGroupChatMemberLeft(Box<subscribe_mod_events::EventGroupChatMemberLeft<S>>),
    #[serde(rename = "#eventGroupChatUpdated")]
    EventGroupChatUpdated(Box<subscribe_mod_events::EventGroupChatUpdated<S>>),
    #[serde(rename = "#eventRateLimitExceeded")]
    EventRateLimitExceeded(Box<subscribe_mod_events::EventRateLimitExceeded<S>>),
}

impl<S: BosStr> SubscribeModEventsMessage<S> {
    /// Decode a framed DAG-CBOR message (header + body).
    pub fn decode_framed<'de>(
        bytes: &'de [u8],
    ) -> Result<SubscribeModEventsMessage<S>, jacquard_common::error::DecodeError>
    where
        S: serde::Deserialize<'de>,
    {
        let (header, body) = jacquard_common::xrpc::subscription::parse_event_header(
            bytes,
        )?;
        match header.t.as_str() {
            "#eventConvoFirstMessage" => {
                let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(
                    body,
                )?;
                Ok(Self::EventConvoFirstMessage(Box::new(variant)))
            }
            "#eventGroupChatCreated" => {
                let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(
                    body,
                )?;
                Ok(Self::EventGroupChatCreated(Box::new(variant)))
            }
            "#eventGroupChatMemberAdded" => {
                let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(
                    body,
                )?;
                Ok(Self::EventGroupChatMemberAdded(Box::new(variant)))
            }
            "#eventGroupChatMemberJoined" => {
                let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(
                    body,
                )?;
                Ok(Self::EventGroupChatMemberJoined(Box::new(variant)))
            }
            "#eventGroupChatJoinRequest" => {
                let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(
                    body,
                )?;
                Ok(Self::EventGroupChatJoinRequest(Box::new(variant)))
            }
            "#eventGroupChatJoinRequestApproved" => {
                let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(
                    body,
                )?;
                Ok(Self::EventGroupChatJoinRequestApproved(Box::new(variant)))
            }
            "#eventGroupChatJoinRequestRejected" => {
                let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(
                    body,
                )?;
                Ok(Self::EventGroupChatJoinRequestRejected(Box::new(variant)))
            }
            "#eventChatAccepted" => {
                let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(
                    body,
                )?;
                Ok(Self::EventChatAccepted(Box::new(variant)))
            }
            "#eventGroupChatMemberLeft" => {
                let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(
                    body,
                )?;
                Ok(Self::EventGroupChatMemberLeft(Box::new(variant)))
            }
            "#eventGroupChatUpdated" => {
                let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(
                    body,
                )?;
                Ok(Self::EventGroupChatUpdated(Box::new(variant)))
            }
            "#eventRateLimitExceeded" => {
                let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(
                    body,
                )?;
                Ok(Self::EventRateLimitExceeded(Box::new(variant)))
            }
            unknown => {
                Err(
                    jacquard_common::error::DecodeError::UnknownEventType(unknown.into()),
                )
            }
        }
    }
}


#[derive(
    Serialize,
    Deserialize,
    Debug,
    Clone,
    PartialEq,
    Eq,
    thiserror::Error,
    miette::Diagnostic
)]

#[serde(tag = "error", content = "message")]
pub enum SubscribeModEventsError {
    #[serde(rename = "FutureCursor")]
    FutureCursor(Option<SmolStr>),
    /// If the consumer of the stream can not keep up with events, and a backlog gets too large, the server will drop the connection.
    #[serde(rename = "ConsumerTooSlow")]
    ConsumerTooSlow(Option<SmolStr>),
    /// Catch-all for unknown error codes.
    #[serde(untagged)]
    Other { error: SmolStr, message: Option<SmolStr> },
}

impl core::fmt::Display for SubscribeModEventsError {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        match self {
            Self::FutureCursor(msg) => {
                write!(f, "FutureCursor")?;
                if let Some(msg) = msg {
                    write!(f, ": {}", msg)?;
                }
                Ok(())
            }
            Self::ConsumerTooSlow(msg) => {
                write!(f, "ConsumerTooSlow")?;
                if let Some(msg) = msg {
                    write!(f, ": {}", msg)?;
                }
                Ok(())
            }
            Self::Other { error, message } => {
                write!(f, "{}", error)?;
                if let Some(msg) = message {
                    write!(f, ": {}", msg)?;
                }
                Ok(())
            }
        }
    }
}

impl<S: BosStr> LexiconSchema for EventChatAccepted<S> {
    fn nsid() -> &'static str {
        "chat.bsky.moderation.subscribeModEvents"
    }
    fn def_name() -> &'static str {
        "eventChatAccepted"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_chat_bsky_moderation_subscribeModEvents()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for EventConvoFirstMessage<S> {
    fn nsid() -> &'static str {
        "chat.bsky.moderation.subscribeModEvents"
    }
    fn def_name() -> &'static str {
        "eventConvoFirstMessage"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_chat_bsky_moderation_subscribeModEvents()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for EventGroupChatCreated<S> {
    fn nsid() -> &'static str {
        "chat.bsky.moderation.subscribeModEvents"
    }
    fn def_name() -> &'static str {
        "eventGroupChatCreated"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_chat_bsky_moderation_subscribeModEvents()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for EventGroupChatJoinRequest<S> {
    fn nsid() -> &'static str {
        "chat.bsky.moderation.subscribeModEvents"
    }
    fn def_name() -> &'static str {
        "eventGroupChatJoinRequest"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_chat_bsky_moderation_subscribeModEvents()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for EventGroupChatJoinRequestApproved<S> {
    fn nsid() -> &'static str {
        "chat.bsky.moderation.subscribeModEvents"
    }
    fn def_name() -> &'static str {
        "eventGroupChatJoinRequestApproved"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_chat_bsky_moderation_subscribeModEvents()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for EventGroupChatJoinRequestRejected<S> {
    fn nsid() -> &'static str {
        "chat.bsky.moderation.subscribeModEvents"
    }
    fn def_name() -> &'static str {
        "eventGroupChatJoinRequestRejected"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_chat_bsky_moderation_subscribeModEvents()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for EventGroupChatMemberAdded<S> {
    fn nsid() -> &'static str {
        "chat.bsky.moderation.subscribeModEvents"
    }
    fn def_name() -> &'static str {
        "eventGroupChatMemberAdded"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_chat_bsky_moderation_subscribeModEvents()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for EventGroupChatMemberJoined<S> {
    fn nsid() -> &'static str {
        "chat.bsky.moderation.subscribeModEvents"
    }
    fn def_name() -> &'static str {
        "eventGroupChatMemberJoined"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_chat_bsky_moderation_subscribeModEvents()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for EventGroupChatMemberLeft<S> {
    fn nsid() -> &'static str {
        "chat.bsky.moderation.subscribeModEvents"
    }
    fn def_name() -> &'static str {
        "eventGroupChatMemberLeft"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_chat_bsky_moderation_subscribeModEvents()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for EventGroupChatUpdated<S> {
    fn nsid() -> &'static str {
        "chat.bsky.moderation.subscribeModEvents"
    }
    fn def_name() -> &'static str {
        "eventGroupChatUpdated"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_chat_bsky_moderation_subscribeModEvents()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for EventRateLimitExceeded<S> {
    fn nsid() -> &'static str {
        "chat.bsky.moderation.subscribeModEvents"
    }
    fn def_name() -> &'static str {
        "eventRateLimitExceeded"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_chat_bsky_moderation_subscribeModEvents()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

///Stream response type for
///chat.bsky.moderation.subscribeModEvents
pub struct SubscribeModEventsStream;
impl jacquard_common::xrpc::SubscriptionResp for SubscribeModEventsStream {
    const NSID: &'static str = "chat.bsky.moderation.subscribeModEvents";
    const ENCODING: jacquard_common::xrpc::MessageEncoding = jacquard_common::xrpc::MessageEncoding::Json;
    type Message<S: BosStr> = SubscribeModEventsMessage<S>;
    type Error = SubscribeModEventsError;
}

impl<S: BosStr> jacquard_common::xrpc::XrpcSubscription for SubscribeModEvents<S> {
    const NSID: &'static str = "chat.bsky.moderation.subscribeModEvents";
    const ENCODING: jacquard_common::xrpc::MessageEncoding = jacquard_common::xrpc::MessageEncoding::Json;
    type Stream = SubscribeModEventsStream;
}

pub struct SubscribeModEventsEndpoint;
impl jacquard_common::xrpc::SubscriptionEndpoint for SubscribeModEventsEndpoint {
    const PATH: &'static str = "/xrpc/chat.bsky.moderation.subscribeModEvents";
    const ENCODING: jacquard_common::xrpc::MessageEncoding = jacquard_common::xrpc::MessageEncoding::Json;
    type Params<S: BosStr> = SubscribeModEvents<S>;
    type Stream = SubscribeModEventsStream;
}

pub mod event_chat_accepted_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 ActorDid;
        type ConvoCreatedAt;
        type ConvoId;
        type CreatedAt;
        type Method;
        type Rev;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type ActorDid = Unset;
        type ConvoCreatedAt = Unset;
        type ConvoId = Unset;
        type CreatedAt = Unset;
        type Method = Unset;
        type Rev = Unset;
    }
    ///State transition - sets the `actor_did` field to Set
    pub struct SetActorDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetActorDid<St> {}
    impl<St: State> State for SetActorDid<St> {
        type ActorDid = Set<members::actor_did>;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type Method = St::Method;
        type Rev = St::Rev;
    }
    ///State transition - sets the `convo_created_at` field to Set
    pub struct SetConvoCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetConvoCreatedAt<St> {}
    impl<St: State> State for SetConvoCreatedAt<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = Set<members::convo_created_at>;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type Method = St::Method;
        type Rev = St::Rev;
    }
    ///State transition - sets the `convo_id` field to Set
    pub struct SetConvoId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetConvoId<St> {}
    impl<St: State> State for SetConvoId<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = Set<members::convo_id>;
        type CreatedAt = St::CreatedAt;
        type Method = St::Method;
        type Rev = St::Rev;
    }
    ///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 ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = Set<members::created_at>;
        type Method = St::Method;
        type Rev = St::Rev;
    }
    ///State transition - sets the `method` field to Set
    pub struct SetMethod<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetMethod<St> {}
    impl<St: State> State for SetMethod<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type Method = Set<members::method>;
        type Rev = St::Rev;
    }
    ///State transition - sets the `rev` field to Set
    pub struct SetRev<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRev<St> {}
    impl<St: State> State for SetRev<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type Method = St::Method;
        type Rev = Set<members::rev>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `actor_did` field
        pub struct actor_did(());
        ///Marker type for the `convo_created_at` field
        pub struct convo_created_at(());
        ///Marker type for the `convo_id` field
        pub struct convo_id(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `method` field
        pub struct method(());
        ///Marker type for the `rev` field
        pub struct rev(());
    }
}

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

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

impl<S: BosStr> EventChatAccepted<S> {
    /// Create a new builder for this type
    pub fn builder() -> EventChatAcceptedBuilder<event_chat_accepted_state::Empty, S> {
        EventChatAcceptedBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> EventChatAcceptedBuilder<St, S>
where
    St: event_chat_accepted_state::State,
    St::ActorDid: event_chat_accepted_state::IsUnset,
{
    /// Set the `actorDid` field (required)
    pub fn actor_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> EventChatAcceptedBuilder<event_chat_accepted_state::SetActorDid<St>, S> {
        self._fields.0 = Option::Some(value.into());
        EventChatAcceptedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventChatAcceptedBuilder<St, S>
where
    St: event_chat_accepted_state::State,
    St::ConvoCreatedAt: event_chat_accepted_state::IsUnset,
{
    /// Set the `convoCreatedAt` field (required)
    pub fn convo_created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> EventChatAcceptedBuilder<event_chat_accepted_state::SetConvoCreatedAt<St>, S> {
        self._fields.1 = Option::Some(value.into());
        EventChatAcceptedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventChatAcceptedBuilder<St, S>
where
    St: event_chat_accepted_state::State,
    St::ConvoId: event_chat_accepted_state::IsUnset,
{
    /// Set the `convoId` field (required)
    pub fn convo_id(
        mut self,
        value: impl Into<S>,
    ) -> EventChatAcceptedBuilder<event_chat_accepted_state::SetConvoId<St>, S> {
        self._fields.2 = Option::Some(value.into());
        EventChatAcceptedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St: event_chat_accepted_state::State, S: BosStr> EventChatAcceptedBuilder<St, S> {
    /// Set the `groupMemberCount` field (optional)
    pub fn group_member_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `groupMemberCount` field to an Option value (optional)
    pub fn maybe_group_member_count(mut self, value: Option<i64>) -> Self {
        self._fields.4 = value;
        self
    }
}

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

impl<St, S: BosStr> EventChatAcceptedBuilder<St, S>
where
    St: event_chat_accepted_state::State,
    St::Method: event_chat_accepted_state::IsUnset,
{
    /// Set the `method` field (required)
    pub fn method(
        mut self,
        value: impl Into<EventChatAcceptedMethod<S>>,
    ) -> EventChatAcceptedBuilder<event_chat_accepted_state::SetMethod<St>, S> {
        self._fields.6 = Option::Some(value.into());
        EventChatAcceptedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: event_chat_accepted_state::State, S: BosStr> EventChatAcceptedBuilder<St, S> {
    /// Set the `ownerDid` field (optional)
    pub fn owner_did(mut self, value: impl Into<Option<Did<S>>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `ownerDid` field to an Option value (optional)
    pub fn maybe_owner_did(mut self, value: Option<Did<S>>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<St, S: BosStr> EventChatAcceptedBuilder<St, S>
where
    St: event_chat_accepted_state::State,
    St::Rev: event_chat_accepted_state::IsUnset,
{
    /// Set the `rev` field (required)
    pub fn rev(
        mut self,
        value: impl Into<S>,
    ) -> EventChatAcceptedBuilder<event_chat_accepted_state::SetRev<St>, S> {
        self._fields.8 = Option::Some(value.into());
        EventChatAcceptedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventChatAcceptedBuilder<St, S>
where
    St: event_chat_accepted_state::State,
    St::ActorDid: event_chat_accepted_state::IsSet,
    St::ConvoCreatedAt: event_chat_accepted_state::IsSet,
    St::ConvoId: event_chat_accepted_state::IsSet,
    St::CreatedAt: event_chat_accepted_state::IsSet,
    St::Method: event_chat_accepted_state::IsSet,
    St::Rev: event_chat_accepted_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> EventChatAccepted<S> {
        EventChatAccepted {
            actor_did: self._fields.0.unwrap(),
            convo_created_at: self._fields.1.unwrap(),
            convo_id: self._fields.2.unwrap(),
            created_at: self._fields.3.unwrap(),
            group_member_count: self._fields.4,
            group_name: self._fields.5,
            method: self._fields.6.unwrap(),
            owner_did: self._fields.7,
            rev: self._fields.8.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>>,
    ) -> EventChatAccepted<S> {
        EventChatAccepted {
            actor_did: self._fields.0.unwrap(),
            convo_created_at: self._fields.1.unwrap(),
            convo_id: self._fields.2.unwrap(),
            created_at: self._fields.3.unwrap(),
            group_member_count: self._fields.4,
            group_name: self._fields.5,
            method: self._fields.6.unwrap(),
            owner_did: self._fields.7,
            rev: self._fields.8.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_chat_bsky_moderation_subscribeModEvents() -> 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("chat.bsky.moderation.subscribeModEvents"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("eventChatAccepted"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Fired when a user accepts a chat convo, either explicitly or by sending a message.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("actorDid"),
                            SmolStr::new_static("convoCreatedAt"),
                            SmolStr::new_static("convoId"),
                            SmolStr::new_static("createdAt"),
                            SmolStr::new_static("method"), SmolStr::new_static("rev")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("actorDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The DID of the person accepting the convo.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("convoCreatedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("When the convo was originally created."),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("convoId"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("groupMemberCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("groupName"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The name of the group chat. Only present for group convos.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("method"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("How the convo was accepted."),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("ownerDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The DID of the group chat owner. Only present for group convos.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("rev"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("eventConvoFirstMessage"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Fired when the first message was sent on a convo.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("createdAt"), SmolStr::new_static("rev"),
                            SmolStr::new_static("convoId"), SmolStr::new_static("user"),
                            SmolStr::new_static("recipients")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("convoId"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("messageId"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("recipients"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "The list of DIDs message recipients. Does not include the sender, which is in the `user` field",
                                    ),
                                ),
                                items: LexArrayItem::String(LexString {
                                    format: Some(LexStringFormat::Did),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("rev"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("user"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The DID of the message author."),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("eventGroupChatCreated"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Fire when a group chat is created."),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("actorDid"),
                            SmolStr::new_static("convoCreatedAt"),
                            SmolStr::new_static("convoId"),
                            SmolStr::new_static("createdAt"),
                            SmolStr::new_static("groupMemberCount"),
                            SmolStr::new_static("groupName"),
                            SmolStr::new_static("initialMemberDids"),
                            SmolStr::new_static("ownerDid"), SmolStr::new_static("rev")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("actorDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The DID of the actor performing the action. For this event, same as ownerDid.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("convoCreatedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("When the group was originally created."),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("convoId"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("groupMemberCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("groupName"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The name set at creation time."),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("initialMemberDids"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "DIDs of everyone added at creation time.",
                                    ),
                                ),
                                items: LexArrayItem::String(LexString {
                                    format: Some(LexStringFormat::Did),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("ownerDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The DID of the group chat owner."),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("rev"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("eventGroupChatJoinRequest"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Fired when a user requests to join a group chat via an join link that requires approval.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("actorDid"),
                            SmolStr::new_static("convoCreatedAt"),
                            SmolStr::new_static("convoId"),
                            SmolStr::new_static("createdAt"),
                            SmolStr::new_static("groupMemberCount"),
                            SmolStr::new_static("groupName"),
                            SmolStr::new_static("joinLinkCode"),
                            SmolStr::new_static("ownerDid"), SmolStr::new_static("rev"),
                            SmolStr::new_static("subjectFollowsOwner")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("actorDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The DID of the person requesting to join.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("convoCreatedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("When the group was originally created."),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("convoId"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("groupMemberCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("groupName"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("joinLinkCode"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The code of the join link used to request joining.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("ownerDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The DID of the group chat owner."),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("rev"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("subjectFollowsOwner"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("eventGroupChatJoinRequestApproved"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Fired when a join request is approved by the group owner.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("actorDid"),
                            SmolStr::new_static("convoCreatedAt"),
                            SmolStr::new_static("convoId"),
                            SmolStr::new_static("createdAt"),
                            SmolStr::new_static("groupMemberCount"),
                            SmolStr::new_static("groupName"),
                            SmolStr::new_static("ownerDid"), SmolStr::new_static("rev"),
                            SmolStr::new_static("subjectDid")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("actorDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The DID of the owner approving the request.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("convoCreatedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("When the group was originally created."),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("convoId"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("groupMemberCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("groupName"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("ownerDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The DID of the group chat owner."),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("rev"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("subjectDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The DID of the member whose request was approved.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("eventGroupChatJoinRequestRejected"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Fired when a join request is rejected by the group owner.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("actorDid"),
                            SmolStr::new_static("convoCreatedAt"),
                            SmolStr::new_static("convoId"),
                            SmolStr::new_static("createdAt"),
                            SmolStr::new_static("groupMemberCount"),
                            SmolStr::new_static("groupName"),
                            SmolStr::new_static("ownerDid"), SmolStr::new_static("rev"),
                            SmolStr::new_static("subjectDid")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("actorDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The DID of the owner rejecting the request.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("convoCreatedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("When the group was originally created."),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("convoId"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("groupMemberCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("groupName"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("ownerDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The DID of the group chat owner."),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("rev"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("subjectDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The DID of the member whose request was rejected.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("eventGroupChatMemberAdded"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Fired when a member is added to a group chat. Note that members are added in the 'request' state.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("actorDid"),
                            SmolStr::new_static("convoCreatedAt"),
                            SmolStr::new_static("convoId"),
                            SmolStr::new_static("createdAt"),
                            SmolStr::new_static("groupMemberCount"),
                            SmolStr::new_static("groupName"),
                            SmolStr::new_static("ownerDid"),
                            SmolStr::new_static("requestMembersCount"),
                            SmolStr::new_static("rev"),
                            SmolStr::new_static("subjectDid"),
                            SmolStr::new_static("subjectFollowsOwner")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("actorDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The DID of the actor performing the action. For this event, same as ownerDid.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("convoCreatedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("When the group was originally created."),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("convoId"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("groupMemberCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("groupName"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("ownerDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The DID of the group chat owner."),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("requestMembersCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("rev"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("subjectDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The DID of the member who was added."),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("subjectFollowsOwner"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("eventGroupChatMemberJoined"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Fired when a member joins a group chat via an join link that does not require approval.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("actorDid"),
                            SmolStr::new_static("convoCreatedAt"),
                            SmolStr::new_static("convoId"),
                            SmolStr::new_static("createdAt"),
                            SmolStr::new_static("groupMemberCount"),
                            SmolStr::new_static("groupName"),
                            SmolStr::new_static("joinLinkCode"),
                            SmolStr::new_static("ownerDid"), SmolStr::new_static("rev"),
                            SmolStr::new_static("subjectFollowsOwner")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("actorDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The DID of the person joining."),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("convoCreatedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("When the group was originally created."),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("convoId"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("groupMemberCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("groupName"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("joinLinkCode"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The code of the join link used to join.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("ownerDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The DID of the group chat owner."),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("rev"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("subjectFollowsOwner"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("eventGroupChatMemberLeft"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Fired when a member leaves or is removed from a group chat.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("actorDid"),
                            SmolStr::new_static("convoCreatedAt"),
                            SmolStr::new_static("convoId"),
                            SmolStr::new_static("createdAt"),
                            SmolStr::new_static("groupMemberCount"),
                            SmolStr::new_static("groupName"),
                            SmolStr::new_static("leaveMethod"),
                            SmolStr::new_static("ownerDid"), SmolStr::new_static("rev"),
                            SmolStr::new_static("subjectDid")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("actorDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The DID of the actor. For voluntary: the person leaving. For kicked: the owner.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("convoCreatedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("When the group was originally created."),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("convoId"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("groupMemberCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("groupName"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("leaveMethod"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("How the member left."),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("ownerDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The DID of the group chat owner."),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("rev"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("subjectDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The DID of the member who left or was removed.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("eventGroupChatUpdated"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Fired when a group chat's metadata or status changes.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("actorDid"),
                            SmolStr::new_static("convoCreatedAt"),
                            SmolStr::new_static("convoId"),
                            SmolStr::new_static("createdAt"),
                            SmolStr::new_static("groupMemberCount"),
                            SmolStr::new_static("groupName"),
                            SmolStr::new_static("ownerDid"), SmolStr::new_static("rev"),
                            SmolStr::new_static("updateType")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("actorDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The DID of the actor performing the action (the owner).",
                                    ),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("convoCreatedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("When the group was originally created."),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("convoId"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("groupMemberCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("groupName"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Current group name."),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("joinLinkCode"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The code of the join link. Only present when updateType is join-link-related.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("joinLinkFollowersOnly"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("joinLinkRequiresApproval"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("lockReason"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Why the group was locked. Only present when updateType is 'locked'.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("newName"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The new group name. Only present when updateType is 'name_changed'.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("oldName"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The previous group name. Only present when updateType is 'name_changed'.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("ownerDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The DID of the group chat owner."),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("rev"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("updateType"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("What changed.")),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("eventRateLimitExceeded"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Fired when a user exceeds a rate limit."),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("actorDid"),
                            SmolStr::new_static("createdAt"),
                            SmolStr::new_static("endpoint"), SmolStr::new_static("rev")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("actorDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The DID of the user who hit the rate limit.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("endpoint"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The NSID of the endpoint that was rate limited.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("rev"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcSubscription(LexXrpcSubscription {
                    parameters: Some(
                        LexXrpcSubscriptionParameter::Params(LexXrpcParameters {
                            properties: {
                                #[allow(unused_mut)]
                                let mut map = BTreeMap::new();
                                map.insert(
                                    SmolStr::new_static("cursor"),
                                    LexXrpcParametersProperty::String(LexString {
                                        description: Some(
                                            CowStr::new_static(
                                                "The last known event seq number to backfill from. Use '2222222222222' to backfill from the beginning. Don't specify a cursor to listen only for new events.",
                                            ),
                                        ),
                                        ..Default::default()
                                    }),
                                );
                                map
                            },
                            ..Default::default()
                        }),
                    ),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod event_convo_first_message_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 ConvoId;
        type CreatedAt;
        type Recipients;
        type Rev;
        type User;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type ConvoId = Unset;
        type CreatedAt = Unset;
        type Recipients = Unset;
        type Rev = Unset;
        type User = Unset;
    }
    ///State transition - sets the `convo_id` field to Set
    pub struct SetConvoId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetConvoId<St> {}
    impl<St: State> State for SetConvoId<St> {
        type ConvoId = Set<members::convo_id>;
        type CreatedAt = St::CreatedAt;
        type Recipients = St::Recipients;
        type Rev = St::Rev;
        type User = St::User;
    }
    ///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 ConvoId = St::ConvoId;
        type CreatedAt = Set<members::created_at>;
        type Recipients = St::Recipients;
        type Rev = St::Rev;
        type User = St::User;
    }
    ///State transition - sets the `recipients` field to Set
    pub struct SetRecipients<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRecipients<St> {}
    impl<St: State> State for SetRecipients<St> {
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type Recipients = Set<members::recipients>;
        type Rev = St::Rev;
        type User = St::User;
    }
    ///State transition - sets the `rev` field to Set
    pub struct SetRev<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRev<St> {}
    impl<St: State> State for SetRev<St> {
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type Recipients = St::Recipients;
        type Rev = Set<members::rev>;
        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 ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type Recipients = St::Recipients;
        type Rev = St::Rev;
        type User = Set<members::user>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `convo_id` field
        pub struct convo_id(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `recipients` field
        pub struct recipients(());
        ///Marker type for the `rev` field
        pub struct rev(());
        ///Marker type for the `user` field
        pub struct user(());
    }
}

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

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

impl<S: BosStr> EventConvoFirstMessage<S> {
    /// Create a new builder for this type
    pub fn builder() -> EventConvoFirstMessageBuilder<
        event_convo_first_message_state::Empty,
        S,
    > {
        EventConvoFirstMessageBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> EventConvoFirstMessageBuilder<St, S>
where
    St: event_convo_first_message_state::State,
    St::ConvoId: event_convo_first_message_state::IsUnset,
{
    /// Set the `convoId` field (required)
    pub fn convo_id(
        mut self,
        value: impl Into<S>,
    ) -> EventConvoFirstMessageBuilder<
        event_convo_first_message_state::SetConvoId<St>,
        S,
    > {
        self._fields.0 = Option::Some(value.into());
        EventConvoFirstMessageBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

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

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

impl<St, S: BosStr> EventConvoFirstMessageBuilder<St, S>
where
    St: event_convo_first_message_state::State,
    St::Rev: event_convo_first_message_state::IsUnset,
{
    /// Set the `rev` field (required)
    pub fn rev(
        mut self,
        value: impl Into<S>,
    ) -> EventConvoFirstMessageBuilder<event_convo_first_message_state::SetRev<St>, S> {
        self._fields.4 = Option::Some(value.into());
        EventConvoFirstMessageBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> EventConvoFirstMessageBuilder<St, S>
where
    St: event_convo_first_message_state::State,
    St::ConvoId: event_convo_first_message_state::IsSet,
    St::CreatedAt: event_convo_first_message_state::IsSet,
    St::Recipients: event_convo_first_message_state::IsSet,
    St::Rev: event_convo_first_message_state::IsSet,
    St::User: event_convo_first_message_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> EventConvoFirstMessage<S> {
        EventConvoFirstMessage {
            convo_id: self._fields.0.unwrap(),
            created_at: self._fields.1.unwrap(),
            message_id: self._fields.2,
            recipients: self._fields.3.unwrap(),
            rev: self._fields.4.unwrap(),
            user: self._fields.5.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>>,
    ) -> EventConvoFirstMessage<S> {
        EventConvoFirstMessage {
            convo_id: self._fields.0.unwrap(),
            created_at: self._fields.1.unwrap(),
            message_id: self._fields.2,
            recipients: self._fields.3.unwrap(),
            rev: self._fields.4.unwrap(),
            user: self._fields.5.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod event_group_chat_created_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 ActorDid;
        type ConvoCreatedAt;
        type ConvoId;
        type CreatedAt;
        type GroupMemberCount;
        type GroupName;
        type InitialMemberDids;
        type OwnerDid;
        type Rev;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type ActorDid = Unset;
        type ConvoCreatedAt = Unset;
        type ConvoId = Unset;
        type CreatedAt = Unset;
        type GroupMemberCount = Unset;
        type GroupName = Unset;
        type InitialMemberDids = Unset;
        type OwnerDid = Unset;
        type Rev = Unset;
    }
    ///State transition - sets the `actor_did` field to Set
    pub struct SetActorDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetActorDid<St> {}
    impl<St: State> State for SetActorDid<St> {
        type ActorDid = Set<members::actor_did>;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type InitialMemberDids = St::InitialMemberDids;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
    }
    ///State transition - sets the `convo_created_at` field to Set
    pub struct SetConvoCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetConvoCreatedAt<St> {}
    impl<St: State> State for SetConvoCreatedAt<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = Set<members::convo_created_at>;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type InitialMemberDids = St::InitialMemberDids;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
    }
    ///State transition - sets the `convo_id` field to Set
    pub struct SetConvoId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetConvoId<St> {}
    impl<St: State> State for SetConvoId<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = Set<members::convo_id>;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type InitialMemberDids = St::InitialMemberDids;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
    }
    ///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 ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = Set<members::created_at>;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type InitialMemberDids = St::InitialMemberDids;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
    }
    ///State transition - sets the `group_member_count` field to Set
    pub struct SetGroupMemberCount<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetGroupMemberCount<St> {}
    impl<St: State> State for SetGroupMemberCount<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = Set<members::group_member_count>;
        type GroupName = St::GroupName;
        type InitialMemberDids = St::InitialMemberDids;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
    }
    ///State transition - sets the `group_name` field to Set
    pub struct SetGroupName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetGroupName<St> {}
    impl<St: State> State for SetGroupName<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = Set<members::group_name>;
        type InitialMemberDids = St::InitialMemberDids;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
    }
    ///State transition - sets the `initial_member_dids` field to Set
    pub struct SetInitialMemberDids<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetInitialMemberDids<St> {}
    impl<St: State> State for SetInitialMemberDids<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type InitialMemberDids = Set<members::initial_member_dids>;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
    }
    ///State transition - sets the `owner_did` field to Set
    pub struct SetOwnerDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetOwnerDid<St> {}
    impl<St: State> State for SetOwnerDid<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type InitialMemberDids = St::InitialMemberDids;
        type OwnerDid = Set<members::owner_did>;
        type Rev = St::Rev;
    }
    ///State transition - sets the `rev` field to Set
    pub struct SetRev<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRev<St> {}
    impl<St: State> State for SetRev<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type InitialMemberDids = St::InitialMemberDids;
        type OwnerDid = St::OwnerDid;
        type Rev = Set<members::rev>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `actor_did` field
        pub struct actor_did(());
        ///Marker type for the `convo_created_at` field
        pub struct convo_created_at(());
        ///Marker type for the `convo_id` field
        pub struct convo_id(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `group_member_count` field
        pub struct group_member_count(());
        ///Marker type for the `group_name` field
        pub struct group_name(());
        ///Marker type for the `initial_member_dids` field
        pub struct initial_member_dids(());
        ///Marker type for the `owner_did` field
        pub struct owner_did(());
        ///Marker type for the `rev` field
        pub struct rev(());
    }
}

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

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

impl<S: BosStr> EventGroupChatCreated<S> {
    /// Create a new builder for this type
    pub fn builder() -> EventGroupChatCreatedBuilder<
        event_group_chat_created_state::Empty,
        S,
    > {
        EventGroupChatCreatedBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> EventGroupChatCreatedBuilder<St, S>
where
    St: event_group_chat_created_state::State,
    St::ActorDid: event_group_chat_created_state::IsUnset,
{
    /// Set the `actorDid` field (required)
    pub fn actor_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> EventGroupChatCreatedBuilder<
        event_group_chat_created_state::SetActorDid<St>,
        S,
    > {
        self._fields.0 = Option::Some(value.into());
        EventGroupChatCreatedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatCreatedBuilder<St, S>
where
    St: event_group_chat_created_state::State,
    St::ConvoCreatedAt: event_group_chat_created_state::IsUnset,
{
    /// Set the `convoCreatedAt` field (required)
    pub fn convo_created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> EventGroupChatCreatedBuilder<
        event_group_chat_created_state::SetConvoCreatedAt<St>,
        S,
    > {
        self._fields.1 = Option::Some(value.into());
        EventGroupChatCreatedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatCreatedBuilder<St, S>
where
    St: event_group_chat_created_state::State,
    St::ConvoId: event_group_chat_created_state::IsUnset,
{
    /// Set the `convoId` field (required)
    pub fn convo_id(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatCreatedBuilder<
        event_group_chat_created_state::SetConvoId<St>,
        S,
    > {
        self._fields.2 = Option::Some(value.into());
        EventGroupChatCreatedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> EventGroupChatCreatedBuilder<St, S>
where
    St: event_group_chat_created_state::State,
    St::GroupMemberCount: event_group_chat_created_state::IsUnset,
{
    /// Set the `groupMemberCount` field (required)
    pub fn group_member_count(
        mut self,
        value: impl Into<i64>,
    ) -> EventGroupChatCreatedBuilder<
        event_group_chat_created_state::SetGroupMemberCount<St>,
        S,
    > {
        self._fields.4 = Option::Some(value.into());
        EventGroupChatCreatedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatCreatedBuilder<St, S>
where
    St: event_group_chat_created_state::State,
    St::GroupName: event_group_chat_created_state::IsUnset,
{
    /// Set the `groupName` field (required)
    pub fn group_name(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatCreatedBuilder<
        event_group_chat_created_state::SetGroupName<St>,
        S,
    > {
        self._fields.5 = Option::Some(value.into());
        EventGroupChatCreatedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatCreatedBuilder<St, S>
where
    St: event_group_chat_created_state::State,
    St::InitialMemberDids: event_group_chat_created_state::IsUnset,
{
    /// Set the `initialMemberDids` field (required)
    pub fn initial_member_dids(
        mut self,
        value: impl Into<Vec<Did<S>>>,
    ) -> EventGroupChatCreatedBuilder<
        event_group_chat_created_state::SetInitialMemberDids<St>,
        S,
    > {
        self._fields.6 = Option::Some(value.into());
        EventGroupChatCreatedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatCreatedBuilder<St, S>
where
    St: event_group_chat_created_state::State,
    St::OwnerDid: event_group_chat_created_state::IsUnset,
{
    /// Set the `ownerDid` field (required)
    pub fn owner_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> EventGroupChatCreatedBuilder<
        event_group_chat_created_state::SetOwnerDid<St>,
        S,
    > {
        self._fields.7 = Option::Some(value.into());
        EventGroupChatCreatedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatCreatedBuilder<St, S>
where
    St: event_group_chat_created_state::State,
    St::Rev: event_group_chat_created_state::IsUnset,
{
    /// Set the `rev` field (required)
    pub fn rev(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatCreatedBuilder<event_group_chat_created_state::SetRev<St>, S> {
        self._fields.8 = Option::Some(value.into());
        EventGroupChatCreatedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatCreatedBuilder<St, S>
where
    St: event_group_chat_created_state::State,
    St::ActorDid: event_group_chat_created_state::IsSet,
    St::ConvoCreatedAt: event_group_chat_created_state::IsSet,
    St::ConvoId: event_group_chat_created_state::IsSet,
    St::CreatedAt: event_group_chat_created_state::IsSet,
    St::GroupMemberCount: event_group_chat_created_state::IsSet,
    St::GroupName: event_group_chat_created_state::IsSet,
    St::InitialMemberDids: event_group_chat_created_state::IsSet,
    St::OwnerDid: event_group_chat_created_state::IsSet,
    St::Rev: event_group_chat_created_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> EventGroupChatCreated<S> {
        EventGroupChatCreated {
            actor_did: self._fields.0.unwrap(),
            convo_created_at: self._fields.1.unwrap(),
            convo_id: self._fields.2.unwrap(),
            created_at: self._fields.3.unwrap(),
            group_member_count: self._fields.4.unwrap(),
            group_name: self._fields.5.unwrap(),
            initial_member_dids: self._fields.6.unwrap(),
            owner_did: self._fields.7.unwrap(),
            rev: self._fields.8.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>>,
    ) -> EventGroupChatCreated<S> {
        EventGroupChatCreated {
            actor_did: self._fields.0.unwrap(),
            convo_created_at: self._fields.1.unwrap(),
            convo_id: self._fields.2.unwrap(),
            created_at: self._fields.3.unwrap(),
            group_member_count: self._fields.4.unwrap(),
            group_name: self._fields.5.unwrap(),
            initial_member_dids: self._fields.6.unwrap(),
            owner_did: self._fields.7.unwrap(),
            rev: self._fields.8.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod event_group_chat_join_request_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 ActorDid;
        type ConvoCreatedAt;
        type ConvoId;
        type CreatedAt;
        type GroupMemberCount;
        type GroupName;
        type JoinLinkCode;
        type OwnerDid;
        type Rev;
        type SubjectFollowsOwner;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type ActorDid = Unset;
        type ConvoCreatedAt = Unset;
        type ConvoId = Unset;
        type CreatedAt = Unset;
        type GroupMemberCount = Unset;
        type GroupName = Unset;
        type JoinLinkCode = Unset;
        type OwnerDid = Unset;
        type Rev = Unset;
        type SubjectFollowsOwner = Unset;
    }
    ///State transition - sets the `actor_did` field to Set
    pub struct SetActorDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetActorDid<St> {}
    impl<St: State> State for SetActorDid<St> {
        type ActorDid = Set<members::actor_did>;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type JoinLinkCode = St::JoinLinkCode;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `convo_created_at` field to Set
    pub struct SetConvoCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetConvoCreatedAt<St> {}
    impl<St: State> State for SetConvoCreatedAt<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = Set<members::convo_created_at>;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type JoinLinkCode = St::JoinLinkCode;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `convo_id` field to Set
    pub struct SetConvoId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetConvoId<St> {}
    impl<St: State> State for SetConvoId<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = Set<members::convo_id>;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type JoinLinkCode = St::JoinLinkCode;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///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 ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = Set<members::created_at>;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type JoinLinkCode = St::JoinLinkCode;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `group_member_count` field to Set
    pub struct SetGroupMemberCount<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetGroupMemberCount<St> {}
    impl<St: State> State for SetGroupMemberCount<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = Set<members::group_member_count>;
        type GroupName = St::GroupName;
        type JoinLinkCode = St::JoinLinkCode;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `group_name` field to Set
    pub struct SetGroupName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetGroupName<St> {}
    impl<St: State> State for SetGroupName<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = Set<members::group_name>;
        type JoinLinkCode = St::JoinLinkCode;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `join_link_code` field to Set
    pub struct SetJoinLinkCode<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetJoinLinkCode<St> {}
    impl<St: State> State for SetJoinLinkCode<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type JoinLinkCode = Set<members::join_link_code>;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `owner_did` field to Set
    pub struct SetOwnerDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetOwnerDid<St> {}
    impl<St: State> State for SetOwnerDid<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type JoinLinkCode = St::JoinLinkCode;
        type OwnerDid = Set<members::owner_did>;
        type Rev = St::Rev;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `rev` field to Set
    pub struct SetRev<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRev<St> {}
    impl<St: State> State for SetRev<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type JoinLinkCode = St::JoinLinkCode;
        type OwnerDid = St::OwnerDid;
        type Rev = Set<members::rev>;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `subject_follows_owner` field to Set
    pub struct SetSubjectFollowsOwner<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSubjectFollowsOwner<St> {}
    impl<St: State> State for SetSubjectFollowsOwner<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type JoinLinkCode = St::JoinLinkCode;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectFollowsOwner = Set<members::subject_follows_owner>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `actor_did` field
        pub struct actor_did(());
        ///Marker type for the `convo_created_at` field
        pub struct convo_created_at(());
        ///Marker type for the `convo_id` field
        pub struct convo_id(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `group_member_count` field
        pub struct group_member_count(());
        ///Marker type for the `group_name` field
        pub struct group_name(());
        ///Marker type for the `join_link_code` field
        pub struct join_link_code(());
        ///Marker type for the `owner_did` field
        pub struct owner_did(());
        ///Marker type for the `rev` field
        pub struct rev(());
        ///Marker type for the `subject_follows_owner` field
        pub struct subject_follows_owner(());
    }
}

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

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

impl<S: BosStr> EventGroupChatJoinRequest<S> {
    /// Create a new builder for this type
    pub fn builder() -> EventGroupChatJoinRequestBuilder<
        event_group_chat_join_request_state::Empty,
        S,
    > {
        EventGroupChatJoinRequestBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> EventGroupChatJoinRequestBuilder<St, S>
where
    St: event_group_chat_join_request_state::State,
    St::ActorDid: event_group_chat_join_request_state::IsUnset,
{
    /// Set the `actorDid` field (required)
    pub fn actor_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> EventGroupChatJoinRequestBuilder<
        event_group_chat_join_request_state::SetActorDid<St>,
        S,
    > {
        self._fields.0 = Option::Some(value.into());
        EventGroupChatJoinRequestBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatJoinRequestBuilder<St, S>
where
    St: event_group_chat_join_request_state::State,
    St::ConvoCreatedAt: event_group_chat_join_request_state::IsUnset,
{
    /// Set the `convoCreatedAt` field (required)
    pub fn convo_created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> EventGroupChatJoinRequestBuilder<
        event_group_chat_join_request_state::SetConvoCreatedAt<St>,
        S,
    > {
        self._fields.1 = Option::Some(value.into());
        EventGroupChatJoinRequestBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatJoinRequestBuilder<St, S>
where
    St: event_group_chat_join_request_state::State,
    St::ConvoId: event_group_chat_join_request_state::IsUnset,
{
    /// Set the `convoId` field (required)
    pub fn convo_id(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatJoinRequestBuilder<
        event_group_chat_join_request_state::SetConvoId<St>,
        S,
    > {
        self._fields.2 = Option::Some(value.into());
        EventGroupChatJoinRequestBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> EventGroupChatJoinRequestBuilder<St, S>
where
    St: event_group_chat_join_request_state::State,
    St::GroupMemberCount: event_group_chat_join_request_state::IsUnset,
{
    /// Set the `groupMemberCount` field (required)
    pub fn group_member_count(
        mut self,
        value: impl Into<i64>,
    ) -> EventGroupChatJoinRequestBuilder<
        event_group_chat_join_request_state::SetGroupMemberCount<St>,
        S,
    > {
        self._fields.4 = Option::Some(value.into());
        EventGroupChatJoinRequestBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatJoinRequestBuilder<St, S>
where
    St: event_group_chat_join_request_state::State,
    St::GroupName: event_group_chat_join_request_state::IsUnset,
{
    /// Set the `groupName` field (required)
    pub fn group_name(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatJoinRequestBuilder<
        event_group_chat_join_request_state::SetGroupName<St>,
        S,
    > {
        self._fields.5 = Option::Some(value.into());
        EventGroupChatJoinRequestBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatJoinRequestBuilder<St, S>
where
    St: event_group_chat_join_request_state::State,
    St::JoinLinkCode: event_group_chat_join_request_state::IsUnset,
{
    /// Set the `joinLinkCode` field (required)
    pub fn join_link_code(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatJoinRequestBuilder<
        event_group_chat_join_request_state::SetJoinLinkCode<St>,
        S,
    > {
        self._fields.6 = Option::Some(value.into());
        EventGroupChatJoinRequestBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatJoinRequestBuilder<St, S>
where
    St: event_group_chat_join_request_state::State,
    St::OwnerDid: event_group_chat_join_request_state::IsUnset,
{
    /// Set the `ownerDid` field (required)
    pub fn owner_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> EventGroupChatJoinRequestBuilder<
        event_group_chat_join_request_state::SetOwnerDid<St>,
        S,
    > {
        self._fields.7 = Option::Some(value.into());
        EventGroupChatJoinRequestBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatJoinRequestBuilder<St, S>
where
    St: event_group_chat_join_request_state::State,
    St::Rev: event_group_chat_join_request_state::IsUnset,
{
    /// Set the `rev` field (required)
    pub fn rev(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatJoinRequestBuilder<
        event_group_chat_join_request_state::SetRev<St>,
        S,
    > {
        self._fields.8 = Option::Some(value.into());
        EventGroupChatJoinRequestBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatJoinRequestBuilder<St, S>
where
    St: event_group_chat_join_request_state::State,
    St::SubjectFollowsOwner: event_group_chat_join_request_state::IsUnset,
{
    /// Set the `subjectFollowsOwner` field (required)
    pub fn subject_follows_owner(
        mut self,
        value: impl Into<bool>,
    ) -> EventGroupChatJoinRequestBuilder<
        event_group_chat_join_request_state::SetSubjectFollowsOwner<St>,
        S,
    > {
        self._fields.9 = Option::Some(value.into());
        EventGroupChatJoinRequestBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatJoinRequestBuilder<St, S>
where
    St: event_group_chat_join_request_state::State,
    St::ActorDid: event_group_chat_join_request_state::IsSet,
    St::ConvoCreatedAt: event_group_chat_join_request_state::IsSet,
    St::ConvoId: event_group_chat_join_request_state::IsSet,
    St::CreatedAt: event_group_chat_join_request_state::IsSet,
    St::GroupMemberCount: event_group_chat_join_request_state::IsSet,
    St::GroupName: event_group_chat_join_request_state::IsSet,
    St::JoinLinkCode: event_group_chat_join_request_state::IsSet,
    St::OwnerDid: event_group_chat_join_request_state::IsSet,
    St::Rev: event_group_chat_join_request_state::IsSet,
    St::SubjectFollowsOwner: event_group_chat_join_request_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> EventGroupChatJoinRequest<S> {
        EventGroupChatJoinRequest {
            actor_did: self._fields.0.unwrap(),
            convo_created_at: self._fields.1.unwrap(),
            convo_id: self._fields.2.unwrap(),
            created_at: self._fields.3.unwrap(),
            group_member_count: self._fields.4.unwrap(),
            group_name: self._fields.5.unwrap(),
            join_link_code: self._fields.6.unwrap(),
            owner_did: self._fields.7.unwrap(),
            rev: self._fields.8.unwrap(),
            subject_follows_owner: self._fields.9.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>>,
    ) -> EventGroupChatJoinRequest<S> {
        EventGroupChatJoinRequest {
            actor_did: self._fields.0.unwrap(),
            convo_created_at: self._fields.1.unwrap(),
            convo_id: self._fields.2.unwrap(),
            created_at: self._fields.3.unwrap(),
            group_member_count: self._fields.4.unwrap(),
            group_name: self._fields.5.unwrap(),
            join_link_code: self._fields.6.unwrap(),
            owner_did: self._fields.7.unwrap(),
            rev: self._fields.8.unwrap(),
            subject_follows_owner: self._fields.9.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod event_group_chat_join_request_approved_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 ActorDid;
        type ConvoCreatedAt;
        type ConvoId;
        type CreatedAt;
        type GroupMemberCount;
        type GroupName;
        type OwnerDid;
        type Rev;
        type SubjectDid;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type ActorDid = Unset;
        type ConvoCreatedAt = Unset;
        type ConvoId = Unset;
        type CreatedAt = Unset;
        type GroupMemberCount = Unset;
        type GroupName = Unset;
        type OwnerDid = Unset;
        type Rev = Unset;
        type SubjectDid = Unset;
    }
    ///State transition - sets the `actor_did` field to Set
    pub struct SetActorDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetActorDid<St> {}
    impl<St: State> State for SetActorDid<St> {
        type ActorDid = Set<members::actor_did>;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
    }
    ///State transition - sets the `convo_created_at` field to Set
    pub struct SetConvoCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetConvoCreatedAt<St> {}
    impl<St: State> State for SetConvoCreatedAt<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = Set<members::convo_created_at>;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
    }
    ///State transition - sets the `convo_id` field to Set
    pub struct SetConvoId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetConvoId<St> {}
    impl<St: State> State for SetConvoId<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = Set<members::convo_id>;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
    }
    ///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 ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = Set<members::created_at>;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
    }
    ///State transition - sets the `group_member_count` field to Set
    pub struct SetGroupMemberCount<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetGroupMemberCount<St> {}
    impl<St: State> State for SetGroupMemberCount<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = Set<members::group_member_count>;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
    }
    ///State transition - sets the `group_name` field to Set
    pub struct SetGroupName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetGroupName<St> {}
    impl<St: State> State for SetGroupName<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = Set<members::group_name>;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
    }
    ///State transition - sets the `owner_did` field to Set
    pub struct SetOwnerDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetOwnerDid<St> {}
    impl<St: State> State for SetOwnerDid<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = Set<members::owner_did>;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
    }
    ///State transition - sets the `rev` field to Set
    pub struct SetRev<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRev<St> {}
    impl<St: State> State for SetRev<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type Rev = Set<members::rev>;
        type SubjectDid = St::SubjectDid;
    }
    ///State transition - sets the `subject_did` field to Set
    pub struct SetSubjectDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSubjectDid<St> {}
    impl<St: State> State for SetSubjectDid<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectDid = Set<members::subject_did>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `actor_did` field
        pub struct actor_did(());
        ///Marker type for the `convo_created_at` field
        pub struct convo_created_at(());
        ///Marker type for the `convo_id` field
        pub struct convo_id(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `group_member_count` field
        pub struct group_member_count(());
        ///Marker type for the `group_name` field
        pub struct group_name(());
        ///Marker type for the `owner_did` field
        pub struct owner_did(());
        ///Marker type for the `rev` field
        pub struct rev(());
        ///Marker type for the `subject_did` field
        pub struct subject_did(());
    }
}

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

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

impl<S: BosStr> EventGroupChatJoinRequestApproved<S> {
    /// Create a new builder for this type
    pub fn builder() -> EventGroupChatJoinRequestApprovedBuilder<
        event_group_chat_join_request_approved_state::Empty,
        S,
    > {
        EventGroupChatJoinRequestApprovedBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> EventGroupChatJoinRequestApprovedBuilder<St, S>
where
    St: event_group_chat_join_request_approved_state::State,
    St::ActorDid: event_group_chat_join_request_approved_state::IsUnset,
{
    /// Set the `actorDid` field (required)
    pub fn actor_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> EventGroupChatJoinRequestApprovedBuilder<
        event_group_chat_join_request_approved_state::SetActorDid<St>,
        S,
    > {
        self._fields.0 = Option::Some(value.into());
        EventGroupChatJoinRequestApprovedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatJoinRequestApprovedBuilder<St, S>
where
    St: event_group_chat_join_request_approved_state::State,
    St::ConvoCreatedAt: event_group_chat_join_request_approved_state::IsUnset,
{
    /// Set the `convoCreatedAt` field (required)
    pub fn convo_created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> EventGroupChatJoinRequestApprovedBuilder<
        event_group_chat_join_request_approved_state::SetConvoCreatedAt<St>,
        S,
    > {
        self._fields.1 = Option::Some(value.into());
        EventGroupChatJoinRequestApprovedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatJoinRequestApprovedBuilder<St, S>
where
    St: event_group_chat_join_request_approved_state::State,
    St::ConvoId: event_group_chat_join_request_approved_state::IsUnset,
{
    /// Set the `convoId` field (required)
    pub fn convo_id(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatJoinRequestApprovedBuilder<
        event_group_chat_join_request_approved_state::SetConvoId<St>,
        S,
    > {
        self._fields.2 = Option::Some(value.into());
        EventGroupChatJoinRequestApprovedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> EventGroupChatJoinRequestApprovedBuilder<St, S>
where
    St: event_group_chat_join_request_approved_state::State,
    St::GroupMemberCount: event_group_chat_join_request_approved_state::IsUnset,
{
    /// Set the `groupMemberCount` field (required)
    pub fn group_member_count(
        mut self,
        value: impl Into<i64>,
    ) -> EventGroupChatJoinRequestApprovedBuilder<
        event_group_chat_join_request_approved_state::SetGroupMemberCount<St>,
        S,
    > {
        self._fields.4 = Option::Some(value.into());
        EventGroupChatJoinRequestApprovedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatJoinRequestApprovedBuilder<St, S>
where
    St: event_group_chat_join_request_approved_state::State,
    St::GroupName: event_group_chat_join_request_approved_state::IsUnset,
{
    /// Set the `groupName` field (required)
    pub fn group_name(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatJoinRequestApprovedBuilder<
        event_group_chat_join_request_approved_state::SetGroupName<St>,
        S,
    > {
        self._fields.5 = Option::Some(value.into());
        EventGroupChatJoinRequestApprovedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatJoinRequestApprovedBuilder<St, S>
where
    St: event_group_chat_join_request_approved_state::State,
    St::OwnerDid: event_group_chat_join_request_approved_state::IsUnset,
{
    /// Set the `ownerDid` field (required)
    pub fn owner_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> EventGroupChatJoinRequestApprovedBuilder<
        event_group_chat_join_request_approved_state::SetOwnerDid<St>,
        S,
    > {
        self._fields.6 = Option::Some(value.into());
        EventGroupChatJoinRequestApprovedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatJoinRequestApprovedBuilder<St, S>
where
    St: event_group_chat_join_request_approved_state::State,
    St::Rev: event_group_chat_join_request_approved_state::IsUnset,
{
    /// Set the `rev` field (required)
    pub fn rev(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatJoinRequestApprovedBuilder<
        event_group_chat_join_request_approved_state::SetRev<St>,
        S,
    > {
        self._fields.7 = Option::Some(value.into());
        EventGroupChatJoinRequestApprovedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatJoinRequestApprovedBuilder<St, S>
where
    St: event_group_chat_join_request_approved_state::State,
    St::SubjectDid: event_group_chat_join_request_approved_state::IsUnset,
{
    /// Set the `subjectDid` field (required)
    pub fn subject_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> EventGroupChatJoinRequestApprovedBuilder<
        event_group_chat_join_request_approved_state::SetSubjectDid<St>,
        S,
    > {
        self._fields.8 = Option::Some(value.into());
        EventGroupChatJoinRequestApprovedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatJoinRequestApprovedBuilder<St, S>
where
    St: event_group_chat_join_request_approved_state::State,
    St::ActorDid: event_group_chat_join_request_approved_state::IsSet,
    St::ConvoCreatedAt: event_group_chat_join_request_approved_state::IsSet,
    St::ConvoId: event_group_chat_join_request_approved_state::IsSet,
    St::CreatedAt: event_group_chat_join_request_approved_state::IsSet,
    St::GroupMemberCount: event_group_chat_join_request_approved_state::IsSet,
    St::GroupName: event_group_chat_join_request_approved_state::IsSet,
    St::OwnerDid: event_group_chat_join_request_approved_state::IsSet,
    St::Rev: event_group_chat_join_request_approved_state::IsSet,
    St::SubjectDid: event_group_chat_join_request_approved_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> EventGroupChatJoinRequestApproved<S> {
        EventGroupChatJoinRequestApproved {
            actor_did: self._fields.0.unwrap(),
            convo_created_at: self._fields.1.unwrap(),
            convo_id: self._fields.2.unwrap(),
            created_at: self._fields.3.unwrap(),
            group_member_count: self._fields.4.unwrap(),
            group_name: self._fields.5.unwrap(),
            owner_did: self._fields.6.unwrap(),
            rev: self._fields.7.unwrap(),
            subject_did: self._fields.8.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>>,
    ) -> EventGroupChatJoinRequestApproved<S> {
        EventGroupChatJoinRequestApproved {
            actor_did: self._fields.0.unwrap(),
            convo_created_at: self._fields.1.unwrap(),
            convo_id: self._fields.2.unwrap(),
            created_at: self._fields.3.unwrap(),
            group_member_count: self._fields.4.unwrap(),
            group_name: self._fields.5.unwrap(),
            owner_did: self._fields.6.unwrap(),
            rev: self._fields.7.unwrap(),
            subject_did: self._fields.8.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod event_group_chat_join_request_rejected_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 ActorDid;
        type ConvoCreatedAt;
        type ConvoId;
        type CreatedAt;
        type GroupMemberCount;
        type GroupName;
        type OwnerDid;
        type Rev;
        type SubjectDid;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type ActorDid = Unset;
        type ConvoCreatedAt = Unset;
        type ConvoId = Unset;
        type CreatedAt = Unset;
        type GroupMemberCount = Unset;
        type GroupName = Unset;
        type OwnerDid = Unset;
        type Rev = Unset;
        type SubjectDid = Unset;
    }
    ///State transition - sets the `actor_did` field to Set
    pub struct SetActorDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetActorDid<St> {}
    impl<St: State> State for SetActorDid<St> {
        type ActorDid = Set<members::actor_did>;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
    }
    ///State transition - sets the `convo_created_at` field to Set
    pub struct SetConvoCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetConvoCreatedAt<St> {}
    impl<St: State> State for SetConvoCreatedAt<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = Set<members::convo_created_at>;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
    }
    ///State transition - sets the `convo_id` field to Set
    pub struct SetConvoId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetConvoId<St> {}
    impl<St: State> State for SetConvoId<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = Set<members::convo_id>;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
    }
    ///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 ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = Set<members::created_at>;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
    }
    ///State transition - sets the `group_member_count` field to Set
    pub struct SetGroupMemberCount<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetGroupMemberCount<St> {}
    impl<St: State> State for SetGroupMemberCount<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = Set<members::group_member_count>;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
    }
    ///State transition - sets the `group_name` field to Set
    pub struct SetGroupName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetGroupName<St> {}
    impl<St: State> State for SetGroupName<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = Set<members::group_name>;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
    }
    ///State transition - sets the `owner_did` field to Set
    pub struct SetOwnerDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetOwnerDid<St> {}
    impl<St: State> State for SetOwnerDid<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = Set<members::owner_did>;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
    }
    ///State transition - sets the `rev` field to Set
    pub struct SetRev<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRev<St> {}
    impl<St: State> State for SetRev<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type Rev = Set<members::rev>;
        type SubjectDid = St::SubjectDid;
    }
    ///State transition - sets the `subject_did` field to Set
    pub struct SetSubjectDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSubjectDid<St> {}
    impl<St: State> State for SetSubjectDid<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectDid = Set<members::subject_did>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `actor_did` field
        pub struct actor_did(());
        ///Marker type for the `convo_created_at` field
        pub struct convo_created_at(());
        ///Marker type for the `convo_id` field
        pub struct convo_id(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `group_member_count` field
        pub struct group_member_count(());
        ///Marker type for the `group_name` field
        pub struct group_name(());
        ///Marker type for the `owner_did` field
        pub struct owner_did(());
        ///Marker type for the `rev` field
        pub struct rev(());
        ///Marker type for the `subject_did` field
        pub struct subject_did(());
    }
}

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

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

impl<S: BosStr> EventGroupChatJoinRequestRejected<S> {
    /// Create a new builder for this type
    pub fn builder() -> EventGroupChatJoinRequestRejectedBuilder<
        event_group_chat_join_request_rejected_state::Empty,
        S,
    > {
        EventGroupChatJoinRequestRejectedBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> EventGroupChatJoinRequestRejectedBuilder<St, S>
where
    St: event_group_chat_join_request_rejected_state::State,
    St::ActorDid: event_group_chat_join_request_rejected_state::IsUnset,
{
    /// Set the `actorDid` field (required)
    pub fn actor_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> EventGroupChatJoinRequestRejectedBuilder<
        event_group_chat_join_request_rejected_state::SetActorDid<St>,
        S,
    > {
        self._fields.0 = Option::Some(value.into());
        EventGroupChatJoinRequestRejectedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatJoinRequestRejectedBuilder<St, S>
where
    St: event_group_chat_join_request_rejected_state::State,
    St::ConvoCreatedAt: event_group_chat_join_request_rejected_state::IsUnset,
{
    /// Set the `convoCreatedAt` field (required)
    pub fn convo_created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> EventGroupChatJoinRequestRejectedBuilder<
        event_group_chat_join_request_rejected_state::SetConvoCreatedAt<St>,
        S,
    > {
        self._fields.1 = Option::Some(value.into());
        EventGroupChatJoinRequestRejectedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatJoinRequestRejectedBuilder<St, S>
where
    St: event_group_chat_join_request_rejected_state::State,
    St::ConvoId: event_group_chat_join_request_rejected_state::IsUnset,
{
    /// Set the `convoId` field (required)
    pub fn convo_id(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatJoinRequestRejectedBuilder<
        event_group_chat_join_request_rejected_state::SetConvoId<St>,
        S,
    > {
        self._fields.2 = Option::Some(value.into());
        EventGroupChatJoinRequestRejectedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> EventGroupChatJoinRequestRejectedBuilder<St, S>
where
    St: event_group_chat_join_request_rejected_state::State,
    St::GroupMemberCount: event_group_chat_join_request_rejected_state::IsUnset,
{
    /// Set the `groupMemberCount` field (required)
    pub fn group_member_count(
        mut self,
        value: impl Into<i64>,
    ) -> EventGroupChatJoinRequestRejectedBuilder<
        event_group_chat_join_request_rejected_state::SetGroupMemberCount<St>,
        S,
    > {
        self._fields.4 = Option::Some(value.into());
        EventGroupChatJoinRequestRejectedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatJoinRequestRejectedBuilder<St, S>
where
    St: event_group_chat_join_request_rejected_state::State,
    St::GroupName: event_group_chat_join_request_rejected_state::IsUnset,
{
    /// Set the `groupName` field (required)
    pub fn group_name(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatJoinRequestRejectedBuilder<
        event_group_chat_join_request_rejected_state::SetGroupName<St>,
        S,
    > {
        self._fields.5 = Option::Some(value.into());
        EventGroupChatJoinRequestRejectedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatJoinRequestRejectedBuilder<St, S>
where
    St: event_group_chat_join_request_rejected_state::State,
    St::OwnerDid: event_group_chat_join_request_rejected_state::IsUnset,
{
    /// Set the `ownerDid` field (required)
    pub fn owner_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> EventGroupChatJoinRequestRejectedBuilder<
        event_group_chat_join_request_rejected_state::SetOwnerDid<St>,
        S,
    > {
        self._fields.6 = Option::Some(value.into());
        EventGroupChatJoinRequestRejectedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatJoinRequestRejectedBuilder<St, S>
where
    St: event_group_chat_join_request_rejected_state::State,
    St::Rev: event_group_chat_join_request_rejected_state::IsUnset,
{
    /// Set the `rev` field (required)
    pub fn rev(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatJoinRequestRejectedBuilder<
        event_group_chat_join_request_rejected_state::SetRev<St>,
        S,
    > {
        self._fields.7 = Option::Some(value.into());
        EventGroupChatJoinRequestRejectedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatJoinRequestRejectedBuilder<St, S>
where
    St: event_group_chat_join_request_rejected_state::State,
    St::SubjectDid: event_group_chat_join_request_rejected_state::IsUnset,
{
    /// Set the `subjectDid` field (required)
    pub fn subject_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> EventGroupChatJoinRequestRejectedBuilder<
        event_group_chat_join_request_rejected_state::SetSubjectDid<St>,
        S,
    > {
        self._fields.8 = Option::Some(value.into());
        EventGroupChatJoinRequestRejectedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatJoinRequestRejectedBuilder<St, S>
where
    St: event_group_chat_join_request_rejected_state::State,
    St::ActorDid: event_group_chat_join_request_rejected_state::IsSet,
    St::ConvoCreatedAt: event_group_chat_join_request_rejected_state::IsSet,
    St::ConvoId: event_group_chat_join_request_rejected_state::IsSet,
    St::CreatedAt: event_group_chat_join_request_rejected_state::IsSet,
    St::GroupMemberCount: event_group_chat_join_request_rejected_state::IsSet,
    St::GroupName: event_group_chat_join_request_rejected_state::IsSet,
    St::OwnerDid: event_group_chat_join_request_rejected_state::IsSet,
    St::Rev: event_group_chat_join_request_rejected_state::IsSet,
    St::SubjectDid: event_group_chat_join_request_rejected_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> EventGroupChatJoinRequestRejected<S> {
        EventGroupChatJoinRequestRejected {
            actor_did: self._fields.0.unwrap(),
            convo_created_at: self._fields.1.unwrap(),
            convo_id: self._fields.2.unwrap(),
            created_at: self._fields.3.unwrap(),
            group_member_count: self._fields.4.unwrap(),
            group_name: self._fields.5.unwrap(),
            owner_did: self._fields.6.unwrap(),
            rev: self._fields.7.unwrap(),
            subject_did: self._fields.8.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>>,
    ) -> EventGroupChatJoinRequestRejected<S> {
        EventGroupChatJoinRequestRejected {
            actor_did: self._fields.0.unwrap(),
            convo_created_at: self._fields.1.unwrap(),
            convo_id: self._fields.2.unwrap(),
            created_at: self._fields.3.unwrap(),
            group_member_count: self._fields.4.unwrap(),
            group_name: self._fields.5.unwrap(),
            owner_did: self._fields.6.unwrap(),
            rev: self._fields.7.unwrap(),
            subject_did: self._fields.8.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod event_group_chat_member_added_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 ActorDid;
        type ConvoCreatedAt;
        type ConvoId;
        type CreatedAt;
        type GroupMemberCount;
        type GroupName;
        type OwnerDid;
        type RequestMembersCount;
        type Rev;
        type SubjectDid;
        type SubjectFollowsOwner;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type ActorDid = Unset;
        type ConvoCreatedAt = Unset;
        type ConvoId = Unset;
        type CreatedAt = Unset;
        type GroupMemberCount = Unset;
        type GroupName = Unset;
        type OwnerDid = Unset;
        type RequestMembersCount = Unset;
        type Rev = Unset;
        type SubjectDid = Unset;
        type SubjectFollowsOwner = Unset;
    }
    ///State transition - sets the `actor_did` field to Set
    pub struct SetActorDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetActorDid<St> {}
    impl<St: State> State for SetActorDid<St> {
        type ActorDid = Set<members::actor_did>;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type RequestMembersCount = St::RequestMembersCount;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `convo_created_at` field to Set
    pub struct SetConvoCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetConvoCreatedAt<St> {}
    impl<St: State> State for SetConvoCreatedAt<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = Set<members::convo_created_at>;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type RequestMembersCount = St::RequestMembersCount;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `convo_id` field to Set
    pub struct SetConvoId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetConvoId<St> {}
    impl<St: State> State for SetConvoId<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = Set<members::convo_id>;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type RequestMembersCount = St::RequestMembersCount;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///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 ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = Set<members::created_at>;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type RequestMembersCount = St::RequestMembersCount;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `group_member_count` field to Set
    pub struct SetGroupMemberCount<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetGroupMemberCount<St> {}
    impl<St: State> State for SetGroupMemberCount<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = Set<members::group_member_count>;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type RequestMembersCount = St::RequestMembersCount;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `group_name` field to Set
    pub struct SetGroupName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetGroupName<St> {}
    impl<St: State> State for SetGroupName<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = Set<members::group_name>;
        type OwnerDid = St::OwnerDid;
        type RequestMembersCount = St::RequestMembersCount;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `owner_did` field to Set
    pub struct SetOwnerDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetOwnerDid<St> {}
    impl<St: State> State for SetOwnerDid<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = Set<members::owner_did>;
        type RequestMembersCount = St::RequestMembersCount;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `request_members_count` field to Set
    pub struct SetRequestMembersCount<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRequestMembersCount<St> {}
    impl<St: State> State for SetRequestMembersCount<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type RequestMembersCount = Set<members::request_members_count>;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `rev` field to Set
    pub struct SetRev<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRev<St> {}
    impl<St: State> State for SetRev<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type RequestMembersCount = St::RequestMembersCount;
        type Rev = Set<members::rev>;
        type SubjectDid = St::SubjectDid;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `subject_did` field to Set
    pub struct SetSubjectDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSubjectDid<St> {}
    impl<St: State> State for SetSubjectDid<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type RequestMembersCount = St::RequestMembersCount;
        type Rev = St::Rev;
        type SubjectDid = Set<members::subject_did>;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `subject_follows_owner` field to Set
    pub struct SetSubjectFollowsOwner<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSubjectFollowsOwner<St> {}
    impl<St: State> State for SetSubjectFollowsOwner<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type RequestMembersCount = St::RequestMembersCount;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
        type SubjectFollowsOwner = Set<members::subject_follows_owner>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `actor_did` field
        pub struct actor_did(());
        ///Marker type for the `convo_created_at` field
        pub struct convo_created_at(());
        ///Marker type for the `convo_id` field
        pub struct convo_id(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `group_member_count` field
        pub struct group_member_count(());
        ///Marker type for the `group_name` field
        pub struct group_name(());
        ///Marker type for the `owner_did` field
        pub struct owner_did(());
        ///Marker type for the `request_members_count` field
        pub struct request_members_count(());
        ///Marker type for the `rev` field
        pub struct rev(());
        ///Marker type for the `subject_did` field
        pub struct subject_did(());
        ///Marker type for the `subject_follows_owner` field
        pub struct subject_follows_owner(());
    }
}

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

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

impl<S: BosStr> EventGroupChatMemberAdded<S> {
    /// Create a new builder for this type
    pub fn builder() -> EventGroupChatMemberAddedBuilder<
        event_group_chat_member_added_state::Empty,
        S,
    > {
        EventGroupChatMemberAddedBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> EventGroupChatMemberAddedBuilder<St, S>
where
    St: event_group_chat_member_added_state::State,
    St::ActorDid: event_group_chat_member_added_state::IsUnset,
{
    /// Set the `actorDid` field (required)
    pub fn actor_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> EventGroupChatMemberAddedBuilder<
        event_group_chat_member_added_state::SetActorDid<St>,
        S,
    > {
        self._fields.0 = Option::Some(value.into());
        EventGroupChatMemberAddedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberAddedBuilder<St, S>
where
    St: event_group_chat_member_added_state::State,
    St::ConvoCreatedAt: event_group_chat_member_added_state::IsUnset,
{
    /// Set the `convoCreatedAt` field (required)
    pub fn convo_created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> EventGroupChatMemberAddedBuilder<
        event_group_chat_member_added_state::SetConvoCreatedAt<St>,
        S,
    > {
        self._fields.1 = Option::Some(value.into());
        EventGroupChatMemberAddedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberAddedBuilder<St, S>
where
    St: event_group_chat_member_added_state::State,
    St::ConvoId: event_group_chat_member_added_state::IsUnset,
{
    /// Set the `convoId` field (required)
    pub fn convo_id(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatMemberAddedBuilder<
        event_group_chat_member_added_state::SetConvoId<St>,
        S,
    > {
        self._fields.2 = Option::Some(value.into());
        EventGroupChatMemberAddedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> EventGroupChatMemberAddedBuilder<St, S>
where
    St: event_group_chat_member_added_state::State,
    St::GroupMemberCount: event_group_chat_member_added_state::IsUnset,
{
    /// Set the `groupMemberCount` field (required)
    pub fn group_member_count(
        mut self,
        value: impl Into<i64>,
    ) -> EventGroupChatMemberAddedBuilder<
        event_group_chat_member_added_state::SetGroupMemberCount<St>,
        S,
    > {
        self._fields.4 = Option::Some(value.into());
        EventGroupChatMemberAddedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberAddedBuilder<St, S>
where
    St: event_group_chat_member_added_state::State,
    St::GroupName: event_group_chat_member_added_state::IsUnset,
{
    /// Set the `groupName` field (required)
    pub fn group_name(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatMemberAddedBuilder<
        event_group_chat_member_added_state::SetGroupName<St>,
        S,
    > {
        self._fields.5 = Option::Some(value.into());
        EventGroupChatMemberAddedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberAddedBuilder<St, S>
where
    St: event_group_chat_member_added_state::State,
    St::OwnerDid: event_group_chat_member_added_state::IsUnset,
{
    /// Set the `ownerDid` field (required)
    pub fn owner_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> EventGroupChatMemberAddedBuilder<
        event_group_chat_member_added_state::SetOwnerDid<St>,
        S,
    > {
        self._fields.6 = Option::Some(value.into());
        EventGroupChatMemberAddedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberAddedBuilder<St, S>
where
    St: event_group_chat_member_added_state::State,
    St::RequestMembersCount: event_group_chat_member_added_state::IsUnset,
{
    /// Set the `requestMembersCount` field (required)
    pub fn request_members_count(
        mut self,
        value: impl Into<i64>,
    ) -> EventGroupChatMemberAddedBuilder<
        event_group_chat_member_added_state::SetRequestMembersCount<St>,
        S,
    > {
        self._fields.7 = Option::Some(value.into());
        EventGroupChatMemberAddedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberAddedBuilder<St, S>
where
    St: event_group_chat_member_added_state::State,
    St::Rev: event_group_chat_member_added_state::IsUnset,
{
    /// Set the `rev` field (required)
    pub fn rev(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatMemberAddedBuilder<
        event_group_chat_member_added_state::SetRev<St>,
        S,
    > {
        self._fields.8 = Option::Some(value.into());
        EventGroupChatMemberAddedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberAddedBuilder<St, S>
where
    St: event_group_chat_member_added_state::State,
    St::SubjectDid: event_group_chat_member_added_state::IsUnset,
{
    /// Set the `subjectDid` field (required)
    pub fn subject_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> EventGroupChatMemberAddedBuilder<
        event_group_chat_member_added_state::SetSubjectDid<St>,
        S,
    > {
        self._fields.9 = Option::Some(value.into());
        EventGroupChatMemberAddedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberAddedBuilder<St, S>
where
    St: event_group_chat_member_added_state::State,
    St::SubjectFollowsOwner: event_group_chat_member_added_state::IsUnset,
{
    /// Set the `subjectFollowsOwner` field (required)
    pub fn subject_follows_owner(
        mut self,
        value: impl Into<bool>,
    ) -> EventGroupChatMemberAddedBuilder<
        event_group_chat_member_added_state::SetSubjectFollowsOwner<St>,
        S,
    > {
        self._fields.10 = Option::Some(value.into());
        EventGroupChatMemberAddedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberAddedBuilder<St, S>
where
    St: event_group_chat_member_added_state::State,
    St::ActorDid: event_group_chat_member_added_state::IsSet,
    St::ConvoCreatedAt: event_group_chat_member_added_state::IsSet,
    St::ConvoId: event_group_chat_member_added_state::IsSet,
    St::CreatedAt: event_group_chat_member_added_state::IsSet,
    St::GroupMemberCount: event_group_chat_member_added_state::IsSet,
    St::GroupName: event_group_chat_member_added_state::IsSet,
    St::OwnerDid: event_group_chat_member_added_state::IsSet,
    St::RequestMembersCount: event_group_chat_member_added_state::IsSet,
    St::Rev: event_group_chat_member_added_state::IsSet,
    St::SubjectDid: event_group_chat_member_added_state::IsSet,
    St::SubjectFollowsOwner: event_group_chat_member_added_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> EventGroupChatMemberAdded<S> {
        EventGroupChatMemberAdded {
            actor_did: self._fields.0.unwrap(),
            convo_created_at: self._fields.1.unwrap(),
            convo_id: self._fields.2.unwrap(),
            created_at: self._fields.3.unwrap(),
            group_member_count: self._fields.4.unwrap(),
            group_name: self._fields.5.unwrap(),
            owner_did: self._fields.6.unwrap(),
            request_members_count: self._fields.7.unwrap(),
            rev: self._fields.8.unwrap(),
            subject_did: self._fields.9.unwrap(),
            subject_follows_owner: self._fields.10.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>>,
    ) -> EventGroupChatMemberAdded<S> {
        EventGroupChatMemberAdded {
            actor_did: self._fields.0.unwrap(),
            convo_created_at: self._fields.1.unwrap(),
            convo_id: self._fields.2.unwrap(),
            created_at: self._fields.3.unwrap(),
            group_member_count: self._fields.4.unwrap(),
            group_name: self._fields.5.unwrap(),
            owner_did: self._fields.6.unwrap(),
            request_members_count: self._fields.7.unwrap(),
            rev: self._fields.8.unwrap(),
            subject_did: self._fields.9.unwrap(),
            subject_follows_owner: self._fields.10.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod event_group_chat_member_joined_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 ActorDid;
        type ConvoCreatedAt;
        type ConvoId;
        type CreatedAt;
        type GroupMemberCount;
        type GroupName;
        type JoinLinkCode;
        type OwnerDid;
        type Rev;
        type SubjectFollowsOwner;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type ActorDid = Unset;
        type ConvoCreatedAt = Unset;
        type ConvoId = Unset;
        type CreatedAt = Unset;
        type GroupMemberCount = Unset;
        type GroupName = Unset;
        type JoinLinkCode = Unset;
        type OwnerDid = Unset;
        type Rev = Unset;
        type SubjectFollowsOwner = Unset;
    }
    ///State transition - sets the `actor_did` field to Set
    pub struct SetActorDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetActorDid<St> {}
    impl<St: State> State for SetActorDid<St> {
        type ActorDid = Set<members::actor_did>;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type JoinLinkCode = St::JoinLinkCode;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `convo_created_at` field to Set
    pub struct SetConvoCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetConvoCreatedAt<St> {}
    impl<St: State> State for SetConvoCreatedAt<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = Set<members::convo_created_at>;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type JoinLinkCode = St::JoinLinkCode;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `convo_id` field to Set
    pub struct SetConvoId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetConvoId<St> {}
    impl<St: State> State for SetConvoId<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = Set<members::convo_id>;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type JoinLinkCode = St::JoinLinkCode;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///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 ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = Set<members::created_at>;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type JoinLinkCode = St::JoinLinkCode;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `group_member_count` field to Set
    pub struct SetGroupMemberCount<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetGroupMemberCount<St> {}
    impl<St: State> State for SetGroupMemberCount<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = Set<members::group_member_count>;
        type GroupName = St::GroupName;
        type JoinLinkCode = St::JoinLinkCode;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `group_name` field to Set
    pub struct SetGroupName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetGroupName<St> {}
    impl<St: State> State for SetGroupName<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = Set<members::group_name>;
        type JoinLinkCode = St::JoinLinkCode;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `join_link_code` field to Set
    pub struct SetJoinLinkCode<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetJoinLinkCode<St> {}
    impl<St: State> State for SetJoinLinkCode<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type JoinLinkCode = Set<members::join_link_code>;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `owner_did` field to Set
    pub struct SetOwnerDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetOwnerDid<St> {}
    impl<St: State> State for SetOwnerDid<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type JoinLinkCode = St::JoinLinkCode;
        type OwnerDid = Set<members::owner_did>;
        type Rev = St::Rev;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `rev` field to Set
    pub struct SetRev<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRev<St> {}
    impl<St: State> State for SetRev<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type JoinLinkCode = St::JoinLinkCode;
        type OwnerDid = St::OwnerDid;
        type Rev = Set<members::rev>;
        type SubjectFollowsOwner = St::SubjectFollowsOwner;
    }
    ///State transition - sets the `subject_follows_owner` field to Set
    pub struct SetSubjectFollowsOwner<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSubjectFollowsOwner<St> {}
    impl<St: State> State for SetSubjectFollowsOwner<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type JoinLinkCode = St::JoinLinkCode;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectFollowsOwner = Set<members::subject_follows_owner>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `actor_did` field
        pub struct actor_did(());
        ///Marker type for the `convo_created_at` field
        pub struct convo_created_at(());
        ///Marker type for the `convo_id` field
        pub struct convo_id(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `group_member_count` field
        pub struct group_member_count(());
        ///Marker type for the `group_name` field
        pub struct group_name(());
        ///Marker type for the `join_link_code` field
        pub struct join_link_code(());
        ///Marker type for the `owner_did` field
        pub struct owner_did(());
        ///Marker type for the `rev` field
        pub struct rev(());
        ///Marker type for the `subject_follows_owner` field
        pub struct subject_follows_owner(());
    }
}

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

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

impl<S: BosStr> EventGroupChatMemberJoined<S> {
    /// Create a new builder for this type
    pub fn builder() -> EventGroupChatMemberJoinedBuilder<
        event_group_chat_member_joined_state::Empty,
        S,
    > {
        EventGroupChatMemberJoinedBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> EventGroupChatMemberJoinedBuilder<St, S>
where
    St: event_group_chat_member_joined_state::State,
    St::ActorDid: event_group_chat_member_joined_state::IsUnset,
{
    /// Set the `actorDid` field (required)
    pub fn actor_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> EventGroupChatMemberJoinedBuilder<
        event_group_chat_member_joined_state::SetActorDid<St>,
        S,
    > {
        self._fields.0 = Option::Some(value.into());
        EventGroupChatMemberJoinedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberJoinedBuilder<St, S>
where
    St: event_group_chat_member_joined_state::State,
    St::ConvoCreatedAt: event_group_chat_member_joined_state::IsUnset,
{
    /// Set the `convoCreatedAt` field (required)
    pub fn convo_created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> EventGroupChatMemberJoinedBuilder<
        event_group_chat_member_joined_state::SetConvoCreatedAt<St>,
        S,
    > {
        self._fields.1 = Option::Some(value.into());
        EventGroupChatMemberJoinedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberJoinedBuilder<St, S>
where
    St: event_group_chat_member_joined_state::State,
    St::ConvoId: event_group_chat_member_joined_state::IsUnset,
{
    /// Set the `convoId` field (required)
    pub fn convo_id(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatMemberJoinedBuilder<
        event_group_chat_member_joined_state::SetConvoId<St>,
        S,
    > {
        self._fields.2 = Option::Some(value.into());
        EventGroupChatMemberJoinedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> EventGroupChatMemberJoinedBuilder<St, S>
where
    St: event_group_chat_member_joined_state::State,
    St::GroupMemberCount: event_group_chat_member_joined_state::IsUnset,
{
    /// Set the `groupMemberCount` field (required)
    pub fn group_member_count(
        mut self,
        value: impl Into<i64>,
    ) -> EventGroupChatMemberJoinedBuilder<
        event_group_chat_member_joined_state::SetGroupMemberCount<St>,
        S,
    > {
        self._fields.4 = Option::Some(value.into());
        EventGroupChatMemberJoinedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberJoinedBuilder<St, S>
where
    St: event_group_chat_member_joined_state::State,
    St::GroupName: event_group_chat_member_joined_state::IsUnset,
{
    /// Set the `groupName` field (required)
    pub fn group_name(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatMemberJoinedBuilder<
        event_group_chat_member_joined_state::SetGroupName<St>,
        S,
    > {
        self._fields.5 = Option::Some(value.into());
        EventGroupChatMemberJoinedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberJoinedBuilder<St, S>
where
    St: event_group_chat_member_joined_state::State,
    St::JoinLinkCode: event_group_chat_member_joined_state::IsUnset,
{
    /// Set the `joinLinkCode` field (required)
    pub fn join_link_code(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatMemberJoinedBuilder<
        event_group_chat_member_joined_state::SetJoinLinkCode<St>,
        S,
    > {
        self._fields.6 = Option::Some(value.into());
        EventGroupChatMemberJoinedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberJoinedBuilder<St, S>
where
    St: event_group_chat_member_joined_state::State,
    St::OwnerDid: event_group_chat_member_joined_state::IsUnset,
{
    /// Set the `ownerDid` field (required)
    pub fn owner_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> EventGroupChatMemberJoinedBuilder<
        event_group_chat_member_joined_state::SetOwnerDid<St>,
        S,
    > {
        self._fields.7 = Option::Some(value.into());
        EventGroupChatMemberJoinedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberJoinedBuilder<St, S>
where
    St: event_group_chat_member_joined_state::State,
    St::Rev: event_group_chat_member_joined_state::IsUnset,
{
    /// Set the `rev` field (required)
    pub fn rev(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatMemberJoinedBuilder<
        event_group_chat_member_joined_state::SetRev<St>,
        S,
    > {
        self._fields.8 = Option::Some(value.into());
        EventGroupChatMemberJoinedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberJoinedBuilder<St, S>
where
    St: event_group_chat_member_joined_state::State,
    St::SubjectFollowsOwner: event_group_chat_member_joined_state::IsUnset,
{
    /// Set the `subjectFollowsOwner` field (required)
    pub fn subject_follows_owner(
        mut self,
        value: impl Into<bool>,
    ) -> EventGroupChatMemberJoinedBuilder<
        event_group_chat_member_joined_state::SetSubjectFollowsOwner<St>,
        S,
    > {
        self._fields.9 = Option::Some(value.into());
        EventGroupChatMemberJoinedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberJoinedBuilder<St, S>
where
    St: event_group_chat_member_joined_state::State,
    St::ActorDid: event_group_chat_member_joined_state::IsSet,
    St::ConvoCreatedAt: event_group_chat_member_joined_state::IsSet,
    St::ConvoId: event_group_chat_member_joined_state::IsSet,
    St::CreatedAt: event_group_chat_member_joined_state::IsSet,
    St::GroupMemberCount: event_group_chat_member_joined_state::IsSet,
    St::GroupName: event_group_chat_member_joined_state::IsSet,
    St::JoinLinkCode: event_group_chat_member_joined_state::IsSet,
    St::OwnerDid: event_group_chat_member_joined_state::IsSet,
    St::Rev: event_group_chat_member_joined_state::IsSet,
    St::SubjectFollowsOwner: event_group_chat_member_joined_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> EventGroupChatMemberJoined<S> {
        EventGroupChatMemberJoined {
            actor_did: self._fields.0.unwrap(),
            convo_created_at: self._fields.1.unwrap(),
            convo_id: self._fields.2.unwrap(),
            created_at: self._fields.3.unwrap(),
            group_member_count: self._fields.4.unwrap(),
            group_name: self._fields.5.unwrap(),
            join_link_code: self._fields.6.unwrap(),
            owner_did: self._fields.7.unwrap(),
            rev: self._fields.8.unwrap(),
            subject_follows_owner: self._fields.9.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>>,
    ) -> EventGroupChatMemberJoined<S> {
        EventGroupChatMemberJoined {
            actor_did: self._fields.0.unwrap(),
            convo_created_at: self._fields.1.unwrap(),
            convo_id: self._fields.2.unwrap(),
            created_at: self._fields.3.unwrap(),
            group_member_count: self._fields.4.unwrap(),
            group_name: self._fields.5.unwrap(),
            join_link_code: self._fields.6.unwrap(),
            owner_did: self._fields.7.unwrap(),
            rev: self._fields.8.unwrap(),
            subject_follows_owner: self._fields.9.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod event_group_chat_member_left_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 ActorDid;
        type ConvoCreatedAt;
        type ConvoId;
        type CreatedAt;
        type GroupMemberCount;
        type GroupName;
        type LeaveMethod;
        type OwnerDid;
        type Rev;
        type SubjectDid;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type ActorDid = Unset;
        type ConvoCreatedAt = Unset;
        type ConvoId = Unset;
        type CreatedAt = Unset;
        type GroupMemberCount = Unset;
        type GroupName = Unset;
        type LeaveMethod = Unset;
        type OwnerDid = Unset;
        type Rev = Unset;
        type SubjectDid = Unset;
    }
    ///State transition - sets the `actor_did` field to Set
    pub struct SetActorDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetActorDid<St> {}
    impl<St: State> State for SetActorDid<St> {
        type ActorDid = Set<members::actor_did>;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type LeaveMethod = St::LeaveMethod;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
    }
    ///State transition - sets the `convo_created_at` field to Set
    pub struct SetConvoCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetConvoCreatedAt<St> {}
    impl<St: State> State for SetConvoCreatedAt<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = Set<members::convo_created_at>;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type LeaveMethod = St::LeaveMethod;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
    }
    ///State transition - sets the `convo_id` field to Set
    pub struct SetConvoId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetConvoId<St> {}
    impl<St: State> State for SetConvoId<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = Set<members::convo_id>;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type LeaveMethod = St::LeaveMethod;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
    }
    ///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 ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = Set<members::created_at>;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type LeaveMethod = St::LeaveMethod;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
    }
    ///State transition - sets the `group_member_count` field to Set
    pub struct SetGroupMemberCount<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetGroupMemberCount<St> {}
    impl<St: State> State for SetGroupMemberCount<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = Set<members::group_member_count>;
        type GroupName = St::GroupName;
        type LeaveMethod = St::LeaveMethod;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
    }
    ///State transition - sets the `group_name` field to Set
    pub struct SetGroupName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetGroupName<St> {}
    impl<St: State> State for SetGroupName<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = Set<members::group_name>;
        type LeaveMethod = St::LeaveMethod;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
    }
    ///State transition - sets the `leave_method` field to Set
    pub struct SetLeaveMethod<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetLeaveMethod<St> {}
    impl<St: State> State for SetLeaveMethod<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type LeaveMethod = Set<members::leave_method>;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
    }
    ///State transition - sets the `owner_did` field to Set
    pub struct SetOwnerDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetOwnerDid<St> {}
    impl<St: State> State for SetOwnerDid<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type LeaveMethod = St::LeaveMethod;
        type OwnerDid = Set<members::owner_did>;
        type Rev = St::Rev;
        type SubjectDid = St::SubjectDid;
    }
    ///State transition - sets the `rev` field to Set
    pub struct SetRev<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRev<St> {}
    impl<St: State> State for SetRev<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type LeaveMethod = St::LeaveMethod;
        type OwnerDid = St::OwnerDid;
        type Rev = Set<members::rev>;
        type SubjectDid = St::SubjectDid;
    }
    ///State transition - sets the `subject_did` field to Set
    pub struct SetSubjectDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSubjectDid<St> {}
    impl<St: State> State for SetSubjectDid<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type LeaveMethod = St::LeaveMethod;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type SubjectDid = Set<members::subject_did>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `actor_did` field
        pub struct actor_did(());
        ///Marker type for the `convo_created_at` field
        pub struct convo_created_at(());
        ///Marker type for the `convo_id` field
        pub struct convo_id(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `group_member_count` field
        pub struct group_member_count(());
        ///Marker type for the `group_name` field
        pub struct group_name(());
        ///Marker type for the `leave_method` field
        pub struct leave_method(());
        ///Marker type for the `owner_did` field
        pub struct owner_did(());
        ///Marker type for the `rev` field
        pub struct rev(());
        ///Marker type for the `subject_did` field
        pub struct subject_did(());
    }
}

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

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

impl<S: BosStr> EventGroupChatMemberLeft<S> {
    /// Create a new builder for this type
    pub fn builder() -> EventGroupChatMemberLeftBuilder<
        event_group_chat_member_left_state::Empty,
        S,
    > {
        EventGroupChatMemberLeftBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> EventGroupChatMemberLeftBuilder<St, S>
where
    St: event_group_chat_member_left_state::State,
    St::ActorDid: event_group_chat_member_left_state::IsUnset,
{
    /// Set the `actorDid` field (required)
    pub fn actor_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> EventGroupChatMemberLeftBuilder<
        event_group_chat_member_left_state::SetActorDid<St>,
        S,
    > {
        self._fields.0 = Option::Some(value.into());
        EventGroupChatMemberLeftBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberLeftBuilder<St, S>
where
    St: event_group_chat_member_left_state::State,
    St::ConvoCreatedAt: event_group_chat_member_left_state::IsUnset,
{
    /// Set the `convoCreatedAt` field (required)
    pub fn convo_created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> EventGroupChatMemberLeftBuilder<
        event_group_chat_member_left_state::SetConvoCreatedAt<St>,
        S,
    > {
        self._fields.1 = Option::Some(value.into());
        EventGroupChatMemberLeftBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberLeftBuilder<St, S>
where
    St: event_group_chat_member_left_state::State,
    St::ConvoId: event_group_chat_member_left_state::IsUnset,
{
    /// Set the `convoId` field (required)
    pub fn convo_id(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatMemberLeftBuilder<
        event_group_chat_member_left_state::SetConvoId<St>,
        S,
    > {
        self._fields.2 = Option::Some(value.into());
        EventGroupChatMemberLeftBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> EventGroupChatMemberLeftBuilder<St, S>
where
    St: event_group_chat_member_left_state::State,
    St::GroupMemberCount: event_group_chat_member_left_state::IsUnset,
{
    /// Set the `groupMemberCount` field (required)
    pub fn group_member_count(
        mut self,
        value: impl Into<i64>,
    ) -> EventGroupChatMemberLeftBuilder<
        event_group_chat_member_left_state::SetGroupMemberCount<St>,
        S,
    > {
        self._fields.4 = Option::Some(value.into());
        EventGroupChatMemberLeftBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberLeftBuilder<St, S>
where
    St: event_group_chat_member_left_state::State,
    St::GroupName: event_group_chat_member_left_state::IsUnset,
{
    /// Set the `groupName` field (required)
    pub fn group_name(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatMemberLeftBuilder<
        event_group_chat_member_left_state::SetGroupName<St>,
        S,
    > {
        self._fields.5 = Option::Some(value.into());
        EventGroupChatMemberLeftBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberLeftBuilder<St, S>
where
    St: event_group_chat_member_left_state::State,
    St::LeaveMethod: event_group_chat_member_left_state::IsUnset,
{
    /// Set the `leaveMethod` field (required)
    pub fn leave_method(
        mut self,
        value: impl Into<EventGroupChatMemberLeftLeaveMethod<S>>,
    ) -> EventGroupChatMemberLeftBuilder<
        event_group_chat_member_left_state::SetLeaveMethod<St>,
        S,
    > {
        self._fields.6 = Option::Some(value.into());
        EventGroupChatMemberLeftBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberLeftBuilder<St, S>
where
    St: event_group_chat_member_left_state::State,
    St::OwnerDid: event_group_chat_member_left_state::IsUnset,
{
    /// Set the `ownerDid` field (required)
    pub fn owner_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> EventGroupChatMemberLeftBuilder<
        event_group_chat_member_left_state::SetOwnerDid<St>,
        S,
    > {
        self._fields.7 = Option::Some(value.into());
        EventGroupChatMemberLeftBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberLeftBuilder<St, S>
where
    St: event_group_chat_member_left_state::State,
    St::Rev: event_group_chat_member_left_state::IsUnset,
{
    /// Set the `rev` field (required)
    pub fn rev(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatMemberLeftBuilder<
        event_group_chat_member_left_state::SetRev<St>,
        S,
    > {
        self._fields.8 = Option::Some(value.into());
        EventGroupChatMemberLeftBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberLeftBuilder<St, S>
where
    St: event_group_chat_member_left_state::State,
    St::SubjectDid: event_group_chat_member_left_state::IsUnset,
{
    /// Set the `subjectDid` field (required)
    pub fn subject_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> EventGroupChatMemberLeftBuilder<
        event_group_chat_member_left_state::SetSubjectDid<St>,
        S,
    > {
        self._fields.9 = Option::Some(value.into());
        EventGroupChatMemberLeftBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatMemberLeftBuilder<St, S>
where
    St: event_group_chat_member_left_state::State,
    St::ActorDid: event_group_chat_member_left_state::IsSet,
    St::ConvoCreatedAt: event_group_chat_member_left_state::IsSet,
    St::ConvoId: event_group_chat_member_left_state::IsSet,
    St::CreatedAt: event_group_chat_member_left_state::IsSet,
    St::GroupMemberCount: event_group_chat_member_left_state::IsSet,
    St::GroupName: event_group_chat_member_left_state::IsSet,
    St::LeaveMethod: event_group_chat_member_left_state::IsSet,
    St::OwnerDid: event_group_chat_member_left_state::IsSet,
    St::Rev: event_group_chat_member_left_state::IsSet,
    St::SubjectDid: event_group_chat_member_left_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> EventGroupChatMemberLeft<S> {
        EventGroupChatMemberLeft {
            actor_did: self._fields.0.unwrap(),
            convo_created_at: self._fields.1.unwrap(),
            convo_id: self._fields.2.unwrap(),
            created_at: self._fields.3.unwrap(),
            group_member_count: self._fields.4.unwrap(),
            group_name: self._fields.5.unwrap(),
            leave_method: self._fields.6.unwrap(),
            owner_did: self._fields.7.unwrap(),
            rev: self._fields.8.unwrap(),
            subject_did: self._fields.9.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>>,
    ) -> EventGroupChatMemberLeft<S> {
        EventGroupChatMemberLeft {
            actor_did: self._fields.0.unwrap(),
            convo_created_at: self._fields.1.unwrap(),
            convo_id: self._fields.2.unwrap(),
            created_at: self._fields.3.unwrap(),
            group_member_count: self._fields.4.unwrap(),
            group_name: self._fields.5.unwrap(),
            leave_method: self._fields.6.unwrap(),
            owner_did: self._fields.7.unwrap(),
            rev: self._fields.8.unwrap(),
            subject_did: self._fields.9.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod event_group_chat_updated_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 ActorDid;
        type ConvoCreatedAt;
        type ConvoId;
        type CreatedAt;
        type GroupMemberCount;
        type GroupName;
        type OwnerDid;
        type Rev;
        type UpdateType;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type ActorDid = Unset;
        type ConvoCreatedAt = Unset;
        type ConvoId = Unset;
        type CreatedAt = Unset;
        type GroupMemberCount = Unset;
        type GroupName = Unset;
        type OwnerDid = Unset;
        type Rev = Unset;
        type UpdateType = Unset;
    }
    ///State transition - sets the `actor_did` field to Set
    pub struct SetActorDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetActorDid<St> {}
    impl<St: State> State for SetActorDid<St> {
        type ActorDid = Set<members::actor_did>;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type UpdateType = St::UpdateType;
    }
    ///State transition - sets the `convo_created_at` field to Set
    pub struct SetConvoCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetConvoCreatedAt<St> {}
    impl<St: State> State for SetConvoCreatedAt<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = Set<members::convo_created_at>;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type UpdateType = St::UpdateType;
    }
    ///State transition - sets the `convo_id` field to Set
    pub struct SetConvoId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetConvoId<St> {}
    impl<St: State> State for SetConvoId<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = Set<members::convo_id>;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type UpdateType = St::UpdateType;
    }
    ///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 ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = Set<members::created_at>;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type UpdateType = St::UpdateType;
    }
    ///State transition - sets the `group_member_count` field to Set
    pub struct SetGroupMemberCount<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetGroupMemberCount<St> {}
    impl<St: State> State for SetGroupMemberCount<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = Set<members::group_member_count>;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type UpdateType = St::UpdateType;
    }
    ///State transition - sets the `group_name` field to Set
    pub struct SetGroupName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetGroupName<St> {}
    impl<St: State> State for SetGroupName<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = Set<members::group_name>;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type UpdateType = St::UpdateType;
    }
    ///State transition - sets the `owner_did` field to Set
    pub struct SetOwnerDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetOwnerDid<St> {}
    impl<St: State> State for SetOwnerDid<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = Set<members::owner_did>;
        type Rev = St::Rev;
        type UpdateType = St::UpdateType;
    }
    ///State transition - sets the `rev` field to Set
    pub struct SetRev<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRev<St> {}
    impl<St: State> State for SetRev<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type Rev = Set<members::rev>;
        type UpdateType = St::UpdateType;
    }
    ///State transition - sets the `update_type` field to Set
    pub struct SetUpdateType<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUpdateType<St> {}
    impl<St: State> State for SetUpdateType<St> {
        type ActorDid = St::ActorDid;
        type ConvoCreatedAt = St::ConvoCreatedAt;
        type ConvoId = St::ConvoId;
        type CreatedAt = St::CreatedAt;
        type GroupMemberCount = St::GroupMemberCount;
        type GroupName = St::GroupName;
        type OwnerDid = St::OwnerDid;
        type Rev = St::Rev;
        type UpdateType = Set<members::update_type>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `actor_did` field
        pub struct actor_did(());
        ///Marker type for the `convo_created_at` field
        pub struct convo_created_at(());
        ///Marker type for the `convo_id` field
        pub struct convo_id(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `group_member_count` field
        pub struct group_member_count(());
        ///Marker type for the `group_name` field
        pub struct group_name(());
        ///Marker type for the `owner_did` field
        pub struct owner_did(());
        ///Marker type for the `rev` field
        pub struct rev(());
        ///Marker type for the `update_type` field
        pub struct update_type(());
    }
}

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

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

impl<S: BosStr> EventGroupChatUpdated<S> {
    /// Create a new builder for this type
    pub fn builder() -> EventGroupChatUpdatedBuilder<
        event_group_chat_updated_state::Empty,
        S,
    > {
        EventGroupChatUpdatedBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> EventGroupChatUpdatedBuilder<St, S>
where
    St: event_group_chat_updated_state::State,
    St::ActorDid: event_group_chat_updated_state::IsUnset,
{
    /// Set the `actorDid` field (required)
    pub fn actor_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> EventGroupChatUpdatedBuilder<
        event_group_chat_updated_state::SetActorDid<St>,
        S,
    > {
        self._fields.0 = Option::Some(value.into());
        EventGroupChatUpdatedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatUpdatedBuilder<St, S>
where
    St: event_group_chat_updated_state::State,
    St::ConvoCreatedAt: event_group_chat_updated_state::IsUnset,
{
    /// Set the `convoCreatedAt` field (required)
    pub fn convo_created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> EventGroupChatUpdatedBuilder<
        event_group_chat_updated_state::SetConvoCreatedAt<St>,
        S,
    > {
        self._fields.1 = Option::Some(value.into());
        EventGroupChatUpdatedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatUpdatedBuilder<St, S>
where
    St: event_group_chat_updated_state::State,
    St::ConvoId: event_group_chat_updated_state::IsUnset,
{
    /// Set the `convoId` field (required)
    pub fn convo_id(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatUpdatedBuilder<
        event_group_chat_updated_state::SetConvoId<St>,
        S,
    > {
        self._fields.2 = Option::Some(value.into());
        EventGroupChatUpdatedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> EventGroupChatUpdatedBuilder<St, S>
where
    St: event_group_chat_updated_state::State,
    St::GroupMemberCount: event_group_chat_updated_state::IsUnset,
{
    /// Set the `groupMemberCount` field (required)
    pub fn group_member_count(
        mut self,
        value: impl Into<i64>,
    ) -> EventGroupChatUpdatedBuilder<
        event_group_chat_updated_state::SetGroupMemberCount<St>,
        S,
    > {
        self._fields.4 = Option::Some(value.into());
        EventGroupChatUpdatedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatUpdatedBuilder<St, S>
where
    St: event_group_chat_updated_state::State,
    St::GroupName: event_group_chat_updated_state::IsUnset,
{
    /// Set the `groupName` field (required)
    pub fn group_name(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatUpdatedBuilder<
        event_group_chat_updated_state::SetGroupName<St>,
        S,
    > {
        self._fields.5 = Option::Some(value.into());
        EventGroupChatUpdatedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<
    St: event_group_chat_updated_state::State,
    S: BosStr,
> EventGroupChatUpdatedBuilder<St, S> {
    /// Set the `joinLinkCode` field (optional)
    pub fn join_link_code(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `joinLinkCode` field to an Option value (optional)
    pub fn maybe_join_link_code(mut self, value: Option<S>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<
    St: event_group_chat_updated_state::State,
    S: BosStr,
> EventGroupChatUpdatedBuilder<St, S> {
    /// Set the `joinLinkFollowersOnly` field (optional)
    pub fn join_link_followers_only(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `joinLinkFollowersOnly` field to an Option value (optional)
    pub fn maybe_join_link_followers_only(mut self, value: Option<bool>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<
    St: event_group_chat_updated_state::State,
    S: BosStr,
> EventGroupChatUpdatedBuilder<St, S> {
    /// Set the `joinLinkRequiresApproval` field (optional)
    pub fn join_link_requires_approval(
        mut self,
        value: impl Into<Option<bool>>,
    ) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `joinLinkRequiresApproval` field to an Option value (optional)
    pub fn maybe_join_link_requires_approval(mut self, value: Option<bool>) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<
    St: event_group_chat_updated_state::State,
    S: BosStr,
> EventGroupChatUpdatedBuilder<St, S> {
    /// Set the `lockReason` field (optional)
    pub fn lock_reason(
        mut self,
        value: impl Into<Option<EventGroupChatUpdatedLockReason<S>>>,
    ) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `lockReason` field to an Option value (optional)
    pub fn maybe_lock_reason(
        mut self,
        value: Option<EventGroupChatUpdatedLockReason<S>>,
    ) -> Self {
        self._fields.9 = value;
        self
    }
}

impl<
    St: event_group_chat_updated_state::State,
    S: BosStr,
> EventGroupChatUpdatedBuilder<St, S> {
    /// Set the `newName` field (optional)
    pub fn new_name(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `newName` field to an Option value (optional)
    pub fn maybe_new_name(mut self, value: Option<S>) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<
    St: event_group_chat_updated_state::State,
    S: BosStr,
> EventGroupChatUpdatedBuilder<St, S> {
    /// Set the `oldName` field (optional)
    pub fn old_name(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.11 = value.into();
        self
    }
    /// Set the `oldName` field to an Option value (optional)
    pub fn maybe_old_name(mut self, value: Option<S>) -> Self {
        self._fields.11 = value;
        self
    }
}

impl<St, S: BosStr> EventGroupChatUpdatedBuilder<St, S>
where
    St: event_group_chat_updated_state::State,
    St::OwnerDid: event_group_chat_updated_state::IsUnset,
{
    /// Set the `ownerDid` field (required)
    pub fn owner_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> EventGroupChatUpdatedBuilder<
        event_group_chat_updated_state::SetOwnerDid<St>,
        S,
    > {
        self._fields.12 = Option::Some(value.into());
        EventGroupChatUpdatedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatUpdatedBuilder<St, S>
where
    St: event_group_chat_updated_state::State,
    St::Rev: event_group_chat_updated_state::IsUnset,
{
    /// Set the `rev` field (required)
    pub fn rev(
        mut self,
        value: impl Into<S>,
    ) -> EventGroupChatUpdatedBuilder<event_group_chat_updated_state::SetRev<St>, S> {
        self._fields.13 = Option::Some(value.into());
        EventGroupChatUpdatedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatUpdatedBuilder<St, S>
where
    St: event_group_chat_updated_state::State,
    St::UpdateType: event_group_chat_updated_state::IsUnset,
{
    /// Set the `updateType` field (required)
    pub fn update_type(
        mut self,
        value: impl Into<EventGroupChatUpdatedUpdateType<S>>,
    ) -> EventGroupChatUpdatedBuilder<
        event_group_chat_updated_state::SetUpdateType<St>,
        S,
    > {
        self._fields.14 = Option::Some(value.into());
        EventGroupChatUpdatedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventGroupChatUpdatedBuilder<St, S>
where
    St: event_group_chat_updated_state::State,
    St::ActorDid: event_group_chat_updated_state::IsSet,
    St::ConvoCreatedAt: event_group_chat_updated_state::IsSet,
    St::ConvoId: event_group_chat_updated_state::IsSet,
    St::CreatedAt: event_group_chat_updated_state::IsSet,
    St::GroupMemberCount: event_group_chat_updated_state::IsSet,
    St::GroupName: event_group_chat_updated_state::IsSet,
    St::OwnerDid: event_group_chat_updated_state::IsSet,
    St::Rev: event_group_chat_updated_state::IsSet,
    St::UpdateType: event_group_chat_updated_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> EventGroupChatUpdated<S> {
        EventGroupChatUpdated {
            actor_did: self._fields.0.unwrap(),
            convo_created_at: self._fields.1.unwrap(),
            convo_id: self._fields.2.unwrap(),
            created_at: self._fields.3.unwrap(),
            group_member_count: self._fields.4.unwrap(),
            group_name: self._fields.5.unwrap(),
            join_link_code: self._fields.6,
            join_link_followers_only: self._fields.7,
            join_link_requires_approval: self._fields.8,
            lock_reason: self._fields.9,
            new_name: self._fields.10,
            old_name: self._fields.11,
            owner_did: self._fields.12.unwrap(),
            rev: self._fields.13.unwrap(),
            update_type: self._fields.14.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>>,
    ) -> EventGroupChatUpdated<S> {
        EventGroupChatUpdated {
            actor_did: self._fields.0.unwrap(),
            convo_created_at: self._fields.1.unwrap(),
            convo_id: self._fields.2.unwrap(),
            created_at: self._fields.3.unwrap(),
            group_member_count: self._fields.4.unwrap(),
            group_name: self._fields.5.unwrap(),
            join_link_code: self._fields.6,
            join_link_followers_only: self._fields.7,
            join_link_requires_approval: self._fields.8,
            lock_reason: self._fields.9,
            new_name: self._fields.10,
            old_name: self._fields.11,
            owner_did: self._fields.12.unwrap(),
            rev: self._fields.13.unwrap(),
            update_type: self._fields.14.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod event_rate_limit_exceeded_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 ActorDid;
        type CreatedAt;
        type Endpoint;
        type Rev;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type ActorDid = Unset;
        type CreatedAt = Unset;
        type Endpoint = Unset;
        type Rev = Unset;
    }
    ///State transition - sets the `actor_did` field to Set
    pub struct SetActorDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetActorDid<St> {}
    impl<St: State> State for SetActorDid<St> {
        type ActorDid = Set<members::actor_did>;
        type CreatedAt = St::CreatedAt;
        type Endpoint = St::Endpoint;
        type Rev = St::Rev;
    }
    ///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 ActorDid = St::ActorDid;
        type CreatedAt = Set<members::created_at>;
        type Endpoint = St::Endpoint;
        type Rev = St::Rev;
    }
    ///State transition - sets the `endpoint` field to Set
    pub struct SetEndpoint<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetEndpoint<St> {}
    impl<St: State> State for SetEndpoint<St> {
        type ActorDid = St::ActorDid;
        type CreatedAt = St::CreatedAt;
        type Endpoint = Set<members::endpoint>;
        type Rev = St::Rev;
    }
    ///State transition - sets the `rev` field to Set
    pub struct SetRev<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRev<St> {}
    impl<St: State> State for SetRev<St> {
        type ActorDid = St::ActorDid;
        type CreatedAt = St::CreatedAt;
        type Endpoint = St::Endpoint;
        type Rev = Set<members::rev>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `actor_did` field
        pub struct actor_did(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `endpoint` field
        pub struct endpoint(());
        ///Marker type for the `rev` field
        pub struct rev(());
    }
}

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

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

impl<S: BosStr> EventRateLimitExceeded<S> {
    /// Create a new builder for this type
    pub fn builder() -> EventRateLimitExceededBuilder<
        event_rate_limit_exceeded_state::Empty,
        S,
    > {
        EventRateLimitExceededBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> EventRateLimitExceededBuilder<St, S>
where
    St: event_rate_limit_exceeded_state::State,
    St::ActorDid: event_rate_limit_exceeded_state::IsUnset,
{
    /// Set the `actorDid` field (required)
    pub fn actor_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> EventRateLimitExceededBuilder<
        event_rate_limit_exceeded_state::SetActorDid<St>,
        S,
    > {
        self._fields.0 = Option::Some(value.into());
        EventRateLimitExceededBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> EventRateLimitExceededBuilder<St, S>
where
    St: event_rate_limit_exceeded_state::State,
    St::Endpoint: event_rate_limit_exceeded_state::IsUnset,
{
    /// Set the `endpoint` field (required)
    pub fn endpoint(
        mut self,
        value: impl Into<S>,
    ) -> EventRateLimitExceededBuilder<
        event_rate_limit_exceeded_state::SetEndpoint<St>,
        S,
    > {
        self._fields.2 = Option::Some(value.into());
        EventRateLimitExceededBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventRateLimitExceededBuilder<St, S>
where
    St: event_rate_limit_exceeded_state::State,
    St::Rev: event_rate_limit_exceeded_state::IsUnset,
{
    /// Set the `rev` field (required)
    pub fn rev(
        mut self,
        value: impl Into<S>,
    ) -> EventRateLimitExceededBuilder<event_rate_limit_exceeded_state::SetRev<St>, S> {
        self._fields.3 = Option::Some(value.into());
        EventRateLimitExceededBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventRateLimitExceededBuilder<St, S>
where
    St: event_rate_limit_exceeded_state::State,
    St::ActorDid: event_rate_limit_exceeded_state::IsSet,
    St::CreatedAt: event_rate_limit_exceeded_state::IsSet,
    St::Endpoint: event_rate_limit_exceeded_state::IsSet,
    St::Rev: event_rate_limit_exceeded_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> EventRateLimitExceeded<S> {
        EventRateLimitExceeded {
            actor_did: self._fields.0.unwrap(),
            created_at: self._fields.1.unwrap(),
            endpoint: self._fields.2.unwrap(),
            rev: self._fields.3.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>>,
    ) -> EventRateLimitExceeded<S> {
        EventRateLimitExceeded {
            actor_did: self._fields.0.unwrap(),
            created_at: self._fields.1.unwrap(),
            endpoint: self._fields.2.unwrap(),
            rev: self._fields.3.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod subscribe_mod_events_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 {}
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {}
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {}
}

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

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

impl<S: BosStr> SubscribeModEvents<S> {
    /// Create a new builder for this type
    pub fn builder() -> SubscribeModEventsBuilder<subscribe_mod_events_state::Empty, S> {
        SubscribeModEventsBuilder::builder()
    }
}

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

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

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

impl<St, S: BosStr> SubscribeModEventsBuilder<St, S>
where
    St: subscribe_mod_events_state::State,
{
    /// Build the final struct.
    pub fn build(self) -> SubscribeModEvents<S> {
        SubscribeModEvents {
            cursor: self._fields.0,
        }
    }
}