import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Box, Text } from 'ink';
import { Colors } from '../../colors.js';
export const HooksList = ({ hooks }) => {
    if (hooks.length === 0) {
        return _jsx(Text, { color: Colors.Foreground, children: "No hooks configured." });
    }
    // Group hooks by event name
    const byEvent = new Map();
    for (const entry of hooks) {
        const eventName = entry.eventName;
        if (!byEvent.has(eventName)) {
            byEvent.set(eventName, []);
        }
        byEvent.get(eventName).push(entry);
    }
    return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, children: [Array.from(byEvent.entries()).map(([eventName, entries]) => (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Text, { color: Colors.AccentCyan, bold: true, children: eventName }), _jsx(Box, { flexDirection: "column", paddingLeft: 2, children: entries.map((entry, index) => {
                            const commandName = entry.config.name ||
                                entry.config.command ||
                                `${entry.config.type} hook`;
                            const statusColor = entry.enabled
                                ? Colors.AccentGreen
                                : Colors.DimComment;
                            const statusText = entry.enabled ? 'enabled' : 'disabled';
                            const details = [];
                            details.push(entry.source);
                            // Show command separately when name exists
                            if (entry.config.name && entry.config.command) {
                                details.push(`command: ${entry.config.command}`);
                            }
                            if (entry.matcher) {
                                details.push(`matcher: ${entry.matcher}`);
                            }
                            if (entry.sequential) {
                                details.push('sequential');
                            }
                            if (entry.config.timeout) {
                                details.push(`timeout: ${entry.config.timeout}ms`);
                            }
                            return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: Colors.AccentYellow, children: commandName }), _jsxs(Text, { color: statusColor, children: [" [", statusText, "]"] })] }), entry.config.description && (_jsx(Text, { color: Colors.DimComment, italic: true, children: entry.config.description })), _jsx(Text, { color: Colors.DimComment, children: details.join(' • ') })] }, `${eventName}-${index}`));
                        }) })] }, eventName))), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: Colors.DimComment, children: "Tip: Use /hooks enable <name> or /hooks disable <name> to manage hooks" }) })] }));
};
//# sourceMappingURL=HooksList.js.map