@opencx/widget 3.0.14 → 3.0.16

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.
@@ -1,7 +1,7 @@
1
1
  var Kt = Object.defineProperty;
2
2
  var kt = (e, t, n) => t in e ? Kt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var Ye = (e, t, n) => kt(e, typeof t != "symbol" ? t + "" : t, n);
4
- import k, { createContext as rt, useContext as ot, useMemo as le, useSyncExternalStore as zt, useEffect as st, useLayoutEffect as Yt, useRef as K, useCallback as ve, useDebugValue as Jt, useState as Xt } from "react";
4
+ import k, { createContext as rt, useContext as ot, useRef as H, useMemo as Ve, useSyncExternalStore as zt, useEffect as st, useLayoutEffect as Yt, useCallback as Ee, useDebugValue as Jt, useState as Xt } from "react";
5
5
  import { jsx as Qt } from "react/jsx-runtime";
6
6
  import { W as Zt } from "./widget.ctx-BN_4PZd7.js";
7
7
  import { v4 as en } from "uuid";
@@ -50,16 +50,13 @@ function nn(e) {
50
50
  return r;
51
51
  }, t.Provider];
52
52
  }
53
- const rn = "3.0.14", [te, on] = nn();
53
+ const rn = "3.0.16", [z, on] = nn();
54
54
  function tr({
55
55
  options: e,
56
56
  children: t,
57
57
  components: n
58
58
  }) {
59
- const r = le(
60
- () => new Zt({ config: e }),
61
- [e]
62
- ), o = le(
59
+ const r = H(new Zt({ config: e })).current, o = Ve(
63
60
  () => new tn({
64
61
  components: n
65
62
  }),
@@ -79,25 +76,25 @@ function tr({
79
76
  );
80
77
  }
81
78
  function nr() {
82
- const { widgetCtx: e } = te();
79
+ const { widgetCtx: e } = z();
83
80
  return e.config;
84
81
  }
85
- function de(e) {
82
+ function oe(e) {
86
83
  return zt(e.subscribe, e.get, e.get);
87
84
  }
88
85
  function rr() {
89
- const { widgetCtx: e } = te();
86
+ const { widgetCtx: e } = z();
90
87
  return {
91
- contactState: de(e.contactCtx.state),
88
+ contactState: oe(e.contactCtx.state),
92
89
  createUnverifiedContact: e.contactCtx.createUnverifiedContact
93
90
  };
94
91
  }
95
92
  function sn() {
96
- const { widgetCtx: e } = te();
97
- return { messagesState: de(e.messageCtx.state), sendMessage: e.messageCtx.sendMessage };
93
+ const { widgetCtx: e } = z();
94
+ return { messagesState: oe(e.messageCtx.state), sendMessage: e.messageCtx.sendMessage };
98
95
  }
99
96
  function an() {
100
- const { widgetCtx: e } = te(), t = de(e.sessionCtx.sessionState), n = de(e.sessionCtx.sessionsState);
97
+ const { widgetCtx: e } = z(), t = oe(e.sessionCtx.sessionState), n = oe(e.sessionCtx.sessionsState);
101
98
  return {
102
99
  sessionState: t,
103
100
  sessionsState: n,
@@ -113,7 +110,7 @@ var sr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
113
110
  function ir(e) {
114
111
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
115
112
  }
116
- function cn(e) {
113
+ function un(e) {
117
114
  if (e.__esModule) return e;
118
115
  var t = e.default;
119
116
  if (typeof t == "function") {
@@ -132,7 +129,7 @@ function cn(e) {
132
129
  });
133
130
  }), n;
134
131
  }
135
- var De = { exports: {} }, we = {};
132
+ var Te = { exports: {} }, ve = {};
136
133
  /**
137
134
  * @license React
138
135
  * use-sync-external-store-shim.production.min.js
@@ -143,39 +140,39 @@ var De = { exports: {} }, we = {};
143
140
  * LICENSE file in the root directory of this source tree.
144
141
  */
145
142
  var Je;
146
- function un() {
147
- if (Je) return we;
143
+ function cn() {
144
+ if (Je) return ve;
148
145
  Je = 1;
149
146
  var e = k;
150
- function t(c, l) {
151
- return c === l && (c !== 0 || 1 / c === 1 / l) || c !== c && l !== l;
147
+ function t(u, l) {
148
+ return u === l && (u !== 0 || 1 / u === 1 / l) || u !== u && l !== l;
152
149
  }
153
150
  var n = typeof Object.is == "function" ? Object.is : t, r = e.useState, o = e.useEffect, s = e.useLayoutEffect, i = e.useDebugValue;
154
- function d(c, l) {
155
- var u = l(), y = r({ inst: { value: u, getSnapshot: l } }), _ = y[0].inst, T = y[1];
151
+ function d(u, l) {
152
+ var c = l(), y = r({ inst: { value: c, getSnapshot: l } }), _ = y[0].inst, C = y[1];
156
153
  return s(function() {
157
- _.value = u, _.getSnapshot = l, h(_) && T({ inst: _ });
158
- }, [c, u, l]), o(function() {
159
- return h(_) && T({ inst: _ }), c(function() {
160
- h(_) && T({ inst: _ });
154
+ _.value = c, _.getSnapshot = l, h(_) && C({ inst: _ });
155
+ }, [u, c, l]), o(function() {
156
+ return h(_) && C({ inst: _ }), u(function() {
157
+ h(_) && C({ inst: _ });
161
158
  });
162
- }, [c]), i(u), u;
159
+ }, [u]), i(c), c;
163
160
  }
164
- function h(c) {
165
- var l = c.getSnapshot;
166
- c = c.value;
161
+ function h(u) {
162
+ var l = u.getSnapshot;
163
+ u = u.value;
167
164
  try {
168
- var u = l();
169
- return !n(c, u);
165
+ var c = l();
166
+ return !n(u, c);
170
167
  } catch {
171
168
  return !0;
172
169
  }
173
170
  }
174
- function f(c, l) {
171
+ function f(u, l) {
175
172
  return l();
176
173
  }
177
174
  var a = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? f : d;
178
- return we.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : a, we;
175
+ return ve.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : a, ve;
179
176
  }
180
177
  var Se = {};
181
178
  /**
@@ -194,150 +191,150 @@ function fn() {
194
191
  var e = k, t = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
195
192
  function n(O) {
196
193
  {
197
- for (var E = arguments.length, w = new Array(E > 1 ? E - 1 : 0), v = 1; v < E; v++)
198
- w[v - 1] = arguments[v];
199
- r("error", O, w);
194
+ for (var E = arguments.length, S = new Array(E > 1 ? E - 1 : 0), v = 1; v < E; v++)
195
+ S[v - 1] = arguments[v];
196
+ r("error", O, S);
200
197
  }
201
198
  }
202
- function r(O, E, w) {
199
+ function r(O, E, S) {
203
200
  {
204
201
  var v = t.ReactDebugCurrentFrame, L = v.getStackAddendum();
205
- L !== "" && (E += "%s", w = w.concat([L]));
206
- var S = w.map(function(C) {
207
- return String(C);
202
+ L !== "" && (E += "%s", S = S.concat([L]));
203
+ var w = S.map(function(T) {
204
+ return String(T);
208
205
  });
209
- S.unshift("Warning: " + E), Function.prototype.apply.call(console[O], console, S);
206
+ w.unshift("Warning: " + E), Function.prototype.apply.call(console[O], console, w);
210
207
  }
211
208
  }
212
209
  function o(O, E) {
213
210
  return O === E && (O !== 0 || 1 / O === 1 / E) || O !== O && E !== E;
214
211
  }
215
- var s = typeof Object.is == "function" ? Object.is : o, i = e.useState, d = e.useEffect, h = e.useLayoutEffect, f = e.useDebugValue, a = !1, c = !1;
216
- function l(O, E, w) {
212
+ var s = typeof Object.is == "function" ? Object.is : o, i = e.useState, d = e.useEffect, h = e.useLayoutEffect, f = e.useDebugValue, a = !1, u = !1;
213
+ function l(O, E, S) {
217
214
  a || e.startTransition !== void 0 && (a = !0, n("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));
218
215
  var v = E();
219
- if (!c) {
216
+ if (!u) {
220
217
  var L = E();
221
- s(v, L) || (n("The result of getSnapshot should be cached to avoid an infinite loop"), c = !0);
218
+ s(v, L) || (n("The result of getSnapshot should be cached to avoid an infinite loop"), u = !0);
222
219
  }
223
- var S = i({
220
+ var w = i({
224
221
  inst: {
225
222
  value: v,
226
223
  getSnapshot: E
227
224
  }
228
- }), C = S[0].inst, x = S[1];
225
+ }), T = w[0].inst, j = w[1];
229
226
  return h(function() {
230
- C.value = v, C.getSnapshot = E, u(C) && x({
231
- inst: C
227
+ T.value = v, T.getSnapshot = E, c(T) && j({
228
+ inst: T
232
229
  });
233
230
  }, [O, v, E]), d(function() {
234
- u(C) && x({
235
- inst: C
231
+ c(T) && j({
232
+ inst: T
236
233
  });
237
234
  var q = function() {
238
- u(C) && x({
239
- inst: C
235
+ c(T) && j({
236
+ inst: T
240
237
  });
241
238
  };
242
239
  return O(q);
243
240
  }, [O]), f(v), v;
244
241
  }
245
- function u(O) {
246
- var E = O.getSnapshot, w = O.value;
242
+ function c(O) {
243
+ var E = O.getSnapshot, S = O.value;
247
244
  try {
248
245
  var v = E();
249
- return !s(w, v);
246
+ return !s(S, v);
250
247
  } catch {
251
248
  return !0;
252
249
  }
253
250
  }
254
- function y(O, E, w) {
251
+ function y(O, E, S) {
255
252
  return E();
256
253
  }
257
- var _ = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", T = !_, p = T ? y : l, z = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : p;
258
- Se.useSyncExternalStore = z, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
254
+ var _ = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", C = !_, p = C ? y : l, Y = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : p;
255
+ Se.useSyncExternalStore = Y, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
259
256
  }()), Se;
260
257
  }
261
- process.env.NODE_ENV === "production" ? De.exports = un() : De.exports = fn();
262
- var ln = De.exports;
263
- const H = () => {
258
+ process.env.NODE_ENV === "production" ? Te.exports = cn() : Te.exports = fn();
259
+ var ln = Te.exports;
260
+ const G = () => {
264
261
  }, P = (
265
262
  /*#__NOINLINE__*/
266
- H()
267
- ), me = Object, g = (e) => e === P, M = (e) => typeof e == "function", G = (e, t) => ({
263
+ G()
264
+ ), we = Object, g = (e) => e === P, M = (e) => typeof e == "function", $ = (e, t) => ({
268
265
  ...e,
269
266
  ...t
270
267
  }), dn = (e) => M(e.then), ce = /* @__PURE__ */ new WeakMap();
271
268
  let pn = 0;
272
- const oe = (e) => {
269
+ const se = (e) => {
273
270
  const t = typeof e, n = e && e.constructor, r = n == Date;
274
271
  let o, s;
275
- if (me(e) === e && !r && n != RegExp) {
272
+ if (we(e) === e && !r && n != RegExp) {
276
273
  if (o = ce.get(e), o) return o;
277
274
  if (o = ++pn + "~", ce.set(e, o), n == Array) {
278
275
  for (o = "@", s = 0; s < e.length; s++)
279
- o += oe(e[s]) + ",";
276
+ o += se(e[s]) + ",";
280
277
  ce.set(e, o);
281
278
  }
282
- if (n == me) {
279
+ if (n == we) {
283
280
  o = "#";
284
- const i = me.keys(e).sort();
281
+ const i = we.keys(e).sort();
285
282
  for (; !g(s = i.pop()); )
286
- g(e[s]) || (o += s + ":" + oe(e[s]) + ",");
283
+ g(e[s]) || (o += s + ":" + se(e[s]) + ",");
287
284
  ce.set(e, o);
288
285
  }
289
286
  } else
290
287
  o = r ? e.toJSON() : t == "symbol" ? e.toString() : t == "string" ? JSON.stringify(e) : "" + e;
291
288
  return o;
292
- }, W = /* @__PURE__ */ new WeakMap(), be = {}, ue = {}, Fe = "undefined", _e = typeof window != Fe, Ae = typeof document != Fe, hn = () => _e && typeof window.requestAnimationFrame != Fe, it = (e, t) => {
289
+ }, W = /* @__PURE__ */ new WeakMap(), me = {}, fe = {}, Fe = "undefined", he = typeof window != Fe, De = typeof document != Fe, hn = () => he && typeof window.requestAnimationFrame != Fe, it = (e, t) => {
293
290
  const n = W.get(e);
294
291
  return [
295
292
  // Getter
296
- () => !g(t) && e.get(t) || be,
293
+ () => !g(t) && e.get(t) || me,
297
294
  // Setter
298
295
  (r) => {
299
296
  if (!g(t)) {
300
297
  const o = e.get(t);
301
- t in ue || (ue[t] = o), n[5](t, G(o, r), o || be);
298
+ t in fe || (fe[t] = o), n[5](t, $(o, r), o || me);
302
299
  }
303
300
  },
304
301
  // Subscriber
305
302
  n[6],
306
303
  // Get server cache snapshot
307
- () => !g(t) && t in ue ? ue[t] : !g(t) && e.get(t) || be
304
+ () => !g(t) && t in fe ? fe[t] : !g(t) && e.get(t) || me
308
305
  ];
309
306
  };
310
- let je = !0;
311
- const _n = () => je, [xe, Pe] = _e && window.addEventListener ? [
307
+ let Ae = !0;
308
+ const _n = () => Ae, [xe, je] = he && window.addEventListener ? [
312
309
  window.addEventListener.bind(window),
313
310
  window.removeEventListener.bind(window)
314
311
  ] : [
315
- H,
316
- H
312
+ G,
313
+ G
317
314
  ], yn = () => {
318
- const e = Ae && document.visibilityState;
315
+ const e = De && document.visibilityState;
319
316
  return g(e) || e !== "hidden";
320
- }, gn = (e) => (Ae && document.addEventListener("visibilitychange", e), xe("focus", e), () => {
321
- Ae && document.removeEventListener("visibilitychange", e), Pe("focus", e);
317
+ }, gn = (e) => (De && document.addEventListener("visibilitychange", e), xe("focus", e), () => {
318
+ De && document.removeEventListener("visibilitychange", e), je("focus", e);
322
319
  }), En = (e) => {
323
320
  const t = () => {
324
- je = !0, e();
321
+ Ae = !0, e();
325
322
  }, n = () => {
326
- je = !1;
323
+ Ae = !1;
327
324
  };
328
325
  return xe("online", t), xe("offline", n), () => {
329
- Pe("online", t), Pe("offline", n);
326
+ je("online", t), je("offline", n);
330
327
  };
331
328
  }, vn = {
332
329
  isOnline: _n,
333
330
  isVisible: yn
334
- }, wn = {
331
+ }, Sn = {
335
332
  initFocus: gn,
336
333
  initReconnect: En
337
- }, Qe = !k.useId, se = !_e || "Deno" in window, Sn = (e) => hn() ? window.requestAnimationFrame(e) : setTimeout(e, 1), Oe = se ? st : Yt, Re = typeof navigator < "u" && navigator.connection, Ze = !se && Re && ([
334
+ }, Qe = !k.useId, ie = !he || "Deno" in window, wn = (e) => hn() ? window.requestAnimationFrame(e) : setTimeout(e, 1), be = ie ? st : Yt, Oe = typeof navigator < "u" && navigator.connection, Ze = !ie && Oe && ([
338
335
  "slow-2g",
339
336
  "2g"
340
- ].includes(Re.effectiveType) || Re.saveData), Me = (e) => {
337
+ ].includes(Oe.effectiveType) || Oe.saveData), Me = (e) => {
341
338
  if (M(e))
342
339
  try {
343
340
  e = e();
@@ -345,22 +342,22 @@ const _n = () => je, [xe, Pe] = _e && window.addEventListener ? [
345
342
  e = "";
346
343
  }
347
344
  const t = e;
348
- return e = typeof e == "string" ? e : (Array.isArray(e) ? e.length : e) ? oe(e) : "", [
345
+ return e = typeof e == "string" ? e : (Array.isArray(e) ? e.length : e) ? se(e) : "", [
349
346
  e,
350
347
  t
351
348
  ];
352
349
  };
353
350
  let mn = 0;
354
- const Le = () => ++mn, at = 0, ct = 1, ut = 2, bn = 3;
351
+ const Pe = () => ++mn, at = 0, ut = 1, ct = 2, bn = 3;
355
352
  var re = {
356
353
  __proto__: null,
357
354
  ERROR_REVALIDATE_EVENT: bn,
358
355
  FOCUS_EVENT: at,
359
- MUTATE_EVENT: ut,
360
- RECONNECT_EVENT: ct
356
+ MUTATE_EVENT: ct,
357
+ RECONNECT_EVENT: ut
361
358
  };
362
359
  async function ft(...e) {
363
- const [t, n, r, o] = e, s = G({
360
+ const [t, n, r, o] = e, s = $({
364
361
  populateCache: !0,
365
362
  throwOnError: !0
366
363
  }, typeof o == "boolean" ? {
@@ -371,51 +368,51 @@ async function ft(...e) {
371
368
  let h = s.optimisticData;
372
369
  const f = (l) => typeof d == "function" ? d(l) : d !== !1, a = s.throwOnError;
373
370
  if (M(n)) {
374
- const l = n, u = [], y = t.keys();
371
+ const l = n, c = [], y = t.keys();
375
372
  for (const _ of y)
376
373
  // Skip the special useSWRInfinite and useSWRSubscription keys.
377
- !/^\$(inf|sub)\$/.test(_) && l(t.get(_)._k) && u.push(_);
378
- return Promise.all(u.map(c));
374
+ !/^\$(inf|sub)\$/.test(_) && l(t.get(_)._k) && c.push(_);
375
+ return Promise.all(c.map(u));
379
376
  }
380
- return c(n);
381
- async function c(l) {
382
- const [u] = Me(l);
383
- if (!u) return;
384
- const [y, _] = it(t, u), [T, p, z, O] = W.get(t), E = () => {
385
- const V = T[u];
386
- return (M(s.revalidate) ? s.revalidate(y().data, l) : s.revalidate !== !1) && (delete z[u], delete O[u], V && V[0]) ? V[0](ut).then(() => y().data) : y().data;
377
+ return u(n);
378
+ async function u(l) {
379
+ const [c] = Me(l);
380
+ if (!c) return;
381
+ const [y, _] = it(t, c), [C, p, Y, O] = W.get(t), E = () => {
382
+ const V = C[c];
383
+ return (M(s.revalidate) ? s.revalidate(y().data, l) : s.revalidate !== !1) && (delete Y[c], delete O[c], V && V[0]) ? V[0](ct).then(() => y().data) : y().data;
387
384
  };
388
385
  if (e.length < 3)
389
386
  return E();
390
- let w = r, v;
391
- const L = Le();
392
- p[u] = [
387
+ let S = r, v;
388
+ const L = Pe();
389
+ p[c] = [
393
390
  L,
394
391
  0
395
392
  ];
396
- const S = !g(h), C = y(), x = C.data, q = C._c, $ = g(q) ? x : q;
397
- if (S && (h = M(h) ? h($, x) : h, _({
393
+ const w = !g(h), T = y(), j = T.data, q = T._c, K = g(q) ? j : q;
394
+ if (w && (h = M(h) ? h(K, j) : h, _({
398
395
  data: h,
399
- _c: $
400
- })), M(w))
396
+ _c: K
397
+ })), M(S))
401
398
  try {
402
- w = w($);
399
+ S = S(K);
403
400
  } catch (V) {
404
401
  v = V;
405
402
  }
406
- if (w && dn(w))
407
- if (w = await w.catch((V) => {
403
+ if (S && dn(S))
404
+ if (S = await S.catch((V) => {
408
405
  v = V;
409
- }), L !== p[u][0]) {
406
+ }), L !== p[c][0]) {
410
407
  if (v) throw v;
411
- return w;
412
- } else v && S && f(v) && (i = !0, _({
413
- data: $,
408
+ return S;
409
+ } else v && w && f(v) && (i = !0, _({
410
+ data: K,
414
411
  _c: P
415
412
  }));
416
413
  if (i && !v)
417
414
  if (M(i)) {
418
- const V = i(w, $);
415
+ const V = i(S, K);
419
416
  _({
420
417
  data: V,
421
418
  error: P,
@@ -423,11 +420,11 @@ async function ft(...e) {
423
420
  });
424
421
  } else
425
422
  _({
426
- data: w,
423
+ data: S,
427
424
  error: P,
428
425
  _c: P
429
426
  });
430
- if (p[u][1] = Le(), Promise.resolve(E()).then(() => {
427
+ if (p[c][1] = Pe(), Promise.resolve(E()).then(() => {
431
428
  _({
432
429
  _c: P
433
430
  });
@@ -435,7 +432,7 @@ async function ft(...e) {
435
432
  if (a) throw v;
436
433
  return;
437
434
  }
438
- return w;
435
+ return S;
439
436
  }
440
437
  }
441
438
  const et = (e, t) => {
@@ -443,17 +440,17 @@ const et = (e, t) => {
443
440
  e[n][0] && e[n][0](t);
444
441
  }, On = (e, t) => {
445
442
  if (!W.has(e)) {
446
- const n = G(wn, t), r = {}, o = ft.bind(P, e);
447
- let s = H;
448
- const i = {}, d = (a, c) => {
443
+ const n = $(Sn, t), r = {}, o = ft.bind(P, e);
444
+ let s = G;
445
+ const i = {}, d = (a, u) => {
449
446
  const l = i[a] || [];
450
- return i[a] = l, l.push(c), () => l.splice(l.indexOf(c), 1);
451
- }, h = (a, c, l) => {
452
- e.set(a, c);
453
- const u = i[a];
454
- if (u)
455
- for (const y of u)
456
- y(c, l);
447
+ return i[a] = l, l.push(u), () => l.splice(l.indexOf(u), 1);
448
+ }, h = (a, u, l) => {
449
+ e.set(a, u);
450
+ const c = i[a];
451
+ if (c)
452
+ for (const y of c)
453
+ y(u, l);
457
454
  }, f = () => {
458
455
  if (!W.has(e) && (W.set(e, [
459
456
  r,
@@ -463,10 +460,10 @@ const et = (e, t) => {
463
460
  o,
464
461
  h,
465
462
  d
466
- ]), !se)) {
467
- const a = n.initFocus(setTimeout.bind(P, et.bind(P, r, at))), c = n.initReconnect(setTimeout.bind(P, et.bind(P, r, ct)));
463
+ ]), !ie)) {
464
+ const a = n.initFocus(setTimeout.bind(P, et.bind(P, r, at))), u = n.initReconnect(setTimeout.bind(P, et.bind(P, r, ut)));
468
465
  s = () => {
469
- a && a(), c && c(), W.delete(e);
466
+ a && a(), u && u(), W.delete(e);
470
467
  };
471
468
  }
472
469
  };
@@ -484,14 +481,14 @@ const et = (e, t) => {
484
481
  }, Rn = (e, t, n, r, o) => {
485
482
  const s = n.errorRetryCount, i = o.retryCount, d = ~~((Math.random() + 0.5) * (1 << (i < 8 ? i : 8))) * n.errorRetryInterval;
486
483
  !g(s) && i > s || setTimeout(r, d, o);
487
- }, Tn = (e, t) => oe(e) == oe(t), [lt, Cn] = On(/* @__PURE__ */ new Map()), Dn = G(
484
+ }, Cn = (e, t) => se(e) == se(t), [lt, Tn] = On(/* @__PURE__ */ new Map()), Dn = $(
488
485
  {
489
486
  // events
490
- onLoadingSlow: H,
491
- onSuccess: H,
492
- onError: H,
487
+ onLoadingSlow: G,
488
+ onSuccess: G,
489
+ onError: G,
493
490
  onErrorRetry: Rn,
494
- onDiscarded: H,
491
+ onDiscarded: G,
495
492
  // switches
496
493
  revalidateOnFocus: !0,
497
494
  revalidateOnReconnect: !0,
@@ -503,22 +500,22 @@ const et = (e, t) => {
503
500
  dedupingInterval: 2 * 1e3,
504
501
  loadingTimeout: Ze ? 5e3 : 3e3,
505
502
  // providers
506
- compare: Tn,
503
+ compare: Cn,
507
504
  isPaused: () => !1,
508
505
  cache: lt,
509
- mutate: Cn,
506
+ mutate: Tn,
510
507
  fallback: {}
511
508
  },
512
509
  // use web preset by default
513
510
  vn
514
511
  ), An = (e, t) => {
515
- const n = G(e, t);
512
+ const n = $(e, t);
516
513
  if (t) {
517
514
  const { use: r, fallback: o } = e, { use: s, fallback: i } = t;
518
- r && s && (n.use = r.concat(s)), o && i && (n.fallback = G(o, i));
515
+ r && s && (n.use = r.concat(s)), o && i && (n.fallback = $(o, i));
519
516
  }
520
517
  return n;
521
- }, jn = rt({}), xn = "$inf$", dt = _e && window.__SWR_DEVTOOLS_USE__, Pn = dt ? window.__SWR_DEVTOOLS_USE__ : [], Ln = () => {
518
+ }, xn = rt({}), jn = "$inf$", dt = he && window.__SWR_DEVTOOLS_USE__, Pn = dt ? window.__SWR_DEVTOOLS_USE__ : [], Ln = () => {
522
519
  dt && (window.__SWR_DEVTOOLS_REACT__ = k);
523
520
  }, In = (e) => M(e[1]) ? [
524
521
  e[0],
@@ -528,9 +525,9 @@ const et = (e, t) => {
528
525
  e[0],
529
526
  null,
530
527
  (e[1] === null ? e[2] : e[1]) || {}
531
- ], Vn = () => G(Dn, ot(jn)), Fn = (e) => (t, n, r) => e(t, n && ((...s) => {
528
+ ], Vn = () => $(Dn, ot(xn)), Fn = (e) => (t, n, r) => e(t, n && ((...s) => {
532
529
  const [i] = Me(t), [, , , d] = W.get(lt);
533
- if (i.startsWith(xn))
530
+ if (i.startsWith(jn))
534
531
  return n(...s);
535
532
  const h = d[i];
536
533
  return g(h) ? n(...s) : (delete d[i], h);
@@ -538,8 +535,8 @@ const et = (e, t) => {
538
535
  const r = Vn(), [o, s, i] = In(n), d = An(r, i);
539
536
  let h = e;
540
537
  const { use: f } = d, a = (f || []).concat(Mn);
541
- for (let c = a.length; c--; )
542
- h = a[c](h);
538
+ for (let u = a.length; u--; )
539
+ h = a[u](h);
543
540
  return h(o, s || d.fetcher || null, d);
544
541
  }, Un = (e, t, n) => {
545
542
  const r = t[e] || (t[e] = []);
@@ -559,41 +556,41 @@ const tt = k.use || ((e) => {
559
556
  }, (t) => {
560
557
  e.status = "rejected", e.reason = t;
561
558
  }), e);
562
- }), Te = {
559
+ }), Re = {
563
560
  dedupe: !0
564
561
  }, Wn = (e, t, n) => {
565
- const { cache: r, compare: o, suspense: s, fallbackData: i, revalidateOnMount: d, revalidateIfStale: h, refreshInterval: f, refreshWhenHidden: a, refreshWhenOffline: c, keepPreviousData: l } = n, [u, y, _, T] = W.get(r), [p, z] = Me(e), O = K(!1), E = K(!1), w = K(p), v = K(t), L = K(n), S = () => L.current, C = () => S().isVisible() && S().isOnline(), [x, q, $, V] = it(r, p), Y = K({}).current, qt = g(i) ? n.fallback[p] : i, Ue = (m, b) => {
566
- for (const A in Y) {
562
+ const { cache: r, compare: o, suspense: s, fallbackData: i, revalidateOnMount: d, revalidateIfStale: h, refreshInterval: f, refreshWhenHidden: a, refreshWhenOffline: u, keepPreviousData: l } = n, [c, y, _, C] = W.get(r), [p, Y] = Me(e), O = H(!1), E = H(!1), S = H(p), v = H(t), L = H(n), w = () => L.current, T = () => w().isVisible() && w().isOnline(), [j, q, K, V] = it(r, p), J = H({}).current, qt = g(i) ? n.fallback[p] : i, Ue = (m, b) => {
563
+ for (const A in J) {
567
564
  const R = A;
568
565
  if (R === "data") {
569
- if (!o(m[R], b[R]) && (!g(m[R]) || !o(ae, b[R])))
566
+ if (!o(m[R], b[R]) && (!g(m[R]) || !o(ue, b[R])))
570
567
  return !1;
571
568
  } else if (b[R] !== m[R])
572
569
  return !1;
573
570
  }
574
571
  return !0;
575
- }, We = le(() => {
576
- const m = !p || !t ? !1 : g(d) ? S().isPaused() || s ? !1 : g(h) ? !0 : h : d, b = (j) => {
577
- const N = G(j);
572
+ }, We = Ve(() => {
573
+ const m = !p || !t ? !1 : g(d) ? w().isPaused() || s ? !1 : g(h) ? !0 : h : d, b = (x) => {
574
+ const N = $(x);
578
575
  return delete N._k, m ? {
579
576
  isValidating: !0,
580
577
  isLoading: !0,
581
578
  ...N
582
579
  } : N;
583
- }, A = x(), R = V(), F = b(A), Z = A === R ? F : b(R);
580
+ }, A = j(), R = V(), F = b(A), ee = A === R ? F : b(R);
584
581
  let D = F;
585
582
  return [
586
583
  () => {
587
- const j = b(x());
588
- return Ue(j, D) ? (D.data = j.data, D.isLoading = j.isLoading, D.isValidating = j.isValidating, D.error = j.error, D) : (D = j, j);
584
+ const x = b(j());
585
+ return Ue(x, D) ? (D.data = x.data, D.isLoading = x.isLoading, D.isValidating = x.isValidating, D.error = x.error, D) : (D = x, x);
589
586
  },
590
- () => Z
587
+ () => ee
591
588
  ];
592
589
  }, [
593
590
  r,
594
591
  p
595
- ]), J = ln.useSyncExternalStore(ve(
596
- (m) => $(p, (b, A) => {
592
+ ]), X = ln.useSyncExternalStore(Ee(
593
+ (m) => K(p, (b, A) => {
597
594
  Ue(A, b) || m();
598
595
  }),
599
596
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -601,13 +598,13 @@ const tt = k.use || ((e) => {
601
598
  r,
602
599
  p
603
600
  ]
604
- ), We[0], We[1]), qe = !O.current, Bt = u[p] && u[p].length > 0, X = J.data, Q = g(X) ? qt : X, ie = J.error, Be = K(Q), ae = l ? g(X) ? Be.current : X : Q, He = Bt && !g(ie) ? !1 : qe && !g(d) ? d : S().isPaused() ? !1 : s ? g(Q) ? !1 : h : g(Q) || h, Ge = !!(p && t && qe && He), Ht = g(J.isValidating) ? Ge : J.isValidating, Gt = g(J.isLoading) ? Ge : J.isLoading, ne = ve(
601
+ ), We[0], We[1]), qe = !O.current, Bt = c[p] && c[p].length > 0, Q = X.data, Z = g(Q) ? qt : Q, ae = X.error, Be = H(Z), ue = l ? g(Q) ? Be.current : Q : Z, He = Bt && !g(ae) ? !1 : qe && !g(d) ? d : w().isPaused() ? !1 : s ? g(Z) ? !1 : h : g(Z) || h, Ge = !!(p && t && qe && He), Ht = g(X.isValidating) ? Ge : X.isValidating, Gt = g(X.isLoading) ? Ge : X.isLoading, ne = Ee(
605
602
  async (m) => {
606
603
  const b = v.current;
607
- if (!p || !b || E.current || S().isPaused())
604
+ if (!p || !b || E.current || w().isPaused())
608
605
  return !1;
609
606
  let A, R, F = !0;
610
- const Z = m || {}, D = !_[p] || !Z.dedupe, j = () => Qe ? !E.current && p === w.current && O.current : p === w.current, N = {
607
+ const ee = m || {}, D = !_[p] || !ee.dedupe, x = () => Qe ? !E.current && p === S.current && O.current : p === S.current, N = {
611
608
  isValidating: !1,
612
609
  isLoading: !1
613
610
  }, Ke = () => {
@@ -618,32 +615,32 @@ const tt = k.use || ((e) => {
618
615
  }, ze = {
619
616
  isValidating: !0
620
617
  };
621
- g(x().data) && (ze.isLoading = !0);
618
+ g(j().data) && (ze.isLoading = !0);
622
619
  try {
623
- if (D && (q(ze), n.loadingTimeout && g(x().data) && setTimeout(() => {
624
- F && j() && S().onLoadingSlow(p, n);
620
+ if (D && (q(ze), n.loadingTimeout && g(j().data) && setTimeout(() => {
621
+ F && x() && w().onLoadingSlow(p, n);
625
622
  }, n.loadingTimeout), _[p] = [
626
- b(z),
627
- Le()
623
+ b(Y),
624
+ Pe()
628
625
  ]), [A, R] = _[p], A = await A, D && setTimeout(ke, n.dedupingInterval), !_[p] || _[p][1] !== R)
629
- return D && j() && S().onDiscarded(p), !1;
626
+ return D && x() && w().onDiscarded(p), !1;
630
627
  N.error = P;
631
628
  const I = y[p];
632
629
  if (!g(I) && // case 1
633
630
  (R <= I[0] || // case 2
634
631
  R <= I[1] || // case 3
635
632
  I[1] === 0))
636
- return Ke(), D && j() && S().onDiscarded(p), !1;
637
- const U = x().data;
638
- N.data = o(U, A) ? U : A, D && j() && S().onSuccess(A, p, n);
633
+ return Ke(), D && x() && w().onDiscarded(p), !1;
634
+ const U = j().data;
635
+ N.data = o(U, A) ? U : A, D && x() && w().onSuccess(A, p, n);
639
636
  } catch (I) {
640
637
  ke();
641
- const U = S(), { shouldRetryOnError: ge } = U;
642
- U.isPaused() || (N.error = I, D && j() && (U.onError(I, p, U), (ge === !0 || M(ge) && ge(I)) && (!S().revalidateOnFocus || !S().revalidateOnReconnect || C()) && U.onErrorRetry(I, p, U, ($t) => {
643
- const Ee = u[p];
644
- Ee && Ee[0] && Ee[0](re.ERROR_REVALIDATE_EVENT, $t);
638
+ const U = w(), { shouldRetryOnError: ye } = U;
639
+ U.isPaused() || (N.error = I, D && x() && (U.onError(I, p, U), (ye === !0 || M(ye) && ye(I)) && (!w().revalidateOnFocus || !w().revalidateOnReconnect || T()) && U.onErrorRetry(I, p, U, ($t) => {
640
+ const ge = c[p];
641
+ ge && ge[0] && ge[0](re.ERROR_REVALIDATE_EVENT, $t);
645
642
  }, {
646
- retryCount: (Z.retryCount || 0) + 1,
643
+ retryCount: (ee.retryCount || 0) + 1,
647
644
  dedupe: !0
648
645
  })));
649
646
  }
@@ -664,46 +661,46 @@ const tt = k.use || ((e) => {
664
661
  p,
665
662
  r
666
663
  ]
667
- ), $e = ve(
664
+ ), $e = Ee(
668
665
  // Use callback to make sure `keyRef.current` returns latest result every time
669
- (...m) => ft(r, w.current, ...m),
666
+ (...m) => ft(r, S.current, ...m),
670
667
  // eslint-disable-next-line react-hooks/exhaustive-deps
671
668
  []
672
669
  );
673
- if (Oe(() => {
674
- v.current = t, L.current = n, g(X) || (Be.current = X);
675
- }), Oe(() => {
670
+ if (be(() => {
671
+ v.current = t, L.current = n, g(Q) || (Be.current = Q);
672
+ }), be(() => {
676
673
  if (!p) return;
677
- const m = ne.bind(P, Te);
674
+ const m = ne.bind(P, Re);
678
675
  let b = 0;
679
- const R = Un(p, u, (F, Z = {}) => {
676
+ const R = Un(p, c, (F, ee = {}) => {
680
677
  if (F == re.FOCUS_EVENT) {
681
678
  const D = Date.now();
682
- S().revalidateOnFocus && D > b && C() && (b = D + S().focusThrottleInterval, m());
679
+ w().revalidateOnFocus && D > b && T() && (b = D + w().focusThrottleInterval, m());
683
680
  } else if (F == re.RECONNECT_EVENT)
684
- S().revalidateOnReconnect && C() && m();
681
+ w().revalidateOnReconnect && T() && m();
685
682
  else {
686
683
  if (F == re.MUTATE_EVENT)
687
684
  return ne();
688
685
  if (F == re.ERROR_REVALIDATE_EVENT)
689
- return ne(Z);
686
+ return ne(ee);
690
687
  }
691
688
  });
692
- return E.current = !1, w.current = p, O.current = !0, q({
693
- _k: z
694
- }), He && (g(Q) || se ? m() : Sn(m)), () => {
689
+ return E.current = !1, S.current = p, O.current = !0, q({
690
+ _k: Y
691
+ }), He && (g(Z) || ie ? m() : wn(m)), () => {
695
692
  E.current = !0, R();
696
693
  };
697
694
  }, [
698
695
  p
699
- ]), Oe(() => {
696
+ ]), be(() => {
700
697
  let m;
701
698
  function b() {
702
- const R = M(f) ? f(x().data) : f;
699
+ const R = M(f) ? f(j().data) : f;
703
700
  R && m !== -1 && (m = setTimeout(A, R));
704
701
  }
705
702
  function A() {
706
- !x().error && (a || S().isVisible()) && (c || S().isOnline()) ? ne(Te).then(b) : b();
703
+ !j().error && (a || w().isVisible()) && (u || w().isOnline()) ? ne(Re).then(b) : b();
707
704
  }
708
705
  return b(), () => {
709
706
  m && (clearTimeout(m), m = -1);
@@ -711,69 +708,77 @@ const tt = k.use || ((e) => {
711
708
  }, [
712
709
  f,
713
710
  a,
714
- c,
711
+ u,
715
712
  p
716
- ]), Jt(ae), s && g(Q) && p) {
717
- if (!Qe && se)
713
+ ]), Jt(ue), s && g(Z) && p) {
714
+ if (!Qe && ie)
718
715
  throw new Error("Fallback data is required when using suspense in SSR.");
719
716
  v.current = t, L.current = n, E.current = !1;
720
- const m = T[p];
717
+ const m = C[p];
721
718
  if (!g(m)) {
722
719
  const b = $e(m);
723
720
  tt(b);
724
721
  }
725
- if (g(ie)) {
726
- const b = ne(Te);
727
- g(ae) || (b.status = "fulfilled", b.value = !0), tt(b);
722
+ if (g(ae)) {
723
+ const b = ne(Re);
724
+ g(ue) || (b.status = "fulfilled", b.value = !0), tt(b);
728
725
  } else
729
- throw ie;
726
+ throw ae;
730
727
  }
731
728
  return {
732
729
  mutate: $e,
733
730
  get data() {
734
- return Y.data = !0, ae;
731
+ return J.data = !0, ue;
735
732
  },
736
733
  get error() {
737
- return Y.error = !0, ie;
734
+ return J.error = !0, ae;
738
735
  },
739
736
  get isValidating() {
740
- return Y.isValidating = !0, Ht;
737
+ return J.isValidating = !0, Ht;
741
738
  },
742
739
  get isLoading() {
743
- return Y.isLoading = !0, Gt;
740
+ return J.isLoading = !0, Gt;
744
741
  }
745
742
  };
746
743
  }, qn = Nn(Wn);
747
744
  function ar() {
748
- const { widgetCtx: e } = te();
745
+ const { widgetCtx: e } = z();
749
746
  return qn([e.config.token], e.api.widgetPrelude, {
750
747
  revalidateOnFocus: !1
751
748
  });
752
749
  }
753
- var pt = {}, Ie = function(e, t) {
754
- return Ie = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n, r) {
750
+ function ur() {
751
+ const { widgetCtx: e } = z();
752
+ return {
753
+ routerState: oe(e.routerCtx.state),
754
+ toSessionsScreen: e.routerCtx.toSessionsScreen,
755
+ toChatScreen: e.routerCtx.toChatScreen
756
+ };
757
+ }
758
+ var pt = {}, Le = function(e, t) {
759
+ return Le = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n, r) {
755
760
  n.__proto__ = r;
756
761
  } || function(n, r) {
757
762
  for (var o in r) Object.prototype.hasOwnProperty.call(r, o) && (n[o] = r[o]);
758
- }, Ie(e, t);
763
+ }, Le(e, t);
759
764
  };
760
765
  function ht(e, t) {
761
766
  if (typeof t != "function" && t !== null)
762
767
  throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
763
- Ie(e, t);
768
+ Le(e, t);
764
769
  function n() {
765
770
  this.constructor = e;
766
771
  }
767
772
  e.prototype = t === null ? Object.create(t) : (n.prototype = t.prototype, new n());
768
773
  }
769
- var pe = function() {
770
- return pe = Object.assign || function(t) {
774
+ var de = function() {
775
+ return de = Object.assign || function(t) {
771
776
  for (var n, r = 1, o = arguments.length; r < o; r++) {
772
777
  n = arguments[r];
773
778
  for (var s in n) Object.prototype.hasOwnProperty.call(n, s) && (t[s] = n[s]);
774
779
  }
775
780
  return t;
776
- }, pe.apply(this, arguments);
781
+ }, de.apply(this, arguments);
777
782
  };
778
783
  function _t(e, t) {
779
784
  var n = {};
@@ -799,7 +804,7 @@ function Et(e, t, n, r, o, s) {
799
804
  if (p !== void 0 && typeof p != "function") throw new TypeError("Function expected");
800
805
  return p;
801
806
  }
802
- for (var d = r.kind, h = d === "getter" ? "get" : d === "setter" ? "set" : "value", f = !t && e ? r.static ? e : e.prototype : null, a = t || (f ? Object.getOwnPropertyDescriptor(f, r.name) : {}), c, l = !1, u = n.length - 1; u >= 0; u--) {
807
+ for (var d = r.kind, h = d === "getter" ? "get" : d === "setter" ? "set" : "value", f = !t && e ? r.static ? e : e.prototype : null, a = t || (f ? Object.getOwnPropertyDescriptor(f, r.name) : {}), u, l = !1, c = n.length - 1; c >= 0; c--) {
803
808
  var y = {};
804
809
  for (var _ in r) y[_] = _ === "access" ? {} : r[_];
805
810
  for (var _ in r.access) y.access[_] = r.access[_];
@@ -807,12 +812,12 @@ function Et(e, t, n, r, o, s) {
807
812
  if (l) throw new TypeError("Cannot add initializers after decoration has completed");
808
813
  s.push(i(p || null));
809
814
  };
810
- var T = (0, n[u])(d === "accessor" ? { get: a.get, set: a.set } : a[h], y);
815
+ var C = (0, n[c])(d === "accessor" ? { get: a.get, set: a.set } : a[h], y);
811
816
  if (d === "accessor") {
812
- if (T === void 0) continue;
813
- if (T === null || typeof T != "object") throw new TypeError("Object expected");
814
- (c = i(T.get)) && (a.get = c), (c = i(T.set)) && (a.set = c), (c = i(T.init)) && o.unshift(c);
815
- } else (c = i(T)) && (d === "field" ? o.unshift(c) : a[h] = c);
817
+ if (C === void 0) continue;
818
+ if (C === null || typeof C != "object") throw new TypeError("Object expected");
819
+ (u = i(C.get)) && (a.get = u), (u = i(C.set)) && (a.set = u), (u = i(C.init)) && o.unshift(u);
820
+ } else (u = i(C)) && (d === "field" ? o.unshift(u) : a[h] = u);
816
821
  }
817
822
  f && Object.defineProperty(f, r.name, a), l = !0;
818
823
  }
@@ -821,10 +826,10 @@ function vt(e, t, n) {
821
826
  n = r ? t[o].call(e, n) : t[o].call(e);
822
827
  return r ? n : void 0;
823
828
  }
824
- function wt(e) {
829
+ function St(e) {
825
830
  return typeof e == "symbol" ? e : "".concat(e);
826
831
  }
827
- function St(e, t, n) {
832
+ function wt(e, t, n) {
828
833
  return typeof t == "symbol" && (t = t.description ? "[".concat(t.description, "]") : ""), Object.defineProperty(e, "name", { configurable: !0, value: n ? "".concat(n, " ", t) : t });
829
834
  }
830
835
  function mt(e, t) {
@@ -840,15 +845,15 @@ function bt(e, t, n, r) {
840
845
  function d(a) {
841
846
  try {
842
847
  f(r.next(a));
843
- } catch (c) {
844
- i(c);
848
+ } catch (u) {
849
+ i(u);
845
850
  }
846
851
  }
847
852
  function h(a) {
848
853
  try {
849
854
  f(r.throw(a));
850
- } catch (c) {
851
- i(c);
855
+ } catch (u) {
856
+ i(u);
852
857
  }
853
858
  }
854
859
  function f(a) {
@@ -917,7 +922,7 @@ function Ot(e, t) {
917
922
  return { value: f[0] ? f[1] : void 0, done: !0 };
918
923
  }
919
924
  }
920
- var ye = Object.create ? function(e, t, n, r) {
925
+ var _e = Object.create ? function(e, t, n, r) {
921
926
  r === void 0 && (r = n);
922
927
  var o = Object.getOwnPropertyDescriptor(t, n);
923
928
  (!o || ("get" in o ? !t.__esModule : o.writable || o.configurable)) && (o = { enumerable: !0, get: function() {
@@ -927,9 +932,9 @@ var ye = Object.create ? function(e, t, n, r) {
927
932
  r === void 0 && (r = n), e[r] = t[n];
928
933
  };
929
934
  function Rt(e, t) {
930
- for (var n in e) n !== "default" && !Object.prototype.hasOwnProperty.call(t, n) && ye(t, e, n);
935
+ for (var n in e) n !== "default" && !Object.prototype.hasOwnProperty.call(t, n) && _e(t, e, n);
931
936
  }
932
- function he(e) {
937
+ function pe(e) {
933
938
  var t = typeof Symbol == "function" && Symbol.iterator, n = t && e[t], r = 0;
934
939
  if (n) return n.call(e);
935
940
  if (e && typeof e.length == "number") return {
@@ -956,12 +961,12 @@ function Ne(e, t) {
956
961
  }
957
962
  return s;
958
963
  }
959
- function Tt() {
964
+ function Ct() {
960
965
  for (var e = [], t = 0; t < arguments.length; t++)
961
966
  e = e.concat(Ne(arguments[t]));
962
967
  return e;
963
968
  }
964
- function Ct() {
969
+ function Tt() {
965
970
  for (var e = 0, t = 0, n = arguments.length; t < n; t++) e += arguments[t].length;
966
971
  for (var r = Array(e), o = 0, t = 0; t < n; t++)
967
972
  for (var s = arguments[t], i = 0, d = s.length; i < d; i++, o++)
@@ -973,8 +978,8 @@ function Dt(e, t, n) {
973
978
  (s || !(r in t)) && (s || (s = Array.prototype.slice.call(t, 0, r)), s[r] = t[r]);
974
979
  return e.concat(s || Array.prototype.slice.call(t));
975
980
  }
976
- function ee(e) {
977
- return this instanceof ee ? (this.v = e, this) : new ee(e);
981
+ function te(e) {
982
+ return this instanceof te ? (this.v = e, this) : new te(e);
978
983
  }
979
984
  function At(e, t, n) {
980
985
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
@@ -982,39 +987,39 @@ function At(e, t, n) {
982
987
  return o = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), d("next"), d("throw"), d("return", i), o[Symbol.asyncIterator] = function() {
983
988
  return this;
984
989
  }, o;
985
- function i(u) {
990
+ function i(c) {
986
991
  return function(y) {
987
- return Promise.resolve(y).then(u, c);
992
+ return Promise.resolve(y).then(c, u);
988
993
  };
989
994
  }
990
- function d(u, y) {
991
- r[u] && (o[u] = function(_) {
992
- return new Promise(function(T, p) {
993
- s.push([u, _, T, p]) > 1 || h(u, _);
995
+ function d(c, y) {
996
+ r[c] && (o[c] = function(_) {
997
+ return new Promise(function(C, p) {
998
+ s.push([c, _, C, p]) > 1 || h(c, _);
994
999
  });
995
- }, y && (o[u] = y(o[u])));
1000
+ }, y && (o[c] = y(o[c])));
996
1001
  }
997
- function h(u, y) {
1002
+ function h(c, y) {
998
1003
  try {
999
- f(r[u](y));
1004
+ f(r[c](y));
1000
1005
  } catch (_) {
1001
1006
  l(s[0][3], _);
1002
1007
  }
1003
1008
  }
1004
- function f(u) {
1005
- u.value instanceof ee ? Promise.resolve(u.value.v).then(a, c) : l(s[0][2], u);
1009
+ function f(c) {
1010
+ c.value instanceof te ? Promise.resolve(c.value.v).then(a, u) : l(s[0][2], c);
1006
1011
  }
1007
- function a(u) {
1008
- h("next", u);
1012
+ function a(c) {
1013
+ h("next", c);
1009
1014
  }
1010
- function c(u) {
1011
- h("throw", u);
1015
+ function u(c) {
1016
+ h("throw", c);
1012
1017
  }
1013
- function l(u, y) {
1014
- u(y), s.shift(), s.length && h(s[0][0], s[0][1]);
1018
+ function l(c, y) {
1019
+ c(y), s.shift(), s.length && h(s[0][0], s[0][1]);
1015
1020
  }
1016
1021
  }
1017
- function jt(e) {
1022
+ function xt(e) {
1018
1023
  var t, n;
1019
1024
  return t = {}, r("next"), r("throw", function(o) {
1020
1025
  throw o;
@@ -1023,14 +1028,14 @@ function jt(e) {
1023
1028
  }, t;
1024
1029
  function r(o, s) {
1025
1030
  t[o] = e[o] ? function(i) {
1026
- return (n = !n) ? { value: ee(e[o](i)), done: !1 } : s ? s(i) : i;
1031
+ return (n = !n) ? { value: te(e[o](i)), done: !1 } : s ? s(i) : i;
1027
1032
  } : s;
1028
1033
  }
1029
1034
  }
1030
- function xt(e) {
1035
+ function jt(e) {
1031
1036
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
1032
1037
  var t = e[Symbol.asyncIterator], n;
1033
- return t ? t.call(e) : (e = typeof he == "function" ? he(e) : e[Symbol.iterator](), n = {}, r("next"), r("throw"), r("return"), n[Symbol.asyncIterator] = function() {
1038
+ return t ? t.call(e) : (e = typeof pe == "function" ? pe(e) : e[Symbol.iterator](), n = {}, r("next"), r("throw"), r("return"), n[Symbol.asyncIterator] = function() {
1034
1039
  return this;
1035
1040
  }, n);
1036
1041
  function r(s) {
@@ -1057,7 +1062,7 @@ var Bn = Object.create ? function(e, t) {
1057
1062
  function Lt(e) {
1058
1063
  if (e && e.__esModule) return e;
1059
1064
  var t = {};
1060
- if (e != null) for (var n in e) n !== "default" && Object.prototype.hasOwnProperty.call(e, n) && ye(t, e, n);
1065
+ if (e != null) for (var n in e) n !== "default" && Object.prototype.hasOwnProperty.call(e, n) && _e(t, e, n);
1061
1066
  return Bn(t, e), t;
1062
1067
  }
1063
1068
  function It(e) {
@@ -1135,28 +1140,28 @@ function Wt(e, t) {
1135
1140
  }
1136
1141
  const Gn = {
1137
1142
  __extends: ht,
1138
- __assign: pe,
1143
+ __assign: de,
1139
1144
  __rest: _t,
1140
1145
  __decorate: yt,
1141
1146
  __param: gt,
1142
1147
  __esDecorate: Et,
1143
1148
  __runInitializers: vt,
1144
- __propKey: wt,
1145
- __setFunctionName: St,
1149
+ __propKey: St,
1150
+ __setFunctionName: wt,
1146
1151
  __metadata: mt,
1147
1152
  __awaiter: bt,
1148
1153
  __generator: Ot,
1149
- __createBinding: ye,
1154
+ __createBinding: _e,
1150
1155
  __exportStar: Rt,
1151
- __values: he,
1156
+ __values: pe,
1152
1157
  __read: Ne,
1153
- __spread: Tt,
1154
- __spreadArrays: Ct,
1158
+ __spread: Ct,
1159
+ __spreadArrays: Tt,
1155
1160
  __spreadArray: Dt,
1156
- __await: ee,
1161
+ __await: te,
1157
1162
  __asyncGenerator: At,
1158
- __asyncDelegator: jt,
1159
- __asyncValues: xt,
1163
+ __asyncDelegator: xt,
1164
+ __asyncValues: jt,
1160
1165
  __makeTemplateObject: Pt,
1161
1166
  __importStar: Lt,
1162
1167
  __importDefault: It,
@@ -1170,17 +1175,17 @@ const Gn = {
1170
1175
  __proto__: null,
1171
1176
  __addDisposableResource: Nt,
1172
1177
  get __assign() {
1173
- return pe;
1178
+ return de;
1174
1179
  },
1175
- __asyncDelegator: jt,
1180
+ __asyncDelegator: xt,
1176
1181
  __asyncGenerator: At,
1177
- __asyncValues: xt,
1178
- __await: ee,
1182
+ __asyncValues: jt,
1183
+ __await: te,
1179
1184
  __awaiter: bt,
1180
1185
  __classPrivateFieldGet: Vt,
1181
1186
  __classPrivateFieldIn: Mt,
1182
1187
  __classPrivateFieldSet: Ft,
1183
- __createBinding: ye,
1188
+ __createBinding: _e,
1184
1189
  __decorate: yt,
1185
1190
  __disposeResources: Ut,
1186
1191
  __esDecorate: Et,
@@ -1192,22 +1197,22 @@ const Gn = {
1192
1197
  __makeTemplateObject: Pt,
1193
1198
  __metadata: mt,
1194
1199
  __param: gt,
1195
- __propKey: wt,
1200
+ __propKey: St,
1196
1201
  __read: Ne,
1197
1202
  __rest: _t,
1198
1203
  __rewriteRelativeImportExtension: Wt,
1199
1204
  __runInitializers: vt,
1200
- __setFunctionName: St,
1201
- __spread: Tt,
1205
+ __setFunctionName: wt,
1206
+ __spread: Ct,
1202
1207
  __spreadArray: Dt,
1203
- __spreadArrays: Ct,
1204
- __values: he,
1208
+ __spreadArrays: Tt,
1209
+ __values: pe,
1205
1210
  default: Gn
1206
- }, Symbol.toStringTag, { value: "Module" })), Kn = /* @__PURE__ */ cn($n);
1207
- var fe = {}, nt;
1211
+ }, Symbol.toStringTag, { value: "Module" })), Kn = /* @__PURE__ */ un($n);
1212
+ var le = {}, nt;
1208
1213
  function kn() {
1209
- if (nt) return fe;
1210
- nt = 1, Object.defineProperty(fe, "__esModule", { value: !0 });
1214
+ if (nt) return le;
1215
+ nt = 1, Object.defineProperty(le, "__esModule", { value: !0 });
1211
1216
  var e = k;
1212
1217
  function t() {
1213
1218
  var n = e.useRef(!1), r = e.useCallback(function() {
@@ -1219,62 +1224,62 @@ function kn() {
1219
1224
  };
1220
1225
  }, []), r;
1221
1226
  }
1222
- return fe.default = t, fe;
1227
+ return le.default = t, le;
1223
1228
  }
1224
1229
  Object.defineProperty(pt, "__esModule", { value: !0 });
1225
- var Ve = Kn, Ce = k, zn = Ve.__importDefault(kn());
1230
+ var Ie = Kn, Ce = k, zn = Ie.__importDefault(kn());
1226
1231
  function Yn(e, t, n) {
1227
1232
  t === void 0 && (t = []), n === void 0 && (n = { loading: !1 });
1228
1233
  var r = Ce.useRef(0), o = zn.default(), s = Ce.useState(n), i = s[0], d = s[1], h = Ce.useCallback(function() {
1229
1234
  for (var f = [], a = 0; a < arguments.length; a++)
1230
1235
  f[a] = arguments[a];
1231
- var c = ++r.current;
1236
+ var u = ++r.current;
1232
1237
  return i.loading || d(function(l) {
1233
- return Ve.__assign(Ve.__assign({}, l), { loading: !0 });
1238
+ return Ie.__assign(Ie.__assign({}, l), { loading: !0 });
1234
1239
  }), e.apply(void 0, f).then(function(l) {
1235
- return o() && c === r.current && d({ value: l, loading: !1 }), l;
1240
+ return o() && u === r.current && d({ value: l, loading: !1 }), l;
1236
1241
  }, function(l) {
1237
- return o() && c === r.current && d({ error: l, loading: !1 }), l;
1242
+ return o() && u === r.current && d({ error: l, loading: !1 }), l;
1238
1243
  });
1239
1244
  }, t);
1240
1245
  return [i, h];
1241
1246
  }
1242
1247
  var cr = pt.default = Yn;
1243
1248
  const B = /* @__PURE__ */ new Map();
1244
- function ur() {
1245
- const [e, t] = Xt([]), { widgetCtx: { api: n } } = te();
1249
+ function fr() {
1250
+ const [e, t] = Xt([]), { widgetCtx: { api: n } } = z();
1246
1251
  function r(a) {
1247
- const c = a.map((l) => ({
1252
+ const u = a.map((l) => ({
1248
1253
  file: l,
1249
1254
  id: en(),
1250
1255
  status: "pending",
1251
1256
  progress: 0
1252
1257
  }));
1253
- t((l) => [...l, ...c]), c.forEach(i);
1258
+ t((l) => [...l, ...u]), u.forEach(i);
1254
1259
  }
1255
- function o(a, c) {
1260
+ function o(a, u) {
1256
1261
  t(
1257
- (l) => l.map((u) => u.id === a ? { ...u, ...c } : u)
1262
+ (l) => l.map((c) => c.id === a ? { ...c, ...u } : c)
1258
1263
  );
1259
1264
  }
1260
1265
  function s(a) {
1261
- t((c) => c.filter((l) => l.id !== a));
1266
+ t((u) => u.filter((l) => l.id !== a));
1262
1267
  }
1263
1268
  const i = async (a) => {
1264
- const c = new AbortController();
1265
- B.set(a.id, c);
1269
+ const u = new AbortController();
1270
+ B.set(a.id, u);
1266
1271
  try {
1267
1272
  t(
1268
- (u) => u.map(
1273
+ (c) => c.map(
1269
1274
  (y) => y.id === a.id ? { ...y, status: "uploading", progress: 0 } : y
1270
1275
  )
1271
1276
  );
1272
1277
  const l = await n.uploadFile(a, {
1273
- signal: c.signal,
1274
- onUploadProgress: (u) => {
1275
- if (!u.total) return;
1278
+ signal: u.signal,
1279
+ onUploadProgress: (c) => {
1280
+ if (!c.total) return;
1276
1281
  const y = Math.round(
1277
- u.loaded * 100 / u.total
1282
+ c.loaded * 100 / c.total
1278
1283
  );
1279
1284
  o(a.id, { progress: y });
1280
1285
  }
@@ -1285,7 +1290,7 @@ function ur() {
1285
1290
  progress: 100
1286
1291
  });
1287
1292
  } catch (l) {
1288
- c.signal.aborted || o(a.id, {
1293
+ u.signal.aborted || o(a.id, {
1289
1294
  status: "error",
1290
1295
  error: l instanceof Error ? l.message : "Upload failed",
1291
1296
  progress: 0
@@ -1294,9 +1299,9 @@ function ur() {
1294
1299
  B.delete(a.id);
1295
1300
  }
1296
1301
  }, d = (a) => {
1297
- const c = B.get(a);
1298
- c && (c.abort(), B.delete(a)), s(a);
1299
- }, h = le(() => e.filter((a) => a.status === "success" && a.fileUrl), [e]);
1302
+ const u = B.get(a);
1303
+ u && (u.abort(), B.delete(a)), s(a);
1304
+ }, h = Ve(() => e.filter((a) => a.status === "success" && a.fileUrl), [e]);
1300
1305
  function f() {
1301
1306
  B.forEach((a) => a.abort()), B.clear(), t([]);
1302
1307
  }
@@ -1308,14 +1313,14 @@ function ur() {
1308
1313
  handleCancelUpload: d,
1309
1314
  successFiles: h,
1310
1315
  emptyTheFiles: f,
1311
- getFileById: (a) => e.find((c) => c.id === a),
1316
+ getFileById: (a) => e.find((u) => u.id === a),
1312
1317
  getUploadProgress: (a) => {
1313
- var c;
1314
- return ((c = e.find((l) => l.id === a)) == null ? void 0 : c.progress) ?? 0;
1318
+ var u;
1319
+ return ((u = e.find((l) => l.id === a)) == null ? void 0 : u.progress) ?? 0;
1315
1320
  },
1316
1321
  getUploadStatus: (a) => {
1317
- var c;
1318
- return (c = e.find((l) => l.id === a)) == null ? void 0 : c.status;
1322
+ var u;
1323
+ return (u = e.find((l) => l.id === a)) == null ? void 0 : u.status;
1319
1324
  },
1320
1325
  hasErrors: e.some((a) => a.status === "error"),
1321
1326
  isUploading: e.some((a) => a.status === "uploading")
@@ -1329,14 +1334,15 @@ export {
1329
1334
  or as c,
1330
1335
  sn as d,
1331
1336
  ar as e,
1332
- de as f,
1337
+ oe as f,
1333
1338
  an as g,
1334
1339
  ur as h,
1335
- pe as i,
1336
- _t as j,
1337
- Dt as k,
1338
- sr as l,
1339
- ir as m,
1340
- te as u
1340
+ fr as i,
1341
+ de as j,
1342
+ _t as k,
1343
+ Dt as l,
1344
+ sr as m,
1345
+ ir as n,
1346
+ z as u
1341
1347
  };
1342
- //# sourceMappingURL=useUploadFiles-pIJKchG_.js.map
1348
+ //# sourceMappingURL=useUploadFiles-Eo0ts3JJ.js.map