@opencx/widget-react-headless 5.0.0-beta.3 → 5.0.0-beta.5

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.js CHANGED
@@ -1,15 +1,15 @@
1
- import $, { useSyncExternalStore as De, useRef as j, useCallback as F, useEffect as q, useMemo as J, useState as K, createContext as Fe, useContext as $e } from "react";
2
- import { isAgentStreamKeepalive as tr, isRecord as Gr, isTurnSteeredPart as Qr, buildSendMessageBody as Xr, log as B, genUuid as Rt, resolveClientPresentation as ea, PrimitiveState as rr, WidgetCtx as ta, resolveSidebarMode as ra, resolveSidebarSide as aa, normalizeCompanionLayouts as sa, resolveCompanionDefaultLayout as na } from "@opencx/widget-core";
3
- import * as Pt from "zod/v4";
1
+ import F, { useSyncExternalStore as De, useRef as D, useCallback as q, useEffect as Z, useMemo as B, useState as V, createContext as Fe, useContext as $e } from "react";
2
+ import { isAgentStreamKeepalive as Jr, isRecord as Kr, buildSendMessageBody as Yr, log as ne, genUuid as xt, resolveClientPresentation as Hr, PrimitiveState as Qt, WidgetCtx as Gr, resolveSidebarMode as Qr, resolveSidebarSide as Xr, normalizeCompanionLayouts as ea, resolveCompanionDefaultLayout as ta } from "@opencx/widget-core";
3
+ import * as At from "zod/v4";
4
4
  import { z as o } from "zod/v4";
5
- import { ZodFirstPartyTypeKind as R } from "zod/v3";
5
+ import { ZodFirstPartyTypeKind as T } from "zod/v3";
6
6
  import "react/jsx-runtime";
