// @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;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
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::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.).

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Measurement<'a> {
    ///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")]
    #[serde(borrow)]
    pub comment: Option<CowStr<'a>>,
    ///Rich text annotations for `comment` (mentions, URLs, hashtags, etc).
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub comment_facets: Option<Vec<Facet<'a>>>,
    ///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")]
    #[serde(borrow)]
    pub evidence_uri: Option<Vec<UriValue<'a>>>,
    ///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")]
    #[serde(borrow)]
    pub locations: Option<Vec<StrongRef<'a>>>,
    ///DIDs of the entities that performed this measurement
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub measurers: Option<Vec<Did<'a>>>,
    ///Short identifier for the measurement methodology
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub method_type: Option<CowStr<'a>>,
    ///URI to methodology documentation, standard protocol, or measurement procedure
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub method_uri: Option<UriValue<'a>>,
    ///The metric being measured, e.g. forest area restored, number of users, etc.
    #[serde(borrow)]
    pub metric: CowStr<'a>,
    ///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")]
    #[serde(borrow)]
    pub subjects: Option<Vec<StrongRef<'a>>>,
    ///The unit of the measured value (e.g. kg CO₂e, hectares, %, index score).
    #[serde(borrow)]
    pub unit: CowStr<'a>,
    ///The measured value as a numeric string (e.g. '1234.56')
    #[serde(borrow)]
    pub value: CowStr<'a>,
}

/// 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<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub cid: Option<Cid<'a>>,
    #[serde(borrow)]
    pub uri: AtUri<'a>,
    #[serde(borrow)]
    pub value: Measurement<'a>,
}

impl<'a> Measurement<'a> {
    pub fn uri(
        uri: impl Into<CowStr<'a>>,
    ) -> Result<RecordUri<'a, MeasurementRecord>, UriError> {
        RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
    }
}

/// 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<'de> = MeasurementGetRecordOutput<'de>;
    type Err<'de> = RecordError<'de>;
}

impl From<MeasurementGetRecordOutput<'_>> for Measurement<'_> {
    fn from(output: MeasurementGetRecordOutput<'_>) -> Self {
        use jacquard_common::IntoStatic;
        output.value.into_static()
    }
}

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

/// Builder for constructing an instance of this type
pub struct MeasurementBuilder<'a, S: measurement_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<CowStr<'a>>,
        Option<Vec<Facet<'a>>>,
        Option<Datetime>,
        Option<Datetime>,
        Option<Vec<UriValue<'a>>>,
        Option<Vec<StrongRef<'a>>>,
        Option<Vec<Did<'a>>>,
        Option<CowStr<'a>>,
        Option<UriValue<'a>>,
        Option<CowStr<'a>>,
        Option<Datetime>,
        Option<Vec<StrongRef<'a>>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

impl<'a, S: measurement_state::State> MeasurementBuilder<'a, S> {
    /// Set the `commentFacets` field (optional)
    pub fn comment_facets(mut self, value: impl Into<Option<Vec<Facet<'a>>>>) -> 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<'a>>>) -> Self {
        self._fields.1 = value;
        self
    }
}

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

impl<'a, S: measurement_state::State> MeasurementBuilder<'a, 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<'a, S: measurement_state::State> MeasurementBuilder<'a, S> {
    /// Set the `evidenceURI` field (optional)
    pub fn evidence_uri(mut self, value: impl Into<Option<Vec<UriValue<'a>>>>) -> 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<'a>>>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<'a, S: measurement_state::State> MeasurementBuilder<'a, S> {
    /// Set the `locations` field (optional)
    pub fn locations(mut self, value: impl Into<Option<Vec<StrongRef<'a>>>>) -> 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<'a>>>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<'a, S: measurement_state::State> MeasurementBuilder<'a, S> {
    /// Set the `measurers` field (optional)
    pub fn measurers(mut self, value: impl Into<Option<Vec<Did<'a>>>>) -> 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<'a>>>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<'a, S: measurement_state::State> MeasurementBuilder<'a, S> {
    /// Set the `methodType` field (optional)
    pub fn method_type(mut self, value: impl Into<Option<CowStr<'a>>>) -> 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<CowStr<'a>>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<'a, S: measurement_state::State> MeasurementBuilder<'a, S> {
    /// Set the `methodURI` field (optional)
    pub fn method_uri(mut self, value: impl Into<Option<UriValue<'a>>>) -> 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<'a>>) -> Self {
        self._fields.8 = value;
        self
    }
}

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

impl<'a, S: measurement_state::State> MeasurementBuilder<'a, 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<'a, S: measurement_state::State> MeasurementBuilder<'a, S> {
    /// Set the `subjects` field (optional)
    pub fn subjects(mut self, value: impl Into<Option<Vec<StrongRef<'a>>>>) -> 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<'a>>>) -> Self {
        self._fields.11 = value;
        self
    }
}

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

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

impl<'a, S> MeasurementBuilder<'a, S>
where
    S: measurement_state::State,
    S::Metric: measurement_state::IsSet,
    S::Unit: measurement_state::IsSet,
    S::CreatedAt: measurement_state::IsSet,
    S::Value: measurement_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Measurement<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> Measurement<'a> {
        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()
    }
}