// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: tools.ozone.moderation.getAccountTimeline
//
// 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;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::Did;
use jacquard_derive::{IntoStatic, lexicon, 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::tools_ozone::moderation::get_account_timeline;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetAccountTimeline<'a> {
    #[serde(borrow)]
    pub did: Did<'a>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetAccountTimelineOutput<'a> {
    #[serde(borrow)]
    pub timeline: Vec<get_account_timeline::TimelineItem<'a>>,
}


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

#[serde(tag = "error", content = "message")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum GetAccountTimelineError<'a> {
    #[serde(rename = "RepoNotFound")]
    RepoNotFound(Option<CowStr<'a>>),
}

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


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct TimelineItem<'a> {
    #[serde(borrow)]
    pub day: CowStr<'a>,
    #[serde(borrow)]
    pub summary: Vec<get_account_timeline::TimelineItemSummary<'a>>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct TimelineItemSummary<'a> {
    pub count: i64,
    #[serde(borrow)]
    pub event_subject_type: TimelineItemSummaryEventSubjectType<'a>,
    #[serde(borrow)]
    pub event_type: TimelineItemSummaryEventType<'a>,
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum TimelineItemSummaryEventSubjectType<'a> {
    Account,
    Record,
    Chat,
    Other(CowStr<'a>),
}

impl<'a> TimelineItemSummaryEventSubjectType<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Account => "account",
            Self::Record => "record",
            Self::Chat => "chat",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for TimelineItemSummaryEventSubjectType<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "account" => Self::Account,
            "record" => Self::Record,
            "chat" => Self::Chat,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for TimelineItemSummaryEventSubjectType<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "account" => Self::Account,
            "record" => Self::Record,
            "chat" => Self::Chat,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

impl<'a> AsRef<str> for TimelineItemSummaryEventSubjectType<'a> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

impl<'de, 'a> serde::Deserialize<'de> for TimelineItemSummaryEventSubjectType<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for TimelineItemSummaryEventSubjectType<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for TimelineItemSummaryEventSubjectType<'_> {
    type Output = TimelineItemSummaryEventSubjectType<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            TimelineItemSummaryEventSubjectType::Account => {
                TimelineItemSummaryEventSubjectType::Account
            }
            TimelineItemSummaryEventSubjectType::Record => {
                TimelineItemSummaryEventSubjectType::Record
            }
            TimelineItemSummaryEventSubjectType::Chat => {
                TimelineItemSummaryEventSubjectType::Chat
            }
            TimelineItemSummaryEventSubjectType::Other(v) => {
                TimelineItemSummaryEventSubjectType::Other(v.into_static())
            }
        }
    }
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum TimelineItemSummaryEventType<'a> {
    ModEventTakedown,
    ModEventReverseTakedown,
    ModEventComment,
    ModEventReport,
    ModEventLabel,
    ModEventAcknowledge,
    ModEventEscalate,
    ModEventMute,
    ModEventUnmute,
    ModEventMuteReporter,
    ModEventUnmuteReporter,
    ModEventEmail,
    ModEventResolveAppeal,
    ModEventDivert,
    ModEventTag,
    AccountEvent,
    IdentityEvent,
    RecordEvent,
    ModEventPriorityScore,
    RevokeAccountCredentialsEvent,
    AgeAssuranceEvent,
    AgeAssuranceOverrideEvent,
    TimelineEventPlcCreate,
    TimelineEventPlcOperation,
    TimelineEventPlcTombstone,
    AccountCreated,
    EmailConfirmed,
    PasswordUpdated,
    HandleUpdated,
    ScheduleTakedownEvent,
    CancelScheduledTakedownEvent,
    Other(CowStr<'a>),
}

impl<'a> TimelineItemSummaryEventType<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::ModEventTakedown => "tools.ozone.moderation.defs#modEventTakedown",
            Self::ModEventReverseTakedown => {
                "tools.ozone.moderation.defs#modEventReverseTakedown"
            }
            Self::ModEventComment => "tools.ozone.moderation.defs#modEventComment",
            Self::ModEventReport => "tools.ozone.moderation.defs#modEventReport",
            Self::ModEventLabel => "tools.ozone.moderation.defs#modEventLabel",
            Self::ModEventAcknowledge => {
                "tools.ozone.moderation.defs#modEventAcknowledge"
            }
            Self::ModEventEscalate => "tools.ozone.moderation.defs#modEventEscalate",
            Self::ModEventMute => "tools.ozone.moderation.defs#modEventMute",
            Self::ModEventUnmute => "tools.ozone.moderation.defs#modEventUnmute",
            Self::ModEventMuteReporter => {
                "tools.ozone.moderation.defs#modEventMuteReporter"
            }
            Self::ModEventUnmuteReporter => {
                "tools.ozone.moderation.defs#modEventUnmuteReporter"
            }
            Self::ModEventEmail => "tools.ozone.moderation.defs#modEventEmail",
            Self::ModEventResolveAppeal => {
                "tools.ozone.moderation.defs#modEventResolveAppeal"
            }
            Self::ModEventDivert => "tools.ozone.moderation.defs#modEventDivert",
            Self::ModEventTag => "tools.ozone.moderation.defs#modEventTag",
            Self::AccountEvent => "tools.ozone.moderation.defs#accountEvent",
            Self::IdentityEvent => "tools.ozone.moderation.defs#identityEvent",
            Self::RecordEvent => "tools.ozone.moderation.defs#recordEvent",
            Self::ModEventPriorityScore => {
                "tools.ozone.moderation.defs#modEventPriorityScore"
            }
            Self::RevokeAccountCredentialsEvent => {
                "tools.ozone.moderation.defs#revokeAccountCredentialsEvent"
            }
            Self::AgeAssuranceEvent => "tools.ozone.moderation.defs#ageAssuranceEvent",
            Self::AgeAssuranceOverrideEvent => {
                "tools.ozone.moderation.defs#ageAssuranceOverrideEvent"
            }
            Self::TimelineEventPlcCreate => {
                "tools.ozone.moderation.defs#timelineEventPlcCreate"
            }
            Self::TimelineEventPlcOperation => {
                "tools.ozone.moderation.defs#timelineEventPlcOperation"
            }
            Self::TimelineEventPlcTombstone => {
                "tools.ozone.moderation.defs#timelineEventPlcTombstone"
            }
            Self::AccountCreated => {
                "tools.ozone.hosting.getAccountHistory#accountCreated"
            }
            Self::EmailConfirmed => {
                "tools.ozone.hosting.getAccountHistory#emailConfirmed"
            }
            Self::PasswordUpdated => {
                "tools.ozone.hosting.getAccountHistory#passwordUpdated"
            }
            Self::HandleUpdated => "tools.ozone.hosting.getAccountHistory#handleUpdated",
            Self::ScheduleTakedownEvent => {
                "tools.ozone.moderation.defs#scheduleTakedownEvent"
            }
            Self::CancelScheduledTakedownEvent => {
                "tools.ozone.moderation.defs#cancelScheduledTakedownEvent"
            }
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for TimelineItemSummaryEventType<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "tools.ozone.moderation.defs#modEventTakedown" => Self::ModEventTakedown,
            "tools.ozone.moderation.defs#modEventReverseTakedown" => {
                Self::ModEventReverseTakedown
            }
            "tools.ozone.moderation.defs#modEventComment" => Self::ModEventComment,
            "tools.ozone.moderation.defs#modEventReport" => Self::ModEventReport,
            "tools.ozone.moderation.defs#modEventLabel" => Self::ModEventLabel,
            "tools.ozone.moderation.defs#modEventAcknowledge" => {
                Self::ModEventAcknowledge
            }
            "tools.ozone.moderation.defs#modEventEscalate" => Self::ModEventEscalate,
            "tools.ozone.moderation.defs#modEventMute" => Self::ModEventMute,
            "tools.ozone.moderation.defs#modEventUnmute" => Self::ModEventUnmute,
            "tools.ozone.moderation.defs#modEventMuteReporter" => {
                Self::ModEventMuteReporter
            }
            "tools.ozone.moderation.defs#modEventUnmuteReporter" => {
                Self::ModEventUnmuteReporter
            }
            "tools.ozone.moderation.defs#modEventEmail" => Self::ModEventEmail,
            "tools.ozone.moderation.defs#modEventResolveAppeal" => {
                Self::ModEventResolveAppeal
            }
            "tools.ozone.moderation.defs#modEventDivert" => Self::ModEventDivert,
            "tools.ozone.moderation.defs#modEventTag" => Self::ModEventTag,
            "tools.ozone.moderation.defs#accountEvent" => Self::AccountEvent,
            "tools.ozone.moderation.defs#identityEvent" => Self::IdentityEvent,
            "tools.ozone.moderation.defs#recordEvent" => Self::RecordEvent,
            "tools.ozone.moderation.defs#modEventPriorityScore" => {
                Self::ModEventPriorityScore
            }
            "tools.ozone.moderation.defs#revokeAccountCredentialsEvent" => {
                Self::RevokeAccountCredentialsEvent
            }
            "tools.ozone.moderation.defs#ageAssuranceEvent" => Self::AgeAssuranceEvent,
            "tools.ozone.moderation.defs#ageAssuranceOverrideEvent" => {
                Self::AgeAssuranceOverrideEvent
            }
            "tools.ozone.moderation.defs#timelineEventPlcCreate" => {
                Self::TimelineEventPlcCreate
            }
            "tools.ozone.moderation.defs#timelineEventPlcOperation" => {
                Self::TimelineEventPlcOperation
            }
            "tools.ozone.moderation.defs#timelineEventPlcTombstone" => {
                Self::TimelineEventPlcTombstone
            }
            "tools.ozone.hosting.getAccountHistory#accountCreated" => {
                Self::AccountCreated
            }
            "tools.ozone.hosting.getAccountHistory#emailConfirmed" => {
                Self::EmailConfirmed
            }
            "tools.ozone.hosting.getAccountHistory#passwordUpdated" => {
                Self::PasswordUpdated
            }
            "tools.ozone.hosting.getAccountHistory#handleUpdated" => Self::HandleUpdated,
            "tools.ozone.moderation.defs#scheduleTakedownEvent" => {
                Self::ScheduleTakedownEvent
            }
            "tools.ozone.moderation.defs#cancelScheduledTakedownEvent" => {
                Self::CancelScheduledTakedownEvent
            }
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for TimelineItemSummaryEventType<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "tools.ozone.moderation.defs#modEventTakedown" => Self::ModEventTakedown,
            "tools.ozone.moderation.defs#modEventReverseTakedown" => {
                Self::ModEventReverseTakedown
            }
            "tools.ozone.moderation.defs#modEventComment" => Self::ModEventComment,
            "tools.ozone.moderation.defs#modEventReport" => Self::ModEventReport,
            "tools.ozone.moderation.defs#modEventLabel" => Self::ModEventLabel,
            "tools.ozone.moderation.defs#modEventAcknowledge" => {
                Self::ModEventAcknowledge
            }
            "tools.ozone.moderation.defs#modEventEscalate" => Self::ModEventEscalate,
            "tools.ozone.moderation.defs#modEventMute" => Self::ModEventMute,
            "tools.ozone.moderation.defs#modEventUnmute" => Self::ModEventUnmute,
            "tools.ozone.moderation.defs#modEventMuteReporter" => {
                Self::ModEventMuteReporter
            }
            "tools.ozone.moderation.defs#modEventUnmuteReporter" => {
                Self::ModEventUnmuteReporter
            }
            "tools.ozone.moderation.defs#modEventEmail" => Self::ModEventEmail,
            "tools.ozone.moderation.defs#modEventResolveAppeal" => {
                Self::ModEventResolveAppeal
            }
            "tools.ozone.moderation.defs#modEventDivert" => Self::ModEventDivert,
            "tools.ozone.moderation.defs#modEventTag" => Self::ModEventTag,
            "tools.ozone.moderation.defs#accountEvent" => Self::AccountEvent,
            "tools.ozone.moderation.defs#identityEvent" => Self::IdentityEvent,
            "tools.ozone.moderation.defs#recordEvent" => Self::RecordEvent,
            "tools.ozone.moderation.defs#modEventPriorityScore" => {
                Self::ModEventPriorityScore
            }
            "tools.ozone.moderation.defs#revokeAccountCredentialsEvent" => {
                Self::RevokeAccountCredentialsEvent
            }
            "tools.ozone.moderation.defs#ageAssuranceEvent" => Self::AgeAssuranceEvent,
            "tools.ozone.moderation.defs#ageAssuranceOverrideEvent" => {
                Self::AgeAssuranceOverrideEvent
            }
            "tools.ozone.moderation.defs#timelineEventPlcCreate" => {
                Self::TimelineEventPlcCreate
            }
            "tools.ozone.moderation.defs#timelineEventPlcOperation" => {
                Self::TimelineEventPlcOperation
            }
            "tools.ozone.moderation.defs#timelineEventPlcTombstone" => {
                Self::TimelineEventPlcTombstone
            }
            "tools.ozone.hosting.getAccountHistory#accountCreated" => {
                Self::AccountCreated
            }
            "tools.ozone.hosting.getAccountHistory#emailConfirmed" => {
                Self::EmailConfirmed
            }
            "tools.ozone.hosting.getAccountHistory#passwordUpdated" => {
                Self::PasswordUpdated
            }
            "tools.ozone.hosting.getAccountHistory#handleUpdated" => Self::HandleUpdated,
            "tools.ozone.moderation.defs#scheduleTakedownEvent" => {
                Self::ScheduleTakedownEvent
            }
            "tools.ozone.moderation.defs#cancelScheduledTakedownEvent" => {
                Self::CancelScheduledTakedownEvent
            }
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

impl<'a> AsRef<str> for TimelineItemSummaryEventType<'a> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

impl<'de, 'a> serde::Deserialize<'de> for TimelineItemSummaryEventType<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for TimelineItemSummaryEventType<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for TimelineItemSummaryEventType<'_> {
    type Output = TimelineItemSummaryEventType<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            TimelineItemSummaryEventType::ModEventTakedown => {
                TimelineItemSummaryEventType::ModEventTakedown
            }
            TimelineItemSummaryEventType::ModEventReverseTakedown => {
                TimelineItemSummaryEventType::ModEventReverseTakedown
            }
            TimelineItemSummaryEventType::ModEventComment => {
                TimelineItemSummaryEventType::ModEventComment
            }
            TimelineItemSummaryEventType::ModEventReport => {
                TimelineItemSummaryEventType::ModEventReport
            }
            TimelineItemSummaryEventType::ModEventLabel => {
                TimelineItemSummaryEventType::ModEventLabel
            }
            TimelineItemSummaryEventType::ModEventAcknowledge => {
                TimelineItemSummaryEventType::ModEventAcknowledge
            }
            TimelineItemSummaryEventType::ModEventEscalate => {
                TimelineItemSummaryEventType::ModEventEscalate
            }
            TimelineItemSummaryEventType::ModEventMute => {
                TimelineItemSummaryEventType::ModEventMute
            }
            TimelineItemSummaryEventType::ModEventUnmute => {
                TimelineItemSummaryEventType::ModEventUnmute
            }
            TimelineItemSummaryEventType::ModEventMuteReporter => {
                TimelineItemSummaryEventType::ModEventMuteReporter
            }
            TimelineItemSummaryEventType::ModEventUnmuteReporter => {
                TimelineItemSummaryEventType::ModEventUnmuteReporter
            }
            TimelineItemSummaryEventType::ModEventEmail => {
                TimelineItemSummaryEventType::ModEventEmail
            }
            TimelineItemSummaryEventType::ModEventResolveAppeal => {
                TimelineItemSummaryEventType::ModEventResolveAppeal
            }
            TimelineItemSummaryEventType::ModEventDivert => {
                TimelineItemSummaryEventType::ModEventDivert
            }
            TimelineItemSummaryEventType::ModEventTag => {
                TimelineItemSummaryEventType::ModEventTag
            }
            TimelineItemSummaryEventType::AccountEvent => {
                TimelineItemSummaryEventType::AccountEvent
            }
            TimelineItemSummaryEventType::IdentityEvent => {
                TimelineItemSummaryEventType::IdentityEvent
            }
            TimelineItemSummaryEventType::RecordEvent => {
                TimelineItemSummaryEventType::RecordEvent
            }
            TimelineItemSummaryEventType::ModEventPriorityScore => {
                TimelineItemSummaryEventType::ModEventPriorityScore
            }
            TimelineItemSummaryEventType::RevokeAccountCredentialsEvent => {
                TimelineItemSummaryEventType::RevokeAccountCredentialsEvent
            }
            TimelineItemSummaryEventType::AgeAssuranceEvent => {
                TimelineItemSummaryEventType::AgeAssuranceEvent
            }
            TimelineItemSummaryEventType::AgeAssuranceOverrideEvent => {
                TimelineItemSummaryEventType::AgeAssuranceOverrideEvent
            }
            TimelineItemSummaryEventType::TimelineEventPlcCreate => {
                TimelineItemSummaryEventType::TimelineEventPlcCreate
            }
            TimelineItemSummaryEventType::TimelineEventPlcOperation => {
                TimelineItemSummaryEventType::TimelineEventPlcOperation
            }
            TimelineItemSummaryEventType::TimelineEventPlcTombstone => {
                TimelineItemSummaryEventType::TimelineEventPlcTombstone
            }
            TimelineItemSummaryEventType::AccountCreated => {
                TimelineItemSummaryEventType::AccountCreated
            }
            TimelineItemSummaryEventType::EmailConfirmed => {
                TimelineItemSummaryEventType::EmailConfirmed
            }
            TimelineItemSummaryEventType::PasswordUpdated => {
                TimelineItemSummaryEventType::PasswordUpdated
            }
            TimelineItemSummaryEventType::HandleUpdated => {
                TimelineItemSummaryEventType::HandleUpdated
            }
            TimelineItemSummaryEventType::ScheduleTakedownEvent => {
                TimelineItemSummaryEventType::ScheduleTakedownEvent
            }
            TimelineItemSummaryEventType::CancelScheduledTakedownEvent => {
                TimelineItemSummaryEventType::CancelScheduledTakedownEvent
            }
            TimelineItemSummaryEventType::Other(v) => {
                TimelineItemSummaryEventType::Other(v.into_static())
            }
        }
    }
}

