@salla.sa/twilight-components 2.13.69 → 2.13.71

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 (56) hide show
  1. package/dist/cjs/app-globals-b7d4e7fe.js.map +1 -1
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/salla-add-product-button_48.cjs.entry.js +2 -2
  4. package/dist/cjs/salla-add-product-button_48.cjs.entry.js.map +1 -1
  5. package/dist/cjs/salla-conditional-offer.cjs.entry.js +10 -2
  6. package/dist/cjs/salla-conditional-offer.cjs.entry.js.map +1 -1
  7. package/dist/cjs/twilight.cjs.js +1 -1
  8. package/dist/collection/components/salla-add-product-button/salla-add-product-button.js +2 -2
  9. package/dist/collection/components/salla-add-product-button/salla-add-product-button.js.map +1 -1
  10. package/dist/collection/components/salla-conditional-offer/salla-conditional-offer.js +13 -3
  11. package/dist/collection/components/salla-conditional-offer/salla-conditional-offer.js.map +1 -1
  12. package/dist/components/index.js.map +1 -1
  13. package/dist/components/salla-add-product-button2.js +2 -2
  14. package/dist/components/salla-add-product-button2.js.map +1 -1
  15. package/dist/components/salla-conditional-offer.js +20 -4
  16. package/dist/components/salla-conditional-offer.js.map +1 -1
  17. package/dist/components/salla-quick-buy2.js.map +1 -1
  18. package/dist/esm/app-globals-d8ab32b4.js.map +1 -1
  19. package/dist/esm/loader.js +1 -1
  20. package/dist/esm/salla-add-product-button_48.entry.js +2 -2
  21. package/dist/esm/salla-add-product-button_48.entry.js.map +1 -1
  22. package/dist/esm/salla-conditional-offer.entry.js +10 -2
  23. package/dist/esm/salla-conditional-offer.entry.js.map +1 -1
  24. package/dist/esm/twilight.js +1 -1
  25. package/dist/esm-es5/app-globals-d8ab32b4.js.map +1 -1
  26. package/dist/esm-es5/loader.js +1 -1
  27. package/dist/esm-es5/loader.js.map +1 -1
  28. package/dist/esm-es5/salla-add-product-button_48.entry.js +1 -1
  29. package/dist/esm-es5/salla-add-product-button_48.entry.js.map +1 -1
  30. package/dist/esm-es5/salla-conditional-offer.entry.js +1 -1
  31. package/dist/esm-es5/salla-conditional-offer.entry.js.map +1 -1
  32. package/dist/esm-es5/twilight.js +1 -1
  33. package/dist/esm-es5/twilight.js.map +1 -1
  34. package/dist/twilight/p-8e070ed6.js.map +1 -1
  35. package/dist/twilight/p-963a9e0e.system.js +1 -1
  36. package/dist/twilight/p-963a9e0e.system.js.map +1 -1
  37. package/dist/twilight/p-9b0d9e94.system.entry.js +5 -0
  38. package/dist/twilight/p-9b0d9e94.system.entry.js.map +1 -0
  39. package/dist/twilight/{p-cfb173cd.entry.js → p-a0a5e444.entry.js} +2 -2
  40. package/dist/twilight/p-a0a5e444.entry.js.map +1 -0
  41. package/dist/twilight/{p-c842998f.system.entry.js → p-cc12efcb.system.entry.js} +2 -2
  42. package/dist/twilight/p-cc12efcb.system.entry.js.map +1 -0
  43. package/dist/twilight/p-dad29c6b.system.js.map +1 -1
  44. package/dist/twilight/p-f49f7b11.entry.js +5 -0
  45. package/dist/twilight/p-f49f7b11.entry.js.map +1 -0
  46. package/dist/twilight/twilight.esm.js +1 -1
  47. package/dist/twilight/twilight.esm.js.map +1 -1
  48. package/dist/types/components/salla-conditional-offer/salla-conditional-offer.d.ts +4 -2
  49. package/package.json +5 -5
  50. package/dist/twilight/p-4242feaf.entry.js +0 -5
  51. package/dist/twilight/p-4242feaf.entry.js.map +0 -1
  52. package/dist/twilight/p-b3d8f527.system.entry.js +0 -5
  53. package/dist/twilight/p-b3d8f527.system.entry.js.map +0 -1
  54. package/dist/twilight/p-c842998f.system.entry.js.map +0 -1
  55. package/dist/twilight/p-cfb173cd.entry.js.map +0 -1
  56. package/dist/types/global.d.ts +0 -20
