import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
 * @license
 * Copyright 2025 Vybestack LLC
 * SPDX-License-Identifier: Apache-2.0
 */
import { useState, useCallback } from 'react';
import { Box, Text } from 'ink';
import { Colors } from '../../colors.js';
import { useKeypress } from '../../hooks/useKeypress.js';
export const SubagentDeleteDialog = ({ subagent, onConfirm, onCancel, isFocused = true, }) => {
    const [isDeleting, setIsDeleting] = useState(false);
    const [error, setError] = useState(null);
    const handleConfirm = useCallback(async () => {
        setIsDeleting(true);
        setError(null);
        try {
            await onConfirm();
        }
        catch (err) {
            setError(err instanceof Error ? err.message : 'Failed to delete');
            setIsDeleting(false);
        }
    }, [onConfirm]);
    useKeypress((key) => {
        if (isDeleting)
            return;
        if (key.name === 'escape') {
            onCancel();
            return;
        }
        if (key.name === 'return') {
            // eslint-disable-next-line @typescript-eslint/no-floating-promises
            handleConfirm();
            return;
        }
    }, { isActive: isFocused && !isDeleting });
    const formatDate = (isoString) => {
        try {
            return new Date(isoString).toLocaleString();
        }
        catch {
            return isoString;
        }
    };
    return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { bold: true, color: "#ff0000", children: "WARNING: This action cannot be undone" }) }), _jsx(Text, { color: Colors.Gray, children: "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500" }), error && (_jsx(Box, { marginY: 1, children: _jsx(Text, { color: "#ff0000", children: error }) })), _jsxs(Box, { flexDirection: "column", marginY: 1, children: [_jsxs(Box, { children: [_jsx(Text, { color: Colors.Gray, children: "Subagent: " }), _jsx(Text, { color: Colors.Foreground, children: subagent.name })] }), _jsxs(Box, { children: [_jsx(Text, { color: Colors.Gray, children: "Profile: " }), _jsx(Text, { color: Colors.Foreground, children: subagent.profile })] }), _jsxs(Box, { children: [_jsx(Text, { color: Colors.Gray, children: "Created: " }), _jsx(Text, { color: Colors.Foreground, children: formatDate(subagent.createdAt) })] })] }), _jsxs(Box, { flexDirection: "column", marginY: 1, children: [_jsx(Text, { color: Colors.Foreground, children: "This will permanently delete the subagent and all" }), _jsx(Text, { color: Colors.Foreground, children: "configuration data. The profile will NOT be affected." })] }), _jsx(Box, { marginY: 1, children: _jsx(Text, { bold: true, color: "#ffff00", children: "WARNING: All subagent settings and prompts will be lost!" }) }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: Colors.Gray, children: "[Enter] Confirm Delete [ESC] Cancel" }) }), isDeleting && (_jsx(Box, { marginTop: 1, children: _jsx(Text, { color: Colors.Gray, children: "Deleting..." }) }))] }));
};
//# sourceMappingURL=SubagentDeleteDialog.js.map