7
- import { z as Z } from "zod";
8
- const ia = "5.0.0-beta.3";
9
- function U(e) {
7
+ import { z } from "zod";
8
+ const ra = "5.0.0-beta.5";
9
+ function $(e) {
10
10
  return De(e.subscribe, e.get, e.get);
11
11
  }
12
- function oa({
12
+ function aa({
13
13
  turnSources: e,
14
14
  liveItems: t,
15
15
  isStreaming: r,
@@ -18,16 +18,16 @@ function oa({
18
18
  var i;
19
19
  if (r || a) return null;
20
20
  const s = t.length > 0 ? t : (i = e.at(-1)) == null ? void 0 : i.items;
21
- return s ? la(s) : null;
21
+ return s ? sa(s) : null;
22
22
  }
23
- function la(e) {
23
+ function sa(e) {
24
24
  for (let t = e.length - 1; t >= 0; t--) {
25
25
  const r = e[t];
26
26
  if ((r == null ? void 0 : r.kind) === "questions") return r.request;
27
27
  }
28
28
  return null;
29
29
  }
30
- var ar = "vercel.ai.error", ua = Symbol.for(ar), Ot, Nt, se = class sr extends (Nt = Error, Ot = ua, Nt) {
30
+ var Xt = "vercel.ai.error", na = Symbol.for(Xt), Mt, Tt, ae = class er extends (Tt = Error, Mt = na, Tt) {
31
31
  /**
32
32
  * Creates an AI SDK Error.
33
33
  *
@@ -41,7 +41,7 @@ var ar = "vercel.ai.error", ua = Symbol.for(ar), Ot, Nt, se = class sr extends (
41
41
  message: r,
42
42
  cause: a
43
43
  }) {
44
- super(r), this[Ot] = !0, this.name = t, this.cause = a;
44
+ super(r), this[Mt] = !0, this.name = t, this.cause = a;
45
45
  }
46
46
  /**
47
47
  * Checks if the given error is an AI SDK Error.
@@ -49,40 +49,40 @@ var ar = "vercel.ai.error", ua = Symbol.for(ar), Ot, Nt, se = class sr extends (
49
49
  * @returns {boolean} True if the error is an AI SDK Error, false otherwise.
50
50
  */
51
51
  static isInstance(t) {
52
- return sr.hasMarker(t, ar);
52
+ return er.hasMarker(t, Xt);
53
53
  }
54
54
  static hasMarker(t, r) {
55
55
  const a = Symbol.for(r);
56
56
  return t != null && typeof t == "object" && a in t && typeof t[a] == "boolean" && t[a] === !0;
57
57
  }
58
58
  };
59
- function nr(e) {
59
+ function tr(e) {
60
60
  return e == null ? "unknown error" : typeof e == "string" ? e : e instanceof Error ? e.toString() : JSON.stringify(e);
61
61
  }
62
- var ir = "AI_InvalidArgumentError", or = `vercel.ai.error.${ir}`, ca = Symbol.for(or), jt, Dt, da = class extends (Dt = se, jt = ca, Dt) {
62
+ var rr = "AI_InvalidArgumentError", ar = `vercel.ai.error.${rr}`, ia = Symbol.for(ar), Rt, Pt, oa = class extends (Pt = ae, Rt = ia, Pt) {
63
63
  constructor({
64
64
  message: e,
65
65
  cause: t,
66
66
  argument: r
67
67
  }) {
68
- super({ name: ir, message: e, cause: t }), this[jt] = !0, this.argument = r;
68
+ super({ name: rr, message: e, cause: t }), this[Rt] = !0, this.argument = r;
69
69
  }
70
70
  static isInstance(e) {
71
- return se.hasMarker(e, or);
71
+ return ae.hasMarker(e, ar);
72
72
  }
73
- }, lr = "AI_JSONParseError", ur = `vercel.ai.error.${lr}`, pa = Symbol.for(ur), kt, Lt, Ft = class extends (Lt = se, kt = pa, Lt) {
73
+ }, sr = "AI_JSONParseError", nr = `vercel.ai.error.${sr}`, la = Symbol.for(nr), Ot, Nt, jt = class extends (Nt = ae, Ot = la, Nt) {
74
74
  constructor({ text: e, cause: t }) {
75
75
  super({
76
- name: lr,
76
+ name: sr,
77
77
  message: `JSON parsing failed: Text: ${e}.
78
- Error message: ${nr(t)}`,
78
+ Error message: ${tr(t)}`,
79
79
  cause: t
80
- }), this[kt] = !0, this.text = e;
80
+ }), this[Ot] = !0, this.text = e;
81
81
  }
82
82
  static isInstance(e) {
83
- return se.hasMarker(e, ur);
83
+ return ae.hasMarker(e, nr);
84
84
  }
85
- }, cr = "AI_TypeValidationError", dr = `vercel.ai.error.${cr}`, fa = Symbol.for(dr), $t, Ut, Me = class ct extends (Ut = se, $t = fa, Ut) {
85
+ }, ir = "AI_TypeValidationError", or = `vercel.ai.error.${ir}`, ua = Symbol.for(or), Dt, kt, Ae = class lt extends (kt = ae, Dt = ua, kt) {
86
86
  constructor({
87
87
  value: t,
88
88
  cause: r,
@@ -95,14 +95,14 @@ Error message: ${nr(t)}`,
95
95
  a.entityName && i.push(a.entityName), a.entityId && i.push(`id: "${a.entityId}"`), s += i.join(", "), s += ")";
96
96
  }
97
97
  super({
98
- name: cr,
98
+ name: ir,
99
99
  message: `${s}: Value: ${JSON.stringify(t)}.
100
- Error message: ${nr(r)}`,
100
+ Error message: ${tr(r)}`,
101
101
  cause: r
102
- }), this[$t] = !0, this.value = t, this.context = a;
102
+ }), this[Dt] = !0, this.value = t, this.context = a;
103
103
  }
104
104
  static isInstance(t) {
105
- return se.hasMarker(t, dr);
105
+ return ae.hasMarker(t, or);
106
106
  }
107
107
  /**
108
108
  * Wraps an error into a TypeValidationError.
@@ -121,25 +121,25 @@ Error message: ${nr(r)}`,
121
121
  context: a
122
122
  }) {
123
123
  var s, i, l;
124
- return ct.isInstance(r) && r.value === t && ((s = r.context) == null ? void 0 : s.field) === (a == null ? void 0 : a.field) && ((i = r.context) == null ? void 0 : i.entityName) === (a == null ? void 0 : a.entityName) && ((l = r.context) == null ? void 0 : l.entityId) === (a == null ? void 0 : a.entityId) ? r : new ct({ value: t, cause: r, context: a });
124
+ return lt.isInstance(r) && r.value === t && ((s = r.context) == null ? void 0 : s.field) === (a == null ? void 0 : a.field) && ((i = r.context) == null ? void 0 : i.entityName) === (a == null ? void 0 : a.entityName) && ((l = r.context) == null ? void 0 : l.entityId) === (a == null ? void 0 : a.entityId) ? r : new lt({ value: t, cause: r, context: a });
125
125
  }
126
126
  };
127
- class st extends Error {
127
+ class rt extends Error {
128
128
  constructor(t, r) {
129
129
  super(t), this.name = "ParseError", this.type = r.type, this.field = r.field, this.value = r.value, this.line = r.line;
130
130
  }
131
131
  }
132
- const qt = 10, ma = 13, ge = 32;
133
- function nt(e) {
132
+ const Lt = 10, ca = 13, ge = 32;
133
+ function at(e) {
134
134
  }
135
- function ga(e) {
135
+ function da(e) {
136
136
  if (typeof e == "function")
137
137
  throw new TypeError(
138
138
  "`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?"
139
139
  );
140
- const { onEvent: t = nt, onError: r = nt, onRetry: a = nt, onComment: s, maxBufferSize: i } = e, l = [];
140
+ const { onEvent: t = at, onError: r = at, onRetry: a = at, onComment: s, maxBufferSize: i } = e, l = [];
141
141
  let n = 0, f = !0, u, c = "", p = 0, v, h = !1;
142
- function x(g) {
142
+ function _(g) {
143
143
  if (h)
144
144
  throw new Error(
145
145
  "Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing."
@@ -157,12 +157,12 @@ function ga(e) {
157
157
  l.push(g);
158
158
  const m = l.join("");
159
159
  l.length = 0, n = 0;
160
- const S = E(m);
161
- S !== "" && (l.push(S), n = S.length), M();
160
+ const b = E(m);
161
+ b !== "" && (l.push(b), n = b.length), M();
162
162
  }
163
163
  function M() {
164
164
  i !== void 0 && (n + c.length <= i || (h = !0, l.length = 0, n = 0, u = void 0, c = "", p = 0, v = void 0, r(
165
- new st(`Buffered data exceeded max buffer size of ${i} characters`, {
165
+ new rt(`Buffered data exceeded max buffer size of ${i} characters`, {
166
166
  type: "max-buffer-size-exceeded"
167
167
  })
168
168
  )));
@@ -170,80 +170,80 @@ function ga(e) {
170
170
  function E(g) {
171
171
  let m = 0;
172
172
  if (g.indexOf("\r") === -1) {
173
- let S = g.indexOf(`
173
+ let b = g.indexOf(`
174
174
  `, m);
175
- for (; S !== -1; ) {
176
- if (m === S) {
177
- p > 0 && t({ id: u, event: v, data: c }), u = void 0, c = "", p = 0, v = void 0, m = S + 1, S = g.indexOf(`
175
+ for (; b !== -1; ) {
176
+ if (m === b) {
177
+ p > 0 && t({ id: u, event: v, data: c }), u = void 0, c = "", p = 0, v = void 0, m = b + 1, b = g.indexOf(`
178
178
  `, m);
179
179
  continue;
180
180
  }
181
181
  const y = g.charCodeAt(m);
182
- if (Zt(g, m, y)) {
183
- const _ = g.charCodeAt(m + 5) === ge ? m + 6 : m + 5, P = g.slice(_, S);
184
- if (p === 0 && g.charCodeAt(S + 1) === qt) {
185
- t({ id: u, event: v, data: P }), u = void 0, c = "", v = void 0, m = S + 2, S = g.indexOf(`
182
+ if (Ft(g, m, y)) {
183
+ const I = g.charCodeAt(m + 5) === ge ? m + 6 : m + 5, k = g.slice(I, b);
184
+ if (p === 0 && g.charCodeAt(b + 1) === Lt) {
185
+ t({ id: u, event: v, data: k }), u = void 0, c = "", v = void 0, m = b + 2, b = g.indexOf(`
186
186
  `, m);
187
187
  continue;
188
188
  }
189
- c = p === 0 ? P : `${c}
190
- ${P}`, p++;
191
- } else zt(g, m, y) ? v = g.slice(
189
+ c = p === 0 ? k : `${c}
190
+ ${k}`, p++;
191
+ } else $t(g, m, y) ? v = g.slice(
192
192
  g.charCodeAt(m + 6) === ge ? m + 7 : m + 6,
193
- S
194
- ) || void 0 : C(g, m, S);
195
- m = S + 1, S = g.indexOf(`
193
+ b
194
+ ) || void 0 : C(g, m, b);
195
+ m = b + 1, b = g.indexOf(`
196
196
  `, m);
197
197
  }
198
198
  return g.slice(m);
199
199
  }
200
200
  for (; m < g.length; ) {
201
- const S = g.indexOf("\r", m), y = g.indexOf(`
201
+ const b = g.indexOf("\r", m), y = g.indexOf(`
202
202
  `, m);
203
- let _ = -1;
204
- if (S !== -1 && y !== -1 ? _ = S < y ? S : y : S !== -1 ? S === g.length - 1 ? _ = -1 : _ = S : y !== -1 && (_ = y), _ === -1)
203
+ let I = -1;
204
+ if (b !== -1 && y !== -1 ? I = b < y ? b : y : b !== -1 ? b === g.length - 1 ? I = -1 : I = b : y !== -1 && (I = y), I === -1)
205
205
  break;
206
- C(g, m, _), m = _ + 1, g.charCodeAt(m - 1) === ma && g.charCodeAt(m) === qt && m++;
206
+ C(g, m, I), m = I + 1, g.charCodeAt(m - 1) === ca && g.charCodeAt(m) === Lt && m++;
207
207
  }
208
208
  return g.slice(m);
209
209
  }
210
- function C(g, m, S) {
211
- if (m === S) {
212
- O();
210
+ function C(g, m, b) {
211
+ if (m === b) {
212
+ N();
213
213
  return;
214
214
  }
215
215
  const y = g.charCodeAt(m);
216
- if (Zt(g, m, y)) {
217
- const V = g.charCodeAt(m + 5) === ge ? m + 6 : m + 5, Te = g.slice(V, S);
218
- c = p === 0 ? Te : `${c}
219
- ${Te}`, p++;
216
+ if (Ft(g, m, y)) {
217
+ const Q = g.charCodeAt(m + 5) === ge ? m + 6 : m + 5, Me = g.slice(Q, b);
218
+ c = p === 0 ? Me : `${c}
219
+ ${Me}`, p++;
220
220
  return;
221
221
  }
222
- if (zt(g, m, y)) {
223
- v = g.slice(g.charCodeAt(m + 6) === ge ? m + 7 : m + 6, S) || void 0;
222
+ if ($t(g, m, y)) {
223
+ v = g.slice(g.charCodeAt(m + 6) === ge ? m + 7 : m + 6, b) || void 0;
224
224
  return;
225
225
  }
226
226
  if (y === 105 && g.charCodeAt(m + 1) === 100 && g.charCodeAt(m + 2) === 58) {
227
- const V = g.slice(g.charCodeAt(m + 3) === ge ? m + 4 : m + 3, S);
228
- u = V.includes("\0") ? void 0 : V;
227
+ const Q = g.slice(g.charCodeAt(m + 3) === ge ? m + 4 : m + 3, b);
228
+ u = Q.includes("\0") ? void 0 : Q;
229
229
  return;
230
230
  }
231
231
  if (y === 58) {
232
232
  if (s) {
233
- const V = g.slice(m, S);
234
- s(V.slice(g.charCodeAt(m + 1) === ge ? 2 : 1));
233
+ const Q = g.slice(m, b);
234
+ s(Q.slice(g.charCodeAt(m + 1) === ge ? 2 : 1));
235
235
  }
236
236
  return;
237
237
  }
238
- const _ = g.slice(m, S), P = _.indexOf(":");
239
- if (P === -1) {
240
- w(_, "", _);
238
+ const I = g.slice(m, b), k = I.indexOf(":");
239
+ if (k === -1) {
240
+ w(I, "", I);
241
241
  return;
242
242
  }
243
- const fe = _.slice(0, P), ne = _.charCodeAt(P + 1) === ge ? 2 : 1, re = _.slice(P + ne);
244
- w(fe, re, _);
243
+ const Y = I.slice(0, k), te = I.charCodeAt(k + 1) === ge ? 2 : 1, ie = I.slice(k + te);
244
+ w(Y, ie, I);
245
245
  }
246
- function w(g, m, S) {
246
+ function w(g, m, b) {
247
247
  switch (g) {
248
248
  case "event":
249
249
  v = m || void 0;
@@ -257,24 +257,24 @@ ${m}`, p++;
257
257
  break;
258
258
  case "retry":
259
259
  /^\d+$/.test(m) ? a(parseInt(m, 10)) : r(
260
- new st(`Invalid \`retry\` value: "${m}"`, {
260
+ new rt(`Invalid \`retry\` value: "${m}"`, {
261
261
  type: "invalid-retry",
262
262
  value: m,
263
- line: S
263
+ line: b
264
264
  })
265
265
  );
266
266
  break;
267
267
  default:
268
268
  r(
269
- new st(
269
+ new rt(
270
270
  `Unknown field "${g.length > 20 ? `${g.slice(0, 20)}…` : g}"`,
271
- { type: "unknown-field", field: g, value: m, line: S }
271
+ { type: "unknown-field", field: g, value: m, line: b }
272
272
  )
273
273
  );
274
274
  break;
275
275
  }
276
276
  }
277
- function O() {
277
+ function N() {
278
278
  p > 0 && t({
279
279
  id: u,
280
280
  event: v,
@@ -288,20 +288,20 @@ ${m}`, p++;
288
288
  }
289
289
  f = !0, u = void 0, c = "", p = 0, v = void 0, l.length = 0, n = 0, h = !1;
290
290
  }
291
- return { feed: x, reset: d };
291
+ return { feed: _, reset: d };
292
292
  }
293
- function Zt(e, t, r) {
293
+ function Ft(e, t, r) {
294
294
  return r === 100 && e.charCodeAt(t + 1) === 97 && e.charCodeAt(t + 2) === 116 && e.charCodeAt(t + 3) === 97 && e.charCodeAt(t + 4) === 58;
295
295
  }
296
- function zt(e, t, r) {
296
+ function $t(e, t, r) {
297
297
  return r === 101 && e.charCodeAt(t + 1) === 118 && e.charCodeAt(t + 2) === 101 && e.charCodeAt(t + 3) === 110 && e.charCodeAt(t + 4) === 116 && e.charCodeAt(t + 5) === 58;
298
298
  }
299
- class ha extends TransformStream {
299
+ class pa extends TransformStream {
300
300
  constructor({ onError: t, onRetry: r, onComment: a, maxBufferSize: s } = {}) {
301
301
  let i;
302
302
  super({
303
303
  start(l) {
304
- i = ga({
304
+ i = da({
305
305
  onEvent: (n) => {
306
306
  l.enqueue(n);
307
307
  },
@@ -320,7 +320,7 @@ class ha extends TransformStream {
320
320
  }
321
321
  }
322
322
  new TextDecoder();
323
- var Q = ({
323
+ var G = ({
324
324
  prefix: e,
325
325
  size: t = 16,
326
326
  alphabet: r = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
@@ -335,13 +335,13 @@ var Q = ({
335
335
  if (e == null)
336
336
  return s;
337
337
  if (r.includes(a))
338
- throw new da({
338
+ throw new oa({
339
339
  argument: "separator",
340
340
  message: `The separator "${a}" must not be part of the alphabet "${r}".`
341
341
  });
342
342
  return () => `${e}${a}${s()}`;
343
- }, va = Q();
344
- function we(e) {
343
+ }, fa = G();
344
+ function Ie(e) {
345
345
  if (e == null)
346
346
  return {};
347
347
  const t = {};
@@ -356,16 +356,16 @@ function we(e) {
356
356
  }
357
357
  return t;
358
358
  }
359
- function ya(e) {
359
+ function ma(e) {
360
360
  var t, r;
361
361
  return (r = (t = globalThis.Buffer) == null ? void 0 : t.isBuffer(e)) != null ? r : !1;
362
362
  }
363
- var ba = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/, Sa = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
364
- function Wt(e) {
363
+ var ga = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/, ha = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
364
+ function Ut(e) {
365
365
  const t = JSON.parse(e);
366
- return t === null || typeof t != "object" || ba.test(e) === !1 && Sa.test(e) === !1 ? t : Ea(t);
366
+ return t === null || typeof t != "object" || ga.test(e) === !1 && ha.test(e) === !1 ? t : va(t);
367
367
  }
368
- function Ea(e) {
368
+ function va(e) {
369
369
  let t = [e];
370
370
  for (; t.length; ) {
371
371
  const r = t;
@@ -383,20 +383,20 @@ function Ea(e) {
383
383
  }
384
384
  return e;
385
385
  }
386
- function Ca(e) {
386
+ function ya(e) {
387
387
  const { stackTraceLimit: t } = Error;
388
388
  try {
389
389
  Error.stackTraceLimit = 0;
390
390
  } catch {
391
- return Wt(e);
391
+ return Ut(e);
392
392
  }
393
393
  try {
394
- return Wt(e);
394
+ return Ut(e);
395
395
  } finally {
396
396
  Error.stackTraceLimit = t;
397
397
  }
398
398
  }
399
- function vt(e) {
399
+ function gt(e) {
400
400
  if (e.type === "object" || Array.isArray(e.type) && e.type.includes("object")) {
401
401
  e.additionalProperties = !1;
402
402
  const { properties: r } = e;
@@ -412,11 +412,11 @@ function vt(e) {
412
412
  return e;
413
413
  }
414
414
  function he(e) {
415
- return typeof e == "boolean" ? e : vt(e);
415
+ return typeof e == "boolean" ? e : gt(e);
416
416
  }
417
- var Ia = /* @__PURE__ */ Symbol(
417
+ var ba = /* @__PURE__ */ Symbol(
418
418
  "Let zodToJsonSchema decide on which parser to use"
419
- ), Bt = {
419
+ ), qt = {
420
420
  name: void 0,
421
421
  $refStrategy: "root",
422
422
  basePath: ["#"],
@@ -436,27 +436,27 @@ var Ia = /* @__PURE__ */ Symbol(
436
436
  emailStrategy: "format:email",
437
437
  base64Strategy: "contentEncoding:base64",
438
438
  nameStrategy: "ref"
439
- }, wa = (e) => typeof e == "string" ? {
440
- ...Bt,
439
+ }, Sa = (e) => typeof e == "string" ? {
440
+ ...qt,
441
441
  name: e
442
442
  } : {
443
- ...Bt,
443
+ ...qt,
444
444
  ...e
445
445
  };
446
- function Y() {
446
+ function J() {
447
447
  return {};
448
448
  }
449
- function _a(e, t) {
449
+ function Ea(e, t) {
450
450
  var r, a, s;
451
451
  const i = {
452
452
  type: "array"
453
453
  };
454
- return (r = e.type) != null && r._def && ((s = (a = e.type) == null ? void 0 : a._def) == null ? void 0 : s.typeName) !== R.ZodAny && (i.items = N(e.type._def, {
454
+ return (r = e.type) != null && r._def && ((s = (a = e.type) == null ? void 0 : a._def) == null ? void 0 : s.typeName) !== T.ZodAny && (i.items = O(e.type._def, {
455
455
  ...t,
456
456
  currentPath: [...t.currentPath, "items"]
457
457
  })), e.minLength && (i.minItems = e.minLength.value), e.maxLength && (i.maxItems = e.maxLength.value), e.exactLength && (i.minItems = e.exactLength.value, i.maxItems = e.exactLength.value), i;
458
458
  }
459
- function xa(e) {
459
+ function Ca(e) {
460
460
  const t = {
461
461
  type: "integer",
462
462
  format: "int64"
@@ -476,18 +476,18 @@ function xa(e) {
476
476
  }
477
477
  return t;
478
478
  }
479
- function Aa() {
479
+ function Ia() {
480
480
  return { type: "boolean" };
481
481
  }
482
- function pr(e, t) {
483
- return N(e.type._def, t);
482
+ function lr(e, t) {
483
+ return O(e.type._def, t);
484
484
  }
485
- var Ma = (e, t) => N(e.innerType._def, t);
486
- function fr(e, t, r) {
485
+ var wa = (e, t) => O(e.innerType._def, t);
486
+ function ur(e, t, r) {
487
487
  const a = r ?? t.dateStrategy;
488
488
  if (Array.isArray(a))
489
489
  return {
490
- anyOf: a.map((s) => fr(e, t, s))
490
+ anyOf: a.map((s) => ur(e, t, s))
491
491
  };
492
492
  switch (a) {
493
493
  case "string":
@@ -502,10 +502,10 @@ function fr(e, t, r) {
502
502
  format: "date"
503
503
  };
504
504
  case "integer":
505
- return Ta(e);
505
+ return _a(e);
506
506
  }
507
507
  }
508
- var Ta = (e) => {
508
+ var _a = (e) => {
509
509
  const t = {
510
510
  type: "integer",
511
511
  format: "unix-time"
@@ -521,35 +521,35 @@ var Ta = (e) => {
521
521
  }
522
522
  return t;
523
523
  };
524
- function Ra(e, t) {
524
+ function xa(e, t) {
525
525
  return {
526
- ...N(e.innerType._def, t),
526
+ ...O(e.innerType._def, t),
527
527
  default: e.defaultValue()
528
528
  };
529
529
  }
530
- function Pa(e, t) {
531
- return t.effectStrategy === "input" ? N(e.schema._def, t) : Y();
530
+ function Aa(e, t) {
531
+ return t.effectStrategy === "input" ? O(e.schema._def, t) : J();
532
532
  }
533
- function Oa(e) {
533
+ function Ma(e) {
534
534
  return {
535
535
  type: "string",
536
536
  enum: Array.from(e.values)
537
537
  };
538
538
  }
539
- var Na = (e) => "type" in e && e.type === "string" ? !1 : "allOf" in e;
540
- function ja(e, t) {
539
+ var Ta = (e) => "type" in e && e.type === "string" ? !1 : "allOf" in e;
540
+ function Ra(e, t) {
541
541
  const r = [
542
- N(e.left._def, {
542
+ O(e.left._def, {
543
543
  ...t,
544
544
  currentPath: [...t.currentPath, "allOf", "0"]
545
545
  }),
546
- N(e.right._def, {
546
+ O(e.right._def, {
547
547
  ...t,
548
548
  currentPath: [...t.currentPath, "allOf", "1"]
549
549
  })
550
550
  ].filter((s) => !!s), a = [];
551
551
  return r.forEach((s) => {
552
- if (Na(s))
552
+ if (Ta(s))
553
553
  a.push(...s.allOf);
554
554
  else {
555
555
  let i = s;
@@ -561,7 +561,7 @@ function ja(e, t) {
561
561
  }
562
562
  }), a.length ? { allOf: a } : void 0;
563
563
  }
564
- function Da(e) {
564
+ function Pa(e) {
565
565
  const t = typeof e.value;
566
566
  return t !== "bigint" && t !== "number" && t !== "boolean" && t !== "string" ? {
567
567
  type: Array.isArray(e.value) ? "array" : "object"
@@ -570,7 +570,7 @@ function Da(e) {
570
570
  const: e.value
571
571
  };
572
572
  }
573
- var it = void 0, ee = {
573
+ var st = void 0, X = {
574
574
  /**
575
575
  * `c` was changed to `[cC]` to replicate /i flag
576
576
  */
@@ -592,10 +592,10 @@ var it = void 0, ee = {
592
592
  * Fix in Zod:
593
593
  * https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
594
594
  */
595
- emoji: () => (it === void 0 && (it = RegExp(
595
+ emoji: () => (st === void 0 && (st = RegExp(
596
596
  "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",
597
597
  "u"
598
- )), it),
598
+ )), st),
599
599
  /**
600
600
  * Unused
601
601
  */
@@ -615,7 +615,7 @@ var it = void 0, ee = {
615
615
  nanoid: /^[a-zA-Z0-9_-]{21}$/,
616
616
  jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
617
617
  };
618
- function mr(e, t) {
618
+ function cr(e, t) {
619
619
  const r = {
620
620
  type: "string"
621
621
  };
@@ -631,96 +631,96 @@ function mr(e, t) {
631
631
  case "email":
632
632
  switch (t.emailStrategy) {
633
633
  case "format:email":
634
- te(r, "email", a.message, t);
634
+ ee(r, "email", a.message, t);
635
635
  break;
636
636
  case "format:idn-email":
637
- te(r, "idn-email", a.message, t);
637
+ ee(r, "idn-email", a.message, t);
638
638
  break;
639
639
  case "pattern:zod":
640
- z(r, ee.email, a.message, t);
640
+ W(r, X.email, a.message, t);
641
641
  break;
642
642
  }
643
643
  break;
644
644
  case "url":
645
- te(r, "uri", a.message, t);
645
+ ee(r, "uri", a.message, t);
646
646
  break;
647
647
  case "uuid":
648
- te(r, "uuid", a.message, t);
648
+ ee(r, "uuid", a.message, t);
649
649
  break;
650
650
  case "regex":
651
- z(r, a.regex, a.message, t);
651
+ W(r, a.regex, a.message, t);
652
652
  break;
653
653
  case "cuid":
654
- z(r, ee.cuid, a.message, t);
654
+ W(r, X.cuid, a.message, t);
655
655
  break;
656
656
  case "cuid2":
657
- z(r, ee.cuid2, a.message, t);
657
+ W(r, X.cuid2, a.message, t);
658
658
  break;
659
659
  case "startsWith":
660
- z(
660
+ W(
661
661
  r,
662
- RegExp(`^${ot(a.value, t)}`),
662
+ RegExp(`^${nt(a.value, t)}`),
663
663
  a.message,
664
664
  t
665
665
  );
666
666
  break;
667
667
  case "endsWith":
668
- z(
668
+ W(
669
669
  r,
670
- RegExp(`${ot(a.value, t)}$`),
670
+ RegExp(`${nt(a.value, t)}$`),
671
671
  a.message,
672
672
  t
673
673
  );
674
674
  break;
675
675
  case "datetime":
676
- te(r, "date-time", a.message, t);
676
+ ee(r, "date-time", a.message, t);
677
677
  break;
678
678
  case "date":
679
- te(r, "date", a.message, t);
679
+ ee(r, "date", a.message, t);
680
680
  break;
681
681
  case "time":
682
- te(r, "time", a.message, t);
682
+ ee(r, "time", a.message, t);
683
683
  break;
684
684
  case "duration":
685
- te(r, "duration", a.message, t);
685
+ ee(r, "duration", a.message, t);
686
686
  break;
687
687
  case "length":
688
688
  r.minLength = typeof r.minLength == "number" ? Math.max(r.minLength, a.value) : a.value, r.maxLength = typeof r.maxLength == "number" ? Math.min(r.maxLength, a.value) : a.value;
689
689
  break;
690
690
  case "includes": {
691
- z(
691
+ W(
692
692
  r,
693
- RegExp(ot(a.value, t)),
693
+ RegExp(nt(a.value, t)),
694
694
  a.message,
695
695
  t
696
696
  );
697
697
  break;
698
698
  }
699
699
  case "ip": {
700
- a.version !== "v6" && te(r, "ipv4", a.message, t), a.version !== "v4" && te(r, "ipv6", a.message, t);
700
+ a.version !== "v6" && ee(r, "ipv4", a.message, t), a.version !== "v4" && ee(r, "ipv6", a.message, t);
701
701
  break;
702
702
  }
703
703
  case "base64url":
704
- z(r, ee.base64url, a.message, t);
704
+ W(r, X.base64url, a.message, t);
705
705
  break;
706
706
  case "jwt":
707
- z(r, ee.jwt, a.message, t);
707
+ W(r, X.jwt, a.message, t);
708
708
  break;
709
709
  case "cidr": {
710
- a.version !== "v6" && z(r, ee.ipv4Cidr, a.message, t), a.version !== "v4" && z(r, ee.ipv6Cidr, a.message, t);
710
+ a.version !== "v6" && W(r, X.ipv4Cidr, a.message, t), a.version !== "v4" && W(r, X.ipv6Cidr, a.message, t);
711
711
  break;
712
712
  }
713
713
  case "emoji":
714
- z(r, ee.emoji(), a.message, t);
714
+ W(r, X.emoji(), a.message, t);
715
715
  break;
716
716
  case "ulid": {
717
- z(r, ee.ulid, a.message, t);
717
+ W(r, X.ulid, a.message, t);
718
718
  break;
719
719
  }
720
720
  case "base64": {
721
721
  switch (t.base64Strategy) {
722
722
  case "format:binary": {
723
- te(r, "binary", a.message, t);
723
+ ee(r, "binary", a.message, t);
724
724
  break;
725
725
  }
726
726
  case "contentEncoding:base64": {
@@ -728,30 +728,30 @@ function mr(e, t) {
728
728
  break;
729
729
  }
730
730
  case "pattern:zod": {
731
- z(r, ee.base64, a.message, t);
731
+ W(r, X.base64, a.message, t);
732
732
  break;
733
733
  }
734
734
  }
735
735
  break;
736
736
  }
737
737
  case "nanoid":
738
- z(r, ee.nanoid, a.message, t);
738
+ W(r, X.nanoid, a.message, t);
739
739
  }
740
740
  return r;
741
741
  }
742
- function ot(e, t) {
743
- return t.patternStrategy === "escape" ? La(e) : e;
742
+ function nt(e, t) {
743
+ return t.patternStrategy === "escape" ? Na(e) : e;
744
744
  }
745
- var ka = new Set(
745
+ var Oa = new Set(
746
746
  "ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789"
747
747
  );
748
- function La(e) {
748
+ function Na(e) {
749
749
  let t = "";
750
750
  for (let r = 0; r < e.length; r++)
751
- ka.has(e[r]) || (t += "\\"), t += e[r];
751
+ Oa.has(e[r]) || (t += "\\"), t += e[r];
752
752
  return t;
753
753
  }
754
- function te(e, t, r, a) {
754
+ function ee(e, t, r, a) {
755
755
  var s;
756
756
  e.format || (s = e.anyOf) != null && s.some((i) => i.format) ? (e.anyOf || (e.anyOf = []), e.format && (e.anyOf.push({
757
757
  format: e.format
@@ -760,16 +760,16 @@ function te(e, t, r, a) {
760
760
  ...r && a.errorMessages && { errorMessage: { format: r } }
761
761
  })) : e.format = t;
762
762
  }
763
- function z(e, t, r, a) {
763
+ function W(e, t, r, a) {
764
764
  var s;
765
765
  e.pattern || (s = e.allOf) != null && s.some((i) => i.pattern) ? (e.allOf || (e.allOf = []), e.pattern && (e.allOf.push({
766
766
  pattern: e.pattern
767
767
  }), delete e.pattern), e.allOf.push({
768
- pattern: Vt(t, a),
768
+ pattern: Zt(t, a),
769
769
  ...r && a.errorMessages && { errorMessage: { pattern: r } }
770
- })) : e.pattern = Vt(t, a);
770
+ })) : e.pattern = Zt(t, a);
771
771
  }
772
- function Vt(e, t) {
772
+ function Zt(e, t) {
773
773
  var r;
774
774
  if (!t.applyRegexFlags || !e.flags)
775
775
  return e.source;
@@ -828,31 +828,31 @@ function Vt(e, t) {
828
828
  }
829
829
  return i;
830
830
  }
831
- function gr(e, t) {
831
+ function dr(e, t) {
832
832
  var r, a, s, i, l, n;
833
833
  const f = {
834
834
  type: "object",
835
- additionalProperties: (r = N(e.valueType._def, {
835
+ additionalProperties: (r = O(e.valueType._def, {
836
836
  ...t,
837
837
  currentPath: [...t.currentPath, "additionalProperties"]
838
838
  })) != null ? r : t.allowedAdditionalProperties
839
839
  };
840
- if (((a = e.keyType) == null ? void 0 : a._def.typeName) === R.ZodString && ((s = e.keyType._def.checks) != null && s.length)) {
841
- const { type: u, ...c } = mr(e.keyType._def, t);
840
+ if (((a = e.keyType) == null ? void 0 : a._def.typeName) === T.ZodString && ((s = e.keyType._def.checks) != null && s.length)) {
841
+ const { type: u, ...c } = cr(e.keyType._def, t);
842
842
  return {
843
843
  ...f,
844
844
  propertyNames: c
845
845
  };
846
846
  } else {
847
- if (((i = e.keyType) == null ? void 0 : i._def.typeName) === R.ZodEnum)
847
+ if (((i = e.keyType) == null ? void 0 : i._def.typeName) === T.ZodEnum)
848
848
  return {
849
849
  ...f,
850
850
  propertyNames: {
851
851
  enum: e.keyType._def.values
852
852
  }
853
853
  };
854
- if (((l = e.keyType) == null ? void 0 : l._def.typeName) === R.ZodBranded && e.keyType._def.type._def.typeName === R.ZodString && ((n = e.keyType._def.type._def.checks) != null && n.length)) {
855
- const { type: u, ...c } = pr(
854
+ if (((l = e.keyType) == null ? void 0 : l._def.typeName) === T.ZodBranded && e.keyType._def.type._def.typeName === T.ZodString && ((n = e.keyType._def.type._def.checks) != null && n.length)) {
855
+ const { type: u, ...c } = lr(
856
856
  e.keyType._def,
857
857
  t
858
858
  );
@@ -864,16 +864,16 @@ function gr(e, t) {
864
864
  }
865
865
  return f;
866
866
  }
867
- function Fa(e, t) {
867
+ function ja(e, t) {
868
868
  if (t.mapStrategy === "record")
869
- return gr(e, t);
870
- const r = N(e.keyType._def, {
869
+ return dr(e, t);
870
+ const r = O(e.keyType._def, {
871
871
  ...t,
872
872
  currentPath: [...t.currentPath, "items", "items", "0"]
873
- }) || Y(), a = N(e.valueType._def, {
873
+ }) || J(), a = O(e.valueType._def, {
874
874
  ...t,
875
875
  currentPath: [...t.currentPath, "items", "items", "1"]
876
- }) || Y();
876
+ }) || J();
877
877
  return {
878
878
  type: "array",
879
879
  maxItems: 125,
@@ -885,7 +885,7 @@ function Fa(e, t) {
885
885
  }
886
886
  };
887
887
  }
888
- function $a(e) {
888
+ function Da(e) {
889
889
  const t = e.values, a = Object.keys(e.values).filter((i) => typeof t[t[i]] != "number").map((i) => t[i]), s = Array.from(
890
890
  new Set(a.map((i) => typeof i))
891
891
  );
@@ -894,28 +894,28 @@ function $a(e) {
894
894
  enum: a
895
895
  };
896
896
  }
897
- function Ua() {
898
- return { not: Y() };
897
+ function ka() {
898
+ return { not: J() };
899
899
  }
900
- function qa() {
900
+ function La() {
901
901
  return {
902
902
  type: "null"
903
903
  };
904
904
  }
905
- var dt = {
905
+ var ut = {
906
906
  ZodString: "string",
907
907
  ZodNumber: "number",
908
908
  ZodBigInt: "integer",
909
909
  ZodBoolean: "boolean",
910
910
  ZodNull: "null"
911
911
  };
912
- function Za(e, t) {
912
+ function Fa(e, t) {
913
913
  const r = e.options instanceof Map ? Array.from(e.options.values()) : e.options;
914
914
  if (r.every(
915
- (a) => a._def.typeName in dt && (!a._def.checks || !a._def.checks.length)
915
+ (a) => a._def.typeName in ut && (!a._def.checks || !a._def.checks.length)
916
916
  )) {
917
917
  const a = r.reduce((s, i) => {
918
- const l = dt[i._def.typeName];
918
+ const l = ut[i._def.typeName];
919
919
  return l && !s.includes(l) ? [...s, l] : s;
920
920
  }, []);
921
921
  return {
@@ -964,11 +964,11 @@ function Za(e, t) {
964
964
  []
965
965
  )
966
966
  };
967
- return za(e, t);
967
+ return $a(e, t);
968
968
  }
969
- var za = (e, t) => {
969
+ var $a = (e, t) => {
970
970
  const r = (e.options instanceof Map ? Array.from(e.options.values()) : e.options).map(
971
- (a, s) => N(a._def, {
971
+ (a, s) => O(a._def, {
972
972
  ...t,
973
973
  currentPath: [...t.currentPath, "anyOf", `${s}`]
974
974
  })
@@ -977,23 +977,23 @@ var za = (e, t) => {
977
977
  );
978
978
  return r.length ? { anyOf: r } : void 0;
979
979
  };
980
- function Wa(e, t) {
980
+ function Ua(e, t) {
981
981
  if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(
982
982
  e.innerType._def.typeName
983
983
  ) && (!e.innerType._def.checks || !e.innerType._def.checks.length))
984
984
  return {
985
985
  type: [
986
- dt[e.innerType._def.typeName],
986
+ ut[e.innerType._def.typeName],
987
987
  "null"
988
988
  ]
989
989
  };
990
- const r = N(e.innerType._def, {
990
+ const r = O(e.innerType._def, {
991
991
  ...t,
992
992
  currentPath: [...t.currentPath, "anyOf", "0"]
993
993
  });
994
994
  return r && { anyOf: [r, { type: "null" }] };
995
995
  }
996
- function Ba(e) {
996
+ function qa(e) {
997
997
  const t = {
998
998
  type: "number"
999
999
  };
@@ -1015,7 +1015,7 @@ function Ba(e) {
1015
1015
  }
1016
1016
  return t;
1017
1017
  }
1018
- function Va(e, t) {
1018
+ function Za(e, t) {
1019
1019
  const r = {
1020
1020
  type: "object",
1021
1021
  properties: {}
@@ -1024,7 +1024,7 @@ function Va(e, t) {
1024
1024
  let n = s[l];
1025
1025
  if (n === void 0 || n._def === void 0)
1026
1026
  continue;
1027
- const f = Ka(n), u = N(n._def, {
1027
+ const f = Wa(n), u = O(n._def, {
1028
1028
  ...t,
1029
1029
  currentPath: [...t.currentPath, "properties", l],
1030
1030
  propertyPath: [...t.currentPath, "properties", l]
@@ -1032,12 +1032,12 @@ function Va(e, t) {
1032
1032
  u !== void 0 && (r.properties[l] = u, f || a.push(l));
1033
1033
  }
1034
1034
  a.length && (r.required = a);
1035
- const i = Ja(e, t);
1035
+ const i = za(e, t);
1036
1036
  return i !== void 0 && (r.additionalProperties = i), r;
1037
1037
  }
1038
- function Ja(e, t) {
1038
+ function za(e, t) {
1039
1039
  if (e.catchall._def.typeName !== "ZodNever")
1040
- return N(e.catchall._def, {
1040
+ return O(e.catchall._def, {
1041
1041
  ...t,
1042
1042
  currentPath: [...t.currentPath, "additionalProperties"]
1043
1043
  });
@@ -1050,31 +1050,31 @@ function Ja(e, t) {
1050
1050
  return t.removeAdditionalStrategy === "strict" ? t.allowedAdditionalProperties : t.rejectedAdditionalProperties;
1051
1051
  }
1052
1052
  }
1053
- function Ka(e) {
1053
+ function Wa(e) {
1054
1054
  try {
1055
1055
  return e.isOptional();
1056
1056
  } catch {
1057
1057
  return !0;
1058
1058
  }
1059
1059
  }
1060
- var Ya = (e, t) => {
1060
+ var Ba = (e, t) => {
1061
1061
  var r;
1062
1062
  if (t.currentPath.toString() === ((r = t.propertyPath) == null ? void 0 : r.toString()))
1063
- return N(e.innerType._def, t);
1064
- const a = N(e.innerType._def, {
1063
+ return O(e.innerType._def, t);
1064
+ const a = O(e.innerType._def, {
1065
1065
  ...t,
1066
1066
  currentPath: [...t.currentPath, "anyOf", "1"]
1067
1067
  });
1068
- return a ? { anyOf: [{ not: Y() }, a] } : Y();
1069
- }, Ha = (e, t) => {
1068
+ return a ? { anyOf: [{ not: J() }, a] } : J();
1069
+ }, Va = (e, t) => {
1070
1070
  if (t.pipeStrategy === "input")
1071
- return N(e.in._def, t);
1071
+ return O(e.in._def, t);
1072
1072
  if (t.pipeStrategy === "output")
1073
- return N(e.out._def, t);
1074
- const r = N(e.in._def, {
1073
+ return O(e.out._def, t);
1074
+ const r = O(e.in._def, {
1075
1075
  ...t,
1076
1076
  currentPath: [...t.currentPath, "allOf", "0"]
1077
- }), a = N(e.out._def, {
1077
+ }), a = O(e.out._def, {
1078
1078
  ...t,
1079
1079
  currentPath: [...t.currentPath, "allOf", r ? "1" : "0"]
1080
1080
  });
@@ -1084,26 +1084,26 @@ var Ya = (e, t) => {
1084
1084
  )
1085
1085
  };
1086
1086
  };
1087
- function Ga(e, t) {
1088
- return N(e.type._def, t);
1087
+ function Ja(e, t) {
1088
+ return O(e.type._def, t);
1089
1089
  }
1090
- function Qa(e, t) {
1090
+ function Ka(e, t) {
1091
1091
  const a = {
1092
1092
  type: "array",
1093
1093
  uniqueItems: !0,
1094
- items: N(e.valueType._def, {
1094
+ items: O(e.valueType._def, {
1095
1095
  ...t,
1096
1096
  currentPath: [...t.currentPath, "items"]
1097
1097
  })
1098
1098
  };
1099
1099
  return e.minSize && (a.minItems = e.minSize.value), e.maxSize && (a.maxItems = e.maxSize.value), a;
1100
1100
  }
1101
- function Xa(e, t) {
1101
+ function Ya(e, t) {
1102
1102
  return e.rest ? {
1103
1103
  type: "array",
1104
1104
  minItems: e.items.length,
1105
1105
  items: e.items.map(
1106
- (r, a) => N(r._def, {
1106
+ (r, a) => O(r._def, {
1107
1107
  ...t,
1108
1108
  currentPath: [...t.currentPath, "items", `${a}`]
1109
1109
  })
@@ -1111,7 +1111,7 @@ function Xa(e, t) {
1111
1111
  (r, a) => a === void 0 ? r : [...r, a],
1112
1112
  []
1113
1113
  ),
1114
- additionalItems: N(e.rest._def, {
1114
+ additionalItems: O(e.rest._def, {
1115
1115
  ...t,
1116
1116
  currentPath: [...t.currentPath, "additionalItems"]
1117
1117
  })
@@ -1120,7 +1120,7 @@ function Xa(e, t) {
1120
1120
  minItems: e.items.length,
1121
1121
  maxItems: e.items.length,
1122
1122
  items: e.items.map(
1123
- (r, a) => N(r._def, {
1123
+ (r, a) => O(r._def, {
1124
1124
  ...t,
1125
1125
  currentPath: [...t.currentPath, "items", `${a}`]
1126
1126
  })
@@ -1130,95 +1130,95 @@ function Xa(e, t) {
1130
1130
  )
1131
1131
  };
1132
1132
  }
1133
- function es() {
1133
+ function Ha() {
1134
1134
  return {
1135
- not: Y()
1135
+ not: J()
1136
1136
  };
1137
1137
  }
1138
- function ts() {
1139
- return Y();
1138
+ function Ga() {
1139
+ return J();
1140
1140
  }
1141
- var rs = (e, t) => N(e.innerType._def, t), as = (e, t, r) => {
1141
+ var Qa = (e, t) => O(e.innerType._def, t), Xa = (e, t, r) => {
1142
1142
  switch (t) {
1143
- case R.ZodString:
1144
- return mr(e, r);
1145
- case R.ZodNumber:
1146
- return Ba(e);
1147
- case R.ZodObject:
1148
- return Va(e, r);
1149
- case R.ZodBigInt:
1150
- return xa(e);
1151
- case R.ZodBoolean:
1152
- return Aa();
1153
- case R.ZodDate:
1154
- return fr(e, r);
1155
- case R.ZodUndefined:
1156
- return es();
1157
- case R.ZodNull:
1158
- return qa();
1159
- case R.ZodArray:
1160
- return _a(e, r);
1161
- case R.ZodUnion:
1162
- case R.ZodDiscriminatedUnion:
1143
+ case T.ZodString:
1144
+ return cr(e, r);
1145
+ case T.ZodNumber:
1146
+ return qa(e);
1147
+ case T.ZodObject:
1163
1148
  return Za(e, r);
1164
- case R.ZodIntersection:
1165
- return ja(e, r);
1166
- case R.ZodTuple:
1167
- return Xa(e, r);
1168
- case R.ZodRecord:
1169
- return gr(e, r);
1170
- case R.ZodLiteral:
1171
- return Da(e);
1172
- case R.ZodEnum:
1173
- return Oa(e);
1174
- case R.ZodNativeEnum:
1175
- return $a(e);
1176
- case R.ZodNullable:
1177
- return Wa(e, r);
1178
- case R.ZodOptional:
1179
- return Ya(e, r);
1180
- case R.ZodMap:
1149
+ case T.ZodBigInt:
1150
+ return Ca(e);
1151
+ case T.ZodBoolean:
1152
+ return Ia();
1153
+ case T.ZodDate:
1154
+ return ur(e, r);
1155
+ case T.ZodUndefined:
1156
+ return Ha();
1157
+ case T.ZodNull:
1158
+ return La();
1159
+ case T.ZodArray:
1160
+ return Ea(e, r);
1161
+ case T.ZodUnion:
1162
+ case T.ZodDiscriminatedUnion:
1181
1163
  return Fa(e, r);
1182
- case R.ZodSet:
1183
- return Qa(e, r);
1184
- case R.ZodLazy:
1185
- return () => e.getter()._def;
1186
- case R.ZodPromise:
1187
- return Ga(e, r);
1188
- case R.ZodNaN:
1189
- case R.ZodNever:
1190
- return Ua();
1191
- case R.ZodEffects:
1192
- return Pa(e, r);
1193
- case R.ZodAny:
1194
- return Y();
1195
- case R.ZodUnknown:
1196
- return ts();
1197
- case R.ZodDefault:
1164
+ case T.ZodIntersection:
1198
1165
  return Ra(e, r);
1199
- case R.ZodBranded:
1200
- return pr(e, r);
1201
- case R.ZodReadonly:
1202
- return rs(e, r);
1203
- case R.ZodCatch:
1204
- return Ma(e, r);
1205
- case R.ZodPipeline:
1206
- return Ha(e, r);
1207
- case R.ZodFunction:
1208
- case R.ZodVoid:
1209
- case R.ZodSymbol:
1166
+ case T.ZodTuple:
1167
+ return Ya(e, r);
1168
+ case T.ZodRecord:
1169
+ return dr(e, r);
1170
+ case T.ZodLiteral:
1171
+ return Pa(e);
1172
+ case T.ZodEnum:
1173
+ return Ma(e);
1174
+ case T.ZodNativeEnum:
1175
+ return Da(e);
1176
+ case T.ZodNullable:
1177
+ return Ua(e, r);
1178
+ case T.ZodOptional:
1179
+ return Ba(e, r);
1180
+ case T.ZodMap:
1181
+ return ja(e, r);
1182
+ case T.ZodSet:
1183
+ return Ka(e, r);
1184
+ case T.ZodLazy:
1185
+ return () => e.getter()._def;
1186
+ case T.ZodPromise:
1187
+ return Ja(e, r);
1188
+ case T.ZodNaN:
1189
+ case T.ZodNever:
1190
+ return ka();
1191
+ case T.ZodEffects:
1192
+ return Aa(e, r);
1193
+ case T.ZodAny:
1194
+ return J();
1195
+ case T.ZodUnknown:
1196
+ return Ga();
1197
+ case T.ZodDefault:
1198
+ return xa(e, r);
1199
+ case T.ZodBranded:
1200
+ return lr(e, r);
1201
+ case T.ZodReadonly:
1202
+ return Qa(e, r);
1203
+ case T.ZodCatch:
1204
+ return wa(e, r);
1205
+ case T.ZodPipeline:
1206
+ return Va(e, r);
1207
+ case T.ZodFunction:
1208
+ case T.ZodVoid:
1209
+ case T.ZodSymbol:
1210
1210
  return;
1211
1211
  default:
1212
1212
  return /* @__PURE__ */ ((a) => {
1213
1213
  })();
1214
1214
  }
1215
- }, ss = (e, t) => {
1215
+ }, es = (e, t) => {
1216
1216
  let r = 0;
1217
1217
  for (; r < e.length && r < t.length && e[r] === t[r]; r++)
1218
1218
  ;
1219
1219
  return [(e.length - r).toString(), ...t.slice(r)].join("/");
1220
1220
  };
1221
- function N(e, t, r = !1) {
1221
+ function O(e, t, r = !1) {
1222
1222
  var a;
1223
1223
  const s = t.seen.get(e);
1224
1224
  if (t.override) {
@@ -1229,39 +1229,39 @@ function N(e, t, r = !1) {
1229
1229
  s,
1230
1230
  r
1231
1231
  );
1232
- if (f !== Ia)
1232
+ if (f !== ba)
1233
1233
  return f;
1234
1234
  }
1235
1235
  if (s && !r) {
1236
- const f = ns(s, t);
1236
+ const f = ts(s, t);
1237
1237
  if (f !== void 0)
1238
1238
  return f;
1239
1239
  }
1240
1240
  const i = { def: e, path: t.currentPath, jsonSchema: void 0 };
1241
1241
  t.seen.set(e, i);
1242
- const l = as(e, e.typeName, t), n = typeof l == "function" ? N(l(), t) : l;
1243
- if (n && is(e, t, n), t.postProcess) {
1242
+ const l = Xa(e, e.typeName, t), n = typeof l == "function" ? O(l(), t) : l;
1243
+ if (n && rs(e, t, n), t.postProcess) {
1244
1244
  const f = t.postProcess(n, e, t);
1245
1245
  return i.jsonSchema = n, f;
1246
1246
  }
1247
1247
  return i.jsonSchema = n, n;
1248
1248
  }
1249
- var ns = (e, t) => {
1249
+ var ts = (e, t) => {
1250
1250
  switch (t.$refStrategy) {
1251
1251
  case "root":
1252
1252
  return { $ref: e.path.join("/") };
1253
1253
  case "relative":
1254
- return { $ref: ss(t.currentPath, e.path) };
1254
+ return { $ref: es(t.currentPath, e.path) };
1255
1255
  case "none":
1256
1256
  case "seen":
1257
1257
  return e.path.length < t.currentPath.length && e.path.every((r, a) => t.currentPath[a] === r) ? (console.warn(
1258
1258
  `Recursive reference detected at ${t.currentPath.join(
1259
1259
  "/"
1260
1260
  )}! Defaulting to any`
1261
- ), Y()) : t.$refStrategy === "seen" ? Y() : void 0;
1261
+ ), J()) : t.$refStrategy === "seen" ? J() : void 0;
1262
1262
  }
1263
- }, is = (e, t, r) => (e.description && (r.description = e.description), r), os = (e) => {
1264
- const t = wa(e), r = t.name !== void 0 ? [...t.basePath, t.definitionPath, t.name] : t.basePath;
1263
+ }, rs = (e, t, r) => (e.description && (r.description = e.description), r), as = (e) => {
1264
+ const t = Sa(e), r = t.name !== void 0 ? [...t.basePath, t.definitionPath, t.name] : t.basePath;
1265
1265
  return {
1266
1266
  ...t,
1267
1267
  currentPath: r,
@@ -1278,34 +1278,34 @@ var ns = (e, t) => {
1278
1278
  ])
1279
1279
  )
1280
1280
  };
1281
- }, ls = (e, t) => {
1281
+ }, ss = (e, t) => {
1282
1282
  var r;
1283
- const a = os(t);
1283
+ const a = as(t);
1284
1284
  let s = typeof t == "object" && t.definitions ? Object.entries(t.definitions).reduce(
1285
1285
  (u, [c, p]) => {
1286
1286
  var v;
1287
1287
  return {
1288
1288
  ...u,
1289
- [c]: (v = N(
1289
+ [c]: (v = O(
1290
1290
  p._def,
1291
1291
  {
1292
1292
  ...a,
1293
1293
  currentPath: [...a.basePath, a.definitionPath, c]
1294
1294
  },
1295
1295
  !0
1296
- )) != null ? v : Y()
1296
+ )) != null ? v : J()
1297
1297
  };
1298
1298
  },
1299
1299
  {}
1300
1300
  ) : void 0;
1301
- const i = typeof t == "string" ? t : (t == null ? void 0 : t.nameStrategy) === "title" || t == null ? void 0 : t.name, l = (r = N(
1301
+ const i = typeof t == "string" ? t : (t == null ? void 0 : t.nameStrategy) === "title" || t == null ? void 0 : t.name, l = (r = O(
1302
1302
  e._def,
1303
1303
  i === void 0 ? a : {
1304
1304
  ...a,
1305
1305
  currentPath: [...a.basePath, a.definitionPath, i]
1306
1306
  },
1307
1307
  !1
1308
- )) != null ? r : Y(), n = typeof t == "object" && t.name !== void 0 && t.nameStrategy === "title" ? t.name : void 0;
1308
+ )) != null ? r : J(), n = typeof t == "object" && t.name !== void 0 && t.nameStrategy === "title" ? t.name : void 0;
1309
1309
  n !== void 0 && (l.title = n);
1310
1310
  const f = i === void 0 ? s ? {
1311
1311
  ...l,
@@ -1322,16 +1322,16 @@ var ns = (e, t) => {
1322
1322
  }
1323
1323
  };
1324
1324
  return f.$schema = "http://json-schema.org/draft-07/schema#", f;
1325
- }, pt = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
1326
- function us(e) {
1325
+ }, ct = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
1326
+ function ns(e) {
1327
1327
  let t;
1328
1328
  return () => (t == null && (t = e()), t);
1329
1329
  }
1330
- function Qe(e, {
1330
+ function Ge(e, {
1331
1331
  validate: t
1332
1332
  } = {}) {
1333
1333
  return {
1334
- [pt]: !0,
1334
+ [ct]: !0,
1335
1335
  _type: void 0,
1336
1336
  // should never be used directly
1337
1337
  get jsonSchema() {
@@ -1340,24 +1340,24 @@ function Qe(e, {
1340
1340
  validate: t
1341
1341
  };
1342
1342
  }
1343
- function cs(e) {
1344
- return typeof e == "object" && e !== null && pt in e && e[pt] === !0 && "jsonSchema" in e && "validate" in e;
1343
+ function is(e) {
1344
+ return typeof e == "object" && e !== null && ct in e && e[ct] === !0 && "jsonSchema" in e && "validate" in e;
1345
1345
  }
1346
- function yt(e) {
1347
- return e == null ? Qe({
1346
+ function ht(e) {
1347
+ return e == null ? Ge({
1348
1348
  type: "object",
1349
1349
  properties: {},
1350
1350
  additionalProperties: !1
1351
- }) : cs(e) ? e : "~standard" in e ? e["~standard"].vendor === "zod" ? hr(e) : ds(e) : e();
1351
+ }) : is(e) ? e : "~standard" in e ? e["~standard"].vendor === "zod" ? pr(e) : os(e) : e();
1352
1352
  }
1353
- function ds(e) {
1354
- return Qe(
1353
+ function os(e) {
1354
+ return Ge(
1355
1355
  () => {
1356
- if (!ps(e))
1356
+ if (!ls(e))
1357
1357
  throw new Error(
1358
1358
  `Standard schema vendor '${e["~standard"].vendor}' does not support JSON Schema conversion.`
1359
1359
  );
1360
- return vt(
1360
+ return gt(
1361
1361
  e["~standard"].jsonSchema.input({
1362
1362
  target: "draft-07"
1363
1363
  })
@@ -1368,7 +1368,7 @@ function ds(e) {
1368
1368
  const r = await e["~standard"].validate(t);
1369
1369
  return "value" in r ? { success: !0, value: r.value } : {
1370
1370
  success: !1,
1371
- error: new Me({
1371
+ error: new Ae({
1372
1372
  value: t,
1373
1373
  cause: r.issues
1374
1374
  })
@@ -1377,15 +1377,15 @@ function ds(e) {
1377
1377
  }
1378
1378
  );
1379
1379
  }
1380
- function ps(e) {
1380
+ function ls(e) {
1381
1381
  return e["~standard"].jsonSchema != null;
1382
1382
  }
1383
- function fs(e, t) {
1383
+ function us(e, t) {
1384
1384
  var r;
1385
1385
  const a = (r = void 0) != null ? r : !1;
1386
- return Qe(
1386
+ return Ge(
1387
1387
  // defer json schema creation to avoid unnecessary computation when only validation is needed
1388
- () => ls(e, {
1388
+ () => ss(e, {
1389
1389
  $refStrategy: a ? "root" : "none"
1390
1390
  }),
1391
1391
  {
@@ -1396,13 +1396,13 @@ function fs(e, t) {
1396
1396
  }
1397
1397
  );
1398
1398
  }
1399
- function ms(e, t) {
1399
+ function cs(e, t) {
1400
1400
  var r;
1401
1401
  const a = (r = void 0) != null ? r : !1;
1402
- return Qe(
1402
+ return Ge(
1403
1403
  // defer json schema creation to avoid unnecessary computation when only validation is needed
1404
- () => vt(
1405
- Pt.toJSONSchema(e, {
1404
+ () => gt(
1405
+ At.toJSONSchema(e, {
1406
1406
  target: "draft-7",
1407
1407
  io: "input",
1408
1408
  reused: a ? "ref" : "inline"
@@ -1410,26 +1410,26 @@ function ms(e, t) {
1410
1410
  ),
1411
1411
  {
1412
1412
  validate: async (s) => {
1413
- const i = await Pt.safeParseAsync(e, s);
1413
+ const i = await At.safeParseAsync(e, s);
1414
1414
  return i.success ? { success: !0, value: i.data } : { success: !1, error: i.error };
1415
1415
  }
1416
1416
  }
1417
1417
  );
1418
1418
  }
1419
- function gs(e) {
1419
+ function ds(e) {
1420
1420
  return "_zod" in e;
1421
1421
  }
1422
- function hr(e, t) {
1423
- return gs(e) ? ms(e) : fs(e);
1422
+ function pr(e, t) {
1423
+ return ds(e) ? cs(e) : us(e);
1424
1424
  }
1425
- async function Jt({
1425
+ async function zt({
1426
1426
  value: e,
1427
1427
  schema: t,
1428
1428
  context: r
1429
1429
  }) {
1430
1430
  const a = await Le({ value: e, schema: t, context: r });
1431
1431
  if (!a.success)
1432
- throw Me.wrap({ value: e, cause: a.error, context: r });
1432
+ throw Ae.wrap({ value: e, cause: a.error, context: r });
1433
1433
  return a.value;
1434
1434
  }
1435
1435
  async function Le({
@@ -1437,20 +1437,20 @@ async function Le({
1437
1437
  schema: t,
1438
1438
  context: r
1439
1439
  }) {
1440
- const a = yt(t);
1440
+ const a = ht(t);
1441
1441
  try {
1442
1442
  if (a.validate == null)
1443
1443
  return { success: !0, value: e, rawValue: e };
1444
1444
  const s = await a.validate(e);
1445
1445
  return s.success ? { success: !0, value: s.value, rawValue: e } : {
1446
1446
  success: !1,
1447
- error: Me.wrap({ value: e, cause: s.error, context: r }),
1447
+ error: Ae.wrap({ value: e, cause: s.error, context: r }),
1448
1448
  rawValue: e
1449
1449
  };
1450
1450
  } catch (s) {
1451
1451
  return {
1452
1452
  success: !1,
1453
- error: Me.wrap({ value: e, cause: s, context: r }),
1453
+ error: Ae.wrap({ value: e, cause: s, context: r }),
1454
1454
  rawValue: e
1455
1455
  };
1456
1456
  }
@@ -1460,21 +1460,21 @@ async function ye({
1460
1460
  schema: t
1461
1461
  }) {
1462
1462
  try {
1463
- const r = Ca(e);
1463
+ const r = ya(e);
1464
1464
  return t == null ? { success: !0, value: r, rawValue: r } : await Le({ value: r, schema: t });
1465
1465
  } catch (r) {
1466
1466
  return {
1467
1467
  success: !1,
1468
- error: Ft.isInstance(r) ? r : new Ft({ text: e, cause: r }),
1468
+ error: jt.isInstance(r) ? r : new jt({ text: e, cause: r }),
1469
1469
  rawValue: void 0
1470
1470
  };
1471
1471
  }
1472
1472
  }
1473
- function hs({
1473
+ function ps({
1474
1474
  stream: e,
1475
1475
  schema: t
1476
1476
  }) {
1477
- return e.pipeThrough(new TextDecoderStream()).pipeThrough(new ha()).pipeThrough(
1477
+ return e.pipeThrough(new TextDecoderStream()).pipeThrough(new pa()).pipeThrough(
1478
1478
  new TransformStream({
1479
1479
  async transform({ data: r }, a) {
1480
1480
  r !== "[DONE]" && a.enqueue(await ye({ text: r, schema: t }));
@@ -1482,17 +1482,17 @@ function hs({
1482
1482
  })
1483
1483
  );
1484
1484
  }
1485
- async function de(e) {
1485
+ async function pe(e) {
1486
1486
  return typeof e == "function" && (e = e()), Promise.resolve(e);
1487
1487
  }
1488
1488
  new TextDecoder();
1489
- function vs(e) {
1489
+ function fs(e) {
1490
1490
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
1491
1491
  }
1492
- var ys = Object.defineProperty, bs = (e, t) => {
1492
+ var ms = Object.defineProperty, gs = (e, t) => {
1493
1493
  for (var r in t)
1494
- ys(e, r, { get: t[r], enumerable: !0 });
1495
- }, vr = "AI_NoObjectGeneratedError", yr = `vercel.ai.error.${vr}`, Ss = Symbol.for(yr), br, pe = class extends se {
1494
+ ms(e, r, { get: t[r], enumerable: !0 });
1495
+ }, fr = "AI_NoObjectGeneratedError", mr = `vercel.ai.error.${fr}`, hs = Symbol.for(mr), gr, fe = class extends ae {
1496
1496
  constructor({
1497
1497
  message: e = "No object generated.",
1498
1498
  cause: t,
@@ -1501,26 +1501,26 @@ var ys = Object.defineProperty, bs = (e, t) => {
1501
1501
  usage: s,
1502
1502
  finishReason: i
1503
1503
  }) {
1504
- super({ name: vr, message: e, cause: t }), this[br] = !0, this.text = r, this.response = a, this.usage = s, this.finishReason = i;
1504
+ super({ name: fr, message: e, cause: t }), this[gr] = !0, this.text = r, this.response = a, this.usage = s, this.finishReason = i;
1505
1505
  }
1506
1506
  static isInstance(e) {
1507
- return se.hasMarker(e, yr);
1507
+ return ae.hasMarker(e, mr);
1508
1508
  }
1509
1509
  };
1510
- br = Ss;
1511
- var Sr = "AI_UIMessageStreamError", Er = `vercel.ai.error.${Sr}`, Es = Symbol.for(Er), Cr, ve = class extends se {
1510
+ gr = hs;
1511
+ var hr = "AI_UIMessageStreamError", vr = `vercel.ai.error.${hr}`, vs = Symbol.for(vr), yr, ve = class extends ae {
1512
1512
  constructor({
1513
1513
  chunkType: e,
1514
1514
  chunkId: t,
1515
1515
  message: r
1516
1516
  }) {
1517
- super({ name: Sr, message: r }), this[Cr] = !0, this.chunkType = e, this.chunkId = t;
1517
+ super({ name: hr, message: r }), this[yr] = !0, this.chunkType = e, this.chunkId = t;
1518
1518
  }
1519
1519
  static isInstance(e) {
1520
- return se.hasMarker(e, Er);
1520
+ return ae.hasMarker(e, vr);
1521
1521
  }
1522
1522
  };
1523
- Cr = Es;
1523
+ yr = vs;
1524
1524
  var be = o.lazy(
1525
1525
  () => o.union([
1526
1526
  o.null(),
@@ -1537,67 +1537,67 @@ var be = o.lazy(
1537
1537
  o.string(),
1538
1538
  o.instanceof(Uint8Array),
1539
1539
  o.instanceof(ArrayBuffer),
1540
- o.custom(ya, { message: "Must be a Buffer" })
1541
- ]), bt = o.record(o.string(), o.string()), Ir = o.object({
1540
+ o.custom(ma, { message: "Must be a Buffer" })
1541
+ ]), vt = o.record(o.string(), o.string()), br = o.object({
1542
1542
  type: o.literal("text"),
1543
1543
  text: o.string(),
1544
1544
  providerOptions: A.optional()
1545
- }), Cs = o.object({
1545
+ }), ys = o.object({
1546
1546
  type: o.literal("image"),
1547
1547
  image: o.union([
1548
1548
  Ue,
1549
1549
  o.instanceof(URL),
1550
- bt
1550
+ vt
1551
1551
  ]),
1552
1552
  mediaType: o.string().optional(),
1553
1553
  providerOptions: A.optional()
1554
- }), wr = o.discriminatedUnion("type", [
1554
+ }), Sr = o.discriminatedUnion("type", [
1555
1555
  o.object({ type: o.literal("data"), data: Ue }),
1556
1556
  o.object({ type: o.literal("url"), url: o.instanceof(URL) }),
1557
1557
  o.object({
1558
1558
  type: o.literal("reference"),
1559
- reference: bt
1559
+ reference: vt
1560
1560
  }),
1561
1561
  o.object({ type: o.literal("text"), text: o.string() })
1562
- ]), Is = o.discriminatedUnion("type", [
1562
+ ]), bs = o.discriminatedUnion("type", [
1563
1563
  o.object({ type: o.literal("data"), data: Ue }),
1564
1564
  o.object({ type: o.literal("url"), url: o.instanceof(URL) })
1565
- ]), _r = o.object({
1565
+ ]), Er = o.object({
1566
1566
  type: o.literal("file"),
1567
1567
  data: o.union([
1568
- wr,
1568
+ Sr,
1569
1569
  Ue,
1570
1570
  o.instanceof(URL),
1571
- bt
1571
+ vt
1572
1572
  ]),
1573
1573
  filename: o.string().optional(),
1574
1574
  mediaType: o.string(),
1575
1575
  providerOptions: A.optional()
1576
- }), ws = o.object({
1576
+ }), Ss = o.object({
1577
1577
  type: o.literal("reasoning"),
1578
1578
  text: o.string(),
1579
1579
  providerOptions: A.optional()
1580
- }), _s = o.object({
1580
+ }), Es = o.object({
1581
1581
  type: o.literal("custom"),
1582
1582
  kind: o.string().transform((e) => e),
1583
1583
  providerOptions: A.optional()
1584
- }), xs = o.object({
1584
+ }), Cs = o.object({
1585
1585
  type: o.literal("reasoning-file"),
1586
1586
  data: o.union([
1587
- Is,
1587
+ bs,
1588
1588
  Ue,
1589
1589
  o.instanceof(URL)
1590
1590
  ]),
1591
1591
  mediaType: o.string(),
1592
1592
  providerOptions: A.optional()
1593
- }), As = o.object({
1593
+ }), Is = o.object({
1594
1594
  type: o.literal("tool-call"),
1595
1595
  toolCallId: o.string(),
1596
1596
  toolName: o.string(),
1597
1597
  input: o.unknown(),
1598
1598
  providerOptions: A.optional(),
1599
1599
  providerExecuted: o.boolean().optional()
1600
- }), Ms = o.discriminatedUnion(
1600
+ }), ws = o.discriminatedUnion(
1601
1601
  "type",
1602
1602
  [
1603
1603
  o.object({
@@ -1636,7 +1636,7 @@ var be = o.lazy(
1636
1636
  }),
1637
1637
  o.object({
1638
1638
  type: o.literal("file"),
1639
- data: wr,
1639
+ data: Sr,
1640
1640
  mediaType: o.string(),
1641
1641
  filename: o.string().optional(),
1642
1642
  providerOptions: A.optional()
@@ -1701,64 +1701,64 @@ var be = o.lazy(
1701
1701
  )
1702
1702
  })
1703
1703
  ]
1704
- ), xr = o.object({
1704
+ ), Cr = o.object({
1705
1705
  type: o.literal("tool-result"),
1706
1706
  toolCallId: o.string(),
1707
1707
  toolName: o.string(),
1708
- output: Ms,
1708
+ output: ws,
1709
1709
  providerOptions: A.optional()
1710
- }), Ts = o.object({
1710
+ }), _s = o.object({
1711
1711
  type: o.literal("tool-approval-request"),
1712
1712
  approvalId: o.string(),
1713
1713
  toolCallId: o.string()
1714
- }), Rs = o.object({
1714
+ }), xs = o.object({
1715
1715
  type: o.literal("tool-approval-response"),
1716
1716
  approvalId: o.string(),
1717
1717
  approved: o.boolean(),
1718
1718
  reason: o.string().optional()
1719
- }), Ps = o.object(
1719
+ }), As = o.object(
1720
1720
  {
1721
1721
  role: o.literal("system"),
1722
1722
  content: o.string(),
1723
1723
  providerOptions: A.optional()
1724
1724
  }
1725
- ), Os = o.object({
1725
+ ), Ms = o.object({
1726
1726
  role: o.literal("user"),
1727
1727
  content: o.union([
1728
1728
  o.string(),
1729
- o.array(o.union([Ir, Cs, _r]))
1729
+ o.array(o.union([br, ys, Er]))
1730
1730
  ]),
1731
1731
  providerOptions: A.optional()
1732
- }), Ns = o.object({
1732
+ }), Ts = o.object({
1733
1733
  role: o.literal("assistant"),
1734
1734
  content: o.union([
1735
1735
  o.string(),
1736
1736
  o.array(
1737
1737
  o.union([
1738
- Ir,
1739
- _s,
1740
- _r,
1741
- ws,
1742
- xs,
1743
- As,
1744
- xr,
1745
- Ts
1738
+ br,
1739
+ Es,
1740
+ Er,
1741
+ Ss,
1742
+ Cs,
1743
+ Is,
1744
+ Cr,
1745
+ _s
1746
1746
  ])
1747
1747
  )
1748
1748
  ]),
1749
1749
  providerOptions: A.optional()
1750
- }), js = o.object({
1750
+ }), Rs = o.object({
1751
1751
  role: o.literal("tool"),
1752
- content: o.array(o.union([xr, Rs])),
1752
+ content: o.array(o.union([Cr, xs])),
1753
1753
  providerOptions: A.optional()
1754
1754
  });
1755
1755
  o.union([
1756
- Ps,
1757
- Os,
1758
- Ns,
1759
- js
1756
+ As,
1757
+ Ms,
1758
+ Ts,
1759
+ Rs
1760
1760
  ]);
1761
- function Ar(e, t) {
1761
+ function Ir(e, t) {
1762
1762
  if (e === void 0 && t === void 0)
1763
1763
  return;
1764
1764
  if (e === void 0)
@@ -1772,22 +1772,22 @@ function Ar(e, t) {
1772
1772
  if (s === void 0)
1773
1773
  continue;
1774
1774
  const i = a in e ? e[a] : void 0, l = s !== null && typeof s == "object" && !Array.isArray(s) && !(s instanceof Date) && !(s instanceof RegExp), n = i != null && typeof i == "object" && !Array.isArray(i) && !(i instanceof Date) && !(i instanceof RegExp);
1775
- l && n ? r[a] = Ar(
1775
+ l && n ? r[a] = Ir(
1776
1776
  i,
1777
1777
  s
1778
1778
  ) : r[a] = s;
1779
1779
  }
1780
1780
  return r;
1781
1781
  }
1782
- var Ds = {};
1783
- bs(Ds, {
1784
- array: () => $s,
1785
- choice: () => Us,
1786
- json: () => qs,
1787
- object: () => Fs,
1788
- text: () => Ls
1782
+ var Ps = {};
1783
+ gs(Ps, {
1784
+ array: () => Ds,
1785
+ choice: () => ks,
1786
+ json: () => Ls,
1787
+ object: () => js,
1788
+ text: () => Ns
1789
1789
  });
1790
- function ks(e) {
1790
+ function Os(e) {
1791
1791
  const t = ["ROOT"];
1792
1792
  let r = -1, a = null, s = 0;
1793
1793
  function i(c) {
@@ -2046,9 +2046,9 @@ async function qe(e) {
2046
2046
  if (e === void 0)
2047
2047
  return { value: void 0, state: "undefined-input" };
2048
2048
  let t = await ye({ text: e });
2049
- return t.success ? { value: t.value, state: "successful-parse" } : (t = await ye({ text: ks(e) }), t.success ? { value: t.value, state: "repaired-parse" } : { value: void 0, state: "failed-parse" });
2049
+ return t.success ? { value: t.value, state: "successful-parse" } : (t = await ye({ text: Os(e) }), t.success ? { value: t.value, state: "repaired-parse" } : { value: void 0, state: "failed-parse" });
2050
2050
  }
2051
- var Ls = () => ({
2051
+ var Ns = () => ({
2052
2052
  name: "text",
2053
2053
  responseFormat: Promise.resolve({ type: "text" }),
2054
2054
  async parseCompleteOutput({ text: e }) {
@@ -2059,15 +2059,15 @@ var Ls = () => ({
2059
2059
  },
2060
2060
  createElementStreamTransform() {
2061
2061
  }
2062
- }), Fs = ({
2062
+ }), js = ({
2063
2063
  schema: e,
2064
2064
  name: t,
2065
2065
  description: r
2066
2066
  }) => {
2067
- const a = yt(e);
2067
+ const a = ht(e);
2068
2068
  return {
2069
2069
  name: "object",
2070
- responseFormat: de(a.jsonSchema).then((s) => ({
2070
+ responseFormat: pe(a.jsonSchema).then((s) => ({
2071
2071
  type: "json",
2072
2072
  schema: s,
2073
2073
  ...t != null && { name: t },
@@ -2076,7 +2076,7 @@ var Ls = () => ({
2076
2076
  async parseCompleteOutput({ text: s }, i) {
2077
2077
  const l = await ye({ text: s });
2078
2078
  if (!l.success)
2079
- throw new pe({
2079
+ throw new fe({
2080
2080
  message: "No object generated: could not parse the response.",
2081
2081
  cause: l.error,
2082
2082
  text: s,
@@ -2089,7 +2089,7 @@ var Ls = () => ({
2089
2089
  schema: a
2090
2090
  });
2091
2091
  if (!n.success)
2092
- throw new pe({
2092
+ throw new fe({
2093
2093
  message: "No object generated: response did not match schema.",
2094
2094
  cause: n.error,
2095
2095
  text: s,
@@ -2116,16 +2116,16 @@ var Ls = () => ({
2116
2116
  createElementStreamTransform() {
2117
2117
  }
2118
2118
  };
2119
- }, $s = ({
2119
+ }, Ds = ({
2120
2120
  element: e,
2121
2121
  name: t,
2122
2122
  description: r
2123
2123
  }) => {
2124
- const a = yt(e);
2124
+ const a = ht(e);
2125
2125
  return {
2126
2126
  name: "array",
2127
2127
  // JSON schema that describes an array of elements:
2128
- responseFormat: de(a.jsonSchema).then((s) => {
2128
+ responseFormat: pe(a.jsonSchema).then((s) => {
2129
2129
  const { $schema: i, ...l } = s;
2130
2130
  return {
2131
2131
  type: "json",
@@ -2145,7 +2145,7 @@ var Ls = () => ({
2145
2145
  async parseCompleteOutput({ text: s }, i) {
2146
2146
  const l = await ye({ text: s });
2147
2147
  if (!l.success)
2148
- throw new pe({
2148
+ throw new fe({
2149
2149
  message: "No object generated: could not parse the response.",
2150
2150
  cause: l.error,
2151
2151
  text: s,
@@ -2155,9 +2155,9 @@ var Ls = () => ({
2155
2155
  });
2156
2156
  const n = l.value;
2157
2157
  if (n == null || typeof n != "object" || !("elements" in n) || !Array.isArray(n.elements))
2158
- throw new pe({
2158
+ throw new fe({
2159
2159
  message: "No object generated: response did not match schema.",
2160
- cause: new Me({
2160
+ cause: new Ae({
2161
2161
  value: n,
2162
2162
  cause: "response must be an object with an elements array"
2163
2163
  }),
@@ -2173,7 +2173,7 @@ var Ls = () => ({
2173
2173
  schema: a
2174
2174
  });
2175
2175
  if (!c.success)
2176
- throw new pe({
2176
+ throw new fe({
2177
2177
  message: "No object generated: response did not match schema.",
2178
2178
  cause: c.error,
2179
2179
  text: s,
@@ -2219,7 +2219,7 @@ var Ls = () => ({
2219
2219
  });
2220
2220
  }
2221
2221
  };
2222
- }, Us = ({
2222
+ }, ks = ({
2223
2223
  options: e,
2224
2224
  name: t,
2225
2225
  description: r
@@ -2243,7 +2243,7 @@ var Ls = () => ({
2243
2243
  async parseCompleteOutput({ text: a }, s) {
2244
2244
  const i = await ye({ text: a });
2245
2245
  if (!i.success)
2246
- throw new pe({
2246
+ throw new fe({
2247
2247
  message: "No object generated: could not parse the response.",
2248
2248
  cause: i.error,
2249
2249
  text: a,
@@ -2253,9 +2253,9 @@ var Ls = () => ({
2253
2253
  });
2254
2254
  const l = i.value;
2255
2255
  if (l == null || typeof l != "object" || !("result" in l) || typeof l.result != "string" || !e.includes(l.result))
2256
- throw new pe({
2256
+ throw new fe({
2257
2257
  message: "No object generated: response did not match schema.",
2258
- cause: new Me({
2258
+ cause: new Ae({
2259
2259
  value: l,
2260
2260
  cause: "response must be an object that contains a choice value."
2261
2261
  }),
@@ -2286,7 +2286,7 @@ var Ls = () => ({
2286
2286
  },
2287
2287
  createElementStreamTransform() {
2288
2288
  }
2289
- }), qs = ({
2289
+ }), Ls = ({
2290
2290
  name: e,
2291
2291
  description: t
2292
2292
  } = {}) => ({
@@ -2299,7 +2299,7 @@ var Ls = () => ({
2299
2299
  async parseCompleteOutput({ text: r }, a) {
2300
2300
  const s = await ye({ text: r });
2301
2301
  if (!s.success)
2302
- throw new pe({
2302
+ throw new fe({
2303
2303
  message: "No object generated: could not parse the response.",
2304
2304
  cause: s.error,
2305
2305
  text: r,
@@ -2325,11 +2325,11 @@ var Ls = () => ({
2325
2325
  });
2326
2326
  new TextEncoder();
2327
2327
  new TextEncoder();
2328
- Q({
2328
+ G({
2329
2329
  prefix: "aitxt",
2330
2330
  size: 24
2331
2331
  });
2332
- Q({
2332
+ G({
2333
2333
  prefix: "call",
2334
2334
  size: 24
2335
2335
  });
@@ -2352,8 +2352,8 @@ Q({
2352
2352
  var Pe = o.record(
2353
2353
  o.string(),
2354
2354
  be.optional()
2355
- ), Zs = us(
2356
- () => hr(
2355
+ ), Fs = ns(
2356
+ () => pr(
2357
2357
  o.union([
2358
2358
  o.strictObject({
2359
2359
  type: o.literal("text-start"),
@@ -2542,28 +2542,28 @@ var Pe = o.record(
2542
2542
  ])
2543
2543
  )
2544
2544
  );
2545
- function zs(e) {
2545
+ function $s(e) {
2546
2546
  return e.type.startsWith("data-");
2547
2547
  }
2548
2548
  function ke() {
2549
2549
  return /* @__PURE__ */ Object.create(null);
2550
2550
  }
2551
- function ft(e) {
2551
+ function dt(e) {
2552
2552
  return e.type.startsWith("tool-");
2553
2553
  }
2554
- function Mr(e) {
2554
+ function wr(e) {
2555
2555
  return e.type === "dynamic-tool";
2556
2556
  }
2557
- function Ae(e) {
2558
- return ft(e) || Mr(e);
2557
+ function xe(e) {
2558
+ return dt(e) || wr(e);
2559
2559
  }
2560
- function mt(e) {
2560
+ function pt(e) {
2561
2561
  return e.type.split("-").slice(1).join("-");
2562
2562
  }
2563
- function Ws(e) {
2564
- return Mr(e) ? e.toolName : mt(e);
2563
+ function Us(e) {
2564
+ return wr(e) ? e.toolName : pt(e);
2565
2565
  }
2566
- function Bs({
2566
+ function qs({
2567
2567
  lastMessage: e,
2568
2568
  messageId: t
2569
2569
  }) {
@@ -2579,7 +2579,7 @@ function Bs({
2579
2579
  partialToolCalls: ke()
2580
2580
  };
2581
2581
  }
2582
- function Vs({
2582
+ function Zs({
2583
2583
  stream: e,
2584
2584
  messageMetadataSchema: t,
2585
2585
  dataPartSchemas: r,
@@ -2592,10 +2592,10 @@ function Vs({
2592
2592
  new TransformStream({
2593
2593
  async transform(n, f) {
2594
2594
  await a(async ({ state: u, write: c }) => {
2595
- var p, v, h, x;
2595
+ var p, v, h, _;
2596
2596
  function M(d) {
2597
- const m = u.message.parts.filter(Ae).find(
2598
- (S) => S.toolCallId === d
2597
+ const m = u.message.parts.filter(xe).find(
2598
+ (b) => b.toolCallId === d
2599
2599
  );
2600
2600
  if (m == null)
2601
2601
  throw new ve({
@@ -2606,10 +2606,10 @@ function Vs({
2606
2606
  return m;
2607
2607
  }
2608
2608
  function E(d) {
2609
- const m = u.message.parts.filter(Ae).find(
2610
- (S) => {
2609
+ const m = u.message.parts.filter(xe).find(
2610
+ (b) => {
2611
2611
  var y;
2612
- return ((y = S.approval) == null ? void 0 : y.id) === d;
2612
+ return ((y = b.approval) == null ? void 0 : y.id) === d;
2613
2613
  }
2614
2614
  );
2615
2615
  if (m == null)
@@ -2623,17 +2623,17 @@ function Vs({
2623
2623
  function C(d) {
2624
2624
  var g;
2625
2625
  const m = u.message.parts.find(
2626
- (_) => ft(_) && _.toolCallId === d.toolCallId
2627
- ), S = d, y = m;
2626
+ (I) => dt(I) && I.toolCallId === d.toolCallId
2627
+ ), b = d, y = m;
2628
2628
  if (m != null) {
2629
- m.state = d.state, y.input = S.input, y.output = S.output, y.errorText = S.errorText, y.rawInput = S.rawInput, y.preliminary = S.preliminary, d.title !== void 0 && (y.title = d.title), d.toolMetadata !== void 0 && (y.toolMetadata = d.toolMetadata), y.providerExecuted = (g = S.providerExecuted) != null ? g : m.providerExecuted;
2630
- const _ = S.providerMetadata;
2631
- if (_ != null)
2629
+ m.state = d.state, y.input = b.input, y.output = b.output, y.errorText = b.errorText, y.rawInput = b.rawInput, y.preliminary = b.preliminary, d.title !== void 0 && (y.title = d.title), d.toolMetadata !== void 0 && (y.toolMetadata = d.toolMetadata), y.providerExecuted = (g = b.providerExecuted) != null ? g : m.providerExecuted;
2630
+ const I = b.providerMetadata;
2631
+ if (I != null)
2632
2632
  if (d.state === "output-available" || d.state === "output-error") {
2633
- const P = m;
2634
- P.resultProviderMetadata = _;
2633
+ const k = m;
2634
+ k.resultProviderMetadata = I;
2635
2635
  } else
2636
- m.callProviderMetadata = _;
2636
+ m.callProviderMetadata = I;
2637
2637
  } else
2638
2638
  u.message.parts.push({
2639
2639
  type: `tool-${d.toolName}`,
@@ -2641,30 +2641,30 @@ function Vs({
2641
2641
  state: d.state,
2642
2642
  title: d.title,
2643
2643
  ...d.toolMetadata !== void 0 ? { toolMetadata: d.toolMetadata } : {},
2644
- input: S.input,
2645
- output: S.output,
2646
- rawInput: S.rawInput,
2647
- errorText: S.errorText,
2648
- providerExecuted: S.providerExecuted,
2649
- preliminary: S.preliminary,
2650
- ...S.providerMetadata != null && (d.state === "output-available" || d.state === "output-error") ? { resultProviderMetadata: S.providerMetadata } : {},
2651
- ...S.providerMetadata != null && !(d.state === "output-available" || d.state === "output-error") ? { callProviderMetadata: S.providerMetadata } : {}
2644
+ input: b.input,
2645
+ output: b.output,
2646
+ rawInput: b.rawInput,
2647
+ errorText: b.errorText,
2648
+ providerExecuted: b.providerExecuted,
2649
+ preliminary: b.preliminary,
2650
+ ...b.providerMetadata != null && (d.state === "output-available" || d.state === "output-error") ? { resultProviderMetadata: b.providerMetadata } : {},
2651
+ ...b.providerMetadata != null && !(d.state === "output-available" || d.state === "output-error") ? { callProviderMetadata: b.providerMetadata } : {}
2652
2652
  });
2653
2653
  }
2654
2654
  function w(d) {
2655
2655
  var g, m;
2656
- const S = u.message.parts.find(
2657
- (P) => P.type === "dynamic-tool" && P.toolCallId === d.toolCallId
2658
- ), y = d, _ = S;
2659
- if (S != null) {
2660
- S.state = d.state, _.toolName = d.toolName, _.input = y.input, _.output = y.output, _.errorText = y.errorText, _.rawInput = (g = y.rawInput) != null ? g : _.rawInput, _.preliminary = y.preliminary, d.title !== void 0 && (_.title = d.title), d.toolMetadata !== void 0 && (_.toolMetadata = d.toolMetadata), _.providerExecuted = (m = y.providerExecuted) != null ? m : S.providerExecuted;
2661
- const P = y.providerMetadata;
2662
- if (P != null)
2656
+ const b = u.message.parts.find(
2657
+ (k) => k.type === "dynamic-tool" && k.toolCallId === d.toolCallId
2658
+ ), y = d, I = b;
2659
+ if (b != null) {
2660
+ b.state = d.state, I.toolName = d.toolName, I.input = y.input, I.output = y.output, I.errorText = y.errorText, I.rawInput = (g = y.rawInput) != null ? g : I.rawInput, I.preliminary = y.preliminary, d.title !== void 0 && (I.title = d.title), d.toolMetadata !== void 0 && (I.toolMetadata = d.toolMetadata), I.providerExecuted = (m = y.providerExecuted) != null ? m : b.providerExecuted;
2661
+ const k = y.providerMetadata;
2662
+ if (k != null)
2663
2663
  if (d.state === "output-available" || d.state === "output-error") {
2664
- const fe = S;
2665
- fe.resultProviderMetadata = P;
2664
+ const Y = b;
2665
+ Y.resultProviderMetadata = k;
2666
2666
  } else
2667
- S.callProviderMetadata = P;
2667
+ b.callProviderMetadata = k;
2668
2668
  } else
2669
2669
  u.message.parts.push({
2670
2670
  type: "dynamic-tool",
@@ -2682,10 +2682,10 @@ function Vs({
2682
2682
  ...y.providerMetadata != null && !(d.state === "output-available" || d.state === "output-error") ? { callProviderMetadata: y.providerMetadata } : {}
2683
2683
  });
2684
2684
  }
2685
- async function O(d) {
2685
+ async function N(d) {
2686
2686
  if (d != null) {
2687
- const g = u.message.metadata != null ? Ar(u.message.metadata, d) : d;
2688
- t != null && await Jt({
2687
+ const g = u.message.metadata != null ? Ir(u.message.metadata, d) : d;
2688
+ t != null && await zt({
2689
2689
  value: g,
2690
2690
  schema: t,
2691
2691
  context: {
@@ -2766,7 +2766,7 @@ function Vs({
2766
2766
  chunkId: n.id,
2767
2767
  message: `Received reasoning-end for missing reasoning part with ID "${n.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`
2768
2768
  });
2769
- d.providerMetadata = (x = n.providerMetadata) != null ? x : d.providerMetadata, d.state = "done", delete u.activeReasoningParts[n.id], c();
2769
+ d.providerMetadata = (_ = n.providerMetadata) != null ? _ : d.providerMetadata, d.state = "done", delete u.activeReasoningParts[n.id], c();
2770
2770
  break;
2771
2771
  }
2772
2772
  case "file":
@@ -2801,7 +2801,7 @@ function Vs({
2801
2801
  break;
2802
2802
  }
2803
2803
  case "tool-input-start": {
2804
- const d = u.message.parts.filter(ft);
2804
+ const d = u.message.parts.filter(dt);
2805
2805
  u.partialToolCalls[n.toolCallId] = {
2806
2806
  text: "",
2807
2807
  toolName: n.toolName,
@@ -2884,7 +2884,7 @@ function Vs({
2884
2884
  break;
2885
2885
  }
2886
2886
  case "tool-input-error": {
2887
- const d = u.message.parts.filter(Ae).find((m) => m.toolCallId === n.toolCallId);
2887
+ const d = u.message.parts.filter(xe).find((m) => m.toolCallId === n.toolCallId);
2888
2888
  (d != null ? d.type === "dynamic-tool" : !!n.dynamic) ? w({
2889
2889
  toolCallId: n.toolCallId,
2890
2890
  toolName: n.toolName,
@@ -2949,7 +2949,7 @@ function Vs({
2949
2949
  toolMetadata: d.toolMetadata
2950
2950
  }) : C({
2951
2951
  toolCallId: n.toolCallId,
2952
- toolName: mt(d),
2952
+ toolName: pt(d),
2953
2953
  state: "output-available",
2954
2954
  input: d.input,
2955
2955
  output: n.output,
@@ -2975,7 +2975,7 @@ function Vs({
2975
2975
  toolMetadata: d.toolMetadata
2976
2976
  }) : C({
2977
2977
  toolCallId: n.toolCallId,
2978
- toolName: mt(d),
2978
+ toolName: pt(d),
2979
2979
  state: "output-error",
2980
2980
  input: d.input,
2981
2981
  rawInput: d.rawInput,
@@ -2996,15 +2996,15 @@ function Vs({
2996
2996
  break;
2997
2997
  }
2998
2998
  case "start": {
2999
- n.messageId != null && (u.message.id = n.messageId), await O(n.messageMetadata), (n.messageId != null || n.messageMetadata != null) && c();
2999
+ n.messageId != null && (u.message.id = n.messageId), await N(n.messageMetadata), (n.messageId != null || n.messageMetadata != null) && c();
3000
3000
  break;
3001
3001
  }
3002
3002
  case "finish": {
3003
- n.finishReason != null && (u.finishReason = n.finishReason), await O(n.messageMetadata), n.messageMetadata != null && c();
3003
+ n.finishReason != null && (u.finishReason = n.finishReason), await N(n.messageMetadata), n.messageMetadata != null && c();
3004
3004
  break;
3005
3005
  }
3006
3006
  case "message-metadata": {
3007
- await O(n.messageMetadata), n.messageMetadata != null && c();
3007
+ await N(n.messageMetadata), n.messageMetadata != null && c();
3008
3008
  break;
3009
3009
  }
3010
3010
  case "error": {
@@ -3012,16 +3012,16 @@ function Vs({
3012
3012
  break;
3013
3013
  }
3014
3014
  default:
3015
- if (zs(n)) {
3015
+ if ($s(n)) {
3016
3016
  if ((r == null ? void 0 : r[n.type]) != null) {
3017
3017
  const m = u.message.parts.findIndex(
3018
3018
  (y) => "id" in y && "data" in y && y.id === n.id && y.type === n.type
3019
- ), S = m >= 0 ? m : u.message.parts.length;
3020
- await Jt({
3019
+ ), b = m >= 0 ? m : u.message.parts.length;
3020
+ await zt({
3021
3021
  value: n.data,
3022
3022
  schema: r[n.type],
3023
3023
  context: {
3024
- field: `message.parts[${S}].data`,
3024
+ field: `message.parts[${b}].data`,
3025
3025
  entityName: n.type,
3026
3026
  entityId: n.id
3027
3027
  }
@@ -3044,7 +3044,7 @@ function Vs({
3044
3044
  })
3045
3045
  );
3046
3046
  }
3047
- async function Js({
3047
+ async function zs({
3048
3048
  stream: e,
3049
3049
  onError: t
3050
3050
  }) {
@@ -3061,19 +3061,19 @@ async function Js({
3061
3061
  r.releaseLock();
3062
3062
  }
3063
3063
  }
3064
- Q({
3064
+ G({
3065
3065
  prefix: "aitxt",
3066
3066
  size: 24
3067
3067
  });
3068
- Q({
3068
+ G({
3069
3069
  prefix: "call",
3070
3070
  size: 24
3071
3071
  });
3072
- Q({
3072
+ G({
3073
3073
  prefix: "aitxt",
3074
3074
  size: 24
3075
3075
  });
3076
- Q({
3076
+ G({
3077
3077
  prefix: "call",
3078
3078
  size: 24
3079
3079
  });
@@ -3082,16 +3082,16 @@ o.record(
3082
3082
  be.optional()
3083
3083
  );
3084
3084
  o.record(o.string(), o.string());
3085
- Q({
3085
+ G({
3086
3086
  prefix: "call",
3087
3087
  size: 24
3088
3088
  });
3089
- Q({
3089
+ G({
3090
3090
  prefix: "call",
3091
3091
  size: 24
3092
3092
  });
3093
- Q({ prefix: "aiobj", size: 24 });
3094
- var Ks = class {
3093
+ G({ prefix: "aiobj", size: 24 });
3094
+ var Ws = class {
3095
3095
  constructor() {
3096
3096
  this.queue = [], this.isProcessing = !1;
3097
3097
  }
@@ -3114,12 +3114,12 @@ var Ks = class {
3114
3114
  });
3115
3115
  }
3116
3116
  };
3117
- Q({ prefix: "aiobj", size: 24 });
3118
- Q({
3117
+ G({ prefix: "aiobj", size: 24 });
3118
+ G({
3119
3119
  prefix: "call",
3120
3120
  size: 24
3121
3121
  });
3122
- async function Ys(e) {
3122
+ async function Bs(e) {
3123
3123
  if (e == null)
3124
3124
  return [];
3125
3125
  if (!globalThis.FileList || !(e instanceof globalThis.FileList))
@@ -3142,7 +3142,7 @@ async function Ys(e) {
3142
3142
  })
3143
3143
  );
3144
3144
  }
3145
- var Hs = class {
3145
+ var Vs = class {
3146
3146
  constructor({
3147
3147
  api: e = "/api/chat",
3148
3148
  credentials: t,
@@ -3159,9 +3159,9 @@ var Hs = class {
3159
3159
  ...t
3160
3160
  }) {
3161
3161
  var r, a, s, i, l;
3162
- const n = await de(this.body), f = await de(this.headers), u = await de(this.credentials), c = {
3163
- ...we(f),
3164
- ...we(t.headers)
3162
+ const n = await pe(this.body), f = await pe(this.headers), u = await pe(this.credentials), c = {
3163
+ ...Ie(f),
3164
+ ...Ie(t.headers)
3165
3165
  }, p = await ((r = this.prepareSendMessagesRequest) == null ? void 0 : r.call(this, {
3166
3166
  api: this.api,
3167
3167
  id: t.chatId,
@@ -3172,7 +3172,7 @@ var Hs = class {
3172
3172
  requestMetadata: t.metadata,
3173
3173
  trigger: t.trigger,
3174
3174
  messageId: t.messageId
3175
- })), v = (a = p == null ? void 0 : p.api) != null ? a : this.api, h = (p == null ? void 0 : p.headers) !== void 0 ? we(p.headers) : c, x = (p == null ? void 0 : p.body) !== void 0 ? p.body : {
3175
+ })), v = (a = p == null ? void 0 : p.api) != null ? a : this.api, h = (p == null ? void 0 : p.headers) !== void 0 ? Ie(p.headers) : c, _ = (p == null ? void 0 : p.body) !== void 0 ? p.body : {
3176
3176
  ...n,
3177
3177
  ...t.body,
3178
3178
  id: t.chatId,
@@ -3185,7 +3185,7 @@ var Hs = class {
3185
3185
  "Content-Type": "application/json",
3186
3186
  ...h
3187
3187
  },
3188
- body: JSON.stringify(x),
3188
+ body: JSON.stringify(_),
3189
3189
  credentials: M,
3190
3190
  signal: e
3191
3191
  });
@@ -3199,9 +3199,9 @@ var Hs = class {
3199
3199
  }
3200
3200
  async reconnectToStream(e) {
3201
3201
  var t, r, a, s, i;
3202
- const l = await de(this.body), n = await de(this.headers), f = await de(this.credentials), u = {
3203
- ...we(n),
3204
- ...we(e.headers)
3202
+ const l = await pe(this.body), n = await pe(this.headers), f = await pe(this.credentials), u = {
3203
+ ...Ie(n),
3204
+ ...Ie(e.headers)
3205
3205
  }, c = await ((t = this.prepareReconnectToStreamRequest) == null ? void 0 : t.call(this, {
3206
3206
  api: this.api,
3207
3207
  id: e.chatId,
@@ -3209,7 +3209,7 @@ var Hs = class {
3209
3209
  headers: u,
3210
3210
  credentials: f,
3211
3211
  requestMetadata: e.metadata
3212
- })), p = (r = c == null ? void 0 : c.api) != null ? r : `${this.api}/${e.chatId}/stream`, v = (c == null ? void 0 : c.headers) !== void 0 ? we(c.headers) : u, h = (a = c == null ? void 0 : c.credentials) != null ? a : f, M = await ((s = this.fetch) != null ? s : globalThis.fetch)(p, {
3212
+ })), p = (r = c == null ? void 0 : c.api) != null ? r : `${this.api}/${e.chatId}/stream`, v = (c == null ? void 0 : c.headers) !== void 0 ? Ie(c.headers) : u, h = (a = c == null ? void 0 : c.credentials) != null ? a : f, M = await ((s = this.fetch) != null ? s : globalThis.fetch)(p, {
3213
3213
  method: "GET",
3214
3214
  headers: v,
3215
3215
  credentials: h
@@ -3224,14 +3224,14 @@ var Hs = class {
3224
3224
  throw new Error("The response body is empty.");
3225
3225
  return this.processResponseStream(M.body);
3226
3226
  }
3227
- }, St = class extends Hs {
3227
+ }, yt = class extends Vs {
3228
3228
  constructor(e = {}) {
3229
3229
  super(e);
3230
3230
  }
3231
3231
  processResponseStream(e) {
3232
- return hs({
3232
+ return ps({
3233
3233
  stream: e,
3234
- schema: Zs
3234
+ schema: Fs
3235
3235
  }).pipeThrough(
3236
3236
  new TransformStream({
3237
3237
  async transform(t, r) {
@@ -3242,11 +3242,11 @@ var Hs = class {
3242
3242
  })
3243
3243
  );
3244
3244
  }
3245
- }, Gs = class {
3245
+ }, Js = class {
3246
3246
  constructor({
3247
- generateId: e = va,
3247
+ generateId: e = fa,
3248
3248
  id: t = e(),
3249
- transport: r = new St(),
3249
+ transport: r = new yt(),
3250
3250
  messageMetadataSchema: a,
3251
3251
  dataPartSchemas: s,
3252
3252
  state: i,
@@ -3256,8 +3256,8 @@ var Hs = class {
3256
3256
  onData: u,
3257
3257
  sendAutomaticallyWhen: c
3258
3258
  }) {
3259
- this.activeResponse = void 0, this.jobExecutor = new Ks(), this.sendMessage = async (p, v) => {
3260
- var h, x, M, E;
3259
+ this.activeResponse = void 0, this.jobExecutor = new Ws(), this.sendMessage = async (p, v) => {
3260
+ var h, _, M, E;
3261
3261
  if (p == null) {
3262
3262
  await this.makeRequest({
3263
3263
  trigger: "submit-message",
@@ -3269,12 +3269,12 @@ var Hs = class {
3269
3269
  let C;
3270
3270
  if ("text" in p || "files" in p ? C = {
3271
3271
  parts: [
3272
- ...Array.isArray(p.files) ? p.files : await Ys(p.files),
3272
+ ...Array.isArray(p.files) ? p.files : await Bs(p.files),
3273
3273
  ..."text" in p && p.text != null ? [{ type: "text", text: p.text }] : []
3274
3274
  ]
3275
3275
  } : C = p, p.messageId != null) {
3276
3276
  const w = this.state.messages.findIndex(
3277
- (O) => O.id === p.messageId
3277
+ (N) => N.id === p.messageId
3278
3278
  );
3279
3279
  if (w === -1)
3280
3280
  throw new Error(`message with id ${p.messageId} not found`);
@@ -3285,7 +3285,7 @@ var Hs = class {
3285
3285
  this.state.messages = this.state.messages.slice(0, w + 1), this.state.replaceMessage(w, {
3286
3286
  ...C,
3287
3287
  id: p.messageId,
3288
- role: (x = C.role) != null ? x : "user",
3288
+ role: (_ = C.role) != null ? _ : "user",
3289
3289
  metadata: p.metadata
3290
3290
  });
3291
3291
  } else
@@ -3304,7 +3304,7 @@ var Hs = class {
3304
3304
  messageId: p,
3305
3305
  ...v
3306
3306
  } = {}) => {
3307
- const h = p == null ? this.state.messages.length - 1 : this.state.messages.findIndex((x) => x.id === p);
3307
+ const h = p == null ? this.state.messages.length - 1 : this.state.messages.findIndex((_) => _.id === p);
3308
3308
  if (h === -1)
3309
3309
  throw new Error(`message ${p} not found`);
3310
3310
  this.state.messages = this.state.messages.slice(
@@ -3324,9 +3324,9 @@ var Hs = class {
3324
3324
  id: p,
3325
3325
  approved: v,
3326
3326
  reason: h,
3327
- options: x
3327
+ options: _
3328
3328
  }) => this.jobExecutor.run(async () => {
3329
- const M = this.state.messages, E = M[M.length - 1], C = (w) => Ae(w) && w.state === "approval-requested" && w.approval.id === p ? {
3329
+ const M = this.state.messages, E = M[M.length - 1], C = (w) => xe(w) && w.state === "approval-requested" && w.approval.id === p ? {
3330
3330
  ...w,
3331
3331
  state: "approval-responded",
3332
3332
  approval: { ...w.approval, id: p, approved: v, reason: h }
@@ -3335,27 +3335,27 @@ var Hs = class {
3335
3335
  ...E,
3336
3336
  parts: E.parts.map(C)
3337
3337
  }), this.activeResponse && (this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(C)), this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen && this.shouldSendAutomatically().then((w) => {
3338
- var O;
3338
+ var N;
3339
3339
  w && this.makeRequest({
3340
3340
  trigger: "submit-message",
3341
- messageId: (O = this.lastMessage) == null ? void 0 : O.id,
3342
- ...x
3341
+ messageId: (N = this.lastMessage) == null ? void 0 : N.id,
3342
+ ..._
3343
3343
  });
3344
3344
  });
3345
3345
  }), this.addToolOutput = async ({
3346
3346
  state: p = "output-available",
3347
3347
  toolCallId: v,
3348
3348
  output: h,
3349
- errorText: x,
3349
+ errorText: _,
3350
3350
  options: M
3351
3351
  }) => this.jobExecutor.run(async () => {
3352
- const E = this.state.messages, C = E[E.length - 1], w = (O) => Ae(O) && O.toolCallId === v ? { ...O, state: p, output: h, errorText: x } : O;
3352
+ const E = this.state.messages, C = E[E.length - 1], w = (N) => xe(N) && N.toolCallId === v ? { ...N, state: p, output: h, errorText: _ } : N;
3353
3353
  this.state.replaceMessage(E.length - 1, {
3354
3354
  ...C,
3355
3355
  parts: C.parts.map(w)
3356
- }), this.activeResponse && (this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(w)), this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen && this.shouldSendAutomatically().then((O) => {
3356
+ }), this.activeResponse && (this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(w)), this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen && this.shouldSendAutomatically().then((N) => {
3357
3357
  var d;
3358
- O && this.makeRequest({
3358
+ N && this.makeRequest({
3359
3359
  trigger: "submit-message",
3360
3360
  messageId: (d = this.lastMessage) == null ? void 0 : d.id,
3361
3361
  ...M
@@ -3432,7 +3432,7 @@ var Hs = class {
3432
3432
  let u = !1, c = !1, p = !1, v;
3433
3433
  try {
3434
3434
  const h = {
3435
- state: Bs({
3435
+ state: qs({
3436
3436
  lastMessage: this.state.snapshot(f),
3437
3437
  messageId: this.generateId()
3438
3438
  }),
@@ -3441,8 +3441,8 @@ var Hs = class {
3441
3441
  v = h, h.abortController.signal.addEventListener("abort", () => {
3442
3442
  u = !0;
3443
3443
  }), this.activeResponse = h;
3444
- let x;
3445
- e === "resume-stream" ? x = n : x = await this.transport.sendMessages({
3444
+ let _;
3445
+ e === "resume-stream" ? _ = n : _ = await this.transport.sendMessages({
3446
3446
  chatId: this.id,
3447
3447
  messages: this.state.messages,
3448
3448
  abortSignal: h.abortController.signal,
@@ -3467,9 +3467,9 @@ var Hs = class {
3467
3467
  })
3468
3468
  )
3469
3469
  );
3470
- await Js({
3471
- stream: Vs({
3472
- stream: x,
3470
+ await zs({
3471
+ stream: Zs({
3472
+ stream: _,
3473
3473
  onToolCall: this.onToolCall,
3474
3474
  onData: this.onData,
3475
3475
  messageMetadataSchema: this.messageMetadataSchema,
@@ -3511,7 +3511,7 @@ var Hs = class {
3511
3511
  });
3512
3512
  }
3513
3513
  };
3514
- function Qs(e, t) {
3514
+ function Ks(e, t) {
3515
3515
  if (typeof e != "function")
3516
3516
  throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);
3517
3517
  let r, a = 0;
@@ -3523,91 +3523,91 @@ function Qs(e, t) {
3523
3523
  }, f);
3524
3524
  };
3525
3525
  }
3526
- var Xs = Qs;
3527
- const en = /* @__PURE__ */ vs(Xs);
3528
- var Tr = (e, t, r) => {
3526
+ var Ys = Ks;
3527
+ const Hs = /* @__PURE__ */ fs(Ys);
3528
+ var _r = (e, t, r) => {
3529
3529
  if (!t.has(e))
3530
3530
  throw TypeError("Cannot " + r);
3531
- }, D = (e, t, r) => (Tr(e, t, "read from private field"), r ? r.call(e) : t.get(e)), ae = (e, t, r) => {
3531
+ }, j = (e, t, r) => (_r(e, t, "read from private field"), r ? r.call(e) : t.get(e)), re = (e, t, r) => {
3532
3532
  if (t.has(e))
3533
3533
  throw TypeError("Cannot add the same private member more than once");
3534
3534
  t instanceof WeakSet ? t.add(e) : t.set(e, r);
3535
- }, ce = (e, t, r, a) => (Tr(e, t, "write to private field"), t.set(e, r), r);
3536
- function tn(e, t) {
3537
- return t != null ? en(e, t) : e;
3535
+ }, de = (e, t, r, a) => (_r(e, t, "write to private field"), t.set(e, r), r);
3536
+ function Gs(e, t) {
3537
+ return t != null ? Hs(e, t) : e;
3538
3538
  }
3539
- var G, Ye, He, Oe, Ne, je, _e, gt, ht, rn = class {
3539
+ var H, Ke, Ye, Oe, Ne, je, we, ft, mt, Qs = class {
3540
3540
  constructor(e = []) {
3541
- ae(this, G, void 0), ae(this, Ye, "ready"), ae(this, He, void 0), ae(this, Oe, /* @__PURE__ */ new Set()), ae(this, Ne, /* @__PURE__ */ new Set()), ae(this, je, /* @__PURE__ */ new Set()), this.pushMessage = (t) => {
3542
- ce(this, G, D(this, G).concat(t)), D(this, _e).call(this);
3541
+ re(this, H, void 0), re(this, Ke, "ready"), re(this, Ye, void 0), re(this, Oe, /* @__PURE__ */ new Set()), re(this, Ne, /* @__PURE__ */ new Set()), re(this, je, /* @__PURE__ */ new Set()), this.pushMessage = (t) => {
3542
+ de(this, H, j(this, H).concat(t)), j(this, we).call(this);
3543
3543
  }, this.popMessage = () => {
3544
- ce(this, G, D(this, G).slice(0, -1)), D(this, _e).call(this);
3544
+ de(this, H, j(this, H).slice(0, -1)), j(this, we).call(this);
3545
3545
  }, this.replaceMessage = (t, r) => {
3546
- ce(this, G, [
3547
- ...D(this, G).slice(0, t),
3546
+ de(this, H, [
3547
+ ...j(this, H).slice(0, t),
3548
3548
  // We deep clone the message here to ensure the new React Compiler (currently in RC) detects deeply nested parts/metadata changes:
3549
3549
  this.snapshot(r),
3550
- ...D(this, G).slice(t + 1)
3551
- ]), D(this, _e).call(this);
3550
+ ...j(this, H).slice(t + 1)
3551
+ ]), j(this, we).call(this);
3552
3552
  }, this.snapshot = (t) => structuredClone(t), this["~registerMessagesCallback"] = (t, r) => {
3553
- const a = r ? tn(t, r) : t;
3554
- return D(this, Oe).add(a), () => {
3555
- D(this, Oe).delete(a);
3553
+ const a = r ? Gs(t, r) : t;
3554
+ return j(this, Oe).add(a), () => {
3555
+ j(this, Oe).delete(a);
3556
3556
  };
3557
- }, this["~registerStatusCallback"] = (t) => (D(this, Ne).add(t), () => {
3558
- D(this, Ne).delete(t);
3559
- }), this["~registerErrorCallback"] = (t) => (D(this, je).add(t), () => {
3560
- D(this, je).delete(t);
3561
- }), ae(this, _e, () => {
3562
- D(this, Oe).forEach((t) => t());
3563
- }), ae(this, gt, () => {
3564
- D(this, Ne).forEach((t) => t());
3565
- }), ae(this, ht, () => {
3566
- D(this, je).forEach((t) => t());
3567
- }), ce(this, G, e);
3557
+ }, this["~registerStatusCallback"] = (t) => (j(this, Ne).add(t), () => {
3558
+ j(this, Ne).delete(t);
3559
+ }), this["~registerErrorCallback"] = (t) => (j(this, je).add(t), () => {
3560
+ j(this, je).delete(t);
3561
+ }), re(this, we, () => {
3562
+ j(this, Oe).forEach((t) => t());
3563
+ }), re(this, ft, () => {
3564
+ j(this, Ne).forEach((t) => t());
3565
+ }), re(this, mt, () => {
3566
+ j(this, je).forEach((t) => t());
3567
+ }), de(this, H, e);
3568
3568
  }
3569
3569
  get status() {
3570
- return D(this, Ye);
3570
+ return j(this, Ke);
3571
3571
  }
3572
3572
  set status(e) {
3573
- ce(this, Ye, e), D(this, gt).call(this);
3573
+ de(this, Ke, e), j(this, ft).call(this);
3574
3574
  }
3575
3575
  get error() {
3576
- return D(this, He);
3576
+ return j(this, Ye);
3577
3577
  }
3578
3578
  set error(e) {
3579
- ce(this, He, e), D(this, ht).call(this);
3579
+ de(this, Ye, e), j(this, mt).call(this);
3580
3580
  }
3581
3581
  get messages() {
3582
- return D(this, G);
3582
+ return j(this, H);
3583
3583
  }
3584
3584
  set messages(e) {
3585
- ce(this, G, [...e]), D(this, _e).call(this);
3585
+ de(this, H, [...e]), j(this, we).call(this);
3586
3586
  }
3587
3587
  };
3588
- G = /* @__PURE__ */ new WeakMap();
3588
+ H = /* @__PURE__ */ new WeakMap();
3589
+ Ke = /* @__PURE__ */ new WeakMap();
3589
3590
  Ye = /* @__PURE__ */ new WeakMap();
3590
- He = /* @__PURE__ */ new WeakMap();
3591
3591
  Oe = /* @__PURE__ */ new WeakMap();
3592
3592
  Ne = /* @__PURE__ */ new WeakMap();
3593
3593
  je = /* @__PURE__ */ new WeakMap();
3594
- _e = /* @__PURE__ */ new WeakMap();
3595
- gt = /* @__PURE__ */ new WeakMap();
3596
- ht = /* @__PURE__ */ new WeakMap();
3597
- var xe, Kt = class extends Gs {
3594
+ we = /* @__PURE__ */ new WeakMap();
3595
+ ft = /* @__PURE__ */ new WeakMap();
3596
+ mt = /* @__PURE__ */ new WeakMap();
3597
+ var _e, Wt = class extends Js {
3598
3598
  constructor({ messages: e, ...t }) {
3599
- const r = new rn(e);
3600
- super({ ...t, state: r }), ae(this, xe, void 0), this["~registerMessagesCallback"] = (a, s) => D(this, xe)["~registerMessagesCallback"](a, s), this["~registerStatusCallback"] = (a) => D(this, xe)["~registerStatusCallback"](a), this["~registerErrorCallback"] = (a) => D(this, xe)["~registerErrorCallback"](a), ce(this, xe, r);
3599
+ const r = new Qs(e);
3600
+ super({ ...t, state: r }), re(this, _e, void 0), this["~registerMessagesCallback"] = (a, s) => j(this, _e)["~registerMessagesCallback"](a, s), this["~registerStatusCallback"] = (a) => j(this, _e)["~registerStatusCallback"](a), this["~registerErrorCallback"] = (a) => j(this, _e)["~registerErrorCallback"](a), de(this, _e, r);
3601
3601
  }
3602
3602
  };
3603
- xe = /* @__PURE__ */ new WeakMap();
3604
- function an({
3603
+ _e = /* @__PURE__ */ new WeakMap();
3604
+ function Xs({
3605
3605
  throttle: e,
3606
3606
  experimental_throttle: t,
3607
3607
  resume: r = !1,
3608
3608
  ...a
3609
3609
  } = {}) {
3610
- const s = e ?? t, i = j({});
3610
+ const s = e ?? t, i = D({});
3611
3611
  "chat" in a || (i.current = {
3612
3612
  onToolCall: a.onToolCall,
3613
3613
  onData: a.onData,
@@ -3619,7 +3619,7 @@ function an({
3619
3619
  let l;
3620
3620
  const n = () => {
3621
3621
  var E;
3622
- return (E = i.current.transport) != null ? E : l ?? (l = new St());
3622
+ return (E = i.current.transport) != null ? E : l ?? (l = new yt());
3623
3623
  }, f = {
3624
3624
  ...a,
3625
3625
  transport: {
@@ -3643,14 +3643,14 @@ function an({
3643
3643
  return (w = (C = i.current).onError) == null ? void 0 : w.call(C, E);
3644
3644
  },
3645
3645
  sendAutomaticallyWhen: (E) => {
3646
- var C, w, O;
3647
- return (O = (w = (C = i.current).sendAutomaticallyWhen) == null ? void 0 : w.call(C, E)) != null ? O : !1;
3646
+ var C, w, N;
3647
+ return (N = (w = (C = i.current).sendAutomaticallyWhen) == null ? void 0 : w.call(C, E)) != null ? N : !1;
3648
3648
  }
3649
- }, u = j(
3650
- "chat" in a ? a.chat : new Kt(f)
3649
+ }, u = D(
3650
+ "chat" in a ? a.chat : new Wt(f)
3651
3651
  );
3652
- ("chat" in a && a.chat !== u.current || "id" in a && a.id != null && u.current.id !== a.id) && (u.current = "chat" in a ? a.chat : new Kt(f));
3653
- const p = F(
3652
+ ("chat" in a && a.chat !== u.current || "id" in a && a.id != null && u.current.id !== a.id) && (u.current = "chat" in a ? a.chat : new Wt(f));
3653
+ const p = q(
3654
3654
  (E) => u.current["~registerMessagesCallback"](E, s),
3655
3655
  // `chatRef.current.id` is required to trigger re-subscription when the chat ID changes
3656
3656
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -3663,17 +3663,17 @@ function an({
3663
3663
  u.current["~registerStatusCallback"],
3664
3664
  () => u.current.status,
3665
3665
  () => u.current.status
3666
- ), x = De(
3666
+ ), _ = De(
3667
3667
  u.current["~registerErrorCallback"],
3668
3668
  () => u.current.error,
3669
3669
  () => u.current.error
3670
- ), M = F(
3670
+ ), M = q(
3671
3671
  (E) => {
3672
3672
  typeof E == "function" && (E = E(u.current.messages)), u.current.messages = E;
3673
3673
  },
3674
3674
  [u]
3675
3675
  );
3676
- return q(() => {
3676
+ return Z(() => {
3677
3677
  r && u.current.resumeStream();
3678
3678
  }, [r, u]), {
3679
3679
  id: u.current.id,
@@ -3683,7 +3683,7 @@ function an({
3683
3683
  regenerate: u.current.regenerate,
3684
3684
  clearError: u.current.clearError,
3685
3685
  stop: u.current.stop,
3686
- error: x,
3686
+ error: _,
3687
3687
  resumeStream: u.current.resumeStream,
3688
3688
  status: h,
3689
3689
  /**
@@ -3694,7 +3694,7 @@ function an({
3694
3694
  addToolApprovalResponse: u.current.addToolApprovalResponse
3695
3695
  };
3696
3696
  }
3697
- class Yt {
3697
+ class Bt {
3698
3698
  constructor(t) {
3699
3699
  this.buffer = [], this.cap = Math.max(1, Math.floor(t));
3700
3700
  }
@@ -3727,7 +3727,7 @@ class Yt {
3727
3727
  return a ?? null;
3728
3728
  }
3729
3729
  }
3730
- function Ht(e, t) {
3730
+ function Vt(e, t) {
3731
3731
  const r = e.flatMap((a) => {
3732
3732
  if (a.kind !== "steps") return [a];
3733
3733
  const s = a.steps.flatMap((i) => i.kind === "reasoning" ? (t == null ? void 0 : t.reasoning) === !1 ? [] : [i] : (t == null ? void 0 : t.toolActivity) === "hidden" ? [] : (t == null ? void 0 : t.toolActivity) === "status" && ("input" in i || "output" in i) ? [{ kind: i.kind, label: i.label, done: i.done }] : [i]);
@@ -3737,30 +3737,30 @@ function Ht(e, t) {
3737
3737
  });
3738
3738
  return r.length === e.length && r.every((a, s) => a === e[s]) ? e : r;
3739
3739
  }
3740
- const sn = Z.union([
3741
- Z.string(),
3742
- Z.looseObject({ id: Z.string().optional(), label: Z.string() })
3743
- ]), nn = Z.looseObject({
3744
- id: Z.string().optional(),
3745
- prompt: Z.string(),
3746
- selection: Z.enum(["single", "multiple"]).default("single"),
3747
- options: Z.array(sn).min(1)
3748
- }), on = Z.looseObject({
3749
- request_id: Z.string().optional(),
3750
- questions: Z.array(nn).min(1)
3740
+ const en = z.union([
3741
+ z.string(),
3742
+ z.looseObject({ id: z.string().optional(), label: z.string() })
3743
+ ]), tn = z.looseObject({
3744
+ id: z.string().optional(),
3745
+ prompt: z.string(),
3746
+ selection: z.enum(["single", "multiple"]).default("single"),
3747
+ options: z.array(en).min(1)
3748
+ }), rn = z.looseObject({
3749
+ request_id: z.string().optional(),
3750
+ questions: z.array(tn).min(1)
3751
3751
  });
3752
- function ln(e) {
3752
+ function an(e) {
3753
3753
  return !!(e != null && e.includes("ask_questions"));
3754
3754
  }
3755
- const un = [
3755
+ const sn = [
3756
3756
  /\bi[’'ʼ‘]?ll\s+(type|describe|enter|write|tell)\b/i,
3757
3757
  /\b(type|describe|enter|write|tell)\s+(it|my\s+own|manually)\b/i,
3758
3758
  /^\s*(other|custom|none\s+of\s+the\s+above|something\s+else)\s*\.?\s*$/i
3759
3759
  ];
3760
- function cn(e) {
3761
- return un.some((t) => t.test(e));
3760
+ function nn(e) {
3761
+ return sn.some((t) => t.test(e));
3762
3762
  }
3763
- function dn(e, t) {
3763
+ function on(e, t) {
3764
3764
  return {
3765
3765
  request_id: e.request_id ?? t ?? "req-clarification",
3766
3766
  questions: e.questions.map((r, a) => ({
@@ -3772,44 +3772,44 @@ function dn(e, t) {
3772
3772
  id: s.id ?? `q${a}-o${i}`,
3773
3773
  label: s.label
3774
3774
  }
3775
- ).filter((s) => !cn(s.label))
3775
+ ).filter((s) => !nn(s.label))
3776
3776
  }))
3777
3777
  };
3778
3778
  }
3779
- function lt(e) {
3779
+ function it(e) {
3780
3780
  try {
3781
3781
  return JSON.parse(e);
3782
3782
  } catch {
3783
3783
  return null;
3784
3784
  }
3785
3785
  }
3786
- function pn(e) {
3786
+ function ln(e) {
3787
3787
  if (e == null) return null;
3788
- if (typeof e == "string") return lt(e);
3788
+ if (typeof e == "string") return it(e);
3789
3789
  if (Array.isArray(e)) {
3790
3790
  for (const t of e)
3791
3791
  if (t && typeof t == "object" && "text" in t) {
3792
3792
  const r = t.text;
3793
- if (typeof r == "string") return lt(r);
3793
+ if (typeof r == "string") return it(r);
3794
3794
  }
3795
3795
  return null;
3796
3796
  }
3797
3797
  if (typeof e == "object") {
3798
3798
  if ("text" in e) {
3799
3799
  const t = e.text;
3800
- if (typeof t == "string") return lt(t);
3800
+ if (typeof t == "string") return it(t);
3801
3801
  }
3802
3802
  return e;
3803
3803
  }
3804
3804
  return null;
3805
3805
  }
3806
- function Gt(e, t) {
3807
- const r = pn(e);
3806
+ function Jt(e, t) {
3807
+ const r = ln(e);
3808
3808
  if (r == null) return null;
3809
- const a = on.safeParse(r);
3810
- return a.success ? dn(a.data, t) : null;
3809
+ const a = rn.safeParse(r);
3810
+ return a.success ? on(a.data, t) : null;
3811
3811
  }
3812
- function Bn(e, t) {
3812
+ function $n(e, t) {
3813
3813
  const r = [];
3814
3814
  for (const a of e.questions) {
3815
3815
  const s = t.get(a.id);
@@ -3820,29 +3820,29 @@ A: ${s.trim()}`);
3820
3820
 
3821
3821
  `);
3822
3822
  }
3823
- const Qt = "data-spec", fn = Z.object({ label: Z.string(), done: Z.boolean() });
3824
- function Ge(e) {
3823
+ const Kt = "data-spec", un = z.object({ label: z.string(), done: z.boolean() });
3824
+ function He(e) {
3825
3825
  const t = [], r = (i) => {
3826
3826
  const l = t.at(-1);
3827
3827
  (l == null ? void 0 : l.kind) === "steps" ? l.steps.push(i) : t.push({ kind: "steps", steps: [i] });
3828
3828
  }, a = (i) => i === "output-available" || i === "output-error";
3829
3829
  let s = null;
3830
3830
  for (const i of e)
3831
- if (!tr(i) && Rr(i) !== "highlight_element") {
3832
- if (mn(i)) {
3833
- const l = gn(i);
3831
+ if (!Jr(i) && xr(i) !== "highlight_element") {
3832
+ if (cn(i)) {
3833
+ const l = dn(i);
3834
3834
  l && t.push(l);
3835
3835
  continue;
3836
3836
  }
3837
3837
  if (i.type === "data-tool-activity") {
3838
- const l = fn.safeParse(i.data);
3838
+ const l = un.safeParse(i.data);
3839
3839
  l.success && r({
3840
3840
  kind: "tool",
3841
3841
  label: l.data.label,
3842
3842
  done: l.data.done
3843
3843
  });
3844
- } else if (i.type === Qt)
3845
- s || (s = { kind: "spec", parts: [] }, t.push(s)), s.parts.push({ type: Qt, data: i.data });
3844
+ } else if (i.type === Kt)
3845
+ s || (s = { kind: "spec", parts: [] }, t.push(s)), s.parts.push({ type: Kt, data: i.data });
3846
3846
  else if (i.type === "text") {
3847
3847
  const l = typeof i.text == "string" ? i.text : "";
3848
3848
  l.trim().length > 0 && t.push({ kind: "text", text: l });
@@ -3854,49 +3854,49 @@ function Ge(e) {
3854
3854
  kind: "tool",
3855
3855
  label: typeof i.toolName == "string" ? i.toolName : "tool",
3856
3856
  done: a(i.state),
3857
- ...Xt(i)
3857
+ ...Yt(i)
3858
3858
  }) : i.type.startsWith("tool-") && r({
3859
3859
  kind: "tool",
3860
3860
  label: i.type.slice(5),
3861
3861
  done: a(i.state),
3862
- ...Xt(i)
3862
+ ...Yt(i)
3863
3863
  });
3864
3864
  }
3865
3865
  return t;
3866
3866
  }
3867
- function Rr(e) {
3867
+ function xr(e) {
3868
3868
  return e.type === "dynamic-tool" ? typeof e.toolName == "string" ? e.toolName : void 0 : e.type.startsWith("tool-") ? e.type.slice(5) : void 0;
3869
3869
  }
3870
- function mn(e) {
3871
- return ln(Rr(e));
3870
+ function cn(e) {
3871
+ return an(xr(e));
3872
3872
  }
3873
- function gn(e) {
3874
- const t = typeof e.toolCallId == "string" ? e.toolCallId : void 0, r = Gt(e.output, t) ?? Gt(e.input, t);
3873
+ function dn(e) {
3874
+ const t = typeof e.toolCallId == "string" ? e.toolCallId : void 0, r = Jt(e.output, t) ?? Jt(e.input, t);
3875
3875
  return r ? { kind: "questions", request: r } : null;
3876
3876
  }
3877
- function Xt(e) {
3877
+ function Yt(e) {
3878
3878
  return {
3879
3879
  ...e.input === void 0 ? {} : { input: e.input },
3880
3880
  ...e.output === void 0 ? {} : { output: e.output }
3881
3881
  };
3882
3882
  }
3883
- function hn(e) {
3883
+ function pn(e) {
3884
3884
  return ({ id: t }) => ({
3885
3885
  api: e.reconnectApi(t),
3886
3886
  headers: e.headers()
3887
3887
  });
3888
3888
  }
3889
- function vn(e) {
3890
- return new St({
3889
+ function fn(e) {
3890
+ return new yt({
3891
3891
  api: e.api,
3892
3892
  headers: () => e.headers(),
3893
3893
  // Every send carries its full body; a send without one is a programming
3894
3894
  // error, and an empty body would be rejected server-side just as loudly.
3895
3895
  prepareSendMessagesRequest: ({ body: t }) => ({ body: t ?? {} }),
3896
- prepareReconnectToStreamRequest: hn(e)
3896
+ prepareReconnectToStreamRequest: pn(e)
3897
3897
  });
3898
3898
  }
3899
- function yn({
3899
+ function mn({
3900
3900
  existing: e,
3901
3901
  fetched: t,
3902
3902
  refreshItems: r = !1
@@ -3908,11 +3908,11 @@ function yn({
3908
3908
  if (s.add(n.turn_id), n.message_uuids.length === 0) continue;
3909
3909
  const f = a.get(n.turn_id);
3910
3910
  if (f && !r) {
3911
- bn(f.rowIds, n.message_uuids) ? i.push(f) : i.push({ ...f, rowIds: n.message_uuids });
3911
+ gn(f.rowIds, n.message_uuids) ? i.push(f) : i.push({ ...f, rowIds: n.message_uuids });
3912
3912
  continue;
3913
3913
  }
3914
3914
  if (n.ui_parts !== null) {
3915
- const u = Ge(n.ui_parts);
3915
+ const u = He(n.ui_parts);
3916
3916
  if (u.length === 0) continue;
3917
3917
  i.push({
3918
3918
  key: (f == null ? void 0 : f.key) ?? `turn-${n.turn_id}`,
@@ -3926,30 +3926,16 @@ function yn({
3926
3926
  s.has(n.turnId) || i.push(n);
3927
3927
  return i.length === e.length && i.every((n, f) => n === e[f]) ? e : i;
3928
3928
  }
3929
- const bn = (e, t) => e.length === t.length && e.every((r, a) => r === t[a]), Sn = (e) => Array.isArray(e) && e.every((t) => typeof t == "string");
3930
- function En(e) {
3929
+ const gn = (e, t) => e.length === t.length && e.every((r, a) => r === t[a]), hn = (e) => Array.isArray(e) && e.every((t) => typeof t == "string");
3930
+ function Ht(e) {
3931
3931
  for (const t of e) {
3932
3932
  if (t.type !== "data-turn-settled") continue;
3933
3933
  const r = t.data;
3934
- return !Gr(r) || typeof r.turn_id != "string" || !Sn(r.message_uuids) ? null : { turnId: r.turn_id, rowIds: r.message_uuids };
3934
+ return !Kr(r) || typeof r.turn_id != "string" || !hn(r.message_uuids) ? null : { turnId: r.turn_id, rowIds: r.message_uuids };
3935
3935
  }
3936
3936
  return null;
3937
3937
  }
3938
- async function Cn(e) {
3939
- const t = e.getReader();
3940
- try {
3941
- for (; ; ) {
3942
- const { value: r, done: a } = await t.read();
3943
- if (a || r === void 0) return { kind: "silent" };
3944
- if (!tr(r))
3945
- return Qr(r) ? { kind: "steered" } : r.type === "error" ? { kind: "failed", errorText: r.errorText } : { kind: "turn" };
3946
- }
3947
- } finally {
3948
- await t.cancel().catch(() => {
3949
- });
3950
- }
3951
- }
3952
- async function In({
3938
+ async function vn({
3953
3939
  api: e,
3954
3940
  sessionId: t,
3955
3941
  chatStop: r
@@ -3960,35 +3946,35 @@ async function In({
3960
3946
  t && await e.stopStream(t);
3961
3947
  }
3962
3948
  }
3963
- const er = 20, wn = "highlight_element";
3964
- function _n({
3949
+ const Gt = 20, yn = "highlight_element";
3950
+ function bn({
3965
3951
  widgetCtx: e,
3966
3952
  config: t,
3967
3953
  sessionId: r,
3968
3954
  persistedMessages: a
3969
3955
  }) {
3970
- var Mt, Tt;
3971
- const { api: s, messageCtx: i } = e, l = j(t);
3956
+ var wt, _t;
3957
+ const { api: s, messageCtx: i } = e, l = D(t);
3972
3958
  l.current = t;
3973
- const { pageContext: n, clientTools: f } = e.features, u = J(
3974
- () => vn({
3959
+ const { pageContext: n, clientTools: f } = e.features, u = B(
3960
+ () => fn({
3975
3961
  ...s.getStreamTransportOptions(),
3976
3962
  headers: () => s.getStreamTransportOptions().headers,
3977
- reconnectApi: (b) => {
3978
- const I = new URL(s.getStreamTransportOptions().reconnectApi(b)), T = l.current.presentation;
3979
- return T != null && T.toolActivity && I.searchParams.set("toolActivity", T.toolActivity), (T == null ? void 0 : T.reasoning) !== void 0 && I.searchParams.set("reasoning", String(T.reasoning)), I.toString();
3963
+ reconnectApi: (S) => {
3964
+ const x = new URL(s.getStreamTransportOptions().reconnectApi(S)), R = l.current.presentation;
3965
+ return R != null && R.toolActivity && x.searchParams.set("toolActivity", R.toolActivity), (R == null ? void 0 : R.reasoning) !== void 0 && x.searchParams.set("reasoning", String(R.reasoning)), x.toString();
3980
3966
  }
3981
3967
  }),
3982
3968
  [s]
3983
- ), [c, p] = K(null), v = j(!1), {
3969
+ ), [c, p] = V(null), v = D(!1), {
3984
3970
  status: h,
3985
- messages: x,
3971
+ messages: _,
3986
3972
  sendMessage: M,
3987
3973
  stop: E,
3988
3974
  error: C,
3989
3975
  clearError: w,
3990
- resumeStream: O
3991
- } = an({
3976
+ resumeStream: N
3977
+ } = Xs({
3992
3978
  id: r ?? void 0,
3993
3979
  // Reattach to a still-live turn (reload, tab switch) — but only once a
3994
3980
  // session actually exists. A fresh visitor has nothing to resume, and the
@@ -4000,351 +3986,307 @@ function _n({
4000
3986
  // whole chat surface (transcript + composer), which stutters on long
4001
3987
  // replies inside customer pages.
4002
3988
  throttle: 50,
4003
- onError: (b) => B.error("agent chat stream error", b),
3989
+ onError: (S) => ne.error("agent chat stream error", S),
4004
3990
  onFinish: p
4005
- }), d = j(x);
4006
- d.current = x;
4007
- const g = j(new Yt(er)), m = j("idle"), S = j(Promise.resolve()), y = j(0), _ = j(0), P = j(0), [fe, ne] = K(0), [re, V] = K(!1), Te = j(re);
4008
- Te.current = re;
4009
- const [Ct, Ze] = K([]), [Zr, zr] = K(null), Re = j(null), me = F((b) => {
4010
- Re.current = b, zr(b);
4011
- }, []), Se = j(null), Ee = j(null), Ce = j(h), It = j(r), tt = j(null), rt = j(null), wt = j(E), ie = j(h);
4012
- ie.current = h;
4013
- const ze = F((b, I) => {
4014
- const T = En(b.parts);
4015
- if (!T || T.rowIds.length === 0) return;
4016
- const k = Ge(b.parts);
4017
- k.length !== 0 && Ze(
4018
- (L) => L.some((le) => le.turnId === T.turnId) ? L : [
3991
+ }), d = D(_);
3992
+ d.current = _;
3993
+ const g = D(new Bt(Gt)), m = D("idle"), b = D(Promise.resolve()), y = D(0), I = D(0), [k, Y] = V(0), [te, ie] = V(!1), Q = D(te);
3994
+ Q.current = te;
3995
+ const [Me, Ze] = V([]), [Fr, $r] = V(null), Te = D(null), me = q((S) => {
3996
+ Te.current = S, $r(S);
3997
+ }, []), Se = D(null), Re = D(null), Ee = D(h), St = D(r), et = D(null), tt = D(null), Et = D(E), oe = D(h);
3998
+ oe.current = h;
3999
+ const ze = q((S, x) => {
4000
+ const R = Ht(S.parts);
4001
+ if (!R || R.rowIds.length === 0) return;
4002
+ const P = He(S.parts);
4003
+ P.length !== 0 && Ze(
4004
+ (L) => L.some((le) => le.turnId === R.turnId) ? L : [
4019
4005
  ...L,
4020
- { key: I, turnId: T.turnId, rowIds: T.rowIds, items: k }
4006
+ { key: x, turnId: R.turnId, rowIds: R.rowIds, items: P }
4021
4007
  ]
4022
4008
  );
4023
- }, []), We = F(
4024
- (b) => Xr({
4009
+ }, []), Ct = q(
4010
+ (S) => Yr({
4025
4011
  config: l.current,
4026
- input: b.input,
4027
- uuid: b.retryUuid ?? b.userMessage.id,
4028
- sessionId: b.sessionId,
4029
- content: b.userMessage.content,
4030
- initialMessages: b.initialMessages,
4012
+ input: S.input,
4013
+ uuid: S.retryUuid ?? S.userMessage.id,
4014
+ sessionId: S.sessionId,
4015
+ content: S.userMessage.content,
4016
+ initialMessages: S.initialMessages,
4031
4017
  sendsPageContext: n
4032
4018
  }),
4033
4019
  [n]
4034
- ), _t = F(
4035
- async (b) => {
4036
- const I = P.current, T = new AbortController();
4037
- let k;
4038
- try {
4039
- const L = await u.sendMessages({
4040
- trigger: "submit-message",
4041
- chatId: b.sessionId,
4042
- messageId: void 0,
4043
- messages: [],
4044
- abortSignal: T.signal,
4045
- body: We(b)
4046
- });
4047
- k = await Cn(L);
4048
- } catch (L) {
4049
- B.error("agent chat steer failed", L);
4050
- return;
4051
- } finally {
4052
- T.abort();
4053
- }
4054
- if (I === P.current) {
4055
- switch (k.kind) {
4056
- case "steered":
4057
- i.markUserMessageDelivered(b.userMessage.id);
4058
- return;
4059
- case "turn":
4060
- Ee.current = b;
4061
- try {
4062
- await E();
4063
- } catch (L) {
4064
- B.error("agent chat steer fallback: client stop failed", L);
4065
- }
4066
- if (I !== P.current) return;
4067
- await O();
4068
- return;
4069
- case "failed":
4070
- B.error("agent chat steer: the turn failed", {
4071
- errorText: k.errorText
4072
- });
4073
- break;
4074
- case "silent":
4075
- i.markUserMessageDelivered(b.userMessage.id);
4076
- break;
4077
- }
4078
- await e.reconcileAfterStream(b.sessionId).catch((L) => {
4079
- B.error("agent chat post-steer reconcile failed", L);
4080
- });
4081
- }
4082
- },
4083
- [u, We, i, E, O, e]
4084
- ), xt = j(_t);
4085
- xt.current = _t, q(() => {
4086
- const b = wt.current;
4087
- wt.current = E;
4088
- const I = It.current;
4089
- if (I === r) return;
4090
- if (It.current = r, I === null) {
4020
+ );
4021
+ Z(() => {
4022
+ const S = Et.current;
4023
+ Et.current = E;
4024
+ const x = St.current;
4025
+ if (x === r) return;
4026
+ if (St.current = r, x === null) {
4091
4027
  Ze([]);
4092
4028
  return;
4093
4029
  }
4094
- const T = ie.current === "submitted" || ie.current === "streaming" || Ce.current === "submitted" || Ce.current === "streaming" || m.current === "in-flight";
4095
- P.current += 1, y.current = 0, _.current = 0, S.current = Promise.resolve(), g.current = new Yt(er), m.current = "idle", Ee.current = null, Se.current = null, p(null), v.current = !1, rt.current = null, tt.current = h === "submitted" || h === "streaming" ? h : null, Ce.current = "ready", ie.current = "ready", w(), ne((k) => k + 1), V(!1), Ze([]), me(null), T && Promise.resolve().then(() => b()).catch((k) => {
4096
- B.error("agent chat client stream cancel failed", k);
4030
+ const R = oe.current === "submitted" || oe.current === "streaming" || Ee.current === "submitted" || Ee.current === "streaming" || m.current === "in-flight";
4031
+ I.current += 1, y.current = 0, b.current = Promise.resolve(), g.current = new Bt(Gt), m.current = "idle", Re.current = null, Se.current = null, p(null), v.current = !1, tt.current = null, et.current = h === "submitted" || h === "streaming" ? h : null, Ee.current = "ready", oe.current = "ready", w(), Y((P) => P + 1), ie(!1), Ze([]), me(null), R && Promise.resolve().then(() => S()).catch((P) => {
4032
+ ne.error("agent chat client stream cancel failed", P);
4097
4033
  });
4098
- }, [r, h, E, w, me]), q(() => {
4034
+ }, [r, h, E, w, me]), Z(() => {
4099
4035
  var L, le;
4100
- const b = tt.current;
4101
- if (b !== null && h === b) {
4102
- Ce.current = "ready";
4036
+ const S = et.current;
4037
+ if (S !== null && h === S) {
4038
+ Ee.current = "ready";
4103
4039
  return;
4104
4040
  }
4105
- tt.current = null;
4106
- const I = Ce.current;
4107
- if (Ce.current = h, (h === "submitted" || h === "streaming") && (I !== "submitted" && I !== "streaming" && Re.current === null && me(`turn-resumed-${Rt()}`), V(!0)), h === "streaming") {
4108
- const W = (L = Ee.current) == null ? void 0 : L.userMessage.id;
4109
- W && i.markUserMessageDelivered(W);
4041
+ et.current = null;
4042
+ const x = Ee.current;
4043
+ if (Ee.current = h, (h === "submitted" || h === "streaming") && (x !== "submitted" && x !== "streaming" && Te.current === null && me(`turn-resumed-${xt()}`), ie(!0)), h === "streaming") {
4044
+ const U = (L = Re.current) == null ? void 0 : L.userMessage.id;
4045
+ U && i.markUserMessageDelivered(U);
4110
4046
  return;
4111
4047
  }
4112
4048
  if (h !== "ready" && h !== "error") return;
4113
- if (I === "streaming" || I === "submitted" || // An empty response can finish before React observes an active status.
4049
+ if (x === "streaming" || x === "submitted" || // An empty response can finish before React observes an active status.
4114
4050
  m.current === "in-flight" && (c == null ? void 0 : c.messages) === d.current) {
4115
- V(!0), m.current === "in-flight" && (m.current = "idle");
4116
- const W = d.current.at(-1), ue = Re.current;
4117
- if (Se.current = ue, ue !== null && W && W.role === "assistant" && ze(W, ue), h === "ready") {
4118
- const X = (le = Ee.current) == null ? void 0 : le.userMessage.id;
4119
- X && i.markUserMessageDelivered(X);
4051
+ ie(!0), m.current === "in-flight" && (m.current = "idle");
4052
+ const U = d.current.at(-1), ue = Te.current;
4053
+ if (Se.current = ue, ue !== null && U && U.role === "assistant" && ze(U, ue), h === "ready") {
4054
+ const ce = (le = Re.current) == null ? void 0 : le.userMessage.id;
4055
+ ce && i.markUserMessageDelivered(ce);
4120
4056
  }
4121
- m.current === "stopping" || (r ? (m.current = "reconciling", e.reconcileAfterStream(r).catch((X) => {
4122
- B.error("agent chat post-turn reconcile failed", X);
4057
+ m.current === "stopping" || (r ? (m.current = "reconciling", e.reconcileAfterStream(r).catch((ce) => {
4058
+ ne.error("agent chat post-turn reconcile failed", ce);
4123
4059
  }).finally(() => {
4124
- m.current === "reconciling" && (m.current = "idle"), ne((X) => X + 1);
4125
- })) : V(!1));
4060
+ m.current === "reconciling" && (m.current = "idle"), Y((ce) => ce + 1);
4061
+ })) : ie(!1));
4126
4062
  }
4127
- if (m.current !== "idle" || !r) return;
4128
- const k = g.current.dequeueNext();
4129
- k && (m.current = "in-flight", Ee.current = k, p(null), v.current = !1, me(`turn-${k.userMessage.id}`), i.appendUserMessageIfAbsent(k.userMessage), ne((W) => W + 1), M(
4130
- { text: k.userMessage.content },
4131
- { body: We(k) }
4063
+ if (m.current !== "idle" || !r || Q.current && h !== "error") return;
4064
+ const P = g.current.dequeueNext();
4065
+ P && (m.current = "in-flight", Re.current = P, p(null), v.current = !1, me(`turn-${P.userMessage.id}`), i.appendUserMessageIfAbsent(P.userMessage), Y((U) => U + 1), M(
4066
+ { text: P.userMessage.content },
4067
+ { body: Ct(P) }
4132
4068
  ));
4133
4069
  }, [
4134
4070
  h,
4135
4071
  r,
4136
- fe,
4072
+ k,
4137
4073
  M,
4138
4074
  i,
4139
4075
  e,
4140
- We,
4076
+ Ct,
4141
4077
  ze,
4142
4078
  me,
4143
4079
  c
4144
4080
  ]);
4145
- const At = F(
4146
- (b) => {
4147
- const I = P.current;
4081
+ const It = q(
4082
+ (S) => {
4083
+ const x = I.current;
4148
4084
  y.current++;
4149
- const k = S.current.then(
4085
+ const P = b.current.then(
4150
4086
  async () => {
4151
- if (I !== P.current) return;
4152
- const L = m.current, le = ie.current === "streaming" && L !== "stopping" && L !== "reconciling" && g.current.size === 0, ue = ie.current === "submitted" || ie.current === "streaming" || L !== "idle" || g.current.size > 0 ? xn(i.buildQueuedUserMessage(b)) : await i.stageUserTurn(b, { pending: !0 });
4153
- if (!ue || I !== P.current) return;
4154
- const X = { ...ue, input: b };
4155
- if (le) {
4156
- i.appendUserMessageIfAbsent(X.userMessage), i.notifySendAccepted(b), _.current++, xt.current(X).catch(
4157
- (at) => B.error("agent chat steer failed", at)
4158
- ).finally(() => {
4159
- I === P.current && _.current--;
4160
- });
4161
- return;
4162
- }
4163
- if (!g.current.enqueue(X)) {
4164
- B.warn("agent chat queue full; rejecting newest send", {
4165
- rejectedMessageId: X.userMessage.id
4087
+ if (x !== I.current) return;
4088
+ const L = m.current, U = oe.current === "submitted" || oe.current === "streaming" || L !== "idle" || Q.current || g.current.size > 0 ? Sn(i.buildQueuedUserMessage(S)) : await i.stageUserTurn(S, { pending: !0 });
4089
+ if (!U || x !== I.current) return;
4090
+ const ue = { ...U, input: S };
4091
+ if (!g.current.enqueue(ue)) {
4092
+ ne.warn("agent chat queue full; rejecting newest send", {
4093
+ rejectedMessageId: ue.userMessage.id
4166
4094
  });
4167
4095
  return;
4168
4096
  }
4169
- ne((at) => at + 1), i.notifySendAccepted(b);
4097
+ Y((ce) => ce + 1), i.notifySendAccepted(S);
4170
4098
  }
4171
4099
  ).finally(() => {
4172
- I === P.current && y.current--;
4100
+ x === I.current && y.current--;
4173
4101
  });
4174
- return S.current = k.then(
4102
+ return b.current = P.then(
4175
4103
  () => {
4176
4104
  },
4177
4105
  () => {
4178
4106
  }
4179
- ), k;
4107
+ ), P;
4180
4108
  },
4181
4109
  [i]
4182
- ), Wr = F(() => {
4183
- const b = Ee.current;
4184
- if (!b) return;
4110
+ ), Ur = q(() => {
4111
+ const S = Re.current;
4112
+ if (!S) return;
4185
4113
  if (!g.current.enqueue({
4186
- ...b,
4187
- retryUuid: Rt()
4114
+ ...S,
4115
+ retryUuid: xt()
4188
4116
  })) {
4189
- B.warn("agent chat queue full; retry not enqueued");
4117
+ ne.warn("agent chat queue full; retry not enqueued");
4190
4118
  return;
4191
4119
  }
4192
- w(), ne((T) => T + 1);
4193
- }, [w]), Br = F((b) => {
4120
+ w(), Y((R) => R + 1);
4121
+ }, [w]), qr = q((S) => {
4194
4122
  g.current.removeWhere(
4195
- (T) => T.userMessage.id === b
4196
- ) && ne((T) => T + 1);
4197
- }, []), Vr = F(() => {
4123
+ (R) => R.userMessage.id === S
4124
+ ) && Y((R) => R + 1);
4125
+ }, []), Zr = q(() => {
4198
4126
  m.current = "stopping", v.current = !1;
4199
- const b = P.current;
4200
- In({ api: s, sessionId: r, chatStop: E }).then(() => {
4201
- b === P.current && (v.current = !0);
4202
- }).catch((I) => {
4203
- B.error("agent chat stop failed", I);
4127
+ const S = I.current;
4128
+ vn({ api: s, sessionId: r, chatStop: E }).then(() => {
4129
+ S === I.current && (v.current = !0);
4130
+ }).catch((x) => {
4131
+ ne.error("agent chat stop failed", x);
4204
4132
  }).then(() => {
4205
- if (b === P.current) {
4133
+ if (S === I.current) {
4206
4134
  if (!r) {
4207
- V(!1);
4135
+ ie(!1);
4208
4136
  return;
4209
4137
  }
4210
- return e.reconcileAfterStream(r).catch((I) => {
4211
- B.error("agent chat post-stop reconcile failed", I);
4138
+ return e.reconcileAfterStream(r).catch((x) => {
4139
+ ne.error("agent chat post-stop reconcile failed", x);
4212
4140
  });
4213
4141
  }
4214
4142
  }).finally(() => {
4215
- b === P.current && (m.current = "idle", ne((I) => I + 1));
4143
+ S === I.current && (m.current = "idle", Y((x) => x + 1));
4216
4144
  });
4217
4145
  }, [s, r, E, e]);
4218
- q(() => {
4219
- const b = {
4220
- send: At,
4221
- hasPendingWork: () => y.current > 0 || _.current > 0 || Te.current || g.current.size > 0 || m.current !== "idle" || ie.current === "submitted" || ie.current === "streaming"
4146
+ Z(() => {
4147
+ const S = {
4148
+ send: It,
4149
+ hasPendingWork: () => y.current > 0 || Q.current || g.current.size > 0 || m.current !== "idle" || oe.current === "submitted" || oe.current === "streaming"
4222
4150
  };
4223
- return i.registerAgentHandlers(b), () => i.unregisterAgentHandlers(b);
4224
- }, [i, At]);
4225
- const Be = (Mt = t.presentation) == null ? void 0 : Mt.toolActivity, Ve = (Tt = t.presentation) == null ? void 0 : Tt.reasoning;
4226
- q(() => {
4151
+ return i.registerAgentHandlers(S), () => i.unregisterAgentHandlers(S);
4152
+ }, [i, It]);
4153
+ const We = (wt = t.presentation) == null ? void 0 : wt.toolActivity, Be = (_t = t.presentation) == null ? void 0 : _t.reasoning;
4154
+ Z(() => {
4227
4155
  var L, le;
4228
4156
  if (!r) return;
4229
- const b = Be === void 0 && Ve === void 0 ? void 0 : { toolActivity: Be, reasoning: Ve }, I = rt.current, T = (I == null ? void 0 : I.sessionId) === r && (((L = I.presentation) == null ? void 0 : L.toolActivity) !== Be || ((le = I.presentation) == null ? void 0 : le.reasoning) !== Ve);
4230
- rt.current = { sessionId: r, presentation: b };
4231
- let k = !1;
4157
+ const S = We === void 0 && Be === void 0 ? void 0 : { toolActivity: We, reasoning: Be }, x = tt.current, R = (x == null ? void 0 : x.sessionId) === r && (((L = x.presentation) == null ? void 0 : L.toolActivity) !== We || ((le = x.presentation) == null ? void 0 : le.reasoning) !== Be);
4158
+ tt.current = { sessionId: r, presentation: S };
4159
+ let P = !1;
4232
4160
  return (async () => {
4233
4161
  try {
4234
- const W = b === void 0 ? await s.getAgentTurnMessages(r) : await s.getAgentTurnMessages(r, b);
4235
- if (!W || k) return;
4162
+ const U = S === void 0 ? await s.getAgentTurnMessages(r) : await s.getAgentTurnMessages(r, S);
4163
+ if (!U || P) return;
4236
4164
  Ze(
4237
- (ue) => yn({ existing: ue, fetched: W, refreshItems: T })
4165
+ (ue) => mn({ existing: ue, fetched: U, refreshItems: R })
4238
4166
  );
4239
- } catch (W) {
4240
- B.error("agent chat turn sources fetch failed", W);
4167
+ } catch (U) {
4168
+ ne.error("agent chat turn sources fetch failed", U);
4241
4169
  }
4242
4170
  })(), () => {
4243
- k = !0;
4171
+ P = !0;
4244
4172
  };
4245
- }, [r, s, Be, Ve]);
4246
- const Jr = J(() => {
4173
+ }, [r, s, We, Be]);
4174
+ const zr = B(() => {
4247
4175
  if (!f) return [];
4248
- const b = x.at(-1);
4249
- if (!b || b.role !== "assistant") return [];
4250
- const I = [];
4251
- for (const T of b.parts)
4252
- Ae(T) && Ws(T) === wn && (T.state !== "input-available" && T.state !== "output-available" || I.push({
4253
- key: `${r ?? "pending"}:${T.toolCallId}`,
4176
+ const S = _.at(-1);
4177
+ if (!S || S.role !== "assistant") return [];
4178
+ const x = [];
4179
+ for (const R of S.parts)
4180
+ xe(R) && Us(R) === yn && (R.state !== "input-available" && R.state !== "output-available" || x.push({
4181
+ key: `${r ?? "pending"}:${R.toolCallId}`,
4254
4182
  type: "highlight-element",
4255
- input: T.input
4183
+ input: R.input
4256
4184
  }));
4257
- return I;
4258
- }, [x, r, f]), oe = h === "submitted" || h === "streaming";
4259
- q(() => {
4260
- if (oe) return;
4261
- const b = Se.current;
4262
- if (b === null) return;
4263
- const I = x.at(-1);
4264
- I && I.role === "assistant" && ze(I, b);
4265
- }, [x, oe, ze]), q(() => {
4266
- const b = () => {
4267
- document.visibilityState === "visible" && r && (oe || C === void 0 && !re || O());
4185
+ return x;
4186
+ }, [_, r, f]), se = h === "submitted" || h === "streaming";
4187
+ Z(() => {
4188
+ if (se) return;
4189
+ const S = Se.current;
4190
+ if (S === null) return;
4191
+ const x = _.at(-1);
4192
+ x && x.role === "assistant" && ze(x, S);
4193
+ }, [_, se, ze]), Z(() => {
4194
+ const S = () => {
4195
+ document.visibilityState === "visible" && r && (se || C === void 0 && !te || N());
4268
4196
  };
4269
- return document.addEventListener("visibilitychange", b), window.addEventListener("online", b), () => {
4270
- document.removeEventListener("visibilitychange", b), window.removeEventListener("online", b);
4197
+ return document.addEventListener("visibilitychange", S), window.addEventListener("online", S), () => {
4198
+ document.removeEventListener("visibilitychange", S), window.removeEventListener("online", S);
4271
4199
  };
4272
- }, [r, oe, re, C, O]), q(() => {
4273
- if (oe || !re) return;
4274
- const b = () => {
4275
- V(!1), Re.current === Se.current && me(null), Se.current = null;
4200
+ }, [r, se, te, C, N]), Z(() => {
4201
+ if (se || !te) return;
4202
+ const S = () => {
4203
+ ie(!1), Y((P) => P + 1), Te.current === Se.current && me(null), Se.current = null;
4276
4204
  };
4277
- if (Re.current === Se.current && (c == null ? void 0 : c.messages) === x && !c.isError && !c.isDisconnect && (!c.isAbort || v.current) && !Ge(c.message.parts).some(
4278
- (I) => I.kind !== "steps"
4205
+ if (Te.current === Se.current && (c == null ? void 0 : c.messages) === _ && !c.isError && !c.isDisconnect && (!c.isAbort || v.current) && !He(c.message.parts).some(
4206
+ (P) => P.kind !== "steps"
4279
4207
  )) {
4280
- const I = a.findLast((T) => T.type === "USER");
4281
- I && i.state.setPartial({ settledAgentUserMessageId: I.id }), b();
4208
+ const P = a.findLast((L) => L.type === "USER");
4209
+ P && i.state.setPartial({ settledAgentUserMessageId: P.id }), S();
4282
4210
  return;
4283
4211
  }
4284
- for (let I = a.length - 1; I >= 0; I -= 1) {
4285
- const T = a[I];
4286
- if (T) {
4287
- if (T.type === "USER") return;
4288
- if (!(T.type !== "AI" && T.type !== "AGENT")) {
4289
- b();
4212
+ if (c && c.messages !== _) return;
4213
+ const x = _.at(-1), R = (x == null ? void 0 : x.role) === "assistant" ? Ht(x.parts) : null;
4214
+ if (R && R.rowIds.length > 0) {
4215
+ const P = new Set(a.map((L) => L.id));
4216
+ R.rowIds.every((L) => P.has(L)) && S();
4217
+ return;
4218
+ }
4219
+ for (let P = a.length - 1; P >= 0; P -= 1) {
4220
+ const L = a[P];
4221
+ if (L) {
4222
+ if (L.type === "USER") return;
4223
+ if (!(L.type !== "AI" && L.type !== "AGENT")) {
4224
+ S();
4290
4225
  return;
4291
4226
  }
4292
4227
  }
4293
4228
  }
4294
4229
  }, [
4295
- oe,
4296
- re,
4230
+ se,
4231
+ te,
4297
4232
  a,
4298
4233
  me,
4299
4234
  c,
4300
- x,
4235
+ _,
4301
4236
  i,
4302
- fe
4237
+ k
4303
4238
  ]);
4304
- const Ie = ea(
4239
+ const Ce = Hr(
4305
4240
  e.agent.presentation,
4306
4241
  t.presentation
4307
- ), Je = Ie == null ? void 0 : Ie.toolActivity, Ke = Ie == null ? void 0 : Ie.reasoning, Kr = J(() => {
4308
- if (!oe && !re) return [];
4309
- const b = x.at(-1);
4310
- return !b || b.role !== "assistant" ? [] : Ht(Ge(b.parts), {
4311
- toolActivity: Je,
4312
- reasoning: Ke
4242
+ ), Ve = Ce == null ? void 0 : Ce.toolActivity, Je = Ce == null ? void 0 : Ce.reasoning, Wr = B(() => {
4243
+ if (h === "submitted" || !se && !te) return [];
4244
+ const S = _.at(-1);
4245
+ return !S || S.role !== "assistant" ? [] : Vt(He(S.parts), {
4246
+ toolActivity: Ve,
4247
+ reasoning: Je
4313
4248
  });
4314
- }, [x, oe, re, Je, Ke]), Yr = J(
4315
- () => Ct.flatMap((b) => {
4316
- const I = Ht(b.items, {
4317
- toolActivity: Je,
4318
- reasoning: Ke
4249
+ }, [
4250
+ _,
4251
+ h,
4252
+ se,
4253
+ te,
4254
+ Ve,
4255
+ Je
4256
+ ]), Br = B(
4257
+ () => Me.flatMap((S) => {
4258
+ const x = Vt(S.items, {
4259
+ toolActivity: Ve,
4260
+ reasoning: Je
4319
4261
  });
4320
- return I.length === 0 ? [] : [I === b.items ? b : { ...b, items: I }];
4262
+ return x.length === 0 ? [] : [x === S.items ? S : { ...S, items: x }];
4321
4263
  }),
4322
- [Ct, Je, Ke]
4323
- ), Hr = J(
4324
- () => g.current.items.map((b) => b.userMessage),
4264
+ [Me, Ve, Je]
4265
+ ), Vr = B(
4266
+ () => g.current.items.map((S) => S.userMessage),
4325
4267
  // eslint-disable-next-line react-hooks/exhaustive-deps -- queueRef is mutable; queueVersion is the signal
4326
- [fe]
4268
+ [k]
4327
4269
  );
4328
4270
  return {
4329
- isStreaming: oe,
4330
- liveItems: Kr,
4271
+ isStreaming: se,
4272
+ liveItems: Wr,
4331
4273
  /** Finished turns' render sources — see `TurnRenderSource`. */
4332
- turnSources: Yr,
4274
+ turnSources: Br,
4333
4275
  /** The live turn's node key (stable through the retained promotion). */
4334
- liveTurnKey: Zr,
4276
+ liveTurnKey: Fr,
4335
4277
  /** The last turn failed — the transcript renders a visible error row. */
4336
4278
  turnFailed: C !== void 0,
4337
- retryFailedTurn: Wr,
4338
- queuedUserMessages: Hr,
4339
- removeQueued: Br,
4340
- stop: Vr,
4341
- pageEffects: Jr
4279
+ retryFailedTurn: Ur,
4280
+ queuedUserMessages: Vr,
4281
+ removeQueued: qr,
4282
+ stop: Zr,
4283
+ pageEffects: zr
4342
4284
  };
4343
4285
  }
4344
- function xn(e) {
4286
+ function Sn(e) {
4345
4287
  return e ? { ...e, initialMessages: [] } : null;
4346
4288
  }
4347
- const Et = {
4289
+ const bt = {
4348
4290
  isStreaming: !1,
4349
4291
  liveItems: [],
4350
4292
  turnSources: [],
@@ -4359,17 +4301,17 @@ const Et = {
4359
4301
  },
4360
4302
  pageEffects: [],
4361
4303
  pendingClarification: null
4362
- }, Xe = Fe(null);
4363
- function Pr() {
4364
- return $e(Xe) ?? Et;
4304
+ }, Qe = Fe(null);
4305
+ function Ar() {
4306
+ return $e(Qe) ?? bt;
4365
4307
  }
4366
- function An({
4308
+ function En({
4367
4309
  children: e,
4368
4310
  widgetCtx: t,
4369
4311
  config: r
4370
4312
  }) {
4371
4313
  var C, w;
4372
- const a = U(t.sessionCtx.sessionState), s = U(t.messageCtx.state), {
4314
+ const a = $(t.sessionCtx.sessionState), s = $(t.messageCtx.state), {
4373
4315
  isStreaming: i,
4374
4316
  liveItems: l,
4375
4317
  turnSources: n,
@@ -4379,13 +4321,13 @@ function An({
4379
4321
  queuedUserMessages: p,
4380
4322
  removeQueued: v,
4381
4323
  stop: h,
4382
- pageEffects: x
4383
- } = _n({
4324
+ pageEffects: _
4325
+ } = bn({
4384
4326
  widgetCtx: t,
4385
4327
  config: r,
4386
4328
  sessionId: ((C = a.session) == null ? void 0 : C.id) ?? null,
4387
4329
  persistedMessages: s.messages
4388
- }), M = ((w = s.messages.at(-1)) == null ? void 0 : w.type) === "USER", E = J(
4330
+ }), M = ((w = s.messages.at(-1)) == null ? void 0 : w.type) === "USER", E = B(
4389
4331
  () => ({
4390
4332
  isStreaming: i,
4391
4333
  liveItems: l,
@@ -4396,8 +4338,8 @@ function An({
4396
4338
  queuedUserMessages: p,
4397
4339
  removeQueued: v,
4398
4340
  stop: h,
4399
- pageEffects: x,
4400
- pendingClarification: oa({
4341
+ pageEffects: _,
4342
+ pendingClarification: aa({
4401
4343
  turnSources: n,
4402
4344
  liveItems: l,
4403
4345
  isStreaming: i,
@@ -4414,20 +4356,20 @@ function An({
4414
4356
  p,
4415
4357
  v,
4416
4358
  h,
4417
- x,
4359
+ _,
4418
4360
  M
4419
4361
  ]
4420
4362
  );
4421
- return /* @__PURE__ */ $.createElement(Xe.Provider, { value: E }, e);
4363
+ return /* @__PURE__ */ F.createElement(Qe.Provider, { value: E }, e);
4422
4364
  }
4423
- function Or({
4365
+ function Mr({
4424
4366
  children: e,
4425
4367
  widgetCtx: t,
4426
4368
  config: r
4427
4369
  }) {
4428
- return U(t.messageCtx.state), t.streaming ? /* @__PURE__ */ $.createElement(An, { widgetCtx: t, config: r }, e) : /* @__PURE__ */ $.createElement(Xe.Provider, { value: Et }, e);
4370
+ return $(t.messageCtx.state), t.streaming ? /* @__PURE__ */ F.createElement(En, { widgetCtx: t, config: r }, e) : /* @__PURE__ */ F.createElement(Qe.Provider, { value: bt }, e);
4429
4371
  }
4430
- class Mn {
4372
+ class Cn {
4431
4373
  constructor(t) {
4432
4374
  this.root = t, this.nextId = 1, this.mountVersion = 0, this.disposed = !1, this.mount = () => {
4433
4375
  const a = ++this.mountVersion;
@@ -4500,7 +4442,7 @@ class Mn {
4500
4442
  });
4501
4443
  };
4502
4444
  const r = this.makeChat(t);
4503
- this.state = new rr({ chats: [r], activeId: r.id });
4445
+ this.state = new Qt({ chats: [r], activeId: r.id });
4504
4446
  }
4505
4447
  makeChat(t) {
4506
4448
  return {
@@ -4510,7 +4452,7 @@ class Mn {
4510
4452
  working: !1,
4511
4453
  hasSession: !1,
4512
4454
  hasDraft: !1,
4513
- ui: Et
4455
+ ui: bt
4514
4456
  };
4515
4457
  }
4516
4458
  releaseChat(t) {
@@ -4524,15 +4466,15 @@ class Mn {
4524
4466
  return !t.closed && !r && !this.isWorking(t) && !t.ctx.messageCtx.state.get().messages.length && !a && !s.length && !t.ctx.uploadCtx.state.get().length;
4525
4467
  }
4526
4468
  }
4527
- const Nr = Fe(null), Tn = new rr({ chats: [], activeId: 0 });
4528
- function jr() {
4529
- const e = $e(Nr), t = U((e == null ? void 0 : e.state) ?? Tn), r = t.chats.filter((s) => !s.closed), a = r.filter(
4469
+ const Tr = Fe(null), In = new Qt({ chats: [], activeId: 0 });
4470
+ function Rr() {
4471
+ const e = $e(Tr), t = $((e == null ? void 0 : e.state) ?? In), r = t.chats.filter((s) => !s.closed), a = r.filter(
4530
4472
  (s) => s.hasSession || s.working || s.hasDraft || s.title
4531
4473
  );
4532
4474
  return { workspace: e, chats: r, openChats: a, activeId: t.activeId };
4533
4475
  }
4534
- function Vn() {
4535
- const { workspace: e, ...t } = jr();
4476
+ function Un() {
4477
+ const { workspace: e, ...t } = Rr();
4536
4478
  if (!e)
4537
4479
  throw new Error("Companion chats require a conversation workspace");
4538
4480
  return {
@@ -4542,35 +4484,35 @@ function Vn() {
4542
4484
  newChat: e.open
4543
4485
  };
4544
4486
  }
4545
- function Rn({
4487
+ function wn({
4546
4488
  chat: e,
4547
4489
  workspace: t
4548
4490
  }) {
4549
- const r = Pr(), a = U(e.ctx.messageCtx.state), s = U(e.ctx.sessionCtx.sessionState), i = U(e.ctx.messageCtx.draftState), l = U(e.ctx.uploadCtx.state), n = a.messages.find(
4491
+ const r = Ar(), a = $(e.ctx.messageCtx.state), s = $(e.ctx.sessionCtx.sessionState), i = $(e.ctx.messageCtx.draftState), l = $(e.ctx.uploadCtx.state), n = a.messages.find(
4550
4492
  (v) => v.type === "USER"
4551
4493
  ), f = (n == null ? void 0 : n.type) === "USER" ? n.content.slice(0, 60) : "", u = r.isStreaming || a.isSendingMessage || s.isCreatingSession, c = !!s.session, p = !!i.text || i.mentions.length > 0 || l.length > 0;
4552
- return q(
4494
+ return Z(
4553
4495
  () => t.update(e.id, { title: f, working: u, hasSession: c, hasDraft: p, ui: r }),
4554
4496
  [t, e.id, f, u, c, p, r]
4555
4497
  ), null;
4556
4498
  }
4557
- function Pn({
4499
+ function _n({
4558
4500
  widgetCtx: e,
4559
4501
  config: t = e.config,
4560
4502
  children: r
4561
4503
  }) {
4562
- const a = J(
4563
- () => new Mn(e),
4504
+ const a = B(
4505
+ () => new Cn(e),
4564
4506
  [e]
4565
4507
  );
4566
- q(() => a.mount(), [a]);
4567
- const { chats: s, activeId: i } = U(a.state), l = s.find((f) => f.id === i), n = J(
4568
- () => s.map((f) => /* @__PURE__ */ $.createElement(Or, { key: f.id, widgetCtx: f.ctx, config: t }, /* @__PURE__ */ $.createElement(Rn, { chat: f, workspace: a }))),
4508
+ Z(() => a.mount(), [a]);
4509
+ const { chats: s, activeId: i } = $(a.state), l = s.find((f) => f.id === i), n = B(
4510
+ () => s.map((f) => /* @__PURE__ */ F.createElement(Mr, { key: f.id, widgetCtx: f.ctx, config: t }, /* @__PURE__ */ F.createElement(wn, { chat: f, workspace: a }))),
4569
4511
  [s, t, a]
4570
4512
  );
4571
- return /* @__PURE__ */ $.createElement(Nr.Provider, { value: a }, n, /* @__PURE__ */ $.createElement(Xe.Provider, { value: l.ui }, r(l.ctx)));
4513
+ return /* @__PURE__ */ F.createElement(Tr.Provider, { value: a }, n, /* @__PURE__ */ F.createElement(Qe.Provider, { value: l.ui }, r(l.ctx)));
4572
4514
  }
4573
- class On {
4515
+ class xn {
4574
4516
  constructor(t) {
4575
4517
  this.components = [];
4576
4518
  const { components: r } = t;
@@ -4596,8 +4538,8 @@ class On {
4596
4538
  return (r = this.get(t)) == null ? void 0 : r.component;
4597
4539
  }
4598
4540
  }
4599
- const Dr = Fe(null);
4600
- function Jn({
4541
+ const Pr = Fe(null);
4542
+ function qn({
4601
4543
  options: e,
4602
4544
  children: t,
4603
4545
  components: r,
@@ -4605,65 +4547,65 @@ function Jn({
4605
4547
  loadingComponent: s,
4606
4548
  errorComponent: i
4607
4549
  }) {
4608
- const l = j(e);
4550
+ const l = D(e);
4609
4551
  l.current = e;
4610
- const n = j(null), f = j(null), [u, c] = K({ status: "loading" }), p = J(
4611
- () => new On({
4552
+ const n = D(null), f = D(null), [u, c] = V({ status: "loading" }), p = B(
4553
+ () => new xn({
4612
4554
  components: r
4613
4555
  }),
4614
4556
  [r]
4615
4557
  );
4616
- if (q(() => {
4617
- const x = f.current ?? (f.current = ta.initialize({
4558
+ if (Z(() => {
4559
+ const _ = f.current ?? (f.current = Gr.initialize({
4618
4560
  config: e,
4619
4561
  storage: a,
4620
4562
  getClientCapabilities: () => l.current.capabilities,
4621
4563
  getRequestConfig: () => l.current
4622
4564
  }));
4623
4565
  let M = !0;
4624
- return x.then(
4566
+ return _.then(
4625
4567
  (E) => {
4626
4568
  M && c({ status: "ready", widgetCtx: E });
4627
4569
  },
4628
4570
  (E) => {
4629
4571
  const C = E instanceof Error ? E : new Error("Widget initialization failed", { cause: E });
4630
- B.error("widget initialization failed", C), M && c({ status: "error", error: C });
4572
+ ne.error("widget initialization failed", C), M && c({ status: "error", error: C });
4631
4573
  }
4632
4574
  ), () => {
4633
4575
  M = !1;
4634
4576
  };
4635
4577
  }, []), u.status === "loading")
4636
- return s ? /* @__PURE__ */ $.createElement($.Fragment, null, s) : null;
4578
+ return s ? /* @__PURE__ */ F.createElement(F.Fragment, null, s) : null;
4637
4579
  if (u.status === "error")
4638
- return i ? /* @__PURE__ */ $.createElement($.Fragment, null, i(u.error)) : null;
4639
- const { widgetCtx: v } = u, h = (x, M) => /* @__PURE__ */ $.createElement(
4640
- Dr.Provider,
4580
+ return i ? /* @__PURE__ */ F.createElement(F.Fragment, null, i(u.error)) : null;
4581
+ const { widgetCtx: v } = u, h = (_, M) => /* @__PURE__ */ F.createElement(
4582
+ Pr.Provider,
4641
4583
  {
4642
4584
  value: {
4643
- widgetCtx: x,
4585
+ widgetCtx: _,
4644
4586
  config: e,
4645
4587
  components: r,
4646
4588
  componentStore: p,
4647
- version: ia,
4589
+ version: ra,
4648
4590
  contentIframeRef: n
4649
4591
  }
4650
4592
  },
4651
4593
  M
4652
4594
  );
4653
- return e.displayMode === "companion" && !e.inline ? /* @__PURE__ */ $.createElement(Pn, { widgetCtx: v, config: e }, (x) => h(x, t)) : h(
4595
+ return e.displayMode === "companion" && !e.inline ? /* @__PURE__ */ F.createElement(_n, { widgetCtx: v, config: e }, (_) => h(_, t)) : h(
4654
4596
  v,
4655
- /* @__PURE__ */ $.createElement(Or, { widgetCtx: v, config: e }, t)
4597
+ /* @__PURE__ */ F.createElement(Mr, { widgetCtx: v, config: e }, t)
4656
4598
  );
4657
4599
  }
4658
- function H() {
4659
- const e = $e(Dr);
4600
+ function K() {
4601
+ const e = $e(Pr);
4660
4602
  if (!e)
4661
4603
  throw new Error("useWidget must be used within a WidgetProvider");
4662
4604
  return e;
4663
4605
  }
4664
- function Kn() {
4665
- const { config: e, widgetCtx: t } = H(), { name: r, avatarUrl: a } = t.agent, s = e.bot;
4666
- return J(
4606
+ function Zn() {
4607
+ const { config: e, widgetCtx: t } = K(), { name: r, avatarUrl: a } = t.agent, s = e.bot;
4608
+ return B(
4667
4609
  () => ({
4668
4610
  isAi: !0,
4669
4611
  id: null,
@@ -4674,24 +4616,24 @@ function Kn() {
4674
4616
  [s == null ? void 0 : s.name, s == null ? void 0 : s.avatarUrl, s == null ? void 0 : s.avatar, r, a]
4675
4617
  );
4676
4618
  }
4677
- function et() {
4678
- const { config: e } = H();
4619
+ function Xe() {
4620
+ const { config: e } = K();
4679
4621
  return e;
4680
4622
  }
4681
- function Yn() {
4682
- const { config: e } = H();
4623
+ function zn() {
4624
+ const { config: e } = K();
4683
4625
  return e.displayMode ?? "popover";
4684
4626
  }
4685
- function Hn() {
4686
- const { widgetCtx: e } = H();
4627
+ function Wn() {
4628
+ const { widgetCtx: e } = K();
4687
4629
  return {
4688
- contactState: U(e.contactCtx.state),
4630
+ contactState: $(e.contactCtx.state),
4689
4631
  createUnverifiedContact: e.contactCtx.createUnverifiedContact
4690
4632
  };
4691
4633
  }
4692
- function Nn() {
4693
- const [e, t] = K("ltr");
4694
- return q(() => {
4634
+ function An() {
4635
+ const [e, t] = V("ltr");
4636
+ return Z(() => {
4695
4637
  const r = () => {
4696
4638
  typeof document > "u" || t(
4697
4639
  window.getComputedStyle((window.top || window).document.body).direction
@@ -4710,8 +4652,8 @@ function Nn() {
4710
4652
  };
4711
4653
  }, []), { dir: e };
4712
4654
  }
4713
- const jn = 500, ut = "opencx:context-changed";
4714
- function kr() {
4655
+ const Mn = 500, ot = "opencx:context-changed";
4656
+ function Or() {
4715
4657
  if (typeof window > "u") return null;
4716
4658
  try {
4717
4659
  const e = window.top ?? window;
@@ -4720,29 +4662,29 @@ function kr() {
4720
4662
  return null;
4721
4663
  }
4722
4664
  }
4723
- function Dn(e) {
4724
- const t = kr();
4665
+ function Tn(e) {
4666
+ const t = Or();
4725
4667
  if (!t) return () => {
4726
4668
  };
4727
4669
  const r = (s) => {
4728
- (s == null ? void 0 : s.type) === ut && (Lr += 1), e();
4670
+ (s == null ? void 0 : s.type) === ot && (Nr += 1), e();
4729
4671
  };
4730
- t.addEventListener("popstate", r), t.addEventListener("hashchange", r), t.addEventListener(ut, r);
4731
- const a = t.setInterval(r, jn);
4672
+ t.addEventListener("popstate", r), t.addEventListener("hashchange", r), t.addEventListener(ot, r);
4673
+ const a = t.setInterval(r, Mn);
4732
4674
  return () => {
4733
- t.removeEventListener("popstate", r), t.removeEventListener("hashchange", r), t.removeEventListener(ut, r), t.clearInterval(a);
4675
+ t.removeEventListener("popstate", r), t.removeEventListener("hashchange", r), t.removeEventListener(ot, r), t.clearInterval(a);
4734
4676
  };
4735
4677
  }
4736
- let Lr = 0;
4737
- function kn() {
4678
+ let Nr = 0;
4679
+ function Rn() {
4738
4680
  var e;
4739
- return `${Lr}|${((e = kr()) == null ? void 0 : e.location.href) ?? ""}`;
4681
+ return `${Nr}|${((e = Or()) == null ? void 0 : e.location.href) ?? ""}`;
4740
4682
  }
4741
- function Gn() {
4742
- return De(Dn, kn, () => "");
4683
+ function Bn() {
4684
+ return De(Tn, Rn, () => "");
4743
4685
  }
4744
- function Fr() {
4745
- const { widgetCtx: e } = H(), t = U(e.messageCtx.state), { isStreaming: r } = Pr();
4686
+ function jr() {
4687
+ const { widgetCtx: e } = K(), t = $(e.messageCtx.state), { isStreaming: r } = Ar();
4746
4688
  return {
4747
4689
  messagesState: r ? { ...t, isSendingMessage: !0, isSendingMessageToAI: !0 } : t,
4748
4690
  sendMessage: e.messageCtx.sendMessage,
@@ -4752,12 +4694,12 @@ function Fr() {
4752
4694
  getSentTextHistory: e.messageCtx.getSentTextHistory
4753
4695
  };
4754
4696
  }
4755
- function $r() {
4697
+ function Dr() {
4756
4698
  var f;
4757
- const { widgetCtx: e } = H(), { oneOpenSessionAllowed: t } = et(), r = U(e.sessionCtx.sessionState), a = U(e.sessionCtx.sessionsState), { openSessions: s, closedSessions: i } = J(() => ({
4699
+ const { widgetCtx: e } = K(), { oneOpenSessionAllowed: t } = Xe(), r = $(e.sessionCtx.sessionState), a = $(e.sessionCtx.sessionsState), { openSessions: s, closedSessions: i } = B(() => ({
4758
4700
  openSessions: a.data.filter((u) => u.isOpened === !0),
4759
4701
  closedSessions: a.data.filter((u) => u.isOpened === !1)
4760
- }), [a.data]), { workspace: l } = jr(), n = l ? l.canCreateChat() : !t || s.length === 0 && !r.isCreatingSession && !((f = r.session) != null && f.isOpened);
4702
+ }), [a.data]), { workspace: l } = Rr(), n = l ? l.canCreateChat() : !t || s.length === 0 && !r.isCreatingSession && !((f = r.session) != null && f.isOpened);
4761
4703
  return {
4762
4704
  sessionState: r,
4763
4705
  sessionsState: a,
@@ -4769,23 +4711,23 @@ function $r() {
4769
4711
  canCreateNewSession: n
4770
4712
  };
4771
4713
  }
4772
- function Qn() {
4714
+ function Vn() {
4773
4715
  var l, n;
4774
- const { sessionState: e } = $r(), { messagesState: t } = Fr(), r = ((l = e.session) == null ? void 0 : l.assignee.kind) === "ai", a = (n = t.messages) == null ? void 0 : n.at(-1), s = (a == null ? void 0 : a.type) === "USER" && a.id !== t.settledAgentUserMessageId;
4716
+ const { sessionState: e } = Dr(), { messagesState: t } = jr(), r = ((l = e.session) == null ? void 0 : l.assignee.kind) === "ai", a = (n = t.messages) == null ? void 0 : n.at(-1), s = (a == null ? void 0 : a.type) === "USER" && a.id !== t.settledAgentUserMessageId;
4775
4717
  return { isAwaitingBotReply: !!(t.isSendingMessageToAI || (r || e.isCreatingSession) && (t.isSendingMessage || s)) };
4776
4718
  }
4777
- function Xn() {
4778
- const { widgetCtx: e } = H();
4719
+ function Jn() {
4720
+ const { widgetCtx: e } = K();
4779
4721
  return {
4780
- routerState: U(e.routerCtx.state),
4722
+ routerState: $(e.routerCtx.state),
4781
4723
  toSessionsScreen: e.routerCtx.toSessionsScreen,
4782
4724
  toChatScreen: e.routerCtx.toChatScreen
4783
4725
  };
4784
4726
  }
4785
- function ei() {
4727
+ function Kn() {
4786
4728
  const {
4787
4729
  widgetCtx: { uploadCtx: e }
4788
- } = H(), t = U(e.state), r = J(
4730
+ } = K(), t = $(e.state), r = B(
4789
4731
  () => t.filter((a) => a.status === "success" && a.fileUrl),
4790
4732
  [t]
4791
4733
  );
@@ -4808,47 +4750,47 @@ function ei() {
4808
4750
  isUploading: t.some((a) => a.status === "uploading")
4809
4751
  };
4810
4752
  }
4811
- const Ur = Fe(null);
4812
- function ti({ children: e }) {
4813
- const t = et(), [r, a] = K(() => t.inline ? !0 : t.isOpen ?? !1);
4814
- return q(() => {
4753
+ const kr = Fe(null);
4754
+ function Yn({ children: e }) {
4755
+ const t = Xe(), [r, a] = V(() => t.inline ? !0 : t.isOpen ?? !1);
4756
+ return Z(() => {
4815
4757
  a((s) => t.isOpen ?? s);
4816
- }, [t.isOpen]), q(() => {
4758
+ }, [t.isOpen]), Z(() => {
4817
4759
  const s = t.openAfterNSeconds;
4818
4760
  if (typeof s != "number" || isNaN(s))
4819
4761
  return;
4820
4762
  const i = setTimeout(() => a(!0), s * 1e3);
4821
4763
  return () => clearTimeout(i);
4822
- }, [t.openAfterNSeconds]), /* @__PURE__ */ $.createElement(Ur.Provider, { value: { isOpen: r, setIsOpen: a } }, e);
4764
+ }, [t.openAfterNSeconds]), /* @__PURE__ */ F.createElement(kr.Provider, { value: { isOpen: r, setIsOpen: a } }, e);
4823
4765
  }
4824
- function ri() {
4825
- const e = $e(Ur);
4766
+ function Hn() {
4767
+ const e = $e(kr);
4826
4768
  if (!e)
4827
4769
  throw new Error(
4828
4770
  "useWidgetTrigger must be used within a WidgetTriggerProvider"
4829
4771
  );
4830
4772
  return e;
4831
4773
  }
4832
- function Ln(e) {
4774
+ function Pn(e) {
4833
4775
  return e !== "fullscreen";
4834
4776
  }
4835
- const qr = Fe(null);
4836
- function ai({ children: e }) {
4777
+ const Lr = Fe(null);
4778
+ function Gn({ children: e }) {
4837
4779
  var s, i;
4838
- const { companion: t } = et(), { dir: r } = Nn(), { widgetCtx: a } = H();
4839
- return /* @__PURE__ */ $.createElement(
4840
- Fn,
4780
+ const { companion: t } = Xe(), { dir: r } = An(), { widgetCtx: a } = K();
4781
+ return /* @__PURE__ */ F.createElement(
4782
+ On,
4841
4783
  {
4842
4784
  configuredDefaultLayout: t == null ? void 0 : t.defaultLayout,
4843
4785
  configuredLayouts: t == null ? void 0 : t.layouts,
4844
- configuredSidebarSide: aa((s = t == null ? void 0 : t.sidebar) == null ? void 0 : s.side, r),
4845
- configuredSidebarMode: ra((i = t == null ? void 0 : t.sidebar) == null ? void 0 : i.mode),
4786
+ configuredSidebarSide: Xr((s = t == null ? void 0 : t.sidebar) == null ? void 0 : s.side, r),
4787
+ configuredSidebarMode: Qr((i = t == null ? void 0 : t.sidebar) == null ? void 0 : i.mode),
4846
4788
  storage: a.storageCtx
4847
4789
  },
4848
4790
  e
4849
4791
  );
4850
4792
  }
4851
- function Fn({
4793
+ function On({
4852
4794
  configuredDefaultLayout: e,
4853
4795
  configuredLayouts: t,
4854
4796
  configuredSidebarSide: r,
@@ -4856,62 +4798,62 @@ function Fn({
4856
4798
  storage: s,
4857
4799
  children: i
4858
4800
  }) {
4859
- const l = sa(t), n = na(
4801
+ const l = ea(t), n = ta(
4860
4802
  e,
4861
4803
  l
4862
- ), f = l.join("|"), [u, c] = K(n), [p, v] = K({
4804
+ ), f = l.join("|"), [u, c] = V(n), [p, v] = V({
4863
4805
  defaultLayout: n,
4864
4806
  allowedLayoutsKey: f
4865
4807
  });
4866
4808
  (p.defaultLayout !== n || p.allowedLayoutsKey !== f) && (v({ defaultLayout: n, allowedLayoutsKey: f }), (p.defaultLayout !== n || !l.includes(u)) && c(n));
4867
4809
  const h = (y) => {
4868
- c((_) => {
4869
- const P = typeof y == "function" ? y(_) : y;
4870
- return l.includes(P) ? P : _;
4810
+ c((I) => {
4811
+ const k = typeof y == "function" ? y(I) : y;
4812
+ return l.includes(k) ? k : I;
4871
4813
  });
4872
- }, x = j(l);
4873
- x.current = l;
4814
+ }, _ = D(l);
4815
+ _.current = l;
4874
4816
  const M = (y) => {
4875
- h(y), x.current.includes(y) && Ln(y) && (s == null || s.setCompanionLayout(y).catch(() => {
4817
+ h(y), _.current.includes(y) && Pn(y) && (s == null || s.setCompanionLayout(y).catch(() => {
4876
4818
  }));
4877
- }, [E, C] = K(r), [w, O] = K(a), [d, g] = K({
4819
+ }, [E, C] = V(r), [w, N] = V(a), [d, g] = V({
4878
4820
  side: r,
4879
4821
  mode: a
4880
4822
  });
4881
4823
  (d.side !== r || d.mode !== a) && (g({
4882
4824
  side: r,
4883
4825
  mode: a
4884
- }), d.side !== r && C(r), d.mode !== a && O(a)), q(() => {
4826
+ }), d.side !== r && C(r), d.mode !== a && N(a)), Z(() => {
4885
4827
  if (!s) return;
4886
4828
  let y = !1;
4887
- return s.getCompanionLayout().then((_) => {
4888
- y || !_ || x.current.includes(_) && c(_);
4829
+ return s.getCompanionLayout().then((I) => {
4830
+ y || !I || _.current.includes(I) && c(I);
4889
4831
  }).catch(() => {
4890
- }), s.getCompanionSidebarSide().then((_) => {
4891
- !y && _ && C(_);
4832
+ }), s.getCompanionSidebarSide().then((I) => {
4833
+ !y && I && C(I);
4892
4834
  }).catch(() => {
4893
- }), s.getCompanionSidebarMode().then((_) => {
4894
- !y && _ && O(_);
4835
+ }), s.getCompanionSidebarMode().then((I) => {
4836
+ !y && I && N(I);
4895
4837
  }).catch(() => {
4896
4838
  }), () => {
4897
4839
  y = !0;
4898
4840
  };
4899
4841
  }, [s]);
4900
- const m = F(
4842
+ const m = q(
4901
4843
  (y) => {
4902
4844
  C(y), s == null || s.setCompanionSidebarSide(y).catch(() => {
4903
4845
  });
4904
4846
  },
4905
4847
  [s]
4906
- ), S = F(
4848
+ ), b = q(
4907
4849
  (y) => {
4908
- O(y), s == null || s.setCompanionSidebarMode(y).catch(() => {
4850
+ N(y), s == null || s.setCompanionSidebarMode(y).catch(() => {
4909
4851
  });
4910
4852
  },
4911
4853
  [s]
4912
4854
  );
4913
- return /* @__PURE__ */ $.createElement(
4914
- qr.Provider,
4855
+ return /* @__PURE__ */ F.createElement(
4856
+ Lr.Provider,
4915
4857
  {
4916
4858
  value: {
4917
4859
  layout: u,
@@ -4922,23 +4864,23 @@ function Fn({
4922
4864
  sidebarSide: E,
4923
4865
  setSidebarSide: m,
4924
4866
  sidebarMode: w,
4925
- setSidebarMode: S
4867
+ setSidebarMode: b
4926
4868
  }
4927
4869
  },
4928
4870
  i
4929
4871
  );
4930
4872
  }
4931
- function si() {
4932
- const e = $e(qr);
4873
+ function Qn() {
4874
+ const e = $e(Lr);
4933
4875
  if (!e)
4934
4876
  throw new Error(
4935
4877
  "useWidgetLayout must be used within a WidgetLayoutProvider"
4936
4878
  );
4937
4879
  return e;
4938
4880
  }
4939
- function ni() {
4881
+ function Xn() {
4940
4882
  var n, f;
4941
- const { widgetCtx: e } = H(), { modesComponents: t } = et(), { sessionState: r } = $r(), a = e.modes, s = (n = r.session) == null ? void 0 : n.modeId, i = a.find((u) => u.id === s), l = (f = t == null ? void 0 : t.find(
4883
+ const { widgetCtx: e } = K(), { modesComponents: t } = Xe(), { sessionState: r } = Dr(), a = e.modes, s = (n = r.session) == null ? void 0 : n.modeId, i = a.find((u) => u.id === s), l = (f = t == null ? void 0 : t.find(
4942
4884
  (u) => {
4943
4885
  var c, p;
4944
4886
  return [
@@ -4956,17 +4898,17 @@ function ni() {
4956
4898
  Component: l
4957
4899
  };
4958
4900
  }
4959
- function ii() {
4960
- const { widgetCtx: e } = H(), {
4901
+ function ei() {
4902
+ const { widgetCtx: e } = K(), {
4961
4903
  messagesState: { messages: t }
4962
- } = Fr(), {
4904
+ } = jr(), {
4963
4905
  csatRequestedMessage: r,
4964
4906
  isCsatRequested: a,
4965
4907
  csatSubmittedMessage: s,
4966
4908
  isCsatSubmitted: i,
4967
4909
  submittedScore: l,
4968
4910
  submittedFeedback: n
4969
- } = J(() => {
4911
+ } = B(() => {
4970
4912
  const f = t.find(
4971
4913
  (c) => c.type === "SYSTEM" && c.subtype === "csat_requested"
4972
4914
  ), u = t.findLast(
@@ -4991,10 +4933,10 @@ function ii() {
4991
4933
  submittedFeedback: n
4992
4934
  };
4993
4935
  }
4994
- function oi(e) {
4995
- const { widgetCtx: t } = H(), r = t.dictationCtx, a = U(r.state), s = j(e);
4936
+ function ti(e) {
4937
+ const { widgetCtx: t } = K(), r = t.dictationCtx, a = $(r.state), s = D(e);
4996
4938
  s.current = e;
4997
- const i = F(() => {
4939
+ const i = q(() => {
4998
4940
  r.start({
4999
4941
  getValue: () => s.current.getValue(),
5000
4942
  setValue: (n) => s.current.setValue(n),
@@ -5003,10 +4945,10 @@ function oi(e) {
5003
4945
  return (f = (n = s.current).onSend) == null ? void 0 : f.call(n);
5004
4946
  }
5005
4947
  });
5006
- }, [r]), l = F(() => {
4948
+ }, [r]), l = q(() => {
5007
4949
  r.isActive() ? r.stop() : i();
5008
4950
  }, [r, i]);
5009
- return q(() => () => r.stop(), [r]), {
4951
+ return Z(() => () => r.stop(), [r]), {
5010
4952
  enabled: t.features.dictation,
5011
4953
  status: a.status,
5012
4954
  error: a.error,
@@ -5019,51 +4961,51 @@ function oi(e) {
5019
4961
  prewarm: r.prewarm
5020
4962
  };
5021
4963
  }
5022
- function li() {
5023
- const { widgetCtx: e } = H(), t = e.messageCtx.draftState, r = U(t), a = F(
4964
+ function ri() {
4965
+ const { widgetCtx: e } = K(), t = e.messageCtx.draftState, r = $(t), a = q(
5024
4966
  (l) => {
5025
4967
  t.setPartial({
5026
4968
  text: typeof l == "function" ? l(t.get().text) : l
5027
4969
  });
5028
4970
  },
5029
4971
  [t]
5030
- ), s = F(
4972
+ ), s = q(
5031
4973
  (l) => {
5032
4974
  t.setPartial({
5033
4975
  mentions: typeof l == "function" ? l(t.get().mentions) : l
5034
4976
  });
5035
4977
  },
5036
4978
  [t]
5037
- ), i = F(() => t.get() !== r ? !1 : (t.reset(), !0), [t, r]);
4979
+ ), i = q(() => t.get() !== r ? !1 : (t.reset(), !0), [t, r]);
5038
4980
  return { ...r, setText: a, setMentions: s, clearSubmitted: i };
5039
4981
  }
5040
4982
  export {
5041
- ut as HOST_CONTEXT_CHANGED_EVENT,
5042
- ai as WidgetLayoutProvider,
5043
- Jn as WidgetProvider,
5044
- ti as WidgetTriggerProvider,
5045
- Ht as applyPresentation,
5046
- Bn as formatAskQuestionsAnswers,
5047
- Pr as useAgentChatUi,
5048
- Kn as useBot,
5049
- Vn as useCompanionChats,
5050
- li as useComposerDraft,
5051
- et as useConfig,
5052
- Hn as useContact,
5053
- ii as useCsat,
5054
- oi as useDictation,
5055
- Yn as useDisplayMode,
5056
- Nn as useDocumentDir,
5057
- Gn as useHostLocation,
5058
- Qn as useIsAwaitingBotReply,
5059
- Fr as useMessages,
5060
- ni as useModes,
5061
- U as usePrimitiveState,
5062
- $r as useSessions,
5063
- ei as useUploadFiles,
5064
- H as useWidget,
5065
- si as useWidgetLayout,
5066
- Xn as useWidgetRouter,
5067
- ri as useWidgetTrigger
4983
+ ot as HOST_CONTEXT_CHANGED_EVENT,
4984
+ Gn as WidgetLayoutProvider,
4985
+ qn as WidgetProvider,
4986
+ Yn as WidgetTriggerProvider,
4987
+ Vt as applyPresentation,
4988
+ $n as formatAskQuestionsAnswers,
4989
+ Ar as useAgentChatUi,
4990
+ Zn as useBot,
4991
+ Un as useCompanionChats,
4992
+ ri as useComposerDraft,
4993
+ Xe as useConfig,
4994
+ Wn as useContact,
4995
+ ei as useCsat,
4996
+ ti as useDictation,
4997
+ zn as useDisplayMode,
4998
+ An as useDocumentDir,
4999
+ Bn as useHostLocation,
5000
+ Vn as useIsAwaitingBotReply,
5001
+ jr as useMessages,
5002
+ Xn as useModes,
5003
+ $ as usePrimitiveState,
5004
+ Dr as useSessions,
5005
+ Kn as useUploadFiles,
5006
+ K as useWidget,
5007
+ Qn as useWidgetLayout,
5008
+ Jn as useWidgetRouter,
5009
+ Hn as useWidgetTrigger
5068
5010
  };
5069
5011
  //# sourceMappingURL=index.js.map