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

from __future__ import annotations

from typing import Annotated, Literal

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

from ..core import context as context_1
from ..core import creative_manifest as creative_manifest_1
from ..core import ext as ext_1
from ..core import format_id as format_id_1
from ..enums import preview_output_format


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 (e.g., 'User just searched for running shoes', 'Podcast discussing weather patterns', 'Article about electric vehicles')"
        ),
    ] = None
    macros: Annotated[
        dict[str, str] | None,
        Field(
            description="Macro values to use for this preview. Supports all universal macros from the format's supported_macros list. See docs/creative/universal-macros.md for available macros."
        ),
    ] = None
    name: Annotated[
        str,
        Field(
            description="Human-readable name for this input set (e.g., 'Sunny morning on mobile', 'Evening podcast ad', 'Desktop dark mode')"
        ),
    ]


class Input2(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 use for this preview')
    ] = None
    name: Annotated[str, Field(description='Human-readable name for this input set')]


class PreviewCreativeRequest3(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    context: context_1.ContextObject | None = None
    creative_id: Annotated[str | None, Field(description='Creative identifier for context')] = None
    ext: ext_1.ExtensionObject | None = None
    output_format: Annotated[
        preview_output_format.PreviewOutputFormat | None,
        Field(
            description="Output format for the preview. 'url' returns preview_url (iframe-embeddable URL), 'html' returns preview_html (raw HTML for direct embedding)."
        ),
    ] = preview_output_format.PreviewOutputFormat.url
    request_type: Annotated[
        Literal['variant'],
        Field(description='Discriminator indicating this is a variant preview request'),
    ]
    variant_id: Annotated[
        str,
        Field(
            description='Platform-assigned variant identifier from get_creative_delivery response'
        ),
    ]


class PreviewCreativeRequest1(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    context: context_1.ContextObject | None = None
    creative_manifest: Annotated[
        creative_manifest_1.CreativeManifest,
        Field(description='Complete creative manifest with all required assets for the format.'),
    ]
    ext: ext_1.ExtensionObject | None = None
    format_id: Annotated[
        format_id_1.FormatId | None,
        Field(
            description='Format identifier for rendering the preview. Optional — defaults to creative_manifest_1.format_id if omitted.'
        ),
    ] = None
    inputs: Annotated[
        list[Input] | None,
        Field(
            description='Array of input sets for generating multiple preview variants. Each input set defines macros and context values for one preview rendering. If not provided, creative agent will generate default previews.',
            min_length=1,
        ),
    ] = None
    output_format: Annotated[
        preview_output_format.PreviewOutputFormat | None,
        Field(
            description="Output format for previews. 'url' returns preview_url (iframe-embeddable URL), 'html' returns preview_html (raw HTML for direct embedding). Default: 'url' for backward compatibility."
        ),
    ] = preview_output_format.PreviewOutputFormat.url
    request_type: Annotated[
        Literal['single'],
        Field(description='Discriminator indicating this is a single preview request'),
    ]
    template_id: Annotated[
        str | None, Field(description='Specific template ID for custom format rendering')
    ] = None


class Request(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    creative_manifest: Annotated[
        creative_manifest_1.CreativeManifest,
        Field(description='Complete creative manifest with all required assets.'),
    ]
    format_id: Annotated[
        format_id_1.FormatId | None,
        Field(
            description='Format identifier for rendering the preview. Optional — defaults to creative_manifest_1.format_id if omitted.'
        ),
    ] = None
    inputs: Annotated[
        list[Input2] | None,
        Field(
            description='Array of input sets for generating multiple preview variants', min_length=1
        ),
    ] = None
    output_format: Annotated[
        preview_output_format.PreviewOutputFormat | None,
        Field(
            description="Output format for this preview. 'url' returns preview_url, 'html' returns preview_html."
        ),
    ] = preview_output_format.PreviewOutputFormat.url
    template_id: Annotated[
        str | None, Field(description='Specific template ID for custom format rendering')
    ] = None


class PreviewCreativeRequest2(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    context: context_1.ContextObject | None = None
    ext: ext_1.ExtensionObject | None = None
    output_format: Annotated[
        preview_output_format.PreviewOutputFormat | None,
        Field(
            description="Default output format for all requests in this batch. Individual requests can override this. 'url' returns preview_url (iframe-embeddable URL), 'html' returns preview_html (raw HTML for direct embedding)."
        ),
    ] = preview_output_format.PreviewOutputFormat.url
    request_type: Annotated[
        Literal['batch'],
        Field(description='Discriminator indicating this is a batch preview request'),
    ]
    requests: Annotated[
        list[Request],
        Field(
            description='Array of preview requests (1-50 items). Each follows the single request structure.',
            max_length=50,
            min_length=1,
        ),
    ]


class PreviewCreativeRequest(
    RootModel[PreviewCreativeRequest1 | PreviewCreativeRequest2 | PreviewCreativeRequest3]
):
    root: Annotated[
        PreviewCreativeRequest1 | PreviewCreativeRequest2 | PreviewCreativeRequest3,
        Field(
            discriminator='request_type',
            description='Request to generate previews of one or more creative manifests. Accepts either a single creative request or an array of requests for batch processing.',
            title='Preview Creative Request',
        ),
    ]
