zen-code 2.2.0 → 2.4.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.
@@ -11,12 +11,13 @@ import { a as et, g as yt } from "./_commonjsHelpers-ByX85dGu.mjs";
11
11
  import Et from "node:buffer";
12
12
  import tt from "react-devtools-core";
13
13
  var te = { exports: {} }, _e, $e;
14
- function j() {
14
+ function q() {
15
15
  if ($e) return _e;
16
16
  $e = 1;
17
17
  const P = ["nodebuffer", "arraybuffer", "fragments"], T = typeof Blob < "u";
18
18
  return T && P.push("blob"), _e = {
19
19
  BINARY_TYPES: P,
20
+ CLOSE_TIMEOUT: 3e4,
20
21
  EMPTY_BUFFER: Buffer.alloc(0),
21
22
  GUID: "258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
22
23
  hasBlob: T,
@@ -28,55 +29,55 @@ function j() {
28
29
  }
29
30
  }, _e;
30
31
  }
31
- const xt = {}, St = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
32
+ const St = {}, xt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
32
33
  __proto__: null,
33
- default: xt
34
- }, Symbol.toStringTag, { value: "Module" })), vt = /* @__PURE__ */ et(St);
34
+ default: St
35
+ }, Symbol.toStringTag, { value: "Module" })), vt = /* @__PURE__ */ et(xt);
35
36
  var Fe;
