jibtalk-core 0.1.0

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,1573 @@
1
+ //#region \0rolldown/runtime.js
2
+ var e = Object.defineProperty, t = (t, n) => {
3
+ let r = {};
4
+ for (var i in t) e(r, i, {
5
+ get: t[i],
6
+ enumerable: !0
7
+ });
8
+ return n || e(r, Symbol.toStringTag, { value: "Module" }), r;
9
+ }, n = Object.create(null);
10
+ n.open = "0", n.close = "1", n.ping = "2", n.pong = "3", n.message = "4", n.upgrade = "5", n.noop = "6";
11
+ var r = Object.create(null);
12
+ Object.keys(n).forEach((e) => {
13
+ r[n[e]] = e;
14
+ });
15
+ var i = {
16
+ type: "error",
17
+ data: "parser error"
18
+ }, a = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", o = typeof ArrayBuffer == "function", s = (e) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(e) : e && e.buffer instanceof ArrayBuffer, c = ({ type: e, data: t }, r, i) => a && t instanceof Blob ? r ? i(t) : l(t, i) : o && (t instanceof ArrayBuffer || s(t)) ? r ? i(t) : l(new Blob([t]), i) : i(n[e] + (t || "")), l = (e, t) => {
19
+ let n = new FileReader();
20
+ return n.onload = function() {
21
+ let e = n.result.split(",")[1];
22
+ t("b" + (e || ""));
23
+ }, n.readAsDataURL(e);
24
+ };
25
+ function u(e) {
26
+ return e instanceof Uint8Array ? e : e instanceof ArrayBuffer ? new Uint8Array(e) : new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
27
+ }
28
+ var d;
29
+ function ee(e, t) {
30
+ if (a && e.data instanceof Blob) return e.data.arrayBuffer().then(u).then(t);
31
+ if (o && (e.data instanceof ArrayBuffer || s(e.data))) return t(u(e.data));
32
+ c(e, !1, (e) => {
33
+ d ||= new TextEncoder(), t(d.encode(e));
34
+ });
35
+ }
36
+ //#endregion
37
+ //#region ../../node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js
38
+ var te = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", f = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
39
+ for (let e = 0; e < 64; e++) f[te.charCodeAt(e)] = e;
40
+ var ne = (e) => {
41
+ let t = e.length * .75, n = e.length, r, i = 0, a, o, s, c;
42
+ e[e.length - 1] === "=" && (t--, e[e.length - 2] === "=" && t--);
43
+ let l = new ArrayBuffer(t), u = new Uint8Array(l);
44
+ for (r = 0; r < n; r += 4) a = f[e.charCodeAt(r)], o = f[e.charCodeAt(r + 1)], s = f[e.charCodeAt(r + 2)], c = f[e.charCodeAt(r + 3)], u[i++] = a << 2 | o >> 4, u[i++] = (o & 15) << 4 | s >> 2, u[i++] = (s & 3) << 6 | c & 63;
45
+ return l;
46
+ }, re = typeof ArrayBuffer == "function", p = (e, t) => {
47
+ if (typeof e != "string") return {
48
+ type: "message",
49
+ data: m(e, t)
50
+ };
51
+ let n = e.charAt(0);
52
+ return n === "b" ? {
53
+ type: "message",
54
+ data: ie(e.substring(1), t)
55
+ } : r[n] ? e.length > 1 ? {
56
+ type: r[n],
57
+ data: e.substring(1)
58
+ } : { type: r[n] } : i;
59
+ }, ie = (e, t) => re ? m(ne(e), t) : {
60
+ base64: !0,
61
+ data: e
62
+ }, m = (e, t) => {
63
+ switch (t) {
64
+ case "blob": return e instanceof Blob ? e : new Blob([e]);
65
+ default: return e instanceof ArrayBuffer ? e : e.buffer;
66
+ }
67
+ }, h = "", ae = (e, t) => {
68
+ let n = e.length, r = Array(n), i = 0;
69
+ e.forEach((e, a) => {
70
+ c(e, !1, (e) => {
71
+ r[a] = e, ++i === n && t(r.join(h));
72
+ });
73
+ });
74
+ }, oe = (e, t) => {
75
+ let n = e.split(h), r = [];
76
+ for (let e = 0; e < n.length; e++) {
77
+ let i = p(n[e], t);
78
+ if (r.push(i), i.type === "error") break;
79
+ }
80
+ return r;
81
+ };
82
+ function se() {
83
+ return new TransformStream({ transform(e, t) {
84
+ ee(e, (n) => {
85
+ let r = n.length, i;
86
+ if (r < 126) i = new Uint8Array(1), new DataView(i.buffer).setUint8(0, r);
87
+ else if (r < 65536) {
88
+ i = new Uint8Array(3);
89
+ let e = new DataView(i.buffer);
90
+ e.setUint8(0, 126), e.setUint16(1, r);
91
+ } else {
92
+ i = new Uint8Array(9);
93
+ let e = new DataView(i.buffer);
94
+ e.setUint8(0, 127), e.setBigUint64(1, BigInt(r));
95
+ }
96
+ e.data && typeof e.data != "string" && (i[0] |= 128), t.enqueue(i), t.enqueue(n);
97
+ });
98
+ } });
99
+ }
100
+ var g;
101
+ function _(e) {
102
+ return e.reduce((e, t) => e + t.length, 0);
103
+ }
104
+ function v(e, t) {
105
+ if (e[0].length === t) return e.shift();
106
+ let n = new Uint8Array(t), r = 0;
107
+ for (let i = 0; i < t; i++) n[i] = e[0][r++], r === e[0].length && (e.shift(), r = 0);
108
+ return e.length && r < e[0].length && (e[0] = e[0].slice(r)), n;
109
+ }
110
+ function ce(e, t) {
111
+ g ||= new TextDecoder();
112
+ let n = [], r = 0, a = -1, o = !1;
113
+ return new TransformStream({ transform(s, c) {
114
+ for (n.push(s);;) {
115
+ if (r === 0) {
116
+ if (_(n) < 1) break;
117
+ let e = v(n, 1);
118
+ o = (e[0] & 128) == 128, a = e[0] & 127, r = a < 126 ? 3 : a === 126 ? 1 : 2;
119
+ } else if (r === 1) {
120
+ if (_(n) < 2) break;
121
+ let e = v(n, 2);
122
+ a = new DataView(e.buffer, e.byteOffset, e.length).getUint16(0), r = 3;
123
+ } else if (r === 2) {
124
+ if (_(n) < 8) break;
125
+ let e = v(n, 8), t = new DataView(e.buffer, e.byteOffset, e.length), o = t.getUint32(0);
126
+ if (o > 2 ** 21 - 1) {
127
+ c.enqueue(i);
128
+ break;
129
+ }
130
+ a = o * 2 ** 32 + t.getUint32(4), r = 3;
131
+ } else {
132
+ if (_(n) < a) break;
133
+ let e = v(n, a);
134
+ c.enqueue(p(o ? e : g.decode(e), t)), r = 0;
135
+ }
136
+ if (a === 0 || a > e) {
137
+ c.enqueue(i);
138
+ break;
139
+ }
140
+ }
141
+ } });
142
+ }
143
+ //#endregion
144
+ //#region ../../node_modules/@socket.io/component-emitter/lib/esm/index.js
145
+ function y(e) {
146
+ if (e) return le(e);
147
+ }
148
+ function le(e) {
149
+ for (var t in y.prototype) e[t] = y.prototype[t];
150
+ return e;
151
+ }
152
+ y.prototype.on = y.prototype.addEventListener = function(e, t) {
153
+ return this._callbacks = this._callbacks || {}, (this._callbacks["$" + e] = this._callbacks["$" + e] || []).push(t), this;
154
+ }, y.prototype.once = function(e, t) {
155
+ function n() {
156
+ this.off(e, n), t.apply(this, arguments);
157
+ }
158
+ return n.fn = t, this.on(e, n), this;
159
+ }, y.prototype.off = y.prototype.removeListener = y.prototype.removeAllListeners = y.prototype.removeEventListener = function(e, t) {
160
+ if (this._callbacks = this._callbacks || {}, arguments.length == 0) return this._callbacks = {}, this;
161
+ var n = this._callbacks["$" + e];
162
+ if (!n) return this;
163
+ if (arguments.length == 1) return delete this._callbacks["$" + e], this;
164
+ for (var r, i = 0; i < n.length; i++) if (r = n[i], r === t || r.fn === t) {
165
+ n.splice(i, 1);
166
+ break;
167
+ }
168
+ return n.length === 0 && delete this._callbacks["$" + e], this;
169
+ }, y.prototype.emit = function(e) {
170
+ this._callbacks = this._callbacks || {};
171
+ for (var t = Array(arguments.length - 1), n = this._callbacks["$" + e], r = 1; r < arguments.length; r++) t[r - 1] = arguments[r];
172
+ if (n) {
173
+ n = n.slice(0);
174
+ for (var r = 0, i = n.length; r < i; ++r) n[r].apply(this, t);
175
+ }
176
+ return this;
177
+ }, y.prototype.emitReserved = y.prototype.emit, y.prototype.listeners = function(e) {
178
+ return this._callbacks = this._callbacks || {}, this._callbacks["$" + e] || [];
179
+ }, y.prototype.hasListeners = function(e) {
180
+ return !!this.listeners(e).length;
181
+ };
182
+ //#endregion
183
+ //#region ../../node_modules/engine.io-client/build/esm/globals.js
184
+ var b = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0), x = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), ue = "arraybuffer";
185
+ //#endregion
186
+ //#region ../../node_modules/engine.io-client/build/esm/util.js
187
+ function S(e, ...t) {
188
+ return t.reduce((t, n) => (e.hasOwnProperty(n) && (t[n] = e[n]), t), {});
189
+ }
190
+ var de = x.setTimeout, fe = x.clearTimeout;
191
+ function C(e, t) {
192
+ t.useNativeTimers ? (e.setTimeoutFn = de.bind(x), e.clearTimeoutFn = fe.bind(x)) : (e.setTimeoutFn = x.setTimeout.bind(x), e.clearTimeoutFn = x.clearTimeout.bind(x));
193
+ }
194
+ var pe = 1.33;
195
+ function me(e) {
196
+ return typeof e == "string" ? he(e) : Math.ceil((e.byteLength || e.size) * pe);
197
+ }
198
+ function he(e) {
199
+ let t = 0, n = 0;
200
+ for (let r = 0, i = e.length; r < i; r++) t = e.charCodeAt(r), t < 128 ? n += 1 : t < 2048 ? n += 2 : t < 55296 || t >= 57344 ? n += 3 : (r++, n += 4);
201
+ return n;
202
+ }
203
+ function w() {
204
+ return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
205
+ }
206
+ //#endregion
207
+ //#region ../../node_modules/engine.io-client/build/esm/contrib/parseqs.js
208
+ function ge(e) {
209
+ let t = "";
210
+ for (let n in e) e.hasOwnProperty(n) && (t.length && (t += "&"), t += encodeURIComponent(n) + "=" + encodeURIComponent(e[n]));
211
+ return t;
212
+ }
213
+ function _e(e) {
214
+ let t = {}, n = e.split("&");
215
+ for (let e = 0, r = n.length; e < r; e++) {
216
+ let r = n[e].split("=");
217
+ t[decodeURIComponent(r[0])] = decodeURIComponent(r[1]);
218
+ }
219
+ return t;
220
+ }
221
+ //#endregion
222
+ //#region ../../node_modules/engine.io-client/build/esm/transport.js
223
+ var ve = class extends Error {
224
+ constructor(e, t, n) {
225
+ super(e), this.description = t, this.context = n, this.type = "TransportError";
226
+ }
227
+ }, T = class extends y {
228
+ constructor(e) {
229
+ super(), this.writable = !1, C(this, e), this.opts = e, this.query = e.query, this.socket = e.socket, this.supportsBinary = !e.forceBase64;
230
+ }
231
+ onError(e, t, n) {
232
+ return super.emitReserved("error", new ve(e, t, n)), this;
233
+ }
234
+ open() {
235
+ return this.readyState = "opening", this.doOpen(), this;
236
+ }
237
+ close() {
238
+ return (this.readyState === "opening" || this.readyState === "open") && (this.doClose(), this.onClose()), this;
239
+ }
240
+ send(e) {
241
+ this.readyState === "open" && this.write(e);
242
+ }
243
+ onOpen() {
244
+ this.readyState = "open", this.writable = !0, super.emitReserved("open");
245
+ }
246
+ onData(e) {
247
+ let t = p(e, this.socket.binaryType);
248
+ this.onPacket(t);
249
+ }
250
+ onPacket(e) {
251
+ super.emitReserved("packet", e);
252
+ }
253
+ onClose(e) {
254
+ this.readyState = "closed", super.emitReserved("close", e);
255
+ }
256
+ pause(e) {}
257
+ createUri(e, t = {}) {
258
+ return e + "://" + this._hostname() + this._port() + this.opts.path + this._query(t);
259
+ }
260
+ _hostname() {
261
+ let e = this.opts.hostname;
262
+ return e.indexOf(":") === -1 ? e : "[" + e + "]";
263
+ }
264
+ _port() {
265
+ return this.opts.port && (this.opts.secure && Number(this.opts.port) !== 443 || !this.opts.secure && Number(this.opts.port) !== 80) ? ":" + this.opts.port : "";
266
+ }
267
+ _query(e) {
268
+ let t = ge(e);
269
+ return t.length ? "?" + t : "";
270
+ }
271
+ }, ye = class extends T {
272
+ constructor() {
273
+ super(...arguments), this._polling = !1;
274
+ }
275
+ get name() {
276
+ return "polling";
277
+ }
278
+ doOpen() {
279
+ this._poll();
280
+ }
281
+ pause(e) {
282
+ this.readyState = "pausing";
283
+ let t = () => {
284
+ this.readyState = "paused", e();
285
+ };
286
+ if (this._polling || !this.writable) {
287
+ let e = 0;
288
+ this._polling && (e++, this.once("pollComplete", function() {
289
+ --e || t();
290
+ })), this.writable || (e++, this.once("drain", function() {
291
+ --e || t();
292
+ }));
293
+ } else t();
294
+ }
295
+ _poll() {
296
+ this._polling = !0, this.doPoll(), this.emitReserved("poll");
297
+ }
298
+ onData(e) {
299
+ oe(e, this.socket.binaryType).forEach((e) => {
300
+ if (this.readyState === "opening" && e.type === "open" && this.onOpen(), e.type === "close") return this.onClose({ description: "transport closed by the server" }), !1;
301
+ this.onPacket(e);
302
+ }), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
303
+ }
304
+ doClose() {
305
+ let e = () => {
306
+ this.write([{ type: "close" }]);
307
+ };
308
+ this.readyState === "open" ? e() : this.once("open", e);
309
+ }
310
+ write(e) {
311
+ this.writable = !1, ae(e, (e) => {
312
+ this.doWrite(e, () => {
313
+ this.writable = !0, this.emitReserved("drain");
314
+ });
315
+ });
316
+ }
317
+ uri() {
318
+ let e = this.opts.secure ? "https" : "http", t = this.query || {};
319
+ return !1 !== this.opts.timestampRequests && (t[this.opts.timestampParam] = w()), !this.supportsBinary && !t.sid && (t.b64 = 1), this.createUri(e, t);
320
+ }
321
+ }, E = !1;
322
+ try {
323
+ E = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
324
+ } catch {}
325
+ var be = E;
326
+ //#endregion
327
+ //#region ../../node_modules/engine.io-client/build/esm/transports/polling-xhr.js
328
+ function xe() {}
329
+ var Se = class extends ye {
330
+ constructor(e) {
331
+ if (super(e), typeof location < "u") {
332
+ let t = location.protocol === "https:", n = location.port;
333
+ n ||= t ? "443" : "80", this.xd = typeof location < "u" && e.hostname !== location.hostname || n !== e.port;
334
+ }
335
+ }
336
+ doWrite(e, t) {
337
+ let n = this.request({
338
+ method: "POST",
339
+ data: e
340
+ });
341
+ n.on("success", t), n.on("error", (e, t) => {
342
+ this.onError("xhr post error", e, t);
343
+ });
344
+ }
345
+ doPoll() {
346
+ let e = this.request();
347
+ e.on("data", this.onData.bind(this)), e.on("error", (e, t) => {
348
+ this.onError("xhr poll error", e, t);
349
+ }), this.pollXhr = e;
350
+ }
351
+ }, D = class e extends y {
352
+ constructor(e, t, n) {
353
+ super(), this.createRequest = e, C(this, n), this._opts = n, this._method = n.method || "GET", this._uri = t, this._data = n.data === void 0 ? null : n.data, this._create();
354
+ }
355
+ _create() {
356
+ var t;
357
+ let n = S(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
358
+ n.xdomain = !!this._opts.xd;
359
+ let r = this._xhr = this.createRequest(n);
360
+ try {
361
+ r.open(this._method, this._uri, !0);
362
+ try {
363
+ if (this._opts.extraHeaders) {
364
+ r.setDisableHeaderCheck && r.setDisableHeaderCheck(!0);
365
+ for (let e in this._opts.extraHeaders) this._opts.extraHeaders.hasOwnProperty(e) && r.setRequestHeader(e, this._opts.extraHeaders[e]);
366
+ }
367
+ } catch {}
368
+ if (this._method === "POST") try {
369
+ r.setRequestHeader("Content-type", "text/plain;charset=UTF-8");
370
+ } catch {}
371
+ try {
372
+ r.setRequestHeader("Accept", "*/*");
373
+ } catch {}
374
+ (t = this._opts.cookieJar) == null || t.addCookies(r), "withCredentials" in r && (r.withCredentials = this._opts.withCredentials), this._opts.requestTimeout && (r.timeout = this._opts.requestTimeout), r.onreadystatechange = () => {
375
+ var e;
376
+ r.readyState === 3 && ((e = this._opts.cookieJar) == null || e.parseCookies(r.getResponseHeader("set-cookie"))), r.readyState === 4 && (r.status === 200 || r.status === 1223 ? this._onLoad() : this.setTimeoutFn(() => {
377
+ this._onError(typeof r.status == "number" ? r.status : 0);
378
+ }, 0));
379
+ }, r.send(this._data);
380
+ } catch (e) {
381
+ this.setTimeoutFn(() => {
382
+ this._onError(e);
383
+ }, 0);
384
+ return;
385
+ }
386
+ typeof document < "u" && (this._index = e.requestsCount++, e.requests[this._index] = this);
387
+ }
388
+ _onError(e) {
389
+ this.emitReserved("error", e, this._xhr), this._cleanup(!0);
390
+ }
391
+ _cleanup(t) {
392
+ if (!(this._xhr === void 0 || this._xhr === null)) {
393
+ if (this._xhr.onreadystatechange = xe, t) try {
394
+ this._xhr.abort();
395
+ } catch {}
396
+ typeof document < "u" && delete e.requests[this._index], this._xhr = null;
397
+ }
398
+ }
399
+ _onLoad() {
400
+ let e = this._xhr.responseText;
401
+ e !== null && (this.emitReserved("data", e), this.emitReserved("success"), this._cleanup());
402
+ }
403
+ abort() {
404
+ this._cleanup();
405
+ }
406
+ };
407
+ if (D.requestsCount = 0, D.requests = {}, typeof document < "u") {
408
+ if (typeof attachEvent == "function") attachEvent("onunload", O);
409
+ else if (typeof addEventListener == "function") {
410
+ let e = "onpagehide" in x ? "pagehide" : "unload";
411
+ addEventListener(e, O, !1);
412
+ }
413
+ }
414
+ function O() {
415
+ for (let e in D.requests) D.requests.hasOwnProperty(e) && D.requests[e].abort();
416
+ }
417
+ var Ce = (function() {
418
+ let e = k({ xdomain: !1 });
419
+ return e && e.responseType !== null;
420
+ })(), we = class extends Se {
421
+ constructor(e) {
422
+ super(e);
423
+ let t = e && e.forceBase64;
424
+ this.supportsBinary = Ce && !t;
425
+ }
426
+ request(e = {}) {
427
+ return Object.assign(e, { xd: this.xd }, this.opts), new D(k, this.uri(), e);
428
+ }
429
+ };
430
+ function k(e) {
431
+ let t = e.xdomain;
432
+ try {
433
+ if (typeof XMLHttpRequest < "u" && (!t || be)) return new XMLHttpRequest();
434
+ } catch {}
435
+ if (!t) try {
436
+ return new x[["Active", "Object"].join("X")]("Microsoft.XMLHTTP");
437
+ } catch {}
438
+ }
439
+ //#endregion
440
+ //#region ../../node_modules/engine.io-client/build/esm/transports/websocket.js
441
+ var A = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative", Te = class extends T {
442
+ get name() {
443
+ return "websocket";
444
+ }
445
+ doOpen() {
446
+ let e = this.uri(), t = this.opts.protocols, n = A ? {} : S(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
447
+ this.opts.extraHeaders && (n.headers = this.opts.extraHeaders);
448
+ try {
449
+ this.ws = this.createSocket(e, t, n);
450
+ } catch (e) {
451
+ return this.emitReserved("error", e);
452
+ }
453
+ this.ws.binaryType = this.socket.binaryType, this.addEventListeners();
454
+ }
455
+ addEventListeners() {
456
+ this.ws.onopen = () => {
457
+ this.opts.autoUnref && this.ws._socket.unref(), this.onOpen();
458
+ }, this.ws.onclose = (e) => this.onClose({
459
+ description: "websocket connection closed",
460
+ context: e
461
+ }), this.ws.onmessage = (e) => this.onData(e.data), this.ws.onerror = (e) => this.onError("websocket error", e);
462
+ }
463
+ write(e) {
464
+ this.writable = !1;
465
+ for (let t = 0; t < e.length; t++) {
466
+ let n = e[t], r = t === e.length - 1;
467
+ c(n, this.supportsBinary, (e) => {
468
+ try {
469
+ this.doWrite(n, e);
470
+ } catch {}
471
+ r && b(() => {
472
+ this.writable = !0, this.emitReserved("drain");
473
+ }, this.setTimeoutFn);
474
+ });
475
+ }
476
+ }
477
+ doClose() {
478
+ this.ws !== void 0 && (this.ws.onerror = () => {}, this.ws.close(), this.ws = null);
479
+ }
480
+ uri() {
481
+ let e = this.opts.secure ? "wss" : "ws", t = this.query || {};
482
+ return this.opts.timestampRequests && (t[this.opts.timestampParam] = w()), this.supportsBinary || (t.b64 = 1), this.createUri(e, t);
483
+ }
484
+ }, j = x.WebSocket || x.MozWebSocket, Ee = {
485
+ websocket: class extends Te {
486
+ createSocket(e, t, n) {
487
+ return A ? new j(e, t, n) : t ? new j(e, t) : new j(e);
488
+ }
489
+ doWrite(e, t) {
490
+ this.ws.send(t);
491
+ }
492
+ },
493
+ webtransport: class extends T {
494
+ get name() {
495
+ return "webtransport";
496
+ }
497
+ doOpen() {
498
+ try {
499
+ this._transport = new WebTransport(this.createUri("https"), this.opts.transportOptions[this.name]);
500
+ } catch (e) {
501
+ return this.emitReserved("error", e);
502
+ }
503
+ this._transport.closed.then(() => {
504
+ this.onClose();
505
+ }).catch((e) => {
506
+ this.onError("webtransport error", e);
507
+ }), this._transport.ready.then(() => {
508
+ this._transport.createBidirectionalStream().then((e) => {
509
+ let t = ce(2 ** 53 - 1, this.socket.binaryType), n = e.readable.pipeThrough(t).getReader(), r = se();
510
+ r.readable.pipeTo(e.writable), this._writer = r.writable.getWriter();
511
+ let i = () => {
512
+ n.read().then(({ done: e, value: t }) => {
513
+ e || (this.onPacket(t), i());
514
+ }).catch((e) => {});
515
+ };
516
+ i();
517
+ let a = { type: "open" };
518
+ this.query.sid && (a.data = `{"sid":"${this.query.sid}"}`), this._writer.write(a).then(() => this.onOpen());
519
+ });
520
+ });
521
+ }
522
+ write(e) {
523
+ this.writable = !1;
524
+ for (let t = 0; t < e.length; t++) {
525
+ let n = e[t], r = t === e.length - 1;
526
+ this._writer.write(n).then(() => {
527
+ r && b(() => {
528
+ this.writable = !0, this.emitReserved("drain");
529
+ }, this.setTimeoutFn);
530
+ });
531
+ }
532
+ }
533
+ doClose() {
534
+ var e;
535
+ (e = this._transport) == null || e.close();
536
+ }
537
+ },
538
+ polling: we
539
+ }, De = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, Oe = [
540
+ "source",
541
+ "protocol",
542
+ "authority",
543
+ "userInfo",
544
+ "user",
545
+ "password",
546
+ "host",
547
+ "port",
548
+ "relative",
549
+ "path",
550
+ "directory",
551
+ "file",
552
+ "query",
553
+ "anchor"
554
+ ];
555
+ function M(e) {
556
+ if (e.length > 8e3) throw "URI too long";
557
+ let t = e, n = e.indexOf("["), r = e.indexOf("]");
558
+ n != -1 && r != -1 && (e = e.substring(0, n) + e.substring(n, r).replace(/:/g, ";") + e.substring(r, e.length));
559
+ let i = De.exec(e || ""), a = {}, o = 14;
560
+ for (; o--;) a[Oe[o]] = i[o] || "";
561
+ return n != -1 && r != -1 && (a.source = t, a.host = a.host.substring(1, a.host.length - 1).replace(/;/g, ":"), a.authority = a.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), a.ipv6uri = !0), a.pathNames = ke(a, a.path), a.queryKey = Ae(a, a.query), a;
562
+ }
563
+ function ke(e, t) {
564
+ let n = t.replace(/\/{2,9}/g, "/").split("/");
565
+ return (t.slice(0, 1) == "/" || t.length === 0) && n.splice(0, 1), t.slice(-1) == "/" && n.splice(n.length - 1, 1), n;
566
+ }
567
+ function Ae(e, t) {
568
+ let n = {};
569
+ return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(e, t, r) {
570
+ t && (n[t] = r);
571
+ }), n;
572
+ }
573
+ //#endregion
574
+ //#region ../../node_modules/engine.io-client/build/esm/socket.js
575
+ var N = typeof addEventListener == "function" && typeof removeEventListener == "function", P = [];
576
+ N && addEventListener("offline", () => {
577
+ P.forEach((e) => e());
578
+ }, !1);
579
+ var F = class e extends y {
580
+ constructor(e, t) {
581
+ if (super(), this.binaryType = ue, this.writeBuffer = [], this._prevBufferLen = 0, this._pingInterval = -1, this._pingTimeout = -1, this._maxPayload = -1, this._pingTimeoutTime = Infinity, e && typeof e == "object" && (t = e, e = null), e) {
582
+ let n = M(e);
583
+ t.hostname = n.host, t.secure = n.protocol === "https" || n.protocol === "wss", t.port = n.port, n.query && (t.query = n.query);
584
+ } else t.host && (t.hostname = M(t.host).host);
585
+ C(this, t), this.secure = t.secure == null ? typeof location < "u" && location.protocol === "https:" : t.secure, t.hostname && !t.port && (t.port = this.secure ? "443" : "80"), this.hostname = t.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = t.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, t.transports.forEach((e) => {
586
+ let t = e.prototype.name;
587
+ this.transports.push(t), this._transportsByName[t] = e;
588
+ }), this.opts = Object.assign({
589
+ path: "/engine.io",
590
+ agent: !1,
591
+ withCredentials: !1,
592
+ upgrade: !0,
593
+ timestampParam: "t",
594
+ rememberUpgrade: !1,
595
+ addTrailingSlash: !0,
596
+ rejectUnauthorized: !0,
597
+ perMessageDeflate: { threshold: 1024 },
598
+ transportOptions: {},
599
+ closeOnBeforeunload: !1
600
+ }, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = _e(this.opts.query)), N && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
601
+ this.transport && (this.transport.removeAllListeners(), this.transport.close());
602
+ }, addEventListener("beforeunload", this._beforeunloadEventListener, !1)), this.hostname !== "localhost" && (this._offlineEventListener = () => {
603
+ this._onClose("transport close", { description: "network connection lost" });
604
+ }, P.push(this._offlineEventListener))), this.opts.withCredentials && (this._cookieJar = void 0), this._open();
605
+ }
606
+ createTransport(e) {
607
+ let t = Object.assign({}, this.opts.query);
608
+ t.EIO = 4, t.transport = e, this.id && (t.sid = this.id);
609
+ let n = Object.assign({}, this.opts, {
610
+ query: t,
611
+ socket: this,
612
+ hostname: this.hostname,
613
+ secure: this.secure,
614
+ port: this.port
615
+ }, this.opts.transportOptions[e]);
616
+ return new this._transportsByName[e](n);
617
+ }
618
+ _open() {
619
+ if (this.transports.length === 0) {
620
+ this.setTimeoutFn(() => {
621
+ this.emitReserved("error", "No transports available");
622
+ }, 0);
623
+ return;
624
+ }
625
+ let t = this.opts.rememberUpgrade && e.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
626
+ this.readyState = "opening";
627
+ let n = this.createTransport(t);
628
+ n.open(), this.setTransport(n);
629
+ }
630
+ setTransport(e) {
631
+ this.transport && this.transport.removeAllListeners(), this.transport = e, e.on("drain", this._onDrain.bind(this)).on("packet", this._onPacket.bind(this)).on("error", this._onError.bind(this)).on("close", (e) => this._onClose("transport close", e));
632
+ }
633
+ onOpen() {
634
+ this.readyState = "open", e.priorWebsocketSuccess = this.transport.name === "websocket", this.emitReserved("open"), this.flush();
635
+ }
636
+ _onPacket(e) {
637
+ if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing") switch (this.emitReserved("packet", e), this.emitReserved("heartbeat"), e.type) {
638
+ case "open":
639
+ this.onHandshake(JSON.parse(e.data));
640
+ break;
641
+ case "ping":
642
+ this._sendPacket("pong"), this.emitReserved("ping"), this.emitReserved("pong"), this._resetPingTimeout();
643
+ break;
644
+ case "error":
645
+ let t = /* @__PURE__ */ Error("server error");
646
+ t.code = e.data, this._onError(t);
647
+ break;
648
+ case "message":
649
+ this.emitReserved("data", e.data), this.emitReserved("message", e.data);
650
+ break;
651
+ }
652
+ }
653
+ onHandshake(e) {
654
+ this.emitReserved("handshake", e), this.id = e.sid, this.transport.query.sid = e.sid, this._pingInterval = e.pingInterval, this._pingTimeout = e.pingTimeout, this._maxPayload = e.maxPayload, this.onOpen(), this.readyState !== "closed" && this._resetPingTimeout();
655
+ }
656
+ _resetPingTimeout() {
657
+ this.clearTimeoutFn(this._pingTimeoutTimer);
658
+ let e = this._pingInterval + this._pingTimeout;
659
+ this._pingTimeoutTime = Date.now() + e, this._pingTimeoutTimer = this.setTimeoutFn(() => {
660
+ this._onClose("ping timeout");
661
+ }, e), this.opts.autoUnref && this._pingTimeoutTimer.unref();
662
+ }
663
+ _onDrain() {
664
+ this.writeBuffer.splice(0, this._prevBufferLen), this._prevBufferLen = 0, this.writeBuffer.length === 0 ? this.emitReserved("drain") : this.flush();
665
+ }
666
+ flush() {
667
+ if (this.readyState !== "closed" && this.transport.writable && !this.upgrading && this.writeBuffer.length) {
668
+ let e = this._getWritablePackets();
669
+ this.transport.send(e), this._prevBufferLen = e.length, this.emitReserved("flush");
670
+ }
671
+ }
672
+ _getWritablePackets() {
673
+ if (!(this._maxPayload && this.transport.name === "polling" && this.writeBuffer.length > 1)) return this.writeBuffer;
674
+ let e = 1;
675
+ for (let t = 0; t < this.writeBuffer.length; t++) {
676
+ let n = this.writeBuffer[t].data;
677
+ if (n && (e += me(n)), t > 0 && e > this._maxPayload) return this.writeBuffer.slice(0, t);
678
+ e += 2;
679
+ }
680
+ return this.writeBuffer;
681
+ }
682
+ _hasPingExpired() {
683
+ if (!this._pingTimeoutTime) return !0;
684
+ let e = Date.now() > this._pingTimeoutTime;
685
+ return e && (this._pingTimeoutTime = 0, b(() => {
686
+ this._onClose("ping timeout");
687
+ }, this.setTimeoutFn)), e;
688
+ }
689
+ write(e, t, n) {
690
+ return this._sendPacket("message", e, t, n), this;
691
+ }
692
+ send(e, t, n) {
693
+ return this._sendPacket("message", e, t, n), this;
694
+ }
695
+ _sendPacket(e, t, n, r) {
696
+ if (typeof t == "function" && (r = t, t = void 0), typeof n == "function" && (r = n, n = null), this.readyState === "closing" || this.readyState === "closed") return;
697
+ n ||= {}, n.compress = !1 !== n.compress;
698
+ let i = {
699
+ type: e,
700
+ data: t,
701
+ options: n
702
+ };
703
+ this.emitReserved("packetCreate", i), this.writeBuffer.push(i), r && this.once("flush", r), this.flush();
704
+ }
705
+ close() {
706
+ let e = () => {
707
+ this._onClose("forced close"), this.transport.close();
708
+ }, t = () => {
709
+ this.off("upgrade", t), this.off("upgradeError", t), e();
710
+ }, n = () => {
711
+ this.once("upgrade", t), this.once("upgradeError", t);
712
+ };
713
+ return (this.readyState === "opening" || this.readyState === "open") && (this.readyState = "closing", this.writeBuffer.length ? this.once("drain", () => {
714
+ this.upgrading ? n() : e();
715
+ }) : this.upgrading ? n() : e()), this;
716
+ }
717
+ _onError(t) {
718
+ if (e.priorWebsocketSuccess = !1, this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening") return this.transports.shift(), this._open();
719
+ this.emitReserved("error", t), this._onClose("transport error", t);
720
+ }
721
+ _onClose(e, t) {
722
+ if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing") {
723
+ if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), N && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
724
+ let e = P.indexOf(this._offlineEventListener);
725
+ e !== -1 && P.splice(e, 1);
726
+ }
727
+ this.readyState = "closed", this.id = null, this.emitReserved("close", e, t), this.writeBuffer = [], this._prevBufferLen = 0;
728
+ }
729
+ }
730
+ };
731
+ F.protocol = 4;
732
+ var je = class extends F {
733
+ constructor() {
734
+ super(...arguments), this._upgrades = [];
735
+ }
736
+ onOpen() {
737
+ if (super.onOpen(), this.readyState === "open" && this.opts.upgrade) for (let e = 0; e < this._upgrades.length; e++) this._probe(this._upgrades[e]);
738
+ }
739
+ _probe(e) {
740
+ let t = this.createTransport(e), n = !1;
741
+ F.priorWebsocketSuccess = !1;
742
+ let r = () => {
743
+ n || (t.send([{
744
+ type: "ping",
745
+ data: "probe"
746
+ }]), t.once("packet", (e) => {
747
+ if (!n) if (e.type === "pong" && e.data === "probe") {
748
+ if (this.upgrading = !0, this.emitReserved("upgrading", t), !t) return;
749
+ F.priorWebsocketSuccess = t.name === "websocket", this.transport.pause(() => {
750
+ n || this.readyState !== "closed" && (l(), this.setTransport(t), t.send([{ type: "upgrade" }]), this.emitReserved("upgrade", t), t = null, this.upgrading = !1, this.flush());
751
+ });
752
+ } else {
753
+ let e = /* @__PURE__ */ Error("probe error");
754
+ e.transport = t.name, this.emitReserved("upgradeError", e);
755
+ }
756
+ }));
757
+ };
758
+ function i() {
759
+ n || (n = !0, l(), t.close(), t = null);
760
+ }
761
+ let a = (e) => {
762
+ let n = /* @__PURE__ */ Error("probe error: " + e);
763
+ n.transport = t.name, i(), this.emitReserved("upgradeError", n);
764
+ };
765
+ function o() {
766
+ a("transport closed");
767
+ }
768
+ function s() {
769
+ a("socket closed");
770
+ }
771
+ function c(e) {
772
+ t && e.name !== t.name && i();
773
+ }
774
+ let l = () => {
775
+ t.removeListener("open", r), t.removeListener("error", a), t.removeListener("close", o), this.off("close", s), this.off("upgrading", c);
776
+ };
777
+ t.once("open", r), t.once("error", a), t.once("close", o), this.once("close", s), this.once("upgrading", c), this._upgrades.indexOf("webtransport") !== -1 && e !== "webtransport" ? this.setTimeoutFn(() => {
778
+ n || t.open();
779
+ }, 200) : t.open();
780
+ }
781
+ onHandshake(e) {
782
+ this._upgrades = this._filterUpgrades(e.upgrades), super.onHandshake(e);
783
+ }
784
+ _filterUpgrades(e) {
785
+ let t = [];
786
+ for (let n = 0; n < e.length; n++) ~this.transports.indexOf(e[n]) && t.push(e[n]);
787
+ return t;
788
+ }
789
+ }, I = class extends je {
790
+ constructor(e, t = {}) {
791
+ let n = typeof e == "object", r = n ? { ...e } : { ...t };
792
+ (!r.transports || r.transports && typeof r.transports[0] == "string") && (r.transports = (r.transports || [
793
+ "polling",
794
+ "websocket",
795
+ "webtransport"
796
+ ]).map((e) => Ee[e]).filter((e) => !!e)), super(n ? r : e, r);
797
+ }
798
+ };
799
+ I.protocol;
800
+ //#endregion
801
+ //#region ../../node_modules/socket.io-client/build/esm/url.js
802
+ function Me(e, t = "", n) {
803
+ let r = e;
804
+ n ||= typeof location < "u" && location, e ??= n.protocol + "//" + n.host, typeof e == "string" && (e.charAt(0) === "/" && (e = e.charAt(1) === "/" ? n.protocol + e : n.host + e), /^(https?|wss?):\/\//.test(e) || (e = n === void 0 ? "https://" + e : n.protocol + "//" + e), r = M(e)), r.port || (/^(http|ws)$/.test(r.protocol) ? r.port = "80" : /^(http|ws)s$/.test(r.protocol) && (r.port = "443")), r.path = r.path || "/";
805
+ let i = r.host.indexOf(":") === -1 ? r.host : "[" + r.host + "]";
806
+ return r.id = r.protocol + "://" + i + ":" + r.port + t, r.href = r.protocol + "://" + i + (n && n.port === r.port ? "" : ":" + r.port), r;
807
+ }
808
+ //#endregion
809
+ //#region ../../node_modules/socket.io-parser/build/esm/is-binary.js
810
+ var Ne = typeof ArrayBuffer == "function", Pe = (e) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(e) : e.buffer instanceof ArrayBuffer, L = Object.prototype.toString, Fe = typeof Blob == "function" || typeof Blob < "u" && L.call(Blob) === "[object BlobConstructor]", Ie = typeof File == "function" || typeof File < "u" && L.call(File) === "[object FileConstructor]";
811
+ function R(e) {
812
+ return Ne && (e instanceof ArrayBuffer || Pe(e)) || Fe && e instanceof Blob || Ie && e instanceof File;
813
+ }
814
+ function z(e, t) {
815
+ if (!e || typeof e != "object") return !1;
816
+ if (Array.isArray(e)) {
817
+ for (let t = 0, n = e.length; t < n; t++) if (z(e[t])) return !0;
818
+ return !1;
819
+ }
820
+ if (R(e)) return !0;
821
+ if (e.toJSON && typeof e.toJSON == "function" && arguments.length === 1) return z(e.toJSON(), !0);
822
+ for (let t in e) if (Object.prototype.hasOwnProperty.call(e, t) && z(e[t])) return !0;
823
+ return !1;
824
+ }
825
+ //#endregion
826
+ //#region ../../node_modules/socket.io-parser/build/esm/binary.js
827
+ function Le(e) {
828
+ let t = [], n = e.data, r = e;
829
+ return r.data = B(n, t), r.attachments = t.length, {
830
+ packet: r,
831
+ buffers: t
832
+ };
833
+ }
834
+ function B(e, t) {
835
+ if (!e) return e;
836
+ if (R(e)) {
837
+ let n = {
838
+ _placeholder: !0,
839
+ num: t.length
840
+ };
841
+ return t.push(e), n;
842
+ } else if (Array.isArray(e)) {
843
+ let n = Array(e.length);
844
+ for (let r = 0; r < e.length; r++) n[r] = B(e[r], t);
845
+ return n;
846
+ } else if (typeof e == "object" && !(e instanceof Date)) {
847
+ let n = {};
848
+ for (let r in e) Object.prototype.hasOwnProperty.call(e, r) && (n[r] = B(e[r], t));
849
+ return n;
850
+ }
851
+ return e;
852
+ }
853
+ function Re(e, t) {
854
+ return e.data = V(e.data, t), delete e.attachments, e;
855
+ }
856
+ function V(e, t) {
857
+ if (!e) return e;
858
+ if (e && e._placeholder === !0) {
859
+ if (typeof e.num == "number" && e.num >= 0 && e.num < t.length) return t[e.num];
860
+ throw Error("illegal attachments");
861
+ } else if (Array.isArray(e)) for (let n = 0; n < e.length; n++) e[n] = V(e[n], t);
862
+ else if (typeof e == "object") for (let n in e) Object.prototype.hasOwnProperty.call(e, n) && (e[n] = V(e[n], t));
863
+ return e;
864
+ }
865
+ //#endregion
866
+ //#region ../../node_modules/socket.io-parser/build/esm/index.js
867
+ var ze = /* @__PURE__ */ t({
868
+ Decoder: () => Ve,
869
+ Encoder: () => Be,
870
+ PacketType: () => U,
871
+ isPacketValid: () => Ke,
872
+ protocol: () => 5
873
+ }), H = [
874
+ "connect",
875
+ "connect_error",
876
+ "disconnect",
877
+ "disconnecting",
878
+ "newListener",
879
+ "removeListener"
880
+ ], U;
881
+ (function(e) {
882
+ e[e.CONNECT = 0] = "CONNECT", e[e.DISCONNECT = 1] = "DISCONNECT", e[e.EVENT = 2] = "EVENT", e[e.ACK = 3] = "ACK", e[e.CONNECT_ERROR = 4] = "CONNECT_ERROR", e[e.BINARY_EVENT = 5] = "BINARY_EVENT", e[e.BINARY_ACK = 6] = "BINARY_ACK";
883
+ })(U ||= {});
884
+ var Be = class {
885
+ constructor(e) {
886
+ this.replacer = e;
887
+ }
888
+ encode(e) {
889
+ return (e.type === U.EVENT || e.type === U.ACK) && z(e) ? this.encodeAsBinary({
890
+ type: e.type === U.EVENT ? U.BINARY_EVENT : U.BINARY_ACK,
891
+ nsp: e.nsp,
892
+ data: e.data,
893
+ id: e.id
894
+ }) : [this.encodeAsString(e)];
895
+ }
896
+ encodeAsString(e) {
897
+ let t = "" + e.type;
898
+ return (e.type === U.BINARY_EVENT || e.type === U.BINARY_ACK) && (t += e.attachments + "-"), e.nsp && e.nsp !== "/" && (t += e.nsp + ","), e.id != null && (t += e.id), e.data != null && (t += JSON.stringify(e.data, this.replacer)), t;
899
+ }
900
+ encodeAsBinary(e) {
901
+ let t = Le(e), n = this.encodeAsString(t.packet), r = t.buffers;
902
+ return r.unshift(n), r;
903
+ }
904
+ }, Ve = class e extends y {
905
+ constructor(e) {
906
+ super(), this.opts = Object.assign({
907
+ reviver: void 0,
908
+ maxAttachments: 10
909
+ }, typeof e == "function" ? { reviver: e } : e);
910
+ }
911
+ add(e) {
912
+ let t;
913
+ if (typeof e == "string") {
914
+ if (this.reconstructor) throw Error("got plaintext data when reconstructing a packet");
915
+ t = this.decodeString(e);
916
+ let n = t.type === U.BINARY_EVENT;
917
+ n || t.type === U.BINARY_ACK ? (t.type = n ? U.EVENT : U.ACK, this.reconstructor = new He(t), t.attachments === 0 && super.emitReserved("decoded", t)) : super.emitReserved("decoded", t);
918
+ } else if (R(e) || e.base64) if (this.reconstructor) t = this.reconstructor.takeBinaryData(e), t && (this.reconstructor = null, super.emitReserved("decoded", t));
919
+ else throw Error("got binary data when not reconstructing a packet");
920
+ else throw Error("Unknown type: " + e);
921
+ }
922
+ decodeString(t) {
923
+ let n = 0, r = { type: Number(t.charAt(0)) };
924
+ if (U[r.type] === void 0) throw Error("unknown packet type " + r.type);
925
+ if (r.type === U.BINARY_EVENT || r.type === U.BINARY_ACK) {
926
+ let e = n + 1;
927
+ for (; t.charAt(++n) !== "-" && n != t.length;);
928
+ let i = t.substring(e, n);
929
+ if (i != Number(i) || t.charAt(n) !== "-") throw Error("Illegal attachments");
930
+ let a = Number(i);
931
+ if (!W(a) || a < 0) throw Error("Illegal attachments");
932
+ if (a > this.opts.maxAttachments) throw Error("too many attachments");
933
+ r.attachments = a;
934
+ }
935
+ if (t.charAt(n + 1) === "/") {
936
+ let e = n + 1;
937
+ for (; ++n && !(t.charAt(n) === "," || n === t.length););
938
+ r.nsp = t.substring(e, n);
939
+ } else r.nsp = "/";
940
+ let i = t.charAt(n + 1);
941
+ if (i !== "" && Number(i) == i) {
942
+ let e = n + 1;
943
+ for (; ++n;) {
944
+ let e = t.charAt(n);
945
+ if (e == null || Number(e) != e) {
946
+ --n;
947
+ break;
948
+ }
949
+ if (n === t.length) break;
950
+ }
951
+ r.id = Number(t.substring(e, n + 1));
952
+ }
953
+ if (t.charAt(++n)) {
954
+ let i = this.tryParse(t.substr(n));
955
+ if (e.isPayloadValid(r.type, i)) r.data = i;
956
+ else throw Error("invalid payload");
957
+ }
958
+ return r;
959
+ }
960
+ tryParse(e) {
961
+ try {
962
+ return JSON.parse(e, this.opts.reviver);
963
+ } catch {
964
+ return !1;
965
+ }
966
+ }
967
+ static isPayloadValid(e, t) {
968
+ switch (e) {
969
+ case U.CONNECT: return G(t);
970
+ case U.DISCONNECT: return t === void 0;
971
+ case U.CONNECT_ERROR: return typeof t == "string" || G(t);
972
+ case U.EVENT:
973
+ case U.BINARY_EVENT: return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && H.indexOf(t[0]) === -1);
974
+ case U.ACK:
975
+ case U.BINARY_ACK: return Array.isArray(t);
976
+ }
977
+ }
978
+ destroy() {
979
+ this.reconstructor &&= (this.reconstructor.finishedReconstruction(), null);
980
+ }
981
+ }, He = class {
982
+ constructor(e) {
983
+ this.packet = e, this.buffers = [], this.reconPack = e;
984
+ }
985
+ takeBinaryData(e) {
986
+ if (this.buffers.push(e), this.buffers.length === this.reconPack.attachments) {
987
+ let e = Re(this.reconPack, this.buffers);
988
+ return this.finishedReconstruction(), e;
989
+ }
990
+ return null;
991
+ }
992
+ finishedReconstruction() {
993
+ this.reconPack = null, this.buffers = [];
994
+ }
995
+ };
996
+ function Ue(e) {
997
+ return typeof e == "string";
998
+ }
999
+ var W = Number.isInteger || function(e) {
1000
+ return typeof e == "number" && isFinite(e) && Math.floor(e) === e;
1001
+ };
1002
+ function We(e) {
1003
+ return e === void 0 || W(e);
1004
+ }
1005
+ function G(e) {
1006
+ return Object.prototype.toString.call(e) === "[object Object]";
1007
+ }
1008
+ function Ge(e, t) {
1009
+ switch (e) {
1010
+ case U.CONNECT: return t === void 0 || G(t);
1011
+ case U.DISCONNECT: return t === void 0;
1012
+ case U.EVENT: return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && H.indexOf(t[0]) === -1);
1013
+ case U.ACK: return Array.isArray(t);
1014
+ case U.CONNECT_ERROR: return typeof t == "string" || G(t);
1015
+ default: return !1;
1016
+ }
1017
+ }
1018
+ function Ke(e) {
1019
+ return Ue(e.nsp) && We(e.id) && Ge(e.type, e.data);
1020
+ }
1021
+ //#endregion
1022
+ //#region ../../node_modules/socket.io-client/build/esm/on.js
1023
+ function K(e, t, n) {
1024
+ return e.on(t, n), function() {
1025
+ e.off(t, n);
1026
+ };
1027
+ }
1028
+ //#endregion
1029
+ //#region ../../node_modules/socket.io-client/build/esm/socket.js
1030
+ var qe = Object.freeze({
1031
+ connect: 1,
1032
+ connect_error: 1,
1033
+ disconnect: 1,
1034
+ disconnecting: 1,
1035
+ newListener: 1,
1036
+ removeListener: 1
1037
+ }), q = class extends y {
1038
+ constructor(e, t, n) {
1039
+ super(), this.connected = !1, this.recovered = !1, this.receiveBuffer = [], this.sendBuffer = [], this._queue = [], this._queueSeq = 0, this.ids = 0, this.acks = {}, this.flags = {}, this.io = e, this.nsp = t, n && n.auth && (this.auth = n.auth), this._opts = Object.assign({}, n), this.io._autoConnect && this.open();
1040
+ }
1041
+ get disconnected() {
1042
+ return !this.connected;
1043
+ }
1044
+ subEvents() {
1045
+ if (this.subs) return;
1046
+ let e = this.io;
1047
+ this.subs = [
1048
+ K(e, "open", this.onopen.bind(this)),
1049
+ K(e, "packet", this.onpacket.bind(this)),
1050
+ K(e, "error", this.onerror.bind(this)),
1051
+ K(e, "close", this.onclose.bind(this))
1052
+ ];
1053
+ }
1054
+ get active() {
1055
+ return !!this.subs;
1056
+ }
1057
+ connect() {
1058
+ return this.connected ? this : (this.subEvents(), this.io._reconnecting || this.io.open(), this.io._readyState === "open" && this.onopen(), this);
1059
+ }
1060
+ open() {
1061
+ return this.connect();
1062
+ }
1063
+ send(...e) {
1064
+ return e.unshift("message"), this.emit.apply(this, e), this;
1065
+ }
1066
+ emit(e, ...t) {
1067
+ if (qe.hasOwnProperty(e)) throw Error("\"" + e.toString() + "\" is a reserved event name");
1068
+ if (t.unshift(e), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile) return this._addToQueue(t), this;
1069
+ let n = {
1070
+ type: U.EVENT,
1071
+ data: t
1072
+ };
1073
+ if (n.options = {}, n.options.compress = this.flags.compress !== !1, typeof t[t.length - 1] == "function") {
1074
+ let e = this.ids++, r = t.pop();
1075
+ this._registerAckCallback(e, r), n.id = e;
1076
+ }
1077
+ let r = this.io.engine?.transport?.writable, i = this.connected && !this.io.engine?._hasPingExpired();
1078
+ return this.flags.volatile && !r || (i ? (this.notifyOutgoingListeners(n), this.packet(n)) : this.sendBuffer.push(n)), this.flags = {}, this;
1079
+ }
1080
+ _registerAckCallback(e, t) {
1081
+ let n = this.flags.timeout ?? this._opts.ackTimeout;
1082
+ if (n === void 0) {
1083
+ this.acks[e] = t;
1084
+ return;
1085
+ }
1086
+ let r = this.io.setTimeoutFn(() => {
1087
+ delete this.acks[e];
1088
+ for (let t = 0; t < this.sendBuffer.length; t++) this.sendBuffer[t].id === e && this.sendBuffer.splice(t, 1);
1089
+ t.call(this, /* @__PURE__ */ Error("operation has timed out"));
1090
+ }, n), i = (...e) => {
1091
+ this.io.clearTimeoutFn(r), t.apply(this, e);
1092
+ };
1093
+ i.withError = !0, this.acks[e] = i;
1094
+ }
1095
+ emitWithAck(e, ...t) {
1096
+ return new Promise((n, r) => {
1097
+ let i = (e, t) => e ? r(e) : n(t);
1098
+ i.withError = !0, t.push(i), this.emit(e, ...t);
1099
+ });
1100
+ }
1101
+ _addToQueue(e) {
1102
+ let t;
1103
+ typeof e[e.length - 1] == "function" && (t = e.pop());
1104
+ let n = {
1105
+ id: this._queueSeq++,
1106
+ tryCount: 0,
1107
+ pending: !1,
1108
+ args: e,
1109
+ flags: Object.assign({ fromQueue: !0 }, this.flags)
1110
+ };
1111
+ e.push((e, ...r) => (this._queue[0], e === null ? (this._queue.shift(), t && t(null, ...r)) : n.tryCount > this._opts.retries && (this._queue.shift(), t && t(e)), n.pending = !1, this._drainQueue())), this._queue.push(n), this._drainQueue();
1112
+ }
1113
+ _drainQueue(e = !1) {
1114
+ if (!this.connected || this._queue.length === 0) return;
1115
+ let t = this._queue[0];
1116
+ t.pending && !e || (t.pending = !0, t.tryCount++, this.flags = t.flags, this.emit.apply(this, t.args));
1117
+ }
1118
+ packet(e) {
1119
+ e.nsp = this.nsp, this.io._packet(e);
1120
+ }
1121
+ onopen() {
1122
+ typeof this.auth == "function" ? this.auth((e) => {
1123
+ this._sendConnectPacket(e);
1124
+ }) : this._sendConnectPacket(this.auth);
1125
+ }
1126
+ _sendConnectPacket(e) {
1127
+ this.packet({
1128
+ type: U.CONNECT,
1129
+ data: this._pid ? Object.assign({
1130
+ pid: this._pid,
1131
+ offset: this._lastOffset
1132
+ }, e) : e
1133
+ });
1134
+ }
1135
+ onerror(e) {
1136
+ this.connected || this.emitReserved("connect_error", e);
1137
+ }
1138
+ onclose(e, t) {
1139
+ this.connected = !1, delete this.id, this.emitReserved("disconnect", e, t), this._clearAcks();
1140
+ }
1141
+ _clearAcks() {
1142
+ Object.keys(this.acks).forEach((e) => {
1143
+ if (!this.sendBuffer.some((t) => String(t.id) === e)) {
1144
+ let t = this.acks[e];
1145
+ delete this.acks[e], t.withError && t.call(this, /* @__PURE__ */ Error("socket has been disconnected"));
1146
+ }
1147
+ });
1148
+ }
1149
+ onpacket(e) {
1150
+ if (e.nsp === this.nsp) switch (e.type) {
1151
+ case U.CONNECT:
1152
+ e.data && e.data.sid ? this.onconnect(e.data.sid, e.data.pid) : this.emitReserved("connect_error", /* @__PURE__ */ 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/)"));
1153
+ break;
1154
+ case U.EVENT:
1155
+ case U.BINARY_EVENT:
1156
+ this.onevent(e);
1157
+ break;
1158
+ case U.ACK:
1159
+ case U.BINARY_ACK:
1160
+ this.onack(e);
1161
+ break;
1162
+ case U.DISCONNECT:
1163
+ this.ondisconnect();
1164
+ break;
1165
+ case U.CONNECT_ERROR:
1166
+ this.destroy();
1167
+ let t = Error(e.data.message);
1168
+ t.data = e.data.data, this.emitReserved("connect_error", t);
1169
+ break;
1170
+ }
1171
+ }
1172
+ onevent(e) {
1173
+ let t = e.data || [];
1174
+ e.id != null && t.push(this.ack(e.id)), this.connected ? this.emitEvent(t) : this.receiveBuffer.push(Object.freeze(t));
1175
+ }
1176
+ emitEvent(e) {
1177
+ if (this._anyListeners && this._anyListeners.length) {
1178
+ let t = this._anyListeners.slice();
1179
+ for (let n of t) n.apply(this, e);
1180
+ }
1181
+ super.emit.apply(this, e), this._pid && e.length && typeof e[e.length - 1] == "string" && (this._lastOffset = e[e.length - 1]);
1182
+ }
1183
+ ack(e) {
1184
+ let t = this, n = !1;
1185
+ return function(...r) {
1186
+ n || (n = !0, t.packet({
1187
+ type: U.ACK,
1188
+ id: e,
1189
+ data: r
1190
+ }));
1191
+ };
1192
+ }
1193
+ onack(e) {
1194
+ let t = this.acks[e.id];
1195
+ typeof t == "function" && (delete this.acks[e.id], t.withError && e.data.unshift(null), t.apply(this, e.data));
1196
+ }
1197
+ onconnect(e, t) {
1198
+ this.id = e, this.recovered = t && this._pid === t, this._pid = t, this.connected = !0, this.emitBuffered(), this._drainQueue(!0), this.emitReserved("connect");
1199
+ }
1200
+ emitBuffered() {
1201
+ this.receiveBuffer.forEach((e) => this.emitEvent(e)), this.receiveBuffer = [], this.sendBuffer.forEach((e) => {
1202
+ this.notifyOutgoingListeners(e), this.packet(e);
1203
+ }), this.sendBuffer = [];
1204
+ }
1205
+ ondisconnect() {
1206
+ this.destroy(), this.onclose("io server disconnect");
1207
+ }
1208
+ destroy() {
1209
+ this.subs &&= (this.subs.forEach((e) => e()), void 0), this.io._destroy(this);
1210
+ }
1211
+ disconnect() {
1212
+ return this.connected && this.packet({ type: U.DISCONNECT }), this.destroy(), this.connected && this.onclose("io client disconnect"), this;
1213
+ }
1214
+ close() {
1215
+ return this.disconnect();
1216
+ }
1217
+ compress(e) {
1218
+ return this.flags.compress = e, this;
1219
+ }
1220
+ get volatile() {
1221
+ return this.flags.volatile = !0, this;
1222
+ }
1223
+ timeout(e) {
1224
+ return this.flags.timeout = e, this;
1225
+ }
1226
+ onAny(e) {
1227
+ return this._anyListeners = this._anyListeners || [], this._anyListeners.push(e), this;
1228
+ }
1229
+ prependAny(e) {
1230
+ return this._anyListeners = this._anyListeners || [], this._anyListeners.unshift(e), this;
1231
+ }
1232
+ offAny(e) {
1233
+ if (!this._anyListeners) return this;
1234
+ if (e) {
1235
+ let t = this._anyListeners;
1236
+ for (let n = 0; n < t.length; n++) if (e === t[n]) return t.splice(n, 1), this;
1237
+ } else this._anyListeners = [];
1238
+ return this;
1239
+ }
1240
+ listenersAny() {
1241
+ return this._anyListeners || [];
1242
+ }
1243
+ onAnyOutgoing(e) {
1244
+ return this._anyOutgoingListeners = this._anyOutgoingListeners || [], this._anyOutgoingListeners.push(e), this;
1245
+ }
1246
+ prependAnyOutgoing(e) {
1247
+ return this._anyOutgoingListeners = this._anyOutgoingListeners || [], this._anyOutgoingListeners.unshift(e), this;
1248
+ }
1249
+ offAnyOutgoing(e) {
1250
+ if (!this._anyOutgoingListeners) return this;
1251
+ if (e) {
1252
+ let t = this._anyOutgoingListeners;
1253
+ for (let n = 0; n < t.length; n++) if (e === t[n]) return t.splice(n, 1), this;
1254
+ } else this._anyOutgoingListeners = [];
1255
+ return this;
1256
+ }
1257
+ listenersAnyOutgoing() {
1258
+ return this._anyOutgoingListeners || [];
1259
+ }
1260
+ notifyOutgoingListeners(e) {
1261
+ if (this._anyOutgoingListeners && this._anyOutgoingListeners.length) {
1262
+ let t = this._anyOutgoingListeners.slice();
1263
+ for (let n of t) n.apply(this, e.data);
1264
+ }
1265
+ }
1266
+ };
1267
+ //#endregion
1268
+ //#region ../../node_modules/socket.io-client/build/esm/contrib/backo2.js
1269
+ function J(e) {
1270
+ e ||= {}, this.ms = e.min || 100, this.max = e.max || 1e4, this.factor = e.factor || 2, this.jitter = e.jitter > 0 && e.jitter <= 1 ? e.jitter : 0, this.attempts = 0;
1271
+ }
1272
+ J.prototype.duration = function() {
1273
+ var e = this.ms * this.factor ** + this.attempts++;
1274
+ if (this.jitter) {
1275
+ var t = Math.random(), n = Math.floor(t * this.jitter * e);
1276
+ e = Math.floor(t * 10) & 1 ? e + n : e - n;
1277
+ }
1278
+ return Math.min(e, this.max) | 0;
1279
+ }, J.prototype.reset = function() {
1280
+ this.attempts = 0;
1281
+ }, J.prototype.setMin = function(e) {
1282
+ this.ms = e;
1283
+ }, J.prototype.setMax = function(e) {
1284
+ this.max = e;
1285
+ }, J.prototype.setJitter = function(e) {
1286
+ this.jitter = e;
1287
+ };
1288
+ //#endregion
1289
+ //#region ../../node_modules/socket.io-client/build/esm/manager.js
1290
+ var Y = class extends y {
1291
+ constructor(e, t) {
1292
+ super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (t = e, e = void 0), t ||= {}, t.path = t.path || "/socket.io", this.opts = t, C(this, t), this.reconnection(t.reconnection !== !1), this.reconnectionAttempts(t.reconnectionAttempts || Infinity), this.reconnectionDelay(t.reconnectionDelay || 1e3), this.reconnectionDelayMax(t.reconnectionDelayMax || 5e3), this.randomizationFactor(t.randomizationFactor ?? .5), this.backoff = new J({
1293
+ min: this.reconnectionDelay(),
1294
+ max: this.reconnectionDelayMax(),
1295
+ jitter: this.randomizationFactor()
1296
+ }), this.timeout(t.timeout == null ? 2e4 : t.timeout), this._readyState = "closed", this.uri = e;
1297
+ let n = t.parser || ze;
1298
+ this.encoder = new n.Encoder(), this.decoder = new n.Decoder(), this._autoConnect = t.autoConnect !== !1, this._autoConnect && this.open();
1299
+ }
1300
+ reconnection(e) {
1301
+ return arguments.length ? (this._reconnection = !!e, e || (this.skipReconnect = !0), this) : this._reconnection;
1302
+ }
1303
+ reconnectionAttempts(e) {
1304
+ return e === void 0 ? this._reconnectionAttempts : (this._reconnectionAttempts = e, this);
1305
+ }
1306
+ reconnectionDelay(e) {
1307
+ var t;
1308
+ return e === void 0 ? this._reconnectionDelay : (this._reconnectionDelay = e, (t = this.backoff) == null || t.setMin(e), this);
1309
+ }
1310
+ randomizationFactor(e) {
1311
+ var t;
1312
+ return e === void 0 ? this._randomizationFactor : (this._randomizationFactor = e, (t = this.backoff) == null || t.setJitter(e), this);
1313
+ }
1314
+ reconnectionDelayMax(e) {
1315
+ var t;
1316
+ return e === void 0 ? this._reconnectionDelayMax : (this._reconnectionDelayMax = e, (t = this.backoff) == null || t.setMax(e), this);
1317
+ }
1318
+ timeout(e) {
1319
+ return arguments.length ? (this._timeout = e, this) : this._timeout;
1320
+ }
1321
+ maybeReconnectOnOpen() {
1322
+ !this._reconnecting && this._reconnection && this.backoff.attempts === 0 && this.reconnect();
1323
+ }
1324
+ open(e) {
1325
+ if (~this._readyState.indexOf("open")) return this;
1326
+ this.engine = new I(this.uri, this.opts);
1327
+ let t = this.engine, n = this;
1328
+ this._readyState = "opening", this.skipReconnect = !1;
1329
+ let r = K(t, "open", function() {
1330
+ n.onopen(), e && e();
1331
+ }), i = (t) => {
1332
+ this.cleanup(), this._readyState = "closed", this.emitReserved("error", t), e ? e(t) : this.maybeReconnectOnOpen();
1333
+ }, a = K(t, "error", i);
1334
+ if (!1 !== this._timeout) {
1335
+ let e = this._timeout, n = this.setTimeoutFn(() => {
1336
+ r(), i(/* @__PURE__ */ Error("timeout")), t.close();
1337
+ }, e);
1338
+ this.opts.autoUnref && n.unref(), this.subs.push(() => {
1339
+ this.clearTimeoutFn(n);
1340
+ });
1341
+ }
1342
+ return this.subs.push(r), this.subs.push(a), this;
1343
+ }
1344
+ connect(e) {
1345
+ return this.open(e);
1346
+ }
1347
+ onopen() {
1348
+ this.cleanup(), this._readyState = "open", this.emitReserved("open");
1349
+ let e = this.engine;
1350
+ this.subs.push(K(e, "ping", this.onping.bind(this)), K(e, "data", this.ondata.bind(this)), K(e, "error", this.onerror.bind(this)), K(e, "close", this.onclose.bind(this)), K(this.decoder, "decoded", this.ondecoded.bind(this)));
1351
+ }
1352
+ onping() {
1353
+ this.emitReserved("ping");
1354
+ }
1355
+ ondata(e) {
1356
+ try {
1357
+ this.decoder.add(e);
1358
+ } catch (e) {
1359
+ this.onclose("parse error", e);
1360
+ }
1361
+ }
1362
+ ondecoded(e) {
1363
+ b(() => {
1364
+ this.emitReserved("packet", e);
1365
+ }, this.setTimeoutFn);
1366
+ }
1367
+ onerror(e) {
1368
+ this.emitReserved("error", e);
1369
+ }
1370
+ socket(e, t) {
1371
+ let n = this.nsps[e];
1372
+ return n ? this._autoConnect && !n.active && n.connect() : (n = new q(this, e, t), this.nsps[e] = n), n;
1373
+ }
1374
+ _destroy(e) {
1375
+ let t = Object.keys(this.nsps);
1376
+ for (let e of t) if (this.nsps[e].active) return;
1377
+ this._close();
1378
+ }
1379
+ _packet(e) {
1380
+ let t = this.encoder.encode(e);
1381
+ for (let n = 0; n < t.length; n++) this.engine.write(t[n], e.options);
1382
+ }
1383
+ cleanup() {
1384
+ this.subs.forEach((e) => e()), this.subs.length = 0, this.decoder.destroy();
1385
+ }
1386
+ _close() {
1387
+ this.skipReconnect = !0, this._reconnecting = !1, this.onclose("forced close");
1388
+ }
1389
+ disconnect() {
1390
+ return this._close();
1391
+ }
1392
+ onclose(e, t) {
1393
+ var n;
1394
+ this.cleanup(), (n = this.engine) == null || n.close(), this.backoff.reset(), this._readyState = "closed", this.emitReserved("close", e, t), this._reconnection && !this.skipReconnect && this.reconnect();
1395
+ }
1396
+ reconnect() {
1397
+ if (this._reconnecting || this.skipReconnect) return this;
1398
+ let e = this;
1399
+ if (this.backoff.attempts >= this._reconnectionAttempts) this.backoff.reset(), this.emitReserved("reconnect_failed"), this._reconnecting = !1;
1400
+ else {
1401
+ let t = this.backoff.duration();
1402
+ this._reconnecting = !0;
1403
+ let n = this.setTimeoutFn(() => {
1404
+ e.skipReconnect || (this.emitReserved("reconnect_attempt", e.backoff.attempts), !e.skipReconnect && e.open((t) => {
1405
+ t ? (e._reconnecting = !1, e.reconnect(), this.emitReserved("reconnect_error", t)) : e.onreconnect();
1406
+ }));
1407
+ }, t);
1408
+ this.opts.autoUnref && n.unref(), this.subs.push(() => {
1409
+ this.clearTimeoutFn(n);
1410
+ });
1411
+ }
1412
+ }
1413
+ onreconnect() {
1414
+ let e = this.backoff.attempts;
1415
+ this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect", e);
1416
+ }
1417
+ }, X = {};
1418
+ function Z(e, t) {
1419
+ typeof e == "object" && (t = e, e = void 0), t ||= {};
1420
+ let n = Me(e, t.path || "/socket.io"), r = n.source, i = n.id, a = n.path, o = X[i] && a in X[i].nsps, s = t.forceNew || t["force new connection"] || !1 === t.multiplex || o, c;
1421
+ return s ? c = new Y(r, t) : (X[i] || (X[i] = new Y(r, t)), c = X[i]), n.query && !t.query && (t.query = n.queryKey), c.socket(n.path, t);
1422
+ }
1423
+ Object.assign(Z, {
1424
+ Manager: Y,
1425
+ Socket: q,
1426
+ io: Z,
1427
+ connect: Z
1428
+ });
1429
+ //#endregion
1430
+ //#region src/index.ts
1431
+ var Q = "\n#jibtalk-sdk-root {\n position: fixed;\n z-index: 9999;\n font-family: 'Outfit', 'Vazirmatn', -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif;\n direction: ltr;\n \n /* Brand colors */\n --primary: #00AC78;\n --secondary: #FF6FA8;\n \n /* Default Dark Mode variables */\n --theme-white: 255, 255, 255;\n --theme-bg: 16, 18, 17;\n --theme-placeholder: 107, 124, 118;\n --theme-hint: 158, 180, 173;\n --theme-surface-elevated: 25, 29, 27;\n --theme-surface-soft: 34, 39, 37;\n --theme-border-soft: 107, 124, 118;\n --theme-backdrop: 0, 0, 0;\n \n --color-white: rgb(var(--theme-white));\n --color-bg: rgb(var(--theme-bg));\n --color-placeholder: rgb(var(--theme-placeholder));\n --color-hint: rgb(var(--theme-hint));\n --color-surface: rgb(var(--theme-surface-elevated));\n --color-surface-soft: rgb(var(--theme-surface-soft));\n --color-border-soft: rgb(var(--theme-border-soft));\n \n --rounded-md: 6px;\n --rounded-lg: 8px;\n --rounded-xl: 12px;\n --rounded-2xl: 16px;\n}\n\n/* Position options */\n#jibtalk-sdk-root.position-bottom-right { bottom: 20px; right: 20px; }\n#jibtalk-sdk-root.position-bottom-left { bottom: 20px; left: 20px; }\n#jibtalk-sdk-root.position-top-right { top: 20px; right: 20px; }\n#jibtalk-sdk-root.position-top-left { top: 20px; left: 20px; }\n\n/* Light theme overrides */\n#jibtalk-sdk-root[data-theme='light'] {\n --theme-white: 27, 36, 32; /* Dark slate text */\n --theme-bg: 242, 247, 245; /* Soft Teal-Gray */\n --theme-placeholder: 122, 141, 133;\n --theme-hint: 83, 100, 92;\n --theme-surface-elevated: 251, 253, 252;\n --theme-surface-soft: 231, 239, 235;\n --theme-border-soft: 180, 197, 190;\n --theme-backdrop: 16, 18, 17;\n}\n\n.jibtalk-sdk-btn {\n background: linear-gradient(135deg, var(--primary), var(--secondary));\n color: white;\n border: none;\n border-radius: 50%;\n width: 60px;\n height: 60px;\n cursor: pointer;\n box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);\n display: flex;\n align-items: center;\n justify-content: center;\n transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out, opacity 0.3s ease-in-out;\n position: relative;\n}\n\n.jibtalk-sdk-btn:hover {\n transform: scale(1.02);\n opacity: 0.9;\n box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.2), 0 6px 20px rgba(0, 0, 0, 0.25);\n}\n\n.jibtalk-sdk-unread-badge {\n position: absolute;\n top: -2px;\n right: -2px;\n background-color: var(--secondary);\n color: white;\n border-radius: 50%;\n width: 20px;\n height: 20px;\n font-size: 11px;\n font-weight: 700;\n display: flex;\n align-items: center;\n justify-content: center;\n border: 2px solid var(--color-surface);\n animation: pulse 1.5s infinite;\n}\n\n@keyframes pulse {\n 0% { transform: scale(1); }\n 50% { transform: scale(1.15); }\n 100% { transform: scale(1); }\n}\n\n.jibtalk-sdk-window {\n width: 350px;\n height: 500px;\n background: rgba(var(--theme-surface-elevated), 0.85);\n backdrop-filter: blur(16px);\n -webkit-backdrop-filter: blur(16px);\n border-radius: var(--rounded-2xl);\n box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06), 0 10px 40px rgba(0, 0, 0, 0.15);\n display: flex;\n flex-direction: column;\n overflow: hidden;\n border: 1px solid rgba(var(--theme-border-soft), 0.4);\n animation: jibtalkSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);\n color: var(--color-white);\n}\n\n@keyframes jibtalkSlideUp {\n from { opacity: 0; transform: translateY(20px); }\n to { opacity: 1; transform: translateY(0); }\n}\n\n.jibtalk-sdk-header {\n background: linear-gradient(135deg, var(--primary), var(--secondary));\n color: white;\n padding: 16px;\n display: flex;\n justify-content: space-between;\n align-items: center;\n border-bottom: 1px solid rgba(var(--theme-border-soft), 0.3);\n}\n\n.jibtalk-sdk-header h4 {\n margin: 0;\n font-size: 16px;\n font-weight: 600;\n}\n\n.jibtalk-sdk-close-btn {\n background: none;\n border: none;\n color: white;\n font-size: 24px;\n cursor: pointer;\n line-height: 1;\n opacity: 0.8;\n transition: opacity 0.3s ease-in-out;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n}\n\n.jibtalk-sdk-close-btn:hover {\n opacity: 1;\n}\n\n.jibtalk-sdk-messages {\n flex: 1;\n padding: 16px;\n overflow-y: auto;\n display: flex;\n flex-direction: column;\n gap: 12px;\n background-color: rgba(var(--theme-bg), 0.8);\n scrollbar-width: thin;\n scrollbar-color: var(--primary) transparent;\n}\n\n/* Custom Scrollbar */\n@supports not (scrollbar-color: auto) {\n .jibtalk-sdk-messages::-webkit-scrollbar {\n width: 6px;\n height: 6px;\n }\n .jibtalk-sdk-messages::-webkit-scrollbar-thumb {\n background: var(--primary);\n border-radius: 3px;\n }\n .jibtalk-sdk-messages::-webkit-scrollbar-track {\n background: transparent;\n }\n}\n\n.jibtalk-sdk-message {\n max-width: 80%;\n padding: 10px 14px;\n border-radius: var(--rounded-xl);\n font-size: 14px;\n line-height: 1.4;\n word-wrap: break-word;\n}\n\n.jibtalk-sdk-message-self {\n align-self: flex-end;\n background: linear-gradient(135deg, var(--primary), var(--secondary));\n color: white;\n border-bottom-right-radius: 4px;\n}\n\n.jibtalk-sdk-message-other {\n align-self: flex-start;\n background: var(--color-surface);\n color: var(--color-white);\n border: 1px solid rgba(var(--theme-border-soft), 0.3);\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);\n border-bottom-left-radius: 4px;\n}\n\n.jibtalk-sdk-input-area {\n padding: 12px;\n background: rgba(var(--theme-surface-elevated), 0.95);\n display: flex;\n gap: 8px;\n border-top: 1px solid rgba(var(--theme-border-soft), 0.3);\n}\n\n.jibtalk-sdk-input {\n flex: 1;\n padding: 10px 14px;\n border: 1px solid rgba(var(--theme-placeholder), 0.5);\n border-radius: 20px;\n outline: none;\n font-size: 14px;\n background: transparent;\n color: var(--color-white);\n transition: border-color 0.3s ease-in-out;\n}\n\n.jibtalk-sdk-input::placeholder {\n color: rgba(var(--theme-placeholder), 0.8);\n}\n\n.jibtalk-sdk-input:focus {\n border-color: var(--primary);\n}\n\n.jibtalk-sdk-send-btn {\n background: linear-gradient(135deg, var(--primary), var(--secondary));\n color: white;\n border: none;\n border-radius: 20px;\n padding: 0 16px;\n font-weight: 500;\n cursor: pointer;\n transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;\n}\n\n.jibtalk-sdk-send-btn:hover {\n opacity: 0.9;\n transform: scale(1.02);\n}\n", Je = () => {
1432
+ if (typeof document > "u") return;
1433
+ let e = "jibtalk-sdk-styles";
1434
+ if (!document.getElementById(e)) {
1435
+ let t = document.createElement("style");
1436
+ t.id = e, t.textContent = Q, document.head.appendChild(t);
1437
+ }
1438
+ }, Ye = class {
1439
+ socket = null;
1440
+ apiKey;
1441
+ backendUrl;
1442
+ visitorId;
1443
+ listeners = /* @__PURE__ */ new Map();
1444
+ isOpen = !1;
1445
+ isConnected = !1;
1446
+ unreadCount = 0;
1447
+ currentConversation = null;
1448
+ messages = [];
1449
+ theme = "dark";
1450
+ position = "bottom-right";
1451
+ primaryColor = "#00AC78";
1452
+ locale = "en";
1453
+ constructor(e) {
1454
+ this.apiKey = e.apiKey, this.backendUrl = typeof globalThis < "u" && globalThis.process?.env?.NEXT_PUBLIC_JIBTALK_BACKEND_URL || typeof window < "u" && window.JIBTALK_BACKEND_URL || "http://localhost:5000", this.theme = e.theme || "dark", this.position = e.position || "bottom-right", this.primaryColor = e.primaryColor || "#00AC78", this.locale = e.locale || "en", this.optionsCustomer = e.customer, this.optionsConvId = e.conversationId, this.optionsTimestamp = e.timestamp, this.optionsSignature = e.signature;
1455
+ let t = typeof window < "u" ? localStorage.getItem("jibtalk_conversation_id") : null;
1456
+ this.currentConversation = t ? { id: t } : null, this.visitorId = e.customer?.id || this.getVisitorId(), this.connect();
1457
+ }
1458
+ getVisitorId() {
1459
+ if (typeof window > "u") return "";
1460
+ let e = localStorage.getItem("jibtalk_visitor_id");
1461
+ return e ||= localStorage.getItem("vyou_visitor_id"), e || (e = "v_" + Math.random().toString(36).substring(2, 11), localStorage.setItem("jibtalk_visitor_id", e)), e;
1462
+ }
1463
+ connect() {
1464
+ typeof window > "u" || (this.socket && this.socket.disconnect(), this.socket = Z(this.backendUrl), this.socket.on("connect", () => {
1465
+ this.isConnected = !0, this.emit("connected"), this.emitStateChange();
1466
+ let e = this.optionsCustomer, t = this.optionsConvId;
1467
+ this.initWidget(e, t);
1468
+ }), this.socket.on("disconnect", () => {
1469
+ this.isConnected = !1, this.emit("disconnected"), this.emitStateChange();
1470
+ }), this.socket.on("session_ready", (e) => {
1471
+ this.currentConversation = e, this.messages = e.messages || [], typeof window < "u" && (e.id && localStorage.setItem("jibtalk_conversation_id", e.id), e.sessionToken && localStorage.setItem("jibtalk_session_token", e.sessionToken)), this.emit("conversationOpened", e), this.emitStateChange();
1472
+ }), this.socket.on("receive_message", (e) => {
1473
+ this.messages.push(e), e.sender === "visitor" ? this.emit("messageSent", e) : (this.isOpen || this.unreadCount++, this.emit("messageReceived", e)), this.emitStateChange();
1474
+ }), this.socket.on("typing_started", (e) => {
1475
+ this.emit("typingStarted", e);
1476
+ }), this.socket.on("typing_stopped", (e) => {
1477
+ this.emit("typingStopped", e);
1478
+ }), this.socket.on("error", (e) => {
1479
+ console.error("JibTalk Socket error:", e.message || e);
1480
+ }));
1481
+ }
1482
+ initWidget(e, t) {
1483
+ if (!this.socket) return;
1484
+ let n = { apiKey: this.apiKey }, r = t || this.currentConversation?.id;
1485
+ if (r && (n.conversationId = r, typeof window < "u" && !e)) {
1486
+ let e = localStorage.getItem("jibtalk_session_token");
1487
+ e && (n.sessionToken = e);
1488
+ }
1489
+ e ? (n.customer = {
1490
+ id: e.id,
1491
+ name: e.name,
1492
+ email: e.email,
1493
+ avatar: e.avatar,
1494
+ metadata: e.metadata
1495
+ }, this.optionsTimestamp && (n.timestamp = this.optionsTimestamp), this.optionsSignature && (n.signature = this.optionsSignature)) : n.visitorId = this.visitorId, this.socket.emit("init_widget", n);
1496
+ }
1497
+ open(e) {
1498
+ this.isOpen || (this.isOpen = !0, this.unreadCount = 0, e && (e.customer && (this.visitorId = e.customer.id || this.visitorId, this.optionsCustomer = e.customer), e.conversationId && (this.optionsConvId = e.conversationId), e.timestamp && (this.optionsTimestamp = e.timestamp), e.signature && (this.optionsSignature = e.signature), this.initWidget(e.customer, e.conversationId)), this.emitStateChange());
1499
+ }
1500
+ close() {
1501
+ this.isOpen && (this.isOpen = !1, this.emitStateChange(), this.emit("conversationClosed", this.currentConversation));
1502
+ }
1503
+ toggle() {
1504
+ this.isOpen ? this.close() : this.open();
1505
+ }
1506
+ destroy() {
1507
+ this.close(), this.socket &&= (this.socket.disconnect(), null), this.listeners.clear(), this.isConnected = !1, this.emitStateChange(), $ === this && ($ = null);
1508
+ }
1509
+ identify(e, t, n) {
1510
+ typeof window > "u" || (this.visitorId = e.id || this.visitorId, this.optionsCustomer = e, t && (this.optionsTimestamp = t), n && (this.optionsSignature = n), this.initWidget(e));
1511
+ }
1512
+ setUser(e, t, n) {
1513
+ this.identify(e, t, n);
1514
+ }
1515
+ logout() {
1516
+ typeof window > "u" || (this.close(), localStorage.removeItem("jibtalk_visitor_id"), localStorage.removeItem("vyou_visitor_id"), localStorage.removeItem("jibtalk_conversation_id"), localStorage.removeItem("jibtalk_session_token"), this.optionsCustomer = void 0, this.optionsConvId = void 0, this.optionsTimestamp = void 0, this.optionsSignature = void 0, this.visitorId = this.getVisitorId(), this.currentConversation = null, this.messages = [], this.unreadCount = 0, this.connect());
1517
+ }
1518
+ sendMessage(e) {
1519
+ !e.trim() || !this.currentConversation || !this.socket || this.socket.emit("send_message", {
1520
+ sessionId: this.currentConversation.id,
1521
+ content: e,
1522
+ sender: "visitor",
1523
+ visitorId: this.visitorId
1524
+ });
1525
+ }
1526
+ startTyping() {
1527
+ !this.socket || !this.currentConversation || this.socket.emit("typing_started", {
1528
+ sessionId: this.currentConversation.id,
1529
+ sender: "visitor",
1530
+ visitorId: this.visitorId
1531
+ });
1532
+ }
1533
+ stopTyping() {
1534
+ !this.socket || !this.currentConversation || this.socket.emit("typing_stopped", {
1535
+ sessionId: this.currentConversation.id,
1536
+ sender: "visitor",
1537
+ visitorId: this.visitorId
1538
+ });
1539
+ }
1540
+ on(e, t) {
1541
+ this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(t);
1542
+ }
1543
+ off(e, t) {
1544
+ this.listeners.has(e) && this.listeners.get(e).delete(t);
1545
+ }
1546
+ emit(e, ...t) {
1547
+ this.listeners.has(e) && this.listeners.get(e).forEach((n) => {
1548
+ try {
1549
+ n(...t);
1550
+ } catch (t) {
1551
+ console.error(`Error in event listener for ${e}:`, t);
1552
+ }
1553
+ });
1554
+ }
1555
+ emitStateChange() {
1556
+ this.emit("stateChange", {
1557
+ isOpen: this.isOpen,
1558
+ isConnected: this.isConnected,
1559
+ unreadCount: this.unreadCount,
1560
+ currentConversation: this.currentConversation,
1561
+ messages: this.messages,
1562
+ theme: this.theme,
1563
+ position: this.position,
1564
+ primaryColor: this.primaryColor,
1565
+ locale: this.locale
1566
+ });
1567
+ }
1568
+ updateOptions(e) {
1569
+ e.theme && (this.theme = e.theme), e.position && (this.position = e.position), e.primaryColor && (this.primaryColor = e.primaryColor), e.locale && (this.locale = e.locale), e.customer && (this.visitorId = e.customer.id || this.visitorId, this.optionsCustomer = e.customer), e.conversationId && (this.optionsConvId = e.conversationId), e.timestamp && (this.optionsTimestamp = e.timestamp), e.signature && (this.optionsSignature = e.signature), this.emitStateChange();
1570
+ }
1571
+ }, $ = null, Xe = (e) => typeof window > "u" ? null : (!$ && e ? $ = new Ye(e) : $ && e && $.updateOptions(e), $);
1572
+ //#endregion
1573
+ export { Ye as JibTalkCore, Q as STYLES_CSS, Xe as getJibTalkInstance, Je as injectStyles };