# generated by datamodel-codegen:
#   filename:  preview-render.json
#   timestamp: 2025-11-15T22:03:55+00:00

from __future__ import annotations

from typing import Annotated, Literal

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


class Dimensions(AdCPBaseModel):
    height: Annotated[float, Field(ge=0.0)]
    width: Annotated[float, Field(ge=0.0)]


class Embedding(AdCPBaseModel):
    csp_policy: Annotated[
        str | None, Field(description="Content Security Policy requirements for embedding")
    ] = None
    recommended_sandbox: Annotated[
        str | None,
        Field(
            description="Recommended iframe sandbox attribute value (e.g., 'allow-scripts allow-same-origin')"
        ),
    ] = None
    requires_https: Annotated[
        bool | None, Field(description="Whether this output requires HTTPS for secure embedding")
    ] = None
    supports_fullscreen: Annotated[
        bool | None, Field(description="Whether this output supports fullscreen mode")
    ] = None


class PreviewRender1(AdCPBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    dimensions: Annotated[
        Dimensions | None, Field(description="Dimensions for this rendered piece")
    ] = None
    embedding: Annotated[
        Embedding | None,
        Field(description="Optional security and embedding metadata for safe iframe integration"),
    ] = None
    output_format: Annotated[
        Literal["url"], Field(description="Discriminator indicating preview_url is provided")
    ]
    preview_url: Annotated[
        AnyUrl,
        Field(
            description="URL to an HTML page that renders this piece. Can be embedded in an iframe."
        ),
    ]
    render_id: Annotated[
        str, Field(description="Unique identifier for this rendered piece within the variant")
    ]
    role: Annotated[
        str,
        Field(
            description="Semantic role of this rendered piece. Use 'primary' for main content, 'companion' for associated banners, descriptive strings for device variants or custom roles."
        ),
    ]


class PreviewRender2(AdCPBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    dimensions: Annotated[
        Dimensions | None, Field(description="Dimensions for this rendered piece")
    ] = None
    embedding: Annotated[
        Embedding | None, Field(description="Optional security and embedding metadata")
    ] = None
    output_format: Annotated[
        Literal["html"], Field(description="Discriminator indicating preview_html is provided")
    ]
    preview_html: Annotated[
        str,
        Field(
            description="Raw HTML for this rendered piece. Can be embedded directly in the page without iframe. Security warning: Only use with trusted creative agents as this bypasses iframe sandboxing."
        ),
    ]
    render_id: Annotated[
        str, Field(description="Unique identifier for this rendered piece within the variant")
    ]
    role: Annotated[
        str,
        Field(
            description="Semantic role of this rendered piece. Use 'primary' for main content, 'companion' for associated banners, descriptive strings for device variants or custom roles."
        ),
    ]


class PreviewRender3(AdCPBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    dimensions: Annotated[
        Dimensions | None, Field(description="Dimensions for this rendered piece")
    ] = None
    embedding: Annotated[
        Embedding | None,
        Field(description="Optional security and embedding metadata for safe iframe integration"),
    ] = None
    output_format: Annotated[
        Literal["both"],
        Field(
            description="Discriminator indicating both preview_url and preview_html are provided"
        ),
    ]
    preview_html: Annotated[
        str,
        Field(
            description="Raw HTML for this rendered piece. Can be embedded directly in the page without iframe. Security warning: Only use with trusted creative agents as this bypasses iframe sandboxing."
        ),
    ]
    preview_url: Annotated[
        AnyUrl,
        Field(
            description="URL to an HTML page that renders this piece. Can be embedded in an iframe."
        ),
    ]
    render_id: Annotated[
        str, Field(description="Unique identifier for this rendered piece within the variant")
    ]
    role: Annotated[
        str,
        Field(
            description="Semantic role of this rendered piece. Use 'primary' for main content, 'companion' for associated banners, descriptive strings for device variants or custom roles."
        ),
    ]


class PreviewRender(RootModel[PreviewRender1 | PreviewRender2 | PreviewRender3]):
    root: Annotated[
        PreviewRender1 | PreviewRender2 | PreviewRender3,
        Field(
            description="A single rendered piece of a creative preview with discriminated output format",
            title="Preview Render",
        ),
    ]
