# generated by datamodel-codegen:
#   filename:  core/creative_asset.json
#   timestamp: 2026-02-28T17:39:50+00:00

from __future__ import annotations

from typing import Annotated

from adcp.types.base import AdCPBaseModel
from pydantic import ConfigDict, Field, StringConstraints

from ..enums import creative_status
from . import format_id as format_id_1
from . import provenance as provenance_1
from .assets import (
    audio_asset,
    brief_asset,
    catalog_asset,
    css_asset,
    daast_asset,
    html_asset,
    image_asset,
    javascript_asset,
    markdown_asset,
    text_asset,
    url_asset,
    vast_asset,
    video_asset,
    webhook_asset,
)


class Input(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    context_description: Annotated[
        str | None,
        Field(description='Natural language description of the context for AI-generated content'),
    ] = None
    macros: Annotated[
        dict[str, str] | None, Field(description='Macro values to apply for this preview')
    ] = None
    name: Annotated[str, Field(description='Human-readable name for this preview variant')]


class CreativeAsset(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    assets: Annotated[
        dict[
            Annotated[str, StringConstraints(pattern=r'^[a-z0-9_]+$')],
            image_asset.ImageAsset
            | video_asset.VideoAsset
            | audio_asset.AudioAsset
            | vast_asset.VastAsset
            | text_asset.TextAsset
            | url_asset.UrlAsset
            | html_asset.HtmlAsset
            | javascript_asset.JavascriptAsset
            | webhook_asset.WebhookAsset
            | css_asset.CssAsset
            | daast_asset.DaastAsset
            | markdown_asset.MarkdownAsset
            | brief_asset.BriefAsset
            | catalog_asset.CatalogAsset,
        ],
        Field(description='Assets required by the format, keyed by asset_id'),
    ]
    creative_id: Annotated[str, Field(description='Unique identifier for the creative')]
    format_id: Annotated[
        format_id_1.FormatId,
        Field(
            description='Format identifier specifying which format this creative conforms to. Can be: (1) concrete format_id referencing a format with fixed dimensions, (2) template format_id referencing a template format, or (3) parameterized format_id with dimensions/duration parameters for template formats.'
        ),
    ]
    inputs: Annotated[
        list[Input] | None,
        Field(
            description='Preview contexts for generative formats - defines what scenarios to generate previews for'
        ),
    ] = None
    name: Annotated[str, Field(description='Human-readable creative name')]
    placement_ids: Annotated[
        list[str] | None,
        Field(
            description="Optional array of placement IDs where this creative should run when uploading via create_media_buy or update_media_buy. References placement_id values from the product's placements array. If omitted, creative runs on all placements. Only used during upload to media buy - not stored in creative library.",
            min_length=1,
        ),
    ] = None
    provenance: Annotated[
        provenance_1.Provenance | None,
        Field(
            description='Provenance metadata for this creative. Serves as the default provenance for all manifests and assets within this creative. A manifest or asset with its own provenance replaces this object entirely (no field-level merging).'
        ),
    ] = None
    status: Annotated[
        creative_status.CreativeStatus | None,
        Field(
            description="For generative creatives: set to 'approved' to finalize, 'rejected' to request regeneration with updated assets/message. Omit for non-generative creatives (system will set based on processing state)."
        ),
    ] = None
    tags: Annotated[
        list[str] | None, Field(description='User-defined tags for organization and searchability')
    ] = None
    weight: Annotated[
        float | None,
        Field(
            description='Optional delivery weight for creative rotation when uploading via create_media_buy or update_media_buy (0-100). If omitted, platform determines rotation. Only used during upload to media buy - not stored in creative library.',
            ge=0.0,
            le=100.0,
        ),
    ] = None
