"""Generic media asset and collection models."""

from __future__ import annotations

from dataclasses import dataclass, field
from datetime import datetime
from enum import Enum
from typing import Any


class MediaType(str, Enum):
    """Types of media assets."""

    IMAGE = "image"
    VIDEO = "video"
    DOCUMENT = "document"


@dataclass
class MediaAsset:
    """A generic media asset from a service provider.

    Common fields are top-level. Provider-specific data goes in `extra`.
    """

    id: str
    type: MediaType
    filename: str
    created_at: datetime

    # Common optional fields
    owner_name: str | None = None
    description: str | None = None
    tags: list[str] = field(default_factory=list)
    thumbnail_url: str | None = None
    preview_url: str | None = None  # transcoded/mid-size — used for sending media
    full_url: str | None = None

    # Provider-specific extras (e.g., rating, location, people for Immich)
    extra: dict[str, Any] = field(default_factory=dict)


@dataclass
class MediaCollection:
    """A generic collection of media assets (album, folder, etc.).

    Provider-specific data goes in `extra`.
    """

    id: str
    name: str
    asset_count: int = 0
    assets: dict[str, MediaAsset] = field(default_factory=dict)
    asset_ids: set[str] = field(default_factory=set)

    # Provider-specific extras
    extra: dict[str, Any] = field(default_factory=dict)
