# adapter/telegram/keyboards/settings.py
from __future__ import annotations

from aiogram.types import InlineKeyboardButton, InlineKeyboardMarkup

from sdk.interface import UserSettings


def settings_main_keyboard() -> InlineKeyboardMarkup:
    return InlineKeyboardMarkup(inline_keyboard=[
        [
            InlineKeyboardButton(text="🧩 Скиллы",       callback_data="settings:skills"),
            InlineKeyboardButton(text="🔗 Коннекторы",   callback_data="settings:connectors"),
        ],
        [
            InlineKeyboardButton(text="🧠 Личность",     callback_data="settings:soul"),
            InlineKeyboardButton(text="🔒 Безопасность", callback_data="settings:safety"),
        ],
        [
            InlineKeyboardButton(text="💳 Подписка",     callback_data="settings:plan"),
        ],
    ])


def skills_keyboard(skills: dict[str, bool]) -> InlineKeyboardMarkup:
    buttons = []
    for skill, enabled in skills.items():
        icon = "✅" if enabled else "❌"
        buttons.append([InlineKeyboardButton(
            text=f"{icon} {skill}",
            callback_data=f"toggle_skill:{skill}",
        )])
    buttons.append([InlineKeyboardButton(text="← Назад", callback_data="settings:back")])
    return InlineKeyboardMarkup(inline_keyboard=buttons)


def safety_keyboard(safety: dict[str, bool]) -> InlineKeyboardMarkup:
    buttons = []
    for trigger, enabled in safety.items():
        icon = "✅" if enabled else "❌"
        buttons.append([InlineKeyboardButton(
            text=f"{icon} {trigger}",
            callback_data=f"toggle_safety:{trigger}",
        )])
    buttons.append([InlineKeyboardButton(text="← Назад", callback_data="settings:back")])
    return InlineKeyboardMarkup(inline_keyboard=buttons)


def back_keyboard() -> InlineKeyboardMarkup:
    return InlineKeyboardMarkup(inline_keyboard=[
        [InlineKeyboardButton(text="← Назад", callback_data="settings:back")],
    ])
