# core/handlers/settings.py
from __future__ import annotations

from core.protocol import IncomingCommand, OutgoingMessage, OutgoingUI, UIButton


async def handle_settings(event: IncomingCommand, auth_mgr, platform, chat_mgr, settings_mgr) -> list:
    return [OutgoingUI(
        chat_id=event.chat_id,
        text="⚙️ Настройки",
        buttons=[
            UIButton(label="🔗 Коннекторы",    action="settings_connectors", style="secondary"),
            UIButton(label="🧩 Скиллы",        action="settings_skills",     style="secondary"),
            UIButton(label="🧠 Личность",      action="settings_soul",       style="secondary"),
            UIButton(label="🔒 Безопасность",  action="settings_safety",     style="secondary"),
            UIButton(label="💳 Подписка",      action="settings_plan",       style="secondary"),
        ],
    )]


async def handle_settings_skills(event: IncomingCommand, auth_mgr, platform, chat_mgr, settings_mgr) -> list:
    s = await settings_mgr.get(event.user_id)
    lines = [("✅" if on else "❌") + f" {name}" for name, on in s.skills.items()]
    text = "🧩 Скиллы\n\n" + ("\n".join(lines) or "Нет доступных скиллов")
    return [OutgoingMessage(chat_id=event.chat_id, text=text)]
