"""Telegram account domain — model, schemas, and repository."""

from repo_core.domains.telegram.account.model import TelegramAccount
from repo_core.domains.telegram.account.schema import (
    AccountCreateRequest,
    AccountResponse,
    AccountListResponse,
    AccountMetadataUpdateRequest,
    AccountProfileUpdateRequest,
    PlatformManagerUpdateRequest,
    AccountStatusUpdateRequest,
    SessionResponse,
    AccountHealthResponse,
    TelegramChannelInput,
    TelegramChannelPreviewResponse,
    TelegramJoinResponse,
    TelegramLeaveResponse,
    TelegramChannelListResponse,
    TelegramChannelInfo,
    TelegramRecentPostResponse,
    TelegramReactionDetailResponse,
    # Global (cross-account) channel schemas
    AssignedAccountInfo,
    GlobalChannelInfo,
    GlobalChannelListResponse,
    GlobalChannelDetailResponse,
    AccountLeaveResult,
    GlobalChannelDeleteResponse,
)
from repo_core.domains.telegram.account.repository import TelegramAccountRepository

__all__ = [
    "TelegramAccount",
    "AccountCreateRequest",
    "AccountResponse",
    "AccountListResponse",
    "AccountMetadataUpdateRequest",
    "AccountProfileUpdateRequest",
    "PlatformManagerUpdateRequest",
    "AccountStatusUpdateRequest",
    "SessionResponse",
    "AccountHealthResponse",
    "TelegramChannelInput",
    "TelegramChannelPreviewResponse",
    "TelegramJoinResponse",
    "TelegramLeaveResponse",
    "TelegramChannelListResponse",
    "TelegramChannelInfo",
    "TelegramRecentPostResponse",
    "TelegramReactionDetailResponse",
    "AssignedAccountInfo",
    "GlobalChannelInfo",
    "GlobalChannelListResponse",
    "GlobalChannelDetailResponse",
    "AccountLeaveResult",
    "GlobalChannelDeleteResponse",
    "TelegramAccountRepository",
]


def create_repository() -> TelegramAccountRepository:
    """Create a TelegramAccountRepository auto-wired from environment variables.

    Requires PostgreSQL env vars (DATABASE_URL, or PG_HOST/PG_PORT/PG_DATABASE).

    Usage::

        repo = create_repository()
        async with repo:
            accounts = await repo.list_all(20, 0)
    """
    return TelegramAccountRepository(model=TelegramAccount)
