import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import React from "react";
import { Box, Text } from "ink";
import { useTheme } from "../theme/theme.js";
import { getModel } from "../../core/model-registry.js";
import { useTerminalSize } from "../hooks/useTerminalSize.js";
const LOGO_LINES = [
    " \u2588\u2588\u2588\u2588\u2588\u2588\u2557  \u2588\u2588\u2588\u2588\u2588\u2588\u2557 ",
    "\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255d \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255d ",
    "\u2588\u2588\u2551  \u2588\u2588\u2588\u2557\u2588\u2588\u2551  \u2588\u2588\u2588\u2557",
    "\u2588\u2588\u2551   \u2588\u2588\u2551\u2588\u2588\u2551   \u2588\u2588\u2551",
    "\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255d\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255d",
    " \u255a\u2550\u2550\u2550\u2550\u2550\u255d  \u255a\u2550\u2550\u2550\u2550\u2550\u255d",
];
// Extended gradient with reverse path for smooth animation loop
const GRADIENT = [
    "#60a5fa",
    "#6da1f9",
    "#7a9df7",
    "#8799f5",
    "#9495f3",
    "#a18ff1",
    "#a78bfa",
    "#a18ff1",
    "#9495f3",
    "#8799f5",
    "#7a9df7",
    "#6da1f9",
];
// One-space left pad to match the terminal-history banner (RESPONSE_LEFT_PADDING).
const LEFT_PAD = " ";
const GAP = "   ";
// Logo is 17 visible chars wide; below this width the info column would
// collide with the art, so we stack it underneath instead. The threshold
// mirrors terminal-history.ts SIDE_BY_SIDE_MIN (LOGO_WIDTH + GAP + 62).
const LOGO_WIDTH = 17;
const SIDE_BY_SIDE_MIN = LOGO_WIDTH + GAP.length + 62;
export function Banner({ version, model, cwd }) {
    const theme = useTheme();
    const { columns } = useTerminalSize();
    const modelInfo = getModel(model);
    const modelName = modelInfo?.name ?? model;
    const home = process.env.HOME ?? "";
    const displayPath = home && cwd.startsWith(home) ? "~" + cwd.slice(home.length) : cwd;
    // Static gradient — no animation needed since the banner is rendered once
    // into Ink's Static area. Animating here would waste CPU and could cause
    // visual duplicates on terminal resize.
    const shift = 0;
    const logo = (_jsx(Box, { flexDirection: "column", flexShrink: 0, children: LOGO_LINES.map((line, i) => (_jsxs(Box, { children: [_jsx(Text, { children: LEFT_PAD }), _jsx(GradientText, { text: line, shift: shift })] }, i))) }));
    // Narrow (stacked) info — mirrors terminal-history.ts: brand line omits
    // "· By Ken Kai", path is truncated to the full terminal width.
    const stackedInfo = (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { children: LEFT_PAD }), _jsx(Text, { color: theme.primary, bold: true, children: "GG Coder" }), _jsxs(Text, { color: theme.textDim, children: [" v", version] })] }), _jsxs(Box, { children: [_jsx(Text, { children: LEFT_PAD }), _jsx(Text, { color: theme.secondary, children: modelName }), _jsx(Text, { color: theme.textDim, children: "  " }), _jsx(Text, { color: theme.textDim, wrap: "truncate", children: displayPath })] }), _jsxs(Box, { children: [_jsx(Text, { children: LEFT_PAD }), _jsx(ShortcutHints, {})] })] }));
    // Side-by-side info — includes "· By Ken Kai".
    const sideInfo = (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: theme.primary, bold: true, children: "GG Coder" }), _jsxs(Text, { color: theme.textDim, children: [" v", version] }), _jsx(Text, { color: theme.textDim, children: " \u00B7 By " }), _jsx(Text, { color: theme.text, bold: true, children: "Ken Kai" })] }), _jsxs(Box, { children: [_jsx(Text, { color: theme.secondary, children: modelName }), _jsx(Text, { color: theme.textDim, children: "  " }), _jsx(Text, { color: theme.textDim, wrap: "truncate", children: displayPath })] }), _jsx(ShortcutHints, {})] }));
    // At narrow widths, stack the info block under the logo.
    if (columns < SIDE_BY_SIDE_MIN) {
        return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, width: columns, children: [logo, _jsx(Box, { marginTop: 1, children: stackedInfo })] }));
    }
    // Side-by-side: logo on the left, info column vertically centered beside it.
    return (_jsxs(Box, { flexDirection: "row", marginTop: 1, marginBottom: 1, width: columns, children: [logo, _jsx(Text, { children: GAP }), _jsx(Box, { flexDirection: "column", justifyContent: "center", children: sideInfo })] }));
}
function ShortcutHints() {
    const theme = useTheme();
    return (_jsxs(Box, { children: [_jsx(Text, { color: theme.primary, children: "Ctrl+T" }), _jsx(Text, { color: theme.textDim, children: " tasks" }), _jsx(Text, { color: theme.textDim, children: " \u00B7 " }), _jsx(Text, { color: theme.primary, children: "Ctrl+S" }), _jsx(Text, { color: theme.textDim, children: " skills" }), _jsx(Text, { color: theme.textDim, children: " \u00B7 " }), _jsx(Text, { color: theme.primary, children: "Shift+Tab" }), _jsx(Text, { color: theme.textDim, children: " toggle thinking" })] }));
}
function GradientText({ text, shift = 0 }) {
    const chars = [];
    let colorIdx = 0;
    for (let i = 0; i < text.length; i++) {
        const ch = text[i];
        if (ch === " ") {
            chars.push(ch);
        }
        else {
            const color = GRADIENT[(colorIdx + shift) % GRADIENT.length];
            chars.push(_jsx(Text, { color: color, children: ch }, i));
            colorIdx++;
        }
    }
    return _jsx(Text, { children: chars });
}
//# sourceMappingURL=Banner.js.map