import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
 * @license
 * Copyright 2025 Vybestack LLC
 * SPDX-License-Identifier: Apache-2.0
 */
import { useCallback } from 'react';
import { Box, Text } from 'ink';
import { Colors } from '../../colors.js';
import { RadioButtonSelect } from '../shared/RadioButtonSelect.js';
import { useKeypress } from '../../hooks/useKeypress.js';
import { formatConfigSummary } from './utils.js';
export const ProfileSuccessSummary = ({ state, onClose, onLoadProfile, }) => {
    // Handle Escape key to close
    useKeypress((key) => {
        if (key.name === 'escape') {
            onClose();
        }
    }, { isActive: true });
    const handleSelect = useCallback((value) => {
        if (value === 'load') {
            // Load the profile using the provided handler
            if (onLoadProfile && state.profileName) {
                onLoadProfile(state.profileName);
            }
            onClose();
        }
        else if (value === 'done') {
            onClose();
        }
    }, [onClose, onLoadProfile, state.profileName]);
    const summary = formatConfigSummary(state);
    return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { bold: true, color: Colors.AccentGreen, children: "\u2713 Profile Created Successfully!" }), _jsx(Text, { color: Colors.Foreground, children: " " }), _jsxs(Text, { bold: true, color: Colors.Foreground, children: ["Profile: ", state.profileName] }), _jsx(Text, { color: Colors.Foreground, children: " " }), _jsx(Text, { color: Colors.Foreground, children: "Configuration Summary:" }), summary.split('\n').map((line, idx) => (_jsx(Text, { color: Colors.Gray, children: line }, idx))), _jsx(Text, { color: Colors.Foreground, children: " " }), _jsxs(Text, { color: Colors.Gray, children: ["You can load this profile with: /profile load ", state.profileName] }), _jsx(Text, { color: Colors.Foreground, children: " " }), _jsx(RadioButtonSelect, { items: [
                    { label: 'Load this profile now', value: 'load', key: 'load' },
                    { label: 'Return to llxprt', value: 'done', key: 'done' },
                ], onSelect: handleSelect, isFocused: true }), _jsx(Text, { color: Colors.Foreground, children: " " }), _jsx(Text, { color: Colors.Gray, children: "Esc Close" })] }));
};
//# sourceMappingURL=ProfileSuccessSummary.js.map