@aiqa/sdk 0.0.0 → 0.0.2

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.
@@ -0,0 +1,3398 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // node_modules/engine.io-parser/build/esm/commons.js
8
+ var PACKET_TYPES = /* @__PURE__ */ Object.create(null);
9
+ PACKET_TYPES["open"] = "0";
10
+ PACKET_TYPES["close"] = "1";
11
+ PACKET_TYPES["ping"] = "2";
12
+ PACKET_TYPES["pong"] = "3";
13
+ PACKET_TYPES["message"] = "4";
14
+ PACKET_TYPES["upgrade"] = "5";
15
+ PACKET_TYPES["noop"] = "6";
16
+ var PACKET_TYPES_REVERSE = /* @__PURE__ */ Object.create(null);
17
+ Object.keys(PACKET_TYPES).forEach((key) => {
18
+ PACKET_TYPES_REVERSE[PACKET_TYPES[key]] = key;
19
+ });
20
+ var ERROR_PACKET = { type: "error", data: "parser error" };
21
+
22
+ // node_modules/engine.io-parser/build/esm/encodePacket.browser.js
23
+ var withNativeBlob = typeof Blob === "function" || typeof Blob !== "undefined" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]";
24
+ var withNativeArrayBuffer = typeof ArrayBuffer === "function";
25
+ var isView = (obj) => {
26
+ return typeof ArrayBuffer.isView === "function" ? ArrayBuffer.isView(obj) : obj && obj.buffer instanceof ArrayBuffer;
27
+ };
28
+ var encodePacket = ({ type, data }, supportsBinary, callback) => {
29
+ if (withNativeBlob && data instanceof Blob) {
30
+ if (supportsBinary) {
31
+ return callback(data);
32
+ } else {
33
+ return encodeBlobAsBase64(data, callback);
34
+ }
35
+ } else if (withNativeArrayBuffer && (data instanceof ArrayBuffer || isView(data))) {
36
+ if (supportsBinary) {
37
+ return callback(data);
38
+ } else {
39
+ return encodeBlobAsBase64(new Blob([data]), callback);
40
+ }
41
+ }
42
+ return callback(PACKET_TYPES[type] + (data || ""));
43
+ };
44
+ var encodeBlobAsBase64 = (data, callback) => {
45
+ const fileReader = new FileReader();
46
+ fileReader.onload = function() {
47
+ const content = fileReader.result.split(",")[1];
48
+ callback("b" + (content || ""));
49
+ };
50
+ return fileReader.readAsDataURL(data);
51
+ };
52
+ function toArray(data) {
53
+ if (data instanceof Uint8Array) {
54
+ return data;
55
+ } else if (data instanceof ArrayBuffer) {
56
+ return new Uint8Array(data);
57
+ } else {
58
+ return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
59
+ }
60
+ }
61
+ var TEXT_ENCODER;
62
+ function encodePacketToBinary(packet, callback) {
63
+ if (withNativeBlob && packet.data instanceof Blob) {
64
+ return packet.data.arrayBuffer().then(toArray).then(callback);
65
+ } else if (withNativeArrayBuffer && (packet.data instanceof ArrayBuffer || isView(packet.data))) {
66
+ return callback(toArray(packet.data));
67
+ }
68
+ encodePacket(packet, false, (encoded) => {
69
+ if (!TEXT_ENCODER) {
70
+ TEXT_ENCODER = new TextEncoder();
71
+ }
72
+ callback(TEXT_ENCODER.encode(encoded));
73
+ });
74
+ }
75
+
76
+ // node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js
77
+ var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
78
+ var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
79
+ for (let i2 = 0; i2 < chars.length; i2++) {
80
+ lookup[chars.charCodeAt(i2)] = i2;
81
+ }
82
+ var decode = (base64) => {
83
+ let bufferLength = base64.length * 0.75, len = base64.length, i2, p = 0, encoded1, encoded2, encoded3, encoded4;
84
+ if (base64[base64.length - 1] === "=") {
85
+ bufferLength--;
86
+ if (base64[base64.length - 2] === "=") {
87
+ bufferLength--;
88
+ }
89
+ }
90
+ const arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);
91
+ for (i2 = 0; i2 < len; i2 += 4) {
92
+ encoded1 = lookup[base64.charCodeAt(i2)];
93
+ encoded2 = lookup[base64.charCodeAt(i2 + 1)];
94
+ encoded3 = lookup[base64.charCodeAt(i2 + 2)];
95
+ encoded4 = lookup[base64.charCodeAt(i2 + 3)];
96
+ bytes[p++] = encoded1 << 2 | encoded2 >> 4;
97
+ bytes[p++] = (encoded2 & 15) << 4 | encoded3 >> 2;
98
+ bytes[p++] = (encoded3 & 3) << 6 | encoded4 & 63;
99
+ }
100
+ return arraybuffer;
101
+ };
102
+
103
+ // node_modules/engine.io-parser/build/esm/decodePacket.browser.js
104
+ var withNativeArrayBuffer2 = typeof ArrayBuffer === "function";
105
+ var decodePacket = (encodedPacket, binaryType) => {
106
+ if (typeof encodedPacket !== "string") {
107
+ return {
108
+ type: "message",
109
+ data: mapBinary(encodedPacket, binaryType)
110
+ };
111
+ }
112
+ const type = encodedPacket.charAt(0);
113
+ if (type === "b") {
114
+ return {
115
+ type: "message",
116
+ data: decodeBase64Packet(encodedPacket.substring(1), binaryType)
117
+ };
118
+ }
119
+ const packetType = PACKET_TYPES_REVERSE[type];
120
+ if (!packetType) {
121
+ return ERROR_PACKET;
122
+ }
123
+ return encodedPacket.length > 1 ? {
124
+ type: PACKET_TYPES_REVERSE[type],
125
+ data: encodedPacket.substring(1)
126
+ } : {
127
+ type: PACKET_TYPES_REVERSE[type]
128
+ };
129
+ };
130
+ var decodeBase64Packet = (data, binaryType) => {
131
+ if (withNativeArrayBuffer2) {
132
+ const decoded = decode(data);
133
+ return mapBinary(decoded, binaryType);
134
+ } else {
135
+ return { base64: true, data };
136
+ }
137
+ };
138
+ var mapBinary = (data, binaryType) => {
139
+ switch (binaryType) {
140
+ case "blob":
141
+ if (data instanceof Blob) {
142
+ return data;
143
+ } else {
144
+ return new Blob([data]);
145
+ }
146
+ case "arraybuffer":
147
+ default:
148
+ if (data instanceof ArrayBuffer) {
149
+ return data;
150
+ } else {
151
+ return data.buffer;
152
+ }
153
+ }
154
+ };
155
+
156
+ // node_modules/engine.io-parser/build/esm/index.js
157
+ var SEPARATOR = String.fromCharCode(30);
158
+ var encodePayload = (packets, callback) => {
159
+ const length2 = packets.length;
160
+ const encodedPackets = new Array(length2);
161
+ let count = 0;
162
+ packets.forEach((packet, i2) => {
163
+ encodePacket(packet, false, (encodedPacket) => {
164
+ encodedPackets[i2] = encodedPacket;
165
+ if (++count === length2) {
166
+ callback(encodedPackets.join(SEPARATOR));
167
+ }
168
+ });
169
+ });
170
+ };
171
+ var decodePayload = (encodedPayload, binaryType) => {
172
+ const encodedPackets = encodedPayload.split(SEPARATOR);
173
+ const packets = [];
174
+ for (let i2 = 0; i2 < encodedPackets.length; i2++) {
175
+ const decodedPacket = decodePacket(encodedPackets[i2], binaryType);
176
+ packets.push(decodedPacket);
177
+ if (decodedPacket.type === "error") {
178
+ break;
179
+ }
180
+ }
181
+ return packets;
182
+ };
183
+ function createPacketEncoderStream() {
184
+ return new TransformStream({
185
+ transform(packet, controller) {
186
+ encodePacketToBinary(packet, (encodedPacket) => {
187
+ const payloadLength = encodedPacket.length;
188
+ let header;
189
+ if (payloadLength < 126) {
190
+ header = new Uint8Array(1);
191
+ new DataView(header.buffer).setUint8(0, payloadLength);
192
+ } else if (payloadLength < 65536) {
193
+ header = new Uint8Array(3);
194
+ const view = new DataView(header.buffer);
195
+ view.setUint8(0, 126);
196
+ view.setUint16(1, payloadLength);
197
+ } else {
198
+ header = new Uint8Array(9);
199
+ const view = new DataView(header.buffer);
200
+ view.setUint8(0, 127);
201
+ view.setBigUint64(1, BigInt(payloadLength));
202
+ }
203
+ if (packet.data && typeof packet.data !== "string") {
204
+ header[0] |= 128;
205
+ }
206
+ controller.enqueue(header);
207
+ controller.enqueue(encodedPacket);
208
+ });
209
+ }
210
+ });
211
+ }
212
+ var TEXT_DECODER;
213
+ function totalLength(chunks) {
214
+ return chunks.reduce((acc, chunk) => acc + chunk.length, 0);
215
+ }
216
+ function concatChunks(chunks, size) {
217
+ if (chunks[0].length === size) {
218
+ return chunks.shift();
219
+ }
220
+ const buffer = new Uint8Array(size);
221
+ let j = 0;
222
+ for (let i2 = 0; i2 < size; i2++) {
223
+ buffer[i2] = chunks[0][j++];
224
+ if (j === chunks[0].length) {
225
+ chunks.shift();
226
+ j = 0;
227
+ }
228
+ }
229
+ if (chunks.length && j < chunks[0].length) {
230
+ chunks[0] = chunks[0].slice(j);
231
+ }
232
+ return buffer;
233
+ }
234
+ function createPacketDecoderStream(maxPayload, binaryType) {
235
+ if (!TEXT_DECODER) {
236
+ TEXT_DECODER = new TextDecoder();
237
+ }
238
+ const chunks = [];
239
+ let state = 0;
240
+ let expectedLength = -1;
241
+ let isBinary2 = false;
242
+ return new TransformStream({
243
+ transform(chunk, controller) {
244
+ chunks.push(chunk);
245
+ while (true) {
246
+ if (state === 0) {
247
+ if (totalLength(chunks) < 1) {
248
+ break;
249
+ }
250
+ const header = concatChunks(chunks, 1);
251
+ isBinary2 = (header[0] & 128) === 128;
252
+ expectedLength = header[0] & 127;
253
+ if (expectedLength < 126) {
254
+ state = 3;
255
+ } else if (expectedLength === 126) {
256
+ state = 1;
257
+ } else {
258
+ state = 2;
259
+ }
260
+ } else if (state === 1) {
261
+ if (totalLength(chunks) < 2) {
262
+ break;
263
+ }
264
+ const headerArray = concatChunks(chunks, 2);
265
+ expectedLength = new DataView(headerArray.buffer, headerArray.byteOffset, headerArray.length).getUint16(0);
266
+ state = 3;
267
+ } else if (state === 2) {
268
+ if (totalLength(chunks) < 8) {
269
+ break;
270
+ }
271
+ const headerArray = concatChunks(chunks, 8);
272
+ const view = new DataView(headerArray.buffer, headerArray.byteOffset, headerArray.length);
273
+ const n = view.getUint32(0);
274
+ if (n > Math.pow(2, 53 - 32) - 1) {
275
+ controller.enqueue(ERROR_PACKET);
276
+ break;
277
+ }
278
+ expectedLength = n * Math.pow(2, 32) + view.getUint32(4);
279
+ state = 3;
280
+ } else {
281
+ if (totalLength(chunks) < expectedLength) {
282
+ break;
283
+ }
284
+ const data = concatChunks(chunks, expectedLength);
285
+ controller.enqueue(decodePacket(isBinary2 ? data : TEXT_DECODER.decode(data), binaryType));
286
+ state = 0;
287
+ }
288
+ if (expectedLength === 0 || expectedLength > maxPayload) {
289
+ controller.enqueue(ERROR_PACKET);
290
+ break;
291
+ }
292
+ }
293
+ }
294
+ });
295
+ }
296
+ var protocol = 4;
297
+
298
+ // node_modules/@socket.io/component-emitter/lib/esm/index.js
299
+ function Emitter(obj) {
300
+ if (obj) return mixin(obj);
301
+ }
302
+ function mixin(obj) {
303
+ for (var key in Emitter.prototype) {
304
+ obj[key] = Emitter.prototype[key];
305
+ }
306
+ return obj;
307
+ }
308
+ Emitter.prototype.on = Emitter.prototype.addEventListener = function(event, fn) {
309
+ this._callbacks = this._callbacks || {};
310
+ (this._callbacks["$" + event] = this._callbacks["$" + event] || []).push(fn);
311
+ return this;
312
+ };
313
+ Emitter.prototype.once = function(event, fn) {
314
+ function on2() {
315
+ this.off(event, on2);
316
+ fn.apply(this, arguments);
317
+ }
318
+ on2.fn = fn;
319
+ this.on(event, on2);
320
+ return this;
321
+ };
322
+ Emitter.prototype.off = Emitter.prototype.removeListener = Emitter.prototype.removeAllListeners = Emitter.prototype.removeEventListener = function(event, fn) {
323
+ this._callbacks = this._callbacks || {};
324
+ if (0 == arguments.length) {
325
+ this._callbacks = {};
326
+ return this;
327
+ }
328
+ var callbacks = this._callbacks["$" + event];
329
+ if (!callbacks) return this;
330
+ if (1 == arguments.length) {
331
+ delete this._callbacks["$" + event];
332
+ return this;
333
+ }
334
+ var cb;
335
+ for (var i2 = 0; i2 < callbacks.length; i2++) {
336
+ cb = callbacks[i2];
337
+ if (cb === fn || cb.fn === fn) {
338
+ callbacks.splice(i2, 1);
339
+ break;
340
+ }
341
+ }
342
+ if (callbacks.length === 0) {
343
+ delete this._callbacks["$" + event];
344
+ }
345
+ return this;
346
+ };
347
+ Emitter.prototype.emit = function(event) {
348
+ this._callbacks = this._callbacks || {};
349
+ var args = new Array(arguments.length - 1), callbacks = this._callbacks["$" + event];
350
+ for (var i2 = 1; i2 < arguments.length; i2++) {
351
+ args[i2 - 1] = arguments[i2];
352
+ }
353
+ if (callbacks) {
354
+ callbacks = callbacks.slice(0);
355
+ for (var i2 = 0, len = callbacks.length; i2 < len; ++i2) {
356
+ callbacks[i2].apply(this, args);
357
+ }
358
+ }
359
+ return this;
360
+ };
361
+ Emitter.prototype.emitReserved = Emitter.prototype.emit;
362
+ Emitter.prototype.listeners = function(event) {
363
+ this._callbacks = this._callbacks || {};
364
+ return this._callbacks["$" + event] || [];
365
+ };
366
+ Emitter.prototype.hasListeners = function(event) {
367
+ return !!this.listeners(event).length;
368
+ };
369
+
370
+ // node_modules/engine.io-client/build/esm/globalThis.browser.js
371
+ var globalThisShim = (() => {
372
+ if (typeof self !== "undefined") {
373
+ return self;
374
+ } else if (typeof window !== "undefined") {
375
+ return window;
376
+ } else {
377
+ return Function("return this")();
378
+ }
379
+ })();
380
+
381
+ // node_modules/engine.io-client/build/esm/util.js
382
+ function pick(obj, ...attr) {
383
+ return attr.reduce((acc, k) => {
384
+ if (obj.hasOwnProperty(k)) {
385
+ acc[k] = obj[k];
386
+ }
387
+ return acc;
388
+ }, {});
389
+ }
390
+ var NATIVE_SET_TIMEOUT = globalThisShim.setTimeout;
391
+ var NATIVE_CLEAR_TIMEOUT = globalThisShim.clearTimeout;
392
+ function installTimerFunctions(obj, opts) {
393
+ if (opts.useNativeTimers) {
394
+ obj.setTimeoutFn = NATIVE_SET_TIMEOUT.bind(globalThisShim);
395
+ obj.clearTimeoutFn = NATIVE_CLEAR_TIMEOUT.bind(globalThisShim);
396
+ } else {
397
+ obj.setTimeoutFn = globalThisShim.setTimeout.bind(globalThisShim);
398
+ obj.clearTimeoutFn = globalThisShim.clearTimeout.bind(globalThisShim);
399
+ }
400
+ }
401
+ var BASE64_OVERHEAD = 1.33;
402
+ function byteLength(obj) {
403
+ if (typeof obj === "string") {
404
+ return utf8Length(obj);
405
+ }
406
+ return Math.ceil((obj.byteLength || obj.size) * BASE64_OVERHEAD);
407
+ }
408
+ function utf8Length(str) {
409
+ let c = 0, length2 = 0;
410
+ for (let i2 = 0, l = str.length; i2 < l; i2++) {
411
+ c = str.charCodeAt(i2);
412
+ if (c < 128) {
413
+ length2 += 1;
414
+ } else if (c < 2048) {
415
+ length2 += 2;
416
+ } else if (c < 55296 || c >= 57344) {
417
+ length2 += 3;
418
+ } else {
419
+ i2++;
420
+ length2 += 4;
421
+ }
422
+ }
423
+ return length2;
424
+ }
425
+
426
+ // node_modules/engine.io-client/build/esm/contrib/parseqs.js
427
+ function encode(obj) {
428
+ let str = "";
429
+ for (let i2 in obj) {
430
+ if (obj.hasOwnProperty(i2)) {
431
+ if (str.length)
432
+ str += "&";
433
+ str += encodeURIComponent(i2) + "=" + encodeURIComponent(obj[i2]);
434
+ }
435
+ }
436
+ return str;
437
+ }
438
+ function decode2(qs) {
439
+ let qry = {};
440
+ let pairs = qs.split("&");
441
+ for (let i2 = 0, l = pairs.length; i2 < l; i2++) {
442
+ let pair = pairs[i2].split("=");
443
+ qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
444
+ }
445
+ return qry;
446
+ }
447
+
448
+ // node_modules/engine.io-client/build/esm/transport.js
449
+ var TransportError = class extends Error {
450
+ constructor(reason, description, context) {
451
+ super(reason);
452
+ this.description = description;
453
+ this.context = context;
454
+ this.type = "TransportError";
455
+ }
456
+ };
457
+ var Transport = class extends Emitter {
458
+ /**
459
+ * Transport abstract constructor.
460
+ *
461
+ * @param {Object} opts - options
462
+ * @protected
463
+ */
464
+ constructor(opts) {
465
+ super();
466
+ this.writable = false;
467
+ installTimerFunctions(this, opts);
468
+ this.opts = opts;
469
+ this.query = opts.query;
470
+ this.socket = opts.socket;
471
+ }
472
+ /**
473
+ * Emits an error.
474
+ *
475
+ * @param {String} reason
476
+ * @param description
477
+ * @param context - the error context
478
+ * @return {Transport} for chaining
479
+ * @protected
480
+ */
481
+ onError(reason, description, context) {
482
+ super.emitReserved("error", new TransportError(reason, description, context));
483
+ return this;
484
+ }
485
+ /**
486
+ * Opens the transport.
487
+ */
488
+ open() {
489
+ this.readyState = "opening";
490
+ this.doOpen();
491
+ return this;
492
+ }
493
+ /**
494
+ * Closes the transport.
495
+ */
496
+ close() {
497
+ if (this.readyState === "opening" || this.readyState === "open") {
498
+ this.doClose();
499
+ this.onClose();
500
+ }
501
+ return this;
502
+ }
503
+ /**
504
+ * Sends multiple packets.
505
+ *
506
+ * @param {Array} packets
507
+ */
508
+ send(packets) {
509
+ if (this.readyState === "open") {
510
+ this.write(packets);
511
+ } else {
512
+ }
513
+ }
514
+ /**
515
+ * Called upon open
516
+ *
517
+ * @protected
518
+ */
519
+ onOpen() {
520
+ this.readyState = "open";
521
+ this.writable = true;
522
+ super.emitReserved("open");
523
+ }
524
+ /**
525
+ * Called with data.
526
+ *
527
+ * @param {String} data
528
+ * @protected
529
+ */
530
+ onData(data) {
531
+ const packet = decodePacket(data, this.socket.binaryType);
532
+ this.onPacket(packet);
533
+ }
534
+ /**
535
+ * Called with a decoded packet.
536
+ *
537
+ * @protected
538
+ */
539
+ onPacket(packet) {
540
+ super.emitReserved("packet", packet);
541
+ }
542
+ /**
543
+ * Called upon close.
544
+ *
545
+ * @protected
546
+ */
547
+ onClose(details) {
548
+ this.readyState = "closed";
549
+ super.emitReserved("close", details);
550
+ }
551
+ /**
552
+ * Pauses the transport, in order not to lose packets during an upgrade.
553
+ *
554
+ * @param onPause
555
+ */
556
+ pause(onPause) {
557
+ }
558
+ createUri(schema, query = {}) {
559
+ return schema + "://" + this._hostname() + this._port() + this.opts.path + this._query(query);
560
+ }
561
+ _hostname() {
562
+ const hostname = this.opts.hostname;
563
+ return hostname.indexOf(":") === -1 ? hostname : "[" + hostname + "]";
564
+ }
565
+ _port() {
566
+ if (this.opts.port && (this.opts.secure && Number(this.opts.port !== 443) || !this.opts.secure && Number(this.opts.port) !== 80)) {
567
+ return ":" + this.opts.port;
568
+ } else {
569
+ return "";
570
+ }
571
+ }
572
+ _query(query) {
573
+ const encodedQuery = encode(query);
574
+ return encodedQuery.length ? "?" + encodedQuery : "";
575
+ }
576
+ };
577
+
578
+ // node_modules/engine.io-client/build/esm/contrib/yeast.js
579
+ var alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split("");
580
+ var length = 64;
581
+ var map = {};
582
+ var seed = 0;
583
+ var i = 0;
584
+ var prev;
585
+ function encode2(num) {
586
+ let encoded = "";
587
+ do {
588
+ encoded = alphabet[num % length] + encoded;
589
+ num = Math.floor(num / length);
590
+ } while (num > 0);
591
+ return encoded;
592
+ }
593
+ function yeast() {
594
+ const now = encode2(+/* @__PURE__ */ new Date());
595
+ if (now !== prev)
596
+ return seed = 0, prev = now;
597
+ return now + "." + encode2(seed++);
598
+ }
599
+ for (; i < length; i++)
600
+ map[alphabet[i]] = i;
601
+
602
+ // node_modules/engine.io-client/build/esm/contrib/has-cors.js
603
+ var value = false;
604
+ try {
605
+ value = typeof XMLHttpRequest !== "undefined" && "withCredentials" in new XMLHttpRequest();
606
+ } catch (err) {
607
+ }
608
+ var hasCORS = value;
609
+
610
+ // node_modules/engine.io-client/build/esm/transports/xmlhttprequest.browser.js
611
+ function XHR(opts) {
612
+ const xdomain = opts.xdomain;
613
+ try {
614
+ if ("undefined" !== typeof XMLHttpRequest && (!xdomain || hasCORS)) {
615
+ return new XMLHttpRequest();
616
+ }
617
+ } catch (e) {
618
+ }
619
+ if (!xdomain) {
620
+ try {
621
+ return new globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
622
+ } catch (e) {
623
+ }
624
+ }
625
+ }
626
+ function createCookieJar() {
627
+ }
628
+
629
+ // node_modules/engine.io-client/build/esm/transports/polling.js
630
+ function empty() {
631
+ }
632
+ var hasXHR2 = (function() {
633
+ const xhr = new XHR({
634
+ xdomain: false
635
+ });
636
+ return null != xhr.responseType;
637
+ })();
638
+ var Polling = class extends Transport {
639
+ /**
640
+ * XHR Polling constructor.
641
+ *
642
+ * @param {Object} opts
643
+ * @package
644
+ */
645
+ constructor(opts) {
646
+ super(opts);
647
+ this.polling = false;
648
+ if (typeof location !== "undefined") {
649
+ const isSSL = "https:" === location.protocol;
650
+ let port = location.port;
651
+ if (!port) {
652
+ port = isSSL ? "443" : "80";
653
+ }
654
+ this.xd = typeof location !== "undefined" && opts.hostname !== location.hostname || port !== opts.port;
655
+ }
656
+ const forceBase64 = opts && opts.forceBase64;
657
+ this.supportsBinary = hasXHR2 && !forceBase64;
658
+ if (this.opts.withCredentials) {
659
+ this.cookieJar = createCookieJar();
660
+ }
661
+ }
662
+ get name() {
663
+ return "polling";
664
+ }
665
+ /**
666
+ * Opens the socket (triggers polling). We write a PING message to determine
667
+ * when the transport is open.
668
+ *
669
+ * @protected
670
+ */
671
+ doOpen() {
672
+ this.poll();
673
+ }
674
+ /**
675
+ * Pauses polling.
676
+ *
677
+ * @param {Function} onPause - callback upon buffers are flushed and transport is paused
678
+ * @package
679
+ */
680
+ pause(onPause) {
681
+ this.readyState = "pausing";
682
+ const pause = () => {
683
+ this.readyState = "paused";
684
+ onPause();
685
+ };
686
+ if (this.polling || !this.writable) {
687
+ let total = 0;
688
+ if (this.polling) {
689
+ total++;
690
+ this.once("pollComplete", function() {
691
+ --total || pause();
692
+ });
693
+ }
694
+ if (!this.writable) {
695
+ total++;
696
+ this.once("drain", function() {
697
+ --total || pause();
698
+ });
699
+ }
700
+ } else {
701
+ pause();
702
+ }
703
+ }
704
+ /**
705
+ * Starts polling cycle.
706
+ *
707
+ * @private
708
+ */
709
+ poll() {
710
+ this.polling = true;
711
+ this.doPoll();
712
+ this.emitReserved("poll");
713
+ }
714
+ /**
715
+ * Overloads onData to detect payloads.
716
+ *
717
+ * @protected
718
+ */
719
+ onData(data) {
720
+ const callback = (packet) => {
721
+ if ("opening" === this.readyState && packet.type === "open") {
722
+ this.onOpen();
723
+ }
724
+ if ("close" === packet.type) {
725
+ this.onClose({ description: "transport closed by the server" });
726
+ return false;
727
+ }
728
+ this.onPacket(packet);
729
+ };
730
+ decodePayload(data, this.socket.binaryType).forEach(callback);
731
+ if ("closed" !== this.readyState) {
732
+ this.polling = false;
733
+ this.emitReserved("pollComplete");
734
+ if ("open" === this.readyState) {
735
+ this.poll();
736
+ } else {
737
+ }
738
+ }
739
+ }
740
+ /**
741
+ * For polling, send a close packet.
742
+ *
743
+ * @protected
744
+ */
745
+ doClose() {
746
+ const close = () => {
747
+ this.write([{ type: "close" }]);
748
+ };
749
+ if ("open" === this.readyState) {
750
+ close();
751
+ } else {
752
+ this.once("open", close);
753
+ }
754
+ }
755
+ /**
756
+ * Writes a packets payload.
757
+ *
758
+ * @param {Array} packets - data packets
759
+ * @protected
760
+ */
761
+ write(packets) {
762
+ this.writable = false;
763
+ encodePayload(packets, (data) => {
764
+ this.doWrite(data, () => {
765
+ this.writable = true;
766
+ this.emitReserved("drain");
767
+ });
768
+ });
769
+ }
770
+ /**
771
+ * Generates uri for connection.
772
+ *
773
+ * @private
774
+ */
775
+ uri() {
776
+ const schema = this.opts.secure ? "https" : "http";
777
+ const query = this.query || {};
778
+ if (false !== this.opts.timestampRequests) {
779
+ query[this.opts.timestampParam] = yeast();
780
+ }
781
+ if (!this.supportsBinary && !query.sid) {
782
+ query.b64 = 1;
783
+ }
784
+ return this.createUri(schema, query);
785
+ }
786
+ /**
787
+ * Creates a request.
788
+ *
789
+ * @param {String} method
790
+ * @private
791
+ */
792
+ request(opts = {}) {
793
+ Object.assign(opts, { xd: this.xd, cookieJar: this.cookieJar }, this.opts);
794
+ return new Request(this.uri(), opts);
795
+ }
796
+ /**
797
+ * Sends data.
798
+ *
799
+ * @param {String} data to send.
800
+ * @param {Function} called upon flush.
801
+ * @private
802
+ */
803
+ doWrite(data, fn) {
804
+ const req = this.request({
805
+ method: "POST",
806
+ data
807
+ });
808
+ req.on("success", fn);
809
+ req.on("error", (xhrStatus, context) => {
810
+ this.onError("xhr post error", xhrStatus, context);
811
+ });
812
+ }
813
+ /**
814
+ * Starts a poll cycle.
815
+ *
816
+ * @private
817
+ */
818
+ doPoll() {
819
+ const req = this.request();
820
+ req.on("data", this.onData.bind(this));
821
+ req.on("error", (xhrStatus, context) => {
822
+ this.onError("xhr poll error", xhrStatus, context);
823
+ });
824
+ this.pollXhr = req;
825
+ }
826
+ };
827
+ var Request = class _Request extends Emitter {
828
+ /**
829
+ * Request constructor
830
+ *
831
+ * @param {Object} options
832
+ * @package
833
+ */
834
+ constructor(uri, opts) {
835
+ super();
836
+ installTimerFunctions(this, opts);
837
+ this.opts = opts;
838
+ this.method = opts.method || "GET";
839
+ this.uri = uri;
840
+ this.data = void 0 !== opts.data ? opts.data : null;
841
+ this.create();
842
+ }
843
+ /**
844
+ * Creates the XHR object and sends the request.
845
+ *
846
+ * @private
847
+ */
848
+ create() {
849
+ var _a;
850
+ const opts = pick(this.opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
851
+ opts.xdomain = !!this.opts.xd;
852
+ const xhr = this.xhr = new XHR(opts);
853
+ try {
854
+ xhr.open(this.method, this.uri, true);
855
+ try {
856
+ if (this.opts.extraHeaders) {
857
+ xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true);
858
+ for (let i2 in this.opts.extraHeaders) {
859
+ if (this.opts.extraHeaders.hasOwnProperty(i2)) {
860
+ xhr.setRequestHeader(i2, this.opts.extraHeaders[i2]);
861
+ }
862
+ }
863
+ }
864
+ } catch (e) {
865
+ }
866
+ if ("POST" === this.method) {
867
+ try {
868
+ xhr.setRequestHeader("Content-type", "text/plain;charset=UTF-8");
869
+ } catch (e) {
870
+ }
871
+ }
872
+ try {
873
+ xhr.setRequestHeader("Accept", "*/*");
874
+ } catch (e) {
875
+ }
876
+ (_a = this.opts.cookieJar) === null || _a === void 0 ? void 0 : _a.addCookies(xhr);
877
+ if ("withCredentials" in xhr) {
878
+ xhr.withCredentials = this.opts.withCredentials;
879
+ }
880
+ if (this.opts.requestTimeout) {
881
+ xhr.timeout = this.opts.requestTimeout;
882
+ }
883
+ xhr.onreadystatechange = () => {
884
+ var _a2;
885
+ if (xhr.readyState === 3) {
886
+ (_a2 = this.opts.cookieJar) === null || _a2 === void 0 ? void 0 : _a2.parseCookies(xhr);
887
+ }
888
+ if (4 !== xhr.readyState)
889
+ return;
890
+ if (200 === xhr.status || 1223 === xhr.status) {
891
+ this.onLoad();
892
+ } else {
893
+ this.setTimeoutFn(() => {
894
+ this.onError(typeof xhr.status === "number" ? xhr.status : 0);
895
+ }, 0);
896
+ }
897
+ };
898
+ xhr.send(this.data);
899
+ } catch (e) {
900
+ this.setTimeoutFn(() => {
901
+ this.onError(e);
902
+ }, 0);
903
+ return;
904
+ }
905
+ if (typeof document !== "undefined") {
906
+ this.index = _Request.requestsCount++;
907
+ _Request.requests[this.index] = this;
908
+ }
909
+ }
910
+ /**
911
+ * Called upon error.
912
+ *
913
+ * @private
914
+ */
915
+ onError(err) {
916
+ this.emitReserved("error", err, this.xhr);
917
+ this.cleanup(true);
918
+ }
919
+ /**
920
+ * Cleans up house.
921
+ *
922
+ * @private
923
+ */
924
+ cleanup(fromError) {
925
+ if ("undefined" === typeof this.xhr || null === this.xhr) {
926
+ return;
927
+ }
928
+ this.xhr.onreadystatechange = empty;
929
+ if (fromError) {
930
+ try {
931
+ this.xhr.abort();
932
+ } catch (e) {
933
+ }
934
+ }
935
+ if (typeof document !== "undefined") {
936
+ delete _Request.requests[this.index];
937
+ }
938
+ this.xhr = null;
939
+ }
940
+ /**
941
+ * Called upon load.
942
+ *
943
+ * @private
944
+ */
945
+ onLoad() {
946
+ const data = this.xhr.responseText;
947
+ if (data !== null) {
948
+ this.emitReserved("data", data);
949
+ this.emitReserved("success");
950
+ this.cleanup();
951
+ }
952
+ }
953
+ /**
954
+ * Aborts the request.
955
+ *
956
+ * @package
957
+ */
958
+ abort() {
959
+ this.cleanup();
960
+ }
961
+ };
962
+ Request.requestsCount = 0;
963
+ Request.requests = {};
964
+ if (typeof document !== "undefined") {
965
+ if (typeof attachEvent === "function") {
966
+ attachEvent("onunload", unloadHandler);
967
+ } else if (typeof addEventListener === "function") {
968
+ const terminationEvent = "onpagehide" in globalThisShim ? "pagehide" : "unload";
969
+ addEventListener(terminationEvent, unloadHandler, false);
970
+ }
971
+ }
972
+ function unloadHandler() {
973
+ for (let i2 in Request.requests) {
974
+ if (Request.requests.hasOwnProperty(i2)) {
975
+ Request.requests[i2].abort();
976
+ }
977
+ }
978
+ }
979
+
980
+ // node_modules/engine.io-client/build/esm/transports/websocket-constructor.browser.js
981
+ var nextTick = (() => {
982
+ const isPromiseAvailable = typeof Promise === "function" && typeof Promise.resolve === "function";
983
+ if (isPromiseAvailable) {
984
+ return (cb) => Promise.resolve().then(cb);
985
+ } else {
986
+ return (cb, setTimeoutFn) => setTimeoutFn(cb, 0);
987
+ }
988
+ })();
989
+ var WebSocket = globalThisShim.WebSocket || globalThisShim.MozWebSocket;
990
+ var usingBrowserWebSocket = true;
991
+ var defaultBinaryType = "arraybuffer";
992
+
993
+ // node_modules/engine.io-client/build/esm/transports/websocket.js
994
+ var isReactNative = typeof navigator !== "undefined" && typeof navigator.product === "string" && navigator.product.toLowerCase() === "reactnative";
995
+ var WS = class extends Transport {
996
+ /**
997
+ * WebSocket transport constructor.
998
+ *
999
+ * @param {Object} opts - connection options
1000
+ * @protected
1001
+ */
1002
+ constructor(opts) {
1003
+ super(opts);
1004
+ this.supportsBinary = !opts.forceBase64;
1005
+ }
1006
+ get name() {
1007
+ return "websocket";
1008
+ }
1009
+ doOpen() {
1010
+ if (!this.check()) {
1011
+ return;
1012
+ }
1013
+ const uri = this.uri();
1014
+ const protocols = this.opts.protocols;
1015
+ const opts = isReactNative ? {} : pick(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
1016
+ if (this.opts.extraHeaders) {
1017
+ opts.headers = this.opts.extraHeaders;
1018
+ }
1019
+ try {
1020
+ this.ws = usingBrowserWebSocket && !isReactNative ? protocols ? new WebSocket(uri, protocols) : new WebSocket(uri) : new WebSocket(uri, protocols, opts);
1021
+ } catch (err) {
1022
+ return this.emitReserved("error", err);
1023
+ }
1024
+ this.ws.binaryType = this.socket.binaryType;
1025
+ this.addEventListeners();
1026
+ }
1027
+ /**
1028
+ * Adds event listeners to the socket
1029
+ *
1030
+ * @private
1031
+ */
1032
+ addEventListeners() {
1033
+ this.ws.onopen = () => {
1034
+ if (this.opts.autoUnref) {
1035
+ this.ws._socket.unref();
1036
+ }
1037
+ this.onOpen();
1038
+ };
1039
+ this.ws.onclose = (closeEvent) => this.onClose({
1040
+ description: "websocket connection closed",
1041
+ context: closeEvent
1042
+ });
1043
+ this.ws.onmessage = (ev) => this.onData(ev.data);
1044
+ this.ws.onerror = (e) => this.onError("websocket error", e);
1045
+ }
1046
+ write(packets) {
1047
+ this.writable = false;
1048
+ for (let i2 = 0; i2 < packets.length; i2++) {
1049
+ const packet = packets[i2];
1050
+ const lastPacket = i2 === packets.length - 1;
1051
+ encodePacket(packet, this.supportsBinary, (data) => {
1052
+ const opts = {};
1053
+ if (!usingBrowserWebSocket) {
1054
+ if (packet.options) {
1055
+ opts.compress = packet.options.compress;
1056
+ }
1057
+ if (this.opts.perMessageDeflate) {
1058
+ const len = (
1059
+ // @ts-ignore
1060
+ "string" === typeof data ? Buffer.byteLength(data) : data.length
1061
+ );
1062
+ if (len < this.opts.perMessageDeflate.threshold) {
1063
+ opts.compress = false;
1064
+ }
1065
+ }
1066
+ }
1067
+ try {
1068
+ if (usingBrowserWebSocket) {
1069
+ this.ws.send(data);
1070
+ } else {
1071
+ this.ws.send(data, opts);
1072
+ }
1073
+ } catch (e) {
1074
+ }
1075
+ if (lastPacket) {
1076
+ nextTick(() => {
1077
+ this.writable = true;
1078
+ this.emitReserved("drain");
1079
+ }, this.setTimeoutFn);
1080
+ }
1081
+ });
1082
+ }
1083
+ }
1084
+ doClose() {
1085
+ if (typeof this.ws !== "undefined") {
1086
+ this.ws.close();
1087
+ this.ws = null;
1088
+ }
1089
+ }
1090
+ /**
1091
+ * Generates uri for connection.
1092
+ *
1093
+ * @private
1094
+ */
1095
+ uri() {
1096
+ const schema = this.opts.secure ? "wss" : "ws";
1097
+ const query = this.query || {};
1098
+ if (this.opts.timestampRequests) {
1099
+ query[this.opts.timestampParam] = yeast();
1100
+ }
1101
+ if (!this.supportsBinary) {
1102
+ query.b64 = 1;
1103
+ }
1104
+ return this.createUri(schema, query);
1105
+ }
1106
+ /**
1107
+ * Feature detection for WebSocket.
1108
+ *
1109
+ * @return {Boolean} whether this transport is available.
1110
+ * @private
1111
+ */
1112
+ check() {
1113
+ return !!WebSocket;
1114
+ }
1115
+ };
1116
+
1117
+ // node_modules/engine.io-client/build/esm/transports/webtransport.js
1118
+ var WT = class extends Transport {
1119
+ get name() {
1120
+ return "webtransport";
1121
+ }
1122
+ doOpen() {
1123
+ if (typeof WebTransport !== "function") {
1124
+ return;
1125
+ }
1126
+ this.transport = new WebTransport(this.createUri("https"), this.opts.transportOptions[this.name]);
1127
+ this.transport.closed.then(() => {
1128
+ this.onClose();
1129
+ }).catch((err) => {
1130
+ this.onError("webtransport error", err);
1131
+ });
1132
+ this.transport.ready.then(() => {
1133
+ this.transport.createBidirectionalStream().then((stream) => {
1134
+ const decoderStream = createPacketDecoderStream(Number.MAX_SAFE_INTEGER, this.socket.binaryType);
1135
+ const reader = stream.readable.pipeThrough(decoderStream).getReader();
1136
+ const encoderStream = createPacketEncoderStream();
1137
+ encoderStream.readable.pipeTo(stream.writable);
1138
+ this.writer = encoderStream.writable.getWriter();
1139
+ const read = () => {
1140
+ reader.read().then(({ done, value: value2 }) => {
1141
+ if (done) {
1142
+ return;
1143
+ }
1144
+ this.onPacket(value2);
1145
+ read();
1146
+ }).catch((err) => {
1147
+ });
1148
+ };
1149
+ read();
1150
+ const packet = { type: "open" };
1151
+ if (this.query.sid) {
1152
+ packet.data = `{"sid":"${this.query.sid}"}`;
1153
+ }
1154
+ this.writer.write(packet).then(() => this.onOpen());
1155
+ });
1156
+ });
1157
+ }
1158
+ write(packets) {
1159
+ this.writable = false;
1160
+ for (let i2 = 0; i2 < packets.length; i2++) {
1161
+ const packet = packets[i2];
1162
+ const lastPacket = i2 === packets.length - 1;
1163
+ this.writer.write(packet).then(() => {
1164
+ if (lastPacket) {
1165
+ nextTick(() => {
1166
+ this.writable = true;
1167
+ this.emitReserved("drain");
1168
+ }, this.setTimeoutFn);
1169
+ }
1170
+ });
1171
+ }
1172
+ }
1173
+ doClose() {
1174
+ var _a;
1175
+ (_a = this.transport) === null || _a === void 0 ? void 0 : _a.close();
1176
+ }
1177
+ };
1178
+
1179
+ // node_modules/engine.io-client/build/esm/transports/index.js
1180
+ var transports = {
1181
+ websocket: WS,
1182
+ webtransport: WT,
1183
+ polling: Polling
1184
+ };
1185
+
1186
+ // node_modules/engine.io-client/build/esm/contrib/parseuri.js
1187
+ var re = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
1188
+ var parts = [
1189
+ "source",
1190
+ "protocol",
1191
+ "authority",
1192
+ "userInfo",
1193
+ "user",
1194
+ "password",
1195
+ "host",
1196
+ "port",
1197
+ "relative",
1198
+ "path",
1199
+ "directory",
1200
+ "file",
1201
+ "query",
1202
+ "anchor"
1203
+ ];
1204
+ function parse(str) {
1205
+ if (str.length > 2e3) {
1206
+ throw "URI too long";
1207
+ }
1208
+ const src = str, b = str.indexOf("["), e = str.indexOf("]");
1209
+ if (b != -1 && e != -1) {
1210
+ str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ";") + str.substring(e, str.length);
1211
+ }
1212
+ let m = re.exec(str || ""), uri = {}, i2 = 14;
1213
+ while (i2--) {
1214
+ uri[parts[i2]] = m[i2] || "";
1215
+ }
1216
+ if (b != -1 && e != -1) {
1217
+ uri.source = src;
1218
+ uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ":");
1219
+ uri.authority = uri.authority.replace("[", "").replace("]", "").replace(/;/g, ":");
1220
+ uri.ipv6uri = true;
1221
+ }
1222
+ uri.pathNames = pathNames(uri, uri["path"]);
1223
+ uri.queryKey = queryKey(uri, uri["query"]);
1224
+ return uri;
1225
+ }
1226
+ function pathNames(obj, path) {
1227
+ const regx = /\/{2,9}/g, names = path.replace(regx, "/").split("/");
1228
+ if (path.slice(0, 1) == "/" || path.length === 0) {
1229
+ names.splice(0, 1);
1230
+ }
1231
+ if (path.slice(-1) == "/") {
1232
+ names.splice(names.length - 1, 1);
1233
+ }
1234
+ return names;
1235
+ }
1236
+ function queryKey(uri, query) {
1237
+ const data = {};
1238
+ query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function($0, $1, $2) {
1239
+ if ($1) {
1240
+ data[$1] = $2;
1241
+ }
1242
+ });
1243
+ return data;
1244
+ }
1245
+
1246
+ // node_modules/engine.io-client/build/esm/socket.js
1247
+ var Socket = class _Socket extends Emitter {
1248
+ /**
1249
+ * Socket constructor.
1250
+ *
1251
+ * @param {String|Object} uri - uri or options
1252
+ * @param {Object} opts - options
1253
+ */
1254
+ constructor(uri, opts = {}) {
1255
+ super();
1256
+ this.binaryType = defaultBinaryType;
1257
+ this.writeBuffer = [];
1258
+ if (uri && "object" === typeof uri) {
1259
+ opts = uri;
1260
+ uri = null;
1261
+ }
1262
+ if (uri) {
1263
+ uri = parse(uri);
1264
+ opts.hostname = uri.host;
1265
+ opts.secure = uri.protocol === "https" || uri.protocol === "wss";
1266
+ opts.port = uri.port;
1267
+ if (uri.query)
1268
+ opts.query = uri.query;
1269
+ } else if (opts.host) {
1270
+ opts.hostname = parse(opts.host).host;
1271
+ }
1272
+ installTimerFunctions(this, opts);
1273
+ this.secure = null != opts.secure ? opts.secure : typeof location !== "undefined" && "https:" === location.protocol;
1274
+ if (opts.hostname && !opts.port) {
1275
+ opts.port = this.secure ? "443" : "80";
1276
+ }
1277
+ this.hostname = opts.hostname || (typeof location !== "undefined" ? location.hostname : "localhost");
1278
+ this.port = opts.port || (typeof location !== "undefined" && location.port ? location.port : this.secure ? "443" : "80");
1279
+ this.transports = opts.transports || [
1280
+ "polling",
1281
+ "websocket",
1282
+ "webtransport"
1283
+ ];
1284
+ this.writeBuffer = [];
1285
+ this.prevBufferLen = 0;
1286
+ this.opts = Object.assign({
1287
+ path: "/engine.io",
1288
+ agent: false,
1289
+ withCredentials: false,
1290
+ upgrade: true,
1291
+ timestampParam: "t",
1292
+ rememberUpgrade: false,
1293
+ addTrailingSlash: true,
1294
+ rejectUnauthorized: true,
1295
+ perMessageDeflate: {
1296
+ threshold: 1024
1297
+ },
1298
+ transportOptions: {},
1299
+ closeOnBeforeunload: false
1300
+ }, opts);
1301
+ this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : "");
1302
+ if (typeof this.opts.query === "string") {
1303
+ this.opts.query = decode2(this.opts.query);
1304
+ }
1305
+ this.id = null;
1306
+ this.upgrades = null;
1307
+ this.pingInterval = null;
1308
+ this.pingTimeout = null;
1309
+ this.pingTimeoutTimer = null;
1310
+ if (typeof addEventListener === "function") {
1311
+ if (this.opts.closeOnBeforeunload) {
1312
+ this.beforeunloadEventListener = () => {
1313
+ if (this.transport) {
1314
+ this.transport.removeAllListeners();
1315
+ this.transport.close();
1316
+ }
1317
+ };
1318
+ addEventListener("beforeunload", this.beforeunloadEventListener, false);
1319
+ }
1320
+ if (this.hostname !== "localhost") {
1321
+ this.offlineEventListener = () => {
1322
+ this.onClose("transport close", {
1323
+ description: "network connection lost"
1324
+ });
1325
+ };
1326
+ addEventListener("offline", this.offlineEventListener, false);
1327
+ }
1328
+ }
1329
+ this.open();
1330
+ }
1331
+ /**
1332
+ * Creates transport of the given type.
1333
+ *
1334
+ * @param {String} name - transport name
1335
+ * @return {Transport}
1336
+ * @private
1337
+ */
1338
+ createTransport(name) {
1339
+ const query = Object.assign({}, this.opts.query);
1340
+ query.EIO = protocol;
1341
+ query.transport = name;
1342
+ if (this.id)
1343
+ query.sid = this.id;
1344
+ const opts = Object.assign({}, this.opts, {
1345
+ query,
1346
+ socket: this,
1347
+ hostname: this.hostname,
1348
+ secure: this.secure,
1349
+ port: this.port
1350
+ }, this.opts.transportOptions[name]);
1351
+ return new transports[name](opts);
1352
+ }
1353
+ /**
1354
+ * Initializes transport to use and starts probe.
1355
+ *
1356
+ * @private
1357
+ */
1358
+ open() {
1359
+ let transport;
1360
+ if (this.opts.rememberUpgrade && _Socket.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1) {
1361
+ transport = "websocket";
1362
+ } else if (0 === this.transports.length) {
1363
+ this.setTimeoutFn(() => {
1364
+ this.emitReserved("error", "No transports available");
1365
+ }, 0);
1366
+ return;
1367
+ } else {
1368
+ transport = this.transports[0];
1369
+ }
1370
+ this.readyState = "opening";
1371
+ try {
1372
+ transport = this.createTransport(transport);
1373
+ } catch (e) {
1374
+ this.transports.shift();
1375
+ this.open();
1376
+ return;
1377
+ }
1378
+ transport.open();
1379
+ this.setTransport(transport);
1380
+ }
1381
+ /**
1382
+ * Sets the current transport. Disables the existing one (if any).
1383
+ *
1384
+ * @private
1385
+ */
1386
+ setTransport(transport) {
1387
+ if (this.transport) {
1388
+ this.transport.removeAllListeners();
1389
+ }
1390
+ this.transport = transport;
1391
+ transport.on("drain", this.onDrain.bind(this)).on("packet", this.onPacket.bind(this)).on("error", this.onError.bind(this)).on("close", (reason) => this.onClose("transport close", reason));
1392
+ }
1393
+ /**
1394
+ * Probes a transport.
1395
+ *
1396
+ * @param {String} name - transport name
1397
+ * @private
1398
+ */
1399
+ probe(name) {
1400
+ let transport = this.createTransport(name);
1401
+ let failed = false;
1402
+ _Socket.priorWebsocketSuccess = false;
1403
+ const onTransportOpen = () => {
1404
+ if (failed)
1405
+ return;
1406
+ transport.send([{ type: "ping", data: "probe" }]);
1407
+ transport.once("packet", (msg) => {
1408
+ if (failed)
1409
+ return;
1410
+ if ("pong" === msg.type && "probe" === msg.data) {
1411
+ this.upgrading = true;
1412
+ this.emitReserved("upgrading", transport);
1413
+ if (!transport)
1414
+ return;
1415
+ _Socket.priorWebsocketSuccess = "websocket" === transport.name;
1416
+ this.transport.pause(() => {
1417
+ if (failed)
1418
+ return;
1419
+ if ("closed" === this.readyState)
1420
+ return;
1421
+ cleanup();
1422
+ this.setTransport(transport);
1423
+ transport.send([{ type: "upgrade" }]);
1424
+ this.emitReserved("upgrade", transport);
1425
+ transport = null;
1426
+ this.upgrading = false;
1427
+ this.flush();
1428
+ });
1429
+ } else {
1430
+ const err = new Error("probe error");
1431
+ err.transport = transport.name;
1432
+ this.emitReserved("upgradeError", err);
1433
+ }
1434
+ });
1435
+ };
1436
+ function freezeTransport() {
1437
+ if (failed)
1438
+ return;
1439
+ failed = true;
1440
+ cleanup();
1441
+ transport.close();
1442
+ transport = null;
1443
+ }
1444
+ const onerror = (err) => {
1445
+ const error = new Error("probe error: " + err);
1446
+ error.transport = transport.name;
1447
+ freezeTransport();
1448
+ this.emitReserved("upgradeError", error);
1449
+ };
1450
+ function onTransportClose() {
1451
+ onerror("transport closed");
1452
+ }
1453
+ function onclose() {
1454
+ onerror("socket closed");
1455
+ }
1456
+ function onupgrade(to) {
1457
+ if (transport && to.name !== transport.name) {
1458
+ freezeTransport();
1459
+ }
1460
+ }
1461
+ const cleanup = () => {
1462
+ transport.removeListener("open", onTransportOpen);
1463
+ transport.removeListener("error", onerror);
1464
+ transport.removeListener("close", onTransportClose);
1465
+ this.off("close", onclose);
1466
+ this.off("upgrading", onupgrade);
1467
+ };
1468
+ transport.once("open", onTransportOpen);
1469
+ transport.once("error", onerror);
1470
+ transport.once("close", onTransportClose);
1471
+ this.once("close", onclose);
1472
+ this.once("upgrading", onupgrade);
1473
+ if (this.upgrades.indexOf("webtransport") !== -1 && name !== "webtransport") {
1474
+ this.setTimeoutFn(() => {
1475
+ if (!failed) {
1476
+ transport.open();
1477
+ }
1478
+ }, 200);
1479
+ } else {
1480
+ transport.open();
1481
+ }
1482
+ }
1483
+ /**
1484
+ * Called when connection is deemed open.
1485
+ *
1486
+ * @private
1487
+ */
1488
+ onOpen() {
1489
+ this.readyState = "open";
1490
+ _Socket.priorWebsocketSuccess = "websocket" === this.transport.name;
1491
+ this.emitReserved("open");
1492
+ this.flush();
1493
+ if ("open" === this.readyState && this.opts.upgrade) {
1494
+ let i2 = 0;
1495
+ const l = this.upgrades.length;
1496
+ for (; i2 < l; i2++) {
1497
+ this.probe(this.upgrades[i2]);
1498
+ }
1499
+ }
1500
+ }
1501
+ /**
1502
+ * Handles a packet.
1503
+ *
1504
+ * @private
1505
+ */
1506
+ onPacket(packet) {
1507
+ if ("opening" === this.readyState || "open" === this.readyState || "closing" === this.readyState) {
1508
+ this.emitReserved("packet", packet);
1509
+ this.emitReserved("heartbeat");
1510
+ this.resetPingTimeout();
1511
+ switch (packet.type) {
1512
+ case "open":
1513
+ this.onHandshake(JSON.parse(packet.data));
1514
+ break;
1515
+ case "ping":
1516
+ this.sendPacket("pong");
1517
+ this.emitReserved("ping");
1518
+ this.emitReserved("pong");
1519
+ break;
1520
+ case "error":
1521
+ const err = new Error("server error");
1522
+ err.code = packet.data;
1523
+ this.onError(err);
1524
+ break;
1525
+ case "message":
1526
+ this.emitReserved("data", packet.data);
1527
+ this.emitReserved("message", packet.data);
1528
+ break;
1529
+ }
1530
+ } else {
1531
+ }
1532
+ }
1533
+ /**
1534
+ * Called upon handshake completion.
1535
+ *
1536
+ * @param {Object} data - handshake obj
1537
+ * @private
1538
+ */
1539
+ onHandshake(data) {
1540
+ this.emitReserved("handshake", data);
1541
+ this.id = data.sid;
1542
+ this.transport.query.sid = data.sid;
1543
+ this.upgrades = this.filterUpgrades(data.upgrades);
1544
+ this.pingInterval = data.pingInterval;
1545
+ this.pingTimeout = data.pingTimeout;
1546
+ this.maxPayload = data.maxPayload;
1547
+ this.onOpen();
1548
+ if ("closed" === this.readyState)
1549
+ return;
1550
+ this.resetPingTimeout();
1551
+ }
1552
+ /**
1553
+ * Sets and resets ping timeout timer based on server pings.
1554
+ *
1555
+ * @private
1556
+ */
1557
+ resetPingTimeout() {
1558
+ this.clearTimeoutFn(this.pingTimeoutTimer);
1559
+ this.pingTimeoutTimer = this.setTimeoutFn(() => {
1560
+ this.onClose("ping timeout");
1561
+ }, this.pingInterval + this.pingTimeout);
1562
+ if (this.opts.autoUnref) {
1563
+ this.pingTimeoutTimer.unref();
1564
+ }
1565
+ }
1566
+ /**
1567
+ * Called on `drain` event
1568
+ *
1569
+ * @private
1570
+ */
1571
+ onDrain() {
1572
+ this.writeBuffer.splice(0, this.prevBufferLen);
1573
+ this.prevBufferLen = 0;
1574
+ if (0 === this.writeBuffer.length) {
1575
+ this.emitReserved("drain");
1576
+ } else {
1577
+ this.flush();
1578
+ }
1579
+ }
1580
+ /**
1581
+ * Flush write buffers.
1582
+ *
1583
+ * @private
1584
+ */
1585
+ flush() {
1586
+ if ("closed" !== this.readyState && this.transport.writable && !this.upgrading && this.writeBuffer.length) {
1587
+ const packets = this.getWritablePackets();
1588
+ this.transport.send(packets);
1589
+ this.prevBufferLen = packets.length;
1590
+ this.emitReserved("flush");
1591
+ }
1592
+ }
1593
+ /**
1594
+ * Ensure the encoded size of the writeBuffer is below the maxPayload value sent by the server (only for HTTP
1595
+ * long-polling)
1596
+ *
1597
+ * @private
1598
+ */
1599
+ getWritablePackets() {
1600
+ const shouldCheckPayloadSize = this.maxPayload && this.transport.name === "polling" && this.writeBuffer.length > 1;
1601
+ if (!shouldCheckPayloadSize) {
1602
+ return this.writeBuffer;
1603
+ }
1604
+ let payloadSize = 1;
1605
+ for (let i2 = 0; i2 < this.writeBuffer.length; i2++) {
1606
+ const data = this.writeBuffer[i2].data;
1607
+ if (data) {
1608
+ payloadSize += byteLength(data);
1609
+ }
1610
+ if (i2 > 0 && payloadSize > this.maxPayload) {
1611
+ return this.writeBuffer.slice(0, i2);
1612
+ }
1613
+ payloadSize += 2;
1614
+ }
1615
+ return this.writeBuffer;
1616
+ }
1617
+ /**
1618
+ * Sends a message.
1619
+ *
1620
+ * @param {String} msg - message.
1621
+ * @param {Object} options.
1622
+ * @param {Function} callback function.
1623
+ * @return {Socket} for chaining.
1624
+ */
1625
+ write(msg, options, fn) {
1626
+ this.sendPacket("message", msg, options, fn);
1627
+ return this;
1628
+ }
1629
+ send(msg, options, fn) {
1630
+ this.sendPacket("message", msg, options, fn);
1631
+ return this;
1632
+ }
1633
+ /**
1634
+ * Sends a packet.
1635
+ *
1636
+ * @param {String} type: packet type.
1637
+ * @param {String} data.
1638
+ * @param {Object} options.
1639
+ * @param {Function} fn - callback function.
1640
+ * @private
1641
+ */
1642
+ sendPacket(type, data, options, fn) {
1643
+ if ("function" === typeof data) {
1644
+ fn = data;
1645
+ data = void 0;
1646
+ }
1647
+ if ("function" === typeof options) {
1648
+ fn = options;
1649
+ options = null;
1650
+ }
1651
+ if ("closing" === this.readyState || "closed" === this.readyState) {
1652
+ return;
1653
+ }
1654
+ options = options || {};
1655
+ options.compress = false !== options.compress;
1656
+ const packet = {
1657
+ type,
1658
+ data,
1659
+ options
1660
+ };
1661
+ this.emitReserved("packetCreate", packet);
1662
+ this.writeBuffer.push(packet);
1663
+ if (fn)
1664
+ this.once("flush", fn);
1665
+ this.flush();
1666
+ }
1667
+ /**
1668
+ * Closes the connection.
1669
+ */
1670
+ close() {
1671
+ const close = () => {
1672
+ this.onClose("forced close");
1673
+ this.transport.close();
1674
+ };
1675
+ const cleanupAndClose = () => {
1676
+ this.off("upgrade", cleanupAndClose);
1677
+ this.off("upgradeError", cleanupAndClose);
1678
+ close();
1679
+ };
1680
+ const waitForUpgrade = () => {
1681
+ this.once("upgrade", cleanupAndClose);
1682
+ this.once("upgradeError", cleanupAndClose);
1683
+ };
1684
+ if ("opening" === this.readyState || "open" === this.readyState) {
1685
+ this.readyState = "closing";
1686
+ if (this.writeBuffer.length) {
1687
+ this.once("drain", () => {
1688
+ if (this.upgrading) {
1689
+ waitForUpgrade();
1690
+ } else {
1691
+ close();
1692
+ }
1693
+ });
1694
+ } else if (this.upgrading) {
1695
+ waitForUpgrade();
1696
+ } else {
1697
+ close();
1698
+ }
1699
+ }
1700
+ return this;
1701
+ }
1702
+ /**
1703
+ * Called upon transport error
1704
+ *
1705
+ * @private
1706
+ */
1707
+ onError(err) {
1708
+ _Socket.priorWebsocketSuccess = false;
1709
+ this.emitReserved("error", err);
1710
+ this.onClose("transport error", err);
1711
+ }
1712
+ /**
1713
+ * Called upon transport close.
1714
+ *
1715
+ * @private
1716
+ */
1717
+ onClose(reason, description) {
1718
+ if ("opening" === this.readyState || "open" === this.readyState || "closing" === this.readyState) {
1719
+ this.clearTimeoutFn(this.pingTimeoutTimer);
1720
+ this.transport.removeAllListeners("close");
1721
+ this.transport.close();
1722
+ this.transport.removeAllListeners();
1723
+ if (typeof removeEventListener === "function") {
1724
+ removeEventListener("beforeunload", this.beforeunloadEventListener, false);
1725
+ removeEventListener("offline", this.offlineEventListener, false);
1726
+ }
1727
+ this.readyState = "closed";
1728
+ this.id = null;
1729
+ this.emitReserved("close", reason, description);
1730
+ this.writeBuffer = [];
1731
+ this.prevBufferLen = 0;
1732
+ }
1733
+ }
1734
+ /**
1735
+ * Filters upgrades, returning only those matching client transports.
1736
+ *
1737
+ * @param {Array} upgrades - server upgrades
1738
+ * @private
1739
+ */
1740
+ filterUpgrades(upgrades) {
1741
+ const filteredUpgrades = [];
1742
+ let i2 = 0;
1743
+ const j = upgrades.length;
1744
+ for (; i2 < j; i2++) {
1745
+ if (~this.transports.indexOf(upgrades[i2]))
1746
+ filteredUpgrades.push(upgrades[i2]);
1747
+ }
1748
+ return filteredUpgrades;
1749
+ }
1750
+ };
1751
+ Socket.protocol = protocol;
1752
+
1753
+ // node_modules/engine.io-client/build/esm/index.js
1754
+ var protocol2 = Socket.protocol;
1755
+
1756
+ // node_modules/socket.io-client/build/esm/url.js
1757
+ function url(uri, path = "", loc) {
1758
+ let obj = uri;
1759
+ loc = loc || typeof location !== "undefined" && location;
1760
+ if (null == uri)
1761
+ uri = loc.protocol + "//" + loc.host;
1762
+ if (typeof uri === "string") {
1763
+ if ("/" === uri.charAt(0)) {
1764
+ if ("/" === uri.charAt(1)) {
1765
+ uri = loc.protocol + uri;
1766
+ } else {
1767
+ uri = loc.host + uri;
1768
+ }
1769
+ }
1770
+ if (!/^(https?|wss?):\/\//.test(uri)) {
1771
+ if ("undefined" !== typeof loc) {
1772
+ uri = loc.protocol + "//" + uri;
1773
+ } else {
1774
+ uri = "https://" + uri;
1775
+ }
1776
+ }
1777
+ obj = parse(uri);
1778
+ }
1779
+ if (!obj.port) {
1780
+ if (/^(http|ws)$/.test(obj.protocol)) {
1781
+ obj.port = "80";
1782
+ } else if (/^(http|ws)s$/.test(obj.protocol)) {
1783
+ obj.port = "443";
1784
+ }
1785
+ }
1786
+ obj.path = obj.path || "/";
1787
+ const ipv6 = obj.host.indexOf(":") !== -1;
1788
+ const host = ipv6 ? "[" + obj.host + "]" : obj.host;
1789
+ obj.id = obj.protocol + "://" + host + ":" + obj.port + path;
1790
+ obj.href = obj.protocol + "://" + host + (loc && loc.port === obj.port ? "" : ":" + obj.port);
1791
+ return obj;
1792
+ }
1793
+
1794
+ // node_modules/socket.io-parser/build/esm/index.js
1795
+ var esm_exports = {};
1796
+ __export(esm_exports, {
1797
+ Decoder: () => Decoder,
1798
+ Encoder: () => Encoder,
1799
+ PacketType: () => PacketType,
1800
+ protocol: () => protocol3
1801
+ });
1802
+
1803
+ // node_modules/socket.io-parser/build/esm/is-binary.js
1804
+ var withNativeArrayBuffer3 = typeof ArrayBuffer === "function";
1805
+ var isView2 = (obj) => {
1806
+ return typeof ArrayBuffer.isView === "function" ? ArrayBuffer.isView(obj) : obj.buffer instanceof ArrayBuffer;
1807
+ };
1808
+ var toString = Object.prototype.toString;
1809
+ var withNativeBlob2 = typeof Blob === "function" || typeof Blob !== "undefined" && toString.call(Blob) === "[object BlobConstructor]";
1810
+ var withNativeFile = typeof File === "function" || typeof File !== "undefined" && toString.call(File) === "[object FileConstructor]";
1811
+ function isBinary(obj) {
1812
+ return withNativeArrayBuffer3 && (obj instanceof ArrayBuffer || isView2(obj)) || withNativeBlob2 && obj instanceof Blob || withNativeFile && obj instanceof File;
1813
+ }
1814
+ function hasBinary(obj, toJSON) {
1815
+ if (!obj || typeof obj !== "object") {
1816
+ return false;
1817
+ }
1818
+ if (Array.isArray(obj)) {
1819
+ for (let i2 = 0, l = obj.length; i2 < l; i2++) {
1820
+ if (hasBinary(obj[i2])) {
1821
+ return true;
1822
+ }
1823
+ }
1824
+ return false;
1825
+ }
1826
+ if (isBinary(obj)) {
1827
+ return true;
1828
+ }
1829
+ if (obj.toJSON && typeof obj.toJSON === "function" && arguments.length === 1) {
1830
+ return hasBinary(obj.toJSON(), true);
1831
+ }
1832
+ for (const key in obj) {
1833
+ if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key])) {
1834
+ return true;
1835
+ }
1836
+ }
1837
+ return false;
1838
+ }
1839
+
1840
+ // node_modules/socket.io-parser/build/esm/binary.js
1841
+ function deconstructPacket(packet) {
1842
+ const buffers = [];
1843
+ const packetData = packet.data;
1844
+ const pack = packet;
1845
+ pack.data = _deconstructPacket(packetData, buffers);
1846
+ pack.attachments = buffers.length;
1847
+ return { packet: pack, buffers };
1848
+ }
1849
+ function _deconstructPacket(data, buffers) {
1850
+ if (!data)
1851
+ return data;
1852
+ if (isBinary(data)) {
1853
+ const placeholder = { _placeholder: true, num: buffers.length };
1854
+ buffers.push(data);
1855
+ return placeholder;
1856
+ } else if (Array.isArray(data)) {
1857
+ const newData = new Array(data.length);
1858
+ for (let i2 = 0; i2 < data.length; i2++) {
1859
+ newData[i2] = _deconstructPacket(data[i2], buffers);
1860
+ }
1861
+ return newData;
1862
+ } else if (typeof data === "object" && !(data instanceof Date)) {
1863
+ const newData = {};
1864
+ for (const key in data) {
1865
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
1866
+ newData[key] = _deconstructPacket(data[key], buffers);
1867
+ }
1868
+ }
1869
+ return newData;
1870
+ }
1871
+ return data;
1872
+ }
1873
+ function reconstructPacket(packet, buffers) {
1874
+ packet.data = _reconstructPacket(packet.data, buffers);
1875
+ delete packet.attachments;
1876
+ return packet;
1877
+ }
1878
+ function _reconstructPacket(data, buffers) {
1879
+ if (!data)
1880
+ return data;
1881
+ if (data && data._placeholder === true) {
1882
+ const isIndexValid = typeof data.num === "number" && data.num >= 0 && data.num < buffers.length;
1883
+ if (isIndexValid) {
1884
+ return buffers[data.num];
1885
+ } else {
1886
+ throw new Error("illegal attachments");
1887
+ }
1888
+ } else if (Array.isArray(data)) {
1889
+ for (let i2 = 0; i2 < data.length; i2++) {
1890
+ data[i2] = _reconstructPacket(data[i2], buffers);
1891
+ }
1892
+ } else if (typeof data === "object") {
1893
+ for (const key in data) {
1894
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
1895
+ data[key] = _reconstructPacket(data[key], buffers);
1896
+ }
1897
+ }
1898
+ }
1899
+ return data;
1900
+ }
1901
+
1902
+ // node_modules/socket.io-parser/build/esm/index.js
1903
+ var RESERVED_EVENTS = [
1904
+ "connect",
1905
+ "connect_error",
1906
+ "disconnect",
1907
+ "disconnecting",
1908
+ "newListener",
1909
+ "removeListener"
1910
+ // used by the Node.js EventEmitter
1911
+ ];
1912
+ var protocol3 = 5;
1913
+ var PacketType;
1914
+ (function(PacketType2) {
1915
+ PacketType2[PacketType2["CONNECT"] = 0] = "CONNECT";
1916
+ PacketType2[PacketType2["DISCONNECT"] = 1] = "DISCONNECT";
1917
+ PacketType2[PacketType2["EVENT"] = 2] = "EVENT";
1918
+ PacketType2[PacketType2["ACK"] = 3] = "ACK";
1919
+ PacketType2[PacketType2["CONNECT_ERROR"] = 4] = "CONNECT_ERROR";
1920
+ PacketType2[PacketType2["BINARY_EVENT"] = 5] = "BINARY_EVENT";
1921
+ PacketType2[PacketType2["BINARY_ACK"] = 6] = "BINARY_ACK";
1922
+ })(PacketType || (PacketType = {}));
1923
+ var Encoder = class {
1924
+ /**
1925
+ * Encoder constructor
1926
+ *
1927
+ * @param {function} replacer - custom replacer to pass down to JSON.parse
1928
+ */
1929
+ constructor(replacer) {
1930
+ this.replacer = replacer;
1931
+ }
1932
+ /**
1933
+ * Encode a packet as a single string if non-binary, or as a
1934
+ * buffer sequence, depending on packet type.
1935
+ *
1936
+ * @param {Object} obj - packet object
1937
+ */
1938
+ encode(obj) {
1939
+ if (obj.type === PacketType.EVENT || obj.type === PacketType.ACK) {
1940
+ if (hasBinary(obj)) {
1941
+ return this.encodeAsBinary({
1942
+ type: obj.type === PacketType.EVENT ? PacketType.BINARY_EVENT : PacketType.BINARY_ACK,
1943
+ nsp: obj.nsp,
1944
+ data: obj.data,
1945
+ id: obj.id
1946
+ });
1947
+ }
1948
+ }
1949
+ return [this.encodeAsString(obj)];
1950
+ }
1951
+ /**
1952
+ * Encode packet as string.
1953
+ */
1954
+ encodeAsString(obj) {
1955
+ let str = "" + obj.type;
1956
+ if (obj.type === PacketType.BINARY_EVENT || obj.type === PacketType.BINARY_ACK) {
1957
+ str += obj.attachments + "-";
1958
+ }
1959
+ if (obj.nsp && "/" !== obj.nsp) {
1960
+ str += obj.nsp + ",";
1961
+ }
1962
+ if (null != obj.id) {
1963
+ str += obj.id;
1964
+ }
1965
+ if (null != obj.data) {
1966
+ str += JSON.stringify(obj.data, this.replacer);
1967
+ }
1968
+ return str;
1969
+ }
1970
+ /**
1971
+ * Encode packet as 'buffer sequence' by removing blobs, and
1972
+ * deconstructing packet into object with placeholders and
1973
+ * a list of buffers.
1974
+ */
1975
+ encodeAsBinary(obj) {
1976
+ const deconstruction = deconstructPacket(obj);
1977
+ const pack = this.encodeAsString(deconstruction.packet);
1978
+ const buffers = deconstruction.buffers;
1979
+ buffers.unshift(pack);
1980
+ return buffers;
1981
+ }
1982
+ };
1983
+ function isObject(value2) {
1984
+ return Object.prototype.toString.call(value2) === "[object Object]";
1985
+ }
1986
+ var Decoder = class _Decoder extends Emitter {
1987
+ /**
1988
+ * Decoder constructor
1989
+ *
1990
+ * @param {function} reviver - custom reviver to pass down to JSON.stringify
1991
+ */
1992
+ constructor(reviver) {
1993
+ super();
1994
+ this.reviver = reviver;
1995
+ }
1996
+ /**
1997
+ * Decodes an encoded packet string into packet JSON.
1998
+ *
1999
+ * @param {String} obj - encoded packet
2000
+ */
2001
+ add(obj) {
2002
+ let packet;
2003
+ if (typeof obj === "string") {
2004
+ if (this.reconstructor) {
2005
+ throw new Error("got plaintext data when reconstructing a packet");
2006
+ }
2007
+ packet = this.decodeString(obj);
2008
+ const isBinaryEvent = packet.type === PacketType.BINARY_EVENT;
2009
+ if (isBinaryEvent || packet.type === PacketType.BINARY_ACK) {
2010
+ packet.type = isBinaryEvent ? PacketType.EVENT : PacketType.ACK;
2011
+ this.reconstructor = new BinaryReconstructor(packet);
2012
+ if (packet.attachments === 0) {
2013
+ super.emitReserved("decoded", packet);
2014
+ }
2015
+ } else {
2016
+ super.emitReserved("decoded", packet);
2017
+ }
2018
+ } else if (isBinary(obj) || obj.base64) {
2019
+ if (!this.reconstructor) {
2020
+ throw new Error("got binary data when not reconstructing a packet");
2021
+ } else {
2022
+ packet = this.reconstructor.takeBinaryData(obj);
2023
+ if (packet) {
2024
+ this.reconstructor = null;
2025
+ super.emitReserved("decoded", packet);
2026
+ }
2027
+ }
2028
+ } else {
2029
+ throw new Error("Unknown type: " + obj);
2030
+ }
2031
+ }
2032
+ /**
2033
+ * Decode a packet String (JSON data)
2034
+ *
2035
+ * @param {String} str
2036
+ * @return {Object} packet
2037
+ */
2038
+ decodeString(str) {
2039
+ let i2 = 0;
2040
+ const p = {
2041
+ type: Number(str.charAt(0))
2042
+ };
2043
+ if (PacketType[p.type] === void 0) {
2044
+ throw new Error("unknown packet type " + p.type);
2045
+ }
2046
+ if (p.type === PacketType.BINARY_EVENT || p.type === PacketType.BINARY_ACK) {
2047
+ const start = i2 + 1;
2048
+ while (str.charAt(++i2) !== "-" && i2 != str.length) {
2049
+ }
2050
+ const buf = str.substring(start, i2);
2051
+ if (buf != Number(buf) || str.charAt(i2) !== "-") {
2052
+ throw new Error("Illegal attachments");
2053
+ }
2054
+ p.attachments = Number(buf);
2055
+ }
2056
+ if ("/" === str.charAt(i2 + 1)) {
2057
+ const start = i2 + 1;
2058
+ while (++i2) {
2059
+ const c = str.charAt(i2);
2060
+ if ("," === c)
2061
+ break;
2062
+ if (i2 === str.length)
2063
+ break;
2064
+ }
2065
+ p.nsp = str.substring(start, i2);
2066
+ } else {
2067
+ p.nsp = "/";
2068
+ }
2069
+ const next = str.charAt(i2 + 1);
2070
+ if ("" !== next && Number(next) == next) {
2071
+ const start = i2 + 1;
2072
+ while (++i2) {
2073
+ const c = str.charAt(i2);
2074
+ if (null == c || Number(c) != c) {
2075
+ --i2;
2076
+ break;
2077
+ }
2078
+ if (i2 === str.length)
2079
+ break;
2080
+ }
2081
+ p.id = Number(str.substring(start, i2 + 1));
2082
+ }
2083
+ if (str.charAt(++i2)) {
2084
+ const payload = this.tryParse(str.substr(i2));
2085
+ if (_Decoder.isPayloadValid(p.type, payload)) {
2086
+ p.data = payload;
2087
+ } else {
2088
+ throw new Error("invalid payload");
2089
+ }
2090
+ }
2091
+ return p;
2092
+ }
2093
+ tryParse(str) {
2094
+ try {
2095
+ return JSON.parse(str, this.reviver);
2096
+ } catch (e) {
2097
+ return false;
2098
+ }
2099
+ }
2100
+ static isPayloadValid(type, payload) {
2101
+ switch (type) {
2102
+ case PacketType.CONNECT:
2103
+ return isObject(payload);
2104
+ case PacketType.DISCONNECT:
2105
+ return payload === void 0;
2106
+ case PacketType.CONNECT_ERROR:
2107
+ return typeof payload === "string" || isObject(payload);
2108
+ case PacketType.EVENT:
2109
+ case PacketType.BINARY_EVENT:
2110
+ return Array.isArray(payload) && (typeof payload[0] === "number" || typeof payload[0] === "string" && RESERVED_EVENTS.indexOf(payload[0]) === -1);
2111
+ case PacketType.ACK:
2112
+ case PacketType.BINARY_ACK:
2113
+ return Array.isArray(payload);
2114
+ }
2115
+ }
2116
+ /**
2117
+ * Deallocates a parser's resources
2118
+ */
2119
+ destroy() {
2120
+ if (this.reconstructor) {
2121
+ this.reconstructor.finishedReconstruction();
2122
+ this.reconstructor = null;
2123
+ }
2124
+ }
2125
+ };
2126
+ var BinaryReconstructor = class {
2127
+ constructor(packet) {
2128
+ this.packet = packet;
2129
+ this.buffers = [];
2130
+ this.reconPack = packet;
2131
+ }
2132
+ /**
2133
+ * Method to be called when binary data received from connection
2134
+ * after a BINARY_EVENT packet.
2135
+ *
2136
+ * @param {Buffer | ArrayBuffer} binData - the raw binary data received
2137
+ * @return {null | Object} returns null if more binary data is expected or
2138
+ * a reconstructed packet object if all buffers have been received.
2139
+ */
2140
+ takeBinaryData(binData) {
2141
+ this.buffers.push(binData);
2142
+ if (this.buffers.length === this.reconPack.attachments) {
2143
+ const packet = reconstructPacket(this.reconPack, this.buffers);
2144
+ this.finishedReconstruction();
2145
+ return packet;
2146
+ }
2147
+ return null;
2148
+ }
2149
+ /**
2150
+ * Cleans up binary packet reconstruction variables.
2151
+ */
2152
+ finishedReconstruction() {
2153
+ this.reconPack = null;
2154
+ this.buffers = [];
2155
+ }
2156
+ };
2157
+
2158
+ // node_modules/socket.io-client/build/esm/on.js
2159
+ function on(obj, ev, fn) {
2160
+ obj.on(ev, fn);
2161
+ return function subDestroy() {
2162
+ obj.off(ev, fn);
2163
+ };
2164
+ }
2165
+
2166
+ // node_modules/socket.io-client/build/esm/socket.js
2167
+ var RESERVED_EVENTS2 = Object.freeze({
2168
+ connect: 1,
2169
+ connect_error: 1,
2170
+ disconnect: 1,
2171
+ disconnecting: 1,
2172
+ // EventEmitter reserved events: https://nodejs.org/api/events.html#events_event_newlistener
2173
+ newListener: 1,
2174
+ removeListener: 1
2175
+ });
2176
+ var Socket2 = class extends Emitter {
2177
+ /**
2178
+ * `Socket` constructor.
2179
+ */
2180
+ constructor(io, nsp, opts) {
2181
+ super();
2182
+ this.connected = false;
2183
+ this.recovered = false;
2184
+ this.receiveBuffer = [];
2185
+ this.sendBuffer = [];
2186
+ this._queue = [];
2187
+ this._queueSeq = 0;
2188
+ this.ids = 0;
2189
+ this.acks = {};
2190
+ this.flags = {};
2191
+ this.io = io;
2192
+ this.nsp = nsp;
2193
+ if (opts && opts.auth) {
2194
+ this.auth = opts.auth;
2195
+ }
2196
+ this._opts = Object.assign({}, opts);
2197
+ if (this.io._autoConnect)
2198
+ this.open();
2199
+ }
2200
+ /**
2201
+ * Whether the socket is currently disconnected
2202
+ *
2203
+ * @example
2204
+ * const socket = io();
2205
+ *
2206
+ * socket.on("connect", () => {
2207
+ * console.log(socket.disconnected); // false
2208
+ * });
2209
+ *
2210
+ * socket.on("disconnect", () => {
2211
+ * console.log(socket.disconnected); // true
2212
+ * });
2213
+ */
2214
+ get disconnected() {
2215
+ return !this.connected;
2216
+ }
2217
+ /**
2218
+ * Subscribe to open, close and packet events
2219
+ *
2220
+ * @private
2221
+ */
2222
+ subEvents() {
2223
+ if (this.subs)
2224
+ return;
2225
+ const io = this.io;
2226
+ this.subs = [
2227
+ on(io, "open", this.onopen.bind(this)),
2228
+ on(io, "packet", this.onpacket.bind(this)),
2229
+ on(io, "error", this.onerror.bind(this)),
2230
+ on(io, "close", this.onclose.bind(this))
2231
+ ];
2232
+ }
2233
+ /**
2234
+ * Whether the Socket will try to reconnect when its Manager connects or reconnects.
2235
+ *
2236
+ * @example
2237
+ * const socket = io();
2238
+ *
2239
+ * console.log(socket.active); // true
2240
+ *
2241
+ * socket.on("disconnect", (reason) => {
2242
+ * if (reason === "io server disconnect") {
2243
+ * // the disconnection was initiated by the server, you need to manually reconnect
2244
+ * console.log(socket.active); // false
2245
+ * }
2246
+ * // else the socket will automatically try to reconnect
2247
+ * console.log(socket.active); // true
2248
+ * });
2249
+ */
2250
+ get active() {
2251
+ return !!this.subs;
2252
+ }
2253
+ /**
2254
+ * "Opens" the socket.
2255
+ *
2256
+ * @example
2257
+ * const socket = io({
2258
+ * autoConnect: false
2259
+ * });
2260
+ *
2261
+ * socket.connect();
2262
+ */
2263
+ connect() {
2264
+ if (this.connected)
2265
+ return this;
2266
+ this.subEvents();
2267
+ if (!this.io["_reconnecting"])
2268
+ this.io.open();
2269
+ if ("open" === this.io._readyState)
2270
+ this.onopen();
2271
+ return this;
2272
+ }
2273
+ /**
2274
+ * Alias for {@link connect()}.
2275
+ */
2276
+ open() {
2277
+ return this.connect();
2278
+ }
2279
+ /**
2280
+ * Sends a `message` event.
2281
+ *
2282
+ * This method mimics the WebSocket.send() method.
2283
+ *
2284
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send
2285
+ *
2286
+ * @example
2287
+ * socket.send("hello");
2288
+ *
2289
+ * // this is equivalent to
2290
+ * socket.emit("message", "hello");
2291
+ *
2292
+ * @return self
2293
+ */
2294
+ send(...args) {
2295
+ args.unshift("message");
2296
+ this.emit.apply(this, args);
2297
+ return this;
2298
+ }
2299
+ /**
2300
+ * Override `emit`.
2301
+ * If the event is in `events`, it's emitted normally.
2302
+ *
2303
+ * @example
2304
+ * socket.emit("hello", "world");
2305
+ *
2306
+ * // all serializable datastructures are supported (no need to call JSON.stringify)
2307
+ * socket.emit("hello", 1, "2", { 3: ["4"], 5: Uint8Array.from([6]) });
2308
+ *
2309
+ * // with an acknowledgement from the server
2310
+ * socket.emit("hello", "world", (val) => {
2311
+ * // ...
2312
+ * });
2313
+ *
2314
+ * @return self
2315
+ */
2316
+ emit(ev, ...args) {
2317
+ if (RESERVED_EVENTS2.hasOwnProperty(ev)) {
2318
+ throw new Error('"' + ev.toString() + '" is a reserved event name');
2319
+ }
2320
+ args.unshift(ev);
2321
+ if (this._opts.retries && !this.flags.fromQueue && !this.flags.volatile) {
2322
+ this._addToQueue(args);
2323
+ return this;
2324
+ }
2325
+ const packet = {
2326
+ type: PacketType.EVENT,
2327
+ data: args
2328
+ };
2329
+ packet.options = {};
2330
+ packet.options.compress = this.flags.compress !== false;
2331
+ if ("function" === typeof args[args.length - 1]) {
2332
+ const id = this.ids++;
2333
+ const ack = args.pop();
2334
+ this._registerAckCallback(id, ack);
2335
+ packet.id = id;
2336
+ }
2337
+ const isTransportWritable = this.io.engine && this.io.engine.transport && this.io.engine.transport.writable;
2338
+ const discardPacket = this.flags.volatile && (!isTransportWritable || !this.connected);
2339
+ if (discardPacket) {
2340
+ } else if (this.connected) {
2341
+ this.notifyOutgoingListeners(packet);
2342
+ this.packet(packet);
2343
+ } else {
2344
+ this.sendBuffer.push(packet);
2345
+ }
2346
+ this.flags = {};
2347
+ return this;
2348
+ }
2349
+ /**
2350
+ * @private
2351
+ */
2352
+ _registerAckCallback(id, ack) {
2353
+ var _a;
2354
+ const timeout = (_a = this.flags.timeout) !== null && _a !== void 0 ? _a : this._opts.ackTimeout;
2355
+ if (timeout === void 0) {
2356
+ this.acks[id] = ack;
2357
+ return;
2358
+ }
2359
+ const timer = this.io.setTimeoutFn(() => {
2360
+ delete this.acks[id];
2361
+ for (let i2 = 0; i2 < this.sendBuffer.length; i2++) {
2362
+ if (this.sendBuffer[i2].id === id) {
2363
+ this.sendBuffer.splice(i2, 1);
2364
+ }
2365
+ }
2366
+ ack.call(this, new Error("operation has timed out"));
2367
+ }, timeout);
2368
+ const fn = (...args) => {
2369
+ this.io.clearTimeoutFn(timer);
2370
+ ack.apply(this, args);
2371
+ };
2372
+ fn.withError = true;
2373
+ this.acks[id] = fn;
2374
+ }
2375
+ /**
2376
+ * Emits an event and waits for an acknowledgement
2377
+ *
2378
+ * @example
2379
+ * // without timeout
2380
+ * const response = await socket.emitWithAck("hello", "world");
2381
+ *
2382
+ * // with a specific timeout
2383
+ * try {
2384
+ * const response = await socket.timeout(1000).emitWithAck("hello", "world");
2385
+ * } catch (err) {
2386
+ * // the server did not acknowledge the event in the given delay
2387
+ * }
2388
+ *
2389
+ * @return a Promise that will be fulfilled when the server acknowledges the event
2390
+ */
2391
+ emitWithAck(ev, ...args) {
2392
+ return new Promise((resolve, reject) => {
2393
+ const fn = (arg1, arg2) => {
2394
+ return arg1 ? reject(arg1) : resolve(arg2);
2395
+ };
2396
+ fn.withError = true;
2397
+ args.push(fn);
2398
+ this.emit(ev, ...args);
2399
+ });
2400
+ }
2401
+ /**
2402
+ * Add the packet to the queue.
2403
+ * @param args
2404
+ * @private
2405
+ */
2406
+ _addToQueue(args) {
2407
+ let ack;
2408
+ if (typeof args[args.length - 1] === "function") {
2409
+ ack = args.pop();
2410
+ }
2411
+ const packet = {
2412
+ id: this._queueSeq++,
2413
+ tryCount: 0,
2414
+ pending: false,
2415
+ args,
2416
+ flags: Object.assign({ fromQueue: true }, this.flags)
2417
+ };
2418
+ args.push((err, ...responseArgs) => {
2419
+ if (packet !== this._queue[0]) {
2420
+ return;
2421
+ }
2422
+ const hasError = err !== null;
2423
+ if (hasError) {
2424
+ if (packet.tryCount > this._opts.retries) {
2425
+ this._queue.shift();
2426
+ if (ack) {
2427
+ ack(err);
2428
+ }
2429
+ }
2430
+ } else {
2431
+ this._queue.shift();
2432
+ if (ack) {
2433
+ ack(null, ...responseArgs);
2434
+ }
2435
+ }
2436
+ packet.pending = false;
2437
+ return this._drainQueue();
2438
+ });
2439
+ this._queue.push(packet);
2440
+ this._drainQueue();
2441
+ }
2442
+ /**
2443
+ * Send the first packet of the queue, and wait for an acknowledgement from the server.
2444
+ * @param force - whether to resend a packet that has not been acknowledged yet
2445
+ *
2446
+ * @private
2447
+ */
2448
+ _drainQueue(force = false) {
2449
+ if (!this.connected || this._queue.length === 0) {
2450
+ return;
2451
+ }
2452
+ const packet = this._queue[0];
2453
+ if (packet.pending && !force) {
2454
+ return;
2455
+ }
2456
+ packet.pending = true;
2457
+ packet.tryCount++;
2458
+ this.flags = packet.flags;
2459
+ this.emit.apply(this, packet.args);
2460
+ }
2461
+ /**
2462
+ * Sends a packet.
2463
+ *
2464
+ * @param packet
2465
+ * @private
2466
+ */
2467
+ packet(packet) {
2468
+ packet.nsp = this.nsp;
2469
+ this.io._packet(packet);
2470
+ }
2471
+ /**
2472
+ * Called upon engine `open`.
2473
+ *
2474
+ * @private
2475
+ */
2476
+ onopen() {
2477
+ if (typeof this.auth == "function") {
2478
+ this.auth((data) => {
2479
+ this._sendConnectPacket(data);
2480
+ });
2481
+ } else {
2482
+ this._sendConnectPacket(this.auth);
2483
+ }
2484
+ }
2485
+ /**
2486
+ * Sends a CONNECT packet to initiate the Socket.IO session.
2487
+ *
2488
+ * @param data
2489
+ * @private
2490
+ */
2491
+ _sendConnectPacket(data) {
2492
+ this.packet({
2493
+ type: PacketType.CONNECT,
2494
+ data: this._pid ? Object.assign({ pid: this._pid, offset: this._lastOffset }, data) : data
2495
+ });
2496
+ }
2497
+ /**
2498
+ * Called upon engine or manager `error`.
2499
+ *
2500
+ * @param err
2501
+ * @private
2502
+ */
2503
+ onerror(err) {
2504
+ if (!this.connected) {
2505
+ this.emitReserved("connect_error", err);
2506
+ }
2507
+ }
2508
+ /**
2509
+ * Called upon engine `close`.
2510
+ *
2511
+ * @param reason
2512
+ * @param description
2513
+ * @private
2514
+ */
2515
+ onclose(reason, description) {
2516
+ this.connected = false;
2517
+ delete this.id;
2518
+ this.emitReserved("disconnect", reason, description);
2519
+ this._clearAcks();
2520
+ }
2521
+ /**
2522
+ * Clears the acknowledgement handlers upon disconnection, since the client will never receive an acknowledgement from
2523
+ * the server.
2524
+ *
2525
+ * @private
2526
+ */
2527
+ _clearAcks() {
2528
+ Object.keys(this.acks).forEach((id) => {
2529
+ const isBuffered = this.sendBuffer.some((packet) => String(packet.id) === id);
2530
+ if (!isBuffered) {
2531
+ const ack = this.acks[id];
2532
+ delete this.acks[id];
2533
+ if (ack.withError) {
2534
+ ack.call(this, new Error("socket has been disconnected"));
2535
+ }
2536
+ }
2537
+ });
2538
+ }
2539
+ /**
2540
+ * Called with socket packet.
2541
+ *
2542
+ * @param packet
2543
+ * @private
2544
+ */
2545
+ onpacket(packet) {
2546
+ const sameNamespace = packet.nsp === this.nsp;
2547
+ if (!sameNamespace)
2548
+ return;
2549
+ switch (packet.type) {
2550
+ case PacketType.CONNECT:
2551
+ if (packet.data && packet.data.sid) {
2552
+ this.onconnect(packet.data.sid, packet.data.pid);
2553
+ } else {
2554
+ 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/)"));
2555
+ }
2556
+ break;
2557
+ case PacketType.EVENT:
2558
+ case PacketType.BINARY_EVENT:
2559
+ this.onevent(packet);
2560
+ break;
2561
+ case PacketType.ACK:
2562
+ case PacketType.BINARY_ACK:
2563
+ this.onack(packet);
2564
+ break;
2565
+ case PacketType.DISCONNECT:
2566
+ this.ondisconnect();
2567
+ break;
2568
+ case PacketType.CONNECT_ERROR:
2569
+ this.destroy();
2570
+ const err = new Error(packet.data.message);
2571
+ err.data = packet.data.data;
2572
+ this.emitReserved("connect_error", err);
2573
+ break;
2574
+ }
2575
+ }
2576
+ /**
2577
+ * Called upon a server event.
2578
+ *
2579
+ * @param packet
2580
+ * @private
2581
+ */
2582
+ onevent(packet) {
2583
+ const args = packet.data || [];
2584
+ if (null != packet.id) {
2585
+ args.push(this.ack(packet.id));
2586
+ }
2587
+ if (this.connected) {
2588
+ this.emitEvent(args);
2589
+ } else {
2590
+ this.receiveBuffer.push(Object.freeze(args));
2591
+ }
2592
+ }
2593
+ emitEvent(args) {
2594
+ if (this._anyListeners && this._anyListeners.length) {
2595
+ const listeners = this._anyListeners.slice();
2596
+ for (const listener of listeners) {
2597
+ listener.apply(this, args);
2598
+ }
2599
+ }
2600
+ super.emit.apply(this, args);
2601
+ if (this._pid && args.length && typeof args[args.length - 1] === "string") {
2602
+ this._lastOffset = args[args.length - 1];
2603
+ }
2604
+ }
2605
+ /**
2606
+ * Produces an ack callback to emit with an event.
2607
+ *
2608
+ * @private
2609
+ */
2610
+ ack(id) {
2611
+ const self2 = this;
2612
+ let sent = false;
2613
+ return function(...args) {
2614
+ if (sent)
2615
+ return;
2616
+ sent = true;
2617
+ self2.packet({
2618
+ type: PacketType.ACK,
2619
+ id,
2620
+ data: args
2621
+ });
2622
+ };
2623
+ }
2624
+ /**
2625
+ * Called upon a server acknowledgement.
2626
+ *
2627
+ * @param packet
2628
+ * @private
2629
+ */
2630
+ onack(packet) {
2631
+ const ack = this.acks[packet.id];
2632
+ if (typeof ack !== "function") {
2633
+ return;
2634
+ }
2635
+ delete this.acks[packet.id];
2636
+ if (ack.withError) {
2637
+ packet.data.unshift(null);
2638
+ }
2639
+ ack.apply(this, packet.data);
2640
+ }
2641
+ /**
2642
+ * Called upon server connect.
2643
+ *
2644
+ * @private
2645
+ */
2646
+ onconnect(id, pid) {
2647
+ this.id = id;
2648
+ this.recovered = pid && this._pid === pid;
2649
+ this._pid = pid;
2650
+ this.connected = true;
2651
+ this.emitBuffered();
2652
+ this.emitReserved("connect");
2653
+ this._drainQueue(true);
2654
+ }
2655
+ /**
2656
+ * Emit buffered events (received and emitted).
2657
+ *
2658
+ * @private
2659
+ */
2660
+ emitBuffered() {
2661
+ this.receiveBuffer.forEach((args) => this.emitEvent(args));
2662
+ this.receiveBuffer = [];
2663
+ this.sendBuffer.forEach((packet) => {
2664
+ this.notifyOutgoingListeners(packet);
2665
+ this.packet(packet);
2666
+ });
2667
+ this.sendBuffer = [];
2668
+ }
2669
+ /**
2670
+ * Called upon server disconnect.
2671
+ *
2672
+ * @private
2673
+ */
2674
+ ondisconnect() {
2675
+ this.destroy();
2676
+ this.onclose("io server disconnect");
2677
+ }
2678
+ /**
2679
+ * Called upon forced client/server side disconnections,
2680
+ * this method ensures the manager stops tracking us and
2681
+ * that reconnections don't get triggered for this.
2682
+ *
2683
+ * @private
2684
+ */
2685
+ destroy() {
2686
+ if (this.subs) {
2687
+ this.subs.forEach((subDestroy) => subDestroy());
2688
+ this.subs = void 0;
2689
+ }
2690
+ this.io["_destroy"](this);
2691
+ }
2692
+ /**
2693
+ * Disconnects the socket manually. In that case, the socket will not try to reconnect.
2694
+ *
2695
+ * If this is the last active Socket instance of the {@link Manager}, the low-level connection will be closed.
2696
+ *
2697
+ * @example
2698
+ * const socket = io();
2699
+ *
2700
+ * socket.on("disconnect", (reason) => {
2701
+ * // console.log(reason); prints "io client disconnect"
2702
+ * });
2703
+ *
2704
+ * socket.disconnect();
2705
+ *
2706
+ * @return self
2707
+ */
2708
+ disconnect() {
2709
+ if (this.connected) {
2710
+ this.packet({ type: PacketType.DISCONNECT });
2711
+ }
2712
+ this.destroy();
2713
+ if (this.connected) {
2714
+ this.onclose("io client disconnect");
2715
+ }
2716
+ return this;
2717
+ }
2718
+ /**
2719
+ * Alias for {@link disconnect()}.
2720
+ *
2721
+ * @return self
2722
+ */
2723
+ close() {
2724
+ return this.disconnect();
2725
+ }
2726
+ /**
2727
+ * Sets the compress flag.
2728
+ *
2729
+ * @example
2730
+ * socket.compress(false).emit("hello");
2731
+ *
2732
+ * @param compress - if `true`, compresses the sending data
2733
+ * @return self
2734
+ */
2735
+ compress(compress) {
2736
+ this.flags.compress = compress;
2737
+ return this;
2738
+ }
2739
+ /**
2740
+ * Sets a modifier for a subsequent event emission that the event message will be dropped when this socket is not
2741
+ * ready to send messages.
2742
+ *
2743
+ * @example
2744
+ * socket.volatile.emit("hello"); // the server may or may not receive it
2745
+ *
2746
+ * @returns self
2747
+ */
2748
+ get volatile() {
2749
+ this.flags.volatile = true;
2750
+ return this;
2751
+ }
2752
+ /**
2753
+ * Sets a modifier for a subsequent event emission that the callback will be called with an error when the
2754
+ * given number of milliseconds have elapsed without an acknowledgement from the server:
2755
+ *
2756
+ * @example
2757
+ * socket.timeout(5000).emit("my-event", (err) => {
2758
+ * if (err) {
2759
+ * // the server did not acknowledge the event in the given delay
2760
+ * }
2761
+ * });
2762
+ *
2763
+ * @returns self
2764
+ */
2765
+ timeout(timeout) {
2766
+ this.flags.timeout = timeout;
2767
+ return this;
2768
+ }
2769
+ /**
2770
+ * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
2771
+ * callback.
2772
+ *
2773
+ * @example
2774
+ * socket.onAny((event, ...args) => {
2775
+ * console.log(`got ${event}`);
2776
+ * });
2777
+ *
2778
+ * @param listener
2779
+ */
2780
+ onAny(listener) {
2781
+ this._anyListeners = this._anyListeners || [];
2782
+ this._anyListeners.push(listener);
2783
+ return this;
2784
+ }
2785
+ /**
2786
+ * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
2787
+ * callback. The listener is added to the beginning of the listeners array.
2788
+ *
2789
+ * @example
2790
+ * socket.prependAny((event, ...args) => {
2791
+ * console.log(`got event ${event}`);
2792
+ * });
2793
+ *
2794
+ * @param listener
2795
+ */
2796
+ prependAny(listener) {
2797
+ this._anyListeners = this._anyListeners || [];
2798
+ this._anyListeners.unshift(listener);
2799
+ return this;
2800
+ }
2801
+ /**
2802
+ * Removes the listener that will be fired when any event is emitted.
2803
+ *
2804
+ * @example
2805
+ * const catchAllListener = (event, ...args) => {
2806
+ * console.log(`got event ${event}`);
2807
+ * }
2808
+ *
2809
+ * socket.onAny(catchAllListener);
2810
+ *
2811
+ * // remove a specific listener
2812
+ * socket.offAny(catchAllListener);
2813
+ *
2814
+ * // or remove all listeners
2815
+ * socket.offAny();
2816
+ *
2817
+ * @param listener
2818
+ */
2819
+ offAny(listener) {
2820
+ if (!this._anyListeners) {
2821
+ return this;
2822
+ }
2823
+ if (listener) {
2824
+ const listeners = this._anyListeners;
2825
+ for (let i2 = 0; i2 < listeners.length; i2++) {
2826
+ if (listener === listeners[i2]) {
2827
+ listeners.splice(i2, 1);
2828
+ return this;
2829
+ }
2830
+ }
2831
+ } else {
2832
+ this._anyListeners = [];
2833
+ }
2834
+ return this;
2835
+ }
2836
+ /**
2837
+ * Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,
2838
+ * e.g. to remove listeners.
2839
+ */
2840
+ listenersAny() {
2841
+ return this._anyListeners || [];
2842
+ }
2843
+ /**
2844
+ * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
2845
+ * callback.
2846
+ *
2847
+ * Note: acknowledgements sent to the server are not included.
2848
+ *
2849
+ * @example
2850
+ * socket.onAnyOutgoing((event, ...args) => {
2851
+ * console.log(`sent event ${event}`);
2852
+ * });
2853
+ *
2854
+ * @param listener
2855
+ */
2856
+ onAnyOutgoing(listener) {
2857
+ this._anyOutgoingListeners = this._anyOutgoingListeners || [];
2858
+ this._anyOutgoingListeners.push(listener);
2859
+ return this;
2860
+ }
2861
+ /**
2862
+ * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
2863
+ * callback. The listener is added to the beginning of the listeners array.
2864
+ *
2865
+ * Note: acknowledgements sent to the server are not included.
2866
+ *
2867
+ * @example
2868
+ * socket.prependAnyOutgoing((event, ...args) => {
2869
+ * console.log(`sent event ${event}`);
2870
+ * });
2871
+ *
2872
+ * @param listener
2873
+ */
2874
+ prependAnyOutgoing(listener) {
2875
+ this._anyOutgoingListeners = this._anyOutgoingListeners || [];
2876
+ this._anyOutgoingListeners.unshift(listener);
2877
+ return this;
2878
+ }
2879
+ /**
2880
+ * Removes the listener that will be fired when any event is emitted.
2881
+ *
2882
+ * @example
2883
+ * const catchAllListener = (event, ...args) => {
2884
+ * console.log(`sent event ${event}`);
2885
+ * }
2886
+ *
2887
+ * socket.onAnyOutgoing(catchAllListener);
2888
+ *
2889
+ * // remove a specific listener
2890
+ * socket.offAnyOutgoing(catchAllListener);
2891
+ *
2892
+ * // or remove all listeners
2893
+ * socket.offAnyOutgoing();
2894
+ *
2895
+ * @param [listener] - the catch-all listener (optional)
2896
+ */
2897
+ offAnyOutgoing(listener) {
2898
+ if (!this._anyOutgoingListeners) {
2899
+ return this;
2900
+ }
2901
+ if (listener) {
2902
+ const listeners = this._anyOutgoingListeners;
2903
+ for (let i2 = 0; i2 < listeners.length; i2++) {
2904
+ if (listener === listeners[i2]) {
2905
+ listeners.splice(i2, 1);
2906
+ return this;
2907
+ }
2908
+ }
2909
+ } else {
2910
+ this._anyOutgoingListeners = [];
2911
+ }
2912
+ return this;
2913
+ }
2914
+ /**
2915
+ * Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,
2916
+ * e.g. to remove listeners.
2917
+ */
2918
+ listenersAnyOutgoing() {
2919
+ return this._anyOutgoingListeners || [];
2920
+ }
2921
+ /**
2922
+ * Notify the listeners for each packet sent
2923
+ *
2924
+ * @param packet
2925
+ *
2926
+ * @private
2927
+ */
2928
+ notifyOutgoingListeners(packet) {
2929
+ if (this._anyOutgoingListeners && this._anyOutgoingListeners.length) {
2930
+ const listeners = this._anyOutgoingListeners.slice();
2931
+ for (const listener of listeners) {
2932
+ listener.apply(this, packet.data);
2933
+ }
2934
+ }
2935
+ }
2936
+ };
2937
+
2938
+ // node_modules/socket.io-client/build/esm/contrib/backo2.js
2939
+ function Backoff(opts) {
2940
+ opts = opts || {};
2941
+ this.ms = opts.min || 100;
2942
+ this.max = opts.max || 1e4;
2943
+ this.factor = opts.factor || 2;
2944
+ this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;
2945
+ this.attempts = 0;
2946
+ }
2947
+ Backoff.prototype.duration = function() {
2948
+ var ms = this.ms * Math.pow(this.factor, this.attempts++);
2949
+ if (this.jitter) {
2950
+ var rand = Math.random();
2951
+ var deviation = Math.floor(rand * this.jitter * ms);
2952
+ ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;
2953
+ }
2954
+ return Math.min(ms, this.max) | 0;
2955
+ };
2956
+ Backoff.prototype.reset = function() {
2957
+ this.attempts = 0;
2958
+ };
2959
+ Backoff.prototype.setMin = function(min) {
2960
+ this.ms = min;
2961
+ };
2962
+ Backoff.prototype.setMax = function(max) {
2963
+ this.max = max;
2964
+ };
2965
+ Backoff.prototype.setJitter = function(jitter) {
2966
+ this.jitter = jitter;
2967
+ };
2968
+
2969
+ // node_modules/socket.io-client/build/esm/manager.js
2970
+ var Manager = class extends Emitter {
2971
+ constructor(uri, opts) {
2972
+ var _a;
2973
+ super();
2974
+ this.nsps = {};
2975
+ this.subs = [];
2976
+ if (uri && "object" === typeof uri) {
2977
+ opts = uri;
2978
+ uri = void 0;
2979
+ }
2980
+ opts = opts || {};
2981
+ opts.path = opts.path || "/socket.io";
2982
+ this.opts = opts;
2983
+ installTimerFunctions(this, opts);
2984
+ this.reconnection(opts.reconnection !== false);
2985
+ this.reconnectionAttempts(opts.reconnectionAttempts || Infinity);
2986
+ this.reconnectionDelay(opts.reconnectionDelay || 1e3);
2987
+ this.reconnectionDelayMax(opts.reconnectionDelayMax || 5e3);
2988
+ this.randomizationFactor((_a = opts.randomizationFactor) !== null && _a !== void 0 ? _a : 0.5);
2989
+ this.backoff = new Backoff({
2990
+ min: this.reconnectionDelay(),
2991
+ max: this.reconnectionDelayMax(),
2992
+ jitter: this.randomizationFactor()
2993
+ });
2994
+ this.timeout(null == opts.timeout ? 2e4 : opts.timeout);
2995
+ this._readyState = "closed";
2996
+ this.uri = uri;
2997
+ const _parser = opts.parser || esm_exports;
2998
+ this.encoder = new _parser.Encoder();
2999
+ this.decoder = new _parser.Decoder();
3000
+ this._autoConnect = opts.autoConnect !== false;
3001
+ if (this._autoConnect)
3002
+ this.open();
3003
+ }
3004
+ reconnection(v) {
3005
+ if (!arguments.length)
3006
+ return this._reconnection;
3007
+ this._reconnection = !!v;
3008
+ return this;
3009
+ }
3010
+ reconnectionAttempts(v) {
3011
+ if (v === void 0)
3012
+ return this._reconnectionAttempts;
3013
+ this._reconnectionAttempts = v;
3014
+ return this;
3015
+ }
3016
+ reconnectionDelay(v) {
3017
+ var _a;
3018
+ if (v === void 0)
3019
+ return this._reconnectionDelay;
3020
+ this._reconnectionDelay = v;
3021
+ (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setMin(v);
3022
+ return this;
3023
+ }
3024
+ randomizationFactor(v) {
3025
+ var _a;
3026
+ if (v === void 0)
3027
+ return this._randomizationFactor;
3028
+ this._randomizationFactor = v;
3029
+ (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setJitter(v);
3030
+ return this;
3031
+ }
3032
+ reconnectionDelayMax(v) {
3033
+ var _a;
3034
+ if (v === void 0)
3035
+ return this._reconnectionDelayMax;
3036
+ this._reconnectionDelayMax = v;
3037
+ (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setMax(v);
3038
+ return this;
3039
+ }
3040
+ timeout(v) {
3041
+ if (!arguments.length)
3042
+ return this._timeout;
3043
+ this._timeout = v;
3044
+ return this;
3045
+ }
3046
+ /**
3047
+ * Starts trying to reconnect if reconnection is enabled and we have not
3048
+ * started reconnecting yet
3049
+ *
3050
+ * @private
3051
+ */
3052
+ maybeReconnectOnOpen() {
3053
+ if (!this._reconnecting && this._reconnection && this.backoff.attempts === 0) {
3054
+ this.reconnect();
3055
+ }
3056
+ }
3057
+ /**
3058
+ * Sets the current transport `socket`.
3059
+ *
3060
+ * @param {Function} fn - optional, callback
3061
+ * @return self
3062
+ * @public
3063
+ */
3064
+ open(fn) {
3065
+ if (~this._readyState.indexOf("open"))
3066
+ return this;
3067
+ this.engine = new Socket(this.uri, this.opts);
3068
+ const socket = this.engine;
3069
+ const self2 = this;
3070
+ this._readyState = "opening";
3071
+ this.skipReconnect = false;
3072
+ const openSubDestroy = on(socket, "open", function() {
3073
+ self2.onopen();
3074
+ fn && fn();
3075
+ });
3076
+ const onError = (err) => {
3077
+ this.cleanup();
3078
+ this._readyState = "closed";
3079
+ this.emitReserved("error", err);
3080
+ if (fn) {
3081
+ fn(err);
3082
+ } else {
3083
+ this.maybeReconnectOnOpen();
3084
+ }
3085
+ };
3086
+ const errorSub = on(socket, "error", onError);
3087
+ if (false !== this._timeout) {
3088
+ const timeout = this._timeout;
3089
+ const timer = this.setTimeoutFn(() => {
3090
+ openSubDestroy();
3091
+ onError(new Error("timeout"));
3092
+ socket.close();
3093
+ }, timeout);
3094
+ if (this.opts.autoUnref) {
3095
+ timer.unref();
3096
+ }
3097
+ this.subs.push(() => {
3098
+ this.clearTimeoutFn(timer);
3099
+ });
3100
+ }
3101
+ this.subs.push(openSubDestroy);
3102
+ this.subs.push(errorSub);
3103
+ return this;
3104
+ }
3105
+ /**
3106
+ * Alias for open()
3107
+ *
3108
+ * @return self
3109
+ * @public
3110
+ */
3111
+ connect(fn) {
3112
+ return this.open(fn);
3113
+ }
3114
+ /**
3115
+ * Called upon transport open.
3116
+ *
3117
+ * @private
3118
+ */
3119
+ onopen() {
3120
+ this.cleanup();
3121
+ this._readyState = "open";
3122
+ this.emitReserved("open");
3123
+ const socket = this.engine;
3124
+ this.subs.push(on(socket, "ping", this.onping.bind(this)), on(socket, "data", this.ondata.bind(this)), on(socket, "error", this.onerror.bind(this)), on(socket, "close", this.onclose.bind(this)), on(this.decoder, "decoded", this.ondecoded.bind(this)));
3125
+ }
3126
+ /**
3127
+ * Called upon a ping.
3128
+ *
3129
+ * @private
3130
+ */
3131
+ onping() {
3132
+ this.emitReserved("ping");
3133
+ }
3134
+ /**
3135
+ * Called with data.
3136
+ *
3137
+ * @private
3138
+ */
3139
+ ondata(data) {
3140
+ try {
3141
+ this.decoder.add(data);
3142
+ } catch (e) {
3143
+ this.onclose("parse error", e);
3144
+ }
3145
+ }
3146
+ /**
3147
+ * Called when parser fully decodes a packet.
3148
+ *
3149
+ * @private
3150
+ */
3151
+ ondecoded(packet) {
3152
+ nextTick(() => {
3153
+ this.emitReserved("packet", packet);
3154
+ }, this.setTimeoutFn);
3155
+ }
3156
+ /**
3157
+ * Called upon socket error.
3158
+ *
3159
+ * @private
3160
+ */
3161
+ onerror(err) {
3162
+ this.emitReserved("error", err);
3163
+ }
3164
+ /**
3165
+ * Creates a new socket for the given `nsp`.
3166
+ *
3167
+ * @return {Socket}
3168
+ * @public
3169
+ */
3170
+ socket(nsp, opts) {
3171
+ let socket = this.nsps[nsp];
3172
+ if (!socket) {
3173
+ socket = new Socket2(this, nsp, opts);
3174
+ this.nsps[nsp] = socket;
3175
+ } else if (this._autoConnect && !socket.active) {
3176
+ socket.connect();
3177
+ }
3178
+ return socket;
3179
+ }
3180
+ /**
3181
+ * Called upon a socket close.
3182
+ *
3183
+ * @param socket
3184
+ * @private
3185
+ */
3186
+ _destroy(socket) {
3187
+ const nsps = Object.keys(this.nsps);
3188
+ for (const nsp of nsps) {
3189
+ const socket2 = this.nsps[nsp];
3190
+ if (socket2.active) {
3191
+ return;
3192
+ }
3193
+ }
3194
+ this._close();
3195
+ }
3196
+ /**
3197
+ * Writes a packet.
3198
+ *
3199
+ * @param packet
3200
+ * @private
3201
+ */
3202
+ _packet(packet) {
3203
+ const encodedPackets = this.encoder.encode(packet);
3204
+ for (let i2 = 0; i2 < encodedPackets.length; i2++) {
3205
+ this.engine.write(encodedPackets[i2], packet.options);
3206
+ }
3207
+ }
3208
+ /**
3209
+ * Clean up transport subscriptions and packet buffer.
3210
+ *
3211
+ * @private
3212
+ */
3213
+ cleanup() {
3214
+ this.subs.forEach((subDestroy) => subDestroy());
3215
+ this.subs.length = 0;
3216
+ this.decoder.destroy();
3217
+ }
3218
+ /**
3219
+ * Close the current socket.
3220
+ *
3221
+ * @private
3222
+ */
3223
+ _close() {
3224
+ this.skipReconnect = true;
3225
+ this._reconnecting = false;
3226
+ this.onclose("forced close");
3227
+ if (this.engine)
3228
+ this.engine.close();
3229
+ }
3230
+ /**
3231
+ * Alias for close()
3232
+ *
3233
+ * @private
3234
+ */
3235
+ disconnect() {
3236
+ return this._close();
3237
+ }
3238
+ /**
3239
+ * Called upon engine close.
3240
+ *
3241
+ * @private
3242
+ */
3243
+ onclose(reason, description) {
3244
+ this.cleanup();
3245
+ this.backoff.reset();
3246
+ this._readyState = "closed";
3247
+ this.emitReserved("close", reason, description);
3248
+ if (this._reconnection && !this.skipReconnect) {
3249
+ this.reconnect();
3250
+ }
3251
+ }
3252
+ /**
3253
+ * Attempt a reconnection.
3254
+ *
3255
+ * @private
3256
+ */
3257
+ reconnect() {
3258
+ if (this._reconnecting || this.skipReconnect)
3259
+ return this;
3260
+ const self2 = this;
3261
+ if (this.backoff.attempts >= this._reconnectionAttempts) {
3262
+ this.backoff.reset();
3263
+ this.emitReserved("reconnect_failed");
3264
+ this._reconnecting = false;
3265
+ } else {
3266
+ const delay = this.backoff.duration();
3267
+ this._reconnecting = true;
3268
+ const timer = this.setTimeoutFn(() => {
3269
+ if (self2.skipReconnect)
3270
+ return;
3271
+ this.emitReserved("reconnect_attempt", self2.backoff.attempts);
3272
+ if (self2.skipReconnect)
3273
+ return;
3274
+ self2.open((err) => {
3275
+ if (err) {
3276
+ self2._reconnecting = false;
3277
+ self2.reconnect();
3278
+ this.emitReserved("reconnect_error", err);
3279
+ } else {
3280
+ self2.onreconnect();
3281
+ }
3282
+ });
3283
+ }, delay);
3284
+ if (this.opts.autoUnref) {
3285
+ timer.unref();
3286
+ }
3287
+ this.subs.push(() => {
3288
+ this.clearTimeoutFn(timer);
3289
+ });
3290
+ }
3291
+ }
3292
+ /**
3293
+ * Called upon successful reconnect.
3294
+ *
3295
+ * @private
3296
+ */
3297
+ onreconnect() {
3298
+ const attempt = this.backoff.attempts;
3299
+ this._reconnecting = false;
3300
+ this.backoff.reset();
3301
+ this.emitReserved("reconnect", attempt);
3302
+ }
3303
+ };
3304
+
3305
+ // node_modules/socket.io-client/build/esm/index.js
3306
+ var cache = {};
3307
+ function lookup2(uri, opts) {
3308
+ if (typeof uri === "object") {
3309
+ opts = uri;
3310
+ uri = void 0;
3311
+ }
3312
+ opts = opts || {};
3313
+ const parsed = url(uri, opts.path || "/socket.io");
3314
+ const source = parsed.source;
3315
+ const id = parsed.id;
3316
+ const path = parsed.path;
3317
+ const sameNamespace = cache[id] && path in cache[id]["nsps"];
3318
+ const newConnection = opts.forceNew || opts["force new connection"] || false === opts.multiplex || sameNamespace;
3319
+ let io;
3320
+ if (newConnection) {
3321
+ io = new Manager(source, opts);
3322
+ } else {
3323
+ if (!cache[id]) {
3324
+ cache[id] = new Manager(source, opts);
3325
+ }
3326
+ io = cache[id];
3327
+ }
3328
+ if (parsed.query && !opts.query) {
3329
+ opts.query = parsed.queryKey;
3330
+ }
3331
+ return io.socket(parsed.path, opts);
3332
+ }
3333
+ Object.assign(lookup2, {
3334
+ Manager,
3335
+ Socket: Socket2,
3336
+ io: lookup2,
3337
+ connect: lookup2
3338
+ });
3339
+
3340
+ // package.json
3341
+ var package_default = {
3342
+ name: "@aiqa/sdk",
3343
+ version: "0.0.2",
3344
+ main: "dist/node/node.js",
3345
+ module: "dist/node/node.js",
3346
+ types: "dist/node/node.d.ts",
3347
+ scripts: {
3348
+ build: "tsup",
3349
+ "dev:node": "tsx src/node.ts",
3350
+ "start:node": "node dist/node/node.js",
3351
+ "serve:browser": "serve .",
3352
+ test: "jest"
3353
+ },
3354
+ exports: {
3355
+ ".": {
3356
+ node: {
3357
+ import: "./dist/node/node.js",
3358
+ types: "./dist/node/node.d.ts"
3359
+ },
3360
+ browser: {
3361
+ import: "./dist/browser/browser.js",
3362
+ types: "./dist/browser/browser.d.ts"
3363
+ },
3364
+ default: "./dist/node/node.js"
3365
+ }
3366
+ },
3367
+ private: false,
3368
+ license: "MIT",
3369
+ author: "AIQA",
3370
+ description: "TypeScript/JavaScript SDK for interacting with the AIQA.",
3371
+ keywords: [
3372
+ "aiqa",
3373
+ "sdk"
3374
+ ],
3375
+ files: [
3376
+ "dist"
3377
+ ],
3378
+ devDependencies: {
3379
+ "@jest/globals": "^29.7.0",
3380
+ esbuild: "^0.23.0",
3381
+ jest: "^29.7.0",
3382
+ "socket.io": "^4.7.5",
3383
+ "ts-jest": "^29.2.3",
3384
+ "ts-node": "^10.9.2",
3385
+ "@types/node": "^22.0.0",
3386
+ serve: "^14.2.3",
3387
+ tsup: "^8.0.0",
3388
+ tsx: "^4.0.0",
3389
+ typescript: "^5.7.0"
3390
+ },
3391
+ dependencies: {
3392
+ "socket.io-client": "^4.7.5"
3393
+ }
3394
+ };
3395
+
3396
+ // src/shared.ts
3397
+ var SDK_VERSION = package_default.version ?? "0.0.1";
3398
+ //# sourceMappingURL=browser.mjs.map