"""Schemas for the public templates gallery. No auth required."""

from datetime import datetime
from typing import Any
from uuid import UUID

from pydantic import BaseModel


class PublicFlowTemplate(BaseModel):
    id: UUID
    name: str
    description: str | None = None
    category: str | None = None
    tree_type: str
    step_count: int
    usage_count: int
    success_rate: float | None = None
    tags: list[str] = []
    preview_structure: dict[str, Any] | None = None
    created_at: datetime

    model_config = {"from_attributes": True}


class PublicScriptTemplate(BaseModel):
    id: UUID
    name: str
    description: str | None = None
    category_name: str | None = None
    category_icon: str | None = None
    complexity: str | None = None
    tags: list[str] = []
    parameter_count: int = 0
    requires_elevation: bool = False
    requires_modules: list[str] = []
    usage_count: int = 0
    is_verified: bool = False
    created_at: datetime

    model_config = {"from_attributes": True}


class PublicGalleryResponse(BaseModel):
    flow_templates: list[PublicFlowTemplate]
    script_templates: list[PublicScriptTemplate]
    total_flows: int
    total_scripts: int
    categories: list[str]
    domains: list[str]


class PublicFlowDetail(BaseModel):
    id: UUID
    name: str
    description: str | None = None
    category: str | None = None
    tree_type: str
    step_count: int
    usage_count: int
    success_rate: float | None = None
    tags: list[str] = []
    preview_structure: dict[str, Any] | None = None
    created_at: datetime

    model_config = {"from_attributes": True}


class PublicScriptDetail(BaseModel):
    id: UUID
    name: str
    description: str | None = None
    category_name: str | None = None
    complexity: str | None = None
    tags: list[str] = []
    parameters: list[dict[str, Any]] = []
    requires_elevation: bool = False
    requires_modules: list[str] = []
    usage_count: int = 0
    is_verified: bool = False
    created_at: datetime

    model_config = {"from_attributes": True}
