"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// packages/block-library/src/navigation/edit/use-navigation-notice.js
var use_navigation_notice_exports = {};
__export(use_navigation_notice_exports, {
  default: () => use_navigation_notice_default
});
module.exports = __toCommonJS(use_navigation_notice_exports);
var import_element = require("@wordpress/element");
var import_data = require("@wordpress/data");
var import_notices = require("@wordpress/notices");
function useNavigationNotice({ name, message = "" } = {}) {
  const noticeRef = (0, import_element.useRef)();
  const { createWarningNotice, removeNotice } = (0, import_data.useDispatch)(import_notices.store);
  const showNotice = (0, import_element.useCallback)(
    (customMsg) => {
      if (noticeRef.current) {
        return;
      }
      noticeRef.current = name;
      createWarningNotice(customMsg || message, {
        id: noticeRef.current,
        type: "snackbar"
      });
    },
    [noticeRef, createWarningNotice, message, name]
  );
  const hideNotice = (0, import_element.useCallback)(() => {
    if (!noticeRef.current) {
      return;
    }
    removeNotice(noticeRef.current);
    noticeRef.current = null;
  }, [noticeRef, removeNotice]);
  return [showNotice, hideNotice];
}
var use_navigation_notice_default = useNavigationNotice;
//# sourceMappingURL=use-navigation-notice.js.map
