import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Box, Text } from "ink";
import { ApprovalGateCard } from "./ApprovalGateCard.js";
export function ApprovalPanel(props) {
    const summary = approvalPanelSummary(props.gates);
    return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: "cyan", children: props.title ?? "Approval gates" }), _jsx(Text, { color: "gray", children: `total ${summary.total} | pending ${summary.pending} | approved ${summary.approved} | rejected ${summary.rejected} | cancelled ${summary.cancelled}` }), props.gates.length === 0 ? (_jsx(Text, { color: "gray", children: "No approval gates" })) : (props.gates.map((gate) => (_jsx(ApprovalGateCard, { gate: gate, projectPath: props.projectPath, showRun: true }, gate.id))))] }));
}
export function approvalPanelSummary(gates) {
    return {
        total: gates.length,
        pending: gates.filter((gate) => gate.status === "pending").length,
        approved: gates.filter((gate) => gate.status === "approved").length,
        rejected: gates.filter((gate) => gate.status === "rejected").length,
        cancelled: gates.filter((gate) => gate.status === "cancelled").length,
    };
}
