@salla.sa/twilight-components 2.11.69 → 2.11.70

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.
Files changed (55) hide show
  1. package/dist/cjs/{app-globals-bd54e7cb.js → app-globals-7aa5a435.js} +2 -2
  2. package/dist/cjs/cart-3ecaa815.js +13 -0
  3. package/dist/cjs/index-1d2b3370.js +2 -2
  4. package/dist/cjs/loader.cjs.js +2 -2
  5. package/dist/cjs/salla-add-product-button.cjs.entry.js +21 -4
  6. package/dist/cjs/{salla-button_36.cjs.entry.js → salla-button_37.cjs.entry.js} +2605 -34
  7. package/dist/cjs/twilight.cjs.js +2 -2
  8. package/dist/collection/collection-manifest.json +1 -0
  9. package/dist/collection/components/salla-add-product-button/salla-add-product-button.css +2 -1
  10. package/dist/collection/components/salla-add-product-button/salla-add-product-button.js +59 -6
  11. package/dist/collection/components/salla-quick-buy/salla-quick-buy.css +10 -0
  12. package/dist/collection/components/salla-quick-buy/salla-quick-buy.js +326 -0
  13. package/dist/collection/global/app-dev.js +4 -0
  14. package/dist/components/index.d.ts +1 -0
  15. package/dist/components/index.js +3 -2
  16. package/dist/components/salla-add-product-button.js +39 -13
  17. package/dist/components/salla-quick-buy.d.ts +11 -0
  18. package/dist/components/salla-quick-buy.js +9 -0
  19. package/dist/components/salla-quick-buy2.js +2612 -0
  20. package/dist/esm/{app-globals-ab75dc1d.js → app-globals-225364bb.js} +2 -2
  21. package/dist/esm/cart-8c60b447.js +11 -0
  22. package/dist/esm/index-f1d446ac.js +2 -2
  23. package/dist/esm/loader.js +2 -2
  24. package/dist/esm/salla-add-product-button.entry.js +21 -4
  25. package/dist/esm/{salla-button_36.entry.js → salla-button_37.entry.js} +2605 -35
  26. package/dist/esm/twilight.js +2 -2
  27. package/dist/esm-es5/app-globals-225364bb.js +24 -0
  28. package/dist/esm-es5/cart-8c60b447.js +4 -0
  29. package/dist/esm-es5/index-f1d446ac.js +1 -1
  30. package/dist/esm-es5/loader.js +1 -1
  31. package/dist/esm-es5/salla-add-product-button.entry.js +2 -2
  32. package/dist/esm-es5/salla-button_37.entry.js +53 -0
  33. package/dist/esm-es5/twilight.js +1 -1
  34. package/dist/twilight/{p-d17a8244.entry.js → p-003923b5.entry.js} +6 -6
  35. package/dist/twilight/p-3c6e1a89.js +24 -0
  36. package/dist/twilight/p-4bf1c1a4.system.js +4 -0
  37. package/dist/twilight/p-60fb9bb5.system.js +4 -0
  38. package/dist/twilight/p-8a13cf01.js +4 -0
  39. package/dist/twilight/p-8c7b124e.system.entry.js +4 -0
  40. package/dist/twilight/p-91f5d041.entry.js +4 -0
  41. package/dist/twilight/{p-d16bcce2.system.entry.js → p-d86b2dbd.system.entry.js} +9 -9
  42. package/dist/twilight/p-f35ef1d6.system.js +24 -0
  43. package/dist/twilight/twilight.esm.js +1 -1
  44. package/dist/twilight/twilight.js +1 -1
  45. package/dist/types/components/salla-add-product-button/salla-add-product-button.d.ts +11 -1
  46. package/dist/types/components/salla-quick-buy/salla-quick-buy.d.ts +50 -0
  47. package/dist/types/components.d.ts +97 -0
  48. package/package.json +6 -5
  49. package/dist/esm-es5/app-globals-ab75dc1d.js +0 -24
  50. package/dist/esm-es5/salla-button_36.entry.js +0 -53
  51. package/dist/twilight/p-70aabbb8.entry.js +0 -4
  52. package/dist/twilight/p-c0731d21.system.js +0 -4
  53. package/dist/twilight/p-e211326b.system.js +0 -24
  54. package/dist/twilight/p-f080991b.system.entry.js +0 -4
  55. package/dist/twilight/p-f43fba74.js +0 -24
@@ -6,6 +6,7 @@
6
6
  Object.defineProperty(exports, '__esModule', { value: true });
7
7
 
8
8
  const index = require('./index-1d2b3370.js');
9
+ const cart = require('./cart-3ecaa815.js');
9
10
  const _commonjsHelpers = require('./_commonjsHelpers-691dd63b.js');
10
11
  const camera = require('./camera-058ddeeb.js');
11
12
 
@@ -122,13 +123,6 @@ const SallaButton = class {
122
123
  };
123
124
  SallaButton.style = sallaButtonCss;
124
125
 
