import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Box, Text } from "ink";
export function ApprovalPanel(props) {
    if (!props.request && !props.bypassConfirmation) {
        return null;
    }
    if (props.bypassConfirmation) {
        return (_jsxs(Box, { borderStyle: "double", borderColor: "red", flexDirection: "column", paddingX: 1, marginTop: 1, height: 5, overflowY: "hidden", children: [_jsx(Text, { color: "red", bold: true, children: "ACTION REQUIRED  TRUSTED BYPASS" }), _jsx(Text, { color: "white", bold: true, children: "Write and shell tools will run without per-tool prompts in this TUI session." }), _jsx(Text, { color: "cyan", bold: true, children: "Press [y] accept bypass  [n/Esc/Tab] stay approval-gated build" })] }));
    }
    const request = props.request;
    if (!request) {
        return null;
    }
    return (_jsxs(Box, { borderStyle: "double", borderColor: "yellow", flexDirection: "column", paddingX: 1, marginTop: 1, height: 6, overflowY: "hidden", children: [_jsxs(Text, { color: "yellow", bold: true, children: ["ACTION REQUIRED  ", request.tool, " needs ", request.permission, " approval"] }), _jsxs(Text, { color: "gray", children: ["risk ", request.risk, "  scope allow-session applies only to this tool", request.bypassable === false ? "  bypass cannot skip this" : ""] }), _jsxs(Text, { color: "white", bold: true, wrap: "wrap", children: [request.preview, " ", formatApprovalTarget(request.arguments)] }), _jsx(Text, { color: "cyan", bold: true, children: "Press [y] allow once  [a] allow session  [n/Esc] deny" })] }));
}
function formatApprovalTarget(argumentsValue) {
    const pathValue = typeof argumentsValue.path === "string" ? argumentsValue.path : "";
    const commandValue = typeof argumentsValue.command === "string" ? argumentsValue.command : "";
    const scriptValue = typeof argumentsValue.script === "string" ? argumentsValue.script : "";
    if (pathValue) {
        return `target ${pathValue}`;
    }
    if (scriptValue) {
        return `script ${scriptValue}`;
    }
    if (commandValue) {
        return `command ${commandValue}`;
    }
    return "";
}
//# sourceMappingURL=ApprovalPanel.js.map