import { cn } from "./index3.js";
import { useReducedMotion } from "./index361.js";
import { useAnimate } from "./index375.js";
/* empty css         */
import * as React from "react";
import { jsx, jsxs } from "react/jsx-runtime";
//#region src/components/organisms/ai/AIThinkingLoader/AIThinkingLoader.tsx
function AnimatedProgressOvals({ className, animationDuration = 3e3, easing = "ease-in-out" }) {
	const prefersReducedMotion = useReducedMotion();
	return /* @__PURE__ */ jsxs("div", {
		"data-slot": "thinking-oval",
		"aria-hidden": "true",
		className: cn("absolute top-0 bottom-0 pointer-events-none", className),
		style: prefersReducedMotion ? void 0 : {
			left: 0,
			right: "100%",
			animationName: "thinking-grow-empty",
			animationDuration: `${animationDuration}ms`,
			animationTimingFunction: easing,
			animationIterationCount: "infinite",
			willChange: "left, right, transform"
		},
		children: [
			/* @__PURE__ */ jsx("div", {
				className: "absolute rounded-full bg-brand-200 opacity-20",
				style: { inset: -40 }
			}),
			/* @__PURE__ */ jsx("div", {
				className: "absolute rounded-full bg-brand-200 opacity-50",
				style: { inset: -20 }
			}),
			/* @__PURE__ */ jsx("div", {
				className: "absolute rounded-full bg-brand-200 opacity-70",
				style: { inset: 0 }
			})
		]
	});
}
AnimatedProgressOvals.displayName = "AnimatedProgressOvals";
function CountdownTimer({ initialTime = 5, isActive = true, onComplete, className }) {
	const [timeLeft, setTimeLeft] = React.useState(initialTime);
	const [scope, animate] = useAnimate();
	const prefersReducedMotion = useReducedMotion();
	const isFirstTick = React.useRef(true);
	React.useEffect(() => {
		setTimeLeft(initialTime);
	}, [initialTime]);
	React.useEffect(() => {
		if (!isActive) return;
		const timer = setInterval(() => {
			setTimeLeft((prev) => {
				if (prev <= 1) {
					onComplete?.();
					return initialTime;
				}
				return prev - 1;
			});
		}, 1e3);
		return () => clearInterval(timer);
	}, [
		isActive,
		initialTime,
		onComplete
	]);
	React.useEffect(() => {
		if (isFirstTick.current) {
			isFirstTick.current = false;
			return;
		}
		if (!prefersReducedMotion && scope.current) animate(scope.current, {
			scale: [1.12, 1],
			y: [-2, 0]
		}, {
			duration: .3,
			ease: [
				.25,
				1,
				.5,
				1
			]
		});
	}, [
		timeLeft,
		animate,
		prefersReducedMotion,
		scope
	]);
	return /* @__PURE__ */ jsx("div", {
		ref: scope,
		role: "timer",
		"aria-label": `${timeLeft} seconds remaining`,
		className: cn("flex items-center justify-center px-3 py-2 rounded-full bg-card/20 shrink-0", !prefersReducedMotion && "animate-[thinking-pop-in_0.3s_ease-out_0.3s_both]", className),
		children: /* @__PURE__ */ jsxs("span", {
			className: "text-sm text-foreground tabular-nums",
			children: [timeLeft, "s"]
		})
	});
}
CountdownTimer.displayName = "CountdownTimer";
function AIThinkingLoader({ loadingText = "Transferring to AI Agent: Meeting Manager", easing = "ease-in-out", showCountdown = true, countdownTime = 5, animationDuration = 3e3, onAnimationComplete, className }) {
	const clipRef = React.useRef(null);
	const prefersReducedMotion = useReducedMotion();
	React.useEffect(() => {
		if (!onAnimationComplete) return;
		const oval = clipRef.current?.querySelector("[data-slot=\"thinking-oval\"]");
		if (!oval) return;
		const handler = () => onAnimationComplete();
		oval.addEventListener("animationiteration", handler);
		return () => oval.removeEventListener("animationiteration", handler);
	}, [onAnimationComplete]);
	return /* @__PURE__ */ jsxs("div", {
		"data-slot": "ai-thinking-loader",
		role: "status",
		"aria-live": "polite",
		"aria-busy": "true",
		"aria-label": loadingText,
		className: cn("relative flex items-center justify-center gap-2 min-h-[3.25rem] px-4 py-2 rounded-full border border-border bg-card/60", className),
		style: prefersReducedMotion ? void 0 : { animation: "thinking-fade-in 0.5s ease-out forwards, thinking-glow 4s ease-in-out 0.5s infinite" },
		children: [
			/* @__PURE__ */ jsx("div", {
				ref: clipRef,
				className: "absolute inset-0 overflow-clip rounded-full",
				children: /* @__PURE__ */ jsx(AnimatedProgressOvals, {
					easing,
					animationDuration
				})
			}),
			/* @__PURE__ */ jsx("span", {
				className: cn("relative z-10 text-sm text-foreground whitespace-nowrap truncate font-medium", !prefersReducedMotion && "animate-[thinking-slide-in_0.35s_ease-out_0.15s_both]"),
				children: loadingText
			}),
			showCountdown && /* @__PURE__ */ jsx(CountdownTimer, {
				initialTime: countdownTime,
				isActive: true,
				className: "relative z-10"
			})
		]
	});
}
AIThinkingLoader.displayName = "AIThinkingLoader";
//#endregion
export { AIThinkingLoader, CountdownTimer };

//# sourceMappingURL=index445.js.map