@danidoble/webserial 4.4.0-beta.3 → 4.4.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/boardroid.cjs +1 -1
  2. package/dist/boardroid.js +1 -1
  3. package/dist/hopper.cjs +2 -2
  4. package/dist/hopper.js +8 -8
  5. package/dist/jofemar.cjs +1 -1
  6. package/dist/jofemar.js +1 -1
  7. package/dist/{kernel-C1HLYiV1.cjs → kernel-9JeWIxgz.cjs} +1 -1
  8. package/dist/{kernel-DtXV8d8B.js → kernel-BnWXOCde.js} +1 -1
  9. package/dist/kernel.cjs +1 -1
  10. package/dist/kernel.js +1 -1
  11. package/dist/locker.cjs +1 -1
  12. package/dist/locker.js +1 -1
  13. package/dist/pinpad.cjs +7 -7
  14. package/dist/pinpad.js +33 -32
  15. package/dist/pinpax.cjs +1 -1
  16. package/dist/pinpax.js +1 -1
  17. package/dist/relay.cjs +1 -1
  18. package/dist/relay.js +1 -1
  19. package/dist/types/kernel.d.ts.map +1 -0
  20. package/dist/types/main.d.ts.map +1 -0
  21. package/dist/{serial → types/serial}/boardroid.d.ts +1 -1
  22. package/dist/types/serial/boardroid.d.ts.map +1 -0
  23. package/dist/types/serial/hopper.d.ts.map +1 -0
  24. package/dist/{serial → types/serial}/jofemar.d.ts +1 -1
  25. package/dist/types/serial/jofemar.d.ts.map +1 -0
  26. package/dist/types/serial/kernel.d.ts.map +1 -0
  27. package/dist/{serial → types/serial}/locker.d.ts +1 -1
  28. package/dist/types/serial/locker.d.ts.map +1 -0
  29. package/dist/types/serial/pinpad.d.ts.map +1 -0
  30. package/dist/types/serial/pinpax.d.ts.map +1 -0
  31. package/dist/types/serial/relay.d.ts.map +1 -0
  32. package/dist/types/utils/devices.d.ts.map +1 -0
  33. package/dist/types/utils/dispatcher.d.ts.map +1 -0
  34. package/dist/types/utils/emulator.d.ts.map +1 -0
  35. package/dist/types/utils/utils.d.ts.map +1 -0
  36. package/dist/{webserial-core-CH2Xov2y.js → webserial-core-52yJu-0N.js} +827 -827
  37. package/dist/webserial-core-BgEbN4Gb.cjs +4 -0
  38. package/dist/webserial.cjs +2 -2
  39. package/dist/webserial.js +5 -5
  40. package/package.json +88 -79
  41. package/dist/kernel-C8ISUhzV.cjs +0 -1
  42. package/dist/kernel-CQcZ_OiG.js +0 -831
  43. package/dist/kernel-DkC7Kj3m.js +0 -841
  44. package/dist/kernel-DyNuXvtW.cjs +0 -1
  45. package/dist/kernel-aqBCxtkj.js +0 -831
  46. package/dist/kernel-pO_elWba.cjs +0 -1
  47. package/dist/kernel.d.ts.map +0 -1
  48. package/dist/main.d.ts.map +0 -1
  49. package/dist/serial/boardroid.d.ts.map +0 -1
  50. package/dist/serial/hopper.d.ts.map +0 -1
  51. package/dist/serial/jofemar.d.ts.map +0 -1
  52. package/dist/serial/kernel.d.ts.map +0 -1
  53. package/dist/serial/locker.d.ts.map +0 -1
  54. package/dist/serial/pinpad.d.ts.map +0 -1
  55. package/dist/serial/pinpax.d.ts.map +0 -1
  56. package/dist/serial/relay.d.ts.map +0 -1
  57. package/dist/utils/devices.d.ts.map +0 -1
  58. package/dist/utils/dispatcher.d.ts.map +0 -1
  59. package/dist/utils/emulator.d.ts.map +0 -1
  60. package/dist/utils/utils.d.ts.map +0 -1
  61. package/dist/webserial-core-Cj_EZjAU.cjs +0 -4
  62. package/dist/webserial-core-D3luFguv.js +0 -3325
  63. package/dist/webserial-core-YjdXyVOx.cjs +0 -4
  64. /package/dist/{kernel.d.ts → types/kernel.d.ts} +0 -0
  65. /package/dist/{main.d.ts → types/main.d.ts} +0 -0
  66. /package/dist/{serial → types/serial}/hopper.d.ts +0 -0
  67. /package/dist/{serial → types/serial}/kernel.d.ts +0 -0
  68. /package/dist/{serial → types/serial}/pinpad.d.ts +0 -0
  69. /package/dist/{serial → types/serial}/pinpax.d.ts +0 -0
  70. /package/dist/{serial → types/serial}/relay.d.ts +0 -0
  71. /package/dist/{utils → types/utils}/devices.d.ts +0 -0
  72. /package/dist/{utils → types/utils}/dispatcher.d.ts +0 -0
  73. /package/dist/{utils → types/utils}/emulator.d.ts +0 -0
  74. /package/dist/{utils → types/utils}/utils.d.ts +0 -0
@@ -1,126 +1,3 @@
1
- class Y extends CustomEvent {
2
- constructor(e, t) {
3
- super(e, t);
4
- }
5
- }
6
- class te extends EventTarget {
7
- __listeners__ = {
8
- debug: !1
9
- };
10
- __debug__ = !1;
11
- __listenersCallbacks__ = [];
12
- dispatch(e, t = null) {
13
- const n = new Y(e, { detail: t });
14
- this.dispatchEvent(n), this.__debug__ && this.dispatchEvent(new Y("debug", { detail: { type: e, data: t } }));
15
- }
16
- dispatchAsync(e, t = null, n = 100) {
17
- const r = this;
18
- setTimeout(() => {
19
- r.dispatch(e, t);
20
- }, n);
21
- }
22
- on(e, t) {
23
- typeof this.__listeners__[e] < "u" && !this.__listeners__[e] && (this.__listeners__[e] = !0), this.__listenersCallbacks__.push({ key: e, callback: t }), this.addEventListener(e, t);
24
- }
25
- off(e, t) {
26
- this.__listenersCallbacks__ = this.__listenersCallbacks__.filter((n) => !(n.key === e && n.callback === t)), this.removeEventListener(e, t);
27
- }
28
- serialRegisterAvailableListener(e) {
29
- this.__listeners__[e] || (this.__listeners__[e] = !1);
30
- }
31
- get availableListeners() {
32
- return Object.keys(this.__listeners__).sort().map((e) => ({
33
- type: e,
34
- listening: this.__listeners__[e]
35
- }));
36
- }
37
- removeAllListeners() {
38
- for (const e of this.__listenersCallbacks__)
39
- ["internal:queue"].includes(e.key) || (this.__listenersCallbacks__ = this.__listenersCallbacks__.filter((t) => !(t.key === e.key && t.callback === e.callback)), this.removeEventListener(e.key, e.callback));
40
- for (const e of Object.keys(this.__listeners__))
41
- this.__listeners__[e] = !1;
42
- }
43
- }
44
- class a extends te {
45
- static instance;
46
- static devices = {};
47
- constructor() {
48
- super(), ["change"].forEach((e) => {
49
- this.serialRegisterAvailableListener(e);
50
- });
51
- }
52
- static $dispatchChange(e = null) {
53
- e && e.$checkAndDispatchConnection(), a.instance.dispatch("change", { devices: a.devices, dispatcher: e });
54
- }
55
- static typeError(e) {
56
- const t = new Error();
57
- throw t.message = `Type ${e} is not supported`, t.name = "DeviceTypeError", t;
58
- }
59
- static registerType(e) {
60
- typeof a.devices[e] > "u" && (a.devices = { ...a.devices, [e]: {} });
61
- }
62
- static add(e) {
63
- const t = e.typeDevice;
64
- typeof a.devices[t] > "u" && a.registerType(t);
65
- const n = e.uuid;
66
- if (typeof a.devices[t] > "u" && a.typeError(t), a.devices[t][n])
67
- throw new Error(`Device with id ${n} already exists`);
68
- return a.devices[t][n] = e, a.$dispatchChange(e), Object.keys(a.devices[t]).indexOf(n);
69
- }
70
- static get(e, t) {
71
- return typeof a.devices[e] > "u" && a.registerType(e), typeof a.devices[e] > "u" && a.typeError(e), a.devices[e][t];
72
- }
73
- static getAll(e = null) {
74
- return e === null ? a.devices : (typeof a.devices[e] > "u" && a.typeError(e), a.devices[e]);
75
- }
76
- static getList() {
77
- return Object.values(a.devices).map((e) => Object.values(e)).flat();
78
- }
79
- static getByNumber(e, t) {
80
- return typeof a.devices[e] > "u" && a.typeError(e), Object.values(a.devices[e]).find((n) => n.deviceNumber === t) ?? null;
81
- }
82
- static getCustom(e, t = 1) {
83
- return typeof a.devices[e] > "u" && a.typeError(e), Object.values(a.devices[e]).find((n) => n.deviceNumber === t) ?? null;
84
- }
85
- static async connectToAll() {
86
- const e = a.getList();
87
- for (const t of e)
88
- t.isConnected || await t.connect().catch(console.warn);
89
- return Promise.resolve(a.areAllConnected());
90
- }
91
- static async disconnectAll() {
92
- const e = a.getList();
93
- for (const t of e)
94
- t.isDisconnected || await t.disconnect().catch(console.warn);
95
- return Promise.resolve(a.areAllDisconnected());
96
- }
97
- static async areAllConnected() {
98
- const e = a.getList();
99
- for (const t of e)
100
- if (!t.isConnected) return Promise.resolve(!1);
101
- return Promise.resolve(!0);
102
- }
103
- static async areAllDisconnected() {
104
- const e = a.getList();
105
- for (const t of e)
106
- if (!t.isDisconnected) return Promise.resolve(!1);
107
- return Promise.resolve(!0);
108
- }
109
- static async getAllConnected() {
110
- const e = a.getList();
111
- return Promise.resolve(e.filter((t) => t.isConnected));
112
- }
113
- static async getAllDisconnected() {
114
- const e = a.getList();
115
- return Promise.resolve(e.filter((t) => t.isDisconnected));
116
- }
117
- }
118
- a.instance || (a.instance = new a());
119
- function J(s = 100) {
120
- return new Promise(
121
- (e) => setTimeout(() => e(), s)
122
- );
123
- }
124
1
  const m = /* @__PURE__ */ Object.create(null);
125
2
  m.open = "0";
126
3
  m.close = "1";
@@ -129,253 +6,253 @@ m.pong = "3";
129
6
  m.message = "4";
130
7
  m.upgrade = "5";
131
8
  m.noop = "6";
132
- const x = /* @__PURE__ */ Object.create(null);
133
- Object.keys(m).forEach((s) => {
134
- x[m[s]] = s;
9
+ const S = /* @__PURE__ */ Object.create(null);
10
+ Object.keys(m).forEach((n) => {
11
+ S[m[n]] = n;
135
12
  });
136
- const D = { type: "error", data: "parser error" }, se = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", ne = typeof ArrayBuffer == "function", re = (s) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(s) : s && s.buffer instanceof ArrayBuffer, V = ({ type: s, data: e }, t, n) => se && e instanceof Blob ? t ? n(e) : Q(e, n) : ne && (e instanceof ArrayBuffer || re(e)) ? t ? n(e) : Q(new Blob([e]), n) : n(m[s] + (e || "")), Q = (s, e) => {
13
+ const D = { type: "error", data: "parser error" }, te = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", se = typeof ArrayBuffer == "function", ne = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n && n.buffer instanceof ArrayBuffer, H = ({ type: n, data: e }, t, s) => te && e instanceof Blob ? t ? s(e) : J(e, s) : se && (e instanceof ArrayBuffer || ne(e)) ? t ? s(e) : J(new Blob([e]), s) : s(m[n] + (e || "")), J = (n, e) => {
137
14
  const t = new FileReader();
138
15
  return t.onload = function() {
139
- const n = t.result.split(",")[1];
140
- e("b" + (n || ""));
141
- }, t.readAsDataURL(s);
16
+ const s = t.result.split(",")[1];
17
+ e("b" + (s || ""));
18
+ }, t.readAsDataURL(n);
142
19
  };
