/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
"use client";
import { getViewportHeightPx } from "./utils.js";
import { useEffect, useState } from "react";
//#region src/components/client/BottomSheet/useViewportHeight.ts
/**
* Hook to get the viewport height in pixels.
* @returns The viewport height in pixels.
*/
function useViewportHeight() {
	const [viewportHeightPx, setViewportHeightPx] = useState(getViewportHeightPx);
	useEffect(() => {
		if (typeof window === "undefined") return;
		function onResize() {
			setViewportHeightPx(getViewportHeightPx());
		}
		onResize();
		window.addEventListener("resize", onResize);
		window.visualViewport?.addEventListener("resize", onResize);
		return () => {
			window.removeEventListener("resize", onResize);
			window.visualViewport?.removeEventListener("resize", onResize);
		};
	}, []);
	return viewportHeightPx;
}
//#endregion
export { useViewportHeight };
