// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: world.ptah.temp.contribution
//
// 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::collection::{Collection, RecordError};
use jacquard_common::types::string::{Did, AtUri, Cid, Datetime};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
/// A deed of addition. Imhotep — the most famous architect in history, deified as the Son of Ptah. Every contributor to a world is an Imhotep. They build within the tradition of the master. Their work is attributed. The lineage is unbroken.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "world.ptah.temp.contribution",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Contribution<S: BosStr = DefaultStr> {
    ///An array tracing every hand this contribution passed through. AT URIs of prior contribution records or DIDs. This is the Carryforward logic expressed at the protocol layer.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub attribution_chain: Option<Vec<AtUri<S>>>,
    ///The canonical standing of this contribution within the world.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub canonical_status: Option<ContributionCanonicalStatus<S>>,
    ///What kind of contribution and which record type it links to.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub contribution_type: Option<ContributionContributionType<S>>,
    ///Who is making the contribution.
    pub contributor_did: Did<S>,
    ///Timestamp of the contribution.
    pub created_at: Datetime,
    ///The approval status of this contribution.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub originator_approval: Option<ContributionOriginatorApproval<S>>,
    ///Whether this contribution complies with public domain sourcing requirements. Relevant for catalog worlds.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub public_domain_compliance: Option<bool>,
    ///The AT URI of the primary record being contributed. The Contribution record is the anchor of attribution — not the exhaustive list of every record the contributor touched. The full scope is discoverable via DID query across record types.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub record_reference: Option<AtUri<S>>,
    ///The AT URI of the world being contributed to.
    pub world_reference: AtUri<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// The canonical standing of this contribution within the world.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ContributionCanonicalStatus<S: BosStr = DefaultStr> {
    CanonicalStatusOfficial,
    CanonicalStatusCommunity,
    CanonicalStatusApocryphal,
    Other(S),
}

impl<S: BosStr> ContributionCanonicalStatus<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::CanonicalStatusOfficial => {
                "world.ptah.temp.defs#canonicalStatusOfficial"
            }
            Self::CanonicalStatusCommunity => {
                "world.ptah.temp.defs#canonicalStatusCommunity"
            }
            Self::CanonicalStatusApocryphal => {
                "world.ptah.temp.defs#canonicalStatusApocryphal"
            }
            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() {
            "world.ptah.temp.defs#canonicalStatusOfficial" => {
                Self::CanonicalStatusOfficial
            }
            "world.ptah.temp.defs#canonicalStatusCommunity" => {
                Self::CanonicalStatusCommunity
            }
            "world.ptah.temp.defs#canonicalStatusApocryphal" => {
                Self::CanonicalStatusApocryphal
            }
            _ => Self::Other(s),
        }
    }
}

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

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

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

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

/// What kind of contribution and which record type it links to.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ContributionContributionType<S: BosStr = DefaultStr> {
    Character,
    Role,
    Action,
    Event,
    Lore,
    Location,
    Other(S),
}

impl<S: BosStr> ContributionContributionType<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Character => "character",
            Self::Role => "role",
            Self::Action => "action",
            Self::Event => "event",
            Self::Lore => "lore",
            Self::Location => "location",
            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() {
            "character" => Self::Character,
            "role" => Self::Role,
            "action" => Self::Action,
            "event" => Self::Event,
            "lore" => Self::Lore,
            "location" => Self::Location,
            _ => Self::Other(s),
        }
    }
}

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

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

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

impl<S: BosStr> jacquard_common::IntoStatic for ContributionContributionType<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = ContributionContributionType<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            ContributionContributionType::Character => {
                ContributionContributionType::Character
            }
            ContributionContributionType::Role => ContributionContributionType::Role,
            ContributionContributionType::Action => ContributionContributionType::Action,
            ContributionContributionType::Event => ContributionContributionType::Event,
            ContributionContributionType::Lore => ContributionContributionType::Lore,
            ContributionContributionType::Location => {
                ContributionContributionType::Location
            }
            ContributionContributionType::Other(v) => {
                ContributionContributionType::Other(v.into_static())
            }
        }
    }
}

/// The approval status of this contribution.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ContributionOriginatorApproval<S: BosStr = DefaultStr> {
    Approved,
    PreApproved,
    CommunityCanon,
    Other(S),
}

