import { useEffect as e, useRef as t, useState as n } from "react";
//#region lib/ui/hooks/useCountdown.ts
function r({ duration: r, isPaused: i, isVisible: a }) {
	let [o, s] = n(0), c = t(null), l = t(null), u = t(0);
	return e(() => {
		if (r === !1 || !a) return;
		if (i) {
			l.current === null && c.current !== null && (l.current = Date.now());
			return;
		}
		l.current !== null && (u.current += Date.now() - l.current, l.current = null), c.current === null && (c.current = Date.now());
		let e = setInterval(() => {
			if (c.current === null) return;
			let t = Date.now() - c.current - u.current, n = Math.min(100, t / r * 100);
			s(n), n >= 100 && clearInterval(e);
		}, 16);
		return () => {
			clearInterval(e);
		};
	}, [
		r,
		i,
		a
	]), { progress: o };
}
//#endregion
export { r as useCountdown };

//# sourceMappingURL=useCountdown.js.map