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

//! Generated bindings for the `app.bsky.ageassurance` Lexicon namespace/module.
pub mod begin;
pub mod get_config;
pub mod get_state;


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

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

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

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::app_bsky::ageassurance;
/// The access level granted based on Age Assurance data we've processed.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Access<S: BosStr = DefaultStr> {
    Unknown,
    None,
    Safe,
    Full,
    Other(S),
}

impl<S: BosStr> Access<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Unknown => "unknown",
            Self::None => "none",
            Self::Safe => "safe",
            Self::Full => "full",
            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() {
            "unknown" => Self::Unknown,
            "none" => Self::None,
            "safe" => Self::Safe,
            "full" => Self::Full,
            _ => Self::Other(s),
        }
    }
}

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

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

impl<S: BosStr> Serialize for Access<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 Access<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> jacquard_common::IntoStatic for Access<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = Access<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            Access::Unknown => Access::Unknown,
            Access::None => Access::None,
            Access::Safe => Access::Safe,
            Access::Full => Access::Full,
            Access::Other(v) => Access::Other(v.into_static()),
        }
    }
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Config<S: BosStr = DefaultStr> {
    ///The per-region Age Assurance configuration.
    pub regions: Vec<ageassurance::ConfigRegion<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// The Age Assurance configuration for a specific region.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ConfigRegion<S: BosStr = DefaultStr> {
    ///The ISO 3166-1 alpha-2 country code this configuration applies to.
    pub country_code: S,
    ///The minimum age (as a whole integer) required to use Bluesky in this region.
    pub min_access_age: i64,
    ///The ISO 3166-2 region code this configuration applies to. If omitted, the configuration applies to the entire country.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub region_code: Option<S>,
    ///The ordered list of Age Assurance rules that apply to this region. Rules should be applied in order, and the first matching rule determines the access level granted. The rules array should always include a default rule as the last item.
    pub rules: Vec<ConfigRegionRulesItem<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 ConfigRegionRulesItem<S: BosStr = DefaultStr> {
    #[serde(rename = "app.bsky.ageassurance.defs#configRegionRuleDefault")]
    ConfigRegionRuleDefault(Box<ageassurance::ConfigRegionRuleDefault<S>>),
    #[serde(rename = "app.bsky.ageassurance.defs#configRegionRuleIfDeclaredOverAge")]
    ConfigRegionRuleIfDeclaredOverAge(
        Box<ageassurance::ConfigRegionRuleIfDeclaredOverAge<S>>,
    ),
    #[serde(rename = "app.bsky.ageassurance.defs#configRegionRuleIfDeclaredUnderAge")]
    ConfigRegionRuleIfDeclaredUnderAge(
        Box<ageassurance::ConfigRegionRuleIfDeclaredUnderAge<S>>,
    ),
    #[serde(rename = "app.bsky.ageassurance.defs#configRegionRuleIfAssuredOverAge")]
    ConfigRegionRuleIfAssuredOverAge(
        Box<ageassurance::ConfigRegionRuleIfAssuredOverAge<S>>,
    ),
    #[serde(rename = "app.bsky.ageassurance.defs#configRegionRuleIfAssuredUnderAge")]
    ConfigRegionRuleIfAssuredUnderAge(
        Box<ageassurance::ConfigRegionRuleIfAssuredUnderAge<S>>,
    ),
    #[serde(rename = "app.bsky.ageassurance.defs#configRegionRuleIfAccountNewerThan")]
    ConfigRegionRuleIfAccountNewerThan(
        Box<ageassurance::ConfigRegionRuleIfAccountNewerThan<S>>,
    ),
    #[serde(rename = "app.bsky.ageassurance.defs#configRegionRuleIfAccountOlderThan")]
    ConfigRegionRuleIfAccountOlderThan(
        Box<ageassurance::ConfigRegionRuleIfAccountOlderThan<S>>,
    ),
}

/// Age Assurance rule that applies by default.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ConfigRegionRuleDefault<S: BosStr = DefaultStr> {
    pub access: ageassurance::Access<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Age Assurance rule that applies if the account is equal-to or newer than a certain date.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ConfigRegionRuleIfAccountNewerThan<S: BosStr = DefaultStr> {
    pub access: ageassurance::Access<S>,
    ///The date threshold as a datetime string.
    pub date: Datetime,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Age Assurance rule that applies if the account is older than a certain date.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ConfigRegionRuleIfAccountOlderThan<S: BosStr = DefaultStr> {
    pub access: ageassurance::Access<S>,
    ///The date threshold as a datetime string.
    pub date: Datetime,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Age Assurance rule that applies if the user has been assured to be equal-to or over a certain age.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ConfigRegionRuleIfAssuredOverAge<S: BosStr = DefaultStr> {
    pub access: ageassurance::Access<S>,
    ///The age threshold as a whole integer.
    pub age: i64,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Age Assurance rule that applies if the user has been assured to be under a certain age.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ConfigRegionRuleIfAssuredUnderAge<S: BosStr = DefaultStr> {
    pub access: ageassurance::Access<S>,
    ///The age threshold as a whole integer.
    pub age: i64,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Age Assurance rule that applies if the user has declared themselves equal-to or over a certain age.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ConfigRegionRuleIfDeclaredOverAge<S: BosStr = DefaultStr> {
    pub access: ageassurance::Access<S>,
    ///The age threshold as a whole integer.
    pub age: i64,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Age Assurance rule that applies if the user has declared themselves under a certain age.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ConfigRegionRuleIfDeclaredUnderAge<S: BosStr = DefaultStr> {
    pub access: ageassurance::Access<S>,
    ///The age threshold as a whole integer.
    pub age: i64,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Object used to store Age Assurance data in stash.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Event<S: BosStr = DefaultStr> {
    ///The access level granted based on Age Assurance data we've processed.
    pub access: EventAccess<S>,
    ///The unique identifier for this instance of the Age Assurance flow, in UUID format.
    pub attempt_id: S,
    ///The IP address used when completing the Age Assurance flow.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub complete_ip: Option<S>,
    ///The user agent used when completing the Age Assurance flow.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub complete_ua: Option<S>,
    ///The ISO 3166-1 alpha-2 country code provided when beginning the Age Assurance flow.
    pub country_code: S,
    ///The date and time of this write operation.
    pub created_at: Datetime,
    ///The email used for Age Assurance.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub email: Option<S>,
    ///The IP address used when initiating the Age Assurance flow.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub init_ip: Option<S>,
    ///The user agent used when initiating the Age Assurance flow.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub init_ua: Option<S>,
    ///The ISO 3166-2 region code provided when beginning the Age Assurance flow.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub region_code: Option<S>,
    ///The status of the Age Assurance process.
    pub status: EventStatus<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// The access level granted based on Age Assurance data we've processed.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum EventAccess<S: BosStr = DefaultStr> {
    Unknown,
    None,
    Safe,
    Full,
    Other(S),
}

impl<S: BosStr> EventAccess<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Unknown => "unknown",
            Self::None => "none",
            Self::Safe => "safe",
            Self::Full => "full",
            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() {
            "unknown" => Self::Unknown,
            "none" => Self::None,
            "safe" => Self::Safe,
            "full" => Self::Full,
            _ => Self::Other(s),
        }
    }
}

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

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

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

impl<S: BosStr> jacquard_common::IntoStatic for EventAccess<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = EventAccess<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            EventAccess::Unknown => EventAccess::Unknown,
            EventAccess::None => EventAccess::None,
            EventAccess::Safe => EventAccess::Safe,
            EventAccess::Full => EventAccess::Full,
            EventAccess::Other(v) => EventAccess::Other(v.into_static()),
        }
    }
}

/// The status of the Age Assurance process.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum EventStatus<S: BosStr = DefaultStr> {
    Unknown,
    Pending,
    Assured,
    Blocked,
    Other(S),
}

impl<S: BosStr> EventStatus<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Unknown => "unknown",
            Self::Pending => "pending",
            Self::Assured => "assured",
            Self::Blocked => "blocked",
            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() {
            "unknown" => Self::Unknown,
            "pending" => Self::Pending,
            "assured" => Self::Assured,
            "blocked" => Self::Blocked,
            _ => Self::Other(s),
        }
    }
}

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

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

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

