@teodorruskvi/chat-core 0.1.49 → 0.1.50

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
@@ -128,23 +128,23 @@ const et = "-", Yt = (e) => {
128
128
  const u = [];
129
129
  let c = 0, l = 0, d;
130
130
  for (let I = 0; I < i.length; I++) {
131
- let p = i[I];
131
+ let A = i[I];
132
132
  if (c === 0) {
133
- if (p === o && (r || i.slice(I, I + s) === t)) {
133
+ if (A === o && (r || i.slice(I, I + s) === t)) {
134
134
  u.push(i.slice(l, I)), l = I + s;
135
135
  continue;
136
136
  }
137
- if (p === "/") {
137
+ if (A === "/") {
138
138
  d = I;
139
139
  continue;
140
140
  }
141
141
  }
142
- p === "[" ? c++ : p === "]" && c--;
142
+ A === "[" ? c++ : A === "]" && c--;
143
143
  }
144
- const m = u.length === 0 ? i : i.substring(l), y = m.startsWith(At), v = y ? m.substring(1) : m, f = d && d > l ? d - l : void 0;
144
+ const g = u.length === 0 ? i : i.substring(l), m = g.startsWith(At), v = m ? g.substring(1) : g, f = d && d > l ? d - l : void 0;
145
145
  return {
146
146
  modifiers: u,
147
- hasImportantModifier: y,
147
+ hasImportantModifier: m,
148
148
  baseClassName: v,
149
149
  maybePostfixModifierPosition: f
150
150
  };
@@ -176,29 +176,29 @@ const et = "-", Yt = (e) => {
176
176
  const c = a[u], {
177
177
  modifiers: l,
178
178
  hasImportantModifier: d,
179
- baseClassName: m,
180
- maybePostfixModifierPosition: y
179
+ baseClassName: g,
180
+ maybePostfixModifierPosition: m
181
181
  } = n(c);
182
- let v = !!y, f = r(v ? m.substring(0, y) : m);
182
+ let v = !!m, f = r(v ? g.substring(0, m) : g);
183
183
  if (!f) {
184
184
  if (!v) {
185
185
  i = c + (i.length > 0 ? " " + i : i);
186
186
  continue;
187
187
  }
188
- if (f = r(m), !f) {
188
+ if (f = r(g), !f) {
189
189
  i = c + (i.length > 0 ? " " + i : i);
190
190
  continue;
191
191
  }
192
192
  v = !1;
193
193
  }
194
- const I = sn(l).join(":"), p = d ? I + At : I, S = p + f;
195
- if (s.includes(S))
194
+ const I = sn(l).join(":"), A = d ? I + At : I, M = A + f;
195
+ if (s.includes(M))
196
196
  continue;
197
- s.push(S);
197
+ s.push(M);
198
198
  const x = o(f, v);
199
- for (let E = 0; E < x.length; ++E) {
200
- const k = x[E];
201
- s.push(p + k);
199
+ for (let k = 0; k < x.length; ++k) {
200
+ const b = x[k];
201
+ s.push(A + b);
202
202
  }
203
203
  i = c + (i.length > 0 ? " " + i : i);
204
204
  }
@@ -238,7 +238,7 @@ function dn(e, ...t) {
238
238
  const D = (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)\(.+\)$/, de = (e) => Te(e) || pn.has(e) || fn.test(e), be = (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)), R = (e) => Tt.test(e), we = (e) => gn.test(e), kn = /* @__PURE__ */ new Set(["length", "size", "percentage"]), vn = (e) => Ee(e, kn, St), In = (e) => Ee(e, "position", St), An = /* @__PURE__ */ new Set(["image", "url"]), xn = (e) => Ee(e, An, Cn), Tn = (e) => Ee(e, "", Mn), Ne = () => !0, Ee = (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)\(.+\)$/, de = (e) => Te(e) || pn.has(e) || fn.test(e), be = (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)), R = (e) => Tt.test(e), we = (e) => gn.test(e), kn = /* @__PURE__ */ new Set(["length", "size", "percentage"]), vn = (e) => Ee(e, kn, St), In = (e) => Ee(e, "position", St), An = /* @__PURE__ */ new Set(["image", "url"]), xn = (e) => Ee(e, An, Cn), Tn = (e) => Ee(e, "", Mn), ze = () => !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"), u = D("contrast"), c = D("grayscale"), l = D("hueRotate"), d = D("invert"), m = D("gap"), y = D("gradientColorStops"), v = D("gradientColorStopPositions"), f = D("inset"), I = D("margin"), p = D("opacity"), S = D("padding"), x = D("saturate"), E = D("scale"), k = D("sepia"), b = D("skew"), A = D("space"), g = D("translate"), w = () => ["auto", "contain", "none"], P = () => ["auto", "hidden", "clip", "visible", "scroll"], j = () => ["auto", R, t], M = () => [R, t], O = () => ["", de, be], F = () => ["auto", Te, R], C = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], B = () => ["solid", "dashed", "dotted", "double", "none"], N = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], K = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], z = () => ["", "0", R], L = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], H = () => [Te, R];
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"), u = D("contrast"), c = D("grayscale"), l = D("hueRotate"), d = D("invert"), g = D("gap"), m = D("gradientColorStops"), v = D("gradientColorStopPositions"), f = D("inset"), I = D("margin"), A = D("opacity"), M = D("padding"), x = D("saturate"), k = D("scale"), b = D("sepia"), h = D("skew"), T = D("space"), p = D("translate"), w = () => ["auto", "contain", "none"], P = () => ["auto", "hidden", "clip", "visible", "scroll"], j = () => ["auto", R, t], C = () => [R, t], O = () => ["", de, be], F = () => ["auto", Te, R], E = () => ["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"], K = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], N = () => ["", "0", R], L = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], H = () => [Te, R];
251
251
  return {
252
252
  cacheSize: 500,
253
253
  separator: ":",
254
254
  theme: {
255
- colors: [Ne],
255
+ colors: [ze],
256
256
  spacing: [de, be],
257
257
  blur: ["none", "", we, R],
258
258
  brightness: H(),
259
259
  borderColor: [e],
260
260
  borderRadius: ["none", "", "full", we, R],
261
- borderSpacing: M(),
261
+ borderSpacing: C(),
262
262
  borderWidth: O(),
263
263
  contrast: H(),
264
- grayscale: z(),
264
+ grayscale: N(),
265
265
  hueRotate: H(),
266
- invert: z(),
267
- gap: M(),
266
+ invert: N(),
267
+ gap: C(),
268
268
  gradientColorStops: [e],
269
269
  gradientColorStopPositions: [wn, be],
270
270
  inset: j(),
271
271
  margin: j(),
272
272
  opacity: H(),
273
- padding: M(),
273
+ padding: C(),
274
274
  saturate: H(),
275
275
  scale: H(),
276
- sepia: z(),
276
+ sepia: N(),
277
277
  skew: H(),
278
- space: M(),
279
- translate: M()
278
+ space: C(),
279
+ translate: C()
280
280
  },
281
281
  classGroups: {
282
282
  // Layout
@@ -370,7 +370,7 @@ const D = (e) => {
370
370
  * @see https://tailwindcss.com/docs/object-position
371
371
  */
372
372
  "object-position": [{
373
- object: [...C(), R]
373
+ object: [...E(), R]
374
374
  }],
375
375
  /**
376
376
  * Overflow
@@ -528,14 +528,14 @@ const D = (e) => {
528
528
  * @see https://tailwindcss.com/docs/flex-grow
529
529
  */
530
530
  grow: [{
531
- grow: z()
531
+ grow: N()
532
532
  }],
533
533
  /**
534
534
  * Flex Shrink
535
535
  * @see https://tailwindcss.com/docs/flex-shrink
536
536
  */
537
537
  shrink: [{
538
- shrink: z()
538
+ shrink: N()
539
539
  }],
540
540
  /**
541
541
  * Order
@@ -549,7 +549,7 @@ const D = (e) => {
549
549
  * @see https://tailwindcss.com/docs/grid-template-columns
550
550
  */
551
551
  "grid-cols": [{
552
- "grid-cols": [Ne]
552
+ "grid-cols": [ze]
553
553
  }],
554
554
  /**
555
555
  * Grid Column Start / End
@@ -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": [Ne]
582
+ "grid-rows": [ze]
583
583
  }],
584
584
  /**
585
585
  * Grid Row Start / End
@@ -630,21 +630,21 @@ const D = (e) => {
630
630
  * @see https://tailwindcss.com/docs/gap
631
631
  */
632
632
  gap: [{
633
- gap: [m]
633
+ gap: [g]
634
634
  }],
635
635
  /**
636
636
  * Gap X
637
637
  * @see https://tailwindcss.com/docs/gap
638
638
  */
639
639
  "gap-x": [{
640
- "gap-x": [m]
640
+ "gap-x": [g]
641
641
  }],
642
642
  /**
643
643
  * Gap Y
644
644
  * @see https://tailwindcss.com/docs/gap
645
645
  */
646
646
  "gap-y": [{
647
- "gap-y": [m]
647
+ "gap-y": [g]
648
648
  }],
649
649
  /**
650
650
  * Justify Content
@@ -715,63 +715,63 @@ const D = (e) => {
715
715
  * @see https://tailwindcss.com/docs/padding
716
716
  */
717
717
  p: [{
718
- p: [S]
718
+ p: [M]
719
719
  }],
720
720
  /**
721
721
  * Padding X
722
722
  * @see https://tailwindcss.com/docs/padding
723
723
  */
724
724
  px: [{
725
- px: [S]
725
+ px: [M]
726
726
  }],
727
727
  /**
728
728
  * Padding Y
729
729
  * @see https://tailwindcss.com/docs/padding
730
730
  */
731
731
  py: [{
732
- py: [S]
732
+ py: [M]
733
733
  }],
734
734
  /**
735
735
  * Padding Start
736
736
  * @see https://tailwindcss.com/docs/padding
737
737
  */
738
738
  ps: [{
739
- ps: [S]
739
+ ps: [M]
740
740
  }],
741
741
  /**
742
742
  * Padding End
743
743
  * @see https://tailwindcss.com/docs/padding
744
744
  */
745
745
  pe: [{
746
- pe: [S]
746
+ pe: [M]
747
747
  }],
748
748
  /**
749
749
  * Padding Top
750
750
  * @see https://tailwindcss.com/docs/padding
751
751
  */
752
752
  pt: [{
753
- pt: [S]
753
+ pt: [M]
754
754
  }],
755
755
  /**
756
756
  * Padding Right
757
757
  * @see https://tailwindcss.com/docs/padding
758
758
  */
759
759
  pr: [{
760
- pr: [S]
760
+ pr: [M]
761
761
  }],
762
762
  /**
763
763
  * Padding Bottom
764
764
  * @see https://tailwindcss.com/docs/padding
765
765
  */
766
766
  pb: [{
767
- pb: [S]
767
+ pb: [M]
768
768
  }],
769
769
  /**
770
770
  * Padding Left
771
771
  * @see https://tailwindcss.com/docs/padding
772
772
  */
773
773
  pl: [{
774
- pl: [S]
774
+ pl: [M]
775
775
  }],
776
776
  /**
777
777
  * Margin
@@ -841,7 +841,7 @@ const D = (e) => {
841
841
  * @see https://tailwindcss.com/docs/space
842
842
  */
843
843
  "space-x": [{
844
- "space-x": [A]
844
+ "space-x": [T]
845
845
  }],
846
846
  /**
847
847
  * Space Between X Reverse
@@ -853,7 +853,7 @@ const D = (e) => {
853
853
  * @see https://tailwindcss.com/docs/space
854
854
  */
855
855
  "space-y": [{
856
- "space-y": [A]
856
+ "space-y": [T]
857
857
  }],
858
858
  /**
859
859
  * Space Between Y Reverse
@@ -942,7 +942,7 @@ const D = (e) => {
942
942
  * @see https://tailwindcss.com/docs/font-family
943
943
  */
944
944
  "font-family": [{
945
- font: [Ne]
945
+ font: [ze]
946
946
  }],
947
947
  /**
948
948
  * Font Variant Numeric
@@ -1029,7 +1029,7 @@ const D = (e) => {
1029
1029
  * @see https://tailwindcss.com/docs/placeholder-opacity
1030
1030
  */
1031
1031
  "placeholder-opacity": [{
1032
- "placeholder-opacity": [p]
1032
+ "placeholder-opacity": [A]
1033
1033
  }],
1034
1034
  /**
1035
1035
  * Text Alignment
@@ -1050,7 +1050,7 @@ const D = (e) => {
1050
1050
  * @see https://tailwindcss.com/docs/text-opacity
1051
1051
  */
1052
1052
  "text-opacity": [{
1053
- "text-opacity": [p]
1053
+ "text-opacity": [A]
1054
1054
  }],
1055
1055
  /**
1056
1056
  * Text Decoration
@@ -1107,7 +1107,7 @@ const D = (e) => {
1107
1107
  * @see https://tailwindcss.com/docs/text-indent
1108
1108
  */
1109
1109
  indent: [{
1110
- indent: M()
1110
+ indent: C()
1111
1111
  }],
1112
1112
  /**
1113
1113
  * Vertical Alignment
@@ -1165,7 +1165,7 @@ const D = (e) => {
1165
1165
  * @see https://tailwindcss.com/docs/background-opacity
1166
1166
  */
1167
1167
  "bg-opacity": [{
1168
- "bg-opacity": [p]
1168
+ "bg-opacity": [A]
1169
1169
  }],
1170
1170
  /**
1171
1171
  * Background Origin
@@ -1179,7 +1179,7 @@ const D = (e) => {
1179
1179
  * @see https://tailwindcss.com/docs/background-position
1180
1180
  */
1181
1181
  "bg-position": [{
1182
- bg: [...C(), In]
1182
+ bg: [...E(), In]
1183
1183
  }],
1184
1184
  /**
1185
1185
  * Background Repeat
@@ -1239,21 +1239,21 @@ const D = (e) => {
1239
1239
  * @see https://tailwindcss.com/docs/gradient-color-stops
1240
1240
  */
1241
1241
  "gradient-from": [{
1242
- from: [y]
1242
+ from: [m]
1243
1243
  }],
1244
1244
  /**
1245
1245
  * Gradient Color Stops Via
1246
1246
  * @see https://tailwindcss.com/docs/gradient-color-stops
1247
1247
  */
1248
1248
  "gradient-via": [{
1249
- via: [y]
1249
+ via: [m]
1250
1250
  }],
1251
1251
  /**
1252
1252
  * Gradient Color Stops To
1253
1253
  * @see https://tailwindcss.com/docs/gradient-color-stops
1254
1254
  */
1255
1255
  "gradient-to": [{
1256
- to: [y]
1256
+ to: [m]
1257
1257
  }],
1258
1258
  // Borders
1259
1259
  /**
@@ -1429,7 +1429,7 @@ const D = (e) => {
1429
1429
  * @see https://tailwindcss.com/docs/border-opacity
1430
1430
  */
1431
1431
  "border-opacity": [{
1432
- "border-opacity": [p]
1432
+ "border-opacity": [A]
1433
1433
  }],
1434
1434
  /**
1435
1435
  * Border Style
@@ -1467,7 +1467,7 @@ const D = (e) => {
1467
1467
  * @see https://tailwindcss.com/docs/divide-opacity
1468
1468
  */
1469
1469
  "divide-opacity": [{
1470
- "divide-opacity": [p]
1470
+ "divide-opacity": [A]
1471
1471
  }],
1472
1472
  /**
1473
1473
  * Divide Style
@@ -1598,7 +1598,7 @@ const D = (e) => {
1598
1598
  * @see https://tailwindcss.com/docs/ring-opacity
1599
1599
  */
1600
1600
  "ring-opacity": [{
1601
- "ring-opacity": [p]
1601
+ "ring-opacity": [A]
1602
1602
  }],
1603
1603
  /**
1604
1604
  * Ring Offset Width
@@ -1627,28 +1627,28 @@ const D = (e) => {
1627
1627
  * @see https://tailwindcss.com/docs/box-shadow-color
1628
1628
  */
1629
1629
  "shadow-color": [{
1630
- shadow: [Ne]
1630
+ shadow: [ze]
1631
1631
  }],
1632
1632
  /**
1633
1633
  * Opacity
1634
1634
  * @see https://tailwindcss.com/docs/opacity
1635
1635
  */
1636
1636
  opacity: [{
1637
- opacity: [p]
1637
+ opacity: [A]
1638
1638
  }],
1639
1639
  /**
1640
1640
  * Mix Blend Mode
1641
1641
  * @see https://tailwindcss.com/docs/mix-blend-mode
1642
1642
  */
1643
1643
  "mix-blend": [{
1644
- "mix-blend": [...N(), "plus-lighter", "plus-darker"]
1644
+ "mix-blend": [...z(), "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": N()
1651
+ "bg-blend": z()
1652
1652
  }],
1653
1653
  // Filters
1654
1654
  /**
@@ -1720,7 +1720,7 @@ const D = (e) => {
1720
1720
  * @see https://tailwindcss.com/docs/sepia
1721
1721
  */
1722
1722
  sepia: [{
1723
- sepia: [k]
1723
+ sepia: [b]
1724
1724
  }],
1725
1725
  /**
1726
1726
  * Backdrop Filter
@@ -1777,7 +1777,7 @@ const D = (e) => {
1777
1777
  * @see https://tailwindcss.com/docs/backdrop-opacity
1778
1778
  */
1779
1779
  "backdrop-opacity": [{
1780
- "backdrop-opacity": [p]
1780
+ "backdrop-opacity": [A]
1781
1781
  }],
1782
1782
  /**
1783
1783
  * Backdrop Saturate
@@ -1791,7 +1791,7 @@ const D = (e) => {
1791
1791
  * @see https://tailwindcss.com/docs/backdrop-sepia
1792
1792
  */
1793
1793
  "backdrop-sepia": [{
1794
- "backdrop-sepia": [k]
1794
+ "backdrop-sepia": [b]
1795
1795
  }],
1796
1796
  // Tables
1797
1797
  /**
@@ -1885,21 +1885,21 @@ const D = (e) => {
1885
1885
  * @see https://tailwindcss.com/docs/scale
1886
1886
  */
1887
1887
  scale: [{
1888
- scale: [E]
1888
+ scale: [k]
1889
1889
  }],
1890
1890
  /**
1891
1891
  * Scale X
1892
1892
  * @see https://tailwindcss.com/docs/scale
1893
1893
  */
1894
1894
  "scale-x": [{
1895
- "scale-x": [E]
1895
+ "scale-x": [k]
1896
1896
  }],
1897
1897
  /**
1898
1898
  * Scale Y
1899
1899
  * @see https://tailwindcss.com/docs/scale
1900
1900
  */
1901
1901
  "scale-y": [{
1902
- "scale-y": [E]
1902
+ "scale-y": [k]
1903
1903
  }],
1904
1904
  /**
1905
1905
  * Rotate
@@ -1913,28 +1913,28 @@ const D = (e) => {
1913
1913
  * @see https://tailwindcss.com/docs/translate
1914
1914
  */
1915
1915
  "translate-x": [{
1916
- "translate-x": [g]
1916
+ "translate-x": [p]
1917
1917
  }],
1918
1918
  /**
1919
1919
  * Translate Y
1920
1920
  * @see https://tailwindcss.com/docs/translate
1921
1921
  */
1922
1922
  "translate-y": [{
1923
- "translate-y": [g]
1923
+ "translate-y": [p]
1924
1924
  }],
1925
1925
  /**
1926
1926
  * Skew X
1927
1927
  * @see https://tailwindcss.com/docs/skew
1928
1928
  */
1929
1929
  "skew-x": [{
1930
- "skew-x": [b]
1930
+ "skew-x": [h]
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": [b]
1937
+ "skew-y": [h]
1938
1938
  }],
1939
1939
  /**
1940
1940
  * Transform Origin
@@ -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": M()
2001
+ "scroll-m": C()
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": M()
2008
+ "scroll-mx": C()
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": M()
2015
+ "scroll-my": C()
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": M()
2022
+ "scroll-ms": C()
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": M()
2029
+ "scroll-me": C()
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": M()
2036
+ "scroll-mt": C()
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": M()
2043
+ "scroll-mr": C()
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": M()
2050
+ "scroll-mb": C()
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": M()
2057
+ "scroll-ml": C()
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": M()
2064
+ "scroll-p": C()
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": M()
2071
+ "scroll-px": C()
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": M()
2078
+ "scroll-py": C()
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": M()
2085
+ "scroll-ps": C()
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": M()
2092
+ "scroll-pe": C()
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": M()
2099
+ "scroll-pt": C()
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": M()
2106
+ "scroll-pr": C()
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": M()
2113
+ "scroll-pb": C()
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": M()
2120
+ "scroll-pl": C()
2121
2121
  }],
2122
2122
  /**
2123
2123
  * Scroll Snap Align
@@ -2310,10 +2310,10 @@ function tt(e) {
2310
2310
  return null;
2311
2311
  }
2312
2312
  }
2313
- function Nn(e) {
2313
+ function zn(e) {
2314
2314
  return typeof e != "string" ? !1 : /^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e);
2315
2315
  }
2316
- function zn(e) {
2316
+ function Nn(e) {
2317
2317
  return e.type === "image_url";
2318
2318
  }
2319
2319
  function Rn(e) {
@@ -2324,7 +2324,7 @@ function Ln(e) {
2324
2324
  `).trim() : typeof e.content == "string" ? e.content : "";
2325
2325
  }
2326
2326
  function Un(e) {
2327
- return e.content.filter(zn);
2327
+ return e.content.filter(Nn);
2328
2328
  }
2329
2329
  function jn(e) {
2330
2330
  return e.content.filter(Rn);
@@ -2399,7 +2399,7 @@ function Et(e) {
2399
2399
  }
2400
2400
  function oo(e) {
2401
2401
  const t = Et(e);
2402
- return typeof e == "string" && Nn(e) ? { content: e, isMarkdown: !0 } : { content: t, isMarkdown: !1 };
2402
+ return typeof e == "string" && zn(e) ? { content: e, isMarkdown: !0 } : { content: t, isMarkdown: !1 };
2403
2403
  }
2404
2404
  function Fn(e) {
2405
2405
  const t = (r) => {
@@ -2448,12 +2448,12 @@ function le(e) {
2448
2448
  );
2449
2449
  }
2450
2450
  function nt(e) {
2451
- var p, S, x, E, k, b, A;
2451
+ var A, M, x, k, b, h, T;
2452
2452
  if (!e || typeof e != "object") return null;
2453
2453
  const t = le(e), n = Kn(t);
2454
2454
  if (!n)
2455
2455
  return null;
2456
- const r = t.toolCalls ?? ((p = t.additionalKwargs) == null ? void 0 : p.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(), u = t.name ?? ((x = t.additionalKwargs) == null ? void 0 : x.agentName) ?? void 0, c = t.model ?? ((E = t.additionalKwargs) == null ? void 0 : E.model) ?? void 0, l = t.toolCallId ?? void 0, d = t.additionalKwargs ?? void 0, m = t.responseMetadata ?? void 0, y = t.checkpointId ?? ((k = t.additionalKwargs) == null ? void 0 : k.checkpointId) ?? void 0, v = t.checkpointNs ?? ((b = t.additionalKwargs) == null ? void 0 : b.checkpointNs) ?? void 0, f = typeof t.toolStreaming == "boolean" ? t.toolStreaming : !!((A = t.additionalKwargs) != null && A.toolStreaming);
2456
+ const r = t.toolCalls ?? ((A = t.additionalKwargs) == null ? void 0 : A.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(), u = t.name ?? ((x = t.additionalKwargs) == null ? void 0 : x.agentName) ?? void 0, c = t.model ?? ((k = t.additionalKwargs) == null ? void 0 : k.model) ?? void 0, l = t.toolCallId ?? void 0, d = t.additionalKwargs ?? void 0, g = t.responseMetadata ?? void 0, m = t.checkpointId ?? ((b = t.additionalKwargs) == null ? void 0 : b.checkpointId) ?? void 0, v = t.checkpointNs ?? ((h = t.additionalKwargs) == null ? void 0 : h.checkpointNs) ?? void 0, f = typeof t.toolStreaming == "boolean" ? t.toolStreaming : !!((T = t.additionalKwargs) != null && T.toolStreaming);
2457
2457
  return {
2458
2458
  ...t,
2459
2459
  id: a,
@@ -2464,11 +2464,11 @@ function nt(e) {
2464
2464
  model: c,
2465
2465
  toolCallId: l,
2466
2466
  toolCalls: o,
2467
- checkpointId: y,
2467
+ checkpointId: m,
2468
2468
  checkpointNs: v,
2469
2469
  toolStreaming: f,
2470
2470
  additionalKwargs: d,
2471
- responseMetadata: m,
2471
+ responseMetadata: g,
2472
2472
  artifact: t.artifact && typeof t.artifact == "object" && !t.artifact.type ? { ...t.artifact, type: t.name } : t.artifact ?? void 0
2473
2473
  };
2474
2474
  }
@@ -2537,8 +2537,8 @@ function qn(e, t = []) {
2537
2537
  if (Array.isArray(e)) {
2538
2538
  const o = e.filter((a) => a.role === "assistant").flatMap((a) => dt(a)), s = /* @__PURE__ */ new Map();
2539
2539
  return o.forEach((a) => s.set(a.id, a)), Array.from(s.values()).map((a) => {
2540
- var d, m, y;
2541
- const i = He(a.id, e) || He(a.id, t), u = Array.isArray((d = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : d.toolProgress) ? (m = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : m.toolProgress : void 0, c = (i == null ? void 0 : i.artifact) ?? a.artifact, l = ut(a.status) ?? ((y = i == null ? void 0 : i.additionalKwargs) != null && y.toolStreaming ? "pending" : null) ?? (i ? "completed" : "pending");
2540
+ var d, g, m;
2541
+ const i = He(a.id, e) || He(a.id, t), u = Array.isArray((d = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : d.toolProgress) ? (g = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : g.toolProgress : void 0, c = (i == null ? void 0 : i.artifact) ?? a.artifact, l = ut(a.status) ?? ((m = i == null ? void 0 : i.additionalKwargs) != null && m.toolStreaming ? "pending" : null) ?? (i ? "completed" : "pending");
2542
2542
  if (i && !a.content && l === "completed") {
2543
2543
  const v = ce(i);
2544
2544
  typeof v == "string" && (a.content = v);
@@ -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 ze = {
2576
+ const Ne = {
2577
2577
  authToken: "authToken",
2578
2578
  authTokenExpiresAt: "authTokenExpiresAt",
2579
2579
  authSessionId: "authSessionId",
@@ -2597,7 +2597,7 @@ function _t(e) {
2597
2597
  return Qe.add(e), () => Qe.delete(e);
2598
2598
  }
2599
2599
  const Hn = 12e4, Gn = 12e4;
2600
- let Ye = Hn, Nt = Gn;
2600
+ let Ye = Hn, zt = Gn;
2601
2601
  const ne = Jt.create({
2602
2602
  // BaseURL is set dynamically via ApiProvider -> api.updateConfig
2603
2603
  timeout: Ye,
@@ -2608,10 +2608,10 @@ 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, ne.defaults.timeout = Ye), n !== null && (zt = n);
2612
2612
  }
2613
2613
  function Jn() {
2614
- return Nt;
2614
+ return zt;
2615
2615
  }
2616
2616
  ne.interceptors.request.use((e) => (Ve && (e.headers.Authorization = `Bearer ${Ve}`), e));
2617
2617
  ne.interceptors.response.use(
@@ -2619,7 +2619,7 @@ ne.interceptors.response.use(
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(ze.authToken, r), ve(r)), o && localStorage.setItem(ze.authTokenExpiresAt, o.toString()), (r || o) && window.dispatchEvent(
2622
+ r && (localStorage.setItem(Ne.authToken, r), ve(r)), o && localStorage.setItem(Ne.authTokenExpiresAt, o.toString()), (r || o) && window.dispatchEvent(
2623
2623
  new CustomEvent("smartorg:chat-token-updated", {
2624
2624
  detail: { token: r, expiresAt: o }
2625
2625
  })
@@ -2741,7 +2741,7 @@ class Yn {
2741
2741
  return ae(n);
2742
2742
  }
2743
2743
  }
2744
- const zt = new Yn();
2744
+ const Nt = new Yn();
2745
2745
  class Zn {
2746
2746
  // Config logic could go here if files ever need a distinct base URL from chat
2747
2747
  // For now, it shares the chatBaseUrl via the shared httpClient
@@ -2840,7 +2840,7 @@ class er {
2840
2840
  }
2841
2841
  const tr = new er(), Lt = Ce(null);
2842
2842
  function nr({ children: e, apiConfig: t }) {
2843
- const n = zt, r = tr;
2843
+ const n = Nt, r = tr;
2844
2844
  if (t) {
2845
2845
  const s = n.baseUrl, a = r.baseUrl, i = n.getAuthToken(), u = t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0;
2846
2846
  (t.baseUrl || t.chatBaseUrl || u) && (u || t.chatBaseUrl && t.chatBaseUrl !== s || t.baseUrl && !s.startsWith(t.baseUrl)) && n.updateConfig(t), (t.baseUrl || t.authBaseUrl) && (t.authBaseUrl && t.authBaseUrl !== a || t.baseUrl && !a.startsWith(t.baseUrl)) && r.updateConfig(t), t.apiKey !== void 0 && t.apiKey !== i && (n.updateConfig({ apiKey: t.apiKey }), r.updateConfig({ apiKey: t.apiKey }));
@@ -3013,46 +3013,46 @@ function pr(e = {}) {
3013
3013
  X(() => {
3014
3014
  i.current = e;
3015
3015
  }, [e]);
3016
- const u = _((g) => {
3017
- var j, M, O, F, C, B, N, K, z, L;
3016
+ const u = _((p) => {
3017
+ var j, C, O, F, E, B, z, K, N, L;
3018
3018
  const w = i.current;
3019
3019
  if (!w) return;
3020
- (j = w.onEvent) == null || j.call(w, g), g.type === "thread_info" && ((M = w.onThreadInfo) == null || M.call(w, g)), g.type === "values" && Array.isArray(g.checkpoints) && ((O = w.handleValuesEvent) == null || O.call(w, g)), g.type === "metadata" && ((F = w.onMetadataEvent) == null || F.call(w, g)), typeof g.type == "string" && (g.type === "custom" || g.type.startsWith("custom.")) && ((C = w.onCustomEvent) == null || C.call(w, g)), g.type === "updates" && ((B = w.onUpdateEvent) == null || B.call(w, g)), g.type === "tool.end" ? (N = w.onToolEnd) == null || N.call(w, g) : g.type === "tool.start" && ((K = w.onToolStart) == null || K.call(w, g)), g.type === "heartbeat" && ((z = w.onHeartbeat) == null || z.call(w, g)), g.type === "token" && ((L = w.onToken) == null || L.call(w, g.token));
3021
- }, []), [c, l] = $(!1), [d, m] = $(null), [y, v] = $(!1), [f, I] = $(null), p = W(null), S = W(!0), x = W(null), E = _((g) => {
3022
- o(g);
3023
- }, []), k = _(() => {
3024
- m(null), I(null);
3020
+ (j = w.onEvent) == null || j.call(w, p), p.type === "thread_info" && ((C = w.onThreadInfo) == null || C.call(w, p)), p.type === "values" && Array.isArray(p.checkpoints) && ((O = w.handleValuesEvent) == null || O.call(w, p)), p.type === "metadata" && ((F = w.onMetadataEvent) == null || F.call(w, p)), typeof p.type == "string" && (p.type === "custom" || p.type.startsWith("custom.")) && ((E = w.onCustomEvent) == null || E.call(w, p)), p.type === "updates" && ((B = w.onUpdateEvent) == null || B.call(w, p)), p.type === "tool.end" ? (z = w.onToolEnd) == null || z.call(w, p) : p.type === "tool.start" && ((K = w.onToolStart) == null || K.call(w, p)), p.type === "heartbeat" && ((N = w.onHeartbeat) == null || N.call(w, p)), p.type === "token" && ((L = w.onToken) == null || L.call(w, p.token));
3021
+ }, []), [c, l] = $(!1), [d, g] = $(null), [m, v] = $(!1), [f, I] = $(null), A = W(null), M = W(!0), x = W(null), k = _((p) => {
3022
+ o(p);
3025
3023
  }, []), b = _(() => {
3026
- var M, O;
3024
+ g(null), I(null);
3025
+ }, []), h = _(() => {
3026
+ var C, O;
3027
3027
  console.debug("[use-chat] stop() invoked - aborting stream");
3028
- const g = (M = x.current) == null ? void 0 : M.threadId, w = (O = x.current) == null ? void 0 : O.runId, P = () => {
3028
+ const p = (C = x.current) == null ? void 0 : C.threadId, w = (O = x.current) == null ? void 0 : O.runId, P = () => {
3029
3029
  var F;
3030
- (F = p.current) == null || F.abort(), p.current = null, x.current = null, l(!1), v(!1);
3030
+ (F = A.current) == null || F.abort(), A.current = null, x.current = null, l(!1), v(!1);
3031
3031
  };
3032
- (w || g ? zt.cancelRun(w || g).catch((F) => {
3032
+ (w || p ? Nt.cancelRun(w || p).catch((F) => {
3033
3033
  console.warn("[use-chat] cancel run failed:", F);
3034
3034
  }) : Promise.resolve()).finally(P);
3035
- }, []), A = _(
3036
- (g) => {
3037
- p.current && (p.current.abort(), p.current = null);
3035
+ }, []), T = _(
3036
+ (p) => {
3037
+ A.current && (A.current.abort(), A.current = null);
3038
3038
  const w = {
3039
- text: typeof g.content == "string" ? g.content : g.text,
3040
- threadId: g.threadId,
3041
- attachments: g.attachments,
3042
- payload: g.payload ? {
3043
- ...g.payload,
3044
- creativityLevel: g.payload.creativityLevel ?? "medium"
3039
+ text: typeof p.content == "string" ? p.content : p.text,
3040
+ threadId: p.threadId,
3041
+ attachments: p.attachments,
3042
+ payload: p.payload ? {
3043
+ ...p.payload,
3044
+ creativityLevel: p.payload.creativityLevel ?? "medium"
3045
3045
  } : { creativityLevel: "medium" },
3046
- config: g.config,
3047
- checkpointId: g.checkpointId,
3048
- checkpointNs: g.checkpointNs || void 0,
3049
- edit: g.edit ?? !1,
3050
- command: g.command
3046
+ config: p.config,
3047
+ checkpointId: p.checkpointId,
3048
+ checkpointNs: p.checkpointNs || void 0,
3049
+ edit: p.edit ?? !1,
3050
+ command: p.command
3051
3051
  };
3052
- l(!0), m(null), I(null);
3052
+ l(!0), g(null), I(null);
3053
3053
  const P = new AbortController();
3054
- p.current = P;
3055
- let j = null, M = !1;
3054
+ A.current = P;
3055
+ let j = null, C = !1;
3056
3056
  return x.current = {
3057
3057
  threadId: w.threadId ?? void 0,
3058
3058
  runId: void 0,
@@ -3060,22 +3060,22 @@ function pr(e = {}) {
3060
3060
  headers: {},
3061
3061
  isStreaming: !0
3062
3062
  }, (async () => {
3063
- var O, F, C, B, N, K;
3063
+ var O, F, E, B, z, K;
3064
3064
  try {
3065
- let z = {};
3065
+ let N = {};
3066
3066
  try {
3067
3067
  if (r)
3068
- z = { Authorization: `Bearer ${r}` };
3068
+ N = { 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(ze.authToken)) || null;
3070
+ const te = window.__AUTH_TOKEN__, ke = ((O = window.localStorage) == null ? void 0 : O.getItem(Ne.authToken)) || null;
3071
3071
  let Q = null;
3072
3072
  try {
3073
- const ge = (F = window.localStorage) == null ? void 0 : F.getItem(ze.chatSettings);
3074
- ge && (Q = ((C = JSON.parse(ge)) == null ? void 0 : C.apiKey) || null);
3073
+ const ge = (F = window.localStorage) == null ? void 0 : F.getItem(Ne.chatSettings);
3074
+ ge && (Q = ((E = JSON.parse(ge)) == null ? void 0 : E.apiKey) || null);
3075
3075
  } catch {
3076
3076
  }
3077
3077
  const Z = te || ke || Q || null;
3078
- Z && (z = { Authorization: `Bearer ${Z}` });
3078
+ Z && (N = { Authorization: `Bearer ${Z}` });
3079
3079
  }
3080
3080
  } catch {
3081
3081
  }
@@ -3083,21 +3083,21 @@ function pr(e = {}) {
3083
3083
  let L = {};
3084
3084
  if (typeof window < "u")
3085
3085
  try {
3086
- const G = (B = window.localStorage) == null ? void 0 : B.getItem(ze.authSessionId);
3086
+ const G = (B = window.localStorage) == null ? void 0 : B.getItem(Ne.authSessionId);
3087
3087
  G && (L = { "X-Session-Id": G });
3088
3088
  } catch {
3089
3089
  }
3090
3090
  const H = {
3091
- ...z,
3091
+ ...N,
3092
3092
  ...L,
3093
3093
  ...s.current
3094
- }, h = {
3094
+ }, y = {
3095
3095
  "Content-Type": "application/json",
3096
3096
  Accept: "text/event-stream",
3097
3097
  ...H
3098
3098
  }, U = await fetch(t + n, {
3099
3099
  method: "POST",
3100
- headers: h,
3100
+ headers: y,
3101
3101
  body: JSON.stringify(w),
3102
3102
  signal: P.signal,
3103
3103
  credentials: a
@@ -3110,13 +3110,13 @@ function pr(e = {}) {
3110
3110
  G == null ? void 0 : G.slice(0, 500)
3111
3111
  );
3112
3112
  const te = `stream ${U.status}${G ? ": " + G : ""}`;
3113
- throw te && (m(te), j = "error"), new Error(te);
3113
+ throw te && (g(te), j = "error"), new Error(te);
3114
3114
  }
3115
3115
  v(!0);
3116
- const T = U.body.getReader(), J = new TextDecoder();
3116
+ const S = U.body.getReader(), J = new TextDecoder();
3117
3117
  let V = "", q = 0, ee = Date.now();
3118
3118
  const re = setInterval(() => {
3119
- Date.now() - ee > 18e5 && (m("Stream idle timeout"), j = "error", P.abort());
3119
+ Date.now() - ee > 18e5 && (g("Stream idle timeout"), j = "error", P.abort());
3120
3120
  }, 5e3), ue = 1024 * 1024;
3121
3121
  try {
3122
3122
  const G = U.headers.get("X-Thread-Id") || U.headers.get("x-thread-id"), te = U.headers.get("X-Run-Id") || U.headers.get("x-run-id");
@@ -3125,7 +3125,7 @@ function pr(e = {}) {
3125
3125
  threadId: G ?? x.current.threadId,
3126
3126
  runId: te ?? x.current.runId
3127
3127
  }); ; ) {
3128
- const { value: ke, done: Q } = await T.read();
3128
+ const { value: ke, done: Q } = await S.read();
3129
3129
  if (Q) break;
3130
3130
  V += J.decode(ke, { stream: !0 }), V.length > ue && (V = "", console.warn("Stream buffer reset: exceeded 1MB"));
3131
3131
  let Z;
@@ -3183,48 +3183,48 @@ function pr(e = {}) {
3183
3183
  j = j ?? "aborted";
3184
3184
  else {
3185
3185
  const te = G.message || String(G);
3186
- j = "error", m(te);
3186
+ j = "error", g(te);
3187
3187
  }
3188
3188
  } finally {
3189
3189
  try {
3190
- await T.cancel();
3190
+ await S.cancel();
3191
3191
  } catch {
3192
3192
  } finally {
3193
- (N = T.releaseLock) == null || N.call(T);
3193
+ (z = S.releaseLock) == null || z.call(S);
3194
3194
  }
3195
3195
  clearInterval(re);
3196
3196
  }
3197
- } catch (z) {
3198
- if (z.name === "AbortError")
3197
+ } catch (N) {
3198
+ if (N.name === "AbortError")
3199
3199
  j = j ?? "aborted";
3200
3200
  else {
3201
- const L = z.message || String(z);
3202
- j = "error", m(L), M || (M = !0, (K = e.onConnectionError) == null || K.call(e, L));
3201
+ const L = N.message || String(N);
3202
+ j = "error", g(L), C || (C = !0, (K = e.onConnectionError) == null || K.call(e, L));
3203
3203
  }
3204
3204
  } finally {
3205
3205
  try {
3206
3206
  if (e.onFinish) {
3207
- const z = {
3207
+ const N = {
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(z);
3214
+ e.onFinish(N);
3215
3215
  }
3216
- } catch (z) {
3217
- console.warn("[use-chat] onClosed callback failed", z);
3216
+ } catch (N) {
3217
+ console.warn("[use-chat] onClosed callback failed", N);
3218
3218
  }
3219
- l(!1), v(!1), p.current = null, x.current = null;
3219
+ l(!1), v(!1), A.current = null, x.current = null;
3220
3220
  }
3221
3221
  })(), Promise.resolve();
3222
3222
  },
3223
3223
  [t, n, r, e, u]
3224
3224
  );
3225
3225
  return X(() => () => {
3226
- var g;
3227
- S.current = !1, (g = p.current) == null || g.abort();
3226
+ var p;
3227
+ M.current = !1, (p = A.current) == null || p.abort();
3228
3228
  }, []), {
3229
3229
  isStreaming: c,
3230
3230
  error: d,
@@ -3236,20 +3236,20 @@ function pr(e = {}) {
3236
3236
  lastCheckpointId: null,
3237
3237
  // Deprecated: use checkpoint from reducer
3238
3238
  lastSeq: 0,
3239
- connected: y,
3240
- stream: A,
3241
- stop: b,
3242
- clear: k,
3243
- setToken: E,
3239
+ connected: m,
3240
+ stream: T,
3241
+ stop: h,
3242
+ clear: b,
3243
+ setToken: k,
3244
3244
  values: {},
3245
3245
  // Provide empty object for backward compatibility
3246
3246
  interrupt: () => Promise.resolve(),
3247
3247
  resume: () => Promise.resolve(),
3248
3248
  goto: () => Promise.resolve(),
3249
- connectionState: d ? "error" : c ? y ? "connected" : "connecting" : "idle",
3249
+ connectionState: d ? "error" : c ? m ? "connected" : "connecting" : "idle",
3250
3250
  messages: [],
3251
3251
  // useStream doesn't maintain messages, use useChatSession instead
3252
- submit: A
3252
+ submit: T
3253
3253
  };
3254
3254
  }
3255
3255
  function gr({
@@ -3259,20 +3259,20 @@ function gr({
3259
3259
  onThreadChange: r,
3260
3260
  onCurrentThreadDeleted: o
3261
3261
  }) {
3262
- const [s, a] = $([]), [i, u] = $(t), [c, l] = $(!1), [d, m] = $(null), y = W(i), v = W(/* @__PURE__ */ new Map());
3262
+ const [s, a] = $([]), [i, u] = $(t), [c, l] = $(!1), [d, g] = $(null), m = W(i), v = W(/* @__PURE__ */ new Map());
3263
3263
  X(() => {
3264
- y.current = i;
3264
+ m.current = i;
3265
3265
  }, [i]), X(() => {
3266
- t !== void 0 && t !== y.current && u(t);
3266
+ t !== void 0 && t !== m.current && u(t);
3267
3267
  }, [t]);
3268
3268
  const f = _(async () => {
3269
- l(!0), m(null);
3269
+ l(!0), g(null);
3270
3270
  try {
3271
- const k = await e.listThreads();
3272
- a(k ?? []);
3273
- } catch (k) {
3274
- const b = String(k);
3275
- m(b), n == null || n(b);
3271
+ const b = await e.listThreads();
3272
+ a(b ?? []);
3273
+ } catch (b) {
3274
+ const h = String(b);
3275
+ g(h), n == null || n(h);
3276
3276
  } finally {
3277
3277
  l(!1);
3278
3278
  }
@@ -3283,81 +3283,81 @@ function gr({
3283
3283
  r == null || r(i);
3284
3284
  }, [i, r]);
3285
3285
  const I = _(
3286
- async (k, b) => {
3286
+ async (b, h) => {
3287
3287
  try {
3288
- const A = b && typeof b == "object" ? { id: b.id, name: b.name ?? "" } : void 0, g = await e.createThread(k, A);
3289
- return u(g.threadId), await f(), g.threadId;
3290
- } catch (A) {
3291
- const g = String(A);
3292
- return n == null || n(g), null;
3288
+ const T = h && typeof h == "object" ? { id: h.id, name: h.name ?? "" } : void 0, p = await e.createThread(b, T);
3289
+ return u(p.threadId), await f(), p.threadId;
3290
+ } catch (T) {
3291
+ const p = String(T);
3292
+ return n == null || n(p), null;
3293
3293
  }
3294
3294
  },
3295
3295
  [e, n, f]
3296
- ), p = _(
3297
- async (k) => {
3298
- const b = s;
3299
- a((g) => g.filter((w) => w.threadId !== k));
3300
- const A = new AbortController();
3301
- v.current.set(k, A);
3296
+ ), A = _(
3297
+ async (b) => {
3298
+ const h = s;
3299
+ a((p) => p.filter((w) => w.threadId !== b));
3300
+ const T = new AbortController();
3301
+ v.current.set(b, T);
3302
3302
  try {
3303
- await e.deleteThread(k), y.current === k && (u(null), o == null || o());
3304
- } catch (g) {
3305
- a(b);
3306
- const w = String(g);
3303
+ await e.deleteThread(b), m.current === b && (u(null), o == null || o());
3304
+ } catch (p) {
3305
+ a(h);
3306
+ const w = String(p);
3307
3307
  n == null || n(w);
3308
3308
  } finally {
3309
- v.current.delete(k);
3309
+ v.current.delete(b);
3310
3310
  }
3311
3311
  },
3312
3312
  [e, o, n, s]
3313
- ), S = _(
3314
- async (k, b) => {
3313
+ ), M = _(
3314
+ async (b, h) => {
3315
3315
  try {
3316
- await e.updateThread(k, b), await f();
3317
- } catch (A) {
3318
- n == null || n(String(A));
3316
+ await e.updateThread(b, h), await f();
3317
+ } catch (T) {
3318
+ n == null || n(String(T));
3319
3319
  }
3320
3320
  },
3321
3321
  [e, n, f]
3322
3322
  ), x = Y(
3323
3323
  () => ({
3324
3324
  createThread: I,
3325
- deleteThread: p,
3326
- renameThread: S,
3325
+ deleteThread: A,
3326
+ renameThread: M,
3327
3327
  refreshThreads: f
3328
3328
  }),
3329
- [I, p, S, f]
3330
- ), E = _((k) => {
3331
- if (!(k != null && k.threadId)) return;
3332
- const b = {
3333
- threadId: k.threadId,
3334
- title: k.title || `Thread ${k.threadId.slice(0, 8)}`,
3335
- project: k.project,
3336
- createdAt: k.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
3337
- updatedAt: k.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
3338
- messageCount: k.messageCount ?? 1
3329
+ [I, A, M, f]
3330
+ ), k = _((b) => {
3331
+ if (!(b != null && b.threadId)) return;
3332
+ const h = {
3333
+ threadId: b.threadId,
3334
+ title: b.title || `Thread ${b.threadId.slice(0, 8)}`,
3335
+ project: b.project,
3336
+ createdAt: b.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
3337
+ updatedAt: b.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
3338
+ messageCount: b.messageCount ?? 1
3339
3339
  };
3340
- a((A) => {
3341
- let g = !1;
3342
- const w = A.map((P) => P.threadId === b.threadId ? (g = !0, console.debug("[useThreadsState] thread_info: updating existing thread", b.threadId), {
3340
+ a((T) => {
3341
+ let p = !1;
3342
+ const w = T.map((P) => P.threadId === h.threadId ? (p = !0, console.debug("[useThreadsState] thread_info: updating existing thread", h.threadId), {
3343
3343
  ...P,
3344
- title: b.title ?? P.title,
3345
- project: b.project ?? P.project,
3346
- updatedAt: b.updatedAt ?? P.updatedAt,
3347
- messageCount: b.messageCount ?? P.messageCount
3344
+ title: h.title ?? P.title,
3345
+ project: h.project ?? P.project,
3346
+ updatedAt: h.updatedAt ?? P.updatedAt,
3347
+ messageCount: h.messageCount ?? P.messageCount
3348
3348
  }) : P);
3349
- return g ? w : (console.debug("[useThreadsState] thread_info: adding thread to list", b.threadId), [b, ...A]);
3349
+ return p ? w : (console.debug("[useThreadsState] thread_info: adding thread to list", h.threadId), [h, ...T]);
3350
3350
  });
3351
3351
  }, []);
3352
3352
  return {
3353
3353
  threads: s,
3354
3354
  currentThreadId: i,
3355
- currentThreadIdRef: y,
3355
+ currentThreadIdRef: m,
3356
3356
  setCurrentThreadId: u,
3357
3357
  isLoadingThreads: c,
3358
3358
  threadsError: d,
3359
3359
  actions: x,
3360
- addThreadFromEvent: E
3360
+ addThreadFromEvent: k
3361
3361
  };
3362
3362
  }
3363
3363
  const jt = Ce(null);
@@ -3375,13 +3375,13 @@ function mr({
3375
3375
  isLoadingThreads: c,
3376
3376
  threadsError: l,
3377
3377
  actions: d,
3378
- addThreadFromEvent: m
3378
+ addThreadFromEvent: g
3379
3379
  } = gr({
3380
3380
  api: o,
3381
3381
  initialThreadId: t,
3382
3382
  onError: n,
3383
3383
  onThreadChange: r
3384
- }), y = Y(
3384
+ }), m = Y(
3385
3385
  () => ({
3386
3386
  threads: s,
3387
3387
  currentThreadId: a,
@@ -3390,7 +3390,7 @@ function mr({
3390
3390
  isLoading: c,
3391
3391
  error: l,
3392
3392
  actions: d,
3393
- addThreadFromEvent: m
3393
+ addThreadFromEvent: g
3394
3394
  }),
3395
3395
  [
3396
3396
  s,
@@ -3400,10 +3400,10 @@ function mr({
3400
3400
  c,
3401
3401
  l,
3402
3402
  d,
3403
- m
3403
+ g
3404
3404
  ]
3405
3405
  );
3406
- return /* @__PURE__ */ ie(jt.Provider, { value: y, children: e });
3406
+ return /* @__PURE__ */ ie(jt.Provider, { value: m, children: e });
3407
3407
  }
3408
3408
  function ot(e) {
3409
3409
  const t = Ue(jt);
@@ -3577,10 +3577,10 @@ function pt(e, t) {
3577
3577
  alternatives: l[0].alternatives
3578
3578
  } : null;
3579
3579
  if (o) {
3580
- const m = typeof r == "string" && r.length > 0 ? r : "task";
3580
+ const g = typeof r == "string" && r.length > 0 ? r : "task";
3581
3581
  return {
3582
3582
  ...e,
3583
- taskMessagesByScope: { ...e.taskMessagesByScope, [m]: i },
3583
+ taskMessagesByScope: { ...e.taskMessagesByScope, [g]: i },
3584
3584
  assemblingId: null
3585
3585
  // Clear streaming state when finalized
3586
3586
  };
@@ -3602,39 +3602,57 @@ function pt(e, t) {
3602
3602
  const l = s[i] ?? {};
3603
3603
  s[i] = {
3604
3604
  ...l,
3605
- lastSeq: t.seq ?? l.lastSeq ?? null
3605
+ lastSeq: t.seq ?? l.lastSeq ?? null,
3606
+ metadata: { ...l.metadata ?? {}, ...c }
3606
3607
  };
3607
3608
  }), { ...e, messagesStreamMeta: s };
3608
3609
  }
3609
- return t.type === "messages/partial" ? vr(e, t, o) : t.type === "tool.start" ? { ...Ir(e, t, o), status: "streaming" } : t.type === "tool.progress" ? Ar(e, t, o) : t.type === "tool.end" ? xr(e, t, o) : t.type === "artifact.update" ? Tr(e, t) : e;
3610
+ if (t.type === "messages/partial" || t.type === "message.delta") {
3611
+ const s = t.type === "messages/partial" ? t : {
3612
+ ...t,
3613
+ type: "messages/partial",
3614
+ messages: t.delta ? [{
3615
+ id: t.id,
3616
+ type: "ai",
3617
+ content: t.delta,
3618
+ scope: t.scope,
3619
+ origin: t.origin
3620
+ }] : []
3621
+ };
3622
+ return vr(e, s, o);
3623
+ }
3624
+ return t.type === "message.start" ? { ...e, assemblingId: t.id, status: "streaming" } : t.type === "message.end" ? { ...e, assemblingId: null } : t.type === "tool.start" ? { ...Ir(e, t, o), status: "streaming" } : t.type === "tool.progress" ? Ar(e, t, o) : t.type === "tool.end" ? xr(e, t, o) : t.type === "artifact.update" ? Tr(e, t) : e;
3610
3625
  }
3611
3626
  function vr(e, t, n) {
3612
- var m, y, v, f, I;
3627
+ var m, v, f, I, A, M, x;
3613
3628
  const r = t.messages;
3614
3629
  if (!r.length)
3615
3630
  return console.warn("[messagesReducer] Dropping messages/partial event without messages[]", t), e;
3616
- const o = r.find((p) => p.type === "ai" || p.type === "assistant" || p.role === "assistant");
3631
+ const o = r.find((k) => k.type === "ai" || k.type === "assistant" || k.role === "assistant");
3617
3632
  if (!o) return e;
3618
- const s = o.id, a = o.content ?? "", i = typeof a == "string" ? [{ type: "text", text: a }] : Array.isArray(a) ? a.map((p) => typeof p == "string" ? { type: "text", text: p } : (p == null ? void 0 : p.type) === "text" ? { type: "text", text: typeof p.text == "string" ? p.text : p.content ?? "" } : ((p == null ? void 0 : p.type) === "reasoning", p)) : [], u = i.filter((p) => p.type === "text").map((p) => p.text).join(""), c = e.assemblingId !== s, l = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3633
+ const s = o.id, a = o.content ?? "", i = typeof a == "string" ? [{ type: "text", text: a }] : Array.isArray(a) ? a.map((k) => typeof k == "string" ? { type: "text", text: k } : (k == null ? void 0 : k.type) === "text" ? { type: "text", text: typeof k.text == "string" ? k.text : k.content ?? "" } : ((k == null ? void 0 : k.type) === "reasoning", k)) : [], u = i.filter((k) => k.type === "text").map((k) => k.text).join(""), c = e.assemblingId !== s, l = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3619
3634
  let d = n ? [...e.taskMessagesByScope[l] || []] : [...e.messages];
3635
+ const g = (v = (m = e.messagesStreamMeta) == null ? void 0 : m[s]) == null ? void 0 : v.metadata;
3620
3636
  if (c) {
3621
- const p = nt({
3637
+ const k = nt({
3622
3638
  ...o,
3623
3639
  role: "assistant",
3624
3640
  content: i,
3625
3641
  scope: t.scope,
3626
- origin: t.origin
3642
+ origin: t.origin,
3643
+ responseMetadata: { ...g, ...o.responseMetadata ?? {} }
3627
3644
  });
3628
- p && d.push(p);
3645
+ k && d.push(k);
3629
3646
  } else {
3630
- const p = d.findIndex((S) => S.id === s);
3631
- if (p !== -1) {
3632
- const S = d[p];
3633
- d[p] = {
3634
- ...S,
3647
+ const k = d.findIndex((b) => b.id === s);
3648
+ if (k !== -1) {
3649
+ const b = d[k];
3650
+ d[k] = {
3651
+ ...b,
3635
3652
  content: i,
3636
- scope: t.scope ?? S.scope,
3637
- origin: t.origin ?? S.origin
3653
+ scope: t.scope ?? b.scope,
3654
+ origin: t.origin ?? b.origin,
3655
+ responseMetadata: { ...g, ...b.responseMetadata, ...o.responseMetadata ?? {} }
3638
3656
  };
3639
3657
  }
3640
3658
  }
@@ -3647,9 +3665,9 @@ function vr(e, t, n) {
3647
3665
  messagesStreamMeta: {
3648
3666
  ...e.messagesStreamMeta ?? {},
3649
3667
  [s]: {
3650
- ...((m = e.messagesStreamMeta) == null ? void 0 : m[s]) ?? {},
3651
- lastSeq: t.seq ?? ((v = (y = e.messagesStreamMeta) == null ? void 0 : y[s]) == null ? void 0 : v.lastSeq) ?? null,
3652
- lastText: u || (((I = (f = e.messagesStreamMeta) == null ? void 0 : f[s]) == null ? void 0 : I.lastText) ?? "")
3668
+ ...((f = e.messagesStreamMeta) == null ? void 0 : f[s]) ?? {},
3669
+ lastSeq: t.seq ?? ((A = (I = e.messagesStreamMeta) == null ? void 0 : I[s]) == null ? void 0 : A.lastSeq) ?? null,
3670
+ lastText: u || (((x = (M = e.messagesStreamMeta) == null ? void 0 : M[s]) == null ? void 0 : x.lastText) ?? "")
3653
3671
  }
3654
3672
  }
3655
3673
  };
@@ -3689,7 +3707,7 @@ function Ir(e, t, n) {
3689
3707
  i.push(c), u = i.length - 1;
3690
3708
  }
3691
3709
  if (u !== -1) {
3692
- const c = i[u], l = [...c.toolCalls || []], d = l.findIndex((m) => m.id === r);
3710
+ const c = i[u], l = [...c.toolCalls || []], d = l.findIndex((g) => g.id === r);
3693
3711
  d >= 0 ? l[d] = { ...l[d], status: "running", content: s } : l.push({
3694
3712
  id: r,
3695
3713
  name: o,
@@ -3815,11 +3833,11 @@ async function Mr(e, t) {
3815
3833
  const l = (i = c == null ? void 0 : c.values) == null ? void 0 : i.messages;
3816
3834
  if (Array.isArray(l))
3817
3835
  for (const d of l) {
3818
- const m = d == null ? void 0 : d.content;
3819
- if (Array.isArray(m))
3820
- for (const y of m) {
3821
- if (!y || typeof y != "object" || y.type !== "image_url" && y.type !== "file") continue;
3822
- const v = y.fileId || y.file_id;
3836
+ const g = d == null ? void 0 : d.content;
3837
+ if (Array.isArray(g))
3838
+ for (const m of g) {
3839
+ if (!m || typeof m != "object" || m.type !== "image_url" && m.type !== "file") continue;
3840
+ const v = m.fileId || m.file_id;
3823
3841
  typeof v == "string" && v.trim() && o.add(v);
3824
3842
  }
3825
3843
  }
@@ -3840,14 +3858,14 @@ async function Mr(e, t) {
3840
3858
  const l = (u = c == null ? void 0 : c.values) == null ? void 0 : u.messages;
3841
3859
  if (Array.isArray(l))
3842
3860
  for (const d of l) {
3843
- const m = d == null ? void 0 : d.content;
3844
- if (Array.isArray(m))
3845
- for (const y of m) {
3846
- if (!y || typeof y != "object" || y.type !== "image_url" && y.type !== "file") continue;
3847
- const v = y.fileId || y.file_id;
3861
+ const g = d == null ? void 0 : d.content;
3862
+ if (Array.isArray(g))
3863
+ for (const m of g) {
3864
+ if (!m || typeof m != "object" || m.type !== "image_url" && m.type !== "file") continue;
3865
+ const v = m.fileId || m.file_id;
3848
3866
  if (!v) continue;
3849
3867
  const f = a.get(v), I = (f == null ? void 0 : f.contentUrl) || (f == null ? void 0 : f.content_url);
3850
- I && (y.type === "image_url" ? (y.imageUrl = y.imageUrl || {}, y.imageUrl.url = I) : y.type === "file" && (y.url = I, !y.name && (f != null && f.filename || f != null && f.name) && (y.name = (f == null ? void 0 : f.filename) || (f == null ? void 0 : f.name))));
3868
+ I && (m.type === "image_url" ? (m.imageUrl = m.imageUrl || {}, m.imageUrl.url = I) : m.type === "file" && (m.url = I, !m.name && (f != null && f.filename || f != null && f.name) && (m.name = (f == null ? void 0 : f.filename) || (f == null ? void 0 : f.name))));
3851
3869
  }
3852
3870
  }
3853
3871
  }
@@ -3863,30 +3881,30 @@ function mt(e) {
3863
3881
  };
3864
3882
  }
3865
3883
  function Cr(e, t) {
3866
- var k, b;
3884
+ var b, h;
3867
3885
  if (!e) return null;
3868
- const n = ((k = e.values) == null ? void 0 : k.activeAgent) ?? null, r = (b = e.values) == null ? void 0 : b.messages, s = (Array.isArray(r) ? r : []).map((A) => Er(A, n)).filter((A) => !!A), a = Re(e.metadata) ?? {}, i = gt(e.config), u = Re(e.parentConfig), c = gt(u), l = Fe(i, ["checkpointId"]), d = Fe(i, ["checkpointNs"]), m = Fe(c, ["checkpointId"]), y = Re(e.config), v = Array.isArray(e.tasks) ? e.tasks.map((A) => ({ ...A })) : e.tasks ?? null, f = Array.isArray(e.next) ? [...e.next] : e.next ?? null, I = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt : new Date(Date.now() - t).toISOString(), p = {
3886
+ 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 = Re(e.metadata) ?? {}, i = gt(e.config), u = Re(e.parentConfig), c = gt(u), l = Fe(i, ["checkpointId"]), d = Fe(i, ["checkpointNs"]), g = Fe(c, ["checkpointId"]), m = Re(e.config), v = Array.isArray(e.tasks) ? e.tasks.map((T) => ({ ...T })) : e.tasks ?? null, f = Array.isArray(e.next) ? [...e.next] : e.next ?? null, I = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt : new Date(Date.now() - t).toISOString(), A = {
3869
3887
  ...a,
3870
3888
  step: Sr(a, ["step"]) ?? 0,
3871
3889
  source: Fe(a, ["source"]) ?? null
3872
- }, S = s.map((A) => ({
3873
- ...A,
3874
- checkpointId: A.checkpointId ?? l ?? null,
3875
- checkpointNs: A.checkpointNs ?? d ?? null
3876
- })), x = e.values, E = Array.isArray(e.interrupts) ? e.interrupts : Array.isArray(x == null ? void 0 : x.interrupts) ? x.interrupts : [];
3890
+ }, M = s.map((T) => ({
3891
+ ...T,
3892
+ checkpointId: T.checkpointId ?? l ?? null,
3893
+ checkpointNs: T.checkpointNs ?? d ?? null
3894
+ })), x = e.values, k = Array.isArray(e.interrupts) ? e.interrupts : Array.isArray(x == null ? void 0 : x.interrupts) ? x.interrupts : [];
3877
3895
  return {
3878
3896
  checkpointId: l ?? null,
3879
3897
  checkpointNs: d ?? null,
3880
3898
  createdAt: I,
3881
- parentId: m ?? null,
3882
- messages: S,
3899
+ parentId: g ?? null,
3900
+ messages: M,
3883
3901
  interrupt: Pr(
3884
- E,
3902
+ k,
3885
3903
  t,
3886
3904
  l ?? null
3887
3905
  ),
3888
- metadata: p,
3889
- config: y ?? null,
3906
+ metadata: A,
3907
+ config: m ?? null,
3890
3908
  parentConfig: u ?? null,
3891
3909
  next: f,
3892
3910
  tasks: v,
@@ -3928,40 +3946,40 @@ function _r(e) {
3928
3946
  const n = t.join(" ").replace(/\s+/g, " ").trim();
3929
3947
  return n ? n.length > ht ? `${n.slice(0, ht - 3)}…` : n : "";
3930
3948
  }
3931
- function Nr(e) {
3949
+ function zr(e) {
3932
3950
  return _r(e.content) || "";
3933
3951
  }
3934
- function zr(e) {
3952
+ function Nr(e) {
3935
3953
  const t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Map(), o = [];
3936
3954
  for (let c = 0; c < e.length; c++) {
3937
- const l = e[c], d = l.checkpointId, m = d ?? `cp-${c}`, y = l.metadata ?? {}, v = typeof y.step == "number" ? y.step : null, f = typeof y.source == "string" ? y.source : null;
3938
- let I = null, p = null;
3939
- const S = Array.isArray(l.messages) ? l.messages : [];
3940
- for (const b of S)
3941
- b.role === "user" && (p || (p = b), b.id && (I = b.id));
3942
- const x = l.next && l.next.length > 0 ? String(l.next[0]) : null, E = l.parentConfig ?? null, k = {
3943
- id: m,
3955
+ const l = e[c], d = l.checkpointId, g = d ?? `cp-${c}`, m = l.metadata ?? {}, v = typeof m.step == "number" ? m.step : null, f = typeof m.source == "string" ? m.source : null;
3956
+ let I = null, A = null;
3957
+ const M = Array.isArray(l.messages) ? l.messages : [];
3958
+ for (const h of M)
3959
+ h.role === "user" && (A || (A = h), h.id && (I = h.id));
3960
+ const x = l.next && l.next.length > 0 ? String(l.next[0]) : null, k = l.parentConfig ?? null, b = {
3961
+ id: g,
3944
3962
  step: v,
3945
3963
  source: f,
3946
3964
  createdAt: l.createdAt ?? null,
3947
3965
  namespace: l.checkpointNs ?? null,
3948
3966
  parentId: l.parentId ?? null,
3949
3967
  next: x,
3950
- parentConfig: E,
3968
+ parentConfig: k,
3951
3969
  userMessageId: I
3952
3970
  };
3953
- if (o.push(k), d && t.set(d, k), d && p) {
3954
- const b = Nr(p);
3955
- b && r.set(d, b);
3971
+ if (o.push(b), d && t.set(d, b), d && A) {
3972
+ const h = zr(A);
3973
+ h && r.set(d, h);
3956
3974
  }
3957
3975
  n.push({
3958
- id: m,
3976
+ id: g,
3959
3977
  messageId: I,
3960
3978
  step: v,
3961
3979
  source: f,
3962
3980
  createdAt: l.createdAt ?? null,
3963
3981
  next: x,
3964
- parentConfig: E
3982
+ parentConfig: k
3965
3983
  });
3966
3984
  }
3967
3985
  const s = /* @__PURE__ */ new Map();
@@ -3972,14 +3990,14 @@ function zr(e) {
3972
3990
  }
3973
3991
  for (const c of s.values()) {
3974
3992
  if (!c.length) continue;
3975
- c.sort((d, m) => {
3976
- const y = d.createdAt ? Date.parse(d.createdAt) : 0;
3977
- return (m.createdAt ? Date.parse(m.createdAt) : 0) - y;
3993
+ c.sort((d, g) => {
3994
+ const m = d.createdAt ? Date.parse(d.createdAt) : 0;
3995
+ return (g.createdAt ? Date.parse(g.createdAt) : 0) - m;
3978
3996
  });
3979
3997
  const l = c.length;
3980
3998
  for (let d = 0; d < c.length; d++) {
3981
- const m = c[d];
3982
- m.attemptCount = l, m.attemptIndex = d, m.isLatestAttempt = d === 0;
3999
+ const g = c[d];
4000
+ g.attemptCount = l, g.attemptIndex = d, g.isLatestAttempt = d === 0;
3983
4001
  }
3984
4002
  }
3985
4003
  return {
@@ -3997,9 +4015,9 @@ function zr(e) {
3997
4015
  const l = [];
3998
4016
  for (const d of t.values())
3999
4017
  d.userMessageId === c && l.push(d);
4000
- return l.length ? (l.sort((d, m) => {
4001
- const y = typeof d.attemptIndex == "number" ? d.attemptIndex : Number.MAX_SAFE_INTEGER, v = typeof m.attemptIndex == "number" ? m.attemptIndex : Number.MAX_SAFE_INTEGER;
4002
- return y - v;
4018
+ return l.length ? (l.sort((d, g) => {
4019
+ const m = typeof d.attemptIndex == "number" ? d.attemptIndex : Number.MAX_SAFE_INTEGER, v = typeof g.attemptIndex == "number" ? g.attemptIndex : Number.MAX_SAFE_INTEGER;
4020
+ return m - v;
4003
4021
  }), l) : [];
4004
4022
  }
4005
4023
  };
@@ -4022,7 +4040,7 @@ function uo(e, t, n) {
4022
4040
  };
4023
4041
  }
4024
4042
  function Rr(e) {
4025
- return Y(() => zr(e), [e]);
4043
+ return Y(() => Nr(e), [e]);
4026
4044
  }
4027
4045
  function $t({
4028
4046
  api: e,
@@ -4037,39 +4055,39 @@ function $t({
4037
4055
  const [u, c] = $(null), d = Y(
4038
4056
  () => mt(u),
4039
4057
  [u]
4040
- ).checkpoints, m = Rr(d), y = m.timeline, [v, f] = $(!1), [I, p] = $(!1), [S, x] = $(!1), [E, k] = $(null), b = W(o), A = W(null), g = W(null);
4058
+ ).checkpoints, g = Rr(d), m = g.timeline, [v, f] = $(!1), [I, A] = $(!1), [M, x] = $(!1), [k, b] = $(null), h = W(o), T = W(null), p = W(null);
4041
4059
  X(() => {
4042
- b.current = o;
4060
+ h.current = o;
4043
4061
  }, [o]);
4044
4062
  const w = _(
4045
- async (C) => {
4063
+ async (E) => {
4046
4064
  const B = await e.getState({
4047
- threadId: C.threadId,
4048
- checkpointId: C.checkpointId,
4049
- checkpointNs: C.checkpointNs
4050
- }), N = {
4065
+ threadId: E.threadId,
4066
+ checkpointId: E.checkpointId,
4067
+ checkpointNs: E.checkpointNs
4068
+ }), z = {
4051
4069
  version: "values@1",
4052
- threadId: C.threadId,
4070
+ threadId: E.threadId,
4053
4071
  checkpoints: [B]
4054
- }, K = t ? await Mr(N, t) : N, { latest: z } = mt(K);
4055
- return z;
4072
+ }, K = t ? await Mr(z, t) : z, { latest: N } = mt(K);
4073
+ return N;
4056
4074
  },
4057
4075
  [e, t]
4058
4076
  ), P = _(
4059
- async (C, B) => {
4060
- var z;
4061
- if (!C) return;
4062
- const N = `${C}:${B ?? "latest"}`;
4063
- if (A.current === N || v) return;
4064
- (z = g.current) == null || z.abort();
4077
+ async (E, B) => {
4078
+ var N;
4079
+ if (!E) return;
4080
+ const z = `${E}:${B ?? "latest"}`;
4081
+ if (T.current === z || v) return;
4082
+ (N = p.current) == null || N.abort();
4065
4083
  const K = new AbortController();
4066
- g.current = K, f(!0), k(null);
4084
+ p.current = K, f(!0), b(null);
4067
4085
  try {
4068
4086
  const L = await w({
4069
- threadId: C,
4087
+ threadId: E,
4070
4088
  checkpointId: B ?? void 0
4071
4089
  });
4072
- if (b.current !== C) {
4090
+ if (h.current !== E) {
4073
4091
  f(!1);
4074
4092
  return;
4075
4093
  }
@@ -4078,65 +4096,65 @@ function $t({
4078
4096
  checkpointNs: (L == null ? void 0 : L.checkpointNs) ?? null,
4079
4097
  pendingInterrupt: (L == null ? void 0 : L.interrupt) ?? null,
4080
4098
  values: L == null ? void 0 : L.values
4081
- }), A.current = N, f(!1), x(!0);
4099
+ }), T.current = z, f(!1), x(!0);
4082
4100
  try {
4083
4101
  const H = await e.getStateHistory({
4084
- threadId: C,
4102
+ threadId: E,
4085
4103
  limit: 100,
4086
4104
  includeMessages: !1
4087
4105
  });
4088
- b.current === C && c(H);
4106
+ h.current === E && c(H);
4089
4107
  } finally {
4090
4108
  x(!1);
4091
4109
  }
4092
4110
  } catch (L) {
4093
4111
  if (f(!1), !Xt(L)) {
4094
4112
  const H = String(L);
4095
- k(H), r == null || r(H);
4113
+ b(H), r == null || r(H);
4096
4114
  }
4097
4115
  }
4098
4116
  },
4099
4117
  [e, n, w, r, i]
4100
4118
  ), j = _(
4101
- async (C, B) => {
4119
+ async (E, B) => {
4102
4120
  if (o) {
4103
- p(!0);
4121
+ A(!0);
4104
4122
  try {
4105
- const N = await w({
4123
+ const z = await w({
4106
4124
  threadId: o,
4107
- checkpointId: C,
4125
+ checkpointId: E,
4108
4126
  checkpointNs: B ?? void 0
4109
4127
  });
4110
- n((N == null ? void 0 : N.messages) ?? [], {
4111
- checkpointId: (N == null ? void 0 : N.checkpointId) ?? C,
4112
- checkpointNs: (N == null ? void 0 : N.checkpointNs) ?? B,
4113
- pendingInterrupt: (N == null ? void 0 : N.interrupt) ?? null,
4114
- values: N == null ? void 0 : N.values
4128
+ n((z == null ? void 0 : z.messages) ?? [], {
4129
+ checkpointId: (z == null ? void 0 : z.checkpointId) ?? E,
4130
+ checkpointNs: (z == null ? void 0 : z.checkpointNs) ?? B,
4131
+ pendingInterrupt: (z == null ? void 0 : z.interrupt) ?? null,
4132
+ values: z == null ? void 0 : z.values
4115
4133
  });
4116
- } catch (N) {
4117
- console.error("[useThreadHistoryState] Navigation failed", N);
4134
+ } catch (z) {
4135
+ console.error("[useThreadHistoryState] Navigation failed", z);
4118
4136
  } finally {
4119
- p(!1);
4137
+ A(!1);
4120
4138
  }
4121
4139
  }
4122
4140
  },
4123
4141
  [o, w, n]
4124
- ), M = _(async () => {
4142
+ ), C = _(async () => {
4125
4143
  o && await P(o);
4126
4144
  }, [o, P]), O = _(
4127
- async (C) => {
4145
+ async (E) => {
4128
4146
  var K;
4129
- const B = (C == null ? void 0 : C.threadId) || o;
4147
+ const B = (E == null ? void 0 : E.threadId) || o;
4130
4148
  if (!B || o !== B) return;
4131
- if (c(C), A.current = `${B}:latest`, (K = C.values) != null && K.messages) {
4132
- const z = await w({
4149
+ if (c(E), T.current = `${B}:latest`, (K = E.values) != null && K.messages) {
4150
+ const N = await w({
4133
4151
  threadId: B
4134
4152
  });
4135
- z && n(z.messages ?? [], {
4136
- checkpointId: z.checkpointId ?? null,
4137
- checkpointNs: z.checkpointNs ?? null,
4138
- pendingInterrupt: z.interrupt ?? null,
4139
- values: z.values
4153
+ N && n(N.messages ?? [], {
4154
+ checkpointId: N.checkpointId ?? null,
4155
+ checkpointNs: N.checkpointNs ?? null,
4156
+ pendingInterrupt: N.interrupt ?? null,
4157
+ values: N.values
4140
4158
  });
4141
4159
  }
4142
4160
  },
@@ -4144,26 +4162,26 @@ function $t({
4144
4162
  );
4145
4163
  X(() => {
4146
4164
  if (!s || !o || v || a) return;
4147
- const C = `${o}:latest`;
4148
- A.current !== C && P(o);
4165
+ const E = `${o}:latest`;
4166
+ T.current !== E && P(o);
4149
4167
  }, [s, o, v, a, P]);
4150
4168
  const F = _(() => {
4151
- c(null), f(!1), p(!1), x(!1), k(null), A.current = null;
4169
+ c(null), f(!1), A(!1), x(!1), b(null), T.current = null;
4152
4170
  }, []);
4153
4171
  return {
4154
4172
  threadCheckpoints: d,
4155
- threadTimeline: y,
4156
- checkpointIndex: m,
4173
+ threadTimeline: m,
4174
+ checkpointIndex: g,
4157
4175
  isLoadingThread: v,
4158
4176
  isLoadingCheckpoint: I,
4159
- isLoadingHistory: S,
4160
- threadStateError: E,
4177
+ isLoadingHistory: M,
4178
+ threadStateError: k,
4161
4179
  loadThread: P,
4162
4180
  navigateToCheckpoint: j,
4163
- setCurrentCheckpointId: (C, B) => {
4164
- n(i(), { checkpointId: C, checkpointNs: B });
4181
+ setCurrentCheckpointId: (E, B) => {
4182
+ n(i(), { checkpointId: E, checkpointNs: B });
4165
4183
  },
4166
- returnToLatest: M,
4184
+ returnToLatest: C,
4167
4185
  handleValuesEvent: O,
4168
4186
  markSkipNextLoad: () => {
4169
4187
  },
@@ -4194,22 +4212,22 @@ function Ur({
4194
4212
  isStreaming: s,
4195
4213
  onError: a
4196
4214
  }) {
4197
- const { chatApi: i, fileApi: u } = Me(), { currentThreadId: c } = ot(), { state: l, seed: d, onEvent: m, dispatch: y } = kr(), {
4215
+ const { chatApi: i, fileApi: u } = Me(), { currentThreadId: c } = ot(), { state: l, seed: d, onEvent: g, dispatch: m } = kr(), {
4198
4216
  threadCheckpoints: v,
4199
4217
  threadTimeline: f,
4200
4218
  checkpointIndex: I,
4201
- isLoadingThread: p,
4202
- isLoadingCheckpoint: S,
4219
+ isLoadingThread: A,
4220
+ isLoadingCheckpoint: M,
4203
4221
  isLoadingHistory: x,
4204
- threadStateError: E,
4205
- loadThread: k,
4206
- navigateToCheckpoint: b,
4207
- setCurrentCheckpointId: A,
4208
- returnToLatest: g,
4222
+ threadStateError: k,
4223
+ loadThread: b,
4224
+ navigateToCheckpoint: h,
4225
+ setCurrentCheckpointId: T,
4226
+ returnToLatest: p,
4209
4227
  handleValuesEvent: w,
4210
4228
  markSkipNextLoad: P,
4211
4229
  markStreamPendingThread: j,
4212
- resetHistoryState: M
4230
+ resetHistoryState: C
4213
4231
  } = $t({
4214
4232
  api: i,
4215
4233
  fileApi: u,
@@ -4223,19 +4241,19 @@ function Ur({
4223
4241
  isStreaming: s,
4224
4242
  getMessages: _(() => l.messages, [l.messages])
4225
4243
  }), O = W(null), F = _(
4226
- (T) => {
4227
- O.current = T;
4244
+ (S) => {
4245
+ O.current = S;
4228
4246
  },
4229
4247
  []
4230
- ), C = W(null), B = _(
4231
- (T) => {
4232
- C.current = T;
4248
+ ), E = W(null), B = _(
4249
+ (S) => {
4250
+ E.current = S;
4233
4251
  },
4234
4252
  []
4235
- ), N = Y(() => ({ assemblingMessageId: l.assemblingId ?? null }), [l.assemblingId]), K = _(
4236
- (T, J) => {
4237
- const V = Ut(T, "user");
4238
- return y({
4253
+ ), z = Y(() => ({ assemblingMessageId: l.assemblingId ?? null }), [l.assemblingId]), K = _(
4254
+ (S, J) => {
4255
+ const V = Ut(S, "user");
4256
+ return m({
4239
4257
  type: "user_message",
4240
4258
  payload: {
4241
4259
  message: V,
@@ -4243,12 +4261,12 @@ function Ur({
4243
4261
  }
4244
4262
  }), V;
4245
4263
  },
4246
- [y]
4247
- ), z = _(async () => {
4248
- O.current ? await O.current() : (d([], {}), M());
4249
- }, [d, M]), L = _(async (T, J, V) => {
4250
- await k(T, J, { clearProgress: !1 });
4251
- }, [k]), H = Y(() => Bn(l.messages), [l.messages]), h = Y(
4264
+ [m]
4265
+ ), N = _(async () => {
4266
+ O.current ? await O.current() : (d([], {}), C());
4267
+ }, [d, C]), L = _(async (S, J, V) => {
4268
+ await b(S, J, { clearProgress: !1 });
4269
+ }, [b]), H = Y(() => Bn(l.messages), [l.messages]), y = Y(
4252
4270
  () => ({
4253
4271
  status: l.status,
4254
4272
  threadId: c,
@@ -4262,39 +4280,39 @@ function Ur({
4262
4280
  checkpoints: v,
4263
4281
  checkpointIndex: I,
4264
4282
  timelineCheckpoints: f,
4265
- metadata: N,
4283
+ metadata: z,
4266
4284
  values: l.values ?? {},
4267
- isLoading: p,
4268
- isLoadingCheckpoint: S,
4285
+ isLoading: A,
4286
+ isLoadingCheckpoint: M,
4269
4287
  isLoadingHistory: x,
4270
- error: E,
4288
+ error: k,
4271
4289
  loadOlder: async () => {
4272
4290
  },
4273
4291
  // Placeholder
4274
- seedFromSnapshot: (T) => {
4275
- d(T.messages, {
4276
- checkpointId: T.checkpointId,
4277
- checkpointNs: T.checkpointNs,
4278
- pendingInterrupt: T.interrupt,
4279
- values: T.values
4292
+ seedFromSnapshot: (S) => {
4293
+ d(S.messages, {
4294
+ checkpointId: S.checkpointId,
4295
+ checkpointNs: S.checkpointNs,
4296
+ pendingInterrupt: S.interrupt,
4297
+ values: S.values
4280
4298
  });
4281
4299
  },
4282
- clearState: z,
4283
- navigateToCheckpoint: b,
4284
- setCurrentCheckpointId: A,
4285
- returnToLatest: g,
4300
+ clearState: N,
4301
+ navigateToCheckpoint: h,
4302
+ setCurrentCheckpointId: T,
4303
+ returnToLatest: p,
4286
4304
  loadThread: L,
4287
- clearThread: z,
4288
- respondToInterrupt: async (T, J, V) => {
4289
- C.current && await C.current(T, J, V);
4305
+ clearThread: N,
4306
+ respondToInterrupt: async (S, J, V) => {
4307
+ E.current && await E.current(S, J, V);
4290
4308
  },
4291
4309
  messagePreviews: I.messagePreviews,
4292
4310
  handleValuesEvent: w,
4293
4311
  markSkipNextLoad: P,
4294
4312
  markStreamPendingThread: j,
4295
- resetHistoryState: M,
4313
+ resetHistoryState: C,
4296
4314
  pushUser: K,
4297
- onEvent: m,
4315
+ onEvent: g,
4298
4316
  artifacts: H
4299
4317
  }),
4300
4318
  [
@@ -4308,22 +4326,22 @@ function Ur({
4308
4326
  v,
4309
4327
  f,
4310
4328
  I,
4311
- N,
4312
- p,
4313
- S,
4314
- x,
4315
- E,
4316
- d,
4317
4329
  z,
4318
- b,
4319
4330
  A,
4320
- g,
4331
+ M,
4332
+ x,
4333
+ k,
4334
+ d,
4335
+ N,
4336
+ h,
4337
+ T,
4338
+ p,
4321
4339
  L,
4322
4340
  w,
4323
4341
  P,
4324
4342
  j,
4325
4343
  K,
4326
- m,
4344
+ g,
4327
4345
  H
4328
4346
  ]
4329
4347
  ), U = Y(
@@ -4333,7 +4351,7 @@ function Ur({
4333
4351
  }),
4334
4352
  [F, B]
4335
4353
  );
4336
- return /* @__PURE__ */ ie(Kt.Provider, { value: U, children: /* @__PURE__ */ ie(Dt.Provider, { value: h, children: e }) });
4354
+ return /* @__PURE__ */ ie(Kt.Provider, { value: U, children: /* @__PURE__ */ ie(Dt.Provider, { value: y, children: e }) });
4337
4355
  }
4338
4356
  const qt = Ce(null), jr = Ce(!1);
4339
4357
  function Br({
@@ -4348,35 +4366,35 @@ function Br({
4348
4366
  onFinish: u,
4349
4367
  onStreamingChange: c
4350
4368
  }) {
4351
- const { chatApi: l, baseUrl: d } = Me(), m = d, y = fe(t), v = fe(n), f = fe(r), I = fe(o), p = fe(s), S = fe(a), x = fe(i), E = fe(u), k = fe(c), b = Y(
4369
+ const { chatApi: l, baseUrl: d } = Me(), g = d, m = fe(t), v = fe(n), f = fe(r), I = fe(o), A = fe(s), M = fe(a), x = fe(i), k = fe(u), b = fe(c), h = Y(
4352
4370
  () => ({
4353
- onError: y,
4371
+ onError: m,
4354
4372
  onAuthError: v,
4355
4373
  onConnectionError: f,
4356
4374
  onMetadataEvent: x,
4357
- onCustomEvent: S,
4358
- onUpdateEvent: p,
4375
+ onCustomEvent: M,
4376
+ onUpdateEvent: A,
4359
4377
  onToolEnd: I,
4360
- onFinish: E
4378
+ onFinish: k
4361
4379
  }),
4362
4380
  [
4363
- y,
4381
+ m,
4364
4382
  v,
4365
4383
  f,
4366
4384
  x,
4367
- S,
4368
- p,
4385
+ M,
4386
+ A,
4369
4387
  I,
4370
- E
4388
+ k
4371
4389
  ]
4372
4390
  );
4373
4391
  return /* @__PURE__ */ ie(jr.Provider, { value: !0, children: /* @__PURE__ */ ie(
4374
4392
  Fr,
4375
4393
  {
4376
4394
  api: l,
4377
- streamBaseUrl: m,
4378
- handlers: b,
4379
- onStreamingChange: k,
4395
+ streamBaseUrl: g,
4396
+ handlers: h,
4397
+ onStreamingChange: b,
4380
4398
  children: e
4381
4399
  }
4382
4400
  ) });
@@ -4392,98 +4410,98 @@ function Fr({
4392
4410
  interrupt: c,
4393
4411
  checkpoint: l,
4394
4412
  timelineCheckpoints: d,
4395
- handleValuesEvent: m,
4396
- markSkipNextLoad: y,
4413
+ handleValuesEvent: g,
4414
+ markSkipNextLoad: m,
4397
4415
  markStreamPendingThread: v,
4398
4416
  resetHistoryState: f,
4399
4417
  pushUser: I,
4400
- onEvent: p,
4401
- messages: S
4402
- } = Vt(), { registerClearThread: x, registerRespondToInterrupt: E } = Lr(), k = _(
4403
- (h) => {
4404
- i(h), v(h.threadId), a.current !== h.threadId && ((h.created ?? !a.current) && y(h.threadId), s(h.threadId));
4418
+ onEvent: A,
4419
+ messages: M
4420
+ } = Vt(), { registerClearThread: x, registerRespondToInterrupt: k } = Lr(), b = _(
4421
+ (y) => {
4422
+ i(y), v(y.threadId), a.current !== y.threadId && ((y.created ?? !a.current) && m(y.threadId), s(y.threadId));
4405
4423
  },
4406
- [i, y, v, s, a]
4407
- ), b = pr({
4424
+ [i, m, v, s, a]
4425
+ ), h = pr({
4408
4426
  baseUrl: n,
4409
- onEvent: p,
4410
- onError: (h) => {
4427
+ onEvent: A,
4428
+ onError: (y) => {
4411
4429
  var U;
4412
- (U = r.onError) == null || U.call(r, (h == null ? void 0 : h.message) ?? String(h));
4430
+ (U = r.onError) == null || U.call(r, (y == null ? void 0 : y.message) ?? String(y));
4413
4431
  },
4414
4432
  onAuthError: r.onAuthError,
4415
4433
  onConnectionError: r.onConnectionError,
4416
4434
  onFinish: r.onFinish,
4417
- onThreadInfo: k,
4435
+ onThreadInfo: b,
4418
4436
  onMetadataEvent: r.onMetadataEvent,
4419
4437
  onCustomEvent: r.onCustomEvent,
4420
4438
  onUpdateEvent: r.onUpdateEvent,
4421
4439
  onToolEnd: r.onToolEnd,
4422
- handleValuesEvent: m
4440
+ handleValuesEvent: g
4423
4441
  });
4424
4442
  X(() => {
4425
- o == null || o(b.isStreaming);
4426
- }, [b.isStreaming, o]);
4427
- const { stream: A, stop: g, clear: w, isStreaming: P, error: j, connected: M, streamedMessages: O, activeMessageId: F } = b;
4443
+ o == null || o(h.isStreaming);
4444
+ }, [h.isStreaming, o]);
4445
+ const { stream: T, stop: p, clear: w, isStreaming: P, error: j, connected: C, streamedMessages: O, activeMessageId: F } = h;
4428
4446
  X(() => {
4429
4447
  u !== void 0 && w();
4430
4448
  }, [u, w]);
4431
- const C = _(
4432
- async (h, U) => {
4433
- await A(h, U);
4449
+ const E = _(
4450
+ async (y, U) => {
4451
+ await T(y, U);
4434
4452
  },
4435
- [A]
4453
+ [T]
4436
4454
  ), B = W(l);
4437
4455
  X(() => {
4438
4456
  B.current = l;
4439
4457
  }, [l]);
4440
- const N = _(
4441
- async (h, U, T) => {
4458
+ const z = _(
4459
+ async (y, U, S) => {
4442
4460
  var G;
4443
4461
  const J = a.current;
4444
4462
  if (!J)
4445
4463
  throw new Error("No active thread to handle interrupt");
4446
- const V = h ? U ?? !0 : !1, q = B.current, ee = (T == null ? void 0 : T.checkpointId) ?? q.id ?? void 0, re = (T == null ? void 0 : T.checkpointNs) ?? q.namespace ?? void 0, ue = {
4464
+ const V = y ? U ?? !0 : !1, q = B.current, ee = (S == null ? void 0 : S.checkpointId) ?? q.id ?? void 0, re = (S == null ? void 0 : S.checkpointNs) ?? q.namespace ?? void 0, ue = {
4447
4465
  threadId: J,
4448
4466
  checkpointId: ee,
4449
4467
  checkpointNs: re,
4450
4468
  command: { kind: "resume", value: V },
4451
4469
  payload: {
4452
- ...(T == null ? void 0 : T.payload) ?? {},
4453
- creativityLevel: ((G = T == null ? void 0 : T.payload) == null ? void 0 : G.creativityLevel) ?? "medium"
4470
+ ...(S == null ? void 0 : S.payload) ?? {},
4471
+ creativityLevel: ((G = S == null ? void 0 : S.payload) == null ? void 0 : G.creativityLevel) ?? "medium"
4454
4472
  },
4455
4473
  edit: !1
4456
4474
  };
4457
- C(ue);
4475
+ E(ue);
4458
4476
  },
4459
- [a, C]
4477
+ [a, E]
4460
4478
  );
4461
4479
  X(() => {
4462
- E(N);
4463
- }, [N, E]);
4480
+ k(z);
4481
+ }, [z, k]);
4464
4482
  const K = _(async () => {
4465
- g(), w(), f(), s(null);
4466
- }, [w, f, s, g]);
4483
+ p(), w(), f(), s(null);
4484
+ }, [w, f, s, p]);
4467
4485
  X(() => {
4468
4486
  x(K);
4469
4487
  }, [K, x]);
4470
- const z = _(
4471
- async (h, U) => {
4472
- P && g();
4473
- let T = a.current;
4474
- const J = (h == null ? void 0 : h.text) ?? "", V = (h == null ? void 0 : h.attachments) ?? [], q = (J == null ? void 0 : J.trim()) ?? "", ee = { ...(h == null ? void 0 : h.payload) ?? {} }, re = Array.isArray(ee.messages) ? ee.messages : void 0;
4488
+ const N = _(
4489
+ async (y, U) => {
4490
+ P && p();
4491
+ let S = a.current;
4492
+ const J = (y == null ? void 0 : y.text) ?? "", V = (y == null ? void 0 : y.attachments) ?? [], q = (J == null ? void 0 : J.trim()) ?? "", ee = { ...(y == null ? void 0 : y.payload) ?? {} }, re = Array.isArray(ee.messages) ? ee.messages : void 0;
4475
4493
  re && delete ee.messages;
4476
- const ue = !!(re && re.length), G = !!(h.contentParts && h.contentParts.length > 0);
4477
- if (!T && !q && V.length === 0 && !ue && !G) return;
4478
- if (!T) {
4494
+ const ue = !!(re && re.length), G = !!(y.contentParts && y.contentParts.length > 0);
4495
+ if (!S && !q && V.length === 0 && !ue && !G) return;
4496
+ if (!S) {
4479
4497
  const ye = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0"), he = Array.from({ length: 4 }, () => Math.floor(Math.random() * 4294967295).toString(16).padStart(8, "0")).join("").slice(0, 16);
4480
- T = `${ye}${he}`, y(T), s(T);
4498
+ S = `${ye}${he}`, m(S), s(S);
4481
4499
  }
4482
4500
  let te = null;
4483
- h.contentParts && h.contentParts.length > 0 && (te = h.contentParts);
4501
+ y.contentParts && y.contentParts.length > 0 && (te = y.contentParts);
4484
4502
  const { contentParts: ke, filesInfo: Q } = te ? { contentParts: te, filesInfo: [] } : await or(V), Z = [...ke];
4485
4503
  q && Z.push({ type: "text", text: J });
4486
- const ge = h == null ? void 0 : h.originalMessageId, je = !!(h != null && h.edit && ge), Be = !ue && Z.length > 0;
4504
+ const ge = y == null ? void 0 : y.originalMessageId, je = !!(y != null && y.edit && ge), Be = !ue && Z.length > 0;
4487
4505
  let me = null;
4488
4506
  if (Be) {
4489
4507
  const ye = je ? ge : `msg-${Date.now()}`;
@@ -4499,40 +4517,40 @@ function Fr({
4499
4517
  ...Q.length ? { files_info: Q } : {}
4500
4518
  };
4501
4519
  Ie.length ? oe.messages = Ie : "messages" in oe || (oe.messages = []);
4502
- const Pe = (h == null ? void 0 : h.checkpointId) ?? l.id ?? void 0;
4503
- if (h != null && h.edit && !Pe)
4520
+ const Pe = (y == null ? void 0 : y.checkpointId) ?? l.id ?? void 0;
4521
+ if (y != null && y.edit && !Pe)
4504
4522
  throw new Error(
4505
- `[streaming] Missing checkpointId for edit submit. threadId=${T ?? "null"}`
4523
+ `[streaming] Missing checkpointId for edit submit. threadId=${S ?? "null"}`
4506
4524
  );
4507
4525
  const Ae = {
4508
- threadId: T,
4509
- content: h == null ? void 0 : h.text,
4526
+ threadId: S,
4527
+ content: y == null ? void 0 : y.text,
4510
4528
  payload: oe,
4511
- config: h == null ? void 0 : h.config,
4529
+ config: y == null ? void 0 : y.config,
4512
4530
  checkpointId: Pe,
4513
- command: h == null ? void 0 : h.command,
4514
- edit: h == null ? void 0 : h.edit
4531
+ command: y == null ? void 0 : y.command,
4532
+ edit: y == null ? void 0 : y.edit
4515
4533
  };
4516
- return C(Ae, U);
4534
+ return E(Ae, U);
4517
4535
  },
4518
- [l, a, P, y, I, C, g, d]
4519
- ), L = Y(() => S, [S]), H = Y(
4536
+ [l, a, P, m, I, E, p, d]
4537
+ ), L = Y(() => M, [M]), H = Y(
4520
4538
  () => ({
4521
4539
  isStreaming: P,
4522
4540
  error: j,
4523
- connectionState: j ? "error" : P ? M ? "connected" : "connecting" : "idle",
4541
+ connectionState: j ? "error" : P ? C ? "connected" : "connecting" : "idle",
4524
4542
  messages: L,
4525
4543
  activeMessageId: F,
4526
- submit: z,
4527
- stop: g,
4544
+ submit: N,
4545
+ stop: p,
4528
4546
  interrupt: c,
4529
4547
  resume: () => Promise.resolve(),
4530
- goto: (h, U) => Promise.resolve(),
4548
+ goto: (y, U) => Promise.resolve(),
4531
4549
  clearError: () => {
4532
4550
  }
4533
4551
  // TODO: Implement error clearing
4534
4552
  }),
4535
- [P, j, z, g, c, M, L]
4553
+ [P, j, N, p, c, C, L]
4536
4554
  );
4537
4555
  return /* @__PURE__ */ ie(qt.Provider, { value: H, children: e });
4538
4556
  }
@@ -4591,28 +4609,28 @@ function po({
4591
4609
  onThreadChange: c,
4592
4610
  onToolEnd: l,
4593
4611
  onUpdateEvent: d,
4594
- onCustomEvent: m,
4595
- onMetadataEvent: y,
4612
+ onCustomEvent: g,
4613
+ onMetadataEvent: m,
4596
4614
  onFinish: v
4597
4615
  }) {
4598
- const f = Dr(t), [I, p] = $(!1), S = pe(i), x = pe(u), E = pe(a), k = pe(c), b = pe(l), A = pe(d), g = pe(m), w = pe(y), P = pe(v), j = Y(
4616
+ const f = Dr(t), [I, A] = $(!1), M = pe(i), x = pe(u), k = pe(a), b = pe(c), h = pe(l), T = pe(d), p = pe(g), w = pe(m), P = pe(v), j = Y(
4599
4617
  () => ({
4600
- onError: S,
4618
+ onError: M,
4601
4619
  onAuthError: x,
4602
- onConnectionError: E,
4603
- onToolEnd: b,
4604
- onUpdateEvent: A,
4605
- onCustomEvent: g,
4620
+ onConnectionError: k,
4621
+ onToolEnd: h,
4622
+ onUpdateEvent: T,
4623
+ onCustomEvent: p,
4606
4624
  onMetadataEvent: w,
4607
4625
  onFinish: P
4608
4626
  }),
4609
4627
  [
4610
- S,
4628
+ M,
4611
4629
  x,
4612
- E,
4613
- b,
4614
- A,
4615
- g,
4630
+ k,
4631
+ h,
4632
+ T,
4633
+ p,
4616
4634
  w,
4617
4635
  P
4618
4636
  ]
@@ -4621,8 +4639,8 @@ function po({
4621
4639
  mr,
4622
4640
  {
4623
4641
  initialThreadId: n,
4624
- onError: S,
4625
- onThreadChange: k,
4642
+ onError: M,
4643
+ onThreadChange: b,
4626
4644
  children: /* @__PURE__ */ ie(
4627
4645
  Ur,
4628
4646
  {
@@ -4630,13 +4648,13 @@ function po({
4630
4648
  initialCheckpointId: r,
4631
4649
  initialCheckpointNs: o,
4632
4650
  autoLoadInitial: s,
4633
- onError: S,
4651
+ onError: M,
4634
4652
  isStreaming: I,
4635
4653
  children: /* @__PURE__ */ ie(
4636
4654
  Br,
4637
4655
  {
4638
4656
  ...j,
4639
- onStreamingChange: p,
4657
+ onStreamingChange: A,
4640
4658
  children: e
4641
4659
  }
4642
4660
  )
@@ -4747,11 +4765,11 @@ function Jr() {
4747
4765
  function go(e) {
4748
4766
  const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Me(), { toast: o } = Jr(), [s, a] = $({}), [i, u] = $(null), [c, l] = $(!1), d = _(() => {
4749
4767
  l(!1), u(null);
4750
- }, []), m = _((v) => {
4768
+ }, []), g = _((v) => {
4751
4769
  u(v), l(!0);
4752
- }, []), y = _(
4770
+ }, []), m = _(
4753
4771
  async (v, f, I) => {
4754
- var p, S;
4772
+ var A, M;
4755
4773
  if (!t) {
4756
4774
  v.preventDefault();
4757
4775
  return;
@@ -4761,56 +4779,56 @@ function go(e) {
4761
4779
  return;
4762
4780
  }
4763
4781
  try {
4764
- const x = String(f.url ?? ""), E = x.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);
4765
- if (E) {
4782
+ const x = String(f.url ?? ""), k = x.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);
4783
+ if (k) {
4766
4784
  v.preventDefault();
4767
- const k = E[1], b = f.name || `file_${k}`, A = f.mimeType || "application/octet-stream";
4768
- m({ id: k, name: b, mimeType: A });
4785
+ const b = k[1], h = f.name || `file_${b}`, T = f.mimeType || "application/octet-stream";
4786
+ g({ id: b, name: h, mimeType: T });
4769
4787
  return;
4770
4788
  }
4771
4789
  if (x.startsWith("data:")) {
4772
- v.preventDefault(), a((b) => ({ ...b, [I]: !0 }));
4773
- const k = o({ title: "Fetching file...", description: "", open: !0 });
4790
+ v.preventDefault(), a((h) => ({ ...h, [I]: !0 }));
4791
+ const b = o({ title: "Fetching file...", description: "", open: !0 });
4774
4792
  try {
4775
- const b = await r.listFiles(n ?? void 0);
4776
- if (!b || !Array.isArray(b))
4793
+ const h = await r.listFiles(n ?? void 0);
4794
+ if (!h || !Array.isArray(h))
4777
4795
  throw new Error("Invalid file list response");
4778
- const A = b.find((g) => !g || typeof g != "object" || !((g.filename ?? "") === (f.name ?? "")) ? !1 : typeof f.size == "number" && typeof g.size == "number" ? g.size === f.size : !0);
4779
- if (!(A != null && A.id))
4796
+ const T = h.find((p) => !p || typeof p != "object" || !((p.filename ?? "") === (f.name ?? "")) ? !1 : typeof f.size == "number" && typeof p.size == "number" ? p.size === f.size : !0);
4797
+ if (!(T != null && T.id))
4780
4798
  throw new Error(`File "${f.name}" is not yet available on the server`);
4781
- if (!A.id || !A.filename)
4799
+ if (!T.id || !T.filename)
4782
4800
  throw new Error("Invalid file data received from server");
4783
- m({
4784
- id: A.id,
4785
- name: f.name || A.filename || `file_${A.id}`,
4786
- mimeType: f.mimeType || A.mime_type || "application/octet-stream"
4787
- }), (p = k.update) == null || p.call(k, {
4788
- id: k.id,
4801
+ g({
4802
+ id: T.id,
4803
+ name: f.name || T.filename || `file_${T.id}`,
4804
+ mimeType: f.mimeType || T.mime_type || "application/octet-stream"
4805
+ }), (A = b.update) == null || A.call(b, {
4806
+ id: b.id,
4789
4807
  title: "Success",
4790
4808
  description: `Opened ${f.name}`,
4791
4809
  open: !0
4792
4810
  });
4793
- } catch (b) {
4794
- console.error("Failed to fetch server file:", b);
4795
- const A = b instanceof Error ? b.message : "Unknown error occurred";
4796
- (S = k.update) == null || S.call(k, { id: k.id, title: "Failed", description: A }), o({
4811
+ } catch (h) {
4812
+ console.error("Failed to fetch server file:", h);
4813
+ const T = h instanceof Error ? h.message : "Unknown error occurred";
4814
+ (M = b.update) == null || M.call(b, { id: b.id, title: "Failed", description: T }), o({
4797
4815
  title: "Failed to fetch file",
4798
- description: A,
4816
+ description: T,
4799
4817
  open: !0
4800
4818
  });
4801
4819
  } finally {
4802
- a((b) => ({ ...b, [I]: !1 }));
4820
+ a((h) => ({ ...h, [I]: !1 }));
4803
4821
  }
4804
4822
  }
4805
4823
  } catch (x) {
4806
- console.error("File click error:", x), a((E) => ({ ...E, [I]: !1 }));
4824
+ console.error("File click error:", x), a((k) => ({ ...k, [I]: !1 }));
4807
4825
  }
4808
4826
  },
4809
- [t, s, o, n, m]
4827
+ [t, s, o, n, g]
4810
4828
  );
4811
4829
  return {
4812
4830
  uploadingFiles: s,
4813
- handleFileClick: y,
4831
+ handleFileClick: m,
4814
4832
  fileViewerOpen: c,
4815
4833
  currentFileInfo: i,
4816
4834
  closeFileViewer: d
@@ -4889,24 +4907,24 @@ function yo(e) {
4889
4907
  }, [e]);
4890
4908
  }
4891
4909
  function Yr(e) {
4892
- var M, O;
4910
+ var C, O;
4893
4911
  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: u } = r || {
4894
4912
  currentThreadId: null,
4895
4913
  setCurrentThreadId: () => {
4896
4914
  },
4897
4915
  actions: {}
4898
- }, c = !!t && t !== a, [l, d] = $([]), m = _((F) => {
4916
+ }, c = !!t && t !== a, [l, d] = $([]), g = _((F) => {
4899
4917
  d(F);
4900
4918
  }, []), {
4901
- isLoadingThread: y,
4919
+ isLoadingThread: m,
4902
4920
  threadStateError: v,
4903
4921
  threadCheckpoints: f,
4904
4922
  isLoadingHistory: I,
4905
- loadThread: p
4923
+ loadThread: A
4906
4924
  } = $t({
4907
4925
  api: Me().chatApi,
4908
4926
  fileApi: Me().fileApi,
4909
- seed: m,
4927
+ seed: g,
4910
4928
  currentThreadId: c ? t : null,
4911
4929
  initialThreadId: c ? t : null,
4912
4930
  isStreaming: !1,
@@ -4916,17 +4934,17 @@ function Yr(e) {
4916
4934
  X(() => {
4917
4935
  !c && !n && a && (o != null && o.loadThread) && o.loadThread(a);
4918
4936
  }, [c, n, a, o == null ? void 0 : o.loadThread]);
4919
- const S = Y(() => {
4937
+ const M = Y(() => {
4920
4938
  var F;
4921
4939
  return ((F = f[0]) == null ? void 0 : F.values) || {};
4922
- }, [f]), x = Y(() => ({ timeline: [], messagePreviews: {} }), []), E = t || a, k = c ? y ? "loading" : "idle" : (o == null ? void 0 : o.status) || "idle", b = c ? l : (s == null ? void 0 : s.messages) || [], A = c ? y : (o == null ? void 0 : o.isLoading) || !1, g = c ? I : (o == null ? void 0 : o.isLoadingHistory) || !1, w = c ? S : (o == null ? void 0 : o.values) || {}, P = c ? {} : (o == null ? void 0 : o.taskMessagesByScope) || {}, j = c ? v : (s == null ? void 0 : s.error) || (o == null ? void 0 : o.error) || null;
4940
+ }, [f]), x = Y(() => ({ timeline: [], messagePreviews: {} }), []), k = t || a, b = c ? m ? "loading" : "idle" : (o == null ? void 0 : o.status) || "idle", h = c ? l : (s == null ? void 0 : s.messages) || [], T = c ? m : (o == null ? void 0 : o.isLoading) || !1, p = c ? I : (o == null ? void 0 : o.isLoadingHistory) || !1, w = c ? M : (o == null ? void 0 : o.values) || {}, P = c ? {} : (o == null ? void 0 : o.taskMessagesByScope) || {}, j = c ? v : (s == null ? void 0 : s.error) || (o == null ? void 0 : o.error) || null;
4923
4941
  return {
4924
4942
  // UNIFIED: Single thread ID concept
4925
- threadId: E,
4926
- status: k,
4927
- messages: b,
4928
- isLoading: A,
4929
- isHistoryLoading: g,
4943
+ threadId: k,
4944
+ status: b,
4945
+ messages: h,
4946
+ isLoading: T,
4947
+ isHistoryLoading: p,
4930
4948
  error: j,
4931
4949
  // Values & Metadata
4932
4950
  values: w,
@@ -4949,7 +4967,7 @@ function Yr(e) {
4949
4967
  // Streaming Status
4950
4968
  // Even in standalone mode, allow streaming state/stop if a stream context exists.
4951
4969
  isStreaming: (s == null ? void 0 : s.isStreaming) || !1,
4952
- activeMessageId: c ? null : ((M = o == null ? void 0 : o.metadata) == null ? void 0 : M.assemblingMessageId) || (s == null ? void 0 : s.activeMessageId) || null,
4970
+ activeMessageId: c ? null : ((C = o == null ? void 0 : o.metadata) == null ? void 0 : C.assemblingMessageId) || (s == null ? void 0 : s.activeMessageId) || null,
4953
4971
  connectionState: (s == null ? void 0 : s.connectionState) || "disconnected",
4954
4972
  streamingAssistantId: !c && (s != null && s.isStreaming) && ((O = o == null ? void 0 : o.metadata) != null && O.assemblingMessageId) ? o.metadata.assemblingMessageId : null,
4955
4973
  // Actions
@@ -4962,7 +4980,7 @@ function Yr(e) {
4962
4980
  }),
4963
4981
  setCurrentThreadId: i,
4964
4982
  loadHistory: c ? async () => {
4965
- t && await p(t);
4983
+ t && await A(t);
4966
4984
  } : async () => {
4967
4985
  },
4968
4986
  onEvent: c ? () => {
@@ -4989,37 +5007,37 @@ function ho({
4989
5007
  setPendingAssistantResponse: c,
4990
5008
  project: l,
4991
5009
  onEvent: d,
4992
- threadId: m,
4993
- clearComposerOnSend: y = !0
5010
+ threadId: g,
5011
+ clearComposerOnSend: m = !0
4994
5012
  }) {
4995
- const { messages: v } = Yr(), [f, I] = $(null), [p, S] = $(""), [x, E] = $(null), [k, b] = $(null), [A, g] = $(!1), [w, P] = $(""), j = W(w), M = W(null);
5013
+ const { messages: v } = Yr(), [f, I] = $(null), [A, M] = $(""), [x, k] = $(null), [b, h] = $(null), [T, p] = $(!1), [w, P] = $(""), j = W(w), C = W(null);
4996
5014
  X(() => {
4997
5015
  if (!f)
4998
- if (m) {
4999
- const h = localStorage.getItem(Ge(m));
5000
- P(h || "");
5016
+ if (g) {
5017
+ const y = localStorage.getItem(Ge(g));
5018
+ P(y || "");
5001
5019
  } else
5002
5020
  P("");
5003
- }, [m, f]);
5004
- const O = _((h) => {
5005
- P(h), !f && m && localStorage.setItem(Ge(m), h);
5006
- }, [m, f]);
5021
+ }, [g, f]);
5022
+ const O = _((y) => {
5023
+ P(y), !f && g && localStorage.setItem(Ge(g), y);
5024
+ }, [g, f]);
5007
5025
  X(() => {
5008
5026
  j.current = w;
5009
5027
  }, [w]), X(() => {
5010
5028
  if (!f) {
5011
- M.current = null;
5029
+ C.current = null;
5012
5030
  return;
5013
5031
  }
5014
- M.current === null && (M.current = j.current), O(p ?? "");
5015
- }, [p, f, O]);
5032
+ C.current === null && (C.current = j.current), O(A ?? "");
5033
+ }, [A, f, O]);
5016
5034
  const F = _(
5017
- (h) => {
5018
- O(h);
5035
+ (y) => {
5036
+ O(y);
5019
5037
  },
5020
5038
  [O]
5021
- ), C = async (h, U) => {
5022
- const T = Array.isArray(U) ? { files: U } : U ?? {}, J = T.files ?? [], V = T.contentParts ?? [], q = h.trim();
5039
+ ), E = async (y, U) => {
5040
+ const S = Array.isArray(U) ? { files: U } : U ?? {}, J = S.files ?? [], V = S.contentParts ?? [], q = y.trim();
5023
5041
  if (!(!q && J.length === 0 && V.length === 0))
5024
5042
  try {
5025
5043
  const ee = J.map(async (Q) => {
@@ -5056,18 +5074,18 @@ function ho({
5056
5074
  config: t.config
5057
5075
  },
5058
5076
  d ? { onEvent: d } : void 0
5059
- ), o == null || o(q), c(!0), y && (m && localStorage.removeItem(Ge(m)), O("")), b(null), I(null), S(""), E(null);
5077
+ ), o == null || o(q), c(!0), m && (g && localStorage.removeItem(Ge(g)), O("")), h(null), I(null), M(""), k(null);
5060
5078
  } catch (ee) {
5061
5079
  const re = (ee == null ? void 0 : ee.message) || "Failed to send message";
5062
- b(re), a == null || a(re), c(!1);
5080
+ h(re), a == null || a(re), c(!1);
5063
5081
  }
5064
- }, B = (h, U) => {
5065
- U || C(h, { files: [] });
5066
- }, N = _(
5067
- async (h) => {
5082
+ }, B = (y, U) => {
5083
+ U || E(y, { files: [] });
5084
+ }, z = _(
5085
+ async (y) => {
5068
5086
  await e(
5069
5087
  {
5070
- attachments: [h],
5088
+ attachments: [y],
5071
5089
  payload: t.payload,
5072
5090
  checkpointId: n ?? void 0,
5073
5091
  checkpointNs: r ?? void 0,
@@ -5075,34 +5093,34 @@ function ho({
5075
5093
  config: t.config
5076
5094
  },
5077
5095
  d ? { onEvent: d } : void 0
5078
- ), s == null || s({ file: h });
5096
+ ), s == null || s({ file: y });
5079
5097
  },
5080
5098
  [n, r, t, s, e]
5081
5099
  ), K = _(
5082
- (h, U, T) => {
5083
- i && (M.current = w, I(h), S(U), E({
5084
- checkpointId: (T == null ? void 0 : T.checkpointId) ?? null,
5085
- checkpointNs: (T == null ? void 0 : T.checkpointNs) ?? null
5086
- }), b(null));
5100
+ (y, U, S) => {
5101
+ i && (C.current = w, I(y), M(U), k({
5102
+ checkpointId: (S == null ? void 0 : S.checkpointId) ?? null,
5103
+ checkpointNs: (S == null ? void 0 : S.checkpointNs) ?? null
5104
+ }), h(null));
5087
5105
  },
5088
5106
  [w, i]
5089
- ), z = _(() => {
5090
- I(null), S(""), E(null), b(null);
5091
- const h = M.current;
5092
- h !== null && P(h), M.current = null;
5093
- }, []), L = _((h) => {
5107
+ ), N = _(() => {
5108
+ I(null), M(""), k(null), h(null);
5109
+ const y = C.current;
5110
+ y !== null && P(y), C.current = null;
5111
+ }, []), L = _((y) => {
5094
5112
  let U = null;
5095
- for (let q = h - 1; q >= 0; q--)
5113
+ for (let q = y - 1; q >= 0; q--)
5096
5114
  if (u[q].role === "user") {
5097
5115
  U = u[q];
5098
5116
  break;
5099
5117
  }
5100
5118
  if (!U) return;
5101
- const T = Array.isArray(U.content) ? U.content : [], V = T.filter((q) => (q == null ? void 0 : q.type) === "text").map((q) => q.text).join("") || (() => {
5119
+ const S = Array.isArray(U.content) ? U.content : [], V = S.filter((q) => (q == null ? void 0 : q.type) === "text").map((q) => q.text).join("") || (() => {
5102
5120
  try {
5103
- return JSON.stringify(T, null, 2);
5121
+ return JSON.stringify(S, null, 2);
5104
5122
  } catch {
5105
- return String(T);
5123
+ return String(S);
5106
5124
  }
5107
5125
  })();
5108
5126
  V && e(
@@ -5120,18 +5138,18 @@ function ho({
5120
5138
  }, [u, e, n, r, t]);
5121
5139
  return {
5122
5140
  editingMessageId: f,
5123
- editingInitialValue: p,
5124
- inputError: k,
5125
- setInputError: b,
5126
- dismissError: A,
5127
- setDismissError: g,
5141
+ editingInitialValue: A,
5142
+ inputError: b,
5143
+ setInputError: h,
5144
+ dismissError: T,
5145
+ setDismissError: p,
5128
5146
  composerValue: w,
5129
5147
  handleComposerChange: F,
5130
- handleSendMessage: C,
5148
+ handleSendMessage: E,
5131
5149
  handleQuickPrompt: B,
5132
- handleExcelUpload: N,
5150
+ handleExcelUpload: z,
5133
5151
  startEditing: K,
5134
- cancelEditing: z,
5152
+ cancelEditing: N,
5135
5153
  handleRegenerateCb: L,
5136
5154
  displayMessages: v
5137
5155
  };
@@ -5187,7 +5205,7 @@ export {
5187
5205
  so as hasContent,
5188
5206
  mt as hydrateHistorySnapshots,
5189
5207
  Ct as isFileLike,
5190
- Nn as looksLikeMarkdown,
5208
+ zn as looksLikeMarkdown,
5191
5209
  lo as messageSignature,
5192
5210
  io as normalizeInterruptId,
5193
5211
  _t as onChatTokenChanged,