import { useRef as u, useCallback as c, useEffect as v } from "react";
function L() {
  let o = u(/* @__PURE__ */ new Map()), s = c((e, l, r, t) => {
    let n = t?.once ? (...f) => {
      o.current.delete(r), r(...f);
    } : r;
    o.current.set(r, {
      type: l,
      eventTarget: e,
      fn: n,
      options: t
    }), e.addEventListener(l, n, t);
  }, []), a = c((e, l, r, t) => {
    var n;
    let f = ((n = o.current.get(r)) === null || n === void 0 ? void 0 : n.fn) || r;
    e.removeEventListener(l, f, t), o.current.delete(r);
  }, []), d = c(() => {
    o.current.forEach((e, l) => {
      a(e.eventTarget, e.type, l, e.options);
    });
  }, [
    a
  ]);
  return v(() => d, [
    d
  ]), {
    addGlobalListener: s,
    removeGlobalListener: a,
    removeAllGlobalListeners: d
  };
}
export {
  L as $
};
//# sourceMappingURL=useGlobalListeners-BOOfV5Wh.es.js.map