143
- function X(s) {
144
- return s instanceof Uint8Array ? s : s instanceof ArrayBuffer ? new Uint8Array(s) : new Uint8Array(s.buffer, s.byteOffset, s.byteLength);
20
+ function Q(n) {
21
+ return n instanceof Uint8Array ? n : n instanceof ArrayBuffer ? new Uint8Array(n) : new Uint8Array(n.buffer, n.byteOffset, n.byteLength);
145
22
  }
146
23
  let P;
147
- function fe(s, e) {
148
- if (se && s.data instanceof Blob)
149
- return s.data.arrayBuffer().then(X).then(e);
150
- if (ne && (s.data instanceof ArrayBuffer || re(s.data)))
151
- return e(X(s.data));
152
- V(s, !1, (t) => {
24
+ function de(n, e) {
25
+ if (te && n.data instanceof Blob)
26
+ return n.data.arrayBuffer().then(Q).then(e);
27
+ if (se && (n.data instanceof ArrayBuffer || ne(n.data)))
28
+ return e(Q(n.data));
29
+ H(n, !1, (t) => {
153
30
  P || (P = new TextEncoder()), e(P.encode(t));
154
31
  });
155
32
  }
156
- const G = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", E = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
157
- for (let s = 0; s < G.length; s++)
158
- E[G.charCodeAt(s)] = s;
159
- const ye = (s) => {
160
- let e = s.length * 0.75, t = s.length, n, r = 0, i, o, h, c;
161
- s[s.length - 1] === "=" && (e--, s[s.length - 2] === "=" && e--);
162
- const p = new ArrayBuffer(e), u = new Uint8Array(p);
163
- for (n = 0; n < t; n += 4)
164
- i = E[s.charCodeAt(n)], o = E[s.charCodeAt(n + 1)], h = E[s.charCodeAt(n + 2)], c = E[s.charCodeAt(n + 3)], u[r++] = i << 2 | o >> 4, u[r++] = (o & 15) << 4 | h >> 2, u[r++] = (h & 3) << 6 | c & 63;
165
- return p;
166
- }, ge = typeof ArrayBuffer == "function", H = (s, e) => {
167
- if (typeof s != "string")
33
+ const X = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", k = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
34
+ for (let n = 0; n < X.length; n++)
35
+ k[X.charCodeAt(n)] = n;
36
+ const ye = (n) => {
37
+ let e = n.length * 0.75, t = n.length, s, i = 0, r, o, l, c;
38
+ n[n.length - 1] === "=" && (e--, n[n.length - 2] === "=" && e--);
39
+ const f = new ArrayBuffer(e), u = new Uint8Array(f);
40
+ for (s = 0; s < t; s += 4)
41
+ r = k[n.charCodeAt(s)], o = k[n.charCodeAt(s + 1)], l = k[n.charCodeAt(s + 2)], c = k[n.charCodeAt(s + 3)], u[i++] = r << 2 | o >> 4, u[i++] = (o & 15) << 4 | l >> 2, u[i++] = (l & 3) << 6 | c & 63;
42
+ return f;
43
+ }, ge = typeof ArrayBuffer == "function", W = (n, e) => {
44
+ if (typeof n != "string")
168
45
  return {
169
46
  type: "message",
170
- data: ie(s, e)
47
+ data: ie(n, e)
171
48
  };
172
- const t = s.charAt(0);
49
+ const t = n.charAt(0);
173
50
  return t === "b" ? {
174
51
  type: "message",
175
- data: me(s.substring(1), e)
176
- } : x[t] ? s.length > 1 ? {
177
- type: x[t],
178
- data: s.substring(1)
52
+ data: me(n.substring(1), e)
53
+ } : S[t] ? n.length > 1 ? {
54
+ type: S[t],
55
+ data: n.substring(1)
179
56
  } : {
180
- type: x[t]
57
+ type: S[t]
181
58
  } : D;
182
- }, me = (s, e) => {
59
+ }, me = (n, e) => {
183
60
  if (ge) {
184
- const t = ye(s);
61
+ const t = ye(n);
185
62
  return ie(t, e);
186
63
  } else
187
- return { base64: !0, data: s };
188
- }, ie = (s, e) => {
64
+ return { base64: !0, data: n };
65
+ }, ie = (n, e) => {
189
66
  switch (e) {
190
67
  case "blob":
191
- return s instanceof Blob ? s : new Blob([s]);
68
+ return n instanceof Blob ? n : new Blob([n]);
192
69
  case "arraybuffer":
193
70
  default:
194
- return s instanceof ArrayBuffer ? s : s.buffer;
195
- }
196
- }, oe = "", be = (s, e) => {
197
- const t = s.length, n = new Array(t);
198
- let r = 0;
199
- s.forEach((i, o) => {
200
- V(i, !1, (h) => {
201
- n[o] = h, ++r === t && e(n.join(oe));
71
+ return n instanceof ArrayBuffer ? n : n.buffer;
72
+ }
73
+ }, re = "", be = (n, e) => {
74
+ const t = n.length, s = new Array(t);
75
+ let i = 0;
76
+ n.forEach((r, o) => {
77
+ H(r, !1, (l) => {
78
+ s[o] = l, ++i === t && e(s.join(re));
202
79
  });
203
80
  });
204
- }, we = (s, e) => {
205
- const t = s.split(oe), n = [];
206
- for (let r = 0; r < t.length; r++) {
207
- const i = H(t[r], e);
208
- if (n.push(i), i.type === "error")
81
+ }, we = (n, e) => {
82
+ const t = n.split(re), s = [];
83
+ for (let i = 0; i < t.length; i++) {
84
+ const r = W(t[i], e);
85
+ if (s.push(r), r.type === "error")
209
86
  break;
210
87
  }
211
- return n;
88
+ return s;
212
89
  };
213
90
  function ve() {
214
91
  return new TransformStream({
215
- transform(s, e) {
216
- fe(s, (t) => {
217
- const n = t.length;
218
- let r;
219
- if (n < 126)
220
- r = new Uint8Array(1), new DataView(r.buffer).setUint8(0, n);
221
- else if (n < 65536) {
222
- r = new Uint8Array(3);
223
- const i = new DataView(r.buffer);
224
- i.setUint8(0, 126), i.setUint16(1, n);
92
+ transform(n, e) {
93
+ de(n, (t) => {
94
+ const s = t.length;
95
+ let i;
96
+ if (s < 126)
97
+ i = new Uint8Array(1), new DataView(i.buffer).setUint8(0, s);
98
+ else if (s < 65536) {
99
+ i = new Uint8Array(3);
100
+ const r = new DataView(i.buffer);
101
+ r.setUint8(0, 126), r.setUint16(1, s);
225
102
  } else {
226
- r = new Uint8Array(9);
227
- const i = new DataView(r.buffer);
228
- i.setUint8(0, 127), i.setBigUint64(1, BigInt(n));
103
+ i = new Uint8Array(9);
104
+ const r = new DataView(i.buffer);
105
+ r.setUint8(0, 127), r.setBigUint64(1, BigInt(s));
229
106
  }
230
- s.data && typeof s.data != "string" && (r[0] |= 128), e.enqueue(r), e.enqueue(t);
107
+ n.data && typeof n.data != "string" && (i[0] |= 128), e.enqueue(i), e.enqueue(t);
231
108
  });
232
109
  }
233
110
  });
234
111
  }
235
112
  let N;
236
- function C(s) {
237
- return s.reduce((e, t) => e + t.length, 0);
113
+ function C(n) {
114
+ return n.reduce((e, t) => e + t.length, 0);
238
115
  }
239
- function T(s, e) {
240
- if (s[0].length === e)
241
- return s.shift();
116
+ function T(n, e) {
117
+ if (n[0].length === e)
118
+ return n.shift();
242
119
  const t = new Uint8Array(e);
243
- let n = 0;
244
- for (let r = 0; r < e; r++)
245
- t[r] = s[0][n++], n === s[0].length && (s.shift(), n = 0);
246
- return s.length && n < s[0].length && (s[0] = s[0].slice(n)), t;
120
+ let s = 0;
121
+ for (let i = 0; i < e; i++)
122
+ t[i] = n[0][s++], s === n[0].length && (n.shift(), s = 0);
123
+ return n.length && s < n[0].length && (n[0] = n[0].slice(s)), t;
247
124
  }
248
- function ke(s, e) {
125
+ function Ee(n, e) {
249
126
  N || (N = new TextDecoder());
250
127
  const t = [];
251
- let n = 0, r = -1, i = !1;
128
+ let s = 0, i = -1, r = !1;
252
129
  return new TransformStream({
253
- transform(o, h) {
130
+ transform(o, l) {
254
131
  for (t.push(o); ; ) {
255
- if (n === 0) {
132
+ if (s === 0) {
256
133
  if (C(t) < 1)
257
134
  break;
258
135
  const c = T(t, 1);
259
- i = (c[0] & 128) === 128, r = c[0] & 127, r < 126 ? n = 3 : r === 126 ? n = 1 : n = 2;
260
- } else if (n === 1) {
136
+ r = (c[0] & 128) === 128, i = c[0] & 127, i < 126 ? s = 3 : i === 126 ? s = 1 : s = 2;
137
+ } else if (s === 1) {
261
138
  if (C(t) < 2)
262
139
  break;
263
140
  const c = T(t, 2);
264
- r = new DataView(c.buffer, c.byteOffset, c.length).getUint16(0), n = 3;
265
- } else if (n === 2) {
141
+ i = new DataView(c.buffer, c.byteOffset, c.length).getUint16(0), s = 3;
142
+ } else if (s === 2) {
266
143
  if (C(t) < 8)
267
144
  break;
268
- const c = T(t, 8), p = new DataView(c.buffer, c.byteOffset, c.length), u = p.getUint32(0);
145
+ const c = T(t, 8), f = new DataView(c.buffer, c.byteOffset, c.length), u = f.getUint32(0);
269
146
  if (u > Math.pow(2, 21) - 1) {
270
- h.enqueue(D);
147
+ l.enqueue(D);
271
148
  break;
272
149
  }
273
- r = u * Math.pow(2, 32) + p.getUint32(4), n = 3;
150
+ i = u * Math.pow(2, 32) + f.getUint32(4), s = 3;
274
151
  } else {
275
- if (C(t) < r)
152
+ if (C(t) < i)
276
153
  break;
277
- const c = T(t, r);
278
- h.enqueue(H(i ? c : N.decode(c), e)), n = 0;
154
+ const c = T(t, i);
155
+ l.enqueue(W(r ? c : N.decode(c), e)), s = 0;
279
156
  }
280
- if (r === 0 || r > s) {
281
- h.enqueue(D);
157
+ if (i === 0 || i > n) {
158
+ l.enqueue(D);
282
159
  break;
283
160
  }
284
161
  }
285
162
  }
286
163
  });
287
164
  }
288
- const ae = 4;
289
- function _(s) {
290
- if (s) return Ee(s);
165
+ const oe = 4;
166
+ function _(n) {
167
+ if (n) return ke(n);
291
168
  }
292
- function Ee(s) {
169
+ function ke(n) {
293
170
  for (var e in _.prototype)
294
- s[e] = _.prototype[e];
295
- return s;
171
+ n[e] = _.prototype[e];
172
+ return n;
296
173
  }
297
- _.prototype.on = _.prototype.addEventListener = function(s, e) {
298
- return this._callbacks = this._callbacks || {}, (this._callbacks["$" + s] = this._callbacks["$" + s] || []).push(e), this;
174
+ _.prototype.on = _.prototype.addEventListener = function(n, e) {
175
+ return this._callbacks = this._callbacks || {}, (this._callbacks["$" + n] = this._callbacks["$" + n] || []).push(e), this;
299
176
  };
300
- _.prototype.once = function(s, e) {
177
+ _.prototype.once = function(n, e) {
301
178
  function t() {
302
- this.off(s, t), e.apply(this, arguments);
179
+ this.off(n, t), e.apply(this, arguments);
303
180
  }
304
- return t.fn = e, this.on(s, t), this;
181
+ return t.fn = e, this.on(n, t), this;
305
182
  };
306
- _.prototype.off = _.prototype.removeListener = _.prototype.removeAllListeners = _.prototype.removeEventListener = function(s, e) {
183
+ _.prototype.off = _.prototype.removeListener = _.prototype.removeAllListeners = _.prototype.removeEventListener = function(n, e) {
307
184
  if (this._callbacks = this._callbacks || {}, arguments.length == 0)
308
185
  return this._callbacks = {}, this;
309
- var t = this._callbacks["$" + s];
186
+ var t = this._callbacks["$" + n];
310
187
  if (!t) return this;
311
188
  if (arguments.length == 1)
312
- return delete this._callbacks["$" + s], this;
313
- for (var n, r = 0; r < t.length; r++)
314
- if (n = t[r], n === e || n.fn === e) {
315
- t.splice(r, 1);
189
+ return delete this._callbacks["$" + n], this;
190
+ for (var s, i = 0; i < t.length; i++)
191
+ if (s = t[i], s === e || s.fn === e) {
192
+ t.splice(i, 1);
316
193
  break;
317
194
  }
318
- return t.length === 0 && delete this._callbacks["$" + s], this;
195
+ return t.length === 0 && delete this._callbacks["$" + n], this;
319
196
  };
320
- _.prototype.emit = function(s) {
197
+ _.prototype.emit = function(n) {
321
198
  this._callbacks = this._callbacks || {};
322
- for (var e = new Array(arguments.length - 1), t = this._callbacks["$" + s], n = 1; n < arguments.length; n++)
323
- e[n - 1] = arguments[n];
199
+ for (var e = new Array(arguments.length - 1), t = this._callbacks["$" + n], s = 1; s < arguments.length; s++)
200
+ e[s - 1] = arguments[s];
324
201
  if (t) {
325
202
  t = t.slice(0);
326
- for (var n = 0, r = t.length; n < r; ++n)
327
- t[n].apply(this, e);
203
+ for (var s = 0, i = t.length; s < i; ++s)
204
+ t[s].apply(this, e);
328
205
  }
329
206
  return this;
330
207
  };
331
208
  _.prototype.emitReserved = _.prototype.emit;
332
- _.prototype.listeners = function(s) {
333
- return this._callbacks = this._callbacks || {}, this._callbacks["$" + s] || [];
209
+ _.prototype.listeners = function(n) {
210
+ return this._callbacks = this._callbacks || {}, this._callbacks["$" + n] || [];
334
211
  };
335
- _.prototype.hasListeners = function(s) {
336
- return !!this.listeners(s).length;
212
+ _.prototype.hasListeners = function(n) {
213
+ return !!this.listeners(n).length;
337
214
  };
338
- const O = typeof Promise == "function" && typeof Promise.resolve == "function" ? (s) => Promise.resolve().then(s) : (s, e) => e(s, 0), d = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), Ce = "arraybuffer";
339
- function ce(s, ...e) {
340
- return e.reduce((t, n) => (s.hasOwnProperty(n) && (t[n] = s[n]), t), {});
215
+ const O = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0), d = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), Ce = "arraybuffer";
216
+ function ae(n, ...e) {
217
+ return e.reduce((t, s) => (n.hasOwnProperty(s) && (t[s] = n[s]), t), {});
341
218
  }
342
219
  const Te = d.setTimeout, Ae = d.clearTimeout;
343
- function L(s, e) {
344
- e.useNativeTimers ? (s.setTimeoutFn = Te.bind(d), s.clearTimeoutFn = Ae.bind(d)) : (s.setTimeoutFn = d.setTimeout.bind(d), s.clearTimeoutFn = d.clearTimeout.bind(d));
220
+ function L(n, e) {
221
+ e.useNativeTimers ? (n.setTimeoutFn = Te.bind(d), n.clearTimeoutFn = Ae.bind(d)) : (n.setTimeoutFn = d.setTimeout.bind(d), n.clearTimeoutFn = d.clearTimeout.bind(d));
345
222
  }
346
- const xe = 1.33;
347
- function Se(s) {
348
- return typeof s == "string" ? Re(s) : Math.ceil((s.byteLength || s.size) * xe);
223
+ const Se = 1.33;
224
+ function xe(n) {
225
+ return typeof n == "string" ? Re(n) : Math.ceil((n.byteLength || n.size) * Se);
349
226
  }
350
- function Re(s) {
227
+ function Re(n) {
351
228
  let e = 0, t = 0;
352
- for (let n = 0, r = s.length; n < r; n++)
353
- e = s.charCodeAt(n), e < 128 ? t += 1 : e < 2048 ? t += 2 : e < 55296 || e >= 57344 ? t += 3 : (n++, t += 4);
229
+ for (let s = 0, i = n.length; s < i; s++)
230
+ e = n.charCodeAt(s), e < 128 ? t += 1 : e < 2048 ? t += 2 : e < 55296 || e >= 57344 ? t += 3 : (s++, t += 4);
354
231
  return t;
355
232
  }
356
- function le() {
233
+ function ce() {
357
234
  return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
358
235
  }
359
- function Be(s) {
236
+ function Be(n) {
360
237
  let e = "";
361
- for (let t in s)
362
- s.hasOwnProperty(t) && (e.length && (e += "&"), e += encodeURIComponent(t) + "=" + encodeURIComponent(s[t]));
238
+ for (let t in n)
239
+ n.hasOwnProperty(t) && (e.length && (e += "&"), e += encodeURIComponent(t) + "=" + encodeURIComponent(n[t]));
363
240
  return e;
364
241
  }
365
- function Oe(s) {
366
- let e = {}, t = s.split("&");
367
- for (let n = 0, r = t.length; n < r; n++) {
368
- let i = t[n].split("=");
369
- e[decodeURIComponent(i[0])] = decodeURIComponent(i[1]);
242
+ function Oe(n) {
243
+ let e = {}, t = n.split("&");
244
+ for (let s = 0, i = t.length; s < i; s++) {
245
+ let r = t[s].split("=");
246
+ e[decodeURIComponent(r[0])] = decodeURIComponent(r[1]);
370
247
  }
371
248
  return e;
372
249
  }
373
250
  class Le extends Error {
374
- constructor(e, t, n) {
375
- super(e), this.description = t, this.context = n, this.type = "TransportError";
251
+ constructor(e, t, s) {
252
+ super(e), this.description = t, this.context = s, this.type = "TransportError";
376
253
  }
377
254
  }
378
- class W extends _ {
255
+ class K extends _ {
379
256
  /**
380
257
  * Transport abstract constructor.
381
258
  *
@@ -394,8 +271,8 @@ class W extends _ {
394
271
  * @return {Transport} for chaining
395
272
  * @protected
396
273
  */
397
- onError(e, t, n) {
398
- return super.emitReserved("error", new Le(e, t, n)), this;
274
+ onError(e, t, s) {
275
+ return super.emitReserved("error", new Le(e, t, s)), this;
399
276
  }
400
277
  /**
401
278
  * Opens the transport.
@@ -432,7 +309,7 @@ class W extends _ {
432
309
  * @protected
433
310
  */
434
311
  onData(e) {
435
- const t = H(e, this.socket.binaryType);
312
+ const t = W(e, this.socket.binaryType);
436
313
  this.onPacket(t);
437
314
  }
438
315
  /**
@@ -473,7 +350,7 @@ class W extends _ {
473
350
  return t.length ? "?" + t : "";
474
351
  }
475
352
  }
476
- class Pe extends W {
353
+ class Pe extends K {
477
354
  constructor() {
478
355
  super(...arguments), this._polling = !1;
479
356
  }
@@ -501,11 +378,11 @@ class Pe extends W {
501
378
  this.readyState = "paused", e();
502
379
  };
503
380
  if (this._polling || !this.writable) {
504
- let n = 0;
505
- this._polling && (n++, this.once("pollComplete", function() {
506
- --n || t();
507
- })), this.writable || (n++, this.once("drain", function() {
508
- --n || t();
381
+ let s = 0;
382
+ this._polling && (s++, this.once("pollComplete", function() {
383
+ --s || t();
384
+ })), this.writable || (s++, this.once("drain", function() {
385
+ --s || t();
509
386
  }));
510
387
  } else
511
388
  t();
@@ -524,10 +401,10 @@ class Pe extends W {
524
401
  * @protected
525
402
  */
526
403
  onData(e) {
527
- const t = (n) => {
528
- if (this.readyState === "opening" && n.type === "open" && this.onOpen(), n.type === "close")
404
+ const t = (s) => {
405
+ if (this.readyState === "opening" && s.type === "open" && this.onOpen(), s.type === "close")
529
406
  return this.onClose({ description: "transport closed by the server" }), !1;
530
- this.onPacket(n);
407
+ this.onPacket(s);
531
408
  };
532
409
  we(e, this.socket.binaryType).forEach(t), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
533
410
  }
@@ -562,15 +439,15 @@ class Pe extends W {
562
439
  */
563
440
  uri() {
564
441
  const e = this.opts.secure ? "https" : "http", t = this.query || {};
565
- return this.opts.timestampRequests !== !1 && (t[this.opts.timestampParam] = le()), !this.supportsBinary && !t.sid && (t.b64 = 1), this.createUri(e, t);
442
+ return this.opts.timestampRequests !== !1 && (t[this.opts.timestampParam] = ce()), !this.supportsBinary && !t.sid && (t.b64 = 1), this.createUri(e, t);
566
443
  }
567
444
  }
568
- let he = !1;
445
+ let le = !1;
569
446
  try {
570
- he = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
447
+ le = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
571
448
  } catch {
572
449
  }
573
- const Ne = he;
450
+ const Ne = le;
574
451
  function Ie() {
575
452
  }
576
453
  class qe extends Pe {
@@ -583,8 +460,8 @@ class qe extends Pe {
583
460
  constructor(e) {
584
461
  if (super(e), typeof location < "u") {
585
462
  const t = location.protocol === "https:";
586
- let n = location.port;
587
- n || (n = t ? "443" : "80"), this.xd = typeof location < "u" && e.hostname !== location.hostname || n !== e.port;
463
+ let s = location.port;
464
+ s || (s = t ? "443" : "80"), this.xd = typeof location < "u" && e.hostname !== location.hostname || s !== e.port;
588
465
  }
589
466
  }
590
467
  /**
@@ -595,12 +472,12 @@ class qe extends Pe {
595
472
  * @private
596
473
  */
597
474
  doWrite(e, t) {
598
- const n = this.request({
475
+ const s = this.request({
599
476
  method: "POST",
600
477
  data: e
601
478
  });
602
- n.on("success", t), n.on("error", (r, i) => {
603
- this.onError("xhr post error", r, i);
479
+ s.on("success", t), s.on("error", (i, r) => {
480
+ this.onError("xhr post error", i, r);
604
481
  });
605
482
  }
606
483
  /**
@@ -610,8 +487,8 @@ class qe extends Pe {
610
487
  */
611
488
  doPoll() {
612
489
  const e = this.request();
613
- e.on("data", this.onData.bind(this)), e.on("error", (t, n) => {
614
- this.onError("xhr poll error", t, n);
490
+ e.on("data", this.onData.bind(this)), e.on("error", (t, s) => {
491
+ this.onError("xhr poll error", t, s);
615
492
  }), this.pollXhr = e;
616
493
  }
617
494
  }
@@ -622,8 +499,8 @@ class g extends _ {
622
499
  * @param {Object} options
623
500
  * @package
624
501
  */
625
- constructor(e, t, n) {
626
- super(), this.createRequest = e, L(this, n), this._opts = n, this._method = n.method || "GET", this._uri = t, this._data = n.data !== void 0 ? n.data : null, this._create();
502
+ constructor(e, t, s) {
503
+ super(), this.createRequest = e, L(this, s), this._opts = s, this._method = s.method || "GET", this._uri = t, this._data = s.data !== void 0 ? s.data : null, this._create();
627
504
  }
628
505
  /**
629
506
  * Creates the XHR object and sends the request.
@@ -632,40 +509,40 @@ class g extends _ {
632
509
  */
633
510
  _create() {
634
511
  var e;
635
- const t = ce(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
512
+ const t = ae(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
636
513
  t.xdomain = !!this._opts.xd;
637
- const n = this._xhr = this.createRequest(t);
514
+ const s = this._xhr = this.createRequest(t);
638
515
  try {
639
- n.open(this._method, this._uri, !0);
516
+ s.open(this._method, this._uri, !0);
640
517
  try {
641
518
  if (this._opts.extraHeaders) {
642
- n.setDisableHeaderCheck && n.setDisableHeaderCheck(!0);
643
- for (let r in this._opts.extraHeaders)
644
- this._opts.extraHeaders.hasOwnProperty(r) && n.setRequestHeader(r, this._opts.extraHeaders[r]);
519
+ s.setDisableHeaderCheck && s.setDisableHeaderCheck(!0);
520
+ for (let i in this._opts.extraHeaders)
521
+ this._opts.extraHeaders.hasOwnProperty(i) && s.setRequestHeader(i, this._opts.extraHeaders[i]);
645
522
  }
646
523
  } catch {
647
524
  }
648
525
  if (this._method === "POST")
649
526
  try {
650
- n.setRequestHeader("Content-type", "text/plain;charset=UTF-8");
527
+ s.setRequestHeader("Content-type", "text/plain;charset=UTF-8");
651
528
  } catch {
652
529
  }
653
530
  try {
654
- n.setRequestHeader("Accept", "*/*");
531
+ s.setRequestHeader("Accept", "*/*");
655
532
  } catch {
656
533
  }
657
- (e = this._opts.cookieJar) === null || e === void 0 || e.addCookies(n), "withCredentials" in n && (n.withCredentials = this._opts.withCredentials), this._opts.requestTimeout && (n.timeout = this._opts.requestTimeout), n.onreadystatechange = () => {
658
- var r;
659
- n.readyState === 3 && ((r = this._opts.cookieJar) === null || r === void 0 || r.parseCookies(
534
+ (e = this._opts.cookieJar) === null || e === void 0 || e.addCookies(s), "withCredentials" in s && (s.withCredentials = this._opts.withCredentials), this._opts.requestTimeout && (s.timeout = this._opts.requestTimeout), s.onreadystatechange = () => {
535
+ var i;
536
+ s.readyState === 3 && ((i = this._opts.cookieJar) === null || i === void 0 || i.parseCookies(
660
537
  // @ts-ignore
661
- n.getResponseHeader("set-cookie")
662
- )), n.readyState === 4 && (n.status === 200 || n.status === 1223 ? this._onLoad() : this.setTimeoutFn(() => {
663
- this._onError(typeof n.status == "number" ? n.status : 0);
538
+ s.getResponseHeader("set-cookie")
539
+ )), s.readyState === 4 && (s.status === 200 || s.status === 1223 ? this._onLoad() : this.setTimeoutFn(() => {
540
+ this._onError(typeof s.status == "number" ? s.status : 0);
664
541
  }, 0));
665
- }, n.send(this._data);
666
- } catch (r) {
542
+ }, s.send(this._data);
543
+ } catch (i) {
667
544
  this.setTimeoutFn(() => {
668
- this._onError(r);
545
+ this._onError(i);
669
546
  }, 0);
670
547
  return;
671
548
  }
@@ -716,21 +593,21 @@ g.requestsCount = 0;
716
593
  g.requests = {};
717
594
  if (typeof document < "u") {
718
595
  if (typeof attachEvent == "function")
719
- attachEvent("onunload", Z);
596
+ attachEvent("onunload", j);
720
597
  else if (typeof addEventListener == "function") {
721
- const s = "onpagehide" in d ? "pagehide" : "unload";
722
- addEventListener(s, Z, !1);
598
+ const n = "onpagehide" in d ? "pagehide" : "unload";
599
+ addEventListener(n, j, !1);
723
600
  }
724
601
  }
725
- function Z() {
726
- for (let s in g.requests)
727
- g.requests.hasOwnProperty(s) && g.requests[s].abort();
602
+ function j() {
603
+ for (let n in g.requests)
604
+ g.requests.hasOwnProperty(n) && g.requests[n].abort();
728
605
  }
729
606
  const De = function() {
730
- const s = ue({
607
+ const n = he({
731
608
  xdomain: !1
732
609
  });
733
- return s && s.responseType !== null;
610
+ return n && n.responseType !== null;
734
611
  }();
735
612
  class Ue extends qe {
736
613
  constructor(e) {
@@ -739,11 +616,11 @@ class Ue extends qe {
739
616
  this.supportsBinary = De && !t;
740
617
  }
741
618
  request(e = {}) {
742
- return Object.assign(e, { xd: this.xd }, this.opts), new g(ue, this.uri(), e);
619
+ return Object.assign(e, { xd: this.xd }, this.opts), new g(he, this.uri(), e);
743
620
  }
744
621
  }
745
- function ue(s) {
746
- const e = s.xdomain;
622
+ function he(n) {
623
+ const e = n.xdomain;
747
624
  try {
748
625
  if (typeof XMLHttpRequest < "u" && (!e || Ne))
749
626
  return new XMLHttpRequest();
@@ -755,18 +632,18 @@ function ue(s) {
755
632
  } catch {
756
633
  }
757
634
  }
758
- const _e = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
759
- class je extends W {
635
+ const ue = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
636
+ class Me extends K {
760
637
  get name() {
761
638
  return "websocket";
762
639
  }
763
640
  doOpen() {
764
- const e = this.uri(), t = this.opts.protocols, n = _e ? {} : ce(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
765
- this.opts.extraHeaders && (n.headers = this.opts.extraHeaders);
641
+ const e = this.uri(), t = this.opts.protocols, s = ue ? {} : ae(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
642
+ this.opts.extraHeaders && (s.headers = this.opts.extraHeaders);
766
643
  try {
767
- this.ws = this.createSocket(e, t, n);
768
- } catch (r) {
769
- return this.emitReserved("error", r);
644
+ this.ws = this.createSocket(e, t, s);
645
+ } catch (i) {
646
+ return this.emitReserved("error", i);
770
647
  }
771
648
  this.ws.binaryType = this.socket.binaryType, this.addEventListeners();
772
649
  }
@@ -786,13 +663,13 @@ class je extends W {
786
663
  write(e) {
787
664
  this.writable = !1;
788
665
  for (let t = 0; t < e.length; t++) {
789
- const n = e[t], r = t === e.length - 1;
790
- V(n, this.supportsBinary, (i) => {
666
+ const s = e[t], i = t === e.length - 1;
667
+ H(s, this.supportsBinary, (r) => {
791
668
  try {
792
- this.doWrite(n, i);
669
+ this.doWrite(s, r);
793
670
  } catch {
794
671
  }
795
- r && O(() => {
672
+ i && O(() => {
796
673
  this.writable = !0, this.emitReserved("drain");
797
674
  }, this.setTimeoutFn);
798
675
  });
@@ -809,19 +686,19 @@ class je extends W {
809
686
  */
810
687
  uri() {
811
688
  const e = this.opts.secure ? "wss" : "ws", t = this.query || {};
812
- return this.opts.timestampRequests && (t[this.opts.timestampParam] = le()), this.supportsBinary || (t.b64 = 1), this.createUri(e, t);
689
+ return this.opts.timestampRequests && (t[this.opts.timestampParam] = ce()), this.supportsBinary || (t.b64 = 1), this.createUri(e, t);
813
690
  }
814
691
  }
815
692
  const I = d.WebSocket || d.MozWebSocket;
816
- class Me extends je {
817
- createSocket(e, t, n) {
818
- return _e ? new I(e, t, n) : t ? new I(e, t) : new I(e);
693
+ class Fe extends Me {
694
+ createSocket(e, t, s) {
695
+ return ue ? new I(e, t, s) : t ? new I(e, t) : new I(e);
819
696
  }
820
697
  doWrite(e, t) {
821
698
  this.ws.send(t);
822
699
  }
823
700
  }
824
- class Fe extends W {
701
+ class $e extends K {
825
702
  get name() {
826
703
  return "webtransport";
827
704
  }
@@ -837,15 +714,15 @@ class Fe extends W {
837
714
  this.onError("webtransport error", e);
838
715
  }), this._transport.ready.then(() => {
839
716
  this._transport.createBidirectionalStream().then((e) => {
840
- const t = ke(Number.MAX_SAFE_INTEGER, this.socket.binaryType), n = e.readable.pipeThrough(t).getReader(), r = ve();
841
- r.readable.pipeTo(e.writable), this._writer = r.writable.getWriter();
842
- const i = () => {
843
- n.read().then(({ done: h, value: c }) => {
844
- h || (this.onPacket(c), i());
845
- }).catch((h) => {
717
+ const t = Ee(Number.MAX_SAFE_INTEGER, this.socket.binaryType), s = e.readable.pipeThrough(t).getReader(), i = ve();
718
+ i.readable.pipeTo(e.writable), this._writer = i.writable.getWriter();
719
+ const r = () => {
720
+ s.read().then(({ done: l, value: c }) => {
721
+ l || (this.onPacket(c), r());
722
+ }).catch((l) => {
846
723
  });
847
724
  };
848
- i();
725
+ r();
849
726
  const o = { type: "open" };
850
727
  this.query.sid && (o.data = `{"sid":"${this.query.sid}"}`), this._writer.write(o).then(() => this.onOpen());
851
728
  });
@@ -854,9 +731,9 @@ class Fe extends W {
854
731
  write(e) {
855
732
  this.writable = !1;
856
733
  for (let t = 0; t < e.length; t++) {
857
- const n = e[t], r = t === e.length - 1;
858
- this._writer.write(n).then(() => {
859
- r && O(() => {
734
+ const s = e[t], i = t === e.length - 1;
735
+ this._writer.write(s).then(() => {
736
+ i && O(() => {
860
737
  this.writable = !0, this.emitReserved("drain");
861
738
  }, this.setTimeoutFn);
862
739
  });
@@ -867,11 +744,11 @@ class Fe extends W {
867
744
  (e = this._transport) === null || e === void 0 || e.close();
868
745
  }
869
746
  }
870
- const $e = {
871
- websocket: Me,
872
- webtransport: Fe,
747
+ const Ve = {
748
+ websocket: Fe,
749
+ webtransport: $e,
873
750
  polling: Ue
874
- }, Ve = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, He = [
751
+ }, He = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, We = [
875
752
  "source",
876
753
  "protocol",
877
754
  "authority",
@@ -887,29 +764,29 @@ const $e = {
887
764
  "query",
888
765
  "anchor"
889
766
  ];
890
- function U(s) {
891
- if (s.length > 8e3)
767
+ function U(n) {
768
+ if (n.length > 8e3)
892
769
  throw "URI too long";
893
- const e = s, t = s.indexOf("["), n = s.indexOf("]");
894
- t != -1 && n != -1 && (s = s.substring(0, t) + s.substring(t, n).replace(/:/g, ";") + s.substring(n, s.length));
895
- let r = Ve.exec(s || ""), i = {}, o = 14;
770
+ const e = n, t = n.indexOf("["), s = n.indexOf("]");
771
+ t != -1 && s != -1 && (n = n.substring(0, t) + n.substring(t, s).replace(/:/g, ";") + n.substring(s, n.length));
772
+ let i = He.exec(n || ""), r = {}, o = 14;
896
773
  for (; o--; )
897
- i[He[o]] = r[o] || "";
898
- return t != -1 && n != -1 && (i.source = e, i.host = i.host.substring(1, i.host.length - 1).replace(/;/g, ":"), i.authority = i.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), i.ipv6uri = !0), i.pathNames = We(i, i.path), i.queryKey = ze(i, i.query), i;
774
+ r[We[o]] = i[o] || "";
775
+ 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 = Ke(r, r.path), r.queryKey = ze(r, r.query), r;
899
776
  }
900
- function We(s, e) {
901
- const t = /\/{2,9}/g, n = e.replace(t, "/").split("/");
902
- return (e.slice(0, 1) == "/" || e.length === 0) && n.splice(0, 1), e.slice(-1) == "/" && n.splice(n.length - 1, 1), n;
777
+ function Ke(n, e) {
778
+ const t = /\/{2,9}/g, s = e.replace(t, "/").split("/");
779
+ return (e.slice(0, 1) == "/" || e.length === 0) && s.splice(0, 1), e.slice(-1) == "/" && s.splice(s.length - 1, 1), s;
903
780
  }
904
- function ze(s, e) {
781
+ function ze(n, e) {
905
782
  const t = {};
906
- return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(n, r, i) {
907
- r && (t[r] = i);
783
+ return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(s, i, r) {
784
+ i && (t[i] = r);
908
785
  }), t;
909
786
  }
910
- const j = typeof addEventListener == "function" && typeof removeEventListener == "function", S = [];
911
- j && addEventListener("offline", () => {
912
- S.forEach((s) => s());
787
+ const M = typeof addEventListener == "function" && typeof removeEventListener == "function", x = [];
788
+ M && addEventListener("offline", () => {
789
+ x.forEach((n) => n());
913
790
  }, !1);
914
791
  class b extends _ {
915
792
  /**
@@ -920,12 +797,12 @@ class b extends _ {
920
797
  */
921
798
  constructor(e, t) {
922
799
  if (super(), this.binaryType = Ce, 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) {
923
- const n = U(e);
924
- t.hostname = n.host, t.secure = n.protocol === "https" || n.protocol === "wss", t.port = n.port, n.query && (t.query = n.query);
800
+ const s = U(e);
801
+ t.hostname = s.host, t.secure = s.protocol === "https" || s.protocol === "wss", t.port = s.port, s.query && (t.query = s.query);
925
802
  } else t.host && (t.hostname = U(t.host).host);
926
- L(this, t), this.secure = t.secure != null ? t.secure : typeof location < "u" && location.protocol === "https:", t.hostname && !t.port && (t.port = this.secure ? "443" : "80"), this.hostname = t.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = t.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, t.transports.forEach((n) => {
927
- const r = n.prototype.name;
928
- this.transports.push(r), this._transportsByName[r] = n;
803
+ L(this, t), this.secure = t.secure != null ? t.secure : typeof location < "u" && location.protocol === "https:", t.hostname && !t.port && (t.port = this.secure ? "443" : "80"), this.hostname = t.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = t.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, t.transports.forEach((s) => {
804
+ const i = s.prototype.name;
805
+ this.transports.push(i), this._transportsByName[i] = s;
929
806
  }), this.opts = Object.assign({
930
807
  path: "/engine.io",
931
808
  agent: !1,
@@ -940,13 +817,13 @@ class b extends _ {
940
817
  },
941
818
  transportOptions: {},
942
819
  closeOnBeforeunload: !1
943
- }, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = Oe(this.opts.query)), j && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
820
+ }, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = Oe(this.opts.query)), M && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
944
821
  this.transport && (this.transport.removeAllListeners(), this.transport.close());
945
822
  }, addEventListener("beforeunload", this._beforeunloadEventListener, !1)), this.hostname !== "localhost" && (this._offlineEventListener = () => {
946
823
  this._onClose("transport close", {
947
824
  description: "network connection lost"
948
825
  });
949
- }, S.push(this._offlineEventListener))), this.opts.withCredentials && (this._cookieJar = void 0), this._open();
826
+ }, x.push(this._offlineEventListener))), this.opts.withCredentials && (this._cookieJar = void 0), this._open();
950
827
  }
951
828
  /**
952
829
  * Creates transport of the given type.
@@ -957,15 +834,15 @@ class b extends _ {
957
834
  */
958
835
  createTransport(e) {
959
836
  const t = Object.assign({}, this.opts.query);
960
- t.EIO = ae, t.transport = e, this.id && (t.sid = this.id);
961
- const n = Object.assign({}, this.opts, {
837
+ t.EIO = oe, t.transport = e, this.id && (t.sid = this.id);
838
+ const s = Object.assign({}, this.opts, {
962
839
  query: t,
963
840
  socket: this,
964
841
  hostname: this.hostname,
965
842
  secure: this.secure,
966
843
  port: this.port
967
844
  }, this.opts.transportOptions[e]);
968
- return new this._transportsByName[e](n);
845
+ return new this._transportsByName[e](s);
969
846
  }
970
847
  /**
971
848
  * Initializes transport to use and starts probe.
@@ -1072,12 +949,12 @@ class b extends _ {
1072
949
  _getWritablePackets() {
1073
950
  if (!(this._maxPayload && this.transport.name === "polling" && this.writeBuffer.length > 1))
1074
951
  return this.writeBuffer;
1075
- let e = 1;
1076
- for (let t = 0; t < this.writeBuffer.length; t++) {
1077
- const n = this.writeBuffer[t].data;
1078
- if (n && (e += Se(n)), t > 0 && e > this._maxPayload)
1079
- return this.writeBuffer.slice(0, t);
1080
- e += 2;
952
+ let t = 1;
953
+ for (let s = 0; s < this.writeBuffer.length; s++) {
954
+ const i = this.writeBuffer[s].data;
955
+ if (i && (t += xe(i)), s > 0 && t > this._maxPayload)
956
+ return this.writeBuffer.slice(0, s);
957
+ t += 2;
1081
958
  }
1082
959
  return this.writeBuffer;
1083
960
  }
@@ -1107,8 +984,8 @@ class b extends _ {
1107
984
  * @param {Function} fn - callback function.
1108
985
  * @return {Socket} for chaining.
1109
986
  */
1110
- write(e, t, n) {
1111
- return this._sendPacket("message", e, t, n), this;
987
+ write(e, t, s) {
988
+ return this._sendPacket("message", e, t, s), this;
1112
989
  }
1113
990
  /**
1114
991
  * Sends a message. Alias of {@link Socket#write}.
@@ -1118,8 +995,8 @@ class b extends _ {
1118
995
  * @param {Function} fn - callback function.
1119
996
  * @return {Socket} for chaining.
1120
997
  */
1121
- send(e, t, n) {
1122
- return this._sendPacket("message", e, t, n), this;
998
+ send(e, t, s) {
999
+ return this._sendPacket("message", e, t, s), this;
1123
1000
  }
1124
1001
  /**
1125
1002
  * Sends a packet.
@@ -1130,16 +1007,16 @@ class b extends _ {
1130
1007
  * @param {Function} fn - callback function.
1131
1008
  * @private
1132
1009
  */
1133
- _sendPacket(e, t, n, r) {
1134
- if (typeof t == "function" && (r = t, t = void 0), typeof n == "function" && (r = n, n = null), this.readyState === "closing" || this.readyState === "closed")
1010
+ _sendPacket(e, t, s, i) {
1011
+ if (typeof t == "function" && (i = t, t = void 0), typeof s == "function" && (i = s, s = null), this.readyState === "closing" || this.readyState === "closed")
1135
1012
  return;
1136
- n = n || {}, n.compress = n.compress !== !1;
1137
- const i = {
1013
+ s = s || {}, s.compress = s.compress !== !1;
1014
+ const r = {
1138
1015
  type: e,
1139
1016
  data: t,
1140
- options: n
1017
+ options: s
1141
1018
  };
1142
- this.emitReserved("packetCreate", i), this.writeBuffer.push(i), r && this.once("flush", r), this.flush();
1019
+ this.emitReserved("packetCreate", r), this.writeBuffer.push(r), i && this.once("flush", i), this.flush();
1143
1020
  }
1144
1021
  /**
1145
1022
  * Closes the connection.
@@ -1149,12 +1026,12 @@ class b extends _ {
1149
1026
  this._onClose("forced close"), this.transport.close();
1150
1027
  }, t = () => {
1151
1028
  this.off("upgrade", t), this.off("upgradeError", t), e();
1152
- }, n = () => {
1029
+ }, s = () => {
1153
1030
  this.once("upgrade", t), this.once("upgradeError", t);
1154
1031
  };
1155
1032
  return (this.readyState === "opening" || this.readyState === "open") && (this.readyState = "closing", this.writeBuffer.length ? this.once("drain", () => {
1156
- this.upgrading ? n() : e();
1157
- }) : this.upgrading ? n() : e()), this;
1033
+ this.upgrading ? s() : e();
1034
+ }) : this.upgrading ? s() : e()), this;
1158
1035
  }
1159
1036
  /**
1160
1037
  * Called upon transport error
@@ -1173,16 +1050,16 @@ class b extends _ {
1173
1050
  */
1174
1051
  _onClose(e, t) {
1175
1052
  if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing") {
1176
- if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), j && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
1177
- const n = S.indexOf(this._offlineEventListener);
1178
- n !== -1 && S.splice(n, 1);
1053
+ if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), M && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
1054
+ const s = x.indexOf(this._offlineEventListener);
1055
+ s !== -1 && x.splice(s, 1);
1179
1056
  }
1180
1057
  this.readyState = "closed", this.id = null, this.emitReserved("close", e, t), this.writeBuffer = [], this._prevBufferLen = 0;
1181
1058
  }
1182
1059
  }
1183
1060
  }
1184
- b.protocol = ae;
1185
- class Ke extends b {
1061
+ b.protocol = oe;
1062
+ class Ye extends b {
1186
1063
  constructor() {
1187
1064
  super(...arguments), this._upgrades = [];
1188
1065
  }
@@ -1198,16 +1075,16 @@ class Ke extends b {
1198
1075
  * @private
1199
1076
  */
1200
1077
  _probe(e) {
1201
- let t = this.createTransport(e), n = !1;
1078
+ let t = this.createTransport(e), s = !1;
1202
1079
  b.priorWebsocketSuccess = !1;
1203
- const r = () => {
1204
- n || (t.send([{ type: "ping", data: "probe" }]), t.once("packet", (y) => {
1205
- if (!n)
1206
- if (y.type === "pong" && y.data === "probe") {
1080
+ const i = () => {
1081
+ s || (t.send([{ type: "ping", data: "probe" }]), t.once("packet", (p) => {
1082
+ if (!s)
1083
+ if (p.type === "pong" && p.data === "probe") {
1207
1084
  if (this.upgrading = !0, this.emitReserved("upgrading", t), !t)
1208
1085
  return;
1209
1086
  b.priorWebsocketSuccess = t.name === "websocket", this.transport.pause(() => {
1210
- n || this.readyState !== "closed" && (u(), this.setTransport(t), t.send([{ type: "upgrade" }]), this.emitReserved("upgrade", t), t = null, this.upgrading = !1, this.flush());
1087
+ s || this.readyState !== "closed" && (u(), this.setTransport(t), t.send([{ type: "upgrade" }]), this.emitReserved("upgrade", t), t = null, this.upgrading = !1, this.flush());
1211
1088
  });
1212
1089
  } else {
1213
1090
  const v = new Error("probe error");
@@ -1215,27 +1092,27 @@ class Ke extends b {
1215
1092
  }
1216
1093
  }));
1217
1094
  };
1218
- function i() {
1219
- n || (n = !0, u(), t.close(), t = null);
1095
+ function r() {
1096
+ s || (s = !0, u(), t.close(), t = null);
1220
1097
  }
1221
- const o = (y) => {
1222
- const v = new Error("probe error: " + y);
1223
- v.transport = t.name, i(), this.emitReserved("upgradeError", v);
1098
+ const o = (p) => {
1099
+ const v = new Error("probe error: " + p);
1100
+ v.transport = t.name, r(), this.emitReserved("upgradeError", v);
1224
1101
  };
1225
- function h() {
1102
+ function l() {
1226
1103
  o("transport closed");
1227
1104
  }
1228
1105
  function c() {
1229
1106
  o("socket closed");
1230
1107
  }
1231
- function p(y) {
1232
- t && y.name !== t.name && i();
1108
+ function f(p) {
1109
+ t && p.name !== t.name && r();
1233
1110
  }
1234
1111
  const u = () => {
1235
- t.removeListener("open", r), t.removeListener("error", o), t.removeListener("close", h), this.off("close", c), this.off("upgrading", p);
1112
+ t.removeListener("open", i), t.removeListener("error", o), t.removeListener("close", l), this.off("close", c), this.off("upgrading", f);
1236
1113
  };
1237
- t.once("open", r), t.once("error", o), t.once("close", h), this.once("close", c), this.once("upgrading", p), this._upgrades.indexOf("webtransport") !== -1 && e !== "webtransport" ? this.setTimeoutFn(() => {
1238
- n || t.open();
1114
+ t.once("open", i), t.once("error", o), t.once("close", l), this.once("close", c), this.once("upgrading", f), this._upgrades.indexOf("webtransport") !== -1 && e !== "webtransport" ? this.setTimeoutFn(() => {
1115
+ s || t.open();
1239
1116
  }, 200) : t.open();
1240
1117
  }
1241
1118
  onHandshake(e) {
@@ -1249,85 +1126,85 @@ class Ke extends b {
1249
1126
  */
1250
1127
  _filterUpgrades(e) {
1251
1128
  const t = [];
1252
- for (let n = 0; n < e.length; n++)
1253
- ~this.transports.indexOf(e[n]) && t.push(e[n]);
1129
+ for (let s = 0; s < e.length; s++)
1130
+ ~this.transports.indexOf(e[s]) && t.push(e[s]);
1254
1131
  return t;
1255
1132
  }
1256
1133
  }
1257
- let Ye = class extends Ke {
1258
- constructor(s, e = {}) {
1259
- const t = typeof s == "object" ? s : e;
1260
- (!t.transports || t.transports && typeof t.transports[0] == "string") && (t.transports = (t.transports || ["polling", "websocket", "webtransport"]).map((n) => $e[n]).filter((n) => !!n)), super(s, t);
1134
+ let Je = class extends Ye {
1135
+ constructor(e, t = {}) {
1136
+ const s = typeof e == "object" ? e : t;
1137
+ (!s.transports || s.transports && typeof s.transports[0] == "string") && (s.transports = (s.transports || ["polling", "websocket", "webtransport"]).map((i) => Ve[i]).filter((i) => !!i)), super(e, s);
1261
1138
  }
1262
1139
  };
1263
- function Je(s, e = "", t) {
1264
- let n = s;
1265
- t = t || typeof location < "u" && location, s == null && (s = t.protocol + "//" + t.host), typeof s == "string" && (s.charAt(0) === "/" && (s.charAt(1) === "/" ? s = t.protocol + s : s = t.host + s), /^(https?|wss?):\/\//.test(s) || (typeof t < "u" ? s = t.protocol + "//" + s : s = "https://" + s), n = U(s)), n.port || (/^(http|ws)$/.test(n.protocol) ? n.port = "80" : /^(http|ws)s$/.test(n.protocol) && (n.port = "443")), n.path = n.path || "/";
1266
- const r = n.host.indexOf(":") !== -1 ? "[" + n.host + "]" : n.host;
1267
- return n.id = n.protocol + "://" + r + ":" + n.port + e, n.href = n.protocol + "://" + r + (t && t.port === n.port ? "" : ":" + n.port), n;
1140
+ function Qe(n, e = "", t) {
1141
+ let s = n;
1142
+ 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 = U(n)), s.port || (/^(http|ws)$/.test(s.protocol) ? s.port = "80" : /^(http|ws)s$/.test(s.protocol) && (s.port = "443")), s.path = s.path || "/";
1143
+ const r = s.host.indexOf(":") !== -1 ? "[" + s.host + "]" : s.host;
1144
+ return s.id = s.protocol + "://" + r + ":" + s.port + e, s.href = s.protocol + "://" + r + (t && t.port === s.port ? "" : ":" + s.port), s;
1268
1145
  }
1269
- const Qe = typeof ArrayBuffer == "function", Xe = (s) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(s) : s.buffer instanceof ArrayBuffer, pe = Object.prototype.toString, Ge = typeof Blob == "function" || typeof Blob < "u" && pe.call(Blob) === "[object BlobConstructor]", Ze = typeof File == "function" || typeof File < "u" && pe.call(File) === "[object FileConstructor]";
1270
- function z(s) {
1271
- return Qe && (s instanceof ArrayBuffer || Xe(s)) || Ge && s instanceof Blob || Ze && s instanceof File;
1146
+ const Xe = typeof ArrayBuffer == "function", je = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n.buffer instanceof ArrayBuffer, _e = Object.prototype.toString, Ge = typeof Blob == "function" || typeof Blob < "u" && _e.call(Blob) === "[object BlobConstructor]", Ze = typeof File == "function" || typeof File < "u" && _e.call(File) === "[object FileConstructor]";
1147
+ function z(n) {
1148
+ return Xe && (n instanceof ArrayBuffer || je(n)) || Ge && n instanceof Blob || Ze && n instanceof File;
1272
1149
  }
1273
- function R(s, e) {
1274
- if (!s || typeof s != "object")
1150
+ function R(n, e) {
1151
+ if (!n || typeof n != "object")
1275
1152
  return !1;
1276
- if (Array.isArray(s)) {
1277
- for (let t = 0, n = s.length; t < n; t++)
1278
- if (R(s[t]))
1153
+ if (Array.isArray(n)) {
1154
+ for (let t = 0, s = n.length; t < s; t++)
1155
+ if (R(n[t]))
1279
1156
  return !0;
1280
1157
  return !1;
1281
1158
  }
1282
- if (z(s))
1159
+ if (z(n))
1283
1160
  return !0;
1284
- if (s.toJSON && typeof s.toJSON == "function" && arguments.length === 1)
1285
- return R(s.toJSON(), !0);
1286
- for (const t in s)
1287
- if (Object.prototype.hasOwnProperty.call(s, t) && R(s[t]))
1161
+ if (n.toJSON && typeof n.toJSON == "function" && arguments.length === 1)
1162
+ return R(n.toJSON(), !0);
1163
+ for (const t in n)
1164
+ if (Object.prototype.hasOwnProperty.call(n, t) && R(n[t]))
1288
1165
  return !0;
1289
1166
  return !1;
1290
1167
  }
1291
- function et(s) {
1292
- const e = [], t = s.data, n = s;
1293
- return n.data = M(t, e), n.attachments = e.length, { packet: n, buffers: e };
1168
+ function et(n) {
1169
+ const e = [], t = n.data, s = n;
1170
+ return s.data = F(t, e), s.attachments = e.length, { packet: s, buffers: e };
1294
1171
  }
1295
- function M(s, e) {
1296
- if (!s)
1297
- return s;
1298
- if (z(s)) {
1172
+ function F(n, e) {
1173
+ if (!n)
1174
+ return n;
1175
+ if (z(n)) {
1299
1176
  const t = { _placeholder: !0, num: e.length };
1300
- return e.push(s), t;
1301
- } else if (Array.isArray(s)) {
1302
- const t = new Array(s.length);
1303
- for (let n = 0; n < s.length; n++)
1304
- t[n] = M(s[n], e);
1177
+ return e.push(n), t;
1178
+ } else if (Array.isArray(n)) {
1179
+ const t = new Array(n.length);
1180
+ for (let s = 0; s < n.length; s++)
1181
+ t[s] = F(n[s], e);
1305
1182
  return t;
1306
- } else if (typeof s == "object" && !(s instanceof Date)) {
1183
+ } else if (typeof n == "object" && !(n instanceof Date)) {
1307
1184
  const t = {};
1308
- for (const n in s)
1309
- Object.prototype.hasOwnProperty.call(s, n) && (t[n] = M(s[n], e));
1185
+ for (const s in n)
1186
+ Object.prototype.hasOwnProperty.call(n, s) && (t[s] = F(n[s], e));
1310
1187
  return t;
1311
1188
  }
1312
- return s;
1189
+ return n;
1313
1190
  }
1314
- function tt(s, e) {
1315
- return s.data = F(s.data, e), delete s.attachments, s;
1191
+ function tt(n, e) {
1192
+ return n.data = $(n.data, e), delete n.attachments, n;
1316
1193
  }
1317
- function F(s, e) {
1318
- if (!s)
1319
- return s;
1320
- if (s && s._placeholder === !0) {
1321
- if (typeof s.num == "number" && s.num >= 0 && s.num < e.length)
1322
- return e[s.num];
1194
+ function $(n, e) {
1195
+ if (!n)
1196
+ return n;
1197
+ if (n && n._placeholder === !0) {
1198
+ if (typeof n.num == "number" && n.num >= 0 && n.num < e.length)
1199
+ return e[n.num];
1323
1200
  throw new Error("illegal attachments");
1324
- } else if (Array.isArray(s))
1325
- for (let t = 0; t < s.length; t++)
1326
- s[t] = F(s[t], e);
1327
- else if (typeof s == "object")
1328
- for (const t in s)
1329
- Object.prototype.hasOwnProperty.call(s, t) && (s[t] = F(s[t], e));
1330
- return s;
1201
+ } else if (Array.isArray(n))
1202
+ for (let t = 0; t < n.length; t++)
1203
+ n[t] = $(n[t], e);
1204
+ else if (typeof n == "object")
1205
+ for (const t in n)
1206
+ Object.prototype.hasOwnProperty.call(n, t) && (n[t] = $(n[t], e));
1207
+ return n;
1331
1208
  }
1332
1209
  const st = [
1333
1210
  "connect",
@@ -1338,11 +1215,11 @@ const st = [
1338
1215
  "removeListener"
1339
1216
  // used by the Node.js EventEmitter
1340
1217
  ], nt = 5;
1341
- var l;
1342
- (function(s) {
1343
- s[s.CONNECT = 0] = "CONNECT", s[s.DISCONNECT = 1] = "DISCONNECT", s[s.EVENT = 2] = "EVENT", s[s.ACK = 3] = "ACK", s[s.CONNECT_ERROR = 4] = "CONNECT_ERROR", s[s.BINARY_EVENT = 5] = "BINARY_EVENT", s[s.BINARY_ACK = 6] = "BINARY_ACK";
1344
- })(l || (l = {}));
1345
- class rt {
1218
+ var h;
1219
+ (function(n) {
1220
+ 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";
1221
+ })(h || (h = {}));
1222
+ class it {
1346
1223
  /**
1347
1224
  * Encoder constructor
1348
1225
  *
@@ -1358,8 +1235,8 @@ class rt {
1358
1235
  * @param {Object} obj - packet object
1359
1236
  */
1360
1237
  encode(e) {
1361
- return (e.type === l.EVENT || e.type === l.ACK) && R(e) ? this.encodeAsBinary({
1362
- type: e.type === l.EVENT ? l.BINARY_EVENT : l.BINARY_ACK,
1238
+ return (e.type === h.EVENT || e.type === h.ACK) && R(e) ? this.encodeAsBinary({
1239
+ type: e.type === h.EVENT ? h.BINARY_EVENT : h.BINARY_ACK,
1363
1240
  nsp: e.nsp,
1364
1241
  data: e.data,
1365
1242
  id: e.id
@@ -1370,7 +1247,7 @@ class rt {
1370
1247
  */
1371
1248
  encodeAsString(e) {
1372
1249
  let t = "" + e.type;
1373
- return (e.type === l.BINARY_EVENT || e.type === l.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;
1250
+ 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;
1374
1251
  }
1375
1252
  /**
1376
1253
  * Encode packet as 'buffer sequence' by removing blobs, and
@@ -1378,14 +1255,14 @@ class rt {
1378
1255
  * a list of buffers.
1379
1256
  */
1380
1257
  encodeAsBinary(e) {
1381
- const t = et(e), n = this.encodeAsString(t.packet), r = t.buffers;
1382
- return r.unshift(n), r;
1258
+ const t = et(e), s = this.encodeAsString(t.packet), i = t.buffers;
1259
+ return i.unshift(s), i;
1383
1260
  }
1384
1261
  }
1385
- function ee(s) {
1386
- return Object.prototype.toString.call(s) === "[object Object]";
1262
+ function G(n) {
1263
+ return Object.prototype.toString.call(n) === "[object Object]";
1387
1264
  }
1388
- class K extends _ {
1265
+ class Y extends _ {
1389
1266
  /**
1390
1267
  * Decoder constructor
1391
1268
  *
@@ -1405,8 +1282,8 @@ class K extends _ {
1405
1282
  if (this.reconstructor)
1406
1283
  throw new Error("got plaintext data when reconstructing a packet");
1407
1284
  t = this.decodeString(e);
1408
- const n = t.type === l.BINARY_EVENT;
1409
- n || t.type === l.BINARY_ACK ? (t.type = n ? l.EVENT : l.ACK, this.reconstructor = new it(t), t.attachments === 0 && super.emitReserved("decoded", t)) : super.emitReserved("decoded", t);
1285
+ const s = t.type === h.BINARY_EVENT;
1286
+ s || t.type === h.BINARY_ACK ? (t.type = s ? h.EVENT : h.ACK, this.reconstructor = new rt(t), t.attachments === 0 && super.emitReserved("decoded", t)) : super.emitReserved("decoded", t);
1410
1287
  } else if (z(e) || e.base64)
1411
1288
  if (this.reconstructor)
1412
1289
  t = this.reconstructor.takeBinaryData(e), t && (this.reconstructor = null, super.emitReserved("decoded", t));
@@ -1423,30 +1300,30 @@ class K extends _ {
1423
1300
  */
1424
1301
  decodeString(e) {
1425
1302
  let t = 0;
1426
- const n = {
1303
+ const s = {
1427
1304
  type: Number(e.charAt(0))
1428
1305
  };
1429
- if (l[n.type] === void 0)
1430
- throw new Error("unknown packet type " + n.type);
1431
- if (n.type === l.BINARY_EVENT || n.type === l.BINARY_ACK) {
1432
- const i = t + 1;
1306
+ if (h[s.type] === void 0)
1307
+ throw new Error("unknown packet type " + s.type);
1308
+ if (s.type === h.BINARY_EVENT || s.type === h.BINARY_ACK) {
1309
+ const r = t + 1;
1433
1310
  for (; e.charAt(++t) !== "-" && t != e.length; )
1434
1311
  ;
1435
- const o = e.substring(i, t);
1312
+ const o = e.substring(r, t);
1436
1313
  if (o != Number(o) || e.charAt(t) !== "-")
1437
1314
  throw new Error("Illegal attachments");
1438
- n.attachments = Number(o);
1315
+ s.attachments = Number(o);
1439
1316
  }
1440
1317
  if (e.charAt(t + 1) === "/") {
1441
- const i = t + 1;
1318
+ const r = t + 1;
1442
1319
  for (; ++t && !(e.charAt(t) === "," || t === e.length); )
1443
1320
  ;
1444
- n.nsp = e.substring(i, t);
1321
+ s.nsp = e.substring(r, t);
1445
1322
  } else
1446
- n.nsp = "/";
1447
- const r = e.charAt(t + 1);
1448
- if (r !== "" && Number(r) == r) {
1449
- const i = t + 1;
1323
+ s.nsp = "/";
1324
+ const i = e.charAt(t + 1);
1325
+ if (i !== "" && Number(i) == i) {
1326
+ const r = t + 1;
1450
1327
  for (; ++t; ) {
1451
1328
  const o = e.charAt(t);
1452
1329
  if (o == null || Number(o) != o) {
@@ -1456,16 +1333,16 @@ class K extends _ {
1456
1333
  if (t === e.length)
1457
1334
  break;
1458
1335
  }
1459
- n.id = Number(e.substring(i, t + 1));
1336
+ s.id = Number(e.substring(r, t + 1));
1460
1337
  }
1461
1338
  if (e.charAt(++t)) {
1462
- const i = this.tryParse(e.substr(t));
1463
- if (K.isPayloadValid(n.type, i))
1464
- n.data = i;
1339
+ const r = this.tryParse(e.substr(t));
1340
+ if (Y.isPayloadValid(s.type, r))
1341
+ s.data = r;
1465
1342
  else
1466
1343
  throw new Error("invalid payload");
1467
1344
  }
1468
- return n;
1345
+ return s;
1469
1346
  }
1470
1347
  tryParse(e) {
1471
1348
  try {
@@ -1476,17 +1353,17 @@ class K extends _ {
1476
1353
  }
1477
1354
  static isPayloadValid(e, t) {
1478
1355
  switch (e) {
1479
- case l.CONNECT:
1480
- return ee(t);
1481
- case l.DISCONNECT:
1356
+ case h.CONNECT:
1357
+ return G(t);
1358
+ case h.DISCONNECT:
1482
1359
  return t === void 0;
1483
- case l.CONNECT_ERROR:
1484
- return typeof t == "string" || ee(t);
1485
- case l.EVENT:
1486
- case l.BINARY_EVENT:
1360
+ case h.CONNECT_ERROR:
1361
+ return typeof t == "string" || G(t);
1362
+ case h.EVENT:
1363
+ case h.BINARY_EVENT:
1487
1364
  return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && st.indexOf(t[0]) === -1);
1488
- case l.ACK:
1489
- case l.BINARY_ACK:
1365
+ case h.ACK:
1366
+ case h.BINARY_ACK:
1490
1367
  return Array.isArray(t);
1491
1368
  }
1492
1369
  }
@@ -1497,7 +1374,7 @@ class K extends _ {
1497
1374
  this.reconstructor && (this.reconstructor.finishedReconstruction(), this.reconstructor = null);
1498
1375
  }
1499
1376
  }
1500
- class it {
1377
+ class rt {
1501
1378
  constructor(e) {
1502
1379
  this.packet = e, this.buffers = [], this.reconPack = e;
1503
1380
  }
@@ -1525,16 +1402,16 @@ class it {
1525
1402
  }
1526
1403
  const ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1527
1404
  __proto__: null,
1528
- Decoder: K,
1529
- Encoder: rt,
1405
+ Decoder: Y,
1406
+ Encoder: it,
1530
1407
  get PacketType() {
1531
- return l;
1408
+ return h;
1532
1409
  },
1533
1410
  protocol: nt
1534
1411
  }, Symbol.toStringTag, { value: "Module" }));
1535
- function f(s, e, t) {
1536
- return s.on(e, t), function() {
1537
- s.off(e, t);
1412
+ function y(n, e, t) {
1413
+ return n.on(e, t), function() {
1414
+ n.off(e, t);
1538
1415
  };
1539
1416
  }
1540
1417
  const at = Object.freeze({
@@ -1546,12 +1423,12 @@ const at = Object.freeze({
1546
1423
  newListener: 1,
1547
1424
  removeListener: 1
1548
1425
  });
1549
- let de = class extends _ {
1426
+ class fe extends _ {
1550
1427
  /**
1551
1428
  * `Socket` constructor.
1552
1429
  */
1553
- constructor(s, e, t) {
1554
- super(), this.connected = !1, this.recovered = !1, this.receiveBuffer = [], this.sendBuffer = [], this._queue = [], this._queueSeq = 0, this.ids = 0, this.acks = {}, this.flags = {}, this.io = s, this.nsp = e, t && t.auth && (this.auth = t.auth), this._opts = Object.assign({}, t), this.io._autoConnect && this.open();
1430
+ constructor(e, t, s) {
1431
+ super(), this.connected = !1, this.recovered = !1, this.receiveBuffer = [], this.sendBuffer = [], this._queue = [], this._queueSeq = 0, this.ids = 0, this.acks = {}, this.flags = {}, this.io = e, this.nsp = t, s && s.auth && (this.auth = s.auth), this._opts = Object.assign({}, s), this.io._autoConnect && this.open();
1555
1432
  }
1556
1433
  /**
1557
1434
  * Whether the socket is currently disconnected
@@ -1578,12 +1455,12 @@ let de = class extends _ {
1578
1455
  subEvents() {
1579
1456
  if (this.subs)
1580
1457
  return;
1581
- const s = this.io;
1458
+ const e = this.io;
1582
1459
  this.subs = [
1583
- f(s, "open", this.onopen.bind(this)),
1584
- f(s, "packet", this.onpacket.bind(this)),
1585
- f(s, "error", this.onerror.bind(this)),
1586
- f(s, "close", this.onclose.bind(this))
1460
+ y(e, "open", this.onopen.bind(this)),
1461
+ y(e, "packet", this.onpacket.bind(this)),
1462
+ y(e, "error", this.onerror.bind(this)),
1463
+ y(e, "close", this.onclose.bind(this))
1587
1464
  ];
1588
1465
  }
1589
1466
  /**
@@ -1640,8 +1517,8 @@ let de = class extends _ {
1640
1517
  *
1641
1518
  * @return self
1642
1519
  */
1643
- send(...s) {
1644
- return s.unshift("message"), this.emit.apply(this, s), this;
1520
+ send(...e) {
1521
+ return e.unshift("message"), this.emit.apply(this, e), this;
1645
1522
  }
1646
1523
  /**
1647
1524
  * Override `emit`.
@@ -1660,42 +1537,42 @@ let de = class extends _ {
1660
1537
  *
1661
1538
  * @return self
1662
1539
  */
1663
- emit(s, ...e) {
1664
- var t, n, r;
1665
- if (at.hasOwnProperty(s))
1666
- throw new Error('"' + s.toString() + '" is a reserved event name');
1667
- if (e.unshift(s), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile)
1668
- return this._addToQueue(e), this;
1669
- const i = {
1670
- type: l.EVENT,
1671
- data: e
1540
+ emit(e, ...t) {
1541
+ var s, i, r;
1542
+ if (at.hasOwnProperty(e))
1543
+ throw new Error('"' + e.toString() + '" is a reserved event name');
1544
+ if (t.unshift(e), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile)
1545
+ return this._addToQueue(t), this;
1546
+ const o = {
1547
+ type: h.EVENT,
1548
+ data: t
1672
1549
  };
1673
- if (i.options = {}, i.options.compress = this.flags.compress !== !1, typeof e[e.length - 1] == "function") {
1674
- const c = this.ids++, p = e.pop();
1675
- this._registerAckCallback(c, p), i.id = c;
1550
+ if (o.options = {}, o.options.compress = this.flags.compress !== !1, typeof t[t.length - 1] == "function") {
1551
+ const u = this.ids++, p = t.pop();
1552
+ this._registerAckCallback(u, p), o.id = u;
1676
1553
  }
1677
- const o = (n = (t = this.io.engine) === null || t === void 0 ? void 0 : t.transport) === null || n === void 0 ? void 0 : n.writable, h = this.connected && !(!((r = this.io.engine) === null || r === void 0) && r._hasPingExpired());
1678
- return this.flags.volatile && !o || (h ? (this.notifyOutgoingListeners(i), this.packet(i)) : this.sendBuffer.push(i)), this.flags = {}, this;
1554
+ const l = (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());
1555
+ return this.flags.volatile && !l || (c ? (this.notifyOutgoingListeners(o), this.packet(o)) : this.sendBuffer.push(o)), this.flags = {}, this;
1679
1556
  }
1680
1557
  /**
1681
1558
  * @private
1682
1559
  */
1683
- _registerAckCallback(s, e) {
1684
- var t;
1685
- const n = (t = this.flags.timeout) !== null && t !== void 0 ? t : this._opts.ackTimeout;
1686
- if (n === void 0) {
1687
- this.acks[s] = e;
1560
+ _registerAckCallback(e, t) {
1561
+ var s;
1562
+ const i = (s = this.flags.timeout) !== null && s !== void 0 ? s : this._opts.ackTimeout;
1563
+ if (i === void 0) {
1564
+ this.acks[e] = t;
1688
1565
  return;
1689
1566
  }
1690
1567
  const r = this.io.setTimeoutFn(() => {
1691
- delete this.acks[s];
1692
- for (let o = 0; o < this.sendBuffer.length; o++)
1693
- this.sendBuffer[o].id === s && this.sendBuffer.splice(o, 1);
1694
- e.call(this, new Error("operation has timed out"));
1695
- }, n), i = (...o) => {
1696
- this.io.clearTimeoutFn(r), e.apply(this, o);
1568
+ delete this.acks[e];
1569
+ for (let l = 0; l < this.sendBuffer.length; l++)
1570
+ this.sendBuffer[l].id === e && this.sendBuffer.splice(l, 1);
1571
+ t.call(this, new Error("operation has timed out"));
1572
+ }, i), o = (...l) => {
1573
+ this.io.clearTimeoutFn(r), t.apply(this, l);
1697
1574
  };
1698
- i.withError = !0, this.acks[s] = i;
1575
+ o.withError = !0, this.acks[e] = o;
1699
1576
  }
1700
1577
  /**
1701
1578
  * Emits an event and waits for an acknowledgement
@@ -1713,10 +1590,10 @@ let de = class extends _ {
1713
1590
  *
1714
1591
  * @return a Promise that will be fulfilled when the server acknowledges the event
1715
1592
  */
1716
- emitWithAck(s, ...e) {
1717
- return new Promise((t, n) => {
1718
- const r = (i, o) => i ? n(i) : t(o);
1719
- r.withError = !0, e.push(r), this.emit(s, ...e);
1593
+ emitWithAck(e, ...t) {
1594
+ return new Promise((s, i) => {
1595
+ const r = (o, l) => o ? i(o) : s(l);
1596
+ r.withError = !0, t.push(r), this.emit(e, ...t);
1720
1597
  });
1721
1598
  }
1722
1599
  /**
@@ -1724,17 +1601,17 @@ let de = class extends _ {
1724
1601
  * @param args
1725
1602
  * @private
1726
1603
  */
1727
- _addToQueue(s) {
1728
- let e;
1729
- typeof s[s.length - 1] == "function" && (e = s.pop());
1730
- const t = {
1604
+ _addToQueue(e) {
1605
+ let t;
1606
+ typeof e[e.length - 1] == "function" && (t = e.pop());
1607
+ const s = {
1731
1608
  id: this._queueSeq++,
1732
1609
  tryCount: 0,
1733
1610
  pending: !1,
1734
- args: s,
1611
+ args: e,
1735
1612
  flags: Object.assign({ fromQueue: !0 }, this.flags)
1736
1613
  };
1737
- s.push((n, ...r) => t !== this._queue[0] ? void 0 : (n !== null ? t.tryCount > this._opts.retries && (this._queue.shift(), e && e(n)) : (this._queue.shift(), e && e(null, ...r)), t.pending = !1, this._drainQueue())), this._queue.push(t), this._drainQueue();
1614
+ e.push((i, ...r) => s !== this._queue[0] ? void 0 : (i !== null ? s.tryCount > this._opts.retries && (this._queue.shift(), t && t(i)) : (this._queue.shift(), t && t(null, ...r)), s.pending = !1, this._drainQueue())), this._queue.push(s), this._drainQueue();
1738
1615
  }
1739
1616
  /**
1740
1617
  * Send the first packet of the queue, and wait for an acknowledgement from the server.
@@ -1742,11 +1619,11 @@ let de = class extends _ {
1742
1619
  *
1743
1620
  * @private
1744
1621
  */
1745
- _drainQueue(s = !1) {
1622
+ _drainQueue(e = !1) {
1746
1623
  if (!this.connected || this._queue.length === 0)
1747
1624
  return;
1748
- const e = this._queue[0];
1749
- e.pending && !s || (e.pending = !0, e.tryCount++, this.flags = e.flags, this.emit.apply(this, e.args));
1625
+ const t = this._queue[0];
1626
+ t.pending && !e || (t.pending = !0, t.tryCount++, this.flags = t.flags, this.emit.apply(this, t.args));
1750
1627
  }
1751
1628
  /**
1752
1629
  * Sends a packet.
@@ -1754,8 +1631,8 @@ let de = class extends _ {
1754
1631
  * @param packet
1755
1632
  * @private
1756
1633
  */
1757
- packet(s) {
1758
- s.nsp = this.nsp, this.io._packet(s);
1634
+ packet(e) {
1635
+ e.nsp = this.nsp, this.io._packet(e);
1759
1636
  }
1760
1637
  /**
1761
1638
  * Called upon engine `open`.
@@ -1763,8 +1640,8 @@ let de = class extends _ {
1763
1640
  * @private
1764
1641
  */
1765
1642
  onopen() {
1766
- typeof this.auth == "function" ? this.auth((s) => {
1767
- this._sendConnectPacket(s);
1643
+ typeof this.auth == "function" ? this.auth((e) => {
1644
+ this._sendConnectPacket(e);
1768
1645
  }) : this._sendConnectPacket(this.auth);
1769
1646
  }
1770
1647
  /**
@@ -1773,10 +1650,10 @@ let de = class extends _ {
1773
1650
  * @param data
1774
1651
  * @private
1775
1652
  */
1776
- _sendConnectPacket(s) {
1653
+ _sendConnectPacket(e) {
1777
1654
  this.packet({
1778
- type: l.CONNECT,
1779
- data: this._pid ? Object.assign({ pid: this._pid, offset: this._lastOffset }, s) : s
1655
+ type: h.CONNECT,
1656
+ data: this._pid ? Object.assign({ pid: this._pid, offset: this._lastOffset }, e) : e
1780
1657
  });
1781
1658
  }
1782
1659
  /**
@@ -1785,8 +1662,8 @@ let de = class extends _ {
1785
1662
  * @param err
1786
1663
  * @private
1787
1664
  */
1788
- onerror(s) {
1789
- this.connected || this.emitReserved("connect_error", s);
1665
+ onerror(e) {
1666
+ this.connected || this.emitReserved("connect_error", e);
1790
1667
  }
1791
1668
  /**
1792
1669
  * Called upon engine `close`.
@@ -1795,8 +1672,8 @@ let de = class extends _ {
1795
1672
  * @param description
1796
1673
  * @private
1797
1674
  */
1798
- onclose(s, e) {
1799
- this.connected = !1, delete this.id, this.emitReserved("disconnect", s, e), this._clearAcks();
1675
+ onclose(e, t) {
1676
+ this.connected = !1, delete this.id, this.emitReserved("disconnect", e, t), this._clearAcks();
1800
1677
  }
1801
1678
  /**
1802
1679
  * Clears the acknowledgement handlers upon disconnection, since the client will never receive an acknowledgement from
@@ -1805,10 +1682,10 @@ let de = class extends _ {
1805
1682
  * @private
1806
1683
  */
1807
1684
  _clearAcks() {
1808
- Object.keys(this.acks).forEach((s) => {
1809
- if (!this.sendBuffer.some((e) => String(e.id) === s)) {
1810
- const e = this.acks[s];
1811
- delete this.acks[s], e.withError && e.call(this, new Error("socket has been disconnected"));
1685
+ Object.keys(this.acks).forEach((e) => {
1686
+ if (!this.sendBuffer.some((s) => String(s.id) === e)) {
1687
+ const s = this.acks[e];
1688
+ delete this.acks[e], s.withError && s.call(this, new Error("socket has been disconnected"));
1812
1689
  }
1813
1690
  });
1814
1691
  }
@@ -1818,27 +1695,27 @@ let de = class extends _ {
1818
1695
  * @param packet
1819
1696
  * @private
1820
1697
  */
1821
- onpacket(s) {
1822
- if (s.nsp === this.nsp)
1823
- switch (s.type) {
1824
- case l.CONNECT:
1825
- s.data && s.data.sid ? this.onconnect(s.data.sid, s.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/)"));
1698
+ onpacket(e) {
1699
+ if (e.nsp === this.nsp)
1700
+ switch (e.type) {
1701
+ case h.CONNECT:
1702
+ 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/)"));
1826
1703
  break;
1827
- case l.EVENT:
1828
- case l.BINARY_EVENT:
1829
- this.onevent(s);
1704
+ case h.EVENT:
1705
+ case h.BINARY_EVENT:
1706
+ this.onevent(e);
1830
1707
  break;
1831
- case l.ACK:
1832
- case l.BINARY_ACK:
1833
- this.onack(s);
1708
+ case h.ACK:
1709
+ case h.BINARY_ACK:
1710
+ this.onack(e);
1834
1711
  break;
1835
- case l.DISCONNECT:
1712
+ case h.DISCONNECT:
1836
1713
  this.ondisconnect();
1837
1714
  break;
1838
- case l.CONNECT_ERROR:
1715
+ case h.CONNECT_ERROR:
1839
1716
  this.destroy();
1840
- const e = new Error(s.data.message);
1841
- e.data = s.data.data, this.emitReserved("connect_error", e);
1717
+ const s = new Error(e.data.message);
1718
+ s.data = e.data.data, this.emitReserved("connect_error", s);
1842
1719
  break;
1843
1720
  }
1844
1721
  }
@@ -1848,31 +1725,31 @@ let de = class extends _ {
1848
1725
  * @param packet
1849
1726
  * @private
1850
1727
  */
1851
- onevent(s) {
1852
- const e = s.data || [];
1853
- s.id != null && e.push(this.ack(s.id)), this.connected ? this.emitEvent(e) : this.receiveBuffer.push(Object.freeze(e));
1728
+ onevent(e) {
1729
+ const t = e.data || [];
1730
+ e.id != null && t.push(this.ack(e.id)), this.connected ? this.emitEvent(t) : this.receiveBuffer.push(Object.freeze(t));
1854
1731
  }
1855
- emitEvent(s) {
1732
+ emitEvent(e) {
1856
1733
  if (this._anyListeners && this._anyListeners.length) {
1857
- const e = this._anyListeners.slice();
1858
- for (const t of e)
1859
- t.apply(this, s);
1734
+ const t = this._anyListeners.slice();
1735
+ for (const s of t)
1736
+ s.apply(this, e);
1860
1737
  }
1861
- super.emit.apply(this, s), this._pid && s.length && typeof s[s.length - 1] == "string" && (this._lastOffset = s[s.length - 1]);
1738
+ super.emit.apply(this, e), this._pid && e.length && typeof e[e.length - 1] == "string" && (this._lastOffset = e[e.length - 1]);
1862
1739
  }
1863
1740
  /**
1864
1741
  * Produces an ack callback to emit with an event.
1865
1742
  *
1866
1743
  * @private
1867
1744
  */
1868
- ack(s) {
1869
- const e = this;
1870
- let t = !1;
1871
- return function(...n) {
1872
- t || (t = !0, e.packet({
1873
- type: l.ACK,
1874
- id: s,
1875
- data: n
1745
+ ack(e) {
1746
+ const t = this;
1747
+ let s = !1;
1748
+ return function(...i) {
1749
+ s || (s = !0, t.packet({
1750
+ type: h.ACK,
1751
+ id: e,
1752
+ data: i
1876
1753
  }));
1877
1754
  };
1878
1755
  }
@@ -1882,17 +1759,17 @@ let de = class extends _ {
1882
1759
  * @param packet
1883
1760
  * @private
1884
1761
  */
1885
- onack(s) {
1886
- const e = this.acks[s.id];
1887
- typeof e == "function" && (delete this.acks[s.id], e.withError && s.data.unshift(null), e.apply(this, s.data));
1762
+ onack(e) {
1763
+ const t = this.acks[e.id];
1764
+ typeof t == "function" && (delete this.acks[e.id], t.withError && e.data.unshift(null), t.apply(this, e.data));
1888
1765
  }
1889
1766
  /**
1890
1767
  * Called upon server connect.
1891
1768
  *
1892
1769
  * @private
1893
1770
  */
1894
- onconnect(s, e) {
1895
- this.id = s, this.recovered = e && this._pid === e, this._pid = e, this.connected = !0, this.emitBuffered(), this.emitReserved("connect"), this._drainQueue(!0);
1771
+ onconnect(e, t) {
1772
+ this.id = e, this.recovered = t && this._pid === t, this._pid = t, this.connected = !0, this.emitBuffered(), this.emitReserved("connect"), this._drainQueue(!0);
1896
1773
  }
1897
1774
  /**
1898
1775
  * Emit buffered events (received and emitted).
@@ -1900,8 +1777,8 @@ let de = class extends _ {
1900
1777
  * @private
1901
1778
  */
1902
1779
  emitBuffered() {
1903
- this.receiveBuffer.forEach((s) => this.emitEvent(s)), this.receiveBuffer = [], this.sendBuffer.forEach((s) => {
1904
- this.notifyOutgoingListeners(s), this.packet(s);
1780
+ this.receiveBuffer.forEach((e) => this.emitEvent(e)), this.receiveBuffer = [], this.sendBuffer.forEach((e) => {
1781
+ this.notifyOutgoingListeners(e), this.packet(e);
1905
1782
  }), this.sendBuffer = [];
1906
1783
  }
1907
1784
  /**
@@ -1920,7 +1797,7 @@ let de = class extends _ {
1920
1797
  * @private
1921
1798
  */
1922
1799
  destroy() {
1923
- this.subs && (this.subs.forEach((s) => s()), this.subs = void 0), this.io._destroy(this);
1800
+ this.subs && (this.subs.forEach((e) => e()), this.subs = void 0), this.io._destroy(this);
1924
1801
  }
1925
1802
  /**
1926
1803
  * Disconnects the socket manually. In that case, the socket will not try to reconnect.
@@ -1939,7 +1816,7 @@ let de = class extends _ {
1939
1816
  * @return self
1940
1817
  */
1941
1818
  disconnect() {
1942
- return this.connected && this.packet({ type: l.DISCONNECT }), this.destroy(), this.connected && this.onclose("io client disconnect"), this;
1819
+ return this.connected && this.packet({ type: h.DISCONNECT }), this.destroy(), this.connected && this.onclose("io client disconnect"), this;
1943
1820
  }
1944
1821
  /**
1945
1822
  * Alias for {@link disconnect()}.
@@ -1958,8 +1835,8 @@ let de = class extends _ {
1958
1835
  * @param compress - if `true`, compresses the sending data
1959
1836
  * @return self
1960
1837
  */
1961
- compress(s) {
1962
- return this.flags.compress = s, this;
1838
+ compress(e) {
1839
+ return this.flags.compress = e, this;
1963
1840
  }
1964
1841
  /**
1965
1842
  * Sets a modifier for a subsequent event emission that the event message will be dropped when this socket is not
@@ -1986,8 +1863,8 @@ let de = class extends _ {
1986
1863
  *
1987
1864
  * @returns self
1988
1865
  */
1989
- timeout(s) {
1990
- return this.flags.timeout = s, this;
1866
+ timeout(e) {
1867
+ return this.flags.timeout = e, this;
1991
1868
  }
1992
1869
  /**
1993
1870
  * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
@@ -2000,8 +1877,8 @@ let de = class extends _ {
2000
1877
  *
2001
1878
  * @param listener
2002
1879
  */
2003
- onAny(s) {
2004
- return this._anyListeners = this._anyListeners || [], this._anyListeners.push(s), this;
1880
+ onAny(e) {
1881
+ return this._anyListeners = this._anyListeners || [], this._anyListeners.push(e), this;
2005
1882
  }
2006
1883
  /**
2007
1884
  * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
@@ -2014,8 +1891,8 @@ let de = class extends _ {
2014
1891
  *
2015
1892
  * @param listener
2016
1893
  */
2017
- prependAny(s) {
2018
- return this._anyListeners = this._anyListeners || [], this._anyListeners.unshift(s), this;
1894
+ prependAny(e) {
1895
+ return this._anyListeners = this._anyListeners || [], this._anyListeners.unshift(e), this;
2019
1896
  }
2020
1897
  /**
2021
1898
  * Removes the listener that will be fired when any event is emitted.
@@ -2035,14 +1912,14 @@ let de = class extends _ {
2035
1912
  *
2036
1913
  * @param listener
2037
1914
  */
2038
- offAny(s) {
1915
+ offAny(e) {
2039
1916
  if (!this._anyListeners)
2040
1917
  return this;
2041
- if (s) {
2042
- const e = this._anyListeners;
2043
- for (let t = 0; t < e.length; t++)
2044
- if (s === e[t])
2045
- return e.splice(t, 1), this;
1918
+ if (e) {
1919
+ const t = this._anyListeners;
1920
+ for (let s = 0; s < t.length; s++)
1921
+ if (e === t[s])
1922
+ return t.splice(s, 1), this;
2046
1923
  } else
2047
1924
  this._anyListeners = [];
2048
1925
  return this;
@@ -2067,8 +1944,8 @@ let de = class extends _ {
2067
1944
  *
2068
1945
  * @param listener
2069
1946
  */
2070
- onAnyOutgoing(s) {
2071
- return this._anyOutgoingListeners = this._anyOutgoingListeners || [], this._anyOutgoingListeners.push(s), this;
1947
+ onAnyOutgoing(e) {
1948
+ return this._anyOutgoingListeners = this._anyOutgoingListeners || [], this._anyOutgoingListeners.push(e), this;
2072
1949
  }
2073
1950
  /**
2074
1951
  * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
@@ -2083,8 +1960,8 @@ let de = class extends _ {
2083
1960
  *
2084
1961
  * @param listener
2085
1962
  */
2086
- prependAnyOutgoing(s) {
2087
- return this._anyOutgoingListeners = this._anyOutgoingListeners || [], this._anyOutgoingListeners.unshift(s), this;
1963
+ prependAnyOutgoing(e) {
1964
+ return this._anyOutgoingListeners = this._anyOutgoingListeners || [], this._anyOutgoingListeners.unshift(e), this;
2088
1965
  }
2089
1966
  /**
2090
1967
  * Removes the listener that will be fired when any event is emitted.
@@ -2104,14 +1981,14 @@ let de = class extends _ {
2104
1981
  *
2105
1982
  * @param [listener] - the catch-all listener (optional)
2106
1983
  */
2107
- offAnyOutgoing(s) {
1984
+ offAnyOutgoing(e) {
2108
1985
  if (!this._anyOutgoingListeners)
2109
1986
  return this;
2110
- if (s) {
2111
- const e = this._anyOutgoingListeners;
2112
- for (let t = 0; t < e.length; t++)
2113
- if (s === e[t])
2114
- return e.splice(t, 1), this;
1987
+ if (e) {
1988
+ const t = this._anyOutgoingListeners;
1989
+ for (let s = 0; s < t.length; s++)
1990
+ if (e === t[s])
1991
+ return t.splice(s, 1), this;
2115
1992
  } else
2116
1993
  this._anyOutgoingListeners = [];
2117
1994
  return this;
@@ -2130,47 +2007,47 @@ let de = class extends _ {
2130
2007
  *
2131
2008
  * @private
2132
2009
  */
2133
- notifyOutgoingListeners(s) {
2010
+ notifyOutgoingListeners(e) {
2134
2011
  if (this._anyOutgoingListeners && this._anyOutgoingListeners.length) {
2135
- const e = this._anyOutgoingListeners.slice();
2136
- for (const t of e)
2137
- t.apply(this, s.data);
2012
+ const t = this._anyOutgoingListeners.slice();
2013
+ for (const s of t)
2014
+ s.apply(this, e.data);
2138
2015
  }
2139
2016
  }
2140
- };
2141
- function w(s) {
2142
- s = s || {}, this.ms = s.min || 100, this.max = s.max || 1e4, this.factor = s.factor || 2, this.jitter = s.jitter > 0 && s.jitter <= 1 ? s.jitter : 0, this.attempts = 0;
2017
+ }
2018
+ function w(n) {
2019
+ n = n || {}, this.ms = n.min || 100, this.max = n.max || 1e4, this.factor = n.factor || 2, this.jitter = n.jitter > 0 && n.jitter <= 1 ? n.jitter : 0, this.attempts = 0;
2143
2020
  }
2144
2021
  w.prototype.duration = function() {
2145
- var s = this.ms * Math.pow(this.factor, this.attempts++);
2022
+ var n = this.ms * Math.pow(this.factor, this.attempts++);
2146
2023
  if (this.jitter) {
2147
- var e = Math.random(), t = Math.floor(e * this.jitter * s);
2148
- s = (Math.floor(e * 10) & 1) == 0 ? s - t : s + t;
2024
+ var e = Math.random(), t = Math.floor(e * this.jitter * n);
2025
+ n = (Math.floor(e * 10) & 1) == 0 ? n - t : n + t;
2149
2026
  }
2150
- return Math.min(s, this.max) | 0;
2027
+ return Math.min(n, this.max) | 0;
2151
2028
  };
2152
2029
  w.prototype.reset = function() {
2153
2030
  this.attempts = 0;
2154
2031
  };
2155
- w.prototype.setMin = function(s) {
2156
- this.ms = s;
2032
+ w.prototype.setMin = function(n) {
2033
+ this.ms = n;
2157
2034
  };
2158
- w.prototype.setMax = function(s) {
2159
- this.max = s;
2035
+ w.prototype.setMax = function(n) {
2036
+ this.max = n;
2160
2037
  };
2161
- w.prototype.setJitter = function(s) {
2162
- this.jitter = s;
2038
+ w.prototype.setJitter = function(n) {
2039
+ this.jitter = n;
2163
2040
  };
2164
- class $ extends _ {
2041
+ class V extends _ {
2165
2042
  constructor(e, t) {
2166
- var n;
2167
- 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, L(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((n = t.randomizationFactor) !== null && n !== void 0 ? n : 0.5), this.backoff = new w({
2043
+ var s;
2044
+ 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, L(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 w({
2168
2045
  min: this.reconnectionDelay(),
2169
2046
  max: this.reconnectionDelayMax(),
2170
2047
  jitter: this.randomizationFactor()
2171
2048
  }), this.timeout(t.timeout == null ? 2e4 : t.timeout), this._readyState = "closed", this.uri = e;
2172
- const r = t.parser || ot;
2173
- this.encoder = new r.Encoder(), this.decoder = new r.Decoder(), this._autoConnect = t.autoConnect !== !1, this._autoConnect && this.open();
2049
+ const i = t.parser || ot;
2050
+ this.encoder = new i.Encoder(), this.decoder = new i.Decoder(), this._autoConnect = t.autoConnect !== !1, this._autoConnect && this.open();
2174
2051
  }
2175
2052
  reconnection(e) {
2176
2053
  return arguments.length ? (this._reconnection = !!e, e || (this.skipReconnect = !0), this) : this._reconnection;
@@ -2212,23 +2089,23 @@ class $ extends _ {
2212
2089
  open(e) {
2213
2090
  if (~this._readyState.indexOf("open"))
2214
2091
  return this;
2215
- this.engine = new Ye(this.uri, this.opts);
2216
- const t = this.engine, n = this;
2092
+ this.engine = new Je(this.uri, this.opts);
2093
+ const t = this.engine, s = this;
2217
2094
  this._readyState = "opening", this.skipReconnect = !1;
2218
- const r = f(t, "open", function() {
2219
- n.onopen(), e && e();
2220
- }), i = (h) => {
2221
- this.cleanup(), this._readyState = "closed", this.emitReserved("error", h), e ? e(h) : this.maybeReconnectOnOpen();
2222
- }, o = f(t, "error", i);
2095
+ const i = y(t, "open", function() {
2096
+ s.onopen(), e && e();
2097
+ }), r = (l) => {
2098
+ this.cleanup(), this._readyState = "closed", this.emitReserved("error", l), e ? e(l) : this.maybeReconnectOnOpen();
2099
+ }, o = y(t, "error", r);
2223
2100
  if (this._timeout !== !1) {
2224
- const h = this._timeout, c = this.setTimeoutFn(() => {
2225
- r(), i(new Error("timeout")), t.close();
2226
- }, h);
2101
+ const l = this._timeout, c = this.setTimeoutFn(() => {
2102
+ i(), r(new Error("timeout")), t.close();
2103
+ }, l);
2227
2104
  this.opts.autoUnref && c.unref(), this.subs.push(() => {
2228
2105
  this.clearTimeoutFn(c);
2229
2106
  });
2230
2107
  }
2231
- return this.subs.push(r), this.subs.push(o), this;
2108
+ return this.subs.push(i), this.subs.push(o), this;
2232
2109
  }
2233
2110
  /**
2234
2111
  * Alias for open()
@@ -2248,12 +2125,12 @@ class $ extends _ {
2248
2125
  this.cleanup(), this._readyState = "open", this.emitReserved("open");
2249
2126
  const e = this.engine;
2250
2127
  this.subs.push(
2251
- f(e, "ping", this.onping.bind(this)),
2252
- f(e, "data", this.ondata.bind(this)),
2253
- f(e, "error", this.onerror.bind(this)),
2254
- f(e, "close", this.onclose.bind(this)),
2128
+ y(e, "ping", this.onping.bind(this)),
2129
+ y(e, "data", this.ondata.bind(this)),
2130
+ y(e, "error", this.onerror.bind(this)),
2131
+ y(e, "close", this.onclose.bind(this)),
2255
2132
  // @ts-ignore
2256
- f(this.decoder, "decoded", this.ondecoded.bind(this))
2133
+ y(this.decoder, "decoded", this.ondecoded.bind(this))
2257
2134
  );
2258
2135
  }
2259
2136
  /**
@@ -2301,8 +2178,8 @@ class $ extends _ {
2301
2178
  * @public
2302
2179
  */
2303
2180
  socket(e, t) {
2304
- let n = this.nsps[e];
2305
- return n ? this._autoConnect && !n.active && n.connect() : (n = new de(this, e, t), this.nsps[e] = n), n;
2181
+ let s = this.nsps[e];
2182
+ return s ? this._autoConnect && !s.active && s.connect() : (s = new fe(this, e, t), this.nsps[e] = s), s;
2306
2183
  }
2307
2184
  /**
2308
2185
  * Called upon a socket close.
@@ -2312,8 +2189,8 @@ class $ extends _ {
2312
2189
  */
2313
2190
  _destroy(e) {
2314
2191
  const t = Object.keys(this.nsps);
2315
- for (const n of t)
2316
- if (this.nsps[n].active)
2192
+ for (const s of t)
2193
+ if (this.nsps[s].active)
2317
2194
  return;
2318
2195
  this._close();
2319
2196
  }
@@ -2325,8 +2202,8 @@ class $ extends _ {
2325
2202
  */
2326
2203
  _packet(e) {
2327
2204
  const t = this.encoder.encode(e);
2328
- for (let n = 0; n < t.length; n++)
2329
- this.engine.write(t[n], e.options);
2205
+ for (let s = 0; s < t.length; s++)
2206
+ this.engine.write(t[s], e.options);
2330
2207
  }
2331
2208
  /**
2332
2209
  * Clean up transport subscriptions and packet buffer.
@@ -2362,8 +2239,8 @@ class $ extends _ {
2362
2239
  * @private
2363
2240
  */
2364
2241
  onclose(e, t) {
2365
- var n;
2366
- this.cleanup(), (n = this.engine) === null || n === void 0 || n.close(), this.backoff.reset(), this._readyState = "closed", this.emitReserved("close", e, t), this._reconnection && !this.skipReconnect && this.reconnect();
2242
+ var s;
2243
+ this.cleanup(), (s = this.engine) === null || s === void 0 || s.close(), this.backoff.reset(), this._readyState = "closed", this.emitReserved("close", e, t), this._reconnection && !this.skipReconnect && this.reconnect();
2367
2244
  }
2368
2245
  /**
2369
2246
  * Attempt a reconnection.
@@ -2379,13 +2256,13 @@ class $ extends _ {
2379
2256
  else {
2380
2257
  const t = this.backoff.duration();
2381
2258
  this._reconnecting = !0;
2382
- const n = this.setTimeoutFn(() => {
2383
- e.skipReconnect || (this.emitReserved("reconnect_attempt", e.backoff.attempts), !e.skipReconnect && e.open((r) => {
2384
- r ? (e._reconnecting = !1, e.reconnect(), this.emitReserved("reconnect_error", r)) : e.onreconnect();
2259
+ const s = this.setTimeoutFn(() => {
2260
+ e.skipReconnect || (this.emitReserved("reconnect_attempt", e.backoff.attempts), !e.skipReconnect && e.open((i) => {
2261
+ i ? (e._reconnecting = !1, e.reconnect(), this.emitReserved("reconnect_error", i)) : e.onreconnect();
2385
2262
  }));
2386
2263
  }, t);
2387
- this.opts.autoUnref && n.unref(), this.subs.push(() => {
2388
- this.clearTimeoutFn(n);
2264
+ this.opts.autoUnref && s.unref(), this.subs.push(() => {
2265
+ this.clearTimeoutFn(s);
2389
2266
  });
2390
2267
  }
2391
2268
  }
@@ -2399,26 +2276,149 @@ class $ extends _ {
2399
2276
  this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect", e);
2400
2277
  }
2401
2278
  }
2402
- const k = {};
2403
- function B(s, e) {
2404
- typeof s == "object" && (e = s, s = void 0), e = e || {};
2405
- const t = Je(s, e.path || "/socket.io"), n = t.source, r = t.id, i = t.path, o = k[r] && i in k[r].nsps, h = e.forceNew || e["force new connection"] || e.multiplex === !1 || o;
2279
+ const E = {};
2280
+ function B(n, e) {
2281
+ typeof n == "object" && (e = n, n = void 0), e = e || {};
2282
+ const t = Qe(n, e.path || "/socket.io"), s = t.source, i = t.id, r = t.path, o = E[i] && r in E[i].nsps, l = e.forceNew || e["force new connection"] || e.multiplex === !1 || o;
2406
2283
  let c;
2407
- return h ? c = new $(n, e) : (k[r] || (k[r] = new $(n, e)), c = k[r]), t.query && !e.query && (e.query = t.queryKey), c.socket(t.path, e);
2284
+ return l ? c = new V(s, e) : (E[i] || (E[i] = new V(s, e)), c = E[i]), t.query && !e.query && (e.query = t.queryKey), c.socket(t.path, e);
2408
2285
  }
2409
2286
  Object.assign(B, {
2410
- Manager: $,
2411
- Socket: de,
2287
+ Manager: V,
2288
+ Socket: fe,
2412
2289
  io: B,
2413
2290
  connect: B
2414
2291
  });
2292
+ class Z extends CustomEvent {
2293
+ constructor(e, t) {
2294
+ super(e, t);
2295
+ }
2296
+ }
2297
+ class pe extends EventTarget {
2298
+ __listeners__ = {
2299
+ debug: !1
2300
+ };
2301
+ __debug__ = !1;
2302
+ __listenersCallbacks__ = [];
2303
+ dispatch(e, t = null) {
2304
+ const s = new Z(e, { detail: t });
2305
+ this.dispatchEvent(s), this.__debug__ && this.dispatchEvent(new Z("debug", { detail: { type: e, data: t } }));
2306
+ }
2307
+ dispatchAsync(e, t = null, s = 100) {
2308
+ const i = this;
2309
+ setTimeout(() => {
2310
+ i.dispatch(e, t);
2311
+ }, s);
2312
+ }
2313
+ on(e, t) {
2314
+ typeof this.__listeners__[e] < "u" && !this.__listeners__[e] && (this.__listeners__[e] = !0), this.__listenersCallbacks__.push({ key: e, callback: t }), this.addEventListener(e, t);
2315
+ }
2316
+ off(e, t) {
2317
+ this.__listenersCallbacks__ = this.__listenersCallbacks__.filter((s) => !(s.key === e && s.callback === t)), this.removeEventListener(e, t);
2318
+ }
2319
+ serialRegisterAvailableListener(e) {
2320
+ this.__listeners__[e] || (this.__listeners__[e] = !1);
2321
+ }
2322
+ get availableListeners() {
2323
+ return Object.keys(this.__listeners__).sort().map((e) => ({
2324
+ type: e,
2325
+ listening: this.__listeners__[e]
2326
+ }));
2327
+ }
2328
+ removeAllListeners() {
2329
+ for (const e of this.__listenersCallbacks__)
2330
+ ["internal:queue"].includes(e.key) || (this.__listenersCallbacks__ = this.__listenersCallbacks__.filter((t) => !(t.key === e.key && t.callback === e.callback)), this.removeEventListener(e.key, e.callback));
2331
+ for (const e of Object.keys(this.__listeners__))
2332
+ this.__listeners__[e] = !1;
2333
+ }
2334
+ }
2335
+ class a extends pe {
2336
+ static instance;
2337
+ static devices = {};
2338
+ constructor() {
2339
+ super(), ["change"].forEach((e) => {
2340
+ this.serialRegisterAvailableListener(e);
2341
+ });
2342
+ }
2343
+ static $dispatchChange(e = null) {
2344
+ e && e.$checkAndDispatchConnection(), a.instance.dispatch("change", { devices: a.devices, dispatcher: e });
2345
+ }
2346
+ static typeError(e) {
2347
+ const t = new Error();
2348
+ throw t.message = `Type ${e} is not supported`, t.name = "DeviceTypeError", t;
2349
+ }
2350
+ static registerType(e) {
2351
+ typeof a.devices[e] > "u" && (a.devices = { ...a.devices, [e]: {} });
2352
+ }
2353
+ static add(e) {
2354
+ const t = e.typeDevice;
2355
+ typeof a.devices[t] > "u" && a.registerType(t);
2356
+ const s = e.uuid;
2357
+ if (typeof a.devices[t] > "u" && a.typeError(t), a.devices[t][s])
2358
+ throw new Error(`Device with id ${s} already exists`);
2359
+ return a.devices[t][s] = e, a.$dispatchChange(e), Object.keys(a.devices[t]).indexOf(s);
2360
+ }
2361
+ static get(e, t) {
2362
+ return typeof a.devices[e] > "u" && a.registerType(e), typeof a.devices[e] > "u" && a.typeError(e), a.devices[e][t];
2363
+ }
2364
+ static getAll(e = null) {
2365
+ return e === null ? a.devices : (typeof a.devices[e] > "u" && a.typeError(e), a.devices[e]);
2366
+ }
2367
+ static getList() {
2368
+ return Object.values(a.devices).map((e) => Object.values(e)).flat();
2369
+ }
2370
+ static getByNumber(e, t) {
2371
+ return typeof a.devices[e] > "u" && a.typeError(e), Object.values(a.devices[e]).find((s) => s.deviceNumber === t) ?? null;
2372
+ }
2373
+ static getCustom(e, t = 1) {
2374
+ return typeof a.devices[e] > "u" && a.typeError(e), Object.values(a.devices[e]).find((s) => s.deviceNumber === t) ?? null;
2375
+ }
2376
+ static async connectToAll() {
2377
+ const e = a.getList();
2378
+ for (const t of e)
2379
+ t.isConnected || await t.connect().catch(console.warn);
2380
+ return Promise.resolve(a.areAllConnected());
2381
+ }
2382
+ static async disconnectAll() {
2383
+ const e = a.getList();
2384
+ for (const t of e)
2385
+ t.isDisconnected || await t.disconnect().catch(console.warn);
2386
+ return Promise.resolve(a.areAllDisconnected());
2387
+ }
2388
+ static async areAllConnected() {
2389
+ const e = a.getList();
2390
+ for (const t of e)
2391
+ if (!t.isConnected) return Promise.resolve(!1);
2392
+ return Promise.resolve(!0);
2393
+ }
2394
+ static async areAllDisconnected() {
2395
+ const e = a.getList();
2396
+ for (const t of e)
2397
+ if (!t.isDisconnected) return Promise.resolve(!1);
2398
+ return Promise.resolve(!0);
2399
+ }
2400
+ static async getAllConnected() {
2401
+ const e = a.getList();
2402
+ return Promise.resolve(e.filter((t) => t.isConnected));
2403
+ }
2404
+ static async getAllDisconnected() {
2405
+ const e = a.getList();
2406
+ return Promise.resolve(e.filter((t) => t.isDisconnected));
2407
+ }
2408
+ }
2409
+ a.instance || (a.instance = new a());
2410
+ function ee(n = 100) {
2411
+ return new Promise(
2412
+ (e) => setTimeout(() => e(), n)
2413
+ );
2414
+ }
2415
2415
  class ct {
2416
2416
  #t = "http://localhost:3000";
2417
2417
  #s = {
2418
2418
  transports: ["websocket"]
2419
2419
  };
2420
2420
  #e;
2421
- #i = !1;
2421
+ #r = !1;
2422
2422
  #o = {};
2423
2423
  set uri(e) {
2424
2424
  const t = new URL(e);
@@ -2441,10 +2441,10 @@ class ct {
2441
2441
  this.#o.onResponse = this.onResponse.bind(this);
2442
2442
  }
2443
2443
  disconnect() {
2444
- this.#e && (this.#e.off("response", this.#o.onResponse), this.#e.disconnect(), this.#e = null), this.#i = !1;
2444
+ this.#e && (this.#e.off("response", this.#o.onResponse), this.#e.disconnect(), this.#e = null), this.#r = !1;
2445
2445
  }
2446
2446
  prepare() {
2447
- this.#i || (this.#e = B(this.#t, this.#s), this.#i = !0, this.#e.on("response", this.#o.onResponse));
2447
+ this.#r || (this.#e = B(this.#t, this.#s), this.#r = !0, this.#e.on("response", this.#o.onResponse));
2448
2448
  }
2449
2449
  connectDevice(e) {
2450
2450
  this.#e.emit("connectDevice", { config: e });
@@ -2471,7 +2471,7 @@ const A = new ct(), q = {
2471
2471
  bufferSize: 32768,
2472
2472
  flowControl: "none"
2473
2473
  };
2474
- class lt extends te {
2474
+ class ht extends pe {
2475
2475
  __internal__ = {
2476
2476
  bypassSerialBytesConnection: !1,
2477
2477
  auto_response: !1,
@@ -2549,9 +2549,9 @@ class lt extends te {
2549
2549
  constructor({
2550
2550
  filters: e = null,
2551
2551
  config_port: t = q,
2552
- no_device: n = 1,
2553
- device_listen_on_channel: r = 1,
2554
- bypassSerialBytesConnection: i = !1,
2552
+ no_device: s = 1,
2553
+ device_listen_on_channel: i = 1,
2554
+ bypassSerialBytesConnection: r = !1,
2555
2555
  socket: o = !1
2556
2556
  } = {
2557
2557
  filters: null,
@@ -2563,7 +2563,7 @@ class lt extends te {
2563
2563
  }) {
2564
2564
  if (super(), !("serial" in navigator))
2565
2565
  throw new Error("Web Serial not supported");
2566
- e && (this.serialFilters = e), t && (this.serialConfigPort = t), i && (this.__internal__.bypassSerialBytesConnection = i), n && this.#w(n), r && ["number", "string"].includes(typeof r) && (this.listenOnChannel = r), this.__internal__.serial.socket = o, this.#y(), this.#g();
2566
+ e && (this.serialFilters = e), t && (this.serialConfigPort = t), r && (this.__internal__.bypassSerialBytesConnection = r), s && this.#w(s), i && ["number", "string"].includes(typeof i) && (this.listenOnChannel = i), this.__internal__.serial.socket = o, this.#y(), this.#g();
2567
2567
  }
2568
2568
  set listenOnChannel(e) {
2569
2569
  if (typeof e == "string" && (e = parseInt(e)), isNaN(e) || e < 1 || e > 255)
@@ -2605,7 +2605,7 @@ class lt extends te {
2605
2605
  }
2606
2606
  get isDisconnected() {
2607
2607
  const e = this.__internal__.serial.connected, t = this.#s(this.__internal__.serial.port);
2608
- return !e && t && (this.dispatch("serial:connected"), this.#r(!1), a.$dispatchChange(this)), this.__internal__.serial.connected = t, !this.__internal__.serial.connected;
2608
+ return !e && t && (this.dispatch("serial:connected"), this.#i(!1), a.$dispatchChange(this)), this.__internal__.serial.connected = t, !this.__internal__.serial.connected;
2609
2609
  }
2610
2610
  get deviceNumber() {
2611
2611
  return this.__internal__.device_number;
@@ -2794,24 +2794,24 @@ class lt extends te {
2794
2794
  #e(e = null) {
2795
2795
  this.__internal__.serial.connected = !1, this.__internal__.aux_port_connector = 0, this.dispatch("serial:disconnected", e), a.$dispatchChange(this);
2796
2796
  }
2797
- #i(e) {
2797
+ #r(e) {
2798
2798
  this.__internal__.serial.aux_connecting = e.detail.active ? "connecting" : "finished";
2799
2799
  }
2800
2800
  socketResponse(e) {
2801
2801
  const t = this.__internal__.serial.connected;
2802
- if (e.type === "disconnect" || e.type === "error" && e.data === "DISCONNECTED" ? this.__internal__.serial.connected = !1 : e.type === "success" && (this.__internal__.serial.connected = !0), a.$dispatchChange(this), !t && this.__internal__.serial.connected && (this.dispatch("serial:connected"), this.#r(!1)), e.type === "success")
2802
+ if (e.type === "disconnect" || e.type === "error" && e.data === "DISCONNECTED" ? this.__internal__.serial.connected = !1 : e.type === "success" && (this.__internal__.serial.connected = !0), a.$dispatchChange(this), !t && this.__internal__.serial.connected && (this.dispatch("serial:connected"), this.#i(!1)), e.type === "success")
2803
2803
  this.#n(new Uint8Array(e.data));
2804
2804
  else if (e.type === "error") {
2805
- const n = new Error("The port is closed or is not readable/writable");
2806
- this.serialErrors(n);
2805
+ const s = new Error("The port is closed or is not readable/writable");
2806
+ this.serialErrors(s);
2807
2807
  } else e.type === "timeout" && this.timeout(e.data.bytes ?? [], this.lastAction || "unknown");
2808
2808
  this.__internal__.serial.last_action = null;
2809
2809
  }
2810
2810
  async connect() {
2811
2811
  return this.isConnected ? !0 : (this.__internal__.serial.aux_connecting = "idle", new Promise((e, t) => {
2812
- this.#t || (this.#t = this.#i.bind(this)), this.on("internal:connecting", this.#t);
2813
- const n = setInterval(() => {
2814
- this.__internal__.serial.aux_connecting === "finished" ? (clearInterval(n), this.__internal__.serial.aux_connecting = "idle", this.#t !== null && this.off("internal:connecting", this.#t), this.isConnected ? e(!0) : t(`${this.typeDevice} device ${this.deviceNumber} not connected`)) : this.__internal__.serial.aux_connecting === "connecting" && (this.__internal__.serial.aux_connecting = "idle", this.dispatch("internal:connecting", { active: !0 }), this.dispatch("serial:connecting", { active: !0 }));
2812
+ this.#t || (this.#t = this.#r.bind(this)), this.on("internal:connecting", this.#t);
2813
+ const s = setInterval(() => {
2814
+ this.__internal__.serial.aux_connecting === "finished" ? (clearInterval(s), this.__internal__.serial.aux_connecting = "idle", this.#t !== null && this.off("internal:connecting", this.#t), this.isConnected ? e(!0) : t(`${this.typeDevice} device ${this.deviceNumber} not connected`)) : this.__internal__.serial.aux_connecting === "connecting" && (this.__internal__.serial.aux_connecting = "idle", this.dispatch("internal:connecting", { active: !0 }), this.dispatch("serial:connecting", { active: !0 }));
2815
2815
  }, 100);
2816
2816
  this.serialConnect();
2817
2817
  }));
@@ -2822,7 +2822,7 @@ class lt extends te {
2822
2822
  A.disconnectDevice(this.configDeviceSocket);
2823
2823
  else {
2824
2824
  const e = this.__internal__.serial.reader, t = this.__internal__.serial.output_stream;
2825
- e && (await e.cancel().catch((n) => this.serialErrors(n)), await this.__internal__.serial.input_done), t && (await t.getWriter().close(), await this.__internal__.serial.output_done), this.__internal__.serial.connected && this.__internal__.serial && this.__internal__.serial.port && await this.__internal__.serial.port.close();
2825
+ e && (await e.cancel().catch((s) => this.serialErrors(s)), await this.__internal__.serial.input_done), t && (await t.getWriter().close(), await this.__internal__.serial.output_done), this.__internal__.serial.connected && this.__internal__.serial && this.__internal__.serial.port && await this.__internal__.serial.port.close();
2826
2826
  }
2827
2827
  } catch (e) {
2828
2828
  this.serialErrors(e);
@@ -2844,39 +2844,39 @@ class lt extends te {
2844
2844
  const t = this.__internal__.serial.port;
2845
2845
  if (!t || t && (!t.readable || !t.writable))
2846
2846
  throw this.#e({ error: "Port is closed, not readable or writable." }), new Error("The port is closed or is not readable/writable");
2847
- const n = this.validateBytes(e);
2847
+ const s = this.validateBytes(e);
2848
2848
  if (this.useRTSCTS && await this.#c(t, 5e3), t.writable === null) return;
2849
- const r = t.writable.getWriter();
2850
- await r.write(n), r.releaseLock();
2849
+ const i = t.writable.getWriter();
2850
+ await i.write(s), i.releaseLock();
2851
2851
  }
2852
2852
  async #c(e, t = 5e3) {
2853
- const n = Date.now();
2853
+ const s = Date.now();
2854
2854
  for (; ; ) {
2855
- if (Date.now() - n > t)
2855
+ if (Date.now() - s > t)
2856
2856
  throw new Error("Timeout waiting for clearToSend signal");
2857
- const { clearToSend: r } = await e.getSignals();
2858
- if (r) return;
2859
- await J(100);
2857
+ const { clearToSend: i } = await e.getSignals();
2858
+ if (i) return;
2859
+ await ee(100);
2860
2860
  }
2861
2861
  }
2862
2862
  #n(e = new Uint8Array([]), t = !1) {
2863
2863
  if (e && e.length > 0) {
2864
- const n = this.__internal__.serial.connected;
2865
- if (this.__internal__.serial.connected = this.#s(this.__internal__.serial.port), a.$dispatchChange(this), !n && this.__internal__.serial.connected && (this.dispatch("serial:connected"), this.#r(!1)), this.__internal__.interval.reconnection && (clearInterval(this.__internal__.interval.reconnection), this.__internal__.interval.reconnection = 0), this.__internal__.timeout.until_response && (clearTimeout(this.__internal__.timeout.until_response), this.__internal__.timeout.until_response = 0), this.__internal__.serial.response.as === "hex")
2864
+ const s = this.__internal__.serial.connected;
2865
+ if (this.__internal__.serial.connected = this.#s(this.__internal__.serial.port), a.$dispatchChange(this), !s && this.__internal__.serial.connected && (this.dispatch("serial:connected"), this.#i(!1)), this.__internal__.interval.reconnection && (clearInterval(this.__internal__.interval.reconnection), this.__internal__.interval.reconnection = 0), this.__internal__.timeout.until_response && (clearTimeout(this.__internal__.timeout.until_response), this.__internal__.timeout.until_response = 0), this.__internal__.serial.response.as === "hex")
2866
2866
  t ? this.serialCorruptMessage(this.parseUint8ToHex(e)) : this.serialMessage(this.parseUint8ToHex(e));
2867
2867
  else if (this.__internal__.serial.response.as === "uint8")
2868
2868
  t ? this.serialCorruptMessage(e) : this.serialMessage(e);
2869
2869
  else if (this.__internal__.serial.response.as === "string") {
2870
- const r = this.parseUint8ArrayToString(e);
2870
+ const i = this.parseUint8ArrayToString(e);
2871
2871
  if (this.__internal__.serial.response.limiter !== null) {
2872
- const i = r.split(this.__internal__.serial.response.limiter);
2873
- for (const o in i)
2874
- i[o] && (t ? this.serialCorruptMessage(i[o]) : this.serialMessage(i[o]));
2872
+ const r = i.split(this.__internal__.serial.response.limiter);
2873
+ for (const o in r)
2874
+ r[o] && (t ? this.serialCorruptMessage(r[o]) : this.serialMessage(r[o]));
2875
2875
  } else
2876
- t ? this.serialCorruptMessage(r) : this.serialMessage(r);
2876
+ t ? this.serialCorruptMessage(i) : this.serialMessage(i);
2877
2877
  } else {
2878
- const r = this.stringToArrayBuffer(this.parseUint8ArrayToString(e));
2879
- t ? this.serialCorruptMessage(r) : this.serialMessage(r);
2878
+ const i = this.stringToArrayBuffer(this.parseUint8ArrayToString(e));
2879
+ t ? this.serialCorruptMessage(i) : this.serialMessage(i);
2880
2880
  }
2881
2881
  }
2882
2882
  if (this.__internal__.serial.queue.length === 0) {
@@ -2899,16 +2899,16 @@ class lt extends te {
2899
2899
  }
2900
2900
  async #l() {
2901
2901
  const e = this.serialFilters, t = await navigator.serial.getPorts({ filters: e });
2902
- return e.length === 0 ? t : t.filter((n) => {
2903
- const r = n.getInfo();
2904
- return e.some((i) => r.usbProductId === i.usbProductId && r.usbVendorId === i.usbVendorId);
2905
- }).filter((n) => !this.#s(n));
2902
+ return e.length === 0 ? t : t.filter((s) => {
2903
+ const i = s.getInfo();
2904
+ return e.some((r) => i.usbProductId === r.usbProductId && i.usbVendorId === r.usbVendorId);
2905
+ }).filter((s) => !this.#s(s));
2906
2906
  }
2907
2907
  async serialPortsSaved(e) {
2908
2908
  const t = this.serialFilters;
2909
2909
  if (this.__internal__.aux_port_connector < e.length) {
2910
- const n = this.__internal__.aux_port_connector;
2911
- this.__internal__.serial.port = e[n];
2910
+ const s = this.__internal__.aux_port_connector;
2911
+ this.__internal__.serial.port = e[s];
2912
2912
  } else
2913
2913
  this.__internal__.aux_port_connector = 0, this.__internal__.serial.port = await navigator.serial.requestPort({
2914
2914
  filters: t
@@ -2965,8 +2965,8 @@ class lt extends te {
2965
2965
  }
2966
2966
  #h(e) {
2967
2967
  if (e) {
2968
- const t = this.__internal__.serial.response.buffer, n = new Uint8Array(t.length + e.byteLength);
2969
- n.set(t, 0), n.set(new Uint8Array(e), t.length), this.__internal__.serial.response.buffer = n;
2968
+ const t = this.__internal__.serial.response.buffer, s = new Uint8Array(t.length + e.byteLength);
2969
+ s.set(t, 0), s.set(new Uint8Array(e), t.length), this.__internal__.serial.response.buffer = s;
2970
2970
  }
2971
2971
  }
2972
2972
  async #u() {
@@ -2979,91 +2979,91 @@ class lt extends te {
2979
2979
  let t = this.__internal__.serial.response.buffer;
2980
2980
  if (this.__internal__.serial.time_until_send_bytes && (clearTimeout(this.__internal__.serial.time_until_send_bytes), this.__internal__.serial.time_until_send_bytes = 0), !(e === null || !t || t.length === 0)) {
2981
2981
  for (; t.length >= e; ) {
2982
- const n = t.slice(0, e);
2983
- this.#n(n), t = t.slice(e);
2982
+ const s = t.slice(0, e);
2983
+ this.#n(s), t = t.slice(e);
2984
2984
  }
2985
2985
  this.__internal__.serial.response.buffer = t, t.length > 0 && (this.__internal__.serial.time_until_send_bytes = setTimeout(() => {
2986
2986
  this.#n(this.__internal__.serial.response.buffer, !0);
2987
2987
  }, this.__internal__.serial.free_timeout_ms || 50));
2988
2988
  }
2989
2989
  }
2990
- async #p() {
2990
+ async #f() {
2991
2991
  const {
2992
2992
  limiter: e,
2993
2993
  prefixLimiter: t = !1,
2994
- sufixLimiter: n = !0
2994
+ sufixLimiter: s = !0
2995
2995
  } = this.__internal__.serial.response;
2996
2996
  if (!e)
2997
2997
  throw new Error("No limiter defined for delimited serial response");
2998
- const r = this.__internal__.serial.response.buffer;
2999
- if (!e || !r || r.length === 0) return;
2998
+ const i = this.__internal__.serial.response.buffer;
2999
+ if (!e || !i || i.length === 0) return;
3000
3000
  this.__internal__.serial.time_until_send_bytes && (clearTimeout(this.__internal__.serial.time_until_send_bytes), this.__internal__.serial.time_until_send_bytes = 0);
3001
- let i = new TextDecoder().decode(r);
3001
+ let r = new TextDecoder().decode(i);
3002
3002
  const o = [];
3003
3003
  if (typeof e == "string") {
3004
3004
  let c;
3005
- if (t && n)
3005
+ if (t && s)
3006
3006
  c = new RegExp(`${e}([^${e}]+)${e}`, "g");
3007
3007
  else if (t)
3008
3008
  c = new RegExp(`${e}([^${e}]*)`, "g");
3009
- else if (n)
3009
+ else if (s)
3010
3010
  c = new RegExp(`([^${e}]+)${e}`, "g");
3011
3011
  else
3012
3012
  return;
3013
- let p, u = 0;
3014
- for (; (p = c.exec(i)) !== null; )
3015
- o.push(new TextEncoder().encode(p[1])), u = c.lastIndex;
3016
- i = i.slice(u);
3013
+ let f, u = 0;
3014
+ for (; (f = c.exec(r)) !== null; )
3015
+ o.push(new TextEncoder().encode(f[1])), u = c.lastIndex;
3016
+ r = r.slice(u);
3017
3017
  } else if (e instanceof RegExp) {
3018
- let c, p = 0;
3019
- if (t && n) {
3018
+ let c, f = 0;
3019
+ if (t && s) {
3020
3020
  const u = new RegExp(`${e.source}(.*?)${e.source}`, "g");
3021
- for (; (c = u.exec(i)) !== null; )
3022
- o.push(new TextEncoder().encode(c[1])), p = u.lastIndex;
3023
- } else if (n)
3024
- for (; (c = e.exec(i)) !== null; ) {
3025
- const u = c.index, y = i.slice(p, u);
3026
- o.push(new TextEncoder().encode(y)), p = e.lastIndex;
3021
+ for (; (c = u.exec(r)) !== null; )
3022
+ o.push(new TextEncoder().encode(c[1])), f = u.lastIndex;
3023
+ } else if (s)
3024
+ for (; (c = e.exec(r)) !== null; ) {
3025
+ const u = c.index, p = r.slice(f, u);
3026
+ o.push(new TextEncoder().encode(p)), f = e.lastIndex;
3027
3027
  }
3028
3028
  else if (t) {
3029
- const u = i.split(e);
3029
+ const u = r.split(e);
3030
3030
  u.shift();
3031
- for (const y of u)
3032
- o.push(new TextEncoder().encode(y));
3033
- i = "";
3031
+ for (const p of u)
3032
+ o.push(new TextEncoder().encode(p));
3033
+ r = "";
3034
3034
  }
3035
- i = i.slice(p);
3035
+ r = r.slice(f);
3036
3036
  }
3037
3037
  for (const c of o)
3038
3038
  this.#n(c);
3039
- const h = new TextEncoder().encode(i);
3040
- this.__internal__.serial.response.buffer = h, h.length > 0 && (this.__internal__.serial.time_until_send_bytes = setTimeout(() => {
3039
+ const l = new TextEncoder().encode(r);
3040
+ this.__internal__.serial.response.buffer = l, l.length > 0 && (this.__internal__.serial.time_until_send_bytes = setTimeout(() => {
3041
3041
  this.#n(this.__internal__.serial.response.buffer, !0), this.__internal__.serial.response.buffer = new Uint8Array(0);
3042
3042
  }, this.__internal__.serial.free_timeout_ms ?? 50));
3043
3043
  }
3044
- async #d() {
3044
+ async #p() {
3045
3045
  const e = this.__internal__.serial.port;
3046
3046
  if (!e || !e.readable) throw new Error("Port is not readable");
3047
3047
  const t = e.readable.getReader();
3048
3048
  this.__internal__.serial.reader = t;
3049
3049
  try {
3050
3050
  for (; this.__internal__.serial.keep_reading; ) {
3051
- const { value: n, done: r } = await t.read();
3052
- if (r) break;
3053
- this.#h(n), this.__internal__.serial.response.delimited ? await this.#p() : this.__internal__.serial.response.length === null ? await this.#u() : await this.#_();
3051
+ const { value: s, done: i } = await t.read();
3052
+ if (i) break;
3053
+ this.#h(s), this.__internal__.serial.response.delimited ? await this.#f() : this.__internal__.serial.response.length === null ? await this.#u() : await this.#_();
3054
3054
  }
3055
- } catch (n) {
3056
- this.serialErrors(n);
3055
+ } catch (s) {
3056
+ this.serialErrors(s);
3057
3057
  } finally {
3058
3058
  t.releaseLock(), this.__internal__.serial.keep_reading = !0, this.__internal__.serial.port && await this.__internal__.serial.port.close();
3059
3059
  }
3060
3060
  }
3061
- #r(e) {
3061
+ #i(e) {
3062
3062
  e !== this.__internal__.serial.connecting && (this.__internal__.serial.connecting = e, this.dispatch("serial:connecting", { active: e }), this.dispatch("internal:connecting", { active: e }));
3063
3063
  }
3064
3064
  async serialConnect() {
3065
3065
  try {
3066
- if (this.#r(!0), this.useSocket)
3066
+ if (this.#i(!0), this.useSocket)
3067
3067
  A.prepare(), this.__internal__.serial.last_action = "connect", this.__internal__.timeout.until_response = setTimeout(async () => {
3068
3068
  await this.timeout(this.__internal__.serial.bytes_connection ?? [], "connection:start");
3069
3069
  }, this.__internal__.time.response_connection), A.connectDevice(this.configDeviceSocket), this.dispatch("serial:sent", {
@@ -3075,36 +3075,36 @@ class lt extends te {
3075
3075
  if (e.length > 0)
3076
3076
  await this.serialPortsSaved(e);
3077
3077
  else {
3078
- const r = this.serialFilters;
3078
+ const i = this.serialFilters;
3079
3079
  this.__internal__.serial.port = await navigator.serial.requestPort({
3080
- filters: r
3080
+ filters: i
3081
3081
  });
3082
3082
  }
3083
3083
  const t = this.__internal__.serial.port;
3084
3084
  if (!t)
3085
3085
  throw new Error("No port selected by the user");
3086
3086
  await t.open(this.serialConfigPort);
3087
- const n = this;
3088
- t.onconnect = (r) => {
3089
- n.dispatch("serial:connected", r), n.#r(!1), a.$dispatchChange(this), n.__internal__.serial.queue.length > 0 ? n.dispatch("internal:queue", {}) : n.__internal__.serial.running_queue = !1;
3087
+ const s = this;
3088
+ t.onconnect = (i) => {
3089
+ s.dispatch("serial:connected", i), s.#i(!1), a.$dispatchChange(this), s.__internal__.serial.queue.length > 0 ? s.dispatch("internal:queue", {}) : s.__internal__.serial.running_queue = !1;
3090
3090
  }, t.ondisconnect = async () => {
3091
- await n.disconnect();
3092
- }, await J(this.__internal__.serial.delay_first_connection), this.__internal__.timeout.until_response = setTimeout(async () => {
3093
- await n.timeout(n.__internal__.serial.bytes_connection ?? [], "connection:start");
3091
+ await s.disconnect();
3092
+ }, await ee(this.__internal__.serial.delay_first_connection), this.__internal__.timeout.until_response = setTimeout(async () => {
3093
+ await s.timeout(s.__internal__.serial.bytes_connection ?? [], "connection:start");
3094
3094
  }, this.__internal__.time.response_connection), this.__internal__.serial.last_action = "connect", await this.#a(this.__internal__.serial.bytes_connection ?? []), this.dispatch("serial:sent", {
3095
3095
  action: "connect",
3096
3096
  bytes: this.__internal__.serial.bytes_connection
3097
- }), this.__internal__.auto_response && this.#n(this.__internal__.serial.auto_response), await this.#d();
3097
+ }), this.__internal__.auto_response && this.#n(this.__internal__.serial.auto_response), await this.#p();
3098
3098
  }
3099
3099
  } catch (e) {
3100
- this.#r(!1), this.serialErrors(e);
3100
+ this.#i(!1), this.serialErrors(e);
3101
3101
  }
3102
3102
  }
3103
- async #f() {
3103
+ async #d() {
3104
3104
  return typeof window > "u" ? !1 : "serial" in navigator && "forget" in SerialPort.prototype && this.__internal__.serial.port ? (await this.__internal__.serial.port.forget(), !0) : !1;
3105
3105
  }
3106
3106
  async serialForget() {
3107
- return await this.#f();
3107
+ return await this.#d();
3108
3108
  }
3109
3109
  decToHex(e) {
3110
3110
  return typeof e == "string" && (e = parseInt(e, 10)), e.toString(16);
@@ -3117,8 +3117,8 @@ class lt extends te {
3117
3117
  }
3118
3118
  add0x(e) {
3119
3119
  const t = [];
3120
- return e.forEach((n, r) => {
3121
- t[r] = "0x" + n;
3120
+ return e.forEach((s, i) => {
3121
+ t[i] = "0x" + s;
3122
3122
  }), t;
3123
3123
  }
3124
3124
  bytesToHex(e) {
@@ -3177,16 +3177,16 @@ class lt extends te {
3177
3177
  action: e.action,
3178
3178
  bytes: e.bytes
3179
3179
  }), this.__internal__.auto_response) {
3180
- let r = new Uint8Array(0);
3180
+ let i = new Uint8Array(0);
3181
3181
  try {
3182
- r = this.validateBytes(this.__internal__.serial.auto_response);
3183
- } catch (i) {
3184
- this.serialErrors(i);
3182
+ i = this.validateBytes(this.__internal__.serial.auto_response);
3183
+ } catch (r) {
3184
+ this.serialErrors(r);
3185
3185
  }
3186
- this.#n(r);
3186
+ this.#n(i);
3187
3187
  }
3188
- const n = [...this.__internal__.serial.queue];
3189
- this.__internal__.serial.queue = n.splice(1), this.__internal__.serial.queue.length > 0 && (this.__internal__.serial.running_queue = !0);
3188
+ const s = [...this.__internal__.serial.queue];
3189
+ this.__internal__.serial.queue = s.splice(1), this.__internal__.serial.queue.length > 0 && (this.__internal__.serial.running_queue = !0);
3190
3190
  }
3191
3191
  validateBytes(e) {
3192
3192
  let t = new Uint8Array(0);
@@ -3203,13 +3203,13 @@ class lt extends te {
3203
3203
  return t;
3204
3204
  }
3205
3205
  async appendToQueue(e, t) {
3206
- const n = this.validateBytes(e);
3206
+ const s = this.validateBytes(e);
3207
3207
  if (["connect", "connection:start"].includes(t)) {
3208
3208
  if (this.__internal__.serial.connected) return;
3209
3209
  await this.serialConnect();
3210
3210
  return;
3211
3211
  }
3212
- this.__internal__.serial.queue.push({ bytes: n, action: t }), this.dispatch("internal:queue", {});
3212
+ this.__internal__.serial.queue.push({ bytes: s, action: t }), this.dispatch("internal:queue", {});
3213
3213
  }
3214
3214
  #w(e = 1) {
3215
3215
  this.__internal__.device_number = e, !this.__internal__.bypassSerialBytesConnection && (this.__internal__.serial.bytes_connection = this.serialSetConnectionConstant(e));
@@ -3237,8 +3237,8 @@ class lt extends te {
3237
3237
  }
3238
3238
  sumHex(e) {
3239
3239
  let t = 0;
3240
- return e.forEach((n) => {
3241
- t += parseInt(n, 16);
3240
+ return e.forEach((s) => {
3241
+ t += parseInt(s, 16);
3242
3242
  }), t.toString(16);
3243
3243
  }
3244
3244
  toString() {
@@ -3272,13 +3272,13 @@ class lt extends te {
3272
3272
  }
3273
3273
  parseStringToTextEncoder(e = "", t = `
3274
3274
  `) {
3275
- const n = new TextEncoder();
3276
- return e += t, n.encode(e);
3275
+ const s = new TextEncoder();
3276
+ return e += t, s.encode(e);
3277
3277
  }
3278
3278
  parseStringToBytes(e = "", t = `
3279
3279
  `) {
3280
- const n = this.parseStringToTextEncoder(e, t);
3281
- return Array.from(n).map((r) => r.toString(16));
3280
+ const s = this.parseStringToTextEncoder(e, t);
3281
+ return Array.from(s).map((i) => i.toString(16));
3282
3282
  }
3283
3283
  parseUint8ToHex(e) {
3284
3284
  return Array.from(e).map((t) => t.toString(16).padStart(2, "0").toLowerCase());
@@ -3288,29 +3288,29 @@ class lt extends te {
3288
3288
  }
3289
3289
  stringArrayToUint8Array(e) {
3290
3290
  const t = [];
3291
- return typeof e == "string" ? this.parseStringToTextEncoder(e).buffer : (e.forEach((n) => {
3292
- const r = n.replace("0x", "");
3293
- t.push(parseInt(r, 16));
3291
+ return typeof e == "string" ? this.parseStringToTextEncoder(e).buffer : (e.forEach((s) => {
3292
+ const i = s.replace("0x", "");
3293
+ t.push(parseInt(i, 16));
3294
3294
  }), new Uint8Array(t));
3295
3295
  }
3296
3296
  parseUint8ArrayToString(e) {
3297
3297
  let t = new Uint8Array(0);
3298
3298
  e instanceof Uint8Array ? t = e : t = this.stringArrayToUint8Array(e), e = this.parseUint8ToHex(t);
3299
- const n = e.map((r) => parseInt(r, 16));
3300
- return this.__internal__.serial.response.replacer ? String.fromCharCode(...n).replace(this.__internal__.serial.response.replacer, "") : String.fromCharCode(...n);
3299
+ const s = e.map((i) => parseInt(i, 16));
3300
+ return this.__internal__.serial.response.replacer ? String.fromCharCode(...s).replace(this.__internal__.serial.response.replacer, "") : String.fromCharCode(...s);
3301
3301
  }
3302
3302
  hexToAscii(e) {
3303
3303
  const t = e.toString();
3304
- let n = "";
3305
- for (let r = 0; r < t.length; r += 2)
3306
- n += String.fromCharCode(parseInt(t.substring(r, 2), 16));
3307
- return n;
3304
+ let s = "";
3305
+ for (let i = 0; i < t.length; i += 2)
3306
+ s += String.fromCharCode(parseInt(t.substring(i, 2), 16));
3307
+ return s;
3308
3308
  }
3309
3309
  asciiToHex(e) {
3310
3310
  const t = [];
3311
- for (let n = 0, r = e.length; n < r; n++) {
3312
- const i = Number(e.charCodeAt(n)).toString(16);
3313
- t.push(i);
3311
+ for (let s = 0, i = e.length; s < i; s++) {
3312
+ const r = Number(e.charCodeAt(s)).toString(16);
3313
+ t.push(r);
3314
3314
  }
3315
3315
  return t.join("");
3316
3316
  }
@@ -3319,7 +3319,7 @@ class lt extends te {
3319
3319
  }
3320
3320
  }
3321
3321
  export {
3322
- A,
3323
- a,
3324
- lt as u
3322
+ a as s,
3323
+ A as u,
3324
+ ht as v
3325
3325
  };