impl<S: BosStr> ContributionOriginatorApproval<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Approved => "approved",
            Self::PreApproved => "preApproved",
            Self::CommunityCanon => "communityCanon",
            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() {
            "approved" => Self::Approved,
            "preApproved" => Self::PreApproved,
            "communityCanon" => Self::CommunityCanon,
            _ => Self::Other(s),
        }
    }
}

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

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

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

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

/// Typed wrapper for GetRecord response with this collection's record type.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ContributionGetRecordOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    pub uri: AtUri<S>,
    pub value: Contribution<S>,
}

impl<S: BosStr> Contribution<S> {
    pub fn uri(uri: S) -> Result<RecordUri<S, ContributionRecord>, UriError> {
        RecordUri::try_from_uri(AtUri::new(uri)?)
    }
}

/// Marker type for deserializing records from this collection.

#[derive(Debug, Serialize, Deserialize)]
pub struct ContributionRecord;
impl XrpcResp for ContributionRecord {
    const NSID: &'static str = "world.ptah.temp.contribution";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = ContributionGetRecordOutput<S>;
    type Err = RecordError;
}

impl<S: BosStr> From<ContributionGetRecordOutput<S>> for Contribution<S> {
    fn from(output: ContributionGetRecordOutput<S>) -> Self {
        output.value
    }
}

impl<S: BosStr> Collection for Contribution<S> {
    const NSID: &'static str = "world.ptah.temp.contribution";
    type Record = ContributionRecord;
}

impl Collection for ContributionRecord {
    const NSID: &'static str = "world.ptah.temp.contribution";
    type Record = ContributionRecord;
}

