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