from pydantic import BaseModel
from typing import Optional

class SetPublicKey(BaseModel):
    public_key: str
    
class RefreshRequest(BaseModel):
    refresh_token: str

class LoginRequest(BaseModel):
    username: str
    password: str
    totp_code: Optional[str] = None

class SetupAccount(BaseModel):
    first_name: str
    last_name: str
    public_key: str
    encrypted_private_key: str
    
class UserPublic(BaseModel):
    id: int
    username: str
    first_name: Optional[str] = None
    last_name: Optional[str] = None
    public_key: Optional[str] = None

    class Config:
        from_attributes = True


class UpdateMe(BaseModel):
    username: Optional[str] = None
    first_name: Optional[str] = None
    last_name: Optional[str] = None
    phone: Optional[str] = None
    email: Optional[str] = None
    about: Optional[str] = None

class UpdateEncryptedPrivateKey(BaseModel):
    encrypted_private_key: str

class ChangePassword(BaseModel):
    current_password: str
    new_password: str

class UpdatePrivacySettings(BaseModel):
    show_email: Optional[bool] = None
    show_phone: Optional[bool] = None
    show_avatar: Optional[bool] = None
    show_about: Optional[bool] = None
    show_username: Optional[bool] = None
    show_last_online: Optional[bool] = None

class TOTPVerifyRequest(BaseModel):
    code: str

class UserProfile(BaseModel):
    id: int
    username: Optional[str] = None
    first_name: Optional[str] = None
    last_name: Optional[str] = None
    about: Optional[str] = None
    phone: Optional[str] = None
    email: Optional[str] = None
    avatar_url: Optional[str] = None
    public_key: Optional[str] = None
    online: bool = False
    last_online: Optional[str] = None
    show_avatar: bool = False
    totp_enabled: bool = False

    class Config:
        from_attributes = True
