"""내보내기 API 스키마."""

from typing import Any, Optional

from pydantic import BaseModel


# ── JSON 프로젝트 내보내기 / 가져오기 ─────────────────────────────────────

class ProjectExportResponse(BaseModel):
    export_version: str
    exported_at: str
    project: dict[str, Any]
    members: list[dict[str, Any]]
    episodes: list[dict[str, Any]]
    entities: list[dict[str, Any]]
    entity_aliases: list[dict[str, Any]]
    relations: list[dict[str, Any]]
    relation_participants: list[dict[str, Any]]
    scene_stills: list[dict[str, Any]]
    entity_episode_links: list[dict[str, Any]]
    images: list[dict[str, Any]]
    world_guides: list[dict[str, Any]]
    webbook_packages: list[dict[str, Any]]
    generation_traces: list[dict[str, Any]]
    operation_logs: list[dict[str, Any]]


class ProjectImportRequest(BaseModel):
    data: dict[str, Any]       # the exported JSON blob
    new_name: Optional[str] = None  # optional name override


class ProjectImportResponse(BaseModel):
    project_id: str
    message: str


# ── 웹북 / PDF 내보내기 ────────────────────────────────────────────────────

class WebbookGenerateRequest(BaseModel):
    web_episode_count: int = 4
    sections_per_episode: int = 10


class ExportFileResponse(BaseModel):
    filename: str
    episode_id: str | None = None
    file_path: str
    size_bytes: int
    created_at: str


class PDFValidationResponse(BaseModel):
    text_readable: bool = False
    images_present: bool = False
    layout_correct: bool = False
    caption_visible: bool = False
    overall_quality: int = 0
    issues: list[str] = []
    pdf_path: str = ""
    pdf_filename: str = ""
    error: str | None = None
