from __future__ import annotations

from dataclasses import dataclass, field


@dataclass(slots=True)
class PermissionContext:
    """Normalized business permission context derived from Directus identity."""

    is_admin: bool = False
    can_manage_sites: bool = False
    can_manage_experiments: bool = False
    can_manage_variants: bool = False
    can_manage_releases: bool = False
    can_manage_goals: bool = False
    can_manage_sdk_configs: bool = False
    can_use_editor: bool = False
    can_read_runtime: bool = False
    raw_permissions: list[str] = field(default_factory=list)


@dataclass(slots=True)
class AuthenticatedPrincipal:
    id: str
    email: str | None = None
    first_name: str | None = None
    status: str | None = None
    fb_token: str | None = None
    role_id: str | None = None
    role_name: str | None = None
    user_group_id: str | None = None
    user_group_name: str | None = None
    domain_permissions: list[str] = field(default_factory=list)
    permissions: PermissionContext = field(default_factory=PermissionContext)

