@variamosple/variamos-components 0.2.2 → 0.2.3

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,6 +1,7 @@
1
- import { jsx as Re } from "react/jsx-runtime";
2
- import { createContext as Oe, useState as O, useEffect as Se, useContext as Ce } from "react";
3
- import { useSession as Be } from "./SessionContext.js";
1
+ import { jsx as Se } from "react/jsx-runtime";
2
+ import { createContext as Ce, useMemo as Be, useState as O, useEffect as xe, useContext as Ne } from "react";
3
+ import { createAccessTokenProvider as Le, accessTokenUrl as Pe } from "./notificationAccessToken.js";
4
+ import { useSession as qe } from "./SessionContext.js";
4
5
  const E = /* @__PURE__ */ Object.create(null);
5
6
  E.open = "0";
6
7
  E.close = "1";
@@ -13,59 +14,59 @@ const N = /* @__PURE__ */ Object.create(null);
13
14
  Object.keys(E).forEach((n) => {
14
15
  N[E[n]] = n;
15
16
  });
16
- const M = { type: "error", data: "parser error" }, re = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", oe = typeof ArrayBuffer == "function", ae = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n && n.buffer instanceof ArrayBuffer, z = ({ type: n, data: e }, t, s) => re && e instanceof Blob ? t ? s(e) : ee(e, s) : oe && (e instanceof ArrayBuffer || ae(e)) ? t ? s(e) : ee(new Blob([e]), s) : s(E[n] + (e || "")), ee = (n, e) => {
17
+ const $ = { type: "error", data: "parser error" }, ae = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", ce = typeof ArrayBuffer == "function", he = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n && n.buffer instanceof ArrayBuffer, z = ({ type: n, data: e }, t, s) => ae && e instanceof Blob ? t ? s(e) : se(e, s) : ce && (e instanceof ArrayBuffer || he(e)) ? t ? s(e) : se(new Blob([e]), s) : s(E[n] + (e || "")), se = (n, e) => {
17
18
  const t = new FileReader();
18
19
  return t.onload = function() {
19
20
  const s = t.result.split(",")[1];
20
21
  e("b" + (s || ""));
21
22
  }, t.readAsDataURL(n);
22
23
  };
