"""Pydantic models and type aliases related to transforms and API responses."""

from collections.abc import Sequence
from typing import Any, Literal

from pydantic import BaseModel, Field

from src.models.image import BBoxData, KeypointData

# Type aliases
TransformType = Literal["transforms_3d", "image_only", "dual", "unknown"]
Targets = Sequence[Literal["image", "mask", "bboxes", "keypoints", "volume", "mask3d"]]


class TransformExecutionConfig(BaseModel):
    """Configuration for transform execution regarding targets and annotation parameters."""

    targets: Sequence[Literal["image", "mask", "bboxes", "keypoints"]] = Field(default=["image"])
    bbox_params: dict[str, Any] | None = None
    keypoint_params: dict[str, Any] | None = None


class TransformInfo(BaseModel):
    """Information about a single transform."""

    name: str
    targets: Targets
    fields: dict[str, Any] | None = None
    parsed_docstring: dict[str, Any] | None = None
    transform_type: TransformType


class TransformsResponse(BaseModel):
    """Response containing all transforms grouped by type."""

    image_only: list[TransformInfo]
    dual: list[TransformInfo]
    transforms_3d: list[TransformInfo]


class TransformResponse(BaseModel):
    """Complete information about original image with visualizations."""

    image: str  # base64 encoded image
    mask: str | None = None
    bboxes: list[BBoxData] | None = None
    keypoints: list[KeypointData] | None = None