@@ -24,12 +24,13 @@ const sallaConditionalOfferCss = ":host{display:block}";
24
24
  const SallaConditionalOffer = class {
25
25
  constructor(hostRef) {
26
26
  index.registerInstance(this, hostRef);
27
- this.canRender = true;
28
27
  this.offer = null;
29
28
  this.products = {};
29
+ this.isLoading = true;
30
+ this.canRender = true;
30
31
  }
31
32
  componentWillLoad() {
32
- return salla.onReady().then(() => {
33
+ salla.onReady().then(() => {
33
34
  var _a, _b, _c;
34
35
  if (!((_a = salla.config.get('store.features')) === null || _a === void 0 ? void 0 : _a.includes('conditional-offer')) || !((_c = (_b = salla.storage.get("cart")) === null || _b === void 0 ? void 0 : _b.summary) === null || _c === void 0 ? void 0 : _c.count)) {
35
36
  throw new Error('feature or cart object does not existed');
@@ -45,6 +46,8 @@ const SallaConditionalOffer = class {
45
46
  .catch(error => {
46
47
  this.canRender = false;
47
48
  salla.logger.error('salla-conditional-offer:: Error', error);
49
+ }).finally(() => {
50
+ this.isLoading = false;
48
51
  });
49
52
  }
50
53
  getProducts() {
@@ -110,9 +113,14 @@ const SallaConditionalOffer = class {
110
113
  ] :
111
114
  index.h("div", { key: "label", class: { "s-conditional-offer-checkpoint-label": true, "first-checkpoint": index$1 === 0, active: isActive }, innerHTML: this.getOfferType(discount) })));
112
115
  }
116
+ getLoadingSkeletonView() {
117
+ return index.h(index.Host, { class: "s-conditional-offer-container " }, index.h("div", { class: "s-conditional-offer-skeleton-wrapper" }, index.h("div", { class: "s-conditional-offer-skeleton-title" }, index.h("salla-skeleton", { height: "16px", width: "30%" })), index.h("div", { class: "s-conditional-offer-skeleton-subtitle" }, index.h("salla-skeleton", { height: "16px", width: "35%" })), index.h("div", { class: "s-conditional-offer-skeleton-checkpoints-wrapper" }, Array(3).fill(null).map(() => ([index.h("salla-skeleton", { key: "checkpoint-line", height: "8px" }), index.h("div", { class: "s-conditional-offer-skeleton-checkpoint", key: "checkpoint" }, index.h("salla-skeleton", { height: "60px", width: "60px", type: "circle" }))])))));
118
+ }
113
119
  render() {
114
120
  if (!this.canRender)
115
121
  return null;
122
+ if (this.isLoading)
123
+ return this.getLoadingSkeletonView();
116
124
  return index.h(index.Host, { class: "s-conditional-offer-container" }, index.h("div", { class: "s-conditional-offer-title-wrapper" }, index.h("div", { class: "s-conditional-offer-title" }, this.offer.title), this.offer.description ? index.h("div", { class: "s-conditional-offer-subtitle" }, this.offer.description, " ", index.h("i", { class: "sicon-information" })) : null), index.h("div", { class: "s-conditional-offer-progress-container" }, this.offer.details.discounts.map((discount, index$1) => (index.h("div", { class: { "flex-1": index$1 > 0 }, key: discount.min_spend }, this.getCheckPointView(discount, index$1))))));
117
125
  }
118
126
  };
@@ -1 +1 @@
1
- {"file":"salla-conditional-offer.entry.cjs.js","mappings":";;;;;;;;;AAEA,IAAY,YAIX;AAJD,WAAY,YAAY;EACpB,yCAAyB,CAAA;EACzB,+BAAe,CAAA;EACf,6CAA6B,CAAA;AACjC,CAAC,EAJW,YAAY,KAAZ,YAAY,QAIvB;AAED,IAAY,SAGX;AAHD,WAAY,SAAS;EACjB,6CAAgC,CAAA;EAChC,8CAAiC,CAAA;AACrC,CAAC,EAHW,SAAS,KAAT,SAAS;;ACRrB,MAAM,wBAAwB,GAAG,sBAAsB;;MCc1C,qBAAqB;;;IAKtB,cAAS,GAAG,IAAI,CAAA;iBAHA,IAAI;oBACwC,EAAE;;EAItE,iBAAiB;IACb,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC;;MACxB,IAAI,EAAC,MAAA,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,0CAAE,QAAQ,CAAC,mBAAmB,CAAC,CAAA,IAAI,EAAC,MAAA,MAAA,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,0CAAE,OAAO,0CAAE,KAAK,CAAA,EAAE;QAClH,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;OAC9D;KACJ,CAAC;OACG,IAAI,CAAC,MAAM,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;OACnC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAqB;;MAE9B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,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E,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAI,CAExH;KACT;MACGA,iBAAK,GAAG,EAAC,OAAO,EAAC,KAAK,EAAE,EAAE,sCAAsC,EAAE,IAAI,EAAE,kBAAkB,EAAEC,OAAK,KAAK,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAI,CAEzK,EACR;GACL;EAED,MAAM;IACF,IAAI,CAAC,IAAI,CAAC,SAAS;MAAE,OAAO,IAAI,CAAA;IAEhC,OAAOD,QAACE,UAAI,IAAC,KAAK,EAAC,+BAA+B,IAC9CF,iBAAK,KAAK,EAAC,mCAAmC,IAC1CA,iBAAK,KAAK,EAAC,2BAA2B,IAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAO,EAC9D,IAAI,CAAC,KAAK,CAAC,WAAW,GAAGA,iBAAK,KAAK,EAAC,8BAA8B,IAC9D,IAAI,CAAC,KAAK,CAAC,WAAW,OAAEA,eAAG,KAAK,EAAC,mBAAmB,GAAG,CACtD,GAAG,IAAI,CACX,EACNA,iBAAK,KAAK,EAAC,wCAAwC,IAC9C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAEC,OAAK,MAC9CD,iBAAK,KAAK,EAAE,EAAE,QAAQ,EAAEC,OAAK,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,QAAQ,CAAC,SAAS,IACvD,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAEA,OAAK,CAAC,CACtC,CACT,CAAC,CACA,CACH,CAAA;GACV;;;;;;","names":["h","index","Host"],"sources":["src/components/salla-conditional-offer/interfaces.ts","src/components/salla-conditional-offer/salla-conditional-offer.scss?tag=salla-conditional-offer","src/components/salla-conditional-offer/salla-conditional-offer.tsx"],"sourcesContent":["import type { Product } from \"@salla.sa/twilight/types/common\";\n\nexport enum DiscountType {\n PERCENTAGE = \"percentage\",\n FIXED = \"fixed\",\n FREE_PRODUCT = \"free_product\",\n}\n\nexport enum OfferType {\n PRODUCT_COUNT = \"products_count\",\n PRODUCT_PURCHASE = \"order_amount\",\n}\n\nexport interface Discount {\n type?: DiscountType;\n value?: number;\n min_spend?: number;\n max_discount?: number;\n}\n\nexport interface OfferDetails {\n based_on?: OfferType;\n ends_at?: number;\n start_value?: number;\n end_value?: number;\n current_value?: number;\n discounts?: Discount[];\n}\n\nexport interface Offer {\n id?: number;\n type?: string;\n title?: string;\n description?: string;\n details?: OfferDetails | null;\n}\n\n\nexport interface ProductDetail {\n id?: number;\n sku?: string;\n name?: string;\n description?: string;\n url?: string;\n promotion_title?: null;\n subtitle?: null;\n type?: string;\n status?: string;\n price?: number;\n base_currency_price?: BaseCurrencyPrice;\n sale_price?: number;\n regular_price?: number;\n starting_price?: null;\n quantity?: null;\n max_quantity?: number;\n discount_ends?: null;\n is_taxable?: boolean;\n has_read_more?: boolean;\n can_add_note?: boolean;\n can_show_remained_quantity?: boolean;\n can_upload_file?: boolean;\n has_custom_form?: boolean;\n has_metadata?: boolean;\n is_on_sale?: boolean;\n is_hidden_quantity?: boolean;\n is_available?: boolean;\n is_out_of_stock?: boolean;\n is_require_shipping?: boolean;\n weight?: null;\n calories?: null;\n image?: Image;\n currency?: string;\n}\n\nexport interface BaseCurrencyPrice {\n currency?: string;\n amount?: number;\n}\n\nexport interface Image {\n url?: string;\n alt?: string;\n}\n\nexport interface UpdatedCart {\n items: Array<Product>;\n total: number;\n}\n",":host {\n display: block;\n}","import { Component, Host, State, h } from \"@stencil/core\";\nimport {\n type Discount,\n DiscountType,\n type Offer,\n OfferType,\n type UpdatedCart,\n} from \"./interfaces\";\nimport type { Product } from \"@salla.sa/twilight/types/common\";\n\n@Component({\n tag: \"salla-conditional-offer\",\n styleUrl: \"salla-conditional-offer.scss\",\n})\nexport class SallaConditionalOffer {\n\n @State() offer: Offer = null;\n @State() products: Record<string, Pick<Product, 'image' | 'url'>> = {}\n\n private canRender = true\n\n componentWillLoad() {\n return salla.onReady().then(() => {\n if (!salla.config.get('store.features')?.includes('conditional-offer') || !salla.storage.get(\"cart\")?.summary?.count) {\n throw new Error('feature or cart object does not existed');\n }\n })\n .then(() => salla.api.cart.offers())\n .then(({ data }: { data: Offer[] }) => {\n //it's okay if there is an exception here, all thens will be skipped, and will catch the error,\n this.offer = data.find(offer => offer.type === \"conditional\")\n this.offer.details.discounts.unshift(({ value: 0, min_spend: 0 }))\n return this.updateInitialOfferValue()\n }).then(() => this.getProducts()).then(() => salla.event.on(\"cart::updated\", (updatedCart: UpdatedCart) => this.updateOfferValues(updatedCart)))\n .catch(error => {\n this.canRender = false\n salla.logger.error('salla-conditional-offer:: Error', error)\n });\n\n\n }\n\n private getProducts() {\n const freeProductIDs = this.offer.details.discounts.filter(({ type }) => type === DiscountType.FREE_PRODUCT).map(({ value }) => value)\n if (freeProductIDs.length > 0) {\n return salla.product.fetch({ source: 'selected', source_value: freeProductIDs }).then(({ data }: { data: Array<Product> }) => {\n data.forEach(({ id, url, image }) => {\n this.products[id] = { url, image }\n })\n })\n }\n }\n private updateInitialOfferValue() {\n return salla.api.cart.details().then(({ data: { cart } }: { data: { cart: UpdatedCart } }) => this.updateOfferValues(cart))\n }\n\n private updateOfferValues({ items, total }: UpdatedCart) {\n const current_value = this.offer.details.based_on === OfferType.PRODUCT_COUNT ? items.reduce((count: number, { quantity }) => count + quantity, 0,) : total\n //we need to assign the offer object a new reference to trigger re-rendering\n this.offer = {\n ...this.offer, details: {\n ...this.offer?.details, current_value,\n }\n }\n return this.offer\n }\n\n private getCheckpointContent(discount: Discount) {\n\n if (discount.type === DiscountType.PERCENTAGE) return `${discount.value}%`\n\n if (discount.type === DiscountType.FIXED) return salla.money(discount.value)\n\n if (discount.type !== DiscountType.FREE_PRODUCT) {\n salla.logger.error(`salla-conditional-offer:: unexpected type (${discount.type})!`);\n return \"\";\n }\n\n const productItem = this.products[discount.value]\n\n if (!productItem) {\n salla.logger.error(`salla-conditional-offer:: there is no product with id (${discount.value})!`);\n return \"\";\n }\n\n return <a class=\"s-conditional-offer-product-link\" href={productItem.url} >\n <img\n class=\"s-conditional-offer-checkpoint-image-content\"\n loading=\"lazy\"\n decoding=\"async\"\n alt={productItem?.image?.alt || \"\"}\n src={productItem?.image?.url} />\n </a>\n\n\n\n }\n\n private getOfferType(discount: Discount): string {\n const basedOn = this.offer.details?.based_on;\n if (basedOn === OfferType.PRODUCT_COUNT) return salla.lang.choice(\"blocks.header.products_count\", discount.min_spend);\n if (basedOn === OfferType.PRODUCT_PURCHASE) return salla.money(discount.min_spend);\n\n salla.logger.warn(`salla-conditional-offer:: Unexpected offer detail's based_on value: ${basedOn}`);\n return `${discount.min_spend}`;\n }\n private mapValueRanges(value: number, initialMinRange: number, initialMaxRange: number, newMinRange: number, newMaxRange: number) {\n\n const newRange = ((value - initialMinRange) * (newMaxRange - newMinRange)) / (initialMaxRange - initialMinRange) + newMinRange;\n\n return newRange > newMaxRange && !Number.isFinite(newRange) ? newMaxRange : newRange;\n }\n\n private getCheckPointView(discount: Discount, index: number) {\n const checkpointIndex = this.offer.details.discounts.findIndex(({ min_spend }) => min_spend === discount.min_spend);\n const previousCheckpointValue = this.offer.details.discounts[checkpointIndex - 1]?.min_spend ?? 0;\n const progressPercentage = this.mapValueRanges(this.offer.details.current_value, previousCheckpointValue, discount.min_spend, 0, 100);\n const isActive = discount.min_spend <= this.offer.details.current_value;\n\n return (\n <div class=\"s-conditional-offer-checkpoint-container\">\n {index > 0 ? [\n <div key=\"progress-line\" class=\"s-conditional-offer-progress-line-container\">\n <div class=\"s-conditional-offer-progress-line-inactive\" />\n <div class=\"s-conditional-offer-progress-line-active\" style={{ width: `${progressPercentage}%` }} />\n </div>,\n <div key=\"checkpoint\" class={`s-conditional-offer-checkpoint ${isActive ? \"s-conditional-offer-active-checkpoint\" : \"\"}`} >\n <div class={`s-conditional-offer-item-avatar-content ${isActive ? \"active\" : \"\"}`} >\n {this.products && this.getCheckpointContent(discount)}\n </div>\n <div class={`s-conditional-offer-checkpoint-label ${isActive ? \"active\" : \"\"}`} innerHTML={this.getOfferType(discount)} />\n\n </div>\n ] :\n <div key=\"label\" class={{ \"s-conditional-offer-checkpoint-label\": true, \"first-checkpoint\": index === 0, active: isActive }} innerHTML={this.getOfferType(discount)} />\n }\n </div>\n );\n }\n\n render() {\n if (!this.canRender) return null\n\n return <Host class=\"s-conditional-offer-container\">\n <div class=\"s-conditional-offer-title-wrapper\">\n <div class=\"s-conditional-offer-title\">{this.offer.title}</div>\n {this.offer.description ? <div class=\"s-conditional-offer-subtitle\">\n {this.offer.description} <i class=\"sicon-information\" />\n </div> : null}\n </div>\n <div class=\"s-conditional-offer-progress-container\">\n {this.offer.details.discounts.map((discount, index) => (\n <div class={{ \"flex-1\": index > 0 }} key={discount.min_spend}>\n {this.getCheckPointView(discount, index)}\n </div>\n ))}\n </div>\n </Host>\n }\n}\n"],"version":3}
1
+ {"file":"salla-conditional-offer.entry.cjs.js","mappings":";;;;;;;;;AAEA,IAAY,YAIX;AAJD,WAAY,YAAY;EACpB,yCAAyB,CAAA;EACzB,+BAAe,CAAA;EACf,6CAA6B,CAAA;AACjC,CAAC,EAJW,YAAY,KAAZ,YAAY,QAIvB;AAED,IAAY,SAGX;AAHD,WAAY,SAAS;EACjB,6CAAgC,CAAA;EAChC,8CAAiC,CAAA;AACrC,CAAC,EAHW,SAAS,KAAT,SAAS;;ACRrB,MAAM,wBAAwB,GAAG,sBAAsB;;MCc1C,qBAAqB;;;iBAEN,IAAI;oBACwC,EAAE;qBACjD,IAAI;qBACJ,IAAI;;EAEzB,iBAAiB;IACb,KAAK,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC;;MACjB,IAAI,EAAC,MAAA,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,0CAAE,QAAQ,CAAC,mBAAmB,CAAC,CAAA,IAAI,EAAC,MAAA,MAAA,KAAK,CAAC,OAAO,CAAC,GAAG,CA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AAG,EAAC,YAAY,IACjEA,4BAAgB,MAAM,EAAC,MAAM,EAAC,KAAK,EAAC,MAAM,EAAC,IAAI,EAAC,QAAQ,GAAG,CACzD,CAAC,CACV,CAAC,CACA,CAEJ,CACH,CAAA;GACV;EAED,MAAM;IACF,IAAI,CAAC,IAAI,CAAC,SAAS;MAAE,OAAO,IAAI,CAAA;IAChC,IAAI,IAAI,CAAC,SAAS;MAAE,OAAO,IAAI,CAAC,sBAAsB,EAAE,CAAA;IAExD,OAAOA,QAACE,UAAI,IAAC,KAAK,EAAC,+BAA+B,IAC9CF,iBAAK,KAAK,EAAC,mCAAmC,IAC1CA,iBAAK,KAAK,EAAC,2BAA2B,IAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAO,EAC9D,IAAI,CAAC,KAAK,CAAC,WAAW,GAAGA,iBAAK,KAAK,EAAC,8BAA8B,IAC9D,IAAI,CAAC,KAAK,CAAC,WAAW,OAAEA,eAAG,KAAK,EAAC,mBAAmB,GAAG,CACtD,GAAG,IAAI,CACX,EACNA,iBAAK,KAAK,EAAC,wCAAwC,IAC9C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAEC,OAAK,MAC9CD,iBAAK,KAAK,EAAE,EAAE,QAAQ,EAAEC,OAAK,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,QAAQ,CAAC,SAAS,IACvD,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAEA,OAAK,CAAC,CACtC,CACT,CAAC,CACA,CACH,CAAA;GACV;;;;;;","names":["h","index","Host"],"sources":["src/components/salla-conditional-offer/interfaces.ts","src/components/salla-conditional-offer/salla-conditional-offer.scss?tag=salla-conditional-offer","src/components/salla-conditional-offer/salla-conditional-offer.tsx"],"sourcesContent":["import type { Product } from \"@salla.sa/twilight/types/common\";\n\nexport enum DiscountType {\n PERCENTAGE = \"percentage\",\n FIXED = \"fixed\",\n FREE_PRODUCT = \"free_product\",\n}\n\nexport enum OfferType {\n PRODUCT_COUNT = \"products_count\",\n PRODUCT_PURCHASE = \"order_amount\",\n}\n\nexport interface Discount {\n type?: DiscountType;\n value?: number;\n min_spend?: number;\n max_discount?: number;\n}\n\nexport interface OfferDetails {\n based_on?: OfferType;\n ends_at?: number;\n start_value?: number;\n end_value?: number;\n current_value?: number;\n discounts?: Discount[];\n}\n\nexport interface Offer {\n id?: number;\n type?: string;\n title?: string;\n description?: string;\n details?: OfferDetails | null;\n}\n\n\nexport interface ProductDetail {\n id?: number;\n sku?: string;\n name?: string;\n description?: string;\n url?: string;\n promotion_title?: null;\n subtitle?: null;\n type?: string;\n status?: string;\n price?: number;\n base_currency_price?: BaseCurrencyPrice;\n sale_price?: number;\n regular_price?: number;\n starting_price?: null;\n quantity?: null;\n max_quantity?: number;\n discount_ends?: null;\n is_taxable?: boolean;\n has_read_more?: boolean;\n can_add_note?: boolean;\n can_show_remained_quantity?: boolean;\n can_upload_file?: boolean;\n has_custom_form?: boolean;\n has_metadata?: boolean;\n is_on_sale?: boolean;\n is_hidden_quantity?: boolean;\n is_available?: boolean;\n is_out_of_stock?: boolean;\n is_require_shipping?: boolean;\n weight?: null;\n calories?: null;\n image?: Image;\n currency?: string;\n}\n\nexport interface BaseCurrencyPrice {\n currency?: string;\n amount?: number;\n}\n\nexport interface Image {\n url?: string;\n alt?: string;\n}\n\nexport interface UpdatedCart {\n items: Array<Product>;\n total: number;\n}\n",":host {\n display: block;\n}","import { Component, Host, State, h } from \"@stencil/core\";\nimport {\n type Discount,\n DiscountType,\n type Offer,\n OfferType,\n type UpdatedCart,\n} from \"./interfaces\";\nimport type { Product } from \"@salla.sa/twilight/types/common\";\n\n@Component({\n tag: \"salla-conditional-offer\",\n styleUrl: \"salla-conditional-offer.scss\",\n})\nexport class SallaConditionalOffer {\n\n @State() offer: Offer = null;\n @State() products: Record<string, Pick<Product, 'image' | 'url'>> = {}\n @State() isLoading = true\n @State() canRender = true\n\n componentWillLoad() {\n salla.onReady().then(() => {\n if (!salla.config.get('store.features')?.includes('conditional-offer') || !salla.storage.get(\"cart\")?.summary?.count) {\n throw new Error('feature or cart object does not existed');\n }\n })\n .then(() => salla.api.cart.offers())\n .then(({ data }: { data: Offer[] }) => {\n //it's okay if there is an exception here, all thens will be skipped, and will catch the error,\n this.offer = data.find(offer => offer.type === \"conditional\")\n this.offer.details.discounts.unshift(({ value: 0, min_spend: 0 }))\n return this.updateInitialOfferValue()\n }).then(() => this.getProducts()).then(() => salla.event.on(\"cart::updated\", (updatedCart: UpdatedCart) => this.updateOfferValues(updatedCart)))\n .catch(error => {\n this.canRender = false\n salla.logger.error('salla-conditional-offer:: Error', error)\n\n\n }).finally(() => {\n this.isLoading = false\n })\n\n\n }\n\n private getProducts() {\n const freeProductIDs = this.offer.details.discounts.filter(({ type }) => type === DiscountType.FREE_PRODUCT).map(({ value }) => value)\n if (freeProductIDs.length > 0) {\n return salla.product.fetch({ source: 'selected', source_value: freeProductIDs }).then(({ data }: { data: Array<Product> }) => {\n data.forEach(({ id, url, image }) => {\n this.products[id] = { url, image }\n })\n })\n }\n }\n private updateInitialOfferValue() {\n return salla.api.cart.details().then(({ data: { cart } }: { data: { cart: UpdatedCart } }) => this.updateOfferValues(cart))\n }\n\n private updateOfferValues({ items, total }: UpdatedCart) {\n const current_value = this.offer.details.based_on === OfferType.PRODUCT_COUNT ? items.reduce((count: number, { quantity }) => count + quantity, 0,) : total\n //we need to assign the offer object a new reference to trigger re-rendering\n this.offer = {\n ...this.offer, details: {\n ...this.offer?.details, current_value,\n }\n }\n return this.offer\n }\n\n private getCheckpointContent(discount: Discount) {\n\n if (discount.type === DiscountType.PERCENTAGE) return `${discount.value}%`\n\n if (discount.type === DiscountType.FIXED) return salla.money(discount.value)\n\n if (discount.type !== DiscountType.FREE_PRODUCT) {\n salla.logger.error(`salla-conditional-offer:: unexpected type (${discount.type})!`);\n return \"\";\n }\n\n const productItem = this.products[discount.value]\n\n if (!productItem) {\n salla.logger.error(`salla-conditional-offer:: there is no product with id (${discount.value})!`);\n return \"\";\n }\n\n return <a class=\"s-conditional-offer-product-link\" href={productItem.url} >\n <img\n class=\"s-conditional-offer-checkpoint-image-content\"\n loading=\"lazy\"\n decoding=\"async\"\n alt={productItem?.image?.alt || \"\"}\n src={productItem?.image?.url} />\n </a>\n\n\n\n }\n\n private getOfferType(discount: Discount): string {\n const basedOn = this.offer.details?.based_on;\n if (basedOn === OfferType.PRODUCT_COUNT) return salla.lang.choice(\"blocks.header.products_count\", discount.min_spend);\n if (basedOn === OfferType.PRODUCT_PURCHASE) return salla.money(discount.min_spend);\n\n salla.logger.warn(`salla-conditional-offer:: Unexpected offer detail's based_on value: ${basedOn}`);\n return `${discount.min_spend}`;\n }\n private mapValueRanges(value: number, initialMinRange: number, initialMaxRange: number, newMinRange: number, newMaxRange: number) {\n\n const newRange = ((value - initialMinRange) * (newMaxRange - newMinRange)) / (initialMaxRange - initialMinRange) + newMinRange;\n\n return newRange > newMaxRange && !Number.isFinite(newRange) ? newMaxRange : newRange;\n }\n\n private getCheckPointView(discount: Discount, index: number) {\n const checkpointIndex = this.offer.details.discounts.findIndex(({ min_spend }) => min_spend === discount.min_spend);\n const previousCheckpointValue = this.offer.details.discounts[checkpointIndex - 1]?.min_spend ?? 0;\n const progressPercentage = this.mapValueRanges(this.offer.details.current_value, previousCheckpointValue, discount.min_spend, 0, 100);\n const isActive = discount.min_spend <= this.offer.details.current_value;\n\n return (\n <div class=\"s-conditional-offer-checkpoint-container\">\n {index > 0 ? [\n <div key=\"progress-line\" class=\"s-conditional-offer-progress-line-container\">\n <div class=\"s-conditional-offer-progress-line-inactive\" />\n <div class=\"s-conditional-offer-progress-line-active\" style={{ width: `${progressPercentage}%` }} />\n </div>,\n <div key=\"checkpoint\" class={`s-conditional-offer-checkpoint ${isActive ? \"s-conditional-offer-active-checkpoint\" : \"\"}`} >\n <div class={`s-conditional-offer-item-avatar-content ${isActive ? \"active\" : \"\"}`} >\n {this.products && this.getCheckpointContent(discount)}\n </div>\n <div class={`s-conditional-offer-checkpoint-label ${isActive ? \"active\" : \"\"}`} innerHTML={this.getOfferType(discount)} />\n\n </div>\n ] :\n <div key=\"label\" class={{ \"s-conditional-offer-checkpoint-label\": true, \"first-checkpoint\": index === 0, active: isActive }} innerHTML={this.getOfferType(discount)} />\n }\n </div>\n );\n }\n\n private getLoadingSkeletonView() {\n return <Host class=\"s-conditional-offer-container \" >\n <div class=\"s-conditional-offer-skeleton-wrapper\">\n <div class=\"s-conditional-offer-skeleton-title\">\n <salla-skeleton height=\"16px\" width=\"30%\" />\n </div>\n\n <div class=\"s-conditional-offer-skeleton-subtitle\">\n <salla-skeleton height=\"16px\" width=\"35%\" />\n </div>\n <div class=\"s-conditional-offer-skeleton-checkpoints-wrapper\">\n {Array(3).fill(null).map(() => (\n [<salla-skeleton key=\"checkpoint-line\" height=\"8px\" />,\n <div class=\"s-conditional-offer-skeleton-checkpoint\" key=\"checkpoint\">\n <salla-skeleton height=\"60px\" width=\"60px\" type=\"circle\" />\n </div>]\n ))}\n </div>\n\n </div>\n </Host>\n }\n\n render() {\n if (!this.canRender) return null\n if (this.isLoading) return this.getLoadingSkeletonView()\n\n return <Host class=\"s-conditional-offer-container\">\n <div class=\"s-conditional-offer-title-wrapper\">\n <div class=\"s-conditional-offer-title\">{this.offer.title}</div>\n {this.offer.description ? <div class=\"s-conditional-offer-subtitle\">\n {this.offer.description} <i class=\"sicon-information\" />\n </div> : null}\n </div>\n <div class=\"s-conditional-offer-progress-container\">\n {this.offer.details.discounts.map((discount, index) => (\n <div class={{ \"flex-1\": index > 0 }} key={discount.min_spend}>\n {this.getCheckPointView(discount, index)}\n </div>\n ))}\n </div>\n </Host>\n }\n}\n"],"version":3}
@@ -23,7 +23,7 @@ const patchBrowser = () => {
23
23
 
24
24
  patchBrowser().then(options => {
25
25
  appGlobals.globalScripts();
26
- return index.bootstrapLazy(JSON.parse("[[\"salla-offer.cjs\",[[0,\"salla-offer\",{\"productCardComponent\":[1,\"product-card-component\"],\"offersList\":[32],\"userCurrency\":[32],\"isMultipleBank\":[32],\"title\":[32],\"currentPage\":[32],\"hasCustomComponent\":[32],\"isBankOffer\":[32],\"canRender\":[32],\"showOffer\":[32],\"offer_with_price_text\":[32],\"with_discount_text\":[32],\"product_discount_text\":[32],\"special_offer_text\":[32],\"multipleBankOfferTitleText\":[32],\"multipleBankOfferTitleDescription\":[32],\"buy_quantity_text\":[32]}]]],[\"salla-products-slider.cjs\",[[0,\"salla-products-slider\",{\"blockTitle\":[1,\"block-title\"],\"subTitle\":[1,\"sub-title\"],\"sliderId\":[1,\"slider-id\"],\"displayAllUrl\":[1,\"display-all-url\"],\"autoplay\":[1028],\"source\":[1537],\"sourceValue\":[1,\"source-value\"],\"limit\":[1026],\"sliderConfig\":[520,\"slider-config\"],\"productCardComponent\":[1,\"product-card-component\"],\"productsData\":[32],\"isReady\":[32],\"sourceValueIsValid\":[32],\"hasCustomComponent\":[32],\"apiUrl\":[32],\"parsedSourceValue\":[32]}]]],[\"salla-product-options.cjs\",[[0,\"salla-product-options\",{\"productId\":[2,\"product-id\"],\"options\":[1],\"optionsData\":[32],\"outOfStockText\":[32],\"donationAmount\":[32],\"selectDonationAmount\":[32],\"selectAmount\":[32],\"isCustomDonation\":[32],\"selectedOptions\":[32],\"canDisabled\":[32],\"selectedSkus\":[32],\"selectedOutSkus\":[32],\"getSelectedOptionsData\":[64],\"reportValidity\":[64],\"hasOutOfStockOption\":[64],\"getSelectedOptions\":[64],\"getOption\":[64]}]]],[\"salla-filters.cjs\",[[0,\"salla-filters\",{\"filters\":[1040],\"isSidebarOpen\":[32],\"filtersData\":[32],\"apply\":[32],\"reset\":[32],\"getFilters\":[64],\"applyFilters\":[64],\"resetFilters\":[64]}]]],[\"salla-notifications.cjs\",[[0,\"salla-notifications\",{\"loadMoreText\":[1,\"load-more-text\"],\"itemPerPage\":[2,\"item-per-page\"],\"pagination\":[32],\"total\":[32],\"showPlaceholder\":[32],\"nextPage\":[32],\"no_notifications_trans\":[32],\"load_more_text_trans\":[32]}]]],[\"salla-order-summary.cjs\",[[0,\"salla-order-summary\",{\"orderId\":[514,\"order-id\"],\"codeCopied\":[32],\"noItemFound\":[32],\"order_items\":[32]}]]],[\"salla-reviews.cjs\",[[0,\"salla-reviews\",{\"displayAllLink\":[516,\"display-all-link\"],\"source\":[513],\"sourceValue\":[513,\"source-value\"],\"limit\":[514],\"type\":[1],\"sort\":[1],\"hideCustomerInfo\":[4,\"hide-customer-info\"],\"reviews\":[32],\"isRTL\":[32],\"showReviews\":[32],\"testimonialText\":[32],\"displayAllLinkText\":[32]}]]],[\"salla-orders.cjs\",[[0,\"salla-orders\",{\"params\":[16],\"loadMoreText\":[1,\"load-more-text\"],\"orderNumberText\":[32],\"totalOrderText\":[32],\"orderDateText\":[32],\"orderStatusText\":[32],\"noOrderText\":[32],\"load_more_text_trans\":[32],\"languageCode\":[32],\"orders\":[32],\"pagination\":[32],\"hasInfiniteScroll\":[32],\"total\":[32],\"nextPage\":[32],\"showPlaceholder\":[32]}]]],[\"salla-advertisement.cjs\",[[0,\"salla-advertisement\",{\"position\":[32],\"advertisements\":[32],\"advertIcon\":[32],\"currentSlug\":[32]}]]],[\"salla-app-install-alert.cjs\",[[0,\"salla-app-install-alert\",{\"data\":[32],\"ctaLink\":[32],\"open\":[32],\"closing\":[32]}]]],[\"salla-apps-icons.cjs\",[[0,\"salla-apps-icons\",{\"hideTitle\":[4,\"hide-title\"],\"appsTitle\":[1,\"apps-title\"],\"vertical\":[4],\"apps\":[32]}]]],[\"salla-conditional-offer.cjs\",[[0,\"salla-conditional-offer\",{\"offer\":[32],\"products\":[32]}]]],[\"salla-contacts.cjs\",[[0,\"salla-contacts\",{\"contactsTitle\":[1025,\"contacts-title\"],\"hideTitle\":[4,\"hide-title\"],\"isHeader\":[4,\"is-header\"],\"horizontal\":[4],\"iconsOnly\":[4,\"icons-only\"],\"contacts\":[32],\"iconsList\":[32]}]]],[\"salla-installment.cjs\",[[0,\"salla-installment\",{\"price\":[1],\"language\":[1],\"currency\":[1],\"tamaraIsActive\":[32],\"tabbyIsActive\":[32],\"spotiiIsActive\":[32],\"mispayActive\":[32],\"installment_sheria_text\":[32]}]]],[\"salla-loyalty-prize-item.cjs\",[[0,\"salla-loyalty-prize-item\",{\"item\":[16]}]]],[\"salla-metadata.cjs\",[[0,\"salla-metadata\",{\"entity\":[1],\"entityId\":[2,\"entity-id\"],\"specs\":[32],\"download\":[32]}]]],[\"salla-payments.cjs\",[[0,\"salla-payments\",{\"exclude\":[1040]}]]],[\"salla-social.cjs\",[[0,\"salla-social\",{\"links\":[32],\"iconsList\":[32]}]]],[\"salla-filters-widget.cjs\",[[4,\"salla-filters-widget\",{\"withLoadMore\":[1028,\"with-load-more\"],\"filtersData\":[16],\"option\":[16],\"isOpen\":[32],\"isShowMore\":[32],\"showMoreLabel\":[32],\"showLessLabel\":[32],\"page\":[32],\"setWidgetHeight\":[64],\"reset\":[64],\"showMore\":[64],\"toggleWidget\":[64]}]]],[\"salla-conditional-fields.cjs\",[[4,\"salla-conditional-fields\",null,[[0,\"change\",\"changeHandler\"]]]]],[\"salla-notification-item.cjs\",[[0,\"salla-notification-item\",{\"notification\":[16]}]]],[\"salla-add-product-button_48.cjs\",[[4,\"salla-gifting\",{\"productId\":[2,\"product-id\"],\"widgetTitle\":[1,\"widget-title\"],\"widgetSubtitle\":[1,\"widget-subtitle\"],\"sectionTitle\":[32],\"sectionSubtitle\":[32],\"sectionBtnText\":[32],\"giftDetails\":[32],\"selectImageForYourGift\":[32],\"selectImageOrUpload\":[32],\"selectGiftMessage\":[32],\"giftCustomText\":[32],\"textId\":[32],\"incorrectGiftText\":[32],\"nextStep\":[32],\"senderNameLabel\":[32],\"receiverNameFieldLabel\":[32],\"receiverMobileFieldLabel\":[32],\"receiverEmailFieldLabel\":[32],\"emailPlaceholder\":[32],\"sendLater\":[32],\"selectSendDateAndTime\":[32],\"canNotEditOrderAfterSelectDate\":[32],\"sendGift\":[32],\"donationRequired\":[32],\"currentStep\":[32],\"showCalendar\":[32],\"showGiftText\":[32],\"currentLang\":[32],\"parentClass\":[32],\"errors\":[32],\"gift\":[32],\"selectedGiftTextOption\":[32],\"showTextArea\":[32],\"selectedImage\":[32],\"uploadedImage\":[32],\"selectedText\":[32],\"senderName\":[32],\"errorMessage\":[32],\"hasError\":[32],\"quantity\":[32],\"deliveryDate\":[32],\"timeZone\":[32],\"receiverName\":[32],\"receiverMobile\":[32],\"receiverCountryCode\":[32],\"receiverEmail\":[32],\"open\":[64],\"close\":[64],\"goToStep2\":[64]}],[4,\"salla-loyalty\",{\"prizePoints\":[1544,\"prize-points\"],\"customerPoints\":[1538,\"customer-points\"],\"prizeTitle\":[1537,\"prize-title\"],\"allowEmail\":[4,\"allow-email\"],\"allowMobile\":[4,\"allow-mobile\"],\"requireEmail\":[4,\"require-email\"],\"guestMessage\":[1025,\"guest-message\"],\"loyaltyProgram\":[32],\"buttonLoading\":[32],\"selectedItem\":[32],\"askConfirmation\":[32],\"is_loggedin\":[32],\"hasError\":[32],\"errorMessage\":[32],\"translationLoaded\":[32],\"open\":[64],\"close\":[64],\"resetExchange\":[64],\"exchangeLoyaltyPoint\":[64]}],[4,\"salla-product-size-guide\",{\"guides\":[32],\"productId\":[32],\"placeholder_title\":[32],\"placeholder_description\":[32],\"modal_title\":[32],\"hasError\":[32],\"open\":[64],\"close\":[64]}],[4,\"salla-login-modal\",{\"isEmailAllowed\":[1028,\"is-email-allowed\"],\"isMobileAllowed\":[1028,\"is-mobile-allowed\"],\"isEmailRequired\":[1028,\"is-email-required\"],\"supportWebAuth\":[516,\"support-web-auth\"],\"inline\":[516],\"withoutReload\":[4,\"without-reload\"],\"currentTabName\":[32],\"regType\":[32],\"translationLoaded\":[32],\"isModalOpen\":[32],\"currentPhone\":[32],\"currentEmail\":[32],\"title\":[32],\"emailErrorMsg\":[32],\"firstNameErrorMsg\":[32],\"lastNameErrorMsg\":[32],\"hasError\":[32],\"errorMessage\":[32],\"dragAndDrop\":[32],\"browseFromFiles\":[32],\"customFields\":[32],\"uploadedImage\":[32],\"open\":[64]},[[8,\"verified\",\"onVerified\"]]],[0,\"salla-offer-modal\",{\"offer\":[32],\"offer_name\":[32],\"offer_message\":[32],\"hasError\":[32],\"errorMessage\":[32],\"productID\":[32],\"offer_type\":[32],\"translationLoaded\":[32],\"addToCartLabel\":[32],\"open\":[64],\"showOffer\":[64]}],[0,\"salla-rating-modal\",{\"orderId\":[2,\"order-id\"],\"order\":[32],\"hasError\":[32],\"errorMessage\":[32],\"translationLoaded\":[32],\"open\":[64],\"close\":[64]}],[4,\"salla-scopes\",{\"selection\":[1],\"searchDisplayLimit\":[2,\"search-display-limit\"],\"translationLoaded\":[32],\"mode\":[32],\"current_scope\":[32],\"scopes\":[32],\"originalScopesList\":[32],\"selected_scope\":[32],\"isOpenedBefore\":[32],\"hasError\":[32],\"loading\":[32],\"close\":[64],\"open\":[64],\"handleSubmit\":[64]}],[0,\"salla-localization-modal\",{\"language\":[1537],\"currency\":[1537],\"translationLoaded\":[32],\"languages\":[32],\"currencies\":[32],\"hasError\":[32],\"errorMessage\":[32],\"open\":[64],\"close\":[64],\"submit\":[64]}],[0,\"salla-bottom-alert\",{\"type\":[513],\"icon\":[513],\"message\":[513],\"actionUrl\":[513,\"action-url\"],\"actionLabel\":[513,\"action-label\"],\"storeId\":[32],\"template\":[32],\"loading\":[32],\"templateData\":[32],\"defaultMessage\":[32],\"defaultActionLabel\":[32],\"storeFeatures\":[32],\"storeDetails\":[32],\"storePrice\":[32],\"theDeveloper\":[32],\"templateInformation\":[32],\"buyTheTemplate\":[32],\"isRtl\":[32]}],[0,\"salla-comments\",{\"itemId\":[2,\"item-id\"],\"loadMoreText\":[1,\"load-more-text\"],\"hideForm\":[4,\"hide-form\"],\"blockTitle\":[1,\"block-title\"],\"hideTitle\":[4,\"hide-title\"],\"type\":[1],\"showFormAvatar\":[4,\"show-form-avatar\"],\"comments\":[32],\"pagination\":[32],\"total\":[32],\"showPlaceholder\":[32],\"nextPage\":[32],\"noComments\":[32],\"comment_title\":[32],\"comment_name\":[32],\"placeholder_text\":[32]}],[0,\"salla-quick-order\",{\"quickOrderTitle\":[1025,\"quick-order-title\"],\"subTitle\":[1025,\"sub-title\"],\"payButtonTitle\":[1025,\"pay-button-title\"],\"confirmPayButtonTitle\":[1025,\"confirm-pay-button-title\"],\"agreementText\":[1025,\"agreement-text\"],\"isEmailRequired\":[1028,\"is-email-required\"],\"productId\":[1025,\"product-id\"],\"thanksMessage\":[1025,\"thanks-message\"],\"quickOrderStyle\":[1025,\"quick-order-style\"],\"user\":[32],\"isAvailable\":[32],\"oneClick\":[32],\"expanded\":[32],\"isTermsRequired\":[32],\"countryCode\":[32],\"submitSucess\":[32],\"placeHolderEmail\":[32],\"emailOptional\":[32],\"agreementShowText\":[32],\"agreementModalHead\":[32],\"userNameLabel\":[32],\"termsChecked\":[32]}],[0,\"salla-user-profile\",{\"customFields\":[1,\"custom-fields\"],\"userData\":[32],\"userDefinedFields\":[32],\"disableAction\":[32],\"first_name_trans\":[32],\"last_name_trans\":[32],\"birthday_trans\":[32],\"birthday_placeholder_trans\":[32],\"gender_trans\":[32],\"gender_placeholder_trans\":[32],\"male_trans\":[32],\"female_trans\":[32],\"email_trans\":[32],\"mobile_trans\":[32],\"save_btn_trans\":[32],\"drag_and_drop_trans\":[32],\"browse_trans\":[32],\"email_required_trans\":[32],\"invalid_email_trans\":[32],\"setCustomFields\":[64]}],[0,\"salla-user-settings\",{\"isNotifiable\":[516,\"is-notifiable\"],\"deactivateAccount\":[32],\"promotionalMsgs\":[32],\"deactivateDesc\":[32],\"promotionalMsgsDesc\":[32],\"sorryForLeavingText\":[32],\"warningText\":[32],\"keepAccount\":[32],\"buttonLoading\":[32]}],[0,\"salla-search\",{\"inline\":[4],\"oval\":[4],\"height\":[2],\"maxWords\":[2,\"max-words\"],\"showAction\":[4,\"show-action\"],\"translationLoaded\":[32],\"results\":[32],\"loading\":[32],\"typing\":[32],\"debounce\":[32],\"search_term\":[32]},[[0,\"keydown\",\"handleKeyDown\"]]],[0,\"salla-menu\",{\"source\":[1],\"sourceValue\":[1,\"source-value\"],\"topnav\":[4],\"useReactLink\":[4,\"use-react-link\"],\"limit\":[2],\"menus\":[32]}],[4,\"salla-social-share\",{\"url\":[513],\"urlName\":[513,\"url-name\"],\"platforms\":[513],\"opened\":[32],\"allPlatforms\":[32],\"platformIcons\":[32],\"convertedPlatforms\":[32],\"open\":[64],\"refresh\":[64]}],[0,\"salla-breadcrumb\",{\"breadcrumbs\":[32]}],[4,\"salla-cart-summary\",{\"showCartLabel\":[4,\"show-cart-label\"],\"cartSummaryCount\":[32],\"cartSummaryTotal\":[32],\"cartLabel\":[32],\"animateToCart\":[64]}],[4,\"salla-infinite-scroll\",{\"nextPage\":[1,\"next-page\"],\"autoload\":[1028],\"container\":[1],\"loadMoreText\":[1,\"load-more-text\"],\"item\":[1],\"loadMore\":[32],\"noMore\":[32],\"failedToLoad\":[32]}],[0,\"salla-maintenance-alert\",{\"title\":[32],\"message\":[32],\"buttonTitle\":[32]}],[4,\"salla-quantity-input\",{\"cartItemId\":[8,\"cart-item-id\"],\"quantity\":[32],\"fireChangeEvent\":[32],\"decrease\":[64],\"increase\":[64],\"setValue\":[64]}],[4,\"salla-user-menu\",{\"inline\":[516],\"avatarOnly\":[516,\"avatar-only\"],\"showHeader\":[516,\"show-header\"],\"relativeDropdown\":[516,\"relative-dropdown\"],\"accountLoading\":[32],\"opened\":[32],\"notifications\":[32],\"orders\":[32],\"pending_orders\":[32],\"wishlist\":[32],\"profile\":[32],\"rating\":[32],\"logout\":[32],\"hello\":[32],\"first_name\":[32],\"last_name\":[32],\"avatar\":[32],\"is_loggedIn\":[32],\"badges\":[32],\"hasBadges\":[32],\"OrderUpdate\":[32]}],[4,\"salla-map\",{\"name\":[1],\"required\":[4],\"readonly\":[4],\"searchable\":[1028],\"lat\":[1026],\"lng\":[1026],\"apiKey\":[1025,\"api-key\"],\"modalTitle\":[1,\"modal-title\"],\"zoom\":[1026],\"theme\":[1025],\"modalActivityTitle\":[32],\"confirmButtonTitle\":[32],\"locateButtonTitle\":[32],\"locateButtonEdit\":[32],\"searchPlaceholder\":[32],\"searchInputValue\":[32],\"formattedAddress\":[32],\"geolocationError\":[32],\"searchInput\":[32],\"mapInput\":[32],\"mapElement\":[32],\"selectedLat\":[32],\"selectedLng\":[32],\"open\":[64]}],[4,\"salla-verify\",{\"display\":[1],\"type\":[1025],\"autoReload\":[4,\"auto-reload\"],\"supportWebAuth\":[4,\"support-web-auth\"],\"translationLoaded\":[32],\"title\":[32],\"resendAfter\":[32],\"hasError\":[32],\"errorMessage\":[32],\"isProfileVerify\":[32],\"getCode\":[64],\"open\":[64]}],[0,\"salla-comment-form\",{\"type\":[1537],\"showAvatar\":[4,\"show-avatar\"],\"itemId\":[1544,\"item-id\"],\"placeholder\":[32],\"submitText\":[32],\"canComment\":[32]}],[4,\"salla-color-picker\",{\"name\":[1],\"required\":[4],\"color\":[1537],\"format\":[1],\"showCancelButton\":[4,\"show-cancel-button\"],\"showTextField\":[4,\"show-text-field\"],\"enableAlpha\":[4,\"enable-alpha\"],\"widgetColor\":[32],\"setPickerOption\":[64],\"movePopUp\":[64],\"setColorValue\":[64],\"openPicker\":[64],\"closePicker\":[64],\"destroyPicker\":[64]}],[0,\"salla-products-list\",{\"source\":[1537],\"sourceValue\":[1032,\"source-value\"],\"limit\":[1026],\"sortBy\":[1025,\"sort-by\"],\"filtersResults\":[1540,\"filters-results\"],\"horizontalCards\":[516,\"horizontal-cards\"],\"rowCards\":[516,\"row-cards\"],\"autoload\":[1028],\"loadMoreText\":[1,\"load-more-text\"],\"productCardComponent\":[1,\"product-card-component\"],\"page\":[32],\"nextPage\":[32],\"hasInfiniteScroll\":[32],\"hasCustomComponent\":[32],\"sourceValueIsValid\":[32],\"placeholderText\":[32],\"endOfText\":[32],\"failedLoadMore\":[32],\"currentPage\":[32],\"currentCategoryIdFilter\":[32],\"isReady\":[32],\"showPlaceholder\":[32],\"parsedFilters\":[32],\"setFilters\":[64],\"reload\":[64]}],[4,\"salla-product-card\",{\"product\":[1],\"horizontal\":[4],\"shadowOnHover\":[4,\"shadow-on-hover\"],\"hideAddBtn\":[4,\"hide-add-btn\"],\"fullImage\":[4,\"full-image\"],\"minimal\":[4],\"isSpecial\":[4,\"is-special\"],\"showQuantity\":[4,\"show-quantity\"],\"productData\":[32],\"fitImageHeight\":[32],\"remained\":[32],\"outOfStock\":[32],\"donationAmount\":[32],\"startingPrice\":[32],\"addToCart\":[32],\"placeholder\":[32]}],[0,\"salla-comment-item\",{\"comment\":[16],\"has_bought_trans\":[32],\"rated_trans\":[32],\"waiting_approval_trans\":[32],\"has_order_trans\":[32]}],[4,\"salla-tab-content\",{\"name\":[1],\"isSelected\":[32],\"getChild\":[64]}],[4,\"salla-tab-header\",{\"name\":[1],\"activeClass\":[1,\"active-class\"],\"height\":[8],\"centered\":[4],\"isSelected\":[32],\"getChild\":[64]}],[4,\"salla-tabs\",{\"backgroundColor\":[1,\"background-color\"],\"vertical\":[4]},[[0,\"tabSelected\",\"onSelectedTab\"]]],[4,\"salla-add-product-button\",{\"channels\":[513],\"subscribedOptions\":[1,\"subscribed-options\"],\"quickBuy\":[1540,\"quick-buy\"],\"quantity\":[514],\"donatingAmount\":[514,\"donating-amount\"],\"notifyOptionsAvailability\":[516,\"notify-options-availability\"],\"productId\":[520,\"product-id\"],\"supportStickyBar\":[516,\"support-sticky-bar\"],\"productStatus\":[513,\"product-status\"],\"productType\":[513,\"product-type\"],\"hasOutOfStockOption\":[32],\"hasSubscribedOptions\":[32],\"selectedOptions\":[32],\"showQuickBuy\":[32],\"isApplePayActive\":[32]}],[0,\"salla-count-down\",{\"date\":[1],\"boxed\":[4],\"size\":[1],\"color\":[1],\"labeled\":[4],\"endText\":[1,\"end-text\"],\"digits\":[1],\"endOfDay\":[4,\"end-of-day\"],\"daysLabel\":[32],\"hoursLabel\":[32],\"minutesLabel\":[32],\"secondsLabel\":[32],\"endLabel\":[32],\"invalidDate\":[32],\"offerEnded\":[32],\"countInterval\":[32],\"days\":[32],\"hours\":[32],\"minutes\":[32],\"seconds\":[32],\"endCountDown\":[64]}],[0,\"salla-datetime-picker\",{\"value\":[1537],\"required\":[4],\"name\":[513],\"placeholder\":[1],\"allowInput\":[4,\"allow-input\"],\"allowInvalidPreload\":[4,\"allow-invalid-preload\"],\"altFormat\":[1,\"alt-format\"],\"altInput\":[4,\"alt-input\"],\"altInputClass\":[1,\"alt-input-class\"],\"appendTo\":[16],\"ariaDateFormat\":[1,\"aria-date-format\"],\"autoFillDefaultTime\":[4,\"auto-fill-default-time\"],\"clickOpens\":[4,\"click-opens\"],\"closeOnSelect\":[4,\"close-on-select\"],\"conjunction\":[1],\"dateFormat\":[1,\"date-format\"],\"defaultDate\":[8,\"default-date\"],\"defaultHour\":[2,\"default-hour\"],\"defaultMinute\":[2,\"default-minute\"],\"defaultSeconds\":[2,\"default-seconds\"],\"disable\":[16],\"disableMobile\":[4,\"disable-mobile\"],\"enable\":[16],\"enableSeconds\":[4,\"enable-seconds\"],\"enableTime\":[4,\"enable-time\"],\"formatDate\":[16],\"hourIncrement\":[2,\"hour-increment\"],\"inline\":[4],\"locale\":[1],\"maxDate\":[8,\"max-date\"],\"maxTime\":[8,\"max-time\"],\"minDate\":[8,\"min-date\"],\"minTime\":[8,\"min-time\"],\"minuteIncrement\":[2,\"minute-increment\"],\"mode\":[1],\"monthSelectorType\":[1,\"month-selector-type\"],\"nextArrow\":[1,\"next-arrow\"],\"noCalendar\":[4,\"no-calendar\"],\"dateParser\":[16],\"position\":[1],\"positionElement\":[16],\"prevArrow\":[1,\"prev-arrow\"],\"shorthandCurrentMonth\":[4,\"shorthand-current-month\"],\"static\":[4],\"showMonths\":[2,\"show-months\"],\"time_24hr\":[4,\"time_-2-4hr\"],\"weekNumbers\":[4,\"week-numbers\"],\"wrap\":[4]}],[0,\"salla-product-availability\",{\"channels\":[1],\"notifyOptionsAvailability\":[4,\"notify-options-availability\"],\"productId\":[2,\"product-id\"],\"isSubscribed\":[1028,\"is-subscribed\"],\"translationLoaded\":[32],\"title_\":[32],\"isVisitorSubscribed\":[32]}],[0,\"salla-file-upload\",{\"value\":[1537],\"files\":[513],\"height\":[513],\"cartItemId\":[1,\"cart-item-id\"],\"profileImage\":[516,\"profile-image\"],\"name\":[1537],\"payloadName\":[1,\"payload-name\"],\"accept\":[1537],\"fileId\":[2,\"file-id\"],\"url\":[1025],\"method\":[1],\"formData\":[1,\"form-data\"],\"required\":[4],\"maxFileSize\":[1,\"max-file-size\"],\"disabled\":[4],\"allowDrop\":[4,\"allow-drop\"],\"allowBrowse\":[4,\"allow-browse\"],\"allowPaste\":[4,\"allow-paste\"],\"allowMultiple\":[4,\"allow-multiple\"],\"allowReplace\":[4,\"allow-replace\"],\"allowRevert\":[4,\"allow-revert\"],\"allowRemove\":[4,\"allow-remove\"],\"allowProcess\":[4,\"allow-process\"],\"allowReorder\":[4,\"allow-reorder\"],\"storeAsFile\":[4,\"store-as-file\"],\"forceRevert\":[4,\"force-revert\"],\"maxFilesCount\":[2,\"max-files-count\"],\"maxParallelUploads\":[2,\"max-parallel-uploads\"],\"checkValidity\":[4,\"check-validity\"],\"itemInsertLocation\":[1,\"item-insert-location\"],\"itemInsertInterval\":[2,\"item-insert-interval\"],\"credits\":[4],\"dropOnPage\":[4,\"drop-on-page\"],\"dropOnElement\":[4,\"drop-on-element\"],\"dropValidation\":[4,\"drop-validation\"],\"ignoredFiles\":[16],\"instantUpload\":[1028,\"instant-upload\"],\"chunkUploads\":[4,\"chunk-uploads\"],\"chunkForce\":[4,\"chunk-force\"],\"chunkSize\":[2,\"chunk-size\"],\"chunkRetryDelays\":[16],\"labelDecimalSeparator\":[1,\"label-decimal-separator\"],\"labelThousandsSeparator\":[1,\"label-thousands-separator\"],\"labelIdle\":[1025,\"label-idle\"],\"iconRemove\":[1,\"icon-remove\"],\"iconProcess\":[1,\"icon-process\"],\"iconRetry\":[1,\"icon-retry\"],\"iconUndo\":[1,\"icon-undo\"],\"setOption\":[64]}],[4,\"salla-list-tile\",{\"href\":[1],\"target\":[1]}],[0,\"salla-progress-bar\",{\"donation\":[1],\"target\":[1026],\"value\":[1026],\"height\":[1025],\"header\":[1025],\"stripped\":[1028],\"message\":[1025],\"unit\":[1025],\"color\":[1025]}],[0,\"salla-quick-buy\",{\"type\":[1025],\"productId\":[1025,\"product-id\"],\"cartId\":[1025,\"cart-id\"],\"amount\":[1538],\"currency\":[1025],\"options\":[16],\"isRequireShipping\":[1028,\"is-require-shipping\"],\"applePayOnly\":[1028,\"apple-pay-only\"],\"isApplePayActive\":[32],\"quickBuy\":[32]}],[0,\"salla-rating-stars\",{\"name\":[1],\"size\":[1],\"value\":[2],\"reviews\":[2]}],[0,\"salla-skeleton\",{\"type\":[1],\"width\":[1],\"height\":[1]}],[4,\"salla-slider\",{\"blockTitle\":[513,\"block-title\"],\"listenToThumbnailsOption\":[516,\"listen-to-thumbnails-option\"],\"blockSubtitle\":[513,\"block-subtitle\"],\"displayAllUrl\":[513,\"display-all-url\"],\"arrowsCentered\":[516,\"arrows-centered\"],\"verticalThumbs\":[516,\"vertical-thumbs\"],\"gridThumbs\":[516,\"grid-thumbs\"],\"vertical\":[516],\"autoHeight\":[516,\"auto-height\"],\"showControls\":[516,\"show-controls\"],\"controlsOuter\":[516,\"controls-outer\"],\"showThumbsControls\":[4,\"show-thumbs-controls\"],\"autoPlay\":[4,\"auto-play\"],\"slidesPerView\":[1,\"slides-per-view\"],\"pagination\":[4],\"centered\":[4],\"loop\":[4],\"direction\":[1537],\"type\":[1],\"sliderConfig\":[520,\"slider-config\"],\"thumbsConfig\":[520,\"thumbs-config\"],\"currentIndex\":[32],\"isEnd\":[32],\"isBeginning\":[32],\"swiperScript\":[32],\"displayAllTitle\":[32],\"windowWidth\":[32],\"slideTo\":[64],\"slideNext\":[64],\"slidePrev\":[64],\"slideToLoop\":[64],\"slideNextLoop\":[64],\"slidePrevLoop\":[64],\"slideReset\":[64],\"slideToClosest\":[64],\"update\":[64],\"updateAutoHeight\":[64],\"updateSlides\":[64],\"updateProgress\":[64],\"updateSlidesClasses\":[64],\"getSlides\":[64]}],[4,\"salla-placeholder\",{\"icon\":[1],\"alignment\":[1],\"iconSize\":[1,\"icon-size\"],\"translationLoaded\":[32]}],[0,\"salla-tel-input\",{\"phone\":[1025],\"autofocus\":[516],\"name\":[1],\"countryCode\":[1025,\"country-code\"],\"mobileRequired\":[32],\"countryCodeLabel\":[32],\"mobileLabel\":[32],\"tooShort\":[32],\"tooLong\":[32],\"invalidCountryCode\":[32],\"invalidNumber\":[32],\"errorMap\":[32],\"getValues\":[64],\"isValid\":[64]}],[4,\"salla-modal\",{\"isClosable\":[1028,\"is-closable\"],\"width\":[513],\"position\":[513],\"visible\":[516],\"hasSkeleton\":[516,\"has-skeleton\"],\"isLoading\":[1540,\"is-loading\"],\"subTitleFirst\":[4,\"sub-title-first\"],\"noPadding\":[4,\"no-padding\"],\"subTitle\":[1,\"sub-title\"],\"centered\":[4],\"iconStyle\":[1,\"icon-style\"],\"modalTitle\":[32],\"open\":[64],\"close\":[64],\"setTitle\":[64],\"loading\":[64],\"stopLoading\":[64]},[[0,\"keyup\",\"handleKeyUp\"]]],[0,\"salla-loading\",{\"size\":[8],\"width\":[8],\"color\":[1],\"bgColor\":[1,\"bg-color\"]}],[4,\"salla-button\",{\"shape\":[513],\"color\":[513],\"fill\":[513],\"size\":[513],\"width\":[513],\"loading\":[516],\"disabled\":[516],\"loaderPosition\":[1,\"loader-position\"],\"href\":[1],\"type\":[513],\"load\":[64],\"stop\":[64],\"setText\":[64],\"disable\":[64],\"enable\":[64]}]]],[\"salla-price-range.cjs\",[[0,\"salla-price-range\",{\"minPrice\":[1032,\"min-price\"],\"maxPrice\":[1032,\"max-price\"],\"option\":[16],\"filtersData\":[520,\"filters-data\"],\"min\":[32],\"max\":[32],\"priceOptions\":[32],\"moreThanLabel\":[32],\"lessThanLabel\":[32],\"toLabel\":[32],\"fromLabel\":[32],\"typing\":[32],\"isMin\":[32],\"isRTL\":[32],\"reset\":[64]}]]]]"), options);
26
+ return index.bootstrapLazy(JSON.parse("[[\"salla-offer.cjs\",[[0,\"salla-offer\",{\"productCardComponent\":[1,\"product-card-component\"],\"offersList\":[32],\"userCurrency\":[32],\"isMultipleBank\":[32],\"title\":[32],\"currentPage\":[32],\"hasCustomComponent\":[32],\"isBankOffer\":[32],\"canRender\":[32],\"showOffer\":[32],\"offer_with_price_text\":[32],\"with_discount_text\":[32],\"product_discount_text\":[32],\"special_offer_text\":[32],\"multipleBankOfferTitleText\":[32],\"multipleBankOfferTitleDescription\":[32],\"buy_quantity_text\":[32]}]]],[\"salla-products-slider.cjs\",[[0,\"salla-products-slider\",{\"blockTitle\":[1,\"block-title\"],\"subTitle\":[1,\"sub-title\"],\"sliderId\":[1,\"slider-id\"],\"displayAllUrl\":[1,\"display-all-url\"],\"autoplay\":[1028],\"source\":[1537],\"sourceValue\":[1,\"source-value\"],\"limit\":[1026],\"sliderConfig\":[520,\"slider-config\"],\"productCardComponent\":[1,\"product-card-component\"],\"productsData\":[32],\"isReady\":[32],\"sourceValueIsValid\":[32],\"hasCustomComponent\":[32],\"apiUrl\":[32],\"parsedSourceValue\":[32]}]]],[\"salla-product-options.cjs\",[[0,\"salla-product-options\",{\"productId\":[2,\"product-id\"],\"options\":[1],\"optionsData\":[32],\"outOfStockText\":[32],\"donationAmount\":[32],\"selectDonationAmount\":[32],\"selectAmount\":[32],\"isCustomDonation\":[32],\"selectedOptions\":[32],\"canDisabled\":[32],\"selectedSkus\":[32],\"selectedOutSkus\":[32],\"getSelectedOptionsData\":[64],\"reportValidity\":[64],\"hasOutOfStockOption\":[64],\"getSelectedOptions\":[64],\"getOption\":[64]}]]],[\"salla-filters.cjs\",[[0,\"salla-filters\",{\"filters\":[1040],\"isSidebarOpen\":[32],\"filtersData\":[32],\"apply\":[32],\"reset\":[32],\"getFilters\":[64],\"applyFilters\":[64],\"resetFilters\":[64]}]]],[\"salla-notifications.cjs\",[[0,\"salla-notifications\",{\"loadMoreText\":[1,\"load-more-text\"],\"itemPerPage\":[2,\"item-per-page\"],\"pagination\":[32],\"total\":[32],\"showPlaceholder\":[32],\"nextPage\":[32],\"no_notifications_trans\":[32],\"load_more_text_trans\":[32]}]]],[\"salla-order-summary.cjs\",[[0,\"salla-order-summary\",{\"orderId\":[514,\"order-id\"],\"codeCopied\":[32],\"noItemFound\":[32],\"order_items\":[32]}]]],[\"salla-reviews.cjs\",[[0,\"salla-reviews\",{\"displayAllLink\":[516,\"display-all-link\"],\"source\":[513],\"sourceValue\":[513,\"source-value\"],\"limit\":[514],\"type\":[1],\"sort\":[1],\"hideCustomerInfo\":[4,\"hide-customer-info\"],\"reviews\":[32],\"isRTL\":[32],\"showReviews\":[32],\"testimonialText\":[32],\"displayAllLinkText\":[32]}]]],[\"salla-conditional-offer.cjs\",[[0,\"salla-conditional-offer\",{\"offer\":[32],\"products\":[32],\"isLoading\":[32],\"canRender\":[32]}]]],[\"salla-orders.cjs\",[[0,\"salla-orders\",{\"params\":[16],\"loadMoreText\":[1,\"load-more-text\"],\"orderNumberText\":[32],\"totalOrderText\":[32],\"orderDateText\":[32],\"orderStatusText\":[32],\"noOrderText\":[32],\"load_more_text_trans\":[32],\"languageCode\":[32],\"orders\":[32],\"pagination\":[32],\"hasInfiniteScroll\":[32],\"total\":[32],\"nextPage\":[32],\"showPlaceholder\":[32]}]]],[\"salla-advertisement.cjs\",[[0,\"salla-advertisement\",{\"position\":[32],\"advertisements\":[32],\"advertIcon\":[32],\"currentSlug\":[32]}]]],[\"salla-app-install-alert.cjs\",[[0,\"salla-app-install-alert\",{\"data\":[32],\"ctaLink\":[32],\"open\":[32],\"closing\":[32]}]]],[\"salla-apps-icons.cjs\",[[0,\"salla-apps-icons\",{\"hideTitle\":[4,\"hide-title\"],\"appsTitle\":[1,\"apps-title\"],\"vertical\":[4],\"apps\":[32]}]]],[\"salla-contacts.cjs\",[[0,\"salla-contacts\",{\"contactsTitle\":[1025,\"contacts-title\"],\"hideTitle\":[4,\"hide-title\"],\"isHeader\":[4,\"is-header\"],\"horizontal\":[4],\"iconsOnly\":[4,\"icons-only\"],\"contacts\":[32],\"iconsList\":[32]}]]],[\"salla-installment.cjs\",[[0,\"salla-installment\",{\"price\":[1],\"language\":[1],\"currency\":[1],\"tamaraIsActive\":[32],\"tabbyIsActive\":[32],\"spotiiIsActive\":[32],\"mispayActive\":[32],\"installment_sheria_text\":[32]}]]],[\"salla-loyalty-prize-item.cjs\",[[0,\"salla-loyalty-prize-item\",{\"item\":[16]}]]],[\"salla-metadata.cjs\",[[0,\"salla-metadata\",{\"entity\":[1],\"entityId\":[2,\"entity-id\"],\"specs\":[32],\"download\":[32]}]]],[\"salla-payments.cjs\",[[0,\"salla-payments\",{\"exclude\":[1040]}]]],[\"salla-social.cjs\",[[0,\"salla-social\",{\"links\":[32],\"iconsList\":[32]}]]],[\"salla-filters-widget.cjs\",[[4,\"salla-filters-widget\",{\"withLoadMore\":[1028,\"with-load-more\"],\"filtersData\":[16],\"option\":[16],\"isOpen\":[32],\"isShowMore\":[32],\"showMoreLabel\":[32],\"showLessLabel\":[32],\"page\":[32],\"setWidgetHeight\":[64],\"reset\":[64],\"showMore\":[64],\"toggleWidget\":[64]}]]],[\"salla-conditional-fields.cjs\",[[4,\"salla-conditional-fields\",null,[[0,\"change\",\"changeHandler\"]]]]],[\"salla-notification-item.cjs\",[[0,\"salla-notification-item\",{\"notification\":[16]}]]],[\"salla-add-product-button_48.cjs\",[[4,\"salla-gifting\",{\"productId\":[2,\"product-id\"],\"widgetTitle\":[1,\"widget-title\"],\"widgetSubtitle\":[1,\"widget-subtitle\"],\"sectionTitle\":[32],\"sectionSubtitle\":[32],\"sectionBtnText\":[32],\"giftDetails\":[32],\"selectImageForYourGift\":[32],\"selectImageOrUpload\":[32],\"selectGiftMessage\":[32],\"giftCustomText\":[32],\"textId\":[32],\"incorrectGiftText\":[32],\"nextStep\":[32],\"senderNameLabel\":[32],\"receiverNameFieldLabel\":[32],\"receiverMobileFieldLabel\":[32],\"receiverEmailFieldLabel\":[32],\"emailPlaceholder\":[32],\"sendLater\":[32],\"selectSendDateAndTime\":[32],\"canNotEditOrderAfterSelectDate\":[32],\"sendGift\":[32],\"donationRequired\":[32],\"currentStep\":[32],\"showCalendar\":[32],\"showGiftText\":[32],\"currentLang\":[32],\"parentClass\":[32],\"errors\":[32],\"gift\":[32],\"selectedGiftTextOption\":[32],\"showTextArea\":[32],\"selectedImage\":[32],\"uploadedImage\":[32],\"selectedText\":[32],\"senderName\":[32],\"errorMessage\":[32],\"hasError\":[32],\"quantity\":[32],\"deliveryDate\":[32],\"timeZone\":[32],\"receiverName\":[32],\"receiverMobile\":[32],\"receiverCountryCode\":[32],\"receiverEmail\":[32],\"open\":[64],\"close\":[64],\"goToStep2\":[64]}],[4,\"salla-loyalty\",{\"prizePoints\":[1544,\"prize-points\"],\"customerPoints\":[1538,\"customer-points\"],\"prizeTitle\":[1537,\"prize-title\"],\"allowEmail\":[4,\"allow-email\"],\"allowMobile\":[4,\"allow-mobile\"],\"requireEmail\":[4,\"require-email\"],\"guestMessage\":[1025,\"guest-message\"],\"loyaltyProgram\":[32],\"buttonLoading\":[32],\"selectedItem\":[32],\"askConfirmation\":[32],\"is_loggedin\":[32],\"hasError\":[32],\"errorMessage\":[32],\"translationLoaded\":[32],\"open\":[64],\"close\":[64],\"resetExchange\":[64],\"exchangeLoyaltyPoint\":[64]}],[4,\"salla-product-size-guide\",{\"guides\":[32],\"productId\":[32],\"placeholder_title\":[32],\"placeholder_description\":[32],\"modal_title\":[32],\"hasError\":[32],\"open\":[64],\"close\":[64]}],[4,\"salla-login-modal\",{\"isEmailAllowed\":[1028,\"is-email-allowed\"],\"isMobileAllowed\":[1028,\"is-mobile-allowed\"],\"isEmailRequired\":[1028,\"is-email-required\"],\"supportWebAuth\":[516,\"support-web-auth\"],\"inline\":[516],\"withoutReload\":[4,\"without-reload\"],\"currentTabName\":[32],\"regType\":[32],\"translationLoaded\":[32],\"isModalOpen\":[32],\"currentPhone\":[32],\"currentEmail\":[32],\"title\":[32],\"emailErrorMsg\":[32],\"firstNameErrorMsg\":[32],\"lastNameErrorMsg\":[32],\"hasError\":[32],\"errorMessage\":[32],\"dragAndDrop\":[32],\"browseFromFiles\":[32],\"customFields\":[32],\"uploadedImage\":[32],\"open\":[64]},[[8,\"verified\",\"onVerified\"]]],[0,\"salla-offer-modal\",{\"offer\":[32],\"offer_name\":[32],\"offer_message\":[32],\"hasError\":[32],\"errorMessage\":[32],\"productID\":[32],\"offer_type\":[32],\"translationLoaded\":[32],\"addToCartLabel\":[32],\"open\":[64],\"showOffer\":[64]}],[0,\"salla-rating-modal\",{\"orderId\":[2,\"order-id\"],\"order\":[32],\"hasError\":[32],\"errorMessage\":[32],\"translationLoaded\":[32],\"open\":[64],\"close\":[64]}],[4,\"salla-scopes\",{\"selection\":[1],\"searchDisplayLimit\":[2,\"search-display-limit\"],\"translationLoaded\":[32],\"mode\":[32],\"current_scope\":[32],\"scopes\":[32],\"originalScopesList\":[32],\"selected_scope\":[32],\"isOpenedBefore\":[32],\"hasError\":[32],\"loading\":[32],\"close\":[64],\"open\":[64],\"handleSubmit\":[64]}],[0,\"salla-localization-modal\",{\"language\":[1537],\"currency\":[1537],\"translationLoaded\":[32],\"languages\":[32],\"currencies\":[32],\"hasError\":[32],\"errorMessage\":[32],\"open\":[64],\"close\":[64],\"submit\":[64]}],[0,\"salla-bottom-alert\",{\"type\":[513],\"icon\":[513],\"message\":[513],\"actionUrl\":[513,\"action-url\"],\"actionLabel\":[513,\"action-label\"],\"storeId\":[32],\"template\":[32],\"loading\":[32],\"templateData\":[32],\"defaultMessage\":[32],\"defaultActionLabel\":[32],\"storeFeatures\":[32],\"storeDetails\":[32],\"storePrice\":[32],\"theDeveloper\":[32],\"templateInformation\":[32],\"buyTheTemplate\":[32],\"isRtl\":[32]}],[0,\"salla-comments\",{\"itemId\":[2,\"item-id\"],\"loadMoreText\":[1,\"load-more-text\"],\"hideForm\":[4,\"hide-form\"],\"blockTitle\":[1,\"block-title\"],\"hideTitle\":[4,\"hide-title\"],\"type\":[1],\"showFormAvatar\":[4,\"show-form-avatar\"],\"comments\":[32],\"pagination\":[32],\"total\":[32],\"showPlaceholder\":[32],\"nextPage\":[32],\"noComments\":[32],\"comment_title\":[32],\"comment_name\":[32],\"placeholder_text\":[32]}],[0,\"salla-quick-order\",{\"quickOrderTitle\":[1025,\"quick-order-title\"],\"subTitle\":[1025,\"sub-title\"],\"payButtonTitle\":[1025,\"pay-button-title\"],\"confirmPayButtonTitle\":[1025,\"confirm-pay-button-title\"],\"agreementText\":[1025,\"agreement-text\"],\"isEmailRequired\":[1028,\"is-email-required\"],\"productId\":[1025,\"product-id\"],\"thanksMessage\":[1025,\"thanks-message\"],\"quickOrderStyle\":[1025,\"quick-order-style\"],\"user\":[32],\"isAvailable\":[32],\"oneClick\":[32],\"expanded\":[32],\"isTermsRequired\":[32],\"countryCode\":[32],\"submitSucess\":[32],\"placeHolderEmail\":[32],\"emailOptional\":[32],\"agreementShowText\":[32],\"agreementModalHead\":[32],\"userNameLabel\":[32],\"termsChecked\":[32]}],[0,\"salla-user-profile\",{\"customFields\":[1,\"custom-fields\"],\"userData\":[32],\"userDefinedFields\":[32],\"disableAction\":[32],\"first_name_trans\":[32],\"last_name_trans\":[32],\"birthday_trans\":[32],\"birthday_placeholder_trans\":[32],\"gender_trans\":[32],\"gender_placeholder_trans\":[32],\"male_trans\":[32],\"female_trans\":[32],\"email_trans\":[32],\"mobile_trans\":[32],\"save_btn_trans\":[32],\"drag_and_drop_trans\":[32],\"browse_trans\":[32],\"email_required_trans\":[32],\"invalid_email_trans\":[32],\"setCustomFields\":[64]}],[0,\"salla-user-settings\",{\"isNotifiable\":[516,\"is-notifiable\"],\"deactivateAccount\":[32],\"promotionalMsgs\":[32],\"deactivateDesc\":[32],\"promotionalMsgsDesc\":[32],\"sorryForLeavingText\":[32],\"warningText\":[32],\"keepAccount\":[32],\"buttonLoading\":[32]}],[0,\"salla-search\",{\"inline\":[4],\"oval\":[4],\"height\":[2],\"maxWords\":[2,\"max-words\"],\"showAction\":[4,\"show-action\"],\"translationLoaded\":[32],\"results\":[32],\"loading\":[32],\"typing\":[32],\"debounce\":[32],\"search_term\":[32]},[[0,\"keydown\",\"handleKeyDown\"]]],[0,\"salla-menu\",{\"source\":[1],\"sourceValue\":[1,\"source-value\"],\"topnav\":[4],\"useReactLink\":[4,\"use-react-link\"],\"limit\":[2],\"menus\":[32]}],[4,\"salla-social-share\",{\"url\":[513],\"urlName\":[513,\"url-name\"],\"platforms\":[513],\"opened\":[32],\"allPlatforms\":[32],\"platformIcons\":[32],\"convertedPlatforms\":[32],\"open\":[64],\"refresh\":[64]}],[0,\"salla-breadcrumb\",{\"breadcrumbs\":[32]}],[4,\"salla-cart-summary\",{\"showCartLabel\":[4,\"show-cart-label\"],\"cartSummaryCount\":[32],\"cartSummaryTotal\":[32],\"cartLabel\":[32],\"animateToCart\":[64]}],[4,\"salla-infinite-scroll\",{\"nextPage\":[1,\"next-page\"],\"autoload\":[1028],\"container\":[1],\"loadMoreText\":[1,\"load-more-text\"],\"item\":[1],\"loadMore\":[32],\"noMore\":[32],\"failedToLoad\":[32]}],[0,\"salla-maintenance-alert\",{\"title\":[32],\"message\":[32],\"buttonTitle\":[32]}],[4,\"salla-quantity-input\",{\"cartItemId\":[8,\"cart-item-id\"],\"quantity\":[32],\"fireChangeEvent\":[32],\"decrease\":[64],\"increase\":[64],\"setValue\":[64]}],[4,\"salla-user-menu\",{\"inline\":[516],\"avatarOnly\":[516,\"avatar-only\"],\"showHeader\":[516,\"show-header\"],\"relativeDropdown\":[516,\"relative-dropdown\"],\"accountLoading\":[32],\"opened\":[32],\"notifications\":[32],\"orders\":[32],\"pending_orders\":[32],\"wishlist\":[32],\"profile\":[32],\"rating\":[32],\"logout\":[32],\"hello\":[32],\"first_name\":[32],\"last_name\":[32],\"avatar\":[32],\"is_loggedIn\":[32],\"badges\":[32],\"hasBadges\":[32],\"OrderUpdate\":[32]}],[4,\"salla-map\",{\"name\":[1],\"required\":[4],\"readonly\":[4],\"searchable\":[1028],\"lat\":[1026],\"lng\":[1026],\"apiKey\":[1025,\"api-key\"],\"modalTitle\":[1,\"modal-title\"],\"zoom\":[1026],\"theme\":[1025],\"modalActivityTitle\":[32],\"confirmButtonTitle\":[32],\"locateButtonTitle\":[32],\"locateButtonEdit\":[32],\"searchPlaceholder\":[32],\"searchInputValue\":[32],\"formattedAddress\":[32],\"geolocationError\":[32],\"searchInput\":[32],\"mapInput\":[32],\"mapElement\":[32],\"selectedLat\":[32],\"selectedLng\":[32],\"open\":[64]}],[4,\"salla-verify\",{\"display\":[1],\"type\":[1025],\"autoReload\":[4,\"auto-reload\"],\"supportWebAuth\":[4,\"support-web-auth\"],\"translationLoaded\":[32],\"title\":[32],\"resendAfter\":[32],\"hasError\":[32],\"errorMessage\":[32],\"isProfileVerify\":[32],\"getCode\":[64],\"open\":[64]}],[0,\"salla-comment-form\",{\"type\":[1537],\"showAvatar\":[4,\"show-avatar\"],\"itemId\":[1544,\"item-id\"],\"placeholder\":[32],\"submitText\":[32],\"canComment\":[32]}],[4,\"salla-color-picker\",{\"name\":[1],\"required\":[4],\"color\":[1537],\"format\":[1],\"showCancelButton\":[4,\"show-cancel-button\"],\"showTextField\":[4,\"show-text-field\"],\"enableAlpha\":[4,\"enable-alpha\"],\"widgetColor\":[32],\"setPickerOption\":[64],\"movePopUp\":[64],\"setColorValue\":[64],\"openPicker\":[64],\"closePicker\":[64],\"destroyPicker\":[64]}],[0,\"salla-products-list\",{\"source\":[1537],\"sourceValue\":[1032,\"source-value\"],\"limit\":[1026],\"sortBy\":[1025,\"sort-by\"],\"filtersResults\":[1540,\"filters-results\"],\"horizontalCards\":[516,\"horizontal-cards\"],\"rowCards\":[516,\"row-cards\"],\"autoload\":[1028],\"loadMoreText\":[1,\"load-more-text\"],\"productCardComponent\":[1,\"product-card-component\"],\"page\":[32],\"nextPage\":[32],\"hasInfiniteScroll\":[32],\"hasCustomComponent\":[32],\"sourceValueIsValid\":[32],\"placeholderText\":[32],\"endOfText\":[32],\"failedLoadMore\":[32],\"currentPage\":[32],\"currentCategoryIdFilter\":[32],\"isReady\":[32],\"showPlaceholder\":[32],\"parsedFilters\":[32],\"setFilters\":[64],\"reload\":[64]}],[4,\"salla-product-card\",{\"product\":[1],\"horizontal\":[4],\"shadowOnHover\":[4,\"shadow-on-hover\"],\"hideAddBtn\":[4,\"hide-add-btn\"],\"fullImage\":[4,\"full-image\"],\"minimal\":[4],\"isSpecial\":[4,\"is-special\"],\"showQuantity\":[4,\"show-quantity\"],\"productData\":[32],\"fitImageHeight\":[32],\"remained\":[32],\"outOfStock\":[32],\"donationAmount\":[32],\"startingPrice\":[32],\"addToCart\":[32],\"placeholder\":[32]}],[0,\"salla-comment-item\",{\"comment\":[16],\"has_bought_trans\":[32],\"rated_trans\":[32],\"waiting_approval_trans\":[32],\"has_order_trans\":[32]}],[4,\"salla-tab-content\",{\"name\":[1],\"isSelected\":[32],\"getChild\":[64]}],[4,\"salla-tab-header\",{\"name\":[1],\"activeClass\":[1,\"active-class\"],\"height\":[8],\"centered\":[4],\"isSelected\":[32],\"getChild\":[64]}],[4,\"salla-tabs\",{\"backgroundColor\":[1,\"background-color\"],\"vertical\":[4]},[[0,\"tabSelected\",\"onSelectedTab\"]]],[4,\"salla-add-product-button\",{\"channels\":[513],\"subscribedOptions\":[1,\"subscribed-options\"],\"quickBuy\":[1540,\"quick-buy\"],\"quantity\":[514],\"donatingAmount\":[514,\"donating-amount\"],\"notifyOptionsAvailability\":[516,\"notify-options-availability\"],\"productId\":[520,\"product-id\"],\"supportStickyBar\":[516,\"support-sticky-bar\"],\"productStatus\":[513,\"product-status\"],\"productType\":[513,\"product-type\"],\"hasOutOfStockOption\":[32],\"hasSubscribedOptions\":[32],\"selectedOptions\":[32],\"showQuickBuy\":[32],\"isApplePayActive\":[32]}],[0,\"salla-count-down\",{\"date\":[1],\"boxed\":[4],\"size\":[1],\"color\":[1],\"labeled\":[4],\"endText\":[1,\"end-text\"],\"digits\":[1],\"endOfDay\":[4,\"end-of-day\"],\"daysLabel\":[32],\"hoursLabel\":[32],\"minutesLabel\":[32],\"secondsLabel\":[32],\"endLabel\":[32],\"invalidDate\":[32],\"offerEnded\":[32],\"countInterval\":[32],\"days\":[32],\"hours\":[32],\"minutes\":[32],\"seconds\":[32],\"endCountDown\":[64]}],[0,\"salla-datetime-picker\",{\"value\":[1537],\"required\":[4],\"name\":[513],\"placeholder\":[1],\"allowInput\":[4,\"allow-input\"],\"allowInvalidPreload\":[4,\"allow-invalid-preload\"],\"altFormat\":[1,\"alt-format\"],\"altInput\":[4,\"alt-input\"],\"altInputClass\":[1,\"alt-input-class\"],\"appendTo\":[16],\"ariaDateFormat\":[1,\"aria-date-format\"],\"autoFillDefaultTime\":[4,\"auto-fill-default-time\"],\"clickOpens\":[4,\"click-opens\"],\"closeOnSelect\":[4,\"close-on-select\"],\"conjunction\":[1],\"dateFormat\":[1,\"date-format\"],\"defaultDate\":[8,\"default-date\"],\"defaultHour\":[2,\"default-hour\"],\"defaultMinute\":[2,\"default-minute\"],\"defaultSeconds\":[2,\"default-seconds\"],\"disable\":[16],\"disableMobile\":[4,\"disable-mobile\"],\"enable\":[16],\"enableSeconds\":[4,\"enable-seconds\"],\"enableTime\":[4,\"enable-time\"],\"formatDate\":[16],\"hourIncrement\":[2,\"hour-increment\"],\"inline\":[4],\"locale\":[1],\"maxDate\":[8,\"max-date\"],\"maxTime\":[8,\"max-time\"],\"minDate\":[8,\"min-date\"],\"minTime\":[8,\"min-time\"],\"minuteIncrement\":[2,\"minute-increment\"],\"mode\":[1],\"monthSelectorType\":[1,\"month-selector-type\"],\"nextArrow\":[1,\"next-arrow\"],\"noCalendar\":[4,\"no-calendar\"],\"dateParser\":[16],\"position\":[1],\"positionElement\":[16],\"prevArrow\":[1,\"prev-arrow\"],\"shorthandCurrentMonth\":[4,\"shorthand-current-month\"],\"static\":[4],\"showMonths\":[2,\"show-months\"],\"time_24hr\":[4,\"time_-2-4hr\"],\"weekNumbers\":[4,\"week-numbers\"],\"wrap\":[4]}],[0,\"salla-product-availability\",{\"channels\":[1],\"notifyOptionsAvailability\":[4,\"notify-options-availability\"],\"productId\":[2,\"product-id\"],\"isSubscribed\":[1028,\"is-subscribed\"],\"translationLoaded\":[32],\"title_\":[32],\"isVisitorSubscribed\":[32]}],[0,\"salla-file-upload\",{\"value\":[1537],\"files\":[513],\"height\":[513],\"cartItemId\":[1,\"cart-item-id\"],\"profileImage\":[516,\"profile-image\"],\"name\":[1537],\"payloadName\":[1,\"payload-name\"],\"accept\":[1537],\"fileId\":[2,\"file-id\"],\"url\":[1025],\"method\":[1],\"formData\":[1,\"form-data\"],\"required\":[4],\"maxFileSize\":[1,\"max-file-size\"],\"disabled\":[4],\"allowDrop\":[4,\"allow-drop\"],\"allowBrowse\":[4,\"allow-browse\"],\"allowPaste\":[4,\"allow-paste\"],\"allowMultiple\":[4,\"allow-multiple\"],\"allowReplace\":[4,\"allow-replace\"],\"allowRevert\":[4,\"allow-revert\"],\"allowRemove\":[4,\"allow-remove\"],\"allowProcess\":[4,\"allow-process\"],\"allowReorder\":[4,\"allow-reorder\"],\"storeAsFile\":[4,\"store-as-file\"],\"forceRevert\":[4,\"force-revert\"],\"maxFilesCount\":[2,\"max-files-count\"],\"maxParallelUploads\":[2,\"max-parallel-uploads\"],\"checkValidity\":[4,\"check-validity\"],\"itemInsertLocation\":[1,\"item-insert-location\"],\"itemInsertInterval\":[2,\"item-insert-interval\"],\"credits\":[4],\"dropOnPage\":[4,\"drop-on-page\"],\"dropOnElement\":[4,\"drop-on-element\"],\"dropValidation\":[4,\"drop-validation\"],\"ignoredFiles\":[16],\"instantUpload\":[1028,\"instant-upload\"],\"chunkUploads\":[4,\"chunk-uploads\"],\"chunkForce\":[4,\"chunk-force\"],\"chunkSize\":[2,\"chunk-size\"],\"chunkRetryDelays\":[16],\"labelDecimalSeparator\":[1,\"label-decimal-separator\"],\"labelThousandsSeparator\":[1,\"label-thousands-separator\"],\"labelIdle\":[1025,\"label-idle\"],\"iconRemove\":[1,\"icon-remove\"],\"iconProcess\":[1,\"icon-process\"],\"iconRetry\":[1,\"icon-retry\"],\"iconUndo\":[1,\"icon-undo\"],\"setOption\":[64]}],[4,\"salla-list-tile\",{\"href\":[1],\"target\":[1]}],[0,\"salla-progress-bar\",{\"donation\":[1],\"target\":[1026],\"value\":[1026],\"height\":[1025],\"header\":[1025],\"stripped\":[1028],\"message\":[1025],\"unit\":[1025],\"color\":[1025]}],[0,\"salla-quick-buy\",{\"type\":[1025],\"productId\":[1025,\"product-id\"],\"cartId\":[1025,\"cart-id\"],\"amount\":[1538],\"currency\":[1025],\"options\":[16],\"isRequireShipping\":[1028,\"is-require-shipping\"],\"applePayOnly\":[1028,\"apple-pay-only\"],\"isApplePayActive\":[32],\"quickBuy\":[32]}],[0,\"salla-rating-stars\",{\"name\":[1],\"size\":[1],\"value\":[2],\"reviews\":[2]}],[4,\"salla-slider\",{\"blockTitle\":[513,\"block-title\"],\"listenToThumbnailsOption\":[516,\"listen-to-thumbnails-option\"],\"blockSubtitle\":[513,\"block-subtitle\"],\"displayAllUrl\":[513,\"display-all-url\"],\"arrowsCentered\":[516,\"arrows-centered\"],\"verticalThumbs\":[516,\"vertical-thumbs\"],\"gridThumbs\":[516,\"grid-thumbs\"],\"vertical\":[516],\"autoHeight\":[516,\"auto-height\"],\"showControls\":[516,\"show-controls\"],\"controlsOuter\":[516,\"controls-outer\"],\"showThumbsControls\":[4,\"show-thumbs-controls\"],\"autoPlay\":[4,\"auto-play\"],\"slidesPerView\":[1,\"slides-per-view\"],\"pagination\":[4],\"centered\":[4],\"loop\":[4],\"direction\":[1537],\"type\":[1],\"sliderConfig\":[520,\"slider-config\"],\"thumbsConfig\":[520,\"thumbs-config\"],\"currentIndex\":[32],\"isEnd\":[32],\"isBeginning\":[32],\"swiperScript\":[32],\"displayAllTitle\":[32],\"windowWidth\":[32],\"slideTo\":[64],\"slideNext\":[64],\"slidePrev\":[64],\"slideToLoop\":[64],\"slideNextLoop\":[64],\"slidePrevLoop\":[64],\"slideReset\":[64],\"slideToClosest\":[64],\"update\":[64],\"updateAutoHeight\":[64],\"updateSlides\":[64],\"updateProgress\":[64],\"updateSlidesClasses\":[64],\"getSlides\":[64]}],[0,\"salla-skeleton\",{\"type\":[1],\"width\":[1],\"height\":[1]}],[4,\"salla-placeholder\",{\"icon\":[1],\"alignment\":[1],\"iconSize\":[1,\"icon-size\"],\"translationLoaded\":[32]}],[0,\"salla-tel-input\",{\"phone\":[1025],\"autofocus\":[516],\"name\":[1],\"countryCode\":[1025,\"country-code\"],\"mobileRequired\":[32],\"countryCodeLabel\":[32],\"mobileLabel\":[32],\"tooShort\":[32],\"tooLong\":[32],\"invalidCountryCode\":[32],\"invalidNumber\":[32],\"errorMap\":[32],\"getValues\":[64],\"isValid\":[64]}],[4,\"salla-modal\",{\"isClosable\":[1028,\"is-closable\"],\"width\":[513],\"position\":[513],\"visible\":[516],\"hasSkeleton\":[516,\"has-skeleton\"],\"isLoading\":[1540,\"is-loading\"],\"subTitleFirst\":[4,\"sub-title-first\"],\"noPadding\":[4,\"no-padding\"],\"subTitle\":[1,\"sub-title\"],\"centered\":[4],\"iconStyle\":[1,\"icon-style\"],\"modalTitle\":[32],\"open\":[64],\"close\":[64],\"setTitle\":[64],\"loading\":[64],\"stopLoading\":[64]},[[0,\"keyup\",\"handleKeyUp\"]]],[0,\"salla-loading\",{\"size\":[8],\"width\":[8],\"color\":[1],\"bgColor\":[1,\"bg-color\"]}],[4,\"salla-button\",{\"shape\":[513],\"color\":[513],\"fill\":[513],\"size\":[513],\"width\":[513],\"loading\":[516],\"disabled\":[516],\"loaderPosition\":[1,\"loader-position\"],\"href\":[1],\"type\":[513],\"load\":[64],\"stop\":[64],\"setText\":[64],\"disable\":[64],\"enable\":[64]}]]],[\"salla-price-range.cjs\",[[0,\"salla-price-range\",{\"minPrice\":[1032,\"min-price\"],\"maxPrice\":[1032,\"max-price\"],\"option\":[16],\"filtersData\":[520,\"filters-data\"],\"min\":[32],\"max\":[32],\"priceOptions\":[32],\"moreThanLabel\":[32],\"lessThanLabel\":[32],\"toLabel\":[32],\"fromLabel\":[32],\"typing\":[32],\"isMin\":[32],\"isRTL\":[32],\"reset\":[64]}]]]]"), options);
27
27
  });
28
28
 
29
29
  exports.setNonce = index.setNonce;
@@ -138,8 +138,8 @@ export class SallaAddProductButton {
138
138
  's-add-product-button-with-apple-pay': this.showQuickBuy && this.isApplePayActive
139
139
  } }, h("div", { class: {
140
140
  's-add-product-button-main': this.showQuickBuy,
141
- 'w-full': !!document.getElementById('fast-checkout-js'), // This is a temporary fix until all themes fully support the fast checkout -- To be removed later
142
- } }, h("salla-button", Object.assign({ color: this.productStatus === 'sale' ? 'primary' : 'light', type: "button", fill: this.productStatus === 'sale' ? 'solid' : 'outline', ref: el => this.btn = el, onClick: event => this.addProductToCart(event), disabled: this.productStatus !== 'sale' }, this.getBtnAttributes(), { "loader-position": "center" }), h("slot", null)), this.showQuickBuy ? this.miniCheckoutWidget() : ''), this.showQuickBuy && this.isApplePayActive ? h("salla-quick-buy", Object.assign({}, this.getQuickBuyBtnAttributes())) : '');
141
+ 'w-full': !document.getElementById('fast-checkout-js'), // This is a temporary fix until all themes fully support the fast checkout -- To be removed later
142
+ } }, h("salla-button", Object.assign({ color: this.productStatus === 'sale' ? 'primary' : 'light', type: "button", fill: this.productStatus === 'sale' ? 'solid' : 'outline', ref: el => this.btn = el, onClick: event => this.addProductToCart(event), disabled: this.productStatus !== 'sale' }, this.getBtnAttributes(), { "loader-position": "center" }), h("slot", null)), this.showQuickBuy && !!document.getElementById('fast-checkout-js') ? this.miniCheckoutWidget() : ''), this.showQuickBuy && this.isApplePayActive ? h("salla-quick-buy", Object.assign({}, this.getQuickBuyBtnAttributes())) : '');
143
143
  }
