from __future__ import annotations

from datetime import datetime

from pydantic import BaseModel, Field

from app.schemas.user import UserProfile


class SendSmsRequest(BaseModel):
    phone: str = Field(min_length=11, max_length=20)
    captchaId: str | None = Field(default=None, min_length=1, max_length=100)
    captchaCode: str | None = Field(default=None, min_length=4, max_length=8)


class LoginRequest(BaseModel):
    phone: str = Field(min_length=11, max_length=20)
    code: str = Field(min_length=4, max_length=8)


class LoginResponse(BaseModel):
    token: str
    expiredAt: datetime
    user: UserProfile
    returnUrl: str | None = None


class CaptchaResponse(BaseModel):
    captchaId: str
    imageBase64: str
    expiresInSeconds: int
