import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Box, Text } from "ink";
import { StatusIcon } from "./design/StatusIcon.js";
import { toneColor } from "./design/terminalTheme.js";
export function buildCacheEfficiencyNotice(cache) {
    const total = cache.hitTokens + cache.missTokens;
    if (total === 0) {
        return {
            state: "pending",
            tone: "muted",
            title: "cache telemetry pending",
            detail: "no DeepSeek cache tokens have been observed yet",
            recommendation: "run /cache plan <goal> before a large edit",
        };
    }
    const ratio = cache.hitTokens / total;
    if (ratio >= 0.65) {
        return {
            state: "success",
            tone: "success",
            title: "strong prefix reuse",
            detail: `${cache.rate} cache hit across ${cache.observedRuns} observed run(s)`,
            recommendation: "keep project facts and tool policy blocks stable",
        };
    }
    if (ratio >= 0.35) {
        return {
            state: "warning",
            tone: "warning",
            title: "cache warming",
            detail: `${cache.rate} cache hit; dynamic context is still moving`,
            recommendation: "pin stable facts with /cache pin add",
        };
    }
    return {
        state: "error",
        tone: "error",
        title: "low cache reuse",
        detail: `${cache.rate} cache hit; most prompt tokens are cold`,
        recommendation: "trim churn with /cache doctor or /cache plan <goal>",
    };
}
export function CacheEfficiencyNotice(props) {
    const model = buildCacheEfficiencyNotice(props.cache);
    return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { flexDirection: "row", children: [_jsx(StatusIcon, { state: model.state, withSpace: true }), _jsx(Text, { color: toneColor(model.tone), children: model.title })] }), !props.compact && _jsx(Text, { color: "gray", children: model.detail }), _jsx(Text, { color: "gray", children: model.recommendation })] }));
}
