import { Message as e, MessageAction as t, MessageActions as n, MessageContent as r, MessageResponse as i } from "../../../components/ai-elements/message.js";
import { Reasoning as a, ReasoningContent as o, ReasoningTrigger as s } from "../../../components/ai-elements/reasoning.js";
import { Tool as c, ToolContent as l, ToolHeader as u, ToolInput as d, ToolOutput as f } from "../../../components/loopstack-elements/tool.js";
import { Fragment as p } from "react";
import { jsx as m, jsxs as h } from "react/jsx-runtime";
import { CopyIcon as g } from "lucide-react";
//#region src/features/documents/renderers/ClaudeMessage.tsx
var _ = ({ document: _ }) => {
	let v = _.content, y = v.id ?? _.id, b = /* @__PURE__ */ new Map();
	if (v.toolResults) for (let e of v.toolResults) b.set(e.tool_use_id, e);
	if (typeof v.content == "string") return /* @__PURE__ */ h(e, {
		from: v.role,
		children: [/* @__PURE__ */ m(r, { children: /* @__PURE__ */ m(i, { children: v.content }) }), v.role === "assistant" && /* @__PURE__ */ m(n, { children: /* @__PURE__ */ m(t, {
			onClick: () => void navigator.clipboard.writeText(v.content),
			label: "Copy",
			children: /* @__PURE__ */ m(g, { className: "size-3" })
		}) })]
	});
	let x = v.content;
	return /* @__PURE__ */ m(p, { children: x.map((p, _) => {
		switch (p.type) {
			case "text": return /* @__PURE__ */ h(e, {
				from: v.role,
				children: [/* @__PURE__ */ m(r, { children: /* @__PURE__ */ m(i, { children: p.text }) }), v.role === "assistant" && /* @__PURE__ */ m(n, { children: /* @__PURE__ */ m(t, {
					onClick: () => void navigator.clipboard.writeText(p.text),
					label: "Copy",
					children: /* @__PURE__ */ m(g, { className: "size-3" })
				}) })]
			}, `${y}-${_}`);
			case "thinking": return /* @__PURE__ */ h(a, {
				className: "w-full",
				isStreaming: !1,
				children: [/* @__PURE__ */ m(s, {}), /* @__PURE__ */ m(o, { children: p.thinking })]
			}, `${y}-${_}`);
			case "tool_use": {
				let t = b.get(p.id), n;
				if (t) try {
					n = JSON.parse(t.content);
				} catch {
					n = t.content;
				}
				return /* @__PURE__ */ m(e, {
					from: "assistant",
					children: /* @__PURE__ */ h(c, { children: [/* @__PURE__ */ m(u, {
						state: t ? t.is_error ? "output-error" : "output-available" : "input-available",
						title: p.name,
						type: "tool-call"
					}), /* @__PURE__ */ h(l, { children: [/* @__PURE__ */ m(d, { input: p.input }), t && /* @__PURE__ */ m(f, {
						output: n,
						errorText: t.is_error ? t.content : ""
					})] })] })
				}, `${y}-${_}`);
			}
			case "tool_result": {
				if (b.size > 0) return null;
				let t;
				try {
					t = JSON.parse(p.content);
				} catch {
					t = p.content;
				}
				return /* @__PURE__ */ m(e, {
					from: "assistant",
					children: /* @__PURE__ */ h(c, { children: [/* @__PURE__ */ m(u, {
						state: p.is_error ? "output-error" : "output-available",
						title: "Tool Result",
						type: "tool-result"
					}), /* @__PURE__ */ m(l, { children: /* @__PURE__ */ m(f, {
						output: t,
						errorText: p.is_error ? p.content : ""
					}) })] })
				}, `${y}-${_}`);
			}
			default: return null;
		}
	}) });
};
//#endregion
export { _ as default };
