@salla.sa/twilight-components 2.14.312 → 2.14.338
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{filepond-CiAt5i10.js → filepond-hpLROc_m.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-poster-DdEJEgnf.js → filepond-plugin-file-poster-C8gskRGl.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-size-0E5awx2w.js → filepond-plugin-file-validate-size-CaO6qVs6.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-type-gT-JewGH.js → filepond-plugin-file-validate-type-mUUtcgCs.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-edit-DtBf5E5M.js → filepond-plugin-image-edit-rptDhPuc.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-exif-orientation-DlG1UV1W.js → filepond-plugin-image-exif-orientation-B6L8W0Qe.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-preview-Dub3Jpec.js → filepond-plugin-image-preview-BoqOfOki.js} +1 -1
- package/dist/cjs/{index-BP5-4y-K.js → index-2liYDuhx.js} +583 -420
- package/dist/cjs/{index-i_mnWz5-.js → index-ChHHnqio.js} +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/salla-accordion_62.cjs.entry.js +173 -94
- package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
- package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
- package/dist/cjs/salla-apps-icons.cjs.entry.js +2 -2
- package/dist/cjs/salla-cart-item-offers.cjs.entry.js +1 -1
- package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
- package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters-widget.cjs.entry.js +60 -12
- package/dist/cjs/salla-filters.cjs.entry.js +1 -1
- package/dist/cjs/salla-hook.cjs.entry.js +2 -2
- package/dist/cjs/salla-installment.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +2 -2
- package/dist/cjs/salla-loyalty-program.cjs.entry.js +2 -2
- package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
- package/dist/cjs/salla-notification-item.cjs.entry.js +2 -2
- package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +2 -2
- package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details.cjs.entry.js +2 -2
- package/dist/cjs/salla-order-summary.cjs.entry.js +2 -2
- package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-orders.cjs.entry.js +1 -1
- package/dist/cjs/salla-payments.cjs.entry.js +3 -3
- package/dist/cjs/salla-price-range.cjs.entry.js +3 -3
- package/dist/cjs/salla-review-card.cjs.entry.js +2 -2
- package/dist/cjs/salla-reviews-page.cjs.entry.js +2 -2
- package/dist/cjs/salla-reviews.cjs.entry.js +2 -2
- package/dist/cjs/salla-social.cjs.entry.js +2 -2
- package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-tooltip.cjs.entry.js +2 -2
- package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
- package/dist/cjs/salla-verify.cjs.entry.js +1 -1
- package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
- package/dist/cjs/twilight.cjs.js +2 -2
- package/dist/collection/components/salla-apps-icons/salla-apps-icons.js +1 -1
- package/dist/collection/components/salla-button/salla-button.js +29 -13
- package/dist/collection/components/salla-comments/salla-comment-item.js +8 -3
- package/dist/collection/components/salla-comments/salla-comments.js +1 -1
- package/dist/collection/components/salla-filters-widget/salla-filters-widget.js +62 -12
- package/dist/collection/components/salla-gifting/salla-gifting.js +3 -3
- package/dist/collection/components/salla-hook/salla-hook.js +1 -1
- package/dist/collection/components/salla-list-tile/salla-list-tile.js +1 -1
- package/dist/collection/components/salla-loading/salla-loading.js +1 -1
- package/dist/collection/components/salla-localization-modal/salla-localization-modal.js +1 -1
- package/dist/collection/components/salla-login-modal/salla-login-modal.js +15 -2
- package/dist/collection/components/salla-loyalty/salla-loyalty-prize-item.js +1 -1
- package/dist/collection/components/salla-loyalty-program/salla-loyalty-program.js +1 -1
- package/dist/collection/components/salla-maintenance-alert/salla-maintenance-alert.js +1 -1
- package/dist/collection/components/salla-map/salla-map.js +3 -3
- package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-cart.js +1 -1
- package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-details.js +2 -2
- package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-options-modal.js +4 -4
- package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-slider.js +2 -2
- package/dist/collection/components/salla-multiple-bundle-product/salla-multiple-bundle-product.js +1 -1
- package/dist/collection/components/salla-notifications/salla-notification-item.js +1 -1
- package/dist/collection/components/salla-offer-modal/salla-offer-modal.js +1 -1
- package/dist/collection/components/salla-order-details/salla-order-details-multiple-bundle-product.js +1 -1
- package/dist/collection/components/salla-order-details/salla-order-details.js +1 -1
- package/dist/collection/components/salla-order-summary/salla-order-summary.js +1 -1
- package/dist/collection/components/salla-payments/salla-payments.js +2 -2
- package/dist/collection/components/salla-placeholder/salla-placeholder.js +1 -1
- package/dist/collection/components/salla-price-range/salla-price-range.js +2 -2
- package/dist/collection/components/salla-product-availability/salla-product-availability.js +1 -1
- package/dist/collection/components/salla-product-card/salla-product-card.js +5 -5
- package/dist/collection/components/salla-product-options/salla-product-options.js +37 -16
- package/dist/collection/components/salla-product-size-guide/salla-product-size-guide.js +2 -2
- package/dist/collection/components/salla-quantity-input/salla-quantity-input.js +13 -2
- package/dist/collection/components/salla-quick-buy/salla-quick-buy.js +2 -2
- package/dist/collection/components/salla-review-card/salla-review-card.js +1 -1
- package/dist/collection/components/salla-reviews/salla-reviews.js +1 -1
- package/dist/collection/components/salla-reviews-page/salla-reviews-page.js +1 -1
- package/dist/collection/components/salla-scopes/salla-scopes.js +1 -1
- package/dist/collection/components/salla-search/salla-search.js +3 -3
- package/dist/collection/components/salla-skeleton/salla-skeleton.js +1 -1
- package/dist/collection/components/salla-slider/salla-slider.js +2 -2
- package/dist/collection/components/salla-social/salla-social.js +1 -1
- package/dist/collection/components/salla-social-share/salla-social-share.js +5 -1
- package/dist/collection/components/salla-tabs/salla-tab-content.js +1 -1
- package/dist/collection/components/salla-tabs/salla-tab-header.js +1 -1
- package/dist/collection/components/salla-tabs/salla-tabs.js +1 -1
- package/dist/collection/components/salla-tel-input/salla-tel-input.js +1 -1
- package/dist/collection/components/salla-tooltip/salla-tooltip.js +1 -1
- package/dist/collection/components/salla-user-menu/salla-user-menu.js +9 -1
- package/dist/collection/components/salla-user-settings/salla-user-settings.js +1 -1
- package/dist/collection/plugins/commonjs-cache-fix.js +21 -0
- package/dist/components/axios.js +583 -420
- package/dist/components/index.js +2 -2
- package/dist/components/salla-apps-icons.js +1 -1
- package/dist/components/salla-button2.js +29 -13
- package/dist/components/salla-comment-item2.js +8 -3
- package/dist/components/salla-comments.js +1 -1
- package/dist/components/salla-filters-widget2.js +61 -11
- package/dist/components/salla-gifting.js +3 -3
- package/dist/components/salla-hook.js +1 -1
- package/dist/components/salla-list-tile2.js +1 -1
- package/dist/components/salla-loading2.js +1 -1
- package/dist/components/salla-localization-modal.js +1 -1
- package/dist/components/salla-login-modal.js +15 -2
- package/dist/components/salla-loyalty-prize-item.js +1 -1
- package/dist/components/salla-loyalty-program.js +1 -1
- package/dist/components/salla-maintenance-alert.js +1 -1
- package/dist/components/salla-map2.js +3 -3
- package/dist/components/salla-multiple-bundle-product-cart2.js +1 -1
- package/dist/components/salla-multiple-bundle-product-details2.js +2 -2
- package/dist/components/salla-multiple-bundle-product-options-modal2.js +4 -4
- package/dist/components/salla-multiple-bundle-product-slider2.js +2 -2
- package/dist/components/salla-multiple-bundle-product.js +1 -1
- package/dist/components/salla-notification-item2.js +1 -1
- package/dist/components/salla-offer-modal.js +1 -1
- package/dist/components/salla-order-details-multiple-bundle-product2.js +1 -1
- package/dist/components/salla-order-details.js +1 -1
- package/dist/components/salla-order-summary.js +1 -1
- package/dist/components/salla-payments.js +2 -2
- package/dist/components/salla-placeholder2.js +1 -1
- package/dist/components/salla-price-range2.js +2 -2
- package/dist/components/salla-product-availability2.js +1 -1
- package/dist/components/salla-product-card2.js +5 -5
- package/dist/components/salla-product-options2.js +37 -16
- package/dist/components/salla-product-size-guide.js +2 -2
- package/dist/components/salla-quantity-input.js +13 -2
- package/dist/components/salla-quick-buy2.js +6 -4
- package/dist/components/salla-review-card2.js +1 -1
- package/dist/components/salla-reviews-page.js +1 -1
- package/dist/components/salla-reviews.js +1 -1
- package/dist/components/salla-scopes.js +1 -1
- package/dist/components/salla-search.js +3 -3
- package/dist/components/salla-skeleton2.js +1 -1
- package/dist/components/salla-slider2.js +2 -2
- package/dist/components/salla-social-share.js +5 -1
- package/dist/components/salla-social.js +1 -1
- package/dist/components/salla-tab-content2.js +1 -1
- package/dist/components/salla-tab-header2.js +1 -1
- package/dist/components/salla-tabs2.js +1 -1
- package/dist/components/salla-tel-input2.js +1 -1
- package/dist/components/salla-tooltip2.js +1 -1
- package/dist/components/salla-user-menu.js +9 -1
- package/dist/components/salla-user-settings.js +1 -1
- package/dist/esm/{filepond-aj0Vz3hN.js → filepond-CwjnR_95.js} +1 -1
- package/dist/esm/{filepond-plugin-file-poster-lPOvqQlG.js → filepond-plugin-file-poster-DES9KQfe.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-size-CV5FbyeW.js → filepond-plugin-file-validate-size-BcloWdhO.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-type-B7RUT3W_.js → filepond-plugin-file-validate-type-CbjGxksB.js} +1 -1
- package/dist/esm/{filepond-plugin-image-edit-CXPgbHP6.js → filepond-plugin-image-edit-BtZ6aJg8.js} +1 -1
- package/dist/esm/{filepond-plugin-image-exif-orientation-BKxDLyfR.js → filepond-plugin-image-exif-orientation-BVNb0UTU.js} +1 -1
- package/dist/esm/{filepond-plugin-image-preview-B3b6dOj7.js → filepond-plugin-image-preview-t1v2q4Jq.js} +1 -1
- package/dist/esm/{index-BVJkSSs6.js → index-CRmtzwUF.js} +583 -420
- package/dist/esm/{index-CvvOXX3k.js → index-HmYGeOpS.js} +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/salla-accordion_62.entry.js +173 -94
- package/dist/esm/salla-advertisement.entry.js +1 -1
- package/dist/esm/salla-app-install-alert.entry.js +1 -1
- package/dist/esm/salla-apps-icons.entry.js +2 -2
- package/dist/esm/salla-cart-item-offers.entry.js +1 -1
- package/dist/esm/salla-conditional-offer.entry.js +1 -1
- package/dist/esm/salla-contacts.entry.js +1 -1
- package/dist/esm/salla-custom-fields.entry.js +1 -1
- package/dist/esm/salla-filters-widget.entry.js +60 -12
- package/dist/esm/salla-filters.entry.js +1 -1
- package/dist/esm/salla-hook.entry.js +2 -2
- package/dist/esm/salla-installment.entry.js +1 -1
- package/dist/esm/salla-loyalty-prize-item.entry.js +2 -2
- package/dist/esm/salla-loyalty-program.entry.js +2 -2
- package/dist/esm/salla-metadata.entry.js +1 -1
- package/dist/esm/salla-notification-item.entry.js +2 -2
- package/dist/esm/salla-notifications.entry.js +1 -1
- package/dist/esm/salla-offer.entry.js +1 -1
- package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +2 -2
- package/dist/esm/salla-order-details-options.entry.js +1 -1
- package/dist/esm/salla-order-details.entry.js +2 -2
- package/dist/esm/salla-order-summary.entry.js +2 -2
- package/dist/esm/salla-order-totals-card.entry.js +1 -1
- package/dist/esm/salla-orders.entry.js +1 -1
- package/dist/esm/salla-payments.entry.js +3 -3
- package/dist/esm/salla-price-range.entry.js +3 -3
- package/dist/esm/salla-review-card.entry.js +2 -2
- package/dist/esm/salla-reviews-page.entry.js +2 -2
- package/dist/esm/salla-reviews.entry.js +2 -2
- package/dist/esm/salla-social.entry.js +2 -2
- package/dist/esm/salla-tiered-offer.entry.js +1 -1
- package/dist/esm/salla-tooltip.entry.js +2 -2
- package/dist/esm/salla-trust-badges.entry.js +1 -1
- package/dist/esm/salla-verify.entry.js +1 -1
- package/dist/esm/salla-wallet.entry.js +1 -1
- package/dist/esm/twilight.js +3 -3
- package/dist/twilight/p-057e38a1.entry.js +4 -0
- package/dist/twilight/p-19f40612.entry.js +4 -0
- package/dist/twilight/{p-56e70b23.entry.js → p-1c31f335.entry.js} +1 -1
- package/dist/twilight/{p-3ba6d234.entry.js → p-1f31af27.entry.js} +1 -1
- package/dist/twilight/{p-caac78a8.entry.js → p-21ced14f.entry.js} +1 -1
- package/dist/twilight/{p-e7eeebf1.entry.js → p-2bb93ed0.entry.js} +1 -1
- package/dist/twilight/{p-a5780098.entry.js → p-3862a37f.entry.js} +1 -1
- package/dist/twilight/{p-65ce7926.entry.js → p-3f45a06b.entry.js} +1 -1
- package/dist/twilight/{p-0dcda629.entry.js → p-403bef37.entry.js} +1 -1
- package/dist/twilight/{p-62e50e0c.entry.js → p-4317d018.entry.js} +1 -1
- package/dist/twilight/{p-da2c81c6.entry.js → p-45053a9b.entry.js} +1 -1
- package/dist/twilight/{p-615331d4.entry.js → p-48d76aa7.entry.js} +1 -1
- package/dist/twilight/{p-366c2a7d.entry.js → p-56d3794f.entry.js} +1 -1
- package/dist/twilight/{p-061ec27c.entry.js → p-69600ceb.entry.js} +1 -1
- package/dist/twilight/{p-3c7c63ee.entry.js → p-817fca09.entry.js} +1 -1
- package/dist/twilight/{p-5606e8dd.entry.js → p-877ee446.entry.js} +1 -1
- package/dist/twilight/p-878f405f.entry.js +4 -0
- package/dist/twilight/{p-883a04da.entry.js → p-88c9cdc0.entry.js} +1 -1
- package/dist/twilight/p-8d231ba5.entry.js +4 -0
- package/dist/twilight/p-9108e972.entry.js +4 -0
- package/dist/twilight/p-95f3e7ea.entry.js +4 -0
- package/dist/twilight/{p-Bf2ln7Tf.js → p-BgkeXrDK.js} +1 -1
- package/dist/twilight/{p-CimxEIO_.js → p-BxtqlawD.js} +2 -2
- package/dist/twilight/p-CRmtzwUF.js +5 -0
- package/dist/twilight/{p-Cau1tMDQ.js → p-DTy6dAEi.js} +1 -1
- package/dist/twilight/{p-CtmyX8MN.js → p-DdMTtNYY.js} +1 -1
- package/dist/twilight/{p-CslymsND.js → p-VCBBJkYb.js} +1 -1
- package/dist/twilight/{p-CJWu6tW6.js → p-YYVkPdoE.js} +1 -1
- package/dist/twilight/{p-7d6d19b9.entry.js → p-a3ae644b.entry.js} +1 -1
- package/dist/twilight/{p-b3311168.entry.js → p-a4ad6d0b.entry.js} +1 -1
- package/dist/twilight/{p-3939ed34.entry.js → p-a665ff5d.entry.js} +1 -1
- package/dist/twilight/{p-032b235d.entry.js → p-a9bec6cf.entry.js} +1 -1
- package/dist/twilight/{p-41b68e9a.entry.js → p-b7f1e672.entry.js} +1 -1
- package/dist/twilight/p-c0f8d377.entry.js +11 -0
- package/dist/twilight/{p-0979d5a6.entry.js → p-e98f8bae.entry.js} +1 -1
- package/dist/twilight/{p-b9090ce1.entry.js → p-eb6378eb.entry.js} +1 -1
- package/dist/twilight/{p-0e4a8f9f.entry.js → p-ef827c32.entry.js} +1 -1
- package/dist/twilight/{p-c133896d.entry.js → p-f01949b5.entry.js} +1 -1
- package/dist/twilight/{p-5afe6962.entry.js → p-f10087fd.entry.js} +1 -1
- package/dist/twilight/{p-f586994e.entry.js → p-f33a5658.entry.js} +1 -1
- package/dist/twilight/p-f4dc16e8.entry.js +4 -0
- package/dist/twilight/{p-eb9bf011.entry.js → p-f6a7b2cf.entry.js} +1 -1
- package/dist/twilight/{p-DZVGmyCg.js → p-sFNa2aTl.js} +1 -1
- package/dist/twilight/{p-BQe0WtLQ.js → p-xAxNmkBV.js} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/types/components/salla-button/salla-button.d.ts +0 -1
- package/dist/types/components/salla-comments/interfaces.d.ts +1 -0
- package/dist/types/components/salla-comments/salla-comment-item.d.ts +1 -0
- package/dist/types/components/salla-filters-widget/salla-filters-widget.d.ts +7 -2
- package/dist/types/components/salla-product-options/salla-product-options.d.ts +8 -0
- package/dist/types/components/salla-quantity-input/salla-quantity-input.d.ts +5 -1
- package/dist/types/components/salla-social-share/salla-social-share.d.ts +1 -0
- package/dist/types/components/salla-user-menu/salla-user-menu.d.ts +1 -0
- package/package.json +5 -5
- package/dist/twilight/p-4657145b.entry.js +0 -11
- package/dist/twilight/p-7f03a939.entry.js +0 -4
- package/dist/twilight/p-87fe3f74.entry.js +0 -4
- package/dist/twilight/p-96f53e45.entry.js +0 -4
- package/dist/twilight/p-BVJkSSs6.js +0 -5
- package/dist/twilight/p-b81e66b2.entry.js +0 -4
- package/dist/twilight/p-d46b3cb6.entry.js +0 -4
- package/dist/twilight/p-e0c73f9b.entry.js +0 -4
- package/dist/twilight/p-f4383a51.entry.js +0 -4
|
@@ -4021,7 +4021,7 @@ var a$4 = /*#__PURE__*/_mergeNamespaces({
|
|
|
4021
4021
|
default: memoryStorage
|
|
4022
4022
|
}, [memoryStorageExports]);
|
|
4023
4023
|
|
|
4024
|
-
function s$2(t,e){ void 0===e&&(e=false),t+="";for(var r,n=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],o=["0","1","2","3","4","5","6","7","8","9"],i=(e=e||!Salla.config.get("store.settings.arabic_numbers_enabled"))?n:o,a=e?o:n,s=0;s<i.length;s++)r=new RegExp(i[s],"g"),t=t.replace(r,a[s]);return t.replace(e?"٫":".",e?".":"٫")}function l$2(t){var e=("".concat(t).match(/\./g)||[]).length;return e&&1!==e?l$2(t.replace(/\.(.+)\./g,".$1")):t}function c$3(t){return "".concat(t).startsWith("https://")||"".concat(t).startsWith("http://")}function u$3(t){if(c$3(t))return t;var e=Salla.config.get("store.url");return e||(e=window.location.href.split("/").slice(0,-1).join("/"),Salla.config.set("store.url",e)),e.rtrim("/")+"/"+(null==t?void 0:t.ltrim("/"))}function p$1(t,e,r){if(r=r||window.location.href,!e||!t)return r;var n=new RegExp("([?&])"+t+"=[^&]+[&]?","g");return (r=r.replace(n,"$1").split("#")[0].replace(/&$|\?$/,"")).includes("?")?r+="&":r+=(r.endsWith("/")?"":"/")+"?",(r+t+"="+encodeURIComponent(e)).replace(/&$|\?$/,"")}function f$2(t){return window.location.origin+"/"+(null==t?void 0:t.ltrim("/"))}function d$3(t){return c$3(t)?t:Salla.config.get("theme.assets")?Salla.config.get("theme.assets").replace(":path",null==t?void 0:t.ltrim("/")):f$2("themes/"+Salla.config.get("theme.name")+"/"+(null==t?void 0:t.ltrim("/")))}String.prototype.toStudlyCase=function(){return this.trim().replace(/([^a-zA-Z\d].)/g,(function(t){return t.toUpperCase().replace(/[^a-zA-Z\d]/g,"")}))},String.prototype.toDatasetName=function(){return this.startsWith("data-")?this.substr(5).toStudlyCase():this.toStudlyCase()},String.prototype.toSelector=function(){return this.trim().startsWith(".")||this.trim().startsWith("#")?this.toString():"#"+this.toString()},String.prototype.replaceArray=function(t,e){for(var r,n=this,o=0;o<t.length;o++)r=new RegExp(t[o],"g"),n=n.replace(r,e[o]);return n},String.prototype.rtrim=function(t){return void 0===t&&(t="\\s"),this.replace(new RegExp("["+t+"]*$"),"")},String.prototype.ltrim=function(t){return void 0===t&&(t="\\s"),this.replace(new RegExp("^["+t+"]*"),"")},String.prototype.digitsOnly=function(){return Salla.helpers.digitsOnly(this)};var h$3=Object.freeze({__proto__:null,addParamToUrl:p$1,api:function(t){var e;return (null===(e=Salla.config.get("store.api",u$3("")))||void 0===e?void 0:e.rtrim("/"))+"/"+(null==t?void 0:t.ltrim("/"))},asset:d$3,base:function(t){return c$3(t)?t:"https://"+new URL(u$3("/")).hostname+"/"+(null==t?void 0:t.ltrim("/"))},baseUrl:f$2,cdn:function(t,e,r){var n="https://cdn.salla.network/";return (e||r)&&(e=e?",width=".concat(e):"",r=r?",height=".concat(r):"",n+="cdn-cgi/image/fit=scale-down".concat(e).concat(r,",onerror=redirect,format=auto/")),n+(null==t?void 0:t.ltrim("/"))},create:function(t,e){return "custom"===t?e:u$3("offers"===t?t:"redirect/".concat(t,"/").concat(e))},domain:function(t){return c$3(t)?t:"".concat(Salla.config.get("store.url",window.location.href.split("/").slice(0,-1).join("/")).rtrim("/"),"/").concat(null==t?void 0:t.ltrim("/"))},get:u$3,is_full_url:c$3,is_page:function(t){return t&&Salla.config.get("page.slug")===t},is_placeholder:function(t){return d$3(salla.config.get("theme.settings.placeholder"))===d$3(t)}}),g$3=function(t,e){return g$3=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e;}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);},g$3(t,e)};var y$3=function(){return y$3=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},y$3.apply(this,arguments)};function v$2(t,e,r){if(2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}function m$3(t){return t instanceof FormData}function w$2(t){return t instanceof File}function S$2(t){return t instanceof Blob}"function"==typeof SuppressedError&&SuppressedError;var b$5=function(){function t(t){this.data=t,this.proxy=this.createProxy();}return t.prototype.createProxy=function(){var t=this;return new Proxy(this,{get:function(e,r){return r in e?e[r]:"string"==typeof r?t.get(r):void 0},set:function(e,r,n){return "string"==typeof r&&(t.set(r,n),true)},has:function(e,r){return "string"==typeof r?t.has(r):r in e},deleteProperty:function(e,r){return "string"==typeof r&&t.delete(r)}})},t.prototype.get=function(t){return m$3(this.data)?this.data.get(t):this.data[t]},t.prototype.getAll=function(t){if(m$3(this.data))return this.data.getAll(t);var e=this.data[t];return void 0===e?[]:[e]},t.prototype.set=function(t,e){var r=this;m$3(this.data)?(this.data.delete(t),null!=e&&(Array.isArray(e)?e.forEach((function(e){w$2(e)||S$2(e)?r.data.append(t,e):r.data.append(t,String(e));})):w$2(e)||S$2(e)?this.data.append(t,e):this.data.append(t,String(e)))):this.data[t]=e;},t.prototype.append=function(t,e){if(m$3(this.data))w$2(e)||S$2(e)?this.data.append(t,e):null!=e&&this.data.append(t,String(e));else {var r=this.data[t];void 0===r?this.data[t]=e:Array.isArray(r)?r.push(e):this.data[t]=[r,e];}},t.prototype.setFile=function(t,e){this.set(t,e);},t.prototype.getFile=function(t){var e=this.get(t);return w$2(e)?e:null},t.prototype.getFiles=function(t){return this.getAll(t).filter(w$2)},t.prototype.has=function(t){return m$3(this.data)?this.data.has(t):t in this.data},t.prototype.delete=function(t){return m$3(this.data)?(this.data.delete(t),true):delete this.data[t]},t.prototype.keys=function(){if(!m$3(this.data))return Object.keys(this.data);for(var t=new Set,e=0,r=this.data.entries();e<r.length;e++){var n=r[e][0];t.add(n);}return Array.from(t)},t.prototype.values=function(){if(!m$3(this.data))return Object.values(this.data);for(var t=[],e=0,r=this.data.entries();e<r.length;e++){var n=r[e][1];t.push(n);}return t},t.prototype.entries=function(){return m$3(this.data)?Array.from(this.data.entries()):Object.entries(this.data)},t.prototype.toObject=function(){if(!m$3(this.data))return y$3({},this.data);for(var t={},e=0,r=this.data.entries();e<r.length;e++){var n=r[e],o=n[0],i=n[1];void 0!==t[o]?(Array.isArray(t[o])||(t[o]=[t[o]]),t[o].push(i)):t[o]=i;}return t},t.prototype.getFileInfo=function(t){var e=this.getFiles(t);return 0===e.length?null:e.map((function(t){return {name:t.name,size:t.size,type:t.type}}))},t.prototype.isFile=function(t){var e=this.get(t);return w$2(e)||S$2(e)},t.prototype.getRawData=function(){return this.data},t.prototype.getProxy=function(){return this.proxy},t}();function _$2(t,e,r){var n,o=t[0];return r&&0==t.length?Array.isArray(r)?(r.push(e),r):[r,e]:Array.isArray(r)?(r.push(e),r):"string"==typeof r?[r,e]:r?(r[o]=_$2(t.slice(1),e,r[o]),r):o?((n={})[o]=_$2(t.slice(1),e),n):""===o?[e]:e}function x$3(){return window.self!==window.top}var A$3,E$3,k$3,P$2,O$2={digitsOnly:function(t){return s$2(t,true).replace(/[^0-9.]/g,"").replace("..",".").rtrim(".")},inputDigitsOnly:function t(e,r){if(void 0===r&&(r=false),"string"==typeof e)return document.querySelectorAll(e).forEach((function(e){return t(e,r)}));if(e){var n=Salla.helpers.digitsOnly(e.value);return e.min&&n<parseInt(e.min)?e.value=e.min:e.max&&n>parseInt(e.max)?e.value=e.max:e.maxLength>=1&&n.toString().length>e.maxLength?e.value=n.toString().substring(0,e.maxLength):e.value=r||e.dataset.hasOwnProperty("digitsWithDecimal")?l$2(n):n.replace(/\D/g,"")}Salla.logger.warn("Can't find Object With Id: "+e);},number:s$2,money:function(t,e){ void 0===e&&(e=true);var r=Salla.config.currency(null==t?void 0:t.currency).symbol;return t=s$2(t="object"==typeof t?t.amount:t)+" "+r,e&&["SAR","ر.س"].includes(r)&&Salla.config.get("store.settings.use_sar_symbol")&&(t=t.replace(r,"<i class=sicon-sar></i>")),t},isIframe:x$3,isPreview:function(){return x$3()},setNested:function(t,e,r){for(var n=t,o=e.split("."),i=o.length,a=0;a<i-1;a++){var s=o[a];n[s]||(n[s]={}),n=n[s];}return n[o[i-1]]=r,t},getNested:function(e,r,n){var o=t$2.default?t$2.default(e,r):t$2(e,r);return void 0!==o?o:n},inputData:function(t,e,r){if(void 0===r&&(r={}),t.includes("[")){var n=t.split("]").join("").split("["),o=n[0],i=r&&"object"==typeof r?r[o]:void 0;return {name:o,value:_$2(n.slice(1),e,i)}}return {name:t,value:e}},url:h$3,addParamToUrl:p$1,debounce:function(t,e){e=e||100;var r,n=[];return function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];return clearTimeout(r),r=setTimeout((function(){var e=t.apply(void 0,o);n.forEach((function(t){return t(e)})),n=[];}),e),new Promise((function(t){return n.push(t)}))}},hasApplePay:function(){var t;try{return !!(null===(t=window.ApplePaySession)||void 0===t?void 0:t.canMakePayments())}catch(t){return console.error(t),false}},createFormDataWrapper:function(t){return new b$5(t).getProxy()},isAppleDevice:function(){try{var t=navigator.userAgent||"",e=navigator.platform||"",r=/iPhone|iPad|iPod/i.test(t),n=/Mac/i.test(e);return r||n}catch(t){return console.error(t),false}}},j$3=(A$3=console,E$3=[],k$3=[],P$2={log:function(t,e){if(A$3&&salla.config.isDebug()){E$3.push([e,t]),"trace"===salla.config.get("debug")&&(e="trace");var r=A$3.log,n=void 0===e?r:this.__dict__[e]||r,o=["%cTwilight","color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;"];k$3.forEach((function(t){o[0]+=t[0],o.push(t[1]);}));var i={event:"#CFF680",backend:"#7b68ee"}[e];i&&(o[0]+="%c"+e[0].toUpperCase()+e.substring(1),o.push("margin-left: 5px;color: ".concat(i,";font-weight:bold; border:1px solid ").concat(i,"; padding: 2px 6px; border-radius: 5px;"))),n.call.apply(n,v$2([A$3],o.concat.apply(o,t),false));}},__dict__:{trace:A$3.trace,debug:A$3.debug,info:A$3.info,warn:A$3.warn,error:A$3.error}},{event:function(){P$2.log(arguments,"event");},trace:function(){P$2.log(arguments,"trace");},debug:function(){P$2.log(arguments,"debug");},info:function(){P$2.log(arguments,"info");},warn:function(){P$2.log(arguments,"warn");},error:function(){P$2.log(arguments,"error");},log:function(){P$2.log(arguments,void 0);},backend:function(){P$2.log(arguments,"backend");},logs:function(t){[t].flat().forEach((function(t){return t&&P$2.log([t].flat(),"backend")}));},history:function(){return E$3.map((function(t){return A$3.log.apply(A$3,v$2([t[0]],t[1],false))})),E$3},addPrefix:function(t){return Array.isArray(t)?k$3.unshift(t):this.warn("addPrefix receives array only!"),this}}),T$2=function(){function t(t,e){ void 0===t&&(t={}),void 0===e&&(e={}),this.default_properties=e,this.properties_=y$3(y$3({},this.default_properties),t);}return t.prototype.merge=function(t){var e;return this.properties_=y$3(y$3({},this.properties_),t),this.properties_.store=y$3(y$3({},(null===(e=this.default_properties)||void 0===e?void 0:e.store)||{}),this.properties_.store),this},t.prototype.set=function(t,e){return t.includes(".")?(Salla.helpers.setNested(this.properties_,t,e),this):(this.properties_[t]=e,this)},t.prototype.currency=function(t){return void 0===t&&(t=void 0),t=t||this.get("user.currency_code"),this.get("currencies."+t)||Object.values(this.get("currencies"))[0]},t.prototype.get=function(t,e){return void 0===e&&(e=null),t.includes(".")?Salla.helpers.getNested(this.properties_,t,e):this.properties_.hasOwnProperty(t)?this.properties_[t]||e:e||void 0},t.prototype.all=function(){return this.properties_},t.prototype.isDebug=function(){return this.get("debug")||Salla.storage.get("debug")},t}(),L$3=function(t){function e(){var e=this;return (e=t.call(this,{wildcard:true,delimiter:"::",newListener:false,removeListener:false,maxListeners:10,verboseMemoryLeak:false,ignoreErrors:false})||this).delimiter="::","undefined"!=typeof document&&(e.body=document.querySelector("body")),e.logableEvents=["cart::item.added.failed","cart::item.deleted.failed"],e.ingoreLogEvents=["document::click","document::keyup","document::change"],e.noneFireableActions=["document.request"],e.emittedEvents=new Set,e}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t;}g$3(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r);}(e,t),e.prototype.createAndDispatch=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];this.dispatch.apply(this,v$2([t],e,false));},e.prototype.emit=function(e){for(var r,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];this.emittedEvents.add(e);var i=e.replace("::",".");if(!this.noneFireableActions.includes(i)&&Salla.call&&"function"==typeof Salla.call(i))return Salla.log("'Salla.".concat(i,"(...)' triggered using event '").concat(e,"'")),i=i.split("."),Array.isArray(n[0])&&(n=n[0]),void(r=salla[i[0]])[i[1]].apply(r,n);t.prototype.emit.apply(this,v$2([e],n,false)),this.trackEvents.apply(this,v$2([e],n,false));},e.prototype.onlyWhen=function(t,e){var r=this;return e=e||function(){},new Promise((function(n){return r.emittedEvents.has(t)?n(e()):r.once(t,(function(){return n(e())}))}))},e.prototype.emitAsync=function(e){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];this.emittedEvents.add(e);var o=t.prototype.emitAsync.apply(this,v$2([e],r,false));try{this.trackEvents.apply(this,v$2([e],r,false));}catch(t){Salla.logger.warn("error on tracking event (".concat(e,")"),r,t);}return o},e.prototype.trackEvents=function(t){for(var e,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];if("undefined"!=typeof window)try{window.dataLayer=window.dataLayer||[];var o={event:t};r.map((function(t){return "object"==typeof t&&(o=y$3(y$3({},o),t))})),window.dataLayer.push(o);}catch(t){salla.logger.error(t.message);}Salla.logger&&!this.ingoreLogEvents.includes(t)&&(e=Salla.logger).event.apply(e,v$2([t],r,false)),this.dispatchMobileEvent.apply(this,v$2([t],r,false));},e.prototype.dispatch=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return this.emit.apply(this,v$2([t],e,false))},e.prototype.dispatchEvents=function(t){if(t)if("object"!=typeof t||Array.isArray(t))Salla.log("Events object is wrong, it should be object of {event:payload}",t);else for(var e=0,r=Object.entries(t);e<r.length;e++){var n=r[e],o=n[0],i=n[1];this.dispatch(o,i);}else Salla.log("No Events To Dispatch!",t);},e.prototype.addListener=function(t,e,r){return this.on(t,e,r)},e.prototype.addEventListener=function(t,e,r){return this.on(t,e,r)},e.prototype.listen=function(t,e){return this.on(t,e)},e.prototype.registerGlobalListener=function(t,e){return this.onAny(e)},e.prototype.dispatchMobileEvent=function(t,e){var r;if(void 0===e&&(e={}),"undefined"!=typeof window){if(window.webkit)try{return void window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:t,details:e}))}catch(t){Salla.log(t,"The native context does not exist yet");}if(null===(r=window.Android)||void 0===r?void 0:r.customEventWithData)try{window.Android.customEventWithData(t,JSON.stringify({details:e}));}catch(t){Salla.log(t,"The native context does not exist yet");}else if(window.flutter_inappwebview)try{window.flutter_inappwebview.callHandler("sallaEvent",{event:t,details:e});}catch(t){Salla.log(t,"The Flutter context does not exist yet");}else;}},e}(eventemitter2Exports.EventEmitter2),D$2=storeEngineExports.createStore([n$3,o$3,i$3,a$4],[]),W$3=storeEngineExports.createStore([o$3],[]),F$3=storeEngineExports.createStore([i$3],[]),C$3=function(){function t(){var t=this;this.clearableItems=["cart","user","salla::wishlist","token"],Salla.event.on("storage::item.remove",(function(e){return t.remove(e)})),Salla.event.on("storage::item.set",(function(e,r){return t.set(e,r)})),this.store=D$2,this.session=W$3,this.cookie=F$3;}return t.prototype.set=function(t,e){var r;if(t.includes(".")){var n=t.split(".")[0],o=((r={})[n]=this.store.get(n),r);return o=Salla.helpers.setNested(o,t,e),this.store.set(n,o[n])}return this.store.set(t,e)},t.prototype.remove=function(t){return this.store.remove(t)},t.prototype.clearAll=function(t){var e=this;if(void 0===t&&(t=false),t)return this.store.clearAll();this.clearableItems.forEach((function(t){e.store.remove(t);}));},t.prototype.get=function(t,e){var r;if(t.includes(".")){var n=t.split(".")[0];return Salla.helpers.getNested(((r={})[n]=this.store.get(n),r),t)}return this.store.get(t,e)},t.prototype.prefixKey=function(t){return "".concat(t,"_").concat(Salla.config.get("store.id"))},t.prototype.setWithTTL=function(t,e,r,n){ void 0===r&&(r=10),void 0===n&&(n="store");var o=this.prefixKey(t),i=(new Date).getTime()+60*r*1e3;return this[n].set(o,{value:e,expiry:i})},t.prototype.getWithTTL=function(t,e,r){ void 0===e&&(e=null),void 0===r&&(r="store");var n=this.prefixKey(t),o=this[r].get(n);return o?(new Date).getTime()>o.expiry?(this[r].remove(n),e):o.value:e},t}(),R$3=function(){function t(){var t=this;this.keysToRemove=["__said","__ssid","theme_edit","ws_port","s-token"],this.dynamicKeysToRemove=["affiliate","cart"],Salla.event.on("cookies::remove",(function(e){return t.remove(e)})),Salla.event.on("cookies::add",(function(e,r){return t.set(e,r)}));}return t.prototype.get=function(t){var e;return null===(e=document.cookie.split("; ").find((function(e){return e.startsWith(t+"=")})))||void 0===e?void 0:e.split("=")[1]},t.prototype.set=function(t,e,r){ void 0===e&&(e=""),void 0===r&&(r=10);var n="";if(r){var o=new Date;o.setTime(o.getTime()+24*r*60*60*1e3),n="; expires="+o.toUTCString();}var i=salla.helpers.isIframe()?"None":"Lax";return document.cookie="".concat(t,"=").concat(e).concat(n,"; path=/; SameSite=").concat(i,"; secure"),this},t.prototype.remove=function(t){var e=salla.helpers.isIframe()?"None":"Lax";return document.cookie="".concat(t,"=; Max-Age=0; path=/; SameSite=").concat(e,"; secure"),this},t.prototype.clearAll=function(t){return void 0===t&&(t=false),this.clean(t)},t.prototype.clean=function(t){var e=this;return document.cookie.split(";").map((function(t){return t.split("=")[0].trim()})).filter((function(r){return t||e.keysToRemove.includes(r)||e.dynamicKeysToRemove.some((function(t){return r.startsWith(t)}))})).forEach((function(t){return e.remove(t)})),this},t.prototype.getCookieByPrefix=function(t){return document.cookie.split("; ").map((function(t){return t.split("=")[0]})).filter((function(e){return e.startsWith(t)}))},t.prototype.clearCookieByPrefix=function(t){var e=this;return this.getCookieByPrefix(t).forEach((function(t){return e.remove(t)}))},t}();"undefined"!=typeof window&&(window.salla=window.salla||window.Salla||{},window.Salla=window.salla),"undefined"!=typeof global&&(global.salla=global.salla||global.Salla||{},global.Salla=global.salla),Salla.status="base",Salla.config=new T$2,Salla.logger=j$3,Salla.event=new L$3,Salla.helpers=O$2,Salla.storage=new C$3,Salla.cookie=new R$3,Salla.log=Salla.logger.log,Salla.money=Salla.helpers.money,Salla.url=Salla.helpers.url,Salla.versions={base:"2.14.311"};var N$3=Salla;
|
|
4024
|
+
function s$2(t,e){ void 0===e&&(e=false),t+="";for(var r,n=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],o=["0","1","2","3","4","5","6","7","8","9"],i=(e=e||!Salla.config.get("store.settings.arabic_numbers_enabled"))?n:o,a=e?o:n,s=0;s<i.length;s++)r=new RegExp(i[s],"g"),t=t.replace(r,a[s]);return t.replace(e?"٫":".",e?".":"٫")}function l$2(t){var e=("".concat(t).match(/\./g)||[]).length;return e&&1!==e?l$2(t.replace(/\.(.+)\./g,".$1")):t}function c$3(t){return "".concat(t).startsWith("https://")||"".concat(t).startsWith("http://")}function u$3(t){if(c$3(t))return t;var e=Salla.config.get("store.url");return e||(e=window.location.href.split("/").slice(0,-1).join("/"),Salla.config.set("store.url",e)),e.rtrim("/")+"/"+(null==t?void 0:t.ltrim("/"))}function p$1(t,e,r){if(r=r||window.location.href,!e||!t)return r;var n=new RegExp("([?&])"+t+"=[^&]+[&]?","g");return (r=r.replace(n,"$1").split("#")[0].replace(/&$|\?$/,"")).includes("?")?r+="&":r+=(r.endsWith("/")?"":"/")+"?",(r+t+"="+encodeURIComponent(e)).replace(/&$|\?$/,"")}function f$2(t){return window.location.origin+"/"+(null==t?void 0:t.ltrim("/"))}function d$3(t){return c$3(t)?t:Salla.config.get("theme.assets")?Salla.config.get("theme.assets").replace(":path",null==t?void 0:t.ltrim("/")):f$2("themes/"+Salla.config.get("theme.name")+"/"+(null==t?void 0:t.ltrim("/")))}String.prototype.toStudlyCase=function(){return this.trim().replace(/([^a-zA-Z\d].)/g,(function(t){return t.toUpperCase().replace(/[^a-zA-Z\d]/g,"")}))},String.prototype.toDatasetName=function(){return this.startsWith("data-")?this.substr(5).toStudlyCase():this.toStudlyCase()},String.prototype.toSelector=function(){return this.trim().startsWith(".")||this.trim().startsWith("#")?this.toString():"#"+this.toString()},String.prototype.replaceArray=function(t,e){for(var r,n=this,o=0;o<t.length;o++)r=new RegExp(t[o],"g"),n=n.replace(r,e[o]);return n},String.prototype.rtrim=function(t){return void 0===t&&(t="\\s"),this.replace(new RegExp("["+t+"]*$"),"")},String.prototype.ltrim=function(t){return void 0===t&&(t="\\s"),this.replace(new RegExp("^["+t+"]*"),"")},String.prototype.digitsOnly=function(){return Salla.helpers.digitsOnly(this)};var h$3=Object.freeze({__proto__:null,addParamToUrl:p$1,api:function(t){var e;return (null===(e=Salla.config.get("store.api",u$3("")))||void 0===e?void 0:e.rtrim("/"))+"/"+(null==t?void 0:t.ltrim("/"))},asset:d$3,base:function(t){return c$3(t)?t:"https://"+new URL(u$3("/")).hostname+"/"+(null==t?void 0:t.ltrim("/"))},baseUrl:f$2,cdn:function(t,e,r){var n="https://cdn.salla.network/";return (e||r)&&(e=e?",width=".concat(e):"",r=r?",height=".concat(r):"",n+="cdn-cgi/image/fit=scale-down".concat(e).concat(r,",onerror=redirect,format=auto/")),n+(null==t?void 0:t.ltrim("/"))},create:function(t,e){return "custom"===t?e:u$3("offers"===t?t:"redirect/".concat(t,"/").concat(e))},domain:function(t){return c$3(t)?t:"".concat(Salla.config.get("store.url",window.location.href.split("/").slice(0,-1).join("/")).rtrim("/"),"/").concat(null==t?void 0:t.ltrim("/"))},get:u$3,is_full_url:c$3,is_page:function(t){return t&&Salla.config.get("page.slug")===t},is_placeholder:function(t){return d$3(salla.config.get("theme.settings.placeholder"))===d$3(t)}}),g$3=function(t,e){return g$3=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e;}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);},g$3(t,e)};var y$3=function(){return y$3=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},y$3.apply(this,arguments)};function v$2(t,e,r){if(2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}function m$3(t){return t instanceof FormData}function w$2(t){return t instanceof File}function S$2(t){return t instanceof Blob}"function"==typeof SuppressedError&&SuppressedError;var b$5=function(){function t(t){this.data=t,this.proxy=this.createProxy();}return t.prototype.createProxy=function(){var t=this;return new Proxy(this,{get:function(e,r){return r in e?e[r]:"string"==typeof r?t.get(r):void 0},set:function(e,r,n){return "string"==typeof r&&(t.set(r,n),true)},has:function(e,r){return "string"==typeof r?t.has(r):r in e},deleteProperty:function(e,r){return "string"==typeof r&&t.delete(r)}})},t.prototype.get=function(t){return m$3(this.data)?this.data.get(t):this.data[t]},t.prototype.getAll=function(t){if(m$3(this.data))return this.data.getAll(t);var e=this.data[t];return void 0===e?[]:[e]},t.prototype.set=function(t,e){var r=this;m$3(this.data)?(this.data.delete(t),null!=e&&(Array.isArray(e)?e.forEach((function(e){w$2(e)||S$2(e)?r.data.append(t,e):r.data.append(t,String(e));})):w$2(e)||S$2(e)?this.data.append(t,e):this.data.append(t,String(e)))):this.data[t]=e;},t.prototype.append=function(t,e){if(m$3(this.data))w$2(e)||S$2(e)?this.data.append(t,e):null!=e&&this.data.append(t,String(e));else {var r=this.data[t];void 0===r?this.data[t]=e:Array.isArray(r)?r.push(e):this.data[t]=[r,e];}},t.prototype.setFile=function(t,e){this.set(t,e);},t.prototype.getFile=function(t){var e=this.get(t);return w$2(e)?e:null},t.prototype.getFiles=function(t){return this.getAll(t).filter(w$2)},t.prototype.has=function(t){return m$3(this.data)?this.data.has(t):t in this.data},t.prototype.delete=function(t){return m$3(this.data)?(this.data.delete(t),true):delete this.data[t]},t.prototype.keys=function(){if(!m$3(this.data))return Object.keys(this.data);for(var t=new Set,e=0,r=this.data.entries();e<r.length;e++){var n=r[e][0];t.add(n);}return Array.from(t)},t.prototype.values=function(){if(!m$3(this.data))return Object.values(this.data);for(var t=[],e=0,r=this.data.entries();e<r.length;e++){var n=r[e][1];t.push(n);}return t},t.prototype.entries=function(){return m$3(this.data)?Array.from(this.data.entries()):Object.entries(this.data)},t.prototype.toObject=function(){if(!m$3(this.data))return y$3({},this.data);for(var t={},e=0,r=this.data.entries();e<r.length;e++){var n=r[e],o=n[0],i=n[1];void 0!==t[o]?(Array.isArray(t[o])||(t[o]=[t[o]]),t[o].push(i)):t[o]=i;}return t},t.prototype.getFileInfo=function(t){var e=this.getFiles(t);return 0===e.length?null:e.map((function(t){return {name:t.name,size:t.size,type:t.type}}))},t.prototype.isFile=function(t){var e=this.get(t);return w$2(e)||S$2(e)},t.prototype.getRawData=function(){return this.data},t.prototype.getProxy=function(){return this.proxy},t}();function _$2(t,e,r){var n,o=t[0];return r&&0==t.length?Array.isArray(r)?(r.push(e),r):[r,e]:Array.isArray(r)?(r.push(e),r):"string"==typeof r?[r,e]:r?(r[o]=_$2(t.slice(1),e,r[o]),r):o?((n={})[o]=_$2(t.slice(1),e),n):""===o?[e]:e}function x$3(){return window.self!==window.top}var A$3,E$3,k$3,P$2,O$2={digitsOnly:function(t){return s$2(t,true).replace(/[^0-9.]/g,"").replace("..",".").rtrim(".")},inputDigitsOnly:function t(e,r){if(void 0===r&&(r=false),"string"==typeof e)return document.querySelectorAll(e).forEach((function(e){return t(e,r)}));if(e){var n=Salla.helpers.digitsOnly(e.value);return e.min&&n<parseInt(e.min)?e.value=e.min:e.max&&n>parseInt(e.max)?e.value=e.max:e.maxLength>=1&&n.toString().length>e.maxLength?e.value=n.toString().substring(0,e.maxLength):e.value=r||e.dataset.hasOwnProperty("digitsWithDecimal")?l$2(n):n.replace(/\D/g,"")}Salla.logger.warn("Can't find Object With Id: "+e);},number:s$2,money:function(t,e){ void 0===e&&(e=true);var r=Salla.config.currency(null==t?void 0:t.currency).symbol;return t=s$2(t="object"==typeof t?t.amount:t)+" "+r,e&&["SAR","ر.س"].includes(r)&&Salla.config.get("store.settings.use_sar_symbol")&&(t=t.replace(r,"<i class=sicon-sar></i>")),t},isIframe:x$3,isPreview:function(){return x$3()},setNested:function(t,e,r){for(var n=t,o=e.split("."),i=o.length,a=0;a<i-1;a++){var s=o[a];n[s]||(n[s]={}),n=n[s];}return n[o[i-1]]=r,t},getNested:function(e,r,n){var o=t$2.default?t$2.default(e,r):t$2(e,r);return void 0!==o?o:n},inputData:function(t,e,r){if(void 0===r&&(r={}),t.includes("[")){var n=t.split("]").join("").split("["),o=n[0],i=r&&"object"==typeof r?r[o]:void 0;return {name:o,value:_$2(n.slice(1),e,i)}}return {name:t,value:e}},url:h$3,addParamToUrl:p$1,debounce:function(t,e){e=e||100;var r,n=[];return function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];return clearTimeout(r),r=setTimeout((function(){var e=t.apply(void 0,o);n.forEach((function(t){return t(e)})),n=[];}),e),new Promise((function(t){return n.push(t)}))}},hasApplePay:function(){var t;try{return !!(null===(t=window.ApplePaySession)||void 0===t?void 0:t.canMakePayments())}catch(t){return console.error(t),false}},createFormDataWrapper:function(t){return new b$5(t).getProxy()},isAppleDevice:function(){try{var t=navigator.userAgent||"",e=navigator.platform||"",r=/iPhone|iPad|iPod/i.test(t),n=/Mac/i.test(e);return r||n}catch(t){return console.error(t),false}},isIOSDevice:function(){try{var t=navigator.userAgent||"";return /iPhone|iPad|iPod/i.test(t)}catch(t){return console.error(t),false}}},j$3=(A$3=console,E$3=[],k$3=[],P$2={log:function(t,e){if(A$3&&salla.config.isDebug()){E$3.push([e,t]),"trace"===salla.config.get("debug")&&(e="trace");var r=A$3.log,n=void 0===e?r:this.__dict__[e]||r,o=["%cTwilight","color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;"];k$3.forEach((function(t){o[0]+=t[0],o.push(t[1]);}));var i={event:"#CFF680",backend:"#7b68ee"}[e];i&&(o[0]+="%c"+e[0].toUpperCase()+e.substring(1),o.push("margin-left: 5px;color: ".concat(i,";font-weight:bold; border:1px solid ").concat(i,"; padding: 2px 6px; border-radius: 5px;"))),n.call.apply(n,v$2([A$3],o.concat.apply(o,t),false));}},__dict__:{trace:A$3.trace,debug:A$3.debug,info:A$3.info,warn:A$3.warn,error:A$3.error}},{event:function(){P$2.log(arguments,"event");},trace:function(){P$2.log(arguments,"trace");},debug:function(){P$2.log(arguments,"debug");},info:function(){P$2.log(arguments,"info");},warn:function(){P$2.log(arguments,"warn");},error:function(){P$2.log(arguments,"error");},log:function(){P$2.log(arguments,void 0);},backend:function(){P$2.log(arguments,"backend");},logs:function(t){[t].flat().forEach((function(t){return t&&P$2.log([t].flat(),"backend")}));},history:function(){return E$3.map((function(t){return A$3.log.apply(A$3,v$2([t[0]],t[1],false))})),E$3},addPrefix:function(t){return Array.isArray(t)?k$3.unshift(t):this.warn("addPrefix receives array only!"),this}}),T$2=function(){function t(t,e){ void 0===t&&(t={}),void 0===e&&(e={}),this.default_properties=e,this.properties_=y$3(y$3({},this.default_properties),t);}return t.prototype.merge=function(t){var e;return this.properties_=y$3(y$3({},this.properties_),t),this.properties_.store=y$3(y$3({},(null===(e=this.default_properties)||void 0===e?void 0:e.store)||{}),this.properties_.store),this},t.prototype.set=function(t,e){return t.includes(".")?(Salla.helpers.setNested(this.properties_,t,e),this):(this.properties_[t]=e,this)},t.prototype.currency=function(t){return void 0===t&&(t=void 0),t=t||this.get("user.currency_code"),this.get("currencies."+t)||Object.values(this.get("currencies"))[0]},t.prototype.get=function(t,e){return void 0===e&&(e=null),t.includes(".")?Salla.helpers.getNested(this.properties_,t,e):this.properties_.hasOwnProperty(t)?this.properties_[t]||e:e||void 0},t.prototype.all=function(){return this.properties_},t.prototype.isDebug=function(){return this.get("debug")||Salla.storage.get("debug")},t}(),L$3=function(t){function e(){var e=this;return (e=t.call(this,{wildcard:true,delimiter:"::",newListener:false,removeListener:false,maxListeners:10,verboseMemoryLeak:false,ignoreErrors:false})||this).delimiter="::","undefined"!=typeof document&&(e.body=document.querySelector("body")),e.logableEvents=["cart::item.added.failed","cart::item.deleted.failed"],e.ingoreLogEvents=["document::click","document::keyup","document::change"],e.noneFireableActions=["document.request"],e.emittedEvents=new Set,e}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t;}g$3(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r);}(e,t),e.prototype.createAndDispatch=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];this.dispatch.apply(this,v$2([t],e,false));},e.prototype.emit=function(e){for(var r,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];this.emittedEvents.add(e);var i=e.replace("::",".");if(!this.noneFireableActions.includes(i)&&Salla.call&&"function"==typeof Salla.call(i))return Salla.log("'Salla.".concat(i,"(...)' triggered using event '").concat(e,"'")),i=i.split("."),Array.isArray(n[0])&&(n=n[0]),void(r=salla[i[0]])[i[1]].apply(r,n);t.prototype.emit.apply(this,v$2([e],n,false)),this.trackEvents.apply(this,v$2([e],n,false));},e.prototype.onlyWhen=function(t,e){var r=this;return e=e||function(){},new Promise((function(n){return r.emittedEvents.has(t)?n(e()):r.once(t,(function(){return n(e())}))}))},e.prototype.emitAsync=function(e){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];this.emittedEvents.add(e);var o=t.prototype.emitAsync.apply(this,v$2([e],r,false));try{this.trackEvents.apply(this,v$2([e],r,false));}catch(t){Salla.logger.warn("error on tracking event (".concat(e,")"),r,t);}return o},e.prototype.trackEvents=function(t){for(var e,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];if("undefined"!=typeof window)try{window.dataLayer=window.dataLayer||[];var o={event:t};r.map((function(t){return "object"==typeof t&&(o=y$3(y$3({},o),t))})),window.dataLayer.push(o);}catch(t){salla.logger.error(t.message);}Salla.logger&&!this.ingoreLogEvents.includes(t)&&(e=Salla.logger).event.apply(e,v$2([t],r,false)),this.dispatchMobileEvent.apply(this,v$2([t],r,false));},e.prototype.dispatch=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return this.emit.apply(this,v$2([t],e,false))},e.prototype.dispatchEvents=function(t){if(t)if("object"!=typeof t||Array.isArray(t))Salla.log("Events object is wrong, it should be object of {event:payload}",t);else for(var e=0,r=Object.entries(t);e<r.length;e++){var n=r[e],o=n[0],i=n[1];this.dispatch(o,i);}else Salla.log("No Events To Dispatch!",t);},e.prototype.addListener=function(t,e,r){return this.on(t,e,r)},e.prototype.addEventListener=function(t,e,r){return this.on(t,e,r)},e.prototype.listen=function(t,e){return this.on(t,e)},e.prototype.registerGlobalListener=function(t,e){return this.onAny(e)},e.prototype.dispatchMobileEvent=function(t,e){var r;if(void 0===e&&(e={}),"undefined"!=typeof window){if(window.webkit)try{return void window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:t,details:e}))}catch(t){Salla.log(t,"The native context does not exist yet");}if(null===(r=window.Android)||void 0===r?void 0:r.customEventWithData)try{window.Android.customEventWithData(t,JSON.stringify({details:e}));}catch(t){Salla.log(t,"The native context does not exist yet");}else if(window.flutter_inappwebview)try{window.flutter_inappwebview.callHandler("sallaEvent",{event:t,details:e});}catch(t){Salla.log(t,"The Flutter context does not exist yet");}else;}},e}(eventemitter2Exports.EventEmitter2),D$2=storeEngineExports.createStore([n$3,o$3,i$3,a$4],[]),W$3=storeEngineExports.createStore([o$3],[]),F$3=storeEngineExports.createStore([i$3],[]),C$3=function(){function t(){var t=this;this.clearableItems=["cart","user","salla::wishlist","token"],Salla.event.on("storage::item.remove",(function(e){return t.remove(e)})),Salla.event.on("storage::item.set",(function(e,r){return t.set(e,r)})),this.store=D$2,this.session=W$3,this.cookie=F$3;}return t.prototype.set=function(t,e){var r;if(t.includes(".")){var n=t.split(".")[0],o=((r={})[n]=this.store.get(n),r);return o=Salla.helpers.setNested(o,t,e),this.store.set(n,o[n])}return this.store.set(t,e)},t.prototype.remove=function(t){return this.store.remove(t)},t.prototype.clearAll=function(t){var e=this;if(void 0===t&&(t=false),t)return this.store.clearAll();this.clearableItems.forEach((function(t){e.store.remove(t);}));},t.prototype.get=function(t,e){var r;if(t.includes(".")){var n=t.split(".")[0];return Salla.helpers.getNested(((r={})[n]=this.store.get(n),r),t)}return this.store.get(t,e)},t.prototype.prefixKey=function(t){return "".concat(t,"_").concat(Salla.config.get("store.id"))},t.prototype.setWithTTL=function(t,e,r,n){ void 0===r&&(r=10),void 0===n&&(n="store");var o=this.prefixKey(t),i=(new Date).getTime()+60*r*1e3;return this[n].set(o,{value:e,expiry:i})},t.prototype.getWithTTL=function(t,e,r){ void 0===e&&(e=null),void 0===r&&(r="store");var n=this.prefixKey(t),o=this[r].get(n);return o?(new Date).getTime()>o.expiry?(this[r].remove(n),e):o.value:e},t}(),R$3=function(){function t(){var t=this;this.keysToRemove=["__said","__ssid","theme_edit","ws_port","s-token"],this.dynamicKeysToRemove=["affiliate","cart"],Salla.event.on("cookies::remove",(function(e){return t.remove(e)})),Salla.event.on("cookies::add",(function(e,r){return t.set(e,r)}));}return t.prototype.get=function(t){var e;return null===(e=document.cookie.split("; ").find((function(e){return e.startsWith(t+"=")})))||void 0===e?void 0:e.split("=")[1]},t.prototype.set=function(t,e,r){ void 0===e&&(e=""),void 0===r&&(r=10);var n="";if(r){var o=new Date;o.setTime(o.getTime()+24*r*60*60*1e3),n="; expires="+o.toUTCString();}var i=salla.helpers.isIframe()?"None":"Lax";return document.cookie="".concat(t,"=").concat(e).concat(n,"; path=/; SameSite=").concat(i,"; secure"),this},t.prototype.remove=function(t){var e=salla.helpers.isIframe()?"None":"Lax";return document.cookie="".concat(t,"=; Max-Age=0; path=/; SameSite=").concat(e,"; secure"),this},t.prototype.clearAll=function(t){return void 0===t&&(t=false),this.clean(t)},t.prototype.clean=function(t){var e=this;return document.cookie.split(";").map((function(t){return t.split("=")[0].trim()})).filter((function(r){return t||e.keysToRemove.includes(r)||e.dynamicKeysToRemove.some((function(t){return r.startsWith(t)}))})).forEach((function(t){return e.remove(t)})),this},t.prototype.getCookieByPrefix=function(t){return document.cookie.split("; ").map((function(t){return t.split("=")[0]})).filter((function(e){return e.startsWith(t)}))},t.prototype.clearCookieByPrefix=function(t){var e=this;return this.getCookieByPrefix(t).forEach((function(t){return e.remove(t)}))},t}();"undefined"!=typeof window&&(window.salla=window.salla||window.Salla||{},window.Salla=window.salla),"undefined"!=typeof global&&(global.salla=global.salla||global.Salla||{},global.Salla=global.salla),Salla.status="base",Salla.config=new T$2,Salla.logger=j$3,Salla.event=new L$3,Salla.helpers=O$2,Salla.storage=new C$3,Salla.cookie=new R$3,Salla.log=Salla.logger.log,Salla.money=Salla.helpers.money,Salla.url=Salla.helpers.url,Salla.versions={base:"2.14.337"};var N$3=Salla;
|
|
4025
4025
|
|
|
4026
4026
|
var js = {exports: {}};
|
|
4027
4027
|
|
|
@@ -6269,7 +6269,7 @@ function requireLang () {
|
|
|
6269
6269
|
var langExports = requireLang();
|
|
6270
6270
|
var a$3 = /*@__PURE__*/getDefaultExportFromCjs(langExports);
|
|
6271
6271
|
|
|
6272
|
-
/*! Axios v1.
|
|
6272
|
+
/*! Axios v1.13.3 Copyright (c) 2026 Matt Zabriskie and contributors */
|
|
6273
6273
|
|
|
6274
6274
|
var axios_1;
|
|
6275
6275
|
var hasRequiredAxios;
|
|
@@ -6278,6 +6278,13 @@ function requireAxios () {
|
|
|
6278
6278
|
if (hasRequiredAxios) return axios_1;
|
|
6279
6279
|
hasRequiredAxios = 1;
|
|
6280
6280
|
|
|
6281
|
+
/**
|
|
6282
|
+
* Create a bound version of a function with a specified `this` context
|
|
6283
|
+
*
|
|
6284
|
+
* @param {Function} fn - The function to bind
|
|
6285
|
+
* @param {*} thisArg - The value to be passed as the `this` parameter
|
|
6286
|
+
* @returns {Function} A new function that will call the original function with the specified `this` context
|
|
6287
|
+
*/
|
|
6281
6288
|
function bind(fn, thisArg) {
|
|
6282
6289
|
return function wrap() {
|
|
6283
6290
|
return fn.apply(thisArg, arguments);
|
|
@@ -6329,7 +6336,7 @@ function requireAxios () {
|
|
|
6329
6336
|
*/
|
|
6330
6337
|
function isBuffer(val) {
|
|
6331
6338
|
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
|
|
6332
|
-
&& isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
|
6339
|
+
&& isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
|
6333
6340
|
}
|
|
6334
6341
|
|
|
6335
6342
|
/**
|
|
@@ -6374,7 +6381,7 @@ function requireAxios () {
|
|
|
6374
6381
|
* @param {*} val The value to test
|
|
6375
6382
|
* @returns {boolean} True if value is a Function, otherwise false
|
|
6376
6383
|
*/
|
|
6377
|
-
const isFunction = typeOfTest('function');
|
|
6384
|
+
const isFunction$1 = typeOfTest('function');
|
|
6378
6385
|
|
|
6379
6386
|
/**
|
|
6380
6387
|
* Determine if a value is a Number
|
|
@@ -6418,6 +6425,27 @@ function requireAxios () {
|
|
|
6418
6425
|
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
|
|
6419
6426
|
};
|
|
6420
6427
|
|
|
6428
|
+
/**
|
|
6429
|
+
* Determine if a value is an empty object (safely handles Buffers)
|
|
6430
|
+
*
|
|
6431
|
+
* @param {*} val The value to test
|
|
6432
|
+
*
|
|
6433
|
+
* @returns {boolean} True if value is an empty object, otherwise false
|
|
6434
|
+
*/
|
|
6435
|
+
const isEmptyObject = (val) => {
|
|
6436
|
+
// Early return for non-objects or Buffers to prevent RangeError
|
|
6437
|
+
if (!isObject(val) || isBuffer(val)) {
|
|
6438
|
+
return false;
|
|
6439
|
+
}
|
|
6440
|
+
|
|
6441
|
+
try {
|
|
6442
|
+
return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
|
6443
|
+
} catch (e) {
|
|
6444
|
+
// Fallback for any other objects that might cause RangeError with Object.keys()
|
|
6445
|
+
return false;
|
|
6446
|
+
}
|
|
6447
|
+
};
|
|
6448
|
+
|
|
6421
6449
|
/**
|
|
6422
6450
|
* Determine if a value is a Date
|
|
6423
6451
|
*
|
|
@@ -6461,7 +6489,7 @@ function requireAxios () {
|
|
|
6461
6489
|
*
|
|
6462
6490
|
* @returns {boolean} True if value is a Stream, otherwise false
|
|
6463
6491
|
*/
|
|
6464
|
-
const isStream = (val) => isObject(val) && isFunction(val.pipe);
|
|
6492
|
+
const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
|
|
6465
6493
|
|
|
6466
6494
|
/**
|
|
6467
6495
|
* Determine if a value is a FormData
|
|
@@ -6474,10 +6502,10 @@ function requireAxios () {
|
|
|
6474
6502
|
let kind;
|
|
6475
6503
|
return thing && (
|
|
6476
6504
|
(typeof FormData === 'function' && thing instanceof FormData) || (
|
|
6477
|
-
isFunction(thing.append) && (
|
|
6505
|
+
isFunction$1(thing.append) && (
|
|
6478
6506
|
(kind = kindOf(thing)) === 'formdata' ||
|
|
6479
6507
|
// detect form-data instance
|
|
6480
|
-
(kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
|
|
6508
|
+
(kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
|
|
6481
6509
|
)
|
|
6482
6510
|
)
|
|
6483
6511
|
)
|
|
@@ -6513,10 +6541,11 @@ function requireAxios () {
|
|
|
6513
6541
|
* If 'obj' is an Object callback will be called passing
|
|
6514
6542
|
* the value, key, and complete object for each property.
|
|
6515
6543
|
*
|
|
6516
|
-
* @param {Object|Array} obj The object to iterate
|
|
6544
|
+
* @param {Object|Array<unknown>} obj The object to iterate
|
|
6517
6545
|
* @param {Function} fn The callback to invoke for each item
|
|
6518
6546
|
*
|
|
6519
|
-
* @param {
|
|
6547
|
+
* @param {Object} [options]
|
|
6548
|
+
* @param {Boolean} [options.allOwnKeys = false]
|
|
6520
6549
|
* @returns {any}
|
|
6521
6550
|
*/
|
|
6522
6551
|
function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
@@ -6540,6 +6569,11 @@ function requireAxios () {
|
|
|
6540
6569
|
fn.call(null, obj[i], i, obj);
|
|
6541
6570
|
}
|
|
6542
6571
|
} else {
|
|
6572
|
+
// Buffer check
|
|
6573
|
+
if (isBuffer(obj)) {
|
|
6574
|
+
return;
|
|
6575
|
+
}
|
|
6576
|
+
|
|
6543
6577
|
// Iterate over object keys
|
|
6544
6578
|
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
|
6545
6579
|
const len = keys.length;
|
|
@@ -6553,6 +6587,10 @@ function requireAxios () {
|
|
|
6553
6587
|
}
|
|
6554
6588
|
|
|
6555
6589
|
function findKey(obj, key) {
|
|
6590
|
+
if (isBuffer(obj)){
|
|
6591
|
+
return null;
|
|
6592
|
+
}
|
|
6593
|
+
|
|
6556
6594
|
key = key.toLowerCase();
|
|
6557
6595
|
const keys = Object.keys(obj);
|
|
6558
6596
|
let i = keys.length;
|
|
@@ -6584,7 +6622,7 @@ function requireAxios () {
|
|
|
6584
6622
|
* Example:
|
|
6585
6623
|
*
|
|
6586
6624
|
* ```js
|
|
6587
|
-
*
|
|
6625
|
+
* const result = merge({foo: 123}, {foo: 456});
|
|
6588
6626
|
* console.log(result.foo); // outputs 456
|
|
6589
6627
|
* ```
|
|
6590
6628
|
*
|
|
@@ -6593,7 +6631,7 @@ function requireAxios () {
|
|
|
6593
6631
|
* @returns {Object} Result of all merge properties
|
|
6594
6632
|
*/
|
|
6595
6633
|
function merge(/* obj1, obj2, obj3, ... */) {
|
|
6596
|
-
const {caseless} = isContextDefined(this) && this || {};
|
|
6634
|
+
const {caseless, skipUndefined} = isContextDefined(this) && this || {};
|
|
6597
6635
|
const result = {};
|
|
6598
6636
|
const assignValue = (val, key) => {
|
|
6599
6637
|
const targetKey = caseless && findKey(result, key) || key;
|
|
@@ -6603,7 +6641,7 @@ function requireAxios () {
|
|
|
6603
6641
|
result[targetKey] = merge({}, val);
|
|
6604
6642
|
} else if (isArray(val)) {
|
|
6605
6643
|
result[targetKey] = val.slice();
|
|
6606
|
-
} else {
|
|
6644
|
+
} else if (!skipUndefined || !isUndefined(val)) {
|
|
6607
6645
|
result[targetKey] = val;
|
|
6608
6646
|
}
|
|
6609
6647
|
};
|
|
@@ -6621,15 +6659,26 @@ function requireAxios () {
|
|
|
6621
6659
|
* @param {Object} b The object to copy properties from
|
|
6622
6660
|
* @param {Object} thisArg The object to bind function to
|
|
6623
6661
|
*
|
|
6624
|
-
* @param {
|
|
6662
|
+
* @param {Object} [options]
|
|
6663
|
+
* @param {Boolean} [options.allOwnKeys]
|
|
6625
6664
|
* @returns {Object} The resulting value of object a
|
|
6626
6665
|
*/
|
|
6627
6666
|
const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
|
|
6628
6667
|
forEach(b, (val, key) => {
|
|
6629
|
-
if (thisArg && isFunction(val)) {
|
|
6630
|
-
a
|
|
6668
|
+
if (thisArg && isFunction$1(val)) {
|
|
6669
|
+
Object.defineProperty(a, key, {
|
|
6670
|
+
value: bind(val, thisArg),
|
|
6671
|
+
writable: true,
|
|
6672
|
+
enumerable: true,
|
|
6673
|
+
configurable: true
|
|
6674
|
+
});
|
|
6631
6675
|
} else {
|
|
6632
|
-
a
|
|
6676
|
+
Object.defineProperty(a, key, {
|
|
6677
|
+
value: val,
|
|
6678
|
+
writable: true,
|
|
6679
|
+
enumerable: true,
|
|
6680
|
+
configurable: true
|
|
6681
|
+
});
|
|
6633
6682
|
}
|
|
6634
6683
|
}, {allOwnKeys});
|
|
6635
6684
|
return a;
|
|
@@ -6660,7 +6709,12 @@ function requireAxios () {
|
|
|
6660
6709
|
*/
|
|
6661
6710
|
const inherits = (constructor, superConstructor, props, descriptors) => {
|
|
6662
6711
|
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
|
6663
|
-
constructor.prototype
|
|
6712
|
+
Object.defineProperty(constructor.prototype, 'constructor', {
|
|
6713
|
+
value: constructor,
|
|
6714
|
+
writable: true,
|
|
6715
|
+
enumerable: false,
|
|
6716
|
+
configurable: true
|
|
6717
|
+
});
|
|
6664
6718
|
Object.defineProperty(constructor, 'super', {
|
|
6665
6719
|
value: superConstructor.prototype
|
|
6666
6720
|
});
|
|
@@ -6842,13 +6896,13 @@ function requireAxios () {
|
|
|
6842
6896
|
const freezeMethods = (obj) => {
|
|
6843
6897
|
reduceDescriptors(obj, (descriptor, name) => {
|
|
6844
6898
|
// skip restricted props in strict mode
|
|
6845
|
-
if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
|
6899
|
+
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
|
6846
6900
|
return false;
|
|
6847
6901
|
}
|
|
6848
6902
|
|
|
6849
6903
|
const value = obj[name];
|
|
6850
6904
|
|
|
6851
|
-
if (!isFunction(value)) return;
|
|
6905
|
+
if (!isFunction$1(value)) return;
|
|
6852
6906
|
|
|
6853
6907
|
descriptor.enumerable = false;
|
|
6854
6908
|
|
|
@@ -6885,6 +6939,8 @@ function requireAxios () {
|
|
|
6885
6939
|
return value != null && Number.isFinite(value = +value) ? value : defaultValue;
|
|
6886
6940
|
};
|
|
6887
6941
|
|
|
6942
|
+
|
|
6943
|
+
|
|
6888
6944
|
/**
|
|
6889
6945
|
* If the thing is a FormData object, return true, otherwise return false.
|
|
6890
6946
|
*
|
|
@@ -6893,7 +6949,7 @@ function requireAxios () {
|
|
|
6893
6949
|
* @returns {boolean}
|
|
6894
6950
|
*/
|
|
6895
6951
|
function isSpecCompliantForm(thing) {
|
|
6896
|
-
return !!(thing && isFunction(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
|
|
6952
|
+
return !!(thing && isFunction$1(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
|
|
6897
6953
|
}
|
|
6898
6954
|
|
|
6899
6955
|
const toJSONObject = (obj) => {
|
|
@@ -6906,6 +6962,11 @@ function requireAxios () {
|
|
|
6906
6962
|
return;
|
|
6907
6963
|
}
|
|
6908
6964
|
|
|
6965
|
+
//Buffer check
|
|
6966
|
+
if (isBuffer(source)) {
|
|
6967
|
+
return source;
|
|
6968
|
+
}
|
|
6969
|
+
|
|
6909
6970
|
if(!('toJSON' in source)) {
|
|
6910
6971
|
stack[i] = source;
|
|
6911
6972
|
const target = isArray(source) ? [] : {};
|
|
@@ -6930,7 +6991,7 @@ function requireAxios () {
|
|
|
6930
6991
|
const isAsyncFn = kindOfTest('AsyncFunction');
|
|
6931
6992
|
|
|
6932
6993
|
const isThenable = (thing) =>
|
|
6933
|
-
thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
|
|
6994
|
+
thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
|
|
6934
6995
|
|
|
6935
6996
|
// original code
|
|
6936
6997
|
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
|
@@ -6954,7 +7015,7 @@ function requireAxios () {
|
|
|
6954
7015
|
})(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
|
|
6955
7016
|
})(
|
|
6956
7017
|
typeof setImmediate === 'function',
|
|
6957
|
-
isFunction(_global.postMessage)
|
|
7018
|
+
isFunction$1(_global.postMessage)
|
|
6958
7019
|
);
|
|
6959
7020
|
|
|
6960
7021
|
const asap = typeof queueMicrotask !== 'undefined' ?
|
|
@@ -6963,7 +7024,7 @@ function requireAxios () {
|
|
|
6963
7024
|
// *********************
|
|
6964
7025
|
|
|
6965
7026
|
|
|
6966
|
-
const isIterable = (thing) => thing != null && isFunction(thing[iterator]);
|
|
7027
|
+
const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
|
|
6967
7028
|
|
|
6968
7029
|
|
|
6969
7030
|
var utils$1 = {
|
|
@@ -6977,6 +7038,7 @@ function requireAxios () {
|
|
|
6977
7038
|
isBoolean,
|
|
6978
7039
|
isObject,
|
|
6979
7040
|
isPlainObject,
|
|
7041
|
+
isEmptyObject,
|
|
6980
7042
|
isReadableStream,
|
|
6981
7043
|
isRequest,
|
|
6982
7044
|
isResponse,
|
|
@@ -6986,7 +7048,7 @@ function requireAxios () {
|
|
|
6986
7048
|
isFile,
|
|
6987
7049
|
isBlob,
|
|
6988
7050
|
isRegExp,
|
|
6989
|
-
isFunction,
|
|
7051
|
+
isFunction: isFunction$1,
|
|
6990
7052
|
isStream,
|
|
6991
7053
|
isURLSearchParams,
|
|
6992
7054
|
isTypedArray,
|
|
@@ -7025,103 +7087,75 @@ function requireAxios () {
|
|
|
7025
7087
|
isIterable
|
|
7026
7088
|
};
|
|
7027
7089
|
|
|
7028
|
-
|
|
7029
|
-
|
|
7030
|
-
|
|
7031
|
-
|
|
7032
|
-
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
*
|
|
7037
|
-
* @returns {Error} The created error.
|
|
7038
|
-
*/
|
|
7039
|
-
function AxiosError(message, code, config, request, response) {
|
|
7040
|
-
Error.call(this);
|
|
7090
|
+
class AxiosError extends Error {
|
|
7091
|
+
static from(error, code, config, request, response, customProps) {
|
|
7092
|
+
const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
|
|
7093
|
+
axiosError.cause = error;
|
|
7094
|
+
axiosError.name = error.name;
|
|
7095
|
+
customProps && Object.assign(axiosError, customProps);
|
|
7096
|
+
return axiosError;
|
|
7097
|
+
}
|
|
7041
7098
|
|
|
7042
|
-
|
|
7043
|
-
|
|
7044
|
-
|
|
7045
|
-
|
|
7046
|
-
|
|
7099
|
+
/**
|
|
7100
|
+
* Create an Error with the specified message, config, error code, request and response.
|
|
7101
|
+
*
|
|
7102
|
+
* @param {string} message The error message.
|
|
7103
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
7104
|
+
* @param {Object} [config] The config.
|
|
7105
|
+
* @param {Object} [request] The request.
|
|
7106
|
+
* @param {Object} [response] The response.
|
|
7107
|
+
*
|
|
7108
|
+
* @returns {Error} The created error.
|
|
7109
|
+
*/
|
|
7110
|
+
constructor(message, code, config, request, response) {
|
|
7111
|
+
super(message);
|
|
7112
|
+
this.name = 'AxiosError';
|
|
7113
|
+
this.isAxiosError = true;
|
|
7114
|
+
code && (this.code = code);
|
|
7115
|
+
config && (this.config = config);
|
|
7116
|
+
request && (this.request = request);
|
|
7117
|
+
if (response) {
|
|
7118
|
+
this.response = response;
|
|
7119
|
+
this.status = response.status;
|
|
7120
|
+
}
|
|
7121
|
+
}
|
|
7047
7122
|
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
|
|
7056
|
-
|
|
7123
|
+
toJSON() {
|
|
7124
|
+
return {
|
|
7125
|
+
// Standard
|
|
7126
|
+
message: this.message,
|
|
7127
|
+
name: this.name,
|
|
7128
|
+
// Microsoft
|
|
7129
|
+
description: this.description,
|
|
7130
|
+
number: this.number,
|
|
7131
|
+
// Mozilla
|
|
7132
|
+
fileName: this.fileName,
|
|
7133
|
+
lineNumber: this.lineNumber,
|
|
7134
|
+
columnNumber: this.columnNumber,
|
|
7135
|
+
stack: this.stack,
|
|
7136
|
+
// Axios
|
|
7137
|
+
config: utils$1.toJSONObject(this.config),
|
|
7138
|
+
code: this.code,
|
|
7139
|
+
status: this.status,
|
|
7140
|
+
};
|
|
7141
|
+
}
|
|
7057
7142
|
}
|
|
7058
7143
|
|
|
7059
|
-
|
|
7060
|
-
|
|
7061
|
-
|
|
7062
|
-
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
|
|
7066
|
-
|
|
7067
|
-
|
|
7068
|
-
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
stack: this.stack,
|
|
7073
|
-
// Axios
|
|
7074
|
-
config: utils$1.toJSONObject(this.config),
|
|
7075
|
-
code: this.code,
|
|
7076
|
-
status: this.status
|
|
7077
|
-
};
|
|
7078
|
-
}
|
|
7079
|
-
});
|
|
7080
|
-
|
|
7081
|
-
const prototype$1 = AxiosError.prototype;
|
|
7082
|
-
const descriptors = {};
|
|
7083
|
-
|
|
7084
|
-
[
|
|
7085
|
-
'ERR_BAD_OPTION_VALUE',
|
|
7086
|
-
'ERR_BAD_OPTION',
|
|
7087
|
-
'ECONNABORTED',
|
|
7088
|
-
'ETIMEDOUT',
|
|
7089
|
-
'ERR_NETWORK',
|
|
7090
|
-
'ERR_FR_TOO_MANY_REDIRECTS',
|
|
7091
|
-
'ERR_DEPRECATED',
|
|
7092
|
-
'ERR_BAD_RESPONSE',
|
|
7093
|
-
'ERR_BAD_REQUEST',
|
|
7094
|
-
'ERR_CANCELED',
|
|
7095
|
-
'ERR_NOT_SUPPORT',
|
|
7096
|
-
'ERR_INVALID_URL'
|
|
7097
|
-
// eslint-disable-next-line func-names
|
|
7098
|
-
].forEach(code => {
|
|
7099
|
-
descriptors[code] = {value: code};
|
|
7100
|
-
});
|
|
7101
|
-
|
|
7102
|
-
Object.defineProperties(AxiosError, descriptors);
|
|
7103
|
-
Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
|
|
7104
|
-
|
|
7105
|
-
// eslint-disable-next-line func-names
|
|
7106
|
-
AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
7107
|
-
const axiosError = Object.create(prototype$1);
|
|
7108
|
-
|
|
7109
|
-
utils$1.toFlatObject(error, axiosError, function filter(obj) {
|
|
7110
|
-
return obj !== Error.prototype;
|
|
7111
|
-
}, prop => {
|
|
7112
|
-
return prop !== 'isAxiosError';
|
|
7113
|
-
});
|
|
7114
|
-
|
|
7115
|
-
AxiosError.call(axiosError, error.message, code, config, request, response);
|
|
7144
|
+
// This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
|
|
7145
|
+
AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
|
|
7146
|
+
AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
|
|
7147
|
+
AxiosError.ECONNABORTED = 'ECONNABORTED';
|
|
7148
|
+
AxiosError.ETIMEDOUT = 'ETIMEDOUT';
|
|
7149
|
+
AxiosError.ERR_NETWORK = 'ERR_NETWORK';
|
|
7150
|
+
AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
|
|
7151
|
+
AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
|
|
7152
|
+
AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
|
|
7153
|
+
AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|
7154
|
+
AxiosError.ERR_CANCELED = 'ERR_CANCELED';
|
|
7155
|
+
AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
7156
|
+
AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
7116
7157
|
|
|
7117
|
-
|
|
7118
|
-
|
|
7119
|
-
axiosError.name = error.name;
|
|
7120
|
-
|
|
7121
|
-
customProps && Object.assign(axiosError, customProps);
|
|
7122
|
-
|
|
7123
|
-
return axiosError;
|
|
7124
|
-
};
|
|
7158
|
+
var AxiosError$1 = AxiosError;
|
|
7125
7159
|
|
|
7126
7160
|
// eslint-disable-next-line strict
|
|
7127
7161
|
var httpAdapter = null;
|
|
@@ -7246,7 +7280,7 @@ function requireAxios () {
|
|
|
7246
7280
|
}
|
|
7247
7281
|
|
|
7248
7282
|
if (!useBlob && utils$1.isBlob(value)) {
|
|
7249
|
-
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
|
7283
|
+
throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
|
|
7250
7284
|
}
|
|
7251
7285
|
|
|
7252
7286
|
if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
|
|
@@ -7407,9 +7441,7 @@ function requireAxios () {
|
|
|
7407
7441
|
replace(/%3A/gi, ':').
|
|
7408
7442
|
replace(/%24/g, '$').
|
|
7409
7443
|
replace(/%2C/gi, ',').
|
|
7410
|
-
replace(/%20/g, '+')
|
|
7411
|
-
replace(/%5B/gi, '[').
|
|
7412
|
-
replace(/%5D/gi, ']');
|
|
7444
|
+
replace(/%20/g, '+');
|
|
7413
7445
|
}
|
|
7414
7446
|
|
|
7415
7447
|
/**
|
|
@@ -7422,29 +7454,26 @@ function requireAxios () {
|
|
|
7422
7454
|
* @returns {string} The formatted url
|
|
7423
7455
|
*/
|
|
7424
7456
|
function buildURL(url, params, options) {
|
|
7425
|
-
/*eslint no-param-reassign:0*/
|
|
7426
7457
|
if (!params) {
|
|
7427
7458
|
return url;
|
|
7428
7459
|
}
|
|
7429
|
-
|
|
7460
|
+
|
|
7430
7461
|
const _encode = options && options.encode || encode;
|
|
7431
7462
|
|
|
7432
|
-
|
|
7433
|
-
options
|
|
7434
|
-
|
|
7435
|
-
};
|
|
7436
|
-
}
|
|
7463
|
+
const _options = utils$1.isFunction(options) ? {
|
|
7464
|
+
serialize: options
|
|
7465
|
+
} : options;
|
|
7437
7466
|
|
|
7438
|
-
const serializeFn =
|
|
7467
|
+
const serializeFn = _options && _options.serialize;
|
|
7439
7468
|
|
|
7440
7469
|
let serializedParams;
|
|
7441
7470
|
|
|
7442
7471
|
if (serializeFn) {
|
|
7443
|
-
serializedParams = serializeFn(params,
|
|
7472
|
+
serializedParams = serializeFn(params, _options);
|
|
7444
7473
|
} else {
|
|
7445
7474
|
serializedParams = utils$1.isURLSearchParams(params) ?
|
|
7446
7475
|
params.toString() :
|
|
7447
|
-
new AxiosURLSearchParams(params,
|
|
7476
|
+
new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
7448
7477
|
}
|
|
7449
7478
|
|
|
7450
7479
|
if (serializedParams) {
|
|
@@ -7469,6 +7498,7 @@ function requireAxios () {
|
|
|
7469
7498
|
*
|
|
7470
7499
|
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
7471
7500
|
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
7501
|
+
* @param {Object} options The options for the interceptor, synchronous and runWhen
|
|
7472
7502
|
*
|
|
7473
7503
|
* @return {Number} An ID used to remove interceptor later
|
|
7474
7504
|
*/
|
|
@@ -7487,7 +7517,7 @@ function requireAxios () {
|
|
|
7487
7517
|
*
|
|
7488
7518
|
* @param {Number} id The ID that was returned by `use`
|
|
7489
7519
|
*
|
|
7490
|
-
* @returns {
|
|
7520
|
+
* @returns {void}
|
|
7491
7521
|
*/
|
|
7492
7522
|
eject(id) {
|
|
7493
7523
|
if (this.handlers[id]) {
|
|
@@ -7608,7 +7638,7 @@ function requireAxios () {
|
|
|
7608
7638
|
};
|
|
7609
7639
|
|
|
7610
7640
|
function toURLEncodedForm(data, options) {
|
|
7611
|
-
return toFormData(data, new platform.classes.URLSearchParams(),
|
|
7641
|
+
return toFormData(data, new platform.classes.URLSearchParams(), {
|
|
7612
7642
|
visitor: function(value, key, path, helpers) {
|
|
7613
7643
|
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
7614
7644
|
this.append(key, value.toString('base64'));
|
|
@@ -7616,8 +7646,9 @@ function requireAxios () {
|
|
|
7616
7646
|
}
|
|
7617
7647
|
|
|
7618
7648
|
return helpers.defaultVisitor.apply(this, arguments);
|
|
7619
|
-
}
|
|
7620
|
-
|
|
7649
|
+
},
|
|
7650
|
+
...options
|
|
7651
|
+
});
|
|
7621
7652
|
}
|
|
7622
7653
|
|
|
7623
7654
|
/**
|
|
@@ -7813,11 +7844,11 @@ function requireAxios () {
|
|
|
7813
7844
|
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
7814
7845
|
|
|
7815
7846
|
try {
|
|
7816
|
-
return JSON.parse(data);
|
|
7847
|
+
return JSON.parse(data, this.parseReviver);
|
|
7817
7848
|
} catch (e) {
|
|
7818
7849
|
if (strictJSONParsing) {
|
|
7819
7850
|
if (e.name === 'SyntaxError') {
|
|
7820
|
-
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
|
7851
|
+
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
|
|
7821
7852
|
}
|
|
7822
7853
|
throw e;
|
|
7823
7854
|
}
|
|
@@ -8251,24 +8282,24 @@ function requireAxios () {
|
|
|
8251
8282
|
return !!(value && value.__CANCEL__);
|
|
8252
8283
|
}
|
|
8253
8284
|
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8285
|
+
class CanceledError extends AxiosError$1 {
|
|
8286
|
+
/**
|
|
8287
|
+
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
|
8288
|
+
*
|
|
8289
|
+
* @param {string=} message The message.
|
|
8290
|
+
* @param {Object=} config The config.
|
|
8291
|
+
* @param {Object=} request The request.
|
|
8292
|
+
*
|
|
8293
|
+
* @returns {CanceledError} The created error.
|
|
8294
|
+
*/
|
|
8295
|
+
constructor(message, config, request) {
|
|
8296
|
+
super(message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
|
|
8297
|
+
this.name = 'CanceledError';
|
|
8298
|
+
this.__CANCEL__ = true;
|
|
8299
|
+
}
|
|
8267
8300
|
}
|
|
8268
8301
|
|
|
8269
|
-
|
|
8270
|
-
__CANCEL__: true
|
|
8271
|
-
});
|
|
8302
|
+
var CanceledError$1 = CanceledError;
|
|
8272
8303
|
|
|
8273
8304
|
/**
|
|
8274
8305
|
* Resolve or reject a Promise based on response status.
|
|
@@ -8284,9 +8315,9 @@ function requireAxios () {
|
|
|
8284
8315
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
8285
8316
|
resolve(response);
|
|
8286
8317
|
} else {
|
|
8287
|
-
reject(new AxiosError(
|
|
8318
|
+
reject(new AxiosError$1(
|
|
8288
8319
|
'Request failed with status code ' + response.status,
|
|
8289
|
-
[AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
|
8320
|
+
[AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
|
8290
8321
|
response.config,
|
|
8291
8322
|
response.request,
|
|
8292
8323
|
response
|
|
@@ -8370,7 +8401,7 @@ function requireAxios () {
|
|
|
8370
8401
|
clearTimeout(timer);
|
|
8371
8402
|
timer = null;
|
|
8372
8403
|
}
|
|
8373
|
-
fn
|
|
8404
|
+
fn(...args);
|
|
8374
8405
|
};
|
|
8375
8406
|
|
|
8376
8407
|
const throttled = (...args) => {
|
|
@@ -8452,27 +8483,38 @@ function requireAxios () {
|
|
|
8452
8483
|
|
|
8453
8484
|
// Standard browser envs support document.cookie
|
|
8454
8485
|
{
|
|
8455
|
-
write(name, value, expires, path, domain, secure) {
|
|
8456
|
-
|
|
8457
|
-
|
|
8458
|
-
utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
|
|
8486
|
+
write(name, value, expires, path, domain, secure, sameSite) {
|
|
8487
|
+
if (typeof document === 'undefined') return;
|
|
8459
8488
|
|
|
8460
|
-
|
|
8489
|
+
const cookie = [`${name}=${encodeURIComponent(value)}`];
|
|
8461
8490
|
|
|
8462
|
-
utils$1.
|
|
8463
|
-
|
|
8464
|
-
|
|
8491
|
+
if (utils$1.isNumber(expires)) {
|
|
8492
|
+
cookie.push(`expires=${new Date(expires).toUTCString()}`);
|
|
8493
|
+
}
|
|
8494
|
+
if (utils$1.isString(path)) {
|
|
8495
|
+
cookie.push(`path=${path}`);
|
|
8496
|
+
}
|
|
8497
|
+
if (utils$1.isString(domain)) {
|
|
8498
|
+
cookie.push(`domain=${domain}`);
|
|
8499
|
+
}
|
|
8500
|
+
if (secure === true) {
|
|
8501
|
+
cookie.push('secure');
|
|
8502
|
+
}
|
|
8503
|
+
if (utils$1.isString(sameSite)) {
|
|
8504
|
+
cookie.push(`SameSite=${sameSite}`);
|
|
8505
|
+
}
|
|
8465
8506
|
|
|
8466
8507
|
document.cookie = cookie.join('; ');
|
|
8467
8508
|
},
|
|
8468
8509
|
|
|
8469
8510
|
read(name) {
|
|
8470
|
-
|
|
8471
|
-
|
|
8511
|
+
if (typeof document === 'undefined') return null;
|
|
8512
|
+
const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
|
|
8513
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
8472
8514
|
},
|
|
8473
8515
|
|
|
8474
8516
|
remove(name) {
|
|
8475
|
-
this.write(name, '', Date.now() - 86400000);
|
|
8517
|
+
this.write(name, '', Date.now() - 86400000, '/');
|
|
8476
8518
|
}
|
|
8477
8519
|
}
|
|
8478
8520
|
|
|
@@ -8551,7 +8593,7 @@ function requireAxios () {
|
|
|
8551
8593
|
|
|
8552
8594
|
function getMergedValue(target, source, prop, caseless) {
|
|
8553
8595
|
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
8554
|
-
return utils$1.merge.call({caseless}, target, source);
|
|
8596
|
+
return utils$1.merge.call({ caseless }, target, source);
|
|
8555
8597
|
} else if (utils$1.isPlainObject(source)) {
|
|
8556
8598
|
return utils$1.merge({}, source);
|
|
8557
8599
|
} else if (utils$1.isArray(source)) {
|
|
@@ -8560,12 +8602,11 @@ function requireAxios () {
|
|
|
8560
8602
|
return source;
|
|
8561
8603
|
}
|
|
8562
8604
|
|
|
8563
|
-
|
|
8564
|
-
function mergeDeepProperties(a, b, prop , caseless) {
|
|
8605
|
+
function mergeDeepProperties(a, b, prop, caseless) {
|
|
8565
8606
|
if (!utils$1.isUndefined(b)) {
|
|
8566
|
-
return getMergedValue(a, b, prop
|
|
8607
|
+
return getMergedValue(a, b, prop, caseless);
|
|
8567
8608
|
} else if (!utils$1.isUndefined(a)) {
|
|
8568
|
-
return getMergedValue(undefined, a, prop
|
|
8609
|
+
return getMergedValue(undefined, a, prop, caseless);
|
|
8569
8610
|
}
|
|
8570
8611
|
}
|
|
8571
8612
|
|
|
@@ -8623,10 +8664,10 @@ function requireAxios () {
|
|
|
8623
8664
|
socketPath: defaultToConfig2,
|
|
8624
8665
|
responseEncoding: defaultToConfig2,
|
|
8625
8666
|
validateStatus: mergeDirectKeys,
|
|
8626
|
-
headers: (a, b
|
|
8667
|
+
headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
|
|
8627
8668
|
};
|
|
8628
8669
|
|
|
8629
|
-
utils$1.forEach(Object.keys(
|
|
8670
|
+
utils$1.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
|
|
8630
8671
|
const merge = mergeMap[prop] || mergeDeepProperties;
|
|
8631
8672
|
const configValue = merge(config1[prop], config2[prop], prop);
|
|
8632
8673
|
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
@@ -8638,7 +8679,7 @@ function requireAxios () {
|
|
|
8638
8679
|
var resolveConfig = (config) => {
|
|
8639
8680
|
const newConfig = mergeConfig({}, config);
|
|
8640
8681
|
|
|
8641
|
-
let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
|
|
8682
|
+
let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
|
|
8642
8683
|
|
|
8643
8684
|
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
|
8644
8685
|
|
|
@@ -8651,17 +8692,21 @@ function requireAxios () {
|
|
|
8651
8692
|
);
|
|
8652
8693
|
}
|
|
8653
8694
|
|
|
8654
|
-
let contentType;
|
|
8655
|
-
|
|
8656
8695
|
if (utils$1.isFormData(data)) {
|
|
8657
8696
|
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
|
8658
|
-
headers.setContentType(undefined); //
|
|
8659
|
-
} else if ((
|
|
8660
|
-
//
|
|
8661
|
-
const
|
|
8662
|
-
headers
|
|
8697
|
+
headers.setContentType(undefined); // browser handles it
|
|
8698
|
+
} else if (utils$1.isFunction(data.getHeaders)) {
|
|
8699
|
+
// Node.js FormData (like form-data package)
|
|
8700
|
+
const formHeaders = data.getHeaders();
|
|
8701
|
+
// Only set safe headers to avoid overwriting security headers
|
|
8702
|
+
const allowedHeaders = ['content-type', 'content-length'];
|
|
8703
|
+
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
8704
|
+
if (allowedHeaders.includes(key.toLowerCase())) {
|
|
8705
|
+
headers.set(key, val);
|
|
8706
|
+
}
|
|
8707
|
+
});
|
|
8663
8708
|
}
|
|
8664
|
-
}
|
|
8709
|
+
}
|
|
8665
8710
|
|
|
8666
8711
|
// Add xsrf header
|
|
8667
8712
|
// This is only done if running in a standard browser environment.
|
|
@@ -8771,22 +8816,25 @@ function requireAxios () {
|
|
|
8771
8816
|
return;
|
|
8772
8817
|
}
|
|
8773
8818
|
|
|
8774
|
-
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
|
|
8819
|
+
reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
|
|
8775
8820
|
|
|
8776
8821
|
// Clean up request
|
|
8777
8822
|
request = null;
|
|
8778
8823
|
};
|
|
8779
8824
|
|
|
8780
8825
|
// Handle low level network errors
|
|
8781
|
-
|
|
8782
|
-
|
|
8783
|
-
|
|
8784
|
-
|
|
8785
|
-
|
|
8786
|
-
|
|
8787
|
-
|
|
8826
|
+
request.onerror = function handleError(event) {
|
|
8827
|
+
// Browsers deliver a ProgressEvent in XHR onerror
|
|
8828
|
+
// (message may be empty; when present, surface it)
|
|
8829
|
+
// See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
|
|
8830
|
+
const msg = event && event.message ? event.message : 'Network Error';
|
|
8831
|
+
const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
|
|
8832
|
+
// attach the underlying event for consumers who want details
|
|
8833
|
+
err.event = event || null;
|
|
8834
|
+
reject(err);
|
|
8835
|
+
request = null;
|
|
8788
8836
|
};
|
|
8789
|
-
|
|
8837
|
+
|
|
8790
8838
|
// Handle timeout
|
|
8791
8839
|
request.ontimeout = function handleTimeout() {
|
|
8792
8840
|
let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
|
|
@@ -8794,9 +8842,9 @@ function requireAxios () {
|
|
|
8794
8842
|
if (_config.timeoutErrorMessage) {
|
|
8795
8843
|
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
8796
8844
|
}
|
|
8797
|
-
reject(new AxiosError(
|
|
8845
|
+
reject(new AxiosError$1(
|
|
8798
8846
|
timeoutErrorMessage,
|
|
8799
|
-
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
|
|
8847
|
+
transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
|
|
8800
8848
|
config,
|
|
8801
8849
|
request));
|
|
8802
8850
|
|
|
@@ -8846,7 +8894,7 @@ function requireAxios () {
|
|
|
8846
8894
|
if (!request) {
|
|
8847
8895
|
return;
|
|
8848
8896
|
}
|
|
8849
|
-
reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
|
|
8897
|
+
reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
|
|
8850
8898
|
request.abort();
|
|
8851
8899
|
request = null;
|
|
8852
8900
|
};
|
|
@@ -8860,7 +8908,7 @@ function requireAxios () {
|
|
|
8860
8908
|
const protocol = parseProtocol(_config.url);
|
|
8861
8909
|
|
|
8862
8910
|
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
|
8863
|
-
reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
|
|
8911
|
+
reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
|
|
8864
8912
|
return;
|
|
8865
8913
|
}
|
|
8866
8914
|
|
|
@@ -8883,13 +8931,13 @@ function requireAxios () {
|
|
|
8883
8931
|
aborted = true;
|
|
8884
8932
|
unsubscribe();
|
|
8885
8933
|
const err = reason instanceof Error ? reason : this.reason;
|
|
8886
|
-
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
|
8934
|
+
controller.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
|
|
8887
8935
|
}
|
|
8888
8936
|
};
|
|
8889
8937
|
|
|
8890
8938
|
let timer = timeout && setTimeout(() => {
|
|
8891
8939
|
timer = null;
|
|
8892
|
-
onabort(new AxiosError(`timeout ${timeout}
|
|
8940
|
+
onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
|
|
8893
8941
|
}, timeout);
|
|
8894
8942
|
|
|
8895
8943
|
const unsubscribe = () => {
|
|
@@ -9002,14 +9050,18 @@ function requireAxios () {
|
|
|
9002
9050
|
})
|
|
9003
9051
|
};
|
|
9004
9052
|
|
|
9005
|
-
const
|
|
9006
|
-
|
|
9053
|
+
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
9054
|
+
|
|
9055
|
+
const {isFunction} = utils$1;
|
|
9056
|
+
|
|
9057
|
+
const globalFetchAPI = (({Request, Response}) => ({
|
|
9058
|
+
Request, Response
|
|
9059
|
+
}))(utils$1.global);
|
|
9060
|
+
|
|
9061
|
+
const {
|
|
9062
|
+
ReadableStream: ReadableStream$1, TextEncoder
|
|
9063
|
+
} = utils$1.global;
|
|
9007
9064
|
|
|
9008
|
-
// used only inside the fetch adapter
|
|
9009
|
-
const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
|
|
9010
|
-
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
|
9011
|
-
async (str) => new Uint8Array(await new Response(str).arrayBuffer())
|
|
9012
|
-
);
|
|
9013
9065
|
|
|
9014
9066
|
const test = (fn, ...args) => {
|
|
9015
9067
|
try {
|
|
@@ -9019,278 +9071,380 @@ function requireAxios () {
|
|
|
9019
9071
|
}
|
|
9020
9072
|
};
|
|
9021
9073
|
|
|
9022
|
-
const
|
|
9023
|
-
|
|
9074
|
+
const factory = (env) => {
|
|
9075
|
+
env = utils$1.merge.call({
|
|
9076
|
+
skipUndefined: true
|
|
9077
|
+
}, globalFetchAPI, env);
|
|
9024
9078
|
|
|
9025
|
-
const
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
|
|
9029
|
-
duplexAccessed = true;
|
|
9030
|
-
return 'half';
|
|
9031
|
-
},
|
|
9032
|
-
}).headers.has('Content-Type');
|
|
9079
|
+
const {fetch: envFetch, Request, Response} = env;
|
|
9080
|
+
const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
|
|
9081
|
+
const isRequestSupported = isFunction(Request);
|
|
9082
|
+
const isResponseSupported = isFunction(Response);
|
|
9033
9083
|
|
|
9034
|
-
|
|
9035
|
-
|
|
9084
|
+
if (!isFetchSupported) {
|
|
9085
|
+
return false;
|
|
9086
|
+
}
|
|
9036
9087
|
|
|
9037
|
-
|
|
9088
|
+
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
|
|
9038
9089
|
|
|
9039
|
-
|
|
9040
|
-
|
|
9090
|
+
const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
|
|
9091
|
+
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
|
9092
|
+
async (str) => new Uint8Array(await new Request(str).arrayBuffer())
|
|
9093
|
+
);
|
|
9041
9094
|
|
|
9095
|
+
const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
|
|
9096
|
+
let duplexAccessed = false;
|
|
9042
9097
|
|
|
9043
|
-
|
|
9044
|
-
|
|
9045
|
-
|
|
9098
|
+
const hasContentType = new Request(platform.origin, {
|
|
9099
|
+
body: new ReadableStream$1(),
|
|
9100
|
+
method: 'POST',
|
|
9101
|
+
get duplex() {
|
|
9102
|
+
duplexAccessed = true;
|
|
9103
|
+
return 'half';
|
|
9104
|
+
},
|
|
9105
|
+
}).headers.has('Content-Type');
|
|
9046
9106
|
|
|
9047
|
-
|
|
9048
|
-
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
|
9049
|
-
!resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
|
|
9050
|
-
(_, config) => {
|
|
9051
|
-
throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
|
|
9052
|
-
});
|
|
9107
|
+
return duplexAccessed && !hasContentType;
|
|
9053
9108
|
});
|
|
9054
|
-
})(new Response));
|
|
9055
9109
|
|
|
9056
|
-
|
|
9057
|
-
|
|
9058
|
-
return 0;
|
|
9059
|
-
}
|
|
9110
|
+
const supportsResponseStream = isResponseSupported && isReadableStreamSupported &&
|
|
9111
|
+
test(() => utils$1.isReadableStream(new Response('').body));
|
|
9060
9112
|
|
|
9061
|
-
|
|
9062
|
-
|
|
9063
|
-
}
|
|
9113
|
+
const resolvers = {
|
|
9114
|
+
stream: supportsResponseStream && ((res) => res.body)
|
|
9115
|
+
};
|
|
9064
9116
|
|
|
9065
|
-
|
|
9066
|
-
|
|
9067
|
-
|
|
9068
|
-
|
|
9117
|
+
isFetchSupported && ((() => {
|
|
9118
|
+
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
|
9119
|
+
!resolvers[type] && (resolvers[type] = (res, config) => {
|
|
9120
|
+
let method = res && res[type];
|
|
9121
|
+
|
|
9122
|
+
if (method) {
|
|
9123
|
+
return method.call(res);
|
|
9124
|
+
}
|
|
9125
|
+
|
|
9126
|
+
throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config);
|
|
9127
|
+
});
|
|
9069
9128
|
});
|
|
9070
|
-
|
|
9071
|
-
}
|
|
9129
|
+
})());
|
|
9072
9130
|
|
|
9073
|
-
|
|
9074
|
-
|
|
9075
|
-
|
|
9131
|
+
const getBodyLength = async (body) => {
|
|
9132
|
+
if (body == null) {
|
|
9133
|
+
return 0;
|
|
9134
|
+
}
|
|
9076
9135
|
|
|
9077
|
-
|
|
9078
|
-
|
|
9079
|
-
|
|
9136
|
+
if (utils$1.isBlob(body)) {
|
|
9137
|
+
return body.size;
|
|
9138
|
+
}
|
|
9080
9139
|
|
|
9081
|
-
|
|
9082
|
-
|
|
9083
|
-
|
|
9084
|
-
|
|
9140
|
+
if (utils$1.isSpecCompliantForm(body)) {
|
|
9141
|
+
const _request = new Request(platform.origin, {
|
|
9142
|
+
method: 'POST',
|
|
9143
|
+
body,
|
|
9144
|
+
});
|
|
9145
|
+
return (await _request.arrayBuffer()).byteLength;
|
|
9146
|
+
}
|
|
9085
9147
|
|
|
9086
|
-
|
|
9087
|
-
|
|
9148
|
+
if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
|
9149
|
+
return body.byteLength;
|
|
9150
|
+
}
|
|
9088
9151
|
|
|
9089
|
-
|
|
9090
|
-
|
|
9152
|
+
if (utils$1.isURLSearchParams(body)) {
|
|
9153
|
+
body = body + '';
|
|
9154
|
+
}
|
|
9091
9155
|
|
|
9092
|
-
|
|
9093
|
-
|
|
9094
|
-
|
|
9095
|
-
|
|
9096
|
-
|
|
9097
|
-
|
|
9098
|
-
|
|
9099
|
-
|
|
9100
|
-
|
|
9101
|
-
|
|
9102
|
-
|
|
9103
|
-
|
|
9104
|
-
|
|
9105
|
-
|
|
9106
|
-
|
|
9107
|
-
|
|
9108
|
-
|
|
9109
|
-
|
|
9110
|
-
|
|
9111
|
-
|
|
9112
|
-
|
|
9113
|
-
|
|
9114
|
-
|
|
9156
|
+
if (utils$1.isString(body)) {
|
|
9157
|
+
return (await encodeText(body)).byteLength;
|
|
9158
|
+
}
|
|
9159
|
+
};
|
|
9160
|
+
|
|
9161
|
+
const resolveBodyLength = async (headers, body) => {
|
|
9162
|
+
const length = utils$1.toFiniteNumber(headers.getContentLength());
|
|
9163
|
+
|
|
9164
|
+
return length == null ? getBodyLength(body) : length;
|
|
9165
|
+
};
|
|
9166
|
+
|
|
9167
|
+
return async (config) => {
|
|
9168
|
+
let {
|
|
9169
|
+
url,
|
|
9170
|
+
method,
|
|
9171
|
+
data,
|
|
9172
|
+
signal,
|
|
9173
|
+
cancelToken,
|
|
9174
|
+
timeout,
|
|
9175
|
+
onDownloadProgress,
|
|
9176
|
+
onUploadProgress,
|
|
9177
|
+
responseType,
|
|
9178
|
+
headers,
|
|
9179
|
+
withCredentials = 'same-origin',
|
|
9180
|
+
fetchOptions
|
|
9181
|
+
} = resolveConfig(config);
|
|
9182
|
+
|
|
9183
|
+
let _fetch = envFetch || fetch;
|
|
9184
|
+
|
|
9185
|
+
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
9186
|
+
|
|
9187
|
+
let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
9188
|
+
|
|
9189
|
+
let request = null;
|
|
9190
|
+
|
|
9191
|
+
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
|
9115
9192
|
composedSignal.unsubscribe();
|
|
9116
|
-
|
|
9193
|
+
});
|
|
9117
9194
|
|
|
9118
|
-
|
|
9195
|
+
let requestContentLength;
|
|
9119
9196
|
|
|
9120
|
-
|
|
9121
|
-
|
|
9122
|
-
|
|
9123
|
-
|
|
9124
|
-
|
|
9125
|
-
|
|
9126
|
-
|
|
9127
|
-
|
|
9128
|
-
|
|
9129
|
-
|
|
9197
|
+
try {
|
|
9198
|
+
if (
|
|
9199
|
+
onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
|
|
9200
|
+
(requestContentLength = await resolveBodyLength(headers, data)) !== 0
|
|
9201
|
+
) {
|
|
9202
|
+
let _request = new Request(url, {
|
|
9203
|
+
method: 'POST',
|
|
9204
|
+
body: data,
|
|
9205
|
+
duplex: "half"
|
|
9206
|
+
});
|
|
9130
9207
|
|
|
9131
|
-
|
|
9208
|
+
let contentTypeHeader;
|
|
9132
9209
|
|
|
9133
|
-
|
|
9134
|
-
|
|
9135
|
-
|
|
9210
|
+
if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
|
|
9211
|
+
headers.setContentType(contentTypeHeader);
|
|
9212
|
+
}
|
|
9136
9213
|
|
|
9137
|
-
|
|
9138
|
-
|
|
9139
|
-
|
|
9140
|
-
|
|
9141
|
-
|
|
9214
|
+
if (_request.body) {
|
|
9215
|
+
const [onProgress, flush] = progressEventDecorator(
|
|
9216
|
+
requestContentLength,
|
|
9217
|
+
progressEventReducer(asyncDecorator(onUploadProgress))
|
|
9218
|
+
);
|
|
9142
9219
|
|
|
9143
|
-
|
|
9220
|
+
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
|
|
9221
|
+
}
|
|
9144
9222
|
}
|
|
9145
|
-
}
|
|
9146
9223
|
|
|
9147
|
-
|
|
9148
|
-
|
|
9149
|
-
|
|
9224
|
+
if (!utils$1.isString(withCredentials)) {
|
|
9225
|
+
withCredentials = withCredentials ? 'include' : 'omit';
|
|
9226
|
+
}
|
|
9150
9227
|
|
|
9151
|
-
|
|
9152
|
-
|
|
9153
|
-
|
|
9154
|
-
request = new Request(url, {
|
|
9155
|
-
...fetchOptions,
|
|
9156
|
-
signal: composedSignal,
|
|
9157
|
-
method: method.toUpperCase(),
|
|
9158
|
-
headers: headers.normalize().toJSON(),
|
|
9159
|
-
body: data,
|
|
9160
|
-
duplex: "half",
|
|
9161
|
-
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
9162
|
-
});
|
|
9228
|
+
// Cloudflare Workers throws when credentials are defined
|
|
9229
|
+
// see https://github.com/cloudflare/workerd/issues/902
|
|
9230
|
+
const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
|
|
9163
9231
|
|
|
9164
|
-
|
|
9232
|
+
const resolvedOptions = {
|
|
9233
|
+
...fetchOptions,
|
|
9234
|
+
signal: composedSignal,
|
|
9235
|
+
method: method.toUpperCase(),
|
|
9236
|
+
headers: headers.normalize().toJSON(),
|
|
9237
|
+
body: data,
|
|
9238
|
+
duplex: "half",
|
|
9239
|
+
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
9240
|
+
};
|
|
9165
9241
|
|
|
9166
|
-
|
|
9242
|
+
request = isRequestSupported && new Request(url, resolvedOptions);
|
|
9167
9243
|
|
|
9168
|
-
|
|
9169
|
-
const options = {};
|
|
9244
|
+
let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
|
|
9170
9245
|
|
|
9171
|
-
|
|
9172
|
-
options[prop] = response[prop];
|
|
9173
|
-
});
|
|
9246
|
+
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
9174
9247
|
|
|
9175
|
-
|
|
9248
|
+
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
|
9249
|
+
const options = {};
|
|
9176
9250
|
|
|
9177
|
-
|
|
9178
|
-
|
|
9179
|
-
|
|
9180
|
-
) || [];
|
|
9251
|
+
['status', 'statusText', 'headers'].forEach(prop => {
|
|
9252
|
+
options[prop] = response[prop];
|
|
9253
|
+
});
|
|
9181
9254
|
|
|
9182
|
-
|
|
9183
|
-
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
9184
|
-
flush && flush();
|
|
9185
|
-
unsubscribe && unsubscribe();
|
|
9186
|
-
}),
|
|
9187
|
-
options
|
|
9188
|
-
);
|
|
9189
|
-
}
|
|
9255
|
+
const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
9190
9256
|
|
|
9191
|
-
|
|
9257
|
+
const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
|
|
9258
|
+
responseContentLength,
|
|
9259
|
+
progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
|
9260
|
+
) || [];
|
|
9192
9261
|
|
|
9193
|
-
|
|
9262
|
+
response = new Response(
|
|
9263
|
+
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
9264
|
+
flush && flush();
|
|
9265
|
+
unsubscribe && unsubscribe();
|
|
9266
|
+
}),
|
|
9267
|
+
options
|
|
9268
|
+
);
|
|
9269
|
+
}
|
|
9194
9270
|
|
|
9195
|
-
|
|
9271
|
+
responseType = responseType || 'text';
|
|
9196
9272
|
|
|
9197
|
-
|
|
9198
|
-
|
|
9199
|
-
|
|
9200
|
-
|
|
9201
|
-
|
|
9202
|
-
|
|
9203
|
-
|
|
9204
|
-
|
|
9205
|
-
|
|
9206
|
-
|
|
9207
|
-
|
|
9208
|
-
|
|
9209
|
-
|
|
9210
|
-
|
|
9211
|
-
|
|
9212
|
-
|
|
9213
|
-
|
|
9214
|
-
|
|
9215
|
-
|
|
9216
|
-
|
|
9273
|
+
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
|
9274
|
+
|
|
9275
|
+
!isStreamResponse && unsubscribe && unsubscribe();
|
|
9276
|
+
|
|
9277
|
+
return await new Promise((resolve, reject) => {
|
|
9278
|
+
settle(resolve, reject, {
|
|
9279
|
+
data: responseData,
|
|
9280
|
+
headers: AxiosHeaders$1.from(response.headers),
|
|
9281
|
+
status: response.status,
|
|
9282
|
+
statusText: response.statusText,
|
|
9283
|
+
config,
|
|
9284
|
+
request
|
|
9285
|
+
});
|
|
9286
|
+
})
|
|
9287
|
+
} catch (err) {
|
|
9288
|
+
unsubscribe && unsubscribe();
|
|
9289
|
+
|
|
9290
|
+
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
9291
|
+
throw Object.assign(
|
|
9292
|
+
new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request),
|
|
9293
|
+
{
|
|
9294
|
+
cause: err.cause || err
|
|
9295
|
+
}
|
|
9296
|
+
)
|
|
9297
|
+
}
|
|
9298
|
+
|
|
9299
|
+
throw AxiosError$1.from(err, err && err.code, config, request);
|
|
9217
9300
|
}
|
|
9301
|
+
}
|
|
9302
|
+
};
|
|
9303
|
+
|
|
9304
|
+
const seedCache = new Map();
|
|
9305
|
+
|
|
9306
|
+
const getFetch = (config) => {
|
|
9307
|
+
let env = (config && config.env) || {};
|
|
9308
|
+
const {fetch, Request, Response} = env;
|
|
9309
|
+
const seeds = [
|
|
9310
|
+
Request, Response, fetch
|
|
9311
|
+
];
|
|
9312
|
+
|
|
9313
|
+
let len = seeds.length, i = len,
|
|
9314
|
+
seed, target, map = seedCache;
|
|
9218
9315
|
|
|
9219
|
-
|
|
9316
|
+
while (i--) {
|
|
9317
|
+
seed = seeds[i];
|
|
9318
|
+
target = map.get(seed);
|
|
9319
|
+
|
|
9320
|
+
target === undefined && map.set(seed, target = (i ? new Map() : factory(env)));
|
|
9321
|
+
|
|
9322
|
+
map = target;
|
|
9220
9323
|
}
|
|
9221
|
-
});
|
|
9222
9324
|
|
|
9325
|
+
return target;
|
|
9326
|
+
};
|
|
9327
|
+
|
|
9328
|
+
getFetch();
|
|
9329
|
+
|
|
9330
|
+
/**
|
|
9331
|
+
* Known adapters mapping.
|
|
9332
|
+
* Provides environment-specific adapters for Axios:
|
|
9333
|
+
* - `http` for Node.js
|
|
9334
|
+
* - `xhr` for browsers
|
|
9335
|
+
* - `fetch` for fetch API-based requests
|
|
9336
|
+
*
|
|
9337
|
+
* @type {Object<string, Function|Object>}
|
|
9338
|
+
*/
|
|
9223
9339
|
const knownAdapters = {
|
|
9224
9340
|
http: httpAdapter,
|
|
9225
9341
|
xhr: xhrAdapter,
|
|
9226
|
-
fetch:
|
|
9342
|
+
fetch: {
|
|
9343
|
+
get: getFetch,
|
|
9344
|
+
}
|
|
9227
9345
|
};
|
|
9228
9346
|
|
|
9347
|
+
// Assign adapter names for easier debugging and identification
|
|
9229
9348
|
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
9230
9349
|
if (fn) {
|
|
9231
9350
|
try {
|
|
9232
|
-
Object.defineProperty(fn, 'name', {value});
|
|
9351
|
+
Object.defineProperty(fn, 'name', { value });
|
|
9233
9352
|
} catch (e) {
|
|
9234
9353
|
// eslint-disable-next-line no-empty
|
|
9235
9354
|
}
|
|
9236
|
-
Object.defineProperty(fn, 'adapterName', {value});
|
|
9355
|
+
Object.defineProperty(fn, 'adapterName', { value });
|
|
9237
9356
|
}
|
|
9238
9357
|
});
|
|
9239
9358
|
|
|
9359
|
+
/**
|
|
9360
|
+
* Render a rejection reason string for unknown or unsupported adapters
|
|
9361
|
+
*
|
|
9362
|
+
* @param {string} reason
|
|
9363
|
+
* @returns {string}
|
|
9364
|
+
*/
|
|
9240
9365
|
const renderReason = (reason) => `- ${reason}`;
|
|
9241
9366
|
|
|
9367
|
+
/**
|
|
9368
|
+
* Check if the adapter is resolved (function, null, or false)
|
|
9369
|
+
*
|
|
9370
|
+
* @param {Function|null|false} adapter
|
|
9371
|
+
* @returns {boolean}
|
|
9372
|
+
*/
|
|
9242
9373
|
const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
|
9243
9374
|
|
|
9244
|
-
|
|
9245
|
-
|
|
9246
|
-
|
|
9375
|
+
/**
|
|
9376
|
+
* Get the first suitable adapter from the provided list.
|
|
9377
|
+
* Tries each adapter in order until a supported one is found.
|
|
9378
|
+
* Throws an AxiosError if no adapter is suitable.
|
|
9379
|
+
*
|
|
9380
|
+
* @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
|
|
9381
|
+
* @param {Object} config - Axios request configuration
|
|
9382
|
+
* @throws {AxiosError} If no suitable adapter is available
|
|
9383
|
+
* @returns {Function} The resolved adapter function
|
|
9384
|
+
*/
|
|
9385
|
+
function getAdapter(adapters, config) {
|
|
9386
|
+
adapters = utils$1.isArray(adapters) ? adapters : [adapters];
|
|
9247
9387
|
|
|
9248
|
-
|
|
9249
|
-
|
|
9250
|
-
|
|
9388
|
+
const { length } = adapters;
|
|
9389
|
+
let nameOrAdapter;
|
|
9390
|
+
let adapter;
|
|
9251
9391
|
|
|
9252
|
-
|
|
9392
|
+
const rejectedReasons = {};
|
|
9253
9393
|
|
|
9254
|
-
|
|
9255
|
-
|
|
9256
|
-
|
|
9394
|
+
for (let i = 0; i < length; i++) {
|
|
9395
|
+
nameOrAdapter = adapters[i];
|
|
9396
|
+
let id;
|
|
9257
9397
|
|
|
9258
|
-
|
|
9398
|
+
adapter = nameOrAdapter;
|
|
9259
9399
|
|
|
9260
|
-
|
|
9261
|
-
|
|
9400
|
+
if (!isResolvedHandle(nameOrAdapter)) {
|
|
9401
|
+
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
|
9262
9402
|
|
|
9263
|
-
|
|
9264
|
-
|
|
9265
|
-
}
|
|
9266
|
-
}
|
|
9267
|
-
|
|
9268
|
-
if (adapter) {
|
|
9269
|
-
break;
|
|
9403
|
+
if (adapter === undefined) {
|
|
9404
|
+
throw new AxiosError$1(`Unknown adapter '${id}'`);
|
|
9270
9405
|
}
|
|
9406
|
+
}
|
|
9271
9407
|
|
|
9272
|
-
|
|
9408
|
+
if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
|
|
9409
|
+
break;
|
|
9273
9410
|
}
|
|
9274
9411
|
|
|
9275
|
-
|
|
9412
|
+
rejectedReasons[id || '#' + i] = adapter;
|
|
9413
|
+
}
|
|
9276
9414
|
|
|
9277
|
-
|
|
9278
|
-
|
|
9279
|
-
|
|
9280
|
-
)
|
|
9415
|
+
if (!adapter) {
|
|
9416
|
+
const reasons = Object.entries(rejectedReasons)
|
|
9417
|
+
.map(([id, state]) => `adapter ${id} ` +
|
|
9418
|
+
(state === false ? 'is not supported by the environment' : 'is not available in the build')
|
|
9419
|
+
);
|
|
9281
9420
|
|
|
9282
|
-
|
|
9283
|
-
|
|
9284
|
-
|
|
9421
|
+
let s = length ?
|
|
9422
|
+
(reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
|
|
9423
|
+
'as no adapter specified';
|
|
9285
9424
|
|
|
9286
|
-
|
|
9287
|
-
|
|
9288
|
-
|
|
9289
|
-
|
|
9290
|
-
|
|
9425
|
+
throw new AxiosError$1(
|
|
9426
|
+
`There is no suitable adapter to dispatch the request ` + s,
|
|
9427
|
+
'ERR_NOT_SUPPORT'
|
|
9428
|
+
);
|
|
9429
|
+
}
|
|
9291
9430
|
|
|
9292
|
-
|
|
9293
|
-
|
|
9431
|
+
return adapter;
|
|
9432
|
+
}
|
|
9433
|
+
|
|
9434
|
+
/**
|
|
9435
|
+
* Exports Axios adapters and utility to resolve an adapter
|
|
9436
|
+
*/
|
|
9437
|
+
var adapters = {
|
|
9438
|
+
/**
|
|
9439
|
+
* Resolve an adapter from a list of adapter names or functions.
|
|
9440
|
+
* @type {Function}
|
|
9441
|
+
*/
|
|
9442
|
+
getAdapter,
|
|
9443
|
+
|
|
9444
|
+
/**
|
|
9445
|
+
* Exposes all known adapters
|
|
9446
|
+
* @type {Object<string, Function|Object>}
|
|
9447
|
+
*/
|
|
9294
9448
|
adapters: knownAdapters
|
|
9295
9449
|
};
|
|
9296
9450
|
|
|
@@ -9307,7 +9461,7 @@ function requireAxios () {
|
|
|
9307
9461
|
}
|
|
9308
9462
|
|
|
9309
9463
|
if (config.signal && config.signal.aborted) {
|
|
9310
|
-
throw new CanceledError(null, config);
|
|
9464
|
+
throw new CanceledError$1(null, config);
|
|
9311
9465
|
}
|
|
9312
9466
|
}
|
|
9313
9467
|
|
|
@@ -9333,7 +9487,7 @@ function requireAxios () {
|
|
|
9333
9487
|
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
|
9334
9488
|
}
|
|
9335
9489
|
|
|
9336
|
-
const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
|
|
9490
|
+
const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter, config);
|
|
9337
9491
|
|
|
9338
9492
|
return adapter(config).then(function onAdapterResolution(response) {
|
|
9339
9493
|
throwIfCancellationRequested(config);
|
|
@@ -9367,7 +9521,7 @@ function requireAxios () {
|
|
|
9367
9521
|
});
|
|
9368
9522
|
}
|
|
9369
9523
|
|
|
9370
|
-
const VERSION = "1.
|
|
9524
|
+
const VERSION = "1.13.3";
|
|
9371
9525
|
|
|
9372
9526
|
const validators$1 = {};
|
|
9373
9527
|
|
|
@@ -9397,9 +9551,9 @@ function requireAxios () {
|
|
|
9397
9551
|
// eslint-disable-next-line func-names
|
|
9398
9552
|
return (value, opt, opts) => {
|
|
9399
9553
|
if (validator === false) {
|
|
9400
|
-
throw new AxiosError(
|
|
9554
|
+
throw new AxiosError$1(
|
|
9401
9555
|
formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
|
|
9402
|
-
AxiosError.ERR_DEPRECATED
|
|
9556
|
+
AxiosError$1.ERR_DEPRECATED
|
|
9403
9557
|
);
|
|
9404
9558
|
}
|
|
9405
9559
|
|
|
@@ -9438,7 +9592,7 @@ function requireAxios () {
|
|
|
9438
9592
|
|
|
9439
9593
|
function assertOptions(options, schema, allowUnknown) {
|
|
9440
9594
|
if (typeof options !== 'object') {
|
|
9441
|
-
throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
|
|
9595
|
+
throw new AxiosError$1('options must be an object', AxiosError$1.ERR_BAD_OPTION_VALUE);
|
|
9442
9596
|
}
|
|
9443
9597
|
const keys = Object.keys(options);
|
|
9444
9598
|
let i = keys.length;
|
|
@@ -9449,12 +9603,12 @@ function requireAxios () {
|
|
|
9449
9603
|
const value = options[opt];
|
|
9450
9604
|
const result = value === undefined || validator(value, opt, options);
|
|
9451
9605
|
if (result !== true) {
|
|
9452
|
-
throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
|
|
9606
|
+
throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
|
|
9453
9607
|
}
|
|
9454
9608
|
continue;
|
|
9455
9609
|
}
|
|
9456
9610
|
if (allowUnknown !== true) {
|
|
9457
|
-
throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
|
|
9611
|
+
throw new AxiosError$1('Unknown option ' + opt, AxiosError$1.ERR_BAD_OPTION);
|
|
9458
9612
|
}
|
|
9459
9613
|
}
|
|
9460
9614
|
}
|
|
@@ -9606,14 +9760,19 @@ function requireAxios () {
|
|
|
9606
9760
|
|
|
9607
9761
|
if (!synchronousRequestInterceptors) {
|
|
9608
9762
|
const chain = [dispatchRequest.bind(this), undefined];
|
|
9609
|
-
chain.unshift
|
|
9610
|
-
chain.push
|
|
9763
|
+
chain.unshift(...requestInterceptorChain);
|
|
9764
|
+
chain.push(...responseInterceptorChain);
|
|
9611
9765
|
len = chain.length;
|
|
9612
9766
|
|
|
9613
9767
|
promise = Promise.resolve(config);
|
|
9614
9768
|
|
|
9769
|
+
let prevResult = config;
|
|
9615
9770
|
while (i < len) {
|
|
9616
|
-
promise = promise
|
|
9771
|
+
promise = promise
|
|
9772
|
+
.then(chain[i++])
|
|
9773
|
+
.then(result => { prevResult = result !== undefined ? result : prevResult; })
|
|
9774
|
+
.catch(chain[i++])
|
|
9775
|
+
.then(() => prevResult);
|
|
9617
9776
|
}
|
|
9618
9777
|
|
|
9619
9778
|
return promise;
|
|
@@ -9623,8 +9782,6 @@ function requireAxios () {
|
|
|
9623
9782
|
|
|
9624
9783
|
let newConfig = config;
|
|
9625
9784
|
|
|
9626
|
-
i = 0;
|
|
9627
|
-
|
|
9628
9785
|
while (i < len) {
|
|
9629
9786
|
const onFulfilled = requestInterceptorChain[i++];
|
|
9630
9787
|
const onRejected = requestInterceptorChain[i++];
|
|
@@ -9646,7 +9803,7 @@ function requireAxios () {
|
|
|
9646
9803
|
len = responseInterceptorChain.length;
|
|
9647
9804
|
|
|
9648
9805
|
while (i < len) {
|
|
9649
|
-
promise = promise.then(responseInterceptorChain[i++]
|
|
9806
|
+
promise = promise.then(responseInterceptorChain[i++]).catch(responseInterceptorChain[i++]);
|
|
9650
9807
|
}
|
|
9651
9808
|
|
|
9652
9809
|
return promise;
|
|
@@ -9749,7 +9906,7 @@ function requireAxios () {
|
|
|
9749
9906
|
return;
|
|
9750
9907
|
}
|
|
9751
9908
|
|
|
9752
|
-
token.reason = new CanceledError(message, config, request);
|
|
9909
|
+
token.reason = new CanceledError$1(message, config, request);
|
|
9753
9910
|
resolvePromise(token.reason);
|
|
9754
9911
|
});
|
|
9755
9912
|
}
|
|
@@ -9833,7 +9990,7 @@ function requireAxios () {
|
|
|
9833
9990
|
*
|
|
9834
9991
|
* ```js
|
|
9835
9992
|
* function f(x, y, z) {}
|
|
9836
|
-
*
|
|
9993
|
+
* const args = [1, 2, 3];
|
|
9837
9994
|
* f.apply(null, args);
|
|
9838
9995
|
* ```
|
|
9839
9996
|
*
|
|
@@ -9928,6 +10085,12 @@ function requireAxios () {
|
|
|
9928
10085
|
LoopDetected: 508,
|
|
9929
10086
|
NotExtended: 510,
|
|
9930
10087
|
NetworkAuthenticationRequired: 511,
|
|
10088
|
+
WebServerIsDown: 521,
|
|
10089
|
+
ConnectionTimedOut: 522,
|
|
10090
|
+
OriginIsUnreachable: 523,
|
|
10091
|
+
TimeoutOccurred: 524,
|
|
10092
|
+
SslHandshakeFailed: 525,
|
|
10093
|
+
InvalidSslCertificate: 526,
|
|
9931
10094
|
};
|
|
9932
10095
|
|
|
9933
10096
|
Object.entries(HttpStatusCode).forEach(([key, value]) => {
|
|
@@ -9968,14 +10131,14 @@ function requireAxios () {
|
|
|
9968
10131
|
axios.Axios = Axios$1;
|
|
9969
10132
|
|
|
9970
10133
|
// Expose Cancel & CancelToken
|
|
9971
|
-
axios.CanceledError = CanceledError;
|
|
10134
|
+
axios.CanceledError = CanceledError$1;
|
|
9972
10135
|
axios.CancelToken = CancelToken$1;
|
|
9973
10136
|
axios.isCancel = isCancel;
|
|
9974
10137
|
axios.VERSION = VERSION;
|
|
9975
10138
|
axios.toFormData = toFormData;
|
|
9976
10139
|
|
|
9977
10140
|
// Expose AxiosError class
|
|
9978
|
-
axios.AxiosError = AxiosError;
|
|
10141
|
+
axios.AxiosError = AxiosError$1;
|
|
9979
10142
|
|
|
9980
10143
|
// alias for CanceledError for backward compatibility
|
|
9981
10144
|
axios.Cancel = axios.CanceledError;
|
|
@@ -12168,7 +12331,7 @@ function jitsuAnalytics(_opts) {
|
|
|
12168
12331
|
// }
|
|
12169
12332
|
}
|
|
12170
12333
|
|
|
12171
|
-
var o=function(e,t,a){return alert(e)},s=function(e,t){return o(e,l.error,t)},l={error:"error",success:"success",info:"info"},c={fire:function(e,t,a){return o(e,t,a)},setNotifier:function(e){o=e,salla.event.emit("twilight::notifier.changed");},error:s,success:function(e,t){return o(e,l.success,t)},info:function(e,t){return o(e,l.info,t)},sallaInitiated:function(){var e=window.location.href.match(/([\?\&]danger=)[^&]+/g);e&&(window.history.replaceState(null,document.title,window.location.pathname),salla.event.once("twilight::notifier.changed",(function(){e.forEach((function(e){e=decodeURI(e.replace("?danger=","").replace("&danger=",""));var t=document.createElement("div");t.innerText=e,s(t.innerHTML),salla.event.emit("twilight::error",e);}));})));},types:l},u=function(e,t){return this.api=e,this.event=t,new Proxy(this,{get:function(a,n){return "event"===n?t:"api"===n?e:e&&e[n]||a[n]}})};function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,n=Array(t);a<t;a++)n[a]=e[a];return n}function p(e,t,a){if(v())return Reflect.construct.apply(null,arguments);var n=[null];return n.push.apply(n,t),new(e.bind.apply(e,n))}function h$1(e,t){var a="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(a)return (a=a.call(e)).next.bind(a);if(Array.isArray(e)||(a=function(e,t){if(e){if("string"==typeof e)return d(e,t);var a={}.toString.call(e).slice(8,-1);return "Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?d(e,t):void 0}}(e))||t){a&&(e=a);var n=0;return function(){return n>=e.length?{done:true}:{done:false,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n]);}return e},f.apply(null,arguments)}function g(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,m(e,t);}function v(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})));}catch(e){}return (v=function(){return !!e})()}function m(e,t){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},m(e,t)}Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){for(var t=this;t;){if(t.matches(e))return t;t=t.parentElement;}}),Element.prototype.getElementSallaData=function(e){if(this.getAttribute){if(this.hasAttribute("data-json"))try{return JSON.parse(this.getAttribute("data-json"))}catch(e){}var t=this.getAttribute("data-function");if(t&&window[t]){if("function"==typeof window[t]){for(var a,n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return this.getFilteredData((a=window[t]).call.apply(a,[this].concat(r)))}return this.getFilteredData(window[t])}var o=this.hasAttribute("data-form-selector")?document.querySelector(this.dataset.formSelector):void 0;if((o="FORM"===this.tagName?this:o||this.closest("form")||this.closest("[salla-form-data]")||this)&&"FORM"===o.tagName)return this.getFilteredData(new FormData(o),null,o);var s=o.querySelectorAll("[name]");if(!s.length)return this.getFilteredData();var l=Object.assign({},this.dataset);return s.forEach((function(e){if(!["checkbox","radio"].includes(e.type)||e.checked)try{var t=Salla.helpers.inputData(e.name,e.value,l);l[t.name]=t.value;}catch(t){Salla.log(e.name+" can't be send");}})),this.getFilteredData(l)}},Element.prototype.canEventFireHook=function(e){return !!this.hasAttribute&&this.hasAttribute(Salla.api.hooksPrefix+e.type)},Element.prototype.hasAttributeStartsWith=function(e,t){e=e.toLowerCase();for(var a=0;a<this.attributes.length;a++){var n=this.attributes[a].name.toLowerCase();if(0===n.indexOf(e))return !t||n}return false},HTMLFormElement.prototype.getAjaxFormData=function(e){var t=this.querySelectorAll('input[type="file"]');t.forEach((function(e){e.files.length||e.setAttribute("disabled","");}));var a=new FormData(this);return t.forEach((function(e){e.files.length||e.removeAttribute("disabled");})),{formData:this.getFilteredData(a,e),url:this.getAttribute("action"),method:this.getAttribute("method")||"post",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}},Element.prototype.getFilteredData=function(e,t,a){var n,r=this;return void 0===e&&(e=null),void 0===t&&(t=null),void 0===a&&(a=null),e=e||(null==(n=a)?void 0:n.dataset)||this.dataset,a&&this.name&&void 0!==this.value&&(e=function(e,t,a){e instanceof FormData?e.append(t,a):e[t]=a;return e}(e,this.name,this.value)),["filterBeforeSubmit","filterBeforeSend"].forEach((function(n){var i,o=(null==(i=a)?void 0:i.dataset[n])||r.dataset[n];if(o){var s=window[o];if("function"==typeof s){if(!s(e,a||r,t)&&e)throw "Data failed to be pass verify function window."+o+"(formData, element, event)!";return s(e,a||r,t)}Salla.log("window."+o+"() not found!");}})),e},HTMLAnchorElement.prototype.getAjaxFormData=function(e){return {formData:this.getFilteredData(null,e),url:this.getAttribute("href"),method:this.dataset.type||"get",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}};var y=function(){function e(){this.events={},this.namespace="";var e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&e.length>1?e[1]:"").toLowerCase();}var t=e.prototype;return t.after_init=function(){this.createDynamicFunctions();},t.createDynamicFunctions=function(){var e=this;Object.keys(this.events).forEach((function(t){e.createDynamicEventFuns(t),e.createDynamicListenerFuns(t);}));},t.createDynamicEventFuns=function(e){if(!this[e]){var t=this;this[e]=function(){for(var a=arguments.length,n=new Array(a),r=0;r<a;r++)n[r]=arguments[r];return t.dispatch.apply(t,[e].concat(n))};}},t.createDynamicListenerFuns=function(e){var t="on"+e.charAt(0).toUpperCase()+e.slice(1);if(!this[t]){var a=this;this[t]=function(t){return a.on(e,(async function(){return t.apply(void 0,arguments)}))};}},t.getEventName=function(e){return e=this.events[e]||e||"unknown-event",!this.namespace||e.includes("::")?e:this.namespace+Salla.event.delimiter+e},t.dispatch=function(e){for(var t,a=arguments.length,n=new Array(a>1?a-1:0),r=1;r<a;r++)n[r-1]=arguments[r];return (t=Salla.event).emitAsync.apply(t,[this.getEventName(e)].concat(n))},t.on=function(e,t,a){return void 0===a&&(a={}),Salla.event.addListener(this.getEventName(e),t,a)},t.once=function(e,t){return Salla.event.once(this.getEventName(e),t)},e}(),w=function(e){function t(){var t;return (t=e.call(this)||this).namespace="auth",t.events={login:"login",logout:"logout",codeSent:"code.sent",codeNotSent:"code.not-sent",verified:"verified",verificationFailed:"verification.failed",loggedIn:"logged.in",registered:"registered",registrationFailed:"registration.failed",loggedOut:"logged.out",failedLogout:"failed.logout",refreshFailed:"refresh.failed",tokenFetched:"token.fetched",tokenInvalid:"token.invalid"},t.after_init(),t}g(t,e);var a=t.prototype;return a.login=function(e){return e?(e.type&&this.setTypeActionOnVerified(e.type),this.next_event=e.next_event||null,this.dispatch.apply(this,["login"].concat(Array.prototype.slice.call(arguments)))):(this.next_event=null,this.dispatch.apply(this,["login"].concat(Array.prototype.slice.call(arguments))))},a.loggedIn=async function(e){var t=this;return Salla.profile.info().finally((function(){return t.dispatch("loggedIn",e)}))},a.setTypeActionOnVerified=function(e){this.type_action_on_verified=e;},a.getTypeActionOnVerified=function(){return this.type_action_on_verified||"redirect"},t}(y),b=function(e){function t(){var t;return (t=e.call(this)||this).namespace="cart",t.events={latestFetched:"latest.fetched",latestFailed:"latest.failed",updated:"updated",itemUpdated:"item.updated",itemUpdatedFailed:"item.updated.failed",itemAdded:"item.added",beforeAddItem:"before.add.item",itemAddedFailed:"item.added.failed",itemDeleted:"item.deleted",itemDeletedFailed:"item.deleted.failed",submitted:"submitted",submitFailed:"submit.failed",imageDeleted:"image.deleted",imageNotDeleted:"image.not.deleted",detailsFetched:"details.fetched",detailsNotFetched:"details.not.fetched",successReset:"success.reset",priceQuoteSucceeded:"price-quote.succeeded",priceQuoteFailed:"price-quote.failed",offersFetched:"offers.fetched",offersFailed:"offers.failed",couponAdded:"coupon.added",couponDeleted:"coupon.deleted",couponAdditionFailed:"coupon.addition.failed",couponDeletionFailed:"coupon.deletion.failed",quickOrderSettingFetched:"quick-order.fetched",quickOrderSettingFailed:"quick-order.failed",quickOrderSucceeded:"quick-order.succeeded",quickOrderFailed:"quick-order.failed",beforeStartFastCheckout:"before.start.fast-checkout",submitting:"submitting"},t.after_init(),t}g(t,e);var a=t.prototype;return a.updated=function(e){var t;return Salla.cookie.set("fresh_summary",1),e&&"object"==typeof e?(e.offer&&salla.product.event.offerExisted(e.offer),e.redirect&&(salla.log("The current cart is purchased!"),salla.cart.api.reset()),e.cart?(salla.storage.set("cart.summary",{total:e.cart.total,sub_total:e.cart.sub_total,discount:e.cart.discount,tax_amount:e.cart.tax_amount,total_discount:e.cart.total_discount,real_shipping_cost:e.cart.real_shipping_cost,count:e.cart.count,shipping_cost:null!=(t=e.cart.free_shipping_bar)&&t.has_free_shipping?0:e.cart.real_shipping_cost}),this.dispatch("updated",e.cart)):void salla.log("Failed to get the cart summary!")):(Salla.logger.info("Cart summary not an object!",e),this.dispatch("updated"))},a.latestFetched=function(e){return this.updated(e.data),this.dispatch("latestFetched",e)},a.itemAdded=function(e,t){return this.updated(e.data),this.dispatch("itemAdded",e,t)},a.itemDeleted=function(e,t){return this.updated(e.data),this.dispatch("itemDeleted",e,t)},a.itemUpdated=function(e,t){return this.updated(e.data),this.dispatch("itemUpdated",e,t)},a.couponAdded=function(e,t){return this.updated(e.data),this.dispatch("couponAdded",e,t)},a.couponDeleted=function(e,t){return this.updated(e.data),this.dispatch("couponDeleted",e,t)},t}(y),S=function(e){function t(){var t;return (t=e.call(this)||this).namespace="order",t.events={canceled:"canceled",notCanceled:"not.canceled",orderCreated:"order.created",orderCreationFailed:"order.creation.failed",invoiceSent:"invoice.sent",invoiceNotSent:"invoice.not.sent",ordersFetched:"order.fetched",ordersNotFetched:"order.not.fetched"},t.after_init(),t}return g(t,e),t}(y),_=function(e){function t(){var t;return (t=e.call(this)||this).namespace="scope",t.events={fetched:"fetched",notFetched:"not.fetched",productAvailabilityFetched:"product-availability.fetched",productAvailabilityNotFetched:"product-availability.not.fetched",changeSucceeded:"changed",changeFailed:"not.changed"},t.after_init(),t}return g(t,e),t}(y),F=function(e){function t(){var t;return (t=e.call(this)||this).namespace="rating",t.events={orderNotFetched:"order.not.fetched",orderFetched:"order.fetched",storeRated:"store.rated",storeFailed:"store.failed",productsRated:"products.rated",productsFailed:"products.failed",shippingRated:"shipping.rated",shippingFailed:"shipping.failed"},t.after_init(),t}return g(t,e),t}(y),k=function(e){function t(){var t;return (t=e.call(this)||this).namespace="comment",t.events={added:"added",additionFailed:"addition.failed",fetched:"fetched",fetchFailed:"fetch.failed"},t.after_init(),t}return g(t,e),t}(y),C=function(e){function t(){var t;return (t=e.call(this)||this).namespace="loyalty",t.events={exchangeSucceeded:"exchange.succeeded",exchangeFailed:"exchange.failed",programFetched:"program.fetched",programNotFetched:"program.not.fetched",resetSucceeded:"exchange-reset.succeeded",resetFailed:"exchange-reset.failed"},t.after_init(),t}g(t,e);var a=t.prototype;return a.exchangeSucceeded=function(e,t){return salla.cart.event.updated(e.data),this.dispatch("exchangeSucceeded",e,t)},a.resetSucceeded=function(e){return salla.cart.event.updated(e.data),this.dispatch("resetSucceeded",e)},t}(y),P=function(e){function t(){var t;return (t=e.call(this)||this).namespace="profile",t.events={updated:"updated",updateFailed:"update.failed",verificationCodeSent:"verification.code.sent",updateContactsFailed:"update.contacts.failed",verified:"verified",unverified:"unverified",infoFetched:"info.fetched",infoNotFetched:"info.not.fetched",settingsUpdated:"settings.updated",updateSettingsFailed:"update.settings.failed",deleted:"deleted",notDeleted:"not.deleted"},t.after_init(),t}return g(t,e),t}(y),A=function(e){function t(){var t;return (t=e.call(this)||this).namespace="product",t.events={priceUpdated:"price.updated",priceUpdateFailed:"price.updated.failed",availabilitySubscribed:"availability.subscribed",availabilitySubscribeFailed:"availability.subscribe.failed",categoriesFetched:"categories.fetched",categoriesFailed:"categories.failed",searchFailed:"search.failed",searchResults:"search.results",offerExisted:"offer.existed",fetchOffersFailed:"fetch.offers.failed",offersFetched:"offers.fetched",sizeGuideFetched:"size-guide.fetched",sizeGuideFetchFailed:"size-guide.failed",giftFetched:"gift.fetched",giftFetchFailed:"gift.failed",detailFetched:"detail.fetched",detailFetchFailed:"detail.failed",addGiftToCartSucceeded:"gift.add-to-cart.succeeded",addGiftToCartFailed:"gift.add-to-cart.failed",giftImageUploadSucceeded:"gift.image-upload.succeeded",giftImageUploadFailed:"gift.image-upload.failed",productListFetchSucceeded:"fetch.succeeded",productListFetchFailed:"fetch.failed",productOptionsFetched:"options.fetched",productOptionsNotFetched:"options.not.fetched"},t.after_init(),t}return g(t,e),t}(y),q=function(e){function t(){var t;return (t=e.call(this)||this).namespace="document",t.events={click:"click",change:"change",submit:"submit",keyup:"keyup",leaving:"leaving",request:"request",requestFailed:"request.failed"},t.after_init(),t}g(t,e);var a=t.prototype;return a.onClick=function(e,t){this.fireCallableFuns("click",e,t);},a.onChange=function(e,t){this.fireCallableFuns("change",e,t);},a.onSubmit=function(e,t){this.fireCallableFuns("submit",e,t);},a.onKeyup=function(e,t){this.fireCallableFuns("keyup",e,t);},a.fireCallableFuns=function(e,t,a){this.on(e,(function(e){"function"!=typeof t?"function"==typeof a&&e.target.matches(t)&&a(e):t(e);}));},a.fireEvent=function(e,t){for(var a=arguments.length,n=new Array(a>2?a-2:0),r=2;r<a;r++)n[r-2]=arguments[r];return this.fireEventForElements.apply(this,[e,t,false].concat(n))},a.fireEventForAll=function(e,t){for(var a=arguments.length,n=new Array(a>2?a-2:0),r=2;r<a;r++)n[r-2]=arguments[r];return this.fireEventForElements.apply(this,[e,t,true].concat(n))},a.fireEventForElements=function(e,t,a){for(var n=this,r=arguments.length,i=new Array(r>3?r-3:0),o=3;o<r;o++)i[o-3]=arguments[o];if("string"==typeof e){if(a)return document.querySelectorAll(e).forEach((function(e){return n.fireEventForElements.apply(n,[e,t,false].concat(i))}));e=document.querySelector(e);}if(e){var s=p(CustomEvent,[t].concat(i));return e.dispatchEvent(s)}salla.log("Failed To get element to fire event: "+t);},t}(y),E=function(e){function t(){var t;return (t=e.call(this)||this).namespace="wishlist",t.events={added:"added",removed:"removed",additionFailed:"addition.failed",removingFailed:"removing.failed"},t.after_init(),t}return g(t,e),t}(y),I=function(e){function t(){var t;return (t=e.call(this)||this).namespace="currency",t.events={changed:"changed",failed:"failed",fetched:"fetched",failedToFetch:"failed.to.fetch"},t.after_init(),t}return g(t,e),t}(y),x=function(e){function t(){var t;return (t=e.call(this)||this).namespace="infiniteScroll",t.events={scrollThreshold:"scroll.threshold",request:"request",load:"load",append:"append",error:"error",last:"last",history:"history"},t.after_init(),t}return g(t,e),t}(y),L=function(e){function t(){var t;return (t=e.call(this)||this).namespace="booking",t.events={added:"added",additionFailed:"addition.failed"},t.after_init(),t}return g(t,e),t}(y),T=function(e){function t(){var t;return (t=e.call(this)||this).namespace="landing",t.events={detailsFetched:"order.fetched",getDetailsFailed:"get.details.failed",orderCreated:"order.created",orderCreationFailed:"order.creation.failed",breadcrumbFetched:"breadcrumb.fetched",breadcrumbFetchFailed:"breadcrumb.fetch.failed"},t.after_init(),t}return g(t,e),t}(y),R=function(e){function t(){var t;return (t=e.call(this)||this).namespace="notifications",t.events={fetched:"fetched",fetchFailed:"fetch.failed"},t.after_init(),t}return g(t,e),t}(y),O=function(e){function t(){var t;return (t=e.call(this)||this).namespace="component",t.events={menuFetched:"menus.fetched",menuFetchFailed:"menus.fetch.failed",reviewsFetched:"reviews.fetched",reviewsFetchFailed:"reviews.fetch.failed"},t.after_init(),t}return g(t,e),t}(y),j=function(e){function t(){var t;return (t=e.call(this)||this).namespace="advertisement",t.events={fetched:"advertisement.fetched",fetchFailed:"advertisement.not.fetched"},t.after_init(),t}return g(t,e),t}(y),D=function(e){function t(){var t;return (t=e.call(this)||this).namespace="navigation",t.events={breadcrumbFetched:"breadcrumb.fetched",breadcrumbFetchFailed:"breadcrumb.fetch.failed"},t.after_init(),t}return g(t,e),t}(y),U=function(e){function t(){var t;return (t=e.call(this)||this).namespace="metadata",t.events={valueFetched:"value.fetched",valueNotFetch:"value.not.fetched"},t.after_init(),t}return g(t,e),t}(y);function N(e){e&&e.sallaInitiated&&!e.initiated&&(e.sallaInitiated(),e.initiated=true);}Salla.event.auth=new w,Salla.event.cart=new b,Salla.event.order=new S,Salla.event.scope=new _,Salla.event.rating=new F,Salla.event.booking=new L,Salla.event.comment=new k,Salla.event.landing=new T,Salla.event.loyalty=new C,Salla.event.product=new A,Salla.event.profile=new P,Salla.event.currency=new I,Salla.event.document=new q,Salla.event.wishlist=new E,Salla.event.infiniteScroll=new x,Salla.event.notifications=new R,Salla.event.component=new O,Salla.event.advertisement=new j,Salla.event.navigation=new D,Salla.event.metadata=new U,Salla.event.on("twilight::initiated",(function(){Object.keys(Salla).forEach((function(e){"object"==typeof(e=Salla[e])&&(N(e),Object.keys(e).forEach((function(t){N(e[t]);})));}));})),Salla.config.default_properties={debug:"undefined"!=typeof process&&"development"==="production",token:null,fastRequests:true,canLeave:true,store:{api:["group","test"].includes(window.location.hostname.split(".").pop())?window.location.origin+"/api/v1/":"https://api.salla.dev/store/v1/"},currencies:{SAR:{code:"SAR",name:"ريال سعودي",symbol:"ر.س",amount:1,country_code:"sa"}}},Salla.config.merge(Salla.config.default_properties),Salla.config.triedToGetCurrencies_=false,Salla.config.triedToGetLanguages_=false,Salla.config.isUser=function(){return "user"===Salla.config.get("user.type")},Salla.config.isGuest=function(){return !Salla.config.isUser()},Salla.config.languages=async function(){var e;if(Salla.config.triedToGetLanguages_)return Salla.config.get("languages");Salla.config.triedToGetLanguages_=true;var t=true,a=[];return null==(e=await salla.document.api.request("languages",null,"get"))||null==(e=e.data)||e.map((function(e){t&&(a=[],t=false),e.code=e.code||e.iso_code,e.url=salla.url.get(e.code),e.is_rtl=e.is_rtl||e.rtl,a.push(e);})),Salla.config.set("languages",a),a},Salla.config.currencies=async function(){var e;if(Salla.config.triedToGetCurrencies_)return Salla.config.get("currencies");Salla.config.triedToGetCurrencies_=true;var t=true,a={};return null==(e=await salla.currency.api.list())||null==(e=e.data)||e.map((function(e){t&&(a={},t=false),e.country_code=e.code.substr(0,2).toLowerCase(),a[e.code]=e;})),Salla.config.set("currencies",a),a},Salla.config.isMobileApp=function(){var e;return ["ios","android"].includes(null==(e=Salla.analytics)||null==(e=e.jitsuAnalytics)||null==(e=e.getContextProperty("app"))||null==(e=e.platform)?void 0:e.toLowerCase())};var M=function(e){function a(t,a){var n;return (n=e.call(this,t,a)||this).options={path:".infinite-scroll-btn",history:"push",status:".infinite-scroll-status",append:".list-block"},n.fetchOptions={headers:{"S-INFINITE-SCROLL":true,"S-Source":"twilight","cache-control":"no-cache",pragma:"no-cache"}},n.instances=[],n}g(a,e);var n=a.prototype;return n.initiate=function(e,a,n,r){ void 0===r&&(r=false),r?((n=n||{}).fetchOptions=f({},this.fetchOptions,n.fetchOptions||{}),n.responseBody="json"):n=this.getCustomOptions(a,n);var i="string"!=typeof e?e:document.querySelector(e),o=n.path;if(i&&o&&("string"!=typeof o||document.querySelector(o))){var s=new t$1(i,n);return s.on("scrollThreshold",Salla.infiniteScroll.event.scrollThreshold),s.on("request",Salla.infiniteScroll.event.request),s.on("load",Salla.infiniteScroll.event.load),s.on("append",Salla.infiniteScroll.event.append),s.on("error",Salla.infiniteScroll.event.error),s.on("last",Salla.infiniteScroll.event.last),s.on("history",Salla.infiniteScroll.event.history),this.instances.push(s),s}Salla.logger.warn(i?"Path Option (a link that has next page link) Not Existed!":"Container For InfiniteScroll not Existed!");},n.getCustomOptions=function(e,t){return (t="object"==typeof e&&e||t||this.options).fetchOptions=this.fetchOptions,t.path=t.path||this.options.path,t.button=t.button||t.path,t.status=t.status||this.options.status,t.hasOwnProperty("history")||(t.history=this.options.history),t.nextPage=t.nextPage||t.next_page,t.append="string"==typeof e&&e||t.append||this.options.append,t},n.loadNextPage=function(e){("string"!=typeof e?e:document.querySelector(e)).loadNextPage();},n.destroy=function(e){("string"!=typeof e?e:document.querySelector(e)).destroy();},a}(u),H=function(){function e(){}var t=e.prototype;return t.submit=async function(e,t){var a,n;void 0===t&&(t=null);var r=t;if("SubmitEvent"===(null==(a=t)||null==(a=a.constructor)?void 0:a.name)||"submit"===(null==(n=t)?void 0:n.type)){var i,o;if(t.preventDefault(),"FORM"!==(null==(i=t.target)?void 0:i.tagName))return Salla.logger.warn("Failed find the target element for submit action. make sure you submit a form element"),new Promise((function(){throw "Failed find the target element for submit action. make sure you submit a form element"}));"SALLA-BUTTON"===(null==(o=t)||null==(o=o.submitter)||null==(o=o.parentElement)?void 0:o.tagName)&&t.submitter.parentElement.load(),r=t.target.getElementSallaData(),salla.log("Data from element",r);}if(/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/gm.test(e))return salla.api.request(e,r,"post").finally((function(){var e;loaderSupported&&(null==(e=t)||null==(e=e.submitter)||e.parentElement.stop());}));var s=e.split("."),l=s.splice(-1);return await salla.call(s.join("."))[l](r).finally((function(){var e;return null==(e=t)||null==(e=e.submitter)||null==(e=e.parentElement)?void 0:e.stop()})).catch((function(e){throw salla.logger.warn(e),e}))},t.onSubmit=function(e,t){return salla.form.submit(e,t),false},t.onChange=function(e,t){var a;return null!=t&&t.currentTarget?"FORM"!==(null==t||null==(a=t.currentTarget)?void 0:a.tagName)||t.currentTarget.checkValidity()?(salla.form.submit(e,t.currentTarget.getElementSallaData()),true):(salla.logger.warn("Trying to trigger '"+e+"' without filling required fields!"),false):(salla.logger.warn("Trying to trigger '"+e+"' without event!"),false)},t.getPossibleValue=function(e,t,a){if(void 0===a&&(a=false),e){if("object"!=typeof e)return e;for(var n,r=0;r<t.length&&!(n=e[t[r]])&&!("undefined"!=typeof FormData&&e instanceof FormData&&(n=e.get(t[r])));r++);return "object"!=typeof(n=n||e)||a?n:void 0}},e}(),V=function(e){function t(t){var a;return (t=t||{}).messages=t.messages||window.translations,t.locale=t.locale||(window.locale||navigator.language||navigator.userLanguage||"ar").split("-")[0],t.fallback=t.fallback||t.locale,(a=e.call(this,t)||this).translationsLoaded=false,a}g(t,e);var a=t.prototype;return a.onLoaded=function(e){var t=this;return new Promise((function(a){if(t.translationsLoaded)return a(e?e():null);Salla.event.once("languages::translations.loaded",(function(){return a(e?e():null)}));}))},a.loadStoreTranslations=function(){if(this.hash=salla.config.get("theme.translations_hash",salla.config.get("store.id","twilight")),this.message||(salla.log("try to load translations from localstorage"),this.messages=salla.storage.get("s_translations."+this.hash),this.messages&&(this.translationsLoaded=true)&&e.prototype.setMessages.call(this,this.messages)),this.messages)return salla.event.dispatch("languages::translations.loaded"),void salla.logger.info("The messages of transactions is already loaded");salla.url.get("")?this.loadScript(salla.url.get("languages/assets/"+this.hash+".js")):this.loadScript("https://cdn.salla.network/js/translations.js",false);},a.setMessages=function(t){e.prototype.setMessages.call(this,t),salla.event.dispatch("languages::translations.loaded"),this.translationsLoaded=true;},a.loadScript=function(e,t){var a=this;void 0===t&&(t=true);var n=document.createElement("script");n.src=e,n.onload=function(){var e;if(window.translations)return salla.storage.remove("s_translations"),salla.storage.set("s_translations",((e={})[a.hash]=window.translations,e)),a.setMessages(window.translations);n.onerror();},n.onerror=function(){if(t)return salla.logger.warn("Failed to load Translations for store, lets try load it from CDN"),a.loadScript("https://cdn.salla.network/js/translations.js",false);salla.logger.error("Failed to load Translations, check your network logs for more details\nor: salla.lang.setMessages({....}), see https://docs.salla.dev for more information's.");},document.head.appendChild(n);},a.getWithDefault=function(e,t,a,n){var r=this.get(e,a,n);return r!==e?r:t},a.get=function(t,a,n){var r=t;(window.translations||this.translationsLoaded)&&(r="trans."+t);var i=e.prototype.get.call(this,r,a,n);return i!==r?i:e.prototype.get.call(this,r,a,"en").replace(r,t)},a.set=function(e,t){return salla.helpers.setNested(this.messages[this.getLocale()+".trans"],e,t),this},a.add=function(e,t){var a=this;return Object.entries(t).forEach((function(t){return salla.helpers.setNested(a.messages[t[0]+".trans"],e,t[1])})),this},a.addBulk=function(e){var t=this;return Object.entries(e).forEach((function(e){var a=e[0],n=e[1];t.add(a,n);})),this},t}(a$3),G=function(){function e(){this.endpoints={},this.webEndpoints=[],this.namespace="BaseApi",this.endpointsMethods={},this.endpointsHeaders={};var e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&e.length>1?e[1]:"").toLowerCase(),this.debounce={request:void 0,time:300,enabled:true,exclude:[]};}var t=e.prototype;return t.after_init=function(){},t.normalRequest=function(e,t,a){ void 0===t&&(t=void 0),void 0===a&&(a=null);var n=Array.isArray(e),r=n?this.getUrl.apply(this,e):this.getUrl(e);e=n?e[0]:e,a=a||this.endpointsMethods[e]||"post";var i=this.endpointsHeaders[e];if("get"===a&&t instanceof FormData){var o={};Array.from(t.entries()).forEach((function(e){o[e[0]]=e[1];})),t={params:o};}return i&&"get"===a&&(t=t?Object.assign(t,i):i),this.webEndpoints.includes(e)?r=salla.url.get(r):"http"!==r.substring(0,4)&&(r=salla.url.api(r)),Salla.api.request(r,t,a,{headers:i})},t.request=function(e,t,a){return void 0===t&&(t=void 0),void 0===a&&(a=null),!salla.api.isFastRequestsAllowed()&&this.debounce.enabled?(this.debounce.request||(this.debounce.request=salla.helpers.debounce(this.normalRequest.bind(this),this.debounce.time)),this.debounce.request(e,t,a)):this.normalRequest(e,t,a)},t.getUrl=function(e){for(var t=this.endpoints[e]||e,a=/{[^{}]+}/i,n=1;n<arguments.length;n++)t=t.replace(a,arguments[n]);return t},t.event=function(){return salla.event[this.className]},e}(),z=function(e){function t(){var t;return (t=e.call(this)||this).addToCartTries=0,t.guestCartAssigned=false,t.namespace="cart",t._pendingCartIdRequest=null,t._pendingAssignRequest=null,t.endpoints={latest:"cart/latest",latestApi:"cart/latest",details:"cart/{cart}",quickAdd:"cart/{cart}/item/{product}/quick-add",addItem:"cart/{cart}/item/{product}/add",deleteItem:"cart/{cart}/item/{item}",updateItem:"cart/{cart}/item/{item}",deleteImage:"cart/{cart}/image/{image}",uploadImage:"cart/{cart}/image",status:"cart/{cart}/status",addCoupon:"cart/{id}/coupon",deleteCoupon:"cart/{id}/coupon",getQuickOrderSettings:"checkout/quick-order",createQuickOrder:"checkout/quick-order",priceQuote:"cart/{cartId}/price-quote",offers:"offers/cart/{cartId}",giftCartDetails:"cart/{cartId}/buy-as-gift",cartGiftToCart:"cart/{cart_id}/buy-as-gift",assign:"cart/{cartId}/assign?merge=1"},t.endpointsMethods={latest:"get",details:"get",status:"get",updateItem:"post",deleteItem:"delete",deleteImage:"delete",deleteCoupon:"put",getQuickOrderSettings:"get",offers:"get",giftCartDetails:"get"},t.webEndpoints=["latest"],t.latestCart=null,t.after_init(),salla.event.on("api::initiated",(function(){return salla.api.cart.getCurrentCartId(false,"api::initiated")})),salla.event.on("auth::token.fetched",t._checkCurrentCart),salla.event.on("auth::token.invalid",t._checkCurrentCart),salla.event.on("auth::verified",(async function(){try{await Salla.api.cart.assign();}catch(e){Salla.log("Error on assign after verified",e);}return Salla.api.cart.getCurrentCartId(true,"auth::verified")}),{async:true}),salla.event.on("twilight::initiated",(function(){return salla.api.cart.syncGuestCart()})),salla.event.on("profile::info.fetched",(function(){return t._checkCurrentCart(true)})),salla.event.on("twilight::error",(function(e){return (e.includes("Cart not available")||e.includes("السلة غير متاحة"))&&salla.cart.api.reset()})),t}g(t,e);var a=t.prototype;return a._checkCurrentCart=function(e){var t,a;void 0===e&&(e=false);var n=salla.storage.get("cart"),r=null==(t=salla.config.get("user"))?void 0:t.id,i=null==(a=salla.config.get("store"))?void 0:a.id;n&&n.id&&!e&&(n.user_id===r&&n.store_id===i||(salla.log("cart",{user_id:n.user_id,store_id:n.store_id}),salla.log("current",{user_id:r,store_id:i}),salla.log("Api:: case2 => The cart is not belong to current "+(n.user_id!==r?"user":"store")+"!"),salla.cart.api.reset()),salla.url.is_page("cart")&&n.id!==salla.config.get("page.id")&&(salla.log("cart",{user_id:n.user_id,store_id:n.store_id}),salla.log("current",{user_id:r,store_id:i}),salla.log("Api:: case2 => The cart is different between storage:"+n.id+" & session:"+salla.config.get("page.id")+" !"),salla.cart.api.reset()));},a.getCurrentCartId=async function(e,t){if(void 0===e&&(e=false),void 0===t&&(t="getCurrentCartId"),Salla.cart.api._pendingCartIdRequest)return Salla.cart.api._pendingCartIdRequest;Salla.cart.api._pendingCartIdRequest=async function(){try{if(!e){if(Salla.cart.api.latestCart)return Salla.cart.api.latestCart.cart.id;var a=Salla.storage.get("cart.id");if(a)return a}var n=await Salla.cart.api.latest(t);return Salla.cart.api.latestCart=n.data,Salla.cart.api.latestCart.cart.id}finally{Salla.cart.api._pendingCartIdRequest=null;}}();var a=Salla.cart.api._pendingCartIdRequest;return Salla.cart.api._pendingCartIdRequest=null,a},a.getUploadImageEndpoint=function(e){return salla.url.api(this.getUrl("uploadImage",e||salla.storage.get("cart.id")))},a.latest=function(e){return void 0===e&&(e="direct"),this.request(salla.auth.api.isSessionless()?"latestApi":"latest",{params:{source:"",callerName:e}}).then((function(e){return salla.api.cart.set(e.data.cart),salla.event.cart.latestFetched(e),e})).catch((function(e){throw salla.api.cart.reset(),salla.event.cart.latestFailed(e),e}))},a.details=async function(e,t){return void 0===t&&(t=[]),e=e||await salla.api.cart.getCurrentCartId(false,"salla.api.cart.details"),this.request(["details",e],{params:{with:t}}).then((function(e){return salla.cart.event.detailsFetched(e),e})).catch((function(e){throw salla.cart.event.detailsNotFetched(e),e}))},a.quickAdd=async function(e,t,a){return this.addItem({id:e,quantity:t,offerType:a,endpoint:"quickAdd"})},a.addItem=async function(e){var t=this.getCartPayload(e);if(!t.id){var a='There is no product "id"!';return salla.cart.event.itemAddedFailed(a),salla.api.errorPromise(a)}var n=salla.form.getPossibleValue(t.payload,["endpoint"]);n&&["addItem","quickAdd"].includes(n)||(n=salla.form.getPossibleValue(t.payload,["quantity","donating_amount"])?"addItem":"quickAdd");var r=await Salla.api.cart.getCurrentCartId(false,"salla.api.cart.addItem");try{t.payload=Salla.helpers.createFormDataWrapper(t.payload||{}),await Salla.cart.event.beforeAddItem(t);}catch(e){}return this.request([n,r,t.id],t.payload.getRawData()).then((function(e){Salla.cart.api.addToCartTries=0;try{Salla.cart.event.itemAdded(e,t.id);}catch(e){Salla.log(e);}return e})).catch((function(a){if(!Salla.cart.api.addToCartTries)return Salla.cart.api.addToCartTries++,Salla.cart.reset(),Salla.cart.api.addItem(e);throw Salla.cart.event.itemAddedFailed(a,t.id),a}))},a.deleteItem=async function(e){var t=this.getCartPayload(e);if(!t.id){var a='There is no "id"!';return salla.cart.event.itemDeletedFailed(a),salla.api.errorPromise(a)}var n=await salla.api.cart.getCurrentCartId(false,"salla.api.cart.deleteItem");return this.request(["deleteItem",n,t.id]).then((function(e){return salla.cart.event.itemDeleted(e,t.id),e})).catch((function(e){throw salla.cart.event.itemDeletedFailed(e,t.id),e}))},a.updateItem=async function(e){var t,a=this.getCartPayload(e);if(!a.id){var n='There is no "id"!';return salla.cart.event.itemUpdatedFailed(n),salla.api.errorPromise(n)}var r=await salla.api.cart.getCurrentCartId(false,"salla.api.cart.updateItem");return "Object"===(null==(t=a.payload.constructor)?void 0:t.name)?a.payload._method="PUT":a.payload.append("_method","PUT"),this.request(["updateItem",r,a.id],a.payload).then((function(e){return salla.cart.event.itemUpdated(e,a.id),e})).catch((function(e){throw salla.cart.event.itemUpdatedFailed(e,a.id),e}))},a.deleteImage=async function(e){if(!(e=salla.form.getPossibleValue(e,["id","image_id","photo_id"]))){var t='There is no "id"!';return salla.cart.event.imageNotDeleted(t),salla.api.errorPromise(t)}var a=await salla.api.cart.getCurrentCartId(false,"salla.api.cart.deleteImage");return this.request(["deleteImage",a,e]).then((function(t){return salla.cart.event.imageDeleted(t,e),t})).catch((function(t){throw salla.cart.event.imageNotDeleted(t,e),t}))},a.status=async function(e,t){ void 0===t&&(t=false),e=e||await salla.api.cart.getCurrentCartId(false,"salla.api.cart.status");var a={has_apple_pay:salla.helpers.hasApplePay()};t&&(a.guest_checkout=1);try{await salla.cart.event.submitting();}catch(e){salla.log("Error on: salla.cart.event.submitting()");}return this.request(["status",e],{params:a})},a.submit=async function(e,t){if(void 0===e&&(e=false),void 0===t&&(t=false),console.log("salla.cart.api.submit",{isGuestCheckout:e}),salla.config.isGuest()&&!e)return salla.log("it looks that the current user is not logged-in, lets login then submit"),salla.cart.loginOnCartPage();var a;if(t)try{var n,r=await Salla.api.cart.assign();a=null==r||null==(n=r.data)?void 0:n.cart_id;}catch(e){Salla.log("Error on assign after login from submit",e);}this.status(null!=a?a:await salla.api.cart.getCurrentCartId(false,"salla.api.cart.submit"),e).then((function(e){var t,a=null==(t=e.data.next_step)?void 0:t.to;if(a||(window.history.pushState({},"",salla.url.addParamToUrl("reload","empty_next_step")),window.history.pushState({},"",salla.url.addParamToUrl("acitve",false===e.data.active?"false":"true_or_undfined")),salla.cart.reset(),window.location.reload()),!["checkout","refresh","login"].includes(a)){var n="Can't find next_step );";throw salla.cart.reset(),salla.cart.event.submitFailed(n),n}return salla.cart.event.submitted(e),"login"===a?salla.cart.loginOnCartPage():"checkout"===a?window.location.href=e.data.next_step.url+(salla.helpers.hasApplePay()?"?has_apple_pay=true":""):(window.history.pushState({},"",salla.url.addParamToUrl("reload","refresh")),void window.location.reload())})).catch((function(e){var t;salla.cart.api.tries=salla.cart.api.tries||0,salla.cart.reset();var a=404===(null==e||null==(t=e.response)||null==(t=t.data)?void 0:t.status);if(a&&0===salla.cart.api.tries)return salla.cart.api.tries++,salla.log("we recived that the current cart is not found, we will try to re-submit one more time"),salla.cart.submit();throw a&&salla.error(salla.lang.get("pages.checkout.try_again")),salla.cart.event.submitFailed(e),e}));},a.getCartPayload=function(e){var t,a=(null==(t=e)?void 0:t.data)||("object"==typeof e?e:void 0);return {id:e=a?salla.form.getPossibleValue(a,["prod_id","product_id","item_id","id"]):e,payload:a="object"==typeof a?a:void 0}},a.normalRequest=function(t,a,n){var r=this;return void 0===a&&(a=void 0),void 0===n&&(n=null),e.prototype.normalRequest.call(this,t,a,n).catch((async function(e){var t;throw 403===(null==e||null==(t=e.response)?void 0:t.status)&&(r.reset(),salla.error(salla.lang.get("pages.checkout.try_again"))),e}))},a.reset=function(){salla.api.cart.latestCart=null,salla.storage.remove("cart"),salla.cookie.clearCookieByPrefix(salla.api.cart.getCartCookiePrefix()),salla.cart.event.successReset();},a.addCoupon=async function(e){if(e=e.data||e,!(e=salla.form.getPossibleValue(e,["coupon"]))){var t=new Error('There is no "Coupon Code"!');return t.name="EmptyCoupon",salla.event.cart.couponAdditionFailed(t),salla.api.errorPromise(t)}var a=await salla.cart.api.getCurrentCartId(false,"salla.api.cart.addCoupon");return this.request(["addCoupon",a],{coupon:e}).then((function(e){var t,n=salla.storage.get("cart");return n&&null!=(t=e.data)&&null!=(t=t.cart)&&t.coupon&&(n.coupon=e.data.cart.coupon,salla.storage.set("cart",n)),salla.event.cart.couponAdded(e,a),e})).catch((function(e){throw salla.event.cart.couponAdditionFailed(e,a),e}))},a.deleteCoupon=async function(){var e=await salla.cart.api.getCurrentCartId(false,"salla.api.cart.deleteCoupon");return this.request(["deleteCoupon",e],{}).then((function(t){var a=salla.storage.get("cart");return a&&a.coupon&&(delete a.coupon,salla.storage.set("cart",a)),salla.event.cart.couponDeleted(t,e),t})).catch((function(t){throw salla.event.cart.couponDeletionFailed(t,e),t}))},a.getQuickOrderSettings=function(){return this.request("getQuickOrderSettings").then((function(e){return salla.event.cart.quickOrderSettingFetched(e),e})).catch((function(e){throw salla.event.cart.quickOrderSettingFailed(e),e}))},a.createQuickOrder=function(e){return this.request("createQuickOrder",e).then((function(e){return salla.event.cart.quickOrderSucceeded(e),e})).catch((function(e){throw salla.event.cart.quickOrderFailed(e),e}))},a.priceQuote=async function(e){return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("cart::priceQuote",e),void salla.event.dispatch("login::open")):this.request(["priceQuote",e||await salla.api.cart.getCurrentCartId(false,"salla.api.cart.priceQuote")]).then((function(e){return salla.cart.api.reset(),salla.event.cart.priceQuoteSucceeded(e).then((function(){return setTimeout((function(){return window.location.href=salla.url.get("/")}),1e3),e}))})).catch((function(e){return salla.event.cart.priceQuoteFailed(e).then((function(){var t;throw 404===(null==(t=e.error)?void 0:t.code)&&window.location.reload(),e}))}))},a.loginOnCartPage=function(){salla.auth.setCanRedirect(false),salla.event.dispatch("login::open",{withoutReload:true,source:"cart-submit"}),salla.auth.event.onLoggedIn((function(){salla.event.dispatch("login::close"),salla.cart.submit(false,true);}));},a.set=function(e){salla.storage.set("cart",e),salla.api.cart.syncGuestCart();},a.offers=async function(){var e=await salla.cart.api.getCurrentCartId(false,"salla.api.cart.offers");return this.request(["offers",e]).then((function(e){return salla.event.cart.offersFetched(e),e})).catch((function(e){throw salla.event.cart.offersFailed(e),e}))},a.getGiftCartDetails=async function(){var e=await salla.api.cart.getCurrentCartId(false,"salla.api.cart.getGiftCartDetails");return this.request(["giftCartDetails",e]).then((function(t){return salla.product.event.giftFetched(t,e),t})).catch((function(t){throw salla.product.event.giftFetchFailed(t,e),t}))},a.addCartGiftToCart=async function(e,t){ void 0===t&&(t=false);var a=await salla.api.cart.getCurrentCartId(false,"salla.api.cart.addCartGiftToCart");return this.request(["cartGiftToCart",a],e).then((function(e){return salla.product.event.addGiftToCartSucceeded(e,a),t&&(window.location.href=e.redirect),e})).catch((function(e){throw salla.product.event.addGiftToCartFailed(e,a),e}))},a.syncGuestCart=async function(){if(salla.config.isGuest()){var e=salla.api.cart.getCartCookiePrefix(),t=salla.cookie.getCookieByPrefix(e),a=salla.storage.get("cart.id");if(!a&&t.length)try{var n,r=null==(n=(await salla.api.cart.latest()).data)||null==(n=n.cart)?void 0:n.id;r&&salla.api.cart.setCartCookie(e,r);}catch(e){salla.log("Failed to fetch latest cart:",e);}salla.cookie.clearCookieByPrefix(e),a&&(salla.config.set("headers.s-cart-id",a),salla.api.cart.setCartCookie(e,a));}},a.assign=async function(){var e=this;if(Salla.api.cart._pendingAssignRequest)return Salla.api.cart._pendingAssignRequest;var t=Salla.storage.get("cart.id");return !(!t||Salla.api.cart.guestCartAssigned)&&(Salla.api.cart._pendingAssignRequest=async function(){try{var a=await e.request(["assign",t]);return Salla.api.cart.guestCartAssigned=true,a}catch(e){throw e}finally{Salla.api.cart._pendingAssignRequest=null;}}(),Salla.api.cart._pendingAssignRequest)},a.setCartCookie=function(e,t){salla.cookie.set(e+"-"+t,t,1);},a.getCartCookiePrefix=function(){return "cart-id-"+salla.config.get("store.id")},t}(G),W=function(e){function t(){var t;return (t=e.call(this)||this).namespace="loyalty",t.endpoints={getProgram:"loyalty",exchange:"loyalty/exchange",reset:"loyalty/exchange"},t.endpointsMethods={getProgram:"get",reset:"put"},t.after_init(),t}g(t,e);var a=t.prototype;return a.getProgram=function(){return this.request("getProgram").then((function(e){return salla.loyalty.event.programFetched(e),e})).catch((function(e){throw salla.loyalty.event.programNotFetched(e),e}))},a.exchange=async function(e,t){if(void 0===t&&(t=null),!(e=salla.form.getPossibleValue(e,["id","loyalty_prize_id","prize_id"]))){var a="Unable to find cart id. Please provide one.";return salla.loyalty.event.exchangeFailed(a),salla.api.errorPromise(a)}if(!(t=t||await salla.cart.getCurrentCartId(false,"salla.api.loyalty.exchange"))){var n="Unable to find cart id. Please provide one.";return salla.loyalty.event.exchangeFailed(n),salla.api.errorPromise(n)}return this.request("exchange",{loyalty_prize_id:e,cart_id:t}).then((function(t){return salla.loyalty.event.exchangeSucceeded(t,e),t})).catch((function(t){throw salla.loyalty.event.exchangeFailed(t,e),t}))},a.reset=async function(e){if(void 0===e&&(e=null),!(e=e||await salla.cart.getCurrentCartId(false,"salla.api.loyalty.reset"))){var t="Unable to find cart id. Please provide one.";return salla.loyalty.event.resetFailed(t),salla.api.errorPromise(t)}return this.request("reset",{cart_id:e}).then((function(e){return salla.loyalty.event.resetSucceeded(e),e})).catch((function(e){throw salla.loyalty.event.resetFailed(e),e}))},t}(G),B=function(e){function t(){var t;return (t=e.call(this)||this).namespace="auth",t.canRedirect_=true,t.afterLoginEvent={event:null,payload:null},t.endpoints={login:"auth/{type}/send_verification",resend:"auth/resend_verification",verify:"auth/{type}/verify",register:"auth/register",logout:"logout",refresh:"auth/refresh"},t.webEndpoints=["logout","auth/jwt","refresh"],t.endpointsMethods={logout:"get"},t.inIframe=salla.helpers.isIframe(),Salla.event.on("twilight::init",(function(){if(Salla.config.isGuest()&&location.href.includes("force_logout"))return delete Salla.api.axios.defaults.headers.common.Authorization,Salla.api.auth.logout("twilight",false)})),t.after_init(),t}g(t,e);var a=t.prototype;return a.setAfterLoginEvent=function(e,t){salla.api.auth.afterLoginEvent={event:e,payload:t};},a.setCanRedirect=function(e){salla.api.auth.canRedirect_=e;},a.canRedirect=function(){return salla.api.auth.canRedirect_&&!salla.api.auth.afterLoginEvent.event},a.login=function(e){var t;null!=(t=e)&&t.data&&(e=e.data);var a=salla.form.getPossibleValue(e,["type"]);if(!["email","mobile"].includes(a)){var n="Login type should be in: [email, mobile]";return salla.auth.event.codeNotSent(n),salla.api.errorPromise(n)}return this.request(["login",a],e).then((function(e){return salla.auth.event.codeSent(e,a),e})).catch((function(e){throw salla.auth.event.codeNotSent(e,a),salla.auth.api.trackBlockedError(e,"login"),e}))},a.verify=async function(e,t){ void 0===t&&(t=true);var a=salla.form.getPossibleValue(e,["type"]);if(!a){var n="Failed to know what's login type!";return salla.auth.event.verificationFailed(n),salla.api.errorPromise(n)}t=false!==salla.form.getPossibleValue(e,["supportWebAuth"])&&t,salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event);var r=await salla.auth.api.request(["verify",a],e);return 200!==(null==r?void 0:r.status)?(salla.auth.event.verificationFailed(r,a),salla.api.errorPromise(r)):salla.auth.api.handlAfterAuthenticatedResponse(r,t)},a.handlAfterAuthenticatedResponse=async function(e,t){var a;e.data||(e={data:e});var n="authenticated"===(null==(a=e.data)?void 0:a.case);return n&&salla.auth.event.tokenFetched(e.data.token),t&&!this.inIframe&&!this.isSessionless()&&await salla.auth.api.request("auth/jwt",{callerName:"salla.auth.api.handlAfterAuthenticatedResponse"}),n&&await salla.auth.event.loggedIn(e).then((function(){return salla.auth.api.afterUserLogin()})),await salla.auth.event.verified(e,e.data.verification.type),salla.api.successPromise(e)},a.resend=function(e){var t;return (e=e.data||e).type=e.type||"mobile","mobile"!==e.type||e.phone&&e.country_code?"email"!==e.type||e.email?this.request("resend",e).then((function(t){return salla.auth.event.codeSent(t,e),t})).catch((function(t){throw salla.auth.event.codeNotSent(t,e),salla.auth.api.trackBlockedError(t,"resend"),t})):(salla.auth.event.codeNotSent(t="There is no email!",e),salla.api.errorPromise(t)):(salla.auth.event.codeNotSent(t="There is no phone or country_code!",e),salla.api.errorPromise(t))},a.register=function(e){var t,a=this;return e.data&&(t=e.element,e=e.data),salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event),this.request("register",e).then((async function(e){var n;return salla.auth.event.registered.call(t,e),"authenticated"===(null==(n=e.data)?void 0:n.case)&&(salla.auth.event.tokenFetched(e.data.token),!a.inIframe&&!a.isSessionless()&&await salla.auth.request("auth/jwt",{callerName:"salla.auth.api.register"}),salla.auth.event.loggedIn(e),salla.auth.api.afterUserLogin()),e})).catch((function(e){throw salla.auth.event.registrationFailed.call(t,e),salla.auth.api.trackBlockedError(e,"register"),e}))},a.handleIframeReadyAction=function(e,t){var a;null==(a=e.contentWindow)||a.postMessage({source:"logout",type:"init",data:{id:salla.config.get("store.id"),lang:"ar",appUrl:t,apiUrl:salla.config.get("store.api").replace(/\/+$/,""),settings:salla.config.all(),storage:{}}},"*");},a.appendIframeAndLogout=function(){var e=this;return new Promise((function(t){var a=salla.config.get("login.url","https://accounts.salla.com"),n=document.createElement("iframe");n.style.display="none",n.src=a+"/logout";var r=function(i){if("login"===i.data.source){var o=i.data.type.replace("iframe::","");if(salla.log("iframe::logout-iframe message received",i.data),["logged-out","ready"].includes(o)){if("ready"===o)return e.handleIframeReadyAction(n,a);window.removeEventListener("message",r),n.remove(),t();}}};window.addEventListener("message",r),document.body.appendChild(n);}))},a.logout=function(e,t){var a=this;return void 0===e&&(e="twilight"),void 0===t&&(t=true),salla.storage.clearAll(),salla.cookie.clearAll(),e=encodeURI(e),salla.auth.event.loggedOut().then((function(){return a.appendIframeAndLogout()})).then((function(){if(t){var a=salla.url.get("logout?from="+e);console.log("Going to "+a+", to do any thing before this action use: salla.auth.even.onLoggedOut(()=>{...})");try{location.href=a;}catch(e){salla.log(e);}}})).catch((function(e){return console.error("Error during logout:",e)}))},a.refresh=function(){return this.request("refresh").then((function(e){return salla.auth.event.tokenFetched(e.data.token),e})).catch((function(e){throw salla.auth.event.refreshFailed(e),e}))},a.afterUserLogin=function(){this.afterLoginEvent.event&&salla.event.emit(this.afterLoginEvent.event,this.afterLoginEvent.payload);},a.isSessionless=function(){return "sessionless"===salla.config.get("auth.mode")},a.trackBlockedError=function(e,t){var a;blockedByProxy=void 0===(null==e||null==(a=e.response)||null==(a=a.headers)?void 0:a["s-ray"]),blockedByProxy&&salla.analytics.track("BlockedByProxy",{class:"auth",function:t,reason:"non-server-request",message:e.message});},t}(G),Q=function(e){function t(){var t;return (t=e.call(this)||this).namespace="order",t.endpoints={cancel:"orders/cancel/{id}",createCartFromOrder:"reorder/{id}",reorderProduct:"reorder/product/{id}",sendInvoice:"orders/send/{id}",fetch:"orders"},t.endpointsMethods={createCartFromOrder:"get",fetch:"get"},t.after_init(),t}g(t,e);var a=t.prototype;return a.show=function(e){var t=salla.form.getPossibleValue((null==e?void 0:e.data)||e,["id","order_id"]);salla.event.dispatch("mobile::order.placed",{order_id:t}),location.href=salla.form.getPossibleValue((null==e?void 0:e.data)||e,["url"]);},a.cancel=function(e){return e=e||Salla.config.get("page.id"),this.request(["cancel",e],{params:{has_apple_pay:salla.helpers.hasApplePay()}}).then((function(t){return salla.event.order.canceled(t,e),t})).catch((function(t){throw salla.event.order.notCanceled(t,e),t}))},a.createCartFromOrder=function(e){return e=e||salla.config.get("page.id"),this.request(["createCartFromOrder",e]).then((function(t){return salla.cart.reset(),salla.event.order.orderCreated(t,e),window.location.href=t.data.url,t})).catch((function(t){throw salla.event.order.orderCreationFailed(t,e),t}))},a.reorderProduct=function(e){return e=e||salla.config.get("page.id"),this.request(["reorderProduct",e]).then((function(e){return salla.event.order.orderCreated(e,e.data.order_id),window.location.href=e.data.url,e})).catch((function(e){throw e}))},a.sendInvoice=function(e){var t=salla.form.getPossibleValue(e,["id"])||salla.config.get("page.id");if(!t||isNaN(t)){var a="There is no id!";return salla.order.event.invoiceNotSent(a),salla.api.errorPromise(a)}return this.request(["sendInvoice",t],e).then((function(e){return salla.event.order.invoiceSent(e,t),e})).catch((function(e){throw salla.event.order.invoiceNotSent(e,t),e}))},a.fetch=function(e){return this.request(["fetch"],{params:e}).then((function(e){return salla.event.order.ordersFetched(e),e})).catch((function(e){throw salla.event.order.ordersNotFetched(e),e}))},t}(G),K=function(e){function t(){var t;return (t=e.call(this)||this).namespace="product",t.previousQuery="",t.endpoints={getPrice:"products/{id}/price",availabilitySubscribe:"products/{id}/availability-notify",search:"products/search",details:"products/{product_id}/details",categories:"products/categories/{?id}",offers:"products/{product_id}/specialoffer",getSizeGuides:"products/{prod_id}/size-guides",giftProductDetails:"products/{product_id}/buy-as-gift",productGiftToCart:"products/{product_id}/buy-as-gift",giftImage:"products/buy-as-gift/image",buyNow:"products/{product_id}/buy-now",fetch:"products",fetchOptions:"products/options"},t.endpointsMethods={details:"get",giftProductDetails:"get",fetch:"get",offers:"get",fetchOptions:"get"},t.after_init(),t}g(t,e);var a=t.prototype;return a.getPrice=function(e){var t=e.data||e,a=salla.form.getPossibleValue(t,["id","prod_id","product_id"]);return this.request(["getPrice",a],"object"==typeof t?t:void 0).then((function(e){return salla.product.event.priceUpdated(e,a),e})).catch((function(e){throw salla.product.event.priceUpdateFailed(e,a),e}))},a.categories=function(e){return this.request(["categories",e||""],null,"get").then((function(e){return salla.product.event.categoriesFetched(e),e})).catch((function(e){throw salla.product.event.categoriesFailed(e),e}))},a.availabilitySubscribe=function(e){var t=e.data||e;return e=salla.form.getPossibleValue(t,["id","prod_id"]),this.request(["availabilitySubscribe",e],"object"==typeof t?t:void 0).then((function(t){return salla.product.event.availabilitySubscribed(t,e),t})).catch((function(t){throw salla.product.event.availabilitySubscribeFailed(t,e),t}))},a.search=function(e){var t,a=e.data;if(a||(a={params:"string"==typeof e?{query:e}:e}),!(e=a instanceof FormData?a.get("query"):a.query||(null==(t=a.params)?void 0:t.query))){var n='There is no "query"!';return salla.product.event.searchFailed(n),salla.api.errorPromise(n)}if(e===salla.api.product.previousQuery){var r="Query is same as previous one!";return salla.product.event.searchFailed(r),salla.api.product.previousQuery=null,salla.api.errorPromise(r)}return salla.api.product.previousQuery=e,this.request("search",a,"get").then((function(t){return salla.product.event.searchResults(t,e),t})).catch((function(t){throw salla.product.event.searchFailed(t,e),t}))},a.offers=function(e){var t;if(!(e=salla.form.getPossibleValue((null==(t=e)?void 0:t.data)|e,["product_id","id"]))){var a='There is no "product_id"!';return salla.product.event.fetchOffersFailed(a),salla.api.errorPromise(a)}return this.request(["offers",e]).then((function(t){return salla.product.event.offersFetched(t,e),t})).catch((function(t){throw salla.product.event.fetchOffersFailed(t,e),t}))},a.getSizeGuides=function(e){return this.request("products/"+e+"/size-guides",null,"get").then((function(t){return salla.product.event.sizeGuideFetched(t,e),t})).catch((function(t){throw salla.product.event.sizeGuideFetchFailed(t,e),t}))},a.getGiftProductDetails=function(e){return this.request(["giftProductDetails",e]).then((function(t){return salla.product.event.giftFetched(t,e),t})).catch((function(t){throw salla.product.event.giftFetchFailed(t,e),t}))},a.getDetails=function(e,t){if(void 0===t&&(t=[]),!Array.isArray(t)){var a="withItems should be array.";return salla.product.event.detailFetchFailed(a),salla.api.errorPromise(a)}if(!e){var n="productId is not passed.";return salla.product.event.detailFetchFailed(n),salla.api.errorPromise(n)}return this.request(["details",e],{params:{with:t}}).then((function(t){return salla.product.event.detailFetched(t,e),t})).catch((function(t){throw salla.product.event.availabilitySubscribeFailed(t,e),t}))},a.addProductGiftToCart=function(e,t,a){return void 0===a&&(a=false),this.request(["productGiftToCart",e],t).then((function(t){return salla.product.event.addGiftToCartSucceeded(t,e),a&&(window.location.href=t.redirect),t})).catch((function(t){throw salla.product.event.addGiftToCartFailed(t,e),t}))},a.uploadGiftImage=function(e){return this.request("giftImage",e).then((function(e){return salla.product.event.giftImageUploadSucceeded(e),e})).catch((function(e){throw salla.product.event.giftImageUploadFailed(e),e}))},a.fetch=function(e){if(!e.source){var t="Source cannot be empty. Please provide one.";return salla.product.event.productListFetchFailed(t),salla.api.errorPromise(t)}var a=!e.source_value,n="string"==typeof e.source_value&&"[]"===e.source_value,r=Array.isArray(e.source_value)&&!e.source_value.length;if((a||n||r)&&!["offers","latest","sales","wishlist","top-rated","reorder"].includes(e.source)){var i="Source value cannot be empty. Please provide one.";return salla.product.event.productListFetchFailed(i),salla.api.errorPromise(i)}if(["categories","brands","tags","selected"].includes(e.source)&&!Array.isArray(e.source_value)){var o="SourceValue type error. Expected an array.";return salla.product.event.productListFetchFailed(o),salla.api.errorPromise(o)}if("search"===e.source&&"string"!=typeof e.source_value){var s="SourceValue type error. Expected a string.";return salla.product.event.productListFetchFailed(s),salla.api.errorPromise(s)}if("related"===e.source&&isNaN(e.source_value)){var l="SourceValue type error. Expected a number.";return salla.product.event.productListFetchFailed(l),salla.api.errorPromise(l)}return this.request(this.endpoints.fetch,{params:e},"get").then((async function(e){return salla.product.event.productListFetchSucceeded(e),e})).catch((function(e){throw salla.product.event.productListFetchFailed(e),e}))},a.fetchOptions=function(e,t){if(void 0===t&&(t={}),!e||0===e.length){var a="At least one product ID is required. Please provide a valid list of product IDs.";return salla.product.event.productOptionsNotFetched(a),salla.api.errorPromise(a)}var n=t.with,r=void 0===n?[]:n,i={selected:e};return r.length>0&&(i.with=r),this.request(this.endpoints.fetchOptions,{params:i},"get").then((function(e){return salla.product.event.productOptionsFetched(e),e})).catch((function(e){throw salla.product.event.productOptionsNotFetched(e),e}))},t}(G),J=function(e){function t(){var t;return (t=e.call(this)||this).namespace="profile",t.endpoints={info:"auth/user",update:"profile/update",updateContacts:"profile/contacts/update",updateCustomFields:"profile/fields",updateSettings:"profile/settings",verify:"profile/verify",delete:"profile"},t.endpointsMethods={delete:"delete"},t.after_init(),t}g(t,e);var a=t.prototype;return a.syncUserData=function(e){var t={id:e.id,type:"user",email:e.email,mobile:e.phone.code+e.phone.number,country_code:e.phone.country,language_code:e.language,currency_code:e.currency,notifications:e.notifications,pending_orders:e.pending_orders,avatar:e.avatar,first_name:e.first_name,last_name:e.last_name,is_hidden_name:e.is_hidden_name,is_notifiable:e.is_notifiable,can_comment:salla.config.get("user.can_comment"),fetched_at:Date.now()};salla.config.set("user",t),salla.storage.set("user",t);},a.info=function(){var e=this;return this.request("info",null,"get").then((function(t){return e.syncUserData(t.data),salla.profile.event.infoFetched(t),t})).catch((function(e){throw salla.profile.event.infoNotFetched(e),e}))},a.update=function(e){var t=this;if(Salla.config.get("store.features",[]).includes("sso-login")){var a="SSO login is enabled. You cannot update your profile.";return Salla.error(a),Promise.reject(new Error(a))}return this.request("update",e).then((function(e){return t.syncUserData(e.data),salla.profile.event.updated(e),e})).catch((function(e){throw salla.event.profile.updateFailed(e),e}))},a.updateCustomFields=function(e){var t=this;if(Salla.config.get("store.features",[]).includes("sso-login")){var a="SSO login is enabled. You cannot update your profile.";return Salla.error(a),Promise.reject(new Error(a))}return this.request("updateCustomFields",e).then((function(e){return t.syncUserData(e.data),salla.profile.event.updated(e),e})).catch((function(e){throw salla.event.profile.updateFailed(e),e}))},a.updateContacts=function(e){return this.request("updateContacts",e).then((function(e){return salla.profile.event.verificationCodeSent(e),e})).catch((function(e){throw salla.event.profile.updateContactsFailed(e),e}))},a.verify=function(e){return this.request("verify",e).then((function(e){return salla.profile.event.verified(e),e})).catch((function(e){throw salla.event.profile.unverified(e),e}))},a.updateSettings=function(e){return this.request("updateSettings",e).then((function(e){return salla.event.profile.settingsUpdated(e),e})).catch((function(e){throw salla.event.profile.updateSettingsFailed(e),e}))},a.delete=function(){return this.request("delete").then((function(e){return salla.storage.clearAll(),salla.cookie.clearAll(),salla.auth.api.appendIframeAndLogout().then((function(){salla.event.profile.deleted(e),window.location.href=salla.url.get("logout");})),e})).catch((function(e){throw salla.event.profile.notDeleted(e),e}))},t}(G),X=function(e){function t(){var t;return (t=e.call(this)||this).namespace="comment",t.endpoints={addComment:"{type}/{id}/comments",comments:"/comments"},t.after_init(),t}g(t,e);var a=t.prototype;return a.add=function(e){var t;if(null!=(t=e)&&t.data&&(e=e.data),"string"==typeof(e=this.getCommentPayload(e,true)))return salla.event.comment.additionFailed(e),salla.api.errorPromise(e);if(!e.comment){var a="can't find comment content!";return salla.event.comment.additionFailed(a),salla.api.errorPromise(a)}return this.request(["addComment","blog"==e.type?"blogs":e.type,e.id],{comment:e.comment}).then((function(t){return salla.event.comment.added(t,e.id),t})).catch((function(t){throw salla.event.comment.additionFailed(t,e.id),t}))},a.getCommentPayload=function(e,t){ void 0===t&&(t=false);var a={};if(["id","type","comment","per_page","page","sort"].forEach((function(t){var n=salla.form.getPossibleValue(e,[t]);n&&(a[t]=n);})),!t){var n=e.ids;if(n&&(a.ids=Array.isArray(n)?n:[n]),!a.ids||!a.ids.length)return "Failed to get ids!"}return a.type&&["products","pages","product","page","blogs","blog"].includes(a.type)?(a.type+=["product","page"].includes(a.type)?"s":"",a):"Failed to get type one of:(products, product, page, pages, blog, blogs)!"},a.fetchComments=function(e){if("string"==typeof(e=this.getCommentPayload(e)))return salla.event.comment.fetchFailed(e),salla.api.errorPromise(e);var t={per_page:e.per_page||5,page:e.page||1,type:e.type,ids:e.ids};return e.sort&&(t.sort=e.sort),this.request(["comments"],{params:t},"get").then((function(t){return salla.event.comment.fetched(t,e),t})).catch((function(t){throw salla.event.comment.fetchFailed(t,e),t}))},a.getComments=function(e,t,a,n,r){ void 0===a&&(a=1),void 0===n&&(n=5);var i=Array.isArray(t)?t:[t];return this.fetchComments({ids:i,type:e+"s",page:a,per_page:n,sort:r})},t}(G),Z=function(e){function t(){var t;return (t=e.call(this)||this).namespace="currency",t.endpoints={change:"/",list:"currencies"},t.endpointsMethods={change:"get",list:"get"},t.webEndpoints=["change"],t.after_init(),t}g(t,e);var a=t.prototype;return a.change=function(e){if(!(e=salla.form.getPossibleValue(e.data||e,["currency","code"]))){var t="Can't find currency code!";return salla.currency.event.failed(t),salla.api.errorPromise(t)}return this.request("change",{params:{change_currency:"",currency:e}}).then((function(t){return salla.cookie.set("fresh_summary",1),salla.storage.set("cart",""),salla.currency.event.changed(t,e),t})).catch((function(t){throw salla.currency.event.failed(t,e),t}))},a.list=function(){return this.request("list").then((function(e){return salla.currency.event.fetched(e),e})).catch((function(e){throw salla.currency.event.failedToFetch(e),e}))},t}(G),$=function(e){function t(){var t;return (t=e.call(this)||this).namespace="document",t}return g(t,e),t.prototype.reload=function(){window.location.reload();},t}(G),Y=function(e){function t(){var t;return (t=e.call(this)||this).namespace="rating",t.endpoints={store:"rating/store",products:"rating/products",shipping:"rating/shipping",order:"rating/{order_id}"},t.endpointsMethods={order:"get"},t.after_init(),t}g(t,e);var a=t.prototype;return a.order=function(e){var t="object"==typeof e?e:{},a=salla.form.getPossibleValue((null==e?void 0:e.data)||e,["order_id","id"]);if(!a){var n='There is no "order_id"!';return salla.event.rating.orderNotFetched(n),salla.api.errorPromise(n)}return this.request(["order",a],t).then((function(e){return salla.event.rating.orderFetched(e,a),e})).catch((function(e){throw salla.event.rating.orderNotFetched(e,a),e}))},a.store=function(e){var t;if(!(e=(null==(t=e)?void 0:t.data)||e)){var a='There is no "data"!';return salla.event.rating.storeFailed(a),salla.api.errorPromise(a)}return this.request("store",e).then((function(t){return salla.event.rating.storeRated(t,e),t})).catch((function(t){throw salla.event.rating.storeFailed(t,e),t}))},a.products=function(e){var t;if(!(e=(null==(t=e)?void 0:t.data)||e)){var a='There is no "data"!';return salla.event.rating.productsFailed(a),salla.api.errorPromise(a)}return this.request("products",e).then((function(t){return salla.event.rating.productsRated(t,e),t})).catch((function(t){throw salla.event.rating.productsFailed(t,e),t}))},a.shipping=function(e){var t;if(!(e=(null==(t=e)?void 0:t.data)||e)){var a='There is no "data"!';return salla.event.rating.shippingFailed(a),salla.api.errorPromise(a)}return this.request("shipping",e).then((function(t){return salla.event.rating.shippingRated(t,e),t})).catch((function(t){throw salla.event.rating.shippingFailed(t,e),t}))},t}(G),ee=function(e){function t(){var t;return (t=e.call(this)||this).namespace="wishlist",t.endpoints={add:"products/favorites/{id}",remove:"products/favorites/{id}"},t.endpointsMethods={remove:"delete"},Salla.onReady((function(){var e;"customer.wishlist"===Salla.config.get("page.slug")&&(null!=(e=Salla.storage.getWithTTL("s-utms"))&&e["s-utm-source"]||t.injectSourceIntoRequest());})),t}g(t,e);var a=t.prototype;return a.injectSourceIntoRequest=function(){Salla.api.axios.interceptors.request.use((function(e){return e.headers=f({},e.headers,{"s-utm-source":"wishlist"}),e}),(function(e){return Promise.reject(e)}));},a.toggle=function(e){return salla.storage.get("salla::wishlist",[]).includes(e)?this.remove(e):this.add(e)},a.add=function(e){var t,a,n=this;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(a=salla.lang.get("common.messages.must_login")),salla.error(a),salla.api.errorPromise(a)):(e=salla.form.getPossibleValue((null==(t=e)?void 0:t.data)||e,["product_id","id"]))?this.request(["add",e]).then((function(t){return n.updateWishlistStorage(e),salla.wishlist.event.added(t,e),t})).catch((function(t){throw salla.wishlist.event.additionFailed(t,e),t})):(salla.wishlist.event.additionFailed(a="Failed to get product id!"),salla.api.errorPromise(a))},a.remove=function(e){var t,a,n=this;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(a=salla.lang.get("common.messages.must_login")),salla.error(a),salla.api.errorPromise(a)):(e=salla.form.getPossibleValue((null==(t=e)?void 0:t.data)||e,["product_id","id"]))?this.request(["remove",e]).then((function(t){return n.updateWishlistStorage(e,false),salla.wishlist.event.removed(t,e),t})).catch((function(t){throw salla.wishlist.event.removingFailed(t,e),t})):(salla.wishlist.event.removingFailed(a="Failed to get id!"),salla.api.errorPromise(a))},a.updateWishlistStorage=function(e,t){ void 0===t&&(t=true);var a=salla.storage.get("salla::wishlist",[]);t?a.push(e):a.splice(a.indexOf(e),1),salla.storage.set("salla::wishlist",a);},t}(G),te=function(e){function t(){var t;return (t=e.call(this)||this).namespace="scopes",t.endpoints={get:"scopes",change:"scopes",getProductAvailability:"scopes/availability?product_id={id}"},t.after_init(),t}g(t,e);var a=t.prototype;return a.get=function(){return this.request("scopes",null,"get").then((function(e){return salla.scope.event.fetched(e),e})).catch((function(e){throw salla.scope.event.notFetched(e),e}))},a.change=function(e){return this.request("scopes",e).then((function(e){return salla.scope.event.changeSucceeded(e),e})).catch((function(e){throw salla.scope.event.changeFailed(e),e}))},a.getProductAvailability=function(e){return void 0===e&&(e=null),this.request("scopes/availability?product_id="+e,null,"get").then((function(t){return salla.scope.event.productAvailabilityFetched(t,e),t})).catch((function(e){throw salla.scope.event.productAvailabilityNotFetched(e),e}))},t}(G),ae=function(e){function t(){var t;return (t=e.call(this)||this).namespace="booking",t.endpoints={add:"cart/booking/product/{id}"},t.endpointsMethods={add:"get"},t}return g(t,e),t.prototype.add=async function(e,t){if(void 0===t&&(t=true),!e){var a="Please provide product id.";return salla.booking.event.additionFailed(a),salla.api.errorPromise(a)}return this.request(["add",e]).then((function(e){return salla.booking.event.added(e),t&&"booking"===e.data.redirect.to&&(window.location.href=e.data.redirect.url),e})).catch((function(e){throw salla.booking.event.additionFailed(e),e}))},t}(G),ne=function(e){function t(){var t;return (t=e.call(this)||this).namespace="landing",t.endpoints={getDetails:"landing/{landing_page_id}",createCartFromPage:"landing/{landing_page_id}",breadcrumbs:"breadcrumbs"},t.endpointsMethods={getDetails:"get",breadcrumbs:"get"},t.after_init(),t}g(t,e);var a=t.prototype;return a.getDetails=function(e){if(!e){var t="page landing id not passed";return salla.event.landing.getDetailsFailed(t),salla.api.errorPromise(t)}return this.request(["getDetails",e]).then((function(t){return salla.event.landing.detailsFetched(t,e),t})).catch((function(t){throw salla.event.landing.getDetailsFailed(t,e),t}))},a.createCartFromPage=function(e){if(!e){var t="page landing id not passed";return salla.event.landing.orderCreationFailed(t),salla.api.errorPromise(t)}return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("landing::createCartFromPage",e),salla.event.dispatch("login::open"),salla.api.successPromise("")):this.request(["createCartFromPage",e]).then((function(t){return salla.event.landing.orderCreated(t,e).then((function(){return location.href=t.data.url})),t})).catch((function(t){throw salla.event.landing.orderCreationFailed(t,e),t}))},a.fetchBreadcrumbs=function(e){if(!e.page){var t="The 'page' parameter is required for the Breadcrumb API. Please provide a valid 'page' parameter.";return salla.event.landing.breadcrumbFetchFailed(t),salla.api.errorPromise(t)}if("product.single"===e.page&&!e.id&&!e.parent_id){var a="The 'id' and 'parent_id' parameters are required when the 'page' parameter is set to 'product.single'. Please provide valid values for both parameters.";return salla.event.landing.breadcrumbFetchFailed(a),salla.api.errorPromise(a)}if(["product.index","customer.orders.single","product.index.tag","page-single","landing-page","brands.single","blog.single","blog.index.author","blog.index.category","blog.index.tag"].includes(e.page)&&!e.id){var n="The 'id' parameter is required when the 'page' parameter is set to "+e.page+". Please provide valid value for the 'ID' parameter.";return salla.event.landing.breadcrumbFetchFailed(n),salla.api.errorPromise(n)}return this.request("breadcrumbs",{params:e}).then((function(e){return salla.event.landing.breadcrumbFetched(e),e})).catch((function(e){throw salla.event.landing.breadcrumbFetchFailed(e),e}))},t}(G),re=function(e){function t(){var t;return (t=e.call(this)||this).namespace="notifications",t.endpoints={fetch:"notifications"},t.endpointsMethods={fetch:"get"},t.after_init(),t}return g(t,e),t.prototype.fetch=function(e){return this.request(["fetch"],{params:e}).then((function(e){return salla.event.notifications.fetched(e),e})).catch((function(e){throw salla.event.notifications.fetchFailed(e),e}))},t}(G),ie=function(){function e(){var e,t=this;this.inIframe=salla.helpers.isIframe(),salla.event.on("twilight::before.ready",(async function(e){return await t.initiateRequest(e)})),salla.event.on("profile::info.fetched",(function(e){return t.setCurrencyAndLanguage(e)})),salla.event.on("auth::token.fetched",(function(e){salla.storage.set("token",e),t.inIframe&&salla.log("token fetched iframe"),t.inIframe&&salla.cookie.set("s-token",e,60),t.setToken(e);})),salla.event.on("auth::token.invalid",(function(){salla.storage.remove("user"),salla.storage.remove("token");})),this.notifier_handler_disabled=false,this.axios=axios.create({baseURL:Salla.config.get("store.api",Salla.config.get("store.url")),headers:{common:{"X-Requested-With":"XMLHttpRequest","S-SOURCE":"twilight","S-APP-VERSION":(null==(e=Salla)||null==(e=e.versions)?void 0:e.twilight)||"2.0.0","S-APP-OS":"browser","cache-control":"no-cache"}}}),this.axios.interceptors.request.use((function(e){"preview"===Salla.config.get("theme.mode")&&(e.url=Salla.url.addParamToUrl("use_username_url",1,e.url));try{var t=Salla.config.get("swoole",[]),a=new RegExp(t.join("|"),"i");t.length>0&&a.test(e.url)&&(e.headers["s-store-api-version"]="swoole");}catch(e){console.log(e);}return e}),(function(e){return Promise.reject(e)}));}var t=e.prototype;return t.getHeaders=function(){var e=f({},this.axios.defaults.headers.common);return delete e["Content-Type"],e},t.getHeader=function(e){var t;return null==(t=Object.entries(this.getHeaders()).filter((function(t){return t[0].toLowerCase()===e.toLowerCase()}))[0])?void 0:t[1]},t.setHeaders=function(e){var t=this;return Object.entries(e).forEach((function(e){return t.setHeader(e[0],e[1])})),this},t.setHeader=function(e,t){return salla.infiniteScroll.fetchOptions.headers[e]=this.axios.defaults.headers.common[e]=t,this},t.withoutNotifier=async function(e){var t=this;return this.notifier_handler_disabled=true,await e().finally((function(){t.notifier_handler_disabled=false;}))},t.initiateRequest=async function(e){var t,a,n;this.axios.defaults.baseURL=Salla.config.get("store.api",Salla.config.get("store.url")),this.setHeaders(f({"Store-Identifier":Salla.config.get("store.id"),currency:(null==(t=e.user)?void 0:t.currency_code)||"SAR","accept-language":salla.lang.getLocale(),"s-user-id":null==(a=e.user)?void 0:a.id,"s-country":null==(n=e.user)?void 0:n.country_code},e.headers||{}));var r=Salla.config.get("store.scope",Salla.storage.get("scope")),i=new URLSearchParams(window.location.search).get("scope");i&&r&&!Salla.url.is_page("cart")&&(r.id=i,Salla.storage.set("scope",r),Salla.cart.reset()),r&&this.setHeaders({"s-scope-type":r.type,"s-scope-id":r.id});var o=Salla.storage.getWithTTL("s-utms");if(o){var s={};Object.entries(o).forEach((function(e){var t=e[0],a=e[1];s[t]="string"==typeof a&&/[^\x00-\x7F]/.test(a)?encodeURIComponent(a):a;})),this.setHeaders(s);}await this.injectTokenToTheRequests(e),salla.storage.get("affiliate_code")&&this.setHeader("s-affiliate-code",salla.storage.get("affiliate_code"));},t.injectTokenToTheRequests=async function(e){var t,a,n,i=this,o=this.getToken(),s="guest"===(null==(t=e.user)?void 0:t.type),l=parseInt((null==(a=e.user)?void 0:a.id)||0),c=parseInt(salla.storage.get("user.id")||0),u=salla.auth.api.isSessionless(),d=function(e){i.setToken(e),salla.event.emit("api::initiated");},p=async function(){s||u||!l?salla.auth.event.tokenInvalid():(salla.log("Api:: case 1 => current is is guest & web session available"),await salla.auth.api.refresh().then((async function(){await salla.profile.info();})).catch((function(){return salla.auth.event.tokenInvalid()})));};if(!o)return salla.log("Api:: case 1 => current is is guest"),void await p();try{n=jwtDecode(o);}catch(e){return Salla.logger.warn("Failed to decode JWT token",e),void Salla.auth.event.tokenInvalid()}return Date.now()/1e3>n.exp?(salla.log("Api:: case 2 => current user is logged-in and there is a token, but it's expired"),void await p()):(u?parseInt(n.sub)!==c:!c||!l||c!==l||parseInt(n.sub)!==l)?(salla.log("Api:: case 3 => there is a token and user in session/local missing or mismatch"),salla.log("sub:"+n.sub+" userIdInWeb:"+l+" userIdInStorage:"+c+", isSessionless:"+u,n.sub,l,c),this.setHeader("Authorization","Bearer "+o),void await salla.profile.info().then((async function(e){!i.inIframe&&!u&&await salla.auth.api.request("auth/jwt",{callerName:"salla.auth.request.injectTokenToTheRequests"}),d(o);})).catch((function(){salla.log("Api:: case 3 => failed get fresh profile"),i.setHeader("Authorization",null),salla.auth.event.tokenInvalid();}))):(salla.log("Api:: case 4 => current user is logged-in and there is a token, and it's not expired"),void d(o))},t.setToken=function(e){return this.setHeader("Authorization","Bearer "+e),salla.event.emit("api::token.injected",e),this.token=e,this},t.cleanupTokenFromUrl=function(){try{var e=new URL(window.location.href);if(!e.searchParams.has("token"))return;e.searchParams.delete("token"),window.history.replaceState({},document.title,e.toString());}catch(e){Salla.logger.warn("Failed to cleanup token from URL",e);}},t.setCurrencyAndLanguage=function(e){return this.setHeaders({currency:e.data.currency,"accept-language":e.data.language})},t.request=function(e,t,a,n){var r=this;void 0===t&&(t=void 0),void 0===a&&(a="get"),void 0===n&&(n={});var i={endPoint:e,payload:t,method:a,options:n},o="undefined"!=typeof event?event.currentTarget:null,s=false;return "SALLA-BUTTON"===(null==o?void 0:o.tagName)&&(s=true),s&&(null==o||o.load()),this.axios[i.method](i.endPoint,i.payload,i.options).then((function(e){return s&&(null==o||o.stop()),e.data&&e.request&&(e=e.data),r.handleAfterResponseActions(e),e})).catch((function(e){throw s&&(null==o||o.stop()),salla.event.document.requestFailed(i,e),r.handleErrorResponse(e),e}))},t.handleAfterResponseActions=function(e){if(e){var t=e.data,a=e.googleTags,n=void 0===a?null:a,r=t&&t.googleTags?t.googleTags:n;try{dataLayer&&r&&dataLayer.push(r);}catch(e){salla.logger.error(e.message);}this.fireEventsForResponse(e),this.showAlert(e);}},t.fireEventsForResponse=function(e){var t,a,n=(null==e?void 0:e.events)||(null==(t=e.data)?void 0:t.events)||(null==(a=e.error)?void 0:a.events);"string"==typeof n&&(n=JSON.parse(n)),n&&Object.keys(n).forEach((function(e){return salla.event.dispatch(e,n[e])}));},t.handleErrorResponse=function(e){if(e.response&&e.response.data)return e.response.data.error&&e.response.data.error.fields&&!this.notifier_handler_disabled?this.handleInvalidFields(e):this.handleAfterResponseActions(e.response.data)},t.showAlert=function(e){var t,a;if(e&&!this.notifier_handler_disabled)return e.case&&e.msg?salla.notify.fire(e.msg,e.case,e):e.hasOwnProperty("success")&&null!=(t=e.data)&&t.message?salla.notify.fire(null==(a=e.data)?void 0:a.message,e.success?salla.notify.types.success:salla.notify.types.error,e):e.error&&e.error.message&&"FORBIDDEN"!==e.error.message?salla.error(e.error.message,e):void 0},t.handleInvalidFields=function(e){var t=e.response.data.error.fields,a=[];Object.keys(t).forEach((function(e){var n=t[e];Array.isArray(n)?n.forEach((function(e){return a.push(e)})):a.push(n);}));var n=(a.length>1?"* ":"")+a.join("\n* ");salla.error(n,e);},t.isFastRequestsAllowed=function(){return Salla.config.get("fastRequests")},t.promise=function(e,t){return void 0===t&&(t=true),new Promise((function(a,n){return t?a(e):n(e)}))},t.errorPromise=function(e){return this.promise(e,false)},t.successPromise=function(e){return this.promise(e,true)},t.getToken=function(){if(Salla.storage.get("token"))return Salla.storage.get("token");try{var e,t=null==(e=new URLSearchParams(window.location.search))?void 0:e.get("token");if(!t)return;if(3!==t.split(".").length)return;return this.cleanupTokenFromUrl(),t}catch(e){Salla.logger.warn("Failed to extract or validate token from URL",e);}},e}(),oe=function(e){function t(){var t;return (t=e.call(this)||this).namespace="component",t.endpoints={getMenus:"menus/{headOrFoot}?store_id={store}&lang={lang}",reviews:"reviews"},t.endpointsMethods={getMenus:"get",reviews:"get"},t}g(t,e);var a=t.prototype;return a.getMenus=async function(e){return void 0===e&&(e="header"),this.request(["getMenus",e,salla.config.get("store.id"),salla.lang.getLocale()]).then((function(e){return salla.event.component.menuFetched(e),e})).catch((function(e){throw salla.event.component.menuFetchFailed(e),e}))},a.getReviews=async function(e){var t=e.per_page,a=void 0===t?5:t,n=e.type,r=void 0===n?"all":n,i=e.items,o=void 0===i?void 0:i;if(!r){var s="Review type cannot be empty. Please provide one.";return salla.event.component.reviewsFetchFailed(s),salla.api.errorPromise(s)}var l=!o||"string"==typeof o&&"[]"===o||Array.isArray(o)&&!o.length;if(!new Set(["all","store","categories","products","json"]).has(r)){var c="Invalid review type. Please provide a valid type.";return salla.event.component.reviewsFetchFailed(c),salla.api.errorPromise(c)}if("all"!==r&&"store"!==r&&l){var u="Items cannot be empty. Please provide one.";return salla.event.component.reviewsFetchFailed(u),salla.api.errorPromise(u)}if(new Set(["products","categories"]).has(r)&&!Array.isArray(o)){var d="Items value must be an array of "+r+" id for review type of "+r+".";return salla.event.component.reviewsFetchFailed(d),salla.api.errorPromise(d)}return this.request(["reviews"],{params:{per_page:a,type:r,items:o}},"get").then((function(e){return salla.event.component.reviewsFetched(e),e})).catch((function(e){throw salla.event.component.reviewsFetchFailed(e),e}))},t}(G),se=function(e){function t(){var t;return (t=e.call(this)||this).namespace="booking",t.endpoints={fetch:"advertisements"},t.endpointsMethods={fetch:"get"},t}return g(t,e),t.prototype.fetch=async function(e){ void 0===e&&(e=null);var t=e?{page:e}:{};return this.request(["fetch"],{params:t}).then((function(e){return salla.event.advertisement.fetched(e),e})).catch((function(e){throw salla.event.advertisement.fetchFailed(e),e}))},t}(G),le=function(e){function t(){var t;return (t=e.call(this)||this).namespace="navigation",t.endpoints={breadcrumbs:"breadcrumbs"},t.endpointsMethods={breadcrumbs:"get"},t.after_init(),t}return g(t,e),t.prototype.fetchBreadcrumbs=function(e){if(!e.page){var t="The 'page' parameter is required for the Breadcrumb API. Please provide a valid 'page' parameter.";return salla.event.navigation.breadcrumbFetchFailed(t),salla.api.errorPromise(t)}if(["product.single","product.index","customer.orders.single","product.index.tag","page-single","landing-page","brands.single","blog.single","blog.index.author","blog.index.category","blog.index.tag"].includes(e.page)&&!e.id){var a="The 'id' parameter is required when the 'page' parameter is set to "+e.page+". Please provide valid value for the 'ID' parameter.";return salla.event.navigation.breadcrumbFetchFailed(a),salla.api.errorPromise(a)}return this.request("breadcrumbs",{params:e}).then((function(e){return salla.event.navigation.breadcrumbFetched(e),e})).catch((function(e){throw salla.event.navigation.breadcrumbFetchFailed(e),e}))},t}(G),ce=function(e){function t(){var t;return (t=e.call(this)||this).namespace="metadata",t.endpoints={fetchValues:"https://api.salla.dev/store/v1/metadata/values"},t.endpointsMethods={fetchValues:"get"},t}return g(t,e),t.prototype.fetchValues=async function(e,t){if(!e||!t){var a="Please provide entity type and entity ids.";return salla.metadata.event.valueNotFetch(a),salla.api.errorPromise(a)}var n={type:e,entities:Array.isArray(t)?t:[t]};return this.request(this.endpoints.fetchValues,{params:n},"get").then((function(e){return salla.metadata.event.valueFetched(e),e})).catch((function(e){throw salla.metadata.event.valueNotFetch(e),e}))},t}(G),ue=function(e){function t(){var t;return (t=e.call(this)||this).auth=new B,t.cart=new z,t.loyalty=new W,t.order=new Q,t.rating=new Y,t.product=new K,t.profile=new J,t.comment=new X,t.currency=new Z,t.document=new $,t.wishlist=new ee,t.scope=new te,t.booking=new ae,t.landing=new ne,t.notifications=new re,t.component=new oe,t.advertisement=new se,t.navigation=new le,t.metadata=new ce,t}return g(t,e),t.prototype.beaconRequest=function(e,t){var a,n,r,i;if(void 0===t&&(t={}),null==(a=window.navigator)||!a.sendBeacon)return fetch(e,t);var o="string"==typeof(null==(n=t)?void 0:n.body)?null==(r=t)?void 0:r.body:JSON.stringify((null==(i=t)?void 0:i.body)||{}),s=new Blob([o],{type:"application/json"});return Salla.log("Beacon payload size: "+s.size+" bytes (~"+(s.size/1024).toFixed(2)+" KB)"),navigator.sendBeacon(e,s),Promise.resolve(new Response('{"status":"sent_via_beacon"}',{status:200,headers:{"Content-Type":"application/json"}}))},t}(ie),de=function(){function t(t){var a,n;if("ready"!==N$3.status)if(t){var r;if(N$3.config.merge(t),!["salla.sa","salla.group"].includes(location.hostname)||null!=(a=N$3.config.get("store.url"))&&a.includes(location.hostname)||!N$3.config.get("store.username")||N$3.config.set("store.url",window.location.origin+"/"+N$3.config.get("store.username")),(null==t?void 0:t.events)&&N$3.event.dispatchEvents(null==t?void 0:t.events),t._token&&salla.api.setHeader("X-CSRF-TOKEN",t._token),window.self===window.top&&(this.injectMaintenanceAlert(),this.injectThemePreviewAlert()),this.injectTemplateStoreAlert(),this.injectAppInstallAlert(),this.applyContentCopyright(),this.injectEditAlert(),null!=t&&null!=(n=t.user)&&n.language_code)salla.lang.setLocale(null==t||null==(r=t.user)?void 0:r.language_code);salla.lang.loadStoreTranslations(),this.setSallaReady(t),this.afterInit();}else this.setSallaReady(t);else salla.log("Trying to re-initiate Salla, while its status === 'ready'!");}var a=t.prototype;return a.afterInit=function(){N$3.url.is_page("product.single")&&N$3.config.isGuest()&&window.addEventListener("mini-checkout::before-init",(function(t){t.preventDefault(),N$3.event.emit("login::open");}));},a.applyContentCopyright=function(){if(N$3.config.get("store.settings.content_copyright")){["contextmenu","selectstart","copy"].forEach((function(e){document.addEventListener(e,(function(e){(function(e){var t;if(!e)return false;var a=null==(t=e.tagName)?void 0:t.toLowerCase();return "input"===a||"textarea"===a})(e.target)||e.preventDefault();}));})),document.addEventListener("keydown",(function(e){var t=e.key.toLowerCase();("f12"===t||e.ctrlKey&&e.shiftKey&&["i","j","c"].includes(t)||e.ctrlKey&&"u"===t)&&(e.preventDefault(),e.stopPropagation());}));var t=document.createElement("style");t.textContent="\n body {\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n }\n input, textarea {\n -webkit-touch-callout: auto;\n -webkit-user-select: auto;\n -moz-user-select: auto;\n -ms-user-select: auto;\n user-select: auto;\n }\n img {\n pointer-events: none;\n -webkit-user-drag: none;\n }\n ",document.head.appendChild(t);}},a.injectMaintenanceAlert=function(){salla.config.get("maintenance")&&(document.body.classList.add("has-maintenance-bar"),document.querySelector("salla-maintenance-alert")?salla.logger.warn("salla-maintenance-alert element Existed before!"):salla.lang.onLoaded((function(){return document.body.prepend(document.createElement("salla-maintenance-alert"))})));},a.injectTemplateStoreAlert=function(){salla.config.get("store.template")&&(document.body.classList.add("has-bottom-alert"),document.querySelector("salla-bottom-alert")?salla.logger.warn("salla-bottom-alert element Existed before!"):salla.lang.onLoaded((function(){return document.body.append(document.createElement("salla-bottom-alert"))})));},a.injectAppInstallAlert=function(){salla.config.get("store.app_install_prompt")&&salla.config.get("store.apps")&&!salla.storage.get("app_install_prompt_disabled")&&!salla.config.isMobileApp()&&(document.body.classList.add("has-app-install-alert"),document.querySelector("salla-app-install-alert")?salla.logger.warn("salla-app-install-alert element Existed before!"):salla.lang.onLoaded((function(){return document.body.append(document.createElement("salla-app-install-alert"))})));},a.injectThemePreviewAlert=function(){"preview"===salla.config.get("theme.mode")&&(document.body.classList.add("has-preview-bar"),document.querySelector("#s-theme_preview_bar")?salla.logger.warn("#s-theme_preview_bar element Existed before!"):salla.lang.onLoaded((function(){var e=document.createElement("div");e.id="s-theme_preview_bar",e.setAttribute("style","display: flex; justify-content: space-between; text-align: center; background-color: #232323; color: #fff; padding: 10px; font-size: 0.875rem; line-height: 1.25rem; position: relative;"),e.innerHTML='\n <div style="display:flex; align-items:center;">\n <img width="32" src="https://cdn.salla.network/images/logo/logo-light.svg">\n <span style="margin:0 10px;">'+salla.lang.get("blocks.header.preview_mode")+': <span style="background:rgba(255,255,255,0.25);border-radius:15px; padding:2px 15px 4px">'+salla.config.get("theme.name")+'</span></span>\n </div>\n <a href="'+salla.url.get("preview_theme/cancel/preview")+'" style="line-height:32px; width:32px;"><i class="sicon-cancel"></i></a>\n ',document.body.prepend(e);})));},a.injectEditAlert=function(){var e=salla.config.get("edit");e&&(document.querySelector("#s-edit-alert")?salla.logger.warn("#s-edit-alert element Existed before!"):salla.lang.onLoaded((function(){var t=document.createElement("div");t.id="s-edit-alert",t.innerHTML='\n <a href="'+e+'" style="display:block; background-color:'+salla.config.get("theme.color.primary","#5cd5c4")+"; color:"+salla.config.get("theme.color.reverse","#fff")+'; padding: 10px; text-align:center; font-size: 0.875rem; line-height: 1.25rem;">\n <i class="sicon-edit"></i> \n '+salla.lang.get("pages.products.quick_edit")+"\n </a>\n ",document.body.prepend(t);})));},a.handleElementAjaxRequest=function(e,t){var a=this;if(!(t instanceof HTMLFormElement||t instanceof HTMLAnchorElement))return salla.logger.warn("trying to call ajax from non Element!!"),false;e.preventDefault();var n=t.getAjaxFormData(e),r=n.method?n.method.toLowerCase():void 0;salla.api.request(n.url,n.formData,r).then((function(e){return e.data&&e.request&&(e=e.data),salla.api.handleAfterResponseActions(e),a.callAjaxEvent(n.events.success,e,n.formData),e})).catch((function(e){throw salla.api.handleErrorResponse(e),a.callAjaxEvent(n.events.fail,e,n.formData),e}));},a.callAjaxEvent=function(e,t,a){if(e){if(a instanceof FormData){var n={};Array.from(a.entries()).forEach((function(e){n[e[0]]=e[1];})),a=n;}window[e]?window[e](t,a):salla.event.dispatch(e,t,a);}},a.setSallaReady=function(t){this.storeUTMs(),N$3.event.emitAsync("twilight::before.ready",t),N$3.status="ready",N$3.event.dispatch("twilight::initiated",t),window.dispatchEvent(new CustomEvent("twilight::initiated",{detail:t}));},a.storeUTMs=function(){var e={fbclid:"facebook",gad_source:"google",ttclid:"tiktok",twclid:"twitter",scid:"snapchat",sccid:"snapchat"},t=Object.keys(e),a=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"].concat(t),n={},r={};window.location.search.replace("?","").split("&").map((function(e){return e.split("=")})).filter((function(e){var t=e[0];return a.includes(t.toLowerCase())})).forEach((function(e){var t=e[0],a=e[1],r=a||"";try{r=decodeURIComponent(a);}catch(e){console.warn("Failed to decode UTM param:",t,a,e);}n[t.toLowerCase()]=r;}));var i=t.find((function(e){return n[e]}));!n.utm_source&&i&&(n.utm_source=e[i],n.utm_campaign=n.utm_campaign||"Using the CLICKID "+i+" provided by "+n.utm_source,n.utm_term=n.utm_term||i+": "+n[i]),n.utm_source&&(Object.entries(n).filter((function(e){var a=e[0];return !t.includes(a)})).forEach((function(e){var t=e[0],a=e[1];r["s-"+t.replace("_","-")]=a;})),r["s-utm-referrer"]=document.referrer,salla.storage.setWithTTL("s-utms",r,129600),this.logUTMVisitData(r));},a.logUTMVisitData=async function(e){var t=e["s-utm-source"],a=e["s-utm-medium"],n=e["s-utm-campaign"];e&&"affiliate"===t&&a&&n&&fetch(salla.config.get("affiliate.utm_url"),{method:"POST",mode:"cors",headers:{"Content-Type":"application/json","s-utm-source":t,"s-utm-medium":a,"s-utm-campaign":n}}).then((function(e){if(e.ok){var t=new URL(window.location.href),a=window.history.state;t.searchParams.delete("utm_source"),t.searchParams.delete("utm_medium"),t.searchParams.delete("utm_campaign"),window.history.replaceState(a,"",t);}}));},t}(),pe=function(){function e(){var e=this;Salla.onReady((function(){return e.init()}));}var t=e.prototype;return t.init=function(){var e,t=this;if(salla.config.get("store.features",[]).includes("sso-login")){if(window.location.hostname.includes("salla"))return salla.log("SSO is not supported yet for stores without custom domain.");salla.auth.event.onLoggedOut((function(){return new Promise((function(e){var t=document.createElement("iframe");t.style.display="none",t.src=salla.url.get("sso/logout"),document.body.appendChild(t),t.onload=function(){document.body.removeChild(t),e();};}))})),null==(e=document.querySelector("salla-login-modal"))||e.remove(),Salla.event.removeAllListeners("login::open"),Salla.event.prependListener("login::open",(function(){return t.redirect()})),window.addEventListener("mini-checkout::before-init",(function(e){Salla.config.isUser()||(e.preventDefault(),t.redirect());}));}},t.redirect=function(){var e=window.location.pathname+window.location.search,t=window.location.origin+"/sso/login?intended_to="+encodeURIComponent(e);return console.log("Redirecting to:",t),window.location.href=t,true},e}(),he=function(){function e(e){this.item=e[0];}return e.prototype.toSegment=function(){var e,t,a,n;return {event:"Product Added",properties:{cart_id:null==(e=this.item.cart_id)?void 0:e.toString(),product_id:null==(t=this.item.id)?void 0:t.toString(),category:this.item.category,currency:null==(a=Salla.config.currency())?void 0:a.code,name:this.item.name,brand:this.item.brand,variant:null==(n=this.item.variant)?void 0:n.toString(),price:this.item.price,quantity:this.item.quantity,sku:this.item.sku,coupon:this.item.coupon,position:this.item.position,url:this.item.url,image_url:this.item.image_url}}},e.shouldSend=function(){return "customer.wishlist"!==salla.config.get("page.slug")},e}(),fe=function(){function e(e){this.product=e[0];}return e.prototype.toSegment=function(){var e;return {event:"Product Viewed",properties:{product_id:null==(e=this.product.id)?void 0:e.toString(),category:this.product.category,name:this.product.name,brand:this.product.brand,variant:this.product.variant,price:this.product.price,quantity:this.product.quantity,currency:this.product.currency,coupon:this.product.coupon,position:this.product.position,value:this.product.value,sku:this.product.sku,url:this.product.url,image_url:this.product.image_url}}},e}(),ge=function(){function e(e){this.cart=e[0];}return e.prototype.toSegment=function(){var e;return {event:"Cart Viewed",properties:{cart_id:null==(e=this.cart.cart_id)?void 0:e.toString(),products:this.cart.products.map((function(e){var t,a;return {product_id:null==(t=e.id)?void 0:t.toString(),name:e.name,price:e.price,category:e.category,sku:e.sku,position:e.position,url:e.url,image_url:e.image_url,brand:e.brand,currency:null==(a=Salla.config.currency())?void 0:a.code,variant:e.variant,coupon:e.coupon,quantity:e.quantity}}))}}},e}(),ve=function(){function e(e){var t=null==e?void 0:e.nextPage;this.listId=salla.config.get("page.slug"),Salla.config.get("page.id")&&(this.listId+="_"+salla.config.get("page.id")),this.sorts=null;try{if(t){var a=new URL(t).searchParams.get("sort");a&&(this.sorts=[{type:"sort",value:a}]);}e.source&&(this.listId=this.listId+"_"+e.source),e.sourceValue&&(this.listId=this.listId+"_"+(Array.isArray(e.sourceValue)?e.sourceValue.join("_"):e.sourceValue));}catch(e){salla.logger.error(e);}this.products=null==e?void 0:e.data;}return e.prototype.toSegment=function(){return {event:"Product List Viewed",properties:{list_id:this.listId,category:salla.config.get("page.title"),sorts:this.sorts,products:this.products.map((function(e){var t,a,n,r,i,o;return {product_id:e.id,category:null==(t=e.category)?void 0:t.name,currency:null==(a=Salla.config.currency())?void 0:a.code,name:e.name,brand:null==(n=e.brand)?void 0:n.name,variant:null==(r=e.variant)?void 0:r.toString(),coupon:null==(i=e.coupon)?void 0:i.toString(),price:e.price,quantity:Number(e.quantity),sku:e.sku,position:0,url:e.url,image_url:null==(o=e.image)?void 0:o.url}}))}}},e.shouldSend=function(e){return !((null==e?void 0:e.nextPage)||"").includes("filters")&&!["index","customer.wishlist"].includes(salla.config.get("page.slug"))},e}(),me=function(){function e(e){this.query=e;}return e.prototype.toSegment=function(){return {event:"Products Searched",properties:{query:this.query}}},e}(),ye=function(){function e(){this.user=JSON.parse(localStorage.getItem("user"));}return e.prototype.toSegment=function(){var e,t,a,n,r;return {event:"Signed In",properties:{first_name:null==(e=this.user)?void 0:e.first_name,last_name:null==(t=this.user)?void 0:t.last_name,type:null==(a=this.user)?void 0:a.type,mobile:null==(n=this.user)?void 0:n.mobile,email:null==(r=this.user)?void 0:r.email}}},e.shouldSend=function(){return "user"===Salla.config.get("user.type")?!Salla.analytics.history.find((function(e){return "Signed In"===e.eventName})):(Salla.profile.event.onInfoFetched((function(){return Salla.event.emit("Signed In")})),false)},e}(),we=function(e){function t(){return e.apply(this,arguments)||this}return g(t,e),t.prototype.toSegment=function(){var t=e.prototype.toSegment.call(this);return {event:"Signed Up",properties:null==t?void 0:t.properties}},t.shouldSend=function(){return "user"===Salla.config.get("user.type")||(Salla.profile.event.onInfoFetched((function(){return Salla.event.emit("Signed Up")})),false)},t}(ye),be=function(){function e(){}return e.prototype.toSegment=function(){return {event:"Signed Out",properties:{}}},e}(),Se=function(){function e(e){this.item=e[0];}return e.prototype.toSegment=function(){var e,t,a,n,r,i,o,s,l,c,u,d,p,h;return {event:"Product Removed",properties:{cart_id:null==(e=this.item)||null==(e=e.cart_id)?void 0:e.toString(),product_id:null==(t=this.item)||null==(t=t.id)?void 0:t.toString(),category:null==(a=this.item)?void 0:a.category,currency:null==(n=Salla.config.currency())?void 0:n.code,name:null==(r=this.item)?void 0:r.name,brand:null==(i=this.item)?void 0:i.brand,variant:null==(o=this.item)?void 0:o.variant,price:null==(s=this.item)?void 0:s.price,quantity:null==(l=this.item)?void 0:l.quantity,sku:null==(c=this.item)?void 0:c.sku,coupon:null==(u=this.item)?void 0:u.coupon,position:null==(d=this.item)?void 0:d.position,url:null==(p=this.item)?void 0:p.url,image_url:null==(h=this.item)?void 0:h.image_url}}},e}(),_e=function(){function e(e){this.product=e.data.product;}return e.prototype.toSegment=function(){var e,t,a,n;return {event:"Product Added to Wishlist",properties:(n={wishlist_id:salla.config.get("store.id")+"_"+salla.config.get("user.id"),wishlist_name:salla.config.get("store.name"),product_id:null==(e=this.product.id)?void 0:e.toString(),name:this.product.name,brand:this.product.brand,variant:this.product.variant,price:this.product.price,quantity:Math.max(1,Number(this.product.quantity)),sku:this.product.sku||null,position:Number(this.product.position||0),url:this.product.url,image_url:(null==(t=this.product)?void 0:t.image)||null,category:this.product.category,currency:null==(a=Salla.config.currency())?void 0:a.code},n.brand=this.product.brand,n)}},e}(),Fe=function(){function e(e){this.product=e.data.product;}return e.prototype.toSegment=function(){var e,t,a,n;return {event:"Product Removed from Wishlist",properties:(n={wishlist_id:salla.config.get("store.id")+"_"+salla.config.get("user.id"),wishlist_name:salla.config.get("store.name"),product_id:null==(e=this.product.id)?void 0:e.toString(),name:this.product.name,brand:this.product.brand,variant:this.product.variant,price:this.product.price,quantity:Math.max(1,Number(this.product.quantity)),sku:this.product.sku||null,coupon:this.product.coupon||null,position:Number(this.product.position||0),currency:null==(t=Salla.config.currency())?void 0:t.code,url:this.product.url,image_url:(null==(a=this.product)?void 0:a.image)||null,category:this.product.category},n.brand=this.product.brand,n)}},e}(),ke=function(){function e(e){this.details=e[0];}return e.prototype.toSegment=function(){return {event:"Order Completed",properties:this.details}},e}(),Ce=function(){function e(e){this.item=e[0];}return e.prototype.toSegment=function(){var e,t;return {event:"Wishlist Product Added to Cart",properties:{wishlist_id:salla.config.get("store.id")+"_"+salla.config.get("user.id"),wishlist_name:salla.config.get("store.name"),cart_id:null==(e=this.item.cart_id)?void 0:e.toString(),product_id:null==(t=this.item.id)?void 0:t.toString(),category:this.item.category,name:this.item.name,brand:this.item.brand,variant:this.item.variant,price:this.item.price,quantity:this.item.quantity,sku:this.item.sku,coupon:this.item.coupon,position:this.item.position,url:this.item.url,image_url:this.item.image_url}}},e.shouldSend=function(){return "customer.wishlist"===salla.config.get("page.slug")},e}(),Pe=function(){function e(e){this.data=e;}return e.prototype.toSegment=function(){var e,t=(null==(e=Salla.analytics.history.find((function(e){return "Product Viewed"===e.eventName})))?void 0:e.payload)||{};return t.share_via=this.data.share_via,{event:"Product Shared",properties:t}},e.shouldSend=function(){return "product.single"===salla.config.get("page.slug")},e}(),Ae=function(){function e(e){this.details=e;}return e.prototype.toSegment=function(){return {event:"Product Reviewed",properties:this.details}},e.registerEvent=function(){salla.event.rating.onProductsRated((function(e,t){var a=t.products,n=t.order_id;Object.values(a).forEach((function(e){var t;Salla.event.emit("Product Reviewed",{product_id:null==(t=e.product_id)?void 0:t.toString(),review_id:null==n?void 0:n.toString(),review_body:e.comment,rating:e.rating});}));}));},e}(),qe=function(){function e(e){this.promotion=e[0];}return e.prototype.toSegment=function(){var e;return {event:"Promotion Viewed",properties:{promotion_id:null==(e=this.promotion.id)?void 0:e.toString(),creative:this.promotion.creative,name:this.promotion.name,position:this.promotion.position}}},e}(),Ee=function(){function e(e){this.promotion=e[0];}return e.prototype.toSegment=function(){var e;return {event:"Promotion Clicked",properties:{promotion_id:null==(e=this.promotion.id)?void 0:e.toString(),creative:this.promotion.creative,name:this.promotion.name,position:this.promotion.position}}},e}(),Ie=function(){function e(e){this.transaction=e;}var t=e.prototype;return t.getCartId=function(){var e,t;return "cart"===salla.config.get("page.slug")?null==(t=salla.config.get("page.id"))?void 0:t.toString():(null==(e=this.transaction)||null==(e=e.data)||null==(e=e.cart)||null==(e=e.id)?void 0:e.toString())||""},t.toSegment=function(){var e,t;return {event:"Coupon Applied",properties:{cart_id:this.getCartId(),coupon_name:(null==(e=this.transaction)||null==(e=e.data)||null==(e=e.cart)?void 0:e.coupon)||"",discount:(null==(t=this.transaction)||null==(t=t.data)||null==(t=t.cart)?void 0:t.discount)||0,currency:salla.config.get("user.currency")||""}}},e}(),xe=function(){function e(e){this.transaction=e;}var t=e.prototype;return t.getCartId=function(){var e;return "cart"===salla.config.get("page.slug")?null==(e=salla.config.get("page.id"))?void 0:e.toString():""},t.getCouponCode=function(){try{var e,t,a=null==(e=this.transaction.response)||null==(e=e.config)?void 0:e.data;return a?null==(t=JSON.parse(a))?void 0:t.coupon:""}catch(e){return ""}},t.toSegment=function(){var e;return {event:"Coupon Denied",properties:{cart_id:this.getCartId(),coupon_name:this.getCouponCode(),reason:(null==(e=this.transaction.response)||null==(e=e.data)||null==(e=e.error)?void 0:e.message)||"Unknown error"}}},e}(),Le=function(){function e(e){this.transaction=e;}var t=e.prototype;return t.getCartId=function(){var e,t;return "cart"===salla.config.get("page.slug")?null==(t=salla.config.get("page.id"))?void 0:t.toString():(null==(e=this.transaction)||null==(e=e.data)||null==(e=e.cart)||null==(e=e.id)?void 0:e.toString())||""},t.toSegment=function(){var e,t;return {event:"Coupon Removed",properties:{cart_id:this.getCartId(),coupon_name:(null==(e=this.transaction)?void 0:e.coupon)||"",discount:(null==(t=this.transaction)||null==(t=t.data)||null==(t=t.cart)?void 0:t.discount)||0,currency:salla.config.get("user.currency")||""}}},e}(),Te=function(){function e(e){this.details=null==e?void 0:e.data;}return e.prototype.toSegment=function(){var t=this,a=["first_name","last_name","birthday","gender"].filter((function(a){var n,r;return e.user[a]!==(null==(n=t.details)?void 0:n[a])&&(void 0!==e.user[a]||void 0!==(null==(r=t.details)?void 0:r[a]))}));return e.setUser(this.details),{event:"User Profile Updated",properties:{updated_fields:a}}},e.registerEvent=function(){Salla.onReady((function(){salla.url.is_page("customer.profile")&&e.setUser(Salla.config.get("user"));}));},e.setUser=function(t){e.user={first_name:null==t?void 0:t.first_name,last_name:null==t?void 0:t.last_name,gender:null==t?void 0:t.gender,birthday:null==t?void 0:t.birthday,avatar:null==t?void 0:t.avatar};},e.shouldSend=function(){return "user"===Salla.config.get("user.type")},e}();Te.user={};var Re=function(e){function t(t){var a;a=e.call(this,t)||this;var n=(null==t?void 0:t.nextPage)||"";return a.filters=a.extractFilters(n),a}g(t,e);var a=t.prototype;return a.extractFilters=function(e){if(!e)return null;try{var t=new URL(e),a=[];return Array.from(t.searchParams.entries()).forEach((function(e){var t=e[0],n=e[1];if(t.startsWith("filters[")){var r=t.match(/^filters\[(.*?)\]/),i=r?r[1]:t;a.push({type:i,value:n});}})),a.length>0?a:null}catch(e){return console.warn("Error extracting filters from URL:",e),null}},a.toSegment=function(){var t=e.prototype.toSegment.call(this);return {event:"Product List Filtered",properties:f({},null==t?void 0:t.properties,{filters:this.filters})}},t.shouldSend=function(e){return ((null==e?void 0:e.nextPage)||"").includes("filters")},t}(ve),Oe=function(){function e(e){this.cart=e;}return e.prototype.toSegment=function(){var e,t,a,n,r=this;return {event:"Cart Updated",properties:{cart_id:null==(e=this.cart.id)?void 0:e.toString(),value:this.cart.total,revenue:this.cart.sub_total,tax:this.cart.tax_amount,discount:this.cart.total_discount,shipping:this.cart.real_shipping_cost,currency:null==(t=Salla.config.currency())?void 0:t.code,affiliation:null==(a=Salla.storage.getWithTTL("s-utms"))?void 0:a["s-utm-source"],products:null==(n=this.cart.items)?void 0:n.map((function(e){var t,a,n,i,o,s;return {product_id:null==(t=e.product_id)?void 0:t.toString(),name:e.product_name,price:e.product_price,category:null==(a=e.category)?void 0:a.toString(),sku:null==(n=e.product_sku)?void 0:n.toString(),position:e.position,url:e.url,image_url:e.product_image,brand:null==(i=e.brand)?void 0:i.toString(),currency:null==(o=Salla.config.currency())?void 0:o.code,variant:null==(s=e.variant)?void 0:s.toString(),coupon:r.cart.coupon,quantity:e.quantity}}))}}},e.shouldSend=function(){return "cart"===salla.config.get("page.slug")},e}(),je=function(){function e(e){this.scope=e.data;}var t=e.prototype;return t.toSegment=function(){return {event:"Market Selected",properties:f({},this.getScope(this.scope),{prev:this.getScope(Salla.config.get("store.scope"))})}},t.getScope=function(e){var t;return {id:null==(t=(e=e||{}).id)?void 0:t.toString(),country:this.getScopeAttribute(e,"countries"),currency:this.getScopeAttribute(e,"currencies"),locale:this.getScopeAttribute(e,"languages")}},t.getScopeAttribute=function(e,t){return e=e[t],Array.isArray(e)?e[0]:e},e}(),De=function(){function e(){}return e.registerEvents=function(){Object.values(this.events).forEach((function(e){e.forEach((function(e){"function"==typeof e.registerEvent&&e.registerEvent();}));}));},e.transform=function(e,t){try{for(var a,n=h$1(this.events[e]||[]);!(a=n()).done;){var r=a.value;if(r&&("function"!=typeof r.shouldSend||r.shouldSend(t))){var i=new r(t).toSegment();return {event:i.event,properties:i.properties}}}return null}catch(e){return console.error("Failed to transform event:",e),null}},e}();De.events={"Order Completed":[ke],"Product Added":[he,Ce],"Product Removed":[Se],"Product Viewed":[fe],"Product Added to Wishlist":[_e],"Product Removed from Wishlist":[Fe],"Cart Viewed":[ge],"Products Searched":[me],"Product List Viewed":[ve],"Product List Filtered":[Re],"Signed Up":[we],"Signed In":[ye],"Signed Out":[be],"Product Reviewed":[Ae],"Product Shared":[Pe],"Promotion Viewed":[qe],"Promotion Clicked":[Ee],"Coupon Applied":[Ie],"Coupon Removed":[Le],"Coupon Denied":[xe],"User Profile Updated":[Te],"Cart Updated":[Oe],"Market Selected":[je]};var Ue=function(){function e(){var e=this;this.history=[],this.customTrackers=[],this.mappedEvents={"wishlist::added":"Product Added to Wishlist","wishlist::removed":"Product Removed from Wishlist","salla-products-list::products.fetched":["Product List Viewed","Product List Filtered"],"auth::registered":"Signed Up","auth::logged.in":"Signed In","auth::logged.out":"Signed Out","share-element":"Product Shared","promotion::viewed":"Promotion Viewed","promotion::clicked":"Promotion Clicked","cart::coupon.added":"Coupon Applied","cart::coupon.deleted":"Coupon Removed","cart::coupon.addition.failed":"Coupon Denied","profile::updated":"User Profile Updated","cart::updated":"Cart Updated","scope::changed":"Market Selected"},Salla.event.onAny((function(t,a){try{if(Object.keys(e.mappedEvents).includes(t)){var n=e.mappedEvents[t];return void(Array.isArray(n)?n:[n]).forEach((function(e){return Salla.event.emit(e,a)}))}if(!Salla.config.get("jitsu.events",[]).includes(t))return;var r=De.transform(t,a);r&&e.track(r.event,r.properties);}catch(e){Salla.log("Error in analytics event handling:",e);}})),Salla.event.on("twilight::before.ready",(function(t){var a,n,r,o,s;e.debugAnalytics=jitsuAnalytics({host:e.getAnalyticsHost(t),writeKey:"bbLD6Xqr1OKsDJfxZBCy7SJN1RIsrkBp:WEa99iY220v9qX7KiuAlML9ldSFJKW2p",fetch:e.customFetch}),e.debugAnalytics.setContextProperty("library",{twilight:Salla.versions});var l=(null==t?void 0:t.jitsu)||{},c=l.host,u=l.key;if(e.jitsuAnalytics=null,c&&u){var d;if(De.registerEvents(),e.initVisitorData(),e.jitsuAnalytics=jitsuAnalytics({host:e.getAnalyticsHost(t),writeKey:u,cookieCapture:{vsc:"vsc"}}),e.setContext("store_id",null==(a=t.store)?void 0:a.id),e.setContext("version",null==(n=t.jitsu)?void 0:n.version),e.setContext("library",{twilight:Salla.versions}),null!=(r=t.jitsu)&&null!=(r=r.context)&&r.extra&&e.setExtraContext(t.jitsu.context.extra),null!=(o=t.store)&&null!=(o=o.scope)&&o.id)e.setContext("scope",null==(d=t.store)?void 0:d.scope);"user"===(null==t||null==(s=t.user)?void 0:s.type)&&e.setContext("traits",e.getFormattedUser(t.user)),e.registerTracker({name:"DefaultSallaTracker",track:function(t,a){return e.jitsuAnalytics.track(t,a)},page:function(t){return e.jitsuAnalytics.page(t)}});}else salla.log("Jitsu configuration is missing. Analytics will not be tracked.");})),Salla.onReady((function(){var t,a={name:Salla.config.get("page.slug",""),id:null==(t=Salla.config.get("page.id",""))?void 0:t.toString()};e.setContext("page",a),e.page(a);}));}var t=e.prototype;return t.setExtraContext=function(e){var t;null!=e&&null!=(t=e.headers)&&t["s-app-os"]&&(this.setContext("app",{version:e.headers["s-app-os-version"],app_release_tag:e.headers["s-app-version"],platform:e.headers["s-app-os"].toLowerCase()}),delete e.headers["s-app-os"],delete e.headers["s-app-os-version"],delete e.headers["s-app-version"],delete e.headers["s-source"]),this.setContext("system",e);},t.getAnalyticsHost=function(e){var t,a="https://salla.cloud/_app/e";if(null==e||null==(t=e.store)||!t.url)return Salla.log("Error getting store url - no config or store URL provided"),a;var n=e.store.url;try{var r="",i=n;if(/https:\/\/demostore\.salla\.sa/.test(i))return Salla.log("demostore.salla.sa detected, using fallback URL"),a;var o=i.match(/(salla\.sa)\/(?:(ar|en)\/)?((?!ar$|en$)[a-zA-Z0-9.-]+)/);if(o){var s=o[3];if(!s||0===s.trim().length||"ar"===s||"en"===s)return Salla.log("Error: invalid or empty store name in salla.sa URL"),a;r=new URL(i).origin+"/"+s;}else {r=new URL(i).origin;}return r+"/_app/e"}catch(e){return Salla.log("Error getting store url, forwarding to salla.cloud:",e),a}},t.setContext=function(e,t){var a,n;null==(a=this.jitsuAnalytics)||a.setContextProperty(e,t),null==(n=this.debugAnalytics)||n.setContextProperty(e,t);},t.customFetch=function(e,t){var a;return Salla.api.beaconRequest(e+"?writekey="+(null==t||null==(a=t.headers)?void 0:a["X-Write-Key"]),t)},t.track=function(e,t){ void 0===t&&(t={}),t=this.finalPayload(t),this.history.push({action:"track",eventName:e,payload:t}),this.pushEventToCustomTrackers("track",e,t);},t.log=function(e,t){var a;return void 0===t&&(t={}),null==(a=this.debugAnalytics)?void 0:a.track(e,t).catch((function(e){return salla.log("Error tracking event:",e),Promise.reject(e)}))},t.page=function(e){var t,a;void 0===e&&(e={}),(e=this.finalPayload(e)).id=null==(t=e.id||Salla.config.get("page.id",""))?void 0:t.toString(),e.name=e.name||Salla.config.get("page.slug"),e.keywords=e.keywords||(null==(a=document.querySelector("meta[name=keywords]"))?void 0:a.content),e.referrer=e.referrer||document.referrer,this.history.push({action:"page",payload:e}),this.pushEventToCustomTrackers("page",e);},t.finalPayload=function(e){ void 0===e&&(e={});var t=Salla.storage.getWithTTL("s-utms");if(t){var a,n=t["s-utm-campaign"],r=t["s-utm-source"],i=t["s-utm-medium"],o=t["s-utm-term"],s=t["s-utm-content"],l=t["s-utm-referrer"];null==(a=Salla.analytics)||a.setContext("campaign",{name:n,source:r,medium:i,term:o,content:s,referrer:l});}return f({},{},e)},t.registerTracker=function(e){"object"==typeof e?"string"==typeof e.name&&e.name?"function"==typeof e.track?"function"==typeof e.page?this.customTrackers.find((function(t){return t.name===e.name}))?Salla.log("tracker with the same name already exists!"):(this.customTrackers.push(e),this.history.forEach((function(t){return "track"===t.action?e.track(t.eventName,t.payload):"page"===t.action?e.page(t.payload):void 0}))):Salla.log("tracker.page most be a function!"):Salla.log("tracker.track most be a function!"):Salla.log("tracker.name most be a string!"):Salla.log('tracker most be an object {name:"tracker name", track: callback, page: callback}!');},t.pushEventToCustomTrackers=function(e,t,a){var n=this;void 0===a&&(a={});var r="page"===e?[t]:[t,a];return Promise.allSettled(this.customTrackers.map((function(t){return n.pushEventToCustomTracker(t[e],r)}))).then((function(t){return t.filter((function(e){return "rejected"===e.status})).map((function(t){return Salla.log("Error on customTracker to send "+e,t)}))}))},t.pushEventToCustomTracker=function(e,t){try{var a=e.apply(void 0,t);return Promise.resolve(a).catch((function(e){return Promise.reject(e)}))}catch(e){return Promise.reject(e)}},t.getFormattedUser=function(e){return e.phone=e.mobile,e.country=e.country_code,e.language=e.language_code,e.currency=e.currency_code,e},t.initVisitorData=function(){null!=Salla.cookie.get("vsc")||Salla.cookie.set("vsc",""+Date.now(),1);},e}(),Ne=function(){function e(){var e=this;Salla.onReady((function(){return e.init()}));}var t=e.prototype;return t.init=function(){if(!Salla.config.isUser()){var e=new URLSearchParams(window.location.search);if(e.has("intended_to"))try{var t=new URL(e.get("intended_to"));if(t.hostname!==window.location.hostname)return;return this.handleAfterLoginEvent(t)}catch(e){return void console.warn("Invalid URL provided in intended_to parameter")}}},t.handleAfterLoginEvent=function(e){var t="intend::user.logged.in";Salla.event.on(t,(function(){return window.location=e})),Salla.api.auth.setAfterLoginEvent(t),Salla.api.auth.setCanRedirect(false),Salla.event.on("salla-login::ready",(function(){return Salla.event.emit("login::open",{withoutReload:true})}));},e}(),Me=function(){function e(e){var t=this;void 0===e&&(e={}),this.config=f({WHITELIST:[location.hostname,"salla.com","salla.sa","salla.dev","salla.network","salla.group","mtjr.at"],POLL_INTERVAL_MS:500,WHITELIST_PAGES:["customer.orders.single","page-single","blog.single","blog.index"]},e),this.originalMethods={},this.isInitialized=false,Salla.onReady((function(){return t.init()}));}var t=e.prototype;return t.normalizeUrl=function(e){try{return new URL(e,location.href)}catch(e){return null}},t.shouldIgnoreUrl=function(e){if(!e)return false;var t="string"==typeof e?e:e.href||String(e),a=t.toLowerCase();if(["tel:","mailto:","javascript:"].some((function(e){return a.startsWith(e)})))return true;try{var n=new URL(t,location.href).hostname.toLowerCase();return ["facebook.com","fb.com","twitter.com","x.com","instagram.com","linkedin.com","youtube.com","youtu.be","tiktok.com","snapchat.com","pinterest.com","whatsapp.com","wa.me","iwtsp.com","telegram.org","t.me","discord.com","discord.gg","reddit.com","tumblr.com","google.com","forms.gle","maps.app.goo.gl","goo.gl","apple.com","smsaexpress.com","aramex.com","aj-ex.com","redboxsa.com","fastcoo-tech.com","express.dhl","najizxpress.net","jtexpress.me","jtexpress-sa.com","tamex.com.sa","aymakan.com.sa","fastlo.com","sls-express.com","logestechs.com","massuul.com","tamara.co","gov.sa","org.sa","stc.com.sa","sa","addtoany.com","wchat.freshchat.com","getbutton.io","heyzine.com","linktr.ee"].some((function(e){return n===e||n.endsWith("."+e)}))}catch(e){return false}},t.isWhitelisted=function(e){if(!e)return false;for(var t,a=e.hostname.toLowerCase(),n=h$1(this.config.WHITELIST);!(t=n()).done;){var r=t.value,i=String(r||"").toLowerCase().trim();if(i&&(a===i||a.endsWith("."+i)))return true}return false},t.emit=function(e){try{window.__redirectLogs||(window.__redirectLogs=[]),window.__redirectLogs.push(e);try{Salla.analytics.log("redirect",e);}catch(e){}}catch(e){}},t.logRedirect=function(e,t,a){if(!this.shouldIgnoreUrl(t)){var n=this.normalizeUrl(t),r=this.normalizeUrl(location.href),i=this.isWhitelisted(n),o={redirect_source:e,redirect_from:r?r.href:String(location.href),redirect_to:n?n.href:String(t),redirect_host:n?n.hostname:null,redirect_referrer:document.referrer||null,page_slug:Salla.config.get("page.slug"),whitelisted:i,stack:a&&a.stack?String(a.stack):void 0,meta:a||void 0};i||this.emit(o);}},t.hookHistoryAPIs=function(){var e=this;["pushState","replaceState"].forEach((function(t){try{var a=history[t];"function"==typeof a&&(e.originalMethods["history."+t]=a,history[t]=function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];try{var o;e.logRedirect(t,null!=(o=r[2])?o:location.href);}catch(e){}return a.apply(history,r)});}catch(e){}})),window.addEventListener("popstate",(function(){e.logRedirect("popstate",location.href);})),window.addEventListener("hashchange",(function(){e.logRedirect("hashchange",location.href);}));},t.hookLocationMethods=function(){var e=this;try{var t=location.assign.bind(location);this.originalMethods["location.assign"]=t,location.assign=function(a){return e.logRedirect("location.assign",a,{stack:(new Error).stack}),t(a)};}catch(e){}try{var a=location.replace.bind(location);this.originalMethods["location.replace"]=a,location.replace=function(t){return e.logRedirect("location.replace",t,{stack:(new Error).stack}),a(t)};}catch(e){}},t.hookWindowOpen=function(){var e=this;try{var t=window.open;this.originalMethods["window.open"]=t,window.open=function(a){a&&e.logRedirect("window.open",a,{stack:(new Error).stack});for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return t.apply(window,[a].concat(r))};}catch(e){}},t.setupEventListeners=function(){var e=this;this.handleLinkClick=function(t){var a=t.target&&t.target.closest?t.target.closest("a[href]"):null;if(a){var n=a.getAttribute("href");if(n&&!n.startsWith("#")&&!e.shouldIgnoreUrl(n)){var r=a.getAttribute("target")||"_self";setTimeout((function(){e.logRedirect("link-click",n,{target:r});}),0);}}},document.addEventListener("click",this.handleLinkClick,true),this.handleFormSubmit=function(t){var a=t.target,n=a&&a.getAttribute&&a.getAttribute("action")||location.href,r=(a&&a.method?String(a.method):"GET").toUpperCase();e.logRedirect("form-submit",n,{method:r});},document.addEventListener("submit",this.handleFormSubmit,true);},t.setupPerformanceObserver=function(){var e=this;try{this.performanceObserver=new PerformanceObserver((function(t){for(var a,n=h$1(t.getEntries());!(a=n()).done;){var r=a.value;"navigation"===r.entryType&&e.logRedirect("performance-navigation",location.href,{type:r.type,redirectCount:r.redirectCount});}})),this.performanceObserver.observe({type:"navigation",buffered:true});}catch(e){}},t.init=function(){if(!this.config.WHITELIST_PAGES.includes(Salla.config.get("page.slug"))&&!this.isInitialized){var e=new URL(Salla.config.get("store.url")).hostname.split(".").slice(-2).join(".");this.config.WHITELIST.includes(e)||this.config.WHITELIST.push(e),this.hookHistoryAPIs(),this.hookLocationMethods(),this.hookWindowOpen(),this.setupEventListeners(),this.setupPerformanceObserver(),this.isInitialized=true;}},t.destroy=function(){var e=this;this.isInitialized&&(Object.keys(this.originalMethods).forEach((function(t){var a=t.split("."),n=a[0],r=a[1];"history"===n&&e.originalMethods[t]?history[r]=e.originalMethods[t]:"location"===n&&e.originalMethods[t]?location[r]=e.originalMethods[t]:"window"===n&&"open"===r&&e.originalMethods[t]&&(window.open=e.originalMethods[t]);})),this.handleLinkClick&&document.removeEventListener("click",this.handleLinkClick,true),this.handleFormSubmit&&document.removeEventListener("submit",this.handleFormSubmit,true),this.performanceObserver&&this.performanceObserver.disconnect(),this.isInitialized=false);},e}(),He=function(){function e(){this._store=new Map,this._whitelist=new Map([["salla-add-product-button",new Set(["validate","componentDidLoad"])],["salla-products-list",new Set(["componentDidLoad"])],["salla-hook",new Set(["componentDidLoad"])]]),this._themeSlots=["head","head:start","head:end","body:start","body:end","product:index.items.start","product:index.items.end","product:single.description.start","product:single.description","product:single.description.end","product:single.form.start","product:single.form.end","blog:index.items.start","blog:index.items.end","blog:single.items.start","blog:single.items.end","brands:index.items.start","brands:index.items.end","brands:single.details.start","brands:single.details.end","brands:single.items.start","brands:single.items.end","cart:items.start","cart:items.end","cart:summary.start","cart:summary.end","cart:submit.start","cart:submit.end","customer:notifications.items.start","customer:notifications.items.end","customer:orders.index.items.start","customer:orders.index.items.end","customer:orders.single.details.start","customer:orders.single.details.end","customer:wishlist.items.start","customer:wishlist.items.end","customer:profile.form.start","customer:profile.form.fields.start","customer:profile.form.fields.end","customer:profile.form.submit.start","customer:profile.form.submit.end","customer:profile.form.end","thank-you:start","thank-you:items.start","thank-you:items.end","thank-you:end"],this._componentHistory=new Map;}var t=e.prototype;return t.registerHook=function(e,t,a,n){var r=this;if(void 0===n&&(n={}),!this._isAllowed(e,t))return console.warn('[Hooks] Hook "'+e+":"+t+'" is not allowed'),function(){};var i=0|n.priority,o=!!n.once,s=this._ensureTag(e),l=s.get(t)||[];return l.push({cb:a,p:i,once:o}),l.sort((function(e,t){return t.p-e.p})),s.set(t,l),"componentDidLoad"===t&&this._callForLoadedComponents(e,a),function(){return r.removeHook(e,t,a)}},t.registerHookOnce=function(e,t,a,n){return void 0===n&&(n={}),this.registerHook(e,t,a,f({},n,{once:true}))},t.call=async function(e,t,a){var n=this._store.get(e);if(n){var r=n.get(t);if(r&&0!==r.length)for(var i=0,o=[].concat(r);i<o.length;i++){var s=o[i];try{await s.cb(a);}catch(a){console.warn('[Hooks] "'+e+":"+t+'" callback failed:',a);}s.once&&this.removeHook(e,t,s.cb);}}},t.removeHook=function(e,t,a){var n=this._store.get(e);if(!n)return false;if(!n.has(t))return false;if(!a)return n.delete(t),0===n.size&&this._store.delete(e),true;var r=n.get(t),i=r.findIndex((function(e){return e.cb===a}));return i>-1&&(r.splice(i,1),0===r.length&&n.delete(t),0===n.size&&this._store.delete(e),true)},t.clear=function(e){e?this._store.delete(e):this._store.clear();},t.get=function(e,t){var a,n=this._store.get(e);return n&&(null==(a=n.get(t))?void 0:a.map((function(e){return e.cb})))||[]},t._ensureTag=function(e){var t=this._store.get(e);return t||(t=new Map,this._store.set(e,t)),t},t._isAllowed=function(e,t){var a=this._whitelist.get(e);return a?!!a.has(t)||(console.warn('[Hooks] Hook "'+t+'" is not allowed for tag "'+e+'"'),false):(console.warn('[Hooks] Tag "'+e+'" is not in the whitelist'),false)},t.registerComponent=function(e,t){this._componentHistory.has(e)||this._componentHistory.set(e,new Set);var a=this._componentHistory.get(e);if(!a.has(t))return a.add(t),this.call(e,"componentDidLoad",t)},t._callForLoadedComponents=async function(e,t){var a=this._componentHistory.get(e);if(a&&0!==a.size)for(var n,r=h$1(a);!(n=r()).done;){var i=n.value;try{await t(i);}catch(t){console.warn('[Hooks] "'+e.replace(/[^a-zA-Z0-9-_]/g,"")+':componentDidLoad" callback failed:',t);}}},t.mount=function(e,t){var a=this;return this._themeSlots.includes(e)?new Promise((function(n){a.registerHook("salla-hook","componentDidLoad",(function(a){a.name===e&&(a.mount(t),n(t));}));})):(console.warn('[Hooks] Hook "'+e+'" is not allowed'),Promise.reject(t))},e}();N$3.onInitiated=function(e){return salla.event.once("twilight::initiated",e)},N$3.onReady=N$3.onReady||function(t){return new Promise((function(a){return "ready"===salla.status?a(t?t(salla.config.all()):salla.config.all()):N$3.onInitiated((function(e){return a(t?t(e):e)}))}))},N$3.status="loading",N$3.notify=c,N$3.lang=new V,N$3.form=new H,N$3.infiniteScroll=new M(void 0,salla.event.infiniteScroll),N$3.api=new ue,N$3.sso=new pe,N$3.intend=new Ne,N$3.hooks=new He,["cart","auth","order","scope","rating","comment","loyalty","product","profile","currency","document","wishlist","booking","landing","metadata"].forEach((function(t){return N$3[t]=new u(N$3.api[t],N$3.event[t])})),N$3.call=function(t){for(var a=N$3,n=t.split(".");n.length&&(a=a[n.shift()]););return a},N$3.analytics=new Ue,N$3.init=function(e){return new de(e)},new Me,salla.event.once("twilight::init",salla.init),salla.event.on("twilight::api",(function(e){var t=null==e?void 0:e.events;t&&salla.event.dispatchEvents(t);})),N$3.success=N$3.notify.success,N$3.error=N$3.notify.error,N$3.versions.twilight="2.14.311",window.dispatchEvent(new CustomEvent("salla::created"));
|
|
12334
|
+
var o=function(e,t,a){return alert(e)},u=function(e,t){return o(e,s.error,t)},s={error:"error",success:"success",info:"info"},l={fire:function(e,t,a){return o(e,t,a)},setNotifier:function(e){o=e,salla.event.emit("twilight::notifier.changed");},error:u,success:function(e,t){return o(e,s.success,t)},info:function(e,t){return o(e,s.info,t)},sallaInitiated:function(){var e=window.location.href.match(/([\?\&]danger=)[^&]+/g);e&&(window.history.replaceState(null,document.title,window.location.pathname),salla.event.once("twilight::notifier.changed",(function(){e.forEach((function(e){e=decodeURI(e.replace("?danger=","").replace("&danger=",""));var t=document.createElement("div");t.innerText=e,u(t.innerHTML),salla.event.emit("twilight::error",e);}));})));},types:s},c=function(e,t){return this.api=e,this.event=t,new Proxy(this,{get:function(a,n){return "event"===n?t:"api"===n?e:e&&e[n]||a[n]}})};function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,n=Array(t);a<t;a++)n[a]=e[a];return n}function p(e,t,a){if(v())return Reflect.construct.apply(null,arguments);var n=[null];return n.push.apply(n,t),new(e.bind.apply(e,n))}function h$1(e,t){var a="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(a)return (a=a.call(e)).next.bind(a);if(Array.isArray(e)||(a=function(e,t){if(e){if("string"==typeof e)return d(e,t);var a={}.toString.call(e).slice(8,-1);return "Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?d(e,t):void 0}}(e))||t){a&&(e=a);var n=0;return function(){return n>=e.length?{done:true}:{done:false,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n]);}return e},f.apply(null,arguments)}function g(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,m(e,t);}function v(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})));}catch(e){}return (v=function(){return !!e})()}function m(e,t){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},m(e,t)}Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){for(var t=this;t;){if(t.matches(e))return t;t=t.parentElement;}}),Element.prototype.getElementSallaData=function(e){if(this.getAttribute){if(this.hasAttribute("data-json"))try{return JSON.parse(this.getAttribute("data-json"))}catch(e){}var t=this.getAttribute("data-function");if(t&&window[t]){if("function"==typeof window[t]){for(var a,n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return this.getFilteredData((a=window[t]).call.apply(a,[this].concat(r)))}return this.getFilteredData(window[t])}var o=this.hasAttribute("data-form-selector")?document.querySelector(this.dataset.formSelector):void 0;if((o="FORM"===this.tagName?this:o||this.closest("form")||this.closest("[salla-form-data]")||this)&&"FORM"===o.tagName)return this.getFilteredData(new FormData(o),null,o);var u=o.querySelectorAll("[name]");if(!u.length)return this.getFilteredData();var s=Object.assign({},this.dataset);return u.forEach((function(e){if(!["checkbox","radio"].includes(e.type)||e.checked)try{var t=Salla.helpers.inputData(e.name,e.value,s);s[t.name]=t.value;}catch(t){Salla.log(e.name+" can't be send");}})),this.getFilteredData(s)}},Element.prototype.canEventFireHook=function(e){return !!this.hasAttribute&&this.hasAttribute(Salla.api.hooksPrefix+e.type)},Element.prototype.hasAttributeStartsWith=function(e,t){e=e.toLowerCase();for(var a=0;a<this.attributes.length;a++){var n=this.attributes[a].name.toLowerCase();if(0===n.indexOf(e))return !t||n}return false},HTMLFormElement.prototype.getAjaxFormData=function(e){var t=this.querySelectorAll('input[type="file"]');t.forEach((function(e){e.files.length||e.setAttribute("disabled","");}));var a=new FormData(this);return t.forEach((function(e){e.files.length||e.removeAttribute("disabled");})),{formData:this.getFilteredData(a,e),url:this.getAttribute("action"),method:this.getAttribute("method")||"post",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}},Element.prototype.getFilteredData=function(e,t,a){var n,r=this;return void 0===e&&(e=null),void 0===t&&(t=null),void 0===a&&(a=null),e=e||(null==(n=a)?void 0:n.dataset)||this.dataset,a&&this.name&&void 0!==this.value&&(e=function(e,t,a){e instanceof FormData?e.append(t,a):e[t]=a;return e}(e,this.name,this.value)),["filterBeforeSubmit","filterBeforeSend"].forEach((function(n){var i,o=(null==(i=a)?void 0:i.dataset[n])||r.dataset[n];if(o){var u=window[o];if("function"==typeof u){if(!u(e,a||r,t)&&e)throw "Data failed to be pass verify function window."+o+"(formData, element, event)!";return u(e,a||r,t)}Salla.log("window."+o+"() not found!");}})),e},HTMLAnchorElement.prototype.getAjaxFormData=function(e){return {formData:this.getFilteredData(null,e),url:this.getAttribute("href"),method:this.dataset.type||"get",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}};var D=function(){function e(){this.events={},this.namespace="";var e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&e.length>1?e[1]:"").toLowerCase();}var t=e.prototype;return t.after_init=function(){this.createDynamicFunctions();},t.createDynamicFunctions=function(){var e=this;Object.keys(this.events).forEach((function(t){e.createDynamicEventFuns(t),e.createDynamicListenerFuns(t);}));},t.createDynamicEventFuns=function(e){if(!this[e]){var t=this;this[e]=function(){for(var a=arguments.length,n=new Array(a),r=0;r<a;r++)n[r]=arguments[r];return t.dispatch.apply(t,[e].concat(n))};}},t.createDynamicListenerFuns=function(e){var t="on"+e.charAt(0).toUpperCase()+e.slice(1);if(!this[t]){var a=this;this[t]=function(t){return a.on(e,(async function(){return t.apply(void 0,arguments)}))};}},t.getEventName=function(e){return e=this.events[e]||e||"unknown-event",!this.namespace||e.includes("::")?e:this.namespace+Salla.event.delimiter+e},t.dispatch=function(e){for(var t,a=arguments.length,n=new Array(a>1?a-1:0),r=1;r<a;r++)n[r-1]=arguments[r];return (t=Salla.event).emitAsync.apply(t,[this.getEventName(e)].concat(n))},t.on=function(e,t,a){return void 0===a&&(a={}),Salla.event.addListener(this.getEventName(e),t,a)},t.once=function(e,t){return Salla.event.once(this.getEventName(e),t)},e}(),F=function(e){function t(){var t;return (t=e.call(this)||this).namespace="auth",t.events={login:"login",logout:"logout",codeSent:"code.sent",codeNotSent:"code.not-sent",verified:"verified",verificationFailed:"verification.failed",loggedIn:"logged.in",registered:"registered",registrationFailed:"registration.failed",loggedOut:"logged.out",failedLogout:"failed.logout",refreshFailed:"refresh.failed",tokenFetched:"token.fetched",tokenInvalid:"token.invalid"},t.after_init(),t}g(t,e);var a=t.prototype;return a.login=function(e){return e?(e.type&&this.setTypeActionOnVerified(e.type),this.next_event=e.next_event||null,this.dispatch.apply(this,["login"].concat(Array.prototype.slice.call(arguments)))):(this.next_event=null,this.dispatch.apply(this,["login"].concat(Array.prototype.slice.call(arguments))))},a.loggedIn=async function(e){var t=this;return Salla.profile.info().finally((function(){return t.dispatch("loggedIn",e)}))},a.setTypeActionOnVerified=function(e){this.type_action_on_verified=e;},a.getTypeActionOnVerified=function(){return this.type_action_on_verified||"redirect"},t}(D),y=function(e){function t(){var t;return (t=e.call(this)||this).namespace="cart",t.events={latestFetched:"latest.fetched",latestFailed:"latest.failed",updated:"updated",itemUpdated:"item.updated",itemUpdatedFailed:"item.updated.failed",itemAdded:"item.added",beforeAddItem:"before.add.item",itemAddedFailed:"item.added.failed",itemDeleted:"item.deleted",itemDeletedFailed:"item.deleted.failed",submitted:"submitted",submitFailed:"submit.failed",imageDeleted:"image.deleted",imageNotDeleted:"image.not.deleted",detailsFetched:"details.fetched",detailsNotFetched:"details.not.fetched",successReset:"success.reset",priceQuoteSucceeded:"price-quote.succeeded",priceQuoteFailed:"price-quote.failed",offersFetched:"offers.fetched",offersFailed:"offers.failed",couponAdded:"coupon.added",couponDeleted:"coupon.deleted",couponAdditionFailed:"coupon.addition.failed",couponDeletionFailed:"coupon.deletion.failed",quickOrderSettingFetched:"quick-order.fetched",quickOrderSettingFailed:"quick-order.failed",quickOrderSucceeded:"quick-order.succeeded",quickOrderFailed:"quick-order.failed",beforeStartFastCheckout:"before.start.fast-checkout",submitting:"submitting"},t.after_init(),t}g(t,e);var a=t.prototype;return a.updated=function(e,t){var a;return void 0===t&&(t={}),Salla.cookie.set("fresh_summary",1),e&&"object"==typeof e?(e.offer&&salla.product.event.offerExisted(e.offer),e.redirect&&(salla.log("The current cart is purchased!"),salla.cart.api.reset()),e.cart?(salla.storage.set("cart.summary",{total:e.cart.total,sub_total:e.cart.sub_total,discount:e.cart.discount,tax_amount:e.cart.tax_amount,total_discount:e.cart.total_discount,real_shipping_cost:e.cart.real_shipping_cost,count:e.cart.count,shipping_cost:null!=(a=e.cart.free_shipping_bar)&&a.has_free_shipping?0:e.cart.real_shipping_cost}),this.dispatch("updated",f({},e.cart,{fromLatestFetched:t.fromLatestFetched}))):void salla.log("Failed to get the cart summary!")):(Salla.logger.info("Cart summary not an object!",e),this.dispatch("updated",{fromLatestFetched:t.fromLatestFetched}))},a.latestFetched=function(e){return this.updated(e.data,{fromLatestFetched:true}),this.dispatch("latestFetched",e)},a.itemAdded=function(e,t){return this.updated(e.data),this.dispatch("itemAdded",e,t)},a.itemDeleted=function(e,t){return this.updated(e.data),this.dispatch("itemDeleted",e,t)},a.itemUpdated=function(e,t){return this.updated(e.data),this.dispatch("itemUpdated",e,t)},a.couponAdded=function(e,t){return this.updated(e.data),this.dispatch("couponAdded",e,t)},a.couponDeleted=function(e,t){return this.updated(e.data),this.dispatch("couponDeleted",e,t)},t}(D),C=function(e){function t(){var t;return (t=e.call(this)||this).namespace="order",t.events={canceled:"canceled",notCanceled:"not.canceled",orderCreated:"order.created",orderCreationFailed:"order.creation.failed",invoiceSent:"invoice.sent",invoiceNotSent:"invoice.not.sent",ordersFetched:"order.fetched",ordersNotFetched:"order.not.fetched"},t.after_init(),t}return g(t,e),t}(D),w=function(e){function t(){var t;return (t=e.call(this)||this).namespace="scope",t.events={fetched:"fetched",notFetched:"not.fetched",productAvailabilityFetched:"product-availability.fetched",productAvailabilityNotFetched:"product-availability.not.fetched",changeSucceeded:"changed",changeFailed:"not.changed"},t.after_init(),t}return g(t,e),t}(D),A=function(e){function t(){var t;return (t=e.call(this)||this).namespace="rating",t.events={orderNotFetched:"order.not.fetched",orderFetched:"order.fetched",storeRated:"store.rated",storeFailed:"store.failed",productsRated:"products.rated",productsFailed:"products.failed",shippingRated:"shipping.rated",shippingFailed:"shipping.failed"},t.after_init(),t}return g(t,e),t}(D),E=function(e){function t(){var t;return (t=e.call(this)||this).namespace="comment",t.events={added:"added",additionFailed:"addition.failed",fetched:"fetched",fetchFailed:"fetch.failed"},t.after_init(),t}return g(t,e),t}(D),S=function(e){function t(){var t;return (t=e.call(this)||this).namespace="loyalty",t.events={exchangeSucceeded:"exchange.succeeded",exchangeFailed:"exchange.failed",programFetched:"program.fetched",programNotFetched:"program.not.fetched",resetSucceeded:"exchange-reset.succeeded",resetFailed:"exchange-reset.failed"},t.after_init(),t}g(t,e);var a=t.prototype;return a.exchangeSucceeded=function(e,t){return salla.cart.event.updated(e.data),this.dispatch("exchangeSucceeded",e,t)},a.resetSucceeded=function(e){return salla.cart.event.updated(e.data),this.dispatch("resetSucceeded",e)},t}(D),b=function(e){function t(){var t;return (t=e.call(this)||this).namespace="profile",t.events={updated:"updated",updateFailed:"update.failed",verificationCodeSent:"verification.code.sent",updateContactsFailed:"update.contacts.failed",verified:"verified",unverified:"unverified",infoFetched:"info.fetched",infoNotFetched:"info.not.fetched",settingsUpdated:"settings.updated",updateSettingsFailed:"update.settings.failed",deleted:"deleted",notDeleted:"not.deleted"},t.after_init(),t}return g(t,e),t}(D),_=function(e){function t(){var t;return (t=e.call(this)||this).namespace="product",t.events={priceUpdated:"price.updated",priceUpdateFailed:"price.updated.failed",availabilitySubscribed:"availability.subscribed",availabilitySubscribeFailed:"availability.subscribe.failed",categoriesFetched:"categories.fetched",categoriesFailed:"categories.failed",searchFailed:"search.failed",searchResults:"search.results",offerExisted:"offer.existed",fetchOffersFailed:"fetch.offers.failed",offersFetched:"offers.fetched",sizeGuideFetched:"size-guide.fetched",sizeGuideFetchFailed:"size-guide.failed",giftFetched:"gift.fetched",giftFetchFailed:"gift.failed",detailFetched:"detail.fetched",detailFetchFailed:"detail.failed",addGiftToCartSucceeded:"gift.add-to-cart.succeeded",addGiftToCartFailed:"gift.add-to-cart.failed",giftImageUploadSucceeded:"gift.image-upload.succeeded",giftImageUploadFailed:"gift.image-upload.failed",productListFetchSucceeded:"fetch.succeeded",productListFetchFailed:"fetch.failed",productOptionsFetched:"options.fetched",productOptionsNotFetched:"options.not.fetched"},t.after_init(),t}return g(t,e),t}(D),k=function(e){function t(){var t;return (t=e.call(this)||this).namespace="document",t.events={click:"click",change:"change",submit:"submit",keyup:"keyup",leaving:"leaving",request:"request",requestFailed:"request.failed"},t.after_init(),t}g(t,e);var a=t.prototype;return a.onClick=function(e,t){this.fireCallableFuns("click",e,t);},a.onChange=function(e,t){this.fireCallableFuns("change",e,t);},a.onSubmit=function(e,t){this.fireCallableFuns("submit",e,t);},a.onKeyup=function(e,t){this.fireCallableFuns("keyup",e,t);},a.fireCallableFuns=function(e,t,a){this.on(e,(function(e){"function"!=typeof t?"function"==typeof a&&e.target.matches(t)&&a(e):t(e);}));},a.fireEvent=function(e,t){for(var a=arguments.length,n=new Array(a>2?a-2:0),r=2;r<a;r++)n[r-2]=arguments[r];return this.fireEventForElements.apply(this,[e,t,false].concat(n))},a.fireEventForAll=function(e,t){for(var a=arguments.length,n=new Array(a>2?a-2:0),r=2;r<a;r++)n[r-2]=arguments[r];return this.fireEventForElements.apply(this,[e,t,true].concat(n))},a.fireEventForElements=function(e,t,a){for(var n=this,r=arguments.length,i=new Array(r>3?r-3:0),o=3;o<r;o++)i[o-3]=arguments[o];if("string"==typeof e){if(a)return document.querySelectorAll(e).forEach((function(e){return n.fireEventForElements.apply(n,[e,t,false].concat(i))}));e=document.querySelector(e);}if(e){var u=p(CustomEvent,[t].concat(i));return e.dispatchEvent(u)}salla.log("Failed To get element to fire event: "+t);},t}(D),B=function(e){function t(){var t;return (t=e.call(this)||this).namespace="wishlist",t.events={added:"added",removed:"removed",additionFailed:"addition.failed",removingFailed:"removing.failed"},t.after_init(),t}return g(t,e),t}(D),P=function(e){function t(){var t;return (t=e.call(this)||this).namespace="currency",t.events={changed:"changed",failed:"failed",fetched:"fetched",failedToFetch:"failed.to.fetch"},t.after_init(),t}return g(t,e),t}(D),q=function(e){function t(){var t;return (t=e.call(this)||this).namespace="infiniteScroll",t.events={scrollThreshold:"scroll.threshold",request:"request",load:"load",append:"append",error:"error",last:"last",history:"history"},t.after_init(),t}return g(t,e),t}(D),x=function(e){function t(){var t;return (t=e.call(this)||this).namespace="booking",t.events={added:"added",additionFailed:"addition.failed"},t.after_init(),t}return g(t,e),t}(D),I=function(e){function t(){var t;return (t=e.call(this)||this).namespace="landing",t.events={detailsFetched:"order.fetched",getDetailsFailed:"get.details.failed",orderCreated:"order.created",orderCreationFailed:"order.creation.failed",breadcrumbFetched:"breadcrumb.fetched",breadcrumbFetchFailed:"breadcrumb.fetch.failed"},t.after_init(),t}return g(t,e),t}(D),L=function(e){function t(){var t;return (t=e.call(this)||this).namespace="notifications",t.events={fetched:"fetched",fetchFailed:"fetch.failed"},t.after_init(),t}return g(t,e),t}(D),T=function(e){function t(){var t;return (t=e.call(this)||this).namespace="component",t.events={menuFetched:"menus.fetched",menuFetchFailed:"menus.fetch.failed",reviewsFetched:"reviews.fetched",reviewsFetchFailed:"reviews.fetch.failed"},t.after_init(),t}return g(t,e),t}(D),R=function(e){function t(){var t;return (t=e.call(this)||this).namespace="advertisement",t.events={fetched:"advertisement.fetched",fetchFailed:"advertisement.not.fetched"},t.after_init(),t}return g(t,e),t}(D),O=function(e){function t(){var t;return (t=e.call(this)||this).namespace="navigation",t.events={breadcrumbFetched:"breadcrumb.fetched",breadcrumbFetchFailed:"breadcrumb.fetch.failed"},t.after_init(),t}return g(t,e),t}(D),j=function(e){function t(){var t;return (t=e.call(this)||this).namespace="metadata",t.events={valueFetched:"value.fetched",valueNotFetch:"value.not.fetched"},t.after_init(),t}return g(t,e),t}(D);function U(e){e&&e.sallaInitiated&&!e.initiated&&(e.sallaInitiated(),e.initiated=true);}Salla.event.auth=new F,Salla.event.cart=new y,Salla.event.order=new C,Salla.event.scope=new w,Salla.event.rating=new A,Salla.event.booking=new x,Salla.event.comment=new E,Salla.event.landing=new I,Salla.event.loyalty=new S,Salla.event.product=new _,Salla.event.profile=new b,Salla.event.currency=new P,Salla.event.document=new k,Salla.event.wishlist=new B,Salla.event.infiniteScroll=new q,Salla.event.notifications=new L,Salla.event.component=new T,Salla.event.advertisement=new R,Salla.event.navigation=new O,Salla.event.metadata=new j,Salla.event.on("twilight::initiated",(function(){Object.keys(Salla).forEach((function(e){"object"==typeof(e=Salla[e])&&(U(e),Object.keys(e).forEach((function(t){U(e[t]);})));}));})),Salla.config.default_properties={debug:"undefined"!=typeof process&&"development"==="production",token:null,fastRequests:true,canLeave:true,store:{api:["group","test"].includes(window.location.hostname.split(".").pop())?window.location.origin+"/api/v1/":"https://api.salla.dev/store/v1/"},currencies:{SAR:{code:"SAR",name:"ريال سعودي",symbol:"ر.س",amount:1,country_code:"sa"}}},Salla.config.merge(Salla.config.default_properties),Salla.config.triedToGetCurrencies_=false,Salla.config.triedToGetLanguages_=false,Salla.config.isUser=function(){return "user"===Salla.config.get("user.type")},Salla.config.isGuest=function(){return !Salla.config.isUser()},Salla.config.languages=async function(){var e;if(Salla.config.triedToGetLanguages_)return Salla.config.get("languages");Salla.config.triedToGetLanguages_=true;var t=true,a=[];return null==(e=await salla.document.api.request("languages",null,"get"))||null==(e=e.data)||e.map((function(e){t&&(a=[],t=false),e.code=e.code||e.iso_code,e.url=salla.url.get(e.code),e.is_rtl=e.is_rtl||e.rtl,a.push(e);})),Salla.config.set("languages",a),a},Salla.config.currencies=async function(){var e;if(Salla.config.triedToGetCurrencies_)return Salla.config.get("currencies");Salla.config.triedToGetCurrencies_=true;var t=true,a={};return null==(e=await salla.currency.api.list())||null==(e=e.data)||e.map((function(e){t&&(a={},t=false),e.country_code=e.code.substr(0,2).toLowerCase(),a[e.code]=e;})),Salla.config.set("currencies",a),a},Salla.config.isMobileApp=function(){var e;return ["ios","android"].includes(null==(e=Salla.analytics)||null==(e=e.jitsuAnalytics)||null==(e=e.getContextProperty("app"))||null==(e=e.platform)?void 0:e.toLowerCase())};var N=function(e){function a(t,a){var n;return (n=e.call(this,t,a)||this).options={path:".infinite-scroll-btn",history:"push",status:".infinite-scroll-status",append:".list-block"},n.fetchOptions={headers:{"S-INFINITE-SCROLL":true,"S-Source":"twilight","cache-control":"no-cache",pragma:"no-cache"}},n.instances=[],n}g(a,e);var n=a.prototype;return n.initiate=function(e,a,n,r){ void 0===r&&(r=false),r?((n=n||{}).fetchOptions=f({},this.fetchOptions,n.fetchOptions||{}),n.responseBody="json"):n=this.getCustomOptions(a,n);var i="string"!=typeof e?e:document.querySelector(e),o=n.path;if(i&&o&&("string"!=typeof o||document.querySelector(o))){var u=new t$1(i,n);return u.on("scrollThreshold",Salla.infiniteScroll.event.scrollThreshold),u.on("request",Salla.infiniteScroll.event.request),u.on("load",Salla.infiniteScroll.event.load),u.on("append",Salla.infiniteScroll.event.append),u.on("error",Salla.infiniteScroll.event.error),u.on("last",Salla.infiniteScroll.event.last),u.on("history",Salla.infiniteScroll.event.history),this.instances.push(u),u}Salla.logger.warn(i?"Path Option (a link that has next page link) Not Existed!":"Container For InfiniteScroll not Existed!");},n.getCustomOptions=function(e,t){return (t="object"==typeof e&&e||t||this.options).fetchOptions=this.fetchOptions,t.path=t.path||this.options.path,t.button=t.button||t.path,t.status=t.status||this.options.status,t.hasOwnProperty("history")||(t.history=this.options.history),t.nextPage=t.nextPage||t.next_page,t.append="string"==typeof e&&e||t.append||this.options.append,t},n.loadNextPage=function(e){("string"!=typeof e?e:document.querySelector(e)).loadNextPage();},n.destroy=function(e){("string"!=typeof e?e:document.querySelector(e)).destroy();},a}(c),M=function(){function e(){}var t=e.prototype;return t.submit=async function(e,t){var a,n;void 0===t&&(t=null);var r=t;if("SubmitEvent"===(null==(a=t)||null==(a=a.constructor)?void 0:a.name)||"submit"===(null==(n=t)?void 0:n.type)){var i,o;if(t.preventDefault(),"FORM"!==(null==(i=t.target)?void 0:i.tagName))return Salla.logger.warn("Failed find the target element for submit action. make sure you submit a form element"),new Promise((function(){throw "Failed find the target element for submit action. make sure you submit a form element"}));"SALLA-BUTTON"===(null==(o=t)||null==(o=o.submitter)||null==(o=o.parentElement)?void 0:o.tagName)&&t.submitter.parentElement.load(),r=t.target.getElementSallaData(),salla.log("Data from element",r);}if(/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/gm.test(e))return salla.api.request(e,r,"post").finally((function(){var e;loaderSupported&&(null==(e=t)||null==(e=e.submitter)||e.parentElement.stop());}));var u=e.split("."),s=u.splice(-1);return await salla.call(u.join("."))[s](r).finally((function(){var e;return null==(e=t)||null==(e=e.submitter)||null==(e=e.parentElement)?void 0:e.stop()})).catch((function(e){throw salla.logger.warn(e),e}))},t.onSubmit=function(e,t){return salla.form.submit(e,t),false},t.onChange=function(e,t){var a;return null!=t&&t.currentTarget?"FORM"!==(null==t||null==(a=t.currentTarget)?void 0:a.tagName)||t.currentTarget.checkValidity()?(salla.form.submit(e,t.currentTarget.getElementSallaData()),true):(salla.logger.warn("Trying to trigger '"+e+"' without filling required fields!"),false):(salla.logger.warn("Trying to trigger '"+e+"' without event!"),false)},t.getPossibleValue=function(e,t,a){if(void 0===a&&(a=false),e){if("object"!=typeof e)return e;for(var n,r=0;r<t.length&&!(n=e[t[r]])&&!("undefined"!=typeof FormData&&e instanceof FormData&&(n=e.get(t[r])));r++);return "object"!=typeof(n=n||e)||a?n:void 0}},e}(),H=function(e){function t(t){var a;return (t=t||{}).messages=t.messages||window.translations,t.locale=t.locale||(window.locale||navigator.language||navigator.userLanguage||"ar").split("-")[0],t.fallback=t.fallback||t.locale,(a=e.call(this,t)||this).translationsLoaded=false,a}g(t,e);var a=t.prototype;return a.onLoaded=function(e){var t=this;return new Promise((function(a){if(t.translationsLoaded)return a(e?e():null);Salla.event.once("languages::translations.loaded",(function(){return a(e?e():null)}));}))},a.loadStoreTranslations=function(){if(this.hash=salla.config.get("theme.translations_hash",salla.config.get("store.id","twilight")),this.message||(salla.log("try to load translations from localstorage"),this.messages=salla.storage.get("s_translations."+this.hash),this.messages&&(this.translationsLoaded=true)&&e.prototype.setMessages.call(this,this.messages)),this.messages)return salla.event.dispatch("languages::translations.loaded"),void salla.logger.info("The messages of transactions is already loaded");salla.url.get("")?this.loadScript(salla.url.get("languages/assets/"+this.hash+".js")):this.loadScript("https://cdn.salla.network/js/translations.js",false);},a.setMessages=function(t){e.prototype.setMessages.call(this,t),salla.event.dispatch("languages::translations.loaded"),this.translationsLoaded=true;},a.loadScript=function(e,t){var a=this;void 0===t&&(t=true);var n=document.createElement("script");n.src=e,n.onload=function(){var e;if(window.translations)return salla.storage.remove("s_translations"),salla.storage.set("s_translations",((e={})[a.hash]=window.translations,e)),a.setMessages(window.translations);n.onerror();},n.onerror=function(){if(t)return salla.logger.warn("Failed to load Translations for store, lets try load it from CDN"),a.loadScript("https://cdn.salla.network/js/translations.js",false);salla.logger.error("Failed to load Translations, check your network logs for more details\nor: salla.lang.setMessages({....}), see https://docs.salla.dev for more information's.");},document.head.appendChild(n);},a.getWithDefault=function(e,t,a,n){var r=this.get(e,a,n);return r!==e?r:t},a.get=function(t,a,n){var r=t;(window.translations||this.translationsLoaded)&&(r="trans."+t);var i=e.prototype.get.call(this,r,a,n);return i!==r?i:e.prototype.get.call(this,r,a,"en").replace(r,t)},a.set=function(e,t){return salla.helpers.setNested(this.messages[this.getLocale()+".trans"],e,t),this},a.add=function(e,t){var a=this;return Object.entries(t).forEach((function(t){return salla.helpers.setNested(a.messages[t[0]+".trans"],e,t[1])})),this},a.addBulk=function(e){var t=this;return Object.entries(e).forEach((function(e){var a=e[0],n=e[1];t.add(a,n);})),this},t}(a$3),V=function(){function e(){this.endpoints={},this.webEndpoints=[],this.namespace="BaseApi",this.endpointsMethods={},this.endpointsHeaders={};var e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&e.length>1?e[1]:"").toLowerCase(),this.debounce={request:void 0,time:300,enabled:true,exclude:[]};}var t=e.prototype;return t.after_init=function(){},t.normalRequest=function(e,t,a){ void 0===t&&(t=void 0),void 0===a&&(a=null);var n=Array.isArray(e),r=n?this.getUrl.apply(this,e):this.getUrl(e);e=n?e[0]:e,a=a||this.endpointsMethods[e]||"post";var i=this.endpointsHeaders[e];if("get"===a&&t instanceof FormData){var o={};Array.from(t.entries()).forEach((function(e){o[e[0]]=e[1];})),t={params:o};}return i&&"get"===a&&(t=t?Object.assign(t,i):i),this.webEndpoints.includes(e)?r=salla.url.get(r):"http"!==r.substring(0,4)&&(r=salla.url.api(r)),Salla.api.request(r,t,a,{headers:i})},t.request=function(e,t,a){return void 0===t&&(t=void 0),void 0===a&&(a=null),!salla.api.isFastRequestsAllowed()&&this.debounce.enabled?(this.debounce.request||(this.debounce.request=salla.helpers.debounce(this.normalRequest.bind(this),this.debounce.time)),this.debounce.request(e,t,a)):this.normalRequest(e,t,a)},t.getUrl=function(e){for(var t=this.endpoints[e]||e,a=/{[^{}]+}/i,n=1;n<arguments.length;n++)t=t.replace(a,arguments[n]);return t},t.event=function(){return salla.event[this.className]},e}(),G=function(e){function t(){var t;return (t=e.call(this)||this).addToCartTries=0,t.guestCartAssigned=false,t.namespace="cart",t._pendingCartIdRequest=null,t._pendingAssignRequest=null,t.endpoints={latest:"cart/latest",latestApi:"cart/latest",details:"cart/{cart}",quickAdd:"cart/{cart}/item/{product}/quick-add",addItem:"cart/{cart}/item/{product}/add",deleteItem:"cart/{cart}/item/{item}",updateItem:"cart/{cart}/item/{item}",deleteImage:"cart/{cart}/image/{image}",uploadImage:"cart/{cart}/image",status:"cart/{cart}/status",addCoupon:"cart/{id}/coupon",deleteCoupon:"cart/{id}/coupon",getQuickOrderSettings:"checkout/quick-order",createQuickOrder:"checkout/quick-order",priceQuote:"cart/{cartId}/price-quote",offers:"offers/cart/{cartId}",giftCartDetails:"cart/{cartId}/buy-as-gift",cartGiftToCart:"cart/{cart_id}/buy-as-gift",assign:"cart/{cartId}/assign?merge=1"},t.endpointsMethods={latest:"get",details:"get",status:"get",updateItem:"post",deleteItem:"delete",deleteImage:"delete",deleteCoupon:"put",getQuickOrderSettings:"get",offers:"get",giftCartDetails:"get"},t.webEndpoints=["latest"],t.latestCart=null,t.after_init(),salla.event.on("api::initiated",(function(){return salla.api.cart.getCurrentCartId(false,"api::initiated")})),salla.event.on("auth::token.fetched",t._checkCurrentCart),salla.event.on("auth::token.invalid",t._checkCurrentCart),salla.event.on("auth::verified",(async function(){try{await Salla.api.cart.assign();}catch(e){Salla.log("Error on assign after verified",e);}return Salla.api.cart.getCurrentCartId(true,"auth::verified")}),{async:true}),salla.event.on("twilight::initiated",(function(){return salla.api.cart.syncGuestCart()})),salla.event.on("profile::info.fetched",(function(){return t._checkCurrentCart(true)})),salla.event.on("twilight::error",(function(e){return (e.includes("Cart not available")||e.includes("السلة غير متاحة"))&&salla.cart.api.reset()})),t}g(t,e);var a=t.prototype;return a._checkCurrentCart=function(e){var t,a;void 0===e&&(e=false);var n=salla.storage.get("cart"),r=null==(t=salla.config.get("user"))?void 0:t.id,i=null==(a=salla.config.get("store"))?void 0:a.id;n&&n.id&&!e&&(n.user_id===r&&n.store_id===i||(salla.log("cart",{user_id:n.user_id,store_id:n.store_id}),salla.log("current",{user_id:r,store_id:i}),salla.log("Api:: case2 => The cart is not belong to current "+(n.user_id!==r?"user":"store")+"!"),salla.cart.api.reset()),salla.url.is_page("cart")&&n.id!==salla.config.get("page.id")&&(salla.log("cart",{user_id:n.user_id,store_id:n.store_id}),salla.log("current",{user_id:r,store_id:i}),salla.log("Api:: case2 => The cart is different between storage:"+n.id+" & session:"+salla.config.get("page.id")+" !"),salla.cart.api.reset()));},a.getCurrentCartId=async function(e,t){if(void 0===e&&(e=false),void 0===t&&(t="getCurrentCartId"),Salla.cart.api._pendingCartIdRequest)return Salla.cart.api._pendingCartIdRequest;Salla.cart.api._pendingCartIdRequest=async function(){try{if(!e){if(Salla.cart.api.latestCart)return Salla.cart.api.latestCart.cart.id;var a=Salla.storage.get("cart.id");if(a)return a}var n=await Salla.cart.api.latest(t);return Salla.cart.api.latestCart=n.data,Salla.cart.api.latestCart.cart.id}finally{Salla.cart.api._pendingCartIdRequest=null;}}();var a=Salla.cart.api._pendingCartIdRequest;return Salla.cart.api._pendingCartIdRequest=null,a},a.getUploadImageEndpoint=function(e){return salla.url.api(this.getUrl("uploadImage",e||salla.storage.get("cart.id")))},a.latest=function(e){return void 0===e&&(e="direct"),this.request(salla.auth.api.isSessionless()?"latestApi":"latest",{params:{source:"",callerName:e}}).then((function(e){return salla.api.cart.set(e.data.cart),salla.event.cart.latestFetched(e),e})).catch((function(e){throw salla.api.cart.reset(),salla.event.cart.latestFailed(e),e}))},a.details=async function(e,t){return void 0===t&&(t=[]),e=e||await salla.api.cart.getCurrentCartId(false,"salla.api.cart.details"),this.request(["details",e],{params:{with:t}}).then((function(e){return salla.cart.event.detailsFetched(e),e})).catch((function(e){throw salla.cart.event.detailsNotFetched(e),e}))},a.quickAdd=async function(e,t,a){return this.addItem({id:e,quantity:t,offerType:a,endpoint:"quickAdd"})},a.addItem=async function(e){var t=this.getCartPayload(e);if(!t.id){var a='There is no product "id"!';return salla.cart.event.itemAddedFailed(a),salla.api.errorPromise(a)}var n=salla.form.getPossibleValue(t.payload,["endpoint"]);n&&["addItem","quickAdd"].includes(n)||(n=salla.form.getPossibleValue(t.payload,["quantity","donating_amount"])?"addItem":"quickAdd");var r=await Salla.api.cart.getCurrentCartId(false,"salla.api.cart.addItem");try{t.payload=Salla.helpers.createFormDataWrapper(t.payload||{}),await Salla.cart.event.beforeAddItem(t);}catch(e){}return this.request([n,r,t.id],t.payload.getRawData()).then((function(e){Salla.cart.api.addToCartTries=0;try{Salla.cart.event.itemAdded(e,t.id);}catch(e){Salla.log(e);}return e})).catch((function(a){if(!Salla.cart.api.addToCartTries)return Salla.cart.api.addToCartTries++,Salla.cart.reset(),Salla.cart.api.addItem(e);throw Salla.cart.event.itemAddedFailed(a,t.id),a}))},a.deleteItem=async function(e){var t=this.getCartPayload(e);if(!t.id){var a='There is no "id"!';return salla.cart.event.itemDeletedFailed(a),salla.api.errorPromise(a)}var n=await salla.api.cart.getCurrentCartId(false,"salla.api.cart.deleteItem");return this.request(["deleteItem",n,t.id]).then((function(e){return salla.cart.event.itemDeleted(e,t.id),e})).catch((function(e){throw salla.cart.event.itemDeletedFailed(e,t.id),e}))},a.updateItem=async function(e){var t,a=this.getCartPayload(e);if(!a.id){var n='There is no "id"!';return salla.cart.event.itemUpdatedFailed(n),salla.api.errorPromise(n)}var r=await salla.api.cart.getCurrentCartId(false,"salla.api.cart.updateItem");return "Object"===(null==(t=a.payload.constructor)?void 0:t.name)?a.payload._method="PUT":a.payload.append("_method","PUT"),this.request(["updateItem",r,a.id],a.payload).then((function(e){return salla.cart.event.itemUpdated(e,a.id),e})).catch((function(e){throw salla.cart.event.itemUpdatedFailed(e,a.id),e}))},a.deleteImage=async function(e){if(!(e=salla.form.getPossibleValue(e,["id","image_id","photo_id"]))){var t='There is no "id"!';return salla.cart.event.imageNotDeleted(t),salla.api.errorPromise(t)}var a=await salla.api.cart.getCurrentCartId(false,"salla.api.cart.deleteImage");return this.request(["deleteImage",a,e]).then((function(t){return salla.cart.event.imageDeleted(t,e),t})).catch((function(t){throw salla.cart.event.imageNotDeleted(t,e),t}))},a.status=async function(e,t){ void 0===t&&(t=false),e=e||await salla.api.cart.getCurrentCartId(false,"salla.api.cart.status");var a={has_apple_pay:salla.helpers.hasApplePay()};t&&(a.guest_checkout=1);try{await salla.cart.event.submitting();}catch(e){salla.log("Error on: salla.cart.event.submitting()");}return this.request(["status",e],{params:a})},a.submit=async function(e,t){if(void 0===e&&(e=false),void 0===t&&(t=false),console.log("salla.cart.api.submit",{isGuestCheckout:e}),salla.config.isGuest()&&!e)return salla.log("it looks that the current user is not logged-in, lets login then submit"),salla.cart.loginOnCartPage();var a;if(t)try{var n,r=await Salla.api.cart.assign();a=null==r||null==(n=r.data)?void 0:n.cart_id;}catch(e){Salla.log("Error on assign after login from submit",e);}this.status(null!=a?a:await salla.api.cart.getCurrentCartId(false,"salla.api.cart.submit"),e).then((function(e){var t,a=null==(t=e.data.next_step)?void 0:t.to;if(a||(window.history.pushState({},"",salla.url.addParamToUrl("reload","empty_next_step")),window.history.pushState({},"",salla.url.addParamToUrl("acitve",false===e.data.active?"false":"true_or_undfined")),salla.cart.reset(),window.location.reload()),!["checkout","refresh","login"].includes(a)){var n="Can't find next_step );";throw salla.cart.reset(),salla.cart.event.submitFailed(n),n}return salla.cart.event.submitted(e),"login"===a?salla.cart.loginOnCartPage():"checkout"===a?window.location.href=e.data.next_step.url+(salla.helpers.hasApplePay()?"?has_apple_pay=true":""):(window.history.pushState({},"",salla.url.addParamToUrl("reload","refresh")),void window.location.reload())})).catch((function(e){var t;salla.cart.api.tries=salla.cart.api.tries||0,salla.cart.reset();var a=404===(null==e||null==(t=e.response)||null==(t=t.data)?void 0:t.status);if(a&&0===salla.cart.api.tries)return salla.cart.api.tries++,salla.log("we recived that the current cart is not found, we will try to re-submit one more time"),salla.cart.submit();throw a&&salla.error(salla.lang.get("pages.checkout.try_again")),salla.cart.event.submitFailed(e),e}));},a.getCartPayload=function(e){var t,a=(null==(t=e)?void 0:t.data)||("object"==typeof e?e:void 0);return {id:e=a?salla.form.getPossibleValue(a,["prod_id","product_id","item_id","id"]):e,payload:a="object"==typeof a?a:void 0}},a.normalRequest=function(t,a,n){var r=this;return void 0===a&&(a=void 0),void 0===n&&(n=null),e.prototype.normalRequest.call(this,t,a,n).catch((async function(e){var t;throw 403===(null==e||null==(t=e.response)?void 0:t.status)&&(r.reset(),salla.error(salla.lang.get("pages.checkout.try_again"))),e}))},a.reset=function(){salla.api.cart.latestCart=null,salla.storage.remove("cart"),salla.cookie.clearCookieByPrefix(salla.api.cart.getCartCookiePrefix()),salla.cart.event.successReset();},a.addCoupon=async function(e){if(e=e.data||e,!(e=salla.form.getPossibleValue(e,["coupon"]))){var t=new Error('There is no "Coupon Code"!');return t.name="EmptyCoupon",salla.event.cart.couponAdditionFailed(t),salla.api.errorPromise(t)}var a=await salla.cart.api.getCurrentCartId(false,"salla.api.cart.addCoupon");return this.request(["addCoupon",a],{coupon:e}).then((function(e){var t,n=salla.storage.get("cart");return n&&null!=(t=e.data)&&null!=(t=t.cart)&&t.coupon&&(n.coupon=e.data.cart.coupon,salla.storage.set("cart",n)),salla.event.cart.couponAdded(e,a),e})).catch((function(e){throw salla.event.cart.couponAdditionFailed(e,a),e}))},a.deleteCoupon=async function(){var e=await salla.cart.api.getCurrentCartId(false,"salla.api.cart.deleteCoupon");return this.request(["deleteCoupon",e],{}).then((function(t){var a=salla.storage.get("cart");return a&&a.coupon&&(delete a.coupon,salla.storage.set("cart",a)),salla.event.cart.couponDeleted(t,e),t})).catch((function(t){throw salla.event.cart.couponDeletionFailed(t,e),t}))},a.getQuickOrderSettings=function(){return this.request("getQuickOrderSettings").then((function(e){return salla.event.cart.quickOrderSettingFetched(e),e})).catch((function(e){throw salla.event.cart.quickOrderSettingFailed(e),e}))},a.createQuickOrder=function(e){return this.request("createQuickOrder",e).then((function(e){return salla.event.cart.quickOrderSucceeded(e),e})).catch((function(e){throw salla.event.cart.quickOrderFailed(e),e}))},a.priceQuote=async function(e){return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("cart::priceQuote",e),void salla.event.dispatch("login::open")):this.request(["priceQuote",e||await salla.api.cart.getCurrentCartId(false,"salla.api.cart.priceQuote")]).then((function(e){return salla.cart.api.reset(),salla.event.cart.priceQuoteSucceeded(e).then((function(){return setTimeout((function(){return window.location.href=salla.url.get("/")}),1e3),e}))})).catch((function(e){return salla.event.cart.priceQuoteFailed(e).then((function(){var t;throw 404===(null==(t=e.error)?void 0:t.code)&&window.location.reload(),e}))}))},a.loginOnCartPage=function(){salla.auth.setCanRedirect(false),salla.event.dispatch("login::open",{withoutReload:true,source:"cart-submit"}),salla.auth.event.onLoggedIn((function(){salla.event.dispatch("login::close"),salla.cart.submit(false,true);}));},a.set=function(e){salla.storage.set("cart",e),salla.api.cart.syncGuestCart();},a.offers=async function(){var e=await salla.cart.api.getCurrentCartId(false,"salla.api.cart.offers");return this.request(["offers",e]).then((function(e){return salla.event.cart.offersFetched(e),e})).catch((function(e){throw salla.event.cart.offersFailed(e),e}))},a.getGiftCartDetails=async function(){var e=await salla.api.cart.getCurrentCartId(false,"salla.api.cart.getGiftCartDetails");return this.request(["giftCartDetails",e]).then((function(t){return salla.product.event.giftFetched(t,e),t})).catch((function(t){throw salla.product.event.giftFetchFailed(t,e),t}))},a.addCartGiftToCart=async function(e,t){ void 0===t&&(t=false);var a=await salla.api.cart.getCurrentCartId(false,"salla.api.cart.addCartGiftToCart");return this.request(["cartGiftToCart",a],e).then((function(e){return salla.product.event.addGiftToCartSucceeded(e,a),t&&(window.location.href=e.redirect),e})).catch((function(e){throw salla.product.event.addGiftToCartFailed(e,a),e}))},a.syncGuestCart=async function(){if(salla.config.isGuest()){var e=salla.api.cart.getCartCookiePrefix(),t=salla.cookie.getCookieByPrefix(e),a=salla.storage.get("cart.id");if(!a&&t.length)try{var n,r=null==(n=(await salla.api.cart.latest()).data)||null==(n=n.cart)?void 0:n.id;r&&salla.api.cart.setCartCookie(e,r);}catch(e){salla.log("Failed to fetch latest cart:",e);}salla.cookie.clearCookieByPrefix(e),a&&(salla.config.set("headers.s-cart-id",a),salla.api.cart.setCartCookie(e,a));}},a.assign=async function(){var e=this;if(Salla.api.cart._pendingAssignRequest)return Salla.api.cart._pendingAssignRequest;var t=Salla.storage.get("cart.id");return !(!t||Salla.api.cart.guestCartAssigned)&&(Salla.api.cart._pendingAssignRequest=async function(){try{var a=await e.request(["assign",t]);return Salla.api.cart.guestCartAssigned=true,a}catch(e){throw e}finally{Salla.api.cart._pendingAssignRequest=null;}}(),Salla.api.cart._pendingAssignRequest)},a.setCartCookie=function(e,t){salla.cookie.set(e+"-"+t,t,1);},a.getCartCookiePrefix=function(){return "cart-id-"+salla.config.get("store.id")},t}(V),z=function(e){function t(){var t;return (t=e.call(this)||this).namespace="loyalty",t.endpoints={getProgram:"loyalty",exchange:"loyalty/exchange",reset:"loyalty/exchange"},t.endpointsMethods={getProgram:"get",reset:"put"},t.after_init(),t}g(t,e);var a=t.prototype;return a.getProgram=function(){return this.request("getProgram").then((function(e){return salla.loyalty.event.programFetched(e),e})).catch((function(e){throw salla.loyalty.event.programNotFetched(e),e}))},a.exchange=async function(e,t){if(void 0===t&&(t=null),!(e=salla.form.getPossibleValue(e,["id","loyalty_prize_id","prize_id"]))){var a="Unable to find cart id. Please provide one.";return salla.loyalty.event.exchangeFailed(a),salla.api.errorPromise(a)}if(!(t=t||await salla.cart.getCurrentCartId(false,"salla.api.loyalty.exchange"))){var n="Unable to find cart id. Please provide one.";return salla.loyalty.event.exchangeFailed(n),salla.api.errorPromise(n)}return this.request("exchange",{loyalty_prize_id:e,cart_id:t}).then((function(t){return salla.loyalty.event.exchangeSucceeded(t,e),t})).catch((function(t){throw salla.loyalty.event.exchangeFailed(t,e),t}))},a.reset=async function(e){if(void 0===e&&(e=null),!(e=e||await salla.cart.getCurrentCartId(false,"salla.api.loyalty.reset"))){var t="Unable to find cart id. Please provide one.";return salla.loyalty.event.resetFailed(t),salla.api.errorPromise(t)}return this.request("reset",{cart_id:e}).then((function(e){return salla.loyalty.event.resetSucceeded(e),e})).catch((function(e){throw salla.loyalty.event.resetFailed(e),e}))},t}(V),W=function(e){function t(){var t;return (t=e.call(this)||this).namespace="auth",t.canRedirect_=true,t.afterLoginEvent={event:null,payload:null},t.endpoints={login:"auth/{type}/send_verification",resend:"auth/resend_verification",verify:"auth/{type}/verify",register:"auth/register",logout:"logout",refresh:"auth/refresh"},t.webEndpoints=["logout","auth/jwt","refresh"],t.endpointsMethods={logout:"get"},t.inIframe=salla.helpers.isIframe(),Salla.event.on("twilight::init",(function(){if(Salla.config.isGuest()&&location.href.includes("force_logout"))return delete Salla.api.axios.defaults.headers.common.Authorization,Salla.api.auth.logout("twilight",false)})),t.after_init(),t}g(t,e);var a=t.prototype;return a.setAfterLoginEvent=function(e,t){salla.api.auth.afterLoginEvent={event:e,payload:t};},a.setCanRedirect=function(e){salla.api.auth.canRedirect_=e;},a.canRedirect=function(){return salla.api.auth.canRedirect_&&!salla.api.auth.afterLoginEvent.event},a.login=function(e){var t;null!=(t=e)&&t.data&&(e=e.data);var a=salla.form.getPossibleValue(e,["type"]);if(!["email","mobile"].includes(a)){var n="Login type should be in: [email, mobile]";return salla.auth.event.codeNotSent(n),salla.api.errorPromise(n)}return this.request(["login",a],e).then((function(e){return salla.auth.event.codeSent(e,a),e})).catch((function(e){throw salla.auth.event.codeNotSent(e,a),salla.auth.api.trackBlockedError(e,"login"),e}))},a.verify=async function(e,t){ void 0===t&&(t=true);var a=salla.form.getPossibleValue(e,["type"]);if(!a){var n="Failed to know what's login type!";return salla.auth.event.verificationFailed(n),salla.api.errorPromise(n)}t=false!==salla.form.getPossibleValue(e,["supportWebAuth"])&&t,salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event);var r=await salla.auth.api.request(["verify",a],e);return 200!==(null==r?void 0:r.status)?(salla.auth.event.verificationFailed(r,a),salla.api.errorPromise(r)):salla.auth.api.handlAfterAuthenticatedResponse(r,t)},a.handlAfterAuthenticatedResponse=async function(e,t){var a;e.data||(e={data:e});var n="authenticated"===(null==(a=e.data)?void 0:a.case);return n&&salla.auth.event.tokenFetched(e.data.token),t&&!this.inIframe&&!this.isSessionless()&&await salla.auth.api.request("auth/jwt",{callerName:"salla.auth.api.handlAfterAuthenticatedResponse"}),n&&await salla.auth.event.loggedIn(e).then((function(){return salla.auth.api.afterUserLogin()})),await salla.auth.event.verified(e,e.data.verification.type),salla.api.successPromise(e)},a.resend=function(e){var t;return (e=e.data||e).type=e.type||"mobile","mobile"!==e.type||e.phone&&e.country_code?"email"!==e.type||e.email?this.request("resend",e).then((function(t){return salla.auth.event.codeSent(t,e),t})).catch((function(t){throw salla.auth.event.codeNotSent(t,e),salla.auth.api.trackBlockedError(t,"resend"),t})):(salla.auth.event.codeNotSent(t="There is no email!",e),salla.api.errorPromise(t)):(salla.auth.event.codeNotSent(t="There is no phone or country_code!",e),salla.api.errorPromise(t))},a.register=function(e){var t,a=this;return e.data&&(t=e.element,e=e.data),salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event),this.request("register",e).then((async function(e){var n;return salla.auth.event.registered.call(t,e),"authenticated"===(null==(n=e.data)?void 0:n.case)&&(salla.auth.event.tokenFetched(e.data.token),!a.inIframe&&!a.isSessionless()&&await salla.auth.request("auth/jwt",{callerName:"salla.auth.api.register"}),salla.auth.event.loggedIn(e),salla.auth.api.afterUserLogin()),e})).catch((function(e){throw salla.auth.event.registrationFailed.call(t,e),salla.auth.api.trackBlockedError(e,"register"),e}))},a.handleIframeReadyAction=function(e,t){var a;null==(a=e.contentWindow)||a.postMessage({source:"logout",type:"init",data:{id:salla.config.get("store.id"),lang:"ar",appUrl:t,apiUrl:salla.config.get("store.api").replace(/\/+$/,""),settings:salla.config.all(),storage:{}}},"*");},a.appendIframeAndLogout=function(){var e=this;return new Promise((function(t){var a=salla.config.get("login.url","https://accounts.salla.com"),n=document.createElement("iframe");n.style.display="none",n.src=a+"/logout";var r=function(i){if("login"===i.data.source){var o=i.data.type.replace("iframe::","");if(salla.log("iframe::logout-iframe message received",i.data),["logged-out","ready"].includes(o)){if("ready"===o)return e.handleIframeReadyAction(n,a);window.removeEventListener("message",r),n.remove(),t();}}};window.addEventListener("message",r),document.body.appendChild(n);}))},a.logout=function(e,t){var a=this;return void 0===e&&(e="twilight"),void 0===t&&(t=true),salla.storage.clearAll(),salla.cookie.clearAll(),e=encodeURI(e),salla.auth.event.loggedOut().then((function(){return a.appendIframeAndLogout()})).then((function(){if(t){var a=salla.url.get("logout?from="+e);console.log("Going to "+a+", to do any thing before this action use: salla.auth.even.onLoggedOut(()=>{...})");try{location.href=a;}catch(e){salla.log(e);}}})).catch((function(e){return console.error("Error during logout:",e)}))},a.refresh=function(){return this.request("refresh").then((function(e){return salla.auth.event.tokenFetched(e.data.token),e})).catch((function(e){throw salla.auth.event.refreshFailed(e),e}))},a.afterUserLogin=function(){this.afterLoginEvent.event&&salla.event.emit(this.afterLoginEvent.event,this.afterLoginEvent.payload);},a.isSessionless=function(){return "sessionless"===salla.config.get("auth.mode")},a.trackBlockedError=function(e,t){var a;void 0===(null==e||null==(a=e.response)||null==(a=a.headers)?void 0:a["s-ray"])&&salla.analytics.track("BlockedByProxy",{class:"auth",function:t,reason:"non-server-request",message:e.message});},t}(V),Q=function(e){function t(){var t;return (t=e.call(this)||this).namespace="order",t.endpoints={cancel:"orders/cancel/{id}",createCartFromOrder:"reorder/{id}",reorderProduct:"reorder/product/{id}",sendInvoice:"orders/send/{id}",fetch:"orders"},t.endpointsMethods={createCartFromOrder:"get",fetch:"get"},t.after_init(),t}g(t,e);var a=t.prototype;return a.show=function(e){var t=salla.form.getPossibleValue((null==e?void 0:e.data)||e,["id","order_id"]);salla.event.dispatch("mobile::order.placed",{order_id:t}),location.href=salla.form.getPossibleValue((null==e?void 0:e.data)||e,["url"]);},a.cancel=function(e){return e=e||Salla.config.get("page.id"),this.request(["cancel",e],{params:{has_apple_pay:salla.helpers.hasApplePay()}}).then((function(t){return salla.event.order.canceled(t,e),t})).catch((function(t){throw salla.event.order.notCanceled(t,e),t}))},a.createCartFromOrder=function(e){return e=e||salla.config.get("page.id"),this.request(["createCartFromOrder",e]).then((function(t){return salla.cart.reset(),salla.event.order.orderCreated(t,e),window.location.href=t.data.url,t})).catch((function(t){throw salla.event.order.orderCreationFailed(t,e),t}))},a.reorderProduct=function(e){return e=e||salla.config.get("page.id"),this.request(["reorderProduct",e]).then((function(t){var a=f({},t.data,{type:"reorder",id:e}),n=f({},t,{data:a});return salla.event.order.orderCreated(n,t.data.order_id),window.location.href=t.data.url,t})).catch((function(t){throw salla.event.order.orderCreationFailed(t,e),t}))},a.sendInvoice=function(e){var t=salla.form.getPossibleValue(e,["id"])||salla.config.get("page.id");if(!t||isNaN(t)){var a="There is no id!";return salla.order.event.invoiceNotSent(a),salla.api.errorPromise(a)}return this.request(["sendInvoice",t],e).then((function(e){return salla.event.order.invoiceSent(e,t),e})).catch((function(e){throw salla.event.order.invoiceNotSent(e,t),e}))},a.fetch=function(e){return this.request(["fetch"],{params:e}).then((function(e){return salla.event.order.ordersFetched(e),e})).catch((function(e){throw salla.event.order.ordersNotFetched(e),e}))},t}(V),K=function(e){function t(){var t;return (t=e.call(this)||this).namespace="product",t.previousQuery="",t.endpoints={getPrice:"products/{id}/price",availabilitySubscribe:"products/{id}/availability-notify",search:"products/search",details:"products/{product_id}/details",categories:"products/categories/{?id}",offers:"products/{product_id}/specialoffer",getSizeGuides:"products/{prod_id}/size-guides",giftProductDetails:"products/{product_id}/buy-as-gift",productGiftToCart:"products/{product_id}/buy-as-gift",giftImage:"products/buy-as-gift/image",buyNow:"products/{product_id}/buy-now",fetch:"products",fetchOptions:"products/options"},t.endpointsMethods={details:"get",giftProductDetails:"get",fetch:"get",offers:"get",fetchOptions:"get"},t.after_init(),t}g(t,e);var a=t.prototype;return a.getPrice=function(e){var t=e.data||e,a=salla.form.getPossibleValue(t,["id","prod_id","product_id"]);return this.request(["getPrice",a],"object"==typeof t?t:void 0).then((function(e){return salla.product.event.priceUpdated(e,a),e})).catch((function(e){throw salla.product.event.priceUpdateFailed(e,a),e}))},a.categories=function(e){return this.request(["categories",e||""],null,"get").then((function(e){return salla.product.event.categoriesFetched(e),e})).catch((function(e){throw salla.product.event.categoriesFailed(e),e}))},a.availabilitySubscribe=function(e){var t=e.data||e;return e=salla.form.getPossibleValue(t,["id","prod_id"]),this.request(["availabilitySubscribe",e],"object"==typeof t?t:void 0).then((function(t){return salla.product.event.availabilitySubscribed(t,e),t})).catch((function(t){throw salla.product.event.availabilitySubscribeFailed(t,e),t}))},a.search=function(e){var t,a=e.data;if(a||(a={params:"string"==typeof e?{query:e}:e}),!(e=a instanceof FormData?a.get("query"):a.query||(null==(t=a.params)?void 0:t.query))){var n='There is no "query"!';return salla.product.event.searchFailed(n),salla.api.errorPromise(n)}if(e===salla.api.product.previousQuery){var r="Query is same as previous one!";return salla.product.event.searchFailed(r),salla.api.product.previousQuery=null,salla.api.errorPromise(r)}return salla.api.product.previousQuery=e,this.request("search",a,"get").then((function(t){return salla.product.event.searchResults(t,e),t})).catch((function(t){throw salla.product.event.searchFailed(t,e),t}))},a.offers=function(e){var t;if(!(e=salla.form.getPossibleValue((null==(t=e)?void 0:t.data)|e,["product_id","id"]))){var a='There is no "product_id"!';return salla.product.event.fetchOffersFailed(a),salla.api.errorPromise(a)}return this.request(["offers",e]).then((function(t){return salla.product.event.offersFetched(t,e),t})).catch((function(t){throw salla.product.event.fetchOffersFailed(t,e),t}))},a.getSizeGuides=function(e){return this.request("products/"+e+"/size-guides",null,"get").then((function(t){return salla.product.event.sizeGuideFetched(t,e),t})).catch((function(t){throw salla.product.event.sizeGuideFetchFailed(t,e),t}))},a.getGiftProductDetails=function(e){return this.request(["giftProductDetails",e]).then((function(t){return salla.product.event.giftFetched(t,e),t})).catch((function(t){throw salla.product.event.giftFetchFailed(t,e),t}))},a.getDetails=function(e,t){if(void 0===t&&(t=[]),!Array.isArray(t)){var a="withItems should be array.";return salla.product.event.detailFetchFailed(a),salla.api.errorPromise(a)}if(!e){var n="productId is not passed.";return salla.product.event.detailFetchFailed(n),salla.api.errorPromise(n)}return this.request(["details",e],{params:{with:t}}).then((function(t){return salla.product.event.detailFetched(t,e),t})).catch((function(t){throw salla.product.event.availabilitySubscribeFailed(t,e),t}))},a.addProductGiftToCart=function(e,t,a){return void 0===a&&(a=false),this.request(["productGiftToCart",e],t).then((function(t){return salla.product.event.addGiftToCartSucceeded(t,e),a&&(window.location.href=t.redirect),t})).catch((function(t){throw salla.product.event.addGiftToCartFailed(t,e),t}))},a.uploadGiftImage=function(e){return this.request("giftImage",e).then((function(e){return salla.product.event.giftImageUploadSucceeded(e),e})).catch((function(e){throw salla.product.event.giftImageUploadFailed(e),e}))},a.fetch=function(e){if(!e.source){var t="Source cannot be empty. Please provide one.";return salla.product.event.productListFetchFailed(t),salla.api.errorPromise(t)}var a=!e.source_value,n="string"==typeof e.source_value&&"[]"===e.source_value,r=Array.isArray(e.source_value)&&!e.source_value.length;if((a||n||r)&&!["offers","latest","sales","wishlist","top-rated","reorder"].includes(e.source)){var i="Source value cannot be empty. Please provide one.";return salla.product.event.productListFetchFailed(i),salla.api.errorPromise(i)}if(["categories","brands","tags","selected"].includes(e.source)&&!Array.isArray(e.source_value)){var o="SourceValue type error. Expected an array.";return salla.product.event.productListFetchFailed(o),salla.api.errorPromise(o)}if("search"===e.source&&"string"!=typeof e.source_value){var u="SourceValue type error. Expected a string.";return salla.product.event.productListFetchFailed(u),salla.api.errorPromise(u)}if("related"===e.source&&isNaN(e.source_value)){var s="SourceValue type error. Expected a number.";return salla.product.event.productListFetchFailed(s),salla.api.errorPromise(s)}return this.request(this.endpoints.fetch,{params:e},"get").then((async function(e){return salla.product.event.productListFetchSucceeded(e),e})).catch((function(e){throw salla.product.event.productListFetchFailed(e),e}))},a.fetchOptions=function(e,t){if(void 0===t&&(t={}),!e||0===e.length){var a="At least one product ID is required. Please provide a valid list of product IDs.";return salla.product.event.productOptionsNotFetched(a),salla.api.errorPromise(a)}var n=t.with,r=void 0===n?[]:n,i={selected:e};return r.length>0&&(i.with=r),this.request(this.endpoints.fetchOptions,{params:i},"get").then((function(e){return salla.product.event.productOptionsFetched(e),e})).catch((function(e){throw salla.product.event.productOptionsNotFetched(e),e}))},t}(V),J=function(e){function t(){var t;return (t=e.call(this)||this).namespace="profile",t.endpoints={info:"auth/user",update:"profile/update",updateContacts:"profile/contacts/update",updateCustomFields:"profile/fields",updateSettings:"profile/settings",verify:"profile/verify",delete:"profile"},t.endpointsMethods={delete:"delete"},t.after_init(),t}g(t,e);var a=t.prototype;return a.syncUserData=function(e){var t={id:e.id,type:"user",email:e.email,mobile:e.phone.code+e.phone.number,country_code:e.phone.country,language_code:e.language,currency_code:e.currency,notifications:e.notifications,pending_orders:e.pending_orders,avatar:e.avatar,first_name:e.first_name,last_name:e.last_name,is_hidden_name:e.is_hidden_name,is_notifiable:e.is_notifiable,can_comment:salla.config.get("user.can_comment"),fetched_at:Date.now()};salla.config.set("user",t),salla.storage.set("user",t);},a.info=function(){var e=this;return this.request("info",null,"get").then((function(t){return e.syncUserData(t.data),salla.profile.event.infoFetched(t),t})).catch((function(e){throw salla.profile.event.infoNotFetched(e),e}))},a.update=function(e){var t=this;if(Salla.config.get("store.features",[]).includes("sso-login")){var a="SSO login is enabled. You cannot update your profile.";return Salla.error(a),Promise.reject(new Error(a))}return this.request("update",e).then((function(e){return t.syncUserData(e.data),salla.profile.event.updated(e),e})).catch((function(e){throw salla.event.profile.updateFailed(e),e}))},a.updateCustomFields=function(e){var t=this;if(Salla.config.get("store.features",[]).includes("sso-login")){var a="SSO login is enabled. You cannot update your profile.";return Salla.error(a),Promise.reject(new Error(a))}return this.request("updateCustomFields",e).then((function(e){return t.syncUserData(e.data),salla.profile.event.updated(e),e})).catch((function(e){throw salla.event.profile.updateFailed(e),e}))},a.updateContacts=function(e){return this.request("updateContacts",e).then((function(e){return salla.profile.event.verificationCodeSent(e),e})).catch((function(e){throw salla.event.profile.updateContactsFailed(e),e}))},a.verify=function(e){return this.request("verify",e).then((function(e){return salla.profile.event.verified(e),e})).catch((function(e){throw salla.event.profile.unverified(e),e}))},a.updateSettings=function(e){return this.request("updateSettings",e).then((function(e){return salla.event.profile.settingsUpdated(e),e})).catch((function(e){throw salla.event.profile.updateSettingsFailed(e),e}))},a.delete=function(){return this.request("delete").then((function(e){return salla.storage.clearAll(),salla.cookie.clearAll(),salla.auth.api.appendIframeAndLogout().then((function(){salla.event.profile.deleted(e),window.location.href=salla.url.get("logout");})),e})).catch((function(e){throw salla.event.profile.notDeleted(e),e}))},t}(V),Z=function(e){function t(){var t;return (t=e.call(this)||this).namespace="comment",t.endpoints={addComment:"{type}/{id}/comments",comments:"/comments"},t.after_init(),t}g(t,e);var a=t.prototype;return a.add=function(e){var t;if(null!=(t=e)&&t.data&&(e=e.data),"string"==typeof(e=this.getCommentPayload(e,true)))return salla.event.comment.additionFailed(e),salla.api.errorPromise(e);if(!e.comment){var a="can't find comment content!";return salla.event.comment.additionFailed(a),salla.api.errorPromise(a)}return this.request(["addComment","blog"==e.type?"blogs":e.type,e.id],{comment:e.comment}).then((function(t){return salla.event.comment.added(t,e.id),t})).catch((function(t){throw salla.event.comment.additionFailed(t,e.id),t}))},a.getCommentPayload=function(e,t){ void 0===t&&(t=false);var a={};if(["id","type","comment","per_page","page","sort"].forEach((function(t){var n=salla.form.getPossibleValue(e,[t]);n&&(a[t]=n);})),!t){var n=e.ids;if(n&&(a.ids=Array.isArray(n)?n:[n]),!a.ids||!a.ids.length)return "Failed to get ids!"}return a.type&&["products","pages","product","page","blogs","blog"].includes(a.type)?(a.type+=["product","page"].includes(a.type)?"s":"",a):"Failed to get type one of:(products, product, page, pages, blog, blogs)!"},a.fetchComments=function(e){if("string"==typeof(e=this.getCommentPayload(e)))return salla.event.comment.fetchFailed(e),salla.api.errorPromise(e);var t={per_page:e.per_page||5,page:e.page||1,type:e.type,ids:e.ids};return e.sort&&(t.sort=e.sort),this.request(["comments"],{params:t},"get").then((function(t){return salla.event.comment.fetched(t,e),t})).catch((function(t){throw salla.event.comment.fetchFailed(t,e),t}))},a.getComments=function(e,t,a,n,r){ void 0===a&&(a=1),void 0===n&&(n=5);var i=Array.isArray(t)?t:[t];return this.fetchComments({ids:i,type:e+"s",page:a,per_page:n,sort:r})},t}(V),$=function(e){function t(){var t;return (t=e.call(this)||this).namespace="currency",t.endpoints={change:"/",list:"currencies"},t.endpointsMethods={change:"get",list:"get"},t.webEndpoints=["change"],t.after_init(),t}g(t,e);var a=t.prototype;return a.change=function(e){if(!(e=salla.form.getPossibleValue(e.data||e,["currency","code"]))){var t="Can't find currency code!";return salla.currency.event.failed(t),salla.api.errorPromise(t)}return this.request("change",{params:{change_currency:"",currency:e}}).then((function(t){return salla.cookie.set("fresh_summary",1),salla.storage.set("cart",""),salla.currency.event.changed(t,e),t})).catch((function(t){throw salla.currency.event.failed(t,e),t}))},a.list=function(){return this.request("list").then((function(e){return salla.currency.event.fetched(e),e})).catch((function(e){throw salla.currency.event.failedToFetch(e),e}))},t}(V),X=function(e){function t(){var t;return (t=e.call(this)||this).namespace="document",t}return g(t,e),t.prototype.reload=function(){window.location.reload();},t}(V),Y=function(e){function t(){var t;return (t=e.call(this)||this).namespace="rating",t.endpoints={store:"rating/store",products:"rating/products",shipping:"rating/shipping",order:"rating/{order_id}"},t.endpointsMethods={order:"get"},t.after_init(),t}g(t,e);var a=t.prototype;return a.order=function(e){var t="object"==typeof e?e:{},a=salla.form.getPossibleValue((null==e?void 0:e.data)||e,["order_id","id"]);if(!a){var n='There is no "order_id"!';return salla.event.rating.orderNotFetched(n),salla.api.errorPromise(n)}return this.request(["order",a],t).then((function(e){return salla.event.rating.orderFetched(e,a),e})).catch((function(e){throw salla.event.rating.orderNotFetched(e,a),e}))},a.store=function(e){var t;if(!(e=(null==(t=e)?void 0:t.data)||e)){var a='There is no "data"!';return salla.event.rating.storeFailed(a),salla.api.errorPromise(a)}return this.request("store",e).then((function(t){return salla.event.rating.storeRated(t,e),t})).catch((function(t){throw salla.event.rating.storeFailed(t,e),t}))},a.products=function(e){var t;if(!(e=(null==(t=e)?void 0:t.data)||e)){var a='There is no "data"!';return salla.event.rating.productsFailed(a),salla.api.errorPromise(a)}return this.request("products",e).then((function(t){return salla.event.rating.productsRated(t,e),t})).catch((function(t){throw salla.event.rating.productsFailed(t,e),t}))},a.shipping=function(e){var t;if(!(e=(null==(t=e)?void 0:t.data)||e)){var a='There is no "data"!';return salla.event.rating.shippingFailed(a),salla.api.errorPromise(a)}return this.request("shipping",e).then((function(t){return salla.event.rating.shippingRated(t,e),t})).catch((function(t){throw salla.event.rating.shippingFailed(t,e),t}))},t}(V),ee=function(e){function t(){var t;return (t=e.call(this)||this).namespace="wishlist",t.endpoints={add:"products/favorites/{id}",remove:"products/favorites/{id}"},t.endpointsMethods={remove:"delete"},Salla.onReady((function(){var e;"customer.wishlist"===Salla.config.get("page.slug")&&(null!=(e=Salla.storage.getWithTTL("s-utms"))&&e["s-utm-source"]||t.injectSourceIntoRequest());})),t}g(t,e);var a=t.prototype;return a.injectSourceIntoRequest=function(){Salla.api.axios.interceptors.request.use((function(e){return e.headers=f({},e.headers,{"s-utm-source":"wishlist"}),e}),(function(e){return Promise.reject(e)}));},a.toggle=function(e){return salla.storage.get("salla::wishlist",[]).includes(e)?this.remove(e):this.add(e)},a.add=function(e){var t,a,n=this;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(a=salla.lang.get("common.messages.must_login")),salla.error(a),salla.api.errorPromise(a)):(e=salla.form.getPossibleValue((null==(t=e)?void 0:t.data)||e,["product_id","id"]))?this.request(["add",e]).then((function(t){return n.updateWishlistStorage(e),salla.wishlist.event.added(t,e),t})).catch((function(t){throw salla.wishlist.event.additionFailed(t,e),t})):(salla.wishlist.event.additionFailed(a="Failed to get product id!"),salla.api.errorPromise(a))},a.remove=function(e){var t,a,n=this;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(a=salla.lang.get("common.messages.must_login")),salla.error(a),salla.api.errorPromise(a)):(e=salla.form.getPossibleValue((null==(t=e)?void 0:t.data)||e,["product_id","id"]))?this.request(["remove",e]).then((function(t){return n.updateWishlistStorage(e,false),salla.wishlist.event.removed(t,e),t})).catch((function(t){throw salla.wishlist.event.removingFailed(t,e),t})):(salla.wishlist.event.removingFailed(a="Failed to get id!"),salla.api.errorPromise(a))},a.updateWishlistStorage=function(e,t){ void 0===t&&(t=true);var a=salla.storage.get("salla::wishlist",[]);t?a.push(e):a.splice(a.indexOf(e),1),salla.storage.set("salla::wishlist",a);},t}(V),te=function(e){function t(){var t;return (t=e.call(this)||this).namespace="scopes",t.endpoints={get:"scopes",change:"scopes",getProductAvailability:"scopes/availability?product_id={id}"},t.after_init(),t}g(t,e);var a=t.prototype;return a.get=function(){return this.request("scopes",null,"get").then((function(e){return salla.scope.event.fetched(e),e})).catch((function(e){throw salla.scope.event.notFetched(e),e}))},a.change=function(e){return this.request("scopes",e).then((function(e){return salla.scope.event.changeSucceeded(e),e})).catch((function(e){throw salla.scope.event.changeFailed(e),e}))},a.getProductAvailability=function(e){return void 0===e&&(e=null),this.request("scopes/availability?product_id="+e,null,"get").then((function(t){return salla.scope.event.productAvailabilityFetched(t,e),t})).catch((function(e){throw salla.scope.event.productAvailabilityNotFetched(e),e}))},t}(V),ae=function(e){function t(){var t;return (t=e.call(this)||this).namespace="booking",t.endpoints={add:"cart/booking/product/{id}"},t.endpointsMethods={add:"get"},t}return g(t,e),t.prototype.add=async function(e,t){if(void 0===t&&(t=true),!e){var a="Please provide product id.";return salla.booking.event.additionFailed(a),salla.api.errorPromise(a)}return this.request(["add",e]).then((function(e){return salla.booking.event.added(e),t&&"booking"===e.data.redirect.to&&(window.location.href=e.data.redirect.url),e})).catch((function(e){throw salla.booking.event.additionFailed(e),e}))},t}(V),ne=function(e){function t(){var t;return (t=e.call(this)||this).namespace="landing",t.endpoints={getDetails:"landing/{landing_page_id}",createCartFromPage:"landing/{landing_page_id}",breadcrumbs:"breadcrumbs"},t.endpointsMethods={getDetails:"get",breadcrumbs:"get"},t.after_init(),t}g(t,e);var a=t.prototype;return a.getDetails=function(e){if(!e){var t="page landing id not passed";return salla.event.landing.getDetailsFailed(t),salla.api.errorPromise(t)}return this.request(["getDetails",e]).then((function(t){return salla.event.landing.detailsFetched(t,e),t})).catch((function(t){throw salla.event.landing.getDetailsFailed(t,e),t}))},a.createCartFromPage=function(e){if(!e){var t="page landing id not passed";return salla.event.landing.orderCreationFailed(t),salla.api.errorPromise(t)}return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("landing::createCartFromPage",e),salla.event.dispatch("login::open"),salla.api.successPromise("")):this.request(["createCartFromPage",e]).then((function(t){return salla.event.landing.orderCreated(t,e).then((function(){return location.href=t.data.url})),t})).catch((function(t){throw salla.event.landing.orderCreationFailed(t,e),t}))},a.fetchBreadcrumbs=function(e){if(!e.page){var t="The 'page' parameter is required for the Breadcrumb API. Please provide a valid 'page' parameter.";return salla.event.landing.breadcrumbFetchFailed(t),salla.api.errorPromise(t)}if("product.single"===e.page&&!e.id&&!e.parent_id){var a="The 'id' and 'parent_id' parameters are required when the 'page' parameter is set to 'product.single'. Please provide valid values for both parameters.";return salla.event.landing.breadcrumbFetchFailed(a),salla.api.errorPromise(a)}if(["product.index","customer.orders.single","product.index.tag","page-single","landing-page","brands.single","blog.single","blog.index.author","blog.index.category","blog.index.tag"].includes(e.page)&&!e.id){var n="The 'id' parameter is required when the 'page' parameter is set to "+e.page+". Please provide valid value for the 'ID' parameter.";return salla.event.landing.breadcrumbFetchFailed(n),salla.api.errorPromise(n)}return this.request("breadcrumbs",{params:e}).then((function(e){return salla.event.landing.breadcrumbFetched(e),e})).catch((function(e){throw salla.event.landing.breadcrumbFetchFailed(e),e}))},t}(V),re=function(e){function t(){var t;return (t=e.call(this)||this).namespace="notifications",t.endpoints={fetch:"notifications"},t.endpointsMethods={fetch:"get"},t.after_init(),t}return g(t,e),t.prototype.fetch=function(e){return this.request(["fetch"],{params:e}).then((function(e){return salla.event.notifications.fetched(e),e})).catch((function(e){throw salla.event.notifications.fetchFailed(e),e}))},t}(V),ie=function(){function e(){var e,t=this;this.inIframe=salla.helpers.isIframe(),salla.event.on("twilight::before.ready",(async function(e){return await t.initiateRequest(e)})),salla.event.on("profile::info.fetched",(function(e){return t.setCurrencyAndLanguage(e)})),salla.event.on("auth::token.fetched",(function(e){salla.storage.set("token",e),t.inIframe&&salla.log("token fetched iframe"),t.inIframe&&salla.cookie.set("s-token",e,60),t.setToken(e);})),salla.event.on("auth::token.invalid",(function(){salla.storage.remove("user"),salla.storage.remove("token");})),this.notifier_handler_disabled=false,this.axios=axios.create({baseURL:Salla.config.get("store.api",Salla.config.get("store.url")),headers:{common:{"X-Requested-With":"XMLHttpRequest","S-SOURCE":"twilight","S-APP-VERSION":(null==(e=Salla)||null==(e=e.versions)?void 0:e.twilight)||"2.0.0","S-APP-OS":"browser","cache-control":"no-cache"}}}),this.axios.interceptors.request.use((function(e){"preview"===Salla.config.get("theme.mode")&&(e.url=Salla.url.addParamToUrl("use_username_url",1,e.url));try{var t,a=Salla.config.get("swoole",[]),n=new RegExp(a.join("|"),"i");a.length>0&&n.test(e.url)&&(e.headers["s-store-api-version"]="swoole");var r=null==(t=Salla.analytics)?void 0:t.getAnonymousId();r&&(e.headers["s-anonymous-id"]=r);}catch(e){Salla.log("Error in request interceptor:",e);}return e}),(function(e){return Promise.reject(e)}));}var t=e.prototype;return t.getHeaders=function(){var e=f({},this.axios.defaults.headers.common);return delete e["Content-Type"],e},t.getHeader=function(e){var t;return null==(t=Object.entries(this.getHeaders()).filter((function(t){return t[0].toLowerCase()===e.toLowerCase()}))[0])?void 0:t[1]},t.setHeaders=function(e){var t=this;return Object.entries(e).forEach((function(e){return t.setHeader(e[0],e[1])})),this},t.setHeader=function(e,t){return salla.infiniteScroll.fetchOptions.headers[e]=this.axios.defaults.headers.common[e]=t,this},t.withoutNotifier=async function(e){var t=this;return this.notifier_handler_disabled=true,await e().finally((function(){t.notifier_handler_disabled=false;}))},t.initiateRequest=async function(e){var t,a,n;this.axios.defaults.baseURL=Salla.config.get("store.api",Salla.config.get("store.url")),this.setHeaders(f({"Store-Identifier":Salla.config.get("store.id"),currency:(null==(t=e.user)?void 0:t.currency_code)||"SAR","accept-language":salla.lang.getLocale(),"s-user-id":null==(a=e.user)?void 0:a.id,"s-country":null==(n=e.user)?void 0:n.country_code},e.headers||{}));var r=Salla.config.get("store.scope",Salla.storage.get("scope")),i=new URLSearchParams(window.location.search).get("scope");i&&r&&!Salla.url.is_page("cart")&&(r.id=i,Salla.storage.set("scope",r),Salla.cart.reset()),r&&this.setHeaders({"s-scope-type":r.type,"s-scope-id":r.id});var o=Salla.storage.getWithTTL("s-utms");if(o){var u={};Object.entries(o).forEach((function(e){var t=e[0],a=e[1];u[t]="string"==typeof a&&/[^\x00-\x7F]/.test(a)?encodeURIComponent(a):a;})),this.setHeaders(u);}await this.injectTokenToTheRequests(e),Salla.storage.get("affiliate_code")&&this.setHeader("s-affiliate-code",Salla.storage.get("affiliate_code"));},t.injectTokenToTheRequests=async function(e){var t,a,n,i=this,o=this.getToken(),u="guest"===(null==(t=e.user)?void 0:t.type),s=parseInt((null==(a=e.user)?void 0:a.id)||0),l=parseInt(salla.storage.get("user.id")||0),c=salla.auth.api.isSessionless(),d=function(e){i.setToken(e),salla.event.emit("api::initiated");},p=async function(){u||c||!s?salla.auth.event.tokenInvalid():(salla.log("Api:: case 1 => current is is guest & web session available"),await salla.auth.api.refresh().then((async function(){await salla.profile.info();})).catch((function(){return salla.auth.event.tokenInvalid()})));};if(!o)return salla.log("Api:: case 1 => current is is guest"),void await p();try{n=jwtDecode(o);}catch(e){return Salla.logger.warn("Failed to decode JWT token",e),void Salla.auth.event.tokenInvalid()}return Date.now()/1e3>n.exp?(salla.log("Api:: case 2 => current user is logged-in and there is a token, but it's expired"),void await p()):(c?parseInt(n.sub)!==l:!l||!s||l!==s||parseInt(n.sub)!==s)?(salla.log("Api:: case 3 => there is a token and user in session/local missing or mismatch"),salla.log("sub:"+n.sub+" userIdInWeb:"+s+" userIdInStorage:"+l+", isSessionless:"+c,n.sub,s,l),this.setHeader("Authorization","Bearer "+o),void await salla.profile.info().then((async function(e){!i.inIframe&&!c&&await salla.auth.api.request("auth/jwt",{callerName:"salla.auth.request.injectTokenToTheRequests"}),d(o);})).catch((function(){salla.log("Api:: case 3 => failed get fresh profile"),i.setHeader("Authorization",null),salla.auth.event.tokenInvalid();}))):(salla.log("Api:: case 4 => current user is logged-in and there is a token, and it's not expired"),void d(o))},t.setToken=function(e){return this.setHeader("Authorization","Bearer "+e),salla.event.emit("api::token.injected",e),this.token=e,this},t.cleanupTokenFromUrl=function(){try{var e=new URL(window.location.href);if(!e.searchParams.has("token"))return;e.searchParams.delete("token"),window.history.replaceState({},document.title,e.toString());}catch(e){Salla.logger.warn("Failed to cleanup token from URL",e);}},t.setCurrencyAndLanguage=function(e){return this.setHeaders({currency:e.data.currency,"accept-language":e.data.language})},t.request=function(e,t,a,n){var r=this;void 0===t&&(t=void 0),void 0===a&&(a="get"),void 0===n&&(n={});var i={endPoint:e,payload:t,method:a,options:n},o="undefined"!=typeof event?event.currentTarget:null,u=false;return "SALLA-BUTTON"===(null==o?void 0:o.tagName)&&(u=true),u&&(null==o||o.load()),this.axios[i.method](i.endPoint,i.payload,i.options).then((function(e){return u&&(null==o||o.stop()),e.data&&e.request&&(e=e.data),r.handleAfterResponseActions(e),e})).catch((function(e){throw u&&(null==o||o.stop()),salla.event.document.requestFailed(i,e),r.handleErrorResponse(e),e}))},t.handleAfterResponseActions=function(e){if(e){var t=e.data,a=e.googleTags,n=void 0===a?null:a,r=t&&t.googleTags?t.googleTags:n;try{dataLayer&&r&&dataLayer.push(r);}catch(e){salla.logger.error(e.message);}this.fireEventsForResponse(e),this.showAlert(e);}},t.fireEventsForResponse=function(e){var t,a,n=(null==e?void 0:e.events)||(null==(t=e.data)?void 0:t.events)||(null==(a=e.error)?void 0:a.events);"string"==typeof n&&(n=JSON.parse(n)),n&&Object.keys(n).forEach((function(e){return salla.event.dispatch(e,n[e])}));},t.handleErrorResponse=function(e){if(e.response&&e.response.data)return e.response.data.error&&e.response.data.error.fields&&!this.notifier_handler_disabled?this.handleInvalidFields(e):this.handleAfterResponseActions(e.response.data)},t.showAlert=function(e){var t,a;if(e&&!this.notifier_handler_disabled)return e.case&&e.msg?salla.notify.fire(e.msg,e.case,e):e.hasOwnProperty("success")&&null!=(t=e.data)&&t.message?salla.notify.fire(null==(a=e.data)?void 0:a.message,e.success?salla.notify.types.success:salla.notify.types.error,e):e.error&&e.error.message&&"FORBIDDEN"!==e.error.message?salla.error(e.error.message,e):void 0},t.handleInvalidFields=function(e){var t=e.response.data.error.fields,a=[];Object.keys(t).forEach((function(e){var n=t[e];Array.isArray(n)?n.forEach((function(e){return a.push(e)})):a.push(n);}));var n=(a.length>1?"* ":"")+a.join("\n* ");salla.error(n,e);},t.isFastRequestsAllowed=function(){return Salla.config.get("fastRequests")},t.promise=function(e,t){return void 0===t&&(t=true),new Promise((function(a,n){return t?a(e):n(e)}))},t.errorPromise=function(e){return this.promise(e,false)},t.successPromise=function(e){return this.promise(e,true)},t.getToken=function(){if(Salla.storage.get("token"))return Salla.storage.get("token");try{var e,t=null==(e=new URLSearchParams(window.location.search))?void 0:e.get("token");if(!t)return;if(3!==t.split(".").length)return;return this.cleanupTokenFromUrl(),t}catch(e){Salla.logger.warn("Failed to extract or validate token from URL",e);}},e}(),oe=function(e){function t(){var t;return (t=e.call(this)||this).namespace="component",t.endpoints={getMenus:"menus/{headOrFoot}?store_id={store}&lang={lang}",reviews:"reviews"},t.endpointsMethods={getMenus:"get",reviews:"get"},t}g(t,e);var a=t.prototype;return a.getMenus=async function(e){return void 0===e&&(e="header"),this.request(["getMenus",e,salla.config.get("store.id"),salla.lang.getLocale()]).then((function(e){return salla.event.component.menuFetched(e),e})).catch((function(e){throw salla.event.component.menuFetchFailed(e),e}))},a.getReviews=async function(e){var t=e.per_page,a=void 0===t?5:t,n=e.type,r=void 0===n?"all":n,i=e.items,o=void 0===i?void 0:i;if(!r){var u="Review type cannot be empty. Please provide one.";return salla.event.component.reviewsFetchFailed(u),salla.api.errorPromise(u)}var s=!o||"string"==typeof o&&"[]"===o||Array.isArray(o)&&!o.length;if(!new Set(["all","store","categories","products","json"]).has(r)){var l="Invalid review type. Please provide a valid type.";return salla.event.component.reviewsFetchFailed(l),salla.api.errorPromise(l)}if("all"!==r&&"store"!==r&&s){var c="Items cannot be empty. Please provide one.";return salla.event.component.reviewsFetchFailed(c),salla.api.errorPromise(c)}if(new Set(["products","categories"]).has(r)&&!Array.isArray(o)){var d="Items value must be an array of "+r+" id for review type of "+r+".";return salla.event.component.reviewsFetchFailed(d),salla.api.errorPromise(d)}return this.request(["reviews"],{params:{per_page:a,type:r,items:o}},"get").then((function(e){return salla.event.component.reviewsFetched(e),e})).catch((function(e){throw salla.event.component.reviewsFetchFailed(e),e}))},t}(V),ue=function(e){function t(){var t;return (t=e.call(this)||this).namespace="booking",t.endpoints={fetch:"advertisements"},t.endpointsMethods={fetch:"get"},t}return g(t,e),t.prototype.fetch=async function(e){ void 0===e&&(e=null);var t=e?{page:e}:{};return this.request(["fetch"],{params:t}).then((function(e){return salla.event.advertisement.fetched(e),e})).catch((function(e){throw salla.event.advertisement.fetchFailed(e),e}))},t}(V),se=function(e){function t(){var t;return (t=e.call(this)||this).namespace="navigation",t.endpoints={breadcrumbs:"breadcrumbs"},t.endpointsMethods={breadcrumbs:"get"},t.after_init(),t}return g(t,e),t.prototype.fetchBreadcrumbs=function(e){if(!e.page){var t="The 'page' parameter is required for the Breadcrumb API. Please provide a valid 'page' parameter.";return salla.event.navigation.breadcrumbFetchFailed(t),salla.api.errorPromise(t)}if(["product.single","product.index","customer.orders.single","product.index.tag","page-single","landing-page","brands.single","blog.single","blog.index.author","blog.index.category","blog.index.tag"].includes(e.page)&&!e.id){var a="The 'id' parameter is required when the 'page' parameter is set to "+e.page+". Please provide valid value for the 'ID' parameter.";return salla.event.navigation.breadcrumbFetchFailed(a),salla.api.errorPromise(a)}return this.request("breadcrumbs",{params:e}).then((function(e){return salla.event.navigation.breadcrumbFetched(e),e})).catch((function(e){throw salla.event.navigation.breadcrumbFetchFailed(e),e}))},t}(V),le=function(e){function t(){var t;return (t=e.call(this)||this).namespace="metadata",t.endpoints={fetchValues:"https://api.salla.dev/store/v1/metadata/values"},t.endpointsMethods={fetchValues:"get"},t}return g(t,e),t.prototype.fetchValues=async function(e,t){if(!e||!t){var a="Please provide entity type and entity ids.";return salla.metadata.event.valueNotFetch(a),salla.api.errorPromise(a)}var n={type:e,entities:Array.isArray(t)?t:[t]};return this.request(this.endpoints.fetchValues,{params:n},"get").then((function(e){return salla.metadata.event.valueFetched(e),e})).catch((function(e){throw salla.metadata.event.valueNotFetch(e),e}))},t}(V),ce=function(e){function t(){var t;return (t=e.call(this)||this).auth=new W,t.cart=new G,t.loyalty=new z,t.order=new Q,t.rating=new Y,t.product=new K,t.profile=new J,t.comment=new Z,t.currency=new $,t.document=new X,t.wishlist=new ee,t.scope=new te,t.booking=new ae,t.landing=new ne,t.notifications=new re,t.component=new oe,t.advertisement=new ue,t.navigation=new se,t.metadata=new le,t}return g(t,e),t.prototype.beaconRequest=function(e,t){var a,n,r,i;if(void 0===t&&(t={}),null==(a=window.navigator)||!a.sendBeacon)return fetch(e,t);var o="string"==typeof(null==(n=t)?void 0:n.body)?null==(r=t)?void 0:r.body:JSON.stringify((null==(i=t)?void 0:i.body)||{}),u=new Blob([o],{type:"application/json"});return Salla.log("Beacon payload size: "+u.size+" bytes (~"+(u.size/1024).toFixed(2)+" KB)"),navigator.sendBeacon(e,u),Promise.resolve(new Response('{"status":"sent_via_beacon"}',{status:200,headers:{"Content-Type":"application/json"}}))},t}(ie),de=function(){function t(t){var a,n;if("ready"!==N$3.status)if(t){var r;if(N$3.config.merge(t),!["salla.sa","salla.group"].includes(location.hostname)||null!=(a=N$3.config.get("store.url"))&&a.includes(location.hostname)||!N$3.config.get("store.username")||N$3.config.set("store.url",window.location.origin+"/"+N$3.config.get("store.username")),(null==t?void 0:t.events)&&N$3.event.dispatchEvents(null==t?void 0:t.events),t._token&&salla.api.setHeader("X-CSRF-TOKEN",t._token),window.self===window.top&&(this.injectMaintenanceAlert(),this.injectThemePreviewAlert()),this.injectTemplateStoreAlert(),this.injectAppInstallAlert(),this.applyContentCopyright(),this.injectEditAlert(),null!=t&&null!=(n=t.user)&&n.language_code)salla.lang.setLocale(null==t||null==(r=t.user)?void 0:r.language_code);salla.lang.loadStoreTranslations(),this.setSallaReady(t),this.afterInit();}else this.setSallaReady(t);else salla.log("Trying to re-initiate Salla, while its status === 'ready'!");}var a=t.prototype;return a.afterInit=function(){N$3.url.is_page("product.single")&&N$3.config.isGuest()&&window.addEventListener("mini-checkout::before-init",(function(t){t.preventDefault(),N$3.event.emit("login::open");}));},a.applyContentCopyright=function(){if(N$3.config.get("store.settings.content_copyright")){["contextmenu","selectstart","copy"].forEach((function(e){document.addEventListener(e,(function(e){(function(e){var t;if(!e)return false;var a=null==(t=e.tagName)?void 0:t.toLowerCase();return "input"===a||"textarea"===a})(e.target)||e.preventDefault();}));})),document.addEventListener("keydown",(function(e){var t=e.key.toLowerCase();("f12"===t||e.ctrlKey&&e.shiftKey&&["i","j","c"].includes(t)||e.ctrlKey&&"u"===t)&&(e.preventDefault(),e.stopPropagation());}));var t=document.createElement("style");t.textContent="\n body {\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n }\n input, textarea {\n -webkit-touch-callout: auto;\n -webkit-user-select: auto;\n -moz-user-select: auto;\n -ms-user-select: auto;\n user-select: auto;\n }\n img {\n pointer-events: none;\n -webkit-user-drag: none;\n }\n ",document.head.appendChild(t);}},a.injectMaintenanceAlert=function(){salla.config.get("maintenance")&&(document.body.classList.add("has-maintenance-bar"),document.querySelector("salla-maintenance-alert")?salla.logger.warn("salla-maintenance-alert element Existed before!"):salla.lang.onLoaded((function(){return document.body.prepend(document.createElement("salla-maintenance-alert"))})));},a.injectTemplateStoreAlert=function(){salla.config.get("store.template")&&(document.body.classList.add("has-bottom-alert"),document.querySelector("salla-bottom-alert")?salla.logger.warn("salla-bottom-alert element Existed before!"):salla.lang.onLoaded((function(){return document.body.append(document.createElement("salla-bottom-alert"))})));},a.injectAppInstallAlert=function(){salla.config.get("store.app_install_prompt")&&salla.config.get("store.apps")&&!salla.storage.get("app_install_prompt_disabled")&&!salla.config.isMobileApp()&&(document.body.classList.add("has-app-install-alert"),document.querySelector("salla-app-install-alert")?salla.logger.warn("salla-app-install-alert element Existed before!"):salla.lang.onLoaded((function(){return document.body.append(document.createElement("salla-app-install-alert"))})));},a.injectThemePreviewAlert=function(){"preview"===salla.config.get("theme.mode")&&(document.body.classList.add("has-preview-bar"),document.querySelector("#s-theme_preview_bar")?salla.logger.warn("#s-theme_preview_bar element Existed before!"):salla.lang.onLoaded((function(){var e=document.createElement("div");e.id="s-theme_preview_bar",e.setAttribute("style","display: flex; justify-content: space-between; text-align: center; background-color: #232323; color: #fff; padding: 10px; font-size: 0.875rem; line-height: 1.25rem; position: relative;"),e.innerHTML='\n <div style="display:flex; align-items:center;">\n <img width="32" src="https://cdn.salla.network/images/logo/logo-light.svg">\n <span style="margin:0 10px;">'+salla.lang.get("blocks.header.preview_mode")+': <span style="background:rgba(255,255,255,0.25);border-radius:15px; padding:2px 15px 4px">'+salla.config.get("theme.name")+'</span></span>\n </div>\n <a href="'+salla.url.get("preview_theme/cancel/preview")+'" style="line-height:32px; width:32px;"><i class="sicon-cancel"></i></a>\n ',document.body.prepend(e);})));},a.injectEditAlert=function(){var e=salla.config.get("edit");e&&(document.querySelector("#s-edit-alert")?salla.logger.warn("#s-edit-alert element Existed before!"):salla.lang.onLoaded((function(){var t=document.createElement("div");t.id="s-edit-alert",t.innerHTML='\n <a href="'+e+'" style="display:block; background-color:'+salla.config.get("theme.color.primary","#5cd5c4")+"; color:"+salla.config.get("theme.color.reverse","#fff")+'; padding: 10px; text-align:center; font-size: 0.875rem; line-height: 1.25rem;">\n <i class="sicon-edit"></i> \n '+salla.lang.get("pages.products.quick_edit")+"\n </a>\n ",document.body.prepend(t);})));},a.handleElementAjaxRequest=function(e,t){var a=this;if(!(t instanceof HTMLFormElement||t instanceof HTMLAnchorElement))return salla.logger.warn("trying to call ajax from non Element!!"),false;e.preventDefault();var n=t.getAjaxFormData(e),r=n.method?n.method.toLowerCase():void 0;salla.api.request(n.url,n.formData,r).then((function(e){return e.data&&e.request&&(e=e.data),salla.api.handleAfterResponseActions(e),a.callAjaxEvent(n.events.success,e,n.formData),e})).catch((function(e){throw salla.api.handleErrorResponse(e),a.callAjaxEvent(n.events.fail,e,n.formData),e}));},a.callAjaxEvent=function(e,t,a){if(e){if(a instanceof FormData){var n={};Array.from(a.entries()).forEach((function(e){n[e[0]]=e[1];})),a=n;}window[e]?window[e](t,a):salla.event.dispatch(e,t,a);}},a.setSallaReady=function(t){this.storeUTMs(),N$3.event.emitAsync("twilight::before.ready",t),N$3.status="ready",N$3.event.dispatch("twilight::initiated",t),window.dispatchEvent(new CustomEvent("twilight::initiated",{detail:t}));},a.storeUTMs=function(){var t={fbclid:"facebook",gad_source:"google",ttclid:"tiktok",twclid:"twitter",scid:"snapchat",sccid:"snapchat"},a=Object.keys(t),n=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"].concat(a),r={},i={};window.location.search.replace("?","").split("&").map((function(e){return e.split("=")})).filter((function(e){var t=e[0];return n.includes(t.toLowerCase())})).forEach((function(t){var a=t[0],n=t[1],i=n||"",o=false;try{i=decodeURIComponent(n),o=true;}catch(t){N$3.log("Failed to decode UTM param:",t);}r[a.toLowerCase()]=o?i.replace(/(?:[\0-\x1F!-,\.\/:-@\[-`\{-\xA9\xAB-\xB1\xB4\xB6-\xB8\xBB\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u036F\u0375\u0378\u0379\u037E\u0380-\u0385\u0387\u038B\u038D\u03A2\u03F6\u0482-\u0489\u0530\u0557\u0558\u055A-\u055F\u0589-\u05CF\u05EB-\u05EE\u05F3-\u061F\u064B-\u065F\u066A-\u066D\u0670\u06D4\u06D6-\u06E4\u06E7-\u06ED\u06FD\u06FE\u0700-\u070F\u0711\u0730-\u074C\u07A6-\u07B0\u07B2-\u07BF\u07EB-\u07F3\u07F6-\u07F9\u07FB-\u07FF\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u083F\u0859-\u085F\u086B-\u086F\u0888\u0890-\u089F\u08CA-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962-\u0965\u0970\u0981-\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA-\u09BC\u09BE-\u09CD\u09CF-\u09DB\u09DE\u09E2-\u09E5\u09F2\u09F3\u09FA\u09FB\u09FD-\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A-\u0A58\u0A5D\u0A5F-\u0A65\u0A70\u0A71\u0A75-\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA-\u0ABC\u0ABE-\u0ACF\u0AD1-\u0ADF\u0AE2-\u0AE5\u0AF0-\u0AF8\u0AFA-\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A-\u0B3C\u0B3E-\u0B5B\u0B5E\u0B62-\u0B65\u0B70\u0B78-\u0B82\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BBA-\u0BCF\u0BD1-\u0BE5\u0BF3-\u0C04\u0C0D\u0C11\u0C29\u0C3A-\u0C3C\u0C3E-\u0C57\u0C5B\u0C5E\u0C5F\u0C62-\u0C65\u0C70-\u0C77\u0C7F\u0C81-\u0C84\u0C8D\u0C91\u0CA9\u0CB4\u0CBA-\u0CBC\u0CBE-\u0CDB\u0CDF\u0CE2-\u0CE5\u0CF0\u0CF3-\u0D03\u0D0D\u0D11\u0D3B\u0D3C\u0D3E-\u0D4D\u0D4F-\u0D53\u0D57\u0D62-\u0D65\u0D79\u0D80-\u0D84\u0D97-\u0D99\u0DB2\u0DBC\u0DBE\u0DBF\u0DC7-\u0DE5\u0DF0-\u0E00\u0E31\u0E34-\u0E3F\u0E47-\u0E4F\u0E5A-\u0E80\u0E83\u0E85\u0E8B\u0EA4\u0EA6\u0EB1\u0EB4-\u0EBC\u0EBE\u0EBF\u0EC5\u0EC7-\u0ECF\u0EDA\u0EDB\u0EE0-\u0EFF\u0F01-\u0F1F\u0F34-\u0F3F\u0F48\u0F6D-\u0F87\u0F8D-\u0FFF\u102B-\u103E\u104A-\u104F\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109F\u10C6\u10C8-\u10CC\u10CE\u10CF\u10FB\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B-\u1368\u137D-\u137F\u1390-\u139F\u13F6\u13F7\u13FE-\u1400\u166D\u166E\u1680\u169B-\u169F\u16EB-\u16ED\u16F9-\u16FF\u1712-\u171E\u1732-\u173F\u1752-\u175F\u176D\u1771-\u177F\u17B4-\u17D6\u17D8-\u17DB\u17DD-\u17DF\u17EA-\u17EF\u17FA-\u180F\u181A-\u181F\u1879-\u187F\u1885\u1886\u18A9\u18AB-\u18AF\u18F6-\u18FF\u191F-\u1945\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19CF\u19DB-\u19FF\u1A17-\u1A1F\u1A55-\u1A7F\u1A8A-\u1A8F\u1A9A-\u1AA6\u1AA8-\u1B04\u1B34-\u1B44\u1B4D-\u1B4F\u1B5A-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BFF\u1C24-\u1C3F\u1C4A-\u1C4C\u1C7E\u1C7F\u1C8B-\u1C8F\u1CBB\u1CBC\u1CC0-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1CFB-\u1CFF\u1DC0-\u1DFF\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FBD\u1FBF-\u1FC1\u1FC5\u1FCD-\u1FCF\u1FD4\u1FD5\u1FDC-\u1FDF\u1FED-\u1FF1\u1FF5\u1FFD-\u206F\u2072\u2073\u207A-\u207E\u208A-\u208F\u209D-\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A-\u245F\u249C-\u24E9\u2500-\u2775\u2794-\u2BFF\u2CE5-\u2CEA\u2CEF-\u2CF1\u2CF4-\u2CFC\u2CFE\u2CFF\u2D26\u2D28-\u2D2C\u2D2E\u2D2F\u2D68-\u2D6E\u2D70-\u2D7F\u2D97-\u2D9F\u2DA7\u2DAF\u2DB7\u2DBF\u2DC7\u2DCF\u2DD7\u2DDF-\u2E2E\u2E30-\u3004\u3008-\u3020\u302A-\u3030\u3036\u3037\u303D-\u3040\u3097-\u309C\u30A0\u30FB\u3100-\u3104\u3130\u318F-\u3191\u3196-\u319F\u31C0-\u31EF\u3200-\u321F\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA48D-\uA4CF\uA4FE\uA4FF\uA60D-\uA60F\uA62C-\uA63F\uA66F-\uA67E\uA69E\uA69F\uA6F0-\uA716\uA720\uA721\uA789\uA78A\uA7DD-\uA7F0\uA802\uA806\uA80B\uA823-\uA82F\uA836-\uA83F\uA874-\uA881\uA8B4-\uA8CF\uA8DA-\uA8F1\uA8F8-\uA8FA\uA8FC\uA8FF\uA926-\uA92F\uA947-\uA95F\uA97D-\uA983\uA9B3-\uA9CE\uA9DA-\uA9DF\uA9E5\uA9FF\uAA29-\uAA3F\uAA43\uAA4C-\uAA4F\uAA5A-\uAA5F\uAA77-\uAA79\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAC3-\uAADA\uAADE\uAADF\uAAEB-\uAAF1\uAAF5-\uAB00\uAB07\uAB08\uAB0F\uAB10\uAB17-\uAB1F\uAB27\uAB2F\uAB5B\uAB6A-\uAB6F\uABE3-\uABEF\uABFA-\uABFF\uD7A4-\uD7AF\uD7C7-\uD7CA\uD7FC-\uD7FF\uE000-\uF8FF\uFA6E\uFA6F\uFADA-\uFAFF\uFB07-\uFB12\uFB18-\uFB1C\uFB1E\uFB29\uFB37\uFB3D\uFB3F\uFB42\uFB45\uFBB2-\uFBD2\uFD3E-\uFD4F\uFD90\uFD91\uFDC8-\uFDEF\uFDFC-\uFE6F\uFE75\uFEFD-\uFF0F\uFF1A-\uFF20\uFF3B-\uFF40\uFF5B-\uFF65\uFFBF-\uFFC1\uFFC8\uFFC9\uFFD0\uFFD1\uFFD8\uFFD9\uFFDD-\uFFFF]|\uD800[\uDC0C\uDC27\uDC3B\uDC3E\uDC4E\uDC4F\uDC5E-\uDC7F\uDCFB-\uDD06\uDD34-\uDD3F\uDD79-\uDD89\uDD8C-\uDE7F\uDE9D-\uDE9F\uDED1-\uDEE0\uDEFC-\uDEFF\uDF24-\uDF2C\uDF4B-\uDF4F\uDF76-\uDF7F\uDF9E\uDF9F\uDFC4-\uDFC7\uDFD0\uDFD6-\uDFFF]|\uD801[\uDC9E\uDC9F\uDCAA-\uDCAF\uDCD4-\uDCD7\uDCFC-\uDCFF\uDD28-\uDD2F\uDD64-\uDD6F\uDD7B\uDD8B\uDD93\uDD96\uDDA2\uDDB2\uDDBA\uDDBD-\uDDBF\uDDF4-\uDDFF\uDF37-\uDF3F\uDF56-\uDF5F\uDF68-\uDF7F\uDF86\uDFB1\uDFBB-\uDFFF]|\uD802[\uDC06\uDC07\uDC09\uDC36\uDC39-\uDC3B\uDC3D\uDC3E\uDC56\uDC57\uDC77\uDC78\uDC9F-\uDCA6\uDCB0-\uDCDF\uDCF3\uDCF6-\uDCFA\uDD1C-\uDD1F\uDD3A-\uDD3F\uDD5A-\uDD7F\uDDB8-\uDDBB\uDDD0\uDDD1\uDE01-\uDE0F\uDE14\uDE18\uDE36-\uDE3F\uDE49-\uDE5F\uDE7F\uDEA0-\uDEBF\uDEC8\uDEE5-\uDEEA\uDEF0-\uDEFF\uDF36-\uDF3F\uDF56\uDF57\uDF73-\uDF77\uDF92-\uDFA8\uDFB0-\uDFFF]|\uD803[\uDC49-\uDC7F\uDCB3-\uDCBF\uDCF3-\uDCF9\uDD24-\uDD2F\uDD3A-\uDD3F\uDD66-\uDD6E\uDD86-\uDE5F\uDE7F\uDEAA-\uDEAF\uDEB2-\uDEC1\uDEC8-\uDEFF\uDF28-\uDF2F\uDF46-\uDF50\uDF55-\uDF6F\uDF82-\uDFAF\uDFCC-\uDFDF\uDFF7-\uDFFF]|\uD804[\uDC00-\uDC02\uDC38-\uDC51\uDC70\uDC73\uDC74\uDC76-\uDC82\uDCB0-\uDCCF\uDCE9-\uDCEF\uDCFA-\uDD02\uDD27-\uDD35\uDD40-\uDD43\uDD45\uDD46\uDD48-\uDD4F\uDD73-\uDD75\uDD77-\uDD82\uDDB3-\uDDC0\uDDC5-\uDDCF\uDDDB\uDDDD-\uDDE0\uDDF5-\uDDFF\uDE12\uDE2C-\uDE3E\uDE41-\uDE7F\uDE87\uDE89\uDE8E\uDE9E\uDEA9-\uDEAF\uDEDF-\uDEEF\uDEFA-\uDF04\uDF0D\uDF0E\uDF11\uDF12\uDF29\uDF31\uDF34\uDF3A-\uDF3C\uDF3E-\uDF4F\uDF51-\uDF5C\uDF62-\uDF7F\uDF8A\uDF8C\uDF8D\uDF8F\uDFB6\uDFB8-\uDFD0\uDFD2\uDFD4-\uDFFF]|\uD805[\uDC35-\uDC46\uDC4B-\uDC4F\uDC5A-\uDC5E\uDC62-\uDC7F\uDCB0-\uDCC3\uDCC6\uDCC8-\uDCCF\uDCDA-\uDD7F\uDDAF-\uDDD7\uDDDC-\uDDFF\uDE30-\uDE43\uDE45-\uDE4F\uDE5A-\uDE7F\uDEAB-\uDEB7\uDEB9-\uDEBF\uDECA-\uDECF\uDEE4-\uDEFF\uDF1B-\uDF2F\uDF3C-\uDF3F\uDF47-\uDFFF]|\uD806[\uDC2C-\uDC9F\uDCF3-\uDCFE\uDD07\uDD08\uDD0A\uDD0B\uDD14\uDD17\uDD30-\uDD3E\uDD40\uDD42-\uDD4F\uDD5A-\uDD9F\uDDA8\uDDA9\uDDD1-\uDDE0\uDDE2\uDDE4-\uDDFF\uDE01-\uDE0A\uDE33-\uDE39\uDE3B-\uDE4F\uDE51-\uDE5B\uDE8A-\uDE9C\uDE9E-\uDEAF\uDEF9-\uDFBF\uDFE1-\uDFEF\uDFFA-\uDFFF]|\uD807[\uDC09\uDC2F-\uDC3F\uDC41-\uDC4F\uDC6D-\uDC71\uDC90-\uDCFF\uDD07\uDD0A\uDD31-\uDD45\uDD47-\uDD4F\uDD5A-\uDD5F\uDD66\uDD69\uDD8A-\uDD97\uDD99-\uDD9F\uDDAA-\uDDAF\uDDDC-\uDDDF\uDDEA-\uDEDF\uDEF3-\uDF01\uDF03\uDF11\uDF34-\uDF4F\uDF5A-\uDFAF\uDFB1-\uDFBF\uDFD5-\uDFFF]|\uD808[\uDF9A-\uDFFF]|\uD809[\uDC6F-\uDC7F\uDD44-\uDFFF]|[\uD80A\uD812-\uD817\uD819\uD824-\uD82A\uD82D\uD82E\uD830-\uD832\uD836\uD83D\uD83F\uD87C\uD87D\uD87F\uD88E-\uDBFF][\uDC00-\uDFFF]|\uD80B[\uDC00-\uDF8F\uDFF1-\uDFFF]|\uD80D[\uDC30-\uDC40\uDC47-\uDC5F]|\uD810[\uDFFB-\uDFFF]|\uD811[\uDE47-\uDFFF]|\uD818[\uDC00-\uDCFF\uDD1E-\uDD2F\uDD3A-\uDFFF]|\uD81A[\uDE39-\uDE3F\uDE5F\uDE6A-\uDE6F\uDEBF\uDECA-\uDECF\uDEEE-\uDEFF\uDF30-\uDF3F\uDF44-\uDF4F\uDF5A\uDF62\uDF78-\uDF7C\uDF90-\uDFFF]|\uD81B[\uDC00-\uDD3F\uDD6D-\uDD6F\uDD7A-\uDE3F\uDE97-\uDE9F\uDEB9\uDEBA\uDED4-\uDEFF\uDF4B-\uDF4F\uDF51-\uDF92\uDFA0-\uDFDF\uDFE2\uDFE4-\uDFF1\uDFF7-\uDFFF]|\uD823[\uDCD6-\uDCFE\uDD1F-\uDD7F\uDDF3-\uDFFF]|\uD82B[\uDC00-\uDFEF\uDFF4\uDFFC\uDFFF]|\uD82C[\uDD23-\uDD31\uDD33-\uDD4F\uDD53\uDD54\uDD56-\uDD63\uDD68-\uDD6F\uDEFC-\uDFFF]|\uD82F[\uDC6B-\uDC6F\uDC7D-\uDC7F\uDC89-\uDC8F\uDC9A-\uDFFF]|\uD833[\uDC00-\uDCEF\uDCFA-\uDFFF]|\uD834[\uDC00-\uDEBF\uDED4-\uDEDF\uDEF4-\uDF5F\uDF79-\uDFFF]|\uD835[\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3\uDFCC\uDFCD]|\uD837[\uDC00-\uDEFF\uDF1F-\uDF24\uDF2B-\uDFFF]|\uD838[\uDC00-\uDC2F\uDC6E-\uDCFF\uDD2D-\uDD36\uDD3E\uDD3F\uDD4A-\uDD4D\uDD4F-\uDE8F\uDEAE-\uDEBF\uDEEC-\uDEEF\uDEFA-\uDFFF]|\uD839[\uDC00-\uDCCF\uDCEC-\uDCEF\uDCFA-\uDDCF\uDDEE\uDDEF\uDDFB-\uDEBF\uDEDF\uDEE3\uDEE6\uDEEE\uDEEF\uDEF5-\uDEFD\uDF00-\uDFDF\uDFE7\uDFEC\uDFEF\uDFFF]|\uD83A[\uDCC5\uDCC6\uDCD0-\uDCFF\uDD44-\uDD4A\uDD4C-\uDD4F\uDD5A-\uDFFF]|\uD83B[\uDC00-\uDC70\uDCAC\uDCB0\uDCB5-\uDD00\uDD2E\uDD3E-\uDDFF\uDE04\uDE20\uDE23\uDE25\uDE26\uDE28\uDE33\uDE38\uDE3A\uDE3C-\uDE41\uDE43-\uDE46\uDE48\uDE4A\uDE4C\uDE50\uDE53\uDE55\uDE56\uDE58\uDE5A\uDE5C\uDE5E\uDE60\uDE63\uDE65\uDE66\uDE6B\uDE73\uDE78\uDE7D\uDE7F\uDE8A\uDE9C-\uDEA0\uDEA4\uDEAA\uDEBC-\uDFFF]|\uD83C[\uDC00-\uDCFF\uDD0D-\uDFFF]|\uD83E[\uDC00-\uDFEF\uDFFA-\uDFFF]|\uD869[\uDEE0-\uDEFF]|\uD86E[\uDC1E\uDC1F]|\uD873[\uDEAE\uDEAF]|\uD87A[\uDFE1-\uDFEF]|\uD87B[\uDE5E-\uDFFF]|\uD87E[\uDE1E-\uDFFF]|\uD884[\uDF4B-\uDF4F]|\uD88D[\uDC7A-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/g," ").replace(/ +/g," ").trim():i;}));var o=a.find((function(e){return r[e]}));!r.utm_source&&o&&(r.utm_source=t[o],r.utm_campaign=r.utm_campaign||"Using the CLICKID "+o+" provided by "+r.utm_source,r.utm_term=r.utm_term||o+": "+r[o]),r.utm_source&&(Object.entries(r).filter((function(e){var t=e[0];return !a.includes(t)})).forEach((function(e){var t=e[0],a=e[1];i["s-"+t.replace("_","-")]=a;})),i["s-utm-referrer"]=document.referrer,salla.storage.setWithTTL("s-utms",i,129600),this.logUTMVisitData(i));},a.logUTMVisitData=async function(t){var a=t["s-utm-source"],n=t["s-utm-medium"],r=t["s-utm-campaign"],i=N$3.config.get("store.id");t&&"affiliate"===a&&n&&r&&fetch(salla.config.get("affiliate.utm_url"),{method:"POST",mode:"cors",headers:{"Content-Type":"application/json","s-utm-source":a,"s-utm-medium":n,"s-utm-campaign":r,"s-store-id":i}}).then((function(e){if(e.ok){var t=new URL(window.location.href),a=window.history.state;t.searchParams.delete("utm_source"),t.searchParams.delete("utm_medium"),t.searchParams.delete("utm_campaign"),window.history.replaceState(a,"",t);}}));},t}(),pe=function(){function e(){var e=this;Salla.onReady((function(){return e.init()}));}var t=e.prototype;return t.init=function(){var e,t=this;if(salla.config.get("store.features",[]).includes("sso-login")){if(window.location.hostname.includes("salla"))return salla.log("SSO is not supported yet for stores without custom domain.");salla.auth.event.onLoggedOut((function(){return new Promise((function(e){var t=document.createElement("iframe");t.style.display="none",t.src=salla.url.get("sso/logout"),document.body.appendChild(t),t.onload=function(){document.body.removeChild(t),e();};}))})),null==(e=document.querySelector("salla-login-modal"))||e.remove(),Salla.event.removeAllListeners("login::open"),Salla.event.prependListener("login::open",(function(){return t.redirect()})),window.addEventListener("mini-checkout::before-init",(function(e){Salla.config.isUser()||(e.preventDefault(),t.redirect());}));}},t.redirect=function(){var e=window.location.pathname+window.location.search,t=window.location.origin+"/sso/login?intended_to="+encodeURIComponent(e);return console.log("Redirecting to:",t),window.location.href=t,true},e}(),he=function(){function e(e){this.item=e[0];}return e.prototype.toSegment=function(){var e,t,a,n,r;return {event:"Product Added",properties:{cart_id:null==(e=this.item.cart_id)?void 0:e.toString(),cart_item_id:null==(t=this.item.cart_item_id)?void 0:t.toString(),product_id:null==(a=this.item.id)?void 0:a.toString(),category:this.item.category,currency:null==(n=Salla.config.currency())?void 0:n.code,name:this.item.name,brand:this.item.brand,variant:null==(r=this.item.variant)?void 0:r.toString(),price:this.item.price,quantity:this.item.quantity,sku:this.item.sku,coupon:this.item.coupon,position:this.item.position,url:this.item.url,image_url:this.item.image_url}}},e.shouldSend=function(){return "customer.wishlist"!==salla.config.get("page.slug")},e}(),fe=function(){function e(e){this.product=e[0];}return e.prototype.toSegment=function(){var e;return {event:"Product Viewed",properties:{product_id:null==(e=this.product.id)?void 0:e.toString(),category:this.product.category,name:this.product.name,brand:this.product.brand,variant:this.product.variant,price:this.product.price,quantity:this.product.quantity,currency:this.product.currency,coupon:this.product.coupon,position:this.product.position,value:this.product.value,sku:this.product.sku,url:this.product.url,image_url:this.product.image_url}}},e}(),ge=function(){function e(e){this.cart=e[0];}return e.prototype.toSegment=function(){var e;return {event:"Cart Viewed",properties:{cart_id:null==(e=this.cart.cart_id)?void 0:e.toString(),products:this.cart.products.map((function(e){var t,a,n;return {product_id:null==(t=e.id)?void 0:t.toString(),cart_item_id:null==(a=e.cart_item_id)?void 0:a.toString(),name:e.name,price:e.price,category:e.category,sku:e.sku,position:e.position,url:e.url,image_url:e.image_url,brand:e.brand,currency:null==(n=Salla.config.currency())?void 0:n.code,variant:e.variant,coupon:e.coupon,quantity:e.quantity}}))}}},e}(),ve=function(){function e(e){var t=null==e?void 0:e.nextPage;this.listId=salla.config.get("page.slug"),Salla.config.get("page.id")&&(this.listId+="_"+salla.config.get("page.id")),this.sorts=null;try{if(t){var a=new URL(t).searchParams.get("sort");a&&(this.sorts=[{type:"sort",value:a}]);}e.source&&(this.listId=this.listId+"_"+e.source),e.sourceValue&&(this.listId=this.listId+"_"+(Array.isArray(e.sourceValue)?e.sourceValue.join("_"):e.sourceValue));}catch(e){salla.logger.error(e);}this.products=null==e?void 0:e.data;}return e.prototype.toSegment=function(){var e=(salla.config.get("page.title")||"").split("|").map((function(e){return e.trim()})),t=e[0],a=e[1]||null;return {event:"Product List Viewed",properties:{list_id:this.listId,category:t,sub_category:a,sorts:this.sorts,products:this.products.map((function(e){var t,a,n,r,i,o;return {product_id:e.id,category:null==(t=e.category)?void 0:t.name,currency:null==(a=Salla.config.currency())?void 0:a.code,name:e.name,brand:null==(n=e.brand)?void 0:n.name,variant:null==(r=e.variant)?void 0:r.toString(),coupon:null==(i=e.coupon)?void 0:i.toString(),price:e.price,quantity:Number(e.quantity),sku:e.sku,position:0,url:e.url,image_url:null==(o=e.image)?void 0:o.url}}))}}},e.shouldSend=function(e){return !((null==e?void 0:e.nextPage)||"").includes("filters")&&!["index","customer.wishlist"].includes(salla.config.get("page.slug"))},e}(),me=function(){function e(e){this.query=e;}return e.prototype.toSegment=function(){return {event:"Products Searched",properties:{query:this.query}}},e}(),De=function(){function e(){this.user=JSON.parse(localStorage.getItem("user"));}return e.prototype.toSegment=function(){var e,t,a,n,r;return {event:"Signed In",properties:{first_name:null==(e=this.user)?void 0:e.first_name,last_name:null==(t=this.user)?void 0:t.last_name,type:null==(a=this.user)?void 0:a.type,mobile:null==(n=this.user)?void 0:n.mobile,email:null==(r=this.user)?void 0:r.email}}},e.shouldSend=function(){return "user"===Salla.config.get("user.type")?!Salla.analytics.history.find((function(e){return "Signed In"===e.eventName})):(Salla.profile.event.onInfoFetched((function(){return Salla.event.emit("Signed In")})),false)},e}(),Fe=function(e){function t(){return e.apply(this,arguments)||this}return g(t,e),t.prototype.toSegment=function(){var t=e.prototype.toSegment.call(this);return {event:"Signed Up",properties:null==t?void 0:t.properties}},t.shouldSend=function(){return "user"===Salla.config.get("user.type")||(Salla.profile.event.onInfoFetched((function(){return Salla.event.emit("Signed Up")})),false)},t}(De),ye=function(){function e(){}return e.prototype.toSegment=function(){return {event:"Signed Out",properties:{}}},e}(),Ce=function(){function e(e){this.item=e[0];}return e.prototype.toSegment=function(){var e,t,a,n,r,i,o,u,s,l,c,d,p,h;return {event:"Product Removed",properties:{cart_id:null==(e=this.item)||null==(e=e.cart_id)?void 0:e.toString(),product_id:null==(t=this.item)||null==(t=t.id)?void 0:t.toString(),category:null==(a=this.item)?void 0:a.category,currency:null==(n=Salla.config.currency())?void 0:n.code,name:null==(r=this.item)?void 0:r.name,brand:null==(i=this.item)?void 0:i.brand,variant:null==(o=this.item)?void 0:o.variant,price:null==(u=this.item)?void 0:u.price,quantity:null==(s=this.item)?void 0:s.quantity,sku:null==(l=this.item)?void 0:l.sku,coupon:null==(c=this.item)?void 0:c.coupon,position:null==(d=this.item)?void 0:d.position,url:null==(p=this.item)?void 0:p.url,image_url:null==(h=this.item)?void 0:h.image_url}}},e}(),we=function(){function e(e){this.product=e.data.product;}return e.prototype.toSegment=function(){var e,t,a,n;return {event:"Product Added to Wishlist",properties:(n={wishlist_id:salla.config.get("store.id")+"_"+salla.config.get("user.id"),wishlist_name:salla.config.get("store.name"),product_id:null==(e=this.product.id)?void 0:e.toString(),name:this.product.name,brand:this.product.brand,variant:this.product.variant,price:this.product.price,quantity:Math.max(1,Number(this.product.quantity)),sku:this.product.sku||null,position:Number(this.product.position||0),url:this.product.url,image_url:(null==(t=this.product)?void 0:t.image)||null,category:this.product.category,currency:null==(a=Salla.config.currency())?void 0:a.code},n.brand=this.product.brand,n)}},e}(),Ae=function(){function e(e){this.product=e.data.product;}return e.prototype.toSegment=function(){var e,t,a,n;return {event:"Product Removed from Wishlist",properties:(n={wishlist_id:salla.config.get("store.id")+"_"+salla.config.get("user.id"),wishlist_name:salla.config.get("store.name"),product_id:null==(e=this.product.id)?void 0:e.toString(),name:this.product.name,brand:this.product.brand,variant:this.product.variant,price:this.product.price,quantity:Math.max(1,Number(this.product.quantity)),sku:this.product.sku||null,coupon:this.product.coupon||null,position:Number(this.product.position||0),currency:null==(t=Salla.config.currency())?void 0:t.code,url:this.product.url,image_url:(null==(a=this.product)?void 0:a.image)||null,category:this.product.category},n.brand=this.product.brand,n)}},e}(),Ee=function(){function e(e){this.details=e[0];}return e.prototype.toSegment=function(){return {event:"Order Completed",properties:this.details}},e}(),Se=function(){function e(e){this.item=e[0];}return e.prototype.toSegment=function(){var e,t;return {event:"Wishlist Product Added to Cart",properties:{wishlist_id:salla.config.get("store.id")+"_"+salla.config.get("user.id"),wishlist_name:salla.config.get("store.name"),cart_id:null==(e=this.item.cart_id)?void 0:e.toString(),product_id:null==(t=this.item.id)?void 0:t.toString(),category:this.item.category,name:this.item.name,brand:this.item.brand,variant:this.item.variant,price:this.item.price,quantity:this.item.quantity,sku:this.item.sku,coupon:this.item.coupon,position:this.item.position,url:this.item.url,image_url:this.item.image_url}}},e.shouldSend=function(){return "customer.wishlist"===salla.config.get("page.slug")},e}(),be=function(){function e(e){this.data=e;}return e.prototype.toSegment=function(){var e,t=(null==(e=Salla.analytics.history.find((function(e){return "Product Viewed"===e.eventName})))?void 0:e.payload)||{};return t.share_via=this.data.share_via,{event:"Product Shared",properties:t}},e.shouldSend=function(){return "product.single"===salla.config.get("page.slug")},e}(),_e=function(){function e(e){this.details=e;}return e.prototype.toSegment=function(){return {event:"Product Reviewed",properties:this.details}},e.registerEvent=function(){salla.event.rating.onProductsRated((function(e,t){var a=t.products,n=t.order_id;Object.values(a).forEach((function(e){var t;Salla.event.emit("Product Reviewed",{product_id:null==(t=e.product_id)?void 0:t.toString(),review_id:null==n?void 0:n.toString(),review_body:e.comment,rating:e.rating});}));}));},e}(),ke=function(){function e(e){this.promotion=e[0];}return e.prototype.toSegment=function(){var e;return {event:"Promotion Viewed",properties:{promotion_id:null==(e=this.promotion.id)?void 0:e.toString(),creative:this.promotion.creative,name:this.promotion.name,position:this.promotion.position}}},e}(),Be=function(){function e(e){this.promotion=e[0];}return e.prototype.toSegment=function(){var e;return {event:"Promotion Clicked",properties:{promotion_id:null==(e=this.promotion.id)?void 0:e.toString(),creative:this.promotion.creative,name:this.promotion.name,position:this.promotion.position}}},e}(),Pe=function(){function e(e){this.transaction=e;}var t=e.prototype;return t.getCartId=function(){var e,t;return "cart"===salla.config.get("page.slug")?null==(t=salla.config.get("page.id"))?void 0:t.toString():(null==(e=this.transaction)||null==(e=e.data)||null==(e=e.cart)||null==(e=e.id)?void 0:e.toString())||""},t.toSegment=function(){var e,t;return {event:"Coupon Applied",properties:{cart_id:this.getCartId(),coupon_name:(null==(e=this.transaction)||null==(e=e.data)||null==(e=e.cart)?void 0:e.coupon)||"",discount:(null==(t=this.transaction)||null==(t=t.data)||null==(t=t.cart)?void 0:t.discount)||0,currency:salla.config.get("user.currency")||""}}},e}(),qe=function(){function e(e){this.transaction=e;}var t=e.prototype;return t.getCartId=function(){var e;return "cart"===salla.config.get("page.slug")?null==(e=salla.config.get("page.id"))?void 0:e.toString():""},t.getCouponCode=function(){try{var e,t,a=null==(e=this.transaction.response)||null==(e=e.config)?void 0:e.data;return a?null==(t=JSON.parse(a))?void 0:t.coupon:""}catch(e){return ""}},t.toSegment=function(){var e;return {event:"Coupon Denied",properties:{cart_id:this.getCartId(),coupon_name:this.getCouponCode(),reason:(null==(e=this.transaction.response)||null==(e=e.data)||null==(e=e.error)?void 0:e.message)||"Unknown error"}}},e}(),xe=function(){function e(e){this.transaction=e;}var t=e.prototype;return t.getCartId=function(){var e,t;return "cart"===salla.config.get("page.slug")?null==(t=salla.config.get("page.id"))?void 0:t.toString():(null==(e=this.transaction)||null==(e=e.data)||null==(e=e.cart)||null==(e=e.id)?void 0:e.toString())||""},t.toSegment=function(){var e,t;return {event:"Coupon Removed",properties:{cart_id:this.getCartId(),coupon_name:(null==(e=this.transaction)?void 0:e.coupon)||"",discount:(null==(t=this.transaction)||null==(t=t.data)||null==(t=t.cart)?void 0:t.discount)||0,currency:salla.config.get("user.currency")||""}}},e}(),Ie=function(){function e(e){this.details=null==e?void 0:e.data;}return e.prototype.toSegment=function(){var t=this,a=["first_name","last_name","birthday","gender"].filter((function(a){var n,r;return e.user[a]!==(null==(n=t.details)?void 0:n[a])&&(void 0!==e.user[a]||void 0!==(null==(r=t.details)?void 0:r[a]))}));return e.setUser(this.details),{event:"User Profile Updated",properties:{updated_fields:a}}},e.registerEvent=function(){Salla.onReady((function(){salla.url.is_page("customer.profile")&&e.setUser(Salla.config.get("user"));}));},e.setUser=function(t){e.user={first_name:null==t?void 0:t.first_name,last_name:null==t?void 0:t.last_name,gender:null==t?void 0:t.gender,birthday:null==t?void 0:t.birthday,avatar:null==t?void 0:t.avatar};},e.shouldSend=function(){return "user"===Salla.config.get("user.type")},e}();Ie.user={};var Le=function(e){function t(t){var a;a=e.call(this,t)||this;var n=(null==t?void 0:t.nextPage)||"";return a.filters=a.extractFilters(n),a}g(t,e);var a=t.prototype;return a.extractFilters=function(e){if(!e)return null;try{var t=new URL(e),a=[];return Array.from(t.searchParams.entries()).forEach((function(e){var t=e[0],n=e[1];if(t.startsWith("filters[")){var r=t.match(/^filters\[(.*?)\]/),i=r?r[1]:t;a.push({type:i,value:n});}})),a.length>0?a:null}catch(e){return console.warn("Error extracting filters from URL:",e),null}},a.toSegment=function(){var t=e.prototype.toSegment.call(this);return {event:"Product List Filtered",properties:f({},null==t?void 0:t.properties,{filters:this.filters})}},t.shouldSend=function(e){return ((null==e?void 0:e.nextPage)||"").includes("filters")},t}(ve),Te=function(){function e(e){this.cart=e;}return e.prototype.toSegment=function(){var e,t,a,n,r=this;return {event:"Cart Updated",properties:{cart_id:null==(e=this.cart.id)?void 0:e.toString(),value:this.cart.total,revenue:this.cart.sub_total,tax:this.cart.tax_amount,discount:this.cart.total_discount,shipping:this.cart.real_shipping_cost,currency:null==(t=Salla.config.currency())?void 0:t.code,affiliation:null==(a=Salla.storage.getWithTTL("s-utms"))?void 0:a["s-utm-source"],products:null==(n=this.cart.items)?void 0:n.map((function(e){var t,a,n,i,o,u;return {product_id:null==(t=e.product_id)?void 0:t.toString(),name:e.product_name,price:e.product_price,category:null==(a=e.category)?void 0:a.toString(),sku:null==(n=e.product_sku)?void 0:n.toString(),position:e.position,url:e.url,image_url:e.product_image,brand:null==(i=e.brand)?void 0:i.toString(),currency:null==(o=Salla.config.currency())?void 0:o.code,variant:null==(u=e.variant)?void 0:u.toString(),coupon:r.cart.coupon,quantity:e.quantity}}))}}},e.shouldSend=function(e){return "cart"===salla.config.get("page.slug")&&!(null!=e&&e.fromLatestFetched)},e}(),Re=function(){function e(e){this.scope=e.data;}var t=e.prototype;return t.toSegment=function(){return {event:"Market Selected",properties:f({},this.getScope(this.scope),{prev:this.getScope(Salla.config.get("store.scope"))})}},t.getScope=function(e){var t;return {id:null==(t=(e=e||{}).id)?void 0:t.toString(),country:this.getScopeAttribute(e,"countries"),currency:this.getScopeAttribute(e,"currencies"),locale:this.getScopeAttribute(e,"languages")}},t.getScopeAttribute=function(e,t){return e=e[t],Array.isArray(e)?e[0]:e},e}(),Oe=function(){function e(e){this.details=e;}return e.prototype.toSegment=function(){var e;return {event:"Product Reordered",properties:{product_id:null==(e=this.details)||null==(e=e.data)||null==(e=e.id)?void 0:e.toString()}}},e.shouldSend=function(e){var t=null==e?void 0:e.data;return (null==t?void 0:t.id)&&!isNaN(null==t?void 0:t.id)&&"reorder"===(null==t?void 0:t.type)},e}(),je=function(){function e(){}return e.registerEvents=function(){Object.values(this.events).forEach((function(e){e.forEach((function(e){"function"==typeof e.registerEvent&&e.registerEvent();}));}));},e.transform=function(e,t){try{for(var a,n=h$1(this.events[e]||[]);!(a=n()).done;){var r=a.value;if(r&&("function"!=typeof r.shouldSend||r.shouldSend(t))){var i=new r(t).toSegment();return {event:i.event,properties:i.properties}}}return null}catch(e){return console.error("Failed to transform event:",e),null}},e}();je.events={"Order Completed":[Ee],"Product Added":[he,Se],"Product Removed":[Ce],"Product Viewed":[fe],"Product Added to Wishlist":[we],"Product Removed from Wishlist":[Ae],"Cart Viewed":[ge],"Products Searched":[me],"Product List Viewed":[ve],"Product List Filtered":[Le],"Signed Up":[Fe],"Signed In":[De],"Signed Out":[ye],"Product Reviewed":[_e],"Product Shared":[be],"Promotion Viewed":[ke],"Promotion Clicked":[Be],"Coupon Applied":[Pe],"Coupon Removed":[xe],"Coupon Denied":[qe],"User Profile Updated":[Ie],"Cart Updated":[Te],"Market Selected":[Re],"Product Reordered":[Oe]};var Ue=function(){function e(){var e=this;this.history=[],this.customTrackers=[],this.context={},this._anonymousId=null,this.mappedEvents={"wishlist::added":"Product Added to Wishlist","wishlist::removed":"Product Removed from Wishlist","salla-products-list::products.fetched":["Product List Viewed","Product List Filtered"],"auth::registered":"Signed Up","auth::logged.in":"Signed In","auth::logged.out":"Signed Out","share-element":"Product Shared","promotion::viewed":"Promotion Viewed","promotion::clicked":"Promotion Clicked","cart::coupon.added":"Coupon Applied","cart::coupon.deleted":"Coupon Removed","cart::coupon.addition.failed":"Coupon Denied","profile::updated":"User Profile Updated","cart::updated":"Cart Updated","scope::changed":"Market Selected","order::order.created":"Product Reordered"},Salla.event.onAny((function(t,a){try{if(Object.keys(e.mappedEvents).includes(t)){var n=e.mappedEvents[t];return void(Array.isArray(n)?n:[n]).forEach((function(e){return Salla.event.emit(e,a)}))}if(!Salla.config.get("jitsu.events",[]).includes(t))return;var r=je.transform(t,a);r&&e.track(r.event,r.properties);}catch(e){Salla.log("Error in analytics event handling:",e);}})),Salla.event.on("twilight::before.ready",(function(t){var a,n,r,o,u,s;e.debugAnalytics=jitsuAnalytics({host:"https://st.salla.dev",writeKey:"bbLD6Xqr1OKsDJfxZBCy7SJN1RIsrkBp:WEa99iY220v9qX7KiuAlML9ldSFJKW2p"});var l=(null==t?void 0:t.jitsu)||{},c=l.host,d=l.key;if(e.jitsuAnalytics=null,c&&d){var p;if(je.registerEvents(),e.jitsuAnalytics=jitsuAnalytics({host:e.getAnalyticsHost(t),writeKey:d}),e._anonymousId=(null==(a=e.jitsuAnalytics)||null==(a=a.user())?void 0:a.anonymousId)||null,e.setContext("store_id",null==(n=t.store)?void 0:n.id),e.setContext("version",null==(r=t.jitsu)?void 0:r.version),e.setContext("library",{twilight:Salla.versions}),null!=(o=t.jitsu)&&null!=(o=o.context)&&o.extra&&e.setExtraContext(t.jitsu.context.extra),null!=(u=t.store)&&null!=(u=u.scope)&&u.id)e.setContext("scope",null==(p=t.store)?void 0:p.scope);"user"===(null==t||null==(s=t.user)?void 0:s.type)&&e.setContext("traits",e.getFormattedUser(t.user)),e.registerTracker({name:"DefaultSallaTracker",track:function(t,a){return e.jitsuAnalytics.track(t,a)},page:function(t){return e.jitsuAnalytics.page(t)}});}else salla.log("Jitsu configuration is missing. Analytics will not be tracked.");})),Salla.onReady((function(){var t,a={name:Salla.config.get("page.slug",""),id:null==(t=Salla.config.get("page.id",""))?void 0:t.toString()};e.setContext("page",a),e.page(a);}));}var t=e.prototype;return t.setExtraContext=function(e){var t;null!=e&&null!=(t=e.headers)&&t["s-app-os"]&&(this.setContext("app",{version:e.headers["s-app-os-version"],app_release_tag:e.headers["s-app-version"],platform:e.headers["s-app-os"].toLowerCase()}),delete e.headers["s-app-os"],delete e.headers["s-app-os-version"],delete e.headers["s-app-version"],delete e.headers["s-source"]),this.setContext("system",e);},t.getAnalyticsHost=function(e){var t,a="https://salla.cloud/_app/e";if(null==e||null==(t=e.store)||!t.url)return Salla.log("Error getting store url - no config or store URL provided"),a;var n=e.store.url;try{var r="",i=n;if(/https:\/\/demostore\.salla\.sa/.test(i)){var o=i.match(/demostore\.salla\.sa\/(?:(ar|en)\/)?((?!ar$|en$)[a-zA-Z0-9.-]+)/);if(o&&o[2]){var u=o[2];return new URL(i).origin+"/"+u+"/_app/e"}return a}var s=i.match(/(salla\.sa)\/(?:(ar|en)\/)?((?!ar$|en$)[a-zA-Z0-9.-]+)/);if(s){var l=s[3];if(!l||0===l.trim().length||"ar"===l||"en"===l)return Salla.log("Error: invalid or empty store name in salla.sa URL"),a;r=new URL(i).origin+"/"+l;}else {r=new URL(i).origin;}return r+"/_app/e"}catch(e){return Salla.log("Error getting store url, forwarding to salla.cloud:",e),a}},t.setContext=function(e,t){var a,n;null==(a=this.jitsuAnalytics)||a.setContextProperty(e,t),null==(n=this.debugAnalytics)||n.setContextProperty(e,t),this.context[e]=t;},t.setAppContext=function(e,t){if(this.jitsuAnalytics)if(e&&"string"==typeof e)if(t&&"object"==typeof t){var a=this.context.apps_context||{};a[e]=f({},a[e],t),this.setContext("apps_context",a);}else Salla.log("setAppContext: payload must be an object");else Salla.log("setAppContext: appId must be a non-empty string");else Salla.log("setAppContext: Analytics not initialized yet");},t.customFetch=function(e,t){var a;return Salla.api.beaconRequest(e+"?writekey="+(null==t||null==(a=t.headers)?void 0:a["X-Write-Key"]),t)},t.track=function(e,t){ void 0===t&&(t={}),t=this.finalPayload(t),this.history.push({action:"track",eventName:e,payload:t}),this.pushEventToCustomTrackers("track",e,t);},t.log=function(e,t){var a;return void 0===t&&(t={}),null==(a=this.debugAnalytics)?void 0:a.track(e,t).catch((function(e){return Salla.log("Error tracking event:",e),Promise.reject(e)}))},t.page=function(e){var t,a;void 0===e&&(e={}),(e=this.finalPayload(e)).id=null==(t=e.id||Salla.config.get("page.id",""))?void 0:t.toString(),e.name=e.name||Salla.config.get("page.slug"),e.keywords=e.keywords||(null==(a=document.querySelector("meta[name=keywords]"))?void 0:a.content),e.referrer=e.referrer||document.referrer,this.history.push({action:"page",payload:e}),this.pushEventToCustomTrackers("page",e);},t.finalPayload=function(e){ void 0===e&&(e={});return this.attachRealtimeContext(),f({},{},e)},t.attachRealtimeContext=function(){try{var e=["user.id","cart.id","cart.user_id","cart.count","cart.summary.count","scope.id","branch-choosed-before"].reduce((function(e,t){var a=Salla.storage.get(t);return a&&(e[t.replace(".","_")]=a),e}),{});Object.keys(e).length>0&&this.setContext("localStorage",e);}catch(e){Salla.analytics.log("attachRealtimeContext",{error:e.message}),Salla.log("Error attaching realtime context:",e);}var t=Salla.storage.getWithTTL("s-utms");if(t){var a=t["s-utm-campaign"],n=t["s-utm-source"],r=t["s-utm-medium"],i=t["s-utm-term"],o=t["s-utm-content"],u=t["s-utm-referrer"];this.setContext("campaign",{name:a,source:n,medium:r,term:i,content:o,referrer:u});}},t.registerTracker=function(e){"object"==typeof e?"string"==typeof e.name&&e.name?"function"==typeof e.track?"function"==typeof e.page?this.customTrackers.find((function(t){return t.name===e.name}))?Salla.log("tracker with the same name already exists!"):(this.customTrackers.push(e),this.history.forEach((function(t){return "track"===t.action?e.track(t.eventName,t.payload):"page"===t.action?e.page(t.payload):void 0}))):Salla.log("tracker.page most be a function!"):Salla.log("tracker.track most be a function!"):Salla.log("tracker.name most be a string!"):Salla.log('tracker most be an object {name:"tracker name", track: callback, page: callback}!');},t.pushEventToCustomTrackers=function(e,t,a){var n=this;void 0===a&&(a={});var r="page"===e?[t]:[t,a];return Promise.allSettled(this.customTrackers.map((function(t){return n.pushEventToCustomTracker(t[e],r)}))).then((function(t){return t.filter((function(e){return "rejected"===e.status})).map((function(t){return Salla.log("Error on customTracker to send "+e,t)}))}))},t.pushEventToCustomTracker=function(e,t){try{var a=e.apply(void 0,t);return Promise.resolve(a).catch((function(e){return Promise.reject(e)}))}catch(e){return Promise.reject(e)}},t.getFormattedUser=function(e){return e.phone=e.mobile,e.country=e.country_code,e.language=e.language_code,e.currency=e.currency_code,e},t.getAnonymousId=function(){try{if(this._anonymousId)return this._anonymousId;if(this.jitsuAnalytics){var e,t=null==(e=this.jitsuAnalytics.user())?void 0:e.anonymousId;if(t)return this._anonymousId=t,t}return null}catch(e){return Salla.log("Error getting anonymous ID from Jitsu:",e),null}},e}(),Ne=function(){function e(){var e=this;Salla.onReady((function(){return e.init()}));}var t=e.prototype;return t.init=function(){if(!Salla.config.isUser()){var e=new URLSearchParams(window.location.search);if(e.has("intended_to"))try{var t=new URL(e.get("intended_to"));if(t.hostname!==window.location.hostname)return;return this.handleAfterLoginEvent(t)}catch(e){return void console.warn("Invalid URL provided in intended_to parameter")}}},t.handleAfterLoginEvent=function(e){var t="intend::user.logged.in";Salla.event.on(t,(function(){return window.location=e})),Salla.api.auth.setAfterLoginEvent(t),Salla.api.auth.setCanRedirect(false),Salla.event.on("salla-login::ready",(function(){return Salla.event.emit("login::open",{withoutReload:true})}));},e}(),Me=function(){function e(e){var t=this;void 0===e&&(e={}),this.config=f({WHITELIST:[location.hostname,"salla.com","salla.sa","salla.dev","salla.network","salla.group","mtjr.at"],POLL_INTERVAL_MS:500,WHITELIST_PAGES:["customer.orders.single","page-single","blog.single","blog.index"]},e),this.originalMethods={},this.isInitialized=false,Salla.onReady((function(){return t.init()}));}var t=e.prototype;return t.normalizeUrl=function(e){try{return new URL(e,location.href)}catch(e){return null}},t.shouldIgnoreUrl=function(e){if(!e)return false;var t="string"==typeof e?e:e.href||String(e),a=t.toLowerCase();if(["tel:","mailto:","javascript:"].some((function(e){return a.startsWith(e)})))return true;try{var n=new URL(t,location.href).hostname.toLowerCase();return ["facebook.com","fb.com","twitter.com","x.com","instagram.com","linkedin.com","youtube.com","youtu.be","tiktok.com","snapchat.com","pinterest.com","whatsapp.com","wa.me","iwtsp.com","telegram.org","t.me","discord.com","discord.gg","reddit.com","tumblr.com","google.com","forms.gle","maps.app.goo.gl","goo.gl","apple.com","smsaexpress.com","aramex.com","aj-ex.com","redboxsa.com","fastcoo-tech.com","express.dhl","najizxpress.net","jtexpress.me","jtexpress-sa.com","tamex.com.sa","aymakan.com.sa","fastlo.com","sls-express.com","logestechs.com","massuul.com","tamara.co","gov.sa","org.sa","stc.com.sa","sa","addtoany.com","wchat.freshchat.com","getbutton.io","heyzine.com","linktr.ee"].some((function(e){return n===e||n.endsWith("."+e)}))}catch(e){return false}},t.isWhitelisted=function(e){if(!e)return false;for(var t,a=e.hostname.toLowerCase(),n=h$1(this.config.WHITELIST);!(t=n()).done;){var r=t.value,i=String(r||"").toLowerCase().trim();if(i&&(a===i||a.endsWith("."+i)))return true}return false},t.emit=function(e){try{window.__redirectLogs||(window.__redirectLogs=[]),window.__redirectLogs.push(e);try{Salla.analytics.log("redirect",e);}catch(e){}}catch(e){}},t.logRedirect=function(e,t,a){if(!this.shouldIgnoreUrl(t)){var n=this.normalizeUrl(t),r=this.normalizeUrl(location.href),i=this.isWhitelisted(n),o={redirect_source:e,redirect_from:r?r.href:String(location.href),redirect_to:n?n.href:String(t),redirect_host:n?n.hostname:null,redirect_referrer:document.referrer||null,page_slug:Salla.config.get("page.slug"),whitelisted:i,stack:a&&a.stack?String(a.stack):void 0,meta:a||void 0};i||this.emit(o);}},t.hookHistoryAPIs=function(){var e=this;["pushState","replaceState"].forEach((function(t){try{var a=history[t];"function"==typeof a&&(e.originalMethods["history."+t]=a,history[t]=function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];try{var o;e.logRedirect(t,null!=(o=r[2])?o:location.href);}catch(e){}return a.apply(history,r)});}catch(e){}})),window.addEventListener("popstate",(function(){e.logRedirect("popstate",location.href);})),window.addEventListener("hashchange",(function(){e.logRedirect("hashchange",location.href);}));},t.hookLocationMethods=function(){var e=this;try{var t=location.assign.bind(location);this.originalMethods["location.assign"]=t,location.assign=function(a){return e.logRedirect("location.assign",a,{stack:(new Error).stack}),t(a)};}catch(e){}try{var a=location.replace.bind(location);this.originalMethods["location.replace"]=a,location.replace=function(t){return e.logRedirect("location.replace",t,{stack:(new Error).stack}),a(t)};}catch(e){}},t.hookWindowOpen=function(){var e=this;try{var t=window.open;this.originalMethods["window.open"]=t,window.open=function(a){a&&e.logRedirect("window.open",a,{stack:(new Error).stack});for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return t.apply(window,[a].concat(r))};}catch(e){}},t.setupEventListeners=function(){var e=this;this.handleLinkClick=function(t){var a=t.target&&t.target.closest?t.target.closest("a[href]"):null;if(a){var n=a.getAttribute("href");if(n&&!n.startsWith("#")&&!e.shouldIgnoreUrl(n)){var r=a.getAttribute("target")||"_self";setTimeout((function(){e.logRedirect("link-click",n,{target:r});}),0);}}},document.addEventListener("click",this.handleLinkClick,true),this.handleFormSubmit=function(t){var a=t.target,n=a&&a.getAttribute&&a.getAttribute("action")||location.href,r=(a&&a.method?String(a.method):"GET").toUpperCase();e.logRedirect("form-submit",n,{method:r});},document.addEventListener("submit",this.handleFormSubmit,true);},t.setupPerformanceObserver=function(){var e=this;try{this.performanceObserver=new PerformanceObserver((function(t){for(var a,n=h$1(t.getEntries());!(a=n()).done;){var r=a.value;"navigation"===r.entryType&&e.logRedirect("performance-navigation",location.href,{type:r.type,redirectCount:r.redirectCount});}})),this.performanceObserver.observe({type:"navigation",buffered:true});}catch(e){}},t.init=function(){if(!this.config.WHITELIST_PAGES.includes(Salla.config.get("page.slug"))&&!this.isInitialized){var e=new URL(Salla.config.get("store.url")).hostname.split(".").slice(-2).join(".");this.config.WHITELIST.includes(e)||this.config.WHITELIST.push(e),this.hookHistoryAPIs(),this.hookLocationMethods(),this.hookWindowOpen(),this.setupEventListeners(),this.setupPerformanceObserver(),this.isInitialized=true;}},t.destroy=function(){var e=this;this.isInitialized&&(Object.keys(this.originalMethods).forEach((function(t){var a=t.split("."),n=a[0],r=a[1];"history"===n&&e.originalMethods[t]?history[r]=e.originalMethods[t]:"location"===n&&e.originalMethods[t]?location[r]=e.originalMethods[t]:"window"===n&&"open"===r&&e.originalMethods[t]&&(window.open=e.originalMethods[t]);})),this.handleLinkClick&&document.removeEventListener("click",this.handleLinkClick,true),this.handleFormSubmit&&document.removeEventListener("submit",this.handleFormSubmit,true),this.performanceObserver&&this.performanceObserver.disconnect(),this.isInitialized=false);},e}(),He=function(){function e(){this._store=new Map,this._whitelist=new Map([["salla-add-product-button",new Set(["validate","componentDidLoad"])],["salla-products-list",new Set(["componentDidLoad"])],["salla-hook",new Set(["componentDidLoad"])]]),this._themeSlots=["head","head:start","head:end","body:start","body:end","product:index.items.start","product:index.items.end","product:single.description.start","product:single.description","product:single.description.end","product:single.form.start","product:single.form.end","blog:index.items.start","blog:index.items.end","blog:single.items.start","blog:single.items.end","brands:index.items.start","brands:index.items.end","brands:single.details.start","brands:single.details.end","brands:single.items.start","brands:single.items.end","cart:items.start","cart:items.end","cart:summary.start","cart:summary.end","cart:submit.start","cart:submit.end","customer:notifications.items.start","customer:notifications.items.end","customer:orders.index.items.start","customer:orders.index.items.end","customer:orders.single.details.start","customer:orders.single.details.end","customer:wishlist.items.start","customer:wishlist.items.end","customer:profile.form.start","customer:profile.form.fields.start","customer:profile.form.fields.end","customer:profile.form.submit.start","customer:profile.form.submit.end","customer:profile.form.end","thank-you:start","thank-you:items.start","thank-you:items.end","thank-you:end"],this._componentHistory=new Map;}var t=e.prototype;return t.registerHook=function(e,t,a,n){var r=this;if(void 0===n&&(n={}),!this._isAllowed(e,t))return console.warn('[Hooks] Hook "'+e+":"+t+'" is not allowed'),function(){};var i=0|n.priority,o=!!n.once,u=this._ensureTag(e),s=u.get(t)||[];return s.push({cb:a,p:i,once:o}),s.sort((function(e,t){return t.p-e.p})),u.set(t,s),"componentDidLoad"===t&&this._callForLoadedComponents(e,a),function(){return r.removeHook(e,t,a)}},t.registerHookOnce=function(e,t,a,n){return void 0===n&&(n={}),this.registerHook(e,t,a,f({},n,{once:true}))},t.call=async function(e,t,a){var n=this._store.get(e);if(n){var r=n.get(t);if(r&&0!==r.length)for(var i=0,o=[].concat(r);i<o.length;i++){var u=o[i];try{await u.cb(a);}catch(a){console.warn('[Hooks] "'+e+":"+t+'" callback failed:',a);}u.once&&this.removeHook(e,t,u.cb);}}},t.removeHook=function(e,t,a){var n=this._store.get(e);if(!n)return false;if(!n.has(t))return false;if(!a)return n.delete(t),0===n.size&&this._store.delete(e),true;var r=n.get(t),i=r.findIndex((function(e){return e.cb===a}));return i>-1&&(r.splice(i,1),0===r.length&&n.delete(t),0===n.size&&this._store.delete(e),true)},t.clear=function(e){e?this._store.delete(e):this._store.clear();},t.get=function(e,t){var a,n=this._store.get(e);return n&&(null==(a=n.get(t))?void 0:a.map((function(e){return e.cb})))||[]},t._ensureTag=function(e){var t=this._store.get(e);return t||(t=new Map,this._store.set(e,t)),t},t._isAllowed=function(e,t){var a=this._whitelist.get(e);return a?!!a.has(t)||(console.warn('[Hooks] Hook "'+t+'" is not allowed for tag "'+e+'"'),false):(console.warn('[Hooks] Tag "'+e+'" is not in the whitelist'),false)},t.registerComponent=function(e,t){this._componentHistory.has(e)||this._componentHistory.set(e,new Set);var a=this._componentHistory.get(e);if(!a.has(t))return a.add(t),this.call(e,"componentDidLoad",t)},t._callForLoadedComponents=async function(e,t){var a=this._componentHistory.get(e);if(a&&0!==a.size)for(var n,r=h$1(a);!(n=r()).done;){var i=n.value;try{await t(i);}catch(t){console.warn('[Hooks] "'+e.replace(/[^a-zA-Z0-9-_]/g,"")+':componentDidLoad" callback failed:',t);}}},t.mount=function(e,t){var a=this;return this._themeSlots.includes(e)?new Promise((function(n){a.registerHook("salla-hook","componentDidLoad",(function(a){a.name===e&&(a.mount(t),n(t));}));})):(console.warn('[Hooks] Hook "'+e+'" is not allowed'),Promise.reject(t))},e}();N$3.versions.twilight="2.14.337",N$3.onInitiated=function(e){return salla.event.once("twilight::initiated",e)},N$3.onReady=N$3.onReady||function(t){return new Promise((function(a){return "ready"===salla.status?a(t?t(salla.config.all()):salla.config.all()):N$3.onInitiated((function(e){return a(t?t(e):e)}))}))},N$3.status="loading",N$3.notify=l,N$3.lang=new H,N$3.form=new M,N$3.infiniteScroll=new N(void 0,salla.event.infiniteScroll),N$3.api=new ce,N$3.sso=new pe,N$3.intend=new Ne,N$3.hooks=new He,["cart","auth","order","scope","rating","comment","loyalty","product","profile","currency","document","wishlist","booking","landing","metadata"].forEach((function(t){return N$3[t]=new c(N$3.api[t],N$3.event[t])})),N$3.call=function(t){for(var a=N$3,n=t.split(".");n.length&&(a=a[n.shift()]););return a},N$3.analytics=new Ue,N$3.partnerApp=function(t){return {setContext:function(a){if(!t)throw new Error("App ID not provided");return N$3.analytics.setAppContext(t,a),this}}},N$3.init=function(e){return new de(e)},new Me,salla.event.once("twilight::init",salla.init),salla.event.on("twilight::api",(function(e){var t=null==e?void 0:e.events;t&&salla.event.dispatchEvents(t);})),N$3.success=N$3.notify.success,N$3.error=N$3.notify.error,window.dispatchEvent(new CustomEvent("salla::created"));
|
|
12172
12335
|
|
|
12173
12336
|
var lazyload_min$1 = {exports: {}};
|
|
12174
12337
|
|