iosignal 5.1.3 → 5.2.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.
Files changed (34) hide show
  1. package/.vscode/settings.json +3 -0
  2. package/dist/{io.d.ts → browser/esm/io.d.ts} +2 -3
  3. package/dist/browser/esm/io.js +23 -0
  4. package/dist/browser/esm/io.js.map +1 -0
  5. package/dist/browser/iife/io.js +23 -0
  6. package/dist/browser/iife/io.js.map +1 -0
  7. package/dist/{iosignal.cjs → node/iosignal.cjs} +206 -3153
  8. package/dist/{iosignal.js → node/iosignal.js} +205 -3152
  9. package/dist/types/client/IOCore.d.ts +1 -2
  10. package/dist/types/client/browser/IOWebSocket.d.ts +1 -1
  11. package/dist/types/common/payload.d.ts +1 -1
  12. package/package.json +17 -18
  13. package/rollup.config.js +6 -6
  14. package/tsconfig.json +7 -6
  15. package/LICENSE +0 -21
  16. package/README.md +0 -78
  17. package/dist/io.js +0 -16
  18. package/dist/io.js.map +0 -1
  19. package/dist/io.min.js +0 -16
  20. package/dist/io.min.js.map +0 -1
  21. package/test/attach-services/RedisService.js +0 -46
  22. package/test/attach-services/replyService.js +0 -46
  23. package/test/auth_server_client/auth_server_client.js +0 -45
  24. package/test/pubsub-counter/pubsub-counter.js +0 -61
  25. package/test/subscribe-signal/cid-a-b.js +0 -94
  26. package/test/subscribe-signal/cs-signal-test.js +0 -47
  27. package/test/subscribe-signal/meta.js +0 -61
  28. package/test/subscribe-signal/self-listen.cjs +0 -50
  29. package/test/subscribe-signal/self-listen.js +0 -40
  30. package/test/subscribe-signal/self-subscribe.cjs +0 -35
  31. package/test/subscribe-signal/self-subscribe.js +0 -35
  32. package/test/subscribe-signal/signal-MBA.js +0 -15
  33. package/test/subscribe-signal/signalPack.js +0 -34
  34. package/test/subscribe-signal/signaling.js +0 -61
@@ -4,7 +4,7 @@ var require$$0 = require('stream');
4
4
  var net = require('net');
5
5
  var require$$0$3 = require('events');
6
6
  var require$$1$1 = require('https');
7
- var require$$2$1 = require('http');
7
+ var require$$2$2 = require('http');
8
8
  var require$$4 = require('tls');
9
9
  var require$$1 = require('crypto');
10
10
  var require$$7 = require('url');
@@ -13,3048 +13,26 @@ var fs = require('fs');
13
13
  var path = require('path');
14
14
  var require$$2 = require('os');
15
15
  var require$$0$2 = require('buffer');
16
+ var require$$2$1 = require('util');
16
17
  var process$1 = require('process');
17
18
 
18
- var version$1 = "5.1.3";
19
+ var version$1 = "5.2.0";
19
20
  var pkg = {
20
21
  version: version$1};
21
22
 
