"""Notes request schemas."""

from __future__ import annotations

from pydantic import BaseModel, Field, field_validator


class NotesGenerateRequest(BaseModel):
    """Optional payload for /notes/generate."""

    engagement_id: int | None = Field(default=None, ge=1)
    include_vault: bool = False
    vault_query: str | None = Field(default=None, max_length=600)
    notes_provider_targets: list[str] | None = None

    @field_validator("vault_query")
    @classmethod
    def _normalize_query(cls, value: str | None) -> str | None:
        if value is None:
            return None
        text = value.strip()
        return text or None

    @field_validator("notes_provider_targets")
    @classmethod
    def _normalize_targets(cls, value: list[str] | None) -> list[str] | None:
        if value is None:
            return None
        normalized: list[str] = []
        for item in value:
            text = str(item or "").strip().lower()
            if text and text not in normalized:
                normalized.append(text)
        return normalized or None
