"""Data types for NoteFlow gRPC client operations."""

from __future__ import annotations

from collections.abc import Callable
from dataclasses import dataclass


@dataclass
class TranscriptSegment:
    """Transcript segment from server."""

    segment_id: int
    text: str
    start_time: float
    end_time: float
    language: str
    is_final: bool
    speaker_id: str = ""
    speaker_confidence: float = 0.0


@dataclass
class ServerInfo:
    """Server information."""

    version: str
    asr_model: str
    asr_ready: bool
    uptime_seconds: float
    active_meetings: int
    diarization_enabled: bool = False
    diarization_ready: bool = False


@dataclass
class MeetingInfo:
    """Meeting information."""

    id: str
    title: str
    state: str
    created_at: float
    started_at: float
    ended_at: float
    duration_seconds: float
    segment_count: int


@dataclass
class AnnotationInfo:
    """Annotation information."""

    id: str
    meeting_id: str
    annotation_type: str
    text: str
    start_time: float
    end_time: float
    segment_ids: list[int]
    created_at: float


@dataclass
class ExportResult:
    """Export result."""

    content: str
    format_name: str
    file_extension: str


@dataclass
class DiarizationResult:
    """Result of speaker diarization refinement."""

    job_id: str
    status: str
    segments_updated: int
    speaker_ids: list[str]
    error_message: str = ""

    @property
    def success(self) -> bool:
        """Check if diarization succeeded."""
        return self.status == "completed" and not self.error_message

    @property
    def is_terminal(self) -> bool:
        """Check if job reached a terminal state."""
        return self.status in {"completed", "failed"}


@dataclass
class RenameSpeakerResult:
    """Result of speaker rename operation."""

    segments_updated: int
    success: bool


# Callback types
TranscriptCallback = Callable[[TranscriptSegment], None]
ConnectionCallback = Callable[[bool, str], None]
