import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
import { Box, Text } from "ink";
export function CommandSuggestions(props) {
    if (props.items.length === 0) {
        return null;
    }
    const maxRows = 8;
    const startIndex = Math.max(0, Math.min(props.selectedIndex - Math.floor(maxRows / 2), Math.max(0, props.items.length - maxRows)));
    const visibleItems = props.items.slice(startIndex, startIndex + maxRows);
    const endIndex = startIndex + visibleItems.length;
    const selectedItem = props.items[props.selectedIndex] ?? props.items[0];
    const hasPreview = Boolean(selectedItem);
    return (_jsxs(Box, { borderStyle: "round", borderColor: "cyan", flexDirection: "column", paddingX: 1, height: Math.min(maxRows, props.items.length) + (hasPreview ? 7 : 4), overflowY: "hidden", children: [_jsxs(Text, { color: "gray", children: ["Command palette  use up/down to pick, Enter to apply, Escape to clear. ", startIndex + 1, "-", endIndex, "/", props.items.length] }), _jsxs(Box, { marginTop: 1, children: [_jsx(Text, { color: "cyan", bold: true, children: "Commands" }), _jsx(Text, { color: "gray", children: " grouped by category" })] }), visibleItems.map((item, index) => {
                const absoluteIndex = startIndex + index;
                const isSelected = absoluteIndex === props.selectedIndex;
                return (_jsxs(Box, { marginTop: index === 0 ? 1 : 0, children: [_jsx(Box, { width: 2, children: _jsx(Text, { color: isSelected ? "cyan" : "gray", children: isSelected ? ">" : " " }) }), _jsx(Box, { width: 13, children: _jsx(Text, { color: isSelected ? "cyan" : "gray", bold: isSelected, children: formatCategory(item.category) }) }), _jsx(Box, { width: 32, children: _jsx(Text, { color: isSelected ? "white" : "cyan", bold: isSelected, wrap: "truncate", children: item.label }) }), _jsxs(Text, { color: isSelected ? "white" : "gray", wrap: "truncate", children: [item.detail, item.hint ? `  ${item.hint}` : ""] })] }, item.key));
            }), selectedItem ? (_jsxs(Box, { marginTop: 1, borderStyle: "single", borderColor: "gray", paddingX: 1, flexDirection: "column", children: [_jsx(Text, { color: "cyan", bold: true, children: selectedItem.label }), _jsx(Text, { color: "white", wrap: "truncate", children: selectedItem.detail }), _jsx(Text, { color: "gray", wrap: "truncate", children: selectedItem.hint ?? previewForCommand(selectedItem) })] })) : null] }));
}
function formatCategory(category) {
    return category.length > 11 ? category.slice(0, 11) : category;
}
function previewForCommand(item) {
    if (item.label.startsWith("/models") || item.label.startsWith("/model")) {
        return "Preview: load provider models, filter by query, then select.";
    }
    if (item.label.startsWith("/sessions") || item.label.startsWith("/resume")) {
        return "Preview: inspect saved workspace session history.";
    }
    if (item.label.startsWith("/connect") || item.label.startsWith("/hosts")) {
        return "Preview: choose local, LAN, Tailscale, or manual Ollama host.";
    }
    if (item.label.startsWith("/doctor")) {
        return "Preview: check runtime, git, provider auth, and bridge setup.";
    }
    if (item.label.startsWith("/experimental")) {
        return "Preview: toggle file analysis, memory, and subagent features.";
    }
    return `Preview: ${item.category} command`;
}
//# sourceMappingURL=CommandSuggestions.js.map