@teodorruskvi/chat-core 0.1.55 → 0.1.57

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
@@ -1,9 +1,9 @@
1
1
  var Ht = Object.defineProperty;
2
2
  var Gt = (e, t, n) => t in e ? Ht(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var at = (e, t, n) => Gt(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { jsx as ce } from "react/jsx-runtime";
4
+ import { jsx as de } from "react/jsx-runtime";
5
5
  import * as it from "react";
6
- import { createContext as Ee, useContext as Ue, useState as $, useRef as G, useEffect as X, useCallback as _, useMemo as Y, useReducer as Wt } from "react";
6
+ import { createContext as Ce, useContext as je, useState as D, useRef as H, useEffect as Y, useCallback as N, useMemo as Z, useReducer as Wt } from "react";
7
7
  import Jt, { isCancel as Xt } from "axios";
8
8
  function It(e) {
9
9
  var t, n, r = "";
@@ -191,10 +191,10 @@ const et = "-", Yt = (e) => {
191
191
  }
192
192
  I = !1;
193
193
  }
194
- const v = sn(l).join(":"), x = f ? v + xt : v, M = x + u;
195
- if (s.includes(M))
194
+ const v = sn(l).join(":"), x = f ? v + xt : v, S = x + u;
195
+ if (s.includes(S))
196
196
  continue;
197
- s.push(M);
197
+ s.push(S);
198
198
  const A = o(u, I);
199
199
  for (let w = 0; w < A.length; ++w) {
200
200
  const b = A[w];
@@ -235,10 +235,10 @@ function un(e, ...t) {
235
235
  return s(dn.apply(null, arguments));
236
236
  };
237
237
  }
238
- const D = (e) => {
238
+ const q = (e) => {
239
239
  const t = (n) => n[e] || [];
240
240
  return t.isThemeGetter = !0, t;
241
- }, Tt = /^\[(?:([a-z-]+):)?(.+)\]$/i, fn = /^\d+\/\d+$/, pn = /* @__PURE__ */ new Set(["px", "full", "screen"]), gn = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, mn = /\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$/, yn = /^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/, hn = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/, bn = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/, ge = (e) => Se(e) || pn.has(e) || fn.test(e), be = (e) => Pe(e, "length", Sn), Se = (e) => !!e && !Number.isNaN(Number(e)), qe = (e) => Pe(e, "number", Se), Ne = (e) => !!e && Number.isInteger(Number(e)), wn = (e) => e.endsWith("%") && Se(e.slice(0, -1)), N = (e) => Tt.test(e), we = (e) => gn.test(e), kn = /* @__PURE__ */ new Set(["length", "size", "percentage"]), In = (e) => Pe(e, kn, St), vn = (e) => Pe(e, "position", St), xn = /* @__PURE__ */ new Set(["image", "url"]), An = (e) => Pe(e, xn, Cn), Tn = (e) => Pe(e, "", Mn), ze = () => !0, Pe = (e, t, n) => {
241
+ }, Tt = /^\[(?:([a-z-]+):)?(.+)\]$/i, fn = /^\d+\/\d+$/, pn = /* @__PURE__ */ new Set(["px", "full", "screen"]), gn = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, mn = /\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$/, yn = /^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/, hn = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/, bn = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/, pe = (e) => Te(e) || pn.has(e) || fn.test(e), Ie = (e) => Ee(e, "length", Sn), Te = (e) => !!e && !Number.isNaN(Number(e)), qe = (e) => Ee(e, "number", Te), _e = (e) => !!e && Number.isInteger(Number(e)), wn = (e) => e.endsWith("%") && Te(e.slice(0, -1)), z = (e) => Tt.test(e), ve = (e) => gn.test(e), kn = /* @__PURE__ */ new Set(["length", "size", "percentage"]), In = (e) => Ee(e, kn, St), vn = (e) => Ee(e, "position", St), xn = /* @__PURE__ */ new Set(["image", "url"]), An = (e) => Ee(e, xn, Cn), Tn = (e) => Ee(e, "", Mn), Ne = () => !0, Ee = (e, t, n) => {
242
242
  const r = Tt.exec(e);
243
243
  return r ? r[1] ? typeof t == "string" ? r[1] === t : t.has(r[1]) : n(r[2]) : !1;
244
244
  }, Sn = (e) => (
@@ -247,36 +247,36 @@ const D = (e) => {
247
247
  // I could also use lookbehind assertion in `lengthUnitRegex` but that isn't supported widely enough.
248
248
  mn.test(e) && !yn.test(e)
249
249
  ), St = () => !1, Mn = (e) => hn.test(e), Cn = (e) => bn.test(e), En = () => {
250
- const e = D("colors"), t = D("spacing"), n = D("blur"), r = D("brightness"), o = D("borderColor"), s = D("borderRadius"), a = D("borderSpacing"), i = D("borderWidth"), d = D("contrast"), c = D("grayscale"), l = D("hueRotate"), f = D("invert"), p = D("gap"), g = D("gradientColorStops"), I = D("gradientColorStopPositions"), u = D("inset"), v = D("margin"), x = D("opacity"), M = D("padding"), A = D("saturate"), w = D("scale"), b = D("sepia"), h = D("skew"), T = D("space"), m = D("translate"), k = () => ["auto", "contain", "none"], E = () => ["auto", "hidden", "clip", "visible", "scroll"], j = () => ["auto", N, t], C = () => [N, t], O = () => ["", ge, be], F = () => ["auto", Se, N], P = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], B = () => ["solid", "dashed", "dotted", "double", "none"], z = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], J = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], U = () => ["", "0", N], R = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], q = () => [Se, N];
250
+ const e = q("colors"), t = q("spacing"), n = q("blur"), r = q("brightness"), o = q("borderColor"), s = q("borderRadius"), a = q("borderSpacing"), i = q("borderWidth"), d = q("contrast"), c = q("grayscale"), l = q("hueRotate"), f = q("invert"), p = q("gap"), g = q("gradientColorStops"), I = q("gradientColorStopPositions"), u = q("inset"), v = q("margin"), x = q("opacity"), S = q("padding"), A = q("saturate"), w = q("scale"), b = q("sepia"), y = q("skew"), T = q("space"), m = q("translate"), k = () => ["auto", "contain", "none"], E = () => ["auto", "hidden", "clip", "visible", "scroll"], U = () => ["auto", z, t], M = () => [z, t], $ = () => ["", pe, Ie], F = () => ["auto", Te, z], _ = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], O = () => ["solid", "dashed", "dotted", "double", "none"], R = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], W = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], B = () => ["", "0", z], L = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], h = () => [Te, z];
251
251
  return {
252
252
  cacheSize: 500,
253
253
  separator: ":",
254
254
  theme: {
255
- colors: [ze],
256
- spacing: [ge, be],
257
- blur: ["none", "", we, N],
258
- brightness: q(),
255
+ colors: [Ne],
256
+ spacing: [pe, Ie],
257
+ blur: ["none", "", ve, z],
258
+ brightness: h(),
259
259
  borderColor: [e],
260
- borderRadius: ["none", "", "full", we, N],
261
- borderSpacing: C(),
262
- borderWidth: O(),
263
- contrast: q(),
264
- grayscale: U(),
265
- hueRotate: q(),
266
- invert: U(),
267
- gap: C(),
260
+ borderRadius: ["none", "", "full", ve, z],
261
+ borderSpacing: M(),
262
+ borderWidth: $(),
263
+ contrast: h(),
264
+ grayscale: B(),
265
+ hueRotate: h(),
266
+ invert: B(),
267
+ gap: M(),
268
268
  gradientColorStops: [e],
269
- gradientColorStopPositions: [wn, be],
270
- inset: j(),
271
- margin: j(),
272
- opacity: q(),
273
- padding: C(),
274
- saturate: q(),
275
- scale: q(),
276
- sepia: U(),
277
- skew: q(),
278
- space: C(),
279
- translate: C()
269
+ gradientColorStopPositions: [wn, Ie],
270
+ inset: U(),
271
+ margin: U(),
272
+ opacity: h(),
273
+ padding: M(),
274
+ saturate: h(),
275
+ scale: h(),
276
+ sepia: B(),
277
+ skew: h(),
278
+ space: M(),
279
+ translate: M()
280
280
  },
281
281
  classGroups: {
282
282
  // Layout
@@ -285,7 +285,7 @@ const D = (e) => {
285
285
  * @see https://tailwindcss.com/docs/aspect-ratio
286
286
  */
287
287
  aspect: [{
288
- aspect: ["auto", "square", "video", N]
288
+ aspect: ["auto", "square", "video", z]
289
289
  }],
290
290
  /**
291
291
  * Container
@@ -297,21 +297,21 @@ const D = (e) => {
297
297
  * @see https://tailwindcss.com/docs/columns
298
298
  */
299
299
  columns: [{
300
- columns: [we]
300
+ columns: [ve]
301
301
  }],
302
302
  /**
303
303
  * Break After
304
304
  * @see https://tailwindcss.com/docs/break-after
305
305
  */
306
306
  "break-after": [{
307
- "break-after": R()
307
+ "break-after": L()
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": R()
314
+ "break-before": L()
315
315
  }],
316
316
  /**
317
317
  * Break Inside
@@ -370,7 +370,7 @@ const D = (e) => {
370
370
  * @see https://tailwindcss.com/docs/object-position
371
371
  */
372
372
  "object-position": [{
373
- object: [...P(), N]
373
+ object: [..._(), z]
374
374
  }],
375
375
  /**
376
376
  * Overflow
@@ -492,7 +492,7 @@ const D = (e) => {
492
492
  * @see https://tailwindcss.com/docs/z-index
493
493
  */
494
494
  z: [{
495
- z: ["auto", Ne, N]
495
+ z: ["auto", _e, z]
496
496
  }],
497
497
  // Flexbox and Grid
498
498
  /**
@@ -500,7 +500,7 @@ const D = (e) => {
500
500
  * @see https://tailwindcss.com/docs/flex-basis
501
501
  */
502
502
  basis: [{
503
- basis: j()
503
+ basis: U()
504
504
  }],
505
505
  /**
506
506
  * Flex Direction
@@ -521,35 +521,35 @@ const D = (e) => {
521
521
  * @see https://tailwindcss.com/docs/flex
522
522
  */
523
523
  flex: [{
524
- flex: ["1", "auto", "initial", "none", N]
524
+ flex: ["1", "auto", "initial", "none", z]
525
525
  }],
526
526
  /**
527
527
  * Flex Grow
528
528
  * @see https://tailwindcss.com/docs/flex-grow
529
529
  */
530
530
  grow: [{
531
- grow: U()
531
+ grow: B()
532
532
  }],
533
533
  /**
534
534
  * Flex Shrink
535
535
  * @see https://tailwindcss.com/docs/flex-shrink
536
536
  */
537
537
  shrink: [{
538
- shrink: U()
538
+ shrink: B()
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", Ne, N]
545
+ order: ["first", "last", "none", _e, z]
546
546
  }],
547
547
  /**
548
548
  * Grid Template Columns
549
549
  * @see https://tailwindcss.com/docs/grid-template-columns
550
550
  */
551
551
  "grid-cols": [{
552
- "grid-cols": [ze]
552
+ "grid-cols": [Ne]
553
553
  }],
554
554
  /**
555
555
  * Grid Column Start / End
@@ -557,8 +557,8 @@ const D = (e) => {
557
557
  */
558
558
  "col-start-end": [{
559
559
  col: ["auto", {
560
- span: ["full", Ne, N]
561
- }, N]
560
+ span: ["full", _e, z]
561
+ }, z]
562
562
  }],
563
563
  /**
564
564
  * Grid Column Start
@@ -579,7 +579,7 @@ const D = (e) => {
579
579
  * @see https://tailwindcss.com/docs/grid-template-rows
580
580
  */
581
581
  "grid-rows": [{
582
- "grid-rows": [ze]
582
+ "grid-rows": [Ne]
583
583
  }],
584
584
  /**
585
585
  * Grid Row Start / End
@@ -587,8 +587,8 @@ const D = (e) => {
587
587
  */
588
588
  "row-start-end": [{
589
589
  row: ["auto", {
590
- span: [Ne, N]
591
- }, N]
590
+ span: [_e, z]
591
+ }, z]
592
592
  }],
593
593
  /**
594
594
  * Grid Row Start
@@ -616,14 +616,14 @@ const D = (e) => {
616
616
  * @see https://tailwindcss.com/docs/grid-auto-columns
617
617
  */
618
618
  "auto-cols": [{
619
- "auto-cols": ["auto", "min", "max", "fr", N]
619
+ "auto-cols": ["auto", "min", "max", "fr", z]
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", N]
626
+ "auto-rows": ["auto", "min", "max", "fr", z]
627
627
  }],
628
628
  /**
629
629
  * Gap
@@ -651,7 +651,7 @@ const D = (e) => {
651
651
  * @see https://tailwindcss.com/docs/justify-content
652
652
  */
653
653
  "justify-content": [{
654
- justify: ["normal", ...J()]
654
+ justify: ["normal", ...W()]
655
655
  }],
656
656
  /**
657
657
  * Justify Items
@@ -672,7 +672,7 @@ const D = (e) => {
672
672
  * @see https://tailwindcss.com/docs/align-content
673
673
  */
674
674
  "align-content": [{
675
- content: ["normal", ...J(), "baseline"]
675
+ content: ["normal", ...W(), "baseline"]
676
676
  }],
677
677
  /**
678
678
  * Align Items
@@ -693,7 +693,7 @@ const D = (e) => {
693
693
  * @see https://tailwindcss.com/docs/place-content
694
694
  */
695
695
  "place-content": [{
696
- "place-content": [...J(), "baseline"]
696
+ "place-content": [...W(), "baseline"]
697
697
  }],
698
698
  /**
699
699
  * Place Items
@@ -715,63 +715,63 @@ const D = (e) => {
715
715
  * @see https://tailwindcss.com/docs/padding
716
716
  */
717
717
  p: [{
718
- p: [M]
718
+ p: [S]
719
719
  }],
720
720
  /**
721
721
  * Padding X
722
722
  * @see https://tailwindcss.com/docs/padding
723
723
  */
724
724
  px: [{
725
- px: [M]
725
+ px: [S]
726
726
  }],
727
727
  /**
728
728
  * Padding Y
729
729
  * @see https://tailwindcss.com/docs/padding
730
730
  */
731
731
  py: [{
732
- py: [M]
732
+ py: [S]
733
733
  }],
734
734
  /**
735
735
  * Padding Start
736
736
  * @see https://tailwindcss.com/docs/padding
737
737
  */
738
738
  ps: [{
739
- ps: [M]
739
+ ps: [S]
740
740
  }],
741
741
  /**
742
742
  * Padding End
743
743
  * @see https://tailwindcss.com/docs/padding
744
744
  */
745
745
  pe: [{
746
- pe: [M]
746
+ pe: [S]
747
747
  }],
748
748
  /**
749
749
  * Padding Top
750
750
  * @see https://tailwindcss.com/docs/padding
751
751
  */
752
752
  pt: [{
753
- pt: [M]
753
+ pt: [S]
754
754
  }],
755
755
  /**
756
756
  * Padding Right
757
757
  * @see https://tailwindcss.com/docs/padding
758
758
  */
759
759
  pr: [{
760
- pr: [M]
760
+ pr: [S]
761
761
  }],
762
762
  /**
763
763
  * Padding Bottom
764
764
  * @see https://tailwindcss.com/docs/padding
765
765
  */
766
766
  pb: [{
767
- pb: [M]
767
+ pb: [S]
768
768
  }],
769
769
  /**
770
770
  * Padding Left
771
771
  * @see https://tailwindcss.com/docs/padding
772
772
  */
773
773
  pl: [{
774
- pl: [M]
774
+ pl: [S]
775
775
  }],
776
776
  /**
777
777
  * Margin
@@ -866,51 +866,51 @@ const D = (e) => {
866
866
  * @see https://tailwindcss.com/docs/width
867
867
  */
868
868
  w: [{
869
- w: ["auto", "min", "max", "fit", "svw", "lvw", "dvw", N, t]
869
+ w: ["auto", "min", "max", "fit", "svw", "lvw", "dvw", z, 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": [N, t, "min", "max", "fit"]
876
+ "min-w": [z, 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": [N, t, "none", "full", "min", "max", "fit", "prose", {
884
- screen: [we]
885
- }, we]
883
+ "max-w": [z, t, "none", "full", "min", "max", "fit", "prose", {
884
+ screen: [ve]
885
+ }, ve]
886
886
  }],
887
887
  /**
888
888
  * Height
889
889
  * @see https://tailwindcss.com/docs/height
890
890
  */
