mphttpx 1.0.12 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -48,6 +48,10 @@ function isPolyfillType(name, value) {
48
48
  && Array.isArray(value.isPolyfill.hierarchy)
49
49
  && value.isPolyfill.hierarchy.indexOf(name) > -1;
50
50
  }
51
+ /** @internal */
52
+ function isArrayBuffer(value) {
53
+ return (!!value && typeof value === "object" && ArrayBuffer.prototype.isPrototypeOf(value)) || isObjectType("ArrayBuffer", value);
54
+ }
51
55
 
52
56
  class TextEncoderP {
53
57
  get encoding() { return "utf-8"; }
@@ -59,7 +63,7 @@ class TextEncoderP {
59
63
  const [source, destination] = args;
60
64
  checkArgsLength(args, 2, "TextEncoder", "encodeInto");
61
65
  let _source = "" + source;
62
- if (!(destination instanceof Uint8Array)) {
66
+ if (!(destination instanceof Uint8Array || isObjectType("Uint8Array", destination))) {
63
67
  throw new TypeError("Failed to execute 'encodeInto' on 'TextEncoder': parameter 2 is not of type 'Uint8Array'.");
64
68
  }
65
69
  let result = encodeText(_source, destination);
@@ -165,30 +169,30 @@ function encodeText(input, destination) {
165
169
  }
166
170
  const TextEncoderE = g["TextEncoder"] || TextEncoderP;
167
171
 
168
- var _a$a, _b$3;
172
+ var _a$b, _b$4;
169
173
  /** @internal */
170
- const state$h = Symbol( /* "TextDecoderState" */);
174
+ const state$k = Symbol( /* "TextDecoderState" */);
171
175
  class TextDecoderP {
172
176
  constructor(label = "utf-8", { fatal = false, ignoreBOM = false } = {}) {
173
177
  let _label = "" + label;
174
178
  if (["utf-8", "utf8", "unicode-1-1-utf-8"].indexOf(_label.toLowerCase()) === -1) {
175
179
  throw new RangeError(`Failed to construct 'TextDecoder': encoding ('${_label}') not implemented.`);
176
180
  }
177
- this[state$h] = new TextDecoderState();
178
- this[state$h].fatal = !!fatal;
179
- this[state$h].ignoreBOM = !!ignoreBOM;
181
+ this[state$k] = new TextDecoderState();
182
+ this[state$k].fatal = !!fatal;
183
+ this[state$k].ignoreBOM = !!ignoreBOM;
180
184
  }
181
185
  get encoding() { return "utf-8"; }
182
- get fatal() { return this[state$h].fatal; }
183
- get ignoreBOM() { return this[state$h].ignoreBOM; }
186
+ get fatal() { return this[state$k].fatal; }
187
+ get ignoreBOM() { return this[state$k].ignoreBOM; }
184
188
  decode(input, { stream = false } = {}) {
185
- const s = this[state$h];
189
+ const s = this[state$k];
186
190
  let bytes;
187
191
  if (input !== undefined) {
188
- if (input instanceof ArrayBuffer) {
192
+ if (isArrayBuffer(input)) {
189
193
  bytes = new Uint8Array(input);
190
194
  }
191
- else if (input instanceof Uint8Array) {
195
+ else if (input instanceof Uint8Array || isObjectType("Uint8Array", input)) {
192
196
  bytes = input;
193
197
  }
194
198
  else if (ArrayBuffer.isView(input)) {
@@ -321,11 +325,11 @@ class TextDecoderState {
321
325
  constructor() {
322
326
  this.fatal = false;
323
327
  this.ignoreBOM = false;
324
- this[_a$a] = 0;
325
- this[_b$3] = [];
328
+ this[_a$b] = 0;
329
+ this[_b$4] = [];
326
330
  }
327
331
  }
328
- _a$a = _bomDone, _b$3 = _partial;
332
+ _a$b = _bomDone, _b$4 = _partial;
329
333
  function getBytesPerSequence(byte) {
330
334
  return (byte > 0xEF) ? 4 : (byte > 0xDF) ? 3 : (byte > 0xBF) ? 2 : 1;
331
335
  }
@@ -346,7 +350,7 @@ const concatString = (res) => {
346
350
  const TextDecoderE = g["TextDecoder"] || TextDecoderP;
347
351
 
348
352
  /** @internal */
349
- const state$g = Symbol( /* "BlobState" */);
353
+ const state$j = Symbol( /* "BlobState" */);
350
354
  class BlobP {
351
355
  constructor(blobParts = [], options) {
352
356
  if (!(Array.isArray(blobParts) || (blobParts && typeof blobParts === "object" && Symbol.iterator in blobParts))) {
@@ -357,38 +361,38 @@ class BlobP {
357
361
  for (let i = 0; i < _blobParts.length; ++i) {
358
362
  let chunk = _blobParts[i];
359
363
  if (isPolyfillType("Blob", chunk)) {
360
- chunks.push(chunk[state$g][_buffer]);
364
+ chunks.push(chunk[state$j][_buffer]);
361
365
  }
362
- else if (chunk instanceof ArrayBuffer || ArrayBuffer.isView(chunk)) {
366
+ else if (isArrayBuffer(chunk) || ArrayBuffer.isView(chunk)) {
363
367
  chunks.push(BufferSource_toUint8Array(chunk));
364
368
  }
365
369
  else {
366
370
  chunks.push(encode$1("" + chunk));
367
371
  }
368
372
  }
369
- this[state$g] = new BlobState(concat(chunks));
370
- const s = this[state$g];
373
+ this[state$j] = new BlobState(concat(chunks));
374
+ const s = this[state$j];
371
375
  s.size = s[_buffer].length;
372
376
  let rawType = "" + ((options === null || options === void 0 ? void 0 : options.type) || "");
373
377
  s.type = /[^\u0020-\u007E]/.test(rawType) ? "" : rawType.toLowerCase();
374
378
  }
375
- get size() { return this[state$g].size; }
376
- get type() { return this[state$g].type; }
379
+ get size() { return this[state$j].size; }
380
+ get type() { return this[state$j].type; }
377
381
  arrayBuffer() {
378
- return Promise.resolve(clone(this[state$g][_buffer].buffer).buffer);
382
+ return Promise.resolve(clone(this[state$j][_buffer].buffer).buffer);
379
383
  }
380
384
  bytes() {
381
- return Promise.resolve(clone(this[state$g][_buffer].buffer));
385
+ return Promise.resolve(clone(this[state$j][_buffer].buffer));
382
386
  }
383
387
  slice(start, end, contentType) {
384
- 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
388
+ 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
385
389
  return new BlobP([sliced], { type: "" + (contentType !== null && contentType !== void 0 ? contentType : "") });
386
390
  }
387
391
  stream() {
388
392
  throw new TypeError("Failed to execute 'stream' on 'Blob': method not implemented.");
389
393
  }
390
394
  text() {
391
- return Promise.resolve(decode$1(this[state$g][_buffer]));
395
+ return Promise.resolve(decode$1(this[state$j][_buffer]));
392
396
  }
393
397
  /** @internal */ toString() { return "[object Blob]"; }
394
398
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Blob"] }; }
@@ -406,10 +410,10 @@ class BlobState {
406
410
  }
407
411
  /** @internal */
408
412
  function Blob_toUint8Array(blob) {
409
- return blob[state$g][_buffer];
413
+ return blob[state$j][_buffer];
410
414
  }
411
415
  function BufferSource_toUint8Array(buf) {
412
- return buf instanceof ArrayBuffer
416
+ return isArrayBuffer(buf)
413
417
  ? new Uint8Array(buf)
414
418
  : new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
415
419
  }
@@ -465,18 +469,18 @@ function Uint8Array_toBase64(input) {
465
469
  const BlobE = g["Blob"] || BlobP;
466
470
 
467
471
  /** @internal */
468
- const state$f = Symbol( /* "FileState" */);
472
+ const state$i = Symbol( /* "FileState" */);
469
473
  class FileP extends BlobP {
470
474
  constructor(...args) {
471
475
  const [fileBits, fileName, options] = args;
472
476
  checkArgsLength(args, 2, "File");
473
477
  super(fileBits, options);
474
- this[state$f] = new FileState();
475
- this[state$f].lastModified = +((options === null || options === void 0 ? void 0 : options.lastModified) ? new Date(options.lastModified) : new Date()) || 0;
476
- this[state$f].name = "" + fileName;
478
+ this[state$i] = new FileState();
479
+ this[state$i].lastModified = +((options === null || options === void 0 ? void 0 : options.lastModified) ? new Date(options.lastModified) : new Date()) || 0;
480
+ this[state$i].name = "" + fileName;
477
481
  }
478
- get lastModified() { return this[state$f].lastModified; }
479
- get name() { return this[state$f].name; }
482
+ get lastModified() { return this[state$i].lastModified; }
483
+ get name() { return this[state$i].name; }
480
484
  get webkitRelativePath() { return ""; }
481
485
  /** @internal */ toString() { return "[object File]"; }
482
486
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["File", "Blob"] }; }
@@ -491,39 +495,39 @@ class FileState {
491
495
  }
492
496
  const FileE = g["Blob"] ? g["File"] : FileP;
493
497
 
494
- var _a$9, _b$2, _c$1, _d$1, _e$1;
495
- /** @internal */ const state$e = Symbol( /* "EventState" */);
498
+ var _a$a, _b$3, _c$1, _d$1, _e$1;
499
+ /** @internal */ const state$h = Symbol( /* "EventState" */);
496
500
  class EventP {
497
501
  constructor(...args) {
498
502
  const [type, eventInitDict] = args;
499
503
  checkArgsLength(args, 1, new.target.name);
500
- this[state$e] = new EventState();
501
- const s = this[state$e];
504
+ this[state$h] = new EventState();
505
+ const s = this[state$h];
502
506
  s.type = "" + type;
503
507
  s.bubbles = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.bubbles);
504
508
  s.cancelable = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.cancelable);
505
509
  s.composed = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.composed);
506
510
  Object.defineProperty(this, "isTrusted", {
507
511
  enumerable: true,
508
- get: (function isTrusted() { return this[state$e][_isTrusted]; }).bind(this),
512
+ get: (function isTrusted() { return this[state$h][_isTrusted]; }).bind(this),
509
513
  });
510
514
  }
511
- get type() { return this[state$e].type; }
512
- get bubbles() { return this[state$e].bubbles; }
513
- get cancelable() { return this[state$e].cancelable; }
514
- get composed() { return this[state$e].composed; }
515
- get target() { return this[state$e].target; }
516
- get currentTarget() { return this[state$e].currentTarget; }
517
- get eventPhase() { return this[state$e].eventPhase; }
518
- get srcElement() { return this[state$e].target; }
519
- get cancelBubble() { return this[state$e].cancelBubble; }
520
- set cancelBubble(value) { this[state$e].cancelBubble = !!value; }
521
- get defaultPrevented() { return this[state$e].defaultPrevented; }
522
- get returnValue() { return this[state$e].returnValue; }
515
+ get type() { return this[state$h].type; }
516
+ get bubbles() { return this[state$h].bubbles; }
517
+ get cancelable() { return this[state$h].cancelable; }
518
+ get composed() { return this[state$h].composed; }
519
+ get target() { return this[state$h].target; }
520
+ get currentTarget() { return this[state$h].currentTarget; }
521
+ get eventPhase() { return this[state$h].eventPhase; }
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; }
523
527
  set returnValue(value) { if (!value) {
524
528
  this.preventDefault();
525
529
  } }
526
- get timeStamp() { return this[state$e].timeStamp; }
530
+ get timeStamp() { return this[state$h].timeStamp; }
527
531
  composedPath() {
528
532
  let path = !!this.target ? [this.target] : [];
529
533
  if (!!this.currentTarget && this.currentTarget !== this.target)
@@ -533,7 +537,7 @@ class EventP {
533
537
  initEvent(...args) {
534
538
  const [type, bubbles, cancelable] = args;
535
539
  checkArgsLength(args, 1, "Event", "initEvent");
536
- const s = this[state$e];
540
+ const s = this[state$h];
537
541
  if (s[_dispatched])
538
542
  return;
539
543
  s.type = "" + type;
@@ -541,7 +545,7 @@ class EventP {
541
545
  s.cancelable = !!cancelable;
542
546
  }
543
547
  preventDefault() {
544
- const s = this[state$e];
548
+ const s = this[state$h];
545
549
  if (s[_passive]) {
546
550
  console.warn(`Ignoring 'preventDefault()' call on event of type '${this.type}' from a listener registered as 'passive'.`);
547
551
  return;
@@ -553,7 +557,7 @@ class EventP {
553
557
  }
554
558
  }
555
559
  stopImmediatePropagation() {
556
- this[state$e][_stopImmediatePropagationCalled] = true;
560
+ this[state$h][_stopImmediatePropagationCalled] = true;
557
561
  this.cancelBubble = true;
558
562
  }
559
563
  stopPropagation() {
@@ -562,14 +566,14 @@ class EventP {
562
566
  /** @internal */ toString() { return "[object Event]"; }
563
567
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Event"] }; }
564
568
  }
565
- const properties$1 = {
569
+ const properties$2 = {
566
570
  NONE: { value: 0, enumerable: true },
567
571
  CAPTURING_PHASE: { value: 1, enumerable: true },
568
572
  AT_TARGET: { value: 2, enumerable: true },
569
573
  BUBBLING_PHASE: { value: 3, enumerable: true },
570
574
  };
571
- Object.defineProperties(EventP, properties$1);
572
- Object.defineProperties(EventP.prototype, properties$1);
575
+ Object.defineProperties(EventP, properties$2);
576
+ Object.defineProperties(EventP.prototype, properties$2);
573
577
  Class_setStringTag(EventP, "Event");
574
578
  /** @internal */ const _timeStamp = (new Date()).getTime();
575
579
  /** @internal */ const _isTrusted = Symbol();
@@ -591,17 +595,17 @@ class EventState {
591
595
  this.defaultPrevented = false;
592
596
  this.returnValue = true;
593
597
  this.timeStamp = (new Date()).getTime() - _timeStamp;
594
- this[_a$9] = false;
595
- this[_b$2] = false;
598
+ this[_a$a] = false;
599
+ this[_b$3] = false;
596
600
  this[_c$1] = false;
597
601
  this[_d$1] = false;
598
602
  this[_e$1] = false;
599
603
  }
600
604
  }
601
- _a$9 = _isTrusted, _b$2 = _passive, _c$1 = _dispatched, _d$1 = _preventDefaultCalled, _e$1 = _stopImmediatePropagationCalled;
605
+ _a$a = _isTrusted, _b$3 = _passive, _c$1 = _dispatched, _d$1 = _preventDefaultCalled, _e$1 = _stopImmediatePropagationCalled;
602
606
  /** @internal */
603
607
  function Event_setTrusted(event, isTrusted) {
604
- Object.defineProperty(event[state$e], _isTrusted, {
608
+ Object.defineProperty(event[state$h], _isTrusted, {
605
609
  value: isTrusted,
606
610
  writable: true,
607
611
  enumerable: true,
@@ -609,16 +613,16 @@ function Event_setTrusted(event, isTrusted) {
609
613
  });
610
614
  }
611
615
  const passive$1 = 0;
612
- const dispatched$2 = 1;
616
+ const dispatched$3 = 1;
613
617
  const preventDefaultCalled$1 = 2;
614
618
  const stopImmediatePropagationCalled$1 = 3;
615
619
  /** @internal */
616
620
  function Event_getEtField(event, field) {
617
- const s = event[state$e];
621
+ const s = event[state$h];
618
622
  switch (field) {
619
623
  case passive$1:
620
624
  return s[_passive];
621
- case dispatched$2:
625
+ case dispatched$3:
622
626
  return s[_dispatched];
623
627
  case preventDefaultCalled$1:
624
628
  return s[_preventDefaultCalled];
@@ -628,12 +632,12 @@ function Event_getEtField(event, field) {
628
632
  }
629
633
  /** @internal */
630
634
  function Event_setEtField(event, field, value) {
631
- const s = event[state$e];
635
+ const s = event[state$h];
632
636
  switch (field) {
633
637
  case passive$1:
634
638
  s[_passive] = value;
635
639
  break;
636
- case dispatched$2:
640
+ case dispatched$3:
637
641
  s[_dispatched] = value;
638
642
  break;
639
643
  case preventDefaultCalled$1:
@@ -647,30 +651,30 @@ function Event_setEtField(event, field, value) {
647
651
  /** @internal */
648
652
  function createInnerEvent(target, type, eventInitDict, isTrusted = true) {
649
653
  let event = new EventP(type, eventInitDict);
650
- event[state$e].target = target;
651
- event[state$e][_isTrusted] = isTrusted;
654
+ event[state$h].target = target;
655
+ event[state$h][_isTrusted] = isTrusted;
652
656
  return event;
653
657
  }
654
658
  const EventE = g["EventTarget"] ? g["Event"] : EventP;
655
659
 
656
- var _a$8;
660
+ var _a$9;
657
661
  const passive = 0;
658
- const dispatched$1 = 1;
662
+ const dispatched$2 = 1;
659
663
  const preventDefaultCalled = 2;
660
664
  const stopImmediatePropagationCalled = 3;
661
- /** @internal */ const state$d = Symbol( /* "EventTargetState" */);
665
+ /** @internal */ const state$g = Symbol( /* "EventTargetState" */);
662
666
  class EventTargetP {
663
667
  constructor() {
664
- this[state$d] = new EventTargetState(this);
665
- this[state$d].name = new.target.name;
668
+ this[state$g] = new EventTargetState(this);
669
+ this[state$g].name = new.target.name;
666
670
  }
667
671
  addEventListener(...args) {
668
672
  const [type, callback, options] = args;
669
- checkArgsLength(args, 2, this[state$d].name, "addEventListener");
673
+ checkArgsLength(args, 2, this[state$g].name, "addEventListener");
670
674
  if (typeof callback !== "function" && typeof callback !== "object" && typeof callback !== "undefined") {
671
- throw new TypeError(`Failed to execute 'addEventListener' on '${this[state$d].name}': parameter 2 is not of type 'Object'.`);
675
+ throw new TypeError(`Failed to execute 'addEventListener' on '${this[state$g].name}': parameter 2 is not of type 'Object'.`);
672
676
  }
673
- const s = this[state$d];
677
+ const s = this[state$g];
674
678
  const executor = new Executor(type, callback);
675
679
  executor.options.capture = typeof options === "boolean" ? options : !!(options === null || options === void 0 ? void 0 : options.capture);
676
680
  if (!s[_executors].some(x => x.equals(executor))) {
@@ -690,21 +694,21 @@ class EventTargetP {
690
694
  }
691
695
  dispatchEvent(...args) {
692
696
  const [event] = args;
693
- checkArgsLength(args, 1, this[state$d].name, "dispatchEvent");
697
+ checkArgsLength(args, 1, this[state$g].name, "dispatchEvent");
694
698
  if (!(event instanceof EventP)) {
695
- throw new TypeError(`Failed to execute 'dispatchEvent' on '${this[state$d].name}': parameter 1 is not of type 'Event'.`);
699
+ throw new TypeError(`Failed to execute 'dispatchEvent' on '${this[state$g].name}': parameter 1 is not of type 'Event'.`);
696
700
  }
697
701
  Event_setTrusted(event, false);
698
- event[state$e].target = this;
702
+ event[state$h].target = this;
699
703
  return EventTarget_fire(this, event);
700
704
  }
701
705
  removeEventListener(...args) {
702
706
  const [type, callback, options] = args;
703
- checkArgsLength(args, 2, this[state$d].name, "removeEventListener");
707
+ checkArgsLength(args, 2, this[state$g].name, "removeEventListener");
704
708
  if (typeof callback !== "function" && typeof callback !== "object" && typeof callback !== "undefined") {
705
- throw new TypeError(`Failed to execute 'removeEventListener' on '${this[state$d].name}': parameter 2 is not of type 'Object'.`);
709
+ throw new TypeError(`Failed to execute 'removeEventListener' on '${this[state$g].name}': parameter 2 is not of type 'Object'.`);
706
710
  }
707
- const s = this[state$d];
711
+ const s = this[state$g];
708
712
  const executor = new Executor(type, callback);
709
713
  executor.options.capture = typeof options === "boolean" ? options : !!(options === null || options === void 0 ? void 0 : options.capture);
710
714
  if (s[_executors].some(x => x.equals(executor))) {
@@ -721,20 +725,20 @@ const _executors = Symbol();
721
725
  class EventTargetState {
722
726
  constructor(target) {
723
727
  this.name = "EventTarget";
724
- this[_a$8] = [];
728
+ this[_a$9] = [];
725
729
  this.target = target;
726
730
  }
727
731
  }
728
- _a$8 = _executors;
732
+ _a$9 = _executors;
729
733
  /** @internal */
730
734
  function EventTarget_fire(target, event) {
731
- const s = target[state$d];
732
- const evs = event[state$e];
735
+ const s = target[state$g];
736
+ const evs = event[state$h];
733
737
  if (!event.target)
734
738
  evs.target = target;
735
739
  evs.currentTarget = target;
736
740
  evs.eventPhase = EventP.AT_TARGET;
737
- Event_setEtField(event, dispatched$1, true);
741
+ Event_setEtField(event, dispatched$2, true);
738
742
  let onceIndexes = [];
739
743
  for (let i = 0; i < s[_executors].length; ++i) {
740
744
  if (Event_getEtField(event, stopImmediatePropagationCalled))
@@ -764,11 +768,11 @@ function EventTarget_fire(target, event) {
764
768
  }
765
769
  evs.currentTarget = null;
766
770
  evs.eventPhase = EventP.NONE;
767
- Event_setEtField(event, dispatched$1, false);
771
+ Event_setEtField(event, dispatched$2, false);
768
772
  return !(event.cancelable && Event_getEtField(event, preventDefaultCalled));
769
773
  }
770
774
  function reply(target, signal, executor) {
771
- const s = target[state$d];
775
+ const s = target[state$g];
772
776
  const onAbort = () => {
773
777
  s[_executors] = s[_executors].filter(x => !x.equals(executor));
774
778
  signal.removeEventListener("abort", onAbort);
@@ -818,13 +822,13 @@ function executeFn(target, cb, ev) {
818
822
  const EventTargetE = g["EventTarget"] || EventTargetP;
819
823
 
820
824
  /** @internal */
821
- const state$c = Symbol( /* "ProgressEventState" */);
825
+ const state$f = Symbol( /* "ProgressEventState" */);
822
826
  class ProgressEventP extends EventP {
823
827
  constructor(type, eventInitDict) {
824
828
  var _a, _b;
825
829
  super(type, eventInitDict);
826
- this[state$c] = new ProgressEventState();
827
- const s = this[state$c];
830
+ this[state$f] = new ProgressEventState();
831
+ const s = this[state$f];
828
832
  s.lengthComputable = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.lengthComputable);
829
833
  s.loaded = Number((_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.loaded) !== null && _a !== void 0 ? _a : 0);
830
834
  s.total = Number((_b = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.total) !== null && _b !== void 0 ? _b : 0);
@@ -839,9 +843,9 @@ class ProgressEventP extends EventP {
839
843
  throw new TypeError(`Failed to construct 'ProgressEvent': Failed to read the '${errField}' property from 'ProgressEventInit': The provided double value is non-finite.`);
840
844
  }
841
845
  }
842
- get lengthComputable() { return getValue(this[state$c].lengthComputable); }
843
- get loaded() { return getValue(this[state$c].loaded); }
844
- get total() { return getValue(this[state$c].total); }
846
+ get lengthComputable() { return getValue(this[state$f].lengthComputable); }
847
+ get loaded() { return getValue(this[state$f].loaded); }
848
+ get total() { return getValue(this[state$f].total); }
845
849
  /** @internal */ toString() { return "[object ProgressEvent]"; }
846
850
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["ProgressEvent", "Event"] }; }
847
851
  }
@@ -859,10 +863,10 @@ function getValue(val) {
859
863
  }
860
864
  function createInnerProgressEvent(target, type, { lengthComputable = false, loaded = 0, total = 0, } = {}) {
861
865
  let event = new ProgressEventP(type);
862
- event[state$c].lengthComputable = lengthComputable;
863
- event[state$c].loaded = loaded;
864
- event[state$c].total = total;
865
- event[state$e].target = target;
866
+ event[state$f].lengthComputable = lengthComputable;
867
+ event[state$f].loaded = loaded;
868
+ event[state$f].total = total;
869
+ event[state$h].target = target;
866
870
  Event_setTrusted(event, true);
867
871
  return event;
868
872
  }
@@ -875,22 +879,22 @@ function emitProcessEvent(target, type, loaded = 0, total = 0) {
875
879
  });
876
880
  EventTarget_fire(target, event);
877
881
  }
878
- const ProgressEventE = g["EventTarget"] ? g["ProgressEvent"] : ProgressEventP;
882
+ g["EventTarget"] ? g["ProgressEvent"] : ProgressEventP;
879
883
 
880
- var _a$7;
884
+ var _a$8;
881
885
  /** @internal */
882
- const state$b = Symbol( /* "FileReaderState" */);
886
+ const state$e = Symbol( /* "FileReaderState" */);
883
887
  class FileReaderP extends EventTargetP {
884
888
  constructor() {
885
889
  super();
886
- this[state$b] = new FileReaderState(this);
890
+ this[state$e] = new FileReaderState(this);
887
891
  }
888
- get readyState() { return this[state$b].readyState; }
889
- get result() { return this[state$b].result; }
890
- get error() { return this[state$b].error; }
892
+ get readyState() { return this[state$e].readyState; }
893
+ get result() { return this[state$e].result; }
894
+ get error() { return this[state$e].error; }
891
895
  abort() {
892
896
  if (this.readyState === FileReaderP.LOADING) {
893
- const s = this[state$b];
897
+ const s = this[state$e];
894
898
  s.readyState = FileReaderP.DONE;
895
899
  s.result = null;
896
900
  s.error = new MPException("An ongoing operation was aborted, typically with a call to abort().", "AbortError");
@@ -899,7 +903,7 @@ class FileReaderP extends EventTargetP {
899
903
  }
900
904
  readAsArrayBuffer(...args) {
901
905
  read$1(this, "readAsArrayBuffer", args, blob => {
902
- this[state$b].result = Blob_toUint8Array(blob).buffer.slice(0);
906
+ this[state$e].result = Blob_toUint8Array(blob).buffer.slice(0);
903
907
  });
904
908
  }
905
909
  readAsBinaryString(...args) {
@@ -910,12 +914,12 @@ class FileReaderP extends EventTargetP {
910
914
  let char = buf[i];
911
915
  str.push(String.fromCharCode(char));
912
916
  }
913
- this[state$b].result = str.join("");
917
+ this[state$e].result = str.join("");
914
918
  });
915
919
  }
916
920
  readAsDataURL(...args) {
917
921
  read$1(this, "readAsDataURL", args, blob => {
918
- this[state$b].result = "data:" + (blob.type || "application/octet-stream") + ";base64," + Uint8Array_toBase64(Blob_toUint8Array(blob));
922
+ this[state$e].result = "data:" + (blob.type || "application/octet-stream") + ";base64," + Uint8Array_toBase64(Blob_toUint8Array(blob));
919
923
  });
920
924
  }
921
925
  readAsText(...args) {
@@ -927,41 +931,41 @@ class FileReaderP extends EventTargetP {
927
931
  console.error(`TypeError: Failed to execute 'readAsText' on 'FileReader': encoding ('${_encoding}') not implemented.`);
928
932
  }
929
933
  }
930
- this[state$b].result = decode$1(Blob_toUint8Array(blob));
934
+ this[state$e].result = decode$1(Blob_toUint8Array(blob));
931
935
  });
932
936
  }
933
- get onabort() { return this[state$b].onabort; }
934
- set onabort(value) { this[state$b].onabort = value; attach$1(this, "abort"); }
935
- get onerror() { return this[state$b].onerror; }
936
- set onerror(value) { this[state$b].onerror = value; attach$1(this, "error"); }
937
- get onload() { return this[state$b].onload; }
938
- set onload(value) { this[state$b].onload = value; attach$1(this, "load"); }
939
- get onloadend() { return this[state$b].onloadend; }
940
- set onloadend(value) { this[state$b].onloadend = value; attach$1(this, "loadend"); }
941
- get onloadstart() { return this[state$b].onloadstart; }
942
- set onloadstart(value) { this[state$b].onloadstart = value; attach$1(this, "loadstart"); }
943
- get onprogress() { return this[state$b].onprogress; }
944
- set onprogress(value) { this[state$b].onprogress = value; attach$1(this, "progress"); }
937
+ get onabort() { return this[state$e].onabort; }
938
+ set onabort(value) { this[state$e].onabort = value; attach$2(this, "abort"); }
939
+ get onerror() { return this[state$e].onerror; }
940
+ set onerror(value) { this[state$e].onerror = value; attach$2(this, "error"); }
941
+ get onload() { return this[state$e].onload; }
942
+ set onload(value) { this[state$e].onload = value; attach$2(this, "load"); }
943
+ get onloadend() { return this[state$e].onloadend; }
944
+ set onloadend(value) { this[state$e].onloadend = value; attach$2(this, "loadend"); }
945
+ get onloadstart() { return this[state$e].onloadstart; }
946
+ set onloadstart(value) { this[state$e].onloadstart = value; attach$2(this, "loadstart"); }
947
+ get onprogress() { return this[state$e].onprogress; }
948
+ set onprogress(value) { this[state$e].onprogress = value; attach$2(this, "progress"); }
945
949
  /** @internal */ toString() { return "[object FileReader]"; }
946
950
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["FileReader", "EventTarget"] }; }
947
951
  }
948
- const properties = {
952
+ const properties$1 = {
949
953
  EMPTY: { value: 0, enumerable: true },
950
954
  LOADING: { value: 1, enumerable: true },
951
955
  DONE: { value: 2, enumerable: true },
952
956
  };
953
- Object.defineProperties(FileReaderP, properties);
954
- Object.defineProperties(FileReaderP.prototype, properties);
957
+ Object.defineProperties(FileReaderP, properties$1);
958
+ Object.defineProperties(FileReaderP.prototype, properties$1);
955
959
  Class_setStringTag(FileReaderP, "FileReader");
956
960
  /** @internal */
957
- const _handlers$3 = Symbol();
961
+ const _handlers$4 = Symbol();
958
962
  /** @internal */
959
963
  class FileReaderState {
960
964
  constructor(target) {
961
965
  this.readyState = FileReaderP.EMPTY;
962
966
  this.result = null;
963
967
  this.error = null;
964
- this[_a$7] = getHandlers$3(this);
968
+ this[_a$8] = getHandlers$4(this);
965
969
  this.onabort = null;
966
970
  this.onerror = null;
967
971
  this.onload = null;
@@ -971,14 +975,14 @@ class FileReaderState {
971
975
  this.target = target;
972
976
  }
973
977
  }
974
- _a$7 = _handlers$3;
978
+ _a$8 = _handlers$4;
975
979
  function read$1(reader, kind, args, setResult) {
976
980
  const [blob] = args;
977
981
  checkArgsLength(args, 1, "FileReader", kind);
978
982
  if (!isPolyfillType("Blob", blob)) {
979
983
  throw new TypeError("Failed to execute '" + kind + "' on 'FileReader': parameter 1 is not of type 'Blob'.");
980
984
  }
981
- const s = reader[state$b];
985
+ const s = reader[state$e];
982
986
  s.error = null;
983
987
  s.readyState = FileReaderP.LOADING;
984
988
  emitProcessEvent(s.target, "loadstart", 0, blob.size);
@@ -998,14 +1002,14 @@ function read$1(reader, kind, args, setResult) {
998
1002
  emitProcessEvent(s.target, "loadend", !!s.result ? blob.size : 0, blob.size);
999
1003
  });
1000
1004
  }
1001
- function attach$1(reader, type) {
1002
- const s = reader[state$b];
1005
+ function attach$2(reader, type) {
1006
+ const s = reader[state$e];
1003
1007
  const fnName = ("on" + type);
1004
1008
  const cb = s[fnName];
1005
- const listener = s[_handlers$3][fnName];
1009
+ const listener = s[_handlers$4][fnName];
1006
1010
  attachFn(reader, type, cb, listener);
1007
1011
  }
1008
- function getHandlers$3(s) {
1012
+ function getHandlers$4(s) {
1009
1013
  return {
1010
1014
  onabort: (ev) => { executeFn(s.target, s.onabort, ev); },
1011
1015
  onerror: (ev) => { executeFn(s.target, s.onerror, ev); },
@@ -1017,14 +1021,14 @@ function getHandlers$3(s) {
1017
1021
  }
1018
1022
  const FileReaderE = g["Blob"] ? g["FileReader"] : FileReaderP;
1019
1023
 
1020
- var _a$6;
1021
- /** @internal */ const state$a = Symbol( /* "URLSearchParamsState" */);
1024
+ var _a$7;
1025
+ /** @internal */ const state$d = Symbol( /* "URLSearchParamsState" */);
1022
1026
  const checkArgsFn$2 = (args, required, funcName) => { checkArgsLength(args, required, "URLSearchParams", funcName); };
1023
1027
  class URLSearchParamsP {
1024
1028
  constructor(init) {
1025
- this[state$a] = new URLSearchParamsState();
1029
+ this[state$d] = new URLSearchParamsState();
1026
1030
  if (init !== undefined) {
1027
- if (isObjectType("URLSearchParams", init)) {
1031
+ if (isObjectType("URLSearchParams", init) || isPolyfillType("URLSearchParams", init)) {
1028
1032
  init.forEach((value, name) => { this.append(name, value); }, this);
1029
1033
  }
1030
1034
  else if (init && typeof init === "object") {
@@ -1070,18 +1074,18 @@ class URLSearchParamsP {
1070
1074
  }
1071
1075
  }
1072
1076
  }
1073
- get size() { return this[state$a][_urlspArray].length; }
1077
+ get size() { return this[state$d][_urlspArray].length; }
1074
1078
  append(...args) {
1075
1079
  const [name, value] = args;
1076
1080
  checkArgsFn$2(args, 2, "append");
1077
- this[state$a][_urlspArray].push(["" + name, normalizeValue$1(value)]);
1081
+ this[state$d][_urlspArray].push(["" + name, normalizeValue$1(value)]);
1078
1082
  }
1079
1083
  delete(...args) {
1080
1084
  const [name, value] = args;
1081
1085
  checkArgsFn$2(args, 1, "delete");
1082
1086
  let _name = "" + name;
1083
1087
  let index = -1;
1084
- let array = this[state$a][_urlspArray];
1088
+ let array = this[state$d][_urlspArray];
1085
1089
  let result = [];
1086
1090
  for (let i = 0; i < array.length; ++i) {
1087
1091
  let item = array[i];
@@ -1095,14 +1099,14 @@ class URLSearchParamsP {
1095
1099
  result.push(item);
1096
1100
  }
1097
1101
  if (index > -1) {
1098
- this[state$a][_urlspArray] = result;
1102
+ this[state$d][_urlspArray] = result;
1099
1103
  }
1100
1104
  }
1101
1105
  get(...args) {
1102
1106
  const [name] = args;
1103
1107
  checkArgsFn$2(args, 1, "get");
1104
1108
  let _name = "" + name;
1105
- let array = this[state$a][_urlspArray];
1109
+ let array = this[state$d][_urlspArray];
1106
1110
  for (let i = 0; i < array.length; ++i) {
1107
1111
  let item = array[i];
1108
1112
  if (item[0] === _name) {
@@ -1115,7 +1119,7 @@ class URLSearchParamsP {
1115
1119
  const [name] = args;
1116
1120
  checkArgsFn$2(args, 1, "getAll");
1117
1121
  let _name = "" + name;
1118
- let array = this[state$a][_urlspArray];
1122
+ let array = this[state$d][_urlspArray];
1119
1123
  let result = [];
1120
1124
  for (let i = 0; i < array.length; ++i) {
1121
1125
  let item = array[i];
@@ -1129,7 +1133,7 @@ class URLSearchParamsP {
1129
1133
  const [name, value] = args;
1130
1134
  checkArgsFn$2(args, 1, "has");
1131
1135
  let _name = "" + name;
1132
- let array = this[state$a][_urlspArray];
1136
+ let array = this[state$d][_urlspArray];
1133
1137
  for (let i = 0; i < array.length; ++i) {
1134
1138
  let item = array[i];
1135
1139
  if (item[0] === _name) {
@@ -1151,7 +1155,7 @@ class URLSearchParamsP {
1151
1155
  let _name = "" + name;
1152
1156
  let _value = normalizeValue$1(value);
1153
1157
  let index = -1;
1154
- let array = this[state$a][_urlspArray];
1158
+ let array = this[state$d][_urlspArray];
1155
1159
  let result = [];
1156
1160
  for (let i = 0; i < array.length; ++i) {
1157
1161
  let item = array[i];
@@ -1167,10 +1171,10 @@ class URLSearchParamsP {
1167
1171
  if (index === -1) {
1168
1172
  result.push([_name, _value]);
1169
1173
  }
1170
- this[state$a][_urlspArray] = result;
1174
+ this[state$d][_urlspArray] = result;
1171
1175
  }
1172
1176
  sort() {
1173
- this[state$a][_urlspArray].sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
1177
+ this[state$d][_urlspArray].sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
1174
1178
  }
1175
1179
  forEach(...args) {
1176
1180
  const [callbackfn, thisArg] = args;
@@ -1178,26 +1182,26 @@ class URLSearchParamsP {
1178
1182
  if (typeof callbackfn !== "function") {
1179
1183
  throw new TypeError("Failed to execute 'forEach' on 'URLSearchParams': parameter 1 is not of type 'Function'.");
1180
1184
  }
1181
- let array = this[state$a][_urlspArray];
1185
+ let array = this[state$d][_urlspArray];
1182
1186
  for (let i = 0; i < array.length; ++i) {
1183
1187
  let item = array[i];
1184
1188
  callbackfn.call(thisArg, item[1], item[0], this);
1185
1189
  }
1186
1190
  }
1187
1191
  entries() {
1188
- return this[state$a][_urlspArray].map(x => [x[0], x[1]]).values();
1192
+ return this[state$d][_urlspArray].map(x => [x[0], x[1]]).values();
1189
1193
  }
1190
1194
  keys() {
1191
- return this[state$a][_urlspArray].map(x => x[0]).values();
1195
+ return this[state$d][_urlspArray].map(x => x[0]).values();
1192
1196
  }
1193
1197
  values() {
1194
- return this[state$a][_urlspArray].map(x => x[1]).values();
1198
+ return this[state$d][_urlspArray].map(x => x[1]).values();
1195
1199
  }
1196
1200
  [Symbol.iterator]() {
1197
1201
  return this.entries();
1198
1202
  }
1199
1203
  toString() {
1200
- let array = this[state$a][_urlspArray];
1204
+ let array = this[state$d][_urlspArray];
1201
1205
  let result = [];
1202
1206
  for (let i = 0; i < array.length; ++i) {
1203
1207
  let item = array[i];
@@ -1214,10 +1218,10 @@ const _urlspArray = Symbol();
1214
1218
  /** @internal */
1215
1219
  class URLSearchParamsState {
1216
1220
  constructor() {
1217
- this[_a$6] = [];
1221
+ this[_a$7] = [];
1218
1222
  }
1219
1223
  }
1220
- _a$6 = _urlspArray;
1224
+ _a$7 = _urlspArray;
1221
1225
  function normalizeValue$1(value) {
1222
1226
  return typeof value === "string" ? value : (value !== null && value !== undefined && typeof value.toString === "function"
1223
1227
  ? value.toString()
@@ -1242,8 +1246,8 @@ function decode(str) {
1242
1246
  }
1243
1247
  const URLSearchParamsE = g["URLSearchParams"] || URLSearchParamsP;
1244
1248
 
1245
- var _a$5;
1246
- /** @internal */ const state$9 = Symbol( /* "FormDataState" */);
1249
+ var _a$6;
1250
+ /** @internal */ const state$c = Symbol( /* "FormDataState" */);
1247
1251
  const checkArgsFn$1 = (args, required, funcName) => { checkArgsLength(args, required, "FormData", funcName); };
1248
1252
  class FormDataP {
1249
1253
  constructor(form, submitter) {
@@ -1257,19 +1261,19 @@ class FormDataP {
1257
1261
  console.error("TypeError: Failed to construct 'FormData': parameter 1 and parameter 2 not implemented.");
1258
1262
  }
1259
1263
  }
1260
- this[state$9] = new FormDataState();
1264
+ this[state$c] = new FormDataState();
1261
1265
  }
1262
1266
  append(...args) {
1263
1267
  const [name, value, filename] = args;
1264
1268
  checkArgsFn$1(args, 2, "append");
1265
- this[state$9][_formData].push(normalizeArgs(name, value, filename));
1269
+ this[state$c][_formData].push(normalizeArgs(name, value, filename));
1266
1270
  }
1267
1271
  delete(...args) {
1268
1272
  const [name] = args;
1269
1273
  checkArgsFn$1(args, 1, "delete");
1270
1274
  let _name = "" + name;
1271
1275
  let index = -1;
1272
- let array = this[state$9][_formData];
1276
+ let array = this[state$c][_formData];
1273
1277
  let result = [];
1274
1278
  for (let i = 0; i < array.length; ++i) {
1275
1279
  let item = array[i];
@@ -1280,14 +1284,14 @@ class FormDataP {
1280
1284
  result.push(item);
1281
1285
  }
1282
1286
  if (index > -1) {
1283
- this[state$9][_formData] = result;
1287
+ this[state$c][_formData] = result;
1284
1288
  }
1285
1289
  }
1286
1290
  get(...args) {
1287
1291
  const [name] = args;
1288
1292
  checkArgsFn$1(args, 1, "get");
1289
1293
  let _name = "" + name;
1290
- let array = this[state$9][_formData];
1294
+ let array = this[state$c][_formData];
1291
1295
  for (let i = 0; i < array.length; ++i) {
1292
1296
  let item = array[i];
1293
1297
  if (item[0] === _name) {
@@ -1300,7 +1304,7 @@ class FormDataP {
1300
1304
  const [name] = args;
1301
1305
  checkArgsFn$1(args, 1, "getAll");
1302
1306
  let _name = "" + name;
1303
- let array = this[state$9][_formData];
1307
+ let array = this[state$c][_formData];
1304
1308
  let result = [];
1305
1309
  for (let i = 0; i < array.length; ++i) {
1306
1310
  let item = array[i];
@@ -1314,7 +1318,7 @@ class FormDataP {
1314
1318
  const [name] = args;
1315
1319
  checkArgsFn$1(args, 1, "has");
1316
1320
  let _name = "" + name;
1317
- let array = this[state$9][_formData];
1321
+ let array = this[state$c][_formData];
1318
1322
  for (let i = 0; i < array.length; ++i) {
1319
1323
  let item = array[i];
1320
1324
  if (item[0] === _name) {
@@ -1329,7 +1333,7 @@ class FormDataP {
1329
1333
  let _name = "" + name;
1330
1334
  let _args = normalizeArgs(name, value, filename);
1331
1335
  let index = -1;
1332
- let array = this[state$9][_formData];
1336
+ let array = this[state$c][_formData];
1333
1337
  let result = [];
1334
1338
  for (let i = 0; i < array.length; ++i) {
1335
1339
  let item = array[i];
@@ -1345,7 +1349,7 @@ class FormDataP {
1345
1349
  if (index === -1) {
1346
1350
  result.push(_args);
1347
1351
  }
1348
- this[state$9][_formData] = result;
1352
+ this[state$c][_formData] = result;
1349
1353
  }
1350
1354
  forEach(...args) {
1351
1355
  const [callbackfn, thisArg] = args;
@@ -1353,20 +1357,20 @@ class FormDataP {
1353
1357
  if (typeof callbackfn !== "function") {
1354
1358
  throw new TypeError("Failed to execute 'forEach' on 'FormData': parameter 1 is not of type 'Function'.");
1355
1359
  }
1356
- let array = this[state$9][_formData];
1360
+ let array = this[state$c][_formData];
1357
1361
  for (let i = 0; i < array.length; ++i) {
1358
1362
  let item = array[i];
1359
1363
  callbackfn.call(thisArg, item[1], item[0], thisArg);
1360
1364
  }
1361
1365
  }
1362
1366
  entries() {
1363
- return this[state$9][_formData].map(x => [x[0], x[1]]).values();
1367
+ return this[state$c][_formData].map(x => [x[0], x[1]]).values();
1364
1368
  }
1365
1369
  keys() {
1366
- return this[state$9][_formData].map(x => x[0]).values();
1370
+ return this[state$c][_formData].map(x => x[0]).values();
1367
1371
  }
1368
1372
  values() {
1369
- return this[state$9][_formData].map(x => x[1]).values();
1373
+ return this[state$c][_formData].map(x => x[1]).values();
1370
1374
  }
1371
1375
  [Symbol.iterator]() {
1372
1376
  return this.entries();
@@ -1380,17 +1384,17 @@ const _formData = Symbol();
1380
1384
  /** @internal */
1381
1385
  class FormDataState {
1382
1386
  constructor() {
1383
- this[_a$5] = [];
1387
+ this[_a$6] = [];
1384
1388
  }
1385
1389
  }
1386
- _a$5 = _formData;
1390
+ _a$6 = _formData;
1387
1391
  /** @internal */
1388
1392
  function FormData_toBlob(formData) {
1389
1393
  const boundary = "----formdata-mphttpx-" + Math.random();
1390
1394
  const p = `--${boundary}\r\nContent-Disposition: form-data; name="`;
1391
1395
  let chunks = [];
1392
- for (let i = 0; i < formData[state$9][_formData].length; ++i) {
1393
- let pair = formData[state$9][_formData][i];
1396
+ for (let i = 0; i < formData[state$c][_formData].length; ++i) {
1397
+ let pair = formData[state$c][_formData][i];
1394
1398
  let name = pair[0];
1395
1399
  let value = pair[1];
1396
1400
  if (typeof value === "string") {
@@ -1480,14 +1484,14 @@ function createFormDataFromBinaryText(text, boundary) {
1480
1484
  }
1481
1485
  const FormDataE = g["FormData"] || FormDataP;
1482
1486
 
1483
- var _a$4, _b$1;
1484
- /** @internal */ const state$8 = Symbol( /* "HeadersState" */);
1487
+ var _a$5, _b$2;
1488
+ /** @internal */ const state$b = Symbol( /* "HeadersState" */);
1485
1489
  const checkArgsFn = (args, required, funcName) => { checkArgsLength(args, required, "Headers", funcName); };
1486
1490
  class HeadersP {
1487
1491
  constructor(init) {
1488
- this[state$8] = new HeadersState();
1492
+ this[state$b] = new HeadersState();
1489
1493
  if (init !== undefined) {
1490
- if (isObjectType("Headers", init)) {
1494
+ if (isObjectType("Headers", init) || isPolyfillType("Headers", init)) {
1491
1495
  init.forEach((value, name) => { this.append(name, value); }, this);
1492
1496
  }
1493
1497
  else if (Array.isArray(init) || (init && typeof init === "object" && Symbol.iterator in init)) {
@@ -1516,15 +1520,15 @@ class HeadersP {
1516
1520
  }
1517
1521
  }
1518
1522
  }
1519
- this[state$8][_initialized] = true;
1523
+ this[state$b][_initialized] = true;
1520
1524
  }
1521
1525
  append(...args) {
1522
1526
  const [name, value] = args;
1523
1527
  checkArgsFn(args, 2, "append");
1524
- let _name = normalizeName(name, throwsFn(this[state$8][_initialized] ? "append" : ""));
1528
+ let _name = normalizeName(name, throwsFn(this[state$b][_initialized] ? "append" : ""));
1525
1529
  let _value = normalizeValue(value);
1526
1530
  let index = -1;
1527
- let array = this[state$8][_headersArray];
1531
+ let array = this[state$b][_headersArray];
1528
1532
  for (let i = 0; i < array.length; ++i) {
1529
1533
  let item = array[i];
1530
1534
  if (item[0] === _name) {
@@ -1542,7 +1546,7 @@ class HeadersP {
1542
1546
  checkArgsFn(args, 1, "delete");
1543
1547
  let _name = normalizeName(name, throwsFn("delete"));
1544
1548
  let index = -1;
1545
- let array = this[state$8][_headersArray];
1549
+ let array = this[state$b][_headersArray];
1546
1550
  let result = [];
1547
1551
  for (let i = 0; i < array.length; ++i) {
1548
1552
  let item = array[i];
@@ -1553,14 +1557,14 @@ class HeadersP {
1553
1557
  result.push(item);
1554
1558
  }
1555
1559
  if (index > -1) {
1556
- this[state$8][_headersArray] = result;
1560
+ this[state$b][_headersArray] = result;
1557
1561
  }
1558
1562
  }
1559
1563
  get(...args) {
1560
1564
  const [name] = args;
1561
1565
  checkArgsFn(args, 1, "get");
1562
1566
  let _name = normalizeName(name, throwsFn("get"));
1563
- let array = this[state$8][_headersArray];
1567
+ let array = this[state$b][_headersArray];
1564
1568
  for (let i = 0; i < array.length; ++i) {
1565
1569
  let item = array[i];
1566
1570
  if (item[0] === _name) {
@@ -1577,7 +1581,7 @@ class HeadersP {
1577
1581
  const [name] = args;
1578
1582
  checkArgsFn(args, 1, "has");
1579
1583
  let _name = normalizeName(name, throwsFn("has"));
1580
- let array = this[state$8][_headersArray];
1584
+ let array = this[state$b][_headersArray];
1581
1585
  for (let i = 0; i < array.length; ++i) {
1582
1586
  let item = array[i];
1583
1587
  if (item[0] === _name) {
@@ -1592,7 +1596,7 @@ class HeadersP {
1592
1596
  let _name = normalizeName(name, throwsFn("set"));
1593
1597
  let _value = normalizeValue(value);
1594
1598
  let index = -1;
1595
- let array = this[state$8][_headersArray];
1599
+ let array = this[state$b][_headersArray];
1596
1600
  for (let i = 0; i < array.length; ++i) {
1597
1601
  let item = array[i];
1598
1602
  if (item[0] === _name) {
@@ -1611,20 +1615,20 @@ class HeadersP {
1611
1615
  if (typeof callbackfn !== "function") {
1612
1616
  throw new TypeError("Failed to execute 'forEach' on 'Headers': parameter 1 is not of type 'Function'.");
1613
1617
  }
1614
- let array = this[state$8][_headersArray];
1618
+ let array = this[state$b][_headersArray];
1615
1619
  for (let i = 0; i < array.length; ++i) {
1616
1620
  let item = array[i];
1617
1621
  callbackfn.call(thisArg, item[1], item[0], this);
1618
1622
  }
1619
1623
  }
1620
1624
  entries() {
1621
- return this[state$8][_headersArray].map(x => [x[0], x[1]]).values();
1625
+ return this[state$b][_headersArray].map(x => [x[0], x[1]]).values();
1622
1626
  }
1623
1627
  keys() {
1624
- return this[state$8][_headersArray].map(x => x[0]).values();
1628
+ return this[state$b][_headersArray].map(x => x[0]).values();
1625
1629
  }
1626
1630
  values() {
1627
- return this[state$8][_headersArray].map(x => x[1]).values();
1631
+ return this[state$b][_headersArray].map(x => x[1]).values();
1628
1632
  }
1629
1633
  [Symbol.iterator]() {
1630
1634
  return this.entries();
@@ -1638,11 +1642,11 @@ Class_setStringTag(HeadersP, "Headers");
1638
1642
  /** @internal */
1639
1643
  class HeadersState {
1640
1644
  constructor() {
1641
- this[_a$4] = false;
1642
- this[_b$1] = [];
1645
+ this[_a$5] = false;
1646
+ this[_b$2] = [];
1643
1647
  }
1644
1648
  }
1645
- _a$4 = _initialized, _b$1 = _headersArray;
1649
+ _a$5 = _initialized, _b$2 = _headersArray;
1646
1650
  function throwsFn(kind) {
1647
1651
  return () => {
1648
1652
  throw new TypeError(`Failed to ${kind ? ("execute '" + kind + "' on") : "construct"} 'Headers': Invalid name`);
@@ -1686,23 +1690,23 @@ function parseHeaders(rawHeaders) {
1686
1690
  }
1687
1691
  const HeadersE = g["Headers"] || HeadersP;
1688
1692
 
1689
- var _a$3;
1690
- /** @internal */ const state$7 = Symbol( /* "BodyState" */);
1693
+ var _a$4;
1694
+ /** @internal */ const state$a = Symbol( /* "BodyState" */);
1691
1695
  class BodyImpl {
1692
1696
  /** @internal */
1693
1697
  constructor() {
1694
1698
  if (new.target === BodyImpl) {
1695
1699
  throw new TypeError("Failed to construct 'Body': Illegal constructor");
1696
1700
  }
1697
- this[state$7] = new BodyState();
1701
+ this[state$a] = new BodyState();
1698
1702
  }
1699
1703
  get body() {
1700
- if (!this[state$7][_body]) {
1704
+ if (!this[state$a][_body]) {
1701
1705
  return null;
1702
1706
  }
1703
- throw new TypeError(`Failed to access 'body' on '${this[state$7].name}': property not implemented.`);
1707
+ throw new TypeError(`Failed to access 'body' on '${this[state$a].name}': property not implemented.`);
1704
1708
  }
1705
- get bodyUsed() { return this[state$7].bodyUsed; }
1709
+ get bodyUsed() { return this[state$a].bodyUsed; }
1706
1710
  ;
1707
1711
  arrayBuffer() {
1708
1712
  const kind = "arrayBuffer";
@@ -1739,23 +1743,23 @@ class BodyState {
1739
1743
  constructor() {
1740
1744
  this.name = "Body";
1741
1745
  this.bodyUsed = false;
1742
- this[_a$3] = "";
1746
+ this[_a$4] = "";
1743
1747
  }
1744
1748
  }
1745
- _a$3 = _body;
1749
+ _a$4 = _body;
1746
1750
  /** @internal */
1747
1751
  function Body_init(body, payload) {
1748
1752
  const b = body;
1749
1753
  if (isObjectType("ReadableStream", payload)) {
1750
- throw new TypeError(`Failed to construct '${b[state$7].name}': ReadableStream not implemented.`);
1754
+ throw new TypeError(`Failed to construct '${b[state$a].name}': ReadableStream not implemented.`);
1751
1755
  }
1752
- b[state$7][_body] = convert(payload, true, type => { if (!b.headers.has("Content-Type")) {
1756
+ b[state$a][_body] = convert(payload, true, type => { if (!b.headers.has("Content-Type")) {
1753
1757
  b.headers.set("Content-Type", type);
1754
1758
  } });
1755
1759
  }
1756
1760
  /** @internal */
1757
1761
  function Body_toPayload(body) {
1758
- return body[state$7][_body];
1762
+ return body[state$a][_body];
1759
1763
  }
1760
1764
  function read(body, kind) {
1761
1765
  return new Promise((resolve, reject) => {
@@ -1768,7 +1772,7 @@ function read(body, kind) {
1768
1772
  });
1769
1773
  }
1770
1774
  function readSync(body, kind) {
1771
- const payload = body[state$7][_body];
1775
+ const payload = body[state$a][_body];
1772
1776
  if (kind === "arrayBuffer") {
1773
1777
  return convertBack("arraybuffer", payload);
1774
1778
  }
@@ -1805,7 +1809,7 @@ function readSync(body, kind) {
1805
1809
  }
1806
1810
  }
1807
1811
  function consumed(body, kind) {
1808
- const s = body[state$7];
1812
+ const s = body[state$a];
1809
1813
  if (!s[_body])
1810
1814
  return;
1811
1815
  if (s.bodyUsed) {
@@ -1822,13 +1826,13 @@ function convert(body, cloneArrayBuffer = true, setContentType, setContentLength
1822
1826
  setContentType("text/plain;charset=UTF-8");
1823
1827
  }
1824
1828
  }
1825
- else if (isObjectType("URLSearchParams", body)) {
1829
+ else if (isObjectType("URLSearchParams", body) || isPolyfillType("URLSearchParams", body)) {
1826
1830
  result = body.toString();
1827
1831
  if (setContentType) {
1828
1832
  setContentType("application/x-www-form-urlencoded;charset=UTF-8");
1829
1833
  }
1830
1834
  }
1831
- else if (body instanceof ArrayBuffer) {
1835
+ else if (isArrayBuffer(body)) {
1832
1836
  result = cloneArrayBuffer ? body.slice(0) : body;
1833
1837
  }
1834
1838
  else if (ArrayBuffer.isView(body)) {
@@ -1867,7 +1871,7 @@ function convert(body, cloneArrayBuffer = true, setContentType, setContentLength
1867
1871
  }
1868
1872
  /** @internal */
1869
1873
  function convertBack(type, data) {
1870
- let temp = !!data ? (typeof data !== "string" && !(data instanceof ArrayBuffer) ? JSON.stringify(data) : data) : "";
1874
+ let temp = !!data ? (typeof data !== "string" && !isArrayBuffer(data) ? JSON.stringify(data) : data) : "";
1871
1875
  if (!type || type === "text") {
1872
1876
  return typeof temp === "string" ? temp : decode$1(temp);
1873
1877
  }
@@ -1875,7 +1879,7 @@ function convertBack(type, data) {
1875
1879
  return JSON.parse(typeof temp === "string" ? temp : decode$1(temp));
1876
1880
  }
1877
1881
  else if (type === "arraybuffer") {
1878
- return temp instanceof ArrayBuffer ? temp.slice(0) : encode$1(temp).buffer;
1882
+ return isArrayBuffer(temp) ? temp.slice(0) : encode$1(temp).buffer;
1879
1883
  }
1880
1884
  else if (type === "blob") {
1881
1885
  return new BlobP([temp]);
@@ -1885,9 +1889,9 @@ function convertBack(type, data) {
1885
1889
  }
1886
1890
  }
1887
1891
 
1888
- var _a$2;
1892
+ var _a$3;
1889
1893
  /** @internal */
1890
- const state$6 = Symbol( /* "AbortSignalState" */);
1894
+ const state$9 = Symbol( /* "AbortSignalState" */);
1891
1895
  class AbortSignalP extends EventTargetP {
1892
1896
  static abort(reason) {
1893
1897
  let signal = createAbortSignal();
@@ -1944,40 +1948,40 @@ class AbortSignalP extends EventTargetP {
1944
1948
  throw new TypeError("Failed to construct 'AbortSignal': Illegal constructor");
1945
1949
  }
1946
1950
  super();
1947
- this[state$6] = new AbortSignalState(this);
1951
+ this[state$9] = new AbortSignalState(this);
1948
1952
  }
1949
- get aborted() { return this[state$6].aborted; }
1950
- get reason() { return this[state$6].reason; }
1953
+ get aborted() { return this[state$9].aborted; }
1954
+ get reason() { return this[state$9].reason; }
1951
1955
  throwIfAborted() {
1952
1956
  if (this.aborted) {
1953
1957
  throw this.reason;
1954
1958
  }
1955
1959
  }
1956
- get onabort() { return this[state$6].onabort; }
1960
+ get onabort() { return this[state$9].onabort; }
1957
1961
  set onabort(value) {
1958
- this[state$6].onabort = value;
1959
- attachFn(this, "abort", value, this[state$6][_handlers$2].onabort);
1962
+ this[state$9].onabort = value;
1963
+ attachFn(this, "abort", value, this[state$9][_handlers$3].onabort);
1960
1964
  }
1961
1965
  /** @internal */ toString() { return "[object AbortSignal]"; }
1962
1966
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortSignal", "EventTarget"] }; }
1963
1967
  }
1964
1968
  Class_setStringTag(AbortSignalP, "AbortSignal");
1965
1969
  /** @internal */
1966
- const _handlers$2 = Symbol();
1970
+ const _handlers$3 = Symbol();
1967
1971
  /** @internal */
1968
1972
  class AbortSignalState {
1969
1973
  constructor(target) {
1970
1974
  this.aborted = false;
1971
1975
  this.reason = undefined;
1972
- this[_a$2] = getHandlers$2(this);
1976
+ this[_a$3] = getHandlers$3(this);
1973
1977
  this.onabort = null;
1974
1978
  this.target = target;
1975
1979
  }
1976
1980
  }
1977
- _a$2 = _handlers$2;
1981
+ _a$3 = _handlers$3;
1978
1982
  /** @internal */
1979
1983
  function AbortSignal_abort(signal, reason, notify = true, isTrusted = true) {
1980
- const s = signal[state$6];
1984
+ const s = signal[state$9];
1981
1985
  if (!s.aborted) {
1982
1986
  s.aborted = true;
1983
1987
  s.reason = reason !== null && reason !== void 0 ? reason : (new MPException("signal is aborted without reason", "AbortError"));
@@ -1987,7 +1991,7 @@ function AbortSignal_abort(signal, reason, notify = true, isTrusted = true) {
1987
1991
  }
1988
1992
  }
1989
1993
  }
1990
- function getHandlers$2(s) {
1994
+ function getHandlers$3(s) {
1991
1995
  return {
1992
1996
  onabort: (ev) => { executeFn(s.target, s.onabort, ev); },
1993
1997
  };
@@ -1995,21 +1999,21 @@ function getHandlers$2(s) {
1995
1999
  /** @internal */
1996
2000
  function createAbortSignal() {
1997
2001
  let signal = Object.create(AbortSignalP.prototype);
1998
- signal[state$d] = new EventTargetState(signal);
1999
- signal[state$6] = new AbortSignalState(signal);
2002
+ signal[state$g] = new EventTargetState(signal);
2003
+ signal[state$9] = new AbortSignalState(signal);
2000
2004
  return signal;
2001
2005
  }
2002
2006
  const AbortSignalE = g["AbortSignal"] || AbortSignalP;
2003
2007
 
2004
2008
  /** @internal */
2005
- const state$5 = Symbol( /* "AbortControllerState" */);
2009
+ const state$8 = Symbol( /* "AbortControllerState" */);
2006
2010
  class AbortControllerP {
2007
2011
  constructor() {
2008
- this[state$5] = new AbortControllerState();
2012
+ this[state$8] = new AbortControllerState();
2009
2013
  }
2010
- get signal() { return this[state$5].signal; }
2014
+ get signal() { return this[state$8].signal; }
2011
2015
  abort(reason) {
2012
- AbortSignal_abort(this[state$5].signal, reason);
2016
+ AbortSignal_abort(this[state$8].signal, reason);
2013
2017
  }
2014
2018
  /** @internal */ toString() { return "[object AbortController]"; }
2015
2019
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortController"] }; }
@@ -2023,15 +2027,15 @@ class AbortControllerState {
2023
2027
  }
2024
2028
  const AbortControllerE = g["AbortController"] || AbortControllerP;
2025
2029
 
2026
- /** @internal */ const state$4 = Symbol( /* "RequestState" */);
2030
+ /** @internal */ const state$7 = Symbol( /* "RequestState" */);
2027
2031
  class RequestP extends BodyImpl {
2028
2032
  constructor(...args) {
2029
2033
  const [input, init] = args;
2030
2034
  checkArgsLength(args, 1, "Request");
2031
2035
  super();
2032
- this[state$7].name = "Request";
2033
- this[state$4] = new RequestState();
2034
- const s = this[state$4];
2036
+ this[state$a].name = "Request";
2037
+ this[state$7] = new RequestState();
2038
+ const s = this[state$7];
2035
2039
  let _init = init !== null && init !== void 0 ? init : {};
2036
2040
  if (typeof _init !== "object") {
2037
2041
  throw new TypeError("Failed to construct 'Request': The provided value is not of type 'RequestInit'.");
@@ -2048,7 +2052,7 @@ class RequestP extends BodyImpl {
2048
2052
  }
2049
2053
  s.method = input.method;
2050
2054
  s.mode = input.mode;
2051
- let inputSignal = input[state$4].signal;
2055
+ let inputSignal = input[state$7].signal;
2052
2056
  if (inputSignal) {
2053
2057
  s.signal = inputSignal;
2054
2058
  }
@@ -2056,7 +2060,7 @@ class RequestP extends BodyImpl {
2056
2060
  let payload = Body_toPayload(input);
2057
2061
  if (!body && payload !== "") {
2058
2062
  body = payload;
2059
- input[state$7].bodyUsed = true;
2063
+ input[state$a].bodyUsed = true;
2060
2064
  }
2061
2065
  }
2062
2066
  else {
@@ -2100,31 +2104,31 @@ class RequestP extends BodyImpl {
2100
2104
  }
2101
2105
  }
2102
2106
  }
2103
- get cache() { return this[state$4].cache; }
2104
- get credentials() { return this[state$4].credentials; }
2105
- get destination() { return this[state$4].destination; }
2107
+ get cache() { return this[state$7].cache; }
2108
+ get credentials() { return this[state$7].credentials; }
2109
+ get destination() { return this[state$7].destination; }
2106
2110
  get headers() {
2107
- const s = this[state$4];
2111
+ const s = this[state$7];
2108
2112
  if (!s.headers) {
2109
2113
  s.headers = new HeadersP();
2110
2114
  }
2111
2115
  return s.headers;
2112
2116
  }
2113
- get integrity() { return this[state$4].integrity; }
2114
- get keepalive() { return this[state$4].keepalive; }
2115
- get method() { return this[state$4].method; }
2116
- get mode() { return this[state$4].mode; }
2117
- get redirect() { return this[state$4].redirect; }
2118
- get referrer() { return this[state$4].referrer; }
2119
- get referrerPolicy() { return this[state$4].referrerPolicy; }
2117
+ get integrity() { return this[state$7].integrity; }
2118
+ get keepalive() { return this[state$7].keepalive; }
2119
+ get method() { return this[state$7].method; }
2120
+ get mode() { return this[state$7].mode; }
2121
+ get redirect() { return this[state$7].redirect; }
2122
+ get referrer() { return this[state$7].referrer; }
2123
+ get referrerPolicy() { return this[state$7].referrerPolicy; }
2120
2124
  get signal() {
2121
- const s = this[state$4];
2125
+ const s = this[state$7];
2122
2126
  if (!s.signal) {
2123
2127
  s.signal = (new AbortControllerP()).signal;
2124
2128
  }
2125
2129
  return s.signal;
2126
2130
  }
2127
- get url() { return this[state$4].url; }
2131
+ get url() { return this[state$7].url; }
2128
2132
  clone() {
2129
2133
  var _a;
2130
2134
  if (this.bodyUsed) {
@@ -2163,7 +2167,7 @@ const RequestE = g["Request"] || RequestP;
2163
2167
 
2164
2168
  // @ts-nocheck
2165
2169
  /** @internal */
2166
- const mp$2 = (() => {
2170
+ const mp$3 = (() => {
2167
2171
  let u = "undefined", r = "request", f = "function";
2168
2172
  let mp;
2169
2173
  mp =
@@ -2188,7 +2192,7 @@ const mp$2 = (() => {
2188
2192
  return mp;
2189
2193
  })();
2190
2194
 
2191
- const request = mp$2 ? mp$2.request : function errorRequest(options) {
2195
+ const request = mp$3 ? mp$3.request : function errorRequest(options) {
2192
2196
  const errMsg = "NOT_SUPPORTED_ERR";
2193
2197
  const errno = 9;
2194
2198
  const err = {
@@ -2215,8 +2219,8 @@ const request = mp$2 ? mp$2.request : function errorRequest(options) {
2215
2219
  throw new ReferenceError("request is not defined");
2216
2220
  };
2217
2221
 
2218
- var _a$1;
2219
- /** @internal */ const state$3 = Symbol( /* "XMLHttpRequestEventTargetState" */);
2222
+ var _a$2;
2223
+ /** @internal */ const state$6 = Symbol( /* "XMLHttpRequestEventTargetState" */);
2220
2224
  class XMLHttpRequestEventTargetP extends EventTargetP {
2221
2225
  /** @internal */
2222
2226
  constructor() {
@@ -2224,35 +2228,35 @@ class XMLHttpRequestEventTargetP extends EventTargetP {
2224
2228
  throw new TypeError("Failed to construct 'XMLHttpRequestEventTarget': Illegal constructor");
2225
2229
  }
2226
2230
  super();
2227
- this[state$3] = new XMLHttpRequestEventTargetState(this);
2228
- }
2229
- get onabort() { return this[state$3].onabort; }
2230
- set onabort(value) { this[state$3].onabort = value; attach(this, "abort"); }
2231
- get onerror() { return this[state$3].onerror; }
2232
- set onerror(value) { this[state$3].onerror = value; attach(this, "error"); }
2233
- get onload() { return this[state$3].onload; }
2234
- set onload(value) { this[state$3].onload = value; attach(this, "load"); }
2235
- get onloadend() { return this[state$3].onloadend; }
2236
- set onloadend(value) { this[state$3].onloadend = value; attach(this, "loadend"); }
2237
- get onloadstart() { return this[state$3].onloadstart; }
2238
- set onloadstart(value) { this[state$3].onloadstart = value; attach(this, "loadstart"); }
2239
- get onprogress() { return this[state$3].onprogress; }
2240
- set onprogress(value) { this[state$3].onprogress = value; attach(this, "progress"); }
2241
- get ontimeout() { return this[state$3].ontimeout; }
2242
- set ontimeout(value) { this[state$3].ontimeout = value; attach(this, "timeout"); }
2231
+ this[state$6] = new XMLHttpRequestEventTargetState(this);
2232
+ }
2233
+ get onabort() { return this[state$6].onabort; }
2234
+ set onabort(value) { this[state$6].onabort = value; attach$1(this, "abort"); }
2235
+ get onerror() { return this[state$6].onerror; }
2236
+ set onerror(value) { this[state$6].onerror = value; attach$1(this, "error"); }
2237
+ get onload() { return this[state$6].onload; }
2238
+ set onload(value) { this[state$6].onload = value; attach$1(this, "load"); }
2239
+ get onloadend() { return this[state$6].onloadend; }
2240
+ set onloadend(value) { this[state$6].onloadend = value; attach$1(this, "loadend"); }
2241
+ get onloadstart() { return this[state$6].onloadstart; }
2242
+ set onloadstart(value) { this[state$6].onloadstart = value; attach$1(this, "loadstart"); }
2243
+ get onprogress() { return this[state$6].onprogress; }
2244
+ set onprogress(value) { this[state$6].onprogress = value; attach$1(this, "progress"); }
2245
+ get ontimeout() { return this[state$6].ontimeout; }
2246
+ set ontimeout(value) { this[state$6].ontimeout = value; attach$1(this, "timeout"); }
2243
2247
  /** @internal */ toString() { return "[object XMLHttpRequestEventTarget]"; }
2244
2248
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestEventTarget", "EventTarget"] }; }
2245
2249
  }
2246
2250
  Class_setStringTag(XMLHttpRequestEventTargetP, "XMLHttpRequestEventTarget");
2247
2251
  /** @internal */
2248
- const _handlers$1 = Symbol();
2252
+ const _handlers$2 = Symbol();
2249
2253
  /** @internal */
2250
2254
  class XMLHttpRequestEventTargetState {
2251
2255
  /**
2252
2256
  * @param _target XMLHttpRequestEventTarget
2253
2257
  */
2254
2258
  constructor(_target) {
2255
- this[_a$1] = getHandlers$1(this);
2259
+ this[_a$2] = getHandlers$2(this);
2256
2260
  this.onabort = null;
2257
2261
  this.onerror = null;
2258
2262
  this.onload = null;
@@ -2263,15 +2267,15 @@ class XMLHttpRequestEventTargetState {
2263
2267
  this.target = _target;
2264
2268
  }
2265
2269
  }
2266
- _a$1 = _handlers$1;
2267
- function attach(target, type) {
2268
- const s = target[state$3];
2270
+ _a$2 = _handlers$2;
2271
+ function attach$1(target, type) {
2272
+ const s = target[state$6];
2269
2273
  const fnName = ("on" + type);
2270
2274
  const cb = s[fnName];
2271
- const listener = s[_handlers$1][fnName];
2275
+ const listener = s[_handlers$2][fnName];
2272
2276
  attachFn(target, type, cb, listener);
2273
2277
  }
2274
- function getHandlers$1(s) {
2278
+ function getHandlers$2(s) {
2275
2279
  return {
2276
2280
  onabort: (ev) => { executeFn(s.target, s.onabort, ev); },
2277
2281
  onerror: (ev) => { executeFn(s.target, s.onerror, ev); },
@@ -2378,50 +2382,50 @@ Class_setStringTag(XMLHttpRequestUploadP, "XMLHttpRequestUpload");
2378
2382
  /** @internal */
2379
2383
  function createXMLHttpRequestUpload() {
2380
2384
  let upload = Object.create(XMLHttpRequestUploadP.prototype);
2381
- upload[state$d] = new EventTargetState(upload);
2382
- upload[state$3] = new XMLHttpRequestEventTargetState(upload);
2385
+ upload[state$g] = new EventTargetState(upload);
2386
+ upload[state$6] = new XMLHttpRequestEventTargetState(upload);
2383
2387
  return upload;
2384
2388
  }
2385
2389
 
2386
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2387
- const mp$1 = { request: request };
2388
- const setRequest = (request) => { mp$1.request = request; };
2390
+ var _a$1, _b$1, _c, _d, _e, _f, _g, _h, _j, _k;
2391
+ const mp$2 = { request: request };
2392
+ const setRequest = (request) => { mp$2.request = request; };
2389
2393
  /** @internal */
2390
- const state$2 = Symbol( /* "XMLHttpRequestState" */);
2394
+ const state$5 = Symbol( /* "XMLHttpRequestState" */);
2391
2395
  class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
2392
2396
  constructor() {
2393
2397
  super();
2394
- this[state$2] = new XMLHttpRequestState(this);
2398
+ this[state$5] = new XMLHttpRequestState(this);
2395
2399
  }
2396
- get readyState() { return this[state$2].readyState; }
2397
- get response() { return this[state$2].response; }
2400
+ get readyState() { return this[state$5].readyState; }
2401
+ get response() { return this[state$5].response; }
2398
2402
  get responseText() { return (!this.responseType || this.responseType === "text") ? this.response : ""; }
2399
- get responseType() { return this[state$2].responseType; }
2400
- set responseType(value) { this[state$2].responseType = normalizeResponseType(value); }
2401
- get responseURL() { return this[state$2].responseURL; }
2403
+ get responseType() { return this[state$5].responseType; }
2404
+ set responseType(value) { this[state$5].responseType = normalizeResponseType(value); }
2405
+ get responseURL() { return this[state$5].responseURL; }
2402
2406
  get responseXML() { return null; }
2403
- get status() { return this[state$2].status; }
2407
+ get status() { return this[state$5].status; }
2404
2408
  get statusText() {
2405
2409
  if (this.readyState === XMLHttpRequestImpl.UNSENT || this.readyState === XMLHttpRequestImpl.OPENED)
2406
2410
  return "";
2407
- return this[state$2].statusText || statusTextMap(this.status);
2411
+ return this[state$5].statusText || statusTextMap(this.status);
2408
2412
  }
2409
- get timeout() { return this[state$2].timeout; }
2410
- set timeout(value) { this[state$2].timeout = value > 0 ? value : 0; }
2413
+ get timeout() { return this[state$5].timeout; }
2414
+ set timeout(value) { this[state$5].timeout = value > 0 ? value : 0; }
2411
2415
  get upload() {
2412
- const s = this[state$2];
2416
+ const s = this[state$5];
2413
2417
  if (!s.upload) {
2414
2418
  s.upload = createXMLHttpRequestUpload();
2415
2419
  }
2416
2420
  return s.upload;
2417
2421
  }
2418
- get withCredentials() { return this[state$2].withCredentials; }
2419
- set withCredentials(value) { this[state$2].withCredentials = !!value; }
2422
+ get withCredentials() { return this[state$5].withCredentials; }
2423
+ set withCredentials(value) { this[state$5].withCredentials = !!value; }
2420
2424
  abort() {
2421
2425
  clearRequest(this);
2422
2426
  }
2423
2427
  getAllResponseHeaders() {
2424
- const headers = this[state$2][_responseHeaders];
2428
+ const headers = this[state$5][_responseHeaders];
2425
2429
  if (!headers)
2426
2430
  return "";
2427
2431
  let result = [];
@@ -2431,9 +2435,9 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
2431
2435
  getResponseHeader(...args) {
2432
2436
  const [name] = args;
2433
2437
  checkArgsLength(args, 1, "XMLHttpRequest", "getResponseHeader");
2434
- if (!this[state$2][_responseHeaders])
2438
+ if (!this[state$5][_responseHeaders])
2435
2439
  return null;
2436
- return this[state$2][_responseHeaders].get(name);
2440
+ return this[state$5][_responseHeaders].get(name);
2437
2441
  }
2438
2442
  open(...args) {
2439
2443
  const [method, url, async = true, username = null, password = null] = args;
@@ -2441,7 +2445,7 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
2441
2445
  if (!async) {
2442
2446
  console.warn("Synchronous XMLHttpRequest is not supported because of its detrimental effects to the end user's experience.");
2443
2447
  }
2444
- const s = this[state$2];
2448
+ const s = this[state$5];
2445
2449
  clearRequest(this, false);
2446
2450
  s[_method] = normalizeMethod(method);
2447
2451
  s[_requestURL] = "" + url;
@@ -2459,12 +2463,12 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
2459
2463
  overrideMimeType(...args) {
2460
2464
  const [mime] = args;
2461
2465
  checkArgsLength(args, 1, "XMLHttpRequest", "overrideMimeType");
2462
- if (this[state$2][_inAfterOpenBeforeSend]) {
2466
+ if (this[state$5][_inAfterOpenBeforeSend]) {
2463
2467
  console.error(`TypeError: Failed to execute 'overrideMimeType' on 'XMLHttpRequest': mimeType ('${mime}') not implemented.`);
2464
2468
  }
2465
2469
  }
2466
2470
  send(body) {
2467
- const s = this[state$2];
2471
+ const s = this[state$5];
2468
2472
  if (!s[_inAfterOpenBeforeSend] || s.readyState !== XMLHttpRequestImpl.OPENED) {
2469
2473
  throw new MPException("Failed to execute 'send' on 'XMLHttpRequest': The object's state must be OPENED.", "InvalidStateError");
2470
2474
  }
@@ -2497,7 +2501,7 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
2497
2501
  };
2498
2502
  // Alipay Mini Program
2499
2503
  options.headers = options.header;
2500
- s[_requestTask] = mp$1.request(options);
2504
+ s[_requestTask] = mp$2.request(options);
2501
2505
  emitProcessEvent(this, "loadstart");
2502
2506
  if (processContentLength && s.upload) {
2503
2507
  emitProcessEvent(this.upload, "loadstart", 0, contentLength);
@@ -2524,7 +2528,7 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
2524
2528
  setRequestHeader(...args) {
2525
2529
  const [name, value] = args;
2526
2530
  checkArgsLength(args, 2, "XMLHttpRequest", "setRequestHeader");
2527
- const s = this[state$2];
2531
+ const s = this[state$5];
2528
2532
  if (!s[_inAfterOpenBeforeSend] || s.readyState !== XMLHttpRequestImpl.OPENED) {
2529
2533
  throw new MPException("Failed to execute 'setRequestHeader' on 'XMLHttpRequest': The object's state must be OPENED.", "InvalidStateError");
2530
2534
  }
@@ -2533,10 +2537,10 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
2533
2537
  });
2534
2538
  s[_requestHeaders].append(_name, value);
2535
2539
  }
2536
- get onreadystatechange() { return this[state$2].onreadystatechange; }
2540
+ get onreadystatechange() { return this[state$5].onreadystatechange; }
2537
2541
  set onreadystatechange(value) {
2538
- this[state$2].onreadystatechange = value;
2539
- attachFn(this, "readystatechange", value, this[state$2][_handlers].onreadystatechange);
2542
+ this[state$5].onreadystatechange = value;
2543
+ attachFn(this, "readystatechange", value, this[state$5][_handlers$1].onreadystatechange);
2540
2544
  }
2541
2545
  /** @internal */ toString() { return "[object XMLHttpRequest]"; }
2542
2546
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequest", "XMLHttpRequestEventTarget", "EventTarget"] }; }
@@ -2544,7 +2548,7 @@ class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
2544
2548
  Object.defineProperties(XMLHttpRequestImpl, XHR_properties);
2545
2549
  Object.defineProperties(XMLHttpRequestImpl.prototype, XHR_properties);
2546
2550
  Class_setStringTag(XMLHttpRequestImpl, "XMLHttpRequest");
2547
- /** @internal */ const _handlers = Symbol();
2551
+ /** @internal */ const _handlers$1 = Symbol();
2548
2552
  /** @internal */ const _inAfterOpenBeforeSend = Symbol();
2549
2553
  /** @internal */ const _resetPending = Symbol();
2550
2554
  /** @internal */ const _timeoutId = Symbol();
@@ -2565,9 +2569,9 @@ class XMLHttpRequestState {
2565
2569
  this.statusText = "";
2566
2570
  this.timeout = 0;
2567
2571
  this.withCredentials = false;
2568
- this[_a] = getHandlers(this);
2572
+ this[_a$1] = getHandlers$1(this);
2569
2573
  this.onreadystatechange = null;
2570
- this[_b] = false;
2574
+ this[_b$1] = false;
2571
2575
  this[_c] = false;
2572
2576
  this[_d] = 0;
2573
2577
  this[_e] = "";
@@ -2579,8 +2583,8 @@ class XMLHttpRequestState {
2579
2583
  this.target = target;
2580
2584
  }
2581
2585
  }
2582
- _a = _handlers, _b = _inAfterOpenBeforeSend, _c = _resetPending, _d = _timeoutId, _e = _requestURL, _f = _method, _g = _requestHeaders, _h = _responseHeaders, _j = _responseContentLength, _k = _requestTask;
2583
- function getHandlers(s) {
2586
+ _a$1 = _handlers$1, _b$1 = _inAfterOpenBeforeSend, _c = _resetPending, _d = _timeoutId, _e = _requestURL, _f = _method, _g = _requestHeaders, _h = _responseHeaders, _j = _responseContentLength, _k = _requestTask;
2587
+ function getHandlers$1(s) {
2584
2588
  return {
2585
2589
  onreadystatechange: (ev) => { executeFn(s.target, s.onreadystatechange, ev); },
2586
2590
  };
@@ -2589,7 +2593,7 @@ function normalizeDataType(responseType) {
2589
2593
  return (responseType === "blob" || responseType === "arraybuffer") ? "arraybuffer" : "text";
2590
2594
  }
2591
2595
  function requestSuccess(res) {
2592
- const s = this[state$2];
2596
+ const s = this[state$5];
2593
2597
  s.responseURL = s[_requestURL];
2594
2598
  s.status = "statusCode" in res ? res.statusCode : "status" in res ? res.status : 200;
2595
2599
  s[_responseHeaders] = new HeadersP(("header" in res ? res.header : "headers" in res ? res.headers : undefined));
@@ -2630,7 +2634,7 @@ function requestFail(err) {
2630
2634
  });
2631
2635
  return;
2632
2636
  }
2633
- const s = this[state$2];
2637
+ const s = this[state$5];
2634
2638
  s.status = 0;
2635
2639
  s.statusText = "errMsg" in err ? err.errMsg : "errorMessage" in err ? err.errorMessage : "";
2636
2640
  if (!s[_inAfterOpenBeforeSend] && s.readyState !== XMLHttpRequestImpl.UNSENT && s.readyState !== XMLHttpRequestImpl.DONE) {
@@ -2639,7 +2643,7 @@ function requestFail(err) {
2639
2643
  }
2640
2644
  }
2641
2645
  function requestComplete() {
2642
- const s = this[state$2];
2646
+ const s = this[state$5];
2643
2647
  s[_requestTask] = null;
2644
2648
  if (!s[_inAfterOpenBeforeSend] && (s.readyState === XMLHttpRequestImpl.OPENED || s.readyState === XMLHttpRequestImpl.LOADING)) {
2645
2649
  setReadyStateAndNotify(this, XMLHttpRequestImpl.DONE);
@@ -2658,7 +2662,7 @@ function safeAbort(task) {
2658
2662
  }
2659
2663
  }
2660
2664
  function clearRequest(xhr, delay = true) {
2661
- const s = xhr[state$2];
2665
+ const s = xhr[state$5];
2662
2666
  const timerFn = delay ? setTimeout : (f) => { f(); };
2663
2667
  s[_resetPending] = true;
2664
2668
  if (s[_requestTask] && s.readyState !== XMLHttpRequestImpl.DONE) {
@@ -2688,7 +2692,7 @@ function clearRequest(xhr, delay = true) {
2688
2692
  });
2689
2693
  }
2690
2694
  function checkRequestTimeout(xhr) {
2691
- const s = xhr[state$2];
2695
+ const s = xhr[state$5];
2692
2696
  if (s.timeout) {
2693
2697
  s[_timeoutId] = setTimeout(() => {
2694
2698
  if (!s.status && s.readyState !== XMLHttpRequestImpl.DONE) {
@@ -2701,7 +2705,7 @@ function checkRequestTimeout(xhr) {
2701
2705
  }
2702
2706
  }
2703
2707
  function resetXHR(xhr) {
2704
- const s = xhr[state$2];
2708
+ const s = xhr[state$5];
2705
2709
  s[_resetPending] = false;
2706
2710
  resetRequestTimeout(xhr);
2707
2711
  s.response = "";
@@ -2713,14 +2717,14 @@ function resetXHR(xhr) {
2713
2717
  s[_responseContentLength] = () => 0;
2714
2718
  }
2715
2719
  function resetRequestTimeout(xhr) {
2716
- const s = xhr[state$2];
2720
+ const s = xhr[state$5];
2717
2721
  if (s[_timeoutId]) {
2718
2722
  clearTimeout(s[_timeoutId]);
2719
2723
  s[_timeoutId] = 0;
2720
2724
  }
2721
2725
  }
2722
2726
  function setReadyStateAndNotify(xhr, value) {
2723
- const s = xhr[state$2];
2727
+ const s = xhr[state$5];
2724
2728
  let hasChanged = value !== s.readyState;
2725
2729
  s.readyState = value;
2726
2730
  if (hasChanged) {
@@ -2732,13 +2736,13 @@ function setReadyStateAndNotify(xhr, value) {
2732
2736
  const XMLHttpRequestP = XMLHttpRequestImpl;
2733
2737
  const XMLHttpRequestE = (typeof XMLHttpRequest !== "undefined" && XMLHttpRequest) || XMLHttpRequestP;
2734
2738
 
2735
- /** @internal */ const state$1 = Symbol( /* "ResponseState" */);
2739
+ /** @internal */ const state$4 = Symbol( /* "ResponseState" */);
2736
2740
  class ResponseP extends BodyImpl {
2737
2741
  constructor(body, init) {
2738
2742
  super();
2739
- this[state$7].name = "Response";
2740
- this[state$1] = new ResponseState();
2741
- const s = this[state$1];
2743
+ this[state$a].name = "Response";
2744
+ this[state$4] = new ResponseState();
2745
+ const s = this[state$4];
2742
2746
  let _init = init !== null && init !== void 0 ? init : {};
2743
2747
  if (typeof _init !== "object") {
2744
2748
  throw new TypeError("Failed to construct 'Response': The provided value is not of type 'ResponseInit'.");
@@ -2756,18 +2760,18 @@ class ResponseP extends BodyImpl {
2756
2760
  Body_init(this, body);
2757
2761
  }
2758
2762
  get headers() {
2759
- const s = this[state$1];
2763
+ const s = this[state$4];
2760
2764
  if (!s.headers) {
2761
2765
  s.headers = new HeadersP();
2762
2766
  }
2763
2767
  return s.headers;
2764
2768
  }
2765
- get ok() { return this[state$1].ok; }
2766
- get redirected() { return this[state$1].redirected; }
2767
- get status() { return this[state$1].status; }
2768
- get statusText() { return this[state$1].statusText; }
2769
- get type() { return this[state$1].type; }
2770
- get url() { return this[state$1].url; }
2769
+ get ok() { return this[state$4].ok; }
2770
+ get redirected() { return this[state$4].redirected; }
2771
+ get status() { return this[state$4].status; }
2772
+ get statusText() { return this[state$4].statusText; }
2773
+ get type() { return this[state$4].type; }
2774
+ get url() { return this[state$4].url; }
2771
2775
  clone() {
2772
2776
  if (this.bodyUsed) {
2773
2777
  throw new TypeError("Failed to execute 'clone' on 'Response': Response body is already used");
@@ -2777,7 +2781,7 @@ class ResponseP extends BodyImpl {
2777
2781
  status: this.status,
2778
2782
  statusText: this.statusText,
2779
2783
  });
2780
- response[state$1].url = this.url;
2784
+ response[state$4].url = this.url;
2781
2785
  return response;
2782
2786
  }
2783
2787
  static json(...args) {
@@ -2789,9 +2793,9 @@ class ResponseP extends BodyImpl {
2789
2793
  }
2790
2794
  static error() {
2791
2795
  let response = new ResponseP(null, { status: 200, statusText: "" });
2792
- response[state$1].ok = false;
2793
- response[state$1].status = 0;
2794
- response[state$1].type = "error";
2796
+ response[state$4].ok = false;
2797
+ response[state$4].status = 0;
2798
+ response[state$4].type = "error";
2795
2799
  return response;
2796
2800
  }
2797
2801
  static redirect(...args) {
@@ -2819,8 +2823,8 @@ class ResponseState {
2819
2823
  }
2820
2824
  const ResponseE = g["Response"] || ResponseP;
2821
2825
 
2822
- const mp = { XMLHttpRequest: XMLHttpRequestE };
2823
- const setXMLHttpRequest = (XHR) => { mp.XMLHttpRequest = XHR; };
2826
+ const mp$1 = { XMLHttpRequest: XMLHttpRequestE };
2827
+ const setXMLHttpRequest = (XHR) => { mp$1.XMLHttpRequest = XHR; };
2824
2828
  function fetchP(...args) {
2825
2829
  if (new.target === fetchP) {
2826
2830
  throw new TypeError("fetch is not a constructor");
@@ -2829,11 +2833,11 @@ function fetchP(...args) {
2829
2833
  checkArgsLength(args, 1, "Window", "fetch");
2830
2834
  return new Promise((resolve, reject) => {
2831
2835
  const request = new RequestP(input, init);
2832
- const signal = request[state$4].signal;
2836
+ const signal = request[state$7].signal;
2833
2837
  if (signal && signal.aborted) {
2834
2838
  return reject(signal.reason);
2835
2839
  }
2836
- let xhr = new mp.XMLHttpRequest();
2840
+ let xhr = new mp$1.XMLHttpRequest();
2837
2841
  xhr.onload = function () {
2838
2842
  let options = {
2839
2843
  headers: parseHeaders(xhr.getAllResponseHeaders() || ""),
@@ -2847,7 +2851,7 @@ function fetchP(...args) {
2847
2851
  }
2848
2852
  setTimeout(() => {
2849
2853
  let response = new ResponseP("response" in xhr ? xhr.response : xhr.responseText, options);
2850
- response[state$1].url = "responseURL" in xhr ? xhr.responseURL : (options.headers.get("X-Request-URL") || "");
2854
+ response[state$4].url = "responseURL" in xhr ? xhr.responseURL : (options.headers.get("X-Request-URL") || "");
2851
2855
  resolve(response);
2852
2856
  });
2853
2857
  };
@@ -2910,24 +2914,24 @@ function fetchP(...args) {
2910
2914
  }
2911
2915
  const fetchE = g["fetch"] || fetchP;
2912
2916
 
2913
- const dispatched = 1;
2917
+ const dispatched$1 = 1;
2914
2918
  /** @internal */
2915
- const state = Symbol( /* "CustomEventState" */);
2919
+ const state$3 = Symbol( /* "CustomEventState" */);
2916
2920
  class CustomEventP extends EventP {
2917
2921
  constructor(type, eventInitDict) {
2918
2922
  var _a;
2919
2923
  super(type, eventInitDict);
2920
- this[state] = new CustomEventState();
2921
- this[state].detail = (_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.detail) !== null && _a !== void 0 ? _a : null;
2924
+ this[state$3] = new CustomEventState();
2925
+ this[state$3].detail = (_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.detail) !== null && _a !== void 0 ? _a : null;
2922
2926
  }
2923
- get detail() { return this[state].detail; }
2927
+ get detail() { return this[state$3].detail; }
2924
2928
  initCustomEvent(...args) {
2925
2929
  const [type, bubbles, cancelable, detail] = args;
2926
2930
  checkArgsLength(args, 1, "CustomEvent", "initCustomEvent");
2927
- if (Event_getEtField(this, dispatched))
2931
+ if (Event_getEtField(this, dispatched$1))
2928
2932
  return;
2929
2933
  this.initEvent(type, bubbles, cancelable);
2930
- this[state].detail = detail !== null && detail !== void 0 ? detail : null;
2934
+ this[state$3].detail = detail !== null && detail !== void 0 ? detail : null;
2931
2935
  }
2932
2936
  /** @internal */ toString() { return "[object CustomEvent]"; }
2933
2937
  /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["CustomEvent", "Event"] }; }
@@ -2938,6 +2942,318 @@ class CustomEventState {
2938
2942
  }
2939
2943
  const CustomEventE = g["EventTarget"] ? g["CustomEvent"] : CustomEventP;
2940
2944
 
2945
+ /** @internal */
2946
+ const state$2 = Symbol( /* "CloseEventState" */);
2947
+ class CloseEventP extends EventP {
2948
+ constructor(type, eventInitDict) {
2949
+ var _a;
2950
+ super(type, eventInitDict);
2951
+ this[state$2] = new CloseEventState();
2952
+ const s = this[state$2];
2953
+ let _code = Number((_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.code) !== null && _a !== void 0 ? _a : 0);
2954
+ s.code = isNaN(_code) ? 0 : _code;
2955
+ if ((eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.reason) !== undefined)
2956
+ s.reason = "" + eventInitDict.reason;
2957
+ s.wasClean = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.wasClean);
2958
+ }
2959
+ get code() { return this[state$2].code; }
2960
+ get reason() { return this[state$2].reason; }
2961
+ get wasClean() { return this[state$2].wasClean; }
2962
+ /** @internal */ toString() { return "[object CloseEvent]"; }
2963
+ /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["CloseEvent", "Event"] }; }
2964
+ }
2965
+ Class_setStringTag(CloseEventP, "CloseEvent");
2966
+ /** @internal */
2967
+ class CloseEventState {
2968
+ constructor() {
2969
+ this.code = 0;
2970
+ this.reason = "";
2971
+ this.wasClean = false;
2972
+ }
2973
+ }
2974
+ g["EventTarget"] ? g["CloseEvent"] : CloseEventP;
2975
+
2976
+ const dispatched = 1;
2977
+ /** @internal */
2978
+ const state$1 = Symbol( /* "MessageEventState" */);
2979
+ class MessageEventP extends EventP {
2980
+ constructor(type, eventInitDict) {
2981
+ var _a;
2982
+ super(type, eventInitDict);
2983
+ this[state$1] = new MessageEventState();
2984
+ const s = this[state$1];
2985
+ s.data = (_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.data) !== null && _a !== void 0 ? _a : null;
2986
+ if ((eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.origin) !== undefined)
2987
+ s.origin = "" + eventInitDict.origin;
2988
+ if ((eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.lastEventId) !== undefined)
2989
+ s.lastEventId = "" + eventInitDict.lastEventId;
2990
+ if ((eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.source) !== undefined)
2991
+ s.source = eventInitDict.source;
2992
+ if ((eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.ports) !== undefined)
2993
+ s.ports = eventInitDict.ports;
2994
+ }
2995
+ get data() { return this[state$1].data; }
2996
+ get lastEventId() { return this[state$1].lastEventId; }
2997
+ get origin() { return this[state$1].origin; }
2998
+ get ports() { return this[state$1].ports; }
2999
+ get source() { return this[state$1].source; }
3000
+ initMessageEvent(...args) {
3001
+ const [type, bubbles, cancelable, data, origin, lastEventId, source, ports] = args;
3002
+ checkArgsLength(args, 1, "MessageEvent", "initMessageEvent");
3003
+ if (Event_getEtField(this, dispatched))
3004
+ return;
3005
+ this.initEvent(type, bubbles, cancelable);
3006
+ const s = this[state$1];
3007
+ s.data = data !== null && data !== void 0 ? data : null;
3008
+ if (origin !== undefined)
3009
+ s.origin = "" + origin;
3010
+ if (lastEventId !== undefined)
3011
+ s.lastEventId = "" + lastEventId;
3012
+ if (source !== undefined)
3013
+ s.source = source;
3014
+ if (ports !== undefined)
3015
+ s.ports = ports;
3016
+ }
3017
+ /** @internal */ toString() { return "[object MessageEvent]"; }
3018
+ /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["MessageEvent", "Event"] }; }
3019
+ }
3020
+ Class_setStringTag(MessageEventP, "MessageEvent");
3021
+ /** @internal */
3022
+ class MessageEventState {
3023
+ constructor() {
3024
+ this.data = null;
3025
+ this.lastEventId = "";
3026
+ this.origin = "";
3027
+ this.ports = [];
3028
+ this.source = null;
3029
+ }
3030
+ }
3031
+ g["EventTarget"] ? g["MessageEvent"] : MessageEventP;
3032
+
3033
+ const connectSocket = mp$3 ? mp$3.connectSocket : function errorConnectSocket(options) {
3034
+ return {
3035
+ send(obj) { },
3036
+ close(obj) { },
3037
+ onOpen(listener) { },
3038
+ onMessage(listener) { },
3039
+ onError(listener) {
3040
+ if (typeof listener === "function") {
3041
+ listener({ errMsg: "NOT_SUPPORTED_ERR" });
3042
+ }
3043
+ },
3044
+ onClose(listener) {
3045
+ if (typeof listener === "function") {
3046
+ setTimeout(() => { listener({ code: 3009, reason: "NOT_SUPPORTED_ERR" }); });
3047
+ }
3048
+ },
3049
+ };
3050
+ };
3051
+
3052
+ var _a, _b;
3053
+ const mp = { connectSocket: connectSocket };
3054
+ const setConnectSocket = (connectSocket) => { mp.connectSocket = connectSocket; };
3055
+ /** @internal */
3056
+ const state = Symbol( /* "WebSocketState" */);
3057
+ class WebSocketImpl extends EventTargetP {
3058
+ constructor(...args) {
3059
+ const [url, protocols] = args;
3060
+ checkArgsLength(args, 1, "WebSocket");
3061
+ super();
3062
+ this[state] = new WebSocketState(this, {
3063
+ url: "" + url,
3064
+ protocols: protocols !== undefined
3065
+ ? (Array.isArray(protocols) || (protocols && typeof protocols === "object" && Symbol.iterator in protocols))
3066
+ ? Array.isArray(protocols) ? protocols : Array.from(protocols)
3067
+ : ["" + protocols]
3068
+ : [],
3069
+ multiple: true, // Alipay Mini Program
3070
+ fail(err) { console.error(err); },
3071
+ });
3072
+ let socketTask = this[state][_socketTask];
3073
+ if (socketTask && typeof socketTask === "object") {
3074
+ onOpen(this);
3075
+ onClose(this);
3076
+ onError(this);
3077
+ onMessage(this);
3078
+ }
3079
+ else {
3080
+ throw new Error(`connectSocket can't establish a connection to the server at ${"" + url}.`);
3081
+ }
3082
+ }
3083
+ get binaryType() { return this[state].binaryType; }
3084
+ set binaryType(value) { if (value === "blob" || value === "arraybuffer") {
3085
+ this[state].binaryType = value;
3086
+ } }
3087
+ get bufferedAmount() { return this[state].bufferedAmount; }
3088
+ get extensions() { return this[state].extensions; }
3089
+ get protocol() { return this[state].protocol; }
3090
+ get readyState() { return this[state].readyState; }
3091
+ get url() { return this[state].url; }
3092
+ close(code, reason) {
3093
+ if (this.readyState === WebSocketImpl.CLOSING || this.readyState === WebSocketImpl.CLOSED)
3094
+ return;
3095
+ this[state].readyState = WebSocketImpl.CLOSING;
3096
+ this[state][_socketTask].close({
3097
+ code: code,
3098
+ reason: reason,
3099
+ fail(err) { console.error(err); },
3100
+ complete: (function () {
3101
+ this[state].readyState = WebSocketImpl.CLOSED;
3102
+ }).bind(this),
3103
+ });
3104
+ }
3105
+ send(...args) {
3106
+ const [data] = args;
3107
+ checkArgsLength(args, 1, "WebSocket", "send");
3108
+ if (this.readyState === WebSocketImpl.CONNECTING) {
3109
+ throw new MPException("Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.", "InvalidStateError");
3110
+ }
3111
+ if (this.readyState === WebSocketImpl.CLOSING || this.readyState === WebSocketImpl.CLOSED) {
3112
+ return console.error("WebSocket is already in CLOSING or CLOSED state.");
3113
+ }
3114
+ let _data;
3115
+ if (isArrayBuffer(data)) {
3116
+ _data = data;
3117
+ }
3118
+ else if (ArrayBuffer.isView(data)) {
3119
+ _data = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
3120
+ }
3121
+ else if (isPolyfillType("Blob", data)) {
3122
+ _data = Blob_toUint8Array(data).buffer.slice(0);
3123
+ }
3124
+ else {
3125
+ _data = "" + data;
3126
+ }
3127
+ this[state][_socketTask].send({
3128
+ data: _data,
3129
+ fail(err) { console.error(err); },
3130
+ });
3131
+ }
3132
+ get onclose() { return this[state].onclose; }
3133
+ set onclose(value) { this[state].onclose = value; attach(this, "close"); }
3134
+ get onerror() { return this[state].onerror; }
3135
+ set onerror(value) { this[state].onerror = value; attach(this, "error"); }
3136
+ get onmessage() { return this[state].onmessage; }
3137
+ set onmessage(value) { this[state].onmessage = value; attach(this, "message"); }
3138
+ get onopen() { return this[state].onopen; }
3139
+ set onopen(value) { this[state].onopen = value; attach(this, "open"); }
3140
+ /** @internal */ toString() { return "[object WebSocket]"; }
3141
+ /** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["WebSocket", "EventTarget"] }; }
3142
+ }
3143
+ const properties = {
3144
+ CONNECTING: { value: 0, enumerable: true },
3145
+ OPEN: { value: 1, enumerable: true },
3146
+ CLOSING: { value: 2, enumerable: true },
3147
+ CLOSED: { value: 3, enumerable: true },
3148
+ };
3149
+ Object.defineProperties(WebSocketImpl, properties);
3150
+ Object.defineProperties(WebSocketImpl.prototype, properties);
3151
+ Class_setStringTag(WebSocketImpl, "WebSocket");
3152
+ /** @internal */ const _socketTask = Symbol();
3153
+ /** @internal */ const _error = Symbol();
3154
+ /** @internal */ const _handlers = Symbol();
3155
+ /** @internal */
3156
+ class WebSocketState {
3157
+ constructor(target, opts) {
3158
+ this.binaryType = "blob";
3159
+ this.bufferedAmount = 0;
3160
+ this.extensions = "";
3161
+ this.protocol = "";
3162
+ this.readyState = 0;
3163
+ this[_a] = null;
3164
+ this[_b] = getHandlers(this);
3165
+ this.onclose = null;
3166
+ this.onerror = null;
3167
+ this.onmessage = null;
3168
+ this.onopen = null;
3169
+ this.target = target;
3170
+ this.url = opts.url;
3171
+ this[_socketTask] = mp.connectSocket(opts);
3172
+ }
3173
+ }
3174
+ _a = _error, _b = _handlers;
3175
+ function attach(target, type) {
3176
+ const s = target[state];
3177
+ const fnName = ("on" + type);
3178
+ const cb = s[fnName];
3179
+ const listener = s[_handlers][fnName];
3180
+ attachFn(target, type, cb, listener);
3181
+ }
3182
+ function getHandlers(s) {
3183
+ return {
3184
+ onclose: (ev) => { executeFn(s.target, s.onclose, ev); },
3185
+ onerror: (ev) => { executeFn(s.target, s.onerror, ev); },
3186
+ onmessage: (ev) => { executeFn(s.target, s.onmessage, ev); },
3187
+ onopen: (ev) => { executeFn(s.target, s.onopen, ev); },
3188
+ };
3189
+ }
3190
+ function onOpen(ws) {
3191
+ let _ws = ws;
3192
+ _ws[state][_socketTask].onOpen(res => {
3193
+ if ("header" in res && res.header && typeof res.header === "object") {
3194
+ let headers = new HeadersP(res.header);
3195
+ _ws[state].protocol = headers.get("Sec-WebSocket-Protocol") || "";
3196
+ }
3197
+ _ws[state].readyState = WebSocketImpl.OPEN;
3198
+ EventTarget_fire(_ws, createInnerEvent(_ws, "open"));
3199
+ });
3200
+ }
3201
+ function onClose(ws) {
3202
+ let _ws = ws;
3203
+ _ws[state][_socketTask].onClose(res => {
3204
+ _ws[state].readyState = WebSocketImpl.CLOSED;
3205
+ let event = new CloseEventP("close", {
3206
+ wasClean: !_ws[state][_error],
3207
+ code: res.code,
3208
+ reason: res.reason,
3209
+ });
3210
+ Event_setTrusted(event, true);
3211
+ EventTarget_fire(_ws, event);
3212
+ });
3213
+ }
3214
+ function onError(ws) {
3215
+ let _ws = ws;
3216
+ _ws[state][_socketTask].onError(res => {
3217
+ console.error(res);
3218
+ _ws[state][_error] = res;
3219
+ _ws[state].readyState = WebSocketImpl.CLOSED;
3220
+ EventTarget_fire(_ws, createInnerEvent(_ws, "error"));
3221
+ });
3222
+ }
3223
+ function onMessage(ws) {
3224
+ let _ws = ws;
3225
+ _ws[state][_socketTask].onMessage(res => {
3226
+ let data = res.data;
3227
+ let _data;
3228
+ // Alipay Mini Program
3229
+ if (data && typeof data === "object" && "data" in data) {
3230
+ _data = data.data;
3231
+ if ("isBuffer" in data && data.isBuffer && typeof _data === "string") {
3232
+ // @ts-ignore
3233
+ try {
3234
+ _data = my.base64ToArrayBuffer(_data);
3235
+ }
3236
+ catch (e) { }
3237
+ }
3238
+ }
3239
+ else {
3240
+ _data = data;
3241
+ }
3242
+ if (isArrayBuffer(_data) && _ws.binaryType === "blob") {
3243
+ _data = new BlobP([_data]);
3244
+ }
3245
+ let event = new MessageEventP("message", {
3246
+ data: _data,
3247
+ origin: _ws.url,
3248
+ });
3249
+ Event_setTrusted(event, true);
3250
+ EventTarget_fire(_ws, event);
3251
+ });
3252
+ }
3253
+
3254
+ const WebSocketP = WebSocketImpl;
3255
+ const WebSocketE = (typeof WebSocket !== "undefined" && WebSocket) || WebSocketP;
3256
+
2941
3257
  exports.AbortController = AbortControllerE;
2942
3258
  exports.AbortControllerP = AbortControllerP;
2943
3259
  exports.AbortSignal = AbortSignalE;
@@ -2958,8 +3274,6 @@ exports.FormData = FormDataE;
2958
3274
  exports.FormDataP = FormDataP;
2959
3275
  exports.Headers = HeadersE;
2960
3276
  exports.HeadersP = HeadersP;
2961
- exports.ProgressEvent = ProgressEventE;
2962
- exports.ProgressEventP = ProgressEventP;
2963
3277
  exports.Request = RequestE;
2964
3278
  exports.RequestP = RequestP;
2965
3279
  exports.Response = ResponseE;
@@ -2970,9 +3284,12 @@ exports.TextEncoder = TextEncoderE;
2970
3284
  exports.TextEncoderP = TextEncoderP;
2971
3285
  exports.URLSearchParams = URLSearchParamsE;
2972
3286
  exports.URLSearchParamsP = URLSearchParamsP;
3287
+ exports.WebSocket = WebSocketE;
3288
+ exports.WebSocketP = WebSocketP;
2973
3289
  exports.XMLHttpRequest = XMLHttpRequestE;
2974
3290
  exports.XMLHttpRequestP = XMLHttpRequestP;
2975
3291
  exports.fetch = fetchE;
2976
3292
  exports.fetchP = fetchP;
3293
+ exports.setConnectSocket = setConnectSocket;
2977
3294
  exports.setRequest = setRequest;
2978
3295
  exports.setXMLHttpRequest = setXMLHttpRequest;