22
- function getDefaultExportFromCjs (x) {
23
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
24
- }
25
-
26
- var buffer = {};
27
-
28
- var base64Js = {};
29
-
30
- var hasRequiredBase64Js;
31
-
32
- function requireBase64Js () {
33
- if (hasRequiredBase64Js) return base64Js;
34
- hasRequiredBase64Js = 1;
35
-
36
- base64Js.byteLength = byteLength;
37
- base64Js.toByteArray = toByteArray;
38
- base64Js.fromByteArray = fromByteArray;
39
-
40
- var lookup = [];
41
- var revLookup = [];
42
- var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
43
-
44
- var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
45
- for (var i = 0, len = code.length; i < len; ++i) {
46
- lookup[i] = code[i];
47
- revLookup[code.charCodeAt(i)] = i;
48
- }
49
-
50
- // Support decoding URL-safe base64 strings, as Node.js does.
51
- // See: https://en.wikipedia.org/wiki/Base64#URL_applications
52
- revLookup['-'.charCodeAt(0)] = 62;
53
- revLookup['_'.charCodeAt(0)] = 63;
54
-
55
- function getLens (b64) {
56
- var len = b64.length;
57
-
58
- if (len % 4 > 0) {
59
- throw new Error('Invalid string. Length must be a multiple of 4')
60
- }
61
-
62
- // Trim off extra bytes after placeholder bytes are found
63
- // See: https://github.com/beatgammit/base64-js/issues/42
64
- var validLen = b64.indexOf('=');
65
- if (validLen === -1) validLen = len;
66
-
67
- var placeHoldersLen = validLen === len
68
- ? 0
69
- : 4 - (validLen % 4);
70
-
71
- return [validLen, placeHoldersLen]
72
- }
73
-
74
- // base64 is 4/3 + up to two characters of the original data
75
- function byteLength (b64) {
76
- var lens = getLens(b64);
77
- var validLen = lens[0];
78
- var placeHoldersLen = lens[1];
79
- return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
80
- }
81
-
82
- function _byteLength (b64, validLen, placeHoldersLen) {
83
- return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
84
- }
85
-
86
- function toByteArray (b64) {
87
- var tmp;
88
- var lens = getLens(b64);
89
- var validLen = lens[0];
90
- var placeHoldersLen = lens[1];
91
-
92
- var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
93
-
94
- var curByte = 0;
95
-
96
- // if there are placeholders, only get up to the last complete 4 chars
97
- var len = placeHoldersLen > 0
98
- ? validLen - 4
99
- : validLen;
100
-
101
- var i;
102
- for (i = 0; i < len; i += 4) {
103
- tmp =
104
- (revLookup[b64.charCodeAt(i)] << 18) |
105
- (revLookup[b64.charCodeAt(i + 1)] << 12) |
106
- (revLookup[b64.charCodeAt(i + 2)] << 6) |
107
- revLookup[b64.charCodeAt(i + 3)];
108
- arr[curByte++] = (tmp >> 16) & 0xFF;
109
- arr[curByte++] = (tmp >> 8) & 0xFF;
110
- arr[curByte++] = tmp & 0xFF;
111
- }
112
-
113
- if (placeHoldersLen === 2) {
114
- tmp =
115
- (revLookup[b64.charCodeAt(i)] << 2) |
116
- (revLookup[b64.charCodeAt(i + 1)] >> 4);
117
- arr[curByte++] = tmp & 0xFF;
118
- }
119
-
120
- if (placeHoldersLen === 1) {
121
- tmp =
122
- (revLookup[b64.charCodeAt(i)] << 10) |
123
- (revLookup[b64.charCodeAt(i + 1)] << 4) |
124
- (revLookup[b64.charCodeAt(i + 2)] >> 2);
125
- arr[curByte++] = (tmp >> 8) & 0xFF;
126
- arr[curByte++] = tmp & 0xFF;
127
- }
128
-
129
- return arr
130
- }
131
-
132
- function tripletToBase64 (num) {
133
- return lookup[num >> 18 & 0x3F] +
134
- lookup[num >> 12 & 0x3F] +
135
- lookup[num >> 6 & 0x3F] +
136
- lookup[num & 0x3F]
137
- }
138
-
139
- function encodeChunk (uint8, start, end) {
140
- var tmp;
141
- var output = [];
142
- for (var i = start; i < end; i += 3) {
143
- tmp =
144
- ((uint8[i] << 16) & 0xFF0000) +
145
- ((uint8[i + 1] << 8) & 0xFF00) +
146
- (uint8[i + 2] & 0xFF);
147
- output.push(tripletToBase64(tmp));
148
- }
149
- return output.join('')
150
- }
151
-
152
- function fromByteArray (uint8) {
153
- var tmp;
154
- var len = uint8.length;
155
- var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
156
- var parts = [];
157
- var maxChunkLength = 16383; // must be multiple of 3
158
-
159
- // go through the array every three bytes, we'll deal with trailing stuff later
160
- for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
161
- parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)));
162
- }
163
-
164
- // pad the end with zeros, but make sure to not forget the extra bytes
165
- if (extraBytes === 1) {
166
- tmp = uint8[len - 1];
167
- parts.push(
168
- lookup[tmp >> 2] +
169
- lookup[(tmp << 4) & 0x3F] +
170
- '=='
171
- );
172
- } else if (extraBytes === 2) {
173
- tmp = (uint8[len - 2] << 8) + uint8[len - 1];
174
- parts.push(
175
- lookup[tmp >> 10] +
176
- lookup[(tmp >> 4) & 0x3F] +
177
- lookup[(tmp << 2) & 0x3F] +
178
- '='
179
- );
180
- }
181
-
182
- return parts.join('')
183
- }
184
- return base64Js;
185
- }
186
-
187
- var ieee754 = {};
188
-
189
- /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
190
-
191
- var hasRequiredIeee754;
192
-
193
- function requireIeee754 () {
194
- if (hasRequiredIeee754) return ieee754;
195
- hasRequiredIeee754 = 1;
196
- ieee754.read = function (buffer, offset, isLE, mLen, nBytes) {
197
- var e, m;
198
- var eLen = (nBytes * 8) - mLen - 1;
199
- var eMax = (1 << eLen) - 1;
200
- var eBias = eMax >> 1;
201
- var nBits = -7;
202
- var i = isLE ? (nBytes - 1) : 0;
203
- var d = isLE ? -1 : 1;
204
- var s = buffer[offset + i];
205
-
206
- i += d;
207
-
208
- e = s & ((1 << (-nBits)) - 1);
209
- s >>= (-nBits);
210
- nBits += eLen;
211
- for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
212
-
213
- m = e & ((1 << (-nBits)) - 1);
214
- e >>= (-nBits);
215
- nBits += mLen;
216
- for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
217
-
218
- if (e === 0) {
219
- e = 1 - eBias;
220
- } else if (e === eMax) {
221
- return m ? NaN : ((s ? -1 : 1) * Infinity)
222
- } else {
223
- m = m + Math.pow(2, mLen);
224
- e = e - eBias;
225
- }
226
- return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
227
- };
228
-
229
- ieee754.write = function (buffer, value, offset, isLE, mLen, nBytes) {
230
- var e, m, c;
231
- var eLen = (nBytes * 8) - mLen - 1;
232
- var eMax = (1 << eLen) - 1;
233
- var eBias = eMax >> 1;
234
- var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0);
235
- var i = isLE ? 0 : (nBytes - 1);
236
- var d = isLE ? 1 : -1;
237
- var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
238
-
239
- value = Math.abs(value);
240
-
241
- if (isNaN(value) || value === Infinity) {
242
- m = isNaN(value) ? 1 : 0;
243
- e = eMax;
244
- } else {
245
- e = Math.floor(Math.log(value) / Math.LN2);
246
- if (value * (c = Math.pow(2, -e)) < 1) {
247
- e--;
248
- c *= 2;
249
- }
250
- if (e + eBias >= 1) {
251
- value += rt / c;
252
- } else {
253
- value += rt * Math.pow(2, 1 - eBias);
254
- }
255
- if (value * c >= 2) {
256
- e++;
257
- c /= 2;
258
- }
259
-
260
- if (e + eBias >= eMax) {
261
- m = 0;
262
- e = eMax;
263
- } else if (e + eBias >= 1) {
264
- m = ((value * c) - 1) * Math.pow(2, mLen);
265
- e = e + eBias;
266
- } else {
267
- m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
268
- e = 0;
269
- }
270
- }
271
-
272
- for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
273
-
274
- e = (e << mLen) | m;
275
- eLen += mLen;
276
- for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
277
-
278
- buffer[offset + i - d] |= s * 128;
279
- };
280
- return ieee754;
281
- }
282
-
283
- /*!
284
- * The buffer module from node.js, for the browser.
285
- *
286
- * @author Feross Aboukhadijeh <https://feross.org>
287
- * @license MIT
288
- */
289
-
290
- var hasRequiredBuffer;
291
-
292
- function requireBuffer () {
293
- if (hasRequiredBuffer) return buffer;
294
- hasRequiredBuffer = 1;
295
- (function (exports$1) {
296
-
297
- const base64 = requireBase64Js();
298
- const ieee754 = requireIeee754();
299
- const customInspectSymbol =
300
- (typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation
301
- ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
302
- : null;
303
-
304
- exports$1.Buffer = Buffer;
305
- exports$1.SlowBuffer = SlowBuffer;
306
- exports$1.INSPECT_MAX_BYTES = 50;
307
-
308
- const K_MAX_LENGTH = 0x7fffffff;
309
- exports$1.kMaxLength = K_MAX_LENGTH;
310
-
311
- /**
312
- * If `Buffer.TYPED_ARRAY_SUPPORT`:
313
- * === true Use Uint8Array implementation (fastest)
314
- * === false Print warning and recommend using `buffer` v4.x which has an Object
315
- * implementation (most compatible, even IE6)
316
- *
317
- * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
318
- * Opera 11.6+, iOS 4.2+.
319
- *
320
- * We report that the browser does not support typed arrays if the are not subclassable
321
- * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
322
- * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
323
- * for __proto__ and has a buggy typed array implementation.
324
- */
325
- Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport();
326
-
327
- if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
328
- typeof console.error === 'function') {
329
- console.error(
330
- 'This browser lacks typed array (Uint8Array) support which is required by ' +
331
- '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
332
- );
333
- }
334
-
335
- function typedArraySupport () {
336
- // Can typed array instances can be augmented?
337
- try {
338
- const arr = new Uint8Array(1);
339
- const proto = { foo: function () { return 42 } };
340
- Object.setPrototypeOf(proto, Uint8Array.prototype);
341
- Object.setPrototypeOf(arr, proto);
342
- return arr.foo() === 42
343
- } catch (e) {
344
- return false
345
- }
346
- }
347
-
348
- Object.defineProperty(Buffer.prototype, 'parent', {
349
- enumerable: true,
350
- get: function () {
351
- if (!Buffer.isBuffer(this)) return undefined
352
- return this.buffer
353
- }
354
- });
355
-
356
- Object.defineProperty(Buffer.prototype, 'offset', {
357
- enumerable: true,
358
- get: function () {
359
- if (!Buffer.isBuffer(this)) return undefined
360
- return this.byteOffset
361
- }
362
- });
363
-
364
- function createBuffer (length) {
365
- if (length > K_MAX_LENGTH) {
366
- throw new RangeError('The value "' + length + '" is invalid for option "size"')
367
- }
368
- // Return an augmented `Uint8Array` instance
369
- const buf = new Uint8Array(length);
370
- Object.setPrototypeOf(buf, Buffer.prototype);
371
- return buf
372
- }
373
-
374
- /**
375
- * The Buffer constructor returns instances of `Uint8Array` that have their
376
- * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
377
- * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
378
- * and the `Uint8Array` methods. Square bracket notation works as expected -- it
379
- * returns a single octet.
380
- *
381
- * The `Uint8Array` prototype remains unmodified.
382
- */
383
-
384
- function Buffer (arg, encodingOrOffset, length) {
385
- // Common case.
386
- if (typeof arg === 'number') {
387
- if (typeof encodingOrOffset === 'string') {
388
- throw new TypeError(
389
- 'The "string" argument must be of type string. Received type number'
390
- )
391
- }
392
- return allocUnsafe(arg)
393
- }
394
- return from(arg, encodingOrOffset, length)
395
- }
396
-
397
- Buffer.poolSize = 8192; // not used by this implementation
398
-
399
- function from (value, encodingOrOffset, length) {
400
- if (typeof value === 'string') {
401
- return fromString(value, encodingOrOffset)
402
- }
403
-
404
- if (ArrayBuffer.isView(value)) {
405
- return fromArrayView(value)
406
- }
407
-
408
- if (value == null) {
409
- throw new TypeError(
410
- 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
411
- 'or Array-like Object. Received type ' + (typeof value)
412
- )
413
- }
414
-
415
- if (isInstance(value, ArrayBuffer) ||
416
- (value && isInstance(value.buffer, ArrayBuffer))) {
417
- return fromArrayBuffer(value, encodingOrOffset, length)
418
- }
419
-
420
- if (typeof SharedArrayBuffer !== 'undefined' &&
421
- (isInstance(value, SharedArrayBuffer) ||
422
- (value && isInstance(value.buffer, SharedArrayBuffer)))) {
423
- return fromArrayBuffer(value, encodingOrOffset, length)
424
- }
425
-
426
- if (typeof value === 'number') {
427
- throw new TypeError(
428
- 'The "value" argument must not be of type number. Received type number'
429
- )
430
- }
431
-
432
- const valueOf = value.valueOf && value.valueOf();
433
- if (valueOf != null && valueOf !== value) {
434
- return Buffer.from(valueOf, encodingOrOffset, length)
435
- }
436
-
437
- const b = fromObject(value);
438
- if (b) return b
439
-
440
- if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
441
- typeof value[Symbol.toPrimitive] === 'function') {
442
- return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length)
443
- }
444
-
445
- throw new TypeError(
446
- 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
447
- 'or Array-like Object. Received type ' + (typeof value)
448
- )
449
- }
450
-
451
- /**
452
- * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
453
- * if value is a number.
454
- * Buffer.from(str[, encoding])
455
- * Buffer.from(array)
456
- * Buffer.from(buffer)
457
- * Buffer.from(arrayBuffer[, byteOffset[, length]])
458
- **/
459
- Buffer.from = function (value, encodingOrOffset, length) {
460
- return from(value, encodingOrOffset, length)
461
- };
462
-
463
- // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
464
- // https://github.com/feross/buffer/pull/148
465
- Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype);
466
- Object.setPrototypeOf(Buffer, Uint8Array);
467
-
468
- function assertSize (size) {
469
- if (typeof size !== 'number') {
470
- throw new TypeError('"size" argument must be of type number')
471
- } else if (size < 0) {
472
- throw new RangeError('The value "' + size + '" is invalid for option "size"')
473
- }
474
- }
475
-
476
- function alloc (size, fill, encoding) {
477
- assertSize(size);
478
- if (size <= 0) {
479
- return createBuffer(size)
480
- }
481
- if (fill !== undefined) {
482
- // Only pay attention to encoding if it's a string. This
483
- // prevents accidentally sending in a number that would
484
- // be interpreted as a start offset.
485
- return typeof encoding === 'string'
486
- ? createBuffer(size).fill(fill, encoding)
487
- : createBuffer(size).fill(fill)
488
- }
489
- return createBuffer(size)
490
- }
491
-
492
- /**
493
- * Creates a new filled Buffer instance.
494
- * alloc(size[, fill[, encoding]])
495
- **/
496
- Buffer.alloc = function (size, fill, encoding) {
497
- return alloc(size, fill, encoding)
498
- };
499
-
500
- function allocUnsafe (size) {
501
- assertSize(size);
502
- return createBuffer(size < 0 ? 0 : checked(size) | 0)
503
- }
504
-
505
- /**
506
- * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
507
- * */
508
- Buffer.allocUnsafe = function (size) {
509
- return allocUnsafe(size)
510
- };
511
- /**
512
- * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
513
- */
514
- Buffer.allocUnsafeSlow = function (size) {
515
- return allocUnsafe(size)
516
- };
517
-
518
- function fromString (string, encoding) {
519
- if (typeof encoding !== 'string' || encoding === '') {
520
- encoding = 'utf8';
521
- }
522
-
523
- if (!Buffer.isEncoding(encoding)) {
524
- throw new TypeError('Unknown encoding: ' + encoding)
525
- }
526
-
527
- const length = byteLength(string, encoding) | 0;
528
- let buf = createBuffer(length);
529
-
530
- const actual = buf.write(string, encoding);
531
-
532
- if (actual !== length) {
533
- // Writing a hex string, for example, that contains invalid characters will
534
- // cause everything after the first invalid character to be ignored. (e.g.
535
- // 'abxxcd' will be treated as 'ab')
536
- buf = buf.slice(0, actual);
537
- }
538
-
539
- return buf
540
- }
541
-
542
- function fromArrayLike (array) {
543
- const length = array.length < 0 ? 0 : checked(array.length) | 0;
544
- const buf = createBuffer(length);
545
- for (let i = 0; i < length; i += 1) {
546
- buf[i] = array[i] & 255;
547
- }
548
- return buf
549
- }
550
-
551
- function fromArrayView (arrayView) {
552
- if (isInstance(arrayView, Uint8Array)) {
553
- const copy = new Uint8Array(arrayView);
554
- return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)
555
- }
556
- return fromArrayLike(arrayView)
557
- }
558
-
559
- function fromArrayBuffer (array, byteOffset, length) {
560
- if (byteOffset < 0 || array.byteLength < byteOffset) {
561
- throw new RangeError('"offset" is outside of buffer bounds')
562
- }
563
-
564
- if (array.byteLength < byteOffset + (length || 0)) {
565
- throw new RangeError('"length" is outside of buffer bounds')
566
- }
567
-
568
- let buf;
569
- if (byteOffset === undefined && length === undefined) {
570
- buf = new Uint8Array(array);
571
- } else if (length === undefined) {
572
- buf = new Uint8Array(array, byteOffset);
573
- } else {
574
- buf = new Uint8Array(array, byteOffset, length);
575
- }
576
-
577
- // Return an augmented `Uint8Array` instance
578
- Object.setPrototypeOf(buf, Buffer.prototype);
579
-
580
- return buf
581
- }
582
-
583
- function fromObject (obj) {
584
- if (Buffer.isBuffer(obj)) {
585
- const len = checked(obj.length) | 0;
586
- const buf = createBuffer(len);
587
-
588
- if (buf.length === 0) {
589
- return buf
590
- }
591
-
592
- obj.copy(buf, 0, 0, len);
593
- return buf
594
- }
595
-
596
- if (obj.length !== undefined) {
597
- if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
598
- return createBuffer(0)
599
- }
600
- return fromArrayLike(obj)
601
- }
602
-
603
- if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
604
- return fromArrayLike(obj.data)
605
- }
606
- }
607
-
608
- function checked (length) {
609
- // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
610
- // length is NaN (which is otherwise coerced to zero.)
611
- if (length >= K_MAX_LENGTH) {
612
- throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
613
- 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
614
- }
615
- return length | 0
616
- }
617
-
618
- function SlowBuffer (length) {
619
- if (+length != length) { // eslint-disable-line eqeqeq
620
- length = 0;
621
- }
622
- return Buffer.alloc(+length)
623
- }
624
-
625
- Buffer.isBuffer = function isBuffer (b) {
626
- return b != null && b._isBuffer === true &&
627
- b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
628
- };
629
-
630
- Buffer.compare = function compare (a, b) {
631
- if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength);
632
- if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength);
633
- if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
634
- throw new TypeError(
635
- 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
636
- )
637
- }
638
-
639
- if (a === b) return 0
640
-
641
- let x = a.length;
642
- let y = b.length;
643
-
644
- for (let i = 0, len = Math.min(x, y); i < len; ++i) {
645
- if (a[i] !== b[i]) {
646
- x = a[i];
647
- y = b[i];
648
- break
649
- }
650
- }
651
-
652
- if (x < y) return -1
653
- if (y < x) return 1
654
- return 0
655
- };
656
-
657
- Buffer.isEncoding = function isEncoding (encoding) {
658
- switch (String(encoding).toLowerCase()) {
659
- case 'hex':
660
- case 'utf8':
661
- case 'utf-8':
662
- case 'ascii':
663
- case 'latin1':
664
- case 'binary':
665
- case 'base64':
666
- case 'ucs2':
667
- case 'ucs-2':
668
- case 'utf16le':
669
- case 'utf-16le':
670
- return true
671
- default:
672
- return false
673
- }
674
- };
675
-
676
- Buffer.concat = function concat (list, length) {
677
- if (!Array.isArray(list)) {
678
- throw new TypeError('"list" argument must be an Array of Buffers')
679
- }
680
-
681
- if (list.length === 0) {
682
- return Buffer.alloc(0)
683
- }
684
-
685
- let i;
686
- if (length === undefined) {
687
- length = 0;
688
- for (i = 0; i < list.length; ++i) {
689
- length += list[i].length;
690
- }
691
- }
692
-
693
- const buffer = Buffer.allocUnsafe(length);
694
- let pos = 0;
695
- for (i = 0; i < list.length; ++i) {
696
- let buf = list[i];
697
- if (isInstance(buf, Uint8Array)) {
698
- if (pos + buf.length > buffer.length) {
699
- if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf);
700
- buf.copy(buffer, pos);
701
- } else {
702
- Uint8Array.prototype.set.call(
703
- buffer,
704
- buf,
705
- pos
706
- );
707
- }
708
- } else if (!Buffer.isBuffer(buf)) {
709
- throw new TypeError('"list" argument must be an Array of Buffers')
710
- } else {
711
- buf.copy(buffer, pos);
712
- }
713
- pos += buf.length;
714
- }
715
- return buffer
716
- };
717
-
718
- function byteLength (string, encoding) {
719
- if (Buffer.isBuffer(string)) {
720
- return string.length
721
- }
722
- if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
723
- return string.byteLength
724
- }
725
- if (typeof string !== 'string') {
726
- throw new TypeError(
727
- 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
728
- 'Received type ' + typeof string
729
- )
730
- }
731
-
732
- const len = string.length;
733
- const mustMatch = (arguments.length > 2 && arguments[2] === true);
734
- if (!mustMatch && len === 0) return 0
735
-
736
- // Use a for loop to avoid recursion
737
- let loweredCase = false;
738
- for (;;) {
739
- switch (encoding) {
740
- case 'ascii':
741
- case 'latin1':
742
- case 'binary':
743
- return len
744
- case 'utf8':
745
- case 'utf-8':
746
- return utf8ToBytes(string).length
747
- case 'ucs2':
748
- case 'ucs-2':
749
- case 'utf16le':
750
- case 'utf-16le':
751
- return len * 2
752
- case 'hex':
753
- return len >>> 1
754
- case 'base64':
755
- return base64ToBytes(string).length
756
- default:
757
- if (loweredCase) {
758
- return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
759
- }
760
- encoding = ('' + encoding).toLowerCase();
761
- loweredCase = true;
762
- }
763
- }
764
- }
765
- Buffer.byteLength = byteLength;
766
-
767
- function slowToString (encoding, start, end) {
768
- let loweredCase = false;
769
-
770
- // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
771
- // property of a typed array.
772
-
773
- // This behaves neither like String nor Uint8Array in that we set start/end
774
- // to their upper/lower bounds if the value passed is out of range.
775
- // undefined is handled specially as per ECMA-262 6th Edition,
776
- // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
777
- if (start === undefined || start < 0) {
778
- start = 0;
779
- }
780
- // Return early if start > this.length. Done here to prevent potential uint32
781
- // coercion fail below.
782
- if (start > this.length) {
783
- return ''
784
- }
785
-
786
- if (end === undefined || end > this.length) {
787
- end = this.length;
788
- }
789
-
790
- if (end <= 0) {
791
- return ''
792
- }
793
-
794
- // Force coercion to uint32. This will also coerce falsey/NaN values to 0.
795
- end >>>= 0;
796
- start >>>= 0;
797
-
798
- if (end <= start) {
799
- return ''
800
- }
801
-
802
- if (!encoding) encoding = 'utf8';
803
-
804
- while (true) {
805
- switch (encoding) {
806
- case 'hex':
807
- return hexSlice(this, start, end)
808
-
809
- case 'utf8':
810
- case 'utf-8':
811
- return utf8Slice(this, start, end)
812
-
813
- case 'ascii':
814
- return asciiSlice(this, start, end)
815
-
816
- case 'latin1':
817
- case 'binary':
818
- return latin1Slice(this, start, end)
819
-
820
- case 'base64':
821
- return base64Slice(this, start, end)
822
-
823
- case 'ucs2':
824
- case 'ucs-2':
825
- case 'utf16le':
826
- case 'utf-16le':
827
- return utf16leSlice(this, start, end)
828
-
829
- default:
830
- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
831
- encoding = (encoding + '').toLowerCase();
832
- loweredCase = true;
833
- }
834
- }
835
- }
836
-
837
- // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
838
- // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
839
- // reliably in a browserify context because there could be multiple different
840
- // copies of the 'buffer' package in use. This method works even for Buffer
841
- // instances that were created from another copy of the `buffer` package.
842
- // See: https://github.com/feross/buffer/issues/154
843
- Buffer.prototype._isBuffer = true;
844
-
845
- function swap (b, n, m) {
846
- const i = b[n];
847
- b[n] = b[m];
848
- b[m] = i;
849
- }
850
-
851
- Buffer.prototype.swap16 = function swap16 () {
852
- const len = this.length;
853
- if (len % 2 !== 0) {
854
- throw new RangeError('Buffer size must be a multiple of 16-bits')
855
- }
856
- for (let i = 0; i < len; i += 2) {
857
- swap(this, i, i + 1);
858
- }
859
- return this
860
- };
861
-
862
- Buffer.prototype.swap32 = function swap32 () {
863
- const len = this.length;
864
- if (len % 4 !== 0) {
865
- throw new RangeError('Buffer size must be a multiple of 32-bits')
866
- }
867
- for (let i = 0; i < len; i += 4) {
868
- swap(this, i, i + 3);
869
- swap(this, i + 1, i + 2);
870
- }
871
- return this
872
- };
873
-
874
- Buffer.prototype.swap64 = function swap64 () {
875
- const len = this.length;
876
- if (len % 8 !== 0) {
877
- throw new RangeError('Buffer size must be a multiple of 64-bits')
878
- }
879
- for (let i = 0; i < len; i += 8) {
880
- swap(this, i, i + 7);
881
- swap(this, i + 1, i + 6);
882
- swap(this, i + 2, i + 5);
883
- swap(this, i + 3, i + 4);
884
- }
885
- return this
886
- };
887
-
888
- Buffer.prototype.toString = function toString () {
889
- const length = this.length;
890
- if (length === 0) return ''
891
- if (arguments.length === 0) return utf8Slice(this, 0, length)
892
- return slowToString.apply(this, arguments)
893
- };
894
-
895
- Buffer.prototype.toLocaleString = Buffer.prototype.toString;
896
-
897
- Buffer.prototype.equals = function equals (b) {
898
- if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
899
- if (this === b) return true
900
- return Buffer.compare(this, b) === 0
901
- };
902
-
903
- Buffer.prototype.inspect = function inspect () {
904
- let str = '';
905
- const max = exports$1.INSPECT_MAX_BYTES;
906
- str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim();
907
- if (this.length > max) str += ' ... ';
908
- return '<Buffer ' + str + '>'
909
- };
910
- if (customInspectSymbol) {
911
- Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect;
912
- }
913
-
914
- Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
915
- if (isInstance(target, Uint8Array)) {
916
- target = Buffer.from(target, target.offset, target.byteLength);
917
- }
918
- if (!Buffer.isBuffer(target)) {
919
- throw new TypeError(
920
- 'The "target" argument must be one of type Buffer or Uint8Array. ' +
921
- 'Received type ' + (typeof target)
922
- )
923
- }
924
-
925
- if (start === undefined) {
926
- start = 0;
927
- }
928
- if (end === undefined) {
929
- end = target ? target.length : 0;
930
- }
931
- if (thisStart === undefined) {
932
- thisStart = 0;
933
- }
934
- if (thisEnd === undefined) {
935
- thisEnd = this.length;
936
- }
937
-
938
- if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
939
- throw new RangeError('out of range index')
940
- }
941
-
942
- if (thisStart >= thisEnd && start >= end) {
943
- return 0
944
- }
945
- if (thisStart >= thisEnd) {
946
- return -1
947
- }
948
- if (start >= end) {
949
- return 1
950
- }
951
-
952
- start >>>= 0;
953
- end >>>= 0;
954
- thisStart >>>= 0;
955
- thisEnd >>>= 0;
956
-
957
- if (this === target) return 0
958
-
959
- let x = thisEnd - thisStart;
960
- let y = end - start;
961
- const len = Math.min(x, y);
962
-
963
- const thisCopy = this.slice(thisStart, thisEnd);
964
- const targetCopy = target.slice(start, end);
965
-
966
- for (let i = 0; i < len; ++i) {
967
- if (thisCopy[i] !== targetCopy[i]) {
968
- x = thisCopy[i];
969
- y = targetCopy[i];
970
- break
971
- }
972
- }
973
-
974
- if (x < y) return -1
975
- if (y < x) return 1
976
- return 0
977
- };
978
-
979
- // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
980
- // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
981
- //
982
- // Arguments:
983
- // - buffer - a Buffer to search
984
- // - val - a string, Buffer, or number
985
- // - byteOffset - an index into `buffer`; will be clamped to an int32
986
- // - encoding - an optional encoding, relevant is val is a string
987
- // - dir - true for indexOf, false for lastIndexOf
988
- function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
989
- // Empty buffer means no match
990
- if (buffer.length === 0) return -1
991
-
992
- // Normalize byteOffset
993
- if (typeof byteOffset === 'string') {
994
- encoding = byteOffset;
995
- byteOffset = 0;
996
- } else if (byteOffset > 0x7fffffff) {
997
- byteOffset = 0x7fffffff;
998
- } else if (byteOffset < -2147483648) {
999
- byteOffset = -2147483648;
1000
- }
1001
- byteOffset = +byteOffset; // Coerce to Number.
1002
- if (numberIsNaN(byteOffset)) {
1003
- // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
1004
- byteOffset = dir ? 0 : (buffer.length - 1);
1005
- }
1006
-
1007
- // Normalize byteOffset: negative offsets start from the end of the buffer
1008
- if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
1009
- if (byteOffset >= buffer.length) {
1010
- if (dir) return -1
1011
- else byteOffset = buffer.length - 1;
1012
- } else if (byteOffset < 0) {
1013
- if (dir) byteOffset = 0;
1014
- else return -1
1015
- }
1016
-
1017
- // Normalize val
1018
- if (typeof val === 'string') {
1019
- val = Buffer.from(val, encoding);
1020
- }
1021
-
1022
- // Finally, search either indexOf (if dir is true) or lastIndexOf
1023
- if (Buffer.isBuffer(val)) {
1024
- // Special case: looking for empty string/buffer always fails
1025
- if (val.length === 0) {
1026
- return -1
1027
- }
1028
- return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
1029
- } else if (typeof val === 'number') {
1030
- val = val & 0xFF; // Search for a byte value [0-255]
1031
- if (typeof Uint8Array.prototype.indexOf === 'function') {
1032
- if (dir) {
1033
- return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
1034
- } else {
1035
- return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
1036
- }
1037
- }
1038
- return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
1039
- }
1040
-
1041
- throw new TypeError('val must be string, number or Buffer')
1042
- }
1043
-
1044
- function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
1045
- let indexSize = 1;
1046
- let arrLength = arr.length;
1047
- let valLength = val.length;
1048
-
1049
- if (encoding !== undefined) {
1050
- encoding = String(encoding).toLowerCase();
1051
- if (encoding === 'ucs2' || encoding === 'ucs-2' ||
1052
- encoding === 'utf16le' || encoding === 'utf-16le') {
1053
- if (arr.length < 2 || val.length < 2) {
1054
- return -1
1055
- }
1056
- indexSize = 2;
1057
- arrLength /= 2;
1058
- valLength /= 2;
1059
- byteOffset /= 2;
1060
- }
1061
- }
1062
-
1063
- function read (buf, i) {
1064
- if (indexSize === 1) {
1065
- return buf[i]
1066
- } else {
1067
- return buf.readUInt16BE(i * indexSize)
1068
- }
1069
- }
1070
-
1071
- let i;
1072
- if (dir) {
1073
- let foundIndex = -1;
1074
- for (i = byteOffset; i < arrLength; i++) {
1075
- if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
1076
- if (foundIndex === -1) foundIndex = i;
1077
- if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
1078
- } else {
1079
- if (foundIndex !== -1) i -= i - foundIndex;
1080
- foundIndex = -1;
1081
- }
1082
- }
1083
- } else {
1084
- if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
1085
- for (i = byteOffset; i >= 0; i--) {
1086
- let found = true;
1087
- for (let j = 0; j < valLength; j++) {
1088
- if (read(arr, i + j) !== read(val, j)) {
1089
- found = false;
1090
- break
1091
- }
1092
- }
1093
- if (found) return i
1094
- }
1095
- }
1096
-
1097
- return -1
1098
- }
1099
-
1100
- Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
1101
- return this.indexOf(val, byteOffset, encoding) !== -1
1102
- };
1103
-
1104
- Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
1105
- return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
1106
- };
1107
-
1108
- Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
1109
- return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
1110
- };
1111
-
1112
- function hexWrite (buf, string, offset, length) {
1113
- offset = Number(offset) || 0;
1114
- const remaining = buf.length - offset;
1115
- if (!length) {
1116
- length = remaining;
1117
- } else {
1118
- length = Number(length);
1119
- if (length > remaining) {
1120
- length = remaining;
1121
- }
1122
- }
1123
-
1124
- const strLen = string.length;
1125
-
1126
- if (length > strLen / 2) {
1127
- length = strLen / 2;
1128
- }
1129
- let i;
1130
- for (i = 0; i < length; ++i) {
1131
- const parsed = parseInt(string.substr(i * 2, 2), 16);
1132
- if (numberIsNaN(parsed)) return i
1133
- buf[offset + i] = parsed;
1134
- }
1135
- return i
1136
- }
1137
-
1138
- function utf8Write (buf, string, offset, length) {
1139
- return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
1140
- }
1141
-
1142
- function asciiWrite (buf, string, offset, length) {
1143
- return blitBuffer(asciiToBytes(string), buf, offset, length)
1144
- }
1145
-
1146
- function base64Write (buf, string, offset, length) {
1147
- return blitBuffer(base64ToBytes(string), buf, offset, length)
1148
- }
1149
-
1150
- function ucs2Write (buf, string, offset, length) {
1151
- return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
1152
- }
1153
-
1154
- Buffer.prototype.write = function write (string, offset, length, encoding) {
1155
- // Buffer#write(string)
1156
- if (offset === undefined) {
1157
- encoding = 'utf8';
1158
- length = this.length;
1159
- offset = 0;
1160
- // Buffer#write(string, encoding)
1161
- } else if (length === undefined && typeof offset === 'string') {
1162
- encoding = offset;
1163
- length = this.length;
1164
- offset = 0;
1165
- // Buffer#write(string, offset[, length][, encoding])
1166
- } else if (isFinite(offset)) {
1167
- offset = offset >>> 0;
1168
- if (isFinite(length)) {
1169
- length = length >>> 0;
1170
- if (encoding === undefined) encoding = 'utf8';
1171
- } else {
1172
- encoding = length;
1173
- length = undefined;
1174
- }
1175
- } else {
1176
- throw new Error(
1177
- 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
1178
- )
1179
- }
1180
-
1181
- const remaining = this.length - offset;
1182
- if (length === undefined || length > remaining) length = remaining;
1183
-
1184
- if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
1185
- throw new RangeError('Attempt to write outside buffer bounds')
1186
- }
1187
-
1188
- if (!encoding) encoding = 'utf8';
1189
-
1190
- let loweredCase = false;
1191
- for (;;) {
1192
- switch (encoding) {
1193
- case 'hex':
1194
- return hexWrite(this, string, offset, length)
1195
-
1196
- case 'utf8':
1197
- case 'utf-8':
1198
- return utf8Write(this, string, offset, length)
1199
-
1200
- case 'ascii':
1201
- case 'latin1':
1202
- case 'binary':
1203
- return asciiWrite(this, string, offset, length)
1204
-
1205
- case 'base64':
1206
- // Warning: maxLength not taken into account in base64Write
1207
- return base64Write(this, string, offset, length)
1208
-
1209
- case 'ucs2':
1210
- case 'ucs-2':
1211
- case 'utf16le':
1212
- case 'utf-16le':
1213
- return ucs2Write(this, string, offset, length)
1214
-
1215
- default:
1216
- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
1217
- encoding = ('' + encoding).toLowerCase();
1218
- loweredCase = true;
1219
- }
1220
- }
1221
- };
1222
-
1223
- Buffer.prototype.toJSON = function toJSON () {
1224
- return {
1225
- type: 'Buffer',
1226
- data: Array.prototype.slice.call(this._arr || this, 0)
1227
- }
1228
- };
1229
-
1230
- function base64Slice (buf, start, end) {
1231
- if (start === 0 && end === buf.length) {
1232
- return base64.fromByteArray(buf)
1233
- } else {
1234
- return base64.fromByteArray(buf.slice(start, end))
1235
- }
1236
- }
1237
-
1238
- function utf8Slice (buf, start, end) {
1239
- end = Math.min(buf.length, end);
1240
- const res = [];
1241
-
1242
- let i = start;
1243
- while (i < end) {
1244
- const firstByte = buf[i];
1245
- let codePoint = null;
1246
- let bytesPerSequence = (firstByte > 0xEF)
1247
- ? 4
1248
- : (firstByte > 0xDF)
1249
- ? 3
1250
- : (firstByte > 0xBF)
1251
- ? 2
1252
- : 1;
1253
-
1254
- if (i + bytesPerSequence <= end) {
1255
- let secondByte, thirdByte, fourthByte, tempCodePoint;
1256
-
1257
- switch (bytesPerSequence) {
1258
- case 1:
1259
- if (firstByte < 0x80) {
1260
- codePoint = firstByte;
1261
- }
1262
- break
1263
- case 2:
1264
- secondByte = buf[i + 1];
1265
- if ((secondByte & 0xC0) === 0x80) {
1266
- tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
1267
- if (tempCodePoint > 0x7F) {
1268
- codePoint = tempCodePoint;
1269
- }
1270
- }
1271
- break
1272
- case 3:
1273
- secondByte = buf[i + 1];
1274
- thirdByte = buf[i + 2];
1275
- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
1276
- tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
1277
- if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
1278
- codePoint = tempCodePoint;
1279
- }
1280
- }
1281
- break
1282
- case 4:
1283
- secondByte = buf[i + 1];
1284
- thirdByte = buf[i + 2];
1285
- fourthByte = buf[i + 3];
1286
- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
1287
- tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
1288
- if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
1289
- codePoint = tempCodePoint;
1290
- }
1291
- }
1292
- }
1293
- }
1294
-
1295
- if (codePoint === null) {
1296
- // we did not generate a valid codePoint so insert a
1297
- // replacement char (U+FFFD) and advance only 1 byte
1298
- codePoint = 0xFFFD;
1299
- bytesPerSequence = 1;
1300
- } else if (codePoint > 0xFFFF) {
1301
- // encode to utf16 (surrogate pair dance)
1302
- codePoint -= 0x10000;
1303
- res.push(codePoint >>> 10 & 0x3FF | 0xD800);
1304
- codePoint = 0xDC00 | codePoint & 0x3FF;
1305
- }
1306
-
1307
- res.push(codePoint);
1308
- i += bytesPerSequence;
1309
- }
1310
-
1311
- return decodeCodePointsArray(res)
1312
- }
1313
-
1314
- // Based on http://stackoverflow.com/a/22747272/680742, the browser with
1315
- // the lowest limit is Chrome, with 0x10000 args.
1316
- // We go 1 magnitude less, for safety
1317
- const MAX_ARGUMENTS_LENGTH = 0x1000;
1318
-
1319
- function decodeCodePointsArray (codePoints) {
1320
- const len = codePoints.length;
1321
- if (len <= MAX_ARGUMENTS_LENGTH) {
1322
- return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
1323
- }
1324
-
1325
- // Decode in chunks to avoid "call stack size exceeded".
1326
- let res = '';
1327
- let i = 0;
1328
- while (i < len) {
1329
- res += String.fromCharCode.apply(
1330
- String,
1331
- codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
1332
- );
1333
- }
1334
- return res
1335
- }
1336
-
1337
- function asciiSlice (buf, start, end) {
1338
- let ret = '';
1339
- end = Math.min(buf.length, end);
1340
-
1341
- for (let i = start; i < end; ++i) {
1342
- ret += String.fromCharCode(buf[i] & 0x7F);
1343
- }
1344
- return ret
1345
- }
1346
-
1347
- function latin1Slice (buf, start, end) {
1348
- let ret = '';
1349
- end = Math.min(buf.length, end);
1350
-
1351
- for (let i = start; i < end; ++i) {
1352
- ret += String.fromCharCode(buf[i]);
1353
- }
1354
- return ret
1355
- }
1356
-
1357
- function hexSlice (buf, start, end) {
1358
- const len = buf.length;
1359
-
1360
- if (!start || start < 0) start = 0;
1361
- if (!end || end < 0 || end > len) end = len;
1362
-
1363
- let out = '';
1364
- for (let i = start; i < end; ++i) {
1365
- out += hexSliceLookupTable[buf[i]];
1366
- }
1367
- return out
1368
- }
1369
-
1370
- function utf16leSlice (buf, start, end) {
1371
- const bytes = buf.slice(start, end);
1372
- let res = '';
1373
- // If bytes.length is odd, the last 8 bits must be ignored (same as node.js)
1374
- for (let i = 0; i < bytes.length - 1; i += 2) {
1375
- res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256));
1376
- }
1377
- return res
1378
- }
1379
-
1380
- Buffer.prototype.slice = function slice (start, end) {
1381
- const len = this.length;
1382
- start = ~~start;
1383
- end = end === undefined ? len : ~~end;
1384
-
1385
- if (start < 0) {
1386
- start += len;
1387
- if (start < 0) start = 0;
1388
- } else if (start > len) {
1389
- start = len;
1390
- }
1391
-
1392
- if (end < 0) {
1393
- end += len;
1394
- if (end < 0) end = 0;
1395
- } else if (end > len) {
1396
- end = len;
1397
- }
1398
-
1399
- if (end < start) end = start;
1400
-
1401
- const newBuf = this.subarray(start, end);
1402
- // Return an augmented `Uint8Array` instance
1403
- Object.setPrototypeOf(newBuf, Buffer.prototype);
1404
-
1405
- return newBuf
1406
- };
1407
-
1408
- /*
1409
- * Need to make sure that buffer isn't trying to write out of bounds.
1410
- */
1411
- function checkOffset (offset, ext, length) {
1412
- if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
1413
- if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
1414
- }
1415
-
1416
- Buffer.prototype.readUintLE =
1417
- Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
1418
- offset = offset >>> 0;
1419
- byteLength = byteLength >>> 0;
1420
- if (!noAssert) checkOffset(offset, byteLength, this.length);
1421
-
1422
- let val = this[offset];
1423
- let mul = 1;
1424
- let i = 0;
1425
- while (++i < byteLength && (mul *= 0x100)) {
1426
- val += this[offset + i] * mul;
1427
- }
1428
-
1429
- return val
1430
- };
1431
-
1432
- Buffer.prototype.readUintBE =
1433
- Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
1434
- offset = offset >>> 0;
1435
- byteLength = byteLength >>> 0;
1436
- if (!noAssert) {
1437
- checkOffset(offset, byteLength, this.length);
1438
- }
1439
-
1440
- let val = this[offset + --byteLength];
1441
- let mul = 1;
1442
- while (byteLength > 0 && (mul *= 0x100)) {
1443
- val += this[offset + --byteLength] * mul;
1444
- }
1445
-
1446
- return val
1447
- };
1448
-
1449
- Buffer.prototype.readUint8 =
1450
- Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
1451
- offset = offset >>> 0;
1452
- if (!noAssert) checkOffset(offset, 1, this.length);
1453
- return this[offset]
1454
- };
1455
-
1456
- Buffer.prototype.readUint16LE =
1457
- Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
1458
- offset = offset >>> 0;
1459
- if (!noAssert) checkOffset(offset, 2, this.length);
1460
- return this[offset] | (this[offset + 1] << 8)
1461
- };
1462
-
1463
- Buffer.prototype.readUint16BE =
1464
- Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
1465
- offset = offset >>> 0;
1466
- if (!noAssert) checkOffset(offset, 2, this.length);
1467
- return (this[offset] << 8) | this[offset + 1]
1468
- };
1469
-
1470
- Buffer.prototype.readUint32LE =
1471
- Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
1472
- offset = offset >>> 0;
1473
- if (!noAssert) checkOffset(offset, 4, this.length);
1474
-
1475
- return ((this[offset]) |
1476
- (this[offset + 1] << 8) |
1477
- (this[offset + 2] << 16)) +
1478
- (this[offset + 3] * 0x1000000)
1479
- };
1480
-
1481
- Buffer.prototype.readUint32BE =
1482
- Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
1483
- offset = offset >>> 0;
1484
- if (!noAssert) checkOffset(offset, 4, this.length);
1485
-
1486
- return (this[offset] * 0x1000000) +
1487
- ((this[offset + 1] << 16) |
1488
- (this[offset + 2] << 8) |
1489
- this[offset + 3])
1490
- };
1491
-
1492
- Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) {
1493
- offset = offset >>> 0;
1494
- validateNumber(offset, 'offset');
1495
- const first = this[offset];
1496
- const last = this[offset + 7];
1497
- if (first === undefined || last === undefined) {
1498
- boundsError(offset, this.length - 8);
1499
- }
1500
-
1501
- const lo = first +
1502
- this[++offset] * 2 ** 8 +
1503
- this[++offset] * 2 ** 16 +
1504
- this[++offset] * 2 ** 24;
1505
-
1506
- const hi = this[++offset] +
1507
- this[++offset] * 2 ** 8 +
1508
- this[++offset] * 2 ** 16 +
1509
- last * 2 ** 24;
1510
-
1511
- return BigInt(lo) + (BigInt(hi) << BigInt(32))
1512
- });
1513
-
1514
- Buffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE (offset) {
1515
- offset = offset >>> 0;
1516
- validateNumber(offset, 'offset');
1517
- const first = this[offset];
1518
- const last = this[offset + 7];
1519
- if (first === undefined || last === undefined) {
1520
- boundsError(offset, this.length - 8);
1521
- }
1522
-
1523
- const hi = first * 2 ** 24 +
1524
- this[++offset] * 2 ** 16 +
1525
- this[++offset] * 2 ** 8 +
1526
- this[++offset];
1527
-
1528
- const lo = this[++offset] * 2 ** 24 +
1529
- this[++offset] * 2 ** 16 +
1530
- this[++offset] * 2 ** 8 +
1531
- last;
1532
-
1533
- return (BigInt(hi) << BigInt(32)) + BigInt(lo)
1534
- });
1535
-
1536
- Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
1537
- offset = offset >>> 0;
1538
- byteLength = byteLength >>> 0;
1539
- if (!noAssert) checkOffset(offset, byteLength, this.length);
1540
-
1541
- let val = this[offset];
1542
- let mul = 1;
1543
- let i = 0;
1544
- while (++i < byteLength && (mul *= 0x100)) {
1545
- val += this[offset + i] * mul;
1546
- }
1547
- mul *= 0x80;
1548
-
1549
- if (val >= mul) val -= Math.pow(2, 8 * byteLength);
1550
-
1551
- return val
1552
- };
1553
-
1554
- Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
1555
- offset = offset >>> 0;
1556
- byteLength = byteLength >>> 0;
1557
- if (!noAssert) checkOffset(offset, byteLength, this.length);
1558
-
1559
- let i = byteLength;
1560
- let mul = 1;
1561
- let val = this[offset + --i];
1562
- while (i > 0 && (mul *= 0x100)) {
1563
- val += this[offset + --i] * mul;
1564
- }
1565
- mul *= 0x80;
1566
-
1567
- if (val >= mul) val -= Math.pow(2, 8 * byteLength);
1568
-
1569
- return val
1570
- };
1571
-
1572
- Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
1573
- offset = offset >>> 0;
1574
- if (!noAssert) checkOffset(offset, 1, this.length);
1575
- if (!(this[offset] & 0x80)) return (this[offset])
1576
- return ((0xff - this[offset] + 1) * -1)
1577
- };
1578
-
1579
- Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
1580
- offset = offset >>> 0;
1581
- if (!noAssert) checkOffset(offset, 2, this.length);
1582
- const val = this[offset] | (this[offset + 1] << 8);
1583
- return (val & 0x8000) ? val | 0xFFFF0000 : val
1584
- };
1585
-
1586
- Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
1587
- offset = offset >>> 0;
1588
- if (!noAssert) checkOffset(offset, 2, this.length);
1589
- const val = this[offset + 1] | (this[offset] << 8);
1590
- return (val & 0x8000) ? val | 0xFFFF0000 : val
1591
- };
1592
-
1593
- Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
1594
- offset = offset >>> 0;
1595
- if (!noAssert) checkOffset(offset, 4, this.length);
1596
-
1597
- return (this[offset]) |
1598
- (this[offset + 1] << 8) |
1599
- (this[offset + 2] << 16) |
1600
- (this[offset + 3] << 24)
1601
- };
1602
-
1603
- Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
1604
- offset = offset >>> 0;
1605
- if (!noAssert) checkOffset(offset, 4, this.length);
1606
-
1607
- return (this[offset] << 24) |
1608
- (this[offset + 1] << 16) |
1609
- (this[offset + 2] << 8) |
1610
- (this[offset + 3])
1611
- };
1612
-
1613
- Buffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE (offset) {
1614
- offset = offset >>> 0;
1615
- validateNumber(offset, 'offset');
1616
- const first = this[offset];
1617
- const last = this[offset + 7];
1618
- if (first === undefined || last === undefined) {
1619
- boundsError(offset, this.length - 8);
1620
- }
1621
-
1622
- const val = this[offset + 4] +
1623
- this[offset + 5] * 2 ** 8 +
1624
- this[offset + 6] * 2 ** 16 +
1625
- (last << 24); // Overflow
1626
-
1627
- return (BigInt(val) << BigInt(32)) +
1628
- BigInt(first +
1629
- this[++offset] * 2 ** 8 +
1630
- this[++offset] * 2 ** 16 +
1631
- this[++offset] * 2 ** 24)
1632
- });
1633
-
1634
- Buffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE (offset) {
1635
- offset = offset >>> 0;
1636
- validateNumber(offset, 'offset');
1637
- const first = this[offset];
1638
- const last = this[offset + 7];
1639
- if (first === undefined || last === undefined) {
1640
- boundsError(offset, this.length - 8);
1641
- }
1642
-
1643
- const val = (first << 24) + // Overflow
1644
- this[++offset] * 2 ** 16 +
1645
- this[++offset] * 2 ** 8 +
1646
- this[++offset];
1647
-
1648
- return (BigInt(val) << BigInt(32)) +
1649
- BigInt(this[++offset] * 2 ** 24 +
1650
- this[++offset] * 2 ** 16 +
1651
- this[++offset] * 2 ** 8 +
1652
- last)
1653
- });
1654
-
1655
- Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
1656
- offset = offset >>> 0;
1657
- if (!noAssert) checkOffset(offset, 4, this.length);
1658
- return ieee754.read(this, offset, true, 23, 4)
1659
- };
1660
-
1661
- Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
1662
- offset = offset >>> 0;
1663
- if (!noAssert) checkOffset(offset, 4, this.length);
1664
- return ieee754.read(this, offset, false, 23, 4)
1665
- };
1666
-
1667
- Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
1668
- offset = offset >>> 0;
1669
- if (!noAssert) checkOffset(offset, 8, this.length);
1670
- return ieee754.read(this, offset, true, 52, 8)
1671
- };
1672
-
1673
- Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
1674
- offset = offset >>> 0;
1675
- if (!noAssert) checkOffset(offset, 8, this.length);
1676
- return ieee754.read(this, offset, false, 52, 8)
1677
- };
1678
-
1679
- function checkInt (buf, value, offset, ext, max, min) {
1680
- if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
1681
- if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
1682
- if (offset + ext > buf.length) throw new RangeError('Index out of range')
1683
- }
1684
-
1685
- Buffer.prototype.writeUintLE =
1686
- Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
1687
- value = +value;
1688
- offset = offset >>> 0;
1689
- byteLength = byteLength >>> 0;
1690
- if (!noAssert) {
1691
- const maxBytes = Math.pow(2, 8 * byteLength) - 1;
1692
- checkInt(this, value, offset, byteLength, maxBytes, 0);
1693
- }
1694
-
1695
- let mul = 1;
1696
- let i = 0;
1697
- this[offset] = value & 0xFF;
1698
- while (++i < byteLength && (mul *= 0x100)) {
1699
- this[offset + i] = (value / mul) & 0xFF;
1700
- }
1701
-
1702
- return offset + byteLength
1703
- };
1704
-
1705
- Buffer.prototype.writeUintBE =
1706
- Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
1707
- value = +value;
1708
- offset = offset >>> 0;
1709
- byteLength = byteLength >>> 0;
1710
- if (!noAssert) {
1711
- const maxBytes = Math.pow(2, 8 * byteLength) - 1;
1712
- checkInt(this, value, offset, byteLength, maxBytes, 0);
1713
- }
1714
-
1715
- let i = byteLength - 1;
1716
- let mul = 1;
1717
- this[offset + i] = value & 0xFF;
1718
- while (--i >= 0 && (mul *= 0x100)) {
1719
- this[offset + i] = (value / mul) & 0xFF;
1720
- }
1721
-
1722
- return offset + byteLength
1723
- };
1724
-
1725
- Buffer.prototype.writeUint8 =
1726
- Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
1727
- value = +value;
1728
- offset = offset >>> 0;
1729
- if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
1730
- this[offset] = (value & 0xff);
1731
- return offset + 1
1732
- };
1733
-
1734
- Buffer.prototype.writeUint16LE =
1735
- Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
1736
- value = +value;
1737
- offset = offset >>> 0;
1738
- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
1739
- this[offset] = (value & 0xff);
1740
- this[offset + 1] = (value >>> 8);
1741
- return offset + 2
1742
- };
1743
-
1744
- Buffer.prototype.writeUint16BE =
1745
- Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
1746
- value = +value;
1747
- offset = offset >>> 0;
1748
- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
1749
- this[offset] = (value >>> 8);
1750
- this[offset + 1] = (value & 0xff);
1751
- return offset + 2
1752
- };
1753
-
1754
- Buffer.prototype.writeUint32LE =
1755
- Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
1756
- value = +value;
1757
- offset = offset >>> 0;
1758
- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
1759
- this[offset + 3] = (value >>> 24);
1760
- this[offset + 2] = (value >>> 16);
1761
- this[offset + 1] = (value >>> 8);
1762
- this[offset] = (value & 0xff);
1763
- return offset + 4
1764
- };
1765
-
1766
- Buffer.prototype.writeUint32BE =
1767
- Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
1768
- value = +value;
1769
- offset = offset >>> 0;
1770
- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
1771
- this[offset] = (value >>> 24);
1772
- this[offset + 1] = (value >>> 16);
1773
- this[offset + 2] = (value >>> 8);
1774
- this[offset + 3] = (value & 0xff);
1775
- return offset + 4
1776
- };
1777
-
1778
- function wrtBigUInt64LE (buf, value, offset, min, max) {
1779
- checkIntBI(value, min, max, buf, offset, 7);
1780
-
1781
- let lo = Number(value & BigInt(0xffffffff));
1782
- buf[offset++] = lo;
1783
- lo = lo >> 8;
1784
- buf[offset++] = lo;
1785
- lo = lo >> 8;
1786
- buf[offset++] = lo;
1787
- lo = lo >> 8;
1788
- buf[offset++] = lo;
1789
- let hi = Number(value >> BigInt(32) & BigInt(0xffffffff));
1790
- buf[offset++] = hi;
1791
- hi = hi >> 8;
1792
- buf[offset++] = hi;
1793
- hi = hi >> 8;
1794
- buf[offset++] = hi;
1795
- hi = hi >> 8;
1796
- buf[offset++] = hi;
1797
- return offset
1798
- }
1799
-
1800
- function wrtBigUInt64BE (buf, value, offset, min, max) {
1801
- checkIntBI(value, min, max, buf, offset, 7);
1802
-
1803
- let lo = Number(value & BigInt(0xffffffff));
1804
- buf[offset + 7] = lo;
1805
- lo = lo >> 8;
1806
- buf[offset + 6] = lo;
1807
- lo = lo >> 8;
1808
- buf[offset + 5] = lo;
1809
- lo = lo >> 8;
1810
- buf[offset + 4] = lo;
1811
- let hi = Number(value >> BigInt(32) & BigInt(0xffffffff));
1812
- buf[offset + 3] = hi;
1813
- hi = hi >> 8;
1814
- buf[offset + 2] = hi;
1815
- hi = hi >> 8;
1816
- buf[offset + 1] = hi;
1817
- hi = hi >> 8;
1818
- buf[offset] = hi;
1819
- return offset + 8
1820
- }
1821
-
1822
- Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) {
1823
- return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
1824
- });
1825
-
1826
- Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) {
1827
- return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
1828
- });
1829
-
1830
- Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
1831
- value = +value;
1832
- offset = offset >>> 0;
1833
- if (!noAssert) {
1834
- const limit = Math.pow(2, (8 * byteLength) - 1);
1835
-
1836
- checkInt(this, value, offset, byteLength, limit - 1, -limit);
1837
- }
1838
-
1839
- let i = 0;
1840
- let mul = 1;
1841
- let sub = 0;
1842
- this[offset] = value & 0xFF;
1843
- while (++i < byteLength && (mul *= 0x100)) {
1844
- if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
1845
- sub = 1;
1846
- }
1847
- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
1848
- }
1849
-
1850
- return offset + byteLength
1851
- };
1852
-
1853
- Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
1854
- value = +value;
1855
- offset = offset >>> 0;
1856
- if (!noAssert) {
1857
- const limit = Math.pow(2, (8 * byteLength) - 1);
1858
-
1859
- checkInt(this, value, offset, byteLength, limit - 1, -limit);
1860
- }
1861
-
1862
- let i = byteLength - 1;
1863
- let mul = 1;
1864
- let sub = 0;
1865
- this[offset + i] = value & 0xFF;
1866
- while (--i >= 0 && (mul *= 0x100)) {
1867
- if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
1868
- sub = 1;
1869
- }
1870
- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
1871
- }
1872
-
1873
- return offset + byteLength
1874
- };
1875
-
1876
- Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
1877
- value = +value;
1878
- offset = offset >>> 0;
1879
- if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -128);
1880
- if (value < 0) value = 0xff + value + 1;
1881
- this[offset] = (value & 0xff);
1882
- return offset + 1
1883
- };
1884
-
1885
- Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
1886
- value = +value;
1887
- offset = offset >>> 0;
1888
- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768);
1889
- this[offset] = (value & 0xff);
1890
- this[offset + 1] = (value >>> 8);
1891
- return offset + 2
1892
- };
1893
-
1894
- Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
1895
- value = +value;
1896
- offset = offset >>> 0;
1897
- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768);
1898
- this[offset] = (value >>> 8);
1899
- this[offset + 1] = (value & 0xff);
1900
- return offset + 2
1901
- };
1902
-
1903
- Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
1904
- value = +value;
1905
- offset = offset >>> 0;
1906
- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);
1907
- this[offset] = (value & 0xff);
1908
- this[offset + 1] = (value >>> 8);
1909
- this[offset + 2] = (value >>> 16);
1910
- this[offset + 3] = (value >>> 24);
1911
- return offset + 4
1912
- };
1913
-
1914
- Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
1915
- value = +value;
1916
- offset = offset >>> 0;
1917
- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);
1918
- if (value < 0) value = 0xffffffff + value + 1;
1919
- this[offset] = (value >>> 24);
1920
- this[offset + 1] = (value >>> 16);
1921
- this[offset + 2] = (value >>> 8);
1922
- this[offset + 3] = (value & 0xff);
1923
- return offset + 4
1924
- };
1925
-
1926
- Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) {
1927
- return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
1928
- });
1929
-
1930
- Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) {
1931
- return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
1932
- });
1933
-
1934
- function checkIEEE754 (buf, value, offset, ext, max, min) {
1935
- if (offset + ext > buf.length) throw new RangeError('Index out of range')
1936
- if (offset < 0) throw new RangeError('Index out of range')
1937
- }
1938
-
1939
- function writeFloat (buf, value, offset, littleEndian, noAssert) {
1940
- value = +value;
1941
- offset = offset >>> 0;
1942
- if (!noAssert) {
1943
- checkIEEE754(buf, value, offset, 4);
1944
- }
1945
- ieee754.write(buf, value, offset, littleEndian, 23, 4);
1946
- return offset + 4
1947
- }
1948
-
1949
- Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
1950
- return writeFloat(this, value, offset, true, noAssert)
1951
- };
1952
-
1953
- Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
1954
- return writeFloat(this, value, offset, false, noAssert)
1955
- };
1956
-
1957
- function writeDouble (buf, value, offset, littleEndian, noAssert) {
1958
- value = +value;
1959
- offset = offset >>> 0;
1960
- if (!noAssert) {
1961
- checkIEEE754(buf, value, offset, 8);
1962
- }
1963
- ieee754.write(buf, value, offset, littleEndian, 52, 8);
1964
- return offset + 8
1965
- }
1966
-
1967
- Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
1968
- return writeDouble(this, value, offset, true, noAssert)
1969
- };
1970
-
1971
- Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
1972
- return writeDouble(this, value, offset, false, noAssert)
1973
- };
1974
-
1975
- // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
1976
- Buffer.prototype.copy = function copy (target, targetStart, start, end) {
1977
- if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
1978
- if (!start) start = 0;
1979
- if (!end && end !== 0) end = this.length;
1980
- if (targetStart >= target.length) targetStart = target.length;
1981
- if (!targetStart) targetStart = 0;
1982
- if (end > 0 && end < start) end = start;
1983
-
1984
- // Copy 0 bytes; we're done
1985
- if (end === start) return 0
1986
- if (target.length === 0 || this.length === 0) return 0
1987
-
1988
- // Fatal error conditions
1989
- if (targetStart < 0) {
1990
- throw new RangeError('targetStart out of bounds')
1991
- }
1992
- if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
1993
- if (end < 0) throw new RangeError('sourceEnd out of bounds')
1994
-
1995
- // Are we oob?
1996
- if (end > this.length) end = this.length;
1997
- if (target.length - targetStart < end - start) {
1998
- end = target.length - targetStart + start;
1999
- }
2000
-
2001
- const len = end - start;
2002
-
2003
- if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
2004
- // Use built-in when available, missing from IE11
2005
- this.copyWithin(targetStart, start, end);
2006
- } else {
2007
- Uint8Array.prototype.set.call(
2008
- target,
2009
- this.subarray(start, end),
2010
- targetStart
2011
- );
2012
- }
2013
-
2014
- return len
2015
- };
2016
-
2017
- // Usage:
2018
- // buffer.fill(number[, offset[, end]])
2019
- // buffer.fill(buffer[, offset[, end]])
2020
- // buffer.fill(string[, offset[, end]][, encoding])
2021
- Buffer.prototype.fill = function fill (val, start, end, encoding) {
2022
- // Handle string cases:
2023
- if (typeof val === 'string') {
2024
- if (typeof start === 'string') {
2025
- encoding = start;
2026
- start = 0;
2027
- end = this.length;
2028
- } else if (typeof end === 'string') {
2029
- encoding = end;
2030
- end = this.length;
2031
- }
2032
- if (encoding !== undefined && typeof encoding !== 'string') {
2033
- throw new TypeError('encoding must be a string')
2034
- }
2035
- if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
2036
- throw new TypeError('Unknown encoding: ' + encoding)
2037
- }
2038
- if (val.length === 1) {
2039
- const code = val.charCodeAt(0);
2040
- if ((encoding === 'utf8' && code < 128) ||
2041
- encoding === 'latin1') {
2042
- // Fast path: If `val` fits into a single byte, use that numeric value.
2043
- val = code;
2044
- }
2045
- }
2046
- } else if (typeof val === 'number') {
2047
- val = val & 255;
2048
- } else if (typeof val === 'boolean') {
2049
- val = Number(val);
2050
- }
2051
-
2052
- // Invalid ranges are not set to a default, so can range check early.
2053
- if (start < 0 || this.length < start || this.length < end) {
2054
- throw new RangeError('Out of range index')
2055
- }
2056
-
2057
- if (end <= start) {
2058
- return this
2059
- }
2060
-
2061
- start = start >>> 0;
2062
- end = end === undefined ? this.length : end >>> 0;
2063
-
2064
- if (!val) val = 0;
2065
-
2066
- let i;
2067
- if (typeof val === 'number') {
2068
- for (i = start; i < end; ++i) {
2069
- this[i] = val;
2070
- }
2071
- } else {
2072
- const bytes = Buffer.isBuffer(val)
2073
- ? val
2074
- : Buffer.from(val, encoding);
2075
- const len = bytes.length;
2076
- if (len === 0) {
2077
- throw new TypeError('The value "' + val +
2078
- '" is invalid for argument "value"')
2079
- }
2080
- for (i = 0; i < end - start; ++i) {
2081
- this[i + start] = bytes[i % len];
2082
- }
2083
- }
2084
-
2085
- return this
2086
- };
2087
-
2088
- // CUSTOM ERRORS
2089
- // =============
2090
-
2091
- // Simplified versions from Node, changed for Buffer-only usage
2092
- const errors = {};
2093
- function E (sym, getMessage, Base) {
2094
- errors[sym] = class NodeError extends Base {
2095
- constructor () {
2096
- super();
2097
-
2098
- Object.defineProperty(this, 'message', {
2099
- value: getMessage.apply(this, arguments),
2100
- writable: true,
2101
- configurable: true
2102
- });
2103
-
2104
- // Add the error code to the name to include it in the stack trace.
2105
- this.name = `${this.name} [${sym}]`;
2106
- // Access the stack to generate the error message including the error code
2107
- // from the name.
2108
- this.stack; // eslint-disable-line no-unused-expressions
2109
- // Reset the name to the actual name.
2110
- delete this.name;
2111
- }
2112
-
2113
- get code () {
2114
- return sym
2115
- }
2116
-
2117
- set code (value) {
2118
- Object.defineProperty(this, 'code', {
2119
- configurable: true,
2120
- enumerable: true,
2121
- value,
2122
- writable: true
2123
- });
2124
- }
2125
-
2126
- toString () {
2127
- return `${this.name} [${sym}]: ${this.message}`
2128
- }
2129
- };
2130
- }
2131
-
2132
- E('ERR_BUFFER_OUT_OF_BOUNDS',
2133
- function (name) {
2134
- if (name) {
2135
- return `${name} is outside of buffer bounds`
2136
- }
2137
-
2138
- return 'Attempt to access memory outside buffer bounds'
2139
- }, RangeError);
2140
- E('ERR_INVALID_ARG_TYPE',
2141
- function (name, actual) {
2142
- return `The "${name}" argument must be of type number. Received type ${typeof actual}`
2143
- }, TypeError);
2144
- E('ERR_OUT_OF_RANGE',
2145
- function (str, range, input) {
2146
- let msg = `The value of "${str}" is out of range.`;
2147
- let received = input;
2148
- if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
2149
- received = addNumericalSeparator(String(input));
2150
- } else if (typeof input === 'bigint') {
2151
- received = String(input);
2152
- if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
2153
- received = addNumericalSeparator(received);
2154
- }
2155
- received += 'n';
2156
- }
2157
- msg += ` It must be ${range}. Received ${received}`;
2158
- return msg
2159
- }, RangeError);
2160
-
2161
- function addNumericalSeparator (val) {
2162
- let res = '';
2163
- let i = val.length;
2164
- const start = val[0] === '-' ? 1 : 0;
2165
- for (; i >= start + 4; i -= 3) {
2166
- res = `_${val.slice(i - 3, i)}${res}`;
2167
- }
2168
- return `${val.slice(0, i)}${res}`
2169
- }
2170
-
2171
- // CHECK FUNCTIONS
2172
- // ===============
2173
-
2174
- function checkBounds (buf, offset, byteLength) {
2175
- validateNumber(offset, 'offset');
2176
- if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {
2177
- boundsError(offset, buf.length - (byteLength + 1));
2178
- }
2179
- }
2180
-
2181
- function checkIntBI (value, min, max, buf, offset, byteLength) {
2182
- if (value > max || value < min) {
2183
- const n = typeof min === 'bigint' ? 'n' : '';
2184
- let range;
2185
- {
2186
- if (min === 0 || min === BigInt(0)) {
2187
- range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`;
2188
- } else {
2189
- range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +
2190
- `${(byteLength + 1) * 8 - 1}${n}`;
2191
- }
2192
- }
2193
- throw new errors.ERR_OUT_OF_RANGE('value', range, value)
2194
- }
2195
- checkBounds(buf, offset, byteLength);
2196
- }
2197
-
2198
- function validateNumber (value, name) {
2199
- if (typeof value !== 'number') {
2200
- throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)
2201
- }
2202
- }
2203
-
2204
- function boundsError (value, length, type) {
2205
- if (Math.floor(value) !== value) {
2206
- validateNumber(value, type);
2207
- throw new errors.ERR_OUT_OF_RANGE('offset', 'an integer', value)
2208
- }
2209
-
2210
- if (length < 0) {
2211
- throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()
2212
- }
2213
-
2214
- throw new errors.ERR_OUT_OF_RANGE('offset',
2215
- `>= ${0} and <= ${length}`,
2216
- value)
2217
- }
2218
-
2219
- // HELPER FUNCTIONS
2220
- // ================
2221
-
2222
- const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
2223
-
2224
- function base64clean (str) {
2225
- // Node takes equal signs as end of the Base64 encoding
2226
- str = str.split('=')[0];
2227
- // Node strips out invalid characters like \n and \t from the string, base64-js does not
2228
- str = str.trim().replace(INVALID_BASE64_RE, '');
2229
- // Node converts strings with length < 2 to ''
2230
- if (str.length < 2) return ''
2231
- // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
2232
- while (str.length % 4 !== 0) {
2233
- str = str + '=';
2234
- }
2235
- return str
2236
- }
2237
-
2238
- function utf8ToBytes (string, units) {
2239
- units = units || Infinity;
2240
- let codePoint;
2241
- const length = string.length;
2242
- let leadSurrogate = null;
2243
- const bytes = [];
2244
-
2245
- for (let i = 0; i < length; ++i) {
2246
- codePoint = string.charCodeAt(i);
2247
-
2248
- // is surrogate component
2249
- if (codePoint > 0xD7FF && codePoint < 0xE000) {
2250
- // last char was a lead
2251
- if (!leadSurrogate) {
2252
- // no lead yet
2253
- if (codePoint > 0xDBFF) {
2254
- // unexpected trail
2255
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
2256
- continue
2257
- } else if (i + 1 === length) {
2258
- // unpaired lead
2259
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
2260
- continue
2261
- }
2262
-
2263
- // valid lead
2264
- leadSurrogate = codePoint;
2265
-
2266
- continue
2267
- }
2268
-
2269
- // 2 leads in a row
2270
- if (codePoint < 0xDC00) {
2271
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
2272
- leadSurrogate = codePoint;
2273
- continue
2274
- }
2275
-
2276
- // valid surrogate pair
2277
- codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
2278
- } else if (leadSurrogate) {
2279
- // valid bmp char, but last char was a lead
2280
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
2281
- }
2282
-
2283
- leadSurrogate = null;
2284
-
2285
- // encode utf8
2286
- if (codePoint < 0x80) {
2287
- if ((units -= 1) < 0) break
2288
- bytes.push(codePoint);
2289
- } else if (codePoint < 0x800) {
2290
- if ((units -= 2) < 0) break
2291
- bytes.push(
2292
- codePoint >> 0x6 | 0xC0,
2293
- codePoint & 0x3F | 0x80
2294
- );
2295
- } else if (codePoint < 0x10000) {
2296
- if ((units -= 3) < 0) break
2297
- bytes.push(
2298
- codePoint >> 0xC | 0xE0,
2299
- codePoint >> 0x6 & 0x3F | 0x80,
2300
- codePoint & 0x3F | 0x80
2301
- );
2302
- } else if (codePoint < 0x110000) {
2303
- if ((units -= 4) < 0) break
2304
- bytes.push(
2305
- codePoint >> 0x12 | 0xF0,
2306
- codePoint >> 0xC & 0x3F | 0x80,
2307
- codePoint >> 0x6 & 0x3F | 0x80,
2308
- codePoint & 0x3F | 0x80
2309
- );
2310
- } else {
2311
- throw new Error('Invalid code point')
2312
- }
2313
- }
2314
-
2315
- return bytes
2316
- }
2317
-
2318
- function asciiToBytes (str) {
2319
- const byteArray = [];
2320
- for (let i = 0; i < str.length; ++i) {
2321
- // Node's code seems to be doing this and not & 0x7F..
2322
- byteArray.push(str.charCodeAt(i) & 0xFF);
2323
- }
2324
- return byteArray
2325
- }
2326
-
2327
- function utf16leToBytes (str, units) {
2328
- let c, hi, lo;
2329
- const byteArray = [];
2330
- for (let i = 0; i < str.length; ++i) {
2331
- if ((units -= 2) < 0) break
2332
-
2333
- c = str.charCodeAt(i);
2334
- hi = c >> 8;
2335
- lo = c % 256;
2336
- byteArray.push(lo);
2337
- byteArray.push(hi);
2338
- }
2339
-
2340
- return byteArray
2341
- }
2342
-
2343
- function base64ToBytes (str) {
2344
- return base64.toByteArray(base64clean(str))
2345
- }
2346
-
2347
- function blitBuffer (src, dst, offset, length) {
2348
- let i;
2349
- for (i = 0; i < length; ++i) {
2350
- if ((i + offset >= dst.length) || (i >= src.length)) break
2351
- dst[i + offset] = src[i];
2352
- }
2353
- return i
2354
- }
2355
-
2356
- // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
2357
- // the `instanceof` check but they should be treated as of that type.
2358
- // See: https://github.com/feross/buffer/issues/166
2359
- function isInstance (obj, type) {
2360
- return obj instanceof type ||
2361
- (obj != null && obj.constructor != null && obj.constructor.name != null &&
2362
- obj.constructor.name === type.name)
2363
- }
2364
- function numberIsNaN (obj) {
2365
- // For IE11 support
2366
- return obj !== obj // eslint-disable-line no-self-compare
2367
- }
2368
-
2369
- // Create lookup table for `toString('hex')`
2370
- // See: https://github.com/feross/buffer/issues/219
2371
- const hexSliceLookupTable = (function () {
2372
- const alphabet = '0123456789abcdef';
2373
- const table = new Array(256);
2374
- for (let i = 0; i < 16; ++i) {
2375
- const i16 = i * 16;
2376
- for (let j = 0; j < 16; ++j) {
2377
- table[i16 + j] = alphabet[i] + alphabet[j];
2378
- }
2379
- }
2380
- return table
2381
- })();
2382
-
2383
- // Return not function with Error if BigInt not supported
2384
- function defineBigIntMethod (fn) {
2385
- return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn
2386
- }
2387
-
2388
- function BufferBigIntNotDefined () {
2389
- throw new Error('BigInt not supported')
2390
- }
2391
- } (buffer));
2392
- return buffer;
2393
- }
2394
-
2395
- var bufferExports = requireBuffer();
2396
-
2397
- const encoder$3 = new TextEncoder();
2398
- const decoder$5 = new TextDecoder();
2399
-
2400
-
2401
- const NB = numberBuffer;
2402
- /**
2403
- * Create a typed buffer with a specific type and initial value
2404
- * @param {string} type - Buffer type (8, 16, 32, F, N)
2405
- * @param {number} [initValue=0] - Initial value for the buffer
2406
- * @returns {Buffer} Typed buffer
2407
- * @throws {TypeError} If invalid type or initValue is provided
2408
- */
2409
- function numberBuffer(type, initValue = 0) {
2410
- let buffer;
2411
- if (type === undefined || typeof type !== 'string' || typeof initValue !== 'number') {
2412
- throw TypeError('invlaid init variablie type name. ')
2413
- }
2414
- type = type.toUpperCase();
2415
-
2416
- if (type.includes('8')) {
2417
- buffer = bufferExports.Buffer.alloc(1);
2418
- if (type.includes('I')) buffer.writeInt8(initValue);
2419
- else buffer.writeUint8(initValue);
2420
- } else if (type.includes('16')) {
2421
- buffer = bufferExports.Buffer.alloc(2);
2422
- if (type.includes('I')) {
2423
- if (type.includes('L')) buffer.writeInt16LE(initValue);
2424
- else buffer.writeInt16BE(initValue);
2425
- } else {
2426
- if (type.includes('L')) buffer.writeUint16LE(initValue);
2427
- else buffer.writeUint16BE(initValue);
2428
- }
2429
- } else if (type.includes('32')) {
2430
- buffer = bufferExports.Buffer.alloc(4);
2431
- if (type.includes('I')) {
2432
- if (type.includes('L')) buffer.writeInt32LE(initValue);
2433
- else buffer.writeInt32BE(initValue);
2434
- } else {
2435
- if (type.includes('L')) buffer.writeUint32LE(initValue);
2436
- else buffer.writeUint32BE(initValue);
2437
- }
2438
- } else if (type.includes('F')) {
2439
- buffer = bufferExports.Buffer.alloc(4);
2440
- if (type.includes('L')) {
2441
- buffer.writeFloatLE(initValue);
2442
- } else {
2443
- buffer.writeFloatBE(initValue);
2444
- }
2445
- } else if (type.includes('N')) { // number as string
2446
- buffer = bufferExports.Buffer.from(String(initValue));
2447
- } else {
2448
- console.log(`invalid type: ${type} or initvalue: ${initValue}`);
2449
- }
2450
- return buffer
2451
- }
2452
-
2453
-
2454
- const MB$1 = metaBuffer;
2455
- /**
2456
- * Create a meta buffer with name, type, and initial value
2457
- * @param {number|string} name - Name of the buffer
2458
- * @param {number|string|Uint8Array|ArrayBuffer|Object|boolean} typeOrData - Data type or value
2459
- * @param {number|string|undefined} [initValue] - Initial value for numeric types
2460
- * @returns {[string, string, Buffer]} metaBufferTuple containing name, buffer type, and buffer
2461
- * @throws {TypeError} If invalid meta buffer type is provided
2462
- */
2463
- function metaBuffer(name, typeOrData, initValue) {
2464
- let buffer;
2465
- let bufferType = 'B';
2466
- if (typeof typeOrData === 'number') {
2467
- if (typeof initValue === 'number') { // initValue 0 should be passed.
2468
- buffer = bufferExports.Buffer.alloc(typeOrData);
2469
- if (initValue !== 0) buffer.fill(initValue);
2470
- bufferType = 'B';
2471
- } else {
2472
- buffer = bufferExports.Buffer.from(String(typeOrData));
2473
- bufferType = 'N';
2474
- }
2475
- } else if (typeof typeOrData === 'string' && typeof initValue === 'number') { // number with type.
2476
- bufferType = typeOrData.toUpperCase(); // use explicit type name
2477
- buffer = numberBuffer(typeOrData, initValue); // notice. two categories. n: number string. 8, 16, 32: typed number.
2478
- } else if (typeof typeOrData === 'string' && initValue === undefined) { // string buffer
2479
- buffer = bufferExports.Buffer.from(typeOrData);
2480
- bufferType = 'S';
2481
- } else if (typeOrData instanceof Uint8Array && initValue === undefined) { // buffer | Uint8Array
2482
- // Buffer.from: Copies the passed buffer data onto a new Buffer instance.
2483
- // typecasting Uint8Array to Buffer.
2484
- buffer = (typeOrData instanceof bufferExports.Buffer) ? typeOrData : bufferExports.Buffer.from(typeOrData);
2485
- } else if (typeOrData instanceof ArrayBuffer && initValue === undefined) { // arrayBuffer
2486
- // Notice. typedArray is recommended instead of arrayBuffer
2487
- buffer = bufferExports.Buffer.from(typeOrData);
2488
- } else if (ArrayBuffer.isView(typeOrData)) { // typedarray buffer
2489
- buffer = bufferExports.Buffer.from(typeOrData.buffer, typeOrData.byteOffset, typeOrData.byteLength);
2490
- } else if (typeof typeOrData === 'object' && initValue === undefined) { // object. like array. stringify
2491
- buffer = bufferExports.Buffer.from(JSON.stringify(typeOrData));
2492
- bufferType = 'O';
2493
- } else if (typeof typeOrData === 'boolean' && initValue === undefined) { // object. like array. stringify
2494
- const v = typeOrData ? 1 : 0;
2495
- buffer = bufferExports.Buffer.from([v]);
2496
- bufferType = '!';
2497
- } else {
2498
- throw TypeError('invalid meta buffer type')
2499
- }
2500
-
2501
- if (typeof name === 'string' && name.includes('#')) name = ''; //
2502
-
2503
- return [name, bufferType, buffer]
2504
- }
2505
-
2506
- const MBA = metaBufferArguments;
2507
- /**
2508
- * Create meta buffers from arguments
2509
- * @param {...any} args - Arguments to create meta buffers
2510
- * @returns {Array<[string, string, Buffer]>} Array of meta buffer tuples
2511
- */
2512
- function metaBufferArguments(...args) {
2513
- let i = 0;
2514
- const mba = args.map(
2515
- data => {
2516
- const argsIndex = i++;
2517
- // tip. MBA use index number as metabuffer's property name.
2518
- if (typeof data === 'number') {
2519
- // * JS's primitive Number stored as string.
2520
- return MB$1(argsIndex, 'N', data)
2521
- } else {
2522
- // typedarray, dataview, array, object, boolean
2523
- return MB$1(argsIndex, data)
2524
- }
2525
- });
2526
-
2527
- return mba
2528
- }
2529
-
2530
- function parseTypeName(type) {
2531
- type = type.toUpperCase();
2532
-
2533
- if (type.includes('8')) {
2534
- if (type.includes('I')) {
2535
- return 'int8'
2536
- } else {
2537
- return 'uint8'
2538
- }
2539
- } else if (type.includes('16')) {
2540
- if (type.includes('I')) {
2541
- if (type.includes('L')) {
2542
- return 'int16_le'
2543
- } else {
2544
- return 'int16_be'
2545
- }
2546
- } else {
2547
- if (type.includes('L')) {
2548
- return 'uint16_le'
2549
- } else {
2550
- return 'uint16_be'
2551
- }
2552
- }
2553
- } else if (type.includes('32')) {
2554
- if (type.includes('I')) {
2555
- if (type.includes('L')) {
2556
- return 'int32_le'
2557
- } else {
2558
- return 'int32_be'
2559
- }
2560
- } else {
2561
- if (type.includes('L')) {
2562
- return 'uint32_le'
2563
- } else {
2564
- return 'uint32_be'
2565
- }
2566
- }
2567
- } else if (type.includes('F')) {
2568
- if (type.includes('L')) {
2569
- return 'float_le'
2570
- } else {
2571
- return 'float_be'
2572
- }
2573
- } else if (type === 'B') {
2574
- return 'buffer'
2575
- } else if (type === 'S') { // string or arguments
2576
- return 'string'
2577
- } else if (type === 'N') { // number encoded as string
2578
- return 'number'
2579
- } else if (type === 'O') { // object encoded string
2580
- return 'object'
2581
- } else if (type === '!') { // boolean 1:true 0:false
2582
- return 'boolean'
2583
- } else {
2584
- throw TypeError('invalid data type')
2585
- }
2586
-
2587
- }
2588
-
2589
- function readTypedBuffer(simpleType, buffer, offset, length) {
2590
- try {
2591
- const type = parseTypeName(simpleType);
2592
- if (type == 'int8') return buffer.readInt8(offset)
2593
- else if (type === 'uint8') return buffer.readUint8(offset)
2594
- else if (type === 'int16_le') return buffer.readInt16LE(offset)
2595
- else if (type === 'int16_be') return buffer.readInt16BE(offset)
2596
- else if (type === 'uint16_le') return buffer.readUint16LE(offset)
2597
- else if (type === 'uint16_be') return buffer.readUint16BE(offset)
2598
- else if (type === 'int32_le') return buffer.readInt32LE(offset)
2599
- else if (type === 'int32_be') return buffer.readInt32BE(offset)
2600
- else if (type === 'uint32_le') return buffer.readUint32LE(offset)
2601
- else if (type === 'uint32_be') return buffer.readUint32BE(offset)
2602
- else if (type === 'float_le') return buffer.readFloatLE(offset)
2603
- else if (type === 'float_be') return buffer.readFloatBE(offset)
2604
-
2605
- else if (type === 'buffer') {
2606
- return buffer.subarray(offset, offset + length)
2607
- } else if (type === 'string') {
2608
- const strBuffer = buffer.subarray(offset, offset + length);
2609
- return decoder$5.decode(strBuffer)
2610
- } else if (type === 'number') {
2611
- const strNumber = buffer.subarray(offset, offset + length);
2612
- return Number(decoder$5.decode(strNumber))
2613
- } else if (type === 'object') {
2614
- const objEncoded = buffer.subarray(offset, offset + length);
2615
- return JSON.parse(decoder$5.decode(objEncoded))
2616
- } else if (type === 'boolean') {
2617
- const v = buffer.readInt8(offset);
2618
- return v === 1
2619
- } else {
2620
- return
2621
- }
2622
- } catch (error) {
2623
- // console.log('MBP:readTypedBuffer obj decoding error.', error)
2624
- }
2625
- // any error and invalid data return undefined
2626
- return
2627
- }
2628
-
2629
- // to join MBA or MB meta list.
2630
- function flatArray(args) {
2631
- let subArr = [];
2632
- const mainArr = args.filter(item => {
2633
- if (Array.isArray(item[0])) subArr = subArr.concat(item);
2634
- else return item
2635
- });
2636
- return mainArr.concat(subArr)
2637
- }
2638
-
2639
- /**
2640
- * Pack data with metadata
2641
- * @param {...any} args - Data to pack
2642
- * @returns {Buffer} Packed buffer with metadata
2643
- */
2644
- function pack$1(...args) {
2645
- const bufArr = flatArray(args);
2646
- // console.log('MBP.pack: flat MB or MBA list', bufArr)
2647
- let size = 0;
2648
- const info = [];
2649
- let offset = 0;
2650
-
2651
- bufArr.forEach(bufPack => {
2652
- const [name, type, data] = bufPack;
2653
- size += data.byteLength;
2654
-
2655
- if (typeof name === 'number' || name.length > 0) {
2656
- // if the item has property name then add meta JSON info.
2657
- // type of name is Number in MBA.(index number)
2658
- // type of name is String in MB. except null string.
2659
- // add additional informative meta info.
2660
- info.push([name, type, offset, data.byteLength]);
2661
- }
2662
- offset = size;
2663
- });
2664
-
2665
-
2666
- // console.log('MBP.pack meta:', info )
2667
- let infoEncoded;
2668
- let infoSize;
2669
-
2670
- if (info.length > 0) {
2671
- let infoStr = JSON.stringify(info);
2672
- // console.log('pack infoStr , size:', infoStr , infoStr.length )
2673
- infoEncoded = encoder$3.encode(infoStr);
2674
- infoSize = infoEncoded.byteLength;
2675
- size = size + infoSize + 2;
2676
- }
2677
-
2678
- const buffer = bufferExports.Buffer.alloc(size);
2679
- offset = 0;
2680
- bufArr.forEach(bufPack => {
2681
- const buf = bufPack[2];
2682
- buffer.set(buf, offset);
2683
- offset += buf.byteLength;
2684
- });
2685
-
2686
- if (info.length > 0) {
2687
- buffer.set(infoEncoded, offset);
2688
- const infoSizeBuff = NB('16', infoSize);
2689
- buffer.set(infoSizeBuff, offset + infoSize);
2690
- return buffer
2691
- } else {
2692
- return buffer
2693
- }
2694
- }
2695
-
2696
-
2697
- /**
2698
- * unpack() will use embeded meta info from the binary pack.
2699
- * You can specify (optional) meta obejct.
2700
- * (It's useful to read pure buffer data.)
2701
- *
2702
- * You can get the meta object from: meta()
2703
- * @param {Buffer|Uint8Array} binPack binaryData
2704
- * @param {Object} meta *OPTION*
2705
- * @returns {Object|undefined} success: return Object (include buffer data). fail: return undefined
2706
- */
2707
- /**
2708
- * Unpack data from buffer using metadata
2709
- * @param {Buffer|Uint8Array} binPack - Binary data to unpack
2710
- * @param {Object} [meta] - Optional metadata object
2711
- * @returns {Object|undefined} Unpacked data or undefined if failed
2712
- */
2713
- function unpack(binPack, meta) {
2714
-
2715
- const infoArr = meta || getMeta(binPack);
2716
- if (!infoArr) return
2717
-
2718
- const buffer = bufferExports.Buffer.from(binPack);
2719
- const binObj = {};
2720
- let readCounter = 0;
2721
- infoArr.forEach(bufPack => {
2722
- const [name, type, offset, length] = bufPack;
2723
- let result = readTypedBuffer(type, buffer, offset, length);
2724
- if (result == undefined) return
2725
- binObj[name] = result;
2726
- if (length) readCounter += length;
2727
- });
2728
-
2729
- // Can not define meta for variable size buffer
2730
- // unpacker support automatic property to read left(did't read) buffers.
2731
- // console.log("######, unpack: buffer " , readCounter, buffer ,buffer.byteLength)
2732
- if (meta && buffer.byteLength !== readCounter) {
2733
- let leftSize = buffer.byteLength - readCounter;
2734
- // console.log('total,left buffer size', buffer.byteLength, leftSize )
2735
- let result = readTypedBuffer('b', buffer, readCounter, leftSize);
2736
- if (result == undefined) return
2737
- binObj["$OTHERS"] = result;
2738
- }
2739
-
2740
- // set args with values if exist.
2741
- let mbaIndex = 0;
2742
- let args = [];
2743
- while (binObj[mbaIndex]) {
2744
- args.push(binObj[mbaIndex++]);
2745
- }
2746
-
2747
- if (args.length > 0) {
2748
- binObj.args = args;
2749
- binObj.$ = binObj.args;
2750
- }
2751
- return binObj
2752
- }
2753
-
2754
-
2755
- const U8 = parseUint8Array; //alias
2756
- /**
2757
- *
2758
- * @param {any} data
2759
- * @param {Boolean} shareArrayBuffer false(default): return new( or copied) ArrayBuffer. true: share the input data's arrayBuffer.
2760
- * @returns {Uint8Array}
2761
- */
2762
- /**
2763
- * Parse data into Uint8Array
2764
- * @param {any} data - Data to parse
2765
- * @param {boolean} [shareArrayBuffer=false] - Whether to share the input data's array buffer
2766
- * @returns {Uint8Array} Parsed Uint8Array
2767
- */
2768
- function parseUint8Array(data, shareArrayBuffer = false) {
2769
- if (data === undefined) throw TypeError('Invalid data type: Undefined')
2770
- if (typeof data === 'string') {
2771
- return encoder$3.encode(data)
2772
- } else if (typeof data === 'number') { // number -> 1 byte uint8array(number)
2773
- return Uint8Array.from([data])
2774
- } else if (data instanceof ArrayBuffer) { // arraybuffer -> wrap uint8array(ab)
2775
- if (shareArrayBuffer) {
2776
- return new Uint8Array(data)
2777
- } else {
2778
- const originData = new Uint8Array(data);
2779
- const dataCopy = new Uint8Array(data.byteLength);
2780
- dataCopy.set(originData);
2781
- return dataCopy
2782
- }
2783
- } else if (ArrayBuffer.isView(data)) { // accept Buffer too.
2784
- if (shareArrayBuffer) {
2785
- return new Uint8Array(data.buffer, data.byteOffset, data.byteLength) // DataView, TypedArray > uint8array( use offset, length )
2786
- } else {
2787
- // new memory to protect origin arraybuffer.
2788
- const originData = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
2789
- const dataCopy = new Uint8Array(data.byteLength);
2790
- dataCopy.set(originData);
2791
- return dataCopy
2792
- }
2793
- } else { // array, object
2794
- return encoder$3.encode(JSON.stringify(data)) // object(array.. ) > JSON.str > encode > unint8array
2795
- }
2796
- }
2797
-
2798
- const B8 = parseBuffer;
2799
- /**
2800
- * Parse data into Buffer
2801
- * @param {any} data - Data to parse
2802
- * @param {boolean} [shareArrayBuffer=false] - Whether to share the input data's array buffer
2803
- * @returns {Buffer} Parsed Buffer
2804
- */
2805
- function parseBuffer(data, shareArrayBuffer = false) {
2806
-
2807
- const u8 = parseUint8Array(data, shareArrayBuffer);
2808
- if (shareArrayBuffer) {
2809
- return bufferExports.Buffer.from(u8.buffer, u8.byteOffset, u8.byteLength)
2810
- } else {
2811
- return bufferExports.Buffer.from(u8)
2812
- }
2813
- }
2814
-
2815
- const B8pack = parseBufferThenConcat;
2816
- function parseBufferThenConcat(...dataArray) {
2817
- const buffers = dataArray.map(data => parseBuffer(data));
2818
- return bufferExports.Buffer.concat(buffers)
2819
- }
2820
-
2821
-
2822
- const U8pack = parseUint8ThenConcat; // alias
2823
- /**
2824
- * 1. parse list of data into U8 list
2825
- * 2. return new Uint8Array merged.
2826
- * @param {...any} dataArray
2827
- * @returns
2828
- */
2829
- function parseUint8ThenConcat(...dataArray) {
2830
- try {
2831
- let bufferSize = 0;
2832
- let offset = 0;
2833
- const buffers = dataArray.map(data => parseUint8Array(data));
2834
- buffers.forEach(buf => { bufferSize += buf.byteLength; });
2835
- const buffer = new Uint8Array(bufferSize);
2836
- buffers.forEach(buf => {
2837
- buffer.set(buf, offset);
2838
- offset += buf.byteLength;
2839
- });
2840
- return buffer
2841
- } catch (error) {
2842
- console.log(error);
2843
- }
2844
- }
2845
-
2846
- function hex(buffer) {
2847
- return Array.prototype.map.call(new Uint8Array(buffer), x => ('00' + x.toString(16)).slice(-2)).join('')
2848
- }
2849
-
2850
- function equal(buf1, buf2) {
2851
- if (buf1.byteLength !== buf2.byteLength) return false
2852
- for (let i = 0; i < buf1.byteLength; i++) {
2853
- if (buf1[i] !== buf2[i]) return false
2854
- }
2855
- return true
2856
- }
2857
-
2858
-
2859
- function getBufferSize(binPack) {
2860
- if (getMetaSize(binPack) === 0) {
2861
- return binPack.byteLength
2862
- } else {
2863
- return binPack.byteLength - getMetaSize(binPack) - TAIL_LEN
2864
- }
2865
- }
2866
-
2867
- // MB and MBA
2868
- function parseMetaInfo(binPack, infoSize) {
2869
- try {
2870
- const buffer = new Uint8Array(binPack.buffer, binPack.byteOffset, binPack.byteLength);
2871
- const infoFrom = buffer.byteLength - infoSize - 2;
2872
- const infoEncoded = buffer.subarray(infoFrom, buffer.byteLength - 2);
2873
- const decoded = decoder$5.decode(infoEncoded);
2874
- const info = JSON.parse(decoded);
2875
-
2876
- if (!Array.isArray(info) || !Array.isArray(info[0])) return
2877
-
2878
- let firstItem = info[0];
2879
- if (!firstItem) return
2880
-
2881
- if (firstItem.length < 3) return
2882
- const [name, type, offset] = firstItem;
2883
-
2884
- if (typeof type !== 'string' || typeof offset !== 'number') return
2885
-
2886
- return info
2887
- } catch (error) {
2888
- // return undefined
2889
- }
2890
- }
2891
-
2892
-
2893
- /**
2894
- * Meta buffer pack Tail:
2895
- * binary Pack include TAIL(two bytes size) info at the end if it has JSON info.
2896
- * not include TAIL if it has not JSON.
2897
- */
2898
- const TAIL_LEN = 2;
2899
-
2900
- /**
2901
- *
2902
- * @param {Buffer|Uint8Array|ArrayBuffer} binPack
2903
- * @returns {Number} last two byte value( read Uint16 bigendian )
2904
- */
2905
- function readTail(binPack) {
2906
- if (binPack instanceof ArrayBuffer) {
2907
- binPack = bufferExports.Buffer.from(binPack); // creates a view for ArrayBuffer, without copying.
2908
- }
2909
- if (binPack instanceof Uint8Array) {
2910
- if (binPack.byteLength <= TAIL_LEN) return 0
2911
-
2912
- const dv = new DataView(binPack.buffer, binPack.byteOffset, binPack.byteLength);
2913
- const infoSize = dv.getUint16(binPack.byteLength - TAIL_LEN); // last 2 bytes for json-info-length.
2914
- return infoSize
2915
-
2916
- } else {
2917
- // throw TypeError('invalid data type.')
2918
- return 0
2919
- }
2920
-
2921
- }
2922
-
2923
-
2924
- // binay data pack is not always Buffer.
2925
- // It should accept Uint8Array binPack.
2926
- // This function don't use Buffer method.
2927
-
2928
- function getMetaSize(binPack) {
2929
- if (binPack instanceof ArrayBuffer) {
2930
- binPack = bufferExports.Buffer.from(binPack); // creates a view for ArrayBuffer, without copying.
2931
- }
2932
- if (binPack instanceof Uint8Array) {
2933
-
2934
- const size = binPack.byteLength;
2935
- if (size <= TAIL_LEN) return 0
2936
-
2937
- //1. tail size check
2938
- const infoSize = readTail(binPack);
2939
- if (infoSize === 0 || infoSize > size) return 0
2940
- //2. try parse JSON
2941
- const success = parseMetaInfo(binPack, infoSize);
2942
- //3. return success: jsonInfoSize, fail: 0
2943
- if (success) return infoSize
2944
- else return 0
2945
- } else {
2946
- return 0
2947
- }
2948
- }
2949
-
2950
-
2951
- /**
2952
- *
2953
- * @param {Buffer|Uint8Array} binPack
2954
- * @returns {Buffer}
2955
- */
2956
- function getBuffer(binPack) {
2957
- const rawBufferSize = getBufferSize(binPack);
2958
- return binPack.subarray(0, rawBufferSize)
2959
- }
2960
-
2961
-
2962
-
2963
- /**
2964
- * extract Meta info object if it has.
2965
- *
2966
- * @param {Buffer|Uint8Array|ArrayBuffer} binPack
2967
- * @param {Boolean} showDetail add additional item info: full data type name and bytelength.
2968
- * @returns {Object|undefined} success: return MetaInfo Object. fail: return undefined.(No valid JSON included.)
2969
- */
2970
- /**
2971
- * Extract metadata from buffer
2972
- * @param {Buffer|Uint8Array|ArrayBuffer} binPack - Binary data to extract metadata from
2973
- * @param {boolean} [showDetail=false] - Whether to show detailed information
2974
- * @returns {Object|undefined} Metadata object or undefined if no valid JSON included
2975
- */
2976
- function getMeta(binPack, showDetail = false) {
2977
- if (binPack instanceof ArrayBuffer) {
2978
- binPack = bufferExports.Buffer.from(binPack); // creates a view for ArrayBuffer, without copying.
2979
- }
2980
- const infoSize = readTail(binPack);
2981
- if (infoSize === 0) return
2982
-
2983
- // check valid Meta
2984
- let metaInfo = parseMetaInfo(binPack, infoSize);
2985
- if (!metaInfo) return
2986
-
2987
- if (!showDetail) {
2988
- return metaInfo
2989
- } else {
2990
- // add additional info
2991
- metaInfo.forEach(bufPack => {
2992
- const len = bufPack[3];
2993
- if (len == undefined) { // add size info.
2994
- if (bufPack[1].includes('8')) bufPack[3] = 1;
2995
- else if (bufPack[1].includes('16')) bufPack[3] = 2;
2996
- else if (bufPack[1].includes('32')) bufPack[3] = 4;
2997
- else if (bufPack[1].includes('F')) bufPack[3] = 4;
2998
- else if (bufPack[1].includes('!')) bufPack[3] = 1;
2999
- }
3000
- bufPack[4] = parseTypeName(bufPack[1]); // add full-type-name.
3001
- });
3002
- return metaInfo
3003
- }
3004
- }
3005
-
3006
- function rawPack(...args) {
3007
- return getBuffer(pack$1(...args))
3008
- }
3009
-
3010
- function meta(...args) {
3011
- return getMeta(pack$1(...args))
3012
- }
3013
-
3014
- function metaDetail(...args) {
3015
- return getMeta(pack$1(...args), true)
3016
- }
23
+ var t$1,e$1={},r$1={};var n$1,i$1,o$1={};
24
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */function f$1(){return n$1||(n$1=1,o$1.read=function(t,e,r,n,i){var o,f,u=8*i-n-1,s=(1<<u)-1,h=s>>1,a=-7,c=r?i-1:0,l=r?-1:1,p=t[e+c];for(c+=l,o=p&(1<<-a)-1,p>>=-a,a+=u;a>0;o=256*o+t[e+c],c+=l,a-=8);for(f=o&(1<<-a)-1,o>>=-a,a+=n;a>0;f=256*f+t[e+c],c+=l,a-=8);if(0===o)o=1-h;else {if(o===s)return f?NaN:1/0*(p?-1:1);f+=Math.pow(2,n),o-=h;}return (p?-1:1)*f*Math.pow(2,o-n)},o$1.write=function(t,e,r,n,i,o){var f,u,s,h=8*o-i-1,a=(1<<h)-1,c=a>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,y=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,f=a):(f=Math.floor(Math.log(e)/Math.LN2),e*(s=Math.pow(2,-f))<1&&(f--,s*=2),(e+=f+c>=1?l/s:l*Math.pow(2,1-c))*s>=2&&(f++,s/=2),f+c>=a?(u=0,f=a):f+c>=1?(u=(e*s-1)*Math.pow(2,i),f+=c):(u=e*Math.pow(2,c-1)*Math.pow(2,i),f=0));i>=8;t[r+p]=255&u,p+=y,u/=256,i-=8);for(f=f<<i|u,h+=i;h>0;t[r+p]=255&f,p+=y,f/=256,h-=8);t[r+p-y]|=128*g;}),o$1}
25
+ /*!
26
+ * The buffer module from node.js, for the browser.
27
+ *
28
+ * @author Feross Aboukhadijeh <https://feross.org>
29
+ * @license MIT
30
+ */var u$1=(i$1||(i$1=1,function(e){const n=function(){if(t$1)return r$1;t$1=1,r$1.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r$1.toByteArray=function(t){var e,r,o=u(t),f=o[0],s=o[1],h=new i(function(t,e,r){return 3*(e+r)/4-r}(0,f,s)),a=0,c=s>0?f-4:f;for(r=0;r<c;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],h[a++]=e>>16&255,h[a++]=e>>8&255,h[a++]=255&e;return 2===s&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,h[a++]=255&e),1===s&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,h[a++]=e>>8&255,h[a++]=255&e),h},r$1.fromByteArray=function(t){for(var r,n=t.length,i=n%3,o=[],f=16383,u=0,s=n-i;u<s;u+=f)o.push(h(t,u,u+f>s?s:u+f));return 1===i?(r=t[n-1],o.push(e[r>>2]+e[r<<4&63]+"==")):2===i&&(r=(t[n-2]<<8)+t[n-1],o.push(e[r>>10]+e[r>>4&63]+e[r<<2&63]+"=")),o.join("")};for(var e=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0;f<64;++f)e[f]=o[f],n[o.charCodeAt(f)]=f;function u(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return -1===r&&(r=e),[r,r===e?0:4-r%4]}function s(t){return e[t>>18&63]+e[t>>12&63]+e[t>>6&63]+e[63&t]}function h(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),i.push(s(n));return i.join("")}return n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63,r$1}(),i=f$1(),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=h,e.SlowBuffer=function(t){return +t!=t&&(t=0),h.alloc(+t)},e.INSPECT_MAX_BYTES=50;const u=2147483647;function s(t){if(t>u)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,h.prototype),e}function h(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return a(t,e,r)}function a(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!h.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|d(t,e);let n=s(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(H(t,Uint8Array)){const e=new Uint8Array(t);return y(e.buffer,e.byteOffset,e.byteLength)}return p(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return y(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(H(t,SharedArrayBuffer)||t&&H(t.buffer,SharedArrayBuffer)))return y(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return h.from(n,e,r);const i=function(t){if(h.isBuffer(t)){const e=0|g(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||Z(t.length)?s(0):p(t):"Buffer"===t.type&&Array.isArray(t.data)?p(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return h.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function l(t){return c(t),s(t<0?0:0|g(t))}function p(t){const e=t.length<0?0:0|g(t.length),r=s(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function y(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,h.prototype),n}function g(t){if(t>=u)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u.toString(16)+" bytes");return 0|t}function d(t,e){if(h.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&true===arguments[2];if(!n&&0===r)return 0;let i=false;for(;;)switch(e){case "ascii":case "latin1":case "binary":return r;case "utf8":case "utf-8":return q(t).length;case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return 2*r;case "hex":return r>>>1;case "base64":return W(t).length;default:if(i)return n?-1:q(t).length;e=(""+e).toLowerCase(),i=true;}}function b(t,e,r){let n=false;if((void 0===e||e<0)&&(e=0),e>this.length)return "";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return "";if((r>>>=0)<=(e>>>=0))return "";for(t||(t="utf8");;)switch(t){case "hex":return S(this,e,r);case "utf8":case "utf-8":return O(this,e,r);case "ascii":return _(this,e,r);case "latin1":case "binary":return R(this,e,r);case "base64":return v(this,e,r);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return N(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=true;}}function w(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function B(t,e,r,n,i){if(0===t.length)return -1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Z(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return -1;r=t.length-1;}else if(r<0){if(!i)return -1;r=0;}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:m(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):m(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function m(t,e,r,n,i){let o,f=1,u=t.length,s=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return -1;f=2,u/=2,s/=2,r/=2;}function h(t,e){return 1===f?t[e]:t.readUInt16BE(e*f)}if(i){let n=-1;for(o=r;o<u;o++)if(h(t,o)===h(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===s)return n*f}else -1!==n&&(o-=o-n),n=-1;}else for(r+s>u&&(r=u-s),o=r;o>=0;o--){let r=true;for(let n=0;n<s;n++)if(h(t,o+n)!==h(e,n)){r=false;break}if(r)return o}return -1}function E(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let f;for(n>o/2&&(n=o/2),f=0;f<n;++f){const n=parseInt(e.substr(2*f,2),16);if(Z(n))return f;t[r+f]=n;}return f}function A(t,e,r,n){return X(q(e,t.length-r),t,r,n)}function U(t,e,r,n){return X(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function I(t,e,r,n){return X(W(e),t,r,n)}function L(t,e,r,n){return X(function(t,e){let r,n,i;const o=[];for(let f=0;f<t.length&&!((e-=2)<0);++f)r=t.charCodeAt(f),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function v(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function O(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,f=e>239?4:e>223?3:e>191?2:1;if(i+f<=r){let r,n,u,s;switch(f){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(s=(31&e)<<6|63&r,s>127&&(o=s));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(s=(15&e)<<12|(63&r)<<6|63&n,s>2047&&(s<55296||s>57343)&&(o=s));break;case 4:r=t[i+1],n=t[i+2],u=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&u)&&(s=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&u,s>65535&&s<1114112&&(o=s));}}null===o?(o=65533,f=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=f;}return function(t){const e=t.length;if(e<=T)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=T));return r}(n)}e.kMaxLength=u,h.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return false}}(),h.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(h.prototype,"parent",{enumerable:true,get:function(){if(h.isBuffer(this))return this.buffer}}),Object.defineProperty(h.prototype,"offset",{enumerable:true,get:function(){if(h.isBuffer(this))return this.byteOffset}}),h.poolSize=8192,h.from=function(t,e,r){return a(t,e,r)},Object.setPrototypeOf(h.prototype,Uint8Array.prototype),Object.setPrototypeOf(h,Uint8Array),h.alloc=function(t,e,r){return function(t,e,r){return c(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},h.allocUnsafe=function(t){return l(t)},h.allocUnsafeSlow=function(t){return l(t)},h.isBuffer=function(t){return null!=t&&true===t._isBuffer&&t!==h.prototype},h.compare=function(t,e){if(H(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),H(e,Uint8Array)&&(e=h.from(e,e.offset,e.byteLength)),!h.isBuffer(t)||!h.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},h.isEncoding=function(t){switch(String(t).toLowerCase()){case "hex":case "utf8":case "utf-8":case "ascii":case "latin1":case "binary":case "base64":case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return true;default:return false}},h.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return h.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=h.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(H(e,Uint8Array))i+e.length>n.length?(h.isBuffer(e)||(e=h.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else {if(!h.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i);}i+=e.length;}return n},h.byteLength=d,h.prototype._isBuffer=true,h.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)w(this,e,e+1);return this},h.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)w(this,e,e+3),w(this,e+1,e+2);return this},h.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)w(this,e,e+7),w(this,e+1,e+6),w(this,e+2,e+5),w(this,e+3,e+4);return this},h.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?O(this,0,t):b.apply(this,arguments)},h.prototype.toLocaleString=h.prototype.toString,h.prototype.equals=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===h.compare(this,t)},h.prototype.inspect=function(){let t="";const r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},o&&(h.prototype[o]=h.prototype.inspect),h.prototype.compare=function(t,e,r,n,i){if(H(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return -1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),f=(r>>>=0)-(e>>>=0);const u=Math.min(o,f),s=this.slice(n,i),a=t.slice(e,r);for(let t=0;t<u;++t)if(s[t]!==a[t]){o=s[t],f=a[t];break}return o<f?-1:f<o?1:0},h.prototype.includes=function(t,e,r){return -1!==this.indexOf(t,e,r)},h.prototype.indexOf=function(t,e,r){return B(this,t,e,r,true)},h.prototype.lastIndexOf=function(t,e,r){return B(this,t,e,r,false)},h.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else {if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0);}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=false;for(;;)switch(n){case "hex":return E(this,t,e,r);case "utf8":case "utf-8":return A(this,t,e,r);case "ascii":case "latin1":case "binary":return U(this,t,e,r);case "base64":return I(this,t,e,r);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return L(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=true;}},h.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const T=4096;function _(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function R(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function S(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=K[t[n]];return i}function N(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function C(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function M(t,e,r,n,i,o){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function x(t,e,r,n,i){Y(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,r}function $(t,e,r,n,i){Y(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=f,f>>=8,t[r+2]=f,f>>=8,t[r+1]=f,f>>=8,t[r]=f,r+8}function P(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function k(t,e,r,n,o){return e=+e,r>>>=0,o||P(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function F(t,e,r,n,o){return e=+e,r>>>=0,o||P(t,0,r,8),i.write(t,e,r,n,52,8),r+8}h.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,h.prototype),n},h.prototype.readUintLE=h.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},h.prototype.readUintBE=h.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},h.prototype.readUint8=h.prototype.readUInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),this[t]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readBigUInt64LE=Q(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))}),h.prototype.readBigUInt64BE=Q(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return (BigInt(n)<<BigInt(32))+BigInt(i)}),h.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},h.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},h.prototype.readInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||C(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt16BE=function(t,e){t>>>=0,e||C(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readBigInt64LE=Q(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return (BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),h.prototype.readBigInt64BE=Q(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return (BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)}),h.prototype.readFloatLE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,true,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,false,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,true,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,false,52,8)},h.prototype.writeUintLE=h.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||M(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},h.prototype.writeUintBE=h.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||M(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},h.prototype.writeUint8=h.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeBigUInt64LE=Q(function(t,e=0){return x(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeBigUInt64BE=Q(function(t,e=0){return $(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);M(this,t,e,r,n-1,-n);}let i=0,o=1,f=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===f&&0!==this[e+i-1]&&(f=1),this[e+i]=(t/o|0)-f&255;return e+r},h.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);M(this,t,e,r,n-1,-n);}let i=r-1,o=1,f=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===f&&0!==this[e+i+1]&&(f=1),this[e+i]=(t/o|0)-f&255;return e+r},h.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeBigInt64LE=Q(function(t,e=0){return x(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),h.prototype.writeBigInt64BE=Q(function(t,e=0){return $(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),h.prototype.writeFloatLE=function(t,e,r){return k(this,t,e,true,r)},h.prototype.writeFloatBE=function(t,e,r){return k(this,t,e,false,r)},h.prototype.writeDoubleLE=function(t,e,r){return F(this,t,e,true,r)},h.prototype.writeDoubleBE=function(t,e,r){return F(this,t,e,false,r)},h.prototype.copy=function(t,e,r,n){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},h.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!h.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e);}}else "number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else {const o=h.isBuffer(t)?t:h.from(t,n),f=o.length;if(0===f)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%f];}return this};const j={};function D(t,e,r){j[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:true,configurable:true}),this.name=`${this.name} [${t}]`,this.stack,delete this.name;}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:true,enumerable:true,value:t,writable:true});}toString(){return `${this.name} [${t}]: ${this.message}`}};}function z(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return `${t.slice(0,r)}${e}`}function Y(t,e,r,n,i,o){if(t>r||t<e){const r="bigint"==typeof e?"n":"";let n;throw n=0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(o+1)}${r}`:`>= -(2${r} ** ${8*(o+1)-1}${r}) and < 2 ** ${8*(o+1)-1}${r}`,new j.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,r){V(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||G(e,t.length-(r+1));}(n,i,o);}function V(t,e){if("number"!=typeof t)throw new j.ERR_INVALID_ARG_TYPE(e,"number",t)}function G(t,e,r){if(Math.floor(t)!==t)throw V(t,r),new j.ERR_OUT_OF_RANGE("offset","an integer",t);if(e<0)throw new j.ERR_BUFFER_OUT_OF_BOUNDS;throw new j.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${e}`,t)}D("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),D("ERR_INVALID_ARG_TYPE",function(t,e){return `The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),D("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=z(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=z(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);const J=/[^+/0-9A-Za-z-_]/g;function q(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let f=0;f<n;++f){if(r=t.charCodeAt(f),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(f+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320);}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r);}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128);}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128);}else {if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128);}}return o}function W(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(J,"")).length<2)return "";for(;t.length%4!=0;)t+="=";return t}(t))}function X(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Z(t){return t!=t}const K=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i];}return e}();function Q(t){return "undefined"==typeof BigInt?tt:t}function tt(){throw new Error("BigInt not supported")}}(e$1)),e$1);const s$1=new TextEncoder,h$1=new TextDecoder,a$1=c$1;function c$1(t,e=0){let r;if(void 0===t||"string"!=typeof t||"number"!=typeof e)throw TypeError("invlaid init variablie type name. ");return (t=t.toUpperCase()).includes("8")?(r=u$1.Buffer.alloc(1),t.includes("I")?r.writeInt8(e):r.writeUint8(e)):t.includes("16")?(r=u$1.Buffer.alloc(2),t.includes("I")?t.includes("L")?r.writeInt16LE(e):r.writeInt16BE(e):t.includes("L")?r.writeUint16LE(e):r.writeUint16BE(e)):t.includes("32")?(r=u$1.Buffer.alloc(4),t.includes("I")?t.includes("L")?r.writeInt32LE(e):r.writeInt32BE(e):t.includes("L")?r.writeUint32LE(e):r.writeUint32BE(e)):t.includes("F")?(r=u$1.Buffer.alloc(4),t.includes("L")?r.writeFloatLE(e):r.writeFloatBE(e)):t.includes("N")?r=u$1.Buffer.from(String(e)):console.log(`invalid type: ${t} or initvalue: ${e}`),r}const l$1=p$1;function p$1(t,e,r){let n,i="B";if("number"==typeof e)"number"==typeof r?(n=u$1.Buffer.alloc(e),0!==r&&n.fill(r),i="B"):(n=u$1.Buffer.from(String(e)),i="N");else if("string"==typeof e&&"number"==typeof r)i=e.toUpperCase(),n=c$1(e,r);else if("string"==typeof e&&void 0===r)n=u$1.Buffer.from(e),i="S";else if(e instanceof Uint8Array&&void 0===r)n=e instanceof u$1.Buffer?e:u$1.Buffer.from(e);else if(e instanceof ArrayBuffer&&void 0===r)n=u$1.Buffer.from(e);else if(ArrayBuffer.isView(e))n=u$1.Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if("object"==typeof e&&void 0===r)n=u$1.Buffer.from(JSON.stringify(e)),i="O";else {if("boolean"!=typeof e||void 0!==r)throw TypeError("invalid meta buffer type");{const t=e?1:0;n=u$1.Buffer.from([t]),i="!";}}return "string"==typeof t&&t.includes("#")&&(t=""),[t,i,n]}const y$1=g$1;function g$1(...t){let e=0;return t.map(t=>{const r=e++;return "number"==typeof t?l$1(r,"N",t):l$1(r,t)})}function d$1(t){if((t=t.toUpperCase()).includes("8"))return t.includes("I")?"int8":"uint8";if(t.includes("16"))return t.includes("I")?t.includes("L")?"int16_le":"int16_be":t.includes("L")?"uint16_le":"uint16_be";if(t.includes("32"))return t.includes("I")?t.includes("L")?"int32_le":"int32_be":t.includes("L")?"uint32_le":"uint32_be";if(t.includes("F"))return t.includes("L")?"float_le":"float_be";if("B"===t)return "buffer";if("S"===t)return "string";if("N"===t)return "number";if("O"===t)return "object";if("!"===t)return "boolean";throw TypeError("invalid data type")}function b$1(t,e,r,n){try{const i=d$1(t);if("int8"==i)return e.readInt8(r);if("uint8"===i)return e.readUint8(r);if("int16_le"===i)return e.readInt16LE(r);if("int16_be"===i)return e.readInt16BE(r);if("uint16_le"===i)return e.readUint16LE(r);if("uint16_be"===i)return e.readUint16BE(r);if("int32_le"===i)return e.readInt32LE(r);if("int32_be"===i)return e.readInt32BE(r);if("uint32_le"===i)return e.readUint32LE(r);if("uint32_be"===i)return e.readUint32BE(r);if("float_le"===i)return e.readFloatLE(r);if("float_be"===i)return e.readFloatBE(r);if("buffer"===i)return e.subarray(r,r+n);if("string"===i){const t=e.subarray(r,r+n);return h$1.decode(t)}if("number"===i){const t=e.subarray(r,r+n);return Number(h$1.decode(t))}if("object"===i){const t=e.subarray(r,r+n);return JSON.parse(h$1.decode(t))}if("boolean"===i){return 1===e.readInt8(r)}return}catch(t){}}function w$1(...t){const e=function(t){let e=[];return t.filter(t=>{if(!Array.isArray(t[0]))return t;e=e.concat(t);}).concat(e)}(t);let r=0;const n=[];let i,o,f=0;if(e.forEach(t=>{const[e,i,o]=t;r+=o.byteLength,("number"==typeof e||e.length>0)&&n.push([e,i,f,o.byteLength]),f=r;}),n.length>0){let t=JSON.stringify(n);i=s$1.encode(t),o=i.byteLength,r=r+o+2;}const h=u$1.Buffer.alloc(r);if(f=0,e.forEach(t=>{const e=t[2];h.set(e,f),f+=e.byteLength;}),n.length>0){h.set(i,f);const t=a$1("16",o);return h.set(t,f+o),h}return h}const B$1=m$1;function m$1(t,e=false){if(void 0===t)throw TypeError("Invalid data type: Undefined");if("string"==typeof t)return s$1.encode(t);if("number"==typeof t)return Uint8Array.from([t]);if(t instanceof ArrayBuffer){if(e)return new Uint8Array(t);{const e=new Uint8Array(t),r=new Uint8Array(t.byteLength);return r.set(e),r}}if(ArrayBuffer.isView(t)){if(e)return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);{const e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),r=new Uint8Array(t.byteLength);return r.set(e),r}}return s$1.encode(JSON.stringify(t))}const E$1=A$1;function A$1(t,e=false){const r=m$1(t,e);return e?u$1.Buffer.from(r.buffer,r.byteOffset,r.byteLength):u$1.Buffer.from(r)}const U$1=I$1;function I$1(...t){const e=t.map(t=>A$1(t));return u$1.Buffer.concat(e)}const L$1=v$1;function v$1(...t){try{let e=0,r=0;const n=t.map(t=>m$1(t));n.forEach(t=>{e+=t.byteLength;});const i=new Uint8Array(e);return n.forEach(t=>{i.set(t,r),r+=t.byteLength;}),i}catch(t){console.log(t);}}function O$1(t){return 0===S$1(t)?t.byteLength:t.byteLength-S$1(t)-_$1}function T$1(t,e){try{const r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),n=r.byteLength-e-2,i=r.subarray(n,r.byteLength-2),o=h$1.decode(i),f=JSON.parse(o);if(!Array.isArray(f)||!Array.isArray(f[0]))return;let u=f[0];if(!u)return;if(u.length<3)return;const[s,a,c]=u;if("string"!=typeof a||"number"!=typeof c)return;return f}catch(t){}}const _$1=2;function R$1(t){if(t instanceof ArrayBuffer&&(t=u$1.Buffer.from(t)),t instanceof Uint8Array){if(t.byteLength<=_$1)return 0;return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint16(t.byteLength-_$1)}return 0}function S$1(t){if(t instanceof ArrayBuffer&&(t=u$1.Buffer.from(t)),t instanceof Uint8Array){const e=t.byteLength;if(e<=_$1)return 0;const r=R$1(t);if(0===r||r>e)return 0;return T$1(t,r)?r:0}return 0}function N$1(t){const e=O$1(t);return t.subarray(0,e)}function C$1(t,e=false){t instanceof ArrayBuffer&&(t=u$1.Buffer.from(t));const r=R$1(t);if(0===r)return;let n=T$1(t,r);return n?e?(n.forEach(t=>{null==t[3]&&(t[1].includes("8")?t[3]=1:t[1].includes("16")?t[3]=2:t[1].includes("32")||t[1].includes("F")?t[3]=4:t[1].includes("!")&&(t[3]=1)),t[4]=d$1(t[1]);}),n):n:void 0}var M$1=Object.freeze({__proto__:null,B8:E$1,B8pack:U$1,Buffer:u$1.Buffer,MB:l$1,MBA:y$1,NB:a$1,TAIL_LEN:_$1,U8:B$1,U8pack:L$1,equal:function(t,e){if(t.byteLength!==e.byteLength)return false;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return false;return true},getBuffer:N$1,getBufferSize:O$1,getMeta:C$1,getMetaDetail:function(t){return C$1(t,true)},getMetaSize:S$1,hex:function(t){return Array.prototype.map.call(new Uint8Array(t),t=>("00"+t.toString(16)).slice(-2)).join("")},meta:function(...t){return C$1(w$1(...t))},metaBuffer:p$1,metaBufferArguments:g$1,metaDetail:function(...t){return C$1(w$1(...t),true)},numberBuffer:c$1,pack:w$1,parseBuffer:A$1,parseBufferThenConcat:I$1,parseMetaInfo:T$1,parseTypeName:d$1,parseUint8Array:m$1,parseUint8ThenConcat:v$1,rawPack:function(...t){return N$1(w$1(...t))},readTail:R$1,readTypedBuffer:b$1,unpack:function(t,e){const r=e||C$1(t);if(!r)return;const n=u$1.Buffer.from(t),i={};let o=0;if(r.forEach(t=>{const[e,r,f,u]=t;let s=b$1(r,n,f,u);null!=s&&(i[e]=s,u&&(o+=u));}),e&&n.byteLength!==o){let t=n.byteLength-o,e=b$1("b",n,o,t);if(null==e)return;i.$OTHERS=e;}let f=0,s=[];for(;i[f];)s.push(i[f++]);return s.length>0&&(i.args=s,i.$=i.args),i}});
3017
31
 
3018
- function getMetaDetail(binPack) {
3019
- return getMeta(binPack, true)
32
+ function getDefaultExportFromCjs (x) {
33
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
3020
34
  }
3021
35
 
3022
- var mbp = /*#__PURE__*/Object.freeze({
3023
- __proto__: null,
3024
- B8: B8,
3025
- B8pack: B8pack,
3026
- Buffer: bufferExports.Buffer,
3027
- MB: MB$1,
3028
- MBA: MBA,
3029
- NB: NB,
3030
- TAIL_LEN: TAIL_LEN,
3031
- U8: U8,
3032
- U8pack: U8pack,
3033
- equal: equal,
3034
- getBuffer: getBuffer,
3035
- getBufferSize: getBufferSize,
3036
- getMeta: getMeta,
3037
- getMetaDetail: getMetaDetail,
3038
- getMetaSize: getMetaSize,
3039
- hex: hex,
3040
- meta: meta,
3041
- metaBuffer: metaBuffer,
3042
- metaBufferArguments: metaBufferArguments,
3043
- metaDetail: metaDetail,
3044
- numberBuffer: numberBuffer,
3045
- pack: pack$1,
3046
- parseBuffer: parseBuffer,
3047
- parseBufferThenConcat: parseBufferThenConcat,
3048
- parseMetaInfo: parseMetaInfo,
3049
- parseTypeName: parseTypeName,
3050
- parseUint8Array: parseUint8Array,
3051
- parseUint8ThenConcat: parseUint8ThenConcat,
3052
- rawPack: rawPack,
3053
- readTail: readTail,
3054
- readTypedBuffer: readTypedBuffer,
3055
- unpack: unpack
3056
- });
3057
-
3058
36
  var eventemitter3 = {exports: {}};
3059
37
 
3060
38
  var hasRequiredEventemitter3;
@@ -3693,28 +671,28 @@ function getSignalPack(tag, ...args) {
3693
671
 
3694
672
  let sigPack;
3695
673
  if (payload.type == PAYLOAD_TYPE.EMPTY) {
3696
- sigPack = mbp.pack(
3697
- mbp.MB('#MsgType', '8', IOMsg.SIGNAL),
3698
- mbp.MB('#tagLen', '8', tagEncoded.byteLength),
3699
- mbp.MB('#tag', tagEncoded),
3700
- mbp.MB('#payloadType', '8', payload.type)
674
+ sigPack = M$1.pack(
675
+ M$1.MB('#MsgType', '8', IOMsg.SIGNAL),
676
+ M$1.MB('#tagLen', '8', tagEncoded.byteLength),
677
+ M$1.MB('#tag', tagEncoded),
678
+ M$1.MB('#payloadType', '8', payload.type)
3701
679
  );
3702
680
  } else if (payload.type == PAYLOAD_TYPE.MBA) {
3703
- let mbaBuffer = mbp.pack(mbp.MBA(...args));
3704
- sigPack = mbp.pack(
3705
- mbp.MB('#MsgType', '8', IOMsg.SIGNAL),
3706
- mbp.MB('#tagLen', '8', tagEncoded.byteLength),
3707
- mbp.MB('#tag', tagEncoded),
3708
- mbp.MB('#payloadType', '8', payload.type),
3709
- mbp.MB('#mbaBuffer', mbaBuffer)
681
+ let mbaBuffer = M$1.pack(M$1.MBA(...args));
682
+ sigPack = M$1.pack(
683
+ M$1.MB('#MsgType', '8', IOMsg.SIGNAL),
684
+ M$1.MB('#tagLen', '8', tagEncoded.byteLength),
685
+ M$1.MB('#tag', tagEncoded),
686
+ M$1.MB('#payloadType', '8', payload.type),
687
+ M$1.MB('#mbaBuffer', mbaBuffer)
3710
688
  );
3711
689
  } else {
3712
- sigPack = mbp.pack(
3713
- mbp.MB('#MsgType', '8', IOMsg.SIGNAL),
3714
- mbp.MB('#tagLen', '8', tagEncoded.byteLength),
3715
- mbp.MB('#tag', tagEncoded),
3716
- mbp.MB('#payloadType', '8', payload.type),
3717
- mbp.MB('#payload', payload.buffer)
690
+ sigPack = M$1.pack(
691
+ M$1.MB('#MsgType', '8', IOMsg.SIGNAL),
692
+ M$1.MB('#tagLen', '8', tagEncoded.byteLength),
693
+ M$1.MB('#tag', tagEncoded),
694
+ M$1.MB('#payloadType', '8', payload.type),
695
+ M$1.MB('#payload', payload.buffer)
3718
696
  );
3719
697
  }
3720
698
  return sigPack
@@ -3734,7 +712,7 @@ function parsePayload(args) {
3734
712
 
3735
713
  } else if (ArrayBuffer.isView(args[0]) || args[0] instanceof ArrayBuffer) {
3736
714
  type = PAYLOAD_TYPE.BINARY;
3737
- pack = mbp.B8(args[0]);
715
+ pack = M$1.B8(args[0]);
3738
716
  } else if (typeof args[0] === 'object') {
3739
717
  type = PAYLOAD_TYPE.OBJECT;
3740
718
  pack = encoder$2.encode(JSON.stringify(args[0]));
@@ -3764,14 +742,21 @@ function getPayloadFromSignalPack(signalPack) {
3764
742
  return signalPack.subarray(3 + tagLen)
3765
743
  }
3766
744
 
3767
- const t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function e(e,r,n,i,o){let f,s,u,h,a,c,l,p,y,g,d,b,B;for(;o>=64;){for(f=r[0],s=r[1],u=r[2],h=r[3],a=r[4],c=r[5],l=r[6],p=r[7],g=0;g<16;g++)d=i+4*g,e[g]=(255&n[d])<<24|(255&n[d+1])<<16|(255&n[d+2])<<8|255&n[d+3];for(g=16;g<64;g++)y=e[g-2],b=(y>>>17|y<<15)^(y>>>19|y<<13)^y>>>10,y=e[g-15],B=(y>>>7|y<<25)^(y>>>18|y<<14)^y>>>3,e[g]=(b+e[g-7]|0)+(B+e[g-16]|0);for(g=0;g<64;g++)b=(((a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7))+(a&c^~a&l)|0)+(p+(t[g]+e[g]|0)|0)|0,B=((f>>>2|f<<30)^(f>>>13|f<<19)^(f>>>22|f<<10))+(f&s^f&u^s&u)|0,p=l,l=c,c=a,a=h+b|0,h=u,u=s,s=f,f=b+B|0;r[0]+=f,r[1]+=s,r[2]+=u,r[3]+=h,r[4]+=a,r[5]+=c,r[6]+=l,r[7]+=p,i+=64,o-=64;}return i}const r=function(){function t(){this.digestLength=32,this.blockSize=64,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=false,this.reset();}return t.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=false,this},t.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset();},t.prototype.update=function(t,r){if(void 0===r&&(r=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");let n=0;if(this.bytesHashed+=r,this.bufferLength>0){for(;this.bufferLength<64&&r>0;)this.buffer[this.bufferLength++]=t[n++],r--;64===this.bufferLength&&(e(this.temp,this.state,this.buffer,0,64),this.bufferLength=0);}for(r>=64&&(n=e(this.temp,this.state,t,n,r),r%=64);r>0;)this.buffer[this.bufferLength++]=t[n++],r--;return this},t.prototype.finish=function(t){if(!this.finished){const t=this.bytesHashed,n=this.bufferLength,i=t/536870912|0,o=t<<3,f=t%64<56?64:128;this.buffer[n]=128;for(var r=n+1;r<f-8;r++)this.buffer[r]=0;this.buffer[f-8]=i>>>24&255,this.buffer[f-7]=i>>>16&255,this.buffer[f-6]=i>>>8&255,this.buffer[f-5]=i>>>0&255,this.buffer[f-4]=o>>>24&255,this.buffer[f-3]=o>>>16&255,this.buffer[f-2]=o>>>8&255,this.buffer[f-1]=o>>>0&255,e(this.temp,this.state,this.buffer,0,f),this.finished=true;}for(r=0;r<8;r++)t[4*r+0]=this.state[r]>>>24&255,t[4*r+1]=this.state[r]>>>16&255,t[4*r+2]=this.state[r]>>>8&255,t[4*r+3]=this.state[r]>>>0&255;return this},t.prototype.digest=function(){const t=new Uint8Array(this.digestLength);return this.finish(t),t},t.prototype._saveState=function(t){for(let e=0;e<this.state.length;e++)t[e]=this.state[e];},t.prototype._restoreState=function(t,e){for(let e=0;e<this.state.length;e++)this.state[e]=t[e];this.bytesHashed=e,this.finished=false,this.bufferLength=0;},t}(),n=function(){function t(t){this.inner=new r,this.outer=new r,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;const e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new r).update(t).finish(e).clean();else for(var n=0;n<t.length;n++)e[n]=t[n];for(n=0;n<e.length;n++)e[n]^=54;this.inner.update(e);for(n=0;n<e.length;n++)e[n]^=106;this.outer.update(e),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(n=0;n<e.length;n++)e[n]=0;}return t.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},t.prototype.clean=function(){for(let t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean();},t.prototype.update=function(t){return this.inner.update(t),this},t.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},t.prototype.digest=function(){const t=new Uint8Array(this.digestLength);return this.finish(t),t},t}();function i(t){const e=(new r).update(t),n=e.digest();return e.clean(),n}var o,f={},s={};var u,h,a={};
3768
- /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */function c(){return u||(u=1,a.read=function(t,e,r,n,i){var o,f,s=8*i-n-1,u=(1<<s)-1,h=u>>1,a=-7,c=r?i-1:0,l=r?-1:1,p=t[e+c];for(c+=l,o=p&(1<<-a)-1,p>>=-a,a+=s;a>0;o=256*o+t[e+c],c+=l,a-=8);for(f=o&(1<<-a)-1,o>>=-a,a+=n;a>0;f=256*f+t[e+c],c+=l,a-=8);if(0===o)o=1-h;else {if(o===u)return f?NaN:1/0*(p?-1:1);f+=Math.pow(2,n),o-=h;}return (p?-1:1)*f*Math.pow(2,o-n)},a.write=function(t,e,r,n,i,o){var f,s,u,h=8*o-i-1,a=(1<<h)-1,c=a>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,y=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,f=a):(f=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-f))<1&&(f--,u*=2),(e+=f+c>=1?l/u:l*Math.pow(2,1-c))*u>=2&&(f++,u/=2),f+c>=a?(s=0,f=a):f+c>=1?(s=(e*u-1)*Math.pow(2,i),f+=c):(s=e*Math.pow(2,c-1)*Math.pow(2,i),f=0));i>=8;t[r+p]=255&s,p+=y,s/=256,i-=8);for(f=f<<i|s,h+=i;h>0;t[r+p]=255&f,p+=y,f/=256,h-=8);t[r+p-y]|=128*g;}),a}
745
+ const t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function e(e,r,n,i,o){let f,s,u,h,a,c,l,p,y,g,d,b,w;for(;o>=64;){for(f=r[0],s=r[1],u=r[2],h=r[3],a=r[4],c=r[5],l=r[6],p=r[7],g=0;g<16;g++)d=i+4*g,e[g]=(255&n[d])<<24|(255&n[d+1])<<16|(255&n[d+2])<<8|255&n[d+3];for(g=16;g<64;g++)y=e[g-2],b=(y>>>17|y<<15)^(y>>>19|y<<13)^y>>>10,y=e[g-15],w=(y>>>7|y<<25)^(y>>>18|y<<14)^y>>>3,e[g]=(b+e[g-7]|0)+(w+e[g-16]|0);for(g=0;g<64;g++)b=(((a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7))+(a&c^~a&l)|0)+(p+(t[g]+e[g]|0)|0)|0,w=((f>>>2|f<<30)^(f>>>13|f<<19)^(f>>>22|f<<10))+(f&s^f&u^s&u)|0,p=l,l=c,c=a,a=h+b|0,h=u,u=s,s=f,f=b+w|0;r[0]+=f,r[1]+=s,r[2]+=u,r[3]+=h,r[4]+=a,r[5]+=c,r[6]+=l,r[7]+=p,i+=64,o-=64;}return i}const r=function(){function t(){this.digestLength=32,this.blockSize=64,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=false,this.reset();}return t.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=false,this},t.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset();},t.prototype.update=function(t,r){if(void 0===r&&(r=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");let n=0;if(this.bytesHashed+=r,this.bufferLength>0){for(;this.bufferLength<64&&r>0;)this.buffer[this.bufferLength++]=t[n++],r--;64===this.bufferLength&&(e(this.temp,this.state,this.buffer,0,64),this.bufferLength=0);}for(r>=64&&(n=e(this.temp,this.state,t,n,r),r%=64);r>0;)this.buffer[this.bufferLength++]=t[n++],r--;return this},t.prototype.finish=function(t){if(!this.finished){const t=this.bytesHashed,n=this.bufferLength,i=t/536870912|0,o=t<<3,f=t%64<56?64:128;this.buffer[n]=128;for(var r=n+1;r<f-8;r++)this.buffer[r]=0;this.buffer[f-8]=i>>>24&255,this.buffer[f-7]=i>>>16&255,this.buffer[f-6]=i>>>8&255,this.buffer[f-5]=i>>>0&255,this.buffer[f-4]=o>>>24&255,this.buffer[f-3]=o>>>16&255,this.buffer[f-2]=o>>>8&255,this.buffer[f-1]=o>>>0&255,e(this.temp,this.state,this.buffer,0,f),this.finished=true;}for(r=0;r<8;r++)t[4*r+0]=this.state[r]>>>24&255,t[4*r+1]=this.state[r]>>>16&255,t[4*r+2]=this.state[r]>>>8&255,t[4*r+3]=this.state[r]>>>0&255;return this},t.prototype.digest=function(){const t=new Uint8Array(this.digestLength);return this.finish(t),t},t.prototype._saveState=function(t){for(let e=0;e<this.state.length;e++)t[e]=this.state[e];},t.prototype._restoreState=function(t,e){for(let e=0;e<this.state.length;e++)this.state[e]=t[e];this.bytesHashed=e,this.finished=false,this.bufferLength=0;},t}(),n=function(){function t(t){this.inner=new r,this.outer=new r,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;const e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new r).update(t).finish(e).clean();else for(var n=0;n<t.length;n++)e[n]=t[n];for(n=0;n<e.length;n++)e[n]^=54;this.inner.update(e);for(n=0;n<e.length;n++)e[n]^=106;this.outer.update(e),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(n=0;n<e.length;n++)e[n]=0;}return t.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},t.prototype.clean=function(){for(let t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean();},t.prototype.update=function(t){return this.inner.update(t),this},t.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},t.prototype.digest=function(){const t=new Uint8Array(this.digestLength);return this.finish(t),t},t}();function i(t){const e=(new r).update(t),n=e.digest();return e.clean(),n}var o,f,s,u={},h={},a={};
746
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */function c(){return f||(f=1,a.read=function(t,e,r,n,i){var o,f,s=8*i-n-1,u=(1<<s)-1,h=u>>1,a=-7,c=r?i-1:0,l=r?-1:1,p=t[e+c];for(c+=l,o=p&(1<<-a)-1,p>>=-a,a+=s;a>0;o=256*o+t[e+c],c+=l,a-=8);for(f=o&(1<<-a)-1,o>>=-a,a+=n;a>0;f=256*f+t[e+c],c+=l,a-=8);if(0===o)o=1-h;else {if(o===u)return f?NaN:1/0*(p?-1:1);f+=Math.pow(2,n),o-=h;}return (p?-1:1)*f*Math.pow(2,o-n)},a.write=function(t,e,r,n,i,o){var f,s,u,h=8*o-i-1,a=(1<<h)-1,c=a>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,y=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,f=a):(f=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-f))<1&&(f--,u*=2),(e+=f+c>=1?l/u:l*Math.pow(2,1-c))*u>=2&&(f++,u/=2),f+c>=a?(s=0,f=a):f+c>=1?(s=(e*u-1)*Math.pow(2,i),f+=c):(s=e*Math.pow(2,c-1)*Math.pow(2,i),f=0));i>=8;t[r+p]=255&s,p+=y,s/=256,i-=8);for(f=f<<i|s,h+=i;h>0;t[r+p]=255&f,p+=y,f/=256,h-=8);t[r+p-y]|=128*g;}),a}
747
+ /*!
748
+ * The buffer module from node.js, for the browser.
749
+ *
750
+ * @author Feross Aboukhadijeh <https://feross.org>
751
+ * @license MIT
752
+ */var l=(s||(s=1,function(t){const e=function(){if(o)return h;o=1,h.byteLength=function(t){var e=f(t),r=e[0],n=e[1];return 3*(r+n)/4-n},h.toByteArray=function(t){var n,i,o=f(t),s=o[0],u=o[1],h=new r(function(t,e,r){return 3*(e+r)/4-r}(0,s,u)),a=0,c=u>0?s-4:s;for(i=0;i<c;i+=4)n=e[t.charCodeAt(i)]<<18|e[t.charCodeAt(i+1)]<<12|e[t.charCodeAt(i+2)]<<6|e[t.charCodeAt(i+3)],h[a++]=n>>16&255,h[a++]=n>>8&255,h[a++]=255&n;return 2===u&&(n=e[t.charCodeAt(i)]<<2|e[t.charCodeAt(i+1)]>>4,h[a++]=255&n),1===u&&(n=e[t.charCodeAt(i)]<<10|e[t.charCodeAt(i+1)]<<4|e[t.charCodeAt(i+2)]>>2,h[a++]=n>>8&255,h[a++]=255&n),h},h.fromByteArray=function(e){for(var r,n=e.length,i=n%3,o=[],f=16383,s=0,h=n-i;s<h;s+=f)o.push(u(e,s,s+f>h?h:s+f));return 1===i?(r=e[n-1],o.push(t[r>>2]+t[r<<4&63]+"==")):2===i&&(r=(e[n-2]<<8)+e[n-1],o.push(t[r>>10]+t[r>>4&63]+t[r<<2&63]+"=")),o.join("")};for(var t=[],e=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0;i<64;++i)t[i]=n[i],e[n.charCodeAt(i)]=i;function f(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return -1===r&&(r=e),[r,r===e?0:4-r%4]}function s(e){return t[e>>18&63]+t[e>>12&63]+t[e>>6&63]+t[63&e]}function u(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),i.push(s(n));return i.join("")}return e["-".charCodeAt(0)]=62,e["_".charCodeAt(0)]=63,h}(),r=c(),n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=s,t.SlowBuffer=function(t){return +t!=t&&(t=0),s.alloc(+t)},t.INSPECT_MAX_BYTES=50;const i=2147483647;function f(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,s.prototype),e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|d(t,e);let n=f(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Q(t,Uint8Array)){const e=new Uint8Array(t);return y(e.buffer,e.byteOffset,e.byteLength)}return p(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Q(t,ArrayBuffer)||t&&Q(t.buffer,ArrayBuffer))return y(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(Q(t,SharedArrayBuffer)||t&&Q(t.buffer,SharedArrayBuffer)))return y(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return s.from(n,e,r);const i=function(t){if(s.isBuffer(t)){const e=0|g(t.length),r=f(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||W(t.length)?f(0):p(t):"Buffer"===t.type&&Array.isArray(t.data)?p(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return s.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function a(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function l(t){return a(t),f(t<0?0:0|g(t))}function p(t){const e=t.length<0?0:0|g(t.length),r=f(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function y(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,s.prototype),n}function g(t){if(t>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Q(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&true===arguments[2];if(!n&&0===r)return 0;let i=false;for(;;)switch(e){case "ascii":case "latin1":case "binary":return r;case "utf8":case "utf-8":return G(t).length;case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return 2*r;case "hex":return r>>>1;case "base64":return K(t).length;default:if(i)return n?-1:G(t).length;e=(""+e).toLowerCase(),i=true;}}function b(t,e,r){let n=false;if((void 0===e||e<0)&&(e=0),e>this.length)return "";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return "";if((r>>>=0)<=(e>>>=0))return "";for(t||(t="utf8");;)switch(t){case "hex":return O(this,e,r);case "utf8":case "utf-8":return v(this,e,r);case "ascii":return T(this,e,r);case "latin1":case "binary":return S(this,e,r);case "base64":return L(this,e,r);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return N(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=true;}}function w(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function B(t,e,r,n,i){if(0===t.length)return -1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),W(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return -1;r=t.length-1;}else if(r<0){if(!i)return -1;r=0;}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:E(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):E(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function E(t,e,r,n,i){let o,f=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return -1;f=2,s/=2,u/=2,r/=2;}function h(t,e){return 1===f?t[e]:t.readUInt16BE(e*f)}if(i){let n=-1;for(o=r;o<s;o++)if(h(t,o)===h(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*f}else -1!==n&&(o-=o-n),n=-1;}else for(r+u>s&&(r=s-u),o=r;o>=0;o--){let r=true;for(let n=0;n<u;n++)if(h(t,o+n)!==h(e,n)){r=false;break}if(r)return o}return -1}function m(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let f;for(n>o/2&&(n=o/2),f=0;f<n;++f){const n=parseInt(e.substr(2*f,2),16);if(W(n))return f;t[r+f]=n;}return f}function A(t,e,r,n){return J(G(e,t.length-r),t,r,n)}function _(t,e,r,n){return J(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function U(t,e,r,n){return J(K(e),t,r,n)}function I(t,e,r,n){return J(function(t,e){let r,n,i;const o=[];for(let f=0;f<t.length&&!((e-=2)<0);++f)r=t.charCodeAt(f),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function L(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function v(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,f=e>239?4:e>223?3:e>191?2:1;if(i+f<=r){let r,n,s,u;switch(f){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],s=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,u>65535&&u<1114112&&(o=u));}}null===o?(o=65533,f=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=f;}return function(t){const e=t.length;if(e<=R)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=R));return r}(n)}t.kMaxLength=i,s.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return false}}(),s.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(s.prototype,"parent",{enumerable:true,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:true,get:function(){if(s.isBuffer(this))return this.byteOffset}}),s.poolSize=8192,s.from=function(t,e,r){return u(t,e,r)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array),s.alloc=function(t,e,r){return function(t,e,r){return a(t),t<=0?f(t):void 0!==e?"string"==typeof r?f(t).fill(e,r):f(t).fill(e):f(t)}(t,e,r)},s.allocUnsafe=function(t){return l(t)},s.allocUnsafeSlow=function(t){return l(t)},s.isBuffer=function(t){return null!=t&&true===t._isBuffer&&t!==s.prototype},s.compare=function(t,e){if(Q(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),Q(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(t)||!s.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},s.isEncoding=function(t){switch(String(t).toLowerCase()){case "hex":case "utf8":case "utf-8":case "ascii":case "latin1":case "binary":case "base64":case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return true;default:return false}},s.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return s.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=s.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(Q(e,Uint8Array))i+e.length>n.length?(s.isBuffer(e)||(e=s.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else {if(!s.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i);}i+=e.length;}return n},s.byteLength=d,s.prototype._isBuffer=true,s.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)w(this,e,e+1);return this},s.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)w(this,e,e+3),w(this,e+1,e+2);return this},s.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)w(this,e,e+7),w(this,e+1,e+6),w(this,e+2,e+5),w(this,e+3,e+4);return this},s.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?v(this,0,t):b.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){let e="";const r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},n&&(s.prototype[n]=s.prototype.inspect),s.prototype.compare=function(t,e,r,n,i){if(Q(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return -1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),f=(r>>>=0)-(e>>>=0);const u=Math.min(o,f),h=this.slice(n,i),a=t.slice(e,r);for(let t=0;t<u;++t)if(h[t]!==a[t]){o=h[t],f=a[t];break}return o<f?-1:f<o?1:0},s.prototype.includes=function(t,e,r){return -1!==this.indexOf(t,e,r)},s.prototype.indexOf=function(t,e,r){return B(this,t,e,r,true)},s.prototype.lastIndexOf=function(t,e,r){return B(this,t,e,r,false)},s.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else {if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0);}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=false;for(;;)switch(n){case "hex":return m(this,t,e,r);case "utf8":case "utf-8":return A(this,t,e,r);case "ascii":case "latin1":case "binary":return _(this,t,e,r);case "base64":return U(this,t,e,r);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return I(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=true;}},s.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const R=4096;function T(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function S(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function O(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=X[t[n]];return i}function N(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function M(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function C(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function x(t,e,r,n,i){D(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,r}function k(t,e,r,n,i){D(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=f,f>>=8,t[r+2]=f,f>>=8,t[r+1]=f,f>>=8,t[r]=f,r+8}function P(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function $(t,e,n,i,o){return e=+e,n>>>=0,o||P(t,0,n,4),r.write(t,e,n,i,23,4),n+4}function F(t,e,n,i,o){return e=+e,n>>>=0,o||P(t,0,n,8),r.write(t,e,n,i,52,8),n+8}s.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,s.prototype),n},s.prototype.readUintLE=s.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||M(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},s.prototype.readUintBE=s.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||M(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUint8=s.prototype.readUInt8=function(t,e){return t>>>=0,e||M(t,1,this.length),this[t]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||M(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||M(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||M(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||M(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readBigUInt64LE=Z(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||q(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))}),s.prototype.readBigUInt64BE=Z(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||q(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return (BigInt(n)<<BigInt(32))+BigInt(i)}),s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||M(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||M(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||M(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||M(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||M(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||M(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||M(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readBigInt64LE=Z(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||q(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return (BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),s.prototype.readBigInt64BE=Z(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||q(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return (BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)}),s.prototype.readFloatLE=function(t,e){return t>>>=0,e||M(t,4,this.length),r.read(this,t,true,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||M(t,4,this.length),r.read(this,t,false,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||M(t,8,this.length),r.read(this,t,true,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||M(t,8,this.length),r.read(this,t,false,52,8)},s.prototype.writeUintLE=s.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||C(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||C(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUint8=s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeBigUInt64LE=Z(function(t,e=0){return x(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeBigUInt64BE=Z(function(t,e=0){return k(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);C(this,t,e,r,n-1,-n);}let i=0,o=1,f=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===f&&0!==this[e+i-1]&&(f=1),this[e+i]=(t/o|0)-f&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);C(this,t,e,r,n-1,-n);}let i=r-1,o=1,f=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===f&&0!==this[e+i+1]&&(f=1),this[e+i]=(t/o|0)-f&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeBigInt64LE=Z(function(t,e=0){return x(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),s.prototype.writeBigInt64BE=Z(function(t,e=0){return k(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),s.prototype.writeFloatLE=function(t,e,r){return $(this,t,e,true,r)},s.prototype.writeFloatBE=function(t,e,r){return $(this,t,e,false,r)},s.prototype.writeDoubleLE=function(t,e,r){return F(this,t,e,true,r)},s.prototype.writeDoubleBE=function(t,e,r){return F(this,t,e,false,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e);}}else "number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else {const o=s.isBuffer(t)?t:s.from(t,n),f=o.length;if(0===f)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%f];}return this};const j={};function z(t,e,r){j[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:true,configurable:true}),this.name=`${this.name} [${t}]`,this.stack,delete this.name;}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:true,enumerable:true,value:t,writable:true});}toString(){return `${this.name} [${t}]: ${this.message}`}};}function H(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return `${t.slice(0,r)}${e}`}function D(t,e,r,n,i,o){if(t>r||t<e){const r="bigint"==typeof e?"n":"";let n;throw n=0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(o+1)}${r}`:`>= -(2${r} ** ${8*(o+1)-1}${r}) and < 2 ** ${8*(o+1)-1}${r}`,new j.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,r){V(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||q(e,t.length-(r+1));}(n,i,o);}function V(t,e){if("number"!=typeof t)throw new j.ERR_INVALID_ARG_TYPE(e,"number",t)}function q(t,e,r){if(Math.floor(t)!==t)throw V(t,r),new j.ERR_OUT_OF_RANGE("offset","an integer",t);if(e<0)throw new j.ERR_BUFFER_OUT_OF_BOUNDS;throw new j.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${e}`,t)}z("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),z("ERR_INVALID_ARG_TYPE",function(t,e){return `The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),z("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=H(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=H(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);const Y=/[^+/0-9A-Za-z-_]/g;function G(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let f=0;f<n;++f){if(r=t.charCodeAt(f),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(f+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320);}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r);}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128);}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128);}else {if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128);}}return o}function K(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(Y,"")).length<2)return "";for(;t.length%4!=0;)t+="=";return t}(t))}function J(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Q(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function W(t){return t!=t}const X=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i];}return e}();function Z(t){return "undefined"==typeof BigInt?tt:t}function tt(){throw new Error("BigInt not supported")}}(u)),u);const p=new TextEncoder,y=new TextDecoder,g=d;function d(t,e=0){let r;if(void 0===t||"string"!=typeof t||"number"!=typeof e)throw TypeError("invlaid init variablie type name. ");return (t=t.toUpperCase()).includes("8")?(r=l.Buffer.alloc(1),t.includes("I")?r.writeInt8(e):r.writeUint8(e)):t.includes("16")?(r=l.Buffer.alloc(2),t.includes("I")?t.includes("L")?r.writeInt16LE(e):r.writeInt16BE(e):t.includes("L")?r.writeUint16LE(e):r.writeUint16BE(e)):t.includes("32")?(r=l.Buffer.alloc(4),t.includes("I")?t.includes("L")?r.writeInt32LE(e):r.writeInt32BE(e):t.includes("L")?r.writeUint32LE(e):r.writeUint32BE(e)):t.includes("F")?(r=l.Buffer.alloc(4),t.includes("L")?r.writeFloatLE(e):r.writeFloatBE(e)):t.includes("N")?r=l.Buffer.from(String(e)):console.log(`invalid type: ${t} or initvalue: ${e}`),r}const b=w;function w(t,e,r){let n,i="B";if("number"==typeof e)"number"==typeof r?(n=l.Buffer.alloc(e),0!==r&&n.fill(r),i="B"):(n=l.Buffer.from(String(e)),i="N");else if("string"==typeof e&&"number"==typeof r)i=e.toUpperCase(),n=d(e,r);else if("string"==typeof e&&void 0===r)n=l.Buffer.from(e),i="S";else if(e instanceof Uint8Array&&void 0===r)n=e instanceof l.Buffer?e:l.Buffer.from(e);else if(e instanceof ArrayBuffer&&void 0===r)n=l.Buffer.from(e);else if(ArrayBuffer.isView(e))n=l.Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if("object"==typeof e&&void 0===r)n=l.Buffer.from(JSON.stringify(e)),i="O";else {if("boolean"!=typeof e||void 0!==r)throw TypeError("invalid meta buffer type");{const t=e?1:0;n=l.Buffer.from([t]),i="!";}}return "string"==typeof t&&t.includes("#")&&(t=""),[t,i,n]}const B=E;function E(...t){let e=0;return t.map(t=>{const r=e++;return "number"==typeof t?b(r,"N",t):b(r,t)})}function m(t){if((t=t.toUpperCase()).includes("8"))return t.includes("I")?"int8":"uint8";if(t.includes("16"))return t.includes("I")?t.includes("L")?"int16_le":"int16_be":t.includes("L")?"uint16_le":"uint16_be";if(t.includes("32"))return t.includes("I")?t.includes("L")?"int32_le":"int32_be":t.includes("L")?"uint32_le":"uint32_be";if(t.includes("F"))return t.includes("L")?"float_le":"float_be";if("B"===t)return "buffer";if("S"===t)return "string";if("N"===t)return "number";if("O"===t)return "object";if("!"===t)return "boolean";throw TypeError("invalid data type")}function A(t,e,r,n){try{const i=m(t);if("int8"==i)return e.readInt8(r);if("uint8"===i)return e.readUint8(r);if("int16_le"===i)return e.readInt16LE(r);if("int16_be"===i)return e.readInt16BE(r);if("uint16_le"===i)return e.readUint16LE(r);if("uint16_be"===i)return e.readUint16BE(r);if("int32_le"===i)return e.readInt32LE(r);if("int32_be"===i)return e.readInt32BE(r);if("uint32_le"===i)return e.readUint32LE(r);if("uint32_be"===i)return e.readUint32BE(r);if("float_le"===i)return e.readFloatLE(r);if("float_be"===i)return e.readFloatBE(r);if("buffer"===i)return e.subarray(r,r+n);if("string"===i){const t=e.subarray(r,r+n);return y.decode(t)}if("number"===i){const t=e.subarray(r,r+n);return Number(y.decode(t))}if("object"===i){const t=e.subarray(r,r+n);return JSON.parse(y.decode(t))}return "boolean"===i?1===e.readInt8(r):void 0}catch(t){}}function _(...t){const e=function(t){let e=[];return t.filter(t=>{if(!Array.isArray(t[0]))return t;e=e.concat(t);}).concat(e)}(t);let r=0;const n=[];let i,o,f=0;if(e.forEach(t=>{const[e,i,o]=t;r+=o.byteLength,("number"==typeof e||e.length>0)&&n.push([e,i,f,o.byteLength]),f=r;}),n.length>0){let t=JSON.stringify(n);i=p.encode(t),o=i.byteLength,r=r+o+2;}const s=l.Buffer.alloc(r);if(f=0,e.forEach(t=>{const e=t[2];s.set(e,f),f+=e.byteLength;}),n.length>0){s.set(i,f);const t=g("16",o);return s.set(t,f+o),s}return s}const U=I;function I(t,e=false){if(void 0===t)throw TypeError("Invalid data type: Undefined");if("string"==typeof t)return p.encode(t);if("number"==typeof t)return Uint8Array.from([t]);if(t instanceof ArrayBuffer){if(e)return new Uint8Array(t);{const e=new Uint8Array(t),r=new Uint8Array(t.byteLength);return r.set(e),r}}if(ArrayBuffer.isView(t)){if(e)return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);{const e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),r=new Uint8Array(t.byteLength);return r.set(e),r}}return p.encode(JSON.stringify(t))}const L=v;function v(t,e=false){const r=I(t,e);return e?l.Buffer.from(r.buffer,r.byteOffset,r.byteLength):l.Buffer.from(r)}const R=T;function T(...t){const e=t.map(t=>v(t));return l.Buffer.concat(e)}const S=O;function O(...t){try{let e=0,r=0;const n=t.map(t=>I(t));n.forEach(t=>{e+=t.byteLength;});const i=new Uint8Array(e);return n.forEach(t=>{i.set(t,r),r+=t.byteLength;}),i}catch(t){console.log(t);}}function N(t){return 0===k(t)?t.byteLength:t.byteLength-k(t)-C}function M(t,e){try{const r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),n=r.byteLength-e-2,i=r.subarray(n,r.byteLength-2),o=y.decode(i),f=JSON.parse(o);if(!Array.isArray(f)||!Array.isArray(f[0]))return;let s=f[0];if(!s)return;if(s.length<3)return;const[u,h,a]=s;if("string"!=typeof h||"number"!=typeof a)return;return f}catch(t){}}const C=2;function x(t){return t instanceof ArrayBuffer&&(t=l.Buffer.from(t)),t instanceof Uint8Array?t.byteLength<=C?0:new DataView(t.buffer,t.byteOffset,t.byteLength).getUint16(t.byteLength-C):0}function k(t){if(t instanceof ArrayBuffer&&(t=l.Buffer.from(t)),t instanceof Uint8Array){const e=t.byteLength;if(e<=C)return 0;const r=x(t);return 0===r||r>e?0:M(t,r)?r:0}return 0}function P(t){const e=N(t);return t.subarray(0,e)}function $(t,e=false){t instanceof ArrayBuffer&&(t=l.Buffer.from(t));const r=x(t);if(0===r)return;let n=M(t,r);return n?e?(n.forEach(t=>{null==t[3]&&(t[1].includes("8")?t[3]=1:t[1].includes("16")?t[3]=2:t[1].includes("32")||t[1].includes("F")?t[3]=4:t[1].includes("!")&&(t[3]=1)),t[4]=m(t[1]);}),n):n:void 0}var F=Object.freeze({__proto__:null,B8:L,B8pack:R,Buffer:l.Buffer,MB:b,MBA:B,NB:g,TAIL_LEN:C,U8:U,U8pack:S,equal:function(t,e){if(t.byteLength!==e.byteLength)return false;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return false;return true},getBuffer:P,getBufferSize:N,getMeta:$,getMetaDetail:function(t){return $(t,true)},getMetaSize:k,hex:function(t){return Array.prototype.map.call(new Uint8Array(t),t=>("00"+t.toString(16)).slice(-2)).join("")},meta:function(...t){return $(_(...t))},metaBuffer:w,metaBufferArguments:E,metaDetail:function(...t){return $(_(...t),true)},numberBuffer:d,pack:_,parseBuffer:v,parseBufferThenConcat:T,parseMetaInfo:M,parseTypeName:m,parseUint8Array:I,parseUint8ThenConcat:O,rawPack:function(...t){return P(_(...t))},readTail:x,readTypedBuffer:A,unpack:function(t,e){const r=e||$(t);if(!r)return;const n=l.Buffer.from(t),i={};let o=0;if(r.forEach(t=>{const[e,r,f,s]=t;let u=A(r,n,f,s);null!=u&&(i[e]=u,s&&(o+=s));}),e&&n.byteLength!==o){let t=n.byteLength-o,e=A("b",n,o,t);if(null==e)return;i.$OTHERS=e;}let f=0,s=[];for(;i[f];)s.push(i[f++]);return s.length>0&&(i.args=s,i.$=i.args),i}});const j={hash:function(t){return i(F.U8(t))},hex:function(t){return F.B8(i(F.U8(t))).toString("hex")},base64:function(t){return F.B8(i(F.U8(t))).toString("base64")}};j.hmac=function(t,e){return function(t,e){const r=new n(t).update(e),i=r.digest();return r.clean(),i}(F.U8(t),F.U8(e))};var z,H={},D={};var V,q,Y={};
753
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */function G(){return V||(V=1,Y.read=function(t,e,r,n,i){var o,f,s=8*i-n-1,u=(1<<s)-1,h=u>>1,a=-7,c=r?i-1:0,l=r?-1:1,p=t[e+c];for(c+=l,o=p&(1<<-a)-1,p>>=-a,a+=s;a>0;o=256*o+t[e+c],c+=l,a-=8);for(f=o&(1<<-a)-1,o>>=-a,a+=n;a>0;f=256*f+t[e+c],c+=l,a-=8);if(0===o)o=1-h;else {if(o===u)return f?NaN:1/0*(p?-1:1);f+=Math.pow(2,n),o-=h;}return (p?-1:1)*f*Math.pow(2,o-n)},Y.write=function(t,e,r,n,i,o){var f,s,u,h=8*o-i-1,a=(1<<h)-1,c=a>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,y=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,f=a):(f=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-f))<1&&(f--,u*=2),(e+=f+c>=1?l/u:l*Math.pow(2,1-c))*u>=2&&(f++,u/=2),f+c>=a?(s=0,f=a):f+c>=1?(s=(e*u-1)*Math.pow(2,i),f+=c):(s=e*Math.pow(2,c-1)*Math.pow(2,i),f=0));i>=8;t[r+p]=255&s,p+=y,s/=256,i-=8);for(f=f<<i|s,h+=i;h>0;t[r+p]=255&f,p+=y,f/=256,h-=8);t[r+p-y]|=128*g;}),Y}
3769
754
  /*!
3770
755
  * The buffer module from node.js, for the browser.
3771
756
  *
3772
757
  * @author Feross Aboukhadijeh <https://feross.org>
3773
758
  * @license MIT
3774
- */var l=(h||(h=1,function(t){const e=function(){if(o)return s;o=1,s.byteLength=function(t){var e=f(t),r=e[0],n=e[1];return 3*(r+n)/4-n},s.toByteArray=function(t){var n,i,o=f(t),s=o[0],u=o[1],h=new r(function(t,e,r){return 3*(e+r)/4-r}(0,s,u)),a=0,c=u>0?s-4:s;for(i=0;i<c;i+=4)n=e[t.charCodeAt(i)]<<18|e[t.charCodeAt(i+1)]<<12|e[t.charCodeAt(i+2)]<<6|e[t.charCodeAt(i+3)],h[a++]=n>>16&255,h[a++]=n>>8&255,h[a++]=255&n;return 2===u&&(n=e[t.charCodeAt(i)]<<2|e[t.charCodeAt(i+1)]>>4,h[a++]=255&n),1===u&&(n=e[t.charCodeAt(i)]<<10|e[t.charCodeAt(i+1)]<<4|e[t.charCodeAt(i+2)]>>2,h[a++]=n>>8&255,h[a++]=255&n),h},s.fromByteArray=function(e){for(var r,n=e.length,i=n%3,o=[],f=16383,s=0,u=n-i;s<u;s+=f)o.push(h(e,s,s+f>u?u:s+f));return 1===i?(r=e[n-1],o.push(t[r>>2]+t[r<<4&63]+"==")):2===i&&(r=(e[n-2]<<8)+e[n-1],o.push(t[r>>10]+t[r>>4&63]+t[r<<2&63]+"=")),o.join("")};for(var t=[],e=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0;i<64;++i)t[i]=n[i],e[n.charCodeAt(i)]=i;function f(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return -1===r&&(r=e),[r,r===e?0:4-r%4]}function u(e){return t[e>>18&63]+t[e>>12&63]+t[e>>6&63]+t[63&e]}function h(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),i.push(u(n));return i.join("")}return e["-".charCodeAt(0)]=62,e["_".charCodeAt(0)]=63,s}(),r=c(),n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=u,t.SlowBuffer=function(t){return +t!=t&&(t=0),u.alloc(+t)},t.INSPECT_MAX_BYTES=50;const i=2147483647;function f(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return h(t,e,r)}function h(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|d(t,e);let n=f(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Q(t,Uint8Array)){const e=new Uint8Array(t);return y(e.buffer,e.byteOffset,e.byteLength)}return p(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Q(t,ArrayBuffer)||t&&Q(t.buffer,ArrayBuffer))return y(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(Q(t,SharedArrayBuffer)||t&&Q(t.buffer,SharedArrayBuffer)))return y(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const i=function(t){if(u.isBuffer(t)){const e=0|g(t.length),r=f(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||W(t.length)?f(0):p(t):"Buffer"===t.type&&Array.isArray(t.data)?p(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function a(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function l(t){return a(t),f(t<0?0:0|g(t))}function p(t){const e=t.length<0?0:0|g(t.length),r=f(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function y(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,u.prototype),n}function g(t){if(t>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function d(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Q(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&true===arguments[2];if(!n&&0===r)return 0;let i=false;for(;;)switch(e){case "ascii":case "latin1":case "binary":return r;case "utf8":case "utf-8":return Y(t).length;case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return 2*r;case "hex":return r>>>1;case "base64":return G(t).length;default:if(i)return n?-1:Y(t).length;e=(""+e).toLowerCase(),i=true;}}function b(t,e,r){let n=false;if((void 0===e||e<0)&&(e=0),e>this.length)return "";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return "";if((r>>>=0)<=(e>>>=0))return "";for(t||(t="utf8");;)switch(t){case "hex":return M(this,e,r);case "utf8":case "utf-8":return v(this,e,r);case "ascii":return N(this,e,r);case "latin1":case "binary":return T(this,e,r);case "base64":return I(this,e,r);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return R(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=true;}}function B(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function w(t,e,r,n,i){if(0===t.length)return -1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),W(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return -1;r=t.length-1;}else if(r<0){if(!i)return -1;r=0;}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:E(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):E(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function E(t,e,r,n,i){let o,f=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return -1;f=2,s/=2,u/=2,r/=2;}function h(t,e){return 1===f?t[e]:t.readUInt16BE(e*f)}if(i){let n=-1;for(o=r;o<s;o++)if(h(t,o)===h(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*f}else -1!==n&&(o-=o-n),n=-1;}else for(r+u>s&&(r=s-u),o=r;o>=0;o--){let r=true;for(let n=0;n<u;n++)if(h(t,o+n)!==h(e,n)){r=false;break}if(r)return o}return -1}function m(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let f;for(n>o/2&&(n=o/2),f=0;f<n;++f){const n=parseInt(e.substr(2*f,2),16);if(W(n))return f;t[r+f]=n;}return f}function _(t,e,r,n){return J(Y(e,t.length-r),t,r,n)}function A(t,e,r,n){return J(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function U(t,e,r,n){return J(G(e),t,r,n)}function L(t,e,r,n){return J(function(t,e){let r,n,i;const o=[];for(let f=0;f<t.length&&!((e-=2)<0);++f)r=t.charCodeAt(f),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function I(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function v(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,f=e>239?4:e>223?3:e>191?2:1;if(i+f<=r){let r,n,s,u;switch(f){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],s=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,u>65535&&u<1114112&&(o=u));}}null===o?(o=65533,f=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=f;}return function(t){const e=t.length;if(e<=S)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=S));return r}(n)}t.kMaxLength=i,u.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return false}}(),u.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(u.prototype,"parent",{enumerable:true,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:true,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(t,e,r){return h(t,e,r)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(t,e,r){return function(t,e,r){return a(t),t<=0?f(t):void 0!==e?"string"==typeof r?f(t).fill(e,r):f(t).fill(e):f(t)}(t,e,r)},u.allocUnsafe=function(t){return l(t)},u.allocUnsafeSlow=function(t){return l(t)},u.isBuffer=function(t){return null!=t&&true===t._isBuffer&&t!==u.prototype},u.compare=function(t,e){if(Q(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),Q(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},u.isEncoding=function(t){switch(String(t).toLowerCase()){case "hex":case "utf8":case "utf-8":case "ascii":case "latin1":case "binary":case "base64":case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return true;default:return false}},u.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=u.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(Q(e,Uint8Array))i+e.length>n.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else {if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i);}i+=e.length;}return n},u.byteLength=d,u.prototype._isBuffer=true,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)B(this,e,e+1);return this},u.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)B(this,e,e+3),B(this,e+1,e+2);return this},u.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)B(this,e,e+7),B(this,e+1,e+6),B(this,e+2,e+5),B(this,e+3,e+4);return this},u.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?v(this,0,t):b.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){let e="";const r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},n&&(u.prototype[n]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,i){if(Q(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return -1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),f=(r>>>=0)-(e>>>=0);const s=Math.min(o,f),h=this.slice(n,i),a=t.slice(e,r);for(let t=0;t<s;++t)if(h[t]!==a[t]){o=h[t],f=a[t];break}return o<f?-1:f<o?1:0},u.prototype.includes=function(t,e,r){return -1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return w(this,t,e,r,true)},u.prototype.lastIndexOf=function(t,e,r){return w(this,t,e,r,false)},u.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else {if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0);}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=false;for(;;)switch(n){case "hex":return m(this,t,e,r);case "utf8":case "utf-8":return _(this,t,e,r);case "ascii":case "latin1":case "binary":return A(this,t,e,r);case "base64":return U(this,t,e,r);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return L(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=true;}},u.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const S=4096;function N(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function T(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function M(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=X[t[n]];return i}function R(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function O(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function C(t,e,r,n,i,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function k(t,e,r,n,i){D(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,r}function x(t,e,r,n,i){D(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=f,f>>=8,t[r+2]=f,f>>=8,t[r+1]=f,f>>=8,t[r]=f,r+8}function P(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function H(t,e,n,i,o){return e=+e,n>>>=0,o||P(t,0,n,4),r.write(t,e,n,i,23,4),n+4}function $(t,e,n,i,o){return e=+e,n>>>=0,o||P(t,0,n,8),r.write(t,e,n,i,52,8),n+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,u.prototype),n},u.prototype.readUintLE=u.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},u.prototype.readUintBE=u.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||q(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))}),u.prototype.readBigUInt64BE=Z(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||q(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return (BigInt(n)<<BigInt(32))+BigInt(i)}),u.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},u.prototype.readInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||O(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||O(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||q(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return (BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),u.prototype.readBigInt64BE=Z(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||q(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return (BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)}),u.prototype.readFloatLE=function(t,e){return t>>>=0,e||O(t,4,this.length),r.read(this,t,true,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||O(t,4,this.length),r.read(this,t,false,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||O(t,8,this.length),r.read(this,t,true,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||O(t,8,this.length),r.read(this,t,false,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||C(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||C(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z(function(t,e=0){return k(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=Z(function(t,e=0){return x(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);C(this,t,e,r,n-1,-n);}let i=0,o=1,f=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===f&&0!==this[e+i-1]&&(f=1),this[e+i]=(t/o|0)-f&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);C(this,t,e,r,n-1,-n);}let i=r-1,o=1,f=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===f&&0!==this[e+i+1]&&(f=1),this[e+i]=(t/o|0)-f&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z(function(t,e=0){return k(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=Z(function(t,e=0){return x(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeFloatLE=function(t,e,r){return H(this,t,e,true,r)},u.prototype.writeFloatBE=function(t,e,r){return H(this,t,e,false,r)},u.prototype.writeDoubleLE=function(t,e,r){return $(this,t,e,true,r)},u.prototype.writeDoubleBE=function(t,e,r){return $(this,t,e,false,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},u.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e);}}else "number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else {const o=u.isBuffer(t)?t:u.from(t,n),f=o.length;if(0===f)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%f];}return this};const z={};function F(t,e,r){z[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:true,configurable:true}),this.name=`${this.name} [${t}]`,this.stack,delete this.name;}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:true,enumerable:true,value:t,writable:true});}toString(){return `${this.name} [${t}]: ${this.message}`}};}function j(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return `${t.slice(0,r)}${e}`}function D(t,e,r,n,i,o){if(t>r||t<e){const r="bigint"==typeof e?"n":"";let n;throw n=0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(o+1)}${r}`:`>= -(2${r} ** ${8*(o+1)-1}${r}) and < 2 ** ${8*(o+1)-1}${r}`,new z.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,r){V(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||q(e,t.length-(r+1));}(n,i,o);}function V(t,e){if("number"!=typeof t)throw new z.ERR_INVALID_ARG_TYPE(e,"number",t)}function q(t,e,r){if(Math.floor(t)!==t)throw V(t,r),new z.ERR_OUT_OF_RANGE("offset","an integer",t);if(e<0)throw new z.ERR_BUFFER_OUT_OF_BOUNDS;throw new z.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${e}`,t)}F("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),F("ERR_INVALID_ARG_TYPE",function(t,e){return `The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),F("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=j(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=j(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);const K=/[^+/0-9A-Za-z-_]/g;function Y(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let f=0;f<n;++f){if(r=t.charCodeAt(f),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(f+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320);}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r);}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128);}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128);}else {if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128);}}return o}function G(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(K,"")).length<2)return "";for(;t.length%4!=0;)t+="=";return t}(t))}function J(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Q(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function W(t){return t!=t}const X=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i];}return e}();function Z(t){return "undefined"==typeof BigInt?tt:t}function tt(){throw new Error("BigInt not supported")}}(f)),f);const p=new TextEncoder,y=new TextDecoder,g=d;function d(t,e=0){let r;if(void 0===t||"string"!=typeof t||"number"!=typeof e)throw TypeError("invlaid init variablie type name. ");return (t=t.toUpperCase()).includes("8")?(r=l.Buffer.alloc(1),t.includes("I")?r.writeInt8(e):r.writeUint8(e)):t.includes("16")?(r=l.Buffer.alloc(2),t.includes("I")?t.includes("L")?r.writeInt16LE(e):r.writeInt16BE(e):t.includes("L")?r.writeUint16LE(e):r.writeUint16BE(e)):t.includes("32")?(r=l.Buffer.alloc(4),t.includes("I")?t.includes("L")?r.writeInt32LE(e):r.writeInt32BE(e):t.includes("L")?r.writeUint32LE(e):r.writeUint32BE(e)):t.includes("F")?(r=l.Buffer.alloc(4),t.includes("L")?r.writeFloatLE(e):r.writeFloatBE(e)):t.includes("N")?r=l.Buffer.from(String(e)):console.log(`invalid type: ${t} or initvalue: ${e}`),r}const b=B;function B(t,e,r){let n,i="B";if("number"==typeof e)"number"==typeof r?(n=l.Buffer.alloc(e),0!==r&&n.fill(r),i="B"):(n=l.Buffer.from(String(e)),i="N");else if("string"==typeof e&&"number"==typeof r)i=e.toUpperCase(),n=d(e,r);else if("string"==typeof e&&void 0===r)n=l.Buffer.from(e),i="S";else if(e instanceof Uint8Array&&void 0===r)n=e instanceof l.Buffer?e:l.Buffer.from(e);else if(e instanceof ArrayBuffer&&void 0===r)n=l.Buffer.from(e);else if(ArrayBuffer.isView(e))n=l.Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if("object"==typeof e&&void 0===r)n=l.Buffer.from(JSON.stringify(e)),i="O";else {if("boolean"!=typeof e||void 0!==r)throw TypeError("invalid meta buffer type");{const t=e?1:0;n=l.Buffer.from([t]),i="!";}}return "string"==typeof t&&t.includes("#")&&(t=""),[t,i,n]}const w=E;function E(...t){let e=0;return t.map(t=>{const r=e++;return "number"==typeof t?b(r,"N",t):b(r,t)})}function m(t){if((t=t.toUpperCase()).includes("8"))return t.includes("I")?"int8":"uint8";if(t.includes("16"))return t.includes("I")?t.includes("L")?"int16_le":"int16_be":t.includes("L")?"uint16_le":"uint16_be";if(t.includes("32"))return t.includes("I")?t.includes("L")?"int32_le":"int32_be":t.includes("L")?"uint32_le":"uint32_be";if(t.includes("F"))return t.includes("L")?"float_le":"float_be";if("B"===t)return "buffer";if("S"===t)return "string";if("N"===t)return "number";if("O"===t)return "object";if("!"===t)return "boolean";throw TypeError("invalid data type")}function _(t,e,r,n){try{const i=m(t);if("int8"==i)return e.readInt8(r);if("uint8"===i)return e.readUint8(r);if("int16_le"===i)return e.readInt16LE(r);if("int16_be"===i)return e.readInt16BE(r);if("uint16_le"===i)return e.readUint16LE(r);if("uint16_be"===i)return e.readUint16BE(r);if("int32_le"===i)return e.readInt32LE(r);if("int32_be"===i)return e.readInt32BE(r);if("uint32_le"===i)return e.readUint32LE(r);if("uint32_be"===i)return e.readUint32BE(r);if("float_le"===i)return e.readFloatLE(r);if("float_be"===i)return e.readFloatBE(r);if("buffer"===i)return e.subarray(r,r+n);if("string"===i){const t=e.subarray(r,r+n);return y.decode(t)}if("number"===i){const t=e.subarray(r,r+n);return Number(y.decode(t))}if("object"===i){const t=e.subarray(r,r+n);return JSON.parse(y.decode(t))}if("boolean"===i){return 1===e.readInt8(r)}return}catch(t){}}function A(...t){const e=function(t){let e=[];return t.filter(t=>{if(!Array.isArray(t[0]))return t;e=e.concat(t);}).concat(e)}(t);let r=0;const n=[];let i,o,f=0;if(e.forEach(t=>{const[e,i,o]=t;r+=o.byteLength,("number"==typeof e||e.length>0)&&n.push([e,i,f,o.byteLength]),f=r;}),n.length>0){let t=JSON.stringify(n);i=p.encode(t),o=i.byteLength,r=r+o+2;}const s=l.Buffer.alloc(r);if(f=0,e.forEach(t=>{const e=t[2];s.set(e,f),f+=e.byteLength;}),n.length>0){s.set(i,f);const t=g("16",o);return s.set(t,f+o),s}return s}const U=L;function L(t,e=false){if(void 0===t)throw TypeError("Invalid data type: Undefined");if("string"==typeof t)return p.encode(t);if("number"==typeof t)return Uint8Array.from([t]);if(t instanceof ArrayBuffer){if(e)return new Uint8Array(t);{const e=new Uint8Array(t),r=new Uint8Array(t.byteLength);return r.set(e),r}}if(ArrayBuffer.isView(t)){if(e)return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);{const e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),r=new Uint8Array(t.byteLength);return r.set(e),r}}return p.encode(JSON.stringify(t))}const I=v;function v(t,e=false){const r=L(t,e);return e?l.Buffer.from(r.buffer,r.byteOffset,r.byteLength):l.Buffer.from(r)}const S=N;function N(...t){const e=t.map(t=>v(t));return l.Buffer.concat(e)}const T=M;function M(...t){try{let e=0,r=0;const n=t.map(t=>L(t));n.forEach(t=>{e+=t.byteLength;});const i=new Uint8Array(e);return n.forEach(t=>{i.set(t,r),r+=t.byteLength;}),i}catch(t){console.log(t);}}function R(t){return 0===x(t)?t.byteLength:t.byteLength-x(t)-C}function O(t,e){try{const r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),n=r.byteLength-e-2,i=r.subarray(n,r.byteLength-2),o=y.decode(i),f=JSON.parse(o);if(!Array.isArray(f)||!Array.isArray(f[0]))return;let s=f[0];if(!s)return;if(s.length<3)return;const[u,h,a]=s;if("string"!=typeof h||"number"!=typeof a)return;return f}catch(t){}}const C=2;function k(t){if(t instanceof ArrayBuffer&&(t=l.Buffer.from(t)),t instanceof Uint8Array){if(t.byteLength<=C)return 0;return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint16(t.byteLength-C)}return 0}function x(t){if(t instanceof ArrayBuffer&&(t=l.Buffer.from(t)),t instanceof Uint8Array){const e=t.byteLength;if(e<=C)return 0;const r=k(t);if(0===r||r>e)return 0;return O(t,r)?r:0}return 0}function P(t){const e=R(t);return t.subarray(0,e)}function H(t,e=false){t instanceof ArrayBuffer&&(t=l.Buffer.from(t));const r=k(t);if(0===r)return;let n=O(t,r);return n?e?(n.forEach(t=>{null==t[3]&&(t[1].includes("8")?t[3]=1:t[1].includes("16")?t[3]=2:t[1].includes("32")||t[1].includes("F")?t[3]=4:t[1].includes("!")&&(t[3]=1)),t[4]=m(t[1]);}),n):n:void 0}var $=Object.freeze({__proto__:null,B8:I,B8pack:S,Buffer:l.Buffer,MB:b,MBA:w,NB:g,TAIL_LEN:C,U8:U,U8pack:T,equal:function(t,e){if(t.byteLength!==e.byteLength)return false;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return false;return true},getBuffer:P,getBufferSize:R,getMeta:H,getMetaDetail:function(t){return H(t,true)},getMetaSize:x,hex:function(t){return Array.prototype.map.call(new Uint8Array(t),t=>("00"+t.toString(16)).slice(-2)).join("")},meta:function(...t){return H(A(...t))},metaBuffer:B,metaBufferArguments:E,metaDetail:function(...t){return H(A(...t),true)},numberBuffer:d,pack:A,parseBuffer:v,parseBufferThenConcat:N,parseMetaInfo:O,parseTypeName:m,parseUint8Array:L,parseUint8ThenConcat:M,rawPack:function(...t){return P(A(...t))},readTail:k,readTypedBuffer:_,unpack:function(t,e){const r=e||H(t);if(!r)return;const n=l.Buffer.from(t),i={};let o=0;if(r.forEach(t=>{const[e,r,f,s]=t;let u=_(r,n,f,s);null!=u&&(i[e]=u,s&&(o+=s));}),e&&n.byteLength!==o){let t=n.byteLength-o,e=_("b",n,o,t);if(null==e)return;i.$OTHERS=e;}let f=0,s=[];for(;i[f];)s.push(i[f++]);return s.length>0&&(i.args=s,i.$=i.args),i}});const z={hash:function(t){return i($.U8(t))},hex:function(t){return $.B8(i($.U8(t))).toString("hex")},base64:function(t){return $.B8(i($.U8(t))).toString("base64")}};z.hmac=function(t,e){return function(t,e){const r=new n(t).update(e),i=r.digest();return r.clean(),i}($.U8(t),$.U8(e))};let F={SERVER_TIME_NONCE:176,AUTH_REQ:177,AUTH_RES:178,AUTH_FAIL:179,ENC_PACK:182,ENC_E2E:183,ENC_488:184};for(let t in F)F[F[t]]=t;const j={SERVER_TIME_NONCE:$.meta($.MB("header","8",0),$.MB("unixTime","32L",0),$.MB("milTime","16L",0),$.MB("counter","16L",0),$.MB("nonce",l.Buffer.alloc(4))),AUTH_REQ:$.meta($.MB("header","8",0),$.MB("id8",l.Buffer.alloc(8)),$.MB("nonce",l.Buffer.alloc(4)),$.MB("hmac32",l.Buffer.alloc(32))),AUTH_RES:$.meta($.MB("header","8",0),$.MB("hmac32",l.Buffer.alloc(32))),ENC_PACK:$.meta($.MB("type","8",0),$.MB("len","32L",0),$.MB("salt12",l.Buffer.alloc(12)),$.MB("hmac",8,0)),ENC_488:$.meta($.MB("type","8",0),$.MB("len","32L",0),$.MB("otpSrc8",l.Buffer.alloc(8)),$.MB("hmac8",l.Buffer.alloc(8)))};function D(t){let e=t[t.length-1];return e[2]+e[3]}const V={SERVER_TIME_NONCE:D(j.SERVER_TIME_NONCE),AUTH_REQ:D(j.AUTH_REQ),AUTH_RES:D(j.AUTH_RES),ENC_PACK:D(j.ENC_PACK),ENC_488:D(j.ENC_488)};function q(t){return globalThis.crypto.getRandomValues(l.Buffer.alloc(t))}class K{constructor(){this._id8=l.Buffer.alloc(8),this._otpSrc44=l.Buffer.alloc(44),this._otp36=l.Buffer.alloc(36),this._hmac=l.Buffer.alloc(32),this.auth_salt12=l.Buffer.alloc(12),this.localNonce=l.Buffer.alloc(4),this.remoteNonce=l.Buffer.alloc(4),this.isAuthorized=false,this.counter=0;}clearAuth(){this._id8.fill(0),this._otpSrc44.fill(0),this._otp36.fill(0),this._hmac.fill(0),this.auth_salt12.fill(0),this.localNonce.fill(0),this.remoteNonce.fill(0),this.isAuthorized=false,this.counter=0;}set_hash_id8(t){$.B8(z.hash(t)).copy(this._id8,0,0,8);}set_id8(t){let e=$.B8(t);this._id8.fill(0),e.copy(this._id8,0,0,8);}set_key(t){$.B8(z.hash(t)).copy(this._otpSrc44,0,0,32);}set_id_key(t){let e=t.indexOf(".");if(-1==e)return;let r=t.substring(0,e),n=t.substring(e+1);this.set_id8(r),this.set_key(n);}copy_id8(t){t.copy(this._id8,0,0,8);}copy_key(t){t.copy(this._otpSrc44,0,0,32);}sha256_n(t,e){let r=z.hash(t);for(let t=0;t<e;t++)r=z.hash(r);return r}set_clock_rand(){const t=Date.now(),e=parseInt(t/1e3),r=t%1e3;++this.counter>65535&&(this.counter=0);l.Buffer.concat([$.NB("32L",e),$.NB("16L",r),$.NB("16L",this.counter),q(4)]).copy(this._otpSrc44,32);}set_clock_nonce(t){const e=Date.now(),r=parseInt(e/1e3),n=e%1e3;++this.counter>65535&&(this.counter=0);l.Buffer.concat([$.NB("32L",r),$.NB("16L",n),$.NB("16L",this.counter),t]).copy(this._otpSrc44,32);}set_salt12(t,e){if(12!=t.byteLength)throw TypeError("set_salt12: Invalid salt12 byteLength.");t.copy(this._otpSrc44,32);}resetOTP(){$.B8(z.hash(this._otpSrc44)).copy(this._otp36,0,0,32);}getIndexOTP(t){return this._otp36.writeUInt32LE(t,32),z.hash(this._otp36)}generateHMAC(t){let e=l.Buffer.concat([this._otpSrc44,t]);this._hmac=$.B8(z.hash(e));}getHMAC8(t){let e=l.Buffer.concat([this._otpSrc44,t]);return this._hmac=$.B8(z.hash(e)),this._hmac.subarray(0,8)}xotp(t,e=0,r=false){let n=(t=$.B8(t,r)).byteLength,i=e,o=0,f=0;for(;n>0;){f=n<32?n:32;let e=this.getIndexOTP(++i);for(let r=0;r<f;r++)t[o++]^=e[r];n-=32;}return t}server_time_nonce(){const t=Date.now(),e=Math.floor(t/1e3),r=t%1e3;return this.localNonce=q(4),this.auth_salt12=l.Buffer.concat([$.NB("32L",e),$.NB("16L",r),q(2),this.localNonce]),l.Buffer.concat([$.NB("8",F.SERVER_TIME_NONCE),this.auth_salt12])}auth_req(t){let e=$.unpack(t,j.SERVER_TIME_NONCE);if(e){let t=l.Buffer.concat([$.NB("32L",e.unixTime),$.NB("16L",e.milTime),$.NB("16L",e.counter),e.nonce]);return this.set_salt12(t,"auth_req"),this.localNonce=q(4),this.generateHMAC(this.localNonce),this.remoteNonce=e.nonce,$.pack($.MB("#header","8",F.AUTH_REQ),$.MB("#id8",this._id8),$.MB("#nonce",this.localNonce),$.MB("#hmac32",this._hmac))}return false}verify_auth_req(t){let e;if(t instanceof Uint8Array){if(e=$.unpack(t,j.AUTH_REQ),!e)return}else e=t;this.set_salt12(this.auth_salt12,"verify_auth_req 1/2"),this.generateHMAC(e.nonce);let r=this._hmac;if($.equal(e.hmac32,r)){this.remoteNonce=e.nonce;let t=l.Buffer.concat([this.localNonce,this.remoteNonce,this.localNonce]);this.set_salt12(t,"verify_auth_req 2/2"),this.generateHMAC(e.nonce);let r=this._hmac,n=$.rawPack($.MB("header","8",F.AUTH_RES),$.MB("hmac32",r));return this.isAuthorized=true,n}return false}verify_auth_res(t){let e=$.unpack(t,j.AUTH_RES);if(e){let t=l.Buffer.concat([this.remoteNonce,this.localNonce,this.remoteNonce]);this.set_salt12(t,"verify_auth_res"),this.generateHMAC(this.localNonce);let r=this._hmac;if($.equal(r,e.hmac32))return this.isAuthorized=true,true}}encrypt_488(t){if(!this.isAuthorized)return;t=$.B8(t),this.set_clock_nonce(this.remoteNonce),this.resetOTP();let e=this.getHMAC8(t),r=this.xotp(t);return $.pack($.MB("#type","8",F.ENC_488),$.MB("#len","32L",t.byteLength),$.MB("#otpSrc8",this._otpSrc44.subarray(32,40)),$.MB("#hmac8",e),$.MB("#xdata",r))}decrypt_488(t){t=$.B8(t);let e=$.unpack(t,j.ENC_488);if(e){let t=l.Buffer.concat([e.otpSrc8,this.localNonce]);this.set_salt12(t,"decrypt_488"),this.resetOTP();let r=e.$OTHERS.subarray(0,e.len),n=this.xotp(r),i=this.getHMAC8(n);if($.equal(i,e.hmac8))return n}}encryptPack(t){t=$.B8(t),this.set_clock_rand(),this.resetOTP();let e=this.getHMAC8(t),r=this.xotp(t);return $.pack($.MB("#type","8",F.ENC_PACK),$.MB("#len","32L",t.byteLength),$.MB("#salt12",this._otpSrc44.subarray(32)),$.MB("#hmac8",e),$.MB("#xdata",r))}decryptPack(t){if(t[0]!==F.ENC_PACK)return;if(t.readUint32LE(1)==t.byteLength-V.ENC_PACK)try{let e=$.unpack(t,j.ENC_PACK);if(!e)return;this.set_salt12(e.salt12,"decryptPack"),this.resetOTP();let r=e.$OTHERS,n=this.xotp(r),i=this.getHMAC8(n);if($.equal(e.hmac,i))return e.data=n,e}catch(t){}}encrypt_e2e(t,e){let r=l.Buffer.alloc(32);r.set(this._otpSrc44.subarray(0,32)),this.set_key(e);let n=this.encryptPack(t);return this._otpSrc44.set(r),n}decrypt_e2e(t,e){let r=l.Buffer.alloc(32);r.set(this._otpSrc44.subarray(0,32)),this.set_key(e);let n=this.decryptPack(t);return this._otpSrc44.set(r),n}}K.RAND=q,K.BohoMsg=F,K.Meta=j,K.MetaSize=V,K.sha256=z,K.MBP=$,K.Buffer=l.Buffer;
759
+ */var K=(q||(q=1,function(t){const e=function(){if(z)return D;z=1,D.byteLength=function(t){var e=o(t),r=e[0],n=e[1];return 3*(r+n)/4-n},D.toByteArray=function(t){var n,i,f=o(t),s=f[0],u=f[1],h=new r(function(t,e,r){return 3*(e+r)/4-r}(0,s,u)),a=0,c=u>0?s-4:s;for(i=0;i<c;i+=4)n=e[t.charCodeAt(i)]<<18|e[t.charCodeAt(i+1)]<<12|e[t.charCodeAt(i+2)]<<6|e[t.charCodeAt(i+3)],h[a++]=n>>16&255,h[a++]=n>>8&255,h[a++]=255&n;return 2===u&&(n=e[t.charCodeAt(i)]<<2|e[t.charCodeAt(i+1)]>>4,h[a++]=255&n),1===u&&(n=e[t.charCodeAt(i)]<<10|e[t.charCodeAt(i+1)]<<4|e[t.charCodeAt(i+2)]>>2,h[a++]=n>>8&255,h[a++]=255&n),h},D.fromByteArray=function(e){for(var r,n=e.length,i=n%3,o=[],f=16383,u=0,h=n-i;u<h;u+=f)o.push(s(e,u,u+f>h?h:u+f));return 1===i?(r=e[n-1],o.push(t[r>>2]+t[r<<4&63]+"==")):2===i&&(r=(e[n-2]<<8)+e[n-1],o.push(t[r>>10]+t[r>>4&63]+t[r<<2&63]+"=")),o.join("")};for(var t=[],e=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0;i<64;++i)t[i]=n[i],e[n.charCodeAt(i)]=i;function o(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return -1===r&&(r=e),[r,r===e?0:4-r%4]}function f(e){return t[e>>18&63]+t[e>>12&63]+t[e>>6&63]+t[63&e]}function s(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),i.push(f(n));return i.join("")}return e["-".charCodeAt(0)]=62,e["_".charCodeAt(0)]=63,D}(),r=G(),n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=f,t.SlowBuffer=function(t){return +t!=t&&(t=0),f.alloc(+t)},t.INSPECT_MAX_BYTES=50;const i=2147483647;function o(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,f.prototype),e}function f(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return h(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!f.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|p(t,e);let n=o(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Q(t,Uint8Array)){const e=new Uint8Array(t);return c(e.buffer,e.byteOffset,e.byteLength)}return a(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Q(t,ArrayBuffer)||t&&Q(t.buffer,ArrayBuffer))return c(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(Q(t,SharedArrayBuffer)||t&&Q(t.buffer,SharedArrayBuffer)))return c(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return f.from(n,e,r);const i=function(t){if(f.isBuffer(t)){const e=0|l(t.length),r=o(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||W(t.length)?o(0):a(t):"Buffer"===t.type&&Array.isArray(t.data)?a(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return f.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function h(t){return u(t),o(t<0?0:0|l(t))}function a(t){const e=t.length<0?0:0|l(t.length),r=o(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function c(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,f.prototype),n}function l(t){if(t>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(f.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Q(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&true===arguments[2];if(!n&&0===r)return 0;let i=false;for(;;)switch(e){case "ascii":case "latin1":case "binary":return r;case "utf8":case "utf-8":return Y(t).length;case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return 2*r;case "hex":return r>>>1;case "base64":return K(t).length;default:if(i)return n?-1:Y(t).length;e=(""+e).toLowerCase(),i=true;}}function y(t,e,r){let n=false;if((void 0===e||e<0)&&(e=0),e>this.length)return "";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return "";if((r>>>=0)<=(e>>>=0))return "";for(t||(t="utf8");;)switch(t){case "hex":return R(this,e,r);case "utf8":case "utf-8":return U(this,e,r);case "ascii":return L(this,e,r);case "latin1":case "binary":return v(this,e,r);case "base64":return _(this,e,r);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=true;}}function g(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function d(t,e,r,n,i){if(0===t.length)return -1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),W(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return -1;r=t.length-1;}else if(r<0){if(!i)return -1;r=0;}if("string"==typeof e&&(e=f.from(e,n)),f.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,i){let o,f=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return -1;f=2,s/=2,u/=2,r/=2;}function h(t,e){return 1===f?t[e]:t.readUInt16BE(e*f)}if(i){let n=-1;for(o=r;o<s;o++)if(h(t,o)===h(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*f}else -1!==n&&(o-=o-n),n=-1;}else for(r+u>s&&(r=s-u),o=r;o>=0;o--){let r=true;for(let n=0;n<u;n++)if(h(t,o+n)!==h(e,n)){r=false;break}if(r)return o}return -1}function w(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let f;for(n>o/2&&(n=o/2),f=0;f<n;++f){const n=parseInt(e.substr(2*f,2),16);if(W(n))return f;t[r+f]=n;}return f}function B(t,e,r,n){return J(Y(e,t.length-r),t,r,n)}function E(t,e,r,n){return J(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function m(t,e,r,n){return J(K(e),t,r,n)}function A(t,e,r,n){return J(function(t,e){let r,n,i;const o=[];for(let f=0;f<t.length&&!((e-=2)<0);++f)r=t.charCodeAt(f),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function _(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function U(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,f=e>239?4:e>223?3:e>191?2:1;if(i+f<=r){let r,n,s,u;switch(f){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],s=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,u>65535&&u<1114112&&(o=u));}}null===o?(o=65533,f=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=f;}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=I));return r}(n)}t.kMaxLength=i,f.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return false}}(),f.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(f.prototype,"parent",{enumerable:true,get:function(){if(f.isBuffer(this))return this.buffer}}),Object.defineProperty(f.prototype,"offset",{enumerable:true,get:function(){if(f.isBuffer(this))return this.byteOffset}}),f.poolSize=8192,f.from=function(t,e,r){return s(t,e,r)},Object.setPrototypeOf(f.prototype,Uint8Array.prototype),Object.setPrototypeOf(f,Uint8Array),f.alloc=function(t,e,r){return function(t,e,r){return u(t),t<=0?o(t):void 0!==e?"string"==typeof r?o(t).fill(e,r):o(t).fill(e):o(t)}(t,e,r)},f.allocUnsafe=function(t){return h(t)},f.allocUnsafeSlow=function(t){return h(t)},f.isBuffer=function(t){return null!=t&&true===t._isBuffer&&t!==f.prototype},f.compare=function(t,e){if(Q(t,Uint8Array)&&(t=f.from(t,t.offset,t.byteLength)),Q(e,Uint8Array)&&(e=f.from(e,e.offset,e.byteLength)),!f.isBuffer(t)||!f.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},f.isEncoding=function(t){switch(String(t).toLowerCase()){case "hex":case "utf8":case "utf-8":case "ascii":case "latin1":case "binary":case "base64":case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return true;default:return false}},f.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return f.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=f.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(Q(e,Uint8Array))i+e.length>n.length?(f.isBuffer(e)||(e=f.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else {if(!f.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i);}i+=e.length;}return n},f.byteLength=p,f.prototype._isBuffer=true,f.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)g(this,e,e+1);return this},f.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)g(this,e,e+3),g(this,e+1,e+2);return this},f.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)g(this,e,e+7),g(this,e+1,e+6),g(this,e+2,e+5),g(this,e+3,e+4);return this},f.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?U(this,0,t):y.apply(this,arguments)},f.prototype.toLocaleString=f.prototype.toString,f.prototype.equals=function(t){if(!f.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===f.compare(this,t)},f.prototype.inspect=function(){let e="";const r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},n&&(f.prototype[n]=f.prototype.inspect),f.prototype.compare=function(t,e,r,n,i){if(Q(t,Uint8Array)&&(t=f.from(t,t.offset,t.byteLength)),!f.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return -1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0);const u=Math.min(o,s),h=this.slice(n,i),a=t.slice(e,r);for(let t=0;t<u;++t)if(h[t]!==a[t]){o=h[t],s=a[t];break}return o<s?-1:s<o?1:0},f.prototype.includes=function(t,e,r){return -1!==this.indexOf(t,e,r)},f.prototype.indexOf=function(t,e,r){return d(this,t,e,r,true)},f.prototype.lastIndexOf=function(t,e,r){return d(this,t,e,r,false)},f.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else {if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0);}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=false;for(;;)switch(n){case "hex":return w(this,t,e,r);case "utf8":case "utf-8":return B(this,t,e,r);case "ascii":case "latin1":case "binary":return E(this,t,e,r);case "base64":return m(this,t,e,r);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=true;}},f.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function L(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function v(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function R(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=X[t[n]];return i}function T(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function S(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!f.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function N(t,e,r,n,i){j(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,r}function M(t,e,r,n,i){j(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=f,f>>=8,t[r+2]=f,f>>=8,t[r+1]=f,f>>=8,t[r]=f,r+8}function C(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function x(t,e,n,i,o){return e=+e,n>>>=0,o||C(t,0,n,4),r.write(t,e,n,i,23,4),n+4}function k(t,e,n,i,o){return e=+e,n>>>=0,o||C(t,0,n,8),r.write(t,e,n,i,52,8),n+8}f.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,f.prototype),n},f.prototype.readUintLE=f.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},f.prototype.readUintBE=f.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},f.prototype.readUint8=f.prototype.readUInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),this[t]},f.prototype.readUint16LE=f.prototype.readUInt16LE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]|this[t+1]<<8},f.prototype.readUint16BE=f.prototype.readUInt16BE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]<<8|this[t+1]},f.prototype.readUint32LE=f.prototype.readUInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},f.prototype.readUint32BE=f.prototype.readUInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},f.prototype.readBigUInt64LE=Z(function(t){H(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))}),f.prototype.readBigUInt64BE=Z(function(t){H(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return (BigInt(n)<<BigInt(32))+BigInt(i)}),f.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},f.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},f.prototype.readInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},f.prototype.readInt16LE=function(t,e){t>>>=0,e||S(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},f.prototype.readInt16BE=function(t,e){t>>>=0,e||S(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},f.prototype.readInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},f.prototype.readInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},f.prototype.readBigInt64LE=Z(function(t){H(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return (BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),f.prototype.readBigInt64BE=Z(function(t){H(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return (BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)}),f.prototype.readFloatLE=function(t,e){return t>>>=0,e||S(t,4,this.length),r.read(this,t,true,23,4)},f.prototype.readFloatBE=function(t,e){return t>>>=0,e||S(t,4,this.length),r.read(this,t,false,23,4)},f.prototype.readDoubleLE=function(t,e){return t>>>=0,e||S(t,8,this.length),r.read(this,t,true,52,8)},f.prototype.readDoubleBE=function(t,e){return t>>>=0,e||S(t,8,this.length),r.read(this,t,false,52,8)},f.prototype.writeUintLE=f.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||O(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},f.prototype.writeUintBE=f.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||O(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},f.prototype.writeUint8=f.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},f.prototype.writeUint16LE=f.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},f.prototype.writeUint16BE=f.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},f.prototype.writeUint32LE=f.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},f.prototype.writeUint32BE=f.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},f.prototype.writeBigUInt64LE=Z(function(t,e=0){return N(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),f.prototype.writeBigUInt64BE=Z(function(t,e=0){return M(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),f.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);O(this,t,e,r,n-1,-n);}let i=0,o=1,f=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===f&&0!==this[e+i-1]&&(f=1),this[e+i]=(t/o|0)-f&255;return e+r},f.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);O(this,t,e,r,n-1,-n);}let i=r-1,o=1,f=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===f&&0!==this[e+i+1]&&(f=1),this[e+i]=(t/o|0)-f&255;return e+r},f.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},f.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},f.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},f.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},f.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},f.prototype.writeBigInt64LE=Z(function(t,e=0){return N(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),f.prototype.writeBigInt64BE=Z(function(t,e=0){return M(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),f.prototype.writeFloatLE=function(t,e,r){return x(this,t,e,true,r)},f.prototype.writeFloatBE=function(t,e,r){return x(this,t,e,false,r)},f.prototype.writeDoubleLE=function(t,e,r){return k(this,t,e,true,r)},f.prototype.writeDoubleBE=function(t,e,r){return k(this,t,e,false,r)},f.prototype.copy=function(t,e,r,n){if(!f.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},f.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!f.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e);}}else "number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else {const o=f.isBuffer(t)?t:f.from(t,n),s=o.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%s];}return this};const P={};function $(t,e,r){P[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:true,configurable:true}),this.name=`${this.name} [${t}]`,this.stack,delete this.name;}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:true,enumerable:true,value:t,writable:true});}toString(){return `${this.name} [${t}]: ${this.message}`}};}function F(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return `${t.slice(0,r)}${e}`}function j(t,e,r,n,i,o){if(t>r||t<e){const r="bigint"==typeof e?"n":"";let n;throw n=0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(o+1)}${r}`:`>= -(2${r} ** ${8*(o+1)-1}${r}) and < 2 ** ${8*(o+1)-1}${r}`,new P.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,r){H(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||V(e,t.length-(r+1));}(n,i,o);}function H(t,e){if("number"!=typeof t)throw new P.ERR_INVALID_ARG_TYPE(e,"number",t)}function V(t,e,r){if(Math.floor(t)!==t)throw H(t,r),new P.ERR_OUT_OF_RANGE("offset","an integer",t);if(e<0)throw new P.ERR_BUFFER_OUT_OF_BOUNDS;throw new P.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${e}`,t)}$("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),$("ERR_INVALID_ARG_TYPE",function(t,e){return `The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),$("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=F(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=F(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);const q=/[^+/0-9A-Za-z-_]/g;function Y(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let f=0;f<n;++f){if(r=t.charCodeAt(f),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(f+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320);}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r);}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128);}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128);}else {if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128);}}return o}function K(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(q,"")).length<2)return "";for(;t.length%4!=0;)t+="=";return t}(t))}function J(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Q(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function W(t){return t!=t}const X=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i];}return e}();function Z(t){return "undefined"==typeof BigInt?tt:t}function tt(){throw new Error("BigInt not supported")}}(H)),H);let J={SERVER_TIME_NONCE:176,AUTH_REQ:177,AUTH_RES:178,AUTH_FAIL:179,ENC_PACK:182,ENC_E2E:183,ENC_488:184};for(let t in J)J[J[t]]=t;const Q={SERVER_TIME_NONCE:F.meta(F.MB("header","8",0),F.MB("unixTime","32L",0),F.MB("milTime","16L",0),F.MB("counter","16L",0),F.MB("nonce",K.Buffer.alloc(4))),AUTH_REQ:F.meta(F.MB("header","8",0),F.MB("id8",K.Buffer.alloc(8)),F.MB("nonce",K.Buffer.alloc(4)),F.MB("hmac32",K.Buffer.alloc(32))),AUTH_RES:F.meta(F.MB("header","8",0),F.MB("hmac32",K.Buffer.alloc(32))),ENC_PACK:F.meta(F.MB("type","8",0),F.MB("len","32L",0),F.MB("salt12",K.Buffer.alloc(12)),F.MB("hmac",8,0)),ENC_488:F.meta(F.MB("type","8",0),F.MB("len","32L",0),F.MB("otpSrc8",K.Buffer.alloc(8)),F.MB("hmac8",K.Buffer.alloc(8)))};function W(t){let e=t[t.length-1];return e[2]+e[3]}const X={SERVER_TIME_NONCE:W(Q.SERVER_TIME_NONCE),AUTH_REQ:W(Q.AUTH_REQ),AUTH_RES:W(Q.AUTH_RES),ENC_PACK:W(Q.ENC_PACK),ENC_488:W(Q.ENC_488)};function Z(t){return globalThis.crypto.getRandomValues(K.Buffer.alloc(t))}class tt{constructor(){this._id8=K.Buffer.alloc(8),this._otpSrc44=K.Buffer.alloc(44),this._otp36=K.Buffer.alloc(36),this._hmac=K.Buffer.alloc(32),this.auth_salt12=K.Buffer.alloc(12),this.localNonce=K.Buffer.alloc(4),this.remoteNonce=K.Buffer.alloc(4),this.isAuthorized=false,this.counter=0;}clearAuth(){this._id8.fill(0),this._otpSrc44.fill(0),this._otp36.fill(0),this._hmac.fill(0),this.auth_salt12.fill(0),this.localNonce.fill(0),this.remoteNonce.fill(0),this.isAuthorized=false,this.counter=0;}set_hash_id8(t){F.B8(j.hash(t)).copy(this._id8,0,0,8);}set_id8(t){let e=F.B8(t);this._id8.fill(0),e.copy(this._id8,0,0,8);}set_key(t){F.B8(j.hash(t)).copy(this._otpSrc44,0,0,32);}set_id_key(t){let e=t.indexOf(".");if(-1==e)return;let r=t.substring(0,e),n=t.substring(e+1);this.set_id8(r),this.set_key(n);}copy_id8(t){t.copy(this._id8,0,0,8);}copy_key(t){t.copy(this._otpSrc44,0,0,32);}sha256_n(t,e){let r=j.hash(t);for(let t=0;t<e;t++)r=j.hash(r);return r}set_clock_rand(){const t=Date.now(),e=parseInt(t/1e3),r=t%1e3;++this.counter>65535&&(this.counter=0);K.Buffer.concat([F.NB("32L",e),F.NB("16L",r),F.NB("16L",this.counter),Z(4)]).copy(this._otpSrc44,32);}set_clock_nonce(t){const e=Date.now(),r=parseInt(e/1e3),n=e%1e3;++this.counter>65535&&(this.counter=0);K.Buffer.concat([F.NB("32L",r),F.NB("16L",n),F.NB("16L",this.counter),t]).copy(this._otpSrc44,32);}set_salt12(t,e){if(12!=t.byteLength)throw TypeError("set_salt12: Invalid salt12 byteLength.");t.copy(this._otpSrc44,32);}resetOTP(){F.B8(j.hash(this._otpSrc44)).copy(this._otp36,0,0,32);}getIndexOTP(t){return this._otp36.writeUInt32LE(t,32),j.hash(this._otp36)}generateHMAC(t){let e=K.Buffer.concat([this._otpSrc44,t]);this._hmac=F.B8(j.hash(e));}getHMAC8(t){let e=K.Buffer.concat([this._otpSrc44,t]);return this._hmac=F.B8(j.hash(e)),this._hmac.subarray(0,8)}xotp(t,e=0,r=false){let n=(t=F.B8(t,r)).byteLength,i=e,o=0,f=0;for(;n>0;){f=n<32?n:32;let e=this.getIndexOTP(++i);for(let r=0;r<f;r++)t[o++]^=e[r];n-=32;}return t}server_time_nonce(){const t=Date.now(),e=Math.floor(t/1e3),r=t%1e3;return this.localNonce=Z(4),this.auth_salt12=K.Buffer.concat([F.NB("32L",e),F.NB("16L",r),Z(2),this.localNonce]),K.Buffer.concat([F.NB("8",J.SERVER_TIME_NONCE),this.auth_salt12])}auth_req(t){let e=F.unpack(t,Q.SERVER_TIME_NONCE);if(e){let t=K.Buffer.concat([F.NB("32L",e.unixTime),F.NB("16L",e.milTime),F.NB("16L",e.counter),e.nonce]);return this.set_salt12(t,"auth_req"),this.localNonce=Z(4),this.generateHMAC(this.localNonce),this.remoteNonce=e.nonce,F.pack(F.MB("#header","8",J.AUTH_REQ),F.MB("#id8",this._id8),F.MB("#nonce",this.localNonce),F.MB("#hmac32",this._hmac))}return false}verify_auth_req(t){let e;if(t instanceof Uint8Array){if(e=F.unpack(t,Q.AUTH_REQ),!e)return}else e=t;this.set_salt12(this.auth_salt12,"verify_auth_req 1/2"),this.generateHMAC(e.nonce);let r=this._hmac;if(F.equal(e.hmac32,r)){this.remoteNonce=e.nonce;let t=K.Buffer.concat([this.localNonce,this.remoteNonce,this.localNonce]);this.set_salt12(t,"verify_auth_req 2/2"),this.generateHMAC(e.nonce);let r=this._hmac,n=F.rawPack(F.MB("header","8",J.AUTH_RES),F.MB("hmac32",r));return this.isAuthorized=true,n}return false}verify_auth_res(t){let e=F.unpack(t,Q.AUTH_RES);if(e){let t=K.Buffer.concat([this.remoteNonce,this.localNonce,this.remoteNonce]);this.set_salt12(t,"verify_auth_res"),this.generateHMAC(this.localNonce);let r=this._hmac;if(F.equal(r,e.hmac32))return this.isAuthorized=true,true}}encrypt_488(t){if(!this.isAuthorized)return;t=F.B8(t),this.set_clock_nonce(this.remoteNonce),this.resetOTP();let e=this.getHMAC8(t),r=this.xotp(t);return F.pack(F.MB("#type","8",J.ENC_488),F.MB("#len","32L",t.byteLength),F.MB("#otpSrc8",this._otpSrc44.subarray(32,40)),F.MB("#hmac8",e),F.MB("#xdata",r))}decrypt_488(t){t=F.B8(t);let e=F.unpack(t,Q.ENC_488);if(e){let t=K.Buffer.concat([e.otpSrc8,this.localNonce]);this.set_salt12(t,"decrypt_488"),this.resetOTP();let r=e.$OTHERS.subarray(0,e.len),n=this.xotp(r),i=this.getHMAC8(n);if(F.equal(i,e.hmac8))return n}}encryptPack(t){t=F.B8(t),this.set_clock_rand(),this.resetOTP();let e=this.getHMAC8(t),r=this.xotp(t);return F.pack(F.MB("#type","8",J.ENC_PACK),F.MB("#len","32L",t.byteLength),F.MB("#salt12",this._otpSrc44.subarray(32)),F.MB("#hmac8",e),F.MB("#xdata",r))}decryptPack(t){if(t[0]!==J.ENC_PACK)return;if(t.readUint32LE(1)==t.byteLength-X.ENC_PACK)try{let e=F.unpack(t,Q.ENC_PACK);if(!e)return;this.set_salt12(e.salt12,"decryptPack"),this.resetOTP();let r=e.$OTHERS,n=this.xotp(r),i=this.getHMAC8(n);if(F.equal(e.hmac,i))return e.data=n,e}catch(t){}}encrypt_e2e(t,e){let r=K.Buffer.alloc(32);r.set(this._otpSrc44.subarray(0,32)),this.set_key(e);let n=this.encryptPack(t);return this._otpSrc44.set(r),n}decrypt_e2e(t,e){let r=K.Buffer.alloc(32);r.set(this._otpSrc44.subarray(0,32)),this.set_key(e);let n=this.decryptPack(t);return this._otpSrc44.set(r),n}}tt.RAND=Z,tt.BohoMsg=J,tt.Meta=Q,tt.MetaSize=X,tt.sha256=j,tt.MBP=F,tt.Buffer=K.Buffer;
3775
760
 
3776
761
  /**
3777
762
  * @typedef {import('meta-buffer-pack').MBP} MBP
@@ -3786,7 +771,7 @@ const t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1
3786
771
  * @typedef {import('boho').Buffer} Buffer
3787
772
  */
3788
773
 
3789
- const Buffer$1 = mbp.Buffer;
774
+ const Buffer$1 = M$1.Buffer;
3790
775
  const encoder$1 = new TextEncoder();
3791
776
  const decoder$4 = new TextDecoder();
3792
777
 
@@ -3881,9 +866,9 @@ class IOCore extends EventEmitter {
3881
866
  * Boho instance for encryption/decryption.
3882
867
  * @type {Boho}
3883
868
  */
3884
- this.boho = new K();
869
+ this.boho = new tt();
3885
870
 
3886
- this.serverTimeNonce = Buffer$1.alloc( K.MetaSize.SERVER_TIME_NONCE );
871
+ this.serverTimeNonce = Buffer$1.alloc( tt.MetaSize.SERVER_TIME_NONCE );
3887
872
  /**
3888
873
  * Indicates if the connection is TLS (wss).
3889
874
  * @type {boolean}
@@ -4156,13 +1141,13 @@ class IOCore extends EventEmitter {
4156
1141
  let msgType = buffer[0];
4157
1142
  let decoded;
4158
1143
 
4159
- if (msgType === K.BohoMsg.ENC_488) {
1144
+ if (msgType === tt.BohoMsg.ENC_488) {
4160
1145
  decoded = this.boho.decrypt_488(buffer);
4161
1146
  if (decoded) {
4162
1147
  msgType = decoded[0];
4163
1148
  buffer = decoded;
4164
1149
  }
4165
- } else if (msgType === K.BohoMsg.ENC_E2E) {
1150
+ } else if (msgType === tt.BohoMsg.ENC_E2E) {
4166
1151
 
4167
1152
  try {
4168
1153
  decoded = this.boho.decrypt_488(buffer);
@@ -4170,8 +1155,8 @@ class IOCore extends EventEmitter {
4170
1155
  // console.log( 'ENC_E2E decoded ', decoded )
4171
1156
  msgType = decoded[0];
4172
1157
  // decoded has msg_header only.
4173
- buffer.set(decoded, K.MetaSize.ENC_488); // set decoded signal_e2e headaer.
4174
- buffer = buffer.subarray(K.MetaSize.ENC_488); // reset offset.
1158
+ buffer.set(decoded, tt.MetaSize.ENC_488); // set decoded signal_e2e headaer.
1159
+ buffer = buffer.subarray(tt.MetaSize.ENC_488); // reset offset.
4175
1160
  // console.log('DECODED MsgType:', IOMsg[ msgType ] )
4176
1161
  } else {
4177
1162
  // console.log('488 DEC_FAIL', buffer)
@@ -4186,7 +1171,7 @@ class IOCore extends EventEmitter {
4186
1171
  }
4187
1172
 
4188
1173
  let type = IOMsg[msgType];
4189
- if (!type) type = K.BohoMsg[msgType];
1174
+ if (!type) type = tt.BohoMsg[msgType];
4190
1175
 
4191
1176
  // console.log( "MsgType: ", type , " LEN ", buffer.byteLength)
4192
1177
 
@@ -4265,7 +1250,7 @@ class IOCore extends EventEmitter {
4265
1250
  this.redirect(url);
4266
1251
  break;
4267
1252
 
4268
- case K.BohoMsg.SERVER_TIME_NONCE: // SERVER_READY
1253
+ case tt.BohoMsg.SERVER_TIME_NONCE: // SERVER_READY
4269
1254
  this.stateChange('server_ready', 'server_ready');
4270
1255
  if (this.useAuth) {
4271
1256
  this.send(this.boho.auth_req(buffer));
@@ -4296,7 +1281,7 @@ class IOCore extends EventEmitter {
4296
1281
 
4297
1282
  case IOMsg.SET:
4298
1283
  try {
4299
- let setPack = mbp.unpack(buffer);
1284
+ let setPack = M$1.unpack(buffer);
4300
1285
  if (setPack) {
4301
1286
  this.emit(setPack.topic, ...setPack.args);
4302
1287
  }
@@ -4375,7 +1360,7 @@ class IOCore extends EventEmitter {
4375
1360
  break;
4376
1361
 
4377
1362
  case PAYLOAD_TYPE.MBA:
4378
- let mbaObject = mbp.unpack(payloadBuffer);
1363
+ let mbaObject = M$1.unpack(payloadBuffer);
4379
1364
  if (tag.indexOf('@') === 0) this.emit('@', tag, ...mbaObject.args);
4380
1365
  else {
4381
1366
  this.emit(tag, tag, ...mbaObject.args);
@@ -4397,11 +1382,11 @@ class IOCore extends EventEmitter {
4397
1382
  this.testPromise(buffer);
4398
1383
  break;
4399
1384
 
4400
- case K.BohoMsg.AUTH_FAIL:
1385
+ case tt.BohoMsg.AUTH_FAIL:
4401
1386
  this.stateChange('auth_fail', 'auth_fail from server.');
4402
1387
  break;
4403
1388
 
4404
- case K.BohoMsg.AUTH_RES:
1389
+ case tt.BohoMsg.AUTH_RES:
4405
1390
  if (this.boho.verify_auth_res(buffer)) {
4406
1391
  this.stateChange('auth_res', 'server sent auth_res');
4407
1392
  this.send(Buffer$1.from([IOMsg.CID_REQ]));
@@ -4431,13 +1416,13 @@ class IOCore extends EventEmitter {
4431
1416
  iam(title) {
4432
1417
  // console.log('iam', title)
4433
1418
  if (title) {
4434
- this.send_enc_mode(mbp.pack(
4435
- mbp.MB('#MsgType', '8', IOMsg.IAM),
4436
- mbp.MB('#', title)
1419
+ this.send_enc_mode(M$1.pack(
1420
+ M$1.MB('#MsgType', '8', IOMsg.IAM),
1421
+ M$1.MB('#', title)
4437
1422
  ));
4438
1423
  } else {
4439
- this.send_enc_mode(mbp.pack(
4440
- mbp.MB('#MsgType', '8', IOMsg.IAM)
1424
+ this.send_enc_mode(M$1.pack(
1425
+ M$1.MB('#MsgType', '8', IOMsg.IAM)
4441
1426
  ));
4442
1427
  }
4443
1428
  }
@@ -4465,9 +1450,9 @@ class IOCore extends EventEmitter {
4465
1450
  echo(args) {
4466
1451
  if (args) {
4467
1452
  // console.log('send echo args:', args)
4468
- this.send_enc_mode(mbp.pack(
4469
- mbp.MB('#MsgType', '8', IOMsg.ECHO),
4470
- mbp.MB('#msg', args)
1453
+ this.send_enc_mode(M$1.pack(
1454
+ M$1.MB('#MsgType', '8', IOMsg.ECHO),
1455
+ M$1.MB('#msg', args)
4471
1456
  ));
4472
1457
  } else {
4473
1458
  // # do not encrypt blank echo #
@@ -4481,7 +1466,7 @@ class IOCore extends EventEmitter {
4481
1466
  * @param {...any} data - Data to send.
4482
1467
  */
4483
1468
  bin(...data) {
4484
- this.send(mbp.U8pack(...data));
1469
+ this.send(M$1.U8pack(...data));
4485
1470
  }
4486
1471
 
4487
1472
  /**
@@ -4531,7 +1516,7 @@ class IOCore extends EventEmitter {
4531
1516
  // encrypt signal_header area only. payload is encrypted with e2e key already.
4532
1517
  let tagLen = data[1];
4533
1518
  let encHeader = this.boho.encrypt_488(data.subarray(0, 3 + tagLen));
4534
- encHeader[0] = K.BohoMsg.ENC_E2E;
1519
+ encHeader[0] = tt.BohoMsg.ENC_E2E;
4535
1520
  this.send(Buffer$1.concat([encHeader, data.subarray(3 + tagLen)]));
4536
1521
  // console.log('<< send_enc_mode [ ENC_E2E ]')
4537
1522
 
@@ -4570,7 +1555,7 @@ class IOCore extends EventEmitter {
4570
1555
  */
4571
1556
  testPromise(buffer) {
4572
1557
 
4573
- let res = mbp.unpack(buffer);
1558
+ let res = M$1.unpack(buffer);
4574
1559
  if (!res) return
4575
1560
 
4576
1561
  if (this.promiseMap.has(res.mid)) {
@@ -4637,18 +1622,18 @@ class IOCore extends EventEmitter {
4637
1622
  if( !this.boho.isAuthorized ) return;
4638
1623
  if (typeof tag !== 'string') throw TypeError('tag should be string.')
4639
1624
  let tagEncoded = encoder$1.encode(tag);
4640
- let dataPack = mbp.B8(data);
1625
+ let dataPack = M$1.B8(data);
4641
1626
 
4642
1627
  //encrypt payload area with key
4643
1628
  let sercretPack = this.boho.encrypt_e2e(dataPack, key);
4644
1629
 
4645
1630
  //change signal MsgType header into SIGNAL_E2E
4646
- let signalPack = mbp.pack(
4647
- mbp.MB('#MsgType', '8', IOMsg.SIGNAL_E2E),
4648
- mbp.MB('#tagLen', '8', tagEncoded.byteLength),
4649
- mbp.MB('#tag', tagEncoded),
4650
- mbp.MB('#payloadType', '8', PAYLOAD_TYPE.BINARY),
4651
- mbp.MB('#payload', sercretPack)
1631
+ let signalPack = M$1.pack(
1632
+ M$1.MB('#MsgType', '8', IOMsg.SIGNAL_E2E),
1633
+ M$1.MB('#tagLen', '8', tagEncoded.byteLength),
1634
+ M$1.MB('#tag', tagEncoded),
1635
+ M$1.MB('#payloadType', '8', PAYLOAD_TYPE.BINARY),
1636
+ M$1.MB('#payload', sercretPack)
4652
1637
  );
4653
1638
 
4654
1639
  this.send_enc_mode(signalPack);
@@ -4678,7 +1663,7 @@ class IOCore extends EventEmitter {
4678
1663
  return Promise.reject(new Error('store get need storeName)'))
4679
1664
  }
4680
1665
  let pack = await this.call('store', 'get', storeName);
4681
- let { $ } = mbp.unpack(pack.body);
1666
+ let { $ } = M$1.unpack(pack.body);
4682
1667
  return $
4683
1668
  }
4684
1669
 
@@ -4695,19 +1680,19 @@ class IOCore extends EventEmitter {
4695
1680
  return Promise.reject(new Error('request need target and topic)'))
4696
1681
  let sigPack;
4697
1682
  if (args.length > 0) {
4698
- sigPack = mbp.pack(
4699
- mbp.MB('#MsgType', '8', IOMsg.CALL),
4700
- mbp.MB('mid', '16', ++this.mid),
4701
- mbp.MB('target', target),
4702
- mbp.MB('topic', topic),
4703
- mbp.MBA(...args)
1683
+ sigPack = M$1.pack(
1684
+ M$1.MB('#MsgType', '8', IOMsg.CALL),
1685
+ M$1.MB('mid', '16', ++this.mid),
1686
+ M$1.MB('target', target),
1687
+ M$1.MB('topic', topic),
1688
+ M$1.MBA(...args)
4704
1689
  );
4705
1690
  } else {
4706
- sigPack = mbp.pack(
4707
- mbp.MB('#MsgType', '8', IOMsg.CALL),
4708
- mbp.MB('mid', '16', ++this.mid),
4709
- mbp.MB('target', target),
4710
- mbp.MB('topic', topic)
1691
+ sigPack = M$1.pack(
1692
+ M$1.MB('#MsgType', '8', IOMsg.CALL),
1693
+ M$1.MB('mid', '16', ++this.mid),
1694
+ M$1.MB('target', target),
1695
+ M$1.MB('topic', topic)
4711
1696
  );
4712
1697
  }
4713
1698
  this.send_enc_mode(sigPack);
@@ -4728,8 +1713,8 @@ class IOCore extends EventEmitter {
4728
1713
  let tagEncoded = encoder$1.encode(tag);
4729
1714
  this.send_enc_mode(
4730
1715
  Buffer$1.concat([
4731
- mbp.NB('8', IOMsg.SUBSCRIBE),
4732
- mbp.NB('8', tagEncoded.byteLength),
1716
+ M$1.NB('8', IOMsg.SUBSCRIBE),
1717
+ M$1.NB('8', tagEncoded.byteLength),
4733
1718
  tagEncoded]));
4734
1719
  } catch (error) { }
4735
1720
 
@@ -4749,8 +1734,8 @@ class IOCore extends EventEmitter {
4749
1734
  let tagEncoded = encoder$1.encode(tag);
4750
1735
  this.send_enc_mode(
4751
1736
  Buffer$1.concat([
4752
- mbp.NB('8', IOMsg.SUBSCRIBE),
4753
- mbp.NB('8', tagEncoded.byteLength),
1737
+ M$1.NB('8', IOMsg.SUBSCRIBE),
1738
+ M$1.NB('8', tagEncoded.byteLength),
4754
1739
  tagEncoded]));
4755
1740
  } catch (error) { }
4756
1741
 
@@ -4777,8 +1762,8 @@ class IOCore extends EventEmitter {
4777
1762
  if (tagEncoded.byteLength > SIZE_LIMIT.TAG_LEN1) throw TypeError('please use tag string bytelength below:' + SIZE_LIMIT.TAG_LEN1)
4778
1763
 
4779
1764
  this.send_enc_mode(Buffer$1.concat([
4780
- mbp.NB('8', IOMsg.UNSUBSCRIBE),
4781
- mbp.NB('8', tagEncoded.byteLength),
1765
+ M$1.NB('8', IOMsg.UNSUBSCRIBE),
1766
+ M$1.NB('8', tagEncoded.byteLength),
4782
1767
  tagEncoded]));
4783
1768
  }
4784
1769
 
@@ -4973,34 +1958,34 @@ function pack(payload) {
4973
1958
  if( payload.byteLength == undefined ) payload = Buffer.from(payload);
4974
1959
 
4975
1960
  if (payload.byteLength < 256) { //one byte len
4976
- return mbp.pack(
4977
- mbp.MB('#type', '8', CongType.TYPE_LEN1),
4978
- mbp.MB('#payloadLen1', '8', payload.byteLength),
4979
- mbp.MB('#payload', payload)
1961
+ return M$1.pack(
1962
+ M$1.MB('#type', '8', CongType.TYPE_LEN1),
1963
+ M$1.MB('#payloadLen1', '8', payload.byteLength),
1964
+ M$1.MB('#payload', payload)
4980
1965
  )
4981
1966
 
4982
1967
  } else if (payload.byteLength < 65536) { // 2bytes len
4983
- return mbp.pack(
4984
- mbp.MB('#type', '8', CongType.TYPE_LEN2),
4985
- mbp.MB('#payloadLen2', '16L', payload.byteLength),
4986
- mbp.MB('#payload', payload)
1968
+ return M$1.pack(
1969
+ M$1.MB('#type', '8', CongType.TYPE_LEN2),
1970
+ M$1.MB('#payloadLen2', '16L', payload.byteLength),
1971
+ M$1.MB('#payload', payload)
4987
1972
  )
4988
1973
 
4989
1974
  } else if (payload.byteLength < 2 ** 24) { // 3bytes len
4990
1975
  let len4Buffer = Buffer.alloc(4);
4991
1976
  len4Buffer.writeUint32LE(payload.byteLength);
4992
1977
  let cropLen3 = len4Buffer.subarray(0, 3);
4993
- return mbp.pack(
4994
- mbp.MB('#type', '8', CongType.TYPE_LEN3),
4995
- mbp.MB('#payloadLen3', cropLen3),
4996
- mbp.MB('#payload', payload)
1978
+ return M$1.pack(
1979
+ M$1.MB('#type', '8', CongType.TYPE_LEN3),
1980
+ M$1.MB('#payloadLen3', cropLen3),
1981
+ M$1.MB('#payload', payload)
4997
1982
  )
4998
1983
 
4999
1984
  } else { //use 4 bytes.
5000
- return mbp.pack(
5001
- mbp.MB('#type', '8', CongType.TYPE_LEN4),
5002
- mbp.MB('#payloadLen4', '32L', payload.byteLength),
5003
- mbp.MB('#payload', payload)
1985
+ return M$1.pack(
1986
+ M$1.MB('#type', '8', CongType.TYPE_LEN4),
1987
+ M$1.MB('#payloadLen4', '32L', payload.byteLength),
1988
+ M$1.MB('#payload', payload)
5004
1989
  )
5005
1990
  }
5006
1991
 
@@ -5880,7 +2865,9 @@ function requirePermessageDeflate () {
5880
2865
  (typeof opts.serverMaxWindowBits === 'number' &&
5881
2866
  opts.serverMaxWindowBits > params.server_max_window_bits))) ||
5882
2867
  (typeof opts.clientMaxWindowBits === 'number' &&
5883
- !params.client_max_window_bits)
2868
+ (typeof params.client_max_window_bits === 'number'
2869
+ ? opts.clientMaxWindowBits > params.client_max_window_bits
2870
+ : !params.client_max_window_bits))
5884
2871
  ) {
5885
2872
  return false;
5886
2873
  }
@@ -6536,6 +3523,10 @@ function requireReceiver () {
6536
3523
  * extensions
6537
3524
  * @param {Boolean} [options.isServer=false] Specifies whether to operate in
6538
3525
  * client or server mode
3526
+ * @param {Number} [options.maxBufferedChunks=0] The maximum number of
3527
+ * buffered data chunks
3528
+ * @param {Number} [options.maxFragments=0] The maximum number of message
3529
+ * fragments
6539
3530
  * @param {Number} [options.maxPayload=0] The maximum allowed message length
6540
3531
  * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
6541
3532
  * not to skip UTF-8 validation for text and close messages
@@ -6550,6 +3541,8 @@ function requireReceiver () {
6550
3541
  this._binaryType = options.binaryType || BINARY_TYPES[0];
6551
3542
  this._extensions = options.extensions || {};
6552
3543
  this._isServer = !!options.isServer;
3544
+ this._maxBufferedChunks = options.maxBufferedChunks | 0;
3545
+ this._maxFragments = options.maxFragments | 0;
6553
3546
  this._maxPayload = options.maxPayload | 0;
6554
3547
  this._skipUTF8Validation = !!options.skipUTF8Validation;
6555
3548
  this[kWebSocket] = undefined;
@@ -6567,6 +3560,7 @@ function requireReceiver () {
6567
3560
 
6568
3561
  this._totalPayloadLength = 0;
6569
3562
  this._messageLength = 0;
3563
+ this._numFragments = 0;
6570
3564
  this._fragments = [];
6571
3565
 
6572
3566
  this._errored = false;
@@ -6585,6 +3579,22 @@ function requireReceiver () {
6585
3579
  _write(chunk, encoding, cb) {
6586
3580
  if (this._opcode === 0x08 && this._state == GET_INFO) return cb();
6587
3581
 
3582
+ if (
3583
+ this._maxBufferedChunks > 0 &&
3584
+ this._buffers.length >= this._maxBufferedChunks
3585
+ ) {
3586
+ cb(
3587
+ this.createError(
3588
+ RangeError,
3589
+ 'Too many buffered chunks',
3590
+ false,
3591
+ 1008,
3592
+ 'WS_ERR_TOO_MANY_BUFFERED_PARTS'
3593
+ )
3594
+ );
3595
+ return;
3596
+ }
3597
+
6588
3598
  this._bufferedBytes += chunk.length;
6589
3599
  this._buffers.push(chunk);
6590
3600
  this.startLoop(cb);
@@ -6974,6 +3984,19 @@ function requireReceiver () {
6974
3984
  return;
6975
3985
  }
6976
3986
 
3987
+ if (this._maxFragments > 0 && ++this._numFragments > this._maxFragments) {
3988
+ const error = this.createError(
3989
+ RangeError,
3990
+ 'Too many message fragments',
3991
+ false,
3992
+ 1008,
3993
+ 'WS_ERR_TOO_MANY_BUFFERED_PARTS'
3994
+ );
3995
+
3996
+ cb(error);
3997
+ return;
3998
+ }
3999
+
6977
4000
  if (this._compressed) {
6978
4001
  this._state = INFLATING;
6979
4002
  this.decompress(data, cb);
@@ -7046,6 +4069,7 @@ function requireReceiver () {
7046
4069
  this._totalPayloadLength = 0;
7047
4070
  this._messageLength = 0;
7048
4071
  this._fragmented = 0;
4072
+ this._numFragments = 0;
7049
4073
  this._fragments = [];
7050
4074
 
7051
4075
  if (this._opcode === 2) {
@@ -7214,6 +4238,9 @@ function requireSender () {
7214
4238
 
7215
4239
  const { Duplex } = require$$0;
7216
4240
  const { randomFillSync } = require$$1;
4241
+ const {
4242
+ types: { isUint8Array }
4243
+ } = require$$2$1;
7217
4244
 
7218
4245
  const PerMessageDeflate = requirePermessageDeflate();
7219
4246
  const { EMPTY_BUFFER, kWebSocket, NOOP } = requireConstants();
@@ -7410,8 +4437,10 @@ function requireSender () {
7410
4437
 
7411
4438
  if (typeof data === 'string') {
7412
4439
  buf.write(data, 2);
7413
- } else {
4440
+ } else if (isUint8Array(data)) {
7414
4441
  buf.set(data, 2);
4442
+ } else {
4443
+ throw new TypeError('Second argument must be a string or a Uint8Array');
7415
4444
  }
7416
4445
  }
7417
4446
 
@@ -8335,7 +5364,7 @@ function requireWebsocket () {
8335
5364
 
8336
5365
  const EventEmitter = require$$0$3;
8337
5366
  const https = require$$1$1;
8338
- const http = require$$2$1;
5367
+ const http = require$$2$2;
8339
5368
  const net$1 = net;
8340
5369
  const tls = require$$4;
8341
5370
  const { randomBytes, createHash } = require$$1;
@@ -8532,6 +5561,10 @@ function requireWebsocket () {
8532
5561
  * multiple times in the same tick
8533
5562
  * @param {Function} [options.generateMask] The function used to generate the
8534
5563
  * masking key
5564
+ * @param {Number} [options.maxBufferedChunks=0] The maximum number of
5565
+ * buffered data chunks
5566
+ * @param {Number} [options.maxFragments=0] The maximum number of message
5567
+ * fragments
8535
5568
  * @param {Number} [options.maxPayload=0] The maximum allowed message size
8536
5569
  * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
8537
5570
  * not to skip UTF-8 validation for text and close messages
@@ -8543,6 +5576,8 @@ function requireWebsocket () {
8543
5576
  binaryType: this.binaryType,
8544
5577
  extensions: this._extensions,
8545
5578
  isServer: this._isServer,
5579
+ maxBufferedChunks: options.maxBufferedChunks,
5580
+ maxFragments: options.maxFragments,
8546
5581
  maxPayload: options.maxPayload,
8547
5582
  skipUTF8Validation: options.skipUTF8Validation
8548
5583
  });
@@ -8971,6 +6006,10 @@ function requireWebsocket () {
8971
6006
  * masking key
8972
6007
  * @param {Number} [options.handshakeTimeout] Timeout in milliseconds for the
8973
6008
  * handshake request
6009
+ * @param {Number} [options.maxBufferedChunks=262144] The maximum number of
6010
+ * buffered data chunks
6011
+ * @param {Number} [options.maxFragments=16384] The maximum number of message
6012
+ * fragments
8974
6013
  * @param {Number} [options.maxPayload=104857600] The maximum allowed message
8975
6014
  * size
8976
6015
  * @param {Number} [options.maxRedirects=10] The maximum number of redirects
@@ -8991,6 +6030,8 @@ function requireWebsocket () {
8991
6030
  autoPong: true,
8992
6031
  closeTimeout: CLOSE_TIMEOUT,
8993
6032
  protocolVersion: protocolVersions[1],
6033
+ maxBufferedChunks: 256 * 1024,
6034
+ maxFragments: 16 * 1024,
8994
6035
  maxPayload: 100 * 1024 * 1024,
8995
6036
  skipUTF8Validation: false,
8996
6037
  perMessageDeflate: true,
@@ -9348,6 +6389,8 @@ function requireWebsocket () {
9348
6389
  websocket.setSocket(socket, head, {
9349
6390
  allowSynchronousEvents: opts.allowSynchronousEvents,
9350
6391
  generateMask: opts.generateMask,
6392
+ maxBufferedChunks: opts.maxBufferedChunks,
6393
+ maxFragments: opts.maxFragments,
9351
6394
  maxPayload: opts.maxPayload,
9352
6395
  skipUTF8Validation: opts.skipUTF8Validation
9353
6396
  });
@@ -9990,7 +7033,7 @@ function requireWebsocketServer () {
9990
7033
  hasRequiredWebsocketServer = 1;
9991
7034
 
9992
7035
  const EventEmitter = require$$0$3;
9993
- const http = require$$2$1;
7036
+ const http = require$$2$2;
9994
7037
  const { Duplex } = require$$0;
9995
7038
  const { createHash } = require$$1;
9996
7039
 
@@ -10030,6 +7073,10 @@ function requireWebsocketServer () {
10030
7073
  * called
10031
7074
  * @param {Function} [options.handleProtocols] A hook to handle protocols
10032
7075
  * @param {String} [options.host] The hostname where to bind the server
7076
+ * @param {Number} [options.maxBufferedChunks=262144] The maximum number of
7077
+ * buffered data chunks
7078
+ * @param {Number} [options.maxFragments=16384] The maximum number of message
7079
+ * fragments
10033
7080
  * @param {Number} [options.maxPayload=104857600] The maximum allowed message
10034
7081
  * size
10035
7082
  * @param {Boolean} [options.noServer=false] Enable no server mode
@@ -10052,6 +7099,8 @@ function requireWebsocketServer () {
10052
7099
  options = {
10053
7100
  allowSynchronousEvents: true,
10054
7101
  autoPong: true,
7102
+ maxBufferedChunks: 256 * 1024,
7103
+ maxFragments: 16 * 1024,
10055
7104
  maxPayload: 100 * 1024 * 1024,
10056
7105
  skipUTF8Validation: false,
10057
7106
  perMessageDeflate: false,
@@ -10411,6 +7460,8 @@ function requireWebsocketServer () {
10411
7460
 
10412
7461
  ws.setSocket(socket, head, {
10413
7462
  allowSynchronousEvents: this.options.allowSynchronousEvents,
7463
+ maxBufferedChunks: this.options.maxBufferedChunks,
7464
+ maxFragments: this.options.maxFragments,
10414
7465
  maxPayload: this.options.maxPayload,
10415
7466
  skipUTF8Validation: this.options.skipUTF8Validation
10416
7467
  });
@@ -10670,7 +7721,9 @@ let serverOption = {
10670
7721
  };
10671
7722
 
10672
7723
  const decoder$3 = new TextDecoder();
10673
- const MB = mbp.MB;
7724
+
7725
+ M$1.NB;
7726
+ const MB = M$1.MB;
10674
7727
 
10675
7728
 
10676
7729
  class RemoteCore {
@@ -10682,7 +7735,7 @@ class RemoteCore {
10682
7735
  socket.rxCounter = 0;
10683
7736
  socket.openTime = Date.now();
10684
7737
 
10685
- this.boho = new K();
7738
+ this.boho = new tt();
10686
7739
  this.encMode = ENC_MODE.AUTO;
10687
7740
  this.channels = new Set(); // subscribed tags
10688
7741
  this.retain_signal = new Map();
@@ -10736,7 +7789,7 @@ class RemoteCore {
10736
7789
  let prnLimit = 20;
10737
7790
  if (isBinary) {
10738
7791
  let msgTypeName = IOMsg[message[0]];
10739
- if (!msgTypeName) msgTypeName = K.BohoMsg[message[0]];
7792
+ if (!msgTypeName) msgTypeName = tt.BohoMsg[message[0]];
10740
7793
 
10741
7794
  msgTypeName = '[' + msgTypeName + ']';
10742
7795
  let size = message.byteLength;
@@ -10789,7 +7842,7 @@ class RemoteCore {
10789
7842
  if (isBinary) {
10790
7843
  msgType = message[0];
10791
7844
 
10792
- if (msgType === K.BohoMsg.ENC_488) {
7845
+ if (msgType === tt.BohoMsg.ENC_488) {
10793
7846
 
10794
7847
  try {
10795
7848
  decoded = this.boho.decrypt_488(message);
@@ -10805,7 +7858,7 @@ class RemoteCore {
10805
7858
  return
10806
7859
  }
10807
7860
 
10808
- } else if (msgType === K.BohoMsg.ENC_E2E) { // symetric E2EE Signal
7861
+ } else if (msgType === tt.BohoMsg.ENC_E2E) { // symetric E2EE Signal
10809
7862
  try {
10810
7863
  decoded = this.boho.decrypt_488(message);
10811
7864
  } catch (err) {
@@ -10815,8 +7868,8 @@ class RemoteCore {
10815
7868
  // console.log('e2e unpack:', decoded )
10816
7869
  if (decoded) {
10817
7870
  msgType = decoded[0];
10818
- message.set(decoded, K.MetaSize.ENC_488); // set decoded signal_e2e headaer.
10819
- message = message.subarray(K.MetaSize.ENC_488); // reset offset.
7871
+ message.set(decoded, tt.MetaSize.ENC_488); // set decoded signal_e2e headaer.
7872
+ message = message.subarray(tt.MetaSize.ENC_488); // reset offset.
10820
7873
  } else {
10821
7874
  return
10822
7875
  }
@@ -10844,7 +7897,7 @@ class RemoteCore {
10844
7897
  }
10845
7898
 
10846
7899
  // console.log('<< SENDING CID_RES:', this.cid)
10847
- this.send_enc_mode(mbp.pack(
7900
+ this.send_enc_mode(M$1.pack(
10848
7901
  MB('#cid_ack', '8', IOMsg.CID_RES),
10849
7902
  MB('#cid', this.cid)
10850
7903
  ));
@@ -10928,7 +7981,7 @@ class RemoteCore {
10928
7981
 
10929
7982
  case IOMsg.CALL: //service request
10930
7983
  try {
10931
- let req = mbp.unpack(message);
7984
+ let req = M$1.unpack(message);
10932
7985
  if (req) {
10933
7986
  if (!req.target || !req.topic) return
10934
7987
  if (this.manager.server.serviceNames.has(req.target)) {
@@ -10953,7 +8006,7 @@ class RemoteCore {
10953
8006
 
10954
8007
 
10955
8008
  // client's auth requst
10956
- case K.BohoMsg.AUTH_REQ:
8009
+ case tt.BohoMsg.AUTH_REQ:
10957
8010
  if (!this.manager.authManager) return
10958
8011
  if (this.state < STATE.SERVER_READY) {
10959
8012
  console.log('protocol error. must called auth_req after server_ready');
@@ -10998,14 +8051,14 @@ class RemoteCore {
10998
8051
  response(msgId, statusCode, body) {
10999
8052
  // console.log('response body', body)
11000
8053
  if (body) {
11001
- this.send_enc_mode(mbp.pack(
8054
+ this.send_enc_mode(M$1.pack(
11002
8055
  MB('#type', '8', IOMsg.RESPONSE_MBP),
11003
8056
  MB('status', '8', statusCode),
11004
8057
  MB('mid', '16', msgId),
11005
8058
  MB('body', body)
11006
8059
  ));
11007
8060
  } else {
11008
- this.send_enc_mode(mbp.pack(
8061
+ this.send_enc_mode(M$1.pack(
11009
8062
  MB('#type', '8', IOMsg.RESPONSE_MBP),
11010
8063
  MB('status', '8', statusCode),
11011
8064
  MB('mid', '16', msgId)
@@ -11032,7 +8085,7 @@ class RemoteCore {
11032
8085
  // console.log('server bypass E2E signal taginfo:', tagInfo )
11033
8086
 
11034
8087
  let encHeader = this.boho.encrypt_488(data.subarray(0, 3 + tagLen));
11035
- encHeader[0] = K.BohoMsg.ENC_E2E;
8088
+ encHeader[0] = tt.BohoMsg.ENC_E2E;
11036
8089
  let newEncBuffer = Buffer.concat([encHeader, data.subarray(3 + tagLen)]);
11037
8090
  this.send(newEncBuffer);
11038
8091
 
@@ -11072,7 +8125,7 @@ class RemoteCore {
11072
8125
  }
11073
8126
 
11074
8127
  // console.log( 'iam res info', info )
11075
- let pack = mbp.pack(
8128
+ let pack = M$1.pack(
11076
8129
  MB('#MsgType', '8', IOMsg.IAM_RES),
11077
8130
  MB('#info', info)
11078
8131
  );
@@ -11650,9 +8703,9 @@ class Manager {
11650
8703
 
11651
8704
  // it's like unix wall command.
11652
8705
  serverSignal(obj) {
11653
- let sigPack = mbp.pack(
11654
- mbp.MB('#MsgType', '8', IOMsg.SERVER_SIGNAL),
11655
- mbp.MB('#signalObject', obj)
8706
+ let sigPack = M$1.pack(
8707
+ M$1.MB('#MsgType', '8', IOMsg.SERVER_SIGNAL),
8708
+ M$1.MB('#signalObject', obj)
11656
8709
  );
11657
8710
 
11658
8711
  this.remotes.forEach(remote => {
@@ -12217,7 +9270,7 @@ class BohoAuth {
12217
9270
  peer.setState(STATE.AUTH_FAIL);
12218
9271
  // add some delay time.
12219
9272
  setTimeout(e => {
12220
- peer.send(Buffer.from([K.BohoMsg.AUTH_FAIL]));
9273
+ peer.send(Buffer.from([tt.BohoMsg.AUTH_FAIL]));
12221
9274
  }, serverOption.auth.delay_auth_fail);
12222
9275
  }
12223
9276
 
@@ -12225,7 +9278,7 @@ class BohoAuth {
12225
9278
  async verify_auth_req(auth_req, peer) {
12226
9279
  try {
12227
9280
  //1. unpack
12228
- let infoPack = mbp.unpack(auth_req, K.Meta.AUTH_REQ);
9281
+ let infoPack = M$1.unpack(auth_req, tt.Meta.AUTH_REQ);
12229
9282
  if (!infoPack) {
12230
9283
  this.send_auth_fail(peer, 'unpack auth_pack fail');
12231
9284
  return
@@ -12281,9 +9334,9 @@ class BohoAuth {
12281
9334
  return
12282
9335
  }
12283
9336
 
12284
- let authClearSignal = mbp.pack(
12285
- mbp.MB('#MsgType', '8', IOMsg.AUTH_CLEAR),
12286
- mbp.MB('#reason', 'duplicate login.')
9337
+ let authClearSignal = M$1.pack(
9338
+ M$1.MB('#MsgType', '8', IOMsg.AUTH_CLEAR),
9339
+ M$1.MB('#reason', 'duplicate login.')
12287
9340
  );
12288
9341
  if (this.keepOldConnection) { // default true
12289
9342
  // keep old connection. reject new connection by sending auth_fail signal.
@@ -12433,7 +9486,7 @@ class FileKeyProvider {
12433
9486
  }
12434
9487
 
12435
9488
  addAuth(id, keyStr, cid, level = 0) {
12436
- let Base64hashKey = Buffer.from(K.sha256.hash(keyStr)).toString('base64');
9489
+ let Base64hashKey = Buffer.from(tt.sha256.hash(keyStr)).toString('base64');
12437
9490
  this.AUTH.set(id, { key: Base64hashKey, cid: cid, level: level });
12438
9491
  }
12439
9492
  }
@@ -12470,7 +9523,7 @@ class RedisKeyProvider {
12470
9523
 
12471
9524
  // add device auth info
12472
9525
  async addAuth(id, keyStr, cid = '', level = 0) {
12473
- let Base64hashKey = Buffer.from(K.sha256.hash(keyStr)).toString('base64');
9526
+ let Base64hashKey = Buffer.from(tt.sha256.hash(keyStr)).toString('base64');
12474
9527
  return this.redis.hSet(DEVICE_PREFIX + id, { 'key': Base64hashKey, 'cid': cid, 'level': level })
12475
9528
  }
12476
9529
 
@@ -12533,7 +9586,7 @@ class StringKeyProvider {
12533
9586
  }
12534
9587
 
12535
9588
  addAuth(id, keyStr, cid, level = 0) {
12536
- let Base64hashKey = Buffer.from(K.sha256.hash(keyStr)).toString('base64');
9589
+ let Base64hashKey = Buffer.from(tt.sha256.hash(keyStr)).toString('base64');
12537
9590
  this.AUTH.set(id, { key: Base64hashKey, cid: cid, level: level });
12538
9591
  }
12539
9592
  }
@@ -12720,7 +9773,7 @@ class RedisService {
12720
9773
 
12721
9774
  const version = pkg.version;
12722
9775
 
12723
- exports.Boho = K;
9776
+ exports.Boho = tt;
12724
9777
  exports.BohoAuth = BohoAuth;
12725
9778
  exports.CongRx = CongRx;
12726
9779
  exports.ENC_MODE = ENC_MODE;
@@ -12729,7 +9782,7 @@ exports.FileLogger = FileLogger;
12729
9782
  exports.IO = IOWS;
12730
9783
  exports.IOCongSocket = IOCongSocket;
12731
9784
  exports.IOMsg = IOMsg;
12732
- exports.MBP = mbp;
9785
+ exports.MBP = M$1;
12733
9786
  exports.PAYLOAD_TYPE = PAYLOAD_TYPE;
12734
9787
  exports.RedisKeyProvider = RedisKeyProvider;
12735
9788
  exports.RedisService = RedisService;