import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
import { Box, Text } from "ink";
import { agentMarkdownFilename } from "../../agentFileUtils.js";
import { generateAgentMarkdown } from "../../generateAgent.js";
import { validateAgentDraft } from "../../validateAgent.js";
export function confirmStepModel(state) {
    const validation = validateAgentDraft(state);
    return {
        ready: validation.ok,
        filename: agentMarkdownFilename(state.name),
        rows: [
            { label: "location", value: state.location },
            { label: "method", value: state.method },
            { label: "type", value: state.type },
            { label: "model", value: state.model },
            { label: "tools", value: state.tools.length ? state.tools.join(", ") : "all tools" },
        ],
        errors: validation.errors,
        warnings: validation.warnings,
        preview: generateAgentMarkdown(state).split(/\r?\n/).slice(0, 8),
    };
}
export function ConfirmStep(props) {
    const model = confirmStepModel(props.state);
    return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { color: model.ready ? "green" : "yellow", children: [model.ready ? "Ready to save" : "Needs input", " ", model.filename] }), model.rows.map((row) => (_jsxs(Box, { children: [_jsx(Text, { color: "gray", children: row.label.padEnd(10) }), _jsx(Text, { children: row.value })] }, row.label))), model.errors.map((error) => (_jsxs(Text, { color: "red", children: ["error: ", error] }, `error:${error}`))), model.warnings.map((warning) => (_jsxs(Text, { color: "yellow", children: ["warning: ", warning] }, `warning:${warning}`)))] }));
}
