import { c } from "react-compiler-runtime";
import { useEffect, useState } from "react";
//#region src/utilities/useDevicePixelRatio.ts
/**
* React hook that returns the device's current pixel ratio according to `window.devicePixelRatio`
*
* This hook will automatically re-render a component if `window.devicePixelRatio` changes (due to monitor preference changes or moving windows between monitors).
*/
function useDevicePixelRatio() {
	const $ = c(3);
	const [devicePixelRatio, updateDevicePixelRatio] = useState(window.devicePixelRatio);
	let t0;
	let t1;
	if ($[0] !== devicePixelRatio) {
		t0 = () => {
			const mm = matchMedia(`(resolution: ${devicePixelRatio}dppx)`);
			const handler = () => {
				updateDevicePixelRatio(window.devicePixelRatio);
			};
			mm.addListener(handler);
			return () => mm.removeListener(handler);
		};
		t1 = [devicePixelRatio];
		$[0] = devicePixelRatio;
		$[1] = t0;
		$[2] = t1;
	} else {
		t0 = $[1];
		t1 = $[2];
	}
	useEffect(t0, t1);
	return devicePixelRatio;
}
//#endregion
export { useDevicePixelRatio as default };

//# sourceMappingURL=useDevicePixelRatio.mjs.map