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);

// src/hooks/focus/useFocusGuards.ts
var useFocusGuards_exports = {};
__export(useFocusGuards_exports, {
  useFocusGuards: () => useFocusGuards
});
module.exports = __toCommonJS(useFocusGuards_exports);
var import_react = require("react");
var selectorName = "data-hw-focus-guard";
function FocusGuard() {
  const element = document.createElement("div");
  element.setAttribute(selectorName, "");
  element.tabIndex = 0;
  element.style.border = "none";
  element.style.outline = "none";
  element.style.boxShadow = "none";
  element.style.opacity = "0";
  element.style.position = "fixed";
  element.style.pointerEvents = "none";
  return element;
}
var FocusGuardsService = class _FocusGuardsService {
  constructor() {
    this.count = 0;
  }
  static getInstance() {
    if (!_FocusGuardsService.instance) {
      _FocusGuardsService.instance = new _FocusGuardsService();
    }
    return _FocusGuardsService.instance;
  }
  add() {
    const edgeGuards = document.querySelectorAll(`[${selectorName}]`);
    document.body.insertAdjacentElement("afterbegin", edgeGuards[0] ?? FocusGuard());
    document.body.insertAdjacentElement("beforeend", edgeGuards[1] ?? FocusGuard());
    this.count++;
  }
  remove() {
    if (this.count === 1) {
      document.querySelectorAll(`[${selectorName}]`).forEach((node) => node.remove());
    }
    this.count--;
  }
};
var useFocusGuards = () => {
  (0, import_react.useEffect)(() => {
    FocusGuardsService.getInstance().add();
    return () => {
      FocusGuardsService.getInstance().remove();
    };
  }, []);
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  useFocusGuards
});
//# sourceMappingURL=useFocusGuards.cjs.map