@levo-so/studio 0.3.10 → 0.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,14 @@
1
1
  "use client";
2
- import { _ as e, a as t, b as n, c as r, f as i, g as a, h as o, i as s, l as c, m as l, n as u, o as d, r as f, s as p, t as m, u as h, v as g, x as _, y as v } from "./pillChrome-wmdnlFIE.js";
3
- import { Children as y, createContext as b, isValidElement as x, useCallback as S, useContext as C, useEffect as w, useLayoutEffect as T, useRef as E, useState as D } from "react";
2
+ import { S as e, _ as t, a as n, b as r, c as i, f as a, g as o, h as s, i as c, l, m as u, n as d, o as f, r as p, s as m, t as h, u as g, v as _, x as v, y } from "./pillChrome-QDjBETmP.js";
3
+ import { Children as b, createContext as x, isValidElement as S, useCallback as C, useContext as w, useEffect as T, useLayoutEffect as ee, useRef as E, useState as D } from "react";
4
4
  import { Fragment as O, jsx as k, jsxs as A } from "react/jsx-runtime";
5
- import { ArrowUp as j, Check as M, ChevronDown as N, Copy as P, MessageSquarePlus as F, Mic as ee, RefreshCw as I, Sparkles as te, Square as L, X as R } from "lucide-react";
6
- import { ActionBarPrimitive as z, AssistantRuntimeProvider as ne, ComposerPrimitive as B, MessagePrimitive as V, ThreadPrimitive as H, WebSpeechDictationAdapter as re, useAui as U, useAuiState as W } from "@assistant-ui/react";
5
+ import { ArrowUp as j, Check as M, ChevronDown as N, Copy as P, MessageSquarePlus as F, Mic as I, RefreshCw as L, Sparkles as te, Square as R, X as z } from "lucide-react";
6
+ import { ActionBarPrimitive as B, AssistantRuntimeProvider as ne, ComposerPrimitive as V, MessagePrimitive as H, ThreadPrimitive as U, WebSpeechDictationAdapter as re, useAui as W, useAuiState as G } from "@assistant-ui/react";
7
7
  import { AssistantChatTransport as ie, useChatRuntime as ae } from "@assistant-ui/react-ai-sdk";
8
8
  import { MarkdownTextPrimitive as oe } from "@assistant-ui/react-markdown";
9
9
  import se from "remark-gfm";
10
10
  //#region ../../libraries/ai-chat/src/FollowUpChips.tsx