impl<S: BosStr> jacquard_common::IntoStatic for EventStatus<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = EventStatus<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            EventStatus::Unknown => EventStatus::Unknown,
            EventStatus::Pending => EventStatus::Pending,
            EventStatus::Assured => EventStatus::Assured,
            EventStatus::Blocked => EventStatus::Blocked,
            EventStatus::Other(v) => EventStatus::Other(v.into_static()),
        }
    }
}

/// The user's computed Age Assurance state.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct State<S: BosStr = DefaultStr> {
    pub access: ageassurance::Access<S>,
    ///The timestamp when this state was last updated.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub last_initiated_at: Option<Datetime>,
    pub status: ageassurance::Status<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Additional metadata needed to compute Age Assurance state client-side.

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

/// The status of the Age Assurance process.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Status<S: BosStr = DefaultStr> {
    Unknown,
    Pending,
    Assured,
    Blocked,
    Other(S),
}

impl<S: BosStr> Status<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Unknown => "unknown",
            Self::Pending => "pending",
            Self::Assured => "assured",
            Self::Blocked => "blocked",
            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() {
            "unknown" => Self::Unknown,
            "pending" => Self::Pending,
            "assured" => Self::Assured,
            "blocked" => Self::Blocked,
            _ => Self::Other(s),
        }
    }
}

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

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

impl<S: BosStr> Serialize for Status<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 Status<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> jacquard_common::IntoStatic for Status<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = Status<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            Status::Unknown => Status::Unknown,
            Status::Pending => Status::Pending,
            Status::Assured => Status::Assured,
            Status::Blocked => Status::Blocked,
            Status::Other(v) => Status::Other(v.into_static()),
        }
    }
}

