"""
Son of Anton v4.2.0 — Configuration
"""

import os

APP_VERSION = "4.2.0"

# ═══════════════════════════════════════════════════
#  AWS Bedrock
# ═══════════════════════════════════════════════════
BEDROCK_API_KEY = os.getenv("BEDROCK_API_KEY", "")
AWS_REGION = os.getenv("AWS_REGION", "eu-central-1")
BEDROCK_ENDPOINT = f"https://bedrock-runtime.{AWS_REGION}.amazonaws.com"

# Models
PRIMARY_MODEL = os.getenv("PRIMARY_MODEL", "eu.anthropic.claude-opus-4-6-v1")
FAST_MODEL = os.getenv("FAST_MODEL", "eu.anthropic.claude-haiku-4-5-20251001-v1:0")

AVAILABLE_MODELS = [
    {"id": "eu.anthropic.claude-opus-4-6-v1", "label": "Opus 4.6", "tier": "expensive"},
    {"id": "eu.anthropic.claude-haiku-4-5-20251001-v1:0", "label": "Haiku 4.5", "tier": "cheap"},
]

# ═══════════════════════════════════════════════════
#  Auth
# ═══════════════════════════════════════════════════
JWT_SECRET = os.getenv("JWT_SECRET", "CreatedSystemsOverloadedFunctionsBySonOfAnton")
SUPERADMIN_PASSWORD = os.getenv("SUPERADMIN_PASSWORD", "admin123")

# ═══════════════════════════════════════════════════
#  Database
# ═══════════════════════════════════════════════════
DATABASE_URL = os.getenv("DATABASE_URL", "sqlite:////data/sonofanton.db")

# ═══════════════════════════════════════════════════
#  Quotas & Uploads
# ═══════════════════════════════════════════════════
DEFAULT_QUOTA = int(os.getenv("DEFAULT_QUOTA", "2000000"))
MAX_UPLOAD_MB = int(os.getenv("MAX_UPLOAD_MB", "50"))
MAX_UPLOAD_BYTES = MAX_UPLOAD_MB * 1024 * 1024
MAX_ATTACHMENT_BYTES = MAX_UPLOAD_BYTES

# ═══════════════════════════════════════════════════
#  Attachments
# ═══════════════════════════════════════════════════
ATTACHMENT_PATH = os.getenv("ATTACHMENT_PATH", "/data/uploads/chat_attachments")
MAX_IMAGE_DIMENSION = 2048
MAX_VIDEO_FRAMES = 6

# ═══════════════════════════════════════════════════
#  ChromaDB / RAG
# ═══════════════════════════════════════════════════
CHROMADB_PATH = os.getenv("CHROMADB_PATH", "/data/chromadb")

# ═══════════════════════════════════════════════════
#  Web Search (SerpAPI)
# ═══════════════════════════════════════════════════
SERPAPI_KEY = os.getenv("SERPAPI_KEY", "")

# ═══════════════════════════════════════════════════
#  App-level defaults
# ═══════════════════════════════════════════════════
REGISTRATION_ENABLED_DEFAULT = os.getenv("REGISTRATION_ENABLED", "true").lower() in ("true", "1", "yes")

# ═══════════════════════════════════════════════════
#  PERMISSION DEFAULTS — applied to new regular users
# ═══════════════════════════════════════════════════
DEFAULT_PERMISSIONS = {
    "can_use_web_search": False,
    "can_use_ui_design": False,
    "can_use_knowledge_base": True,
    "can_use_gitlab": False,
    "can_use_attachments": True,
    "can_export_pptx": True,
    "can_export_docx": True,
    "allowed_models": "eu.anthropic.claude-haiku-4-5-20251001-v1:0",
    "max_tokens_cap": 4096,
    "max_reasoning_budget": 0,
    "max_chats": 50,
    "max_messages_per_day": 100,
    "max_knowledge_bases": 3,
    "max_documents_per_kb": 20,
    "max_attachment_size_mb": 10,
    "max_attachments_per_message": 5,
}

SUPERADMIN_PERMISSIONS = {
    "can_use_web_search": True,
    "can_use_ui_design": True,
    "can_use_knowledge_base": True,
    "can_use_gitlab": True,
    "can_use_attachments": True,
    "can_export_pptx": True,
    "can_export_docx": True,
    "allowed_models": "all",
    "max_tokens_cap": 65536,
    "max_reasoning_budget": 32000,
    "max_chats": 0,
    "max_messages_per_day": 0,
    "max_knowledge_bases": 0,
    "max_documents_per_kb": 0,
    "max_attachment_size_mb": 50,
    "max_attachments_per_message": 20,
}

PERMISSION_FIELDS = list(DEFAULT_PERMISSIONS.keys())