import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Box, Text } from 'ink';
import { Colors } from '../colors.js';
import { useStreamingContext } from '../contexts/StreamingContext.js';
import { StreamingState } from '../types.js';
import { GeminiRespondingSpinner } from './GeminiRespondingSpinner.js';
import { formatDuration } from '../utils/formatters.js';
export const LoadingIndicator = ({ currentLoadingPhrase, elapsedTime, rightContent, thought, }) => {
    const streamingState = useStreamingContext();
    if (streamingState === StreamingState.Idle) {
        return null;
    }
    const primaryText = thought?.subject || currentLoadingPhrase;
    const timerText = streamingState === StreamingState.WaitingForConfirmation
        ? ''
        : ` (esc to cancel, ${elapsedTime < 60
            ? `${elapsedTime}s`
            : formatDuration(elapsedTime * 1000)})`;
    const lineText = primaryText
        ? `${primaryText}${timerText}`
        : timerText.trimStart();
    return (_jsx(Box, { marginTop: 1, paddingLeft: 0, flexDirection: "column", children: _jsxs(Box, { width: "100%", flexDirection: "row", children: [_jsx(Box, { marginRight: 1, children: _jsx(GeminiRespondingSpinner, { nonRespondingDisplay: streamingState === StreamingState.WaitingForConfirmation
                            ? '⠏'
                            : '' }) }), _jsx(Box, { flexGrow: 1, flexShrink: 1, minWidth: 0, children: lineText && (_jsx(Text, { color: Colors.AccentPurple, wrap: timerText ? 'truncate-middle' : 'truncate-end', children: lineText })) }), rightContent && (_jsx(Box, { marginLeft: 1, flexShrink: 0, children: rightContent }))] }) }));
};
//# sourceMappingURL=LoadingIndicator.js.map