11
- var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipClassName: i }) => {
11
+ var K = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipClassName: i }) => {
12
12
  if (e.length === 0) return null;
13
13
  let a = [
14
14
  "rounded-full border border-zinc-200 bg-white text-zinc-700",
@@ -40,7 +40,7 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
40
40
  let t = E(null), n = E(null);
41
41
  return n.current !== (e ?? null) && (n.current = e ?? null, t.current = null), {
42
42
  conversationIdRef: t,
43
- handleFinish: S(({ message: e }) => {
43
+ handleFinish: C(({ message: e }) => {
44
44
  let n = e.metadata;
45
45
  if (!n || typeof n != "object") return;
46
46
  let r = n.conversation_id;
@@ -48,7 +48,7 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
48
48
  let i = r.trim();
49
49
  i.length !== 0 && t.current !== i && (t.current = i);
50
50
  }, []),
51
- reset: S(() => {
51
+ reset: C(() => {
52
52
  t.current = null;
53
53
  }, [])
54
54
  };
@@ -57,14 +57,14 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
57
57
  return {
58
58
  followUps: t,
59
59
  setFollowUps: n,
60
- clearOnSend: S(() => n([]), []),
61
- handleData: S((e) => {
60
+ clearOnSend: C(() => n([]), []),
61
+ handleData: C((e) => {
62
62
  if (e.type !== "data-follow_ups") return !1;
63
63
  let t = e.data?.suggestions;
64
64
  return Array.isArray(t) ? (n(t.filter((e) => typeof e == "string")), !0) : !1;
65
65
  }, [])
66
66
  };
67
- }, de = (e) => e instanceof Error && e.message.includes("intelligence.site_agent.NO_ACTIVE_AGENT"), K = b({ agentUnavailable: !1 }), fe = () => C(K), pe = (...e) => e.filter(Boolean).join(" "), me = "inline-flex items-center justify-center gap-1.5 transition-all duration-200", he = "rounded-full border border-zinc-200 bg-white/95 px-3 py-1.5 font-medium text-xs text-zinc-500 shadow-lg backdrop-blur-sm hover:text-zinc-900", ge = ({ onClick: e, isRunning: t = !1, iconOnly: n = !1, icon: r = /* @__PURE__ */ k(N, { className: "h-3 w-3" }), className: i = he }) => /* @__PURE__ */ A("button", {
67
+ }, de = (e) => e instanceof Error && e.message.includes("intelligence.site_agent.NO_ACTIVE_AGENT"), q = x({ agentUnavailable: !1 }), fe = () => w(q), pe = (...e) => e.filter(Boolean).join(" "), me = "inline-flex items-center justify-center gap-1.5 transition-all duration-200", he = "rounded-full border border-zinc-200 bg-white/95 px-3 py-1.5 font-medium text-xs text-zinc-500 shadow-lg backdrop-blur-sm hover:text-zinc-900", ge = ({ onClick: e, isRunning: t = !1, iconOnly: n = !1, icon: r = /* @__PURE__ */ k(N, { className: "h-3 w-3" }), className: i = he }) => /* @__PURE__ */ A("button", {
68
68
  type: "button",
69
69
  "aria-label": "Scroll to bottom",
70
70
  onClick: e,
@@ -74,7 +74,7 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
74
74
  let [i, a] = D(null), o = t ? JSON.stringify(t) : "", s = E(t);
75
75
  s.current = t;
76
76
  let c = E(n);
77
- return c.current = n, w(() => {
77
+ return c.current = n, T(() => {
78
78
  if (!r || !e) {
79
79
  a([...c.current]);
80
80
  return;
@@ -107,7 +107,7 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
107
107
  let a = E(!1), [o, s] = D(!0), c = E(n);
108
108
  c.current = n;
109
109
  let l = E(i);
110
- return l.current = i, w(() => {
110
+ return l.current = i, T(() => {
111
111
  let n = a.current;
112
112
  if (a.current = t, !t || n || (c.current?.(), !r)) return;
113
113
  let i = null, o = null;
@@ -128,7 +128,7 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
128
128
  t,
129
129
  e,
130
130
  r
131
- ]), w(() => {
131
+ ]), T(() => {
132
132
  let t = e.current;
133
133
  if (!t) return;
134
134
  let n = () => {
@@ -151,7 +151,7 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
151
151
  });
152
152
  }
153
153
  };
154
- }, q = (...e) => e.filter(Boolean).join(" "), J = ({ onStop: e }) => /* @__PURE__ */ k("button", {
154
+ }, J = (...e) => e.filter(Boolean).join(" "), xe = ({ onStop: e }) => /* @__PURE__ */ k("button", {
155
155
  type: "button",
156
156
  onClick: e,
157
157
  "aria-label": "Stop generating",
@@ -160,20 +160,20 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
160
160
  backgroundColor: "var(--color-brand, #0a0a0a)",
161
161
  color: "var(--color-brand-foreground, #fff)"
162
162
  },
163
- children: /* @__PURE__ */ k(L, { className: "h-3.5 w-3.5 fill-current" })
164
- }), xe = () => /* @__PURE__ */ A(O, { children: [/* @__PURE__ */ k(B.If, {
163
+ children: /* @__PURE__ */ k(R, { className: "h-3.5 w-3.5 fill-current" })
164
+ }), Se = () => /* @__PURE__ */ A(O, { children: [/* @__PURE__ */ k(V.If, {
165
165
  dictation: !1,
166
- children: /* @__PURE__ */ k(B.Dictate, {
166
+ children: /* @__PURE__ */ k(V.Dictate, {
167
167
  className: "flex h-8 w-8 items-center justify-center rounded-md text-zinc-500 transition-colors hover:bg-zinc-100 hover:text-zinc-900",
168
- children: /* @__PURE__ */ k(ee, { className: "h-4 w-4" })
168
+ children: /* @__PURE__ */ k(I, { className: "h-4 w-4" })
169
169
  })
170
- }), /* @__PURE__ */ k(B.If, {
170
+ }), /* @__PURE__ */ k(V.If, {
171
171
  dictation: !0,
172
- children: /* @__PURE__ */ k(B.StopDictation, {
172
+ children: /* @__PURE__ */ k(V.StopDictation, {
173
173
  className: "flex h-8 w-8 animate-pulse items-center justify-center rounded-md bg-red-500/15 text-red-500 transition-colors hover:bg-red-500/25",
174
- children: /* @__PURE__ */ k(L, { className: "h-3 w-3 fill-current" })
174
+ children: /* @__PURE__ */ k(R, { className: "h-3 w-3 fill-current" })
175
175
  })
176
- })] }), Se = () => /* @__PURE__ */ k(B.Send, {
176
+ })] }), Ce = () => /* @__PURE__ */ k(V.Send, {
177
177
  "aria-label": "Send message",
178
178
  className: "flex h-9 w-9 items-center justify-center rounded-md shadow-md transition-all duration-300 hover:scale-110 active:scale-95 disabled:cursor-not-allowed disabled:opacity-40 disabled:shadow-none disabled:hover:scale-100",
179
179
  style: {
@@ -181,15 +181,15 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
181
181
  color: "var(--color-brand-foreground, #fff)"
182
182
  },
183
183
  children: /* @__PURE__ */ k(j, { className: "h-5 w-5 stroke-[2.5px]" })
184
- }), Ce = ({ variant: t, isRunning: n, onStop: r }) => {
185
- let i = (e) => {
186
- e.nativeEvent.isComposing || n && e.key === "Enter" && !e.shiftKey && e.preventDefault();
184
+ }), we = ({ variant: e, isRunning: t, onStop: n }) => {
185
+ let r = (e) => {
186
+ e.nativeEvent.isComposing || t && e.key === "Enter" && !e.shiftKey && e.preventDefault();
187
187
  };
188
- return t === "expanded" ? /* @__PURE__ */ A("div", {
188
+ return e === "expanded" ? /* @__PURE__ */ A("div", {
189
189
  className: "rounded-lg border border-zinc-200 bg-white shadow-sm transition-colors focus-within:border-[var(--color-brand,#a1a1aa)]",
190
- children: [/* @__PURE__ */ k(B.Input, {
190
+ children: [/* @__PURE__ */ k(V.Input, {
191
191
  "data-ai-chat-composer": "",
192
- className: q("ai-chat-textarea w-full resize-none overflow-y-auto bg-transparent px-6 pt-4 text-base text-zinc-900 leading-relaxed placeholder:text-zinc-500 focus:outline-none", "max-h-[160px]"),
192
+ className: J("ai-chat-textarea w-full resize-none overflow-y-auto bg-transparent px-6 pt-4 text-base text-zinc-900 leading-relaxed placeholder:text-zinc-500 focus:outline-none", "max-h-[160px]"),
193
193
  placeholder: "Ask anything about this site…",
194
194
  rows: 1,
195
195
  submitMode: "enter",
@@ -197,18 +197,18 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
197
197
  autoCorrect: "off",
198
198
  autoCapitalize: "none",
199
199
  inputMode: "text",
200
- onInput: (t) => e(t.currentTarget),
201
- onKeyDown: i
200
+ onInput: (e) => _(e.currentTarget),
201
+ onKeyDown: r
202
202
  }), /* @__PURE__ */ A("div", {
203
203
  className: "flex items-center justify-between px-3 pt-1 pb-2",
204
- children: [/* @__PURE__ */ k(xe, {}), n ? /* @__PURE__ */ k(J, { onStop: r }) : /* @__PURE__ */ k(Se, {})]
204
+ children: [/* @__PURE__ */ k(Se, {}), t ? /* @__PURE__ */ k(xe, { onStop: n }) : /* @__PURE__ */ k(Ce, {})]
205
205
  })]
206
206
  }) : /* @__PURE__ */ A("div", {
207
207
  className: "flex items-end gap-2 rounded-lg border border-zinc-200 bg-white p-2 shadow-sm transition-colors focus-within:border-[var(--color-brand,#a1a1aa)]",
208
208
  children: [
209
- /* @__PURE__ */ k(B.Input, {
209
+ /* @__PURE__ */ k(V.Input, {
210
210
  "data-ai-chat-composer": "",
211
- className: q("ai-chat-textarea min-w-0 flex-1 resize-none overflow-y-auto bg-transparent px-2 py-1.5 text-base text-zinc-900 leading-relaxed placeholder:text-zinc-500 focus:outline-none", "max-h-[120px]"),
211
+ className: J("ai-chat-textarea min-w-0 flex-1 resize-none overflow-y-auto bg-transparent px-2 py-1.5 text-base text-zinc-900 leading-relaxed placeholder:text-zinc-500 focus:outline-none", "max-h-[120px]"),
212
212
  placeholder: "Ask a follow-up…",
213
213
  rows: 1,
214
214
  submitMode: "enter",
@@ -216,40 +216,40 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
216
216
  autoCorrect: "off",
217
217
  autoCapitalize: "none",
218
218
  inputMode: "text",
219
- onInput: (t) => e(t.currentTarget),
220
- onKeyDown: i
219
+ onInput: (e) => _(e.currentTarget),
220
+ onKeyDown: r
221
221
  }),
222
- /* @__PURE__ */ k(xe, {}),
223
- n ? /* @__PURE__ */ k(J, { onStop: r }) : /* @__PURE__ */ k(Se, {})
222
+ /* @__PURE__ */ k(Se, {}),
223
+ t ? /* @__PURE__ */ k(xe, { onStop: n }) : /* @__PURE__ */ k(Ce, {})
224
224
  ]
225
225
  });
226
- }, we = "rounded-2xl border border-zinc-200 bg-zinc-100 px-3.5 py-2.5", Te = "ai-chat-textarea w-full resize-none bg-transparent text-base text-zinc-900 leading-relaxed placeholder:text-zinc-500 focus:outline-none", Ee = "rounded-md px-2 py-1 text-xs text-zinc-500 transition-colors hover:bg-zinc-100", De = "rounded-md px-2 py-1 text-xs transition-opacity hover:opacity-80", Oe = ({ autoGrowMax: t, boxClassName: n = we, inputClassName: r = Te, cancelClassName: i = Ee, sendClassName: o = De, sendStyle: s }) => {
227
- let c = W((e) => e.thread.isRunning);
228
- return /* @__PURE__ */ k(V.Root, {
226
+ }, Te = "rounded-2xl border border-zinc-200 bg-zinc-100 px-3.5 py-2.5", Ee = "ai-chat-textarea w-full resize-none bg-transparent text-base text-zinc-900 leading-relaxed placeholder:text-zinc-500 focus:outline-none", De = "rounded-md px-2 py-1 text-xs text-zinc-500 transition-colors hover:bg-zinc-100", Oe = "rounded-md px-2 py-1 text-xs transition-opacity hover:opacity-80", ke = ({ autoGrowMax: e, boxClassName: n = Te, inputClassName: r = Ee, cancelClassName: i = De, sendClassName: a = Oe, sendStyle: o }) => {
227
+ let s = G((e) => e.thread.isRunning);
228
+ return /* @__PURE__ */ k(H.Root, {
229
229
  className: "mb-4 pr-2 pl-0",
230
- children: /* @__PURE__ */ A(B.Root, { children: [/* @__PURE__ */ k("div", {
230
+ children: /* @__PURE__ */ A(V.Root, { children: [/* @__PURE__ */ k("div", {
231
231
  className: n,
232
- children: /* @__PURE__ */ k(B.Input, {
232
+ children: /* @__PURE__ */ k(V.Input, {
233
233
  className: r,
234
234
  rows: 1,
235
- onInput: (n) => e(n.currentTarget, t)
235
+ onInput: (t) => _(t.currentTarget, e)
236
236
  })
237
237
  }), /* @__PURE__ */ A("div", {
238
238
  className: "mt-2 flex justify-end gap-1.5",
239
- children: [/* @__PURE__ */ k(B.Cancel, {
239
+ children: [/* @__PURE__ */ k(V.Cancel, {
240
240
  className: i,
241
241
  children: "Cancel"
242
- }), /* @__PURE__ */ k(B.Send, {
243
- disabled: c,
244
- className: `${o} ${a}`,
245
- style: s,
242
+ }), /* @__PURE__ */ k(V.Send, {
243
+ disabled: s,
244
+ className: `${a} ${t}`,
245
+ style: o,
246
246
  children: "Save"
247
247
  })]
248
248
  })] })
249
249
  });
250
- }, ke = ({ idleClassName: e = "text-zinc-500 hover:text-zinc-900", copiedClassName: t = "text-emerald-500", errorClassName: n = "text-rose-500", className: r = "rounded p-1.5 transition-colors", iconClassName: i = "h-3 w-3" }) => {
251
- let [a, o] = D("idle"), s = W((e) => e.message);
252
- w(() => {
250
+ }, Ae = ({ idleClassName: e = "text-zinc-500 hover:text-zinc-900", copiedClassName: t = "text-emerald-500", errorClassName: n = "text-rose-500", className: r = "rounded p-1.5 transition-colors", iconClassName: i = "h-3 w-3" }) => {
251
+ let [a, o] = D("idle"), s = G((e) => e.message);
252
+ T(() => {
253
253
  if (a === "idle") return;
254
254
  let e = setTimeout(() => o("idle"), 1500);
255
255
  return () => clearTimeout(e);
@@ -261,7 +261,7 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
261
261
  } catch {
262
262
  o("error");
263
263
  }
264
- }, l = a === "copied" ? t ?? e : a === "error" ? n ?? e : e, u = a === "copied" ? "Copied" : a === "error" ? "Copy failed" : "Copy message", d = a === "copied" ? M : a === "error" ? R : P;
264
+ }, l = a === "copied" ? t ?? e : a === "error" ? n ?? e : e, u = a === "copied" ? "Copied" : a === "error" ? "Copy failed" : "Copy message", d = a === "copied" ? M : a === "error" ? z : P;
265
265
  return /* @__PURE__ */ k("button", {
266
266
  type: "button",
267
267
  "aria-label": u,
@@ -269,10 +269,10 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
269
269
  className: [r, l].filter(Boolean).join(" "),
270
270
  children: /* @__PURE__ */ k(d, { className: i })
271
271
  });
272
- }, Ae = ({ children: e }) => {
272
+ }, je = ({ children: e }) => {
273
273
  let [t, n] = D(!1), r = "plaintext", i = "";
274
- return y.forEach(e, (e) => {
275
- if (x(e)) {
274
+ return b.forEach(e, (e) => {
275
+ if (S(e)) {
276
276
  let t = e.props, n = /language-(\w+)/.exec(t.className ?? "");
277
277
  n && (r = n[1] ?? r), typeof t.children == "string" && (i = t.children.trim());
278
278
  }
@@ -296,24 +296,24 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
296
296
  children: e
297
297
  })]
298
298
  });
299
- }, je = (e) => /* @__PURE__ */ k("a", {
299
+ }, Me = (e) => /* @__PURE__ */ k("a", {
300
300
  ...e,
301
301
  target: "_blank",
302
302
  rel: "noopener noreferrer"
303
- }), Me = ({ className: e, ...t }) => /* @__PURE__ */ k("div", {
303
+ }), Ne = ({ className: e, ...t }) => /* @__PURE__ */ k("div", {
304
304
  className: "w-full max-w-full overflow-x-auto",
305
305
  children: /* @__PURE__ */ k("table", {
306
306
  ...t,
307
307
  className: ["w-max min-w-full [&_td]:max-w-[20rem] [&_th]:max-w-[20rem]", e].filter(Boolean).join(" ")
308
308
  })
309
- }), Ne = () => /* @__PURE__ */ k(oe, {
309
+ }), Pe = () => /* @__PURE__ */ k(oe, {
310
310
  remarkPlugins: [se],
311
311
  components: {
312
- pre: Ae,
313
- a: je,
314
- table: Me
312
+ pre: je,
313
+ a: Me,
314
+ table: Ne
315
315
  }
316
- }), Pe = [
316
+ }), Fe = [
317
317
  "Thinking",
318
318
  "Pondering",
319
319
  "Drafting",
@@ -327,12 +327,12 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
327
327
  "Untangling",
328
328
  "Threading the needle",
329
329
  "Lining up ideas"
330
- ], Fe = (e) => {
330
+ ], Ie = (e) => {
331
331
  let t = Math.floor(e / 60), n = e % 60;
332
332
  return t > 0 ? `${t}m ${n.toString().padStart(2, "0")}s` : `${n}s`;
333
- }, Ie = ({ phrases: e = Pe, textClassName: t = "ai-thinking-text", timerClassName: n = "text-xs text-zinc-500/70 tabular-nums", longRunningClassName: r = "ml-1.5 text-zinc-500/45", longRunningHint: i = "· hang tight" }) => {
333
+ }, Le = ({ phrases: e = Fe, textClassName: t = "ai-thinking-text", timerClassName: n = "text-xs text-zinc-500/70 tabular-nums", longRunningClassName: r = "ml-1.5 text-zinc-500/45", longRunningHint: i = "· hang tight" }) => {
334
334
  let [a, o] = D(() => e.length > 0 ? Math.floor(Math.random() * e.length) : 0), [s, c] = D(0);
335
- w(() => {
335
+ T(() => {
336
336
  let t = e.length > 0 ? setInterval(() => {
337
337
  o((t) => (t + 1) % e.length);
338
338
  }, 2800) : null, n = setInterval(() => {
@@ -369,128 +369,128 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
369
369
  })]
370
370
  }), u && /* @__PURE__ */ A("span", {
371
371
  className: `${n} min-w-0 truncate`,
372
- children: [Fe(s), d && /* @__PURE__ */ k("span", {
372
+ children: [Ie(s), d && /* @__PURE__ */ k("span", {
373
373
  className: r,
374
374
  children: i
375
375
  })]
376
376
  })]
377
377
  });
378
- }, Le = () => null, Re = "max-w-none text-sm text-zinc-900 leading-relaxed [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&_a:hover]:text-sky-700 [&_a]:break-words [&_a]:font-medium [&_a]:text-sky-600 [&_a]:underline [&_a]:underline-offset-2 [&_li]:text-sm [&_ol]:my-2 [&_ol]:list-decimal [&_ol]:pl-5 [&_p]:my-2 [&_p]:text-sm [&_strong]:font-semibold [&_ul]:my-2 [&_ul]:list-disc [&_ul]:pl-5", ze = "group pr-4 pb-6", Be = "mt-2 flex items-center gap-2 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100", Ve = "text-xs text-zinc-500/60", He = "rounded p-1.5 text-zinc-500 transition-colors hover:text-zinc-900", Ue = ({ tools: e = Le, Parts: t, thinkingIndicator: r = /* @__PURE__ */ k(Ie, {}), rootClassName: i = ze, contentClassName: a = Re, metaClassName: o = Be, wrapContent: s, metaSlot: c, copyIdleClassName: l, copyCopiedClassName: u, reloadClassName: d = He, timeClassName: f = Ve, timeFormatOptions: p, readOnly: m = !1, belowContent: h, footerSlot: g }) => {
379
- let y = W((e) => e.message), b = _(y), x = t ?? V.Content, S = y.status?.type === "running", C = /* @__PURE__ */ k("div", {
380
- className: a,
378
+ }, Re = () => null, ze = "max-w-none text-sm text-zinc-900 leading-relaxed [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&_a:hover]:text-sky-700 [&_a]:break-words [&_a]:font-medium [&_a]:text-sky-600 [&_a]:underline [&_a]:underline-offset-2 [&_li]:text-sm [&_ol]:my-2 [&_ol]:list-decimal [&_ol]:pl-5 [&_p]:my-2 [&_p]:text-sm [&_strong]:font-semibold [&_ul]:my-2 [&_ul]:list-disc [&_ul]:pl-5", Be = "group pr-4 pb-6", Ve = "mt-2 flex items-center gap-2 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100", He = "text-xs text-zinc-500/60", Ue = "rounded p-1.5 text-zinc-500 transition-colors hover:text-zinc-900", We = ({ tools: t = Re, Parts: n, thinkingIndicator: i = /* @__PURE__ */ k(Le, {}), rootClassName: a = Be, contentClassName: o = ze, metaClassName: s = Ve, wrapContent: c, metaSlot: l, copyIdleClassName: u, copyCopiedClassName: d, reloadClassName: f = Ue, timeClassName: p = He, timeFormatOptions: m, readOnly: h = !1, belowContent: g, footerSlot: _ }) => {
379
+ let y = G((e) => e.message), b = e(y), x = n ?? H.Content, S = y.status?.type === "running", C = /* @__PURE__ */ k("div", {
380
+ className: o,
381
381
  children: /* @__PURE__ */ k(x, { components: {
382
- Text: Ne,
383
- tools: { Fallback: e }
382
+ Text: Pe,
383
+ tools: { Fallback: t }
384
384
  } })
385
385
  });
386
- return /* @__PURE__ */ k(V.Root, {
387
- className: i,
386
+ return /* @__PURE__ */ k(H.Root, {
387
+ className: a,
388
388
  children: /* @__PURE__ */ A("div", {
389
389
  className: "flex min-w-0 flex-col",
390
390
  children: [
391
- s ? s(C) : C,
391
+ c ? c(C) : C,
392
392
  S && /* @__PURE__ */ k("div", {
393
393
  className: "mt-1",
394
- children: r
394
+ children: i
395
395
  }),
396
- !S && h && /* @__PURE__ */ k("div", {
396
+ !S && g && /* @__PURE__ */ k("div", {
397
397
  className: "mt-2",
398
- children: h
398
+ children: g
399
399
  }),
400
400
  !S && /* @__PURE__ */ A("div", {
401
- className: o,
401
+ className: s,
402
402
  children: [
403
403
  /* @__PURE__ */ k("span", {
404
- className: f,
405
- title: v(b) || void 0,
406
- children: n(b, p)
404
+ className: p,
405
+ title: r(b) || void 0,
406
+ children: v(b, m)
407
407
  }),
408
- c,
409
- /* @__PURE__ */ A(z.Root, {
408
+ l,
409
+ /* @__PURE__ */ A(B.Root, {
410
410
  className: "flex items-center gap-0.5",
411
- children: [/* @__PURE__ */ k(ke, {
412
- idleClassName: l,
413
- copiedClassName: u
414
- }), !m && /* @__PURE__ */ k(z.Reload, {
415
- className: `${d} disabled:cursor-not-allowed disabled:opacity-40`,
416
- children: /* @__PURE__ */ k(I, { className: "h-3 w-3" })
411
+ children: [/* @__PURE__ */ k(Ae, {
412
+ idleClassName: u,
413
+ copiedClassName: d
414
+ }), !h && /* @__PURE__ */ k(B.Reload, {
415
+ className: `${f} disabled:cursor-not-allowed disabled:opacity-40`,
416
+ children: /* @__PURE__ */ k(L, { className: "h-3 w-3" })
417
417
  })]
418
418
  })
419
419
  ]
420
420
  }),
421
- !S && g
421
+ !S && _
422
422
  ]
423
423
  })
424
424
  });
425
- }, We = "group flex flex-col items-end pb-4 pl-12", Ge = "rounded-2xl border border-zinc-200 bg-zinc-100 px-3.5 py-2.5 text-sm text-zinc-900 leading-relaxed", Ke = "mt-1 flex items-center gap-2 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100", qe = "text-xs text-zinc-500/60", Je = "rounded px-2 py-1 font-medium text-xs text-zinc-500 transition-colors hover:text-zinc-900", Ye = ({ attachmentsSlot: e, rootClassName: t = We, bubbleClassName: r = Ge, contentSlot: i, metaClassName: a = Ke, timeClassName: o = qe, editClassName: s = Je, copyIdleClassName: c, copyCopiedClassName: l, timeFormatOptions: u, readOnly: d = !1 }) => {
426
- let f = W((e) => e.message), p = W((e) => e.thread.isRunning), m = _(f);
427
- return /* @__PURE__ */ A(V.Root, {
428
- className: t,
425
+ }, Ge = "group flex flex-col items-end pb-4 pl-12", Ke = "rounded-2xl border border-zinc-200 bg-zinc-100 px-3.5 py-2.5 text-sm text-zinc-900 leading-relaxed", qe = "mt-1 flex items-center gap-2 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100", Je = "text-xs text-zinc-500/60", Ye = "rounded px-2 py-1 font-medium text-xs text-zinc-500 transition-colors hover:text-zinc-900", Xe = ({ attachmentsSlot: t, rootClassName: n = Ge, bubbleClassName: i = Ke, contentSlot: a, metaClassName: o = qe, timeClassName: s = Je, editClassName: c = Ye, copyIdleClassName: l, copyCopiedClassName: u, timeFormatOptions: d, readOnly: f = !1 }) => {
426
+ let p = G((e) => e.message), m = G((e) => e.thread.isRunning), h = e(p);
427
+ return /* @__PURE__ */ A(H.Root, {
428
+ className: n,
429
429
  "data-user-message": "true",
430
430
  children: [
431
- e,
431
+ t,
432
432
  /* @__PURE__ */ k("div", {
433
- className: r,
434
- children: i ?? /* @__PURE__ */ k(V.Content, {})
433
+ className: i,
434
+ children: a ?? /* @__PURE__ */ k(H.Content, {})
435
435
  }),
436
436
  /* @__PURE__ */ A("div", {
437
- className: a,
437
+ className: o,
438
438
  children: [/* @__PURE__ */ k("span", {
439
- className: o,
440
- title: v(m) || void 0,
441
- children: n(m, u)
442
- }), /* @__PURE__ */ A(z.Root, {
439
+ className: s,
440
+ title: r(h) || void 0,
441
+ children: v(h, d)
442
+ }), /* @__PURE__ */ A(B.Root, {
443
443
  className: "flex items-center gap-0.5",
444
- children: [/* @__PURE__ */ k(ke, {
445
- idleClassName: c,
446
- copiedClassName: l
447
- }), !d && /* @__PURE__ */ k(z.Edit, {
448
- disabled: p,
449
- className: `${s} disabled:cursor-not-allowed disabled:opacity-40`,
444
+ children: [/* @__PURE__ */ k(Ae, {
445
+ idleClassName: l,
446
+ copiedClassName: u
447
+ }), !f && /* @__PURE__ */ k(B.Edit, {
448
+ disabled: m,
449
+ className: `${c} disabled:cursor-not-allowed disabled:opacity-40`,
450
450
  children: "Edit"
451
451
  })]
452
452
  })]
453
453
  })
454
454
  ]
455
455
  });
456
- }, Xe = () => /* @__PURE__ */ k(Oe, { sendStyle: {
456
+ }, Ze = () => /* @__PURE__ */ k(ke, { sendStyle: {
457
457
  backgroundColor: "var(--color-brand, #0a0a0a)",
458
458
  color: "var(--color-brand-foreground, #fff)"
459
- } }), Ze = [
459
+ } }), Qe = [
460
460
  "What do you offer?",
461
461
  "How much does it cost?",
462
462
  "Why should I choose you?",
463
463
  "How do I get in touch?"
464
- ], Qe = [
464
+ ], $e = [
465
465
  "w-3/4",
466
466
  "w-4/5",
467
467
  "w-2/3",
468
468
  "w-3/5"
469
- ], $e = ({ workspaceId: e, siteName: t, siteLogo: n, apiBaseUrl: r, authHeaders: i, agentId: a, followUps: o, hideComposer: s = !1 }) => {
470
- let c = U(), l = W((e) => e.thread.isRunning), { agentUnavailable: u } = fe(), d = E(null), { isAtBottom: f, scrollToBottom: p } = be({
471
- viewportRef: d,
472
- isRunning: l
473
- }), m = _e({
469
+ ], et = ({ workspaceId: e, siteName: t, siteLogo: n, apiBaseUrl: r, authHeaders: i, agentId: a, followUps: s, hideComposer: c = !1 }) => {
470
+ let l = W(), u = G((e) => e.thread.isRunning), { agentUnavailable: d } = fe(), f = E(null), { isAtBottom: p, scrollToBottom: m } = be({
471
+ viewportRef: f,
472
+ isRunning: u
473
+ }), h = _e({
474
474
  endpoint: e ? `${r}/suggestions${a ? `?agent_id=${encodeURIComponent(a)}` : ""}` : void 0,
475
475
  headers: e ? {
476
- ...i,
476
+ ...o(i),
477
477
  "Levo-Workspace": e
478
478
  } : void 0,
479
- fallback: Ze
480
- }), h = S((e) => {
481
- g(c.thread.composer(), e);
482
- }, [c]), _ = S(() => c.thread.cancelRun(), [c]), v = E(l);
483
- return w(() => {
484
- v.current = l;
485
- }, [l]), w(() => {
479
+ fallback: Qe
480
+ }), g = C((e) => {
481
+ y(l.thread.composer(), e);
482
+ }, [l]), _ = C(() => l.thread.cancelRun(), [l]), v = E(u);
483
+ return T(() => {
484
+ v.current = u;
485
+ }, [u]), T(() => {
486
486
  let e = (e) => {
487
- e.key !== "Escape" || e.isComposing || !v.current || (e.preventDefault(), e.stopImmediatePropagation(), c.thread.cancelRun());
487
+ e.key !== "Escape" || e.isComposing || !v.current || (e.preventDefault(), e.stopImmediatePropagation(), l.thread.cancelRun());
488
488
  };
489
489
  return window.addEventListener("keydown", e, !0), () => window.removeEventListener("keydown", e, !0);
490
- }, [c]), /* @__PURE__ */ A(H.Root, {
490
+ }, [l]), /* @__PURE__ */ A(U.Root, {
491
491
  className: "relative flex flex-1 flex-col overflow-hidden",
492
492
  children: [
493
- /* @__PURE__ */ k(H.If, {
493
+ /* @__PURE__ */ k(U.If, {
494
494
  empty: !0,
495
495
  children: /* @__PURE__ */ k("div", {
496
496
  className: "pointer-events-none absolute inset-0 z-0 overflow-hidden",
@@ -500,20 +500,20 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
500
500
  })
501
501
  })
502
502
  }),
503
- u && /* @__PURE__ */ k("div", {
503
+ d && /* @__PURE__ */ k("div", {
504
504
  role: "alert",
505
505
  className: "relative z-20 shrink-0 border-amber-200 border-b bg-amber-50 px-4 py-2.5 text-amber-800 text-xs",
506
506
  children: "This conversation is no longer available. Please refresh the page to start a new chat."
507
507
  }),
508
- /* @__PURE__ */ A(H.Viewport, {
509
- ref: d,
508
+ /* @__PURE__ */ A(U.Viewport, {
509
+ ref: f,
510
510
  turnAnchor: "top",
511
511
  className: "relative z-10 flex-1 overflow-y-auto",
512
512
  autoScroll: !1,
513
513
  scrollToBottomOnRunStart: !1,
514
514
  scrollToBottomOnInitialize: !1,
515
515
  scrollToBottomOnThreadSwitch: !1,
516
- children: [/* @__PURE__ */ k(H.Empty, { children: /* @__PURE__ */ A("div", {
516
+ children: [/* @__PURE__ */ k(U.Empty, { children: /* @__PURE__ */ A("div", {
517
517
  className: "flex min-h-full flex-col items-center justify-center px-6 py-6",
518
518
  children: [/* @__PURE__ */ A("div", {
519
519
  className: "mb-5 flex flex-col items-center gap-2 text-center",
@@ -542,68 +542,68 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
542
542
  ]
543
543
  }), /* @__PURE__ */ k("div", {
544
544
  className: "flex w-full max-w-md flex-col gap-2",
545
- children: m === null ? Qe.map((e, t) => /* @__PURE__ */ k("div", {
545
+ children: h === null ? $e.map((e, t) => /* @__PURE__ */ k("div", {
546
546
  className: "flex h-[42px] items-center rounded-xl border border-zinc-200 bg-white px-4",
547
547
  children: /* @__PURE__ */ k("span", { className: `block h-3 animate-pulse rounded bg-zinc-200 ${e}` })
548
- }, `skeleton-${t}`)) : m.map((e, t) => /* @__PURE__ */ k("button", {
548
+ }, `skeleton-${t}`)) : h.map((e, t) => /* @__PURE__ */ k("button", {
549
549
  type: "button",
550
- onClick: () => h(e),
550
+ onClick: () => g(e),
551
551
  className: "ai-chat-suggestion rounded-xl border border-zinc-200 bg-white px-4 py-2.5 text-left text-sm text-zinc-700 transition-[border-color,background-color,transform] duration-150 hover:border-zinc-300 hover:bg-zinc-50 active:scale-[0.98]",
552
552
  style: { animationDelay: `${t * 40}ms` },
553
553
  children: e
554
554
  }, e))
555
555
  })]
556
- }) }), /* @__PURE__ */ k(H.If, {
556
+ }) }), /* @__PURE__ */ k(U.If, {
557
557
  empty: !1,
558
558
  children: /* @__PURE__ */ k("div", {
559
559
  className: "ai-chat-kb-messages mx-auto max-w-3xl px-6 py-6 pt-8",
560
- children: /* @__PURE__ */ k(H.Messages, { components: {
561
- UserMessage: Ye,
562
- AssistantMessage: Ue,
563
- EditComposer: Xe
560
+ children: /* @__PURE__ */ k(U.Messages, { components: {
561
+ UserMessage: Xe,
562
+ AssistantMessage: We,
563
+ EditComposer: Ze
564
564
  } })
565
565
  })
566
566
  })]
567
567
  }),
568
- !s && /* @__PURE__ */ k("div", {
568
+ !c && /* @__PURE__ */ k("div", {
569
569
  className: "relative z-10 shrink-0 border-zinc-200 border-t bg-white/95 backdrop-blur-sm",
570
570
  children: /* @__PURE__ */ A("div", {
571
571
  className: "relative mx-auto max-w-3xl px-4 pt-3 pb-3",
572
572
  children: [
573
- !f && /* @__PURE__ */ k("div", {
573
+ !p && /* @__PURE__ */ k("div", {
574
574
  className: "pointer-events-none absolute inset-x-0 -top-9 z-20 flex justify-center",
575
575
  children: /* @__PURE__ */ k(ge, {
576
- onClick: p,
577
- isRunning: l,
576
+ onClick: m,
577
+ isRunning: u,
578
578
  className: "pointer-events-auto rounded-full border border-zinc-200 bg-white/95 px-3 py-1.5 font-medium text-xs text-zinc-500 shadow-lg backdrop-blur-sm hover:text-zinc-900"
579
579
  })
580
580
  }),
581
- o.length > 0 && !l && /* @__PURE__ */ k("div", {
581
+ s.length > 0 && !u && /* @__PURE__ */ k("div", {
582
582
  className: "mb-2",
583
- children: /* @__PURE__ */ k(G, {
584
- chips: o,
585
- onSelect: h,
583
+ children: /* @__PURE__ */ k(K, {
584
+ chips: s,
585
+ onSelect: g,
586
586
  size: "compact"
587
587
  })
588
588
  }),
589
- /* @__PURE__ */ A(B.Root, { children: [
590
- /* @__PURE__ */ k(H.If, {
589
+ /* @__PURE__ */ A(V.Root, { children: [
590
+ /* @__PURE__ */ k(U.If, {
591
591
  empty: !0,
592
- children: /* @__PURE__ */ k(Ce, {
592
+ children: /* @__PURE__ */ k(we, {
593
593
  variant: "expanded",
594
- isRunning: l,
594
+ isRunning: u,
595
595
  onStop: _
596
596
  })
597
597
  }),
598
- /* @__PURE__ */ k(H.If, {
598
+ /* @__PURE__ */ k(U.If, {
599
599
  empty: !1,
600
- children: /* @__PURE__ */ k(Ce, {
600
+ children: /* @__PURE__ */ k(we, {
601
601
  variant: "compact",
602
- isRunning: l,
602
+ isRunning: u,
603
603
  onStop: _
604
604
  })
605
605
  }),
606
- /* @__PURE__ */ k(B.If, {
606
+ /* @__PURE__ */ k(V.If, {
607
607
  dictation: !0,
608
608
  children: /* @__PURE__ */ A("div", {
609
609
  className: "mt-2 flex items-center justify-center gap-2",
@@ -614,7 +614,7 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
614
614
  })
615
615
  })
616
616
  ] }),
617
- /* @__PURE__ */ k(H.If, {
617
+ /* @__PURE__ */ k(U.If, {
618
618
  empty: !1,
619
619
  children: /* @__PURE__ */ k("p", {
620
620
  className: "mt-2 text-center text-[10px] text-zinc-500/70",
@@ -626,88 +626,87 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
626
626
  })
627
627
  ]
628
628
  });
629
- }, Y = 4096, et = 400, tt = 300, nt = 2e3, rt = (e) => document.querySelector(e)?.content?.trim() || void 0, it = (e) => {
629
+ }, Y = 4096, tt = 400, nt = 300, rt = 2e3, it = (e) => document.querySelector(e)?.content?.trim() || void 0, at = (e) => {
630
630
  for (let t of e) {
631
- let e = rt(t);
631
+ let e = it(t);
632
632
  if (e) return e;
633
633
  }
634
- }, at = (e, t) => e.length > t ? `${e.slice(0, t - 1).trimEnd()}…` : e, X = (e) => JSON.stringify(e).length, ot = () => {
634
+ }, ot = (e, t) => e.length > t ? `${e.slice(0, t - 1).trimEnd()}…` : e, X = (e) => JSON.stringify(e).length, st = () => {
635
635
  if (typeof window > "u" || typeof document > "u") return;
636
636
  let e = {}, t = window.location?.href;
637
637
  t && (e.url = t);
638
- let n = document.title?.trim() || it(["meta[property=\"og:title\"]", "meta[name=\"twitter:title\"]"]);
639
- n && (e.page_title = at(n, tt));
640
- let r = it([
638
+ let n = document.title?.trim() || at(["meta[property=\"og:title\"]", "meta[name=\"twitter:title\"]"]);
639
+ n && (e.page_title = ot(n, nt));
640
+ let r = at([
641
641
  "meta[name=\"description\"]",
642
642
  "meta[property=\"og:description\"]",
643
643
  "meta[name=\"twitter:description\"]"
644
644
  ]);
645
- r && (e.description = at(r, et));
645
+ r && (e.description = ot(r, tt));
646
646
  let i = document.referrer?.trim();
647
- if (i && (e.referrer = i), Object.keys(e).length !== 0) return e.description && X(e) > Y && delete e.description, e.referrer && X(e) > Y && delete e.referrer, e.url && X(e) > Y && (e.url = e.url.slice(0, nt)), e;
648
- }, st = ({ workspaceId: e, siteName: t, siteLogo: n, agentId: r, apiBaseUrl: i, authHeaders: a, children: o }) => {
649
- let s = E(e);
650
- s.current = e;
651
- let c = E(r);
652
- c.current = r;
653
- let { followUps: l, clearOnSend: u, handleData: d } = ue(), [f, p] = D(!1), { conversationIdRef: m, handleFinish: h, reset: g } = le(e), _ = ae({
647
+ if (i && (e.referrer = i), Object.keys(e).length !== 0) return e.description && X(e) > Y && delete e.description, e.referrer && X(e) > Y && delete e.referrer, e.url && X(e) > Y && (e.url = e.url.slice(0, rt)), e;
648
+ }, ct = ({ workspaceId: e, siteName: t, siteLogo: n, agentId: r, apiBaseUrl: i, authHeaders: a, children: s }) => {
649
+ let c = E(e);
650
+ c.current = e;
651
+ let l = E(r);
652
+ l.current = r;
653
+ let { followUps: u, clearOnSend: d, handleData: f } = ue(), [p, m] = D(!1), { conversationIdRef: h, handleFinish: g, reset: _ } = le(e), v = ae({
654
654
  joinStrategy: "none",
655
655
  transport: ce({
656
656
  api: `${i}/stream`,
657
657
  credentials: "include",
658
- headers: a,
659
658
  onSendStart: () => {
660
- u(), p(!1);
659
+ d(), m(!1);
661
660
  },
662
661
  getHeaders: () => {
663
- let e = {};
664
- return s.current && (e["Levo-Workspace"] = s.current), e;
662
+ let e = { ...o(a) };
663
+ return c.current && (e["Levo-Workspace"] = c.current), e;
665
664
  },
666
665
  getBody: (e) => {
667
666
  let t = {
668
667
  messages: e.messages,
669
- workspace_id: s.current
668
+ workspace_id: c.current
670
669
  };
671
- m.current && (t.conversation_id = m.current), c.current && (t.agent_id = c.current);
672
- let n = ot();
670
+ h.current && (t.conversation_id = h.current), l.current && (t.agent_id = l.current);
671
+ let n = st();
673
672
  return n && (t.context = n), t;
674
673
  }
675
674
  }),
676
675
  adapters: { dictation: new re({ interimResults: !1 }) },
677
- onData: d,
678
- onFinish: h,
676
+ onData: f,
677
+ onFinish: g,
679
678
  onError: (e) => {
680
- de(e) ? p(!0) : console.warn("[levo-kb-chat] stream error:", e);
679
+ de(e) ? m(!0) : console.warn("[levo-kb-chat] stream error:", e);
681
680
  }
682
- }), v = S(() => {
683
- _.threads.switchToNewThread().catch((e) => {
681
+ }), y = C(() => {
682
+ v.threads.switchToNewThread().catch((e) => {
684
683
  console.warn("[levo-kb-chat] switchToNewThread failed:", e);
685
- }), g(), u(), p(!1);
684
+ }), _(), d(), m(!1);
686
685
  }, [
686
+ v,
687
687
  _,
688
- g,
689
- u
688
+ d
690
689
  ]);
691
690
  return /* @__PURE__ */ k(ne, {
692
- runtime: _,
693
- children: /* @__PURE__ */ k(K.Provider, {
694
- value: { agentUnavailable: f },
695
- children: o ? o({
696
- followUps: l,
697
- onResetChat: v
698
- }) : /* @__PURE__ */ k($e, {
691
+ runtime: v,
692
+ children: /* @__PURE__ */ k(q.Provider, {
693
+ value: { agentUnavailable: p },
694
+ children: s ? s({
695
+ followUps: u,
696
+ onResetChat: y
697
+ }) : /* @__PURE__ */ k(et, {
699
698
  workspaceId: e,
700
699
  siteName: t,
701
700
  siteLogo: n,
702
701
  apiBaseUrl: i,
703
702
  authHeaders: a,
704
703
  agentId: r,
705
- followUps: l
704
+ followUps: u
706
705
  })
707
706
  })
708
707
  });
709
- }, ct = (e, t, n) => {
710
- w(() => {
708
+ }, lt = (e, t, n) => {
709
+ T(() => {
711
710
  if (!e) return;
712
711
  let r = (e) => {
713
712
  if (e.key !== "Escape" || e.isComposing) return;
@@ -724,14 +723,14 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
724
723
  t,
725
724
  n
726
725
  ]);
727
- }, Z = "(max-width: 639px)", lt = () => {
726
+ }, Z = "(max-width: 639px)", ut = () => {
728
727
  let [e, t] = D(() => typeof window < "u" && window.matchMedia(Z).matches);
729
- return w(() => {
728
+ return T(() => {
730
729
  let e = window.matchMedia(Z), n = () => t(e.matches);
731
730
  return n(), e.addEventListener("change", n), () => e.removeEventListener("change", n);
732
731
  }, []), e;
733
- }, ut = (e, t) => {
734
- w(() => {
732
+ }, dt = (e, t) => {
733
+ T(() => {
735
734
  let n = t.current, r = window.visualViewport;
736
735
  if (!e || !n || !r || !window.matchMedia(Z).matches) return;
737
736
  let i = () => {
@@ -741,8 +740,8 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
741
740
  r.removeEventListener("resize", i), r.removeEventListener("scroll", i), n.style.removeProperty("--ai-vv-top"), n.style.removeProperty("--ai-vv-height");
742
741
  };
743
742
  }, [e, t]);
744
- }, dt = (e, t, n) => {
745
- w(() => {
743
+ }, ft = (e, t, n) => {
744
+ T(() => {
746
745
  if (!e) return;
747
746
  let r = (e) => {
748
747
  let r = e.composedPath();
@@ -754,65 +753,65 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
754
753
  t,
755
754
  n
756
755
  ]);
757
- }, Q = (...e) => e.filter(Boolean).join(" "), ft = ({ open: e, onToggle: n, askLabel: a, panelId: o, initialDraft: g }) => {
758
- let _ = U(), v = lt(), y = W((e) => e.thread.isRunning), b = W((e) => e.thread.messages.length > 0), x = W((e) => e.composer.text), S = x.trim().length > 0, [C, M] = D(!1);
759
- w(() => {
760
- g && _.thread.composer().setText(g);
761
- }, []);
762
- let N = E(null), P = E(null), F = E(!1);
756
+ }, Q = (...e) => e.filter(Boolean).join(" "), pt = ({ open: e, onToggle: t, askLabel: r, panelId: o, initialDraft: s }) => {
757
+ let _ = W(), v = ut(), y = G((e) => e.thread.isRunning), b = G((e) => e.thread.messages.length > 0), x = G((e) => e.composer.text), S = x.trim().length > 0, [C, w] = D(!1);
763
758
  T(() => {
764
- let e = N.current;
765
- !e || document.activeElement === e || (F.current = !0, e.focus({ preventScroll: !0 }));
766
- }, []), T(() => {
767
- let t = N.current, n = P.current;
759
+ s && _.thread.composer().setText(s);
760
+ }, []);
761
+ let M = E(null), N = E(null), P = E(!1);
762
+ ee(() => {
763
+ let e = M.current;
764
+ !e || document.activeElement === e || (P.current = !0, e.focus({ preventScroll: !0 }));
765
+ }, []), ee(() => {
766
+ let t = M.current, n = N.current;
768
767
  if (!(!t || !n)) {
769
768
  if (!e) {
770
- t.style.height = "", M(!1);
769
+ t.style.height = "", w(!1);
771
770
  return;
772
771
  }
773
- M(l(n, t));
772
+ w(u(n, t));
774
773
  }
775
774
  }, [x, e]);
776
- let I = E(e);
777
- w(() => {
778
- let t = I.current;
779
- I.current = e;
780
- let n = N.current;
775
+ let F = E(e);
776
+ T(() => {
777
+ let t = F.current;
778
+ F.current = e;
779
+ let n = M.current;
781
780
  e || !t || !n || document.activeElement === n && n.blur();
782
781
  }, [e]);
783
- let R = E(y);
784
- w(() => {
785
- let e = !R.current && y;
786
- R.current = y, v && e && N.current?.blur();
782
+ let L = E(y);
783
+ T(() => {
784
+ let e = !L.current && y;
785
+ L.current = y, v && e && M.current?.blur();
787
786
  }, [y, v]);
788
- let z = b ? "Continue conversation" : a;
787
+ let z = b ? "Continue conversation" : r;
789
788
  return /* @__PURE__ */ k("div", {
790
- className: Q(u, e ? p : r),
789
+ className: Q(d, e ? m : i),
791
790
  children: /* @__PURE__ */ A("div", {
792
- ref: P,
793
- className: Q(h, C && "ai-chat-pill-surface--stacked"),
791
+ ref: N,
792
+ className: Q(g, C && "ai-chat-pill-surface--stacked"),
794
793
  children: [
795
794
  /* @__PURE__ */ k("button", {
796
795
  type: "button",
797
- onClick: n,
796
+ onClick: t,
798
797
  "aria-label": e ? "Collapse AI chat" : "Expand AI chat",
799
798
  "aria-expanded": e,
800
799
  "aria-controls": o,
801
- className: c,
800
+ className: l,
802
801
  children: /* @__PURE__ */ k(te, { className: "h-5 w-5" })
803
802
  }),
804
803
  /* @__PURE__ */ A("div", {
805
- className: f,
806
- children: [/* @__PURE__ */ k(B.Input, {
807
- ref: N,
804
+ className: p,
805
+ children: [/* @__PURE__ */ k(V.Input, {
806
+ ref: M,
808
807
  "data-ai-chat-composer": "",
809
808
  placeholder: e ? "Ask anything…" : "",
810
809
  onFocus: () => {
811
- if (F.current) {
812
- F.current = !1;
810
+ if (P.current) {
811
+ P.current = !1;
813
812
  return;
814
813
  }
815
- e || n();
814
+ e || t();
816
815
  },
817
816
  onKeyDown: (e) => {
818
817
  e.nativeEvent.isComposing || e.key !== "Enter" || e.shiftKey || (e.preventDefault(), !y && S && _.thread.composer().send());
@@ -826,74 +825,74 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
826
825
  autoCorrect: "off",
827
826
  autoCapitalize: "none",
828
827
  inputMode: "text",
829
- className: Q(i, "transition-opacity duration-200", !e && "opacity-0")
828
+ className: Q(a, "transition-opacity duration-200", !e && "opacity-0")
830
829
  }), /* @__PURE__ */ k("span", {
831
- className: Q(s, "transition-opacity duration-150", e && "opacity-0"),
830
+ className: Q(c, "transition-opacity duration-150", e && "opacity-0"),
832
831
  "aria-hidden": !0,
833
832
  children: z
834
833
  })]
835
834
  }),
836
835
  /* @__PURE__ */ A("div", {
837
- className: m,
838
- children: [e && /* @__PURE__ */ A(O, { children: [/* @__PURE__ */ k(B.If, {
836
+ className: h,
837
+ children: [e && /* @__PURE__ */ A(O, { children: [/* @__PURE__ */ k(V.If, {
839
838
  dictation: !1,
840
- children: /* @__PURE__ */ k(B.Dictate, {
839
+ children: /* @__PURE__ */ k(V.Dictate, {
841
840
  "aria-label": "Start dictation",
842
841
  className: "ai-chat-icon-btn flex h-11 w-11 flex-shrink-0 items-center justify-center rounded-full transition-colors active:scale-95",
843
- children: /* @__PURE__ */ k(ee, { className: "h-5 w-5" })
842
+ children: /* @__PURE__ */ k(I, { className: "h-5 w-5" })
844
843
  })
845
- }), /* @__PURE__ */ k(B.If, {
844
+ }), /* @__PURE__ */ k(V.If, {
846
845
  dictation: !0,
847
- children: /* @__PURE__ */ k(B.StopDictation, {
846
+ children: /* @__PURE__ */ k(V.StopDictation, {
848
847
  "aria-label": "Stop dictation",
849
848
  className: "flex h-11 w-11 flex-shrink-0 animate-pulse items-center justify-center rounded-full bg-red-500/15 text-red-500 transition-colors hover:bg-red-500/25",
850
- children: /* @__PURE__ */ k(L, { className: "h-4 w-4 fill-current" })
849
+ children: /* @__PURE__ */ k(R, { className: "h-4 w-4 fill-current" })
851
850
  })
852
851
  })] }), e ? y ? /* @__PURE__ */ k("button", {
853
852
  type: "button",
854
853
  onClick: () => _.thread.cancelRun(),
855
854
  "aria-label": "Stop generating",
856
- className: t,
857
- style: d,
858
- children: /* @__PURE__ */ k(L, { className: "h-4 w-4 fill-current" })
859
- }) : /* @__PURE__ */ k(B.Send, {
855
+ className: n,
856
+ style: f,
857
+ children: /* @__PURE__ */ k(R, { className: "h-4 w-4 fill-current" })
858
+ }) : /* @__PURE__ */ k(V.Send, {
860
859
  "aria-label": "Send message",
861
- className: Q(t, "disabled:cursor-not-allowed disabled:opacity-40 disabled:shadow-none disabled:hover:scale-100"),
862
- style: d,
860
+ className: Q(n, "disabled:cursor-not-allowed disabled:opacity-40 disabled:shadow-none disabled:hover:scale-100"),
861
+ style: f,
863
862
  children: /* @__PURE__ */ k(j, { className: "h-5 w-5 stroke-[2.5px]" })
864
863
  }) : /* @__PURE__ */ k("button", {
865
864
  type: "button",
866
- onClick: n,
865
+ onClick: t,
867
866
  "aria-label": "Open AI chat",
868
- className: t,
869
- style: d,
867
+ className: n,
868
+ style: f,
870
869
  children: /* @__PURE__ */ k(j, { className: "h-5 w-5 stroke-[2.5px]" })
871
870
  })]
872
871
  })
873
872
  ]
874
873
  })
875
874
  });
876
- }, pt = "linear-gradient(to right, color-mix(in oklch, var(--ai-chat-thinking-1, oklch(0.65 0.15 253.81)) 40%, transparent), color-mix(in oklch, var(--ai-chat-thinking-2, oklch(0.65 0.15 17.5826)) 40%, transparent))", $ = (...e) => e.filter(Boolean).join(" "), mt = ({ workspaceId: e, siteName: t, siteLogo: n, siteIcon: r, siteSlug: i, agentId: a, apiBaseUrl: s, authHeaders: c, initialOpen: l, initialDraft: u, showBranding: d = !0 }) => {
875
+ }, mt = "linear-gradient(to right, color-mix(in oklch, var(--ai-chat-thinking-1, oklch(0.65 0.15 253.81)) 40%, transparent), color-mix(in oklch, var(--ai-chat-thinking-2, oklch(0.65 0.15 17.5826)) 40%, transparent))", $ = (...e) => e.filter(Boolean).join(" "), ht = ({ workspaceId: e, siteName: t, siteLogo: n, siteIcon: r, siteSlug: i, agentId: a, apiBaseUrl: o, authHeaders: c, initialOpen: l, initialDraft: u, showBranding: d = !0 }) => {
877
876
  let [f, p] = D(!1);
878
- w(() => {
877
+ T(() => {
879
878
  if (!l) return;
880
879
  let e = requestAnimationFrame(() => p(!0));
881
880
  return () => cancelAnimationFrame(e);
882
881
  }, [l]);
883
- let m = `kb-chat-panel-${e ?? "default"}`, h = E(null), g = E(null), _ = S(() => p(!1), []);
884
- ct(f, g, _), dt(f, h, _), ut(f, h);
885
- let v = o(t);
882
+ let m = `kb-chat-panel-${e ?? "default"}`, h = E(null), g = E(null), _ = C(() => p(!1), []);
883
+ lt(f, g, _), ft(f, h, _), dt(f, h);
884
+ let v = s(t);
886
885
  return /* @__PURE__ */ k("div", {
887
886
  ref: h,
888
887
  className: $("ai-chat-launcher pointer-events-none fixed bottom-5 left-1/2 z-[60] flex -translate-x-1/2 flex-col", "ai-chat-kb-wrap", f ? "w-[min(34rem,calc(100vw-1.5rem))]" : "ai-chat-kb-wrap-closed w-[19.5rem]"),
889
- children: /* @__PURE__ */ k(st, {
888
+ children: /* @__PURE__ */ k(ct, {
890
889
  workspaceId: e,
891
890
  siteName: t,
892
891
  siteLogo: n,
893
892
  agentId: a,
894
- apiBaseUrl: s,
893
+ apiBaseUrl: o,
895
894
  authHeaders: c,
896
- children: ({ followUps: o, onResetChat: l }) => /* @__PURE__ */ k(gt, {
895
+ children: ({ followUps: s, onResetChat: l }) => /* @__PURE__ */ k(_t, {
897
896
  open: f,
898
897
  onToggle: () => p((e) => !e),
899
898
  threadStateRef: g,
@@ -905,27 +904,27 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
905
904
  siteSlug: i,
906
905
  initialDraft: u,
907
906
  showBranding: d,
908
- followUps: o,
909
- thread: /* @__PURE__ */ k($e, {
907
+ followUps: s,
908
+ thread: /* @__PURE__ */ k(et, {
910
909
  workspaceId: e,
911
910
  siteName: t,
912
911
  siteLogo: n,
913
912
  agentId: a,
914
- apiBaseUrl: s,
913
+ apiBaseUrl: o,
915
914
  authHeaders: c,
916
- followUps: o,
915
+ followUps: s,
917
916
  hideComposer: !0
918
917
  })
919
918
  })
920
919
  })
921
920
  });
922
- }, ht = [
921
+ }, gt = [
923
922
  "rounded-full border border-zinc-200 bg-white text-zinc-700",
924
923
  "px-3 py-1 text-[13px] leading-snug",
925
924
  "transition-[border-color,background-color,color,transform] duration-150 hover:border-zinc-300 hover:bg-zinc-50 hover:text-zinc-900 active:scale-95"
926
- ].join(" "), gt = ({ open: e, onToggle: t, threadStateRef: n, onResetChat: r, askLabel: i, panelId: a, siteName: o, siteIcon: s, siteSlug: c, initialDraft: l, showBranding: u, followUps: d, thread: f }) => {
927
- let p = U(), m = W((e) => e.thread.isRunning), h = W((e) => e.thread.messages.length > 0), _ = lt() ? d.slice(0, 2) : d;
928
- w(() => (n.current = {
925
+ ].join(" "), _t = ({ open: e, onToggle: t, threadStateRef: n, onResetChat: r, askLabel: i, panelId: a, siteName: o, siteIcon: s, siteSlug: c, initialDraft: l, showBranding: u, followUps: d, thread: f }) => {
926
+ let p = W(), m = G((e) => e.thread.isRunning), h = G((e) => e.thread.messages.length > 0), g = ut() ? d.slice(0, 2) : d;
927
+ T(() => (n.current = {
929
928
  isRunning: m,
930
929
  cancelRun: () => p.thread.cancelRun()
931
930
  }, () => {
@@ -935,9 +934,9 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
935
934
  p,
936
935
  n
937
936
  ]);
938
- let v = S((e) => {
939
- g(p.thread.composer(), e);
940
- }, [p]), y = o ?? "Ask AI", b = `https://levo.so/?utm_source=${encodeURIComponent(c || "website")}&utm_term=Powered%20By%20levo.so&utm_campaign=site_agent&utm_medium=organic_site_agent`;
937
+ let _ = C((e) => {
938
+ y(p.thread.composer(), e);
939
+ }, [p]), v = o ?? "Ask AI", b = `https://levo.so/?utm_source=${encodeURIComponent(c || "website")}&utm_term=Powered%20By%20levo.so&utm_campaign=site_agent&utm_medium=organic_site_agent`;
941
940
  return /* @__PURE__ */ A(O, { children: [
942
941
  /* @__PURE__ */ k("div", {
943
942
  "aria-hidden": !0,
@@ -945,7 +944,7 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
945
944
  style: { filter: "drop-shadow(0 16px 32px rgba(0,0,0,0.16)) drop-shadow(0 2px 8px rgba(0,0,0,0.08))" },
946
945
  children: /* @__PURE__ */ k("div", {
947
946
  className: $("ai-chat-kb-surface h-full w-full p-[2px]", !e && "ai-chat-kb-surface-closed"),
948
- style: { background: pt },
947
+ style: { background: mt },
949
948
  children: /* @__PURE__ */ k("div", { className: "h-full w-full rounded-t-[26px] rounded-b-[40px] bg-white" })
950
949
  })
951
950
  }),
@@ -965,7 +964,7 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
965
964
  className: "h-6 w-6 shrink-0 rounded-sm object-contain"
966
965
  }) : null, /* @__PURE__ */ k("span", {
967
966
  className: "truncate font-semibold text-sm text-zinc-900",
968
- children: y
967
+ children: v
969
968
  })]
970
969
  }), /* @__PURE__ */ A("div", {
971
970
  className: "flex flex-shrink-0 items-center gap-1",
@@ -981,7 +980,7 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
981
980
  onClick: t,
982
981
  "aria-label": "Close AI chat",
983
982
  className: "ai-chat-icon-btn flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full transition-[background-color,color,transform] duration-150 active:scale-95",
984
- children: /* @__PURE__ */ k(R, { className: "h-4 w-4" })
983
+ children: /* @__PURE__ */ k(z, { className: "h-4 w-4" })
985
984
  })]
986
985
  })]
987
986
  }),
@@ -990,19 +989,19 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
990
989
  className: "ai-chat-kb-thread flex max-h-[min(60vh,32rem)] min-h-0 flex-col overflow-hidden",
991
990
  children: f
992
991
  }),
993
- _.length > 0 && !m && /* @__PURE__ */ k("div", {
992
+ g.length > 0 && !m && /* @__PURE__ */ k("div", {
994
993
  className: "shrink-0 px-4 pt-1 pb-2",
995
- children: /* @__PURE__ */ k(G, {
996
- chips: _,
997
- onSelect: v,
998
- chipClassName: ht
994
+ children: /* @__PURE__ */ k(K, {
995
+ chips: g,
996
+ onSelect: _,
997
+ chipClassName: gt
999
998
  })
1000
999
  })
1001
1000
  ]
1002
1001
  }),
1003
1002
  /* @__PURE__ */ k("div", {
1004
1003
  className: "ai-chat-kb-pillbox pointer-events-auto relative z-20 mx-3 mt-1",
1005
- children: /* @__PURE__ */ k(ft, {
1004
+ children: /* @__PURE__ */ k(pt, {
1006
1005
  open: e,
1007
1006
  onToggle: t,
1008
1007
  askLabel: i,
@@ -1030,4 +1029,4 @@ var G = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
1030
1029
  ] });
1031
1030
  };
1032
1031
  //#endregion
1033
- export { mt as KBChatWidget };
1032
+ export { ht as KBChatWidget };