from pydantic import BaseModel, Field


class CategoryCreateRequest(BaseModel):
    name: str = Field(min_length=1, max_length=100)
    parent_id: str | int | None = Field(default='all')


class CategoryUpdateRequest(BaseModel):
    name: str = Field(min_length=1, max_length=100)


class CleanRules(BaseModel):
    enabled: bool = False
    newton_interp: bool = False
    current_min: float | None = None
    current_max: float | None = None
    voltage_min: float | None = None
    voltage_max: float | None = None
    temperature_min: float | None = None
    temperature_max: float | None = None


class SmoothConfig(BaseModel):
    enabled: bool = False
    window: int = Field(default=5, ge=2, le=500)


class PackageUpdateRequest(BaseModel):
    name: str = Field(min_length=1, max_length=255)
    category_id: str | int | None = Field(default=None)
    remark: str | None = Field(default=None)


class PackageCreateRequest(BaseModel):
    name: str = Field(min_length=1, max_length=255)
    category_id: str | int | None = Field(default=None)
    remark: str | None = Field(default=None)
    file_ids: list[int] = Field(default_factory=list)
    clean_rules: CleanRules | None = Field(default=None)
    smooth: SmoothConfig | None = Field(default=None)
    auto_split: bool = Field(default=False)
    row_start: int | None = Field(default=None, ge=1)
    row_end: int | None = Field(default=None, ge=1)


class PreviewRequest(BaseModel):
    file_ids: list[int] = Field(default_factory=list)
    clean_rules: CleanRules | None = Field(default=None)
    smooth: SmoothConfig | None = Field(default=None)
    row_start: int | None = Field(default=None, ge=1)
    row_end: int | None = Field(default=None, ge=1)
