// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: network.cosmik.card
//
// 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::{AtUri, Cid, Datetime, UriValue};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
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::com_atproto::repo::strong_ref::StrongRef;
use crate::network_cosmik::Provenance;
use crate::network_cosmik::card;
/// A record representing a card with content.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "network.cosmik.card",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Card<S: BosStr = DefaultStr> {
    ///The specific content of the card, determined by the card type.
    pub content: CardContent<S>,
    ///Timestamp when this card was created (usually set by PDS).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub created_at: Option<Datetime>,
    ///Optional strong reference to the original card (for NOTE cards).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub original_card: Option<StrongRef<S>>,
    ///Optional strong reference to a parent card (for NOTE cards).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parent_card: Option<StrongRef<S>>,
    ///Optional provenance information for this card.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub provenance: Option<Provenance<S>>,
    ///The type of card
    pub r#type: CardType<S>,
    ///Optional URL associated with the card. Required for URL cards, optional for NOTE cards.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub url: Option<UriValue<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum CardContent<S: BosStr = DefaultStr> {
    #[serde(rename = "network.cosmik.card#urlContent")]
    UrlContent(Box<card::UrlContent<S>>),
    #[serde(rename = "network.cosmik.card#noteContent")]
    NoteContent(Box<card::NoteContent<S>>),
}

/// The type of card

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

impl<S: BosStr> CardType<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Url => "URL",
            Self::Note => "NOTE",
            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() {
            "URL" => Self::Url,
            "NOTE" => Self::Note,
            _ => Self::Other(s),
        }
    }
}

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

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

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

impl<S: BosStr> jacquard_common::IntoStatic for CardType<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = CardType<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            CardType::Url => CardType::Url,
            CardType::Note => CardType::Note,
            CardType::Other(v) => CardType::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 CardGetRecordOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    pub uri: AtUri<S>,
    pub value: Card<S>,
}