36
- function oe() {
37
+ function ae() {
37
38
  if (Fe) return te.exports;
38
39
  Fe = 1;
39
- const { EMPTY_BUFFER: P } = j(), T = Buffer[Symbol.species];
40
- function M(f, a) {
41
- if (f.length === 0) return P;
42
- if (f.length === 1) return f[0];
40
+ const { EMPTY_BUFFER: P } = q(), T = Buffer[Symbol.species];
41
+ function M(l, a) {
42
+ if (l.length === 0) return P;
43
+ if (l.length === 1) return l[0];
43
44
  const _ = Buffer.allocUnsafe(a);
44
45
  let h = 0;
45
- for (let C = 0; C < f.length; C++) {
46
- const c = f[C];
46
+ for (let L = 0; L < l.length; L++) {
47
+ const c = l[L];
47
48
  _.set(c, h), h += c.length;
48
49
  }
49
50
  return h < a ? new T(_.buffer, _.byteOffset, h) : _;
50
51
  }
51
- function B(f, a, _, h, C) {
52
- for (let c = 0; c < C; c++)
53
- _[h + c] = f[c] ^ a[c & 3];
52
+ function D(l, a, _, h, L) {
53
+ for (let c = 0; c < L; c++)
54
+ _[h + c] = l[c] ^ a[c & 3];
54
55
  }
55
- function b(f, a) {
56
- for (let _ = 0; _ < f.length; _++)
57
- f[_] ^= a[_ & 3];
56
+ function x(l, a) {
57
+ for (let _ = 0; _ < l.length; _++)
58
+ l[_] ^= a[_ & 3];
58
59
  }
59
- function d(f) {
60
- return f.length === f.buffer.byteLength ? f.buffer : f.buffer.slice(f.byteOffset, f.byteOffset + f.length);
60
+ function d(l) {
61
+ return l.length === l.buffer.byteLength ? l.buffer : l.buffer.slice(l.byteOffset, l.byteOffset + l.length);
61
62
  }
62
- function n(f) {
63
- if (n.readOnly = !0, Buffer.isBuffer(f)) return f;
63
+ function n(l) {
64
+ if (n.readOnly = !0, Buffer.isBuffer(l)) return l;
64
65
  let a;
65
- return f instanceof ArrayBuffer ? a = new T(f) : ArrayBuffer.isView(f) ? a = new T(f.buffer, f.byteOffset, f.byteLength) : (a = Buffer.from(f), n.readOnly = !1), a;
66
+ return l instanceof ArrayBuffer ? a = new T(l) : ArrayBuffer.isView(l) ? a = new T(l.buffer, l.byteOffset, l.byteLength) : (a = Buffer.from(l), n.readOnly = !1), a;
66
67
  }
67
68
  if (te.exports = {
68
69
  concat: M,
69
- mask: B,
70
+ mask: D,
70
71
  toArrayBuffer: d,
71
72
  toBuffer: n,
72
- unmask: b
73
+ unmask: x
73
74
  }, !process.env.WS_NO_BUFFER_UTIL)
74
75
  try {
75
- const f = vt;
76
- te.exports.mask = function(a, _, h, C, c) {
77
- c < 48 ? B(a, _, h, C, c) : f.mask(a, _, h, C, c);
76
+ const l = vt;
77
+ te.exports.mask = function(a, _, h, L, c) {
78
+ c < 48 ? D(a, _, h, L, c) : l.mask(a, _, h, L, c);
78
79
  }, te.exports.unmask = function(a, _) {
79
- a.length < 32 ? b(a, _) : f.unmask(a, _);
80
+ a.length < 32 ? x(a, _) : l.unmask(a, _);
80
81
  };
81
82
  } catch {
82
83
  }
@@ -94,10 +95,10 @@ function bt() {
94
95
  * @param {Number} [concurrency=Infinity] The maximum number of jobs allowed
95
96
  * to run concurrently
96
97
  */
97
- constructor(b) {
98
+ constructor(x) {
98
99
  this[P] = () => {
99
100
  this.pending--, this[T]();
100
- }, this.concurrency = b || 1 / 0, this.jobs = [], this.pending = 0;
101
+ }, this.concurrency = x || 1 / 0, this.jobs = [], this.pending = 0;
101
102
  }
102
103
  /**
103
104
  * Adds a job to the queue.
@@ -105,8 +106,8 @@ function bt() {
105
106
  * @param {Function} job The job to run
106
107
  * @public
107
108
  */
108
- add(b) {
109
- this.jobs.push(b), this[T]();
109
+ add(x) {
110
+ this.jobs.push(x), this[T]();
110
111
  }
111
112
  /**
112
113
  * Removes a job from the queue and runs it if possible.
@@ -115,19 +116,19 @@ function bt() {
115
116
  */
116
117
  [T]() {
117
118
  if (this.pending !== this.concurrency && this.jobs.length) {
118
- const b = this.jobs.shift();
119
- this.pending++, b(this[P]);
119
+ const x = this.jobs.shift();
120
+ this.pending++, x(this[P]);
120
121
  }
121
122
  }
122
123
  }
123
124
  return pe = M, pe;
124
125
  }
125
126
  var me, Ve;
126
- function ae() {
127
+ function le() {
127
128
  if (Ve) return me;
128
129
  Ve = 1;
129
- const P = gt, T = oe(), M = bt(), { kStatusCode: B } = j(), b = Buffer[Symbol.species], d = Buffer.from([0, 0, 255, 255]), n = /* @__PURE__ */ Symbol("permessage-deflate"), f = /* @__PURE__ */ Symbol("total-length"), a = /* @__PURE__ */ Symbol("callback"), _ = /* @__PURE__ */ Symbol("buffers"), h = /* @__PURE__ */ Symbol("error");
130
- let C;
130
+ const P = gt, T = ae(), M = bt(), { kStatusCode: D } = q(), x = Buffer[Symbol.species], d = Buffer.from([0, 0, 255, 255]), n = /* @__PURE__ */ Symbol("permessage-deflate"), l = /* @__PURE__ */ Symbol("total-length"), a = /* @__PURE__ */ Symbol("callback"), _ = /* @__PURE__ */ Symbol("buffers"), h = /* @__PURE__ */ Symbol("error");
131
+ let L;
131
132
  class c {
132
133
  /**
133
134
  * Creates a PerMessageDeflate instance.
@@ -153,10 +154,10 @@ function ae() {
153
154
  * client mode
154
155
  * @param {Number} [maxPayload=0] The maximum allowed message length
155
156
  */
156
- constructor(p, l, E) {
157
- if (this._maxPayload = E | 0, this._options = p || {}, this._threshold = this._options.threshold !== void 0 ? this._options.threshold : 1024, this._isServer = !!l, this._deflate = null, this._inflate = null, this.params = null, !C) {
158
- const u = this._options.concurrencyLimit !== void 0 ? this._options.concurrencyLimit : 10;
159
- C = new M(u);
157
+ constructor(p, f, E) {
158
+ if (this._maxPayload = E | 0, this._options = p || {}, this._threshold = this._options.threshold !== void 0 ? this._options.threshold : 1024, this._isServer = !!f, this._deflate = null, this._inflate = null, this.params = null, !L) {
159
+ const w = this._options.concurrencyLimit !== void 0 ? this._options.concurrencyLimit : 10;
160
+ L = new M(w);
160
161
  }
161
162
  }
162
163
  /**
@@ -208,10 +209,10 @@ function ae() {
208
209
  * @private
209
210
  */
210
211
  acceptAsServer(p) {
211
- const l = this._options, E = p.find((u) => !(l.serverNoContextTakeover === !1 && u.server_no_context_takeover || u.server_max_window_bits && (l.serverMaxWindowBits === !1 || typeof l.serverMaxWindowBits == "number" && l.serverMaxWindowBits > u.server_max_window_bits) || typeof l.clientMaxWindowBits == "number" && !u.client_max_window_bits));
212
+ const f = this._options, E = p.find((w) => !(f.serverNoContextTakeover === !1 && w.server_no_context_takeover || w.server_max_window_bits && (f.serverMaxWindowBits === !1 || typeof f.serverMaxWindowBits == "number" && f.serverMaxWindowBits > w.server_max_window_bits) || typeof f.clientMaxWindowBits == "number" && !w.client_max_window_bits));
212
213
  if (!E)
213
214
  throw new Error("None of the extension offers can be accepted");
214
- return l.serverNoContextTakeover && (E.server_no_context_takeover = !0), l.clientNoContextTakeover && (E.client_no_context_takeover = !0), typeof l.serverMaxWindowBits == "number" && (E.server_max_window_bits = l.serverMaxWindowBits), typeof l.clientMaxWindowBits == "number" ? E.client_max_window_bits = l.clientMaxWindowBits : (E.client_max_window_bits === !0 || l.clientMaxWindowBits === !1) && delete E.client_max_window_bits, E;
215
+ return f.serverNoContextTakeover && (E.server_no_context_takeover = !0), f.clientNoContextTakeover && (E.client_no_context_takeover = !0), typeof f.serverMaxWindowBits == "number" && (E.server_max_window_bits = f.serverMaxWindowBits), typeof f.clientMaxWindowBits == "number" ? E.client_max_window_bits = f.clientMaxWindowBits : (E.client_max_window_bits === !0 || f.clientMaxWindowBits === !1) && delete E.client_max_window_bits, E;
215
216
  }
216
217
  /**
217
218
  * Accept the extension negotiation response.
@@ -221,16 +222,16 @@ function ae() {
221
222
  * @private
222
223
  */
223
224
  acceptAsClient(p) {
224
- const l = p[0];
225
- if (this._options.clientNoContextTakeover === !1 && l.client_no_context_takeover)
225
+ const f = p[0];
226
+ if (this._options.clientNoContextTakeover === !1 && f.client_no_context_takeover)
226
227
  throw new Error('Unexpected parameter "client_no_context_takeover"');
227
- if (!l.client_max_window_bits)
228
- typeof this._options.clientMaxWindowBits == "number" && (l.client_max_window_bits = this._options.clientMaxWindowBits);
229
- else if (this._options.clientMaxWindowBits === !1 || typeof this._options.clientMaxWindowBits == "number" && l.client_max_window_bits > this._options.clientMaxWindowBits)
228
+ if (!f.client_max_window_bits)
229
+ typeof this._options.clientMaxWindowBits == "number" && (f.client_max_window_bits = this._options.clientMaxWindowBits);
230
+ else if (this._options.clientMaxWindowBits === !1 || typeof this._options.clientMaxWindowBits == "number" && f.client_max_window_bits > this._options.clientMaxWindowBits)
230
231
  throw new Error(
231
232
  'Unexpected or invalid parameter "client_max_window_bits"'
232
233
  );
233
- return l;
234
+ return f;
234
235
  }
235
236
  /**
236
237
  * Normalize parameters.
@@ -240,38 +241,38 @@ function ae() {
240
241
  * @private
241
242
  */
242
243
  normalizeParams(p) {
243
- return p.forEach((l) => {
244
- Object.keys(l).forEach((E) => {
245
- let u = l[E];
246
- if (u.length > 1)
244
+ return p.forEach((f) => {
245
+ Object.keys(f).forEach((E) => {
246
+ let w = f[E];
247
+ if (w.length > 1)
247
248
  throw new Error(`Parameter "${E}" must have only a single value`);
248
- if (u = u[0], E === "client_max_window_bits") {
249
- if (u !== !0) {
250
- const e = +u;
251
- if (!Number.isInteger(e) || e < 8 || e > 15)
249
+ if (w = w[0], E === "client_max_window_bits") {
250
+ if (w !== !0) {
251
+ const t = +w;
252
+ if (!Number.isInteger(t) || t < 8 || t > 15)
252
253
  throw new TypeError(
253
- `Invalid value for parameter "${E}": ${u}`
254
+ `Invalid value for parameter "${E}": ${w}`
254
255
  );
255
- u = e;
256
+ w = t;
256
257
  } else if (!this._isServer)
257
258
  throw new TypeError(
258
- `Invalid value for parameter "${E}": ${u}`
259
+ `Invalid value for parameter "${E}": ${w}`
259
260
  );
260
261
  } else if (E === "server_max_window_bits") {
261
- const e = +u;
262
- if (!Number.isInteger(e) || e < 8 || e > 15)
262
+ const t = +w;
263
+ if (!Number.isInteger(t) || t < 8 || t > 15)
263
264
  throw new TypeError(
264
- `Invalid value for parameter "${E}": ${u}`
265
+ `Invalid value for parameter "${E}": ${w}`
265
266
  );
266
- u = e;
267
+ w = t;
267
268
  } else if (E === "client_no_context_takeover" || E === "server_no_context_takeover") {
268
- if (u !== !0)
269
+ if (w !== !0)
269
270
  throw new TypeError(
270
- `Invalid value for parameter "${E}": ${u}`
271
+ `Invalid value for parameter "${E}": ${w}`
271
272
  );
272
273
  } else
273
274
  throw new Error(`Unknown parameter "${E}"`);
274
- l[E] = u;
275
+ f[E] = w;
275
276
  });
276
277
  }), p;
277
278
  }
@@ -283,10 +284,10 @@ function ae() {
283
284
  * @param {Function} callback Callback
284
285
  * @public
285
286
  */
286
- decompress(p, l, E) {
287
- C.add((u) => {
288
- this._decompress(p, l, (e, t) => {
289
- u(), E(e, t);
287
+ decompress(p, f, E) {
288
+ L.add((w) => {
289
+ this._decompress(p, f, (t, e) => {
290
+ w(), E(t, e);
290
291
  });
291
292
  });
292
293
  }
@@ -298,10 +299,10 @@ function ae() {
298
299
  * @param {Function} callback Callback
299
300
  * @public
300
301
  */
301
- compress(p, l, E) {
302
- C.add((u) => {
303
- this._compress(p, l, (e, t) => {
304
- u(), E(e, t);
302
+ compress(p, f, E) {
303
+ L.add((w) => {
304
+ this._compress(p, f, (t, e) => {
305
+ w(), E(t, e);
305
306
  });
306
307
  });
307
308
  }
@@ -313,26 +314,26 @@ function ae() {
313
314
  * @param {Function} callback Callback
314
315
  * @private
315
316
  */
316
- _decompress(p, l, E) {
317
- const u = this._isServer ? "client" : "server";
317
+ _decompress(p, f, E) {
318
+ const w = this._isServer ? "client" : "server";
318
319
  if (!this._inflate) {
319
- const e = `${u}_max_window_bits`, t = typeof this.params[e] != "number" ? P.Z_DEFAULT_WINDOWBITS : this.params[e];
320
+ const t = `${w}_max_window_bits`, e = typeof this.params[t] != "number" ? P.Z_DEFAULT_WINDOWBITS : this.params[t];
320
321
  this._inflate = P.createInflateRaw({
321
322
  ...this._options.zlibInflateOptions,
322
- windowBits: t
323
- }), this._inflate[n] = this, this._inflate[f] = 0, this._inflate[_] = [], this._inflate.on("error", v), this._inflate.on("data", k);
323
+ windowBits: e
324
+ }), this._inflate[n] = this, this._inflate[l] = 0, this._inflate[_] = [], this._inflate.on("error", v), this._inflate.on("data", C);
324
325
  }
325
- this._inflate[a] = E, this._inflate.write(p), l && this._inflate.write(d), this._inflate.flush(() => {
326
- const e = this._inflate[h];
327
- if (e) {
328
- this._inflate.close(), this._inflate = null, E(e);
326
+ this._inflate[a] = E, this._inflate.write(p), f && this._inflate.write(d), this._inflate.flush(() => {
327
+ const t = this._inflate[h];
328
+ if (t) {
329
+ this._inflate.close(), this._inflate = null, E(t);
329
330
  return;
330
331
  }
331
- const t = T.concat(
332
+ const e = T.concat(
332
333
  this._inflate[_],
333
- this._inflate[f]
334
+ this._inflate[l]
334
335
  );
335
- this._inflate._readableState.endEmitted ? (this._inflate.close(), this._inflate = null) : (this._inflate[f] = 0, this._inflate[_] = [], l && this.params[`${u}_no_context_takeover`] && this._inflate.reset()), E(null, t);
336
+ this._inflate._readableState.endEmitted ? (this._inflate.close(), this._inflate = null) : (this._inflate[l] = 0, this._inflate[_] = [], f && this.params[`${w}_no_context_takeover`] && this._inflate.reset()), E(null, e);
336
337
  });
337
338
  }
338
339
  /**
@@ -343,43 +344,43 @@ function ae() {
343
344
  * @param {Function} callback Callback
344
345
  * @private
345
346
  */
346
- _compress(p, l, E) {
347
- const u = this._isServer ? "server" : "client";
347
+ _compress(p, f, E) {
348
+ const w = this._isServer ? "server" : "client";
348
349
  if (!this._deflate) {
349
- const e = `${u}_max_window_bits`, t = typeof this.params[e] != "number" ? P.Z_DEFAULT_WINDOWBITS : this.params[e];
350
+ const t = `${w}_max_window_bits`, e = typeof this.params[t] != "number" ? P.Z_DEFAULT_WINDOWBITS : this.params[t];
350
351
  this._deflate = P.createDeflateRaw({
351
352
  ...this._options.zlibDeflateOptions,
352
- windowBits: t
353
- }), this._deflate[f] = 0, this._deflate[_] = [], this._deflate.on("data", w);
353
+ windowBits: e
354
+ }), this._deflate[l] = 0, this._deflate[_] = [], this._deflate.on("data", b);
354
355
  }
355
356
  this._deflate[a] = E, this._deflate.write(p), this._deflate.flush(P.Z_SYNC_FLUSH, () => {
356
357
  if (!this._deflate)
357
358
  return;
358
- let e = T.concat(
359
+ let t = T.concat(
359
360
  this._deflate[_],
360
- this._deflate[f]
361
+ this._deflate[l]
361
362
  );
362
- l && (e = new b(e.buffer, e.byteOffset, e.length - 4)), this._deflate[a] = null, this._deflate[f] = 0, this._deflate[_] = [], l && this.params[`${u}_no_context_takeover`] && this._deflate.reset(), E(null, e);
363
+ f && (t = new x(t.buffer, t.byteOffset, t.length - 4)), this._deflate[a] = null, this._deflate[l] = 0, this._deflate[_] = [], f && this.params[`${w}_no_context_takeover`] && this._deflate.reset(), E(null, t);
363
364
  });
364
365
  }
365
366
  }
366
367
  me = c;
367
- function w(O) {
368
- this[_].push(O), this[f] += O.length;
368
+ function b(O) {
369
+ this[_].push(O), this[l] += O.length;
369
370
  }
370
- function k(O) {
371
- if (this[f] += O.length, this[n]._maxPayload < 1 || this[f] <= this[n]._maxPayload) {
371
+ function C(O) {
372
+ if (this[l] += O.length, this[n]._maxPayload < 1 || this[l] <= this[n]._maxPayload) {
372
373
  this[_].push(O);
373
374
  return;
374
375
  }
375
- this[h] = new RangeError("Max payload size exceeded"), this[h].code = "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH", this[h][B] = 1009, this.removeListener("data", k), this.reset();
376
+ this[h] = new RangeError("Max payload size exceeded"), this[h].code = "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH", this[h][D] = 1009, this.removeListener("data", C), this.reset();
376
377
  }
377
378
  function v(O) {
378
379
  if (this[n]._inflate = null, this[h]) {
379
380
  this[a](this[h]);
380
381
  return;
381
382
  }
382
- O[B] = 1007, this[a](O);
383
+ O[D] = 1007, this[a](O);
383
384
  }
384
385
  return me;
385
386
  }
@@ -392,7 +393,7 @@ var Ge;
392
393
  function ie() {
393
394
  if (Ge) return re.exports;
394
395
  Ge = 1;
395
- const { isUtf8: P } = Et, { hasBlob: T } = j(), M = [
396
+ const { isUtf8: P } = Et, { hasBlob: T } = q(), M = [
396
397
  0,
397
398
  0,
398
399
  0,
@@ -530,26 +531,26 @@ function ie() {
530
531
  0
531
532
  // 112 - 127
532
533
  ];
533
- function B(n) {
534
+ function D(n) {
534
535
  return n >= 1e3 && n <= 1014 && n !== 1004 && n !== 1005 && n !== 1006 || n >= 3e3 && n <= 4999;
535
536
  }
536
- function b(n) {
537
- const f = n.length;
537
+ function x(n) {
538
+ const l = n.length;
538
539
  let a = 0;
539
- for (; a < f; )
540
+ for (; a < l; )
540
541
  if ((n[a] & 128) === 0)
541
542
  a++;
542
543
  else if ((n[a] & 224) === 192) {
543
- if (a + 1 === f || (n[a + 1] & 192) !== 128 || (n[a] & 254) === 192)
544
+ if (a + 1 === l || (n[a + 1] & 192) !== 128 || (n[a] & 254) === 192)
544
545
  return !1;
545
546
  a += 2;
546
547
  } else if ((n[a] & 240) === 224) {
547
- if (a + 2 >= f || (n[a + 1] & 192) !== 128 || (n[a + 2] & 192) !== 128 || n[a] === 224 && (n[a + 1] & 224) === 128 || // Overlong
548
+ if (a + 2 >= l || (n[a + 1] & 192) !== 128 || (n[a + 2] & 192) !== 128 || n[a] === 224 && (n[a + 1] & 224) === 128 || // Overlong
548
549
  n[a] === 237 && (n[a + 1] & 224) === 160)
549
550
  return !1;
550
551
  a += 3;
551
552
  } else if ((n[a] & 248) === 240) {
552
- if (a + 3 >= f || (n[a + 1] & 192) !== 128 || (n[a + 2] & 192) !== 128 || (n[a + 3] & 192) !== 128 || n[a] === 240 && (n[a + 1] & 240) === 128 || // Overlong
553
+ if (a + 3 >= l || (n[a + 1] & 192) !== 128 || (n[a + 2] & 192) !== 128 || (n[a + 3] & 192) !== 128 || n[a] === 240 && (n[a + 1] & 240) === 128 || // Overlong
553
554
  n[a] === 244 && n[a + 1] > 143 || n[a] > 244)
554
555
  return !1;
555
556
  a += 4;
@@ -562,18 +563,18 @@ function ie() {
562
563
  }
563
564
  if (re.exports = {
564
565
  isBlob: d,
565
- isValidStatusCode: B,
566
- isValidUTF8: b,
566
+ isValidStatusCode: D,
567
+ isValidUTF8: x,
567
568
  tokenChars: M
568
569
  }, P)
569
570
  re.exports.isValidUTF8 = function(n) {
570
- return n.length < 24 ? b(n) : P(n);
571
+ return n.length < 24 ? x(n) : P(n);
571
572
  };
572
573
  else if (!process.env.WS_NO_UTF_8_VALIDATE)
573
574
  try {
574
575
  const n = Tt;
575
- re.exports.isValidUTF8 = function(f) {
576
- return f.length < 32 ? b(f) : n(f);
576
+ re.exports.isValidUTF8 = function(l) {
577
+ return l.length < 32 ? x(l) : n(l);
577
578
  };
578
579
  } catch {
579
580
  }
@@ -583,12 +584,12 @@ var ge, je;
583
584
  function rt() {
584
585
  if (je) return ge;
585
586
  je = 1;
586
- const { Writable: P } = se, T = ae(), {
587
+ const { Writable: P } = se, T = le(), {
587
588
  BINARY_TYPES: M,
588
- EMPTY_BUFFER: B,
589
- kStatusCode: b,
589
+ EMPTY_BUFFER: D,
590
+ kStatusCode: x,
590
591
  kWebSocket: d
591
- } = j(), { concat: n, toArrayBuffer: f, unmask: a } = oe(), { isValidStatusCode: _, isValidUTF8: h } = ie(), C = Buffer[Symbol.species], c = 0, w = 1, k = 2, v = 3, O = 4, p = 5, l = 6;
592
+ } = q(), { concat: n, toArrayBuffer: l, unmask: a } = ae(), { isValidStatusCode: _, isValidUTF8: h } = ie(), L = Buffer[Symbol.species], c = 0, b = 1, C = 2, v = 3, O = 4, p = 5, f = 6;
592
593
  class E extends P {
593
594
  /**
594
595
  * Creates a Receiver instance.
@@ -606,8 +607,8 @@ function rt() {
606
607
  * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
607
608
  * not to skip UTF-8 validation for text and close messages
608
609
  */
609
- constructor(e = {}) {
610
- super(), this._allowSynchronousEvents = e.allowSynchronousEvents !== void 0 ? e.allowSynchronousEvents : !0, this._binaryType = e.binaryType || M[0], this._extensions = e.extensions || {}, this._isServer = !!e.isServer, this._maxPayload = e.maxPayload | 0, this._skipUTF8Validation = !!e.skipUTF8Validation, this[d] = void 0, this._bufferedBytes = 0, this._buffers = [], this._compressed = !1, this._payloadLength = 0, this._mask = void 0, this._fragmented = 0, this._masked = !1, this._fin = !1, this._opcode = 0, this._totalPayloadLength = 0, this._messageLength = 0, this._fragments = [], this._errored = !1, this._loop = !1, this._state = c;
610
+ constructor(t = {}) {
611
+ super(), this._allowSynchronousEvents = t.allowSynchronousEvents !== void 0 ? t.allowSynchronousEvents : !0, this._binaryType = t.binaryType || M[0], this._extensions = t.extensions || {}, this._isServer = !!t.isServer, this._maxPayload = t.maxPayload | 0, this._skipUTF8Validation = !!t.skipUTF8Validation, this[d] = void 0, this._bufferedBytes = 0, this._buffers = [], this._compressed = !1, this._payloadLength = 0, this._mask = void 0, this._fragmented = 0, this._masked = !1, this._fin = !1, this._opcode = 0, this._totalPayloadLength = 0, this._messageLength = 0, this._fragments = [], this._errored = !1, this._loop = !1, this._state = c;
611
612
  }
612
613
  /**
613
614
  * Implements `Writable.prototype._write()`.
@@ -617,9 +618,9 @@ function rt() {
617
618
  * @param {Function} cb Callback
618
619
  * @private
619
620
  */
620
- _write(e, t, i) {
621
- if (this._opcode === 8 && this._state == c) return i();
622
- this._bufferedBytes += e.length, this._buffers.push(e), this.startLoop(i);
621
+ _write(t, e, s) {
622
+ if (this._opcode === 8 && this._state == c) return s();
623
+ this._bufferedBytes += t.length, this._buffers.push(t), this.startLoop(s);
623
624
  }
624
625
  /**
625
626
  * Consumes `n` bytes from the buffered data.
@@ -628,26 +629,26 @@ function rt() {
628
629
  * @return {Buffer} The consumed bytes
629
630
  * @private
630
631
  */
631
- consume(e) {
632
- if (this._bufferedBytes -= e, e === this._buffers[0].length) return this._buffers.shift();
633
- if (e < this._buffers[0].length) {
634
- const i = this._buffers[0];
635
- return this._buffers[0] = new C(
636
- i.buffer,
637
- i.byteOffset + e,
638
- i.length - e
639
- ), new C(i.buffer, i.byteOffset, e);
632
+ consume(t) {
633
+ if (this._bufferedBytes -= t, t === this._buffers[0].length) return this._buffers.shift();
634
+ if (t < this._buffers[0].length) {
635
+ const s = this._buffers[0];
636
+ return this._buffers[0] = new L(
637
+ s.buffer,
638
+ s.byteOffset + t,
639
+ s.length - t
640
+ ), new L(s.buffer, s.byteOffset, t);
640
641
  }
641
- const t = Buffer.allocUnsafe(e);
642
+ const e = Buffer.allocUnsafe(t);
642
643
  do {
643
- const i = this._buffers[0], s = t.length - e;
644
- e >= i.length ? t.set(this._buffers.shift(), s) : (t.set(new Uint8Array(i.buffer, i.byteOffset, e), s), this._buffers[0] = new C(
645
- i.buffer,
646
- i.byteOffset + e,
647
- i.length - e
648
- )), e -= i.length;
649
- } while (e > 0);
650
- return t;
644
+ const s = this._buffers[0], i = e.length - t;
645
+ t >= s.length ? e.set(this._buffers.shift(), i) : (e.set(new Uint8Array(s.buffer, s.byteOffset, t), i), this._buffers[0] = new L(
646
+ s.buffer,
647
+ s.byteOffset + t,
648
+ s.length - t
649
+ )), t -= s.length;
650
+ } while (t > 0);
651
+ return e;
651
652
  }
652
653
  /**
653
654
  * Starts the parsing loop.
@@ -655,32 +656,32 @@ function rt() {
655
656
  * @param {Function} cb Callback
656
657
  * @private
657
658
  */
658
- startLoop(e) {
659
+ startLoop(t) {
659
660
  this._loop = !0;
660
661
  do
661
662
  switch (this._state) {
662
663
  case c:
663
- this.getInfo(e);
664
+ this.getInfo(t);
664
665
  break;
665
- case w:
666
- this.getPayloadLength16(e);
666
+ case b:
667
+ this.getPayloadLength16(t);
667
668
  break;
668
- case k:
669
- this.getPayloadLength64(e);
669
+ case C:
670
+ this.getPayloadLength64(t);
670
671
  break;
671
672
  case v:
672
673
  this.getMask();
673
674
  break;
674
675
  case O:
675
- this.getData(e);
676
+ this.getData(t);
676
677
  break;
677
678
  case p:
678
- case l:
679
+ case f:
679
680
  this._loop = !1;
680
681
  return;
681
682
  }
682
683
  while (this._loop);
683
- this._errored || e();
684
+ this._errored || t();
684
685
  }
685
686
  /**
686
687
  * Reads the first two bytes of a frame.
@@ -688,141 +689,141 @@ function rt() {
688
689
  * @param {Function} cb Callback
689
690
  * @private
690
691
  */
691
- getInfo(e) {
692
+ getInfo(t) {
692
693
  if (this._bufferedBytes < 2) {
693
694
  this._loop = !1;
694
695
  return;
695
696
  }
696
- const t = this.consume(2);
697
- if ((t[0] & 48) !== 0) {
698
- const s = this.createError(
697
+ const e = this.consume(2);
698
+ if ((e[0] & 48) !== 0) {
699
+ const i = this.createError(
699
700
  RangeError,
700
701
  "RSV2 and RSV3 must be clear",
701
702
  !0,
702
703
  1002,
703
704
  "WS_ERR_UNEXPECTED_RSV_2_3"
704
705
  );
705
- e(s);
706
+ t(i);
706
707
  return;
707
708
  }
708
- const i = (t[0] & 64) === 64;
709
- if (i && !this._extensions[T.extensionName]) {
710
- const s = this.createError(
709
+ const s = (e[0] & 64) === 64;
710
+ if (s && !this._extensions[T.extensionName]) {
711
+ const i = this.createError(
711
712
  RangeError,
712
713
  "RSV1 must be clear",
713
714
  !0,
714
715
  1002,
715
716
  "WS_ERR_UNEXPECTED_RSV_1"
716
717
  );
717
- e(s);
718
+ t(i);
718
719
  return;
719
720
  }
720
- if (this._fin = (t[0] & 128) === 128, this._opcode = t[0] & 15, this._payloadLength = t[1] & 127, this._opcode === 0) {
721
- if (i) {
722
- const s = this.createError(
721
+ if (this._fin = (e[0] & 128) === 128, this._opcode = e[0] & 15, this._payloadLength = e[1] & 127, this._opcode === 0) {
722
+ if (s) {
723
+ const i = this.createError(
723
724
  RangeError,
724
725
  "RSV1 must be clear",
725
726
  !0,
726
727
  1002,
727
728
  "WS_ERR_UNEXPECTED_RSV_1"
728
729
  );
729
- e(s);
730
+ t(i);
730
731
  return;
731
732
  }
732
733
  if (!this._fragmented) {
733
- const s = this.createError(
734
+ const i = this.createError(
734
735
  RangeError,
735
736
  "invalid opcode 0",
736
737
  !0,
737
738
  1002,
738
739
  "WS_ERR_INVALID_OPCODE"
739
740
  );
740
- e(s);
741
+ t(i);
741
742
  return;
742
743
  }
743
744
  this._opcode = this._fragmented;
744
745
  } else if (this._opcode === 1 || this._opcode === 2) {
745
746
  if (this._fragmented) {
746
- const s = this.createError(
747
+ const i = this.createError(
747
748
  RangeError,
748
749
  `invalid opcode ${this._opcode}`,
749
750
  !0,
750
751
  1002,
751
752
  "WS_ERR_INVALID_OPCODE"
752
753
  );
753
- e(s);
754
+ t(i);
754
755
  return;
755
756
  }
756
- this._compressed = i;
757
+ this._compressed = s;
757
758
  } else if (this._opcode > 7 && this._opcode < 11) {
758
759
  if (!this._fin) {
759
- const s = this.createError(
760
+ const i = this.createError(
760
761
  RangeError,
761
762
  "FIN must be set",
762
763
  !0,
763
764
  1002,
764
765
  "WS_ERR_EXPECTED_FIN"
765
766
  );
766
- e(s);
767
+ t(i);
767
768
  return;
768
769
  }
769
- if (i) {
770
- const s = this.createError(
770
+ if (s) {
771
+ const i = this.createError(
771
772
  RangeError,
772
773
  "RSV1 must be clear",
773
774
  !0,
774
775
  1002,
775
776
  "WS_ERR_UNEXPECTED_RSV_1"
776
777
  );
777
- e(s);
778
+ t(i);
778
779
  return;
779
780
  }
780
781
  if (this._payloadLength > 125 || this._opcode === 8 && this._payloadLength === 1) {
781
- const s = this.createError(
782
+ const i = this.createError(
782
783
  RangeError,
783
784
  `invalid payload length ${this._payloadLength}`,
784
785
  !0,
785
786
  1002,
786
787
  "WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"
787
788
  );
788
- e(s);
789
+ t(i);
789
790
  return;
790
791
  }
791
792
  } else {
792
- const s = this.createError(
793
+ const i = this.createError(
793
794
  RangeError,
794
795
  `invalid opcode ${this._opcode}`,
795
796
  !0,
796
797
  1002,
797
798
  "WS_ERR_INVALID_OPCODE"
798
799
  );
799
- e(s);
800
+ t(i);
800
801
  return;
801
802
  }
802
- if (!this._fin && !this._fragmented && (this._fragmented = this._opcode), this._masked = (t[1] & 128) === 128, this._isServer) {
803
+ if (!this._fin && !this._fragmented && (this._fragmented = this._opcode), this._masked = (e[1] & 128) === 128, this._isServer) {
803
804
  if (!this._masked) {
804
- const s = this.createError(
805
+ const i = this.createError(
805
806
  RangeError,
806
807
  "MASK must be set",
807
808
  !0,
808
809
  1002,
809
810
  "WS_ERR_EXPECTED_MASK"
810
811
  );
811
- e(s);
812
+ t(i);
812
813
  return;
813
814
  }
814
815
  } else if (this._masked) {
815
- const s = this.createError(
816
+ const i = this.createError(
816
817
  RangeError,
817
818
  "MASK must be clear",
818
819
  !0,
819
820
  1002,
820
821
  "WS_ERR_UNEXPECTED_MASK"
821
822
  );
822
- e(s);
823
+ t(i);
823
824
  return;
824
825
  }
825
- this._payloadLength === 126 ? this._state = w : this._payloadLength === 127 ? this._state = k : this.haveLength(e);
826
+ this._payloadLength === 126 ? this._state = b : this._payloadLength === 127 ? this._state = C : this.haveLength(t);
826
827
  }
827
828
  /**
828
829
  * Gets extended payload length (7+16).
@@ -830,12 +831,12 @@ function rt() {
830
831
  * @param {Function} cb Callback
831
832
  * @private
832
833
  */
833
- getPayloadLength16(e) {
834
+ getPayloadLength16(t) {
834
835
  if (this._bufferedBytes < 2) {
835
836
  this._loop = !1;
836
837
  return;
837
838
  }
838
- this._payloadLength = this.consume(2).readUInt16BE(0), this.haveLength(e);
839
+ this._payloadLength = this.consume(2).readUInt16BE(0), this.haveLength(t);
839
840
  }
840
841
  /**
841
842
  * Gets extended payload length (7+64).
@@ -843,24 +844,24 @@ function rt() {
843
844
  * @param {Function} cb Callback
844
845
  * @private
845
846
  */
846
- getPayloadLength64(e) {
847
+ getPayloadLength64(t) {
847
848
  if (this._bufferedBytes < 8) {
848
849
  this._loop = !1;
849
850
  return;
850
851
  }
851
- const t = this.consume(8), i = t.readUInt32BE(0);
852
- if (i > Math.pow(2, 21) - 1) {
853
- const s = this.createError(
852
+ const e = this.consume(8), s = e.readUInt32BE(0);
853
+ if (s > Math.pow(2, 21) - 1) {
854
+ const i = this.createError(
854
855
  RangeError,
855
856
  "Unsupported WebSocket frame: payload length > 2^53 - 1",
856
857
  !1,
857
858
  1009,
858
859
  "WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH"
859
860
  );
860
- e(s);
861
+ t(i);
861
862
  return;
862
863
  }
863
- this._payloadLength = i * Math.pow(2, 32) + t.readUInt32BE(4), this.haveLength(e);
864
+ this._payloadLength = s * Math.pow(2, 32) + e.readUInt32BE(4), this.haveLength(t);
864
865
  }
865
866
  /**
866
867
  * Payload length has been read.
@@ -868,16 +869,16 @@ function rt() {
868
869
  * @param {Function} cb Callback
869
870
  * @private
870
871
  */
871
- haveLength(e) {
872
+ haveLength(t) {
872
873
  if (this._payloadLength && this._opcode < 8 && (this._totalPayloadLength += this._payloadLength, this._totalPayloadLength > this._maxPayload && this._maxPayload > 0)) {
873
- const t = this.createError(
874
+ const e = this.createError(
874
875
  RangeError,
875
876
  "Max payload size exceeded",
876
877
  !1,
877
878
  1009,
878
879
  "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"
879
880
  );
880
- e(t);
881
+ t(e);
881
882
  return;
882
883
  }
883
884
  this._masked ? this._state = v : this._state = O;
@@ -900,24 +901,24 @@ function rt() {
900
901
  * @param {Function} cb Callback
901
902
  * @private
902
903
  */
903
- getData(e) {
904
- let t = B;
904
+ getData(t) {
905
+ let e = D;
905
906
  if (this._payloadLength) {
906
907
  if (this._bufferedBytes < this._payloadLength) {
907
908
  this._loop = !1;
908
909
  return;
909
910
  }
910
- t = this.consume(this._payloadLength), this._masked && (this._mask[0] | this._mask[1] | this._mask[2] | this._mask[3]) !== 0 && a(t, this._mask);
911
+ e = this.consume(this._payloadLength), this._masked && (this._mask[0] | this._mask[1] | this._mask[2] | this._mask[3]) !== 0 && a(e, this._mask);
911
912
  }
912
913
  if (this._opcode > 7) {
913
- this.controlMessage(t, e);
914
+ this.controlMessage(e, t);
914
915
  return;
915
916
  }
916
917
  if (this._compressed) {
917
- this._state = p, this.decompress(t, e);
918
+ this._state = p, this.decompress(e, t);
918
919
  return;
919
920
  }
920
- t.length && (this._messageLength = this._totalPayloadLength, this._fragments.push(t)), this.dataMessage(e);
921
+ e.length && (this._messageLength = this._totalPayloadLength, this._fragments.push(e)), this.dataMessage(t);
921
922
  }
922
923
  /**
923
924
  * Decompresses data.
@@ -926,24 +927,24 @@ function rt() {
926
927
  * @param {Function} cb Callback
927
928
  * @private
928
929
  */
929
- decompress(e, t) {
930
- this._extensions[T.extensionName].decompress(e, this._fin, (s, m) => {
931
- if (s) return t(s);
930
+ decompress(t, e) {
931
+ this._extensions[T.extensionName].decompress(t, this._fin, (i, m) => {
932
+ if (i) return e(i);
932
933
  if (m.length) {
933
934
  if (this._messageLength += m.length, this._messageLength > this._maxPayload && this._maxPayload > 0) {
934
- const y = this.createError(
935
+ const u = this.createError(
935
936
  RangeError,
936
937
  "Max payload size exceeded",
937
938
  !1,
938
939
  1009,
939
940
  "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"
940
941
  );
941
- t(y);
942
+ e(u);
942
943
  return;
943
944
  }
944
945
  this._fragments.push(m);
945
946
  }
946
- this.dataMessage(t), this._state === c && this.startLoop(t);
947
+ this.dataMessage(e), this._state === c && this.startLoop(e);
947
948
  });
948
949
  }
949
950
  /**
@@ -952,20 +953,20 @@ function rt() {
952
953
  * @param {Function} cb Callback
953
954
  * @private
954
955
  */
955
- dataMessage(e) {
956
+ dataMessage(t) {
956
957
  if (!this._fin) {
957
958
  this._state = c;
958
959
  return;
959
960
  }
960
- const t = this._messageLength, i = this._fragments;
961
+ const e = this._messageLength, s = this._fragments;
961
962
  if (this._totalPayloadLength = 0, this._messageLength = 0, this._fragmented = 0, this._fragments = [], this._opcode === 2) {
962
- let s;
963
- this._binaryType === "nodebuffer" ? s = n(i, t) : this._binaryType === "arraybuffer" ? s = f(n(i, t)) : this._binaryType === "blob" ? s = new Blob(i) : s = i, this._allowSynchronousEvents ? (this.emit("message", s, !0), this._state = c) : (this._state = l, setImmediate(() => {
964
- this.emit("message", s, !0), this._state = c, this.startLoop(e);
963
+ let i;
964
+ this._binaryType === "nodebuffer" ? i = n(s, e) : this._binaryType === "arraybuffer" ? i = l(n(s, e)) : this._binaryType === "blob" ? i = new Blob(s) : i = s, this._allowSynchronousEvents ? (this.emit("message", i, !0), this._state = c) : (this._state = f, setImmediate(() => {
965
+ this.emit("message", i, !0), this._state = c, this.startLoop(t);
965
966
  }));
966
967
  } else {
967
- const s = n(i, t);
968
- if (!this._skipUTF8Validation && !h(s)) {
968
+ const i = n(s, e);
969
+ if (!this._skipUTF8Validation && !h(i)) {
969
970
  const m = this.createError(
970
971
  Error,
971
972
  "invalid UTF-8 sequence",
@@ -973,11 +974,11 @@ function rt() {
973
974
  1007,
974
975
  "WS_ERR_INVALID_UTF8"
975
976
  );
976
- e(m);
977
+ t(m);
977
978
  return;
978
979
  }
979
- this._state === p || this._allowSynchronousEvents ? (this.emit("message", s, !1), this._state = c) : (this._state = l, setImmediate(() => {
980
- this.emit("message", s, !1), this._state = c, this.startLoop(e);
980
+ this._state === p || this._allowSynchronousEvents ? (this.emit("message", i, !1), this._state = c) : (this._state = f, setImmediate(() => {
981
+ this.emit("message", i, !1), this._state = c, this.startLoop(t);
981
982
  }));
982
983
  }
983
984
  }
@@ -988,29 +989,29 @@ function rt() {
988
989
  * @return {(Error|RangeError|undefined)} A possible error
989
990
  * @private
990
991
  */
991
- controlMessage(e, t) {
992
+ controlMessage(t, e) {
992
993
  if (this._opcode === 8) {
993
- if (e.length === 0)
994
- this._loop = !1, this.emit("conclude", 1005, B), this.end();
994
+ if (t.length === 0)
995
+ this._loop = !1, this.emit("conclude", 1005, D), this.end();
995
996
  else {
996
- const i = e.readUInt16BE(0);
997
- if (!_(i)) {
997
+ const s = t.readUInt16BE(0);
998
+ if (!_(s)) {
998
999
  const m = this.createError(
999
1000
  RangeError,
1000
- `invalid status code ${i}`,
1001
+ `invalid status code ${s}`,
1001
1002
  !0,
1002
1003
  1002,
1003
1004
  "WS_ERR_INVALID_CLOSE_CODE"
1004
1005
  );
1005
- t(m);
1006
+ e(m);
1006
1007
  return;
1007
1008
  }
1008
- const s = new C(
1009
- e.buffer,
1010
- e.byteOffset + 2,
1011
- e.length - 2
1009
+ const i = new L(
1010
+ t.buffer,
1011
+ t.byteOffset + 2,
1012
+ t.length - 2
1012
1013
  );
1013
- if (!this._skipUTF8Validation && !h(s)) {
1014
+ if (!this._skipUTF8Validation && !h(i)) {
1014
1015
  const m = this.createError(
1015
1016
  Error,
1016
1017
  "invalid UTF-8 sequence",
@@ -1018,16 +1019,16 @@ function rt() {
1018
1019
  1007,
1019
1020
  "WS_ERR_INVALID_UTF8"
1020
1021
  );
1021
- t(m);
1022
+ e(m);
1022
1023
  return;
1023
1024
  }
1024
- this._loop = !1, this.emit("conclude", i, s), this.end();
1025
+ this._loop = !1, this.emit("conclude", s, i), this.end();
1025
1026
  }
1026
1027
  this._state = c;
1027
1028
  return;
1028
1029
  }
1029
- this._allowSynchronousEvents ? (this.emit(this._opcode === 9 ? "ping" : "pong", e), this._state = c) : (this._state = l, setImmediate(() => {
1030
- this.emit(this._opcode === 9 ? "ping" : "pong", e), this._state = c, this.startLoop(t);
1030
+ this._allowSynchronousEvents ? (this.emit(this._opcode === 9 ? "ping" : "pong", t), this._state = c) : (this._state = f, setImmediate(() => {
1031
+ this.emit(this._opcode === 9 ? "ping" : "pong", t), this._state = c, this.startLoop(e);
1031
1032
  }));
1032
1033
  }
1033
1034
  /**
@@ -1042,12 +1043,12 @@ function rt() {
1042
1043
  * @return {(Error|RangeError)} The error
1043
1044
  * @private
1044
1045
  */
1045
- createError(e, t, i, s, m) {
1046
+ createError(t, e, s, i, m) {
1046
1047
  this._loop = !1, this._errored = !0;
1047
- const y = new e(
1048
- i ? `Invalid WebSocket frame: ${t}` : t
1048
+ const u = new t(
1049
+ s ? `Invalid WebSocket frame: ${e}` : e
1049
1050
  );
1050
- return Error.captureStackTrace(y, this.createError), y.code = m, y[b] = s, y;
1051
+ return Error.captureStackTrace(u, this.createError), u.code = m, u[x] = i, u;
1051
1052
  }
1052
1053
  }
1053
1054
  return ge = E, ge;
@@ -1056,10 +1057,10 @@ var ye, qe;
1056
1057
  function st() {
1057
1058
  if (qe) return ye;
1058
1059
  qe = 1;
1059
- const { Duplex: P } = se, { randomFillSync: T } = Oe, M = ae(), { EMPTY_BUFFER: B, kWebSocket: b, NOOP: d } = j(), { isBlob: n, isValidStatusCode: f } = ie(), { mask: a, toBuffer: _ } = oe(), h = /* @__PURE__ */ Symbol("kByteLength"), C = Buffer.alloc(4), c = 8 * 1024;
1060
- let w, k = c;
1060
+ const { Duplex: P } = se, { randomFillSync: T } = Oe, M = le(), { EMPTY_BUFFER: D, kWebSocket: x, NOOP: d } = q(), { isBlob: n, isValidStatusCode: l } = ie(), { mask: a, toBuffer: _ } = ae(), h = /* @__PURE__ */ Symbol("kByteLength"), L = Buffer.alloc(4), c = 8 * 1024;
1061
+ let b, C = c;
1061
1062
  const v = 0, O = 1, p = 2;
1062
- class l {
1063
+ class f {
1063
1064
  /**
1064
1065
  * Creates a Sender instance.
1065
1066
  *
@@ -1068,8 +1069,8 @@ function st() {
1068
1069
  * @param {Function} [generateMask] The function used to generate the masking
1069
1070
  * key
1070
1071
  */
1071
- constructor(t, i, s) {
1072
- this._extensions = i || {}, s && (this._generateMask = s, this._maskBuffer = Buffer.alloc(4)), this._socket = t, this._firstFragment = !0, this._compress = !1, this._bufferedBytes = 0, this._queue = [], this._state = v, this.onerror = d, this[b] = void 0;
1072
+ constructor(e, s, i) {
1073
+ this._extensions = s || {}, i && (this._generateMask = i, this._maskBuffer = Buffer.alloc(4)), this._socket = e, this._firstFragment = !0, this._compress = !1, this._bufferedBytes = 0, this._queue = [], this._state = v, this.onerror = d, this[x] = void 0;
1073
1074
  }
1074
1075
  /**
1075
1076
  * Frames a piece of data according to the HyBi WebSocket protocol.
@@ -1092,15 +1093,15 @@ function st() {
1092
1093
  * @return {(Buffer|String)[]} The framed data
1093
1094
  * @public
1094
1095
  */
1095
- static frame(t, i) {
1096
- let s, m = !1, y = 2, R = !1;
1097
- i.mask && (s = i.maskBuffer || C, i.generateMask ? i.generateMask(s) : (k === c && (w === void 0 && (w = Buffer.alloc(c)), T(w, 0, c), k = 0), s[0] = w[k++], s[1] = w[k++], s[2] = w[k++], s[3] = w[k++]), R = (s[0] | s[1] | s[2] | s[3]) === 0, y = 6);
1098
- let D;
1099
- typeof t == "string" ? (!i.mask || R) && i[h] !== void 0 ? D = i[h] : (t = Buffer.from(t), D = t.length) : (D = t.length, m = i.mask && i.readOnly && !R);
1100
- let A = D;
1101
- D >= 65536 ? (y += 8, A = 127) : D > 125 && (y += 2, A = 126);
1102
- const N = Buffer.allocUnsafe(m ? D + y : y);
1103
- return N[0] = i.fin ? i.opcode | 128 : i.opcode, i.rsv1 && (N[0] |= 64), N[1] = A, A === 126 ? N.writeUInt16BE(D, 2) : A === 127 && (N[2] = N[3] = 0, N.writeUIntBE(D, 4, 6)), i.mask ? (N[1] |= 128, N[y - 4] = s[0], N[y - 3] = s[1], N[y - 2] = s[2], N[y - 1] = s[3], R ? [N, t] : m ? (a(t, s, N, y, D), [N]) : (a(t, s, t, 0, D), [N, t])) : [N, t];
1096
+ static frame(e, s) {
1097
+ let i, m = !1, u = 2, R = !1;
1098
+ s.mask && (i = s.maskBuffer || L, s.generateMask ? s.generateMask(i) : (C === c && (b === void 0 && (b = Buffer.alloc(c)), T(b, 0, c), C = 0), i[0] = b[C++], i[1] = b[C++], i[2] = b[C++], i[3] = b[C++]), R = (i[0] | i[1] | i[2] | i[3]) === 0, u = 6);
1099
+ let B;
1100
+ typeof e == "string" ? (!s.mask || R) && s[h] !== void 0 ? B = s[h] : (e = Buffer.from(e), B = e.length) : (B = e.length, m = s.mask && s.readOnly && !R);
1101
+ let A = B;
1102
+ B >= 65536 ? (u += 8, A = 127) : B > 125 && (u += 2, A = 126);
1103
+ const N = Buffer.allocUnsafe(m ? B + u : u);
1104
+ return N[0] = s.fin ? s.opcode | 128 : s.opcode, s.rsv1 && (N[0] |= 64), N[1] = A, A === 126 ? N.writeUInt16BE(B, 2) : A === 127 && (N[2] = N[3] = 0, N.writeUIntBE(B, 4, 6)), s.mask ? (N[1] |= 128, N[u - 4] = i[0], N[u - 3] = i[1], N[u - 2] = i[2], N[u - 1] = i[3], R ? [N, e] : m ? (a(e, i, N, u, B), [N]) : (a(e, i, e, 0, B), [N, e])) : [N, e];
1104
1105
  }
1105
1106
  /**
1106
1107
  * Sends a close message to the other peer.
@@ -1111,33 +1112,33 @@ function st() {
1111
1112
  * @param {Function} [cb] Callback
1112
1113
  * @public
1113
1114
  */
1114
- close(t, i, s, m) {
1115
- let y;
1116
- if (t === void 0)
1117
- y = B;
1115
+ close(e, s, i, m) {
1116
+ let u;
1117
+ if (e === void 0)
1118
+ u = D;
1118
1119
  else {
1119
- if (typeof t != "number" || !f(t))
1120
+ if (typeof e != "number" || !l(e))
1120
1121
  throw new TypeError("First argument must be a valid error code number");
1121
- if (i === void 0 || !i.length)
1122
- y = Buffer.allocUnsafe(2), y.writeUInt16BE(t, 0);
1122
+ if (s === void 0 || !s.length)
1123
+ u = Buffer.allocUnsafe(2), u.writeUInt16BE(e, 0);
1123
1124
  else {
1124
- const D = Buffer.byteLength(i);
1125
- if (D > 123)
1125
+ const B = Buffer.byteLength(s);
1126
+ if (B > 123)
1126
1127
  throw new RangeError("The message must not be greater than 123 bytes");
1127
- y = Buffer.allocUnsafe(2 + D), y.writeUInt16BE(t, 0), typeof i == "string" ? y.write(i, 2) : y.set(i, 2);
1128
+ u = Buffer.allocUnsafe(2 + B), u.writeUInt16BE(e, 0), typeof s == "string" ? u.write(s, 2) : u.set(s, 2);
1128
1129
  }
1129
1130
  }
1130
1131
  const R = {
1131
- [h]: y.length,
1132
+ [h]: u.length,
1132
1133
  fin: !0,
1133
1134
  generateMask: this._generateMask,
1134
- mask: s,
1135
+ mask: i,
1135
1136
  maskBuffer: this._maskBuffer,
1136
1137
  opcode: 8,
1137
1138
  readOnly: !1,
1138
1139
  rsv1: !1
1139
1140
  };
1140
- this._state !== v ? this.enqueue([this.dispatch, y, !1, R, m]) : this.sendFrame(l.frame(y, R), m);
1141
+ this._state !== v ? this.enqueue([this.dispatch, u, !1, R, m]) : this.sendFrame(f.frame(u, R), m);
1141
1142
  }
1142
1143
  /**
1143
1144
  * Sends a ping message to the other peer.
@@ -1147,21 +1148,21 @@ function st() {
1147
1148
  * @param {Function} [cb] Callback
1148
1149
  * @public
1149
1150
  */
1150
- ping(t, i, s) {
1151
- let m, y;
1152
- if (typeof t == "string" ? (m = Buffer.byteLength(t), y = !1) : n(t) ? (m = t.size, y = !1) : (t = _(t), m = t.length, y = _.readOnly), m > 125)
1151
+ ping(e, s, i) {
1152
+ let m, u;
1153
+ if (typeof e == "string" ? (m = Buffer.byteLength(e), u = !1) : n(e) ? (m = e.size, u = !1) : (e = _(e), m = e.length, u = _.readOnly), m > 125)
1153
1154
  throw new RangeError("The data size must not be greater than 125 bytes");
1154
1155
  const R = {
1155
1156
  [h]: m,
1156
1157
  fin: !0,
1157
1158
  generateMask: this._generateMask,
1158
- mask: i,
1159
+ mask: s,
1159
1160
  maskBuffer: this._maskBuffer,
1160
1161
  opcode: 9,
1161
- readOnly: y,
1162
+ readOnly: u,
1162
1163
  rsv1: !1
1163
1164
  };
1164
- n(t) ? this._state !== v ? this.enqueue([this.getBlobData, t, !1, R, s]) : this.getBlobData(t, !1, R, s) : this._state !== v ? this.enqueue([this.dispatch, t, !1, R, s]) : this.sendFrame(l.frame(t, R), s);
1165
+ n(e) ? this._state !== v ? this.enqueue([this.getBlobData, e, !1, R, i]) : this.getBlobData(e, !1, R, i) : this._state !== v ? this.enqueue([this.dispatch, e, !1, R, i]) : this.sendFrame(f.frame(e, R), i);
1165
1166
  }
1166
1167
  /**
1167
1168
  * Sends a pong message to the other peer.
@@ -1171,21 +1172,21 @@ function st() {
1171
1172
  * @param {Function} [cb] Callback
1172
1173
  * @public
1173
1174
  */
1174
- pong(t, i, s) {
1175
- let m, y;
1176
- if (typeof t == "string" ? (m = Buffer.byteLength(t), y = !1) : n(t) ? (m = t.size, y = !1) : (t = _(t), m = t.length, y = _.readOnly), m > 125)
1175
+ pong(e, s, i) {
1176
+ let m, u;
1177
+ if (typeof e == "string" ? (m = Buffer.byteLength(e), u = !1) : n(e) ? (m = e.size, u = !1) : (e = _(e), m = e.length, u = _.readOnly), m > 125)
1177
1178
  throw new RangeError("The data size must not be greater than 125 bytes");
1178
1179
  const R = {
1179
1180
  [h]: m,
1180
1181
  fin: !0,
1181
1182
  generateMask: this._generateMask,
1182
- mask: i,
1183
+ mask: s,
1183
1184
  maskBuffer: this._maskBuffer,
1184
1185
  opcode: 10,
1185
- readOnly: y,
1186
+ readOnly: u,
1186
1187
  rsv1: !1
1187
1188
  };
1188
- n(t) ? this._state !== v ? this.enqueue([this.getBlobData, t, !1, R, s]) : this.getBlobData(t, !1, R, s) : this._state !== v ? this.enqueue([this.dispatch, t, !1, R, s]) : this.sendFrame(l.frame(t, R), s);
1189
+ n(e) ? this._state !== v ? this.enqueue([this.getBlobData, e, !1, R, i]) : this.getBlobData(e, !1, R, i) : this._state !== v ? this.enqueue([this.dispatch, e, !1, R, i]) : this.sendFrame(f.frame(e, R), i);
1189
1190
  }
1190
1191
  /**
1191
1192
  * Sends a data message to the other peer.
@@ -1203,21 +1204,21 @@ function st() {
1203
1204
  * @param {Function} [cb] Callback
1204
1205
  * @public
1205
1206
  */
1206
- send(t, i, s) {
1207
+ send(e, s, i) {
1207
1208
  const m = this._extensions[M.extensionName];
1208
- let y = i.binary ? 2 : 1, R = i.compress, D, A;
1209
- typeof t == "string" ? (D = Buffer.byteLength(t), A = !1) : n(t) ? (D = t.size, A = !1) : (t = _(t), D = t.length, A = _.readOnly), this._firstFragment ? (this._firstFragment = !1, R && m && m.params[m._isServer ? "server_no_context_takeover" : "client_no_context_takeover"] && (R = D >= m._threshold), this._compress = R) : (R = !1, y = 0), i.fin && (this._firstFragment = !0);
1209
+ let u = s.binary ? 2 : 1, R = s.compress, B, A;
1210
+ typeof e == "string" ? (B = Buffer.byteLength(e), A = !1) : n(e) ? (B = e.size, A = !1) : (e = _(e), B = e.length, A = _.readOnly), this._firstFragment ? (this._firstFragment = !1, R && m && m.params[m._isServer ? "server_no_context_takeover" : "client_no_context_takeover"] && (R = B >= m._threshold), this._compress = R) : (R = !1, u = 0), s.fin && (this._firstFragment = !0);
1210
1211
  const N = {
1211
- [h]: D,
1212
- fin: i.fin,
1212
+ [h]: B,
1213
+ fin: s.fin,
1213
1214
  generateMask: this._generateMask,
1214
- mask: i.mask,
1215
+ mask: s.mask,
1215
1216
  maskBuffer: this._maskBuffer,
1216
- opcode: y,
1217
+ opcode: u,
1217
1218
  readOnly: A,
1218
1219
  rsv1: R
1219
1220
  };
1220
- n(t) ? this._state !== v ? this.enqueue([this.getBlobData, t, this._compress, N, s]) : this.getBlobData(t, this._compress, N, s) : this._state !== v ? this.enqueue([this.dispatch, t, this._compress, N, s]) : this.dispatch(t, this._compress, N, s);
1221
+ n(e) ? this._state !== v ? this.enqueue([this.getBlobData, e, this._compress, N, i]) : this.getBlobData(e, this._compress, N, i) : this._state !== v ? this.enqueue([this.dispatch, e, this._compress, N, i]) : this.dispatch(e, this._compress, N, i);
1221
1222
  }
1222
1223
  /**
1223
1224
  * Gets the contents of a blob as binary data.
@@ -1242,20 +1243,20 @@ function st() {
1242
1243
  * @param {Function} [cb] Callback
1243
1244
  * @private
1244
1245
  */
1245
- getBlobData(t, i, s, m) {
1246
- this._bufferedBytes += s[h], this._state = p, t.arrayBuffer().then((y) => {
1246
+ getBlobData(e, s, i, m) {
1247
+ this._bufferedBytes += i[h], this._state = p, e.arrayBuffer().then((u) => {
1247
1248
  if (this._socket.destroyed) {
1248
- const D = new Error(
1249
+ const B = new Error(
1249
1250
  "The socket was closed while the blob was being read"
1250
1251
  );
1251
- process.nextTick(E, this, D, m);
1252
+ process.nextTick(E, this, B, m);
1252
1253
  return;
1253
1254
  }
1254
- this._bufferedBytes -= s[h];
1255
- const R = _(y);
1256
- i ? this.dispatch(R, i, s, m) : (this._state = v, this.sendFrame(l.frame(R, s), m), this.dequeue());
1257
- }).catch((y) => {
1258
- process.nextTick(u, this, y, m);
1255
+ this._bufferedBytes -= i[h];
1256
+ const R = _(u);
1257
+ s ? this.dispatch(R, s, i, m) : (this._state = v, this.sendFrame(f.frame(R, i), m), this.dequeue());
1258
+ }).catch((u) => {
1259
+ process.nextTick(w, this, u, m);
1259
1260
  });
1260
1261
  }
1261
1262
  /**
@@ -1281,13 +1282,13 @@ function st() {
1281
1282
  * @param {Function} [cb] Callback
1282
1283
  * @private
1283
1284
  */
1284
- dispatch(t, i, s, m) {
1285
- if (!i) {
1286
- this.sendFrame(l.frame(t, s), m);
1285
+ dispatch(e, s, i, m) {
1286
+ if (!s) {
1287
+ this.sendFrame(f.frame(e, i), m);
1287
1288
  return;
1288
1289
  }
1289
- const y = this._extensions[M.extensionName];
1290
- this._bufferedBytes += s[h], this._state = O, y.compress(t, s.fin, (R, D) => {
1290
+ const u = this._extensions[M.extensionName];
1291
+ this._bufferedBytes += i[h], this._state = O, u.compress(e, i.fin, (R, B) => {
1291
1292
  if (this._socket.destroyed) {
1292
1293
  const A = new Error(
1293
1294
  "The socket was closed while data was being compressed"
@@ -1295,7 +1296,7 @@ function st() {
1295
1296
  E(this, A, m);
1296
1297
  return;
1297
1298
  }
1298
- this._bufferedBytes -= s[h], this._state = v, s.readOnly = !1, this.sendFrame(l.frame(D, s), m), this.dequeue();
1299
+ this._bufferedBytes -= i[h], this._state = v, i.readOnly = !1, this.sendFrame(f.frame(B, i), m), this.dequeue();
1299
1300
  });
1300
1301
  }
1301
1302
  /**
@@ -1305,8 +1306,8 @@ function st() {
1305
1306
  */
1306
1307
  dequeue() {
1307
1308
  for (; this._state === v && this._queue.length; ) {
1308
- const t = this._queue.shift();
1309
- this._bufferedBytes -= t[3][h], Reflect.apply(t[0], this, t.slice(1));
1309
+ const e = this._queue.shift();
1310
+ this._bufferedBytes -= e[3][h], Reflect.apply(e[0], this, e.slice(1));
1310
1311
  }
1311
1312
  }
1312
1313
  /**
@@ -1315,8 +1316,8 @@ function st() {
1315
1316
  * @param {Array} params Send operation parameters.
1316
1317
  * @private
1317
1318
  */
1318
- enqueue(t) {
1319
- this._bufferedBytes += t[3][h], this._queue.push(t);
1319
+ enqueue(e) {
1320
+ this._bufferedBytes += e[3][h], this._queue.push(e);
1320
1321
  }
1321
1322
  /**
1322
1323
  * Sends a frame.
@@ -1325,20 +1326,20 @@ function st() {
1325
1326
  * @param {Function} [cb] Callback
1326
1327
  * @private
1327
1328
  */
1328
- sendFrame(t, i) {
1329
- t.length === 2 ? (this._socket.cork(), this._socket.write(t[0]), this._socket.write(t[1], i), this._socket.uncork()) : this._socket.write(t[0], i);
1329
+ sendFrame(e, s) {
1330
+ e.length === 2 ? (this._socket.cork(), this._socket.write(e[0]), this._socket.write(e[1], s), this._socket.uncork()) : this._socket.write(e[0], s);
1330
1331
  }
1331
1332
  }
1332
- ye = l;
1333
- function E(e, t, i) {
1334
- typeof i == "function" && i(t);
1335
- for (let s = 0; s < e._queue.length; s++) {
1336
- const m = e._queue[s], y = m[m.length - 1];
1337
- typeof y == "function" && y(t);
1333
+ ye = f;
1334
+ function E(t, e, s) {
1335
+ typeof s == "function" && s(e);
1336
+ for (let i = 0; i < t._queue.length; i++) {
1337
+ const m = t._queue[i], u = m[m.length - 1];
1338
+ typeof u == "function" && u(e);
1338
1339
  }
1339
1340
  }
1340
- function u(e, t, i) {
1341
- E(e, t, i), e.onerror(t);
1341
+ function w(t, e, s) {
1342
+ E(t, e, s), t.onerror(e);
1342
1343
  }
1343
1344
  return ye;
1344
1345
  }
@@ -1346,7 +1347,7 @@ var Ee, ze;
1346
1347
  function Ct() {
1347
1348
  if (ze) return Ee;
1348
1349
  ze = 1;
1349
- const { kForOnEventAttribute: P, kListener: T } = j(), M = /* @__PURE__ */ Symbol("kCode"), B = /* @__PURE__ */ Symbol("kData"), b = /* @__PURE__ */ Symbol("kError"), d = /* @__PURE__ */ Symbol("kMessage"), n = /* @__PURE__ */ Symbol("kReason"), f = /* @__PURE__ */ Symbol("kTarget"), a = /* @__PURE__ */ Symbol("kType"), _ = /* @__PURE__ */ Symbol("kWasClean");
1350
+ const { kForOnEventAttribute: P, kListener: T } = q(), M = /* @__PURE__ */ Symbol("kCode"), D = /* @__PURE__ */ Symbol("kData"), x = /* @__PURE__ */ Symbol("kError"), d = /* @__PURE__ */ Symbol("kMessage"), n = /* @__PURE__ */ Symbol("kReason"), l = /* @__PURE__ */ Symbol("kTarget"), a = /* @__PURE__ */ Symbol("kType"), _ = /* @__PURE__ */ Symbol("kWasClean");
1350
1351
  class h {
1351
1352
  /**
1352
1353
  * Create a new `Event`.
@@ -1355,13 +1356,13 @@ function Ct() {
1355
1356
  * @throws {TypeError} If the `type` argument is not specified
1356
1357
  */
1357
1358
  constructor(p) {
1358
- this[f] = null, this[a] = p;
1359
+ this[l] = null, this[a] = p;
1359
1360
  }
1360
1361
  /**
1361
1362
  * @type {*}
1362
1363
  */
1363
1364
  get target() {
1364
- return this[f];
1365
+ return this[l];
1365
1366
  }
1366
1367
  /**
1367
1368
  * @type {String}
@@ -1371,7 +1372,7 @@ function Ct() {
1371
1372
  }
1372
1373
  }
1373
1374
  Object.defineProperty(h.prototype, "target", { enumerable: !0 }), Object.defineProperty(h.prototype, "type", { enumerable: !0 });
1374
- class C extends h {
1375
+ class L extends h {
1375
1376
  /**
1376
1377
  * Create a new `CloseEvent`.
1377
1378
  *
@@ -1385,8 +1386,8 @@ function Ct() {
1385
1386
  * @param {Boolean} [options.wasClean=false] Indicates whether or not the
1386
1387
  * connection was cleanly closed
1387
1388
  */
1388
- constructor(p, l = {}) {
1389
- super(p), this[M] = l.code === void 0 ? 0 : l.code, this[n] = l.reason === void 0 ? "" : l.reason, this[_] = l.wasClean === void 0 ? !1 : l.wasClean;
1389
+ constructor(p, f = {}) {
1390
+ super(p), this[M] = f.code === void 0 ? 0 : f.code, this[n] = f.reason === void 0 ? "" : f.reason, this[_] = f.wasClean === void 0 ? !1 : f.wasClean;
1390
1391
  }
1391
1392
  /**
1392
1393
  * @type {Number}
@@ -1407,7 +1408,7 @@ function Ct() {
1407
1408
  return this[_];
1408
1409
  }
1409
1410
  }
1410
- Object.defineProperty(C.prototype, "code", { enumerable: !0 }), Object.defineProperty(C.prototype, "reason", { enumerable: !0 }), Object.defineProperty(C.prototype, "wasClean", { enumerable: !0 });
1411
+ Object.defineProperty(L.prototype, "code", { enumerable: !0 }), Object.defineProperty(L.prototype, "reason", { enumerable: !0 }), Object.defineProperty(L.prototype, "wasClean", { enumerable: !0 });
1411
1412
  class c extends h {
1412
1413
  /**
1413
1414
  * Create a new `ErrorEvent`.
@@ -1418,14 +1419,14 @@ function Ct() {
1418
1419
  * @param {*} [options.error=null] The error that generated this event
1419
1420
  * @param {String} [options.message=''] The error message
1420
1421
  */
1421
- constructor(p, l = {}) {
1422
- super(p), this[b] = l.error === void 0 ? null : l.error, this[d] = l.message === void 0 ? "" : l.message;
1422
+ constructor(p, f = {}) {
1423
+ super(p), this[x] = f.error === void 0 ? null : f.error, this[d] = f.message === void 0 ? "" : f.message;
1423
1424
  }
1424
1425
  /**
1425
1426
  * @type {*}
1426
1427
  */
1427
1428
  get error() {
1428
- return this[b];
1429
+ return this[x];
1429
1430
  }
1430
1431
  /**
1431
1432
  * @type {String}
@@ -1435,7 +1436,7 @@ function Ct() {
1435
1436
  }
1436
1437
  }
1437
1438
  Object.defineProperty(c.prototype, "error", { enumerable: !0 }), Object.defineProperty(c.prototype, "message", { enumerable: !0 });
1438
- class w extends h {
1439
+ class b extends h {
1439
1440
  /**
1440
1441
  * Create a new `MessageEvent`.
1441
1442
  *
@@ -1444,18 +1445,18 @@ function Ct() {
1444
1445
  * attributes via object members of the same name
1445
1446
  * @param {*} [options.data=null] The message content
1446
1447
  */
1447
- constructor(p, l = {}) {
1448
- super(p), this[B] = l.data === void 0 ? null : l.data;
1448
+ constructor(p, f = {}) {
1449
+ super(p), this[D] = f.data === void 0 ? null : f.data;
1449
1450
  }
1450
1451
  /**
1451
1452
  * @type {*}
1452
1453
  */
1453
1454
  get data() {
1454
- return this[B];
1455
+ return this[D];
1455
1456
  }
1456
1457
  }
1457
- Object.defineProperty(w.prototype, "data", { enumerable: !0 }), Ee = {
1458
- CloseEvent: C,
1458
+ Object.defineProperty(b.prototype, "data", { enumerable: !0 }), Ee = {
1459
+ CloseEvent: L,
1459
1460
  ErrorEvent: c,
1460
1461
  Event: h,
1461
1462
  EventTarget: {
@@ -1471,43 +1472,43 @@ function Ct() {
1471
1472
  * the listener would be automatically removed when invoked.
1472
1473
  * @public
1473
1474
  */
1474
- addEventListener(O, p, l = {}) {
1475
- for (const u of this.listeners(O))
1476
- if (!l[P] && u[T] === p && !u[P])
1475
+ addEventListener(O, p, f = {}) {
1476
+ for (const w of this.listeners(O))
1477
+ if (!f[P] && w[T] === p && !w[P])
1477
1478
  return;
1478
1479
  let E;
1479
1480
  if (O === "message")
1480
- E = function(e, t) {
1481
- const i = new w("message", {
1482
- data: t ? e : e.toString()
1481
+ E = function(t, e) {
1482
+ const s = new b("message", {
1483
+ data: e ? t : t.toString()
1483
1484
  });
1484
- i[f] = this, v(p, this, i);
1485
+ s[l] = this, v(p, this, s);
1485
1486
  };
1486
1487
  else if (O === "close")
1487
- E = function(e, t) {
1488
- const i = new C("close", {
1489
- code: e,
1490
- reason: t.toString(),
1488
+ E = function(t, e) {
1489
+ const s = new L("close", {
1490
+ code: t,
1491
+ reason: e.toString(),
1491
1492
  wasClean: this._closeFrameReceived && this._closeFrameSent
1492
1493
  });
1493
- i[f] = this, v(p, this, i);
1494
+ s[l] = this, v(p, this, s);
1494
1495
  };
1495
1496
  else if (O === "error")
1496
- E = function(e) {
1497
- const t = new c("error", {
1498
- error: e,
1499
- message: e.message
1497
+ E = function(t) {
1498
+ const e = new c("error", {
1499
+ error: t,
1500
+ message: t.message
1500
1501
  });
1501
- t[f] = this, v(p, this, t);
1502
+ e[l] = this, v(p, this, e);
1502
1503
  };
1503
1504
  else if (O === "open")
1504
1505
  E = function() {
1505
- const e = new h("open");
1506
- e[f] = this, v(p, this, e);
1506
+ const t = new h("open");
1507
+ t[l] = this, v(p, this, t);
1507
1508
  };
1508
1509
  else
1509
1510
  return;
1510
- E[P] = !!l[P], E[T] = p, l.once ? this.once(O, E) : this.on(O, E);
1511
+ E[P] = !!f[P], E[T] = p, f.once ? this.once(O, E) : this.on(O, E);
1511
1512
  },
1512
1513
  /**
1513
1514
  * Remove an event listener.
@@ -1517,120 +1518,121 @@ function Ct() {
1517
1518
  * @public
1518
1519
  */
1519
1520
  removeEventListener(O, p) {
1520
- for (const l of this.listeners(O))
1521
- if (l[T] === p && !l[P]) {
1522
- this.removeListener(O, l);
1521
+ for (const f of this.listeners(O))
1522
+ if (f[T] === p && !f[P]) {
1523
+ this.removeListener(O, f);
1523
1524
  break;
1524
1525
  }
1525
1526
  }
1526
1527
  },
1527
- MessageEvent: w
1528
+ MessageEvent: b
1528
1529
  };
1529
- function v(O, p, l) {
1530
- typeof O == "object" && O.handleEvent ? O.handleEvent.call(O, l) : O.call(p, l);
1530
+ function v(O, p, f) {
1531
+ typeof O == "object" && O.handleEvent ? O.handleEvent.call(O, f) : O.call(p, f);
1531
1532
  }
1532
1533
  return Ee;
1533
1534
  }
1534
- var xe, He;
1535
+ var Se, He;
1535
1536
  function it() {
1536
- if (He) return xe;
1537
+ if (He) return Se;
1537
1538
  He = 1;
1538
1539
  const { tokenChars: P } = ie();
1539
- function T(b, d, n) {
1540
- b[d] === void 0 ? b[d] = [n] : b[d].push(n);
1540
+ function T(x, d, n) {
1541
+ x[d] === void 0 ? x[d] = [n] : x[d].push(n);
1541
1542
  }
1542
- function M(b) {
1543
+ function M(x) {
1543
1544
  const d = /* @__PURE__ */ Object.create(null);
1544
- let n = /* @__PURE__ */ Object.create(null), f = !1, a = !1, _ = !1, h, C, c = -1, w = -1, k = -1, v = 0;
1545
- for (; v < b.length; v++)
1546
- if (w = b.charCodeAt(v), h === void 0)
1547
- if (k === -1 && P[w] === 1)
1545
+ let n = /* @__PURE__ */ Object.create(null), l = !1, a = !1, _ = !1, h, L, c = -1, b = -1, C = -1, v = 0;
1546
+ for (; v < x.length; v++)
1547
+ if (b = x.charCodeAt(v), h === void 0)
1548
+ if (C === -1 && P[b] === 1)
1548
1549
  c === -1 && (c = v);
1549
- else if (v !== 0 && (w === 32 || w === 9))
1550
- k === -1 && c !== -1 && (k = v);
1551
- else if (w === 59 || w === 44) {
1550
+ else if (v !== 0 && (b === 32 || b === 9))
1551
+ C === -1 && c !== -1 && (C = v);
1552
+ else if (b === 59 || b === 44) {
1552
1553
  if (c === -1)
1553
1554
  throw new SyntaxError(`Unexpected character at index ${v}`);
1554
- k === -1 && (k = v);
1555
- const p = b.slice(c, k);
1556
- w === 44 ? (T(d, p, n), n = /* @__PURE__ */ Object.create(null)) : h = p, c = k = -1;
1555
+ C === -1 && (C = v);
1556
+ const p = x.slice(c, C);
1557
+ b === 44 ? (T(d, p, n), n = /* @__PURE__ */ Object.create(null)) : h = p, c = C = -1;
1557
1558
  } else
1558
1559
  throw new SyntaxError(`Unexpected character at index ${v}`);
1559
- else if (C === void 0)
1560
- if (k === -1 && P[w] === 1)
1560
+ else if (L === void 0)
1561
+ if (C === -1 && P[b] === 1)
1561
1562
  c === -1 && (c = v);
1562
- else if (w === 32 || w === 9)
1563
- k === -1 && c !== -1 && (k = v);
1564
- else if (w === 59 || w === 44) {
1563
+ else if (b === 32 || b === 9)
1564
+ C === -1 && c !== -1 && (C = v);
1565
+ else if (b === 59 || b === 44) {
1565
1566
  if (c === -1)
1566
1567
  throw new SyntaxError(`Unexpected character at index ${v}`);
1567
- k === -1 && (k = v), T(n, b.slice(c, k), !0), w === 44 && (T(d, h, n), n = /* @__PURE__ */ Object.create(null), h = void 0), c = k = -1;
1568
- } else if (w === 61 && c !== -1 && k === -1)
1569
- C = b.slice(c, v), c = k = -1;
1568
+ C === -1 && (C = v), T(n, x.slice(c, C), !0), b === 44 && (T(d, h, n), n = /* @__PURE__ */ Object.create(null), h = void 0), c = C = -1;
1569
+ } else if (b === 61 && c !== -1 && C === -1)
1570
+ L = x.slice(c, v), c = C = -1;
1570
1571
  else
1571
1572
  throw new SyntaxError(`Unexpected character at index ${v}`);
1572
1573
  else if (a) {
1573
- if (P[w] !== 1)
1574
+ if (P[b] !== 1)
1574
1575
  throw new SyntaxError(`Unexpected character at index ${v}`);
1575
- c === -1 ? c = v : f || (f = !0), a = !1;
1576
+ c === -1 ? c = v : l || (l = !0), a = !1;
1576
1577
  } else if (_)
1577
- if (P[w] === 1)
1578
+ if (P[b] === 1)
1578
1579
  c === -1 && (c = v);
1579
- else if (w === 34 && c !== -1)
1580
- _ = !1, k = v;
1581
- else if (w === 92)
1580
+ else if (b === 34 && c !== -1)
1581
+ _ = !1, C = v;
1582
+ else if (b === 92)
1582
1583
  a = !0;
1583
1584
  else
1584
1585
  throw new SyntaxError(`Unexpected character at index ${v}`);
1585
- else if (w === 34 && b.charCodeAt(v - 1) === 61)
1586
+ else if (b === 34 && x.charCodeAt(v - 1) === 61)
1586
1587
  _ = !0;
1587
- else if (k === -1 && P[w] === 1)
1588
+ else if (C === -1 && P[b] === 1)
1588
1589
  c === -1 && (c = v);
1589
- else if (c !== -1 && (w === 32 || w === 9))
1590
- k === -1 && (k = v);
1591
- else if (w === 59 || w === 44) {
1590
+ else if (c !== -1 && (b === 32 || b === 9))
1591
+ C === -1 && (C = v);
1592
+ else if (b === 59 || b === 44) {
1592
1593
  if (c === -1)
1593
1594
  throw new SyntaxError(`Unexpected character at index ${v}`);
1594
- k === -1 && (k = v);
1595
- let p = b.slice(c, k);
1596
- f && (p = p.replace(/\\/g, ""), f = !1), T(n, C, p), w === 44 && (T(d, h, n), n = /* @__PURE__ */ Object.create(null), h = void 0), C = void 0, c = k = -1;
1595
+ C === -1 && (C = v);
1596
+ let p = x.slice(c, C);
1597
+ l && (p = p.replace(/\\/g, ""), l = !1), T(n, L, p), b === 44 && (T(d, h, n), n = /* @__PURE__ */ Object.create(null), h = void 0), L = void 0, c = C = -1;
1597
1598
  } else
1598
1599
  throw new SyntaxError(`Unexpected character at index ${v}`);
1599
- if (c === -1 || _ || w === 32 || w === 9)
1600
+ if (c === -1 || _ || b === 32 || b === 9)
1600
1601
  throw new SyntaxError("Unexpected end of input");
1601
- k === -1 && (k = v);
1602
- const O = b.slice(c, k);
1603
- return h === void 0 ? T(d, O, n) : (C === void 0 ? T(n, O, !0) : f ? T(n, C, O.replace(/\\/g, "")) : T(n, C, O), T(d, h, n)), d;
1602
+ C === -1 && (C = v);
1603
+ const O = x.slice(c, C);
1604
+ return h === void 0 ? T(d, O, n) : (L === void 0 ? T(n, O, !0) : l ? T(n, L, O.replace(/\\/g, "")) : T(n, L, O), T(d, h, n)), d;
1604
1605
  }
1605
- function B(b) {
1606
- return Object.keys(b).map((d) => {
1607
- let n = b[d];
1608
- return Array.isArray(n) || (n = [n]), n.map((f) => [d].concat(
1609
- Object.keys(f).map((a) => {
1610
- let _ = f[a];
1606
+ function D(x) {
1607
+ return Object.keys(x).map((d) => {
1608
+ let n = x[d];
1609
+ return Array.isArray(n) || (n = [n]), n.map((l) => [d].concat(
1610
+ Object.keys(l).map((a) => {
1611
+ let _ = l[a];
1611
1612
  return Array.isArray(_) || (_ = [_]), _.map((h) => h === !0 ? a : `${a}=${h}`).join("; ");
1612
1613
  })
1613
1614
  ).join("; ")).join(", ");
1614
1615
  }).join(", ");
1615
1616
  }
1616
- return xe = { format: B, parse: M }, xe;
1617
+ return Se = { format: D, parse: M }, Se;
1617
1618
  }
1618
- var Se, Ye;
1619
+ var xe, Ye;
1619
1620
  function Te() {
1620
- if (Ye) return Se;
1621
+ if (Ye) return xe;
1621
1622
  Ye = 1;
1622
- const P = Qe, T = dt, M = Je, B = _t, b = pt, { randomBytes: d, createHash: n } = Oe, { Duplex: f, Readable: a } = se, { URL: _ } = mt, h = ae(), C = rt(), c = st(), { isBlob: w } = ie(), {
1623
- BINARY_TYPES: k,
1624
- EMPTY_BUFFER: v,
1625
- GUID: O,
1626
- kForOnEventAttribute: p,
1627
- kListener: l,
1628
- kStatusCode: E,
1629
- kWebSocket: u,
1623
+ const P = Qe, T = dt, M = Je, D = _t, x = pt, { randomBytes: d, createHash: n } = Oe, { Duplex: l, Readable: a } = se, { URL: _ } = mt, h = le(), L = rt(), c = st(), { isBlob: b } = ie(), {
1624
+ BINARY_TYPES: C,
1625
+ CLOSE_TIMEOUT: v,
1626
+ EMPTY_BUFFER: O,
1627
+ GUID: p,
1628
+ kForOnEventAttribute: f,
1629
+ kListener: E,
1630
+ kStatusCode: w,
1631
+ kWebSocket: t,
1630
1632
  NOOP: e
1631
- } = j(), {
1632
- EventTarget: { addEventListener: t, removeEventListener: i }
1633
- } = Ct(), { format: s, parse: m } = it(), { toBuffer: y } = oe(), R = 30 * 1e3, D = /* @__PURE__ */ Symbol("kAborted"), A = [8, 13], N = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"], V = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;
1633
+ } = q(), {
1634
+ EventTarget: { addEventListener: s, removeEventListener: i }
1635
+ } = Ct(), { format: m, parse: u } = it(), { toBuffer: R } = ae(), B = /* @__PURE__ */ Symbol("kAborted"), A = [8, 13], N = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"], G = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;
1634
1636
  class S extends P {
1635
1637
  /**
1636
1638
  * Create a new `WebSocket`.
@@ -1639,8 +1641,8 @@ function Te() {
1639
1641
  * @param {(String|String[])} [protocols] The subprotocols
1640
1642
  * @param {Object} [options] Connection options
1641
1643
  */
1642
- constructor(o, x, L) {
1643
- super(), this._binaryType = k[0], this._closeCode = 1006, this._closeFrameReceived = !1, this._closeFrameSent = !1, this._closeMessage = v, this._closeTimer = null, this._errorEmitted = !1, this._extensions = {}, this._paused = !1, this._protocol = "", this._readyState = S.CONNECTING, this._receiver = null, this._sender = null, this._socket = null, o !== null ? (this._bufferedAmount = 0, this._isServer = !1, this._redirects = 0, x === void 0 ? x = [] : Array.isArray(x) || (typeof x == "object" && x !== null ? (L = x, x = []) : x = [x]), G(this, o, x, L)) : (this._autoPong = L.autoPong, this._isServer = !0);
1644
+ constructor(o, y, k) {
1645
+ super(), this._binaryType = C[0], this._closeCode = 1006, this._closeFrameReceived = !1, this._closeFrameSent = !1, this._closeMessage = O, this._closeTimer = null, this._errorEmitted = !1, this._extensions = {}, this._paused = !1, this._protocol = "", this._readyState = S.CONNECTING, this._receiver = null, this._sender = null, this._socket = null, o !== null ? (this._bufferedAmount = 0, this._isServer = !1, this._redirects = 0, y === void 0 ? y = [] : Array.isArray(y) || (typeof y == "object" && y !== null ? (k = y, y = []) : y = [y]), F(this, o, y, k)) : (this._autoPong = k.autoPong, this._closeTimeout = k.closeTimeout, this._isServer = !0);
1644
1646
  }
1645
1647
  /**
1646
1648
  * For historical reasons, the custom "nodebuffer" type is used by the default
@@ -1652,7 +1654,7 @@ function Te() {
1652
1654
  return this._binaryType;
1653
1655
  }
1654
1656
  set binaryType(o) {
1655
- k.includes(o) && (this._binaryType = o, this._receiver && (this._receiver._binaryType = o));
1657
+ C.includes(o) && (this._binaryType = o, this._receiver && (this._receiver._binaryType = o));
1656
1658
  }
1657
1659
  /**
1658
1660
  * @type {Number}
@@ -1734,16 +1736,16 @@ function Te() {
1734
1736
  * not to skip UTF-8 validation for text and close messages
1735
1737
  * @private
1736
1738
  */
1737
- setSocket(o, x, L) {
1738
- const g = new C({
1739
- allowSynchronousEvents: L.allowSynchronousEvents,
1739
+ setSocket(o, y, k) {
1740
+ const g = new L({
1741
+ allowSynchronousEvents: k.allowSynchronousEvents,
1740
1742
  binaryType: this.binaryType,
1741
1743
  extensions: this._extensions,
1742
1744
  isServer: this._isServer,
1743
- maxPayload: L.maxPayload,
1744
- skipUTF8Validation: L.skipUTF8Validation
1745
- }), U = new c(o, this._extensions, L.generateMask);
1746
- this._receiver = g, this._sender = U, this._socket = o, g[u] = this, U[u] = this, o[u] = this, g.on("conclude", nt), g.on("drain", ot), g.on("error", at), g.on("message", lt), g.on("ping", ft), g.on("pong", ht), U.onerror = ct, o.setTimeout && o.setTimeout(0), o.setNoDelay && o.setNoDelay(), x.length > 0 && o.unshift(x), o.on("close", Ne), o.on("data", ne), o.on("end", Pe), o.on("error", Re), this._readyState = S.OPEN, this.emit("open");
1745
+ maxPayload: k.maxPayload,
1746
+ skipUTF8Validation: k.skipUTF8Validation
1747
+ }), U = new c(o, this._extensions, k.generateMask);
1748
+ this._receiver = g, this._sender = U, this._socket = o, g[t] = this, U[t] = this, o[t] = this, g.on("conclude", nt), g.on("drain", ot), g.on("error", at), g.on("message", lt), g.on("ping", ft), g.on("pong", ht), U.onerror = ct, o.setTimeout && o.setTimeout(0), o.setNoDelay && o.setNoDelay(), y.length > 0 && o.unshift(y), o.on("close", Ne), o.on("data", oe), o.on("end", Pe), o.on("error", Re), this._readyState = S.OPEN, this.emit("open");
1747
1749
  }
1748
1750
  /**
1749
1751
  * Emit the `'close'` event.
@@ -1777,7 +1779,7 @@ function Te() {
1777
1779
  * closing
1778
1780
  * @public
1779
1781
  */
1780
- close(o, x) {
1782
+ close(o, y) {
1781
1783
  if (this.readyState !== S.CLOSED) {
1782
1784
  if (this.readyState === S.CONNECTING) {
1783
1785
  W(this, this._req, "WebSocket was closed before the connection was established");
@@ -1787,9 +1789,9 @@ function Te() {
1787
1789
  this._closeFrameSent && (this._closeFrameReceived || this._receiver._writableState.errorEmitted) && this._socket.end();
1788
1790
  return;
1789
1791
  }
1790
- this._readyState = S.CLOSING, this._sender.close(o, x, !this._isServer, (L) => {
1791
- L || (this._closeFrameSent = !0, (this._closeFrameReceived || this._receiver._writableState.errorEmitted) && this._socket.end());
1792
- }), Le(this);
1792
+ this._readyState = S.CLOSING, this._sender.close(o, y, !this._isServer, (k) => {
1793
+ k || (this._closeFrameSent = !0, (this._closeFrameReceived || this._receiver._writableState.errorEmitted) && this._socket.end());
1794
+ }), ke(this);
1793
1795
  }
1794
1796
  }
1795
1797
  /**
@@ -1808,14 +1810,14 @@ function Te() {
1808
1810
  * @param {Function} [cb] Callback which is executed when the ping is sent
1809
1811
  * @public
1810
1812
  */
1811
- ping(o, x, L) {
1813
+ ping(o, y, k) {
1812
1814
  if (this.readyState === S.CONNECTING)
1813
1815
  throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
1814
- if (typeof o == "function" ? (L = o, o = x = void 0) : typeof x == "function" && (L = x, x = void 0), typeof o == "number" && (o = o.toString()), this.readyState !== S.OPEN) {
1815
- ce(this, o, L);
1816
+ if (typeof o == "function" ? (k = o, o = y = void 0) : typeof y == "function" && (k = y, y = void 0), typeof o == "number" && (o = o.toString()), this.readyState !== S.OPEN) {
1817
+ ce(this, o, k);
1816
1818
  return;
1817
1819
  }
1818
- x === void 0 && (x = !this._isServer), this._sender.ping(o || v, x, L);
1820
+ y === void 0 && (y = !this._isServer), this._sender.ping(o || O, y, k);
1819
1821
  }
1820
1822
  /**
1821
1823
  * Send a pong.
@@ -1825,14 +1827,14 @@ function Te() {
1825
1827
  * @param {Function} [cb] Callback which is executed when the pong is sent
1826
1828
  * @public
1827
1829
  */
1828
- pong(o, x, L) {
1830
+ pong(o, y, k) {
1829
1831
  if (this.readyState === S.CONNECTING)
1830
1832
  throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
1831
- if (typeof o == "function" ? (L = o, o = x = void 0) : typeof x == "function" && (L = x, x = void 0), typeof o == "number" && (o = o.toString()), this.readyState !== S.OPEN) {
1832
- ce(this, o, L);
1833
+ if (typeof o == "function" ? (k = o, o = y = void 0) : typeof y == "function" && (k = y, y = void 0), typeof o == "number" && (o = o.toString()), this.readyState !== S.OPEN) {
1834
+ ce(this, o, k);
1833
1835
  return;
1834
1836
  }
1835
- x === void 0 && (x = !this._isServer), this._sender.pong(o || v, x, L);
1837
+ y === void 0 && (y = !this._isServer), this._sender.pong(o || O, y, k);
1836
1838
  }
1837
1839
  /**
1838
1840
  * Resume the socket.
@@ -1857,11 +1859,11 @@ function Te() {
1857
1859
  * @param {Function} [cb] Callback which is executed when data is written out
1858
1860
  * @public
1859
1861
  */
1860
- send(o, x, L) {
1862
+ send(o, y, k) {
1861
1863
  if (this.readyState === S.CONNECTING)
1862
1864
  throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
1863
- if (typeof x == "function" && (L = x, x = {}), typeof o == "number" && (o = o.toString()), this.readyState !== S.OPEN) {
1864
- ce(this, o, L);
1865
+ if (typeof y == "function" && (k = y, y = {}), typeof o == "number" && (o = o.toString()), this.readyState !== S.OPEN) {
1866
+ ce(this, o, k);
1865
1867
  return;
1866
1868
  }
1867
1869
  const g = {
@@ -1869,9 +1871,9 @@ function Te() {
1869
1871
  mask: !this._isServer,
1870
1872
  compress: !0,
1871
1873
  fin: !0,
1872
- ...x
1874
+ ...y
1873
1875
  };
1874
- this._extensions[h.extensionName] || (g.compress = !1), this._sender.send(o || v, g, L);
1876
+ this._extensions[h.extensionName] || (g.compress = !1), this._sender.send(o || O, g, k);
1875
1877
  }
1876
1878
  /**
1877
1879
  * Forcibly close the connection.
@@ -1927,32 +1929,33 @@ function Te() {
1927
1929
  enumerable: !0,
1928
1930
  get() {
1929
1931
  for (const o of this.listeners(r))
1930
- if (o[p]) return o[l];
1932
+ if (o[f]) return o[E];
1931
1933
  return null;
1932
1934
  },
1933
1935
  set(o) {
1934
- for (const x of this.listeners(r))
1935
- if (x[p]) {
1936
- this.removeListener(r, x);
1936
+ for (const y of this.listeners(r))
1937
+ if (y[f]) {
1938
+ this.removeListener(r, y);
1937
1939
  break;
1938
1940
  }
1939
1941
  typeof o == "function" && this.addEventListener(r, o, {
1940
- [p]: !0
1942
+ [f]: !0
1941
1943
  });
1942
1944
  }
1943
1945
  });
1944
- }), S.prototype.addEventListener = t, S.prototype.removeEventListener = i, Se = S;
1945
- function G(r, o, x, L) {
1946
+ }), S.prototype.addEventListener = s, S.prototype.removeEventListener = i, xe = S;
1947
+ function F(r, o, y, k) {
1946
1948
  const g = {
1947
1949
  allowSynchronousEvents: !0,
1948
1950
  autoPong: !0,
1951
+ closeTimeout: v,
1949
1952
  protocolVersion: A[1],
1950
1953
  maxPayload: 104857600,
1951
1954
  skipUTF8Validation: !1,
1952
1955
  perMessageDeflate: !0,
1953
1956
  followRedirects: !1,
1954
1957
  maxRedirects: 10,
1955
- ...L,
1958
+ ...k,
1956
1959
  socketPath: void 0,
1957
1960
  hostname: void 0,
1958
1961
  protocol: void 0,
@@ -1962,7 +1965,7 @@ function Te() {
1962
1965
  path: void 0,
1963
1966
  port: void 0
1964
1967
  };
1965
- if (r._autoPong = g.autoPong, !A.includes(g.protocolVersion))
1968
+ if (r._autoPong = g.autoPong, r._closeTimeout = g.closeTimeout, !A.includes(g.protocolVersion))
1966
1969
  throw new RangeError(
1967
1970
  `Unsupported protocol version: ${g.protocolVersion} (supported versions: ${A.join(", ")})`
1968
1971
  );
@@ -1982,12 +1985,12 @@ function Te() {
1982
1985
  const I = new SyntaxError(X);
1983
1986
  if (r._redirects === 0)
1984
1987
  throw I;
1985
- q(r, I);
1988
+ j(r, I);
1986
1989
  return;
1987
1990
  }
1988
1991
  const Be = z ? 443 : 80, De = d(16).toString("base64"), Ie = z ? T.request : M.request, Z = /* @__PURE__ */ new Set();
1989
1992
  let Q;
1990
- if (g.createConnection = g.createConnection || (z ? he : fe), g.defaultPort = g.defaultPort || Be, g.port = U.port || Be, g.host = U.hostname.startsWith("[") ? U.hostname.slice(1, -1) : U.hostname, g.headers = {
1993
+ if (g.createConnection = g.createConnection || (z ? he : ne), g.defaultPort = g.defaultPort || Be, g.port = U.port || Be, g.host = U.hostname.startsWith("[") ? U.hostname.slice(1, -1) : U.hostname, g.headers = {
1991
1994
  ...g.headers,
1992
1995
  "Sec-WebSocket-Version": g.protocolVersion,
1993
1996
  "Sec-WebSocket-Key": De,
@@ -1997,17 +2000,17 @@ function Te() {
1997
2000
  g.perMessageDeflate !== !0 ? g.perMessageDeflate : {},
1998
2001
  !1,
1999
2002
  g.maxPayload
2000
- ), g.headers["Sec-WebSocket-Extensions"] = s({
2003
+ ), g.headers["Sec-WebSocket-Extensions"] = m({
2001
2004
  [h.extensionName]: Q.offer()
2002
- })), x.length) {
2003
- for (const I of x) {
2004
- if (typeof I != "string" || !V.test(I) || Z.has(I))
2005
+ })), y.length) {
2006
+ for (const I of y) {
2007
+ if (typeof I != "string" || !G.test(I) || Z.has(I))
2005
2008
  throw new SyntaxError(
2006
2009
  "An invalid or duplicated subprotocol was specified"
2007
2010
  );
2008
2011
  Z.add(I);
2009
2012
  }
2010
- g.headers["Sec-WebSocket-Protocol"] = x.join(",");
2013
+ g.headers["Sec-WebSocket-Protocol"] = y.join(",");
2011
2014
  }
2012
2015
  if (g.origin && (g.protocolVersion < 13 ? g.headers["Sec-WebSocket-Origin"] = g.origin : g.headers.Origin = g.origin), (U.username || U.password) && (g.auth = `${U.username}:${U.password}`), H) {
2013
2016
  const I = g.path.split(":");
@@ -2017,24 +2020,24 @@ function Te() {
2017
2020
  if (g.followRedirects) {
2018
2021
  if (r._redirects === 0) {
2019
2022
  r._originalIpc = H, r._originalSecure = z, r._originalHostOrSocketPath = H ? g.socketPath : U.host;
2020
- const I = L && L.headers;
2021
- if (L = { ...L, headers: {} }, I)
2022
- for (const [F, Y] of Object.entries(I))
2023
- L.headers[F.toLowerCase()] = Y;
2023
+ const I = k && k.headers;
2024
+ if (k = { ...k, headers: {} }, I)
2025
+ for (const [V, Y] of Object.entries(I))
2026
+ k.headers[V.toLowerCase()] = Y;
2024
2027
  } else if (r.listenerCount("redirect") === 0) {
2025
2028
  const I = H ? r._originalIpc ? g.socketPath === r._originalHostOrSocketPath : !1 : r._originalIpc ? !1 : U.host === r._originalHostOrSocketPath;
2026
2029
  (!I || r._originalSecure && !z) && (delete g.headers.authorization, delete g.headers.cookie, I || delete g.headers.host, g.auth = void 0);
2027
2030
  }
2028
- g.auth && !L.headers.authorization && (L.headers.authorization = "Basic " + Buffer.from(g.auth).toString("base64")), $ = r._req = Ie(g), r._redirects && r.emit("redirect", r.url, $);
2031
+ g.auth && !k.headers.authorization && (k.headers.authorization = "Basic " + Buffer.from(g.auth).toString("base64")), $ = r._req = Ie(g), r._redirects && r.emit("redirect", r.url, $);
2029
2032
  } else
2030
2033
  $ = r._req = Ie(g);
2031
2034
  g.timeout && $.on("timeout", () => {
2032
2035
  W(r, $, "Opening handshake has timed out");
2033
2036
  }), $.on("error", (I) => {
2034
- $ === null || $[D] || ($ = r._req = null, q(r, I));
2037
+ $ === null || $[B] || ($ = r._req = null, j(r, I));
2035
2038
  }), $.on("response", (I) => {
2036
- const F = I.headers.location, Y = I.statusCode;
2037
- if (F && g.followRedirects && Y >= 300 && Y < 400) {
2039
+ const V = I.headers.location, Y = I.statusCode;
2040
+ if (V && g.followRedirects && Y >= 300 && Y < 400) {
2038
2041
  if (++r._redirects > g.maxRedirects) {
2039
2042
  W(r, $, "Maximum redirects exceeded");
2040
2043
  return;
@@ -2042,65 +2045,65 @@ function Te() {
2042
2045
  $.abort();
2043
2046
  let J;
2044
2047
  try {
2045
- J = new _(F, o);
2048
+ J = new _(V, o);
2046
2049
  } catch {
2047
- const K = new SyntaxError(`Invalid URL: ${F}`);
2048
- q(r, K);
2050
+ const K = new SyntaxError(`Invalid URL: ${V}`);
2051
+ j(r, K);
2049
2052
  return;
2050
2053
  }
2051
- G(r, J, x, L);
2054
+ F(r, J, y, k);
2052
2055
  } else r.emit("unexpected-response", $, I) || W(
2053
2056
  r,
2054
2057
  $,
2055
2058
  `Unexpected server response: ${I.statusCode}`
2056
2059
  );
2057
- }), $.on("upgrade", (I, F, Y) => {
2060
+ }), $.on("upgrade", (I, V, Y) => {
2058
2061
  if (r.emit("upgrade", I), r.readyState !== S.CONNECTING) return;
2059
2062
  $ = r._req = null;
2060
2063
  const J = I.headers.upgrade;
2061
2064
  if (J === void 0 || J.toLowerCase() !== "websocket") {
2062
- W(r, F, "Invalid Upgrade header");
2065
+ W(r, V, "Invalid Upgrade header");
2063
2066
  return;
2064
2067
  }
2065
- const Ue = n("sha1").update(De + O).digest("base64");
2068
+ const Ue = n("sha1").update(De + p).digest("base64");
2066
2069
  if (I.headers["sec-websocket-accept"] !== Ue) {
2067
- W(r, F, "Invalid Sec-WebSocket-Accept header");
2070
+ W(r, V, "Invalid Sec-WebSocket-Accept header");
2068
2071
  return;
2069
2072
  }
2070
2073
  const K = I.headers["sec-websocket-protocol"];
2071
2074
  let ee;
2072
2075
  if (K !== void 0 ? Z.size ? Z.has(K) || (ee = "Server sent an invalid subprotocol") : ee = "Server sent a subprotocol but none was requested" : Z.size && (ee = "Server sent no subprotocol"), ee) {
2073
- W(r, F, ee);
2076
+ W(r, V, ee);
2074
2077
  return;
2075
2078
  }
2076
2079
  K && (r._protocol = K);
2077
2080
  const Me = I.headers["sec-websocket-extensions"];
2078
2081
  if (Me !== void 0) {
2079
2082
  if (!Q) {
2080
- W(r, F, "Server sent a Sec-WebSocket-Extensions header but no extension was requested");
2083
+ W(r, V, "Server sent a Sec-WebSocket-Extensions header but no extension was requested");
2081
2084
  return;
2082
2085
  }
2083
2086
  let ue;
2084
2087
  try {
2085
- ue = m(Me);
2088
+ ue = u(Me);
2086
2089
  } catch {
2087
- W(r, F, "Invalid Sec-WebSocket-Extensions header");
2090
+ W(r, V, "Invalid Sec-WebSocket-Extensions header");
2088
2091
  return;
2089
2092
  }
2090
2093
  const Ae = Object.keys(ue);
2091
2094
  if (Ae.length !== 1 || Ae[0] !== h.extensionName) {
2092
- W(r, F, "Server indicated an extension that was not requested");
2095
+ W(r, V, "Server indicated an extension that was not requested");
2093
2096
  return;
2094
2097
  }
2095
2098
  try {
2096
2099
  Q.accept(ue[h.extensionName]);
2097
2100
  } catch {
2098
- W(r, F, "Invalid Sec-WebSocket-Extensions header");
2101
+ W(r, V, "Invalid Sec-WebSocket-Extensions header");
2099
2102
  return;
2100
2103
  }
2101
2104
  r._extensions[h.extensionName] = Q;
2102
2105
  }
2103
- r.setSocket(F, Y, {
2106
+ r.setSocket(V, Y, {
2104
2107
  allowSynchronousEvents: g.allowSynchronousEvents,
2105
2108
  generateMask: g.generateMask,
2106
2109
  maxPayload: g.maxPayload,
@@ -2108,91 +2111,93 @@ function Te() {
2108
2111
  });
2109
2112
  }), g.finishRequest ? g.finishRequest($, r) : $.end();
2110
2113
  }
2111
- function q(r, o) {
2114
+ function j(r, o) {
2112
2115
  r._readyState = S.CLOSING, r._errorEmitted = !0, r.emit("error", o), r.emitClose();
2113
2116
  }
2114
- function fe(r) {
2115
- return r.path = r.socketPath, B.connect(r);
2117
+ function ne(r) {
2118
+ return r.path = r.socketPath, D.connect(r);
2116
2119
  }
2117
2120
  function he(r) {
2118
- return r.path = void 0, !r.servername && r.servername !== "" && (r.servername = B.isIP(r.host) ? "" : r.host), b.connect(r);
2121
+ return r.path = void 0, !r.servername && r.servername !== "" && (r.servername = D.isIP(r.host) ? "" : r.host), x.connect(r);
2119
2122
  }
2120
- function W(r, o, x) {
2123
+ function W(r, o, y) {
2121
2124
  r._readyState = S.CLOSING;
2122
- const L = new Error(x);
2123
- Error.captureStackTrace(L, W), o.setHeader ? (o[D] = !0, o.abort(), o.socket && !o.socket.destroyed && o.socket.destroy(), process.nextTick(q, r, L)) : (o.destroy(L), o.once("error", r.emit.bind(r, "error")), o.once("close", r.emitClose.bind(r)));
2125
+ const k = new Error(y);
2126
+ Error.captureStackTrace(k, W), o.setHeader ? (o[B] = !0, o.abort(), o.socket && !o.socket.destroyed && o.socket.destroy(), process.nextTick(j, r, k)) : (o.destroy(k), o.once("error", r.emit.bind(r, "error")), o.once("close", r.emitClose.bind(r)));
2124
2127
  }
2125
- function ce(r, o, x) {
2128
+ function ce(r, o, y) {
2126
2129
  if (o) {
2127
- const L = w(o) ? o.size : y(o).length;
2128
- r._socket ? r._sender._bufferedBytes += L : r._bufferedAmount += L;
2130
+ const k = b(o) ? o.size : R(o).length;
2131
+ r._socket ? r._sender._bufferedBytes += k : r._bufferedAmount += k;
2129
2132
  }
2130
- if (x) {
2131
- const L = new Error(
2133
+ if (y) {
2134
+ const k = new Error(
2132
2135
  `WebSocket is not open: readyState ${r.readyState} (${N[r.readyState]})`
2133
2136
  );
2134
- process.nextTick(x, L);
2137
+ process.nextTick(y, k);
2135
2138
  }
2136
2139
  }
2137
2140
  function nt(r, o) {
2138
- const x = this[u];
2139
- x._closeFrameReceived = !0, x._closeMessage = o, x._closeCode = r, x._socket[u] !== void 0 && (x._socket.removeListener("data", ne), process.nextTick(ke, x._socket), r === 1005 ? x.close() : x.close(r, o));
2141
+ const y = this[t];
2142
+ y._closeFrameReceived = !0, y._closeMessage = o, y._closeCode = r, y._socket[t] !== void 0 && (y._socket.removeListener("data", oe), process.nextTick(Le, y._socket), r === 1005 ? y.close() : y.close(r, o));
2140
2143
  }
2141
2144
  function ot() {
2142
- const r = this[u];
2145
+ const r = this[t];
2143
2146
  r.isPaused || r._socket.resume();
2144
2147
  }
2145
2148
  function at(r) {
2146
- const o = this[u];
2147
- o._socket[u] !== void 0 && (o._socket.removeListener("data", ne), process.nextTick(ke, o._socket), o.close(r[E])), o._errorEmitted || (o._errorEmitted = !0, o.emit("error", r));
2149
+ const o = this[t];
2150
+ o._socket[t] !== void 0 && (o._socket.removeListener("data", oe), process.nextTick(Le, o._socket), o.close(r[w])), o._errorEmitted || (o._errorEmitted = !0, o.emit("error", r));
2148
2151
  }
2149
2152
  function Ce() {
2150
- this[u].emitClose();
2153
+ this[t].emitClose();
2151
2154
  }
2152
2155
  function lt(r, o) {
2153
- this[u].emit("message", r, o);
2156
+ this[t].emit("message", r, o);
2154
2157
  }
2155
2158
  function ft(r) {
2156
- const o = this[u];
2159
+ const o = this[t];
2157
2160
  o._autoPong && o.pong(r, !this._isServer, e), o.emit("ping", r);
2158
2161
  }
2159
2162
  function ht(r) {
2160
- this[u].emit("pong", r);
2163
+ this[t].emit("pong", r);
2161
2164
  }
2162
- function ke(r) {
2165
+ function Le(r) {
2163
2166
  r.resume();
2164
2167
  }
2165
2168
  function ct(r) {
2166
- const o = this[u];
2167
- o.readyState !== S.CLOSED && (o.readyState === S.OPEN && (o._readyState = S.CLOSING, Le(o)), this._socket.end(), o._errorEmitted || (o._errorEmitted = !0, o.emit("error", r)));
2169
+ const o = this[t];
2170
+ o.readyState !== S.CLOSED && (o.readyState === S.OPEN && (o._readyState = S.CLOSING, ke(o)), this._socket.end(), o._errorEmitted || (o._errorEmitted = !0, o.emit("error", r)));
2168
2171
  }
2169
- function Le(r) {
2172
+ function ke(r) {
2170
2173
  r._closeTimer = setTimeout(
2171
2174
  r._socket.destroy.bind(r._socket),
2172
- R
2175
+ r._closeTimeout
2173
2176
  );
2174
2177
  }
2175
2178
  function Ne() {
2176
- const r = this[u];
2177
- this.removeListener("close", Ne), this.removeListener("data", ne), this.removeListener("end", Pe), r._readyState = S.CLOSING;
2178
- let o;
2179
- !this._readableState.endEmitted && !r._closeFrameReceived && !r._receiver._writableState.errorEmitted && (o = r._socket.read()) !== null && r._receiver.write(o), r._receiver.end(), this[u] = void 0, clearTimeout(r._closeTimer), r._receiver._writableState.finished || r._receiver._writableState.errorEmitted ? r.emitClose() : (r._receiver.on("error", Ce), r._receiver.on("finish", Ce));
2179
+ const r = this[t];
2180
+ if (this.removeListener("close", Ne), this.removeListener("data", oe), this.removeListener("end", Pe), r._readyState = S.CLOSING, !this._readableState.endEmitted && !r._closeFrameReceived && !r._receiver._writableState.errorEmitted && this._readableState.length !== 0) {
2181
+ const o = this.read(this._readableState.length);
2182
+ r._receiver.write(o);
2183
+ }
2184
+ r._receiver.end(), this[t] = void 0, clearTimeout(r._closeTimer), r._receiver._writableState.finished || r._receiver._writableState.errorEmitted ? r.emitClose() : (r._receiver.on("error", Ce), r._receiver.on("finish", Ce));
2180
2185
  }
2181
- function ne(r) {
2182
- this[u]._receiver.write(r) || this.pause();
2186
+ function oe(r) {
2187
+ this[t]._receiver.write(r) || this.pause();
2183
2188
  }
2184
2189
  function Pe() {
2185
- const r = this[u];
2190
+ const r = this[t];
2186
2191
  r._readyState = S.CLOSING, r._receiver.end(), this.end();
2187
2192
  }
2188
2193
  function Re() {
2189
- const r = this[u];
2194
+ const r = this[t];
2190
2195
  this.removeListener("error", Re), this.on("error", e), r && (r._readyState = S.CLOSING, this.destroy());
2191
2196
  }
2192
- return Se;
2197
+ return xe;
2193
2198
  }
2194
2199
  var ve, Ke;
2195
- function kt() {
2200
+ function Lt() {
2196
2201
  if (Ke) return ve;
2197
2202
  Ke = 1, Te();
2198
2203
  const { Duplex: P } = se;
@@ -2202,11 +2207,11 @@ function kt() {
2202
2207
  function M() {
2203
2208
  !this.destroyed && this._writableState.finished && this.destroy();
2204
2209
  }
2205
- function B(d) {
2206
- this.removeListener("error", B), this.destroy(), this.listenerCount("error") === 0 && this.emit("error", d);
2210
+ function D(d) {
2211
+ this.removeListener("error", D), this.destroy(), this.listenerCount("error") === 0 && this.emit("error", d);
2207
2212
  }
2208
- function b(d, n) {
2209
- let f = !0;
2213
+ function x(d, n) {
2214
+ let l = !0;
2210
2215
  const a = new P({
2211
2216
  ...n,
2212
2217
  autoDestroy: !1,
@@ -2214,11 +2219,11 @@ function kt() {
2214
2219
  objectMode: !1,
2215
2220
  writableObjectMode: !1
2216
2221
  });
2217
- return d.on("message", function(h, C) {
2218
- const c = !C && a._readableState.objectMode ? h.toString() : h;
2222
+ return d.on("message", function(h, L) {
2223
+ const c = !L && a._readableState.objectMode ? h.toString() : h;
2219
2224
  a.push(c) || d.pause();
2220
2225
  }), d.once("error", function(h) {
2221
- a.destroyed || (f = !1, a.destroy(h));
2226
+ a.destroyed || (l = !1, a.destroy(h));
2222
2227
  }), d.once("close", function() {
2223
2228
  a.destroyed || a.push(null);
2224
2229
  }), a._destroy = function(_, h) {
@@ -2226,12 +2231,12 @@ function kt() {
2226
2231
  h(_), process.nextTick(T, a);
2227
2232
  return;
2228
2233
  }
2229
- let C = !1;
2230
- d.once("error", function(w) {
2231
- C = !0, h(w);
2234
+ let L = !1;
2235
+ d.once("error", function(b) {
2236
+ L = !0, h(b);
2232
2237
  }), d.once("close", function() {
2233
- C || h(_), process.nextTick(T, a);
2234
- }), f && d.terminate();
2238
+ L || h(_), process.nextTick(T, a);
2239
+ }), l && d.terminate();
2235
2240
  }, a._final = function(_) {
2236
2241
  if (d.readyState === d.CONNECTING) {
2237
2242
  d.once("open", function() {
@@ -2244,54 +2249,54 @@ function kt() {
2244
2249
  }), d.close()));
2245
2250
  }, a._read = function() {
2246
2251
  d.isPaused && d.resume();
2247
- }, a._write = function(_, h, C) {
2252
+ }, a._write = function(_, h, L) {
2248
2253
  if (d.readyState === d.CONNECTING) {
2249
2254
  d.once("open", function() {
2250
- a._write(_, h, C);
2255
+ a._write(_, h, L);
2251
2256
  });
2252
2257
  return;
2253
2258
  }
2254
- d.send(_, C);
2255
- }, a.on("end", M), a.on("error", B), a;
2259
+ d.send(_, L);
2260
+ }, a.on("end", M), a.on("error", D), a;
2256
2261
  }
2257
- return ve = b, ve;
2262
+ return ve = x, ve;
2258
2263
  }
2259
- kt();
2264
+ Lt();
2260
2265
  rt();
2261
2266
  st();
2262
- var Lt = Te();
2263
- const Nt = /* @__PURE__ */ yt(Lt);
2267
+ var kt = Te();
2268
+ const Nt = /* @__PURE__ */ yt(kt);
2264
2269
  var be, Xe;
2265
2270
  function Pt() {
2266
2271
  if (Xe) return be;
2267
2272
  Xe = 1;
2268
2273
  const { tokenChars: P } = ie();
2269
2274
  function T(M) {
2270
- const B = /* @__PURE__ */ new Set();
2271
- let b = -1, d = -1, n = 0;
2275
+ const D = /* @__PURE__ */ new Set();
2276
+ let x = -1, d = -1, n = 0;
2272
2277
  for (n; n < M.length; n++) {
2273
2278
  const a = M.charCodeAt(n);
2274
2279
  if (d === -1 && P[a] === 1)
2275
- b === -1 && (b = n);
2280
+ x === -1 && (x = n);
2276
2281
  else if (n !== 0 && (a === 32 || a === 9))
2277
- d === -1 && b !== -1 && (d = n);
2282
+ d === -1 && x !== -1 && (d = n);
2278
2283
  else if (a === 44) {
2279
- if (b === -1)
2284
+ if (x === -1)
2280
2285
  throw new SyntaxError(`Unexpected character at index ${n}`);
2281
2286
  d === -1 && (d = n);
2282
- const _ = M.slice(b, d);
2283
- if (B.has(_))
2287
+ const _ = M.slice(x, d);
2288
+ if (D.has(_))
2284
2289
  throw new SyntaxError(`The "${_}" subprotocol is duplicated`);
2285
- B.add(_), b = d = -1;
2290
+ D.add(_), x = d = -1;
2286
2291
  } else
2287
2292
  throw new SyntaxError(`Unexpected character at index ${n}`);
2288
2293
  }
2289
- if (b === -1 || d !== -1)
2294
+ if (x === -1 || d !== -1)
2290
2295
  throw new SyntaxError("Unexpected end of input");
2291
- const f = M.slice(b, n);
2292
- if (B.has(f))
2293
- throw new SyntaxError(`The "${f}" subprotocol is duplicated`);
2294
- return B.add(f), B;
2296
+ const l = M.slice(x, n);
2297
+ if (D.has(l))
2298
+ throw new SyntaxError(`The "${l}" subprotocol is duplicated`);
2299
+ return D.add(l), D;
2295
2300
  }
2296
2301
  return be = { parse: T }, be;
2297
2302
  }
@@ -2299,8 +2304,8 @@ var we, Ze;
2299
2304
  function Rt() {
2300
2305
  if (Ze) return we;
2301
2306
  Ze = 1;
2302
- const P = Qe, T = Je, { Duplex: M } = se, { createHash: B } = Oe, b = it(), d = ae(), n = Pt(), f = Te(), { GUID: a, kWebSocket: _ } = j(), h = /^[+/0-9A-Za-z]{22}==$/, C = 0, c = 1, w = 2;
2303
- class k extends P {
2307
+ const P = Qe, T = Je, { Duplex: M } = se, { createHash: D } = Oe, x = it(), d = le(), n = Pt(), l = Te(), { CLOSE_TIMEOUT: a, GUID: _, kWebSocket: h } = q(), L = /^[+/0-9A-Za-z]{22}==$/, c = 0, b = 1, C = 2;
2308
+ class v extends P {
2304
2309
  /**
2305
2310
  * Create a `WebSocketServer` instance.
2306
2311
  *
@@ -2314,6 +2319,9 @@ function Rt() {
2314
2319
  * pending connections
2315
2320
  * @param {Boolean} [options.clientTracking=true] Specifies whether or not to
2316
2321
  * track clients
2322
+ * @param {Number} [options.closeTimeout=30000] Duration in milliseconds to
2323
+ * wait for the closing handshake to finish after `websocket.close()` is
2324
+ * called
2317
2325
  * @param {Function} [options.handleProtocols] A hook to handle protocols
2318
2326
  * @param {String} [options.host] The hostname where to bind the server
2319
2327
  * @param {Number} [options.maxPayload=104857600] The maximum allowed message
@@ -2332,7 +2340,7 @@ function Rt() {
2332
2340
  * class to use. It must be the `WebSocket` class or class that extends it
2333
2341
  * @param {Function} [callback] A listener for the `listening` event
2334
2342
  */
2335
- constructor(e, t) {
2343
+ constructor(e, s) {
2336
2344
  if (super(), e = {
2337
2345
  allowSynchronousEvents: !0,
2338
2346
  autoPong: !0,
@@ -2341,6 +2349,7 @@ function Rt() {
2341
2349
  perMessageDeflate: !1,
2342
2350
  handleProtocols: null,
2343
2351
  clientTracking: !0,
2352
+ closeTimeout: a,
2344
2353
  verifyClient: null,
2345
2354
  noServer: !1,
2346
2355
  backlog: null,
@@ -2349,34 +2358,34 @@ function Rt() {
2349
2358
  host: null,
2350
2359
  path: null,
2351
2360
  port: null,
2352
- WebSocket: f,
2361
+ WebSocket: l,
2353
2362
  ...e
2354
2363
  }, e.port == null && !e.server && !e.noServer || e.port != null && (e.server || e.noServer) || e.server && e.noServer)
2355
2364
  throw new TypeError(
2356
2365
  'One and only one of the "port", "server", or "noServer" options must be specified'
2357
2366
  );
2358
- if (e.port != null ? (this._server = T.createServer((i, s) => {
2359
- const m = T.STATUS_CODES[426];
2360
- s.writeHead(426, {
2361
- "Content-Length": m.length,
2367
+ if (e.port != null ? (this._server = T.createServer((i, m) => {
2368
+ const u = T.STATUS_CODES[426];
2369
+ m.writeHead(426, {
2370
+ "Content-Length": u.length,
2362
2371
  "Content-Type": "text/plain"
2363
- }), s.end(m);
2372
+ }), m.end(u);
2364
2373
  }), this._server.listen(
2365
2374
  e.port,
2366
2375
  e.host,
2367
2376
  e.backlog,
2368
- t
2377
+ s
2369
2378
  )) : e.server && (this._server = e.server), this._server) {
2370
2379
  const i = this.emit.bind(this, "connection");
2371
- this._removeListeners = v(this._server, {
2380
+ this._removeListeners = O(this._server, {
2372
2381
  listening: this.emit.bind(this, "listening"),
2373
2382
  error: this.emit.bind(this, "error"),
2374
- upgrade: (s, m, y) => {
2375
- this.handleUpgrade(s, m, y, i);
2383
+ upgrade: (m, u, R) => {
2384
+ this.handleUpgrade(m, u, R, i);
2376
2385
  }
2377
2386
  });
2378
2387
  }
2379
- e.perMessageDeflate === !0 && (e.perMessageDeflate = {}), e.clientTracking && (this.clients = /* @__PURE__ */ new Set(), this._shouldEmitClose = !1), this.options = e, this._state = C;
2388
+ e.perMessageDeflate === !0 && (e.perMessageDeflate = {}), e.clientTracking && (this.clients = /* @__PURE__ */ new Set(), this._shouldEmitClose = !1), this.options = e, this._state = c;
2380
2389
  }
2381
2390
  /**
2382
2391
  * Returns the bound address, the address family name, and port of the server
@@ -2400,19 +2409,19 @@ function Rt() {
2400
2409
  * @public
2401
2410
  */
2402
2411
  close(e) {
2403
- if (this._state === w) {
2412
+ if (this._state === C) {
2404
2413
  e && this.once("close", () => {
2405
2414
  e(new Error("The server is not running"));
2406
- }), process.nextTick(O, this);
2415
+ }), process.nextTick(p, this);
2407
2416
  return;
2408
2417
  }
2409
- if (e && this.once("close", e), this._state !== c)
2410
- if (this._state = c, this.options.noServer || this.options.server)
2411
- this._server && (this._removeListeners(), this._removeListeners = this._server = null), this.clients ? this.clients.size ? this._shouldEmitClose = !0 : process.nextTick(O, this) : process.nextTick(O, this);
2418
+ if (e && this.once("close", e), this._state !== b)
2419
+ if (this._state = b, this.options.noServer || this.options.server)
2420
+ this._server && (this._removeListeners(), this._removeListeners = this._server = null), this.clients ? this.clients.size ? this._shouldEmitClose = !0 : process.nextTick(p, this) : process.nextTick(p, this);
2412
2421
  else {
2413
- const t = this._server;
2414
- this._removeListeners(), this._removeListeners = this._server = null, t.close(() => {
2415
- O(this);
2422
+ const s = this._server;
2423
+ this._removeListeners(), this._removeListeners = this._server = null, s.close(() => {
2424
+ p(this);
2416
2425
  });
2417
2426
  }
2418
2427
  }
@@ -2425,8 +2434,8 @@ function Rt() {
2425
2434
  */
2426
2435
  shouldHandle(e) {
2427
2436
  if (this.options.path) {
2428
- const t = e.url.indexOf("?");
2429
- if ((t !== -1 ? e.url.slice(0, t) : e.url) !== this.options.path) return !1;
2437
+ const s = e.url.indexOf("?");
2438
+ if ((s !== -1 ? e.url.slice(0, s) : e.url) !== this.options.path) return !1;
2430
2439
  }
2431
2440
  return !0;
2432
2441
  }
@@ -2439,80 +2448,80 @@ function Rt() {
2439
2448
  * @param {Function} cb Callback
2440
2449
  * @public
2441
2450
  */
2442
- handleUpgrade(e, t, i, s) {
2443
- t.on("error", p);
2444
- const m = e.headers["sec-websocket-key"], y = e.headers.upgrade, R = +e.headers["sec-websocket-version"];
2451
+ handleUpgrade(e, s, i, m) {
2452
+ s.on("error", f);
2453
+ const u = e.headers["sec-websocket-key"], R = e.headers.upgrade, B = +e.headers["sec-websocket-version"];
2445
2454
  if (e.method !== "GET") {
2446
- E(this, e, t, 405, "Invalid HTTP method");
2455
+ w(this, e, s, 405, "Invalid HTTP method");
2447
2456
  return;
2448
2457
  }
2449
- if (y === void 0 || y.toLowerCase() !== "websocket") {
2450
- E(this, e, t, 400, "Invalid Upgrade header");
2458
+ if (R === void 0 || R.toLowerCase() !== "websocket") {
2459
+ w(this, e, s, 400, "Invalid Upgrade header");
2451
2460
  return;
2452
2461
  }
2453
- if (m === void 0 || !h.test(m)) {
2454
- E(this, e, t, 400, "Missing or invalid Sec-WebSocket-Key header");
2462
+ if (u === void 0 || !L.test(u)) {
2463
+ w(this, e, s, 400, "Missing or invalid Sec-WebSocket-Key header");
2455
2464
  return;
2456
2465
  }
2457
- if (R !== 13 && R !== 8) {
2458
- E(this, e, t, 400, "Missing or invalid Sec-WebSocket-Version header", {
2466
+ if (B !== 13 && B !== 8) {
2467
+ w(this, e, s, 400, "Missing or invalid Sec-WebSocket-Version header", {
2459
2468
  "Sec-WebSocket-Version": "13, 8"
2460
2469
  });
2461
2470
  return;
2462
2471
  }
2463
2472
  if (!this.shouldHandle(e)) {
2464
- l(t, 400);
2473
+ E(s, 400);
2465
2474
  return;
2466
2475
  }
2467
- const D = e.headers["sec-websocket-protocol"];
2468
- let A = /* @__PURE__ */ new Set();
2469
- if (D !== void 0)
2476
+ const A = e.headers["sec-websocket-protocol"];
2477
+ let N = /* @__PURE__ */ new Set();
2478
+ if (A !== void 0)
2470
2479
  try {
2471
- A = n.parse(D);
2480
+ N = n.parse(A);
2472
2481
  } catch {
2473
- E(this, e, t, 400, "Invalid Sec-WebSocket-Protocol header");
2482
+ w(this, e, s, 400, "Invalid Sec-WebSocket-Protocol header");
2474
2483
  return;
2475
2484
  }
2476
- const N = e.headers["sec-websocket-extensions"], V = {};
2477
- if (this.options.perMessageDeflate && N !== void 0) {
2478
- const S = new d(
2485
+ const G = e.headers["sec-websocket-extensions"], S = {};
2486
+ if (this.options.perMessageDeflate && G !== void 0) {
2487
+ const F = new d(
2479
2488
  this.options.perMessageDeflate,
2480
2489
  !0,
2481
2490
  this.options.maxPayload
2482
2491
  );
2483
2492
  try {
2484
- const G = b.parse(N);
2485
- G[d.extensionName] && (S.accept(G[d.extensionName]), V[d.extensionName] = S);
2493
+ const j = x.parse(G);
2494
+ j[d.extensionName] && (F.accept(j[d.extensionName]), S[d.extensionName] = F);
2486
2495
  } catch {
2487
- E(this, e, t, 400, "Invalid or unacceptable Sec-WebSocket-Extensions header");
2496
+ w(this, e, s, 400, "Invalid or unacceptable Sec-WebSocket-Extensions header");
2488
2497
  return;
2489
2498
  }
2490
2499
  }
2491
2500
  if (this.options.verifyClient) {
2492
- const S = {
2493
- origin: e.headers[`${R === 8 ? "sec-websocket-origin" : "origin"}`],
2501
+ const F = {
2502
+ origin: e.headers[`${B === 8 ? "sec-websocket-origin" : "origin"}`],
2494
2503
  secure: !!(e.socket.authorized || e.socket.encrypted),
2495
2504
  req: e
2496
2505
  };
2497
2506
  if (this.options.verifyClient.length === 2) {
2498
- this.options.verifyClient(S, (G, q, fe, he) => {
2499
- if (!G)
2500
- return l(t, q || 401, fe, he);
2507
+ this.options.verifyClient(F, (j, ne, he, W) => {
2508
+ if (!j)
2509
+ return E(s, ne || 401, he, W);
2501
2510
  this.completeUpgrade(
2502
- V,
2503
- m,
2504
- A,
2511
+ S,
2512
+ u,
2513
+ N,
2505
2514
  e,
2506
- t,
2515
+ s,
2507
2516
  i,
2508
- s
2517
+ m
2509
2518
  );
2510
2519
  });
2511
2520
  return;
2512
2521
  }
2513
- if (!this.options.verifyClient(S)) return l(t, 401);
2522
+ if (!this.options.verifyClient(F)) return E(s, 401);
2514
2523
  }
2515
- this.completeUpgrade(V, m, A, e, t, i, s);
2524
+ this.completeUpgrade(S, u, N, e, s, i, m);
2516
2525
  }
2517
2526
  /**
2518
2527
  * Upgrade the connection to WebSocket.
@@ -2527,83 +2536,83 @@ function Rt() {
2527
2536
  * @throws {Error} If called more than once with the same socket
2528
2537
  * @private
2529
2538
  */
2530
- completeUpgrade(e, t, i, s, m, y, R) {
2531
- if (!m.readable || !m.writable) return m.destroy();
2532
- if (m[_])
2539
+ completeUpgrade(e, s, i, m, u, R, B) {
2540
+ if (!u.readable || !u.writable) return u.destroy();
2541
+ if (u[h])
2533
2542
  throw new Error(
2534
2543
  "server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration"
2535
2544
  );
2536
- if (this._state > C) return l(m, 503);
2537
- const A = [
2545
+ if (this._state > c) return E(u, 503);
2546
+ const N = [
2538
2547
  "HTTP/1.1 101 Switching Protocols",
2539
2548
  "Upgrade: websocket",
2540
2549
  "Connection: Upgrade",
2541
- `Sec-WebSocket-Accept: ${B("sha1").update(t + a).digest("base64")}`
2542
- ], N = new this.options.WebSocket(null, void 0, this.options);
2550
+ `Sec-WebSocket-Accept: ${D("sha1").update(s + _).digest("base64")}`
2551
+ ], G = new this.options.WebSocket(null, void 0, this.options);
2543
2552
  if (i.size) {
2544
- const V = this.options.handleProtocols ? this.options.handleProtocols(i, s) : i.values().next().value;
2545
- V && (A.push(`Sec-WebSocket-Protocol: ${V}`), N._protocol = V);
2553
+ const S = this.options.handleProtocols ? this.options.handleProtocols(i, m) : i.values().next().value;
2554
+ S && (N.push(`Sec-WebSocket-Protocol: ${S}`), G._protocol = S);
2546
2555
  }
2547
2556
  if (e[d.extensionName]) {
2548
- const V = e[d.extensionName].params, S = b.format({
2549
- [d.extensionName]: [V]
2557
+ const S = e[d.extensionName].params, F = x.format({
2558
+ [d.extensionName]: [S]
2550
2559
  });
2551
- A.push(`Sec-WebSocket-Extensions: ${S}`), N._extensions = e;
2560
+ N.push(`Sec-WebSocket-Extensions: ${F}`), G._extensions = e;
2552
2561
  }
2553
- this.emit("headers", A, s), m.write(A.concat(`\r
2562
+ this.emit("headers", N, m), u.write(N.concat(`\r
2554
2563
  `).join(`\r
2555
- `)), m.removeListener("error", p), N.setSocket(m, y, {
2564
+ `)), u.removeListener("error", f), G.setSocket(u, R, {
2556
2565
  allowSynchronousEvents: this.options.allowSynchronousEvents,
2557
2566
  maxPayload: this.options.maxPayload,
2558
2567
  skipUTF8Validation: this.options.skipUTF8Validation
2559
- }), this.clients && (this.clients.add(N), N.on("close", () => {
2560
- this.clients.delete(N), this._shouldEmitClose && !this.clients.size && process.nextTick(O, this);
2561
- })), R(N, s);
2568
+ }), this.clients && (this.clients.add(G), G.on("close", () => {
2569
+ this.clients.delete(G), this._shouldEmitClose && !this.clients.size && process.nextTick(p, this);
2570
+ })), B(G, m);
2562
2571
  }
2563
2572
  }
2564
- we = k;
2565
- function v(u, e) {
2566
- for (const t of Object.keys(e)) u.on(t, e[t]);
2573
+ we = v;
2574
+ function O(t, e) {
2575
+ for (const s of Object.keys(e)) t.on(s, e[s]);
2567
2576
  return function() {
2568
2577
  for (const i of Object.keys(e))
2569
- u.removeListener(i, e[i]);
2578
+ t.removeListener(i, e[i]);
2570
2579
  };
2571
2580
  }
2572
- function O(u) {
2573
- u._state = w, u.emit("close");
2581
+ function p(t) {
2582
+ t._state = C, t.emit("close");
2574
2583
  }
2575
- function p() {
2584
+ function f() {
2576
2585
  this.destroy();
2577
2586
  }
2578
- function l(u, e, t, i) {
2579
- t = t || T.STATUS_CODES[e], i = {
2587
+ function E(t, e, s, i) {
2588
+ s = s || T.STATUS_CODES[e], i = {
2580
2589
  Connection: "close",
2581
2590
  "Content-Type": "text/html",
2582
- "Content-Length": Buffer.byteLength(t),
2591
+ "Content-Length": Buffer.byteLength(s),
2583
2592
  ...i
2584
- }, u.once("finish", u.destroy), u.end(
2593
+ }, t.once("finish", t.destroy), t.end(
2585
2594
  `HTTP/1.1 ${e} ${T.STATUS_CODES[e]}\r
2586
- ` + Object.keys(i).map((s) => `${s}: ${i[s]}`).join(`\r
2595
+ ` + Object.keys(i).map((m) => `${m}: ${i[m]}`).join(`\r
2587
2596
  `) + `\r
2588
2597
  \r
2589
- ` + t
2598
+ ` + s
2590
2599
  );
2591
2600
  }
2592
- function E(u, e, t, i, s, m) {
2593
- if (u.listenerCount("wsClientError")) {
2594
- const y = new Error(s);
2595
- Error.captureStackTrace(y, E), u.emit("wsClientError", y, t, e);
2601
+ function w(t, e, s, i, m, u) {
2602
+ if (t.listenerCount("wsClientError")) {
2603
+ const R = new Error(m);
2604
+ Error.captureStackTrace(R, w), t.emit("wsClientError", R, s, e);
2596
2605
  } else
2597
- l(t, i, s, m);
2606
+ E(s, i, m, u);
2598
2607
  }
2599
2608
  return we;
2600
2609
  }
2601
2610
  Rt();
2602
- const le = global;
2603
- le.WebSocket ||= Nt;
2604
- le.window ||= global;
2605
- le.self ||= global;
2606
- le.window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = [
2611
+ const fe = global;
2612
+ fe.WebSocket ||= Nt;
2613
+ fe.window ||= global;
2614
+ fe.self ||= global;
2615
+ fe.window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = [
2607
2616
  {
2608
2617
  // ComponentFilterElementType
2609
2618
  type: 1,