import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Box, Text } from 'ink';
const MAX_VISIBLE_FILES = 8;
export function FileMentionPickerPanel({ query, suggestions, highlightedIndex, loading, error, }) {
    const { visibleSuggestions, startIndex } = getVisibleSuggestions(suggestions, highlightedIndex);
    return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Text, { dimColor: true, children: "File mentions" }), _jsx(Text, { dimColor: true, children: query ? `Search: ${query}` : 'Type after @ to search workspace files. Use up/down and Tab to choose.' }), error ? (_jsxs(Text, { color: "yellow", children: ["File search unavailable: ", error] })) : visibleSuggestions.length > 0 ? (visibleSuggestions.map((suggestion, index) => {
                const absoluteIndex = startIndex + index;
                const isHighlighted = absoluteIndex === highlightedIndex;
                return (_jsx(Text, { color: isHighlighted ? 'cyan' : undefined, dimColor: !isHighlighted, children: `${isHighlighted ? '◉' : '○'} @${suggestion.path}` }, suggestion.path));
            })) : (_jsx(Text, { dimColor: true, children: loading ? 'Searching workspace files...' : 'No matching files.' }))] }));
}
function getVisibleSuggestions(suggestions, highlightedIndex) {
    if (suggestions.length <= MAX_VISIBLE_FILES) {
        return { visibleSuggestions: suggestions, startIndex: 0 };
    }
    const half = Math.floor(MAX_VISIBLE_FILES / 2);
    const startIndex = Math.min(Math.max(0, highlightedIndex - half), Math.max(0, suggestions.length - MAX_VISIBLE_FILES));
    return {
        visibleSuggestions: suggestions.slice(startIndex, startIndex + MAX_VISIBLE_FILES),
        startIndex,
    };
}
//# sourceMappingURL=FileMentionPickerPanel.js.map