"use client";
import { twMerge as e } from "./helpers/twMerge.js";
import { ChatInput as t } from "./ChatInput.js";
import { t as n } from "../chunks/ChatMessage.js";
import { ChatTypingIndicator as r } from "./ChatTypingIndicator.js";
import { useEffect as i, useRef as a } from "react";
import { Icon as o } from "@clubmed/trident-icons";
import { jsx as s, jsxs as c } from "react/jsx-runtime";
//#region lib/ui/ChatWindow.tsx
var l = /* @__PURE__ */ s("svg", {
	className: "absolute top-full inset-x-[50%] -translate-x-1/2",
	width: "118",
	height: "27",
	viewBox: "0 0 118 27",
	children: /* @__PURE__ */ s("path", {
		d: "M0 0C10.8283 0 21.1946 5.40419 28.7327 13.2062L30.2673 14.7945C45.991 31.0685 72.009 31.0685 87.7327 14.7945L89.2673 13.2062C96.8054 5.40419 107.172 0 118 0C118 0 80.6853 0 0 0Z",
		fill: "#F6EFE7"
	})
});
function u({ title: u = "Ask me a question", greeting: d, messages: f, inputValue: p, inputPlaceholder: m, isTyping: h = !1, onInputChange: g, onSubmit: _, onClose: v, onAudioClick: y, logo: b, className: x, ...S }) {
	let C = a(null);
	return i(() => {
		let e = C.current;
		e && e.scrollTo({
			top: e.scrollHeight,
			behavior: "smooth"
		});
	}, [f, h]), /* @__PURE__ */ c("div", {
		...S,
		className: e("flex flex-col gap-20 items-center", x),
		children: [/* @__PURE__ */ c("div", {
			className: "chat-border bg-white flex flex-col h-full w-full rounded-32 overflow-hidden",
			children: [
				/* @__PURE__ */ c("div", {
					className: "relative flex flex-col items-center shrink-0 pt-4 px-4 h-133 overflow-hidden",
					children: [/* @__PURE__ */ s("div", {
						className: "absolute inset-x-4 top-4 h-102 bg-lightSand rounded-[24]",
						children: l
					}), /* @__PURE__ */ c("div", {
						className: "relative flex flex-col flex-1 items-center justify-end pb-8 w-full z-10",
						children: [/* @__PURE__ */ s("div", {
							className: "flex items-center justify-center px-12 py-8 w-full",
							children: /* @__PURE__ */ s("p", {
								className: "font-serif font-bold italic text-h5 text-center text-black line-clamp-2",
								children: u
							})
						}), b ?? /* @__PURE__ */ s("button", {
							type: "button",
							"aria-label": "AI assistant",
							className: "chat-border flex items-center justify-center size-48 rounded-full bg-white",
							children: /* @__PURE__ */ s(o, {
								name: "Sparkles",
								width: "24px"
							})
						})]
					})]
				}),
				/* @__PURE__ */ c("div", {
					ref: C,
					role: "log",
					"aria-label": "Chat messages",
					"aria-live": "polite",
					className: "chat-message-log flex flex-col flex-1 gap-20 overflow-y-auto py-20",
					children: [
						d ? /* @__PURE__ */ s("div", {
							className: "px-20",
							children: /* @__PURE__ */ s("p", {
								className: "text-b3 text-black",
								children: d
							})
						}) : null,
						f.map((e) => /* @__PURE__ */ s(n, {
							sender: e.sender,
							children: e.content
						}, e.id)),
						h && /* @__PURE__ */ s("div", {
							className: "px-12",
							children: /* @__PURE__ */ s(r, {})
						})
					]
				}),
				/* @__PURE__ */ s("div", {
					className: "shrink-0 px-8 pb-8 pt-12",
					children: /* @__PURE__ */ s(t, {
						value: p,
						placeholder: m,
						onValueChange: g,
						onSubmit: _,
						onAudioClick: y
					})
				})
			]
		}), v && /* @__PURE__ */ s("button", {
			type: "button",
			"aria-label": "Close chat",
			onClick: v,
			className: "flex items-center justify-center size-48 rounded-full bg-black border border-black text-white shrink-0 hover:opacity-80 transition-opacity",
			children: /* @__PURE__ */ s(o, {
				name: "CrossDefault",
				width: "24px"
			})
		})]
	});
}
//#endregion
export { u as ChatWindow };

//# sourceMappingURL=ChatWindow.js.map