"""
Event types for the mainline application.
Defines the core events that flow through the system.
These types support a future migration to an event-driven architecture.
"""

from dataclasses import dataclass
from datetime import datetime
from enum import Enum, auto


class EventType(Enum):
    """Core event types in the mainline application."""

    NEW_HEADLINE = auto()
    FRAME_TICK = auto()
    MIC_LEVEL = auto()
    NTFY_MESSAGE = auto()
    STREAM_START = auto()
    STREAM_END = auto()


@dataclass
class HeadlineEvent:
    """Event emitted when a new headline is ready for display."""

    title: str
    source: str
    timestamp: str
    language: str | None = None


@dataclass
class FrameTickEvent:
    """Event emitted on each render frame."""

    frame_number: int
    timestamp: datetime
    delta_seconds: float


@dataclass
class MicLevelEvent:
    """Event emitted when microphone level changes significantly."""

    db_level: float
    excess_above_threshold: float
    timestamp: datetime


@dataclass
class NtfyMessageEvent:
    """Event emitted when an ntfy message is received."""

    title: str
    body: str
    message_id: str | None = None
    timestamp: datetime | None = None


@dataclass
class StreamEvent:
    """Event emitted when stream starts or ends."""

    event_type: EventType
    headline_count: int = 0
    timestamp: datetime | None = None