125
- const PendingOrdersIcon = `<!-- Generated by IcoMoon.io -->
126
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="30" height="32" viewBox="0 0 30 32">
127
- <title>cart</title>
128
- <path d="M15.426 28.084c0-1.412-0.85-2.684-2.156-3.226-1.305-0.54-2.807-0.241-3.805 0.758-0.999 0.998-1.298 2.5-0.758 3.805 0.54 1.303 1.815 2.155 3.226 2.155 1.928-0.003 3.49-1.564 3.492-3.492h0.001zM10.597 28.084h0.001c0-0.54 0.326-1.027 0.825-1.235 0.498-0.206 1.074-0.091 1.455 0.29 0.383 0.382 0.497 0.957 0.29 1.456-0.208 0.5-0.695 0.825-1.235 0.825-0.355 0-0.695-0.142-0.944-0.391-0.251-0.251-0.392-0.591-0.392-0.946h-0.001l0.001 0.001zM28.23 28.084c0-1.412-0.85-2.684-2.155-3.226-1.305-0.54-2.807-0.241-3.806 0.758s-1.297 2.5-0.756 3.805c0.54 1.303 1.813 2.155 3.226 2.155 1.927-0.003 3.49-1.564 3.491-3.492zM23.401 28.084c0-0.54 0.326-1.027 0.825-1.235 0.5-0.206 1.075-0.091 1.457 0.29s0.497 0.957 0.289 1.456c-0.206 0.5-0.693 0.825-1.233 0.825-0.738 0-1.337-0.599-1.337-1.337l-0.001 0.001zM1.953 0.234l-0.342-0.059c-0.29-0.064-0.594-0.004-0.839 0.166-0.247 0.169-0.414 0.436-0.463 0.734-0.050 0.3 0.023 0.607 0.201 0.85s0.444 0.402 0.738 0.44l0.341 0.059c1.825 0.324 3.248 1.794 3.548 3.662l1.981 12.369h-0.001c0.218 1.387 0.913 2.651 1.96 3.563s2.379 1.412 3.754 1.41h14.242c0.601 0 1.088-0.498 1.088-1.112s-0.487-1.112-1.088-1.112h-14.242c-1.679-0.001-3.139-1.183-3.525-2.854h11.463c1.614 0.004 3.188-0.518 4.493-1.49 1.305-0.973 2.271-2.346 2.762-3.918l1.298-4.136c0.145-0.455 0.065-0.953-0.213-1.336-0.278-0.385-0.72-0.608-1.187-0.602h-20.467l-0.181-1.141c-0.218-1.367-0.849-2.631-1.802-3.615-0.954-0.983-2.184-1.64-3.518-1.878h-0.001zM26.946 9.096l-0.993 3.169v-0.001c-0.353 1.122-1.044 2.101-1.975 2.796s-2.056 1.067-3.208 1.067h-11.833l-1.125-7.042 19.134 0.011z"></path>
129
- </svg>
130
- `;
131
-
132
126
  /*
133
127
  * anime.js v3.2.1
134
128
  * (c) 2020 Julian Garnier
@@ -1500,7 +1494,7 @@ const SallaCartSummary = class {
1500
1494
  }, '-=1700');
1501
1495
  }
1502
1496
  render() {
1503
- return (index.h(index.Host, null, index.h("a", { class: "s-cart-summary-wrapper", href: salla.url.get('cart') }, index.h("div", { id: "s-cart-icon" }, index.h("slot", { name: "icon" }, index.h("i", { class: "s-cart-summary-icon", innerHTML: PendingOrdersIcon }))), index.h("span", { class: "s-cart-summary-count" }, salla.helpers.number(this.cartSummaryCount)), index.h("p", { class: "s-cart-summary-content" }, this.showCartLabel && index.h("span", { class: "s-cart-summary-label" }, this.cartLabel), index.h("b", { class: "s-cart-summary-total" }, salla.money(this.cartSummaryTotal))))));
1497
+ return (index.h(index.Host, null, index.h("a", { class: "s-cart-summary-wrapper", href: salla.url.get('cart') }, index.h("div", { id: "s-cart-icon" }, index.h("slot", { name: "icon" }, index.h("i", { class: "s-cart-summary-icon", innerHTML: cart.Cart }))), index.h("span", { class: "s-cart-summary-count" }, salla.helpers.number(this.cartSummaryCount)), index.h("p", { class: "s-cart-summary-content" }, this.showCartLabel && index.h("span", { class: "s-cart-summary-label" }, this.cartLabel), index.h("b", { class: "s-cart-summary-total" }, salla.money(this.cartSummaryTotal))))));
1504
1498
  }
1505
1499
  get host() { return index.getElement(this); }
1506
1500
  };
@@ -1994,7 +1988,7 @@ var EVENT_KEY = 'keydown',
1994
1988
  EVENT_CLICK_OUTSIDE = 'mousedown',
1995
1989
  EVENT_TAB_MOVE = 'focusin';
1996
1990
 
1997
- function $(selector, context) {
1991
+ function $$1(selector, context) {
1998
1992
  return (context || document).querySelector(selector);
1999
1993
  }
2000
1994
 
@@ -2232,13 +2226,13 @@ var Picker = function () {
2232
2226
  var wrapper = parseHTML(html);
2233
2227
 
2234
2228
  this.domElement = wrapper;
2235
- this._domH = $('.picker_hue', wrapper);
2236
- this._domSL = $('.picker_sl', wrapper);
2237
- this._domA = $('.picker_alpha', wrapper);
2238
- this._domEdit = $('.picker_editor input', wrapper);
2239
- this._domSample = $('.picker_sample', wrapper);
2240
- this._domOkay = $('.picker_done button', wrapper);
2241
- this._domCancel = $('.picker_cancel button', wrapper);
2229
+ this._domH = $$1('.picker_hue', wrapper);
2230
+ this._domSL = $$1('.picker_sl', wrapper);
2231
+ this._domA = $$1('.picker_alpha', wrapper);
2232
+ this._domEdit = $$1('.picker_editor input', wrapper);
2233
+ this._domSample = $$1('.picker_sample', wrapper);
2234
+ this._domOkay = $$1('.picker_done button', wrapper);
2235
+ this._domCancel = $$1('.picker_cancel button', wrapper);
2242
2236
 
2243
2237
  wrapper.classList.add('layout_' + this.settings.layout);
2244
2238
  if (!this.settings.alpha) {
@@ -2423,9 +2417,9 @@ var Picker = function () {
2423
2417
  var uiH = this._domH,
2424
2418
  uiSL = this._domSL,
2425
2419
  uiA = this._domA,
2426
- thumbH = $('.picker_selector', uiH),
2427
- thumbSL = $('.picker_selector', uiSL),
2428
- thumbA = $('.picker_selector', uiA);
2420
+ thumbH = $$1('.picker_selector', uiH),
2421
+ thumbSL = $$1('.picker_selector', uiSL),
2422
+ thumbA = $$1('.picker_selector', uiA);
2429
2423
 
2430
2424
  function posX(parent, child, relX) {
2431
2425
  child.style.left = relX * 100 + '%';
@@ -2765,7 +2759,7 @@ var HOOKS = [
2765
2759
  "onYearChange",
2766
2760
  "onPreCalendarPosition",
2767
2761
  ];
2768
- var defaults = {
2762
+ var defaults$1 = {
2769
2763
  _disable: [],
2770
2764
  allowInput: false,
2771
2765
  allowInvalidPreload: false,
@@ -3115,7 +3109,7 @@ var formats = {
3115
3109
  };
3116
3110
 
3117
3111
  var createDateFormatter = function (_a) {
3118
- var _b = _a.config, config = _b === void 0 ? defaults : _b, _c = _a.l10n, l10n = _c === void 0 ? english : _c, _d = _a.isMobile, isMobile = _d === void 0 ? false : _d;
3112
+ var _b = _a.config, config = _b === void 0 ? defaults$1 : _b, _c = _a.l10n, l10n = _c === void 0 ? english : _c, _d = _a.isMobile, isMobile = _d === void 0 ? false : _d;
3119
3113
  return function (dateObj, frmt, overrideLocale) {
3120
3114
  var locale = overrideLocale || l10n;
3121
3115
  if (config.formatDate !== undefined && !isMobile) {
@@ -3134,7 +3128,7 @@ var createDateFormatter = function (_a) {
3134
3128
  };
3135
3129
  };
3136
3130
  var createDateParser = function (_a) {
3137
- var _b = _a.config, config = _b === void 0 ? defaults : _b, _c = _a.l10n, l10n = _c === void 0 ? english : _c;
3131
+ var _b = _a.config, config = _b === void 0 ? defaults$1 : _b, _c = _a.l10n, l10n = _c === void 0 ? english : _c;
3138
3132
  return function (date, givenFormat, timeless, customLocale) {
3139
3133
  if (date !== 0 && !date)
3140
3134
  return undefined;
@@ -3147,7 +3141,7 @@ var createDateParser = function (_a) {
3147
3141
  date.toFixed !== undefined)
3148
3142
  parsedDate = new Date(date);
3149
3143
  else if (typeof date === "string") {
3150
- var format = givenFormat || (config || defaults).dateFormat;
3144
+ var format = givenFormat || (config || defaults$1).dateFormat;
3151
3145
  var datestr = String(date).trim();
3152
3146
  if (datestr === "today") {
3153
3147
  parsedDate = new Date();
@@ -3292,7 +3286,7 @@ var __spreadArrays = (undefined && undefined.__spreadArrays) || function () {
3292
3286
  var DEBOUNCED_CHANGE_MS = 300;
3293
3287
  function FlatpickrInstance(element, instanceConfig) {
3294
3288
  var self = {
3295
- config: __assign(__assign({}, defaults), flatpickr.defaultConfig),
3289
+ config: __assign(__assign({}, defaults$1), flatpickr.defaultConfig),
3296
3290
  l10n: english,
3297
3291
  };
3298
3292
  self.parseDate = createDateParser({ config: self.config, l10n: self.l10n });
@@ -4589,7 +4583,7 @@ function FlatpickrInstance(element, instanceConfig) {
4589
4583
  });
4590
4584
  var timeMode = userConfig.mode === "time";
4591
4585
  if (!userConfig.dateFormat && (userConfig.enableTime || timeMode)) {
4592
- var defaultDateFormat = flatpickr.defaultConfig.dateFormat || defaults.dateFormat;
4586
+ var defaultDateFormat = flatpickr.defaultConfig.dateFormat || defaults$1.dateFormat;
4593
4587
  formats.dateFormat =
4594
4588
  userConfig.noCalendar || timeMode
4595
4589
  ? "H:i" + (userConfig.enableSeconds ? ":S" : "")
@@ -4598,7 +4592,7 @@ function FlatpickrInstance(element, instanceConfig) {
4598
4592
  if (userConfig.altInput &&
4599
4593
  (userConfig.enableTime || timeMode) &&
4600
4594
  !userConfig.altFormat) {
4601
- var defaultAltFormat = flatpickr.defaultConfig.altFormat || defaults.altFormat;
4595
+ var defaultAltFormat = flatpickr.defaultConfig.altFormat || defaults$1.altFormat;
4602
4596
  formats.altFormat =
4603
4597
  userConfig.noCalendar || timeMode
4604
4598
  ? "h:i" + (userConfig.enableSeconds ? ":S K" : " K")
@@ -21007,7 +21001,7 @@ const LeftArrow = `<!-- Generated by IcoMoon.io -->
21007
21001
  </svg>
21008
21002
  `;
21009
21003
 
21010
- const Cancel = `<!-- Generated by IcoMoon.io -->
21004
+ const Cancel$1 = `<!-- Generated by IcoMoon.io -->
21011
21005
  <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
21012
21006
  <title>cancel</title>
21013
21007
  <path d="M17.885 16l7.057-7.057c0.521-0.521 0.521-1.364 0-1.885s-1.364-0.521-1.885 0l-7.057 7.057-7.057-7.057c-0.521-0.521-1.364-0.521-1.885 0s-0.521 1.364 0 1.885l7.057 7.057-7.057 7.057c-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391l7.057-7.057 7.057 7.057c0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391c0.521-0.521 0.521-1.364 0-1.885z"></path>
@@ -21340,7 +21334,7 @@ const SallaGifting = class {
21340
21334
  :
21341
21335
  [
21342
21336
  index.h("div", { class: "s-gifting-modal-header" }, index.h("span", { class: "s-gifting-modal-icon" }, index.h("span", { innerHTML: GiftSharing })), index.h("h2", { class: "s-gifting-modal-title" }, index.h("div", { class: "s-gifting-modal-badge-wrapper" }, index.h("div", { class: "s-gifting-modal-badge" }, index.h("span", null, index.h("span", null, this.currentStep), "/2")), index.h("span", null, this.giftDetails)))),
21343
- index.h("div", { class: "s-gifting-steps-wrapper " + this.parentClass, ref: el => this.stepsWrapper = el }, index.h("div", { class: "s-gifting-step-one gift-step-1", ref: el => this.step1Elems = el }, index.h("div", { class: "s-gifting-modal-uploader-title anime-item" }, this.selectImageForYourGift), index.h("div", { class: "s-gifting-modal-uploader anime-item", ref: el => this.uploader = el }, index.h("span", { class: "s-gifting-remove-preview", onClick: () => this.removePreview(), innerHTML: Cancel }), this.selectImageOrUpload && index.h("salla-file-upload", { "instant-upload": true, name: "image_url", url: salla.url.api(salla.product.api.getUrl('giftImage')), onUploaded: event => this.handleUploadImage(event.detail), labelIdle: this.getFilepondPlaceholder(), onRemoved: () => this.handleRemoveImage() })), index.h("div", { class: "anime-item" }, !this.uploadedImage && !!this.gift && this.gift.gift_images.length > 0 ?
21337
+ index.h("div", { class: "s-gifting-steps-wrapper " + this.parentClass, ref: el => this.stepsWrapper = el }, index.h("div", { class: "s-gifting-step-one gift-step-1", ref: el => this.step1Elems = el }, index.h("div", { class: "s-gifting-modal-uploader-title anime-item" }, this.selectImageForYourGift), index.h("div", { class: "s-gifting-modal-uploader anime-item", ref: el => this.uploader = el }, index.h("span", { class: "s-gifting-remove-preview", onClick: () => this.removePreview(), innerHTML: Cancel$1 }), this.selectImageOrUpload && index.h("salla-file-upload", { "instant-upload": true, name: "image_url", url: salla.url.api(salla.product.api.getUrl('giftImage')), onUploaded: event => this.handleUploadImage(event.detail), labelIdle: this.getFilepondPlaceholder(), onRemoved: () => this.handleRemoveImage() })), index.h("div", { class: "anime-item" }, !this.uploadedImage && !!this.gift && this.gift.gift_images.length > 0 ?
21344
21338
  index.h("salla-slider", { id: "gifting-slider", loop: false, "controls-outer": true, class: "s-gifting-slider", type: "carousel" }, index.h("div", { slot: "items" }, (_a = this.gift) === null || _a === void 0 ? void 0 : _a.gift_images.map((item) => index.h("img", { class: "s-gifting-image s-gifting-clickable", src: item.url, onClick: () => this.setPreview(item), alt: `${item.id}` }))))
21345
21339
  : ""), index.h("div", { class: "anime-item" }, index.h("div", { class: "s-form-group s-gifting-selectText", ref: el => this.textSelect = el }, index.h("select", { id: "gift-text-selection", name: "gift-text-selection", class: "s-form-control s-gifting-select", onChange: e => this.toggleGiftText(e) }, index.h("option", { "data-id": null, selected: true }, this.selectGiftMessage), (_b = this.gift) === null || _b === void 0 ? void 0 :
21346
21340
  _b.gift_texts.map((txt) => index.h("option", { "data-id": txt.id, value: txt.text, key: txt.id }, txt.text)), index.h("option", { "data-id": "custom" }, this.giftCustomText))), index.h("div", { class: this.showGiftText ? "s-form-group s-gifting-textarea shown" : "s-form-group s-gifting-textarea hide", ref: (el) => this.customTextArea = el }, index.h("label", { htmlFor: "gift-custom-text", class: "s-form-label" }, this.giftCustomText), index.h("div", { class: "mt-1" }, index.h("textarea", { onInput: (event) => this.handleTextAreaChange(event), rows: 4, ref: (el) => this.textArea = el, name: "gift-custom-text", id: "gift-custom-text", class: "s-form-control" })))), index.h("div", { class: "anime-item" }, index.h("salla-button", { color: "primary", width: "wide", onClick: () => this.goToStep2() }, index.h("span", null, this.nextStep)))), index.h("div", { class: "s-gifting-step-two gift-step-2", ref: el => this.step2Elems = el }, index.h("div", { class: this.errors && this.errors['sender_name'] ? "s-form-group s-form-has-error anime-item opacity-0" : "s-form-group anime-item opacity-0" }, index.h("label", { htmlFor: "sender_name", class: "s-form-label" }, this.senderNameLabel), index.h("input", { type: "text", class: "s-form-control", name: "sender_name", id: "sender_name", value: this.senderName, onInput: (event) => this.handleSenderName(event), placeholder: "" }), this.errors && this.errors['sender_name'] ?
@@ -22069,7 +22063,7 @@ const SallaLoyalty = class {
22069
22063
  ];
22070
22064
  }
22071
22065
  getAfterExchangeUI() {
22072
- return index.h("slot", { name: 'points-applied-widget' }, index.h("salla-list-tile", { class: "s-loyalty-after-exchange" }, index.h("div", { slot: "title", class: "s-loyalty-after-exchange-title" }, this.prizeTitle, " \u00A0 - \u00A0 ", this.prizePoints, " ", salla.lang.get('pages.loyalty_program.point')), index.h("div", { slot: 'action', class: "s-loyalty-after-exchange-action" }, index.h("salla-button", { class: "s-loyalty-after-exchange-reset", shape: "icon", fill: 'outline', color: "danger", size: "small", onClick: () => this.resetExchange() }, index.h("span", { innerHTML: Cancel })))));
22066
+ return index.h("slot", { name: 'points-applied-widget' }, index.h("salla-list-tile", { class: "s-loyalty-after-exchange" }, index.h("div", { slot: "title", class: "s-loyalty-after-exchange-title" }, this.prizeTitle, " \u00A0 - \u00A0 ", this.prizePoints, " ", salla.lang.get('pages.loyalty_program.point')), index.h("div", { slot: 'action', class: "s-loyalty-after-exchange-action" }, index.h("salla-button", { class: "s-loyalty-after-exchange-reset", shape: "icon", fill: 'outline', color: "danger", size: "small", onClick: () => this.resetExchange() }, index.h("span", { innerHTML: Cancel$1 })))));
22073
22067
  }
22074
22068
  /**
22075
22069
  * Show loyalty modal
@@ -23027,7 +23021,7 @@ const SallaModal = class {
23027
23021
  return (index.h(index.Host, { class: 'salla-modal s-modal s-modal-container s-hidden', "aria-modal": "true", role: "dialog", onKeyUp: e => this.handleKeyUp(e) }, index.h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }), index.h("div", { class: "s-modal-wrapper" }, index.h("span", { class: 's-modal-spacer s-modal-align-' + this.position }, "\u200B"), index.h("div", { class: 's-modal-body ' + 's-modal-align-' + this.position + ' s-modal-' + this.getWidth() + (this.noPadding ? ' s-modal-nopadding' : ' s-modal-padding') }, index.h("slot", { name: "loading" }, index.h("salla-loading", null)), index.h("div", { class: "s-hidden" }, index.h("slot", null))))));
23028
23022
  }
23029
23023
  return (index.h(index.Host, { class: 'salla-modal s-modal s-modal-container s-hidden', "aria-modal": "true", role: "dialog" }, index.h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }), index.h("div", { class: "s-modal-wrapper" }, index.h("span", { class: 's-modal-spacer s-modal-align-' + this.position }, "\u200B"), index.h("div", { class: 's-modal-body ' + 's-modal-align-' + this.position + ' s-modal-' + this.getWidth() + (this.noPadding ? ' s-modal-nopadding' : ' s-modal-padding') }, index.h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.centered } }, this.isClosable ?
23030
- index.h("button", { class: "s-modal-close", onClick: () => this.closeModal(), type: "button" }, index.h("span", { innerHTML: Cancel }))
23024
+ index.h("button", { class: "s-modal-close", onClick: () => this.closeModal(), type: "button" }, index.h("span", { innerHTML: Cancel$1 }))
23031
23025
  : '', this.modalTitle || this.subTitle ?
23032
23026
  index.h("div", { class: "s-modal-header-inner" }, index.h("slot", { name: 'icon' }, !!this.iconStyle ?
23033
23027
  index.h("div", { class: this.iconBlockClasses(), innerHTML: this.iconStyle == 'error' ? AlertEngineIcon : CheckCircle2 })
@@ -23595,6 +23589,2582 @@ const SallaQuantityInput = class {
23595
23589
  };
23596
23590
  SallaQuantityInput.style = sallaQuantityInputCss;
23597
23591
 
23592
+ const FullWallet = `<!-- Generated by IcoMoon.io -->
23593
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
23594
+ <title>full-wallet</title>
23595
+ <path d="M29 12h-26c-0.668-0.008-1.284-0.226-1.787-0.59l0.009 0.006c-0.744-0.552-1.222-1.428-1.222-2.416 0-1.657 1.343-3 2.999-3h6c0.552 0 1 0.448 1 1s-0.448 1-1 1v0h-6c-0.552 0-1 0.448-1 1 0 0.326 0.156 0.616 0.397 0.798l0.002 0.002c0.167 0.12 0.374 0.194 0.599 0.2l0.001 0h26c0.552 0 1 0.448 1 1s-0.448 1-1 1v0zM27 12c-0.552 0-1-0.448-1-1v0-3h-3c-0.552 0-1-0.448-1-1s0.448-1 1-1v0h4c0.552 0 1 0.448 1 1v0 4c0 0.552-0.448 1-1 1v0zM29 30h-26c-1.657 0-3-1.343-3-3v0-18c0-0.552 0.448-1 1-1s1 0.448 1 1v0 18c0 0.552 0.448 1 1 1v0h25v-5c0-0.552 0.448-1 1-1s1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM29 18c-0.552 0-1-0.448-1-1v0-6c0-0.552 0.448-1 1-1s1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM31 24h-7c-2.209 0-4-1.791-4-4s1.791-4 4-4v0h7c0.552 0 1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM24 18c-1.105 0-2 0.895-2 2s0.895 2 2 2v0h6v-4zM25 12c-0.001 0-0.001 0-0.002 0-0.389 0-0.726-0.222-0.891-0.546l-0.003-0.006-3.552-7.106-2.306 1.152c-0.13 0.066-0.284 0.105-0.447 0.105-0.552 0-1-0.448-1-1 0-0.39 0.223-0.727 0.548-0.892l0.006-0.003 3.2-1.6c0.13-0.067 0.284-0.106 0.447-0.106 0.39 0 0.727 0.223 0.892 0.548l0.003 0.006 4 8c0.067 0.13 0.106 0.285 0.106 0.448 0 0.552-0.448 1-1 1v0zM21 12c-0.001 0-0.001 0-0.002 0-0.389 0-0.726-0.222-0.891-0.546l-0.003-0.006-3.552-7.106-15.104 7.552c-0.13 0.066-0.284 0.105-0.447 0.105-0.552 0-1-0.448-1-1 0-0.39 0.223-0.727 0.548-0.892l0.006-0.003 16-8c0.13-0.067 0.284-0.106 0.447-0.106 0.39 0 0.727 0.223 0.892 0.548l0.003 0.006 4 8c0.067 0.13 0.106 0.285 0.106 0.448 0 0.552-0.448 1-1 1-0.001 0-0.001 0-0.002 0h0z"></path>
23596
+ </svg>
23597
+ `;
23598
+
23599
+ var bind = function bind(fn, thisArg) {
23600
+ return function wrap() {
23601
+ var args = new Array(arguments.length);
23602
+ for (var i = 0; i < args.length; i++) {
23603
+ args[i] = arguments[i];
23604
+ }
23605
+ return fn.apply(thisArg, args);
23606
+ };
23607
+ };
23608
+
23609
+ // utils is a library of generic helper functions non-specific to axios
23610
+
23611
+ var toString = Object.prototype.toString;
23612
+
23613
+ /**
23614
+ * Determine if a value is an Array
23615
+ *
23616
+ * @param {Object} val The value to test
23617
+ * @returns {boolean} True if value is an Array, otherwise false
23618
+ */
23619
+ function isArray(val) {
23620
+ return toString.call(val) === '[object Array]';
23621
+ }
23622
+
23623
+ /**
23624
+ * Determine if a value is undefined
23625
+ *
23626
+ * @param {Object} val The value to test
23627
+ * @returns {boolean} True if the value is undefined, otherwise false
23628
+ */
23629
+ function isUndefined(val) {
23630
+ return typeof val === 'undefined';
23631
+ }
23632
+
23633
+ /**
23634
+ * Determine if a value is a Buffer
23635
+ *
23636
+ * @param {Object} val The value to test
23637
+ * @returns {boolean} True if value is a Buffer, otherwise false
23638
+ */
23639
+ function isBuffer(val) {
23640
+ return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
23641
+ && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
23642
+ }
23643
+
23644
+ /**
23645
+ * Determine if a value is an ArrayBuffer
23646
+ *
23647
+ * @param {Object} val The value to test
23648
+ * @returns {boolean} True if value is an ArrayBuffer, otherwise false
23649
+ */
23650
+ function isArrayBuffer(val) {
23651
+ return toString.call(val) === '[object ArrayBuffer]';
23652
+ }
23653
+
23654
+ /**
23655
+ * Determine if a value is a FormData
23656
+ *
23657
+ * @param {Object} val The value to test
23658
+ * @returns {boolean} True if value is an FormData, otherwise false
23659
+ */
23660
+ function isFormData(val) {
23661
+ return (typeof FormData !== 'undefined') && (val instanceof FormData);
23662
+ }
23663
+
23664
+ /**
23665
+ * Determine if a value is a view on an ArrayBuffer
23666
+ *
23667
+ * @param {Object} val The value to test
23668
+ * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
23669
+ */
23670
+ function isArrayBufferView(val) {
23671
+ var result;
23672
+ if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
23673
+ result = ArrayBuffer.isView(val);
23674
+ } else {
23675
+ result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
23676
+ }
23677
+ return result;
23678
+ }
23679
+
23680
+ /**
23681
+ * Determine if a value is a String
23682
+ *
23683
+ * @param {Object} val The value to test
23684
+ * @returns {boolean} True if value is a String, otherwise false
23685
+ */
23686
+ function isString(val) {
23687
+ return typeof val === 'string';
23688
+ }
23689
+
23690
+ /**
23691
+ * Determine if a value is a Number
23692
+ *
23693
+ * @param {Object} val The value to test
23694
+ * @returns {boolean} True if value is a Number, otherwise false
23695
+ */
23696
+ function isNumber(val) {
23697
+ return typeof val === 'number';
23698
+ }
23699
+
23700
+ /**
23701
+ * Determine if a value is an Object
23702
+ *
23703
+ * @param {Object} val The value to test
23704
+ * @returns {boolean} True if value is an Object, otherwise false
23705
+ */
23706
+ function isObject(val) {
23707
+ return val !== null && typeof val === 'object';
23708
+ }
23709
+
23710
+ /**
23711
+ * Determine if a value is a plain Object
23712
+ *
23713
+ * @param {Object} val The value to test
23714
+ * @return {boolean} True if value is a plain Object, otherwise false
23715
+ */
23716
+ function isPlainObject(val) {
23717
+ if (toString.call(val) !== '[object Object]') {
23718
+ return false;
23719
+ }
23720
+
23721
+ var prototype = Object.getPrototypeOf(val);
23722
+ return prototype === null || prototype === Object.prototype;
23723
+ }
23724
+
23725
+ /**
23726
+ * Determine if a value is a Date
23727
+ *
23728
+ * @param {Object} val The value to test
23729
+ * @returns {boolean} True if value is a Date, otherwise false
23730
+ */
23731
+ function isDate(val) {
23732
+ return toString.call(val) === '[object Date]';
23733
+ }
23734
+
23735
+ /**
23736
+ * Determine if a value is a File
23737
+ *
23738
+ * @param {Object} val The value to test
23739
+ * @returns {boolean} True if value is a File, otherwise false
23740
+ */
23741
+ function isFile(val) {
23742
+ return toString.call(val) === '[object File]';
23743
+ }
23744
+
23745
+ /**
23746
+ * Determine if a value is a Blob
23747
+ *
23748
+ * @param {Object} val The value to test
23749
+ * @returns {boolean} True if value is a Blob, otherwise false
23750
+ */
23751
+ function isBlob(val) {
23752
+ return toString.call(val) === '[object Blob]';
23753
+ }
23754
+
23755
+ /**
23756
+ * Determine if a value is a Function
23757
+ *
23758
+ * @param {Object} val The value to test
23759
+ * @returns {boolean} True if value is a Function, otherwise false
23760
+ */
23761
+ function isFunction(val) {
23762
+ return toString.call(val) === '[object Function]';
23763
+ }
23764
+
23765
+ /**
23766
+ * Determine if a value is a Stream
23767
+ *
23768
+ * @param {Object} val The value to test
23769
+ * @returns {boolean} True if value is a Stream, otherwise false
23770
+ */
23771
+ function isStream(val) {
23772
+ return isObject(val) && isFunction(val.pipe);
23773
+ }
23774
+
23775
+ /**
23776
+ * Determine if a value is a URLSearchParams object
23777
+ *
23778
+ * @param {Object} val The value to test
23779
+ * @returns {boolean} True if value is a URLSearchParams object, otherwise false
23780
+ */
23781
+ function isURLSearchParams(val) {
23782
+ return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
23783
+ }
23784
+
23785
+ /**
23786
+ * Trim excess whitespace off the beginning and end of a string
23787
+ *
23788
+ * @param {String} str The String to trim
23789
+ * @returns {String} The String freed of excess whitespace
23790
+ */
23791
+ function trim(str) {
23792
+ return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
23793
+ }
23794
+
23795
+ /**
23796
+ * Determine if we're running in a standard browser environment
23797
+ *
23798
+ * This allows axios to run in a web worker, and react-native.
23799
+ * Both environments support XMLHttpRequest, but not fully standard globals.
23800
+ *
23801
+ * web workers:
23802
+ * typeof window -> undefined
23803
+ * typeof document -> undefined
23804
+ *
23805
+ * react-native:
23806
+ * navigator.product -> 'ReactNative'
23807
+ * nativescript
23808
+ * navigator.product -> 'NativeScript' or 'NS'
23809
+ */
23810
+ function isStandardBrowserEnv() {
23811
+ if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
23812
+ navigator.product === 'NativeScript' ||
23813
+ navigator.product === 'NS')) {
23814
+ return false;
23815
+ }
23816
+ return (
23817
+ typeof window !== 'undefined' &&
23818
+ typeof document !== 'undefined'
23819
+ );
23820
+ }
23821
+
23822
+ /**
23823
+ * Iterate over an Array or an Object invoking a function for each item.
23824
+ *
23825
+ * If `obj` is an Array callback will be called passing
23826
+ * the value, index, and complete array for each item.
23827
+ *
23828
+ * If 'obj' is an Object callback will be called passing
23829
+ * the value, key, and complete object for each property.
23830
+ *
23831
+ * @param {Object|Array} obj The object to iterate
23832
+ * @param {Function} fn The callback to invoke for each item
23833
+ */
23834
+ function forEach(obj, fn) {
23835
+ // Don't bother if no value provided
23836
+ if (obj === null || typeof obj === 'undefined') {
23837
+ return;
23838
+ }
23839
+
23840
+ // Force an array if not already something iterable
23841
+ if (typeof obj !== 'object') {
23842
+ /*eslint no-param-reassign:0*/
23843
+ obj = [obj];
23844
+ }
23845
+
23846
+ if (isArray(obj)) {
23847
+ // Iterate over array values
23848
+ for (var i = 0, l = obj.length; i < l; i++) {
23849
+ fn.call(null, obj[i], i, obj);
23850
+ }
23851
+ } else {
23852
+ // Iterate over object keys
23853
+ for (var key in obj) {
23854
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
23855
+ fn.call(null, obj[key], key, obj);
23856
+ }
23857
+ }
23858
+ }
23859
+ }
23860
+
23861
+ /**
23862
+ * Accepts varargs expecting each argument to be an object, then
23863
+ * immutably merges the properties of each object and returns result.
23864
+ *
23865
+ * When multiple objects contain the same key the later object in
23866
+ * the arguments list will take precedence.
23867
+ *
23868
+ * Example:
23869
+ *
23870
+ * ```js
23871
+ * var result = merge({foo: 123}, {foo: 456});
23872
+ * console.log(result.foo); // outputs 456
23873
+ * ```
23874
+ *
23875
+ * @param {Object} obj1 Object to merge
23876
+ * @returns {Object} Result of all merge properties
23877
+ */
23878
+ function merge(/* obj1, obj2, obj3, ... */) {
23879
+ var result = {};
23880
+ function assignValue(val, key) {
23881
+ if (isPlainObject(result[key]) && isPlainObject(val)) {
23882
+ result[key] = merge(result[key], val);
23883
+ } else if (isPlainObject(val)) {
23884
+ result[key] = merge({}, val);
23885
+ } else if (isArray(val)) {
23886
+ result[key] = val.slice();
23887
+ } else {
23888
+ result[key] = val;
23889
+ }
23890
+ }
23891
+
23892
+ for (var i = 0, l = arguments.length; i < l; i++) {
23893
+ forEach(arguments[i], assignValue);
23894
+ }
23895
+ return result;
23896
+ }
23897
+
23898
+ /**
23899
+ * Extends object a by mutably adding to it the properties of object b.
23900
+ *
23901
+ * @param {Object} a The object to be extended
23902
+ * @param {Object} b The object to copy properties from
23903
+ * @param {Object} thisArg The object to bind function to
23904
+ * @return {Object} The resulting value of object a
23905
+ */
23906
+ function extend(a, b, thisArg) {
23907
+ forEach(b, function assignValue(val, key) {
23908
+ if (thisArg && typeof val === 'function') {
23909
+ a[key] = bind(val, thisArg);
23910
+ } else {
23911
+ a[key] = val;
23912
+ }
23913
+ });
23914
+ return a;
23915
+ }
23916
+
23917
+ /**
23918
+ * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
23919
+ *
23920
+ * @param {string} content with BOM
23921
+ * @return {string} content value without BOM
23922
+ */
23923
+ function stripBOM(content) {
23924
+ if (content.charCodeAt(0) === 0xFEFF) {
23925
+ content = content.slice(1);
23926
+ }
23927
+ return content;
23928
+ }
23929
+
23930
+ var utils = {
23931
+ isArray: isArray,
23932
+ isArrayBuffer: isArrayBuffer,
23933
+ isBuffer: isBuffer,
23934
+ isFormData: isFormData,
23935
+ isArrayBufferView: isArrayBufferView,
23936
+ isString: isString,
23937
+ isNumber: isNumber,
23938
+ isObject: isObject,
23939
+ isPlainObject: isPlainObject,
23940
+ isUndefined: isUndefined,
23941
+ isDate: isDate,
23942
+ isFile: isFile,
23943
+ isBlob: isBlob,
23944
+ isFunction: isFunction,
23945
+ isStream: isStream,
23946
+ isURLSearchParams: isURLSearchParams,
23947
+ isStandardBrowserEnv: isStandardBrowserEnv,
23948
+ forEach: forEach,
23949
+ merge: merge,
23950
+ extend: extend,
23951
+ trim: trim,
23952
+ stripBOM: stripBOM
23953
+ };
23954
+
23955
+ function encode(val) {
23956
+ return encodeURIComponent(val).
23957
+ replace(/%3A/gi, ':').
23958
+ replace(/%24/g, '$').
23959
+ replace(/%2C/gi, ',').
23960
+ replace(/%20/g, '+').
23961
+ replace(/%5B/gi, '[').
23962
+ replace(/%5D/gi, ']');
23963
+ }
23964
+
23965
+ /**
23966
+ * Build a URL by appending params to the end
23967
+ *
23968
+ * @param {string} url The base of the url (e.g., http://www.google.com)
23969
+ * @param {object} [params] The params to be appended
23970
+ * @returns {string} The formatted url
23971
+ */
23972
+ var buildURL = function buildURL(url, params, paramsSerializer) {
23973
+ /*eslint no-param-reassign:0*/
23974
+ if (!params) {
23975
+ return url;
23976
+ }
23977
+
23978
+ var serializedParams;
23979
+ if (paramsSerializer) {
23980
+ serializedParams = paramsSerializer(params);
23981
+ } else if (utils.isURLSearchParams(params)) {
23982
+ serializedParams = params.toString();
23983
+ } else {
23984
+ var parts = [];
23985
+
23986
+ utils.forEach(params, function serialize(val, key) {
23987
+ if (val === null || typeof val === 'undefined') {
23988
+ return;
23989
+ }
23990
+
23991
+ if (utils.isArray(val)) {
23992
+ key = key + '[]';
23993
+ } else {
23994
+ val = [val];
23995
+ }
23996
+
23997
+ utils.forEach(val, function parseValue(v) {
23998
+ if (utils.isDate(v)) {
23999
+ v = v.toISOString();
24000
+ } else if (utils.isObject(v)) {
24001
+ v = JSON.stringify(v);
24002
+ }
24003
+ parts.push(encode(key) + '=' + encode(v));
24004
+ });
24005
+ });
24006
+
24007
+ serializedParams = parts.join('&');
24008
+ }
24009
+
24010
+ if (serializedParams) {
24011
+ var hashmarkIndex = url.indexOf('#');
24012
+ if (hashmarkIndex !== -1) {
24013
+ url = url.slice(0, hashmarkIndex);
24014
+ }
24015
+
24016
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
24017
+ }
24018
+
24019
+ return url;
24020
+ };
24021
+
24022
+ function InterceptorManager() {
24023
+ this.handlers = [];
24024
+ }
24025
+
24026
+ /**
24027
+ * Add a new interceptor to the stack
24028
+ *
24029
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
24030
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
24031
+ *
24032
+ * @return {Number} An ID used to remove interceptor later
24033
+ */
24034
+ InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
24035
+ this.handlers.push({
24036
+ fulfilled: fulfilled,
24037
+ rejected: rejected,
24038
+ synchronous: options ? options.synchronous : false,
24039
+ runWhen: options ? options.runWhen : null
24040
+ });
24041
+ return this.handlers.length - 1;
24042
+ };
24043
+
24044
+ /**
24045
+ * Remove an interceptor from the stack
24046
+ *
24047
+ * @param {Number} id The ID that was returned by `use`
24048
+ */
24049
+ InterceptorManager.prototype.eject = function eject(id) {
24050
+ if (this.handlers[id]) {
24051
+ this.handlers[id] = null;
24052
+ }
24053
+ };
24054
+
24055
+ /**
24056
+ * Iterate over all the registered interceptors
24057
+ *
24058
+ * This method is particularly useful for skipping over any
24059
+ * interceptors that may have become `null` calling `eject`.
24060
+ *
24061
+ * @param {Function} fn The function to call for each interceptor
24062
+ */
24063
+ InterceptorManager.prototype.forEach = function forEach(fn) {
24064
+ utils.forEach(this.handlers, function forEachHandler(h) {
24065
+ if (h !== null) {
24066
+ fn(h);
24067
+ }
24068
+ });
24069
+ };
24070
+
24071
+ var InterceptorManager_1 = InterceptorManager;
24072
+
24073
+ var normalizeHeaderName = function normalizeHeaderName(headers, normalizedName) {
24074
+ utils.forEach(headers, function processHeader(value, name) {
24075
+ if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
24076
+ headers[normalizedName] = value;
24077
+ delete headers[name];
24078
+ }
24079
+ });
24080
+ };
24081
+
24082
+ /**
24083
+ * Update an Error with the specified config, error code, and response.
24084
+ *
24085
+ * @param {Error} error The error to update.
24086
+ * @param {Object} config The config.
24087
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
24088
+ * @param {Object} [request] The request.
24089
+ * @param {Object} [response] The response.
24090
+ * @returns {Error} The error.
24091
+ */
24092
+ var enhanceError = function enhanceError(error, config, code, request, response) {
24093
+ error.config = config;
24094
+ if (code) {
24095
+ error.code = code;
24096
+ }
24097
+
24098
+ error.request = request;
24099
+ error.response = response;
24100
+ error.isAxiosError = true;
24101
+
24102
+ error.toJSON = function toJSON() {
24103
+ return {
24104
+ // Standard
24105
+ message: this.message,
24106
+ name: this.name,
24107
+ // Microsoft
24108
+ description: this.description,
24109
+ number: this.number,
24110
+ // Mozilla
24111
+ fileName: this.fileName,
24112
+ lineNumber: this.lineNumber,
24113
+ columnNumber: this.columnNumber,
24114
+ stack: this.stack,
24115
+ // Axios
24116
+ config: this.config,
24117
+ code: this.code,
24118
+ status: this.response && this.response.status ? this.response.status : null
24119
+ };
24120
+ };
24121
+ return error;
24122
+ };
24123
+
24124
+ /**
24125
+ * Create an Error with the specified message, config, error code, request and response.
24126
+ *
24127
+ * @param {string} message The error message.
24128
+ * @param {Object} config The config.
24129
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
24130
+ * @param {Object} [request] The request.
24131
+ * @param {Object} [response] The response.
24132
+ * @returns {Error} The created error.
24133
+ */
24134
+ var createError = function createError(message, config, code, request, response) {
24135
+ var error = new Error(message);
24136
+ return enhanceError(error, config, code, request, response);
24137
+ };
24138
+
24139
+ /**
24140
+ * Resolve or reject a Promise based on response status.
24141
+ *
24142
+ * @param {Function} resolve A function that resolves the promise.
24143
+ * @param {Function} reject A function that rejects the promise.
24144
+ * @param {object} response The response.
24145
+ */
24146
+ var settle = function settle(resolve, reject, response) {
24147
+ var validateStatus = response.config.validateStatus;
24148
+ if (!response.status || !validateStatus || validateStatus(response.status)) {
24149
+ resolve(response);
24150
+ } else {
24151
+ reject(createError(
24152
+ 'Request failed with status code ' + response.status,
24153
+ response.config,
24154
+ null,
24155
+ response.request,
24156
+ response
24157
+ ));
24158
+ }
24159
+ };
24160
+
24161
+ var cookies = (
24162
+ utils.isStandardBrowserEnv() ?
24163
+
24164
+ // Standard browser envs support document.cookie
24165
+ (function standardBrowserEnv() {
24166
+ return {
24167
+ write: function write(name, value, expires, path, domain, secure) {
24168
+ var cookie = [];
24169
+ cookie.push(name + '=' + encodeURIComponent(value));
24170
+
24171
+ if (utils.isNumber(expires)) {
24172
+ cookie.push('expires=' + new Date(expires).toGMTString());
24173
+ }
24174
+
24175
+ if (utils.isString(path)) {
24176
+ cookie.push('path=' + path);
24177
+ }
24178
+
24179
+ if (utils.isString(domain)) {
24180
+ cookie.push('domain=' + domain);
24181
+ }
24182
+
24183
+ if (secure === true) {
24184
+ cookie.push('secure');
24185
+ }
24186
+
24187
+ document.cookie = cookie.join('; ');
24188
+ },
24189
+
24190
+ read: function read(name) {
24191
+ var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
24192
+ return (match ? decodeURIComponent(match[3]) : null);
24193
+ },
24194
+
24195
+ remove: function remove(name) {
24196
+ this.write(name, '', Date.now() - 86400000);
24197
+ }
24198
+ };
24199
+ })() :
24200
+
24201
+ // Non standard browser env (web workers, react-native) lack needed support.
24202
+ (function nonStandardBrowserEnv() {
24203
+ return {
24204
+ write: function write() {},
24205
+ read: function read() { return null; },
24206
+ remove: function remove() {}
24207
+ };
24208
+ })()
24209
+ );
24210
+
24211
+ /**
24212
+ * Determines whether the specified URL is absolute
24213
+ *
24214
+ * @param {string} url The URL to test
24215
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
24216
+ */
24217
+ var isAbsoluteURL = function isAbsoluteURL(url) {
24218
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
24219
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
24220
+ // by any combination of letters, digits, plus, period, or hyphen.
24221
+ return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
24222
+ };
24223
+
24224
+ /**
24225
+ * Creates a new URL by combining the specified URLs
24226
+ *
24227
+ * @param {string} baseURL The base URL
24228
+ * @param {string} relativeURL The relative URL
24229
+ * @returns {string} The combined URL
24230
+ */
24231
+ var combineURLs = function combineURLs(baseURL, relativeURL) {
24232
+ return relativeURL
24233
+ ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
24234
+ : baseURL;
24235
+ };
24236
+
24237
+ /**
24238
+ * Creates a new URL by combining the baseURL with the requestedURL,
24239
+ * only when the requestedURL is not already an absolute URL.
24240
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
24241
+ *
24242
+ * @param {string} baseURL The base URL
24243
+ * @param {string} requestedURL Absolute or relative URL to combine
24244
+ * @returns {string} The combined full path
24245
+ */
24246
+ var buildFullPath = function buildFullPath(baseURL, requestedURL) {
24247
+ if (baseURL && !isAbsoluteURL(requestedURL)) {
24248
+ return combineURLs(baseURL, requestedURL);
24249
+ }
24250
+ return requestedURL;
24251
+ };
24252
+
24253
+ // Headers whose duplicates are ignored by node
24254
+ // c.f. https://nodejs.org/api/http.html#http_message_headers
24255
+ var ignoreDuplicateOf = [
24256
+ 'age', 'authorization', 'content-length', 'content-type', 'etag',
24257
+ 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
24258
+ 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
24259
+ 'referer', 'retry-after', 'user-agent'
24260
+ ];
24261
+
24262
+ /**
24263
+ * Parse headers into an object
24264
+ *
24265
+ * ```
24266
+ * Date: Wed, 27 Aug 2014 08:58:49 GMT
24267
+ * Content-Type: application/json
24268
+ * Connection: keep-alive
24269
+ * Transfer-Encoding: chunked
24270
+ * ```
24271
+ *
24272
+ * @param {String} headers Headers needing to be parsed
24273
+ * @returns {Object} Headers parsed into an object
24274
+ */
24275
+ var parseHeaders = function parseHeaders(headers) {
24276
+ var parsed = {};
24277
+ var key;
24278
+ var val;
24279
+ var i;
24280
+
24281
+ if (!headers) { return parsed; }
24282
+
24283
+ utils.forEach(headers.split('\n'), function parser(line) {
24284
+ i = line.indexOf(':');
24285
+ key = utils.trim(line.substr(0, i)).toLowerCase();
24286
+ val = utils.trim(line.substr(i + 1));
24287
+
24288
+ if (key) {
24289
+ if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
24290
+ return;
24291
+ }
24292
+ if (key === 'set-cookie') {
24293
+ parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
24294
+ } else {
24295
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
24296
+ }
24297
+ }
24298
+ });
24299
+
24300
+ return parsed;
24301
+ };
24302
+
24303
+ var isURLSameOrigin = (
24304
+ utils.isStandardBrowserEnv() ?
24305
+
24306
+ // Standard browser envs have full support of the APIs needed to test
24307
+ // whether the request URL is of the same origin as current location.
24308
+ (function standardBrowserEnv() {
24309
+ var msie = /(msie|trident)/i.test(navigator.userAgent);
24310
+ var urlParsingNode = document.createElement('a');
24311
+ var originURL;
24312
+
24313
+ /**
24314
+ * Parse a URL to discover it's components
24315
+ *
24316
+ * @param {String} url The URL to be parsed
24317
+ * @returns {Object}
24318
+ */
24319
+ function resolveURL(url) {
24320
+ var href = url;
24321
+
24322
+ if (msie) {
24323
+ // IE needs attribute set twice to normalize properties
24324
+ urlParsingNode.setAttribute('href', href);
24325
+ href = urlParsingNode.href;
24326
+ }
24327
+
24328
+ urlParsingNode.setAttribute('href', href);
24329
+
24330
+ // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
24331
+ return {
24332
+ href: urlParsingNode.href,
24333
+ protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
24334
+ host: urlParsingNode.host,
24335
+ search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
24336
+ hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
24337
+ hostname: urlParsingNode.hostname,
24338
+ port: urlParsingNode.port,
24339
+ pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
24340
+ urlParsingNode.pathname :
24341
+ '/' + urlParsingNode.pathname
24342
+ };
24343
+ }
24344
+
24345
+ originURL = resolveURL(window.location.href);
24346
+
24347
+ /**
24348
+ * Determine if a URL shares the same origin as the current location
24349
+ *
24350
+ * @param {String} requestURL The URL to test
24351
+ * @returns {boolean} True if URL shares the same origin, otherwise false
24352
+ */
24353
+ return function isURLSameOrigin(requestURL) {
24354
+ var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
24355
+ return (parsed.protocol === originURL.protocol &&
24356
+ parsed.host === originURL.host);
24357
+ };
24358
+ })() :
24359
+
24360
+ // Non standard browser envs (web workers, react-native) lack needed support.
24361
+ (function nonStandardBrowserEnv() {
24362
+ return function isURLSameOrigin() {
24363
+ return true;
24364
+ };
24365
+ })()
24366
+ );
24367
+
24368
+ /**
24369
+ * A `Cancel` is an object that is thrown when an operation is canceled.
24370
+ *
24371
+ * @class
24372
+ * @param {string=} message The message.
24373
+ */
24374
+ function Cancel(message) {
24375
+ this.message = message;
24376
+ }
24377
+
24378
+ Cancel.prototype.toString = function toString() {
24379
+ return 'Cancel' + (this.message ? ': ' + this.message : '');
24380
+ };
24381
+
24382
+ Cancel.prototype.__CANCEL__ = true;
24383
+
24384
+ var Cancel_1 = Cancel;
24385
+
24386
+ var xhr = function xhrAdapter(config) {
24387
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
24388
+ var requestData = config.data;
24389
+ var requestHeaders = config.headers;
24390
+ var responseType = config.responseType;
24391
+ var onCanceled;
24392
+ function done() {
24393
+ if (config.cancelToken) {
24394
+ config.cancelToken.unsubscribe(onCanceled);
24395
+ }
24396
+
24397
+ if (config.signal) {
24398
+ config.signal.removeEventListener('abort', onCanceled);
24399
+ }
24400
+ }
24401
+
24402
+ if (utils.isFormData(requestData)) {
24403
+ delete requestHeaders['Content-Type']; // Let the browser set it
24404
+ }
24405
+
24406
+ var request = new XMLHttpRequest();
24407
+
24408
+ // HTTP basic authentication
24409
+ if (config.auth) {
24410
+ var username = config.auth.username || '';
24411
+ var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
24412
+ requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
24413
+ }
24414
+
24415
+ var fullPath = buildFullPath(config.baseURL, config.url);
24416
+ request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
24417
+
24418
+ // Set the request timeout in MS
24419
+ request.timeout = config.timeout;
24420
+
24421
+ function onloadend() {
24422
+ if (!request) {
24423
+ return;
24424
+ }
24425
+ // Prepare the response
24426
+ var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
24427
+ var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
24428
+ request.responseText : request.response;
24429
+ var response = {
24430
+ data: responseData,
24431
+ status: request.status,
24432
+ statusText: request.statusText,
24433
+ headers: responseHeaders,
24434
+ config: config,
24435
+ request: request
24436
+ };
24437
+
24438
+ settle(function _resolve(value) {
24439
+ resolve(value);
24440
+ done();
24441
+ }, function _reject(err) {
24442
+ reject(err);
24443
+ done();
24444
+ }, response);
24445
+
24446
+ // Clean up request
24447
+ request = null;
24448
+ }
24449
+
24450
+ if ('onloadend' in request) {
24451
+ // Use onloadend if available
24452
+ request.onloadend = onloadend;
24453
+ } else {
24454
+ // Listen for ready state to emulate onloadend
24455
+ request.onreadystatechange = function handleLoad() {
24456
+ if (!request || request.readyState !== 4) {
24457
+ return;
24458
+ }
24459
+
24460
+ // The request errored out and we didn't get a response, this will be
24461
+ // handled by onerror instead
24462
+ // With one exception: request that using file: protocol, most browsers
24463
+ // will return status as 0 even though it's a successful request
24464
+ if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
24465
+ return;
24466
+ }
24467
+ // readystate handler is calling before onerror or ontimeout handlers,
24468
+ // so we should call onloadend on the next 'tick'
24469
+ setTimeout(onloadend);
24470
+ };
24471
+ }
24472
+
24473
+ // Handle browser request cancellation (as opposed to a manual cancellation)
24474
+ request.onabort = function handleAbort() {
24475
+ if (!request) {
24476
+ return;
24477
+ }
24478
+
24479
+ reject(createError('Request aborted', config, 'ECONNABORTED', request));
24480
+
24481
+ // Clean up request
24482
+ request = null;
24483
+ };
24484
+
24485
+ // Handle low level network errors
24486
+ request.onerror = function handleError() {
24487
+ // Real errors are hidden from us by the browser
24488
+ // onerror should only fire if it's a network error
24489
+ reject(createError('Network Error', config, null, request));
24490
+
24491
+ // Clean up request
24492
+ request = null;
24493
+ };
24494
+
24495
+ // Handle timeout
24496
+ request.ontimeout = function handleTimeout() {
24497
+ var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
24498
+ var transitional = config.transitional || defaults_1.transitional;
24499
+ if (config.timeoutErrorMessage) {
24500
+ timeoutErrorMessage = config.timeoutErrorMessage;
24501
+ }
24502
+ reject(createError(
24503
+ timeoutErrorMessage,
24504
+ config,
24505
+ transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
24506
+ request));
24507
+
24508
+ // Clean up request
24509
+ request = null;
24510
+ };
24511
+
24512
+ // Add xsrf header
24513
+ // This is only done if running in a standard browser environment.
24514
+ // Specifically not if we're in a web worker, or react-native.
24515
+ if (utils.isStandardBrowserEnv()) {
24516
+ // Add xsrf header
24517
+ var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
24518
+ cookies.read(config.xsrfCookieName) :
24519
+ undefined;
24520
+
24521
+ if (xsrfValue) {
24522
+ requestHeaders[config.xsrfHeaderName] = xsrfValue;
24523
+ }
24524
+ }
24525
+
24526
+ // Add headers to the request
24527
+ if ('setRequestHeader' in request) {
24528
+ utils.forEach(requestHeaders, function setRequestHeader(val, key) {
24529
+ if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
24530
+ // Remove Content-Type if data is undefined
24531
+ delete requestHeaders[key];
24532
+ } else {
24533
+ // Otherwise add header to the request
24534
+ request.setRequestHeader(key, val);
24535
+ }
24536
+ });
24537
+ }
24538
+
24539
+ // Add withCredentials to request if needed
24540
+ if (!utils.isUndefined(config.withCredentials)) {
24541
+ request.withCredentials = !!config.withCredentials;
24542
+ }
24543
+
24544
+ // Add responseType to request if needed
24545
+ if (responseType && responseType !== 'json') {
24546
+ request.responseType = config.responseType;
24547
+ }
24548
+
24549
+ // Handle progress if needed
24550
+ if (typeof config.onDownloadProgress === 'function') {
24551
+ request.addEventListener('progress', config.onDownloadProgress);
24552
+ }
24553
+
24554
+ // Not all browsers support upload events
24555
+ if (typeof config.onUploadProgress === 'function' && request.upload) {
24556
+ request.upload.addEventListener('progress', config.onUploadProgress);
24557
+ }
24558
+
24559
+ if (config.cancelToken || config.signal) {
24560
+ // Handle cancellation
24561
+ // eslint-disable-next-line func-names
24562
+ onCanceled = function(cancel) {
24563
+ if (!request) {
24564
+ return;
24565
+ }
24566
+ reject(!cancel || (cancel && cancel.type) ? new Cancel_1('canceled') : cancel);
24567
+ request.abort();
24568
+ request = null;
24569
+ };
24570
+
24571
+ config.cancelToken && config.cancelToken.subscribe(onCanceled);
24572
+ if (config.signal) {
24573
+ config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
24574
+ }
24575
+ }
24576
+
24577
+ if (!requestData) {
24578
+ requestData = null;
24579
+ }
24580
+
24581
+ // Send the request
24582
+ request.send(requestData);
24583
+ });
24584
+ };
24585
+
24586
+ var DEFAULT_CONTENT_TYPE = {
24587
+ 'Content-Type': 'application/x-www-form-urlencoded'
24588
+ };
24589
+
24590
+ function setContentTypeIfUnset(headers, value) {
24591
+ if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
24592
+ headers['Content-Type'] = value;
24593
+ }
24594
+ }
24595
+
24596
+ function getDefaultAdapter() {
24597
+ var adapter;
24598
+ if (typeof XMLHttpRequest !== 'undefined') {
24599
+ // For browsers use XHR adapter
24600
+ adapter = xhr;
24601
+ } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
24602
+ // For node use HTTP adapter
24603
+ adapter = xhr;
24604
+ }
24605
+ return adapter;
24606
+ }
24607
+
24608
+ function stringifySafely(rawValue, parser, encoder) {
24609
+ if (utils.isString(rawValue)) {
24610
+ try {
24611
+ (parser || JSON.parse)(rawValue);
24612
+ return utils.trim(rawValue);
24613
+ } catch (e) {
24614
+ if (e.name !== 'SyntaxError') {
24615
+ throw e;
24616
+ }
24617
+ }
24618
+ }
24619
+
24620
+ return (encoder || JSON.stringify)(rawValue);
24621
+ }
24622
+
24623
+ var defaults = {
24624
+
24625
+ transitional: {
24626
+ silentJSONParsing: true,
24627
+ forcedJSONParsing: true,
24628
+ clarifyTimeoutError: false
24629
+ },
24630
+
24631
+ adapter: getDefaultAdapter(),
24632
+
24633
+ transformRequest: [function transformRequest(data, headers) {
24634
+ normalizeHeaderName(headers, 'Accept');
24635
+ normalizeHeaderName(headers, 'Content-Type');
24636
+
24637
+ if (utils.isFormData(data) ||
24638
+ utils.isArrayBuffer(data) ||
24639
+ utils.isBuffer(data) ||
24640
+ utils.isStream(data) ||
24641
+ utils.isFile(data) ||
24642
+ utils.isBlob(data)
24643
+ ) {
24644
+ return data;
24645
+ }
24646
+ if (utils.isArrayBufferView(data)) {
24647
+ return data.buffer;
24648
+ }
24649
+ if (utils.isURLSearchParams(data)) {
24650
+ setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
24651
+ return data.toString();
24652
+ }
24653
+ if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
24654
+ setContentTypeIfUnset(headers, 'application/json');
24655
+ return stringifySafely(data);
24656
+ }
24657
+ return data;
24658
+ }],
24659
+
24660
+ transformResponse: [function transformResponse(data) {
24661
+ var transitional = this.transitional || defaults.transitional;
24662
+ var silentJSONParsing = transitional && transitional.silentJSONParsing;
24663
+ var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
24664
+ var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
24665
+
24666
+ if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {
24667
+ try {
24668
+ return JSON.parse(data);
24669
+ } catch (e) {
24670
+ if (strictJSONParsing) {
24671
+ if (e.name === 'SyntaxError') {
24672
+ throw enhanceError(e, this, 'E_JSON_PARSE');
24673
+ }
24674
+ throw e;
24675
+ }
24676
+ }
24677
+ }
24678
+
24679
+ return data;
24680
+ }],
24681
+
24682
+ /**
24683
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
24684
+ * timeout is not created.
24685
+ */
24686
+ timeout: 0,
24687
+
24688
+ xsrfCookieName: 'XSRF-TOKEN',
24689
+ xsrfHeaderName: 'X-XSRF-TOKEN',
24690
+
24691
+ maxContentLength: -1,
24692
+ maxBodyLength: -1,
24693
+
24694
+ validateStatus: function validateStatus(status) {
24695
+ return status >= 200 && status < 300;
24696
+ },
24697
+
24698
+ headers: {
24699
+ common: {
24700
+ 'Accept': 'application/json, text/plain, */*'
24701
+ }
24702
+ }
24703
+ };
24704
+
24705
+ utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
24706
+ defaults.headers[method] = {};
24707
+ });
24708
+
24709
+ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
24710
+ defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
24711
+ });
24712
+
24713
+ var defaults_1 = defaults;
24714
+
24715
+ /**
24716
+ * Transform the data for a request or a response
24717
+ *
24718
+ * @param {Object|String} data The data to be transformed
24719
+ * @param {Array} headers The headers for the request or response
24720
+ * @param {Array|Function} fns A single function or Array of functions
24721
+ * @returns {*} The resulting transformed data
24722
+ */
24723
+ var transformData = function transformData(data, headers, fns) {
24724
+ var context = this || defaults_1;
24725
+ /*eslint no-param-reassign:0*/
24726
+ utils.forEach(fns, function transform(fn) {
24727
+ data = fn.call(context, data, headers);
24728
+ });
24729
+
24730
+ return data;
24731
+ };
24732
+
24733
+ var isCancel = function isCancel(value) {
24734
+ return !!(value && value.__CANCEL__);
24735
+ };
24736
+
24737
+ /**
24738
+ * Throws a `Cancel` if cancellation has been requested.
24739
+ */
24740
+ function throwIfCancellationRequested(config) {
24741
+ if (config.cancelToken) {
24742
+ config.cancelToken.throwIfRequested();
24743
+ }
24744
+
24745
+ if (config.signal && config.signal.aborted) {
24746
+ throw new Cancel_1('canceled');
24747
+ }
24748
+ }
24749
+
24750
+ /**
24751
+ * Dispatch a request to the server using the configured adapter.
24752
+ *
24753
+ * @param {object} config The config that is to be used for the request
24754
+ * @returns {Promise} The Promise to be fulfilled
24755
+ */
24756
+ var dispatchRequest = function dispatchRequest(config) {
24757
+ throwIfCancellationRequested(config);
24758
+
24759
+ // Ensure headers exist
24760
+ config.headers = config.headers || {};
24761
+
24762
+ // Transform request data
24763
+ config.data = transformData.call(
24764
+ config,
24765
+ config.data,
24766
+ config.headers,
24767
+ config.transformRequest
24768
+ );
24769
+
24770
+ // Flatten headers
24771
+ config.headers = utils.merge(
24772
+ config.headers.common || {},
24773
+ config.headers[config.method] || {},
24774
+ config.headers
24775
+ );
24776
+
24777
+ utils.forEach(
24778
+ ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
24779
+ function cleanHeaderConfig(method) {
24780
+ delete config.headers[method];
24781
+ }
24782
+ );
24783
+
24784
+ var adapter = config.adapter || defaults_1.adapter;
24785
+
24786
+ return adapter(config).then(function onAdapterResolution(response) {
24787
+ throwIfCancellationRequested(config);
24788
+
24789
+ // Transform response data
24790
+ response.data = transformData.call(
24791
+ config,
24792
+ response.data,
24793
+ response.headers,
24794
+ config.transformResponse
24795
+ );
24796
+
24797
+ return response;
24798
+ }, function onAdapterRejection(reason) {
24799
+ if (!isCancel(reason)) {
24800
+ throwIfCancellationRequested(config);
24801
+
24802
+ // Transform response data
24803
+ if (reason && reason.response) {
24804
+ reason.response.data = transformData.call(
24805
+ config,
24806
+ reason.response.data,
24807
+ reason.response.headers,
24808
+ config.transformResponse
24809
+ );
24810
+ }
24811
+ }
24812
+
24813
+ return Promise.reject(reason);
24814
+ });
24815
+ };
24816
+
24817
+ /**
24818
+ * Config-specific merge-function which creates a new config-object
24819
+ * by merging two configuration objects together.
24820
+ *
24821
+ * @param {Object} config1
24822
+ * @param {Object} config2
24823
+ * @returns {Object} New object resulting from merging config2 to config1
24824
+ */
24825
+ var mergeConfig = function mergeConfig(config1, config2) {
24826
+ // eslint-disable-next-line no-param-reassign
24827
+ config2 = config2 || {};
24828
+ var config = {};
24829
+
24830
+ function getMergedValue(target, source) {
24831
+ if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
24832
+ return utils.merge(target, source);
24833
+ } else if (utils.isPlainObject(source)) {
24834
+ return utils.merge({}, source);
24835
+ } else if (utils.isArray(source)) {
24836
+ return source.slice();
24837
+ }
24838
+ return source;
24839
+ }
24840
+
24841
+ // eslint-disable-next-line consistent-return
24842
+ function mergeDeepProperties(prop) {
24843
+ if (!utils.isUndefined(config2[prop])) {
24844
+ return getMergedValue(config1[prop], config2[prop]);
24845
+ } else if (!utils.isUndefined(config1[prop])) {
24846
+ return getMergedValue(undefined, config1[prop]);
24847
+ }
24848
+ }
24849
+
24850
+ // eslint-disable-next-line consistent-return
24851
+ function valueFromConfig2(prop) {
24852
+ if (!utils.isUndefined(config2[prop])) {
24853
+ return getMergedValue(undefined, config2[prop]);
24854
+ }
24855
+ }
24856
+
24857
+ // eslint-disable-next-line consistent-return
24858
+ function defaultToConfig2(prop) {
24859
+ if (!utils.isUndefined(config2[prop])) {
24860
+ return getMergedValue(undefined, config2[prop]);
24861
+ } else if (!utils.isUndefined(config1[prop])) {
24862
+ return getMergedValue(undefined, config1[prop]);
24863
+ }
24864
+ }
24865
+
24866
+ // eslint-disable-next-line consistent-return
24867
+ function mergeDirectKeys(prop) {
24868
+ if (prop in config2) {
24869
+ return getMergedValue(config1[prop], config2[prop]);
24870
+ } else if (prop in config1) {
24871
+ return getMergedValue(undefined, config1[prop]);
24872
+ }
24873
+ }
24874
+
24875
+ var mergeMap = {
24876
+ 'url': valueFromConfig2,
24877
+ 'method': valueFromConfig2,
24878
+ 'data': valueFromConfig2,
24879
+ 'baseURL': defaultToConfig2,
24880
+ 'transformRequest': defaultToConfig2,
24881
+ 'transformResponse': defaultToConfig2,
24882
+ 'paramsSerializer': defaultToConfig2,
24883
+ 'timeout': defaultToConfig2,
24884
+ 'timeoutMessage': defaultToConfig2,
24885
+ 'withCredentials': defaultToConfig2,
24886
+ 'adapter': defaultToConfig2,
24887
+ 'responseType': defaultToConfig2,
24888
+ 'xsrfCookieName': defaultToConfig2,
24889
+ 'xsrfHeaderName': defaultToConfig2,
24890
+ 'onUploadProgress': defaultToConfig2,
24891
+ 'onDownloadProgress': defaultToConfig2,
24892
+ 'decompress': defaultToConfig2,
24893
+ 'maxContentLength': defaultToConfig2,
24894
+ 'maxBodyLength': defaultToConfig2,
24895
+ 'transport': defaultToConfig2,
24896
+ 'httpAgent': defaultToConfig2,
24897
+ 'httpsAgent': defaultToConfig2,
24898
+ 'cancelToken': defaultToConfig2,
24899
+ 'socketPath': defaultToConfig2,
24900
+ 'responseEncoding': defaultToConfig2,
24901
+ 'validateStatus': mergeDirectKeys
24902
+ };
24903
+
24904
+ utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
24905
+ var merge = mergeMap[prop] || mergeDeepProperties;
24906
+ var configValue = merge(prop);
24907
+ (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
24908
+ });
24909
+
24910
+ return config;
24911
+ };
24912
+
24913
+ var data$1 = {
24914
+ "version": "0.23.0"
24915
+ };
24916
+
24917
+ var VERSION = data$1.version;
24918
+
24919
+ var validators$1 = {};
24920
+
24921
+ // eslint-disable-next-line func-names
24922
+ ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
24923
+ validators$1[type] = function validator(thing) {
24924
+ return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
24925
+ };
24926
+ });
24927
+
24928
+ var deprecatedWarnings = {};
24929
+
24930
+ /**
24931
+ * Transitional option validator
24932
+ * @param {function|boolean?} validator - set to false if the transitional option has been removed
24933
+ * @param {string?} version - deprecated version / removed since version
24934
+ * @param {string?} message - some message with additional info
24935
+ * @returns {function}
24936
+ */
24937
+ validators$1.transitional = function transitional(validator, version, message) {
24938
+ function formatMessage(opt, desc) {
24939
+ return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
24940
+ }
24941
+
24942
+ // eslint-disable-next-line func-names
24943
+ return function(value, opt, opts) {
24944
+ if (validator === false) {
24945
+ throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')));
24946
+ }
24947
+
24948
+ if (version && !deprecatedWarnings[opt]) {
24949
+ deprecatedWarnings[opt] = true;
24950
+ // eslint-disable-next-line no-console
24951
+ console.warn(
24952
+ formatMessage(
24953
+ opt,
24954
+ ' has been deprecated since v' + version + ' and will be removed in the near future'
24955
+ )
24956
+ );
24957
+ }
24958
+
24959
+ return validator ? validator(value, opt, opts) : true;
24960
+ };
24961
+ };
24962
+
24963
+ /**
24964
+ * Assert object's properties type
24965
+ * @param {object} options
24966
+ * @param {object} schema
24967
+ * @param {boolean?} allowUnknown
24968
+ */
24969
+
24970
+ function assertOptions(options, schema, allowUnknown) {
24971
+ if (typeof options !== 'object') {
24972
+ throw new TypeError('options must be an object');
24973
+ }
24974
+ var keys = Object.keys(options);
24975
+ var i = keys.length;
24976
+ while (i-- > 0) {
24977
+ var opt = keys[i];
24978
+ var validator = schema[opt];
24979
+ if (validator) {
24980
+ var value = options[opt];
24981
+ var result = value === undefined || validator(value, opt, options);
24982
+ if (result !== true) {
24983
+ throw new TypeError('option ' + opt + ' must be ' + result);
24984
+ }
24985
+ continue;
24986
+ }
24987
+ if (allowUnknown !== true) {
24988
+ throw Error('Unknown option ' + opt);
24989
+ }
24990
+ }
24991
+ }
24992
+
24993
+ var validator = {
24994
+ assertOptions: assertOptions,
24995
+ validators: validators$1
24996
+ };
24997
+
24998
+ var validators = validator.validators;
24999
+ /**
25000
+ * Create a new instance of Axios
25001
+ *
25002
+ * @param {Object} instanceConfig The default config for the instance
25003
+ */
25004
+ function Axios(instanceConfig) {
25005
+ this.defaults = instanceConfig;
25006
+ this.interceptors = {
25007
+ request: new InterceptorManager_1(),
25008
+ response: new InterceptorManager_1()
25009
+ };
25010
+ }
25011
+
25012
+ /**
25013
+ * Dispatch a request
25014
+ *
25015
+ * @param {Object} config The config specific for this request (merged with this.defaults)
25016
+ */
25017
+ Axios.prototype.request = function request(config) {
25018
+ /*eslint no-param-reassign:0*/
25019
+ // Allow for axios('example/url'[, config]) a la fetch API
25020
+ if (typeof config === 'string') {
25021
+ config = arguments[1] || {};
25022
+ config.url = arguments[0];
25023
+ } else {
25024
+ config = config || {};
25025
+ }
25026
+
25027
+ config = mergeConfig(this.defaults, config);
25028
+
25029
+ // Set config.method
25030
+ if (config.method) {
25031
+ config.method = config.method.toLowerCase();
25032
+ } else if (this.defaults.method) {
25033
+ config.method = this.defaults.method.toLowerCase();
25034
+ } else {
25035
+ config.method = 'get';
25036
+ }
25037
+
25038
+ var transitional = config.transitional;
25039
+
25040
+ if (transitional !== undefined) {
25041
+ validator.assertOptions(transitional, {
25042
+ silentJSONParsing: validators.transitional(validators.boolean),
25043
+ forcedJSONParsing: validators.transitional(validators.boolean),
25044
+ clarifyTimeoutError: validators.transitional(validators.boolean)
25045
+ }, false);
25046
+ }
25047
+
25048
+ // filter out skipped interceptors
25049
+ var requestInterceptorChain = [];
25050
+ var synchronousRequestInterceptors = true;
25051
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
25052
+ if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
25053
+ return;
25054
+ }
25055
+
25056
+ synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
25057
+
25058
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
25059
+ });
25060
+
25061
+ var responseInterceptorChain = [];
25062
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
25063
+ responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
25064
+ });
25065
+
25066
+ var promise;
25067
+
25068
+ if (!synchronousRequestInterceptors) {
25069
+ var chain = [dispatchRequest, undefined];
25070
+
25071
+ Array.prototype.unshift.apply(chain, requestInterceptorChain);
25072
+ chain = chain.concat(responseInterceptorChain);
25073
+
25074
+ promise = Promise.resolve(config);
25075
+ while (chain.length) {
25076
+ promise = promise.then(chain.shift(), chain.shift());
25077
+ }
25078
+
25079
+ return promise;
25080
+ }
25081
+
25082
+
25083
+ var newConfig = config;
25084
+ while (requestInterceptorChain.length) {
25085
+ var onFulfilled = requestInterceptorChain.shift();
25086
+ var onRejected = requestInterceptorChain.shift();
25087
+ try {
25088
+ newConfig = onFulfilled(newConfig);
25089
+ } catch (error) {
25090
+ onRejected(error);
25091
+ break;
25092
+ }
25093
+ }
25094
+
25095
+ try {
25096
+ promise = dispatchRequest(newConfig);
25097
+ } catch (error) {
25098
+ return Promise.reject(error);
25099
+ }
25100
+
25101
+ while (responseInterceptorChain.length) {
25102
+ promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
25103
+ }
25104
+
25105
+ return promise;
25106
+ };
25107
+
25108
+ Axios.prototype.getUri = function getUri(config) {
25109
+ config = mergeConfig(this.defaults, config);
25110
+ return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
25111
+ };
25112
+
25113
+ // Provide aliases for supported request methods
25114
+ utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
25115
+ /*eslint func-names:0*/
25116
+ Axios.prototype[method] = function(url, config) {
25117
+ return this.request(mergeConfig(config || {}, {
25118
+ method: method,
25119
+ url: url,
25120
+ data: (config || {}).data
25121
+ }));
25122
+ };
25123
+ });
25124
+
25125
+ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
25126
+ /*eslint func-names:0*/
25127
+ Axios.prototype[method] = function(url, data, config) {
25128
+ return this.request(mergeConfig(config || {}, {
25129
+ method: method,
25130
+ url: url,
25131
+ data: data
25132
+ }));
25133
+ };
25134
+ });
25135
+
25136
+ var Axios_1 = Axios;
25137
+
25138
+ /**
25139
+ * A `CancelToken` is an object that can be used to request cancellation of an operation.
25140
+ *
25141
+ * @class
25142
+ * @param {Function} executor The executor function.
25143
+ */
25144
+ function CancelToken(executor) {
25145
+ if (typeof executor !== 'function') {
25146
+ throw new TypeError('executor must be a function.');
25147
+ }
25148
+
25149
+ var resolvePromise;
25150
+
25151
+ this.promise = new Promise(function promiseExecutor(resolve) {
25152
+ resolvePromise = resolve;
25153
+ });
25154
+
25155
+ var token = this;
25156
+
25157
+ // eslint-disable-next-line func-names
25158
+ this.promise.then(function(cancel) {
25159
+ if (!token._listeners) return;
25160
+
25161
+ var i;
25162
+ var l = token._listeners.length;
25163
+
25164
+ for (i = 0; i < l; i++) {
25165
+ token._listeners[i](cancel);
25166
+ }
25167
+ token._listeners = null;
25168
+ });
25169
+
25170
+ // eslint-disable-next-line func-names
25171
+ this.promise.then = function(onfulfilled) {
25172
+ var _resolve;
25173
+ // eslint-disable-next-line func-names
25174
+ var promise = new Promise(function(resolve) {
25175
+ token.subscribe(resolve);
25176
+ _resolve = resolve;
25177
+ }).then(onfulfilled);
25178
+
25179
+ promise.cancel = function reject() {
25180
+ token.unsubscribe(_resolve);
25181
+ };
25182
+
25183
+ return promise;
25184
+ };
25185
+
25186
+ executor(function cancel(message) {
25187
+ if (token.reason) {
25188
+ // Cancellation has already been requested
25189
+ return;
25190
+ }
25191
+
25192
+ token.reason = new Cancel_1(message);
25193
+ resolvePromise(token.reason);
25194
+ });
25195
+ }
25196
+
25197
+ /**
25198
+ * Throws a `Cancel` if cancellation has been requested.
25199
+ */
25200
+ CancelToken.prototype.throwIfRequested = function throwIfRequested() {
25201
+ if (this.reason) {
25202
+ throw this.reason;
25203
+ }
25204
+ };
25205
+
25206
+ /**
25207
+ * Subscribe to the cancel signal
25208
+ */
25209
+
25210
+ CancelToken.prototype.subscribe = function subscribe(listener) {
25211
+ if (this.reason) {
25212
+ listener(this.reason);
25213
+ return;
25214
+ }
25215
+
25216
+ if (this._listeners) {
25217
+ this._listeners.push(listener);
25218
+ } else {
25219
+ this._listeners = [listener];
25220
+ }
25221
+ };
25222
+
25223
+ /**
25224
+ * Unsubscribe from the cancel signal
25225
+ */
25226
+
25227
+ CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
25228
+ if (!this._listeners) {
25229
+ return;
25230
+ }
25231
+ var index = this._listeners.indexOf(listener);
25232
+ if (index !== -1) {
25233
+ this._listeners.splice(index, 1);
25234
+ }
25235
+ };
25236
+
25237
+ /**
25238
+ * Returns an object that contains a new `CancelToken` and a function that, when called,
25239
+ * cancels the `CancelToken`.
25240
+ */
25241
+ CancelToken.source = function source() {
25242
+ var cancel;
25243
+ var token = new CancelToken(function executor(c) {
25244
+ cancel = c;
25245
+ });
25246
+ return {
25247
+ token: token,
25248
+ cancel: cancel
25249
+ };
25250
+ };
25251
+
25252
+ var CancelToken_1 = CancelToken;
25253
+
25254
+ /**
25255
+ * Syntactic sugar for invoking a function and expanding an array for arguments.
25256
+ *
25257
+ * Common use case would be to use `Function.prototype.apply`.
25258
+ *
25259
+ * ```js
25260
+ * function f(x, y, z) {}
25261
+ * var args = [1, 2, 3];
25262
+ * f.apply(null, args);
25263
+ * ```
25264
+ *
25265
+ * With `spread` this example can be re-written.
25266
+ *
25267
+ * ```js
25268
+ * spread(function(x, y, z) {})([1, 2, 3]);
25269
+ * ```
25270
+ *
25271
+ * @param {Function} callback
25272
+ * @returns {Function}
25273
+ */
25274
+ var spread = function spread(callback) {
25275
+ return function wrap(arr) {
25276
+ return callback.apply(null, arr);
25277
+ };
25278
+ };
25279
+
25280
+ /**
25281
+ * Determines whether the payload is an error thrown by Axios
25282
+ *
25283
+ * @param {*} payload The value to test
25284
+ * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
25285
+ */
25286
+ var isAxiosError = function isAxiosError(payload) {
25287
+ return (typeof payload === 'object') && (payload.isAxiosError === true);
25288
+ };
25289
+
25290
+ /**
25291
+ * Create an instance of Axios
25292
+ *
25293
+ * @param {Object} defaultConfig The default config for the instance
25294
+ * @return {Axios} A new instance of Axios
25295
+ */
25296
+ function createInstance(defaultConfig) {
25297
+ var context = new Axios_1(defaultConfig);
25298
+ var instance = bind(Axios_1.prototype.request, context);
25299
+
25300
+ // Copy axios.prototype to instance
25301
+ utils.extend(instance, Axios_1.prototype, context);
25302
+
25303
+ // Copy context to instance
25304
+ utils.extend(instance, context);
25305
+
25306
+ // Factory for creating new instances
25307
+ instance.create = function create(instanceConfig) {
25308
+ return createInstance(mergeConfig(defaultConfig, instanceConfig));
25309
+ };
25310
+
25311
+ return instance;
25312
+ }
25313
+
25314
+ // Create the default instance to be exported
25315
+ var axios$1 = createInstance(defaults_1);
25316
+
25317
+ // Expose Axios class to allow class inheritance
25318
+ axios$1.Axios = Axios_1;
25319
+
25320
+ // Expose Cancel & CancelToken
25321
+ axios$1.Cancel = Cancel_1;
25322
+ axios$1.CancelToken = CancelToken_1;
25323
+ axios$1.isCancel = isCancel;
25324
+ axios$1.VERSION = data$1.version;
25325
+
25326
+ // Expose all/spread
25327
+ axios$1.all = function all(promises) {
25328
+ return Promise.all(promises);
25329
+ };
25330
+ axios$1.spread = spread;
25331
+
25332
+ // Expose isAxiosError
25333
+ axios$1.isAxiosError = isAxiosError;
25334
+
25335
+ var axios_1 = axios$1;
25336
+
25337
+ // Allow use of default import syntax in TypeScript
25338
+ var _default = axios$1;
25339
+ axios_1.default = _default;
25340
+
25341
+ var axios = axios_1;
25342
+
25343
+ const Http = {
25344
+ request(method, url, data, successCb = null, errorCb = null) {
25345
+ return axios
25346
+ .request({url, data, method: method.toLowerCase(), responseType: 'json'})
25347
+ .then(successCb)
25348
+ .catch(errorCb);
25349
+ },
25350
+
25351
+ get(url, successCb = null, errorCb = null, data) {
25352
+ // return this.request('get', url, data, successCb, errorCb);
25353
+ return axios
25354
+ .get(url, {params: data})
25355
+ .then(successCb)
25356
+ .catch(errorCb);
25357
+ },
25358
+
25359
+ post(url, data, successCb = null, errorCb = null) {
25360
+ return this.request('post', url, data, successCb, errorCb);
25361
+ },
25362
+
25363
+ put(url, data, successCb = null, errorCb = null) {
25364
+ return this.request('put', url, data, successCb, errorCb);
25365
+ },
25366
+
25367
+ delete(url, data, successCb = null, errorCb = null) {
25368
+ return this.request('delete', url, data, successCb, errorCb);
25369
+ },
25370
+
25371
+ requestWithSupportAjax(url, payload, method = 'post') {
25372
+ return new Promise((resolve, reject) => {
25373
+ if (!window?.isLegacyTheme) {
25374
+ return this.request(method, url, payload, ({data}) => {
25375
+ return resolve(data);
25376
+ }, ({response}) => {
25377
+ return reject(response);
25378
+ })
25379
+ }
25380
+
25381
+ /**
25382
+ * @deprecated to support legacy themes
25383
+ */
25384
+ $.ajax({
25385
+ url: url,
25386
+ method: method.toUpperCase(),
25387
+ data: payload,
25388
+ async: false,
25389
+ success: function ({data}) {
25390
+ return resolve(data);
25391
+ },
25392
+ error: function ({response}) {
25393
+ return reject(response);
25394
+ }
25395
+ });
25396
+ })
25397
+ }
25398
+ };
25399
+
25400
+ const DetectOS = {
25401
+ options: [],
25402
+ header: [navigator.platform, navigator.userAgent, navigator.appVersion, navigator.vendor, window.opera],
25403
+ dataos: [
25404
+ {name: 'Windows Phone', value: 'Windows Phone', version: 'OS'},
25405
+ {name: 'Windows', value: 'Win', version: 'NT'},
25406
+ {name: 'iPhone', value: 'iPhone', version: 'OS'},
25407
+ {name: 'iPad', value: 'iPad', version: 'OS'},
25408
+ {name: 'Kindle', value: 'Silk', version: 'Silk'},
25409
+ {name: 'Android', value: 'Android', version: 'Android'},
25410
+ {name: 'PlayBook', value: 'PlayBook', version: 'OS'},
25411
+ {name: 'BlackBerry', value: 'BlackBerry', version: '/'},
25412
+ {name: 'Macintosh', value: 'Mac', version: 'OS X'},
25413
+ {name: 'Linux', value: 'Linux', version: 'rv'},
25414
+ {name: 'Palm', value: 'Palm', version: 'PalmOS'}
25415
+ ],
25416
+ databrowser: [
25417
+ {name: 'Chrome', value: 'Chrome', version: 'Chrome'},
25418
+ {name: 'Firefox', value: 'Firefox', version: 'Firefox'},
25419
+ {name: 'Safari', value: 'Safari', version: 'Version'},
25420
+ {name: 'Internet Explorer', value: 'MSIE', version: 'MSIE'},
25421
+ {name: 'Opera', value: 'Opera', version: 'Opera'},
25422
+ {name: 'BlackBerry', value: 'CLDC', version: 'CLDC'},
25423
+ {name: 'Mozilla', value: 'Mozilla', version: 'Mozilla'}
25424
+ ],
25425
+ init: function () {
25426
+ var agent = this.header.join(' '),
25427
+ os = this.matchItem(agent, this.dataos),
25428
+ browser = this.matchItem(agent, this.databrowser);
25429
+
25430
+ return {os: os, browser: browser};
25431
+ },
25432
+ matchItem: function (string, data) {
25433
+ var i = 0,
25434
+ j = 0,
25435
+ regex,
25436
+ regexv,
25437
+ match,
25438
+ matches,
25439
+ version;
25440
+
25441
+ for (i = 0; i < data.length; i += 1) {
25442
+ regex = new RegExp(data[i].value, 'i');
25443
+ match = regex.test(string);
25444
+ if (match) {
25445
+ regexv = new RegExp(data[i].version + '[- /:;]([\\d._]+)', 'i');
25446
+ matches = string.match(regexv);
25447
+ version = '';
25448
+ if (matches) {
25449
+ if (matches[1]) {
25450
+ matches = matches[1];
25451
+ }
25452
+ }
25453
+ if (matches) {
25454
+ matches = matches.split(/[._]+/);
25455
+ for (j = 0; j < matches.length; j += 1) {
25456
+ if (j === 0) {
25457
+ version += matches[j] + '.';
25458
+ } else {
25459
+ version += matches[j];
25460
+ }
25461
+ }
25462
+ } else {
25463
+ version = '0';
25464
+ }
25465
+ return {
25466
+ name: data[i].name,
25467
+ version: parseFloat(version)
25468
+ };
25469
+ }
25470
+ }
25471
+ return {name: 'unknown', version: 0};
25472
+ }
25473
+ };
25474
+
25475
+ window.Salla = window.Salla || {};
25476
+ window.Salla.Payments = window.Salla.Payments || {};
25477
+
25478
+ /**
25479
+ * Full Example
25480
+ *
25481
+ * Salla.event.createAndDispatch('payments::apple-pay.start-transaction', {
25482
+ * amount: 1000,
25483
+ * validateMerchant: {
25484
+ * url: '{{ route('cp.marketplace.cart.pay', ['cart' => $cart]) }}',
25485
+ * // onFailed: (response) => {
25486
+ * // laravel.ajax.errorHandler(response);
25487
+ * // this.onCancel({}, response.data.error.message);
25488
+ * // },
25489
+ * // onSuccess: (response) => {
25490
+ * // laravel.ajax.successHandler(response);
25491
+ * // }
25492
+ * },
25493
+ * authorized: {
25494
+ * url: '{{ route('cp.marketplace.cart.confirm', ['cart' => $cart]) }}',
25495
+ * // onFailed: (response) => {
25496
+ * // laravel.ajax.errorHandler(response);
25497
+ * // this.onCancel({}, response.data.error.message);
25498
+ * // },
25499
+ * // onSuccess: (response) => {
25500
+ * // // nothing
25501
+ * // }
25502
+ * },
25503
+ * // onError: function (message) {
25504
+ * // laravel.alert(message);
25505
+ * // }
25506
+ * });
25507
+ */
25508
+ window.SallaApplePay = {
25509
+ session: null,
25510
+ detail: null,
25511
+ address_id: null,
25512
+ shipping_methods: [],
25513
+ total: undefined,
25514
+ request: undefined,
25515
+ id: undefined,
25516
+ init: function () {
25517
+ document.removeEventListener('payments::apple-pay.start-transaction', SallaApplePay.startSession);
25518
+ Salla.event.addEventListener('payments::apple-pay.start-transaction', SallaApplePay.startSession);
25519
+ },
25520
+
25521
+ initDefault: function () {
25522
+ if (!SallaApplePay.detail.onError) {
25523
+ SallaApplePay.detail.onError = function (message) {
25524
+ salla.notify.error(message);
25525
+ };
25526
+ }
25527
+
25528
+ if (!SallaApplePay.detail.authorized.onFailed) {
25529
+ SallaApplePay.detail.authorized.onFailed = (response) => {
25530
+ salla.logger.log(JSON.stringify(response));
25531
+ salla.api.handleErrorResponse(response);
25532
+ SallaApplePay.onCancel({}, response.data.error.message);
25533
+ };
25534
+ }
25535
+
25536
+ if (!SallaApplePay.detail.validateMerchant.onFailed) {
25537
+ SallaApplePay.detail.validateMerchant.onFailed = (response) => {
25538
+ salla.logger.log(JSON.stringify(response));
25539
+ salla.api.handleErrorResponse(response);
25540
+ SallaApplePay.onCancel({}, response.data.error.message);
25541
+ };
25542
+ }
25543
+
25544
+ if (!SallaApplePay.detail.authorized.onSuccess) {
25545
+ SallaApplePay.detail.authorized.onSuccess = (response) => {
25546
+ salla.logger.log(JSON.stringify(response));
25547
+ salla.api.handleAfterResponseActions(response);
25548
+ };
25549
+ }
25550
+ },
25551
+
25552
+ prepareLineItems: function () {
25553
+ if(!SallaApplePay.detail?.items?.length){
25554
+ SallaApplePay.detail.items = [
25555
+ {
25556
+ label: salla.lang.get('pages.cart.items_total'),
25557
+ amount: SallaApplePay.detail.amount
25558
+ }
25559
+ ];
25560
+ }
25561
+
25562
+ return SallaApplePay.detail.items;
25563
+ },
25564
+
25565
+ prepareTotal: function () {
25566
+ return {
25567
+ // apple ask to use business name
25568
+ label: window.location.hostname || 'Salla',
25569
+ //label: salla.lang.get('pages.cart.final_total'),
25570
+ amount: SallaApplePay.detail.amount
25571
+ }
25572
+ },
25573
+
25574
+ startSession: async function (event) {
25575
+
25576
+ SallaApplePay.detail = event.detail || event;
25577
+
25578
+ salla.log('🍏 Pay: payments::apple-pay.start-transaction', SallaApplePay.detail);
25579
+
25580
+ SallaApplePay.initDefault();
25581
+
25582
+ let version = SallaApplePay.getApplePaySessionVersion();
25583
+ let supportedNetworks = SallaApplePay.detail.supportedNetworks || ['masterCard', 'visa'];
25584
+
25585
+ if (version === 5) {
25586
+ supportedNetworks.push('mada');
25587
+ }
25588
+
25589
+ SallaApplePay.request = {
25590
+ countryCode: 'SA',
25591
+ supportsCouponCode: true,
25592
+ couponCode: '',
25593
+ currencyCode: SallaApplePay.detail.currency || 'SAR',
25594
+ requiredShippingContactFields: SallaApplePay.detail.requiredShippingContactFields ? SallaApplePay.detail.requiredShippingContactFields : [],
25595
+ merchantCapabilities: ['supports3DS'],
25596
+ supportedNetworks: supportedNetworks,
25597
+ supportedCountries: SallaApplePay.detail.supportedCountries || ['SA'],
25598
+ total: SallaApplePay.prepareTotal(),
25599
+ shippingContact: SallaApplePay.detail.shippingContact ? SallaApplePay.detail.shippingContact : {},
25600
+ shippingMethods: SallaApplePay.detail.shippingMethods && SallaApplePay.detail.shippingMethods.length ? SallaApplePay.mappingShippingMethods(event.detail.shippingMethods) : [],
25601
+ lineItems: SallaApplePay.prepareLineItems()
25602
+ };
25603
+
25604
+ salla.log('🍏 Pay: init ', SallaApplePay.request);
25605
+
25606
+ // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentrequest
25607
+ SallaApplePay.session = new ApplePaySession(version, SallaApplePay.request);
25608
+
25609
+ SallaApplePay.session.onshippingcontactselected = SallaApplePay.onShippingContactSelected;
25610
+ SallaApplePay.session.onshippingmethodselected = SallaApplePay.onShippingMethodSelected;
25611
+ SallaApplePay.session.onvalidatemerchant = SallaApplePay.onValidateMerchant;
25612
+ SallaApplePay.session.onpaymentauthorized = SallaApplePay.onPaymentAuthorized;
25613
+ SallaApplePay.session.oncancel = SallaApplePay.onCancel;
25614
+ SallaApplePay.session.oncouponcodechanged = SallaApplePay.oncouponcodechanged;
25615
+
25616
+ SallaApplePay.session.begin();
25617
+ },
25618
+
25619
+ oncouponcodechanged(event) {
25620
+ Salla.event.dispatch('payments::apple-pay.coupon.change', event);
25621
+
25622
+ return Http.post(SallaApplePay.detail.oncouponcodechanged.url.replace('{id}', SallaApplePay.id), {
25623
+ 'coupon': event.couponCode,
25624
+ 'payment_method': 'apple_pay',
25625
+ }, async ({data}) => {
25626
+ if (typeof SallaApplePay.detail.oncouponcodechanged.onSuccess === 'function') {
25627
+ SallaApplePay.detail.oncouponcodechanged.onSuccess(data);
25628
+ }
25629
+
25630
+ salla.log('🍏 Pay: Coupon applied success');
25631
+
25632
+ await SallaApplePay.recalculateTotal();
25633
+
25634
+ SallaApplePay.session.completeCouponCodeChange({
25635
+ newTotal: SallaApplePay.prepareTotal(),
25636
+ newLineItems: SallaApplePay.prepareLineItems()
25637
+ });
25638
+ }, async (error) => {
25639
+ let response = error?.response;
25640
+
25641
+ Salla.event.dispatch('payments::apple-pay.coupon.failed', response);
25642
+
25643
+ // SallaApplePay.abortSession();
25644
+ if (typeof SallaApplePay.detail.oncouponcodechanged.onFailed === 'function') {
25645
+ SallaApplePay.detail.oncouponcodechanged.onFailed(response);
25646
+ }
25647
+
25648
+ await SallaApplePay.recalculateTotal();
25649
+
25650
+ SallaApplePay.session.completeCouponCodeChange({
25651
+ newTotal: SallaApplePay.prepareTotal(),
25652
+ newLineItems: SallaApplePay.prepareLineItems(),
25653
+ errors: [new window.ApplePayError('couponCodeInvalid')]
25654
+ });
25655
+ });
25656
+ },
25657
+
25658
+ onCancel: (event = {}, message = null) => {
25659
+ SallaApplePay.detail.onError(message || salla.lang.get('pages.checkout.payment_failed'));
25660
+ Salla.event.createAndDispatch('payments::apple-pay.canceled', event);
25661
+ },
25662
+
25663
+ /**
25664
+ * Confirm payment after authorization.
25665
+ *
25666
+ * @param event
25667
+ */
25668
+ onPaymentAuthorized: (event) => {
25669
+ salla.logger.log('🍏 Pay: onPaymentAuthorized', event.payment);
25670
+
25671
+ Salla.event.dispatch('payments::apple-pay.authorized.init', event);
25672
+ Http.post(SallaApplePay.detail.authorized.url.replace('{id}', SallaApplePay.id), {
25673
+ payment_method: 'apple_pay',
25674
+ applepay_token: JSON.stringify(event.payment)
25675
+ }, ({data}) => {
25676
+ Salla.event.dispatch('payments::apple-pay.authorized.success', data);
25677
+
25678
+ SallaApplePay.session.completePayment(ApplePaySession.STATUS_SUCCESS);
25679
+
25680
+ if (typeof SallaApplePay.detail.authorized.onSuccess === 'function') {
25681
+ SallaApplePay.detail.authorized.onSuccess(data);
25682
+ }
25683
+ }, (error) => {
25684
+
25685
+ let response = error?.response;
25686
+
25687
+ Salla.event.dispatch('payments::apple-pay.authorized.failed', response);
25688
+
25689
+ SallaApplePay.session.completePayment({
25690
+ status: ApplePaySession.STATUS_FAILURE,
25691
+ errors: [new ApplePayError("unknown", undefined, response?.data?.error?.message || response?.data?.error?.code || 'Failed to parse authorized response')]
25692
+ });
25693
+
25694
+ if (typeof SallaApplePay.detail.authorized.onFailed === 'function') {
25695
+ SallaApplePay.detail.authorized.onFailed(response);
25696
+ }
25697
+ });
25698
+ },
25699
+
25700
+ /**
25701
+ * Validate Submit.
25702
+ *
25703
+ * @param event
25704
+ */
25705
+ onValidateMerchant: (event) => {
25706
+ Salla.event.dispatch('payments::apple-pay.validate-merchant.init', event);
25707
+
25708
+ Http.post(SallaApplePay.detail.validateMerchant.url.replace('{id}', SallaApplePay.id), {
25709
+ validation_url: event.validationURL
25710
+ }, ({data}) => {
25711
+
25712
+ Salla.event.dispatch('payments::apple-pay.validate-merchant.success', data);
25713
+
25714
+ if (typeof SallaApplePay.detail.validateMerchant.onSuccess === 'function') {
25715
+ SallaApplePay.detail.validateMerchant.onSuccess(data).then((response) => {
25716
+ // check if there are redirect
25717
+ if (response?.redirect) {
25718
+ window.location = response.redirect;
25719
+ return SallaApplePay.abortValidateMerchant(response);
25720
+ }
25721
+
25722
+ SallaApplePay.session.completeMerchantValidation(data.data);
25723
+ }).catch((response) => {
25724
+ SallaApplePay.abortValidateMerchant(response);
25725
+ });
25726
+ } else {
25727
+ SallaApplePay.session.completeMerchantValidation(data.data);
25728
+ }
25729
+
25730
+ }, ({response}) => {
25731
+ SallaApplePay.abortValidateMerchant(response);
25732
+ });
25733
+ },
25734
+
25735
+ abortValidateMerchant: (response = null) => {
25736
+
25737
+ SallaApplePay.abortSession();
25738
+ Salla.event.dispatch('payments::apple-pay.validate-merchant.failed', response);
25739
+
25740
+ if (typeof SallaApplePay.detail.validateMerchant.onFailed === 'function') {
25741
+ SallaApplePay.detail.validateMerchant.onFailed(response);
25742
+ }
25743
+ },
25744
+
25745
+ /**
25746
+ * Select Shipping Contact
25747
+ *
25748
+ * @param event
25749
+ */
25750
+ onShippingContactSelected: async (event) => {
25751
+ salla.logger.log('🍏 Pay: onShippingContactSelected', event.shippingContact);
25752
+
25753
+ if (!SallaApplePay.detail.requiredShippingContactFields) {
25754
+ return;
25755
+ }
25756
+
25757
+ // Create New Address
25758
+ return Http.post(SallaApplePay.detail.shippingContactSelected.url.replace('{id}', SallaApplePay.id),
25759
+ {
25760
+ 'country': event.shippingContact.country,
25761
+ 'city': event.shippingContact.locality,
25762
+ 'local': event.shippingContact.subLocality,
25763
+ 'description': event.shippingContact.subAdministrativeArea,
25764
+ 'street': event.shippingContact.administrativeArea,
25765
+ 'country_code': event.shippingContact.countryCode,
25766
+ 'postal_code': event.shippingContact.postalCode
25767
+ },
25768
+ async ({data}) => {
25769
+ if (typeof SallaApplePay.detail.shippingContactSelected.onSuccess === 'function') {
25770
+ SallaApplePay.detail.shippingContactSelected.onSuccess(data);
25771
+ }
25772
+
25773
+ SallaApplePay.address_id = data.data.address_id;
25774
+ SallaApplePay.shipping_methods = data.data.shipping_methods;
25775
+
25776
+ if (!SallaApplePay.shipping_methods || (SallaApplePay.shipping_methods && !SallaApplePay.shipping_methods.length)) {
25777
+ salla.logger.warn('🍏 Pay: We dont found any supported methods', data);
25778
+
25779
+ return SallaApplePay.session.completeShippingContactSelection({
25780
+ status: SallaApplePay.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,
25781
+ errors: [
25782
+ new window.ApplePayError('addressUnserviceable')
25783
+ ]
25784
+ });
25785
+ }
25786
+
25787
+ try {
25788
+ await SallaApplePay.selectApplePayShippingMethod(SallaApplePay.shipping_methods[0]['ship_id'], SallaApplePay.shipping_methods[0]['private_ship_id']);
25789
+ } catch (error) {
25790
+ salla.logger.warn('Failed set the shipping details to api', error);
25791
+
25792
+ return SallaApplePay.session.completeShippingContactSelection({
25793
+ status: SallaApplePay.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,
25794
+ errors: [
25795
+ new window.ApplePayError('addressUnserviceable')
25796
+ ]
25797
+ });
25798
+ }
25799
+
25800
+ try {
25801
+ await SallaApplePay.recalculateTotal();
25802
+ } catch (error) {
25803
+ salla.logger.warn('🍏 Pay: Failed recalculate total', error);
25804
+
25805
+ return SallaApplePay.session.completeShippingContactSelection({
25806
+ status: SallaApplePay.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,
25807
+ errors: [
25808
+ new window.ApplePayError('addressUnserviceable')
25809
+ ]
25810
+ });
25811
+ }
25812
+
25813
+ SallaApplePay.session.completeShippingContactSelection({
25814
+ newTotal: SallaApplePay.prepareTotal(),
25815
+ newLineItems: SallaApplePay.prepareLineItems(),
25816
+ newShippingMethods: SallaApplePay.mappingShippingMethods(SallaApplePay.shipping_methods)
25817
+ });
25818
+
25819
+ }, ({response}) => {
25820
+ salla.logger.warn('🍏 Pay: Failed add address via api', response);
25821
+
25822
+ if (typeof SallaApplePay.detail.shippingContactSelected.onFailed === 'function') {
25823
+ SallaApplePay.detail.shippingContactSelected.onFailed(response);
25824
+ }
25825
+
25826
+ // parse 422 errors
25827
+ let fields = response?.data?.error?.fields;
25828
+
25829
+ let errors = [];
25830
+
25831
+ if (fields?.country_code) {
25832
+ errors.push(new window.ApplePayError('shippingContactInvalid', 'countryCode', fields?.country_code[0]));
25833
+ }
25834
+
25835
+ if (fields?.city) {
25836
+ errors.push(new window.ApplePayError('shippingContactInvalid', 'locality', fields?.city[0]));
25837
+ }
25838
+
25839
+ if (fields?.country) {
25840
+ errors.push(new window.ApplePayError('shippingContactInvalid', 'country', fields?.country[0]));
25841
+ }
25842
+
25843
+ if (errors.length === 0 && response?.data?.error?.message) {
25844
+ errors.push(new window.ApplePayError('shippingContactInvalid', 'locality', response?.data?.error?.message));
25845
+ }
25846
+
25847
+ SallaApplePay.session.completeShippingContactSelection({
25848
+ newTotal: SallaApplePay.prepareTotal(),
25849
+ newLineItems: SallaApplePay.prepareLineItems(),
25850
+ status: SallaApplePay.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,
25851
+ errors: errors
25852
+ });
25853
+ });
25854
+ },
25855
+
25856
+ /**
25857
+ * Select Shipping Method
25858
+ *
25859
+ * @param event
25860
+ *
25861
+ */
25862
+ onShippingMethodSelected: async (event) => {
25863
+ salla.logger.log(event);
25864
+
25865
+ let shipping_ids = event.shippingMethod.identifier.split(',');
25866
+
25867
+ try {
25868
+ await SallaApplePay.selectApplePayShippingMethod(shipping_ids[0], typeof shipping_ids[1] === 'undefined' ? null : shipping_ids[1]);
25869
+
25870
+ await SallaApplePay.recalculateTotal();
25871
+
25872
+ SallaApplePay.session.completeShippingMethodSelection({
25873
+ newTotal: SallaApplePay.prepareTotal(),
25874
+ newLineItems: SallaApplePay.prepareLineItems(),
25875
+ });
25876
+ } catch (error) {
25877
+ salla.logger.warn('🍏 Pay: Failed set the shipping details to api', error);
25878
+
25879
+ // todo :: find a better handling for error without abort session
25880
+ SallaApplePay.abortSession();
25881
+ }
25882
+ },
25883
+
25884
+
25885
+ abortSession: () => {
25886
+ if (SallaApplePay.session) {
25887
+ SallaApplePay.session.abort();
25888
+ }
25889
+ },
25890
+
25891
+ getApplePaySessionVersion: () => {
25892
+ const userAgent = navigator.userAgent || navigator.vendor || window.opera;
25893
+
25894
+ if (userAgent === 'sallapp') {
25895
+ return 5;
25896
+ }
25897
+
25898
+ // can't handle custom user agent like sallapp
25899
+ let detection = DetectOS.init();
25900
+ let v = parseFloat(detection.os.version);
25901
+
25902
+ if (detection.os.name === 'Macintosh') {
25903
+ if (v < 10.142) {
25904
+ return 1;
25905
+ }
25906
+ } else {
25907
+ if (v < 12.11) {
25908
+ return 1;
25909
+ }
25910
+ }
25911
+
25912
+ return 5;
25913
+ },
25914
+
25915
+ recalculateTotal: () => {
25916
+ salla.logger.log('Recalculate Total');
25917
+
25918
+ return Http.requestWithSupportAjax(SallaApplePay.detail.recalculateTotal.url.replace('{id}', SallaApplePay.id),{}, 'get').then((data) => {
25919
+ console.log(data);
25920
+ // todo :: enhance response from backend
25921
+ SallaApplePay.detail.amount = data.data.initial_data.cart.total;
25922
+ SallaApplePay.detail.items = data.data.initial_data.cart.items.map((item) => {
25923
+ return {
25924
+ label: item.title,
25925
+ amount: item.amount === 'مجاني' ? 0 : item.amount.toString().replace('+', ''),
25926
+ };
25927
+ });
25928
+
25929
+ // lets remove last element (final total)
25930
+ SallaApplePay.detail.items.pop();
25931
+
25932
+ return data;
25933
+ }).catch((error) => {
25934
+ salla.logger.warn('🍏 Pay: recalculate total failed', error);
25935
+
25936
+ // general error
25937
+ return error?.response?.data?.message;
25938
+ });
25939
+ },
25940
+
25941
+
25942
+ selectApplePayShippingMethod: (company_id, private_company_id) => {
25943
+ salla.logger.log('🍏 Pay: select shipping method ', 'company_id : ' + company_id, 'private_company_id: ' + private_company_id);
25944
+
25945
+ return Http.requestWithSupportAjax(SallaApplePay.detail.shippingMethodSelected.url.replace('{id}', SallaApplePay.id), {
25946
+ address_id: SallaApplePay.address_id,
25947
+ company_id: company_id,
25948
+ private_company_id: private_company_id,
25949
+ payment_method: 'apple_pay'
25950
+ }, 'post').then(() => {
25951
+ if (typeof SallaApplePay.detail. shippingMethodSelected.onSuccess === 'function') {
25952
+ SallaApplePay.detail.shippingMethodSelected.onSuccess(data);
25953
+ }
25954
+
25955
+ // we don't have any data in this request, lets resolve the promise
25956
+ return true;
25957
+ }).catch((error) => {
25958
+ salla.logger.warn('🍏 Pay: Set shipping method failed', error);
25959
+
25960
+ if (typeof SallaApplePay.detail.shippingMethodSelected.onFailed === 'function') {
25961
+ SallaApplePay.detail.shippingMethodSelected.onFailed(error);
25962
+ }
25963
+
25964
+ // parse 422 errors
25965
+ let response = error?.response?.data?.error;
25966
+
25967
+ // address id is not valid
25968
+ if (response?.data?.fields?.address_id) {
25969
+ return response?.data?.fields?.address_id[0];
25970
+ }
25971
+
25972
+ // general error
25973
+ return response?.data?.message;
25974
+ });
25975
+ },
25976
+ mappingShippingMethods: methods => methods.map(method => ({
25977
+ 'label': method.shipping_title,
25978
+ 'amount': method.enable_free_shipping ? 0 : method.ship_cost,
25979
+ 'detail': '',
25980
+ 'identifier': method.ship_id.toString() + (method.private_ship_id ? ',' + method.private_ship_id.toString() : '')
25981
+ }))
25982
+ };
25983
+
25984
+ if (window.ApplePaySession && ApplePaySession.canMakePayments()) {
25985
+ SallaApplePay.init();
25986
+ } else {
25987
+ // You can hide the Apple Pay button easy with add data-show-if-apple-pay-supported to element like <div data-show-if-apple-pay-supported>
25988
+ document.querySelectorAll('data-show-if-apple-pay-supported').forEach(element => element.style.display = 'none');
25989
+ }
25990
+
25991
+ const sallaQuickBuyCss = ".s-quick-buy-button .s-button-text{display:-ms-flexbox;display:flex}apple-pay-button{--apple-pay-button-width:100%;--apple-pay-button-height:40px;--apple-pay-button-border-radius:7px;--apple-pay-button-padding:0px 5px;--apple-pay-button-box-sizing:content-box}";
25992
+
25993
+ const SallaQuickBuy = class {
25994
+ constructor(hostRef) {
25995
+ index.registerInstance(this, hostRef);
25996
+ /**
25997
+ * Button type.
25998
+ *
25999
+ * @type {string}
26000
+ * @default plain
26001
+ **/
26002
+ this.type = 'buy';
26003
+ /**
26004
+ * Product amount.
26005
+ *
26006
+ * @type {number}
26007
+ * @default 0
26008
+ **/
26009
+ this.amount = 0;
26010
+ /**
26011
+ * Product options, if is empty will get the data from the document.querySelector('salla-product-options[product-id="X"]')
26012
+ *
26013
+ * @type {object}
26014
+ * @default {}
26015
+ */
26016
+ this.options = {};
26017
+ this.quickBuy = salla.lang.get('pages.products.buy_now');
26018
+ salla.lang.onLoaded(() => {
26019
+ this.quickBuy = salla.lang.get('pages.products.buy_now');
26020
+ });
26021
+ }
26022
+ async quickBuyHandler() {
26023
+ if (salla.config.isGuest()) {
26024
+ // todo (low) :: find a way to re-fire the method after success
26025
+ return salla.auth.event.dispatch('login::open');
26026
+ }
26027
+ let optionsElement = document.querySelector(`salla-product-options[product-id="${this.productId}"]`);
26028
+ //make sure all the required options are selected
26029
+ if (optionsElement && !await optionsElement.reportValidity()) {
26030
+ return salla.error(salla.lang.get('common.messages.required_fields'));
26031
+ }
26032
+ //use this way to get quantity too
26033
+ let data = this.host.getElementSallaData();
26034
+ // if the store doesn't have Apple Pay , just create a cart and then redirect to check out page
26035
+ // @ts-ignore
26036
+ if (!this.isApplePayActive) {
26037
+ // return salla.product.buyNow(this.productId, data);
26038
+ return salla.api.request('checkout/quick-purchase/' + this.productId, data, 'post')
26039
+ .then(resp => {
26040
+ if (resp.data.redirect) {
26041
+ window.location.href = resp.data.redirect;
26042
+ }
26043
+ return resp;
26044
+ });
26045
+ }
26046
+ data.is_applepay = true;
26047
+ if ('append' in data) {
26048
+ data.append('is_applepay', true);
26049
+ }
26050
+ // noinspection TypeScriptValidateJSTypes
26051
+ salla.event.dispatch('payments::apple-pay.start-transaction', {
26052
+ amount: this.amount,
26053
+ currency: this.currency,
26054
+ requiredShippingContactFields: this.isRequireShipping ? ['postalAddress'] : null,
26055
+ shippingMethods: this.isRequireShipping ? [] : null,
26056
+ supportedNetworks: salla.config.get('store.settings.buy_now.networks'),
26057
+ // supportedCountries: data.applepay_supported_networks, // todo :: later get it from store settings with countries
26058
+ validateMerchant: {
26059
+ url: salla.url.get('checkout/applepay/validate'),
26060
+ onSuccess: () => {
26061
+ return salla.api.request('checkout/quick-purchase/' + this.productId, typeof data == 'object' ? data : undefined, 'post', {}).then(response => {
26062
+ var _a, _b;
26063
+ // if is redirect url returned for any reason, lets redirect the user to check out
26064
+ if ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.redirect) {
26065
+ salla.log('🍏 Pay: create checkout success: redirect exits, go to checkout page');
26066
+ window.location.href = response.data.redirect.url;
26067
+ return response;
26068
+ }
26069
+ // the cart is not ready to complete apply pay session
26070
+ if (!((_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.id)) {
26071
+ salla.logger.warn('🍏 Pay: create checkout success: No id, or redirect');
26072
+ return response;
26073
+ }
26074
+ window.SallaApplePay.id = response.data.id || response.data.data.id;
26075
+ salla.log('🍏 Pay: create checkout success: with id #' + window.SallaApplePay.id);
26076
+ });
26077
+ }
26078
+ },
26079
+ authorized: {
26080
+ // submit checkout route
26081
+ url: salla.url.get('checkout/{id}/payments/submit'),
26082
+ onFailed: (response) => {
26083
+ var _a, _b, _c, _d;
26084
+ window.SallaApplePay.onCancel({}, ((_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.message) || ((_d = (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.error) === null || _d === void 0 ? void 0 : _d.code) || salla.lang.get('pages.checkout.payment_failed'));
26085
+ },
26086
+ onSuccess: (response) => {
26087
+ window.location.href = response.redirect.url;
26088
+ salla.log('🍏 Pay: authorized Success:: redirect to thank you page, order placed');
26089
+ }
26090
+ },
26091
+ shippingMethodSelected: this.isRequireShipping ? {
26092
+ url: salla.url.get('checkout/{id}/shipping/details'),
26093
+ } : null,
26094
+ shippingContactSelected: this.isRequireShipping ? {
26095
+ url: salla.url.get('checkout/{id}/address/add'),
26096
+ } : null,
26097
+ oncouponcodechanged: {
26098
+ url: salla.url.get('checkout/{id}/coupons')
26099
+ },
26100
+ recalculateTotal: {
26101
+ url: salla.url.get('checkout/{id}/payments/recalculate')
26102
+ },
26103
+ onError: function (message) {
26104
+ salla.log(message);
26105
+ salla.notify.error(message);
26106
+ }
26107
+ });
26108
+ }
26109
+ componentWillLoad() {
26110
+ return new Promise((resolve, reject) => {
26111
+ salla.onReady(async () => {
26112
+ var _a, _b;
26113
+ if (!this.currency) {
26114
+ this.currency = salla.config.get('user.currency_code');
26115
+ }
26116
+ if (!this.productId && salla.config.get('page.id')) {
26117
+ this.productId = salla.config.get('page.id');
26118
+ }
26119
+ if (window.innerWidth <= 768 && this.type !== 'plain') {
26120
+ this.type = 'plain';
26121
+ }
26122
+ if (!this.productId) {
26123
+ salla.logger.warn('🍏 Pay: Failed load the quick buy, the product id is missing');
26124
+ return reject();
26125
+ }
26126
+ if (!this.amount && this.productId) {
26127
+ await salla.product.getDetails(this.productId, []).then((response) => {
26128
+ var _a;
26129
+ this.amount = response.data.price;
26130
+ this.isRequireShipping = ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.is_require_shipping) || false;
26131
+ }).catch((error) => {
26132
+ salla.logger.warn('🍏 Pay: Failed load the quick buy, get the product details failed: ', error);
26133
+ return reject();
26134
+ });
26135
+ }
26136
+ if (salla.url.is_page('product.single')) {
26137
+ salla.product.event.onPriceUpdated(response => this.amount = response.data.price);
26138
+ }
26139
+ this.isApplePayActive = ((_a = window.ApplePaySession) === null || _a === void 0 ? void 0 : _a.canMakePayments()) && ((_b = salla.config.get('store.settings.payments')) === null || _b === void 0 ? void 0 : _b.includes('apple_pay'));
26140
+ let applePaySdk = document.getElementById('apple-pay-sdk');
26141
+ if (applePaySdk || !this.isApplePayActive) {
26142
+ salla.logger.warn('🍏 Pay: Skipped load apple pay because ' + (applePaySdk ? 'already loaded' : 'is not available in the browser'));
26143
+ resolve(true);
26144
+ return;
26145
+ }
26146
+ const script = document.createElement('script');
26147
+ script.src = 'https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js';
26148
+ script.setAttribute('id', 'apple-pay-sdk');
26149
+ script.async = true;
26150
+ document.body.appendChild(script);
26151
+ resolve(true);
26152
+ });
26153
+ });
26154
+ }
26155
+ render() {
26156
+ return index.h(index.Host, null, this.quickBuyButton());
26157
+ }
26158
+ quickBuyButton() {
26159
+ return this.isApplePayActive
26160
+ ? index.h("apple-pay-button", { locale: salla.config.get('user.language_code'), onClick: () => this.quickBuyHandler(), "data-quick-purchase": "applepay", class: "s-quick-buy-apple-pay", "data-is-applepay": "1", buttonstyle: "black", type: this.type })
26161
+ :
26162
+ index.h("salla-button", { onClick: () => this.quickBuyHandler(), class: "s-quick-buy-button", color: "primary", fill: "outline", size: "medium", width: "wide", shape: "btn" }, index.h("span", { innerHTML: FullWallet }), this.quickBuy);
26163
+ }
26164
+ get host() { return index.getElement(this); }
26165
+ };
26166
+ SallaQuickBuy.style = sallaQuickBuyCss;
26167
+
23598
26168
  const CelebrationIcon = `<!-- Generated by IcoMoon.io -->
23599
26169
  <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
23600
26170
  <title>party-horn</title>
@@ -23792,7 +26362,7 @@ const SallaQuickOrder = class {
23792
26362
  return (index.h(index.Host, { class: "s-quick-order" }, index.h("div", { class: 's-quick-order-confirm', style: { backgroundColor: salla.config.get('theme.color.primary') + '10', borderColor: salla.config.get('theme.color.primary') + '10', color: salla.config.get('theme.color.primary') } }, index.h("i", { innerHTML: CelebrationIcon }), index.h("span", null, this.thanksMessage))));
23793
26363
  }
23794
26364
  return (index.h(index.Host, { class: `s-quick-order s-quick-order-${this.getDarkOrLight()}` }, index.h("div", { class: `s-quick-order-container s-quick-order-${this.quickOrderStyle}`, style: { backgroundColor: this.getStyleColor() } }, index.h("div", { class: "s-quick-order-button-cont" }, index.h("div", null, index.h("h3", null, this.quickOrderTitle), index.h("p", null, this.subTitle)), index.h("salla-button", { class: this.expanded ? "s-quick-order-btn-close" : "", onClick: (e) => this.submit(e, true), color: this.getBtnColor() }, this.oneClick
23795
- ? this.confirmPayButtonTitle : this.expanded ? index.h("i", { innerHTML: Cancel }) : this.confirmPayButtonTitle)), index.h("form", { onSubmit: (e) => this.submit(e), class: 's-quick-order-expandable ' + (this.expanded ? 's-quick-order-shown' : '') }, Salla.config.isGuest() &&
26365
+ ? this.confirmPayButtonTitle : this.expanded ? index.h("i", { innerHTML: Cancel$1 }) : this.confirmPayButtonTitle)), index.h("form", { onSubmit: (e) => this.submit(e), class: 's-quick-order-expandable ' + (this.expanded ? 's-quick-order-shown' : '') }, Salla.config.isGuest() &&
23796
26366
  [
23797
26367
  index.h("div", { class: "s-form-group" }, index.h("span", { innerHTML: PortraitIcon }), index.h("input", { type: "text", required: true, class: "s-form-control", name: 'name', placeholder: this.userNameLabel, ref: el => (this.nameInput = el) })),
23798
26368
  index.h("div", { class: "s-quick-order-flex-input" }, index.h("div", { class: "s-form-group" }, index.h("span", { innerHTML: IphoneXIcon }), index.h("salla-tel-input", { ref: el => (this.phoneInput = el) })), index.h("div", { class: "s-form-group" }, index.h("span", { innerHTML: MailIcon }), index.h("input", { type: "email", class: "s-form-control", name: 'email', required: this.isEmailRequired, placeholder: this.placeHolderEmail + ' ' + (this.isEmailRequired ? '' : this.emailOptional), ref: el => (this.emailInput = el) }))),
@@ -24979,7 +27549,7 @@ const SallaSocialShare = class {
24979
27549
  }, '-=200');
24980
27550
  }
24981
27551
  render() {
24982
- return (index.h("div", { class: "s-social-share-wrapper" }, index.h("slot", { name: 'widget' }, index.h("salla-button", { "aria-label": "Share", onClick: () => this.open(), class: "s-social-share-btn", shape: "icon", fill: "outline", color: "light" }, index.h("span", { innerHTML: this.opened ? Cancel : ShareAlt }))), index.h("ul", { ref: el => this.shareMenu = el, class: "s-social-share-list a2a_kit share" }, this.platforms.split(',').map(platform => {
27552
+ return (index.h("div", { class: "s-social-share-wrapper" }, index.h("slot", { name: 'widget' }, index.h("salla-button", { "aria-label": "Share", onClick: () => this.open(), class: "s-social-share-btn", shape: "icon", fill: "outline", color: "light" }, index.h("span", { innerHTML: this.opened ? Cancel$1 : ShareAlt }))), index.h("ul", { ref: el => this.shareMenu = el, class: "s-social-share-list a2a_kit share" }, this.platforms.split(',').map(platform => {
24983
27553
  return (index.h("li", { ref: el => this.platformItem = el }, index.h("a", { class: `a2a_button_${platform}`, "aria-label": `Share Via ${platform}` }, this.platformIcons.map((icon) => {
24984
27554
  if (icon.name === platform) {
24985
27555
  return index.h("span", { class: "s-social-share-icon", innerHTML: icon.icon });
@@ -26633,7 +29203,7 @@ const SallaUserMenu = class {
26633
29203
  this.items = {
26634
29204
  notifications: BellRing,
26635
29205
  orders: OrderIcon,
26636
- pending_orders: PendingOrdersIcon,
29206
+ pending_orders: cart.Cart,
26637
29207
  wishlist: WishListIcon,
26638
29208
  profile: ProfileIcon,
26639
29209
  };
@@ -26766,7 +29336,7 @@ const SallaUserMenu = class {
26766
29336
  //todo:: reduce class names, they are too long
26767
29337
  return (index.h(index.Host, null, this.inline ?
26768
29338
  index.h("ul", { class: "s-user-menu-inline" }, Object.entries(this.items).map((item, i) => this.getMenuItem(item, i)))
26769
- : index.h("div", { class: { 's-user-menu-wrapper': true, 's-user-menu-relative-dropdown': this.relativeDropdown } }, this.getTheHeader(), index.h("div", { class: { 's-user-menu-toggler': true, 'opened': this.opened } }, index.h("div", { class: "s-user-menu-dropdown", onClick: (e) => e.stopPropagation() }, this.showHeader ? index.h("div", { class: "s-user-menu-dropdown-header" }, index.h("img", { src: this.avatar, alt: `${this.first_name} ${this.last_name}` }), index.h("div", { class: "s-user-menu-dropdown-header-content" }, index.h("span", null, this.hello), index.h("p", null, this.first_name, " ", this.last_name)), index.h("button", { class: "s-user-menu-dropdown-header-close", innerHTML: Cancel, onClick: () => this.opened = false })) : '', index.h("ul", { class: "s-user-menu-dropdown-list" }, Object.entries(this.items).map((item, i) => this.getMenuItem(item, i))))))));
29339
+ : index.h("div", { class: { 's-user-menu-wrapper': true, 's-user-menu-relative-dropdown': this.relativeDropdown } }, this.getTheHeader(), index.h("div", { class: { 's-user-menu-toggler': true, 'opened': this.opened } }, index.h("div", { class: "s-user-menu-dropdown", onClick: (e) => e.stopPropagation() }, this.showHeader ? index.h("div", { class: "s-user-menu-dropdown-header" }, index.h("img", { src: this.avatar, alt: `${this.first_name} ${this.last_name}` }), index.h("div", { class: "s-user-menu-dropdown-header-content" }, index.h("span", null, this.hello), index.h("p", null, this.first_name, " ", this.last_name)), index.h("button", { class: "s-user-menu-dropdown-header-close", innerHTML: Cancel$1, onClick: () => this.opened = false })) : '', index.h("ul", { class: "s-user-menu-dropdown-list" }, Object.entries(this.items).map((item, i) => this.getMenuItem(item, i))))))));
26770
29340
  }
26771
29341
  componentDidLoad() {
26772
29342
  var _a;
@@ -27039,6 +29609,7 @@ exports.salla_product_availability = SallaProductAvailability;
27039
29609
  exports.salla_product_size_guide = SallaProductSizeGuide;
27040
29610
  exports.salla_progress_bar = SallaProgressBar;
27041
29611
  exports.salla_quantity_input = SallaQuantityInput;
29612
+ exports.salla_quick_buy = SallaQuickBuy;
27042
29613
  exports.salla_quick_order = SallaQuickOrder;
27043
29614
  exports.salla_rating_modal = SallaRatingModal;
27044
29615
  exports.salla_rating_stars = SallaRatingStars;