"use strict";

import { createRef, useCallback, useContext, useMemo } from "react";
import { ToastContext } from "./context";
export const useIOToast = () => {
  const {
    addToast,
    removeToast,
    removeAllToasts
  } = useContext(ToastContext);
  const show = useCallback((message, options) => {
    addToast({
      message,
      ...options
    });
  }, [addToast]);
  const error = useCallback(message => {
    show(message, {
      variant: "error",
      icon: "errorFilled",
      hapticFeedback: "notificationError"
    });
  }, [show]);
  const info = useCallback(message => {
    show(message, {
      variant: "info",
      icon: "infoFilled",
      hapticFeedback: "impactMedium"
    });
  }, [show]);
  const success = useCallback(message => {
    show(message, {
      variant: "success",
      icon: "success",
      hapticFeedback: "notificationSuccess"
    });
  }, [show]);
  const warning = useCallback(message => {
    show(message, {
      variant: "warning",
      icon: "warningFilled",
      hapticFeedback: "notificationWarning"
    });
  }, [show]);
  return useMemo(() => ({
    show,
    error,
    info,
    success,
    warning,
    hide: removeToast,
    hideAll: removeAllToasts
  }), [show, error, info, success, warning, removeToast, removeAllToasts]);
};
export const IOToastRef = /*#__PURE__*/createRef();
export const 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