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 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';
/**
 * Chat input component that handles user input and tool interactions.
 *
 * 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, isToolConfirmationMode, pendingToolCalls, currentToolIndex, mcpInitialized, client, nonInteractivePrompt, nonInteractiveLoadingMessage, customCommands, inputDisabled, developmentMode, onToolConfirm, onToolCancel, onSubmit, onCancel, onToggleMode, }) {
    const { colors } = useTheme();
    const loadingLabel = nonInteractivePrompt
        ? (nonInteractiveLoadingMessage ?? 'Loading...')
        : 'Loading...';
    return (_jsxs(Box, { flexDirection: "column", marginLeft: -1, children: [isCancelling && _jsx(CancellingIndicator, {}), isToolConfirmationMode && pendingToolCalls[currentToolIndex] ? (_jsx(ToolConfirmation, { toolCall: pendingToolCalls[currentToolIndex], onConfirm: onToolConfirm, onCancel: onToolCancel })) : /* Tool Execution - skip indicator for streaming tools (they show their own progress) */
                isToolExecuting &&
                    pendingToolCalls[currentToolIndex] &&
                    pendingToolCalls[currentToolIndex].function.name !== 'execute_bash' ? (_jsx(ToolExecutionIndicator, { toolName: pendingToolCalls[currentToolIndex].function.name, currentIndex: currentToolIndex, totalTools: pendingToolCalls.length })) : /* User Input */
                    mcpInitialized && client && !nonInteractivePrompt ? (_jsx(UserInput, { customCommands: customCommands, onSubmit: msg => void onSubmit(msg), disabled: inputDisabled, onCancel: onCancel, onToggleMode: onToggleMode, developmentMode: developmentMode })) : /* Client Missing */
                        mcpInitialized && !client ? (_jsx(_Fragment, {})) : /* Non-Interactive Complete */
                            nonInteractivePrompt && !nonInteractiveLoadingMessage ? (_jsx(Text, { color: colors.secondary, children: "Completed. Exiting." })) : (
                            /* Loading */
                            _jsxs(Text, { color: colors.secondary, children: [_jsx(Spinner, { type: "dots" }), " ", loadingLabel] }))] }));
}
//# sourceMappingURL=chat-input.js.map