from __future__ import annotations

from datetime import datetime
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field


class QualifyRequest(BaseModel):
    within_mandate: bool = False
    affected_count: int | None = Field(default=None, ge=2, description="Nombre de personnes concernées (minimum 2)")
    is_structural: bool = False
    context_description: str | None = Field(default=None, max_length=2000)


class QualifyResponse(BaseModel):
    decision_type: str
    process: str
    recommended_modalities: list[str]
    recommend_onchain: bool
    onchain_reason: str | None
    confidence: str
    collective_available: bool
    record_in_observatory: bool
    reasons: list[str]


class QualificationProtocolOut(BaseModel):
    model_config = ConfigDict(from_attributes=True)

    id: UUID
    name: str
    description: str | None = None
    small_group_max: int
    collective_wot_min: int
    default_modalities: list[str]
    is_active: bool
    created_at: datetime


class QualificationProtocolCreate(BaseModel):
    name: str = Field(..., min_length=1, max_length=128)
    description: str | None = None
    small_group_max: int = Field(default=5, ge=1)
    collective_wot_min: int = Field(default=50, ge=1)
    default_modalities: list[str] = Field(
        default=["vote_wot", "vote_smith", "consultation_avis", "election"]
    )
