@pstdio/ui 0.0.4 → 0.1.0

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 (47) hide show
  1. package/dist/chat-ui.js +1212 -193
  2. package/dist/chat-ui.js.map +1 -1
  3. package/dist/components/chat-ui/index.d.ts +8 -5
  4. package/dist/components/chat-ui/tool-rendering/build-timeline.d.ts +2 -2
  5. package/dist/components/documentation/docs-changelog.d.ts +20 -0
  6. package/dist/components/documentation/docs-changelog.stories.d.ts +15 -0
  7. package/dist/components/documentation/docs-outline.d.ts +13 -0
  8. package/dist/components/documentation/docs-outline.stories.d.ts +16 -0
  9. package/dist/components/documentation/docs-pagination.d.ts +10 -0
  10. package/dist/components/documentation/docs-pagination.stories.d.ts +14 -0
  11. package/dist/components/documentation/docs-sidebar.d.ts +14 -0
  12. package/dist/components/documentation/docs-sidebar.stories.d.ts +7 -0
  13. package/dist/components/folder-picker-dialog.d.ts +25 -0
  14. package/dist/components/folder-picker-dialog.stories.d.ts +11 -0
  15. package/dist/components/panel-menu.d.ts +2 -0
  16. package/dist/components/panel-menu.stories.d.ts +1 -0
  17. package/dist/components/rich-text/markdown-editor/markdown-editor.d.ts +1 -0
  18. package/dist/components/rich-text/markdown-editor/markdown-editor.stories.d.ts +1 -0
  19. package/dist/components/rich-text/utils/inferResourceType.d.ts +1 -1
  20. package/dist/components/session-indicator.d.ts +1 -1
  21. package/dist/components/switch.d.ts +15 -0
  22. package/dist/components/switch.stories.d.ts +16 -0
  23. package/dist/components/{ticket-card.d.ts → tickets/ticket-card.d.ts} +2 -1
  24. package/dist/components/tickets/ticket-list.d.ts +23 -0
  25. package/dist/components/tickets/ticket-list.stories.d.ts +10 -0
  26. package/dist/empty-state-Bu1ocnPz.js +70 -0
  27. package/dist/empty-state-Bu1ocnPz.js.map +1 -0
  28. package/dist/index.d.ts +27 -0
  29. package/dist/index.js +1148 -305
  30. package/dist/index.js.map +1 -1
  31. package/dist/{rich-message-CiA3ripk.js → rich-message-CNDoACE7.js} +8 -7
  32. package/dist/{rich-message-CiA3ripk.js.map → rich-message-CNDoACE7.js.map} +1 -1
  33. package/dist/rich-text.js +267 -262
  34. package/dist/rich-text.js.map +1 -1
  35. package/dist/style.css +1 -1
  36. package/dist/theme/primitives/colors.d.ts +12 -28
  37. package/dist/theme/recipes/menu.d.ts +1 -1
  38. package/dist/theme/tokens/borders.d.ts +6 -6
  39. package/dist/theme/tokens/colors.d.ts +180 -0
  40. package/dist/{theme-9E0MRtZk.js → theme-C7CIuIPZ.js} +197 -115
  41. package/dist/theme-C7CIuIPZ.js.map +1 -0
  42. package/dist/theme.js +1 -1
  43. package/package.json +6 -8
  44. package/dist/theme-9E0MRtZk.js.map +0 -1
  45. /package/dist/components/{ticket-board.d.ts → tickets/ticket-board.d.ts} +0 -0
  46. /package/dist/components/{ticket-board.stories.d.ts → tickets/ticket-board.stories.d.ts} +0 -0
  47. /package/dist/components/{ticket-card.stories.d.ts → tickets/ticket-card.stories.d.ts} +0 -0
package/dist/chat-ui.js CHANGED
@@ -1,10 +1,10 @@
1
- import { defineSlotRecipe as ht, createSlotRecipeContext as bt, chakra as at, AbsoluteCenter as gt, IconButton as ct, Tooltip as $, Portal as St, Kbd as xt, Text as Ct, Spacer as vt, HStack as yt, Flex as wt, Box as Rt } from "@chakra-ui/react";
2
- import { jsx as l, jsxs as K, Fragment as _t } from "react/jsx-runtime";
3
- import { c as N } from "react/compiler-runtime";
4
- import { ArrowDownIcon as zt, Square as Bt, ArrowUp as Tt } from "lucide-react";
5
- import { StickToBottom as dt, useStickToBottomContext as mt } from "use-stick-to-bottom";
6
- import { useRef as ut, useEffect as ft, useState as q } from "react";
7
- import { g as rt, P as Pt, a as Et } from "./rich-message-CiA3ripk.js";
1
+ import { jsx as l, jsxs as x, Fragment as Ie } from "react/jsx-runtime";
2
+ import { c as y } from "react/compiler-runtime";
3
+ import { chakra as Ee, AbsoluteCenter as ct, IconButton as He, defineSlotRecipe as at, createSlotRecipeContext as dt, Text as J, Code as $e, Button as Re, HStack as Ne, Box as T, Flex as fe, Tooltip as ue, Portal as ut, Kbd as ft, Spacer as pt, Timeline as mt, Span as ie, Avatar as X, Card as L, Link as je, Stack as Ue, Spinner as ht } from "@chakra-ui/react";
4
+ import { ArrowDownIcon as gt, ShieldX as bt, ShieldCheck as xt, Square as yt, ArrowUp as St, Move as kt, FileDown as Tt, FileUp as wt, FileDiff as Ct, Trash2 as Pt, FilePen as _t, FileText as Bt, ListTree as Rt, Terminal as qe, File as It, Globe as vt, Search as At, AlertTriangle as Dt, DotIcon as $t, ChevronUpIcon as Ft, MessageCircleIcon as Mt } from "lucide-react";
5
+ import { StickToBottom as Ve, useStickToBottomContext as Ge } from "use-stick-to-bottom";
6
+ import { useRef as Ke, useEffect as Ye, useState as oe } from "react";
7
+ import { f as Pe, P as zt, g as Lt, R as Je, h as Ot } from "./rich-message-CNDoACE7.js";
8
8
  import "@lexical/react/LexicalCollaborationContext";
9
9
  import "@lexical/react/LexicalCollaborationPlugin";
10
10
  import "@lexical/react/LexicalComposer";
@@ -25,10 +25,48 @@ import "@lexical/utils";
25
25
  import "react-dom";
26
26
  import "./tooltip-Gm7PLwZG.js";
27
27
  import "@lexical/markdown";
28
+ import "@lexical/react/LexicalAutoFocusPlugin";
28
29
  import "@lexical/react/LexicalHistoryPlugin";
29
30
  import "@lexical/react/LexicalOnChangePlugin";
30
31
  import "@lexical/react/LexicalTreeView";
