import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Box, Text } from "ink";
import { StatusBadge } from "./design/StatusBadge.js";
import { StatusIcon } from "./design/StatusIcon.js";
import { truncateCells } from "./design/textLayout.js";
export function StatusNoticePanel(props) {
    const rows = buildStatusNoticeRows(props);
    if (rows.length === 0)
        return null;
    const width = props.width ?? 80;
    return (_jsx(Box, { flexDirection: "column", marginTop: 1, children: rows.map((row) => (_jsxs(Box, { flexDirection: "row", children: [_jsx(StatusIcon, { state: row.state, withSpace: true }), _jsx(StatusBadge, { label: row.label, tone: row.tone }), _jsx(Text, { color: "gray", children: " " }), _jsx(Text, { color: "gray", children: truncateCells(row.text, Math.max(16, width - 18)) })] }, row.id))) }));
}
export function buildStatusNoticeRows(input) {
    const rows = [];
    if (!input.providerReady) {
        rows.push({
            id: "provider",
            state: "warning",
            tone: "warning",
            label: "provider",
            text: "missing DeepSeek provider; set DEEPSEEK_API_KEY or run /doctor",
        });
    }
    if (input.shellEnabled || input.browserEnabled || input.permissionProfile === "open") {
        rows.push({
            id: "permissions",
            state: input.permissionProfile === "open" ? "error" : "warning",
            tone: input.permissionProfile === "open" ? "error" : "warning",
            label: "access",
            text: permissionNoticeText(input),
        });
    }
    if (input.providerReady) {
        rows.push({
            id: "cache",
            state: "pending",
            tone: "muted",
            label: "cache",
            text: "use /cache plan <goal> before large edits to protect DeepSeek prefix reuse",
        });
    }
    return rows.slice(0, 3);
}
function permissionNoticeText(input) {
    const enabled = [
        input.shellEnabled ? "shell" : "",
        input.browserEnabled ? "browser" : "",
    ].filter(Boolean).join("+") || input.permissionProfile;
    return `${enabled} access enabled; use /permissions safe before risky work`;
}
