"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const React = require("react");
const globals = require("../utils/globals.cjs");
function _interopNamespaceDefault(e) {
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
  if (e) {
    for (const k in e) {
      if (k !== "default") {
        const d = Object.getOwnPropertyDescriptor(e, k);
        Object.defineProperty(n, k, d.get ? d : {
          enumerable: true,
          get: () => e[k]
        });
      }
    }
  }
  n.default = e;
  return Object.freeze(n);
}
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
function useEventListener(type, eventHandler, element = globals.Window, options = { passive: true }, enabled = true) {
  React__namespace.useEffect(() => {
    if (element && enabled) {
      element.addEventListener(type, eventHandler, options);
      return () => {
        if (typeof options === "object") {
          const { once, passive, ...removeOptions } = options;
          element.removeEventListener(type, eventHandler, removeOptions);
        } else {
          element.removeEventListener(type, eventHandler, options);
        }
      };
    }
    return void 0;
  }, [eventHandler, element, type, enabled, options]);
}
exports.useEventListener = useEventListener;
//# sourceMappingURL=useEventListener.cjs.map