31
- const kt = ht({
32
+ import { D as Wt, E as Et } from "./empty-state-Bu1ocnPz.js";
33
+ import { DiffEditor as Ht } from "@monaco-editor/react";
34
+ const Nt = {
35
+ "aria-roledescription": "conversation",
36
+ initial: "instant",
37
+ resize: "instant",
38
+ role: "log"
39
+ }, jt = Ee(Ve, {
40
+ base: {
41
+ position: "relative",
42
+ flex: 1,
43
+ overflowY: "auto",
44
+ height: "full"
45
+ }
46
+ }, {
47
+ forwardProps: ["resize"],
48
+ defaultProps: Nt
49
+ }), Ut = Ee(Ve.Content, {
50
+ base: {
51
+ p: "0"
52
+ }
53
+ }, {
54
+ defaultProps: {
55
+ "aria-live": "polite",
56
+ role: "list"
57
+ }
58
+ }), qt = (t) => {
59
+ const e = y(4), {
60
+ isAtBottom: n,
61
+ scrollToBottom: i
62
+ } = Ge();
63
+ let r;
64
+ return e[0] !== n || e[1] !== t || e[2] !== i ? (r = !n && /* @__PURE__ */ l(ct, { axis: "horizontal", bottom: "md", children: /* @__PURE__ */ l(He, { rounded: "full", onClick: () => i(), variant: "outline", size: "xs", ...t, children: /* @__PURE__ */ l(gt, { size: 16 }) }) }), e[0] = n, e[1] = t, e[2] = i, e[3] = r) : r = e[3], r;
65
+ }, _e = {
66
+ Root: jt,
67
+ Viewport: Ut,
68
+ ScrollToBottom: qt
69
+ }, Vt = at({
32
70
  className: "ai-message",
33
71
  slots: ["root", "content"],
34
72
  base: {
@@ -134,214 +172,1195 @@ const kt = ht({
134
172
  shape: "rounded"
135
173
  }
136
174
  }), {
137
- withProvider: Dt,
138
- withContext: Mt
139
- } = bt({
140
- recipe: kt
141
- }), It = Dt("div", "root"), At = Mt("div", "content"), ve = {
142
- Root: It,
143
- Content: At
144
- }, jt = {
145
- "aria-roledescription": "conversation",
146
- initial: "instant",
147
- resize: "instant",
148
- role: "log"
149
- }, Ft = at(dt, {
150
- base: {
151
- position: "relative",
152
- flex: 1,
153
- overflowY: "auto",
154
- height: "full"
155
- }
156
- }, {
157
- forwardProps: ["resize"],
158
- defaultProps: jt
159
- }), Lt = at(dt.Content, {
160
- base: {
161
- p: "0"
162
- }
163
- }, {
164
- defaultProps: {
165
- "aria-live": "polite",
166
- role: "list"
167
- }
168
- }), Wt = (n) => {
169
- const t = N(4), {
170
- isAtBottom: e,
171
- scrollToBottom: i
172
- } = mt();
173
- let o;
174
- return t[0] !== e || t[1] !== n || t[2] !== i ? (o = !e && /* @__PURE__ */ l(gt, { axis: "horizontal", bottom: "md", children: /* @__PURE__ */ l(ct, { rounded: "full", onClick: () => i(), variant: "outline", size: "xs", ...n, children: /* @__PURE__ */ l(zt, { size: 16 }) }) }), t[0] = e, t[1] = n, t[2] = i, t[3] = o) : o = t[3], o;
175
- }, ye = {
176
- Root: Ft,
177
- Viewport: Lt,
178
- ScrollToBottom: Wt
179
- }, $t = (n) => {
175
+ withProvider: Gt,
176
+ withContext: Kt
177
+ } = dt({
178
+ recipe: Vt
179
+ }), Yt = Gt("div", "root"), Jt = Kt("div", "content"), Fe = {
180
+ Root: Yt,
181
+ Content: Jt
182
+ }, Xt = (t) => {
183
+ if (t == null) return null;
184
+ const e = typeof t == "string" ? t : JSON.stringify(t, null, 2);
185
+ return e.length === 0 ? null : e.length > 200 ? `${e.slice(0, 200)}...` : e;
186
+ }, co = (t) => {
187
+ const e = y(19), {
188
+ toolName: n,
189
+ toolInput: i,
190
+ onApprove: r,
191
+ onDeny: o
192
+ } = t;
193
+ let s;
194
+ e[0] !== i ? (s = Xt(i), e[0] = i, e[1] = s) : s = e[1];
195
+ const c = s;
196
+ let d;
197
+ e[2] !== n ? (d = /* @__PURE__ */ x(J, { textStyle: "label/S/medium", color: "fg", children: [
198
+ "Allow ",
199
+ /* @__PURE__ */ l($e, { size: "sm", children: n }),
200
+ "?"
201
+ ] }), e[2] = n, e[3] = d) : d = e[3];
202
+ let a;
203
+ e[4] !== c ? (a = c ? /* @__PURE__ */ l($e, { size: "sm", whiteSpace: "pre-wrap", maxH: "6rem", overflowY: "auto", children: c }) : null, e[4] = c, e[5] = a) : a = e[5];
204
+ let f;
205
+ e[6] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (f = /* @__PURE__ */ l(bt, { size: 14 }), e[6] = f) : f = e[6];
206
+ let u;
207
+ e[7] !== o ? (u = /* @__PURE__ */ x(Re, { size: "xs", variant: "outline", onClick: o, children: [
208
+ f,
209
+ "Deny"
210
+ ] }), e[7] = o, e[8] = u) : u = e[8];
211
+ let p;
212
+ e[9] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (p = /* @__PURE__ */ l(xt, { size: 14 }), e[9] = p) : p = e[9];
213
+ let m;
214
+ e[10] !== r ? (m = /* @__PURE__ */ x(Re, { size: "xs", colorPalette: "green", onClick: r, children: [
215
+ p,
216
+ "Allow"
217
+ ] }), e[10] = r, e[11] = m) : m = e[11];
218
+ let h;
219
+ e[12] !== u || e[13] !== m ? (h = /* @__PURE__ */ x(Ne, { gap: "xs", justifyContent: "flex-end", children: [
220
+ u,
221
+ m
222
+ ] }), e[12] = u, e[13] = m, e[14] = h) : h = e[14];
223
+ let g;
224
+ return e[15] !== d || e[16] !== a || e[17] !== h ? (g = /* @__PURE__ */ l(T, { px: "sm", py: "xs", mx: "sm", borderWidth: "1px", borderColor: "border.warning", borderRadius: "lg", bg: "bg.warning", children: /* @__PURE__ */ x(fe, { direction: "column", gap: "xs", children: [
225
+ d,
226
+ a,
227
+ h
228
+ ] }) }), e[15] = d, e[16] = a, e[17] = h, e[18] = g) : g = e[18], g;
229
+ }, Qt = (t) => {
180
230
  const {
181
- previousUserMessageCount: t,
182
- userMessageCount: e
183
- } = n;
184
- return t === 0 ? !1 : e > t;
231
+ previousUserMessageCount: e,
232
+ userMessageCount: n
233
+ } = t;
234
+ return e === 0 ? !1 : n > e;
185
235
  };
186
- function we(n) {
187
- const t = N(4), {
188
- userMessageCount: e
189
- } = n, {
236
+ function Zt(t) {
237
+ const e = y(4), {
238
+ userMessageCount: n
239
+ } = t, {
190
240
  scrollToBottom: i
191
- } = mt(), o = ut(e);
192
- let r, d;
193
- return t[0] !== i || t[1] !== e ? (r = () => {
194
- $t({
195
- previousUserMessageCount: o.current,
196
- userMessageCount: e
197
- }) && i(), o.current = e;
198
- }, d = [e, i], t[0] = i, t[1] = e, t[2] = r, t[3] = d) : (r = t[2], d = t[3]), ft(r, d), null;
241
+ } = Ge(), r = Ke(n);
242
+ let o, s;
243
+ return e[0] !== i || e[1] !== n ? (o = () => {
244
+ Qt({
245
+ previousUserMessageCount: r.current,
246
+ userMessageCount: n
247
+ }) && i(), r.current = n;
248
+ }, s = [n, i], e[0] = i, e[1] = n, e[2] = o, e[3] = s) : (o = e[2], s = e[3]), Ye(o, s), null;
199
249
  }
200
- const qt = (n) => {
201
- const t = N(22);
202
- let e, i, o, r;
203
- t[0] !== n ? ({
204
- title: r,
205
- shortcut: o,
206
- canInterrupt: e,
250
+ const en = (t) => {
251
+ const e = y(22);
252
+ let n, i, r, o;
253
+ e[0] !== t ? ({
254
+ title: o,
255
+ shortcut: r,
256
+ canInterrupt: n,
207
257
  ...i
208
- } = n, t[0] = n, t[1] = e, t[2] = i, t[3] = o, t[4] = r) : (e = t[1], i = t[2], o = t[3], r = t[4]);
209
- const d = i["aria-label"] ?? r;
210
- let p;
211
- t[5] !== e ? (p = e ? /* @__PURE__ */ l(Bt, { size: 16, strokeWidth: 2, fill: "currentColor" }) : /* @__PURE__ */ l(Tt, { size: 16, strokeWidth: 2 }), t[5] = e, t[6] = p) : p = t[6];
212
- const x = p;
258
+ } = t, e[0] = t, e[1] = n, e[2] = i, e[3] = r, e[4] = o) : (n = e[1], i = e[2], r = e[3], o = e[4]);
259
+ const s = i["aria-label"] ?? o;
260
+ let c;
261
+ e[5] !== n ? (c = n ? /* @__PURE__ */ l(yt, { size: 16, strokeWidth: 2, fill: "currentColor" }) : /* @__PURE__ */ l(St, { size: 16, strokeWidth: 2 }), e[5] = n, e[6] = c) : c = e[6];
262
+ const d = c;
213
263
  let a;
214
- t[7] !== d || t[8] !== x || t[9] !== i || t[10] !== r ? (a = /* @__PURE__ */ l(ct, { size: "sm", variant: "solid", borderRadius: "full", colorPalette: "primary", "aria-label": d, title: r, ...i, children: x }), t[7] = d, t[8] = x, t[9] = i, t[10] = r, t[11] = a) : a = t[11];
215
- const u = a;
216
- if (r) {
217
- let h;
218
- t[12] !== o || t[13] !== r ? (h = o ? /* @__PURE__ */ K(_t, { children: [
219
- r,
264
+ e[7] !== s || e[8] !== d || e[9] !== i || e[10] !== o ? (a = /* @__PURE__ */ l(He, { size: "sm", variant: "solid", borderRadius: "full", colorPalette: "primary", "aria-label": s, title: o, ...i, children: d }), e[7] = s, e[8] = d, e[9] = i, e[10] = o, e[11] = a) : a = e[11];
265
+ const f = a;
266
+ if (o) {
267
+ let u;
268
+ e[12] !== r || e[13] !== o ? (u = r ? /* @__PURE__ */ x(Ie, { children: [
269
+ o,
220
270
  " ",
221
- /* @__PURE__ */ l(xt, { fontSize: "xs", children: o })
222
- ] }) : r, t[12] = o, t[13] = r, t[14] = h) : h = t[14];
223
- const b = h;
271
+ /* @__PURE__ */ l(ft, { fontSize: "xs", children: r })
272
+ ] }) : o, e[12] = r, e[13] = o, e[14] = u) : u = e[14];
273
+ const p = u;
224
274
  let m;
225
- t[15] !== u ? (m = /* @__PURE__ */ l($.Trigger, { asChild: !0, children: u }), t[15] = u, t[16] = m) : m = t[16];
226
- let s;
227
- t[17] !== b ? (s = /* @__PURE__ */ l(St, { children: /* @__PURE__ */ l($.Positioner, { children: /* @__PURE__ */ l($.Content, { children: b }) }) }), t[17] = b, t[18] = s) : s = t[18];
228
- let f;
229
- return t[19] !== m || t[20] !== s ? (f = /* @__PURE__ */ K($.Root, { closeDelay: 50, openDelay: 100, children: [
275
+ e[15] !== f ? (m = /* @__PURE__ */ l(ue.Trigger, { asChild: !0, children: f }), e[15] = f, e[16] = m) : m = e[16];
276
+ let h;
277
+ e[17] !== p ? (h = /* @__PURE__ */ l(ut, { children: /* @__PURE__ */ l(ue.Positioner, { children: /* @__PURE__ */ l(ue.Content, { children: p }) }) }), e[17] = p, e[18] = h) : h = e[18];
278
+ let g;
279
+ return e[19] !== m || e[20] !== h ? (g = /* @__PURE__ */ x(ue.Root, { closeDelay: 50, openDelay: 100, children: [
230
280
  m,
231
- s
232
- ] }), t[19] = m, t[20] = s, t[21] = f) : f = t[21], f;
281
+ h
282
+ ] }), e[19] = m, e[20] = h, e[21] = g) : g = e[21], g;
233
283
  }
234
- return u;
235
- }, Re = (n) => {
236
- const t = N(60), {
237
- defaultState: e,
284
+ return f;
285
+ }, tn = (t) => {
286
+ const e = y(60), {
287
+ defaultState: n,
238
288
  onSubmit: i,
239
- onInterrupt: o,
240
- streaming: r,
241
- attachedResources: d,
242
- onClearAttachments: p,
243
- isDisabled: x,
289
+ onInterrupt: r,
290
+ streaming: o,
291
+ attachedResources: s,
292
+ onClearAttachments: c,
293
+ isDisabled: d,
244
294
  onChange: a,
245
- placeholder: u,
246
- attachmentList: h,
247
- actions: b
248
- } = n, m = i === void 0 ? Kt : i, s = r === void 0 ? !1 : r;
249
- let f;
250
- t[0] !== d ? (f = d === void 0 ? [] : d, t[0] = d, t[1] = f) : f = t[1];
251
- const U = f, g = x === void 0 ? !1 : x, [H, nt] = q(!1), [V, it] = q(e), [Y, st] = q(0);
252
- let P;
253
- t[2] !== e ? (P = () => rt(e), t[2] = e, t[3] = P) : P = t[3];
254
- const [C, J] = q(P), lt = ut(null);
255
- let E, k;
256
- t[4] !== e || t[5] !== a ? (E = () => {
257
- const c = rt(e);
258
- it(e), st(Nt), J(c), a?.(c);
259
- }, k = [e, a], t[4] = e, t[5] = a, t[6] = E, t[7] = k) : (E = t[6], k = t[7]), ft(E, k);
260
- let D;
261
- t[8] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (D = () => {
262
- nt(!0);
263
- const c = lt.current?.querySelector('[contenteditable="true"]');
264
- c instanceof HTMLElement && c.focus();
265
- }, t[8] = D) : D = t[8];
266
- const pt = D;
295
+ placeholder: f,
296
+ attachmentList: u,
297
+ actions: p
298
+ } = t, m = i === void 0 ? nn : i, h = o === void 0 ? !1 : o;
299
+ let g;
300
+ e[0] !== s ? (g = s === void 0 ? [] : s, e[0] = s, e[1] = g) : g = e[1];
301
+ const S = g, k = d === void 0 ? !1 : d, [P, A] = oe(!1), [I, D] = oe(n), [v, $] = oe(0);
302
+ let _;
303
+ e[2] !== n ? (_ = () => Pe(n), e[2] = n, e[3] = _) : _ = e[3];
304
+ const [C, O] = oe(_), F = Ke(null);
305
+ let B, R;
306
+ e[4] !== n || e[5] !== a ? (B = () => {
307
+ const w = Pe(n);
308
+ D(n), $(rn), O(w), a?.(w);
309
+ }, R = [n, a], e[4] = n, e[5] = a, e[6] = B, e[7] = R) : (B = e[6], R = e[7]), Ye(B, R);
267
310
  let M;
268
- t[9] !== e || t[10] !== a ? (M = () => {
269
- it(e), st(Ut);
270
- const c = rt(e);
271
- J(c), a?.(c);
272
- }, t[9] = e, t[10] = a, t[11] = M) : M = t[11];
273
- const O = M;
274
- let I;
275
- t[12] !== U || t[13] !== g || t[14] !== p || t[15] !== o || t[16] !== m || t[17] !== O || t[18] !== s || t[19] !== C ? (I = () => {
276
- if (g)
311
+ e[8] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (M = () => {
312
+ A(!0);
313
+ const w = F.current?.querySelector('[contenteditable="true"]');
314
+ w instanceof HTMLElement && w.focus();
315
+ }, e[8] = M) : M = e[8];
316
+ const ne = M;
317
+ let N;
318
+ e[9] !== n || e[10] !== a ? (N = () => {
319
+ D(n), $(on);
320
+ const w = Pe(n);
321
+ O(w), a?.(w);
322
+ }, e[9] = n, e[10] = a, e[11] = N) : N = e[11];
323
+ const re = N;
324
+ let W;
325
+ e[12] !== S || e[13] !== k || e[14] !== c || e[15] !== r || e[16] !== m || e[17] !== re || e[18] !== h || e[19] !== C ? (W = () => {
326
+ if (k)
277
327
  return;
278
- if (s) {
279
- o?.();
328
+ if (h) {
329
+ r?.();
280
330
  return;
281
331
  }
282
- const c = C.trim();
283
- c && (m(c, U), O(), p?.());
284
- }, t[12] = U, t[13] = g, t[14] = p, t[15] = o, t[16] = m, t[17] = O, t[18] = s, t[19] = C, t[20] = I) : I = t[20];
285
- const v = I, S = s && !!o;
286
- let A;
287
- t[21] !== u ? (A = u ? /* @__PURE__ */ l(Ct, { textStyle: "label/M/regular", color: "fg.subtle", pointerEvents: "none", position: "absolute", top: "0", children: u }) : void 0, t[21] = u, t[22] = A) : A = t[22];
288
- const X = A, G = H ? "blue.border" : "border.muted", Q = H ? "mid" : "low", Z = H ? "blue.border" : "border";
289
- let y;
290
- t[23] !== Z ? (y = {
291
- borderColor: Z,
292
- boxShadow: "mid"
293
- }, t[23] = Z, t[24] = y) : y = t[24];
332
+ const w = C.trim();
333
+ w && (m(w, S), re(), c?.());
334
+ }, e[12] = S, e[13] = k, e[14] = c, e[15] = r, e[16] = m, e[17] = re, e[18] = h, e[19] = C, e[20] = W) : W = e[20];
335
+ const z = W, H = h && !!r;
336
+ let se;
337
+ e[21] !== f ? (se = f ? /* @__PURE__ */ l(J, { textStyle: "label/M/regular", color: "fg.subtle", pointerEvents: "none", position: "absolute", top: "0", children: f }) : void 0, e[21] = f, e[22] = se) : se = e[22];
338
+ const xe = se, ye = P ? "blue.border" : "border.muted", Se = P ? "mid" : "low", ke = P ? "blue.border" : "border";
294
339
  let j;
295
- t[25] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (j = {
340
+ e[23] !== ke ? (j = {
341
+ borderColor: ke,
342
+ boxShadow: "mid"
343
+ }, e[23] = ke, e[24] = j) : j = e[24];
344
+ let le;
345
+ e[25] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (le = {
296
346
  borderColor: "blue.border",
297
347
  boxShadow: "mid"
298
- }, t[25] = j) : j = t[25];
299
- let F;
300
- t[26] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (F = () => nt(!1), t[26] = F) : F = t[26];
301
- const tt = !g;
302
- let w;
303
- t[27] !== a ? (w = (c) => {
304
- J(c), a?.(c);
305
- }, t[27] = a, t[28] = w) : w = t[28];
306
- let R;
307
- t[29] !== Y || t[30] !== V || t[31] !== v || t[32] !== X || t[33] !== tt || t[34] !== w ? (R = /* @__PURE__ */ l(Pt, { defaultState: V, isEditable: tt, placeholder: X, onChange: w, onSubmit: v }, Y), t[29] = Y, t[30] = V, t[31] = v, t[32] = X, t[33] = tt, t[34] = w, t[35] = R) : R = t[35];
308
- let L;
309
- t[36] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (L = /* @__PURE__ */ l(vt, {}), t[36] = L) : L = t[36];
310
- const et = S ? "Stop Response" : "Message Sending", ot = s ? void 0 : "Enter";
311
- let _;
312
- t[37] !== S || t[38] !== g || t[39] !== s || t[40] !== C ? (_ = s && !S || !s && !C.trim() || g, t[37] = S, t[38] = g, t[39] = s, t[40] = C, t[41] = _) : _ = t[41];
313
- let z;
314
- t[42] !== S || t[43] !== v || t[44] !== et || t[45] !== ot || t[46] !== _ ? (z = /* @__PURE__ */ l(qt, { canInterrupt: S, title: et, shortcut: ot, onClick: v, disabled: _ }), t[42] = S, t[43] = v, t[44] = et, t[45] = ot, t[46] = _, t[47] = z) : z = t[47];
315
- let B;
316
- t[48] !== b || t[49] !== z ? (B = /* @__PURE__ */ K(yt, { gap: "1", mt: "md", children: [
317
- b,
318
- L,
319
- z
320
- ] }), t[48] = b, t[49] = z, t[50] = B) : B = t[50];
321
- let T;
322
- t[51] !== h || t[52] !== R || t[53] !== B ? (T = /* @__PURE__ */ K(wt, { direction: "column", color: "fg", children: [
323
- h,
324
- R,
325
- B
326
- ] }), t[51] = h, t[52] = R, t[53] = B, t[54] = T) : T = t[54];
327
- let W;
328
- return t[55] !== G || t[56] !== Q || t[57] !== y || t[58] !== T ? (W = /* @__PURE__ */ l(Rt, { ref: lt, width: "100%", paddingX: "lg", paddingY: "md", bg: "bg", borderRadius: "md", borderWidth: "1px", borderStyle: "solid", borderColor: G, boxShadow: Q, transition: "box-shadow 0.2s ease-in-out, border-color 0.2s ease-in-out", _hover: y, _focusWithin: j, onClick: pt, onBlur: F, children: T }), t[55] = G, t[56] = Q, t[57] = y, t[58] = T, t[59] = W) : W = t[59], W;
348
+ }, e[25] = le) : le = e[25];
349
+ let ce;
350
+ e[26] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (ce = () => A(!1), e[26] = ce) : ce = e[26];
351
+ const Te = !k;
352
+ let U;
353
+ e[27] !== a ? (U = (w) => {
354
+ O(w), a?.(w);
355
+ }, e[27] = a, e[28] = U) : U = e[28];
356
+ let q;
357
+ e[29] !== v || e[30] !== I || e[31] !== z || e[32] !== xe || e[33] !== Te || e[34] !== U ? (q = /* @__PURE__ */ l(zt, { defaultState: I, isEditable: Te, placeholder: xe, onChange: U, onSubmit: z }, v), e[29] = v, e[30] = I, e[31] = z, e[32] = xe, e[33] = Te, e[34] = U, e[35] = q) : q = e[35];
358
+ let ae;
359
+ e[36] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (ae = /* @__PURE__ */ l(pt, {}), e[36] = ae) : ae = e[36];
360
+ const we = H ? "Stop Response" : "Message Sending", Ce = h ? void 0 : "Enter";
361
+ let V;
362
+ e[37] !== H || e[38] !== k || e[39] !== h || e[40] !== C ? (V = h && !H || !h && !C.trim() || k, e[37] = H, e[38] = k, e[39] = h, e[40] = C, e[41] = V) : V = e[41];
363
+ let G;
364
+ e[42] !== H || e[43] !== z || e[44] !== we || e[45] !== Ce || e[46] !== V ? (G = /* @__PURE__ */ l(en, { canInterrupt: H, title: we, shortcut: Ce, onClick: z, disabled: V }), e[42] = H, e[43] = z, e[44] = we, e[45] = Ce, e[46] = V, e[47] = G) : G = e[47];
365
+ let K;
366
+ e[48] !== p || e[49] !== G ? (K = /* @__PURE__ */ x(Ne, { gap: "1", mt: "md", children: [
367
+ p,
368
+ ae,
369
+ G
370
+ ] }), e[48] = p, e[49] = G, e[50] = K) : K = e[50];
371
+ let Y;
372
+ e[51] !== u || e[52] !== q || e[53] !== K ? (Y = /* @__PURE__ */ x(fe, { direction: "column", color: "fg", children: [
373
+ u,
374
+ q,
375
+ K
376
+ ] }), e[51] = u, e[52] = q, e[53] = K, e[54] = Y) : Y = e[54];
377
+ let de;
378
+ return e[55] !== ye || e[56] !== Se || e[57] !== j || e[58] !== Y ? (de = /* @__PURE__ */ l(T, { ref: F, width: "100%", paddingX: "lg", paddingY: "md", bg: "bg", borderRadius: "md", borderWidth: "1px", borderStyle: "solid", borderColor: ye, boxShadow: Se, transition: "box-shadow 0.2s ease-in-out, border-color 0.2s ease-in-out", _hover: j, _focusWithin: le, onClick: ne, onBlur: ce, children: Y }), e[55] = ye, e[56] = Se, e[57] = j, e[58] = Y, e[59] = de) : de = e[59], de;
329
379
  };
330
- function Kt() {
380
+ function nn() {
381
+ }
382
+ function rn(t) {
383
+ return t + 1;
331
384
  }
332
- function Nt(n) {
333
- return n + 1;
385
+ function on(t) {
386
+ return t + 1;
334
387
  }
335
- function Ut(n) {
336
- return n + 1;
388
+ const sn = (t = "") => JSON.stringify(Lt(t)), ln = (t) => {
389
+ const e = y(8);
390
+ let n, i;
391
+ e[0] !== t ? ({
392
+ children: n,
393
+ ...i
394
+ } = t, e[0] = t, e[1] = n, e[2] = i) : (n = e[1], i = e[2]);
395
+ let r;
396
+ e[3] !== n ? (r = /* @__PURE__ */ l(Je, { defaultState: n }), e[3] = n, e[4] = r) : r = e[4];
397
+ let o;
398
+ return e[5] !== i || e[6] !== r ? (o = /* @__PURE__ */ l(T, { ...i, children: r }), e[5] = i, e[6] = r, e[7] = o) : o = e[7], o;
399
+ }, cn = ln, Xe = {
400
+ shell: qe,
401
+ ls: Rt,
402
+ read_file: Bt,
403
+ write_file: _t,
404
+ delete_file: Pt,
405
+ patch: Ct,
406
+ upload_files: wt,
407
+ download_file: Tt,
408
+ move_file: kt
409
+ }, an = {
410
+ dot: $t,
411
+ danger: Dt,
412
+ search: At,
413
+ browser: vt,
414
+ file: It,
415
+ terminal: qe,
416
+ ...Xe
417
+ }, Me = "dot", dn = (t) => Object.hasOwn(Xe, t), un = (t) => an[t], Qe = (t) => {
418
+ if (!t) return Me;
419
+ const e = t.replace(/^tool-/, "");
420
+ if (dn(e)) return e;
421
+ switch (e) {
422
+ case "read":
423
+ return "file";
424
+ case "bash":
425
+ return "terminal";
426
+ case "apply_patch":
427
+ return "patch";
428
+ case "grep":
429
+ return "search";
430
+ case "glob":
431
+ return "file";
432
+ case "search":
433
+ return "search";
434
+ case "browser":
435
+ return "browser";
436
+ case "fs":
437
+ case "file":
438
+ return "file";
439
+ default:
440
+ return Me;
441
+ }
442
+ };
443
+ function ve(t) {
444
+ const e = t.lastIndexOf("/");
445
+ return e >= 0 ? t.slice(e + 1) : t;
446
+ }
447
+ function pe(t) {
448
+ if (!t) return null;
449
+ const e = t.split(" ")[0].trim();
450
+ if (e === "/dev/null") return null;
451
+ let n = e;
452
+ return (n.startsWith("a/") || n.startsWith("b/")) && (n = n.slice(2)), n.replace(/^\/+/, "").replace(/\\/g, "/");
453
+ }
454
+ const he = (t) => t.startsWith("--- "), Ae = (t) => t.startsWith("+++ "), De = (t) => t.startsWith("@@"), fn = (t) => t.startsWith("+") && !(Ae(t) || t === "+++"), pn = (t) => t.startsWith("-") && !(he(t) || t === "---"), mn = (t, e) => {
455
+ t.has(e) || t.set(e, {
456
+ additions: 0,
457
+ deletions: 0
458
+ });
459
+ }, hn = (t, e) => {
460
+ const n = t.get(e);
461
+ n && (n.additions += 1);
462
+ }, gn = (t, e) => {
463
+ const n = t.get(e);
464
+ n && (n.deletions += 1);
465
+ }, bn = (t, e, n) => {
466
+ if (he(t))
467
+ return {
468
+ ...e,
469
+ lastMinusHeader: pe(t.slice(4)),
470
+ inHunk: !1
471
+ };
472
+ if (Ae(t)) {
473
+ const r = pe(t.slice(4)) ?? e.lastMinusHeader;
474
+ return r && mn(n, r), {
475
+ ...e,
476
+ currentPath: r,
477
+ inHunk: !1
478
+ };
479
+ }
480
+ return e.currentPath ? De(t) ? {
481
+ ...e,
482
+ inHunk: !0
483
+ } : e.inHunk ? fn(t) ? (hn(n, e.currentPath), e) : (pn(t) && gn(n, e.currentPath), e) : e : e;
484
+ };
485
+ function Ze(t) {
486
+ if (!t || typeof t != "string") return [];
487
+ const e = /* @__PURE__ */ new Map();
488
+ let n = {
489
+ currentPath: null,
490
+ lastMinusHeader: null,
491
+ inHunk: !1
492
+ };
493
+ const i = t.split(/\r?\n/);
494
+ for (const r of i)
495
+ n = bn(r, n, e);
496
+ return Array.from(e.entries()).map(([r, {
497
+ additions: o,
498
+ deletions: s
499
+ }]) => ({
500
+ filePath: r,
501
+ additions: o,
502
+ deletions: s
503
+ }));
504
+ }
505
+ function xn(t) {
506
+ return Ze(t).map((e) => ({
507
+ kind: "diff",
508
+ fileName: ve(e.filePath),
509
+ filePath: e.filePath,
510
+ additions: e.additions,
511
+ deletions: e.deletions
512
+ }));
513
+ }
514
+ function yn(t) {
515
+ return Ze(t).map((e) => e.filePath);
516
+ }
517
+ const et = (t) => he(t) || t.startsWith("diff --git "), Sn = (t) => t.startsWith(" ") || t.startsWith("+") || t.startsWith("-") ? !1 : t.trim() !== "", kn = (t, e, n) => {
518
+ if (t.startsWith(" ")) {
519
+ const i = t.slice(1);
520
+ e.push(i), n.push(i);
521
+ return;
522
+ }
523
+ if (t.startsWith("-")) {
524
+ e.push(t.slice(1));
525
+ return;
526
+ }
527
+ t.startsWith("+") && n.push(t.slice(1));
528
+ }, Tn = (t, e, n, i) => {
529
+ let r = e;
530
+ for (; r < t.length; ) {
531
+ const o = t[r] || "";
532
+ if (et(o) || De(o) || Sn(o))
533
+ break;
534
+ kn(o, n, i), r += 1;
535
+ }
536
+ return (n.length > 0 || i.length > 0) && (n.push(""), i.push("")), r;
537
+ }, wn = (t, e) => {
538
+ const n = pe((t[e] || "").slice(4)), i = t[e + 1] || "";
539
+ if (!Ae(i)) return {
540
+ nextIndex: e + 1
541
+ };
542
+ const o = pe(i.slice(4)) ?? n ?? "", s = [], c = [];
543
+ let d = e + 2;
544
+ for (; d < t.length; ) {
545
+ const a = t[d] || "";
546
+ if (et(a)) break;
547
+ if (!De(a)) {
548
+ d += 1;
549
+ continue;
550
+ }
551
+ d = Tn(t, d + 1, s, c);
552
+ }
553
+ return {
554
+ nextIndex: d,
555
+ preview: {
556
+ filePath: o,
557
+ original: s.join(`
558
+ `),
559
+ modified: c.join(`
560
+ `)
561
+ }
562
+ };
563
+ };
564
+ function Cn(t) {
565
+ if (!t || typeof t != "string") return [];
566
+ const e = t.split(/\r?\n/), n = [];
567
+ let i = 0;
568
+ for (; i < e.length; ) {
569
+ const r = e[i] || "";
570
+ if (!he(r)) {
571
+ i += 1;
572
+ continue;
573
+ }
574
+ const {
575
+ nextIndex: o,
576
+ preview: s
577
+ } = wn(e, i);
578
+ s && n.push(s), i = Math.max(o, i + 1);
579
+ }
580
+ return n;
581
+ }
582
+ const Pn = {
583
+ apply_patch: "Apply patch",
584
+ read: "Read file",
585
+ bash: "Run",
586
+ grep: "Search files",
587
+ glob: "Find files",
588
+ skill: "Load skill"
589
+ }, ze = {
590
+ pending: "queued",
591
+ error: "failed",
592
+ "output-error": "failed",
593
+ "input-streaming": "running",
594
+ "input-available": "queued"
595
+ }, tt = (t) => t.replace(/^tool-/, ""), _n = (t) => t.split(" ").filter((e) => e.length > 0).map((e) => e[0].toUpperCase() + e.slice(1)).join(" "), Bn = (t) => tt(t.tool ?? "tool"), Rn = (t) => {
596
+ const e = tt(t);
597
+ return Pn[e] ?? _n(e.replace(/_/g, " "));
598
+ }, In = (t) => !t || typeof t != "string" ? null : ze[t] ? ze[t] : t.includes("stream") ? "running" : null, nt = (t) => t === "error" || t === "output-error", Q = (t) => nt(t.state?.status) ? {
599
+ type: "icon",
600
+ icon: "danger"
601
+ } : {
602
+ type: "icon",
603
+ icon: Qe(Bn(t))
604
+ }, Z = (t, e, n) => {
605
+ const r = [{
606
+ kind: "text",
607
+ text: n ?? Rn(t.tool ?? "tool"),
608
+ bold: !0
609
+ }];
610
+ e && r.push({
611
+ kind: "text",
612
+ text: e,
613
+ muted: !0
614
+ });
615
+ const o = In(t.state?.status);
616
+ return o && r.push({
617
+ kind: "text",
618
+ text: o,
619
+ muted: !0
620
+ }), r;
621
+ }, ee = (t) => {
622
+ const e = t.state?.input;
623
+ return !e || typeof e != "object" || Array.isArray(e) ? null : e;
624
+ }, ge = (t) => {
625
+ const e = t.state?.output;
626
+ return !e || typeof e != "object" || Array.isArray(e) ? null : e;
627
+ }, b = (t) => typeof t == "string" && t.trim().length > 0 ? t : null, me = (t) => !t || typeof t != "object" || Array.isArray(t) ? null : t, vn = (t, e) => {
628
+ const n = me(t.state);
629
+ return n ? me(n[e]) : null;
630
+ }, An = (t) => t.replace(/\\/g, "/").replace(/^\/+/, ""), Dn = (t) => t.includes("--- ") && t.includes("+++ ") && t.includes("@@"), rt = (t) => {
631
+ const e = ge(t);
632
+ return [vn(t, "metadata"), me(e?.metadata)].filter(Boolean);
633
+ }, $n = (t) => {
634
+ const e = me(t);
635
+ if (!e) return null;
636
+ const n = b(e.filePath) ?? b(e.relativePath) ?? b(e.path);
637
+ return n ? {
638
+ filePath: An(n),
639
+ additions: typeof e.additions == "number" ? e.additions : 0,
640
+ deletions: typeof e.deletions == "number" ? e.deletions : 0,
641
+ diff: b(e.diff) ?? void 0,
642
+ before: b(e.before) ?? void 0,
643
+ after: b(e.after) ?? void 0
644
+ } : null;
645
+ }, ot = (t) => {
646
+ const e = [];
647
+ for (const n of rt(t)) {
648
+ const i = Array.isArray(n.files) ? n.files : [];
649
+ for (const r of i) {
650
+ const o = $n(r);
651
+ o && e.push(o);
652
+ }
653
+ }
654
+ return e;
655
+ }, Fn = (t) => {
656
+ const e = ee(t), n = b(e?.diff);
657
+ if (n) return n;
658
+ for (const o of rt(t)) {
659
+ const s = b(o.diff);
660
+ if (s) return s;
661
+ }
662
+ const i = ot(t).map((o) => o.diff).filter((o) => !!o);
663
+ if (i.length > 0) return i.join(`
664
+ `);
665
+ const r = b(e?.patchText);
666
+ return r && Dn(r) ? r : null;
667
+ }, Mn = (t) => {
668
+ const e = /* @__PURE__ */ new Set(), n = [];
669
+ for (const i of t)
670
+ e.has(i.filePath) || (e.add(i.filePath), n.push({
671
+ kind: "diff",
672
+ fileName: ve(i.filePath),
673
+ filePath: i.filePath,
674
+ additions: i.additions,
675
+ deletions: i.deletions
676
+ }));
677
+ return n;
678
+ }, zn = (t) => Array.from(new Set(t.map((e) => e.filePath))), be = (t) => {
679
+ const e = ge(t);
680
+ return b(t.state?.output) ?? b(e?.returnDisplay) ?? b(e?.preview) ?? b(e?.stdout);
681
+ }, Ln = (t) => {
682
+ const e = t.match(/<skill_content(?:\s+name="([^"]+)")?>([\s\S]*?)<\/skill_content>/);
683
+ return e ? {
684
+ skillName: b(e[1]) ?? void 0,
685
+ content: b(e[2]) ?? ""
686
+ } : null;
687
+ }, On = (t) => {
688
+ const e = ee(t);
689
+ return b(e?.name) ?? b(e?.skillName) ?? b(e?.skill) ?? b(e?.skill_name) ?? void 0;
690
+ }, Wn = (t) => ({
691
+ kind: "link",
692
+ text: ve(t),
693
+ filePath: t
694
+ }), te = (t, e) => !nt(t.state?.status) || !t.state?.errorText ? e : [{
695
+ type: "comment",
696
+ text: t.state.errorText
697
+ }, ...e], En = (t) => {
698
+ const e = Fn(t), n = ot(t), i = Z(t, void 0, "Apply patch"), r = xn(e ?? void 0);
699
+ r.length > 0 ? i.push(...r) : i.push(...Mn(n));
700
+ const o = [], s = Cn(e ?? void 0);
701
+ for (const c of s)
702
+ o.push({
703
+ type: "diff",
704
+ language: "diff",
705
+ original: c.original,
706
+ modified: c.modified,
707
+ sideBySide: !1
708
+ });
709
+ if (o.length === 0)
710
+ for (const c of n)
711
+ !c.before && !c.after || o.push({
712
+ type: "diff",
713
+ language: "diff",
714
+ original: c.before ?? "",
715
+ modified: c.after ?? "",
716
+ sideBySide: !1
717
+ });
718
+ if (o.length === 0) {
719
+ const c = yn(e ?? void 0);
720
+ c.length === 0 && c.push(...zn(n)), c.length > 0 && o.push({
721
+ type: "references",
722
+ references: c
723
+ });
724
+ }
725
+ return {
726
+ indicator: Q(t),
727
+ title: i,
728
+ blocks: te(t, o)
729
+ };
730
+ }, Hn = (t) => {
731
+ const e = ee(t), n = ge(t), i = b(e?.filePath) ?? b(e?.file) ?? b(n?.filePath) ?? b(n?.file) ?? b(n?.path) ?? void 0, r = Z(t, void 0, "Read file");
732
+ return i && r.push(Wn(i)), {
733
+ indicator: Q(t),
734
+ title: r,
735
+ blocks: te(t, [])
736
+ };
737
+ }, Nn = (t) => {
738
+ const e = ee(t), n = ge(t), i = b(e?.command) ?? void 0, r = Z(t, i, "Run command"), o = [], s = be(t);
739
+ s && o.push({
740
+ type: "code",
741
+ language: "text",
742
+ code: s
743
+ });
744
+ const c = b(n?.stderr);
745
+ return c && c !== s && o.push({
746
+ type: "code",
747
+ language: "text",
748
+ code: c
749
+ }), typeof n?.exitCode == "number" && o.push({
750
+ type: "text",
751
+ text: `Exit code: ${n.exitCode}`
752
+ }), {
753
+ indicator: Q(t),
754
+ title: r,
755
+ blocks: te(t, o)
756
+ };
757
+ }, jn = (t) => {
758
+ const e = ee(t), n = be(t), i = b(e?.pattern) ?? void 0, r = Z(t, i, "Search files"), o = n ? [{
759
+ type: "code",
760
+ language: "text",
761
+ code: n
762
+ }] : [];
763
+ return {
764
+ indicator: Q(t),
765
+ title: r,
766
+ blocks: te(t, o)
767
+ };
768
+ }, Un = (t) => {
769
+ const e = ee(t), n = be(t), i = b(e?.pattern) ?? void 0, r = Z(t, i, "Find files"), o = [];
770
+ if (n) {
771
+ const s = n.split(/\r?\n/).map((c) => c.trim()).filter((c) => c.length > 0);
772
+ s.length > 0 && o.push({
773
+ type: "references",
774
+ references: s
775
+ });
776
+ }
777
+ return {
778
+ indicator: Q(t),
779
+ title: r,
780
+ blocks: te(t, o)
781
+ };
782
+ }, qn = (t) => {
783
+ const e = be(t), n = e ? Ln(e) : null, i = On(t) ?? n?.skillName, r = Z(t, i, "Load skill"), o = n?.content ?? e, s = o ? [{
784
+ type: "code",
785
+ language: "markdown",
786
+ code: o
787
+ }] : [];
788
+ return {
789
+ indicator: Q(t),
790
+ title: r,
791
+ blocks: te(t, s)
792
+ };
793
+ }, Le = () => ({
794
+ apply_patch: En,
795
+ read: Hn,
796
+ bash: Nn,
797
+ grep: jn,
798
+ glob: Un,
799
+ skill: qn
800
+ }), Oe = {
801
+ pending: "queued",
802
+ error: "failed",
803
+ "output-error": "failed",
804
+ "input-streaming": "running",
805
+ "input-available": "queued"
806
+ }, it = (t) => t.replace(/^tool-/, ""), Vn = (t) => t.split(" ").filter((e) => e.length > 0).map((e) => e[0].toUpperCase() + e.slice(1)).join(" "), Gn = (t) => {
807
+ const e = it(t ?? "tool").replace(/_/g, " ");
808
+ return Vn(e);
809
+ }, st = (t) => t === "error" || t === "output-error", Kn = (t) => st(t.state?.status) ? {
810
+ type: "icon",
811
+ icon: "danger"
812
+ } : {
813
+ type: "icon",
814
+ icon: Qe(t.tool ?? "tool")
815
+ }, Yn = (t) => !t || typeof t != "string" ? null : Oe[t] ? Oe[t] : t.includes("stream") ? "running" : null, We = (t) => {
816
+ if (typeof t == "string") return t;
817
+ if (t == null) return null;
818
+ try {
819
+ return JSON.stringify(t, null, 2);
820
+ } catch {
821
+ return null;
822
+ }
823
+ }, Jn = (t) => {
824
+ const e = [];
825
+ st(t.state?.status) && t.state?.errorText && e.push({
826
+ type: "comment",
827
+ text: t.state.errorText
828
+ });
829
+ const n = We(t.state?.input);
830
+ n && e.push({
831
+ type: "code",
832
+ language: "json",
833
+ code: n
834
+ });
835
+ const i = We(t.state?.output);
836
+ return i && e.push({
837
+ type: "code",
838
+ language: "json",
839
+ code: i
840
+ }), e;
841
+ }, Xn = (t) => {
842
+ const e = [{
843
+ kind: "text",
844
+ text: Gn(t.tool),
845
+ bold: !0
846
+ }], n = Yn(t.state?.status);
847
+ return n && e.push({
848
+ kind: "text",
849
+ text: n,
850
+ muted: !0
851
+ }), {
852
+ indicator: Kn(t),
853
+ title: e,
854
+ blocks: Jn(t)
855
+ };
856
+ }, Qn = (t) => t ? {
857
+ ...Le(),
858
+ ...t
859
+ } : Le(), Zn = (t, e) => {
860
+ const n = t.tool ?? "tool";
861
+ return e[n] ?? e[it(n)];
862
+ }, er = (t, e, n) => {
863
+ const i = Zn(t, e);
864
+ if (i) {
865
+ const r = i(t, n);
866
+ if (r) return r;
867
+ }
868
+ return Xn(t);
869
+ }, tr = (t, e) => {
870
+ const n = Qn(e?.toolRenderers);
871
+ return {
872
+ items: t.map((r) => er(r, n, e))
873
+ };
874
+ }, nr = {
875
+ base: "vs-dark",
876
+ inherit: !0,
877
+ rules: [],
878
+ colors: {
879
+ "editor.background": "#0a0d15",
880
+ "editor.foreground": "#f5f5f5",
881
+ "editor.lineHighlightBackground": "#22252C",
882
+ "editorCursor.foreground": "#A7A7A7",
883
+ "editorWhitespace.foreground": "#3B3B3B",
884
+ "editorIndentGuide.background": "#404040",
885
+ "editorIndentGuide.activeBackground": "#707070"
886
+ }
887
+ };
888
+ function rr(t) {
889
+ const e = y(11), {
890
+ original: n,
891
+ modified: i,
892
+ language: r,
893
+ sideBySide: o,
894
+ disableScroll: s
895
+ } = t, c = r === void 0 ? "plaintext" : r, d = o === void 0 ? !1 : o, a = s === void 0 ? !0 : s;
896
+ let f;
897
+ e[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (f = {
898
+ enabled: !1
899
+ }, e[0] = f) : f = e[0];
900
+ let u;
901
+ e[1] !== a ? (u = a ? {
902
+ scrollbar: {
903
+ vertical: "hidden",
904
+ horizontal: "hidden",
905
+ useShadows: !1,
906
+ alwaysConsumeMouseWheel: !1
907
+ },
908
+ overviewRulerLanes: 0
909
+ } : {}, e[1] = a, e[2] = u) : u = e[2];
910
+ let p;
911
+ e[3] !== d || e[4] !== u ? (p = {
912
+ renderSideBySide: d,
913
+ readOnly: !0,
914
+ fontSize: 11,
915
+ minimap: f,
916
+ wordWrap: "on",
917
+ scrollBeyondLastLine: !1,
918
+ ...u
919
+ }, e[3] = d, e[4] = u, e[5] = p) : p = e[5];
920
+ const m = p;
921
+ let h;
922
+ return e[6] !== c || e[7] !== i || e[8] !== m || e[9] !== n ? (h = /* @__PURE__ */ l(Ht, { width: "100%", height: "100%", original: n, modified: i, language: c, theme: "ps-theme", options: m, beforeMount: ir, onMount: or }), e[6] = c, e[7] = i, e[8] = m, e[9] = n, e[10] = h) : h = e[10], h;
923
+ }
924
+ function or(t, e) {
925
+ e.editor.setTheme("ps-theme");
926
+ }
927
+ function ir(t) {
928
+ t.editor.defineTheme("ps-theme", nr);
929
+ }
930
+ const E = mt, lt = (t, e, n, i = !1) => {
931
+ i && t.stopPropagation(), e.href || t.preventDefault(), e.filePath && n?.(e.filePath);
932
+ };
933
+ function sr(t) {
934
+ const e = y(6), {
935
+ seg: n
936
+ } = t;
937
+ let i;
938
+ e[0] !== n.alt || e[1] !== n.src ? (i = /* @__PURE__ */ l(X.Image, { src: n.src, alt: n.alt }), e[0] = n.alt, e[1] = n.src, e[2] = i) : i = e[2];
939
+ let r;
940
+ e[3] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (r = /* @__PURE__ */ l(X.Fallback, {}), e[3] = r) : r = e[3];
941
+ let o;
942
+ return e[4] !== i ? (o = /* @__PURE__ */ x(X.Root, { width: "1.5rem", height: "1.5rem", children: [
943
+ i,
944
+ r
945
+ ] }), e[4] = i, e[5] = o) : o = e[5], o;
946
+ }
947
+ function lr(t) {
948
+ const e = y(9), {
949
+ seg: n,
950
+ onOpenFile: i
951
+ } = t, r = n.additions ?? 0, o = n.deletions ?? 0;
952
+ let s;
953
+ e[0] !== i || e[1] !== n.fileName || e[2] !== n.filePath ? (s = () => {
954
+ const d = n.filePath ?? n.fileName;
955
+ i?.(d);
956
+ }, e[0] = i, e[1] = n.fileName, e[2] = n.filePath, e[3] = s) : s = e[3];
957
+ let c;
958
+ return e[4] !== n.fileName || e[5] !== r || e[6] !== o || e[7] !== s ? (c = /* @__PURE__ */ l(Wt, { fileName: n.fileName, additions: r, deletions: o, onClickFileLink: s }), e[4] = n.fileName, e[5] = r, e[6] = o, e[7] = s, e[8] = c) : c = e[8], c;
959
+ }
960
+ function cr(t) {
961
+ const e = y(13), {
962
+ seg: n,
963
+ onOpenFile: i
964
+ } = t, r = n.bold ? "medium" : void 0, o = !!(n.href || n.filePath), s = n.href ?? "#", c = (n.muted, "fg.muted"), d = o ? "pointer" : "default";
965
+ let a;
966
+ e[0] !== i || e[1] !== n ? (a = (m) => lt(m, n, i, !0), e[0] = i, e[1] = n, e[2] = a) : a = e[2];
967
+ const f = n.muted ? "fg.muted" : "fg.blue-dark";
968
+ let u;
969
+ e[3] !== f ? (u = {
970
+ textDecoration: "underline",
971
+ color: f
972
+ }, e[3] = f, e[4] = u) : u = e[4];
973
+ let p;
974
+ return e[5] !== r || e[6] !== n.text || e[7] !== s || e[8] !== c || e[9] !== d || e[10] !== a || e[11] !== u ? (p = /* @__PURE__ */ l(je, { href: s, fontWeight: r, color: c, textDecoration: "none", cursor: d, onClick: a, _hover: u, children: n.text }), e[5] = r, e[6] = n.text, e[7] = s, e[8] = c, e[9] = d, e[10] = a, e[11] = u, e[12] = p) : p = e[12], p;
975
+ }
976
+ function ar(t) {
977
+ const e = y(12), {
978
+ seg: n,
979
+ onOpenFile: i
980
+ } = t, r = n.bold ? "medium" : void 0, o = n.href ?? "#", s = n.muted ? "fg.muted" : "accent.primary";
981
+ let c;
982
+ e[0] !== i || e[1] !== n ? (c = (u) => lt(u, n, i), e[0] = i, e[1] = n, e[2] = c) : c = e[2];
983
+ const d = n.muted ? "fg.muted" : "accent.primary";
984
+ let a;
985
+ e[3] !== d ? (a = {
986
+ color: d,
987
+ textDecoration: "underline"
988
+ }, e[3] = d, e[4] = a) : a = e[4];
989
+ let f;
990
+ return e[5] !== r || e[6] !== n.text || e[7] !== o || e[8] !== s || e[9] !== c || e[10] !== a ? (f = /* @__PURE__ */ l(je, { href: o, fontWeight: r, color: s, textDecoration: "underline", onClick: c, _hover: a, children: n.text }), e[5] = r, e[6] = n.text, e[7] = o, e[8] = s, e[9] = c, e[10] = a, e[11] = f) : f = e[11], f;
991
+ }
992
+ function dr(t) {
993
+ const e = y(6), {
994
+ seg: n,
995
+ isClickable: i
996
+ } = t, r = n.bold ? "medium" : void 0, o = i && !n.muted ? "fg" : "fg.muted";
997
+ let s;
998
+ e[0] !== o ? (s = {
999
+ color: o
1000
+ }, e[0] = o, e[1] = s) : s = e[1];
1001
+ let c;
1002
+ return e[2] !== n.text || e[3] !== r || e[4] !== s ? (c = /* @__PURE__ */ l(ie, { fontWeight: r, color: "fg.muted", _groupHover: s, children: n.text }), e[2] = n.text, e[3] = r, e[4] = s, e[5] = c) : c = e[5], c;
1003
+ }
1004
+ function ur(t) {
1005
+ const e = y(11), {
1006
+ seg: n,
1007
+ isClickable: i,
1008
+ onOpenFile: r
1009
+ } = t;
1010
+ switch (n.kind) {
1011
+ case "avatar": {
1012
+ let o;
1013
+ return e[0] !== n ? (o = /* @__PURE__ */ l(sr, { seg: n }), e[0] = n, e[1] = o) : o = e[1], o;
1014
+ }
1015
+ case "diff": {
1016
+ let o;
1017
+ return e[2] !== r || e[3] !== n ? (o = /* @__PURE__ */ l(lr, { seg: n, onOpenFile: r }), e[2] = r, e[3] = n, e[4] = o) : o = e[4], o;
1018
+ }
1019
+ case "link": {
1020
+ let o;
1021
+ return e[5] !== r || e[6] !== n ? (o = n.variant === "bubble" ? /* @__PURE__ */ l(cr, { seg: n, onOpenFile: r }) : /* @__PURE__ */ l(ar, { seg: n, onOpenFile: r }), e[5] = r, e[6] = n, e[7] = o) : o = e[7], o;
1022
+ }
1023
+ case "text": {
1024
+ let o;
1025
+ return e[8] !== i || e[9] !== n ? (o = /* @__PURE__ */ l(dr, { seg: n, isClickable: i }), e[8] = i, e[9] = n, e[10] = o) : o = e[10], o;
1026
+ }
1027
+ default:
1028
+ return null;
1029
+ }
1030
+ }
1031
+ function fr(t) {
1032
+ const e = y(10), {
1033
+ ind: n
1034
+ } = t;
1035
+ if (!n || n.type === "none")
1036
+ return null;
1037
+ if (n.type === "icon") {
1038
+ let s;
1039
+ e[0] !== n.icon ? (s = un(n.icon), e[0] = n.icon, e[1] = s) : s = e[1];
1040
+ const c = s;
1041
+ let d;
1042
+ return e[2] !== c ? (d = /* @__PURE__ */ l(E.Indicator, { outline: "none", shadow: "none", border: "none", background: "bg", color: "fg", children: /* @__PURE__ */ l(ie, { display: "inline-flex", alignItems: "center", children: /* @__PURE__ */ l(c, { size: 14, strokeWidth: 1 }) }) }), e[2] = c, e[3] = d) : d = e[3], d;
1043
+ }
1044
+ let i;
1045
+ e[4] !== n.alt || e[5] !== n.src ? (i = /* @__PURE__ */ l(X.Image, { src: n.src, alt: n.alt }), e[4] = n.alt, e[5] = n.src, e[6] = i) : i = e[6];
1046
+ let r;
1047
+ e[7] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (r = /* @__PURE__ */ l(X.Fallback, {}), e[7] = r) : r = e[7];
1048
+ let o;
1049
+ return e[8] !== i ? (o = /* @__PURE__ */ l(E.Indicator, { children: /* @__PURE__ */ x(X.Root, { boxSize: "full", children: [
1050
+ i,
1051
+ r
1052
+ ] }) }), e[8] = i, e[9] = o) : o = e[9], o;
1053
+ }
1054
+ function pr(t) {
1055
+ const e = y(5), {
1056
+ code: n,
1057
+ language: i
1058
+ } = t, r = i ? `${i} code block` : "code block";
1059
+ let o;
1060
+ e[0] !== n ? (o = /* @__PURE__ */ l(T, { as: "code", children: n }), e[0] = n, e[1] = o) : o = e[1];
1061
+ let s;
1062
+ return e[2] !== r || e[3] !== o ? (s = /* @__PURE__ */ l(T, { as: "pre", background: "bg.muted", color: "fg", borderRadius: "md", padding: "sm", fontFamily: "mono", fontSize: "xs", lineHeight: "shorter", overflowX: "auto", whiteSpace: "pre", "aria-label": r, children: o }), e[2] = r, e[3] = o, e[4] = s) : s = e[4], s;
1063
+ }
1064
+ function mr(t) {
1065
+ const e = y(26), {
1066
+ b: n,
1067
+ onOpenFile: i
1068
+ } = t;
1069
+ switch (n.type) {
1070
+ case "comment": {
1071
+ let r;
1072
+ e[0] !== n.text ? (r = /* @__PURE__ */ l(L.Body, { children: n.text }), e[0] = n.text, e[1] = r) : r = e[1];
1073
+ let o;
1074
+ e[2] !== n.reactions ? (o = n.reactions?.clap ? /* @__PURE__ */ l(L.Footer, { children: /* @__PURE__ */ x(Re, { children: [
1075
+ "👏 ",
1076
+ n.reactions.clap
1077
+ ] }) }) : null, e[2] = n.reactions, e[3] = o) : o = e[3];
1078
+ let s;
1079
+ return e[4] !== r || e[5] !== o ? (s = /* @__PURE__ */ x(L.Root, { children: [
1080
+ r,
1081
+ o
1082
+ ] }), e[4] = r, e[5] = o, e[6] = s) : s = e[6], s;
1083
+ }
1084
+ case "code": {
1085
+ let r;
1086
+ return e[7] !== n.code || e[8] !== n.language ? (r = /* @__PURE__ */ l(L.Root, { border: "0", padding: "0", children: /* @__PURE__ */ l(L.Body, { padding: "0", children: /* @__PURE__ */ l(pr, { language: n.language, code: n.code }) }) }), e[7] = n.code, e[8] = n.language, e[9] = r) : r = e[9], r;
1087
+ }
1088
+ case "diff": {
1089
+ const r = n.sideBySide ?? !1;
1090
+ let o;
1091
+ return e[10] !== n.language || e[11] !== n.modified || e[12] !== n.original || e[13] !== r ? (o = /* @__PURE__ */ l(L.Root, { border: "0", padding: "0", children: /* @__PURE__ */ l(L.Body, { padding: "0", children: /* @__PURE__ */ l(T, { height: "240px", minW: "320px", overflow: "hidden", children: /* @__PURE__ */ l(rr, { original: n.original, modified: n.modified, language: n.language, sideBySide: r, disableScroll: !0 }) }) }) }), e[10] = n.language, e[11] = n.modified, e[12] = n.original, e[13] = r, e[14] = o) : o = e[14], o;
1092
+ }
1093
+ case "text": {
1094
+ let r;
1095
+ return e[15] !== n.text ? (r = /* @__PURE__ */ l(L.Root, { background: "transparent", children: /* @__PURE__ */ l(L.Body, { padding: "sm", children: /* @__PURE__ */ l(J, { textStyle: "label/S/regular", children: n.text }) }) }), e[15] = n.text, e[16] = r) : r = e[16], r;
1096
+ }
1097
+ case "references": {
1098
+ let r;
1099
+ e[17] !== n.references ? (r = n.references.map(hr), e[17] = n.references, e[18] = r) : r = e[18];
1100
+ let o;
1101
+ return e[19] !== r ? (o = /* @__PURE__ */ l(Ue, { mt: "xs", gap: "xs", flexDir: "row", flexWrap: "wrap", children: r }), e[19] = r, e[20] = o) : o = e[20], o;
1102
+ }
1103
+ case "component": {
1104
+ let r;
1105
+ e[21] !== n || e[22] !== i ? (r = n.render({
1106
+ onOpenFile: i
1107
+ }), e[21] = n, e[22] = i, e[23] = r) : r = e[23];
1108
+ let o;
1109
+ return e[24] !== r ? (o = /* @__PURE__ */ l(Ie, { children: r }), e[24] = r, e[25] = o) : o = e[25], o;
1110
+ }
1111
+ }
1112
+ }
1113
+ function hr(t) {
1114
+ return /* @__PURE__ */ l(Ot, { fileName: t }, t);
1115
+ }
1116
+ function gr(t) {
1117
+ const e = y(22), {
1118
+ item: n,
1119
+ itemKey: i,
1120
+ isOpen: r,
1121
+ canExpand: o,
1122
+ hasBlocks: s,
1123
+ onToggle: c,
1124
+ onOpenFile: d
1125
+ } = t;
1126
+ let a;
1127
+ e[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (a = /* @__PURE__ */ l(E.Separator, {}), e[0] = a) : a = e[0];
1128
+ let f;
1129
+ e[1] !== n.indicator ? (f = /* @__PURE__ */ x(E.Connector, { children: [
1130
+ a,
1131
+ /* @__PURE__ */ l(fr, { ind: n.indicator })
1132
+ ] }), e[1] = n.indicator, e[2] = f) : f = e[2];
1133
+ let u;
1134
+ e[3] !== o || e[4] !== r || e[5] !== n.title || e[6] !== i || e[7] !== d || e[8] !== c ? (u = n.title.length > 0 && /* @__PURE__ */ l(E.Title, { className: "group", fontWeight: "normal", display: "flex", alignItems: "center", justifyContent: "space-between", cursor: o ? "pointer" : "default", onClick: o ? () => c(i) : void 0, children: /* @__PURE__ */ x(ie, { display: "inline-flex", alignItems: "center", gap: "sm", flexWrap: "wrap", children: [
1135
+ /* @__PURE__ */ l(ie, { display: "inline-flex", alignItems: "center", gap: "xs", flexWrap: "wrap", children: n.title.map((g, S) => /* @__PURE__ */ l(ur, { seg: g, isClickable: o, onOpenFile: d }, S)) }),
1136
+ o ? /* @__PURE__ */ l(ie, { display: "inline-flex", alignItems: "center", transition: "transform 200ms ease, color 200ms ease", transform: r ? "rotate(0deg)" : "rotate(-180deg)", color: "transparent", _groupHover: {
1137
+ color: "fg"
1138
+ }, children: /* @__PURE__ */ l(Ft, { size: 12 }) }) : null
1139
+ ] }) }), e[3] = o, e[4] = r, e[5] = n.title, e[6] = i, e[7] = d, e[8] = c, e[9] = u) : u = e[9];
1140
+ let p;
1141
+ e[10] !== s || e[11] !== r || e[12] !== n.blocks || e[13] !== d ? (p = s ? /* @__PURE__ */ l(T, { display: "grid", gridTemplateRows: r ? "1fr" : "0fr", transition: "grid-template-rows 220ms ease", children: r ? /* @__PURE__ */ l(T, { overflow: "hidden", opacity: 1, transform: "translateY(0)", transition: "opacity 200ms ease, transform 200ms ease", children: n.blocks.map((g, S) => /* @__PURE__ */ l(T, { children: /* @__PURE__ */ l(mr, { b: g, onOpenFile: d }) }, S)) }) : null }) : null, e[10] = s, e[11] = r, e[12] = n.blocks, e[13] = d, e[14] = p) : p = e[14];
1142
+ let m;
1143
+ e[15] !== u || e[16] !== p ? (m = /* @__PURE__ */ x(E.Content, { pb: "xs", children: [
1144
+ u,
1145
+ p
1146
+ ] }), e[15] = u, e[16] = p, e[17] = m) : m = e[17];
1147
+ let h;
1148
+ return e[18] !== i || e[19] !== f || e[20] !== m ? (h = /* @__PURE__ */ x(E.Item, { gap: "xs", children: [
1149
+ f,
1150
+ m
1151
+ ] }, i), e[18] = i, e[19] = f, e[20] = m, e[21] = h) : h = e[21], h;
1152
+ }
1153
+ function br(t) {
1154
+ const e = y(11), {
1155
+ data: n,
1156
+ onOpenFile: i
1157
+ } = t;
1158
+ let r;
1159
+ e[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (r = {}, e[0] = r) : r = e[0];
1160
+ const [o, s] = oe(r), c = xr;
1161
+ let d;
1162
+ e[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (d = (p) => {
1163
+ s((m) => ({
1164
+ ...m,
1165
+ [p]: !m[p]
1166
+ }));
1167
+ }, e[1] = d) : d = e[1];
1168
+ const a = d;
1169
+ let f;
1170
+ if (e[2] !== n.items || e[3] !== o || e[4] !== i) {
1171
+ let p;
1172
+ e[6] !== o || e[7] !== i ? (p = (m, h) => {
1173
+ const g = c(m, h), S = (m.blocks?.length ?? 0) > 0, k = (m.expandable ?? !0) && S, P = k ? o[g] ?? !1 : S;
1174
+ return /* @__PURE__ */ l(gr, { item: m, itemKey: g, isOpen: P, canExpand: k, hasBlocks: S, onToggle: a, onOpenFile: i }, g);
1175
+ }, e[6] = o, e[7] = i, e[8] = p) : p = e[8], f = n.items.map(p), e[2] = n.items, e[3] = o, e[4] = i, e[5] = f;
1176
+ } else
1177
+ f = e[5];
1178
+ let u;
1179
+ return e[9] !== f ? (u = /* @__PURE__ */ l(E.Root, { children: f }), e[9] = f, e[10] = u) : u = e[10], u;
1180
+ }
1181
+ function xr(t, e) {
1182
+ return t.id ? `id:${t.id}` : `idx:${e}`;
1183
+ }
1184
+ function yr(t) {
1185
+ const e = y(6), {
1186
+ invocations: n,
1187
+ labeledBlocks: i,
1188
+ onOpenFile: r
1189
+ } = t;
1190
+ let o;
1191
+ e[0] !== n || e[1] !== i ? (o = tr(n, {
1192
+ labeledBlocks: i
1193
+ }), e[0] = n, e[1] = i, e[2] = o) : o = e[2];
1194
+ const s = o;
1195
+ let c;
1196
+ return e[3] !== s || e[4] !== r ? (c = /* @__PURE__ */ l(br, { data: s, onOpenFile: r }), e[3] = s, e[4] = r, e[5] = c) : c = e[5], c;
1197
+ }
1198
+ const Sr = (t) => t.type === "tool", Be = (t) => t >= 1e3 ? `${(t / 1e3).toFixed(1)}k` : String(t), kr = (t) => {
1199
+ switch (t) {
1200
+ case "timeout":
1201
+ return "Session timed out.";
1202
+ case "crash":
1203
+ return "Session crashed unexpectedly.";
1204
+ case "permission":
1205
+ return "Permission denied.";
1206
+ default:
1207
+ return "An error occurred.";
1208
+ }
1209
+ }, Tr = (t, e) => {
1210
+ const n = [];
1211
+ let i = e;
1212
+ for (; i < t.length; ) {
1213
+ const r = t[i];
1214
+ if (!Sr(r)) break;
1215
+ n.push(r), i += 1;
1216
+ }
1217
+ return {
1218
+ invocations: n,
1219
+ nextIndex: i - 1
1220
+ };
1221
+ };
1222
+ function wr(t) {
1223
+ const e = y(7), {
1224
+ message: n,
1225
+ onOpenFile: i,
1226
+ toolInvocationTimeline: r
1227
+ } = t, o = r ?? yr;
1228
+ let s;
1229
+ e[0] !== n.parts ? (s = n.parts ?? [], e[0] = n.parts, e[1] = s) : s = e[1];
1230
+ const c = s;
1231
+ let d;
1232
+ if (e[2] !== o || e[3] !== n.id || e[4] !== i || e[5] !== c) {
1233
+ const a = [];
1234
+ for (let f = 0; f < c.length; f = f + 1, f) {
1235
+ const u = c[f], p = `${n.id}-${f}`;
1236
+ e: switch (u.type) {
1237
+ case "text": {
1238
+ a.push(/* @__PURE__ */ l("div", { children: /* @__PURE__ */ l(cn, { children: u.text }) }, p));
1239
+ break e;
1240
+ }
1241
+ case "reasoning": {
1242
+ a.push(/* @__PURE__ */ l(T, { padding: "0", css: {
1243
+ "& .rich-text, & .rich-text *": {
1244
+ color: "fg.subtle !important",
1245
+ fontSize: ".75rem !important",
1246
+ fontWeight: "normal !important"
1247
+ }
1248
+ }, children: /* @__PURE__ */ l(Je, { defaultState: u.text }) }, p));
1249
+ break e;
1250
+ }
1251
+ case "tool": {
1252
+ const {
1253
+ invocations: m,
1254
+ nextIndex: h
1255
+ } = Tr(c, f);
1256
+ f = h, a.push(/* @__PURE__ */ l(T, { width: "full", children: /* @__PURE__ */ l(o, { invocations: m, labeledBlocks: !0, onOpenFile: i }) }, p));
1257
+ break e;
1258
+ }
1259
+ case "loading": {
1260
+ a.push(/* @__PURE__ */ x(T, { display: "flex", alignItems: "center", gap: "2", py: "2", children: [
1261
+ /* @__PURE__ */ l(ht, { size: "sm" }),
1262
+ /* @__PURE__ */ l(J, { fontSize: "sm", color: "fg.muted", children: "Thinking..." })
1263
+ ] }, p));
1264
+ break e;
1265
+ }
1266
+ case "error": {
1267
+ a.push(/* @__PURE__ */ l(T, { py: "2", children: /* @__PURE__ */ l(J, { fontSize: "sm", color: "fg.error", children: kr(u.errorType) }) }, p));
1268
+ break e;
1269
+ }
1270
+ case "token_usage": {
1271
+ a.push(/* @__PURE__ */ l(T, { py: "1", children: /* @__PURE__ */ x(J, { fontSize: "xs", color: "fg.subtle", children: [
1272
+ "Tokens: ",
1273
+ Be(u.inputTokens),
1274
+ " in / ",
1275
+ Be(u.outputTokens),
1276
+ " out",
1277
+ u.cacheReadTokens ? ` / ${Be(u.cacheReadTokens)} cache read` : ""
1278
+ ] }) }, p));
1279
+ break e;
1280
+ }
1281
+ default:
1282
+ a.push(null);
1283
+ }
1284
+ }
1285
+ d = /* @__PURE__ */ l(Ie, { children: a }), e[2] = o, e[3] = n.id, e[4] = i, e[5] = c, e[6] = d;
1286
+ } else
1287
+ d = e[6];
1288
+ return d;
1289
+ }
1290
+ const Cr = (t) => t === "user" || t === "assistant" || t === "developer" ? t : "assistant", Pr = (t) => {
1291
+ const e = t.parts ?? [];
1292
+ return e.length === 0 || e.some((i) => i.type === "text" && "text" in i) ? !1 : e.some((i) => i.type === "reasoning" || i.type === "tool");
1293
+ }, _r = (t) => {
1294
+ const e = [];
1295
+ for (const n of t) {
1296
+ const i = e[e.length - 1];
1297
+ if (i && i.role === n.role && Pr(n)) {
1298
+ i.parts = [...i.parts ?? [], ...n.parts ?? []];
1299
+ continue;
1300
+ }
1301
+ e.push({
1302
+ ...n,
1303
+ parts: [...n.parts ?? []]
1304
+ });
1305
+ }
1306
+ return e;
1307
+ }, Br = sn(), ao = (t) => {
1308
+ const e = y(43), {
1309
+ messages: n,
1310
+ streaming: i,
1311
+ emptyStateTitle: r,
1312
+ emptyStateDescription: o,
1313
+ chatInputPlaceholder: s,
1314
+ onSubmitMessage: c,
1315
+ actions: d,
1316
+ repoMenu: a,
1317
+ attachedResources: f,
1318
+ onClearAttachments: u,
1319
+ attachmentList: p,
1320
+ approvalPrompt: m
1321
+ } = t, h = i === void 0 ? !1 : i;
1322
+ let g, S, k, P, A, I, D, v, $, _;
1323
+ if (e[0] !== o || e[1] !== r || e[2] !== n || e[3] !== h) {
1324
+ const ne = _r(n), N = ne.length > 0, re = ne.reduce(Rr, 0);
1325
+ k = fe, I = "relative", D = "column", v = "full", $ = "full", _ = "hidden", S = _e.Root, A = /* @__PURE__ */ l(Zt, { userMessageCount: re }), g = _e.Viewport, P = N ? /* @__PURE__ */ l(Ue, { gap: "sm", children: ne.map((W) => {
1326
+ const z = Cr(W.role);
1327
+ return /* @__PURE__ */ l(Fe.Root, { from: z, children: /* @__PURE__ */ l(Fe.Content, { from: z, children: /* @__PURE__ */ l(wr, { message: W, streaming: h }) }) }, W.id);
1328
+ }) }) : /* @__PURE__ */ l(Et, { icon: /* @__PURE__ */ l(Mt, { size: 48, strokeWidth: 1.5 }), title: r, description: o }), e[0] = o, e[1] = r, e[2] = n, e[3] = h, e[4] = g, e[5] = S, e[6] = k, e[7] = P, e[8] = A, e[9] = I, e[10] = D, e[11] = v, e[12] = $, e[13] = _;
1329
+ } else
1330
+ g = e[4], S = e[5], k = e[6], P = e[7], A = e[8], I = e[9], D = e[10], v = e[11], $ = e[12], _ = e[13];
1331
+ let C;
1332
+ e[14] !== g || e[15] !== P ? (C = /* @__PURE__ */ l(g, { children: P }), e[14] = g, e[15] = P, e[16] = C) : C = e[16];
1333
+ let O;
1334
+ e[17] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (O = /* @__PURE__ */ l(_e.ScrollToBottom, { "aria-label": "Scroll to latest message" }), e[17] = O) : O = e[17];
1335
+ let F;
1336
+ e[18] !== S || e[19] !== A || e[20] !== C ? (F = /* @__PURE__ */ x(S, { children: [
1337
+ A,
1338
+ C,
1339
+ O
1340
+ ] }), e[18] = S, e[19] = A, e[20] = C, e[21] = F) : F = e[21];
1341
+ let B;
1342
+ e[22] !== d || e[23] !== f || e[24] !== p || e[25] !== s || e[26] !== u || e[27] !== c || e[28] !== h ? (B = /* @__PURE__ */ l(T, { px: "sm", children: /* @__PURE__ */ l(tn, { placeholder: s, defaultState: Br, streaming: h, onSubmit: c, actions: d, attachedResources: f, onClearAttachments: u, attachmentList: p }) }), e[22] = d, e[23] = f, e[24] = p, e[25] = s, e[26] = u, e[27] = c, e[28] = h, e[29] = B) : B = e[29];
1343
+ let R;
1344
+ e[30] !== a ? (R = /* @__PURE__ */ l(fe, { p: "2xs", justifyContent: "flex-end", children: a }), e[30] = a, e[31] = R) : R = e[31];
1345
+ let M;
1346
+ return e[32] !== k || e[33] !== m || e[34] !== F || e[35] !== B || e[36] !== R || e[37] !== I || e[38] !== D || e[39] !== v || e[40] !== $ || e[41] !== _ ? (M = /* @__PURE__ */ x(k, { position: I, direction: D, w: v, h: $, overflow: _, children: [
1347
+ F,
1348
+ m,
1349
+ B,
1350
+ R
1351
+ ] }), e[32] = k, e[33] = m, e[34] = F, e[35] = B, e[36] = R, e[37] = I, e[38] = D, e[39] = v, e[40] = $, e[41] = _, e[42] = M) : M = e[42], M;
1352
+ };
1353
+ function Rr(t, e) {
1354
+ return t + (e.role === "user" ? 1 : 0);
337
1355
  }
338
- const _e = (n = "") => JSON.stringify(Et(n));
339
1356
  export {
340
- we as AutoScroll,
341
- Re as ChatInput,
342
- ve as ChatMessage,
343
- ye as ChatPrimitives,
344
- qt as SendButton,
345
- _e as createSerializedPromptState
1357
+ co as ApprovalPrompt,
1358
+ Zt as AutoScroll,
1359
+ tn as ChatInput,
1360
+ Fe as ChatMessage,
1361
+ ao as ChatPanel,
1362
+ _e as ChatPrimitives,
1363
+ en as SendButton,
1364
+ sn as createSerializedPromptState
346
1365
  };
347
1366
  //# sourceMappingURL=chat-ui.js.map