mphttpx 1.0.12 → 1.2.0-beta.1

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.
package/dist/index.esm.js CHANGED
@@ -7,13 +7,6 @@
7
7
  /** @internal */
8
8
  const polyfill = "MPHTTPX";
9
9
  /** @internal */
10
- function Class_setStringTag(targetFunc, stringTag) {
11
- Object.defineProperty(targetFunc.prototype, Symbol.toStringTag, {
12
- configurable: true,
13
- value: stringTag,
14
- });
15
- }
16
- /** @internal */
17
10
  function checkArgsLength(args, required, className, funcName) {
18
11
  if (args.length < required) {
19
12
  throw new TypeError(`Failed to ${funcName ? ("execute '" + funcName + "' on") : "construct"} '${className}': ${required} argument${required > 1 ? "s" : ""} required, but only ${args.length} present.`);
@@ -34,7 +27,7 @@ function isObjectType(name, value) {
34
27
  return Object.prototype.toString.call(value) === `[object ${name}]`;
35
28
  }
36
29
  /** @internal */
37
- function isPolyfillType(name, value) {
30
+ function isPolyfillType(name, value, strict = false) {
38
31
  return !!value
39
32
  && typeof value === "object"
40
33
  && "isPolyfill" in value
@@ -44,7 +37,12 @@ function isPolyfillType(name, value) {
44
37
  && value.isPolyfill.symbol === polyfill
45
38
  && "hierarchy" in value.isPolyfill
46
39
  && Array.isArray(value.isPolyfill.hierarchy)
47
- && value.isPolyfill.hierarchy.indexOf(name) > -1;
40
+ && ((index) => strict ? index === 0 : index > -1)(value.isPolyfill.hierarchy.indexOf(name));
41
+ }
42
+ /** @internal */
43
+ function isArrayBuffer(value) {
44
+ // Mini Program
45
+ return isObjectType("ArrayBuffer", value) || (!!value && typeof value === "object" && ArrayBuffer.prototype.isPrototypeOf(value));
48
46
  }
49
47
 
50
48
  class TextEncoderP {
@@ -57,16 +55,16 @@ class TextEncoderP {
57
55
  const [source, destination] = args;
58
56
  checkArgsLength(args, 2, "TextEncoder", "encodeInto");
59
57
  let _source = "" + source;
60
- if (!(destination instanceof Uint8Array)) {
58
+ if (!(destination instanceof Uint8Array || isObjectType("Uint8Array", destination))) {
61
59
  throw new TypeError("Failed to execute 'encodeInto' on 'TextEncoder': parameter 2 is not of type 'Uint8Array'.");
62
60
  }
63
61
  let result = encodeText(_source, destination);
64
62
  return { read: result.read, written: result.written };
65
63
  }
66
64
  /** @internal */ toString() { return "[object TextEncoder]"; }
65
+ /** @internal */ get [Symbol.toStringTag]() { return "TextEncoder"; }
67
66
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["TextEncoder"] }; }
68
67
  }
69
- Class_setStringTag(TextEncoderP, "TextEncoder");
70
68
  function encodeText(input, destination) {
71
69
  const HAS_DESTINATION = typeof destination !== "undefined";
72
70
  let pos = 0;
@@ -163,30 +161,30 @@ function encodeText(input, destination) {
163
161
  }
164
162
  const TextEncoderE = g["TextEncoder"] || TextEncoderP;
165
163
 
166
- var _a$a, _b$3;
164
+ var _a$b, _b$4;
167
165
  /** @internal */
168
- const state$h = Symbol( /* "TextDecoderState" */);
166
+ const state$k = Symbol( /* "TextDecoderState" */);
169
167
  class TextDecoderP {
170
168
  constructor(label = "utf-8", { fatal = false, ignoreBOM = false } = {}) {
171
169
  let _label = "" + label;
172
170
  if (["utf-8", "utf8", "unicode-1-1-utf-8"].indexOf(_label.toLowerCase()) === -1) {
173
171
  throw new RangeError(`Failed to construct 'TextDecoder': encoding ('${_label}') not implemented.`);
174
172
  }
175
- this[state$h] = new TextDecoderState();
176
- this[state$h].fatal = !!fatal;
177
- this[state$h].ignoreBOM = !!ignoreBOM;
173
+ this[state$k] = new TextDecoderState();
174
+ this[state$k].fatal = !!fatal;
175
+ this[state$k].ignoreBOM = !!ignoreBOM;
178
176
  }
179
177
  get encoding() { return "utf-8"; }
180
- get fatal() { return this[state$h].fatal; }
181
- get ignoreBOM() { return this[state$h].ignoreBOM; }
178
+ get fatal() { return this[state$k].fatal; }
179
+ get ignoreBOM() { return this[state$k].ignoreBOM; }
182
180
  decode(input, { stream = false } = {}) {
183
- const s = this[state$h];
181
+ const s = this[state$k];
184
182
  let bytes;
185
183
  if (input !== undefined) {
186
- if (input instanceof ArrayBuffer) {
184
+ if (isArrayBuffer(input)) {
187
185
  bytes = new Uint8Array(input);
188
186
  }
189
- else if (input instanceof Uint8Array) {
187
+ else if (input instanceof Uint8Array || isObjectType("Uint8Array", input)) {
190
188
  bytes = input;
191
189
  }
192
190
  else if (ArrayBuffer.isView(input)) {
@@ -309,9 +307,9 @@ class TextDecoderP {
309
307
  return res.length > 0x4000 ? buildString(res) : concatString(res);
310
308
  }
311
309
  /** @internal */ toString() { return "[object TextDecoder]"; }
310
+ /** @internal */ get [Symbol.toStringTag]() { return "TextDecoder"; }
312
311
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["TextDecoder"] }; }
313
312
  }
314
- Class_setStringTag(TextDecoderP, "TextDecoder");
315
313
  /** @internal */ const _bomDone = Symbol();
316
314
  /** @internal */ const _partial = Symbol();
317
315
  /** @internal */
@@ -319,11 +317,11 @@ class TextDecoderState {
319
317
  constructor() {
320
318
  this.fatal = false;
321
319
  this.ignoreBOM = false;
322
- this[_a$a] = 0;
323
- this[_b$3] = [];
320
+ this[_a$b] = 0;
321
+ this[_b$4] = [];
324
322
  }
325
323
  }
326
- _a$a = _bomDone, _b$3 = _partial;
324
+ _a$b = _bomDone, _b$4 = _partial;
327
325
  function getBytesPerSequence(byte) {
328
326
  return (byte > 0xEF) ? 4 : (byte > 0xDF) ? 3 : (byte > 0xBF) ? 2 : 1;
329
327
  }
@@ -344,7 +342,7 @@ const concatString = (res) => {
344
342
  const TextDecoderE = g["TextDecoder"] || TextDecoderP;
345
343
 
346
344
  /** @internal */
347
- const state$g = Symbol( /* "BlobState" */);
345
+ const state$j = Symbol( /* "BlobState" */);
348
346
  class BlobP {
349
347
  constructor(blobParts = [], options) {
350
348
  if (!(Array.isArray(blobParts) || (blobParts && typeof blobParts === "object" && Symbol.iterator in blobParts))) {
@@ -355,43 +353,43 @@ class BlobP {
355
353
  for (let i = 0; i < _blobParts.length; ++i) {
356
354
  let chunk = _blobParts[i];
357
355
  if (isPolyfillType("Blob", chunk)) {
358
- chunks.push(chunk[state$g][_buffer]);
356
+ chunks.push(chunk[state$j][_buffer]);
359
357
  }
360
- else if (chunk instanceof ArrayBuffer || ArrayBuffer.isView(chunk)) {
358
+ else if (isArrayBuffer(chunk) || ArrayBuffer.isView(chunk)) {
361
359
  chunks.push(BufferSource_toUint8Array(chunk));
362
360
  }
363
361
  else {
364
362
  chunks.push(encode$1("" + chunk));
365
363
  }
366
364
  }
367
- this[state$g] = new BlobState(concat(chunks));
368
- const s = this[state$g];
365
+ this[state$j] = new BlobState(concat(chunks));
366
+ const s = this[state$j];
369
367
  s.size = s[_buffer].length;
370
368
  let rawType = "" + ((options === null || options === void 0 ? void 0 : options.type) || "");
371
369
  s.type = /[^\u0020-\u007E]/.test(rawType) ? "" : rawType.toLowerCase();
372
370
  }
373
- get size() { return this[state$g].size; }
374
- get type() { return this[state$g].type; }
371
+ get size() { return this[state$j].size; }
372
+ get type() { return this[state$j].type; }
375
373
  arrayBuffer() {
376
- return Promise.resolve(clone(this[state$g][_buffer].buffer).buffer);
374
+ return Promise.resolve(clone(this[state$j][_buffer].buffer).buffer);
377
375
  }
378
376
  bytes() {
379
- return Promise.resolve(clone(this[state$g][_buffer].buffer));
377
+ return Promise.resolve(clone(this[state$j][_buffer].buffer));
380
378
  }
381
379
  slice(start, end, contentType) {
382
- let sliced = this[state$g][_buffer].slice(start !== null && start !== void 0 ? start : 0, end !== null && end !== void 0 ? end : this[state$g][_buffer].length); // × WeChat 2.5.0
380
+ let sliced = this[state$j][_buffer].slice(start !== null && start !== void 0 ? start : 0, end !== null && end !== void 0 ? end : this[state$j][_buffer].length); // × WeChat 2.5.0
383
381
  return new BlobP([sliced], { type: "" + (contentType !== null && contentType !== void 0 ? contentType : "") });
384
382
  }
385
383
  stream() {
386
384
  throw new TypeError("Failed to execute 'stream' on 'Blob': method not implemented.");
387
385
  }
388
386
  text() {
389
- return Promise.resolve(decode$1(this[state$g][_buffer]));
387
+ return Promise.resolve(decode$1(this[state$j][_buffer]));
390
388
  }
391
389
  /** @internal */ toString() { return "[object Blob]"; }
390
+ /** @internal */ get [Symbol.toStringTag]() { return "Blob"; }
392
391
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Blob"] }; }
393
392
  }
394
- Class_setStringTag(BlobP, "Blob");
395
393
  /** @internal */
396
394
  const _buffer = Symbol();
397
395
  /** @internal */
@@ -404,10 +402,10 @@ class BlobState {
404
402
  }
405
403
  /** @internal */
406
404
  function Blob_toUint8Array(blob) {
407
- return blob[state$g][_buffer];
405
+ return blob[state$j][_buffer];
408
406
  }
409
407
  function BufferSource_toUint8Array(buf) {
410
- return buf instanceof ArrayBuffer
408
+ return isArrayBuffer(buf)
411
409
  ? new Uint8Array(buf)
412
410
  : new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
413
411
  }
@@ -463,23 +461,23 @@ function Uint8Array_toBase64(input) {
463
461
  const BlobE = g["Blob"] || BlobP;
464
462
 
465
463
  /** @internal */
466
- const state$f = Symbol( /* "FileState" */);
464
+ const state$i = Symbol( /* "FileState" */);
467
465
  class FileP extends BlobP {
468
466
  constructor(...args) {
469
467
  const [fileBits, fileName, options] = args;
470
468
  checkArgsLength(args, 2, "File");
471
469
  super(fileBits, options);
472
- this[state$f] = new FileState();
473
- this[state$f].lastModified = +((options === null || options === void 0 ? void 0 : options.lastModified) ? new Date(options.lastModified) : new Date()) || 0;
474
- this[state$f].name = "" + fileName;
470
+ this[state$i] = new FileState();
471
+ this[state$i].lastModified = +((options === null || options === void 0 ? void 0 : options.lastModified) ? new Date(options.lastModified) : new Date()) || 0;
472
+ this[state$i].name = "" + fileName;
475
473
  }
476
- get lastModified() { return this[state$f].lastModified; }
477
- get name() { return this[state$f].name; }
474
+ get lastModified() { return this[state$i].lastModified; }
475
+ get name() { return this[state$i].name; }
478
476
  get webkitRelativePath() { return ""; }
479
477
  /** @internal */ toString() { return "[object File]"; }
478
+ /** @internal */ get [Symbol.toStringTag]() { return "File"; }
480
479
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["File", "Blob"] }; }
481
480
  }
482
- Class_setStringTag(FileP, "File");
483
481
  /** @internal */
484
482
  class FileState {
485
483
  constructor() {
@@ -489,39 +487,47 @@ class FileState {
489
487
  }
490
488
  const FileE = g["Blob"] ? g["File"] : FileP;
491
489
 
492
- var _a$9, _b$2, _c$1, _d$1, _e$1;
493
- /** @internal */ const state$e = Symbol( /* "EventState" */);
490
+ var _a$a, _b$3, _c$1, _d$1, _e$1;
491
+ /** @internal */ const state$h = Symbol( /* "EventState" */);
494
492
  class EventP {
493
+ static get NONE() { return 0; }
494
+ static get CAPTURING_PHASE() { return 1; }
495
+ static get AT_TARGET() { return 2; }
496
+ static get BUBBLING_PHASE() { return 3; }
495
497
  constructor(...args) {
496
498
  const [type, eventInitDict] = args;
497
499
  checkArgsLength(args, 1, new.target.name);
498
- this[state$e] = new EventState();
499
- const s = this[state$e];
500
+ this[state$h] = new EventState();
501
+ const s = this[state$h];
500
502
  s.type = "" + type;
501
503
  s.bubbles = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.bubbles);
502
504
  s.cancelable = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.cancelable);
503
505
  s.composed = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.composed);
504
506
  Object.defineProperty(this, "isTrusted", {
505
507
  enumerable: true,
506
- get: (function isTrusted() { return this[state$e][_isTrusted]; }).bind(this),
508
+ get: (function isTrusted() { return this[state$h][_isTrusted]; }).bind(this),
507
509
  });
508
510
  }
509
- get type() { return this[state$e].type; }
510
- get bubbles() { return this[state$e].bubbles; }
511
- get cancelable() { return this[state$e].cancelable; }
512
- get composed() { return this[state$e].composed; }
513
- get target() { return this[state$e].target; }
514
- get currentTarget() { return this[state$e].currentTarget; }
515
- get eventPhase() { return this[state$e].eventPhase; }
516
- get srcElement() { return this[state$e].target; }
517
- get cancelBubble() { return this[state$e].cancelBubble; }
518
- set cancelBubble(value) { this[state$e].cancelBubble = !!value; }
519
- get defaultPrevented() { return this[state$e].defaultPrevented; }
520
- get returnValue() { return this[state$e].returnValue; }
511
+ get type() { return this[state$h].type; }
512
+ get bubbles() { return this[state$h].bubbles; }
513
+ get cancelable() { return this[state$h].cancelable; }
514
+ get composed() { return this[state$h].composed; }
515
+ get target() { return this[state$h].target; }
516
+ get currentTarget() { return this[state$h].currentTarget; }
517
+ get eventPhase() { return this[state$h].eventPhase; }
518
+ get NONE() { return 0; }
519
+ get CAPTURING_PHASE() { return 1; }
520
+ get AT_TARGET() { return 2; }
521
+ get BUBBLING_PHASE() { return 3; }
522
+ get srcElement() { return this[state$h].target; }
523
+ get cancelBubble() { return this[state$h].cancelBubble; }
524
+ set cancelBubble(value) { this[state$h].cancelBubble = !!value; }
525
+ get defaultPrevented() { return this[state$h].defaultPrevented; }
526
+ get returnValue() { return this[state$h].returnValue; }
521
527
  set returnValue(value) { if (!value) {
522
528
  this.preventDefault();
523
529
  } }
524
- get timeStamp() { return this[state$e].timeStamp; }
530
+ get timeStamp() { return this[state$h].timeStamp; }
525
531
  composedPath() {
526
532
  let path = !!this.target ? [this.target] : [];
527
533
  if (!!this.currentTarget && this.currentTarget !== this.target)
@@ -531,7 +537,7 @@ class EventP {
531
537
  initEvent(...args) {
532
538
  const [type, bubbles, cancelable] = args;
533
539
  checkArgsLength(args, 1, "Event", "initEvent");
534
- const s = this[state$e];
540
+ const s = this[state$h];
535
541
  if (s[_dispatched])
536
542
  return;
537
543
  s.type = "" + type;
@@ -539,7 +545,7 @@ class EventP {
539
545
  s.cancelable = !!cancelable;
540
546
  }
541
547
  preventDefault() {
542
- const s = this[state$e];
548
+ const s = this[state$h];
543
549
  if (s[_passive]) {
544
550
  console.warn(`Ignoring 'preventDefault()' call on event of type '${this.type}' from a listener registered as 'passive'.`);
545
551
  return;
@@ -551,24 +557,16 @@ class EventP {
551
557
  }
552
558
  }
553
559
  stopImmediatePropagation() {
554
- this[state$e][_stopImmediatePropagationCalled] = true;
560
+ this[state$h][_stopImmediatePropagationCalled] = true;
555
561
  this.cancelBubble = true;
556
562
  }
557
563
  stopPropagation() {
558
564
  this.cancelBubble = true;
559
565
  }
560
566
  /** @internal */ toString() { return "[object Event]"; }
567
+ /** @internal */ get [Symbol.toStringTag]() { return "Event"; }
561
568
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Event"] }; }
562
569
  }
563
- const properties$1 = {
564
- NONE: { value: 0, enumerable: true },
565
- CAPTURING_PHASE: { value: 1, enumerable: true },
566
- AT_TARGET: { value: 2, enumerable: true },
567
- BUBBLING_PHASE: { value: 3, enumerable: true },
568
- };
569
- Object.defineProperties(EventP, properties$1);
570
- Object.defineProperties(EventP.prototype, properties$1);
571
- Class_setStringTag(EventP, "Event");
572
570
  /** @internal */ const _timeStamp = (new Date()).getTime();
573
571
  /** @internal */ const _isTrusted = Symbol();
574
572
  /** @internal */ const _passive = Symbol();
@@ -584,22 +582,22 @@ class EventState {
584
582
  this.composed = false;
585
583
  this.target = null;
586
584
  this.currentTarget = null;
587
- this.eventPhase = EventP.NONE;
585
+ this.eventPhase = 0 /* NONE */;
588
586
  this.cancelBubble = false;
589
587
  this.defaultPrevented = false;
590
588
  this.returnValue = true;
591
589
  this.timeStamp = (new Date()).getTime() - _timeStamp;
592
- this[_a$9] = false;
593
- this[_b$2] = false;
590
+ this[_a$a] = false;
591
+ this[_b$3] = false;
594
592
  this[_c$1] = false;
595
593
  this[_d$1] = false;
596
594
  this[_e$1] = false;
597
595
  }
598
596
  }
599
- _a$9 = _isTrusted, _b$2 = _passive, _c$1 = _dispatched, _d$1 = _preventDefaultCalled, _e$1 = _stopImmediatePropagationCalled;
597
+ _a$a = _isTrusted, _b$3 = _passive, _c$1 = _dispatched, _d$1 = _preventDefaultCalled, _e$1 = _stopImmediatePropagationCalled;
600
598
  /** @internal */
601
599
  function Event_setTrusted(event, isTrusted) {
602
- Object.defineProperty(event[state$e], _isTrusted, {
600
+ Object.defineProperty(event[state$h], _isTrusted, {
603
601
  value: isTrusted,
604
602
  writable: true,
605
603
  enumerable: true,
@@ -607,16 +605,16 @@ function Event_setTrusted(event, isTrusted) {
607
605
  });
608
606
  }
609
607
  const passive$1 = 0;
610
- const dispatched$2 = 1;
608
+ const dispatched$3 = 1;
611
609
  const preventDefaultCalled$1 = 2;
612
610
  const stopImmediatePropagationCalled$1 = 3;
613
611
  /** @internal */
614
612
  function Event_getEtField(event, field) {
615
- const s = event[state$e];
613
+ const s = event[state$h];
616
614
  switch (field) {
617
615
  case passive$1:
618
616
  return s[_passive];
619
- case dispatched$2:
617
+ case dispatched$3:
620
618
  return s[_dispatched];
621
619
  case preventDefaultCalled$1:
622
620
  return s[_preventDefaultCalled];
@@ -626,12 +624,12 @@ function Event_getEtField(event, field) {
626
624
  }
627
625
  /** @internal */
628
626
  function Event_setEtField(event, field, value) {
629
- const s = event[state$e];
627
+ const s = event[state$h];
630
628
  switch (field) {
631
629
  case passive$1:
632
630
  s[_passive] = value;
633
631
  break;
634
- case dispatched$2:
632
+ case dispatched$3:
635
633
  s[_dispatched] = value;
636
634
  break;
637
635
  case preventDefaultCalled$1:
@@ -645,30 +643,30 @@ function Event_setEtField(event, field, value) {
645
643
  /** @internal */
646
644
  function createInnerEvent(target, type, eventInitDict, isTrusted = true) {
647
645
  let event = new EventP(type, eventInitDict);
648
- event[state$e].target = target;
649
- event[state$e][_isTrusted] = isTrusted;
646
+ event[state$h].target = target;
647
+ event[state$h][_isTrusted] = isTrusted;
650
648
  return event;
651
649
  }
652
650
  const EventE = g["EventTarget"] ? g["Event"] : EventP;
653
651
 
654
- var _a$8;
652
+ var _a$9;
655
653
  const passive = 0;
656
- const dispatched$1 = 1;
654
+ const dispatched$2 = 1;
657
655
  const preventDefaultCalled = 2;
658
656
  const stopImmediatePropagationCalled = 3;
659
- /** @internal */ const state$d = Symbol( /* "EventTargetState" */);
657
+ /** @internal */ const state$g = Symbol( /* "EventTargetState" */);
660
658
  class EventTargetP {
661
659
  constructor() {
662
- this[state$d] = new EventTargetState(this);
663
- this[state$d].name = new.target.name;
660
+ this[state$g] = new EventTargetState(this);
661
+ this[state$g].name = new.target.name;
664
662
  }
665
663
  addEventListener(...args) {
666
664
  const [type, callback, options] = args;
667
- checkArgsLength(args, 2, this[state$d].name, "addEventListener");
665
+ checkArgsLength(args, 2, this[state$g].name, "addEventListener");
668
666
  if (typeof callback !== "function" && typeof callback !== "object" && typeof callback !== "undefined") {
669
- throw new TypeError(`Failed to execute 'addEventListener' on '${this[state$d].name}': parameter 2 is not of type 'Object'.`);
667
+ throw new TypeError(`Failed to execute 'addEventListener' on '${this[state$g].name}': parameter 2 is not of type 'Object'.`);
670
668
  }
671
- const s = this[state$d];
669
+ const s = this[state$g];
672
670
  const executor = new Executor(type, callback);
673
671
  executor.options.capture = typeof options === "boolean" ? options : !!(options === null || options === void 0 ? void 0 : options.capture);
674
672
  if (!s[_executors].some(x => x.equals(executor))) {
@@ -688,21 +686,21 @@ class EventTargetP {
688
686
  }
689
687
  dispatchEvent(...args) {
690
688
  const [event] = args;
691
- checkArgsLength(args, 1, this[state$d].name, "dispatchEvent");
689
+ checkArgsLength(args, 1, this[state$g].name, "dispatchEvent");
692
690
  if (!(event instanceof EventP)) {
693
- throw new TypeError(`Failed to execute 'dispatchEvent' on '${this[state$d].name}': parameter 1 is not of type 'Event'.`);
691
+ throw new TypeError(`Failed to execute 'dispatchEvent' on '${this[state$g].name}': parameter 1 is not of type 'Event'.`);
694
692
  }
695
693
  Event_setTrusted(event, false);
696
- event[state$e].target = this;
694
+ event[state$h].target = this;
697
695
  return EventTarget_fire(this, event);
698
696
  }
699
697
  removeEventListener(...args) {
700
698
  const [type, callback, options] = args;
701
- checkArgsLength(args, 2, this[state$d].name, "removeEventListener");
699
+ checkArgsLength(args, 2, this[state$g].name, "removeEventListener");
702
700
  if (typeof callback !== "function" && typeof callback !== "object" && typeof callback !== "undefined") {
703
- throw new TypeError(`Failed to execute 'removeEventListener' on '${this[state$d].name}': parameter 2 is not of type 'Object'.`);
701
+ throw new TypeError(`Failed to execute 'removeEventListener' on '${this[state$g].name}': parameter 2 is not of type 'Object'.`);
704
702
  }
705
- const s = this[state$d];
703
+ const s = this[state$g];
706
704
  const executor = new Executor(type, callback);
707
705
  executor.options.capture = typeof options === "boolean" ? options : !!(options === null || options === void 0 ? void 0 : options.capture);
708
706
  if (s[_executors].some(x => x.equals(executor))) {
@@ -710,29 +708,29 @@ class EventTargetP {
710
708
  }
711
709
  }
712
710
  /** @internal */ toString() { return "[object EventTarget]"; }
711
+ /** @internal */ get [Symbol.toStringTag]() { return "EventTarget"; }
713
712
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["EventTarget"] }; }
714
713
  }
715
- Class_setStringTag(EventTargetP, "EventTarget");
716
714
  /** @internal */
717
715
  const _executors = Symbol();
718
716
  /** @internal */
719
717
  class EventTargetState {
720
718
  constructor(target) {
721
719
  this.name = "EventTarget";
722
- this[_a$8] = [];
720
+ this[_a$9] = [];
723
721
  this.target = target;
724
722
  }
725
723
  }
726
- _a$8 = _executors;
724
+ _a$9 = _executors;
727
725
  /** @internal */
728
726
  function EventTarget_fire(target, event) {
729
- const s = target[state$d];
730
- const evs = event[state$e];
727
+ const s = target[state$g];
728
+ const evs = event[state$h];
731
729
  if (!event.target)
732
730
  evs.target = target;
733
731
  evs.currentTarget = target;
734
- evs.eventPhase = EventP.AT_TARGET;
735
- Event_setEtField(event, dispatched$1, true);
732
+ evs.eventPhase = 2 /* AT_TARGET */;
733
+ Event_setEtField(event, dispatched$2, true);
736
734
  let onceIndexes = [];
737
735
  for (let i = 0; i < s[_executors].length; ++i) {
738
736
  if (Event_getEtField(event, stopImmediatePropagationCalled))
@@ -761,12 +759,12 @@ function EventTarget_fire(target, event) {
761
759
  }, []);
762
760
  }
763
761
  evs.currentTarget = null;
764
- evs.eventPhase = EventP.NONE;
765
- Event_setEtField(event, dispatched$1, false);
762
+ evs.eventPhase = 0 /* NONE */;
763
+ Event_setEtField(event, dispatched$2, false);
766
764
  return !(event.cancelable && Event_getEtField(event, preventDefaultCalled));
767
765
  }
768
766
  function reply(target, signal, executor) {
769
- const s = target[state$d];
767
+ const s = target[state$g];
770
768
  const onAbort = () => {
771
769
  s[_executors] = s[_executors].filter(x => !x.equals(executor));
772
770
  signal.removeEventListener("abort", onAbort);
@@ -816,13 +814,13 @@ function executeFn(target, cb, ev) {
816
814
  const EventTargetE = g["EventTarget"] || EventTargetP;
817
815
 
818
816
  /** @internal */
819
- const state$c = Symbol( /* "ProgressEventState" */);
817
+ const state$f = Symbol( /* "ProgressEventState" */);
820
818
  class ProgressEventP extends EventP {
821
819
  constructor(type, eventInitDict) {
822
820
  var _a, _b;
823
821
  super(type, eventInitDict);
824
- this[state$c] = new ProgressEventState();
825
- const s = this[state$c];
822
+ this[state$f] = new ProgressEventState();
823
+ const s = this[state$f];
826
824
  s.lengthComputable = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.lengthComputable);
827
825
  s.loaded = Number((_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.loaded) !== null && _a !== void 0 ? _a : 0);
828
826
  s.total = Number((_b = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.total) !== null && _b !== void 0 ? _b : 0);
@@ -837,13 +835,13 @@ class ProgressEventP extends EventP {
837
835
  throw new TypeError(`Failed to construct 'ProgressEvent': Failed to read the '${errField}' property from 'ProgressEventInit': The provided double value is non-finite.`);
838
836
  }
839
837
  }
840
- get lengthComputable() { return getValue(this[state$c].lengthComputable); }
841
- get loaded() { return getValue(this[state$c].loaded); }
842
- get total() { return getValue(this[state$c].total); }
838
+ get lengthComputable() { return getValue(this[state$f].lengthComputable); }
839
+ get loaded() { return getValue(this[state$f].loaded); }
840
+ get total() { return getValue(this[state$f].total); }
843
841
  /** @internal */ toString() { return "[object ProgressEvent]"; }
842
+ /** @internal */ get [Symbol.toStringTag]() { return "ProgressEvent"; }
844
843
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["ProgressEvent", "Event"] }; }
845
844
  }
846
- Class_setStringTag(ProgressEventP, "ProgressEvent");
847
845
  /** @internal */
848
846
  class ProgressEventState {
849
847
  constructor() {
@@ -857,10 +855,10 @@ function getValue(val) {
857
855
  }
858
856
  function createInnerProgressEvent(target, type, { lengthComputable = false, loaded = 0, total = 0, } = {}) {
859
857
  let event = new ProgressEventP(type);
860
- event[state$c].lengthComputable = lengthComputable;
861
- event[state$c].loaded = loaded;
862
- event[state$c].total = total;
863
- event[state$e].target = target;
858
+ event[state$f].lengthComputable = lengthComputable;
859
+ event[state$f].loaded = loaded;
860
+ event[state$f].total = total;
861
+ event[state$h].target = target;
864
862
  Event_setTrusted(event, true);
865
863
  return event;
866
864
  }
@@ -873,23 +871,29 @@ function emitProcessEvent(target, type, loaded = 0, total = 0) {
873
871
  });
874
872
  EventTarget_fire(target, event);
875
873
  }
876
- const ProgressEventE = g["EventTarget"] ? g["ProgressEvent"] : ProgressEventP;
874
+ g["EventTarget"] ? g["ProgressEvent"] : ProgressEventP;
877
875
 
878
- var _a$7;
876
+ var _a$8;
879
877
  /** @internal */
880
- const state$b = Symbol( /* "FileReaderState" */);
878
+ const state$e = Symbol( /* "FileReaderState" */);
881
879
  class FileReaderP extends EventTargetP {
880
+ static get EMPTY() { return 0; }
881
+ static get LOADING() { return 1; }
882
+ static get DONE() { return 2; }
882
883
  constructor() {
883
884
  super();
884
- this[state$b] = new FileReaderState(this);
885
- }
886
- get readyState() { return this[state$b].readyState; }
887
- get result() { return this[state$b].result; }
888
- get error() { return this[state$b].error; }
885
+ this[state$e] = new FileReaderState(this);
886
+ }
887
+ get readyState() { return this[state$e].readyState; }
888
+ get result() { return this[state$e].result; }
889
+ get EMPTY() { return 0; }
890
+ get LOADING() { return 1; }
891
+ get DONE() { return 2; }
892
+ get error() { return this[state$e].error; }
889
893
  abort() {
890
- if (this.readyState === FileReaderP.LOADING) {
891
- const s = this[state$b];
892
- s.readyState = FileReaderP.DONE;
894
+ if (this.readyState === 1 /* LOADING */) {
895
+ const s = this[state$e];
896
+ s.readyState = 2 /* DONE */;
893
897
  s.result = null;
894
898
  s.error = new MPException("An ongoing operation was aborted, typically with a call to abort().", "AbortError");
895
899
  emitProcessEvent(this, "abort");
@@ -897,7 +901,7 @@ class FileReaderP extends EventTargetP {
897
901
  }
898
902
  readAsArrayBuffer(...args) {
899
903
  read$1(this, "readAsArrayBuffer", args, blob => {
900
- this[state$b].result = Blob_toUint8Array(blob).buffer.slice(0);
904
+ this[state$e].result = Blob_toUint8Array(blob).buffer.slice(0);
901
905
  });
902
906
  }
903
907
  readAsBinaryString(...args) {
@@ -908,12 +912,12 @@ class FileReaderP extends EventTargetP {
908
912
  let char = buf[i];
909
913
  str.push(String.fromCharCode(char));
910
914
  }
911
- this[state$b].result = str.join("");
915
+ this[state$e].result = str.join("");
912
916
  });
913
917
  }
914
918
  readAsDataURL(...args) {
915
919
  read$1(this, "readAsDataURL", args, blob => {
916
- this[state$b].result = "data:" + (blob.type || "application/octet-stream") + ";base64," + Uint8Array_toBase64(Blob_toUint8Array(blob));
920
+ this[state$e].result = "data:" + (blob.type || "application/octet-stream") + ";base64," + Uint8Array_toBase64(Blob_toUint8Array(blob));
917
921
  });
918
922
  }
919
923
  readAsText(...args) {
@@ -925,41 +929,34 @@ class FileReaderP extends EventTargetP {
925
929
  console.error(`TypeError: Failed to execute 'readAsText' on 'FileReader': encoding ('${_encoding}') not implemented.`);
926
930
  }
927
931
  }
928
- this[state$b].result = decode$1(Blob_toUint8Array(blob));
932
+ this[state$e].result = decode$1(Blob_toUint8Array(blob));
929
933
  });
930
934
  }
931
- get onabort() { return this[state$b].onabort; }
932
- set onabort(value) { this[state$b].onabort = value; attach$1(this, "abort"); }
933
- get onerror() { return this[state$b].onerror; }
934
- set onerror(value) { this[state$b].onerror = value; attach$1(this, "error"); }
935
- get onload() { return this[state$b].onload; }
936
- set onload(value) { this[state$b].onload = value; attach$1(this, "load"); }
937
- get onloadend() { return this[state$b].onloadend; }
938
- set onloadend(value) { this[state$b].onloadend = value; attach$1(this, "loadend"); }
939
- get onloadstart() { return this[state$b].onloadstart; }
940
- set onloadstart(value) { this[state$b].onloadstart = value; attach$1(this, "loadstart"); }
941
- get onprogress() { return this[state$b].onprogress; }
942
- set onprogress(value) { this[state$b].onprogress = value; attach$1(this, "progress"); }
935
+ get onabort() { return this[state$e].onabort; }
936
+ set onabort(value) { this[state$e].onabort = value; attach$2(this, "abort"); }
937
+ get onerror() { return this[state$e].onerror; }
938
+ set onerror(value) { this[state$e].onerror = value; attach$2(this, "error"); }
939
+ get onload() { return this[state$e].onload; }
940
+ set onload(value) { this[state$e].onload = value; attach$2(this, "load"); }
941
+ get onloadend() { return this[state$e].onloadend; }
942
+ set onloadend(value) { this[state$e].onloadend = value; attach$2(this, "loadend"); }
943
+ get onloadstart() { return this[state$e].onloadstart; }
944
+ set onloadstart(value) { this[state$e].onloadstart = value; attach$2(this, "loadstart"); }
945
+ get onprogress() { return this[state$e].onprogress; }
946
+ set onprogress(value) { this[state$e].onprogress = value; attach$2(this, "progress"); }
943
947
  /** @internal */ toString() { return "[object FileReader]"; }
948
+ /** @internal */ get [Symbol.toStringTag]() { return "FileReader"; }
944
949
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["FileReader", "EventTarget"] }; }
945
950
  }
946
- const properties = {
947
- EMPTY: { value: 0, enumerable: true },
948
- LOADING: { value: 1, enumerable: true },
949
- DONE: { value: 2, enumerable: true },
950
- };
951
- Object.defineProperties(FileReaderP, properties);
952
- Object.defineProperties(FileReaderP.prototype, properties);
953
- Class_setStringTag(FileReaderP, "FileReader");
954
951
  /** @internal */
955
- const _handlers$3 = Symbol();
952
+ const _handlers$4 = Symbol();
956
953
  /** @internal */
957
954
  class FileReaderState {
958
955
  constructor(target) {
959
- this.readyState = FileReaderP.EMPTY;
956
+ this.readyState = 0 /* EMPTY */;
960
957
  this.result = null;
961
958
  this.error = null;
962
- this[_a$7] = getHandlers$3(this);
959
+ this[_a$8] = getHandlers$4(this);
963
960
  this.onabort = null;
964
961
  this.onerror = null;
965
962
  this.onload = null;
@@ -969,20 +966,20 @@ class FileReaderState {
969
966
  this.target = target;
970
967
  }
971
968
  }
972
- _a$7 = _handlers$3;
969
+ _a$8 = _handlers$4;
973
970
  function read$1(reader, kind, args, setResult) {
974
971
  const [blob] = args;
975
972
  checkArgsLength(args, 1, "FileReader", kind);
976
973
  if (!isPolyfillType("Blob", blob)) {
977
974
  throw new TypeError("Failed to execute '" + kind + "' on 'FileReader': parameter 1 is not of type 'Blob'.");
978
975
  }
979
- const s = reader[state$b];
976
+ const s = reader[state$e];
980
977
  s.error = null;
981
- s.readyState = FileReaderP.LOADING;
978
+ s.readyState = 1 /* LOADING */;
982
979
  emitProcessEvent(s.target, "loadstart", 0, blob.size);
983
980
  setTimeout(() => {
984
- if (s.readyState === FileReaderP.LOADING) {
985
- s.readyState = FileReaderP.DONE;
981
+ if (s.readyState === 1 /* LOADING */) {
982
+ s.readyState = 2 /* DONE */;
986
983
  try {
987
984
  setResult(blob);
988
985
  emitProcessEvent(s.target, "load", blob.size, blob.size);
@@ -996,14 +993,14 @@ function read$1(reader, kind, args, setResult) {
996
993
  emitProcessEvent(s.target, "loadend", !!s.result ? blob.size : 0, blob.size);
997
994
  });
998
995
  }
999
- function attach$1(reader, type) {
1000
- const s = reader[state$b];
996
+ function attach$2(reader, type) {
997
+ const s = reader[state$e];
1001
998
  const fnName = ("on" + type);
1002
999
  const cb = s[fnName];
1003
- const listener = s[_handlers$3][fnName];
1000
+ const listener = s[_handlers$4][fnName];
1004
1001
  attachFn(reader, type, cb, listener);
1005
1002
  }
1006
- function getHandlers$3(s) {
1003
+ function getHandlers$4(s) {
1007
1004
  return {
1008
1005
  onabort: (ev) => { executeFn(s.target, s.onabort, ev); },
1009
1006
  onerror: (ev) => { executeFn(s.target, s.onerror, ev); },
@@ -1015,14 +1012,14 @@ function getHandlers$3(s) {
1015
1012
  }
1016
1013
  const FileReaderE = g["Blob"] ? g["FileReader"] : FileReaderP;
1017
1014
 
1018
- var _a$6;
1019
- /** @internal */ const state$a = Symbol( /* "URLSearchParamsState" */);
1015
+ var _a$7;
1016
+ /** @internal */ const state$d = Symbol( /* "URLSearchParamsState" */);
1020
1017
  const checkArgsFn$2 = (args, required, funcName) => { checkArgsLength(args, required, "URLSearchParams", funcName); };
1021
1018
  class URLSearchParamsP {
1022
1019
  constructor(init) {
1023
- this[state$a] = new URLSearchParamsState();
1020
+ this[state$d] = new URLSearchParamsState();
1024
1021
  if (init !== undefined) {
1025
- if (isObjectType("URLSearchParams", init)) {
1022
+ if (isObjectType("URLSearchParams", init) || isPolyfillType("URLSearchParams", init)) {
1026
1023
  init.forEach((value, name) => { this.append(name, value); }, this);
1027
1024
  }
1028
1025
  else if (init && typeof init === "object") {
@@ -1068,18 +1065,18 @@ class URLSearchParamsP {
1068
1065
  }
1069
1066
  }
1070
1067
  }
1071
- get size() { return this[state$a][_urlspArray].length; }
1068
+ get size() { return this[state$d][_urlspArray].length; }
1072
1069
  append(...args) {
1073
1070
  const [name, value] = args;
1074
1071
  checkArgsFn$2(args, 2, "append");
1075
- this[state$a][_urlspArray].push(["" + name, normalizeValue$1(value)]);
1072
+ this[state$d][_urlspArray].push(["" + name, normalizeValue$1(value)]);
1076
1073
  }
1077
1074
  delete(...args) {
1078
1075
  const [name, value] = args;
1079
1076
  checkArgsFn$2(args, 1, "delete");
1080
1077
  let _name = "" + name;
1081
1078
  let index = -1;
1082
- let array = this[state$a][_urlspArray];
1079
+ let array = this[state$d][_urlspArray];
1083
1080
  let result = [];
1084
1081
  for (let i = 0; i < array.length; ++i) {
1085
1082
  let item = array[i];
@@ -1093,14 +1090,14 @@ class URLSearchParamsP {
1093
1090
  result.push(item);
1094
1091
  }
1095
1092
  if (index > -1) {
1096
- this[state$a][_urlspArray] = result;
1093
+ this[state$d][_urlspArray] = result;
1097
1094
  }
1098
1095
  }
1099
1096
  get(...args) {
1100
1097
  const [name] = args;
1101
1098
  checkArgsFn$2(args, 1, "get");
1102
1099
  let _name = "" + name;
1103
- let array = this[state$a][_urlspArray];
1100
+ let array = this[state$d][_urlspArray];
1104
1101
  for (let i = 0; i < array.length; ++i) {
1105
1102
  let item = array[i];
1106
1103
  if (item[0] === _name) {
@@ -1113,7 +1110,7 @@ class URLSearchParamsP {
1113
1110
  const [name] = args;
1114
1111
  checkArgsFn$2(args, 1, "getAll");
1115
1112
  let _name = "" + name;
1116
- let array = this[state$a][_urlspArray];
1113
+ let array = this[state$d][_urlspArray];
1117
1114
  let result = [];
1118
1115
  for (let i = 0; i < array.length; ++i) {
1119
1116
  let item = array[i];
@@ -1127,7 +1124,7 @@ class URLSearchParamsP {
1127
1124
  const [name, value] = args;
1128
1125
  checkArgsFn$2(args, 1, "has");
1129
1126
  let _name = "" + name;
1130
- let array = this[state$a][_urlspArray];
1127
+ let array = this[state$d][_urlspArray];
1131
1128
  for (let i = 0; i < array.length; ++i) {
1132
1129
  let item = array[i];
1133
1130
  if (item[0] === _name) {
@@ -1149,7 +1146,7 @@ class URLSearchParamsP {
1149
1146
  let _name = "" + name;
1150
1147
  let _value = normalizeValue$1(value);
1151
1148
  let index = -1;
1152
- let array = this[state$a][_urlspArray];
1149
+ let array = this[state$d][_urlspArray];
1153
1150
  let result = [];
1154
1151
  for (let i = 0; i < array.length; ++i) {
1155
1152
  let item = array[i];
@@ -1165,10 +1162,10 @@ class URLSearchParamsP {
1165
1162
  if (index === -1) {
1166
1163
  result.push([_name, _value]);
1167
1164
  }
1168
- this[state$a][_urlspArray] = result;
1165
+ this[state$d][_urlspArray] = result;
1169
1166
  }
1170
1167
  sort() {
1171
- this[state$a][_urlspArray].sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
1168
+ this[state$d][_urlspArray].sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
1172
1169
  }
1173
1170
  forEach(...args) {
1174
1171
  const [callbackfn, thisArg] = args;
@@ -1176,26 +1173,26 @@ class URLSearchParamsP {
1176
1173
  if (typeof callbackfn !== "function") {
1177
1174
  throw new TypeError("Failed to execute 'forEach' on 'URLSearchParams': parameter 1 is not of type 'Function'.");
1178
1175
  }
1179
- let array = this[state$a][_urlspArray];
1176
+ let array = this[state$d][_urlspArray];
1180
1177
  for (let i = 0; i < array.length; ++i) {
1181
1178
  let item = array[i];
1182
1179
  callbackfn.call(thisArg, item[1], item[0], this);
1183
1180
  }
1184
1181
  }
1185
1182
  entries() {
1186
- return this[state$a][_urlspArray].map(x => [x[0], x[1]]).values();
1183
+ return this[state$d][_urlspArray].map(x => [x[0], x[1]]).values();
1187
1184
  }
1188
1185
  keys() {
1189
- return this[state$a][_urlspArray].map(x => x[0]).values();
1186
+ return this[state$d][_urlspArray].map(x => x[0]).values();
1190
1187
  }
1191
1188
  values() {
1192
- return this[state$a][_urlspArray].map(x => x[1]).values();
1189
+ return this[state$d][_urlspArray].map(x => x[1]).values();
1193
1190
  }
1194
1191
  [Symbol.iterator]() {
1195
1192
  return this.entries();
1196
1193
  }
1197
1194
  toString() {
1198
- let array = this[state$a][_urlspArray];
1195
+ let array = this[state$d][_urlspArray];
1199
1196
  let result = [];
1200
1197
  for (let i = 0; i < array.length; ++i) {
1201
1198
  let item = array[i];
@@ -1203,19 +1200,18 @@ class URLSearchParamsP {
1203
1200
  }
1204
1201
  return result.join("&");
1205
1202
  }
1206
- /** @internal */
1207
- get isPolyfill() { return { symbol: polyfill, hierarchy: ["URLSearchParams"] }; }
1203
+ /** @internal */ get [Symbol.toStringTag]() { return "URLSearchParams"; }
1204
+ /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["URLSearchParams"] }; }
1208
1205
  }
1209
- Class_setStringTag(URLSearchParamsP, "URLSearchParams");
1210
1206
  /** @internal */
1211
1207
  const _urlspArray = Symbol();
1212
1208
  /** @internal */
1213
1209
  class URLSearchParamsState {
1214
1210
  constructor() {
1215
- this[_a$6] = [];
1211
+ this[_a$7] = [];
1216
1212
  }
1217
1213
  }
1218
- _a$6 = _urlspArray;
1214
+ _a$7 = _urlspArray;
1219
1215
  function normalizeValue$1(value) {
1220
1216
  return typeof value === "string" ? value : (value !== null && value !== undefined && typeof value.toString === "function"
1221
1217
  ? value.toString()
@@ -1240,8 +1236,8 @@ function decode(str) {
1240
1236
  }
1241
1237
  const URLSearchParamsE = g["URLSearchParams"] || URLSearchParamsP;
1242
1238
 
1243
- var _a$5;
1244
- /** @internal */ const state$9 = Symbol( /* "FormDataState" */);
1239
+ var _a$6;
1240
+ /** @internal */ const state$c = Symbol( /* "FormDataState" */);
1245
1241
  const checkArgsFn$1 = (args, required, funcName) => { checkArgsLength(args, required, "FormData", funcName); };
1246
1242
  class FormDataP {
1247
1243
  constructor(form, submitter) {
@@ -1255,19 +1251,19 @@ class FormDataP {
1255
1251
  console.error("TypeError: Failed to construct 'FormData': parameter 1 and parameter 2 not implemented.");
1256
1252
  }
1257
1253
  }
1258
- this[state$9] = new FormDataState();
1254
+ this[state$c] = new FormDataState();
1259
1255
  }
1260
1256
  append(...args) {
1261
1257
  const [name, value, filename] = args;
1262
1258
  checkArgsFn$1(args, 2, "append");
1263
- this[state$9][_formData].push(normalizeArgs(name, value, filename));
1259
+ this[state$c][_formData].push(normalizeArgs(name, value, filename));
1264
1260
  }
1265
1261
  delete(...args) {
1266
1262
  const [name] = args;
1267
1263
  checkArgsFn$1(args, 1, "delete");
1268
1264
  let _name = "" + name;
1269
1265
  let index = -1;
1270
- let array = this[state$9][_formData];
1266
+ let array = this[state$c][_formData];
1271
1267
  let result = [];
1272
1268
  for (let i = 0; i < array.length; ++i) {
1273
1269
  let item = array[i];
@@ -1278,14 +1274,14 @@ class FormDataP {
1278
1274
  result.push(item);
1279
1275
  }
1280
1276
  if (index > -1) {
1281
- this[state$9][_formData] = result;
1277
+ this[state$c][_formData] = result;
1282
1278
  }
1283
1279
  }
1284
1280
  get(...args) {
1285
1281
  const [name] = args;
1286
1282
  checkArgsFn$1(args, 1, "get");
1287
1283
  let _name = "" + name;
1288
- let array = this[state$9][_formData];
1284
+ let array = this[state$c][_formData];
1289
1285
  for (let i = 0; i < array.length; ++i) {
1290
1286
  let item = array[i];
1291
1287
  if (item[0] === _name) {
@@ -1298,7 +1294,7 @@ class FormDataP {
1298
1294
  const [name] = args;
1299
1295
  checkArgsFn$1(args, 1, "getAll");
1300
1296
  let _name = "" + name;
1301
- let array = this[state$9][_formData];
1297
+ let array = this[state$c][_formData];
1302
1298
  let result = [];
1303
1299
  for (let i = 0; i < array.length; ++i) {
1304
1300
  let item = array[i];
@@ -1312,7 +1308,7 @@ class FormDataP {
1312
1308
  const [name] = args;
1313
1309
  checkArgsFn$1(args, 1, "has");
1314
1310
  let _name = "" + name;
1315
- let array = this[state$9][_formData];
1311
+ let array = this[state$c][_formData];
1316
1312
  for (let i = 0; i < array.length; ++i) {
1317
1313
  let item = array[i];
1318
1314
  if (item[0] === _name) {
@@ -1327,7 +1323,7 @@ class FormDataP {
1327
1323
  let _name = "" + name;
1328
1324
  let _args = normalizeArgs(name, value, filename);
1329
1325
  let index = -1;
1330
- let array = this[state$9][_formData];
1326
+ let array = this[state$c][_formData];
1331
1327
  let result = [];
1332
1328
  for (let i = 0; i < array.length; ++i) {
1333
1329
  let item = array[i];
@@ -1343,7 +1339,7 @@ class FormDataP {
1343
1339
  if (index === -1) {
1344
1340
  result.push(_args);
1345
1341
  }
1346
- this[state$9][_formData] = result;
1342
+ this[state$c][_formData] = result;
1347
1343
  }
1348
1344
  forEach(...args) {
1349
1345
  const [callbackfn, thisArg] = args;
@@ -1351,44 +1347,44 @@ class FormDataP {
1351
1347
  if (typeof callbackfn !== "function") {
1352
1348
  throw new TypeError("Failed to execute 'forEach' on 'FormData': parameter 1 is not of type 'Function'.");
1353
1349
  }
1354
- let array = this[state$9][_formData];
1350
+ let array = this[state$c][_formData];
1355
1351
  for (let i = 0; i < array.length; ++i) {
1356
1352
  let item = array[i];
1357
1353
  callbackfn.call(thisArg, item[1], item[0], thisArg);
1358
1354
  }
1359
1355
  }
1360
1356
  entries() {
1361
- return this[state$9][_formData].map(x => [x[0], x[1]]).values();
1357
+ return this[state$c][_formData].map(x => [x[0], x[1]]).values();
1362
1358
  }
1363
1359
  keys() {
1364
- return this[state$9][_formData].map(x => x[0]).values();
1360
+ return this[state$c][_formData].map(x => x[0]).values();
1365
1361
  }
1366
1362
  values() {
1367
- return this[state$9][_formData].map(x => x[1]).values();
1363
+ return this[state$c][_formData].map(x => x[1]).values();
1368
1364
  }
1369
1365
  [Symbol.iterator]() {
1370
1366
  return this.entries();
1371
1367
  }
1372
1368
  /** @internal */ toString() { return "[object FormData]"; }
1369
+ /** @internal */ get [Symbol.toStringTag]() { return "FormData"; }
1373
1370
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["FormData"] }; }
1374
1371
  }
1375
- Class_setStringTag(FormDataP, "FormData");
1376
1372
  /** @internal */
1377
1373
  const _formData = Symbol();
1378
1374
  /** @internal */
1379
1375
  class FormDataState {
1380
1376
  constructor() {
1381
- this[_a$5] = [];
1377
+ this[_a$6] = [];
1382
1378
  }
1383
1379
  }
1384
- _a$5 = _formData;
1380
+ _a$6 = _formData;
1385
1381
  /** @internal */
1386
1382
  function FormData_toBlob(formData) {
1387
1383
  const boundary = "----formdata-mphttpx-" + Math.random();
1388
1384
  const p = `--${boundary}\r\nContent-Disposition: form-data; name="`;
1389
1385
  let chunks = [];
1390
- for (let i = 0; i < formData[state$9][_formData].length; ++i) {
1391
- let pair = formData[state$9][_formData][i];
1386
+ for (let i = 0; i < formData[state$c][_formData].length; ++i) {
1387
+ let pair = formData[state$c][_formData][i];
1392
1388
  let name = pair[0];
1393
1389
  let value = pair[1];
1394
1390
  if (typeof value === "string") {
@@ -1408,7 +1404,7 @@ function normalizeArgs(name, value, filename) {
1408
1404
  : typeof value.name === "string"
1409
1405
  ? value.name
1410
1406
  : "blob";
1411
- if (value.name !== filename || isObjectType("Blob", value)) {
1407
+ if (value.name !== filename || isObjectType("Blob", value) || isPolyfillType("Blob", value, true)) {
1412
1408
  value = new FileP([value], filename);
1413
1409
  }
1414
1410
  return ["" + name, value];
@@ -1478,15 +1474,15 @@ function createFormDataFromBinaryText(text, boundary) {
1478
1474
  }
1479
1475
  const FormDataE = g["FormData"] || FormDataP;
1480
1476
 
1481
- var _a$4, _b$1;
1482
- /** @internal */ const state$8 = Symbol( /* "HeadersState" */);
1477
+ var _a$5, _b$2;
1478
+ /** @internal */ const state$b = Symbol( /* "HeadersState" */);
1483
1479
  const checkArgsFn = (args, required, funcName) => { checkArgsLength(args, required, "Headers", funcName); };
1484
1480
  class HeadersP {
1485
1481
  constructor(init) {
1486
- this[state$8] = new HeadersState();
1482
+ this[state$b] = new HeadersState();
1487
1483
  if (init !== undefined) {
1488
- if (isObjectType("Headers", init)) {
1489
- init.forEach((value, name) => { this.append(name, value); }, this);
1484
+ if (isObjectType("Headers", init) || isPolyfillType("Headers", init)) {
1485
+ init.forEach((value, name) => { Headers_append(this, name, value); }, this);
1490
1486
  }
1491
1487
  else if (Array.isArray(init) || (init && typeof init === "object" && Symbol.iterator in init)) {
1492
1488
  let _init = Array.isArray(init) ? init : Array.from(init);
@@ -1514,58 +1510,27 @@ class HeadersP {
1514
1510
  }
1515
1511
  }
1516
1512
  }
1517
- this[state$8][_initialized] = true;
1513
+ this[state$b][_initialized] = true;
1518
1514
  }
1519
1515
  append(...args) {
1520
1516
  const [name, value] = args;
1521
1517
  checkArgsFn(args, 2, "append");
1522
- let _name = normalizeName(name, throwsFn(this[state$8][_initialized] ? "append" : ""));
1518
+ let _name = normalizeName(name, throwsFn(this[state$b][_initialized] ? "append" : ""));
1523
1519
  let _value = normalizeValue(value);
1524
- let index = -1;
1525
- let array = this[state$8][_headersArray];
1526
- for (let i = 0; i < array.length; ++i) {
1527
- let item = array[i];
1528
- if (item[0] === _name) {
1529
- item[1] = `${item[1]}, ${_value}`;
1530
- index = i;
1531
- break;
1532
- }
1533
- }
1534
- if (index === -1) {
1535
- array.push([_name, _value]);
1536
- }
1520
+ Headers_append(this, _name, _value);
1537
1521
  }
1538
1522
  delete(...args) {
1539
1523
  const [name] = args;
1540
1524
  checkArgsFn(args, 1, "delete");
1541
1525
  let _name = normalizeName(name, throwsFn("delete"));
1542
- let index = -1;
1543
- let array = this[state$8][_headersArray];
1544
- let result = [];
1545
- for (let i = 0; i < array.length; ++i) {
1546
- let item = array[i];
1547
- if (item[0] === _name) {
1548
- index = i;
1549
- continue;
1550
- }
1551
- result.push(item);
1552
- }
1553
- if (index > -1) {
1554
- this[state$8][_headersArray] = result;
1555
- }
1526
+ delete this[state$b][_headersDict][_name];
1556
1527
  }
1557
1528
  get(...args) {
1529
+ var _c;
1558
1530
  const [name] = args;
1559
1531
  checkArgsFn(args, 1, "get");
1560
1532
  let _name = normalizeName(name, throwsFn("get"));
1561
- let array = this[state$8][_headersArray];
1562
- for (let i = 0; i < array.length; ++i) {
1563
- let item = array[i];
1564
- if (item[0] === _name) {
1565
- return item[1];
1566
- }
1567
- }
1568
- return null;
1533
+ return (_c = this[state$b][_headersDict][_name]) !== null && _c !== void 0 ? _c : null;
1569
1534
  }
1570
1535
  getSetCookie() {
1571
1536
  let value = this.get("Set-Cookie");
@@ -1575,33 +1540,14 @@ class HeadersP {
1575
1540
  const [name] = args;
1576
1541
  checkArgsFn(args, 1, "has");
1577
1542
  let _name = normalizeName(name, throwsFn("has"));
1578
- let array = this[state$8][_headersArray];
1579
- for (let i = 0; i < array.length; ++i) {
1580
- let item = array[i];
1581
- if (item[0] === _name) {
1582
- return true;
1583
- }
1584
- }
1585
- return false;
1543
+ return this[state$b][_headersDict].hasOwnProperty(_name);
1586
1544
  }
1587
1545
  set(...args) {
1588
1546
  const [name, value] = args;
1589
1547
  checkArgsFn(args, 2, "set");
1590
1548
  let _name = normalizeName(name, throwsFn("set"));
1591
1549
  let _value = normalizeValue(value);
1592
- let index = -1;
1593
- let array = this[state$8][_headersArray];
1594
- for (let i = 0; i < array.length; ++i) {
1595
- let item = array[i];
1596
- if (item[0] === _name) {
1597
- item[1] = _value;
1598
- index = i;
1599
- break;
1600
- }
1601
- }
1602
- if (index === -1) {
1603
- array.push([_name, _value]);
1604
- }
1550
+ this[state$b][_headersDict][_name] = _value;
1605
1551
  }
1606
1552
  forEach(...args) {
1607
1553
  const [callbackfn, thisArg] = args;
@@ -1609,38 +1555,49 @@ class HeadersP {
1609
1555
  if (typeof callbackfn !== "function") {
1610
1556
  throw new TypeError("Failed to execute 'forEach' on 'Headers': parameter 1 is not of type 'Function'.");
1611
1557
  }
1612
- let array = this[state$8][_headersArray];
1613
- for (let i = 0; i < array.length; ++i) {
1614
- let item = array[i];
1615
- callbackfn.call(thisArg, item[1], item[0], this);
1558
+ let names = Object.getOwnPropertyNames(this[state$b][_headersDict]);
1559
+ for (let i = 0; i < names.length; ++i) {
1560
+ let name = names[i];
1561
+ callbackfn.call(thisArg, this[state$b][_headersDict][name], name, this);
1616
1562
  }
1617
1563
  }
1618
1564
  entries() {
1619
- return this[state$8][_headersArray].map(x => [x[0], x[1]]).values();
1565
+ let array = [];
1566
+ this.forEach((value, name) => { array.push([name, value]); });
1567
+ return array.values();
1620
1568
  }
1621
1569
  keys() {
1622
- return this[state$8][_headersArray].map(x => x[0]).values();
1570
+ let array = [];
1571
+ this.forEach((value, name) => { array.push(name); });
1572
+ return array.values();
1623
1573
  }
1624
1574
  values() {
1625
- return this[state$8][_headersArray].map(x => x[1]).values();
1575
+ let array = [];
1576
+ this.forEach((value, name) => { array.push(value); });
1577
+ return array.values();
1626
1578
  }
1627
1579
  [Symbol.iterator]() {
1628
1580
  return this.entries();
1629
1581
  }
1630
1582
  /** @internal */ toString() { return "[object Headers]"; }
1583
+ /** @internal */ get [Symbol.toStringTag]() { return "Headers"; }
1631
1584
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Headers"] }; }
1632
1585
  }
1633
- Class_setStringTag(HeadersP, "Headers");
1634
1586
  /** @internal */ const _initialized = Symbol();
1635
- /** @internal */ const _headersArray = Symbol();
1587
+ /** @internal */ const _headersDict = Symbol();
1636
1588
  /** @internal */
1637
1589
  class HeadersState {
1638
1590
  constructor() {
1639
- this[_a$4] = false;
1640
- this[_b$1] = [];
1591
+ this[_a$5] = false;
1592
+ this[_b$2] = {};
1641
1593
  }
1642
1594
  }
1643
- _a$4 = _initialized, _b$1 = _headersArray;
1595
+ _a$5 = _initialized, _b$2 = _headersDict;
1596
+ function Headers_append(headers, name, value) {
1597
+ let dict = headers[state$b][_headersDict];
1598
+ let oldValue = dict[name];
1599
+ dict[name] = oldValue !== undefined ? `${oldValue}, ${value}` : value;
1600
+ }
1644
1601
  function throwsFn(kind) {
1645
1602
  return () => {
1646
1603
  throw new TypeError(`Failed to ${kind ? ("execute '" + kind + "' on") : "construct"} 'Headers': Invalid name`);
@@ -1684,23 +1641,23 @@ function parseHeaders(rawHeaders) {
1684
1641
  }
1685
1642
  const HeadersE = g["Headers"] || HeadersP;
1686
1643
 
1687
- var _a$3;
1688
- /** @internal */ const state$7 = Symbol( /* "BodyState" */);
1644
+ var _a$4;
1645
+ /** @internal */ const state$a = Symbol( /* "BodyState" */);
1689
1646
  class BodyImpl {
1690
1647
  /** @internal */
1691
1648
  constructor() {
1692
1649
  if (new.target === BodyImpl) {
1693
1650
  throw new TypeError("Failed to construct 'Body': Illegal constructor");
1694
1651
  }
1695
- this[state$7] = new BodyState();
1652
+ this[state$a] = new BodyState();
1696
1653
  }
1697
1654
  get body() {
1698
- if (!this[state$7][_body]) {
1655
+ if (!this[state$a][_body]) {
1699
1656
  return null;
1700
1657
  }
1701
- throw new TypeError(`Failed to access 'body' on '${this[state$7].name}': property not implemented.`);
1658
+ throw new TypeError(`Failed to access 'body' on '${this[state$a].name}': property not implemented.`);
1702
1659
  }
1703
- get bodyUsed() { return this[state$7].bodyUsed; }
1660
+ get bodyUsed() { return this[state$a].bodyUsed; }
1704
1661
  ;
1705
1662
  arrayBuffer() {
1706
1663
  const kind = "arrayBuffer";
@@ -1727,9 +1684,9 @@ class BodyImpl {
1727
1684
  return consumed(this, kind) || read(this, kind);
1728
1685
  }
1729
1686
  /** @internal */ toString() { return "[object Body]"; }
1687
+ /** @internal */ get [Symbol.toStringTag]() { return "Body"; }
1730
1688
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Body"] }; }
1731
1689
  }
1732
- Class_setStringTag(BodyImpl, "Body");
1733
1690
  /** @internal */
1734
1691
  const _body = Symbol();
1735
1692
  /** @internal */
@@ -1737,23 +1694,23 @@ class BodyState {
1737
1694
  constructor() {
1738
1695
  this.name = "Body";
1739
1696
  this.bodyUsed = false;
1740
- this[_a$3] = "";
1697
+ this[_a$4] = "";
1741
1698
  }
1742
1699
  }
1743
- _a$3 = _body;
1700
+ _a$4 = _body;
1744
1701
  /** @internal */
1745
1702
  function Body_init(body, payload) {
1746
1703
  const b = body;
1747
1704
  if (isObjectType("ReadableStream", payload)) {
1748
- throw new TypeError(`Failed to construct '${b[state$7].name}': ReadableStream not implemented.`);
1705
+ throw new TypeError(`Failed to construct '${b[state$a].name}': ReadableStream not implemented.`);
1749
1706
  }
1750
- b[state$7][_body] = convert(payload, true, type => { if (!b.headers.has("Content-Type")) {
1707
+ b[state$a][_body] = convert(payload, true, type => { if (!b.headers.has("Content-Type")) {
1751
1708
  b.headers.set("Content-Type", type);
1752
1709
  } });
1753
1710
  }
1754
1711
  /** @internal */
1755
1712
  function Body_toPayload(body) {
1756
- return body[state$7][_body];
1713
+ return body[state$a][_body];
1757
1714
  }
1758
1715
  function read(body, kind) {
1759
1716
  return new Promise((resolve, reject) => {
@@ -1766,7 +1723,7 @@ function read(body, kind) {
1766
1723
  });
1767
1724
  }
1768
1725
  function readSync(body, kind) {
1769
- const payload = body[state$7][_body];
1726
+ const payload = body[state$a][_body];
1770
1727
  if (kind === "arrayBuffer") {
1771
1728
  return convertBack("arraybuffer", payload);
1772
1729
  }
@@ -1803,7 +1760,7 @@ function readSync(body, kind) {
1803
1760
  }
1804
1761
  }
1805
1762
  function consumed(body, kind) {
1806
- const s = body[state$7];
1763
+ const s = body[state$a];
1807
1764
  if (!s[_body])
1808
1765
  return;
1809
1766
  if (s.bodyUsed) {
@@ -1820,13 +1777,13 @@ function convert(body, cloneArrayBuffer = true, setContentType, setContentLength
1820
1777
  setContentType("text/plain;charset=UTF-8");
1821
1778
  }
1822
1779
  }
1823
- else if (isObjectType("URLSearchParams", body)) {
1780
+ else if (isObjectType("URLSearchParams", body) || isPolyfillType("URLSearchParams", body)) {
1824
1781
  result = body.toString();
1825
1782
  if (setContentType) {
1826
1783
  setContentType("application/x-www-form-urlencoded;charset=UTF-8");
1827
1784
  }
1828
1785
  }
1829
- else if (body instanceof ArrayBuffer) {
1786
+ else if (isArrayBuffer(body)) {
1830
1787
  result = cloneArrayBuffer ? body.slice(0) : body;
1831
1788
  }
1832
1789
  else if (ArrayBuffer.isView(body)) {
@@ -1865,7 +1822,7 @@ function convert(body, cloneArrayBuffer = true, setContentType, setContentLength
1865
1822
  }
1866
1823
  /** @internal */
1867
1824
  function convertBack(type, data) {
1868
- let temp = !!data ? (typeof data !== "string" && !(data instanceof ArrayBuffer) ? JSON.stringify(data) : data) : "";
1825
+ let temp = !!data ? (typeof data !== "string" && !isArrayBuffer(data) ? JSON.stringify(data) : data) : "";
1869
1826
  if (!type || type === "text") {
1870
1827
  return typeof temp === "string" ? temp : decode$1(temp);
1871
1828
  }
@@ -1873,7 +1830,7 @@ function convertBack(type, data) {
1873
1830
  return JSON.parse(typeof temp === "string" ? temp : decode$1(temp));
1874
1831
  }
1875
1832
  else if (type === "arraybuffer") {
1876
- return temp instanceof ArrayBuffer ? temp.slice(0) : encode$1(temp).buffer;
1833
+ return isArrayBuffer(temp) ? temp.slice(0) : encode$1(temp).buffer;
1877
1834
  }
1878
1835
  else if (type === "blob") {
1879
1836
  return new BlobP([temp]);
@@ -1883,9 +1840,9 @@ function convertBack(type, data) {
1883
1840
  }
1884
1841
  }
1885
1842
 
1886
- var _a$2;
1843
+ var _a$3;
1887
1844
  /** @internal */
1888
- const state$6 = Symbol( /* "AbortSignalState" */);
1845
+ const state$9 = Symbol( /* "AbortSignalState" */);
1889
1846
  class AbortSignalP extends EventTargetP {
1890
1847
  static abort(reason) {
1891
1848
  let signal = createAbortSignal();
@@ -1942,40 +1899,40 @@ class AbortSignalP extends EventTargetP {
1942
1899
  throw new TypeError("Failed to construct 'AbortSignal': Illegal constructor");
1943
1900
  }
1944
1901
  super();
1945
- this[state$6] = new AbortSignalState(this);
1902
+ this[state$9] = new AbortSignalState(this);
1946
1903
  }
1947
- get aborted() { return this[state$6].aborted; }
1948
- get reason() { return this[state$6].reason; }
1904
+ get aborted() { return this[state$9].aborted; }
1905
+ get reason() { return this[state$9].reason; }
1949
1906
  throwIfAborted() {
1950
1907
  if (this.aborted) {
1951
1908
  throw this.reason;
1952
1909
  }
1953
1910
  }
1954
- get onabort() { return this[state$6].onabort; }
1911
+ get onabort() { return this[state$9].onabort; }
1955
1912
  set onabort(value) {
1956
- this[state$6].onabort = value;
1957
- attachFn(this, "abort", value, this[state$6][_handlers$2].onabort);
1913
+ this[state$9].onabort = value;
1914
+ attachFn(this, "abort", value, this[state$9][_handlers$3].onabort);
1958
1915
  }
1959
1916
  /** @internal */ toString() { return "[object AbortSignal]"; }
1917
+ /** @internal */ get [Symbol.toStringTag]() { return "AbortSignal"; }
1960
1918
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortSignal", "EventTarget"] }; }
1961
1919
  }
1962
- Class_setStringTag(AbortSignalP, "AbortSignal");
1963
1920
  /** @internal */
1964
- const _handlers$2 = Symbol();
1921
+ const _handlers$3 = Symbol();
1965
1922
  /** @internal */
1966
1923
  class AbortSignalState {
1967
1924
  constructor(target) {
1968
1925
  this.aborted = false;
1969
1926
  this.reason = undefined;
1970
- this[_a$2] = getHandlers$2(this);
1927
+ this[_a$3] = getHandlers$3(this);
1971
1928
  this.onabort = null;
1972
1929
  this.target = target;
1973
1930
  }
1974
1931
  }
1975
- _a$2 = _handlers$2;
1932
+ _a$3 = _handlers$3;
1976
1933
  /** @internal */
1977
1934
  function AbortSignal_abort(signal, reason, notify = true, isTrusted = true) {
1978
- const s = signal[state$6];
1935
+ const s = signal[state$9];
1979
1936
  if (!s.aborted) {
1980
1937
  s.aborted = true;
1981
1938
  s.reason = reason !== null && reason !== void 0 ? reason : (new MPException("signal is aborted without reason", "AbortError"));
@@ -1985,7 +1942,7 @@ function AbortSignal_abort(signal, reason, notify = true, isTrusted = true) {
1985
1942
  }
1986
1943
  }
1987
1944
  }
1988
- function getHandlers$2(s) {
1945
+ function getHandlers$3(s) {
1989
1946
  return {
1990
1947
  onabort: (ev) => { executeFn(s.target, s.onabort, ev); },
1991
1948
  };
@@ -1993,26 +1950,26 @@ function getHandlers$2(s) {
1993
1950
  /** @internal */
1994
1951
  function createAbortSignal() {
1995
1952
  let signal = Object.create(AbortSignalP.prototype);
1996
- signal[state$d] = new EventTargetState(signal);
1997
- signal[state$6] = new AbortSignalState(signal);
1953
+ signal[state$g] = new EventTargetState(signal);
1954
+ signal[state$9] = new AbortSignalState(signal);
1998
1955
  return signal;
1999
1956
  }
2000
1957
  const AbortSignalE = g["AbortSignal"] || AbortSignalP;
2001
1958
 
2002
1959
  /** @internal */
2003
- const state$5 = Symbol( /* "AbortControllerState" */);
1960
+ const state$8 = Symbol( /* "AbortControllerState" */);
2004
1961
  class AbortControllerP {
2005
1962
  constructor() {
2006
- this[state$5] = new AbortControllerState();
1963
+ this[state$8] = new AbortControllerState();
2007
1964
  }
2008
- get signal() { return this[state$5].signal; }
1965
+ get signal() { return this[state$8].signal; }
2009
1966
  abort(reason) {
2010
- AbortSignal_abort(this[state$5].signal, reason);
1967
+ AbortSignal_abort(this[state$8].signal, reason);
2011
1968
  }
2012
1969
  /** @internal */ toString() { return "[object AbortController]"; }
1970
+ /** @internal */ get [Symbol.toStringTag]() { return "AbortController"; }
2013
1971
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortController"] }; }
2014
1972
  }
2015
- Class_setStringTag(AbortControllerP, "AbortController");
2016
1973
  /** @internal */
2017
1974
  class AbortControllerState {
2018
1975
  constructor() {
@@ -2021,15 +1978,15 @@ class AbortControllerState {
2021
1978
  }
2022
1979
  const AbortControllerE = g["AbortController"] || AbortControllerP;
2023
1980
 
2024
- /** @internal */ const state$4 = Symbol( /* "RequestState" */);
1981
+ /** @internal */ const state$7 = Symbol( /* "RequestState" */);
2025
1982
  class RequestP extends BodyImpl {
2026
1983
  constructor(...args) {
2027
1984
  const [input, init] = args;
2028
1985
  checkArgsLength(args, 1, "Request");
2029
1986
  super();
2030
- this[state$7].name = "Request";
2031
- this[state$4] = new RequestState();
2032
- const s = this[state$4];
1987
+ this[state$a].name = "Request";
1988
+ this[state$7] = new RequestState();
1989
+ const s = this[state$7];
2033
1990
  let _init = init !== null && init !== void 0 ? init : {};
2034
1991
  if (typeof _init !== "object") {
2035
1992
  throw new TypeError("Failed to construct 'Request': The provided value is not of type 'RequestInit'.");
@@ -2046,7 +2003,7 @@ class RequestP extends BodyImpl {
2046
2003
  }
2047
2004
  s.method = input.method;
2048
2005
  s.mode = input.mode;
2049
- let inputSignal = input[state$4].signal;
2006
+ let inputSignal = input[state$7].signal;
2050
2007
  if (inputSignal) {
2051
2008
  s.signal = inputSignal;
2052
2009
  }
@@ -2054,7 +2011,7 @@ class RequestP extends BodyImpl {
2054
2011
  let payload = Body_toPayload(input);
2055
2012
  if (!body && payload !== "") {
2056
2013
  body = payload;
2057
- input[state$7].bodyUsed = true;
2014
+ input[state$a].bodyUsed = true;
2058
2015
  }
2059
2016
  }
2060
2017
  else {
@@ -2098,31 +2055,31 @@ class RequestP extends BodyImpl {
2098
2055
  }
2099
2056
  }
2100
2057
  }
2101
- get cache() { return this[state$4].cache; }
2102
- get credentials() { return this[state$4].credentials; }
2103
- get destination() { return this[state$4].destination; }
2058
+ get cache() { return this[state$7].cache; }
2059
+ get credentials() { return this[state$7].credentials; }
2060
+ get destination() { return this[state$7].destination; }
2104
2061
  get headers() {
2105
- const s = this[state$4];
2062
+ const s = this[state$7];
2106
2063
  if (!s.headers) {
2107
2064
  s.headers = new HeadersP();
2108
2065
  }
2109
2066
  return s.headers;
2110
2067
  }
2111
- get integrity() { return this[state$4].integrity; }
2112
- get keepalive() { return this[state$4].keepalive; }
2113
- get method() { return this[state$4].method; }
2114
- get mode() { return this[state$4].mode; }
2115
- get redirect() { return this[state$4].redirect; }
2116
- get referrer() { return this[state$4].referrer; }
2117
- get referrerPolicy() { return this[state$4].referrerPolicy; }
2068
+ get integrity() { return this[state$7].integrity; }
2069
+ get keepalive() { return this[state$7].keepalive; }
2070
+ get method() { return this[state$7].method; }
2071
+ get mode() { return this[state$7].mode; }
2072
+ get redirect() { return this[state$7].redirect; }
2073
+ get referrer() { return this[state$7].referrer; }
2074
+ get referrerPolicy() { return this[state$7].referrerPolicy; }
2118
2075
  get signal() {
2119
- const s = this[state$4];
2076
+ const s = this[state$7];
2120
2077
  if (!s.signal) {
2121
2078
  s.signal = (new AbortControllerP()).signal;
2122
2079
  }
2123
2080
  return s.signal;
2124
2081
  }
2125
- get url() { return this[state$4].url; }
2082
+ get url() { return this[state$7].url; }
2126
2083
  clone() {
2127
2084
  var _a;
2128
2085
  if (this.bodyUsed) {
@@ -2131,9 +2088,9 @@ class RequestP extends BodyImpl {
2131
2088
  return new RequestP(this, { body: (_a = Body_toPayload(this)) !== null && _a !== void 0 ? _a : null });
2132
2089
  }
2133
2090
  /** @internal */ toString() { return "[object Request]"; }
2091
+ /** @internal */ get [Symbol.toStringTag]() { return "Request"; }
2134
2092
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Request"] }; }
2135
2093
  }
2136
- Class_setStringTag(RequestP, "Request");
2137
2094
  /** @internal */
2138
2095
  class RequestState {
2139
2096
  constructor() {
@@ -2160,8 +2117,7 @@ function normalizeMethod(method) {
2160
2117
  const RequestE = g["Request"] || RequestP;
2161
2118
 
2162
2119
  // @ts-nocheck
2163
- /** @internal */
2164
- const mp$2 = (() => {
2120
+ function getPlatform() {
2165
2121
  let u = "undefined", r = "request", f = "function";
2166
2122
  let mp;
2167
2123
  mp =
@@ -2184,9 +2140,11 @@ const mp$2 = (() => {
2184
2140
  (typeof Taro !== u && typeof (Taro === null || Taro === void 0 ? void 0 : Taro[r]) === f && Taro) || // Taro
2185
2141
  undefined;
2186
2142
  return mp;
2187
- })();
2143
+ }
2144
+ /** @internal */
2145
+ const mp$3 = getPlatform();
2188
2146
 
2189
- const request = mp$2 ? mp$2.request : function errorRequest(options) {
2147
+ const request = mp$3 ? mp$3.request : function errorRequest(options) {
2190
2148
  const errMsg = "NOT_SUPPORTED_ERR";
2191
2149
  const errno = 9;
2192
2150
  const err = {
@@ -2213,8 +2171,8 @@ const request = mp$2 ? mp$2.request : function errorRequest(options) {
2213
2171
  throw new ReferenceError("request is not defined");
2214
2172
  };
2215
2173
 
2216
- var _a$1;
2217
- /** @internal */ const state$3 = Symbol( /* "XMLHttpRequestEventTargetState" */);
2174
+ var _a$2;
2175
+ /** @internal */ const state$6 = Symbol( /* "XMLHttpRequestEventTargetState" */);
2218
2176
  class XMLHttpRequestEventTargetP extends EventTargetP {
2219
2177
  /** @internal */
2220
2178
  constructor() {
@@ -2222,35 +2180,35 @@ class XMLHttpRequestEventTargetP extends EventTargetP {
2222
2180
  throw new TypeError("Failed to construct 'XMLHttpRequestEventTarget': Illegal constructor");
2223
2181
  }
2224
2182
  super();
2225
- this[state$3] = new XMLHttpRequestEventTargetState(this);
2226
- }
2227
- get onabort() { return this[state$3].onabort; }
2228
- set onabort(value) { this[state$3].onabort = value; attach(this, "abort"); }
2229
- get onerror() { return this[state$3].onerror; }
2230
- set onerror(value) { this[state$3].onerror = value; attach(this, "error"); }
2231
- get onload() { return this[state$3].onload; }
2232
- set onload(value) { this[state$3].onload = value; attach(this, "load"); }
2233
- get onloadend() { return this[state$3].onloadend; }
2234
- set onloadend(value) { this[state$3].onloadend = value; attach(this, "loadend"); }
2235
- get onloadstart() { return this[state$3].onloadstart; }
2236
- set onloadstart(value) { this[state$3].onloadstart = value; attach(this, "loadstart"); }
2237
- get onprogress() { return this[state$3].onprogress; }
2238
- set onprogress(value) { this[state$3].onprogress = value; attach(this, "progress"); }
2239
- get ontimeout() { return this[state$3].ontimeout; }
2240
- set ontimeout(value) { this[state$3].ontimeout = value; attach(this, "timeout"); }
2183
+ this[state$6] = new XMLHttpRequestEventTargetState(this);
2184
+ }
2185
+ get onabort() { return this[state$6].onabort; }
2186
+ set onabort(value) { this[state$6].onabort = value; attach$1(this, "abort"); }
2187
+ get onerror() { return this[state$6].onerror; }
2188
+ set onerror(value) { this[state$6].onerror = value; attach$1(this, "error"); }
2189
+ get onload() { return this[state$6].onload; }
2190
+ set onload(value) { this[state$6].onload = value; attach$1(this, "load"); }
2191
+ get onloadend() { return this[state$6].onloadend; }
2192
+ set onloadend(value) { this[state$6].onloadend = value; attach$1(this, "loadend"); }
2193
+ get onloadstart() { return this[state$6].onloadstart; }
2194
+ set onloadstart(value) { this[state$6].onloadstart = value; attach$1(this, "loadstart"); }
2195
+ get onprogress() { return this[state$6].onprogress; }
2196
+ set onprogress(value) { this[state$6].onprogress = value; attach$1(this, "progress"); }
2197
+ get ontimeout() { return this[state$6].ontimeout; }
2198
+ set ontimeout(value) { this[state$6].ontimeout = value; attach$1(this, "timeout"); }
2241
2199
  /** @internal */ toString() { return "[object XMLHttpRequestEventTarget]"; }
2200
+ /** @internal */ get [Symbol.toStringTag]() { return "XMLHttpRequestEventTarget"; }
2242
2201
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestEventTarget", "EventTarget"] }; }
2243
2202
  }
2244
- Class_setStringTag(XMLHttpRequestEventTargetP, "XMLHttpRequestEventTarget");
2245
2203
  /** @internal */
2246
- const _handlers$1 = Symbol();
2204
+ const _handlers$2 = Symbol();
2247
2205
  /** @internal */
2248
2206
  class XMLHttpRequestEventTargetState {
2249
2207
  /**
2250
2208
  * @param _target XMLHttpRequestEventTarget
2251
2209
  */
2252
2210
  constructor(_target) {
2253
- this[_a$1] = getHandlers$1(this);
2211
+ this[_a$2] = getHandlers$2(this);
2254
2212
  this.onabort = null;
2255
2213
  this.onerror = null;
2256
2214
  this.onload = null;
@@ -2261,15 +2219,15 @@ class XMLHttpRequestEventTargetState {
2261
2219
  this.target = _target;
2262
2220
  }
2263
2221
  }
2264
- _a$1 = _handlers$1;
2265
- function attach(target, type) {
2266
- const s = target[state$3];
2222
+ _a$2 = _handlers$2;
2223
+ function attach$1(target, type) {
2224
+ const s = target[state$6];
2267
2225
  const fnName = ("on" + type);
2268
2226
  const cb = s[fnName];
2269
- const listener = s[_handlers$1][fnName];
2227
+ const listener = s[_handlers$2][fnName];
2270
2228
  attachFn(target, type, cb, listener);
2271
2229
  }
2272
- function getHandlers$1(s) {
2230
+ function getHandlers$2(s) {
2273
2231
  return {
2274
2232
  onabort: (ev) => { executeFn(s.target, s.onabort, ev); },
2275
2233
  onerror: (ev) => { executeFn(s.target, s.onerror, ev); },
@@ -2280,14 +2238,6 @@ function getHandlers$1(s) {
2280
2238
  ontimeout: (ev) => { executeFn(s.target, s.ontimeout, ev); },
2281
2239
  };
2282
2240
  }
2283
- /** @internal */
2284
- const XHR_properties = {
2285
- UNSENT: { value: 0, enumerable: true },
2286
- OPENED: { value: 1, enumerable: true },
2287
- HEADERS_RECEIVED: { value: 2, enumerable: true },
2288
- LOADING: { value: 3, enumerable: true },
2289
- DONE: { value: 4, enumerable: true },
2290
- };
2291
2241
  const responseTypes = ["", "text", "json", "arraybuffer", "blob", "document"];
2292
2242
  /** @internal */
2293
2243
  function normalizeResponseType(responseType) {
@@ -2370,56 +2320,65 @@ class XMLHttpRequestUploadP extends XMLHttpRequestEventTargetP {
2370
2320
  super();
2371
2321
  }
2372
2322
  /** @internal */ toString() { return "[object XMLHttpRequestUpload]"; }
2323
+ /** @internal */ get [Symbol.toStringTag]() { return "XMLHttpRequestUpload"; }
2373
2324
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestUpload", "XMLHttpRequestEventTarget", "EventTarget"] }; }
2374
2325
  }
2375
- Class_setStringTag(XMLHttpRequestUploadP, "XMLHttpRequestUpload");
2376
2326
  /** @internal */
2377
2327
  function createXMLHttpRequestUpload() {
2378
2328
  let upload = Object.create(XMLHttpRequestUploadP.prototype);
2379
- upload[state$d] = new EventTargetState(upload);
2380
- upload[state$3] = new XMLHttpRequestEventTargetState(upload);
2329
+ upload[state$g] = new EventTargetState(upload);
2330
+ upload[state$6] = new XMLHttpRequestEventTargetState(upload);
2381
2331
  return upload;
2382
2332
  }
2383
2333
 
2384
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2385
- const mp$1 = { request: request };
2386
- const setRequest = (request) => { mp$1.request = request; };
2387
- /** @internal */
2388
- const state$2 = Symbol( /* "XMLHttpRequestState" */);
2334
+ var _a$1, _b$1, _c, _d, _e, _f, _g, _h, _j, _k;
2335
+ const mp$2 = { request: request };
2336
+ const setRequest = (request) => { mp$2.request = request; };
2337
+ /** @internal */ const state$5 = Symbol( /* "XMLHttpRequestState" */);
2389
2338
  class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
2339
+ static get UNSENT() { return 0; }
2340
+ static get OPENED() { return 1; }
2341
+ static get HEADERS_RECEIVED() { return 2; }
2342
+ static get LOADING() { return 3; }
2343
+ static get DONE() { return 4; }
2390
2344
  constructor() {
2391
2345
  super();
2392
- this[state$2] = new XMLHttpRequestState(this);
2393
- }
2394
- get readyState() { return this[state$2].readyState; }
2395
- get response() { return this[state$2].response; }
2346
+ this[state$5] = new XMLHttpRequestState(this);
2347
+ }
2348
+ get UNSENT() { return 0; }
2349
+ get OPENED() { return 1; }
2350
+ get HEADERS_RECEIVED() { return 2; }
2351
+ get LOADING() { return 3; }
2352
+ get DONE() { return 4; }
2353
+ get readyState() { return this[state$5].readyState; }
2354
+ get response() { return this[state$5].response; }
2396
2355
  get responseText() { return (!this.responseType || this.responseType === "text") ? this.response : ""; }
2397
- get responseType() { return this[state$2].responseType; }
2398
- set responseType(value) { this[state$2].responseType = normalizeResponseType(value); }
2399
- get responseURL() { return this[state$2].responseURL; }
2356
+ get responseType() { return this[state$5].responseType; }
2357
+ set responseType(value) { this[state$5].responseType = normalizeResponseType(value); }
2358
+ get responseURL() { return this[state$5].responseURL; }
2400
2359
  get responseXML() { return null; }
2401
- get status() { return this[state$2].status; }
2360
+ get status() { return this[state$5].status; }
2402
2361
  get statusText() {
2403
- if (this.readyState === XMLHttpRequestImpl.UNSENT || this.readyState === XMLHttpRequestImpl.OPENED)
2362
+ if (this.readyState === 0 /* UNSENT */ || this.readyState === 1 /* OPENED */)
2404
2363
  return "";
2405
- return this[state$2].statusText || statusTextMap(this.status);
2364
+ return this[state$5].statusText || statusTextMap(this.status);
2406
2365
  }
2407
- get timeout() { return this[state$2].timeout; }
2408
- set timeout(value) { this[state$2].timeout = value > 0 ? value : 0; }
2366
+ get timeout() { return this[state$5].timeout; }
2367
+ set timeout(value) { this[state$5].timeout = value > 0 ? value : 0; }
2409
2368
  get upload() {
2410
- const s = this[state$2];
2369
+ const s = this[state$5];
2411
2370
  if (!s.upload) {
2412
2371
  s.upload = createXMLHttpRequestUpload();
2413
2372
  }
2414
2373
  return s.upload;
2415
2374
  }
2416
- get withCredentials() { return this[state$2].withCredentials; }
2417
- set withCredentials(value) { this[state$2].withCredentials = !!value; }
2375
+ get withCredentials() { return this[state$5].withCredentials; }
2376
+ set withCredentials(value) { this[state$5].withCredentials = !!value; }
2418
2377
  abort() {
2419
2378
  clearRequest(this);
2420
2379
  }
2421
2380
  getAllResponseHeaders() {
2422
- const headers = this[state$2][_responseHeaders];
2381
+ const headers = this[state$5][_responseHeaders];
2423
2382
  if (!headers)
2424
2383
  return "";
2425
2384
  let result = [];
@@ -2429,9 +2388,9 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
2429
2388
  getResponseHeader(...args) {
2430
2389
  const [name] = args;
2431
2390
  checkArgsLength(args, 1, "XMLHttpRequest", "getResponseHeader");
2432
- if (!this[state$2][_responseHeaders])
2391
+ if (!this[state$5][_responseHeaders])
2433
2392
  return null;
2434
- return this[state$2][_responseHeaders].get(name);
2393
+ return this[state$5][_responseHeaders].get(name);
2435
2394
  }
2436
2395
  open(...args) {
2437
2396
  const [method, url, async = true, username = null, password = null] = args;
@@ -2439,7 +2398,7 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
2439
2398
  if (!async) {
2440
2399
  console.warn("Synchronous XMLHttpRequest is not supported because of its detrimental effects to the end user's experience.");
2441
2400
  }
2442
- const s = this[state$2];
2401
+ const s = this[state$5];
2443
2402
  clearRequest(this, false);
2444
2403
  s[_method] = normalizeMethod(method);
2445
2404
  s[_requestURL] = "" + url;
@@ -2452,18 +2411,18 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
2452
2411
  }
2453
2412
  }
2454
2413
  s[_inAfterOpenBeforeSend] = true;
2455
- setReadyStateAndNotify(this, XMLHttpRequestImpl.OPENED);
2414
+ setReadyStateAndNotify(this, 1 /* OPENED */);
2456
2415
  }
2457
2416
  overrideMimeType(...args) {
2458
2417
  const [mime] = args;
2459
2418
  checkArgsLength(args, 1, "XMLHttpRequest", "overrideMimeType");
2460
- if (this[state$2][_inAfterOpenBeforeSend]) {
2419
+ if (this[state$5][_inAfterOpenBeforeSend]) {
2461
2420
  console.error(`TypeError: Failed to execute 'overrideMimeType' on 'XMLHttpRequest': mimeType ('${mime}') not implemented.`);
2462
2421
  }
2463
2422
  }
2464
2423
  send(body) {
2465
- const s = this[state$2];
2466
- if (!s[_inAfterOpenBeforeSend] || s.readyState !== XMLHttpRequestImpl.OPENED) {
2424
+ const s = this[state$5];
2425
+ if (!s[_inAfterOpenBeforeSend] || s.readyState !== 1 /* OPENED */) {
2467
2426
  throw new MPException("Failed to execute 'send' on 'XMLHttpRequest': The object's state must be OPENED.", "InvalidStateError");
2468
2427
  }
2469
2428
  s[_inAfterOpenBeforeSend] = false;
@@ -2495,14 +2454,14 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
2495
2454
  };
2496
2455
  // Alipay Mini Program
2497
2456
  options.headers = options.header;
2498
- s[_requestTask] = mp$1.request(options);
2457
+ s[_requestTask] = mp$2.request(options);
2499
2458
  emitProcessEvent(this, "loadstart");
2500
2459
  if (processContentLength && s.upload) {
2501
2460
  emitProcessEvent(this.upload, "loadstart", 0, contentLength);
2502
2461
  }
2503
2462
  setTimeout(() => {
2504
2463
  if (s.upload) {
2505
- const _aborted = s[_inAfterOpenBeforeSend] || s.readyState !== XMLHttpRequestImpl.OPENED;
2464
+ const _aborted = s[_inAfterOpenBeforeSend] || s.readyState !== 1 /* OPENED */;
2506
2465
  const _contentLength = _aborted ? 0 : contentLength;
2507
2466
  if (_aborted) {
2508
2467
  emitProcessEvent(this.upload, "abort");
@@ -2522,27 +2481,29 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
2522
2481
  setRequestHeader(...args) {
2523
2482
  const [name, value] = args;
2524
2483
  checkArgsLength(args, 2, "XMLHttpRequest", "setRequestHeader");
2525
- const s = this[state$2];
2526
- if (!s[_inAfterOpenBeforeSend] || s.readyState !== XMLHttpRequestImpl.OPENED) {
2484
+ const s = this[state$5];
2485
+ if (!s[_inAfterOpenBeforeSend] || s.readyState !== 1 /* OPENED */) {
2527
2486
  throw new MPException("Failed to execute 'setRequestHeader' on 'XMLHttpRequest': The object's state must be OPENED.", "InvalidStateError");
2528
2487
  }
2529
- let _name = normalizeName(name, () => {
2530
- throw new SyntaxError(`Failed to execute 'setRequestHeader' on 'XMLHttpRequest': '${name}' is not a valid HTTP header field name.`);
2531
- });
2532
- s[_requestHeaders].append(_name, value);
2488
+ let _name = "" + name;
2489
+ let _value = "" + value;
2490
+ try {
2491
+ s[_requestHeaders].append(_name, _value);
2492
+ }
2493
+ catch (e) {
2494
+ throw new SyntaxError(`Failed to execute 'setRequestHeader' on 'XMLHttpRequest': '${_name}' is not a valid HTTP header field name.`);
2495
+ }
2533
2496
  }
2534
- get onreadystatechange() { return this[state$2].onreadystatechange; }
2497
+ get onreadystatechange() { return this[state$5].onreadystatechange; }
2535
2498
  set onreadystatechange(value) {
2536
- this[state$2].onreadystatechange = value;
2537
- attachFn(this, "readystatechange", value, this[state$2][_handlers].onreadystatechange);
2499
+ this[state$5].onreadystatechange = value;
2500
+ attachFn(this, "readystatechange", value, this[state$5][_handlers$1].onreadystatechange);
2538
2501
  }
2539
2502
  /** @internal */ toString() { return "[object XMLHttpRequest]"; }
2503
+ /** @internal */ get [Symbol.toStringTag]() { return "XMLHttpRequest"; }
2540
2504
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequest", "XMLHttpRequestEventTarget", "EventTarget"] }; }
2541
2505
  }
2542
- Object.defineProperties(XMLHttpRequestImpl, XHR_properties);
2543
- Object.defineProperties(XMLHttpRequestImpl.prototype, XHR_properties);
2544
- Class_setStringTag(XMLHttpRequestImpl, "XMLHttpRequest");
2545
- /** @internal */ const _handlers = Symbol();
2506
+ /** @internal */ const _handlers$1 = Symbol();
2546
2507
  /** @internal */ const _inAfterOpenBeforeSend = Symbol();
2547
2508
  /** @internal */ const _resetPending = Symbol();
2548
2509
  /** @internal */ const _timeoutId = Symbol();
@@ -2555,7 +2516,7 @@ Class_setStringTag(XMLHttpRequestImpl, "XMLHttpRequest");
2555
2516
  /** @internal */
2556
2517
  class XMLHttpRequestState {
2557
2518
  constructor(target) {
2558
- this.readyState = XMLHttpRequestImpl.UNSENT;
2519
+ this.readyState = 0 /* UNSENT */;
2559
2520
  this.response = "";
2560
2521
  this.responseType = "";
2561
2522
  this.responseURL = "";
@@ -2563,9 +2524,9 @@ class XMLHttpRequestState {
2563
2524
  this.statusText = "";
2564
2525
  this.timeout = 0;
2565
2526
  this.withCredentials = false;
2566
- this[_a] = getHandlers(this);
2527
+ this[_a$1] = getHandlers$1(this);
2567
2528
  this.onreadystatechange = null;
2568
- this[_b] = false;
2529
+ this[_b$1] = false;
2569
2530
  this[_c] = false;
2570
2531
  this[_d] = 0;
2571
2532
  this[_e] = "";
@@ -2577,8 +2538,8 @@ class XMLHttpRequestState {
2577
2538
  this.target = target;
2578
2539
  }
2579
2540
  }
2580
- _a = _handlers, _b = _inAfterOpenBeforeSend, _c = _resetPending, _d = _timeoutId, _e = _requestURL, _f = _method, _g = _requestHeaders, _h = _responseHeaders, _j = _responseContentLength, _k = _requestTask;
2581
- function getHandlers(s) {
2541
+ _a$1 = _handlers$1, _b$1 = _inAfterOpenBeforeSend, _c = _resetPending, _d = _timeoutId, _e = _requestURL, _f = _method, _g = _requestHeaders, _h = _responseHeaders, _j = _responseContentLength, _k = _requestTask;
2542
+ function getHandlers$1(s) {
2582
2543
  return {
2583
2544
  onreadystatechange: (ev) => { executeFn(s.target, s.onreadystatechange, ev); },
2584
2545
  };
@@ -2587,15 +2548,15 @@ function normalizeDataType(responseType) {
2587
2548
  return (responseType === "blob" || responseType === "arraybuffer") ? "arraybuffer" : "text";
2588
2549
  }
2589
2550
  function requestSuccess(res) {
2590
- const s = this[state$2];
2551
+ const s = this[state$5];
2591
2552
  s.responseURL = s[_requestURL];
2592
2553
  s.status = "statusCode" in res ? res.statusCode : "status" in res ? res.status : 200;
2593
- s[_responseHeaders] = new HeadersP(("header" in res ? res.header : "headers" in res ? res.headers : undefined));
2554
+ s[_responseHeaders] = new HeadersP(("header" in res ? res.header : "headers" in res ? res.headers : {}));
2594
2555
  let lengthStr = s[_responseHeaders].get("Content-Length");
2595
2556
  s[_responseContentLength] = () => { return lengthStr ? parseInt(lengthStr) : 0; };
2596
- if (s.readyState === XMLHttpRequestImpl.OPENED) {
2597
- setReadyStateAndNotify(this, XMLHttpRequestImpl.HEADERS_RECEIVED);
2598
- setReadyStateAndNotify(this, XMLHttpRequestImpl.LOADING);
2557
+ if (s.readyState === 1 /* OPENED */) {
2558
+ setReadyStateAndNotify(this, 2 /* HEADERS_RECEIVED */);
2559
+ setReadyStateAndNotify(this, 3 /* LOADING */);
2599
2560
  setTimeout(() => {
2600
2561
  if (!s[_inAfterOpenBeforeSend]) {
2601
2562
  let l = s[_responseContentLength];
@@ -2624,23 +2585,23 @@ function requestFail(err) {
2624
2585
  requestSuccess.call(this, {
2625
2586
  statusCode: "statusCode" in err ? err.statusCode : err.status || 0,
2626
2587
  header: "header" in err ? err.header : err.headers || {},
2627
- data: "data" in err ? err.data : "",
2588
+ data: "data" in err ? err.data || "" : "",
2628
2589
  });
2629
2590
  return;
2630
2591
  }
2631
- const s = this[state$2];
2592
+ const s = this[state$5];
2632
2593
  s.status = 0;
2633
2594
  s.statusText = "errMsg" in err ? err.errMsg : "errorMessage" in err ? err.errorMessage : "";
2634
- if (!s[_inAfterOpenBeforeSend] && s.readyState !== XMLHttpRequestImpl.UNSENT && s.readyState !== XMLHttpRequestImpl.DONE) {
2595
+ if (!s[_inAfterOpenBeforeSend] && s.readyState !== 0 /* UNSENT */ && s.readyState !== 4 /* DONE */) {
2635
2596
  emitProcessEvent(this, "error");
2636
2597
  resetRequestTimeout(this);
2637
2598
  }
2638
2599
  }
2639
2600
  function requestComplete() {
2640
- const s = this[state$2];
2601
+ const s = this[state$5];
2641
2602
  s[_requestTask] = null;
2642
- if (!s[_inAfterOpenBeforeSend] && (s.readyState === XMLHttpRequestImpl.OPENED || s.readyState === XMLHttpRequestImpl.LOADING)) {
2643
- setReadyStateAndNotify(this, XMLHttpRequestImpl.DONE);
2603
+ if (!s[_inAfterOpenBeforeSend] && (s.readyState === 1 /* OPENED */ || s.readyState === 3 /* LOADING */)) {
2604
+ setReadyStateAndNotify(this, 4 /* DONE */);
2644
2605
  }
2645
2606
  setTimeout(() => {
2646
2607
  if (!s[_inAfterOpenBeforeSend]) {
@@ -2656,12 +2617,12 @@ function safeAbort(task) {
2656
2617
  }
2657
2618
  }
2658
2619
  function clearRequest(xhr, delay = true) {
2659
- const s = xhr[state$2];
2620
+ const s = xhr[state$5];
2660
2621
  const timerFn = delay ? setTimeout : (f) => { f(); };
2661
2622
  s[_resetPending] = true;
2662
- if (s[_requestTask] && s.readyState !== XMLHttpRequestImpl.DONE) {
2623
+ if (s[_requestTask] && s.readyState !== 4 /* DONE */) {
2663
2624
  if (delay) {
2664
- setReadyStateAndNotify(xhr, XMLHttpRequestImpl.DONE);
2625
+ setReadyStateAndNotify(xhr, 4 /* DONE */);
2665
2626
  }
2666
2627
  timerFn(() => {
2667
2628
  const requestTask = s[_requestTask];
@@ -2679,27 +2640,27 @@ function clearRequest(xhr, delay = true) {
2679
2640
  timerFn(() => {
2680
2641
  if (s[_resetPending]) {
2681
2642
  if (delay) {
2682
- s.readyState = XMLHttpRequestImpl.UNSENT;
2643
+ s.readyState = 0 /* UNSENT */;
2683
2644
  }
2684
2645
  resetXHR(xhr);
2685
2646
  }
2686
2647
  });
2687
2648
  }
2688
2649
  function checkRequestTimeout(xhr) {
2689
- const s = xhr[state$2];
2650
+ const s = xhr[state$5];
2690
2651
  if (s.timeout) {
2691
2652
  s[_timeoutId] = setTimeout(() => {
2692
- if (!s.status && s.readyState !== XMLHttpRequestImpl.DONE) {
2653
+ if (!s.status && s.readyState !== 4 /* DONE */) {
2693
2654
  if (s[_requestTask])
2694
2655
  safeAbort(s[_requestTask]);
2695
- setReadyStateAndNotify(xhr, XMLHttpRequestImpl.DONE);
2656
+ setReadyStateAndNotify(xhr, 4 /* DONE */);
2696
2657
  emitProcessEvent(xhr, "timeout");
2697
2658
  }
2698
2659
  }, s.timeout);
2699
2660
  }
2700
2661
  }
2701
2662
  function resetXHR(xhr) {
2702
- const s = xhr[state$2];
2663
+ const s = xhr[state$5];
2703
2664
  s[_resetPending] = false;
2704
2665
  resetRequestTimeout(xhr);
2705
2666
  s.response = "";
@@ -2711,14 +2672,14 @@ function resetXHR(xhr) {
2711
2672
  s[_responseContentLength] = () => 0;
2712
2673
  }
2713
2674
  function resetRequestTimeout(xhr) {
2714
- const s = xhr[state$2];
2675
+ const s = xhr[state$5];
2715
2676
  if (s[_timeoutId]) {
2716
2677
  clearTimeout(s[_timeoutId]);
2717
2678
  s[_timeoutId] = 0;
2718
2679
  }
2719
2680
  }
2720
2681
  function setReadyStateAndNotify(xhr, value) {
2721
- const s = xhr[state$2];
2682
+ const s = xhr[state$5];
2722
2683
  let hasChanged = value !== s.readyState;
2723
2684
  s.readyState = value;
2724
2685
  if (hasChanged) {
@@ -2730,13 +2691,13 @@ function setReadyStateAndNotify(xhr, value) {
2730
2691
  const XMLHttpRequestP = XMLHttpRequestImpl;
2731
2692
  const XMLHttpRequestE = (typeof XMLHttpRequest !== "undefined" && XMLHttpRequest) || XMLHttpRequestP;
2732
2693
 
2733
- /** @internal */ const state$1 = Symbol( /* "ResponseState" */);
2694
+ /** @internal */ const state$4 = Symbol( /* "ResponseState" */);
2734
2695
  class ResponseP extends BodyImpl {
2735
2696
  constructor(body, init) {
2736
2697
  super();
2737
- this[state$7].name = "Response";
2738
- this[state$1] = new ResponseState();
2739
- const s = this[state$1];
2698
+ this[state$a].name = "Response";
2699
+ this[state$4] = new ResponseState();
2700
+ const s = this[state$4];
2740
2701
  let _init = init !== null && init !== void 0 ? init : {};
2741
2702
  if (typeof _init !== "object") {
2742
2703
  throw new TypeError("Failed to construct 'Response': The provided value is not of type 'ResponseInit'.");
@@ -2754,18 +2715,18 @@ class ResponseP extends BodyImpl {
2754
2715
  Body_init(this, body);
2755
2716
  }
2756
2717
  get headers() {
2757
- const s = this[state$1];
2718
+ const s = this[state$4];
2758
2719
  if (!s.headers) {
2759
2720
  s.headers = new HeadersP();
2760
2721
  }
2761
2722
  return s.headers;
2762
2723
  }
2763
- get ok() { return this[state$1].ok; }
2764
- get redirected() { return this[state$1].redirected; }
2765
- get status() { return this[state$1].status; }
2766
- get statusText() { return this[state$1].statusText; }
2767
- get type() { return this[state$1].type; }
2768
- get url() { return this[state$1].url; }
2724
+ get ok() { return this[state$4].ok; }
2725
+ get redirected() { return this[state$4].redirected; }
2726
+ get status() { return this[state$4].status; }
2727
+ get statusText() { return this[state$4].statusText; }
2728
+ get type() { return this[state$4].type; }
2729
+ get url() { return this[state$4].url; }
2769
2730
  clone() {
2770
2731
  if (this.bodyUsed) {
2771
2732
  throw new TypeError("Failed to execute 'clone' on 'Response': Response body is already used");
@@ -2775,7 +2736,7 @@ class ResponseP extends BodyImpl {
2775
2736
  status: this.status,
2776
2737
  statusText: this.statusText,
2777
2738
  });
2778
- response[state$1].url = this.url;
2739
+ response[state$4].url = this.url;
2779
2740
  return response;
2780
2741
  }
2781
2742
  static json(...args) {
@@ -2787,9 +2748,9 @@ class ResponseP extends BodyImpl {
2787
2748
  }
2788
2749
  static error() {
2789
2750
  let response = new ResponseP(null, { status: 200, statusText: "" });
2790
- response[state$1].ok = false;
2791
- response[state$1].status = 0;
2792
- response[state$1].type = "error";
2751
+ response[state$4].ok = false;
2752
+ response[state$4].status = 0;
2753
+ response[state$4].type = "error";
2793
2754
  return response;
2794
2755
  }
2795
2756
  static redirect(...args) {
@@ -2801,9 +2762,9 @@ class ResponseP extends BodyImpl {
2801
2762
  return new ResponseP(null, { status, headers: { location: "" + url } });
2802
2763
  }
2803
2764
  /** @internal */ toString() { return "[object Response]"; }
2765
+ /** @internal */ get [Symbol.toStringTag]() { return "Response"; }
2804
2766
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Response"] }; }
2805
2767
  }
2806
- Class_setStringTag(ResponseP, "Response");
2807
2768
  /** @internal */
2808
2769
  class ResponseState {
2809
2770
  constructor() {
@@ -2817,8 +2778,8 @@ class ResponseState {
2817
2778
  }
2818
2779
  const ResponseE = g["Response"] || ResponseP;
2819
2780
 
2820
- const mp = { XMLHttpRequest: XMLHttpRequestE };
2821
- const setXMLHttpRequest = (XHR) => { mp.XMLHttpRequest = XHR; };
2781
+ const mp$1 = { XMLHttpRequest: XMLHttpRequestE };
2782
+ const setXMLHttpRequest = (XHR) => { mp$1.XMLHttpRequest = XHR; };
2822
2783
  function fetchP(...args) {
2823
2784
  if (new.target === fetchP) {
2824
2785
  throw new TypeError("fetch is not a constructor");
@@ -2827,11 +2788,11 @@ function fetchP(...args) {
2827
2788
  checkArgsLength(args, 1, "Window", "fetch");
2828
2789
  return new Promise((resolve, reject) => {
2829
2790
  const request = new RequestP(input, init);
2830
- const signal = request[state$4].signal;
2791
+ const signal = request[state$7].signal;
2831
2792
  if (signal && signal.aborted) {
2832
2793
  return reject(signal.reason);
2833
2794
  }
2834
- let xhr = new mp.XMLHttpRequest();
2795
+ let xhr = new mp$1.XMLHttpRequest();
2835
2796
  xhr.onload = function () {
2836
2797
  let options = {
2837
2798
  headers: parseHeaders(xhr.getAllResponseHeaders() || ""),
@@ -2845,7 +2806,7 @@ function fetchP(...args) {
2845
2806
  }
2846
2807
  setTimeout(() => {
2847
2808
  let response = new ResponseP("response" in xhr ? xhr.response : xhr.responseText, options);
2848
- response[state$1].url = "responseURL" in xhr ? xhr.responseURL : (options.headers.get("X-Request-URL") || "");
2809
+ response[state$4].url = "responseURL" in xhr ? xhr.responseURL : (options.headers.get("X-Request-URL") || "");
2849
2810
  resolve(response);
2850
2811
  });
2851
2812
  };
@@ -2874,7 +2835,7 @@ function fetchP(...args) {
2874
2835
  if ("responseType" in xhr) {
2875
2836
  xhr.responseType = "arraybuffer";
2876
2837
  }
2877
- if (init && typeof init === "object" && typeof init.headers === "object" && !isObjectType("Headers", init.headers)) {
2838
+ if (init && typeof init === "object" && typeof init.headers === "object" && !(isObjectType("Headers", init.headers) || isPolyfillType("Headers", init.headers))) {
2878
2839
  let headers = init.headers;
2879
2840
  let names = [];
2880
2841
  Object.getOwnPropertyNames(headers).forEach(name => {
@@ -2896,8 +2857,8 @@ function fetchP(...args) {
2896
2857
  const abortXHR = () => { xhr.abort(); };
2897
2858
  signal.addEventListener("abort", abortXHR);
2898
2859
  xhr.onreadystatechange = function () {
2899
- // DONE (success or failure)
2900
- if (xhr.readyState === 4) {
2860
+ // success or failure
2861
+ if (xhr.readyState === 4 /* DONE */) {
2901
2862
  signal.removeEventListener("abort", abortXHR);
2902
2863
  }
2903
2864
  };
@@ -2908,32 +2869,344 @@ function fetchP(...args) {
2908
2869
  }
2909
2870
  const fetchE = g["fetch"] || fetchP;
2910
2871
 
2911
- const dispatched = 1;
2872
+ const dispatched$1 = 1;
2912
2873
  /** @internal */
2913
- const state = Symbol( /* "CustomEventState" */);
2874
+ const state$3 = Symbol( /* "CustomEventState" */);
2914
2875
  class CustomEventP extends EventP {
2915
2876
  constructor(type, eventInitDict) {
2916
2877
  var _a;
2917
2878
  super(type, eventInitDict);
2918
- this[state] = new CustomEventState();
2919
- this[state].detail = (_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.detail) !== null && _a !== void 0 ? _a : null;
2879
+ this[state$3] = new CustomEventState();
2880
+ this[state$3].detail = (_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.detail) !== null && _a !== void 0 ? _a : null;
2920
2881
  }
2921
- get detail() { return this[state].detail; }
2882
+ get detail() { return this[state$3].detail; }
2922
2883
  initCustomEvent(...args) {
2923
2884
  const [type, bubbles, cancelable, detail] = args;
2924
2885
  checkArgsLength(args, 1, "CustomEvent", "initCustomEvent");
2925
- if (Event_getEtField(this, dispatched))
2886
+ if (Event_getEtField(this, dispatched$1))
2926
2887
  return;
2927
2888
  this.initEvent(type, bubbles, cancelable);
2928
- this[state].detail = detail !== null && detail !== void 0 ? detail : null;
2889
+ this[state$3].detail = detail !== null && detail !== void 0 ? detail : null;
2929
2890
  }
2930
2891
  /** @internal */ toString() { return "[object CustomEvent]"; }
2892
+ /** @internal */ get [Symbol.toStringTag]() { return "CustomEvent"; }
2931
2893
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["CustomEvent", "Event"] }; }
2932
2894
  }
2933
- Class_setStringTag(CustomEventP, "CustomEvent");
2934
2895
  /** @internal */
2935
2896
  class CustomEventState {
2936
2897
  }
2937
2898
  const CustomEventE = g["EventTarget"] ? g["CustomEvent"] : CustomEventP;
2938
2899
 
2939
- export { AbortControllerE as AbortController, AbortControllerP, AbortSignalE as AbortSignal, AbortSignalP, BlobE as Blob, BlobP, CustomEventE as CustomEvent, CustomEventP, EventE as Event, EventP, EventTargetE as EventTarget, EventTargetP, FileE as File, FileP, FileReaderE as FileReader, FileReaderP, FormDataE as FormData, FormDataP, HeadersE as Headers, HeadersP, ProgressEventE as ProgressEvent, ProgressEventP, RequestE as Request, RequestP, ResponseE as Response, ResponseP, TextDecoderE as TextDecoder, TextDecoderP, TextEncoderE as TextEncoder, TextEncoderP, URLSearchParamsE as URLSearchParams, URLSearchParamsP, XMLHttpRequestE as XMLHttpRequest, XMLHttpRequestP, fetchE as fetch, fetchP, setRequest, setXMLHttpRequest };
2900
+ /** @internal */
2901
+ const state$2 = Symbol( /* "CloseEventState" */);
2902
+ class CloseEventP extends EventP {
2903
+ constructor(type, eventInitDict) {
2904
+ var _a;
2905
+ super(type, eventInitDict);
2906
+ this[state$2] = new CloseEventState();
2907
+ const s = this[state$2];
2908
+ let _code = Number((_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.code) !== null && _a !== void 0 ? _a : 0);
2909
+ s.code = isNaN(_code) ? 0 : _code;
2910
+ if ((eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.reason) !== undefined)
2911
+ s.reason = "" + eventInitDict.reason;
2912
+ s.wasClean = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.wasClean);
2913
+ }
2914
+ get code() { return this[state$2].code; }
2915
+ get reason() { return this[state$2].reason; }
2916
+ get wasClean() { return this[state$2].wasClean; }
2917
+ /** @internal */ toString() { return "[object CloseEvent]"; }
2918
+ /** @internal */ get [Symbol.toStringTag]() { return "CloseEvent"; }
2919
+ /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["CloseEvent", "Event"] }; }
2920
+ }
2921
+ /** @internal */
2922
+ class CloseEventState {
2923
+ constructor() {
2924
+ this.code = 0;
2925
+ this.reason = "";
2926
+ this.wasClean = false;
2927
+ }
2928
+ }
2929
+ g["EventTarget"] ? g["CloseEvent"] : CloseEventP;
2930
+
2931
+ const dispatched = 1;
2932
+ /** @internal */
2933
+ const state$1 = Symbol( /* "MessageEventState" */);
2934
+ class MessageEventP extends EventP {
2935
+ constructor(type, eventInitDict) {
2936
+ var _a;
2937
+ super(type, eventInitDict);
2938
+ this[state$1] = new MessageEventState();
2939
+ const s = this[state$1];
2940
+ s.data = (_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.data) !== null && _a !== void 0 ? _a : null;
2941
+ if ((eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.origin) !== undefined)
2942
+ s.origin = "" + eventInitDict.origin;
2943
+ if ((eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.lastEventId) !== undefined)
2944
+ s.lastEventId = "" + eventInitDict.lastEventId;
2945
+ if ((eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.source) !== undefined)
2946
+ s.source = eventInitDict.source;
2947
+ if ((eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.ports) !== undefined)
2948
+ s.ports = eventInitDict.ports;
2949
+ }
2950
+ get data() { return this[state$1].data; }
2951
+ get lastEventId() { return this[state$1].lastEventId; }
2952
+ get origin() { return this[state$1].origin; }
2953
+ get ports() { return this[state$1].ports; }
2954
+ get source() { return this[state$1].source; }
2955
+ initMessageEvent(...args) {
2956
+ const [type, bubbles, cancelable, data, origin, lastEventId, source, ports] = args;
2957
+ checkArgsLength(args, 1, "MessageEvent", "initMessageEvent");
2958
+ if (Event_getEtField(this, dispatched))
2959
+ return;
2960
+ this.initEvent(type, bubbles, cancelable);
2961
+ const s = this[state$1];
2962
+ s.data = data !== null && data !== void 0 ? data : null;
2963
+ if (origin !== undefined)
2964
+ s.origin = "" + origin;
2965
+ if (lastEventId !== undefined)
2966
+ s.lastEventId = "" + lastEventId;
2967
+ if (source !== undefined)
2968
+ s.source = source;
2969
+ if (ports !== undefined)
2970
+ s.ports = ports;
2971
+ }
2972
+ /** @internal */ toString() { return "[object MessageEvent]"; }
2973
+ /** @internal */ get [Symbol.toStringTag]() { return "MessageEvent"; }
2974
+ /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["MessageEvent", "Event"] }; }
2975
+ }
2976
+ /** @internal */
2977
+ class MessageEventState {
2978
+ constructor() {
2979
+ this.data = null;
2980
+ this.lastEventId = "";
2981
+ this.origin = "";
2982
+ this.ports = [];
2983
+ this.source = null;
2984
+ }
2985
+ }
2986
+ g["EventTarget"] ? g["MessageEvent"] : MessageEventP;
2987
+
2988
+ const connectSocket = mp$3 ? mp$3.connectSocket : function errorConnectSocket(options) {
2989
+ return {
2990
+ send(obj) { },
2991
+ close(obj) { },
2992
+ onOpen(listener) { },
2993
+ onMessage(listener) { },
2994
+ onError(listener) {
2995
+ if (typeof listener === "function") {
2996
+ listener({ errMsg: "NOT_SUPPORTED_ERR" });
2997
+ }
2998
+ },
2999
+ onClose(listener) {
3000
+ if (typeof listener === "function") {
3001
+ setTimeout(() => { listener({ code: 3009, reason: "NOT_SUPPORTED_ERR" }); });
3002
+ }
3003
+ },
3004
+ };
3005
+ };
3006
+
3007
+ var _a, _b;
3008
+ const mp = { connectSocket: connectSocket };
3009
+ const setConnectSocket = (connectSocket) => { mp.connectSocket = connectSocket; };
3010
+ /** @internal */
3011
+ const state = Symbol( /* "WebSocketState" */);
3012
+ class WebSocketImpl extends EventTargetP {
3013
+ static get CONNECTING() { return 0; }
3014
+ static get OPEN() { return 1; }
3015
+ static get CLOSING() { return 2; }
3016
+ static get CLOSED() { return 3; }
3017
+ constructor(...args) {
3018
+ const [url, protocols] = args;
3019
+ checkArgsLength(args, 1, "WebSocket");
3020
+ super();
3021
+ this[state] = new WebSocketState(this, {
3022
+ url: "" + url,
3023
+ protocols: protocols !== undefined
3024
+ ? (Array.isArray(protocols) || (protocols && typeof protocols === "object" && Symbol.iterator in protocols))
3025
+ ? Array.isArray(protocols) ? protocols : Array.from(protocols)
3026
+ : ["" + protocols]
3027
+ : [],
3028
+ multiple: true, // Alipay Mini Program
3029
+ fail(err) { console.error(err); },
3030
+ });
3031
+ let socketTask = this[state][_socketTask];
3032
+ if (socketTask && typeof socketTask === "object") {
3033
+ onOpen(this);
3034
+ onClose(this);
3035
+ onError(this);
3036
+ onMessage(this);
3037
+ }
3038
+ else {
3039
+ throw new Error(`connectSocket can't establish a connection to the server at ${"" + url}.`);
3040
+ }
3041
+ }
3042
+ get CONNECTING() { return 0; }
3043
+ get OPEN() { return 1; }
3044
+ get CLOSING() { return 2; }
3045
+ get CLOSED() { return 3; }
3046
+ get binaryType() { return this[state].binaryType; }
3047
+ set binaryType(value) { if (value === "blob" || value === "arraybuffer") {
3048
+ this[state].binaryType = value;
3049
+ } }
3050
+ get bufferedAmount() { return this[state].bufferedAmount; }
3051
+ get extensions() { return this[state].extensions; }
3052
+ get protocol() { return this[state].protocol; }
3053
+ get readyState() { return this[state].readyState; }
3054
+ get url() { return this[state].url; }
3055
+ close(code, reason) {
3056
+ if (this.readyState === 2 /* CLOSING */ || this.readyState === 3 /* CLOSED */)
3057
+ return;
3058
+ this[state].readyState = 2 /* CLOSING */;
3059
+ this[state][_socketTask].close({
3060
+ code: code,
3061
+ reason: reason,
3062
+ fail(err) { console.error(err); },
3063
+ complete: (function () {
3064
+ this[state].readyState = 3 /* CLOSED */;
3065
+ }).bind(this),
3066
+ });
3067
+ }
3068
+ send(...args) {
3069
+ const [data] = args;
3070
+ checkArgsLength(args, 1, "WebSocket", "send");
3071
+ if (this.readyState === 0 /* CONNECTING */) {
3072
+ throw new MPException("Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.", "InvalidStateError");
3073
+ }
3074
+ if (this.readyState === 2 /* CLOSING */ || this.readyState === 3 /* CLOSED */) {
3075
+ return console.error("WebSocket is already in CLOSING or CLOSED state.");
3076
+ }
3077
+ let _data;
3078
+ if (isArrayBuffer(data)) {
3079
+ _data = data;
3080
+ }
3081
+ else if (ArrayBuffer.isView(data)) {
3082
+ _data = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
3083
+ }
3084
+ else if (isPolyfillType("Blob", data)) {
3085
+ _data = Blob_toUint8Array(data).buffer.slice(0);
3086
+ }
3087
+ else {
3088
+ _data = "" + data;
3089
+ }
3090
+ this[state][_socketTask].send({
3091
+ data: _data,
3092
+ fail(err) { console.error(err); },
3093
+ });
3094
+ }
3095
+ get onclose() { return this[state].onclose; }
3096
+ set onclose(value) { this[state].onclose = value; attach(this, "close"); }
3097
+ get onerror() { return this[state].onerror; }
3098
+ set onerror(value) { this[state].onerror = value; attach(this, "error"); }
3099
+ get onmessage() { return this[state].onmessage; }
3100
+ set onmessage(value) { this[state].onmessage = value; attach(this, "message"); }
3101
+ get onopen() { return this[state].onopen; }
3102
+ set onopen(value) { this[state].onopen = value; attach(this, "open"); }
3103
+ /** @internal */ toString() { return "[object WebSocket]"; }
3104
+ /** @internal */ get [Symbol.toStringTag]() { return "WebSocket"; }
3105
+ /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["WebSocket", "EventTarget"] }; }
3106
+ }
3107
+ /** @internal */ const _socketTask = Symbol();
3108
+ /** @internal */ const _error = Symbol();
3109
+ /** @internal */ const _handlers = Symbol();
3110
+ /** @internal */
3111
+ class WebSocketState {
3112
+ constructor(target, opts) {
3113
+ this.binaryType = "blob";
3114
+ this.bufferedAmount = 0;
3115
+ this.extensions = "";
3116
+ this.protocol = "";
3117
+ this.readyState = 0;
3118
+ this[_a] = null;
3119
+ this[_b] = getHandlers(this);
3120
+ this.onclose = null;
3121
+ this.onerror = null;
3122
+ this.onmessage = null;
3123
+ this.onopen = null;
3124
+ this.target = target;
3125
+ this.url = opts.url;
3126
+ this[_socketTask] = mp.connectSocket(opts);
3127
+ }
3128
+ }
3129
+ _a = _error, _b = _handlers;
3130
+ function attach(target, type) {
3131
+ const s = target[state];
3132
+ const fnName = ("on" + type);
3133
+ const cb = s[fnName];
3134
+ const listener = s[_handlers][fnName];
3135
+ attachFn(target, type, cb, listener);
3136
+ }
3137
+ function getHandlers(s) {
3138
+ return {
3139
+ onclose: (ev) => { executeFn(s.target, s.onclose, ev); },
3140
+ onerror: (ev) => { executeFn(s.target, s.onerror, ev); },
3141
+ onmessage: (ev) => { executeFn(s.target, s.onmessage, ev); },
3142
+ onopen: (ev) => { executeFn(s.target, s.onopen, ev); },
3143
+ };
3144
+ }
3145
+ function onOpen(ws) {
3146
+ let socket = ws;
3147
+ socket[state][_socketTask].onOpen(res => {
3148
+ if ("header" in res && res.header && typeof res.header === "object") {
3149
+ let headers = new HeadersP(res.header);
3150
+ socket[state].protocol = headers.get("Sec-WebSocket-Protocol") || "";
3151
+ }
3152
+ socket[state].readyState = 1 /* OPEN */;
3153
+ EventTarget_fire(socket, createInnerEvent(socket, "open"));
3154
+ });
3155
+ }
3156
+ function onClose(ws) {
3157
+ let socket = ws;
3158
+ socket[state][_socketTask].onClose(res => {
3159
+ socket[state].readyState = 3 /* CLOSED */;
3160
+ let event = new CloseEventP("close", {
3161
+ wasClean: !socket[state][_error],
3162
+ code: res.code,
3163
+ reason: res.reason,
3164
+ });
3165
+ Event_setTrusted(event, true);
3166
+ EventTarget_fire(socket, event);
3167
+ });
3168
+ }
3169
+ function onError(ws) {
3170
+ let socket = ws;
3171
+ socket[state][_socketTask].onError(res => {
3172
+ console.error(res);
3173
+ socket[state][_error] = res;
3174
+ socket[state].readyState = 3 /* CLOSED */;
3175
+ EventTarget_fire(socket, createInnerEvent(socket, "error"));
3176
+ });
3177
+ }
3178
+ function onMessage(ws) {
3179
+ let socket = ws;
3180
+ socket[state][_socketTask].onMessage(res => {
3181
+ let data = res.data;
3182
+ let _data;
3183
+ // Alipay Mini Program
3184
+ if (data && typeof data === "object" && "data" in data) {
3185
+ _data = data.data;
3186
+ if ("isBuffer" in data && data.isBuffer && typeof _data === "string") {
3187
+ // @ts-ignore
3188
+ try {
3189
+ _data = my.base64ToArrayBuffer(_data);
3190
+ }
3191
+ catch (e) { }
3192
+ }
3193
+ }
3194
+ else {
3195
+ _data = data;
3196
+ }
3197
+ if (isArrayBuffer(_data) && socket.binaryType === "blob") {
3198
+ _data = new BlobP([_data]);
3199
+ }
3200
+ let event = new MessageEventP("message", {
3201
+ data: _data,
3202
+ origin: socket.url,
3203
+ });
3204
+ Event_setTrusted(event, true);
3205
+ EventTarget_fire(socket, event);
3206
+ });
3207
+ }
3208
+
3209
+ const WebSocketP = WebSocketImpl;
3210
+ const WebSocketE = (typeof WebSocket !== "undefined" && WebSocket) || WebSocketP;
3211
+
3212
+ export { AbortControllerE as AbortController, AbortControllerP, AbortSignalE as AbortSignal, AbortSignalP, BlobE as Blob, BlobP, CustomEventE as CustomEvent, CustomEventP, EventE as Event, EventP, EventTargetE as EventTarget, EventTargetP, FileE as File, FileP, FileReaderE as FileReader, FileReaderP, FormDataE as FormData, FormDataP, HeadersE as Headers, HeadersP, RequestE as Request, RequestP, ResponseE as Response, ResponseP, TextDecoderE as TextDecoder, TextDecoderP, TextEncoderE as TextEncoder, TextEncoderP, URLSearchParamsE as URLSearchParams, URLSearchParamsP, WebSocketE as WebSocket, WebSocketP, XMLHttpRequestE as XMLHttpRequest, XMLHttpRequestP, fetchE as fetch, fetchP, setConnectSocket, setRequest, setXMLHttpRequest };