from pydantic import BaseModel
from typing import List, Dict, Any


class PresetModel(BaseModel):
    filename: str
    mode: str
    start_freq: float | None
    stop_freq: float | None
    points: int | None
    bandwidth: float | None


class CalibrationModel(BaseModel):
    name: str
    is_complete: bool
    standards: Dict[str, bool]


class SettingsStatusModel(BaseModel):
    current_preset: PresetModel | None
    current_calibration: Dict[str, Any] | None
    working_calibration: Dict[str, Any] | None
    available_presets: int
    available_calibrations: int
    available_references: int


class SetPresetRequest(BaseModel):
    filename: str


class StartCalibrationRequest(BaseModel):
    preset_filename: str | None = None


class CalibrateStandardRequest(BaseModel):
    standard: str


class SaveCalibrationRequest(BaseModel):
    name: str


class SetCalibrationRequest(BaseModel):
    name: str
    preset_filename: str | None = None


class RemoveStandardRequest(BaseModel):
    standard: str


class WorkingCalibrationModel(BaseModel):
    active: bool
    preset: str | None = None
    progress: str | None = None
    is_complete: bool | None = None
    completed_standards: List[str] | None = None
    missing_standards: List[str] | None = None


# Reference models
class ReferenceModel(BaseModel):
    name: str
    timestamp: str
    preset_filename: str
    description: str
    metadata: Dict[str, Any]


class CreateReferenceRequest(BaseModel):
    name: str
    description: str = ""
    metadata: Dict[str, Any] = {}
    preset_filename: str | None = None


class SetReferenceRequest(BaseModel):
    name: str
    preset_filename: str | None = None
