"""Asset schemas (CRUD)."""

from datetime import datetime
from typing import List

from pydantic import BaseModel, Field


class AssetUpdate(BaseModel):
    """Request to update asset metadata."""

    name: str | None = Field(None, min_length=1, max_length=100, description="Display name")
    description: str | None = Field(None, max_length=500, description="Optional description")
    tags: List[str] | None = Field(None, description="User-defined tags")
    icon: str | None = Field(
        None,
        max_length=64,
        description="Icon id from the curated icon library. Pass empty string to clear.",
    )
    icon_color: str | None = Field(
        None,
        max_length=32,
        description="Optional CSS color override for the icon. Empty/null inherits the channel accent.",
    )


class AssetResponse(BaseModel):
    """Asset response."""

    id: str = Field(description="Asset ID")
    name: str = Field(description="Display name")
    filename: str = Field(description="Original upload filename")
    mime_type: str = Field(description="MIME type")
    asset_type: str = Field(description="Asset type: sound, image, video, other")
    size_bytes: int = Field(description="File size in bytes")
    description: str | None = Field(None, description="Description")
    tags: List[str] = Field(default_factory=list, description="User-defined tags")
    prebuilt: bool = Field(False, description="Whether this is a shipped prebuilt asset")
    icon: str | None = Field(
        None,
        max_length=64,
        description="Icon id from the curated icon library. Pass empty string to clear.",
    )
    icon_color: str | None = Field(
        None,
        max_length=32,
        description="Optional CSS color override for the icon. Empty/null inherits the channel accent.",
    )
    created_at: datetime = Field(description="Creation timestamp")
    updated_at: datetime = Field(description="Last update timestamp")


class AssetListResponse(BaseModel):
    """List of assets."""

    assets: List[AssetResponse] = Field(description="List of assets")
    count: int = Field(description="Number of assets")