impl<S: BosStr> LexiconSchema for Config<S> {
    fn nsid() -> &'static str {
        "app.bsky.ageassurance.defs"
    }
    fn def_name() -> &'static str {
        "config"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_ageassurance_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ConfigRegion<S> {
    fn nsid() -> &'static str {
        "app.bsky.ageassurance.defs"
    }
    fn def_name() -> &'static str {
        "configRegion"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_ageassurance_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ConfigRegionRuleDefault<S> {
    fn nsid() -> &'static str {
        "app.bsky.ageassurance.defs"
    }
    fn def_name() -> &'static str {
        "configRegionRuleDefault"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_ageassurance_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ConfigRegionRuleIfAccountNewerThan<S> {
    fn nsid() -> &'static str {
        "app.bsky.ageassurance.defs"
    }
    fn def_name() -> &'static str {
        "configRegionRuleIfAccountNewerThan"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_ageassurance_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ConfigRegionRuleIfAccountOlderThan<S> {
    fn nsid() -> &'static str {
        "app.bsky.ageassurance.defs"
    }
    fn def_name() -> &'static str {
        "configRegionRuleIfAccountOlderThan"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_ageassurance_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ConfigRegionRuleIfAssuredOverAge<S> {
    fn nsid() -> &'static str {
        "app.bsky.ageassurance.defs"
    }
    fn def_name() -> &'static str {
        "configRegionRuleIfAssuredOverAge"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_ageassurance_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ConfigRegionRuleIfAssuredUnderAge<S> {
    fn nsid() -> &'static str {
        "app.bsky.ageassurance.defs"
    }
    fn def_name() -> &'static str {
        "configRegionRuleIfAssuredUnderAge"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_ageassurance_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ConfigRegionRuleIfDeclaredOverAge<S> {
    fn nsid() -> &'static str {
        "app.bsky.ageassurance.defs"
    }
    fn def_name() -> &'static str {
        "configRegionRuleIfDeclaredOverAge"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_ageassurance_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ConfigRegionRuleIfDeclaredUnderAge<S> {
    fn nsid() -> &'static str {
        "app.bsky.ageassurance.defs"
    }
    fn def_name() -> &'static str {
        "configRegionRuleIfDeclaredUnderAge"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_ageassurance_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for Event<S> {
    fn nsid() -> &'static str {
        "app.bsky.ageassurance.defs"
    }
    fn def_name() -> &'static str {
        "event"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_ageassurance_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for State<S> {
    fn nsid() -> &'static str {
        "app.bsky.ageassurance.defs"
    }
    fn def_name() -> &'static str {
        "state"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_ageassurance_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for StateMetadata<S> {
    fn nsid() -> &'static str {
        "app.bsky.ageassurance.defs"
    }
    fn def_name() -> &'static str {
        "stateMetadata"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_ageassurance_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

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

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

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

