import { cn as e } from "../../../lib/utils.js";
import { Loader as t } from "../atoms/loader.js";
import { Skeleton as n } from "../atoms/skeleton.js";
import { Message as r, MessageContent as i } from "./message.js";
import { Fragment as a } from "react";
import { jsx as o, jsxs as s } from "react/jsx-runtime";
//#region lib/components/ui/molecules/chat-message-list.tsx
function c({ messages: t, isStreaming: n = !1, renderMessage: r, loadingIndicator: i, children: c, className: f, ...p }) {
	let m = e("mx-auto flex w-full max-w-3xl flex-col gap-8 px-6", f);
	if (c) return /* @__PURE__ */ o("div", {
		"aria-live": "polite",
		className: m,
		"data-slot": "chat-message-list",
		role: "log",
		...p,
		children: c
	});
	if (!t) return null;
	let h = t.at(-1), g = n && (!h || h.role !== "assistant" || !h.content);
	return /* @__PURE__ */ s("div", {
		"aria-live": "polite",
		className: m,
		"data-slot": "chat-message-list",
		role: "log",
		...p,
		children: [t.map((e) => {
			let t = e.role === "user", i = e === h;
			return r ? /* @__PURE__ */ o(a, { children: r(e, {
				isLast: i,
				isStreaming: i && n
			}) }, e.id) : t || e.content ? t ? /* @__PURE__ */ o(l, { children: e.content }, e.id) : /* @__PURE__ */ o(u, {
				isAnimating: i && n,
				children: e.content
			}, e.id) : null;
		}), g && /* @__PURE__ */ o(d, { children: i })]
	});
}
function l({ children: t, className: n, ...a }) {
	return /* @__PURE__ */ o(r, {
		className: e("ml-auto max-w-2xl", n),
		"data-slot": "chat-user-message",
		...a,
		children: /* @__PURE__ */ o(i, {
			className: "rounded-xl bg-primary px-4 py-2 text-primary-foreground",
			children: t
		})
	});
}
function u({ children: e, isAnimating: t, className: n, ...a }) {
	return /* @__PURE__ */ o(r, {
		className: n,
		"data-slot": "chat-assistant-message",
		...a,
		children: typeof e == "string" ? /* @__PURE__ */ o(i, {
			className: "prose-sm bg-transparent p-0 [&_h1]:text-2xl [&_h2]:text-xl [&_h3]:text-lg",
			isAnimating: t,
			markdown: !0,
			children: e
		}) : e
	});
}
function d({ children: n, className: r, ...i }) {
	return /* @__PURE__ */ o("div", {
		className: e("flex items-center gap-2 px-1", r),
		"data-slot": "chat-streaming-indicator",
		...i,
		children: n ?? /* @__PURE__ */ o(t, { variant: "typing" })
	});
}
var f = [
	{
		role: "user",
		lines: 1,
		width: "60%"
	},
	{
		role: "assistant",
		lines: 3,
		width: "85%"
	},
	{
		role: "user",
		lines: 1,
		width: "45%"
	},
	{
		role: "assistant",
		lines: 2,
		width: "75%"
	}
];
function p({ className: t, ...r }) {
	return /* @__PURE__ */ o("div", {
		className: e("mx-auto flex w-full max-w-3xl flex-col gap-8 px-6", t),
		...r,
		children: f.map((e, t) => e.role === "user" ? /* @__PURE__ */ o("div", {
			className: "ml-auto flex max-w-2xl items-start gap-3",
			children: /* @__PURE__ */ o(n, {
				className: "h-10 rounded-xl",
				style: { width: e.width }
			})
		}, `msg-skeleton-${t.toString()}`) : /* @__PURE__ */ o("div", {
			className: "flex flex-col gap-2",
			style: { maxWidth: e.width },
			children: Array.from({ length: e.lines }).map((r, i) => /* @__PURE__ */ o(n, {
				className: "h-4 rounded",
				style: { width: i === e.lines - 1 ? "65%" : "100%" }
			}, `line-${t.toString()}-${i.toString()}`))
		}, `msg-skeleton-${t.toString()}`))
	});
}
//#endregion
export { u as ChatAssistantMessage, c as ChatMessageList, p as ChatMessageListSkeleton, d as ChatStreamingIndicator, l as ChatUserMessage };
