"""Filter-related schemas."""

from typing import Any, Dict, List, Optional

from pydantic import BaseModel, Field


class FilterInstanceSchema(BaseModel):
    """A single filter instance with its configuration."""

    filter_id: str = Field(description="Filter type identifier")
    options: Dict[str, Any] = Field(default_factory=dict, description="Filter-specific options")


class FilterOptionDefSchema(BaseModel):
    """Describes a configurable option for a filter type."""

    key: str = Field(description="Option key")
    label: str = Field(description="Display label")
    type: str = Field(description="Option type (float, int, bool, select, or string)")
    default: Any = Field(description="Default value")
    min_value: Any = Field(description="Minimum value")
    max_value: Any = Field(description="Maximum value")
    step: Any = Field(description="Step increment")
    choices: Optional[List[Dict[str, str]]] = Field(default=None, description="Available choices for select type")
    max_length: Optional[int] = Field(default=None, description="Maximum string length for string type")


class FilterTypeResponse(BaseModel):
    """Available filter type with its options schema."""

    filter_id: str = Field(description="Filter type identifier")
    filter_name: str = Field(description="Display name")
    options_schema: List[FilterOptionDefSchema] = Field(description="Configurable options")


class FilterTypeListResponse(BaseModel):
    """List of available filter types."""

    filters: List[FilterTypeResponse] = Field(description="Available filter types")
    count: int = Field(description="Number of filter types")
