from __future__ import annotations

from typing import Any, List, Optional

from pydantic import BaseModel, ConfigDict, Field


class LaboratorioBase(BaseModel):
    nome: str = Field(min_length=1, max_length=255, description="Nome do laboratório")


class LaboratorioCreate(LaboratorioBase):
    pass


class LaboratorioUpdate(BaseModel):
    nome: str | None = Field(default=None, min_length=1, max_length=255)


class LaboratorioOut(BaseModel):
    id: str
    nome: str
    produtos_catalogo: Optional[Any] = None
    createdAt: str
    updatedAt: str

    model_config = ConfigDict(
        json_schema_extra={
            "example": {
                "id": "66fd0abca1f0xxxxxx",
                "nome": "Pfizer",
                "produtos_catalogo": None,
                "createdAt": "2025-10-01T12:00:00.000Z",
                "updatedAt": "2025-10-01T12:00:00.000Z"
            }
        }
    )


class PaginatedLaboratorios(BaseModel):
    items: List[LaboratorioOut]
    total: int

    model_config = ConfigDict(
        json_schema_extra={
            "example": {
                "items": [
                    {
                        "id": "66fd0abca1f0xxxxxx",
                        "nome": "Pfizer",
                        "produtos_catalogo": None,
                        "createdAt": "2025-10-01T12:00:00.000Z",
                        "updatedAt": "2025-10-01T12:00:00.000Z"
                    }
                ],
                "total": 1
            }
        }
    )
