"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useIOToast = exports.IOToastRef = exports.IOToast = void 0;
var _react = _interopRequireDefault(require("react"));
var _context = require("./context");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const useIOToast = () => {
  const {
    addToast,
    removeToast,
    removeAllToasts
  } = _react.default.useContext(_context.ToastContext);
  const show = _react.default.useCallback((message, options) => {
    addToast({
      message,
      ...options
    });
  }, [addToast]);
  const error = _react.default.useCallback(message => {
    show(message, {
      variant: "error",
      icon: "errorFilled",
      hapticFeedback: "notificationError"
    });
  }, [show]);
  const info = _react.default.useCallback(message => {
    show(message, {
      variant: "info",
      icon: "infoFilled",
      hapticFeedback: "impactMedium"
    });
  }, [show]);
  const success = _react.default.useCallback(message => {
    show(message, {
      variant: "success",
      icon: "success",
      hapticFeedback: "notificationSuccess"
    });
  }, [show]);
  const warning = _react.default.useCallback(message => {
    show(message, {
      variant: "warning",
      icon: "warningFilled",
      hapticFeedback: "notificationWarning"
    });
  }, [show]);
  return _react.default.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__*/_react.default.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