"use client";
import { useCallback, useRef, useState } from "react";
//#region packages/@mantine/hooks/src/use-intersection/use-intersection.ts
function useIntersection(options) {
	const [entry, setEntry] = useState(null);
	const observer = useRef(null);
	return {
		ref: useCallback((element) => {
			if (observer.current) {
				observer.current.disconnect();
				observer.current = null;
			}
			if (element === null) {
				setEntry(null);
				return;
			}
			observer.current = new IntersectionObserver(([_entry]) => {
				setEntry(_entry);
			}, options);
			observer.current.observe(element);
		}, [
			options?.rootMargin,
			options?.root,
			options?.threshold
		]),
		entry
	};
}
//#endregion
export { useIntersection };

//# sourceMappingURL=use-intersection.mjs.map