'use client';

import { useEffect, useState } from "react";

//#region src/hooks/useKeyboardDetector.ts
const useKeyboardDetector = () => {
	const [windowHeight, setWindowHeight] = useState(null);
	useEffect(() => {
		const updateHeight = () => {
			if (Boolean(window.visualViewport?.height && window.visualViewport.height < window.innerHeight - 100) && window.visualViewport) setWindowHeight(window.visualViewport.height);
			else setWindowHeight(null);
		};
		window.visualViewport?.addEventListener("resize", updateHeight, { passive: true });
		updateHeight();
		return () => {
			window.visualViewport?.removeEventListener("resize", updateHeight);
		};
	}, []);
	return {
		windowHeight,
		isKeyboardOpen: windowHeight !== null
	};
};

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