"""X (Twitter) account domain model — Pydantic v2 with ORM compatibility."""

from __future__ import annotations

import uuid
from datetime import datetime
from typing import Any

from repo_core.base.models import DomainModel


class XAccount(DomainModel):
    """X (Twitter) account entity — Pydantic representation.

    Built with ``from_attributes=True`` so it can be constructed directly
    from SQLAlchemy ORM objects or database rows.

    Example::

        {
            "id": "<uuid>",
            "username": "Baran683065",
            "password": "encrypted...",
            "email": "user@example.com",
            "account_id": "1234567890",
            "viewport": {"width": 1920, "height": 1080},
            "timezone": "America/New_York",
            "locale": "en-US",
            "geolocation": {"latitude": 40.7128, "longitude": -74.0060},
            "proxy_region": "US-NY",
            "status": "active",
        }
    """

    id: uuid.UUID
    username: str
    password: str
    email: str | None = None
    mobile: str | None = None
    account_id: str | None = None
    display_name: str | None = None
    viewport: dict[str, Any] = {"width": 1920, "height": 1080}
    timezone: str = "UTC"
    locale: str = "en-US"
    geolocation: dict[str, Any] | None = None
    proxy_region: str | None = None
    account_metadata: dict[str, Any] = {}
    status: str = "active"
    last_active_at: datetime | None = None
    created_at: datetime | None = None
    updated_at: datetime | None = None

    @property
    def platform(self) -> str:
        return "x"

