// src/components/Popover/useOutsidePress.ts
import { useEffect } from "react";
var useOutsidePress = ({
  referenceRef,
  floatingRef,
  enabled,
  onOutsidePress
}) => {
  useEffect(() => {
    if (!enabled) return;
    const handler = (event) => {
      const target = event.target;
      if (!target) return;
      if (referenceRef.current?.contains(target)) return;
      if (floatingRef.current?.contains(target)) return;
      onOutsidePress(event);
    };
    document.addEventListener("pointerdown", handler);
    return () => document.removeEventListener("pointerdown", handler);
  }, [enabled, onOutsidePress, referenceRef, floatingRef]);
};

export {
  useOutsidePress
};
//# sourceMappingURL=chunk-WYJP7HVL.js.map
