import { useRef as i, useEffect as E } from "react";
const c = ["mousedown", "touchstart"], f = (t, u = c, n = !0) => {
  const r = i(null);
  return d(r, t, u, n), r;
}, d = (t, u, n = c, r = !0) => {
  E(() => {
    if (!r)
      return;
    const o = t && "current" in t ? t.current : t, s = (e) => {
      o && !o.contains(e.target) && u(e);
    };
    return n.forEach((e) => {
      document.addEventListener(e, s);
    }), () => {
      n.forEach((e) => {
        document.removeEventListener(e, s);
      });
    };
  }, [t, u, n, r]);
};
export {
  c as DEFAULT_EVENT_TYPES,
  f as default,
  d as useClickOutsideWithRef
};
//# sourceMappingURL=useClickOutside.js.map
