// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: org.hypercerts.context.measurement
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

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

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

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime, UriValue};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon};
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::richtext::facet::Facet;
use crate::app_certified::Did;
use crate::com_atproto::repo::strong_ref::StrongRef;
/// Measurement data related to one or more records (e.g. activities, projects, etc.).

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "org.hypercerts.context.measurement",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Measurement<S: BosStr = DefaultStr> {
    ///Short comment of this measurement, suitable for previews and list views. Rich text annotations may be provided via `commentFacets`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub comment: Option<S>,
    ///Rich text annotations for `comment` (mentions, URLs, hashtags, etc).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub comment_facets: Option<Vec<Facet<S>>>,
    ///Client-declared timestamp when this record was originally created
    pub created_at: Datetime,
    ///The end date and time when the measurement ended. For one-time measurements, this should equal the start date.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub end_date: Option<Datetime>,
    ///URIs to related evidence or underlying data (e.g. org.hypercerts.claim.evidence records or raw datasets)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub evidence_uri: Option<Vec<UriValue<S>>>,
    ///Optional geographic references related to where the measurement was taken. Each referenced record must conform with the app.certified.location lexicon.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub locations: Option<Vec<StrongRef<S>>>,
    ///DIDs of the entities that performed this measurement
    #[serde(skip_serializing_if = "Option::is_none")]
    pub measurers: Option<Vec<Did<S>>>,
    ///Short identifier for the measurement methodology
    #[serde(skip_serializing_if = "Option::is_none")]
    pub method_type: Option<S>,
    ///URI to methodology documentation, standard protocol, or measurement procedure
    #[serde(skip_serializing_if = "Option::is_none")]
    pub method_uri: Option<UriValue<S>>,
    ///The metric being measured, e.g. forest area restored, number of users, etc.
    pub metric: S,
    ///The start date and time when the measurement began.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub start_date: Option<Datetime>,
    ///Strong references to the records this measurement refers to (e.g. activities, projects, or claims).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub subjects: Option<Vec<StrongRef<S>>>,
    ///The unit of the measured value (e.g. kg CO₂e, hectares, %, index score).
    pub unit: S,
    ///The measured value as a numeric string (e.g. '1234.56')
    pub value: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

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

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

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

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

#[derive(Debug, Serialize, Deserialize)]
pub struct MeasurementRecord;
impl XrpcResp for MeasurementRecord {
    const NSID: &'static str = "org.hypercerts.context.measurement";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = MeasurementGetRecordOutput<S>;
    type Err = RecordError;
}

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

impl<S: BosStr> Collection for Measurement<S> {
    const NSID: &'static str = "org.hypercerts.context.measurement";
    type Record = MeasurementRecord;
}

impl Collection for MeasurementRecord {
    const NSID: &'static str = "org.hypercerts.context.measurement";
    type Record = MeasurementRecord;
}

impl<S: BosStr> LexiconSchema for Measurement<S> {
    fn nsid() -> &'static str {
        "org.hypercerts.context.measurement"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_org_hypercerts_context_measurement()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.comment {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 3000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("comment"),
                    max: 3000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.comment {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 300usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("comment"),
                        max: 300usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.evidence_uri {
            #[allow(unused_comparisons)]
            if value.len() > 50usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("evidence_uri"),
                    max: 50usize,
                    actual: value.len(),
                });
            }
        }
        if let Some(ref value) = self.locations {
            #[allow(unused_comparisons)]
            if value.len() > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("locations"),
                    max: 100usize,
                    actual: value.len(),
                });
            }
        }
        if let Some(ref value) = self.measurers {
            #[allow(unused_comparisons)]
            if value.len() > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("measurers"),
                    max: 100usize,
                    actual: value.len(),
                });
            }
        }
        if let Some(ref value) = self.method_type {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 30usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("method_type"),
                    max: 30usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.metric;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 500usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("metric"),
                    max: 500usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.subjects {
            #[allow(unused_comparisons)]
            if value.len() > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("subjects"),
                    max: 100usize,
                    actual: value.len(),
                });
            }
        }
        {
            let value = &self.unit;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 50usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("unit"),
                    max: 50usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.value;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 500usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("value"),
                    max: 500usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

pub mod measurement_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 CreatedAt;
        type Metric;
        type Unit;
        type Value;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type CreatedAt = Unset;
        type Metric = Unset;
        type Unit = Unset;
        type Value = Unset;
    }
    ///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 CreatedAt = Set<members::created_at>;
        type Metric = St::Metric;
        type Unit = St::Unit;
        type Value = St::Value;
    }
    ///State transition - sets the `metric` field to Set
    pub struct SetMetric<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetMetric<St> {}
    impl<St: State> State for SetMetric<St> {
        type CreatedAt = St::CreatedAt;
        type Metric = Set<members::metric>;
        type Unit = St::Unit;
        type Value = St::Value;
    }
    ///State transition - sets the `unit` field to Set
    pub struct SetUnit<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUnit<St> {}
    impl<St: State> State for SetUnit<St> {
        type CreatedAt = St::CreatedAt;
        type Metric = St::Metric;
        type Unit = Set<members::unit>;
        type Value = St::Value;
    }
    ///State transition - sets the `value` field to Set
    pub struct SetValue<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetValue<St> {}
    impl<St: State> State for SetValue<St> {
        type CreatedAt = St::CreatedAt;
        type Metric = St::Metric;
        type Unit = St::Unit;
        type Value = Set<members::value>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `metric` field
        pub struct metric(());
        ///Marker type for the `unit` field
        pub struct unit(());
        ///Marker type for the `value` field
        pub struct value(());
    }
}

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

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

