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