import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Box, Text } from 'ink';
import { getColors } from '../config/index.js';
import { BaseConfigWizard } from './base-config-wizard.js';
import { McpStep } from './steps/mcp-step.js';
import { buildMcpConfigObject } from './validation.js';
function parseMcpConfig(raw) {
    const config = raw;
    return config?.mcpServers ?? {};
}
function McpSummaryItems({ items }) {
    const colors = getColors();
    const entries = Object.entries(items);
    if (entries.length === 0) {
        return (_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: colors.warning, children: "No MCP servers configured" }) }));
    }
    return (_jsxs(Box, { marginBottom: 1, flexDirection: "column", children: [_jsxs(Text, { color: colors.secondary, children: ["MCP Servers (", entries.length, "):"] }), entries.map(([key, server]) => (_jsxs(Text, { color: colors.success, children: ["\u2022 ", server.name, " (", server.transport, ")"] }, key)))] }));
}
export function McpWizard({ projectDir, onComplete, onCancel }) {
    return (_jsx(BaseConfigWizard, { title: "MCP Server Configuration", focusId: "mcp-wizard", configFileName: ".mcp.json", initialItems: {}, parseConfig: parseMcpConfig, buildConfig: buildMcpConfigObject, hasItems: items => Object.keys(items).length > 0, renderConfigureStep: ({ items, onComplete: onItemsComplete, onBack, onDelete, configExists, }) => (_jsx(McpStep, { existingServers: items, onComplete: onItemsComplete, onBack: onBack, onDelete: onDelete, configExists: configExists })), renderSummaryItems: items => _jsx(McpSummaryItems, { items: items }), projectDir: projectDir, onComplete: onComplete, onCancel: onCancel }));
}
//# sourceMappingURL=mcp-wizard.js.map