"use client";
import { cn } from "../../lib/utils.js";
import { Button } from "../ui/button.js";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../ui/tooltip.js";
import { _r } from "../../node_modules/streamdown/dist/chunk-RLXIAIE6.js";
import "../../node_modules/streamdown/dist/index.js";
import "../ui/button-group.js";
import { c } from "react/compiler-runtime";
import { createContext, memo, useContext, useEffect, useState } from "react";
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
import { ChevronRightIcon, XIcon } from "lucide-react";
const Message = (i) => {
	let a = c(10), o, s, l;
	a[0] === i ? (o = a[1], s = a[2], l = a[3]) : ({className: o, from: s, ...l} = i, a[0] = i, a[1] = o, a[2] = s, a[3] = l);
	let u = s === "user" ? "is-user ml-auto max-w-[80%] justify-end" : "is-assistant", f;
	a[4] !== o || a[5] !== u ? (f = cn("group relative flex w-full flex-col gap-2 rounded-lg transition-colors", u, o), a[4] = o, a[5] = u, a[6] = f) : f = a[6];
	let p;
	return a[7] !== l || a[8] !== f ? (p = /* @__PURE__ */ jsx("div", {
		className: f,
		...l
	}), a[7] = l, a[8] = f, a[9] = p) : p = a[9], p;
}, MessageContent = (i) => {
	let a = c(10), o, s, l;
	a[0] === i ? (o = a[1], s = a[2], l = a[3]) : ({children: o, className: s, ...l} = i, a[0] = i, a[1] = o, a[2] = s, a[3] = l);
	let u;
	a[4] === s ? u = a[5] : (u = cn("is-user:dark flex w-fit flex-col gap-2 overflow-hidden", "group-[.is-user]:bg-secondary group-[.is-user]:text-foreground group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:px-4 group-[.is-user]:py-3", "group-[.is-assistant]:text-foreground", s), a[4] = s, a[5] = u);
	let f;
	return a[6] !== o || a[7] !== l || a[8] !== u ? (f = /* @__PURE__ */ jsx("div", {
		className: u,
		...l,
		children: o
	}), a[6] = o, a[7] = l, a[8] = u, a[9] = f) : f = a[9], f;
}, MessageActions = (i) => {
	let a = c(10), o, s, l;
	a[0] === i ? (o = a[1], s = a[2], l = a[3]) : ({className: s, children: o, ...l} = i, a[0] = i, a[1] = o, a[2] = s, a[3] = l);
	let u;
	a[4] === s ? u = a[5] : (u = cn("absolute top-0 right-0 flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100", s), a[4] = s, a[5] = u);
	let f;
	return a[6] !== o || a[7] !== l || a[8] !== u ? (f = /* @__PURE__ */ jsx("div", {
		className: u,
		...l,
		children: o
	}), a[6] = o, a[7] = l, a[8] = u, a[9] = f) : f = a[9], f;
}, MessageAction = (e) => {
	let u = c(22), f, p, m, h, g, _;
	u[0] === e ? (f = u[1], p = u[2], m = u[3], h = u[4], g = u[5], _ = u[6]) : ({tooltip: _, children: f, label: p, variant: h, size: g, ...m} = e, u[0] = e, u[1] = f, u[2] = p, u[3] = m, u[4] = h, u[5] = g, u[6] = _);
	let v = h === void 0 ? "ghost" : h, y = g === void 0 ? "icon-sm" : g, b = p || _, x;
	u[7] === b ? x = u[8] : (x = /* @__PURE__ */ jsx("span", {
		className: "sr-only",
		children: b
	}), u[7] = b, u[8] = x);
	let S;
	u[9] !== f || u[10] !== m || u[11] !== y || u[12] !== x || u[13] !== v ? (S = /* @__PURE__ */ jsxs(Button, {
		size: y,
		type: "button",
		variant: v,
		...m,
		children: [f, x]
	}), u[9] = f, u[10] = m, u[11] = y, u[12] = x, u[13] = v, u[14] = S) : S = u[14];
	let C = S;
	if (_) {
		let e;
		u[15] === C ? e = u[16] : (e = /* @__PURE__ */ jsx(TooltipTrigger, {
			asChild: !0,
			children: C
		}), u[15] = C, u[16] = e);
		let i;
		u[17] === _ ? i = u[18] : (i = /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: _ }) }), u[17] = _, u[18] = i);
		let d;
		return u[19] !== e || u[20] !== i ? (d = /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [e, i] }) }), u[19] = e, u[20] = i, u[21] = d) : d = u[21], d;
	}
	return C;
};
createContext(null);
const MessageResponse = memo((i) => {
	let a = c(8), o, s;
	a[0] === i ? (o = a[1], s = a[2]) : ({className: o, ...s} = i, a[0] = i, a[1] = o, a[2] = s);
	let l;
	a[3] === o ? l = a[4] : (l = cn("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", o), a[3] = o, a[4] = l);
	let f;
	return a[5] !== s || a[6] !== l ? (f = /* @__PURE__ */ jsx(_r, {
		className: l,
		...s
	}), a[5] = s, a[6] = l, a[7] = f) : f = a[7], f;
}, (e, i) => e.children === i.children);
MessageResponse.displayName = "MessageResponse";
export { Message, MessageAction, MessageActions, MessageContent, MessageResponse };
