@paydock/client-sdk 1.140.1 → 1.141.0-beta

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/bundles/index.mjs CHANGED
@@ -315,7 +315,7 @@ function _superPropBase(t, o) {
315
315
  }
316
316
  function _superPropGet(t, o, e, r) {
317
317
  var p = _get(_getPrototypeOf(t.prototype ), o, e);
318
- return "function" == typeof p ? function (t) {
318
+ return 2 & r && "function" == typeof p ? function (t) {
319
319
  return p.apply(e, t);
320
320
  } : p;
321
321
  }
@@ -1192,7 +1192,7 @@ SDK.headerKeys = Object.freeze({
1192
1192
  version: 'x-sdk-version',
1193
1193
  type: 'x-sdk-type'
1194
1194
  });
1195
- SDK._version = 'v1.140.1';
1195
+ SDK._version = 'v1.141.0-beta';
1196
1196
 
1197
1197
  function isFunction(value) {
1198
1198
  return typeof value === 'function';
@@ -6579,7 +6579,7 @@ var PopupRunner = /*#__PURE__*/function (_ContextualRunner) {
6579
6579
  }, {
6580
6580
  key: "setEnv",
6581
6581
  value: function setEnv(env, alias) {
6582
- _superPropGet(PopupRunner, "setEnv", this)([env, alias]);
6582
+ _superPropGet(PopupRunner, "setEnv", this, 3)([env, alias]);
6583
6583
  this.dispatcher.setEnv(env, alias);
6584
6584
  this.popup.setEnv(env);
6585
6585
  }
@@ -6638,7 +6638,7 @@ var ZipmoneyRunner = /*#__PURE__*/function (_BaseRunner) {
6638
6638
  return _createClass(ZipmoneyRunner, [{
6639
6639
  key: "setEnv",
6640
6640
  value: function setEnv(env, alias) {
6641
- _superPropGet(ZipmoneyRunner, "setEnv", this)([env, alias]);
6641
+ _superPropGet(ZipmoneyRunner, "setEnv", this, 3)([env, alias]);
6642
6642
  this.apiEnv.setEnv(env, alias);
6643
6643
  }
6644
6644
  }]);
@@ -6667,6 +6667,9 @@ var ZipmoneyContextualRunner = /*#__PURE__*/function (_ContextualRunner) {
6667
6667
  return _createClass(ZipmoneyContextualRunner, [{
6668
6668
  key: "run",
6669
6669
  value: function run() {
6670
+ if (this.isRunning()) {
6671
+ return;
6672
+ }
6670
6673
  this.runs = true;
6671
6674
  this.background.initLoader();
6672
6675
  this.checkoutTab = window.open(this.getLoadingUrl(), '_blank');
@@ -6703,7 +6706,7 @@ var ZipmoneyContextualRunner = /*#__PURE__*/function (_ContextualRunner) {
6703
6706
  }, {
6704
6707
  key: "stop",
6705
6708
  value: function stop() {
6706
- _superPropGet(ZipmoneyContextualRunner, "stop", this)([]);
6709
+ _superPropGet(ZipmoneyContextualRunner, "stop", this, 3)([]);
6707
6710
  this.runs = false;
6708
6711
  var element = document.querySelector('.zipmoney-overlay');
6709
6712
  if (element) {
@@ -6932,7 +6935,7 @@ var ZipmoneyRedirectRunner = /*#__PURE__*/function (_RedirectRunner) {
6932
6935
  }, {
6933
6936
  key: "setEnv",
6934
6937
  value: function setEnv(env, alias) {
6935
- _superPropGet(ZipmoneyRedirectRunner, "setEnv", this)([env, alias]);
6938
+ _superPropGet(ZipmoneyRedirectRunner, "setEnv", this, 3)([env, alias]);
6936
6939
  this.storageDispatcher.setEnv(env, alias);
6937
6940
  }
6938
6941
  }]);
@@ -6992,7 +6995,7 @@ var AfterpayRunner = /*#__PURE__*/function (_PopupRunner) {
6992
6995
  }, {
6993
6996
  key: "onCheckout",
6994
6997
  value: function onCheckout(event, cb) {
6995
- _superPropGet(AfterpayRunner, "onCheckout", this)([event, function (checkout, data) {
6998
+ _superPropGet(AfterpayRunner, "onCheckout", this, 3)([event, function (checkout, data) {
6996
6999
  if (!(data === null || data === void 0 ? void 0 : data.status)) return cb(checkout);
6997
7000
  var status = data.status,
6998
7001
  newData = __rest(data, ["status"]);
@@ -7237,29 +7240,67 @@ var CheckoutButton = /*#__PURE__*/function () {
7237
7240
  value: function initCheckout(container) {
7238
7241
  var _this = this;
7239
7242
  container.on('click', function (event) {
7240
- if (isContextualRunner(_this.runner)) {
7241
- if (_this.runner.isRunning()) return;else _this.runner.run();
7242
- } else if (isRedirectRunner(_this.runner)) {
7243
- if (!_this.runner.getRedirectUrl()) throw Error("".concat(CHECKOUT_BTN_LOG_PREFIX, " The merchant redirect URL should is required in the '").concat(_this.mode, "' mode."));
7244
- }
7245
- _this.eventEmitter.emit(CHECKOUT_BUTTON_EVENT.CLICK);
7246
- var externalCheckout = new Builder$1(_this.gatewayId, _this.runner.getSuccessRedirectUri(), _this.runner.getErrorRedirectUri());
7247
- externalCheckout.setMeta(_this.meta);
7248
- externalCheckout.setEnv(_this.env);
7249
- externalCheckout.send(_this.accessToken, function (checkout) {
7250
- var buttonEvent = isContextualRunner(_this.runner) ? CHECKOUT_BUTTON_EVENT.POPUP_REDIRECT : CHECKOUT_BUTTON_EVENT.REDIRECT;
7251
- _this.eventEmitter.emit(buttonEvent);
7252
- _this.runner.next(checkout, _this.buildAdditionalParams());
7253
- }, function (error, code) {
7254
- console.error("".concat(CHECKOUT_BTN_LOG_PREFIX, " ").concat(error));
7255
- _this.eventEmitter.emit(CHECKOUT_BUTTON_EVENT.ERROR, {
7256
- error: error,
7257
- code: code
7258
- });
7259
- _this.runner.error(error, code, function (close) {
7260
- if (close) _this.close();
7261
- });
7262
- });
7243
+ return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee() {
7244
+ var _this2 = this;
7245
+ var results, externalCheckout;
7246
+ return _regenerator().w(function (_context) {
7247
+ while (1) switch (_context.n) {
7248
+ case 0:
7249
+ if (!isContextualRunner(this.runner)) {
7250
+ _context.n = 2;
7251
+ break;
7252
+ }
7253
+ if (!this.runner.isRunning()) {
7254
+ _context.n = 1;
7255
+ break;
7256
+ }
7257
+ return _context.a(2);
7258
+ case 1:
7259
+ this.runner.run();
7260
+ case 2:
7261
+ if (!(isRedirectRunner(this.runner) && !this.runner.getRedirectUrl())) {
7262
+ _context.n = 3;
7263
+ break;
7264
+ }
7265
+ throw Error("".concat(CHECKOUT_BTN_LOG_PREFIX, " The merchant redirect URL should is required in the '").concat(this.mode, "' mode."));
7266
+ case 3:
7267
+ _context.n = 4;
7268
+ return this.eventEmitter.emitWithResult(CHECKOUT_BUTTON_EVENT.CLICK);
7269
+ case 4:
7270
+ results = _context.v;
7271
+ if (!results.some(function (result) {
7272
+ return result === false;
7273
+ })) {
7274
+ _context.n = 5;
7275
+ break;
7276
+ }
7277
+ if (isContextualRunner(this.runner) && this.runner.isRunning()) {
7278
+ this.close();
7279
+ }
7280
+ return _context.a(2);
7281
+ case 5:
7282
+ externalCheckout = new Builder$1(this.gatewayId, this.runner.getSuccessRedirectUri(), this.runner.getErrorRedirectUri());
7283
+ externalCheckout.setMeta(this.meta);
7284
+ externalCheckout.setEnv(this.env);
7285
+ externalCheckout.send(this.accessToken, function (checkout) {
7286
+ var buttonEvent = isContextualRunner(_this2.runner) ? CHECKOUT_BUTTON_EVENT.POPUP_REDIRECT : CHECKOUT_BUTTON_EVENT.REDIRECT;
7287
+ _this2.eventEmitter.emit(buttonEvent);
7288
+ _this2.runner.next(checkout, _this2.buildAdditionalParams());
7289
+ }, function (error, code) {
7290
+ console.error("".concat(CHECKOUT_BTN_LOG_PREFIX, " ").concat(error));
7291
+ _this2.eventEmitter.emit(CHECKOUT_BUTTON_EVENT.ERROR, {
7292
+ error: error,
7293
+ code: code
7294
+ });
7295
+ _this2.runner.error(error, code, function (close) {
7296
+ if (close) _this2.close();
7297
+ });
7298
+ });
7299
+ case 6:
7300
+ return _context.a(2);
7301
+ }
7302
+ }, _callee, this);
7303
+ }));
7263
7304
  });
7264
7305
  }
7265
7306
  /**
@@ -7497,7 +7538,7 @@ var AfterpayCheckoutButton = /*#__PURE__*/function (_CheckoutButton) {
7497
7538
  }, {
7498
7539
  key: "buildAdditionalParams",
7499
7540
  value: function buildAdditionalParams() {
7500
- var params = _superPropGet(AfterpayCheckoutButton, "buildAdditionalParams", this)([]);
7541
+ var params = _superPropGet(AfterpayCheckoutButton, "buildAdditionalParams", this, 3)([]);
7501
7542
  if (this.showETP) {
7502
7543
  params.show_etp = true;
7503
7544
  }
@@ -7858,7 +7899,7 @@ var AfterPayWalletService = /*#__PURE__*/function (_WalletService) {
7858
7899
  }, {
7859
7900
  key: "setEnv",
7860
7901
  value: function setEnv(env) {
7861
- _superPropGet(AfterPayWalletService, "setEnv", this)([env]);
7902
+ _superPropGet(AfterPayWalletService, "setEnv", this, 3)([env]);
7862
7903
  if (this.isRedirectMode) {
7863
7904
  this.storageDispatcher.setEnv(env);
7864
7905
  }
@@ -8047,7 +8088,7 @@ var AfterPayWalletService = /*#__PURE__*/function (_WalletService) {
8047
8088
  }]);
8048
8089
  }(WalletService);
8049
8090
 
8050
- /*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */
8091
+ /*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */
8051
8092
 
8052
8093
  var purify_cjs;
8053
8094
  var hasRequiredPurify_cjs;
@@ -8352,7 +8393,7 @@ function requirePurify_cjs () {
8352
8393
  function createDOMPurify() {
8353
8394
  let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
8354
8395
  const DOMPurify = root => createDOMPurify(root);
8355
- DOMPurify.version = '3.3.0';
8396
+ DOMPurify.version = '3.3.3';
8356
8397
  DOMPurify.removed = [];
8357
8398
  if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
8358
8399
  // Not running in a browser, provide a factory function
@@ -8647,7 +8688,7 @@ function requirePurify_cjs () {
8647
8688
  /* Parse profile info */
8648
8689
  if (USE_PROFILES) {
8649
8690
  ALLOWED_TAGS = addToSet({}, text);
8650
- ALLOWED_ATTR = [];
8691
+ ALLOWED_ATTR = create(null);
8651
8692
  if (USE_PROFILES.html === true) {
8652
8693
  addToSet(ALLOWED_TAGS, html$1);
8653
8694
  addToSet(ALLOWED_ATTR, html);
@@ -8668,6 +8709,13 @@ function requirePurify_cjs () {
8668
8709
  addToSet(ALLOWED_ATTR, xml);
8669
8710
  }
8670
8711
  }
8712
+ /* Prevent function-based ADD_ATTR / ADD_TAGS from leaking across calls */
8713
+ if (!objectHasOwnProperty(cfg, 'ADD_TAGS')) {
8714
+ EXTRA_ELEMENT_HANDLING.tagCheck = null;
8715
+ }
8716
+ if (!objectHasOwnProperty(cfg, 'ADD_ATTR')) {
8717
+ EXTRA_ELEMENT_HANDLING.attributeCheck = null;
8718
+ }
8671
8719
  /* Merge configuration parameters */
8672
8720
  if (cfg.ADD_TAGS) {
8673
8721
  if (typeof cfg.ADD_TAGS === 'function') {
@@ -8698,6 +8746,12 @@ function requirePurify_cjs () {
8698
8746
  }
8699
8747
  addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
8700
8748
  }
8749
+ if (cfg.ADD_FORBID_CONTENTS) {
8750
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
8751
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
8752
+ }
8753
+ addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
8754
+ }
8701
8755
  /* Add #text in case KEEP_CONTENT is set to true */
8702
8756
  if (KEEP_CONTENT) {
8703
8757
  ALLOWED_TAGS['#text'] = true;
@@ -9059,6 +9113,10 @@ function requirePurify_cjs () {
9059
9113
  */
9060
9114
  // eslint-disable-next-line complexity
9061
9115
  const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
9116
+ /* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */
9117
+ if (FORBID_ATTR[lcName]) {
9118
+ return false;
9119
+ }
9062
9120
  /* Make sure attribute cannot clobber */
9063
9121
  if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
9064
9122
  return false;
@@ -9151,7 +9209,7 @@ function requirePurify_cjs () {
9151
9209
  value = SANITIZE_NAMED_PROPS_PREFIX + value;
9152
9210
  }
9153
9211
  /* Work around a security issue with comments inside attributes */
9154
- if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title|textarea)/i, value)) {
9212
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
9155
9213
  _removeAttribute(name, currentNode);
9156
9214
  continue;
9157
9215
  }
@@ -9632,14 +9690,14 @@ var WalletBackground = /*#__PURE__*/function (_Background) {
9632
9690
  key: "initControl",
9633
9691
  value: function initControl() {
9634
9692
  if (!this.imageStyle) this.createImageStyles();
9635
- _superPropGet(WalletBackground, "initControl", this)([]);
9693
+ _superPropGet(WalletBackground, "initControl", this, 3)([]);
9636
9694
  }
9637
9695
  }, {
9638
9696
  key: "clear",
9639
9697
  value: function clear() {
9640
9698
  if (this.imageStyle) this.imageStyle.parentNode.removeChild(this.imageStyle);
9641
9699
  this.imageStyle = null;
9642
- _superPropGet(WalletBackground, "clear", this)([]);
9700
+ _superPropGet(WalletBackground, "clear", this, 3)([]);
9643
9701
  }
9644
9702
  }, {
9645
9703
  key: "createTemplate",
@@ -9761,7 +9819,7 @@ var FlypayV2WalletService = /*#__PURE__*/function (_WalletService) {
9761
9819
  key: "setEnv",
9762
9820
  value: function setEnv(env) {
9763
9821
  this.link.setEnv(env);
9764
- return _superPropGet(FlypayV2WalletService, "setEnv", this)([env]);
9822
+ return _superPropGet(FlypayV2WalletService, "setEnv", this, 3)([env]);
9765
9823
  }
9766
9824
  }, {
9767
9825
  key: "enable",
@@ -10471,8 +10529,11 @@ var AppleWalletService = /*#__PURE__*/function (_WalletService) {
10471
10529
  formattedCapabilities = _this4.formatCapabilities(_this4.meta.apple_pay_capabilities);
10472
10530
  }
10473
10531
  ApplePaySession.applePayCapabilities(_this4.getMerchantId()).then(function (capabilities) {
10474
- var canMakePayment = formattedCapabilities.includes(capabilities === null || capabilities === void 0 ? void 0 : capabilities.paymentCredentialStatus);
10475
- resolve(canMakePayment);
10532
+ if (_this4.isUnsuportedBrowser(capabilities)) {
10533
+ return resolve(ApplePaySession.canMakePayments());
10534
+ }
10535
+ var allowedCapability = formattedCapabilities.includes(capabilities === null || capabilities === void 0 ? void 0 : capabilities.paymentCredentialStatus);
10536
+ return resolve(allowedCapability);
10476
10537
  })["catch"](function (_err) {
10477
10538
  return resolve(false);
10478
10539
  });
@@ -10595,6 +10656,11 @@ var AppleWalletService = /*#__PURE__*/function (_WalletService) {
10595
10656
  value: function createButtonStyle() {
10596
10657
  return "\n apple-pay-button {\n display: inline-block;\n --apple-pay-button-width: 100%;\n --apple-pay-button-height: 40px;\n --apple-pay-button-border-radius: 5px;\n --apple-pay-button-padding: 5px 0px;\n }\n ";
10597
10658
  }
10659
+ }, {
10660
+ key: "isUnsuportedBrowser",
10661
+ value: function isUnsuportedBrowser(capabilities) {
10662
+ return (capabilities === null || capabilities === void 0 ? void 0 : capabilities.paymentCredentialStatus) === 'applePayUnsupported';
10663
+ }
10598
10664
  }]);
10599
10665
  }(WalletService);
10600
10666
 
@@ -14510,7 +14576,7 @@ var HtmlWidget = /*#__PURE__*/function (_HtmlMultiWidget) {
14510
14576
  key: "setFormElement",
14511
14577
  value: function setFormElement(element) {
14512
14578
  this.configs[0].setFormFields([element.field]);
14513
- _superPropGet(HtmlWidget, "setFormElement", this)([_extends(_extends({}, element), {
14579
+ _superPropGet(HtmlWidget, "setFormElement", this, 3)([_extends(_extends({}, element), {
14514
14580
  field: element.field.replace('*', '')
14515
14581
  })]);
14516
14582
  }
@@ -16408,19 +16474,19 @@ var ZipmoneyCheckoutButton = /*#__PURE__*/function (_CheckoutButton) {
16408
16474
  return _this;
16409
16475
  }
16410
16476
  /**
16411
- * Method for setting suspended redirect uri. Redirect after referred checkout
16412
- *
16413
- * The URI is used for a redirect after the checkout is complete.
16414
- * This can be provided, even if using in-context checkout (sdk). By default, the standard styled page will be used.
16415
- * If using in-context (sdk) we will not automatically redirect to this URI.
16416
- *
16417
- * @param {uri} string - uri for suspended redirect (by default)
16418
- */
16477
+ * Method for setting suspended redirect uri. Redirect after referred checkout
16478
+ *
16479
+ * The URI is used for a redirect after the checkout is complete.
16480
+ * This can be provided, even if using in-context checkout (sdk). By default, the standard styled page will be used.
16481
+ * If using in-context (sdk) we will not automatically redirect to this URI.
16482
+ *
16483
+ * @param {uri} string - uri for suspended redirect (by default)
16484
+ */
16419
16485
  _inherits(ZipmoneyCheckoutButton, _CheckoutButton);
16420
16486
  return _createClass(ZipmoneyCheckoutButton, [{
16421
16487
  key: "setSuspendedRedirectUri",
16422
16488
  value: function setSuspendedRedirectUri(uri) {
16423
- _superPropGet(ZipmoneyCheckoutButton, "setSuspendedRedirectUri", this)([uri]);
16489
+ _superPropGet(ZipmoneyCheckoutButton, "setSuspendedRedirectUri", this, 3)([uri]);
16424
16490
  }
16425
16491
  /**
16426
16492
  * Method for setting the merchant redirect URL.
@@ -16437,21 +16503,39 @@ var ZipmoneyCheckoutButton = /*#__PURE__*/function (_CheckoutButton) {
16437
16503
  key: "setRedirectUrl",
16438
16504
  value: function setRedirectUrl(url) {
16439
16505
  if (isContextualRunner(this.runner)) {
16440
- _superPropGet(ZipmoneyCheckoutButton, "chooseRunner", this)([GATEWAY_TYPE.ZIPMONEY, CHECKOUT_MODE.REDIRECT]);
16441
- _superPropGet(ZipmoneyCheckoutButton, "setEnv", this)([this.env, this.alias]);
16506
+ _superPropGet(ZipmoneyCheckoutButton, "chooseRunner", this, 3)([GATEWAY_TYPE.ZIPMONEY, CHECKOUT_MODE.REDIRECT]);
16507
+ _superPropGet(ZipmoneyCheckoutButton, "setEnv", this, 3)([this.env, this.alias]);
16442
16508
  }
16443
- _superPropGet(ZipmoneyCheckoutButton, "setRedirectUrl", this)([url]);
16509
+ _superPropGet(ZipmoneyCheckoutButton, "setRedirectUrl", this, 3)([url]);
16444
16510
  }
16445
16511
  }, {
16446
16512
  key: "buildAdditionalParams",
16447
16513
  value: function buildAdditionalParams() {
16448
- var defaultParams = _superPropGet(ZipmoneyCheckoutButton, "buildAdditionalParams", this)([]);
16514
+ var defaultParams = _superPropGet(ZipmoneyCheckoutButton, "buildAdditionalParams", this, 3)([]);
16449
16515
  var params = _extends(_extends({}, defaultParams), {
16450
16516
  public_key: this.publicKey,
16451
16517
  gateway_id: this.gatewayId
16452
16518
  });
16453
16519
  return params;
16454
16520
  }
16521
+ /**
16522
+ * Subscribe to the click event with an async handler.
16523
+ * The checkout flow will wait for the async handler to complete before proceeding.
16524
+ * If the handler resolves to `false`, the checkout flow will be cancelled.
16525
+ *
16526
+ * @param handler - Async function to be called when the button is clicked
16527
+ *
16528
+ * @example
16529
+ * button.onClick(async () => {
16530
+ * const isValid = await fetchDataFromServer();
16531
+ * return isValid; // return false to stop checkout
16532
+ * });
16533
+ */
16534
+ }, {
16535
+ key: "onClick",
16536
+ value: function onClick(handler) {
16537
+ this.eventEmitter.subscribe(CHECKOUT_BUTTON_EVENT.CLICK, handler);
16538
+ }
16455
16539
  }]);
16456
16540
  }(CheckoutButton);
16457
16541
 
@@ -17347,7 +17431,7 @@ var InstructionCardFormShow = /*#__PURE__*/function (_InstructionHandler) {
17347
17431
  }, {
17348
17432
  key: "destroy",
17349
17433
  value: function destroy() {
17350
- _superPropGet(InstructionCardFormShow, "destroy", this)([]);
17434
+ _superPropGet(InstructionCardFormShow, "destroy", this, 3)([]);
17351
17435
  clearTimeout(this.timeoutId);
17352
17436
  }
17353
17437
  }, {
@@ -17846,7 +17930,7 @@ var InstructionPaymentMethodShow = /*#__PURE__*/function (_InstructionHandler) {
17846
17930
  }, {
17847
17931
  key: "destroy",
17848
17932
  value: function destroy() {
17849
- _superPropGet(InstructionPaymentMethodShow, "destroy", this)([]);
17933
+ _superPropGet(InstructionPaymentMethodShow, "destroy", this, 3)([]);
17850
17934
  clearTimeout(this.timeoutId);
17851
17935
  }
17852
17936
  }, {
@@ -20010,8 +20094,11 @@ var ApplePayOpenWalletService = /*#__PURE__*/function (_OpenWalletService) {
20010
20094
  formattedCapabilities = _this6.formatCapabilities(_this6.meta.apple_pay_capabilities);
20011
20095
  }
20012
20096
  ApplePaySession.applePayCapabilities(_this6.getMerchantId()).then(function (capabilities) {
20013
- var canMakePayment = formattedCapabilities.includes(capabilities === null || capabilities === void 0 ? void 0 : capabilities.paymentCredentialStatus);
20014
- resolve(canMakePayment);
20097
+ if (_this6.isUnsuportedBrowser(capabilities)) {
20098
+ return resolve(ApplePaySession.canMakePayments());
20099
+ }
20100
+ var allowedCapability = formattedCapabilities.includes(capabilities === null || capabilities === void 0 ? void 0 : capabilities.paymentCredentialStatus);
20101
+ return resolve(allowedCapability);
20015
20102
  })["catch"](function () {
20016
20103
  resolve(false);
20017
20104
  });
@@ -20272,6 +20359,11 @@ var ApplePayOpenWalletService = /*#__PURE__*/function (_OpenWalletService) {
20272
20359
  applePayLaterAvailability: this.meta.apple_pay_later_availability
20273
20360
  });
20274
20361
  }
20362
+ }, {
20363
+ key: "isUnsuportedBrowser",
20364
+ value: function isUnsuportedBrowser(capabilities) {
20365
+ return (capabilities === null || capabilities === void 0 ? void 0 : capabilities.paymentCredentialStatus) === 'applePayUnsupported';
20366
+ }
20275
20367
  }]);
20276
20368
  }(OpenWalletService);
20277
20369
 
@@ -23689,8 +23781,11 @@ var ApplePayWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
23689
23781
  formattedCapabilities = _this6.formatCapabilities(_this6.meta.apple_pay_capabilities);
23690
23782
  }
23691
23783
  ApplePaySession.applePayCapabilities(config.credentials[WALLET_TYPE.APPLE].merchant).then(function (capabilities) {
23692
- var canMakePayment = formattedCapabilities.includes(capabilities === null || capabilities === void 0 ? void 0 : capabilities.paymentCredentialStatus);
23693
- resolve(canMakePayment);
23784
+ if (_this6.isUnsuportedBrowser(capabilities)) {
23785
+ return resolve(ApplePaySession.canMakePayments());
23786
+ }
23787
+ var allowedCapability = formattedCapabilities.includes(capabilities === null || capabilities === void 0 ? void 0 : capabilities.paymentCredentialStatus);
23788
+ return resolve(allowedCapability);
23694
23789
  })["catch"](function (_err) {
23695
23790
  return resolve(false);
23696
23791
  });
@@ -23861,6 +23956,11 @@ var ApplePayWalletButtonExpress = /*#__PURE__*/function (_BaseWalletButton) {
23861
23956
  var code = codeMap[error.code] || 'unknown';
23862
23957
  return new ApplePayError(code, contactField, error.message);
23863
23958
  }
23959
+ }, {
23960
+ key: "isUnsuportedBrowser",
23961
+ value: function isUnsuportedBrowser(capabilities) {
23962
+ return (capabilities === null || capabilities === void 0 ? void 0 : capabilities.paymentCredentialStatus) === 'applePayUnsupported';
23963
+ }
23864
23964
  }]);
23865
23965
  }(BaseWalletButton);
23866
23966
 
@@ -27412,8 +27512,8 @@ var index$6 = /*#__PURE__*/Object.freeze({
27412
27512
  // * 0's are not included unless the value is a 'relative zero'
27413
27513
  //
27414
27514
 
27415
- var START$1 = 'Start';
27416
- var END$1 = 'End';
27515
+ var START = 'Start';
27516
+ var END = 'End';
27417
27517
  var UNLOAD_EVENT = 'unloadEvent';
27418
27518
  var REDIRECT = 'redirect';
27419
27519
  var DOMAIN_LOOKUP = 'domainLookup';
@@ -27439,26 +27539,26 @@ function addPT(offset, pt) {
27439
27539
  if (!pt) return;
27440
27540
  v.of = offset;
27441
27541
  handleValue(v.of, v, 'n', true);
27442
- handleValue(pt[UNLOAD_EVENT + START$1], v, 'u', isL1Api);
27443
- handleValue(pt[REDIRECT + START$1], v, 'r', isL1Api);
27444
- handleValue(pt[UNLOAD_EVENT + END$1], v, 'ue', isL1Api);
27445
- handleValue(pt[REDIRECT + END$1], v, 're', isL1Api);
27446
- handleValue(pt['fetch' + START$1], v, 'f', isL1Api);
27447
- handleValue(pt[DOMAIN_LOOKUP + START$1], v, 'dn', isL1Api);
27448
- handleValue(pt[DOMAIN_LOOKUP + END$1], v, 'dne', isL1Api);
27449
- handleValue(pt['c' + ONNECT + START$1], v, 'c', isL1Api);
27450
- handleValue(pt['secureC' + ONNECT + 'ion' + START$1], v, 's', isL1Api);
27451
- handleValue(pt['c' + ONNECT + END$1], v, 'ce', isL1Api);
27452
- handleValue(pt[REQUEST + START$1], v, 'rq', isL1Api);
27453
- handleValue(pt[RESPONSE + START$1], v, 'rp', isL1Api);
27454
- handleValue(pt[RESPONSE + END$1], v, 'rpe', isL1Api);
27542
+ handleValue(pt[UNLOAD_EVENT + START], v, 'u', isL1Api);
27543
+ handleValue(pt[REDIRECT + START], v, 'r', isL1Api);
27544
+ handleValue(pt[UNLOAD_EVENT + END], v, 'ue', isL1Api);
27545
+ handleValue(pt[REDIRECT + END], v, 're', isL1Api);
27546
+ handleValue(pt['fetch' + START], v, 'f', isL1Api);
27547
+ handleValue(pt[DOMAIN_LOOKUP + START], v, 'dn', isL1Api);
27548
+ handleValue(pt[DOMAIN_LOOKUP + END], v, 'dne', isL1Api);
27549
+ handleValue(pt['c' + ONNECT + START], v, 'c', isL1Api);
27550
+ handleValue(pt['secureC' + ONNECT + 'ion' + START], v, 's', isL1Api);
27551
+ handleValue(pt['c' + ONNECT + END], v, 'ce', isL1Api);
27552
+ handleValue(pt[REQUEST + START], v, 'rq', isL1Api);
27553
+ handleValue(pt[RESPONSE + START], v, 'rp', isL1Api);
27554
+ handleValue(pt[RESPONSE + END], v, 'rpe', isL1Api);
27455
27555
  handleValue(pt.domLoading, v, 'dl', isL1Api);
27456
27556
  handleValue(pt.domInteractive, v, 'di', isL1Api);
27457
- handleValue(pt[DOM_CONTENT_LOAD_EVENT + START$1], v, 'ds', isL1Api);
27458
- handleValue(pt[DOM_CONTENT_LOAD_EVENT + END$1], v, 'de', isL1Api);
27557
+ handleValue(pt[DOM_CONTENT_LOAD_EVENT + START], v, 'ds', isL1Api);
27558
+ handleValue(pt[DOM_CONTENT_LOAD_EVENT + END], v, 'de', isL1Api);
27459
27559
  handleValue(pt.domComplete, v, 'dc', isL1Api);
27460
- handleValue(pt[LOAD_EVENT + START$1], v, 'l', isL1Api);
27461
- handleValue(pt[LOAD_EVENT + END$1], v, 'le', isL1Api);
27560
+ handleValue(pt[LOAD_EVENT + START], v, 'l', isL1Api);
27561
+ handleValue(pt[LOAD_EVENT + END], v, 'le', isL1Api);
27462
27562
  return v;
27463
27563
  }
27464
27564
 
@@ -29712,21 +29812,11 @@ const FETCH_DONE$1 = 'fetch-done';
29712
29812
  const FETCH_BODY$1 = 'fetch-body-';
29713
29813
  const JSONP_END$1 = 'jsonp-end';
29714
29814
  const originalSetTimeout$1 = originals.ST;
29715
- const START = '-start';
29716
- const END = '-end';
29717
- const BODY = '-body';
29718
- const CB_END = 'cb' + END;
29719
- const JS_TIME = 'jsTime';
29720
- const FETCH = 'fetch';
29721
29815
 
29722
29816
  var CONSTANTS = /*#__PURE__*/Object.freeze({
29723
29817
  __proto__: null,
29724
- BODY: BODY,
29725
- CB_END: CB_END,
29726
29818
  CB_START: CB_START$1,
29727
- END: END,
29728
29819
  FEATURE_NAME: FEATURE_NAME$2,
29729
- FETCH: FETCH,
29730
29820
  FETCH_BODY: FETCH_BODY$1,
29731
29821
  FETCH_DONE: FETCH_DONE$1,
29732
29822
  FETCH_START: FETCH_START$1,
@@ -29737,11 +29827,9 @@ var CONSTANTS = /*#__PURE__*/Object.freeze({
29737
29827
  INTERACTION_EVENTS: INTERACTION_EVENTS$1,
29738
29828
  JSONP_END: JSONP_END$1,
29739
29829
  JSONP_NODE: JSONP_NODE$1,
29740
- JS_TIME: JS_TIME,
29741
29830
  MAX_TIMER_BUDGET: MAX_TIMER_BUDGET$1,
29742
29831
  REMAINING: REMAINING$1,
29743
29832
  SPA_NODE: SPA_NODE$1,
29744
- START: START,
29745
29833
  originalSetTimeout: originalSetTimeout$1
29746
29834
  });
29747
29835
 
@@ -41660,6 +41748,25 @@ var recorder = /*#__PURE__*/Object.freeze({
41660
41748
  // However, the vast majority of the codebase has diverged from UZIP.js to increase performance and reduce bundle size.
41661
41749
  // Sometimes 0 will appear where -1 would be more appropriate. This is because using a uint
41662
41750
  // is better for memory in most engines (I *think*).
41751
+ var ch2 = {};
41752
+ var wk = (function (c, id, msg, transfer, cb) {
41753
+ var w = new Worker(ch2[id] || (ch2[id] = URL.createObjectURL(new Blob([
41754
+ c + ';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'
41755
+ ], { type: 'text/javascript' }))));
41756
+ w.onmessage = function (e) {
41757
+ var d = e.data, ed = d.$e$;
41758
+ if (ed) {
41759
+ var err = new Error(ed[0]);
41760
+ err['code'] = ed[1];
41761
+ err.stack = ed[2];
41762
+ cb(err, null);
41763
+ }
41764
+ else
41765
+ cb(null, d);
41766
+ };
41767
+ w.postMessage(msg, transfer);
41768
+ return w;
41769
+ });
41663
41770
 
41664
41771
  // aliases for shorter compressed code (most minifers don't do this)
41665
41772
  var u8 = Uint8Array, u16 = Uint16Array, u32 = Uint32Array;
@@ -41688,7 +41795,7 @@ var freb = function (eb, start) {
41688
41795
  var _a = freb(fleb, 2), fl = _a[0], revfl = _a[1];
41689
41796
  // we can ignore the fact that the other numbers are wrong; they never happen anyway
41690
41797
  fl[28] = 258, revfl[258] = 28;
41691
- var _b = freb(fdeb, 0), revfd = _b[1];
41798
+ var _b = freb(fdeb, 0), fd = _b[0], revfd = _b[1];
41692
41799
  // map of value to reverse (assuming 16 bits)
41693
41800
  var rev = new u16(32768);
41694
41801
  for (var i = 0; i < 32768; ++i) {
@@ -41765,14 +41872,35 @@ var fdt = new u8(32);
41765
41872
  for (var i = 0; i < 32; ++i)
41766
41873
  fdt[i] = 5;
41767
41874
  // fixed length map
41768
- var flm = /*#__PURE__*/ hMap(flt, 9, 0);
41875
+ var flm = /*#__PURE__*/ hMap(flt, 9, 0), flrm = /*#__PURE__*/ hMap(flt, 9, 1);
41769
41876
  // fixed distance map
41770
- var fdm = /*#__PURE__*/ hMap(fdt, 5, 0);
41877
+ var fdm = /*#__PURE__*/ hMap(fdt, 5, 0), fdrm = /*#__PURE__*/ hMap(fdt, 5, 1);
41878
+ // find max of array
41879
+ var max = function (a) {
41880
+ var m = a[0];
41881
+ for (var i = 1; i < a.length; ++i) {
41882
+ if (a[i] > m)
41883
+ m = a[i];
41884
+ }
41885
+ return m;
41886
+ };
41887
+ // read d, starting at bit p and mask with m
41888
+ var bits = function (d, p, m) {
41889
+ var o = (p / 8) | 0;
41890
+ return ((d[o] | (d[o + 1] << 8)) >> (p & 7)) & m;
41891
+ };
41892
+ // read d, starting at bit p continuing for at least 16 bits
41893
+ var bits16 = function (d, p) {
41894
+ var o = (p / 8) | 0;
41895
+ return ((d[o] | (d[o + 1] << 8) | (d[o + 2] << 16)) >> (p & 7));
41896
+ };
41771
41897
  // get end of byte
41772
41898
  var shft = function (p) { return ((p + 7) / 8) | 0; };
41773
41899
  // typed array slice - allows garbage collector to free original reference,
41774
41900
  // while being more compatible than .slice
41775
41901
  var slc = function (v, s, e) {
41902
+ if (s == null || s < 0)
41903
+ s = 0;
41776
41904
  if (e == null || e > v.length)
41777
41905
  e = v.length;
41778
41906
  // can't use .constructor in case user-supplied
@@ -41780,6 +41908,232 @@ var slc = function (v, s, e) {
41780
41908
  n.set(v.subarray(s, e));
41781
41909
  return n;
41782
41910
  };
41911
+ /**
41912
+ * Codes for errors generated within this library
41913
+ */
41914
+ var FlateErrorCode = {
41915
+ UnexpectedEOF: 0,
41916
+ InvalidBlockType: 1,
41917
+ InvalidLengthLiteral: 2,
41918
+ InvalidDistance: 3,
41919
+ StreamFinished: 4,
41920
+ NoStreamHandler: 5,
41921
+ InvalidHeader: 6,
41922
+ NoCallback: 7,
41923
+ InvalidUTF8: 8,
41924
+ ExtraFieldTooLong: 9,
41925
+ InvalidDate: 10,
41926
+ FilenameTooLong: 11,
41927
+ StreamFinishing: 12,
41928
+ InvalidZipData: 13,
41929
+ UnknownCompressionMethod: 14
41930
+ };
41931
+ // error codes
41932
+ var ec = [
41933
+ 'unexpected EOF',
41934
+ 'invalid block type',
41935
+ 'invalid length/literal',
41936
+ 'invalid distance',
41937
+ 'stream finished',
41938
+ 'no stream handler',
41939
+ ,
41940
+ 'no callback',
41941
+ 'invalid UTF-8 data',
41942
+ 'extra field too long',
41943
+ 'date not in range 1980-2099',
41944
+ 'filename too long',
41945
+ 'stream finishing',
41946
+ 'invalid zip data'
41947
+ // determined by unknown compression method
41948
+ ];
41949
+ var err = function (ind, msg, nt) {
41950
+ var e = new Error(msg || ec[ind]);
41951
+ e.code = ind;
41952
+ if (Error.captureStackTrace)
41953
+ Error.captureStackTrace(e, err);
41954
+ if (!nt)
41955
+ throw e;
41956
+ return e;
41957
+ };
41958
+ // expands raw DEFLATE data
41959
+ var inflt = function (dat, buf, st) {
41960
+ // source length
41961
+ var sl = dat.length;
41962
+ if (!sl || (st && st.f && !st.l))
41963
+ return buf || new u8(0);
41964
+ // have to estimate size
41965
+ var noBuf = !buf || st;
41966
+ // no state
41967
+ var noSt = !st || st.i;
41968
+ if (!st)
41969
+ st = {};
41970
+ // Assumes roughly 33% compression ratio average
41971
+ if (!buf)
41972
+ buf = new u8(sl * 3);
41973
+ // ensure buffer can fit at least l elements
41974
+ var cbuf = function (l) {
41975
+ var bl = buf.length;
41976
+ // need to increase size to fit
41977
+ if (l > bl) {
41978
+ // Double or set to necessary, whichever is greater
41979
+ var nbuf = new u8(Math.max(bl * 2, l));
41980
+ nbuf.set(buf);
41981
+ buf = nbuf;
41982
+ }
41983
+ };
41984
+ // last chunk bitpos bytes
41985
+ var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;
41986
+ // total bits
41987
+ var tbts = sl * 8;
41988
+ do {
41989
+ if (!lm) {
41990
+ // BFINAL - this is only 1 when last chunk is next
41991
+ final = bits(dat, pos, 1);
41992
+ // type: 0 = no compression, 1 = fixed huffman, 2 = dynamic huffman
41993
+ var type = bits(dat, pos + 1, 3);
41994
+ pos += 3;
41995
+ if (!type) {
41996
+ // go to end of byte boundary
41997
+ var s = shft(pos) + 4, l = dat[s - 4] | (dat[s - 3] << 8), t = s + l;
41998
+ if (t > sl) {
41999
+ if (noSt)
42000
+ err(0);
42001
+ break;
42002
+ }
42003
+ // ensure size
42004
+ if (noBuf)
42005
+ cbuf(bt + l);
42006
+ // Copy over uncompressed data
42007
+ buf.set(dat.subarray(s, t), bt);
42008
+ // Get new bitpos, update byte count
42009
+ st.b = bt += l, st.p = pos = t * 8, st.f = final;
42010
+ continue;
42011
+ }
42012
+ else if (type == 1)
42013
+ lm = flrm, dm = fdrm, lbt = 9, dbt = 5;
42014
+ else if (type == 2) {
42015
+ // literal lengths
42016
+ var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;
42017
+ var tl = hLit + bits(dat, pos + 5, 31) + 1;
42018
+ pos += 14;
42019
+ // length+distance tree
42020
+ var ldt = new u8(tl);
42021
+ // code length tree
42022
+ var clt = new u8(19);
42023
+ for (var i = 0; i < hcLen; ++i) {
42024
+ // use index map to get real code
42025
+ clt[clim[i]] = bits(dat, pos + i * 3, 7);
42026
+ }
42027
+ pos += hcLen * 3;
42028
+ // code lengths bits
42029
+ var clb = max(clt), clbmsk = (1 << clb) - 1;
42030
+ // code lengths map
42031
+ var clm = hMap(clt, clb, 1);
42032
+ for (var i = 0; i < tl;) {
42033
+ var r = clm[bits(dat, pos, clbmsk)];
42034
+ // bits read
42035
+ pos += r & 15;
42036
+ // symbol
42037
+ var s = r >>> 4;
42038
+ // code length to copy
42039
+ if (s < 16) {
42040
+ ldt[i++] = s;
42041
+ }
42042
+ else {
42043
+ // copy count
42044
+ var c = 0, n = 0;
42045
+ if (s == 16)
42046
+ n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];
42047
+ else if (s == 17)
42048
+ n = 3 + bits(dat, pos, 7), pos += 3;
42049
+ else if (s == 18)
42050
+ n = 11 + bits(dat, pos, 127), pos += 7;
42051
+ while (n--)
42052
+ ldt[i++] = c;
42053
+ }
42054
+ }
42055
+ // length tree distance tree
42056
+ var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
42057
+ // max length bits
42058
+ lbt = max(lt);
42059
+ // max dist bits
42060
+ dbt = max(dt);
42061
+ lm = hMap(lt, lbt, 1);
42062
+ dm = hMap(dt, dbt, 1);
42063
+ }
42064
+ else
42065
+ err(1);
42066
+ if (pos > tbts) {
42067
+ if (noSt)
42068
+ err(0);
42069
+ break;
42070
+ }
42071
+ }
42072
+ // Make sure the buffer can hold this + the largest possible addition
42073
+ // Maximum chunk size (practically, theoretically infinite) is 2^17;
42074
+ if (noBuf)
42075
+ cbuf(bt + 131072);
42076
+ var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
42077
+ var lpos = pos;
42078
+ for (;; lpos = pos) {
42079
+ // bits read, code
42080
+ var c = lm[bits16(dat, pos) & lms], sym = c >>> 4;
42081
+ pos += c & 15;
42082
+ if (pos > tbts) {
42083
+ if (noSt)
42084
+ err(0);
42085
+ break;
42086
+ }
42087
+ if (!c)
42088
+ err(2);
42089
+ if (sym < 256)
42090
+ buf[bt++] = sym;
42091
+ else if (sym == 256) {
42092
+ lpos = pos, lm = null;
42093
+ break;
42094
+ }
42095
+ else {
42096
+ var add = sym - 254;
42097
+ // no extra bits needed if less
42098
+ if (sym > 264) {
42099
+ // index
42100
+ var i = sym - 257, b = fleb[i];
42101
+ add = bits(dat, pos, (1 << b) - 1) + fl[i];
42102
+ pos += b;
42103
+ }
42104
+ // dist
42105
+ var d = dm[bits16(dat, pos) & dms], dsym = d >>> 4;
42106
+ if (!d)
42107
+ err(3);
42108
+ pos += d & 15;
42109
+ var dt = fd[dsym];
42110
+ if (dsym > 3) {
42111
+ var b = fdeb[dsym];
42112
+ dt += bits16(dat, pos) & ((1 << b) - 1), pos += b;
42113
+ }
42114
+ if (pos > tbts) {
42115
+ if (noSt)
42116
+ err(0);
42117
+ break;
42118
+ }
42119
+ if (noBuf)
42120
+ cbuf(bt + 131072);
42121
+ var end = bt + add;
42122
+ for (; bt < end; bt += 4) {
42123
+ buf[bt] = buf[bt - dt];
42124
+ buf[bt + 1] = buf[bt + 1 - dt];
42125
+ buf[bt + 2] = buf[bt + 2 - dt];
42126
+ buf[bt + 3] = buf[bt + 3 - dt];
42127
+ }
42128
+ bt = end;
42129
+ }
42130
+ }
42131
+ st.l = lm, st.p = lpos, st.b = bt, st.f = final;
42132
+ if (lm)
42133
+ final = 1, st.m = lbt, st.d = dm, st.n = dbt;
42134
+ } while (!final);
42135
+ return bt == buf.length ? buf : slc(buf, 0, bt);
42136
+ };
41783
42137
  // starting at p, write the minimum number of bits that can hold v to d
41784
42138
  var wbits = function (d, p, v) {
41785
42139
  v <<= p & 7;
@@ -42117,6 +42471,9 @@ var dflt = function (dat, lvl, plvl, pre, post, lst) {
42117
42471
  }
42118
42472
  }
42119
42473
  pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i - bs, pos);
42474
+ // this is the easiest way to avoid needing to maintain state
42475
+ if (!lst && pos & 7)
42476
+ pos = wfblk(w, pos + 1, et);
42120
42477
  }
42121
42478
  return slc(o, 0, pre + shft(pos) + post);
42122
42479
  };
@@ -42145,10 +42502,156 @@ var crc = function () {
42145
42502
  d: function () { return ~c; }
42146
42503
  };
42147
42504
  };
42505
+ // Alder32
42506
+ var adler = function () {
42507
+ var a = 1, b = 0;
42508
+ return {
42509
+ p: function (d) {
42510
+ // closures have awful performance
42511
+ var n = a, m = b;
42512
+ var l = d.length | 0;
42513
+ for (var i = 0; i != l;) {
42514
+ var e = Math.min(i + 2655, l);
42515
+ for (; i < e; ++i)
42516
+ m += n += d[i];
42517
+ n = (n & 65535) + 15 * (n >> 16), m = (m & 65535) + 15 * (m >> 16);
42518
+ }
42519
+ a = n, b = m;
42520
+ },
42521
+ d: function () {
42522
+ a %= 65521, b %= 65521;
42523
+ return (a & 255) << 24 | (a >>> 8) << 16 | (b & 255) << 8 | (b >>> 8);
42524
+ }
42525
+ };
42526
+ };
42148
42527
  // deflate with opts
42149
42528
  var dopt = function (dat, opt, pre, post, st) {
42150
- return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : (12 + opt.mem), pre, post, true);
42529
+ return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : (12 + opt.mem), pre, post, !st);
42530
+ };
42531
+ // Walmart object spread
42532
+ var mrg = function (a, b) {
42533
+ var o = {};
42534
+ for (var k in a)
42535
+ o[k] = a[k];
42536
+ for (var k in b)
42537
+ o[k] = b[k];
42538
+ return o;
42539
+ };
42540
+ // worker clone
42541
+ // This is possibly the craziest part of the entire codebase, despite how simple it may seem.
42542
+ // The only parameter to this function is a closure that returns an array of variables outside of the function scope.
42543
+ // We're going to try to figure out the variable names used in the closure as strings because that is crucial for workerization.
42544
+ // We will return an object mapping of true variable name to value (basically, the current scope as a JS object).
42545
+ // The reason we can't just use the original variable names is minifiers mangling the toplevel scope.
42546
+ // This took me three weeks to figure out how to do.
42547
+ var wcln = function (fn, fnStr, td) {
42548
+ var dt = fn();
42549
+ var st = fn.toString();
42550
+ var ks = st.slice(st.indexOf('[') + 1, st.lastIndexOf(']')).replace(/\s+/g, '').split(',');
42551
+ for (var i = 0; i < dt.length; ++i) {
42552
+ var v = dt[i], k = ks[i];
42553
+ if (typeof v == 'function') {
42554
+ fnStr += ';' + k + '=';
42555
+ var st_1 = v.toString();
42556
+ if (v.prototype) {
42557
+ // for global objects
42558
+ if (st_1.indexOf('[native code]') != -1) {
42559
+ var spInd = st_1.indexOf(' ', 8) + 1;
42560
+ fnStr += st_1.slice(spInd, st_1.indexOf('(', spInd));
42561
+ }
42562
+ else {
42563
+ fnStr += st_1;
42564
+ for (var t in v.prototype)
42565
+ fnStr += ';' + k + '.prototype.' + t + '=' + v.prototype[t].toString();
42566
+ }
42567
+ }
42568
+ else
42569
+ fnStr += st_1;
42570
+ }
42571
+ else
42572
+ td[k] = v;
42573
+ }
42574
+ return [fnStr, td];
42575
+ };
42576
+ var ch = [];
42577
+ // clone bufs
42578
+ var cbfs = function (v) {
42579
+ var tl = [];
42580
+ for (var k in v) {
42581
+ if (v[k].buffer) {
42582
+ tl.push((v[k] = new v[k].constructor(v[k])).buffer);
42583
+ }
42584
+ }
42585
+ return tl;
42586
+ };
42587
+ // use a worker to execute code
42588
+ var wrkr = function (fns, init, id, cb) {
42589
+ var _a;
42590
+ if (!ch[id]) {
42591
+ var fnStr = '', td_1 = {}, m = fns.length - 1;
42592
+ for (var i = 0; i < m; ++i)
42593
+ _a = wcln(fns[i], fnStr, td_1), fnStr = _a[0], td_1 = _a[1];
42594
+ ch[id] = wcln(fns[m], fnStr, td_1);
42595
+ }
42596
+ var td = mrg({}, ch[id][1]);
42597
+ return wk(ch[id][0] + ';onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=' + init.toString() + '}', id, td, cbfs(td), cb);
42598
+ };
42599
+ // base async inflate fn
42600
+ var bInflt = function () { return [u8, u16, u32, fleb, fdeb, clim, fl, fd, flrm, fdrm, rev, ec, hMap, max, bits, bits16, shft, slc, err, inflt, inflateSync, pbf, gu8]; };
42601
+ var bDflt = function () { return [u8, u16, u32, fleb, fdeb, clim, revfl, revfd, flm, flt, fdm, fdt, rev, deo, et, hMap, wbits, wbits16, hTree, ln, lc, clen, wfblk, wblk, shft, slc, dflt, dopt, deflateSync, pbf]; };
42602
+ // gzip extra
42603
+ var gze = function () { return [gzh, gzhl, wbytes, crc, crct]; };
42604
+ // gunzip extra
42605
+ var guze = function () { return [gzs, gzl]; };
42606
+ // zlib extra
42607
+ var zle = function () { return [zlh, wbytes, adler]; };
42608
+ // unzlib extra
42609
+ var zule = function () { return [zlv]; };
42610
+ // post buf
42611
+ var pbf = function (msg) { return postMessage(msg, [msg.buffer]); };
42612
+ // get u8
42613
+ var gu8 = function (o) { return o && o.size && new u8(o.size); };
42614
+ // async helper
42615
+ var cbify = function (dat, opts, fns, init, id, cb) {
42616
+ var w = wrkr(fns, init, id, function (err, dat) {
42617
+ w.terminate();
42618
+ cb(err, dat);
42619
+ });
42620
+ w.postMessage([dat, opts], opts.consume ? [dat.buffer] : []);
42621
+ return function () { w.terminate(); };
42151
42622
  };
42623
+ // auto stream
42624
+ var astrm = function (strm) {
42625
+ strm.ondata = function (dat, final) { return postMessage([dat, final], [dat.buffer]); };
42626
+ return function (ev) { return strm.push(ev.data[0], ev.data[1]); };
42627
+ };
42628
+ // async stream attach
42629
+ var astrmify = function (fns, strm, opts, init, id) {
42630
+ var t;
42631
+ var w = wrkr(fns, init, id, function (err, dat) {
42632
+ if (err)
42633
+ w.terminate(), strm.ondata.call(strm, err);
42634
+ else {
42635
+ if (dat[1])
42636
+ w.terminate();
42637
+ strm.ondata.call(strm, err, dat[0], dat[1]);
42638
+ }
42639
+ });
42640
+ w.postMessage(opts);
42641
+ strm.push = function (d, f) {
42642
+ if (!strm.ondata)
42643
+ err(5);
42644
+ if (t)
42645
+ strm.ondata(err(4, 0, 1), null, !!f);
42646
+ w.postMessage([d, t = f], [d.buffer]);
42647
+ };
42648
+ strm.terminate = function () { w.terminate(); };
42649
+ };
42650
+ // read 2 bytes
42651
+ var b2 = function (d, b) { return d[b] | (d[b + 1] << 8); };
42652
+ // read 4 bytes
42653
+ var b4 = function (d, b) { return (d[b] | (d[b + 1] << 8) | (d[b + 2] << 16) | (d[b + 3] << 24)) >>> 0; };
42654
+ var b8 = function (d, b) { return b4(d, b) + (b4(d, b + 4) * 4294967296); };
42152
42655
  // write bytes
42153
42656
  var wbytes = function (d, b, v) {
42154
42657
  for (; v; ++b)
@@ -42166,8 +42669,242 @@ var gzh = function (c, o) {
42166
42669
  c[i + 10] = fn.charCodeAt(i);
42167
42670
  }
42168
42671
  };
42672
+ // gzip footer: -8 to -4 = CRC, -4 to -0 is length
42673
+ // gzip start
42674
+ var gzs = function (d) {
42675
+ if (d[0] != 31 || d[1] != 139 || d[2] != 8)
42676
+ err(6, 'invalid gzip data');
42677
+ var flg = d[3];
42678
+ var st = 10;
42679
+ if (flg & 4)
42680
+ st += d[10] | (d[11] << 8) + 2;
42681
+ for (var zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++])
42682
+ ;
42683
+ return st + (flg & 2);
42684
+ };
42685
+ // gzip length
42686
+ var gzl = function (d) {
42687
+ var l = d.length;
42688
+ return ((d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16) | (d[l - 1] << 24)) >>> 0;
42689
+ };
42169
42690
  // gzip header length
42170
42691
  var gzhl = function (o) { return 10 + ((o.filename && (o.filename.length + 1)) || 0); };
42692
+ // zlib header
42693
+ var zlh = function (c, o) {
42694
+ var lv = o.level, fl = lv == 0 ? 0 : lv < 6 ? 1 : lv == 9 ? 3 : 2;
42695
+ c[0] = 120, c[1] = (fl << 6) | (fl ? (32 - 2 * fl) : 1);
42696
+ };
42697
+ // zlib valid
42698
+ var zlv = function (d) {
42699
+ if ((d[0] & 15) != 8 || (d[0] >>> 4) > 7 || ((d[0] << 8 | d[1]) % 31))
42700
+ err(6, 'invalid zlib data');
42701
+ if (d[1] & 32)
42702
+ err(6, 'invalid zlib data: preset dictionaries not supported');
42703
+ };
42704
+ function AsyncCmpStrm(opts, cb) {
42705
+ if (!cb && typeof opts == 'function')
42706
+ cb = opts, opts = {};
42707
+ this.ondata = cb;
42708
+ return opts;
42709
+ }
42710
+ // zlib footer: -4 to -0 is Adler32
42711
+ /**
42712
+ * Streaming DEFLATE compression
42713
+ */
42714
+ var Deflate = /*#__PURE__*/ (function () {
42715
+ function Deflate(opts, cb) {
42716
+ if (!cb && typeof opts == 'function')
42717
+ cb = opts, opts = {};
42718
+ this.ondata = cb;
42719
+ this.o = opts || {};
42720
+ }
42721
+ Deflate.prototype.p = function (c, f) {
42722
+ this.ondata(dopt(c, this.o, 0, 0, !f), f);
42723
+ };
42724
+ /**
42725
+ * Pushes a chunk to be deflated
42726
+ * @param chunk The chunk to push
42727
+ * @param final Whether this is the last chunk
42728
+ */
42729
+ Deflate.prototype.push = function (chunk, final) {
42730
+ if (!this.ondata)
42731
+ err(5);
42732
+ if (this.d)
42733
+ err(4);
42734
+ this.d = final;
42735
+ this.p(chunk, final || false);
42736
+ };
42737
+ return Deflate;
42738
+ }());
42739
+ /**
42740
+ * Asynchronous streaming DEFLATE compression
42741
+ */
42742
+ var AsyncDeflate = /*#__PURE__*/ (function () {
42743
+ function AsyncDeflate(opts, cb) {
42744
+ astrmify([
42745
+ bDflt,
42746
+ function () { return [astrm, Deflate]; }
42747
+ ], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {
42748
+ var strm = new Deflate(ev.data);
42749
+ onmessage = astrm(strm);
42750
+ }, 6);
42751
+ }
42752
+ return AsyncDeflate;
42753
+ }());
42754
+ function deflate(data, opts, cb) {
42755
+ if (!cb)
42756
+ cb = opts, opts = {};
42757
+ if (typeof cb != 'function')
42758
+ err(7);
42759
+ return cbify(data, opts, [
42760
+ bDflt,
42761
+ ], function (ev) { return pbf(deflateSync(ev.data[0], ev.data[1])); }, 0, cb);
42762
+ }
42763
+ /**
42764
+ * Compresses data with DEFLATE without any wrapper
42765
+ * @param data The data to compress
42766
+ * @param opts The compression options
42767
+ * @returns The deflated version of the data
42768
+ */
42769
+ function deflateSync(data, opts) {
42770
+ return dopt(data, opts || {}, 0, 0);
42771
+ }
42772
+ /**
42773
+ * Streaming DEFLATE decompression
42774
+ */
42775
+ var Inflate = /*#__PURE__*/ (function () {
42776
+ /**
42777
+ * Creates an inflation stream
42778
+ * @param cb The callback to call whenever data is inflated
42779
+ */
42780
+ function Inflate(cb) {
42781
+ this.s = {};
42782
+ this.p = new u8(0);
42783
+ this.ondata = cb;
42784
+ }
42785
+ Inflate.prototype.e = function (c) {
42786
+ if (!this.ondata)
42787
+ err(5);
42788
+ if (this.d)
42789
+ err(4);
42790
+ var l = this.p.length;
42791
+ var n = new u8(l + c.length);
42792
+ n.set(this.p), n.set(c, l), this.p = n;
42793
+ };
42794
+ Inflate.prototype.c = function (final) {
42795
+ this.d = this.s.i = final || false;
42796
+ var bts = this.s.b;
42797
+ var dt = inflt(this.p, this.o, this.s);
42798
+ this.ondata(slc(dt, bts, this.s.b), this.d);
42799
+ this.o = slc(dt, this.s.b - 32768), this.s.b = this.o.length;
42800
+ this.p = slc(this.p, (this.s.p / 8) | 0), this.s.p &= 7;
42801
+ };
42802
+ /**
42803
+ * Pushes a chunk to be inflated
42804
+ * @param chunk The chunk to push
42805
+ * @param final Whether this is the final chunk
42806
+ */
42807
+ Inflate.prototype.push = function (chunk, final) {
42808
+ this.e(chunk), this.c(final);
42809
+ };
42810
+ return Inflate;
42811
+ }());
42812
+ /**
42813
+ * Asynchronous streaming DEFLATE decompression
42814
+ */
42815
+ var AsyncInflate = /*#__PURE__*/ (function () {
42816
+ /**
42817
+ * Creates an asynchronous inflation stream
42818
+ * @param cb The callback to call whenever data is deflated
42819
+ */
42820
+ function AsyncInflate(cb) {
42821
+ this.ondata = cb;
42822
+ astrmify([
42823
+ bInflt,
42824
+ function () { return [astrm, Inflate]; }
42825
+ ], this, 0, function () {
42826
+ var strm = new Inflate();
42827
+ onmessage = astrm(strm);
42828
+ }, 7);
42829
+ }
42830
+ return AsyncInflate;
42831
+ }());
42832
+ function inflate(data, opts, cb) {
42833
+ if (!cb)
42834
+ cb = opts, opts = {};
42835
+ if (typeof cb != 'function')
42836
+ err(7);
42837
+ return cbify(data, opts, [
42838
+ bInflt
42839
+ ], function (ev) { return pbf(inflateSync(ev.data[0], gu8(ev.data[1]))); }, 1, cb);
42840
+ }
42841
+ /**
42842
+ * Expands DEFLATE data with no wrapper
42843
+ * @param data The data to decompress
42844
+ * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.
42845
+ * @returns The decompressed version of the data
42846
+ */
42847
+ function inflateSync(data, out) {
42848
+ return inflt(data, out);
42849
+ }
42850
+ // before you yell at me for not just using extends, my reason is that TS inheritance is hard to workerize.
42851
+ /**
42852
+ * Streaming GZIP compression
42853
+ */
42854
+ var Gzip = /*#__PURE__*/ (function () {
42855
+ function Gzip(opts, cb) {
42856
+ this.c = crc();
42857
+ this.l = 0;
42858
+ this.v = 1;
42859
+ Deflate.call(this, opts, cb);
42860
+ }
42861
+ /**
42862
+ * Pushes a chunk to be GZIPped
42863
+ * @param chunk The chunk to push
42864
+ * @param final Whether this is the last chunk
42865
+ */
42866
+ Gzip.prototype.push = function (chunk, final) {
42867
+ Deflate.prototype.push.call(this, chunk, final);
42868
+ };
42869
+ Gzip.prototype.p = function (c, f) {
42870
+ this.c.p(c);
42871
+ this.l += c.length;
42872
+ var raw = dopt(c, this.o, this.v && gzhl(this.o), f && 8, !f);
42873
+ if (this.v)
42874
+ gzh(raw, this.o), this.v = 0;
42875
+ if (f)
42876
+ wbytes(raw, raw.length - 8, this.c.d()), wbytes(raw, raw.length - 4, this.l);
42877
+ this.ondata(raw, f);
42878
+ };
42879
+ return Gzip;
42880
+ }());
42881
+ /**
42882
+ * Asynchronous streaming GZIP compression
42883
+ */
42884
+ var AsyncGzip = /*#__PURE__*/ (function () {
42885
+ function AsyncGzip(opts, cb) {
42886
+ astrmify([
42887
+ bDflt,
42888
+ gze,
42889
+ function () { return [astrm, Deflate, Gzip]; }
42890
+ ], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {
42891
+ var strm = new Gzip(ev.data);
42892
+ onmessage = astrm(strm);
42893
+ }, 8);
42894
+ }
42895
+ return AsyncGzip;
42896
+ }());
42897
+ function gzip(data, opts, cb) {
42898
+ if (!cb)
42899
+ cb = opts, opts = {};
42900
+ if (typeof cb != 'function')
42901
+ err(7);
42902
+ return cbify(data, opts, [
42903
+ bDflt,
42904
+ gze,
42905
+ function () { return [gzipSync]; }
42906
+ ], function (ev) { return pbf(gzipSync(ev.data[0], ev.data[1])); }, 2, cb);
42907
+ }
42171
42908
  /**
42172
42909
  * Compresses data with GZIP
42173
42910
  * @param data The data to compress
@@ -42182,6 +42919,336 @@ function gzipSync(data, opts) {
42182
42919
  var d = dopt(data, opts, gzhl(opts), 8), s = d.length;
42183
42920
  return gzh(d, opts), wbytes(d, s - 8, c.d()), wbytes(d, s - 4, l), d;
42184
42921
  }
42922
+ /**
42923
+ * Streaming GZIP decompression
42924
+ */
42925
+ var Gunzip = /*#__PURE__*/ (function () {
42926
+ /**
42927
+ * Creates a GUNZIP stream
42928
+ * @param cb The callback to call whenever data is inflated
42929
+ */
42930
+ function Gunzip(cb) {
42931
+ this.v = 1;
42932
+ Inflate.call(this, cb);
42933
+ }
42934
+ /**
42935
+ * Pushes a chunk to be GUNZIPped
42936
+ * @param chunk The chunk to push
42937
+ * @param final Whether this is the last chunk
42938
+ */
42939
+ Gunzip.prototype.push = function (chunk, final) {
42940
+ Inflate.prototype.e.call(this, chunk);
42941
+ if (this.v) {
42942
+ var s = this.p.length > 3 ? gzs(this.p) : 4;
42943
+ if (s >= this.p.length && !final)
42944
+ return;
42945
+ this.p = this.p.subarray(s), this.v = 0;
42946
+ }
42947
+ if (final) {
42948
+ if (this.p.length < 8)
42949
+ err(6, 'invalid gzip data');
42950
+ this.p = this.p.subarray(0, -8);
42951
+ }
42952
+ // necessary to prevent TS from using the closure value
42953
+ // This allows for workerization to function correctly
42954
+ Inflate.prototype.c.call(this, final);
42955
+ };
42956
+ return Gunzip;
42957
+ }());
42958
+ /**
42959
+ * Asynchronous streaming GZIP decompression
42960
+ */
42961
+ var AsyncGunzip = /*#__PURE__*/ (function () {
42962
+ /**
42963
+ * Creates an asynchronous GUNZIP stream
42964
+ * @param cb The callback to call whenever data is deflated
42965
+ */
42966
+ function AsyncGunzip(cb) {
42967
+ this.ondata = cb;
42968
+ astrmify([
42969
+ bInflt,
42970
+ guze,
42971
+ function () { return [astrm, Inflate, Gunzip]; }
42972
+ ], this, 0, function () {
42973
+ var strm = new Gunzip();
42974
+ onmessage = astrm(strm);
42975
+ }, 9);
42976
+ }
42977
+ return AsyncGunzip;
42978
+ }());
42979
+ function gunzip(data, opts, cb) {
42980
+ if (!cb)
42981
+ cb = opts, opts = {};
42982
+ if (typeof cb != 'function')
42983
+ err(7);
42984
+ return cbify(data, opts, [
42985
+ bInflt,
42986
+ guze,
42987
+ function () { return [gunzipSync]; }
42988
+ ], function (ev) { return pbf(gunzipSync(ev.data[0])); }, 3, cb);
42989
+ }
42990
+ /**
42991
+ * Expands GZIP data
42992
+ * @param data The data to decompress
42993
+ * @param out Where to write the data. GZIP already encodes the output size, so providing this doesn't save memory.
42994
+ * @returns The decompressed version of the data
42995
+ */
42996
+ function gunzipSync(data, out) {
42997
+ return inflt(data.subarray(gzs(data), -8), out || new u8(gzl(data)));
42998
+ }
42999
+ /**
43000
+ * Streaming Zlib compression
43001
+ */
43002
+ var Zlib = /*#__PURE__*/ (function () {
43003
+ function Zlib(opts, cb) {
43004
+ this.c = adler();
43005
+ this.v = 1;
43006
+ Deflate.call(this, opts, cb);
43007
+ }
43008
+ /**
43009
+ * Pushes a chunk to be zlibbed
43010
+ * @param chunk The chunk to push
43011
+ * @param final Whether this is the last chunk
43012
+ */
43013
+ Zlib.prototype.push = function (chunk, final) {
43014
+ Deflate.prototype.push.call(this, chunk, final);
43015
+ };
43016
+ Zlib.prototype.p = function (c, f) {
43017
+ this.c.p(c);
43018
+ var raw = dopt(c, this.o, this.v && 2, f && 4, !f);
43019
+ if (this.v)
43020
+ zlh(raw, this.o), this.v = 0;
43021
+ if (f)
43022
+ wbytes(raw, raw.length - 4, this.c.d());
43023
+ this.ondata(raw, f);
43024
+ };
43025
+ return Zlib;
43026
+ }());
43027
+ /**
43028
+ * Asynchronous streaming Zlib compression
43029
+ */
43030
+ var AsyncZlib = /*#__PURE__*/ (function () {
43031
+ function AsyncZlib(opts, cb) {
43032
+ astrmify([
43033
+ bDflt,
43034
+ zle,
43035
+ function () { return [astrm, Deflate, Zlib]; }
43036
+ ], this, AsyncCmpStrm.call(this, opts, cb), function (ev) {
43037
+ var strm = new Zlib(ev.data);
43038
+ onmessage = astrm(strm);
43039
+ }, 10);
43040
+ }
43041
+ return AsyncZlib;
43042
+ }());
43043
+ function zlib(data, opts, cb) {
43044
+ if (!cb)
43045
+ cb = opts, opts = {};
43046
+ if (typeof cb != 'function')
43047
+ err(7);
43048
+ return cbify(data, opts, [
43049
+ bDflt,
43050
+ zle,
43051
+ function () { return [zlibSync]; }
43052
+ ], function (ev) { return pbf(zlibSync(ev.data[0], ev.data[1])); }, 4, cb);
43053
+ }
43054
+ /**
43055
+ * Compress data with Zlib
43056
+ * @param data The data to compress
43057
+ * @param opts The compression options
43058
+ * @returns The zlib-compressed version of the data
43059
+ */
43060
+ function zlibSync(data, opts) {
43061
+ if (!opts)
43062
+ opts = {};
43063
+ var a = adler();
43064
+ a.p(data);
43065
+ var d = dopt(data, opts, 2, 4);
43066
+ return zlh(d, opts), wbytes(d, d.length - 4, a.d()), d;
43067
+ }
43068
+ /**
43069
+ * Streaming Zlib decompression
43070
+ */
43071
+ var Unzlib = /*#__PURE__*/ (function () {
43072
+ /**
43073
+ * Creates a Zlib decompression stream
43074
+ * @param cb The callback to call whenever data is inflated
43075
+ */
43076
+ function Unzlib(cb) {
43077
+ this.v = 1;
43078
+ Inflate.call(this, cb);
43079
+ }
43080
+ /**
43081
+ * Pushes a chunk to be unzlibbed
43082
+ * @param chunk The chunk to push
43083
+ * @param final Whether this is the last chunk
43084
+ */
43085
+ Unzlib.prototype.push = function (chunk, final) {
43086
+ Inflate.prototype.e.call(this, chunk);
43087
+ if (this.v) {
43088
+ if (this.p.length < 2 && !final)
43089
+ return;
43090
+ this.p = this.p.subarray(2), this.v = 0;
43091
+ }
43092
+ if (final) {
43093
+ if (this.p.length < 4)
43094
+ err(6, 'invalid zlib data');
43095
+ this.p = this.p.subarray(0, -4);
43096
+ }
43097
+ // necessary to prevent TS from using the closure value
43098
+ // This allows for workerization to function correctly
43099
+ Inflate.prototype.c.call(this, final);
43100
+ };
43101
+ return Unzlib;
43102
+ }());
43103
+ /**
43104
+ * Asynchronous streaming Zlib decompression
43105
+ */
43106
+ var AsyncUnzlib = /*#__PURE__*/ (function () {
43107
+ /**
43108
+ * Creates an asynchronous Zlib decompression stream
43109
+ * @param cb The callback to call whenever data is deflated
43110
+ */
43111
+ function AsyncUnzlib(cb) {
43112
+ this.ondata = cb;
43113
+ astrmify([
43114
+ bInflt,
43115
+ zule,
43116
+ function () { return [astrm, Inflate, Unzlib]; }
43117
+ ], this, 0, function () {
43118
+ var strm = new Unzlib();
43119
+ onmessage = astrm(strm);
43120
+ }, 11);
43121
+ }
43122
+ return AsyncUnzlib;
43123
+ }());
43124
+ function unzlib(data, opts, cb) {
43125
+ if (!cb)
43126
+ cb = opts, opts = {};
43127
+ if (typeof cb != 'function')
43128
+ err(7);
43129
+ return cbify(data, opts, [
43130
+ bInflt,
43131
+ zule,
43132
+ function () { return [unzlibSync]; }
43133
+ ], function (ev) { return pbf(unzlibSync(ev.data[0], gu8(ev.data[1]))); }, 5, cb);
43134
+ }
43135
+ /**
43136
+ * Expands Zlib data
43137
+ * @param data The data to decompress
43138
+ * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.
43139
+ * @returns The decompressed version of the data
43140
+ */
43141
+ function unzlibSync(data, out) {
43142
+ return inflt((zlv(data), data.subarray(2, -4)), out);
43143
+ }
43144
+ /**
43145
+ * Streaming GZIP, Zlib, or raw DEFLATE decompression
43146
+ */
43147
+ var Decompress = /*#__PURE__*/ (function () {
43148
+ /**
43149
+ * Creates a decompression stream
43150
+ * @param cb The callback to call whenever data is decompressed
43151
+ */
43152
+ function Decompress(cb) {
43153
+ this.G = Gunzip;
43154
+ this.I = Inflate;
43155
+ this.Z = Unzlib;
43156
+ this.ondata = cb;
43157
+ }
43158
+ /**
43159
+ * Pushes a chunk to be decompressed
43160
+ * @param chunk The chunk to push
43161
+ * @param final Whether this is the last chunk
43162
+ */
43163
+ Decompress.prototype.push = function (chunk, final) {
43164
+ if (!this.ondata)
43165
+ err(5);
43166
+ if (!this.s) {
43167
+ if (this.p && this.p.length) {
43168
+ var n = new u8(this.p.length + chunk.length);
43169
+ n.set(this.p), n.set(chunk, this.p.length);
43170
+ }
43171
+ else
43172
+ this.p = chunk;
43173
+ if (this.p.length > 2) {
43174
+ var _this_1 = this;
43175
+ var cb = function () { _this_1.ondata.apply(_this_1, arguments); };
43176
+ this.s = (this.p[0] == 31 && this.p[1] == 139 && this.p[2] == 8)
43177
+ ? new this.G(cb)
43178
+ : ((this.p[0] & 15) != 8 || (this.p[0] >> 4) > 7 || ((this.p[0] << 8 | this.p[1]) % 31))
43179
+ ? new this.I(cb)
43180
+ : new this.Z(cb);
43181
+ this.s.push(this.p, final);
43182
+ this.p = null;
43183
+ }
43184
+ }
43185
+ else
43186
+ this.s.push(chunk, final);
43187
+ };
43188
+ return Decompress;
43189
+ }());
43190
+ /**
43191
+ * Asynchronous streaming GZIP, Zlib, or raw DEFLATE decompression
43192
+ */
43193
+ var AsyncDecompress = /*#__PURE__*/ (function () {
43194
+ /**
43195
+ * Creates an asynchronous decompression stream
43196
+ * @param cb The callback to call whenever data is decompressed
43197
+ */
43198
+ function AsyncDecompress(cb) {
43199
+ this.G = AsyncGunzip;
43200
+ this.I = AsyncInflate;
43201
+ this.Z = AsyncUnzlib;
43202
+ this.ondata = cb;
43203
+ }
43204
+ /**
43205
+ * Pushes a chunk to be decompressed
43206
+ * @param chunk The chunk to push
43207
+ * @param final Whether this is the last chunk
43208
+ */
43209
+ AsyncDecompress.prototype.push = function (chunk, final) {
43210
+ Decompress.prototype.push.call(this, chunk, final);
43211
+ };
43212
+ return AsyncDecompress;
43213
+ }());
43214
+ function decompress(data, opts, cb) {
43215
+ if (!cb)
43216
+ cb = opts, opts = {};
43217
+ if (typeof cb != 'function')
43218
+ err(7);
43219
+ return (data[0] == 31 && data[1] == 139 && data[2] == 8)
43220
+ ? gunzip(data, opts, cb)
43221
+ : ((data[0] & 15) != 8 || (data[0] >> 4) > 7 || ((data[0] << 8 | data[1]) % 31))
43222
+ ? inflate(data, opts, cb)
43223
+ : unzlib(data, opts, cb);
43224
+ }
43225
+ /**
43226
+ * Expands compressed GZIP, Zlib, or raw DEFLATE data, automatically detecting the format
43227
+ * @param data The data to decompress
43228
+ * @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.
43229
+ * @returns The decompressed version of the data
43230
+ */
43231
+ function decompressSync(data, out) {
43232
+ return (data[0] == 31 && data[1] == 139 && data[2] == 8)
43233
+ ? gunzipSync(data, out)
43234
+ : ((data[0] & 15) != 8 || (data[0] >> 4) > 7 || ((data[0] << 8 | data[1]) % 31))
43235
+ ? inflateSync(data, out)
43236
+ : unzlibSync(data, out);
43237
+ }
43238
+ // flatten a directory structure
43239
+ var fltn = function (d, p, t, o) {
43240
+ for (var k in d) {
43241
+ var val = d[k], n = p + k, op = o;
43242
+ if (Array.isArray(val))
43243
+ op = mrg(o, val[1]), val = val[0];
43244
+ if (val instanceof u8)
43245
+ t[n] = [val, op];
43246
+ else {
43247
+ t[n += '/'] = [new u8(0), op];
43248
+ fltn(val, n, t, o);
43249
+ }
43250
+ }
43251
+ };
42185
43252
  // text encoder
42186
43253
  var te = typeof TextEncoder != 'undefined' && /*#__PURE__*/ new TextEncoder();
42187
43254
  // text decoder
@@ -42193,6 +43260,100 @@ try {
42193
43260
  tds = 1;
42194
43261
  }
42195
43262
  catch (e) { }
43263
+ // decode UTF8
43264
+ var dutf8 = function (d) {
43265
+ for (var r = '', i = 0;;) {
43266
+ var c = d[i++];
43267
+ var eb = (c > 127) + (c > 223) + (c > 239);
43268
+ if (i + eb > d.length)
43269
+ return [r, slc(d, i - 1)];
43270
+ if (!eb)
43271
+ r += String.fromCharCode(c);
43272
+ else if (eb == 3) {
43273
+ c = ((c & 15) << 18 | (d[i++] & 63) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63)) - 65536,
43274
+ r += String.fromCharCode(55296 | (c >> 10), 56320 | (c & 1023));
43275
+ }
43276
+ else if (eb & 1)
43277
+ r += String.fromCharCode((c & 31) << 6 | (d[i++] & 63));
43278
+ else
43279
+ r += String.fromCharCode((c & 15) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63));
43280
+ }
43281
+ };
43282
+ /**
43283
+ * Streaming UTF-8 decoding
43284
+ */
43285
+ var DecodeUTF8 = /*#__PURE__*/ (function () {
43286
+ /**
43287
+ * Creates a UTF-8 decoding stream
43288
+ * @param cb The callback to call whenever data is decoded
43289
+ */
43290
+ function DecodeUTF8(cb) {
43291
+ this.ondata = cb;
43292
+ if (tds)
43293
+ this.t = new TextDecoder();
43294
+ else
43295
+ this.p = et;
43296
+ }
43297
+ /**
43298
+ * Pushes a chunk to be decoded from UTF-8 binary
43299
+ * @param chunk The chunk to push
43300
+ * @param final Whether this is the last chunk
43301
+ */
43302
+ DecodeUTF8.prototype.push = function (chunk, final) {
43303
+ if (!this.ondata)
43304
+ err(5);
43305
+ final = !!final;
43306
+ if (this.t) {
43307
+ this.ondata(this.t.decode(chunk, { stream: true }), final);
43308
+ if (final) {
43309
+ if (this.t.decode().length)
43310
+ err(8);
43311
+ this.t = null;
43312
+ }
43313
+ return;
43314
+ }
43315
+ if (!this.p)
43316
+ err(4);
43317
+ var dat = new u8(this.p.length + chunk.length);
43318
+ dat.set(this.p);
43319
+ dat.set(chunk, this.p.length);
43320
+ var _a = dutf8(dat), ch = _a[0], np = _a[1];
43321
+ if (final) {
43322
+ if (np.length)
43323
+ err(8);
43324
+ this.p = null;
43325
+ }
43326
+ else
43327
+ this.p = np;
43328
+ this.ondata(ch, final);
43329
+ };
43330
+ return DecodeUTF8;
43331
+ }());
43332
+ /**
43333
+ * Streaming UTF-8 encoding
43334
+ */
43335
+ var EncodeUTF8 = /*#__PURE__*/ (function () {
43336
+ /**
43337
+ * Creates a UTF-8 decoding stream
43338
+ * @param cb The callback to call whenever data is encoded
43339
+ */
43340
+ function EncodeUTF8(cb) {
43341
+ this.ondata = cb;
43342
+ }
43343
+ /**
43344
+ * Pushes a chunk to be encoded to UTF-8
43345
+ * @param chunk The string data to push
43346
+ * @param final Whether this is the last chunk
43347
+ */
43348
+ EncodeUTF8.prototype.push = function (chunk, final) {
43349
+ if (!this.ondata)
43350
+ err(5);
43351
+ if (this.d)
43352
+ err(4);
43353
+ this.ondata(strToU8(chunk), this.d = final || false);
43354
+ };
43355
+ return EncodeUTF8;
43356
+ }());
42196
43357
  /**
42197
43358
  * Converts a string into a Uint8Array for use with compression/decompression methods
42198
43359
  * @param str The string to encode
@@ -42232,12 +43393,918 @@ function strToU8(str, latin1) {
42232
43393
  }
42233
43394
  return slc(ar, 0, ai);
42234
43395
  }
43396
+ /**
43397
+ * Converts a Uint8Array to a string
43398
+ * @param dat The data to decode to string
43399
+ * @param latin1 Whether or not to interpret the data as Latin-1. This should
43400
+ * not need to be true unless encoding to binary string.
43401
+ * @returns The original UTF-8/Latin-1 string
43402
+ */
43403
+ function strFromU8(dat, latin1) {
43404
+ if (latin1) {
43405
+ var r = '';
43406
+ for (var i = 0; i < dat.length; i += 16384)
43407
+ r += String.fromCharCode.apply(null, dat.subarray(i, i + 16384));
43408
+ return r;
43409
+ }
43410
+ else if (td)
43411
+ return td.decode(dat);
43412
+ else {
43413
+ var _a = dutf8(dat), out = _a[0], ext = _a[1];
43414
+ if (ext.length)
43415
+ err(8);
43416
+ return out;
43417
+ }
43418
+ }
43419
+ // deflate bit flag
43420
+ var dbf = function (l) { return l == 1 ? 3 : l < 6 ? 2 : l == 9 ? 1 : 0; };
43421
+ // skip local zip header
43422
+ var slzh = function (d, b) { return b + 30 + b2(d, b + 26) + b2(d, b + 28); };
43423
+ // read zip header
43424
+ var zh = function (d, b, z) {
43425
+ var fnl = b2(d, b + 28), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl, bs = b4(d, b + 20);
43426
+ var _a = z && bs == 4294967295 ? z64e(d, es) : [bs, b4(d, b + 24), b4(d, b + 42)], sc = _a[0], su = _a[1], off = _a[2];
43427
+ return [b2(d, b + 10), sc, su, fn, es + b2(d, b + 30) + b2(d, b + 32), off];
43428
+ };
43429
+ // read zip64 extra field
43430
+ var z64e = function (d, b) {
43431
+ for (; b2(d, b) != 1; b += 4 + b2(d, b + 2))
43432
+ ;
43433
+ return [b8(d, b + 12), b8(d, b + 4), b8(d, b + 20)];
43434
+ };
43435
+ // extra field length
43436
+ var exfl = function (ex) {
43437
+ var le = 0;
43438
+ if (ex) {
43439
+ for (var k in ex) {
43440
+ var l = ex[k].length;
43441
+ if (l > 65535)
43442
+ err(9);
43443
+ le += l + 4;
43444
+ }
43445
+ }
43446
+ return le;
43447
+ };
43448
+ // write zip header
43449
+ var wzh = function (d, b, f, fn, u, c, ce, co) {
43450
+ var fl = fn.length, ex = f.extra, col = co && co.length;
43451
+ var exl = exfl(ex);
43452
+ wbytes(d, b, ce != null ? 0x2014B50 : 0x4034B50), b += 4;
43453
+ if (ce != null)
43454
+ d[b++] = 20, d[b++] = f.os;
43455
+ d[b] = 20, b += 2; // spec compliance? what's that?
43456
+ d[b++] = (f.flag << 1) | (c < 0 && 8), d[b++] = u && 8;
43457
+ d[b++] = f.compression & 255, d[b++] = f.compression >> 8;
43458
+ var dt = new Date(f.mtime == null ? Date.now() : f.mtime), y = dt.getFullYear() - 1980;
43459
+ if (y < 0 || y > 119)
43460
+ err(10);
43461
+ wbytes(d, b, (y << 25) | ((dt.getMonth() + 1) << 21) | (dt.getDate() << 16) | (dt.getHours() << 11) | (dt.getMinutes() << 5) | (dt.getSeconds() >>> 1)), b += 4;
43462
+ if (c != -1) {
43463
+ wbytes(d, b, f.crc);
43464
+ wbytes(d, b + 4, c < 0 ? -c - 2 : c);
43465
+ wbytes(d, b + 8, f.size);
43466
+ }
43467
+ wbytes(d, b + 12, fl);
43468
+ wbytes(d, b + 14, exl), b += 16;
43469
+ if (ce != null) {
43470
+ wbytes(d, b, col);
43471
+ wbytes(d, b + 6, f.attrs);
43472
+ wbytes(d, b + 10, ce), b += 14;
43473
+ }
43474
+ d.set(fn, b);
43475
+ b += fl;
43476
+ if (exl) {
43477
+ for (var k in ex) {
43478
+ var exf = ex[k], l = exf.length;
43479
+ wbytes(d, b, +k);
43480
+ wbytes(d, b + 2, l);
43481
+ d.set(exf, b + 4), b += 4 + l;
43482
+ }
43483
+ }
43484
+ if (col)
43485
+ d.set(co, b), b += col;
43486
+ return b;
43487
+ };
43488
+ // write zip footer (end of central directory)
43489
+ var wzf = function (o, b, c, d, e) {
43490
+ wbytes(o, b, 0x6054B50); // skip disk
43491
+ wbytes(o, b + 8, c);
43492
+ wbytes(o, b + 10, c);
43493
+ wbytes(o, b + 12, d);
43494
+ wbytes(o, b + 16, e);
43495
+ };
43496
+ /**
43497
+ * A pass-through stream to keep data uncompressed in a ZIP archive.
43498
+ */
43499
+ var ZipPassThrough = /*#__PURE__*/ (function () {
43500
+ /**
43501
+ * Creates a pass-through stream that can be added to ZIP archives
43502
+ * @param filename The filename to associate with this data stream
43503
+ */
43504
+ function ZipPassThrough(filename) {
43505
+ this.filename = filename;
43506
+ this.c = crc();
43507
+ this.size = 0;
43508
+ this.compression = 0;
43509
+ }
43510
+ /**
43511
+ * Processes a chunk and pushes to the output stream. You can override this
43512
+ * method in a subclass for custom behavior, but by default this passes
43513
+ * the data through. You must call this.ondata(err, chunk, final) at some
43514
+ * point in this method.
43515
+ * @param chunk The chunk to process
43516
+ * @param final Whether this is the last chunk
43517
+ */
43518
+ ZipPassThrough.prototype.process = function (chunk, final) {
43519
+ this.ondata(null, chunk, final);
43520
+ };
43521
+ /**
43522
+ * Pushes a chunk to be added. If you are subclassing this with a custom
43523
+ * compression algorithm, note that you must push data from the source
43524
+ * file only, pre-compression.
43525
+ * @param chunk The chunk to push
43526
+ * @param final Whether this is the last chunk
43527
+ */
43528
+ ZipPassThrough.prototype.push = function (chunk, final) {
43529
+ if (!this.ondata)
43530
+ err(5);
43531
+ this.c.p(chunk);
43532
+ this.size += chunk.length;
43533
+ if (final)
43534
+ this.crc = this.c.d();
43535
+ this.process(chunk, final || false);
43536
+ };
43537
+ return ZipPassThrough;
43538
+ }());
43539
+ // I don't extend because TypeScript extension adds 1kB of runtime bloat
43540
+ /**
43541
+ * Streaming DEFLATE compression for ZIP archives. Prefer using AsyncZipDeflate
43542
+ * for better performance
43543
+ */
43544
+ var ZipDeflate = /*#__PURE__*/ (function () {
43545
+ /**
43546
+ * Creates a DEFLATE stream that can be added to ZIP archives
43547
+ * @param filename The filename to associate with this data stream
43548
+ * @param opts The compression options
43549
+ */
43550
+ function ZipDeflate(filename, opts) {
43551
+ var _this_1 = this;
43552
+ if (!opts)
43553
+ opts = {};
43554
+ ZipPassThrough.call(this, filename);
43555
+ this.d = new Deflate(opts, function (dat, final) {
43556
+ _this_1.ondata(null, dat, final);
43557
+ });
43558
+ this.compression = 8;
43559
+ this.flag = dbf(opts.level);
43560
+ }
43561
+ ZipDeflate.prototype.process = function (chunk, final) {
43562
+ try {
43563
+ this.d.push(chunk, final);
43564
+ }
43565
+ catch (e) {
43566
+ this.ondata(e, null, final);
43567
+ }
43568
+ };
43569
+ /**
43570
+ * Pushes a chunk to be deflated
43571
+ * @param chunk The chunk to push
43572
+ * @param final Whether this is the last chunk
43573
+ */
43574
+ ZipDeflate.prototype.push = function (chunk, final) {
43575
+ ZipPassThrough.prototype.push.call(this, chunk, final);
43576
+ };
43577
+ return ZipDeflate;
43578
+ }());
43579
+ /**
43580
+ * Asynchronous streaming DEFLATE compression for ZIP archives
43581
+ */
43582
+ var AsyncZipDeflate = /*#__PURE__*/ (function () {
43583
+ /**
43584
+ * Creates a DEFLATE stream that can be added to ZIP archives
43585
+ * @param filename The filename to associate with this data stream
43586
+ * @param opts The compression options
43587
+ */
43588
+ function AsyncZipDeflate(filename, opts) {
43589
+ var _this_1 = this;
43590
+ if (!opts)
43591
+ opts = {};
43592
+ ZipPassThrough.call(this, filename);
43593
+ this.d = new AsyncDeflate(opts, function (err, dat, final) {
43594
+ _this_1.ondata(err, dat, final);
43595
+ });
43596
+ this.compression = 8;
43597
+ this.flag = dbf(opts.level);
43598
+ this.terminate = this.d.terminate;
43599
+ }
43600
+ AsyncZipDeflate.prototype.process = function (chunk, final) {
43601
+ this.d.push(chunk, final);
43602
+ };
43603
+ /**
43604
+ * Pushes a chunk to be deflated
43605
+ * @param chunk The chunk to push
43606
+ * @param final Whether this is the last chunk
43607
+ */
43608
+ AsyncZipDeflate.prototype.push = function (chunk, final) {
43609
+ ZipPassThrough.prototype.push.call(this, chunk, final);
43610
+ };
43611
+ return AsyncZipDeflate;
43612
+ }());
43613
+ // TODO: Better tree shaking
43614
+ /**
43615
+ * A zippable archive to which files can incrementally be added
43616
+ */
43617
+ var Zip = /*#__PURE__*/ (function () {
43618
+ /**
43619
+ * Creates an empty ZIP archive to which files can be added
43620
+ * @param cb The callback to call whenever data for the generated ZIP archive
43621
+ * is available
43622
+ */
43623
+ function Zip(cb) {
43624
+ this.ondata = cb;
43625
+ this.u = [];
43626
+ this.d = 1;
43627
+ }
43628
+ /**
43629
+ * Adds a file to the ZIP archive
43630
+ * @param file The file stream to add
43631
+ */
43632
+ Zip.prototype.add = function (file) {
43633
+ var _this_1 = this;
43634
+ if (!this.ondata)
43635
+ err(5);
43636
+ // finishing or finished
43637
+ if (this.d & 2)
43638
+ this.ondata(err(4 + (this.d & 1) * 8, 0, 1), null, false);
43639
+ else {
43640
+ var f = strToU8(file.filename), fl_1 = f.length;
43641
+ var com = file.comment, o = com && strToU8(com);
43642
+ var u = fl_1 != file.filename.length || (o && (com.length != o.length));
43643
+ var hl_1 = fl_1 + exfl(file.extra) + 30;
43644
+ if (fl_1 > 65535)
43645
+ this.ondata(err(11, 0, 1), null, false);
43646
+ var header = new u8(hl_1);
43647
+ wzh(header, 0, file, f, u, -1);
43648
+ var chks_1 = [header];
43649
+ var pAll_1 = function () {
43650
+ for (var _i = 0, chks_2 = chks_1; _i < chks_2.length; _i++) {
43651
+ var chk = chks_2[_i];
43652
+ _this_1.ondata(null, chk, false);
43653
+ }
43654
+ chks_1 = [];
43655
+ };
43656
+ var tr_1 = this.d;
43657
+ this.d = 0;
43658
+ var ind_1 = this.u.length;
43659
+ var uf_1 = mrg(file, {
43660
+ f: f,
43661
+ u: u,
43662
+ o: o,
43663
+ t: function () {
43664
+ if (file.terminate)
43665
+ file.terminate();
43666
+ },
43667
+ r: function () {
43668
+ pAll_1();
43669
+ if (tr_1) {
43670
+ var nxt = _this_1.u[ind_1 + 1];
43671
+ if (nxt)
43672
+ nxt.r();
43673
+ else
43674
+ _this_1.d = 1;
43675
+ }
43676
+ tr_1 = 1;
43677
+ }
43678
+ });
43679
+ var cl_1 = 0;
43680
+ file.ondata = function (err, dat, final) {
43681
+ if (err) {
43682
+ _this_1.ondata(err, dat, final);
43683
+ _this_1.terminate();
43684
+ }
43685
+ else {
43686
+ cl_1 += dat.length;
43687
+ chks_1.push(dat);
43688
+ if (final) {
43689
+ var dd = new u8(16);
43690
+ wbytes(dd, 0, 0x8074B50);
43691
+ wbytes(dd, 4, file.crc);
43692
+ wbytes(dd, 8, cl_1);
43693
+ wbytes(dd, 12, file.size);
43694
+ chks_1.push(dd);
43695
+ uf_1.c = cl_1, uf_1.b = hl_1 + cl_1 + 16, uf_1.crc = file.crc, uf_1.size = file.size;
43696
+ if (tr_1)
43697
+ uf_1.r();
43698
+ tr_1 = 1;
43699
+ }
43700
+ else if (tr_1)
43701
+ pAll_1();
43702
+ }
43703
+ };
43704
+ this.u.push(uf_1);
43705
+ }
43706
+ };
43707
+ /**
43708
+ * Ends the process of adding files and prepares to emit the final chunks.
43709
+ * This *must* be called after adding all desired files for the resulting
43710
+ * ZIP file to work properly.
43711
+ */
43712
+ Zip.prototype.end = function () {
43713
+ var _this_1 = this;
43714
+ if (this.d & 2) {
43715
+ this.ondata(err(4 + (this.d & 1) * 8, 0, 1), null, true);
43716
+ return;
43717
+ }
43718
+ if (this.d)
43719
+ this.e();
43720
+ else
43721
+ this.u.push({
43722
+ r: function () {
43723
+ if (!(_this_1.d & 1))
43724
+ return;
43725
+ _this_1.u.splice(-1, 1);
43726
+ _this_1.e();
43727
+ },
43728
+ t: function () { }
43729
+ });
43730
+ this.d = 3;
43731
+ };
43732
+ Zip.prototype.e = function () {
43733
+ var bt = 0, l = 0, tl = 0;
43734
+ for (var _i = 0, _a = this.u; _i < _a.length; _i++) {
43735
+ var f = _a[_i];
43736
+ tl += 46 + f.f.length + exfl(f.extra) + (f.o ? f.o.length : 0);
43737
+ }
43738
+ var out = new u8(tl + 22);
43739
+ for (var _b = 0, _c = this.u; _b < _c.length; _b++) {
43740
+ var f = _c[_b];
43741
+ wzh(out, bt, f, f.f, f.u, -f.c - 2, l, f.o);
43742
+ bt += 46 + f.f.length + exfl(f.extra) + (f.o ? f.o.length : 0), l += f.b;
43743
+ }
43744
+ wzf(out, bt, this.u.length, tl, l);
43745
+ this.ondata(null, out, true);
43746
+ this.d = 2;
43747
+ };
43748
+ /**
43749
+ * A method to terminate any internal workers used by the stream. Subsequent
43750
+ * calls to add() will fail.
43751
+ */
43752
+ Zip.prototype.terminate = function () {
43753
+ for (var _i = 0, _a = this.u; _i < _a.length; _i++) {
43754
+ var f = _a[_i];
43755
+ f.t();
43756
+ }
43757
+ this.d = 2;
43758
+ };
43759
+ return Zip;
43760
+ }());
43761
+ function zip(data, opts, cb) {
43762
+ if (!cb)
43763
+ cb = opts, opts = {};
43764
+ if (typeof cb != 'function')
43765
+ err(7);
43766
+ var r = {};
43767
+ fltn(data, '', r, opts);
43768
+ var k = Object.keys(r);
43769
+ var lft = k.length, o = 0, tot = 0;
43770
+ var slft = lft, files = new Array(lft);
43771
+ var term = [];
43772
+ var tAll = function () {
43773
+ for (var i = 0; i < term.length; ++i)
43774
+ term[i]();
43775
+ };
43776
+ var cbd = function (a, b) {
43777
+ mt(function () { cb(a, b); });
43778
+ };
43779
+ mt(function () { cbd = cb; });
43780
+ var cbf = function () {
43781
+ var out = new u8(tot + 22), oe = o, cdl = tot - o;
43782
+ tot = 0;
43783
+ for (var i = 0; i < slft; ++i) {
43784
+ var f = files[i];
43785
+ try {
43786
+ var l = f.c.length;
43787
+ wzh(out, tot, f, f.f, f.u, l);
43788
+ var badd = 30 + f.f.length + exfl(f.extra);
43789
+ var loc = tot + badd;
43790
+ out.set(f.c, loc);
43791
+ wzh(out, o, f, f.f, f.u, l, tot, f.m), o += 16 + badd + (f.m ? f.m.length : 0), tot = loc + l;
43792
+ }
43793
+ catch (e) {
43794
+ return cbd(e, null);
43795
+ }
43796
+ }
43797
+ wzf(out, o, files.length, cdl, oe);
43798
+ cbd(null, out);
43799
+ };
43800
+ if (!lft)
43801
+ cbf();
43802
+ var _loop_1 = function (i) {
43803
+ var fn = k[i];
43804
+ var _a = r[fn], file = _a[0], p = _a[1];
43805
+ var c = crc(), size = file.length;
43806
+ c.p(file);
43807
+ var f = strToU8(fn), s = f.length;
43808
+ var com = p.comment, m = com && strToU8(com), ms = m && m.length;
43809
+ var exl = exfl(p.extra);
43810
+ var compression = p.level == 0 ? 0 : 8;
43811
+ var cbl = function (e, d) {
43812
+ if (e) {
43813
+ tAll();
43814
+ cbd(e, null);
43815
+ }
43816
+ else {
43817
+ var l = d.length;
43818
+ files[i] = mrg(p, {
43819
+ size: size,
43820
+ crc: c.d(),
43821
+ c: d,
43822
+ f: f,
43823
+ m: m,
43824
+ u: s != fn.length || (m && (com.length != ms)),
43825
+ compression: compression
43826
+ });
43827
+ o += 30 + s + exl + l;
43828
+ tot += 76 + 2 * (s + exl) + (ms || 0) + l;
43829
+ if (!--lft)
43830
+ cbf();
43831
+ }
43832
+ };
43833
+ if (s > 65535)
43834
+ cbl(err(11, 0, 1), null);
43835
+ if (!compression)
43836
+ cbl(null, file);
43837
+ else if (size < 160000) {
43838
+ try {
43839
+ cbl(null, deflateSync(file, p));
43840
+ }
43841
+ catch (e) {
43842
+ cbl(e, null);
43843
+ }
43844
+ }
43845
+ else
43846
+ term.push(deflate(file, p, cbl));
43847
+ };
43848
+ // Cannot use lft because it can decrease
43849
+ for (var i = 0; i < slft; ++i) {
43850
+ _loop_1(i);
43851
+ }
43852
+ return tAll;
43853
+ }
43854
+ /**
43855
+ * Synchronously creates a ZIP file. Prefer using `zip` for better performance
43856
+ * with more than one file.
43857
+ * @param data The directory structure for the ZIP archive
43858
+ * @param opts The main options, merged with per-file options
43859
+ * @returns The generated ZIP archive
43860
+ */
43861
+ function zipSync(data, opts) {
43862
+ if (!opts)
43863
+ opts = {};
43864
+ var r = {};
43865
+ var files = [];
43866
+ fltn(data, '', r, opts);
43867
+ var o = 0;
43868
+ var tot = 0;
43869
+ for (var fn in r) {
43870
+ var _a = r[fn], file = _a[0], p = _a[1];
43871
+ var compression = p.level == 0 ? 0 : 8;
43872
+ var f = strToU8(fn), s = f.length;
43873
+ var com = p.comment, m = com && strToU8(com), ms = m && m.length;
43874
+ var exl = exfl(p.extra);
43875
+ if (s > 65535)
43876
+ err(11);
43877
+ var d = compression ? deflateSync(file, p) : file, l = d.length;
43878
+ var c = crc();
43879
+ c.p(file);
43880
+ files.push(mrg(p, {
43881
+ size: file.length,
43882
+ crc: c.d(),
43883
+ c: d,
43884
+ f: f,
43885
+ m: m,
43886
+ u: s != fn.length || (m && (com.length != ms)),
43887
+ o: o,
43888
+ compression: compression
43889
+ }));
43890
+ o += 30 + s + exl + l;
43891
+ tot += 76 + 2 * (s + exl) + (ms || 0) + l;
43892
+ }
43893
+ var out = new u8(tot + 22), oe = o, cdl = tot - o;
43894
+ for (var i = 0; i < files.length; ++i) {
43895
+ var f = files[i];
43896
+ wzh(out, f.o, f, f.f, f.u, f.c.length);
43897
+ var badd = 30 + f.f.length + exfl(f.extra);
43898
+ out.set(f.c, f.o + badd);
43899
+ wzh(out, o, f, f.f, f.u, f.c.length, f.o, f.m), o += 16 + badd + (f.m ? f.m.length : 0);
43900
+ }
43901
+ wzf(out, o, files.length, cdl, oe);
43902
+ return out;
43903
+ }
43904
+ /**
43905
+ * Streaming pass-through decompression for ZIP archives
43906
+ */
43907
+ var UnzipPassThrough = /*#__PURE__*/ (function () {
43908
+ function UnzipPassThrough() {
43909
+ }
43910
+ UnzipPassThrough.prototype.push = function (data, final) {
43911
+ this.ondata(null, data, final);
43912
+ };
43913
+ UnzipPassThrough.compression = 0;
43914
+ return UnzipPassThrough;
43915
+ }());
43916
+ /**
43917
+ * Streaming DEFLATE decompression for ZIP archives. Prefer AsyncZipInflate for
43918
+ * better performance.
43919
+ */
43920
+ var UnzipInflate = /*#__PURE__*/ (function () {
43921
+ /**
43922
+ * Creates a DEFLATE decompression that can be used in ZIP archives
43923
+ */
43924
+ function UnzipInflate() {
43925
+ var _this_1 = this;
43926
+ this.i = new Inflate(function (dat, final) {
43927
+ _this_1.ondata(null, dat, final);
43928
+ });
43929
+ }
43930
+ UnzipInflate.prototype.push = function (data, final) {
43931
+ try {
43932
+ this.i.push(data, final);
43933
+ }
43934
+ catch (e) {
43935
+ this.ondata(e, null, final);
43936
+ }
43937
+ };
43938
+ UnzipInflate.compression = 8;
43939
+ return UnzipInflate;
43940
+ }());
43941
+ /**
43942
+ * Asynchronous streaming DEFLATE decompression for ZIP archives
43943
+ */
43944
+ var AsyncUnzipInflate = /*#__PURE__*/ (function () {
43945
+ /**
43946
+ * Creates a DEFLATE decompression that can be used in ZIP archives
43947
+ */
43948
+ function AsyncUnzipInflate(_, sz) {
43949
+ var _this_1 = this;
43950
+ if (sz < 320000) {
43951
+ this.i = new Inflate(function (dat, final) {
43952
+ _this_1.ondata(null, dat, final);
43953
+ });
43954
+ }
43955
+ else {
43956
+ this.i = new AsyncInflate(function (err, dat, final) {
43957
+ _this_1.ondata(err, dat, final);
43958
+ });
43959
+ this.terminate = this.i.terminate;
43960
+ }
43961
+ }
43962
+ AsyncUnzipInflate.prototype.push = function (data, final) {
43963
+ if (this.i.terminate)
43964
+ data = slc(data, 0);
43965
+ this.i.push(data, final);
43966
+ };
43967
+ AsyncUnzipInflate.compression = 8;
43968
+ return AsyncUnzipInflate;
43969
+ }());
43970
+ /**
43971
+ * A ZIP archive decompression stream that emits files as they are discovered
43972
+ */
43973
+ var Unzip = /*#__PURE__*/ (function () {
43974
+ /**
43975
+ * Creates a ZIP decompression stream
43976
+ * @param cb The callback to call whenever a file in the ZIP archive is found
43977
+ */
43978
+ function Unzip(cb) {
43979
+ this.onfile = cb;
43980
+ this.k = [];
43981
+ this.o = {
43982
+ 0: UnzipPassThrough
43983
+ };
43984
+ this.p = et;
43985
+ }
43986
+ /**
43987
+ * Pushes a chunk to be unzipped
43988
+ * @param chunk The chunk to push
43989
+ * @param final Whether this is the last chunk
43990
+ */
43991
+ Unzip.prototype.push = function (chunk, final) {
43992
+ var _this_1 = this;
43993
+ if (!this.onfile)
43994
+ err(5);
43995
+ if (!this.p)
43996
+ err(4);
43997
+ if (this.c > 0) {
43998
+ var len = Math.min(this.c, chunk.length);
43999
+ var toAdd = chunk.subarray(0, len);
44000
+ this.c -= len;
44001
+ if (this.d)
44002
+ this.d.push(toAdd, !this.c);
44003
+ else
44004
+ this.k[0].push(toAdd);
44005
+ chunk = chunk.subarray(len);
44006
+ if (chunk.length)
44007
+ return this.push(chunk, final);
44008
+ }
44009
+ else {
44010
+ var f = 0, i = 0, is = void 0, buf = void 0;
44011
+ if (!this.p.length)
44012
+ buf = chunk;
44013
+ else if (!chunk.length)
44014
+ buf = this.p;
44015
+ else {
44016
+ buf = new u8(this.p.length + chunk.length);
44017
+ buf.set(this.p), buf.set(chunk, this.p.length);
44018
+ }
44019
+ var l = buf.length, oc = this.c, add = oc && this.d;
44020
+ var _loop_2 = function () {
44021
+ var _a;
44022
+ var sig = b4(buf, i);
44023
+ if (sig == 0x4034B50) {
44024
+ f = 1, is = i;
44025
+ this_1.d = null;
44026
+ this_1.c = 0;
44027
+ var bf = b2(buf, i + 6), cmp_1 = b2(buf, i + 8), u = bf & 2048, dd = bf & 8, fnl = b2(buf, i + 26), es = b2(buf, i + 28);
44028
+ if (l > i + 30 + fnl + es) {
44029
+ var chks_3 = [];
44030
+ this_1.k.unshift(chks_3);
44031
+ f = 2;
44032
+ var sc_1 = b4(buf, i + 18), su_1 = b4(buf, i + 22);
44033
+ var fn_1 = strFromU8(buf.subarray(i + 30, i += 30 + fnl), !u);
44034
+ if (sc_1 == 4294967295) {
44035
+ _a = dd ? [-2] : z64e(buf, i), sc_1 = _a[0], su_1 = _a[1];
44036
+ }
44037
+ else if (dd)
44038
+ sc_1 = -1;
44039
+ i += es;
44040
+ this_1.c = sc_1;
44041
+ var d_1;
44042
+ var file_1 = {
44043
+ name: fn_1,
44044
+ compression: cmp_1,
44045
+ start: function () {
44046
+ if (!file_1.ondata)
44047
+ err(5);
44048
+ if (!sc_1)
44049
+ file_1.ondata(null, et, true);
44050
+ else {
44051
+ var ctr = _this_1.o[cmp_1];
44052
+ if (!ctr)
44053
+ file_1.ondata(err(14, 'unknown compression type ' + cmp_1, 1), null, false);
44054
+ d_1 = sc_1 < 0 ? new ctr(fn_1) : new ctr(fn_1, sc_1, su_1);
44055
+ d_1.ondata = function (err, dat, final) { file_1.ondata(err, dat, final); };
44056
+ for (var _i = 0, chks_4 = chks_3; _i < chks_4.length; _i++) {
44057
+ var dat = chks_4[_i];
44058
+ d_1.push(dat, false);
44059
+ }
44060
+ if (_this_1.k[0] == chks_3 && _this_1.c)
44061
+ _this_1.d = d_1;
44062
+ else
44063
+ d_1.push(et, true);
44064
+ }
44065
+ },
44066
+ terminate: function () {
44067
+ if (d_1 && d_1.terminate)
44068
+ d_1.terminate();
44069
+ }
44070
+ };
44071
+ if (sc_1 >= 0)
44072
+ file_1.size = sc_1, file_1.originalSize = su_1;
44073
+ this_1.onfile(file_1);
44074
+ }
44075
+ return "break";
44076
+ }
44077
+ else if (oc) {
44078
+ if (sig == 0x8074B50) {
44079
+ is = i += 12 + (oc == -2 && 8), f = 3, this_1.c = 0;
44080
+ return "break";
44081
+ }
44082
+ else if (sig == 0x2014B50) {
44083
+ is = i -= 4, f = 3, this_1.c = 0;
44084
+ return "break";
44085
+ }
44086
+ }
44087
+ };
44088
+ var this_1 = this;
44089
+ for (; i < l - 4; ++i) {
44090
+ var state_1 = _loop_2();
44091
+ if (state_1 === "break")
44092
+ break;
44093
+ }
44094
+ this.p = et;
44095
+ if (oc < 0) {
44096
+ var dat = f ? buf.subarray(0, is - 12 - (oc == -2 && 8) - (b4(buf, is - 16) == 0x8074B50 && 4)) : buf.subarray(0, i);
44097
+ if (add)
44098
+ add.push(dat, !!f);
44099
+ else
44100
+ this.k[+(f == 2)].push(dat);
44101
+ }
44102
+ if (f & 2)
44103
+ return this.push(buf.subarray(i), final);
44104
+ this.p = buf.subarray(i);
44105
+ }
44106
+ if (final) {
44107
+ if (this.c)
44108
+ err(13);
44109
+ this.p = null;
44110
+ }
44111
+ };
44112
+ /**
44113
+ * Registers a decoder with the stream, allowing for files compressed with
44114
+ * the compression type provided to be expanded correctly
44115
+ * @param decoder The decoder constructor
44116
+ */
44117
+ Unzip.prototype.register = function (decoder) {
44118
+ this.o[decoder.compression] = decoder;
44119
+ };
44120
+ return Unzip;
44121
+ }());
44122
+ var mt = typeof queueMicrotask == 'function' ? queueMicrotask : typeof setTimeout == 'function' ? setTimeout : function (fn) { fn(); };
44123
+ function unzip(data, opts, cb) {
44124
+ if (!cb)
44125
+ cb = opts, opts = {};
44126
+ if (typeof cb != 'function')
44127
+ err(7);
44128
+ var term = [];
44129
+ var tAll = function () {
44130
+ for (var i = 0; i < term.length; ++i)
44131
+ term[i]();
44132
+ };
44133
+ var files = {};
44134
+ var cbd = function (a, b) {
44135
+ mt(function () { cb(a, b); });
44136
+ };
44137
+ mt(function () { cbd = cb; });
44138
+ var e = data.length - 22;
44139
+ for (; b4(data, e) != 0x6054B50; --e) {
44140
+ if (!e || data.length - e > 65558) {
44141
+ cbd(err(13, 0, 1), null);
44142
+ return tAll;
44143
+ }
44144
+ }
44145
+ var lft = b2(data, e + 8);
44146
+ if (lft) {
44147
+ var c = lft;
44148
+ var o = b4(data, e + 16);
44149
+ var z = o == 4294967295 || c == 65535;
44150
+ if (z) {
44151
+ var ze = b4(data, e - 12);
44152
+ z = b4(data, ze) == 0x6064B50;
44153
+ if (z) {
44154
+ c = lft = b4(data, ze + 32);
44155
+ o = b4(data, ze + 48);
44156
+ }
44157
+ }
44158
+ var fltr = opts && opts.filter;
44159
+ var _loop_3 = function (i) {
44160
+ var _a = zh(data, o, z), c_1 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);
44161
+ o = no;
44162
+ var cbl = function (e, d) {
44163
+ if (e) {
44164
+ tAll();
44165
+ cbd(e, null);
44166
+ }
44167
+ else {
44168
+ if (d)
44169
+ files[fn] = d;
44170
+ if (!--lft)
44171
+ cbd(null, files);
44172
+ }
44173
+ };
44174
+ if (!fltr || fltr({
44175
+ name: fn,
44176
+ size: sc,
44177
+ originalSize: su,
44178
+ compression: c_1
44179
+ })) {
44180
+ if (!c_1)
44181
+ cbl(null, slc(data, b, b + sc));
44182
+ else if (c_1 == 8) {
44183
+ var infl = data.subarray(b, b + sc);
44184
+ if (sc < 320000) {
44185
+ try {
44186
+ cbl(null, inflateSync(infl, new u8(su)));
44187
+ }
44188
+ catch (e) {
44189
+ cbl(e, null);
44190
+ }
44191
+ }
44192
+ else
44193
+ term.push(inflate(infl, { size: su }, cbl));
44194
+ }
44195
+ else
44196
+ cbl(err(14, 'unknown compression type ' + c_1, 1), null);
44197
+ }
44198
+ else
44199
+ cbl(null, null);
44200
+ };
44201
+ for (var i = 0; i < c; ++i) {
44202
+ _loop_3(i);
44203
+ }
44204
+ }
44205
+ else
44206
+ cbd(null, {});
44207
+ return tAll;
44208
+ }
44209
+ /**
44210
+ * Synchronously decompresses a ZIP archive. Prefer using `unzip` for better
44211
+ * performance with more than one file.
44212
+ * @param data The raw compressed ZIP file
44213
+ * @param opts The ZIP extraction options
44214
+ * @returns The decompressed files
44215
+ */
44216
+ function unzipSync(data, opts) {
44217
+ var files = {};
44218
+ var e = data.length - 22;
44219
+ for (; b4(data, e) != 0x6054B50; --e) {
44220
+ if (!e || data.length - e > 65558)
44221
+ err(13);
44222
+ }
44223
+ var c = b2(data, e + 8);
44224
+ if (!c)
44225
+ return {};
44226
+ var o = b4(data, e + 16);
44227
+ var z = o == 4294967295 || c == 65535;
44228
+ if (z) {
44229
+ var ze = b4(data, e - 12);
44230
+ z = b4(data, ze) == 0x6064B50;
44231
+ if (z) {
44232
+ c = b4(data, ze + 32);
44233
+ o = b4(data, ze + 48);
44234
+ }
44235
+ }
44236
+ var fltr = opts && opts.filter;
44237
+ for (var i = 0; i < c; ++i) {
44238
+ var _a = zh(data, o, z), c_2 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);
44239
+ o = no;
44240
+ if (!fltr || fltr({
44241
+ name: fn,
44242
+ size: sc,
44243
+ originalSize: su,
44244
+ compression: c_2
44245
+ })) {
44246
+ if (!c_2)
44247
+ files[fn] = slc(data, b, b + sc);
44248
+ else if (c_2 == 8)
44249
+ files[fn] = inflateSync(data.subarray(b, b + sc), new u8(su));
44250
+ else
44251
+ err(14, 'unknown compression type ' + c_2);
44252
+ }
44253
+ }
44254
+ return files;
44255
+ }
42235
44256
 
42236
44257
  var browser = /*#__PURE__*/Object.freeze({
42237
44258
  __proto__: null,
44259
+ AsyncCompress: AsyncGzip,
44260
+ AsyncDecompress: AsyncDecompress,
44261
+ AsyncDeflate: AsyncDeflate,
44262
+ AsyncGunzip: AsyncGunzip,
44263
+ AsyncGzip: AsyncGzip,
44264
+ AsyncInflate: AsyncInflate,
44265
+ AsyncUnzipInflate: AsyncUnzipInflate,
44266
+ AsyncUnzlib: AsyncUnzlib,
44267
+ AsyncZipDeflate: AsyncZipDeflate,
44268
+ AsyncZlib: AsyncZlib,
44269
+ Compress: Gzip,
44270
+ DecodeUTF8: DecodeUTF8,
44271
+ Decompress: Decompress,
44272
+ Deflate: Deflate,
44273
+ EncodeUTF8: EncodeUTF8,
44274
+ FlateErrorCode: FlateErrorCode,
44275
+ Gunzip: Gunzip,
44276
+ Gzip: Gzip,
44277
+ Inflate: Inflate,
44278
+ Unzip: Unzip,
44279
+ UnzipInflate: UnzipInflate,
44280
+ UnzipPassThrough: UnzipPassThrough,
44281
+ Unzlib: Unzlib,
44282
+ Zip: Zip,
44283
+ ZipDeflate: ZipDeflate,
44284
+ ZipPassThrough: ZipPassThrough,
44285
+ Zlib: Zlib,
44286
+ compress: gzip,
42238
44287
  compressSync: gzipSync,
44288
+ decompress: decompress,
44289
+ decompressSync: decompressSync,
44290
+ deflate: deflate,
44291
+ deflateSync: deflateSync,
44292
+ gunzip: gunzip,
44293
+ gunzipSync: gunzipSync,
44294
+ gzip: gzip,
42239
44295
  gzipSync: gzipSync,
42240
- strToU8: strToU8
44296
+ inflate: inflate,
44297
+ inflateSync: inflateSync,
44298
+ strFromU8: strFromU8,
44299
+ strToU8: strToU8,
44300
+ unzip: unzip,
44301
+ unzipSync: unzipSync,
44302
+ unzlib: unzlib,
44303
+ unzlibSync: unzlibSync,
44304
+ zip: zip,
44305
+ zipSync: zipSync,
44306
+ zlib: zlib,
44307
+ zlibSync: zlibSync
42241
44308
  });
42242
44309
 
42243
44310
  export { AfterpayCheckoutButton, AfterpayOnSiteMessaging, Api, ApplePayOpenWalletButton, ApplePayWalletButtonExpress, CHECKOUT_BUTTON_EVENT, Canvas3ds, Checkout, ClickToPay, Configuration, ELEMENT, ERROR_OPERATION, EVENT$5 as EVENT, Builder$1 as ExternalCheckoutBuilder, Checker as ExternalCheckoutChecker, FORM_FIELD$1 as FORM_FIELD, FRAUD_PREVENTION_EVENTS, FraudPreventionService, GooglePayOpenWalletButton, HtmlMultiWidget, HtmlPaymentSourceWidget, HtmlWidget, InstructionDebugger, MultiWidget, OpenWalletButtons, PAYMENT_TYPE, PURPOSE, PayPalDataCollector, PayPalSavePaymentSourceWidget, Builder as PaymentSourceBuilder, PaymentSourceWidget, PaypalCheckoutButton, PaypalWalletButtonExpress, STYLABLE_ELEMENT, STYLABLE_ELEMENT_STATE, STYLE$2 as STYLE, SUPPORTED_CARD_TYPES, TEXT, TOKEN_TYPE, TRIGGER$1 as TRIGGER, TYPE, VAULT_DISPLAY_STYLE, VaultDisplayWidget, WALLET_TYPES, WalletButtons, ZipmoneyCheckoutButton };