23
- function te(n) {
24
+ function ne(n) {
24
25
  return n instanceof Uint8Array ? n : n instanceof ArrayBuffer ? new Uint8Array(n) : new Uint8Array(n.buffer, n.byteOffset, n.byteLength);
25
26
  }
26
27
  let V;
27
- function xe(n, e) {
28
- if (re && n.data instanceof Blob)
29
- return n.data.arrayBuffer().then(te).then(e);
30
- if (oe && (n.data instanceof ArrayBuffer || ae(n.data)))
31
- return e(te(n.data));
28
+ function Ie(n, e) {
29
+ if (ae && n.data instanceof Blob)
30
+ return n.data.arrayBuffer().then(ne).then(e);
31
+ if (ce && (n.data instanceof ArrayBuffer || he(n.data)))
32
+ return e(ne(n.data));
32
33
  z(n, !1, (t) => {
33
34
  V || (V = new TextEncoder()), e(V.encode(t));
34
35
  });
35
36
  }
36
- const se = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", C = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
37
- for (let n = 0; n < se.length; n++)
38
- C[se.charCodeAt(n)] = n;
39
- const Ne = (n) => {
40
- let e = n.length * 0.75, t = n.length, s, i = 0, r, o, a, h;
37
+ const ie = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", C = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
38
+ for (let n = 0; n < ie.length; n++)
39
+ C[ie.charCodeAt(n)] = n;
40
+ const De = (n) => {
41
+ let e = n.length * 0.75, t = n.length, s, i = 0, r, o, a, c;
41
42
  n[n.length - 1] === "=" && (e--, n[n.length - 2] === "=" && e--);
42
43
  const m = new ArrayBuffer(e), d = new Uint8Array(m);
43
44
  for (s = 0; s < t; s += 4)
44
- r = C[n.charCodeAt(s)], o = C[n.charCodeAt(s + 1)], a = C[n.charCodeAt(s + 2)], h = C[n.charCodeAt(s + 3)], d[i++] = r << 2 | o >> 4, d[i++] = (o & 15) << 4 | a >> 2, d[i++] = (a & 3) << 6 | h & 63;
45
+ r = C[n.charCodeAt(s)], o = C[n.charCodeAt(s + 1)], a = C[n.charCodeAt(s + 2)], c = C[n.charCodeAt(s + 3)], d[i++] = r << 2 | o >> 4, d[i++] = (o & 15) << 4 | a >> 2, d[i++] = (a & 3) << 6 | c & 63;
45
46
  return m;
46
- }, Le = typeof ArrayBuffer == "function", J = (n, e) => {
47
+ }, Fe = typeof ArrayBuffer == "function", J = (n, e) => {
47
48
  if (typeof n != "string")
48
49
  return {
49
50
  type: "message",
50
- data: ce(n, e)
51
+ data: fe(n, e)
51
52
  };
52
53
  const t = n.charAt(0);
53
54
  return t === "b" ? {
54
55
  type: "message",
55
- data: Pe(n.substring(1), e)
56
+ data: Ve(n.substring(1), e)
56
57
  } : N[t] ? n.length > 1 ? {
57
58
  type: N[t],
58
59
  data: n.substring(1)
59
60
  } : {
60
61
  type: N[t]
61
- } : M;
62
- }, Pe = (n, e) => {
63
- if (Le) {
64
- const t = Ne(n);
65
- return ce(t, e);
62
+ } : $;
63
+ }, Ve = (n, e) => {
64
+ if (Fe) {
65
+ const t = De(n);
66
+ return fe(t, e);
66
67
  } else
67
68
  return { base64: !0, data: n };
68
- }, ce = (n, e) => {
69
+ }, fe = (n, e) => {
69
70
  switch (e) {
70
71
  case "blob":
71
72
  return n instanceof Blob ? n : new Blob([n]);
@@ -73,16 +74,16 @@ const Ne = (n) => {
73
74
  default:
74
75
  return n instanceof ArrayBuffer ? n : n.buffer;
75
76
  }
76
- }, he = "", qe = (n, e) => {
77
+ }, ue = "", Ue = (n, e) => {
77
78
  const t = n.length, s = new Array(t);
78
79
  let i = 0;
79
80
  n.forEach((r, o) => {
80
81
  z(r, !1, (a) => {
81
- s[o] = a, ++i === t && e(s.join(he));
82
+ s[o] = a, ++i === t && e(s.join(ue));
82
83
  });
83
84
  });
84
- }, Ie = (n, e) => {
85
- const t = n.split(he), s = [];
85
+ }, Me = (n, e) => {
86
+ const t = n.split(ue), s = [];
86
87
  for (let i = 0; i < t.length; i++) {
87
88
  const r = J(t[i], e);
88
89
  if (s.push(r), r.type === "error")
@@ -90,10 +91,10 @@ const Ne = (n) => {
90
91
  }
91
92
  return s;
92
93
  };
93
- function De() {
94
+ function $e() {
94
95
  return new TransformStream({
95
96
  transform(n, e) {
96
- xe(n, (t) => {
97
+ Ie(n, (t) => {
97
98
  const s = t.length;
98
99
  let i;
99
100
  if (s < 126)
@@ -125,7 +126,7 @@ function x(n, e) {
125
126
  t[i] = n[0][s++], s === n[0].length && (n.shift(), s = 0);
126
127
  return n.length && s < n[0].length && (n[0] = n[0].slice(s)), t;
127
128
  }
128
- function Fe(n, e) {
129
+ function He(n, e) {
129
130
  U || (U = new TextDecoder());
130
131
  const t = [];
131
132
  let s = 0, i = -1, r = !1;
@@ -135,55 +136,55 @@ function Fe(n, e) {
135
136
  if (s === 0) {
136
137
  if (B(t) < 1)
137
138
  break;
138
- const h = x(t, 1);
139
- r = (h[0] & 128) === 128, i = h[0] & 127, i < 126 ? s = 3 : i === 126 ? s = 1 : s = 2;
139
+ const c = x(t, 1);
140
+ r = (c[0] & 128) === 128, i = c[0] & 127, i < 126 ? s = 3 : i === 126 ? s = 1 : s = 2;
140
141
  } else if (s === 1) {
141
142
  if (B(t) < 2)
142
143
  break;
143
- const h = x(t, 2);
144
- i = new DataView(h.buffer, h.byteOffset, h.length).getUint16(0), s = 3;
144
+ const c = x(t, 2);
145
+ i = new DataView(c.buffer, c.byteOffset, c.length).getUint16(0), s = 3;
145
146
  } else if (s === 2) {
146
147
  if (B(t) < 8)
147
148
  break;
148
- const h = x(t, 8), m = new DataView(h.buffer, h.byteOffset, h.length), d = m.getUint32(0);
149
+ const c = x(t, 8), m = new DataView(c.buffer, c.byteOffset, c.length), d = m.getUint32(0);
149
150
  if (d > Math.pow(2, 21) - 1) {
150
- a.enqueue(M);
151
+ a.enqueue($);
151
152
  break;
152
153
  }
153
154
  i = d * Math.pow(2, 32) + m.getUint32(4), s = 3;
154
155
  } else {
155
156
  if (B(t) < i)
156
157
  break;
157
- const h = x(t, i);
158
- a.enqueue(J(r ? h : U.decode(h), e)), s = 0;
158
+ const c = x(t, i);
159
+ a.enqueue(J(r ? c : U.decode(c), e)), s = 0;
159
160
  }
160
161
  if (i === 0 || i > n) {
161
- a.enqueue(M);
162
+ a.enqueue($);
162
163
  break;
163
164
  }
164
165
  }
165
166
  }
166
167
  });
167
168
  }
168
- const fe = 4;
169
- function u(n) {
170
- if (n) return Ve(n);
169
+ const le = 4;
170
+ function l(n) {
171
+ if (n) return Ke(n);
171
172
  }
172
- function Ve(n) {
173
- for (var e in u.prototype)
174
- n[e] = u.prototype[e];
173
+ function Ke(n) {
174
+ for (var e in l.prototype)
175
+ n[e] = l.prototype[e];
175
176
  return n;
176
177
  }
177
- u.prototype.on = u.prototype.addEventListener = function(n, e) {
178
+ l.prototype.on = l.prototype.addEventListener = function(n, e) {
178
179
  return this._callbacks = this._callbacks || {}, (this._callbacks["$" + n] = this._callbacks["$" + n] || []).push(e), this;
179
180
  };
180
- u.prototype.once = function(n, e) {
181
+ l.prototype.once = function(n, e) {
181
182
  function t() {
182
183
  this.off(n, t), e.apply(this, arguments);
183
184
  }
184
185
  return t.fn = e, this.on(n, t), this;
185
186
  };
186
- u.prototype.off = u.prototype.removeListener = u.prototype.removeAllListeners = u.prototype.removeEventListener = function(n, e) {
187
+ l.prototype.off = l.prototype.removeListener = l.prototype.removeAllListeners = l.prototype.removeEventListener = function(n, e) {
187
188
  if (this._callbacks = this._callbacks || {}, arguments.length == 0)
188
189
  return this._callbacks = {}, this;
189
190
  var t = this._callbacks["$" + n];
@@ -197,7 +198,7 @@ u.prototype.off = u.prototype.removeListener = u.prototype.removeAllListeners =
197
198
  }
198
199
  return t.length === 0 && delete this._callbacks["$" + n], this;
199
200
  };
200
- u.prototype.emit = function(n) {
201
+ l.prototype.emit = function(n) {
201
202
  this._callbacks = this._callbacks || {};
202
203
  for (var e = new Array(arguments.length - 1), t = this._callbacks["$" + n], s = 1; s < arguments.length; s++)
203
204
  e[s - 1] = arguments[s];
@@ -208,41 +209,41 @@ u.prototype.emit = function(n) {
208
209
  }
209
210
  return this;
210
211
  };
211
- u.prototype.emitReserved = u.prototype.emit;
212
- u.prototype.listeners = function(n) {
212
+ l.prototype.emitReserved = l.prototype.emit;
213
+ l.prototype.listeners = function(n) {
213
214
  return this._callbacks = this._callbacks || {}, this._callbacks["$" + n] || [];
214
215
  };
215
- u.prototype.hasListeners = function(n) {
216
+ l.prototype.hasListeners = function(n) {
216
217
  return !!this.listeners(n).length;
217
218
  };
218
- const D = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0), y = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), Ue = "arraybuffer";
219
- function ue(n, ...e) {
219
+ const D = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0), y = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), We = "arraybuffer";
220
+ function pe(n, ...e) {
220
221
  return e.reduce((t, s) => (n.hasOwnProperty(s) && (t[s] = n[s]), t), {});
221
222
  }
222
- const $e = y.setTimeout, Me = y.clearTimeout;
223
+ const Ye = y.setTimeout, ze = y.clearTimeout;
223
224
  function F(n, e) {
224
- e.useNativeTimers ? (n.setTimeoutFn = $e.bind(y), n.clearTimeoutFn = Me.bind(y)) : (n.setTimeoutFn = y.setTimeout.bind(y), n.clearTimeoutFn = y.clearTimeout.bind(y));
225
+ e.useNativeTimers ? (n.setTimeoutFn = Ye.bind(y), n.clearTimeoutFn = ze.bind(y)) : (n.setTimeoutFn = y.setTimeout.bind(y), n.clearTimeoutFn = y.clearTimeout.bind(y));
225
226
  }
226
- const He = 1.33;
227
- function Ke(n) {
228
- return typeof n == "string" ? We(n) : Math.ceil((n.byteLength || n.size) * He);
227
+ const Je = 1.33;
228
+ function Xe(n) {
229
+ return typeof n == "string" ? Qe(n) : Math.ceil((n.byteLength || n.size) * Je);
229
230
  }
230
- function We(n) {
231
+ function Qe(n) {
231
232
  let e = 0, t = 0;
232
233
  for (let s = 0, i = n.length; s < i; s++)
233
234
  e = n.charCodeAt(s), e < 128 ? t += 1 : e < 2048 ? t += 2 : e < 55296 || e >= 57344 ? t += 3 : (s++, t += 4);
234
235
  return t;
235
236
  }
236
- function le() {
237
+ function de() {
237
238
  return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
238
239
  }
239
- function Ye(n) {
240
+ function je(n) {
240
241
  let e = "";
241
242
  for (let t in n)
242
243
  n.hasOwnProperty(t) && (e.length && (e += "&"), e += encodeURIComponent(t) + "=" + encodeURIComponent(n[t]));
243
244
  return e;
244
245
  }
245
- function ze(n) {
246
+ function Ge(n) {
246
247
  let e = {}, t = n.split("&");
247
248
  for (let s = 0, i = t.length; s < i; s++) {
248
249
  let r = t[s].split("=");
@@ -250,12 +251,12 @@ function ze(n) {
250
251
  }
251
252
  return e;
252
253
  }
253
- class Je extends Error {
254
+ class Ze extends Error {
254
255
  constructor(e, t, s) {
255
256
  super(e), this.description = t, this.context = s, this.type = "TransportError";
256
257
  }
257
258
  }
258
- class X extends u {
259
+ class X extends l {
259
260
  /**
260
261
  * Transport abstract constructor.
261
262
  *
@@ -275,7 +276,7 @@ class X extends u {
275
276
  * @protected
276
277
  */
277
278
  onError(e, t, s) {
278
- return super.emitReserved("error", new Je(e, t, s)), this;
279
+ return super.emitReserved("error", new Ze(e, t, s)), this;
279
280
  }
280
281
  /**
281
282
  * Opens the transport.
@@ -349,11 +350,11 @@ class X extends u {
349
350
  return this.opts.port && (this.opts.secure && Number(this.opts.port) !== 443 || !this.opts.secure && Number(this.opts.port) !== 80) ? ":" + this.opts.port : "";
350
351
  }
351
352
  _query(e) {
352
- const t = Ye(e);
353
+ const t = je(e);
353
354
  return t.length ? "?" + t : "";
354
355
  }
355
356
  }
356
- class Xe extends X {
357
+ class et extends X {
357
358
  constructor() {
358
359
  super(...arguments), this._polling = !1;
359
360
  }
@@ -409,7 +410,7 @@ class Xe extends X {
409
410
  return this.onClose({ description: "transport closed by the server" }), !1;
410
411
  this.onPacket(s);
411
412
  };
412
- Ie(e, this.socket.binaryType).forEach(t), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
413
+ Me(e, this.socket.binaryType).forEach(t), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
413
414
  }
414
415
  /**
415
416
  * For polling, send a close packet.
@@ -429,7 +430,7 @@ class Xe extends X {
429
430
  * @protected
430
431
  */
431
432
  write(e) {
432
- this.writable = !1, qe(e, (t) => {
433
+ this.writable = !1, Ue(e, (t) => {
433
434
  this.doWrite(t, () => {
434
435
  this.writable = !0, this.emitReserved("drain");
435
436
  });
@@ -442,18 +443,18 @@ class Xe extends X {
442
443
  */
443
444
  uri() {
444
445
  const e = this.opts.secure ? "https" : "http", t = this.query || {};
445
- return this.opts.timestampRequests !== !1 && (t[this.opts.timestampParam] = le()), !this.supportsBinary && !t.sid && (t.b64 = 1), this.createUri(e, t);
446
+ return this.opts.timestampRequests !== !1 && (t[this.opts.timestampParam] = de()), !this.supportsBinary && !t.sid && (t.b64 = 1), this.createUri(e, t);
446
447
  }
447
448
  }
448
- let pe = !1;
449
+ let ye = !1;
449
450
  try {
450
- pe = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
451
+ ye = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
451
452
  } catch {
452
453
  }
453
- const Qe = pe;
454
- function je() {
454
+ const tt = ye;
455
+ function st() {
455
456
  }
456
- class Ge extends Xe {
457
+ class nt extends et {
457
458
  /**
458
459
  * XHR Polling constructor.
459
460
  *
@@ -495,7 +496,7 @@ class Ge extends Xe {
495
496
  }), this.pollXhr = e;
496
497
  }
497
498
  }
498
- class b extends u {
499
+ class b extends l {
499
500
  /**
500
501
  * Request constructor
501
502
  *
@@ -512,7 +513,7 @@ class b extends u {
512
513
  */
513
514
  _create() {
514
515
  var e;
515
- const t = ue(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
516
+ const t = pe(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
516
517
  t.xdomain = !!this._opts.xd;
517
518
  const s = this._xhr = this.createRequest(t);
518
519
  try {
@@ -566,7 +567,7 @@ class b extends u {
566
567
  */
567
568
  _cleanup(e) {
568
569
  if (!(typeof this._xhr > "u" || this._xhr === null)) {
569
- if (this._xhr.onreadystatechange = je, e)
570
+ if (this._xhr.onreadystatechange = st, e)
570
571
  try {
571
572
  this._xhr.abort();
572
573
  } catch {
@@ -596,36 +597,36 @@ b.requestsCount = 0;
596
597
  b.requests = {};
597
598
  if (typeof document < "u") {
598
599
  if (typeof attachEvent == "function")
599
- attachEvent("onunload", ne);
600
+ attachEvent("onunload", re);
600
601
  else if (typeof addEventListener == "function") {
601
602
  const n = "onpagehide" in y ? "pagehide" : "unload";
602
- addEventListener(n, ne, !1);
603
+ addEventListener(n, re, !1);
603
604
  }
604
605
  }
605
- function ne() {
606
+ function re() {
606
607
  for (let n in b.requests)
607
608
  b.requests.hasOwnProperty(n) && b.requests[n].abort();
608
609
  }
609
- const Ze = (function() {
610
- const n = de({
610
+ const it = (function() {
611
+ const n = me({
611
612
  xdomain: !1
612
613
  });
613
614
  return n && n.responseType !== null;
614
615
  })();
615
- class et extends Ge {
616
+ class rt extends nt {
616
617
  constructor(e) {
617
618
  super(e);
618
619
  const t = e && e.forceBase64;
619
- this.supportsBinary = Ze && !t;
620
+ this.supportsBinary = it && !t;
620
621
  }
621
622
  request(e = {}) {
622
- return Object.assign(e, { xd: this.xd }, this.opts), new b(de, this.uri(), e);
623
+ return Object.assign(e, { xd: this.xd }, this.opts), new b(me, this.uri(), e);
623
624
  }
624
625
  }
625
- function de(n) {
626
+ function me(n) {
626
627
  const e = n.xdomain;
627
628
  try {
628
- if (typeof XMLHttpRequest < "u" && (!e || Qe))
629
+ if (typeof XMLHttpRequest < "u" && (!e || tt))
629
630
  return new XMLHttpRequest();
630
631
  } catch {
631
632
  }
@@ -635,13 +636,13 @@ function de(n) {
635
636
  } catch {
636
637
  }
637
638
  }
638
- const ye = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
639
- class tt extends X {
639
+ const ge = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
640
+ class ot extends X {
640
641
  get name() {
641
642
  return "websocket";
642
643
  }
643
644
  doOpen() {
644
- const e = this.uri(), t = this.opts.protocols, s = ye ? {} : ue(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
645
+ const e = this.uri(), t = this.opts.protocols, s = ge ? {} : pe(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
645
646
  this.opts.extraHeaders && (s.headers = this.opts.extraHeaders);
646
647
  try {
647
648
  this.ws = this.createSocket(e, t, s);
@@ -689,19 +690,19 @@ class tt extends X {
689
690
  */
690
691
  uri() {
691
692
  const e = this.opts.secure ? "wss" : "ws", t = this.query || {};
692
- return this.opts.timestampRequests && (t[this.opts.timestampParam] = le()), this.supportsBinary || (t.b64 = 1), this.createUri(e, t);
693
+ return this.opts.timestampRequests && (t[this.opts.timestampParam] = de()), this.supportsBinary || (t.b64 = 1), this.createUri(e, t);
693
694
  }
694
695
  }
695
- const $ = y.WebSocket || y.MozWebSocket;
696
- class st extends tt {
696
+ const M = y.WebSocket || y.MozWebSocket;
697
+ class at extends ot {
697
698
  createSocket(e, t, s) {
698
- return ye ? new $(e, t, s) : t ? new $(e, t) : new $(e);
699
+ return ge ? new M(e, t, s) : t ? new M(e, t) : new M(e);
699
700
  }
700
701
  doWrite(e, t) {
701
702
  this.ws.send(t);
702
703
  }
703
704
  }
704
- class nt extends X {
705
+ class ct extends X {
705
706
  get name() {
706
707
  return "webtransport";
707
708
  }
@@ -717,11 +718,11 @@ class nt extends X {
717
718
  this.onError("webtransport error", e);
718
719
  }), this._transport.ready.then(() => {
719
720
  this._transport.createBidirectionalStream().then((e) => {
720
- const t = Fe(Number.MAX_SAFE_INTEGER, this.socket.binaryType), s = e.readable.pipeThrough(t).getReader(), i = De();
721
+ const t = He(Number.MAX_SAFE_INTEGER, this.socket.binaryType), s = e.readable.pipeThrough(t).getReader(), i = $e();
721
722
  i.readable.pipeTo(e.writable), this._writer = i.writable.getWriter();
722
723
  const r = () => {
723
- s.read().then(({ done: a, value: h }) => {
724
- a || (this.onPacket(h), r());
724
+ s.read().then(({ done: a, value: c }) => {
725
+ a || (this.onPacket(c), r());
725
726
  }).catch((a) => {
726
727
  });
727
728
  };
@@ -747,11 +748,11 @@ class nt extends X {
747
748
  (e = this._transport) === null || e === void 0 || e.close();
748
749
  }
749
750
  }
750
- const it = {
751
- websocket: st,
752
- webtransport: nt,
753
- polling: et
754
- }, rt = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, ot = [
751
+ const ht = {
752
+ websocket: at,
753
+ webtransport: ct,
754
+ polling: rt
755
+ }, ft = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, ut = [
755
756
  "source",
756
757
  "protocol",
757
758
  "authority",
@@ -772,16 +773,16 @@ function H(n) {
772
773
  throw "URI too long";
773
774
  const e = n, t = n.indexOf("["), s = n.indexOf("]");
774
775
  t != -1 && s != -1 && (n = n.substring(0, t) + n.substring(t, s).replace(/:/g, ";") + n.substring(s, n.length));
775
- let i = rt.exec(n || ""), r = {}, o = 14;
776
+ let i = ft.exec(n || ""), r = {}, o = 14;
776
777
  for (; o--; )
777
- r[ot[o]] = i[o] || "";
778
- return t != -1 && s != -1 && (r.source = e, r.host = r.host.substring(1, r.host.length - 1).replace(/;/g, ":"), r.authority = r.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), r.ipv6uri = !0), r.pathNames = at(r, r.path), r.queryKey = ct(r, r.query), r;
778
+ r[ut[o]] = i[o] || "";
779
+ return t != -1 && s != -1 && (r.source = e, r.host = r.host.substring(1, r.host.length - 1).replace(/;/g, ":"), r.authority = r.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), r.ipv6uri = !0), r.pathNames = lt(r, r.path), r.queryKey = pt(r, r.query), r;
779
780
  }
780
- function at(n, e) {
781
+ function lt(n, e) {
781
782
  const t = /\/{2,9}/g, s = e.replace(t, "/").split("/");
782
783
  return (e.slice(0, 1) == "/" || e.length === 0) && s.splice(0, 1), e.slice(-1) == "/" && s.splice(s.length - 1, 1), s;
783
784
  }
784
- function ct(n, e) {
785
+ function pt(n, e) {
785
786
  const t = {};
786
787
  return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(s, i, r) {
787
788
  i && (t[i] = r);
@@ -791,7 +792,7 @@ const K = typeof addEventListener == "function" && typeof removeEventListener ==
791
792
  K && addEventListener("offline", () => {
792
793
  L.forEach((n) => n());
793
794
  }, !1);
794
- class A extends u {
795
+ class T extends l {
795
796
  /**
796
797
  * Socket constructor.
797
798
  *
@@ -799,7 +800,7 @@ class A extends u {
799
800
  * @param {Object} opts - options
800
801
  */
801
802
  constructor(e, t) {
802
- if (super(), this.binaryType = Ue, this.writeBuffer = [], this._prevBufferLen = 0, this._pingInterval = -1, this._pingTimeout = -1, this._maxPayload = -1, this._pingTimeoutTime = 1 / 0, e && typeof e == "object" && (t = e, e = null), e) {
803
+ if (super(), this.binaryType = We, this.writeBuffer = [], this._prevBufferLen = 0, this._pingInterval = -1, this._pingTimeout = -1, this._maxPayload = -1, this._pingTimeoutTime = 1 / 0, e && typeof e == "object" && (t = e, e = null), e) {
803
804
  const s = H(e);
804
805
  t.hostname = s.host, t.secure = s.protocol === "https" || s.protocol === "wss", t.port = s.port, s.query && (t.query = s.query);
805
806
  } else t.host && (t.hostname = H(t.host).host);
@@ -820,7 +821,7 @@ class A extends u {
820
821
  },
821
822
  transportOptions: {},
822
823
  closeOnBeforeunload: !1
823
- }, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = ze(this.opts.query)), K && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
824
+ }, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = Ge(this.opts.query)), K && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
824
825
  this.transport && (this.transport.removeAllListeners(), this.transport.close());
825
826
  }, addEventListener("beforeunload", this._beforeunloadEventListener, !1)), this.hostname !== "localhost" && (this._offlineEventListener = () => {
826
827
  this._onClose("transport close", {
@@ -837,7 +838,7 @@ class A extends u {
837
838
  */
838
839
  createTransport(e) {
839
840
  const t = Object.assign({}, this.opts.query);
840
- t.EIO = fe, t.transport = e, this.id && (t.sid = this.id);
841
+ t.EIO = le, t.transport = e, this.id && (t.sid = this.id);
841
842
  const s = Object.assign({}, this.opts, {
842
843
  query: t,
843
844
  socket: this,
@@ -859,7 +860,7 @@ class A extends u {
859
860
  }, 0);
860
861
  return;
861
862
  }
862
- const e = this.opts.rememberUpgrade && A.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
863
+ const e = this.opts.rememberUpgrade && T.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
863
864
  this.readyState = "opening";
864
865
  const t = this.createTransport(e);
865
866
  t.open(), this.setTransport(t);
@@ -878,7 +879,7 @@ class A extends u {
878
879
  * @private
879
880
  */
880
881
  onOpen() {
881
- this.readyState = "open", A.priorWebsocketSuccess = this.transport.name === "websocket", this.emitReserved("open"), this.flush();
882
+ this.readyState = "open", T.priorWebsocketSuccess = this.transport.name === "websocket", this.emitReserved("open"), this.flush();
882
883
  }
883
884
  /**
884
885
  * Handles a packet.
@@ -955,7 +956,7 @@ class A extends u {
955
956
  let t = 1;
956
957
  for (let s = 0; s < this.writeBuffer.length; s++) {
957
958
  const i = this.writeBuffer[s].data;
958
- if (i && (t += Ke(i)), s > 0 && t > this._maxPayload)
959
+ if (i && (t += Xe(i)), s > 0 && t > this._maxPayload)
959
960
  return this.writeBuffer.slice(0, s);
960
961
  t += 2;
961
962
  }
@@ -1042,7 +1043,7 @@ class A extends u {
1042
1043
  * @private
1043
1044
  */
1044
1045
  _onError(e) {
1045
- if (A.priorWebsocketSuccess = !1, this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening")
1046
+ if (T.priorWebsocketSuccess = !1, this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening")
1046
1047
  return this.transports.shift(), this._open();
1047
1048
  this.emitReserved("error", e), this._onClose("transport error", e);
1048
1049
  }
@@ -1061,8 +1062,8 @@ class A extends u {
1061
1062
  }
1062
1063
  }
1063
1064
  }
1064
- A.protocol = fe;
1065
- class ht extends A {
1065
+ T.protocol = le;
1066
+ class dt extends T {
1066
1067
  constructor() {
1067
1068
  super(...arguments), this._upgrades = [];
1068
1069
  }
@@ -1079,14 +1080,14 @@ class ht extends A {
1079
1080
  */
1080
1081
  _probe(e) {
1081
1082
  let t = this.createTransport(e), s = !1;
1082
- A.priorWebsocketSuccess = !1;
1083
+ T.priorWebsocketSuccess = !1;
1083
1084
  const i = () => {
1084
- s || (t.send([{ type: "ping", data: "probe" }]), t.once("packet", (g) => {
1085
+ s || (t.send([{ type: "ping", data: "probe" }]), t.once("packet", (w) => {
1085
1086
  if (!s)
1086
- if (g.type === "pong" && g.data === "probe") {
1087
+ if (w.type === "pong" && w.data === "probe") {
1087
1088
  if (this.upgrading = !0, this.emitReserved("upgrading", t), !t)
1088
1089
  return;
1089
- A.priorWebsocketSuccess = t.name === "websocket", this.transport.pause(() => {
1090
+ T.priorWebsocketSuccess = t.name === "websocket", this.transport.pause(() => {
1090
1091
  s || this.readyState !== "closed" && (d(), this.setTransport(t), t.send([{ type: "upgrade" }]), this.emitReserved("upgrade", t), t = null, this.upgrading = !1, this.flush());
1091
1092
  });
1092
1093
  } else {
@@ -1098,23 +1099,23 @@ class ht extends A {
1098
1099
  function r() {
1099
1100
  s || (s = !0, d(), t.close(), t = null);
1100
1101
  }
1101
- const o = (g) => {
1102
- const v = new Error("probe error: " + g);
1102
+ const o = (w) => {
1103
+ const v = new Error("probe error: " + w);
1103
1104
  v.transport = t.name, r(), this.emitReserved("upgradeError", v);
1104
1105
  };
1105
1106
  function a() {
1106
1107
  o("transport closed");
1107
1108
  }
1108
- function h() {
1109
+ function c() {
1109
1110
  o("socket closed");
1110
1111
  }
1111
- function m(g) {
1112
- t && g.name !== t.name && r();
1112
+ function m(w) {
1113
+ t && w.name !== t.name && r();
1113
1114
  }
1114
1115
  const d = () => {
1115
- t.removeListener("open", i), t.removeListener("error", o), t.removeListener("close", a), this.off("close", h), this.off("upgrading", m);
1116
+ t.removeListener("open", i), t.removeListener("error", o), t.removeListener("close", a), this.off("close", c), this.off("upgrading", m);
1116
1117
  };
1117
- t.once("open", i), t.once("error", o), t.once("close", a), this.once("close", h), this.once("upgrading", m), this._upgrades.indexOf("webtransport") !== -1 && e !== "webtransport" ? this.setTimeoutFn(() => {
1118
+ t.once("open", i), t.once("error", o), t.once("close", a), this.once("close", c), this.once("upgrading", m), this._upgrades.indexOf("webtransport") !== -1 && e !== "webtransport" ? this.setTimeoutFn(() => {
1118
1119
  s || t.open();
1119
1120
  }, 200) : t.open();
1120
1121
  }
@@ -1134,21 +1135,21 @@ class ht extends A {
1134
1135
  return t;
1135
1136
  }
1136
1137
  }
1137
- let ft = class extends ht {
1138
+ let yt = class extends dt {
1138
1139
  constructor(e, t = {}) {
1139
1140
  const s = typeof e == "object", i = s ? { ...e } : { ...t };
1140
- (!i.transports || i.transports && typeof i.transports[0] == "string") && (i.transports = (i.transports || ["polling", "websocket", "webtransport"]).map((r) => it[r]).filter((r) => !!r)), super(s ? i : e, i);
1141
+ (!i.transports || i.transports && typeof i.transports[0] == "string") && (i.transports = (i.transports || ["polling", "websocket", "webtransport"]).map((r) => ht[r]).filter((r) => !!r)), super(s ? i : e, i);
1141
1142
  }
1142
1143
  };
1143
- function ut(n, e = "", t) {
1144
+ function mt(n, e = "", t) {
1144
1145
  let s = n;
1145
1146
  t = t || typeof location < "u" && location, n == null && (n = t.protocol + "//" + t.host), typeof n == "string" && (n.charAt(0) === "/" && (n.charAt(1) === "/" ? n = t.protocol + n : n = t.host + n), /^(https?|wss?):\/\//.test(n) || (typeof t < "u" ? n = t.protocol + "//" + n : n = "https://" + n), s = H(n)), s.port || (/^(http|ws)$/.test(s.protocol) ? s.port = "80" : /^(http|ws)s$/.test(s.protocol) && (s.port = "443")), s.path = s.path || "/";
1146
1147
  const r = s.host.indexOf(":") !== -1 ? "[" + s.host + "]" : s.host;
1147
1148
  return s.id = s.protocol + "://" + r + ":" + s.port + e, s.href = s.protocol + "://" + r + (t && t.port === s.port ? "" : ":" + s.port), s;
1148
1149
  }
1149
- const lt = typeof ArrayBuffer == "function", pt = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n.buffer instanceof ArrayBuffer, me = Object.prototype.toString, dt = typeof Blob == "function" || typeof Blob < "u" && me.call(Blob) === "[object BlobConstructor]", yt = typeof File == "function" || typeof File < "u" && me.call(File) === "[object FileConstructor]";
1150
+ const gt = typeof ArrayBuffer == "function", _t = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n.buffer instanceof ArrayBuffer, _e = Object.prototype.toString, wt = typeof Blob == "function" || typeof Blob < "u" && _e.call(Blob) === "[object BlobConstructor]", bt = typeof File == "function" || typeof File < "u" && _e.call(File) === "[object FileConstructor]";
1150
1151
  function Q(n) {
1151
- return lt && (n instanceof ArrayBuffer || pt(n)) || dt && n instanceof Blob || yt && n instanceof File;
1152
+ return gt && (n instanceof ArrayBuffer || _t(n)) || wt && n instanceof Blob || bt && n instanceof File;
1152
1153
  }
1153
1154
  function P(n, e) {
1154
1155
  if (!n || typeof n != "object")
@@ -1168,7 +1169,7 @@ function P(n, e) {
1168
1169
  return !0;
1169
1170
  return !1;
1170
1171
  }
1171
- function mt(n) {
1172
+ function Et(n) {
1172
1173
  const e = [], t = n.data, s = n;
1173
1174
  return s.data = q(t, e), s.attachments = e.length, { packet: s, buffers: e };
1174
1175
  }
@@ -1193,7 +1194,7 @@ function q(n, e, t) {
1193
1194
  }
1194
1195
  return n;
1195
1196
  }
1196
- function gt(n, e) {
1197
+ function vt(n, e) {
1197
1198
  return n.data = W(n.data, e), delete n.attachments, n;
1198
1199
  }
1199
1200
  function W(n, e) {
@@ -1211,7 +1212,7 @@ function W(n, e) {
1211
1212
  Object.prototype.hasOwnProperty.call(n, t) && (n[t] = W(n[t], e));
1212
1213
  return n;
1213
1214
  }
1214
- const _t = [
1215
+ const kt = [
1215
1216
  "connect",
1216
1217
  // used on the client side
1217
1218
  "connect_error",
@@ -1225,11 +1226,11 @@ const _t = [
1225
1226
  "removeListener"
1226
1227
  // used by the Node.js EventEmitter
1227
1228
  ];
1228
- var c;
1229
+ var h;
1229
1230
  (function(n) {
1230
1231
  n[n.CONNECT = 0] = "CONNECT", n[n.DISCONNECT = 1] = "DISCONNECT", n[n.EVENT = 2] = "EVENT", n[n.ACK = 3] = "ACK", n[n.CONNECT_ERROR = 4] = "CONNECT_ERROR", n[n.BINARY_EVENT = 5] = "BINARY_EVENT", n[n.BINARY_ACK = 6] = "BINARY_ACK";
1231
- })(c || (c = {}));
1232
- class wt {
1232
+ })(h || (h = {}));
1233
+ class Tt {
1233
1234
  /**
1234
1235
  * Encoder constructor
1235
1236
  *
@@ -1245,8 +1246,8 @@ class wt {
1245
1246
  * @param {Object} obj - packet object
1246
1247
  */
1247
1248
  encode(e) {
1248
- return (e.type === c.EVENT || e.type === c.ACK) && P(e) ? this.encodeAsBinary({
1249
- type: e.type === c.EVENT ? c.BINARY_EVENT : c.BINARY_ACK,
1249
+ return (e.type === h.EVENT || e.type === h.ACK) && P(e) ? this.encodeAsBinary({
1250
+ type: e.type === h.EVENT ? h.BINARY_EVENT : h.BINARY_ACK,
1250
1251
  nsp: e.nsp,
1251
1252
  data: e.data,
1252
1253
  id: e.id
@@ -1257,7 +1258,7 @@ class wt {
1257
1258
  */
1258
1259
  encodeAsString(e) {
1259
1260
  let t = "" + e.type;
1260
- return (e.type === c.BINARY_EVENT || e.type === c.BINARY_ACK) && (t += e.attachments + "-"), e.nsp && e.nsp !== "/" && (t += e.nsp + ","), e.id != null && (t += e.id), e.data != null && (t += JSON.stringify(e.data, this.replacer)), t;
1261
+ return (e.type === h.BINARY_EVENT || e.type === h.BINARY_ACK) && (t += e.attachments + "-"), e.nsp && e.nsp !== "/" && (t += e.nsp + ","), e.id != null && (t += e.id), e.data != null && (t += JSON.stringify(e.data, this.replacer)), t;
1261
1262
  }
1262
1263
  /**
1263
1264
  * Encode packet as 'buffer sequence' by removing blobs, and
@@ -1265,11 +1266,11 @@ class wt {
1265
1266
  * a list of buffers.
1266
1267
  */
1267
1268
  encodeAsBinary(e) {
1268
- const t = mt(e), s = this.encodeAsString(t.packet), i = t.buffers;
1269
+ const t = Et(e), s = this.encodeAsString(t.packet), i = t.buffers;
1269
1270
  return i.unshift(s), i;
1270
1271
  }
1271
1272
  }
1272
- class j extends u {
1273
+ class j extends l {
1273
1274
  /**
1274
1275
  * Decoder constructor
1275
1276
  */
@@ -1290,8 +1291,8 @@ class j extends u {
1290
1291
  if (this.reconstructor)
1291
1292
  throw new Error("got plaintext data when reconstructing a packet");
1292
1293
  t = this.decodeString(e);
1293
- const s = t.type === c.BINARY_EVENT;
1294
- s || t.type === c.BINARY_ACK ? (t.type = s ? c.EVENT : c.ACK, this.reconstructor = new bt(t)) : super.emitReserved("decoded", t);
1294
+ const s = t.type === h.BINARY_EVENT;
1295
+ s || t.type === h.BINARY_ACK ? (t.type = s ? h.EVENT : h.ACK, this.reconstructor = new At(t)) : super.emitReserved("decoded", t);
1295
1296
  } else if (Q(e) || e.base64)
1296
1297
  if (this.reconstructor)
1297
1298
  t = this.reconstructor.takeBinaryData(e), t && (this.reconstructor = null, super.emitReserved("decoded", t));
@@ -1311,9 +1312,9 @@ class j extends u {
1311
1312
  const s = {
1312
1313
  type: Number(e.charAt(0))
1313
1314
  };
1314
- if (c[s.type] === void 0)
1315
+ if (h[s.type] === void 0)
1315
1316
  throw new Error("unknown packet type " + s.type);
1316
- if (s.type === c.BINARY_EVENT || s.type === c.BINARY_ACK) {
1317
+ if (s.type === h.BINARY_EVENT || s.type === h.BINARY_ACK) {
1317
1318
  const r = t + 1;
1318
1319
  for (; e.charAt(++t) !== "-" && t != e.length; )
1319
1320
  ;
@@ -1321,7 +1322,7 @@ class j extends u {
1321
1322
  if (o != Number(o) || e.charAt(t) !== "-")
1322
1323
  throw new Error("Illegal attachments");
1323
1324
  const a = Number(o);
1324
- if (!Et(a) || a < 1)
1325
+ if (!Rt(a) || a < 1)
1325
1326
  throw new Error("Illegal attachments");
1326
1327
  if (a > this.opts.maxAttachments)
1327
1328
  throw new Error("too many attachments");
@@ -1366,17 +1367,17 @@ class j extends u {
1366
1367
  }
1367
1368
  static isPayloadValid(e, t) {
1368
1369
  switch (e) {
1369
- case c.CONNECT:
1370
- return ie(t);
1371
- case c.DISCONNECT:
1370
+ case h.CONNECT:
1371
+ return oe(t);
1372
+ case h.DISCONNECT:
1372
1373
  return t === void 0;
1373
- case c.CONNECT_ERROR:
1374
- return typeof t == "string" || ie(t);
1375
- case c.EVENT:
1376
- case c.BINARY_EVENT:
1377
- return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && _t.indexOf(t[0]) === -1);
1378
- case c.ACK:
1379
- case c.BINARY_ACK:
1374
+ case h.CONNECT_ERROR:
1375
+ return typeof t == "string" || oe(t);
1376
+ case h.EVENT:
1377
+ case h.BINARY_EVENT:
1378
+ return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && kt.indexOf(t[0]) === -1);
1379
+ case h.ACK:
1380
+ case h.BINARY_ACK:
1380
1381
  return Array.isArray(t);
1381
1382
  }
1382
1383
  }
@@ -1387,7 +1388,7 @@ class j extends u {
1387
1388
  this.reconstructor && (this.reconstructor.finishedReconstruction(), this.reconstructor = null);
1388
1389
  }
1389
1390
  }
1390
- class bt {
1391
+ class At {
1391
1392
  constructor(e) {
1392
1393
  this.packet = e, this.buffers = [], this.reconPack = e;
1393
1394
  }
@@ -1401,7 +1402,7 @@ class bt {
1401
1402
  */
1402
1403
  takeBinaryData(e) {
1403
1404
  if (this.buffers.push(e), this.buffers.length === this.reconPack.attachments) {
1404
- const t = gt(this.reconPack, this.buffers);
1405
+ const t = vt(this.reconPack, this.buffers);
1405
1406
  return this.finishedReconstruction(), t;
1406
1407
  }
1407
1408
  return null;
@@ -1413,26 +1414,26 @@ class bt {
1413
1414
  this.reconPack = null, this.buffers = [];
1414
1415
  }
1415
1416
  }
1416
- const Et = Number.isInteger || function(n) {
1417
+ const Rt = Number.isInteger || function(n) {
1417
1418
  return typeof n == "number" && isFinite(n) && Math.floor(n) === n;
1418
1419
  };
1419
- function ie(n) {
1420
+ function oe(n) {
1420
1421
  return Object.prototype.toString.call(n) === "[object Object]";
1421
1422
  }
1422
- const vt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1423
+ const Ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1423
1424
  __proto__: null,
1424
1425
  Decoder: j,
1425
- Encoder: wt,
1426
+ Encoder: Tt,
1426
1427
  get PacketType() {
1427
- return c;
1428
+ return h;
1428
1429
  }
1429
1430
  }, Symbol.toStringTag, { value: "Module" }));
1430
- function w(n, e, t) {
1431
+ function _(n, e, t) {
1431
1432
  return n.on(e, t), function() {
1432
1433
  n.off(e, t);
1433
1434
  };
1434
1435
  }
1435
- const kt = Object.freeze({
1436
+ const St = Object.freeze({
1436
1437
  connect: 1,
1437
1438
  connect_error: 1,
1438
1439
  disconnect: 1,
@@ -1441,7 +1442,7 @@ const kt = Object.freeze({
1441
1442
  newListener: 1,
1442
1443
  removeListener: 1
1443
1444
  });
1444
- class ge extends u {
1445
+ class we extends l {
1445
1446
  /**
1446
1447
  * `Socket` constructor.
1447
1448
  */
@@ -1475,10 +1476,10 @@ class ge extends u {
1475
1476
  return;
1476
1477
  const e = this.io;
1477
1478
  this.subs = [
1478
- w(e, "open", this.onopen.bind(this)),
1479
- w(e, "packet", this.onpacket.bind(this)),
1480
- w(e, "error", this.onerror.bind(this)),
1481
- w(e, "close", this.onclose.bind(this))
1479
+ _(e, "open", this.onopen.bind(this)),
1480
+ _(e, "packet", this.onpacket.bind(this)),
1481
+ _(e, "error", this.onerror.bind(this)),
1482
+ _(e, "close", this.onclose.bind(this))
1482
1483
  ];
1483
1484
  }
1484
1485
  /**
@@ -1557,20 +1558,20 @@ class ge extends u {
1557
1558
  */
1558
1559
  emit(e, ...t) {
1559
1560
  var s, i, r;
1560
- if (kt.hasOwnProperty(e))
1561
+ if (St.hasOwnProperty(e))
1561
1562
  throw new Error('"' + e.toString() + '" is a reserved event name');
1562
1563
  if (t.unshift(e), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile)
1563
1564
  return this._addToQueue(t), this;
1564
1565
  const o = {
1565
- type: c.EVENT,
1566
+ type: h.EVENT,
1566
1567
  data: t
1567
1568
  };
1568
1569
  if (o.options = {}, o.options.compress = this.flags.compress !== !1, typeof t[t.length - 1] == "function") {
1569
- const d = this.ids++, g = t.pop();
1570
- this._registerAckCallback(d, g), o.id = d;
1570
+ const d = this.ids++, w = t.pop();
1571
+ this._registerAckCallback(d, w), o.id = d;
1571
1572
  }
1572
- const a = (i = (s = this.io.engine) === null || s === void 0 ? void 0 : s.transport) === null || i === void 0 ? void 0 : i.writable, h = this.connected && !(!((r = this.io.engine) === null || r === void 0) && r._hasPingExpired());
1573
- return this.flags.volatile && !a || (h ? (this.notifyOutgoingListeners(o), this.packet(o)) : this.sendBuffer.push(o)), this.flags = {}, this;
1573
+ const a = (i = (s = this.io.engine) === null || s === void 0 ? void 0 : s.transport) === null || i === void 0 ? void 0 : i.writable, c = this.connected && !(!((r = this.io.engine) === null || r === void 0) && r._hasPingExpired());
1574
+ return this.flags.volatile && !a || (c ? (this.notifyOutgoingListeners(o), this.packet(o)) : this.sendBuffer.push(o)), this.flags = {}, this;
1574
1575
  }
1575
1576
  /**
1576
1577
  * @private
@@ -1670,7 +1671,7 @@ class ge extends u {
1670
1671
  */
1671
1672
  _sendConnectPacket(e) {
1672
1673
  this.packet({
1673
- type: c.CONNECT,
1674
+ type: h.CONNECT,
1674
1675
  data: this._pid ? Object.assign({ pid: this._pid, offset: this._lastOffset }, e) : e
1675
1676
  });
1676
1677
  }
@@ -1716,21 +1717,21 @@ class ge extends u {
1716
1717
  onpacket(e) {
1717
1718
  if (e.nsp === this.nsp)
1718
1719
  switch (e.type) {
1719
- case c.CONNECT:
1720
+ case h.CONNECT:
1720
1721
  e.data && e.data.sid ? this.onconnect(e.data.sid, e.data.pid) : this.emitReserved("connect_error", new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));
1721
1722
  break;
1722
- case c.EVENT:
1723
- case c.BINARY_EVENT:
1723
+ case h.EVENT:
1724
+ case h.BINARY_EVENT:
1724
1725
  this.onevent(e);
1725
1726
  break;
1726
- case c.ACK:
1727
- case c.BINARY_ACK:
1727
+ case h.ACK:
1728
+ case h.BINARY_ACK:
1728
1729
  this.onack(e);
1729
1730
  break;
1730
- case c.DISCONNECT:
1731
+ case h.DISCONNECT:
1731
1732
  this.ondisconnect();
1732
1733
  break;
1733
- case c.CONNECT_ERROR:
1734
+ case h.CONNECT_ERROR:
1734
1735
  this.destroy();
1735
1736
  const s = new Error(e.data.message);
1736
1737
  s.data = e.data.data, this.emitReserved("connect_error", s);
@@ -1765,7 +1766,7 @@ class ge extends u {
1765
1766
  let s = !1;
1766
1767
  return function(...i) {
1767
1768
  s || (s = !0, t.packet({
1768
- type: c.ACK,
1769
+ type: h.ACK,
1769
1770
  id: e,
1770
1771
  data: i
1771
1772
  }));
@@ -1834,7 +1835,7 @@ class ge extends u {
1834
1835
  * @return self
1835
1836
  */
1836
1837
  disconnect() {
1837
- return this.connected && this.packet({ type: c.DISCONNECT }), this.destroy(), this.connected && this.onclose("io client disconnect"), this;
1838
+ return this.connected && this.packet({ type: h.DISCONNECT }), this.destroy(), this.connected && this.onclose("io client disconnect"), this;
1838
1839
  }
1839
1840
  /**
1840
1841
  * Alias for {@link disconnect()}.
@@ -2056,7 +2057,7 @@ R.prototype.setMax = function(n) {
2056
2057
  R.prototype.setJitter = function(n) {
2057
2058
  this.jitter = n;
2058
2059
  };
2059
- class Y extends u {
2060
+ class Y extends l {
2060
2061
  constructor(e, t) {
2061
2062
  var s;
2062
2063
  super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (t = e, e = void 0), t = t || {}, t.path = t.path || "/socket.io", this.opts = t, F(this, t), this.reconnection(t.reconnection !== !1), this.reconnectionAttempts(t.reconnectionAttempts || 1 / 0), this.reconnectionDelay(t.reconnectionDelay || 1e3), this.reconnectionDelayMax(t.reconnectionDelayMax || 5e3), this.randomizationFactor((s = t.randomizationFactor) !== null && s !== void 0 ? s : 0.5), this.backoff = new R({
@@ -2064,7 +2065,7 @@ class Y extends u {
2064
2065
  max: this.reconnectionDelayMax(),
2065
2066
  jitter: this.randomizationFactor()
2066
2067
  }), this.timeout(t.timeout == null ? 2e4 : t.timeout), this._readyState = "closed", this.uri = e;
2067
- const i = t.parser || vt;
2068
+ const i = t.parser || Ot;
2068
2069
  this.encoder = new i.Encoder(), this.decoder = new i.Decoder(), this._autoConnect = t.autoConnect !== !1, this._autoConnect && this.open();
2069
2070
  }
2070
2071
  reconnection(e) {
@@ -2107,20 +2108,20 @@ class Y extends u {
2107
2108
  open(e) {
2108
2109
  if (~this._readyState.indexOf("open"))
2109
2110
  return this;
2110
- this.engine = new ft(this.uri, this.opts);
2111
+ this.engine = new yt(this.uri, this.opts);
2111
2112
  const t = this.engine, s = this;
2112
2113
  this._readyState = "opening", this.skipReconnect = !1;
2113
- const i = w(t, "open", function() {
2114
+ const i = _(t, "open", function() {
2114
2115
  s.onopen(), e && e();
2115
2116
  }), r = (a) => {
2116
2117
  this.cleanup(), this._readyState = "closed", this.emitReserved("error", a), e ? e(a) : this.maybeReconnectOnOpen();
2117
- }, o = w(t, "error", r);
2118
+ }, o = _(t, "error", r);
2118
2119
  if (this._timeout !== !1) {
2119
- const a = this._timeout, h = this.setTimeoutFn(() => {
2120
+ const a = this._timeout, c = this.setTimeoutFn(() => {
2120
2121
  i(), r(new Error("timeout")), t.close();
2121
2122
  }, a);
2122
- this.opts.autoUnref && h.unref(), this.subs.push(() => {
2123
- this.clearTimeoutFn(h);
2123
+ this.opts.autoUnref && c.unref(), this.subs.push(() => {
2124
+ this.clearTimeoutFn(c);
2124
2125
  });
2125
2126
  }
2126
2127
  return this.subs.push(i), this.subs.push(o), this;
@@ -2143,12 +2144,12 @@ class Y extends u {
2143
2144
  this.cleanup(), this._readyState = "open", this.emitReserved("open");
2144
2145
  const e = this.engine;
2145
2146
  this.subs.push(
2146
- w(e, "ping", this.onping.bind(this)),
2147
- w(e, "data", this.ondata.bind(this)),
2148
- w(e, "error", this.onerror.bind(this)),
2149
- w(e, "close", this.onclose.bind(this)),
2147
+ _(e, "ping", this.onping.bind(this)),
2148
+ _(e, "data", this.ondata.bind(this)),
2149
+ _(e, "error", this.onerror.bind(this)),
2150
+ _(e, "close", this.onclose.bind(this)),
2150
2151
  // @ts-ignore
2151
- w(this.decoder, "decoded", this.ondecoded.bind(this))
2152
+ _(this.decoder, "decoded", this.ondecoded.bind(this))
2152
2153
  );
2153
2154
  }
2154
2155
  /**
@@ -2197,7 +2198,7 @@ class Y extends u {
2197
2198
  */
2198
2199
  socket(e, t) {
2199
2200
  let s = this.nsps[e];
2200
- return s ? this._autoConnect && !s.active && s.connect() : (s = new ge(this, e, t), this.nsps[e] = s), s;
2201
+ return s ? this._autoConnect && !s.active && s.connect() : (s = new we(this, e, t), this.nsps[e] = s), s;
2201
2202
  }
2202
2203
  /**
2203
2204
  * Called upon a socket close.
@@ -2297,161 +2298,170 @@ class Y extends u {
2297
2298
  const S = {};
2298
2299
  function I(n, e) {
2299
2300
  typeof n == "object" && (e = n, n = void 0), e = e || {};
2300
- const t = ut(n, e.path || "/socket.io"), s = t.source, i = t.id, r = t.path, o = S[i] && r in S[i].nsps, a = e.forceNew || e["force new connection"] || e.multiplex === !1 || o;
2301
- let h;
2302
- return a ? h = new Y(s, e) : (S[i] || (S[i] = new Y(s, e)), h = S[i]), t.query && !e.query && (e.query = t.queryKey), h.socket(t.path, e);
2301
+ const t = mt(n, e.path || "/socket.io"), s = t.source, i = t.id, r = t.path, o = S[i] && r in S[i].nsps, a = e.forceNew || e["force new connection"] || e.multiplex === !1 || o;
2302
+ let c;
2303
+ return a ? c = new Y(s, e) : (S[i] || (S[i] = new Y(s, e)), c = S[i]), t.query && !e.query && (e.query = t.queryKey), c.socket(t.path, e);
2303
2304
  }
2304
2305
  Object.assign(I, {
2305
2306
  Manager: Y,
2306
- Socket: ge,
2307
+ Socket: we,
2307
2308
  io: I,
2308
2309
  connect: I
2309
2310
  });
2310
- const _e = Oe(void 0), St = ({
2311
+ const be = Ce(void 0), Pt = ({
2311
2312
  apiUrl: n,
2312
- children: e
2313
+ adminApiUrl: e,
2314
+ children: t
2313
2315
  }) => {
2314
- const { user: t } = Be(), [s, i] = O([]), [r, o] = O(0), [a, h] = O(null), [m, d] = O(!1), [g, v] = O(null), T = () => {
2315
- const f = localStorage.getItem("authToken");
2316
+ const { user: s } = qe(), i = Be(
2317
+ () => e ? Le({ url: Pe(e) }) : null,
2318
+ [e]
2319
+ ), [r, o] = O([]), [a, c] = O(0), [m, d] = O(null), [w, v] = O(!1), [G, Z] = O(null), A = async () => {
2320
+ const u = await (i == null ? void 0 : i.get()) ?? localStorage.getItem("authToken");
2316
2321
  return {
2317
2322
  "Content-Type": "application/json",
2318
- ...f ? { Authorization: `Bearer ${f}` } : {}
2323
+ ...u ? { Authorization: `Bearer ${u}` } : {}
2319
2324
  };
2320
- }, G = async (f = "inbox", l = 1, p = 10) => {
2321
- if (t) {
2322
- d(!0);
2325
+ }, ee = async (f = "inbox", u = 1, p = 10) => {
2326
+ if (s) {
2327
+ v(!0);
2323
2328
  try {
2324
- const _ = await fetch(
2325
- `${n}/notifications?recipientId=${t.id}&page=${l}&limit=${p}&folder=${f}`,
2326
- { headers: T() }
2329
+ const g = await fetch(
2330
+ `${n}/notifications?recipientId=${s.id}&page=${u}&limit=${p}&folder=${f}`,
2331
+ { headers: await A() }
2327
2332
  );
2328
- if (_.ok) {
2329
- const k = await _.json();
2330
- if (i(k), f === "inbox") {
2331
- const Ae = k.filter((Te) => !Te.isRead).length;
2332
- o(Ae);
2333
+ if (g.ok) {
2334
+ const k = await g.json();
2335
+ if (o(k), f === "inbox") {
2336
+ const Re = k.filter((Oe) => !Oe.isRead).length;
2337
+ c(Re);
2333
2338
  }
2334
2339
  }
2335
- } catch (_) {
2336
- console.error("Failed to fetch notifications:", _);
2340
+ } catch (g) {
2341
+ console.error("Failed to fetch notifications:", g);
2337
2342
  } finally {
2338
- d(!1);
2343
+ v(!1);
2339
2344
  }
2340
2345
  }
2341
- }, we = async (f) => {
2346
+ }, Ee = async (f) => {
2342
2347
  try {
2343
2348
  (await fetch(`${n}/notifications/${f}/read`, {
2344
2349
  method: "PATCH",
2345
- headers: T()
2346
- })).ok && (i(
2347
- (p) => p.map((_) => _.id === f ? { ..._, isRead: !0 } : _)
2348
- ), o((p) => Math.max(0, p - 1)));
2349
- } catch (l) {
2350
- console.error("Failed to mark notification as read:", l);
2350
+ headers: await A()
2351
+ })).ok && (o(
2352
+ (p) => p.map((g) => g.id === f ? { ...g, isRead: !0 } : g)
2353
+ ), c((p) => Math.max(0, p - 1)));
2354
+ } catch (u) {
2355
+ console.error("Failed to mark notification as read:", u);
2351
2356
  }
2352
- }, be = async () => {
2353
- if (t)
2357
+ }, ve = async () => {
2358
+ if (s)
2354
2359
  try {
2355
- (await fetch(`${n}/notifications/read-all?recipientId=${t.id}`, {
2360
+ (await fetch(`${n}/notifications/read-all?recipientId=${s.id}`, {
2356
2361
  method: "PATCH",
2357
- headers: T()
2358
- })).ok && (i((l) => l.map((p) => ({ ...p, isRead: !0 }))), o(0));
2362
+ headers: await A()
2363
+ })).ok && (o((u) => u.map((p) => ({ ...p, isRead: !0 }))), c(0));
2359
2364
  } catch (f) {
2360
2365
  console.error("Failed to mark all notifications as read:", f);
2361
2366
  }
2362
- }, Ee = async () => {
2363
- if (t)
2367
+ }, ke = async () => {
2368
+ if (s)
2364
2369
  try {
2365
- (await fetch(`${n}/notifications/trash?recipientId=${t.id}`, {
2370
+ (await fetch(`${n}/notifications/trash?recipientId=${s.id}`, {
2366
2371
  method: "DELETE",
2367
- headers: T()
2368
- })).ok && i([]);
2372
+ headers: await A()
2373
+ })).ok && o([]);
2369
2374
  } catch (f) {
2370
2375
  console.error("Failed to empty trash:", f);
2371
2376
  }
2372
- }, ve = async (f) => {
2377
+ }, Te = async (f) => {
2373
2378
  try {
2374
2379
  (await fetch(`${n}/notifications/${f}`, {
2375
2380
  method: "DELETE",
2376
- headers: T()
2377
- })).ok && i((p) => {
2378
- const _ = p.find((k) => k.id === f);
2379
- return _ && !_.isRead && o((k) => Math.max(0, k - 1)), p.filter((k) => k.id !== f);
2381
+ headers: await A()
2382
+ })).ok && o((p) => {
2383
+ const g = p.find((k) => k.id === f);
2384
+ return g && !g.isRead && c((k) => Math.max(0, k - 1)), p.filter((k) => k.id !== f);
2380
2385
  });
2381
- } catch (l) {
2382
- console.error("Failed to delete notification:", l);
2386
+ } catch (u) {
2387
+ console.error("Failed to delete notification:", u);
2383
2388
  }
2384
- }, Z = async () => {
2385
- if (t)
2389
+ }, te = async () => {
2390
+ if (s)
2386
2391
  try {
2387
- const f = await fetch(`${n}/notifications/preferences?recipientId=${t.id}`, {
2388
- headers: T()
2392
+ const f = await fetch(`${n}/notifications/preferences?recipientId=${s.id}`, {
2393
+ headers: await A()
2389
2394
  });
2390
2395
  if (f.ok) {
2391
- const l = await f.json();
2392
- h(l);
2396
+ const u = await f.json();
2397
+ d(u);
2393
2398
  }
2394
2399
  } catch (f) {
2395
2400
  console.error("Failed to fetch preferences:", f);
2396
2401
  }
2397
- }, ke = async (f) => {
2398
- if (t)
2402
+ }, Ae = async (f) => {
2403
+ if (s)
2399
2404
  try {
2400
- const l = await fetch(`${n}/notifications/preferences?recipientId=${t.id}`, {
2405
+ const u = await fetch(`${n}/notifications/preferences?recipientId=${s.id}`, {
2401
2406
  method: "PATCH",
2402
- headers: T(),
2407
+ headers: await A(),
2403
2408
  body: JSON.stringify(f)
2404
2409
  });
2405
- if (l.ok) {
2406
- const p = await l.json();
2407
- h(p);
2410
+ if (u.ok) {
2411
+ const p = await u.json();
2412
+ d(p);
2408
2413
  }
2409
- } catch (l) {
2410
- console.error("Failed to update preferences:", l);
2414
+ } catch (u) {
2415
+ console.error("Failed to update preferences:", u);
2411
2416
  }
2412
2417
  };
2413
- return Se(() => {
2414
- if (!t) {
2415
- g && (g.disconnect(), v(null)), i([]), o(0), h(null);
2418
+ return xe(() => {
2419
+ if (!s) {
2420
+ i == null || i.clear(), G && (G.disconnect(), Z(null)), o([]), c(0), d(null);
2416
2421
  return;
2417
2422
  }
2418
2423
  const f = I(n, {
2419
- query: { userId: t.id },
2424
+ auth: (u) => {
2425
+ ((i == null ? void 0 : i.get()) ?? Promise.resolve(null)).then(
2426
+ (p) => u(p ? { token: p } : {})
2427
+ );
2428
+ },
2429
+ query: { userId: s.id },
2420
2430
  transports: ["websocket"]
2421
2431
  });
2422
2432
  return f.on("connect", () => {
2423
2433
  console.log("WebSocket connected to notifications microservice");
2424
- }), f.on("notification", (l) => {
2425
- i((p) => [l, ...p]), o((p) => p + 1);
2426
- }), v(f), G("inbox"), Z(), () => {
2434
+ }), f.on("notification", (u) => {
2435
+ o((p) => [u, ...p]), c((p) => p + 1);
2436
+ }), Z(f), ee("inbox"), te(), () => {
2427
2437
  f.disconnect();
2428
2438
  };
2429
- }, [t, n]), /* @__PURE__ */ Re(
2430
- _e.Provider,
2439
+ }, [s, n, i]), /* @__PURE__ */ Se(
2440
+ be.Provider,
2431
2441
  {
2432
2442
  value: {
2433
- notifications: s,
2434
- unreadCount: r,
2435
- preferences: a,
2436
- isLoading: m,
2437
- fetchNotifications: G,
2438
- markAsRead: we,
2439
- markAllAsRead: be,
2440
- emptyTrash: Ee,
2441
- deleteNotification: ve,
2442
- fetchPreferences: Z,
2443
- updatePreferences: ke
2443
+ notifications: r,
2444
+ unreadCount: a,
2445
+ preferences: m,
2446
+ isLoading: w,
2447
+ fetchNotifications: ee,
2448
+ markAsRead: Ee,
2449
+ markAllAsRead: ve,
2450
+ emptyTrash: ke,
2451
+ deleteNotification: Te,
2452
+ fetchPreferences: te,
2453
+ updatePreferences: Ae
2444
2454
  },
2445
- children: e
2455
+ children: t
2446
2456
  }
2447
2457
  );
2448
- }, Ct = () => {
2449
- const n = Ce(_e);
2458
+ }, qt = () => {
2459
+ const n = Ne(be);
2450
2460
  if (n === void 0)
2451
2461
  throw new Error("useNotifications must be used within a NotificationProvider");
2452
2462
  return n;
2453
2463
  };
2454
2464
  export {
2455
- St as NotificationProvider,
2456
- Ct as useNotifications
2465
+ Pt as NotificationProvider,
2466
+ qt as useNotifications
2457
2467
  };