from typing import Any

from pydantic import BaseModel, EmailStr, Field


class RegisterRequest(BaseModel):
    email: EmailStr
    password: str = Field(min_length=6, max_length=128)


class LoginRequest(BaseModel):
    email: EmailStr
    password: str


class ProfileUpdate(BaseModel):
    firstname: str = ""
    lastname: str = ""
    patronymic: str = ""
    age: int | None = Field(default=None, ge=18, le=120)
    phone: str = ""


class RobotSettingsUpdate(BaseModel):
    settings: dict[str, Any]


class RobotsBulkUpdate(BaseModel):
    robots: list[dict[str, Any]]
    selected_robot_id: str | None = None


class ExternalDataWrite(BaseModel):
    user_id: int | None = None
    source_app: str = Field(min_length=1, max_length=100)
    data_key: str = Field(min_length=1, max_length=100)
    data_value: dict[str, Any]


class UserPublic(BaseModel):
    id: int
    email: str
    firstname: str
    lastname: str
    patronymic: str
    age: int | None
    phone: str
    rating: float
    points: int
    selected_robot_id: str
