"""15code promotional content — single source of truth for branding."""
from __future__ import annotations

import random
from typing import Any


# ── Core brand constants ──────────────────────────────────────────────────
BRAND: dict[str, Any] = {
    "name":          "15code Verify",
    "vendor":        "15code",
    "tagline_zh":    "让 LLM 世界更透明",
    "tagline_en":    "Making the LLM world transparent",

    # Main site
    "main_url":      "https://15code.com",
    "verify_url":    "https://verify.15code.com",
    "github_url":    "https://github.com/15code/verify",
    "docs_url":      "https://verify.15code.com/docs",
    "leaderboard":   "https://verify.15code.com/leaderboard",
    "download_url":  "https://verify.15code.com/download",

    # 15code's own services (ad targets)
    "api_console":   "https://15code.com/console",
    "pricing_url":   "https://15code.com/pricing",
    "signup_url":    "https://15code.com/signup?ref=verify",
    "discord":       "https://discord.gg/15code",

    # Social
    "x_handle":      "@15code_ai",
    "email":         "hello@15code.com",
}


# ── Rotating promo messages ───────────────────────────────────────────────
# Shown in CLI footer / Web banners / Report footers.
# Kept short, respectful, and always clearly marked as "from 15code".
_PROMO_MESSAGES: list[dict[str, str]] = [
    {
        "zh": "这个免费工具由 15code 出品。想用一个信得过的 LLM 服务？试试 15code 官方平台。",
        "en": "This free tool is made by 15code. Want an LLM service you can trust? Try 15code.",
        "cta": "15code.com",
    },
    {
        "zh": "15code 自家服务也在本工具的公开榜单上，欢迎监督对比。",
        "en": "15code's own service is on the public leaderboard too — hold us accountable.",
        "cta": "verify.15code.com/leaderboard",
    },
    {
        "zh": "觉得有用？在 GitHub 给个 Star，帮助更多人识破掺水服务。",
        "en": "Find this useful? Star us on GitHub — help more people spot adulterated services.",
        "cta": "github.com/15code/verify",
    },
    {
        "zh": "想集成到自己的监控系统？15code Verify 提供免费 API。",
        "en": "Want to integrate with your monitoring? 15code Verify offers a free API.",
        "cta": "verify.15code.com/docs",
    },
    {
        "zh": "15code 提供 Claude / GPT / Gemini 等主流模型的统一 API 网关，按官方价计费，零套路。",
        "en": "15code offers a unified API gateway for Claude / GPT / Gemini — official pricing, no tricks.",
        "cta": "15code.com/pricing",
    },
]


def get_promo_rotation(lang: str = "zh") -> dict[str, str]:
    """Return a random promo message (stable per day if seeded)."""
    msg = random.choice(_PROMO_MESSAGES)
    return {"text": msg[lang], "cta": msg["cta"]}


# ── CLI banners ───────────────────────────────────────────────────────────
def cli_header_banner() -> str:
    return (
        "╭──────────────────────────────────────────────────────────────╮\n"
        "│  [bold cyan]15code Verify[/bold cyan] — LLM provider integrity check        │\n"
        "│  [dim]free · open-source · made by 15code[/dim]                     │\n"
        f"│  [dim]🌐 {BRAND['verify_url']:45}[/dim] │\n"
        "╰──────────────────────────────────────────────────────────────╯"
    )


def cli_footer_banner(lang: str = "zh") -> str:
    promo = get_promo_rotation(lang)
    return (
        "\n[dim]─────────────────────────────────────────────────────[/dim]\n"
        f"[cyan]♥ {promo['text']}[/cyan]\n"
        f"[dim]→ {promo['cta']}[/dim]\n"
        f"[dim]Share this report · Help others · Star us on GitHub[/dim]\n"
        f"[dim]{BRAND['github_url']}[/dim]"
    )


# ── Report footers ────────────────────────────────────────────────────────
def report_disclaimer_full(lang: str = "zh") -> str:
    if lang == "zh":
        return (
            "本报告反映特定时间点的技术指标观测，不构成对服务商的法律评价或"
            "商业决策建议。方法论见 docs/PROBE_DESIGN.md。\n"
            f"—— 由 {BRAND['name']} 生成 · {BRAND['verify_url']}"
        )
    return (
        "This report reflects technical observations at a specific point in time and "
        "does not constitute a legal evaluation or business recommendation. "
        f"See methodology at docs/PROBE_DESIGN.md.\n— Generated by {BRAND['name']} · {BRAND['verify_url']}"
    )


def report_footer_html(lang: str = "zh") -> str:
    """HTML footer for shared report pages (for social preview / PDF export)."""
    promo = get_promo_rotation(lang)
    return (
        '<div style="border-top:1px solid #333;margin-top:2rem;padding:1rem;'
        'text-align:center;font-size:13px;color:#888;">'
        f'  <div style="margin-bottom:.5rem;">'
        f'    Generated by <a href="{BRAND["verify_url"]}" '
        f'style="color:#ff6a00;">{BRAND["name"]}</a> · '
        f'    <a href="{BRAND["github_url"]}" style="color:#888;">GitHub</a>'
        '  </div>'
        f'  <div style="color:#ff6a00;">♥ {promo["text"]}</div>'
        f'  <div><a href="https://{promo["cta"]}" style="color:#ff6a00;">→ {promo["cta"]}</a></div>'
        '</div>'
    )


def get_all_links() -> dict[str, str]:
    """All canonical links for embedding in any client."""
    return {k: v for k, v in BRAND.items() if isinstance(v, str) and v.startswith("http")}
