@zenera/chat-widget 0.0.0-stage → 0.1.1

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.
Files changed (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +190 -2
  3. package/dist/index.js +16 -0
  4. package/dist/shadow-DmEgvnQS.js +4 -0
  5. package/dist/styles.css +2 -0
  6. package/dist/types/packages/chat-widget/src/index.d.ts +4 -0
  7. package/dist/types/packages/chat-widget/src/launcher/geometry.d.ts +27 -0
  8. package/dist/types/packages/chat-widget/src/launcher/index.d.ts +17 -0
  9. package/dist/types/packages/chat-widget/src/launcher/presentation.d.ts +59 -0
  10. package/dist/types/packages/chat-widget/src/launcher/shell.d.ts +22 -0
  11. package/dist/types/packages/chat-widget/src/reducer.d.ts +63 -0
  12. package/dist/types/packages/chat-widget/src/transport.d.ts +98 -0
  13. package/dist/types/packages/chat-widget/src/ui/ChatSidebar.d.ts +54 -0
  14. package/dist/types/packages/chat-widget/src/ui/ChatThreadView.d.ts +37 -0
  15. package/dist/types/packages/chat-widget/src/ui/ZeneraChat.d.ts +42 -0
  16. package/dist/types/packages/chat-widget/src/ui/ZeneraChatLauncher.d.ts +15 -0
  17. package/dist/types/packages/chat-widget/src/ui/ZeneraChatWidget.d.ts +26 -0
  18. package/dist/types/packages/chat-widget/src/ui/index.d.ts +9 -0
  19. package/dist/types/packages/chat-widget/src/ui/internal/InterruptCard.d.ts +35 -0
  20. package/dist/types/packages/chat-widget/src/ui/internal/KnownToolContent.d.ts +7 -0
  21. package/dist/types/packages/chat-widget/src/ui/internal/McpToolContent.d.ts +7 -0
  22. package/dist/types/packages/chat-widget/src/ui/internal/MemoryToolContent.d.ts +10 -0
  23. package/dist/types/packages/chat-widget/src/ui/internal/ShadowFrame.d.ts +6 -0
  24. package/dist/types/packages/chat-widget/src/ui/internal/ToolCallCard.d.ts +25 -0
  25. package/dist/types/packages/chat-widget/src/ui/internal/ToolContent.d.ts +22 -0
  26. package/dist/types/packages/chat-widget/src/ui/internal/composerDraft.d.ts +4 -0
  27. package/dist/types/packages/chat-widget/src/ui/internal/memoryPresentation.d.ts +13 -0
  28. package/dist/types/packages/chat-widget/src/ui/internal/toolPresentation.d.ts +23 -0
  29. package/dist/types/packages/chat-widget/src/useChatThread.d.ts +24 -0
  30. package/dist/types/packages/chat-widget/src/useThreadList.d.ts +11 -0
  31. package/dist/types/packages/chat-widget/src/widget.d.ts +32 -0
  32. package/dist/types/shared/components/Button.d.ts +11 -0
  33. package/dist/types/shared/components/CodeBlock.d.ts +5 -0
  34. package/dist/types/shared/components/CollapsibleBubble.d.ts +7 -0
  35. package/dist/types/shared/components/CopyButton.d.ts +6 -0
  36. package/dist/types/shared/components/DeleteButton.d.ts +13 -0
  37. package/dist/types/shared/components/Hint.d.ts +7 -0
  38. package/dist/types/shared/components/Input.d.ts +2 -0
  39. package/dist/types/shared/components/Markdown.d.ts +6 -0
  40. package/dist/types/shared/components/Mermaid.d.ts +8 -0
  41. package/dist/types/shared/components/Textarea.d.ts +2 -0
  42. package/dist/types/shared/lib/clipboard.d.ts +4 -0
  43. package/dist/types/shared/lib/colorScheme.d.ts +1 -0
  44. package/dist/types/shared/lib/focus.d.ts +2 -0
  45. package/dist/types/shared/lib/highlight.d.ts +3 -0
  46. package/dist/types/shared/lib/portalContainer.d.ts +2 -0
  47. package/dist/types/shared/lib/promptHistory.d.ts +32 -0
  48. package/dist/types/shared/lib/utils.d.ts +2 -0
  49. package/dist/ui.js +2823 -0
  50. package/dist/useThreadList-Pg29akQ4.js +576 -0
  51. package/dist/widget/chat-widget.iife.js +315 -0
  52. package/package.json +89 -5
package/dist/ui.js ADDED
@@ -0,0 +1,2823 @@
1
+ import { jsx as n, jsxs as d, Fragment as _e } from "react/jsx-runtime";
2
+ import * as Ae from "react";
3
+ import { useSyncExternalStore as Rt, useState as O, useRef as $, useId as It, useLayoutEffect as Se, useEffect as P, useContext as it, createContext as at, useMemo as de, useCallback as ue, Fragment as $t } from "react";
4
+ import { clsx as Pt } from "clsx";
5
+ import { twMerge as Mt } from "tailwind-merge";
6
+ import { ChevronDown as st, Check as Te, Copy as Dt, PauseCircle as Wt, Wrench as Ht, Plug as qt, Users as Bt, Globe as Ft, Terminal as Ut, Files as Kt, Brain as ot, LoaderCircle as ge, ChevronRight as lt, MessageSquarePlus as Jt, Square as Xt, SendHorizontal as Zt, Trash2 as Gt, PanelRightOpen as Yt, PanelRightClose as Vt, PanelLeftOpen as Qt, PanelLeftClose as er, Plus as tr, SquarePen as rr } from "lucide-react";
7
+ import { u as nr, j as ir } from "./useThreadList-Pg29akQ4.js";
8
+ import { Slot as ar } from "@radix-ui/react-slot";
9
+ import { cva as sr } from "class-variance-authority";
10
+ import * as pe from "@radix-ui/react-tooltip";
11
+ import or from "react-markdown";
12
+ import lr from "rehype-sanitize";
13
+ import cr from "remark-gfm";
14
+ import M from "highlight.js/lib/core";
15
+ import dr from "highlight.js/lib/languages/bash";
16
+ import ur from "highlight.js/lib/languages/css";
17
+ import mr from "highlight.js/lib/languages/dockerfile";
18
+ import fr from "highlight.js/lib/languages/diff";
19
+ import pr from "highlight.js/lib/languages/ini";
20
+ import hr from "highlight.js/lib/languages/javascript";
21
+ import gr from "highlight.js/lib/languages/json";
22
+ import br from "highlight.js/lib/languages/markdown";
23
+ import xr from "highlight.js/lib/languages/python";
24
+ import yr from "highlight.js/lib/languages/sql";
25
+ import vr from "highlight.js/lib/languages/typescript";
26
+ import wr from "highlight.js/lib/languages/xml";
27
+ import Nr from "highlight.js/lib/languages/yaml";
28
+ import { createPortal as ct } from "react-dom";
29
+ function kr(e) {
30
+ const t = new MutationObserver(e);
31
+ return t.observe(document.documentElement, { attributes: !0, attributeFilter: ["class"] }), () => t.disconnect();
32
+ }
33
+ function je() {
34
+ return Rt(
35
+ kr,
36
+ () => document.documentElement.classList.contains("dark") ? "dark" : "light",
37
+ () => "light"
38
+ );
39
+ }
40
+ function k(...e) {
41
+ return Mt(Pt(e));
42
+ }
43
+ const _r = sr(
44
+ "inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0",
45
+ {
46
+ variants: {
47
+ variant: {
48
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
49
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
50
+ outline: "border border-input bg-transparent hover:bg-accent",
51
+ ghost: "hover:bg-accent hover:text-accent-foreground",
52
+ destructive: "bg-destructive text-white hover:bg-destructive/90",
53
+ link: "text-primary underline-offset-4 hover:underline"
54
+ },
55
+ size: {
56
+ default: "h-9 px-4 py-2",
57
+ sm: "h-8 px-3 text-xs",
58
+ lg: "h-10 px-6",
59
+ icon: "size-9"
60
+ }
61
+ },
62
+ defaultVariants: { variant: "default", size: "default" }
63
+ }
64
+ ), re = Ae.forwardRef(
65
+ ({ className: e, variant: t, size: i, asChild: a = !1, ...s }, r) => /* @__PURE__ */ n(
66
+ a ? ar : "button",
67
+ {
68
+ ref: r,
69
+ className: k(_r({ variant: t, size: i, className: e })),
70
+ ...s
71
+ }
72
+ )
73
+ );
74
+ re.displayName = "Button";
75
+ const dt = 240, Sr = 48, Cr = (e) => e > dt + Sr;
76
+ function Er({
77
+ children: e,
78
+ className: t
79
+ }) {
80
+ const [i, a] = O(!1), [s, r] = O(!1), o = $(null), l = It();
81
+ Se(() => {
82
+ const p = o.current;
83
+ if (!p) return;
84
+ const h = () => r(Cr(p.offsetHeight));
85
+ h();
86
+ const u = new ResizeObserver(h);
87
+ return u.observe(p), () => u.disconnect();
88
+ }, []);
89
+ const c = s && !i;
90
+ return /* @__PURE__ */ d("div", { className: t, children: [
91
+ /* @__PURE__ */ n(
92
+ "div",
93
+ {
94
+ id: l,
95
+ style: c ? { maxHeight: dt } : void 0,
96
+ className: k(
97
+ c && "overflow-hidden [mask-image:linear-gradient(to_bottom,black_70%,transparent)]"
98
+ ),
99
+ children: /* @__PURE__ */ n("div", { ref: o, children: e })
100
+ }
101
+ ),
102
+ s && /* @__PURE__ */ d(
103
+ "button",
104
+ {
105
+ type: "button",
106
+ "aria-expanded": i,
107
+ "aria-controls": l,
108
+ onClick: () => a((p) => !p),
109
+ className: "mt-1 flex cursor-pointer items-center gap-1 rounded-sm text-xs text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3.5",
110
+ children: [
111
+ i ? "Show less" : "Show more",
112
+ /* @__PURE__ */ n(st, { className: k("transition-transform", i && "rotate-180") })
113
+ ]
114
+ }
115
+ )
116
+ ] });
117
+ }
118
+ async function zr(e) {
119
+ var i;
120
+ if ((i = navigator.clipboard) != null && i.writeText)
121
+ try {
122
+ await navigator.clipboard.writeText(e);
123
+ return;
124
+ } catch {
125
+ }
126
+ const t = document.createElement("textarea");
127
+ t.value = e, t.setAttribute("readonly", ""), t.style.position = "fixed", t.style.opacity = "0", document.body.append(t), t.select();
128
+ try {
129
+ if (!document.execCommand("copy")) throw new Error("copy was refused");
130
+ } finally {
131
+ t.remove();
132
+ }
133
+ }
134
+ const ut = (e) => e.replace(/[\r\n]+$/, "");
135
+ function He(e) {
136
+ var a;
137
+ const t = ((a = window.getSelection()) == null ? void 0 : a.toString()) ?? "", i = ut(t);
138
+ !t || i === t || (e.clipboardData.setData("text/plain", i), e.preventDefault());
139
+ }
140
+ const Lr = 1500, qe = "opacity-0 group-hover/msg:opacity-100 [@media(hover:none)]:opacity-100";
141
+ function ze({
142
+ text: e,
143
+ label: t = "Copy",
144
+ className: i
145
+ }) {
146
+ const [a, s] = O("idle"), r = $(void 0);
147
+ P(() => () => clearTimeout(r.current), []);
148
+ const o = async () => {
149
+ try {
150
+ await zr(ut(e)), s("copied");
151
+ } catch {
152
+ s("failed");
153
+ }
154
+ clearTimeout(r.current), r.current = setTimeout(() => s("idle"), Lr);
155
+ }, l = a === "copied" ? "Copied" : a === "failed" ? "Copy failed" : t;
156
+ return /* @__PURE__ */ d(
157
+ "button",
158
+ {
159
+ type: "button",
160
+ title: l,
161
+ "aria-label": l,
162
+ onClick: () => void o(),
163
+ className: k(
164
+ // `relative` anchors the absolutely positioned sr-only status: without it the status
165
+ // is placed against the page, outside the scrolling panes, and makes the page scroll.
166
+ "relative inline-flex size-6 cursor-pointer select-none items-center justify-center rounded-md text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3.5",
167
+ a === "failed" && "text-danger",
168
+ i
169
+ ),
170
+ children: [
171
+ a === "copied" ? /* @__PURE__ */ n(Te, {}) : /* @__PURE__ */ n(Dt, {}),
172
+ /* @__PURE__ */ n("span", { role: "status", className: "sr-only", children: a === "idle" ? "" : l })
173
+ ]
174
+ }
175
+ );
176
+ }
177
+ const mt = at(null), Or = () => it(mt);
178
+ function ye({
179
+ label: e,
180
+ side: t,
181
+ className: i,
182
+ children: a
183
+ }) {
184
+ const s = Or();
185
+ return /* @__PURE__ */ n(pe.Provider, { delayDuration: 300, children: /* @__PURE__ */ d(pe.Root, { children: [
186
+ /* @__PURE__ */ n(pe.Trigger, { asChild: !0, children: a }),
187
+ /* @__PURE__ */ n(pe.Portal, { container: s, children: /* @__PURE__ */ n(
188
+ pe.Content,
189
+ {
190
+ side: t,
191
+ sideOffset: 6,
192
+ className: k(
193
+ "z-50 max-w-sm rounded-md border border-border bg-popover px-3 py-1.5 text-xs whitespace-pre-line text-popover-foreground shadow-md",
194
+ i
195
+ ),
196
+ children: e
197
+ }
198
+ ) })
199
+ ] }) });
200
+ }
201
+ M.registerLanguage("bash", dr);
202
+ M.registerLanguage("css", ur);
203
+ M.registerLanguage("dockerfile", mr);
204
+ M.registerLanguage("diff", fr);
205
+ M.registerLanguage("ini", pr);
206
+ M.registerLanguage("javascript", hr);
207
+ M.registerLanguage("json", gr);
208
+ M.registerLanguage("markdown", br);
209
+ M.registerLanguage("python", xr);
210
+ M.registerLanguage("sql", yr);
211
+ M.registerLanguage("typescript", vr);
212
+ M.registerLanguage("xml", wr);
213
+ M.registerLanguage("yaml", Nr);
214
+ M.registerAliases(["jsonl", "ndjson"], { languageName: "json" });
215
+ const Ar = 5e5, Tr = /(^|\/)(docker|container)file(\.[^/]+)?$|\.(docker|container)file$/i;
216
+ function jr(e) {
217
+ if (Tr.test(e)) return "dockerfile";
218
+ const t = e.slice(e.lastIndexOf(".") + 1).toLowerCase();
219
+ return M.getLanguage(t) ? t : void 0;
220
+ }
221
+ function Rr(e, t) {
222
+ return !t || !M.getLanguage(t) || e.length > Ar ? null : M.highlight(e, { language: t, ignoreIllegals: !0 }).value;
223
+ }
224
+ function Z({
225
+ code: e,
226
+ lang: t,
227
+ className: i
228
+ }) {
229
+ const a = de(() => Rr(e, t), [e, t]);
230
+ return /* @__PURE__ */ d("div", { className: "group/code relative min-w-0", children: [
231
+ /* @__PURE__ */ n("pre", { className: k("overflow-x-auto font-mono text-xs", i), children: a === null ? /* @__PURE__ */ n("code", { children: e }) : /* @__PURE__ */ n("code", { dangerouslySetInnerHTML: { __html: a } }) }),
232
+ e && /* @__PURE__ */ n(
233
+ ze,
234
+ {
235
+ text: e,
236
+ label: "Copy code",
237
+ className: "absolute top-1.5 right-1.5 bg-surface-code/80 opacity-0 group-hover/code:opacity-100 [@media(hover:none)]:opacity-100"
238
+ }
239
+ )
240
+ ] });
241
+ }
242
+ let Ir, $r = 0;
243
+ const Pr = () => Ir ?? (Ir = import("mermaid").then(({ default: e }) => e));
244
+ function Mr({ code: e, natural: t = !1 }) {
245
+ const [i, a] = O(null), [s, r] = O(null), o = je();
246
+ return P(() => {
247
+ let l = !0;
248
+ return Pr().then((c) => (c.initialize({
249
+ startOnLoad: !1,
250
+ theme: o === "dark" ? "dark" : "default",
251
+ securityLevel: "strict",
252
+ suppressErrorRendering: !0,
253
+ flowchart: { useMaxWidth: !t },
254
+ state: { useMaxWidth: !t },
255
+ themeVariables: { fontSize: "14px" }
256
+ }), c.render(`mermaid-${++$r}`, e))).then(
257
+ (c) => {
258
+ l && (a(c.svg), r(null));
259
+ },
260
+ (c) => {
261
+ l && (a(null), r(c instanceof Error ? c.message : String(c)));
262
+ }
263
+ ), () => {
264
+ l = !1;
265
+ };
266
+ }, [e, o, t]), i === null ? /* @__PURE__ */ d("div", { children: [
267
+ s && /* @__PURE__ */ d("p", { className: "mb-1 text-xs text-danger", children: [
268
+ "Mermaid: ",
269
+ s
270
+ ] }),
271
+ /* @__PURE__ */ n(Z, { code: e })
272
+ ] }) : t ? /* @__PURE__ */ n("div", { className: "overflow-x-auto", children: /* @__PURE__ */ n("div", { className: "mx-auto w-max", dangerouslySetInnerHTML: { __html: i } }) }) : /* @__PURE__ */ n(
273
+ "div",
274
+ {
275
+ className: "flex justify-center overflow-x-auto",
276
+ dangerouslySetInnerHTML: { __html: i }
277
+ }
278
+ );
279
+ }
280
+ const Dr = [
281
+ "p",
282
+ "h1",
283
+ "h2",
284
+ "h3",
285
+ "h4",
286
+ "h5",
287
+ "h6",
288
+ "ul",
289
+ "ol",
290
+ "li",
291
+ "blockquote",
292
+ "table"
293
+ ];
294
+ function Wr(e) {
295
+ return function({ node: i, ...a }) {
296
+ var r;
297
+ return /* @__PURE__ */ n(e, { ...a, "data-line": (r = i == null ? void 0 : i.position) == null ? void 0 : r.start.line });
298
+ };
299
+ }
300
+ function ie({
301
+ children: e,
302
+ className: t,
303
+ lines: i,
304
+ linkAction: a
305
+ }) {
306
+ const s = de(
307
+ () => ({
308
+ ...i ? Object.fromEntries(Dr.map((r) => [r, Wr(r)])) : void 0,
309
+ a: ({ href: r, children: o }) => {
310
+ if (r && /^https?:\/\//.test(r))
311
+ return /* @__PURE__ */ n("a", { href: r, target: "_blank", rel: "noreferrer", children: o });
312
+ const l = r ? a == null ? void 0 : a(r) : void 0;
313
+ return l ? /* @__PURE__ */ n(
314
+ "button",
315
+ {
316
+ type: "button",
317
+ className: "cursor-pointer text-primary underline-offset-2 hover:underline",
318
+ onClick: l,
319
+ children: o
320
+ }
321
+ ) : /* @__PURE__ */ n("span", { className: "text-primary", children: o });
322
+ },
323
+ pre: ({ node: r, children: o }) => {
324
+ var f, m;
325
+ const l = r == null ? void 0 : r.children[0];
326
+ if ((l == null ? void 0 : l.type) !== "element" || l.tagName !== "code")
327
+ return /* @__PURE__ */ n("pre", { children: o });
328
+ const c = l.properties.className, p = (f = (Array.isArray(c) ? c.map(String) : []).find((x) => x.startsWith("language-"))) == null ? void 0 : f.slice(9), h = l.children.map((x) => x.type === "text" ? x.value : "").join("").replace(/\n$/, ""), u = p === "mermaid" ? /* @__PURE__ */ n(Mr, { code: h }) : /* @__PURE__ */ n(Z, { code: h, lang: p });
329
+ return i ? /* @__PURE__ */ n("div", { "data-line": (m = r == null ? void 0 : r.position) == null ? void 0 : m.start.line, children: u }) : u;
330
+ }
331
+ }),
332
+ [i, a]
333
+ );
334
+ return /* @__PURE__ */ n("div", { className: k("markdown", t), children: /* @__PURE__ */ n(
335
+ or,
336
+ {
337
+ remarkPlugins: [cr],
338
+ rehypePlugins: [lr],
339
+ components: s,
340
+ children: e
341
+ }
342
+ ) });
343
+ }
344
+ const ft = Ae.forwardRef(({ className: e, ...t }, i) => /* @__PURE__ */ n(
345
+ "textarea",
346
+ {
347
+ ref: i,
348
+ className: k(
349
+ "w-full rounded-md border border-input bg-surface-input px-3 py-2 text-sm outline-none placeholder:text-muted-foreground focus-visible:border-ring disabled:opacity-50",
350
+ e
351
+ ),
352
+ ...t
353
+ }
354
+ ));
355
+ ft.displayName = "Textarea";
356
+ function Hr() {
357
+ var t;
358
+ let e = document.activeElement;
359
+ for (; (t = e == null ? void 0 : e.shadowRoot) != null && t.activeElement; ) e = e.shadowRoot.activeElement;
360
+ return e;
361
+ }
362
+ function qr(e) {
363
+ var a;
364
+ if ((a = window.matchMedia) != null && a.call(window, "(pointer: coarse)").matches) return !1;
365
+ const t = Hr();
366
+ return !t || t === document.body ? !0 : t.closest('[role="dialog"], [role="menu"], [role="listbox"]') || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName) || t.isContentEditable === !0 ? !1 : e === void 0 || !!(e != null && e.contains(t));
367
+ }
368
+ function Br(e, t) {
369
+ !e || e.disabled || !qr(t) || (e.focus({ preventScroll: !0 }), e.setSelectionRange(e.value.length, e.value.length));
370
+ }
371
+ const Fr = 30, Ur = 1e4, Ni = (e, t, i) => `zenera.history.${e}.${t}.${i}`;
372
+ function pt(e) {
373
+ try {
374
+ const t = JSON.parse(localStorage.getItem(e) ?? "[]");
375
+ return Array.isArray(t) ? t.filter((i) => typeof i == "string") : [];
376
+ } catch {
377
+ return [];
378
+ }
379
+ }
380
+ function Kr(e, t) {
381
+ const i = t.trim();
382
+ if (!(!i || i.length > Ur))
383
+ try {
384
+ const a = [...pt(e).filter((s) => s !== i), i];
385
+ localStorage.setItem(e, JSON.stringify(a.slice(-Fr)));
386
+ } catch {
387
+ }
388
+ }
389
+ function Jr(e) {
390
+ const t = /* @__PURE__ */ new Set(), i = [];
391
+ for (let a = e.length - 1; a >= 0; a--)
392
+ !e[a].trim() || t.has(e[a]) || (t.add(e[a]), i.unshift(e[a]));
393
+ return i;
394
+ }
395
+ function Xr(e, t, i, a) {
396
+ if (i === "up") {
397
+ if (!e.length) return null;
398
+ const r = t ? t.draft : a, o = t ? Math.max(0, t.index - 1) : e.length - 1;
399
+ return { value: e[o], browsing: { index: o, draft: r, shown: e[o] } };
400
+ }
401
+ if (!t) return null;
402
+ const s = t.index + 1;
403
+ return s >= e.length ? { value: t.draft, browsing: null } : {
404
+ value: e[s],
405
+ browsing: { index: s, draft: t.draft, shown: e[s] }
406
+ };
407
+ }
408
+ const Zr = (e, t, i) => t === i && !e.slice(0, t).includes(`
409
+ `);
410
+ function Gr(e) {
411
+ const t = $(null), i = $(e);
412
+ P(() => {
413
+ i.current = e;
414
+ });
415
+ const a = ue(() => {
416
+ t.current = null;
417
+ }, []);
418
+ return { onKeyDown: ue(
419
+ (r, o, l) => {
420
+ if (r.key !== "ArrowUp" && r.key !== "ArrowDown" || r.shiftKey || r.altKey || r.ctrlKey || r.metaKey || r.nativeEvent.isComposing)
421
+ return;
422
+ const c = r.currentTarget, p = t.current !== null && t.current.shown === o;
423
+ p || (t.current = null);
424
+ const h = r.key === "ArrowUp" ? "up" : "down";
425
+ if (h === "up" && !p && !Zr(o, c.selectionStart, c.selectionEnd))
426
+ return;
427
+ const u = Xr(
428
+ Jr(i.current()),
429
+ t.current,
430
+ h,
431
+ o
432
+ );
433
+ u && (r.preventDefault(), t.current = u.browsing, l(u.value), requestAnimationFrame(
434
+ () => c.setSelectionRange(u.value.length, u.value.length)
435
+ ));
436
+ },
437
+ []
438
+ ), reset: a };
439
+ }
440
+ const Yr = "zenera.draft.chat", ki = (e, t, i, a) => `${Yr}.${e}.${t}.${i}.${a ?? "new"}`;
441
+ function Vr(e) {
442
+ try {
443
+ return localStorage.getItem(e) ?? "";
444
+ } catch {
445
+ return "";
446
+ }
447
+ }
448
+ function Be(e, t) {
449
+ try {
450
+ t ? localStorage.setItem(e, t) : localStorage.removeItem(e);
451
+ } catch {
452
+ }
453
+ }
454
+ const ht = at(null);
455
+ function Qr(e, t) {
456
+ return e.ended ? e.ended : !t || t.status === "pending" ? "waiting" : t.status === "superseded" || t.resumeState === "stale" ? "superseded" : t.resumeState === "failed" ? "failed" : t.resumeState === "queued" ? "resuming" : t.status;
457
+ }
458
+ function Fe({
459
+ icon: e,
460
+ title: t,
461
+ text: i,
462
+ tone: a,
463
+ children: s
464
+ }) {
465
+ return /* @__PURE__ */ d(
466
+ "div",
467
+ {
468
+ role: "group",
469
+ "aria-label": "The agent is waiting for you",
470
+ className: k(
471
+ "my-1 flex flex-col gap-2 rounded-lg border px-3 py-2.5 text-sm sm:flex-row sm:items-center",
472
+ a === "active" && "border-primary/40 bg-primary/5",
473
+ a === "done" && "border-border bg-secondary/40",
474
+ a === "muted" && "border-border bg-transparent text-muted-foreground",
475
+ a === "danger" && "border-danger/40 text-danger"
476
+ ),
477
+ children: [
478
+ /* @__PURE__ */ d("div", { className: "flex min-w-0 flex-1 items-center gap-3", children: [
479
+ e,
480
+ /* @__PURE__ */ d("div", { className: "min-w-0", children: [
481
+ /* @__PURE__ */ n("div", { className: "font-medium", children: t }),
482
+ i && /* @__PURE__ */ n("div", { className: "text-xs text-muted-foreground", children: i })
483
+ ] })
484
+ ] }),
485
+ s && /* @__PURE__ */ n("div", { className: "flex shrink-0 items-center gap-2", children: s })
486
+ ]
487
+ }
488
+ );
489
+ }
490
+ function en({ interrupt: e, info: t, actions: i }) {
491
+ const a = Qr(e, t);
492
+ return a !== "waiting" ? /* @__PURE__ */ n(
493
+ Fe,
494
+ {
495
+ tone: "muted",
496
+ icon: /* @__PURE__ */ n(Te, { className: "size-4" }),
497
+ title: a === "cancelled" || a === "superseded" ? "Skipped" : "Done - continuing"
498
+ }
499
+ ) : /* @__PURE__ */ n(
500
+ Fe,
501
+ {
502
+ tone: "active",
503
+ icon: /* @__PURE__ */ n(Wt, { className: "size-4 text-primary" }),
504
+ title: e.message ?? "The agent is waiting for you",
505
+ children: t && /* @__PURE__ */ n(
506
+ re,
507
+ {
508
+ type: "button",
509
+ size: "sm",
510
+ variant: "ghost",
511
+ onClick: () => void i.cancel(e.id),
512
+ children: "Skip"
513
+ }
514
+ )
515
+ }
516
+ );
517
+ }
518
+ function tn({ interrupt: e }) {
519
+ var s, r;
520
+ const t = it(ht);
521
+ if (!t) return null;
522
+ const i = typeof ((s = e.metadata) == null ? void 0 : s.kind) == "string" ? e.metadata.kind : e.reason, a = ((r = t.cards) == null ? void 0 : r[i]) ?? en;
523
+ return /* @__PURE__ */ n(a, { interrupt: e, info: t.info[e.id], actions: t });
524
+ }
525
+ const Ue = {
526
+ stdout: "Output",
527
+ stderr: "Standard error",
528
+ cwd: "Working directory",
529
+ ids: "Memory IDs",
530
+ job_id: "Job ID",
531
+ url: "URL",
532
+ urls: "URLs",
533
+ duration_ms: "Duration (ms)",
534
+ start_line: "Start line",
535
+ end_line: "End line"
536
+ };
537
+ function gt(e) {
538
+ return Object.hasOwn(Ue, e) ? Ue[e] : e.replace(/_/g, " ").replace(/^./, (t) => t.toUpperCase());
539
+ }
540
+ function me({ url: e, children: t }) {
541
+ return /^https?:\/\//i.test(e) ? /* @__PURE__ */ n("a", { className: "break-all text-primary underline", href: e, target: "_blank", rel: "noreferrer", children: t ?? e }) : /* @__PURE__ */ n("span", { className: "break-all", children: t ?? e });
542
+ }
543
+ function bt({ text: e, path: t }) {
544
+ return e === "" ? /* @__PURE__ */ n("span", { className: "text-muted-foreground", children: "(empty)" }) : t && /\.(md|markdown)$/i.test(t) ? /* @__PURE__ */ n(ie, { className: "text-xs [overflow-wrap:anywhere]", children: e }) : /* @__PURE__ */ n(Z, { code: e, lang: t ? jr(t) : void 0 });
545
+ }
546
+ function I({
547
+ value: e,
548
+ field: t = "",
549
+ depth: i = 0
550
+ }) {
551
+ if (typeof e == "string")
552
+ return t === "url" || t === "urls" ? /* @__PURE__ */ n(me, { url: e }) : ["command", "stdout", "stderr", "content", "patch", "output"].includes(t) ? /* @__PURE__ */ n(
553
+ Z,
554
+ {
555
+ className: k(t === "stderr" && "text-danger"),
556
+ code: e || "(empty)",
557
+ lang: t === "patch" ? "diff" : t === "command" ? "bash" : void 0
558
+ }
559
+ ) : /* @__PURE__ */ n("div", { className: "whitespace-pre-wrap break-words [overflow-wrap:anywhere]", children: e || "(empty)" });
560
+ if (e === null || typeof e != "object")
561
+ return /* @__PURE__ */ n("span", { className: "font-mono", children: String(e) });
562
+ if (i >= 3) return /* @__PURE__ */ n(Z, { code: JSON.stringify(e, null, 2), lang: "json" });
563
+ if (Array.isArray(e))
564
+ return e.length ? /* @__PURE__ */ n("div", { className: "space-y-2", children: e.map((s, r) => /* @__PURE__ */ n(I, { value: s, field: t, depth: i + 1 }, r)) }) : /* @__PURE__ */ n("span", { className: "text-muted-foreground", children: "None" });
565
+ const a = Object.entries(e);
566
+ return a.length ? /* @__PURE__ */ n("dl", { className: "grid min-w-0 grid-cols-[minmax(0,6rem)_minmax(0,1fr)] items-start gap-x-3 gap-y-2", children: a.map(([s, r]) => /* @__PURE__ */ d($t, { children: [
567
+ /* @__PURE__ */ n(
568
+ "dt",
569
+ {
570
+ className: k(
571
+ "break-words text-[11px] text-muted-foreground",
572
+ (s === "error" || s === "failed") && "text-danger"
573
+ ),
574
+ children: gt(s)
575
+ }
576
+ ),
577
+ /* @__PURE__ */ n("dd", { className: "min-w-0", children: /* @__PURE__ */ n(I, { value: r, field: s, depth: i + 1 }) })
578
+ ] }, s)) }) : /* @__PURE__ */ n("span", { className: "text-muted-foreground", children: "No fields" });
579
+ }
580
+ function be({ value: e }) {
581
+ return /* @__PURE__ */ n("dl", { className: "flex min-w-0 flex-wrap gap-x-4 gap-y-1 text-[11px] text-muted-foreground", children: Object.entries(e).map(([t, i]) => /* @__PURE__ */ d("div", { className: "flex min-w-0 max-w-full items-baseline gap-1", children: [
582
+ /* @__PURE__ */ d("dt", { className: "shrink-0", children: [
583
+ gt(t),
584
+ ":"
585
+ ] }),
586
+ /* @__PURE__ */ n("dd", { className: "min-w-0 break-all", children: /* @__PURE__ */ n(I, { value: i }) })
587
+ ] }, t)) });
588
+ }
589
+ function K({
590
+ value: e,
591
+ omit: t,
592
+ renderValue: i = (a) => /* @__PURE__ */ n(I, { value: a })
593
+ }) {
594
+ const a = Object.fromEntries(Object.entries(e).filter(([s]) => !t.includes(s)));
595
+ return Object.keys(a).length ? /* @__PURE__ */ d("details", { className: "mt-2 text-muted-foreground", children: [
596
+ /* @__PURE__ */ n("summary", { className: "w-fit cursor-pointer rounded-sm text-[11px] outline-none hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground", children: "Details" }),
597
+ /* @__PURE__ */ n("div", { className: "mt-2", children: i(a) })
598
+ ] }) : null;
599
+ }
600
+ function A(e) {
601
+ return e !== null && typeof e == "object" && !Array.isArray(e) ? Object.fromEntries(Object.entries(e)) : void 0;
602
+ }
603
+ function xe(e) {
604
+ try {
605
+ return { value: JSON.parse(e) };
606
+ } catch (t) {
607
+ if (!(t instanceof SyntaxError)) throw t;
608
+ return;
609
+ }
610
+ }
611
+ function rn(e) {
612
+ let t = "", i = 0, a = !1, s = !1;
613
+ const r = () => {
614
+ t = t.trimEnd() + `
615
+ ` + " ".repeat(i);
616
+ };
617
+ for (const o of e) {
618
+ if (a) {
619
+ t += o, s ? s = !1 : o === "\\" ? s = !0 : o === '"' && (a = !1);
620
+ continue;
621
+ }
622
+ o === '"' ? (a = !0, t += o) : o === "{" || o === "[" ? (t += o, i++, r()) : o === "}" || o === "]" ? (i = Math.max(0, i - 1), r(), t += o) : o === "," ? (t += o, r()) : o === ":" ? t += ": " : /\s/.test(o) ? t && !/\s$/.test(t) && (t += " ") : t += o;
623
+ }
624
+ return t;
625
+ }
626
+ function nn(e) {
627
+ var a;
628
+ let t = 1;
629
+ for (; t < e.length; ) {
630
+ const s = e[t];
631
+ if (s === '"' || s.charCodeAt(0) < 32) break;
632
+ if (s === "\\") {
633
+ const r = e[t + 1];
634
+ if (!r) break;
635
+ if (r === "u") {
636
+ if (!/^[\da-f]{4}$/i.test(e.slice(t + 2, t + 6))) break;
637
+ t += 6;
638
+ continue;
639
+ }
640
+ if (!'"\\/bfnrt'.includes(r)) break;
641
+ t += 2;
642
+ } else
643
+ t++;
644
+ }
645
+ const i = (a = xe(e.slice(0, t) + '"')) == null ? void 0 : a.value;
646
+ return typeof i == "string" ? i : void 0;
647
+ }
648
+ function an(e) {
649
+ var c, p, h;
650
+ if (!e.startsWith("{")) return;
651
+ const t = [];
652
+ let i = 1, a = 1, s = !1, r = !1;
653
+ for (let u = 1; u < e.length; u++) {
654
+ const f = e[u];
655
+ if (s)
656
+ r ? r = !1 : f === "\\" ? r = !0 : f === '"' && (s = !1);
657
+ else if (f === '"')
658
+ s = !0;
659
+ else if (f === "{" || f === "[")
660
+ a++;
661
+ else if (f === "}" || f === "]")
662
+ a--;
663
+ else if (f === "," && a === 1) {
664
+ const m = A((c = xe("{" + e.slice(i, u) + "}")) == null ? void 0 : c.value);
665
+ if (!m) return t.length ? Object.fromEntries(t) : void 0;
666
+ t.push(...Object.entries(m)), i = u + 1;
667
+ }
668
+ }
669
+ const o = e.slice(i), l = A((p = xe("{" + o + "}")) == null ? void 0 : p.value);
670
+ if (l && /(?:true|false|null|["}\]])\s*$/.test(o))
671
+ t.push(...Object.entries(l));
672
+ else {
673
+ const u = /^\s*("(?:[^"\\]|\\.)*")\s*:\s*(".*)$/s.exec(o);
674
+ if (u) {
675
+ const f = (h = xe(u[1])) == null ? void 0 : h.value, m = nn(u[2]);
676
+ typeof f == "string" && m !== void 0 && t.push([f, m]);
677
+ }
678
+ }
679
+ return t.length ? Object.fromEntries(t) : void 0;
680
+ }
681
+ function Ke(e) {
682
+ const t = /\n\u2026 (\d+) more characters$/.exec(e), i = (t ? e.slice(0, t.index) : e).trimStart(), a = xe(i), s = t ? Number(t[1]) : void 0;
683
+ if (a)
684
+ return {
685
+ value: a.value,
686
+ raw: JSON.stringify(a.value, null, 2) + (t ? t[0] : ""),
687
+ incomplete: !1,
688
+ omitted: s
689
+ };
690
+ const r = /^[{["]/.test(i);
691
+ return {
692
+ value: r ? an(i) : void 0,
693
+ raw: r ? rn(i) + (t ? t[0] : "") : e,
694
+ incomplete: r,
695
+ omitted: s
696
+ };
697
+ }
698
+ const Je = {
699
+ memory_search: { title: "Memory search", family: "memory" },
700
+ memory_grep: { title: "Search memory text", family: "memory" },
701
+ memory_load: { title: "Load memories", family: "memory" },
702
+ memory_commit: { title: "Remember", family: "memory" },
703
+ memory_forget: { title: "Forget memories", family: "memory" },
704
+ read_file: { title: "Read file", family: "file" },
705
+ list_dir: { title: "List directory", family: "file" },
706
+ find_files: { title: "Find files", family: "file" },
707
+ write_file: { title: "Write file", family: "file" },
708
+ apply_patch: { title: "Apply patch", family: "file" },
709
+ move_file: { title: "Move file", family: "file" },
710
+ copy_file: { title: "Copy file", family: "file" },
711
+ delete_file: { title: "Delete file", family: "file" },
712
+ run_command: { title: "Run command", family: "command" },
713
+ run_command_background: { title: "Start command", family: "command" },
714
+ read_command_output: { title: "Read command output", family: "command" },
715
+ stop_command: { title: "Stop command", family: "command" },
716
+ web_search: { title: "Web search", family: "web" },
717
+ web_answer: { title: "Web answer", family: "web" },
718
+ web_read: { title: "Read web pages", family: "web" },
719
+ fork: { title: "Parallel agents", family: "agent" },
720
+ compact: { title: "Summarize context", family: "agent" },
721
+ mcp_servers: { title: "Connected services", family: "mcp" },
722
+ mcp_tools: { title: "List service tools", family: "mcp" },
723
+ mcp_describe: { title: "Read tool", family: "mcp" },
724
+ mcp_call: { title: "Service call", family: "mcp" }
725
+ };
726
+ function ne(e) {
727
+ return e.replace(/[_-]+/g, " ").trim();
728
+ }
729
+ function sn(e) {
730
+ return Object.values(A(e) ?? {}).filter(
731
+ (t) => ["string", "number", "boolean"].includes(typeof t) && String(t).length <= 80
732
+ ).slice(0, 3).map(String).join(" · ");
733
+ }
734
+ function ee(e, t) {
735
+ const i = t === "memory" ? "memories" : `${t}s`;
736
+ return Array.isArray(e) ? `${e.length} ${e.length === 1 ? t : i}` : void 0;
737
+ }
738
+ function T(e) {
739
+ return typeof e == "string" ? e : "";
740
+ }
741
+ function on(e, t, i) {
742
+ var p, h;
743
+ const a = e.startsWith("transfer_to_") ? e.slice(12) : "", s = Object.hasOwn(Je, e) ? Je[e] : void 0, r = A(t.value) ?? {}, o = a ? "Transfer to agent" : e === "mcp_call" && T(r.tool) ? T(r.tool) : (s == null ? void 0 : s.title) ?? e, l = a ? "agent" : (s == null ? void 0 : s.family) ?? "other";
744
+ let c = "";
745
+ switch (e) {
746
+ case "memory_search":
747
+ case "web_search":
748
+ case "web_answer":
749
+ c = T(r.query);
750
+ break;
751
+ case "memory_grep":
752
+ c = T(r.pattern);
753
+ break;
754
+ case "memory_load":
755
+ case "memory_forget":
756
+ c = [ee(r.ids, "memory"), T(r.reason)].filter(Boolean).join(" - ");
757
+ break;
758
+ case "memory_commit":
759
+ c = [ee(r.nodes, "node"), ee(r.edges, "link")].filter(Boolean).join(" - ");
760
+ break;
761
+ case "run_command":
762
+ case "run_command_background":
763
+ c = T(r.command);
764
+ break;
765
+ case "read_command_output":
766
+ case "stop_command":
767
+ c = T(r.job_id), typeof r.start_line == "number" && (c += ` from line ${r.start_line}`);
768
+ break;
769
+ case "read_file":
770
+ c = T(r.path), typeof r.start_line == "number" ? (c += `:${r.start_line}`, typeof r.end_line == "number" && (c += `-${r.end_line}`)) : typeof r.end_line == "number" && (c += `:1-${r.end_line}`);
771
+ break;
772
+ case "write_file":
773
+ case "delete_file":
774
+ c = T(r.path);
775
+ break;
776
+ case "list_dir":
777
+ c = T(r.path) || (t.incomplete ? "" : "/");
778
+ break;
779
+ case "find_files":
780
+ c = [T(r.pattern), T(r.path)].filter(Boolean).join(" in ");
781
+ break;
782
+ case "move_file":
783
+ case "copy_file":
784
+ c = [T(r.from), T(r.to)].filter(Boolean).join(" -> ");
785
+ break;
786
+ case "apply_patch": {
787
+ const u = [
788
+ ...T(r.patch).matchAll(/^\*\*\* (?:Update|Add|Delete) File: (.+)$/gm)
789
+ ].map((f) => f[1]);
790
+ c = u.length ? `${u[0]}${u.length > 1 ? ` +${ee(u.slice(1), "file")}` : ""}` : "";
791
+ break;
792
+ }
793
+ case "web_read": {
794
+ const u = Array.isArray(r.urls) ? r.urls : [];
795
+ c = T(u[0]), u.length > 1 && (c += ` +${u.length - 1} URLs`);
796
+ break;
797
+ }
798
+ case "mcp_servers": {
799
+ const u = (p = A(i == null ? void 0 : i.value)) == null ? void 0 : p.servers;
800
+ c = ee(u, "service") ?? "";
801
+ break;
802
+ }
803
+ case "mcp_tools": {
804
+ const u = (h = A(i == null ? void 0 : i.value)) == null ? void 0 : h.tools;
805
+ c = [ne(T(r.server)), ee(u, "tool")].filter(Boolean).join(" · ");
806
+ break;
807
+ }
808
+ case "mcp_describe":
809
+ c = [ne(T(r.server)), T(r.tool)].filter(Boolean).join(" · ");
810
+ break;
811
+ case "mcp_call":
812
+ c = [ne(T(r.server)), sn(r.arguments)].filter(Boolean).join(" · ");
813
+ break;
814
+ default:
815
+ c = a ? [a, T(r.reason)].filter(Boolean).join(" - ") : T(r.reason) || T(Object.values(r).find((u) => typeof u == "string"));
816
+ }
817
+ return !c && typeof t.value == "string" && (c = t.value), !c && l === "other" && Object.keys(r).length && (c = ee(Object.keys(r), "argument") ?? ""), { title: o, family: l, preview: c.replace(/\s+/g, " ").trim() };
818
+ }
819
+ function ln(e, t, i) {
820
+ if (!e)
821
+ return i ? { label: "Running", tone: "muted", pending: !0 } : { label: "No result", tone: "muted" };
822
+ const a = A(e.value);
823
+ return t || a != null && a.error || (a == null ? void 0 : a.isError) === !0 || (a == null ? void 0 : a.stopped) === !1 ? { label: "Failed", tone: "danger" } : (a == null ? void 0 : a.auth_required) === !0 ? { label: "Needs connection", tone: "warning" } : (a == null ? void 0 : a.timed_out) === !0 ? { label: "Timed out", tone: "danger" } : typeof (a == null ? void 0 : a.exit_code) == "number" && a.exit_code !== 0 ? { label: `Exit ${a.exit_code}`, tone: "danger" } : e.omitted !== void 0 ? { label: "Truncated", tone: "warning" } : e.incomplete ? { label: "Invalid JSON", tone: "warning" } : a != null && a.truncated ? { label: "Truncated", tone: "warning" } : Array.isArray(a == null ? void 0 : a.failed) && a.failed.length ? { label: "Partial failure", tone: "warning" } : (a == null ? void 0 : a.running) === !0 ? { label: "Job running", tone: "muted" } : (a == null ? void 0 : a.started) === !0 ? { label: "Started", tone: "success" } : typeof (a == null ? void 0 : a.exit_code) == "number" ? { label: `Exit ${a.exit_code}`, tone: "success" } : { label: "Done", tone: "success" };
824
+ }
825
+ function Ne(e, t) {
826
+ return Object.fromEntries(Object.entries(e).filter(([i]) => t.includes(i)));
827
+ }
828
+ function te(e) {
829
+ if (!Array.isArray(e)) return;
830
+ const t = e.map(A);
831
+ return t.every((i) => i !== void 0) ? t : void 0;
832
+ }
833
+ function cn({ value: e }) {
834
+ return /* @__PURE__ */ n("div", { className: "space-y-4", children: e.map((t, i) => /* @__PURE__ */ d("article", { className: "min-w-0 space-y-2 [overflow-wrap:anywhere]", children: [
835
+ typeof t.url == "string" ? /* @__PURE__ */ n(me, { url: t.url, children: typeof t.title == "string" ? t.title : t.url }) : t.title !== void 0 ? /* @__PURE__ */ n(I, { value: t.title }) : null,
836
+ t.error !== void 0 && /* @__PURE__ */ n("div", { className: "text-danger", children: /* @__PURE__ */ n(I, { value: t.error }) }),
837
+ typeof t.text == "string" && /* @__PURE__ */ n("div", { className: "whitespace-pre-wrap", children: t.text }),
838
+ typeof t.excerpt == "string" && /* @__PURE__ */ n("p", { className: "whitespace-pre-wrap", children: t.excerpt }),
839
+ t.truncated === !0 && /* @__PURE__ */ n("p", { className: "text-warning", children: "Page content is truncated." }),
840
+ /* @__PURE__ */ n(be, { value: Ne(t, ["author", "published_date", "status"]) }),
841
+ /* @__PURE__ */ n(
842
+ K,
843
+ {
844
+ value: t,
845
+ omit: [
846
+ "error",
847
+ "author",
848
+ "published_date",
849
+ "status",
850
+ ...typeof t.url == "string" ? ["url", ...typeof t.title == "string" ? ["title"] : []] : ["title"],
851
+ ...typeof t.text == "string" ? ["text"] : [],
852
+ ...typeof t.excerpt == "string" ? ["excerpt"] : [],
853
+ ...typeof t.truncated == "boolean" ? ["truncated"] : []
854
+ ]
855
+ }
856
+ )
857
+ ] }, i)) });
858
+ }
859
+ function xt({
860
+ name: e,
861
+ input: t,
862
+ value: i,
863
+ args: a,
864
+ partial: s
865
+ }) {
866
+ var h;
867
+ const r = A(i);
868
+ if (!r) return /* @__PURE__ */ n(I, { value: i });
869
+ const o = A(a), l = (u, f, m = []) => /* @__PURE__ */ d("div", { className: "min-w-0 space-y-2 [overflow-wrap:anywhere]", children: [
870
+ r.error !== void 0 && /* @__PURE__ */ n("div", { className: "text-danger", children: /* @__PURE__ */ n(I, { value: r.error }) }),
871
+ r.hint !== void 0 && /* @__PURE__ */ n("div", { className: "text-muted-foreground", children: /* @__PURE__ */ n(I, { value: r.hint }) }),
872
+ u,
873
+ !t && (r.truncated === !0 || typeof r.truncated == "number" && r.truncated > 0) && /* @__PURE__ */ n("p", { className: "text-warning", children: e === "list_dir" && typeof r.truncated == "number" ? `${r.truncated} total entries; this listing is limited.` : "Only part of the available output is included." }),
874
+ r.out_of_memory !== void 0 && /* @__PURE__ */ d("div", { className: "text-danger", children: [
875
+ /* @__PURE__ */ n("p", { className: "mb-1", children: "Out of memory" }),
876
+ /* @__PURE__ */ n(I, { value: r.out_of_memory })
877
+ ] }),
878
+ /* @__PURE__ */ n(be, { value: Ne(r, m) }),
879
+ /* @__PURE__ */ n(
880
+ K,
881
+ {
882
+ value: r,
883
+ omit: [
884
+ ...f,
885
+ ...m,
886
+ "error",
887
+ "hint",
888
+ "out_of_memory",
889
+ ...!t && (typeof r.truncated == "boolean" || typeof r.truncated == "number") ? ["truncated"] : []
890
+ ]
891
+ }
892
+ )
893
+ ] }), c = typeof r.path == "string" ? r.path : typeof (o == null ? void 0 : o.path) == "string" ? o.path : void 0, p = ["path", "start_line", "end_line", "lines", "bytes"];
894
+ switch (e) {
895
+ case "read_file":
896
+ case "write_file":
897
+ if (typeof r.content == "string")
898
+ return l(
899
+ /* @__PURE__ */ n(bt, { text: r.content, path: c }),
900
+ ["content"],
901
+ p
902
+ );
903
+ if (t && typeof r.path == "string")
904
+ return l(
905
+ /* @__PURE__ */ n("code", { className: "block break-all", children: r.path }),
906
+ ["path"],
907
+ ["start_line", "end_line"]
908
+ );
909
+ if (!t && e === "write_file" && r.written === !0)
910
+ return l(
911
+ /* @__PURE__ */ d("p", { children: [
912
+ "Wrote ",
913
+ /* @__PURE__ */ n("code", { className: "break-all", children: c })
914
+ ] }),
915
+ ["written", "path"],
916
+ ["lines", "bytes"]
917
+ );
918
+ break;
919
+ case "list_dir":
920
+ if (t)
921
+ return l(/* @__PURE__ */ n("code", { className: "block break-all", children: c ?? "/" }), ["path"]);
922
+ if ((h = te(r.entries)) != null && h.every((u) => typeof u.name == "string")) {
923
+ const u = te(r.entries) ?? [];
924
+ return l(
925
+ u.length ? /* @__PURE__ */ n("ul", { className: "space-y-1", children: u.map((f, m) => /* @__PURE__ */ d("li", { className: "min-w-0", children: [
926
+ /* @__PURE__ */ d("div", { className: "flex flex-wrap items-baseline gap-x-3 gap-y-1", children: [
927
+ /* @__PURE__ */ d("code", { className: "break-all", children: [
928
+ String(f.name),
929
+ f.kind === "dir" ? "/" : ""
930
+ ] }),
931
+ /* @__PURE__ */ n(
932
+ be,
933
+ {
934
+ value: Ne(f, [
935
+ "kind",
936
+ "format",
937
+ "bytes",
938
+ "lines"
939
+ ])
940
+ }
941
+ )
942
+ ] }),
943
+ /* @__PURE__ */ n(
944
+ K,
945
+ {
946
+ value: f,
947
+ omit: ["name", "kind", "format", "bytes", "lines"]
948
+ }
949
+ )
950
+ ] }, m)) }) : /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: "Directory is empty" }),
951
+ ["entries"],
952
+ ["path"]
953
+ );
954
+ }
955
+ break;
956
+ case "find_files":
957
+ if (t && typeof r.pattern == "string")
958
+ return l(
959
+ /* @__PURE__ */ n("code", { className: "block break-all", children: r.pattern }),
960
+ ["pattern"],
961
+ ["path"]
962
+ );
963
+ if (Array.isArray(r.matches) && r.matches.every((u) => typeof u == "string"))
964
+ return l(
965
+ r.matches.length ? /* @__PURE__ */ n("ul", { className: "space-y-1", children: r.matches.map((u, f) => /* @__PURE__ */ n("li", { children: /* @__PURE__ */ n("code", { className: "break-all", children: u }) }, f)) }) : /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: "No matching files" }),
966
+ ["matches"],
967
+ ["pattern"]
968
+ );
969
+ break;
970
+ case "apply_patch": {
971
+ if (t && typeof r.patch == "string")
972
+ return l(/* @__PURE__ */ n(Z, { code: r.patch, lang: "diff" }), ["patch"]);
973
+ const u = te(r.files);
974
+ if (!t && (u != null && u.every((f) => typeof f.path == "string")))
975
+ return l(
976
+ /* @__PURE__ */ d(_e, { children: [
977
+ /* @__PURE__ */ n("ul", { className: "space-y-1", children: u.map((f, m) => /* @__PURE__ */ d("li", { children: [
978
+ /* @__PURE__ */ d("div", { className: "flex flex-wrap gap-x-2", children: [
979
+ /* @__PURE__ */ n("code", { className: "break-all", children: String(f.path) }),
980
+ /* @__PURE__ */ n(be, { value: Ne(f, ["action", "to"]) })
981
+ ] }),
982
+ /* @__PURE__ */ n(K, { value: f, omit: ["path", "action", "to"] })
983
+ ] }, m)) }),
984
+ r.fuzzy !== void 0 && /* @__PURE__ */ d("p", { className: "text-warning", children: [
985
+ "Whitespace-tolerant matches: ",
986
+ String(r.fuzzy)
987
+ ] }),
988
+ r.ignoredHeadings !== void 0 && /* @__PURE__ */ d("p", { className: "text-warning", children: [
989
+ "Ignored patch headings: ",
990
+ String(r.ignoredHeadings)
991
+ ] })
992
+ ] }),
993
+ ["files", "fuzzy", "ignoredHeadings"],
994
+ ["applied"]
995
+ );
996
+ break;
997
+ }
998
+ case "move_file":
999
+ case "copy_file":
1000
+ if (typeof r.from == "string" && typeof r.to == "string")
1001
+ return l(
1002
+ /* @__PURE__ */ d("code", { className: "block break-all", children: [
1003
+ r.from,
1004
+ " ",
1005
+ "->",
1006
+ " ",
1007
+ r.to
1008
+ ] }),
1009
+ ["from", "to"],
1010
+ ["moved", "copied", "bytes", "directory", "overwrite", "recursive"]
1011
+ );
1012
+ break;
1013
+ case "delete_file":
1014
+ if (typeof r.path == "string")
1015
+ return l(
1016
+ /* @__PURE__ */ n("code", { className: "block break-all", children: r.path }),
1017
+ ["path"],
1018
+ ["deleted", "directory", "recursive"]
1019
+ );
1020
+ break;
1021
+ case "run_command":
1022
+ case "run_command_background":
1023
+ case "read_command_output":
1024
+ case "stop_command":
1025
+ if (t) {
1026
+ if (typeof r.command == "string")
1027
+ return l(
1028
+ /* @__PURE__ */ n(Z, { code: r.command, lang: "bash" }),
1029
+ ["command"],
1030
+ ["cwd", "timeout"]
1031
+ );
1032
+ if (typeof r.job_id == "string")
1033
+ return l(
1034
+ /* @__PURE__ */ n("code", { className: "break-all", children: r.job_id }),
1035
+ ["job_id"],
1036
+ ["start_line"]
1037
+ );
1038
+ } else {
1039
+ const u = ["stdout", "output", "stderr"].filter(
1040
+ (f) => typeof r[f] == "string"
1041
+ );
1042
+ if (u.length)
1043
+ return l(
1044
+ /* @__PURE__ */ d("div", { className: "space-y-2", children: [
1045
+ u.every((f) => r[f] === "") && /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: s ? "No output in the received prefix" : "No output" }),
1046
+ u.filter((f) => r[f] !== "").map((f) => /* @__PURE__ */ d(
1047
+ "div",
1048
+ {
1049
+ className: f === "stderr" ? "text-danger" : void 0,
1050
+ children: [
1051
+ f === "stderr" && /* @__PURE__ */ n("p", { className: "mb-1 text-[11px]", children: "Standard error" }),
1052
+ /* @__PURE__ */ n(Z, { code: String(r[f]) })
1053
+ ]
1054
+ },
1055
+ f
1056
+ ))
1057
+ ] }),
1058
+ u,
1059
+ [
1060
+ "exit_code",
1061
+ "duration_ms",
1062
+ "job_id",
1063
+ "command",
1064
+ "running",
1065
+ "start_line",
1066
+ "end_line",
1067
+ "lines",
1068
+ "timed_out"
1069
+ ]
1070
+ );
1071
+ if (typeof r.job_id == "string")
1072
+ return l(
1073
+ /* @__PURE__ */ n("code", { className: "break-all", children: r.job_id }),
1074
+ ["job_id"],
1075
+ ["started", "stopped"]
1076
+ );
1077
+ }
1078
+ break;
1079
+ case "web_search":
1080
+ case "web_read":
1081
+ case "web_answer":
1082
+ if (t) {
1083
+ if (typeof r.query == "string")
1084
+ return l(/* @__PURE__ */ n("p", { className: "whitespace-pre-wrap", children: r.query }), ["query"]);
1085
+ if (Array.isArray(r.urls) && r.urls.every((u) => typeof u == "string"))
1086
+ return l(
1087
+ /* @__PURE__ */ n("ul", { className: "space-y-1", children: r.urls.map((u, f) => /* @__PURE__ */ n("li", { children: /* @__PURE__ */ n(me, { url: u }) }, f)) }),
1088
+ ["urls"]
1089
+ );
1090
+ } else {
1091
+ const f = ["results", "pages", "sources", "failed"].filter((m) => te(r[m]) !== void 0);
1092
+ if (f.length || typeof r.answer == "string")
1093
+ return l(
1094
+ /* @__PURE__ */ d("div", { className: "space-y-4", children: [
1095
+ typeof r.answer == "string" && /* @__PURE__ */ n(ie, { className: "text-xs", children: r.answer }),
1096
+ f.map((m) => {
1097
+ var x, v;
1098
+ return /* @__PURE__ */ d("div", { children: [
1099
+ m === "failed" && (((x = te(r[m])) == null ? void 0 : x.length) ?? 0) > 0 && /* @__PURE__ */ n("p", { className: "mb-2 text-danger", children: "Some pages could not be fetched." }),
1100
+ m !== "failed" && ((v = te(r[m])) == null ? void 0 : v.length) === 0 && /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: "No sources returned" }),
1101
+ /* @__PURE__ */ n(cn, { value: te(r[m]) ?? [] })
1102
+ ] }, m);
1103
+ }),
1104
+ Array.isArray(r.skipped) && r.skipped.length > 0 && /* @__PURE__ */ d("div", { className: "text-warning", children: [
1105
+ /* @__PURE__ */ n("p", { className: "mb-1", children: "Some URLs were skipped." }),
1106
+ /* @__PURE__ */ n(I, { value: r.skipped, field: "urls" })
1107
+ ] })
1108
+ ] }),
1109
+ [
1110
+ ...f,
1111
+ ...typeof r.answer == "string" ? ["answer"] : [],
1112
+ ...Array.isArray(r.skipped) ? ["skipped"] : []
1113
+ ],
1114
+ ["query", "found", "cost_usd"]
1115
+ );
1116
+ }
1117
+ break;
1118
+ case "compact":
1119
+ if (t && typeof r.reason == "string")
1120
+ return l(
1121
+ /* @__PURE__ */ n("p", { className: "whitespace-pre-wrap", children: r.reason }),
1122
+ ["reason"],
1123
+ ["nodes"]
1124
+ );
1125
+ break;
1126
+ default:
1127
+ if (t && e.startsWith("transfer_to_"))
1128
+ return l(
1129
+ r.reason !== void 0 ? /* @__PURE__ */ n(I, { value: r.reason }) : /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: "No additional arguments" }),
1130
+ ["reason"]
1131
+ );
1132
+ }
1133
+ return r.error !== void 0 ? l(null, []) : /* @__PURE__ */ n(I, { value: i });
1134
+ }
1135
+ const yt = Ae.forwardRef(({ className: e, ...t }, i) => /* @__PURE__ */ n(
1136
+ "input",
1137
+ {
1138
+ ref: i,
1139
+ className: k(
1140
+ "h-9 w-full rounded-md border border-input bg-surface-input px-3 text-sm outline-none placeholder:text-muted-foreground focus-visible:border-ring disabled:opacity-50",
1141
+ e
1142
+ ),
1143
+ ...t
1144
+ }
1145
+ ));
1146
+ yt.displayName = "Input";
1147
+ function Le(e) {
1148
+ if (!Array.isArray(e)) return;
1149
+ const t = e.map(A);
1150
+ return t.every((i) => i !== void 0) ? t : void 0;
1151
+ }
1152
+ const _ = (e) => typeof e == "string" ? e : void 0;
1153
+ function V({ children: e }) {
1154
+ return /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: e });
1155
+ }
1156
+ function dn({ tools: e }) {
1157
+ const [t, i] = O(""), a = t.trim().toLowerCase(), s = a ? e.filter(
1158
+ (r) => `${_(r.name) ?? ""} ${_(r.description) ?? ""}`.toLowerCase().includes(a)
1159
+ ) : e;
1160
+ return e.length ? /* @__PURE__ */ d("div", { className: "space-y-2", children: [
1161
+ e.length > 12 && /* @__PURE__ */ n(
1162
+ yt,
1163
+ {
1164
+ className: "h-7 text-xs",
1165
+ placeholder: `Filter ${e.length} tools`,
1166
+ "aria-label": "Filter tools",
1167
+ value: t,
1168
+ onChange: (r) => i(r.target.value)
1169
+ }
1170
+ ),
1171
+ /* @__PURE__ */ n("ul", { className: "space-y-1.5", children: s.map((r, o) => /* @__PURE__ */ d("li", { className: "min-w-0", children: [
1172
+ /* @__PURE__ */ n("code", { className: "break-all text-foreground", children: _(r.name) ?? "?" }),
1173
+ _(r.description) && /* @__PURE__ */ n(
1174
+ "p",
1175
+ {
1176
+ className: "line-clamp-2 text-muted-foreground",
1177
+ title: _(r.description),
1178
+ children: _(r.description)
1179
+ }
1180
+ )
1181
+ ] }, o)) }),
1182
+ a && !s.length && /* @__PURE__ */ n(V, { children: "No matching tools" })
1183
+ ] }) : /* @__PURE__ */ n(V, { children: "No tools" });
1184
+ }
1185
+ function un({ schema: e }) {
1186
+ const t = A(e), i = Object.entries(A(t == null ? void 0 : t.properties) ?? {}), a = Array.isArray(t == null ? void 0 : t.required) ? t.required : [];
1187
+ return i.length ? /* @__PURE__ */ n("ul", { className: "space-y-1.5", children: i.map(([s, r]) => {
1188
+ var c;
1189
+ const o = A(r) ?? {}, l = Array.isArray(o.enum) ? o.enum.map(String).join(" | ") : o.type === "array" ? `${_((c = A(o.items)) == null ? void 0 : c.type) ?? "any"}[]` : Array.isArray(o.type) ? o.type.join(" | ") : _(o.type) ?? "";
1190
+ return /* @__PURE__ */ d("li", { className: "min-w-0", children: [
1191
+ /* @__PURE__ */ d("div", { className: "flex flex-wrap items-baseline gap-x-2", children: [
1192
+ /* @__PURE__ */ n("code", { className: "break-all text-foreground", children: s }),
1193
+ l && /* @__PURE__ */ n("span", { className: "text-muted-foreground", children: l }),
1194
+ a.includes(s) && /* @__PURE__ */ n("span", { className: "text-[11px] text-warning", children: "required" })
1195
+ ] }),
1196
+ _(o.description) && /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: _(o.description) })
1197
+ ] }, s);
1198
+ }) }) : /* @__PURE__ */ n(V, { children: "Takes no arguments" });
1199
+ }
1200
+ function mn(e) {
1201
+ if (/^\s*[{[]/.test(e))
1202
+ try {
1203
+ return { value: JSON.parse(e) };
1204
+ } catch {
1205
+ return;
1206
+ }
1207
+ }
1208
+ function vt({ part: e }) {
1209
+ switch (e.type) {
1210
+ case "text": {
1211
+ const t = _(e.text) ?? "", i = mn(t);
1212
+ return i ? /* @__PURE__ */ n(I, { value: i.value }) : t ? /* @__PURE__ */ n(ie, { className: "text-xs [overflow-wrap:anywhere]", children: t }) : /* @__PURE__ */ n(V, { children: "(empty)" });
1213
+ }
1214
+ case "image": {
1215
+ const t = _(e.mimeType) ?? "", i = _(e.data);
1216
+ return /^image\/[\w.+-]+$/.test(t) && i ? /* @__PURE__ */ n(
1217
+ "img",
1218
+ {
1219
+ className: "max-h-64 max-w-full rounded border border-border",
1220
+ src: `data:${t};base64,${i}`,
1221
+ alt: ""
1222
+ }
1223
+ ) : /* @__PURE__ */ n(V, { children: `Image (${t || "unknown type"})` });
1224
+ }
1225
+ case "resource_link": {
1226
+ const t = _(e.uri);
1227
+ return t ? /* @__PURE__ */ n(me, { url: t, children: _(e.name) ?? _(e.title) ?? t }) : null;
1228
+ }
1229
+ case "resource": {
1230
+ const t = A(e.resource) ?? {}, i = _(t.uri);
1231
+ return /* @__PURE__ */ d("div", { className: "space-y-1", children: [
1232
+ i && /* @__PURE__ */ n(me, { url: i }),
1233
+ _(t.text) !== void 0 && /* @__PURE__ */ n(vt, { part: { type: "text", text: t.text } })
1234
+ ] });
1235
+ }
1236
+ default:
1237
+ return /* @__PURE__ */ n(I, { value: e });
1238
+ }
1239
+ }
1240
+ function fn({ object: e }) {
1241
+ if (e.auth_required === !0) {
1242
+ const s = _(e.connect_url);
1243
+ return /* @__PURE__ */ d("div", { className: "space-y-1 text-warning", children: [
1244
+ /* @__PURE__ */ n("p", { children: _(e.message) ?? "This service needs a connected account." }),
1245
+ s && /* @__PURE__ */ d(me, { url: s, children: [
1246
+ "Connect ",
1247
+ ne(_(e.server) ?? "")
1248
+ ] })
1249
+ ] });
1250
+ }
1251
+ const t = Le(e.content) ?? [], i = e.structuredContent, a = i !== void 0 ? t.filter((s) => s.type !== "text") : t;
1252
+ return /* @__PURE__ */ d("div", { className: "min-w-0 space-y-2 [overflow-wrap:anywhere]", children: [
1253
+ e.isError === !0 && /* @__PURE__ */ n("p", { className: "text-danger", children: "The service returned an error." }),
1254
+ /* @__PURE__ */ d("div", { className: k("space-y-2", e.isError === !0 && "text-danger"), children: [
1255
+ i !== void 0 && /* @__PURE__ */ n(I, { value: i }),
1256
+ a.map((s, r) => /* @__PURE__ */ n(vt, { part: s }, r)),
1257
+ i === void 0 && !t.length && /* @__PURE__ */ n(V, { children: "No content" })
1258
+ ] }),
1259
+ e.truncated === !0 && /* @__PURE__ */ n("p", { className: "text-warning", children: _(e.note) ?? "Only part of the result is included." })
1260
+ ] });
1261
+ }
1262
+ function pn({
1263
+ name: e,
1264
+ input: t,
1265
+ value: i,
1266
+ args: a,
1267
+ partial: s
1268
+ }) {
1269
+ const r = A(i), o = /* @__PURE__ */ n(xt, { name: e, input: t, value: i, args: a, partial: s });
1270
+ if (!r || r.error !== void 0) return o;
1271
+ if (t) {
1272
+ const l = _(r.server);
1273
+ switch (e) {
1274
+ case "mcp_servers":
1275
+ return Object.keys(r).length ? o : /* @__PURE__ */ n(V, { children: "No arguments" });
1276
+ case "mcp_tools":
1277
+ case "mcp_describe":
1278
+ if (!l) break;
1279
+ return /* @__PURE__ */ d("p", { children: [
1280
+ ne(l),
1281
+ _(r.tool) && /* @__PURE__ */ d(_e, { children: [
1282
+ " · ",
1283
+ /* @__PURE__ */ n("code", { className: "break-all", children: _(r.tool) })
1284
+ ] })
1285
+ ] });
1286
+ case "mcp_call": {
1287
+ if (!l) break;
1288
+ const c = A(r.arguments);
1289
+ return /* @__PURE__ */ d("div", { className: "space-y-2", children: [
1290
+ c && Object.keys(c).length ? /* @__PURE__ */ n(I, { value: c }) : r.arguments === void 0 || c ? /* @__PURE__ */ n(V, { children: "No arguments" }) : /* @__PURE__ */ n(I, { value: r.arguments }),
1291
+ /* @__PURE__ */ n(
1292
+ be,
1293
+ {
1294
+ value: {
1295
+ service: ne(l),
1296
+ ..._(r.tool) ? { tool: r.tool } : {}
1297
+ }
1298
+ }
1299
+ )
1300
+ ] });
1301
+ }
1302
+ }
1303
+ return o;
1304
+ }
1305
+ switch (e) {
1306
+ case "mcp_servers": {
1307
+ const l = Le(r.servers);
1308
+ if (!l) break;
1309
+ return l.length ? /* @__PURE__ */ n("ul", { className: "space-y-1", children: l.map((c, p) => /* @__PURE__ */ d("li", { className: "flex flex-wrap items-baseline gap-x-2", children: [
1310
+ /* @__PURE__ */ n("span", { className: "text-foreground", title: _(c.server), children: ne(_(c.server) ?? "?") }),
1311
+ typeof c.tools == "number" && /* @__PURE__ */ d("span", { className: "text-muted-foreground", children: [
1312
+ c.tools,
1313
+ " ",
1314
+ c.tools === 1 ? "tool" : "tools"
1315
+ ] })
1316
+ ] }, p)) }) : /* @__PURE__ */ n(V, { children: "No services are enabled for this chat" });
1317
+ }
1318
+ case "mcp_tools": {
1319
+ const l = Le(r.tools);
1320
+ if (!l) break;
1321
+ return /* @__PURE__ */ n(dn, { tools: l });
1322
+ }
1323
+ case "mcp_describe":
1324
+ if (r.inputSchema === void 0 && _(r.description) === void 0) break;
1325
+ return /* @__PURE__ */ d("div", { className: "min-w-0 space-y-3 [overflow-wrap:anywhere]", children: [
1326
+ _(r.description) && /* @__PURE__ */ n(ie, { className: "text-xs", children: _(r.description) ?? "" }),
1327
+ /* @__PURE__ */ d("div", { children: [
1328
+ /* @__PURE__ */ n("p", { className: "mb-1 text-[11px] font-semibold text-muted-foreground", children: "Parameters" }),
1329
+ /* @__PURE__ */ n(un, { schema: r.inputSchema })
1330
+ ] })
1331
+ ] });
1332
+ case "mcp_call":
1333
+ if (r.auth_required !== !0 && r.content === void 0 && r.structuredContent === void 0)
1334
+ break;
1335
+ return /* @__PURE__ */ n(fn, { object: r });
1336
+ }
1337
+ return o;
1338
+ }
1339
+ function hn(e) {
1340
+ const t = [], i = [];
1341
+ for (const a of e.split(/\r?\n/)) {
1342
+ const s = a.trim();
1343
+ if (!s || /^<\/?memory-recollection>$/.test(a)) continue;
1344
+ const r = /^( *)(?:(\d+\.\d+|--) {2,}|([\u2190\u2192][\w-]+) {2,}(?:(\d+\.\d+) {2,})?)([A-Za-z0-9_ -]+?) {2,}(\S+)\s*$/.exec(
1345
+ a
1346
+ );
1347
+ if (r && (r[3] || r[1].length <= 2))
1348
+ t.push({
1349
+ id: r[6],
1350
+ kind: r[5],
1351
+ depth: r[3] ? Math.floor(r[1].length / 2) : 0,
1352
+ score: r[2] === "--" ? void 0 : r[2] ?? r[4],
1353
+ relation: r[3],
1354
+ lines: []
1355
+ });
1356
+ else if (s.startsWith("(more memory matched than fits;") || /^\u2026 \d+ more characters$/.test(s))
1357
+ i.push(s);
1358
+ else if (t.length && /^ {6,}\S/.test(a))
1359
+ t[t.length - 1].lines.push(s);
1360
+ else
1361
+ return;
1362
+ }
1363
+ return t.length ? { entries: t, notes: i } : void 0;
1364
+ }
1365
+ function wt({ node: e }) {
1366
+ return /* @__PURE__ */ d("div", { className: "flex flex-wrap items-baseline gap-x-2 gap-y-1 text-[11px] text-muted-foreground", children: [
1367
+ typeof e.kind == "string" && /* @__PURE__ */ n("span", { className: "font-medium capitalize", children: e.kind }),
1368
+ e.stale === !0 && /* @__PURE__ */ n("span", { className: "text-warning", children: "Superseded" }),
1369
+ typeof e.id == "string" && /* @__PURE__ */ n("code", { className: "break-all", children: e.id }),
1370
+ typeof e.ref == "string" && /* @__PURE__ */ d("code", { className: "break-all", children: [
1371
+ "Ref: ",
1372
+ e.ref
1373
+ ] })
1374
+ ] });
1375
+ }
1376
+ function Xe({
1377
+ nodes: e,
1378
+ renderValue: t
1379
+ }) {
1380
+ return e.length ? /* @__PURE__ */ n("div", { className: "space-y-4", children: e.map((i, a) => {
1381
+ const s = A(i.file), r = typeof i.file == "string" ? i.file : s == null ? void 0 : s.path;
1382
+ return /* @__PURE__ */ d("article", { className: "min-w-0 space-y-2 [overflow-wrap:anywhere]", children: [
1383
+ /* @__PURE__ */ n(wt, { node: i }),
1384
+ typeof i.text == "string" && /* @__PURE__ */ n(ie, { className: "text-xs", children: i.text }),
1385
+ typeof r == "string" && /* @__PURE__ */ d("div", { className: "text-[11px] text-muted-foreground", children: [
1386
+ /* @__PURE__ */ n("code", { className: "break-all", children: r }),
1387
+ typeof (s == null ? void 0 : s.bytes) == "number" && /* @__PURE__ */ d("span", { children: [
1388
+ " (",
1389
+ s.bytes.toLocaleString(),
1390
+ " bytes)"
1391
+ ] })
1392
+ ] }),
1393
+ typeof i.content == "string" && /* @__PURE__ */ n(
1394
+ bt,
1395
+ {
1396
+ text: i.content,
1397
+ path: typeof r == "string" ? r : void 0
1398
+ }
1399
+ ),
1400
+ /* @__PURE__ */ n(
1401
+ K,
1402
+ {
1403
+ value: i,
1404
+ omit: [
1405
+ "id",
1406
+ "ref",
1407
+ "kind",
1408
+ "text",
1409
+ "content",
1410
+ ...typeof i.file == "string" ? ["file"] : []
1411
+ ],
1412
+ renderValue: t
1413
+ }
1414
+ )
1415
+ ] }, a);
1416
+ }) }) : /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: "No memories" });
1417
+ }
1418
+ function Ze(e) {
1419
+ if (!Array.isArray(e)) return;
1420
+ const t = e.map(A);
1421
+ if (t.every(
1422
+ (i) => i !== void 0 && ["id", "ref", "kind", "text", "content"].every(
1423
+ (a) => i[a] === void 0 || typeof i[a] == "string"
1424
+ ) && ["id", "ref", "text", "file"].some((a) => i[a] !== void 0)
1425
+ ))
1426
+ return t;
1427
+ }
1428
+ function gn({ value: e, renderValue: t }) {
1429
+ const i = Array.isArray(e) ? e.map(A) : void 0;
1430
+ return !i || !i.every(
1431
+ (a) => a !== void 0 && typeof a.in == "string" && typeof a.line == "number" && typeof a.text == "string"
1432
+ ) ? /* @__PURE__ */ n(_e, { children: t({ hits: e }) }) : /* @__PURE__ */ n("div", { className: "space-y-2", children: i.map((a, s) => /* @__PURE__ */ d("div", { children: [
1433
+ /* @__PURE__ */ d("div", { className: "mb-1 text-[11px] text-muted-foreground", children: [
1434
+ String(a.in),
1435
+ ":",
1436
+ String(a.line)
1437
+ ] }),
1438
+ /* @__PURE__ */ n("pre", { className: "whitespace-pre-wrap break-words font-mono text-xs", children: String(a.text) }),
1439
+ /* @__PURE__ */ n(K, { value: a, omit: ["in", "line", "text"], renderValue: t })
1440
+ ] }, s)) });
1441
+ }
1442
+ function bn({
1443
+ name: e,
1444
+ input: t,
1445
+ value: i,
1446
+ text: a,
1447
+ renderValue: s
1448
+ }) {
1449
+ const r = A(i), o = typeof i == "string" ? i : a;
1450
+ if (!t && e === "memory_search" && (i === void 0 || typeof i == "string")) {
1451
+ const l = hn(o);
1452
+ return l ? /* @__PURE__ */ d("div", { className: "space-y-3", children: [
1453
+ l.entries.map((c, p) => /* @__PURE__ */ d(
1454
+ "article",
1455
+ {
1456
+ className: "min-w-0 space-y-1 [overflow-wrap:anywhere]",
1457
+ style: { marginLeft: `${Math.min(c.depth, 6) * 0.75}rem` },
1458
+ children: [
1459
+ /* @__PURE__ */ d("div", { className: "flex flex-wrap items-baseline gap-x-2 gap-y-1 text-[11px] text-muted-foreground", children: [
1460
+ c.relation && /* @__PURE__ */ n("span", { children: c.relation }),
1461
+ /* @__PURE__ */ n("span", { className: "font-medium capitalize", children: c.kind }),
1462
+ c.score && /* @__PURE__ */ d("span", { children: [
1463
+ "Score ",
1464
+ c.score
1465
+ ] }),
1466
+ /* @__PURE__ */ n("code", { className: "break-all", children: c.id })
1467
+ ] }),
1468
+ c.lines.map((h, u) => /* @__PURE__ */ n(
1469
+ "div",
1470
+ {
1471
+ className: h.startsWith("/memory/") || h.startsWith("+ ") ? "whitespace-pre-wrap font-mono text-[11px] text-muted-foreground" : "whitespace-pre-wrap",
1472
+ children: h
1473
+ },
1474
+ u
1475
+ ))
1476
+ ]
1477
+ },
1478
+ p
1479
+ )),
1480
+ l.notes.map((c, p) => /* @__PURE__ */ n("p", { className: "text-warning", children: c }, p))
1481
+ ] }) : /* @__PURE__ */ n("div", { className: "whitespace-pre-wrap [overflow-wrap:anywhere]", children: o || "(empty)" });
1482
+ }
1483
+ if (!t && e === "memory_load") {
1484
+ const l = Ze(i);
1485
+ if (l) return /* @__PURE__ */ n(Xe, { nodes: l, renderValue: s });
1486
+ }
1487
+ if (t && e === "memory_commit" && r) {
1488
+ const l = Ze(r.nodes);
1489
+ if (l)
1490
+ return /* @__PURE__ */ d("div", { children: [
1491
+ /* @__PURE__ */ n(Xe, { nodes: l, renderValue: s }),
1492
+ r.edges !== void 0 && /* @__PURE__ */ n("div", { className: "mt-3", children: s({ links: r.edges }) }),
1493
+ /* @__PURE__ */ n(K, { value: r, omit: ["nodes", "edges"], renderValue: s })
1494
+ ] });
1495
+ }
1496
+ if (t && r && (e === "memory_load" || e === "memory_forget") && Array.isArray(r.ids) && r.ids.every((l) => typeof l == "string"))
1497
+ return /* @__PURE__ */ d("div", { children: [
1498
+ /* @__PURE__ */ n("div", { className: "flex flex-wrap gap-x-3 gap-y-1 font-mono text-[11px]", children: r.ids.map((l, c) => /* @__PURE__ */ n("code", { className: "break-all", children: l }, c)) }),
1499
+ r.reason !== void 0 && /* @__PURE__ */ n("div", { className: "mt-2", children: s({ reason: r.reason }) }),
1500
+ /* @__PURE__ */ n(K, { value: r, omit: ["ids", "reason"], renderValue: s })
1501
+ ] });
1502
+ if (!t && e === "memory_grep" && r && Array.isArray(r.matches)) {
1503
+ const l = r.matches.map(A);
1504
+ if (l.every(
1505
+ (c) => c !== void 0 && typeof c.id == "string" && Array.isArray(c.hits)
1506
+ ))
1507
+ return /* @__PURE__ */ d("div", { className: "space-y-3", children: [
1508
+ typeof r.found == "number" && /* @__PURE__ */ d("p", { className: "text-muted-foreground", children: [
1509
+ r.found,
1510
+ " ",
1511
+ r.found === 1 ? "match" : "matches"
1512
+ ] }),
1513
+ r.truncated === !0 && /* @__PURE__ */ n("p", { className: "text-warning", children: "More matches are available." }),
1514
+ l.map((c, p) => /* @__PURE__ */ d("article", { className: "min-w-0 space-y-2 [overflow-wrap:anywhere]", children: [
1515
+ /* @__PURE__ */ n(wt, { node: c }),
1516
+ typeof c.file == "string" && /* @__PURE__ */ n("code", { className: "block break-all text-[11px] text-muted-foreground", children: c.file }),
1517
+ /* @__PURE__ */ n(gn, { value: c.hits, renderValue: s }),
1518
+ typeof c.more == "number" && c.more > 0 && /* @__PURE__ */ d("p", { className: "text-warning", children: [
1519
+ c.more,
1520
+ " additional hits"
1521
+ ] }),
1522
+ /* @__PURE__ */ n(
1523
+ K,
1524
+ {
1525
+ value: c,
1526
+ omit: [
1527
+ "id",
1528
+ "hits",
1529
+ ...typeof c.kind == "string" ? ["kind"] : [],
1530
+ ...typeof c.stale == "boolean" ? ["stale"] : [],
1531
+ ...typeof c.file == "string" ? ["file"] : [],
1532
+ ...typeof c.more == "number" ? ["more"] : []
1533
+ ],
1534
+ renderValue: s
1535
+ }
1536
+ )
1537
+ ] }, p)),
1538
+ r.unsearched !== void 0 && /* @__PURE__ */ d("div", { className: "text-warning", children: [
1539
+ /* @__PURE__ */ n("p", { className: "mb-1", children: "Some memories were not searched." }),
1540
+ s({ unsearched: r.unsearched })
1541
+ ] }),
1542
+ /* @__PURE__ */ n(
1543
+ K,
1544
+ {
1545
+ value: r,
1546
+ omit: [
1547
+ "matches",
1548
+ "unsearched",
1549
+ ...typeof r.found == "number" ? ["found"] : [],
1550
+ ...typeof r.truncated == "boolean" ? ["truncated"] : []
1551
+ ],
1552
+ renderValue: s
1553
+ }
1554
+ )
1555
+ ] });
1556
+ }
1557
+ return !t && e === "memory_commit" && r && typeof r.summary == "string" ? /* @__PURE__ */ d("div", { className: "space-y-2", children: [
1558
+ /* @__PURE__ */ n("p", { children: r.summary.replace(/^memory_commit /, "Remembered ") }),
1559
+ r.ids !== void 0 && s({ "Memory IDs": r.ids }),
1560
+ /* @__PURE__ */ n(K, { value: r, omit: ["summary", "ids"], renderValue: s })
1561
+ ] }) : i !== void 0 ? s(i) : /* @__PURE__ */ n("div", { className: "whitespace-pre-wrap [overflow-wrap:anywhere]", children: o || "(empty)" });
1562
+ }
1563
+ const xn = {
1564
+ memory: ot,
1565
+ file: Kt,
1566
+ command: Ut,
1567
+ web: Ft,
1568
+ agent: Bt,
1569
+ mcp: qt,
1570
+ other: Ht
1571
+ };
1572
+ function Nt({
1573
+ className: e,
1574
+ children: t
1575
+ }) {
1576
+ return /* @__PURE__ */ d("div", { className: k("relative ml-[7px] pl-2", e), children: [
1577
+ /* @__PURE__ */ n(
1578
+ "span",
1579
+ {
1580
+ "aria-hidden": !0,
1581
+ className: "absolute -top-1 left-0 h-4 w-3 rounded-bl-lg border-b border-l border-border"
1582
+ }
1583
+ ),
1584
+ t
1585
+ ] });
1586
+ }
1587
+ function Ge({
1588
+ payload: e,
1589
+ raw: t,
1590
+ markdown: i,
1591
+ receiving: a,
1592
+ tool: s
1593
+ }) {
1594
+ return /* @__PURE__ */ d(_e, { children: [
1595
+ e.omitted !== void 0 ? /* @__PURE__ */ d("p", { className: "mb-2 text-warning", children: [
1596
+ "Output truncated: ",
1597
+ e.omitted.toLocaleString(),
1598
+ " more characters were not sent.",
1599
+ e.incomplete && " Showing only the available prefix."
1600
+ ] }) : e.incomplete ? /* @__PURE__ */ n("p", { className: "mb-2 text-muted-foreground", children: a ? "Receiving arguments..." : "Incomplete or invalid JSON. Only the available content is shown." }) : null,
1601
+ t ? /* @__PURE__ */ n(
1602
+ Z,
1603
+ {
1604
+ code: e.raw || "(empty)",
1605
+ lang: e.incomplete ? void 0 : "json"
1606
+ }
1607
+ ) : (s == null ? void 0 : s.family) === "memory" && !e.incomplete ? /* @__PURE__ */ n(
1608
+ bn,
1609
+ {
1610
+ name: s.name,
1611
+ input: s.input,
1612
+ value: e.value,
1613
+ text: e.raw,
1614
+ renderValue: (r) => /* @__PURE__ */ n(I, { value: r })
1615
+ }
1616
+ ) : (s == null ? void 0 : s.family) === "mcp" && e.value !== void 0 ? /* @__PURE__ */ n(
1617
+ pn,
1618
+ {
1619
+ name: s.name,
1620
+ input: s.input,
1621
+ value: e.value,
1622
+ args: s.args,
1623
+ partial: e.incomplete || e.omitted !== void 0
1624
+ }
1625
+ ) : s && e.value !== void 0 ? /* @__PURE__ */ n(
1626
+ xt,
1627
+ {
1628
+ name: s.name,
1629
+ input: s.input,
1630
+ value: e.value,
1631
+ args: s.args,
1632
+ partial: e.incomplete || e.omitted !== void 0
1633
+ }
1634
+ ) : e.value !== void 0 ? /* @__PURE__ */ n(I, { value: e.value }) : e.incomplete ? /* @__PURE__ */ n(Z, { code: e.raw }) : i ? /* @__PURE__ */ n(ie, { children: e.raw }) : /* @__PURE__ */ n("div", { className: "whitespace-pre-wrap break-words [overflow-wrap:anywhere]", children: e.raw || "(empty)" })
1635
+ ] });
1636
+ }
1637
+ function yn({
1638
+ item: e,
1639
+ running: t
1640
+ }) {
1641
+ const [i, a] = O(!1), [s, r] = O(!1), o = de(() => Ke(e.args), [e.args]), l = de(
1642
+ () => e.result === void 0 ? void 0 : Ke(e.result),
1643
+ [e.result]
1644
+ ), { title: c, family: p, preview: h } = on(e.name, o, l), u = t && l === void 0 && (o.incomplete || !e.args.trim()), f = A(o.value), m = !u && !o.incomplete && (!e.args.trim() || f !== void 0 && !Object.keys(f).length), x = ln(l, e.isError, t), v = xn[p], g = e.interrupt && !e.interrupt.ended && l === void 0, y = /* @__PURE__ */ d(
1645
+ "details",
1646
+ {
1647
+ className: "group min-w-0 text-xs",
1648
+ onToggle: (C) => a(C.currentTarget.open),
1649
+ children: [
1650
+ /* @__PURE__ */ d("summary", { className: "group/row flex min-w-0 cursor-pointer list-none items-center gap-2 -mx-1.5 rounded-sm px-1.5 py-1.5 text-muted-foreground outline-none hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground [&::-webkit-details-marker]:hidden", children: [
1651
+ /* @__PURE__ */ n(v, { className: "size-3.5 shrink-0 text-muted-foreground" }),
1652
+ /* @__PURE__ */ n("span", { className: "max-w-[40%] shrink-0 truncate", title: e.name, children: c }),
1653
+ /* @__PURE__ */ n(
1654
+ "span",
1655
+ {
1656
+ className: k(
1657
+ "min-w-0 flex-1 truncate text-muted-foreground",
1658
+ (p === "command" || p === "file") && "font-mono"
1659
+ ),
1660
+ title: h,
1661
+ children: h || (u ? "Receiving arguments..." : "")
1662
+ }
1663
+ ),
1664
+ /* @__PURE__ */ d(
1665
+ "span",
1666
+ {
1667
+ className: k(
1668
+ "ml-auto flex shrink-0 items-center gap-1 text-[11px]",
1669
+ x.tone === "danger" ? "text-danger" : x.tone === "warning" ? "text-warning" : "text-muted-foreground"
1670
+ ),
1671
+ children: [
1672
+ g ? null : x.pending ? /* @__PURE__ */ n(ge, { className: "size-3 animate-spin" }) : x.tone === "success" ? /* @__PURE__ */ n(Te, { className: "size-3" }) : null,
1673
+ /* @__PURE__ */ n("span", { children: g ? "Paused" : x.label })
1674
+ ]
1675
+ }
1676
+ ),
1677
+ /* @__PURE__ */ n(lt, { className: "size-3.5 shrink-0 text-muted-foreground opacity-0 transition group-open:rotate-90 group-open:opacity-100 group-hover/row:opacity-100 group-focus-visible/row:opacity-100" })
1678
+ ] }),
1679
+ i && /* @__PURE__ */ d(Nt, { className: "my-1", children: [
1680
+ /* @__PURE__ */ d("div", { className: "flex items-center justify-between gap-2 py-1.5 pl-3 text-[11px] text-muted-foreground", children: [
1681
+ /* @__PURE__ */ n("span", { className: "min-w-0 truncate font-mono", children: e.name }),
1682
+ /* @__PURE__ */ n(
1683
+ "button",
1684
+ {
1685
+ type: "button",
1686
+ "aria-label": "Show raw arguments and result",
1687
+ "aria-pressed": s,
1688
+ className: k("shrink-0 cursor-pointer rounded-sm outline-none"),
1689
+ onClick: () => r(!s),
1690
+ children: "Raw"
1691
+ }
1692
+ )
1693
+ ] }),
1694
+ !m && /* @__PURE__ */ d("section", { className: "px-3 pb-3", "aria-label": "Arguments", children: [
1695
+ /* @__PURE__ */ n("h4", { className: "mb-2 text-[11px] font-semibold text-muted-foreground", children: "Arguments" }),
1696
+ /* @__PURE__ */ n("div", { className: "max-h-64 overflow-auto", children: /* @__PURE__ */ n(
1697
+ Ge,
1698
+ {
1699
+ payload: o,
1700
+ raw: s,
1701
+ receiving: t && l === void 0,
1702
+ tool: {
1703
+ name: e.name,
1704
+ family: p,
1705
+ input: !0,
1706
+ args: o.value
1707
+ }
1708
+ }
1709
+ ) })
1710
+ ] }),
1711
+ /* @__PURE__ */ d("section", { className: "px-3 pb-3", "aria-label": "Result", children: [
1712
+ /* @__PURE__ */ n("h4", { className: "mb-2 text-[11px] font-semibold text-muted-foreground", children: "Result" }),
1713
+ /* @__PURE__ */ n("div", { className: "max-h-80 overflow-auto", children: l ? /* @__PURE__ */ n(
1714
+ Ge,
1715
+ {
1716
+ payload: l,
1717
+ raw: s,
1718
+ markdown: e.name === "fork",
1719
+ tool: {
1720
+ name: e.name,
1721
+ family: p,
1722
+ input: !1,
1723
+ args: o.value
1724
+ }
1725
+ }
1726
+ ) : /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: t ? "Waiting for result..." : "No result was received." }) })
1727
+ ] })
1728
+ ] })
1729
+ ]
1730
+ }
1731
+ );
1732
+ return e.interrupt ? /* @__PURE__ */ d("div", { className: "min-w-0", children: [
1733
+ y,
1734
+ /* @__PURE__ */ n(tn, { interrupt: e.interrupt })
1735
+ ] }) : y;
1736
+ }
1737
+ function vn(e) {
1738
+ const t = /* @__PURE__ */ new Map();
1739
+ let i, a;
1740
+ for (const s of e)
1741
+ if (s.kind === "assistant") {
1742
+ if (s.subagent) {
1743
+ const r = [s.agent, s.branch].filter((o, l, c) => o && c.indexOf(o) === l).join(" · ");
1744
+ a !== s.subagent && t.set(s.id, r || "Subagent");
1745
+ } else s.agent && ((i && i !== s.agent || a && i) && t.set(s.id, s.agent), i = s.agent);
1746
+ a = s.subagent;
1747
+ }
1748
+ return t;
1749
+ }
1750
+ function Ye(e, t) {
1751
+ const i = (a) => a.kind === "tool" || a.kind === "reasoning";
1752
+ return t.kind === "user" ? "mt-6" : i(e) && i(t) ? "" : "mt-3";
1753
+ }
1754
+ const kt = (e) => e.kind === "tool" || e.kind === "reasoning";
1755
+ function wn(e) {
1756
+ let t = e.length;
1757
+ for (; t > 0 && e[t - 1].item.kind === "assistant"; ) t--;
1758
+ const i = e.slice(t), a = e.findIndex(({ item: o }) => o.kind !== "user"), s = a < 0 ? [] : e.slice(a, t);
1759
+ return s.some(({ item: o }) => kt(o)) && i.some(({ item: o }) => o.kind === "assistant" && o.text.trim() !== "") && !s.some(({ item: o }) => o.kind === "tool" && o.interrupt && !o.interrupt.ended) ? { before: e.slice(0, a), steps: s, answer: i } : { before: e, steps: [], answer: [] };
1760
+ }
1761
+ function Nn({
1762
+ count: e,
1763
+ className: t,
1764
+ children: i
1765
+ }) {
1766
+ const [a, s] = O(!1);
1767
+ return /* @__PURE__ */ d("div", { className: t, children: [
1768
+ /* @__PURE__ */ d(
1769
+ "button",
1770
+ {
1771
+ type: "button",
1772
+ "aria-expanded": a,
1773
+ onClick: () => s(!a),
1774
+ className: k(
1775
+ "-mx-1.5 flex cursor-pointer items-center gap-1.5 rounded-sm px-1.5 py-1.5 text-sm outline-none hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground",
1776
+ a ? "text-foreground" : "text-muted-foreground"
1777
+ ),
1778
+ children: [
1779
+ "Completed ",
1780
+ e,
1781
+ " ",
1782
+ e === 1 ? "step" : "steps",
1783
+ a ? /* @__PURE__ */ n(st, { className: "size-4" }) : /* @__PURE__ */ n(lt, { className: "size-4" })
1784
+ ]
1785
+ }
1786
+ ),
1787
+ a && /* @__PURE__ */ n("div", { className: "mb-1 ml-1.5 border-l border-border pl-3", children: i })
1788
+ ] });
1789
+ }
1790
+ function kn({ item: e, running: t, agent: i }) {
1791
+ switch (e.kind) {
1792
+ case "user":
1793
+ return /* @__PURE__ */ d(
1794
+ "div",
1795
+ {
1796
+ className: "group/msg relative ml-auto flex w-fit max-w-[80%] flex-col items-end",
1797
+ onCopy: He,
1798
+ children: [
1799
+ /* @__PURE__ */ n(Er, { className: "max-w-full rounded-xl bg-accent px-3 py-2 text-sm whitespace-pre-wrap [overflow-wrap:anywhere]", children: e.text }),
1800
+ e.text && /* @__PURE__ */ n(
1801
+ ze,
1802
+ {
1803
+ text: e.text,
1804
+ label: "Copy message",
1805
+ className: k("absolute bottom-1 right-full mr-1", qe)
1806
+ }
1807
+ )
1808
+ ]
1809
+ }
1810
+ );
1811
+ case "assistant":
1812
+ return /* @__PURE__ */ d("div", { className: "group/msg relative min-w-0", onCopy: He, children: [
1813
+ i && /* @__PURE__ */ n("div", { className: "mb-1 text-xs text-muted-foreground", children: i }),
1814
+ /* @__PURE__ */ n(ie, { className: "text-sm", children: e.text }),
1815
+ e.text && // Over the end of the last line, so it takes no height of its own.
1816
+ /* @__PURE__ */ n(
1817
+ ze,
1818
+ {
1819
+ text: e.text,
1820
+ label: "Copy message",
1821
+ className: k(
1822
+ "absolute bottom-0 right-0 bg-background",
1823
+ qe
1824
+ )
1825
+ }
1826
+ )
1827
+ ] });
1828
+ case "reasoning":
1829
+ return /* @__PURE__ */ d("details", { className: "group text-xs text-muted-foreground", children: [
1830
+ /* @__PURE__ */ d("summary", { className: "-mx-1.5 flex cursor-pointer list-none items-center gap-1.5 rounded-sm px-1.5 py-1.5 outline-none hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground [&::-webkit-details-marker]:hidden", children: [
1831
+ /* @__PURE__ */ n(ot, { className: "size-3.5" }),
1832
+ "Thinking"
1833
+ ] }),
1834
+ /* @__PURE__ */ n(Nt, { className: "mb-1", children: /* @__PURE__ */ n("div", { className: "whitespace-pre-wrap pl-3", children: e.text }) })
1835
+ ] });
1836
+ case "error":
1837
+ return /* @__PURE__ */ n("div", { className: "rounded-md border border-danger/40 px-3 py-2 text-sm text-danger", children: e.text });
1838
+ case "tool":
1839
+ return /* @__PURE__ */ n(yn, { item: e, running: t });
1840
+ }
1841
+ }
1842
+ function _n({
1843
+ items: e,
1844
+ running: t,
1845
+ interrupts: i
1846
+ }) {
1847
+ var u, f;
1848
+ const a = de(() => vn(e), [e]), s = de(() => {
1849
+ const m = [];
1850
+ return e.forEach((x, v) => {
1851
+ (x.kind === "user" || m.length === 0) && m.push({ key: x.kind === "user" ? x.id : "head", rows: [] }), m.at(-1).rows.push({ item: x, index: v });
1852
+ }), m;
1853
+ }, [e]), r = (u = e.findLast((m) => m.kind === "user")) == null ? void 0 : u.id, o = $(null), l = $(null), c = $(void 0), p = $(void 0), h = (f = e[0]) == null ? void 0 : f.id;
1854
+ return Se(() => {
1855
+ var x, v;
1856
+ const m = c.current;
1857
+ c.current = r, h !== p.current ? (p.current = h, (x = l.current) == null || x.scrollIntoView({ block: "end", behavior: "instant" })) : t && m && r !== m && ((v = o.current) == null || v.scrollIntoView({ block: "start", behavior: "smooth" }));
1858
+ }, [h, r, t]), /* @__PURE__ */ n(ht.Provider, { value: i ?? null, children: /* @__PURE__ */ d("div", { className: "mx-auto flex w-full max-w-5xl flex-col p-4", children: [
1859
+ s.map((m, x) => {
1860
+ var C;
1861
+ const v = x === s.length - 1, g = v && t ? { before: m.rows, steps: [], answer: [] } : wn(m.rows), y = (w, j = !1) => w.map(({ item: L, index: E }) => /* @__PURE__ */ n(
1862
+ "div",
1863
+ {
1864
+ ref: v && L.id === r ? o : void 0,
1865
+ className: k(
1866
+ "min-w-0 scroll-mt-4",
1867
+ E > 0 && !j && Ye(e[E - 1], L),
1868
+ // Folded steps are evenly spaced, remarks as tall as a step row.
1869
+ j && L.kind === "assistant" && "py-1.5"
1870
+ ),
1871
+ children: /* @__PURE__ */ n(kn, { item: L, running: t, agent: a.get(L.id) })
1872
+ },
1873
+ `${L.kind}:${L.id}`
1874
+ ));
1875
+ return (
1876
+ // The last turn is tall enough to scroll its message up to the top.
1877
+ /* @__PURE__ */ d(
1878
+ "div",
1879
+ {
1880
+ className: k(
1881
+ "flex flex-col",
1882
+ v && "min-h-[var(--chat-turn-min,calc(100dvh-168px))]"
1883
+ ),
1884
+ children: [
1885
+ y(g.before),
1886
+ g.steps.length > 0 && /* @__PURE__ */ n(
1887
+ Nn,
1888
+ {
1889
+ count: g.steps.filter(({ item: w }) => kt(w)).length,
1890
+ className: g.steps[0].index > 0 ? Ye(
1891
+ e[g.steps[0].index - 1],
1892
+ g.steps[0].item
1893
+ ) : void 0,
1894
+ children: y(g.steps, !0)
1895
+ },
1896
+ `steps:${g.steps[0].item.id}`
1897
+ ),
1898
+ y(g.answer),
1899
+ v && t && ((C = e.at(-1)) == null ? void 0 : C.kind) === "user" && /* @__PURE__ */ n(ge, { className: "mt-4 size-4 animate-spin text-muted-foreground" })
1900
+ ]
1901
+ },
1902
+ m.key
1903
+ )
1904
+ );
1905
+ }),
1906
+ /* @__PURE__ */ n("div", { ref: l })
1907
+ ] }) });
1908
+ }
1909
+ function Sn({
1910
+ title: e,
1911
+ nudge: t = 0,
1912
+ variants: i
1913
+ }) {
1914
+ const a = i != null && i.length ? Cn(i, t) : void 0, s = (a == null ? void 0 : a.title) ?? "Start your chat here", r = a ? a.subtitle : e;
1915
+ return /* @__PURE__ */ n("div", { className: "flex flex-1 flex-col items-center justify-center gap-2 p-6 text-center", children: /* @__PURE__ */ d("div", { className: "empty-chat-nudge flex flex-col items-center gap-2", children: [
1916
+ /* @__PURE__ */ n(Jt, { className: "size-8 text-muted-foreground" }),
1917
+ /* @__PURE__ */ n("h2", { className: "text-xl font-semibold", children: s }),
1918
+ r && /* @__PURE__ */ n("p", { className: "text-sm text-muted-foreground", children: r })
1919
+ ] }, t) });
1920
+ }
1921
+ function Cn(e, t) {
1922
+ const i = e[(t % e.length + e.length) % e.length];
1923
+ return typeof i == "string" ? { title: i } : i;
1924
+ }
1925
+ function En(e) {
1926
+ return /* @__PURE__ */ n(zn, { ...e }, e.draftKey ?? "");
1927
+ }
1928
+ function zn({
1929
+ disabled: e,
1930
+ running: t,
1931
+ placeholder: i,
1932
+ historyKey: a,
1933
+ draftKey: s,
1934
+ focusSignal: r,
1935
+ onSend: o,
1936
+ onStop: l
1937
+ }) {
1938
+ const [c, p] = O(() => s ? Vr(s) : "");
1939
+ P(() => {
1940
+ s && Be(s, c);
1941
+ }, [s, c]);
1942
+ const h = Gr(() => a ? pt(a) : []), u = $(null), f = $(null), m = ue(
1943
+ (y) => Br(u.current, y),
1944
+ []
1945
+ );
1946
+ P(() => {
1947
+ e || m();
1948
+ }, [e, m]), P(() => {
1949
+ r && m();
1950
+ }, [r, m]);
1951
+ const x = $(t);
1952
+ P(() => {
1953
+ x.current && !t && m(f.current), x.current = t;
1954
+ }, [t, m]), Se(() => {
1955
+ const y = u.current;
1956
+ y && (y.style.height = "auto", y.style.height = `${y.scrollHeight}px`);
1957
+ }, [c]);
1958
+ const v = (y) => {
1959
+ y == null || y.preventDefault(), !(e || t || !c.trim()) && (o(c), a && Kr(a, c), h.reset(), s && Be(s, ""), p(""), m(f.current));
1960
+ };
1961
+ return /* @__PURE__ */ n("form", { ref: f, onSubmit: v, className: "mx-auto w-full max-w-5xl p-4", children: /* @__PURE__ */ d(
1962
+ "div",
1963
+ {
1964
+ className: "thinking-border flex items-end gap-2 rounded-xl border border-input bg-surface-input p-2",
1965
+ "data-thinking": t,
1966
+ children: [
1967
+ /* @__PURE__ */ n(
1968
+ ft,
1969
+ {
1970
+ ref: u,
1971
+ disabled: e,
1972
+ rows: 1,
1973
+ value: c,
1974
+ onChange: (y) => p(y.target.value),
1975
+ onKeyDown: (y) => {
1976
+ y.key === "Enter" && !y.shiftKey && !y.nativeEvent.isComposing ? v(y) : a && h.onKeyDown(y, c, p);
1977
+ },
1978
+ placeholder: i,
1979
+ className: "max-h-60 min-h-9 resize-none overflow-y-auto border-0 bg-transparent leading-5 focus-visible:ring-0"
1980
+ }
1981
+ ),
1982
+ t ? /* @__PURE__ */ n(ye, { label: "Stop", className: "zenera-chat", children: /* @__PURE__ */ n(
1983
+ re,
1984
+ {
1985
+ type: "button",
1986
+ size: "icon",
1987
+ variant: "outline",
1988
+ onClick: () => {
1989
+ l(), m(f.current);
1990
+ },
1991
+ "aria-label": "Stop",
1992
+ children: /* @__PURE__ */ n(Xt, {})
1993
+ }
1994
+ ) }) : /* @__PURE__ */ n(ye, { label: "Send (Enter)", className: "zenera-chat", children: /* @__PURE__ */ n(
1995
+ re,
1996
+ {
1997
+ type: "submit",
1998
+ size: "icon",
1999
+ disabled: e || !c.trim(),
2000
+ "aria-label": "Send",
2001
+ className: k(!c.trim() && "opacity-60"),
2002
+ children: /* @__PURE__ */ n(Zt, {})
2003
+ }
2004
+ ) })
2005
+ ]
2006
+ }
2007
+ ) });
2008
+ }
2009
+ let Ln;
2010
+ const On = () => Ln ?? (Ln = import("./shadow-DmEgvnQS.js").then((e) => e.default));
2011
+ function An(e) {
2012
+ if (document.querySelector("style[data-zenera-chat-properties]")) return;
2013
+ const t = e.match(/@property\s+[^{]+\{[^}]*\}/g);
2014
+ if (!t) return;
2015
+ const i = document.createElement("style");
2016
+ i.dataset.zeneraChatProperties = "", i.textContent = t.join(`
2017
+ `), document.head.append(i);
2018
+ }
2019
+ function _t({
2020
+ children: e,
2021
+ className: t,
2022
+ style: i
2023
+ }) {
2024
+ const a = $(null), [s, r] = O(null);
2025
+ return Se(() => {
2026
+ const o = a.current;
2027
+ if (!o) return;
2028
+ const l = o.shadowRoot ?? o.attachShadow({ mode: "open" }), c = document.createElement("style"), p = document.createElement("div");
2029
+ p.style.height = "100%", l.append(c, p);
2030
+ let h = !0;
2031
+ return On().then((u) => {
2032
+ h && (An(u), c.textContent = u, r(p));
2033
+ }), () => {
2034
+ h = !1, c.remove(), p.remove(), r(null);
2035
+ };
2036
+ }, []), /* @__PURE__ */ n(
2037
+ "div",
2038
+ {
2039
+ ref: a,
2040
+ className: t,
2041
+ style: { display: "block", height: "100%", ...i },
2042
+ children: s && ct(
2043
+ /* @__PURE__ */ n(mt.Provider, { value: s, children: e }),
2044
+ s
2045
+ )
2046
+ }
2047
+ );
2048
+ }
2049
+ const ke = (e) => e && Object.fromEntries(
2050
+ Object.entries(e).map(([t, i]) => [`--${t}`, i])
2051
+ );
2052
+ function _i({ isolate: e = !0, className: t, style: i, theme: a, ...s }) {
2053
+ const r = je();
2054
+ return e ? /* @__PURE__ */ n(_t, { className: t, style: i, children: /* @__PURE__ */ n(Oe, { ...s, dark: r === "dark", rootStyle: ke(a) }) }) : /* @__PURE__ */ n(
2055
+ Oe,
2056
+ {
2057
+ ...s,
2058
+ rootClassName: t,
2059
+ rootStyle: { ...ke(a), ...i }
2060
+ }
2061
+ );
2062
+ }
2063
+ function Oe({
2064
+ transport: e,
2065
+ threadId: t,
2066
+ onThreadChange: i,
2067
+ onTurnEnd: a,
2068
+ placeholder: s = "Message…",
2069
+ starterMessages: r,
2070
+ newChatSignal: o = 0,
2071
+ historyKey: l,
2072
+ draftKey: c,
2073
+ rootClassName: p,
2074
+ rootStyle: h,
2075
+ dark: u,
2076
+ nested: f
2077
+ }) {
2078
+ const [m, x] = O(null), v = t ?? m;
2079
+ P(() => x(null), [t]);
2080
+ const g = nr(e, v), [y, C] = O(null), [w, j] = O(!1);
2081
+ P(() => {
2082
+ y && v && (C(null), g.send(y));
2083
+ }, [y, v, g]);
2084
+ const L = g.status === "running", [E, q] = O(!1);
2085
+ P(() => {
2086
+ E && !L && (a == null || a()), q(L);
2087
+ }, [L, E, a]);
2088
+ const D = ue(
2089
+ (ae) => {
2090
+ if (v) {
2091
+ g.send(ae);
2092
+ return;
2093
+ }
2094
+ e && (j(!0), e.createThread().then(({ thread: B }) => {
2095
+ C(ae), x(B.id), i == null || i(B.id);
2096
+ }).catch(() => {
2097
+ }).finally(() => j(!1)));
2098
+ },
2099
+ [v, g, e, i]
2100
+ ), J = !!(v && g.status === "idle" && !g.items.length && g.error);
2101
+ return /* @__PURE__ */ d(
2102
+ "div",
2103
+ {
2104
+ className: k(
2105
+ !f && "zenera-chat",
2106
+ "flex h-full min-h-0 flex-col text-foreground",
2107
+ u && "dark",
2108
+ p
2109
+ ),
2110
+ style: h,
2111
+ children: [
2112
+ J ? /* @__PURE__ */ n("div", { className: "flex flex-1 items-center justify-center p-6 text-center", children: /* @__PURE__ */ n("h2", { className: "text-xl font-semibold", children: g.error }) }) : !v && !g.items.length && (r != null && r.length) ? /* @__PURE__ */ n(Sn, { nudge: o, variants: r }) : /* @__PURE__ */ d("div", { className: "min-h-0 flex-1 overflow-y-auto [--chat-turn-min:calc(100cqh_-_2rem)] [container-type:size]", children: [
2113
+ /* @__PURE__ */ n(
2114
+ _n,
2115
+ {
2116
+ items: g.items,
2117
+ running: L,
2118
+ interrupts: {
2119
+ info: g.interruptInfo,
2120
+ cancel: g.cancelInterrupt,
2121
+ refresh: g.refreshInterrupts
2122
+ }
2123
+ }
2124
+ ),
2125
+ v && g.status === "loading" && !g.starting && /* @__PURE__ */ n(ge, { className: "mx-auto size-4 animate-spin text-muted-foreground" })
2126
+ ] }),
2127
+ g.starting && /* @__PURE__ */ d("p", { className: "mx-auto flex items-center gap-2 text-sm text-muted-foreground", children: [
2128
+ /* @__PURE__ */ n(ge, { className: "size-3.5 animate-spin" }),
2129
+ "Starting the project (",
2130
+ g.starting,
2131
+ ")…"
2132
+ ] }),
2133
+ g.reconnecting && !g.starting && /* @__PURE__ */ d("p", { className: "mx-auto flex items-center gap-2 text-sm text-muted-foreground", children: [
2134
+ /* @__PURE__ */ n(ge, { className: "size-3.5 animate-spin" }),
2135
+ "Connection lost, reconnecting… the answer goes on meanwhile."
2136
+ ] }),
2137
+ g.error && !J && /* @__PURE__ */ n("p", { className: "mx-auto w-full max-w-5xl px-4 text-sm text-danger", children: g.error }),
2138
+ /* @__PURE__ */ n(
2139
+ En,
2140
+ {
2141
+ disabled: !e || !!g.starting || w,
2142
+ running: L,
2143
+ placeholder: s,
2144
+ historyKey: l,
2145
+ draftKey: c,
2146
+ onSend: D,
2147
+ onStop: g.cancel
2148
+ }
2149
+ )
2150
+ ]
2151
+ }
2152
+ );
2153
+ }
2154
+ function Tn(e, t = 4e3) {
2155
+ const [i, a] = O(null), s = $(void 0);
2156
+ P(() => () => clearTimeout(s.current), []);
2157
+ const r = ue(() => {
2158
+ clearTimeout(s.current), a(null);
2159
+ }, []);
2160
+ return { armed: i, request: (l) => {
2161
+ if (clearTimeout(s.current), i !== l) {
2162
+ a(l), s.current = setTimeout(() => a(null), t);
2163
+ return;
2164
+ }
2165
+ a(null), e(l);
2166
+ }, disarm: r };
2167
+ }
2168
+ function jn({
2169
+ armed: e,
2170
+ onClick: t,
2171
+ disabled: i,
2172
+ label: a = "Delete",
2173
+ alwaysShown: s,
2174
+ className: r
2175
+ }) {
2176
+ const o = e ? "Click again to delete" : a;
2177
+ return /* @__PURE__ */ n(ye, { label: o, children: /* @__PURE__ */ d(
2178
+ "button",
2179
+ {
2180
+ type: "button",
2181
+ "aria-label": o,
2182
+ disabled: i,
2183
+ onClick: (l) => {
2184
+ l.stopPropagation(), t();
2185
+ },
2186
+ className: k(
2187
+ "cursor-pointer items-center gap-1 rounded p-1 text-xs text-muted-foreground hover:text-danger disabled:opacity-50",
2188
+ e ? "flex bg-danger/15 px-1.5 text-danger" : s ? "flex" : "hidden group-focus-within:flex group-hover:flex [@media(hover:none)]:flex",
2189
+ r
2190
+ ),
2191
+ children: [
2192
+ /* @__PURE__ */ n(Gt, { className: "size-3.5" }),
2193
+ e && "Delete"
2194
+ ]
2195
+ }
2196
+ ) });
2197
+ }
2198
+ const Rn = 45, In = 256, Ee = 192, Ve = 480, St = 300, $n = 140, Qe = (e) => typeof localStorage > "u" ? null : localStorage.getItem(e);
2199
+ function Pn(e, t, i) {
2200
+ return e === "right" ? i.right - t : t - i.left;
2201
+ }
2202
+ function Mn(e = "zenera.chatSidebar", t = "left", i) {
2203
+ const a = `${e}Collapsed`, s = `${e}Width`, [r, o] = O(() => {
2204
+ if (i !== void 0) return i;
2205
+ const m = Qe(a);
2206
+ return m !== null ? m === "1" : typeof window < "u" && window.matchMedia("(max-width: 767px)").matches;
2207
+ }), [l, c] = O(() => {
2208
+ const m = Number(Qe(s));
2209
+ return m >= Ee && m <= Ve ? m : In;
2210
+ }), [p, h] = O(!1);
2211
+ return { collapsed: r, width: l, resizing: p, toggle: () => o((m) => (localStorage.setItem(a, m ? "0" : "1"), !m)), setCollapsed: o, startResize: (m) => {
2212
+ var q;
2213
+ const x = m.currentTarget.parentElement;
2214
+ if (!x) return;
2215
+ const v = (((q = x.parentElement) == null ? void 0 : q.clientWidth) ?? 1 / 0) - St, g = Math.min(Ve, v);
2216
+ if (g < Ee) return;
2217
+ m.preventDefault();
2218
+ const y = m.currentTarget;
2219
+ y.setPointerCapture(m.pointerId);
2220
+ const C = x.getBoundingClientRect();
2221
+ let w = r, j = l;
2222
+ h(!0);
2223
+ const L = (D) => {
2224
+ const J = Pn(t, D.clientX, C);
2225
+ w = J < $n, o(w), w || (j = Math.round(Math.min(Math.max(J, Ee), g)), c(j));
2226
+ }, E = () => {
2227
+ y.removeEventListener("pointermove", L), y.removeEventListener("lostpointercapture", E), h(!1), localStorage.setItem(a, w ? "1" : "0"), localStorage.setItem(s, String(j));
2228
+ };
2229
+ y.addEventListener("pointermove", L), y.addEventListener("lostpointercapture", E);
2230
+ } };
2231
+ }
2232
+ function Dn({
2233
+ transport: e,
2234
+ layout: t,
2235
+ activeThreadId: i,
2236
+ onSelect: a,
2237
+ onNew: s,
2238
+ onDelete: r,
2239
+ renderLink: o,
2240
+ newDisabled: l,
2241
+ refreshKey: c,
2242
+ footer: p,
2243
+ side: h = "left",
2244
+ showToggle: u = !1,
2245
+ className: f
2246
+ }) {
2247
+ const { collapsed: m, width: x, resizing: v, startResize: g } = t, y = ir(e, c), C = Tn((E) => {
2248
+ y.remove(E).then(() => r == null ? void 0 : r(E)).catch(() => {
2249
+ });
2250
+ }), w = !e || l, j = h === "right" ? "left" : "right", L = h === "right" ? m ? Yt : Vt : m ? Qt : er;
2251
+ return /* @__PURE__ */ d(
2252
+ "aside",
2253
+ {
2254
+ style: { width: m ? Rn : x },
2255
+ className: k(
2256
+ "relative flex shrink-0 flex-col gap-2 border-border",
2257
+ h === "right" ? "border-l" : "border-r",
2258
+ m ? "items-center p-1 pt-3" : "p-3",
2259
+ !v && "transition-[width] duration-150",
2260
+ f
2261
+ ),
2262
+ children: [
2263
+ /* @__PURE__ */ n(
2264
+ "div",
2265
+ {
2266
+ className: k(
2267
+ "group absolute inset-y-0 z-10 w-2 cursor-col-resize touch-none",
2268
+ h === "right" ? "-left-1" : "-right-1"
2269
+ ),
2270
+ title: "Drag to resize",
2271
+ onPointerDown: g,
2272
+ children: /* @__PURE__ */ n("div", { className: "mx-auto h-full w-px group-hover:w-0.5 group-hover:bg-primary/60" })
2273
+ }
2274
+ ),
2275
+ /* @__PURE__ */ d(
2276
+ "div",
2277
+ {
2278
+ className: k(
2279
+ "flex gap-2",
2280
+ m ? "flex-col items-center" : h === "right" ? "flex-row-reverse" : "flex-row"
2281
+ ),
2282
+ children: [
2283
+ u && /* @__PURE__ */ n(
2284
+ ye,
2285
+ {
2286
+ label: m ? "Expand sidebar" : "Collapse sidebar",
2287
+ side: m ? j : "bottom",
2288
+ children: /* @__PURE__ */ n(
2289
+ re,
2290
+ {
2291
+ variant: "outline",
2292
+ size: "icon",
2293
+ "aria-label": m ? "Expand sidebar" : "Collapse sidebar",
2294
+ "aria-expanded": !m,
2295
+ onClick: t.toggle,
2296
+ children: /* @__PURE__ */ n(L, {})
2297
+ }
2298
+ )
2299
+ }
2300
+ ),
2301
+ m ? /* @__PURE__ */ n(ye, { label: "New chat", side: j, children: /* @__PURE__ */ n(
2302
+ re,
2303
+ {
2304
+ variant: "outline",
2305
+ size: "icon",
2306
+ "aria-label": "New chat",
2307
+ disabled: w,
2308
+ onClick: s,
2309
+ children: /* @__PURE__ */ n(tr, {})
2310
+ }
2311
+ ) }) : /* @__PURE__ */ d(
2312
+ re,
2313
+ {
2314
+ variant: "outline",
2315
+ className: "min-w-0 flex-1 justify-start overflow",
2316
+ disabled: w,
2317
+ onClick: s,
2318
+ children: [
2319
+ /* @__PURE__ */ n(rr, {}),
2320
+ "New chat"
2321
+ ]
2322
+ }
2323
+ )
2324
+ ]
2325
+ }
2326
+ ),
2327
+ /* @__PURE__ */ n(
2328
+ "div",
2329
+ {
2330
+ className: k(
2331
+ "flex min-h-0 flex-1 flex-col gap-1.5 overflow-y-auto",
2332
+ m && "hidden"
2333
+ ),
2334
+ children: y.threads.map((E) => {
2335
+ const q = E.id === i, D = {
2336
+ className: k(
2337
+ "flex min-w-0 flex-1 cursor-pointer items-center gap-2 px-2 py-1.5 text-left text-sm text-muted-foreground hover:text-foreground",
2338
+ q && "text-foreground"
2339
+ ),
2340
+ children: /* @__PURE__ */ n("span", { className: "truncate", children: E.title })
2341
+ };
2342
+ return /* @__PURE__ */ d(
2343
+ "div",
2344
+ {
2345
+ className: k(
2346
+ "group flex items-center rounded-md hover:bg-accent",
2347
+ q && "bg-accent"
2348
+ ),
2349
+ children: [
2350
+ o ? o(E, D) : /* @__PURE__ */ n(
2351
+ "button",
2352
+ {
2353
+ type: "button",
2354
+ className: D.className,
2355
+ onClick: () => a == null ? void 0 : a(E.id),
2356
+ children: D.children
2357
+ }
2358
+ ),
2359
+ /* @__PURE__ */ n(
2360
+ jn,
2361
+ {
2362
+ armed: C.armed === E.id,
2363
+ disabled: y.removing,
2364
+ label: "Delete chat",
2365
+ onClick: () => C.request(E.id),
2366
+ className: "mr-1"
2367
+ }
2368
+ )
2369
+ ]
2370
+ },
2371
+ E.id
2372
+ );
2373
+ })
2374
+ }
2375
+ ),
2376
+ p
2377
+ ]
2378
+ }
2379
+ );
2380
+ }
2381
+ function Si({
2382
+ isolate: e = !0,
2383
+ className: t,
2384
+ style: i,
2385
+ theme: a,
2386
+ ...s
2387
+ }) {
2388
+ const r = je();
2389
+ return e ? /* @__PURE__ */ n(_t, { className: t, style: i, children: /* @__PURE__ */ n(et, { ...s, dark: r === "dark", rootStyle: ke(a) }) }) : /* @__PURE__ */ n(
2390
+ et,
2391
+ {
2392
+ ...s,
2393
+ rootClassName: t,
2394
+ rootStyle: { ...ke(a), ...i }
2395
+ }
2396
+ );
2397
+ }
2398
+ function et({
2399
+ transport: e,
2400
+ threadId: t,
2401
+ onThreadChange: i,
2402
+ onTurnEnd: a,
2403
+ renderLink: s,
2404
+ sidebarStorageKey: r,
2405
+ sidebarSide: o = "left",
2406
+ sidebarCollapsed: l,
2407
+ onSidebarCollapsedChange: c,
2408
+ sidebarToggle: p = !1,
2409
+ sidebarClassName: h,
2410
+ rootClassName: u,
2411
+ rootStyle: f,
2412
+ dark: m,
2413
+ ...x
2414
+ }) {
2415
+ const v = Mn(r, o, l), { collapsed: g, setCollapsed: y } = v, C = $(null), [w, j] = O(null);
2416
+ P(() => {
2417
+ const R = C.current;
2418
+ if (!R || typeof ResizeObserver > "u") return;
2419
+ const Q = new ResizeObserver(() => j(R.clientWidth));
2420
+ return Q.observe(R), () => Q.disconnect();
2421
+ }, []);
2422
+ const E = w !== null && w - v.width < St && !g ? { ...v, collapsed: !0 } : v, q = $(!1);
2423
+ P(() => {
2424
+ q.current ? l !== void 0 && y(l) : q.current = !0;
2425
+ }, [l, y]);
2426
+ const D = $(c);
2427
+ D.current = c, P(() => {
2428
+ var R;
2429
+ return (R = D.current) == null ? void 0 : R.call(D, g);
2430
+ }, [g]);
2431
+ const [J, ae] = O(null), [B, ve] = O(0), se = t === void 0 ? J : t, [Ce, we] = O(0), H = ue(
2432
+ (R) => {
2433
+ ae(R), i == null || i(R);
2434
+ },
2435
+ [i]
2436
+ ), G = /* @__PURE__ */ n(
2437
+ Dn,
2438
+ {
2439
+ transport: e,
2440
+ layout: E,
2441
+ side: o,
2442
+ showToggle: p,
2443
+ activeThreadId: se,
2444
+ onSelect: H,
2445
+ onNew: () => {
2446
+ ve((R) => R + 1), H(null);
2447
+ },
2448
+ onDelete: (R) => R === se && H(null),
2449
+ renderLink: s,
2450
+ refreshKey: Ce,
2451
+ className: h
2452
+ }
2453
+ );
2454
+ return /* @__PURE__ */ d(
2455
+ "div",
2456
+ {
2457
+ ref: C,
2458
+ className: k(
2459
+ "zenera-chat flex h-full min-h-0 text-foreground",
2460
+ m && "dark",
2461
+ u
2462
+ ),
2463
+ style: f,
2464
+ children: [
2465
+ o === "left" && G,
2466
+ /* @__PURE__ */ n("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ n(
2467
+ Oe,
2468
+ {
2469
+ ...x,
2470
+ nested: !0,
2471
+ newChatSignal: B,
2472
+ transport: e,
2473
+ threadId: se,
2474
+ onThreadChange: (R) => {
2475
+ we((Q) => Q + 1), H(R);
2476
+ },
2477
+ onTurnEnd: () => {
2478
+ we((R) => R + 1), a == null || a();
2479
+ }
2480
+ }
2481
+ ) }),
2482
+ o === "right" && G
2483
+ ]
2484
+ }
2485
+ );
2486
+ }
2487
+ const Ct = 360, Et = 320, zt = 360, Wn = 240, Y = (e, t, i) => Math.min(Math.max(e, t), i), fe = (e, t) => Math.min(e, t);
2488
+ function Lt(e, t) {
2489
+ const i = Y(
2490
+ e.width,
2491
+ fe(Ct, t.width),
2492
+ Math.max(t.width, 0)
2493
+ ), a = Y(
2494
+ e.height,
2495
+ fe(Et, t.height),
2496
+ Math.max(t.height, 0)
2497
+ );
2498
+ return {
2499
+ width: i,
2500
+ height: a,
2501
+ left: Y(e.left, 0, t.width - i),
2502
+ top: Y(e.top, 0, t.height - a)
2503
+ };
2504
+ }
2505
+ function Hn(e, t, i, a) {
2506
+ return Lt({ ...e, left: e.left + t, top: e.top + i }, a);
2507
+ }
2508
+ function qn(e, t, i, a, s) {
2509
+ const r = fe(Ct, s.width), o = fe(Et, s.height);
2510
+ let l = e.left, c = e.top, p = e.left + e.width, h = e.top + e.height;
2511
+ return t.includes("w") && (l = Y(l + i, 0, p - r)), t.includes("e") && (p = Y(p + i, l + r, s.width)), t.includes("n") && (c = Y(c + a, 0, h - o)), t.includes("s") && (h = Y(h + a, c + o, s.height)), { left: l, top: c, width: p - l, height: h - c };
2512
+ }
2513
+ function Bn(e, t) {
2514
+ const i = t ? e - Wn : e;
2515
+ return Math.max(i, fe(zt, e));
2516
+ }
2517
+ function Ot(e, t, i) {
2518
+ return Y(
2519
+ e,
2520
+ fe(zt, t),
2521
+ Bn(t, i)
2522
+ );
2523
+ }
2524
+ function tt(e, t, i, a, s) {
2525
+ const r = t === "right" ? e - i : e + i;
2526
+ return Ot(r, a, s);
2527
+ }
2528
+ const he = (e) => {
2529
+ throw new Error(`ZeneraChatLauncher: ${e}`);
2530
+ };
2531
+ function rt(e, t) {
2532
+ const { mode: i, side: a = "right", width: s, resizable: r = !0, defaultOpen: o = !1 } = e, { placement: l, height: c, contentTarget: p, draggable: h = !0 } = e;
2533
+ i !== "popup" && i !== "sidebar" && he(`presentation.mode must be 'popup' or 'sidebar', not ${String(i)}`), a !== "left" && a !== "right" && he(`presentation.side must be 'left' or 'right', not ${String(a)}`);
2534
+ let u = null;
2535
+ return i === "sidebar" && (l !== "overlay" && l !== "docked" && he("a sidebar needs presentation.placement: 'overlay' or 'docked'"), l === "docked" && (p || he("a docked sidebar needs presentation.contentTarget"), u = typeof p == "string" ? t(p) : p, u || he(`contentTarget ${String(p)} matches no element`))), {
2536
+ mode: i,
2537
+ docked: i === "sidebar" && l === "docked",
2538
+ side: a,
2539
+ width: s ?? (i === "popup" ? "380px" : "820px"),
2540
+ height: c ?? "600px",
2541
+ contentTarget: u,
2542
+ resizable: r,
2543
+ draggable: h,
2544
+ defaultOpen: o
2545
+ };
2546
+ }
2547
+ const Fn = "(max-width: 767px)", Un = ["n", "s", "e", "w", "ne", "nw", "se", "sw"], nt = 16, Kn = `
2548
+ :host { display: contents; }
2549
+ * { box-sizing: border-box; }
2550
+ .button {
2551
+ position: fixed; bottom: 24px; z-index: 2147483000;
2552
+ width: 56px; height: 56px; padding: 0; border: 0; border-radius: 50%;
2553
+ display: flex; align-items: center; justify-content: center; cursor: pointer;
2554
+ background: var(--zenera-launcher-accent, #4f46e5); color: #fff;
2555
+ box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
2556
+ }
2557
+ .button[hidden] { display: none; }
2558
+ .button:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
2559
+ .button[data-side='right'] { right: 24px; }
2560
+ .button[data-side='left'] { left: 24px; }
2561
+ .panel {
2562
+ position: fixed; z-index: 2147483001; display: flex; flex-direction: column;
2563
+ background: #fff; color: #111827; border: 0 solid #e5e7eb;
2564
+ font: 14px/1.4 system-ui, -apple-system, 'Segoe UI', sans-serif;
2565
+ }
2566
+ .panel[hidden] { display: none; }
2567
+ .panel:focus { outline: none; }
2568
+ .panel[data-mode='popup'] {
2569
+ bottom: 96px; max-width: calc(100vw - 32px); max-height: calc(100vh - 120px);
2570
+ border-width: 1px; border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
2571
+ }
2572
+ .panel[data-mode='popup'][data-side='right'] { right: 24px; }
2573
+ .panel[data-mode='popup'][data-side='left'] { left: 24px; }
2574
+ .panel[data-mode='sidebar'] { top: 0; bottom: 0; max-width: 100vw; }
2575
+ .panel[data-mode='sidebar'][data-side='right'] { right: 0; border-left-width: 1px; }
2576
+ .panel[data-mode='sidebar'][data-side='left'] { left: 0; border-right-width: 1px; }
2577
+ .panel[data-mode='sidebar'][data-overlay] { box-shadow: 0 0 32px rgba(0, 0, 0, 0.2); }
2578
+ .header {
2579
+ display: flex; align-items: center; justify-content: space-between; flex: none;
2580
+ height: 44px; padding: 0 8px 0 16px; border-bottom: 1px solid #e5e7eb; font-weight: 600;
2581
+ }
2582
+ .close {
2583
+ width: 32px; height: 32px; padding: 0; border: 0; border-radius: 6px;
2584
+ background: transparent; color: inherit; cursor: pointer; font-size: 20px; line-height: 1;
2585
+ }
2586
+ .close:hover { background: rgba(127, 127, 127, 0.2); }
2587
+ .close:focus-visible { outline: 2px solid #93c5fd; }
2588
+ .header[data-draggable] { cursor: grab; touch-action: none; user-select: none; }
2589
+ .panel[data-gesture] .header[data-draggable] { cursor: grabbing; }
2590
+ .panel[data-gesture], .panel[data-gesture] ::slotted(*) { user-select: none; }
2591
+ .handle { position: absolute; z-index: 1; touch-action: none; }
2592
+ .handle[hidden] { display: none; }
2593
+ .handle[data-edge='n'] { top: -3px; left: 14px; right: 14px; height: 6px; cursor: ns-resize; }
2594
+ .handle[data-edge='s'] { bottom: -3px; left: 14px; right: 14px; height: 6px; cursor: ns-resize; }
2595
+ .handle[data-edge='e'] { right: -3px; top: 14px; bottom: 14px; width: 6px; cursor: ew-resize; }
2596
+ .handle[data-edge='w'] { left: -3px; top: 14px; bottom: 14px; width: 6px; cursor: ew-resize; }
2597
+ .handle[data-edge='ne'] { top: -4px; right: -4px; width: 14px; height: 14px; cursor: nesw-resize; }
2598
+ .handle[data-edge='nw'] { top: -4px; left: -4px; width: 14px; height: 14px; cursor: nwse-resize; }
2599
+ .handle[data-edge='se'] { bottom: -4px; right: -4px; width: 14px; height: 14px; cursor: nwse-resize; }
2600
+ .handle[data-edge='sw'] { bottom: -4px; left: -4px; width: 14px; height: 14px; cursor: nesw-resize; }
2601
+ .panel[data-mode='sidebar'] .handle { top: 0; bottom: 0; }
2602
+ .handle:focus-visible { outline: 2px solid #93c5fd; outline-offset: -2px; }
2603
+ .body { flex: 1; min-height: 0; }
2604
+ slot { display: block; height: 100%; }
2605
+ :host([data-scheme='dark']) .panel { background: #111827; color: #f9fafb; border-color: #374151; }
2606
+ :host([data-scheme='dark']) .header { border-color: #374151; }
2607
+ `, Jn = '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>', U = (e, t = {}) => {
2608
+ const i = document.createElement(e);
2609
+ for (const [a, s] of Object.entries(t)) i.setAttribute(a, s);
2610
+ return i;
2611
+ };
2612
+ function Xn(e) {
2613
+ var De;
2614
+ const { chatId: t, onOpenChange: i } = e;
2615
+ if (!t) throw new Error("ZeneraChatLauncher: chatId is required");
2616
+ if (document.getElementById(t))
2617
+ throw new Error(`ZeneraChatLauncher: the page already has an element with id "${t}"`);
2618
+ const a = (b) => document.querySelector(b), s = (De = window.matchMedia) == null ? void 0 : De.call(window, Fn);
2619
+ let r = e.presentation, o = rt(r, a), l = o.defaultOpen, c = !1, p = (s == null ? void 0 : s.matches) ?? !1, h = null, u = null, f = null, m = null;
2620
+ const x = U("div", { "data-zenera-chat-launcher": "" }), v = U("div", { id: t });
2621
+ v.style.cssText = "display:block;height:100%", x.append(v);
2622
+ const g = x.attachShadow({ mode: "open" }), y = U("style");
2623
+ y.textContent = Kn;
2624
+ const C = U("button", { type: "button", class: "button" });
2625
+ C.innerHTML = Jn;
2626
+ const w = U("div", {
2627
+ class: "panel",
2628
+ role: "dialog",
2629
+ "aria-modal": "false",
2630
+ "aria-label": "Chat",
2631
+ tabindex: "-1"
2632
+ }), j = U("div", { class: "header" }), L = U("span");
2633
+ L.textContent = "Chat";
2634
+ const E = U("button", { type: "button", class: "close", "aria-label": "Close chat" });
2635
+ E.textContent = "×", j.append(L, E);
2636
+ const q = U("div", { class: "body" });
2637
+ q.append(U("slot")), w.append(j, q);
2638
+ const D = /* @__PURE__ */ new Map();
2639
+ for (const b of Un) {
2640
+ const S = U("div", { class: "handle", "data-edge": b });
2641
+ D.set(b, S), w.append(S);
2642
+ }
2643
+ g.append(y, C, w);
2644
+ const J = () => {
2645
+ if (!h) return;
2646
+ const { target: b, property: S, value: N, priority: z } = h;
2647
+ N ? b.style.setProperty(S, N, z) : b.style.removeProperty(S), h = null;
2648
+ }, ae = (b, S) => {
2649
+ const N = b.contentTarget, z = b.side === "left" ? "margin-left" : "margin-right";
2650
+ h = {
2651
+ target: N,
2652
+ property: z,
2653
+ value: N.style.getPropertyValue(z),
2654
+ priority: N.style.getPropertyPriority(z)
2655
+ }, N.style.setProperty(z, S);
2656
+ }, B = () => ({
2657
+ width: document.documentElement.clientWidth || window.innerWidth,
2658
+ height: window.innerHeight
2659
+ }), ve = () => {
2660
+ const { left: b, top: S, width: N, height: z } = w.getBoundingClientRect();
2661
+ return { left: b, top: S, width: N, height: z };
2662
+ }, se = () => l && o.docked && !p, Ce = (b) => {
2663
+ const { mode: S, side: N, width: z, height: F, resizable: X, draggable: oe } = o, le = S === "popup", W = w.style;
2664
+ le && f ? (f = Lt(f, B()), W.left = `${f.left}px`, W.top = `${f.top}px`, W.width = `${f.width}px`, W.height = `${f.height}px`, W.right = W.bottom = "auto", W.maxWidth = W.maxHeight = "none") : (W.left = W.top = W.right = W.bottom = "", W.maxWidth = W.maxHeight = "", W.width = le ? z : we(b), W.height = le ? F : ""), j.toggleAttribute("data-draggable", le && oe);
2665
+ const At = N === "right" ? "w" : "e";
2666
+ for (const [Tt, ce] of D) {
2667
+ const We = X && (le || Tt === At);
2668
+ if (ce.hidden = !We, We && !le)
2669
+ ce.setAttribute("role", "separator"), ce.setAttribute("aria-orientation", "vertical"), ce.setAttribute("aria-label", "Resize chat"), ce.tabIndex = 0;
2670
+ else
2671
+ for (const jt of ["role", "aria-orientation", "aria-label", "tabindex"])
2672
+ ce.removeAttribute(jt);
2673
+ }
2674
+ }, we = (b) => m === null ? o.width : `${Ot(m, B().width, b)}px`, H = () => {
2675
+ const { mode: b, side: S, docked: N } = o, z = l && N && !p;
2676
+ w.dataset.mode = b, w.dataset.side = S, C.dataset.side = S, w.toggleAttribute("data-overlay", b === "sidebar" && !z), w.hidden = !l, C.hidden = l && b === "sidebar", C.setAttribute("aria-expanded", String(l)), C.setAttribute("aria-label", l ? "Close chat" : "Open chat"), Ce(z), J(), z && ae(o, w.style.width);
2677
+ }, G = (b) => {
2678
+ if (b === l) return;
2679
+ b && (u = document.activeElement);
2680
+ const S = !b && x.contains(document.activeElement);
2681
+ l = b, H(), b ? w.focus() : S && (u instanceof HTMLElement && u.isConnected ? u : C).focus(), i == null || i(l);
2682
+ }, R = () => {
2683
+ if (c) throw new Error("ZeneraChatLauncher: already unmounted");
2684
+ }, Q = (b) => {
2685
+ b.key === "Escape" && l && !b.defaultPrevented && G(!1);
2686
+ }, Re = (b) => {
2687
+ p = b.matches, H();
2688
+ }, Ie = () => {
2689
+ l && (f || m !== null) && H();
2690
+ }, $e = (b, S) => {
2691
+ b.addEventListener("pointerdown", (N) => {
2692
+ if (N.button !== 0 || !N.isPrimary) return;
2693
+ const z = S(N);
2694
+ if (!z) return;
2695
+ N.preventDefault(), b.setPointerCapture(N.pointerId), w.setAttribute("data-gesture", "");
2696
+ const F = (oe) => z(oe.clientX - N.clientX, oe.clientY - N.clientY), X = () => {
2697
+ w.removeAttribute("data-gesture"), b.removeEventListener("pointermove", F), b.removeEventListener("pointerup", X), b.removeEventListener("pointercancel", X);
2698
+ };
2699
+ b.addEventListener("pointermove", F), b.addEventListener("pointerup", X), b.addEventListener("pointercancel", X);
2700
+ });
2701
+ };
2702
+ for (const [b, S] of D)
2703
+ $e(S, () => {
2704
+ if (!o.resizable) return null;
2705
+ if (o.mode === "popup") {
2706
+ const F = ve();
2707
+ return (X, oe) => {
2708
+ f = qn(F, b, X, oe, B()), H();
2709
+ };
2710
+ }
2711
+ const N = w.getBoundingClientRect().width, z = se();
2712
+ return (F) => {
2713
+ m = tt(
2714
+ N,
2715
+ o.side,
2716
+ F,
2717
+ B().width,
2718
+ z
2719
+ ), H();
2720
+ };
2721
+ });
2722
+ $e(j, (b) => {
2723
+ if (o.mode !== "popup" || !o.draggable || b.target instanceof Node && E.contains(b.target)) return null;
2724
+ const S = ve();
2725
+ return (N, z) => {
2726
+ f = Hn(S, N, z, B()), H();
2727
+ };
2728
+ }), g.addEventListener("keydown", (b) => {
2729
+ const { key: S, target: N } = b;
2730
+ !(N instanceof HTMLElement) || !N.classList.contains("handle") || S !== "ArrowLeft" && S !== "ArrowRight" || o.mode !== "sidebar" || !o.resizable || (b.preventDefault(), m = tt(
2731
+ w.getBoundingClientRect().width,
2732
+ o.side,
2733
+ S === "ArrowLeft" ? -nt : nt,
2734
+ B().width,
2735
+ se()
2736
+ ), H());
2737
+ });
2738
+ const Pe = () => x.setAttribute(
2739
+ "data-scheme",
2740
+ document.documentElement.classList.contains("dark") ? "dark" : "light"
2741
+ ), Me = new MutationObserver(Pe);
2742
+ return Me.observe(document.documentElement, {
2743
+ attributes: !0,
2744
+ attributeFilter: ["class"]
2745
+ }), C.addEventListener("click", () => G(!l)), E.addEventListener("click", () => G(!1)), document.addEventListener("keydown", Q), s == null || s.addEventListener("change", Re), window.addEventListener("resize", Ie), Pe(), H(), document.body.append(x), {
2746
+ container: v,
2747
+ get isOpen() {
2748
+ return l;
2749
+ },
2750
+ open() {
2751
+ R(), G(!0);
2752
+ },
2753
+ close() {
2754
+ R(), G(!1);
2755
+ },
2756
+ toggle() {
2757
+ R(), G(!l);
2758
+ },
2759
+ update(b) {
2760
+ R();
2761
+ const S = Object.fromEntries(
2762
+ Object.entries(b).filter(([, X]) => X !== void 0)
2763
+ ), N = { ...r, ...S }, z = rt(N, a), F = z.width !== o.width;
2764
+ (F || z.side !== o.side || z.height !== o.height) && (f = null), F && (m = null), o = z, r = N, H();
2765
+ },
2766
+ unmount() {
2767
+ c || (c = !0, J(), document.removeEventListener("keydown", Q), s == null || s.removeEventListener("change", Re), window.removeEventListener("resize", Ie), Me.disconnect(), x.remove());
2768
+ }
2769
+ };
2770
+ }
2771
+ function Ci({
2772
+ chatId: e,
2773
+ presentation: t,
2774
+ open: i,
2775
+ onOpenChange: a,
2776
+ children: s
2777
+ }) {
2778
+ const [r, o] = O(null), l = $({ presentation: t, open: i, onOpenChange: a });
2779
+ l.current = { presentation: t, open: i, onOpenChange: a }, P(() => {
2780
+ const { presentation: g, open: y } = l.current, C = Xn({
2781
+ chatId: e,
2782
+ presentation: { ...g, defaultOpen: y ?? g.defaultOpen },
2783
+ onOpenChange: (w) => {
2784
+ var j, L;
2785
+ return (L = (j = l.current).onOpenChange) == null ? void 0 : L.call(j, w);
2786
+ }
2787
+ });
2788
+ return o(C), () => {
2789
+ C.unmount(), o(null);
2790
+ };
2791
+ }, [e]);
2792
+ const { mode: c, side: p, width: h } = t, u = "placement" in t ? t.placement : void 0, f = "height" in t ? t.height : void 0, m = "contentTarget" in t ? t.contentTarget : void 0, x = "draggable" in t ? t.draggable : void 0, { resizable: v } = t;
2793
+ return P(() => {
2794
+ r == null || r.update({
2795
+ mode: c,
2796
+ placement: u,
2797
+ side: p,
2798
+ width: h,
2799
+ height: f,
2800
+ contentTarget: m,
2801
+ resizable: v,
2802
+ draggable: x
2803
+ });
2804
+ }, [r, c, u, p, h, f, m, v, x]), P(() => {
2805
+ !r || i === void 0 || i === r.isOpen || (i ? r.open() : r.close());
2806
+ }, [r, i]), r ? ct(s, r.container) : null;
2807
+ }
2808
+ export {
2809
+ _n as ChatMessages,
2810
+ Dn as ChatSidebar,
2811
+ En as Composer,
2812
+ Sn as EmptyChat,
2813
+ tn as InterruptCard,
2814
+ ht as InterruptsContext,
2815
+ Fe as Shell,
2816
+ _i as ZeneraChat,
2817
+ Ci as ZeneraChatLauncher,
2818
+ Si as ZeneraChatWidget,
2819
+ ki as composerDraftKey,
2820
+ Ni as historyKey,
2821
+ Qr as interruptPhase,
2822
+ Mn as useSidebarLayout
2823
+ };