# This file was auto-generated by Fern from our API Definition.

from __future__ import annotations

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata
from .asset_transcription import AssetTranscription
from .audio_analysis import AudioAnalysis
from .canvas_placement import CanvasPlacement
from .clip_animation import ClipAnimation
from .generation_source_context import GenerationSourceContext
from .image_analysis import ImageAnalysis
from .pending_blocks_metadata_model import PendingBlocksMetadataModel
from .pending_clip_task import PendingClipTask
from .pending_external_audios_metadata_model import PendingExternalAudiosMetadataModel
from .project_external_audio_response_model_source_context import ProjectExternalAudioResponseModelSourceContext
from .project_video_thumbnail_sheet_response_model import ProjectVideoThumbnailSheetResponseModel
from .video_analysis import VideoAnalysis


class ProjectExtendedResponseAssetsItem_Video(UncheckedBaseModel):
    type: typing.Literal["video"] = "video"
    video_id: str
    filename: str
    signed_url: typing.Optional[str] = None
    signed_preview_url: typing.Optional[str] = None
    offset_ms: int
    duration_ms: int
    volume_gain_db: float
    muted: bool
    fade_in_ms: typing.Optional[int] = None
    fade_out_ms: typing.Optional[int] = None
    width: int
    height: int
    codec: str
    order: str
    created_at_ms: int
    updated_at_ms: int
    error: typing.Optional[str] = None
    thumbnail_interval_seconds: float
    thumbnail_size: typing.List[int]
    thumbnail_sheets: typing.List[ProjectVideoThumbnailSheetResponseModel]
    start_time_ms: int
    end_time_ms: typing.Optional[int] = None
    asset_preview_signed_url: typing.Optional[str] = None
    source_video_id: typing.Optional[str] = None
    source_asset_id: typing.Optional[str] = None
    source_platform_asset_id: typing.Optional[str] = None
    pending_blocks_metadata: typing.Optional[PendingBlocksMetadataModel] = None
    pending_external_audios_metadata: typing.Optional[PendingExternalAudiosMetadataModel] = None
    speech_imported: typing.Optional[bool] = None
    pending_task: typing.Optional[PendingClipTask] = None
    audio_track_ready: typing.Optional[bool] = None
    export_format_ready: typing.Optional[bool] = None
    current_snapshot_id: typing.Optional[str] = None
    source_context: typing.Optional[GenerationSourceContext] = None
    analysis: typing.Optional[VideoAnalysis] = None
    transcription: typing.Optional[AssetTranscription] = None
    canvas_placement: typing.Optional[CanvasPlacement] = None
    animation: typing.Optional[ClipAnimation] = None
    playback_speed: typing.Optional[float] = None
    opacity: typing.Optional[float] = None
    track_id: typing.Optional[str] = None
    preview_job_progress: typing.Optional[float] = None
    import_speech_progress: typing.Optional[float] = None

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow


class ProjectExtendedResponseAssetsItem_Audio(UncheckedBaseModel):
    type: typing.Literal["audio"] = "audio"
    external_audio_id: str
    filename: str
    signed_url: typing.Optional[str] = None
    offset_ms: int
    duration_ms: int
    start_time_ms: int
    end_time_ms: typing.Optional[int] = None
    order: str
    track_id: str
    created_at_ms: int
    updated_at_ms: int
    volume_gain_db: typing.Optional[float] = None
    muted: typing.Optional[bool] = None
    fade_in_ms: typing.Optional[int] = None
    fade_out_ms: typing.Optional[int] = None
    source_external_audio_id: typing.Optional[str] = None
    source_asset_id: typing.Optional[str] = None
    source_platform_asset_id: typing.Optional[str] = None
    pending_blocks_metadata: typing.Optional[PendingBlocksMetadataModel] = None
    pending_external_audios_metadata: typing.Optional[PendingExternalAudiosMetadataModel] = None
    speech_imported: typing.Optional[bool] = None
    pending_task: typing.Optional[PendingClipTask] = None
    error: typing.Optional[str] = None
    current_snapshot_id: typing.Optional[str] = None
    source_context: typing.Optional[ProjectExternalAudioResponseModelSourceContext] = None
    analysis: typing.Optional[AudioAnalysis] = None
    transcription: typing.Optional[AssetTranscription] = None
    import_speech_progress: typing.Optional[float] = None

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow


class ProjectExtendedResponseAssetsItem_Image(UncheckedBaseModel):
    type: typing.Literal["image"] = "image"
    image_id: str
    filename: str
    signed_url: typing.Optional[str] = None
    thumbnail_signed_url: typing.Optional[str] = None
    source: typing.Optional[typing.Literal["upload"]] = None
    file_size_bytes: int
    width: int
    height: int
    track_id: typing.Optional[str] = None
    offset_ms: int
    duration_ms: int
    order: str
    canvas_placement: CanvasPlacement
    animation: typing.Optional[ClipAnimation] = None
    opacity: typing.Optional[float] = None
    created_at_ms: int
    updated_at_ms: int
    current_snapshot_id: typing.Optional[str] = None
    source_asset_id: typing.Optional[str] = None
    source_platform_asset_id: typing.Optional[str] = None
    error: typing.Optional[str] = None
    pending_task: typing.Optional[PendingClipTask] = None
    analysis: typing.Optional[ImageAnalysis] = None

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow


ProjectExtendedResponseAssetsItem = typing_extensions.Annotated[
    typing.Union[
        ProjectExtendedResponseAssetsItem_Video,
        ProjectExtendedResponseAssetsItem_Audio,
        ProjectExtendedResponseAssetsItem_Image,
    ],
    UnionMetadata(discriminant="type"),
]
