import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Box, Text } from 'ink';
import WelcomeMessage from '../../components/welcome-message.js';
import { getClosestConfigFile } from '../../config/index.js';
import { useResponsiveTerminal } from '../../hooks/useTerminalWidth.js';
import { useTheme } from '../../hooks/useTheme.js';
import { formatGitStatusSummary, getGitStatusSummarySync, } from '../../tools/git/utils.js';
import { DEVELOPMENT_MODE_LABELS } from '../../types/core.js';
/**
 * Format a {@link GitStatusSummary} for inline display next to the
 * provider/model/config segment of the boot summary.
 */
export function formatBootSummaryGitLabel(status) {
    const { branch, marker } = formatGitStatusSummary(status);
    return marker ? `⎇ ${branch} (${marker})` : `⎇ ${branch}`;
}
/**
 * Minimal one-liner showing provider/model (+ optional mode) + config path.
 * Replaces the old full Status box which rendered inside Ink's <Static> and
 * couldn't update after first paint. Run /status for the full picture.
 */
function BootSummary({ provider, model, mode, }) {
    const { colors } = useTheme();
    const { isNarrow } = useResponsiveTerminal();
    const configPath = getClosestConfigFile('agents.config.json');
    const homedir = process.env.HOME || process.env.USERPROFILE || '';
    const shortConfig = homedir ? configPath.replace(homedir, '~') : configPath;
    const modeLabel = mode ? DEVELOPMENT_MODE_LABELS[mode] : undefined;
    const gitStatus = getGitStatusSummarySync();
    const gitLabel = gitStatus ? formatBootSummaryGitLabel(gitStatus) : undefined;
    // Narrow terminals: provider + model + mode on the first line, with the
    // branch (when present) underneath so the line doesn't overflow.
    if (isNarrow) {
        if (!provider || !model)
            return _jsx(_Fragment, {});
        return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { children: [_jsx(Text, { color: colors.success, bold: true, children: provider }), _jsx(Text, { color: colors.secondary, children: " \u00B7 " }), _jsx(Text, { color: colors.success, children: model }), modeLabel && (_jsxs(_Fragment, { children: [_jsx(Text, { color: colors.secondary, children: " \u00B7 " }), _jsx(Text, { color: colors.info, children: modeLabel })] }))] }), gitLabel && _jsx(Text, { color: colors.primary, children: gitLabel })] }));
    }
    return (_jsx(Text, { color: colors.secondary, children: provider && model ? (_jsxs(_Fragment, { children: [_jsx(Text, { color: colors.success, bold: true, children: provider }), _jsx(Text, { color: colors.secondary, children: " \u00B7 " }), _jsx(Text, { color: colors.success, children: model }), modeLabel && (_jsxs(_Fragment, { children: [_jsx(Text, { color: colors.secondary, children: " \u00B7 " }), _jsx(Text, { color: colors.info, children: modeLabel })] })), _jsx(Text, { color: colors.secondary, children: " \u00B7 " }), _jsx(Text, { color: colors.secondary, children: shortConfig }), gitLabel && (_jsxs(_Fragment, { children: [_jsx(Text, { color: colors.secondary, children: " \u00B7 " }), _jsx(Text, { color: colors.primary, children: gitLabel })] }))] })) : (_jsxs(_Fragment, { children: [_jsx(Text, { color: colors.secondary, children: shortConfig }), gitLabel && (_jsxs(_Fragment, { children: [_jsx(Text, { color: colors.secondary, children: " \u00B7 " }), _jsx(Text, { color: colors.primary, children: gitLabel })] }))] })) }));
}
/**
 * Creates static components for the app container (welcome banner +
 * one-line boot summary).
 *
 * The full Status box was removed from startup — it rendered inside Ink's
 * <Static> which freezes after first paint, so background work (MCP, LSP,
 * update check) never showed. Users can run /status any time to see the
 * full picture.
 */
export function createStaticComponents({ shouldShowWelcome, currentProvider, currentModel, nonInteractiveMode = false, developmentMode, }) {
    const components = [];
    if (shouldShowWelcome) {
        components.push(_jsx(WelcomeMessage, {}, "welcome"));
    }
    // Boot summary header: always in interactive mode (for config path
    // visibility), and in run mode we include the active development mode
    // so it's obvious what the agent is executing under.
    if (currentProvider || currentModel) {
        components.push(_jsx(Box, { flexDirection: "column", marginBottom: 1, children: _jsx(BootSummary, { provider: currentProvider, model: currentModel, mode: nonInteractiveMode ? developmentMode : undefined }) }, "boot-summary"));
    }
    return components;
}
//# sourceMappingURL=app-container.js.map