"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useIOToast = exports.IOToastRef = exports.IOToast = void 0;
var _react = require("react");
var _context = require("./context");
const useIOToast = () => {
  const {
    addToast,
    removeToast,
    removeAllToasts
  } = (0, _react.useContext)(_context.ToastContext);
  const show = (0, _react.useCallback)((message, options) => {
    addToast({
      message,
      ...options
    });
  }, [addToast]);
  const error = (0, _react.useCallback)(message => {
    show(message, {
      variant: "error",
      icon: "errorFilled",
      hapticFeedback: "notificationError"
    });
  }, [show]);
  const info = (0, _react.useCallback)(message => {
    show(message, {
      variant: "info",
      icon: "infoFilled",
      hapticFeedback: "impactMedium"
    });
  }, [show]);
  const success = (0, _react.useCallback)(message => {
    show(message, {
      variant: "success",
      icon: "success",
      hapticFeedback: "notificationSuccess"
    });
  }, [show]);
  const warning = (0, _react.useCallback)(message => {
    show(message, {
      variant: "warning",
      icon: "warningFilled",
      hapticFeedback: "notificationWarning"
    });
  }, [show]);
  return (0, _react.useMemo)(() => ({
    show,
    error,
    info,
    success,
    warning,
    hide: removeToast,
    hideAll: removeAllToasts
  }), [show, error, info, success, warning, removeToast, removeAllToasts]);
};
exports.useIOToast = useIOToast;
const IOToastRef = exports.IOToastRef = /*#__PURE__*/(0, _react.createRef)();
const IOToast = exports.IOToast = {
  show: (message, options) => IOToastRef.current?.show(message, options),
  error: message => IOToastRef.current?.error(message),
  warning: message => IOToastRef.current?.warning(message),
  success: message => IOToastRef.current?.success(message),
  info: message => IOToastRef.current?.info(message),
  hideAll: () => IOToastRef.current?.hideAll(),
  hide: id => IOToastRef.current?.hide(id)
};
//# sourceMappingURL=useIOToast.js.map