import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { Box, Text } from 'ink';
import { theme } from '../semantic-colors.js';
import { shortenPath, tildeifyPath, getDisplayString, } from '@google/gemini-cli-core';
import { ConsoleSummaryDisplay } from './ConsoleSummaryDisplay.js';
import process from 'node:process';
import { MemoryUsageDisplay } from './MemoryUsageDisplay.js';
import { ContextUsageDisplay } from './ContextUsageDisplay.js';
import { QuotaDisplay } from './QuotaDisplay.js';
import { DebugProfiler } from './DebugProfiler.js';
import { isDevelopment } from '../../utils/installationInfo.js';
import { useUIState } from '../contexts/UIStateContext.js';
import { useConfig } from '../contexts/ConfigContext.js';
import { useSettings } from '../contexts/SettingsContext.js';
import { useVimMode } from '../contexts/VimModeContext.js';
export const Footer = () => {
    const uiState = useUIState();
    const config = useConfig();
    const settings = useSettings();
    const { vimEnabled, vimMode } = useVimMode();
    const { model, targetDir, debugMode, branchName, debugMessage, corgiMode, errorCount, showErrorDetails, promptTokenCount, isTrustedFolder, terminalWidth, quotaStats, } = {
        model: uiState.currentModel,
        targetDir: config.getTargetDir(),
        debugMode: config.getDebugMode(),
        branchName: uiState.branchName,
        debugMessage: uiState.debugMessage,
        corgiMode: uiState.corgiMode,
        errorCount: uiState.errorCount,
        showErrorDetails: uiState.showErrorDetails,
        promptTokenCount: uiState.sessionStats.lastPromptTokenCount,
        isTrustedFolder: uiState.isTrustedFolder,
        terminalWidth: uiState.terminalWidth,
        quotaStats: uiState.quota.stats,
    };
    const showMemoryUsage = config.getDebugMode() || settings.merged.ui.showMemoryUsage;
    const isFullErrorVerbosity = settings.merged.ui.errorVerbosity === 'full';
    const showErrorSummary = !showErrorDetails &&
        errorCount > 0 &&
        (isFullErrorVerbosity || debugMode || isDevelopment);
    const hideCWD = settings.merged.ui.footer.hideCWD;
    const hideSandboxStatus = settings.merged.ui.footer.hideSandboxStatus;
    const hideModelInfo = settings.merged.ui.footer.hideModelInfo;
    const hideContextPercentage = settings.merged.ui.footer.hideContextPercentage;
    const pathLength = Math.max(20, Math.floor(terminalWidth * 0.25));
    const displayPath = shortenPath(tildeifyPath(targetDir), pathLength);
    const justifyContent = hideCWD && hideModelInfo ? 'center' : 'space-between';
    const displayVimMode = vimEnabled ? vimMode : undefined;
    const showDebugProfiler = debugMode || isDevelopment;
    return (_jsxs(Box, { justifyContent: justifyContent, width: terminalWidth, flexDirection: "row", alignItems: "center", paddingX: 1, children: [(showDebugProfiler || displayVimMode || !hideCWD) && (_jsxs(Box, { children: [showDebugProfiler && _jsx(DebugProfiler, {}), displayVimMode && (_jsxs(Text, { color: theme.text.secondary, children: ["[", displayVimMode, "] "] })), !hideCWD && (_jsxs(Text, { color: theme.text.primary, children: [displayPath, branchName && (_jsxs(Text, { color: theme.text.secondary, children: [" (", branchName, "*)"] }))] })), debugMode && (_jsx(Text, { color: theme.status.error, children: ' ' + (debugMessage || '--debug') }))] })), !hideSandboxStatus && (_jsx(Box, { flexGrow: 1, alignItems: "center", justifyContent: "center", display: "flex", children: isTrustedFolder === false ? (_jsx(Text, { color: theme.status.warning, children: "untrusted" })) : process.env['SANDBOX'] &&
                    process.env['SANDBOX'] !== 'sandbox-exec' ? (_jsx(Text, { color: "green", children: process.env['SANDBOX'].replace(/^gemini-(?:cli-)?/, '') })) : process.env['SANDBOX'] === 'sandbox-exec' ? (_jsxs(Text, { color: theme.status.warning, children: ["macOS Seatbelt", ' ', _jsxs(Text, { color: theme.text.secondary, children: ["(", process.env['SEATBELT_PROFILE'], ")"] })] })) : (_jsxs(Text, { color: theme.status.error, children: ["no sandbox", terminalWidth >= 100 && (_jsx(Text, { color: theme.text.secondary, children: " (see /docs)" }))] })) })), !hideModelInfo && (_jsxs(Box, { alignItems: "center", justifyContent: "flex-end", children: [_jsxs(Box, { alignItems: "center", children: [_jsxs(Text, { color: theme.text.primary, children: [_jsx(Text, { color: theme.text.secondary, children: "/model " }), getDisplayString(model), !hideContextPercentage && (_jsxs(_Fragment, { children: [' ', _jsx(ContextUsageDisplay, { promptTokenCount: promptTokenCount, model: model, terminalWidth: terminalWidth })] })), quotaStats && (_jsxs(_Fragment, { children: [' ', _jsx(QuotaDisplay, { remaining: quotaStats.remaining, limit: quotaStats.limit, resetTime: quotaStats.resetTime, terse: true })] }))] }), showMemoryUsage && _jsx(MemoryUsageDisplay, {})] }), _jsxs(Box, { alignItems: "center", children: [corgiMode && (_jsx(Box, { paddingLeft: 1, flexDirection: "row", children: _jsxs(Text, { children: [_jsx(Text, { color: theme.ui.symbol, children: "| " }), _jsx(Text, { color: theme.status.error, children: "\u25BC" }), _jsx(Text, { color: theme.text.primary, children: "(\u00B4" }), _jsx(Text, { color: theme.status.error, children: "\u1D25" }), _jsx(Text, { color: theme.text.primary, children: "`)" }), _jsx(Text, { color: theme.status.error, children: "\u25BC" })] }) })), showErrorSummary && (_jsxs(Box, { paddingLeft: 1, flexDirection: "row", children: [_jsx(Text, { color: theme.ui.comment, children: "| " }), _jsx(ConsoleSummaryDisplay, { errorCount: errorCount })] }))] })] }))] }));
};
//# sourceMappingURL=Footer.js.map