import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { Box, Text } from 'ink';
import Spinner from 'ink-spinner';
import CancellingIndicator from '../../components/cancelling-indicator.js';
import QuestionPrompt from '../../components/question-prompt.js';
import { TaskListDisplay } from '../../components/task-list-display.js';
import ToolConfirmation from '../../components/tool-confirmation.js';
import ToolExecutionIndicator from '../../components/tool-execution-indicator.js';
import UserInput from '../../components/user-input.js';
import { useTheme } from '../../hooks/useTheme.js';
import { LiveCompactCounts } from '../../utils/tool-result-display.js';
/**
 * Interactive chat input. Renders user input, tool confirmation prompts,
 * question prompts, and in-flight indicators.
 *
 * Non-interactive (`run`) mode does not route through this component —
 * see NonInteractiveShell.
 *
 * Unlike ChatHistory, this component CAN be conditionally mounted/unmounted.
 * It does not contain ink's Static component, so it's safe to hide when
 * modal dialogs are shown.
 */
export function ChatInput({ isCancelling, isToolExecuting, isQuestionMode, pendingToolCalls, currentToolIndex, pendingQuestion, onQuestionAnswer, pendingSubagentApproval, onSubagentToolApproval, pendingToolConfirmation, onToolConfirmation, mcpInitialized, client, customCommands, inputDisabled, isBusy, developmentMode, contextPercentUsed, contextSource, sessionName, compactToolCounts, onToggleCompactDisplay, compactToolDisplay, liveTaskList, onSubmit, onToggleMode, onToggleReasoningExpanded, tune, currentModel, activeEditor, onDismissActiveEditor, }) {
    const { colors } = useTheme();
    return (_jsxs(Box, { flexDirection: "column", marginLeft: -1, children: [compactToolCounts && Object.keys(compactToolCounts).length > 0 && (_jsx(LiveCompactCounts, { counts: compactToolCounts })), liveTaskList && liveTaskList.length > 0 && (_jsx(TaskListDisplay, { tasks: liveTaskList, title: "Tasks" })), isCancelling && _jsx(CancellingIndicator, {}), pendingSubagentApproval ? (_jsx(ToolConfirmation, { toolCall: pendingSubagentApproval.toolCall, onConfirm: onSubagentToolApproval, onCancel: () => onSubagentToolApproval(false) })) : /* Main agent tool confirmation (unified inline approval gate) */
                pendingToolConfirmation ? (_jsx(ToolConfirmation, { toolCall: pendingToolConfirmation.toolCall, onConfirm: onToolConfirmation, onCancel: () => onToolConfirmation(false) })) : /* Tool Execution - skip indicator for streaming tools (they show their own progress) */
                    isToolExecuting &&
                        pendingToolCalls[currentToolIndex] &&
                        pendingToolCalls[currentToolIndex].function.name !== 'execute_bash' &&
                        pendingToolCalls[currentToolIndex].function.name !== 'agent' ? (_jsx(ToolExecutionIndicator, { toolName: pendingToolCalls[currentToolIndex].function.name, currentIndex: currentToolIndex, totalTools: pendingToolCalls.length })) : /* Question Prompt (ask_question tool) */
                        isQuestionMode && pendingQuestion ? (_jsx(QuestionPrompt, { question: pendingQuestion, onAnswer: onQuestionAnswer })) : /* User Input */
                            mcpInitialized && client ? (_jsx(UserInput, { customCommands: customCommands, onSubmit: (msg, display, images) => void onSubmit(msg, display, images), disabled: inputDisabled, isBusy: isBusy, onToggleMode: onToggleMode, onToggleReasoningExpanded: onToggleReasoningExpanded, onToggleCompactDisplay: onToggleCompactDisplay, compactToolDisplay: compactToolDisplay, developmentMode: developmentMode, contextPercentUsed: contextPercentUsed, contextSource: contextSource, sessionName: sessionName, tune: tune, currentModel: currentModel, activeEditor: activeEditor, onDismissActiveEditor: onDismissActiveEditor })) : /* Client Missing */
                                mcpInitialized && !client ? (_jsx(_Fragment, {})) : (
                                /* Loading */
                                _jsxs(Text, { color: colors.secondary, children: [_jsx(Spinner, { type: "dots" }), " Loading..."] }))] }));
}
//# sourceMappingURL=chat-input.js.map