@teodorruskvi/chat-core 0.1.50 → 0.1.51

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
@@ -5,17 +5,17 @@ import { jsx as ie } from "react/jsx-runtime";
5
5
  import * as it from "react";
6
6
  import { createContext as Ce, useContext as Ue, useState as $, useRef as W, useEffect as X, useCallback as _, useMemo as Y, useReducer as Wt } from "react";
7
7
  import Jt, { isCancel as Xt } from "axios";
8
- function vt(e) {
8
+ function It(e) {
9
9
  var t, n, r = "";
10
10
  if (typeof e == "string" || typeof e == "number") r += e;
11
11
  else if (typeof e == "object") if (Array.isArray(e)) {
12
- var o = e.length;
13
- for (t = 0; t < o; t++) e[t] && (n = vt(e[t])) && (r && (r += " "), r += n);
12
+ var s = e.length;
13
+ for (t = 0; t < s; t++) e[t] && (n = It(e[t])) && (r && (r += " "), r += n);
14
14
  } else for (n in e) e[n] && (r && (r += " "), r += n);
15
15
  return r;
16
16
  }
17
17
  function Qt() {
18
- for (var e, t, n = 0, r = "", o = arguments.length; n < o; n++) (e = arguments[n]) && (t = vt(e)) && (r && (r += " "), r += t);
18
+ for (var e, t, n = 0, r = "", s = arguments.length; n < s; n++) (e = arguments[n]) && (t = It(e)) && (r && (r += " "), r += t);
19
19
  return r;
20
20
  }
21
21
  const et = "-", Yt = (e) => {
@@ -26,26 +26,26 @@ const et = "-", Yt = (e) => {
26
26
  return {
27
27
  getClassGroupId: (a) => {
28
28
  const i = a.split(et);
29
- return i[0] === "" && i.length !== 1 && i.shift(), It(i, t) || Zt(a);
29
+ return i[0] === "" && i.length !== 1 && i.shift(), vt(i, t) || Zt(a);
30
30
  },
31
31
  getConflictingClassGroupIds: (a, i) => {
32
32
  const u = n[a] || [];
33
33
  return i && r[a] ? [...u, ...r[a]] : u;
34
34
  }
35
35
  };
36
- }, It = (e, t) => {
36
+ }, vt = (e, t) => {
37
37
  var a;
38
38
  if (e.length === 0)
39
39
  return t.classGroupId;
40
- const n = e[0], r = t.nextPart.get(n), o = r ? It(e.slice(1), r) : void 0;
41
- if (o)
42
- return o;
40
+ const n = e[0], r = t.nextPart.get(n), s = r ? vt(e.slice(1), r) : void 0;
41
+ if (s)
42
+ return s;
43
43
  if (t.validators.length === 0)
44
44
  return;
45
- const s = e.join(et);
45
+ const o = e.join(et);
46
46
  return (a = t.validators.find(({
47
47
  validator: i
48
- }) => i(s))) == null ? void 0 : a.classGroupId;
48
+ }) => i(o))) == null ? void 0 : a.classGroupId;
49
49
  }, ct = /^\[(.+)\]$/, Zt = (e) => {
50
50
  if (ct.test(e)) {
51
51
  const t = ct.exec(e)[1], n = t == null ? void 0 : t.substring(0, t.indexOf(":"));
@@ -60,29 +60,29 @@ const et = "-", Yt = (e) => {
60
60
  nextPart: /* @__PURE__ */ new Map(),
61
61
  validators: []
62
62
  };
63
- return nn(Object.entries(e.classGroups), n).forEach(([s, a]) => {
64
- Xe(a, r, s, t);
63
+ return nn(Object.entries(e.classGroups), n).forEach(([o, a]) => {
64
+ Xe(a, r, o, t);
65
65
  }), r;
66
66
  }, Xe = (e, t, n, r) => {
67
- e.forEach((o) => {
68
- if (typeof o == "string") {
69
- const s = o === "" ? t : lt(t, o);
70
- s.classGroupId = n;
67
+ e.forEach((s) => {
68
+ if (typeof s == "string") {
69
+ const o = s === "" ? t : lt(t, s);
70
+ o.classGroupId = n;
71
71
  return;
72
72
  }
73
- if (typeof o == "function") {
74
- if (tn(o)) {
75
- Xe(o(r), t, n, r);
73
+ if (typeof s == "function") {
74
+ if (tn(s)) {
75
+ Xe(s(r), t, n, r);
76
76
  return;
77
77
  }
78
78
  t.validators.push({
79
- validator: o,
79
+ validator: s,
80
80
  classGroupId: n
81
81
  });
82
82
  return;
83
83
  }
84
- Object.entries(o).forEach(([s, a]) => {
85
- Xe(a, lt(t, s), n, r);
84
+ Object.entries(s).forEach(([o, a]) => {
85
+ Xe(a, lt(t, o), n, r);
86
86
  });
87
87
  });
88
88
  }, lt = (e, t) => {
@@ -94,8 +94,8 @@ const et = "-", Yt = (e) => {
94
94
  }), n = n.nextPart.get(r);
95
95
  }), n;
96
96
  }, tn = (e) => e.isThemeGetter, nn = (e, t) => t ? e.map(([n, r]) => {
97
- const o = r.map((s) => typeof s == "string" ? t + s : typeof s == "object" ? Object.fromEntries(Object.entries(s).map(([a, i]) => [t + a, i])) : s);
98
- return [n, o];
97
+ const s = r.map((o) => typeof o == "string" ? t + o : typeof o == "object" ? Object.fromEntries(Object.entries(o).map(([a, i]) => [t + a, i])) : o);
98
+ return [n, s];
99
99
  }) : e, rn = (e) => {
100
100
  if (e < 1)
101
101
  return {
@@ -105,47 +105,47 @@ const et = "-", Yt = (e) => {
105
105
  }
106
106
  };
107
107
  let t = 0, n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
108
- const o = (s, a) => {
109
- n.set(s, a), t++, t > e && (t = 0, r = n, n = /* @__PURE__ */ new Map());
108
+ const s = (o, a) => {
109
+ n.set(o, a), t++, t > e && (t = 0, r = n, n = /* @__PURE__ */ new Map());
110
110
  };
111
111
  return {
112
- get(s) {
113
- let a = n.get(s);
112
+ get(o) {
113
+ let a = n.get(o);
114
114
  if (a !== void 0)
115
115
  return a;
116
- if ((a = r.get(s)) !== void 0)
117
- return o(s, a), a;
116
+ if ((a = r.get(o)) !== void 0)
117
+ return s(o, a), a;
118
118
  },
119
- set(s, a) {
120
- n.has(s) ? n.set(s, a) : o(s, a);
119
+ set(o, a) {
120
+ n.has(o) ? n.set(o, a) : s(o, a);
121
121
  }
122
122
  };
123
- }, At = "!", on = (e) => {
123
+ }, xt = "!", sn = (e) => {
124
124
  const {
125
125
  separator: t,
126
126
  experimentalParseClassName: n
127
- } = e, r = t.length === 1, o = t[0], s = t.length, a = (i) => {
127
+ } = e, r = t.length === 1, s = t[0], o = t.length, a = (i) => {
128
128
  const u = [];
129
129
  let c = 0, l = 0, d;
130
- for (let I = 0; I < i.length; I++) {
131
- let A = i[I];
130
+ for (let v = 0; v < i.length; v++) {
131
+ let x = i[v];
132
132
  if (c === 0) {
133
- if (A === o && (r || i.slice(I, I + s) === t)) {
134
- u.push(i.slice(l, I)), l = I + s;
133
+ if (x === s && (r || i.slice(v, v + o) === t)) {
134
+ u.push(i.slice(l, v)), l = v + o;
135
135
  continue;
136
136
  }
137
- if (A === "/") {
138
- d = I;
137
+ if (x === "/") {
138
+ d = v;
139
139
  continue;
140
140
  }
141
141
  }
142
- A === "[" ? c++ : A === "]" && c--;
142
+ x === "[" ? c++ : x === "]" && c--;
143
143
  }
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;
144
+ const g = u.length === 0 ? i : i.substring(l), m = g.startsWith(xt), I = m ? g.substring(1) : g, f = d && d > l ? d - l : void 0;
145
145
  return {
146
146
  modifiers: u,
147
147
  hasImportantModifier: m,
148
- baseClassName: v,
148
+ baseClassName: I,
149
149
  maybePostfixModifierPosition: f
150
150
  };
151
151
  };
@@ -153,7 +153,7 @@ const et = "-", Yt = (e) => {
153
153
  className: i,
154
154
  parseClassName: a
155
155
  }) : a;
156
- }, sn = (e) => {
156
+ }, on = (e) => {
157
157
  if (e.length <= 1)
158
158
  return e;
159
159
  const t = [];
@@ -163,14 +163,14 @@ const et = "-", Yt = (e) => {
163
163
  }), t.push(...n.sort()), t;
164
164
  }, an = (e) => ({
165
165
  cache: rn(e.cacheSize),
166
- parseClassName: on(e),
166
+ parseClassName: sn(e),
167
167
  ...Yt(e)
168
168
  }), cn = /\s+/, ln = (e, t) => {
169
169
  const {
170
170
  parseClassName: n,
171
171
  getClassGroupId: r,
172
- getConflictingClassGroupIds: o
173
- } = t, s = [], a = e.trim().split(cn);
172
+ getConflictingClassGroupIds: s
173
+ } = t, o = [], a = e.trim().split(cn);
174
174
  let i = "";
175
175
  for (let u = a.length - 1; u >= 0; u -= 1) {
176
176
  const c = a[u], {
@@ -179,9 +179,9 @@ const et = "-", Yt = (e) => {
179
179
  baseClassName: g,
180
180
  maybePostfixModifierPosition: m
181
181
  } = n(c);
182
- let v = !!m, f = r(v ? g.substring(0, m) : g);
182
+ let I = !!m, f = r(I ? g.substring(0, m) : g);
183
183
  if (!f) {
184
- if (!v) {
184
+ if (!I) {
185
185
  i = c + (i.length > 0 ? " " + i : i);
186
186
  continue;
187
187
  }
@@ -189,16 +189,16 @@ const et = "-", Yt = (e) => {
189
189
  i = c + (i.length > 0 ? " " + i : i);
190
190
  continue;
191
191
  }
192
- v = !1;
192
+ I = !1;
193
193
  }
194
- const I = sn(l).join(":"), A = d ? I + At : I, M = A + f;
195
- if (s.includes(M))
194
+ const v = on(l).join(":"), x = d ? v + xt : v, M = x + f;
195
+ if (o.includes(M))
196
196
  continue;
197
- s.push(M);
198
- const x = o(f, v);
199
- for (let k = 0; k < x.length; ++k) {
200
- const b = x[k];
201
- s.push(A + b);
197
+ o.push(M);
198
+ const A = s(f, I);
199
+ for (let k = 0; k < A.length; ++k) {
200
+ const b = A[k];
201
+ o.push(x + b);
202
202
  }
203
203
  i = c + (i.length > 0 ? " " + i : i);
204
204
  }
@@ -207,38 +207,38 @@ const et = "-", Yt = (e) => {
207
207
  function un() {
208
208
  let e = 0, t, n, r = "";
209
209
  for (; e < arguments.length; )
210
- (t = arguments[e++]) && (n = xt(t)) && (r && (r += " "), r += n);
210
+ (t = arguments[e++]) && (n = At(t)) && (r && (r += " "), r += n);
211
211
  return r;
212
212
  }
213
- const xt = (e) => {
213
+ const At = (e) => {
214
214
  if (typeof e == "string")
215
215
  return e;
216
216
  let t, n = "";
217
217
  for (let r = 0; r < e.length; r++)
218
- e[r] && (t = xt(e[r])) && (n && (n += " "), n += t);
218
+ e[r] && (t = At(e[r])) && (n && (n += " "), n += t);
219
219
  return n;
220
220
  };
221
221
  function dn(e, ...t) {
222
- let n, r, o, s = a;
222
+ let n, r, s, o = a;
223
223
  function a(u) {
224
224
  const c = t.reduce((l, d) => d(l), e());
225
- return n = an(c), r = n.cache.get, o = n.cache.set, s = i, i(u);
225
+ return n = an(c), r = n.cache.get, s = n.cache.set, o = i, i(u);
226
226
  }
227
227
  function i(u) {
228
228
  const c = r(u);
229
229
  if (c)
230
230
  return c;
231
231
  const l = ln(u, n);
232
- return o(u, l), l;
232
+ return s(u, l), l;
233
233
  }
234
234
  return function() {
235
- return s(un.apply(null, arguments));
235
+ return o(un.apply(null, arguments));
236
236
  };
237
237
  }
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), ze = () => !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"]), In = (e) => Ee(e, kn, St), vn = (e) => Ee(e, "position", St), xn = /* @__PURE__ */ new Set(["image", "url"]), An = (e) => Ee(e, xn, Cn), Tn = (e) => Ee(e, "", Mn), 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,7 +247,7 @@ 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"), 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];
250
+ const e = D("colors"), t = D("spacing"), n = D("blur"), r = D("brightness"), s = D("borderColor"), o = 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"), I = D("gradientColorStopPositions"), f = D("inset"), v = D("margin"), x = D("opacity"), M = D("padding"), A = 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: ":",
@@ -778,63 +778,63 @@ const D = (e) => {
778
778
  * @see https://tailwindcss.com/docs/margin
779
779
  */
780
780
  m: [{
781
- m: [I]
781
+ m: [v]
782
782
  }],
783
783
  /**
784
784
  * Margin X
785
785
  * @see https://tailwindcss.com/docs/margin
786
786
  */
787
787
  mx: [{
788
- mx: [I]
788
+ mx: [v]
789
789
  }],
790
790
  /**
791
791
  * Margin Y
792
792
  * @see https://tailwindcss.com/docs/margin
793
793
  */
794
794
  my: [{
795
- my: [I]
795
+ my: [v]
796
796
  }],
797
797
  /**
798
798
  * Margin Start
799
799
  * @see https://tailwindcss.com/docs/margin
800
800
  */
801
801
  ms: [{
802
- ms: [I]
802
+ ms: [v]
803
803
  }],
804
804
  /**
805
805
  * Margin End
806
806
  * @see https://tailwindcss.com/docs/margin
807
807
  */
808
808
  me: [{
809
- me: [I]
809
+ me: [v]
810
810
  }],
811
811
  /**
812
812
  * Margin Top
813
813
  * @see https://tailwindcss.com/docs/margin
814
814
  */
815
815
  mt: [{
816
- mt: [I]
816
+ mt: [v]
817
817
  }],
818
818
  /**
819
819
  * Margin Right
820
820
  * @see https://tailwindcss.com/docs/margin
821
821
  */
822
822
  mr: [{
823
- mr: [I]
823
+ mr: [v]
824
824
  }],
825
825
  /**
826
826
  * Margin Bottom
827
827
  * @see https://tailwindcss.com/docs/margin
828
828
  */
829
829
  mb: [{
830
- mb: [I]
830
+ mb: [v]
831
831
  }],
832
832
  /**
833
833
  * Margin Left
834
834
  * @see https://tailwindcss.com/docs/margin
835
835
  */
836
836
  ml: [{
837
- ml: [I]
837
+ ml: [v]
838
838
  }],
839
839
  /**
840
840
  * Space Between X
@@ -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": [A]
1032
+ "placeholder-opacity": [x]
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": [A]
1053
+ "text-opacity": [x]
1054
1054
  }],
1055
1055
  /**
1056
1056
  * Text Decoration
@@ -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": [A]
1168
+ "bg-opacity": [x]
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: [...E(), In]
1182
+ bg: [...E(), vn]
1183
1183
  }],
1184
1184
  /**
1185
1185
  * Background Repeat
@@ -1195,7 +1195,7 @@ const D = (e) => {
1195
1195
  * @see https://tailwindcss.com/docs/background-size
1196
1196
  */
1197
1197
  "bg-size": [{
1198
- bg: ["auto", "cover", "contain", vn]
1198
+ bg: ["auto", "cover", "contain", In]
1199
1199
  }],
1200
1200
  /**
1201
1201
  * Background Image
@@ -1204,7 +1204,7 @@ const D = (e) => {
1204
1204
  "bg-image": [{
1205
1205
  bg: ["none", {
1206
1206
  "gradient-to": ["t", "tr", "r", "br", "b", "bl", "l", "tl"]
1207
- }, xn]
1207
+ }, An]
1208
1208
  }],
1209
1209
  /**
1210
1210
  * Background Color
@@ -1218,21 +1218,21 @@ const D = (e) => {
1218
1218
  * @see https://tailwindcss.com/docs/gradient-color-stops
1219
1219
  */
1220
1220
  "gradient-from-pos": [{
1221
- from: [v]
1221
+ from: [I]
1222
1222
  }],
1223
1223
  /**
1224
1224
  * Gradient Color Stops Via Position
1225
1225
  * @see https://tailwindcss.com/docs/gradient-color-stops
1226
1226
  */
1227
1227
  "gradient-via-pos": [{
1228
- via: [v]
1228
+ via: [I]
1229
1229
  }],
1230
1230
  /**
1231
1231
  * Gradient Color Stops To Position
1232
1232
  * @see https://tailwindcss.com/docs/gradient-color-stops
1233
1233
  */
1234
1234
  "gradient-to-pos": [{
1235
- to: [v]
1235
+ to: [I]
1236
1236
  }],
1237
1237
  /**
1238
1238
  * Gradient Color Stops From
@@ -1261,105 +1261,105 @@ const D = (e) => {
1261
1261
  * @see https://tailwindcss.com/docs/border-radius
1262
1262
  */
1263
1263
  rounded: [{
1264
- rounded: [s]
1264
+ rounded: [o]
1265
1265
  }],
1266
1266
  /**
1267
1267
  * Border Radius Start
1268
1268
  * @see https://tailwindcss.com/docs/border-radius
1269
1269
  */
1270
1270
  "rounded-s": [{
1271
- "rounded-s": [s]
1271
+ "rounded-s": [o]
1272
1272
  }],
1273
1273
  /**
1274
1274
  * Border Radius End
1275
1275
  * @see https://tailwindcss.com/docs/border-radius
1276
1276
  */
1277
1277
  "rounded-e": [{
1278
- "rounded-e": [s]
1278
+ "rounded-e": [o]
1279
1279
  }],
1280
1280
  /**
1281
1281
  * Border Radius Top
1282
1282
  * @see https://tailwindcss.com/docs/border-radius
1283
1283
  */
1284
1284
  "rounded-t": [{
1285
- "rounded-t": [s]
1285
+ "rounded-t": [o]
1286
1286
  }],
1287
1287
  /**
1288
1288
  * Border Radius Right
1289
1289
  * @see https://tailwindcss.com/docs/border-radius
1290
1290
  */
1291
1291
  "rounded-r": [{
1292
- "rounded-r": [s]
1292
+ "rounded-r": [o]
1293
1293
  }],
1294
1294
  /**
1295
1295
  * Border Radius Bottom
1296
1296
  * @see https://tailwindcss.com/docs/border-radius
1297
1297
  */
1298
1298
  "rounded-b": [{
1299
- "rounded-b": [s]
1299
+ "rounded-b": [o]
1300
1300
  }],
1301
1301
  /**
1302
1302
  * Border Radius Left
1303
1303
  * @see https://tailwindcss.com/docs/border-radius
1304
1304
  */
1305
1305
  "rounded-l": [{
1306
- "rounded-l": [s]
1306
+ "rounded-l": [o]
1307
1307
  }],
1308
1308
  /**
1309
1309
  * Border Radius Start Start
1310
1310
  * @see https://tailwindcss.com/docs/border-radius
1311
1311
  */
1312
1312
  "rounded-ss": [{
1313
- "rounded-ss": [s]
1313
+ "rounded-ss": [o]
1314
1314
  }],
1315
1315
  /**
1316
1316
  * Border Radius Start End
1317
1317
  * @see https://tailwindcss.com/docs/border-radius
1318
1318
  */
1319
1319
  "rounded-se": [{
1320
- "rounded-se": [s]
1320
+ "rounded-se": [o]
1321
1321
  }],
1322
1322
  /**
1323
1323
  * Border Radius End End
1324
1324
  * @see https://tailwindcss.com/docs/border-radius
1325
1325
  */
1326
1326
  "rounded-ee": [{
1327
- "rounded-ee": [s]
1327
+ "rounded-ee": [o]
1328
1328
  }],
1329
1329
  /**
1330
1330
  * Border Radius End Start
1331
1331
  * @see https://tailwindcss.com/docs/border-radius
1332
1332
  */
1333
1333
  "rounded-es": [{
1334
- "rounded-es": [s]
1334
+ "rounded-es": [o]
1335
1335
  }],
1336
1336
  /**
1337
1337
  * Border Radius Top Left
1338
1338
  * @see https://tailwindcss.com/docs/border-radius
1339
1339
  */
1340
1340
  "rounded-tl": [{
1341
- "rounded-tl": [s]
1341
+ "rounded-tl": [o]
1342
1342
  }],
1343
1343
  /**
1344
1344
  * Border Radius Top Right
1345
1345
  * @see https://tailwindcss.com/docs/border-radius
1346
1346
  */
1347
1347
  "rounded-tr": [{
1348
- "rounded-tr": [s]
1348
+ "rounded-tr": [o]
1349
1349
  }],
1350
1350
  /**
1351
1351
  * Border Radius Bottom Right
1352
1352
  * @see https://tailwindcss.com/docs/border-radius
1353
1353
  */
1354
1354
  "rounded-br": [{
1355
- "rounded-br": [s]
1355
+ "rounded-br": [o]
1356
1356
  }],
1357
1357
  /**
1358
1358
  * Border Radius Bottom Left
1359
1359
  * @see https://tailwindcss.com/docs/border-radius
1360
1360
  */
1361
1361
  "rounded-bl": [{
1362
- "rounded-bl": [s]
1362
+ "rounded-bl": [o]
1363
1363
  }],
1364
1364
  /**
1365
1365
  * Border Width
@@ -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": [A]
1432
+ "border-opacity": [x]
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": [A]
1470
+ "divide-opacity": [x]
1471
1471
  }],
1472
1472
  /**
1473
1473
  * Divide Style
@@ -1481,70 +1481,70 @@ const D = (e) => {
1481
1481
  * @see https://tailwindcss.com/docs/border-color
1482
1482
  */
1483
1483
  "border-color": [{
1484
- border: [o]
1484
+ border: [s]
1485
1485
  }],
1486
1486
  /**
1487
1487
  * Border Color X
1488
1488
  * @see https://tailwindcss.com/docs/border-color
1489
1489
  */
1490
1490
  "border-color-x": [{
1491
- "border-x": [o]
1491
+ "border-x": [s]
1492
1492
  }],
1493
1493
  /**
1494
1494
  * Border Color Y
1495
1495
  * @see https://tailwindcss.com/docs/border-color
1496
1496
  */
1497
1497
  "border-color-y": [{
1498
- "border-y": [o]
1498
+ "border-y": [s]
1499
1499
  }],
1500
1500
  /**
1501
1501
  * Border Color S
1502
1502
  * @see https://tailwindcss.com/docs/border-color
1503
1503
  */
1504
1504
  "border-color-s": [{
1505
- "border-s": [o]
1505
+ "border-s": [s]
1506
1506
  }],
1507
1507
  /**
1508
1508
  * Border Color E
1509
1509
  * @see https://tailwindcss.com/docs/border-color
1510
1510
  */
1511
1511
  "border-color-e": [{
1512
- "border-e": [o]
1512
+ "border-e": [s]
1513
1513
  }],
1514
1514
  /**
1515
1515
  * Border Color Top
1516
1516
  * @see https://tailwindcss.com/docs/border-color
1517
1517
  */
1518
1518
  "border-color-t": [{
1519
- "border-t": [o]
1519
+ "border-t": [s]
1520
1520
  }],
1521
1521
  /**
1522
1522
  * Border Color Right
1523
1523
  * @see https://tailwindcss.com/docs/border-color
1524
1524
  */
1525
1525
  "border-color-r": [{
1526
- "border-r": [o]
1526
+ "border-r": [s]
1527
1527
  }],
1528
1528
  /**
1529
1529
  * Border Color Bottom
1530
1530
  * @see https://tailwindcss.com/docs/border-color
1531
1531
  */
1532
1532
  "border-color-b": [{
1533
- "border-b": [o]
1533
+ "border-b": [s]
1534
1534
  }],
1535
1535
  /**
1536
1536
  * Border Color Left
1537
1537
  * @see https://tailwindcss.com/docs/border-color
1538
1538
  */
1539
1539
  "border-color-l": [{
1540
- "border-l": [o]
1540
+ "border-l": [s]
1541
1541
  }],
1542
1542
  /**
1543
1543
  * Divide Color
1544
1544
  * @see https://tailwindcss.com/docs/divide-color
1545
1545
  */
1546
1546
  "divide-color": [{
1547
- divide: [o]
1547
+ divide: [s]
1548
1548
  }],
1549
1549
  /**
1550
1550
  * Outline 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": [A]
1601
+ "ring-opacity": [x]
1602
1602
  }],
1603
1603
  /**
1604
1604
  * Ring Offset Width
@@ -1634,7 +1634,7 @@ const D = (e) => {
1634
1634
  * @see https://tailwindcss.com/docs/opacity
1635
1635
  */
1636
1636
  opacity: [{
1637
- opacity: [A]
1637
+ opacity: [x]
1638
1638
  }],
1639
1639
  /**
1640
1640
  * Mix Blend Mode
@@ -1713,7 +1713,7 @@ const D = (e) => {
1713
1713
  * @see https://tailwindcss.com/docs/saturate
1714
1714
  */
1715
1715
  saturate: [{
1716
- saturate: [x]
1716
+ saturate: [A]
1717
1717
  }],
1718
1718
  /**
1719
1719
  * Sepia
@@ -1777,14 +1777,14 @@ const D = (e) => {
1777
1777
  * @see https://tailwindcss.com/docs/backdrop-opacity
1778
1778
  */
1779
1779
  "backdrop-opacity": [{
1780
- "backdrop-opacity": [A]
1780
+ "backdrop-opacity": [x]
1781
1781
  }],
1782
1782
  /**
1783
1783
  * Backdrop Saturate
1784
1784
  * @see https://tailwindcss.com/docs/backdrop-saturate
1785
1785
  */
1786
1786
  "backdrop-saturate": [{
1787
- "backdrop-saturate": [x]
1787
+ "backdrop-saturate": [A]
1788
1788
  }],
1789
1789
  /**
1790
1790
  * Backdrop Sepia
@@ -2276,21 +2276,21 @@ const D = (e) => {
2276
2276
  }
2277
2277
  };
2278
2278
  }, Pn = /* @__PURE__ */ dn(En);
2279
- function ro(...e) {
2279
+ function rs(...e) {
2280
2280
  return Pn(Qt(e));
2281
2281
  }
2282
2282
  function _n(e) {
2283
2283
  let t = !1, n = "";
2284
- for (const o of e) {
2285
- if (o === "\\") {
2286
- n += o, t = !t;
2284
+ for (const s of e) {
2285
+ if (s === "\\") {
2286
+ n += s, t = !t;
2287
2287
  continue;
2288
2288
  }
2289
- if (o === "'" && !t) {
2289
+ if (s === "'" && !t) {
2290
2290
  n += '"';
2291
2291
  continue;
2292
2292
  }
2293
- n += o, t = !1;
2293
+ n += s, t = !1;
2294
2294
  }
2295
2295
  return n.replace(/\bTrue\b/g, "true").replace(/\bFalse\b/g, "false").replace(/\bNone\b/g, "null");
2296
2296
  }
@@ -2372,8 +2372,8 @@ function Ke(e) {
2372
2372
  if (n === "data" && typeof r == "string" && r.length > 100)
2373
2373
  t[n] = `[base64 ${r.length} chars omitted]`;
2374
2374
  else {
2375
- const o = Ke(r);
2376
- o !== void 0 && (t[n] = o);
2375
+ const s = Ke(r);
2376
+ s !== void 0 && (t[n] = s);
2377
2377
  }
2378
2378
  }
2379
2379
  if (Object.keys(t).length)
@@ -2397,15 +2397,15 @@ function Et(e) {
2397
2397
  return "";
2398
2398
  }
2399
2399
  }
2400
- function oo(e) {
2400
+ function ss(e) {
2401
2401
  const t = Et(e);
2402
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) => {
2406
2406
  try {
2407
- const o = Ke(r);
2408
- return typeof o == "string" ? o : JSON.stringify(o ?? "");
2407
+ const s = Ke(r);
2408
+ return typeof s == "string" ? s : JSON.stringify(s ?? "");
2409
2409
  } catch {
2410
2410
  return "";
2411
2411
  }
@@ -2413,7 +2413,7 @@ function Fn(e) {
2413
2413
  return n.length ? t(n.map((r) => r.text).join(`
2414
2414
  `)) : t(e);
2415
2415
  }
2416
- function so(e) {
2416
+ function os(e) {
2417
2417
  return e.content.some((t) => t.type === "text" ? t.text.trim().length > 0 : t.type === "image_url" || t.type === "file");
2418
2418
  }
2419
2419
  function ce(e) {
@@ -2448,24 +2448,24 @@ function le(e) {
2448
2448
  );
2449
2449
  }
2450
2450
  function nt(e) {
2451
- var A, M, x, k, b, h, T;
2451
+ var x, M, A, 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 ?? ((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);
2456
+ const r = t.toolCalls ?? ((x = t.additionalKwargs) == null ? void 0 : x.toolCalls), s = Array.isArray(r) ? r.map(rt) : void 0, o = Dn(t.content ?? t.parts, !!(s != null && s.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 ?? ((A = t.additionalKwargs) == null ? void 0 : A.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, I = 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,
2460
2460
  role: n,
2461
- content: s,
2461
+ content: o,
2462
2462
  createdAt: i,
2463
2463
  name: u,
2464
2464
  model: c,
2465
2465
  toolCallId: l,
2466
- toolCalls: o,
2466
+ toolCalls: s,
2467
2467
  checkpointId: m,
2468
- checkpointNs: v,
2468
+ checkpointNs: I,
2469
2469
  toolStreaming: f,
2470
2470
  additionalKwargs: d,
2471
2471
  responseMetadata: g,
@@ -2522,11 +2522,11 @@ function Vn(e, t) {
2522
2522
  if (!n) return;
2523
2523
  const r = typeof n == "string" ? n : Et(n);
2524
2524
  if (!r.trim()) return;
2525
- const o = [{ type: "text", text: r }];
2525
+ const s = [{ type: "text", text: r }];
2526
2526
  return {
2527
2527
  id: `tool-${t.id}`,
2528
2528
  role: "tool",
2529
- content: o,
2529
+ content: s,
2530
2530
  name: t.name,
2531
2531
  toolCallId: t.id,
2532
2532
  artifact: t.artifact,
@@ -2535,13 +2535,13 @@ function Vn(e, t) {
2535
2535
  }
2536
2536
  function qn(e, t = []) {
2537
2537
  if (Array.isArray(e)) {
2538
- const o = e.filter((a) => a.role === "assistant").flatMap((a) => dt(a)), s = /* @__PURE__ */ new Map();
2539
- return o.forEach((a) => s.set(a.id, a)), Array.from(s.values()).map((a) => {
2538
+ const s = e.filter((a) => a.role === "assistant").flatMap((a) => dt(a)), o = /* @__PURE__ */ new Map();
2539
+ return s.forEach((a) => o.set(a.id, a)), Array.from(o.values()).map((a) => {
2540
2540
  var d, g, m;
2541
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
- const v = ce(i);
2544
- typeof v == "string" && (a.content = v);
2543
+ const I = ce(i);
2544
+ typeof I == "string" && (a.content = I);
2545
2545
  }
2546
2546
  return {
2547
2547
  call: a,
@@ -2556,21 +2556,21 @@ function qn(e, t = []) {
2556
2556
  const n = dt(e);
2557
2557
  return n.length === 0 ? [] : n.map((r) => {
2558
2558
  var u, c, l;
2559
- const o = He(r.id, t) ?? Vn(e, r), s = Array.isArray((u = o == null ? void 0 : o.additionalKwargs) == null ? void 0 : u.toolProgress) ? (c = o == null ? void 0 : o.additionalKwargs) == null ? void 0 : c.toolProgress : void 0, a = (o == null ? void 0 : o.artifact) ?? r.artifact, i = ut(r.status) ?? ((l = o == null ? void 0 : o.additionalKwargs) != null && l.toolStreaming ? "pending" : null) ?? (o ? "completed" : "pending");
2560
- if (o && !r.content && i === "completed") {
2561
- const d = ce(o);
2559
+ const s = He(r.id, t) ?? Vn(e, r), o = Array.isArray((u = s == null ? void 0 : s.additionalKwargs) == null ? void 0 : u.toolProgress) ? (c = s == null ? void 0 : s.additionalKwargs) == null ? void 0 : c.toolProgress : void 0, a = (s == null ? void 0 : s.artifact) ?? r.artifact, i = ut(r.status) ?? ((l = s == null ? void 0 : s.additionalKwargs) != null && l.toolStreaming ? "pending" : null) ?? (s ? "completed" : "pending");
2560
+ if (s && !r.content && i === "completed") {
2561
+ const d = ce(s);
2562
2562
  typeof d == "string" && (r.content = d);
2563
2563
  }
2564
2564
  return {
2565
2565
  call: r,
2566
- result: o,
2566
+ result: s,
2567
2567
  state: i,
2568
- progress: s,
2568
+ progress: o,
2569
2569
  artifact: a
2570
2570
  };
2571
2571
  });
2572
2572
  }
2573
- function ao(e, t = []) {
2573
+ function as(e, t = []) {
2574
2574
  return qn(e, t).map((n) => n.artifact).filter((n) => !!n);
2575
2575
  }
2576
2576
  const Ne = {
@@ -2590,7 +2590,7 @@ const Qe = /* @__PURE__ */ new Set();
2590
2590
  function Pt() {
2591
2591
  return Ve;
2592
2592
  }
2593
- function ve(e) {
2593
+ function Ie(e) {
2594
2594
  Ve = e, Qe.forEach((t) => t(e));
2595
2595
  }
2596
2596
  function _t(e) {
@@ -2618,10 +2618,10 @@ ne.interceptors.response.use(
2618
2618
  (e) => {
2619
2619
  if (typeof window < "u" && (e != null && e.data))
2620
2620
  try {
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(Ne.authToken, r), ve(r)), o && localStorage.setItem(Ne.authTokenExpiresAt, o.toString()), (r || o) && window.dispatchEvent(
2621
+ const t = e.data, n = t.data || {}, r = typeof t.token == "string" && t.token || typeof n.token == "string" && n.token || null, s = 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(Ne.authToken, r), Ie(r)), s && localStorage.setItem(Ne.authTokenExpiresAt, s.toString()), (r || s) && window.dispatchEvent(
2623
2623
  new CustomEvent("smartorg:chat-token-updated", {
2624
- detail: { token: r, expiresAt: o }
2624
+ detail: { token: r, expiresAt: s }
2625
2625
  })
2626
2626
  );
2627
2627
  } catch (t) {
@@ -2631,7 +2631,7 @@ ne.interceptors.response.use(
2631
2631
  },
2632
2632
  (e) => Promise.reject(e)
2633
2633
  );
2634
- async function se(e, t) {
2634
+ async function oe(e, t) {
2635
2635
  return ne.defaults.baseURL ? (await ne.get(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
2636
2636
  }
2637
2637
  async function Ze(e, t, n) {
@@ -2660,7 +2660,7 @@ class Yn {
2660
2660
  const n = t.baseUrl.replace(/\/+$/, "");
2661
2661
  ne.defaults.baseURL = n;
2662
2662
  }
2663
- t.apiKey !== void 0 ? ve(t.apiKey) : t.getToken && ve(t.getToken()), (t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0) && Wn({
2663
+ t.apiKey !== void 0 ? Ie(t.apiKey) : t.getToken && Ie(t.getToken()), (t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0) && Wn({
2664
2664
  requestTimeoutMs: t.requestTimeoutMs,
2665
2665
  historyTimeoutMs: t.historyTimeoutMs
2666
2666
  });
@@ -2670,22 +2670,22 @@ class Yn {
2670
2670
  return Pt();
2671
2671
  }
2672
2672
  setAuthToken(t) {
2673
- ve(t);
2673
+ Ie(t);
2674
2674
  }
2675
2675
  onTokenChange(t) {
2676
2676
  return _t(t);
2677
2677
  }
2678
2678
  // ---- Thread Management ----
2679
2679
  async listThreads() {
2680
- const t = await se("/threads"), n = ae(t);
2680
+ const t = await oe("/threads"), n = ae(t);
2681
2681
  return (n == null ? void 0 : n.items) ?? (t == null ? void 0 : t.items) ?? [];
2682
2682
  }
2683
2683
  // listUsers moved to AuthApi
2684
2684
  async createThread(t, n) {
2685
2685
  const r = {};
2686
2686
  t && (r.title = t), n && (r.project = n);
2687
- const o = await Ze("/threads", Object.keys(r).length ? r : void 0);
2688
- return ae(o);
2687
+ const s = await Ze("/threads", Object.keys(r).length ? r : void 0);
2688
+ return ae(s);
2689
2689
  }
2690
2690
  async updateThread(t, n) {
2691
2691
  const r = await Xn(`/threads/${t}`, { title: n });
@@ -2696,24 +2696,24 @@ class Yn {
2696
2696
  return ae(n);
2697
2697
  }
2698
2698
  async threadInfo(t) {
2699
- const n = await se(`/threads/${t}/info`);
2699
+ const n = await oe(`/threads/${t}/info`);
2700
2700
  return ae(n);
2701
2701
  }
2702
2702
  // ---- Agents ----
2703
2703
  async listAgents() {
2704
- const t = await se("/agents"), n = ae(t);
2704
+ const t = await oe("/agents"), n = ae(t);
2705
2705
  return (n == null ? void 0 : n.items) ?? [];
2706
2706
  }
2707
2707
  async getAgent(t) {
2708
- const n = await se(`/agents/${t}`);
2708
+ const n = await oe(`/agents/${t}`);
2709
2709
  return ae(n);
2710
2710
  }
2711
2711
  async getAgentSchema(t) {
2712
- const n = await se(`/agents/${t}/schema`);
2712
+ const n = await oe(`/agents/${t}/schema`);
2713
2713
  return ae(n);
2714
2714
  }
2715
2715
  async getState(t) {
2716
- const n = await se(`/threads/${t.threadId}/state`, {
2716
+ const n = await oe(`/threads/${t.threadId}/state`, {
2717
2717
  params: {
2718
2718
  checkpoint_id: t.checkpointId,
2719
2719
  checkpoint_ns: t.checkpointNs
@@ -2722,7 +2722,7 @@ class Yn {
2722
2722
  return ae(n);
2723
2723
  }
2724
2724
  async getStateHistory(t) {
2725
- const n = await se(`/threads/${t.threadId}/state/history`, {
2725
+ const n = await oe(`/threads/${t.threadId}/state/history`, {
2726
2726
  params: {
2727
2727
  checkpoint_id: t.checkpointId,
2728
2728
  checkpoint_ns: t.checkpointNs,
@@ -2746,13 +2746,13 @@ 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
2748
2748
  async fetchFileBlob(t, n) {
2749
- return await se(t, {
2749
+ return await oe(t, {
2750
2750
  responseType: "blob",
2751
- onDownloadProgress: (o) => {
2751
+ onDownloadProgress: (s) => {
2752
2752
  try {
2753
- if (n && o.lengthComputable) {
2754
- const s = o.loaded / o.total;
2755
- n(s);
2753
+ if (n && s.lengthComputable) {
2754
+ const o = s.loaded / s.total;
2755
+ n(o);
2756
2756
  }
2757
2757
  } catch {
2758
2758
  }
@@ -2762,8 +2762,8 @@ class Zn {
2762
2762
  });
2763
2763
  }
2764
2764
  async viewFileById(t, n) {
2765
- const r = await this.fetchFileBlob(`/files/${t}/view`, n), o = URL.createObjectURL(r);
2766
- window.open(o, "_blank"), setTimeout(() => URL.revokeObjectURL(o), 6e4);
2765
+ const r = await this.fetchFileBlob(`/files/${t}/view`, n), s = URL.createObjectURL(r);
2766
+ window.open(s, "_blank"), setTimeout(() => URL.revokeObjectURL(s), 6e4);
2767
2767
  }
2768
2768
  async getFileBlob(t, n) {
2769
2769
  return await this.fetchFileBlob(`/files/${t}/view`, n);
@@ -2772,30 +2772,30 @@ class Zn {
2772
2772
  return await (await this.fetchFileBlob(`/files/${t}/view`, n)).text();
2773
2773
  }
2774
2774
  async downloadFileById(t, n) {
2775
- const r = await this.fetchFileBlob(`/files/${t}/download`, n), o = URL.createObjectURL(r);
2776
- let s = `file_${t}`;
2775
+ const r = await this.fetchFileBlob(`/files/${t}/download`, n), s = URL.createObjectURL(r);
2776
+ let o = `file_${t}`;
2777
2777
  try {
2778
- const i = await se(`/files/${t}`);
2779
- s = (i == null ? void 0 : i.filename) ?? s;
2778
+ const i = await oe(`/files/${t}`);
2779
+ o = (i == null ? void 0 : i.filename) ?? o;
2780
2780
  } catch {
2781
2781
  }
2782
2782
  const a = document.createElement("a");
2783
- a.href = o, a.download = s, document.body.appendChild(a), a.click(), a.remove(), setTimeout(() => URL.revokeObjectURL(o), 6e4);
2783
+ a.href = s, a.download = o, document.body.appendChild(a), a.click(), a.remove(), setTimeout(() => URL.revokeObjectURL(s), 6e4);
2784
2784
  }
2785
2785
  async getFileInfo(t) {
2786
- return await se(`/files/${t}`);
2786
+ return await oe(`/files/${t}`);
2787
2787
  }
2788
2788
  async listFiles(t, n = 50, r = 0) {
2789
- const o = { limit: n, offset: r };
2790
- return t && (o.thread_id = t), await se("/files", { params: o });
2789
+ const s = { limit: n, offset: r };
2790
+ return t && (s.thread_id = t), await oe("/files", { params: s });
2791
2791
  }
2792
2792
  async uploadFile(t, n, r) {
2793
- const o = new FormData();
2794
- return o.append("file", t), n && o.append("thread_id", n), await Ze("/files/upload-form", o, {
2795
- onUploadProgress: (s) => {
2793
+ const s = new FormData();
2794
+ return s.append("file", t), n && s.append("thread_id", n), await Ze("/files/upload-form", s, {
2795
+ onUploadProgress: (o) => {
2796
2796
  try {
2797
- if (r && s.lengthComputable) {
2798
- const a = s.loaded / s.total;
2797
+ if (r && o.lengthComputable) {
2798
+ const a = o.loaded / o.total;
2799
2799
  r(a);
2800
2800
  }
2801
2801
  } catch {
@@ -2820,21 +2820,21 @@ class er {
2820
2820
  const n = t.baseUrl.replace(/\/+$/, "");
2821
2821
  this._authBaseUrl = `${n}/auth`;
2822
2822
  }
2823
- t.apiKey !== void 0 ? ve(t.apiKey) : t.getToken && ve(t.getToken());
2823
+ t.apiKey !== void 0 ? Ie(t.apiKey) : t.getToken && Ie(t.getToken());
2824
2824
  }
2825
2825
  // ---- Token Management ----
2826
2826
  getAuthToken() {
2827
2827
  return Pt();
2828
2828
  }
2829
2829
  setAuthToken(t) {
2830
- ve(t);
2830
+ Ie(t);
2831
2831
  }
2832
2832
  onTokenChange(t) {
2833
2833
  return _t(t);
2834
2834
  }
2835
2835
  // ---- User Management ----
2836
2836
  async listUsers() {
2837
- const t = await se("/users", { baseURL: this.baseUrl });
2837
+ const t = await oe("/users", { baseURL: this.baseUrl });
2838
2838
  return (t == null ? void 0 : t.users) ?? [];
2839
2839
  }
2840
2840
  }
@@ -2842,53 +2842,53 @@ const tr = new er(), Lt = Ce(null);
2842
2842
  function nr({ children: e, apiConfig: t }) {
2843
2843
  const n = Nt, r = tr;
2844
2844
  if (t) {
2845
- const s = n.baseUrl, a = r.baseUrl, i = n.getAuthToken(), u = t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0;
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 }));
2845
+ const o = n.baseUrl, a = r.baseUrl, i = n.getAuthToken(), u = t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0;
2846
+ (t.baseUrl || t.chatBaseUrl || u) && (u || t.chatBaseUrl && t.chatBaseUrl !== o || t.baseUrl && !o.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 }));
2847
2847
  }
2848
- const o = {
2848
+ const s = {
2849
2849
  token: n.getAuthToken(),
2850
- setToken: (s) => {
2851
- n.setAuthToken(s), r.setAuthToken(s);
2850
+ setToken: (o) => {
2851
+ n.setAuthToken(o), r.setAuthToken(o);
2852
2852
  },
2853
2853
  chatApi: n,
2854
2854
  authApi: r,
2855
2855
  fileApi: Rt,
2856
2856
  baseUrl: n.baseUrl
2857
2857
  };
2858
- return /* @__PURE__ */ ie(Lt.Provider, { value: o, children: e });
2858
+ return /* @__PURE__ */ ie(Lt.Provider, { value: s, children: e });
2859
2859
  }
2860
2860
  async function rr(e) {
2861
2861
  return await new Promise((t, n) => {
2862
2862
  const r = new FileReader();
2863
2863
  r.onload = () => {
2864
2864
  try {
2865
- const o = r.result, s = new Uint8Array(o);
2865
+ const s = r.result, o = new Uint8Array(s);
2866
2866
  let a = "";
2867
- const i = s.byteLength;
2868
- for (let u = 0; u < i; u++) a += String.fromCharCode(s[u]);
2867
+ const i = o.byteLength;
2868
+ for (let u = 0; u < i; u++) a += String.fromCharCode(o[u]);
2869
2869
  t(btoa(a));
2870
- } catch (o) {
2871
- n(o);
2870
+ } catch (s) {
2871
+ n(s);
2872
2872
  }
2873
- }, r.onerror = (o) => n(o), r.readAsArrayBuffer(e);
2873
+ }, r.onerror = (s) => n(s), r.readAsArrayBuffer(e);
2874
2874
  });
2875
2875
  }
2876
- async function or(e = []) {
2876
+ async function sr(e = []) {
2877
2877
  const t = [], n = [];
2878
2878
  for (const r of e)
2879
2879
  try {
2880
- const o = await rr(r), s = r.type || "application/octet-stream";
2880
+ const s = await rr(r), o = r.type || "application/octet-stream";
2881
2881
  n.push({
2882
2882
  filename: r.name,
2883
- data: o,
2884
- mime_type: s
2885
- }), s.startsWith("image/") ? t.push({
2883
+ data: s,
2884
+ mime_type: o
2885
+ }), o.startsWith("image/") ? t.push({
2886
2886
  type: "image_url",
2887
- image_url: { url: `data:${s};base64,${o}` }
2887
+ image_url: { url: `data:${o};base64,${s}` }
2888
2888
  }) : t.push({
2889
2889
  type: "file",
2890
- url: `data:${s};base64,${o}`,
2891
- mimeType: s,
2890
+ url: `data:${o};base64,${s}`,
2891
+ mimeType: o,
2892
2892
  name: r.name,
2893
2893
  size: r.size
2894
2894
  });
@@ -2896,10 +2896,10 @@ async function or(e = []) {
2896
2896
  }
2897
2897
  return { contentParts: t, filesInfo: n };
2898
2898
  }
2899
- function sr(e) {
2899
+ function or(e) {
2900
2900
  return e.filter((t) => t.type === "text").map((t) => t.text).join("");
2901
2901
  }
2902
- function io(e) {
2902
+ function is(e) {
2903
2903
  if (e == null) return null;
2904
2904
  const t = String(e).trim();
2905
2905
  return t.length > 0 ? t : null;
@@ -2911,13 +2911,13 @@ function ar(e) {
2911
2911
  name: e.name ?? void 0
2912
2912
  };
2913
2913
  }
2914
- function co(e) {
2914
+ function cs(e) {
2915
2915
  var n;
2916
2916
  if (e.name && e.name.trim()) return e.name;
2917
2917
  const t = (n = e.additionalKwargs) == null ? void 0 : n.agentName;
2918
2918
  return typeof t == "string" && t.trim() ? t : e.model && e.model.includes("/") ? e.model.split("/").pop() || null : e.model || null;
2919
2919
  }
2920
- function lo(e) {
2920
+ function ls(e) {
2921
2921
  const t = e.updatedAt ?? e.createdAt ?? "", n = Array.isArray(e.content) ? e.content.map((a) => {
2922
2922
  switch (a.type) {
2923
2923
  case "text":
@@ -2927,8 +2927,8 @@ function lo(e) {
2927
2927
  default:
2928
2928
  return a.type === "interrupt" ? "interrupt" : "unknown";
2929
2929
  }
2930
- }).join("|") : "", r = "checkpointId" in e && e.checkpointId ? `cp:${e.checkpointId}` : "", o = "checkpointNs" in e && e.checkpointNs ? `ns:${e.checkpointNs}` : "", s = [r, o].filter(Boolean).join("|");
2931
- return `${e.id}:${t}:${n}${s ? `:${s}` : ""}`;
2930
+ }).join("|") : "", r = "checkpointId" in e && e.checkpointId ? `cp:${e.checkpointId}` : "", s = "checkpointNs" in e && e.checkpointNs ? `ns:${e.checkpointNs}` : "", o = [r, s].filter(Boolean).join("|");
2931
+ return `${e.id}:${t}:${n}${o ? `:${o}` : ""}`;
2932
2932
  }
2933
2933
  function Me() {
2934
2934
  const e = Ue(Lt);
@@ -3009,7 +3009,7 @@ function fr(e, t) {
3009
3009
  return "type" in n || (n.type = e), n;
3010
3010
  }
3011
3011
  function pr(e = {}) {
3012
- const t = e.baseUrl || "", n = e.streamPath ?? "/stream", [r, o] = $(e.token ?? null), s = W(e.headers ?? {}), a = e.credentials ?? "include", i = W(e);
3012
+ const t = e.baseUrl || "", n = e.streamPath ?? "/stream", [r, s] = $(e.token ?? null), o = W(e.headers ?? {}), a = e.credentials ?? "include", i = W(e);
3013
3013
  X(() => {
3014
3014
  i.current = e;
3015
3015
  }, [e]);
@@ -3018,23 +3018,23 @@ function pr(e = {}) {
3018
3018
  const w = i.current;
3019
3019
  if (!w) return;
3020
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);
3021
+ }, []), [c, l] = $(!1), [d, g] = $(null), [m, I] = $(!1), [f, v] = $(null), x = W(null), M = W(!0), A = W(null), k = _((p) => {
3022
+ s(p);
3023
3023
  }, []), b = _(() => {
3024
- g(null), I(null);
3024
+ g(null), v(null);
3025
3025
  }, []), h = _(() => {
3026
3026
  var C, O;
3027
3027
  console.debug("[use-chat] stop() invoked - aborting stream");
3028
- const p = (C = x.current) == null ? void 0 : C.threadId, w = (O = x.current) == null ? void 0 : O.runId, P = () => {
3028
+ const p = (C = A.current) == null ? void 0 : C.threadId, w = (O = A.current) == null ? void 0 : O.runId, P = () => {
3029
3029
  var F;
3030
- (F = A.current) == null || F.abort(), A.current = null, x.current = null, l(!1), v(!1);
3030
+ (F = x.current) == null || F.abort(), x.current = null, A.current = null, l(!1), I(!1);
3031
3031
  };
3032
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
3035
  }, []), T = _(
3036
3036
  (p) => {
3037
- A.current && (A.current.abort(), A.current = null);
3037
+ x.current && (x.current.abort(), x.current = null);
3038
3038
  const w = {
3039
3039
  text: typeof p.content == "string" ? p.content : p.text,
3040
3040
  threadId: p.threadId,
@@ -3049,11 +3049,11 @@ function pr(e = {}) {
3049
3049
  edit: p.edit ?? !1,
3050
3050
  command: p.command
3051
3051
  };
3052
- l(!0), g(null), I(null);
3052
+ l(!0), g(null), v(null);
3053
3053
  const P = new AbortController();
3054
- A.current = P;
3054
+ x.current = P;
3055
3055
  let j = null, C = !1;
3056
- return x.current = {
3056
+ return A.current = {
3057
3057
  threadId: w.threadId ?? void 0,
3058
3058
  runId: void 0,
3059
3059
  // Will be updated from headers
@@ -3090,7 +3090,7 @@ function pr(e = {}) {
3090
3090
  const H = {
3091
3091
  ...N,
3092
3092
  ...L,
3093
- ...s.current
3093
+ ...o.current
3094
3094
  }, y = {
3095
3095
  "Content-Type": "application/json",
3096
3096
  Accept: "text/event-stream",
@@ -3102,7 +3102,7 @@ function pr(e = {}) {
3102
3102
  signal: P.signal,
3103
3103
  credentials: a
3104
3104
  });
3105
- if (x.current && (x.current.headers = H), !U.ok || !U.body) {
3105
+ if (A.current && (A.current.headers = H), !U.ok || !U.body) {
3106
3106
  const G = await U.text().catch(() => "");
3107
3107
  console.debug(
3108
3108
  "[use-chat] non-OK response",
@@ -3112,7 +3112,7 @@ function pr(e = {}) {
3112
3112
  const te = `stream ${U.status}${G ? ": " + G : ""}`;
3113
3113
  throw te && (g(te), j = "error"), new Error(te);
3114
3114
  }
3115
- v(!0);
3115
+ I(!0);
3116
3116
  const S = U.body.getReader(), J = new TextDecoder();
3117
3117
  let V = "", q = 0, ee = Date.now();
3118
3118
  const re = setInterval(() => {
@@ -3120,10 +3120,10 @@ function pr(e = {}) {
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");
3123
- for (x.current && (x.current = {
3124
- ...x.current,
3125
- threadId: G ?? x.current.threadId,
3126
- runId: te ?? x.current.runId
3123
+ for (A.current && (A.current = {
3124
+ ...A.current,
3125
+ threadId: G ?? A.current.threadId,
3126
+ runId: te ?? A.current.runId
3127
3127
  }); ; ) {
3128
3128
  const { value: ke, done: Q } = await S.read();
3129
3129
  if (Q) break;
@@ -3139,42 +3139,42 @@ function pr(e = {}) {
3139
3139
  for (const he of je)
3140
3140
  if (!he.startsWith(":") && he) {
3141
3141
  if (he.startsWith("event:")) {
3142
- const xe = he.slice(6).trim();
3143
- xe && (me = xe);
3142
+ const Ae = he.slice(6).trim();
3143
+ Ae && (me = Ae);
3144
3144
  continue;
3145
3145
  }
3146
3146
  if (he.startsWith("data:")) {
3147
- const xe = he.slice(5);
3148
- Be.push(xe.startsWith(" ") ? xe.slice(1) : xe);
3147
+ const Ae = he.slice(5);
3148
+ Be.push(Ae.startsWith(" ") ? Ae.slice(1) : Ae);
3149
3149
  }
3150
3150
  }
3151
- const Ie = Be.join(`
3151
+ const ve = Be.join(`
3152
3152
  `);
3153
- if (!Ie) continue;
3154
- let oe;
3153
+ if (!ve) continue;
3154
+ let se;
3155
3155
  try {
3156
- oe = JSON.parse(Ie);
3156
+ se = JSON.parse(ve);
3157
3157
  } catch {
3158
- console.debug("[use-chat] malformed SSE:", Ie.slice(0, 200));
3158
+ console.debug("[use-chat] malformed SSE:", ve.slice(0, 200));
3159
3159
  continue;
3160
3160
  }
3161
- oe = fr(me, oe);
3162
- const Pe = cr(oe) ? oe.data : oe;
3161
+ se = fr(me, se);
3162
+ const Pe = cr(se) ? se.data : se;
3163
3163
  if (!Pe) {
3164
- console.warn("[use-chat] dropped envelope event without payload", oe);
3164
+ console.warn("[use-chat] dropped envelope event without payload", se);
3165
3165
  continue;
3166
3166
  }
3167
- const Ae = $n(Pe);
3167
+ const xe = $n(Pe);
3168
3168
  ee = Date.now();
3169
- const ye = typeof Ae.seq == "number" ? Ae.seq : void 0;
3169
+ const ye = typeof xe.seq == "number" ? xe.seq : void 0;
3170
3170
  if (ye !== void 0) {
3171
3171
  if (ye <= q) {
3172
- console.debug("[use-chat] drop duplicate/out-of-order event", { seq: ye, lastProcessedSeq: q, type: Ae.type });
3172
+ console.debug("[use-chat] drop duplicate/out-of-order event", { seq: ye, lastProcessedSeq: q, type: xe.type });
3173
3173
  continue;
3174
3174
  }
3175
3175
  q = ye;
3176
3176
  }
3177
- u(Ae);
3177
+ u(xe);
3178
3178
  }
3179
3179
  }
3180
3180
  j === null && !P.signal.aborted && (j = "complete");
@@ -3216,7 +3216,7 @@ function pr(e = {}) {
3216
3216
  } catch (N) {
3217
3217
  console.warn("[use-chat] onClosed callback failed", N);
3218
3218
  }
3219
- l(!1), v(!1), A.current = null, x.current = null;
3219
+ l(!1), I(!1), x.current = null, A.current = null;
3220
3220
  }
3221
3221
  })(), Promise.resolve();
3222
3222
  },
@@ -3224,7 +3224,7 @@ function pr(e = {}) {
3224
3224
  );
3225
3225
  return X(() => () => {
3226
3226
  var p;
3227
- M.current = !1, (p = A.current) == null || p.abort();
3227
+ M.current = !1, (p = x.current) == null || p.abort();
3228
3228
  }, []), {
3229
3229
  isStreaming: c,
3230
3230
  error: d,
@@ -3257,9 +3257,9 @@ function gr({
3257
3257
  initialThreadId: t = null,
3258
3258
  onError: n,
3259
3259
  onThreadChange: r,
3260
- onCurrentThreadDeleted: o
3260
+ onCurrentThreadDeleted: s
3261
3261
  }) {
3262
- const [s, a] = $([]), [i, u] = $(t), [c, l] = $(!1), [d, g] = $(null), m = W(i), v = W(/* @__PURE__ */ new Map());
3262
+ const [o, a] = $([]), [i, u] = $(t), [c, l] = $(!1), [d, g] = $(null), m = W(i), I = W(/* @__PURE__ */ new Map());
3263
3263
  X(() => {
3264
3264
  m.current = i;
3265
3265
  }, [i]), X(() => {
@@ -3282,7 +3282,7 @@ function gr({
3282
3282
  }, [f]), X(() => {
3283
3283
  r == null || r(i);
3284
3284
  }, [i, r]);
3285
- const I = _(
3285
+ const v = _(
3286
3286
  async (b, h) => {
3287
3287
  try {
3288
3288
  const T = h && typeof h == "object" ? { id: h.id, name: h.name ?? "" } : void 0, p = await e.createThread(b, T);
@@ -3293,23 +3293,23 @@ function gr({
3293
3293
  }
3294
3294
  },
3295
3295
  [e, n, f]
3296
- ), A = _(
3296
+ ), x = _(
3297
3297
  async (b) => {
3298
- const h = s;
3298
+ const h = o;
3299
3299
  a((p) => p.filter((w) => w.threadId !== b));
3300
3300
  const T = new AbortController();
3301
- v.current.set(b, T);
3301
+ I.current.set(b, T);
3302
3302
  try {
3303
- await e.deleteThread(b), m.current === b && (u(null), o == null || o());
3303
+ await e.deleteThread(b), m.current === b && (u(null), s == null || s());
3304
3304
  } catch (p) {
3305
3305
  a(h);
3306
3306
  const w = String(p);
3307
3307
  n == null || n(w);
3308
3308
  } finally {
3309
- v.current.delete(b);
3309
+ I.current.delete(b);
3310
3310
  }
3311
3311
  },
3312
- [e, o, n, s]
3312
+ [e, s, n, o]
3313
3313
  ), M = _(
3314
3314
  async (b, h) => {
3315
3315
  try {
@@ -3319,14 +3319,14 @@ function gr({
3319
3319
  }
3320
3320
  },
3321
3321
  [e, n, f]
3322
- ), x = Y(
3322
+ ), A = Y(
3323
3323
  () => ({
3324
- createThread: I,
3325
- deleteThread: A,
3324
+ createThread: v,
3325
+ deleteThread: x,
3326
3326
  renameThread: M,
3327
3327
  refreshThreads: f
3328
3328
  }),
3329
- [I, A, M, f]
3329
+ [v, x, M, f]
3330
3330
  ), k = _((b) => {
3331
3331
  if (!(b != null && b.threadId)) return;
3332
3332
  const h = {
@@ -3350,13 +3350,13 @@ function gr({
3350
3350
  });
3351
3351
  }, []);
3352
3352
  return {
3353
- threads: s,
3353
+ threads: o,
3354
3354
  currentThreadId: i,
3355
3355
  currentThreadIdRef: m,
3356
3356
  setCurrentThreadId: u,
3357
3357
  isLoadingThreads: c,
3358
3358
  threadsError: d,
3359
- actions: x,
3359
+ actions: A,
3360
3360
  addThreadFromEvent: k
3361
3361
  };
3362
3362
  }
@@ -3367,8 +3367,8 @@ function mr({
3367
3367
  onError: n,
3368
3368
  onThreadChange: r
3369
3369
  }) {
3370
- const { chatApi: o } = Me(), {
3371
- threads: s,
3370
+ const { chatApi: s } = Me(), {
3371
+ threads: o,
3372
3372
  currentThreadId: a,
3373
3373
  setCurrentThreadId: i,
3374
3374
  currentThreadIdRef: u,
@@ -3377,13 +3377,13 @@ function mr({
3377
3377
  actions: d,
3378
3378
  addThreadFromEvent: g
3379
3379
  } = gr({
3380
- api: o,
3380
+ api: s,
3381
3381
  initialThreadId: t,
3382
3382
  onError: n,
3383
3383
  onThreadChange: r
3384
3384
  }), m = Y(
3385
3385
  () => ({
3386
- threads: s,
3386
+ threads: o,
3387
3387
  currentThreadId: a,
3388
3388
  setCurrentThreadId: i,
3389
3389
  currentThreadIdRef: u,
@@ -3393,7 +3393,7 @@ function mr({
3393
3393
  addThreadFromEvent: g
3394
3394
  }),
3395
3395
  [
3396
- s,
3396
+ o,
3397
3397
  a,
3398
3398
  i,
3399
3399
  u,
@@ -3405,7 +3405,7 @@ function mr({
3405
3405
  );
3406
3406
  return /* @__PURE__ */ ie(jt.Provider, { value: m, children: e });
3407
3407
  }
3408
- function ot(e) {
3408
+ function st(e) {
3409
3409
  const t = Ue(jt);
3410
3410
  if (!t && !(e != null && e.optional)) throw new Error("useThreads must be used within a ThreadsProvider");
3411
3411
  return t;
@@ -3438,8 +3438,8 @@ function yr(e, t) {
3438
3438
  }
3439
3439
  function hr(e, t, n) {
3440
3440
  return e.find((r) => {
3441
- const o = Bt(r);
3442
- return !!((o == null ? void 0 : o.id) === t || n && r.toolCallId === n);
3441
+ const s = Bt(r);
3442
+ return !!((s == null ? void 0 : s.id) === t || n && r.toolCallId === n);
3443
3443
  }) ?? null;
3444
3444
  }
3445
3445
  function Oe(e) {
@@ -3452,8 +3452,8 @@ function Ft(e, t, n) {
3452
3452
  function br(e, t, n) {
3453
3453
  for (let r = e.length - 1; r >= 0; r--)
3454
3454
  if (e[r].role === "assistant") {
3455
- const s = { ...e[r], checkpointId: t, checkpointNs: n ?? void 0 };
3456
- return Ft(e, r, s);
3455
+ const o = { ...e[r], checkpointId: t, checkpointNs: n ?? void 0 };
3456
+ return Ft(e, r, o);
3457
3457
  }
3458
3458
  return e;
3459
3459
  }
@@ -3484,7 +3484,19 @@ function wr(e, t) {
3484
3484
  messages: Oe(((n = t.payload) == null ? void 0 : n.messages) ?? [])
3485
3485
  };
3486
3486
  case "user_message": {
3487
- const { message: r } = t.payload;
3487
+ const { message: r, editingMessageId: s } = t.payload;
3488
+ if (s) {
3489
+ const o = e.messages.findIndex((a) => a.id === s);
3490
+ if (o !== -1)
3491
+ return {
3492
+ ...e,
3493
+ status: "streaming",
3494
+ messages: [...e.messages.slice(0, o), r],
3495
+ assemblingId: null,
3496
+ lastCheckpointId: null,
3497
+ error: null
3498
+ };
3499
+ }
3488
3500
  return {
3489
3501
  ...e,
3490
3502
  status: "streaming",
@@ -3495,7 +3507,7 @@ function wr(e, t) {
3495
3507
  };
3496
3508
  }
3497
3509
  case "seed": {
3498
- const r = Oe(t.payload.messages), o = {
3510
+ const r = Oe(t.payload.messages), s = {
3499
3511
  ...e,
3500
3512
  status: "idle",
3501
3513
  messages: r,
@@ -3504,32 +3516,32 @@ function wr(e, t) {
3504
3516
  taskMessagesByScope: {},
3505
3517
  error: null
3506
3518
  };
3507
- return Object.prototype.hasOwnProperty.call(t.payload, "checkpointId") && (o.lastCheckpointId = t.payload.checkpointId ?? null), Object.prototype.hasOwnProperty.call(t.payload, "checkpointNs") && (o.lastCheckpointNs = t.payload.checkpointNs ?? null), Object.prototype.hasOwnProperty.call(t.payload, "values") && (o.values = t.payload.values ?? {}), o;
3519
+ return Object.prototype.hasOwnProperty.call(t.payload, "checkpointId") && (s.lastCheckpointId = t.payload.checkpointId ?? null), Object.prototype.hasOwnProperty.call(t.payload, "checkpointNs") && (s.lastCheckpointNs = t.payload.checkpointNs ?? null), Object.prototype.hasOwnProperty.call(t.payload, "values") && (s.values = t.payload.values ?? {}), s;
3508
3520
  }
3509
3521
  case "prepend": {
3510
3522
  const r = Oe(t.payload.messages);
3511
3523
  if (!r.length) return e;
3512
- const o = new Set(e.messages.map((a) => a.id)), s = r.filter((a) => !o.has(a.id));
3513
- return s.length ? { ...e, messages: [...s, ...e.messages] } : e;
3524
+ const s = new Set(e.messages.map((a) => a.id)), o = r.filter((a) => !s.has(a.id));
3525
+ return o.length ? { ...e, messages: [...o, ...e.messages] } : e;
3514
3526
  }
3515
3527
  case "event":
3516
3528
  return pt(e, t.payload.ev);
3517
3529
  case "batch": {
3518
3530
  const { events: r } = t.payload;
3519
- return r.length ? r.reduce((o, s) => pt(o, s), e) : e;
3531
+ return r.length ? r.reduce((s, o) => pt(s, o), e) : e;
3520
3532
  }
3521
3533
  default:
3522
3534
  return e;
3523
3535
  }
3524
3536
  }
3525
3537
  function kr(e = []) {
3526
- const [t, n] = Wt(wr, { ...Ot, messages: e }), r = W([]), o = W(null), s = _(() => {
3527
- o.current !== null && typeof window < "u" && window.cancelAnimationFrame(o.current), o.current = null;
3538
+ const [t, n] = Wt(wr, { ...Ot, messages: e }), r = W([]), s = W(null), o = _(() => {
3539
+ s.current !== null && typeof window < "u" && window.cancelAnimationFrame(s.current), s.current = null;
3528
3540
  const c = r.current;
3529
3541
  c.length && (r.current = [], n({ type: "batch", payload: { events: c } }));
3530
3542
  }, []), a = _(() => {
3531
- typeof window < "u" && typeof window.requestAnimationFrame == "function" ? o.current === null && (o.current = window.requestAnimationFrame(() => s())) : setTimeout(s, 8);
3532
- }, [s]), i = _((c) => {
3543
+ typeof window < "u" && typeof window.requestAnimationFrame == "function" ? s.current === null && (s.current = window.requestAnimationFrame(() => o())) : setTimeout(o, 8);
3544
+ }, [o]), i = _((c) => {
3533
3545
  r.current.push(c), a();
3534
3546
  }, [a]), u = Y(() => ({
3535
3547
  setStatus: (c, l) => n({ type: "status", payload: { status: c, error: l } }),
@@ -3541,14 +3553,14 @@ function kr(e = []) {
3541
3553
  return { state: t, dispatch: n, ...u };
3542
3554
  }
3543
3555
  function pt(e, t) {
3544
- const n = t.origin, r = t.scope, o = n === "task" || typeof r == "string" && r.startsWith("tools:");
3556
+ const n = t.origin, r = t.scope, s = n === "task" || typeof r == "string" && r.startsWith("tools:");
3545
3557
  if (t.type === "checkpoint") {
3546
- const s = t.checkpointNs ?? e.lastCheckpointNs ?? null, a = br(e.messages, t.checkpointId, s);
3547
- return { ...e, lastCheckpointId: t.checkpointId, lastCheckpointNs: s, messages: a };
3558
+ const o = t.checkpointNs ?? e.lastCheckpointNs ?? null, a = br(e.messages, t.checkpointId, o);
3559
+ return { ...e, lastCheckpointId: t.checkpointId, lastCheckpointNs: o, messages: a };
3548
3560
  }
3549
3561
  if (t.type === "status") {
3550
- const s = t.status === "completed" || t.status === "error" ? "idle" : t.status === "interrupted" ? "awaiting_input" : e.status;
3551
- return { ...e, status: s };
3562
+ const o = t.status === "completed" || t.status === "error" ? "idle" : t.status === "interrupted" ? "awaiting_input" : e.status;
3563
+ return { ...e, status: o };
3552
3564
  }
3553
3565
  if (t.type === "interrupt")
3554
3566
  return {
@@ -3562,21 +3574,21 @@ function pt(e, t) {
3562
3574
  }
3563
3575
  };
3564
3576
  if (t.type === "error") {
3565
- const s = {
3577
+ const o = {
3566
3578
  id: `err-${Date.now()}`,
3567
3579
  role: "system",
3568
3580
  content: [{ type: "text", text: `Error: ${t.message}` }],
3569
3581
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
3570
3582
  };
3571
- return { ...e, status: "error", error: t.message, messages: [...e.messages, s] };
3583
+ return { ...e, status: "error", error: t.message, messages: [...e.messages, o] };
3572
3584
  }
3573
3585
  if (t.type === "values" && "messages" in t && Array.isArray(t.messages)) {
3574
- const s = t, a = Array.isArray(s.messages) ? s.messages : [], i = Oe(a), { messages: u, ...c } = s, l = c.__interrupt__ ?? c.interrupts, d = Array.isArray(l) && l.length > 0 ? {
3586
+ const o = t, a = Array.isArray(o.messages) ? o.messages : [], i = Oe(a), { messages: u, ...c } = o, l = c.__interrupt__ ?? c.interrupts, d = Array.isArray(l) && l.length > 0 ? {
3575
3587
  id: l[0].id || "native-interrupt",
3576
3588
  value: l[0].value || l[0],
3577
3589
  alternatives: l[0].alternatives
3578
3590
  } : null;
3579
- if (o) {
3591
+ if (s) {
3580
3592
  const g = typeof r == "string" && r.length > 0 ? r : "task";
3581
3593
  return {
3582
3594
  ...e,
@@ -3595,20 +3607,20 @@ function pt(e, t) {
3595
3607
  };
3596
3608
  }
3597
3609
  if (t.type === "messages/metadata") {
3598
- const s = { ...e.messagesStreamMeta ?? {} }, a = t.metadata;
3610
+ const o = { ...e.messagesStreamMeta ?? {} }, a = t.metadata;
3599
3611
  return a && typeof a == "object" && Object.entries(a).forEach(([i, u]) => {
3600
3612
  const c = u == null ? void 0 : u.metadata;
3601
3613
  if (!c || typeof c != "object") return;
3602
- const l = s[i] ?? {};
3603
- s[i] = {
3614
+ const l = o[i] ?? {};
3615
+ o[i] = {
3604
3616
  ...l,
3605
3617
  lastSeq: t.seq ?? l.lastSeq ?? null,
3606
3618
  metadata: { ...l.metadata ?? {}, ...c }
3607
3619
  };
3608
- }), { ...e, messagesStreamMeta: s };
3620
+ }), { ...e, messagesStreamMeta: o };
3609
3621
  }
3610
3622
  if (t.type === "messages/partial" || t.type === "message.delta") {
3611
- const s = t.type === "messages/partial" ? t : {
3623
+ const o = t.type === "messages/partial" ? t : {
3612
3624
  ...t,
3613
3625
  type: "messages/partial",
3614
3626
  messages: t.delta ? [{
@@ -3619,32 +3631,32 @@ function pt(e, t) {
3619
3631
  origin: t.origin
3620
3632
  }] : []
3621
3633
  };
3622
- return vr(e, s, o);
3634
+ return Ir(e, o, s);
3623
3635
  }
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;
3636
+ return t.type === "message.start" ? { ...e, assemblingId: t.id, status: "streaming" } : t.type === "message.end" ? { ...e, assemblingId: null } : t.type === "tool.start" ? { ...vr(e, t, s), status: "streaming" } : t.type === "tool.progress" ? xr(e, t, s) : t.type === "tool.end" ? Ar(e, t, s) : t.type === "artifact.update" ? Tr(e, t) : e;
3625
3637
  }
3626
- function vr(e, t, n) {
3627
- var m, v, f, I, A, M, x;
3638
+ function Ir(e, t, n) {
3639
+ var m, I, f, v, x, M, A;
3628
3640
  const r = t.messages;
3629
3641
  if (!r.length)
3630
3642
  return console.warn("[messagesReducer] Dropping messages/partial event without messages[]", t), e;
3631
- const o = r.find((k) => k.type === "ai" || k.type === "assistant" || k.role === "assistant");
3632
- if (!o) return e;
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";
3643
+ const s = r.find((k) => k.type === "ai" || k.type === "assistant" || k.role === "assistant");
3644
+ if (!s) return e;
3645
+ const o = s.id, a = s.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 !== o, l = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3634
3646
  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;
3647
+ const g = (I = (m = e.messagesStreamMeta) == null ? void 0 : m[o]) == null ? void 0 : I.metadata;
3636
3648
  if (c) {
3637
3649
  const k = nt({
3638
- ...o,
3650
+ ...s,
3639
3651
  role: "assistant",
3640
3652
  content: i,
3641
3653
  scope: t.scope,
3642
3654
  origin: t.origin,
3643
- responseMetadata: { ...g, ...o.responseMetadata ?? {} }
3655
+ responseMetadata: { ...g, ...s.responseMetadata ?? {} }
3644
3656
  });
3645
3657
  k && d.push(k);
3646
3658
  } else {
3647
- const k = d.findIndex((b) => b.id === s);
3659
+ const k = d.findIndex((b) => b.id === o);
3648
3660
  if (k !== -1) {
3649
3661
  const b = d[k];
3650
3662
  d[k] = {
@@ -3652,7 +3664,7 @@ function vr(e, t, n) {
3652
3664
  content: i,
3653
3665
  scope: t.scope ?? b.scope,
3654
3666
  origin: t.origin ?? b.origin,
3655
- responseMetadata: { ...g, ...b.responseMetadata, ...o.responseMetadata ?? {} }
3667
+ responseMetadata: { ...g, ...b.responseMetadata, ...s.responseMetadata ?? {} }
3656
3668
  };
3657
3669
  }
3658
3670
  }
@@ -3661,32 +3673,32 @@ function vr(e, t, n) {
3661
3673
  status: "streaming",
3662
3674
  messages: n ? e.messages : d,
3663
3675
  taskMessagesByScope: n ? { ...e.taskMessagesByScope, [l]: d } : e.taskMessagesByScope,
3664
- assemblingId: s,
3676
+ assemblingId: o,
3665
3677
  messagesStreamMeta: {
3666
3678
  ...e.messagesStreamMeta ?? {},
3667
- [s]: {
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) ?? "")
3679
+ [o]: {
3680
+ ...((f = e.messagesStreamMeta) == null ? void 0 : f[o]) ?? {},
3681
+ lastSeq: t.seq ?? ((x = (v = e.messagesStreamMeta) == null ? void 0 : v[o]) == null ? void 0 : x.lastSeq) ?? null,
3682
+ lastText: u || (((A = (M = e.messagesStreamMeta) == null ? void 0 : M[o]) == null ? void 0 : A.lastText) ?? "")
3671
3683
  }
3672
3684
  }
3673
3685
  };
3674
3686
  }
3675
- function st(e, t) {
3687
+ function ot(e, t) {
3676
3688
  var n;
3677
3689
  if (!t) return -1;
3678
3690
  for (let r = e.length - 1; r >= 0; r--) {
3679
- const o = e[r];
3680
- if (o.role === "assistant" && ((n = o.toolCalls) != null && n.some((s) => s.id === t)))
3691
+ const s = e[r];
3692
+ if (s.role === "assistant" && ((n = s.toolCalls) != null && n.some((o) => o.id === t)))
3681
3693
  return r;
3682
3694
  }
3683
3695
  return -1;
3684
3696
  }
3685
- function Ir(e, t, n) {
3697
+ function vr(e, t, n) {
3686
3698
  const r = t.id || t.callId;
3687
3699
  if (!r) return e;
3688
- const o = t.name || "tool", s = `Starting ${o}...`, a = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3689
- let i = n ? [...e.taskMessagesByScope[a] || []] : [...e.messages], u = st(i, r);
3700
+ const s = t.name || "tool", o = `Starting ${s}...`, a = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3701
+ let i = n ? [...e.taskMessagesByScope[a] || []] : [...e.messages], u = ot(i, r);
3690
3702
  if (u === -1) {
3691
3703
  for (let c = i.length - 1; c >= 0; c--)
3692
3704
  if (i[c].role === "assistant") {
@@ -3708,12 +3720,12 @@ function Ir(e, t, n) {
3708
3720
  }
3709
3721
  if (u !== -1) {
3710
3722
  const c = i[u], l = [...c.toolCalls || []], d = l.findIndex((g) => g.id === r);
3711
- d >= 0 ? l[d] = { ...l[d], status: "running", content: s } : l.push({
3723
+ d >= 0 ? l[d] = { ...l[d], status: "running", content: o } : l.push({
3712
3724
  id: r,
3713
- name: o,
3725
+ name: s,
3714
3726
  args: t.args || {},
3715
3727
  status: "running",
3716
- content: s
3728
+ content: o
3717
3729
  }), i[u] = {
3718
3730
  ...c,
3719
3731
  toolCalls: l,
@@ -3727,17 +3739,17 @@ function Ir(e, t, n) {
3727
3739
  taskMessagesByScope: n ? { ...e.taskMessagesByScope, [a]: i } : e.taskMessagesByScope
3728
3740
  };
3729
3741
  }
3730
- function Ar(e, t, n) {
3742
+ function xr(e, t, n) {
3731
3743
  const r = t.id;
3732
3744
  if (!r) return e;
3733
- const o = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3734
- let s = n ? [...e.taskMessagesByScope[o] || []] : [...e.messages];
3735
- const a = st(s, r);
3745
+ const s = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3746
+ let o = n ? [...e.taskMessagesByScope[s] || []] : [...e.messages];
3747
+ const a = ot(o, r);
3736
3748
  if (a !== -1) {
3737
- const i = s[a], u = ce(t.content), c = (i.toolCalls || []).map(
3749
+ const i = o[a], u = ce(t.content), c = (i.toolCalls || []).map(
3738
3750
  (l) => l.id === r ? { ...l, content: typeof u == "string" ? u : l.content } : l
3739
3751
  );
3740
- s[a] = {
3752
+ o[a] = {
3741
3753
  ...i,
3742
3754
  toolCalls: c,
3743
3755
  scope: t.scope ?? i.scope,
@@ -3746,18 +3758,18 @@ function Ar(e, t, n) {
3746
3758
  }
3747
3759
  return {
3748
3760
  ...e,
3749
- messages: n ? e.messages : s,
3750
- taskMessagesByScope: n ? { ...e.taskMessagesByScope, [o]: s } : e.taskMessagesByScope
3761
+ messages: n ? e.messages : o,
3762
+ taskMessagesByScope: n ? { ...e.taskMessagesByScope, [s]: o } : e.taskMessagesByScope
3751
3763
  };
3752
3764
  }
3753
- function xr(e, t, n) {
3765
+ function Ar(e, t, n) {
3754
3766
  const r = t.id;
3755
3767
  if (!r) return e;
3756
- const o = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3757
- let s = n ? [...e.taskMessagesByScope[o] || []] : [...e.messages];
3758
- const a = st(s, r), i = ce(t.content ?? t.error);
3768
+ const s = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3769
+ let o = n ? [...e.taskMessagesByScope[s] || []] : [...e.messages];
3770
+ const a = ot(o, r), i = ce(t.content ?? t.error);
3759
3771
  if (a !== -1) {
3760
- const c = s[a], l = (c.toolCalls || []).map(
3772
+ const c = o[a], l = (c.toolCalls || []).map(
3761
3773
  (d) => d.id === r ? {
3762
3774
  ...d,
3763
3775
  status: t.error ? "failed" : "completed",
@@ -3765,7 +3777,7 @@ function xr(e, t, n) {
3765
3777
  artifact: t.artifact
3766
3778
  } : d
3767
3779
  );
3768
- s[a] = {
3780
+ o[a] = {
3769
3781
  ...c,
3770
3782
  toolCalls: l,
3771
3783
  scope: t.scope ?? c.scope,
@@ -3783,21 +3795,21 @@ function xr(e, t, n) {
3783
3795
  scope: t.scope,
3784
3796
  origin: t.origin
3785
3797
  };
3786
- return s.push(u), {
3798
+ return o.push(u), {
3787
3799
  ...e,
3788
- messages: n ? e.messages : s,
3789
- taskMessagesByScope: n ? { ...e.taskMessagesByScope, [o]: s } : e.taskMessagesByScope
3800
+ messages: n ? e.messages : o,
3801
+ taskMessagesByScope: n ? { ...e.taskMessagesByScope, [s]: o } : e.taskMessagesByScope
3790
3802
  };
3791
3803
  }
3792
3804
  function Tr(e, t) {
3793
3805
  const n = t.artifactId, r = hr(e.messages, n, t.callId);
3794
3806
  if (!r) return e;
3795
- const o = e.messages.indexOf(r), s = yr(r, {
3807
+ const s = e.messages.indexOf(r), o = yr(r, {
3796
3808
  status: t.status,
3797
3809
  progress: t.progress,
3798
3810
  error: t.error
3799
3811
  });
3800
- return t.partial_data && s.artifact && (s.artifact = { ...s.artifact, ...t.partial_data }), { ...e, messages: Ft(e.messages, o, s) };
3812
+ return t.partial_data && o.artifact && (o.artifact = { ...o.artifact, ...t.partial_data }), { ...e, messages: Ft(e.messages, s, o) };
3801
3813
  }
3802
3814
  function Re(e) {
3803
3815
  if (!(!e || typeof e != "object" || Array.isArray(e)))
@@ -3828,7 +3840,7 @@ function gt(e) {
3828
3840
  async function Mr(e, t) {
3829
3841
  var i, u;
3830
3842
  if (!e) return e ?? null;
3831
- const n = le(e), r = Array.isArray(n.checkpoints) ? n.checkpoints : n.checkpoints ? Object.values(n.checkpoints) : [], o = /* @__PURE__ */ new Set();
3843
+ const n = le(e), r = Array.isArray(n.checkpoints) ? n.checkpoints : n.checkpoints ? Object.values(n.checkpoints) : [], s = /* @__PURE__ */ new Set();
3832
3844
  for (const c of r) {
3833
3845
  const l = (i = c == null ? void 0 : c.values) == null ? void 0 : i.messages;
3834
3846
  if (Array.isArray(l))
@@ -3837,15 +3849,15 @@ async function Mr(e, t) {
3837
3849
  if (Array.isArray(g))
3838
3850
  for (const m of g) {
3839
3851
  if (!m || typeof m != "object" || m.type !== "image_url" && m.type !== "file") continue;
3840
- const v = m.fileId || m.file_id;
3841
- typeof v == "string" && v.trim() && o.add(v);
3852
+ const I = m.fileId || m.file_id;
3853
+ typeof I == "string" && I.trim() && s.add(I);
3842
3854
  }
3843
3855
  }
3844
3856
  }
3845
- if (o.size === 0)
3857
+ if (s.size === 0)
3846
3858
  return n;
3847
- const s = await Promise.all(
3848
- Array.from(o).map(async (c) => {
3859
+ const o = await Promise.all(
3860
+ Array.from(s).map(async (c) => {
3849
3861
  try {
3850
3862
  const l = await t.getFileInfo(c), d = le(l);
3851
3863
  return [c, d];
@@ -3853,7 +3865,7 @@ async function Mr(e, t) {
3853
3865
  return [c, null];
3854
3866
  }
3855
3867
  })
3856
- ), a = new Map(s);
3868
+ ), a = new Map(o);
3857
3869
  for (const c of r) {
3858
3870
  const l = (u = c == null ? void 0 : c.values) == null ? void 0 : u.messages;
3859
3871
  if (Array.isArray(l))
@@ -3862,40 +3874,40 @@ async function Mr(e, t) {
3862
3874
  if (Array.isArray(g))
3863
3875
  for (const m of g) {
3864
3876
  if (!m || typeof m != "object" || m.type !== "image_url" && m.type !== "file") continue;
3865
- const v = m.fileId || m.file_id;
3866
- if (!v) continue;
3867
- const f = a.get(v), I = (f == null ? void 0 : f.contentUrl) || (f == null ? void 0 : f.content_url);
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))));
3877
+ const I = m.fileId || m.file_id;
3878
+ if (!I) continue;
3879
+ const f = a.get(I), v = (f == null ? void 0 : f.contentUrl) || (f == null ? void 0 : f.content_url);
3880
+ v && (m.type === "image_url" ? (m.imageUrl = m.imageUrl || {}, m.imageUrl.url = v) : m.type === "file" && (m.url = v, !m.name && (f != null && f.filename || f != null && f.name) && (m.name = (f == null ? void 0 : f.filename) || (f == null ? void 0 : f.name))));
3869
3881
  }
3870
3882
  }
3871
3883
  }
3872
3884
  return n;
3873
3885
  }
3874
3886
  function mt(e) {
3875
- const r = [...(Array.isArray(e == null ? void 0 : e.checkpoints) ? (e == null ? void 0 : e.checkpoints) ?? [] : e != null && e.checkpoints ? Object.values(e.checkpoints) : []).map((s, a) => Cr(le(s), a)).filter((s) => !!s)].sort((s, a) => yt(a.createdAt) - yt(s.createdAt)), o = r[0] ?? null;
3887
+ const r = [...(Array.isArray(e == null ? void 0 : e.checkpoints) ? (e == null ? void 0 : e.checkpoints) ?? [] : e != null && e.checkpoints ? Object.values(e.checkpoints) : []).map((o, a) => Cr(le(o), a)).filter((o) => !!o)].sort((o, a) => yt(a.createdAt) - yt(o.createdAt)), s = r[0] ?? null;
3876
3888
  return {
3877
3889
  threadId: (e == null ? void 0 : e.threadId) ?? "",
3878
- latest: o,
3890
+ latest: s,
3879
3891
  checkpoints: r,
3880
- interrupt: (o == null ? void 0 : o.interrupt) ?? null
3892
+ interrupt: (s == null ? void 0 : s.interrupt) ?? null
3881
3893
  };
3882
3894
  }
3883
3895
  function Cr(e, t) {
3884
3896
  var b, h;
3885
3897
  if (!e) return null;
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 = {
3898
+ const n = ((b = e.values) == null ? void 0 : b.activeAgent) ?? null, r = (h = e.values) == null ? void 0 : h.messages, o = (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), I = Array.isArray(e.tasks) ? e.tasks.map((T) => ({ ...T })) : e.tasks ?? null, f = Array.isArray(e.next) ? [...e.next] : e.next ?? null, v = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt : new Date(Date.now() - t).toISOString(), x = {
3887
3899
  ...a,
3888
3900
  step: Sr(a, ["step"]) ?? 0,
3889
3901
  source: Fe(a, ["source"]) ?? null
3890
- }, M = s.map((T) => ({
3902
+ }, M = o.map((T) => ({
3891
3903
  ...T,
3892
3904
  checkpointId: T.checkpointId ?? l ?? null,
3893
3905
  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 : [];
3906
+ })), A = e.values, k = Array.isArray(e.interrupts) ? e.interrupts : Array.isArray(A == null ? void 0 : A.interrupts) ? A.interrupts : [];
3895
3907
  return {
3896
3908
  checkpointId: l ?? null,
3897
3909
  checkpointNs: d ?? null,
3898
- createdAt: I,
3910
+ createdAt: v,
3899
3911
  parentId: g ?? null,
3900
3912
  messages: M,
3901
3913
  interrupt: Pr(
@@ -3903,11 +3915,11 @@ function Cr(e, t) {
3903
3915
  t,
3904
3916
  l ?? null
3905
3917
  ),
3906
- metadata: A,
3918
+ metadata: x,
3907
3919
  config: m ?? null,
3908
3920
  parentConfig: u ?? null,
3909
3921
  next: f,
3910
- tasks: v,
3922
+ tasks: I,
3911
3923
  values: e.values ?? {}
3912
3924
  };
3913
3925
  }
@@ -3917,15 +3929,15 @@ function Er(e, t) {
3917
3929
  }
3918
3930
  function Pr(e, t, n) {
3919
3931
  const r = e.length;
3920
- for (let o = r - 1; o >= 0; o -= 1) {
3921
- const s = e[o];
3922
- if (!s || typeof s != "object")
3932
+ for (let s = r - 1; s >= 0; s -= 1) {
3933
+ const o = e[s];
3934
+ if (!o || typeof o != "object")
3923
3935
  continue;
3924
- const a = s, i = a.value ?? s;
3936
+ const a = o, i = a.value ?? o;
3925
3937
  if (i == null)
3926
3938
  continue;
3927
3939
  return {
3928
- id: typeof a.id == "string" && a.id.trim() ? a.id : `interrupt-${n ?? t}-${o}`,
3940
+ id: typeof a.id == "string" && a.id.trim() ? a.id : `interrupt-${n ?? t}-${s}`,
3929
3941
  value: i
3930
3942
  };
3931
3943
  }
@@ -3950,45 +3962,45 @@ function zr(e) {
3950
3962
  return _r(e.content) || "";
3951
3963
  }
3952
3964
  function Nr(e) {
3953
- const t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Map(), o = [];
3965
+ const t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Map(), s = [];
3954
3966
  for (let c = 0; c < e.length; c++) {
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;
3967
+ const l = e[c], d = l.checkpointId, g = d ?? `cp-${c}`, m = l.metadata ?? {}, I = typeof m.step == "number" ? m.step : null, f = typeof m.source == "string" ? m.source : null;
3968
+ let v = null, x = null;
3957
3969
  const M = Array.isArray(l.messages) ? l.messages : [];
3958
3970
  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 = {
3971
+ h.role === "user" && (x || (x = h), h.id && (v = h.id));
3972
+ const A = l.next && l.next.length > 0 ? String(l.next[0]) : null, k = l.parentConfig ?? null, b = {
3961
3973
  id: g,
3962
- step: v,
3974
+ step: I,
3963
3975
  source: f,
3964
3976
  createdAt: l.createdAt ?? null,
3965
3977
  namespace: l.checkpointNs ?? null,
3966
3978
  parentId: l.parentId ?? null,
3967
- next: x,
3979
+ next: A,
3968
3980
  parentConfig: k,
3969
- userMessageId: I
3981
+ userMessageId: v
3970
3982
  };
3971
- if (o.push(b), d && t.set(d, b), d && A) {
3972
- const h = zr(A);
3983
+ if (s.push(b), d && t.set(d, b), d && x) {
3984
+ const h = zr(x);
3973
3985
  h && r.set(d, h);
3974
3986
  }
3975
3987
  n.push({
3976
3988
  id: g,
3977
- messageId: I,
3978
- step: v,
3989
+ messageId: v,
3990
+ step: I,
3979
3991
  source: f,
3980
3992
  createdAt: l.createdAt ?? null,
3981
- next: x,
3993
+ next: A,
3982
3994
  parentConfig: k
3983
3995
  });
3984
3996
  }
3985
- const s = /* @__PURE__ */ new Map();
3986
- for (const c of o) {
3997
+ const o = /* @__PURE__ */ new Map();
3998
+ for (const c of s) {
3987
3999
  if (!c.userMessageId) continue;
3988
- const l = s.get(c.userMessageId) ?? [];
3989
- l.push(c), s.set(c.userMessageId, l);
4000
+ const l = o.get(c.userMessageId) ?? [];
4001
+ l.push(c), o.set(c.userMessageId, l);
3990
4002
  }
3991
- for (const c of s.values()) {
4003
+ for (const c of o.values()) {
3992
4004
  if (!c.length) continue;
3993
4005
  c.sort((d, g) => {
3994
4006
  const m = d.createdAt ? Date.parse(d.createdAt) : 0;
@@ -4016,26 +4028,26 @@ function Nr(e) {
4016
4028
  for (const d of t.values())
4017
4029
  d.userMessageId === c && l.push(d);
4018
4030
  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;
4031
+ const m = typeof d.attemptIndex == "number" ? d.attemptIndex : Number.MAX_SAFE_INTEGER, I = typeof g.attemptIndex == "number" ? g.attemptIndex : Number.MAX_SAFE_INTEGER;
4032
+ return m - I;
4021
4033
  }), l) : [];
4022
4034
  }
4023
4035
  };
4024
4036
  }
4025
- function uo(e, t, n) {
4037
+ function us(e, t, n) {
4026
4038
  if (!e)
4027
4039
  return { attemptCount: 1, attemptIndex: 0, attempts: [] };
4028
4040
  const r = n.getMessageAttempts(e);
4029
4041
  if (!r.length)
4030
4042
  return { attemptCount: 1, attemptIndex: 0, attempts: [] };
4031
- let o = 0;
4043
+ let s = 0;
4032
4044
  if (t) {
4033
- const s = r.findIndex((a) => a.id === t);
4034
- s >= 0 && (o = s);
4045
+ const o = r.findIndex((a) => a.id === t);
4046
+ o >= 0 && (s = o);
4035
4047
  }
4036
4048
  return {
4037
4049
  attemptCount: r.length,
4038
- attemptIndex: o,
4050
+ attemptIndex: s,
4039
4051
  attempts: r
4040
4052
  };
4041
4053
  }
@@ -4047,18 +4059,18 @@ function $t({
4047
4059
  fileApi: t,
4048
4060
  seed: n,
4049
4061
  onError: r,
4050
- currentThreadId: o,
4051
- autoLoadInitial: s = !0,
4062
+ currentThreadId: s,
4063
+ autoLoadInitial: o = !0,
4052
4064
  isStreaming: a,
4053
4065
  getMessages: i
4054
4066
  }) {
4055
4067
  const [u, c] = $(null), d = Y(
4056
4068
  () => mt(u),
4057
4069
  [u]
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);
4070
+ ).checkpoints, g = Rr(d), m = g.timeline, [I, f] = $(!1), [v, x] = $(!1), [M, A] = $(!1), [k, b] = $(null), h = W(s), T = W(null), p = W(null);
4059
4071
  X(() => {
4060
- h.current = o;
4061
- }, [o]);
4072
+ h.current = s;
4073
+ }, [s]);
4062
4074
  const w = _(
4063
4075
  async (E) => {
4064
4076
  const B = await e.getState({
@@ -4078,7 +4090,7 @@ function $t({
4078
4090
  var N;
4079
4091
  if (!E) return;
4080
4092
  const z = `${E}:${B ?? "latest"}`;
4081
- if (T.current === z || v) return;
4093
+ if (T.current === z || I) return;
4082
4094
  (N = p.current) == null || N.abort();
4083
4095
  const K = new AbortController();
4084
4096
  p.current = K, f(!0), b(null);
@@ -4096,7 +4108,7 @@ function $t({
4096
4108
  checkpointNs: (L == null ? void 0 : L.checkpointNs) ?? null,
4097
4109
  pendingInterrupt: (L == null ? void 0 : L.interrupt) ?? null,
4098
4110
  values: L == null ? void 0 : L.values
4099
- }), T.current = z, f(!1), x(!0);
4111
+ }), T.current = z, f(!1), A(!0);
4100
4112
  try {
4101
4113
  const H = await e.getStateHistory({
4102
4114
  threadId: E,
@@ -4105,7 +4117,7 @@ function $t({
4105
4117
  });
4106
4118
  h.current === E && c(H);
4107
4119
  } finally {
4108
- x(!1);
4120
+ A(!1);
4109
4121
  }
4110
4122
  } catch (L) {
4111
4123
  if (f(!1), !Xt(L)) {
@@ -4117,11 +4129,11 @@ function $t({
4117
4129
  [e, n, w, r, i]
4118
4130
  ), j = _(
4119
4131
  async (E, B) => {
4120
- if (o) {
4121
- A(!0);
4132
+ if (s) {
4133
+ x(!0);
4122
4134
  try {
4123
4135
  const z = await w({
4124
- threadId: o,
4136
+ threadId: s,
4125
4137
  checkpointId: E,
4126
4138
  checkpointNs: B ?? void 0
4127
4139
  });
@@ -4134,18 +4146,18 @@ function $t({
4134
4146
  } catch (z) {
4135
4147
  console.error("[useThreadHistoryState] Navigation failed", z);
4136
4148
  } finally {
4137
- A(!1);
4149
+ x(!1);
4138
4150
  }
4139
4151
  }
4140
4152
  },
4141
- [o, w, n]
4153
+ [s, w, n]
4142
4154
  ), C = _(async () => {
4143
- o && await P(o);
4144
- }, [o, P]), O = _(
4155
+ s && await P(s);
4156
+ }, [s, P]), O = _(
4145
4157
  async (E) => {
4146
4158
  var K;
4147
- const B = (E == null ? void 0 : E.threadId) || o;
4148
- if (!B || o !== B) return;
4159
+ const B = (E == null ? void 0 : E.threadId) || s;
4160
+ if (!B || s !== B) return;
4149
4161
  if (c(E), T.current = `${B}:latest`, (K = E.values) != null && K.messages) {
4150
4162
  const N = await w({
4151
4163
  threadId: B
@@ -4158,22 +4170,22 @@ function $t({
4158
4170
  });
4159
4171
  }
4160
4172
  },
4161
- [o, w, n]
4173
+ [s, w, n]
4162
4174
  );
4163
4175
  X(() => {
4164
- if (!s || !o || v || a) return;
4165
- const E = `${o}:latest`;
4166
- T.current !== E && P(o);
4167
- }, [s, o, v, a, P]);
4176
+ if (!o || !s || I || a) return;
4177
+ const E = `${s}:latest`;
4178
+ T.current !== E && P(s);
4179
+ }, [o, s, I, a, P]);
4168
4180
  const F = _(() => {
4169
- c(null), f(!1), A(!1), x(!1), b(null), T.current = null;
4181
+ c(null), f(!1), x(!1), A(!1), b(null), T.current = null;
4170
4182
  }, []);
4171
4183
  return {
4172
4184
  threadCheckpoints: d,
4173
4185
  threadTimeline: m,
4174
4186
  checkpointIndex: g,
4175
- isLoadingThread: v,
4176
- isLoadingCheckpoint: I,
4187
+ isLoadingThread: I,
4188
+ isLoadingCheckpoint: v,
4177
4189
  isLoadingHistory: M,
4178
4190
  threadStateError: k,
4179
4191
  loadThread: P,
@@ -4208,17 +4220,17 @@ function Ur({
4208
4220
  initialThreadId: t = null,
4209
4221
  initialCheckpointId: n = null,
4210
4222
  initialCheckpointNs: r = null,
4211
- autoLoadInitial: o = !0,
4212
- isStreaming: s,
4223
+ autoLoadInitial: s = !0,
4224
+ isStreaming: o,
4213
4225
  onError: a
4214
4226
  }) {
4215
- const { chatApi: i, fileApi: u } = Me(), { currentThreadId: c } = ot(), { state: l, seed: d, onEvent: g, dispatch: m } = kr(), {
4216
- threadCheckpoints: v,
4227
+ const { chatApi: i, fileApi: u } = Me(), { currentThreadId: c } = st(), { state: l, seed: d, onEvent: g, dispatch: m } = kr(), {
4228
+ threadCheckpoints: I,
4217
4229
  threadTimeline: f,
4218
- checkpointIndex: I,
4219
- isLoadingThread: A,
4230
+ checkpointIndex: v,
4231
+ isLoadingThread: x,
4220
4232
  isLoadingCheckpoint: M,
4221
- isLoadingHistory: x,
4233
+ isLoadingHistory: A,
4222
4234
  threadStateError: k,
4223
4235
  loadThread: b,
4224
4236
  navigateToCheckpoint: h,
@@ -4237,8 +4249,8 @@ function Ur({
4237
4249
  initialThreadId: t,
4238
4250
  initialCheckpointId: n,
4239
4251
  initialCheckpointNs: r,
4240
- autoLoadInitial: o,
4241
- isStreaming: s,
4252
+ autoLoadInitial: s,
4253
+ isStreaming: o,
4242
4254
  getMessages: _(() => l.messages, [l.messages])
4243
4255
  }), O = W(null), F = _(
4244
4256
  (S) => {
@@ -4277,14 +4289,14 @@ function Ur({
4277
4289
  id: l.lastCheckpointId ?? null,
4278
4290
  namespace: l.lastCheckpointNs ?? null
4279
4291
  },
4280
- checkpoints: v,
4281
- checkpointIndex: I,
4292
+ checkpoints: I,
4293
+ checkpointIndex: v,
4282
4294
  timelineCheckpoints: f,
4283
4295
  metadata: z,
4284
4296
  values: l.values ?? {},
4285
- isLoading: A,
4297
+ isLoading: x,
4286
4298
  isLoadingCheckpoint: M,
4287
- isLoadingHistory: x,
4299
+ isLoadingHistory: A,
4288
4300
  error: k,
4289
4301
  loadOlder: async () => {
4290
4302
  },
@@ -4306,7 +4318,7 @@ function Ur({
4306
4318
  respondToInterrupt: async (S, J, V) => {
4307
4319
  E.current && await E.current(S, J, V);
4308
4320
  },
4309
- messagePreviews: I.messagePreviews,
4321
+ messagePreviews: v.messagePreviews,
4310
4322
  handleValuesEvent: w,
4311
4323
  markSkipNextLoad: P,
4312
4324
  markStreamPendingThread: j,
@@ -4323,13 +4335,13 @@ function Ur({
4323
4335
  l.lastCheckpointId,
4324
4336
  l.lastCheckpointNs,
4325
4337
  l.values,
4326
- v,
4327
- f,
4328
4338
  I,
4339
+ f,
4340
+ v,
4329
4341
  z,
4330
- A,
4331
- M,
4332
4342
  x,
4343
+ M,
4344
+ A,
4333
4345
  k,
4334
4346
  d,
4335
4347
  N,
@@ -4359,32 +4371,32 @@ function Br({
4359
4371
  onError: t,
4360
4372
  onAuthError: n,
4361
4373
  onConnectionError: r,
4362
- onToolEnd: o,
4363
- onUpdateEvent: s,
4374
+ onToolEnd: s,
4375
+ onUpdateEvent: o,
4364
4376
  onCustomEvent: a,
4365
4377
  onMetadataEvent: i,
4366
4378
  onFinish: u,
4367
4379
  onStreamingChange: c
4368
4380
  }) {
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(
4381
+ const { chatApi: l, baseUrl: d } = Me(), g = d, m = fe(t), I = fe(n), f = fe(r), v = fe(s), x = fe(o), M = fe(a), A = fe(i), k = fe(u), b = fe(c), h = Y(
4370
4382
  () => ({
4371
4383
  onError: m,
4372
- onAuthError: v,
4384
+ onAuthError: I,
4373
4385
  onConnectionError: f,
4374
- onMetadataEvent: x,
4386
+ onMetadataEvent: A,
4375
4387
  onCustomEvent: M,
4376
- onUpdateEvent: A,
4377
- onToolEnd: I,
4388
+ onUpdateEvent: x,
4389
+ onToolEnd: v,
4378
4390
  onFinish: k
4379
4391
  }),
4380
4392
  [
4381
4393
  m,
4382
- v,
4394
+ I,
4383
4395
  f,
4384
- x,
4385
- M,
4386
4396
  A,
4387
- I,
4397
+ M,
4398
+ x,
4399
+ v,
4388
4400
  k
4389
4401
  ]
4390
4402
  );
@@ -4404,27 +4416,27 @@ function Fr({
4404
4416
  api: t,
4405
4417
  streamBaseUrl: n,
4406
4418
  handlers: r,
4407
- onStreamingChange: o
4419
+ onStreamingChange: s
4408
4420
  }) {
4409
- const { setCurrentThreadId: s, currentThreadIdRef: a, addThreadFromEvent: i, currentThreadId: u } = ot(), {
4421
+ const { setCurrentThreadId: o, currentThreadIdRef: a, addThreadFromEvent: i, currentThreadId: u } = st(), {
4410
4422
  interrupt: c,
4411
4423
  checkpoint: l,
4412
4424
  timelineCheckpoints: d,
4413
4425
  handleValuesEvent: g,
4414
4426
  markSkipNextLoad: m,
4415
- markStreamPendingThread: v,
4427
+ markStreamPendingThread: I,
4416
4428
  resetHistoryState: f,
4417
- pushUser: I,
4418
- onEvent: A,
4429
+ pushUser: v,
4430
+ onEvent: x,
4419
4431
  messages: M
4420
- } = Vt(), { registerClearThread: x, registerRespondToInterrupt: k } = Lr(), b = _(
4432
+ } = Vt(), { registerClearThread: A, registerRespondToInterrupt: k } = Lr(), b = _(
4421
4433
  (y) => {
4422
- i(y), v(y.threadId), a.current !== y.threadId && ((y.created ?? !a.current) && m(y.threadId), s(y.threadId));
4434
+ i(y), I(y.threadId), a.current !== y.threadId && ((y.created ?? !a.current) && m(y.threadId), o(y.threadId));
4423
4435
  },
4424
- [i, m, v, s, a]
4436
+ [i, m, I, o, a]
4425
4437
  ), h = pr({
4426
4438
  baseUrl: n,
4427
- onEvent: A,
4439
+ onEvent: x,
4428
4440
  onError: (y) => {
4429
4441
  var U;
4430
4442
  (U = r.onError) == null || U.call(r, (y == null ? void 0 : y.message) ?? String(y));
@@ -4440,8 +4452,8 @@ function Fr({
4440
4452
  handleValuesEvent: g
4441
4453
  });
4442
4454
  X(() => {
4443
- o == null || o(h.isStreaming);
4444
- }, [h.isStreaming, o]);
4455
+ s == null || s(h.isStreaming);
4456
+ }, [h.isStreaming, s]);
4445
4457
  const { stream: T, stop: p, clear: w, isStreaming: P, error: j, connected: C, streamedMessages: O, activeMessageId: F } = h;
4446
4458
  X(() => {
4447
4459
  u !== void 0 && w();
@@ -4480,11 +4492,11 @@ function Fr({
4480
4492
  k(z);
4481
4493
  }, [z, k]);
4482
4494
  const K = _(async () => {
4483
- p(), w(), f(), s(null);
4484
- }, [w, f, s, p]);
4495
+ p(), w(), f(), o(null);
4496
+ }, [w, f, o, p]);
4485
4497
  X(() => {
4486
- x(K);
4487
- }, [K, x]);
4498
+ A(K);
4499
+ }, [K, A]);
4488
4500
  const N = _(
4489
4501
  async (y, U) => {
4490
4502
  P && p();
@@ -4495,11 +4507,11 @@ function Fr({
4495
4507
  if (!S && !q && V.length === 0 && !ue && !G) return;
4496
4508
  if (!S) {
4497
4509
  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);
4498
- S = `${ye}${he}`, m(S), s(S);
4510
+ S = `${ye}${he}`, m(S), o(S);
4499
4511
  }
4500
4512
  let te = null;
4501
4513
  y.contentParts && y.contentParts.length > 0 && (te = y.contentParts);
4502
- const { contentParts: ke, filesInfo: Q } = te ? { contentParts: te, filesInfo: [] } : await or(V), Z = [...ke];
4514
+ const { contentParts: ke, filesInfo: Q } = te ? { contentParts: te, filesInfo: [] } : await sr(V), Z = [...ke];
4503
4515
  q && Z.push({ type: "text", text: J });
4504
4516
  const ge = y == null ? void 0 : y.originalMessageId, je = !!(y != null && y.edit && ge), Be = !ue && Z.length > 0;
4505
4517
  let me = null;
@@ -4510,30 +4522,30 @@ function Fr({
4510
4522
  role: "user",
4511
4523
  content: Z,
4512
4524
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
4513
- }, "user"), je ? I(me, { editingMessageId: ge }) : I(me);
4525
+ }, "user"), je ? v(me, { editingMessageId: ge }) : v(me);
4514
4526
  }
4515
- const Ie = ue ? re : me ? [me] : [], oe = {
4527
+ const ve = ue ? re : me ? [me] : [], se = {
4516
4528
  ...ee,
4517
4529
  ...Q.length ? { files_info: Q } : {}
4518
4530
  };
4519
- Ie.length ? oe.messages = Ie : "messages" in oe || (oe.messages = []);
4531
+ ve.length ? se.messages = ve : "messages" in se || (se.messages = []);
4520
4532
  const Pe = (y == null ? void 0 : y.checkpointId) ?? l.id ?? void 0;
4521
4533
  if (y != null && y.edit && !Pe)
4522
4534
  throw new Error(
4523
4535
  `[streaming] Missing checkpointId for edit submit. threadId=${S ?? "null"}`
4524
4536
  );
4525
- const Ae = {
4537
+ const xe = {
4526
4538
  threadId: S,
4527
4539
  content: y == null ? void 0 : y.text,
4528
- payload: oe,
4540
+ payload: se,
4529
4541
  config: y == null ? void 0 : y.config,
4530
4542
  checkpointId: Pe,
4531
4543
  command: y == null ? void 0 : y.command,
4532
4544
  edit: y == null ? void 0 : y.edit
4533
4545
  };
4534
- return E(Ae, U);
4546
+ return E(xe, U);
4535
4547
  },
4536
- [l, a, P, m, I, E, p, d]
4548
+ [l, a, P, m, v, E, p, d]
4537
4549
  ), L = Y(() => M, [M]), H = Y(
4538
4550
  () => ({
4539
4551
  isStreaming: P,
@@ -4576,8 +4588,8 @@ function $r(e, t) {
4576
4588
  const n = Object.keys(e), r = Object.keys(t);
4577
4589
  if (n.length !== r.length)
4578
4590
  return !1;
4579
- for (const o of n)
4580
- if (!Object.prototype.hasOwnProperty.call(t, o) || !Object.is(e[o], t[o]))
4591
+ for (const s of n)
4592
+ if (!Object.prototype.hasOwnProperty.call(t, s) || !Object.is(e[s], t[s]))
4581
4593
  return !1;
4582
4594
  return !0;
4583
4595
  }
@@ -4586,23 +4598,23 @@ function Dr(e) {
4586
4598
  return $r(t.current, e) || (t.current = e, n.current = e), n.current;
4587
4599
  }
4588
4600
  function Kr(e) {
4589
- const t = e.artifact && typeof e.artifact == "object" ? e.artifact : null, n = !t && e.content && typeof e.content == "object" ? e.content : null, r = t ?? n, o = (r == null ? void 0 : r.task_id) ?? (r == null ? void 0 : r.taskId) ?? null;
4590
- return typeof o == "string" ? o : null;
4601
+ const t = e.artifact && typeof e.artifact == "object" ? e.artifact : null, n = !t && e.content && typeof e.content == "object" ? e.content : null, r = t ?? n, s = (r == null ? void 0 : r.task_id) ?? (r == null ? void 0 : r.taskId) ?? null;
4602
+ return typeof s == "string" ? s : null;
4591
4603
  }
4592
- function fo(e) {
4604
+ function ds(e) {
4593
4605
  const { setCurrentTaskId: t, getCurrentTaskId: n, onToolEnd: r } = e;
4594
- return (o) => {
4595
- const s = Kr(o), a = (n == null ? void 0 : n()) ?? null;
4596
- s && s !== a && t(s), r == null || r(o);
4606
+ return (s) => {
4607
+ const o = Kr(s), a = (n == null ? void 0 : n()) ?? null;
4608
+ o && o !== a && t(o), r == null || r(s);
4597
4609
  };
4598
4610
  }
4599
- function po({
4611
+ function fs({
4600
4612
  children: e,
4601
4613
  apiConfig: t,
4602
4614
  initialThreadId: n = null,
4603
4615
  initialCheckpointId: r = null,
4604
- initialCheckpointNs: o = null,
4605
- autoLoadInitial: s = !0,
4616
+ initialCheckpointNs: s = null,
4617
+ autoLoadInitial: o = !0,
4606
4618
  onConnectionError: a,
4607
4619
  onError: i,
4608
4620
  onAuthError: u,
@@ -4611,12 +4623,12 @@ function po({
4611
4623
  onUpdateEvent: d,
4612
4624
  onCustomEvent: g,
4613
4625
  onMetadataEvent: m,
4614
- onFinish: v
4626
+ onFinish: I
4615
4627
  }) {
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(
4628
+ const f = Dr(t), [v, x] = $(!1), M = pe(i), A = pe(u), k = pe(a), b = pe(c), h = pe(l), T = pe(d), p = pe(g), w = pe(m), P = pe(I), j = Y(
4617
4629
  () => ({
4618
4630
  onError: M,
4619
- onAuthError: x,
4631
+ onAuthError: A,
4620
4632
  onConnectionError: k,
4621
4633
  onToolEnd: h,
4622
4634
  onUpdateEvent: T,
@@ -4626,7 +4638,7 @@ function po({
4626
4638
  }),
4627
4639
  [
4628
4640
  M,
4629
- x,
4641
+ A,
4630
4642
  k,
4631
4643
  h,
4632
4644
  T,
@@ -4646,15 +4658,15 @@ function po({
4646
4658
  {
4647
4659
  initialThreadId: n,
4648
4660
  initialCheckpointId: r,
4649
- initialCheckpointNs: o,
4650
- autoLoadInitial: s,
4661
+ initialCheckpointNs: s,
4662
+ autoLoadInitial: o,
4651
4663
  onError: M,
4652
- isStreaming: I,
4664
+ isStreaming: v,
4653
4665
  children: /* @__PURE__ */ ie(
4654
4666
  Br,
4655
4667
  {
4656
4668
  ...j,
4657
- onStreamingChange: A,
4669
+ onStreamingChange: x,
4658
4670
  children: e
4659
4671
  }
4660
4672
  )
@@ -4731,9 +4743,9 @@ function Le(e) {
4731
4743
  });
4732
4744
  }
4733
4745
  function Wr({ ...e }) {
4734
- const t = Hr(), n = (o) => Le({
4746
+ const t = Hr(), n = (s) => Le({
4735
4747
  type: "UPDATE_TOAST",
4736
- toast: { ...o, id: t }
4748
+ toast: { ...s, id: t }
4737
4749
  }), r = () => Le({ type: "DISMISS_TOAST", toastId: t });
4738
4750
  return Le({
4739
4751
  type: "ADD_TOAST",
@@ -4741,8 +4753,8 @@ function Wr({ ...e }) {
4741
4753
  ...e,
4742
4754
  id: t,
4743
4755
  open: !0,
4744
- onOpenChange: (o) => {
4745
- o || r();
4756
+ onOpenChange: (s) => {
4757
+ s || r();
4746
4758
  }
4747
4759
  }
4748
4760
  }), {
@@ -4762,33 +4774,33 @@ function Jr() {
4762
4774
  dismiss: (n) => Le({ type: "DISMISS_TOAST", toastId: n })
4763
4775
  };
4764
4776
  }
4765
- function go(e) {
4766
- const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Me(), { toast: o } = Jr(), [s, a] = $({}), [i, u] = $(null), [c, l] = $(!1), d = _(() => {
4777
+ function ps(e) {
4778
+ const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Me(), { toast: s } = Jr(), [o, a] = $({}), [i, u] = $(null), [c, l] = $(!1), d = _(() => {
4767
4779
  l(!1), u(null);
4768
- }, []), g = _((v) => {
4769
- u(v), l(!0);
4780
+ }, []), g = _((I) => {
4781
+ u(I), l(!0);
4770
4782
  }, []), m = _(
4771
- async (v, f, I) => {
4772
- var A, M;
4783
+ async (I, f, v) => {
4784
+ var x, M;
4773
4785
  if (!t) {
4774
- v.preventDefault();
4786
+ I.preventDefault();
4775
4787
  return;
4776
4788
  }
4777
- if (s[I]) {
4778
- v.preventDefault();
4789
+ if (o[v]) {
4790
+ I.preventDefault();
4779
4791
  return;
4780
4792
  }
4781
4793
  try {
4782
- const x = String(f.url ?? ""), k = x.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);
4794
+ const A = String(f.url ?? ""), k = A.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);
4783
4795
  if (k) {
4784
- v.preventDefault();
4796
+ I.preventDefault();
4785
4797
  const b = k[1], h = f.name || `file_${b}`, T = f.mimeType || "application/octet-stream";
4786
4798
  g({ id: b, name: h, mimeType: T });
4787
4799
  return;
4788
4800
  }
4789
- if (x.startsWith("data:")) {
4790
- v.preventDefault(), a((h) => ({ ...h, [I]: !0 }));
4791
- const b = o({ title: "Fetching file...", description: "", open: !0 });
4801
+ if (A.startsWith("data:")) {
4802
+ I.preventDefault(), a((h) => ({ ...h, [v]: !0 }));
4803
+ const b = s({ title: "Fetching file...", description: "", open: !0 });
4792
4804
  try {
4793
4805
  const h = await r.listFiles(n ?? void 0);
4794
4806
  if (!h || !Array.isArray(h))
@@ -4802,7 +4814,7 @@ function go(e) {
4802
4814
  id: T.id,
4803
4815
  name: f.name || T.filename || `file_${T.id}`,
4804
4816
  mimeType: f.mimeType || T.mime_type || "application/octet-stream"
4805
- }), (A = b.update) == null || A.call(b, {
4817
+ }), (x = b.update) == null || x.call(b, {
4806
4818
  id: b.id,
4807
4819
  title: "Success",
4808
4820
  description: `Opened ${f.name}`,
@@ -4811,36 +4823,36 @@ function go(e) {
4811
4823
  } catch (h) {
4812
4824
  console.error("Failed to fetch server file:", h);
4813
4825
  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({
4826
+ (M = b.update) == null || M.call(b, { id: b.id, title: "Failed", description: T }), s({
4815
4827
  title: "Failed to fetch file",
4816
4828
  description: T,
4817
4829
  open: !0
4818
4830
  });
4819
4831
  } finally {
4820
- a((h) => ({ ...h, [I]: !1 }));
4832
+ a((h) => ({ ...h, [v]: !1 }));
4821
4833
  }
4822
4834
  }
4823
- } catch (x) {
4824
- console.error("File click error:", x), a((k) => ({ ...k, [I]: !1 }));
4835
+ } catch (A) {
4836
+ console.error("File click error:", A), a((k) => ({ ...k, [v]: !1 }));
4825
4837
  }
4826
4838
  },
4827
- [t, s, o, n, g]
4839
+ [t, o, s, n, g]
4828
4840
  );
4829
4841
  return {
4830
- uploadingFiles: s,
4842
+ uploadingFiles: o,
4831
4843
  handleFileClick: m,
4832
4844
  fileViewerOpen: c,
4833
4845
  currentFileInfo: i,
4834
4846
  closeFileViewer: d
4835
4847
  };
4836
4848
  }
4837
- function mo(e) {
4849
+ function gs(e) {
4838
4850
  return Y(() => {
4839
4851
  const t = e;
4840
4852
  let n = Array.isArray(t.content) ? t.content : [];
4841
4853
  return typeof t.content == "string" && (n = [{ type: "text", text: t.content }]), {
4842
4854
  contentParts: n,
4843
- textContent: sr(n),
4855
+ textContent: or(n),
4844
4856
  toolMeta: ar(t),
4845
4857
  imageParts: n.filter((r) => r.type === "image_url"),
4846
4858
  fileParts: n.filter((r) => r.type === "file"),
@@ -4854,13 +4866,13 @@ function Xr(e) {
4854
4866
  if (!e) return [];
4855
4867
  const t = [], n = e.split(/\r?\n/);
4856
4868
  for (const r of n) {
4857
- const o = r.trim();
4858
- if (!o || !o.startsWith(kt))
4869
+ const s = r.trim();
4870
+ if (!s || !s.startsWith(kt))
4859
4871
  continue;
4860
- const s = o.slice(kt.length).trim();
4861
- if (!s || s.toLowerCase() === "[done]")
4872
+ const o = s.slice(kt.length).trim();
4873
+ if (!o || o.toLowerCase() === "[done]")
4862
4874
  continue;
4863
- const a = tt(s);
4875
+ const a = tt(o);
4864
4876
  a && typeof a == "object" && t.push(a);
4865
4877
  }
4866
4878
  return t;
@@ -4873,7 +4885,7 @@ function Qr(e) {
4873
4885
  }
4874
4886
  return null;
4875
4887
  }
4876
- function yo(e) {
4888
+ function ms(e) {
4877
4889
  return Y(() => {
4878
4890
  const t = e.content.filter(
4879
4891
  (u) => u.type === "text"
@@ -4890,25 +4902,25 @@ function yo(e) {
4890
4902
  }
4891
4903
  if (!r.length)
4892
4904
  return null;
4893
- const s = Qr(r) ?? r[r.length - 1];
4894
- if (!s)
4905
+ const o = Qr(r) ?? r[r.length - 1];
4906
+ if (!o)
4895
4907
  return null;
4896
- const a = s.output ?? s.payload ?? s, i = ce(a);
4908
+ const a = o.output ?? o.payload ?? o, i = ce(a);
4897
4909
  return i && typeof i == "object" && !Array.isArray(i) ? {
4898
4910
  kind: "dict",
4899
4911
  value: i,
4900
4912
  data: i,
4901
- event: s
4913
+ event: o
4902
4914
  } : {
4903
4915
  kind: "generic",
4904
4916
  value: i,
4905
- event: s
4917
+ event: o
4906
4918
  };
4907
4919
  }, [e]);
4908
4920
  }
4909
4921
  function Yr(e) {
4910
4922
  var C, O;
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 || {
4923
+ const t = typeof e == "string" ? e : e == null ? void 0 : e.threadId, n = typeof e == "object" ? e.lazy : !1, r = st({ optional: !0 }), s = Vt({ optional: !0 }), o = Or(), { currentThreadId: a, setCurrentThreadId: i, actions: u } = r || {
4912
4924
  currentThreadId: null,
4913
4925
  setCurrentThreadId: () => {
4914
4926
  },
@@ -4917,10 +4929,10 @@ function Yr(e) {
4917
4929
  d(F);
4918
4930
  }, []), {
4919
4931
  isLoadingThread: m,
4920
- threadStateError: v,
4932
+ threadStateError: I,
4921
4933
  threadCheckpoints: f,
4922
- isLoadingHistory: I,
4923
- loadThread: A
4934
+ isLoadingHistory: v,
4935
+ loadThread: x
4924
4936
  } = $t({
4925
4937
  api: Me().chatApi,
4926
4938
  fileApi: Me().fileApi,
@@ -4932,12 +4944,12 @@ function Yr(e) {
4932
4944
  autoLoadInitial: c && !n
4933
4945
  });
4934
4946
  X(() => {
4935
- !c && !n && a && (o != null && o.loadThread) && o.loadThread(a);
4936
- }, [c, n, a, o == null ? void 0 : o.loadThread]);
4947
+ !c && !n && a && (s != null && s.loadThread) && s.loadThread(a);
4948
+ }, [c, n, a, s == null ? void 0 : s.loadThread]);
4937
4949
  const M = Y(() => {
4938
4950
  var F;
4939
4951
  return ((F = f[0]) == null ? void 0 : F.values) || {};
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;
4952
+ }, [f]), A = Y(() => ({ timeline: [], messagePreviews: {} }), []), k = t || a, b = c ? m ? "loading" : "idle" : (s == null ? void 0 : s.status) || "idle", h = c ? l : (o == null ? void 0 : o.messages) || [], T = c ? m : (s == null ? void 0 : s.isLoading) || !1, p = c ? v : (s == null ? void 0 : s.isLoadingHistory) || !1, w = c ? M : (s == null ? void 0 : s.values) || {}, P = c ? {} : (s == null ? void 0 : s.taskMessagesByScope) || {}, j = c ? I : (o == null ? void 0 : o.error) || (s == null ? void 0 : s.error) || null;
4941
4953
  return {
4942
4954
  // UNIFIED: Single thread ID concept
4943
4955
  threadId: k,
@@ -4949,42 +4961,42 @@ function Yr(e) {
4949
4961
  // Values & Metadata
4950
4962
  values: w,
4951
4963
  taskMessagesByScope: P,
4952
- metadata: c ? {} : o == null ? void 0 : o.metadata,
4964
+ metadata: c ? {} : s == null ? void 0 : s.metadata,
4953
4965
  // Actions & State relating to Global/Active Thread only
4954
4966
  navigateToCheckpoint: c ? async () => {
4955
- } : (o == null ? void 0 : o.navigateToCheckpoint) || (async () => {
4967
+ } : (s == null ? void 0 : s.navigateToCheckpoint) || (async () => {
4956
4968
  }),
4957
4969
  returnToLatest: c ? async () => {
4958
- } : (o == null ? void 0 : o.returnToLatest) || (async () => {
4970
+ } : (s == null ? void 0 : s.returnToLatest) || (async () => {
4959
4971
  }),
4960
- checkpoint: c ? f[0] ? { id: f[0].checkpointId, namespace: f[0].checkpointNs } : null : (o == null ? void 0 : o.checkpoint) || null,
4961
- checkpoints: c ? f : (o == null ? void 0 : o.checkpoints) || [],
4962
- checkpointIndex: c ? x : (o == null ? void 0 : o.checkpointIndex) || { timeline: [], messagePreviews: {} },
4963
- interrupt: c ? null : (o == null ? void 0 : o.interrupt) || null,
4972
+ checkpoint: c ? f[0] ? { id: f[0].checkpointId, namespace: f[0].checkpointNs } : null : (s == null ? void 0 : s.checkpoint) || null,
4973
+ checkpoints: c ? f : (s == null ? void 0 : s.checkpoints) || [],
4974
+ checkpointIndex: c ? A : (s == null ? void 0 : s.checkpointIndex) || { timeline: [], messagePreviews: {} },
4975
+ interrupt: c ? null : (s == null ? void 0 : s.interrupt) || null,
4964
4976
  respondToInterrupt: c ? async () => {
4965
- } : (o == null ? void 0 : o.respondToInterrupt) || (async () => {
4977
+ } : (s == null ? void 0 : s.respondToInterrupt) || (async () => {
4966
4978
  }),
4967
4979
  // Streaming Status
4968
4980
  // Even in standalone mode, allow streaming state/stop if a stream context exists.
4969
- isStreaming: (s == null ? void 0 : s.isStreaming) || !1,
4970
- activeMessageId: c ? null : ((C = o == null ? void 0 : o.metadata) == null ? void 0 : C.assemblingMessageId) || (s == null ? void 0 : s.activeMessageId) || null,
4971
- connectionState: (s == null ? void 0 : s.connectionState) || "disconnected",
4972
- streamingAssistantId: !c && (s != null && s.isStreaming) && ((O = o == null ? void 0 : o.metadata) != null && O.assemblingMessageId) ? o.metadata.assemblingMessageId : null,
4981
+ isStreaming: (o == null ? void 0 : o.isStreaming) || !1,
4982
+ activeMessageId: c ? null : ((C = s == null ? void 0 : s.metadata) == null ? void 0 : C.assemblingMessageId) || (o == null ? void 0 : o.activeMessageId) || null,
4983
+ connectionState: (o == null ? void 0 : o.connectionState) || "disconnected",
4984
+ streamingAssistantId: !c && (o != null && o.isStreaming) && ((O = s == null ? void 0 : s.metadata) != null && O.assemblingMessageId) ? s.metadata.assemblingMessageId : null,
4973
4985
  // Actions
4974
- submit: (s == null ? void 0 : s.submit) || (async () => {
4986
+ submit: (o == null ? void 0 : o.submit) || (async () => {
4975
4987
  }),
4976
- stop: (s == null ? void 0 : s.stop) || (() => {
4988
+ stop: (o == null ? void 0 : o.stop) || (() => {
4977
4989
  }),
4978
4990
  clearThread: c ? async () => {
4979
- } : (o == null ? void 0 : o.clearThread) || (async () => {
4991
+ } : (s == null ? void 0 : s.clearThread) || (async () => {
4980
4992
  }),
4981
4993
  setCurrentThreadId: i,
4982
4994
  loadHistory: c ? async () => {
4983
- t && await A(t);
4995
+ t && await x(t);
4984
4996
  } : async () => {
4985
4997
  },
4986
4998
  onEvent: c ? () => {
4987
- } : (o == null ? void 0 : o.onEvent) || (() => {
4999
+ } : (s == null ? void 0 : s.onEvent) || (() => {
4988
5000
  }),
4989
5001
  // Thread Management
4990
5002
  createThread: u == null ? void 0 : u.createThread,
@@ -4994,13 +5006,13 @@ function Yr(e) {
4994
5006
  isThreadsLoading: (r == null ? void 0 : r.isLoading) || !1
4995
5007
  };
4996
5008
  }
4997
- function ho({
5009
+ function ys({
4998
5010
  submit: e,
4999
5011
  chatRequest: t,
5000
5012
  lastCheckpointId: n,
5001
5013
  lastCheckpointNs: r,
5002
- onMessageSent: o,
5003
- onExcelUploadSuccess: s,
5014
+ onMessageSent: s,
5015
+ onExcelUploadSuccess: o,
5004
5016
  onError: a,
5005
5017
  enableMessageEditing: i,
5006
5018
  messages: u,
@@ -5010,7 +5022,7 @@ function ho({
5010
5022
  threadId: g,
5011
5023
  clearComposerOnSend: m = !0
5012
5024
  }) {
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);
5025
+ const { messages: I } = Yr(), [f, v] = $(null), [x, M] = $(""), [A, k] = $(null), [b, h] = $(null), [T, p] = $(!1), [w, P] = $(""), j = W(w), C = W(null);
5014
5026
  X(() => {
5015
5027
  if (!f)
5016
5028
  if (g) {
@@ -5029,8 +5041,8 @@ function ho({
5029
5041
  C.current = null;
5030
5042
  return;
5031
5043
  }
5032
- C.current === null && (C.current = j.current), O(A ?? "");
5033
- }, [A, f, O]);
5044
+ C.current === null && (C.current = j.current), O(x ?? "");
5045
+ }, [x, f, O]);
5034
5046
  const F = _(
5035
5047
  (y) => {
5036
5048
  O(y);
@@ -5059,7 +5071,7 @@ function ho({
5059
5071
  name: Q.filename,
5060
5072
  size: Q.size
5061
5073
  };
5062
- }), G = [...V, ...ue], te = f ? (x == null ? void 0 : x.checkpointId) ?? n ?? void 0 : n ?? void 0, ke = f ? (x == null ? void 0 : x.checkpointNs) ?? r ?? void 0 : r ?? void 0;
5074
+ }), G = [...V, ...ue], te = f ? (A == null ? void 0 : A.checkpointId) ?? n ?? void 0 : n ?? void 0, ke = f ? (A == null ? void 0 : A.checkpointNs) ?? r ?? void 0 : r ?? void 0;
5063
5075
  await e(
5064
5076
  {
5065
5077
  text: q || "",
@@ -5074,7 +5086,7 @@ function ho({
5074
5086
  config: t.config
5075
5087
  },
5076
5088
  d ? { onEvent: d } : void 0
5077
- ), o == null || o(q), c(!0), m && (g && localStorage.removeItem(Ge(g)), O("")), h(null), I(null), M(""), k(null);
5089
+ ), s == null || s(q), c(!0), m && (g && localStorage.removeItem(Ge(g)), O("")), h(null), v(null), M(""), k(null);
5078
5090
  } catch (ee) {
5079
5091
  const re = (ee == null ? void 0 : ee.message) || "Failed to send message";
5080
5092
  h(re), a == null || a(re), c(!1);
@@ -5093,19 +5105,19 @@ function ho({
5093
5105
  config: t.config
5094
5106
  },
5095
5107
  d ? { onEvent: d } : void 0
5096
- ), s == null || s({ file: y });
5108
+ ), o == null || o({ file: y });
5097
5109
  },
5098
- [n, r, t, s, e]
5110
+ [n, r, t, o, e]
5099
5111
  ), K = _(
5100
5112
  (y, U, S) => {
5101
- i && (C.current = w, I(y), M(U), k({
5113
+ i && (C.current = w, v(y), M(U), k({
5102
5114
  checkpointId: (S == null ? void 0 : S.checkpointId) ?? null,
5103
5115
  checkpointNs: (S == null ? void 0 : S.checkpointNs) ?? null
5104
5116
  }), h(null));
5105
5117
  },
5106
5118
  [w, i]
5107
5119
  ), N = _(() => {
5108
- I(null), M(""), k(null), h(null);
5120
+ v(null), M(""), k(null), h(null);
5109
5121
  const y = C.current;
5110
5122
  y !== null && P(y), C.current = null;
5111
5123
  }, []), L = _((y) => {
@@ -5138,7 +5150,7 @@ function ho({
5138
5150
  }, [u, e, n, r, t]);
5139
5151
  return {
5140
5152
  editingMessageId: f,
5141
- editingInitialValue: A,
5153
+ editingInitialValue: x,
5142
5154
  inputError: b,
5143
5155
  setInputError: h,
5144
5156
  dismissError: T,
@@ -5151,10 +5163,10 @@ function ho({
5151
5163
  startEditing: K,
5152
5164
  cancelEditing: N,
5153
5165
  handleRegenerateCb: L,
5154
- displayMessages: v
5166
+ displayMessages: I
5155
5167
  };
5156
5168
  }
5157
- function bo(e) {
5169
+ function hs(e) {
5158
5170
  return Y(() => e ? {
5159
5171
  textContent: Ln(e),
5160
5172
  imageParts: Un(e),
@@ -5169,12 +5181,12 @@ function bo(e) {
5169
5181
  contentParts: []
5170
5182
  }, [e]);
5171
5183
  }
5172
- function wo(e, t, n) {
5173
- const [r, o] = $(e), s = W(e), a = W(null);
5184
+ function bs(e, t, n) {
5185
+ const [r, s] = $(e), o = W(e), a = W(null);
5174
5186
  return X(() => {
5175
- s.current = e;
5187
+ o.current = e;
5176
5188
  const i = () => {
5177
- o(s.current), a.current && (clearTimeout(a.current), a.current = null);
5189
+ s(o.current), a.current && (clearTimeout(a.current), a.current = null);
5178
5190
  };
5179
5191
  if (!t || n <= 0) {
5180
5192
  i();
@@ -5188,46 +5200,46 @@ function wo(e, t, n) {
5188
5200
  }, [e, t, n]), r;
5189
5201
  }
5190
5202
  export {
5191
- po as ChatProviders,
5203
+ fs as ChatProviders,
5192
5204
  Ur as ThreadStateProvider,
5193
5205
  mr as ThreadsProvider,
5194
- ro as cn,
5195
- sr as collectText,
5196
- fo as createTaskSyncToolEndHandler,
5206
+ rs as cn,
5207
+ or as collectText,
5208
+ ds as createTaskSyncToolEndHandler,
5197
5209
  Kr as extractTaskIdFromToolEnd,
5198
5210
  ar as extractToolMeta,
5199
- oo as formatToolOutput,
5200
- co as getAgentNameFromMessage,
5211
+ ss as formatToolOutput,
5212
+ cs as getAgentNameFromMessage,
5201
5213
  Pt as getChatToken,
5202
- uo as getMessageAttemptInfo,
5203
- ao as getToolCallArtifacts,
5214
+ us as getMessageAttemptInfo,
5215
+ as as getToolCallArtifacts,
5204
5216
  qn as getToolCalls,
5205
- so as hasContent,
5217
+ os as hasContent,
5206
5218
  mt as hydrateHistorySnapshots,
5207
5219
  Ct as isFileLike,
5208
5220
  zn as looksLikeMarkdown,
5209
- lo as messageSignature,
5210
- io as normalizeInterruptId,
5221
+ ls as messageSignature,
5222
+ is as normalizeInterruptId,
5211
5223
  _t as onChatTokenChanged,
5212
5224
  tt as parseJsonSafe,
5213
5225
  Et as pretty,
5214
5226
  Mr as refreshHistoryFileUrls,
5215
5227
  Ke as sanitizeForDisplay,
5216
- ve as setChatToken,
5228
+ Ie as setChatToken,
5217
5229
  Fn as stringifyTool,
5218
5230
  Me as useApi,
5219
- ho as useChatController,
5231
+ ys as useChatController,
5220
5232
  Yr as useChatSession,
5221
- go as useFilePreview,
5222
- bo as useMessageContent,
5223
- mo as useParsedMessageContent,
5233
+ ps as useFilePreview,
5234
+ hs as useMessageContent,
5235
+ gs as useParsedMessageContent,
5224
5236
  pr as useStream,
5225
- wo as useStreamingMarkdownBuffer,
5237
+ bs as useStreamingMarkdownBuffer,
5226
5238
  $t as useThreadHistoryState,
5227
5239
  Vt as useThreadState,
5228
5240
  Lr as useThreadStateUpdater,
5229
- ot as useThreads,
5241
+ st as useThreads,
5230
5242
  gr as useThreadsState,
5231
- yo as useToolPayload
5243
+ ms as useToolPayload
5232
5244
  };
5233
5245
  //# sourceMappingURL=index.esm.js.map