/*! ratio-ui · design system for knowledge sharing · https://github.com/losol/ratio-ui · (c) 2026 Losol AS · MPL-2.0 */
import { useEffect, useState } from "react";
//#region src/visuals/Progress/useProgressAnimation.ts
var colorTokens = {
	primary: "var(--color-primary-700)",
	success: "var(--color-success-600)",
	warning: "var(--color-warning-500)",
	error: "var(--color-error-600)",
	info: "var(--color-info-600)",
	neutral: "var(--color-neutral-500)"
};
/** Resolves a semantic color name to a CSS value, or passes through raw values. */
function resolveColor(color) {
	return colorTokens[color] ?? color;
}
/**
* Shared logic for animated progress components.
* Returns the clamped percentage and a flag that flips to `true`
* after first paint so CSS transitions can kick in.
*/
function useProgressAnimation(value, max) {
	const [animated, setAnimated] = useState(false);
	useEffect(() => {
		const id = requestAnimationFrame(() => setAnimated(true));
		return () => cancelAnimationFrame(id);
	}, []);
	return {
		pct: max > 0 ? Math.min(Math.max(value / max, 0), 1) : 0,
		animated
	};
}
//#endregion
export { resolveColor, useProgressAnimation };

//# sourceMappingURL=useProgressAnimation.js.map