import "react";
import { jsx as e, jsxs as t } from "react/jsx-runtime";
//#region src/features/documents/renderers/AiMessageContent.tsx
var n = (e, t) => e instanceof URL ? e.toString() : typeof e == "string" ? `data:${t || "application/octet-stream"};base64,${e}` : "#", r = ({ part: t }) => /* @__PURE__ */ e("div", {
	className: "text-sm leading-relaxed whitespace-pre-wrap",
	children: t.text
}), i = ({ part: r }) => /* @__PURE__ */ t("div", { children: [/* @__PURE__ */ e("img", {
	src: n(r.image, r.mediaType),
	alt: "Uploaded image",
	className: "h-auto max-w-full rounded-lg border shadow-sm",
	style: { maxHeight: "400px" }
}), r.mediaType && /* @__PURE__ */ t("div", {
	className: "mt-1 text-xs text-gray-500",
	children: ["Type: ", r.mediaType]
})] }), a = ({ part: n }) => /* @__PURE__ */ e("div", { children: /* @__PURE__ */ t("div", {
	className: "flex items-center space-x-2",
	children: [/* @__PURE__ */ e("div", {
		className: "text-2xl",
		children: "📎"
	}), /* @__PURE__ */ t("div", { children: [/* @__PURE__ */ e("div", {
		className: "text-sm font-medium",
		children: n.filename || "Unnamed file"
	}), /* @__PURE__ */ e("div", {
		className: "text-xs text-gray-500",
		children: n.mediaType
	})] })]
}) }), o = ({ part: n }) => n.text ? /* @__PURE__ */ t("div", { children: [/* @__PURE__ */ e("div", {
	className: "mb-2 flex items-center space-x-2",
	children: /* @__PURE__ */ e("div", {
		className: "text-sm font-medium text-purple-600",
		children: "Reasoning"
	})
}), /* @__PURE__ */ e("div", {
	className: "text-sm whitespace-pre-wrap text-purple-800",
	children: n.text
})] }) : "", s = ({ part: n }) => /* @__PURE__ */ t("div", { children: [/* @__PURE__ */ t("div", {
	className: "mb-2 flex items-center justify-between",
	children: [/* @__PURE__ */ t("div", {
		className: "flex items-center space-x-2",
		children: [/* @__PURE__ */ e("div", {
			className: "text-sm font-medium",
			children: n.toolName
		}), n.providerExecuted && /* @__PURE__ */ e("span", {
			className: "rounded bg-green-100 px-2 py-1 text-xs text-green-800",
			children: "Executed"
		})]
	}), /* @__PURE__ */ t("div", {
		className: "ml-5 font-mono text-xs text-gray-500",
		children: ["ID: ", n.toolCallId]
	})]
}), n.input ? /* @__PURE__ */ t("div", {
	className: "rounded border bg-white p-2 text-xs",
	children: [/* @__PURE__ */ e("div", {
		className: "mb-1 text-gray-600",
		children: "Input:"
	}), /* @__PURE__ */ e("pre", {
		className: "overflow-x-auto whitespace-pre-wrap",
		children: JSON.stringify(n.input, null, 2)
	})]
}) : ""] }), c = ({ part: n }) => /* @__PURE__ */ t("div", { children: [/* @__PURE__ */ t("div", {
	className: "mb-2 flex items-center justify-between",
	children: [/* @__PURE__ */ t("div", {
		className: "text-sm font-medium",
		children: [n.toolName, " Result"]
	}), /* @__PURE__ */ t("div", {
		className: "ml-5 font-mono text-xs text-gray-500",
		children: ["ID: ", n.toolCallId]
	})]
}), /* @__PURE__ */ e("div", {
	className: "rounded border bg-white p-2 text-xs",
	children: /* @__PURE__ */ e("pre", {
		className: "overflow-x-auto whitespace-pre-wrap",
		children: JSON.stringify(n.output, null, 2)
	})
})] }), l = ({ message: n }) => {
	let l = (n, l) => {
		switch (n.type) {
			case "text": return /* @__PURE__ */ e(r, { part: n }, l);
			case "image": return /* @__PURE__ */ e(i, { part: n }, l);
			case "file": return /* @__PURE__ */ e(a, { part: n }, l);
			case "reasoning": return /* @__PURE__ */ e(o, { part: n }, l);
			case "tool-call": return /* @__PURE__ */ e(s, { part: n }, l);
			case "tool-result": return /* @__PURE__ */ e(c, { part: n }, l);
			default: return /* @__PURE__ */ t("div", {
				className: "rounded bg-gray-100 p-2 text-sm",
				children: ["Unknown content type: ", n.type]
			}, l);
		}
	};
	return /* @__PURE__ */ e("div", {
		className: "message-content",
		children: (() => {
			if (n.role === "system") return /* @__PURE__ */ t("div", {
				className: "rounded-lg border-l-4 border-gray-400 bg-gray-50 p-3 text-sm text-gray-600 italic",
				children: [/* @__PURE__ */ e("div", {
					className: "mb-1 font-medium",
					children: "System"
				}), /* @__PURE__ */ e("div", {
					className: "whitespace-pre-wrap",
					children: n.content
				})]
			});
			let { content: i } = n;
			return typeof i == "string" ? /* @__PURE__ */ e(r, { part: {
				type: "text",
				text: i
			} }) : Array.isArray(i) ? /* @__PURE__ */ e("div", {
				className: "space-y-2",
				children: i.map((e, t) => l(e, t))
			}) : /* @__PURE__ */ e("div", {
				className: "text-sm text-red-600",
				children: "Invalid content format"
			});
		})()
	});
};
//#endregion
export { l as default };