144
144
  componentDidLoad() {
145
145
  if (!this.notifyOptionsAvailability) {
@@ -1 +1 @@
1
- {"version":3,"file":"salla-add-product-button.js","sourceRoot":"","sources":["../../../src/components/salla-add-product-button/salla-add-product-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAgB,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,IAAI,MAAM,2BAA2B,CAAC;AAC7C,sDAAsD;AACtD,OAAO,UAAU,MAAM,kCAAkC,CAAC;AAM1D,MAAM,OAAO,qBAAqB;;IAExB,mBAAc,GAAQ,EAAE,CAAC;;;;;;;;;yBA8C2C,MAAM;uBAKuD,SAAS;;;2BAW3G,EAAE;;;;EAWjC,QAAQ;IACd,IAAI,IAAI,CAAC,aAAa,KAAK,MAAM,IAAI,IAAI,CAAC,gBAAgB,IAAI,MAAM,CAAC,UAAU,IAAI,GAAG,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,gBAAgB,EAAE;MACpI,OAAO,IAAI,CAAC;KACb;IAED,IAAI,IAAI,CAAC,aAAa,KAAK,MAAM,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE;MACnE,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;KAC9C;IAED,IAAI,IAAI,CAAC,aAAa,KAAK,MAAM,EAAE;MACjC,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;KACjD;IAED,IAAI,IAAI,CAAC,WAAW,KAAK,UAAU,EAAE;MACnC,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;KACtD;IAED,WAAW;IACX,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;EAC1D,CAAC;EAEO,gBAAgB,CAAC,KAAK;;IAE5B,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE;MAClC,KAAK,CAAC,c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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, State, Event, EventEmitter, Host, Prop, h } from '@stencil/core';\nimport Cart from '../../assets/svg/cart.svg';\n// import SallaIcon from '../../assets/svg/salla.svg';\nimport WalletIcon from '../../assets/svg/full-wallet.svg';\n\n@Component({\n tag: 'salla-add-product-button',\n styleUrl: 'salla-add-product-button.css'\n})\nexport class SallaAddProductButton {\n\n private hostAttributes: any = {};\n private btn?: HTMLSallaButtonElement;\n private passedLabel: string;\n\n /**\n * Channels.\n */\n @Prop({ reflect: true }) channels: string;\n\n /**\n * Subscribed Options ex: \"[[139487,2394739],[1212,1544]]\"\n */\n @Prop() subscribedOptions: string;\n\n /**\n * Support Quick Pay Button\n */\n @Prop({ reflect: true, mutable: true }) quickBuy: boolean;\n\n /**\n * Product Quantity\n */\n @Prop({ reflect: true }) quantity: number;\n\n /**\n * Donating amount.\n */\n @Prop({ reflect: true }) donatingAmount: number;\n\n /**\n * Listen to product options availability.\n */\n @Prop({ reflect: true }) notifyOptionsAvailability: boolean;\n\n /**\n * Product id\n */\n @Prop({ reflect: true }) productId;\n\n /**\n * Support themes that have a sticky bar\n */\n @Prop({ reflect: true }) supportStickyBar: boolean;\n /**\n * Product Status.Defaults to `sale`\n */\n @Prop({ reflect: true }) productStatus: 'sale' | 'out' | 'out-and-notify' = 'sale';\n\n /**\n * Product type. Defaults to `product`\n */\n @Prop({ reflect: true }) productType: 'product' | 'service' | 'codes' | 'digital' | 'food' | 'donating' | 'group_products' | 'booking' = 'product';\n\n /**\n * Custome DOM event emitter when product gets added to cart successfully.\n */\n @Event() success: EventEmitter;\n\n @State() hasOutOfStockOption: boolean;\n\n @State() hasSubscribedOptions: boolean;\n\n @State() selectedOptions: Array<any> = [];\n @State() showQuickBuy: boolean;\n @State() isApplePayActive: boolean;\n\n /**\n * Custome DOM event emitter when product addition to cart fails.\n */\n @Event() failed: EventEmitter;\n\n @Element() host: HTMLElement;\n\n private getLabel() {\n if (this.productStatus === 'sale' && this.supportStickyBar && window.innerWidth <= 768 && this.showQuickBuy && this.isApplePayActive) {\n return Cart;\n }\n\n if (this.productStatus === 'sale' && this.productType === 'booking') {\n return salla.lang.get('pages.cart.book_now');\n }\n\n if (this.productStatus === 'sale') {\n return salla.lang.get('pages.cart.add_to_cart');\n }\n\n if (this.productType !== 'donating') {\n return salla.lang.get('pages.products.out_of_stock');\n }\n\n // donating\n return salla.lang.get('pages.products.donation_exceed');\n }\n\n private addProductToCart(event) {\n\n if (this.productType === 'booking') {\n event.preventDefault();\n return this.addBookingProduct();\n }\n\n // we want to ignore the click action when the type of button is submit a form\n if (this.hostAttributes.type === 'submit') {\n return false;\n }\n event.preventDefault();\n\n this.btn?.disable();\n /**\n * by default the quick add is just an alias for add item function\n * but its work only when the id is the only value is passed via the object\n * so we will filter the object entities to remove null and zero values in case we don't want the normal add item action\n */\n const data: any = Object.entries({\n id: this.productId,\n donation_amount: this.donatingAmount,\n quantity: this.quantity,\n endpoint: 'quickAdd'\n }).reduce((a, [k, v]) => (v ? (a[k] = v, a) : a), {})\n return salla.cart.addItem(data)\n .then(response => {\n this.selectedOptions = [];\n this.btn?.enable();\n this.success.emit(response);\n })\n .catch(error => { this.failed.emit(error); this.btn?.enable(); });\n }\n\n private addBookingProduct() {\n if (salla.config.isGuest()) {\n salla.auth.api.setAfterLoginEvent('booking::add', this.productId);\n salla.event.dispatch('login::open');\n return;\n }\n return salla.booking.add(this.productId)\n .then(resp => this.success.emit(resp))\n .catch(error => this.failed.emit(error))\n }\n\n private getBtnAttributes() {\n for (let i = 0; i < this.host.attributes.length; i++) {\n if (!['id', 'class'].includes(this.host.attributes[i].name)) {\n this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;\n }\n }\n\n return this.hostAttributes;\n }\n\n private getQuickBuyBtnAttributes() {\n return {\n ...this.getBtnAttributes(),\n type: this.supportStickyBar && window.innerWidth <= 768 ? 'plain' : this.productType == 'donating' ? 'donate' : 'buy'\n }\n }\n private miniCheckoutWidget() {\n let storeId = salla.config.get('store.id');\n if (!storeId) {\n return;\n }\n return <salla-mini-checkout-widget\n language={salla.lang.locale}\n store-id={storeId}\n products={[this.productId]}\n api={salla.config.get('store.api')}\n outline\n form-selector=\"form.product-form\"\n class=\"s-add-product-button-mini-checkout\"\n >\n {/* {window.innerWidth <= 768 && this.isApplePayActive && this.supportStickyBar ? <div slot=\"widget-label\">\n <span innerHTML={SallaIcon}></span>\n </div> : ''} */} \n\n <div slot=\"widget-label\" class=\"s-add-product-button-mini-checkout-content\">\n <span innerHTML={WalletIcon}></span>\n {salla.lang.get('pages.products.buy_now')}\n </div>\n </salla-mini-checkout-widget>\n }\n\n\n componentWillLoad() {\n return salla.onReady()\n .then(() => {\n this.showQuickBuy = this.quickBuy\n && salla.config.get('store.settings.buy_now')\n && this.productStatus == 'sale'\n && this.productType !== 'booking';\n\n this.isApplePayActive = window.ApplePaySession?.canMakePayments()\n && salla.config.get('store.settings.payments')?.includes('apple_pay')\n && salla.config.get('store.settings.is_salla_gateway', false);\n\n this.passedLabel = this.host.innerHTML.replace('<!---->', '').trim();\n if (!!this.passedLabel && window.innerWidth >= 768) {\n return this.btn?.setText(this.passedLabel);\n }\n \n if (this.host.getAttribute('type') === 'submit' && this.supportStickyBar) {\n window.addEventListener('resize', () => this.btn?.setText((window.innerWidth >= 768 && !!this.passedLabel) ? this.passedLabel : this.getLabel()));\n }\n })\n }\n\n\n render() {\n //TODO:: find a better fix, this is a patch for issue that duplicates the buttons more than twice @see the screenshot inside this folder\n if (this.host.closest('.swiper-slide')?.classList.contains('swiper-slide-duplicate')) {\n return ''\n }\n if (this.hasSubscribedOptions) {\n return <Host>\n <salla-product-availability {...this.getBtnAttributes()} is-subscribed={true}>\n <span class=\"s-hidden\"><slot /></span>\n </salla-product-availability>\n </Host>;\n }\n\n if ((this.productStatus === 'out-and-notify' && this.channels) || this.hasOutOfStockOption) {\n return <Host>\n <salla-product-availability {...this.getBtnAttributes()}>\n <span class=\"s-hidden\"><slot /></span>\n </salla-product-availability>\n </Host>;\n }\n\n return <Host class={{\n 's-add-product-button-with-quick-buy': this.showQuickBuy,\n 's-add-product-button-with-sticky-bar': this.supportStickyBar,\n 's-add-product-button-with-apple-pay': this.showQuickBuy && this.isApplePayActive\n }}>\n <div class={{\n 's-add-product-button-main': this.showQuickBuy,\n 'w-full': !!document.getElementById('fast-checkout-js'), // This is a temporary fix until all themes fully support the fast checkout -- To be removed later\n }}>\n <salla-button color={this.productStatus === 'sale' ? 'primary' : 'light'}\n type=\"button\"\n fill={this.productStatus === 'sale' ? 'solid' : 'outline'}\n ref={el => this.btn = el as HTMLSallaButtonElement}\n onClick={event => this.addProductToCart(event)}\n disabled={this.productStatus !== 'sale'}\n {...this.getBtnAttributes()}\n loader-position=\"center\"\n >\n <slot />\n </salla-button>\n {this.showQuickBuy ? this.miniCheckoutWidget() : ''}\n </div>\n {this.showQuickBuy && this.isApplePayActive ? <salla-quick-buy {...this.getQuickBuyBtnAttributes()} /> : ''}\n </Host>;\n }\n\n componentDidLoad() {\n if (!this.notifyOptionsAvailability) {\n return;\n }\n\n salla.event.on('product-options::change', async data => {\n if (!['thumbnail', 'color', 'single-option'].includes(data.option.type)) {\n return;\n }\n this.hasSubscribedOptions = false;\n this.selectedOptions = await (document.querySelector(`salla-product-options[product-id=\"${this.productId}\"]`) as any)?.getSelectedOptions();\n this.hasOutOfStockOption = await (document.querySelector(`salla-product-options[product-id=\"${this.productId}\"]`) as any)?.hasOutOfStockOption();\n let subscribedDetails = salla.storage.get(`product-${this.productId}-subscribed-options`);\n\n if (!subscribedDetails && !this.subscribedOptions || !this.hasOutOfStockOption) {\n return;\n }\n\n if (salla.config.isGuest()) {\n const parsedSubscribedDetails = subscribedDetails ? subscribedDetails.map(ids => ids.split(',').map(id => parseInt(id))) : [];\n\n this.hasSubscribedOptions = parsedSubscribedDetails.length > 0 && parsedSubscribedDetails.some(ids =>\n ids.every(id => this.selectedOptions.some(option => option.id === id))\n );\n } else {\n this.hasSubscribedOptions = this.subscribedOptions && this.subscribedOptions !== 'null' && this.subscribedOptions !== '[]' ? JSON.parse(this.subscribedOptions).some(ids =>\n ids.every(id => this.selectedOptions.some(option => option.id === id))\n ) : false;\n }\n });\n\n\n }\n\n componentDidRender(): void {\n //if label not passed, get label\n if (!!this.passedLabel && (!this.supportStickyBar || window.innerWidth >= 768)) {\n // if passed label, set it\n this.btn?.setText(this.passedLabel)\n return;\n }\n this.btn?.setText(this.getLabel())\n\n salla.lang.onLoaded(() => this.btn?.setText(this.getLabel()));\n }\n}\n"]}
1
+ {"version":3,"file":"salla-add-product-button.js","sourceRoot":"","sources":["../../../src/components/salla-add-product-button/salla-add-product-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAgB,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,IAAI,MAAM,2BAA2B,CAAC;AAC7C,sDAAsD;AACtD,OAAO,UAAU,MAAM,kCAAkC,CAAC;AAM1D,MAAM,OAAO,qBAAqB;;IAExB,mBAAc,GAAQ,EAAE,CAAC;;;;;;;;;yBA8C2C,MAAM;uBAKuD,SAAS;;;2BAW3G,EAAE;;;;EAWjC,QAAQ;IACd,IAAI,IAAI,CAAC,aAAa,KAAK,MAAM,IAAI,IAAI,CAAC,gBAAgB,IAAI,MAAM,CAAC,UAAU,IAAI,GAAG,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,gBAAgB,EAAE;MACpI,OAAO,IAAI,CAAC;KACb;IAED,IAAI,IAAI,CAAC,aAAa,KAAK,MAAM,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE;MACnE,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;KAC9C;I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G,0CAAE,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;MACnC,OAAO;KACR;IACD,MAAA,IAAI,CAAC,GAAG,0CAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;IAElC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,WAAC,OAAA,MAAA,IAAI,CAAC,GAAG,0CAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA,EAAA,CAAC,CAAC;EAChE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, State, Event, EventEmitter, Host, Prop, h } from '@stencil/core';\nimport Cart from '../../assets/svg/cart.svg';\n// import SallaIcon from '../../assets/svg/salla.svg';\nimport WalletIcon from '../../assets/svg/full-wallet.svg';\n\n@Component({\n tag: 'salla-add-product-button',\n styleUrl: 'salla-add-product-button.css'\n})\nexport class SallaAddProductButton {\n\n private hostAttributes: any = {};\n private btn?: HTMLSallaButtonElement;\n private passedLabel: string;\n\n /**\n * Channels.\n */\n @Prop({ reflect: true }) channels: string;\n\n /**\n * Subscribed Options ex: \"[[139487,2394739],[1212,1544]]\"\n */\n @Prop() subscribedOptions: string;\n\n /**\n * Support Quick Pay Button\n */\n @Prop({ reflect: true, mutable: true }) quickBuy: boolean;\n\n /**\n * Product Quantity\n */\n @Prop({ reflect: true }) quantity: number;\n\n /**\n * Donating amount.\n */\n @Prop({ reflect: true }) donatingAmount: number;\n\n /**\n * Listen to product options availability.\n */\n @Prop({ reflect: true }) notifyOptionsAvailability: boolean;\n\n /**\n * Product id\n */\n @Prop({ reflect: true }) productId;\n\n /**\n * Support themes that have a sticky bar\n */\n @Prop({ reflect: true }) supportStickyBar: boolean;\n /**\n * Product Status.Defaults to `sale`\n */\n @Prop({ reflect: true }) productStatus: 'sale' | 'out' | 'out-and-notify' = 'sale';\n\n /**\n * Product type. Defaults to `product`\n */\n @Prop({ reflect: true }) productType: 'product' | 'service' | 'codes' | 'digital' | 'food' | 'donating' | 'group_products' | 'booking' = 'product';\n\n /**\n * Custome DOM event emitter when product gets added to cart successfully.\n */\n @Event() success: EventEmitter;\n\n @State() hasOutOfStockOption: boolean;\n\n @State() hasSubscribedOptions: boolean;\n\n @State() selectedOptions: Array<any> = [];\n @State() showQuickBuy: boolean;\n @State() isApplePayActive: boolean;\n\n /**\n * Custome DOM event emitter when product addition to cart fails.\n */\n @Event() failed: EventEmitter;\n\n @Element() host: HTMLElement;\n\n private getLabel() {\n if (this.productStatus === 'sale' && this.supportStickyBar && window.innerWidth <= 768 && this.showQuickBuy && this.isApplePayActive) {\n return Cart;\n }\n\n if (this.productStatus === 'sale' && this.productType === 'booking') {\n return salla.lang.get('pages.cart.book_now');\n }\n\n if (this.productStatus === 'sale') {\n return salla.lang.get('pages.cart.add_to_cart');\n }\n\n if (this.productType !== 'donating') {\n return salla.lang.get('pages.products.out_of_stock');\n }\n\n // donating\n return salla.lang.get('pages.products.donation_exceed');\n }\n\n private addProductToCart(event) {\n\n if (this.productType === 'booking') {\n event.preventDefault();\n return this.addBookingProduct();\n }\n\n // we want to ignore the click action when the type of button is submit a form\n if (this.hostAttributes.type === 'submit') {\n return false;\n }\n event.preventDefault();\n\n this.btn?.disable();\n /**\n * by default the quick add is just an alias for add item function\n * but its work only when the id is the only value is passed via the object\n * so we will filter the object entities to remove null and zero values in case we don't want the normal add item action\n */\n const data: any = Object.entries({\n id: this.productId,\n donation_amount: this.donatingAmount,\n quantity: this.quantity,\n endpoint: 'quickAdd'\n }).reduce((a, [k, v]) => (v ? (a[k] = v, a) : a), {})\n return salla.cart.addItem(data)\n .then(response => {\n this.selectedOptions = [];\n this.btn?.enable();\n this.success.emit(response);\n })\n .catch(error => { this.failed.emit(error); this.btn?.enable(); });\n }\n\n private addBookingProduct() {\n if (salla.config.isGuest()) {\n salla.auth.api.setAfterLoginEvent('booking::add', this.productId);\n salla.event.dispatch('login::open');\n return;\n }\n return salla.booking.add(this.productId)\n .then(resp => this.success.emit(resp))\n .catch(error => this.failed.emit(error))\n }\n\n private getBtnAttributes() {\n for (let i = 0; i < this.host.attributes.length; i++) {\n if (!['id', 'class'].includes(this.host.attributes[i].name)) {\n this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;\n }\n }\n\n return this.hostAttributes;\n }\n\n private getQuickBuyBtnAttributes() {\n return {\n ...this.getBtnAttributes(),\n type: this.supportStickyBar && window.innerWidth <= 768 ? 'plain' : this.productType == 'donating' ? 'donate' : 'buy'\n }\n }\n private miniCheckoutWidget() {\n let storeId = salla.config.get('store.id');\n if (!storeId) {\n return;\n }\n return <salla-mini-checkout-widget\n language={salla.lang.locale}\n store-id={storeId}\n products={[this.productId]}\n api={salla.config.get('store.api')}\n outline\n form-selector=\"form.product-form\"\n class=\"s-add-product-button-mini-checkout\"\n >\n {/* {window.innerWidth <= 768 && this.isApplePayActive && this.supportStickyBar ? <div slot=\"widget-label\">\n <span innerHTML={SallaIcon}></span>\n </div> : ''} */} \n\n <div slot=\"widget-label\" class=\"s-add-product-button-mini-checkout-content\">\n <span innerHTML={WalletIcon}></span>\n {salla.lang.get('pages.products.buy_now')}\n </div>\n </salla-mini-checkout-widget>\n }\n\n\n componentWillLoad() {\n return salla.onReady()\n .then(() => {\n this.showQuickBuy = this.quickBuy\n && salla.config.get('store.settings.buy_now')\n && this.productStatus == 'sale'\n && this.productType !== 'booking';\n\n this.isApplePayActive = window.ApplePaySession?.canMakePayments()\n && salla.config.get('store.settings.payments')?.includes('apple_pay')\n && salla.config.get('store.settings.is_salla_gateway', false);\n\n this.passedLabel = this.host.innerHTML.replace('<!---->', '').trim();\n if (!!this.passedLabel && window.innerWidth >= 768) {\n return this.btn?.setText(this.passedLabel);\n }\n \n if (this.host.getAttribute('type') === 'submit' && this.supportStickyBar) {\n window.addEventListener('resize', () => this.btn?.setText((window.innerWidth >= 768 && !!this.passedLabel) ? this.passedLabel : this.getLabel()));\n }\n })\n }\n\n\n render() {\n //TODO:: find a better fix, this is a patch for issue that duplicates the buttons more than twice @see the screenshot inside this folder\n if (this.host.closest('.swiper-slide')?.classList.contains('swiper-slide-duplicate')) {\n return ''\n }\n if (this.hasSubscribedOptions) {\n return <Host>\n <salla-product-availability {...this.getBtnAttributes()} is-subscribed={true}>\n <span class=\"s-hidden\"><slot /></span>\n </salla-product-availability>\n </Host>;\n }\n\n if ((this.productStatus === 'out-and-notify' && this.channels) || this.hasOutOfStockOption) {\n return <Host>\n <salla-product-availability {...this.getBtnAttributes()}>\n <span class=\"s-hidden\"><slot /></span>\n </salla-product-availability>\n </Host>;\n }\n\n return <Host class={{\n 's-add-product-button-with-quick-buy': this.showQuickBuy,\n 's-add-product-button-with-sticky-bar': this.supportStickyBar,\n 's-add-product-button-with-apple-pay': this.showQuickBuy && this.isApplePayActive\n }}>\n <div class={{\n 's-add-product-button-main': this.showQuickBuy,\n 'w-full': !document.getElementById('fast-checkout-js'), // This is a temporary fix until all themes fully support the fast checkout -- To be removed later\n }}>\n <salla-button color={this.productStatus === 'sale' ? 'primary' : 'light'}\n type=\"button\"\n fill={this.productStatus === 'sale' ? 'solid' : 'outline'}\n ref={el => this.btn = el as HTMLSallaButtonElement}\n onClick={event => this.addProductToCart(event)}\n disabled={this.productStatus !== 'sale'}\n {...this.getBtnAttributes()}\n loader-position=\"center\"\n >\n <slot />\n </salla-button>\n {this.showQuickBuy && !!document.getElementById('fast-checkout-js') ? this.miniCheckoutWidget() : ''}\n </div>\n {this.showQuickBuy && this.isApplePayActive ? <salla-quick-buy {...this.getQuickBuyBtnAttributes()} /> : ''}\n </Host>;\n }\n\n componentDidLoad() {\n if (!this.notifyOptionsAvailability) {\n return;\n }\n\n salla.event.on('product-options::change', async data => {\n if (!['thumbnail', 'color', 'single-option'].includes(data.option.type)) {\n return;\n }\n this.hasSubscribedOptions = false;\n this.selectedOptions = await (document.querySelector(`salla-product-options[product-id=\"${this.productId}\"]`) as any)?.getSelectedOptions();\n this.hasOutOfStockOption = await (document.querySelector(`salla-product-options[product-id=\"${this.productId}\"]`) as any)?.hasOutOfStockOption();\n let subscribedDetails = salla.storage.get(`product-${this.productId}-subscribed-options`);\n\n if (!subscribedDetails && !this.subscribedOptions || !this.hasOutOfStockOption) {\n return;\n }\n\n if (salla.config.isGuest()) {\n const parsedSubscribedDetails = subscribedDetails ? subscribedDetails.map(ids => ids.split(',').map(id => parseInt(id))) : [];\n\n this.hasSubscribedOptions = parsedSubscribedDetails.length > 0 && parsedSubscribedDetails.some(ids =>\n ids.every(id => this.selectedOptions.some(option => option.id === id))\n );\n } else {\n this.hasSubscribedOptions = this.subscribedOptions && this.subscribedOptions !== 'null' && this.subscribedOptions !== '[]' ? JSON.parse(this.subscribedOptions).some(ids =>\n ids.every(id => this.selectedOptions.some(option => option.id === id))\n ) : false;\n }\n });\n\n\n }\n\n componentDidRender(): void {\n //if label not passed, get label\n if (!!this.passedLabel && (!this.supportStickyBar || window.innerWidth >= 768)) {\n // if passed label, set it\n this.btn?.setText(this.passedLabel)\n return;\n }\n this.btn?.setText(this.getLabel())\n\n salla.lang.onLoaded(() => this.btn?.setText(this.getLabel()));\n }\n}\n"]}
@@ -5,12 +5,13 @@ import { Host, h } from "@stencil/core";
5
5
  import { DiscountType, OfferType, } from "./interfaces";
6
6
  export class SallaConditionalOffer {
7
7
  constructor() {
8
- this.canRender = true;
9
8
  this.offer = null;
10
9
  this.products = {};
10
+ this.isLoading = true;
11
+ this.canRender = true;
11
12
  }
12
13
  componentWillLoad() {
13
- return salla.onReady().then(() => {
14
+ salla.onReady().then(() => {
14
15
  var _a, _b, _c;
15
16
  if (!((_a = salla.config.get('store.features')) === null || _a === void 0 ? void 0 : _a.includes('conditional-offer')) || !((_c = (_b = salla.storage.get("cart")) === null || _b === void 0 ? void 0 : _b.summary) === null || _c === void 0 ? void 0 : _c.count)) {
16
17
  throw new Error('feature or cart object does not existed');
@@ -26,6 +27,8 @@ export class SallaConditionalOffer {
26
27
  .catch(error => {
27
28
  this.canRender = false;
28
29
  salla.logger.error('salla-conditional-offer:: Error', error);
30
+ }).finally(() => {
31
+ this.isLoading = false;
29
32
  });
30
33
  }
31
34
  getProducts() {
@@ -91,9 +94,14 @@ export class SallaConditionalOffer {
91
94
  ] :
92
95
  h("div", { key: "label", class: { "s-conditional-offer-checkpoint-label": true, "first-checkpoint": index === 0, active: isActive }, innerHTML: this.getOfferType(discount) })));
93
96
  }
97
+ getLoadingSkeletonView() {
98
+ return h(Host, { class: "s-conditional-offer-container " }, h("div", { class: "s-conditional-offer-skeleton-wrapper" }, h("div", { class: "s-conditional-offer-skeleton-title" }, h("salla-skeleton", { height: "16px", width: "30%" })), h("div", { class: "s-conditional-offer-skeleton-subtitle" }, h("salla-skeleton", { height: "16px", width: "35%" })), h("div", { class: "s-conditional-offer-skeleton-checkpoints-wrapper" }, Array(3).fill(null).map(() => ([h("salla-skeleton", { key: "checkpoint-line", height: "8px" }), h("div", { class: "s-conditional-offer-skeleton-checkpoint", key: "checkpoint" }, h("salla-skeleton", { height: "60px", width: "60px", type: "circle" }))])))));
99
+ }
94
100
  render() {
95
101
  if (!this.canRender)
96
102
  return null;
103
+ if (this.isLoading)
104
+ return this.getLoadingSkeletonView();
97
105
  return h(Host, { class: "s-conditional-offer-container" }, h("div", { class: "s-conditional-offer-title-wrapper" }, h("div", { class: "s-conditional-offer-title" }, this.offer.title), this.offer.description ? h("div", { class: "s-conditional-offer-subtitle" }, this.offer.description, " ", h("i", { class: "sicon-information" })) : null), h("div", { class: "s-conditional-offer-progress-container" }, this.offer.details.discounts.map((discount, index) => (h("div", { class: { "flex-1": index > 0 }, key: discount.min_spend }, this.getCheckPointView(discount, index))))));
98
106
  }
99
107
  static get is() { return "salla-conditional-offer"; }
@@ -110,7 +118,9 @@ export class SallaConditionalOffer {
110
118
  static get states() {
111
119
  return {
112
120
  "offer": {},
113
- "products": {}
121
+ "products": {},
122
+ "isLoading": {},
123
+ "canRender": {}
114
124
  };
115
125
  }
116
126
  }
@@ -1 +1 @@
1
- {"version":3,"file":"salla-conditional-offer.js","sourceRoot":"","sources":["../../../src/components/salla-conditional-offer/salla-conditional-offer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAEH,YAAY,EAEZ,SAAS,GAEZ,MAAM,cAAc,CAAC;AAOtB,MAAM,OAAO,qBAAqB;;IAKtB,cAAS,GAAG,IAAI,CAAA;iBAHA,IAAI;oBACwC,EAAE;;EAItE,iBAAiB;IACb,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;;MAC7B,IAAI,CAAC,CAAA,MAAA,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,0CAAE,QAAQ,CAAC,mBAAmB,CAAC,CAAA,IAAI,CAAC,CAAA,MAAA,MAAA,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,0CAAE,OAAO,0CAAE,KAAK,CAAA,EAAE;QAClH,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;OAC9D;IACL,CAAC,CAAC;OACG,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;OACnC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAqB,EAAE,EAAE;MAClC,+FAA+F;MAC/F,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,aAAa,CAAC,CAAA;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AAE,EAAE,QAAQ,EAAE,KAAK,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,QAAQ,CAAC,SAAS,IACvD,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,KAAK,CAAC,CACtC,CACT,CAAC,CACA,CACH,CAAA;EACX,CAAC;;;;;;;;;;;;CACJ","sourcesContent":["import { Component, Host, State, h } from \"@stencil/core\";\nimport {\n type Discount,\n DiscountType,\n type Offer,\n OfferType,\n type UpdatedCart,\n} from \"./interfaces\";\nimport type { Product } from \"@salla.sa/twilight/types/common\";\n\n@Component({\n tag: \"salla-conditional-offer\",\n styleUrl: \"salla-conditional-offer.scss\",\n})\nexport class SallaConditionalOffer {\n\n @State() offer: Offer = null;\n @State() products: Record<string, Pick<Product, 'image' | 'url'>> = {}\n\n private canRender = true\n\n componentWillLoad() {\n return salla.onReady().then(() => {\n if (!salla.config.get('store.features')?.includes('conditional-offer') || !salla.storage.get(\"cart\")?.summary?.count) {\n throw new Error('feature or cart object does not existed');\n }\n })\n .then(() => salla.api.cart.offers())\n .then(({ data }: { data: Offer[] }) => {\n //it's okay if there is an exception here, all thens will be skipped, and will catch the error,\n this.offer = data.find(offer => offer.type === \"conditional\")\n this.offer.details.discounts.unshift(({ value: 0, min_spend: 0 }))\n return this.updateInitialOfferValue()\n }).then(() => this.getProducts()).then(() => salla.event.on(\"cart::updated\", (updatedCart: UpdatedCart) => this.updateOfferValues(updatedCart)))\n .catch(error => {\n this.canRender = false\n salla.logger.error('salla-conditional-offer:: Error', error)\n });\n\n\n }\n\n private getProducts() {\n const freeProductIDs = this.offer.details.discounts.filter(({ type }) => type === DiscountType.FREE_PRODUCT).map(({ value }) => value)\n if (freeProductIDs.length > 0) {\n return salla.product.fetch({ source: 'selected', source_value: freeProductIDs }).then(({ data }: { data: Array<Product> }) => {\n data.forEach(({ id, url, image }) => {\n this.products[id] = { url, image }\n })\n })\n }\n }\n private updateInitialOfferValue() {\n return salla.api.cart.details().then(({ data: { cart } }: { data: { cart: UpdatedCart } }) => this.updateOfferValues(cart))\n }\n\n private updateOfferValues({ items, total }: UpdatedCart) {\n const current_value = this.offer.details.based_on === OfferType.PRODUCT_COUNT ? items.reduce((count: number, { quantity }) => count + quantity, 0,) : total\n //we need to assign the offer object a new reference to trigger re-rendering\n this.offer = {\n ...this.offer, details: {\n ...this.offer?.details, current_value,\n }\n }\n return this.offer\n }\n\n private getCheckpointContent(discount: Discount) {\n\n if (discount.type === DiscountType.PERCENTAGE) return `${discount.value}%`\n\n if (discount.type === DiscountType.FIXED) return salla.money(discount.value)\n\n if (discount.type !== DiscountType.FREE_PRODUCT) {\n salla.logger.error(`salla-conditional-offer:: unexpected type (${discount.type})!`);\n return \"\";\n }\n\n const productItem = this.products[discount.value]\n\n if (!productItem) {\n salla.logger.error(`salla-conditional-offer:: there is no product with id (${discount.value})!`);\n return \"\";\n }\n\n return <a class=\"s-conditional-offer-product-link\" href={productItem.url} >\n <img\n class=\"s-conditional-offer-checkpoint-image-content\"\n loading=\"lazy\"\n decoding=\"async\"\n alt={productItem?.image?.alt || \"\"}\n src={productItem?.image?.url} />\n </a>\n\n\n\n }\n\n private getOfferType(discount: Discount): string {\n const basedOn = this.offer.details?.based_on;\n if (basedOn === OfferType.PRODUCT_COUNT) return salla.lang.choice(\"blocks.header.products_count\", discount.min_spend);\n if (basedOn === OfferType.PRODUCT_PURCHASE) return salla.money(discount.min_spend);\n\n salla.logger.warn(`salla-conditional-offer:: Unexpected offer detail's based_on value: ${basedOn}`);\n return `${discount.min_spend}`;\n }\n private mapValueRanges(value: number, initialMinRange: number, initialMaxRange: number, newMinRange: number, newMaxRange: number) {\n\n const newRange = ((value - initialMinRange) * (newMaxRange - newMinRange)) / (initialMaxRange - initialMinRange) + newMinRange;\n\n return newRange > newMaxRange && !Number.isFinite(newRange) ? newMaxRange : newRange;\n }\n\n private getCheckPointView(discount: Discount, index: number) {\n const checkpointIndex = this.offer.details.discounts.findIndex(({ min_spend }) => min_spend === discount.min_spend);\n const previousCheckpointValue = this.offer.details.discounts[checkpointIndex - 1]?.min_spend ?? 0;\n const progressPercentage = this.mapValueRanges(this.offer.details.current_value, previousCheckpointValue, discount.min_spend, 0, 100);\n const isActive = discount.min_spend <= this.offer.details.current_value;\n\n return (\n <div class=\"s-conditional-offer-checkpoint-container\">\n {index > 0 ? [\n <div key=\"progress-line\" class=\"s-conditional-offer-progress-line-container\">\n <div class=\"s-conditional-offer-progress-line-inactive\" />\n <div class=\"s-conditional-offer-progress-line-active\" style={{ width: `${progressPercentage}%` }} />\n </div>,\n <div key=\"checkpoint\" class={`s-conditional-offer-checkpoint ${isActive ? \"s-conditional-offer-active-checkpoint\" : \"\"}`} >\n <div class={`s-conditional-offer-item-avatar-content ${isActive ? \"active\" : \"\"}`} >\n {this.products && this.getCheckpointContent(discount)}\n </div>\n <div class={`s-conditional-offer-checkpoint-label ${isActive ? \"active\" : \"\"}`} innerHTML={this.getOfferType(discount)} />\n\n </div>\n ] :\n <div key=\"label\" class={{ \"s-conditional-offer-checkpoint-label\": true, \"first-checkpoint\": index === 0, active: isActive }} innerHTML={this.getOfferType(discount)} />\n }\n </div>\n );\n }\n\n render() {\n if (!this.canRender) return null\n\n return <Host class=\"s-conditional-offer-container\">\n <div class=\"s-conditional-offer-title-wrapper\">\n <div class=\"s-conditional-offer-title\">{this.offer.title}</div>\n {this.offer.description ? <div class=\"s-conditional-offer-subtitle\">\n {this.offer.description} <i class=\"sicon-information\" />\n </div> : null}\n </div>\n <div class=\"s-conditional-offer-progress-container\">\n {this.offer.details.discounts.map((discount, index) => (\n <div class={{ \"flex-1\": index > 0 }} key={discount.min_spend}>\n {this.getCheckPointView(discount, index)}\n </div>\n ))}\n </div>\n </Host>\n }\n}\n"]}
1
+ {"version":3,"file":"salla-conditional-offer.js","sourceRoot":"","sources":["../../../src/components/salla-conditional-offer/salla-conditional-offer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE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AAC,+BAA+B;MAC9C,WAAK,KAAK,EAAC,mCAAmC;QAC1C,WAAK,KAAK,EAAC,2BAA2B,IAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAO;QAC9D,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,WAAK,KAAK,EAAC,8BAA8B;UAC9D,IAAI,CAAC,KAAK,CAAC,WAAW;;UAAE,SAAG,KAAK,EAAC,mBAAmB,GAAG,CACtD,CAAC,CAAC,CAAC,IAAI,CACX;MACN,WAAK,KAAK,EAAC,wCAAwC,IAC9C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC,CACnD,WAAK,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,QAAQ,CAAC,SAAS,IACvD,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,KAAK,CAAC,CACtC,CACT,CAAC,CACA,CACH,CAAA;EACX,CAAC;;;;;;;;;;;;;;CACJ","sourcesContent":["import { Component, Host, State, h } from \"@stencil/core\";\nimport {\n type Discount,\n DiscountType,\n type Offer,\n OfferType,\n type UpdatedCart,\n} from \"./interfaces\";\nimport type { Product } from \"@salla.sa/twilight/types/common\";\n\n@Component({\n tag: \"salla-conditional-offer\",\n styleUrl: \"salla-conditional-offer.scss\",\n})\nexport class SallaConditionalOffer {\n\n @State() offer: Offer = null;\n @State() products: Record<string, Pick<Product, 'image' | 'url'>> = {}\n @State() isLoading = true\n @State() canRender = true\n\n componentWillLoad() {\n salla.onReady().then(() => {\n if (!salla.config.get('store.features')?.includes('conditional-offer') || !salla.storage.get(\"cart\")?.summary?.count) {\n throw new Error('feature or cart object does not existed');\n }\n })\n .then(() => salla.api.cart.offers())\n .then(({ data }: { data: Offer[] }) => {\n //it's okay if there is an exception here, all thens will be skipped, and will catch the error,\n this.offer = data.find(offer => offer.type === \"conditional\")\n this.offer.details.discounts.unshift(({ value: 0, min_spend: 0 }))\n return this.updateInitialOfferValue()\n }).then(() => this.getProducts()).then(() => salla.event.on(\"cart::updated\", (updatedCart: UpdatedCart) => this.updateOfferValues(updatedCart)))\n .catch(error => {\n this.canRender = false\n salla.logger.error('salla-conditional-offer:: Error', error)\n\n\n }).finally(() => {\n this.isLoading = false\n })\n\n\n }\n\n private getProducts() {\n const freeProductIDs = this.offer.details.discounts.filter(({ type }) => type === DiscountType.FREE_PRODUCT).map(({ value }) => value)\n if (freeProductIDs.length > 0) {\n return salla.product.fetch({ source: 'selected', source_value: freeProductIDs }).then(({ data }: { data: Array<Product> }) => {\n data.forEach(({ id, url, image }) => {\n this.products[id] = { url, image }\n })\n })\n }\n }\n private updateInitialOfferValue() {\n return salla.api.cart.details().then(({ data: { cart } }: { data: { cart: UpdatedCart } }) => this.updateOfferValues(cart))\n }\n\n private updateOfferValues({ items, total }: UpdatedCart) {\n const current_value = this.offer.details.based_on === OfferType.PRODUCT_COUNT ? items.reduce((count: number, { quantity }) => count + quantity, 0,) : total\n //we need to assign the offer object a new reference to trigger re-rendering\n this.offer = {\n ...this.offer, details: {\n ...this.offer?.details, current_value,\n }\n }\n return this.offer\n }\n\n private getCheckpointContent(discount: Discount) {\n\n if (discount.type === DiscountType.PERCENTAGE) return `${discount.value}%`\n\n if (discount.type === DiscountType.FIXED) return salla.money(discount.value)\n\n if (discount.type !== DiscountType.FREE_PRODUCT) {\n salla.logger.error(`salla-conditional-offer:: unexpected type (${discount.type})!`);\n return \"\";\n }\n\n const productItem = this.products[discount.value]\n\n if (!productItem) {\n salla.logger.error(`salla-conditional-offer:: there is no product with id (${discount.value})!`);\n return \"\";\n }\n\n return <a class=\"s-conditional-offer-product-link\" href={productItem.url} >\n <img\n class=\"s-conditional-offer-checkpoint-image-content\"\n loading=\"lazy\"\n decoding=\"async\"\n alt={productItem?.image?.alt || \"\"}\n src={productItem?.image?.url} />\n </a>\n\n\n\n }\n\n private getOfferType(discount: Discount): string {\n const basedOn = this.offer.details?.based_on;\n if (basedOn === OfferType.PRODUCT_COUNT) return salla.lang.choice(\"blocks.header.products_count\", discount.min_spend);\n if (basedOn === OfferType.PRODUCT_PURCHASE) return salla.money(discount.min_spend);\n\n salla.logger.warn(`salla-conditional-offer:: Unexpected offer detail's based_on value: ${basedOn}`);\n return `${discount.min_spend}`;\n }\n private mapValueRanges(value: number, initialMinRange: number, initialMaxRange: number, newMinRange: number, newMaxRange: number) {\n\n const newRange = ((value - initialMinRange) * (newMaxRange - newMinRange)) / (initialMaxRange - initialMinRange) + newMinRange;\n\n return newRange > newMaxRange && !Number.isFinite(newRange) ? newMaxRange : newRange;\n }\n\n private getCheckPointView(discount: Discount, index: number) {\n const checkpointIndex = this.offer.details.discounts.findIndex(({ min_spend }) => min_spend === discount.min_spend);\n const previousCheckpointValue = this.offer.details.discounts[checkpointIndex - 1]?.min_spend ?? 0;\n const progressPercentage = this.mapValueRanges(this.offer.details.current_value, previousCheckpointValue, discount.min_spend, 0, 100);\n const isActive = discount.min_spend <= this.offer.details.current_value;\n\n return (\n <div class=\"s-conditional-offer-checkpoint-container\">\n {index > 0 ? [\n <div key=\"progress-line\" class=\"s-conditional-offer-progress-line-container\">\n <div class=\"s-conditional-offer-progress-line-inactive\" />\n <div class=\"s-conditional-offer-progress-line-active\" style={{ width: `${progressPercentage}%` }} />\n </div>,\n <div key=\"checkpoint\" class={`s-conditional-offer-checkpoint ${isActive ? \"s-conditional-offer-active-checkpoint\" : \"\"}`} >\n <div class={`s-conditional-offer-item-avatar-content ${isActive ? \"active\" : \"\"}`} >\n {this.products && this.getCheckpointContent(discount)}\n </div>\n <div class={`s-conditional-offer-checkpoint-label ${isActive ? \"active\" : \"\"}`} innerHTML={this.getOfferType(discount)} />\n\n </div>\n ] :\n <div key=\"label\" class={{ \"s-conditional-offer-checkpoint-label\": true, \"first-checkpoint\": index === 0, active: isActive }} innerHTML={this.getOfferType(discount)} />\n }\n </div>\n );\n }\n\n private getLoadingSkeletonView() {\n return <Host class=\"s-conditional-offer-container \" >\n <div class=\"s-conditional-offer-skeleton-wrapper\">\n <div class=\"s-conditional-offer-skeleton-title\">\n <salla-skeleton height=\"16px\" width=\"30%\" />\n </div>\n\n <div class=\"s-conditional-offer-skeleton-subtitle\">\n <salla-skeleton height=\"16px\" width=\"35%\" />\n </div>\n <div class=\"s-conditional-offer-skeleton-checkpoints-wrapper\">\n {Array(3).fill(null).map(() => (\n [<salla-skeleton key=\"checkpoint-line\" height=\"8px\" />,\n <div class=\"s-conditional-offer-skeleton-checkpoint\" key=\"checkpoint\">\n <salla-skeleton height=\"60px\" width=\"60px\" type=\"circle\" />\n </div>]\n ))}\n </div>\n\n </div>\n </Host>\n }\n\n render() {\n if (!this.canRender) return null\n if (this.isLoading) return this.getLoadingSkeletonView()\n\n return <Host class=\"s-conditional-offer-container\">\n <div class=\"s-conditional-offer-title-wrapper\">\n <div class=\"s-conditional-offer-title\">{this.offer.title}</div>\n {this.offer.description ? <div class=\"s-conditional-offer-subtitle\">\n {this.offer.description} <i class=\"sicon-information\" />\n </div> : null}\n </div>\n <div class=\"s-conditional-offer-progress-container\">\n {this.offer.details.discounts.map((discount, index) => (\n <div class={{ \"flex-1\": index > 0 }} key={discount.min_spend}>\n {this.getCheckPointView(discount, index)}\n </div>\n ))}\n </div>\n </Host>\n }\n}\n"]}