@teodorruskvi/chat-core 0.1.30 → 0.1.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,58 +1,58 @@
1
- var zn = Object.defineProperty;
2
- var Un = (e, t, n) => t in e ? zn(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var Bt = (e, t, n) => Un(e, typeof t != "symbol" ? t + "" : t, n);
1
+ var Ln = Object.defineProperty;
2
+ var zn = (e, t, n) => t in e ? Ln(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var $t = (e, t, n) => zn(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { jsx as Ce } from "react/jsx-runtime";
5
- import * as Dt from "react";
6
- import { createContext as Ge, useContext as at, useState as H, useRef as K, useEffect as ae, useCallback as E, useMemo as fe, useReducer as Fn } from "react";
7
- import jn, { isCancel as Vt } from "axios";
8
- function rn(e) {
5
+ import * as Bt from "react";
6
+ import { createContext as We, useContext as ot, useState as W, useRef as H, useEffect as se, useCallback as E, useMemo as de, useReducer as Un } from "react";
7
+ import Fn, { isCancel as Dt } from "axios";
8
+ function nn(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
12
  var s = e.length;
13
- for (t = 0; t < s; t++) e[t] && (n = rn(e[t])) && (r && (r += " "), r += n);
13
+ for (t = 0; t < s; t++) e[t] && (n = nn(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
- function On() {
18
- for (var e, t, n = 0, r = "", s = arguments.length; n < s; n++) (e = arguments[n]) && (t = rn(e)) && (r && (r += " "), r += t);
17
+ function jn() {
18
+ for (var e, t, n = 0, r = "", s = arguments.length; n < s; n++) (e = arguments[n]) && (t = nn(e)) && (r && (r += " "), r += t);
19
19
  return r;
20
20
  }
21
- const zt = "-", $n = (e) => {
22
- const t = Dn(e), {
21
+ const Lt = "-", On = (e) => {
22
+ const t = Bn(e), {
23
23
  conflictingClassGroups: n,
24
24
  conflictingClassGroupModifiers: r
25
25
  } = e;
26
26
  return {
27
27
  getClassGroupId: (a) => {
28
- const i = a.split(zt);
29
- return i[0] === "" && i.length !== 1 && i.shift(), sn(i, t) || Bn(a);
28
+ const i = a.split(Lt);
29
+ return i[0] === "" && i.length !== 1 && i.shift(), rn(i, t) || $n(a);
30
30
  },
31
31
  getConflictingClassGroupIds: (a, i) => {
32
32
  const f = n[a] || [];
33
33
  return i && r[a] ? [...f, ...r[a]] : f;
34
34
  }
35
35
  };
36
- }, sn = (e, t) => {
36
+ }, rn = (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), s = r ? sn(e.slice(1), r) : void 0;
40
+ const n = e[0], r = t.nextPart.get(n), s = r ? rn(e.slice(1), r) : void 0;
41
41
  if (s)
42
42
  return s;
43
43
  if (t.validators.length === 0)
44
44
  return;
45
- const o = e.join(zt);
45
+ const o = e.join(Lt);
46
46
  return (a = t.validators.find(({
47
47
  validator: i
48
48
  }) => i(o))) == null ? void 0 : a.classGroupId;
49
- }, Kt = /^\[(.+)\]$/, Bn = (e) => {
50
- if (Kt.test(e)) {
51
- const t = Kt.exec(e)[1], n = t == null ? void 0 : t.substring(0, t.indexOf(":"));
49
+ }, Vt = /^\[(.+)\]$/, $n = (e) => {
50
+ if (Vt.test(e)) {
51
+ const t = Vt.exec(e)[1], n = t == null ? void 0 : t.substring(0, t.indexOf(":"));
52
52
  if (n)
53
53
  return "arbitrary.." + n;
54
54
  }
55
- }, Dn = (e) => {
55
+ }, Bn = (e) => {
56
56
  const {
57
57
  theme: t,
58
58
  prefix: n
@@ -60,19 +60,19 @@ const zt = "-", $n = (e) => {
60
60
  nextPart: /* @__PURE__ */ new Map(),
61
61
  validators: []
62
62
  };
63
- return Kn(Object.entries(e.classGroups), n).forEach(([o, a]) => {
64
- Nt(a, r, o, t);
63
+ return Vn(Object.entries(e.classGroups), n).forEach(([o, a]) => {
64
+ Rt(a, r, o, t);
65
65
  }), r;
66
- }, Nt = (e, t, n, r) => {
66
+ }, Rt = (e, t, n, r) => {
67
67
  e.forEach((s) => {
68
68
  if (typeof s == "string") {
69
- const o = s === "" ? t : Ht(t, s);
69
+ const o = s === "" ? t : Kt(t, s);
70
70
  o.classGroupId = n;
71
71
  return;
72
72
  }
73
73
  if (typeof s == "function") {
74
- if (Vn(s)) {
75
- Nt(s(r), t, n, r);
74
+ if (Dn(s)) {
75
+ Rt(s(r), t, n, r);
76
76
  return;
77
77
  }
78
78
  t.validators.push({
@@ -82,21 +82,21 @@ const zt = "-", $n = (e) => {
82
82
  return;
83
83
  }
84
84
  Object.entries(s).forEach(([o, a]) => {
85
- Nt(a, Ht(t, o), n, r);
85
+ Rt(a, Kt(t, o), n, r);
86
86
  });
87
87
  });
88
- }, Ht = (e, t) => {
88
+ }, Kt = (e, t) => {
89
89
  let n = e;
90
- return t.split(zt).forEach((r) => {
90
+ return t.split(Lt).forEach((r) => {
91
91
  n.nextPart.has(r) || n.nextPart.set(r, {
92
92
  nextPart: /* @__PURE__ */ new Map(),
93
93
  validators: []
94
94
  }), n = n.nextPart.get(r);
95
95
  }), n;
96
- }, Vn = (e) => e.isThemeGetter, Kn = (e, t) => t ? e.map(([n, r]) => {
96
+ }, Dn = (e) => e.isThemeGetter, Vn = (e, t) => t ? e.map(([n, r]) => {
97
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
98
  return [n, s];
99
- }) : e, Hn = (e) => {
99
+ }) : e, Kn = (e) => {
100
100
  if (e < 1)
101
101
  return {
102
102
  get: () => {
@@ -120,7 +120,7 @@ const zt = "-", $n = (e) => {
120
120
  n.has(o) ? n.set(o, a) : s(o, a);
121
121
  }
122
122
  };
123
- }, on = "!", qn = (e) => {
123
+ }, sn = "!", Hn = (e) => {
124
124
  const {
125
125
  separator: t,
126
126
  experimentalParseClassName: n
@@ -141,11 +141,11 @@ const zt = "-", $n = (e) => {
141
141
  }
142
142
  I === "[" ? l++ : I === "]" && l--;
143
143
  }
144
- const g = f.length === 0 ? i : i.substring(c), h = g.startsWith(on), v = h ? g.substring(1) : g, m = d && d > c ? d - c : void 0;
144
+ const g = f.length === 0 ? i : i.substring(c), h = g.startsWith(sn), k = h ? g.substring(1) : g, m = d && d > c ? d - c : void 0;
145
145
  return {
146
146
  modifiers: f,
147
147
  hasImportantModifier: h,
148
- baseClassName: v,
148
+ baseClassName: k,
149
149
  maybePostfixModifierPosition: m
150
150
  };
151
151
  };
@@ -153,7 +153,7 @@ const zt = "-", $n = (e) => {
153
153
  className: i,
154
154
  parseClassName: a
155
155
  }) : a;
156
- }, Wn = (e) => {
156
+ }, qn = (e) => {
157
157
  if (e.length <= 1)
158
158
  return e;
159
159
  const t = [];
@@ -161,16 +161,16 @@ const zt = "-", $n = (e) => {
161
161
  return e.forEach((r) => {
162
162
  r[0] === "[" ? (t.push(...n.sort(), r), n = []) : n.push(r);
163
163
  }), t.push(...n.sort()), t;
164
- }, Gn = (e) => ({
165
- cache: Hn(e.cacheSize),
166
- parseClassName: qn(e),
167
- ...$n(e)
168
- }), Jn = /\s+/, Xn = (e, t) => {
164
+ }, Wn = (e) => ({
165
+ cache: Kn(e.cacheSize),
166
+ parseClassName: Hn(e),
167
+ ...On(e)
168
+ }), Gn = /\s+/, Jn = (e, t) => {
169
169
  const {
170
170
  parseClassName: n,
171
171
  getClassGroupId: r,
172
172
  getConflictingClassGroupIds: s
173
- } = t, o = [], a = e.trim().split(Jn);
173
+ } = t, o = [], a = e.trim().split(Gn);
174
174
  let i = "";
175
175
  for (let f = a.length - 1; f >= 0; f -= 1) {
176
176
  const l = a[f], {
@@ -179,9 +179,9 @@ const zt = "-", $n = (e) => {
179
179
  baseClassName: g,
180
180
  maybePostfixModifierPosition: h
181
181
  } = n(l);
182
- let v = !!h, m = r(v ? g.substring(0, h) : g);
182
+ let k = !!h, m = r(k ? g.substring(0, h) : g);
183
183
  if (!m) {
184
- if (!v) {
184
+ if (!k) {
185
185
  i = l + (i.length > 0 ? " " + i : i);
186
186
  continue;
187
187
  }
@@ -189,94 +189,94 @@ const zt = "-", $n = (e) => {
189
189
  i = l + (i.length > 0 ? " " + i : i);
190
190
  continue;
191
191
  }
192
- v = !1;
192
+ k = !1;
193
193
  }
194
- const y = Wn(c).join(":"), I = d ? y + on : y, A = I + m;
195
- if (o.includes(A))
194
+ const y = qn(c).join(":"), I = d ? y + sn : y, S = I + m;
195
+ if (o.includes(S))
196
196
  continue;
197
- o.push(A);
198
- const x = s(m, v);
199
- for (let N = 0; N < x.length; ++N) {
200
- const _ = x[N];
201
- o.push(I + _);
197
+ o.push(S);
198
+ const C = s(m, k);
199
+ for (let L = 0; L < C.length; ++L) {
200
+ const z = C[L];
201
+ o.push(I + z);
202
202
  }
203
203
  i = l + (i.length > 0 ? " " + i : i);
204
204
  }
205
205
  return i;
206
206
  };
207
- function Qn() {
207
+ function Xn() {
208
208
  let e = 0, t, n, r = "";
209
209
  for (; e < arguments.length; )
210
- (t = arguments[e++]) && (n = an(t)) && (r && (r += " "), r += n);
210
+ (t = arguments[e++]) && (n = on(t)) && (r && (r += " "), r += n);
211
211
  return r;
212
212
  }
213
- const an = (e) => {
213
+ const on = (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 = an(e[r])) && (n && (n += " "), n += t);
218
+ e[r] && (t = on(e[r])) && (n && (n += " "), n += t);
219
219
  return n;
220
220
  };
221
- function Yn(e, ...t) {
221
+ function Qn(e, ...t) {
222
222
  let n, r, s, o = a;
223
223
  function a(f) {
224
224
  const l = t.reduce((c, d) => d(c), e());
225
- return n = Gn(l), r = n.cache.get, s = n.cache.set, o = i, i(f);
225
+ return n = Wn(l), r = n.cache.get, s = n.cache.set, o = i, i(f);
226
226
  }
227
227
  function i(f) {
228
228
  const l = r(f);
229
229
  if (l)
230
230
  return l;
231
- const c = Xn(f, n);
231
+ const c = Jn(f, n);
232
232
  return s(f, c), c;
233
233
  }
234
234
  return function() {
235
- return o(Qn.apply(null, arguments));
235
+ return o(Xn.apply(null, arguments));
236
236
  };
237
237
  }
238
- const Z = (e) => {
238
+ const te = (e) => {
239
239
  const t = (n) => n[e] || [];
240
240
  return t.isThemeGetter = !0, t;
241
- }, cn = /^\[(?:([a-z-]+):)?(.+)\]$/i, Zn = /^\d+\/\d+$/, er = /* @__PURE__ */ new Set(["px", "full", "screen"]), tr = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, nr = /\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$/, rr = /^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/, sr = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/, or = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/, Ne = (e) => qe(e) || er.has(e) || Zn.test(e), ze = (e) => Je(e, "length", pr), qe = (e) => !!e && !Number.isNaN(Number(e)), xt = (e) => Je(e, "number", qe), Ze = (e) => !!e && Number.isInteger(Number(e)), ar = (e) => e.endsWith("%") && qe(e.slice(0, -1)), F = (e) => cn.test(e), Ue = (e) => tr.test(e), ir = /* @__PURE__ */ new Set(["length", "size", "percentage"]), cr = (e) => Je(e, ir, ln), lr = (e) => Je(e, "position", ln), ur = /* @__PURE__ */ new Set(["image", "url"]), dr = (e) => Je(e, ur, mr), fr = (e) => Je(e, "", gr), et = () => !0, Je = (e, t, n) => {
242
- const r = cn.exec(e);
241
+ }, an = /^\[(?:([a-z-]+):)?(.+)\]$/i, Yn = /^\d+\/\d+$/, Zn = /* @__PURE__ */ new Set(["px", "full", "screen"]), er = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, tr = /\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$/, nr = /^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/, rr = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/, sr = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/, Ne = (e) => He(e) || Zn.has(e) || Yn.test(e), ze = (e) => Ge(e, "length", fr), He = (e) => !!e && !Number.isNaN(Number(e)), xt = (e) => Ge(e, "number", He), Ze = (e) => !!e && Number.isInteger(Number(e)), or = (e) => e.endsWith("%") && He(e.slice(0, -1)), O = (e) => an.test(e), Ue = (e) => er.test(e), ar = /* @__PURE__ */ new Set(["length", "size", "percentage"]), ir = (e) => Ge(e, ar, cn), cr = (e) => Ge(e, "position", cn), lr = /* @__PURE__ */ new Set(["image", "url"]), ur = (e) => Ge(e, lr, gr), dr = (e) => Ge(e, "", pr), et = () => !0, Ge = (e, t, n) => {
242
+ const r = an.exec(e);
243
243
  return r ? r[1] ? typeof t == "string" ? r[1] === t : t.has(r[1]) : n(r[2]) : !1;
244
- }, pr = (e) => (
244
+ }, fr = (e) => (
245
245
  // `colorFunctionRegex` check is necessary because color functions can have percentages in them which which would be incorrectly classified as lengths.
246
246
  // For example, `hsl(0 0% 0%)` would be classified as a length without this check.
247
247
  // I could also use lookbehind assertion in `lengthUnitRegex` but that isn't supported widely enough.
248
- nr.test(e) && !rr.test(e)
249
- ), ln = () => !1, gr = (e) => sr.test(e), mr = (e) => or.test(e), hr = () => {
250
- const e = Z("colors"), t = Z("spacing"), n = Z("blur"), r = Z("brightness"), s = Z("borderColor"), o = Z("borderRadius"), a = Z("borderSpacing"), i = Z("borderWidth"), f = Z("contrast"), l = Z("grayscale"), c = Z("hueRotate"), d = Z("invert"), g = Z("gap"), h = Z("gradientColorStops"), v = Z("gradientColorStopPositions"), m = Z("inset"), y = Z("margin"), I = Z("opacity"), A = Z("padding"), x = Z("saturate"), N = Z("scale"), _ = Z("sepia"), k = Z("skew"), T = Z("space"), L = Z("translate"), j = () => ["auto", "contain", "none"], O = () => ["auto", "hidden", "clip", "visible", "scroll"], $ = () => ["auto", F, t], C = () => [F, t], J = () => ["", Ne, ze], W = () => ["auto", qe, F], Q = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], te = () => ["solid", "dashed", "dotted", "double", "none"], ne = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], S = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], P = () => ["", "0", F], D = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], V = () => [qe, F];
248
+ tr.test(e) && !nr.test(e)
249
+ ), cn = () => !1, pr = (e) => rr.test(e), gr = (e) => sr.test(e), mr = () => {
250
+ const e = te("colors"), t = te("spacing"), n = te("blur"), r = te("brightness"), s = te("borderColor"), o = te("borderRadius"), a = te("borderSpacing"), i = te("borderWidth"), f = te("contrast"), l = te("grayscale"), c = te("hueRotate"), d = te("invert"), g = te("gap"), h = te("gradientColorStops"), k = te("gradientColorStopPositions"), m = te("inset"), y = te("margin"), I = te("opacity"), S = te("padding"), C = te("saturate"), L = te("scale"), z = te("sepia"), w = te("skew"), v = te("space"), F = te("translate"), $ = () => ["auto", "contain", "none"], B = () => ["auto", "hidden", "clip", "visible", "scroll"], D = () => ["auto", O, t], P = () => [O, t], J = () => ["", Ne, ze], G = () => ["auto", He, O], Q = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], X = () => ["solid", "dashed", "dotted", "double", "none"], oe = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], A = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], R = () => ["", "0", O], V = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], K = () => [He, O];
251
251
  return {
252
252
  cacheSize: 500,
253
253
  separator: ":",
254
254
  theme: {
255
255
  colors: [et],
256
256
  spacing: [Ne, ze],
257
- blur: ["none", "", Ue, F],
258
- brightness: V(),
257
+ blur: ["none", "", Ue, O],
258
+ brightness: K(),
259
259
  borderColor: [e],
260
- borderRadius: ["none", "", "full", Ue, F],
261
- borderSpacing: C(),
260
+ borderRadius: ["none", "", "full", Ue, O],
261
+ borderSpacing: P(),
262
262
  borderWidth: J(),
263
- contrast: V(),
264
- grayscale: P(),
265
- hueRotate: V(),
266
- invert: P(),
267
- gap: C(),
263
+ contrast: K(),
264
+ grayscale: R(),
265
+ hueRotate: K(),
266
+ invert: R(),
267
+ gap: P(),
268
268
  gradientColorStops: [e],
269
- gradientColorStopPositions: [ar, ze],
270
- inset: $(),
271
- margin: $(),
272
- opacity: V(),
273
- padding: C(),
274
- saturate: V(),
275
- scale: V(),
276
- sepia: P(),
277
- skew: V(),
278
- space: C(),
279
- translate: C()
269
+ gradientColorStopPositions: [or, ze],
270
+ inset: D(),
271
+ margin: D(),
272
+ opacity: K(),
273
+ padding: P(),
274
+ saturate: K(),
275
+ scale: K(),
276
+ sepia: R(),
277
+ skew: K(),
278
+ space: P(),
279
+ translate: P()
280
280
  },
281
281
  classGroups: {
282
282
  // Layout
@@ -285,7 +285,7 @@ const Z = (e) => {
285
285
  * @see https://tailwindcss.com/docs/aspect-ratio
286
286
  */
287
287
  aspect: [{
288
- aspect: ["auto", "square", "video", F]
288
+ aspect: ["auto", "square", "video", O]
289
289
  }],
290
290
  /**
291
291
  * Container
@@ -304,14 +304,14 @@ const Z = (e) => {
304
304
  * @see https://tailwindcss.com/docs/break-after
305
305
  */
306
306
  "break-after": [{
307
- "break-after": D()
307
+ "break-after": V()
308
308
  }],
309
309
  /**
310
310
  * Break Before
311
311
  * @see https://tailwindcss.com/docs/break-before
312
312
  */
313
313
  "break-before": [{
314
- "break-before": D()
314
+ "break-before": V()
315
315
  }],
316
316
  /**
317
317
  * Break Inside
@@ -370,49 +370,49 @@ const Z = (e) => {
370
370
  * @see https://tailwindcss.com/docs/object-position
371
371
  */
372
372
  "object-position": [{
373
- object: [...Q(), F]
373
+ object: [...Q(), O]
374
374
  }],
375
375
  /**
376
376
  * Overflow
377
377
  * @see https://tailwindcss.com/docs/overflow
378
378
  */
379
379
  overflow: [{
380
- overflow: O()
380
+ overflow: B()
381
381
  }],
382
382
  /**
383
383
  * Overflow X
384
384
  * @see https://tailwindcss.com/docs/overflow
385
385
  */
386
386
  "overflow-x": [{
387
- "overflow-x": O()
387
+ "overflow-x": B()
388
388
  }],
389
389
  /**
390
390
  * Overflow Y
391
391
  * @see https://tailwindcss.com/docs/overflow
392
392
  */
393
393
  "overflow-y": [{
394
- "overflow-y": O()
394
+ "overflow-y": B()
395
395
  }],
396
396
  /**
397
397
  * Overscroll Behavior
398
398
  * @see https://tailwindcss.com/docs/overscroll-behavior
399
399
  */
400
400
  overscroll: [{
401
- overscroll: j()
401
+ overscroll: $()
402
402
  }],
403
403
  /**
404
404
  * Overscroll Behavior X
405
405
  * @see https://tailwindcss.com/docs/overscroll-behavior
406
406
  */
407
407
  "overscroll-x": [{
408
- "overscroll-x": j()
408
+ "overscroll-x": $()
409
409
  }],
410
410
  /**
411
411
  * Overscroll Behavior Y
412
412
  * @see https://tailwindcss.com/docs/overscroll-behavior
413
413
  */
414
414
  "overscroll-y": [{
415
- "overscroll-y": j()
415
+ "overscroll-y": $()
416
416
  }],
417
417
  /**
418
418
  * Position
@@ -492,7 +492,7 @@ const Z = (e) => {
492
492
  * @see https://tailwindcss.com/docs/z-index
493
493
  */
494
494
  z: [{
495
- z: ["auto", Ze, F]
495
+ z: ["auto", Ze, O]
496
496
  }],
497
497
  // Flexbox and Grid
498
498
  /**
@@ -500,7 +500,7 @@ const Z = (e) => {
500
500
  * @see https://tailwindcss.com/docs/flex-basis
501
501
  */
502
502
  basis: [{
503
- basis: $()
503
+ basis: D()
504
504
  }],
505
505
  /**
506
506
  * Flex Direction
@@ -521,28 +521,28 @@ const Z = (e) => {
521
521
  * @see https://tailwindcss.com/docs/flex
522
522
  */
523
523
  flex: [{
524
- flex: ["1", "auto", "initial", "none", F]
524
+ flex: ["1", "auto", "initial", "none", O]
525
525
  }],
526
526
  /**
527
527
  * Flex Grow
528
528
  * @see https://tailwindcss.com/docs/flex-grow
529
529
  */
530
530
  grow: [{
531
- grow: P()
531
+ grow: R()
532
532
  }],
533
533
  /**
534
534
  * Flex Shrink
535
535
  * @see https://tailwindcss.com/docs/flex-shrink
536
536
  */
537
537
  shrink: [{
538
- shrink: P()
538
+ shrink: R()
539
539
  }],
540
540
  /**
541
541
  * Order
542
542
  * @see https://tailwindcss.com/docs/order
543
543
  */
544
544
  order: [{
545
- order: ["first", "last", "none", Ze, F]
545
+ order: ["first", "last", "none", Ze, O]
546
546
  }],
547
547
  /**
548
548
  * Grid Template Columns
@@ -557,22 +557,22 @@ const Z = (e) => {
557
557
  */
558
558
  "col-start-end": [{
559
559
  col: ["auto", {
560
- span: ["full", Ze, F]
561
- }, F]
560
+ span: ["full", Ze, O]
561
+ }, O]
562
562
  }],
563
563
  /**
564
564
  * Grid Column Start
565
565
  * @see https://tailwindcss.com/docs/grid-column
566
566
  */
567
567
  "col-start": [{
568
- "col-start": W()
568
+ "col-start": G()
569
569
  }],
570
570
  /**
571
571
  * Grid Column End
572
572
  * @see https://tailwindcss.com/docs/grid-column
573
573
  */
574
574
  "col-end": [{
575
- "col-end": W()
575
+ "col-end": G()
576
576
  }],
577
577
  /**
578
578
  * Grid Template Rows
@@ -587,22 +587,22 @@ const Z = (e) => {
587
587
  */
588
588
  "row-start-end": [{
589
589
  row: ["auto", {
590
- span: [Ze, F]
591
- }, F]
590
+ span: [Ze, O]
591
+ }, O]
592
592
  }],
593
593
  /**
594
594
  * Grid Row Start
595
595
  * @see https://tailwindcss.com/docs/grid-row
596
596
  */
597
597
  "row-start": [{
598
- "row-start": W()
598
+ "row-start": G()
599
599
  }],
600
600
  /**
601
601
  * Grid Row End
602
602
  * @see https://tailwindcss.com/docs/grid-row
603
603
  */
604
604
  "row-end": [{
605
- "row-end": W()
605
+ "row-end": G()
606
606
  }],
607
607
  /**
608
608
  * Grid Auto Flow
@@ -616,14 +616,14 @@ const Z = (e) => {
616
616
  * @see https://tailwindcss.com/docs/grid-auto-columns
617
617
  */
618
618
  "auto-cols": [{
619
- "auto-cols": ["auto", "min", "max", "fr", F]
619
+ "auto-cols": ["auto", "min", "max", "fr", O]
620
620
  }],
621
621
  /**
622
622
  * Grid Auto Rows
623
623
  * @see https://tailwindcss.com/docs/grid-auto-rows
624
624
  */
625
625
  "auto-rows": [{
626
- "auto-rows": ["auto", "min", "max", "fr", F]
626
+ "auto-rows": ["auto", "min", "max", "fr", O]
627
627
  }],
628
628
  /**
629
629
  * Gap
@@ -651,7 +651,7 @@ const Z = (e) => {
651
651
  * @see https://tailwindcss.com/docs/justify-content
652
652
  */
653
653
  "justify-content": [{
654
- justify: ["normal", ...S()]
654
+ justify: ["normal", ...A()]
655
655
  }],
656
656
  /**
657
657
  * Justify Items
@@ -672,7 +672,7 @@ const Z = (e) => {
672
672
  * @see https://tailwindcss.com/docs/align-content
673
673
  */
674
674
  "align-content": [{
675
- content: ["normal", ...S(), "baseline"]
675
+ content: ["normal", ...A(), "baseline"]
676
676
  }],
677
677
  /**
678
678
  * Align Items
@@ -693,7 +693,7 @@ const Z = (e) => {
693
693
  * @see https://tailwindcss.com/docs/place-content
694
694
  */
695
695
  "place-content": [{
696
- "place-content": [...S(), "baseline"]
696
+ "place-content": [...A(), "baseline"]
697
697
  }],
698
698
  /**
699
699
  * Place Items
@@ -715,63 +715,63 @@ const Z = (e) => {
715
715
  * @see https://tailwindcss.com/docs/padding
716
716
  */
717
717
  p: [{
718
- p: [A]
718
+ p: [S]
719
719
  }],
720
720
  /**
721
721
  * Padding X
722
722
  * @see https://tailwindcss.com/docs/padding
723
723
  */
724
724
  px: [{
725
- px: [A]
725
+ px: [S]
726
726
  }],
727
727
  /**
728
728
  * Padding Y
729
729
  * @see https://tailwindcss.com/docs/padding
730
730
  */
731
731
  py: [{
732
- py: [A]
732
+ py: [S]
733
733
  }],
734
734
  /**
735
735
  * Padding Start
736
736
  * @see https://tailwindcss.com/docs/padding
737
737
  */
738
738
  ps: [{
739
- ps: [A]
739
+ ps: [S]
740
740
  }],
741
741
  /**
742
742
  * Padding End
743
743
  * @see https://tailwindcss.com/docs/padding
744
744
  */
745
745
  pe: [{
746
- pe: [A]
746
+ pe: [S]
747
747
  }],
748
748
  /**
749
749
  * Padding Top
750
750
  * @see https://tailwindcss.com/docs/padding
751
751
  */
752
752
  pt: [{
753
- pt: [A]
753
+ pt: [S]
754
754
  }],
755
755
  /**
756
756
  * Padding Right
757
757
  * @see https://tailwindcss.com/docs/padding
758
758
  */
759
759
  pr: [{
760
- pr: [A]
760
+ pr: [S]
761
761
  }],
762
762
  /**
763
763
  * Padding Bottom
764
764
  * @see https://tailwindcss.com/docs/padding
765
765
  */
766
766
  pb: [{
767
- pb: [A]
767
+ pb: [S]
768
768
  }],
769
769
  /**
770
770
  * Padding Left
771
771
  * @see https://tailwindcss.com/docs/padding
772
772
  */
773
773
  pl: [{
774
- pl: [A]
774
+ pl: [S]
775
775
  }],
776
776
  /**
777
777
  * Margin
@@ -841,7 +841,7 @@ const Z = (e) => {
841
841
  * @see https://tailwindcss.com/docs/space
842
842
  */
843
843
  "space-x": [{
844
- "space-x": [T]
844
+ "space-x": [v]
845
845
  }],
846
846
  /**
847
847
  * Space Between X Reverse
@@ -853,7 +853,7 @@ const Z = (e) => {
853
853
  * @see https://tailwindcss.com/docs/space
854
854
  */
855
855
  "space-y": [{
856
- "space-y": [T]
856
+ "space-y": [v]
857
857
  }],
858
858
  /**
859
859
  * Space Between Y Reverse
@@ -866,21 +866,21 @@ const Z = (e) => {
866
866
  * @see https://tailwindcss.com/docs/width
867
867
  */
868
868
  w: [{
869
- w: ["auto", "min", "max", "fit", "svw", "lvw", "dvw", F, t]
869
+ w: ["auto", "min", "max", "fit", "svw", "lvw", "dvw", O, t]
870
870
  }],
871
871
  /**
872
872
  * Min-Width
873
873
  * @see https://tailwindcss.com/docs/min-width
874
874
  */
875
875
  "min-w": [{
876
- "min-w": [F, t, "min", "max", "fit"]
876
+ "min-w": [O, t, "min", "max", "fit"]
877
877
  }],
878
878
  /**
879
879
  * Max-Width
880
880
  * @see https://tailwindcss.com/docs/max-width
881
881
  */
882
882
  "max-w": [{
883
- "max-w": [F, t, "none", "full", "min", "max", "fit", "prose", {
883
+ "max-w": [O, t, "none", "full", "min", "max", "fit", "prose", {
884
884
  screen: [Ue]
885
885
  }, Ue]
886
886
  }],
@@ -889,28 +889,28 @@ const Z = (e) => {
889
889
  * @see https://tailwindcss.com/docs/height
890
890
  */
891
891
  h: [{
892
- h: [F, t, "auto", "min", "max", "fit", "svh", "lvh", "dvh"]
892
+ h: [O, t, "auto", "min", "max", "fit", "svh", "lvh", "dvh"]
893
893
  }],
894
894
  /**
895
895
  * Min-Height
896
896
  * @see https://tailwindcss.com/docs/min-height
897
897
  */
898
898
  "min-h": [{
899
- "min-h": [F, t, "min", "max", "fit", "svh", "lvh", "dvh"]
899
+ "min-h": [O, t, "min", "max", "fit", "svh", "lvh", "dvh"]
900
900
  }],
901
901
  /**
902
902
  * Max-Height
903
903
  * @see https://tailwindcss.com/docs/max-height
904
904
  */
905
905
  "max-h": [{
906
- "max-h": [F, t, "min", "max", "fit", "svh", "lvh", "dvh"]
906
+ "max-h": [O, t, "min", "max", "fit", "svh", "lvh", "dvh"]
907
907
  }],
908
908
  /**
909
909
  * Size
910
910
  * @see https://tailwindcss.com/docs/size
911
911
  */
912
912
  size: [{
913
- size: [F, t, "auto", "min", "max", "fit"]
913
+ size: [O, t, "auto", "min", "max", "fit"]
914
914
  }],
915
915
  // Typography
916
916
  /**
@@ -979,35 +979,35 @@ const Z = (e) => {
979
979
  * @see https://tailwindcss.com/docs/letter-spacing
980
980
  */
981
981
  tracking: [{
982
- tracking: ["tighter", "tight", "normal", "wide", "wider", "widest", F]
982
+ tracking: ["tighter", "tight", "normal", "wide", "wider", "widest", O]
983
983
  }],
984
984
  /**
985
985
  * Line Clamp
986
986
  * @see https://tailwindcss.com/docs/line-clamp
987
987
  */
988
988
  "line-clamp": [{
989
- "line-clamp": ["none", qe, xt]
989
+ "line-clamp": ["none", He, xt]
990
990
  }],
991
991
  /**
992
992
  * Line Height
993
993
  * @see https://tailwindcss.com/docs/line-height
994
994
  */
995
995
  leading: [{
996
- leading: ["none", "tight", "snug", "normal", "relaxed", "loose", Ne, F]
996
+ leading: ["none", "tight", "snug", "normal", "relaxed", "loose", Ne, O]
997
997
  }],
998
998
  /**
999
999
  * List Style Image
1000
1000
  * @see https://tailwindcss.com/docs/list-style-image
1001
1001
  */
1002
1002
  "list-image": [{
1003
- "list-image": ["none", F]
1003
+ "list-image": ["none", O]
1004
1004
  }],
1005
1005
  /**
1006
1006
  * List Style Type
1007
1007
  * @see https://tailwindcss.com/docs/list-style-type
1008
1008
  */
1009
1009
  "list-style-type": [{
1010
- list: ["none", "disc", "decimal", F]
1010
+ list: ["none", "disc", "decimal", O]
1011
1011
  }],
1012
1012
  /**
1013
1013
  * List Style Position
@@ -1062,7 +1062,7 @@ const Z = (e) => {
1062
1062
  * @see https://tailwindcss.com/docs/text-decoration-style
1063
1063
  */
1064
1064
  "text-decoration-style": [{
1065
- decoration: [...te(), "wavy"]
1065
+ decoration: [...X(), "wavy"]
1066
1066
  }],
1067
1067
  /**
1068
1068
  * Text Decoration Thickness
@@ -1076,7 +1076,7 @@ const Z = (e) => {
1076
1076
  * @see https://tailwindcss.com/docs/text-underline-offset
1077
1077
  */
1078
1078
  "underline-offset": [{
1079
- "underline-offset": ["auto", Ne, F]
1079
+ "underline-offset": ["auto", Ne, O]
1080
1080
  }],
1081
1081
  /**
1082
1082
  * Text Decoration Color
@@ -1107,14 +1107,14 @@ const Z = (e) => {
1107
1107
  * @see https://tailwindcss.com/docs/text-indent
1108
1108
  */
1109
1109
  indent: [{
1110
- indent: C()
1110
+ indent: P()
1111
1111
  }],
1112
1112
  /**
1113
1113
  * Vertical Alignment
1114
1114
  * @see https://tailwindcss.com/docs/vertical-align
1115
1115
  */
1116
1116
  "vertical-align": [{
1117
- align: ["baseline", "top", "middle", "bottom", "text-top", "text-bottom", "sub", "super", F]
1117
+ align: ["baseline", "top", "middle", "bottom", "text-top", "text-bottom", "sub", "super", O]
1118
1118
  }],
1119
1119
  /**
1120
1120
  * Whitespace
@@ -1142,7 +1142,7 @@ const Z = (e) => {
1142
1142
  * @see https://tailwindcss.com/docs/content
1143
1143
  */
1144
1144
  content: [{
1145
- content: ["none", F]
1145
+ content: ["none", O]
1146
1146
  }],
1147
1147
  // Backgrounds
1148
1148
  /**
@@ -1179,7 +1179,7 @@ const Z = (e) => {
1179
1179
  * @see https://tailwindcss.com/docs/background-position
1180
1180
  */
1181
1181
  "bg-position": [{
1182
- bg: [...Q(), lr]
1182
+ bg: [...Q(), cr]
1183
1183
  }],
1184
1184
  /**
1185
1185
  * Background Repeat
@@ -1195,7 +1195,7 @@ const Z = (e) => {
1195
1195
  * @see https://tailwindcss.com/docs/background-size
1196
1196
  */
1197
1197
  "bg-size": [{
1198
- bg: ["auto", "cover", "contain", cr]
1198
+ bg: ["auto", "cover", "contain", ir]
1199
1199
  }],
1200
1200
  /**
1201
1201
  * Background Image
@@ -1204,7 +1204,7 @@ const Z = (e) => {
1204
1204
  "bg-image": [{
1205
1205
  bg: ["none", {
1206
1206
  "gradient-to": ["t", "tr", "r", "br", "b", "bl", "l", "tl"]
1207
- }, dr]
1207
+ }, ur]
1208
1208
  }],
1209
1209
  /**
1210
1210
  * Background Color
@@ -1218,21 +1218,21 @@ const Z = (e) => {
1218
1218
  * @see https://tailwindcss.com/docs/gradient-color-stops
1219
1219
  */
1220
1220
  "gradient-from-pos": [{
1221
- from: [v]
1221
+ from: [k]
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: [k]
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: [k]
1236
1236
  }],
1237
1237
  /**
1238
1238
  * Gradient Color Stops From
@@ -1436,7 +1436,7 @@ const Z = (e) => {
1436
1436
  * @see https://tailwindcss.com/docs/border-style
1437
1437
  */
1438
1438
  "border-style": [{
1439
- border: [...te(), "hidden"]
1439
+ border: [...X(), "hidden"]
1440
1440
  }],
1441
1441
  /**
1442
1442
  * Divide Width X
@@ -1474,7 +1474,7 @@ const Z = (e) => {
1474
1474
  * @see https://tailwindcss.com/docs/divide-style
1475
1475
  */
1476
1476
  "divide-style": [{
1477
- divide: te()
1477
+ divide: X()
1478
1478
  }],
1479
1479
  /**
1480
1480
  * Border Color
@@ -1551,14 +1551,14 @@ const Z = (e) => {
1551
1551
  * @see https://tailwindcss.com/docs/outline-style
1552
1552
  */
1553
1553
  "outline-style": [{
1554
- outline: ["", ...te()]
1554
+ outline: ["", ...X()]
1555
1555
  }],
1556
1556
  /**
1557
1557
  * Outline Offset
1558
1558
  * @see https://tailwindcss.com/docs/outline-offset
1559
1559
  */
1560
1560
  "outline-offset": [{
1561
- "outline-offset": [Ne, F]
1561
+ "outline-offset": [Ne, O]
1562
1562
  }],
1563
1563
  /**
1564
1564
  * Outline Width
@@ -1620,7 +1620,7 @@ const Z = (e) => {
1620
1620
  * @see https://tailwindcss.com/docs/box-shadow
1621
1621
  */
1622
1622
  shadow: [{
1623
- shadow: ["", "inner", "none", Ue, fr]
1623
+ shadow: ["", "inner", "none", Ue, dr]
1624
1624
  }],
1625
1625
  /**
1626
1626
  * Box Shadow Color
@@ -1641,14 +1641,14 @@ const Z = (e) => {
1641
1641
  * @see https://tailwindcss.com/docs/mix-blend-mode
1642
1642
  */
1643
1643
  "mix-blend": [{
1644
- "mix-blend": [...ne(), "plus-lighter", "plus-darker"]
1644
+ "mix-blend": [...oe(), "plus-lighter", "plus-darker"]
1645
1645
  }],
1646
1646
  /**
1647
1647
  * Background Blend Mode
1648
1648
  * @see https://tailwindcss.com/docs/background-blend-mode
1649
1649
  */
1650
1650
  "bg-blend": [{
1651
- "bg-blend": ne()
1651
+ "bg-blend": oe()
1652
1652
  }],
1653
1653
  // Filters
1654
1654
  /**
@@ -1685,7 +1685,7 @@ const Z = (e) => {
1685
1685
  * @see https://tailwindcss.com/docs/drop-shadow
1686
1686
  */
1687
1687
  "drop-shadow": [{
1688
- "drop-shadow": ["", "none", Ue, F]
1688
+ "drop-shadow": ["", "none", Ue, O]
1689
1689
  }],
1690
1690
  /**
1691
1691
  * Grayscale
@@ -1713,14 +1713,14 @@ const Z = (e) => {
1713
1713
  * @see https://tailwindcss.com/docs/saturate
1714
1714
  */
1715
1715
  saturate: [{
1716
- saturate: [x]
1716
+ saturate: [C]
1717
1717
  }],
1718
1718
  /**
1719
1719
  * Sepia
1720
1720
  * @see https://tailwindcss.com/docs/sepia
1721
1721
  */
1722
1722
  sepia: [{
1723
- sepia: [_]
1723
+ sepia: [z]
1724
1724
  }],
1725
1725
  /**
1726
1726
  * Backdrop Filter
@@ -1784,14 +1784,14 @@ const Z = (e) => {
1784
1784
  * @see https://tailwindcss.com/docs/backdrop-saturate
1785
1785
  */
1786
1786
  "backdrop-saturate": [{
1787
- "backdrop-saturate": [x]
1787
+ "backdrop-saturate": [C]
1788
1788
  }],
1789
1789
  /**
1790
1790
  * Backdrop Sepia
1791
1791
  * @see https://tailwindcss.com/docs/backdrop-sepia
1792
1792
  */
1793
1793
  "backdrop-sepia": [{
1794
- "backdrop-sepia": [_]
1794
+ "backdrop-sepia": [z]
1795
1795
  }],
1796
1796
  // Tables
1797
1797
  /**
@@ -1842,35 +1842,35 @@ const Z = (e) => {
1842
1842
  * @see https://tailwindcss.com/docs/transition-property
1843
1843
  */
1844
1844
  transition: [{
1845
- transition: ["none", "all", "", "colors", "opacity", "shadow", "transform", F]
1845
+ transition: ["none", "all", "", "colors", "opacity", "shadow", "transform", O]
1846
1846
  }],
1847
1847
  /**
1848
1848
  * Transition Duration
1849
1849
  * @see https://tailwindcss.com/docs/transition-duration
1850
1850
  */
1851
1851
  duration: [{
1852
- duration: V()
1852
+ duration: K()
1853
1853
  }],
1854
1854
  /**
1855
1855
  * Transition Timing Function
1856
1856
  * @see https://tailwindcss.com/docs/transition-timing-function
1857
1857
  */
1858
1858
  ease: [{
1859
- ease: ["linear", "in", "out", "in-out", F]
1859
+ ease: ["linear", "in", "out", "in-out", O]
1860
1860
  }],
1861
1861
  /**
1862
1862
  * Transition Delay
1863
1863
  * @see https://tailwindcss.com/docs/transition-delay
1864
1864
  */
1865
1865
  delay: [{
1866
- delay: V()
1866
+ delay: K()
1867
1867
  }],
1868
1868
  /**
1869
1869
  * Animation
1870
1870
  * @see https://tailwindcss.com/docs/animation
1871
1871
  */
1872
1872
  animate: [{
1873
- animate: ["none", "spin", "ping", "pulse", "bounce", F]
1873
+ animate: ["none", "spin", "ping", "pulse", "bounce", O]
1874
1874
  }],
1875
1875
  // Transforms
1876
1876
  /**
@@ -1885,63 +1885,63 @@ const Z = (e) => {
1885
1885
  * @see https://tailwindcss.com/docs/scale
1886
1886
  */
1887
1887
  scale: [{
1888
- scale: [N]
1888
+ scale: [L]
1889
1889
  }],
1890
1890
  /**
1891
1891
  * Scale X
1892
1892
  * @see https://tailwindcss.com/docs/scale
1893
1893
  */
1894
1894
  "scale-x": [{
1895
- "scale-x": [N]
1895
+ "scale-x": [L]
1896
1896
  }],
1897
1897
  /**
1898
1898
  * Scale Y
1899
1899
  * @see https://tailwindcss.com/docs/scale
1900
1900
  */
1901
1901
  "scale-y": [{
1902
- "scale-y": [N]
1902
+ "scale-y": [L]
1903
1903
  }],
1904
1904
  /**
1905
1905
  * Rotate
1906
1906
  * @see https://tailwindcss.com/docs/rotate
1907
1907
  */
1908
1908
  rotate: [{
1909
- rotate: [Ze, F]
1909
+ rotate: [Ze, O]
1910
1910
  }],
1911
1911
  /**
1912
1912
  * Translate X
1913
1913
  * @see https://tailwindcss.com/docs/translate
1914
1914
  */
1915
1915
  "translate-x": [{
1916
- "translate-x": [L]
1916
+ "translate-x": [F]
1917
1917
  }],
1918
1918
  /**
1919
1919
  * Translate Y
1920
1920
  * @see https://tailwindcss.com/docs/translate
1921
1921
  */
1922
1922
  "translate-y": [{
1923
- "translate-y": [L]
1923
+ "translate-y": [F]
1924
1924
  }],
1925
1925
  /**
1926
1926
  * Skew X
1927
1927
  * @see https://tailwindcss.com/docs/skew
1928
1928
  */
1929
1929
  "skew-x": [{
1930
- "skew-x": [k]
1930
+ "skew-x": [w]
1931
1931
  }],
1932
1932
  /**
1933
1933
  * Skew Y
1934
1934
  * @see https://tailwindcss.com/docs/skew
1935
1935
  */
1936
1936
  "skew-y": [{
1937
- "skew-y": [k]
1937
+ "skew-y": [w]
1938
1938
  }],
1939
1939
  /**
1940
1940
  * Transform Origin
1941
1941
  * @see https://tailwindcss.com/docs/transform-origin
1942
1942
  */
1943
1943
  "transform-origin": [{
1944
- origin: ["center", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left", "top-left", F]
1944
+ origin: ["center", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left", "top-left", O]
1945
1945
  }],
1946
1946
  // Interactivity
1947
1947
  /**
@@ -1963,7 +1963,7 @@ const Z = (e) => {
1963
1963
  * @see https://tailwindcss.com/docs/cursor
1964
1964
  */
1965
1965
  cursor: [{
1966
- cursor: ["auto", "default", "pointer", "wait", "text", "move", "help", "not-allowed", "none", "context-menu", "progress", "cell", "crosshair", "vertical-text", "alias", "copy", "no-drop", "grab", "grabbing", "all-scroll", "col-resize", "row-resize", "n-resize", "e-resize", "s-resize", "w-resize", "ne-resize", "nw-resize", "se-resize", "sw-resize", "ew-resize", "ns-resize", "nesw-resize", "nwse-resize", "zoom-in", "zoom-out", F]
1966
+ cursor: ["auto", "default", "pointer", "wait", "text", "move", "help", "not-allowed", "none", "context-menu", "progress", "cell", "crosshair", "vertical-text", "alias", "copy", "no-drop", "grab", "grabbing", "all-scroll", "col-resize", "row-resize", "n-resize", "e-resize", "s-resize", "w-resize", "ne-resize", "nw-resize", "se-resize", "sw-resize", "ew-resize", "ns-resize", "nesw-resize", "nwse-resize", "zoom-in", "zoom-out", O]
1967
1967
  }],
1968
1968
  /**
1969
1969
  * Caret Color
@@ -1998,126 +1998,126 @@ const Z = (e) => {
1998
1998
  * @see https://tailwindcss.com/docs/scroll-margin
1999
1999
  */
2000
2000
  "scroll-m": [{
2001
- "scroll-m": C()
2001
+ "scroll-m": P()
2002
2002
  }],
2003
2003
  /**
2004
2004
  * Scroll Margin X
2005
2005
  * @see https://tailwindcss.com/docs/scroll-margin
2006
2006
  */
2007
2007
  "scroll-mx": [{
2008
- "scroll-mx": C()
2008
+ "scroll-mx": P()
2009
2009
  }],
2010
2010
  /**
2011
2011
  * Scroll Margin Y
2012
2012
  * @see https://tailwindcss.com/docs/scroll-margin
2013
2013
  */
2014
2014
  "scroll-my": [{
2015
- "scroll-my": C()
2015
+ "scroll-my": P()
2016
2016
  }],
2017
2017
  /**
2018
2018
  * Scroll Margin Start
2019
2019
  * @see https://tailwindcss.com/docs/scroll-margin
2020
2020
  */
2021
2021
  "scroll-ms": [{
2022
- "scroll-ms": C()
2022
+ "scroll-ms": P()
2023
2023
  }],
2024
2024
  /**
2025
2025
  * Scroll Margin End
2026
2026
  * @see https://tailwindcss.com/docs/scroll-margin
2027
2027
  */
2028
2028
  "scroll-me": [{
2029
- "scroll-me": C()
2029
+ "scroll-me": P()
2030
2030
  }],
2031
2031
  /**
2032
2032
  * Scroll Margin Top
2033
2033
  * @see https://tailwindcss.com/docs/scroll-margin
2034
2034
  */
2035
2035
  "scroll-mt": [{
2036
- "scroll-mt": C()
2036
+ "scroll-mt": P()
2037
2037
  }],
2038
2038
  /**
2039
2039
  * Scroll Margin Right
2040
2040
  * @see https://tailwindcss.com/docs/scroll-margin
2041
2041
  */
2042
2042
  "scroll-mr": [{
2043
- "scroll-mr": C()
2043
+ "scroll-mr": P()
2044
2044
  }],
2045
2045
  /**
2046
2046
  * Scroll Margin Bottom
2047
2047
  * @see https://tailwindcss.com/docs/scroll-margin
2048
2048
  */
2049
2049
  "scroll-mb": [{
2050
- "scroll-mb": C()
2050
+ "scroll-mb": P()
2051
2051
  }],
2052
2052
  /**
2053
2053
  * Scroll Margin Left
2054
2054
  * @see https://tailwindcss.com/docs/scroll-margin
2055
2055
  */
2056
2056
  "scroll-ml": [{
2057
- "scroll-ml": C()
2057
+ "scroll-ml": P()
2058
2058
  }],
2059
2059
  /**
2060
2060
  * Scroll Padding
2061
2061
  * @see https://tailwindcss.com/docs/scroll-padding
2062
2062
  */
2063
2063
  "scroll-p": [{
2064
- "scroll-p": C()
2064
+ "scroll-p": P()
2065
2065
  }],
2066
2066
  /**
2067
2067
  * Scroll Padding X
2068
2068
  * @see https://tailwindcss.com/docs/scroll-padding
2069
2069
  */
2070
2070
  "scroll-px": [{
2071
- "scroll-px": C()
2071
+ "scroll-px": P()
2072
2072
  }],
2073
2073
  /**
2074
2074
  * Scroll Padding Y
2075
2075
  * @see https://tailwindcss.com/docs/scroll-padding
2076
2076
  */
2077
2077
  "scroll-py": [{
2078
- "scroll-py": C()
2078
+ "scroll-py": P()
2079
2079
  }],
2080
2080
  /**
2081
2081
  * Scroll Padding Start
2082
2082
  * @see https://tailwindcss.com/docs/scroll-padding
2083
2083
  */
2084
2084
  "scroll-ps": [{
2085
- "scroll-ps": C()
2085
+ "scroll-ps": P()
2086
2086
  }],
2087
2087
  /**
2088
2088
  * Scroll Padding End
2089
2089
  * @see https://tailwindcss.com/docs/scroll-padding
2090
2090
  */
2091
2091
  "scroll-pe": [{
2092
- "scroll-pe": C()
2092
+ "scroll-pe": P()
2093
2093
  }],
2094
2094
  /**
2095
2095
  * Scroll Padding Top
2096
2096
  * @see https://tailwindcss.com/docs/scroll-padding
2097
2097
  */
2098
2098
  "scroll-pt": [{
2099
- "scroll-pt": C()
2099
+ "scroll-pt": P()
2100
2100
  }],
2101
2101
  /**
2102
2102
  * Scroll Padding Right
2103
2103
  * @see https://tailwindcss.com/docs/scroll-padding
2104
2104
  */
2105
2105
  "scroll-pr": [{
2106
- "scroll-pr": C()
2106
+ "scroll-pr": P()
2107
2107
  }],
2108
2108
  /**
2109
2109
  * Scroll Padding Bottom
2110
2110
  * @see https://tailwindcss.com/docs/scroll-padding
2111
2111
  */
2112
2112
  "scroll-pb": [{
2113
- "scroll-pb": C()
2113
+ "scroll-pb": P()
2114
2114
  }],
2115
2115
  /**
2116
2116
  * Scroll Padding Left
2117
2117
  * @see https://tailwindcss.com/docs/scroll-padding
2118
2118
  */
2119
2119
  "scroll-pl": [{
2120
- "scroll-pl": C()
2120
+ "scroll-pl": P()
2121
2121
  }],
2122
2122
  /**
2123
2123
  * Scroll Snap Align
@@ -2185,7 +2185,7 @@ const Z = (e) => {
2185
2185
  * @see https://tailwindcss.com/docs/will-change
2186
2186
  */
2187
2187
  "will-change": [{
2188
- "will-change": ["auto", "scroll", "contents", "transform", F]
2188
+ "will-change": ["auto", "scroll", "contents", "transform", O]
2189
2189
  }],
2190
2190
  // SVG
2191
2191
  /**
@@ -2275,11 +2275,11 @@ const Z = (e) => {
2275
2275
  "font-size": ["leading"]
2276
2276
  }
2277
2277
  };
2278
- }, yr = /* @__PURE__ */ Yn(hr);
2278
+ }, hr = /* @__PURE__ */ Qn(mr);
2279
2279
  function Vs(...e) {
2280
- return yr(On(e));
2280
+ return hr(jn(e));
2281
2281
  }
2282
- function br(e) {
2282
+ function yr(e) {
2283
2283
  let t = !1, n = "";
2284
2284
  for (const s of e) {
2285
2285
  if (s === "\\") {
@@ -2294,13 +2294,13 @@ function br(e) {
2294
2294
  }
2295
2295
  return n.replace(/\bTrue\b/g, "true").replace(/\bFalse\b/g, "false").replace(/\bNone\b/g, "null");
2296
2296
  }
2297
- function Ut(e) {
2297
+ function zt(e) {
2298
2298
  const t = e == null ? void 0 : e.trim();
2299
2299
  if (!t || !(t.startsWith("{") || t.startsWith("["))) return null;
2300
2300
  try {
2301
2301
  return JSON.parse(t);
2302
2302
  } catch {
2303
- const n = br(t);
2303
+ const n = yr(t);
2304
2304
  if (n)
2305
2305
  try {
2306
2306
  return JSON.parse(n);
@@ -2310,29 +2310,29 @@ function Ut(e) {
2310
2310
  return null;
2311
2311
  }
2312
2312
  }
2313
- function wr(e) {
2313
+ function br(e) {
2314
2314
  return typeof e != "string" ? !1 : /^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e);
2315
2315
  }
2316
- function kr(e) {
2316
+ function wr(e) {
2317
2317
  return e.type === "image_url";
2318
2318
  }
2319
- function vr(e) {
2319
+ function kr(e) {
2320
2320
  return e.type === "file";
2321
2321
  }
2322
2322
  function Ir(e) {
2323
2323
  return Array.isArray(e.content) ? e.content.filter((t) => t.type === "text").map((t) => t.text).join(`
2324
2324
  `).trim() : typeof e.content == "string" ? e.content : "";
2325
2325
  }
2326
+ function vr(e) {
2327
+ return e.content.filter(wr);
2328
+ }
2326
2329
  function Tr(e) {
2327
2330
  return e.content.filter(kr);
2328
2331
  }
2329
- function Ar(e) {
2330
- return e.content.filter(vr);
2331
- }
2332
- function un(e) {
2332
+ function ln(e) {
2333
2333
  return Array.isArray(e.toolCalls) ? e.toolCalls : [];
2334
2334
  }
2335
- function Sr(e) {
2335
+ function Ar(e) {
2336
2336
  const t = [];
2337
2337
  return e.forEach((n) => {
2338
2338
  n.artifact && t.push(n.artifact), Array.isArray(n.toolCalls) && n.toolCalls.forEach((r) => {
@@ -2340,7 +2340,7 @@ function Sr(e) {
2340
2340
  });
2341
2341
  }), t;
2342
2342
  }
2343
- function dn(e) {
2343
+ function un(e) {
2344
2344
  return !!(e && typeof e == "object" && (e.type === "file" || e.mimeType || e.filename || e.sourceType === "base64"));
2345
2345
  }
2346
2346
  function yt(e) {
@@ -2355,7 +2355,7 @@ function yt(e) {
2355
2355
  }
2356
2356
  return n;
2357
2357
  }
2358
- if (dn(e)) {
2358
+ if (un(e)) {
2359
2359
  try {
2360
2360
  console.debug("[message-utils] sanitizeForDisplay - dropping file-like object", {
2361
2361
  sampleFilename: e && (e.filename || e.name) ? e.filename || e.name : void 0,
@@ -2387,9 +2387,9 @@ function yt(e) {
2387
2387
  }
2388
2388
  return e;
2389
2389
  }
2390
- function fn(e) {
2390
+ function dn(e) {
2391
2391
  if (typeof e == "string") return e;
2392
- if (dn(e)) return "";
2392
+ if (un(e)) return "";
2393
2393
  try {
2394
2394
  const t = yt(e);
2395
2395
  return t === void 0 ? "" : typeof t == "string" ? t : JSON.stringify(t, null, 2);
@@ -2398,10 +2398,10 @@ function fn(e) {
2398
2398
  }
2399
2399
  }
2400
2400
  function Ks(e) {
2401
- const t = fn(e);
2402
- return typeof e == "string" && wr(e) ? { content: e, isMarkdown: !0 } : { content: t, isMarkdown: !1 };
2401
+ const t = dn(e);
2402
+ return typeof e == "string" && br(e) ? { content: e, isMarkdown: !0 } : { content: t, isMarkdown: !1 };
2403
2403
  }
2404
- function xr(e) {
2404
+ function Sr(e) {
2405
2405
  const t = (r) => {
2406
2406
  try {
2407
2407
  const s = yt(r);
@@ -2421,7 +2421,7 @@ function Me(e) {
2421
2421
  if (typeof e == "string") {
2422
2422
  const t = e.trim();
2423
2423
  if (t.startsWith("{") || t.startsWith("[")) {
2424
- const n = Ut(t);
2424
+ const n = zt(t);
2425
2425
  if (n !== null)
2426
2426
  return Me(n);
2427
2427
  }
@@ -2436,24 +2436,24 @@ function Me(e) {
2436
2436
  }
2437
2437
  return typeof e == "object" && !Array.isArray(e) && (e.type === "text" && typeof e.text == "string" || typeof e.text == "string") ? e.text : Array.isArray(e) && e.length > 0 ? Me(e[0]) : e;
2438
2438
  }
2439
- function Cr(e) {
2439
+ function xr(e) {
2440
2440
  return e.replace(/[_-](\w)/g, (t, n) => n ? n.toUpperCase() : "").replace(/^\w/, (t) => t.toLowerCase());
2441
2441
  }
2442
2442
  function Ee(e) {
2443
2443
  return !e || typeof e != "object" ? e : Array.isArray(e) ? e.map(Ee) : Object.fromEntries(
2444
2444
  Object.entries(e).map(([t, n]) => [
2445
- Cr(t),
2445
+ xr(t),
2446
2446
  Ee(n)
2447
2447
  ])
2448
2448
  );
2449
2449
  }
2450
2450
  function bt(e) {
2451
- var y, I, A, x, N, _;
2451
+ var y, I, S, C, L, z;
2452
2452
  if (!e || typeof e != "object") return null;
2453
- const t = Ee(e), n = Pr(t);
2453
+ const t = Ee(e), n = Er(t);
2454
2454
  if (!n)
2455
2455
  return null;
2456
- const r = Array.isArray(t.toolCalls) ? t.toolCalls.map(Ft) : void 0, s = Er(t.content ?? t.parts, !!(r != null && r.length)), o = t.id ?? `msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`, a = t.createdAt ?? ((y = t.additionalKwargs) == null ? void 0 : y.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(), i = t.name ?? ((I = t.additionalKwargs) == null ? void 0 : I.agentName) ?? void 0, f = t.model ?? ((A = t.additionalKwargs) == null ? void 0 : A.model) ?? void 0, l = t.toolCallId ?? void 0, c = t.additionalKwargs ?? void 0, d = t.responseMetadata ?? void 0, g = t.checkpointId ?? ((x = t.additionalKwargs) == null ? void 0 : x.checkpointId) ?? void 0, h = t.checkpointNs ?? ((N = t.additionalKwargs) == null ? void 0 : N.checkpointNs) ?? void 0, v = typeof t.toolStreaming == "boolean" ? t.toolStreaming : !!((_ = t.additionalKwargs) != null && _.toolStreaming);
2456
+ const r = Array.isArray(t.toolCalls) ? t.toolCalls.map(Ut) : void 0, s = Mr(t.content ?? t.parts, !!(r != null && r.length)), o = t.id ?? `msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`, a = t.createdAt ?? ((y = t.additionalKwargs) == null ? void 0 : y.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(), i = t.name ?? ((I = t.additionalKwargs) == null ? void 0 : I.agentName) ?? void 0, f = t.model ?? ((S = t.additionalKwargs) == null ? void 0 : S.model) ?? void 0, l = t.toolCallId ?? void 0, c = t.additionalKwargs ?? void 0, d = t.responseMetadata ?? void 0, g = t.checkpointId ?? ((C = t.additionalKwargs) == null ? void 0 : C.checkpointId) ?? void 0, h = t.checkpointNs ?? ((L = t.additionalKwargs) == null ? void 0 : L.checkpointNs) ?? void 0, k = typeof t.toolStreaming == "boolean" ? t.toolStreaming : !!((z = t.additionalKwargs) != null && z.toolStreaming);
2457
2457
  return {
2458
2458
  ...t,
2459
2459
  id: o,
@@ -2466,13 +2466,13 @@ function bt(e) {
2466
2466
  toolCalls: r,
2467
2467
  checkpointId: g,
2468
2468
  checkpointNs: h,
2469
- toolStreaming: v,
2469
+ toolStreaming: k,
2470
2470
  additionalKwargs: c,
2471
2471
  responseMetadata: d,
2472
2472
  artifact: t.artifact ?? void 0
2473
2473
  };
2474
2474
  }
2475
- function Mr(e) {
2475
+ function Cr(e) {
2476
2476
  if (!e || typeof e != "object") return e;
2477
2477
  const t = Ee(e);
2478
2478
  if (t.tool && !t.name && (t.name = t.tool), t.type === "artifact.update" && t.artifact && typeof t.artifact == "object") {
@@ -2481,7 +2481,7 @@ function Mr(e) {
2481
2481
  }
2482
2482
  return t;
2483
2483
  }
2484
- function Ft(e) {
2484
+ function Ut(e) {
2485
2485
  const t = Ee(e), n = t.content ?? t.output ?? void 0;
2486
2486
  return {
2487
2487
  ...t,
@@ -2492,35 +2492,35 @@ function Ft(e) {
2492
2492
  content: typeof n == "string" ? n : n ? JSON.stringify(n) : void 0
2493
2493
  };
2494
2494
  }
2495
- function Er(e, t) {
2496
- return Array.isArray(e) ? e.map((n) => n.type === "tool_call" || n.type === "tool" ? t ? null : Ft(Ee(n)) : n).filter(
2495
+ function Mr(e, t) {
2496
+ return Array.isArray(e) ? e.map((n) => n.type === "tool_call" || n.type === "tool" ? t ? null : Ut(Ee(n)) : n).filter(
2497
2497
  (n) => !!(n && typeof n == "object" && typeof n.type == "string")
2498
2498
  ) : [];
2499
2499
  }
2500
- function Pr(e) {
2500
+ function Er(e) {
2501
2501
  const t = Ee(e), n = t.role;
2502
2502
  if (n && (n === "assistant" || n === "user" || n === "system" || n === "tool" || n === "interrupt"))
2503
2503
  return n;
2504
2504
  const r = t.type;
2505
2505
  return r === "human" ? "user" : r === "ai" ? "assistant" : r === "tool" ? "tool" : r === "system" ? "system" : null;
2506
2506
  }
2507
- function qt(e) {
2507
+ function Ht(e) {
2508
2508
  if (!e) return null;
2509
2509
  const t = String(e).toLowerCase();
2510
2510
  return t === "running" || t === "pending" ? "pending" : t === "completed" || t === "success" ? "completed" : t === "error" || t === "failed" || t === "failure" ? "error" : null;
2511
2511
  }
2512
- function Wt(e) {
2513
- return (Array.isArray(e.toolCalls) ? e.toolCalls : un(e)).map(Ft);
2512
+ function qt(e) {
2513
+ return (Array.isArray(e.toolCalls) ? e.toolCalls : ln(e)).map(Ut);
2514
2514
  }
2515
2515
  function Ct(e, t) {
2516
2516
  return t.find(
2517
2517
  (n) => n.role === "tool" && (n.toolCallId === e || n.id === e)
2518
2518
  );
2519
2519
  }
2520
- function Rr(e, t) {
2520
+ function Pr(e, t) {
2521
2521
  const n = t.response ?? t.content;
2522
2522
  if (!n) return;
2523
- const r = typeof n == "string" ? n : fn(n);
2523
+ const r = typeof n == "string" ? n : dn(n);
2524
2524
  if (!r.trim()) return;
2525
2525
  const s = [{ type: "text", text: r }];
2526
2526
  return {
@@ -2533,15 +2533,15 @@ function Rr(e, t) {
2533
2533
  createdAt: e.createdAt
2534
2534
  };
2535
2535
  }
2536
- function Nr(e, t = []) {
2536
+ function Rr(e, t = []) {
2537
2537
  if (Array.isArray(e)) {
2538
- const s = e.filter((a) => a.role === "assistant").flatMap((a) => Wt(a)), o = /* @__PURE__ */ new Map();
2538
+ const s = e.filter((a) => a.role === "assistant").flatMap((a) => qt(a)), o = /* @__PURE__ */ new Map();
2539
2539
  return s.forEach((a) => o.set(a.id, a)), Array.from(o.values()).map((a) => {
2540
2540
  var d, g, h;
2541
- const i = Ct(a.id, e) || Ct(a.id, t), f = 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, l = (i == null ? void 0 : i.artifact) ?? a.artifact, c = qt(a.status) ?? ((h = i == null ? void 0 : i.additionalKwargs) != null && h.toolStreaming ? "pending" : null) ?? (i ? "completed" : "pending");
2541
+ const i = Ct(a.id, e) || Ct(a.id, t), f = 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, l = (i == null ? void 0 : i.artifact) ?? a.artifact, c = Ht(a.status) ?? ((h = i == null ? void 0 : i.additionalKwargs) != null && h.toolStreaming ? "pending" : null) ?? (i ? "completed" : "pending");
2542
2542
  if (i && !a.content && c === "completed") {
2543
- const v = Me(i);
2544
- typeof v == "string" && (a.content = v);
2543
+ const k = Me(i);
2544
+ typeof k == "string" && (a.content = k);
2545
2545
  }
2546
2546
  return {
2547
2547
  call: a,
@@ -2553,10 +2553,10 @@ function Nr(e, t = []) {
2553
2553
  });
2554
2554
  }
2555
2555
  if (e.role !== "assistant") return [];
2556
- const n = Wt(e);
2556
+ const n = qt(e);
2557
2557
  return n.length === 0 ? [] : n.map((r) => {
2558
2558
  var f, l, c;
2559
- const s = Ct(r.id, t) ?? Rr(e, r), o = Array.isArray((f = s == null ? void 0 : s.additionalKwargs) == null ? void 0 : f.toolProgress) ? (l = s == null ? void 0 : s.additionalKwargs) == null ? void 0 : l.toolProgress : void 0, a = (s == null ? void 0 : s.artifact) ?? r.artifact, i = qt(r.status) ?? ((c = s == null ? void 0 : s.additionalKwargs) != null && c.toolStreaming ? "pending" : null) ?? (s ? "completed" : "pending");
2559
+ const s = Ct(r.id, t) ?? Pr(e, r), o = Array.isArray((f = s == null ? void 0 : s.additionalKwargs) == null ? void 0 : f.toolProgress) ? (l = s == null ? void 0 : s.additionalKwargs) == null ? void 0 : l.toolProgress : void 0, a = (s == null ? void 0 : s.artifact) ?? r.artifact, i = Ht(r.status) ?? ((c = s == null ? void 0 : s.additionalKwargs) != null && c.toolStreaming ? "pending" : null) ?? (s ? "completed" : "pending");
2560
2560
  if (s && !r.content && i === "completed") {
2561
2561
  const d = Me(s);
2562
2562
  typeof d == "string" && (r.content = d);
@@ -2571,9 +2571,9 @@ function Nr(e, t = []) {
2571
2571
  });
2572
2572
  }
2573
2573
  function qs(e, t = []) {
2574
- return Nr(e, t).map((n) => n.artifact).filter((n) => !!n);
2574
+ return Rr(e, t).map((n) => n.artifact).filter((n) => !!n);
2575
2575
  }
2576
- const nt = {
2576
+ const tt = {
2577
2577
  authToken: "authToken",
2578
2578
  authTokenExpiresAt: "authTokenExpiresAt",
2579
2579
  authSessionId: "authSessionId",
@@ -2586,40 +2586,40 @@ function Mt(e) {
2586
2586
  return `draft:${e}`;
2587
2587
  }
2588
2588
  let wt = null;
2589
- const _t = /* @__PURE__ */ new Set();
2590
- function pn() {
2589
+ const Nt = /* @__PURE__ */ new Set();
2590
+ function fn() {
2591
2591
  return wt;
2592
2592
  }
2593
- function Ve(e) {
2594
- wt = e, _t.forEach((t) => t(e));
2593
+ function De(e) {
2594
+ wt = e, Nt.forEach((t) => t(e));
2595
2595
  }
2596
- function gn(e) {
2597
- return _t.add(e), () => _t.delete(e);
2596
+ function pn(e) {
2597
+ return Nt.add(e), () => Nt.delete(e);
2598
2598
  }
2599
- const _r = 12e4, Lr = 12e4;
2600
- let Lt = _r, mn = Lr;
2601
- const ye = jn.create({
2599
+ const Nr = 12e4, _r = 12e4;
2600
+ let _t = Nr, gn = _r;
2601
+ const me = Fn.create({
2602
2602
  // BaseURL is set dynamically via ApiProvider -> api.updateConfig
2603
- timeout: Lt,
2603
+ timeout: _t,
2604
2604
  withCredentials: !0
2605
2605
  });
2606
- function Gt(e) {
2606
+ function Wt(e) {
2607
2607
  return typeof e != "number" || !Number.isFinite(e) || e <= 0 ? null : Math.floor(e);
2608
2608
  }
2609
- function zr(e) {
2610
- const t = Gt(e.requestTimeoutMs), n = Gt(e.historyTimeoutMs);
2611
- t !== null && (Lt = t, ye.defaults.timeout = Lt), n !== null && (mn = n);
2609
+ function Lr(e) {
2610
+ const t = Wt(e.requestTimeoutMs), n = Wt(e.historyTimeoutMs);
2611
+ t !== null && (_t = t, me.defaults.timeout = _t), n !== null && (gn = n);
2612
2612
  }
2613
- function Ur() {
2614
- return mn;
2613
+ function zr() {
2614
+ return gn;
2615
2615
  }
2616
- ye.interceptors.request.use((e) => (wt && (e.headers.Authorization = `Bearer ${wt}`), e));
2617
- ye.interceptors.response.use(
2616
+ me.interceptors.request.use((e) => (wt && (e.headers.Authorization = `Bearer ${wt}`), e));
2617
+ me.interceptors.response.use(
2618
2618
  (e) => {
2619
2619
  if (typeof window < "u" && (e != null && e.data))
2620
2620
  try {
2621
2621
  const t = e.data, n = t.data || {}, r = typeof t.token == "string" && t.token || typeof n.token == "string" && n.token || null, 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(nt.authToken, r), Ve(r)), s && localStorage.setItem(nt.authTokenExpiresAt, s.toString()), (r || s) && window.dispatchEvent(
2622
+ r && (localStorage.setItem(tt.authToken, r), De(r)), s && localStorage.setItem(tt.authTokenExpiresAt, s.toString()), (r || s) && window.dispatchEvent(
2623
2623
  new CustomEvent("smartorg:chat-token-updated", {
2624
2624
  detail: { token: r, expiresAt: s }
2625
2625
  })
@@ -2631,108 +2631,108 @@ ye.interceptors.response.use(
2631
2631
  },
2632
2632
  (e) => Promise.reject(e)
2633
2633
  );
2634
- async function ve(e, t) {
2635
- return ye.defaults.baseURL ? (await ye.get(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
2634
+ async function ke(e, t) {
2635
+ return me.defaults.baseURL ? (await me.get(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
2636
2636
  }
2637
- async function ft(e, t, n) {
2638
- return ye.defaults.baseURL ? (await ye.post(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
2637
+ async function dt(e, t, n) {
2638
+ return me.defaults.baseURL ? (await me.post(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
2639
2639
  }
2640
- async function Fr(e, t, n) {
2641
- return ye.defaults.baseURL ? (await ye.put(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
2640
+ async function Ur(e, t, n) {
2641
+ return me.defaults.baseURL ? (await me.put(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
2642
2642
  }
2643
- async function Jt(e, t) {
2644
- return ye.defaults.baseURL ? (await ye.delete(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
2643
+ async function Gt(e, t) {
2644
+ return me.defaults.baseURL ? (await me.delete(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
2645
2645
  }
2646
- function we(e) {
2646
+ function ye(e) {
2647
2647
  return e && typeof e == "object" && "data" in e ? e.data : e;
2648
2648
  }
2649
- class jr {
2649
+ class Fr {
2650
2650
  // ---- Configuration ----
2651
2651
  // Chat client uses the default httpClient baseURL, no need for internal tracking
2652
2652
  // unless we want to support multiple instances with different URLs in the future.
2653
2653
  get baseUrl() {
2654
- return ye.defaults.baseURL || "";
2654
+ return me.defaults.baseURL || "";
2655
2655
  }
2656
2656
  updateConfig(t) {
2657
2657
  if (t.chatBaseUrl)
2658
- ye.defaults.baseURL = t.chatBaseUrl;
2658
+ me.defaults.baseURL = t.chatBaseUrl;
2659
2659
  else if (t.baseUrl) {
2660
2660
  const n = t.baseUrl.replace(/\/+$/, "");
2661
- n.endsWith("/chat") ? ye.defaults.baseURL = n : ye.defaults.baseURL = `${n}/chat`;
2661
+ n.endsWith("/chat") ? me.defaults.baseURL = n : me.defaults.baseURL = `${n}/chat`;
2662
2662
  }
2663
- t.apiKey !== void 0 ? Ve(t.apiKey) : t.getToken && Ve(t.getToken()), (t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0) && zr({
2663
+ t.apiKey !== void 0 ? De(t.apiKey) : t.getToken && De(t.getToken()), (t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0) && Lr({
2664
2664
  requestTimeoutMs: t.requestTimeoutMs,
2665
2665
  historyTimeoutMs: t.historyTimeoutMs
2666
2666
  });
2667
2667
  }
2668
2668
  // ---- Token Management ----
2669
2669
  getAuthToken() {
2670
- return pn();
2670
+ return fn();
2671
2671
  }
2672
2672
  setAuthToken(t) {
2673
- Ve(t);
2673
+ De(t);
2674
2674
  }
2675
2675
  onTokenChange(t) {
2676
- return gn(t);
2676
+ return pn(t);
2677
2677
  }
2678
2678
  // ---- Thread Management ----
2679
2679
  async listThreads() {
2680
- const t = await ve("/threads"), n = we(t);
2680
+ const t = await ke("/threads"), n = ye(t);
2681
2681
  return (n == null ? void 0 : n.items) ?? (t == null ? void 0 : t.items) ?? [];
2682
2682
  }
2683
2683
  async listSharedThreads() {
2684
- const t = await ve("/threads/shared"), n = we(t);
2684
+ const t = await ke("/threads/shared"), n = ye(t);
2685
2685
  return (n == null ? void 0 : n.items) ?? (t == null ? void 0 : t.items) ?? [];
2686
2686
  }
2687
2687
  // listUsers moved to AuthApi
2688
2688
  async createThread(t, n) {
2689
2689
  const r = {};
2690
2690
  t && (r.title = t), n && (r.project = n);
2691
- const s = await ft("/threads", Object.keys(r).length ? r : void 0);
2692
- return we(s);
2691
+ const s = await dt("/threads", Object.keys(r).length ? r : void 0);
2692
+ return ye(s);
2693
2693
  }
2694
2694
  async updateThread(t, n) {
2695
- const r = await Fr(`/threads/${t}`, { title: n });
2696
- return we(r);
2695
+ const r = await Ur(`/threads/${t}`, { title: n });
2696
+ return ye(r);
2697
2697
  }
2698
2698
  async deleteThread(t) {
2699
- const n = await Jt(`/threads/${t}`);
2700
- return we(n);
2699
+ const n = await Gt(`/threads/${t}`);
2700
+ return ye(n);
2701
2701
  }
2702
2702
  async shareThread(t, n) {
2703
- const r = await ft(`/threads/${t}/share`, {
2703
+ const r = await dt(`/threads/${t}/share`, {
2704
2704
  shared_with_user_id: n
2705
2705
  });
2706
- return we(r);
2706
+ return ye(r);
2707
2707
  }
2708
2708
  async threadInfo(t) {
2709
- const n = await ve(`/threads/${t}/info`);
2710
- return we(n);
2709
+ const n = await ke(`/threads/${t}/info`);
2710
+ return ye(n);
2711
2711
  }
2712
2712
  // ---- Agents ----
2713
2713
  async listAgents() {
2714
- const t = await ve("/agents"), n = we(t);
2714
+ const t = await ke("/agents"), n = ye(t);
2715
2715
  return (n == null ? void 0 : n.items) ?? [];
2716
2716
  }
2717
2717
  async getAgent(t) {
2718
- const n = await ve(`/agents/${t}`);
2719
- return we(n);
2718
+ const n = await ke(`/agents/${t}`);
2719
+ return ye(n);
2720
2720
  }
2721
2721
  async getAgentSchema(t) {
2722
- const n = await ve(`/agents/${t}/schema`);
2723
- return we(n);
2722
+ const n = await ke(`/agents/${t}/schema`);
2723
+ return ye(n);
2724
2724
  }
2725
2725
  async getState(t) {
2726
- const n = await ve(`/threads/${t.threadId}/state`, {
2726
+ const n = await ke(`/threads/${t.threadId}/state`, {
2727
2727
  params: {
2728
2728
  checkpoint_id: t.checkpointId,
2729
2729
  checkpoint_ns: t.checkpointNs
2730
2730
  }
2731
2731
  });
2732
- return we(n);
2732
+ return ye(n);
2733
2733
  }
2734
2734
  async getStateHistory(t) {
2735
- const n = await ve(`/threads/${t.threadId}/state/history`, {
2735
+ const n = await ke(`/threads/${t.threadId}/state/history`, {
2736
2736
  params: {
2737
2737
  checkpoint_id: t.checkpointId,
2738
2738
  checkpoint_ns: t.checkpointNs,
@@ -2740,27 +2740,27 @@ class jr {
2740
2740
  offset: t.offset ?? 0,
2741
2741
  include_messages: t.includeMessages ?? !0
2742
2742
  },
2743
- timeout: Ur(),
2743
+ timeout: zr(),
2744
2744
  signal: t.signal
2745
2745
  });
2746
- return we(n);
2746
+ return ye(n);
2747
2747
  }
2748
2748
  // ---- Run Management ----
2749
2749
  async cancelRun(t) {
2750
- const n = await ft("/stream/cancel", { threadId: t });
2751
- return we(n);
2750
+ const n = await dt("/stream/cancel", { threadId: t });
2751
+ return ye(n);
2752
2752
  }
2753
2753
  async unshareThread(t, n) {
2754
- const r = await Jt(`/threads/${t}/share/${n}`);
2755
- return we(r);
2754
+ const r = await Gt(`/threads/${t}/share/${n}`);
2755
+ return ye(r);
2756
2756
  }
2757
2757
  }
2758
- const hn = new jr();
2759
- class Or {
2758
+ const mn = new Fr();
2759
+ class jr {
2760
2760
  // Config logic could go here if files ever need a distinct base URL from chat
2761
2761
  // For now, it shares the chatBaseUrl via the shared httpClient
2762
2762
  async fetchFileBlob(t, n) {
2763
- return await ve(t, {
2763
+ return await ke(t, {
2764
2764
  responseType: "blob",
2765
2765
  onDownloadProgress: (s) => {
2766
2766
  try {
@@ -2789,7 +2789,7 @@ class Or {
2789
2789
  const r = await this.fetchFileBlob(`/files/${t}/download`, n), s = URL.createObjectURL(r);
2790
2790
  let o = `file_${t}`;
2791
2791
  try {
2792
- const i = await ve(`/files/${t}`);
2792
+ const i = await ke(`/files/${t}`);
2793
2793
  o = (i == null ? void 0 : i.filename) ?? o;
2794
2794
  } catch {
2795
2795
  }
@@ -2797,15 +2797,15 @@ class Or {
2797
2797
  a.href = s, a.download = o, document.body.appendChild(a), a.click(), a.remove(), setTimeout(() => URL.revokeObjectURL(s), 6e4);
2798
2798
  }
2799
2799
  async getFileInfo(t) {
2800
- return await ve(`/files/${t}`);
2800
+ return await ke(`/files/${t}`);
2801
2801
  }
2802
2802
  async listFiles(t, n = 50, r = 0) {
2803
2803
  const s = { limit: n, offset: r };
2804
- return t && (s.thread_id = t), await ve("/files", { params: s });
2804
+ return t && (s.thread_id = t), await ke("/files", { params: s });
2805
2805
  }
2806
2806
  async uploadFile(t, n, r) {
2807
2807
  const s = new FormData();
2808
- return s.append("file", t), n && s.append("thread_id", n), await ft("/files/upload-form", s, {
2808
+ return s.append("file", t), n && s.append("thread_id", n), await dt("/files/upload-form", s, {
2809
2809
  onUploadProgress: (o) => {
2810
2810
  try {
2811
2811
  if (r && o.lengthComputable) {
@@ -2818,11 +2818,11 @@ class Or {
2818
2818
  });
2819
2819
  }
2820
2820
  }
2821
- const yn = new Or();
2822
- class $r {
2821
+ const hn = new jr();
2822
+ class Or {
2823
2823
  constructor() {
2824
2824
  // ---- Configuration ----
2825
- Bt(this, "_authBaseUrl", "");
2825
+ $t(this, "_authBaseUrl", "");
2826
2826
  }
2827
2827
  get baseUrl() {
2828
2828
  return this._authBaseUrl;
@@ -2834,27 +2834,27 @@ class $r {
2834
2834
  const n = t.baseUrl.replace(/\/+$/, "");
2835
2835
  this._authBaseUrl = `${n}/auth`;
2836
2836
  }
2837
- t.apiKey !== void 0 ? Ve(t.apiKey) : t.getToken && Ve(t.getToken());
2837
+ t.apiKey !== void 0 ? De(t.apiKey) : t.getToken && De(t.getToken());
2838
2838
  }
2839
2839
  // ---- Token Management ----
2840
2840
  getAuthToken() {
2841
- return pn();
2841
+ return fn();
2842
2842
  }
2843
2843
  setAuthToken(t) {
2844
- Ve(t);
2844
+ De(t);
2845
2845
  }
2846
2846
  onTokenChange(t) {
2847
- return gn(t);
2847
+ return pn(t);
2848
2848
  }
2849
2849
  // ---- User Management ----
2850
2850
  async listUsers() {
2851
- const t = await ve("/users", { baseURL: this.baseUrl });
2851
+ const t = await ke("/users", { baseURL: this.baseUrl });
2852
2852
  return (t == null ? void 0 : t.users) ?? [];
2853
2853
  }
2854
2854
  }
2855
- const Br = new $r(), bn = Ge(null);
2856
- function Dr({ children: e, apiConfig: t }) {
2857
- const n = hn, r = Br;
2855
+ const $r = new Or(), yn = We(null);
2856
+ function Br({ children: e, apiConfig: t }) {
2857
+ const n = mn, r = $r;
2858
2858
  if (t) {
2859
2859
  const o = n.baseUrl, a = r.baseUrl, i = n.getAuthToken(), f = t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0;
2860
2860
  (t.baseUrl || t.chatBaseUrl || f) && (f || 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 }));
@@ -2866,12 +2866,12 @@ function Dr({ children: e, apiConfig: t }) {
2866
2866
  },
2867
2867
  chatApi: n,
2868
2868
  authApi: r,
2869
- fileApi: yn,
2869
+ fileApi: hn,
2870
2870
  baseUrl: n.baseUrl
2871
2871
  };
2872
- return /* @__PURE__ */ Ce(bn.Provider, { value: s, children: e });
2872
+ return /* @__PURE__ */ Ce(yn.Provider, { value: s, children: e });
2873
2873
  }
2874
- async function Vr(e) {
2874
+ async function Dr(e) {
2875
2875
  return await new Promise((t, n) => {
2876
2876
  const r = new FileReader();
2877
2877
  r.onload = () => {
@@ -2887,11 +2887,11 @@ async function Vr(e) {
2887
2887
  }, r.onerror = (s) => n(s), r.readAsArrayBuffer(e);
2888
2888
  });
2889
2889
  }
2890
- async function Kr(e = []) {
2890
+ async function Vr(e = []) {
2891
2891
  const t = [], n = [];
2892
2892
  for (const r of e)
2893
2893
  try {
2894
- const s = await Vr(r), o = r.type || "application/octet-stream";
2894
+ const s = await Dr(r), o = r.type || "application/octet-stream";
2895
2895
  n.push({
2896
2896
  filename: r.name,
2897
2897
  data: s,
@@ -2910,7 +2910,7 @@ async function Kr(e = []) {
2910
2910
  }
2911
2911
  return { contentParts: t, filesInfo: n };
2912
2912
  }
2913
- function Hr(e) {
2913
+ function Kr(e) {
2914
2914
  return e.filter((t) => t.type === "text").map((t) => t.text).join("");
2915
2915
  }
2916
2916
  function Ws(e) {
@@ -2918,7 +2918,7 @@ function Ws(e) {
2918
2918
  const t = String(e).trim();
2919
2919
  return t.length > 0 ? t : null;
2920
2920
  }
2921
- function qr(e) {
2921
+ function Hr(e) {
2922
2922
  const t = e.toolCallId ?? (e.role === "tool" ? e.id : void 0);
2923
2923
  return e.role === "tool" && !t && console.error("[meta-utils] CRITICAL: Tool message missing toolCallId!", e), {
2924
2924
  toolCallId: t ?? void 0,
@@ -2944,12 +2944,12 @@ function Js(e) {
2944
2944
  }).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("|");
2945
2945
  return `${e.id}:${t}:${n}${o ? `:${o}` : ""}`;
2946
2946
  }
2947
- function We() {
2948
- const e = at(bn);
2947
+ function qe() {
2948
+ const e = ot(yn);
2949
2949
  if (!e) throw new Error("useApi must be used within ApiProvider");
2950
2950
  return e;
2951
2951
  }
2952
- function Wr(e, t, n) {
2952
+ function qr(e, t, n) {
2953
2953
  const r = typeof t == "string" ? [{ type: "text", text: t }] : t;
2954
2954
  return {
2955
2955
  id: `msg-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,
@@ -2959,14 +2959,14 @@ function Wr(e, t, n) {
2959
2959
  ...n
2960
2960
  };
2961
2961
  }
2962
- function wn(e, t = "user") {
2963
- return typeof e == "string" ? Wr(t, e) : e;
2962
+ function bn(e, t = "user") {
2963
+ return typeof e == "string" ? qr(t, e) : e;
2964
2964
  }
2965
- function rt(e) {
2965
+ function nt(e) {
2966
2966
  if (!(!e || typeof e != "object" || Array.isArray(e)))
2967
2967
  return { ...e };
2968
2968
  }
2969
- function dt(e, t) {
2969
+ function ut(e, t) {
2970
2970
  if (e)
2971
2971
  for (const n of t) {
2972
2972
  const r = e[n];
@@ -2974,7 +2974,7 @@ function dt(e, t) {
2974
2974
  return r.trim();
2975
2975
  }
2976
2976
  }
2977
- function Gr(e, t) {
2977
+ function Wr(e, t) {
2978
2978
  if (!e) return null;
2979
2979
  for (const n of t) {
2980
2980
  const r = e[n];
@@ -2983,12 +2983,12 @@ function Gr(e, t) {
2983
2983
  }
2984
2984
  return null;
2985
2985
  }
2986
- function Xt(e) {
2987
- const t = rt(e);
2986
+ function Jt(e) {
2987
+ const t = nt(e);
2988
2988
  if (t)
2989
- return rt(t.configurable) ?? t;
2989
+ return nt(t.configurable) ?? t;
2990
2990
  }
2991
- async function Et(e, t) {
2991
+ async function Gr(e, t) {
2992
2992
  var i, f;
2993
2993
  if (!e) return e ?? null;
2994
2994
  const n = Ee(e), r = Array.isArray(n.checkpoints) ? n.checkpoints : n.checkpoints ? Object.values(n.checkpoints) : [], s = /* @__PURE__ */ new Set();
@@ -3000,8 +3000,8 @@ async function Et(e, t) {
3000
3000
  if (Array.isArray(g))
3001
3001
  for (const h of g) {
3002
3002
  if (!h || typeof h != "object" || h.type !== "image_url" && h.type !== "file") continue;
3003
- const v = h.fileId || h.file_id;
3004
- typeof v == "string" && v.trim() && s.add(v);
3003
+ const k = h.fileId || h.file_id;
3004
+ typeof k == "string" && k.trim() && s.add(k);
3005
3005
  }
3006
3006
  }
3007
3007
  }
@@ -3025,17 +3025,17 @@ async function Et(e, t) {
3025
3025
  if (Array.isArray(g))
3026
3026
  for (const h of g) {
3027
3027
  if (!h || typeof h != "object" || h.type !== "image_url" && h.type !== "file") continue;
3028
- const v = h.fileId || h.file_id;
3029
- if (!v) continue;
3030
- const m = a.get(v), y = (m == null ? void 0 : m.contentUrl) || (m == null ? void 0 : m.content_url);
3028
+ const k = h.fileId || h.file_id;
3029
+ if (!k) continue;
3030
+ const m = a.get(k), y = (m == null ? void 0 : m.contentUrl) || (m == null ? void 0 : m.content_url);
3031
3031
  y && (h.type === "image_url" ? (h.imageUrl = h.imageUrl || {}, h.imageUrl.url = y) : h.type === "file" && (h.url = y, !h.name && (m != null && m.filename || m != null && m.name) && (h.name = (m == null ? void 0 : m.filename) || (m == null ? void 0 : m.name))));
3032
3032
  }
3033
3033
  }
3034
3034
  }
3035
3035
  return n;
3036
3036
  }
3037
- function tt(e) {
3038
- 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) => Jr(Ee(o), a)).filter((o) => !!o)].sort((o, a) => Qt(a.createdAt) - Qt(o.createdAt)), s = r[0] ?? null;
3037
+ function ft(e) {
3038
+ 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) => Jr(Ee(o), a)).filter((o) => !!o)].sort((o, a) => Xt(a.createdAt) - Xt(o.createdAt)), s = r[0] ?? null;
3039
3039
  return {
3040
3040
  threadId: (e == null ? void 0 : e.threadId) ?? "",
3041
3041
  latest: s,
@@ -3044,25 +3044,25 @@ function tt(e) {
3044
3044
  };
3045
3045
  }
3046
3046
  function Jr(e, t) {
3047
- var _, k;
3047
+ var z, w;
3048
3048
  if (!e) return null;
3049
- const n = ((_ = e.values) == null ? void 0 : _.activeAgent) ?? null, r = (k = e.values) == null ? void 0 : k.messages, o = (Array.isArray(r) ? r : []).map((T) => Xr(T, n)).filter((T) => !!T), a = rt(e.metadata) ?? {}, i = Xt(e.config), f = rt(e.parentConfig), l = Xt(f), c = dt(i, ["checkpointId"]), d = dt(i, ["checkpointNs"]), g = dt(l, ["checkpointId"]), h = rt(e.config), v = Array.isArray(e.tasks) ? e.tasks.map((T) => ({ ...T })) : e.tasks ?? null, m = Array.isArray(e.next) ? [...e.next] : e.next ?? null, y = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt : new Date(Date.now() - t).toISOString(), I = {
3049
+ const n = ((z = e.values) == null ? void 0 : z.activeAgent) ?? null, r = (w = e.values) == null ? void 0 : w.messages, o = (Array.isArray(r) ? r : []).map((v) => Xr(v, n)).filter((v) => !!v), a = nt(e.metadata) ?? {}, i = Jt(e.config), f = nt(e.parentConfig), l = Jt(f), c = ut(i, ["checkpointId"]), d = ut(i, ["checkpointNs"]), g = ut(l, ["checkpointId"]), h = nt(e.config), k = Array.isArray(e.tasks) ? e.tasks.map((v) => ({ ...v })) : e.tasks ?? null, m = Array.isArray(e.next) ? [...e.next] : e.next ?? null, y = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt : new Date(Date.now() - t).toISOString(), I = {
3050
3050
  ...a,
3051
- step: Gr(a, ["step"]) ?? 0,
3052
- source: dt(a, ["source"]) ?? null
3053
- }, A = o.map((T) => ({
3054
- ...T,
3055
- checkpointId: T.checkpointId ?? c ?? null,
3056
- checkpointNs: T.checkpointNs ?? d ?? null
3057
- })), x = e.values, N = Array.isArray(e.interrupts) ? e.interrupts : Array.isArray(x == null ? void 0 : x.interrupts) ? x.interrupts : [];
3051
+ step: Wr(a, ["step"]) ?? 0,
3052
+ source: ut(a, ["source"]) ?? null
3053
+ }, S = o.map((v) => ({
3054
+ ...v,
3055
+ checkpointId: v.checkpointId ?? c ?? null,
3056
+ checkpointNs: v.checkpointNs ?? d ?? null
3057
+ })), C = e.values, L = Array.isArray(e.interrupts) ? e.interrupts : Array.isArray(C == null ? void 0 : C.interrupts) ? C.interrupts : [];
3058
3058
  return {
3059
3059
  checkpointId: c ?? null,
3060
3060
  checkpointNs: d ?? null,
3061
3061
  createdAt: y,
3062
3062
  parentId: g ?? null,
3063
- messages: A,
3063
+ messages: S,
3064
3064
  interrupt: Qr(
3065
- N,
3065
+ L,
3066
3066
  t,
3067
3067
  c ?? null
3068
3068
  ),
@@ -3070,7 +3070,7 @@ function Jr(e, t) {
3070
3070
  config: h ?? null,
3071
3071
  parentConfig: f ?? null,
3072
3072
  next: m,
3073
- tasks: v,
3073
+ tasks: k,
3074
3074
  values: e.values ?? {}
3075
3075
  };
3076
3076
  }
@@ -3094,7 +3094,7 @@ function Qr(e, t, n) {
3094
3094
  }
3095
3095
  return null;
3096
3096
  }
3097
- function Qt(e) {
3097
+ function Xt(e) {
3098
3098
  if (!e) return 0;
3099
3099
  const t = Date.parse(e);
3100
3100
  return Number.isFinite(t) ? t : 0;
@@ -3103,120 +3103,120 @@ function Yr(e) {
3103
3103
  return !!e && typeof e == "object" && "data" in e;
3104
3104
  }
3105
3105
  function Zr(e = {}) {
3106
- const t = e.baseUrl || "", n = e.streamPath ?? "/stream", [r, s] = H(e.token ?? null), o = K(e.headers ?? {}), a = e.credentials ?? "include", i = K(e);
3107
- ae(() => {
3106
+ const t = e.baseUrl || "", n = e.streamPath ?? "/stream", [r, s] = W(e.token ?? null), o = H(e.headers ?? {}), a = e.credentials ?? "include", i = H(e);
3107
+ se(() => {
3108
3108
  i.current = e;
3109
3109
  }, [e]);
3110
- const f = E((p) => {
3111
- var U, q, B, re, X, se, G, oe, pe, ee;
3112
- const b = i.current;
3113
- if (!b) return;
3114
- if (p.type === "thread_info") {
3115
- (U = b.onThreadInfo) == null || U.call(b, p);
3110
+ const f = E((T) => {
3111
+ var x, q, U, ne, ee, Y, j, re, be, ve;
3112
+ const p = i.current;
3113
+ if (!p) return;
3114
+ if (T.type === "thread_info") {
3115
+ (x = p.onThreadInfo) == null || x.call(p, T);
3116
3116
  return;
3117
3117
  }
3118
- if (p.type === "values" && Array.isArray(p.checkpoints)) {
3119
- (q = b.handleValuesEvent) == null || q.call(b, p);
3118
+ if (T.type === "values" && Array.isArray(T.checkpoints)) {
3119
+ (q = p.handleValuesEvent) == null || q.call(p, T);
3120
3120
  return;
3121
3121
  }
3122
- if (p.type === "metadata") {
3123
- (B = b.onMetadataEvent) == null || B.call(b, p);
3122
+ if (T.type === "metadata") {
3123
+ (U = p.onMetadataEvent) == null || U.call(p, T);
3124
3124
  return;
3125
3125
  }
3126
- if (typeof p.type == "string" && (p.type === "custom" || p.type.startsWith("custom."))) {
3127
- (re = b.onCustomEvent) == null || re.call(b, p);
3126
+ if (typeof T.type == "string" && (T.type === "custom" || T.type.startsWith("custom."))) {
3127
+ (ne = p.onCustomEvent) == null || ne.call(p, T);
3128
3128
  return;
3129
3129
  }
3130
- (X = b.onEvent) == null || X.call(b, p), p.type === "updates" && ((se = b.onUpdateEvent) == null || se.call(b, p)), p.type === "tool.end" ? (G = b.onToolEnd) == null || G.call(b, p) : p.type === "tool.start" && ((oe = b.onToolStart) == null || oe.call(b, p)), p.type === "heartbeat" && ((pe = b.onHeartbeat) == null || pe.call(b, p)), p.type === "token" && ((ee = b.onToken) == null || ee.call(b, p.token));
3131
- }, []), [l, c] = H(!1), [d, g] = H(null), [h, v] = H(""), [m, y] = H(null), [I, A] = H(0), [x, N] = H(!1), [_, k] = H({}), [T, L] = H(null), [j, O] = H({}), $ = K(null), C = K(!0), J = K(0), W = K(null), Q = K(null), te = K(null), ne = K(null), S = K([]), P = K(/* @__PURE__ */ new Set()), D = K({
3130
+ (ee = p.onEvent) == null || ee.call(p, T), T.type === "updates" && ((Y = p.onUpdateEvent) == null || Y.call(p, T)), T.type === "tool.end" ? (j = p.onToolEnd) == null || j.call(p, T) : T.type === "tool.start" && ((re = p.onToolStart) == null || re.call(p, T)), T.type === "heartbeat" && ((be = p.onHeartbeat) == null || be.call(p, T)), T.type === "token" && ((ve = p.onToken) == null || ve.call(p, T.token));
3131
+ }, []), [l, c] = W(!1), [d, g] = W(null), [h, k] = W(""), [m, y] = W(null), [I, S] = W(0), [C, L] = W(!1), [z, w] = W({}), [v, F] = W(null), [$, B] = W({}), D = H(null), P = H(!0), J = H(0), G = H(null), Q = H(null), X = H(null), oe = H(null), A = H([]), R = H(/* @__PURE__ */ new Set()), V = H({
3132
3132
  messageId: null,
3133
3133
  lastSeq: null,
3134
3134
  lastText: ""
3135
- }), V = E((p) => {
3136
- s(p);
3135
+ }), K = E((T) => {
3136
+ s(T);
3137
3137
  }, []), u = E(() => {
3138
- v(""), y(null), g(null), Q.current = null, te.current = null, ne.current = null, S.current = [], P.current = /* @__PURE__ */ new Set(), k({}), L(null), O({}), D.current = {
3138
+ k(""), y(null), g(null), Q.current = null, X.current = null, oe.current = null, A.current = [], R.current = /* @__PURE__ */ new Set(), w({}), F(null), B({}), V.current = {
3139
3139
  messageId: null,
3140
3140
  lastSeq: null,
3141
3141
  lastText: ""
3142
3142
  };
3143
- }, []), R = E(() => {
3144
- var U;
3143
+ }, []), N = E(() => {
3144
+ var x;
3145
3145
  console.debug("[use-chat] stop() invoked - aborting stream");
3146
- const p = (U = W.current) == null ? void 0 : U.threadId, b = () => {
3146
+ const T = (x = G.current) == null ? void 0 : x.threadId, p = () => {
3147
3147
  var q;
3148
- (q = $.current) == null || q.abort(), $.current = null, W.current = null, c(!1), N(!1), J.current = 0, A(0);
3148
+ (q = D.current) == null || q.abort(), D.current = null, G.current = null, c(!1), L(!1), J.current = 0, S(0);
3149
3149
  };
3150
- (p ? hn.cancelRun(p).catch((q) => {
3150
+ (T ? mn.cancelRun(T).catch((q) => {
3151
3151
  console.warn("[use-chat] cancel run failed:", q);
3152
- }) : Promise.resolve()).finally(b);
3153
- }, []), M = E(
3154
- (p) => {
3155
- $.current && ($.current.abort(), $.current = null);
3156
- const b = {
3157
- text: typeof p.content == "string" ? p.content : p.text,
3158
- threadId: p.threadId,
3159
- attachments: p.attachments,
3160
- payload: p.payload,
3161
- config: p.config,
3162
- checkpointId: p.checkpointId,
3163
- checkpointNs: p.checkpointNs || void 0,
3164
- edit: p.edit,
3165
- command: p.command
3152
+ }) : Promise.resolve()).finally(p);
3153
+ }, []), _ = E(
3154
+ (T) => {
3155
+ D.current && (D.current.abort(), D.current = null);
3156
+ const p = {
3157
+ text: typeof T.content == "string" ? T.content : T.text,
3158
+ threadId: T.threadId,
3159
+ attachments: T.attachments,
3160
+ payload: T.payload,
3161
+ config: T.config,
3162
+ checkpointId: T.checkpointId,
3163
+ checkpointNs: T.checkpointNs || void 0,
3164
+ edit: T.edit,
3165
+ command: T.command
3166
3166
  };
3167
- c(!0), g(null), v(""), y(null), Q.current = null, te.current = null, ne.current = null, S.current = [], P.current = /* @__PURE__ */ new Set(), k({}), L(null), O({}), D.current = {
3167
+ c(!0), g(null), k(""), y(null), Q.current = null, X.current = null, oe.current = null, A.current = [], R.current = /* @__PURE__ */ new Set(), w({}), F(null), B({}), V.current = {
3168
3168
  messageId: null,
3169
3169
  lastSeq: null,
3170
3170
  lastText: ""
3171
3171
  };
3172
- const z = new AbortController();
3173
- $.current = z;
3174
- let U = null, q = !1;
3175
- const B = (re) => {
3176
- if (P.current.has(re)) return;
3177
- const X = S.current[0];
3178
- X && k((se) => {
3179
- let G = T;
3180
- if (!G) {
3181
- const ge = Object.values(se).filter((je) => je.role === "assistant");
3182
- ge.length > 0 && (G = ge[ge.length - 1].id);
3172
+ const M = new AbortController();
3173
+ D.current = M;
3174
+ let x = null, q = !1;
3175
+ const U = (ne) => {
3176
+ if (R.current.has(ne)) return;
3177
+ const ee = A.current[0];
3178
+ ee && w((Y) => {
3179
+ let j = v;
3180
+ if (!j) {
3181
+ const fe = Object.values(Y).filter((Fe) => Fe.role === "assistant");
3182
+ fe.length > 0 && (j = fe[fe.length - 1].id);
3183
3183
  }
3184
- if (!G || !se[G]) return se;
3185
- const oe = se[G], pe = [...oe.toolCalls || []], ee = X.id ?? `task-${re}`;
3186
- return pe.some((ge) => ge.id === ee && ge.name === "task" && ge.scope === re) || pe.push({
3187
- id: ee,
3184
+ if (!j || !Y[j]) return Y;
3185
+ const re = Y[j], be = [...re.toolCalls || []], ve = ee.id ?? `task-${ne}`;
3186
+ return be.some((fe) => fe.id === ve && fe.name === "task" && fe.scope === ne) || be.push({
3187
+ id: ve,
3188
3188
  name: "task",
3189
3189
  args: {
3190
- description: X.description,
3191
- subagentType: X.subagentType
3190
+ description: ee.description,
3191
+ subagentType: ee.subagentType
3192
3192
  },
3193
3193
  status: "running",
3194
- content: X.description,
3195
- scope: re
3196
- }), P.current.add(re), S.current.shift(), { ...se, [G]: { ...oe, toolCalls: pe } };
3194
+ content: ee.description,
3195
+ scope: ne
3196
+ }), R.current.add(ne), A.current.shift(), { ...Y, [j]: { ...re, toolCalls: be } };
3197
3197
  });
3198
3198
  };
3199
- return W.current = {
3200
- threadId: b.threadId ?? null,
3199
+ return G.current = {
3200
+ threadId: p.threadId ?? null,
3201
3201
  headers: {},
3202
3202
  isStreaming: !0
3203
3203
  }, (async () => {
3204
- var re, X, se, G, oe, pe, ee, Fe, ge, je, Oe, Xe;
3204
+ var ne, ee, Y, j, re, be, ve, Je, fe, Fe, je, Xe;
3205
3205
  try {
3206
3206
  let Te = {};
3207
3207
  try {
3208
3208
  if (r)
3209
3209
  Te = { Authorization: `Bearer ${r}` };
3210
3210
  else if (typeof window < "u") {
3211
- const Se = window.__AUTH_TOKEN__, Tt = ((re = window.localStorage) == null ? void 0 : re.getItem(nt.authToken)) || null;
3212
- let lt = null;
3211
+ const Se = window.__AUTH_TOKEN__, Tt = ((ne = window.localStorage) == null ? void 0 : ne.getItem(tt.authToken)) || null;
3212
+ let ct = null;
3213
3213
  try {
3214
- const ut = (X = window.localStorage) == null ? void 0 : X.getItem(nt.chatSettings);
3215
- ut && (lt = ((se = JSON.parse(ut)) == null ? void 0 : se.apiKey) || null);
3214
+ const lt = (ee = window.localStorage) == null ? void 0 : ee.getItem(tt.chatSettings);
3215
+ lt && (ct = ((Y = JSON.parse(lt)) == null ? void 0 : Y.apiKey) || null);
3216
3216
  } catch {
3217
3217
  }
3218
- const He = Se || Tt || lt || null;
3219
- He && (Te = { Authorization: `Bearer ${He}` });
3218
+ const Ke = Se || Tt || ct || null;
3219
+ Ke && (Te = { Authorization: `Bearer ${Ke}` });
3220
3220
  }
3221
3221
  } catch {
3222
3222
  }
@@ -3224,88 +3224,88 @@ function Zr(e = {}) {
3224
3224
  let Ae = {};
3225
3225
  if (typeof window < "u")
3226
3226
  try {
3227
- const de = (G = window.localStorage) == null ? void 0 : G.getItem(nt.authSessionId);
3228
- de && (Ae = { "X-Session-Id": de });
3227
+ const ue = (j = window.localStorage) == null ? void 0 : j.getItem(tt.authSessionId);
3228
+ ue && (Ae = { "X-Session-Id": ue });
3229
3229
  } catch {
3230
3230
  }
3231
- const Ke = {
3231
+ const Ve = {
3232
3232
  ...Te,
3233
3233
  ...Ae,
3234
3234
  ...o.current
3235
- }, vt = {
3235
+ }, It = {
3236
3236
  "Content-Type": "application/json",
3237
3237
  Accept: "text/event-stream",
3238
- ...Ke
3238
+ ...Ve
3239
3239
  }, Ie = await fetch(t + n, {
3240
3240
  method: "POST",
3241
- headers: vt,
3242
- body: JSON.stringify(b),
3243
- signal: z.signal,
3241
+ headers: It,
3242
+ body: JSON.stringify(p),
3243
+ signal: M.signal,
3244
3244
  credentials: a
3245
3245
  });
3246
- if (W.current && (W.current.headers = Ke), !Ie.ok || !Ie.body) {
3247
- const de = await Ie.text().catch(() => "");
3246
+ if (G.current && (G.current.headers = Ve), !Ie.ok || !Ie.body) {
3247
+ const ue = await Ie.text().catch(() => "");
3248
3248
  console.debug(
3249
3249
  "[use-chat] non-OK response",
3250
3250
  Ie.status,
3251
- de == null ? void 0 : de.slice(0, 500)
3251
+ ue == null ? void 0 : ue.slice(0, 500)
3252
3252
  );
3253
- const Se = `stream ${Ie.status}${de ? ": " + de : ""}`;
3254
- throw Se && (g(Se), U = "error"), new Error(Se);
3253
+ const Se = `stream ${Ie.status}${ue ? ": " + ue : ""}`;
3254
+ throw Se && (g(Se), x = "error"), new Error(Se);
3255
3255
  }
3256
- N(!0);
3257
- const Qe = Ie.body.getReader(), Mn = new TextDecoder();
3258
- let $e = "", ct = [];
3259
- J.current = 0, A(0);
3260
- let Ye = 0, Be = null;
3261
- const It = () => {
3262
- if (ct.length) {
3263
- const de = ct.join("");
3264
- ct = [], C.current && v((Se) => Se + de);
3256
+ L(!0);
3257
+ const Qe = Ie.body.getReader(), Cn = new TextDecoder();
3258
+ let Oe = "", it = [];
3259
+ J.current = 0, S(0);
3260
+ let Ye = 0, $e = null;
3261
+ const vt = () => {
3262
+ if (it.length) {
3263
+ const ue = it.join("");
3264
+ it = [], P.current && k((Se) => Se + ue);
3265
3265
  }
3266
- Be = null;
3267
- }, En = () => {
3268
- typeof window < "u" && Be == null && (Be = requestAnimationFrame(It));
3266
+ $e = null;
3267
+ }, Mn = () => {
3268
+ typeof window < "u" && $e == null && ($e = requestAnimationFrame(vt));
3269
3269
  };
3270
- let jt = Date.now();
3271
- const Pn = setInterval(() => {
3272
- Date.now() - jt > 18e5 && (g("Stream idle timeout"), U = "error", z.abort());
3273
- }, 5e3), Rn = 1024 * 1024;
3270
+ let Ft = Date.now();
3271
+ const En = setInterval(() => {
3272
+ Date.now() - Ft > 18e5 && (g("Stream idle timeout"), x = "error", M.abort());
3273
+ }, 5e3), Pn = 1024 * 1024;
3274
3274
  try {
3275
3275
  const Se = (Ie.headers.get("X-Thread-Id") || Ie.headers.get("x-thread-id")) ?? null;
3276
- for (W.current && !W.current.threadId && (W.current = {
3277
- ...W.current,
3276
+ for (G.current && !G.current.threadId && (G.current = {
3277
+ ...G.current,
3278
3278
  threadId: Se
3279
3279
  }); ; ) {
3280
- const { value: Tt, done: lt } = await Qe.read();
3281
- if (lt) break;
3282
- $e += Mn.decode(Tt, { stream: !0 }), $e.length > Rn && ($e = "", console.warn("Stream buffer reset: exceeded 1MB"));
3283
- let He;
3284
- for (; (He = $e.indexOf(`
3280
+ const { value: Tt, done: ct } = await Qe.read();
3281
+ if (ct) break;
3282
+ Oe += Cn.decode(Tt, { stream: !0 }), Oe.length > Pn && (Oe = "", console.warn("Stream buffer reset: exceeded 1MB"));
3283
+ let Ke;
3284
+ for (; (Ke = Oe.indexOf(`
3285
3285
 
3286
3286
  `)) >= 0; ) {
3287
- const ut = $e.slice(0, He);
3288
- $e = $e.slice(He + 2);
3289
- const Nn = ut.split(/\r?\n/), Ot = [];
3287
+ const lt = Oe.slice(0, Ke);
3288
+ Oe = Oe.slice(Ke + 2);
3289
+ const Rn = lt.split(/\r?\n/), jt = [];
3290
3290
  let At = null;
3291
- for (const w of Nn) {
3292
- if (w.startsWith(":")) {
3293
- w.startsWith(": heartbeat") && console.debug("[use-chat] SSE heartbeat comment received");
3291
+ for (const b of Rn) {
3292
+ if (b.startsWith(":")) {
3293
+ b.startsWith(": heartbeat") && console.debug("[use-chat] SSE heartbeat comment received");
3294
3294
  continue;
3295
3295
  }
3296
- if (w) {
3297
- if (w.startsWith("event:")) {
3298
- const le = w.slice(6).trim();
3299
- le && (At = le);
3296
+ if (b) {
3297
+ if (b.startsWith("event:")) {
3298
+ const ce = b.slice(6).trim();
3299
+ ce && (At = ce);
3300
3300
  continue;
3301
3301
  }
3302
- if (w.startsWith("data:")) {
3303
- const le = w.slice(5);
3304
- Ot.push(le.startsWith(" ") ? le.slice(1) : le);
3302
+ if (b.startsWith("data:")) {
3303
+ const ce = b.slice(5);
3304
+ jt.push(ce.startsWith(" ") ? ce.slice(1) : ce);
3305
3305
  }
3306
3306
  }
3307
3307
  }
3308
- const St = Ot.join(`
3308
+ const St = jt.join(`
3309
3309
  `);
3310
3310
  if (!St) continue;
3311
3311
  let Pe;
@@ -3316,230 +3316,230 @@ function Zr(e = {}) {
3316
3316
  continue;
3317
3317
  }
3318
3318
  At && typeof Pe == "object" && Pe !== null && !("type" in Pe) && (Pe.type = At);
3319
- const $t = Yr(Pe) ? Pe.data : Pe;
3320
- if (!$t) {
3319
+ const Ot = Yr(Pe) ? Pe.data : Pe;
3320
+ if (!Ot) {
3321
3321
  console.warn("[use-chat] dropped envelope event without payload", Pe);
3322
3322
  continue;
3323
3323
  }
3324
- const ie = Mr($t);
3325
- jt = Date.now();
3326
- const De = ie.seq;
3327
- if (De !== void 0) {
3328
- if (De <= Ye) {
3329
- console.debug("[use-chat] drop duplicate/out-of-order event", { seq: De, lastProcessedSeq: Ye, type: ie.type });
3324
+ const ae = Cr(Ot);
3325
+ Ft = Date.now();
3326
+ const Be = ae.seq;
3327
+ if (Be !== void 0) {
3328
+ if (Be <= Ye) {
3329
+ console.debug("[use-chat] drop duplicate/out-of-order event", { seq: Be, lastProcessedSeq: Ye, type: ae.type });
3330
3330
  continue;
3331
3331
  }
3332
- Ye > 0 && De > Ye + 1, Ye = De, J.current = De, A(De);
3332
+ Ye > 0 && Be > Ye + 1, Ye = Be, J.current = Be, S(Be);
3333
3333
  }
3334
- const _n = ["messages/partial", "metadata", "checkpoint", "values", "heartbeat", "token", "status", "error", "interrupt", "tool.start", "tool.progress", "tool.end", "task.start"];
3335
- let ke = ie.type || "unknown";
3336
- if (_n.includes(ke) || (ie.messages || ie.content !== void 0 && ie.id) && (ke = "messages/partial"), ke === "checkpoint") {
3337
- const w = ie;
3338
- Q.current = w.checkpointId ?? null, te.current = w.checkpointNs ?? null, y(w.checkpointId ?? null);
3339
- } else if (ke === "values") {
3340
- const w = ie, le = w == null ? void 0 : w.origin, ce = w == null ? void 0 : w.scope;
3341
- le === "task" && typeof ce == "string" && ce.startsWith("tools:") && B(ce);
3342
- const me = le === "task" || typeof ce == "string" && ce.startsWith("tools:");
3343
- if (Array.isArray(w.checkpoints)) {
3344
- ne.current = w;
3334
+ const Nn = ["messages/partial", "metadata", "checkpoint", "values", "heartbeat", "token", "status", "error", "interrupt", "tool.start", "tool.progress", "tool.end", "task.start"];
3335
+ let we = ae.type || "unknown";
3336
+ if (Nn.includes(we) || (ae.messages || ae.content !== void 0 && ae.id) && (we = "messages/partial"), we === "checkpoint") {
3337
+ const b = ae;
3338
+ Q.current = b.checkpointId ?? null, X.current = b.checkpointNs ?? null, y(b.checkpointId ?? null);
3339
+ } else if (we === "values") {
3340
+ const b = ae, ce = b == null ? void 0 : b.origin, ie = b == null ? void 0 : b.scope;
3341
+ ce === "task" && typeof ie == "string" && ie.startsWith("tools:") && U(ie);
3342
+ const pe = ce === "task" || typeof ie == "string" && ie.startsWith("tools:");
3343
+ if (Array.isArray(b.checkpoints)) {
3344
+ oe.current = b;
3345
3345
  try {
3346
- const ue = tt(w).latest;
3347
- ue && (Q.current = ue.checkpointId ?? null, te.current = ue.checkpointNs ?? null, y(ue.checkpointId ?? null), me || O(ue.values ?? {})), me || (k({}), L(null));
3348
- } catch (Y) {
3349
- console.warn("[use-chat] Failed to hydrate values payload", Y);
3346
+ const le = ft(b).latest;
3347
+ le && (Q.current = le.checkpointId ?? null, X.current = le.checkpointNs ?? null, y(le.checkpointId ?? null), pe || B(le.values ?? {})), pe || (w({}), F(null));
3348
+ } catch (Z) {
3349
+ console.warn("[use-chat] Failed to hydrate values payload", Z);
3350
3350
  }
3351
- } else if ((oe = w.values) != null && oe.messages)
3352
- me || (k({}), L(null)), me || O(w.values ?? {});
3351
+ } else if ((re = b.values) != null && re.messages)
3352
+ pe || (w({}), F(null)), pe || B(b.values ?? {});
3353
3353
  else {
3354
- const Y = w.values && typeof w.values == "object" ? w.values : w;
3355
- me || O(Y ?? {});
3354
+ const Z = b.values && typeof b.values == "object" ? b.values : b;
3355
+ pe || B(Z ?? {});
3356
3356
  }
3357
3357
  }
3358
- if (ke === "task.start") {
3359
- const w = ie;
3360
- S.current.push({
3361
- id: w.id ?? w.callId,
3362
- description: w.description,
3363
- subagentType: w.subagentType ?? w.subagent_type
3358
+ if (we === "task.start") {
3359
+ const b = ae;
3360
+ A.current.push({
3361
+ id: b.id ?? b.callId,
3362
+ description: b.description,
3363
+ subagentType: b.subagentType ?? b.subagent_type
3364
3364
  });
3365
3365
  }
3366
- if (ke === "tool.start" || ke === "tool.progress" || ke === "tool.end") {
3367
- const w = ie, le = w.id || w.callId, ce = w.scope;
3368
- w.origin === "task" && typeof ce == "string" && ce.startsWith("tools:") && B(ce), le && k((me) => {
3369
- let Y = T;
3370
- if (!Y) {
3371
- const ue = Object.values(me).filter((he) => he.role === "assistant");
3372
- ue.length > 0 && (Y = ue[ue.length - 1].id);
3366
+ if (we === "tool.start" || we === "tool.progress" || we === "tool.end") {
3367
+ const b = ae, ce = b.id || b.callId, ie = b.scope;
3368
+ b.origin === "task" && typeof ie == "string" && ie.startsWith("tools:") && U(ie), ce && w((pe) => {
3369
+ let Z = v;
3370
+ if (!Z) {
3371
+ const le = Object.values(pe).filter((ge) => ge.role === "assistant");
3372
+ le.length > 0 && (Z = le[le.length - 1].id);
3373
3373
  }
3374
- if (Y && me[Y]) {
3375
- const ue = me[Y], he = [...ue.toolCalls || []], xe = he.findIndex((Re) => Re.id === le);
3376
- let be = w.content || w.status || "Processing...";
3377
- return ie.type === "tool.start" ? be = `Starting ${w.name || w.tool || "tool"}...` : ie.type === "tool.end" && w.error && (be = `Error: ${w.error}`), xe >= 0 ? he[xe] = {
3378
- ...he[xe],
3379
- content: be,
3380
- status: ie.type === "tool.start" ? "running" : ie.type === "tool.end" ? w.error ? "failed" : "completed" : he[xe].status,
3381
- artifact: w.artifact || he[xe].artifact,
3382
- scope: ce ?? he[xe].scope
3383
- } : he.push({
3384
- id: le,
3385
- name: w.name || w.tool || "tool",
3386
- args: w.args || {},
3387
- status: ie.type === "tool.end" ? w.error ? "failed" : "completed" : "running",
3388
- content: be,
3389
- artifact: w.artifact,
3390
- scope: ce
3391
- }), { ...me, [Y]: { ...ue, toolCalls: he } };
3374
+ if (Z && pe[Z]) {
3375
+ const le = pe[Z], ge = [...le.toolCalls || []], xe = ge.findIndex((Re) => Re.id === ce);
3376
+ let he = b.content || b.status || "Processing...";
3377
+ return ae.type === "tool.start" ? he = `Starting ${b.name || b.tool || "tool"}...` : ae.type === "tool.end" && b.error && (he = `Error: ${b.error}`), xe >= 0 ? ge[xe] = {
3378
+ ...ge[xe],
3379
+ content: he,
3380
+ status: ae.type === "tool.start" ? "running" : ae.type === "tool.end" ? b.error ? "failed" : "completed" : ge[xe].status,
3381
+ artifact: b.artifact || ge[xe].artifact,
3382
+ scope: ie ?? ge[xe].scope
3383
+ } : ge.push({
3384
+ id: ce,
3385
+ name: b.name || b.tool || "tool",
3386
+ args: b.args || {},
3387
+ status: ae.type === "tool.end" ? b.error ? "failed" : "completed" : "running",
3388
+ content: he,
3389
+ artifact: b.artifact,
3390
+ scope: ie
3391
+ }), { ...pe, [Z]: { ...le, toolCalls: ge } };
3392
3392
  }
3393
- return me;
3393
+ return pe;
3394
3394
  });
3395
- } else if (ke === "messages/partial") {
3396
- const w = ie, le = w.messages || [w];
3397
- if (Array.isArray(le) && le.length > 0) {
3398
- const ce = le.find((Y) => Y.type === "ai"), me = le.find((Y) => Y.type === "tool");
3399
- if (ce) {
3400
- const Y = ce.id, ue = ce.content ?? "", he = !1, xe = he ? (D.current.lastText || "") + ue : ue;
3401
- if (D.current.messageId !== Y) {
3402
- const be = ce.name ?? ce.agentName ?? "assistant";
3403
- D.current = {
3404
- messageId: Y,
3395
+ } else if (we === "messages/partial") {
3396
+ const b = ae, ce = b.messages || [b];
3397
+ if (Array.isArray(ce) && ce.length > 0) {
3398
+ const ie = ce.find((Z) => Z.type === "ai"), pe = ce.find((Z) => Z.type === "tool");
3399
+ if (ie) {
3400
+ const Z = ie.id, le = ie.content ?? "", ge = !1, xe = ge ? (V.current.lastText || "") + le : le;
3401
+ if (V.current.messageId !== Z) {
3402
+ const he = ie.name ?? ie.agentName ?? "assistant";
3403
+ V.current = {
3404
+ messageId: Z,
3405
3405
  lastSeq: null,
3406
3406
  lastText: ""
3407
3407
  };
3408
3408
  const Re = bt({
3409
- id: Y,
3409
+ id: Z,
3410
3410
  role: "assistant",
3411
- name: be,
3412
- model: be,
3411
+ name: he,
3412
+ model: he,
3413
3413
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
3414
3414
  content: [{ type: "text", text: xe }]
3415
3415
  });
3416
- k((Ln) => ({ ...Ln, [Y]: Re })), L(Y), D.current.lastText = xe;
3416
+ w((_n) => ({ ..._n, [Z]: Re })), F(Z), V.current.lastText = xe;
3417
3417
  } else
3418
- k((be) => {
3419
- const Re = be[Y];
3418
+ w((he) => {
3419
+ const Re = he[Z];
3420
3420
  return Re ? {
3421
- ...be,
3422
- [Y]: {
3421
+ ...he,
3422
+ [Z]: {
3423
3423
  ...Re,
3424
3424
  content: [{ type: "text", text: xe }],
3425
3425
  // Preserve existing metadata if the chunk doesn't have it
3426
- responseMetadata: ce.responseMetadata ?? Re.responseMetadata
3426
+ responseMetadata: ie.responseMetadata ?? Re.responseMetadata
3427
3427
  }
3428
- } : be;
3429
- }), D.current.lastText = xe;
3430
- if (!he) {
3431
- const be = D.current.lastText || "";
3432
- if (ue.length > be.length) {
3433
- const Re = ue.slice(be.length);
3434
- ct.push(Re), En();
3428
+ } : he;
3429
+ }), V.current.lastText = xe;
3430
+ if (!ge) {
3431
+ const he = V.current.lastText || "";
3432
+ if (le.length > he.length) {
3433
+ const Re = le.slice(he.length);
3434
+ it.push(Re), Mn();
3435
3435
  }
3436
3436
  }
3437
3437
  }
3438
- if (me) {
3439
- const Y = me.id || `tool-${Date.now()}`, ue = bt({
3440
- ...me,
3441
- id: Y,
3438
+ if (pe) {
3439
+ const Z = pe.id || `tool-${Date.now()}`, le = bt({
3440
+ ...pe,
3441
+ id: Z,
3442
3442
  role: "tool",
3443
3443
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
3444
3444
  });
3445
- k((he) => ({ ...he, [Y]: ue }));
3445
+ w((ge) => ({ ...ge, [Z]: le }));
3446
3446
  }
3447
3447
  }
3448
- } else if (ke === "heartbeat") {
3448
+ } else if (we === "heartbeat") {
3449
3449
  console.debug("[use-chat] heartbeat received");
3450
3450
  try {
3451
- } catch (w) {
3452
- console.warn("[use-chat] heartbeat callback failed", w);
3451
+ } catch (b) {
3452
+ console.warn("[use-chat] heartbeat callback failed", b);
3453
3453
  }
3454
- } else if (Be !== null && cancelAnimationFrame(Be), It(), ke === "checkpoint")
3455
- y(ie.checkpointId ?? null);
3456
- else if (ke === "error") {
3457
- const w = ie;
3458
- if (g(w.message), U = "error", w.error_type === "auth_error" || w.code === "TOKEN_EXPIRED" || ((pe = w.message) == null ? void 0 : pe.includes("token")) || ((ee = w.message) == null ? void 0 : ee.includes("401")) || ((Fe = w.message) == null ? void 0 : Fe.includes("unauthorized")) || ((ge = w.message) == null ? void 0 : ge.includes("Unauthorized"))) {
3459
- console.error("[use-chat] Auth error detected:", w.message);
3454
+ } else if ($e !== null && cancelAnimationFrame($e), vt(), we === "checkpoint")
3455
+ y(ae.checkpointId ?? null);
3456
+ else if (we === "error") {
3457
+ const b = ae;
3458
+ if (g(b.message), x = "error", b.error_type === "auth_error" || b.code === "TOKEN_EXPIRED" || ((be = b.message) == null ? void 0 : be.includes("token")) || ((ve = b.message) == null ? void 0 : ve.includes("401")) || ((Je = b.message) == null ? void 0 : Je.includes("unauthorized")) || ((fe = b.message) == null ? void 0 : fe.includes("Unauthorized"))) {
3459
+ console.error("[use-chat] Auth error detected:", b.message);
3460
3460
  try {
3461
- (je = e.onAuthError) == null || je.call(e, w.message);
3462
- } catch (ce) {
3463
- console.warn("[use-chat] onAuthError handler failed", ce);
3461
+ (Fe = e.onAuthError) == null || Fe.call(e, b.message);
3462
+ } catch (ie) {
3463
+ console.warn("[use-chat] onAuthError handler failed", ie);
3464
3464
  }
3465
- z.abort();
3465
+ M.abort();
3466
3466
  }
3467
- } else if (ke === "status") {
3468
- const w = ie;
3469
- (w.status === "completed" || w.status === "interrupted" || w.status === "error") && (c(!1), console.log("[use-chat] Status event received:", w));
3467
+ } else if (we === "status") {
3468
+ const b = ae;
3469
+ (b.status === "completed" || b.status === "interrupted" || b.status === "error") && (c(!1), console.log("[use-chat] Status event received:", b));
3470
3470
  }
3471
- f(ie);
3471
+ f(ae);
3472
3472
  }
3473
3473
  }
3474
- It(), U === null && !z.signal.aborted && (U = "complete");
3475
- } catch (de) {
3476
- if (de.name === "AbortError")
3477
- U = U ?? "aborted";
3474
+ vt(), x === null && !M.signal.aborted && (x = "complete");
3475
+ } catch (ue) {
3476
+ if (ue.name === "AbortError")
3477
+ x = x ?? "aborted";
3478
3478
  else {
3479
- const Se = de.message || String(de);
3480
- U = "error", g(Se);
3479
+ const Se = ue.message || String(ue);
3480
+ x = "error", g(Se);
3481
3481
  }
3482
3482
  } finally {
3483
3483
  try {
3484
3484
  await Qe.cancel();
3485
3485
  } catch {
3486
3486
  } finally {
3487
- (Oe = Qe.releaseLock) == null || Oe.call(Qe);
3487
+ (je = Qe.releaseLock) == null || je.call(Qe);
3488
3488
  }
3489
- Be !== null && typeof window < "u" && window.cancelAnimationFrame(Be), clearInterval(Pn);
3489
+ $e !== null && typeof window < "u" && window.cancelAnimationFrame($e), clearInterval(En);
3490
3490
  }
3491
3491
  } catch (Te) {
3492
3492
  if (Te.name === "AbortError")
3493
- U = U ?? "aborted";
3493
+ x = x ?? "aborted";
3494
3494
  else {
3495
3495
  const Ae = Te.message || String(Te);
3496
- U = "error", g(Ae), q || (q = !0, (Xe = e.onConnectionError) == null || Xe.call(e, Ae));
3496
+ x = "error", g(Ae), q || (q = !0, (Xe = e.onConnectionError) == null || Xe.call(e, Ae));
3497
3497
  }
3498
3498
  } finally {
3499
- const Te = J.current, Ae = Q.current, Ke = te.current, vt = ne.current;
3499
+ const Te = J.current, Ae = Q.current, Ve = X.current, It = oe.current;
3500
3500
  try {
3501
3501
  if (e.onFinish) {
3502
3502
  const Ie = {
3503
3503
  lastSeq: Te,
3504
3504
  lastCheckpointId: Ae,
3505
- lastCheckpointNs: Ke,
3506
- lastValues: vt
3505
+ lastCheckpointNs: Ve,
3506
+ lastValues: It
3507
3507
  };
3508
3508
  e.onFinish(Ie);
3509
3509
  }
3510
3510
  } catch (Ie) {
3511
3511
  console.warn("[use-chat] onClosed callback failed", Ie);
3512
3512
  }
3513
- c(!1), N(!1), $.current = null, J.current = 0, A(0), W.current = null;
3513
+ c(!1), L(!1), D.current = null, J.current = 0, S(0), G.current = null;
3514
3514
  }
3515
3515
  })(), Promise.resolve();
3516
3516
  },
3517
3517
  [t, n, r, e]
3518
3518
  );
3519
- return ae(() => () => {
3520
- var p;
3521
- C.current = !1, (p = $.current) == null || p.abort();
3519
+ return se(() => () => {
3520
+ var T;
3521
+ P.current = !1, (T = D.current) == null || T.abort();
3522
3522
  }, []), {
3523
3523
  isStreaming: l,
3524
3524
  error: d,
3525
3525
  assistantText: h,
3526
- activeMessageId: T,
3527
- streamedMessages: _,
3526
+ activeMessageId: v,
3527
+ streamedMessages: z,
3528
3528
  lastCheckpointId: m,
3529
3529
  lastSeq: I,
3530
- connected: x,
3531
- stream: M,
3532
- stop: R,
3530
+ connected: C,
3531
+ stream: _,
3532
+ stop: N,
3533
3533
  clear: u,
3534
- setToken: V,
3535
- values: j,
3534
+ setToken: K,
3535
+ values: $,
3536
3536
  interrupt: () => Promise.resolve(),
3537
3537
  resume: () => Promise.resolve(),
3538
3538
  goto: () => Promise.resolve(),
3539
- connectionState: d ? "error" : l ? x ? "connected" : "connecting" : "idle",
3539
+ connectionState: d ? "error" : l ? C ? "connected" : "connecting" : "idle",
3540
3540
  messages: [],
3541
3541
  // useStream doesn't maintain messages, use useChatSession instead
3542
- submit: M
3542
+ submit: _
3543
3543
  };
3544
3544
  }
3545
3545
  const es = ["detail", "message", "error", "description", "title"];
@@ -3592,159 +3592,159 @@ function ns({
3592
3592
  onThreadChange: r,
3593
3593
  onCurrentThreadDeleted: s
3594
3594
  }) {
3595
- const [o, a] = H([]), [i, f] = H(t), [l, c] = H(!1), [d, g] = H(null), [h, v] = H([]), [m, y] = H(!1), [, I] = H(null), [A, x] = H(null), [N, _] = H(!1), k = K(i), T = K(/* @__PURE__ */ new Map());
3596
- ae(() => {
3597
- k.current = i;
3598
- }, [i]), ae(() => {
3599
- t !== void 0 && t !== k.current && f(t);
3595
+ const [o, a] = W([]), [i, f] = W(t), [l, c] = W(!1), [d, g] = W(null), [h, k] = W([]), [m, y] = W(!1), [, I] = W(null), [S, C] = W(null), [L, z] = W(!1), w = H(i), v = H(/* @__PURE__ */ new Map());
3596
+ se(() => {
3597
+ w.current = i;
3598
+ }, [i]), se(() => {
3599
+ t !== void 0 && t !== w.current && f(t);
3600
3600
  }, [t]);
3601
- const L = E(async () => {
3601
+ const F = E(async () => {
3602
3602
  c(!0), g(null);
3603
3603
  try {
3604
- const S = await e.listThreads();
3605
- a(S ?? []);
3606
- } catch (S) {
3607
- const P = String(S);
3608
- g(P), n == null || n(P);
3604
+ const A = await e.listThreads();
3605
+ a(A ?? []);
3606
+ } catch (A) {
3607
+ const R = String(A);
3608
+ g(R), n == null || n(R);
3609
3609
  } finally {
3610
3610
  c(!1);
3611
3611
  }
3612
- }, [e, n]), j = E(async () => {
3612
+ }, [e, n]), $ = E(async () => {
3613
3613
  y(!0), I(null);
3614
3614
  try {
3615
- const S = await e.listSharedThreads();
3616
- v(S ?? []);
3617
- } catch (S) {
3618
- const P = String(S);
3619
- I(P), n == null || n(P);
3615
+ const A = await e.listSharedThreads();
3616
+ k(A ?? []);
3617
+ } catch (A) {
3618
+ const R = String(A);
3619
+ I(R), n == null || n(R);
3620
3620
  } finally {
3621
3621
  y(!1);
3622
3622
  }
3623
3623
  }, [e, n]);
3624
- ae(() => {
3625
- L();
3626
- }, [L]), ae(() => {
3627
- j();
3628
- }, [j]), ae(() => {
3624
+ se(() => {
3625
+ F();
3626
+ }, [F]), se(() => {
3627
+ $();
3628
+ }, [$]), se(() => {
3629
3629
  r == null || r(i);
3630
3630
  }, [i, r]);
3631
- const O = E(
3632
- async (S, P) => {
3631
+ const B = E(
3632
+ async (A, R) => {
3633
3633
  try {
3634
- const D = P && typeof P == "object" ? { id: P.id, name: P.name ?? "" } : void 0, V = await e.createThread(S, D);
3635
- return f(V.threadId), await L(), V.threadId;
3636
- } catch (D) {
3637
- const V = String(D);
3638
- return n == null || n(V), null;
3634
+ const V = R && typeof R == "object" ? { id: R.id, name: R.name ?? "" } : void 0, K = await e.createThread(A, V);
3635
+ return f(K.threadId), await F(), K.threadId;
3636
+ } catch (V) {
3637
+ const K = String(V);
3638
+ return n == null || n(K), null;
3639
3639
  }
3640
3640
  },
3641
- [e, n, L]
3642
- ), $ = E(
3643
- async (S) => {
3644
- const P = o;
3645
- a((V) => V.filter((u) => u.threadId !== S));
3646
- const D = new AbortController();
3647
- T.current.set(S, D);
3641
+ [e, n, F]
3642
+ ), D = E(
3643
+ async (A) => {
3644
+ const R = o;
3645
+ a((K) => K.filter((u) => u.threadId !== A));
3646
+ const V = new AbortController();
3647
+ v.current.set(A, V);
3648
3648
  try {
3649
- await e.deleteThread(S), k.current === S && (f(null), s == null || s());
3650
- } catch (V) {
3651
- a(P);
3652
- const u = String(V);
3649
+ await e.deleteThread(A), w.current === A && (f(null), s == null || s());
3650
+ } catch (K) {
3651
+ a(R);
3652
+ const u = String(K);
3653
3653
  n == null || n(u);
3654
3654
  } finally {
3655
- T.current.delete(S);
3655
+ v.current.delete(A);
3656
3656
  }
3657
3657
  },
3658
3658
  [e, s, n, o]
3659
- ), C = E(
3660
- async (S, P) => {
3659
+ ), P = E(
3660
+ async (A, R) => {
3661
3661
  try {
3662
- await e.updateThread(S, P), await L();
3663
- } catch (D) {
3664
- n == null || n(String(D));
3662
+ await e.updateThread(A, R), await F();
3663
+ } catch (V) {
3664
+ n == null || n(String(V));
3665
3665
  }
3666
3666
  },
3667
- [e, n, L]
3667
+ [e, n, F]
3668
3668
  ), J = E(
3669
- async (S, P) => {
3670
- _(!0), x("Sharing thread…");
3669
+ async (A, R) => {
3670
+ z(!0), C("Sharing thread…");
3671
3671
  try {
3672
- await e.shareThread(S, P), await j(), x("Shared successfully");
3673
- } catch (D) {
3674
- const V = ts(D);
3675
- throw n == null || n(V), x(`Failed to share: ${V}`), new Error(V);
3672
+ await e.shareThread(A, R), await $(), C("Shared successfully");
3673
+ } catch (V) {
3674
+ const K = ts(V);
3675
+ throw n == null || n(K), C(`Failed to share: ${K}`), new Error(K);
3676
3676
  } finally {
3677
- _(!1);
3677
+ z(!1);
3678
3678
  }
3679
3679
  },
3680
- [e, n, j]
3681
- ), W = E(
3682
- async (S, P) => {
3680
+ [e, n, $]
3681
+ ), G = E(
3682
+ async (A, R) => {
3683
3683
  try {
3684
- await e.unshareThread(S, P), await j();
3685
- } catch (D) {
3686
- const V = String(D);
3687
- throw n == null || n(V), D;
3684
+ await e.unshareThread(A, R), await $();
3685
+ } catch (V) {
3686
+ const K = String(V);
3687
+ throw n == null || n(K), V;
3688
3688
  }
3689
3689
  },
3690
- [e, n, j]
3691
- ), Q = fe(
3690
+ [e, n, $]
3691
+ ), Q = de(
3692
3692
  () => ({
3693
- createThread: O,
3694
- deleteThread: $,
3695
- renameThread: C,
3696
- refreshThreads: L,
3697
- refreshSharedThreads: j,
3693
+ createThread: B,
3694
+ deleteThread: D,
3695
+ renameThread: P,
3696
+ refreshThreads: F,
3697
+ refreshSharedThreads: $,
3698
3698
  shareThread: J,
3699
- unshareThread: W
3699
+ unshareThread: G
3700
3700
  }),
3701
- [O, $, C, L, j, J, W]
3702
- ), te = E((S) => {
3703
- if (!(S != null && S.threadId)) return;
3704
- const P = {
3705
- threadId: S.threadId,
3706
- title: S.title || `Thread ${S.threadId.slice(0, 8)}`,
3707
- project: S.project,
3708
- createdAt: S.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
3709
- updatedAt: S.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
3710
- messageCount: S.messageCount ?? 1
3701
+ [B, D, P, F, $, J, G]
3702
+ ), X = E((A) => {
3703
+ if (!(A != null && A.threadId)) return;
3704
+ const R = {
3705
+ threadId: A.threadId,
3706
+ title: A.title || `Thread ${A.threadId.slice(0, 8)}`,
3707
+ project: A.project,
3708
+ createdAt: A.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
3709
+ updatedAt: A.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
3710
+ messageCount: A.messageCount ?? 1
3711
3711
  };
3712
- a((D) => {
3713
- let V = !1;
3714
- const u = D.map((R) => R.threadId === P.threadId ? (V = !0, console.debug("[useThreadsState] thread_info: updating existing thread", P.threadId), {
3715
- ...R,
3716
- title: P.title ?? R.title,
3717
- project: P.project ?? R.project,
3718
- updatedAt: P.updatedAt ?? R.updatedAt,
3719
- messageCount: P.messageCount ?? R.messageCount
3720
- }) : R);
3721
- return V ? u : (console.debug("[useThreadsState] thread_info: adding thread to list", P.threadId), [P, ...D]);
3712
+ a((V) => {
3713
+ let K = !1;
3714
+ const u = V.map((N) => N.threadId === R.threadId ? (K = !0, console.debug("[useThreadsState] thread_info: updating existing thread", R.threadId), {
3715
+ ...N,
3716
+ title: R.title ?? N.title,
3717
+ project: R.project ?? N.project,
3718
+ updatedAt: R.updatedAt ?? N.updatedAt,
3719
+ messageCount: R.messageCount ?? N.messageCount
3720
+ }) : N);
3721
+ return K ? u : (console.debug("[useThreadsState] thread_info: adding thread to list", R.threadId), [R, ...V]);
3722
3722
  });
3723
- }, []), ne = E(() => x(null), []);
3723
+ }, []), oe = E(() => C(null), []);
3724
3724
  return {
3725
3725
  threads: o,
3726
3726
  currentThreadId: i,
3727
- currentThreadIdRef: k,
3727
+ currentThreadIdRef: w,
3728
3728
  setCurrentThreadId: f,
3729
3729
  isLoadingThreads: l,
3730
3730
  threadsError: d,
3731
3731
  sharedThreads: h,
3732
3732
  isLoadingSharedThreads: m,
3733
3733
  actions: Q,
3734
- addThreadFromEvent: te,
3735
- shareInFlight: N,
3736
- shareStatus: A,
3737
- clearShareStatus: ne
3734
+ addThreadFromEvent: X,
3735
+ shareInFlight: L,
3736
+ shareStatus: S,
3737
+ clearShareStatus: oe
3738
3738
  };
3739
3739
  }
3740
- const kn = Ge(null);
3740
+ const wn = We(null);
3741
3741
  function rs({
3742
3742
  children: e,
3743
3743
  initialThreadId: t = null,
3744
3744
  onError: n,
3745
3745
  onThreadChange: r
3746
3746
  }) {
3747
- const { chatApi: s } = We(), {
3747
+ const { chatApi: s } = qe(), {
3748
3748
  threads: o,
3749
3749
  currentThreadId: a,
3750
3750
  setCurrentThreadId: i,
@@ -3754,7 +3754,7 @@ function rs({
3754
3754
  sharedThreads: d,
3755
3755
  isLoadingSharedThreads: g,
3756
3756
  actions: h,
3757
- addThreadFromEvent: v,
3757
+ addThreadFromEvent: k,
3758
3758
  shareInFlight: m,
3759
3759
  shareStatus: y,
3760
3760
  clearShareStatus: I
@@ -3763,7 +3763,7 @@ function rs({
3763
3763
  initialThreadId: t,
3764
3764
  onError: n,
3765
3765
  onThreadChange: r
3766
- }), A = fe(
3766
+ }), S = de(
3767
3767
  () => ({
3768
3768
  threads: o,
3769
3769
  currentThreadId: a,
@@ -3777,7 +3777,7 @@ function rs({
3777
3777
  shareInFlight: m,
3778
3778
  shareStatus: y,
3779
3779
  clearShareStatus: I,
3780
- addThreadFromEvent: v
3780
+ addThreadFromEvent: k
3781
3781
  }),
3782
3782
  [
3783
3783
  o,
@@ -3792,17 +3792,17 @@ function rs({
3792
3792
  m,
3793
3793
  y,
3794
3794
  I,
3795
- v
3795
+ k
3796
3796
  ]
3797
3797
  );
3798
- return /* @__PURE__ */ Ce(kn.Provider, { value: A, children: e });
3798
+ return /* @__PURE__ */ Ce(wn.Provider, { value: S, children: e });
3799
3799
  }
3800
- function st() {
3801
- const e = at(kn);
3800
+ function rt() {
3801
+ const e = ot(wn);
3802
3802
  if (!e) throw new Error("useThreads must be used within a ThreadsProvider");
3803
3803
  return e;
3804
3804
  }
3805
- function vn(e) {
3805
+ function kn(e) {
3806
3806
  const t = e.artifact;
3807
3807
  return !t || typeof t != "object" ? null : "metadata" in t && t.metadata ? t.metadata : {
3808
3808
  id: t.id ?? e.id ?? `artifact-${Date.now()}`,
@@ -3813,7 +3813,7 @@ function vn(e) {
3813
3813
  };
3814
3814
  }
3815
3815
  function ss(e, t) {
3816
- const n = vn(e);
3816
+ const n = kn(e);
3817
3817
  if (!n) return e;
3818
3818
  const r = {
3819
3819
  ...n,
@@ -3830,21 +3830,21 @@ function ss(e, t) {
3830
3830
  }
3831
3831
  function os(e, t, n) {
3832
3832
  return e.find((r) => {
3833
- const s = vn(r);
3833
+ const s = kn(r);
3834
3834
  return !!((s == null ? void 0 : s.id) === t || n && r.toolCallId === n);
3835
3835
  }) ?? null;
3836
3836
  }
3837
3837
  function gt(e) {
3838
3838
  return e.map((t) => bt(t)).filter((t) => !!t);
3839
3839
  }
3840
- function it(e, t, n) {
3840
+ function at(e, t, n) {
3841
3841
  return t < 0 || t >= e.length ? e : [...e.slice(0, t), n, ...e.slice(t + 1)];
3842
3842
  }
3843
3843
  function as(e, t, n) {
3844
3844
  for (let r = e.length - 1; r >= 0; r--)
3845
3845
  if (e[r].role === "assistant") {
3846
3846
  const o = { ...e[r], checkpointId: t, checkpointNs: n ?? void 0 };
3847
- return it(e, r, o);
3847
+ return at(e, r, o);
3848
3848
  }
3849
3849
  return e;
3850
3850
  }
@@ -3915,17 +3915,17 @@ function ls(e, t) {
3915
3915
  return { ...e, messages: a };
3916
3916
  }
3917
3917
  case "event":
3918
- return Yt(e, t.payload.ev);
3918
+ return Qt(e, t.payload.ev);
3919
3919
  case "batch": {
3920
3920
  const { events: r } = t.payload;
3921
- return r.length ? r.reduce((s, o) => Yt(s, o), e) : e;
3921
+ return r.length ? r.reduce((s, o) => Qt(s, o), e) : e;
3922
3922
  }
3923
3923
  default:
3924
3924
  return e;
3925
3925
  }
3926
3926
  }
3927
3927
  function us(e = []) {
3928
- const [t, n] = Fn(ls, { ...cs, messages: e }), r = K([]), s = K(null), o = K(null), a = E(() => {
3928
+ const [t, n] = Un(ls, { ...cs, messages: e }), r = H([]), s = H(null), o = H(null), a = E(() => {
3929
3929
  s.current !== null && typeof window < "u" && window.cancelAnimationFrame(s.current), o.current !== null && clearTimeout(o.current), s.current = null, o.current = null;
3930
3930
  const c = r.current;
3931
3931
  c.length && (r.current = [], n({ type: "batch", payload: { events: c } }));
@@ -3934,10 +3934,10 @@ function us(e = []) {
3934
3934
  }, [a]), f = E((c) => {
3935
3935
  r.current.push(c), i();
3936
3936
  }, [i]);
3937
- ae(() => () => {
3937
+ se(() => () => {
3938
3938
  s.current !== null && typeof window < "u" && window.cancelAnimationFrame(s.current), o.current !== null && clearTimeout(o.current), r.current = [];
3939
3939
  }, []);
3940
- const l = fe(() => ({
3940
+ const l = de(() => ({
3941
3941
  reset: (c) => n({ type: "reset", payload: { messages: c } }),
3942
3942
  seed: (c, d) => n({ type: "seed", payload: { messages: c, ...d ?? {} } }),
3943
3943
  prepend: (c) => n({ type: "prepend", payload: { messages: c } }),
@@ -3946,7 +3946,7 @@ function us(e = []) {
3946
3946
  }), [f]);
3947
3947
  return { state: t, dispatch: n, ...l };
3948
3948
  }
3949
- function Yt(e, t) {
3949
+ function Qt(e, t) {
3950
3950
  var a;
3951
3951
  const n = t, r = n == null ? void 0 : n.origin, s = n == null ? void 0 : n.scope, o = r === "task" || typeof s == "string" && s.startsWith("tools:");
3952
3952
  if (t.type === "tool.start")
@@ -4017,7 +4017,7 @@ function fs(e, t, n) {
4017
4017
  const s = e[r], o = (s.toolCalls ?? []).map(
4018
4018
  (a) => a.id === t ? { ...a, ...n } : a
4019
4019
  );
4020
- return it(e, r, { ...s, toolCalls: o });
4020
+ return at(e, r, { ...s, toolCalls: o });
4021
4021
  }
4022
4022
  function ps(e, t) {
4023
4023
  const n = t, r = n.id || n.callId, s = n.name ?? void 0, o = n.scope ?? void 0, a = `Starting ${s ?? "tool"}...`;
@@ -4041,7 +4041,7 @@ function ps(e, t) {
4041
4041
  status: "running",
4042
4042
  content: a,
4043
4043
  scope: o
4044
- }), i = it(i, f, { ...l, toolCalls: c });
4044
+ }), i = at(i, f, { ...l, toolCalls: c });
4045
4045
  } else {
4046
4046
  const l = n.agentName ?? "assistant", c = {
4047
4047
  id: `ai-${Date.now()}`,
@@ -4073,7 +4073,7 @@ function gs(e, t) {
4073
4073
  const i = o[a], f = r ?? null, l = typeof f == "string" ? f : JSON.stringify(f), c = Me(f), d = typeof c == "string" ? c : l, g = (i.toolCalls ?? []).map(
4074
4074
  (h) => h.id === n ? { ...h, content: d, scope: s ?? h.scope } : h
4075
4075
  );
4076
- o = it(o, a, { ...i, toolCalls: g });
4076
+ o = at(o, a, { ...i, toolCalls: g });
4077
4077
  }
4078
4078
  return { ...e, messages: o };
4079
4079
  }
@@ -4155,10 +4155,10 @@ function hs(e, t) {
4155
4155
  ...t.partial_data
4156
4156
  }), {
4157
4157
  ...e,
4158
- messages: it(e.messages, o, a)
4158
+ messages: at(e.messages, o, a)
4159
4159
  };
4160
4160
  }
4161
- const Zt = 120;
4161
+ const Yt = 120;
4162
4162
  function ys(e) {
4163
4163
  if (!Array.isArray(e))
4164
4164
  return "";
@@ -4166,7 +4166,7 @@ function ys(e) {
4166
4166
  if (!t.length)
4167
4167
  return "";
4168
4168
  const n = t.join(" ").replace(/\s+/g, " ").trim();
4169
- return n ? n.length > Zt ? `${n.slice(0, Zt - 3)}…` : n : "";
4169
+ return n ? n.length > Yt ? `${n.slice(0, Yt - 3)}…` : n : "";
4170
4170
  }
4171
4171
  function bs(e) {
4172
4172
  return ys(e.content) || "";
@@ -4174,34 +4174,34 @@ function bs(e) {
4174
4174
  function ws(e) {
4175
4175
  const t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Map(), s = [];
4176
4176
  for (let l = 0; l < e.length; l++) {
4177
- const c = e[l], d = c.checkpointId, g = d ?? `cp-${l}`, h = c.metadata ?? {}, v = typeof h.step == "number" ? h.step : null, m = typeof h.source == "string" ? h.source : null;
4177
+ const c = e[l], d = c.checkpointId, g = d ?? `cp-${l}`, h = c.metadata ?? {}, k = typeof h.step == "number" ? h.step : null, m = typeof h.source == "string" ? h.source : null;
4178
4178
  let y = null, I = null;
4179
- const A = Array.isArray(c.messages) ? c.messages : [];
4180
- for (const k of A)
4181
- k.role === "user" && (I || (I = k), k.id && (y = k.id));
4182
- const x = c.next && c.next.length > 0 ? String(c.next[0]) : null, N = c.parentConfig ?? null, _ = {
4179
+ const S = Array.isArray(c.messages) ? c.messages : [];
4180
+ for (const w of S)
4181
+ w.role === "user" && (I || (I = w), w.id && (y = w.id));
4182
+ const C = c.next && c.next.length > 0 ? String(c.next[0]) : null, L = c.parentConfig ?? null, z = {
4183
4183
  id: g,
4184
- step: v,
4184
+ step: k,
4185
4185
  source: m,
4186
4186
  createdAt: c.createdAt ?? null,
4187
4187
  namespace: c.checkpointNs ?? null,
4188
4188
  parentId: c.parentId ?? null,
4189
- next: x,
4190
- parentConfig: N,
4189
+ next: C,
4190
+ parentConfig: L,
4191
4191
  userMessageId: y
4192
4192
  };
4193
- if (s.push(_), d && t.set(d, _), d && I) {
4194
- const k = bs(I);
4195
- k && r.set(d, k);
4193
+ if (s.push(z), d && t.set(d, z), d && I) {
4194
+ const w = bs(I);
4195
+ w && r.set(d, w);
4196
4196
  }
4197
4197
  n.push({
4198
4198
  id: g,
4199
4199
  messageId: y,
4200
- step: v,
4200
+ step: k,
4201
4201
  source: m,
4202
4202
  createdAt: c.createdAt ?? null,
4203
- next: x,
4204
- parentConfig: N
4203
+ next: C,
4204
+ parentConfig: L
4205
4205
  });
4206
4206
  }
4207
4207
  const o = /* @__PURE__ */ new Map();
@@ -4238,8 +4238,8 @@ function ws(e) {
4238
4238
  for (const d of t.values())
4239
4239
  d.userMessageId === l && c.push(d);
4240
4240
  return c.length ? (c.sort((d, g) => {
4241
- const h = typeof d.attemptIndex == "number" ? d.attemptIndex : Number.MAX_SAFE_INTEGER, v = typeof g.attemptIndex == "number" ? g.attemptIndex : Number.MAX_SAFE_INTEGER;
4242
- return h - v;
4241
+ const h = typeof d.attemptIndex == "number" ? d.attemptIndex : Number.MAX_SAFE_INTEGER, k = typeof g.attemptIndex == "number" ? g.attemptIndex : Number.MAX_SAFE_INTEGER;
4242
+ return h - k;
4243
4243
  }), c) : [];
4244
4244
  }
4245
4245
  };
@@ -4262,9 +4262,9 @@ function Xs(e, t, n) {
4262
4262
  };
4263
4263
  }
4264
4264
  function ks(e) {
4265
- return fe(() => ws(e), [e]);
4265
+ return de(() => ws(e), [e]);
4266
4266
  }
4267
- function Tn({
4267
+ function vn({
4268
4268
  api: e,
4269
4269
  fileApi: t,
4270
4270
  seed: n,
@@ -4277,176 +4277,198 @@ function Tn({
4277
4277
  isStreaming: l,
4278
4278
  getMessages: c
4279
4279
  }) {
4280
- const [d, g] = H(null), v = fe(
4281
- () => tt(d),
4280
+ const [d, g] = W(null), k = de(
4281
+ () => ft(d),
4282
4282
  [d]
4283
- ).checkpoints, m = ks(v), y = m.timeline, [I, A] = H(!1), [x, N] = H(!1), [_, k] = H(null), T = K(s), L = K(null), j = K(null), O = K(null), $ = K(null), C = K(null), J = K(/* @__PURE__ */ new Map()), W = K(null);
4284
- ae(() => {
4285
- T.current = s;
4283
+ ).checkpoints, m = ks(k), y = m.timeline, [I, S] = W(!1), [C, L] = W(!1), [z, w] = W(null), v = H(s), F = H(null), $ = H(null), B = H(null), D = H(null), P = H(null), J = H(/* @__PURE__ */ new Map()), G = H(null);
4284
+ se(() => {
4285
+ v.current = s;
4286
4286
  }, [s]);
4287
4287
  const Q = E(
4288
4288
  async (p) => {
4289
- var z, U;
4289
+ var x, q;
4290
4290
  if (!p.threadId) return;
4291
- const b = p.threadId;
4292
- (z = p.onStart) == null || z.call(p), p.setLoading(!0);
4291
+ const M = p.threadId;
4292
+ (x = p.onStart) == null || x.call(p), p.setLoading(!0);
4293
4293
  try {
4294
- await p.action(b);
4295
- } catch (q) {
4296
- if (!Vt(q) && T.current === b) {
4297
- const re = String(q);
4298
- (U = p.handleError) == null || U.call(p, re), r == null || r(re);
4294
+ await p.action(M);
4295
+ } catch (U) {
4296
+ if (!Dt(U) && v.current === M) {
4297
+ const ee = String(U);
4298
+ (q = p.handleError) == null || q.call(p, ee), r == null || r(ee);
4299
4299
  }
4300
- throw q;
4300
+ throw U;
4301
4301
  } finally {
4302
4302
  p.setLoading(!1);
4303
4303
  }
4304
4304
  },
4305
4305
  [r]
4306
- ), te = E(
4307
- async (p, b) => {
4308
- var re;
4306
+ ), X = E(
4307
+ async (p) => {
4308
+ const M = await e.getState({
4309
+ threadId: p.threadId,
4310
+ checkpointId: p.checkpointId,
4311
+ checkpointNs: p.checkpointNs
4312
+ }), x = p.forTimelineHistory ?? {
4313
+ version: "values@1",
4314
+ threadId: p.threadId,
4315
+ checkpoints: [M]
4316
+ }, q = t ? await Gr(x, t) : x, { latest: U } = ft(q);
4317
+ return U;
4318
+ },
4319
+ [e, t]
4320
+ ), oe = E(
4321
+ async (p, M) => {
4322
+ var ee;
4309
4323
  if (!p) return;
4310
- const z = `${p}:${b ?? "latest"}`, U = J.current.get(z);
4311
- if (U)
4312
- return U;
4313
- (re = W.current) == null || re.abort();
4314
- const q = new AbortController();
4315
- W.current = q;
4316
- const B = Q({
4324
+ const x = `${p}:${M ?? "latest"}`, q = J.current.get(x);
4325
+ if (q)
4326
+ return q;
4327
+ (ee = G.current) == null || ee.abort();
4328
+ const U = new AbortController();
4329
+ G.current = U;
4330
+ const ne = Q({
4317
4331
  threadId: p,
4318
- setLoading: A,
4319
- onStart: () => k(null),
4320
- handleError: (X) => k(X),
4321
- action: async (X) => {
4322
- const se = await e.getStateHistory({
4323
- threadId: X,
4324
- checkpointId: b ?? void 0,
4325
- signal: q.signal,
4332
+ setLoading: S,
4333
+ onStart: () => w(null),
4334
+ handleError: (Y) => w(Y),
4335
+ action: async (Y) => {
4336
+ const j = await X({
4337
+ threadId: Y,
4338
+ checkpointId: M ?? void 0
4339
+ }), re = await e.getStateHistory({
4340
+ threadId: Y,
4341
+ checkpointId: M ?? void 0,
4342
+ signal: U.signal,
4326
4343
  limit: 100,
4327
- includeMessages: !0
4328
- }), G = t ? await Et(se, t) : se;
4329
- if (T.current !== X) {
4344
+ includeMessages: !1
4345
+ });
4346
+ if (v.current !== Y) {
4330
4347
  console.log(
4331
- `[useThreadHistoryState] Thread changed during load (was ${X}, now ${T.current}), discarding stale data`
4348
+ `[useThreadHistoryState] Thread changed during load (was ${Y}, now ${v.current}), discarding stale data`
4332
4349
  );
4333
4350
  return;
4334
4351
  }
4335
- const { checkpoints: oe, latest: pe } = tt(G), ee = b ? oe.find((Fe) => Fe.checkpointId === b) ?? pe : pe;
4336
- n((ee == null ? void 0 : ee.messages) ?? [], {
4337
- checkpointId: (ee == null ? void 0 : ee.checkpointId) ?? null,
4338
- checkpointNs: (ee == null ? void 0 : ee.checkpointNs) ?? null,
4339
- pendingInterrupt: (ee == null ? void 0 : ee.interrupt) ?? null
4340
- }), g(G);
4352
+ n((j == null ? void 0 : j.messages) ?? [], {
4353
+ checkpointId: (j == null ? void 0 : j.checkpointId) ?? null,
4354
+ checkpointNs: (j == null ? void 0 : j.checkpointNs) ?? null,
4355
+ pendingInterrupt: (j == null ? void 0 : j.interrupt) ?? null,
4356
+ values: j == null ? void 0 : j.values
4357
+ }), g(re);
4341
4358
  }
4342
4359
  });
4343
- J.current.set(z, B);
4360
+ J.current.set(x, ne);
4344
4361
  try {
4345
- await B;
4362
+ await ne;
4346
4363
  } finally {
4347
- J.current.delete(z), W.current === q && (W.current = null);
4364
+ J.current.delete(x), G.current === U && (G.current = null);
4348
4365
  }
4349
- return T.current === p && (C.current = z), B;
4366
+ return v.current === p && (P.current = x), ne;
4350
4367
  },
4351
- [e, n, Q, t]
4352
- ), ne = E(
4353
- async (p, b) => {
4354
- $.current = p;
4368
+ [e, n, Q, X]
4369
+ ), A = E(
4370
+ async (p, M) => {
4371
+ D.current = p;
4355
4372
  try {
4356
- await te(p, b);
4357
- } catch (z) {
4358
- if (!Vt(z))
4359
- throw z;
4373
+ await oe(p, M);
4374
+ } catch (x) {
4375
+ if (!Dt(x))
4376
+ throw x;
4360
4377
  } finally {
4361
- $.current === p && ($.current = null);
4378
+ D.current === p && (D.current = null);
4362
4379
  }
4363
4380
  },
4364
- [te]
4365
- ), S = E((p) => {
4366
- j.current = p;
4367
- }, []), P = E((p) => {
4368
- O.current = p;
4369
- }, []), D = E(
4381
+ [oe]
4382
+ ), R = E((p) => {
4383
+ $.current = p;
4384
+ }, []), V = E((p) => {
4385
+ B.current = p;
4386
+ }, []), K = E(
4370
4387
  async (p) => {
4371
- const b = p.threadId ?? T.current;
4372
- if (!b || T.current && T.current !== b && O.current !== b)
4373
- return;
4374
- const z = t ? await Et(p, t) : p, { checkpoints: U, latest: q } = tt(z);
4375
- if (!U.length)
4388
+ const M = p == null ? void 0 : p.threadId, x = typeof M == "string" ? M : v.current;
4389
+ if (!x || v.current && v.current !== x && B.current !== x)
4376
4390
  return;
4377
- const B = q;
4378
- n((B == null ? void 0 : B.messages) ?? [], {
4379
- checkpointId: (B == null ? void 0 : B.checkpointId) ?? null,
4380
- checkpointNs: (B == null ? void 0 : B.checkpointNs) ?? null,
4381
- pendingInterrupt: (B == null ? void 0 : B.interrupt) ?? null,
4382
- values: B == null ? void 0 : B.values
4383
- }), g(z), C.current = `${b}:latest`, j.current = null, O.current === b && (O.current = null);
4391
+ const q = p, U = await X({
4392
+ threadId: x
4393
+ });
4394
+ U && (n(U.messages ?? [], {
4395
+ checkpointId: U.checkpointId ?? null,
4396
+ checkpointNs: U.checkpointNs ?? null,
4397
+ pendingInterrupt: U.interrupt ?? null,
4398
+ values: U.values
4399
+ }), g(q), P.current = `${x}:latest`, $.current = null, B.current === x && (B.current = null));
4384
4400
  },
4385
- [n, l, t]
4386
- ), V = E(
4387
- async (p, b) => {
4388
- const z = T.current;
4401
+ [n, l, X]
4402
+ ), u = E(
4403
+ async (p, M) => {
4404
+ const x = v.current;
4389
4405
  await Q({
4390
- threadId: z,
4391
- setLoading: N,
4392
- action: async (U) => {
4393
- const q = await e.getStateHistory({
4394
- threadId: U,
4406
+ threadId: x,
4407
+ setLoading: L,
4408
+ action: async (q) => {
4409
+ const U = await X({
4410
+ threadId: q,
4395
4411
  checkpointId: p,
4396
- checkpointNs: b ?? void 0,
4412
+ checkpointNs: M ?? void 0
4413
+ }), ne = await e.getStateHistory({
4414
+ threadId: q,
4415
+ checkpointId: p,
4416
+ checkpointNs: M ?? void 0,
4397
4417
  limit: 100,
4398
- includeMessages: !0
4399
- }), B = t ? await Et(q, t) : q;
4400
- if (T.current !== U)
4418
+ includeMessages: !1
4419
+ });
4420
+ if (v.current !== q)
4401
4421
  return;
4402
- const { checkpoints: re } = tt(B), X = re.find(
4403
- (se) => se.checkpointId === p && (b ? se.checkpointNs === b : !0)
4422
+ const { checkpoints: ee } = ft(ne), Y = ee.find(
4423
+ (j) => j.checkpointId === p && (M ? j.checkpointNs === M : !0)
4404
4424
  );
4405
- if (!X) {
4406
- console.warn("[useThreadHistoryState] Requested checkpoint not found:", { checkpointId: p, checkpointNs: b });
4425
+ if (!Y) {
4426
+ console.warn("[useThreadHistoryState] Requested checkpoint not found:", { checkpointId: p, checkpointNs: M });
4407
4427
  return;
4408
4428
  }
4409
- g(B), n(X.messages ?? [], {
4410
- checkpointId: X.checkpointId ?? null,
4411
- checkpointNs: X.checkpointNs ?? null
4429
+ g(ne), n((U == null ? void 0 : U.messages) ?? [], {
4430
+ checkpointId: (U == null ? void 0 : U.checkpointId) ?? Y.checkpointId ?? null,
4431
+ checkpointNs: (U == null ? void 0 : U.checkpointNs) ?? Y.checkpointNs ?? null,
4432
+ pendingInterrupt: (U == null ? void 0 : U.interrupt) ?? null,
4433
+ values: U == null ? void 0 : U.values
4412
4434
  });
4413
4435
  }
4414
4436
  }).catch(() => {
4415
4437
  });
4416
4438
  },
4417
- [e, n, Q, t]
4418
- ), u = E(
4419
- (p, b) => {
4439
+ [e, n, Q, X]
4440
+ ), N = E(
4441
+ (p, M) => {
4420
4442
  n(c(), {
4421
4443
  checkpointId: p ?? null,
4422
- checkpointNs: b ?? null
4444
+ checkpointNs: M ?? null
4423
4445
  });
4424
4446
  },
4425
4447
  [c, n]
4426
- ), R = E(async () => {
4427
- T.current && await ne(T.current);
4428
- }, [ne]);
4429
- ae(() => {
4448
+ ), _ = E(async () => {
4449
+ v.current && await A(v.current);
4450
+ }, [A]);
4451
+ se(() => {
4430
4452
  if (!f || !s || I || l)
4431
4453
  return;
4432
- if (j.current === s) {
4433
- j.current = null, L.current = s;
4454
+ if ($.current === s) {
4455
+ $.current = null, F.current = s;
4434
4456
  return;
4435
4457
  }
4436
- if (O.current === s) {
4437
- L.current = s;
4458
+ if (B.current === s) {
4459
+ F.current = s;
4438
4460
  return;
4439
4461
  }
4440
- if ($.current === s) {
4441
- $.current = null, L.current = s;
4462
+ if (D.current === s) {
4463
+ D.current = null, F.current = s;
4442
4464
  return;
4443
4465
  }
4444
- if (L.current === s)
4466
+ if (F.current === s)
4445
4467
  return;
4446
- L.current = s;
4468
+ F.current = s;
4447
4469
  let p;
4448
- const b = `${s}:latest`;
4449
- C.current !== b && ne(s, p);
4470
+ const M = `${s}:latest`;
4471
+ P.current !== M && A(s, p);
4450
4472
  }, [
4451
4473
  f,
4452
4474
  s,
@@ -4455,42 +4477,42 @@ function Tn({
4455
4477
  o,
4456
4478
  I,
4457
4479
  l,
4458
- ne
4480
+ A
4459
4481
  ]);
4460
- const M = E(() => {
4461
- g(null), A(!1), N(!1), k(null), j.current = null, O.current = null, L.current = null, C.current = null, $.current = null;
4482
+ const T = E(() => {
4483
+ g(null), S(!1), L(!1), w(null), $.current = null, B.current = null, F.current = null, P.current = null, D.current = null;
4462
4484
  }, []);
4463
4485
  return {
4464
- threadCheckpoints: v,
4486
+ threadCheckpoints: k,
4465
4487
  threadTimeline: y,
4466
4488
  checkpointIndex: m,
4467
4489
  isLoadingThread: I,
4468
- isLoadingCheckpoint: x,
4469
- threadStateError: _,
4470
- loadThread: ne,
4471
- navigateToCheckpoint: V,
4472
- setCurrentCheckpointId: u,
4473
- returnToLatest: R,
4474
- handleValuesEvent: D,
4475
- markSkipNextLoad: S,
4476
- markStreamPendingThread: P,
4477
- resetHistoryState: M,
4478
- clearState: M
4490
+ isLoadingCheckpoint: C,
4491
+ threadStateError: z,
4492
+ loadThread: A,
4493
+ navigateToCheckpoint: u,
4494
+ setCurrentCheckpointId: N,
4495
+ returnToLatest: _,
4496
+ handleValuesEvent: K,
4497
+ markSkipNextLoad: R,
4498
+ markStreamPendingThread: V,
4499
+ resetHistoryState: T,
4500
+ clearState: T
4479
4501
  };
4480
4502
  }
4481
- const An = Ge(null), Sn = Ge(null);
4482
- function xn(e) {
4483
- const t = at(An);
4503
+ const Tn = We(null), An = We(null);
4504
+ function Sn(e) {
4505
+ const t = ot(Tn);
4484
4506
  if (!t && !(e != null && e.optional)) throw new Error("useThreadState must be used within a ThreadStateProvider");
4485
4507
  return t;
4486
4508
  }
4487
- function vs() {
4488
- const e = at(Sn);
4509
+ function Is() {
4510
+ const e = ot(An);
4489
4511
  if (!e)
4490
4512
  throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");
4491
4513
  return e;
4492
4514
  }
4493
- function Is({
4515
+ function vs({
4494
4516
  children: e,
4495
4517
  initialThreadId: t = null,
4496
4518
  initialCheckpointId: n = null,
@@ -4499,22 +4521,22 @@ function Is({
4499
4521
  isStreaming: o,
4500
4522
  onError: a
4501
4523
  }) {
4502
- const { chatApi: i, fileApi: f } = We(), { currentThreadId: l } = st(), { state: c, seed: d, onEvent: g, dispatch: h } = us(), {
4503
- threadCheckpoints: v,
4524
+ const { chatApi: i, fileApi: f } = qe(), { currentThreadId: l } = rt(), { state: c, seed: d, onEvent: g, dispatch: h } = us(), {
4525
+ threadCheckpoints: k,
4504
4526
  threadTimeline: m,
4505
4527
  checkpointIndex: y,
4506
4528
  isLoadingThread: I,
4507
- isLoadingCheckpoint: A,
4508
- threadStateError: x,
4509
- loadThread: N,
4510
- navigateToCheckpoint: _,
4511
- setCurrentCheckpointId: k,
4512
- returnToLatest: T,
4513
- handleValuesEvent: L,
4514
- markSkipNextLoad: j,
4515
- markStreamPendingThread: O,
4516
- resetHistoryState: $
4517
- } = Tn({
4529
+ isLoadingCheckpoint: S,
4530
+ threadStateError: C,
4531
+ loadThread: L,
4532
+ navigateToCheckpoint: z,
4533
+ setCurrentCheckpointId: w,
4534
+ returnToLatest: v,
4535
+ handleValuesEvent: F,
4536
+ markSkipNextLoad: $,
4537
+ markStreamPendingThread: B,
4538
+ resetHistoryState: D
4539
+ } = vn({
4518
4540
  api: i,
4519
4541
  fileApi: f,
4520
4542
  seed: d,
@@ -4527,34 +4549,34 @@ function Is({
4527
4549
  isStreaming: o,
4528
4550
  getMessages: E(() => c.messages, [c.messages])
4529
4551
  });
4530
- ae(() => {
4531
- l || (d([], {}), $());
4532
- }, [l, d, $]);
4533
- const C = K(null), J = E(
4552
+ se(() => {
4553
+ l || (d([], {}), D());
4554
+ }, [l, d, D]);
4555
+ const P = H(null), J = E(
4534
4556
  (u) => {
4535
- C.current = u;
4557
+ P.current = u;
4536
4558
  },
4537
4559
  []
4538
- ), W = K(null), Q = E(
4560
+ ), G = H(null), Q = E(
4539
4561
  (u) => {
4540
- W.current = u;
4562
+ G.current = u;
4541
4563
  },
4542
4564
  []
4543
- ), te = fe(() => ({ assemblingMessageId: c.assemblingId ?? null }), [c.assemblingId]), ne = E(
4544
- (u, R) => {
4545
- const M = wn(u, "user");
4565
+ ), X = de(() => ({ assemblingMessageId: c.assemblingId ?? null }), [c.assemblingId]), oe = E(
4566
+ (u, N) => {
4567
+ const _ = bn(u, "user");
4546
4568
  return h({
4547
4569
  type: "user_message",
4548
4570
  payload: {
4549
- message: M,
4550
- editingMessageId: R == null ? void 0 : R.editingMessageId
4571
+ message: _,
4572
+ editingMessageId: N == null ? void 0 : N.editingMessageId
4551
4573
  }
4552
- }), M;
4574
+ }), _;
4553
4575
  },
4554
4576
  [h]
4555
- ), S = E(async () => {
4556
- C.current ? await C.current() : (d([], {}), $());
4557
- }, [d, $]), P = fe(() => Sr(c.messages), [c.messages]), D = fe(
4577
+ ), A = E(async () => {
4578
+ P.current ? await P.current() : (d([], {}), D());
4579
+ }, [d, D]), R = de(() => Ar(c.messages), [c.messages]), V = de(
4558
4580
  () => ({
4559
4581
  threadId: l,
4560
4582
  messages: c.messages,
@@ -4564,14 +4586,14 @@ function Is({
4564
4586
  id: c.lastCheckpointId ?? null,
4565
4587
  namespace: c.lastCheckpointNs ?? null
4566
4588
  },
4567
- checkpoints: v,
4589
+ checkpoints: k,
4568
4590
  checkpointIndex: y,
4569
4591
  timelineCheckpoints: m,
4570
- metadata: te,
4592
+ metadata: X,
4571
4593
  values: c.values ?? {},
4572
4594
  isLoading: I,
4573
- isLoadingCheckpoint: A,
4574
- error: x,
4595
+ isLoadingCheckpoint: S,
4596
+ error: C,
4575
4597
  loadOlder: async () => {
4576
4598
  },
4577
4599
  // Placeholder
@@ -4583,25 +4605,25 @@ function Is({
4583
4605
  values: u.values
4584
4606
  });
4585
4607
  },
4586
- clearState: S,
4587
- navigateToCheckpoint: _,
4588
- setCurrentCheckpointId: k,
4589
- returnToLatest: T,
4590
- loadThread: async (u, R, M) => {
4591
- await N(u, R, { clearProgress: !1 });
4608
+ clearState: A,
4609
+ navigateToCheckpoint: z,
4610
+ setCurrentCheckpointId: w,
4611
+ returnToLatest: v,
4612
+ loadThread: async (u, N, _) => {
4613
+ await L(u, N, { clearProgress: !1 });
4592
4614
  },
4593
- clearThread: S,
4594
- respondToInterrupt: async (u, R, M) => {
4595
- W.current && await W.current(u, R, M);
4615
+ clearThread: A,
4616
+ respondToInterrupt: async (u, N, _) => {
4617
+ G.current && await G.current(u, N, _);
4596
4618
  },
4597
4619
  messagePreviews: y.messagePreviews,
4598
- handleValuesEvent: L,
4599
- markSkipNextLoad: j,
4600
- markStreamPendingThread: O,
4601
- resetHistoryState: $,
4602
- pushUser: ne,
4620
+ handleValuesEvent: F,
4621
+ markSkipNextLoad: $,
4622
+ markStreamPendingThread: B,
4623
+ resetHistoryState: D,
4624
+ pushUser: oe,
4603
4625
  onEvent: g,
4604
- artifacts: P
4626
+ artifacts: R
4605
4627
  }),
4606
4628
  [
4607
4629
  l,
@@ -4611,36 +4633,36 @@ function Is({
4611
4633
  c.lastCheckpointId,
4612
4634
  c.lastCheckpointNs,
4613
4635
  c.values,
4614
- v,
4636
+ k,
4615
4637
  m,
4616
4638
  y,
4617
- te,
4639
+ X,
4618
4640
  I,
4619
- A,
4620
- x,
4621
- d,
4622
4641
  S,
4623
- _,
4624
- k,
4625
- T,
4626
- N,
4642
+ C,
4643
+ d,
4644
+ A,
4645
+ z,
4646
+ w,
4647
+ v,
4627
4648
  L,
4628
- j,
4629
- O,
4630
- ne,
4649
+ F,
4650
+ $,
4651
+ B,
4652
+ oe,
4631
4653
  g,
4632
- P
4654
+ R
4633
4655
  ]
4634
- ), V = fe(
4656
+ ), K = de(
4635
4657
  () => ({
4636
4658
  registerClearThread: J,
4637
4659
  registerRespondToInterrupt: Q
4638
4660
  }),
4639
4661
  [J, Q]
4640
4662
  );
4641
- return /* @__PURE__ */ Ce(Sn.Provider, { value: V, children: /* @__PURE__ */ Ce(An.Provider, { value: D, children: e }) });
4663
+ return /* @__PURE__ */ Ce(An.Provider, { value: K, children: /* @__PURE__ */ Ce(Tn.Provider, { value: V, children: e }) });
4642
4664
  }
4643
- const Cn = Ge(null), Ts = Ge(!1);
4665
+ const xn = We(null), Ts = We(!1);
4644
4666
  function As({
4645
4667
  children: e,
4646
4668
  onError: t,
@@ -4653,26 +4675,26 @@ function As({
4653
4675
  onFinish: f,
4654
4676
  onStreamingChange: l
4655
4677
  }) {
4656
- const { chatApi: c, baseUrl: d } = We(), g = d, h = _e(t), v = _e(n), m = _e(r), y = _e(s), I = _e(o), A = _e(a), x = _e(i), N = _e(f), _ = _e(l), k = fe(
4678
+ const { chatApi: c, baseUrl: d } = qe(), g = d, h = _e(t), k = _e(n), m = _e(r), y = _e(s), I = _e(o), S = _e(a), C = _e(i), L = _e(f), z = _e(l), w = de(
4657
4679
  () => ({
4658
4680
  onError: h,
4659
- onAuthError: v,
4681
+ onAuthError: k,
4660
4682
  onConnectionError: m,
4661
- onMetadataEvent: x,
4662
- onCustomEvent: A,
4683
+ onMetadataEvent: C,
4684
+ onCustomEvent: S,
4663
4685
  onUpdateEvent: I,
4664
4686
  onToolEnd: y,
4665
- onFinish: N
4687
+ onFinish: L
4666
4688
  }),
4667
4689
  [
4668
4690
  h,
4669
- v,
4691
+ k,
4670
4692
  m,
4671
- x,
4672
- A,
4693
+ C,
4694
+ S,
4673
4695
  I,
4674
4696
  y,
4675
- N
4697
+ L
4676
4698
  ]
4677
4699
  );
4678
4700
  return /* @__PURE__ */ Ce(Ts.Provider, { value: !0, children: /* @__PURE__ */ Ce(
@@ -4680,8 +4702,8 @@ function As({
4680
4702
  {
4681
4703
  api: c,
4682
4704
  streamBaseUrl: g,
4683
- handlers: k,
4684
- onStreamingChange: _,
4705
+ handlers: w,
4706
+ onStreamingChange: z,
4685
4707
  children: e
4686
4708
  }
4687
4709
  ) });
@@ -4693,160 +4715,160 @@ function Ss({
4693
4715
  handlers: r,
4694
4716
  onStreamingChange: s
4695
4717
  }) {
4696
- const { setCurrentThreadId: o, currentThreadIdRef: a, addThreadFromEvent: i, currentThreadId: f } = st(), {
4718
+ const { setCurrentThreadId: o, currentThreadIdRef: a, addThreadFromEvent: i, currentThreadId: f } = rt(), {
4697
4719
  interrupt: l,
4698
4720
  checkpoint: c,
4699
4721
  timelineCheckpoints: d,
4700
4722
  handleValuesEvent: g,
4701
4723
  markSkipNextLoad: h,
4702
- markStreamPendingThread: v,
4724
+ markStreamPendingThread: k,
4703
4725
  resetHistoryState: m,
4704
4726
  pushUser: y,
4705
4727
  onEvent: I,
4706
- messages: A
4707
- } = xn(), { registerClearThread: x, registerRespondToInterrupt: N } = vs(), _ = E(
4728
+ messages: S
4729
+ } = Sn(), { registerClearThread: C, registerRespondToInterrupt: L } = Is(), z = E(
4708
4730
  (u) => {
4709
- i(u), v(u.threadId), a.current !== u.threadId && ((u.created ?? !a.current) && h(u.threadId), o(u.threadId));
4731
+ i(u), k(u.threadId), a.current !== u.threadId && ((u.created ?? !a.current) && h(u.threadId), o(u.threadId));
4710
4732
  },
4711
- [i, h, v, o, a]
4712
- ), k = Zr({
4733
+ [i, h, k, o, a]
4734
+ ), w = Zr({
4713
4735
  baseUrl: n,
4714
4736
  onEvent: I,
4715
4737
  onError: (u) => {
4716
- var R;
4717
- (R = r.onError) == null || R.call(r, (u == null ? void 0 : u.message) ?? String(u));
4738
+ var N;
4739
+ (N = r.onError) == null || N.call(r, (u == null ? void 0 : u.message) ?? String(u));
4718
4740
  },
4719
4741
  onAuthError: r.onAuthError,
4720
4742
  onConnectionError: r.onConnectionError,
4721
4743
  onFinish: r.onFinish,
4722
- onThreadInfo: _,
4744
+ onThreadInfo: z,
4723
4745
  onMetadataEvent: r.onMetadataEvent,
4724
4746
  onCustomEvent: r.onCustomEvent,
4725
4747
  onUpdateEvent: r.onUpdateEvent,
4726
4748
  onToolEnd: r.onToolEnd,
4727
4749
  handleValuesEvent: g
4728
4750
  });
4729
- ae(() => {
4730
- s == null || s(k.isStreaming);
4731
- }, [k.isStreaming, s]);
4732
- const { stream: T, stop: L, clear: j, isStreaming: O, error: $, connected: C, streamedMessages: J, activeMessageId: W } = k;
4733
- ae(() => {
4734
- f !== void 0 && j();
4735
- }, [f, j]);
4751
+ se(() => {
4752
+ s == null || s(w.isStreaming);
4753
+ }, [w.isStreaming, s]);
4754
+ const { stream: v, stop: F, clear: $, isStreaming: B, error: D, connected: P, streamedMessages: J, activeMessageId: G } = w;
4755
+ se(() => {
4756
+ f !== void 0 && $();
4757
+ }, [f, $]);
4736
4758
  const Q = E(
4737
- async (u, R) => {
4738
- await T(u, R);
4759
+ async (u, N) => {
4760
+ await v(u, N);
4739
4761
  },
4740
- [T]
4741
- ), te = K(c);
4742
- ae(() => {
4743
- te.current = c;
4762
+ [v]
4763
+ ), X = H(c);
4764
+ se(() => {
4765
+ X.current = c;
4744
4766
  }, [c]);
4745
- const ne = E(
4746
- async (u, R, M) => {
4747
- const p = a.current;
4748
- if (!p)
4767
+ const oe = E(
4768
+ async (u, N, _) => {
4769
+ const T = a.current;
4770
+ if (!T)
4749
4771
  throw new Error("No active thread to handle interrupt");
4750
- const b = u ? R ?? !0 : !1, z = te.current, U = (M == null ? void 0 : M.checkpointId) ?? z.id ?? void 0, q = (M == null ? void 0 : M.checkpointNs) ?? z.namespace ?? void 0, B = {
4751
- threadId: p,
4752
- checkpointId: U,
4772
+ const p = u ? N ?? !0 : !1, M = X.current, x = (_ == null ? void 0 : _.checkpointId) ?? M.id ?? void 0, q = (_ == null ? void 0 : _.checkpointNs) ?? M.namespace ?? void 0, U = {
4773
+ threadId: T,
4774
+ checkpointId: x,
4753
4775
  checkpointNs: q,
4754
- command: { kind: "resume", value: b },
4755
- payload: M == null ? void 0 : M.payload
4776
+ command: { kind: "resume", value: p },
4777
+ payload: _ == null ? void 0 : _.payload
4756
4778
  };
4757
- Q(B);
4779
+ Q(U);
4758
4780
  },
4759
4781
  [a, Q]
4760
4782
  );
4761
- ae(() => {
4762
- N(ne);
4763
- }, [ne, N]);
4764
- const S = E(async () => {
4765
- L(), j(), m(), o(null);
4766
- }, [j, m, o, L]);
4767
- ae(() => {
4768
- x(S);
4769
- }, [S, x]);
4770
- const P = E(
4771
- async (u, R) => {
4772
- O && L();
4773
- let M = a.current;
4774
- const p = (u == null ? void 0 : u.text) ?? "", b = (u == null ? void 0 : u.attachments) ?? [], z = (p == null ? void 0 : p.trim()) ?? "", U = { ...(u == null ? void 0 : u.payload) ?? {} }, q = Array.isArray(U.messages) ? U.messages : void 0;
4775
- q && delete U.messages;
4776
- const B = !!(q && q.length), re = !!(u.contentParts && u.contentParts.length > 0);
4777
- if (!M && !z && b.length === 0 && !B && !re) return;
4778
- if (!M) {
4779
- const Ae = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0"), Ke = Array.from({ length: 4 }, () => Math.floor(Math.random() * 4294967295).toString(16).padStart(8, "0")).join("").slice(0, 16);
4780
- M = `${Ae}${Ke}`, h(M), o(M);
4783
+ se(() => {
4784
+ L(oe);
4785
+ }, [oe, L]);
4786
+ const A = E(async () => {
4787
+ F(), $(), m(), o(null);
4788
+ }, [$, m, o, F]);
4789
+ se(() => {
4790
+ C(A);
4791
+ }, [A, C]);
4792
+ const R = E(
4793
+ async (u, N) => {
4794
+ B && F();
4795
+ let _ = a.current;
4796
+ const T = (u == null ? void 0 : u.text) ?? "", p = (u == null ? void 0 : u.attachments) ?? [], M = (T == null ? void 0 : T.trim()) ?? "", x = { ...(u == null ? void 0 : u.payload) ?? {} }, q = Array.isArray(x.messages) ? x.messages : void 0;
4797
+ q && delete x.messages;
4798
+ const U = !!(q && q.length), ne = !!(u.contentParts && u.contentParts.length > 0);
4799
+ if (!_ && !M && p.length === 0 && !U && !ne) return;
4800
+ if (!_) {
4801
+ const Ae = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0"), Ve = Array.from({ length: 4 }, () => Math.floor(Math.random() * 4294967295).toString(16).padStart(8, "0")).join("").slice(0, 16);
4802
+ _ = `${Ae}${Ve}`, h(_), o(_);
4781
4803
  }
4782
- let X = null;
4783
- u.contentParts && u.contentParts.length > 0 && (X = u.contentParts);
4784
- const { contentParts: se, filesInfo: G } = X ? { contentParts: X, filesInfo: [] } : await Kr(b), oe = [...se];
4785
- z && oe.push({ type: "text", text: p });
4786
- const pe = u == null ? void 0 : u.originalMessageId, ee = !!(u != null && u.edit && pe), Fe = !B && oe.length > 0;
4787
- let ge = null;
4788
- if (Fe) {
4789
- const Ae = ee ? pe : `msg-${Date.now()}`;
4790
- ge = wn({
4804
+ let ee = null;
4805
+ u.contentParts && u.contentParts.length > 0 && (ee = u.contentParts);
4806
+ const { contentParts: Y, filesInfo: j } = ee ? { contentParts: ee, filesInfo: [] } : await Vr(p), re = [...Y];
4807
+ M && re.push({ type: "text", text: T });
4808
+ const be = u == null ? void 0 : u.originalMessageId, ve = !!(u != null && u.edit && be), Je = !U && re.length > 0;
4809
+ let fe = null;
4810
+ if (Je) {
4811
+ const Ae = ve ? be : `msg-${Date.now()}`;
4812
+ fe = bn({
4791
4813
  id: Ae,
4792
4814
  role: "user",
4793
- content: oe,
4815
+ content: re,
4794
4816
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
4795
- }, "user"), ee ? y(ge, { editingMessageId: pe }) : y(ge);
4817
+ }, "user"), ve ? y(fe, { editingMessageId: be }) : y(fe);
4796
4818
  }
4797
- const je = B ? q : ge ? [ge] : [], Oe = {
4798
- ...U,
4799
- ...G.length ? { files_info: G } : {}
4819
+ const Fe = U ? q : fe ? [fe] : [], je = {
4820
+ ...x,
4821
+ ...j.length ? { files_info: j } : {}
4800
4822
  };
4801
- je.length ? Oe.messages = je : "messages" in Oe || (Oe.messages = []);
4823
+ Fe.length ? je.messages = Fe : "messages" in je || (je.messages = []);
4802
4824
  const Xe = (u == null ? void 0 : u.checkpointId) ?? c.id ?? void 0;
4803
4825
  if (u != null && u.edit && !Xe)
4804
4826
  throw new Error(
4805
- `[streaming] Missing checkpointId for edit submit. threadId=${M ?? "null"}`
4827
+ `[streaming] Missing checkpointId for edit submit. threadId=${_ ?? "null"}`
4806
4828
  );
4807
4829
  const Te = {
4808
- threadId: M,
4830
+ threadId: _,
4809
4831
  content: u == null ? void 0 : u.text,
4810
- payload: Oe,
4832
+ payload: je,
4811
4833
  config: u == null ? void 0 : u.config,
4812
4834
  checkpointId: Xe,
4813
4835
  command: u == null ? void 0 : u.command,
4814
4836
  edit: u == null ? void 0 : u.edit
4815
4837
  };
4816
- return Q(Te, R);
4838
+ return Q(Te, N);
4817
4839
  },
4818
- [c, a, O, h, y, Q, L, d]
4819
- ), D = fe(() => {
4840
+ [c, a, B, h, y, Q, F, d]
4841
+ ), V = de(() => {
4820
4842
  const u = Object.keys(J).length > 0;
4821
- if (!O && !u)
4822
- return A;
4823
- const R = /* @__PURE__ */ new Map();
4824
- return A.forEach((M) => R.set(M.id, M)), Object.values(J).forEach((M) => {
4825
- R.set(M.id, M);
4826
- }), Array.from(R.values());
4827
- }, [O, J, A]), V = fe(
4843
+ if (!B && !u)
4844
+ return S;
4845
+ const N = /* @__PURE__ */ new Map();
4846
+ return S.forEach((_) => N.set(_.id, _)), Object.values(J).forEach((_) => {
4847
+ N.set(_.id, _);
4848
+ }), Array.from(N.values());
4849
+ }, [B, J, S]), K = de(
4828
4850
  () => ({
4829
- isStreaming: O,
4830
- error: $,
4831
- connectionState: $ ? "error" : O ? C ? "connected" : "connecting" : "idle",
4832
- messages: D,
4833
- activeMessageId: W,
4834
- submit: P,
4835
- stop: L,
4851
+ isStreaming: B,
4852
+ error: D,
4853
+ connectionState: D ? "error" : B ? P ? "connected" : "connecting" : "idle",
4854
+ messages: V,
4855
+ activeMessageId: G,
4856
+ submit: R,
4857
+ stop: F,
4836
4858
  interrupt: l,
4837
4859
  resume: () => Promise.resolve(),
4838
- goto: (u, R) => Promise.resolve(),
4860
+ goto: (u, N) => Promise.resolve(),
4839
4861
  clearError: () => {
4840
4862
  }
4841
4863
  // TODO: Implement error clearing
4842
4864
  }),
4843
- [O, $, P, L, l, C, D]
4865
+ [B, D, R, F, l, P, V]
4844
4866
  );
4845
- return /* @__PURE__ */ Ce(Cn.Provider, { value: V, children: e });
4867
+ return /* @__PURE__ */ Ce(xn.Provider, { value: K, children: e });
4846
4868
  }
4847
4869
  function _e(e) {
4848
- const t = K(e);
4849
- return ae(() => {
4870
+ const t = H(e);
4871
+ return se(() => {
4850
4872
  t.current = e;
4851
4873
  }, [e]), E((...n) => {
4852
4874
  const r = t.current;
@@ -4855,16 +4877,16 @@ function _e(e) {
4855
4877
  }, []);
4856
4878
  }
4857
4879
  function xs() {
4858
- const e = at(Cn);
4880
+ const e = ot(xn);
4859
4881
  if (!e) throw new Error("useStream must be used within StreamingProvider");
4860
4882
  return e;
4861
4883
  }
4862
- function en(e) {
4884
+ function Zt(e) {
4863
4885
  return typeof e == "object" && e !== null;
4864
4886
  }
4865
4887
  function Cs(e, t) {
4866
4888
  if (Object.is(e, t)) return !0;
4867
- if (!en(e) || !en(t)) return !1;
4889
+ if (!Zt(e) || !Zt(t)) return !1;
4868
4890
  const n = Object.keys(e), r = Object.keys(t);
4869
4891
  if (n.length !== r.length)
4870
4892
  return !1;
@@ -4874,7 +4896,7 @@ function Cs(e, t) {
4874
4896
  return !0;
4875
4897
  }
4876
4898
  function Ms(e) {
4877
- const t = K(e), n = K(e);
4899
+ const t = H(e), n = H(e);
4878
4900
  return Cs(t.current, e) || (t.current = e, n.current = e), n.current;
4879
4901
  }
4880
4902
  function Es(e) {
@@ -4903,49 +4925,49 @@ function Ys({
4903
4925
  onUpdateEvent: d,
4904
4926
  onCustomEvent: g,
4905
4927
  onMetadataEvent: h,
4906
- onFinish: v
4928
+ onFinish: k
4907
4929
  }) {
4908
- const m = Ms(t), [y, I] = H(!1), A = Le(i), x = Le(f), N = Le(a), _ = Le(l), k = Le(c), T = Le(d), L = Le(g), j = Le(h), O = Le(v), $ = fe(
4930
+ const m = Ms(t), [y, I] = W(!1), S = Le(i), C = Le(f), L = Le(a), z = Le(l), w = Le(c), v = Le(d), F = Le(g), $ = Le(h), B = Le(k), D = de(
4909
4931
  () => ({
4910
- onError: A,
4911
- onAuthError: x,
4912
- onConnectionError: N,
4913
- onToolEnd: k,
4914
- onUpdateEvent: T,
4915
- onCustomEvent: L,
4916
- onMetadataEvent: j,
4917
- onFinish: O
4932
+ onError: S,
4933
+ onAuthError: C,
4934
+ onConnectionError: L,
4935
+ onToolEnd: w,
4936
+ onUpdateEvent: v,
4937
+ onCustomEvent: F,
4938
+ onMetadataEvent: $,
4939
+ onFinish: B
4918
4940
  }),
4919
4941
  [
4920
- A,
4921
- x,
4922
- N,
4923
- k,
4924
- T,
4942
+ S,
4943
+ C,
4925
4944
  L,
4926
- j,
4927
- O
4945
+ w,
4946
+ v,
4947
+ F,
4948
+ $,
4949
+ B
4928
4950
  ]
4929
4951
  );
4930
- return /* @__PURE__ */ Ce(Dr, { apiConfig: m, children: /* @__PURE__ */ Ce(
4952
+ return /* @__PURE__ */ Ce(Br, { apiConfig: m, children: /* @__PURE__ */ Ce(
4931
4953
  rs,
4932
4954
  {
4933
4955
  initialThreadId: n,
4934
- onError: A,
4935
- onThreadChange: _,
4956
+ onError: S,
4957
+ onThreadChange: z,
4936
4958
  children: /* @__PURE__ */ Ce(
4937
- Is,
4959
+ vs,
4938
4960
  {
4939
4961
  initialThreadId: n,
4940
4962
  initialCheckpointId: r,
4941
4963
  initialCheckpointNs: s,
4942
4964
  autoLoadInitial: o,
4943
- onError: A,
4965
+ onError: S,
4944
4966
  isStreaming: y,
4945
4967
  children: /* @__PURE__ */ Ce(
4946
4968
  As,
4947
4969
  {
4948
- ...$,
4970
+ ...D,
4949
4971
  onStreamingChange: I,
4950
4972
  children: e
4951
4973
  }
@@ -4956,7 +4978,7 @@ function Ys({
4956
4978
  ) });
4957
4979
  }
4958
4980
  function Le(e) {
4959
- const t = K(e);
4981
+ const t = H(e);
4960
4982
  return t.current = e, E((...n) => {
4961
4983
  const r = t.current;
4962
4984
  if (r)
@@ -4964,20 +4986,20 @@ function Le(e) {
4964
4986
  }, []);
4965
4987
  }
4966
4988
  const Ps = 1, Rs = 1e6;
4967
- let Pt = 0;
4989
+ let Et = 0;
4968
4990
  function Ns() {
4969
- return Pt = (Pt + 1) % Number.MAX_SAFE_INTEGER, Pt.toString();
4991
+ return Et = (Et + 1) % Number.MAX_SAFE_INTEGER, Et.toString();
4970
4992
  }
4971
- const Rt = /* @__PURE__ */ new Map(), tn = (e) => {
4972
- if (Rt.has(e))
4993
+ const Pt = /* @__PURE__ */ new Map(), en = (e) => {
4994
+ if (Pt.has(e))
4973
4995
  return;
4974
4996
  const t = setTimeout(() => {
4975
- Rt.delete(e), ot({
4997
+ Pt.delete(e), st({
4976
4998
  type: "REMOVE_TOAST",
4977
4999
  toastId: e
4978
5000
  });
4979
5001
  }, Rs);
4980
- Rt.set(e, t);
5002
+ Pt.set(e, t);
4981
5003
  }, _s = (e, t) => {
4982
5004
  switch (t.type) {
4983
5005
  case "ADD_TOAST":
@@ -4994,8 +5016,8 @@ const Rt = /* @__PURE__ */ new Map(), tn = (e) => {
4994
5016
  };
4995
5017
  case "DISMISS_TOAST": {
4996
5018
  const { toastId: n } = t;
4997
- return n ? tn(n) : e.toasts.forEach((r) => {
4998
- tn(r.id);
5019
+ return n ? en(n) : e.toasts.forEach((r) => {
5020
+ en(r.id);
4999
5021
  }), {
5000
5022
  ...e,
5001
5023
  toasts: e.toasts.map(
@@ -5017,17 +5039,17 @@ const Rt = /* @__PURE__ */ new Map(), tn = (e) => {
5017
5039
  }
5018
5040
  }, mt = [];
5019
5041
  let ht = { toasts: [] };
5020
- function ot(e) {
5042
+ function st(e) {
5021
5043
  ht = _s(ht, e), mt.forEach((t) => {
5022
5044
  t(ht);
5023
5045
  });
5024
5046
  }
5025
5047
  function Ls({ ...e }) {
5026
- const t = Ns(), n = (s) => ot({
5048
+ const t = Ns(), n = (s) => st({
5027
5049
  type: "UPDATE_TOAST",
5028
5050
  toast: { ...s, id: t }
5029
- }), r = () => ot({ type: "DISMISS_TOAST", toastId: t });
5030
- return ot({
5051
+ }), r = () => st({ type: "DISMISS_TOAST", toastId: t });
5052
+ return st({
5031
5053
  type: "ADD_TOAST",
5032
5054
  toast: {
5033
5055
  ...e,
@@ -5044,76 +5066,76 @@ function Ls({ ...e }) {
5044
5066
  };
5045
5067
  }
5046
5068
  function zs() {
5047
- const [e, t] = Dt.useState(ht);
5048
- return Dt.useEffect(() => (mt.push(t), () => {
5069
+ const [e, t] = Bt.useState(ht);
5070
+ return Bt.useEffect(() => (mt.push(t), () => {
5049
5071
  const n = mt.indexOf(t);
5050
5072
  n > -1 && mt.splice(n, 1);
5051
5073
  }), [e]), {
5052
5074
  ...e,
5053
5075
  toast: Ls,
5054
- dismiss: (n) => ot({ type: "DISMISS_TOAST", toastId: n })
5076
+ dismiss: (n) => st({ type: "DISMISS_TOAST", toastId: n })
5055
5077
  };
5056
5078
  }
5057
5079
  function Zs(e) {
5058
- const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = We(), { toast: s } = zs(), [o, a] = H({}), [i, f] = H(null), [l, c] = H(!1), d = E(() => {
5080
+ const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = qe(), { toast: s } = zs(), [o, a] = W({}), [i, f] = W(null), [l, c] = W(!1), d = E(() => {
5059
5081
  c(!1), f(null);
5060
- }, []), g = E((v) => {
5061
- f(v), c(!0);
5082
+ }, []), g = E((k) => {
5083
+ f(k), c(!0);
5062
5084
  }, []), h = E(
5063
- async (v, m, y) => {
5064
- var I, A;
5085
+ async (k, m, y) => {
5086
+ var I, S;
5065
5087
  if (!t) {
5066
- v.preventDefault();
5088
+ k.preventDefault();
5067
5089
  return;
5068
5090
  }
5069
5091
  if (o[y]) {
5070
- v.preventDefault();
5092
+ k.preventDefault();
5071
5093
  return;
5072
5094
  }
5073
5095
  try {
5074
- const x = String(m.url ?? ""), N = x.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);
5075
- if (N) {
5076
- v.preventDefault();
5077
- const _ = N[1], k = m.name || `file_${_}`, T = m.mimeType || "application/octet-stream";
5078
- g({ id: _, name: k, mimeType: T });
5096
+ const C = String(m.url ?? ""), L = C.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);
5097
+ if (L) {
5098
+ k.preventDefault();
5099
+ const z = L[1], w = m.name || `file_${z}`, v = m.mimeType || "application/octet-stream";
5100
+ g({ id: z, name: w, mimeType: v });
5079
5101
  return;
5080
5102
  }
5081
- if (x.startsWith("data:")) {
5082
- v.preventDefault(), a((k) => ({ ...k, [y]: !0 }));
5083
- const _ = s({ title: "Fetching file...", description: "", open: !0 });
5103
+ if (C.startsWith("data:")) {
5104
+ k.preventDefault(), a((w) => ({ ...w, [y]: !0 }));
5105
+ const z = s({ title: "Fetching file...", description: "", open: !0 });
5084
5106
  try {
5085
- const k = await r.listFiles(n ?? void 0);
5086
- if (!k || !Array.isArray(k))
5107
+ const w = await r.listFiles(n ?? void 0);
5108
+ if (!w || !Array.isArray(w))
5087
5109
  throw new Error("Invalid file list response");
5088
- const T = k.find((L) => !L || typeof L != "object" || !((L.filename ?? "") === (m.name ?? "")) ? !1 : typeof m.size == "number" && typeof L.size == "number" ? L.size === m.size : !0);
5089
- if (!(T != null && T.id))
5110
+ const v = w.find((F) => !F || typeof F != "object" || !((F.filename ?? "") === (m.name ?? "")) ? !1 : typeof m.size == "number" && typeof F.size == "number" ? F.size === m.size : !0);
5111
+ if (!(v != null && v.id))
5090
5112
  throw new Error(`File "${m.name}" is not yet available on the server`);
5091
- if (!T.id || !T.filename)
5113
+ if (!v.id || !v.filename)
5092
5114
  throw new Error("Invalid file data received from server");
5093
5115
  g({
5094
- id: T.id,
5095
- name: m.name || T.filename || `file_${T.id}`,
5096
- mimeType: m.mimeType || T.mime_type || "application/octet-stream"
5097
- }), (I = _.update) == null || I.call(_, {
5098
- id: _.id,
5116
+ id: v.id,
5117
+ name: m.name || v.filename || `file_${v.id}`,
5118
+ mimeType: m.mimeType || v.mime_type || "application/octet-stream"
5119
+ }), (I = z.update) == null || I.call(z, {
5120
+ id: z.id,
5099
5121
  title: "Success",
5100
5122
  description: `Opened ${m.name}`,
5101
5123
  open: !0
5102
5124
  });
5103
- } catch (k) {
5104
- console.error("Failed to fetch server file:", k);
5105
- const T = k instanceof Error ? k.message : "Unknown error occurred";
5106
- (A = _.update) == null || A.call(_, { id: _.id, title: "Failed", description: T }), s({
5125
+ } catch (w) {
5126
+ console.error("Failed to fetch server file:", w);
5127
+ const v = w instanceof Error ? w.message : "Unknown error occurred";
5128
+ (S = z.update) == null || S.call(z, { id: z.id, title: "Failed", description: v }), s({
5107
5129
  title: "Failed to fetch file",
5108
- description: T,
5130
+ description: v,
5109
5131
  open: !0
5110
5132
  });
5111
5133
  } finally {
5112
- a((k) => ({ ...k, [y]: !1 }));
5134
+ a((w) => ({ ...w, [y]: !1 }));
5113
5135
  }
5114
5136
  }
5115
- } catch (x) {
5116
- console.error("File click error:", x), a((N) => ({ ...N, [y]: !1 }));
5137
+ } catch (C) {
5138
+ console.error("File click error:", C), a((L) => ({ ...L, [y]: !1 }));
5117
5139
  }
5118
5140
  },
5119
5141
  [t, o, s, n, g]
@@ -5127,32 +5149,32 @@ function Zs(e) {
5127
5149
  };
5128
5150
  }
5129
5151
  function eo(e) {
5130
- return fe(() => {
5152
+ return de(() => {
5131
5153
  const t = e;
5132
5154
  let n = Array.isArray(t.content) ? t.content : [];
5133
5155
  return typeof t.content == "string" && (n = [{ type: "text", text: t.content }]), {
5134
5156
  contentParts: n,
5135
- textContent: Hr(n),
5136
- toolMeta: qr(t),
5157
+ textContent: Kr(n),
5158
+ toolMeta: Hr(t),
5137
5159
  imageParts: n.filter((r) => r.type === "image_url"),
5138
5160
  fileParts: n.filter((r) => r.type === "file"),
5139
- toolRaw: xr(n),
5161
+ toolRaw: Sr(n),
5140
5162
  isToolStreaming: !!t.toolStreaming
5141
5163
  };
5142
5164
  }, [e]);
5143
5165
  }
5144
- const nn = "data:";
5166
+ const tn = "data:";
5145
5167
  function Us(e) {
5146
5168
  if (!e) return [];
5147
5169
  const t = [], n = e.split(/\r?\n/);
5148
5170
  for (const r of n) {
5149
5171
  const s = r.trim();
5150
- if (!s || !s.startsWith(nn))
5172
+ if (!s || !s.startsWith(tn))
5151
5173
  continue;
5152
- const o = s.slice(nn.length).trim();
5174
+ const o = s.slice(tn.length).trim();
5153
5175
  if (!o || o.toLowerCase() === "[done]")
5154
5176
  continue;
5155
- const a = Ut(o);
5177
+ const a = zt(o);
5156
5178
  a && typeof a == "object" && t.push(a);
5157
5179
  }
5158
5180
  return t;
@@ -5166,7 +5188,7 @@ function Fs(e) {
5166
5188
  return null;
5167
5189
  }
5168
5190
  function to(e) {
5169
- return fe(() => {
5191
+ return de(() => {
5170
5192
  const t = e.content.filter(
5171
5193
  (f) => f.type === "text"
5172
5194
  );
@@ -5177,7 +5199,7 @@ function to(e) {
5177
5199
  );
5178
5200
  if (!r.length) {
5179
5201
  const f = t.map((c) => c.text ?? "").join(`
5180
- `), l = Ut(f);
5202
+ `), l = zt(f);
5181
5203
  l && typeof l == "object" && (r = [l]);
5182
5204
  }
5183
5205
  if (!r.length)
@@ -5199,36 +5221,36 @@ function to(e) {
5199
5221
  }, [e]);
5200
5222
  }
5201
5223
  function js(e) {
5202
- var _;
5203
- const t = typeof e == "string" ? e : e == null ? void 0 : e.threadId, { currentThreadId: n, setCurrentThreadId: r, actions: s } = st(), o = xn({ optional: !0 }), a = xs(), i = !!t && t !== n, [f, l] = H([]), c = E((k) => {
5204
- l(k);
5224
+ var z;
5225
+ const t = typeof e == "string" ? e : e == null ? void 0 : e.threadId, { currentThreadId: n, setCurrentThreadId: r, actions: s } = rt(), o = Sn({ optional: !0 }), a = xs(), i = !!t && t !== n, [f, l] = W([]), c = E((w) => {
5226
+ l(w);
5205
5227
  }, []), {
5206
5228
  isLoadingThread: d,
5207
5229
  threadStateError: g,
5208
5230
  threadCheckpoints: h
5209
- } = Tn({
5210
- api: We().chatApi,
5211
- fileApi: We().fileApi,
5231
+ } = vn({
5232
+ api: qe().chatApi,
5233
+ fileApi: qe().fileApi,
5212
5234
  seed: c,
5213
5235
  currentThreadId: i ? t : null,
5214
5236
  initialThreadId: i ? t : null,
5215
5237
  isStreaming: !1,
5216
5238
  getMessages: () => f,
5217
5239
  autoLoadInitial: !0
5218
- }), v = fe(() => {
5219
- var k;
5220
- return ((k = h[0]) == null ? void 0 : k.values) || {};
5221
- }, [h]), m = t || n, y = i ? f : (a == null ? void 0 : a.messages) || [], I = i ? d : (o == null ? void 0 : o.isLoading) || !1, A = i ? v : (o == null ? void 0 : o.values) || {}, x = i ? {} : (o == null ? void 0 : o.taskMessagesByScope) || {}, N = i ? g : (a == null ? void 0 : a.error) || (o == null ? void 0 : o.error) || null;
5240
+ }), k = de(() => {
5241
+ var w;
5242
+ return ((w = h[0]) == null ? void 0 : w.values) || {};
5243
+ }, [h]), m = t || n, y = i ? f : (a == null ? void 0 : a.messages) || [], I = i ? d : (o == null ? void 0 : o.isLoading) || !1, S = i ? k : (o == null ? void 0 : o.values) || {}, C = i ? {} : (o == null ? void 0 : o.taskMessagesByScope) || {}, L = i ? g : (a == null ? void 0 : a.error) || (o == null ? void 0 : o.error) || null;
5222
5244
  return {
5223
5245
  // UNIFIED: Single thread ID concept
5224
5246
  threadId: m,
5225
5247
  messages: y,
5226
5248
  isLoading: I,
5227
5249
  isHistoryLoading: I,
5228
- error: N,
5250
+ error: L,
5229
5251
  // Values & Metadata
5230
- values: A,
5231
- taskMessagesByScope: x,
5252
+ values: S,
5253
+ taskMessagesByScope: C,
5232
5254
  metadata: o == null ? void 0 : o.metadata,
5233
5255
  // Actions & State relating to Global/Active Thread only
5234
5256
  navigateToCheckpoint: (o == null ? void 0 : o.navigateToCheckpoint) || (async () => {
@@ -5246,7 +5268,7 @@ function js(e) {
5246
5268
  isStreaming: (a == null ? void 0 : a.isStreaming) || !1,
5247
5269
  activeMessageId: (a == null ? void 0 : a.activeMessageId) || null,
5248
5270
  connectionState: (a == null ? void 0 : a.connectionState) || "disconnected",
5249
- streamingAssistantId: a != null && a.isStreaming && ((_ = o == null ? void 0 : o.metadata) != null && _.assemblingMessageId) ? o.metadata.assemblingMessageId : null,
5271
+ streamingAssistantId: a != null && a.isStreaming && ((z = o == null ? void 0 : o.metadata) != null && z.assemblingMessageId) ? o.metadata.assemblingMessageId : null,
5250
5272
  // Actions
5251
5273
  submit: (a == null ? void 0 : a.submit) || (async () => {
5252
5274
  }),
@@ -5260,8 +5282,8 @@ function js(e) {
5260
5282
  deleteThread: s.deleteThread,
5261
5283
  renameThread: s.renameThread,
5262
5284
  shareThread: s.shareThread,
5263
- threads: st().threads,
5264
- isThreadsLoading: st().isLoading
5285
+ threads: rt().threads,
5286
+ isThreadsLoading: rt().isLoading
5265
5287
  };
5266
5288
  }
5267
5289
  function no({
@@ -5280,78 +5302,78 @@ function no({
5280
5302
  threadId: g,
5281
5303
  clearComposerOnSend: h = !0
5282
5304
  }) {
5283
- const { messages: v } = js(), [m, y] = H(null), [I, A] = H(""), [x, N] = H(null), [_, k] = H(null), [T, L] = H(!1), [j, O] = H(""), $ = K(j), C = K(null);
5284
- ae(() => {
5305
+ const { messages: k } = js(), [m, y] = W(null), [I, S] = W(""), [C, L] = W(null), [z, w] = W(null), [v, F] = W(!1), [$, B] = W(""), D = H($), P = H(null);
5306
+ se(() => {
5285
5307
  if (!m)
5286
5308
  if (g) {
5287
5309
  const u = localStorage.getItem(Mt(g));
5288
- O(u || "");
5310
+ B(u || "");
5289
5311
  } else
5290
- O("");
5312
+ B("");
5291
5313
  }, [g, m]);
5292
5314
  const J = E((u) => {
5293
- O(u), !m && g && localStorage.setItem(Mt(g), u);
5315
+ B(u), !m && g && localStorage.setItem(Mt(g), u);
5294
5316
  }, [g, m]);
5295
- ae(() => {
5296
- $.current = j;
5297
- }, [j]), ae(() => {
5317
+ se(() => {
5318
+ D.current = $;
5319
+ }, [$]), se(() => {
5298
5320
  if (!m) {
5299
- C.current = null;
5321
+ P.current = null;
5300
5322
  return;
5301
5323
  }
5302
- C.current === null && (C.current = $.current), J(I ?? "");
5324
+ P.current === null && (P.current = D.current), J(I ?? "");
5303
5325
  }, [I, m, J]);
5304
- const W = E(
5326
+ const G = E(
5305
5327
  (u) => {
5306
5328
  J(u);
5307
5329
  },
5308
5330
  [J]
5309
- ), Q = async (u, R) => {
5310
- const M = Array.isArray(R) ? { files: R } : R ?? {}, p = M.files ?? [], b = M.contentParts ?? [], z = u.trim();
5311
- if (!(!z && p.length === 0 && b.length === 0))
5331
+ ), Q = async (u, N) => {
5332
+ const _ = Array.isArray(N) ? { files: N } : N ?? {}, T = _.files ?? [], p = _.contentParts ?? [], M = u.trim();
5333
+ if (!(!M && T.length === 0 && p.length === 0))
5312
5334
  try {
5313
- const U = p.map(async (G) => {
5335
+ const x = T.map(async (j) => {
5314
5336
  try {
5315
- const oe = await yn.uploadFile(G);
5316
- return { file: G, record: oe };
5317
- } catch (oe) {
5318
- throw console.error("Failed to upload file", G.name, oe), new Error(`Failed to upload ${G.name}`);
5337
+ const re = await hn.uploadFile(j);
5338
+ return { file: j, record: re };
5339
+ } catch (re) {
5340
+ throw console.error("Failed to upload file", j.name, re), new Error(`Failed to upload ${j.name}`);
5319
5341
  }
5320
- }), B = (await Promise.all(U)).map(({ record: G }) => {
5321
- const oe = G.mime_type;
5322
- return oe.startsWith("image/") ? {
5342
+ }), U = (await Promise.all(x)).map(({ record: j }) => {
5343
+ const re = j.mime_type;
5344
+ return re.startsWith("image/") ? {
5323
5345
  type: "image_url",
5324
- image_url: { url: G.content_url }
5346
+ image_url: { url: j.content_url }
5325
5347
  } : {
5326
5348
  type: "file",
5327
- url: G.content_url,
5328
- mimeType: oe,
5329
- name: G.filename,
5330
- size: G.size
5349
+ url: j.content_url,
5350
+ mimeType: re,
5351
+ name: j.filename,
5352
+ size: j.size
5331
5353
  };
5332
- }), re = [...b, ...B], X = m ? (x == null ? void 0 : x.checkpointId) ?? n ?? void 0 : n ?? void 0, se = m ? (x == null ? void 0 : x.checkpointNs) ?? r ?? void 0 : r ?? void 0;
5354
+ }), ne = [...p, ...U], ee = m ? (C == null ? void 0 : C.checkpointId) ?? n ?? void 0 : n ?? void 0, Y = m ? (C == null ? void 0 : C.checkpointNs) ?? r ?? void 0 : r ?? void 0;
5333
5355
  await e(
5334
5356
  {
5335
- text: z || "",
5336
- contentParts: re,
5337
- attachments: p,
5357
+ text: M || "",
5358
+ contentParts: ne,
5359
+ attachments: T,
5338
5360
  payload: t.payload,
5339
5361
  edit: !!m,
5340
- checkpointId: X,
5341
- checkpointNs: se,
5362
+ checkpointId: ee,
5363
+ checkpointNs: Y,
5342
5364
  project: c ?? void 0,
5343
5365
  originalMessageId: m ?? void 0,
5344
5366
  config: t.config
5345
5367
  },
5346
5368
  d ? { onEvent: d } : void 0
5347
- ), s == null || s(z), l(!0), h && (g && localStorage.removeItem(Mt(g)), J("")), k(null), y(null), A(""), N(null);
5348
- } catch (U) {
5349
- const q = (U == null ? void 0 : U.message) || "Failed to send message";
5350
- k(q), a == null || a(q), l(!1);
5369
+ ), s == null || s(M), l(!0), h && (g && localStorage.removeItem(Mt(g)), J("")), w(null), y(null), S(""), L(null);
5370
+ } catch (x) {
5371
+ const q = (x == null ? void 0 : x.message) || "Failed to send message";
5372
+ w(q), a == null || a(q), l(!1);
5351
5373
  }
5352
- }, te = (u, R) => {
5353
- R || Q(u, { files: [] });
5354
- }, ne = E(
5374
+ }, X = (u, N) => {
5375
+ N || Q(u, { files: [] });
5376
+ }, oe = E(
5355
5377
  async (u) => {
5356
5378
  await e(
5357
5379
  {
@@ -5366,41 +5388,41 @@ function no({
5366
5388
  ), o == null || o({ file: u });
5367
5389
  },
5368
5390
  [n, r, t, o, e]
5369
- ), S = E(
5370
- (u, R, M) => {
5371
- i && (C.current = j, y(u), A(R), N({
5372
- checkpointId: (M == null ? void 0 : M.checkpointId) ?? null,
5373
- checkpointNs: (M == null ? void 0 : M.checkpointNs) ?? null
5374
- }), k(null));
5391
+ ), A = E(
5392
+ (u, N, _) => {
5393
+ i && (P.current = $, y(u), S(N), L({
5394
+ checkpointId: (_ == null ? void 0 : _.checkpointId) ?? null,
5395
+ checkpointNs: (_ == null ? void 0 : _.checkpointNs) ?? null
5396
+ }), w(null));
5375
5397
  },
5376
- [j, i]
5377
- ), P = E(() => {
5378
- y(null), A(""), N(null), k(null);
5379
- const u = C.current;
5380
- u !== null && O(u), C.current = null;
5381
- }, []), D = E((u) => {
5382
- let R = null;
5383
- for (let z = u - 1; z >= 0; z--)
5384
- if (f[z].role === "user") {
5385
- R = f[z];
5398
+ [$, i]
5399
+ ), R = E(() => {
5400
+ y(null), S(""), L(null), w(null);
5401
+ const u = P.current;
5402
+ u !== null && B(u), P.current = null;
5403
+ }, []), V = E((u) => {
5404
+ let N = null;
5405
+ for (let M = u - 1; M >= 0; M--)
5406
+ if (f[M].role === "user") {
5407
+ N = f[M];
5386
5408
  break;
5387
5409
  }
5388
- if (!R) return;
5389
- const M = Array.isArray(R.content) ? R.content : [], b = M.filter((z) => (z == null ? void 0 : z.type) === "text").map((z) => z.text).join("") || (() => {
5410
+ if (!N) return;
5411
+ const _ = Array.isArray(N.content) ? N.content : [], p = _.filter((M) => (M == null ? void 0 : M.type) === "text").map((M) => M.text).join("") || (() => {
5390
5412
  try {
5391
- return JSON.stringify(M, null, 2);
5413
+ return JSON.stringify(_, null, 2);
5392
5414
  } catch {
5393
- return String(M);
5415
+ return String(_);
5394
5416
  }
5395
5417
  })();
5396
- b && e(
5418
+ p && e(
5397
5419
  {
5398
- text: b,
5420
+ text: p,
5399
5421
  payload: t.payload,
5400
5422
  checkpointId: n ?? void 0,
5401
5423
  checkpointNs: r ?? void 0,
5402
5424
  edit: !0,
5403
- originalMessageId: R.id,
5425
+ originalMessageId: N.id,
5404
5426
  config: t.config
5405
5427
  },
5406
5428
  d ? { onEvent: d } : void 0
@@ -5409,27 +5431,27 @@ function no({
5409
5431
  return {
5410
5432
  editingMessageId: m,
5411
5433
  editingInitialValue: I,
5412
- inputError: _,
5413
- setInputError: k,
5414
- dismissError: T,
5415
- setDismissError: L,
5416
- composerValue: j,
5417
- handleComposerChange: W,
5434
+ inputError: z,
5435
+ setInputError: w,
5436
+ dismissError: v,
5437
+ setDismissError: F,
5438
+ composerValue: $,
5439
+ handleComposerChange: G,
5418
5440
  handleSendMessage: Q,
5419
- handleQuickPrompt: te,
5420
- handleExcelUpload: ne,
5421
- startEditing: S,
5422
- cancelEditing: P,
5423
- handleRegenerateCb: D,
5424
- displayMessages: v
5441
+ handleQuickPrompt: X,
5442
+ handleExcelUpload: oe,
5443
+ startEditing: A,
5444
+ cancelEditing: R,
5445
+ handleRegenerateCb: V,
5446
+ displayMessages: k
5425
5447
  };
5426
5448
  }
5427
5449
  function ro(e) {
5428
- return fe(() => e ? {
5450
+ return de(() => e ? {
5429
5451
  textContent: Ir(e),
5430
- imageParts: Tr(e),
5431
- fileParts: Ar(e),
5432
- toolCalls: un(e),
5452
+ imageParts: vr(e),
5453
+ fileParts: Tr(e),
5454
+ toolCalls: ln(e),
5433
5455
  contentParts: e.content
5434
5456
  } : {
5435
5457
  textContent: "",
@@ -5440,8 +5462,8 @@ function ro(e) {
5440
5462
  }, [e]);
5441
5463
  }
5442
5464
  function so(e, t, n) {
5443
- const [r, s] = H(e), o = K(e), a = K(null);
5444
- return ae(() => {
5465
+ const [r, s] = W(e), o = H(e), a = H(null);
5466
+ return se(() => {
5445
5467
  o.current = e;
5446
5468
  const i = () => {
5447
5469
  s(o.current), a.current && (clearTimeout(a.current), a.current = null);
@@ -5459,33 +5481,33 @@ function so(e, t, n) {
5459
5481
  }
5460
5482
  export {
5461
5483
  Ys as ChatProviders,
5462
- Is as ThreadStateProvider,
5484
+ vs as ThreadStateProvider,
5463
5485
  rs as ThreadsProvider,
5464
5486
  Vs as cn,
5465
- Hr as collectText,
5487
+ Kr as collectText,
5466
5488
  Qs as createTaskSyncToolEndHandler,
5467
5489
  Es as extractTaskIdFromToolEnd,
5468
- qr as extractToolMeta,
5490
+ Hr as extractToolMeta,
5469
5491
  Ks as formatToolOutput,
5470
5492
  Gs as getAgentNameFromMessage,
5471
- pn as getChatToken,
5493
+ fn as getChatToken,
5472
5494
  Xs as getMessageAttemptInfo,
5473
5495
  qs as getToolCallArtifacts,
5474
- Nr as getToolCalls,
5496
+ Rr as getToolCalls,
5475
5497
  Hs as hasContent,
5476
- tt as hydrateHistorySnapshots,
5477
- dn as isFileLike,
5478
- wr as looksLikeMarkdown,
5498
+ ft as hydrateHistorySnapshots,
5499
+ un as isFileLike,
5500
+ br as looksLikeMarkdown,
5479
5501
  Js as messageSignature,
5480
5502
  Ws as normalizeInterruptId,
5481
- gn as onChatTokenChanged,
5482
- Ut as parseJsonSafe,
5483
- fn as pretty,
5484
- Et as refreshHistoryFileUrls,
5503
+ pn as onChatTokenChanged,
5504
+ zt as parseJsonSafe,
5505
+ dn as pretty,
5506
+ Gr as refreshHistoryFileUrls,
5485
5507
  yt as sanitizeForDisplay,
5486
- Ve as setChatToken,
5487
- xr as stringifyTool,
5488
- We as useApi,
5508
+ De as setChatToken,
5509
+ Sr as stringifyTool,
5510
+ qe as useApi,
5489
5511
  no as useChatController,
5490
5512
  js as useChatSession,
5491
5513
  Zs as useFilePreview,
@@ -5493,10 +5515,10 @@ export {
5493
5515
  eo as useParsedMessageContent,
5494
5516
  Zr as useStream,
5495
5517
  so as useStreamingMarkdownBuffer,
5496
- Tn as useThreadHistoryState,
5497
- xn as useThreadState,
5498
- vs as useThreadStateUpdater,
5499
- st as useThreads,
5518
+ vn as useThreadHistoryState,
5519
+ Sn as useThreadState,
5520
+ Is as useThreadStateUpdater,
5521
+ rt as useThreads,
5500
5522
  ns as useThreadsState,
5501
5523
  to as useToolPayload
5502
5524
  };