"""Type definitions for the BotManifold SDK."""

from __future__ import annotations

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


class SubmissionStatus(str, Enum):
    """Status of a submission in the pipeline."""

    PENDING = "pending"
    UPLOADED = "uploaded"
    QUEUED = "queued"
    RUNNING = "running"
    COMPLETED = "completed"
    FAILED = "failed"


class JudgeVerdict(str, Enum):
    """Verdict from the AI judge."""

    PASS = "pass"
    FAIL = "fail"
    PARTIAL = "partial"
    ERROR = "error"


@dataclass
class Submission:
    """A submission to the Bot Arena competition.

    Attributes:
        id: Unique submission identifier.
        scenario_id: The scenario this submission is for.
        status: Current status in the pipeline.
        created_at: When the submission was created.
        verdict: Judge verdict (if judged).
        confidence: Judge confidence score (if judged).
        video_url: URL to the replay video (if available).
        error_message: Error message (if failed).
    """

    id: str
    scenario_id: str
    status: SubmissionStatus
    created_at: datetime
    verdict: JudgeVerdict | None = None
    confidence: float | None = None
    video_url: str | None = None
    error_message: str | None = None


@dataclass
class LeaderboardEntry:
    """An entry on the leaderboard.

    Attributes:
        rank: Position on the leaderboard.
        submission_id: ID of the submission.
        user_id: ID of the user (anonymized in public view).
        scenario_id: The scenario.
        score: Numerical score.
        verdict: Judge verdict.
        submitted_at: When the submission was made.
    """

    rank: int
    submission_id: str
    user_id: str
    scenario_id: str
    score: float
    verdict: JudgeVerdict
    submitted_at: datetime


@dataclass
class Scenario:
    """Information about an available scenario.

    Attributes:
        id: Unique scenario identifier.
        name: Human-readable name.
        description: Detailed description of the task.
        difficulty: Difficulty rating (1-5).
        time_limit: Maximum episode time in seconds.
        observation_space: Description of observation structure.
        action_space: Description of action structure.
    """

    id: str
    name: str
    description: str
    difficulty: int
    time_limit: float
    observation_space: dict[str, Any]
    action_space: dict[str, Any]