/// Response type for tools.ozone.moderation.getAccountTimeline
pub struct GetAccountTimelineResponse;
impl jacquard_common::xrpc::XrpcResp for GetAccountTimelineResponse {
    const NSID: &'static str = "tools.ozone.moderation.getAccountTimeline";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = GetAccountTimelineOutput<'de>;
    type Err<'de> = GetAccountTimelineError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for GetAccountTimeline<'a> {
    const NSID: &'static str = "tools.ozone.moderation.getAccountTimeline";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetAccountTimelineResponse;
}

/// Endpoint type for tools.ozone.moderation.getAccountTimeline
pub struct GetAccountTimelineRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetAccountTimelineRequest {
    const PATH: &'static str = "/xrpc/tools.ozone.moderation.getAccountTimeline";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<'de> = GetAccountTimeline<'de>;
    type Response = GetAccountTimelineResponse;
}

impl<'a> LexiconSchema for TimelineItem<'a> {
    fn nsid() -> &'static str {
        "tools.ozone.moderation.getAccountTimeline"
    }
    fn def_name() -> &'static str {
        "timelineItem"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_tools_ozone_moderation_getAccountTimeline()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for TimelineItemSummary<'a> {
    fn nsid() -> &'static str {
        "tools.ozone.moderation.getAccountTimeline"
    }
    fn def_name() -> &'static str {
        "timelineItemSummary"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_tools_ozone_moderation_getAccountTimeline()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

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

