import { cn } from "./index3.js";
import { useControllableState } from "./index11.js";
import { AnimatePresence } from "./index308.js";
import { motion } from "./index359.js";
import { MarkdownRenderer } from "./index417.js";
import { cva } from "class-variance-authority";
import { ChevronDown, ChevronRight, Lightbulb } from "lucide-react";
import * as React from "react";
import { jsx, jsxs } from "react/jsx-runtime";
//#region src/components/organisms/ai/AIReasoningBlock/AIReasoningBlock.tsx
var reasoningBlockVariants = cva("overflow-hidden rounded-xl border transition-colors", {
	variants: {
		variant: {
			default: "border-border bg-muted",
			thinking: "border-primary bg-primary/10",
			subtle: "border-border bg-background"
		},
		state: {
			idle: "",
			streaming: "border-primary"
		}
	},
	defaultVariants: {
		variant: "default",
		state: "idle"
	}
});
function ThinkingIndicator({ className }) {
	return /* @__PURE__ */ jsxs("div", {
		className: cn("flex items-center gap-1", className),
		role: "status",
		"aria-label": "Thinking",
		children: [
			/* @__PURE__ */ jsx(motion.span, {
				className: "size-1.5 rounded-full bg-primary motion-reduce:animate-none",
				animate: { opacity: [
					.3,
					1,
					.3
				] },
				transition: {
					duration: 1.5,
					repeat: Number.POSITIVE_INFINITY,
					delay: 0
				}
			}),
			/* @__PURE__ */ jsx(motion.span, {
				className: "size-1.5 rounded-full bg-primary motion-reduce:animate-none",
				animate: { opacity: [
					.3,
					1,
					.3
				] },
				transition: {
					duration: 1.5,
					repeat: Number.POSITIVE_INFINITY,
					delay: .2
				}
			}),
			/* @__PURE__ */ jsx(motion.span, {
				className: "size-1.5 rounded-full bg-primary motion-reduce:animate-none",
				animate: { opacity: [
					.3,
					1,
					.3
				] },
				transition: {
					duration: 1.5,
					repeat: Number.POSITIVE_INFINITY,
					delay: .4
				}
			})
		]
	});
}
function AIReasoningTrigger({ title = "Reasoning", isOpen, onToggle, isStreaming = false, duration, contentId, className }) {
	return /* @__PURE__ */ jsxs("button", {
		type: "button",
		onClick: onToggle,
		"aria-expanded": isOpen,
		"aria-controls": contentId,
		className: cn("flex items-center justify-between w-full px-4 py-3 transition-colors hover:bg-fg-primary/5 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring rounded-xl", className),
		children: [/* @__PURE__ */ jsxs("div", {
			className: "flex items-center gap-2",
			children: [
				/* @__PURE__ */ jsx(Lightbulb, {
					className: cn("size-4", isStreaming ? "text-primary" : "text-quaternary-foreground"),
					"aria-hidden": "true"
				}),
				/* @__PURE__ */ jsx("span", {
					className: "text-sm font-medium text-foreground",
					children: title
				}),
				isStreaming && /* @__PURE__ */ jsx(ThinkingIndicator, {}),
				duration && !isStreaming && /* @__PURE__ */ jsx("span", {
					className: "text-xs text-muted-foreground",
					children: duration
				})
			]
		}), isOpen ? /* @__PURE__ */ jsx(ChevronDown, {
			className: "size-4 text-muted-foreground transition-transform",
			"aria-hidden": "true"
		}) : /* @__PURE__ */ jsx(ChevronRight, {
			className: "size-4 text-muted-foreground rtl:rotate-180 transition-transform",
			"aria-hidden": "true"
		})]
	});
}
AIReasoningTrigger.displayName = "AIReasoningTrigger";
function AIReasoningContent({ children, markdown = true, className }) {
	return /* @__PURE__ */ jsx("div", {
		className: cn("px-4 pb-4", className),
		children: markdown && typeof children === "string" ? /* @__PURE__ */ jsx(MarkdownRenderer, {
			className: "text-sm text-secondary-foreground",
			children
		}) : /* @__PURE__ */ jsx("div", {
			className: "text-sm text-secondary-foreground",
			children
		})
	});
}
AIReasoningContent.displayName = "AIReasoningContent";
function AIReasoningBlock({ children, title = "Reasoning", open: controlledOpen, defaultOpen = false, onOpenChange, isStreaming = false, markdown = true, duration, variant, className }) {
	const contentId = React.useId();
	const [isOpen, setIsOpen] = useControllableState({
		value: controlledOpen,
		defaultValue: defaultOpen,
		onChange: onOpenChange
	});
	const handleToggle = () => {
		setIsOpen(!isOpen);
	};
	return /* @__PURE__ */ jsxs("div", {
		"data-slot": "ai-reasoning-block",
		className: cn(reasoningBlockVariants({
			variant: isStreaming ? "thinking" : variant,
			state: isStreaming ? "streaming" : "idle"
		}), className),
		children: [/* @__PURE__ */ jsx(AIReasoningTrigger, {
			title,
			isOpen,
			onToggle: handleToggle,
			isStreaming,
			duration,
			contentId
		}), /* @__PURE__ */ jsx(AnimatePresence, { children: isOpen && /* @__PURE__ */ jsx(motion.div, {
			id: contentId,
			role: "region",
			"aria-label": title,
			initial: {
				height: 0,
				opacity: 0
			},
			animate: {
				height: "auto",
				opacity: 1
			},
			exit: {
				height: 0,
				opacity: 0
			},
			transition: { duration: .2 },
			className: "overflow-hidden",
			children: /* @__PURE__ */ jsx(AIReasoningContent, {
				markdown,
				children
			})
		}) })]
	});
}
AIReasoningBlock.displayName = "AIReasoningBlock";
function AIThinkingBar({ text = "Thinking...", isThinking = true, action, className }) {
	if (!isThinking) return null;
	return /* @__PURE__ */ jsxs(motion.div, {
		"data-slot": "ai-thinking-bar",
		initial: {
			opacity: 0,
			y: -10
		},
		animate: {
			opacity: 1,
			y: 0
		},
		exit: {
			opacity: 0,
			y: -10
		},
		className: cn("flex items-center justify-between px-4 py-2 rounded-lg bg-primary/10 border border-primary motion-reduce:animate-none", className),
		children: [/* @__PURE__ */ jsxs("div", {
			className: "flex items-center gap-2",
			children: [
				/* @__PURE__ */ jsx(Lightbulb, {
					className: "size-4 text-primary",
					"aria-hidden": "true"
				}),
				/* @__PURE__ */ jsx("span", {
					className: "text-sm text-primary",
					children: text
				}),
				/* @__PURE__ */ jsx(ThinkingIndicator, {})
			]
		}), action]
	});
}
AIThinkingBar.displayName = "AIThinkingBar";
//#endregion
export { AIReasoningBlock, AIReasoningContent, AIReasoningTrigger, AIThinkingBar, ThinkingIndicator, reasoningBlockVariants };

//# sourceMappingURL=index432.js.map