import { jsx as _jsx } from "react/jsx-runtime";
import { ErrorMessage } from '../../../components/message-box.js';
import { generateKey } from '../../../session/key-generator.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
 */
export const displayError = (error, keyPrefix, addToChatQueue) => {
    if (error instanceof Error && error.message === 'Operation was cancelled') {
        addToChatQueue(_jsx(ErrorMessage, { message: "Interrupted by user.", hideBox: true }, generateKey(keyPrefix)));
    }
    else {
        addToChatQueue(_jsx(ErrorMessage, { message: formatError(error), hideBox: true }, generateKey(keyPrefix)));
    }
};
//# sourceMappingURL=message-helpers.js.map