"""Pydantic models for service guide APIs."""

from __future__ import annotations

from typing import Any

from pydantic import BaseModel, Field

from app.schemas.service_guide_profile import StandardServiceGuideProfile


class ServiceGuideListItem(BaseModel):
    profile_id: str
    doc_id: str
    matter_name: str
    colloquial_names: list[str] = Field(default_factory=list)
    implementation_code: str = ""
    matter_version: str = ""
    handled_org_names: list[str] = Field(default_factory=list)
    region_names: list[str] = Field(default_factory=list)
    express_supported: bool | None = None
    reservation_supported: bool | None = None
    needs_review: bool = False


class ServiceGuideListResponse(BaseModel):
    total: int
    page: int
    page_size: int
    items: list[ServiceGuideListItem] = Field(default_factory=list)


class ServiceGuideDetailResponse(BaseModel):
    profile_id: str
    doc_id: str
    scene_type: str
    guide_version: str = ""
    profile: StandardServiceGuideProfile = Field(
        ...,
        description="完整的 StandardServiceGuideProfile 结构化详情对象；首批稳定字段强类型，保留扩展字段兼容性。",
    )


class ServiceGuideExtractPreviewResponse(BaseModel):
    detected: bool
    detection_confidence: float = 0.0
    profile: StandardServiceGuideProfile | None = Field(
        None,
        description="抽取得到的 StandardServiceGuideProfile 预览对象；首批稳定字段强类型，保留扩展字段兼容性。",
    )
    quality: dict[str, Any] = Field(default_factory=dict)
    warnings: list[str] = Field(default_factory=list)