"""Music data models for background music generation.

This module defines the data structures for music generation,
including the music brief from the Music Director agent and
the generated music track metadata.
"""

from enum import Enum

from pydantic import BaseModel, Field


class MusicMood(str, Enum):
    """Emotional quality of the music."""

    UPBEAT = "upbeat"
    CALM = "calm"
    DRAMATIC = "dramatic"
    SUSPENSEFUL = "suspenseful"
    JOYFUL = "joyful"
    MELANCHOLIC = "melancholic"
    ENERGETIC = "energetic"
    PEACEFUL = "peaceful"


class MusicGenre(str, Enum):
    """Musical style/genre for generation."""

    ORCHESTRAL = "orchestral"
    ELECTRONIC = "electronic"
    ACOUSTIC = "acoustic"
    AMBIENT = "ambient"
    CINEMATIC = "cinematic"
    POP = "pop"
    JAZZ = "jazz"
    CLASSICAL = "classical"


class MusicBrief(BaseModel):
    """Output from Music Director agent describing desired music.

    This represents the creative direction for background music,
    including the prompt for AI music generation and metadata
    about the desired style.

    Note: All fields are required (no Optional types) for OpenAI structured output compatibility.
    """

    prompt: str = Field(description="Detailed music generation prompt for Lyria 2 (50-100 words)")
    negative_prompt: str = Field(
        default="vocals, singing, lyrics",
        description="Elements to exclude from generation",
    )
    mood: MusicMood = Field(description="Overall emotional quality of the music")
    genre: MusicGenre = Field(description="Music genre/style")
    tempo: str = Field(
        default="moderate", description="Tempo description (e.g., 'moderate 100 BPM')"
    )
    instruments: list[str] = Field(
        default_factory=list, description="Key instruments to feature (empty list if unspecified)"
    )
    rationale: str = Field(description="Why this music fits the video content")


class GeneratedMusic(BaseModel):
    """Represents a generated music track.

    This contains metadata about a music track generated by Lyria 2,
    including the file path and generation parameters.
    """

    file_path: str = Field(description="Local path to the WAV file")
    duration_seconds: float = Field(
        default=32.8, description="Duration in seconds (Lyria generates ~32.8s)"
    )
    prompt_used: str = Field(description="Prompt used for generation")
    brief: MusicBrief = Field(description="Original music brief")