/// Builder for constructing an instance of this type
pub struct GetAccountTimelineBuilder<'a, S: get_account_timeline_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<Did<'a>>,),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> GetAccountTimeline<'a> {
    /// Create a new builder for this type
    pub fn new() -> GetAccountTimelineBuilder<'a, get_account_timeline_state::Empty> {
        GetAccountTimelineBuilder::new()
    }
}

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

impl<'a, S> GetAccountTimelineBuilder<'a, S>
where
    S: get_account_timeline_state::State,
    S::Did: get_account_timeline_state::IsUnset,
{
    /// Set the `did` field (required)
    pub fn did(
        mut self,
        value: impl Into<Did<'a>>,
    ) -> GetAccountTimelineBuilder<'a, get_account_timeline_state::SetDid<S>> {
        self._fields.0 = Option::Some(value.into());
        GetAccountTimelineBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> GetAccountTimelineBuilder<'a, S>
where
    S: get_account_timeline_state::State,
    S::Did: get_account_timeline_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> GetAccountTimeline<'a> {
        GetAccountTimeline {
            did: self._fields.0.unwrap(),
        }
    }
}

pub mod timeline_item_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 Day;
        type Summary;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Day = Unset;
        type Summary = Unset;
    }
    ///State transition - sets the `day` field to Set
    pub struct SetDay<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetDay<S> {}
    impl<S: State> State for SetDay<S> {
        type Day = Set<members::day>;
        type Summary = S::Summary;
    }
    ///State transition - sets the `summary` field to Set
    pub struct SetSummary<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetSummary<S> {}
    impl<S: State> State for SetSummary<S> {
        type Day = S::Day;
        type Summary = Set<members::summary>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `day` field
        pub struct day(());
        ///Marker type for the `summary` field
        pub struct summary(());
    }
}

