'use client';

import { useGetElementOrWindow } from "../useGetElementOrWindow.mjs";
import { useScrollBlockageStore } from "./useScrollBlockageStore.mjs";
import { useEffect } from "react";
import { useShallow } from "zustand/react/shallow";

//#region src/hooks/useScrollBlockage/index.tsx
const useScrollBlockage = (props) => {
	const { disableScroll = false, element, key = "unnamed_blocker" } = props ?? {};
	const { isElementScrollBlocked, addBlockage, removeBlockage } = useScrollBlockageStore(useShallow((s) => ({
		isElementScrollBlocked: s.isElementScrollBlocked,
		addBlockage: s.addBlockage,
		removeBlockage: s.removeBlockage
	})));
	const containerElement = useGetElementOrWindow(element);
	useEffect(() => {
		const el = element ?? window.document.body;
		if (disableScroll) addBlockage(key, el);
		else removeBlockage(key, el);
	}, [
		addBlockage,
		disableScroll,
		element,
		key,
		removeBlockage
	]);
	return { isScrollBlocked: containerElement ? isElementScrollBlocked(containerElement) : false };
};

//#endregion
export { useScrollBlockage };
//# sourceMappingURL=index.mjs.map