"""Pydantic schemas for the update API."""

from pydantic import BaseModel, Field


class UpdateReleaseInfo(BaseModel):
    version: str
    tag: str
    name: str
    body: str
    prerelease: bool
    published_at: str


class UpdateStatusResponse(BaseModel):
    current_version: str
    has_update: bool
    checking: bool
    last_check: float | None
    last_error: str | None
    releases_url: str
    install_type: str
    can_auto_update: bool
    downloading: bool
    download_progress: float
    applying: bool
    release: UpdateReleaseInfo | None
    dismissed_version: str


class UpdateSettingsResponse(BaseModel):
    enabled: bool
    check_interval_hours: float
    include_prerelease: bool


class UpdateSettingsRequest(BaseModel):
    enabled: bool
    check_interval_hours: float = Field(ge=0.5, le=168)
    include_prerelease: bool


class DismissRequest(BaseModel):
    version: str