/// Builder for constructing an instance of this type
pub struct TimelineItemBuilder<'a, S: timeline_item_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<CowStr<'a>>,
        Option<Vec<get_account_timeline::TimelineItemSummary<'a>>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> TimelineItem<'a> {
    /// Create a new builder for this type
    pub fn new() -> TimelineItemBuilder<'a, timeline_item_state::Empty> {
        TimelineItemBuilder::new()
    }
}

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

impl<'a, S> TimelineItemBuilder<'a, S>
where
    S: timeline_item_state::State,
    S::Day: timeline_item_state::IsUnset,
{
    /// Set the `day` field (required)
    pub fn day(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> TimelineItemBuilder<'a, timeline_item_state::SetDay<S>> {
        self._fields.0 = Option::Some(value.into());
        TimelineItemBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> TimelineItemBuilder<'a, S>
where
    S: timeline_item_state::State,
    S::Summary: timeline_item_state::IsUnset,
{
    /// Set the `summary` field (required)
    pub fn summary(
        mut self,
        value: impl Into<Vec<get_account_timeline::TimelineItemSummary<'a>>>,
    ) -> TimelineItemBuilder<'a, timeline_item_state::SetSummary<S>> {
        self._fields.1 = Option::Some(value.into());
        TimelineItemBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> TimelineItemBuilder<'a, S>
where
    S: timeline_item_state::State,
    S::Day: timeline_item_state::IsSet,
    S::Summary: timeline_item_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> TimelineItem<'a> {
        TimelineItem {
            day: self._fields.0.unwrap(),
            summary: self._fields.1.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> TimelineItem<'a> {
        TimelineItem {
            day: self._fields.0.unwrap(),
            summary: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_tools_ozone_moderation_getAccountTimeline() -> 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("tools.ozone.moderation.getAccountTimeline"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcQuery(LexXrpcQuery {
                    parameters: Some(
                        LexXrpcQueryParameter::Params(LexXrpcParameters {
                            required: Some(vec![SmolStr::new_static("did")]),
                            properties: {
                                #[allow(unused_mut)]
                                let mut map = BTreeMap::new();
                                map.insert(
                                    SmolStr::new_static("did"),
                                    LexXrpcParametersProperty::String(LexString {
                                        format: Some(LexStringFormat::Did),
                                        ..Default::default()
                                    }),
                                );
                                map
                            },
                            ..Default::default()
                        }),
                    ),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("timelineItem"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![SmolStr::new_static("day"), SmolStr::new_static("summary")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("day"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("summary"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#timelineItemSummary"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("timelineItemSummary"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("eventSubjectType"),
                            SmolStr::new_static("eventType"),
                            SmolStr::new_static("count")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("count"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("eventSubjectType"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("eventType"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod timeline_item_summary_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 EventSubjectType;
        type Count;
        type EventType;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type EventSubjectType = Unset;
        type Count = Unset;
        type EventType = Unset;
    }
    ///State transition - sets the `event_subject_type` field to Set
    pub struct SetEventSubjectType<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetEventSubjectType<S> {}
    impl<S: State> State for SetEventSubjectType<S> {
        type EventSubjectType = Set<members::event_subject_type>;
        type Count = S::Count;
        type EventType = S::EventType;
    }
    ///State transition - sets the `count` field to Set
    pub struct SetCount<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCount<S> {}
    impl<S: State> State for SetCount<S> {
        type EventSubjectType = S::EventSubjectType;
        type Count = Set<members::count>;
        type EventType = S::EventType;
    }
    ///State transition - sets the `event_type` field to Set
    pub struct SetEventType<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetEventType<S> {}
    impl<S: State> State for SetEventType<S> {
        type EventSubjectType = S::EventSubjectType;
        type Count = S::Count;
        type EventType = Set<members::event_type>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `event_subject_type` field
        pub struct event_subject_type(());
        ///Marker type for the `count` field
        pub struct count(());
        ///Marker type for the `event_type` field
        pub struct event_type(());
    }
}

/// Builder for constructing an instance of this type
pub struct TimelineItemSummaryBuilder<'a, S: timeline_item_summary_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<i64>,
        Option<TimelineItemSummaryEventSubjectType<'a>>,
        Option<TimelineItemSummaryEventType<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> TimelineItemSummary<'a> {
    /// Create a new builder for this type
    pub fn new() -> TimelineItemSummaryBuilder<'a, timeline_item_summary_state::Empty> {
        TimelineItemSummaryBuilder::new()
    }
}

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

impl<'a, S> TimelineItemSummaryBuilder<'a, S>
where
    S: timeline_item_summary_state::State,
    S::Count: timeline_item_summary_state::IsUnset,
{
    /// Set the `count` field (required)
    pub fn count(
        mut self,
        value: impl Into<i64>,
    ) -> TimelineItemSummaryBuilder<'a, timeline_item_summary_state::SetCount<S>> {
        self._fields.0 = Option::Some(value.into());
        TimelineItemSummaryBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> TimelineItemSummaryBuilder<'a, S>
where
    S: timeline_item_summary_state::State,
    S::EventSubjectType: timeline_item_summary_state::IsUnset,
{
    /// Set the `eventSubjectType` field (required)
    pub fn event_subject_type(
        mut self,
        value: impl Into<TimelineItemSummaryEventSubjectType<'a>>,
    ) -> TimelineItemSummaryBuilder<
        'a,
        timeline_item_summary_state::SetEventSubjectType<S>,
    > {
        self._fields.1 = Option::Some(value.into());
        TimelineItemSummaryBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> TimelineItemSummaryBuilder<'a, S>
where
    S: timeline_item_summary_state::State,
    S::EventType: timeline_item_summary_state::IsUnset,
{
    /// Set the `eventType` field (required)
    pub fn event_type(
        mut self,
        value: impl Into<TimelineItemSummaryEventType<'a>>,
    ) -> TimelineItemSummaryBuilder<'a, timeline_item_summary_state::SetEventType<S>> {
        self._fields.2 = Option::Some(value.into());
        TimelineItemSummaryBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> TimelineItemSummaryBuilder<'a, S>
where
    S: timeline_item_summary_state::State,
    S::EventSubjectType: timeline_item_summary_state::IsSet,
    S::Count: timeline_item_summary_state::IsSet,
    S::EventType: timeline_item_summary_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> TimelineItemSummary<'a> {
        TimelineItemSummary {
            count: self._fields.0.unwrap(),
            event_subject_type: self._fields.1.unwrap(),
            event_type: self._fields.2.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> TimelineItemSummary<'a> {
        TimelineItemSummary {
            count: self._fields.0.unwrap(),
            event_subject_type: self._fields.1.unwrap(),
            event_type: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}