impl<S: BosStr> Measurement<S> {
    /// Create a new builder for this type
    pub fn builder() -> MeasurementBuilder<measurement_state::Empty, S> {
        MeasurementBuilder::builder()
    }
}

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

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

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

impl<St: measurement_state::State, S: BosStr> MeasurementBuilder<St, S> {
    /// Set the `commentFacets` field (optional)
    pub fn comment_facets(mut self, value: impl Into<Option<Vec<Facet<S>>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `commentFacets` field to an Option value (optional)
    pub fn maybe_comment_facets(mut self, value: Option<Vec<Facet<S>>>) -> Self {
        self._fields.1 = value;
        self
    }
}

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

impl<St: measurement_state::State, S: BosStr> MeasurementBuilder<St, S> {
    /// Set the `endDate` field (optional)
    pub fn end_date(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `endDate` field to an Option value (optional)
    pub fn maybe_end_date(mut self, value: Option<Datetime>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St: measurement_state::State, S: BosStr> MeasurementBuilder<St, S> {
    /// Set the `evidenceURI` field (optional)
    pub fn evidence_uri(mut self, value: impl Into<Option<Vec<UriValue<S>>>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `evidenceURI` field to an Option value (optional)
    pub fn maybe_evidence_uri(mut self, value: Option<Vec<UriValue<S>>>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<St: measurement_state::State, S: BosStr> MeasurementBuilder<St, S> {
    /// Set the `locations` field (optional)
    pub fn locations(mut self, value: impl Into<Option<Vec<StrongRef<S>>>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `locations` field to an Option value (optional)
    pub fn maybe_locations(mut self, value: Option<Vec<StrongRef<S>>>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St: measurement_state::State, S: BosStr> MeasurementBuilder<St, S> {
    /// Set the `measurers` field (optional)
    pub fn measurers(mut self, value: impl Into<Option<Vec<Did<S>>>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `measurers` field to an Option value (optional)
    pub fn maybe_measurers(mut self, value: Option<Vec<Did<S>>>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<St: measurement_state::State, S: BosStr> MeasurementBuilder<St, S> {
    /// Set the `methodType` field (optional)
    pub fn method_type(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `methodType` field to an Option value (optional)
    pub fn maybe_method_type(mut self, value: Option<S>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<St: measurement_state::State, S: BosStr> MeasurementBuilder<St, S> {
    /// Set the `methodURI` field (optional)
    pub fn method_uri(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `methodURI` field to an Option value (optional)
    pub fn maybe_method_uri(mut self, value: Option<UriValue<S>>) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<St, S: BosStr> MeasurementBuilder<St, S>
where
    St: measurement_state::State,
    St::Metric: measurement_state::IsUnset,
{
    /// Set the `metric` field (required)
    pub fn metric(
        mut self,
        value: impl Into<S>,
    ) -> MeasurementBuilder<measurement_state::SetMetric<St>, S> {
        self._fields.9 = Option::Some(value.into());
        MeasurementBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: measurement_state::State, S: BosStr> MeasurementBuilder<St, S> {
    /// Set the `startDate` field (optional)
    pub fn start_date(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `startDate` field to an Option value (optional)
    pub fn maybe_start_date(mut self, value: Option<Datetime>) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<St: measurement_state::State, S: BosStr> MeasurementBuilder<St, S> {
    /// Set the `subjects` field (optional)
    pub fn subjects(mut self, value: impl Into<Option<Vec<StrongRef<S>>>>) -> Self {
        self._fields.11 = value.into();
        self
    }
    /// Set the `subjects` field to an Option value (optional)
    pub fn maybe_subjects(mut self, value: Option<Vec<StrongRef<S>>>) -> Self {
        self._fields.11 = value;
        self
    }
}

impl<St, S: BosStr> MeasurementBuilder<St, S>
where
    St: measurement_state::State,
    St::Unit: measurement_state::IsUnset,
{
    /// Set the `unit` field (required)
    pub fn unit(
        mut self,
        value: impl Into<S>,
    ) -> MeasurementBuilder<measurement_state::SetUnit<St>, S> {
        self._fields.12 = Option::Some(value.into());
        MeasurementBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> MeasurementBuilder<St, S>
where
    St: measurement_state::State,
    St::CreatedAt: measurement_state::IsSet,
    St::Metric: measurement_state::IsSet,
    St::Unit: measurement_state::IsSet,
    St::Value: measurement_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Measurement<S> {
        Measurement {
            comment: self._fields.0,
            comment_facets: self._fields.1,
            created_at: self._fields.2.unwrap(),
            end_date: self._fields.3,
            evidence_uri: self._fields.4,
            locations: self._fields.5,
            measurers: self._fields.6,
            method_type: self._fields.7,
            method_uri: self._fields.8,
            metric: self._fields.9.unwrap(),
            start_date: self._fields.10,
            subjects: self._fields.11,
            unit: self._fields.12.unwrap(),
            value: self._fields.13.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>>,
    ) -> Measurement<S> {
        Measurement {
            comment: self._fields.0,
            comment_facets: self._fields.1,
            created_at: self._fields.2.unwrap(),
            end_date: self._fields.3,
            evidence_uri: self._fields.4,
            locations: self._fields.5,
            measurers: self._fields.6,
            method_type: self._fields.7,
            method_uri: self._fields.8,
            metric: self._fields.9.unwrap(),
            start_date: self._fields.10,
            subjects: self._fields.11,
            unit: self._fields.12.unwrap(),
            value: self._fields.13.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_org_hypercerts_context_measurement() -> 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("org.hypercerts.context.measurement"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static(
                            "Measurement data related to one or more records (e.g. activities, projects, etc.).",
                        ),
                    ),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("metric"), SmolStr::new_static("unit"),
                                SmolStr::new_static("value"),
                                SmolStr::new_static("createdAt")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("comment"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Short comment of this measurement, suitable for previews and list views. Rich text annotations may be provided via `commentFacets`.",
                                        ),
                                    ),
                                    max_length: Some(3000usize),
                                    max_graphemes: Some(300usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("commentFacets"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(
                                        CowStr::new_static(
                                            "Rich text annotations for `comment` (mentions, URLs, hashtags, etc).",
                                        ),
                                    ),
                                    items: LexArrayItem::Ref(LexRef {
                                        r#ref: CowStr::new_static("app.bsky.richtext.facet"),
                                        ..Default::default()
                                    }),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Client-declared timestamp when this record was originally created",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("endDate"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The end date and time when the measurement ended. For one-time measurements, this should equal the start date.",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("evidenceURI"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(
                                        CowStr::new_static(
                                            "URIs to related evidence or underlying data (e.g. org.hypercerts.claim.evidence records or raw datasets)",
                                        ),
                                    ),
                                    items: LexArrayItem::String(LexString {
                                        format: Some(LexStringFormat::Uri),
                                        ..Default::default()
                                    }),
                                    max_length: Some(50usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("locations"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(
                                        CowStr::new_static(
                                            "Optional geographic references related to where the measurement was taken. Each referenced record must conform with the app.certified.location lexicon.",
                                        ),
                                    ),
                                    items: LexArrayItem::Ref(LexRef {
                                        r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                        ..Default::default()
                                    }),
                                    max_length: Some(100usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("measurers"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(
                                        CowStr::new_static(
                                            "DIDs of the entities that performed this measurement",
                                        ),
                                    ),
                                    items: LexArrayItem::Ref(LexRef {
                                        r#ref: CowStr::new_static("app.certified.defs#did"),
                                        ..Default::default()
                                    }),
                                    max_length: Some(100usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("methodType"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Short identifier for the measurement methodology",
                                        ),
                                    ),
                                    max_length: Some(30usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("methodURI"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "URI to methodology documentation, standard protocol, or measurement procedure",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Uri),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("metric"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The metric being measured, e.g. forest area restored, number of users, etc.",
                                        ),
                                    ),
                                    max_length: Some(500usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("startDate"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The start date and time when the measurement began.",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("subjects"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(
                                        CowStr::new_static(
                                            "Strong references to the records this measurement refers to (e.g. activities, projects, or claims).",
                                        ),
                                    ),
                                    items: LexArrayItem::Ref(LexRef {
                                        r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                        ..Default::default()
                                    }),
                                    max_length: Some(100usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("unit"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The unit of the measured value (e.g. kg CO₂e, hectares, %, index score).",
                                        ),
                                    ),
                                    max_length: Some(50usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("value"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The measured value as a numeric string (e.g. '1234.56')",
                                        ),
                                    ),
                                    max_length: Some(500usize),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}