'use client';

import React from 'react';
import { Button, Tooltip } from 'antd';
import { HelpCircle } from 'lucide-react';
import { ICON_SIZE_MD } from '@/components/icons';
import {
    KeyboardShortcutsHelpModal,
    type KeyboardShortcutHelpItem,
} from '@/components/keyboard/KeyboardShortcutsHelpModal';

export type ProjetosShortcutsHelpProps = {
    items: KeyboardShortcutHelpItem[];
    open: boolean;
    onOpenChange: (open: boolean) => void;
    title?: string;
    intro?: string;
};

/**
 * Botão + modal de atalhos documentados in-app (listagem / sprints).
 */
export function ProjetosShortcutsHelp({
    items,
    open,
    onOpenChange,
    title,
    intro,
}: ProjetosShortcutsHelpProps) {
    return (
        <>
            <Tooltip title="Atalhos de teclado (?)">
                <Button
                    type="text"
                    aria-label="Ver atalhos de teclado"
                    data-testid="projetos-shortcuts-help-trigger"
                    icon={<HelpCircle size={ICON_SIZE_MD} aria-hidden />}
                    onClick={() => onOpenChange(true)}
                />
            </Tooltip>
            <KeyboardShortcutsHelpModal
                open={open}
                onClose={() => onOpenChange(false)}
                title={title}
                intro={intro}
                items={items}
                data-testid="projetos-shortcuts-help-modal"
            />
        </>
    );
}

export const PROJETOS_LIST_SHORTCUT_ITEMS: KeyboardShortcutHelpItem[] = [
    { keys: '/', label: 'Focar busca (abre filtros)' },
    { keys: 'Ctrl+Shift+F', label: 'Abrir filtros' },
    { keys: 'Ctrl+N', label: 'Novo projeto (com permissão)' },
    { keys: '?', label: 'Mostrar esta ajuda' },
];

export const PROJETOS_SPRINTS_LIST_SHORTCUT_ITEMS: KeyboardShortcutHelpItem[] = [
    { keys: '/', label: 'Focar busca de sprints (abre filtros)' },
    { keys: '?', label: 'Mostrar esta ajuda' },
    { keys: 'Opções', label: 'Fixar / desafixar Minha sprint (menu da linha)' },
];

export const PROJETOS_SPRINTS_SHORTCUT_ITEMS: KeyboardShortcutHelpItem[] = [
    ...PROJETOS_SPRINTS_LIST_SHORTCUT_ITEMS,
    { keys: 'P', label: 'Fixar / desafixar sprint (no detalhe ou board)' },
];

export const PROJETOS_SPRINT_DETALHE_SHORTCUT_ITEMS: KeyboardShortcutHelpItem[] = [
    { keys: 'P', label: 'Fixar / desafixar esta sprint' },
    { keys: '?', label: 'Mostrar esta ajuda' },
];