891
891
  h: [{
892
- h: [N, t, "auto", "min", "max", "fit", "svh", "lvh", "dvh"]
892
+ h: [z, 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": [N, t, "min", "max", "fit", "svh", "lvh", "dvh"]
899
+ "min-h": [z, 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": [N, t, "min", "max", "fit", "svh", "lvh", "dvh"]
906
+ "max-h": [z, 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: [N, t, "auto", "min", "max", "fit"]
913
+ size: [z, t, "auto", "min", "max", "fit"]
914
914
  }],
915
915
  // Typography
916
916
  /**
@@ -918,7 +918,7 @@ const D = (e) => {
918
918
  * @see https://tailwindcss.com/docs/font-size
919
919
  */
920
920
  "font-size": [{
921
- text: ["base", we, be]
921
+ text: ["base", ve, Ie]
922
922
  }],
923
923
  /**
924
924
  * Font Smoothing
@@ -942,7 +942,7 @@ const D = (e) => {
942
942
  * @see https://tailwindcss.com/docs/font-family
943
943
  */
944
944
  "font-family": [{
945
- font: [ze]
945
+ font: [Ne]
946
946
  }],
947
947
  /**
948
948
  * Font Variant Numeric
@@ -979,35 +979,35 @@ const D = (e) => {
979
979
  * @see https://tailwindcss.com/docs/letter-spacing
980
980
  */
981
981
  tracking: [{
982
- tracking: ["tighter", "tight", "normal", "wide", "wider", "widest", N]
982
+ tracking: ["tighter", "tight", "normal", "wide", "wider", "widest", z]
983
983
  }],
984
984
  /**
985
985
  * Line Clamp
986
986
  * @see https://tailwindcss.com/docs/line-clamp
987
987
  */
988
988
  "line-clamp": [{
989
- "line-clamp": ["none", Se, qe]
989
+ "line-clamp": ["none", Te, qe]
990
990
  }],
991
991
  /**
992
992
  * Line Height
993
993
  * @see https://tailwindcss.com/docs/line-height
994
994
  */
995
995
  leading: [{
996
- leading: ["none", "tight", "snug", "normal", "relaxed", "loose", ge, N]
996
+ leading: ["none", "tight", "snug", "normal", "relaxed", "loose", pe, z]
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", N]
1003
+ "list-image": ["none", z]
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", N]
1010
+ list: ["none", "disc", "decimal", z]
1011
1011
  }],
1012
1012
  /**
1013
1013
  * List Style Position
@@ -1062,21 +1062,21 @@ const D = (e) => {
1062
1062
  * @see https://tailwindcss.com/docs/text-decoration-style
1063
1063
  */
1064
1064
  "text-decoration-style": [{
1065
- decoration: [...B(), "wavy"]
1065
+ decoration: [...O(), "wavy"]
1066
1066
  }],
1067
1067
  /**
1068
1068
  * Text Decoration Thickness
1069
1069
  * @see https://tailwindcss.com/docs/text-decoration-thickness
1070
1070
  */
1071
1071
  "text-decoration-thickness": [{
1072
- decoration: ["auto", "from-font", ge, be]
1072
+ decoration: ["auto", "from-font", pe, Ie]
1073
1073
  }],
1074
1074
  /**
1075
1075
  * Text Underline Offset
1076
1076
  * @see https://tailwindcss.com/docs/text-underline-offset
1077
1077
  */
1078
1078
  "underline-offset": [{
1079
- "underline-offset": ["auto", ge, N]
1079
+ "underline-offset": ["auto", pe, z]
1080
1080
  }],
1081
1081
  /**
1082
1082
  * Text Decoration Color
@@ -1107,14 +1107,14 @@ const D = (e) => {
1107
1107
  * @see https://tailwindcss.com/docs/text-indent
1108
1108
  */
1109
1109
  indent: [{
1110
- indent: C()
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", N]
1117
+ align: ["baseline", "top", "middle", "bottom", "text-top", "text-bottom", "sub", "super", z]
1118
1118
  }],
1119
1119
  /**
1120
1120
  * Whitespace
@@ -1142,7 +1142,7 @@ const D = (e) => {
1142
1142
  * @see https://tailwindcss.com/docs/content
1143
1143
  */
1144
1144
  content: [{
1145
- content: ["none", N]
1145
+ content: ["none", z]
1146
1146
  }],
1147
1147
  // Backgrounds
1148
1148
  /**
@@ -1179,7 +1179,7 @@ const D = (e) => {
1179
1179
  * @see https://tailwindcss.com/docs/background-position
1180
1180
  */
1181
1181
  "bg-position": [{
1182
- bg: [...P(), vn]
1182
+ bg: [..._(), vn]
1183
1183
  }],
1184
1184
  /**
1185
1185
  * Background Repeat
@@ -1436,7 +1436,7 @@ const D = (e) => {
1436
1436
  * @see https://tailwindcss.com/docs/border-style
1437
1437
  */
1438
1438
  "border-style": [{
1439
- border: [...B(), "hidden"]
1439
+ border: [...O(), "hidden"]
1440
1440
  }],
1441
1441
  /**
1442
1442
  * Divide Width X
@@ -1474,7 +1474,7 @@ const D = (e) => {
1474
1474
  * @see https://tailwindcss.com/docs/divide-style
1475
1475
  */
1476
1476
  "divide-style": [{
1477
- divide: B()
1477
+ divide: O()
1478
1478
  }],
1479
1479
  /**
1480
1480
  * Border Color
@@ -1551,21 +1551,21 @@ const D = (e) => {
1551
1551
  * @see https://tailwindcss.com/docs/outline-style
1552
1552
  */
1553
1553
  "outline-style": [{
1554
- outline: ["", ...B()]
1554
+ outline: ["", ...O()]
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": [ge, N]
1561
+ "outline-offset": [pe, z]
1562
1562
  }],
1563
1563
  /**
1564
1564
  * Outline Width
1565
1565
  * @see https://tailwindcss.com/docs/outline-width
1566
1566
  */
1567
1567
  "outline-w": [{
1568
- outline: [ge, be]
1568
+ outline: [pe, Ie]
1569
1569
  }],
1570
1570
  /**
1571
1571
  * Outline Color
@@ -1579,7 +1579,7 @@ const D = (e) => {
1579
1579
  * @see https://tailwindcss.com/docs/ring-width
1580
1580
  */
1581
1581
  "ring-w": [{
1582
- ring: O()
1582
+ ring: $()
1583
1583
  }],
1584
1584
  /**
1585
1585
  * Ring Width Inset
@@ -1605,7 +1605,7 @@ const D = (e) => {
1605
1605
  * @see https://tailwindcss.com/docs/ring-offset-width
1606
1606
  */
1607
1607
  "ring-offset-w": [{
1608
- "ring-offset": [ge, be]
1608
+ "ring-offset": [pe, Ie]
1609
1609
  }],
1610
1610
  /**
1611
1611
  * Ring Offset Color
@@ -1620,14 +1620,14 @@ const D = (e) => {
1620
1620
  * @see https://tailwindcss.com/docs/box-shadow
1621
1621
  */
1622
1622
  shadow: [{
1623
- shadow: ["", "inner", "none", we, Tn]
1623
+ shadow: ["", "inner", "none", ve, Tn]
1624
1624
  }],
1625
1625
  /**
1626
1626
  * Box Shadow Color
1627
1627
  * @see https://tailwindcss.com/docs/box-shadow-color
1628
1628
  */
1629
1629
  "shadow-color": [{
1630
- shadow: [ze]
1630
+ shadow: [Ne]
1631
1631
  }],
1632
1632
  /**
1633
1633
  * Opacity
@@ -1641,14 +1641,14 @@ const D = (e) => {
1641
1641
  * @see https://tailwindcss.com/docs/mix-blend-mode
1642
1642
  */
1643
1643
  "mix-blend": [{
1644
- "mix-blend": [...z(), "plus-lighter", "plus-darker"]
1644
+ "mix-blend": [...R(), "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": z()
1651
+ "bg-blend": R()
1652
1652
  }],
1653
1653
  // Filters
1654
1654
  /**
@@ -1685,7 +1685,7 @@ const D = (e) => {
1685
1685
  * @see https://tailwindcss.com/docs/drop-shadow
1686
1686
  */
1687
1687
  "drop-shadow": [{
1688
- "drop-shadow": ["", "none", we, N]
1688
+ "drop-shadow": ["", "none", ve, z]
1689
1689
  }],
1690
1690
  /**
1691
1691
  * Grayscale
@@ -1842,35 +1842,35 @@ const D = (e) => {
1842
1842
  * @see https://tailwindcss.com/docs/transition-property
1843
1843
  */
1844
1844
  transition: [{
1845
- transition: ["none", "all", "", "colors", "opacity", "shadow", "transform", N]
1845
+ transition: ["none", "all", "", "colors", "opacity", "shadow", "transform", z]
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: h()
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", N]
1859
+ ease: ["linear", "in", "out", "in-out", z]
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: h()
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", N]
1873
+ animate: ["none", "spin", "ping", "pulse", "bounce", z]
1874
1874
  }],
1875
1875
  // Transforms
1876
1876
  /**
@@ -1906,7 +1906,7 @@ const D = (e) => {
1906
1906
  * @see https://tailwindcss.com/docs/rotate
1907
1907
  */
1908
1908
  rotate: [{
1909
- rotate: [Ne, N]
1909
+ rotate: [_e, z]
1910
1910
  }],
1911
1911
  /**
1912
1912
  * Translate X
@@ -1927,21 +1927,21 @@ const D = (e) => {
1927
1927
  * @see https://tailwindcss.com/docs/skew
1928
1928
  */
1929
1929
  "skew-x": [{
1930
- "skew-x": [h]
1930
+ "skew-x": [y]
1931
1931
  }],
1932
1932
  /**
1933
1933
  * Skew Y
1934
1934
  * @see https://tailwindcss.com/docs/skew
1935
1935
  */
1936
1936
  "skew-y": [{
1937
- "skew-y": [h]
1937
+ "skew-y": [y]
1938
1938
  }],
1939
1939
  /**
1940
1940
  * Transform Origin
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", N]
1944
+ origin: ["center", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left", "top-left", z]
1945
1945
  }],
1946
1946
  // Interactivity
1947
1947
  /**
@@ -1963,7 +1963,7 @@ const D = (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", N]
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", z]
1967
1967
  }],
1968
1968
  /**
1969
1969
  * Caret Color
@@ -1998,126 +1998,126 @@ const D = (e) => {
1998
1998
  * @see https://tailwindcss.com/docs/scroll-margin
1999
1999
  */
2000
2000
  "scroll-m": [{
2001
- "scroll-m": C()
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": C()
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": C()
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": C()
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": C()
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": C()
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": C()
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": C()
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": C()
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": C()
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": C()
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": C()
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": C()
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": C()
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": C()
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": C()
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": C()
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": C()
2120
+ "scroll-pl": M()
2121
2121
  }],
2122
2122
  /**
2123
2123
  * Scroll Snap Align
@@ -2185,7 +2185,7 @@ const D = (e) => {
2185
2185
  * @see https://tailwindcss.com/docs/will-change
2186
2186
  */
2187
2187
  "will-change": [{
2188
- "will-change": ["auto", "scroll", "contents", "transform", N]
2188
+ "will-change": ["auto", "scroll", "contents", "transform", z]
2189
2189
  }],
2190
2190
  // SVG
2191
2191
  /**
@@ -2200,7 +2200,7 @@ const D = (e) => {
2200
2200
  * @see https://tailwindcss.com/docs/stroke-width
2201
2201
  */
2202
2202
  "stroke-w": [{
2203
- stroke: [ge, be, qe]
2203
+ stroke: [pe, Ie, qe]
2204
2204
  }],
2205
2205
  /**
2206
2206
  * Stroke
@@ -2343,12 +2343,12 @@ function Bn(e) {
2343
2343
  function Ct(e) {
2344
2344
  return !!(e && typeof e == "object" && (e.type === "file" || e.mimeType || e.filename || e.sourceType === "base64"));
2345
2345
  }
2346
- function Ke(e) {
2346
+ function De(e) {
2347
2347
  if (typeof e == "string")
2348
2348
  return e;
2349
2349
  if (e && typeof e == "object") {
2350
2350
  if (Array.isArray(e)) {
2351
- const n = e.map(Ke).filter((r) => r !== void 0);
2351
+ const n = e.map(De).filter((r) => r !== void 0);
2352
2352
  if (!n.length) {
2353
2353
  console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined", { originalLength: e.length });
2354
2354
  return;
@@ -2372,7 +2372,7 @@ function Ke(e) {
2372
2372
  if (n === "data" && typeof r == "string" && r.length > 100)
2373
2373
  t[n] = `[base64 ${r.length} chars omitted]`;
2374
2374
  else {
2375
- const o = Ke(r);
2375
+ const o = De(r);
2376
2376
  o !== void 0 && (t[n] = o);
2377
2377
  }
2378
2378
  }
@@ -2391,7 +2391,7 @@ function Et(e) {
2391
2391
  if (typeof e == "string") return e;
2392
2392
  if (Ct(e)) return "";
2393
2393
  try {
2394
- const t = Ke(e);
2394
+ const t = De(e);
2395
2395
  return t === void 0 ? "" : typeof t == "string" ? t : JSON.stringify(t, null, 2);
2396
2396
  } catch {
2397
2397
  return "";
@@ -2404,7 +2404,7 @@ function oo(e) {
2404
2404
  function Fn(e) {
2405
2405
  const t = (r) => {
2406
2406
  try {
2407
- const o = Ke(r);
2407
+ const o = De(r);
2408
2408
  return typeof o == "string" ? o : JSON.stringify(o ?? "");
2409
2409
  } catch {
2410
2410
  return "";
@@ -2416,44 +2416,44 @@ function Fn(e) {
2416
2416
  function so(e) {
2417
2417
  return e.content.some((t) => t.type === "text" ? t.text.trim().length > 0 : t.type === "image_url" || t.type === "file");
2418
2418
  }
2419
- function de(e) {
2419
+ function ue(e) {
2420
2420
  if (e == null) return e;
2421
2421
  if (typeof e == "string") {
2422
2422
  const t = e.trim();
2423
2423
  if (t.startsWith("{") || t.startsWith("[")) {
2424
2424
  const n = tt(t);
2425
2425
  if (n !== null)
2426
- return de(n);
2426
+ return ue(n);
2427
2427
  }
2428
2428
  return e;
2429
2429
  }
2430
2430
  if (typeof e == "object" && !Array.isArray(e)) {
2431
2431
  if (e.content !== void 0)
2432
- return Array.isArray(e.content) ? e.content.map((t) => de(t)).filter(Boolean).join(`
2433
- `) : de(e.content);
2432
+ return Array.isArray(e.content) ? e.content.map((t) => ue(t)).filter(Boolean).join(`
2433
+ `) : ue(e.content);
2434
2434
  if (e.value !== void 0)
2435
- return de(e.value);
2435
+ return ue(e.value);
2436
2436
  }
2437
- return typeof e == "object" && !Array.isArray(e) && (e.type === "text" && typeof e.text == "string" || typeof e.text == "string") ? e.text : Array.isArray(e) && e.length > 0 ? de(e[0]) : e;
2437
+ return typeof e == "object" && !Array.isArray(e) && (e.type === "text" && typeof e.text == "string" || typeof e.text == "string") ? e.text : Array.isArray(e) && e.length > 0 ? ue(e[0]) : e;
2438
2438
  }
2439
2439
  function On(e) {
2440
2440
  return e.replace(/[_-](\w)/g, (t, n) => n ? n.toUpperCase() : "").replace(/^\w/, (t) => t.toLowerCase());
2441
2441
  }
2442
- function ue(e) {
2443
- return !e || typeof e != "object" ? e : Array.isArray(e) ? e.map(ue) : Object.fromEntries(
2442
+ function fe(e) {
2443
+ return !e || typeof e != "object" ? e : Array.isArray(e) ? e.map(fe) : Object.fromEntries(
2444
2444
  Object.entries(e).map(([t, n]) => [
2445
2445
  On(t),
2446
- ue(n)
2446
+ fe(n)
2447
2447
  ])
2448
2448
  );
2449
2449
  }
2450
2450
  function nt(e) {
2451
- var x, M, A, w, b, h, T;
2451
+ var x, S, A, w, b, y, T;
2452
2452
  if (!e || typeof e != "object") return null;
2453
- const t = ue(e), n = Kn(t);
2453
+ const t = fe(e), n = Kn(t);
2454
2454
  if (!n)
2455
2455
  return null;
2456
- const r = t.toolCalls ?? ((x = t.additionalKwargs) == null ? void 0 : x.toolCalls), o = Array.isArray(r) ? r.map(rt) : void 0, s = Dn(t.content ?? t.parts, !!(o != null && o.length)), a = t.id ?? `msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`, i = t.createdAt ?? ((M = t.additionalKwargs) == null ? void 0 : M.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(), d = t.name ?? ((A = t.additionalKwargs) == null ? void 0 : A.agentName) ?? void 0, c = t.model ?? ((w = t.additionalKwargs) == null ? void 0 : w.model) ?? void 0, l = t.toolCallId ?? void 0, f = t.additionalKwargs ?? void 0, p = t.responseMetadata ?? void 0, g = t.checkpointId ?? ((b = t.additionalKwargs) == null ? void 0 : b.checkpointId) ?? void 0, I = t.checkpointNs ?? ((h = t.additionalKwargs) == null ? void 0 : h.checkpointNs) ?? void 0, u = typeof t.toolStreaming == "boolean" ? t.toolStreaming : !!((T = t.additionalKwargs) != null && T.toolStreaming);
2456
+ const r = t.toolCalls ?? ((x = t.additionalKwargs) == null ? void 0 : x.toolCalls), o = Array.isArray(r) ? r.map(rt) : void 0, s = Dn(t.content ?? t.parts, !!(o != null && o.length)), a = t.id ?? `msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`, i = t.createdAt ?? ((S = t.additionalKwargs) == null ? void 0 : S.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(), d = t.name ?? ((A = t.additionalKwargs) == null ? void 0 : A.agentName) ?? void 0, c = t.model ?? ((w = t.additionalKwargs) == null ? void 0 : w.model) ?? void 0, l = t.toolCallId ?? void 0, f = t.additionalKwargs ?? void 0, p = t.responseMetadata ?? void 0, g = t.checkpointId ?? ((b = t.additionalKwargs) == null ? void 0 : b.checkpointId) ?? void 0, I = t.checkpointNs ?? ((y = t.additionalKwargs) == null ? void 0 : y.checkpointNs) ?? void 0, u = typeof t.toolStreaming == "boolean" ? t.toolStreaming : !!((T = t.additionalKwargs) != null && T.toolStreaming);
2457
2457
  return {
2458
2458
  ...t,
2459
2459
  id: a,
@@ -2474,7 +2474,7 @@ function nt(e) {
2474
2474
  }
2475
2475
  function $n(e) {
2476
2476
  if (!e || typeof e != "object") return e;
2477
- const t = ue(e);
2477
+ const t = fe(e);
2478
2478
  if (t.tool && !t.name && (t.name = t.tool), t.type === "artifact.update" && t.artifact && typeof t.artifact == "object") {
2479
2479
  const n = t.artifact;
2480
2480
  !n.type && t.name && (n.type = t.name);
@@ -2482,7 +2482,7 @@ function $n(e) {
2482
2482
  return t;
2483
2483
  }
2484
2484
  function rt(e) {
2485
- const t = ue(e), n = t.content ?? t.output ?? void 0;
2485
+ const t = fe(e), n = t.content ?? t.output ?? void 0;
2486
2486
  return {
2487
2487
  ...t,
2488
2488
  type: "tool_call",
@@ -2493,12 +2493,12 @@ function rt(e) {
2493
2493
  };
2494
2494
  }
2495
2495
  function Dn(e, t) {
2496
- return typeof e == "string" ? [{ type: "text", text: e }] : Array.isArray(e) ? e.map((n) => typeof n == "string" ? { type: "text", text: n } : n.type === "tool_call" || n.type === "tool" ? t ? null : rt(ue(n)) : n).filter(
2496
+ return typeof e == "string" ? [{ type: "text", text: e }] : Array.isArray(e) ? e.map((n) => typeof n == "string" ? { type: "text", text: n } : n.type === "tool_call" || n.type === "tool" ? t ? null : rt(fe(n)) : n).filter(
2497
2497
  (n) => !!(n && typeof n == "object" && typeof n.type == "string")
2498
2498
  ) : [];
2499
2499
  }
2500
2500
  function Kn(e) {
2501
- const t = ue(e), n = t.role;
2501
+ const t = fe(e), n = t.role;
2502
2502
  if (n && (n === "assistant" || n === "user" || n === "system" || n === "tool"))
2503
2503
  return n;
2504
2504
  const r = t.type;
@@ -2540,7 +2540,7 @@ function qn(e, t = []) {
2540
2540
  var f, p, g;
2541
2541
  const i = He(a.id, e) || He(a.id, t), d = Array.isArray((f = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : f.toolProgress) ? (p = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : p.toolProgress : void 0, c = (i == null ? void 0 : i.artifact) ?? a.artifact, l = dt(a.status) ?? ((g = i == null ? void 0 : i.additionalKwargs) != null && g.toolStreaming ? "pending" : null) ?? (i ? "completed" : "pending");
2542
2542
  if (i && !a.content && l === "completed") {
2543
- const I = de(i);
2543
+ const I = ue(i);
2544
2544
  typeof I == "string" && (a.content = I);
2545
2545
  }
2546
2546
  return {
@@ -2558,7 +2558,7 @@ function qn(e, t = []) {
2558
2558
  var d, c, l;
2559
2559
  const o = He(r.id, t) ?? Vn(e, r), s = Array.isArray((d = o == null ? void 0 : o.additionalKwargs) == null ? void 0 : d.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 = dt(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 f = de(o);
2561
+ const f = ue(o);
2562
2562
  typeof f == "string" && (r.content = f);
2563
2563
  }
2564
2564
  return {
@@ -2573,7 +2573,7 @@ function qn(e, t = []) {
2573
2573
  function ao(e, t = []) {
2574
2574
  return qn(e, t).map((n) => n.artifact).filter((n) => !!n);
2575
2575
  }
2576
- const Re = {
2576
+ const ze = {
2577
2577
  authToken: "authToken",
2578
2578
  authTokenExpiresAt: "authTokenExpiresAt",
2579
2579
  authSessionId: "authSessionId",
@@ -2585,20 +2585,20 @@ const Re = {
2585
2585
  function Ge(e) {
2586
2586
  return `draft:${e}`;
2587
2587
  }
2588
- let Ve = null;
2588
+ let Ke = null;
2589
2589
  const Qe = /* @__PURE__ */ new Set();
2590
2590
  function Pt() {
2591
- return Ve;
2591
+ return Ke;
2592
2592
  }
2593
- function ve(e) {
2594
- Ve = e, Qe.forEach((t) => t(e));
2593
+ function xe(e) {
2594
+ Ke = e, Qe.forEach((t) => t(e));
2595
2595
  }
2596
2596
  function _t(e) {
2597
2597
  return Qe.add(e), () => Qe.delete(e);
2598
2598
  }
2599
2599
  const Hn = 12e4, Gn = 12e4;
2600
2600
  let Ye = Hn, Nt = Gn;
2601
- const ne = Jt.create({
2601
+ const oe = Jt.create({
2602
2602
  // BaseURL is set dynamically via ApiProvider -> api.updateConfig
2603
2603
  timeout: Ye,
2604
2604
  withCredentials: !0
@@ -2608,18 +2608,18 @@ function ft(e) {
2608
2608
  }
2609
2609
  function Wn(e) {
2610
2610
  const t = ft(e.requestTimeoutMs), n = ft(e.historyTimeoutMs);
2611
- t !== null && (Ye = t, ne.defaults.timeout = Ye), n !== null && (Nt = n);
2611
+ t !== null && (Ye = t, oe.defaults.timeout = Ye), n !== null && (Nt = n);
2612
2612
  }
2613
2613
  function Jn() {
2614
2614
  return Nt;
2615
2615
  }
2616
- ne.interceptors.request.use((e) => (Ve && (e.headers.Authorization = `Bearer ${Ve}`), e));
2617
- ne.interceptors.response.use(
2616
+ oe.interceptors.request.use((e) => (Ke && (e.headers.Authorization = `Bearer ${Ke}`), e));
2617
+ oe.interceptors.response.use(
2618
2618
  (e) => {
2619
2619
  if (typeof window < "u" && (e != null && e.data))
2620
2620
  try {
2621
2621
  const t = e.data, n = t.data || {}, r = typeof t.token == "string" && t.token || typeof n.token == "string" && n.token || null, o = typeof t.expires_at == "number" && t.expires_at || typeof n.expires_at == "number" && n.expires_at || typeof t.expiresAt == "number" && t.expiresAt || typeof n.expiresAt == "number" && n.expiresAt || null;
2622
- r && (localStorage.setItem(Re.authToken, r), ve(r)), o && localStorage.setItem(Re.authTokenExpiresAt, o.toString()), (r || o) && window.dispatchEvent(
2622
+ r && (localStorage.setItem(ze.authToken, r), xe(r)), o && localStorage.setItem(ze.authTokenExpiresAt, o.toString()), (r || o) && window.dispatchEvent(
2623
2623
  new CustomEvent("smartorg:chat-token-updated", {
2624
2624
  detail: { token: r, expiresAt: o }
2625
2625
  })
@@ -2632,18 +2632,18 @@ ne.interceptors.response.use(
2632
2632
  (e) => Promise.reject(e)
2633
2633
  );
2634
2634
  async function ae(e, t) {
2635
- return ne.defaults.baseURL ? (await ne.get(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
2635
+ return oe.defaults.baseURL ? (await oe.get(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
2636
2636
  }
2637
2637
  async function Ze(e, t, n) {
2638
- return ne.defaults.baseURL ? (await ne.post(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
2638
+ return oe.defaults.baseURL ? (await oe.post(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
2639
2639
  }
2640
2640
  async function Xn(e, t, n) {
2641
- return ne.defaults.baseURL ? (await ne.put(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
2641
+ return oe.defaults.baseURL ? (await oe.put(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
2642
2642
  }
2643
2643
  async function Qn(e, t) {
2644
- return ne.defaults.baseURL ? (await ne.delete(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
2644
+ return oe.defaults.baseURL ? (await oe.delete(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
2645
2645
  }
2646
- function ie(e) {
2646
+ function le(e) {
2647
2647
  return e && typeof e == "object" && "data" in e ? e.data : e;
2648
2648
  }
2649
2649
  class Yn {
@@ -2651,16 +2651,16 @@ class Yn {
2651
2651
  // Chat client uses the default httpClient baseURL, no need for internal tracking
2652
2652
  // unless we want to support multiple instances with different URLs in the future.
2653
2653
  get baseUrl() {
2654
- return ne.defaults.baseURL || "";
2654
+ return oe.defaults.baseURL || "";
2655
2655
  }
2656
2656
  updateConfig(t) {
2657
2657
  if (t.chatBaseUrl)
2658
- ne.defaults.baseURL = t.chatBaseUrl;
2658
+ oe.defaults.baseURL = t.chatBaseUrl;
2659
2659
  else if (t.baseUrl) {
2660
2660
  const n = t.baseUrl.replace(/\/+$/, "");
2661
- ne.defaults.baseURL = n;
2661
+ oe.defaults.baseURL = n;
2662
2662
  }
2663
- t.apiKey !== void 0 ? ve(t.apiKey) : t.getToken && ve(t.getToken()), (t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0) && Wn({
2663
+ t.apiKey !== void 0 ? xe(t.apiKey) : t.getToken && xe(t.getToken()), (t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0) && Wn({
2664
2664
  requestTimeoutMs: t.requestTimeoutMs,
2665
2665
  historyTimeoutMs: t.historyTimeoutMs
2666
2666
  });
@@ -2670,14 +2670,14 @@ class Yn {
2670
2670
  return Pt();
2671
2671
  }
2672
2672
  setAuthToken(t) {
2673
- ve(t);
2673
+ xe(t);
2674
2674
  }
2675
2675
  onTokenChange(t) {
2676
2676
  return _t(t);
2677
2677
  }
2678
2678
  // ---- Thread Management ----
2679
2679
  async listThreads() {
2680
- const t = await ae("/threads"), n = ie(t);
2680
+ const t = await ae("/threads"), n = le(t);
2681
2681
  return (n == null ? void 0 : n.items) ?? (t == null ? void 0 : t.items) ?? [];
2682
2682
  }
2683
2683
  // listUsers moved to AuthApi
@@ -2685,32 +2685,32 @@ class Yn {
2685
2685
  const r = {};
2686
2686
  t && (r.title = t), n && (r.project = n);
2687
2687
  const o = await Ze("/threads", Object.keys(r).length ? r : void 0);
2688
- return ie(o);
2688
+ return le(o);
2689
2689
  }
2690
2690
  async updateThread(t, n) {
2691
2691
  const r = await Xn(`/threads/${t}`, { title: n });
2692
- return ie(r);
2692
+ return le(r);
2693
2693
  }
2694
2694
  async deleteThread(t) {
2695
2695
  const n = await Qn(`/threads/${t}`);
2696
- return ie(n);
2696
+ return le(n);
2697
2697
  }
2698
2698
  async threadInfo(t) {
2699
2699
  const n = await ae(`/threads/${t}/info`);
2700
- return ie(n);
2700
+ return le(n);
2701
2701
  }
2702
2702
  // ---- Agents ----
2703
2703
  async listAgents() {
2704
- const t = await ae("/agents"), n = ie(t);
2704
+ const t = await ae("/agents"), n = le(t);
2705
2705
  return (n == null ? void 0 : n.items) ?? [];
2706
2706
  }
2707
2707
  async getAgent(t) {
2708
2708
  const n = await ae(`/agents/${t}`);
2709
- return ie(n);
2709
+ return le(n);
2710
2710
  }
2711
2711
  async getAgentSchema(t) {
2712
2712
  const n = await ae(`/agents/${t}/schema`);
2713
- return ie(n);
2713
+ return le(n);
2714
2714
  }
2715
2715
  async getState(t) {
2716
2716
  const n = await ae(`/threads/${t.threadId}/state`, {
@@ -2719,7 +2719,7 @@ class Yn {
2719
2719
  checkpoint_ns: t.checkpointNs
2720
2720
  }
2721
2721
  });
2722
- return ie(n);
2722
+ return le(n);
2723
2723
  }
2724
2724
  async getStateHistory(t) {
2725
2725
  const n = await ae(`/threads/${t.threadId}/state/history`, {
@@ -2733,12 +2733,12 @@ class Yn {
2733
2733
  timeout: Jn(),
2734
2734
  signal: t.signal
2735
2735
  });
2736
- return ie(n);
2736
+ return le(n);
2737
2737
  }
2738
2738
  // ---- Run Management ----
2739
2739
  async cancelRun(t) {
2740
2740
  const n = await Ze(`/runs/${t}/cancel`);
2741
- return ie(n);
2741
+ return le(n);
2742
2742
  }
2743
2743
  }
2744
2744
  const zt = new Yn();
@@ -2820,14 +2820,14 @@ class er {
2820
2820
  const n = t.baseUrl.replace(/\/+$/, "");
2821
2821
  this._authBaseUrl = `${n}/auth`;
2822
2822
  }
2823
- t.apiKey !== void 0 ? ve(t.apiKey) : t.getToken && ve(t.getToken());
2823
+ t.apiKey !== void 0 ? xe(t.apiKey) : t.getToken && xe(t.getToken());
2824
2824
  }
2825
2825
  // ---- Token Management ----
2826
2826
  getAuthToken() {
2827
2827
  return Pt();
2828
2828
  }
2829
2829
  setAuthToken(t) {
2830
- ve(t);
2830
+ xe(t);
2831
2831
  }
2832
2832
  onTokenChange(t) {
2833
2833
  return _t(t);
@@ -2838,7 +2838,7 @@ class er {
2838
2838
  return (t == null ? void 0 : t.users) ?? [];
2839
2839
  }
2840
2840
  }
2841
- const tr = new er(), Lt = Ee(null);
2841
+ const tr = new er(), Lt = Ce(null);
2842
2842
  function nr({ children: e, apiConfig: t }) {
2843
2843
  const n = zt, r = tr;
2844
2844
  if (t) {
@@ -2855,7 +2855,7 @@ function nr({ children: e, apiConfig: t }) {
2855
2855
  fileApi: Rt,
2856
2856
  baseUrl: n.baseUrl
2857
2857
  };
2858
- return /* @__PURE__ */ ce(Lt.Provider, { value: o, children: e });
2858
+ return /* @__PURE__ */ de(Lt.Provider, { value: o, children: e });
2859
2859
  }
2860
2860
  async function rr(e) {
2861
2861
  return await new Promise((t, n) => {
@@ -2930,8 +2930,8 @@ function lo(e) {
2930
2930
  }).join("|") : "", r = "checkpointId" in e && e.checkpointId ? `cp:${e.checkpointId}` : "", o = "checkpointNs" in e && e.checkpointNs ? `ns:${e.checkpointNs}` : "", s = [r, o].filter(Boolean).join("|");
2931
2931
  return `${e.id}:${t}:${n}${s ? `:${s}` : ""}`;
2932
2932
  }
2933
- function Ce() {
2934
- const e = Ue(Lt);
2933
+ function Me() {
2934
+ const e = je(Lt);
2935
2935
  if (!e) throw new Error("useApi must be used within ApiProvider");
2936
2936
  return e;
2937
2937
  }
@@ -2951,26 +2951,26 @@ function jt(e, t = "user") {
2951
2951
  function cr(e) {
2952
2952
  return !!e && typeof e == "object" && "data" in e;
2953
2953
  }
2954
- function Me(e) {
2954
+ function Se(e) {
2955
2955
  return typeof e == "object" && e !== null;
2956
2956
  }
2957
2957
  function lr(e) {
2958
- return Me(e) ? typeof e.id == "string" && typeof e.type == "string" && "content" in e : !1;
2958
+ return Se(e) ? typeof e.id == "string" && typeof e.type == "string" && "content" in e : !1;
2959
2959
  }
2960
2960
  function dr(e) {
2961
2961
  return Array.isArray(e) && e.every(lr);
2962
2962
  }
2963
2963
  function ur(e) {
2964
- if (!Me(e)) return {};
2964
+ if (!Se(e)) return {};
2965
2965
  const t = {};
2966
2966
  for (const [n, r] of Object.entries(e))
2967
- Me(r) && (t[n] = {
2968
- metadata: Me(r.metadata) ? r.metadata : void 0
2967
+ Se(r) && (t[n] = {
2968
+ metadata: Se(r.metadata) ? r.metadata : void 0
2969
2969
  });
2970
2970
  return t;
2971
2971
  }
2972
2972
  function fr(e, t) {
2973
- if (!e || !Me(t))
2973
+ if (!e || !Se(t))
2974
2974
  return t;
2975
2975
  if (e === "messages/partial") {
2976
2976
  const r = t;
@@ -2997,7 +2997,7 @@ function fr(e, t) {
2997
2997
  }
2998
2998
  if (e === "messages/metadata") {
2999
2999
  const r = t;
3000
- return (r == null ? void 0 : r.type) === "messages/metadata" && Me(r.metadata) ? {
3000
+ return (r == null ? void 0 : r.type) === "messages/metadata" && Se(r.metadata) ? {
3001
3001
  type: "messages/metadata",
3002
3002
  metadata: ur(r.metadata),
3003
3003
  seq: typeof r.seq == "number" ? r.seq : void 0,
@@ -3009,30 +3009,30 @@ function fr(e, t) {
3009
3009
  return "type" in n || (n.type = e), n;
3010
3010
  }
3011
3011
  function pr(e = {}) {
3012
- const t = e.baseUrl || "", n = e.streamPath ?? "/stream", [r, o] = $(e.token ?? null), s = G(e.headers ?? {}), a = e.credentials ?? "include", i = G(e);
3013
- X(() => {
3012
+ const t = e.baseUrl || "", n = e.streamPath ?? "/stream", [r, o] = D(e.token ?? null), s = H(e.headers ?? {}), a = e.credentials ?? "include", i = H(e);
3013
+ Y(() => {
3014
3014
  i.current = e;
3015
3015
  }, [e]);
3016
- const d = _((m) => {
3017
- var j, C, O, F, P, B, z, J, U, R;
3016
+ const d = N((m) => {
3017
+ var U, M, $, F, _, O, R, W, B, L;
3018
3018
  const k = i.current;
3019
3019
  if (!k) return;
3020
- (j = k.onEvent) == null || j.call(k, m), m.type === "thread_info" && ((C = k.onThreadInfo) == null || C.call(k, m)), m.type === "values" && ((O = k.handleValuesEvent) == null || O.call(k, m)), m.type === "metadata" && ((F = k.onMetadataEvent) == null || F.call(k, m)), typeof m.type == "string" && (m.type === "custom" || m.type.startsWith("custom.")) && ((P = k.onCustomEvent) == null || P.call(k, m)), m.type === "updates" && ((B = k.onUpdateEvent) == null || B.call(k, m)), m.type === "tool.end" ? (z = k.onToolEnd) == null || z.call(k, m) : m.type === "tool.start" && ((J = k.onToolStart) == null || J.call(k, m)), m.type === "heartbeat" && ((U = k.onHeartbeat) == null || U.call(k, m)), m.type === "token" && ((R = k.onToken) == null || R.call(k, m.token));
3021
- }, []), [c, l] = $(!1), [f, p] = $(null), [g, I] = $(!1), [u, v] = $(null), x = G(null), M = G(!0), A = G(null), w = _((m) => {
3020
+ (U = k.onEvent) == null || U.call(k, m), m.type === "thread_info" && ((M = k.onThreadInfo) == null || M.call(k, m)), m.type === "values" && (($ = k.handleValuesEvent) == null || $.call(k, m)), m.type === "metadata" && ((F = k.onMetadataEvent) == null || F.call(k, m)), typeof m.type == "string" && (m.type === "custom" || m.type.startsWith("custom.")) && ((_ = k.onCustomEvent) == null || _.call(k, m)), m.type === "updates" && ((O = k.onUpdateEvent) == null || O.call(k, m)), m.type === "tool.end" ? (R = k.onToolEnd) == null || R.call(k, m) : m.type === "tool.start" && ((W = k.onToolStart) == null || W.call(k, m)), m.type === "heartbeat" && ((B = k.onHeartbeat) == null || B.call(k, m)), m.type === "token" && ((L = k.onToken) == null || L.call(k, m.token));
3021
+ }, []), [c, l] = D(!1), [f, p] = D(null), [g, I] = D(!1), [u, v] = D(null), x = H(null), S = H(!0), A = H(null), w = N((m) => {
3022
3022
  o(m);
3023
- }, []), b = _(() => {
3023
+ }, []), b = N(() => {
3024
3024
  p(null), v(null);
3025
- }, []), h = _(() => {
3026
- var C, O;
3025
+ }, []), y = N(() => {
3026
+ var M, $;
3027
3027
  console.debug("[use-chat] stop() invoked - aborting stream");
3028
- const m = (C = A.current) == null ? void 0 : C.threadId, k = (O = A.current) == null ? void 0 : O.runId, E = () => {
3028
+ const m = (M = A.current) == null ? void 0 : M.threadId, k = ($ = A.current) == null ? void 0 : $.runId, E = () => {
3029
3029
  var F;
3030
3030
  (F = x.current) == null || F.abort(), x.current = null, A.current = null, l(!1), I(!1);
3031
3031
  };
3032
3032
  (k || m ? zt.cancelRun(k || m).catch((F) => {
3033
3033
  console.warn("[use-chat] cancel run failed:", F);
3034
3034
  }) : Promise.resolve()).finally(E);
3035
- }, []), T = _(
3035
+ }, []), T = N(
3036
3036
  (m) => {
3037
3037
  x.current && (x.current.abort(), x.current = null);
3038
3038
  const k = {
@@ -3052,7 +3052,7 @@ function pr(e = {}) {
3052
3052
  l(!0), p(null), v(null);
3053
3053
  const E = new AbortController();
3054
3054
  x.current = E;
3055
- let j = null, C = !1;
3055
+ let U = null, M = !1;
3056
3056
  return A.current = {
3057
3057
  threadId: k.threadId ?? void 0,
3058
3058
  runId: void 0,
@@ -3060,161 +3060,161 @@ function pr(e = {}) {
3060
3060
  headers: {},
3061
3061
  isStreaming: !0
3062
3062
  }, (async () => {
3063
- var O, F, P, B, z, J;
3063
+ var $, F, _, O, R, W;
3064
3064
  try {
3065
- let U = {};
3065
+ let B = {};
3066
3066
  try {
3067
3067
  if (r)
3068
- U = { Authorization: `Bearer ${r}` };
3068
+ B = { Authorization: `Bearer ${r}` };
3069
3069
  else if (typeof window < "u") {
3070
- const te = window.__AUTH_TOKEN__, ke = ((O = window.localStorage) == null ? void 0 : O.getItem(Re.authToken)) || null;
3071
- let Q = null;
3070
+ const se = window.__AUTH_TOKEN__, he = (($ = window.localStorage) == null ? void 0 : $.getItem(ze.authToken)) || null;
3071
+ let X = null;
3072
3072
  try {
3073
- const pe = (F = window.localStorage) == null ? void 0 : F.getItem(Re.chatSettings);
3074
- pe && (Q = ((P = JSON.parse(pe)) == null ? void 0 : P.apiKey) || null);
3073
+ const be = (F = window.localStorage) == null ? void 0 : F.getItem(ze.chatSettings);
3074
+ be && (X = ((_ = JSON.parse(be)) == null ? void 0 : _.apiKey) || null);
3075
3075
  } catch {
3076
3076
  }
3077
- const Z = te || ke || Q || null;
3078
- Z && (U = { Authorization: `Bearer ${Z}` });
3077
+ const Q = se || he || X || null;
3078
+ Q && (B = { Authorization: `Bearer ${Q}` });
3079
3079
  }
3080
3080
  } catch {
3081
3081
  }
3082
3082
  console.debug("[use-chat] POST", t + n);
3083
- let R = {};
3083
+ let L = {};
3084
3084
  if (typeof window < "u")
3085
3085
  try {
3086
- const H = (B = window.localStorage) == null ? void 0 : B.getItem(Re.authSessionId);
3087
- H && (R = { "X-Session-Id": H });
3086
+ const G = (O = window.localStorage) == null ? void 0 : O.getItem(ze.authSessionId);
3087
+ G && (L = { "X-Session-Id": G });
3088
3088
  } catch {
3089
3089
  }
3090
- const q = {
3091
- ...U,
3092
- ...R,
3090
+ const h = {
3091
+ ...B,
3092
+ ...L,
3093
3093
  ...s.current
3094
- }, y = {
3094
+ }, j = {
3095
3095
  "Content-Type": "application/json",
3096
3096
  Accept: "text/event-stream",
3097
- ...q
3098
- }, L = await fetch(t + n, {
3097
+ ...h
3098
+ }, C = await fetch(t + n, {
3099
3099
  method: "POST",
3100
- headers: y,
3100
+ headers: j,
3101
3101
  body: JSON.stringify(k),
3102
3102
  signal: E.signal,
3103
3103
  credentials: a
3104
3104
  });
3105
- if (A.current && (A.current.headers = q), !L.ok || !L.body) {
3106
- const H = await L.text().catch(() => "");
3105
+ if (A.current && (A.current.headers = h), !C.ok || !C.body) {
3106
+ const G = await C.text().catch(() => "");
3107
3107
  console.debug(
3108
3108
  "[use-chat] non-OK response",
3109
- L.status,
3110
- H == null ? void 0 : H.slice(0, 500)
3109
+ C.status,
3110
+ G == null ? void 0 : G.slice(0, 500)
3111
3111
  );
3112
- const te = `stream ${L.status}${H ? ": " + H : ""}`;
3113
- throw te && (p(te), j = "error"), new Error(te);
3112
+ const se = `stream ${C.status}${G ? ": " + G : ""}`;
3113
+ throw se && (p(se), U = "error"), new Error(se);
3114
3114
  }
3115
3115
  I(!0);
3116
- const S = L.body.getReader(), W = new TextDecoder();
3116
+ const P = C.body.getReader(), J = new TextDecoder();
3117
3117
  let K = "", V = 0, ee = Date.now();
3118
- const oe = setInterval(() => {
3119
- Date.now() - ee > 18e5 && (p("Stream idle timeout"), j = "error", E.abort());
3120
- }, 5e3), fe = 1024 * 1024;
3118
+ const ie = setInterval(() => {
3119
+ Date.now() - ee > 18e5 && (p("Stream idle timeout"), U = "error", E.abort());
3120
+ }, 5e3), ye = 1024 * 1024;
3121
3121
  try {
3122
- const H = L.headers.get("X-Thread-Id") || L.headers.get("x-thread-id"), te = L.headers.get("X-Run-Id") || L.headers.get("x-run-id");
3122
+ const G = C.headers.get("X-Thread-Id") || C.headers.get("x-thread-id"), se = C.headers.get("X-Run-Id") || C.headers.get("x-run-id");
3123
3123
  for (A.current && (A.current = {
3124
3124
  ...A.current,
3125
- threadId: H ?? A.current.threadId,
3126
- runId: te ?? A.current.runId
3125
+ threadId: G ?? A.current.threadId,
3126
+ runId: se ?? A.current.runId
3127
3127
  }); ; ) {
3128
- const { value: ke, done: Q } = await S.read();
3129
- if (Q) break;
3130
- K += W.decode(ke, { stream: !0 }), K.length > fe && (K = "", console.warn("Stream buffer reset: exceeded 1MB"));
3131
- let Z;
3132
- for (; (Z = K.indexOf(`
3128
+ const { value: he, done: X } = await P.read();
3129
+ if (X) break;
3130
+ K += J.decode(he, { stream: !0 }), K.length > ye && (K = "", console.warn("Stream buffer reset: exceeded 1MB"));
3131
+ let Q;
3132
+ for (; (Q = K.indexOf(`
3133
3133
 
3134
3134
  `)) >= 0; ) {
3135
- const pe = K.slice(0, Z);
3136
- K = K.slice(Z + 2);
3137
- const _e = pe.split(/\r?\n/), Be = [];
3138
- let he = null;
3139
- for (const le of _e)
3140
- if (!le.startsWith(":") && le) {
3141
- if (le.startsWith("event:")) {
3142
- const Te = le.slice(6).trim();
3143
- Te && (he = Te);
3135
+ const be = K.slice(0, Q);
3136
+ K = K.slice(Q + 2);
3137
+ const Ve = be.split(/\r?\n/), we = [];
3138
+ let Pe = null;
3139
+ for (const ce of Ve)
3140
+ if (!ce.startsWith(":") && ce) {
3141
+ if (ce.startsWith("event:")) {
3142
+ const Ae = ce.slice(6).trim();
3143
+ Ae && (Pe = Ae);
3144
3144
  continue;
3145
3145
  }
3146
- if (le.startsWith("data:")) {
3147
- const Te = le.slice(5);
3148
- Be.push(Te.startsWith(" ") ? Te.slice(1) : Te);
3146
+ if (ce.startsWith("data:")) {
3147
+ const Ae = ce.slice(5);
3148
+ we.push(Ae.startsWith(" ") ? Ae.slice(1) : Ae);
3149
3149
  }
3150
3150
  }
3151
- const xe = Be.join(`
3151
+ const ke = we.join(`
3152
3152
  `);
3153
- if (!xe) continue;
3154
- let se;
3153
+ if (!ke) continue;
3154
+ let ne;
3155
3155
  try {
3156
- se = JSON.parse(xe);
3156
+ ne = JSON.parse(ke);
3157
3157
  } catch {
3158
- console.debug("[use-chat] malformed SSE:", xe.slice(0, 200));
3158
+ console.debug("[use-chat] malformed SSE:", ke.slice(0, 200));
3159
3159
  continue;
3160
3160
  }
3161
- se = fr(he, se);
3162
- const Ie = cr(se) ? se.data : se;
3163
- if (!Ie) {
3164
- console.warn("[use-chat] dropped envelope event without payload", se);
3161
+ ne = fr(Pe, ne);
3162
+ const Ue = cr(ne) ? ne.data : ne;
3163
+ if (!Ue) {
3164
+ console.warn("[use-chat] dropped envelope event without payload", ne);
3165
3165
  continue;
3166
3166
  }
3167
- const Ae = $n(Ie);
3167
+ const re = $n(Ue);
3168
3168
  ee = Date.now();
3169
- const re = typeof Ae.seq == "number" ? Ae.seq : void 0;
3170
- if (re !== void 0) {
3171
- if (re <= V) {
3172
- console.debug("[use-chat] drop duplicate/out-of-order event", { seq: re, lastProcessedSeq: V, type: Ae.type });
3169
+ const te = typeof re.seq == "number" ? re.seq : void 0;
3170
+ if (te !== void 0) {
3171
+ if (te <= V) {
3172
+ console.debug("[use-chat] drop duplicate/out-of-order event", { seq: te, lastProcessedSeq: V, type: re.type });
3173
3173
  continue;
3174
3174
  }
3175
- V = re;
3175
+ V = te;
3176
3176
  }
3177
- d(Ae);
3177
+ d(re);
3178
3178
  }
3179
3179
  }
3180
- j === null && !E.signal.aborted && (j = "complete");
3181
- } catch (H) {
3182
- if (H.name === "AbortError")
3183
- j = j ?? "aborted";
3180
+ U === null && !E.signal.aborted && (U = "complete");
3181
+ } catch (G) {
3182
+ if (G.name === "AbortError")
3183
+ U = U ?? "aborted";
3184
3184
  else {
3185
- const te = H.message || String(H);
3186
- j = "error", p(te);
3185
+ const se = G.message || String(G);
3186
+ U = "error", p(se);
3187
3187
  }
3188
3188
  } finally {
3189
3189
  try {
3190
- await S.cancel();
3190
+ await P.cancel();
3191
3191
  } catch {
3192
3192
  } finally {
3193
- (z = S.releaseLock) == null || z.call(S);
3193
+ (R = P.releaseLock) == null || R.call(P);
3194
3194
  }
3195
- clearInterval(oe);
3195
+ clearInterval(ie);
3196
3196
  }
3197
- } catch (U) {
3198
- if (U.name === "AbortError")
3199
- j = j ?? "aborted";
3197
+ } catch (B) {
3198
+ if (B.name === "AbortError")
3199
+ U = U ?? "aborted";
3200
3200
  else {
3201
- const R = U.message || String(U);
3202
- j = "error", p(R), C || (C = !0, (J = e.onConnectionError) == null || J.call(e, R));
3201
+ const L = B.message || String(B);
3202
+ U = "error", p(L), M || (M = !0, (W = e.onConnectionError) == null || W.call(e, L));
3203
3203
  }
3204
3204
  } finally {
3205
3205
  try {
3206
3206
  if (e.onFinish) {
3207
- const U = {
3207
+ const B = {
3208
3208
  lastSeq: 0,
3209
3209
  lastCheckpointId: null,
3210
3210
  lastCheckpointNs: null,
3211
3211
  lastValues: null
3212
3212
  // Let the reducer/history hook provide the final values
3213
3213
  };
3214
- e.onFinish(U);
3214
+ e.onFinish(B);
3215
3215
  }
3216
- } catch (U) {
3217
- console.warn("[use-chat] onClosed callback failed", U);
3216
+ } catch (B) {
3217
+ console.warn("[use-chat] onClosed callback failed", B);
3218
3218
  }
3219
3219
  l(!1), I(!1), x.current = null, A.current = null;
3220
3220
  }
@@ -3222,9 +3222,9 @@ function pr(e = {}) {
3222
3222
  },
3223
3223
  [t, n, r, e, d]
3224
3224
  );
3225
- return X(() => () => {
3225
+ return Y(() => () => {
3226
3226
  var m;
3227
- M.current = !1, (m = x.current) == null || m.abort();
3227
+ S.current = !1, (m = x.current) == null || m.abort();
3228
3228
  }, []), {
3229
3229
  isStreaming: c,
3230
3230
  error: f,
@@ -3238,7 +3238,7 @@ function pr(e = {}) {
3238
3238
  lastSeq: 0,
3239
3239
  connected: g,
3240
3240
  stream: T,
3241
- stop: h,
3241
+ stop: y,
3242
3242
  clear: b,
3243
3243
  setToken: w,
3244
3244
  values: {},
@@ -3259,33 +3259,33 @@ function gr({
3259
3259
  onThreadChange: r,
3260
3260
  onCurrentThreadDeleted: o
3261
3261
  }) {
3262
- const [s, a] = $([]), [i, d] = $(t), [c, l] = $(!1), [f, p] = $(null), g = G(i), I = G(/* @__PURE__ */ new Map());
3263
- X(() => {
3262
+ const [s, a] = D([]), [i, d] = D(t), [c, l] = D(!1), [f, p] = D(null), g = H(i), I = H(/* @__PURE__ */ new Map());
3263
+ Y(() => {
3264
3264
  g.current = i;
3265
- }, [i]), X(() => {
3265
+ }, [i]), Y(() => {
3266
3266
  t !== void 0 && t !== g.current && d(t);
3267
3267
  }, [t]);
3268
- const u = _(async () => {
3268
+ const u = N(async () => {
3269
3269
  l(!0), p(null);
3270
3270
  try {
3271
3271
  const b = await e.listThreads();
3272
3272
  a(b ?? []);
3273
3273
  } catch (b) {
3274
- const h = String(b);
3275
- p(h), n == null || n(h);
3274
+ const y = String(b);
3275
+ p(y), n == null || n(y);
3276
3276
  } finally {
3277
3277
  l(!1);
3278
3278
  }
3279
3279
  }, [e, n]);
3280
- X(() => {
3280
+ Y(() => {
3281
3281
  u();
3282
- }, [u]), X(() => {
3282
+ }, [u]), Y(() => {
3283
3283
  r == null || r(i);
3284
3284
  }, [i, r]);
3285
- const v = _(
3286
- async (b, h) => {
3285
+ const v = N(
3286
+ async (b, y) => {
3287
3287
  try {
3288
- const T = h && typeof h == "object" ? { id: h.id, name: h.name ?? "" } : void 0, m = await e.createThread(b, T);
3288
+ const T = y && typeof y == "object" ? { id: y.id, name: y.name ?? "" } : void 0, m = await e.createThread(b, T);
3289
3289
  return d(m.threadId), await u(), m.threadId;
3290
3290
  } catch (T) {
3291
3291
  const m = String(T);
@@ -3293,16 +3293,16 @@ function gr({
3293
3293
  }
3294
3294
  },
3295
3295
  [e, n, u]
3296
- ), x = _(
3296
+ ), x = N(
3297
3297
  async (b) => {
3298
- const h = s;
3298
+ const y = s;
3299
3299
  a((m) => m.filter((k) => k.threadId !== b));
3300
3300
  const T = new AbortController();
3301
3301
  I.current.set(b, T);
3302
3302
  try {
3303
3303
  await e.deleteThread(b), g.current === b && (d(null), o == null || o());
3304
3304
  } catch (m) {
3305
- a(h);
3305
+ a(y);
3306
3306
  const k = String(m);
3307
3307
  n == null || n(k);
3308
3308
  } finally {
@@ -3310,26 +3310,26 @@ function gr({
3310
3310
  }
3311
3311
  },
3312
3312
  [e, o, n, s]
3313
- ), M = _(
3314
- async (b, h) => {
3313
+ ), S = N(
3314
+ async (b, y) => {
3315
3315
  try {
3316
- await e.updateThread(b, h), await u();
3316
+ await e.updateThread(b, y), await u();
3317
3317
  } catch (T) {
3318
3318
  n == null || n(String(T));
3319
3319
  }
3320
3320
  },
3321
3321
  [e, n, u]
3322
- ), A = Y(
3322
+ ), A = Z(
3323
3323
  () => ({
3324
3324
  createThread: v,
3325
3325
  deleteThread: x,
3326
- renameThread: M,
3326
+ renameThread: S,
3327
3327
  refreshThreads: u
3328
3328
  }),
3329
- [v, x, M, u]
3330
- ), w = _((b) => {
3329
+ [v, x, S, u]
3330
+ ), w = N((b) => {
3331
3331
  if (!(b != null && b.threadId)) return;
3332
- const h = {
3332
+ const y = {
3333
3333
  threadId: b.threadId,
3334
3334
  title: b.title || `Thread ${b.threadId.slice(0, 8)}`,
3335
3335
  project: b.project,
@@ -3339,14 +3339,14 @@ function gr({
3339
3339
  };
3340
3340
  a((T) => {
3341
3341
  let m = !1;
3342
- const k = T.map((E) => E.threadId === h.threadId ? (m = !0, console.debug("[useThreadsState] thread_info: updating existing thread", h.threadId), {
3342
+ const k = T.map((E) => E.threadId === y.threadId ? (m = !0, console.debug("[useThreadsState] thread_info: updating existing thread", y.threadId), {
3343
3343
  ...E,
3344
- title: h.title ?? E.title,
3345
- project: h.project ?? E.project,
3346
- updatedAt: h.updatedAt ?? E.updatedAt,
3347
- messageCount: h.messageCount ?? E.messageCount
3344
+ title: y.title ?? E.title,
3345
+ project: y.project ?? E.project,
3346
+ updatedAt: y.updatedAt ?? E.updatedAt,
3347
+ messageCount: y.messageCount ?? E.messageCount
3348
3348
  }) : E);
3349
- return m ? k : (console.debug("[useThreadsState] thread_info: adding thread to list", h.threadId), [h, ...T]);
3349
+ return m ? k : (console.debug("[useThreadsState] thread_info: adding thread to list", y.threadId), [y, ...T]);
3350
3350
  });
3351
3351
  }, []);
3352
3352
  return {
@@ -3360,14 +3360,14 @@ function gr({
3360
3360
  addThreadFromEvent: w
3361
3361
  };
3362
3362
  }
3363
- const Ut = Ee(null);
3363
+ const Ut = Ce(null);
3364
3364
  function mr({
3365
3365
  children: e,
3366
3366
  initialThreadId: t = null,
3367
3367
  onError: n,
3368
3368
  onThreadChange: r
3369
3369
  }) {
3370
- const { chatApi: o } = Ce(), {
3370
+ const { chatApi: o } = Me(), {
3371
3371
  threads: s,
3372
3372
  currentThreadId: a,
3373
3373
  setCurrentThreadId: i,
@@ -3381,7 +3381,7 @@ function mr({
3381
3381
  initialThreadId: t,
3382
3382
  onError: n,
3383
3383
  onThreadChange: r
3384
- }), g = Y(
3384
+ }), g = Z(
3385
3385
  () => ({
3386
3386
  threads: s,
3387
3387
  currentThreadId: a,
@@ -3403,10 +3403,10 @@ function mr({
3403
3403
  p
3404
3404
  ]
3405
3405
  );
3406
- return /* @__PURE__ */ ce(Ut.Provider, { value: g, children: e });
3406
+ return /* @__PURE__ */ de(Ut.Provider, { value: g, children: e });
3407
3407
  }
3408
3408
  function ot(e) {
3409
- const t = Ue(Ut);
3409
+ const t = je(Ut);
3410
3410
  if (!t && !(e != null && e.optional)) throw new Error("useThreads must be used within a ThreadsProvider");
3411
3411
  return t;
3412
3412
  }
@@ -3442,7 +3442,7 @@ function hr(e, t, n) {
3442
3442
  return !!((o == null ? void 0 : o.id) === t || n && r.toolCallId === n);
3443
3443
  }) ?? null;
3444
3444
  }
3445
- function Oe(e) {
3445
+ function Fe(e) {
3446
3446
  const t = /* @__PURE__ */ new Set();
3447
3447
  return e.map((n) => nt(n)).filter((n) => !n || t.has(n.id) ? !1 : (t.add(n.id), !0));
3448
3448
  }
@@ -3481,7 +3481,7 @@ function wr(e, t) {
3481
3481
  case "reset":
3482
3482
  return {
3483
3483
  ...Ot,
3484
- messages: Oe(((n = t.payload) == null ? void 0 : n.messages) ?? [])
3484
+ messages: Fe(((n = t.payload) == null ? void 0 : n.messages) ?? [])
3485
3485
  };
3486
3486
  case "user_message": {
3487
3487
  const { message: r, editingMessageId: o } = t.payload;
@@ -3509,7 +3509,7 @@ function wr(e, t) {
3509
3509
  };
3510
3510
  }
3511
3511
  case "seed": {
3512
- const r = Oe(t.payload.messages), o = {
3512
+ const r = Fe(t.payload.messages), o = {
3513
3513
  ...e,
3514
3514
  status: "idle",
3515
3515
  messages: r,
@@ -3521,7 +3521,7 @@ function wr(e, t) {
3521
3521
  return Object.prototype.hasOwnProperty.call(t.payload, "checkpointId") && (o.lastCheckpointId = t.payload.checkpointId ?? null), Object.prototype.hasOwnProperty.call(t.payload, "checkpointNs") && (o.lastCheckpointNs = t.payload.checkpointNs ?? null), Object.prototype.hasOwnProperty.call(t.payload, "values") && (o.values = t.payload.values ?? {}), o;
3522
3522
  }
3523
3523
  case "prepend": {
3524
- const r = Oe(t.payload.messages);
3524
+ const r = Fe(t.payload.messages);
3525
3525
  if (!r.length) return e;
3526
3526
  const o = new Set(e.messages.map((a) => a.id)), s = r.filter((a) => !o.has(a.id));
3527
3527
  return s.length ? { ...e, messages: [...s, ...e.messages] } : e;
@@ -3537,15 +3537,15 @@ function wr(e, t) {
3537
3537
  }
3538
3538
  }
3539
3539
  function kr(e = []) {
3540
- const [t, n] = Wt(wr, { ...Ot, messages: e }), r = G([]), o = G(null), s = _(() => {
3540
+ const [t, n] = Wt(wr, { ...Ot, messages: e }), r = H([]), o = H(null), s = N(() => {
3541
3541
  o.current !== null && typeof window < "u" && window.cancelAnimationFrame(o.current), o.current = null;
3542
3542
  const c = r.current;
3543
3543
  c.length && (r.current = [], n({ type: "batch", payload: { events: c } }));
3544
- }, []), a = _(() => {
3544
+ }, []), a = N(() => {
3545
3545
  typeof window < "u" && typeof window.requestAnimationFrame == "function" ? o.current === null && (o.current = window.requestAnimationFrame(() => s())) : setTimeout(s, 8);
3546
- }, [s]), i = _((c) => {
3546
+ }, [s]), i = N((c) => {
3547
3547
  r.current.push(c), a();
3548
- }, [a]), d = Y(() => ({
3548
+ }, [a]), d = Z(() => ({
3549
3549
  setStatus: (c, l) => n({ type: "status", payload: { status: c, error: l } }),
3550
3550
  reset: (c) => n({ type: "reset", payload: { messages: c } }),
3551
3551
  seed: (c, l) => n({ type: "seed", payload: { messages: c, ...l ?? {} } }),
@@ -3588,7 +3588,7 @@ function pt(e, t) {
3588
3588
  const s = t, a = s.values && typeof s.values == "object" ? { ...s.values } : {}, i = Array.isArray(s.messages) ? s.messages : Array.isArray(a.messages) ? a.messages : [];
3589
3589
  if (!i.length && Object.keys(a).length === 0)
3590
3590
  return e;
3591
- const d = Oe(i);
3591
+ const d = Fe(i);
3592
3592
  delete a.messages;
3593
3593
  let c = e.lastCheckpointId, l = e.lastCheckpointNs;
3594
3594
  const f = s.config || s.checkpoint, p = (f == null ? void 0 : f.configurable) || f;
@@ -3653,7 +3653,7 @@ function pt(e, t) {
3653
3653
  return t.type === "message.start" ? { ...e, assemblingId: t.id, status: "streaming" } : t.type === "message.end" ? { ...e, assemblingId: null } : t.type === "tool.start" ? { ...vr(e, t, o), status: "streaming" } : t.type === "tool.progress" ? xr(e, t, o) : t.type === "tool.end" ? Ar(e, t, o) : t.type === "artifact.update" ? Tr(e, t) : e;
3654
3654
  }
3655
3655
  function Ir(e, t, n) {
3656
- var g, I, u, v, x, M, A;
3656
+ var g, I, u, v, x, S, A;
3657
3657
  const r = t.messages;
3658
3658
  if (!r.length)
3659
3659
  return console.warn("[messagesReducer] Dropping messages/partial event without messages[]", t), e;
@@ -3696,7 +3696,7 @@ function Ir(e, t, n) {
3696
3696
  [s]: {
3697
3697
  ...((u = e.messagesStreamMeta) == null ? void 0 : u[s]) ?? {},
3698
3698
  lastSeq: t.seq ?? ((x = (v = e.messagesStreamMeta) == null ? void 0 : v[s]) == null ? void 0 : x.lastSeq) ?? null,
3699
- lastText: d || (((A = (M = e.messagesStreamMeta) == null ? void 0 : M[s]) == null ? void 0 : A.lastText) ?? "")
3699
+ lastText: d || (((A = (S = e.messagesStreamMeta) == null ? void 0 : S[s]) == null ? void 0 : A.lastText) ?? "")
3700
3700
  }
3701
3701
  }
3702
3702
  };
@@ -3763,7 +3763,7 @@ function xr(e, t, n) {
3763
3763
  let s = n ? [...e.taskMessagesByScope[o] || []] : [...e.messages];
3764
3764
  const a = st(s, r);
3765
3765
  if (a !== -1) {
3766
- const i = s[a], d = de(t.content), c = (i.toolCalls || []).map(
3766
+ const i = s[a], d = ue(t.content), c = (i.toolCalls || []).map(
3767
3767
  (l) => l.id === r ? { ...l, content: typeof d == "string" ? d : l.content } : l
3768
3768
  );
3769
3769
  s[a] = {
@@ -3784,7 +3784,7 @@ function Ar(e, t, n) {
3784
3784
  if (!r) return e;
3785
3785
  const o = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3786
3786
  let s = n ? [...e.taskMessagesByScope[o] || []] : [...e.messages];
3787
- const a = st(s, r), i = de(t.content ?? t.error);
3787
+ const a = st(s, r), i = ue(t.content ?? t.error);
3788
3788
  if (a !== -1) {
3789
3789
  const c = s[a], l = (c.toolCalls || []).map(
3790
3790
  (f) => f.id === r ? {
@@ -3828,11 +3828,11 @@ function Tr(e, t) {
3828
3828
  });
3829
3829
  return t.partial_data && s.artifact && (s.artifact = { ...s.artifact, ...t.partial_data }), { ...e, messages: Ft(e.messages, o, s) };
3830
3830
  }
3831
- function Le(e) {
3831
+ function Re(e) {
3832
3832
  if (!(!e || typeof e != "object" || Array.isArray(e)))
3833
3833
  return { ...e };
3834
3834
  }
3835
- function Fe(e, t) {
3835
+ function Be(e, t) {
3836
3836
  if (e)
3837
3837
  for (const n of t) {
3838
3838
  const r = e[n];
@@ -3850,14 +3850,14 @@ function Sr(e, t) {
3850
3850
  return null;
3851
3851
  }
3852
3852
  function gt(e) {
3853
- const t = Le(e);
3853
+ const t = Re(e);
3854
3854
  if (t)
3855
- return Le(t.configurable) ?? t;
3855
+ return Re(t.configurable) ?? t;
3856
3856
  }
3857
3857
  async function Mr(e, t) {
3858
3858
  var i, d;
3859
3859
  if (!e) return e ?? null;
3860
- const n = ue(e), r = Array.isArray(n.checkpoints) ? n.checkpoints : n.checkpoints ? Object.values(n.checkpoints) : [], o = /* @__PURE__ */ new Set();
3860
+ const n = fe(e), r = Array.isArray(n.checkpoints) ? n.checkpoints : n.checkpoints ? Object.values(n.checkpoints) : [], o = /* @__PURE__ */ new Set();
3861
3861
  for (const c of r) {
3862
3862
  const l = (i = c == null ? void 0 : c.values) == null ? void 0 : i.messages;
3863
3863
  if (Array.isArray(l))
@@ -3876,7 +3876,7 @@ async function Mr(e, t) {
3876
3876
  const s = await Promise.all(
3877
3877
  Array.from(o).map(async (c) => {
3878
3878
  try {
3879
- const l = await t.getFileInfo(c), f = ue(l);
3879
+ const l = await t.getFileInfo(c), f = fe(l);
3880
3880
  return [c, f];
3881
3881
  } catch {
3882
3882
  return [c, null];
@@ -3901,7 +3901,7 @@ async function Mr(e, t) {
3901
3901
  return n;
3902
3902
  }
3903
3903
  function mt(e) {
3904
- const r = [...(Array.isArray(e == null ? void 0 : e.checkpoints) ? (e == null ? void 0 : e.checkpoints) ?? [] : e != null && e.checkpoints ? Object.values(e.checkpoints) : []).map((s, a) => Cr(ue(s), a)).filter((s) => !!s)].sort((s, a) => yt(a.createdAt) - yt(s.createdAt)), o = r[0] ?? null;
3904
+ const r = [...(Array.isArray(e == null ? void 0 : e.checkpoints) ? (e == null ? void 0 : e.checkpoints) ?? [] : e != null && e.checkpoints ? Object.values(e.checkpoints) : []).map((s, a) => Cr(fe(s), a)).filter((s) => !!s)].sort((s, a) => yt(a.createdAt) - yt(s.createdAt)), o = r[0] ?? null;
3905
3905
  return {
3906
3906
  threadId: (e == null ? void 0 : e.threadId) ?? "",
3907
3907
  latest: o,
@@ -3910,13 +3910,13 @@ function mt(e) {
3910
3910
  };
3911
3911
  }
3912
3912
  function Cr(e, t) {
3913
- var b, h;
3913
+ var b, y;
3914
3914
  if (!e) return null;
3915
- const n = ((b = e.values) == null ? void 0 : b.activeAgent) ?? null, r = (h = e.values) == null ? void 0 : h.messages, s = (Array.isArray(r) ? r : []).map((T) => Er(T, n)).filter((T) => !!T), a = Le(e.metadata) ?? {}, i = gt(e.config), d = Le(e.parentConfig), c = gt(d), l = Fe(i, ["checkpointId"]), f = Fe(i, ["checkpointNs"]), p = Fe(c, ["checkpointId"]), g = Le(e.config), I = Array.isArray(e.tasks) ? e.tasks.map((T) => ({ ...T })) : e.tasks ?? null, u = 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(), x = {
3915
+ 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((T) => Er(T, n)).filter((T) => !!T), a = Re(e.metadata) ?? {}, i = gt(e.config), d = Re(e.parentConfig), c = gt(d), l = Be(i, ["checkpointId"]), f = Be(i, ["checkpointNs"]), p = Be(c, ["checkpointId"]), g = Re(e.config), I = Array.isArray(e.tasks) ? e.tasks.map((T) => ({ ...T })) : e.tasks ?? null, u = 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(), x = {
3916
3916
  ...a,
3917
3917
  step: Sr(a, ["step"]) ?? 0,
3918
- source: Fe(a, ["source"]) ?? null
3919
- }, M = s.map((T) => ({
3918
+ source: Be(a, ["source"]) ?? null
3919
+ }, S = s.map((T) => ({
3920
3920
  ...T,
3921
3921
  checkpointId: T.checkpointId ?? l ?? null,
3922
3922
  checkpointNs: T.checkpointNs ?? f ?? null
@@ -3926,7 +3926,7 @@ function Cr(e, t) {
3926
3926
  checkpointNs: f ?? null,
3927
3927
  createdAt: v,
3928
3928
  parentId: p ?? null,
3929
- messages: M,
3929
+ messages: S,
3930
3930
  interrupt: Pr(
3931
3931
  w,
3932
3932
  t,
@@ -3983,9 +3983,9 @@ function zr(e) {
3983
3983
  for (let c = 0; c < e.length; c++) {
3984
3984
  const l = e[c], f = l.checkpointId, p = f ?? `cp-${c}`, g = l.metadata ?? {}, I = typeof g.step == "number" ? g.step : null, u = typeof g.source == "string" ? g.source : null;
3985
3985
  let v = null, x = null;
3986
- const M = Array.isArray(l.messages) ? l.messages : [];
3987
- for (const h of M)
3988
- h.role === "user" && (x || (x = h), h.id && (v = h.id));
3986
+ const S = Array.isArray(l.messages) ? l.messages : [];
3987
+ for (const y of S)
3988
+ y.role === "user" && (x || (x = y), y.id && (v = y.id));
3989
3989
  const A = l.next && l.next.length > 0 ? String(l.next[0]) : null, w = l.parentConfig ?? null, b = {
3990
3990
  id: p,
3991
3991
  step: I,
@@ -3998,8 +3998,8 @@ function zr(e) {
3998
3998
  userMessageId: v
3999
3999
  };
4000
4000
  if (o.push(b), f && t.set(f, b), f && x) {
4001
- const h = Nr(x);
4002
- h && r.set(f, h);
4001
+ const y = Nr(x);
4002
+ y && r.set(f, y);
4003
4003
  }
4004
4004
  n.push({
4005
4005
  id: p,
@@ -4069,7 +4069,7 @@ function uo(e, t, n) {
4069
4069
  };
4070
4070
  }
4071
4071
  function Rr(e) {
4072
- return Y(() => zr(e), [e]);
4072
+ return Z(() => zr(e), [e]);
4073
4073
  }
4074
4074
  function $t({
4075
4075
  api: e,
@@ -4081,108 +4081,108 @@ function $t({
4081
4081
  isStreaming: a,
4082
4082
  getMessages: i
4083
4083
  }) {
4084
- const [d, c] = $(null), f = Y(
4084
+ const [d, c] = D(null), f = Z(
4085
4085
  () => mt(d),
4086
4086
  [d]
4087
- ).checkpoints, p = Rr(f), g = p.timeline, [I, u] = $(!1), [v, x] = $(!1), [M, A] = $(!1), [w, b] = $(null), h = G(o), T = G(null), m = G(null);
4088
- X(() => {
4089
- h.current = o;
4087
+ ).checkpoints, p = Rr(f), g = p.timeline, [I, u] = D(!1), [v, x] = D(!1), [S, A] = D(!1), [w, b] = D(null), y = H(o), T = H(null), m = H(null);
4088
+ Y(() => {
4089
+ y.current = o;
4090
4090
  }, [o]);
4091
- const k = _(
4092
- async (P) => {
4093
- const B = await e.getState({
4094
- threadId: P.threadId,
4095
- checkpointId: P.checkpointId,
4096
- checkpointNs: P.checkpointNs
4097
- }), z = {
4091
+ const k = N(
4092
+ async (_) => {
4093
+ const O = await e.getState({
4094
+ threadId: _.threadId,
4095
+ checkpointId: _.checkpointId,
4096
+ checkpointNs: _.checkpointNs
4097
+ }), R = {
4098
4098
  version: "values@1",
4099
- threadId: P.threadId,
4100
- checkpoints: [B]
4101
- }, J = t ? await Mr(z, t) : z, { latest: U } = mt(J);
4102
- return U;
4099
+ threadId: _.threadId,
4100
+ checkpoints: [O]
4101
+ }, W = t ? await Mr(R, t) : R, { latest: B } = mt(W);
4102
+ return B;
4103
4103
  },
4104
4104
  [e, t]
4105
- ), E = _(
4106
- async (P, B) => {
4107
- var U;
4108
- if (!P) return;
4109
- const z = `${P}:${B ?? "latest"}`;
4110
- if (T.current === z || I) return;
4111
- (U = m.current) == null || U.abort();
4112
- const J = new AbortController();
4113
- m.current = J, u(!0), b(null);
4105
+ ), E = N(
4106
+ async (_, O) => {
4107
+ var B;
4108
+ if (!_) return;
4109
+ const R = `${_}:${O ?? "latest"}`;
4110
+ if (T.current === R || I) return;
4111
+ (B = m.current) == null || B.abort();
4112
+ const W = new AbortController();
4113
+ m.current = W, u(!0), b(null);
4114
4114
  try {
4115
- const R = await k({
4116
- threadId: P,
4117
- checkpointId: B ?? void 0
4115
+ const L = await k({
4116
+ threadId: _,
4117
+ checkpointId: O ?? void 0
4118
4118
  });
4119
- if (h.current !== P) {
4119
+ if (y.current !== _) {
4120
4120
  u(!1);
4121
4121
  return;
4122
4122
  }
4123
- n((R == null ? void 0 : R.messages) ?? [], {
4124
- checkpointId: (R == null ? void 0 : R.checkpointId) ?? null,
4125
- checkpointNs: (R == null ? void 0 : R.checkpointNs) ?? null,
4126
- pendingInterrupt: (R == null ? void 0 : R.interrupt) ?? null,
4127
- values: R == null ? void 0 : R.values
4128
- }), T.current = z, u(!1), A(!0);
4123
+ n((L == null ? void 0 : L.messages) ?? [], {
4124
+ checkpointId: (L == null ? void 0 : L.checkpointId) ?? null,
4125
+ checkpointNs: (L == null ? void 0 : L.checkpointNs) ?? null,
4126
+ pendingInterrupt: (L == null ? void 0 : L.interrupt) ?? null,
4127
+ values: L == null ? void 0 : L.values
4128
+ }), T.current = R, u(!1), A(!0);
4129
4129
  try {
4130
- const q = await e.getStateHistory({
4131
- threadId: P,
4130
+ const h = await e.getStateHistory({
4131
+ threadId: _,
4132
4132
  limit: 100,
4133
4133
  includeMessages: !1
4134
4134
  });
4135
- h.current === P && c(q);
4135
+ y.current === _ && c(h);
4136
4136
  } finally {
4137
4137
  A(!1);
4138
4138
  }
4139
- } catch (R) {
4140
- if (u(!1), !Xt(R)) {
4141
- const q = String(R);
4142
- b(q), r == null || r(q);
4139
+ } catch (L) {
4140
+ if (u(!1), !Xt(L)) {
4141
+ const h = String(L);
4142
+ b(h), r == null || r(h);
4143
4143
  }
4144
4144
  }
4145
4145
  },
4146
4146
  [e, n, k, r, i]
4147
- ), j = _(
4148
- async (P, B) => {
4147
+ ), U = N(
4148
+ async (_, O) => {
4149
4149
  if (o) {
4150
4150
  x(!0);
4151
4151
  try {
4152
- const z = await k({
4152
+ const R = await k({
4153
4153
  threadId: o,
4154
- checkpointId: P,
4155
- checkpointNs: B ?? void 0
4154
+ checkpointId: _,
4155
+ checkpointNs: O ?? void 0
4156
4156
  });
4157
- n((z == null ? void 0 : z.messages) ?? [], {
4158
- checkpointId: (z == null ? void 0 : z.checkpointId) ?? P,
4159
- checkpointNs: (z == null ? void 0 : z.checkpointNs) ?? B,
4160
- pendingInterrupt: (z == null ? void 0 : z.interrupt) ?? null,
4161
- values: z == null ? void 0 : z.values
4157
+ n((R == null ? void 0 : R.messages) ?? [], {
4158
+ checkpointId: (R == null ? void 0 : R.checkpointId) ?? _,
4159
+ checkpointNs: (R == null ? void 0 : R.checkpointNs) ?? O,
4160
+ pendingInterrupt: (R == null ? void 0 : R.interrupt) ?? null,
4161
+ values: R == null ? void 0 : R.values
4162
4162
  });
4163
- } catch (z) {
4164
- console.error("[useThreadHistoryState] Navigation failed", z);
4163
+ } catch (R) {
4164
+ console.error("[useThreadHistoryState] Navigation failed", R);
4165
4165
  } finally {
4166
4166
  x(!1);
4167
4167
  }
4168
4168
  }
4169
4169
  },
4170
4170
  [o, k, n]
4171
- ), C = _(async () => {
4171
+ ), M = N(async () => {
4172
4172
  o && await E(o);
4173
- }, [o, E]), O = _(
4174
- async (P) => {
4175
- const B = (P == null ? void 0 : P.threadId) || o;
4176
- !B || o !== B || (c(P), T.current = `${B}:latest`);
4173
+ }, [o, E]), $ = N(
4174
+ async (_) => {
4175
+ const O = (_ == null ? void 0 : _.threadId) || o;
4176
+ !O || o !== O || (c(_), T.current = `${O}:latest`);
4177
4177
  },
4178
4178
  [o]
4179
4179
  );
4180
- X(() => {
4180
+ Y(() => {
4181
4181
  if (!s || !o || I || a) return;
4182
- const P = `${o}:latest`;
4183
- T.current !== P && E(o);
4182
+ const _ = `${o}:latest`;
4183
+ T.current !== _ && E(o);
4184
4184
  }, [s, o, I, a, E]);
4185
- const F = _(() => {
4185
+ const F = N(() => {
4186
4186
  c(null), u(!1), x(!1), A(!1), b(null), T.current = null;
4187
4187
  }, []);
4188
4188
  return {
@@ -4191,15 +4191,15 @@ function $t({
4191
4191
  checkpointIndex: p,
4192
4192
  isLoadingThread: I,
4193
4193
  isLoadingCheckpoint: v,
4194
- isLoadingHistory: M,
4194
+ isLoadingHistory: S,
4195
4195
  threadStateError: w,
4196
4196
  loadThread: E,
4197
- navigateToCheckpoint: j,
4198
- setCurrentCheckpointId: (P, B) => {
4199
- n(i(), { checkpointId: P, checkpointNs: B });
4197
+ navigateToCheckpoint: U,
4198
+ setCurrentCheckpointId: (_, O) => {
4199
+ n(i(), { checkpointId: _, checkpointNs: O });
4200
4200
  },
4201
- returnToLatest: C,
4202
- handleValuesEvent: O,
4201
+ returnToLatest: M,
4202
+ handleValuesEvent: $,
4203
4203
  markSkipNextLoad: () => {
4204
4204
  },
4205
4205
  markStreamPendingThread: () => {
@@ -4208,14 +4208,14 @@ function $t({
4208
4208
  clearState: F
4209
4209
  };
4210
4210
  }
4211
- const Dt = Ee(null), Kt = Ee(null);
4211
+ const Dt = Ce(null), Kt = Ce(null);
4212
4212
  function Vt(e) {
4213
- const t = Ue(Dt);
4213
+ const t = je(Dt);
4214
4214
  if (!t && !(e != null && e.optional)) throw new Error("useThreadState must be used within a ThreadStateProvider");
4215
4215
  return t;
4216
4216
  }
4217
4217
  function Lr() {
4218
- const e = Ue(Kt);
4218
+ const e = je(Kt);
4219
4219
  if (!e)
4220
4220
  throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");
4221
4221
  return e;
@@ -4229,22 +4229,22 @@ function jr({
4229
4229
  isStreaming: s,
4230
4230
  onError: a
4231
4231
  }) {
4232
- const { chatApi: i, fileApi: d } = Ce(), { currentThreadId: c } = ot(), { state: l, seed: f, onEvent: p, dispatch: g } = kr(), {
4232
+ const { chatApi: i, fileApi: d } = Me(), { currentThreadId: c } = ot(), { state: l, seed: f, onEvent: p, dispatch: g } = kr(), {
4233
4233
  threadCheckpoints: I,
4234
4234
  threadTimeline: u,
4235
4235
  checkpointIndex: v,
4236
4236
  isLoadingThread: x,
4237
- isLoadingCheckpoint: M,
4237
+ isLoadingCheckpoint: S,
4238
4238
  isLoadingHistory: A,
4239
4239
  threadStateError: w,
4240
4240
  loadThread: b,
4241
- navigateToCheckpoint: h,
4241
+ navigateToCheckpoint: y,
4242
4242
  setCurrentCheckpointId: T,
4243
4243
  returnToLatest: m,
4244
4244
  handleValuesEvent: k,
4245
4245
  markSkipNextLoad: E,
4246
- markStreamPendingThread: j,
4247
- resetHistoryState: C
4246
+ markStreamPendingThread: U,
4247
+ resetHistoryState: M
4248
4248
  } = $t({
4249
4249
  api: i,
4250
4250
  fileApi: d,
@@ -4256,34 +4256,34 @@ function jr({
4256
4256
  initialCheckpointNs: r,
4257
4257
  autoLoadInitial: o,
4258
4258
  isStreaming: s,
4259
- getMessages: _(() => l.messages, [l.messages])
4260
- }), O = G(null), F = _(
4261
- (S) => {
4262
- O.current = S;
4259
+ getMessages: N(() => l.messages, [l.messages])
4260
+ }), $ = H(null), F = N(
4261
+ (P) => {
4262
+ $.current = P;
4263
4263
  },
4264
4264
  []
4265
- ), P = G(null), B = _(
4266
- (S) => {
4267
- P.current = S;
4265
+ ), _ = H(null), O = N(
4266
+ (P) => {
4267
+ _.current = P;
4268
4268
  },
4269
4269
  []
4270
- ), z = Y(() => ({ assemblingMessageId: l.assemblingId ?? null }), [l.assemblingId]), J = _(
4271
- (S, W) => {
4272
- const K = jt(S, "user");
4270
+ ), R = Z(() => ({ assemblingMessageId: l.assemblingId ?? null }), [l.assemblingId]), W = N(
4271
+ (P, J) => {
4272
+ const K = jt(P, "user");
4273
4273
  return g({
4274
4274
  type: "user_message",
4275
4275
  payload: {
4276
4276
  message: K,
4277
- editingMessageId: W == null ? void 0 : W.editingMessageId
4277
+ editingMessageId: J == null ? void 0 : J.editingMessageId
4278
4278
  }
4279
4279
  }), K;
4280
4280
  },
4281
4281
  [g]
4282
- ), U = _(async () => {
4283
- O.current ? await O.current() : (f([], {}), C());
4284
- }, [f, C]), R = _(async (S, W, K) => {
4285
- await b(S, W, { clearProgress: !1 });
4286
- }, [b]), q = Y(() => Bn(l.messages), [l.messages]), y = Y(
4282
+ ), B = N(async () => {
4283
+ $.current ? await $.current() : (f([], {}), M());
4284
+ }, [f, M]), L = N(async (P, J, K) => {
4285
+ await b(P, J, { clearProgress: !1 });
4286
+ }, [b]), h = Z(() => Bn(l.messages), [l.messages]), j = Z(
4287
4287
  () => ({
4288
4288
  status: l.status,
4289
4289
  threadId: c,
@@ -4297,40 +4297,40 @@ function jr({
4297
4297
  checkpoints: I,
4298
4298
  checkpointIndex: v,
4299
4299
  timelineCheckpoints: u,
4300
- metadata: z,
4300
+ metadata: R,
4301
4301
  values: l.values ?? {},
4302
4302
  isLoading: x,
4303
- isLoadingCheckpoint: M,
4303
+ isLoadingCheckpoint: S,
4304
4304
  isLoadingHistory: A,
4305
4305
  error: w,
4306
4306
  loadOlder: async () => {
4307
4307
  },
4308
4308
  // Placeholder
4309
- seedFromSnapshot: (S) => {
4310
- f(S.messages, {
4311
- checkpointId: S.checkpointId,
4312
- checkpointNs: S.checkpointNs,
4313
- pendingInterrupt: S.interrupt,
4314
- values: S.values
4309
+ seedFromSnapshot: (P) => {
4310
+ f(P.messages, {
4311
+ checkpointId: P.checkpointId,
4312
+ checkpointNs: P.checkpointNs,
4313
+ pendingInterrupt: P.interrupt,
4314
+ values: P.values
4315
4315
  });
4316
4316
  },
4317
- clearState: U,
4318
- navigateToCheckpoint: h,
4317
+ clearState: B,
4318
+ navigateToCheckpoint: y,
4319
4319
  setCurrentCheckpointId: T,
4320
4320
  returnToLatest: m,
4321
- loadThread: R,
4322
- clearThread: U,
4323
- respondToInterrupt: async (S, W, K) => {
4324
- P.current && await P.current(S, W, K);
4321
+ loadThread: L,
4322
+ clearThread: B,
4323
+ respondToInterrupt: async (P, J, K) => {
4324
+ _.current && await _.current(P, J, K);
4325
4325
  },
4326
4326
  messagePreviews: v.messagePreviews,
4327
4327
  handleValuesEvent: k,
4328
4328
  markSkipNextLoad: E,
4329
- markStreamPendingThread: j,
4330
- resetHistoryState: C,
4331
- pushUser: J,
4329
+ markStreamPendingThread: U,
4330
+ resetHistoryState: M,
4331
+ pushUser: W,
4332
4332
  onEvent: p,
4333
- artifacts: q
4333
+ artifacts: h
4334
4334
  }),
4335
4335
  [
4336
4336
  c,
@@ -4343,34 +4343,34 @@ function jr({
4343
4343
  I,
4344
4344
  u,
4345
4345
  v,
4346
- z,
4346
+ R,
4347
4347
  x,
4348
- M,
4348
+ S,
4349
4349
  A,
4350
4350
  w,
4351
4351
  f,
4352
- U,
4353
- h,
4352
+ B,
4353
+ y,
4354
4354
  T,
4355
4355
  m,
4356
- R,
4356
+ L,
4357
4357
  k,
4358
4358
  E,
4359
- j,
4360
- J,
4359
+ U,
4360
+ W,
4361
4361
  p,
4362
- q
4362
+ h
4363
4363
  ]
4364
- ), L = Y(
4364
+ ), C = Z(
4365
4365
  () => ({
4366
4366
  registerClearThread: F,
4367
- registerRespondToInterrupt: B
4367
+ registerRespondToInterrupt: O
4368
4368
  }),
4369
- [F, B]
4369
+ [F, O]
4370
4370
  );
4371
- return /* @__PURE__ */ ce(Kt.Provider, { value: L, children: /* @__PURE__ */ ce(Dt.Provider, { value: y, children: e }) });
4371
+ return /* @__PURE__ */ de(Kt.Provider, { value: C, children: /* @__PURE__ */ de(Dt.Provider, { value: j, children: e }) });
4372
4372
  }
4373
- const qt = Ee(null), Ur = Ee(!1);
4373
+ const qt = Ce(null), Ur = Ce(!1);
4374
4374
  function Br({
4375
4375
  children: e,
4376
4376
  onError: t,
@@ -4383,13 +4383,13 @@ function Br({
4383
4383
  onFinish: d,
4384
4384
  onStreamingChange: c
4385
4385
  }) {
4386
- const { chatApi: l, baseUrl: f } = Ce(), p = f, g = me(t), I = me(n), u = me(r), v = me(o), x = me(s), M = me(a), A = me(i), w = me(d), b = me(c), h = Y(
4386
+ const { chatApi: l, baseUrl: f } = Me(), p = f, g = ge(t), I = ge(n), u = ge(r), v = ge(o), x = ge(s), S = ge(a), A = ge(i), w = ge(d), b = ge(c), y = Z(
4387
4387
  () => ({
4388
4388
  onError: g,
4389
4389
  onAuthError: I,
4390
4390
  onConnectionError: u,
4391
4391
  onMetadataEvent: A,
4392
- onCustomEvent: M,
4392
+ onCustomEvent: S,
4393
4393
  onUpdateEvent: x,
4394
4394
  onToolEnd: v,
4395
4395
  onFinish: w
@@ -4399,18 +4399,18 @@ function Br({
4399
4399
  I,
4400
4400
  u,
4401
4401
  A,
4402
- M,
4402
+ S,
4403
4403
  x,
4404
4404
  v,
4405
4405
  w
4406
4406
  ]
4407
4407
  );
4408
- return /* @__PURE__ */ ce(Ur.Provider, { value: !0, children: /* @__PURE__ */ ce(
4408
+ return /* @__PURE__ */ de(Ur.Provider, { value: !0, children: /* @__PURE__ */ de(
4409
4409
  Fr,
4410
4410
  {
4411
4411
  api: l,
4412
4412
  streamBaseUrl: p,
4413
- handlers: h,
4413
+ handlers: y,
4414
4414
  onStreamingChange: b,
4415
4415
  children: e
4416
4416
  }
@@ -4433,18 +4433,18 @@ function Fr({
4433
4433
  resetHistoryState: u,
4434
4434
  pushUser: v,
4435
4435
  onEvent: x,
4436
- messages: M
4437
- } = Vt(), { registerClearThread: A, registerRespondToInterrupt: w } = Lr(), b = _(
4438
- (y) => {
4439
- i(y), I(y.threadId), a.current !== y.threadId && ((y.created ?? !a.current) && g(y.threadId), s(y.threadId));
4436
+ messages: S
4437
+ } = Vt(), { registerClearThread: A, registerRespondToInterrupt: w } = Lr(), b = N(
4438
+ (h) => {
4439
+ i(h), I(h.threadId), a.current !== h.threadId && ((h.created ?? !a.current) && g(h.threadId), s(h.threadId));
4440
4440
  },
4441
4441
  [i, g, I, s, a]
4442
- ), h = pr({
4442
+ ), y = pr({
4443
4443
  baseUrl: n,
4444
4444
  onEvent: x,
4445
- onError: (y) => {
4446
- var L;
4447
- (L = r.onError) == null || L.call(r, (y == null ? void 0 : y.message) ?? String(y));
4445
+ onError: (h) => {
4446
+ var j;
4447
+ (j = r.onError) == null || j.call(r, (h == null ? void 0 : h.message) ?? String(h));
4448
4448
  },
4449
4449
  onAuthError: r.onAuthError,
4450
4450
  onConnectionError: r.onConnectionError,
@@ -4456,137 +4456,147 @@ function Fr({
4456
4456
  onToolEnd: r.onToolEnd,
4457
4457
  handleValuesEvent: p
4458
4458
  });
4459
- X(() => {
4460
- o == null || o(h.isStreaming);
4461
- }, [h.isStreaming, o]);
4462
- const { stream: T, stop: m, clear: k, isStreaming: E, error: j, connected: C, streamedMessages: O, activeMessageId: F } = h;
4463
- X(() => {
4459
+ Y(() => {
4460
+ o == null || o(y.isStreaming);
4461
+ }, [y.isStreaming, o]);
4462
+ const { stream: T, stop: m, clear: k, isStreaming: E, error: U, connected: M, activeMessageId: $ } = y;
4463
+ Y(() => {
4464
4464
  d !== void 0 && k();
4465
4465
  }, [d, k]);
4466
- const P = _(
4467
- async (y, L) => {
4468
- await T(y, L);
4466
+ const F = N(
4467
+ async (h, j) => {
4468
+ await T(h, j);
4469
4469
  },
4470
4470
  [T]
4471
- ), B = G(l);
4472
- X(() => {
4473
- B.current = l;
4471
+ ), _ = H(l);
4472
+ Y(() => {
4473
+ _.current = l;
4474
4474
  }, [l]);
4475
- const z = _(
4476
- async (y, L, S) => {
4477
- var H;
4478
- const W = a.current;
4479
- if (!W)
4475
+ const O = N(
4476
+ async (h, j, C) => {
4477
+ var ye;
4478
+ const P = a.current;
4479
+ if (!P)
4480
4480
  throw new Error("No active thread to handle interrupt");
4481
- const K = y ? L ?? !0 : !1, V = B.current, ee = (S == null ? void 0 : S.checkpointId) ?? V.id ?? void 0, oe = (S == null ? void 0 : S.checkpointNs) ?? V.namespace ?? void 0, fe = {
4482
- threadId: W,
4483
- checkpointId: ee,
4484
- checkpointNs: oe,
4485
- command: { kind: "resume", value: K },
4481
+ const J = h ? j ?? !0 : !1, K = _.current, V = (C == null ? void 0 : C.checkpointId) ?? K.id ?? void 0, ee = (C == null ? void 0 : C.checkpointNs) ?? K.namespace ?? void 0, ie = {
4482
+ threadId: P,
4483
+ checkpointId: V,
4484
+ checkpointNs: ee,
4485
+ command: { kind: "resume", value: J },
4486
4486
  payload: {
4487
- ...(S == null ? void 0 : S.payload) ?? {},
4488
- creativityLevel: ((H = S == null ? void 0 : S.payload) == null ? void 0 : H.creativityLevel) ?? "medium"
4487
+ ...(C == null ? void 0 : C.payload) ?? {},
4488
+ creativityLevel: ((ye = C == null ? void 0 : C.payload) == null ? void 0 : ye.creativityLevel) ?? "medium"
4489
4489
  },
4490
4490
  edit: !1
4491
4491
  };
4492
- P(fe);
4492
+ F(ie);
4493
4493
  },
4494
- [a, P]
4494
+ [a, F]
4495
4495
  );
4496
- X(() => {
4497
- w(z);
4498
- }, [z, w]);
4499
- const J = _(async () => {
4496
+ Y(() => {
4497
+ w(O);
4498
+ }, [O, w]);
4499
+ const R = N(async () => {
4500
4500
  m(), k(), u(), s(null);
4501
4501
  }, [k, u, s, m]);
4502
- X(() => {
4503
- A(J);
4504
- }, [J, A]);
4505
- const U = _(
4506
- async (y, L) => {
4502
+ Y(() => {
4503
+ A(R);
4504
+ }, [R, A]);
4505
+ const W = N(
4506
+ async (h, j) => {
4507
4507
  E && m();
4508
- let S = a.current;
4509
- const W = (y == null ? void 0 : y.text) ?? "", K = (y == null ? void 0 : y.attachments) ?? [], V = (W == null ? void 0 : W.trim()) ?? "", ee = { ...(y == null ? void 0 : y.payload) ?? {} }, oe = Array.isArray(ee.messages) ? ee.messages : void 0;
4510
- oe && delete ee.messages;
4511
- const fe = !!(oe && oe.length), H = !!(y.contentParts && y.contentParts.length > 0);
4512
- if (!S && !V && K.length === 0 && !fe && !H) return;
4513
- if (!S) {
4514
- const re = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0"), le = Array.from({ length: 4 }, () => Math.floor(Math.random() * 4294967295).toString(16).padStart(8, "0")).join("").slice(0, 16);
4515
- S = `${re}${le}`, g(S), s(S);
4508
+ let C = a.current;
4509
+ const P = (h == null ? void 0 : h.text) ?? "", J = (h == null ? void 0 : h.attachments) ?? [], K = (P == null ? void 0 : P.trim()) ?? "", V = { ...(h == null ? void 0 : h.payload) ?? {} }, ee = Array.isArray(V.messages) ? V.messages : void 0;
4510
+ ee && delete V.messages;
4511
+ const ie = !!(ee && ee.length), ye = !!(h.contentParts && h.contentParts.length > 0);
4512
+ if (!C && !K && J.length === 0 && !ie && !ye) return;
4513
+ if (!C) {
4514
+ const re = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0"), te = Array.from({ length: 4 }, () => Math.floor(Math.random() * 4294967295).toString(16).padStart(8, "0")).join("").slice(0, 16);
4515
+ C = `${re}${te}`, g(C), s(C);
4516
4516
  }
4517
- let te = null;
4518
- y.contentParts && y.contentParts.length > 0 && (te = y.contentParts);
4519
- const { contentParts: ke, filesInfo: Q } = te ? { contentParts: te, filesInfo: [] } : await or(K), Z = [...ke];
4520
- V && Z.push({ type: "text", text: W });
4521
- const pe = y == null ? void 0 : y.originalMessageId, _e = !!(y != null && y.edit && pe), Be = !fe && Z.length > 0;
4522
- let he = null;
4523
- if (Be) {
4524
- const re = _e ? pe : `msg-${Date.now()}`;
4525
- he = jt({
4517
+ let G = null;
4518
+ h.contentParts && h.contentParts.length > 0 && (G = h.contentParts);
4519
+ const { contentParts: se, filesInfo: he } = G ? { contentParts: G, filesInfo: [] } : await or(J), X = [...se];
4520
+ K && X.push({ type: "text", text: P });
4521
+ const Q = h == null ? void 0 : h.originalMessageId, be = !!(h != null && h.edit && Q), Ve = !ie && X.length > 0;
4522
+ let we = null;
4523
+ if (Ve) {
4524
+ const re = be ? Q : `msg-${Date.now()}`;
4525
+ we = jt({
4526
4526
  id: re,
4527
4527
  role: "user",
4528
- content: Z,
4528
+ content: X,
4529
4529
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
4530
- }, "user"), _e ? v(he, { editingMessageId: pe }) : v(he);
4530
+ }, "user"), be ? v(we, { editingMessageId: Q }) : v(we);
4531
4531
  }
4532
- const xe = fe ? oe : he ? [he] : [], se = {
4533
- ...ee,
4534
- ...Q.length ? { files_info: Q } : {}
4532
+ const Pe = ie ? ee : we ? [we] : [], ke = {
4533
+ ...V,
4534
+ ...he.length ? { files_info: he } : {}
4535
4535
  };
4536
- xe.length ? se.messages = xe : "messages" in se || (se.messages = []);
4537
- let Ie = (y == null ? void 0 : y.checkpointId) ?? l.id ?? void 0;
4538
- if (_e && !Ie) {
4539
- const re = M.find((le) => le.id === pe);
4540
- re != null && re.checkpointId && (Ie = re.checkpointId);
4536
+ Pe.length ? ke.messages = Pe : "messages" in ke || (ke.messages = []);
4537
+ let ne = (h == null ? void 0 : h.checkpointId) ?? l.id ?? void 0;
4538
+ if (be) {
4539
+ const re = S.find((te) => te.id === Q);
4540
+ if (re)
4541
+ if (re.checkpointId)
4542
+ ne = re.checkpointId;
4543
+ else {
4544
+ const te = re.additionalKwargs || re.additional_kwargs || {}, ce = te.checkpoint_id || te.checkpointId;
4545
+ ce && (ne = ce);
4546
+ }
4547
+ if (!ne) {
4548
+ const te = S.findIndex((ce) => ce.id === Q);
4549
+ te > 0 && S[te - 1].checkpointId && (ne = S[te - 1].checkpointId ?? void 0);
4550
+ }
4541
4551
  }
4542
- if (y != null && y.edit && !Ie)
4552
+ if (h != null && h.edit && !ne)
4543
4553
  throw new Error(
4544
- `[streaming] Missing checkpointId for edit submit. threadId=${S ?? "null"}. Ensure you are editing a message that has been saved.`
4554
+ `[streaming] Missing checkpointId for edit submit. threadId=${C ?? "null"}. Ensure you are editing a message that has been saved.`
4545
4555
  );
4546
- const Ae = {
4547
- threadId: S,
4548
- content: y == null ? void 0 : y.text,
4549
- payload: se,
4550
- config: y == null ? void 0 : y.config,
4551
- checkpointId: Ie,
4552
- command: y == null ? void 0 : y.command,
4553
- edit: y == null ? void 0 : y.edit
4556
+ const Ue = {
4557
+ threadId: C,
4558
+ content: h == null ? void 0 : h.text,
4559
+ payload: ke,
4560
+ config: h == null ? void 0 : h.config,
4561
+ checkpointId: ne,
4562
+ command: h == null ? void 0 : h.command,
4563
+ edit: h == null ? void 0 : h.edit
4554
4564
  };
4555
- return P(Ae, L);
4565
+ return F(Ue, j);
4556
4566
  },
4557
- [l, a, E, g, v, P, m, f]
4558
- ), R = Y(() => M, [M]), q = Y(
4567
+ [l, a, E, g, v, F, m, f]
4568
+ ), B = Z(() => S, [S]), L = Z(
4559
4569
  () => ({
4560
4570
  isStreaming: E,
4561
- error: j,
4562
- connectionState: j ? "error" : E ? C ? "connected" : "connecting" : "idle",
4563
- messages: R,
4564
- activeMessageId: F,
4565
- submit: U,
4571
+ error: U,
4572
+ connectionState: U ? "error" : E ? M ? "connected" : "connecting" : "idle",
4573
+ messages: B,
4574
+ activeMessageId: $,
4575
+ submit: W,
4566
4576
  stop: m,
4567
4577
  interrupt: c,
4568
4578
  resume: () => Promise.resolve(),
4569
- goto: (y, L) => Promise.resolve(),
4579
+ goto: (h, j) => Promise.resolve(),
4570
4580
  clearError: () => {
4571
4581
  }
4572
4582
  // TODO: Implement error clearing
4573
4583
  }),
4574
- [E, j, U, m, c, C, R]
4584
+ [E, U, W, m, c, M, B]
4575
4585
  );
4576
- return /* @__PURE__ */ ce(qt.Provider, { value: q, children: e });
4586
+ return /* @__PURE__ */ de(qt.Provider, { value: L, children: e });
4577
4587
  }
4578
- function me(e) {
4579
- const t = G(e);
4580
- return X(() => {
4588
+ function ge(e) {
4589
+ const t = H(e);
4590
+ return Y(() => {
4581
4591
  t.current = e;
4582
- }, [e]), _((...n) => {
4592
+ }, [e]), N((...n) => {
4583
4593
  const r = t.current;
4584
4594
  if (r)
4585
4595
  return r(...n);
4586
4596
  }, []);
4587
4597
  }
4588
4598
  function Or(e) {
4589
- return Ue(qt);
4599
+ return je(qt);
4590
4600
  }
4591
4601
  function bt(e) {
4592
4602
  return typeof e == "object" && e !== null;
@@ -4603,7 +4613,7 @@ function $r(e, t) {
4603
4613
  return !0;
4604
4614
  }
4605
4615
  function Dr(e) {
4606
- const t = G(e), n = G(e);
4616
+ const t = H(e), n = H(e);
4607
4617
  return $r(t.current, e) || (t.current = e, n.current = e), n.current;
4608
4618
  }
4609
4619
  function Kr(e) {
@@ -4634,47 +4644,47 @@ function po({
4634
4644
  onMetadataEvent: g,
4635
4645
  onFinish: I
4636
4646
  }) {
4637
- const u = Dr(t), [v, x] = $(!1), M = ye(i), A = ye(d), w = ye(a), b = ye(c), h = ye(l), T = ye(f), m = ye(p), k = ye(g), E = ye(I), j = Y(
4647
+ const u = Dr(t), [v, x] = D(!1), S = me(i), A = me(d), w = me(a), b = me(c), y = me(l), T = me(f), m = me(p), k = me(g), E = me(I), U = Z(
4638
4648
  () => ({
4639
- onError: M,
4649
+ onError: S,
4640
4650
  onAuthError: A,
4641
4651
  onConnectionError: w,
4642
- onToolEnd: h,
4652
+ onToolEnd: y,
4643
4653
  onUpdateEvent: T,
4644
4654
  onCustomEvent: m,
4645
4655
  onMetadataEvent: k,
4646
4656
  onFinish: E
4647
4657
  }),
4648
4658
  [
4649
- M,
4659
+ S,
4650
4660
  A,
4651
4661
  w,
4652
- h,
4662
+ y,
4653
4663
  T,
4654
4664
  m,
4655
4665
  k,
4656
4666
  E
4657
4667
  ]
4658
4668
  );
4659
- return /* @__PURE__ */ ce(nr, { apiConfig: u, children: /* @__PURE__ */ ce(
4669
+ return /* @__PURE__ */ de(nr, { apiConfig: u, children: /* @__PURE__ */ de(
4660
4670
  mr,
4661
4671
  {
4662
4672
  initialThreadId: n,
4663
- onError: M,
4673
+ onError: S,
4664
4674
  onThreadChange: b,
4665
- children: /* @__PURE__ */ ce(
4675
+ children: /* @__PURE__ */ de(
4666
4676
  jr,
4667
4677
  {
4668
4678
  initialThreadId: n,
4669
4679
  initialCheckpointId: r,
4670
4680
  initialCheckpointNs: o,
4671
4681
  autoLoadInitial: s,
4672
- onError: M,
4682
+ onError: S,
4673
4683
  isStreaming: v,
4674
- children: /* @__PURE__ */ ce(
4684
+ children: /* @__PURE__ */ de(
4675
4685
  Br,
4676
4686
  {
4677
- ...j,
4687
+ ...U,
4678
4688
  onStreamingChange: x,
4679
4689
  children: e
4680
4690
  }
@@ -4684,9 +4694,9 @@ function po({
4684
4694
  }
4685
4695
  ) });
4686
4696
  }
4687
- function ye(e) {
4688
- const t = G(e);
4689
- return t.current = e, _((...n) => {
4697
+ function me(e) {
4698
+ const t = H(e);
4699
+ return t.current = e, N((...n) => {
4690
4700
  const r = t.current;
4691
4701
  if (r)
4692
4702
  return r(...n);
@@ -4701,7 +4711,7 @@ const Je = /* @__PURE__ */ new Map(), wt = (e) => {
4701
4711
  if (Je.has(e))
4702
4712
  return;
4703
4713
  const t = setTimeout(() => {
4704
- Je.delete(e), je({
4714
+ Je.delete(e), Le({
4705
4715
  type: "REMOVE_TOAST",
4706
4716
  toastId: e
4707
4717
  });
@@ -4744,19 +4754,19 @@ const Je = /* @__PURE__ */ new Map(), wt = (e) => {
4744
4754
  toasts: e.toasts.filter((n) => n.id !== t.toastId)
4745
4755
  };
4746
4756
  }
4747
- }, $e = [];
4748
- let De = { toasts: [] };
4749
- function je(e) {
4750
- De = Gr(De, e), $e.forEach((t) => {
4751
- t(De);
4757
+ }, Oe = [];
4758
+ let $e = { toasts: [] };
4759
+ function Le(e) {
4760
+ $e = Gr($e, e), Oe.forEach((t) => {
4761
+ t($e);
4752
4762
  });
4753
4763
  }
4754
4764
  function Wr({ ...e }) {
4755
- const t = Hr(), n = (o) => je({
4765
+ const t = Hr(), n = (o) => Le({
4756
4766
  type: "UPDATE_TOAST",
4757
4767
  toast: { ...o, id: t }
4758
- }), r = () => je({ type: "DISMISS_TOAST", toastId: t });
4759
- return je({
4768
+ }), r = () => Le({ type: "DISMISS_TOAST", toastId: t });
4769
+ return Le({
4760
4770
  type: "ADD_TOAST",
4761
4771
  toast: {
4762
4772
  ...e,
@@ -4773,24 +4783,24 @@ function Wr({ ...e }) {
4773
4783
  };
4774
4784
  }
4775
4785
  function Jr() {
4776
- const [e, t] = it.useState(De);
4777
- return it.useEffect(() => ($e.push(t), () => {
4778
- const n = $e.indexOf(t);
4779
- n > -1 && $e.splice(n, 1);
4786
+ const [e, t] = it.useState($e);
4787
+ return it.useEffect(() => (Oe.push(t), () => {
4788
+ const n = Oe.indexOf(t);
4789
+ n > -1 && Oe.splice(n, 1);
4780
4790
  }), [e]), {
4781
4791
  ...e,
4782
4792
  toast: Wr,
4783
- dismiss: (n) => je({ type: "DISMISS_TOAST", toastId: n })
4793
+ dismiss: (n) => Le({ type: "DISMISS_TOAST", toastId: n })
4784
4794
  };
4785
4795
  }
4786
4796
  function go(e) {
4787
- const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Ce(), { toast: o } = Jr(), [s, a] = $({}), [i, d] = $(null), [c, l] = $(!1), f = _(() => {
4797
+ const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Me(), { toast: o } = Jr(), [s, a] = D({}), [i, d] = D(null), [c, l] = D(!1), f = N(() => {
4788
4798
  l(!1), d(null);
4789
- }, []), p = _((I) => {
4799
+ }, []), p = N((I) => {
4790
4800
  d(I), l(!0);
4791
- }, []), g = _(
4801
+ }, []), g = N(
4792
4802
  async (I, u, v) => {
4793
- var x, M;
4803
+ var x, S;
4794
4804
  if (!t) {
4795
4805
  I.preventDefault();
4796
4806
  return;
@@ -4803,18 +4813,18 @@ function go(e) {
4803
4813
  const A = String(u.url ?? ""), w = A.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);
4804
4814
  if (w) {
4805
4815
  I.preventDefault();
4806
- const b = w[1], h = u.name || `file_${b}`, T = u.mimeType || "application/octet-stream";
4807
- p({ id: b, name: h, mimeType: T });
4816
+ const b = w[1], y = u.name || `file_${b}`, T = u.mimeType || "application/octet-stream";
4817
+ p({ id: b, name: y, mimeType: T });
4808
4818
  return;
4809
4819
  }
4810
4820
  if (A.startsWith("data:")) {
4811
- I.preventDefault(), a((h) => ({ ...h, [v]: !0 }));
4821
+ I.preventDefault(), a((y) => ({ ...y, [v]: !0 }));
4812
4822
  const b = o({ title: "Fetching file...", description: "", open: !0 });
4813
4823
  try {
4814
- const h = await r.listFiles(n ?? void 0);
4815
- if (!h || !Array.isArray(h))
4824
+ const y = await r.listFiles(n ?? void 0);
4825
+ if (!y || !Array.isArray(y))
4816
4826
  throw new Error("Invalid file list response");
4817
- const T = h.find((m) => !m || typeof m != "object" || !((m.filename ?? "") === (u.name ?? "")) ? !1 : typeof u.size == "number" && typeof m.size == "number" ? m.size === u.size : !0);
4827
+ const T = y.find((m) => !m || typeof m != "object" || !((m.filename ?? "") === (u.name ?? "")) ? !1 : typeof u.size == "number" && typeof m.size == "number" ? m.size === u.size : !0);
4818
4828
  if (!(T != null && T.id))
4819
4829
  throw new Error(`File "${u.name}" is not yet available on the server`);
4820
4830
  if (!T.id || !T.filename)
@@ -4829,16 +4839,16 @@ function go(e) {
4829
4839
  description: `Opened ${u.name}`,
4830
4840
  open: !0
4831
4841
  });
4832
- } catch (h) {
4833
- console.error("Failed to fetch server file:", h);
4834
- const T = h instanceof Error ? h.message : "Unknown error occurred";
4835
- (M = b.update) == null || M.call(b, { id: b.id, title: "Failed", description: T }), o({
4842
+ } catch (y) {
4843
+ console.error("Failed to fetch server file:", y);
4844
+ const T = y instanceof Error ? y.message : "Unknown error occurred";
4845
+ (S = b.update) == null || S.call(b, { id: b.id, title: "Failed", description: T }), o({
4836
4846
  title: "Failed to fetch file",
4837
4847
  description: T,
4838
4848
  open: !0
4839
4849
  });
4840
4850
  } finally {
4841
- a((h) => ({ ...h, [v]: !1 }));
4851
+ a((y) => ({ ...y, [v]: !1 }));
4842
4852
  }
4843
4853
  }
4844
4854
  } catch (A) {
@@ -4856,7 +4866,7 @@ function go(e) {
4856
4866
  };
4857
4867
  }
4858
4868
  function mo(e) {
4859
- return Y(() => {
4869
+ return Z(() => {
4860
4870
  const t = e;
4861
4871
  let n = Array.isArray(t.content) ? t.content : [];
4862
4872
  return typeof t.content == "string" && (n = [{ type: "text", text: t.content }]), {
@@ -4895,7 +4905,7 @@ function Qr(e) {
4895
4905
  return null;
4896
4906
  }
4897
4907
  function yo(e) {
4898
- return Y(() => {
4908
+ return Z(() => {
4899
4909
  const t = e.content.filter(
4900
4910
  (d) => d.type === "text"
4901
4911
  );
@@ -4914,7 +4924,7 @@ function yo(e) {
4914
4924
  const s = Qr(r) ?? r[r.length - 1];
4915
4925
  if (!s)
4916
4926
  return null;
4917
- const a = s.output ?? s.payload ?? s, i = de(a);
4927
+ const a = s.output ?? s.payload ?? s, i = ue(a);
4918
4928
  return i && typeof i == "object" && !Array.isArray(i) ? {
4919
4929
  kind: "dict",
4920
4930
  value: i,
@@ -4928,13 +4938,13 @@ function yo(e) {
4928
4938
  }, [e]);
4929
4939
  }
4930
4940
  function Yr(e) {
4931
- var C, O;
4941
+ var M, $;
4932
4942
  const t = typeof e == "string" ? e : e == null ? void 0 : e.threadId, n = typeof e == "object" ? e.lazy : !1, r = ot({ optional: !0 }), o = Vt({ optional: !0 }), s = Or(), { currentThreadId: a, setCurrentThreadId: i, actions: d } = r || {
4933
4943
  currentThreadId: null,
4934
4944
  setCurrentThreadId: () => {
4935
4945
  },
4936
4946
  actions: {}
4937
- }, c = !!t && t !== a, [l, f] = $([]), p = _((F) => {
4947
+ }, c = !!t && t !== a, [l, f] = D([]), p = N((F) => {
4938
4948
  f(F);
4939
4949
  }, []), {
4940
4950
  isLoadingThread: g,
@@ -4943,8 +4953,8 @@ function Yr(e) {
4943
4953
  isLoadingHistory: v,
4944
4954
  loadThread: x
4945
4955
  } = $t({
4946
- api: Ce().chatApi,
4947
- fileApi: Ce().fileApi,
4956
+ api: Me().chatApi,
4957
+ fileApi: Me().fileApi,
4948
4958
  seed: p,
4949
4959
  currentThreadId: c ? t : null,
4950
4960
  initialThreadId: c ? t : null,
@@ -4952,21 +4962,21 @@ function Yr(e) {
4952
4962
  getMessages: () => l,
4953
4963
  autoLoadInitial: c && !n
4954
4964
  });
4955
- X(() => {
4965
+ Y(() => {
4956
4966
  !c && !n && a && (o != null && o.loadThread) && o.loadThread(a);
4957
4967
  }, [c, n, a, o == null ? void 0 : o.loadThread]);
4958
- const M = Y(() => {
4968
+ const S = Z(() => {
4959
4969
  var F;
4960
4970
  return ((F = u[0]) == null ? void 0 : F.values) || {};
4961
- }, [u]), A = Y(() => ({ timeline: [], messagePreviews: {} }), []), w = t || a, b = c ? g ? "loading" : "idle" : (o == null ? void 0 : o.status) || "idle", h = c ? l : (s == null ? void 0 : s.messages) || [], T = c ? g : (o == null ? void 0 : o.isLoading) || !1, m = c ? v : (o == null ? void 0 : o.isLoadingHistory) || !1, k = c ? M : (o == null ? void 0 : o.values) || {}, E = c ? {} : (o == null ? void 0 : o.taskMessagesByScope) || {}, j = c ? I : (s == null ? void 0 : s.error) || (o == null ? void 0 : o.error) || null;
4971
+ }, [u]), A = Z(() => ({ timeline: [], messagePreviews: {} }), []), w = t || a, b = c ? g ? "loading" : "idle" : (o == null ? void 0 : o.status) || "idle", y = c ? l : (s == null ? void 0 : s.messages) || [], T = c ? g : (o == null ? void 0 : o.isLoading) || !1, m = c ? v : (o == null ? void 0 : o.isLoadingHistory) || !1, k = c ? S : (o == null ? void 0 : o.values) || {}, E = c ? {} : (o == null ? void 0 : o.taskMessagesByScope) || {}, U = c ? I : (s == null ? void 0 : s.error) || (o == null ? void 0 : o.error) || null;
4962
4972
  return {
4963
4973
  // UNIFIED: Single thread ID concept
4964
4974
  threadId: w,
4965
4975
  status: b,
4966
- messages: h,
4976
+ messages: y,
4967
4977
  isLoading: T,
4968
4978
  isHistoryLoading: m,
4969
- error: j,
4979
+ error: U,
4970
4980
  // Values & Metadata
4971
4981
  values: k,
4972
4982
  taskMessagesByScope: E,
@@ -4988,9 +4998,9 @@ function Yr(e) {
4988
4998
  // Streaming Status
4989
4999
  // Even in standalone mode, allow streaming state/stop if a stream context exists.
4990
5000
  isStreaming: (s == null ? void 0 : s.isStreaming) || !1,
4991
- activeMessageId: c ? null : ((C = o == null ? void 0 : o.metadata) == null ? void 0 : C.assemblingMessageId) || (s == null ? void 0 : s.activeMessageId) || null,
5001
+ activeMessageId: c ? null : ((M = o == null ? void 0 : o.metadata) == null ? void 0 : M.assemblingMessageId) || (s == null ? void 0 : s.activeMessageId) || null,
4992
5002
  connectionState: (s == null ? void 0 : s.connectionState) || "disconnected",
4993
- streamingAssistantId: !c && (s != null && s.isStreaming) && ((O = o == null ? void 0 : o.metadata) != null && O.assemblingMessageId) ? o.metadata.assemblingMessageId : null,
5003
+ streamingAssistantId: !c && (s != null && s.isStreaming) && (($ = o == null ? void 0 : o.metadata) != null && $.assemblingMessageId) ? o.metadata.assemblingMessageId : null,
4994
5004
  // Actions
4995
5005
  submit: (s == null ? void 0 : s.submit) || (async () => {
4996
5006
  }),
@@ -5031,82 +5041,82 @@ function ho({
5031
5041
  threadId: p,
5032
5042
  clearComposerOnSend: g = !0
5033
5043
  }) {
5034
- const { messages: I } = Yr(), [u, v] = $(null), [x, M] = $(""), [A, w] = $(null), [b, h] = $(null), [T, m] = $(!1), [k, E] = $(""), j = G(k), C = G(null);
5035
- X(() => {
5044
+ const { messages: I } = Yr(), [u, v] = D(null), [x, S] = D(""), [A, w] = D(null), [b, y] = D(null), [T, m] = D(!1), [k, E] = D(""), U = H(k), M = H(null);
5045
+ Y(() => {
5036
5046
  if (!u)
5037
5047
  if (p) {
5038
- const y = localStorage.getItem(Ge(p));
5039
- E(y || "");
5048
+ const j = localStorage.getItem(Ge(p));
5049
+ E(j || "");
5040
5050
  } else
5041
5051
  E("");
5042
5052
  }, [p, u]);
5043
- const O = _((y) => {
5044
- E(y), !u && p && localStorage.setItem(Ge(p), y);
5053
+ const $ = N((j) => {
5054
+ E(j), !u && p && localStorage.setItem(Ge(p), j);
5045
5055
  }, [p, u]);
5046
- X(() => {
5047
- j.current = k;
5048
- }, [k]), X(() => {
5056
+ Y(() => {
5057
+ U.current = k;
5058
+ }, [k]), Y(() => {
5049
5059
  if (!u) {
5050
- C.current = null;
5060
+ M.current = null;
5051
5061
  return;
5052
5062
  }
5053
- C.current === null && (C.current = j.current), O(x ?? "");
5054
- }, [x, u, O]);
5055
- const F = _(
5056
- (y) => {
5057
- O(y);
5063
+ M.current === null && (M.current = U.current), $(x ?? "");
5064
+ }, [x, u, $]);
5065
+ const F = N(
5066
+ (j) => {
5067
+ $(j);
5058
5068
  },
5059
- [O]
5060
- ), P = async (y, L) => {
5061
- const S = Array.isArray(L) ? { files: L } : L ?? {}, W = S.files ?? [], K = S.contentParts ?? [], V = y.trim();
5062
- if (!(!V && W.length === 0 && K.length === 0))
5069
+ [$]
5070
+ ), _ = async (j, C) => {
5071
+ const P = Array.isArray(C) ? { files: C } : C ?? {}, J = P.files ?? [], K = P.contentParts ?? [], V = j.trim();
5072
+ if (!(!V && J.length === 0 && K.length === 0))
5063
5073
  try {
5064
- const ee = W.map(async (Q) => {
5074
+ const ee = J.map(async (X) => {
5065
5075
  try {
5066
- const Z = await Rt.uploadFile(Q);
5067
- return { file: Q, record: Z };
5068
- } catch (Z) {
5069
- throw console.error("Failed to upload file", Q.name, Z), new Error(`Failed to upload ${Q.name}`);
5076
+ const Q = await Rt.uploadFile(X);
5077
+ return { file: X, record: Q };
5078
+ } catch (Q) {
5079
+ throw console.error("Failed to upload file", X.name, Q), new Error(`Failed to upload ${X.name}`);
5070
5080
  }
5071
- }), fe = (await Promise.all(ee)).map(({ record: Q }) => {
5072
- const Z = Q.mime_type;
5073
- return Z.startsWith("image/") ? {
5081
+ }), ye = (await Promise.all(ee)).map(({ record: X }) => {
5082
+ const Q = X.mime_type;
5083
+ return Q.startsWith("image/") ? {
5074
5084
  type: "image_url",
5075
- image_url: { url: Q.content_url }
5085
+ image_url: { url: X.content_url }
5076
5086
  } : {
5077
5087
  type: "file",
5078
- url: Q.content_url,
5079
- mimeType: Z,
5080
- name: Q.filename,
5081
- size: Q.size
5088
+ url: X.content_url,
5089
+ mimeType: Q,
5090
+ name: X.filename,
5091
+ size: X.size
5082
5092
  };
5083
- }), H = [...K, ...fe], te = u ? (A == null ? void 0 : A.checkpointId) ?? n ?? void 0 : n ?? void 0, ke = u ? (A == null ? void 0 : A.checkpointNs) ?? r ?? void 0 : r ?? void 0;
5093
+ }), G = [...K, ...ye], se = u ? (A == null ? void 0 : A.checkpointId) ?? n ?? void 0 : n ?? void 0, he = u ? (A == null ? void 0 : A.checkpointNs) ?? r ?? void 0 : r ?? void 0;
5084
5094
  await e(
5085
5095
  {
5086
5096
  text: V || "",
5087
- contentParts: H,
5088
- attachments: W,
5097
+ contentParts: G,
5098
+ attachments: J,
5089
5099
  payload: t.payload,
5090
5100
  edit: !!u,
5091
- checkpointId: te,
5092
- checkpointNs: ke,
5101
+ checkpointId: se,
5102
+ checkpointNs: he,
5093
5103
  project: l ?? void 0,
5094
5104
  originalMessageId: u ?? void 0,
5095
5105
  config: t.config
5096
5106
  },
5097
5107
  f ? { onEvent: f } : void 0
5098
- ), o == null || o(V), c(!0), g && (p && localStorage.removeItem(Ge(p)), O("")), h(null), v(null), M(""), w(null);
5108
+ ), o == null || o(V), c(!0), g && (p && localStorage.removeItem(Ge(p)), $("")), y(null), v(null), S(""), w(null);
5099
5109
  } catch (ee) {
5100
- const oe = (ee == null ? void 0 : ee.message) || "Failed to send message";
5101
- h(oe), a == null || a(oe), c(!1);
5110
+ const ie = (ee == null ? void 0 : ee.message) || "Failed to send message";
5111
+ y(ie), a == null || a(ie), c(!1);
5102
5112
  }
5103
- }, B = (y, L) => {
5104
- L || P(y, { files: [] });
5105
- }, z = _(
5106
- async (y) => {
5113
+ }, O = (j, C) => {
5114
+ C || _(j, { files: [] });
5115
+ }, R = N(
5116
+ async (j) => {
5107
5117
  await e(
5108
5118
  {
5109
- attachments: [y],
5119
+ attachments: [j],
5110
5120
  payload: t.payload,
5111
5121
  checkpointId: n ?? void 0,
5112
5122
  checkpointNs: r ?? void 0,
@@ -5114,34 +5124,34 @@ function ho({
5114
5124
  config: t.config
5115
5125
  },
5116
5126
  f ? { onEvent: f } : void 0
5117
- ), s == null || s({ file: y });
5127
+ ), s == null || s({ file: j });
5118
5128
  },
5119
5129
  [n, r, t, s, e]
5120
- ), J = _(
5121
- (y, L, S) => {
5122
- i && (C.current = k, v(y), M(L), w({
5123
- checkpointId: (S == null ? void 0 : S.checkpointId) ?? null,
5124
- checkpointNs: (S == null ? void 0 : S.checkpointNs) ?? null
5125
- }), h(null));
5130
+ ), W = N(
5131
+ (j, C, P) => {
5132
+ i && (M.current = k, v(j), S(C), w({
5133
+ checkpointId: (P == null ? void 0 : P.checkpointId) ?? null,
5134
+ checkpointNs: (P == null ? void 0 : P.checkpointNs) ?? null
5135
+ }), y(null));
5126
5136
  },
5127
5137
  [k, i]
5128
- ), U = _(() => {
5129
- v(null), M(""), w(null), h(null);
5130
- const y = C.current;
5131
- y !== null && E(y), C.current = null;
5132
- }, []), R = _((y) => {
5133
- let L = null;
5134
- for (let V = y - 1; V >= 0; V--)
5138
+ ), B = N(() => {
5139
+ v(null), S(""), w(null), y(null);
5140
+ const j = M.current;
5141
+ j !== null && E(j), M.current = null;
5142
+ }, []), L = N((j) => {
5143
+ let C = null;
5144
+ for (let V = j - 1; V >= 0; V--)
5135
5145
  if (d[V].role === "user") {
5136
- L = d[V];
5146
+ C = d[V];
5137
5147
  break;
5138
5148
  }
5139
- if (!L) return;
5140
- const S = Array.isArray(L.content) ? L.content : [], K = S.filter((V) => (V == null ? void 0 : V.type) === "text").map((V) => V.text).join("") || (() => {
5149
+ if (!C) return;
5150
+ const P = Array.isArray(C.content) ? C.content : [], K = P.filter((V) => (V == null ? void 0 : V.type) === "text").map((V) => V.text).join("") || (() => {
5141
5151
  try {
5142
- return JSON.stringify(S, null, 2);
5152
+ return JSON.stringify(P, null, 2);
5143
5153
  } catch {
5144
- return String(S);
5154
+ return String(P);
5145
5155
  }
5146
5156
  })();
5147
5157
  K && e(
@@ -5151,7 +5161,7 @@ function ho({
5151
5161
  checkpointId: n ?? void 0,
5152
5162
  checkpointNs: r ?? void 0,
5153
5163
  edit: !0,
5154
- originalMessageId: L.id,
5164
+ originalMessageId: C.id,
5155
5165
  config: t.config
5156
5166
  },
5157
5167
  f ? { onEvent: f } : void 0
@@ -5161,22 +5171,22 @@ function ho({
5161
5171
  editingMessageId: u,
5162
5172
  editingInitialValue: x,
5163
5173
  inputError: b,
5164
- setInputError: h,
5174
+ setInputError: y,
5165
5175
  dismissError: T,
5166
5176
  setDismissError: m,
5167
5177
  composerValue: k,
5168
5178
  handleComposerChange: F,
5169
- handleSendMessage: P,
5170
- handleQuickPrompt: B,
5171
- handleExcelUpload: z,
5172
- startEditing: J,
5173
- cancelEditing: U,
5174
- handleRegenerateCb: R,
5179
+ handleSendMessage: _,
5180
+ handleQuickPrompt: O,
5181
+ handleExcelUpload: R,
5182
+ startEditing: W,
5183
+ cancelEditing: B,
5184
+ handleRegenerateCb: L,
5175
5185
  displayMessages: I
5176
5186
  };
5177
5187
  }
5178
5188
  function bo(e) {
5179
- return Y(() => e ? {
5189
+ return Z(() => e ? {
5180
5190
  textContent: Ln(e),
5181
5191
  imageParts: jn(e),
5182
5192
  fileParts: Un(e),
@@ -5191,8 +5201,8 @@ function bo(e) {
5191
5201
  }, [e]);
5192
5202
  }
5193
5203
  function wo(e, t, n) {
5194
- const [r, o] = $(e), s = G(e), a = G(null);
5195
- return X(() => {
5204
+ const [r, o] = D(e), s = H(e), a = H(null);
5205
+ return Y(() => {
5196
5206
  s.current = e;
5197
5207
  const i = () => {
5198
5208
  o(s.current), a.current && (clearTimeout(a.current), a.current = null);
@@ -5233,10 +5243,10 @@ export {
5233
5243
  tt as parseJsonSafe,
5234
5244
  Et as pretty,
5235
5245
  Mr as refreshHistoryFileUrls,
5236
- Ke as sanitizeForDisplay,
5237
- ve as setChatToken,
5246
+ De as sanitizeForDisplay,
5247
+ xe as setChatToken,
5238
5248
  Fn as stringifyTool,
5239
- Ce as useApi,
5249
+ Me as useApi,
5240
5250
  ho as useChatController,
5241
5251
  Yr as useChatSession,
5242
5252
  go as useFilePreview,