import { jsx as _jsx } from "react/jsx-runtime";
import { ErrorMessage } from '../../../components/message-box.js';
import { formatError } from '../../../utils/error-formatter.js';
/**
 * Displays an error in the chat queue with special handling for cancellation errors.
 *
 * @param error - The error to display
 * @param keyPrefix - Prefix for the React component key
 * @param addToChatQueue - Callback to add error message to chat
 * @param getNextComponentKey - Function to generate unique React keys
 */
export const displayError = (error, keyPrefix, addToChatQueue, getNextComponentKey) => {
    if (error instanceof Error && error.message === 'Operation was cancelled') {
        addToChatQueue(_jsx(ErrorMessage, { message: "Interrupted by user.", hideBox: true }, `${keyPrefix}-${getNextComponentKey()}`));
    }
    else {
        addToChatQueue(_jsx(ErrorMessage, { message: formatError(error), hideBox: true }, `${keyPrefix}-${getNextComponentKey()}`));
    }
};
//# sourceMappingURL=message-helpers.js.map