"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useEventHandlers = void 0;
var _react = require("react");
const useEventHandlers = config => {
  const handleMessageSent = (0, _react.useCallback)(async event => {
    try {
      if (config?.eventHandlers?.onMessageSent) {
        await config.eventHandlers.onMessageSent(event);
      }
    } catch (error) {
      console.error('Error in message sent handler:', error);
      throw error;
    }
  }, [config]);
  const handleMessageFailed = (0, _react.useCallback)(event => {
    try {
      if (config?.eventHandlers?.onMessageFailed) {
        config.eventHandlers.onMessageFailed(event);
      }
      console.error('Message failed details:', {
        message: event.message,
        roomJID: event.roomJID,
        messageType: event.messageType,
        error: event.error?.message,
        timestamp: new Date().toISOString()
      });
    } catch (handlerError) {
      console.error('Error in message failed handler:', handlerError);
    }
  }, [config]);
  const handleMessageEdited = (0, _react.useCallback)(event => {
    try {
      if (config?.eventHandlers?.onMessageEdited) {
        config.eventHandlers.onMessageEdited(event);
      }
    } catch (error) {
      console.error('Error in message edited handler:', error);
    }
  }, [config]);
  const handleMessageRetry = (0, _react.useCallback)(event => {
    try {
      config?.eventHandlers?.onMessageRetry?.(event);
    } catch (error) {
      console.error('Error in message retry handler:', error);
    }
  }, [config]);
  return {
    handleMessageSent,
    handleMessageFailed,
    handleMessageEdited,
    handleMessageRetry
  };
};
exports.useEventHandlers = useEventHandlers;
//# sourceMappingURL=useEventHandlers.js.map