/// Content structure for a note card.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct NoteContent<S: BosStr = DefaultStr> {
    ///The note text content
    pub text: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Content structure for a URL card.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct UrlContent<S: BosStr = DefaultStr> {
    ///Optional metadata about the URL
    #[serde(skip_serializing_if = "Option::is_none")]
    pub metadata: Option<card::UrlMetadata<S>>,
    ///The URL being saved
    pub url: UriValue<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Metadata about a URL.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct UrlMetadata<S: BosStr = DefaultStr> {
    ///Author of the content
    #[serde(skip_serializing_if = "Option::is_none")]
    pub author: Option<S>,
    ///Description of the page
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<S>,
    ///Digital Object Identifier (DOI) for academic content
    #[serde(skip_serializing_if = "Option::is_none")]
    pub doi: Option<S>,
    ///URL of a representative image
    #[serde(skip_serializing_if = "Option::is_none")]
    pub image_url: Option<UriValue<S>>,
    ///International Standard Book Number (ISBN) for books
    #[serde(skip_serializing_if = "Option::is_none")]
    pub isbn: Option<S>,
    ///When the content was published
    #[serde(skip_serializing_if = "Option::is_none")]
    pub published_date: Option<Datetime>,
    ///When the metadata was retrieved
    #[serde(skip_serializing_if = "Option::is_none")]
    pub retrieved_at: Option<Datetime>,
    ///Name of the site
    #[serde(skip_serializing_if = "Option::is_none")]
    pub site_name: Option<S>,
    ///Title of the page
    #[serde(skip_serializing_if = "Option::is_none")]
    pub title: Option<S>,
    ///Type of content (e.g., 'video', 'article')
    #[serde(skip_serializing_if = "Option::is_none")]
    pub r#type: Option<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

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

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

#[derive(Debug, Serialize, Deserialize)]
pub struct CardRecord;
impl XrpcResp for CardRecord {
    const NSID: &'static str = "network.cosmik.card";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = CardGetRecordOutput<S>;
    type Err = RecordError;
}

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

impl<S: BosStr> Collection for Card<S> {
    const NSID: &'static str = "network.cosmik.card";
    type Record = CardRecord;
}

impl Collection for CardRecord {
    const NSID: &'static str = "network.cosmik.card";
    type Record = CardRecord;
}

impl<S: BosStr> LexiconSchema for Card<S> {
    fn nsid() -> &'static str {
        "network.cosmik.card"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_network_cosmik_card()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for NoteContent<S> {
    fn nsid() -> &'static str {
        "network.cosmik.card"
    }
    fn def_name() -> &'static str {
        "noteContent"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_network_cosmik_card()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.text;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 10000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("text"),
                    max: 10000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for UrlContent<S> {
    fn nsid() -> &'static str {
        "network.cosmik.card"
    }
    fn def_name() -> &'static str {
        "urlContent"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_network_cosmik_card()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for UrlMetadata<S> {
    fn nsid() -> &'static str {
        "network.cosmik.card"
    }
    fn def_name() -> &'static str {
        "urlMetadata"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_network_cosmik_card()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

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

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

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

impl<S: BosStr> Card<S> {
    /// Create a new builder for this type
    pub fn builder() -> CardBuilder<card_state::Empty, S> {
        CardBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> CardBuilder<St, S>
where
    St: card_state::State,
    St::Content: card_state::IsUnset,
{
    /// Set the `content` field (required)
    pub fn content(
        mut self,
        value: impl Into<CardContent<S>>,
    ) -> CardBuilder<card_state::SetContent<St>, S> {
        self._fields.0 = Option::Some(value.into());
        CardBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St: card_state::State, S: BosStr> CardBuilder<St, S> {
    /// Set the `originalCard` field (optional)
    pub fn original_card(mut self, value: impl Into<Option<StrongRef<S>>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `originalCard` field to an Option value (optional)
    pub fn maybe_original_card(mut self, value: Option<StrongRef<S>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St: card_state::State, S: BosStr> CardBuilder<St, S> {
    /// Set the `parentCard` field (optional)
    pub fn parent_card(mut self, value: impl Into<Option<StrongRef<S>>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `parentCard` field to an Option value (optional)
    pub fn maybe_parent_card(mut self, value: Option<StrongRef<S>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St: card_state::State, S: BosStr> CardBuilder<St, S> {
    /// Set the `provenance` field (optional)
    pub fn provenance(mut self, value: impl Into<Option<Provenance<S>>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `provenance` field to an Option value (optional)
    pub fn maybe_provenance(mut self, value: Option<Provenance<S>>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<St, S: BosStr> CardBuilder<St, S>
where
    St: card_state::State,
    St::Type: card_state::IsUnset,
{
    /// Set the `type` field (required)
    pub fn r#type(
        mut self,
        value: impl Into<CardType<S>>,
    ) -> CardBuilder<card_state::SetType<St>, S> {
        self._fields.5 = Option::Some(value.into());
        CardBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: card_state::State, S: BosStr> CardBuilder<St, S> {
    /// Set the `url` field (optional)
    pub fn url(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `url` field to an Option value (optional)
    pub fn maybe_url(mut self, value: Option<UriValue<S>>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<St, S: BosStr> CardBuilder<St, S>
where
    St: card_state::State,
    St::Content: card_state::IsSet,
    St::Type: card_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Card<S> {
        Card {
            content: self._fields.0.unwrap(),
            created_at: self._fields.1,
            original_card: self._fields.2,
            parent_card: self._fields.3,
            provenance: self._fields.4,
            r#type: self._fields.5.unwrap(),
            url: self._fields.6,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Card<S> {
        Card {
            content: self._fields.0.unwrap(),
            created_at: self._fields.1,
            original_card: self._fields.2,
            parent_card: self._fields.3,
            provenance: self._fields.4,
            r#type: self._fields.5.unwrap(),
            url: self._fields.6,
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_network_cosmik_card() -> 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("network.cosmik.card"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static("A record representing a card with content."),
                    ),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("type"), SmolStr::new_static("content")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("content"),
                                LexObjectProperty::Union(LexRefUnion {
                                    description: Some(
                                        CowStr::new_static(
                                            "The specific content of the card, determined by the card type.",
                                        ),
                                    ),
                                    refs: vec![
                                        CowStr::new_static("#urlContent"),
                                        CowStr::new_static("#noteContent")
                                    ],
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Timestamp when this card was created (usually set by PDS).",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("originalCard"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("parentCard"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("provenance"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("network.cosmik.defs#provenance"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("type"),
                                LexObjectProperty::String(LexString {
                                    description: Some(CowStr::new_static("The type of card")),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("url"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Optional URL associated with the card. Required for URL cards, optional for NOTE cards.",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Uri),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("noteContent"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Content structure for a note card."),
                    ),
                    required: Some(vec![SmolStr::new_static("text")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("text"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The note text content"),
                                ),
                                max_length: Some(10000usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("urlContent"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Content structure for a URL card."),
                    ),
                    required: Some(vec![SmolStr::new_static("url")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("metadata"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#urlMetadata"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("url"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The URL being saved"),
                                ),
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("urlMetadata"),
                LexUserType::Object(LexObject {
                    description: Some(CowStr::new_static("Metadata about a URL.")),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("author"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Author of the content"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("description"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Description of the page"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("doi"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Digital Object Identifier (DOI) for academic content",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("imageUrl"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("URL of a representative image"),
                                ),
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("isbn"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "International Standard Book Number (ISBN) for books",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("publishedDate"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("When the content was published"),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("retrievedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("When the metadata was retrieved"),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("siteName"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("Name of the site")),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("title"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("Title of the page")),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("type"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Type of content (e.g., 'video', 'article')",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

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

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

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

impl<S: BosStr> UrlContent<S> {
    /// Create a new builder for this type
    pub fn builder() -> UrlContentBuilder<url_content_state::Empty, S> {
        UrlContentBuilder::builder()
    }
}

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

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

impl<St: url_content_state::State, S: BosStr> UrlContentBuilder<St, S> {
    /// Set the `metadata` field (optional)
    pub fn metadata(mut self, value: impl Into<Option<card::UrlMetadata<S>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `metadata` field to an Option value (optional)
    pub fn maybe_metadata(mut self, value: Option<card::UrlMetadata<S>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St, S: BosStr> UrlContentBuilder<St, S>
where
    St: url_content_state::State,
    St::Url: url_content_state::IsUnset,
{
    /// Set the `url` field (required)
    pub fn url(
        mut self,
        value: impl Into<UriValue<S>>,
    ) -> UrlContentBuilder<url_content_state::SetUrl<St>, S> {
        self._fields.1 = Option::Some(value.into());
        UrlContentBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> UrlContentBuilder<St, S>
where
    St: url_content_state::State,
    St::Url: url_content_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> UrlContent<S> {
        UrlContent {
            metadata: self._fields.0,
            url: self._fields.1.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> UrlContent<S> {
        UrlContent {
            metadata: self._fields.0,
            url: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}