"""Template commands."""

from __future__ import annotations

from dataclasses import dataclass, field
from typing import List, Optional


@dataclass
class SegmentCommand:
    segment_order: int
    duration_min: float
    duration_max: float
    material_type: Optional[str] = None


@dataclass
class CreateTemplateCommand:
    user_id: str
    name: str
    mode: str
    category: str = ""
    tags: List[str] = field(default_factory=list)
    title_config: dict = field(default_factory=dict)
    subtitle_config: dict = field(default_factory=dict)
    bgm_config: dict = field(default_factory=dict)
    estimated_duration: float = 0.0
    segments: List[SegmentCommand] = field(default_factory=list)


@dataclass
class UpdateTemplateCommand:
    template_id: str
    user_id: str
    name: Optional[str] = None
    mode: Optional[str] = None
    category: Optional[str] = None
    tags: Optional[List[str]] = None
    title_config: Optional[dict] = None
    subtitle_config: Optional[dict] = None
    bgm_config: Optional[dict] = None
    estimated_duration: Optional[float] = None
    segments: Optional[List[SegmentCommand]] = None


@dataclass
class CreateCategoryCommand:
    user_id: str
    name: str


@dataclass
class ValidateTemplateCommand:
    template_id: str
    user_id: str
    voiceover_duration: Optional[float] = None  # 配音实际时长（用于偏差校验）