impl<S: BosStr> Config<S> {
    /// Create a new builder for this type
    pub fn builder() -> ConfigBuilder<config_state::Empty, S> {
        ConfigBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> ConfigBuilder<St, S>
where
    St: config_state::State,
    St::Regions: config_state::IsUnset,
{
    /// Set the `regions` field (required)
    pub fn regions(
        mut self,
        value: impl Into<Vec<ageassurance::ConfigRegion<S>>>,
    ) -> ConfigBuilder<config_state::SetRegions<St>, S> {
        self._fields.0 = Option::Some(value.into());
        ConfigBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ConfigBuilder<St, S>
where
    St: config_state::State,
    St::Regions: config_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Config<S> {
        Config {
            regions: self._fields.0.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>>) -> Config<S> {
        Config {
            regions: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_app_bsky_ageassurance_defs() -> LexiconDoc<'static> {
    #[allow(unused_imports)]
    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
    use jacquard_lexicon::lexicon::*;
    use alloc::collections::BTreeMap;
    LexiconDoc {
        lexicon: Lexicon::Lexicon1,
        id: CowStr::new_static("app.bsky.ageassurance.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("access"),
                LexUserType::String(LexString {
                    description: Some(
                        CowStr::new_static(
                            "The access level granted based on Age Assurance data we've processed.",
                        ),
                    ),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("config"),
                LexUserType::Object(LexObject {
                    description: Some(CowStr::new_static("")),
                    required: Some(vec![SmolStr::new_static("regions")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("regions"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "The per-region Age Assurance configuration.",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static(
                                        "app.bsky.ageassurance.defs#configRegion",
                                    ),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("configRegion"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "The Age Assurance configuration for a specific region.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("countryCode"),
                            SmolStr::new_static("minAccessAge"),
                            SmolStr::new_static("rules")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("countryCode"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The ISO 3166-1 alpha-2 country code this configuration applies to.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("minAccessAge"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("regionCode"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The ISO 3166-2 region code this configuration applies to. If omitted, the configuration applies to the entire country.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("rules"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "The ordered list of Age Assurance rules that apply to this region. Rules should be applied in order, and the first matching rule determines the access level granted. The rules array should always include a default rule as the last item.",
                                    ),
                                ),
                                items: LexArrayItem::Union(LexRefUnion {
                                    refs: vec![
                                        CowStr::new_static("#configRegionRuleDefault"),
                                        CowStr::new_static("#configRegionRuleIfDeclaredOverAge"),
                                        CowStr::new_static("#configRegionRuleIfDeclaredUnderAge"),
                                        CowStr::new_static("#configRegionRuleIfAssuredOverAge"),
                                        CowStr::new_static("#configRegionRuleIfAssuredUnderAge"),
                                        CowStr::new_static("#configRegionRuleIfAccountNewerThan"),
                                        CowStr::new_static("#configRegionRuleIfAccountOlderThan")
                                    ],
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("configRegionRuleDefault"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Age Assurance rule that applies by default."),
                    ),
                    required: Some(vec![SmolStr::new_static("access")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("access"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "app.bsky.ageassurance.defs#access",
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("configRegionRuleIfAccountNewerThan"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Age Assurance rule that applies if the account is equal-to or newer than a certain date.",
                        ),
                    ),
                    required: Some(
                        vec![SmolStr::new_static("date"), SmolStr::new_static("access")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("access"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "app.bsky.ageassurance.defs#access",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("date"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The date threshold as a datetime string.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("configRegionRuleIfAccountOlderThan"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Age Assurance rule that applies if the account is older than a certain date.",
                        ),
                    ),
                    required: Some(
                        vec![SmolStr::new_static("date"), SmolStr::new_static("access")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("access"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "app.bsky.ageassurance.defs#access",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("date"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The date threshold as a datetime string.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("configRegionRuleIfAssuredOverAge"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Age Assurance rule that applies if the user has been assured to be equal-to or over a certain age.",
                        ),
                    ),
                    required: Some(
                        vec![SmolStr::new_static("age"), SmolStr::new_static("access")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("access"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "app.bsky.ageassurance.defs#access",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("age"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("configRegionRuleIfAssuredUnderAge"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Age Assurance rule that applies if the user has been assured to be under a certain age.",
                        ),
                    ),
                    required: Some(
                        vec![SmolStr::new_static("age"), SmolStr::new_static("access")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("access"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "app.bsky.ageassurance.defs#access",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("age"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("configRegionRuleIfDeclaredOverAge"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Age Assurance rule that applies if the user has declared themselves equal-to or over a certain age.",
                        ),
                    ),
                    required: Some(
                        vec![SmolStr::new_static("age"), SmolStr::new_static("access")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("access"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "app.bsky.ageassurance.defs#access",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("age"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("configRegionRuleIfDeclaredUnderAge"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Age Assurance rule that applies if the user has declared themselves under a certain age.",
                        ),
                    ),
                    required: Some(
                        vec![SmolStr::new_static("age"), SmolStr::new_static("access")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("access"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "app.bsky.ageassurance.defs#access",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("age"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("event"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Object used to store Age Assurance data in stash.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("createdAt"),
                            SmolStr::new_static("status"), SmolStr::new_static("access"),
                            SmolStr::new_static("attemptId"),
                            SmolStr::new_static("countryCode")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("access"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The access level granted based on Age Assurance data we've processed.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("attemptId"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The unique identifier for this instance of the Age Assurance flow, in UUID format.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("completeIp"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The IP address used when completing the Age Assurance flow.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("completeUa"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The user agent used when completing the Age Assurance flow.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("countryCode"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The ISO 3166-1 alpha-2 country code provided when beginning the Age Assurance flow.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The date and time of this write operation.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("email"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The email used for Age Assurance."),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("initIp"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The IP address used when initiating the Age Assurance flow.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("initUa"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The user agent used when initiating the Age Assurance flow.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("regionCode"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The ISO 3166-2 region code provided when beginning the Age Assurance flow.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("status"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The status of the Age Assurance process.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("state"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("The user's computed Age Assurance state."),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("status"), SmolStr::new_static("access")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("access"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "app.bsky.ageassurance.defs#access",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("lastInitiatedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The timestamp when this state was last updated.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("status"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "app.bsky.ageassurance.defs#status",
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("stateMetadata"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Additional metadata needed to compute Age Assurance state client-side.",
                        ),
                    ),
                    required: Some(vec![]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("accountCreatedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The account creation timestamp."),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("status"),
                LexUserType::String(LexString {
                    description: Some(
                        CowStr::new_static("The status of the Age Assurance process."),
                    ),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod config_region_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 CountryCode;
        type MinAccessAge;
        type Rules;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type CountryCode = Unset;
        type MinAccessAge = Unset;
        type Rules = Unset;
    }
    ///State transition - sets the `country_code` field to Set
    pub struct SetCountryCode<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCountryCode<St> {}
    impl<St: State> State for SetCountryCode<St> {
        type CountryCode = Set<members::country_code>;
        type MinAccessAge = St::MinAccessAge;
        type Rules = St::Rules;
    }
    ///State transition - sets the `min_access_age` field to Set
    pub struct SetMinAccessAge<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetMinAccessAge<St> {}
    impl<St: State> State for SetMinAccessAge<St> {
        type CountryCode = St::CountryCode;
        type MinAccessAge = Set<members::min_access_age>;
        type Rules = St::Rules;
    }
    ///State transition - sets the `rules` field to Set
    pub struct SetRules<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRules<St> {}
    impl<St: State> State for SetRules<St> {
        type CountryCode = St::CountryCode;
        type MinAccessAge = St::MinAccessAge;
        type Rules = Set<members::rules>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `country_code` field
        pub struct country_code(());
        ///Marker type for the `min_access_age` field
        pub struct min_access_age(());
        ///Marker type for the `rules` field
        pub struct rules(());
    }
}

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

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

impl<S: BosStr> ConfigRegion<S> {
    /// Create a new builder for this type
    pub fn builder() -> ConfigRegionBuilder<config_region_state::Empty, S> {
        ConfigRegionBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> ConfigRegionBuilder<St, S>
where
    St: config_region_state::State,
    St::CountryCode: config_region_state::IsUnset,
{
    /// Set the `countryCode` field (required)
    pub fn country_code(
        mut self,
        value: impl Into<S>,
    ) -> ConfigRegionBuilder<config_region_state::SetCountryCode<St>, S> {
        self._fields.0 = Option::Some(value.into());
        ConfigRegionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ConfigRegionBuilder<St, S>
where
    St: config_region_state::State,
    St::MinAccessAge: config_region_state::IsUnset,
{
    /// Set the `minAccessAge` field (required)
    pub fn min_access_age(
        mut self,
        value: impl Into<i64>,
    ) -> ConfigRegionBuilder<config_region_state::SetMinAccessAge<St>, S> {
        self._fields.1 = Option::Some(value.into());
        ConfigRegionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: config_region_state::State, S: BosStr> ConfigRegionBuilder<St, S> {
    /// Set the `regionCode` field (optional)
    pub fn region_code(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `regionCode` field to an Option value (optional)
    pub fn maybe_region_code(mut self, value: Option<S>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St, S: BosStr> ConfigRegionBuilder<St, S>
where
    St: config_region_state::State,
    St::Rules: config_region_state::IsUnset,
{
    /// Set the `rules` field (required)
    pub fn rules(
        mut self,
        value: impl Into<Vec<ConfigRegionRulesItem<S>>>,
    ) -> ConfigRegionBuilder<config_region_state::SetRules<St>, S> {
        self._fields.3 = Option::Some(value.into());
        ConfigRegionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ConfigRegionBuilder<St, S>
where
    St: config_region_state::State,
    St::CountryCode: config_region_state::IsSet,
    St::MinAccessAge: config_region_state::IsSet,
    St::Rules: config_region_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ConfigRegion<S> {
        ConfigRegion {
            country_code: self._fields.0.unwrap(),
            min_access_age: self._fields.1.unwrap(),
            region_code: self._fields.2,
            rules: self._fields.3.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> ConfigRegion<S> {
        ConfigRegion {
            country_code: self._fields.0.unwrap(),
            min_access_age: self._fields.1.unwrap(),
            region_code: self._fields.2,
            rules: self._fields.3.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

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

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

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

impl<S: BosStr> ConfigRegionRuleDefault<S> {
    /// Create a new builder for this type
    pub fn builder() -> ConfigRegionRuleDefaultBuilder<
        config_region_rule_default_state::Empty,
        S,
    > {
        ConfigRegionRuleDefaultBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> ConfigRegionRuleDefaultBuilder<St, S>
where
    St: config_region_rule_default_state::State,
    St::Access: config_region_rule_default_state::IsUnset,
{
    /// Set the `access` field (required)
    pub fn access(
        mut self,
        value: impl Into<ageassurance::Access<S>>,
    ) -> ConfigRegionRuleDefaultBuilder<
        config_region_rule_default_state::SetAccess<St>,
        S,
    > {
        self._fields.0 = Option::Some(value.into());
        ConfigRegionRuleDefaultBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ConfigRegionRuleDefaultBuilder<St, S>
where
    St: config_region_rule_default_state::State,
    St::Access: config_region_rule_default_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ConfigRegionRuleDefault<S> {
        ConfigRegionRuleDefault {
            access: self._fields.0.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>>,
    ) -> ConfigRegionRuleDefault<S> {
        ConfigRegionRuleDefault {
            access: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

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

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

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

impl<S: BosStr> ConfigRegionRuleIfAccountNewerThan<S> {
    /// Create a new builder for this type
    pub fn builder() -> ConfigRegionRuleIfAccountNewerThanBuilder<
        config_region_rule_if_account_newer_than_state::Empty,
        S,
    > {
        ConfigRegionRuleIfAccountNewerThanBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> ConfigRegionRuleIfAccountNewerThanBuilder<St, S>
where
    St: config_region_rule_if_account_newer_than_state::State,
    St::Access: config_region_rule_if_account_newer_than_state::IsUnset,
{
    /// Set the `access` field (required)
    pub fn access(
        mut self,
        value: impl Into<ageassurance::Access<S>>,
    ) -> ConfigRegionRuleIfAccountNewerThanBuilder<
        config_region_rule_if_account_newer_than_state::SetAccess<St>,
        S,
    > {
        self._fields.0 = Option::Some(value.into());
        ConfigRegionRuleIfAccountNewerThanBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ConfigRegionRuleIfAccountNewerThanBuilder<St, S>
where
    St: config_region_rule_if_account_newer_than_state::State,
    St::Date: config_region_rule_if_account_newer_than_state::IsUnset,
{
    /// Set the `date` field (required)
    pub fn date(
        mut self,
        value: impl Into<Datetime>,
    ) -> ConfigRegionRuleIfAccountNewerThanBuilder<
        config_region_rule_if_account_newer_than_state::SetDate<St>,
        S,
    > {
        self._fields.1 = Option::Some(value.into());
        ConfigRegionRuleIfAccountNewerThanBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ConfigRegionRuleIfAccountNewerThanBuilder<St, S>
where
    St: config_region_rule_if_account_newer_than_state::State,
    St::Access: config_region_rule_if_account_newer_than_state::IsSet,
    St::Date: config_region_rule_if_account_newer_than_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ConfigRegionRuleIfAccountNewerThan<S> {
        ConfigRegionRuleIfAccountNewerThan {
            access: self._fields.0.unwrap(),
            date: 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>>,
    ) -> ConfigRegionRuleIfAccountNewerThan<S> {
        ConfigRegionRuleIfAccountNewerThan {
            access: self._fields.0.unwrap(),
            date: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

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

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

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

impl<S: BosStr> ConfigRegionRuleIfAccountOlderThan<S> {
    /// Create a new builder for this type
    pub fn builder() -> ConfigRegionRuleIfAccountOlderThanBuilder<
        config_region_rule_if_account_older_than_state::Empty,
        S,
    > {
        ConfigRegionRuleIfAccountOlderThanBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> ConfigRegionRuleIfAccountOlderThanBuilder<St, S>
where
    St: config_region_rule_if_account_older_than_state::State,
    St::Access: config_region_rule_if_account_older_than_state::IsUnset,
{
    /// Set the `access` field (required)
    pub fn access(
        mut self,
        value: impl Into<ageassurance::Access<S>>,
    ) -> ConfigRegionRuleIfAccountOlderThanBuilder<
        config_region_rule_if_account_older_than_state::SetAccess<St>,
        S,
    > {
        self._fields.0 = Option::Some(value.into());
        ConfigRegionRuleIfAccountOlderThanBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ConfigRegionRuleIfAccountOlderThanBuilder<St, S>
where
    St: config_region_rule_if_account_older_than_state::State,
    St::Date: config_region_rule_if_account_older_than_state::IsUnset,
{
    /// Set the `date` field (required)
    pub fn date(
        mut self,
        value: impl Into<Datetime>,
    ) -> ConfigRegionRuleIfAccountOlderThanBuilder<
        config_region_rule_if_account_older_than_state::SetDate<St>,
        S,
    > {
        self._fields.1 = Option::Some(value.into());
        ConfigRegionRuleIfAccountOlderThanBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ConfigRegionRuleIfAccountOlderThanBuilder<St, S>
where
    St: config_region_rule_if_account_older_than_state::State,
    St::Access: config_region_rule_if_account_older_than_state::IsSet,
    St::Date: config_region_rule_if_account_older_than_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ConfigRegionRuleIfAccountOlderThan<S> {
        ConfigRegionRuleIfAccountOlderThan {
            access: self._fields.0.unwrap(),
            date: 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>>,
    ) -> ConfigRegionRuleIfAccountOlderThan<S> {
        ConfigRegionRuleIfAccountOlderThan {
            access: self._fields.0.unwrap(),
            date: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

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

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

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

impl<S: BosStr> ConfigRegionRuleIfAssuredOverAge<S> {
    /// Create a new builder for this type
    pub fn builder() -> ConfigRegionRuleIfAssuredOverAgeBuilder<
        config_region_rule_if_assured_over_age_state::Empty,
        S,
    > {
        ConfigRegionRuleIfAssuredOverAgeBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> ConfigRegionRuleIfAssuredOverAgeBuilder<St, S>
where
    St: config_region_rule_if_assured_over_age_state::State,
    St::Access: config_region_rule_if_assured_over_age_state::IsUnset,
{
    /// Set the `access` field (required)
    pub fn access(
        mut self,
        value: impl Into<ageassurance::Access<S>>,
    ) -> ConfigRegionRuleIfAssuredOverAgeBuilder<
        config_region_rule_if_assured_over_age_state::SetAccess<St>,
        S,
    > {
        self._fields.0 = Option::Some(value.into());
        ConfigRegionRuleIfAssuredOverAgeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ConfigRegionRuleIfAssuredOverAgeBuilder<St, S>
where
    St: config_region_rule_if_assured_over_age_state::State,
    St::Age: config_region_rule_if_assured_over_age_state::IsUnset,
{
    /// Set the `age` field (required)
    pub fn age(
        mut self,
        value: impl Into<i64>,
    ) -> ConfigRegionRuleIfAssuredOverAgeBuilder<
        config_region_rule_if_assured_over_age_state::SetAge<St>,
        S,
    > {
        self._fields.1 = Option::Some(value.into());
        ConfigRegionRuleIfAssuredOverAgeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ConfigRegionRuleIfAssuredOverAgeBuilder<St, S>
where
    St: config_region_rule_if_assured_over_age_state::State,
    St::Access: config_region_rule_if_assured_over_age_state::IsSet,
    St::Age: config_region_rule_if_assured_over_age_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ConfigRegionRuleIfAssuredOverAge<S> {
        ConfigRegionRuleIfAssuredOverAge {
            access: self._fields.0.unwrap(),
            age: 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>>,
    ) -> ConfigRegionRuleIfAssuredOverAge<S> {
        ConfigRegionRuleIfAssuredOverAge {
            access: self._fields.0.unwrap(),
            age: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

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

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

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

impl<S: BosStr> ConfigRegionRuleIfAssuredUnderAge<S> {
    /// Create a new builder for this type
    pub fn builder() -> ConfigRegionRuleIfAssuredUnderAgeBuilder<
        config_region_rule_if_assured_under_age_state::Empty,
        S,
    > {
        ConfigRegionRuleIfAssuredUnderAgeBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> ConfigRegionRuleIfAssuredUnderAgeBuilder<St, S>
where
    St: config_region_rule_if_assured_under_age_state::State,
    St::Access: config_region_rule_if_assured_under_age_state::IsUnset,
{
    /// Set the `access` field (required)
    pub fn access(
        mut self,
        value: impl Into<ageassurance::Access<S>>,
    ) -> ConfigRegionRuleIfAssuredUnderAgeBuilder<
        config_region_rule_if_assured_under_age_state::SetAccess<St>,
        S,
    > {
        self._fields.0 = Option::Some(value.into());
        ConfigRegionRuleIfAssuredUnderAgeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ConfigRegionRuleIfAssuredUnderAgeBuilder<St, S>
where
    St: config_region_rule_if_assured_under_age_state::State,
    St::Age: config_region_rule_if_assured_under_age_state::IsUnset,
{
    /// Set the `age` field (required)
    pub fn age(
        mut self,
        value: impl Into<i64>,
    ) -> ConfigRegionRuleIfAssuredUnderAgeBuilder<
        config_region_rule_if_assured_under_age_state::SetAge<St>,
        S,
    > {
        self._fields.1 = Option::Some(value.into());
        ConfigRegionRuleIfAssuredUnderAgeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ConfigRegionRuleIfAssuredUnderAgeBuilder<St, S>
where
    St: config_region_rule_if_assured_under_age_state::State,
    St::Access: config_region_rule_if_assured_under_age_state::IsSet,
    St::Age: config_region_rule_if_assured_under_age_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ConfigRegionRuleIfAssuredUnderAge<S> {
        ConfigRegionRuleIfAssuredUnderAge {
            access: self._fields.0.unwrap(),
            age: 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>>,
    ) -> ConfigRegionRuleIfAssuredUnderAge<S> {
        ConfigRegionRuleIfAssuredUnderAge {
            access: self._fields.0.unwrap(),
            age: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

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

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

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

impl<S: BosStr> ConfigRegionRuleIfDeclaredOverAge<S> {
    /// Create a new builder for this type
    pub fn builder() -> ConfigRegionRuleIfDeclaredOverAgeBuilder<
        config_region_rule_if_declared_over_age_state::Empty,
        S,
    > {
        ConfigRegionRuleIfDeclaredOverAgeBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> ConfigRegionRuleIfDeclaredOverAgeBuilder<St, S>
where
    St: config_region_rule_if_declared_over_age_state::State,
    St::Access: config_region_rule_if_declared_over_age_state::IsUnset,
{
    /// Set the `access` field (required)
    pub fn access(
        mut self,
        value: impl Into<ageassurance::Access<S>>,
    ) -> ConfigRegionRuleIfDeclaredOverAgeBuilder<
        config_region_rule_if_declared_over_age_state::SetAccess<St>,
        S,
    > {
        self._fields.0 = Option::Some(value.into());
        ConfigRegionRuleIfDeclaredOverAgeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ConfigRegionRuleIfDeclaredOverAgeBuilder<St, S>
where
    St: config_region_rule_if_declared_over_age_state::State,
    St::Age: config_region_rule_if_declared_over_age_state::IsUnset,
{
    /// Set the `age` field (required)
    pub fn age(
        mut self,
        value: impl Into<i64>,
    ) -> ConfigRegionRuleIfDeclaredOverAgeBuilder<
        config_region_rule_if_declared_over_age_state::SetAge<St>,
        S,
    > {
        self._fields.1 = Option::Some(value.into());
        ConfigRegionRuleIfDeclaredOverAgeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ConfigRegionRuleIfDeclaredOverAgeBuilder<St, S>
where
    St: config_region_rule_if_declared_over_age_state::State,
    St::Access: config_region_rule_if_declared_over_age_state::IsSet,
    St::Age: config_region_rule_if_declared_over_age_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ConfigRegionRuleIfDeclaredOverAge<S> {
        ConfigRegionRuleIfDeclaredOverAge {
            access: self._fields.0.unwrap(),
            age: 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>>,
    ) -> ConfigRegionRuleIfDeclaredOverAge<S> {
        ConfigRegionRuleIfDeclaredOverAge {
            access: self._fields.0.unwrap(),
            age: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

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

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

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

impl<S: BosStr> ConfigRegionRuleIfDeclaredUnderAge<S> {
    /// Create a new builder for this type
    pub fn builder() -> ConfigRegionRuleIfDeclaredUnderAgeBuilder<
        config_region_rule_if_declared_under_age_state::Empty,
        S,
    > {
        ConfigRegionRuleIfDeclaredUnderAgeBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> ConfigRegionRuleIfDeclaredUnderAgeBuilder<St, S>
where
    St: config_region_rule_if_declared_under_age_state::State,
    St::Access: config_region_rule_if_declared_under_age_state::IsUnset,
{
    /// Set the `access` field (required)
    pub fn access(
        mut self,
        value: impl Into<ageassurance::Access<S>>,
    ) -> ConfigRegionRuleIfDeclaredUnderAgeBuilder<
        config_region_rule_if_declared_under_age_state::SetAccess<St>,
        S,
    > {
        self._fields.0 = Option::Some(value.into());
        ConfigRegionRuleIfDeclaredUnderAgeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ConfigRegionRuleIfDeclaredUnderAgeBuilder<St, S>
where
    St: config_region_rule_if_declared_under_age_state::State,
    St::Age: config_region_rule_if_declared_under_age_state::IsUnset,
{
    /// Set the `age` field (required)
    pub fn age(
        mut self,
        value: impl Into<i64>,
    ) -> ConfigRegionRuleIfDeclaredUnderAgeBuilder<
        config_region_rule_if_declared_under_age_state::SetAge<St>,
        S,
    > {
        self._fields.1 = Option::Some(value.into());
        ConfigRegionRuleIfDeclaredUnderAgeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ConfigRegionRuleIfDeclaredUnderAgeBuilder<St, S>
where
    St: config_region_rule_if_declared_under_age_state::State,
    St::Access: config_region_rule_if_declared_under_age_state::IsSet,
    St::Age: config_region_rule_if_declared_under_age_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ConfigRegionRuleIfDeclaredUnderAge<S> {
        ConfigRegionRuleIfDeclaredUnderAge {
            access: self._fields.0.unwrap(),
            age: 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>>,
    ) -> ConfigRegionRuleIfDeclaredUnderAge<S> {
        ConfigRegionRuleIfDeclaredUnderAge {
            access: self._fields.0.unwrap(),
            age: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod event_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 Access;
        type AttemptId;
        type CountryCode;
        type CreatedAt;
        type Status;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Access = Unset;
        type AttemptId = Unset;
        type CountryCode = Unset;
        type CreatedAt = Unset;
        type Status = Unset;
    }
    ///State transition - sets the `access` field to Set
    pub struct SetAccess<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetAccess<St> {}
    impl<St: State> State for SetAccess<St> {
        type Access = Set<members::access>;
        type AttemptId = St::AttemptId;
        type CountryCode = St::CountryCode;
        type CreatedAt = St::CreatedAt;
        type Status = St::Status;
    }
    ///State transition - sets the `attempt_id` field to Set
    pub struct SetAttemptId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetAttemptId<St> {}
    impl<St: State> State for SetAttemptId<St> {
        type Access = St::Access;
        type AttemptId = Set<members::attempt_id>;
        type CountryCode = St::CountryCode;
        type CreatedAt = St::CreatedAt;
        type Status = St::Status;
    }
    ///State transition - sets the `country_code` field to Set
    pub struct SetCountryCode<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCountryCode<St> {}
    impl<St: State> State for SetCountryCode<St> {
        type Access = St::Access;
        type AttemptId = St::AttemptId;
        type CountryCode = Set<members::country_code>;
        type CreatedAt = St::CreatedAt;
        type Status = St::Status;
    }
    ///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 Access = St::Access;
        type AttemptId = St::AttemptId;
        type CountryCode = St::CountryCode;
        type CreatedAt = Set<members::created_at>;
        type Status = St::Status;
    }
    ///State transition - sets the `status` field to Set
    pub struct SetStatus<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetStatus<St> {}
    impl<St: State> State for SetStatus<St> {
        type Access = St::Access;
        type AttemptId = St::AttemptId;
        type CountryCode = St::CountryCode;
        type CreatedAt = St::CreatedAt;
        type Status = Set<members::status>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `access` field
        pub struct access(());
        ///Marker type for the `attempt_id` field
        pub struct attempt_id(());
        ///Marker type for the `country_code` field
        pub struct country_code(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `status` field
        pub struct status(());
    }
}

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

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

impl<S: BosStr> Event<S> {
    /// Create a new builder for this type
    pub fn builder() -> EventBuilder<event_state::Empty, S> {
        EventBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> EventBuilder<St, S>
where
    St: event_state::State,
    St::Access: event_state::IsUnset,
{
    /// Set the `access` field (required)
    pub fn access(
        mut self,
        value: impl Into<EventAccess<S>>,
    ) -> EventBuilder<event_state::SetAccess<St>, S> {
        self._fields.0 = Option::Some(value.into());
        EventBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventBuilder<St, S>
where
    St: event_state::State,
    St::AttemptId: event_state::IsUnset,
{
    /// Set the `attemptId` field (required)
    pub fn attempt_id(
        mut self,
        value: impl Into<S>,
    ) -> EventBuilder<event_state::SetAttemptId<St>, S> {
        self._fields.1 = Option::Some(value.into());
        EventBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: event_state::State, S: BosStr> EventBuilder<St, S> {
    /// Set the `completeIp` field (optional)
    pub fn complete_ip(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `completeIp` field to an Option value (optional)
    pub fn maybe_complete_ip(mut self, value: Option<S>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St: event_state::State, S: BosStr> EventBuilder<St, S> {
    /// Set the `completeUa` field (optional)
    pub fn complete_ua(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `completeUa` field to an Option value (optional)
    pub fn maybe_complete_ua(mut self, value: Option<S>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St, S: BosStr> EventBuilder<St, S>
where
    St: event_state::State,
    St::CountryCode: event_state::IsUnset,
{
    /// Set the `countryCode` field (required)
    pub fn country_code(
        mut self,
        value: impl Into<S>,
    ) -> EventBuilder<event_state::SetCountryCode<St>, S> {
        self._fields.4 = Option::Some(value.into());
        EventBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

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

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

impl<St: event_state::State, S: BosStr> EventBuilder<St, S> {
    /// Set the `initUa` field (optional)
    pub fn init_ua(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `initUa` field to an Option value (optional)
    pub fn maybe_init_ua(mut self, value: Option<S>) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<St: event_state::State, S: BosStr> EventBuilder<St, S> {
    /// Set the `regionCode` field (optional)
    pub fn region_code(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `regionCode` field to an Option value (optional)
    pub fn maybe_region_code(mut self, value: Option<S>) -> Self {
        self._fields.9 = value;
        self
    }
}

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

impl<St, S: BosStr> EventBuilder<St, S>
where
    St: event_state::State,
    St::Access: event_state::IsSet,
    St::AttemptId: event_state::IsSet,
    St::CountryCode: event_state::IsSet,
    St::CreatedAt: event_state::IsSet,
    St::Status: event_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Event<S> {
        Event {
            access: self._fields.0.unwrap(),
            attempt_id: self._fields.1.unwrap(),
            complete_ip: self._fields.2,
            complete_ua: self._fields.3,
            country_code: self._fields.4.unwrap(),
            created_at: self._fields.5.unwrap(),
            email: self._fields.6,
            init_ip: self._fields.7,
            init_ua: self._fields.8,
            region_code: self._fields.9,
            status: self._fields.10.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Event<S> {
        Event {
            access: self._fields.0.unwrap(),
            attempt_id: self._fields.1.unwrap(),
            complete_ip: self._fields.2,
            complete_ua: self._fields.3,
            country_code: self._fields.4.unwrap(),
            created_at: self._fields.5.unwrap(),
            email: self._fields.6,
            init_ip: self._fields.7,
            init_ua: self._fields.8,
            region_code: self._fields.9,
            status: self._fields.10.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

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

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

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

impl<S: BosStr> State<S> {
    /// Create a new builder for this type
    pub fn builder() -> StateBuilder<state_state::Empty, S> {
        StateBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> StateBuilder<St, S>
where
    St: state_state::State,
    St::Access: state_state::IsUnset,
{
    /// Set the `access` field (required)
    pub fn access(
        mut self,
        value: impl Into<ageassurance::Access<S>>,
    ) -> StateBuilder<state_state::SetAccess<St>, S> {
        self._fields.0 = Option::Some(value.into());
        StateBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: state_state::State, S: BosStr> StateBuilder<St, S> {
    /// Set the `lastInitiatedAt` field (optional)
    pub fn last_initiated_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `lastInitiatedAt` field to an Option value (optional)
    pub fn maybe_last_initiated_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.1 = value;
        self
    }
}

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

impl<St, S: BosStr> StateBuilder<St, S>
where
    St: state_state::State,
    St::Access: state_state::IsSet,
    St::Status: state_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> State<S> {
        State {
            access: self._fields.0.unwrap(),
            last_initiated_at: self._fields.1,
            status: 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<SmolStr, Data<S>>) -> State<S> {
        State {
            access: self._fields.0.unwrap(),
            last_initiated_at: self._fields.1,
            status: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}