impl<S: BosStr> LexiconSchema for Contribution<S> {
    fn nsid() -> &'static str {
        "world.ptah.temp.contribution"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_world_ptah_temp_contribution()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.contribution_type {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 640usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("contribution_type"),
                    max: 640usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.contribution_type {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("contribution_type"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

pub mod contribution_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 ContributorDid;
        type CreatedAt;
        type WorldReference;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type ContributorDid = Unset;
        type CreatedAt = Unset;
        type WorldReference = Unset;
    }
    ///State transition - sets the `contributor_did` field to Set
    pub struct SetContributorDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetContributorDid<St> {}
    impl<St: State> State for SetContributorDid<St> {
        type ContributorDid = Set<members::contributor_did>;
        type CreatedAt = St::CreatedAt;
        type WorldReference = St::WorldReference;
    }
    ///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 ContributorDid = St::ContributorDid;
        type CreatedAt = Set<members::created_at>;
        type WorldReference = St::WorldReference;
    }
    ///State transition - sets the `world_reference` field to Set
    pub struct SetWorldReference<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetWorldReference<St> {}
    impl<St: State> State for SetWorldReference<St> {
        type ContributorDid = St::ContributorDid;
        type CreatedAt = St::CreatedAt;
        type WorldReference = Set<members::world_reference>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `contributor_did` field
        pub struct contributor_did(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `world_reference` field
        pub struct world_reference(());
    }
}

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

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

impl<S: BosStr> Contribution<S> {
    /// Create a new builder for this type
    pub fn builder() -> ContributionBuilder<contribution_state::Empty, S> {
        ContributionBuilder::builder()
    }
}

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

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

impl<St: contribution_state::State, S: BosStr> ContributionBuilder<St, S> {
    /// Set the `attributionChain` field (optional)
    pub fn attribution_chain(mut self, value: impl Into<Option<Vec<AtUri<S>>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `attributionChain` field to an Option value (optional)
    pub fn maybe_attribution_chain(mut self, value: Option<Vec<AtUri<S>>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St: contribution_state::State, S: BosStr> ContributionBuilder<St, S> {
    /// Set the `canonicalStatus` field (optional)
    pub fn canonical_status(
        mut self,
        value: impl Into<Option<ContributionCanonicalStatus<S>>>,
    ) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `canonicalStatus` field to an Option value (optional)
    pub fn maybe_canonical_status(
        mut self,
        value: Option<ContributionCanonicalStatus<S>>,
    ) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St: contribution_state::State, S: BosStr> ContributionBuilder<St, S> {
    /// Set the `contributionType` field (optional)
    pub fn contribution_type(
        mut self,
        value: impl Into<Option<ContributionContributionType<S>>>,
    ) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `contributionType` field to an Option value (optional)
    pub fn maybe_contribution_type(
        mut self,
        value: Option<ContributionContributionType<S>>,
    ) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St, S: BosStr> ContributionBuilder<St, S>
where
    St: contribution_state::State,
    St::ContributorDid: contribution_state::IsUnset,
{
    /// Set the `contributorDID` field (required)
    pub fn contributor_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> ContributionBuilder<contribution_state::SetContributorDid<St>, S> {
        self._fields.3 = Option::Some(value.into());
        ContributionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St: contribution_state::State, S: BosStr> ContributionBuilder<St, S> {
    /// Set the `originatorApproval` field (optional)
    pub fn originator_approval(
        mut self,
        value: impl Into<Option<ContributionOriginatorApproval<S>>>,
    ) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `originatorApproval` field to an Option value (optional)
    pub fn maybe_originator_approval(
        mut self,
        value: Option<ContributionOriginatorApproval<S>>,
    ) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St: contribution_state::State, S: BosStr> ContributionBuilder<St, S> {
    /// Set the `publicDomainCompliance` field (optional)
    pub fn public_domain_compliance(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `publicDomainCompliance` field to an Option value (optional)
    pub fn maybe_public_domain_compliance(mut self, value: Option<bool>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<St: contribution_state::State, S: BosStr> ContributionBuilder<St, S> {
    /// Set the `recordReference` field (optional)
    pub fn record_reference(mut self, value: impl Into<Option<AtUri<S>>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `recordReference` field to an Option value (optional)
    pub fn maybe_record_reference(mut self, value: Option<AtUri<S>>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<St, S: BosStr> ContributionBuilder<St, S>
where
    St: contribution_state::State,
    St::WorldReference: contribution_state::IsUnset,
{
    /// Set the `worldReference` field (required)
    pub fn world_reference(
        mut self,
        value: impl Into<AtUri<S>>,
    ) -> ContributionBuilder<contribution_state::SetWorldReference<St>, S> {
        self._fields.8 = Option::Some(value.into());
        ContributionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ContributionBuilder<St, S>
where
    St: contribution_state::State,
    St::ContributorDid: contribution_state::IsSet,
    St::CreatedAt: contribution_state::IsSet,
    St::WorldReference: contribution_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Contribution<S> {
        Contribution {
            attribution_chain: self._fields.0,
            canonical_status: self._fields.1,
            contribution_type: self._fields.2,
            contributor_did: self._fields.3.unwrap(),
            created_at: self._fields.4.unwrap(),
            originator_approval: self._fields.5,
            public_domain_compliance: self._fields.6,
            record_reference: self._fields.7,
            world_reference: 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>>,
    ) -> Contribution<S> {
        Contribution {
            attribution_chain: self._fields.0,
            canonical_status: self._fields.1,
            contribution_type: self._fields.2,
            contributor_did: self._fields.3.unwrap(),
            created_at: self._fields.4.unwrap(),
            originator_approval: self._fields.5,
            public_domain_compliance: self._fields.6,
            record_reference: self._fields.7,
            world_reference: self._fields.8.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_world_ptah_temp_contribution() -> 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("world.ptah.temp.contribution"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static(
                            "A deed of addition. Imhotep — the most famous architect in history, deified as the Son of Ptah. Every contributor to a world is an Imhotep. They build within the tradition of the master. Their work is attributed. The lineage is unbroken.",
                        ),
                    ),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("contributorDID"),
                                SmolStr::new_static("worldReference"),
                                SmolStr::new_static("createdAt")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("attributionChain"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(
                                        CowStr::new_static(
                                            "An array tracing every hand this contribution passed through. AT URIs of prior contribution records or DIDs. This is the Carryforward logic expressed at the protocol layer.",
                                        ),
                                    ),
                                    items: LexArrayItem::String(LexString {
                                        format: Some(LexStringFormat::AtUri),
                                        ..Default::default()
                                    }),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("canonicalStatus"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The canonical standing of this contribution within the world.",
                                        ),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("contributionType"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "What kind of contribution and which record type it links to.",
                                        ),
                                    ),
                                    max_length: Some(640usize),
                                    max_graphemes: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("contributorDID"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Who is making the contribution."),
                                    ),
                                    format: Some(LexStringFormat::Did),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Timestamp of the contribution."),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("originatorApproval"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The approval status of this contribution.",
                                        ),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("publicDomainCompliance"),
                                LexObjectProperty::Boolean(LexBoolean {
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("recordReference"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The AT URI of the primary record being contributed. The Contribution record is the anchor of attribution — not the exhaustive list of every record the contributor touched. The full scope is discoverable via DID query across record types.",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::AtUri),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("worldReference"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The AT URI of the world being contributed to.",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::AtUri),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}