@teodorruskvi/chat-core 0.1.39 → 0.1.41

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.
package/dist/index.esm.js CHANGED
@@ -3,7 +3,7 @@ var Ht = (e, t, n) => t in e ? Gt(e, t, { enumerable: !0, configurable: !0, writ
3
3
  var st = (e, t, n) => Ht(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { jsx as ie } from "react/jsx-runtime";
5
5
  import * as at from "react";
6
- import { createContext as Se, useContext as Ue, useState as $, useRef as K, useEffect as W, useCallback as U, useMemo as X, useReducer as Wt } from "react";
6
+ import { createContext as Se, useContext as Ue, useState as $, useRef as K, useEffect as q, useCallback as R, useMemo as Q, useReducer as Wt } from "react";
7
7
  import qt, { isCancel as Jt } from "axios";
8
8
  function vt(e) {
9
9
  var t, n, r = "";
@@ -126,7 +126,7 @@ const Ze = "-", Qt = (e) => {
126
126
  experimentalParseClassName: n
127
127
  } = e, r = t.length === 1, o = t[0], s = t.length, a = (i) => {
128
128
  const u = [];
129
- let c = 0, l = 0, p;
129
+ let c = 0, l = 0, f;
130
130
  for (let v = 0; v < i.length; v++) {
131
131
  let I = i[v];
132
132
  if (c === 0) {
@@ -135,13 +135,13 @@ const Ze = "-", Qt = (e) => {
135
135
  continue;
136
136
  }
137
137
  if (I === "/") {
138
- p = v;
138
+ f = v;
139
139
  continue;
140
140
  }
141
141
  }
142
142
  I === "[" ? c++ : I === "]" && c--;
143
143
  }
144
- const m = u.length === 0 ? i : i.substring(l), h = m.startsWith(It), k = h ? m.substring(1) : m, d = p && p > l ? p - l : void 0;
144
+ const m = u.length === 0 ? i : i.substring(l), h = m.startsWith(It), k = h ? m.substring(1) : m, d = f && f > l ? f - l : void 0;
145
145
  return {
146
146
  modifiers: u,
147
147
  hasImportantModifier: h,
@@ -175,7 +175,7 @@ const Ze = "-", Qt = (e) => {
175
175
  for (let u = a.length - 1; u >= 0; u -= 1) {
176
176
  const c = a[u], {
177
177
  modifiers: l,
178
- hasImportantModifier: p,
178
+ hasImportantModifier: f,
179
179
  baseClassName: m,
180
180
  maybePostfixModifierPosition: h
181
181
  } = n(c);
@@ -191,14 +191,14 @@ const Ze = "-", Qt = (e) => {
191
191
  }
192
192
  k = !1;
193
193
  }
194
- const v = on(l).join(":"), I = p ? v + It : v, A = I + d;
195
- if (s.includes(A))
194
+ const v = on(l).join(":"), I = f ? v + It : v, C = I + d;
195
+ if (s.includes(C))
196
196
  continue;
197
- s.push(A);
197
+ s.push(C);
198
198
  const T = o(d, k);
199
199
  for (let N = 0; N < T.length; ++N) {
200
- const b = T[N];
201
- s.push(I + b);
200
+ const w = T[N];
201
+ s.push(I + w);
202
202
  }
203
203
  i = c + (i.length > 0 ? " " + i : i);
204
204
  }
@@ -221,7 +221,7 @@ const Tt = (e) => {
221
221
  function un(e, ...t) {
222
222
  let n, r, o, s = a;
223
223
  function a(u) {
224
- const c = t.reduce((l, p) => p(l), e());
224
+ const c = t.reduce((l, f) => f(l), e());
225
225
  return n = sn(c), r = n.cache.get, o = n.cache.set, s = i, i(u);
226
226
  }
227
227
  function i(u) {
@@ -238,7 +238,7 @@ function un(e, ...t) {
238
238
  const B = (e) => {
239
239
  const t = (n) => n[e] || [];
240
240
  return t.isThemeGetter = !0, t;
241
- }, xt = /^\[(?:([a-z-]+):)?(.+)\]$/i, dn = /^\d+\/\d+$/, fn = /* @__PURE__ */ new Set(["px", "full", "screen"]), pn = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, gn = /\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/, mn = /^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/, hn = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/, yn = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/, fe = (e) => xe(e) || fn.has(e) || dn.test(e), be = (e) => Ce(e, "length", An), xe = (e) => !!e && !Number.isNaN(Number(e)), Ke = (e) => Ce(e, "number", xe), Pe = (e) => !!e && Number.isInteger(Number(e)), bn = (e) => e.endsWith("%") && xe(e.slice(0, -1)), R = (e) => xt.test(e), we = (e) => pn.test(e), wn = /* @__PURE__ */ new Set(["length", "size", "percentage"]), vn = (e) => Ce(e, wn, At), kn = (e) => Ce(e, "position", At), In = /* @__PURE__ */ new Set(["image", "url"]), Tn = (e) => Ce(e, In, Cn), xn = (e) => Ce(e, "", Sn), Ne = () => !0, Ce = (e, t, n) => {
241
+ }, xt = /^\[(?:([a-z-]+):)?(.+)\]$/i, dn = /^\d+\/\d+$/, fn = /* @__PURE__ */ new Set(["px", "full", "screen"]), pn = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, gn = /\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/, mn = /^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/, hn = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/, yn = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/, fe = (e) => xe(e) || fn.has(e) || dn.test(e), be = (e) => Ce(e, "length", An), xe = (e) => !!e && !Number.isNaN(Number(e)), Ke = (e) => Ce(e, "number", xe), Pe = (e) => !!e && Number.isInteger(Number(e)), bn = (e) => e.endsWith("%") && xe(e.slice(0, -1)), U = (e) => xt.test(e), we = (e) => pn.test(e), wn = /* @__PURE__ */ new Set(["length", "size", "percentage"]), vn = (e) => Ce(e, wn, At), kn = (e) => Ce(e, "position", At), In = /* @__PURE__ */ new Set(["image", "url"]), Tn = (e) => Ce(e, In, Cn), xn = (e) => Ce(e, "", Sn), Ne = () => !0, Ce = (e, t, n) => {
242
242
  const r = xt.exec(e);
243
243
  return r ? r[1] ? typeof t == "string" ? r[1] === t : t.has(r[1]) : n(r[2]) : !1;
244
244
  }, An = (e) => (
@@ -247,36 +247,36 @@ const B = (e) => {
247
247
  // I could also use lookbehind assertion in `lengthUnitRegex` but that isn't supported widely enough.
248
248
  gn.test(e) && !mn.test(e)
249
249
  ), At = () => !1, Sn = (e) => hn.test(e), Cn = (e) => yn.test(e), Mn = () => {
250
- const e = B("colors"), t = B("spacing"), n = B("blur"), r = B("brightness"), o = B("borderColor"), s = B("borderRadius"), a = B("borderSpacing"), i = B("borderWidth"), u = B("contrast"), c = B("grayscale"), l = B("hueRotate"), p = B("invert"), m = B("gap"), h = B("gradientColorStops"), k = B("gradientColorStopPositions"), d = B("inset"), v = B("margin"), I = B("opacity"), A = B("padding"), T = B("saturate"), N = B("scale"), b = B("sepia"), y = B("skew"), x = B("space"), g = B("translate"), w = () => ["auto", "contain", "none"], z = () => ["auto", "hidden", "clip", "visible", "scroll"], j = () => ["auto", R, t], S = () => [R, t], C = () => ["", fe, be], L = () => ["auto", xe, R], _ = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], O = () => ["solid", "dashed", "dotted", "double", "none"], F = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], G = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], E = () => ["", "0", R], D = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], Q = () => [xe, R];
250
+ const e = B("colors"), t = B("spacing"), n = B("blur"), r = B("brightness"), o = B("borderColor"), s = B("borderRadius"), a = B("borderSpacing"), i = B("borderWidth"), u = B("contrast"), c = B("grayscale"), l = B("hueRotate"), f = B("invert"), m = B("gap"), h = B("gradientColorStops"), k = B("gradientColorStopPositions"), d = B("inset"), v = B("margin"), I = B("opacity"), C = B("padding"), T = B("saturate"), N = B("scale"), w = B("sepia"), y = B("skew"), x = B("space"), p = B("translate"), b = () => ["auto", "contain", "none"], z = () => ["auto", "hidden", "clip", "visible", "scroll"], j = () => ["auto", U, t], M = () => [U, t], O = () => ["", fe, be], E = () => ["auto", xe, U], L = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], _ = () => ["solid", "dashed", "dotted", "double", "none"], G = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], F = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], P = () => ["", "0", U], V = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], Y = () => [xe, U];
251
251
  return {
252
252
  cacheSize: 500,
253
253
  separator: ":",
254
254
  theme: {
255
255
  colors: [Ne],
256
256
  spacing: [fe, be],
257
- blur: ["none", "", we, R],
258
- brightness: Q(),
257
+ blur: ["none", "", we, U],
258
+ brightness: Y(),
259
259
  borderColor: [e],
260
- borderRadius: ["none", "", "full", we, R],
261
- borderSpacing: S(),
262
- borderWidth: C(),
263
- contrast: Q(),
264
- grayscale: E(),
265
- hueRotate: Q(),
266
- invert: E(),
267
- gap: S(),
260
+ borderRadius: ["none", "", "full", we, U],
261
+ borderSpacing: M(),
262
+ borderWidth: O(),
263
+ contrast: Y(),
264
+ grayscale: P(),
265
+ hueRotate: Y(),
266
+ invert: P(),
267
+ gap: M(),
268
268
  gradientColorStops: [e],
269
269
  gradientColorStopPositions: [bn, be],
270
270
  inset: j(),
271
271
  margin: j(),
272
- opacity: Q(),
273
- padding: S(),
274
- saturate: Q(),
275
- scale: Q(),
276
- sepia: E(),
277
- skew: Q(),
278
- space: S(),
279
- translate: S()
272
+ opacity: Y(),
273
+ padding: M(),
274
+ saturate: Y(),
275
+ scale: Y(),
276
+ sepia: P(),
277
+ skew: Y(),
278
+ space: M(),
279
+ translate: M()
280
280
  },
281
281
  classGroups: {
282
282
  // Layout
@@ -285,7 +285,7 @@ const B = (e) => {
285
285
  * @see https://tailwindcss.com/docs/aspect-ratio
286
286
  */
287
287
  aspect: [{
288
- aspect: ["auto", "square", "video", R]
288
+ aspect: ["auto", "square", "video", U]
289
289
  }],
290
290
  /**
291
291
  * Container
@@ -304,14 +304,14 @@ const B = (e) => {
304
304
  * @see https://tailwindcss.com/docs/break-after
305
305
  */
306
306
  "break-after": [{
307
- "break-after": D()
307
+ "break-after": V()
308
308
  }],
309
309
  /**
310
310
  * Break Before
311
311
  * @see https://tailwindcss.com/docs/break-before
312
312
  */
313
313
  "break-before": [{
314
- "break-before": D()
314
+ "break-before": V()
315
315
  }],
316
316
  /**
317
317
  * Break Inside
@@ -370,7 +370,7 @@ const B = (e) => {
370
370
  * @see https://tailwindcss.com/docs/object-position
371
371
  */
372
372
  "object-position": [{
373
- object: [..._(), R]
373
+ object: [...L(), U]
374
374
  }],
375
375
  /**
376
376
  * Overflow
@@ -398,21 +398,21 @@ const B = (e) => {
398
398
  * @see https://tailwindcss.com/docs/overscroll-behavior
399
399
  */
400
400
  overscroll: [{
401
- overscroll: w()
401
+ overscroll: b()
402
402
  }],
403
403
  /**
404
404
  * Overscroll Behavior X
405
405
  * @see https://tailwindcss.com/docs/overscroll-behavior
406
406
  */
407
407
  "overscroll-x": [{
408
- "overscroll-x": w()
408
+ "overscroll-x": b()
409
409
  }],
410
410
  /**
411
411
  * Overscroll Behavior Y
412
412
  * @see https://tailwindcss.com/docs/overscroll-behavior
413
413
  */
414
414
  "overscroll-y": [{
415
- "overscroll-y": w()
415
+ "overscroll-y": b()
416
416
  }],
417
417
  /**
418
418
  * Position
@@ -492,7 +492,7 @@ const B = (e) => {
492
492
  * @see https://tailwindcss.com/docs/z-index
493
493
  */
494
494
  z: [{
495
- z: ["auto", Pe, R]
495
+ z: ["auto", Pe, U]
496
496
  }],
497
497
  // Flexbox and Grid
498
498
  /**
@@ -521,28 +521,28 @@ const B = (e) => {
521
521
  * @see https://tailwindcss.com/docs/flex
522
522
  */
523
523
  flex: [{
524
- flex: ["1", "auto", "initial", "none", R]
524
+ flex: ["1", "auto", "initial", "none", U]
525
525
  }],
526
526
  /**
527
527
  * Flex Grow
528
528
  * @see https://tailwindcss.com/docs/flex-grow
529
529
  */
530
530
  grow: [{
531
- grow: E()
531
+ grow: P()
532
532
  }],
533
533
  /**
534
534
  * Flex Shrink
535
535
  * @see https://tailwindcss.com/docs/flex-shrink
536
536
  */
537
537
  shrink: [{
538
- shrink: E()
538
+ shrink: P()
539
539
  }],
540
540
  /**
541
541
  * Order
542
542
  * @see https://tailwindcss.com/docs/order
543
543
  */
544
544
  order: [{
545
- order: ["first", "last", "none", Pe, R]
545
+ order: ["first", "last", "none", Pe, U]
546
546
  }],
547
547
  /**
548
548
  * Grid Template Columns
@@ -557,22 +557,22 @@ const B = (e) => {
557
557
  */
558
558
  "col-start-end": [{
559
559
  col: ["auto", {
560
- span: ["full", Pe, R]
561
- }, R]
560
+ span: ["full", Pe, U]
561
+ }, U]
562
562
  }],
563
563
  /**
564
564
  * Grid Column Start
565
565
  * @see https://tailwindcss.com/docs/grid-column
566
566
  */
567
567
  "col-start": [{
568
- "col-start": L()
568
+ "col-start": E()
569
569
  }],
570
570
  /**
571
571
  * Grid Column End
572
572
  * @see https://tailwindcss.com/docs/grid-column
573
573
  */
574
574
  "col-end": [{
575
- "col-end": L()
575
+ "col-end": E()
576
576
  }],
577
577
  /**
578
578
  * Grid Template Rows
@@ -587,22 +587,22 @@ const B = (e) => {
587
587
  */
588
588
  "row-start-end": [{
589
589
  row: ["auto", {
590
- span: [Pe, R]
591
- }, R]
590
+ span: [Pe, U]
591
+ }, U]
592
592
  }],
593
593
  /**
594
594
  * Grid Row Start
595
595
  * @see https://tailwindcss.com/docs/grid-row
596
596
  */
597
597
  "row-start": [{
598
- "row-start": L()
598
+ "row-start": E()
599
599
  }],
600
600
  /**
601
601
  * Grid Row End
602
602
  * @see https://tailwindcss.com/docs/grid-row
603
603
  */
604
604
  "row-end": [{
605
- "row-end": L()
605
+ "row-end": E()
606
606
  }],
607
607
  /**
608
608
  * Grid Auto Flow
@@ -616,14 +616,14 @@ const B = (e) => {
616
616
  * @see https://tailwindcss.com/docs/grid-auto-columns
617
617
  */
618
618
  "auto-cols": [{
619
- "auto-cols": ["auto", "min", "max", "fr", R]
619
+ "auto-cols": ["auto", "min", "max", "fr", U]
620
620
  }],
621
621
  /**
622
622
  * Grid Auto Rows
623
623
  * @see https://tailwindcss.com/docs/grid-auto-rows
624
624
  */
625
625
  "auto-rows": [{
626
- "auto-rows": ["auto", "min", "max", "fr", R]
626
+ "auto-rows": ["auto", "min", "max", "fr", U]
627
627
  }],
628
628
  /**
629
629
  * Gap
@@ -651,7 +651,7 @@ const B = (e) => {
651
651
  * @see https://tailwindcss.com/docs/justify-content
652
652
  */
653
653
  "justify-content": [{
654
- justify: ["normal", ...G()]
654
+ justify: ["normal", ...F()]
655
655
  }],
656
656
  /**
657
657
  * Justify Items
@@ -672,7 +672,7 @@ const B = (e) => {
672
672
  * @see https://tailwindcss.com/docs/align-content
673
673
  */
674
674
  "align-content": [{
675
- content: ["normal", ...G(), "baseline"]
675
+ content: ["normal", ...F(), "baseline"]
676
676
  }],
677
677
  /**
678
678
  * Align Items
@@ -693,7 +693,7 @@ const B = (e) => {
693
693
  * @see https://tailwindcss.com/docs/place-content
694
694
  */
695
695
  "place-content": [{
696
- "place-content": [...G(), "baseline"]
696
+ "place-content": [...F(), "baseline"]
697
697
  }],
698
698
  /**
699
699
  * Place Items
@@ -715,63 +715,63 @@ const B = (e) => {
715
715
  * @see https://tailwindcss.com/docs/padding
716
716
  */
717
717
  p: [{
718
- p: [A]
718
+ p: [C]
719
719
  }],
720
720
  /**
721
721
  * Padding X
722
722
  * @see https://tailwindcss.com/docs/padding
723
723
  */
724
724
  px: [{
725
- px: [A]
725
+ px: [C]
726
726
  }],
727
727
  /**
728
728
  * Padding Y
729
729
  * @see https://tailwindcss.com/docs/padding
730
730
  */
731
731
  py: [{
732
- py: [A]
732
+ py: [C]
733
733
  }],
734
734
  /**
735
735
  * Padding Start
736
736
  * @see https://tailwindcss.com/docs/padding
737
737
  */
738
738
  ps: [{
739
- ps: [A]
739
+ ps: [C]
740
740
  }],
741
741
  /**
742
742
  * Padding End
743
743
  * @see https://tailwindcss.com/docs/padding
744
744
  */
745
745
  pe: [{
746
- pe: [A]
746
+ pe: [C]
747
747
  }],
748
748
  /**
749
749
  * Padding Top
750
750
  * @see https://tailwindcss.com/docs/padding
751
751
  */
752
752
  pt: [{
753
- pt: [A]
753
+ pt: [C]
754
754
  }],
755
755
  /**
756
756
  * Padding Right
757
757
  * @see https://tailwindcss.com/docs/padding
758
758
  */
759
759
  pr: [{
760
- pr: [A]
760
+ pr: [C]
761
761
  }],
762
762
  /**
763
763
  * Padding Bottom
764
764
  * @see https://tailwindcss.com/docs/padding
765
765
  */
766
766
  pb: [{
767
- pb: [A]
767
+ pb: [C]
768
768
  }],
769
769
  /**
770
770
  * Padding Left
771
771
  * @see https://tailwindcss.com/docs/padding
772
772
  */
773
773
  pl: [{
774
- pl: [A]
774
+ pl: [C]
775
775
  }],
776
776
  /**
777
777
  * Margin
@@ -866,21 +866,21 @@ const B = (e) => {
866
866
  * @see https://tailwindcss.com/docs/width
867
867
  */
868
868
  w: [{
869
- w: ["auto", "min", "max", "fit", "svw", "lvw", "dvw", R, t]
869
+ w: ["auto", "min", "max", "fit", "svw", "lvw", "dvw", U, t]
870
870
  }],
871
871
  /**
872
872
  * Min-Width
873
873
  * @see https://tailwindcss.com/docs/min-width
874
874
  */
875
875
  "min-w": [{
876
- "min-w": [R, t, "min", "max", "fit"]
876
+ "min-w": [U, t, "min", "max", "fit"]
877
877
  }],
878
878
  /**
879
879
  * Max-Width
880
880
  * @see https://tailwindcss.com/docs/max-width
881
881
  */
882
882
  "max-w": [{
883
- "max-w": [R, t, "none", "full", "min", "max", "fit", "prose", {
883
+ "max-w": [U, t, "none", "full", "min", "max", "fit", "prose", {
884
884
  screen: [we]
885
885
  }, we]
886
886
  }],
@@ -889,28 +889,28 @@ const B = (e) => {
889
889
  * @see https://tailwindcss.com/docs/height
890
890
  */
891
891
  h: [{
892
- h: [R, t, "auto", "min", "max", "fit", "svh", "lvh", "dvh"]
892
+ h: [U, t, "auto", "min", "max", "fit", "svh", "lvh", "dvh"]
893
893
  }],
894
894
  /**
895
895
  * Min-Height
896
896
  * @see https://tailwindcss.com/docs/min-height
897
897
  */
898
898
  "min-h": [{
899
- "min-h": [R, t, "min", "max", "fit", "svh", "lvh", "dvh"]
899
+ "min-h": [U, t, "min", "max", "fit", "svh", "lvh", "dvh"]
900
900
  }],
901
901
  /**
902
902
  * Max-Height
903
903
  * @see https://tailwindcss.com/docs/max-height
904
904
  */
905
905
  "max-h": [{
906
- "max-h": [R, t, "min", "max", "fit", "svh", "lvh", "dvh"]
906
+ "max-h": [U, t, "min", "max", "fit", "svh", "lvh", "dvh"]
907
907
  }],
908
908
  /**
909
909
  * Size
910
910
  * @see https://tailwindcss.com/docs/size
911
911
  */
912
912
  size: [{
913
- size: [R, t, "auto", "min", "max", "fit"]
913
+ size: [U, t, "auto", "min", "max", "fit"]
914
914
  }],
915
915
  // Typography
916
916
  /**
@@ -979,7 +979,7 @@ const B = (e) => {
979
979
  * @see https://tailwindcss.com/docs/letter-spacing
980
980
  */
981
981
  tracking: [{
982
- tracking: ["tighter", "tight", "normal", "wide", "wider", "widest", R]
982
+ tracking: ["tighter", "tight", "normal", "wide", "wider", "widest", U]
983
983
  }],
984
984
  /**
985
985
  * Line Clamp
@@ -993,21 +993,21 @@ const B = (e) => {
993
993
  * @see https://tailwindcss.com/docs/line-height
994
994
  */
995
995
  leading: [{
996
- leading: ["none", "tight", "snug", "normal", "relaxed", "loose", fe, R]
996
+ leading: ["none", "tight", "snug", "normal", "relaxed", "loose", fe, U]
997
997
  }],
998
998
  /**
999
999
  * List Style Image
1000
1000
  * @see https://tailwindcss.com/docs/list-style-image
1001
1001
  */
1002
1002
  "list-image": [{
1003
- "list-image": ["none", R]
1003
+ "list-image": ["none", U]
1004
1004
  }],
1005
1005
  /**
1006
1006
  * List Style Type
1007
1007
  * @see https://tailwindcss.com/docs/list-style-type
1008
1008
  */
1009
1009
  "list-style-type": [{
1010
- list: ["none", "disc", "decimal", R]
1010
+ list: ["none", "disc", "decimal", U]
1011
1011
  }],
1012
1012
  /**
1013
1013
  * List Style Position
@@ -1062,7 +1062,7 @@ const B = (e) => {
1062
1062
  * @see https://tailwindcss.com/docs/text-decoration-style
1063
1063
  */
1064
1064
  "text-decoration-style": [{
1065
- decoration: [...O(), "wavy"]
1065
+ decoration: [..._(), "wavy"]
1066
1066
  }],
1067
1067
  /**
1068
1068
  * Text Decoration Thickness
@@ -1076,7 +1076,7 @@ const B = (e) => {
1076
1076
  * @see https://tailwindcss.com/docs/text-underline-offset
1077
1077
  */
1078
1078
  "underline-offset": [{
1079
- "underline-offset": ["auto", fe, R]
1079
+ "underline-offset": ["auto", fe, U]
1080
1080
  }],
1081
1081
  /**
1082
1082
  * Text Decoration Color
@@ -1107,14 +1107,14 @@ const B = (e) => {
1107
1107
  * @see https://tailwindcss.com/docs/text-indent
1108
1108
  */
1109
1109
  indent: [{
1110
- indent: S()
1110
+ indent: M()
1111
1111
  }],
1112
1112
  /**
1113
1113
  * Vertical Alignment
1114
1114
  * @see https://tailwindcss.com/docs/vertical-align
1115
1115
  */
1116
1116
  "vertical-align": [{
1117
- align: ["baseline", "top", "middle", "bottom", "text-top", "text-bottom", "sub", "super", R]
1117
+ align: ["baseline", "top", "middle", "bottom", "text-top", "text-bottom", "sub", "super", U]
1118
1118
  }],
1119
1119
  /**
1120
1120
  * Whitespace
@@ -1142,7 +1142,7 @@ const B = (e) => {
1142
1142
  * @see https://tailwindcss.com/docs/content
1143
1143
  */
1144
1144
  content: [{
1145
- content: ["none", R]
1145
+ content: ["none", U]
1146
1146
  }],
1147
1147
  // Backgrounds
1148
1148
  /**
@@ -1179,7 +1179,7 @@ const B = (e) => {
1179
1179
  * @see https://tailwindcss.com/docs/background-position
1180
1180
  */
1181
1181
  "bg-position": [{
1182
- bg: [..._(), kn]
1182
+ bg: [...L(), kn]
1183
1183
  }],
1184
1184
  /**
1185
1185
  * Background Repeat
@@ -1436,7 +1436,7 @@ const B = (e) => {
1436
1436
  * @see https://tailwindcss.com/docs/border-style
1437
1437
  */
1438
1438
  "border-style": [{
1439
- border: [...O(), "hidden"]
1439
+ border: [..._(), "hidden"]
1440
1440
  }],
1441
1441
  /**
1442
1442
  * Divide Width X
@@ -1474,7 +1474,7 @@ const B = (e) => {
1474
1474
  * @see https://tailwindcss.com/docs/divide-style
1475
1475
  */
1476
1476
  "divide-style": [{
1477
- divide: O()
1477
+ divide: _()
1478
1478
  }],
1479
1479
  /**
1480
1480
  * Border Color
@@ -1551,14 +1551,14 @@ const B = (e) => {
1551
1551
  * @see https://tailwindcss.com/docs/outline-style
1552
1552
  */
1553
1553
  "outline-style": [{
1554
- outline: ["", ...O()]
1554
+ outline: ["", ..._()]
1555
1555
  }],
1556
1556
  /**
1557
1557
  * Outline Offset
1558
1558
  * @see https://tailwindcss.com/docs/outline-offset
1559
1559
  */
1560
1560
  "outline-offset": [{
1561
- "outline-offset": [fe, R]
1561
+ "outline-offset": [fe, U]
1562
1562
  }],
1563
1563
  /**
1564
1564
  * Outline Width
@@ -1579,7 +1579,7 @@ const B = (e) => {
1579
1579
  * @see https://tailwindcss.com/docs/ring-width
1580
1580
  */
1581
1581
  "ring-w": [{
1582
- ring: C()
1582
+ ring: O()
1583
1583
  }],
1584
1584
  /**
1585
1585
  * Ring Width Inset
@@ -1641,14 +1641,14 @@ const B = (e) => {
1641
1641
  * @see https://tailwindcss.com/docs/mix-blend-mode
1642
1642
  */
1643
1643
  "mix-blend": [{
1644
- "mix-blend": [...F(), "plus-lighter", "plus-darker"]
1644
+ "mix-blend": [...G(), "plus-lighter", "plus-darker"]
1645
1645
  }],
1646
1646
  /**
1647
1647
  * Background Blend Mode
1648
1648
  * @see https://tailwindcss.com/docs/background-blend-mode
1649
1649
  */
1650
1650
  "bg-blend": [{
1651
- "bg-blend": F()
1651
+ "bg-blend": G()
1652
1652
  }],
1653
1653
  // Filters
1654
1654
  /**
@@ -1685,7 +1685,7 @@ const B = (e) => {
1685
1685
  * @see https://tailwindcss.com/docs/drop-shadow
1686
1686
  */
1687
1687
  "drop-shadow": [{
1688
- "drop-shadow": ["", "none", we, R]
1688
+ "drop-shadow": ["", "none", we, U]
1689
1689
  }],
1690
1690
  /**
1691
1691
  * Grayscale
@@ -1706,7 +1706,7 @@ const B = (e) => {
1706
1706
  * @see https://tailwindcss.com/docs/invert
1707
1707
  */
1708
1708
  invert: [{
1709
- invert: [p]
1709
+ invert: [f]
1710
1710
  }],
1711
1711
  /**
1712
1712
  * Saturate
@@ -1720,7 +1720,7 @@ const B = (e) => {
1720
1720
  * @see https://tailwindcss.com/docs/sepia
1721
1721
  */
1722
1722
  sepia: [{
1723
- sepia: [b]
1723
+ sepia: [w]
1724
1724
  }],
1725
1725
  /**
1726
1726
  * Backdrop Filter
@@ -1770,7 +1770,7 @@ const B = (e) => {
1770
1770
  * @see https://tailwindcss.com/docs/backdrop-invert
1771
1771
  */
1772
1772
  "backdrop-invert": [{
1773
- "backdrop-invert": [p]
1773
+ "backdrop-invert": [f]
1774
1774
  }],
1775
1775
  /**
1776
1776
  * Backdrop Opacity
@@ -1791,7 +1791,7 @@ const B = (e) => {
1791
1791
  * @see https://tailwindcss.com/docs/backdrop-sepia
1792
1792
  */
1793
1793
  "backdrop-sepia": [{
1794
- "backdrop-sepia": [b]
1794
+ "backdrop-sepia": [w]
1795
1795
  }],
1796
1796
  // Tables
1797
1797
  /**
@@ -1842,35 +1842,35 @@ const B = (e) => {
1842
1842
  * @see https://tailwindcss.com/docs/transition-property
1843
1843
  */
1844
1844
  transition: [{
1845
- transition: ["none", "all", "", "colors", "opacity", "shadow", "transform", R]
1845
+ transition: ["none", "all", "", "colors", "opacity", "shadow", "transform", U]
1846
1846
  }],
1847
1847
  /**
1848
1848
  * Transition Duration
1849
1849
  * @see https://tailwindcss.com/docs/transition-duration
1850
1850
  */
1851
1851
  duration: [{
1852
- duration: Q()
1852
+ duration: Y()
1853
1853
  }],
1854
1854
  /**
1855
1855
  * Transition Timing Function
1856
1856
  * @see https://tailwindcss.com/docs/transition-timing-function
1857
1857
  */
1858
1858
  ease: [{
1859
- ease: ["linear", "in", "out", "in-out", R]
1859
+ ease: ["linear", "in", "out", "in-out", U]
1860
1860
  }],
1861
1861
  /**
1862
1862
  * Transition Delay
1863
1863
  * @see https://tailwindcss.com/docs/transition-delay
1864
1864
  */
1865
1865
  delay: [{
1866
- delay: Q()
1866
+ delay: Y()
1867
1867
  }],
1868
1868
  /**
1869
1869
  * Animation
1870
1870
  * @see https://tailwindcss.com/docs/animation
1871
1871
  */
1872
1872
  animate: [{
1873
- animate: ["none", "spin", "ping", "pulse", "bounce", R]
1873
+ animate: ["none", "spin", "ping", "pulse", "bounce", U]
1874
1874
  }],
1875
1875
  // Transforms
1876
1876
  /**
@@ -1906,21 +1906,21 @@ const B = (e) => {
1906
1906
  * @see https://tailwindcss.com/docs/rotate
1907
1907
  */
1908
1908
  rotate: [{
1909
- rotate: [Pe, R]
1909
+ rotate: [Pe, U]
1910
1910
  }],
1911
1911
  /**
1912
1912
  * Translate X
1913
1913
  * @see https://tailwindcss.com/docs/translate
1914
1914
  */
1915
1915
  "translate-x": [{
1916
- "translate-x": [g]
1916
+ "translate-x": [p]
1917
1917
  }],
1918
1918
  /**
1919
1919
  * Translate Y
1920
1920
  * @see https://tailwindcss.com/docs/translate
1921
1921
  */
1922
1922
  "translate-y": [{
1923
- "translate-y": [g]
1923
+ "translate-y": [p]
1924
1924
  }],
1925
1925
  /**
1926
1926
  * Skew X
@@ -1941,7 +1941,7 @@ const B = (e) => {
1941
1941
  * @see https://tailwindcss.com/docs/transform-origin
1942
1942
  */
1943
1943
  "transform-origin": [{
1944
- origin: ["center", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left", "top-left", R]
1944
+ origin: ["center", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left", "top-left", U]
1945
1945
  }],
1946
1946
  // Interactivity
1947
1947
  /**
@@ -1963,7 +1963,7 @@ const B = (e) => {
1963
1963
  * @see https://tailwindcss.com/docs/cursor
1964
1964
  */
1965
1965
  cursor: [{
1966
- cursor: ["auto", "default", "pointer", "wait", "text", "move", "help", "not-allowed", "none", "context-menu", "progress", "cell", "crosshair", "vertical-text", "alias", "copy", "no-drop", "grab", "grabbing", "all-scroll", "col-resize", "row-resize", "n-resize", "e-resize", "s-resize", "w-resize", "ne-resize", "nw-resize", "se-resize", "sw-resize", "ew-resize", "ns-resize", "nesw-resize", "nwse-resize", "zoom-in", "zoom-out", R]
1966
+ cursor: ["auto", "default", "pointer", "wait", "text", "move", "help", "not-allowed", "none", "context-menu", "progress", "cell", "crosshair", "vertical-text", "alias", "copy", "no-drop", "grab", "grabbing", "all-scroll", "col-resize", "row-resize", "n-resize", "e-resize", "s-resize", "w-resize", "ne-resize", "nw-resize", "se-resize", "sw-resize", "ew-resize", "ns-resize", "nesw-resize", "nwse-resize", "zoom-in", "zoom-out", U]
1967
1967
  }],
1968
1968
  /**
1969
1969
  * Caret Color
@@ -1998,126 +1998,126 @@ const B = (e) => {
1998
1998
  * @see https://tailwindcss.com/docs/scroll-margin
1999
1999
  */
2000
2000
  "scroll-m": [{
2001
- "scroll-m": S()
2001
+ "scroll-m": M()
2002
2002
  }],
2003
2003
  /**
2004
2004
  * Scroll Margin X
2005
2005
  * @see https://tailwindcss.com/docs/scroll-margin
2006
2006
  */
2007
2007
  "scroll-mx": [{
2008
- "scroll-mx": S()
2008
+ "scroll-mx": M()
2009
2009
  }],
2010
2010
  /**
2011
2011
  * Scroll Margin Y
2012
2012
  * @see https://tailwindcss.com/docs/scroll-margin
2013
2013
  */
2014
2014
  "scroll-my": [{
2015
- "scroll-my": S()
2015
+ "scroll-my": M()
2016
2016
  }],
2017
2017
  /**
2018
2018
  * Scroll Margin Start
2019
2019
  * @see https://tailwindcss.com/docs/scroll-margin
2020
2020
  */
2021
2021
  "scroll-ms": [{
2022
- "scroll-ms": S()
2022
+ "scroll-ms": M()
2023
2023
  }],
2024
2024
  /**
2025
2025
  * Scroll Margin End
2026
2026
  * @see https://tailwindcss.com/docs/scroll-margin
2027
2027
  */
2028
2028
  "scroll-me": [{
2029
- "scroll-me": S()
2029
+ "scroll-me": M()
2030
2030
  }],
2031
2031
  /**
2032
2032
  * Scroll Margin Top
2033
2033
  * @see https://tailwindcss.com/docs/scroll-margin
2034
2034
  */
2035
2035
  "scroll-mt": [{
2036
- "scroll-mt": S()
2036
+ "scroll-mt": M()
2037
2037
  }],
2038
2038
  /**
2039
2039
  * Scroll Margin Right
2040
2040
  * @see https://tailwindcss.com/docs/scroll-margin
2041
2041
  */
2042
2042
  "scroll-mr": [{
2043
- "scroll-mr": S()
2043
+ "scroll-mr": M()
2044
2044
  }],
2045
2045
  /**
2046
2046
  * Scroll Margin Bottom
2047
2047
  * @see https://tailwindcss.com/docs/scroll-margin
2048
2048
  */
2049
2049
  "scroll-mb": [{
2050
- "scroll-mb": S()
2050
+ "scroll-mb": M()
2051
2051
  }],
2052
2052
  /**
2053
2053
  * Scroll Margin Left
2054
2054
  * @see https://tailwindcss.com/docs/scroll-margin
2055
2055
  */
2056
2056
  "scroll-ml": [{
2057
- "scroll-ml": S()
2057
+ "scroll-ml": M()
2058
2058
  }],
2059
2059
  /**
2060
2060
  * Scroll Padding
2061
2061
  * @see https://tailwindcss.com/docs/scroll-padding
2062
2062
  */
2063
2063
  "scroll-p": [{
2064
- "scroll-p": S()
2064
+ "scroll-p": M()
2065
2065
  }],
2066
2066
  /**
2067
2067
  * Scroll Padding X
2068
2068
  * @see https://tailwindcss.com/docs/scroll-padding
2069
2069
  */
2070
2070
  "scroll-px": [{
2071
- "scroll-px": S()
2071
+ "scroll-px": M()
2072
2072
  }],
2073
2073
  /**
2074
2074
  * Scroll Padding Y
2075
2075
  * @see https://tailwindcss.com/docs/scroll-padding
2076
2076
  */
2077
2077
  "scroll-py": [{
2078
- "scroll-py": S()
2078
+ "scroll-py": M()
2079
2079
  }],
2080
2080
  /**
2081
2081
  * Scroll Padding Start
2082
2082
  * @see https://tailwindcss.com/docs/scroll-padding
2083
2083
  */
2084
2084
  "scroll-ps": [{
2085
- "scroll-ps": S()
2085
+ "scroll-ps": M()
2086
2086
  }],
2087
2087
  /**
2088
2088
  * Scroll Padding End
2089
2089
  * @see https://tailwindcss.com/docs/scroll-padding
2090
2090
  */
2091
2091
  "scroll-pe": [{
2092
- "scroll-pe": S()
2092
+ "scroll-pe": M()
2093
2093
  }],
2094
2094
  /**
2095
2095
  * Scroll Padding Top
2096
2096
  * @see https://tailwindcss.com/docs/scroll-padding
2097
2097
  */
2098
2098
  "scroll-pt": [{
2099
- "scroll-pt": S()
2099
+ "scroll-pt": M()
2100
2100
  }],
2101
2101
  /**
2102
2102
  * Scroll Padding Right
2103
2103
  * @see https://tailwindcss.com/docs/scroll-padding
2104
2104
  */
2105
2105
  "scroll-pr": [{
2106
- "scroll-pr": S()
2106
+ "scroll-pr": M()
2107
2107
  }],
2108
2108
  /**
2109
2109
  * Scroll Padding Bottom
2110
2110
  * @see https://tailwindcss.com/docs/scroll-padding
2111
2111
  */
2112
2112
  "scroll-pb": [{
2113
- "scroll-pb": S()
2113
+ "scroll-pb": M()
2114
2114
  }],
2115
2115
  /**
2116
2116
  * Scroll Padding Left
2117
2117
  * @see https://tailwindcss.com/docs/scroll-padding
2118
2118
  */
2119
2119
  "scroll-pl": [{
2120
- "scroll-pl": S()
2120
+ "scroll-pl": M()
2121
2121
  }],
2122
2122
  /**
2123
2123
  * Scroll Snap Align
@@ -2185,7 +2185,7 @@ const B = (e) => {
2185
2185
  * @see https://tailwindcss.com/docs/will-change
2186
2186
  */
2187
2187
  "will-change": [{
2188
- "will-change": ["auto", "scroll", "contents", "transform", R]
2188
+ "will-change": ["auto", "scroll", "contents", "transform", U]
2189
2189
  }],
2190
2190
  // SVG
2191
2191
  /**
@@ -2448,12 +2448,12 @@ function le(e) {
2448
2448
  );
2449
2449
  }
2450
2450
  function tt(e) {
2451
- var v, I, A, T, N, b;
2451
+ var v, I, C, T, N, w;
2452
2452
  if (!e || typeof e != "object") return null;
2453
2453
  const t = le(e), n = Vn(t);
2454
2454
  if (!n)
2455
2455
  return null;
2456
- const r = Array.isArray(t.toolCalls) ? t.toolCalls.map(nt) : void 0, o = $n(t.content ?? t.parts, !!(r != null && r.length)), s = t.id ?? `msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`, a = t.createdAt ?? ((v = t.additionalKwargs) == null ? void 0 : v.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(), i = t.name ?? ((I = t.additionalKwargs) == null ? void 0 : I.agentName) ?? void 0, u = t.model ?? ((A = t.additionalKwargs) == null ? void 0 : A.model) ?? void 0, c = t.toolCallId ?? void 0, l = t.additionalKwargs ?? void 0, p = t.responseMetadata ?? void 0, m = t.checkpointId ?? ((T = t.additionalKwargs) == null ? void 0 : T.checkpointId) ?? void 0, h = t.checkpointNs ?? ((N = t.additionalKwargs) == null ? void 0 : N.checkpointNs) ?? void 0, k = typeof t.toolStreaming == "boolean" ? t.toolStreaming : !!((b = t.additionalKwargs) != null && b.toolStreaming);
2456
+ const r = Array.isArray(t.toolCalls) ? t.toolCalls.map(nt) : void 0, o = $n(t.content ?? t.parts, !!(r != null && r.length)), s = t.id ?? `msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`, a = t.createdAt ?? ((v = t.additionalKwargs) == null ? void 0 : v.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(), i = t.name ?? ((I = t.additionalKwargs) == null ? void 0 : I.agentName) ?? void 0, u = t.model ?? ((C = t.additionalKwargs) == null ? void 0 : C.model) ?? void 0, c = t.toolCallId ?? void 0, l = t.additionalKwargs ?? void 0, f = t.responseMetadata ?? void 0, m = t.checkpointId ?? ((T = t.additionalKwargs) == null ? void 0 : T.checkpointId) ?? void 0, h = t.checkpointNs ?? ((N = t.additionalKwargs) == null ? void 0 : N.checkpointNs) ?? void 0, k = typeof t.toolStreaming == "boolean" ? t.toolStreaming : !!((w = t.additionalKwargs) != null && w.toolStreaming);
2457
2457
  return {
2458
2458
  ...t,
2459
2459
  id: s,
@@ -2468,7 +2468,7 @@ function tt(e) {
2468
2468
  checkpointNs: h,
2469
2469
  toolStreaming: k,
2470
2470
  additionalKwargs: l,
2471
- responseMetadata: p,
2471
+ responseMetadata: f,
2472
2472
  artifact: t.artifact ?? void 0
2473
2473
  };
2474
2474
  }
@@ -2537,8 +2537,8 @@ function Kn(e, t = []) {
2537
2537
  if (Array.isArray(e)) {
2538
2538
  const o = e.filter((a) => a.role === "assistant").flatMap((a) => ut(a)), s = /* @__PURE__ */ new Map();
2539
2539
  return o.forEach((a) => s.set(a.id, a)), Array.from(s.values()).map((a) => {
2540
- var p, m, h;
2541
- const i = Ge(a.id, e) || Ge(a.id, t), u = Array.isArray((p = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : p.toolProgress) ? (m = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : m.toolProgress : void 0, c = (i == null ? void 0 : i.artifact) ?? a.artifact, l = lt(a.status) ?? ((h = i == null ? void 0 : i.additionalKwargs) != null && h.toolStreaming ? "pending" : null) ?? (i ? "completed" : "pending");
2540
+ var f, m, h;
2541
+ const i = Ge(a.id, e) || Ge(a.id, t), u = Array.isArray((f = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : f.toolProgress) ? (m = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : m.toolProgress : void 0, c = (i == null ? void 0 : i.artifact) ?? a.artifact, l = lt(a.status) ?? ((h = i == null ? void 0 : i.additionalKwargs) != null && h.toolStreaming ? "pending" : null) ?? (i ? "completed" : "pending");
2542
2542
  if (i && !a.content && l === "completed") {
2543
2543
  const k = ce(i);
2544
2544
  typeof k == "string" && (a.content = k);
@@ -2558,8 +2558,8 @@ function Kn(e, t = []) {
2558
2558
  var u, c, l;
2559
2559
  const o = Ge(r.id, t) ?? Dn(e, r), s = Array.isArray((u = o == null ? void 0 : o.additionalKwargs) == null ? void 0 : u.toolProgress) ? (c = o == null ? void 0 : o.additionalKwargs) == null ? void 0 : c.toolProgress : void 0, a = (o == null ? void 0 : o.artifact) ?? r.artifact, i = lt(r.status) ?? ((l = o == null ? void 0 : o.additionalKwargs) != null && l.toolStreaming ? "pending" : null) ?? (o ? "completed" : "pending");
2560
2560
  if (o && !r.content && i === "completed") {
2561
- const p = ce(o);
2562
- typeof p == "string" && (r.content = p);
2561
+ const f = ce(o);
2562
+ typeof f == "string" && (r.content = f);
2563
2563
  }
2564
2564
  return {
2565
2565
  call: r,
@@ -2952,128 +2952,128 @@ function ir(e) {
2952
2952
  return !!e && typeof e == "object" && "data" in e;
2953
2953
  }
2954
2954
  function cr(e = {}) {
2955
- const t = e.baseUrl || "", n = e.streamPath ?? "/runs/stream", [r, o] = $(e.token ?? null), s = K(e.headers ?? {}), a = e.credentials ?? "include", i = K(e);
2956
- W(() => {
2955
+ const t = e.baseUrl || "", n = e.streamPath ?? "/stream", [r, o] = $(e.token ?? null), s = K(e.headers ?? {}), a = e.credentials ?? "include", i = K(e);
2956
+ q(() => {
2957
2957
  i.current = e;
2958
2958
  }, [e]);
2959
- const u = U((g) => {
2960
- var j, S, C, L, _, O, F, G, E, D;
2961
- const w = i.current;
2962
- if (!w) return;
2963
- (j = w.onEvent) == null || j.call(w, g), g.type === "thread_info" && ((S = w.onThreadInfo) == null || S.call(w, g)), g.type === "values" && Array.isArray(g.checkpoints) && ((C = w.handleValuesEvent) == null || C.call(w, g)), g.type === "metadata" && ((L = w.onMetadataEvent) == null || L.call(w, g)), typeof g.type == "string" && (g.type === "custom" || g.type.startsWith("custom.")) && ((_ = w.onCustomEvent) == null || _.call(w, g)), g.type === "updates" && ((O = w.onUpdateEvent) == null || O.call(w, g)), g.type === "tool.end" ? (F = w.onToolEnd) == null || F.call(w, g) : g.type === "tool.start" && ((G = w.onToolStart) == null || G.call(w, g)), g.type === "heartbeat" && ((E = w.onHeartbeat) == null || E.call(w, g)), g.type === "token" && ((D = w.onToken) == null || D.call(w, g.token));
2964
- }, []), [c, l] = $(!1), [p, m] = $(null), [h, k] = $(!1), [d, v] = $(null), I = K(null), A = K(!0), T = K(null), N = U((g) => {
2965
- o(g);
2966
- }, []), b = U(() => {
2959
+ const u = R((p) => {
2960
+ var j, M, O, E, L, _, G, F, P, V;
2961
+ const b = i.current;
2962
+ if (!b) return;
2963
+ (j = b.onEvent) == null || j.call(b, p), p.type === "thread_info" && ((M = b.onThreadInfo) == null || M.call(b, p)), p.type === "values" && Array.isArray(p.checkpoints) && ((O = b.handleValuesEvent) == null || O.call(b, p)), p.type === "metadata" && ((E = b.onMetadataEvent) == null || E.call(b, p)), typeof p.type == "string" && (p.type === "custom" || p.type.startsWith("custom.")) && ((L = b.onCustomEvent) == null || L.call(b, p)), p.type === "updates" && ((_ = b.onUpdateEvent) == null || _.call(b, p)), p.type === "tool.end" ? (G = b.onToolEnd) == null || G.call(b, p) : p.type === "tool.start" && ((F = b.onToolStart) == null || F.call(b, p)), p.type === "heartbeat" && ((P = b.onHeartbeat) == null || P.call(b, p)), p.type === "token" && ((V = b.onToken) == null || V.call(b, p.token));
2964
+ }, []), [c, l] = $(!1), [f, m] = $(null), [h, k] = $(!1), [d, v] = $(null), I = K(null), C = K(!0), T = K(null), N = R((p) => {
2965
+ o(p);
2966
+ }, []), w = R(() => {
2967
2967
  m(null), v(null);
2968
- }, []), y = U(() => {
2969
- var S, C;
2968
+ }, []), y = R(() => {
2969
+ var M, O;
2970
2970
  console.debug("[use-chat] stop() invoked - aborting stream");
2971
- const g = (S = T.current) == null ? void 0 : S.threadId, w = (C = T.current) == null ? void 0 : C.runId, z = () => {
2972
- var L;
2973
- (L = I.current) == null || L.abort(), I.current = null, T.current = null, l(!1), k(!1);
2971
+ const p = (M = T.current) == null ? void 0 : M.threadId, b = (O = T.current) == null ? void 0 : O.runId, z = () => {
2972
+ var E;
2973
+ (E = I.current) == null || E.abort(), I.current = null, T.current = null, l(!1), k(!1);
2974
2974
  };
2975
- (w || g ? _t.cancelRun(w || g).catch((L) => {
2976
- console.warn("[use-chat] cancel run failed:", L);
2975
+ (b || p ? _t.cancelRun(b || p).catch((E) => {
2976
+ console.warn("[use-chat] cancel run failed:", E);
2977
2977
  }) : Promise.resolve()).finally(z);
2978
- }, []), x = U(
2979
- (g) => {
2978
+ }, []), x = R(
2979
+ (p) => {
2980
2980
  I.current && (I.current.abort(), I.current = null);
2981
- const w = {
2982
- text: typeof g.content == "string" ? g.content : g.text,
2983
- threadId: g.threadId,
2984
- attachments: g.attachments,
2985
- payload: g.payload,
2986
- config: g.config,
2987
- checkpointId: g.checkpointId,
2988
- checkpointNs: g.checkpointNs || void 0,
2989
- edit: g.edit,
2990
- command: g.command
2981
+ const b = {
2982
+ text: typeof p.content == "string" ? p.content : p.text,
2983
+ threadId: p.threadId,
2984
+ attachments: p.attachments,
2985
+ payload: p.payload,
2986
+ config: p.config,
2987
+ checkpointId: p.checkpointId,
2988
+ checkpointNs: p.checkpointNs || void 0,
2989
+ edit: p.edit,
2990
+ command: p.command
2991
2991
  };
2992
2992
  l(!0), m(null), v(null);
2993
2993
  const z = new AbortController();
2994
2994
  I.current = z;
2995
- let j = null, S = !1;
2995
+ let j = null, M = !1;
2996
2996
  return T.current = {
2997
- threadId: w.threadId ?? void 0,
2997
+ threadId: b.threadId ?? void 0,
2998
2998
  runId: void 0,
2999
2999
  // Will be updated from headers
3000
3000
  headers: {},
3001
3001
  isStreaming: !0
3002
3002
  }, (async () => {
3003
- var C, L, _, O, F, G;
3003
+ var O, E, L, _, G, F;
3004
3004
  try {
3005
- let E = {};
3005
+ let P = {};
3006
3006
  try {
3007
3007
  if (r)
3008
- E = { Authorization: `Bearer ${r}` };
3008
+ P = { Authorization: `Bearer ${r}` };
3009
3009
  else if (typeof window < "u") {
3010
- const ee = window.__AUTH_TOKEN__, ve = ((C = window.localStorage) == null ? void 0 : C.getItem(_e.authToken)) || null;
3011
- let J = null;
3010
+ const te = window.__AUTH_TOKEN__, ve = ((O = window.localStorage) == null ? void 0 : O.getItem(_e.authToken)) || null;
3011
+ let X = null;
3012
3012
  try {
3013
- const me = (L = window.localStorage) == null ? void 0 : L.getItem(_e.chatSettings);
3014
- me && (J = ((_ = JSON.parse(me)) == null ? void 0 : _.apiKey) || null);
3013
+ const me = (E = window.localStorage) == null ? void 0 : E.getItem(_e.chatSettings);
3014
+ me && (X = ((L = JSON.parse(me)) == null ? void 0 : L.apiKey) || null);
3015
3015
  } catch {
3016
3016
  }
3017
- const Y = ee || ve || J || null;
3018
- Y && (E = { Authorization: `Bearer ${Y}` });
3017
+ const Z = te || ve || X || null;
3018
+ Z && (P = { Authorization: `Bearer ${Z}` });
3019
3019
  }
3020
3020
  } catch {
3021
3021
  }
3022
3022
  console.debug("[use-chat] POST", t + n);
3023
- let D = {};
3023
+ let V = {};
3024
3024
  if (typeof window < "u")
3025
3025
  try {
3026
- const H = (O = window.localStorage) == null ? void 0 : O.getItem(_e.authSessionId);
3027
- H && (D = { "X-Session-Id": H });
3026
+ const W = (_ = window.localStorage) == null ? void 0 : _.getItem(_e.authSessionId);
3027
+ W && (V = { "X-Session-Id": W });
3028
3028
  } catch {
3029
3029
  }
3030
- const Q = {
3031
- ...E,
3032
- ...D,
3030
+ const Y = {
3031
+ ...P,
3032
+ ...V,
3033
3033
  ...s.current
3034
- }, f = {
3034
+ }, g = {
3035
3035
  "Content-Type": "application/json",
3036
3036
  Accept: "text/event-stream",
3037
- ...Q
3038
- }, P = await fetch(t + n, {
3037
+ ...Y
3038
+ }, A = await fetch(t + n, {
3039
3039
  method: "POST",
3040
- headers: f,
3041
- body: JSON.stringify(w),
3040
+ headers: g,
3041
+ body: JSON.stringify(b),
3042
3042
  signal: z.signal,
3043
3043
  credentials: a
3044
3044
  });
3045
- if (T.current && (T.current.headers = Q), !P.ok || !P.body) {
3046
- const H = await P.text().catch(() => "");
3045
+ if (T.current && (T.current.headers = Y), !A.ok || !A.body) {
3046
+ const W = await A.text().catch(() => "");
3047
3047
  console.debug(
3048
3048
  "[use-chat] non-OK response",
3049
- P.status,
3050
- H == null ? void 0 : H.slice(0, 500)
3049
+ A.status,
3050
+ W == null ? void 0 : W.slice(0, 500)
3051
3051
  );
3052
- const ee = `stream ${P.status}${H ? ": " + H : ""}`;
3053
- throw ee && (m(ee), j = "error"), new Error(ee);
3052
+ const te = `stream ${A.status}${W ? ": " + W : ""}`;
3053
+ throw te && (m(te), j = "error"), new Error(te);
3054
3054
  }
3055
3055
  k(!0);
3056
- const M = P.body.getReader(), te = new TextDecoder();
3057
- let q = "", V = 0, Z = Date.now();
3056
+ const S = A.body.getReader(), H = new TextDecoder();
3057
+ let J = "", D = 0, ee = Date.now();
3058
3058
  const oe = setInterval(() => {
3059
- Date.now() - Z > 18e5 && (m("Stream idle timeout"), j = "error", z.abort());
3059
+ Date.now() - ee > 18e5 && (m("Stream idle timeout"), j = "error", z.abort());
3060
3060
  }, 5e3), ue = 1024 * 1024;
3061
3061
  try {
3062
- const H = P.headers.get("X-Thread-Id") || P.headers.get("x-thread-id"), ee = P.headers.get("X-Run-Id") || P.headers.get("x-run-id");
3062
+ const W = A.headers.get("X-Thread-Id") || A.headers.get("x-thread-id"), te = A.headers.get("X-Run-Id") || A.headers.get("x-run-id");
3063
3063
  for (T.current && (T.current = {
3064
3064
  ...T.current,
3065
- threadId: H ?? T.current.threadId,
3066
- runId: ee ?? T.current.runId
3065
+ threadId: W ?? T.current.threadId,
3066
+ runId: te ?? T.current.runId
3067
3067
  }); ; ) {
3068
- const { value: ve, done: J } = await M.read();
3069
- if (J) break;
3070
- q += te.decode(ve, { stream: !0 }), q.length > ue && (q = "", console.warn("Stream buffer reset: exceeded 1MB"));
3071
- let Y;
3072
- for (; (Y = q.indexOf(`
3068
+ const { value: ve, done: X } = await S.read();
3069
+ if (X) break;
3070
+ J += H.decode(ve, { stream: !0 }), J.length > ue && (J = "", console.warn("Stream buffer reset: exceeded 1MB"));
3071
+ let Z;
3072
+ for (; (Z = J.indexOf(`
3073
3073
 
3074
3074
  `)) >= 0; ) {
3075
- const me = q.slice(0, Y);
3076
- q = q.slice(Y + 2);
3075
+ const me = J.slice(0, Z);
3076
+ J = J.slice(Z + 2);
3077
3077
  const je = me.split(/\r?\n/), Le = [];
3078
3078
  let de = null;
3079
3079
  for (const ye of je)
@@ -3105,56 +3105,56 @@ function cr(e = {}) {
3105
3105
  continue;
3106
3106
  }
3107
3107
  const Ee = Bn(Me);
3108
- Z = Date.now();
3108
+ ee = Date.now();
3109
3109
  const he = Ee.seq;
3110
3110
  if (he !== void 0) {
3111
- if (he <= V) {
3112
- console.debug("[use-chat] drop duplicate/out-of-order event", { seq: he, lastProcessedSeq: V, type: Ee.type });
3111
+ if (he <= D) {
3112
+ console.debug("[use-chat] drop duplicate/out-of-order event", { seq: he, lastProcessedSeq: D, type: Ee.type });
3113
3113
  continue;
3114
3114
  }
3115
- V = he;
3115
+ D = he;
3116
3116
  }
3117
3117
  u(Ee);
3118
3118
  }
3119
3119
  }
3120
3120
  j === null && !z.signal.aborted && (j = "complete");
3121
- } catch (H) {
3122
- if (H.name === "AbortError")
3121
+ } catch (W) {
3122
+ if (W.name === "AbortError")
3123
3123
  j = j ?? "aborted";
3124
3124
  else {
3125
- const ee = H.message || String(H);
3126
- j = "error", m(ee);
3125
+ const te = W.message || String(W);
3126
+ j = "error", m(te);
3127
3127
  }
3128
3128
  } finally {
3129
3129
  try {
3130
- await M.cancel();
3130
+ await S.cancel();
3131
3131
  } catch {
3132
3132
  } finally {
3133
- (F = M.releaseLock) == null || F.call(M);
3133
+ (G = S.releaseLock) == null || G.call(S);
3134
3134
  }
3135
3135
  clearInterval(oe);
3136
3136
  }
3137
- } catch (E) {
3138
- if (E.name === "AbortError")
3137
+ } catch (P) {
3138
+ if (P.name === "AbortError")
3139
3139
  j = j ?? "aborted";
3140
3140
  else {
3141
- const D = E.message || String(E);
3142
- j = "error", m(D), S || (S = !0, (G = e.onConnectionError) == null || G.call(e, D));
3141
+ const V = P.message || String(P);
3142
+ j = "error", m(V), M || (M = !0, (F = e.onConnectionError) == null || F.call(e, V));
3143
3143
  }
3144
3144
  } finally {
3145
3145
  try {
3146
3146
  if (e.onFinish) {
3147
- const E = {
3147
+ const P = {
3148
3148
  lastSeq: 0,
3149
3149
  lastCheckpointId: null,
3150
3150
  lastCheckpointNs: null,
3151
3151
  lastValues: null
3152
3152
  // Let the reducer/history hook provide the final values
3153
3153
  };
3154
- e.onFinish(E);
3154
+ e.onFinish(P);
3155
3155
  }
3156
- } catch (E) {
3157
- console.warn("[use-chat] onClosed callback failed", E);
3156
+ } catch (P) {
3157
+ console.warn("[use-chat] onClosed callback failed", P);
3158
3158
  }
3159
3159
  l(!1), k(!1), I.current = null, T.current = null;
3160
3160
  }
@@ -3162,12 +3162,12 @@ function cr(e = {}) {
3162
3162
  },
3163
3163
  [t, n, r, e, u]
3164
3164
  );
3165
- return W(() => () => {
3166
- var g;
3167
- A.current = !1, (g = I.current) == null || g.abort();
3165
+ return q(() => () => {
3166
+ var p;
3167
+ C.current = !1, (p = I.current) == null || p.abort();
3168
3168
  }, []), {
3169
3169
  isStreaming: c,
3170
- error: p,
3170
+ error: f,
3171
3171
  assistantText: "",
3172
3172
  // Deprecated: use messages from reducer
3173
3173
  activeMessageId: d,
@@ -3179,14 +3179,14 @@ function cr(e = {}) {
3179
3179
  connected: h,
3180
3180
  stream: x,
3181
3181
  stop: y,
3182
- clear: b,
3182
+ clear: w,
3183
3183
  setToken: N,
3184
3184
  values: {},
3185
3185
  // Provide empty object for backward compatibility
3186
3186
  interrupt: () => Promise.resolve(),
3187
3187
  resume: () => Promise.resolve(),
3188
3188
  goto: () => Promise.resolve(),
3189
- connectionState: p ? "error" : c ? h ? "connected" : "connecting" : "idle",
3189
+ connectionState: f ? "error" : c ? h ? "connected" : "connecting" : "idle",
3190
3190
  messages: [],
3191
3191
  // useStream doesn't maintain messages, use useChatSession instead
3192
3192
  submit: x
@@ -3199,94 +3199,94 @@ function lr({
3199
3199
  onThreadChange: r,
3200
3200
  onCurrentThreadDeleted: o
3201
3201
  }) {
3202
- const [s, a] = $([]), [i, u] = $(t), [c, l] = $(!1), [p, m] = $(null), h = K(i), k = K(/* @__PURE__ */ new Map());
3203
- W(() => {
3202
+ const [s, a] = $([]), [i, u] = $(t), [c, l] = $(!1), [f, m] = $(null), h = K(i), k = K(/* @__PURE__ */ new Map());
3203
+ q(() => {
3204
3204
  h.current = i;
3205
- }, [i]), W(() => {
3205
+ }, [i]), q(() => {
3206
3206
  t !== void 0 && t !== h.current && u(t);
3207
3207
  }, [t]);
3208
- const d = U(async () => {
3208
+ const d = R(async () => {
3209
3209
  l(!0), m(null);
3210
3210
  try {
3211
- const b = await e.listThreads();
3212
- a(b ?? []);
3213
- } catch (b) {
3214
- const y = String(b);
3211
+ const w = await e.listThreads();
3212
+ a(w ?? []);
3213
+ } catch (w) {
3214
+ const y = String(w);
3215
3215
  m(y), n == null || n(y);
3216
3216
  } finally {
3217
3217
  l(!1);
3218
3218
  }
3219
3219
  }, [e, n]);
3220
- W(() => {
3220
+ q(() => {
3221
3221
  d();
3222
- }, [d]), W(() => {
3222
+ }, [d]), q(() => {
3223
3223
  r == null || r(i);
3224
3224
  }, [i, r]);
3225
- const v = U(
3226
- async (b, y) => {
3225
+ const v = R(
3226
+ async (w, y) => {
3227
3227
  try {
3228
- const x = y && typeof y == "object" ? { id: y.id, name: y.name ?? "" } : void 0, g = await e.createThread(b, x);
3229
- return u(g.threadId), await d(), g.threadId;
3228
+ const x = y && typeof y == "object" ? { id: y.id, name: y.name ?? "" } : void 0, p = await e.createThread(w, x);
3229
+ return u(p.threadId), await d(), p.threadId;
3230
3230
  } catch (x) {
3231
- const g = String(x);
3232
- return n == null || n(g), null;
3231
+ const p = String(x);
3232
+ return n == null || n(p), null;
3233
3233
  }
3234
3234
  },
3235
3235
  [e, n, d]
3236
- ), I = U(
3237
- async (b) => {
3236
+ ), I = R(
3237
+ async (w) => {
3238
3238
  const y = s;
3239
- a((g) => g.filter((w) => w.threadId !== b));
3239
+ a((p) => p.filter((b) => b.threadId !== w));
3240
3240
  const x = new AbortController();
3241
- k.current.set(b, x);
3241
+ k.current.set(w, x);
3242
3242
  try {
3243
- await e.deleteThread(b), h.current === b && (u(null), o == null || o());
3244
- } catch (g) {
3243
+ await e.deleteThread(w), h.current === w && (u(null), o == null || o());
3244
+ } catch (p) {
3245
3245
  a(y);
3246
- const w = String(g);
3247
- n == null || n(w);
3246
+ const b = String(p);
3247
+ n == null || n(b);
3248
3248
  } finally {
3249
- k.current.delete(b);
3249
+ k.current.delete(w);
3250
3250
  }
3251
3251
  },
3252
3252
  [e, o, n, s]
3253
- ), A = U(
3254
- async (b, y) => {
3253
+ ), C = R(
3254
+ async (w, y) => {
3255
3255
  try {
3256
- await e.updateThread(b, y), await d();
3256
+ await e.updateThread(w, y), await d();
3257
3257
  } catch (x) {
3258
3258
  n == null || n(String(x));
3259
3259
  }
3260
3260
  },
3261
3261
  [e, n, d]
3262
- ), T = X(
3262
+ ), T = Q(
3263
3263
  () => ({
3264
3264
  createThread: v,
3265
3265
  deleteThread: I,
3266
- renameThread: A,
3266
+ renameThread: C,
3267
3267
  refreshThreads: d
3268
3268
  }),
3269
- [v, I, A, d]
3270
- ), N = U((b) => {
3271
- if (!(b != null && b.threadId)) return;
3269
+ [v, I, C, d]
3270
+ ), N = R((w) => {
3271
+ if (!(w != null && w.threadId)) return;
3272
3272
  const y = {
3273
- threadId: b.threadId,
3274
- title: b.title || `Thread ${b.threadId.slice(0, 8)}`,
3275
- project: b.project,
3276
- createdAt: b.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
3277
- updatedAt: b.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
3278
- messageCount: b.messageCount ?? 1
3273
+ threadId: w.threadId,
3274
+ title: w.title || `Thread ${w.threadId.slice(0, 8)}`,
3275
+ project: w.project,
3276
+ createdAt: w.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
3277
+ updatedAt: w.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
3278
+ messageCount: w.messageCount ?? 1
3279
3279
  };
3280
3280
  a((x) => {
3281
- let g = !1;
3282
- const w = x.map((z) => z.threadId === y.threadId ? (g = !0, console.debug("[useThreadsState] thread_info: updating existing thread", y.threadId), {
3281
+ let p = !1;
3282
+ const b = x.map((z) => z.threadId === y.threadId ? (p = !0, console.debug("[useThreadsState] thread_info: updating existing thread", y.threadId), {
3283
3283
  ...z,
3284
3284
  title: y.title ?? z.title,
3285
3285
  project: y.project ?? z.project,
3286
3286
  updatedAt: y.updatedAt ?? z.updatedAt,
3287
3287
  messageCount: y.messageCount ?? z.messageCount
3288
3288
  }) : z);
3289
- return g ? w : (console.debug("[useThreadsState] thread_info: adding thread to list", y.threadId), [y, ...x]);
3289
+ return p ? b : (console.debug("[useThreadsState] thread_info: adding thread to list", y.threadId), [y, ...x]);
3290
3290
  });
3291
3291
  }, []);
3292
3292
  return {
@@ -3295,7 +3295,7 @@ function lr({
3295
3295
  currentThreadIdRef: h,
3296
3296
  setCurrentThreadId: u,
3297
3297
  isLoadingThreads: c,
3298
- threadsError: p,
3298
+ threadsError: f,
3299
3299
  actions: T,
3300
3300
  addThreadFromEvent: N
3301
3301
  };
@@ -3314,14 +3314,14 @@ function ur({
3314
3314
  currentThreadIdRef: u,
3315
3315
  isLoadingThreads: c,
3316
3316
  threadsError: l,
3317
- actions: p,
3317
+ actions: f,
3318
3318
  addThreadFromEvent: m
3319
3319
  } = lr({
3320
3320
  api: o,
3321
3321
  initialThreadId: t,
3322
3322
  onError: n,
3323
3323
  onThreadChange: r
3324
- }), h = X(
3324
+ }), h = Q(
3325
3325
  () => ({
3326
3326
  threads: s,
3327
3327
  currentThreadId: a,
@@ -3329,7 +3329,7 @@ function ur({
3329
3329
  currentThreadIdRef: u,
3330
3330
  isLoading: c,
3331
3331
  error: l,
3332
- actions: p,
3332
+ actions: f,
3333
3333
  addThreadFromEvent: m
3334
3334
  }),
3335
3335
  [
@@ -3339,7 +3339,7 @@ function ur({
3339
3339
  u,
3340
3340
  c,
3341
3341
  l,
3342
- p,
3342
+ f,
3343
3343
  m
3344
3344
  ]
3345
3345
  );
@@ -3462,15 +3462,15 @@ function gr(e, t) {
3462
3462
  }
3463
3463
  }
3464
3464
  function mr(e = []) {
3465
- const [t, n] = Wt(gr, { ...Ot, messages: e }), r = K([]), o = K(null), s = U(() => {
3465
+ const [t, n] = Wt(gr, { ...Ot, messages: e }), r = K([]), o = K(null), s = R(() => {
3466
3466
  o.current !== null && typeof window < "u" && window.cancelAnimationFrame(o.current), o.current = null;
3467
3467
  const c = r.current;
3468
3468
  c.length && (r.current = [], n({ type: "batch", payload: { events: c } }));
3469
- }, []), a = U(() => {
3469
+ }, []), a = R(() => {
3470
3470
  typeof window < "u" && typeof window.requestAnimationFrame == "function" ? o.current === null && (o.current = window.requestAnimationFrame(() => s())) : setTimeout(s, 8);
3471
- }, [s]), i = U((c) => {
3471
+ }, [s]), i = R((c) => {
3472
3472
  r.current.push(c), a();
3473
- }, [a]), u = X(() => ({
3473
+ }, [a]), u = Q(() => ({
3474
3474
  setStatus: (c, l) => n({ type: "status", payload: { status: c, error: l } }),
3475
3475
  reset: (c) => n({ type: "reset", payload: { messages: c } }),
3476
3476
  seed: (c, l) => n({ type: "seed", payload: { messages: c, ...l ?? {} } }),
@@ -3500,7 +3500,7 @@ function ft(e, t) {
3500
3500
  return { ...e, status: "error", error: t.message, messages: [...e.messages, i] };
3501
3501
  }
3502
3502
  if (t.type === "values" && ((a = n.values) != null && a.messages)) {
3503
- const i = n.values, u = Array.isArray(i.messages) ? i.messages : [], c = Oe(u), { messages: l, ...p } = i;
3503
+ const i = n.values, u = Array.isArray(i.messages) ? i.messages : [], c = Oe(u), { messages: l, ...f } = i;
3504
3504
  if (s) {
3505
3505
  const m = typeof o == "string" && o.length > 0 ? o : "task";
3506
3506
  return {
@@ -3514,7 +3514,7 @@ function ft(e, t) {
3514
3514
  messages: c,
3515
3515
  assemblingId: null,
3516
3516
  pendingInterrupt: null,
3517
- values: p
3517
+ values: f
3518
3518
  };
3519
3519
  }
3520
3520
  return t.type === "messages/partial" ? hr(e, n) : t.type === "tool.start" ? s ? e : yr(e, t) : t.type === "tool.progress" ? s ? e : br(e, t) : t.type === "tool.end" ? s ? e : wr(e, t) : t.type === "artifact.update" ? vr(e, t) : e;
@@ -3571,7 +3571,7 @@ function yr(e, t) {
3571
3571
  }
3572
3572
  }
3573
3573
  if (i !== -1) {
3574
- const u = a[i], c = [...u.toolCalls || []], l = c.findIndex((p) => p.id === r);
3574
+ const u = a[i], c = [...u.toolCalls || []], l = c.findIndex((f) => f.id === r);
3575
3575
  l >= 0 ? c[l] = { ...c[l], status: "running", content: s } : c.push({
3576
3576
  id: r,
3577
3577
  name: o,
@@ -3665,8 +3665,8 @@ async function Ir(e, t) {
3665
3665
  for (const c of r) {
3666
3666
  const l = (i = c == null ? void 0 : c.values) == null ? void 0 : i.messages;
3667
3667
  if (Array.isArray(l))
3668
- for (const p of l) {
3669
- const m = p == null ? void 0 : p.content;
3668
+ for (const f of l) {
3669
+ const m = f == null ? void 0 : f.content;
3670
3670
  if (Array.isArray(m))
3671
3671
  for (const h of m) {
3672
3672
  if (!h || typeof h != "object" || h.type !== "image_url" && h.type !== "file") continue;
@@ -3680,8 +3680,8 @@ async function Ir(e, t) {
3680
3680
  const s = await Promise.all(
3681
3681
  Array.from(o).map(async (c) => {
3682
3682
  try {
3683
- const l = await t.getFileInfo(c), p = le(l);
3684
- return [c, p];
3683
+ const l = await t.getFileInfo(c), f = le(l);
3684
+ return [c, f];
3685
3685
  } catch {
3686
3686
  return [c, null];
3687
3687
  }
@@ -3690,8 +3690,8 @@ async function Ir(e, t) {
3690
3690
  for (const c of r) {
3691
3691
  const l = (u = c == null ? void 0 : c.values) == null ? void 0 : u.messages;
3692
3692
  if (Array.isArray(l))
3693
- for (const p of l) {
3694
- const m = p == null ? void 0 : p.content;
3693
+ for (const f of l) {
3694
+ const m = f == null ? void 0 : f.content;
3695
3695
  if (Array.isArray(m))
3696
3696
  for (const h of m) {
3697
3697
  if (!h || typeof h != "object" || h.type !== "image_url" && h.type !== "file") continue;
@@ -3714,23 +3714,23 @@ function gt(e) {
3714
3714
  };
3715
3715
  }
3716
3716
  function Tr(e, t) {
3717
- var b, y;
3717
+ var w, y;
3718
3718
  if (!e) return null;
3719
- const n = ((b = e.values) == null ? void 0 : b.activeAgent) ?? null, r = (y = e.values) == null ? void 0 : y.messages, s = (Array.isArray(r) ? r : []).map((x) => xr(x, n)).filter((x) => !!x), a = ze(e.metadata) ?? {}, i = pt(e.config), u = ze(e.parentConfig), c = pt(u), l = Fe(i, ["checkpointId"]), p = Fe(i, ["checkpointNs"]), m = Fe(c, ["checkpointId"]), h = ze(e.config), k = Array.isArray(e.tasks) ? e.tasks.map((x) => ({ ...x })) : e.tasks ?? null, d = Array.isArray(e.next) ? [...e.next] : e.next ?? null, v = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt : new Date(Date.now() - t).toISOString(), I = {
3719
+ const n = ((w = e.values) == null ? void 0 : w.activeAgent) ?? null, r = (y = e.values) == null ? void 0 : y.messages, s = (Array.isArray(r) ? r : []).map((x) => xr(x, n)).filter((x) => !!x), a = ze(e.metadata) ?? {}, i = pt(e.config), u = ze(e.parentConfig), c = pt(u), l = Fe(i, ["checkpointId"]), f = Fe(i, ["checkpointNs"]), m = Fe(c, ["checkpointId"]), h = ze(e.config), k = Array.isArray(e.tasks) ? e.tasks.map((x) => ({ ...x })) : e.tasks ?? null, d = Array.isArray(e.next) ? [...e.next] : e.next ?? null, v = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt : new Date(Date.now() - t).toISOString(), I = {
3720
3720
  ...a,
3721
3721
  step: kr(a, ["step"]) ?? 0,
3722
3722
  source: Fe(a, ["source"]) ?? null
3723
- }, A = s.map((x) => ({
3723
+ }, C = s.map((x) => ({
3724
3724
  ...x,
3725
3725
  checkpointId: x.checkpointId ?? l ?? null,
3726
- checkpointNs: x.checkpointNs ?? p ?? null
3726
+ checkpointNs: x.checkpointNs ?? f ?? null
3727
3727
  })), T = e.values, N = Array.isArray(e.interrupts) ? e.interrupts : Array.isArray(T == null ? void 0 : T.interrupts) ? T.interrupts : [];
3728
3728
  return {
3729
3729
  checkpointId: l ?? null,
3730
- checkpointNs: p ?? null,
3730
+ checkpointNs: f ?? null,
3731
3731
  createdAt: v,
3732
3732
  parentId: m ?? null,
3733
- messages: A,
3733
+ messages: C,
3734
3734
  interrupt: Ar(
3735
3735
  N,
3736
3736
  t,
@@ -3785,12 +3785,12 @@ function Cr(e) {
3785
3785
  function Mr(e) {
3786
3786
  const t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Map(), o = [];
3787
3787
  for (let c = 0; c < e.length; c++) {
3788
- const l = e[c], p = l.checkpointId, m = p ?? `cp-${c}`, h = l.metadata ?? {}, k = typeof h.step == "number" ? h.step : null, d = typeof h.source == "string" ? h.source : null;
3788
+ const l = e[c], f = l.checkpointId, m = f ?? `cp-${c}`, h = l.metadata ?? {}, k = typeof h.step == "number" ? h.step : null, d = typeof h.source == "string" ? h.source : null;
3789
3789
  let v = null, I = null;
3790
- const A = Array.isArray(l.messages) ? l.messages : [];
3791
- for (const y of A)
3790
+ const C = Array.isArray(l.messages) ? l.messages : [];
3791
+ for (const y of C)
3792
3792
  y.role === "user" && (I || (I = y), y.id && (v = y.id));
3793
- const T = l.next && l.next.length > 0 ? String(l.next[0]) : null, N = l.parentConfig ?? null, b = {
3793
+ const T = l.next && l.next.length > 0 ? String(l.next[0]) : null, N = l.parentConfig ?? null, w = {
3794
3794
  id: m,
3795
3795
  step: k,
3796
3796
  source: d,
@@ -3801,9 +3801,9 @@ function Mr(e) {
3801
3801
  parentConfig: N,
3802
3802
  userMessageId: v
3803
3803
  };
3804
- if (o.push(b), p && t.set(p, b), p && I) {
3804
+ if (o.push(w), f && t.set(f, w), f && I) {
3805
3805
  const y = Cr(I);
3806
- y && r.set(p, y);
3806
+ y && r.set(f, y);
3807
3807
  }
3808
3808
  n.push({
3809
3809
  id: m,
@@ -3823,14 +3823,14 @@ function Mr(e) {
3823
3823
  }
3824
3824
  for (const c of s.values()) {
3825
3825
  if (!c.length) continue;
3826
- c.sort((p, m) => {
3827
- const h = p.createdAt ? Date.parse(p.createdAt) : 0;
3826
+ c.sort((f, m) => {
3827
+ const h = f.createdAt ? Date.parse(f.createdAt) : 0;
3828
3828
  return (m.createdAt ? Date.parse(m.createdAt) : 0) - h;
3829
3829
  });
3830
3830
  const l = c.length;
3831
- for (let p = 0; p < c.length; p++) {
3832
- const m = c[p];
3833
- m.attemptCount = l, m.attemptIndex = p, m.isLatestAttempt = p === 0;
3831
+ for (let f = 0; f < c.length; f++) {
3832
+ const m = c[f];
3833
+ m.attemptCount = l, m.attemptIndex = f, m.isLatestAttempt = f === 0;
3834
3834
  }
3835
3835
  }
3836
3836
  return {
@@ -3846,10 +3846,10 @@ function Mr(e) {
3846
3846
  getCheckpoint: (c) => t.get(c),
3847
3847
  getMessageAttempts: (c) => {
3848
3848
  const l = [];
3849
- for (const p of t.values())
3850
- p.userMessageId === c && l.push(p);
3851
- return l.length ? (l.sort((p, m) => {
3852
- const h = typeof p.attemptIndex == "number" ? p.attemptIndex : Number.MAX_SAFE_INTEGER, k = typeof m.attemptIndex == "number" ? m.attemptIndex : Number.MAX_SAFE_INTEGER;
3849
+ for (const f of t.values())
3850
+ f.userMessageId === c && l.push(f);
3851
+ return l.length ? (l.sort((f, m) => {
3852
+ const h = typeof f.attemptIndex == "number" ? f.attemptIndex : Number.MAX_SAFE_INTEGER, k = typeof m.attemptIndex == "number" ? m.attemptIndex : Number.MAX_SAFE_INTEGER;
3853
3853
  return h - k;
3854
3854
  }), l) : [];
3855
3855
  }
@@ -3873,7 +3873,7 @@ function so(e, t, n) {
3873
3873
  };
3874
3874
  }
3875
3875
  function Er(e) {
3876
- return X(() => Mr(e), [e]);
3876
+ return Q(() => Mr(e), [e]);
3877
3877
  }
3878
3878
  function Bt({
3879
3879
  api: e,
@@ -3885,76 +3885,76 @@ function Bt({
3885
3885
  isStreaming: a,
3886
3886
  getMessages: i
3887
3887
  }) {
3888
- const [u, c] = $(null), p = X(
3888
+ const [u, c] = $(null), f = Q(
3889
3889
  () => gt(u),
3890
3890
  [u]
3891
- ).checkpoints, m = Er(p), h = m.timeline, [k, d] = $(!1), [v, I] = $(!1), [A, T] = $(null), N = K(o), b = K(null), y = K(null);
3892
- W(() => {
3891
+ ).checkpoints, m = Er(f), h = m.timeline, [k, d] = $(!1), [v, I] = $(!1), [C, T] = $(null), N = K(o), w = K(null), y = K(null), x = K(null);
3892
+ q(() => {
3893
3893
  N.current = o;
3894
3894
  }, [o]);
3895
- const x = U(
3896
- async (C) => {
3895
+ const p = R(
3896
+ async (E) => {
3897
3897
  const L = await e.getState({
3898
- threadId: C.threadId,
3899
- checkpointId: C.checkpointId,
3900
- checkpointNs: C.checkpointNs
3898
+ threadId: E.threadId,
3899
+ checkpointId: E.checkpointId,
3900
+ checkpointNs: E.checkpointNs
3901
3901
  }), _ = {
3902
3902
  version: "values@1",
3903
- threadId: C.threadId,
3903
+ threadId: E.threadId,
3904
3904
  checkpoints: [L]
3905
- }, O = t ? await Ir(_, t) : _, { latest: F } = gt(O);
3905
+ }, G = t ? await Ir(_, t) : _, { latest: F } = gt(G);
3906
3906
  return F;
3907
3907
  },
3908
3908
  [e, t]
3909
- ), g = U(
3910
- async (C, L) => {
3911
- var G;
3912
- if (!C) return;
3913
- const _ = `${C}:${L ?? "latest"}`, O = i();
3914
- if (b.current === _ && !k && O.length > 0) return;
3915
- (G = y.current) == null || G.abort();
3916
- const F = new AbortController();
3917
- y.current = F, d(!0), T(null);
3909
+ ), b = R(
3910
+ async (E, L) => {
3911
+ var F;
3912
+ if (!E) return;
3913
+ const _ = `${E}:${L ?? "latest"}`;
3914
+ if (y.current === _ || w.current === _) return;
3915
+ y.current = _, (F = x.current) == null || F.abort();
3916
+ const G = new AbortController();
3917
+ x.current = G, d(!0), T(null);
3918
3918
  try {
3919
- const E = await x({
3920
- threadId: C,
3919
+ const P = await p({
3920
+ threadId: E,
3921
3921
  checkpointId: L ?? void 0
3922
3922
  });
3923
- if (N.current !== C) return;
3924
- n((E == null ? void 0 : E.messages) ?? [], {
3925
- checkpointId: (E == null ? void 0 : E.checkpointId) ?? null,
3926
- checkpointNs: (E == null ? void 0 : E.checkpointNs) ?? null,
3927
- pendingInterrupt: (E == null ? void 0 : E.interrupt) ?? null,
3928
- values: E == null ? void 0 : E.values
3929
- }), b.current = _;
3930
- const D = await e.getStateHistory({
3931
- threadId: C,
3923
+ if (N.current !== E) return;
3924
+ n((P == null ? void 0 : P.messages) ?? [], {
3925
+ checkpointId: (P == null ? void 0 : P.checkpointId) ?? null,
3926
+ checkpointNs: (P == null ? void 0 : P.checkpointNs) ?? null,
3927
+ pendingInterrupt: (P == null ? void 0 : P.interrupt) ?? null,
3928
+ values: P == null ? void 0 : P.values
3929
+ }), w.current = _;
3930
+ const V = await e.getStateHistory({
3931
+ threadId: E,
3932
3932
  limit: 100,
3933
3933
  includeMessages: !1
3934
3934
  });
3935
- N.current === C && c(D);
3936
- } catch (E) {
3937
- if (!Jt(E)) {
3938
- const D = String(E);
3939
- T(D), r == null || r(D);
3935
+ N.current === E && c(V);
3936
+ } catch (P) {
3937
+ if (!Jt(P)) {
3938
+ const V = String(P);
3939
+ T(V), r == null || r(V);
3940
3940
  }
3941
3941
  } finally {
3942
- d(!1);
3942
+ y.current = null, d(!1);
3943
3943
  }
3944
3944
  },
3945
- [e, n, x, r, k, i]
3946
- ), w = U(
3947
- async (C, L) => {
3945
+ [e, n, p, r, k, i]
3946
+ ), z = R(
3947
+ async (E, L) => {
3948
3948
  if (o) {
3949
3949
  I(!0);
3950
3950
  try {
3951
- const _ = await x({
3951
+ const _ = await p({
3952
3952
  threadId: o,
3953
- checkpointId: C,
3953
+ checkpointId: E,
3954
3954
  checkpointNs: L ?? void 0
3955
3955
  });
3956
3956
  n((_ == null ? void 0 : _.messages) ?? [], {
3957
- checkpointId: (_ == null ? void 0 : _.checkpointId) ?? C,
3957
+ checkpointId: (_ == null ? void 0 : _.checkpointId) ?? E,
3958
3958
  checkpointNs: (_ == null ? void 0 : _.checkpointNs) ?? L,
3959
3959
  pendingInterrupt: (_ == null ? void 0 : _.interrupt) ?? null,
3960
3960
  values: _ == null ? void 0 : _.values
@@ -3966,16 +3966,16 @@ function Bt({
3966
3966
  }
3967
3967
  }
3968
3968
  },
3969
- [o, x, n]
3970
- ), z = U(async () => {
3971
- o && await g(o);
3972
- }, [o, g]), j = U(
3973
- async (C) => {
3974
- var O;
3975
- const L = (C == null ? void 0 : C.threadId) || o;
3969
+ [o, p, n]
3970
+ ), j = R(async () => {
3971
+ o && await b(o);
3972
+ }, [o, b]), M = R(
3973
+ async (E) => {
3974
+ var G;
3975
+ const L = (E == null ? void 0 : E.threadId) || o;
3976
3976
  if (!L || o !== L) return;
3977
- if (c(C), b.current = `${L}:latest`, (O = C.values) != null && O.messages) {
3978
- const F = await x({
3977
+ if (c(E), w.current = `${L}:latest`, (G = E.values) != null && G.messages) {
3978
+ const F = await p({
3979
3979
  threadId: L
3980
3980
  });
3981
3981
  F && n(F.messages ?? [], {
@@ -3986,36 +3986,36 @@ function Bt({
3986
3986
  });
3987
3987
  }
3988
3988
  },
3989
- [o, x, n]
3989
+ [o, p, n]
3990
3990
  );
3991
- W(() => {
3991
+ q(() => {
3992
3992
  if (!s || !o || k || a) return;
3993
- const C = `${o}:latest`;
3994
- b.current !== C && g(o);
3995
- }, [s, o, k, a, g]);
3996
- const S = U(() => {
3997
- c(null), d(!1), I(!1), T(null), b.current = null;
3993
+ const E = `${o}:latest`;
3994
+ w.current !== E && b(o);
3995
+ }, [s, o, k, a, b]);
3996
+ const O = R(() => {
3997
+ c(null), d(!1), I(!1), T(null), w.current = null;
3998
3998
  }, []);
3999
3999
  return {
4000
- threadCheckpoints: p,
4000
+ threadCheckpoints: f,
4001
4001
  threadTimeline: h,
4002
4002
  checkpointIndex: m,
4003
4003
  isLoadingThread: k,
4004
4004
  isLoadingCheckpoint: v,
4005
- threadStateError: A,
4006
- loadThread: g,
4007
- navigateToCheckpoint: w,
4008
- setCurrentCheckpointId: (C, L) => {
4009
- n(i(), { checkpointId: C, checkpointNs: L });
4005
+ threadStateError: C,
4006
+ loadThread: b,
4007
+ navigateToCheckpoint: z,
4008
+ setCurrentCheckpointId: (E, L) => {
4009
+ n(i(), { checkpointId: E, checkpointNs: L });
4010
4010
  },
4011
- returnToLatest: z,
4012
- handleValuesEvent: j,
4011
+ returnToLatest: j,
4012
+ handleValuesEvent: M,
4013
4013
  markSkipNextLoad: () => {
4014
4014
  },
4015
4015
  markStreamPendingThread: () => {
4016
4016
  },
4017
- resetHistoryState: S,
4018
- clearState: S
4017
+ resetHistoryState: O,
4018
+ clearState: O
4019
4019
  };
4020
4020
  }
4021
4021
  const $t = Se(null), Vt = Se(null);
@@ -4039,25 +4039,25 @@ function Nr({
4039
4039
  isStreaming: s,
4040
4040
  onError: a
4041
4041
  }) {
4042
- const { chatApi: i, fileApi: u } = Ae(), { currentThreadId: c } = rt(), { state: l, seed: p, onEvent: m, dispatch: h } = mr(), {
4042
+ const { chatApi: i, fileApi: u } = Ae(), { currentThreadId: c } = rt(), { state: l, seed: f, onEvent: m, dispatch: h } = mr(), {
4043
4043
  threadCheckpoints: k,
4044
4044
  threadTimeline: d,
4045
4045
  checkpointIndex: v,
4046
4046
  isLoadingThread: I,
4047
- isLoadingCheckpoint: A,
4047
+ isLoadingCheckpoint: C,
4048
4048
  threadStateError: T,
4049
4049
  loadThread: N,
4050
- navigateToCheckpoint: b,
4050
+ navigateToCheckpoint: w,
4051
4051
  setCurrentCheckpointId: y,
4052
4052
  returnToLatest: x,
4053
- handleValuesEvent: g,
4054
- markSkipNextLoad: w,
4053
+ handleValuesEvent: p,
4054
+ markSkipNextLoad: b,
4055
4055
  markStreamPendingThread: z,
4056
4056
  resetHistoryState: j
4057
4057
  } = Bt({
4058
4058
  api: i,
4059
4059
  fileApi: u,
4060
- seed: p,
4060
+ seed: f,
4061
4061
  onError: a,
4062
4062
  currentThreadId: c,
4063
4063
  initialThreadId: t,
@@ -4065,32 +4065,34 @@ function Nr({
4065
4065
  initialCheckpointNs: r,
4066
4066
  autoLoadInitial: o,
4067
4067
  isStreaming: s,
4068
- getMessages: U(() => l.messages, [l.messages])
4069
- }), S = K(null), C = U(
4070
- (f) => {
4071
- S.current = f;
4068
+ getMessages: R(() => l.messages, [l.messages])
4069
+ }), M = K(null), O = R(
4070
+ (A) => {
4071
+ M.current = A;
4072
4072
  },
4073
4073
  []
4074
- ), L = K(null), _ = U(
4075
- (f) => {
4076
- L.current = f;
4074
+ ), E = K(null), L = R(
4075
+ (A) => {
4076
+ E.current = A;
4077
4077
  },
4078
4078
  []
4079
- ), O = X(() => ({ assemblingMessageId: l.assemblingId ?? null }), [l.assemblingId]), F = U(
4080
- (f, P) => {
4081
- const M = Ut(f, "user");
4079
+ ), _ = Q(() => ({ assemblingMessageId: l.assemblingId ?? null }), [l.assemblingId]), G = R(
4080
+ (A, S) => {
4081
+ const H = Ut(A, "user");
4082
4082
  return h({
4083
4083
  type: "user_message",
4084
4084
  payload: {
4085
- message: M,
4086
- editingMessageId: P == null ? void 0 : P.editingMessageId
4085
+ message: H,
4086
+ editingMessageId: S == null ? void 0 : S.editingMessageId
4087
4087
  }
4088
- }), M;
4088
+ }), H;
4089
4089
  },
4090
4090
  [h]
4091
- ), G = U(async () => {
4092
- S.current ? await S.current() : (p([], {}), j());
4093
- }, [p, j]), E = X(() => Ln(l.messages), [l.messages]), D = X(
4091
+ ), F = R(async () => {
4092
+ M.current ? await M.current() : (f([], {}), j());
4093
+ }, [f, j]), P = R(async (A, S, H) => {
4094
+ await N(A, S, { clearProgress: !1 });
4095
+ }, [N]), V = Q(() => Ln(l.messages), [l.messages]), Y = Q(
4094
4096
  () => ({
4095
4097
  status: l.status,
4096
4098
  threadId: c,
@@ -4104,41 +4106,39 @@ function Nr({
4104
4106
  checkpoints: k,
4105
4107
  checkpointIndex: v,
4106
4108
  timelineCheckpoints: d,
4107
- metadata: O,
4109
+ metadata: _,
4108
4110
  values: l.values ?? {},
4109
4111
  isLoading: I,
4110
- isLoadingCheckpoint: A,
4112
+ isLoadingCheckpoint: C,
4111
4113
  error: T,
4112
4114
  loadOlder: async () => {
4113
4115
  },
4114
4116
  // Placeholder
4115
- seedFromSnapshot: (f) => {
4116
- p(f.messages, {
4117
- checkpointId: f.checkpointId,
4118
- checkpointNs: f.checkpointNs,
4119
- pendingInterrupt: f.interrupt,
4120
- values: f.values
4117
+ seedFromSnapshot: (A) => {
4118
+ f(A.messages, {
4119
+ checkpointId: A.checkpointId,
4120
+ checkpointNs: A.checkpointNs,
4121
+ pendingInterrupt: A.interrupt,
4122
+ values: A.values
4121
4123
  });
4122
4124
  },
4123
- clearState: G,
4124
- navigateToCheckpoint: b,
4125
+ clearState: F,
4126
+ navigateToCheckpoint: w,
4125
4127
  setCurrentCheckpointId: y,
4126
4128
  returnToLatest: x,
4127
- loadThread: async (f, P, M) => {
4128
- await N(f, P, { clearProgress: !1 });
4129
- },
4130
- clearThread: G,
4131
- respondToInterrupt: async (f, P, M) => {
4132
- L.current && await L.current(f, P, M);
4129
+ loadThread: P,
4130
+ clearThread: F,
4131
+ respondToInterrupt: async (A, S, H) => {
4132
+ E.current && await E.current(A, S, H);
4133
4133
  },
4134
4134
  messagePreviews: v.messagePreviews,
4135
- handleValuesEvent: g,
4136
- markSkipNextLoad: w,
4135
+ handleValuesEvent: p,
4136
+ markSkipNextLoad: b,
4137
4137
  markStreamPendingThread: z,
4138
4138
  resetHistoryState: j,
4139
- pushUser: F,
4139
+ pushUser: G,
4140
4140
  onEvent: m,
4141
- artifacts: E
4141
+ artifacts: V
4142
4142
  }),
4143
4143
  [
4144
4144
  c,
@@ -4151,31 +4151,31 @@ function Nr({
4151
4151
  k,
4152
4152
  d,
4153
4153
  v,
4154
- O,
4154
+ _,
4155
4155
  I,
4156
- A,
4156
+ C,
4157
4157
  T,
4158
- p,
4159
- G,
4160
- b,
4158
+ f,
4159
+ F,
4160
+ w,
4161
4161
  y,
4162
4162
  x,
4163
- N,
4164
- g,
4165
- w,
4163
+ P,
4164
+ p,
4165
+ b,
4166
4166
  z,
4167
- F,
4167
+ G,
4168
4168
  m,
4169
- E
4169
+ V
4170
4170
  ]
4171
- ), Q = X(
4171
+ ), g = Q(
4172
4172
  () => ({
4173
- registerClearThread: C,
4174
- registerRespondToInterrupt: _
4173
+ registerClearThread: O,
4174
+ registerRespondToInterrupt: L
4175
4175
  }),
4176
- [C, _]
4176
+ [O, L]
4177
4177
  );
4178
- return /* @__PURE__ */ ie(Vt.Provider, { value: Q, children: /* @__PURE__ */ ie($t.Provider, { value: D, children: e }) });
4178
+ return /* @__PURE__ */ ie(Vt.Provider, { value: g, children: /* @__PURE__ */ ie($t.Provider, { value: Y, children: e }) });
4179
4179
  }
4180
4180
  const Kt = Se(null), _r = Se(!1);
4181
4181
  function zr({
@@ -4190,13 +4190,13 @@ function zr({
4190
4190
  onFinish: u,
4191
4191
  onStreamingChange: c
4192
4192
  }) {
4193
- const { chatApi: l, baseUrl: p } = Ae(), m = p, h = pe(t), k = pe(n), d = pe(r), v = pe(o), I = pe(s), A = pe(a), T = pe(i), N = pe(u), b = pe(c), y = X(
4193
+ const { chatApi: l, baseUrl: f } = Ae(), m = f, h = pe(t), k = pe(n), d = pe(r), v = pe(o), I = pe(s), C = pe(a), T = pe(i), N = pe(u), w = pe(c), y = Q(
4194
4194
  () => ({
4195
4195
  onError: h,
4196
4196
  onAuthError: k,
4197
4197
  onConnectionError: d,
4198
4198
  onMetadataEvent: T,
4199
- onCustomEvent: A,
4199
+ onCustomEvent: C,
4200
4200
  onUpdateEvent: I,
4201
4201
  onToolEnd: v,
4202
4202
  onFinish: N
@@ -4206,7 +4206,7 @@ function zr({
4206
4206
  k,
4207
4207
  d,
4208
4208
  T,
4209
- A,
4209
+ C,
4210
4210
  I,
4211
4211
  v,
4212
4212
  N
@@ -4218,7 +4218,7 @@ function zr({
4218
4218
  api: l,
4219
4219
  streamBaseUrl: m,
4220
4220
  handlers: y,
4221
- onStreamingChange: b,
4221
+ onStreamingChange: w,
4222
4222
  children: e
4223
4223
  }
4224
4224
  ) });
@@ -4233,159 +4233,159 @@ function Rr({
4233
4233
  const { setCurrentThreadId: s, currentThreadIdRef: a, addThreadFromEvent: i, currentThreadId: u } = rt(), {
4234
4234
  interrupt: c,
4235
4235
  checkpoint: l,
4236
- timelineCheckpoints: p,
4236
+ timelineCheckpoints: f,
4237
4237
  handleValuesEvent: m,
4238
4238
  markSkipNextLoad: h,
4239
4239
  markStreamPendingThread: k,
4240
4240
  resetHistoryState: d,
4241
4241
  pushUser: v,
4242
4242
  onEvent: I,
4243
- messages: A
4244
- } = Dt(), { registerClearThread: T, registerRespondToInterrupt: N } = Pr(), b = U(
4245
- (f) => {
4246
- i(f), k(f.threadId), a.current !== f.threadId && ((f.created ?? !a.current) && h(f.threadId), s(f.threadId));
4243
+ messages: C
4244
+ } = Dt(), { registerClearThread: T, registerRespondToInterrupt: N } = Pr(), w = R(
4245
+ (g) => {
4246
+ i(g), k(g.threadId), a.current !== g.threadId && ((g.created ?? !a.current) && h(g.threadId), s(g.threadId));
4247
4247
  },
4248
4248
  [i, h, k, s, a]
4249
4249
  ), y = cr({
4250
4250
  baseUrl: n,
4251
4251
  onEvent: I,
4252
- onError: (f) => {
4253
- var P;
4254
- (P = r.onError) == null || P.call(r, (f == null ? void 0 : f.message) ?? String(f));
4252
+ onError: (g) => {
4253
+ var A;
4254
+ (A = r.onError) == null || A.call(r, (g == null ? void 0 : g.message) ?? String(g));
4255
4255
  },
4256
4256
  onAuthError: r.onAuthError,
4257
4257
  onConnectionError: r.onConnectionError,
4258
4258
  onFinish: r.onFinish,
4259
- onThreadInfo: b,
4259
+ onThreadInfo: w,
4260
4260
  onMetadataEvent: r.onMetadataEvent,
4261
4261
  onCustomEvent: r.onCustomEvent,
4262
4262
  onUpdateEvent: r.onUpdateEvent,
4263
4263
  onToolEnd: r.onToolEnd,
4264
4264
  handleValuesEvent: m
4265
4265
  });
4266
- W(() => {
4266
+ q(() => {
4267
4267
  o == null || o(y.isStreaming);
4268
4268
  }, [y.isStreaming, o]);
4269
- const { stream: x, stop: g, clear: w, isStreaming: z, error: j, connected: S, streamedMessages: C, activeMessageId: L } = y;
4270
- W(() => {
4271
- u !== void 0 && w();
4272
- }, [u, w]);
4273
- const _ = U(
4274
- async (f, P) => {
4275
- await x(f, P);
4269
+ const { stream: x, stop: p, clear: b, isStreaming: z, error: j, connected: M, streamedMessages: O, activeMessageId: E } = y;
4270
+ q(() => {
4271
+ u !== void 0 && b();
4272
+ }, [u, b]);
4273
+ const L = R(
4274
+ async (g, A) => {
4275
+ await x(g, A);
4276
4276
  },
4277
4277
  [x]
4278
- ), O = K(l);
4279
- W(() => {
4280
- O.current = l;
4278
+ ), _ = K(l);
4279
+ q(() => {
4280
+ _.current = l;
4281
4281
  }, [l]);
4282
- const F = U(
4283
- async (f, P, M) => {
4284
- const te = a.current;
4285
- if (!te)
4282
+ const G = R(
4283
+ async (g, A, S) => {
4284
+ const H = a.current;
4285
+ if (!H)
4286
4286
  throw new Error("No active thread to handle interrupt");
4287
- const q = f ? P ?? !0 : !1, V = O.current, Z = (M == null ? void 0 : M.checkpointId) ?? V.id ?? void 0, oe = (M == null ? void 0 : M.checkpointNs) ?? V.namespace ?? void 0, ue = {
4288
- threadId: te,
4289
- checkpointId: Z,
4287
+ const J = g ? A ?? !0 : !1, D = _.current, ee = (S == null ? void 0 : S.checkpointId) ?? D.id ?? void 0, oe = (S == null ? void 0 : S.checkpointNs) ?? D.namespace ?? void 0, ue = {
4288
+ threadId: H,
4289
+ checkpointId: ee,
4290
4290
  checkpointNs: oe,
4291
- command: { kind: "resume", value: q },
4292
- payload: M == null ? void 0 : M.payload
4291
+ command: { kind: "resume", value: J },
4292
+ payload: S == null ? void 0 : S.payload
4293
4293
  };
4294
- _(ue);
4294
+ L(ue);
4295
4295
  },
4296
- [a, _]
4296
+ [a, L]
4297
4297
  );
4298
- W(() => {
4299
- N(F);
4300
- }, [F, N]);
4301
- const G = U(async () => {
4302
- g(), w(), d(), s(null);
4303
- }, [w, d, s, g]);
4304
- W(() => {
4305
- T(G);
4306
- }, [G, T]);
4307
- const E = U(
4308
- async (f, P) => {
4309
- z && g();
4310
- let M = a.current;
4311
- const te = (f == null ? void 0 : f.text) ?? "", q = (f == null ? void 0 : f.attachments) ?? [], V = (te == null ? void 0 : te.trim()) ?? "", Z = { ...(f == null ? void 0 : f.payload) ?? {} }, oe = Array.isArray(Z.messages) ? Z.messages : void 0;
4312
- oe && delete Z.messages;
4313
- const ue = !!(oe && oe.length), H = !!(f.contentParts && f.contentParts.length > 0);
4314
- if (!M && !V && q.length === 0 && !ue && !H) return;
4315
- if (!M) {
4298
+ q(() => {
4299
+ N(G);
4300
+ }, [G, N]);
4301
+ const F = R(async () => {
4302
+ p(), b(), d(), s(null);
4303
+ }, [b, d, s, p]);
4304
+ q(() => {
4305
+ T(F);
4306
+ }, [F, T]);
4307
+ const P = R(
4308
+ async (g, A) => {
4309
+ z && p();
4310
+ let S = a.current;
4311
+ const H = (g == null ? void 0 : g.text) ?? "", J = (g == null ? void 0 : g.attachments) ?? [], D = (H == null ? void 0 : H.trim()) ?? "", ee = { ...(g == null ? void 0 : g.payload) ?? {} }, oe = Array.isArray(ee.messages) ? ee.messages : void 0;
4312
+ oe && delete ee.messages;
4313
+ const ue = !!(oe && oe.length), W = !!(g.contentParts && g.contentParts.length > 0);
4314
+ if (!S && !D && J.length === 0 && !ue && !W) return;
4315
+ if (!S) {
4316
4316
  const he = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0"), ye = Array.from({ length: 4 }, () => Math.floor(Math.random() * 4294967295).toString(16).padStart(8, "0")).join("").slice(0, 16);
4317
- M = `${he}${ye}`, h(M), s(M);
4317
+ S = `${he}${ye}`, h(S), s(S);
4318
4318
  }
4319
- let ee = null;
4320
- f.contentParts && f.contentParts.length > 0 && (ee = f.contentParts);
4321
- const { contentParts: ve, filesInfo: J } = ee ? { contentParts: ee, filesInfo: [] } : await rr(q), Y = [...ve];
4322
- V && Y.push({ type: "text", text: te });
4323
- const me = f == null ? void 0 : f.originalMessageId, je = !!(f != null && f.edit && me), Le = !ue && Y.length > 0;
4319
+ let te = null;
4320
+ g.contentParts && g.contentParts.length > 0 && (te = g.contentParts);
4321
+ const { contentParts: ve, filesInfo: X } = te ? { contentParts: te, filesInfo: [] } : await rr(J), Z = [...ve];
4322
+ D && Z.push({ type: "text", text: H });
4323
+ const me = g == null ? void 0 : g.originalMessageId, je = !!(g != null && g.edit && me), Le = !ue && Z.length > 0;
4324
4324
  let de = null;
4325
4325
  if (Le) {
4326
4326
  const he = je ? me : `msg-${Date.now()}`;
4327
4327
  de = Ut({
4328
4328
  id: he,
4329
4329
  role: "user",
4330
- content: Y,
4330
+ content: Z,
4331
4331
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
4332
4332
  }, "user"), je ? v(de, { editingMessageId: me }) : v(de);
4333
4333
  }
4334
4334
  const Ie = ue ? oe : de ? [de] : [], ne = {
4335
- ...Z,
4336
- ...J.length ? { files_info: J } : {}
4335
+ ...ee,
4336
+ ...X.length ? { files_info: X } : {}
4337
4337
  };
4338
4338
  Ie.length ? ne.messages = Ie : "messages" in ne || (ne.messages = []);
4339
- const Me = (f == null ? void 0 : f.checkpointId) ?? l.id ?? void 0;
4340
- if (f != null && f.edit && !Me)
4339
+ const Me = (g == null ? void 0 : g.checkpointId) ?? l.id ?? void 0;
4340
+ if (g != null && g.edit && !Me)
4341
4341
  throw new Error(
4342
- `[streaming] Missing checkpointId for edit submit. threadId=${M ?? "null"}`
4342
+ `[streaming] Missing checkpointId for edit submit. threadId=${S ?? "null"}`
4343
4343
  );
4344
4344
  const Ee = {
4345
- threadId: M,
4346
- content: f == null ? void 0 : f.text,
4345
+ threadId: S,
4346
+ content: g == null ? void 0 : g.text,
4347
4347
  payload: ne,
4348
- config: f == null ? void 0 : f.config,
4348
+ config: g == null ? void 0 : g.config,
4349
4349
  checkpointId: Me,
4350
- command: f == null ? void 0 : f.command,
4351
- edit: f == null ? void 0 : f.edit
4350
+ command: g == null ? void 0 : g.command,
4351
+ edit: g == null ? void 0 : g.edit
4352
4352
  };
4353
- return _(Ee, P);
4353
+ return L(Ee, A);
4354
4354
  },
4355
- [l, a, z, h, v, _, g, p]
4356
- ), D = X(() => {
4357
- const f = Object.keys(C).length > 0;
4358
- if (!z && !f)
4359
- return A;
4360
- const P = /* @__PURE__ */ new Map();
4361
- return A.forEach((M) => P.set(M.id, M)), Object.values(C).forEach((M) => {
4362
- P.set(M.id, M);
4363
- }), Array.from(P.values());
4364
- }, [z, C, A]), Q = X(
4355
+ [l, a, z, h, v, L, p, f]
4356
+ ), V = Q(() => {
4357
+ const g = Object.keys(O).length > 0;
4358
+ if (!z && !g)
4359
+ return C;
4360
+ const A = /* @__PURE__ */ new Map();
4361
+ return C.forEach((S) => A.set(S.id, S)), Object.values(O).forEach((S) => {
4362
+ A.set(S.id, S);
4363
+ }), Array.from(A.values());
4364
+ }, [z, O, C]), Y = Q(
4365
4365
  () => ({
4366
4366
  isStreaming: z,
4367
4367
  error: j,
4368
- connectionState: j ? "error" : z ? S ? "connected" : "connecting" : "idle",
4369
- messages: D,
4370
- activeMessageId: L,
4371
- submit: E,
4372
- stop: g,
4368
+ connectionState: j ? "error" : z ? M ? "connected" : "connecting" : "idle",
4369
+ messages: V,
4370
+ activeMessageId: E,
4371
+ submit: P,
4372
+ stop: p,
4373
4373
  interrupt: c,
4374
4374
  resume: () => Promise.resolve(),
4375
- goto: (f, P) => Promise.resolve(),
4375
+ goto: (g, A) => Promise.resolve(),
4376
4376
  clearError: () => {
4377
4377
  }
4378
4378
  // TODO: Implement error clearing
4379
4379
  }),
4380
- [z, j, E, g, c, S, D]
4380
+ [z, j, P, p, c, M, V]
4381
4381
  );
4382
- return /* @__PURE__ */ ie(Kt.Provider, { value: Q, children: e });
4382
+ return /* @__PURE__ */ ie(Kt.Provider, { value: Y, children: e });
4383
4383
  }
4384
4384
  function pe(e) {
4385
4385
  const t = K(e);
4386
- return W(() => {
4386
+ return q(() => {
4387
4387
  t.current = e;
4388
- }, [e]), U((...n) => {
4388
+ }, [e]), R((...n) => {
4389
4389
  const r = t.current;
4390
4390
  if (r)
4391
4391
  return r(...n);
@@ -4435,30 +4435,30 @@ function io({
4435
4435
  onAuthError: u,
4436
4436
  onThreadChange: c,
4437
4437
  onToolEnd: l,
4438
- onUpdateEvent: p,
4438
+ onUpdateEvent: f,
4439
4439
  onCustomEvent: m,
4440
4440
  onMetadataEvent: h,
4441
4441
  onFinish: k
4442
4442
  }) {
4443
- const d = Lr(t), [v, I] = $(!1), A = ge(i), T = ge(u), N = ge(a), b = ge(c), y = ge(l), x = ge(p), g = ge(m), w = ge(h), z = ge(k), j = X(
4443
+ const d = Lr(t), [v, I] = $(!1), C = ge(i), T = ge(u), N = ge(a), w = ge(c), y = ge(l), x = ge(f), p = ge(m), b = ge(h), z = ge(k), j = Q(
4444
4444
  () => ({
4445
- onError: A,
4445
+ onError: C,
4446
4446
  onAuthError: T,
4447
4447
  onConnectionError: N,
4448
4448
  onToolEnd: y,
4449
4449
  onUpdateEvent: x,
4450
- onCustomEvent: g,
4451
- onMetadataEvent: w,
4450
+ onCustomEvent: p,
4451
+ onMetadataEvent: b,
4452
4452
  onFinish: z
4453
4453
  }),
4454
4454
  [
4455
- A,
4455
+ C,
4456
4456
  T,
4457
4457
  N,
4458
4458
  y,
4459
4459
  x,
4460
- g,
4461
- w,
4460
+ p,
4461
+ b,
4462
4462
  z
4463
4463
  ]
4464
4464
  );
@@ -4466,8 +4466,8 @@ function io({
4466
4466
  ur,
4467
4467
  {
4468
4468
  initialThreadId: n,
4469
- onError: A,
4470
- onThreadChange: b,
4469
+ onError: C,
4470
+ onThreadChange: w,
4471
4471
  children: /* @__PURE__ */ ie(
4472
4472
  Nr,
4473
4473
  {
@@ -4475,7 +4475,7 @@ function io({
4475
4475
  initialCheckpointId: r,
4476
4476
  initialCheckpointNs: o,
4477
4477
  autoLoadInitial: s,
4478
- onError: A,
4478
+ onError: C,
4479
4479
  isStreaming: v,
4480
4480
  children: /* @__PURE__ */ ie(
4481
4481
  zr,
@@ -4492,7 +4492,7 @@ function io({
4492
4492
  }
4493
4493
  function ge(e) {
4494
4494
  const t = K(e);
4495
- return t.current = e, U((...n) => {
4495
+ return t.current = e, R((...n) => {
4496
4496
  const r = t.current;
4497
4497
  if (r)
4498
4498
  return r(...n);
@@ -4590,13 +4590,13 @@ function Kr() {
4590
4590
  };
4591
4591
  }
4592
4592
  function co(e) {
4593
- const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Ae(), { toast: o } = Kr(), [s, a] = $({}), [i, u] = $(null), [c, l] = $(!1), p = U(() => {
4593
+ const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Ae(), { toast: o } = Kr(), [s, a] = $({}), [i, u] = $(null), [c, l] = $(!1), f = R(() => {
4594
4594
  l(!1), u(null);
4595
- }, []), m = U((k) => {
4595
+ }, []), m = R((k) => {
4596
4596
  u(k), l(!0);
4597
- }, []), h = U(
4597
+ }, []), h = R(
4598
4598
  async (k, d, v) => {
4599
- var I, A;
4599
+ var I, C;
4600
4600
  if (!t) {
4601
4601
  k.preventDefault();
4602
4602
  return;
@@ -4609,18 +4609,18 @@ function co(e) {
4609
4609
  const T = String(d.url ?? ""), N = T.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);
4610
4610
  if (N) {
4611
4611
  k.preventDefault();
4612
- const b = N[1], y = d.name || `file_${b}`, x = d.mimeType || "application/octet-stream";
4613
- m({ id: b, name: y, mimeType: x });
4612
+ const w = N[1], y = d.name || `file_${w}`, x = d.mimeType || "application/octet-stream";
4613
+ m({ id: w, name: y, mimeType: x });
4614
4614
  return;
4615
4615
  }
4616
4616
  if (T.startsWith("data:")) {
4617
4617
  k.preventDefault(), a((y) => ({ ...y, [v]: !0 }));
4618
- const b = o({ title: "Fetching file...", description: "", open: !0 });
4618
+ const w = o({ title: "Fetching file...", description: "", open: !0 });
4619
4619
  try {
4620
4620
  const y = await r.listFiles(n ?? void 0);
4621
4621
  if (!y || !Array.isArray(y))
4622
4622
  throw new Error("Invalid file list response");
4623
- const x = y.find((g) => !g || typeof g != "object" || !((g.filename ?? "") === (d.name ?? "")) ? !1 : typeof d.size == "number" && typeof g.size == "number" ? g.size === d.size : !0);
4623
+ const x = y.find((p) => !p || typeof p != "object" || !((p.filename ?? "") === (d.name ?? "")) ? !1 : typeof d.size == "number" && typeof p.size == "number" ? p.size === d.size : !0);
4624
4624
  if (!(x != null && x.id))
4625
4625
  throw new Error(`File "${d.name}" is not yet available on the server`);
4626
4626
  if (!x.id || !x.filename)
@@ -4629,8 +4629,8 @@ function co(e) {
4629
4629
  id: x.id,
4630
4630
  name: d.name || x.filename || `file_${x.id}`,
4631
4631
  mimeType: d.mimeType || x.mime_type || "application/octet-stream"
4632
- }), (I = b.update) == null || I.call(b, {
4633
- id: b.id,
4632
+ }), (I = w.update) == null || I.call(w, {
4633
+ id: w.id,
4634
4634
  title: "Success",
4635
4635
  description: `Opened ${d.name}`,
4636
4636
  open: !0
@@ -4638,7 +4638,7 @@ function co(e) {
4638
4638
  } catch (y) {
4639
4639
  console.error("Failed to fetch server file:", y);
4640
4640
  const x = y instanceof Error ? y.message : "Unknown error occurred";
4641
- (A = b.update) == null || A.call(b, { id: b.id, title: "Failed", description: x }), o({
4641
+ (C = w.update) == null || C.call(w, { id: w.id, title: "Failed", description: x }), o({
4642
4642
  title: "Failed to fetch file",
4643
4643
  description: x,
4644
4644
  open: !0
@@ -4658,11 +4658,11 @@ function co(e) {
4658
4658
  handleFileClick: h,
4659
4659
  fileViewerOpen: c,
4660
4660
  currentFileInfo: i,
4661
- closeFileViewer: p
4661
+ closeFileViewer: f
4662
4662
  };
4663
4663
  }
4664
4664
  function lo(e) {
4665
- return X(() => {
4665
+ return Q(() => {
4666
4666
  const t = e;
4667
4667
  let n = Array.isArray(t.content) ? t.content : [];
4668
4668
  return typeof t.content == "string" && (n = [{ type: "text", text: t.content }]), {
@@ -4701,7 +4701,7 @@ function Hr(e) {
4701
4701
  return null;
4702
4702
  }
4703
4703
  function uo(e) {
4704
- return X(() => {
4704
+ return Q(() => {
4705
4705
  const t = e.content.filter(
4706
4706
  (u) => u.type === "text"
4707
4707
  );
@@ -4740,8 +4740,8 @@ function Wr(e) {
4740
4740
  setCurrentThreadId: () => {
4741
4741
  },
4742
4742
  actions: {}
4743
- }, c = !!t && t !== a, [l, p] = $([]), m = U((j) => {
4744
- p(j);
4743
+ }, c = !!t && t !== a, [l, f] = $([]), m = R((j) => {
4744
+ f(j);
4745
4745
  }, []), {
4746
4746
  isLoadingThread: h,
4747
4747
  threadStateError: k,
@@ -4757,24 +4757,24 @@ function Wr(e) {
4757
4757
  getMessages: () => l,
4758
4758
  autoLoadInitial: c && !n
4759
4759
  });
4760
- W(() => {
4760
+ q(() => {
4761
4761
  !c && !n && a && (o != null && o.loadThread) && o.loadThread(a);
4762
4762
  }, [c, n, a, o == null ? void 0 : o.loadThread]);
4763
- const I = X(() => {
4763
+ const I = Q(() => {
4764
4764
  var j;
4765
4765
  return ((j = d[0]) == null ? void 0 : j.values) || {};
4766
- }, [d]), A = X(() => ({ timeline: [], messagePreviews: {} }), []), T = t || a, N = c ? h ? "loading" : "idle" : (o == null ? void 0 : o.status) || "idle", b = c ? l : (s == null ? void 0 : s.messages) || [], y = c ? h : (o == null ? void 0 : o.isLoading) || !1, x = c ? I : (o == null ? void 0 : o.values) || {}, g = c ? {} : (o == null ? void 0 : o.taskMessagesByScope) || {}, w = c ? k : (s == null ? void 0 : s.error) || (o == null ? void 0 : o.error) || null;
4766
+ }, [d]), C = Q(() => ({ timeline: [], messagePreviews: {} }), []), T = t || a, N = c ? h ? "loading" : "idle" : (o == null ? void 0 : o.status) || "idle", w = c ? l : (s == null ? void 0 : s.messages) || [], y = c ? h : (o == null ? void 0 : o.isLoading) || !1, x = c ? I : (o == null ? void 0 : o.values) || {}, p = c ? {} : (o == null ? void 0 : o.taskMessagesByScope) || {}, b = c ? k : (s == null ? void 0 : s.error) || (o == null ? void 0 : o.error) || null;
4767
4767
  return {
4768
4768
  // UNIFIED: Single thread ID concept
4769
4769
  threadId: T,
4770
4770
  status: N,
4771
- messages: b,
4771
+ messages: w,
4772
4772
  isLoading: y,
4773
4773
  isHistoryLoading: y,
4774
- error: w,
4774
+ error: b,
4775
4775
  // Values & Metadata
4776
4776
  values: x,
4777
- taskMessagesByScope: g,
4777
+ taskMessagesByScope: p,
4778
4778
  metadata: c ? {} : o == null ? void 0 : o.metadata,
4779
4779
  // Actions & State relating to Global/Active Thread only
4780
4780
  navigateToCheckpoint: c ? async () => {
@@ -4785,7 +4785,7 @@ function Wr(e) {
4785
4785
  }),
4786
4786
  checkpoint: c ? d[0] ? { id: d[0].checkpointId, namespace: d[0].checkpointNs } : null : (o == null ? void 0 : o.checkpoint) || null,
4787
4787
  checkpoints: c ? d : (o == null ? void 0 : o.checkpoints) || [],
4788
- checkpointIndex: c ? A : (o == null ? void 0 : o.checkpointIndex) || { timeline: [], messagePreviews: {} },
4788
+ checkpointIndex: c ? C : (o == null ? void 0 : o.checkpointIndex) || { timeline: [], messagePreviews: {} },
4789
4789
  interrupt: c ? null : (o == null ? void 0 : o.interrupt) || null,
4790
4790
  respondToInterrupt: c ? async () => {
4791
4791
  } : (o == null ? void 0 : o.respondToInterrupt) || (async () => {
@@ -4829,156 +4829,156 @@ function fo({
4829
4829
  messages: u,
4830
4830
  setPendingAssistantResponse: c,
4831
4831
  project: l,
4832
- onEvent: p,
4832
+ onEvent: f,
4833
4833
  threadId: m,
4834
4834
  clearComposerOnSend: h = !0
4835
4835
  }) {
4836
- const { messages: k } = Wr(), [d, v] = $(null), [I, A] = $(""), [T, N] = $(null), [b, y] = $(null), [x, g] = $(!1), [w, z] = $(""), j = K(w), S = K(null);
4837
- W(() => {
4836
+ const { messages: k } = Wr(), [d, v] = $(null), [I, C] = $(""), [T, N] = $(null), [w, y] = $(null), [x, p] = $(!1), [b, z] = $(""), j = K(b), M = K(null);
4837
+ q(() => {
4838
4838
  if (!d)
4839
4839
  if (m) {
4840
- const f = localStorage.getItem(He(m));
4841
- z(f || "");
4840
+ const g = localStorage.getItem(He(m));
4841
+ z(g || "");
4842
4842
  } else
4843
4843
  z("");
4844
4844
  }, [m, d]);
4845
- const C = U((f) => {
4846
- z(f), !d && m && localStorage.setItem(He(m), f);
4845
+ const O = R((g) => {
4846
+ z(g), !d && m && localStorage.setItem(He(m), g);
4847
4847
  }, [m, d]);
4848
- W(() => {
4849
- j.current = w;
4850
- }, [w]), W(() => {
4848
+ q(() => {
4849
+ j.current = b;
4850
+ }, [b]), q(() => {
4851
4851
  if (!d) {
4852
- S.current = null;
4852
+ M.current = null;
4853
4853
  return;
4854
4854
  }
4855
- S.current === null && (S.current = j.current), C(I ?? "");
4856
- }, [I, d, C]);
4857
- const L = U(
4858
- (f) => {
4859
- C(f);
4855
+ M.current === null && (M.current = j.current), O(I ?? "");
4856
+ }, [I, d, O]);
4857
+ const E = R(
4858
+ (g) => {
4859
+ O(g);
4860
4860
  },
4861
- [C]
4862
- ), _ = async (f, P) => {
4863
- const M = Array.isArray(P) ? { files: P } : P ?? {}, te = M.files ?? [], q = M.contentParts ?? [], V = f.trim();
4864
- if (!(!V && te.length === 0 && q.length === 0))
4861
+ [O]
4862
+ ), L = async (g, A) => {
4863
+ const S = Array.isArray(A) ? { files: A } : A ?? {}, H = S.files ?? [], J = S.contentParts ?? [], D = g.trim();
4864
+ if (!(!D && H.length === 0 && J.length === 0))
4865
4865
  try {
4866
- const Z = te.map(async (J) => {
4866
+ const ee = H.map(async (X) => {
4867
4867
  try {
4868
- const Y = await zt.uploadFile(J);
4869
- return { file: J, record: Y };
4870
- } catch (Y) {
4871
- throw console.error("Failed to upload file", J.name, Y), new Error(`Failed to upload ${J.name}`);
4868
+ const Z = await zt.uploadFile(X);
4869
+ return { file: X, record: Z };
4870
+ } catch (Z) {
4871
+ throw console.error("Failed to upload file", X.name, Z), new Error(`Failed to upload ${X.name}`);
4872
4872
  }
4873
- }), ue = (await Promise.all(Z)).map(({ record: J }) => {
4874
- const Y = J.mime_type;
4875
- return Y.startsWith("image/") ? {
4873
+ }), ue = (await Promise.all(ee)).map(({ record: X }) => {
4874
+ const Z = X.mime_type;
4875
+ return Z.startsWith("image/") ? {
4876
4876
  type: "image_url",
4877
- image_url: { url: J.content_url }
4877
+ image_url: { url: X.content_url }
4878
4878
  } : {
4879
4879
  type: "file",
4880
- url: J.content_url,
4881
- mimeType: Y,
4882
- name: J.filename,
4883
- size: J.size
4880
+ url: X.content_url,
4881
+ mimeType: Z,
4882
+ name: X.filename,
4883
+ size: X.size
4884
4884
  };
4885
- }), H = [...q, ...ue], ee = d ? (T == null ? void 0 : T.checkpointId) ?? n ?? void 0 : n ?? void 0, ve = d ? (T == null ? void 0 : T.checkpointNs) ?? r ?? void 0 : r ?? void 0;
4885
+ }), W = [...J, ...ue], te = d ? (T == null ? void 0 : T.checkpointId) ?? n ?? void 0 : n ?? void 0, ve = d ? (T == null ? void 0 : T.checkpointNs) ?? r ?? void 0 : r ?? void 0;
4886
4886
  await e(
4887
4887
  {
4888
- text: V || "",
4889
- contentParts: H,
4890
- attachments: te,
4888
+ text: D || "",
4889
+ contentParts: W,
4890
+ attachments: H,
4891
4891
  payload: t.payload,
4892
4892
  edit: !!d,
4893
- checkpointId: ee,
4893
+ checkpointId: te,
4894
4894
  checkpointNs: ve,
4895
4895
  project: l ?? void 0,
4896
4896
  originalMessageId: d ?? void 0,
4897
4897
  config: t.config
4898
4898
  },
4899
- p ? { onEvent: p } : void 0
4900
- ), o == null || o(V), c(!0), h && (m && localStorage.removeItem(He(m)), C("")), y(null), v(null), A(""), N(null);
4901
- } catch (Z) {
4902
- const oe = (Z == null ? void 0 : Z.message) || "Failed to send message";
4899
+ f ? { onEvent: f } : void 0
4900
+ ), o == null || o(D), c(!0), h && (m && localStorage.removeItem(He(m)), O("")), y(null), v(null), C(""), N(null);
4901
+ } catch (ee) {
4902
+ const oe = (ee == null ? void 0 : ee.message) || "Failed to send message";
4903
4903
  y(oe), a == null || a(oe), c(!1);
4904
4904
  }
4905
- }, O = (f, P) => {
4906
- P || _(f, { files: [] });
4907
- }, F = U(
4908
- async (f) => {
4905
+ }, _ = (g, A) => {
4906
+ A || L(g, { files: [] });
4907
+ }, G = R(
4908
+ async (g) => {
4909
4909
  await e(
4910
4910
  {
4911
- attachments: [f],
4911
+ attachments: [g],
4912
4912
  payload: t.payload,
4913
4913
  checkpointId: n ?? void 0,
4914
4914
  checkpointNs: r ?? void 0,
4915
4915
  project: l ?? void 0,
4916
4916
  config: t.config
4917
4917
  },
4918
- p ? { onEvent: p } : void 0
4919
- ), s == null || s({ file: f });
4918
+ f ? { onEvent: f } : void 0
4919
+ ), s == null || s({ file: g });
4920
4920
  },
4921
4921
  [n, r, t, s, e]
4922
- ), G = U(
4923
- (f, P, M) => {
4924
- i && (S.current = w, v(f), A(P), N({
4925
- checkpointId: (M == null ? void 0 : M.checkpointId) ?? null,
4926
- checkpointNs: (M == null ? void 0 : M.checkpointNs) ?? null
4922
+ ), F = R(
4923
+ (g, A, S) => {
4924
+ i && (M.current = b, v(g), C(A), N({
4925
+ checkpointId: (S == null ? void 0 : S.checkpointId) ?? null,
4926
+ checkpointNs: (S == null ? void 0 : S.checkpointNs) ?? null
4927
4927
  }), y(null));
4928
4928
  },
4929
- [w, i]
4930
- ), E = U(() => {
4931
- v(null), A(""), N(null), y(null);
4932
- const f = S.current;
4933
- f !== null && z(f), S.current = null;
4934
- }, []), D = U((f) => {
4935
- let P = null;
4936
- for (let V = f - 1; V >= 0; V--)
4937
- if (u[V].role === "user") {
4938
- P = u[V];
4929
+ [b, i]
4930
+ ), P = R(() => {
4931
+ v(null), C(""), N(null), y(null);
4932
+ const g = M.current;
4933
+ g !== null && z(g), M.current = null;
4934
+ }, []), V = R((g) => {
4935
+ let A = null;
4936
+ for (let D = g - 1; D >= 0; D--)
4937
+ if (u[D].role === "user") {
4938
+ A = u[D];
4939
4939
  break;
4940
4940
  }
4941
- if (!P) return;
4942
- const M = Array.isArray(P.content) ? P.content : [], q = M.filter((V) => (V == null ? void 0 : V.type) === "text").map((V) => V.text).join("") || (() => {
4941
+ if (!A) return;
4942
+ const S = Array.isArray(A.content) ? A.content : [], J = S.filter((D) => (D == null ? void 0 : D.type) === "text").map((D) => D.text).join("") || (() => {
4943
4943
  try {
4944
- return JSON.stringify(M, null, 2);
4944
+ return JSON.stringify(S, null, 2);
4945
4945
  } catch {
4946
- return String(M);
4946
+ return String(S);
4947
4947
  }
4948
4948
  })();
4949
- q && e(
4949
+ J && e(
4950
4950
  {
4951
- text: q,
4951
+ text: J,
4952
4952
  payload: t.payload,
4953
4953
  checkpointId: n ?? void 0,
4954
4954
  checkpointNs: r ?? void 0,
4955
4955
  edit: !0,
4956
- originalMessageId: P.id,
4956
+ originalMessageId: A.id,
4957
4957
  config: t.config
4958
4958
  },
4959
- p ? { onEvent: p } : void 0
4959
+ f ? { onEvent: f } : void 0
4960
4960
  );
4961
4961
  }, [u, e, n, r, t]);
4962
4962
  return {
4963
4963
  editingMessageId: d,
4964
4964
  editingInitialValue: I,
4965
- inputError: b,
4965
+ inputError: w,
4966
4966
  setInputError: y,
4967
4967
  dismissError: x,
4968
- setDismissError: g,
4969
- composerValue: w,
4970
- handleComposerChange: L,
4971
- handleSendMessage: _,
4972
- handleQuickPrompt: O,
4973
- handleExcelUpload: F,
4974
- startEditing: G,
4975
- cancelEditing: E,
4976
- handleRegenerateCb: D,
4968
+ setDismissError: p,
4969
+ composerValue: b,
4970
+ handleComposerChange: E,
4971
+ handleSendMessage: L,
4972
+ handleQuickPrompt: _,
4973
+ handleExcelUpload: G,
4974
+ startEditing: F,
4975
+ cancelEditing: P,
4976
+ handleRegenerateCb: V,
4977
4977
  displayMessages: k
4978
4978
  };
4979
4979
  }
4980
4980
  function po(e) {
4981
- return X(() => e ? {
4981
+ return Q(() => e ? {
4982
4982
  textContent: Rn(e),
4983
4983
  imageParts: Un(e),
4984
4984
  fileParts: jn(e),
@@ -4994,7 +4994,7 @@ function po(e) {
4994
4994
  }
4995
4995
  function go(e, t, n) {
4996
4996
  const [r, o] = $(e), s = K(e), a = K(null);
4997
- return W(() => {
4997
+ return q(() => {
4998
4998
  s.current = e;
4999
4999
  const i = () => {
5000
5000
  o(s.current), a.current && (clearTimeout(a.current), a.current = null);