@salla.sa/twilight 2.6.19 → 2.7.1
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/@salla.sa/twilight.min.js +4 -5
- package/dist/@salla.sa/twilight.min.js.map +1 -1
- package/dist/cjs/index.js +3 -27
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +3 -27
- package/dist/esm/index.js.map +1 -1
- package/package.json +10 -5
- package/types/api/index.d.ts +3 -1
- package/types/lib/salla-config.ts +3 -3
- package/types/tiwlight-config.d.ts +3 -0
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).salla={})}(this,(function(exports){"use strict";let notifier=function(e,t,r){return alert(e)},setNotifier=function(e){notifier=e},fire=function(e,t,r){return notifier(e,t,r)},error=function(e,t){return notifier(e,types.error,t)},info=function(e,t){return notifier(e,types.info,t)},success=function(e,t){return notifier(e,types.success,t)},sallaInitiated=function(){let e=window.location.href.match(/([\?\&]danger=)[^&]+/g);e&&e.forEach((e=>{error(decodeURI(e.replace("?danger=","").replace("&danger=","")))}))},types={error:"error",success:"success",info:"info"};var Notify={fire:fire,setNotifier:setNotifier,error:error,success:success,info:info,sallaInitiated:sallaInitiated,types:types},Logger=function(e){let t={log:function(t,r){if(!e)return;"trace"===salla.config.get("debug")&&(r="trace");let i=e.log,n=void 0===r?i:this.__dict__[r]||i,a=["%cTwilight","color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;"],s={event:"#CFF680",backend:"#7b68ee"}[r];s&&(a[0]+="%c"+r[0].toUpperCase()+r.substring(1),a.push(`margin-left: 5px;color: ${s};font-weight:bold; border:1px solid ${s}; padding: 2px 6px; border-radius: 5px;`)),n.call(e,...a.concat(...t))},__dict__:{trace:e.trace,debug:e.debug,info:e.info,warn:e.warn,error:e.error}};return{event:function(){t.log(arguments,"event")},trace:function(){t.log(arguments,"trace")},debug:function(){t.log(arguments,"debug")},info:function(){t.log(arguments,"info")},warn:function(){t.log(arguments,"warn")},error:function(){t.log(arguments,"error")},log:function(){t.log(arguments,void 0)},backend:function(){t.log(arguments,"backend")},logs:function(e){[e].flat().forEach((e=>e&&t.log([e].flat(),"backend")))}}}(window.console);class BaseEvent{constructor(e){this.parent=e,this.events={},this.namespace="";let t=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(t&&t.length>1?t[1]:"").toLowerCase()}after_init(){this.createDynamicFunctions()}createDynamicFunctions(){Object.keys(this.events).forEach((e=>{this.createDynamicEventFuns(e),this.createDynamicListenerFuns(e)}))}createDynamicEventFuns(e){if(this[e])return;let t=this;this[e]=function(...r){return t.dispatch(e,...r)}}createDynamicListenerFuns(e){let t="on"+e.charAt(0).toUpperCase()+e.slice(1);if(this[t])return;let r=this;this[t]=function(t){return r.on(e,t)}}getEventName(e){return e=this.events[e]||e,!this.namespace||e.includes("::")?e:this.namespace+this.parent.delimiter+e}dispatch(e,...t){return this.parent.dispatch(this.getEventName(e),...t)}on(e,t){this.parent.addListener(this.getEventName(e),t)}once(e,t){this.parent.once(this.getEventName(e),t)}register(e,t){this.on(e,t)}registerEventTemporary(e,t,r){r||(r=1),emitter.many(e,r,t)}}class AuthEvents extends BaseEvent{constructor(e){super(e),this.namespace="auth",this.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",tokenFetched:"token.fetched",refreshFailed:"refresh.failed"},this.after_init()}login(e){return e?(e.type&&this.setTypeActionOnVerified(e.type),this.next_event=e.next_event||null,this.dispatch("login",...arguments)):(this.next_event=null,this.dispatch("login",...arguments))}loggedIn(e){salla.profile.info().then((e=>{salla.config.set("user",{id:e.data.id,type:"user",email:e.data.email,mobile:e.data.phone.code+e.data.phone.number,country_code:e.data.phone.country,language_code:e.data.language,currency_code:e.data.currency})})).finally((()=>this.dispatch("loggedIn",e)))}setTypeActionOnVerified(e){this.type_action_on_verified=e}getTypeActionOnVerified(){return this.type_action_on_verified||"redirect"}}class CartEvents extends BaseEvent{constructor(e){super(e),this.namespace="cart",this.events={latestFetched:"latest.fetched",latestFailed:"latest.failed",updated:"updated",itemUpdated:"item.updated",itemUpdatedFailed:"item.updated.failed",itemAdded:"item.added",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",couponAdded:"coupon.added",couponDeleted:"coupon.deleted",couponAdditionFailed:"coupon.addition.failed",couponDeletionFailed:"coupon.deletion.failed"},this.after_init()}updated(e){return salla.cookie.set("fresh_summary",1),e&&"object"==typeof e?(e.offer&&salla.product.event.offerExisted(e.offer),salla.storage.set("cart.summary",{total:e.cart.total,sub_total:e.cart.sub_total,discount:e.cart.discount,real_shipping_cost:e.cart.real_shipping_cost,count:e.cart.count,shipping_cost:e.cart.free_shipping_bar?.has_free_shipping?0:e.cart.real_shipping_cost}),this.dispatch("updated",e.cart)):(salla.logger.info("Cart summary not an object!",e),this.dispatch("updated"))}latestFetched(e){return this.updated(e.data),this.dispatch("latestFetched",e)}itemAdded(e,t){return this.updated(e.data),this.dispatch("itemAdded",e,t)}itemDeleted(e,t){return this.updated(e.data),this.dispatch("itemDeleted",e,t)}itemUpdated(e,t){return this.updated(e.data),this.dispatch("itemUpdated",e,t)}couponAdded(e,t){return this.updated(e.data),this.dispatch("couponAdded",e,t)}couponDeleted(e,t){return this.updated(e.data),this.dispatch("couponDeleted",e,t)}}class OrderEvents extends BaseEvent{constructor(e){super(e),this.namespace="order",this.events={canceled:"canceled",notCanceled:"not.canceled",orderCreated:"order.created",orderCreationFailed:"order.creation.failed",invoiceSent:"invoice.sent",invoiceNotSent:"invoice.not.sent"},this.after_init()}}class ScopeEvents extends BaseEvent{constructor(e){super(e),this.namespace="scope",this.events={fetched:"fetched",notFetched:"not.fetched",productAvailabilityFetched:"product-availability.fetched",productAvailabilityNotFetched:"product-availability.not.fetched",changeSucceeded:"changed",changeFailed:"not.changed"},this.after_init()}}class RatingEvents extends BaseEvent{constructor(e){super(e),this.namespace="rating",this.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"},this.after_init()}}class CommentEvents extends BaseEvent{constructor(e){super(e),this.namespace="comment",this.events={added:"added",additionFailed:"addition.failed"},this.after_init()}}class LoyaltyEvents extends BaseEvent{constructor(e){super(e),this.namespace="loyalty",this.events={exchangeSucceeded:"exchange.succeeded",exchangeFailed:"exchange.failed",programFetched:"program.fetched",programNotFetched:"program.not.fetched",resetSucceeded:"exchange-reset.succeeded",resetFailed:"exchange-reset.failed"},this.after_init()}}class ProfileEvents extends BaseEvent{constructor(e){super(e),this.namespace="profile",this.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"},this.after_init()}}class ProductEvents extends BaseEvent{constructor(e){super(e),this.namespace="product",this.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",addGiftToCartSucceeded:"gift.add-to-cart.succeeded",addGiftToCartFailed:"gift.add-to-cart.failed",giftImageUploadSucceeded:"gift.image-upload.succeeded",giftImageUploadFailed:"gift.image-upload.failed"},this.after_init()}}class DocumentEvents extends BaseEvent{constructor(e){super(e),this.namespace="document",this.events={click:"click",change:"change",submit:"submit",keyup:"keyup",leaving:"leaving",request:"request",requestFailed:"request.failed"},this.after_init()}onClick(e,t){this.fireCallableFuns("click",e,t)}onChange(e,t){this.fireCallableFuns("change",e,t)}onSubmit(e,t){this.fireCallableFuns("submit",e,t)}onKeyup(e,t){this.fireCallableFuns("keyup",e,t)}fireCallableFuns(e,t,r){this.on(e,(e=>{"function"!=typeof t?"function"==typeof r&&e.target.matches(t)&&r(e):t(e)}))}fireEvent(e,t,...r){return this.fireEventForElements(e,t,!1,...r)}fireEventForAll(e,t,...r){return this.fireEventForElements(e,t,!0,...r)}fireEventForElements(e,t,r,...i){if("string"==typeof e){if(r)return document.querySelectorAll(e).forEach((e=>this.fireEventForElements(e,t,!1,...i)));e=document.querySelector(e)}if(!e)return void salla.log("Failed To get element to fire event: "+t);const n=new CustomEvent(t,...i);return e.dispatchEvent(n)}}class WishlistEvents extends BaseEvent{constructor(e){super(e),this.namespace="wishlist",this.events={added:"added",removed:"removed",additionFailed:"addition.failed",removingFailed:"removing.failed"},this.after_init()}}class CurrencyEvents extends BaseEvent{constructor(e){super(e),this.namespace="currency",this.events={changed:"changed",failed:"failed",fetched:"fetched",failedToFetch:"failed.to.fetch"},this.after_init()}}class TwilightEvents extends BaseEvent{constructor(e){super(e),this.namespace="twilight",this.events={initiated:"initiated"},this.after_init()}}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},eventemitter2$1={exports:{}};
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).salla={})}(this,(function(e){"use strict";let t=function(e,t,r){return alert(e)},r=function(e,r){return t(e,n.error,r)},n={error:"error",success:"success",info:"info"};var i={fire:function(e,r,n){return t(e,r,n)},setNotifier:function(e){t=e},error:r,success:function(e,r){return t(e,n.success,r)},info:function(e,r){return t(e,n.info,r)},sallaInitiated:function(){let e=window.location.href.match(/([\?\&]danger=)[^&]+/g);e&&e.forEach((e=>{r(decodeURI(e.replace("?danger=","").replace("&danger=","")))}))},types:n},s=function(e){let t={log:function(t,r){if(!e)return;"trace"===salla.config.get("debug")&&(r="trace");let n=e.log,i=void 0===r?n:this.__dict__[r]||n,s=["%cTwilight","color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;"],a={event:"#CFF680",backend:"#7b68ee"}[r];a&&(s[0]+="%c"+r[0].toUpperCase()+r.substring(1),s.push(`margin-left: 5px;color: ${a};font-weight:bold; border:1px solid ${a}; padding: 2px 6px; border-radius: 5px;`)),i.call(e,...s.concat(...t))},__dict__:{trace:e.trace,debug:e.debug,info:e.info,warn:e.warn,error:e.error}};return{event:function(){t.log(arguments,"event")},trace:function(){t.log(arguments,"trace")},debug:function(){t.log(arguments,"debug")},info:function(){t.log(arguments,"info")},warn:function(){t.log(arguments,"warn")},error:function(){t.log(arguments,"error")},log:function(){t.log(arguments,void 0)},backend:function(){t.log(arguments,"backend")},logs:function(e){[e].flat().forEach((e=>e&&t.log([e].flat(),"backend")))}}}(window.console);class a{constructor(e){this.parent=e,this.events={},this.namespace="";let t=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(t&&t.length>1?t[1]:"").toLowerCase()}after_init(){this.createDynamicFunctions()}createDynamicFunctions(){Object.keys(this.events).forEach((e=>{this.createDynamicEventFuns(e),this.createDynamicListenerFuns(e)}))}createDynamicEventFuns(e){if(this[e])return;let t=this;this[e]=function(...r){return t.dispatch(e,...r)}}createDynamicListenerFuns(e){let t="on"+e.charAt(0).toUpperCase()+e.slice(1);if(this[t])return;let r=this;this[t]=function(t){return r.on(e,t)}}getEventName(e){return e=this.events[e]||e,!this.namespace||e.includes("::")?e:this.namespace+this.parent.delimiter+e}dispatch(e,...t){return this.parent.dispatch(this.getEventName(e),...t)}on(e,t){this.parent.addListener(this.getEventName(e),t)}once(e,t){this.parent.once(this.getEventName(e),t)}register(e,t){this.on(e,t)}registerEventTemporary(e,t,r){r||(r=1),emitter.many(e,r,t)}}class o extends a{constructor(e){super(e),this.namespace="auth",this.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",tokenFetched:"token.fetched",refreshFailed:"refresh.failed"},this.after_init()}login(e){return e?(e.type&&this.setTypeActionOnVerified(e.type),this.next_event=e.next_event||null,this.dispatch("login",...arguments)):(this.next_event=null,this.dispatch("login",...arguments))}loggedIn(e){salla.profile.info().then((e=>{salla.config.set("user",{id:e.data.id,type:"user",email:e.data.email,mobile:e.data.phone.code+e.data.phone.number,country_code:e.data.phone.country,language_code:e.data.language,currency_code:e.data.currency})})).finally((()=>this.dispatch("loggedIn",e)))}setTypeActionOnVerified(e){this.type_action_on_verified=e}getTypeActionOnVerified(){return this.type_action_on_verified||"redirect"}}class l extends a{constructor(e){super(e),this.namespace="cart",this.events={latestFetched:"latest.fetched",latestFailed:"latest.failed",updated:"updated",itemUpdated:"item.updated",itemUpdatedFailed:"item.updated.failed",itemAdded:"item.added",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",couponAdded:"coupon.added",couponDeleted:"coupon.deleted",couponAdditionFailed:"coupon.addition.failed",couponDeletionFailed:"coupon.deletion.failed"},this.after_init()}updated(e){return salla.cookie.set("fresh_summary",1),e&&"object"==typeof e?(e.offer&&salla.product.event.offerExisted(e.offer),salla.storage.set("cart.summary",{total:e.cart.total,sub_total:e.cart.sub_total,discount:e.cart.discount,real_shipping_cost:e.cart.real_shipping_cost,count:e.cart.count,shipping_cost:e.cart.free_shipping_bar?.has_free_shipping?0:e.cart.real_shipping_cost}),this.dispatch("updated",e.cart)):(salla.logger.info("Cart summary not an object!",e),this.dispatch("updated"))}latestFetched(e){return this.updated(e.data),this.dispatch("latestFetched",e)}itemAdded(e,t){return this.updated(e.data),this.dispatch("itemAdded",e,t)}itemDeleted(e,t){return this.updated(e.data),this.dispatch("itemDeleted",e,t)}itemUpdated(e,t){return this.updated(e.data),this.dispatch("itemUpdated",e,t)}couponAdded(e,t){return this.updated(e.data),this.dispatch("couponAdded",e,t)}couponDeleted(e,t){return this.updated(e.data),this.dispatch("couponDeleted",e,t)}}class c extends a{constructor(e){super(e),this.namespace="order",this.events={canceled:"canceled",notCanceled:"not.canceled",orderCreated:"order.created",orderCreationFailed:"order.creation.failed",invoiceSent:"invoice.sent",invoiceNotSent:"invoice.not.sent"},this.after_init()}}class u extends a{constructor(e){super(e),this.namespace="scope",this.events={fetched:"fetched",notFetched:"not.fetched",productAvailabilityFetched:"product-availability.fetched",productAvailabilityNotFetched:"product-availability.not.fetched",changeSucceeded:"changed",changeFailed:"not.changed"},this.after_init()}}class h extends a{constructor(e){super(e),this.namespace="rating",this.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"},this.after_init()}}class d extends a{constructor(e){super(e),this.namespace="comment",this.events={added:"added",additionFailed:"addition.failed"},this.after_init()}}class f extends a{constructor(e){super(e),this.namespace="loyalty",this.events={exchangeSucceeded:"exchange.succeeded",exchangeFailed:"exchange.failed",programFetched:"program.fetched",programNotFetched:"program.not.fetched",resetSucceeded:"exchange-reset.succeeded",resetFailed:"exchange-reset.failed"},this.after_init()}}class p extends a{constructor(e){super(e),this.namespace="profile",this.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"},this.after_init()}}class g extends a{constructor(e){super(e),this.namespace="product",this.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",addGiftToCartSucceeded:"gift.add-to-cart.succeeded",addGiftToCartFailed:"gift.add-to-cart.failed",giftImageUploadSucceeded:"gift.image-upload.succeeded",giftImageUploadFailed:"gift.image-upload.failed"},this.after_init()}}class m extends a{constructor(e){super(e),this.namespace="document",this.events={click:"click",change:"change",submit:"submit",keyup:"keyup",leaving:"leaving",request:"request",requestFailed:"request.failed"},this.after_init()}onClick(e,t){this.fireCallableFuns("click",e,t)}onChange(e,t){this.fireCallableFuns("change",e,t)}onSubmit(e,t){this.fireCallableFuns("submit",e,t)}onKeyup(e,t){this.fireCallableFuns("keyup",e,t)}fireCallableFuns(e,t,r){this.on(e,(e=>{"function"!=typeof t?"function"==typeof r&&e.target.matches(t)&&r(e):t(e)}))}fireEvent(e,t,...r){return this.fireEventForElements(e,t,!1,...r)}fireEventForAll(e,t,...r){return this.fireEventForElements(e,t,!0,...r)}fireEventForElements(e,t,r,...n){if("string"==typeof e){if(r)return document.querySelectorAll(e).forEach((e=>this.fireEventForElements(e,t,!1,...n)));e=document.querySelector(e)}if(!e)return void salla.log("Failed To get element to fire event: "+t);const i=new CustomEvent(t,...n);return e.dispatchEvent(i)}}class v extends a{constructor(e){super(e),this.namespace="wishlist",this.events={added:"added",removed:"removed",additionFailed:"addition.failed",removingFailed:"removing.failed"},this.after_init()}}class y extends a{constructor(e){super(e),this.namespace="currency",this.events={changed:"changed",failed:"failed",fetched:"fetched",failedToFetch:"failed.to.fetch"},this.after_init()}}class b extends a{constructor(e){super(e),this.namespace="twilight",this.events={initiated:"initiated"},this.after_init()}}var w="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function _(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var E={exports:{}};
|
|
2
2
|
/*!
|
|
3
3
|
* EventEmitter2
|
|
4
4
|
* https://github.com/hij1nx/EventEmitter2
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) 2013 hij1nx
|
|
7
7
|
* Licensed under the MIT license.
|
|
8
|
-
*/
|
|
9
|
-
!function(e,t){!function(t){var r=Object.hasOwnProperty,i=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},n="object"==typeof process&&"function"==typeof process.nextTick,a="function"==typeof Symbol,s="object"==typeof Reflect,o="function"==typeof setImmediate?setImmediate:setTimeout,l=a?s&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys:function(e){var t=Object.getOwnPropertyNames(e);return t.push.apply(t,Object.getOwnPropertySymbols(e)),t}:Object.keys;function c(){this._events={},this._conf&&u.call(this,this._conf)}function u(e){e&&(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),e.maxListeners!==t&&(this._maxListeners=e.maxListeners),e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),e.ignoreErrors&&(this.ignoreErrors=e.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function h(e,t){var r="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(r+=" Event name: "+t+"."),"undefined"!=typeof process&&process.emitWarning){var i=new Error(r);i.name="MaxListenersExceededWarning",i.emitter=this,i.count=e,process.emitWarning(i)}else console.error(r),console.trace&&console.trace()}var d=function(e,t,r){var i=arguments.length;switch(i){case 0:return[];case 1:return[e];case 2:return[e,t];case 3:return[e,t,r];default:for(var n=new Array(i);i--;)n[i]=arguments[i];return n}};function p(e,r){for(var i={},n=e.length,a=r?r.length:0,s=0;s<n;s++)i[e[s]]=s<a?r[s]:t;return i}function f(e,t,r){var i,n;if(this._emitter=e,this._target=t,this._listeners={},this._listenersCount=0,(r.on||r.off)&&(i=r.on,n=r.off),t.addEventListener?(i=t.addEventListener,n=t.removeEventListener):t.addListener?(i=t.addListener,n=t.removeListener):t.on&&(i=t.on,n=t.off),!i&&!n)throw Error("target does not implement any known event API");if("function"!=typeof i)throw TypeError("on method must be a function");if("function"!=typeof n)throw TypeError("off method must be a function");this._on=i,this._off=n;var a=e._observers;a?a.push(this):e._observers=[this]}function g(e,i,n,a){var s=Object.assign({},i);if(!e)return s;if("object"!=typeof e)throw TypeError("options must be an object");var o,l,c,u=Object.keys(e),h=u.length;function d(e){throw Error('Invalid "'+o+'" option value'+(e?". Reason: "+e:""))}for(var p=0;p<h;p++){if(o=u[p],!a&&!r.call(i,o))throw Error('Unknown "'+o+'" option');(l=e[o])!==t&&(c=n[o],s[o]=c?c(l,d):l)}return s}function m(e,t){return"function"==typeof e&&e.hasOwnProperty("prototype")||t("value must be a constructor"),e}function v(e){var t="value must be type of "+e.join("|"),r=e.length,i=e[0],n=e[1];return 1===r?function(e,r){if(typeof e===i)return e;r(t)}:2===r?function(e,r){var a=typeof e;if(a===i||a===n)return e;r(t)}:function(i,n){for(var a=typeof i,s=r;s-- >0;)if(a===e[s])return i;n(t)}}Object.assign(f.prototype,{subscribe:function(e,t,r){var i=this,n=this._target,a=this._emitter,s=this._listeners,o=function(){var i=d.apply(null,arguments),s={data:i,name:t,original:e};if(r){var o=r.call(n,s);!1!==o&&a.emit.apply(a,[s.name].concat(i))}else a.emit.apply(a,[t].concat(i))};if(s[e])throw Error("Event '"+e+"' is already listening");this._listenersCount++,a._newListener&&a._removeListener&&!i._onNewListener?(this._onNewListener=function(r){r===t&&null===s[e]&&(s[e]=o,i._on.call(n,e,o))},a.on("newListener",this._onNewListener),this._onRemoveListener=function(r){r===t&&!a.hasListeners(r)&&s[e]&&(s[e]=null,i._off.call(n,e,o))},s[e]=null,a.on("removeListener",this._onRemoveListener)):(s[e]=o,i._on.call(n,e,o))},unsubscribe:function(e){var t,r,i,n=this,a=this._listeners,s=this._emitter,o=this._off,c=this._target;if(e&&"string"!=typeof e)throw TypeError("event must be a string");function u(){n._onNewListener&&(s.off("newListener",n._onNewListener),s.off("removeListener",n._onRemoveListener),n._onNewListener=null,n._onRemoveListener=null);var e=w.call(s,n);s._observers.splice(e,1)}if(e){if(!(t=a[e]))return;o.call(c,e,t),delete a[e],--this._listenersCount||u()}else{for(i=(r=l(a)).length;i-- >0;)e=r[i],o.call(c,e,a[e]);this._listeners={},this._listenersCount=0,u()}}});var y=v(["function"]),b=v(["object","function"]);function _(e,t,r){var i,n,a,s=0,o=new e((function(l,c,u){function h(){n&&(n=null),s&&(clearTimeout(s),s=0)}r=g(r,{timeout:0,overload:!1},{timeout:function(e,t){return("number"!=typeof(e*=1)||e<0||!Number.isFinite(e))&&t("timeout must be a positive number"),e}}),i=!r.overload&&"function"==typeof e.prototype.cancel&&"function"==typeof u;var d=function(e){h(),l(e)},p=function(e){h(),c(e)};i?t(d,p,u):(n=[function(e){p(e||Error("canceled"))}],t(d,p,(function(e){if(a)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof e)throw TypeError("onCancel callback must be a function");n.push(e)})),a=!0),r.timeout>0&&(s=setTimeout((function(){var e=Error("timeout");e.code="ETIMEDOUT",s=0,o.cancel(e),c(e)}),r.timeout))}));return i||(o.cancel=function(e){if(n){for(var t=n.length,r=1;r<t;r++)n[r](e);n[0](e),n=null}}),o}function w(e){var t=this._observers;if(!t)return-1;for(var r=t.length,i=0;i<r;i++)if(t[i]._target===e)return i;return-1}function S(e,t,r,i,n){if(!r)return null;if(0===i){var a=typeof t;if("string"===a){var s,o,c=0,u=0,h=this.delimiter,d=h.length;if(-1!==(o=t.indexOf(h))){s=new Array(5);do{s[c++]=t.slice(u,o),u=o+d}while(-1!==(o=t.indexOf(h,u)));s[c++]=t.slice(u),t=s,n=c}else t=[t],n=1}else"object"===a?n=t.length:(t=[t],n=1)}var p,f,g,m,v,y,b,_=null,w=t[i],$=t[i+1];if(i===n)r._listeners&&("function"==typeof r._listeners?(e&&e.push(r._listeners),_=[r]):(e&&e.push.apply(e,r._listeners),_=[r]));else{if("*"===w){for(o=(y=l(r)).length;o-- >0;)"_listeners"!==(p=y[o])&&(b=S(e,t,r[p],i+1,n))&&(_?_.push.apply(_,b):_=b);return _}if("**"===w){for((v=i+1===n||i+2===n&&"*"===$)&&r._listeners&&(_=S(e,t,r,n,n)),o=(y=l(r)).length;o-- >0;)"_listeners"!==(p=y[o])&&("*"===p||"**"===p?(r[p]._listeners&&!v&&(b=S(e,t,r[p],n,n))&&(_?_.push.apply(_,b):_=b),b=S(e,t,r[p],i,n)):b=S(e,t,r[p],p===$?i+2:i,n),b&&(_?_.push.apply(_,b):_=b));return _}r[w]&&(_=S(e,t,r[w],i+1,n))}if((f=r["*"])&&S(e,t,f,i+1,n),g=r["**"])if(i<n)for(g._listeners&&S(e,t,g,n,n),o=(y=l(g)).length;o-- >0;)"_listeners"!==(p=y[o])&&(p===$?S(e,t,g[p],i+2,n):p===w?S(e,t,g[p],i+1,n):((m={})[p]=g[p],S(e,t,{"**":m},i+1,n)));else g._listeners?S(e,t,g,n,n):g["*"]&&g["*"]._listeners&&S(e,t,g["*"],n,n);return _}function $(e,t,r){var i,n,a=0,s=0,o=this.delimiter,l=o.length;if("string"==typeof e)if(-1!==(i=e.indexOf(o))){n=new Array(5);do{n[a++]=e.slice(s,i),s=i+l}while(-1!==(i=e.indexOf(o,s)));n[a++]=e.slice(s)}else n=[e],a=1;else n=e,a=e.length;if(a>1)for(i=0;i+1<a;i++)if("**"===n[i]&&"**"===n[i+1])return;var c,u=this.listenerTree;for(i=0;i<a;i++)if(u=u[c=n[i]]||(u[c]={}),i===a-1)return u._listeners?("function"==typeof u._listeners&&(u._listeners=[u._listeners]),r?u._listeners.unshift(t):u._listeners.push(t),!u._listeners.warned&&this._maxListeners>0&&u._listeners.length>this._maxListeners&&(u._listeners.warned=!0,h.call(this,u._listeners.length,c))):u._listeners=t,!0;return!0}function E(e,t,r,i){for(var n,a,s,o,c=l(e),u=c.length,h=e._listeners;u-- >0;)n=e[a=c[u]],s="_listeners"===a?r:r?r.concat(a):[a],o=i||"symbol"==typeof a,h&&t.push(o?s:s.join(this.delimiter)),"object"==typeof n&&E.call(this,n,t,s,o);return t}function A(e){for(var t,r,i,n=l(e),a=n.length;a-- >0;)(t=e[r=n[a]])&&(i=!0,"_listeners"===r||A(t)||delete e[r]);return i}function C(e,t,r){this.emitter=e,this.event=t,this.listener=r}function x(e,r,i){if(!0===i)s=!0;else if(!1===i)a=!0;else{if(!i||"object"!=typeof i)throw TypeError("options should be an object or true");var a=i.async,s=i.promisify,l=i.nextTick,c=i.objectify}if(a||l||s){var u=r,h=r._origin||r;if(l&&!n)throw Error("process.nextTick is not supported");s===t&&(s="AsyncFunction"===r.constructor.name),r=function(){var e=arguments,t=this,r=this.event;return s?l?Promise.resolve():new Promise((function(e){o(e)})).then((function(){return t.event=r,u.apply(t,e)})):(l?process.nextTick:o)((function(){t.event=r,u.apply(t,e)}))},r._async=!0,r._origin=h}return[r,c?new C(this,e,r):this]}function P(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,u.call(this,e)}C.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},P.EventEmitter2=P,P.prototype.listenTo=function(e,r,n){if("object"!=typeof e)throw TypeError("target musts be an object");var a=this;function s(t){if("object"!=typeof t)throw TypeError("events must be an object");var r,i=n.reducers,s=w.call(a,e);r=-1===s?new f(a,e,n):a._observers[s];for(var o,c=l(t),u=c.length,h="function"==typeof i,d=0;d<u;d++)o=c[d],r.subscribe(o,t[o]||o,h?i:i&&i[o])}return n=g(n,{on:t,off:t,reducers:t},{on:y,off:y,reducers:b}),i(r)?s(p(r)):s("string"==typeof r?p(r.split(/\s+/)):r),this},P.prototype.stopListeningTo=function(e,t){var r=this._observers;if(!r)return!1;var i,n=r.length,a=!1;if(e&&"object"!=typeof e)throw TypeError("target should be an object");for(;n-- >0;)i=r[n],e&&i._target!==e||(i.unsubscribe(t),a=!0);return a},P.prototype.delimiter=".",P.prototype.setMaxListeners=function(e){e!==t&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},P.prototype.getMaxListeners=function(){return this._maxListeners},P.prototype.event="",P.prototype.once=function(e,t,r){return this._once(e,t,!1,r)},P.prototype.prependOnceListener=function(e,t,r){return this._once(e,t,!0,r)},P.prototype._once=function(e,t,r,i){return this._many(e,1,t,r,i)},P.prototype.many=function(e,t,r,i){return this._many(e,t,r,!1,i)},P.prototype.prependMany=function(e,t,r,i){return this._many(e,t,r,!0,i)},P.prototype._many=function(e,t,r,i,n){var a=this;if("function"!=typeof r)throw new Error("many only accepts instances of Function");function s(){return 0==--t&&a.off(e,s),r.apply(this,arguments)}return s._origin=r,this._on(e,s,i,n)},P.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var e,t,r,i,n,s,o=arguments[0],l=this.wildcard;if("newListener"===o&&!this._newListener&&!this._events.newListener)return!1;if(l&&(e=o,"newListener"!==o&&"removeListener"!==o&&"object"==typeof o)){if(r=o.length,a)for(i=0;i<r;i++)if("symbol"==typeof o[i]){s=!0;break}s||(o=o.join(this.delimiter))}var u,h=arguments.length;if(this._all&&this._all.length)for(i=0,r=(u=this._all.slice()).length;i<r;i++)switch(this.event=o,h){case 1:u[i].call(this,o);break;case 2:u[i].call(this,o,arguments[1]);break;case 3:u[i].call(this,o,arguments[1],arguments[2]);break;default:u[i].apply(this,arguments)}if(l)u=[],S.call(this,u,e,this.listenerTree,0,r);else{if("function"==typeof(u=this._events[o])){switch(this.event=o,h){case 1:u.call(this);break;case 2:u.call(this,arguments[1]);break;case 3:u.call(this,arguments[1],arguments[2]);break;default:for(t=new Array(h-1),n=1;n<h;n++)t[n-1]=arguments[n];u.apply(this,t)}return!0}u&&(u=u.slice())}if(u&&u.length){if(h>3)for(t=new Array(h-1),n=1;n<h;n++)t[n-1]=arguments[n];for(i=0,r=u.length;i<r;i++)switch(this.event=o,h){case 1:u[i].call(this);break;case 2:u[i].call(this,arguments[1]);break;case 3:u[i].call(this,arguments[1],arguments[2]);break;default:u[i].apply(this,t)}return!0}if(!this.ignoreErrors&&!this._all&&"error"===o)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},P.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var e,t,r,i,n,s,o=arguments[0],l=this.wildcard;if("newListener"===o&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(l&&(e=o,"newListener"!==o&&"removeListener"!==o&&"object"==typeof o)){if(i=o.length,a)for(n=0;n<i;n++)if("symbol"==typeof o[n]){t=!0;break}t||(o=o.join(this.delimiter))}var u,h=[],d=arguments.length;if(this._all)for(n=0,i=this._all.length;n<i;n++)switch(this.event=o,d){case 1:h.push(this._all[n].call(this,o));break;case 2:h.push(this._all[n].call(this,o,arguments[1]));break;case 3:h.push(this._all[n].call(this,o,arguments[1],arguments[2]));break;default:h.push(this._all[n].apply(this,arguments))}if(l?(u=[],S.call(this,u,e,this.listenerTree,0)):u=this._events[o],"function"==typeof u)switch(this.event=o,d){case 1:h.push(u.call(this));break;case 2:h.push(u.call(this,arguments[1]));break;case 3:h.push(u.call(this,arguments[1],arguments[2]));break;default:for(r=new Array(d-1),s=1;s<d;s++)r[s-1]=arguments[s];h.push(u.apply(this,r))}else if(u&&u.length){if(u=u.slice(),d>3)for(r=new Array(d-1),s=1;s<d;s++)r[s-1]=arguments[s];for(n=0,i=u.length;n<i;n++)switch(this.event=o,d){case 1:h.push(u[n].call(this));break;case 2:h.push(u[n].call(this,arguments[1]));break;case 3:h.push(u[n].call(this,arguments[1],arguments[2]));break;default:h.push(u[n].apply(this,r))}}else if(!this.ignoreErrors&&!this._all&&"error"===o)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(h)},P.prototype.on=function(e,t,r){return this._on(e,t,!1,r)},P.prototype.prependListener=function(e,t,r){return this._on(e,t,!0,r)},P.prototype.onAny=function(e){return this._onAny(e,!1)},P.prototype.prependAny=function(e){return this._onAny(e,!0)},P.prototype.addListener=P.prototype.on,P.prototype._onAny=function(e,t){if("function"!=typeof e)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),t?this._all.unshift(e):this._all.push(e),this},P.prototype._on=function(e,r,i,n){if("function"==typeof e)return this._onAny(e,r),this;if("function"!=typeof r)throw new Error("on only accepts instances of Function");this._events||c.call(this);var a,s=this;return n!==t&&(r=(a=x.call(this,e,r,n))[0],s=a[1]),this._newListener&&this.emit("newListener",e,r),this.wildcard?($.call(this,e,r,i),s):(this._events[e]?("function"==typeof this._events[e]&&(this._events[e]=[this._events[e]]),i?this._events[e].unshift(r):this._events[e].push(r),!this._events[e].warned&&this._maxListeners>0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,h.call(this,this._events[e].length,e))):this._events[e]=r,s)},P.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var r,n=[];if(this.wildcard){var a="string"==typeof e?e.split(this.delimiter):e.slice();if(!(n=S.call(this,null,a,this.listenerTree,0)))return this}else{if(!this._events[e])return this;r=this._events[e],n.push({_listeners:r})}for(var s=0;s<n.length;s++){var o=n[s];if(r=o._listeners,i(r)){for(var l=-1,c=0,u=r.length;c<u;c++)if(r[c]===t||r[c].listener&&r[c].listener===t||r[c]._origin&&r[c]._origin===t){l=c;break}if(l<0)continue;return this.wildcard?o._listeners.splice(l,1):this._events[e].splice(l,1),0===r.length&&(this.wildcard?delete o._listeners:delete this._events[e]),this._removeListener&&this.emit("removeListener",e,t),this}(r===t||r.listener&&r.listener===t||r._origin&&r._origin===t)&&(this.wildcard?delete o._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return this.listenerTree&&A(this.listenerTree),this},P.prototype.offAny=function(e){var t,r=0,i=0;if(e&&this._all&&this._all.length>0){for(r=0,i=(t=this._all).length;r<i;r++)if(e===t[r])return t.splice(r,1),this._removeListener&&this.emit("removeListenerAny",e),this}else{if(t=this._all,this._removeListener)for(r=0,i=t.length;r<i;r++)this.emit("removeListenerAny",t[r]);this._all=[]}return this},P.prototype.removeListener=P.prototype.off,P.prototype.removeAllListeners=function(e){if(e===t)return!this._events||c.call(this),this;if(this.wildcard){var r,i=S.call(this,null,e,this.listenerTree,0);if(!i)return this;for(r=0;r<i.length;r++)i[r]._listeners=null;this.listenerTree&&A(this.listenerTree)}else this._events&&(this._events[e]=null);return this},P.prototype.listeners=function(e){var r,i,n,a,s,o=this._events;if(e===t){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!o)return[];for(a=(r=l(o)).length,n=[];a-- >0;)"function"==typeof(i=o[r[a]])?n.push(i):n.push.apply(n,i);return n}if(this.wildcard){if(!(s=this.listenerTree))return[];var c=[],u="string"==typeof e?e.split(this.delimiter):e.slice();return S.call(this,c,u,s,0),c}return o&&(i=o[e])?"function"==typeof i?[i]:i:[]},P.prototype.eventNames=function(e){var t=this._events;return this.wildcard?E.call(this,this.listenerTree,[],null,e):t?l(t):[]},P.prototype.listenerCount=function(e){return this.listeners(e).length},P.prototype.hasListeners=function(e){if(this.wildcard){var r=[],i="string"==typeof e?e.split(this.delimiter):e.slice();return S.call(this,r,i,this.listenerTree,0),r.length>0}var n=this._events,a=this._all;return!!(a&&a.length||n&&(e===t?l(n).length:n[e]))},P.prototype.listenersAny=function(){return this._all?this._all:[]},P.prototype.waitFor=function(e,r){var i=this,n=typeof r;return"number"===n?r={timeout:r}:"function"===n&&(r={filter:r}),_((r=g(r,{timeout:0,filter:t,handleError:!1,Promise:Promise,overload:!1},{filter:y,Promise:m})).Promise,(function(t,n,a){function s(){var a=r.filter;if(!a||a.apply(i,arguments))if(i.off(e,s),r.handleError){var o=arguments[0];o?n(o):t(d.apply(null,arguments).slice(1))}else t(d.apply(null,arguments))}a((function(){i.off(e,s)})),i._on(e,s,!1)}),{timeout:r.timeout,overload:r.overload})};var F=P.prototype;Object.defineProperties(P,{defaultMaxListeners:{get:function(){return F._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");F._maxListeners=e},enumerable:!0},once:{value:function(e,t,r){return _((r=g(r,{Promise:Promise,timeout:0,overload:!1},{Promise:m})).Promise,(function(r,i,n){var a;if("function"==typeof e.addEventListener)return a=function(){r(d.apply(null,arguments))},n((function(){e.removeEventListener(t,a)})),void e.addEventListener(t,a,{once:!0});var s,o=function(){s&&e.removeListener("error",s),r(d.apply(null,arguments))};"error"!==t&&(s=function(r){e.removeListener(t,o),i(r)},e.once("error",s)),n((function(){s&&e.removeListener("error",s),e.removeListener(t,o)})),e.once(t,o)}),{timeout:r.timeout,overload:r.overload})},writable:!0,configurable:!0}}),Object.defineProperties(F,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),e.exports=P}()}(eventemitter2$1);var eventemitter2=eventemitter2$1.exports;class InfiniteScrollEvents extends BaseEvent{constructor(e){super(e),this.namespace="infiniteScroll",this.events={scrollThreshold:"scroll.threshold",request:"request",load:"load",append:"append",error:"error",last:"last",history:"history"},this.after_init()}}class sallaEmitter extends eventemitter2{constructor(){super({wildcard:!0,delimiter:"::",newListener:!1,removeListener:!1,maxListeners:10,verboseMemoryLeak:!1,ignoreErrors:!1}),this.globalListners={},this.delimiter="::",this.auth=new AuthEvents(this),this.cart=new CartEvents(this),this.order=new OrderEvents(this),this.scope=new ScopeEvents(this),this.rating=new RatingEvents(this),this.comment=new CommentEvents(this),this.loyalty=new LoyaltyEvents(this),this.product=new ProductEvents(this),this.profile=new ProfileEvents(this),this.currency=new CurrencyEvents(this),this.document=new DocumentEvents(this),this.twilight=new TwilightEvents(this),this.wishlist=new WishlistEvents(this),this.infiniteScroll=new InfiniteScrollEvents(this),this.body=document.querySelector("body"),this.logableEvents=["cart::item.added.failed","cart::item.deleted.failed"],this.ingoreLogEvents=["document::click","document::keyup","document::change"],this.noneFireableActions=["document.request"],this.on("twilight::initiated",this.initiateSallaInAllClasses)}initiateSallaInAllClasses(){let e=this;Object.keys(salla).forEach((t=>{"object"==typeof(t=salla[t])&&(e.callSallaInitiate(t),Object.keys(t).forEach((r=>{e.callSallaInitiate(t[r])})))}))}callSallaInitiate(e){e&&e.sallaInitiated&&!e.initiated&&(e.sallaInitiated(),e.initiated=!0)}createAndDispatch(e,...t){this.dispatch(e,...t)}dispatch(e,...t){let r=e.replace("::",".");if(!this.noneFireableActions.includes(r)&&"function"==typeof salla.call(r))return salla.log(`'salla.${r}(...)' triggered using event '${e}'`),r=r.split("."),void salla[r[0]][r[1]](...t);this.emit(e,...t),window.dataLayer=window.dataLayer||[],window.dataLayer.push(Object.assign({event:e},...t.values())),this.ingoreLogEvents.includes(e)||!salla.config.get("debug")&&!this.logableEvents.includes(e)||salla.logger.event(e,...t);let i=this;Object.keys(this.globalListners).forEach((function(r){i.globalListners[r](e,...t)})),this.dispatchMobileEvent(e,{...t.values()})}dispatchEvents(e){if(e&&"object"==typeof e)for(const[t,r]of Object.entries(e))this.dispatch(t,r);else salla.log("No Events To Dispatch!",e)}addListener(e,t){this.on(e,t)}addEventListener(e,t){this.addListener(e,t)}listen(e,t){this.addListener(e,t)}registerGlobalListener(e,t){this.globalListners[e]=t}dispatchMobileEvent(e,t={}){if(!(window.dataLayer&&dataLayer[0]&&dataLayer[0].page&&dataLayer[0].page.mobileApp))return"";if(window.webkit)try{window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:e,details:t}))}catch(e){console.log(e,"The native context does not exist yet")}else if(Android)try{Android.customEventWithData(e,JSON.stringify({details:t}))}catch(e){console.log(e,"The native context does not exist yet")}}}class BaseApi{constructor(e){this.parent=e,this.endpoints={},this.webEndpoints=[],this.namespace="BaseApi",this.endpointsMethods={},this.endpointsHeaders={};var t=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(t&&t.length>1?t[1]:"").toLowerCase(),this.debounce={request:void 0,time:300,enabled:!0,exclude:[]}}after_init(){}normalRequest(e,t,r=null){let i=this,n=Array.isArray(e),a=n?this.getUrl(...e):this.getUrl(e);e=n?e[0]:e,r=r||this.endpointsMethods[e]||"post";let s=this.endpointsHeaders[e];if("get"===r&&t instanceof FormData){var o={};Array.from(t.entries()).forEach((function(e){o[e[0]]=e[1]})),t={params:o}}s&&"get"===r&&(t=t?Object.assign(t,s):s);let l={namespace:this.namespace,action:e,url:a,payload:t,method:r,headers:s};try{salla.event.document.request(l)}catch(e){return salla.event.document.requestFailed(l),new Promise((()=>{throw e}))}this.webEndpoints.includes(e)?a=salla.url.get(a):"http"!==a.substring(0,4)&&(a=salla.url.api(a));let c="undefined"!=typeof event?event.currentTarget:null,u=!1;return"SALLA-BUTTON"===c?.tagName&&(u=!0),u&&c?.load(),this.parent[r](a,t,{headers:s}).then((e=>(u&&c?.stop(),e.data&&e.request&&(e=e.data),i.handleAfterResponseActions(e),e))).catch((e=>{throw u&&c?.stop(),salla.event.document.requestFailed(l,e),i.handleErrorResponse(e),e}))}request(e,t,r=null){return!this.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,r)):this.normalRequest(e,t,r)}getUrl(e){let t=this.endpoints[e]||e;const r=/{[^{}]+}/i;for(let e=1;e<arguments.length;e++)t=t.replace(r,arguments[e]);return t}handleAfterResponseActions(e){if(!e)return;let{data:t,googleTags:r=null}=e,i=t&&t.googleTags?t.googleTags:r;dataLayer&&i&&dataLayer.push(i),this.fireEventsForResponse(e),this.renderSections(e),this.showAlert(e),e.data?.token&&salla.event.auth.tokenFetched(e.data.token)}fireEventsForResponse(e){let t=e.events||e.data?.events||e.error?.events;"string"==typeof t&&(t=JSON.parse(t)),t&&Object.keys(t).forEach((e=>salla.event.dispatch(e,t[e])))}renderSections(e){e.sections&&Object.keys(e.sections).forEach((t=>{document.querySelectorAll(t.toSelector()).forEach((function(r){r.innerHTML=e.sections[t]}))}))}handleErrorResponse(e){if(e.response&&e.response.data)return e.response.data.error&&e.response.data.error.fields?this.handleInvalidFields(e):this.handleAfterResponseActions(e.response.data)}showAlert(e){if(e)return e.case&&e.msg?salla.notify.fire(e.msg,e.case,e):e.hasOwnProperty("success")&&e.data?.message?salla.notify.fire(e.data?.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}handleInvalidFields(e){let t=e.response.data.error.fields,r=[];Object.keys(t).forEach((e=>{let i=t[e];Array.isArray(i)?i.forEach((e=>r.push(e))):r.push(i)}));let i=(r.length>1?"* ":"")+r.join("\n* ");salla.error(i,e)}event(){return salla.event[this.className]}getPossibleValue(e,t,r=!1){if(!e)return;if("object"!=typeof e)return e;let i;for(let r=0;r<t.length&&!(i=e[t[r]])&&!("undefined"!=typeof FormData&&e instanceof FormData&&(i=e.get(t[r])));r++);return i=i||e,"object"!=typeof i||r?i:void 0}isFastRequestsAllowed(){return salla.config.get("fastRequests")}promise(e,t=!0){return new Promise(((r,i)=>t?r(e):i(e)))}errorPromise(e){return this.promise(e,!1)}successPromise(e){return this.promise(e,!0)}}class CartApi extends BaseApi{constructor(e){super(e),this.namespace="cart",this.endpoints={latest:"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"},this.endpointsMethods={latest:"get",details:"get",status:"get",updateItem:"post",deleteItem:"delete",deleteImage:"delete",deleteCoupon:"put"},this.webEndpoints=["latest"],this.after_init()}async getCurrentCartId(){return salla.storage.get("cart.id")||(await this.latest()).data.cart.id}getUploadImageEndpoint(e){return salla.url.api(this.getUrl("uploadImage",e||salla.storage.get("cart.id")))}latest(){return this.request("latest",{params:{source:""}}).then((e=>(salla.storage.set("cart",e.data.cart),salla.event.cart.latestFetched(e),e))).catch((e=>{throw salla.storage.set("cart",""),salla.event.cart.latestFailed(e),e}))}async details(){let e=await this.getCurrentCartId();return this.request(["details",e]).then((function(e){return salla.cart.event.detailsFetched(e),e})).catch((function(e){throw salla.cart.event.detailsNotFetched(e),e}))}async quickAdd(e){return this.addItem(e)}async addItem(e){let t=this.getCartPayload(e);if(!t.id){let e='There is no product "id"!';return salla.cart.event.itemAddedFailed(e),this.errorPromise(e)}let r=this.getPossibleValue(t.payload,["quantity","donating_amount"])?"addItem":"quickAdd",i=await this.getCurrentCartId();return this.request([r,i,t.id],t.payload).then((function(e){return salla.cart.event.itemAdded(e,t.id),e})).catch((function(e){throw salla.cart.event.itemAddedFailed(e,t.id),e}))}async deleteItem(e){let t=this.getCartPayload(e);if(!t.id){let e='There is no "id"!';return salla.cart.event.itemDeletedFailed(e),this.errorPromise(e)}let r=await this.getCurrentCartId();return this.request(["deleteItem",r,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}))}async updateItem(e){let t=this.getCartPayload(e);if(!t.id){let e='There is no "id"!';return salla.cart.event.itemUpdatedFailed(e),this.errorPromise(e)}let r=await this.getCurrentCartId();return"Object"===t.payload.constructor?.name?t.payload._method="PUT":t.payload.append("_method","PUT"),this.request(["updateItem",r,t.id],t.payload).then((function(e){return salla.cart.event.itemUpdated(e,t.id),e})).catch((function(e){throw salla.cart.event.itemUpdatedFailed(e,t.id),e}))}async deleteImage(e){if(!(e=this.getPossibleValue(e,["id","image_id","photo_id"]))){let e='There is no "id"!';return salla.cart.event.imageNotDeleted(e),this.errorPromise(e)}let t=await this.getCurrentCartId();return this.request(["deleteImage",t,e]).then((function(t){return salla.cart.event.imageDeleted(t,e),t})).catch((function(t){throw salla.cart.event.imageNotDeleted(t,e),t}))}async status(e){return this.request(["status",e||await this.getCurrentCartId()])}async submit(){this.status(await this.getCurrentCartId()).then((e=>{let t=e.data.next_step.to;if(!["checkout","refresh","login"].includes(t)){let e="Can't find next_step );";throw salla.cart.event.submitFailed(e),e}if(salla.cart.event.submitted(e),"login"===t)return salla.auth.setCanRedirect(!1),salla.event.dispatch("login::open"),void salla.auth.event.onLoggedIn((e=>{salla.event.dispatch("login::close"),this.submit()}));"checkout"===t?window.location.href=e.data.next_step.url+(window.ApplePaySession?"?has_apple_pay=true":""):window.location.reload()})).catch((function(e){throw salla.cart.event.submitFailed(e),e}))}getCartPayload(e){let t=e?.data||("object"==typeof e?e:void 0);return e=t?this.getPossibleValue(t,["prod_id","product_id","item_id","id"]):e,t="object"==typeof t?t:void 0,{id:e,payload:t}}handleAfterResponseActions(e){if(403===e.status){salla.storage.remove("cart");let e=salla.lang.get("pages.checkout.try_again");throw salla.error(e),e}super.handleAfterResponseActions(e)}reset(){salla.storage.remove("cart"),salla.cart.event.successReset()}async addCoupon(e){if(e=e.data||e,!(e=this.getPossibleValue(e,["coupon"]))){let e=new Error('There is no "Coupon Code"!');return e.name="EmptyCoupon",salla.event.cart.couponAdditionFailed(e),this.errorPromise(e)}let t=await salla.cart.api.getCurrentCartId();return this.request(["addCoupon",t],{coupon:e}).then((function(e){return salla.event.cart.couponAdded(e,t),e})).catch((function(e){throw salla.event.cart.couponAdditionFailed(e,t),e}))}async deleteCoupon(){let e=await salla.cart.api.getCurrentCartId();return this.request(["deleteCoupon",e],{}).then((function(t){return salla.event.cart.couponDeleted(t,e),t})).catch((function(t){throw salla.event.cart.couponDeletionFailed(t,e),t}))}}class LoyaltyApi extends BaseApi{constructor(e){super(e),this.namespace="loyalty",this.endpoints={getProgram:"loyalty",exchange:"loyalty/exchange",reset:"loyalty/exchange"},this.endpointsMethods={getProgram:"get",reset:"put"},this.after_init()}getProgram(){return this.request("getProgram").then((e=>(salla.loyalty.event.programFetched(e),e))).catch((e=>{throw salla.loyalty.event.programNotFetched(e),e}))}async exchange(e,t=null){if(!(e=this.getPossibleValue(e,["id","loyalty_prize_id","prize_id"]))){let e="Unable to find cart id. Please provide one.";return salla.loyalty.event.exchangeFailed(e),this.errorPromise(e)}if(!(t=t||await salla.cart.getCurrentCartId())){let e="Unable to find cart id. Please provide one.";return salla.loyalty.event.exchangeFailed(e),this.errorPromise(e)}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}))}async reset(e=null){if(!(e=e||await salla.cart.getCurrentCartId())){let e="Unable to find cart id. Please provide one.";return salla.loyalty.event.resetFailed(e),this.errorPromise(e)}return this.request("reset",{cart_id:e}).then((e=>(salla.loyalty.event.resetSucceeded(e),e))).catch((e=>{throw salla.loyalty.event.resetFailed(e),e}))}}class AuthApi extends BaseApi{constructor(e){super(e),this.namespace="auth",this.canRedirect_=!0,this.endpoints={login:"auth/{type}/send_verification",resend:"auth/resend_verification",verify:"auth/{type}/verify",register:"auth/register",logout:"logout",refresh:"auth/refresh"},this.webEndpoints=["logout","auth/jwt","refresh"],this.endpointsMethods={logout:"get"},this.after_init()}setCanRedirect(e){salla.api.auth.canRedirect_=e}canRedirect(){return salla.api.auth.canRedirect_}login(e){e.data&&(e=e.data);let t=this.getPossibleValue(e,["type"]);if(!["email","mobile"].includes(t)){let e="Login type should be in: [email, mobile]";return salla.auth.event.codeNotSent(e),this.errorPromise(e)}return this.request(["login",t],e).then((function(e){return salla.auth.event.codeSent(e,t),e})).catch((function(e){throw salla.auth.event.codeNotSent(e,t),e}))}async verify(e,t=!0){let r=this.getPossibleValue(e,["type"]);if(!r){let e="Failed to know what's login type!";return salla.auth.event.verificationFailed(e),this.errorPromise(e)}t=!1!==this.getPossibleValue(e,["supportWebAuth"])&&t,salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event);let i=await this.request(["verify",r],e);return 200!==i?.status?(salla.auth.event.verificationFailed(i,r),this.errorPromise(i)):(t&&await this.request("auth/jwt"),"authenticated"===i.data?.case&&salla.auth.event.loggedIn(i),salla.auth.event.verified(i,r),this.successPromise(i))}resend(e){let 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),t})):(salla.auth.event.codeNotSent(t="There is no email!",e),this.errorPromise(t)):(salla.auth.event.codeNotSent(t="There is no phone or country_code!",e),this.errorPromise(t))}register(e){let t;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((function(e){return salla.auth.event.registered.call(t,e),"authenticated"===e.data?.case&&salla.auth.event.loggedIn(e),e})).catch((function(e){throw salla.auth.event.registrationFailed.call(t,e),e}))}logout(){return this.request("logout").then((function(e){return salla.auth.event.loggedOut(e),salla.log("Reloading after 0.1 sec..."),setTimeout((()=>location.reload()),100),e})).catch((function(e){throw salla.auth.event.failedLogout(e),e}))}refresh(){return this.request("refresh").catch((function(e){throw salla.auth.event.refreshFailed(e),e}))}}class OrderApi extends BaseApi{constructor(e){super(e),this.namespace="order",this.endpoints={cancel:"orders/cancel/{id}",createCartFromOrder:"reorder/{id}",sendInvoice:"orders/send/{id}"},this.endpointsMethods={createCartFromOrder:"get"},this.after_init()}show(e){let t=this.getPossibleValue(e?.data||e,["id","order_id"]);salla.event.dispatch("mobile::order.placed",{order_id:t}),location.href=this.getPossibleValue(e?.data||e,["url"])}cancel(e){return e=e||salla.config.get("page.id"),this.request(["cancel",e],{params:{has_apple_pay:!!window.ApplePaySession}}).then((function(t){return salla.event.order.canceled(t,e),t})).catch((function(t){throw salla.event.order.notCanceled(t,e),t}))}createCartFromOrder(e){return e=e||salla.config.get("page.id"),this.request(["createCartFromOrder",e]).then((function(t){return salla.storage.set("cart",{id:t.data.cart_id,user_id:salla.config.get("user.id")}),salla.event.order.orderCreated(t,e),window.location.href=t.data.url,t})).catch((function(t){throw salla.event.order.orderCreationFailed(t,e),t}))}sendInvoice(e){let t=this.getPossibleValue(e,["id"])||salla.config.get("page.id");if(!t||isNaN(t)){let e="There is no id!";return salla.order.event.invoiceNotSent(e),this.errorPromise(e)}return this.request(["sendInvoice",t],e).then((e=>(salla.event.order.invoiceSent(e,t),e))).catch((e=>{throw salla.event.order.invoiceNotSent(e,t),e}))}}class ProductApi extends BaseApi{constructor(e){super(e),this.namespace="product",this.previousQuery="",this.endpoints={getPrice:"products/{id}/price",availabilitySubscribe:"products/{id}/availability-notify",search:"products/search",categories:"products/categories/{?id}",purchaseNow:"checkout/quick-purchase/{id}",offers:"products/{product_id}/specialoffer",getSizeGuides:"products/{prod_id}/size-guides",giftDetail:"products/{product_id}/buy-as-gift",giftToCart:"products/{product_id}/buy-as-gift",giftImage:"products/buy-as-gift/image"},this.endpointsMethods={giftDetail:"get"},this.webEndpoints=["purchaseNow"],this.after_init()}getPrice(e){let t=e.data||e,r=this.getPossibleValue(t,["id","prod_id","product_id"]);return this.request(["getPrice",r],"object"==typeof t?t:void 0).then((function(e){return salla.product.event.priceUpdated(e,r),e})).catch((function(e){throw salla.product.event.priceUpdateFailed(e,r),e}))}categories(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}))}availabilitySubscribe(e){let t=e.data||e;return e=this.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.availabilitySubscribedFailed(t,e),t}))}search(e){let t=e.data;if(t||(t={params:"string"==typeof e?{query:e}:e}),!(e=t instanceof FormData?t.get("query"):t.query||t.params?.query)){let e='There is no "query"!';return salla.product.event.searchFailed(e),this.errorPromise(e)}if(e===salla.api.product.previousQuery){let e="Query is same as previous one!";return salla.product.event.searchFailed(e),salla.api.product.previousQuery=null,this.errorPromise(e)}return salla.api.product.previousQuery=e,this.request("search",t,"get").then((function(t){return salla.product.event.searchResults(t,e),t})).catch((function(t){throw salla.product.event.searchFailed(t,e),t}))}offers(e){if(!(e=this.getPossibleValue(e?.data|e,["product_id","id"]))){let e='There is no "product_id"!';return salla.offer.event.fetchDetailsFailed(e),this.errorPromise(e)}return this.request(["offers",e]).then((function(t){return salla.product.event.offersFetched(t,e),t})).catch((function(t){throw salla.product.event.fetchFffersFailed(t,e),t}))}purchaseNow(e){if(salla.config.isGuest())return salla.auth.event.dispatch("login");let t=e.product_data,r=this.getPossibleValue(t,["id","prod_id"]);if(!e.is_applepay)return this.request(["quickPurchase",r],"object"==typeof t?t:void 0).then((function(e){return e})).catch((function(e){throw e}));salla.event.dispatch("payments::apple-pay.start-transaction",{amount:e.total,currency:e.currency,requiredShippingContactFields:e.require_shipping?["postalAddress"]:null,shippingMethods:e.require_shipping?[]:null,supportedNetworks:e.applepay_supported_networks,validateMerchant:{url:baseUrl+"checkout/applepay/validate",onFailed:({response:e})=>{console.log("validateMerchant Failed!")},onSuccess:e=>(console.log("validateMerchant Success"),this.request(["quickPurchase",r],"object"==typeof t?t:void 0))},authorized:{url:baseUrl+"/checkout/{id}/payments/submit",onFailed:e=>{console.log("authorized Failed!"),window.Salla.Payments.ApplePay.onCancel({},e.data.error.message)},onSuccess:e=>{console.log(e),window.location.href=e.redirect.url,console.log("authorized Success:: redirect to thank you page, order placed")}},shippingMethodSelected:e.require_shipping?{url:baseUrl+"/checkout/{id}/shipping/details",onFailed:e=>{console.log("select shipping method failed!")},onSuccess:e=>{console.log("select shipping method success")}}:null,shippingContactSelected:e.require_shipping?{url:baseUrl+"/checkout/{id}/address/add",onFailed:e=>{console.log("created contact failed!")},onSuccess:e=>{console.log("created contact success : ",e.data.address_id)}}:null,recalculateTotal:{url:baseUrl+"/checkout/{id}/payments/recalculate"},onError:function(e){console.log(e),salla.notify.error(e)}})}getSizeGuides(e){return this.request(`products/${e}/size-guides`,null,"get").then((t=>(salla.product.event.sizeGuideFetched(t,e),t))).catch((t=>{throw salla.product.event.sizeGuideFetchFailed(t,e),t}))}getGiftDetails(e){return this.request(["giftDetail",e]).then((t=>(salla.product.event.giftFetched(t,e),t))).catch((t=>{throw salla.product.event.giftFetchFailed(t,e),t}))}addGiftToCart(e,t,r=!1){return this.request(["giftToCart",e],t).then((t=>(salla.product.event.addGiftToCartSucceeded(t,e),r&&(window.location.href=t.redirect),response))).catch((t=>{throw salla.product.event.addGiftToCartFailed(t,e),t}))}uploadGiftImage(e){return this.request("giftImage",e).then((e=>(salla.product.event.giftImageUploadSucceeded(e),e))).catch((e=>{throw salla.product.event.giftImageUploadFailed(e),e}))}}class ProfileApi extends BaseApi{constructor(e){super(e),this.namespace="profile",this.endpoints={info:"auth/user",update:"profile/update",updateContacts:"profile/contacts/update",verify:"profile/verify"},this.after_init()}info(){return this.request("info",null,"get").then((e=>(salla.profile.event.infoFetched(e),e))).catch((e=>{throw salla.profile.event.infoNotFetched(e),e}))}update(e){return this.request("update",e).then((e=>(salla.profile.event.updated(e),e))).catch((e=>{throw salla.event.profile.updateFailed(e),e}))}updateContacts(e){return this.request("updateContacts",e).then((e=>(salla.profile.event.verificationCodeSent(e),e))).catch((e=>{throw salla.event.profile.updateContactsFailed(e),e}))}verify(e){return this.request("verify",e).then((e=>(salla.profile.event.verified(e),e))).catch((e=>{throw salla.event.profile.unVerified(e),e}))}}class CommentApi extends BaseApi{constructor(e){super(e),this.namespace="comment",this.endpoints={add:"{type}/{id}/comments"},this.after_init()}add(e){e?.data&&(e=e.data);let t,{id:r,type:i,comment:n}=Object.fromEntries(e);return r?i&&["products","pages","product","page"].includes(i)?n?(i+=["product","page"].includes(i)?"s":"",this.request(["add",i,r],{comment:n}).then((function(e){return salla.event.comment.added(e,r),e})).catch((function(e){throw salla.event.comment.additionFailed(e,r),e}))):(salla.event.comment.additionFailed(t="can't find comment content!"),this.errorPromise(t)):(salla.event.comment.additionFailed(t="Failed to get type one of:(products, product, page, pages)!"),this.errorPromise(t)):(salla.event.comment.additionFailed(t="Failed to get id!"),this.errorPromise(t))}}class CurrencyApi extends BaseApi{constructor(e){super(e),this.namespace="currency",this.endpoints={change:"/",list:"currencies"},this.endpointsMethods={change:"get",list:"get"},this.webEndpoints=["change"],this.after_init()}change(e){if(!(e=this.getPossibleValue(e.data||e,["currency","code"]))){let e="Can't find currency code!";return salla.currency.event.failed(e),this.errorPromise(e)}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}))}list(){return this.request("list").then((function(e){return salla.currency.event.fetched(e),e})).catch((function(e){throw salla.currency.event.failedToFetch(e),e}))}}class DocumentApi extends BaseApi{constructor(e){super(e),this.namespace="document"}}class RatingApi extends BaseApi{constructor(e){super(e),this.namespace="rating",this.endpoints={store:"rating/store",products:"rating/products",shipping:"rating/shipping",order:"rating/{order_id}"},this.endpointsMethods={order:"get"},this.after_init()}order(e){let t="object"==typeof e?e:{},r=this.getPossibleValue(e?.data||e,["order_id","id"]);if(!r){let e='There is no "order_id"!';return salla.event.rating.orderNotFetched(e),this.errorPromise(e)}return this.request(["order",r],t).then((function(e){return salla.event.rating.orderFetched(e,r),e})).catch((function(e){throw salla.event.rating.orderNotFetched(e,r),e}))}store(e){if(!(e=e.data||e)){let e='There is no "data"!';return salla.event.rating.storeFailed(e),this.errorPromise(e)}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}))}products(e){if(!(e=e.data||e)){let e='There is no "data"!';return salla.event.rating.productsFailed(e),this.errorPromise(e)}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}))}shipping(e){if(!(e=e.data||e)){let e='There is no "data"!';return salla.event.rating.shippingFailed(e),this.errorPromise(e)}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}))}}class SallaInit{constructor(e){salla.config.merge(e),e?(e._token&&(salla.api.defaults.headers.common["X-CSRF-TOKEN"]=e._token),this.injectMaintenanceAlert(),this.injectThemePreviewAlert(),this.injectEditAlert(),e?.user?.language_code&&salla.lang.setLocale(e?.user?.language_code),salla.lang.loadStoreTranslations(),salla.twilight.event.initiated(e)):salla.twilight.event.initiated(e)}injectMaintenanceAlert(){salla.config.get("maintenance")&&(document.querySelector(".store-notify")?salla.logger.warn(".store-notify element Existed before!"):salla.lang.onLoaded((()=>{var e=document.createElement("div");e.classList.add("store-notify"),e.style="background-color: #d63031; color: #fff; padding: 10px 15px; text-align: center; font-size: 17px;",e.innerHTML=`<p style="margin:0 !important;">${salla.lang.get("blocks.header.maintenance_alert")}</p>`,document.body.prepend(e)})))}injectThemePreviewAlert(){"preview"===salla.config.get("theme.mode")&&(document.querySelector("#s-theme_preview_bar")?salla.logger.warn("#s-theme_preview_bar element Existed before!"):salla.lang.onLoaded((()=>{let 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://assets.salla.sa/cp/assets/images/logo-new.png">\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)})))}injectEditAlert(){let e=salla.config.get("edit");e&&(document.querySelector("#s-edit-alert")?salla.logger.warn("#s-edit-alert element Existed before!"):salla.lang.onLoaded((()=>{let 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)})))}handleElementAjaxRequest(e,t){if(!(t instanceof HTMLFormElement||t instanceof HTMLAnchorElement))return salla.logger.warn("trying to call ajax from non Element!!"),!1;e.preventDefault();let r=t.getAjaxFormData(e),i=r.method?r.method.toLowerCase():void 0;salla.api.document.request(r.url,r.formData,i).then((e=>(e.data&&e.request&&(e=e.data),salla.api.document.handleAfterResponseActions(e),this.callAjaxEvent(r.events.success,e,r.formData),e))).catch((e=>{throw salla.api.document.handleErrorResponse(e),this.callAjaxEvent(r.events.fail,e,r.formData),e}))}callAjaxEvent(e,t,r){if(e){if(r instanceof FormData){var i={};Array.from(r.entries()).forEach((function(e){i[e[0]]=e[1]})),r=i}window[e]?window[e](t,r):salla.event.dispatch(e,t,r)}}}class TwilightApi extends BaseApi{constructor(e){super(e),this.namespace="twilight",this.after_init()}init(e){let t=e?.events;return salla.isInitiated||(delete e.events,new SallaInit(e),salla.isInitiated=!0),t&&salla.event.dispatchEvents(t),this.successPromise(e)}api(e){let t=e?.events;return t&&salla.event.dispatchEvents(t),this.successPromise(e)}}class WishlistApi extends BaseApi{constructor(e){super(e),this.namespace="wishlist",this.endpoints={add:"products/favorites/{id}",remove:"products/favorites/{id}"},this.endpointsMethods={remove:"delete"},this.after_init()}toggle(e){return salla.storage.get("salla::wishlist",[]).includes(e)?this.remove(e):this.add(e)}add(e){let t;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(t=salla.lang.get("common.messages.must_login")),salla.error(t),this.errorPromise(t)):(e=this.getPossibleValue(e?.data||e,["product_id","id"]))?this.request(["add",e]).then((t=>(this.updateWishlistStorage(e),salla.wishlist.event.added(t,e),t))).catch((function(t){throw salla.wishlist.event.additionFailed(t,e),t})):(salla.wishlist.event.additionFailed(t="Failed to get product id!"),this.errorPromise(t))}remove(e){let t;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(t=salla.lang.get("common.messages.must_login")),salla.error(t),this.errorPromise(t)):(e=this.getPossibleValue(e?.data||e,["product_id","id"]))?this.request(["remove",e]).then((t=>(this.updateWishlistStorage(e,!1),salla.wishlist.event.removed(t,e),t))).catch((function(t){throw salla.wishlist.event.removingFailed(t,e),t})):(salla.wishlist.event.removingFailed(t="Failed to get id!"),this.errorPromise(t))}updateWishlistStorage(e,t=!0){let r=salla.storage.get("salla::wishlist",[]);t?r.push(e):r.splice(r.indexOf(e),1),salla.storage.set("salla::wishlist",r)}}class ScopeApi extends BaseApi{constructor(e){super(e),this.namespace="scopes",this.endpoints={get:"scopes",change:"scopes",getProductAvailability:"scopes/availability?product_id={id}"},this.after_init()}get(){return this.request("scopes",null,"get").then((e=>(salla.scope.event.fetched(e),e))).catch((e=>{throw salla.scope.event.notFetched(e),e}))}change(e){return this.request("scopes",e).then((e=>(salla.scope.event.changeSucceeded(e),e))).catch((e=>{throw salla.scope.event.changeFailed(e),e}))}getProductAvailability(e=null){return this.request(`scopes/availability?product_id=${e}`,null,"get").then((t=>(salla.scope.event.productAvailabilityFetched(t,e),t))).catch((e=>{throw salla.scope.event.productAvailabilityNotFetched(e),resp}))}}function e(e){this.message=e}e.prototype=new Error,e.prototype.name="InvalidCharacterError";var r="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var r=String(t).replace(/=+$/,"");if(r.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var i,n,a=0,s=0,o="";n=r.charAt(s++);~n&&(i=a%4?64*i+n:n,a++%4)?o+=String.fromCharCode(255&i>>(-2*a&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return o};function t(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(r(e).replace(/(.)/g,(function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(t)}catch(e){return r(t)}}function n(e){this.message=e}function o(e,r){if("string"!=typeof e)throw new n("Invalid token specified");var i=!0===(r=r||{}).header?0:1;try{return JSON.parse(t(e.split(".")[i]))}catch(e){throw new n("Invalid token specified: "+e.message)}}n.prototype=new Error,n.prototype.name="InvalidTokenError";const axios=require("axios");class sallaRequest{constructor(e){return e.on("twilight::initiated",(()=>this.initiateRequest())),e.on("profile::info.fetched",this.setCurrencyAndLanguage),e.on("auth::token.fetched",(e=>this.handleToken(e))),e.on("document::request.failed",((e,t)=>{salla.logger.warn(t,e)})),axios.create({headers:{common:{"X-Requested-With":"XMLHttpRequest","S-SOURCE":"twilight","S-APP-VERSION":"v2.0.0","S-APP-OS":"browser"}}})}initiateRequest(){salla.api.defaults.baseURL=salla.config.get("store.api",salla.config.get("store.url")),salla.api.defaults.headers.common["Store-Identifier"]=salla.config.get("store.id"),salla.api.defaults.headers.common.currency=salla.config.get("user.currency_code","SAR"),salla.infiniteScroll.fetchOptions.headers["Accept-Language"]=salla.api.defaults.headers.common["accept-language"]=salla.lang.getLocale(),salla.api.defaults.headers.common["s-user-id"]=salla.config.get("user.id"),this.injectTokenToTheRequests()}injectTokenToTheRequests(){let e=salla.storage.get("token"),t=salla.config.isGuest(),r=salla.storage.get("cart");if(r&&(r.user_id!==salla.config.get("user.id")||r.store_id!==salla.config.get("store.id")))return salla.log("Auth:: The cart is not belong to current "+(r.user_id!==salla.config.get("user.id")?"user":"store")+"!"),void salla.cart.api.reset();if(t&&!e)return;if(t&&e)return salla.log("Auth:: Token without user!"),salla.storage.remove("token"),void salla.cart.api.reset();if(!e)return salla.cart.api.reset(),void salla.auth.api.refresh();let i=o(e);return Date.now()/1e3>i.exp?(salla.log("Auth:: An expired token!"),salla.storage.remove("token"),salla.cart.api.reset(),void salla.auth.api.refresh()):i.sub!==salla.config.get("user.id")?(salla.log("Auth:: The user id is not match the token details!"),salla.storage.remove("token"),salla.cart.api.reset(),void salla.auth.api.refresh()):void this.setToken(e)}handleToken(e){salla.storage.set("token",e),this.setToken(e),salla.cart.api.reset()}setToken(e){salla.api.defaults.headers.common.Authorization="Bearer "+e}setCurrencyAndLanguage(e){salla.api.defaults.headers.common.currency=e.data.currency,salla.api.defaults.headers.common["accept-language"]=e.data.language,salla.infiniteScroll.fetchOptions.headers["Accept-Language"]=e.data.language}}class SallaApi extends sallaRequest{constructor(e){super(e),this.apis={auth:new AuthApi(this),cart:new CartApi(this),loyalty:new LoyaltyApi(this),order:new OrderApi(this),rating:new RatingApi(this),product:new ProductApi(this),profile:new ProfileApi(this),comment:new CommentApi(this),currency:new CurrencyApi(this),document:new DocumentApi(this),twilight:new TwilightApi(this),wishlist:new WishlistApi(this),scope:new ScopeApi(this)},Object.assign(this,this.apis),this.getHeaders=()=>this.defaults.headers.common}}class Action{constructor(e,t){return this.api=e,this.event=t,new Proxy(this,{get:function(r,i){return"event"===i?t:"api"===i&&"twilight"!==e?.namespace?e:e&&e[i]||r[i]}})}}var version={build:6,date:"9/1/2022, 9:16:16 AM",package_version:"2.6.19"},js={exports:{}},core={exports:{}},evEmitter={exports:{}},hasRequiredEvEmitter;function requireEvEmitter(){return hasRequiredEvEmitter||(hasRequiredEvEmitter=1,function(e){!function(t,r){e.exports?e.exports=r():t.EvEmitter=r()}("undefined"!=typeof window?window:commonjsGlobal,(function(){function e(){}let t=e.prototype;return t.on=function(e,t){if(!e||!t)return this;let r=this._events=this._events||{},i=r[e]=r[e]||[];return i.includes(t)||i.push(t),this},t.once=function(e,t){if(!e||!t)return this;this.on(e,t);let r=this._onceEvents=this._onceEvents||{};return(r[e]=r[e]||{})[t]=!0,this},t.off=function(e,t){let r=this._events&&this._events[e];if(!r||!r.length)return this;let i=r.indexOf(t);return-1!=i&&r.splice(i,1),this},t.emitEvent=function(e,t){let r=this._events&&this._events[e];if(!r||!r.length)return this;r=r.slice(0),t=t||[];let i=this._onceEvents&&this._onceEvents[e];for(let n of r){i&&i[n]&&(this.off(e,n),delete i[n]),n.apply(this,t)}return this},t.allOff=function(){return delete this._events,delete this._onceEvents,this},e}))}(evEmitter)),evEmitter.exports}var utils={exports:{}},hasRequiredUtils,hasRequiredCore;function requireUtils(){return hasRequiredUtils||(hasRequiredUtils=1,function(e){!function(t,r){e.exports?e.exports=r(t):t.fizzyUIUtils=r(t)}(commonjsGlobal,(function(e){let t={extend:function(e,t){return Object.assign(e,t)},modulo:function(e,t){return(e%t+t)%t},makeArray:function(e){if(Array.isArray(e))return e;if(null==e)return[];return"object"==typeof e&&"number"==typeof e.length?[...e]:[e]},removeFrom:function(e,t){let r=e.indexOf(t);-1!=r&&e.splice(r,1)},getParent:function(e,t){for(;e.parentNode&&e!=document.body;)if((e=e.parentNode).matches(t))return e},getQueryElement:function(e){return"string"==typeof e?document.querySelector(e):e},handleEvent:function(e){let t="on"+e.type;this[t]&&this[t](e)},filterFindElements:function(e,r){return(e=t.makeArray(e)).filter((e=>e instanceof HTMLElement)).reduce(((e,t)=>{if(!r)return e.push(t),e;t.matches(r)&&e.push(t);let i=t.querySelectorAll(r);return e=e.concat(...i)}),[])},debounceMethod:function(e,t,r){r=r||100;let i=e.prototype[t],n=t+"Timeout";e.prototype[t]=function(){clearTimeout(this[n]);let e=arguments;this[n]=setTimeout((()=>{i.apply(this,e),delete this[n]}),r)}},docReady:function(e){let t=document.readyState;"complete"==t||"interactive"==t?setTimeout(e):document.addEventListener("DOMContentLoaded",e)},toDashed:function(e){return e.replace(/(.)([A-Z])/g,(function(e,t,r){return t+"-"+r})).toLowerCase()}},r=e.console;return t.htmlInit=function(i,n){t.docReady((function(){let a="data-"+t.toDashed(n),s=document.querySelectorAll(`[${a}]`),o=e.jQuery;[...s].forEach((e=>{let t,s=e.getAttribute(a);try{t=s&&JSON.parse(s)}catch(t){return void(r&&r.error(`Error parsing ${a} on ${e.className}: ${t}`))}let l=new i(e,t);o&&o.data(e,n,l)}))}))},t}))}(utils)),utils.exports}function requireCore(){return hasRequiredCore||(hasRequiredCore=1,function(e){!function(t,r){e.exports?e.exports=r(t,requireEvEmitter(),requireUtils()):t.InfiniteScroll=r(t,t.EvEmitter,t.fizzyUIUtils)}(window,(function(e,t,r){let i=e.jQuery,n={};function a(e,t){let s=r.getQueryElement(e);if(s){if((e=s).infiniteScrollGUID){let r=n[e.infiniteScrollGUID];return r.option(t),r}this.element=e,this.options={...a.defaults},this.option(t),i&&(this.$element=i(this.element)),this.create()}else console.error("Bad element for InfiniteScroll: "+(s||e))}a.defaults={},a.create={},a.destroy={};let s=a.prototype;Object.assign(s,t.prototype);let o=0;s.create=function(){let e=this.guid=++o;if(this.element.infiniteScrollGUID=e,n[e]=this,this.pageIndex=1,this.loadCount=0,this.updateGetPath(),this.getPath&&this.getPath()){this.updateGetAbsolutePath(),this.log("initialized",[this.element.className]),this.callOnInit();for(let e in a.create)a.create[e].call(this)}else console.error("Disabling InfiniteScroll")},s.option=function(e){Object.assign(this.options,e)},s.callOnInit=function(){let e=this.options.onInit;e&&e.call(this,this)},s.dispatchEvent=function(e,t,r){this.log(e,r);let n=t?[t].concat(r):r;if(this.emitEvent(e,n),!i||!this.$element)return;let a=e+=".infiniteScroll";if(t){let r=i.Event(t);r.type=e,a=r}this.$element.trigger(a,r)};let l={initialized:e=>`on ${e}`,request:e=>`URL: ${e}`,load:(e,t)=>`${e.title||""}. URL: ${t}`,error:(e,t)=>`${e}. URL: ${t}`,append:(e,t,r)=>`${r.length} items. URL: ${t}`,last:(e,t)=>`URL: ${t}`,history:(e,t)=>`URL: ${t}`,pageIndex:function(e,t){return`current page determined to be: ${e} from ${t}`}};s.log=function(e,t){if(!this.options.debug)return;let r=`[InfiniteScroll] ${e}`,i=l[e];i&&(r+=". "+i.apply(this,t)),console.log(r)},s.updateMeasurements=function(){this.windowHeight=e.innerHeight;let t=this.element.getBoundingClientRect();this.top=t.top+e.scrollY},s.updateScroller=function(){let t=this.options.elementScroll;if(t){if(this.scroller=!0===t?this.element:r.getQueryElement(t),!this.scroller)throw new Error(`Unable to find elementScroll: ${t}`)}else this.scroller=e},s.updateGetPath=function(){let e=this.options.path;if(!e)return void console.error(`InfiniteScroll path option required. Set as: ${e}`);let t=typeof e;"function"!=t?"string"==t&&e.match("{{#}}")?this.updateGetPathTemplate(e):this.updateGetPathSelector(e):this.getPath=e},s.updateGetPathTemplate=function(e){this.getPath=()=>{let t=this.pageIndex+1;return e.replace("{{#}}",t)};let t=e.replace(/(\\\?|\?)/,"\\?").replace("{{#}}","(\\d\\d?\\d?)"),r=new RegExp(t),i=location.href.match(r);i&&(this.pageIndex=parseInt(i[1],10),this.log("pageIndex",[this.pageIndex,"template string"]))};let c=[/^(.*?\/?page\/?)(\d\d?\d?)(.*?$)/,/^(.*?\/?\?page=)(\d\d?\d?)(.*?$)/,/(.*?)(\d\d?\d?)(?!.*\d)(.*?$)/],u=a.getPathParts=function(e){if(e)for(let t of c){let r=e.match(t);if(r){let[,e,t,i]=r;return{begin:e,index:t,end:i}}}};s.updateGetPathSelector=function(e){let t=document.querySelector(e);if(!t)return void console.error(`Bad InfiniteScroll path option. Next link not found: ${e}`);let r=t.getAttribute("href"),i=u(r);if(!i)return void console.error(`InfiniteScroll unable to parse next link href: ${r}`);let{begin:n,index:a,end:s}=i;this.isPathSelector=!0,this.getPath=()=>n+(this.pageIndex+1)+s,this.pageIndex=parseInt(a,10)-1,this.log("pageIndex",[this.pageIndex,"next link"])},s.updateGetAbsolutePath=function(){let e=this.getPath();if(e.match(/^http/)||e.match(/^\//))return void(this.getAbsolutePath=this.getPath);let{pathname:t}=location,r=e.match(/^\?/),i=t.substring(0,t.lastIndexOf("/")),n=r?t:i+"/";this.getAbsolutePath=()=>n+this.getPath()},a.create.hideNav=function(){let e=r.getQueryElement(this.options.hideNav);e&&(e.style.display="none",this.nav=e)},a.destroy.hideNav=function(){this.nav&&(this.nav.style.display="")},s.destroy=function(){this.allOff();for(let e in a.destroy)a.destroy[e].call(this);delete this.element.infiniteScrollGUID,delete n[this.guid],i&&this.$element&&i.removeData(this.element,"infiniteScroll")},a.throttle=function(e,t){let r,i;return t=t||200,function(){let n=+new Date,a=arguments,s=()=>{r=n,e.apply(this,a)};r&&n<r+t?(clearTimeout(i),i=setTimeout(s,t)):s()}},a.data=function(e){let t=(e=r.getQueryElement(e))&&e.infiniteScrollGUID;return t&&n[t]},a.setJQuery=function(e){i=e},r.htmlInit(a,"infinite-scroll"),s._init=function(){};let{jQueryBridget:h}=e;return i&&h&&h("infiniteScroll",a,i),a}))}(core)),core.exports}var pageLoad={exports:{}},hasRequiredPageLoad;function requirePageLoad(){return hasRequiredPageLoad||(hasRequiredPageLoad=1,function(e){!function(t,r){e.exports?e.exports=r(t,requireCore()):r(t,t.InfiniteScroll)}(window,(function(e,t){let r=t.prototype;Object.assign(t.defaults,{loadOnScroll:!0,checkLastPage:!0,responseBody:"text",domParseResponse:!0}),t.create.pageLoad=function(){this.canLoad=!0,this.on("scrollThreshold",this.onScrollThresholdLoad),this.on("load",this.checkLastPage),this.options.outlayer&&this.on("append",this.onAppendOutlayer)},r.onScrollThresholdLoad=function(){this.options.loadOnScroll&&this.loadNextPage()};let i=new DOMParser;function n(e){let t=document.createDocumentFragment();return e&&t.append(...e),t}return r.loadNextPage=function(){if(this.isLoading||!this.canLoad)return;let{responseBody:e,domParseResponse:t,fetchOptions:r}=this.options,n=this.getAbsolutePath();this.isLoading=!0,"function"==typeof r&&(r=r());let a=fetch(n,r).then((r=>{if(!r.ok){let e=new Error(r.statusText);return this.onPageError(e,n,r),{response:r}}return r[e]().then((a=>("text"==e&&t&&(a=i.parseFromString(a,"text/html")),204==r.status?(this.lastPageReached(a,n),{body:a,response:r}):this.onPageLoad(a,n,r))))})).catch((e=>{this.onPageError(e,n)}));return this.dispatchEvent("request",null,[n,a]),a},r.onPageLoad=function(e,t,r){return this.options.append||(this.isLoading=!1),this.pageIndex++,this.loadCount++,this.dispatchEvent("load",null,[e,t,r]),this.appendNextPage(e,t,r)},r.appendNextPage=function(e,t,r){let{append:i,responseBody:a,domParseResponse:s}=this.options;if(!("text"==a&&s)||!i)return{body:e,response:r};let o=e.querySelectorAll(i),l={body:e,response:r,items:o};if(!o||!o.length)return this.lastPageReached(e,t),l;let c=n(o),u=()=>(this.appendItems(o,c),this.isLoading=!1,this.dispatchEvent("append",null,[e,t,o,r]),l);return this.options.outlayer?this.appendOutlayerItems(c,u):u()},r.appendItems=function(e,t){e&&e.length&&(function(e){let t=e.querySelectorAll("script");for(let e of t){let t=document.createElement("script"),r=e.attributes;for(let e of r)t.setAttribute(e.name,e.value);t.innerHTML=e.innerHTML,e.parentNode.replaceChild(t,e)}}(t=t||n(e)),this.element.appendChild(t))},r.appendOutlayerItems=function(r,i){let n=t.imagesLoaded||e.imagesLoaded;return n?new Promise((function(e){n(r,(function(){let t=i();e(t)}))})):(console.error("[InfiniteScroll] imagesLoaded required for outlayer option"),void(this.isLoading=!1))},r.onAppendOutlayer=function(e,t,r){this.options.outlayer.appended(r)},r.checkLastPage=function(e,t){let r,{checkLastPage:i,path:n}=this.options;if(i){if("function"==typeof n){if(!this.getPath())return void this.lastPageReached(e,t)}"string"==typeof i?r=i:this.isPathSelector&&(r=n),r&&e.querySelector&&(e.querySelector(r)||this.lastPageReached(e,t))}},r.lastPageReached=function(e,t){this.canLoad=!1,this.dispatchEvent("last",null,[e,t])},r.onPageError=function(e,t,r){return this.isLoading=!1,this.canLoad=!1,this.dispatchEvent("error",null,[e,t,r]),e},t.create.prefill=function(){if(!this.options.prefill)return;let e=this.options.append;e?(this.updateMeasurements(),this.updateScroller(),this.isPrefilling=!0,this.on("append",this.prefill),this.once("error",this.stopPrefill),this.once("last",this.stopPrefill),this.prefill()):console.error(`append option required for prefill. Set as :${e}`)},r.prefill=function(){let e=this.getPrefillDistance();this.isPrefilling=e>=0,this.isPrefilling?(this.log("prefill"),this.loadNextPage()):this.stopPrefill()},r.getPrefillDistance=function(){return this.options.elementScroll?this.scroller.clientHeight-this.scroller.scrollHeight:this.windowHeight-this.element.clientHeight},r.stopPrefill=function(){this.log("stopPrefill"),this.off("append",this.prefill)},t}))}(pageLoad)),pageLoad.exports}var scrollWatch={exports:{}},hasRequiredScrollWatch;function requireScrollWatch(){return hasRequiredScrollWatch||(hasRequiredScrollWatch=1,function(e){!function(t,r){e.exports?e.exports=r(t,requireCore(),requireUtils()):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){let i=t.prototype;return Object.assign(t.defaults,{scrollThreshold:400}),t.create.scrollWatch=function(){this.pageScrollHandler=this.onPageScroll.bind(this),this.resizeHandler=this.onResize.bind(this);let e=this.options.scrollThreshold;(e||0===e)&&this.enableScrollWatch()},t.destroy.scrollWatch=function(){this.disableScrollWatch()},i.enableScrollWatch=function(){this.isScrollWatching||(this.isScrollWatching=!0,this.updateMeasurements(),this.updateScroller(),this.on("last",this.disableScrollWatch),this.bindScrollWatchEvents(!0))},i.disableScrollWatch=function(){this.isScrollWatching&&(this.bindScrollWatchEvents(!1),delete this.isScrollWatching)},i.bindScrollWatchEvents=function(t){let r=t?"addEventListener":"removeEventListener";this.scroller[r]("scroll",this.pageScrollHandler),e[r]("resize",this.resizeHandler)},i.onPageScroll=t.throttle((function(){this.getBottomDistance()<=this.options.scrollThreshold&&this.dispatchEvent("scrollThreshold")})),i.getBottomDistance=function(){let t,r;return this.options.elementScroll?(t=this.scroller.scrollHeight,r=this.scroller.scrollTop+this.scroller.clientHeight):(t=this.top+this.element.clientHeight,r=e.scrollY+this.windowHeight),t-r},i.onResize=function(){this.updateMeasurements()},r.debounceMethod(t,"onResize",150),t}))}(scrollWatch)),scrollWatch.exports}var history$1={exports:{}},hasRequiredHistory;function requireHistory(){return hasRequiredHistory||(hasRequiredHistory=1,function(e){!function(t,r){e.exports?e.exports=r(t,requireCore(),requireUtils()):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){let i=t.prototype;Object.assign(t.defaults,{history:"replace"});let n=document.createElement("a");return t.create.history=function(){if(!this.options.history)return;n.href=this.getAbsolutePath(),(n.origin||n.protocol+"//"+n.host)==location.origin?this.options.append?this.createHistoryAppend():this.createHistoryPageLoad():console.error(`[InfiniteScroll] cannot set history with different origin: ${n.origin} on ${location.origin} . History behavior disabled.`)},i.createHistoryAppend=function(){this.updateMeasurements(),this.updateScroller(),this.scrollPages=[{top:0,path:location.href,title:document.title}],this.scrollPage=this.scrollPages[0],this.scrollHistoryHandler=this.onScrollHistory.bind(this),this.unloadHandler=this.onUnload.bind(this),this.scroller.addEventListener("scroll",this.scrollHistoryHandler),this.on("append",this.onAppendHistory),this.bindHistoryAppendEvents(!0)},i.bindHistoryAppendEvents=function(t){let r=t?"addEventListener":"removeEventListener";this.scroller[r]("scroll",this.scrollHistoryHandler),e[r]("unload",this.unloadHandler)},i.createHistoryPageLoad=function(){this.on("load",this.onPageLoadHistory)},t.destroy.history=i.destroyHistory=function(){this.options.history&&this.options.append&&this.bindHistoryAppendEvents(!1)},i.onAppendHistory=function(e,t,r){if(!r||!r.length)return;let i=r[0],a=this.getElementScrollY(i);n.href=t,this.scrollPages.push({top:a,path:n.href,title:e.title})},i.getElementScrollY=function(t){if(this.options.elementScroll)return t.offsetTop-this.top;return t.getBoundingClientRect().top+e.scrollY},i.onScrollHistory=function(){let e=this.getClosestScrollPage();e!=this.scrollPage&&(this.scrollPage=e,this.setHistory(e.title,e.path))},r.debounceMethod(t,"onScrollHistory",150),i.getClosestScrollPage=function(){let t,r;t=this.options.elementScroll?this.scroller.scrollTop+this.scroller.clientHeight/2:e.scrollY+this.windowHeight/2;for(let e of this.scrollPages){if(e.top>=t)break;r=e}return r},i.setHistory=function(e,t){let r=this.options.history;r&&history[r+"State"]&&(history[r+"State"](null,e,t),this.options.historyTitle&&(document.title=e),this.dispatchEvent("history",null,[e,t]))},i.onUnload=function(){if(0===this.scrollPage.top)return;let t=e.scrollY-this.scrollPage.top+this.top;this.destroyHistory(),scrollTo(0,t)},i.onPageLoadHistory=function(e,t){this.setHistory(e.title,t)},t}))}(history$1)),history$1.exports}var button={exports:{}},hasRequiredButton;function requireButton(){return hasRequiredButton||(hasRequiredButton=1,function(e){!function(t,r){e.exports?e.exports=r(t,requireCore(),requireUtils()):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){class i{constructor(e,t){this.element=e,this.infScroll=t,this.clickHandler=this.onClick.bind(this),this.element.addEventListener("click",this.clickHandler),t.on("request",this.disable.bind(this)),t.on("load",this.enable.bind(this)),t.on("error",this.hide.bind(this)),t.on("last",this.hide.bind(this))}onClick(e){e.preventDefault(),this.infScroll.loadNextPage()}enable(){this.element.removeAttribute("disabled")}disable(){this.element.disabled="disabled"}hide(){this.element.style.display="none"}destroy(){this.element.removeEventListener("click",this.clickHandler)}}return t.create.button=function(){let e=r.getQueryElement(this.options.button);e&&(this.button=new i(e,this))},t.destroy.button=function(){this.button&&this.button.destroy()},t.Button=i,t}))}(button)),button.exports}var status={exports:{}},hasRequiredStatus;function requireStatus(){return hasRequiredStatus||(hasRequiredStatus=1,function(e){!function(t,r){e.exports?e.exports=r(t,requireCore(),requireUtils()):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){let i=t.prototype;function n(e){s(e,"none")}function a(e){s(e,"block")}function s(e,t){e&&(e.style.display=t)}return t.create.status=function(){let e=r.getQueryElement(this.options.status);e&&(this.statusElement=e,this.statusEventElements={request:e.querySelector(".infinite-scroll-request"),error:e.querySelector(".infinite-scroll-error"),last:e.querySelector(".infinite-scroll-last")},this.on("request",this.showRequestStatus),this.on("error",this.showErrorStatus),this.on("last",this.showLastStatus),this.bindHideStatus("on"))},i.bindHideStatus=function(e){let t=this.options.append?"append":"load";this[e](t,this.hideAllStatus)},i.showRequestStatus=function(){this.showStatus("request")},i.showErrorStatus=function(){this.showStatus("error")},i.showLastStatus=function(){this.showStatus("last"),this.bindHideStatus("off")},i.showStatus=function(e){a(this.statusElement),this.hideStatusEventElements(),a(this.statusEventElements[e])},i.hideAllStatus=function(){n(this.statusElement),this.hideStatusEventElements()},i.hideStatusEventElements=function(){for(let e in this.statusEventElements){n(this.statusEventElements[e])}},t}))}(status)),status.exports}
|
|
8
|
+
*/!function(e,t){!function(t){var r=Object.hasOwnProperty,n=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},i="object"==typeof process&&"function"==typeof process.nextTick,s="function"==typeof Symbol,a="object"==typeof Reflect,o="function"==typeof setImmediate?setImmediate:setTimeout,l=s?a&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys:function(e){var t=Object.getOwnPropertyNames(e);return t.push.apply(t,Object.getOwnPropertySymbols(e)),t}:Object.keys;function c(){this._events={},this._conf&&u.call(this,this._conf)}function u(e){e&&(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),e.maxListeners!==t&&(this._maxListeners=e.maxListeners),e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),e.ignoreErrors&&(this.ignoreErrors=e.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function h(e,t){var r="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(r+=" Event name: "+t+"."),"undefined"!=typeof process&&process.emitWarning){var n=new Error(r);n.name="MaxListenersExceededWarning",n.emitter=this,n.count=e,process.emitWarning(n)}else console.error(r),console.trace&&console.trace()}var d=function(e,t,r){var n=arguments.length;switch(n){case 0:return[];case 1:return[e];case 2:return[e,t];case 3:return[e,t,r];default:for(var i=new Array(n);n--;)i[n]=arguments[n];return i}};function f(e,r){for(var n={},i=e.length,s=r?r.length:0,a=0;a<i;a++)n[e[a]]=a<s?r[a]:t;return n}function p(e,t,r){var n,i;if(this._emitter=e,this._target=t,this._listeners={},this._listenersCount=0,(r.on||r.off)&&(n=r.on,i=r.off),t.addEventListener?(n=t.addEventListener,i=t.removeEventListener):t.addListener?(n=t.addListener,i=t.removeListener):t.on&&(n=t.on,i=t.off),!n&&!i)throw Error("target does not implement any known event API");if("function"!=typeof n)throw TypeError("on method must be a function");if("function"!=typeof i)throw TypeError("off method must be a function");this._on=n,this._off=i;var s=e._observers;s?s.push(this):e._observers=[this]}function g(e,n,i,s){var a=Object.assign({},n);if(!e)return a;if("object"!=typeof e)throw TypeError("options must be an object");var o,l,c,u=Object.keys(e),h=u.length;function d(e){throw Error('Invalid "'+o+'" option value'+(e?". Reason: "+e:""))}for(var f=0;f<h;f++){if(o=u[f],!s&&!r.call(n,o))throw Error('Unknown "'+o+'" option');(l=e[o])!==t&&(c=i[o],a[o]=c?c(l,d):l)}return a}function m(e,t){return"function"==typeof e&&e.hasOwnProperty("prototype")||t("value must be a constructor"),e}function v(e){var t="value must be type of "+e.join("|"),r=e.length,n=e[0],i=e[1];return 1===r?function(e,r){if(typeof e===n)return e;r(t)}:2===r?function(e,r){var s=typeof e;if(s===n||s===i)return e;r(t)}:function(n,i){for(var s=typeof n,a=r;a-- >0;)if(s===e[a])return n;i(t)}}Object.assign(p.prototype,{subscribe:function(e,t,r){var n=this,i=this._target,s=this._emitter,a=this._listeners,o=function(){var n=d.apply(null,arguments),a={data:n,name:t,original:e};if(r){var o=r.call(i,a);!1!==o&&s.emit.apply(s,[a.name].concat(n))}else s.emit.apply(s,[t].concat(n))};if(a[e])throw Error("Event '"+e+"' is already listening");this._listenersCount++,s._newListener&&s._removeListener&&!n._onNewListener?(this._onNewListener=function(r){r===t&&null===a[e]&&(a[e]=o,n._on.call(i,e,o))},s.on("newListener",this._onNewListener),this._onRemoveListener=function(r){r===t&&!s.hasListeners(r)&&a[e]&&(a[e]=null,n._off.call(i,e,o))},a[e]=null,s.on("removeListener",this._onRemoveListener)):(a[e]=o,n._on.call(i,e,o))},unsubscribe:function(e){var t,r,n,i=this,s=this._listeners,a=this._emitter,o=this._off,c=this._target;if(e&&"string"!=typeof e)throw TypeError("event must be a string");function u(){i._onNewListener&&(a.off("newListener",i._onNewListener),a.off("removeListener",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var e=_.call(a,i);a._observers.splice(e,1)}if(e){if(!(t=s[e]))return;o.call(c,e,t),delete s[e],--this._listenersCount||u()}else{for(n=(r=l(s)).length;n-- >0;)e=r[n],o.call(c,e,s[e]);this._listeners={},this._listenersCount=0,u()}}});var y=v(["function"]),b=v(["object","function"]);function w(e,t,r){var n,i,s,a=0,o=new e((function(l,c,u){function h(){i&&(i=null),a&&(clearTimeout(a),a=0)}r=g(r,{timeout:0,overload:!1},{timeout:function(e,t){return("number"!=typeof(e*=1)||e<0||!Number.isFinite(e))&&t("timeout must be a positive number"),e}}),n=!r.overload&&"function"==typeof e.prototype.cancel&&"function"==typeof u;var d=function(e){h(),l(e)},f=function(e){h(),c(e)};n?t(d,f,u):(i=[function(e){f(e||Error("canceled"))}],t(d,f,(function(e){if(s)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof e)throw TypeError("onCancel callback must be a function");i.push(e)})),s=!0),r.timeout>0&&(a=setTimeout((function(){var e=Error("timeout");e.code="ETIMEDOUT",a=0,o.cancel(e),c(e)}),r.timeout))}));return n||(o.cancel=function(e){if(i){for(var t=i.length,r=1;r<t;r++)i[r](e);i[0](e),i=null}}),o}function _(e){var t=this._observers;if(!t)return-1;for(var r=t.length,n=0;n<r;n++)if(t[n]._target===e)return n;return-1}function E(e,t,r,n,i){if(!r)return null;if(0===n){var s=typeof t;if("string"===s){var a,o,c=0,u=0,h=this.delimiter,d=h.length;if(-1!==(o=t.indexOf(h))){a=new Array(5);do{a[c++]=t.slice(u,o),u=o+d}while(-1!==(o=t.indexOf(h,u)));a[c++]=t.slice(u),t=a,i=c}else t=[t],i=1}else"object"===s?i=t.length:(t=[t],i=1)}var f,p,g,m,v,y,b,w=null,_=t[n],S=t[n+1];if(n===i)r._listeners&&("function"==typeof r._listeners?(e&&e.push(r._listeners),w=[r]):(e&&e.push.apply(e,r._listeners),w=[r]));else{if("*"===_){for(o=(y=l(r)).length;o-- >0;)"_listeners"!==(f=y[o])&&(b=E(e,t,r[f],n+1,i))&&(w?w.push.apply(w,b):w=b);return w}if("**"===_){for((v=n+1===i||n+2===i&&"*"===S)&&r._listeners&&(w=E(e,t,r,i,i)),o=(y=l(r)).length;o-- >0;)"_listeners"!==(f=y[o])&&("*"===f||"**"===f?(r[f]._listeners&&!v&&(b=E(e,t,r[f],i,i))&&(w?w.push.apply(w,b):w=b),b=E(e,t,r[f],n,i)):b=E(e,t,r[f],f===S?n+2:n,i),b&&(w?w.push.apply(w,b):w=b));return w}r[_]&&(w=E(e,t,r[_],n+1,i))}if((p=r["*"])&&E(e,t,p,n+1,i),g=r["**"])if(n<i)for(g._listeners&&E(e,t,g,i,i),o=(y=l(g)).length;o-- >0;)"_listeners"!==(f=y[o])&&(f===S?E(e,t,g[f],n+2,i):f===_?E(e,t,g[f],n+1,i):((m={})[f]=g[f],E(e,t,{"**":m},n+1,i)));else g._listeners?E(e,t,g,i,i):g["*"]&&g["*"]._listeners&&E(e,t,g["*"],i,i);return w}function S(e,t,r){var n,i,s=0,a=0,o=this.delimiter,l=o.length;if("string"==typeof e)if(-1!==(n=e.indexOf(o))){i=new Array(5);do{i[s++]=e.slice(a,n),a=n+l}while(-1!==(n=e.indexOf(o,a)));i[s++]=e.slice(a)}else i=[e],s=1;else i=e,s=e.length;if(s>1)for(n=0;n+1<s;n++)if("**"===i[n]&&"**"===i[n+1])return;var c,u=this.listenerTree;for(n=0;n<s;n++)if(u=u[c=i[n]]||(u[c]={}),n===s-1)return u._listeners?("function"==typeof u._listeners&&(u._listeners=[u._listeners]),r?u._listeners.unshift(t):u._listeners.push(t),!u._listeners.warned&&this._maxListeners>0&&u._listeners.length>this._maxListeners&&(u._listeners.warned=!0,h.call(this,u._listeners.length,c))):u._listeners=t,!0;return!0}function x(e,t,r,n){for(var i,s,a,o,c=l(e),u=c.length,h=e._listeners;u-- >0;)i=e[s=c[u]],a="_listeners"===s?r:r?r.concat(s):[s],o=n||"symbol"==typeof s,h&&t.push(o?a:a.join(this.delimiter)),"object"==typeof i&&x.call(this,i,t,a,o);return t}function A(e){for(var t,r,n,i=l(e),s=i.length;s-- >0;)(t=e[r=i[s]])&&(n=!0,"_listeners"===r||A(t)||delete e[r]);return n}function P(e,t,r){this.emitter=e,this.event=t,this.listener=r}function F(e,r,n){if(!0===n)a=!0;else if(!1===n)s=!0;else{if(!n||"object"!=typeof n)throw TypeError("options should be an object or true");var s=n.async,a=n.promisify,l=n.nextTick,c=n.objectify}if(s||l||a){var u=r,h=r._origin||r;if(l&&!i)throw Error("process.nextTick is not supported");a===t&&(a="AsyncFunction"===r.constructor.name),r=function(){var e=arguments,t=this,r=this.event;return a?l?Promise.resolve():new Promise((function(e){o(e)})).then((function(){return t.event=r,u.apply(t,e)})):(l?process.nextTick:o)((function(){t.event=r,u.apply(t,e)}))},r._async=!0,r._origin=h}return[r,c?new P(this,e,r):this]}function L(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,u.call(this,e)}P.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},L.EventEmitter2=L,L.prototype.listenTo=function(e,r,i){if("object"!=typeof e)throw TypeError("target musts be an object");var s=this;function a(t){if("object"!=typeof t)throw TypeError("events must be an object");var r,n=i.reducers,a=_.call(s,e);r=-1===a?new p(s,e,i):s._observers[a];for(var o,c=l(t),u=c.length,h="function"==typeof n,d=0;d<u;d++)o=c[d],r.subscribe(o,t[o]||o,h?n:n&&n[o])}return i=g(i,{on:t,off:t,reducers:t},{on:y,off:y,reducers:b}),n(r)?a(f(r)):a("string"==typeof r?f(r.split(/\s+/)):r),this},L.prototype.stopListeningTo=function(e,t){var r=this._observers;if(!r)return!1;var n,i=r.length,s=!1;if(e&&"object"!=typeof e)throw TypeError("target should be an object");for(;i-- >0;)n=r[i],e&&n._target!==e||(n.unsubscribe(t),s=!0);return s},L.prototype.delimiter=".",L.prototype.setMaxListeners=function(e){e!==t&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},L.prototype.getMaxListeners=function(){return this._maxListeners},L.prototype.event="",L.prototype.once=function(e,t,r){return this._once(e,t,!1,r)},L.prototype.prependOnceListener=function(e,t,r){return this._once(e,t,!0,r)},L.prototype._once=function(e,t,r,n){return this._many(e,1,t,r,n)},L.prototype.many=function(e,t,r,n){return this._many(e,t,r,!1,n)},L.prototype.prependMany=function(e,t,r,n){return this._many(e,t,r,!0,n)},L.prototype._many=function(e,t,r,n,i){var s=this;if("function"!=typeof r)throw new Error("many only accepts instances of Function");function a(){return 0==--t&&s.off(e,a),r.apply(this,arguments)}return a._origin=r,this._on(e,a,n,i)},L.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var e,t,r,n,i,a,o=arguments[0],l=this.wildcard;if("newListener"===o&&!this._newListener&&!this._events.newListener)return!1;if(l&&(e=o,"newListener"!==o&&"removeListener"!==o&&"object"==typeof o)){if(r=o.length,s)for(n=0;n<r;n++)if("symbol"==typeof o[n]){a=!0;break}a||(o=o.join(this.delimiter))}var u,h=arguments.length;if(this._all&&this._all.length)for(n=0,r=(u=this._all.slice()).length;n<r;n++)switch(this.event=o,h){case 1:u[n].call(this,o);break;case 2:u[n].call(this,o,arguments[1]);break;case 3:u[n].call(this,o,arguments[1],arguments[2]);break;default:u[n].apply(this,arguments)}if(l)u=[],E.call(this,u,e,this.listenerTree,0,r);else{if("function"==typeof(u=this._events[o])){switch(this.event=o,h){case 1:u.call(this);break;case 2:u.call(this,arguments[1]);break;case 3:u.call(this,arguments[1],arguments[2]);break;default:for(t=new Array(h-1),i=1;i<h;i++)t[i-1]=arguments[i];u.apply(this,t)}return!0}u&&(u=u.slice())}if(u&&u.length){if(h>3)for(t=new Array(h-1),i=1;i<h;i++)t[i-1]=arguments[i];for(n=0,r=u.length;n<r;n++)switch(this.event=o,h){case 1:u[n].call(this);break;case 2:u[n].call(this,arguments[1]);break;case 3:u[n].call(this,arguments[1],arguments[2]);break;default:u[n].apply(this,t)}return!0}if(!this.ignoreErrors&&!this._all&&"error"===o)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},L.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var e,t,r,n,i,a,o=arguments[0],l=this.wildcard;if("newListener"===o&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(l&&(e=o,"newListener"!==o&&"removeListener"!==o&&"object"==typeof o)){if(n=o.length,s)for(i=0;i<n;i++)if("symbol"==typeof o[i]){t=!0;break}t||(o=o.join(this.delimiter))}var u,h=[],d=arguments.length;if(this._all)for(i=0,n=this._all.length;i<n;i++)switch(this.event=o,d){case 1:h.push(this._all[i].call(this,o));break;case 2:h.push(this._all[i].call(this,o,arguments[1]));break;case 3:h.push(this._all[i].call(this,o,arguments[1],arguments[2]));break;default:h.push(this._all[i].apply(this,arguments))}if(l?(u=[],E.call(this,u,e,this.listenerTree,0)):u=this._events[o],"function"==typeof u)switch(this.event=o,d){case 1:h.push(u.call(this));break;case 2:h.push(u.call(this,arguments[1]));break;case 3:h.push(u.call(this,arguments[1],arguments[2]));break;default:for(r=new Array(d-1),a=1;a<d;a++)r[a-1]=arguments[a];h.push(u.apply(this,r))}else if(u&&u.length){if(u=u.slice(),d>3)for(r=new Array(d-1),a=1;a<d;a++)r[a-1]=arguments[a];for(i=0,n=u.length;i<n;i++)switch(this.event=o,d){case 1:h.push(u[i].call(this));break;case 2:h.push(u[i].call(this,arguments[1]));break;case 3:h.push(u[i].call(this,arguments[1],arguments[2]));break;default:h.push(u[i].apply(this,r))}}else if(!this.ignoreErrors&&!this._all&&"error"===o)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(h)},L.prototype.on=function(e,t,r){return this._on(e,t,!1,r)},L.prototype.prependListener=function(e,t,r){return this._on(e,t,!0,r)},L.prototype.onAny=function(e){return this._onAny(e,!1)},L.prototype.prependAny=function(e){return this._onAny(e,!0)},L.prototype.addListener=L.prototype.on,L.prototype._onAny=function(e,t){if("function"!=typeof e)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),t?this._all.unshift(e):this._all.push(e),this},L.prototype._on=function(e,r,n,i){if("function"==typeof e)return this._onAny(e,r),this;if("function"!=typeof r)throw new Error("on only accepts instances of Function");this._events||c.call(this);var s,a=this;return i!==t&&(r=(s=F.call(this,e,r,i))[0],a=s[1]),this._newListener&&this.emit("newListener",e,r),this.wildcard?(S.call(this,e,r,n),a):(this._events[e]?("function"==typeof this._events[e]&&(this._events[e]=[this._events[e]]),n?this._events[e].unshift(r):this._events[e].push(r),!this._events[e].warned&&this._maxListeners>0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,h.call(this,this._events[e].length,e))):this._events[e]=r,a)},L.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var r,i=[];if(this.wildcard){var s="string"==typeof e?e.split(this.delimiter):e.slice();if(!(i=E.call(this,null,s,this.listenerTree,0)))return this}else{if(!this._events[e])return this;r=this._events[e],i.push({_listeners:r})}for(var a=0;a<i.length;a++){var o=i[a];if(r=o._listeners,n(r)){for(var l=-1,c=0,u=r.length;c<u;c++)if(r[c]===t||r[c].listener&&r[c].listener===t||r[c]._origin&&r[c]._origin===t){l=c;break}if(l<0)continue;return this.wildcard?o._listeners.splice(l,1):this._events[e].splice(l,1),0===r.length&&(this.wildcard?delete o._listeners:delete this._events[e]),this._removeListener&&this.emit("removeListener",e,t),this}(r===t||r.listener&&r.listener===t||r._origin&&r._origin===t)&&(this.wildcard?delete o._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return this.listenerTree&&A(this.listenerTree),this},L.prototype.offAny=function(e){var t,r=0,n=0;if(e&&this._all&&this._all.length>0){for(r=0,n=(t=this._all).length;r<n;r++)if(e===t[r])return t.splice(r,1),this._removeListener&&this.emit("removeListenerAny",e),this}else{if(t=this._all,this._removeListener)for(r=0,n=t.length;r<n;r++)this.emit("removeListenerAny",t[r]);this._all=[]}return this},L.prototype.removeListener=L.prototype.off,L.prototype.removeAllListeners=function(e){if(e===t)return!this._events||c.call(this),this;if(this.wildcard){var r,n=E.call(this,null,e,this.listenerTree,0);if(!n)return this;for(r=0;r<n.length;r++)n[r]._listeners=null;this.listenerTree&&A(this.listenerTree)}else this._events&&(this._events[e]=null);return this},L.prototype.listeners=function(e){var r,n,i,s,a,o=this._events;if(e===t){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!o)return[];for(s=(r=l(o)).length,i=[];s-- >0;)"function"==typeof(n=o[r[s]])?i.push(n):i.push.apply(i,n);return i}if(this.wildcard){if(!(a=this.listenerTree))return[];var c=[],u="string"==typeof e?e.split(this.delimiter):e.slice();return E.call(this,c,u,a,0),c}return o&&(n=o[e])?"function"==typeof n?[n]:n:[]},L.prototype.eventNames=function(e){var t=this._events;return this.wildcard?x.call(this,this.listenerTree,[],null,e):t?l(t):[]},L.prototype.listenerCount=function(e){return this.listeners(e).length},L.prototype.hasListeners=function(e){if(this.wildcard){var r=[],n="string"==typeof e?e.split(this.delimiter):e.slice();return E.call(this,r,n,this.listenerTree,0),r.length>0}var i=this._events,s=this._all;return!!(s&&s.length||i&&(e===t?l(i).length:i[e]))},L.prototype.listenersAny=function(){return this._all?this._all:[]},L.prototype.waitFor=function(e,r){var n=this,i=typeof r;return"number"===i?r={timeout:r}:"function"===i&&(r={filter:r}),w((r=g(r,{timeout:0,filter:t,handleError:!1,Promise:Promise,overload:!1},{filter:y,Promise:m})).Promise,(function(t,i,s){function a(){var s=r.filter;if(!s||s.apply(n,arguments))if(n.off(e,a),r.handleError){var o=arguments[0];o?i(o):t(d.apply(null,arguments).slice(1))}else t(d.apply(null,arguments))}s((function(){n.off(e,a)})),n._on(e,a,!1)}),{timeout:r.timeout,overload:r.overload})};var O=L.prototype;Object.defineProperties(L,{defaultMaxListeners:{get:function(){return O._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");O._maxListeners=e},enumerable:!0},once:{value:function(e,t,r){return w((r=g(r,{Promise:Promise,timeout:0,overload:!1},{Promise:m})).Promise,(function(r,n,i){var s;if("function"==typeof e.addEventListener)return s=function(){r(d.apply(null,arguments))},i((function(){e.removeEventListener(t,s)})),void e.addEventListener(t,s,{once:!0});var a,o=function(){a&&e.removeListener("error",a),r(d.apply(null,arguments))};"error"!==t&&(a=function(r){e.removeListener(t,o),n(r)},e.once("error",a)),i((function(){a&&e.removeListener("error",a),e.removeListener(t,o)})),e.once(t,o)}),{timeout:r.timeout,overload:r.overload})},writable:!0,configurable:!0}}),Object.defineProperties(O,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),e.exports=L}()}(E);var S=E.exports;class x extends a{constructor(e){super(e),this.namespace="infiniteScroll",this.events={scrollThreshold:"scroll.threshold",request:"request",load:"load",append:"append",error:"error",last:"last",history:"history"},this.after_init()}}class A{constructor(e){this.parent=e,this.endpoints={},this.webEndpoints=[],this.namespace="BaseApi",this.endpointsMethods={},this.endpointsHeaders={};var t=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(t&&t.length>1?t[1]:"").toLowerCase(),this.debounce={request:void 0,time:300,enabled:!0,exclude:[]}}after_init(){}normalRequest(e,t,r=null){let n=this,i=Array.isArray(e),s=i?this.getUrl(...e):this.getUrl(e);e=i?e[0]:e,r=r||this.endpointsMethods[e]||"post";let a=this.endpointsHeaders[e];if("get"===r&&t instanceof FormData){var o={};Array.from(t.entries()).forEach((function(e){o[e[0]]=e[1]})),t={params:o}}a&&"get"===r&&(t=t?Object.assign(t,a):a);let l={namespace:this.namespace,action:e,url:s,payload:t,method:r,headers:a};try{salla.event.document.request(l)}catch(e){return salla.event.document.requestFailed(l),new Promise((()=>{throw e}))}this.webEndpoints.includes(e)?s=salla.url.get(s):"http"!==s.substring(0,4)&&(s=salla.url.api(s));let c="undefined"!=typeof event?event.currentTarget:null,u=!1;return"SALLA-BUTTON"===c?.tagName&&(u=!0),u&&c?.load(),this.parent[r](s,t,{headers:a}).then((e=>(u&&c?.stop(),e.data&&e.request&&(e=e.data),n.handleAfterResponseActions(e),e))).catch((e=>{throw u&&c?.stop(),salla.event.document.requestFailed(l,e),n.handleErrorResponse(e),e}))}request(e,t,r=null){return!this.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,r)):this.normalRequest(e,t,r)}getUrl(e){let t=this.endpoints[e]||e;const r=/{[^{}]+}/i;for(let e=1;e<arguments.length;e++)t=t.replace(r,arguments[e]);return t}handleAfterResponseActions(e){if(!e)return;let{data:t,googleTags:r=null}=e,n=t&&t.googleTags?t.googleTags:r;dataLayer&&n&&dataLayer.push(n),this.fireEventsForResponse(e),this.renderSections(e),this.showAlert(e),e.data?.token&&salla.event.auth.tokenFetched(e.data.token)}fireEventsForResponse(e){let t=e.events||e.data?.events||e.error?.events;"string"==typeof t&&(t=JSON.parse(t)),t&&Object.keys(t).forEach((e=>salla.event.dispatch(e,t[e])))}renderSections(e){e.sections&&Object.keys(e.sections).forEach((t=>{document.querySelectorAll(t.toSelector()).forEach((function(r){r.innerHTML=e.sections[t]}))}))}handleErrorResponse(e){if(e.response&&e.response.data)return e.response.data.error&&e.response.data.error.fields?this.handleInvalidFields(e):this.handleAfterResponseActions(e.response.data)}showAlert(e){if(e&&salla.config.get("sdk.notifier_handler_disabled"))return e.case&&e.msg?salla.notify.fire(e.msg,e.case,e):e.hasOwnProperty("success")&&e.data?.message?salla.notify.fire(e.data?.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}handleInvalidFields(e){let t=e.response.data.error.fields,r=[];Object.keys(t).forEach((e=>{let n=t[e];Array.isArray(n)?n.forEach((e=>r.push(e))):r.push(n)}));let n=(r.length>1?"* ":"")+r.join("\n* ");salla.error(n,e)}event(){return salla.event[this.className]}getPossibleValue(e,t,r=!1){if(!e)return;if("object"!=typeof e)return e;let n;for(let r=0;r<t.length&&!(n=e[t[r]])&&!("undefined"!=typeof FormData&&e instanceof FormData&&(n=e.get(t[r])));r++);return n=n||e,"object"!=typeof n||r?n:void 0}isFastRequestsAllowed(){return salla.config.get("fastRequests")}promise(e,t=!0){return new Promise(((r,n)=>t?r(e):n(e)))}errorPromise(e){return this.promise(e,!1)}successPromise(e){return this.promise(e,!0)}}class P extends A{constructor(e){super(e),this.namespace="cart",this.endpoints={latest:"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"},this.endpointsMethods={latest:"get",details:"get",status:"get",updateItem:"post",deleteItem:"delete",deleteImage:"delete",deleteCoupon:"put"},this.webEndpoints=["latest"],this.after_init()}async getCurrentCartId(){return salla.storage.get("cart.id")||(await this.latest()).data.cart.id}getUploadImageEndpoint(e){return salla.url.api(this.getUrl("uploadImage",e||salla.storage.get("cart.id")))}latest(){return this.request("latest",{params:{source:""}}).then((e=>(salla.storage.set("cart",e.data.cart),salla.event.cart.latestFetched(e),e))).catch((e=>{throw salla.storage.set("cart",""),salla.event.cart.latestFailed(e),e}))}async details(){let e=await this.getCurrentCartId();return this.request(["details",e]).then((function(e){return salla.cart.event.detailsFetched(e),e})).catch((function(e){throw salla.cart.event.detailsNotFetched(e),e}))}async quickAdd(e){return this.addItem(e)}async addItem(e){let t=this.getCartPayload(e);if(!t.id){let e='There is no product "id"!';return salla.cart.event.itemAddedFailed(e),this.errorPromise(e)}let r=this.getPossibleValue(t.payload,["quantity","donating_amount"])?"addItem":"quickAdd",n=await this.getCurrentCartId();return this.request([r,n,t.id],t.payload).then((function(e){return salla.cart.event.itemAdded(e,t.id),e})).catch((function(e){throw salla.cart.event.itemAddedFailed(e,t.id),e}))}async deleteItem(e){let t=this.getCartPayload(e);if(!t.id){let e='There is no "id"!';return salla.cart.event.itemDeletedFailed(e),this.errorPromise(e)}let r=await this.getCurrentCartId();return this.request(["deleteItem",r,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}))}async updateItem(e){let t=this.getCartPayload(e);if(!t.id){let e='There is no "id"!';return salla.cart.event.itemUpdatedFailed(e),this.errorPromise(e)}let r=await this.getCurrentCartId();return"Object"===t.payload.constructor?.name?t.payload._method="PUT":t.payload.append("_method","PUT"),this.request(["updateItem",r,t.id],t.payload).then((function(e){return salla.cart.event.itemUpdated(e,t.id),e})).catch((function(e){throw salla.cart.event.itemUpdatedFailed(e,t.id),e}))}async deleteImage(e){if(!(e=this.getPossibleValue(e,["id","image_id","photo_id"]))){let e='There is no "id"!';return salla.cart.event.imageNotDeleted(e),this.errorPromise(e)}let t=await this.getCurrentCartId();return this.request(["deleteImage",t,e]).then((function(t){return salla.cart.event.imageDeleted(t,e),t})).catch((function(t){throw salla.cart.event.imageNotDeleted(t,e),t}))}async status(e){return this.request(["status",e||await this.getCurrentCartId()])}async submit(){this.status(await this.getCurrentCartId()).then((e=>{let t=e.data.next_step.to;if(!["checkout","refresh","login"].includes(t)){let e="Can't find next_step );";throw salla.cart.event.submitFailed(e),e}if(salla.cart.event.submitted(e),"login"===t)return salla.auth.setCanRedirect(!1),salla.event.dispatch("login::open"),void salla.auth.event.onLoggedIn((e=>{salla.event.dispatch("login::close"),this.submit()}));"checkout"===t?window.location.href=e.data.next_step.url+(window.ApplePaySession?"?has_apple_pay=true":""):window.location.reload()})).catch((function(e){throw salla.cart.event.submitFailed(e),e}))}getCartPayload(e){let t=e?.data||("object"==typeof e?e:void 0);return e=t?this.getPossibleValue(t,["prod_id","product_id","item_id","id"]):e,t="object"==typeof t?t:void 0,{id:e,payload:t}}handleAfterResponseActions(e){if(403===e.status){salla.storage.remove("cart");let e=salla.lang.get("pages.checkout.try_again");throw salla.error(e),e}super.handleAfterResponseActions(e)}reset(){salla.storage.remove("cart"),salla.cart.event.successReset()}async addCoupon(e){if(e=e.data||e,!(e=this.getPossibleValue(e,["coupon"]))){let e=new Error('There is no "Coupon Code"!');return e.name="EmptyCoupon",salla.event.cart.couponAdditionFailed(e),this.errorPromise(e)}let t=await salla.cart.api.getCurrentCartId();return this.request(["addCoupon",t],{coupon:e}).then((function(e){return salla.event.cart.couponAdded(e,t),e})).catch((function(e){throw salla.event.cart.couponAdditionFailed(e,t),e}))}async deleteCoupon(){let e=await salla.cart.api.getCurrentCartId();return this.request(["deleteCoupon",e],{}).then((function(t){return salla.event.cart.couponDeleted(t,e),t})).catch((function(t){throw salla.event.cart.couponDeletionFailed(t,e),t}))}}class F extends A{constructor(e){super(e),this.namespace="loyalty",this.endpoints={getProgram:"loyalty",exchange:"loyalty/exchange",reset:"loyalty/exchange"},this.endpointsMethods={getProgram:"get",reset:"put"},this.after_init()}getProgram(){return this.request("getProgram").then((e=>(salla.loyalty.event.programFetched(e),e))).catch((e=>{throw salla.loyalty.event.programNotFetched(e),e}))}async exchange(e,t=null){if(!(e=this.getPossibleValue(e,["id","loyalty_prize_id","prize_id"]))){let e="Unable to find cart id. Please provide one.";return salla.loyalty.event.exchangeFailed(e),this.errorPromise(e)}if(!(t=t||await salla.cart.getCurrentCartId())){let e="Unable to find cart id. Please provide one.";return salla.loyalty.event.exchangeFailed(e),this.errorPromise(e)}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}))}async reset(e=null){if(!(e=e||await salla.cart.getCurrentCartId())){let e="Unable to find cart id. Please provide one.";return salla.loyalty.event.resetFailed(e),this.errorPromise(e)}return this.request("reset",{cart_id:e}).then((e=>(salla.loyalty.event.resetSucceeded(e),e))).catch((e=>{throw salla.loyalty.event.resetFailed(e),e}))}}class L extends A{constructor(e){super(e),this.namespace="auth",this.canRedirect_=!0,this.endpoints={login:"auth/{type}/send_verification",resend:"auth/resend_verification",verify:"auth/{type}/verify",register:"auth/register",logout:"logout",refresh:"auth/refresh"},this.webEndpoints=["logout","auth/jwt","refresh"],this.endpointsMethods={logout:"get"},this.after_init()}setCanRedirect(e){salla.api.auth.canRedirect_=e}canRedirect(){return salla.api.auth.canRedirect_}login(e){e.data&&(e=e.data);let t=this.getPossibleValue(e,["type"]);if(!["email","mobile"].includes(t)){let e="Login type should be in: [email, mobile]";return salla.auth.event.codeNotSent(e),this.errorPromise(e)}return this.request(["login",t],e).then((function(e){return salla.auth.event.codeSent(e,t),e})).catch((function(e){throw salla.auth.event.codeNotSent(e,t),e}))}async verify(e,t=!0){let r=this.getPossibleValue(e,["type"]);if(!r){let e="Failed to know what's login type!";return salla.auth.event.verificationFailed(e),this.errorPromise(e)}t=!1!==this.getPossibleValue(e,["supportWebAuth"])&&t,salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event);let n=await this.request(["verify",r],e);return 200!==n?.status?(salla.auth.event.verificationFailed(n,r),this.errorPromise(n)):(t&&await this.request("auth/jwt"),"authenticated"===n.data?.case&&salla.auth.event.loggedIn(n),salla.auth.event.verified(n,r),this.successPromise(n))}resend(e){let 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),t})):(salla.auth.event.codeNotSent(t="There is no email!",e),this.errorPromise(t)):(salla.auth.event.codeNotSent(t="There is no phone or country_code!",e),this.errorPromise(t))}register(e){let t;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((function(e){return salla.auth.event.registered.call(t,e),"authenticated"===e.data?.case&&salla.auth.event.loggedIn(e),e})).catch((function(e){throw salla.auth.event.registrationFailed.call(t,e),e}))}logout(){return this.request("logout").then((function(e){return salla.auth.event.loggedOut(e),salla.log("Reloading after 0.1 sec..."),setTimeout((()=>location.reload()),100),e})).catch((function(e){throw salla.auth.event.failedLogout(e),e}))}refresh(){return this.request("refresh").catch((function(e){throw salla.auth.event.refreshFailed(e),e}))}}class O extends A{constructor(e){super(e),this.namespace="order",this.endpoints={cancel:"orders/cancel/{id}",createCartFromOrder:"reorder/{id}",sendInvoice:"orders/send/{id}"},this.endpointsMethods={createCartFromOrder:"get"},this.after_init()}show(e){let t=this.getPossibleValue(e?.data||e,["id","order_id"]);salla.event.dispatch("mobile::order.placed",{order_id:t}),location.href=this.getPossibleValue(e?.data||e,["url"])}cancel(e){return e=e||salla.config.get("page.id"),this.request(["cancel",e],{params:{has_apple_pay:!!window.ApplePaySession}}).then((function(t){return salla.event.order.canceled(t,e),t})).catch((function(t){throw salla.event.order.notCanceled(t,e),t}))}createCartFromOrder(e){return e=e||salla.config.get("page.id"),this.request(["createCartFromOrder",e]).then((function(t){return salla.storage.set("cart",{id:t.data.cart_id,user_id:salla.config.get("user.id")}),salla.event.order.orderCreated(t,e),window.location.href=t.data.url,t})).catch((function(t){throw salla.event.order.orderCreationFailed(t,e),t}))}sendInvoice(e){let t=this.getPossibleValue(e,["id"])||salla.config.get("page.id");if(!t||isNaN(t)){let e="There is no id!";return salla.order.event.invoiceNotSent(e),this.errorPromise(e)}return this.request(["sendInvoice",t],e).then((e=>(salla.event.order.invoiceSent(e,t),e))).catch((e=>{throw salla.event.order.invoiceNotSent(e,t),e}))}}class k extends A{constructor(e){super(e),this.namespace="product",this.previousQuery="",this.endpoints={getPrice:"products/{id}/price",availabilitySubscribe:"products/{id}/availability-notify",search:"products/search",categories:"products/categories/{?id}",purchaseNow:"checkout/quick-purchase/{id}",offers:"products/{product_id}/specialoffer",getSizeGuides:"products/{prod_id}/size-guides",giftDetail:"products/{product_id}/buy-as-gift",giftToCart:"products/{product_id}/buy-as-gift",giftImage:"products/buy-as-gift/image"},this.endpointsMethods={giftDetail:"get"},this.webEndpoints=["purchaseNow"],this.after_init()}getPrice(e){let t=e.data||e,r=this.getPossibleValue(t,["id","prod_id","product_id"]);return this.request(["getPrice",r],"object"==typeof t?t:void 0).then((function(e){return salla.product.event.priceUpdated(e,r),e})).catch((function(e){throw salla.product.event.priceUpdateFailed(e,r),e}))}categories(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}))}availabilitySubscribe(e){let t=e.data||e;return e=this.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.availabilitySubscribedFailed(t,e),t}))}search(e){let t=e.data;if(t||(t={params:"string"==typeof e?{query:e}:e}),!(e=t instanceof FormData?t.get("query"):t.query||t.params?.query)){let e='There is no "query"!';return salla.product.event.searchFailed(e),this.errorPromise(e)}if(e===salla.api.product.previousQuery){let e="Query is same as previous one!";return salla.product.event.searchFailed(e),salla.api.product.previousQuery=null,this.errorPromise(e)}return salla.api.product.previousQuery=e,this.request("search",t,"get").then((function(t){return salla.product.event.searchResults(t,e),t})).catch((function(t){throw salla.product.event.searchFailed(t,e),t}))}offers(e){if(!(e=this.getPossibleValue(e?.data|e,["product_id","id"]))){let e='There is no "product_id"!';return salla.offer.event.fetchDetailsFailed(e),this.errorPromise(e)}return this.request(["offers",e]).then((function(t){return salla.product.event.offersFetched(t,e),t})).catch((function(t){throw salla.product.event.fetchFffersFailed(t,e),t}))}purchaseNow(e){if(salla.config.isGuest())return salla.auth.event.dispatch("login");let t=e.product_data,r=this.getPossibleValue(t,["id","prod_id"]);if(!e.is_applepay)return this.request(["quickPurchase",r],"object"==typeof t?t:void 0).then((function(e){return e})).catch((function(e){throw e}));salla.event.dispatch("payments::apple-pay.start-transaction",{amount:e.total,currency:e.currency,requiredShippingContactFields:e.require_shipping?["postalAddress"]:null,shippingMethods:e.require_shipping?[]:null,supportedNetworks:e.applepay_supported_networks,validateMerchant:{url:baseUrl+"checkout/applepay/validate",onFailed:({response:e})=>{console.log("validateMerchant Failed!")},onSuccess:e=>(console.log("validateMerchant Success"),this.request(["quickPurchase",r],"object"==typeof t?t:void 0))},authorized:{url:baseUrl+"/checkout/{id}/payments/submit",onFailed:e=>{console.log("authorized Failed!"),window.Salla.Payments.ApplePay.onCancel({},e.data.error.message)},onSuccess:e=>{console.log(e),window.location.href=e.redirect.url,console.log("authorized Success:: redirect to thank you page, order placed")}},shippingMethodSelected:e.require_shipping?{url:baseUrl+"/checkout/{id}/shipping/details",onFailed:e=>{console.log("select shipping method failed!")},onSuccess:e=>{console.log("select shipping method success")}}:null,shippingContactSelected:e.require_shipping?{url:baseUrl+"/checkout/{id}/address/add",onFailed:e=>{console.log("created contact failed!")},onSuccess:e=>{console.log("created contact success : ",e.data.address_id)}}:null,recalculateTotal:{url:baseUrl+"/checkout/{id}/payments/recalculate"},onError:function(e){console.log(e),salla.notify.error(e)}})}getSizeGuides(e){return this.request(`products/${e}/size-guides`,null,"get").then((t=>(salla.product.event.sizeGuideFetched(t,e),t))).catch((t=>{throw salla.product.event.sizeGuideFetchFailed(t,e),t}))}getGiftDetails(e){return this.request(["giftDetail",e]).then((t=>(salla.product.event.giftFetched(t,e),t))).catch((t=>{throw salla.product.event.giftFetchFailed(t,e),t}))}addGiftToCart(e,t,r=!1){return this.request(["giftToCart",e],t).then((t=>(salla.product.event.addGiftToCartSucceeded(t,e),r&&(window.location.href=t.redirect),response))).catch((t=>{throw salla.product.event.addGiftToCartFailed(t,e),t}))}uploadGiftImage(e){return this.request("giftImage",e).then((e=>(salla.product.event.giftImageUploadSucceeded(e),e))).catch((e=>{throw salla.product.event.giftImageUploadFailed(e),e}))}}class T extends A{constructor(e){super(e),this.namespace="profile",this.endpoints={info:"auth/user",update:"profile/update",updateContacts:"profile/contacts/update",verify:"profile/verify"},this.after_init()}info(){return this.request("info",null,"get").then((e=>(salla.profile.event.infoFetched(e),e))).catch((e=>{throw salla.profile.event.infoNotFetched(e),e}))}update(e){return this.request("update",e).then((e=>(salla.profile.event.updated(e),e))).catch((e=>{throw salla.event.profile.updateFailed(e),e}))}updateContacts(e){return this.request("updateContacts",e).then((e=>(salla.profile.event.verificationCodeSent(e),e))).catch((e=>{throw salla.event.profile.updateContactsFailed(e),e}))}verify(e){return this.request("verify",e).then((e=>(salla.profile.event.verified(e),e))).catch((e=>{throw salla.event.profile.unVerified(e),e}))}}class j extends A{constructor(e){super(e),this.namespace="comment",this.endpoints={add:"{type}/{id}/comments"},this.after_init()}add(e){e?.data&&(e=e.data);let t,{id:r,type:n,comment:i}=Object.fromEntries(e);return r?n&&["products","pages","product","page"].includes(n)?i?(n+=["product","page"].includes(n)?"s":"",this.request(["add",n,r],{comment:i}).then((function(e){return salla.event.comment.added(e,r),e})).catch((function(e){throw salla.event.comment.additionFailed(e,r),e}))):(salla.event.comment.additionFailed(t="can't find comment content!"),this.errorPromise(t)):(salla.event.comment.additionFailed(t="Failed to get type one of:(products, product, page, pages)!"),this.errorPromise(t)):(salla.event.comment.additionFailed(t="Failed to get id!"),this.errorPromise(t))}}class C extends A{constructor(e){super(e),this.namespace="currency",this.endpoints={change:"/",list:"currencies"},this.endpointsMethods={change:"get",list:"get"},this.webEndpoints=["change"],this.after_init()}change(e){if(!(e=this.getPossibleValue(e.data||e,["currency","code"]))){let e="Can't find currency code!";return salla.currency.event.failed(e),this.errorPromise(e)}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}))}list(){return this.request("list").then((function(e){return salla.currency.event.fetched(e),e})).catch((function(e){throw salla.currency.event.failedToFetch(e),e}))}}class R extends A{constructor(e){super(e),this.namespace="document"}}class I extends A{constructor(e){super(e),this.namespace="rating",this.endpoints={store:"rating/store",products:"rating/products",shipping:"rating/shipping",order:"rating/{order_id}"},this.endpointsMethods={order:"get"},this.after_init()}order(e){let t="object"==typeof e?e:{},r=this.getPossibleValue(e?.data||e,["order_id","id"]);if(!r){let e='There is no "order_id"!';return salla.event.rating.orderNotFetched(e),this.errorPromise(e)}return this.request(["order",r],t).then((function(e){return salla.event.rating.orderFetched(e,r),e})).catch((function(e){throw salla.event.rating.orderNotFetched(e,r),e}))}store(e){if(!(e=e.data||e)){let e='There is no "data"!';return salla.event.rating.storeFailed(e),this.errorPromise(e)}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}))}products(e){if(!(e=e.data||e)){let e='There is no "data"!';return salla.event.rating.productsFailed(e),this.errorPromise(e)}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}))}shipping(e){if(!(e=e.data||e)){let e='There is no "data"!';return salla.event.rating.shippingFailed(e),this.errorPromise(e)}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}))}}class q{constructor(e){salla.config.merge(e),e?(e._token&&(salla.api.defaults.headers.common["X-CSRF-TOKEN"]=e._token),this.injectMaintenanceAlert(),this.injectThemePreviewAlert(),this.injectEditAlert(),e?.user?.language_code&&salla.lang.setLocale(e?.user?.language_code),salla.lang.loadStoreTranslations(),salla.twilight.event.initiated(e)):salla.twilight.event.initiated(e)}injectMaintenanceAlert(){salla.config.get("maintenance")&&(document.querySelector(".store-notify")?salla.logger.warn(".store-notify element Existed before!"):salla.lang.onLoaded((()=>{var e=document.createElement("div");e.classList.add("store-notify"),e.style="background-color: #d63031; color: #fff; padding: 10px 15px; text-align: center; font-size: 17px;",e.innerHTML=`<p style="margin:0 !important;">${salla.lang.get("blocks.header.maintenance_alert")}</p>`,document.body.prepend(e)})))}injectThemePreviewAlert(){"preview"===salla.config.get("theme.mode")&&(document.querySelector("#s-theme_preview_bar")?salla.logger.warn("#s-theme_preview_bar element Existed before!"):salla.lang.onLoaded((()=>{let 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://assets.salla.sa/cp/assets/images/logo-new.png">\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)})))}injectEditAlert(){let e=salla.config.get("edit");e&&(document.querySelector("#s-edit-alert")?salla.logger.warn("#s-edit-alert element Existed before!"):salla.lang.onLoaded((()=>{let 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)})))}handleElementAjaxRequest(e,t){if(!(t instanceof HTMLFormElement||t instanceof HTMLAnchorElement))return salla.logger.warn("trying to call ajax from non Element!!"),!1;e.preventDefault();let r=t.getAjaxFormData(e),n=r.method?r.method.toLowerCase():void 0;salla.api.document.request(r.url,r.formData,n).then((e=>(e.data&&e.request&&(e=e.data),salla.api.document.handleAfterResponseActions(e),this.callAjaxEvent(r.events.success,e,r.formData),e))).catch((e=>{throw salla.api.document.handleErrorResponse(e),this.callAjaxEvent(r.events.fail,e,r.formData),e}))}callAjaxEvent(e,t,r){if(e){if(r instanceof FormData){var n={};Array.from(r.entries()).forEach((function(e){n[e[0]]=e[1]})),r=n}window[e]?window[e](t,r):salla.event.dispatch(e,t,r)}}}class N extends A{constructor(e){super(e),this.namespace="twilight",this.after_init()}init(e){let t=e?.events;return salla.isInitiated||(delete e.events,new q(e),salla.isInitiated=!0),t&&salla.event.dispatchEvents(t),this.successPromise(e)}api(e){let t=e?.events;return t&&salla.event.dispatchEvents(t),this.successPromise(e)}}class D extends A{constructor(e){super(e),this.namespace="wishlist",this.endpoints={add:"products/favorites/{id}",remove:"products/favorites/{id}"},this.endpointsMethods={remove:"delete"},this.after_init()}toggle(e){return salla.storage.get("salla::wishlist",[]).includes(e)?this.remove(e):this.add(e)}add(e){let t;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(t=salla.lang.get("common.messages.must_login")),salla.error(t),this.errorPromise(t)):(e=this.getPossibleValue(e?.data||e,["product_id","id"]))?this.request(["add",e]).then((t=>(this.updateWishlistStorage(e),salla.wishlist.event.added(t,e),t))).catch((function(t){throw salla.wishlist.event.additionFailed(t,e),t})):(salla.wishlist.event.additionFailed(t="Failed to get product id!"),this.errorPromise(t))}remove(e){let t;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(t=salla.lang.get("common.messages.must_login")),salla.error(t),this.errorPromise(t)):(e=this.getPossibleValue(e?.data||e,["product_id","id"]))?this.request(["remove",e]).then((t=>(this.updateWishlistStorage(e,!1),salla.wishlist.event.removed(t,e),t))).catch((function(t){throw salla.wishlist.event.removingFailed(t,e),t})):(salla.wishlist.event.removingFailed(t="Failed to get id!"),this.errorPromise(t))}updateWishlistStorage(e,t=!0){let r=salla.storage.get("salla::wishlist",[]);t?r.push(e):r.splice(r.indexOf(e),1),salla.storage.set("salla::wishlist",r)}}class U extends A{constructor(e){super(e),this.namespace="scopes",this.endpoints={get:"scopes",change:"scopes",getProductAvailability:"scopes/availability?product_id={id}"},this.after_init()}get(){return this.request("scopes",null,"get").then((e=>(salla.scope.event.fetched(e),e))).catch((e=>{throw salla.scope.event.notFetched(e),e}))}change(e){return this.request("scopes",e).then((e=>(salla.scope.event.changeSucceeded(e),e))).catch((e=>{throw salla.scope.event.changeFailed(e),e}))}getProductAvailability(e=null){return this.request(`scopes/availability?product_id=${e}`,null,"get").then((t=>(salla.scope.event.productAvailabilityFetched(t,e),t))).catch((e=>{throw salla.scope.event.productAvailabilityNotFetched(e),resp}))}}var M,$={exports:{}},z={exports:{}},H=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}},B=H,G=Object.prototype.toString,V=(M=Object.create(null),function(e){var t=G.call(e);return M[t]||(M[t]=t.slice(8,-1).toLowerCase())});function W(e){return e=e.toLowerCase(),function(t){return V(t)===e}}function J(e){return Array.isArray(e)}function Q(e){return void 0===e}var K=W("ArrayBuffer");function Y(e){return null!==e&&"object"==typeof e}function Z(e){if("object"!==V(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}var X=W("Date"),ee=W("File"),te=W("Blob"),re=W("FileList");function ne(e){return"[object Function]"===G.call(e)}var ie=W("URLSearchParams");function se(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),J(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}var ae,oe=(ae="undefined"!=typeof Uint8Array&&Object.getPrototypeOf(Uint8Array),function(e){return ae&&e instanceof ae}),le={isArray:J,isArrayBuffer:K,isBuffer:function(e){return null!==e&&!Q(e)&&null!==e.constructor&&!Q(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){var t="[object FormData]";return e&&("function"==typeof FormData&&e instanceof FormData||G.call(e)===t||ne(e.toString)&&e.toString()===t)},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&K(e.buffer)},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:Y,isPlainObject:Z,isUndefined:Q,isDate:X,isFile:ee,isBlob:te,isFunction:ne,isStream:function(e){return Y(e)&&ne(e.pipe)},isURLSearchParams:ie,isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:se,merge:function e(){var t={};function r(r,n){Z(t[n])&&Z(r)?t[n]=e(t[n],r):Z(r)?t[n]=e({},r):J(r)?t[n]=r.slice():t[n]=r}for(var n=0,i=arguments.length;n<i;n++)se(arguments[n],r);return t},extend:function(e,t,r){return se(t,(function(t,n){e[n]=r&&"function"==typeof t?B(t,r):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e},inherits:function(e,t,r,n){e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,r&&Object.assign(e.prototype,r)},toFlatObject:function(e,t,r){var n,i,s,a={};t=t||{};do{for(i=(n=Object.getOwnPropertyNames(e)).length;i-- >0;)a[s=n[i]]||(t[s]=e[s],a[s]=!0);e=Object.getPrototypeOf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:V,kindOfTest:W,endsWith:function(e,t,r){e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;var n=e.indexOf(t,r);return-1!==n&&n===r},toArray:function(e){if(!e)return null;var t=e.length;if(Q(t))return null;for(var r=new Array(t);t-- >0;)r[t]=e[t];return r},isTypedArray:oe,isFileList:re},ce=le;function ue(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var he=function(e,t,r){if(!t)return e;var n;if(r)n=r(t);else if(ce.isURLSearchParams(t))n=t.toString();else{var i=[];ce.forEach(t,(function(e,t){null!=e&&(ce.isArray(e)?t+="[]":e=[e],ce.forEach(e,(function(e){ce.isDate(e)?e=e.toISOString():ce.isObject(e)&&(e=JSON.stringify(e)),i.push(ue(t)+"="+ue(e))})))})),n=i.join("&")}if(n){var s=e.indexOf("#");-1!==s&&(e=e.slice(0,s)),e+=(-1===e.indexOf("?")?"?":"&")+n}return e},de=le;function fe(){this.handlers=[]}fe.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},fe.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},fe.prototype.forEach=function(e){de.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var pe,ge,me=fe,ve=le;function ye(){if(ge)return pe;ge=1;var e=le;function t(e,t,r,n,i){Error.call(this),this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i)}e.inherits(t,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var r=t.prototype,n={};return["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED"].forEach((function(e){n[e]={value:e}})),Object.defineProperties(t,n),Object.defineProperty(r,"isAxiosError",{value:!0}),t.from=function(n,i,s,a,o,l){var c=Object.create(r);return e.toFlatObject(n,c,(function(e){return e!==Error.prototype})),t.call(c,n.message,i,s,a,o),c.name=n.name,l&&Object.assign(c,l),c},pe=t}var be,we,_e,Ee,Se,xe,Ae={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};function Pe(){if(we)return be;we=1;var e=le;return be=function(t,r){r=r||new FormData;var n=[];function i(t){return null===t?"":e.isDate(t)?t.toISOString():e.isArrayBuffer(t)||e.isTypedArray(t)?"function"==typeof Blob?new Blob([t]):Buffer.from(t):t}return function t(s,a){if(e.isPlainObject(s)||e.isArray(s)){if(-1!==n.indexOf(s))throw Error("Circular reference detected in "+a);n.push(s),e.forEach(s,(function(n,s){if(!e.isUndefined(n)){var o,l=a?a+"."+s:s;if(n&&!a&&"object"==typeof n)if(e.endsWith(s,"{}"))n=JSON.stringify(n);else if(e.endsWith(s,"[]")&&(o=e.toArray(n)))return void o.forEach((function(t){!e.isUndefined(t)&&r.append(l,i(t))}));t(n,l)}})),n.pop()}else r.append(a,i(s))}(t),r},be}function Fe(){if(Ee)return _e;Ee=1;var e=ye();return _e=function(t,r,n){var i=n.config.validateStatus;n.status&&i&&!i(n.status)?r(new e("Request failed with status code "+n.status,[e.ERR_BAD_REQUEST,e.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):t(n)}}function Le(){if(xe)return Se;xe=1;var e=le;return Se=e.isStandardBrowserEnv()?{write:function(t,r,n,i,s,a){var o=[];o.push(t+"="+encodeURIComponent(r)),e.isNumber(n)&&o.push("expires="+new Date(n).toGMTString()),e.isString(i)&&o.push("path="+i),e.isString(s)&&o.push("domain="+s),!0===a&&o.push("secure"),document.cookie=o.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}}var Oe,ke,Te,je,Ce,Re,Ie,qe,Ne,De,Ue,Me,$e=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},ze=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},He=function(e,t){return e&&!$e(t)?ze(e,t):t};function Be(){if(ke)return Oe;ke=1;var e=le,t=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];return Oe=function(r){var n,i,s,a={};return r?(e.forEach(r.split("\n"),(function(r){if(s=r.indexOf(":"),n=e.trim(r.substr(0,s)).toLowerCase(),i=e.trim(r.substr(s+1)),n){if(a[n]&&t.indexOf(n)>=0)return;a[n]="set-cookie"===n?(a[n]?a[n]:[]).concat([i]):a[n]?a[n]+", "+i:i}})),a):a}}function Ge(){if(je)return Te;je=1;var e=le;return Te=e.isStandardBrowserEnv()?function(){var t,r=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function i(e){var t=e;return r&&(n.setAttribute("href",t),t=n.href),n.setAttribute("href",t),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return t=i(window.location.href),function(r){var n=e.isString(r)?i(r):r;return n.protocol===t.protocol&&n.host===t.host}}():function(){return!0},Te}function Ve(){if(Re)return Ce;Re=1;var e=ye();function t(t){e.call(this,null==t?"canceled":t,e.ERR_CANCELED),this.name="CanceledError"}return le.inherits(t,e,{__CANCEL__:!0}),Ce=t}function We(){return qe||(qe=1,Ie=function(e){var t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}),Ie}function Je(){if(De)return Ne;De=1;var e=le,t=Fe(),r=Le(),n=he,i=He,s=Be(),a=Ge(),o=Ae,l=ye(),c=Ve(),u=We();return Ne=function(h){return new Promise((function(d,f){var p,g=h.data,m=h.headers,v=h.responseType;function y(){h.cancelToken&&h.cancelToken.unsubscribe(p),h.signal&&h.signal.removeEventListener("abort",p)}e.isFormData(g)&&e.isStandardBrowserEnv()&&delete m["Content-Type"];var b=new XMLHttpRequest;if(h.auth){var w=h.auth.username||"",_=h.auth.password?unescape(encodeURIComponent(h.auth.password)):"";m.Authorization="Basic "+btoa(w+":"+_)}var E=i(h.baseURL,h.url);function S(){if(b){var e="getAllResponseHeaders"in b?s(b.getAllResponseHeaders()):null,r={data:v&&"text"!==v&&"json"!==v?b.response:b.responseText,status:b.status,statusText:b.statusText,headers:e,config:h,request:b};t((function(e){d(e),y()}),(function(e){f(e),y()}),r),b=null}}if(b.open(h.method.toUpperCase(),n(E,h.params,h.paramsSerializer),!0),b.timeout=h.timeout,"onloadend"in b?b.onloadend=S:b.onreadystatechange=function(){b&&4===b.readyState&&(0!==b.status||b.responseURL&&0===b.responseURL.indexOf("file:"))&&setTimeout(S)},b.onabort=function(){b&&(f(new l("Request aborted",l.ECONNABORTED,h,b)),b=null)},b.onerror=function(){f(new l("Network Error",l.ERR_NETWORK,h,b,b)),b=null},b.ontimeout=function(){var e=h.timeout?"timeout of "+h.timeout+"ms exceeded":"timeout exceeded",t=h.transitional||o;h.timeoutErrorMessage&&(e=h.timeoutErrorMessage),f(new l(e,t.clarifyTimeoutError?l.ETIMEDOUT:l.ECONNABORTED,h,b)),b=null},e.isStandardBrowserEnv()){var x=(h.withCredentials||a(E))&&h.xsrfCookieName?r.read(h.xsrfCookieName):void 0;x&&(m[h.xsrfHeaderName]=x)}"setRequestHeader"in b&&e.forEach(m,(function(e,t){void 0===g&&"content-type"===t.toLowerCase()?delete m[t]:b.setRequestHeader(t,e)})),e.isUndefined(h.withCredentials)||(b.withCredentials=!!h.withCredentials),v&&"json"!==v&&(b.responseType=h.responseType),"function"==typeof h.onDownloadProgress&&b.addEventListener("progress",h.onDownloadProgress),"function"==typeof h.onUploadProgress&&b.upload&&b.upload.addEventListener("progress",h.onUploadProgress),(h.cancelToken||h.signal)&&(p=function(e){b&&(f(!e||e&&e.type?new c:e),b.abort(),b=null)},h.cancelToken&&h.cancelToken.subscribe(p),h.signal&&(h.signal.aborted?p():h.signal.addEventListener("abort",p))),g||(g=null);var A=u(E);A&&-1===["http","https","file"].indexOf(A)?f(new l("Unsupported protocol "+A+":",l.ERR_BAD_REQUEST,h)):b.send(g)}))},Ne}var Qe=le,Ke=function(e,t){ve.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))},Ye=ye(),Ze=Ae,Xe=Pe(),et={"Content-Type":"application/x-www-form-urlencoded"};function tt(e,t){!Qe.isUndefined(e)&&Qe.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var rt,nt={transitional:Ze,adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(rt=Je()),rt),transformRequest:[function(e,t){if(Ke(t,"Accept"),Ke(t,"Content-Type"),Qe.isFormData(e)||Qe.isArrayBuffer(e)||Qe.isBuffer(e)||Qe.isStream(e)||Qe.isFile(e)||Qe.isBlob(e))return e;if(Qe.isArrayBufferView(e))return e.buffer;if(Qe.isURLSearchParams(e))return tt(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString();var r,n=Qe.isObject(e),i=t&&t["Content-Type"];if((r=Qe.isFileList(e))||n&&"multipart/form-data"===i){var s=this.env&&this.env.FormData;return Xe(r?{"files[]":e}:e,s&&new s)}return n||"application/json"===i?(tt(t,"application/json"),function(e,t,r){if(Qe.isString(e))try{return(t||JSON.parse)(e),Qe.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||nt.transitional,r=t&&t.silentJSONParsing,n=t&&t.forcedJSONParsing,i=!r&&"json"===this.responseType;if(i||n&&Qe.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(i){if("SyntaxError"===e.name)throw Ye.from(e,Ye.ERR_BAD_RESPONSE,this,null,this.response);throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Me?Ue:(Me=1,Ue=null)},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};Qe.forEach(["delete","get","head"],(function(e){nt.headers[e]={}})),Qe.forEach(["post","put","patch"],(function(e){nt.headers[e]=Qe.merge(et)}));var it,st,at=nt,ot=le,lt=at;function ct(){return st?it:(st=1,it=function(e){return!(!e||!e.__CANCEL__)})}var ut=le,ht=function(e,t,r){var n=this||lt;return ot.forEach(r,(function(r){e=r.call(n,e,t)})),e},dt=ct(),ft=at,pt=Ve();function gt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new pt}var mt,vt,yt=le,bt=function(e,t){t=t||{};var r={};function n(e,t){return yt.isPlainObject(e)&&yt.isPlainObject(t)?yt.merge(e,t):yt.isPlainObject(t)?yt.merge({},t):yt.isArray(t)?t.slice():t}function i(r){return yt.isUndefined(t[r])?yt.isUndefined(e[r])?void 0:n(void 0,e[r]):n(e[r],t[r])}function s(e){if(!yt.isUndefined(t[e]))return n(void 0,t[e])}function a(r){return yt.isUndefined(t[r])?yt.isUndefined(e[r])?void 0:n(void 0,e[r]):n(void 0,t[r])}function o(r){return r in t?n(e[r],t[r]):r in e?n(void 0,e[r]):void 0}var l={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:o};return yt.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=l[e]||i,n=t(e);yt.isUndefined(n)&&t!==o||(r[e]=n)})),r};function wt(){return vt?mt:(vt=1,mt={version:"0.27.2"})}var _t=wt().version,Et=ye(),St={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){St[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var xt={};St.transitional=function(e,t,r){function n(e,t){return"[Axios v"+_t+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return function(r,i,s){if(!1===e)throw new Et(n(i," has been removed"+(t?" in "+t:"")),Et.ERR_DEPRECATED);return t&&!xt[i]&&(xt[i]=!0,console.warn(n(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,i,s)}};var At,Pt,Ft,Lt,Ot,kt,Tt={assertOptions:function(e,t,r){if("object"!=typeof e)throw new Et("options must be an object",Et.ERR_BAD_OPTION_VALUE);for(var n=Object.keys(e),i=n.length;i-- >0;){var s=n[i],a=t[s];if(a){var o=e[s],l=void 0===o||a(o,s,e);if(!0!==l)throw new Et("option "+s+" must be "+l,Et.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new Et("Unknown option "+s,Et.ERR_BAD_OPTION)}},validators:St},jt=le,Ct=he,Rt=me,It=function(e){return gt(e),e.headers=e.headers||{},e.data=ht.call(e,e.data,e.headers,e.transformRequest),e.headers=ut.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),ut.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||ft.adapter)(e).then((function(t){return gt(e),t.data=ht.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return dt(t)||(gt(e),t&&t.response&&(t.response.data=ht.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},qt=bt,Nt=He,Dt=Tt,Ut=Dt.validators;function Mt(e){this.defaults=e,this.interceptors={request:new Rt,response:new Rt}}Mt.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=qt(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var r=t.transitional;void 0!==r&&Dt.assertOptions(r,{silentJSONParsing:Ut.transitional(Ut.boolean),forcedJSONParsing:Ut.transitional(Ut.boolean),clarifyTimeoutError:Ut.transitional(Ut.boolean)},!1);var n=[],i=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(i=i&&e.synchronous,n.unshift(e.fulfilled,e.rejected))}));var s,a=[];if(this.interceptors.response.forEach((function(e){a.push(e.fulfilled,e.rejected)})),!i){var o=[It,void 0];for(Array.prototype.unshift.apply(o,n),o=o.concat(a),s=Promise.resolve(t);o.length;)s=s.then(o.shift(),o.shift());return s}for(var l=t;n.length;){var c=n.shift(),u=n.shift();try{l=c(l)}catch(e){u(e);break}}try{s=It(l)}catch(e){return Promise.reject(e)}for(;a.length;)s=s.then(a.shift(),a.shift());return s},Mt.prototype.getUri=function(e){e=qt(this.defaults,e);var t=Nt(e.baseURL,e.url);return Ct(t,e.params,e.paramsSerializer)},jt.forEach(["delete","get","head","options"],(function(e){Mt.prototype[e]=function(t,r){return this.request(qt(r||{},{method:e,url:t,data:(r||{}).data}))}})),jt.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,i){return this.request(qt(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}Mt.prototype[e]=t(),Mt.prototype[e+"Form"]=t(!0)}));var $t=le,zt=H,Ht=Mt,Bt=bt;var Gt=function e(t){var r=new Ht(t),n=zt(Ht.prototype.request,r);return $t.extend(n,Ht.prototype,r),$t.extend(n,r),n.create=function(r){return e(Bt(t,r))},n}(at);Gt.Axios=Ht,Gt.CanceledError=Ve(),Gt.CancelToken=function(){if(Pt)return At;Pt=1;var e=Ve();function t(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var r;this.promise=new Promise((function(e){r=e}));var n=this;this.promise.then((function(e){if(n._listeners){var t,r=n._listeners.length;for(t=0;t<r;t++)n._listeners[t](e);n._listeners=null}})),this.promise.then=function(e){var t,r=new Promise((function(e){n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},t((function(t){n.reason||(n.reason=new e(t),r(n.reason))}))}return t.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},t.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},t.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},t.source=function(){var e;return{token:new t((function(t){e=t})),cancel:e}},At=t}(),Gt.isCancel=ct(),Gt.VERSION=wt().version,Gt.toFormData=Pe(),Gt.AxiosError=ye(),Gt.Cancel=Gt.CanceledError,Gt.all=function(e){return Promise.all(e)},Gt.spread=Lt?Ft:(Lt=1,Ft=function(e){return function(t){return e.apply(null,t)}}),Gt.isAxiosError=function(){if(kt)return Ot;kt=1;var e=le;return Ot=function(t){return e.isObject(t)&&!0===t.isAxiosError}}(),z.exports=Gt,z.exports.default=Gt,function(e){e.exports=z.exports}($);var Vt=_($.exports);function Wt(e){this.message=e}Wt.prototype=new Error,Wt.prototype.name="InvalidCharacterError";var Jt="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new Wt("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,i=0,s=0,a="";n=t.charAt(s++);~n&&(r=i%4?64*r+n:n,i++%4)?a+=String.fromCharCode(255&r>>(-2*i&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};function Qt(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(Jt(e).replace(/(.)/g,(function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(t)}catch(e){return Jt(t)}}function Kt(e){this.message=e}Kt.prototype=new Error,Kt.prototype.name="InvalidTokenError";class Yt{constructor(e,t){return this.api=e,this.event=t,new Proxy(this,{get:function(r,n){return"event"===n?t:"api"===n&&"twilight"!==e?.namespace?e:e&&e[n]||r[n]}})}}var Zt,Xt={exports:{}},er={exports:{}},tr={exports:{}};function rr(){return Zt||(Zt=1,function(e){!function(t,r){e.exports?e.exports=r():t.EvEmitter=r()}("undefined"!=typeof window?window:w,(function(){function e(){}let t=e.prototype;return t.on=function(e,t){if(!e||!t)return this;let r=this._events=this._events||{},n=r[e]=r[e]||[];return n.includes(t)||n.push(t),this},t.once=function(e,t){if(!e||!t)return this;this.on(e,t);let r=this._onceEvents=this._onceEvents||{};return(r[e]=r[e]||{})[t]=!0,this},t.off=function(e,t){let r=this._events&&this._events[e];if(!r||!r.length)return this;let n=r.indexOf(t);return-1!=n&&r.splice(n,1),this},t.emitEvent=function(e,t){let r=this._events&&this._events[e];if(!r||!r.length)return this;r=r.slice(0),t=t||[];let n=this._onceEvents&&this._onceEvents[e];for(let i of r){n&&n[i]&&(this.off(e,i),delete n[i]),i.apply(this,t)}return this},t.allOff=function(){return delete this._events,delete this._onceEvents,this},e}))}(tr)),tr.exports}var nr,ir,sr={exports:{}};function ar(){return nr||(nr=1,function(e){!function(t,r){e.exports?e.exports=r(t):t.fizzyUIUtils=r(t)}(w,(function(e){let t={extend:function(e,t){return Object.assign(e,t)},modulo:function(e,t){return(e%t+t)%t},makeArray:function(e){if(Array.isArray(e))return e;if(null==e)return[];return"object"==typeof e&&"number"==typeof e.length?[...e]:[e]},removeFrom:function(e,t){let r=e.indexOf(t);-1!=r&&e.splice(r,1)},getParent:function(e,t){for(;e.parentNode&&e!=document.body;)if((e=e.parentNode).matches(t))return e},getQueryElement:function(e){return"string"==typeof e?document.querySelector(e):e},handleEvent:function(e){let t="on"+e.type;this[t]&&this[t](e)},filterFindElements:function(e,r){return(e=t.makeArray(e)).filter((e=>e instanceof HTMLElement)).reduce(((e,t)=>{if(!r)return e.push(t),e;t.matches(r)&&e.push(t);let n=t.querySelectorAll(r);return e=e.concat(...n)}),[])},debounceMethod:function(e,t,r){r=r||100;let n=e.prototype[t],i=t+"Timeout";e.prototype[t]=function(){clearTimeout(this[i]);let e=arguments;this[i]=setTimeout((()=>{n.apply(this,e),delete this[i]}),r)}},docReady:function(e){let t=document.readyState;"complete"==t||"interactive"==t?setTimeout(e):document.addEventListener("DOMContentLoaded",e)},toDashed:function(e){return e.replace(/(.)([A-Z])/g,(function(e,t,r){return t+"-"+r})).toLowerCase()}},r=e.console;return t.htmlInit=function(n,i){t.docReady((function(){let s="data-"+t.toDashed(i),a=document.querySelectorAll(`[${s}]`),o=e.jQuery;[...a].forEach((e=>{let t,a=e.getAttribute(s);try{t=a&&JSON.parse(a)}catch(t){return void(r&&r.error(`Error parsing ${s} on ${e.className}: ${t}`))}let l=new n(e,t);o&&o.data(e,i,l)}))}))},t}))}(sr)),sr.exports}function or(){return ir||(ir=1,function(e){!function(t,r){e.exports?e.exports=r(t,rr(),ar()):t.InfiniteScroll=r(t,t.EvEmitter,t.fizzyUIUtils)}(window,(function(e,t,r){let n=e.jQuery,i={};function s(e,t){let a=r.getQueryElement(e);if(a){if((e=a).infiniteScrollGUID){let r=i[e.infiniteScrollGUID];return r.option(t),r}this.element=e,this.options={...s.defaults},this.option(t),n&&(this.$element=n(this.element)),this.create()}else console.error("Bad element for InfiniteScroll: "+(a||e))}s.defaults={},s.create={},s.destroy={};let a=s.prototype;Object.assign(a,t.prototype);let o=0;a.create=function(){let e=this.guid=++o;if(this.element.infiniteScrollGUID=e,i[e]=this,this.pageIndex=1,this.loadCount=0,this.updateGetPath(),this.getPath&&this.getPath()){this.updateGetAbsolutePath(),this.log("initialized",[this.element.className]),this.callOnInit();for(let e in s.create)s.create[e].call(this)}else console.error("Disabling InfiniteScroll")},a.option=function(e){Object.assign(this.options,e)},a.callOnInit=function(){let e=this.options.onInit;e&&e.call(this,this)},a.dispatchEvent=function(e,t,r){this.log(e,r);let i=t?[t].concat(r):r;if(this.emitEvent(e,i),!n||!this.$element)return;let s=e+=".infiniteScroll";if(t){let r=n.Event(t);r.type=e,s=r}this.$element.trigger(s,r)};let l={initialized:e=>`on ${e}`,request:e=>`URL: ${e}`,load:(e,t)=>`${e.title||""}. URL: ${t}`,error:(e,t)=>`${e}. URL: ${t}`,append:(e,t,r)=>`${r.length} items. URL: ${t}`,last:(e,t)=>`URL: ${t}`,history:(e,t)=>`URL: ${t}`,pageIndex:function(e,t){return`current page determined to be: ${e} from ${t}`}};a.log=function(e,t){if(!this.options.debug)return;let r=`[InfiniteScroll] ${e}`,n=l[e];n&&(r+=". "+n.apply(this,t)),console.log(r)},a.updateMeasurements=function(){this.windowHeight=e.innerHeight;let t=this.element.getBoundingClientRect();this.top=t.top+e.scrollY},a.updateScroller=function(){let t=this.options.elementScroll;if(t){if(this.scroller=!0===t?this.element:r.getQueryElement(t),!this.scroller)throw new Error(`Unable to find elementScroll: ${t}`)}else this.scroller=e},a.updateGetPath=function(){let e=this.options.path;if(!e)return void console.error(`InfiniteScroll path option required. Set as: ${e}`);let t=typeof e;"function"!=t?"string"==t&&e.match("{{#}}")?this.updateGetPathTemplate(e):this.updateGetPathSelector(e):this.getPath=e},a.updateGetPathTemplate=function(e){this.getPath=()=>{let t=this.pageIndex+1;return e.replace("{{#}}",t)};let t=e.replace(/(\\\?|\?)/,"\\?").replace("{{#}}","(\\d\\d?\\d?)"),r=new RegExp(t),n=location.href.match(r);n&&(this.pageIndex=parseInt(n[1],10),this.log("pageIndex",[this.pageIndex,"template string"]))};let c=[/^(.*?\/?page\/?)(\d\d?\d?)(.*?$)/,/^(.*?\/?\?page=)(\d\d?\d?)(.*?$)/,/(.*?)(\d\d?\d?)(?!.*\d)(.*?$)/],u=s.getPathParts=function(e){if(e)for(let t of c){let r=e.match(t);if(r){let[,e,t,n]=r;return{begin:e,index:t,end:n}}}};a.updateGetPathSelector=function(e){let t=document.querySelector(e);if(!t)return void console.error(`Bad InfiniteScroll path option. Next link not found: ${e}`);let r=t.getAttribute("href"),n=u(r);if(!n)return void console.error(`InfiniteScroll unable to parse next link href: ${r}`);let{begin:i,index:s,end:a}=n;this.isPathSelector=!0,this.getPath=()=>i+(this.pageIndex+1)+a,this.pageIndex=parseInt(s,10)-1,this.log("pageIndex",[this.pageIndex,"next link"])},a.updateGetAbsolutePath=function(){let e=this.getPath();if(e.match(/^http/)||e.match(/^\//))return void(this.getAbsolutePath=this.getPath);let{pathname:t}=location,r=e.match(/^\?/),n=t.substring(0,t.lastIndexOf("/")),i=r?t:n+"/";this.getAbsolutePath=()=>i+this.getPath()},s.create.hideNav=function(){let e=r.getQueryElement(this.options.hideNav);e&&(e.style.display="none",this.nav=e)},s.destroy.hideNav=function(){this.nav&&(this.nav.style.display="")},a.destroy=function(){this.allOff();for(let e in s.destroy)s.destroy[e].call(this);delete this.element.infiniteScrollGUID,delete i[this.guid],n&&this.$element&&n.removeData(this.element,"infiniteScroll")},s.throttle=function(e,t){let r,n;return t=t||200,function(){let i=+new Date,s=arguments,a=()=>{r=i,e.apply(this,s)};r&&i<r+t?(clearTimeout(n),n=setTimeout(a,t)):a()}},s.data=function(e){let t=(e=r.getQueryElement(e))&&e.infiniteScrollGUID;return t&&i[t]},s.setJQuery=function(e){n=e},r.htmlInit(s,"infinite-scroll"),a._init=function(){};let{jQueryBridget:h}=e;return n&&h&&h("infiniteScroll",s,n),s}))}(er)),er.exports}var lr,cr={exports:{}};function ur(){return lr||(lr=1,function(e){!function(t,r){e.exports?e.exports=r(t,or()):r(t,t.InfiniteScroll)}(window,(function(e,t){let r=t.prototype;Object.assign(t.defaults,{loadOnScroll:!0,checkLastPage:!0,responseBody:"text",domParseResponse:!0}),t.create.pageLoad=function(){this.canLoad=!0,this.on("scrollThreshold",this.onScrollThresholdLoad),this.on("load",this.checkLastPage),this.options.outlayer&&this.on("append",this.onAppendOutlayer)},r.onScrollThresholdLoad=function(){this.options.loadOnScroll&&this.loadNextPage()};let n=new DOMParser;function i(e){let t=document.createDocumentFragment();return e&&t.append(...e),t}return r.loadNextPage=function(){if(this.isLoading||!this.canLoad)return;let{responseBody:e,domParseResponse:t,fetchOptions:r}=this.options,i=this.getAbsolutePath();this.isLoading=!0,"function"==typeof r&&(r=r());let s=fetch(i,r).then((r=>{if(!r.ok){let e=new Error(r.statusText);return this.onPageError(e,i,r),{response:r}}return r[e]().then((s=>("text"==e&&t&&(s=n.parseFromString(s,"text/html")),204==r.status?(this.lastPageReached(s,i),{body:s,response:r}):this.onPageLoad(s,i,r))))})).catch((e=>{this.onPageError(e,i)}));return this.dispatchEvent("request",null,[i,s]),s},r.onPageLoad=function(e,t,r){return this.options.append||(this.isLoading=!1),this.pageIndex++,this.loadCount++,this.dispatchEvent("load",null,[e,t,r]),this.appendNextPage(e,t,r)},r.appendNextPage=function(e,t,r){let{append:n,responseBody:s,domParseResponse:a}=this.options;if(!("text"==s&&a)||!n)return{body:e,response:r};let o=e.querySelectorAll(n),l={body:e,response:r,items:o};if(!o||!o.length)return this.lastPageReached(e,t),l;let c=i(o),u=()=>(this.appendItems(o,c),this.isLoading=!1,this.dispatchEvent("append",null,[e,t,o,r]),l);return this.options.outlayer?this.appendOutlayerItems(c,u):u()},r.appendItems=function(e,t){e&&e.length&&(function(e){let t=e.querySelectorAll("script");for(let e of t){let t=document.createElement("script"),r=e.attributes;for(let e of r)t.setAttribute(e.name,e.value);t.innerHTML=e.innerHTML,e.parentNode.replaceChild(t,e)}}(t=t||i(e)),this.element.appendChild(t))},r.appendOutlayerItems=function(r,n){let i=t.imagesLoaded||e.imagesLoaded;return i?new Promise((function(e){i(r,(function(){let t=n();e(t)}))})):(console.error("[InfiniteScroll] imagesLoaded required for outlayer option"),void(this.isLoading=!1))},r.onAppendOutlayer=function(e,t,r){this.options.outlayer.appended(r)},r.checkLastPage=function(e,t){let r,{checkLastPage:n,path:i}=this.options;if(n){if("function"==typeof i){if(!this.getPath())return void this.lastPageReached(e,t)}"string"==typeof n?r=n:this.isPathSelector&&(r=i),r&&e.querySelector&&(e.querySelector(r)||this.lastPageReached(e,t))}},r.lastPageReached=function(e,t){this.canLoad=!1,this.dispatchEvent("last",null,[e,t])},r.onPageError=function(e,t,r){return this.isLoading=!1,this.canLoad=!1,this.dispatchEvent("error",null,[e,t,r]),e},t.create.prefill=function(){if(!this.options.prefill)return;let e=this.options.append;e?(this.updateMeasurements(),this.updateScroller(),this.isPrefilling=!0,this.on("append",this.prefill),this.once("error",this.stopPrefill),this.once("last",this.stopPrefill),this.prefill()):console.error(`append option required for prefill. Set as :${e}`)},r.prefill=function(){let e=this.getPrefillDistance();this.isPrefilling=e>=0,this.isPrefilling?(this.log("prefill"),this.loadNextPage()):this.stopPrefill()},r.getPrefillDistance=function(){return this.options.elementScroll?this.scroller.clientHeight-this.scroller.scrollHeight:this.windowHeight-this.element.clientHeight},r.stopPrefill=function(){this.log("stopPrefill"),this.off("append",this.prefill)},t}))}(cr)),cr.exports}var hr,dr={exports:{}};function fr(){return hr||(hr=1,function(e){!function(t,r){e.exports?e.exports=r(t,or(),ar()):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){let n=t.prototype;return Object.assign(t.defaults,{scrollThreshold:400}),t.create.scrollWatch=function(){this.pageScrollHandler=this.onPageScroll.bind(this),this.resizeHandler=this.onResize.bind(this);let e=this.options.scrollThreshold;(e||0===e)&&this.enableScrollWatch()},t.destroy.scrollWatch=function(){this.disableScrollWatch()},n.enableScrollWatch=function(){this.isScrollWatching||(this.isScrollWatching=!0,this.updateMeasurements(),this.updateScroller(),this.on("last",this.disableScrollWatch),this.bindScrollWatchEvents(!0))},n.disableScrollWatch=function(){this.isScrollWatching&&(this.bindScrollWatchEvents(!1),delete this.isScrollWatching)},n.bindScrollWatchEvents=function(t){let r=t?"addEventListener":"removeEventListener";this.scroller[r]("scroll",this.pageScrollHandler),e[r]("resize",this.resizeHandler)},n.onPageScroll=t.throttle((function(){this.getBottomDistance()<=this.options.scrollThreshold&&this.dispatchEvent("scrollThreshold")})),n.getBottomDistance=function(){let t,r;return this.options.elementScroll?(t=this.scroller.scrollHeight,r=this.scroller.scrollTop+this.scroller.clientHeight):(t=this.top+this.element.clientHeight,r=e.scrollY+this.windowHeight),t-r},n.onResize=function(){this.updateMeasurements()},r.debounceMethod(t,"onResize",150),t}))}(dr)),dr.exports}var pr,gr={exports:{}};function mr(){return pr||(pr=1,function(e){!function(t,r){e.exports?e.exports=r(t,or(),ar()):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){let n=t.prototype;Object.assign(t.defaults,{history:"replace"});let i=document.createElement("a");return t.create.history=function(){if(!this.options.history)return;i.href=this.getAbsolutePath(),(i.origin||i.protocol+"//"+i.host)==location.origin?this.options.append?this.createHistoryAppend():this.createHistoryPageLoad():console.error(`[InfiniteScroll] cannot set history with different origin: ${i.origin} on ${location.origin} . History behavior disabled.`)},n.createHistoryAppend=function(){this.updateMeasurements(),this.updateScroller(),this.scrollPages=[{top:0,path:location.href,title:document.title}],this.scrollPage=this.scrollPages[0],this.scrollHistoryHandler=this.onScrollHistory.bind(this),this.unloadHandler=this.onUnload.bind(this),this.scroller.addEventListener("scroll",this.scrollHistoryHandler),this.on("append",this.onAppendHistory),this.bindHistoryAppendEvents(!0)},n.bindHistoryAppendEvents=function(t){let r=t?"addEventListener":"removeEventListener";this.scroller[r]("scroll",this.scrollHistoryHandler),e[r]("unload",this.unloadHandler)},n.createHistoryPageLoad=function(){this.on("load",this.onPageLoadHistory)},t.destroy.history=n.destroyHistory=function(){this.options.history&&this.options.append&&this.bindHistoryAppendEvents(!1)},n.onAppendHistory=function(e,t,r){if(!r||!r.length)return;let n=r[0],s=this.getElementScrollY(n);i.href=t,this.scrollPages.push({top:s,path:i.href,title:e.title})},n.getElementScrollY=function(t){if(this.options.elementScroll)return t.offsetTop-this.top;return t.getBoundingClientRect().top+e.scrollY},n.onScrollHistory=function(){let e=this.getClosestScrollPage();e!=this.scrollPage&&(this.scrollPage=e,this.setHistory(e.title,e.path))},r.debounceMethod(t,"onScrollHistory",150),n.getClosestScrollPage=function(){let t,r;t=this.options.elementScroll?this.scroller.scrollTop+this.scroller.clientHeight/2:e.scrollY+this.windowHeight/2;for(let e of this.scrollPages){if(e.top>=t)break;r=e}return r},n.setHistory=function(e,t){let r=this.options.history;r&&history[r+"State"]&&(history[r+"State"](null,e,t),this.options.historyTitle&&(document.title=e),this.dispatchEvent("history",null,[e,t]))},n.onUnload=function(){if(0===this.scrollPage.top)return;let t=e.scrollY-this.scrollPage.top+this.top;this.destroyHistory(),scrollTo(0,t)},n.onPageLoadHistory=function(e,t){this.setHistory(e.title,t)},t}))}(gr)),gr.exports}var vr,yr={exports:{}};function br(){return vr||(vr=1,function(e){!function(t,r){e.exports?e.exports=r(t,or(),ar()):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){class n{constructor(e,t){this.element=e,this.infScroll=t,this.clickHandler=this.onClick.bind(this),this.element.addEventListener("click",this.clickHandler),t.on("request",this.disable.bind(this)),t.on("load",this.enable.bind(this)),t.on("error",this.hide.bind(this)),t.on("last",this.hide.bind(this))}onClick(e){e.preventDefault(),this.infScroll.loadNextPage()}enable(){this.element.removeAttribute("disabled")}disable(){this.element.disabled="disabled"}hide(){this.element.style.display="none"}destroy(){this.element.removeEventListener("click",this.clickHandler)}}return t.create.button=function(){let e=r.getQueryElement(this.options.button);e&&(this.button=new n(e,this))},t.destroy.button=function(){this.button&&this.button.destroy()},t.Button=n,t}))}(yr)),yr.exports}var wr,_r={exports:{}};function Er(){return wr||(wr=1,function(e){!function(t,r){e.exports?e.exports=r(t,or(),ar()):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){let n=t.prototype;function i(e){a(e,"none")}function s(e){a(e,"block")}function a(e,t){e&&(e.style.display=t)}return t.create.status=function(){let e=r.getQueryElement(this.options.status);e&&(this.statusElement=e,this.statusEventElements={request:e.querySelector(".infinite-scroll-request"),error:e.querySelector(".infinite-scroll-error"),last:e.querySelector(".infinite-scroll-last")},this.on("request",this.showRequestStatus),this.on("error",this.showErrorStatus),this.on("last",this.showLastStatus),this.bindHideStatus("on"))},n.bindHideStatus=function(e){let t=this.options.append?"append":"load";this[e](t,this.hideAllStatus)},n.showRequestStatus=function(){this.showStatus("request")},n.showErrorStatus=function(){this.showStatus("error")},n.showLastStatus=function(){this.showStatus("last"),this.bindHideStatus("off")},n.showStatus=function(e){s(this.statusElement),this.hideStatusEventElements(),s(this.statusEventElements[e])},n.hideAllStatus=function(){i(this.statusElement),this.hideStatusEventElements()},n.hideStatusEventElements=function(){for(let e in this.statusEventElements){i(this.statusEventElements[e])}},t}))}(_r)),_r.exports}
|
|
10
9
|
/*!
|
|
11
10
|
* Infinite Scroll v4.0.1
|
|
12
11
|
* Automatically add next page
|
|
@@ -16,7 +15,7 @@
|
|
|
16
15
|
*
|
|
17
16
|
* https://infinite-scroll.com
|
|
18
17
|
* Copyright 2018-2020 Metafizzy
|
|
19
|
-
*/!function(e){window,e.exports&&(e.exports=function(e){return e}(requireCore(),requirePageLoad(),requireScrollWatch(),requireHistory(),requireButton(),requireStatus()))}(js);var TheInfiniteScroll=js.exports;class InfiniteScroll extends Action{constructor(e,t){super(e,t),this.options={path:".infinite-scroll-btn",history:"push",status:".infinite-scroll-status",append:".list-block"},this.fetchOptions={headers:{"S-INFINITE-SCROLL":!0}},this.instances=[]}initiate(e,t,r){r=this.getCustomOptions(t,r);let i="string"!=typeof e?e:document.querySelector(e),n=r.path;if(!i||!n||"string"==typeof n&&!document.querySelector(n))return void salla.logger.warn(i?"Path Option (a link that has next page link) Not Existed!":"Container For InfiniteScroll not Existed!");let a=new TheInfiniteScroll(i,r);return a.on("scrollThreshold",salla.infiniteScroll.event.scrollThreshold),a.on("request",salla.infiniteScroll.event.request),a.on("load",salla.infiniteScroll.event.load),a.on("append",salla.infiniteScroll.event.append),a.on("error",salla.infiniteScroll.event.error),a.on("last",salla.infiniteScroll.event.last),a.on("history",salla.infiniteScroll.event.history),this.instances.push(a),a}getCustomOptions(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}}function injectValueToFromData(e,t,r){return e instanceof FormData?e.append(t,r):e[t]=r,e}function number(e,t=!1){e+="";let r,i=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],n=["0","1","2","3","4","5","6","7","8","9"],a=(t=t||!salla.config.get("store.settings.arabic_numbers_enabled"))?i:n,s=t?n:i;for(let t=0;t<a.length;t++)r=new RegExp(a[t],"g"),e=e.replace(r,s[t]);return e}function digitsOnly(e){return number(e,!0).replace(/[^0-9.]/g,"").replace("..",".").rtrim(".")}function inputDigitsOnly(e,t=!1){if("string"==typeof e)return document.querySelectorAll(e).forEach((e=>inputDigitsOnly(e,t)));if(!e)return void salla.logger.warn("Can't find Object With Id: "+e);let r=salla.helpers.digitsOnly(e.value);return e.min&&r<e.min?e.value=e.min:e.max&&r>e.max?e.value=e.max:e.maxLength>=1&&r.toString().length>e.maxLength?e.value=r.toString().substring(0,e.maxLength):e.value=t||e.dataset.hasOwnProperty("digitsWithDecimal")?getOnlyDecimal(r):r.replace(/\D/g,"")}function getOnlyDecimal(e){let t=(e.match(/\./g)||[]).length;return t&&1!==t?getOnlyDecimal(e.replace(/\.(.+)\./g,".$1")):e}function money(e){return number(e?.amount|e)+" "+salla.config.currency(e?.currency).symbol}String.prototype.toStudlyCase=function(){return this.trim().replace(/([^a-zA-Z\d].)/g,(function(e){return e.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:"#"+this},String.prototype.replaceArray=function(e,t){for(var r,i=this,n=0;n<e.length;n++)r=new RegExp(e[n],"g"),i=i.replace(r,t[n]);return i},String.prototype.rtrim=function(e){return void 0===e&&(e="\\s"),this.replace(new RegExp("["+e+"]*$"),"")},String.prototype.ltrim=function(e){return void 0===e&&(e="\\s"),this.replace(new RegExp("^["+e+"]*"),"")},String.prototype.digitsOnly=function(){return salla.helpers.digitsOnly(this)},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,...t){if(!this.getAttribute)return;if(this.hasAttribute("data-json"))try{return JSON.parse(this.getAttribute("data-json"))}catch(e){}let r=this.getAttribute("data-function");if(r&&window[r])return"function"==typeof window[r]?this.getFilteredData(window[r].call(this,...t)):this.getFilteredData(window[r]);let i=this.hasAttribute("data-form-selector")?document.querySelector(this.dataset.formSelector):void 0;if(i="FORM"===this.tagName?this:i||this.closest("form")||this.closest("[salla-form-data]")||this,i&&"FORM"===i.tagName)return this.getFilteredData(new FormData(i),null,i);let n=i.querySelectorAll("[name]");if(!n.length)return this.getFilteredData();let a=Object.assign({},this.dataset);return n.forEach((e=>{if(!["checkbox","radio"].includes(e.type)||e.checked)try{let t=salla.helpers.inputData(e.name,e.value,a);a[t.name]=t.value}catch(t){salla.log(e.name+" can't be send")}})),this.getFilteredData(a)},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 r=0;r<this.attributes.length;r++){let i=this.attributes[r].name.toLowerCase();if(0===i.indexOf(e))return!t||i}return!1},HTMLFormElement.prototype.getAjaxFormData=function(e){var t=this.querySelectorAll('input[type="file"]');t.forEach((e=>{e.files.length||e.setAttribute("disabled","")}));var r=new FormData(this);return t.forEach((e=>{e.files.length||e.removeAttribute("disabled")})),{formData:this.getFilteredData(r,e),url:this.getAttribute("action"),method:this.getAttribute("method")||"post",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}},Element.prototype.getFilteredData=function(e=null,t=null,r=null){return e=e||r?.dataset||this.dataset,r&&this.name&&void 0!==this.value&&(e=injectValueToFromData(e,this.name,this.value)),["filterBeforeSubmit","filterBeforeSend"].forEach((i=>{let n=r?.dataset[i]||this.dataset[i];if(n){var a=window[n];if("function"==typeof a){if(!a(e,r||this,t)&&e)throw`Data failed to be pass verify function window.${n}(formData, element, event)!`;return a(e,r||this,t)}salla.log("window."+n+"() 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 isArray$3=Array.isArray,isArray_1=isArray$3,freeGlobal$1="object"==typeof commonjsGlobal&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,_freeGlobal=freeGlobal$1,freeGlobal=_freeGlobal,freeSelf="object"==typeof self&&self&&self.Object===Object&&self,root$3=freeGlobal||freeSelf||Function("return this")(),_root=root$3,root$2=_root,Symbol$4=root$2.Symbol,_Symbol=Symbol$4,Symbol$3=_Symbol,objectProto$4=Object.prototype,hasOwnProperty$3=objectProto$4.hasOwnProperty,nativeObjectToString$1=objectProto$4.toString,symToStringTag$1=Symbol$3?Symbol$3.toStringTag:void 0;function getRawTag$1(e){var t=hasOwnProperty$3.call(e,symToStringTag$1),r=e[symToStringTag$1];try{e[symToStringTag$1]=void 0;var i=!0}catch(e){}var n=nativeObjectToString$1.call(e);return i&&(t?e[symToStringTag$1]=r:delete e[symToStringTag$1]),n}var _getRawTag=getRawTag$1,objectProto$3=Object.prototype,nativeObjectToString=objectProto$3.toString;function objectToString$1(e){return nativeObjectToString.call(e)}var _objectToString=objectToString$1,Symbol$2=_Symbol,getRawTag=_getRawTag,objectToString=_objectToString,nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=Symbol$2?Symbol$2.toStringTag:void 0;function baseGetTag$2(e){return null==e?void 0===e?undefinedTag:nullTag:symToStringTag&&symToStringTag in Object(e)?getRawTag(e):objectToString(e)}var _baseGetTag=baseGetTag$2;function isObjectLike$1(e){return null!=e&&"object"==typeof e}var isObjectLike_1=isObjectLike$1,baseGetTag$1=_baseGetTag,isObjectLike=isObjectLike_1,symbolTag="[object Symbol]";function isSymbol$3(e){return"symbol"==typeof e||isObjectLike(e)&&baseGetTag$1(e)==symbolTag}var isSymbol_1=isSymbol$3,isArray$2=isArray_1,isSymbol$2=isSymbol_1,reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/;function isKey$1(e,t){if(isArray$2(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!isSymbol$2(e))||(reIsPlainProp.test(e)||!reIsDeepProp.test(e)||null!=t&&e in Object(t))}var _isKey=isKey$1;function isObject$4(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var isObject_1=isObject$4,baseGetTag=_baseGetTag,isObject$3=isObject_1,asyncTag="[object AsyncFunction]",funcTag="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction$3(e){if(!isObject$3(e))return!1;var t=baseGetTag(e);return t==funcTag||t==genTag||t==asyncTag||t==proxyTag}var isFunction_1=isFunction$3,root$1=_root,coreJsData$1=root$1["__core-js_shared__"],_coreJsData=coreJsData$1,coreJsData=_coreJsData,maskSrcKey=(uid=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||""),uid?"Symbol(src)_1."+uid:""),uid;function isMasked$1(e){return!!maskSrcKey&&maskSrcKey in e}var _isMasked=isMasked$1,funcProto$1=Function.prototype,funcToString$1=funcProto$1.toString;function toSource$1(e){if(null!=e){try{return funcToString$1.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var _toSource=toSource$1,isFunction$2=isFunction_1,isMasked=_isMasked,isObject$2=isObject_1,toSource=_toSource,reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reIsHostCtor=/^\[object .+?Constructor\]$/,funcProto=Function.prototype,objectProto$2=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$2=objectProto$2.hasOwnProperty,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty$2).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative$1(e){return!(!isObject$2(e)||isMasked(e))&&(isFunction$2(e)?reIsNative:reIsHostCtor).test(toSource(e))}var _baseIsNative=baseIsNative$1;function getValue$1(e,t){return null==e?void 0:e[t]}var _getValue=getValue$1,baseIsNative=_baseIsNative,getValue=_getValue;function getNative$2(e,t){var r=getValue(e,t);return baseIsNative(r)?r:void 0}var _getNative=getNative$2,getNative$1=_getNative,nativeCreate$4=getNative$1(Object,"create"),_nativeCreate=nativeCreate$4,nativeCreate$3=_nativeCreate;function hashClear$1(){this.__data__=nativeCreate$3?nativeCreate$3(null):{},this.size=0}var _hashClear=hashClear$1;function hashDelete$1(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var _hashDelete=hashDelete$1,nativeCreate$2=_nativeCreate,HASH_UNDEFINED$1="__lodash_hash_undefined__",objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty;function hashGet$1(e){var t=this.__data__;if(nativeCreate$2){var r=t[e];return r===HASH_UNDEFINED$1?void 0:r}return hasOwnProperty$1.call(t,e)?t[e]:void 0}var _hashGet=hashGet$1,nativeCreate$1=_nativeCreate,objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty;function hashHas$1(e){var t=this.__data__;return nativeCreate$1?void 0!==t[e]:hasOwnProperty.call(t,e)}var _hashHas=hashHas$1,nativeCreate=_nativeCreate,HASH_UNDEFINED="__lodash_hash_undefined__";function hashSet$1(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=nativeCreate&&void 0===t?HASH_UNDEFINED:t,this}var _hashSet=hashSet$1,hashClear=_hashClear,hashDelete=_hashDelete,hashGet=_hashGet,hashHas=_hashHas,hashSet=_hashSet;function Hash$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}Hash$1.prototype.clear=hashClear,Hash$1.prototype.delete=hashDelete,Hash$1.prototype.get=hashGet,Hash$1.prototype.has=hashHas,Hash$1.prototype.set=hashSet;var _Hash=Hash$1;function listCacheClear$1(){this.__data__=[],this.size=0}var _listCacheClear=listCacheClear$1;function eq$1(e,t){return e===t||e!=e&&t!=t}var eq_1=eq$1,eq=eq_1;function assocIndexOf$4(e,t){for(var r=e.length;r--;)if(eq(e[r][0],t))return r;return-1}var _assocIndexOf=assocIndexOf$4,assocIndexOf$3=_assocIndexOf,arrayProto=Array.prototype,splice=arrayProto.splice;function listCacheDelete$1(e){var t=this.__data__,r=assocIndexOf$3(t,e);return!(r<0)&&(r==t.length-1?t.pop():splice.call(t,r,1),--this.size,!0)}var _listCacheDelete=listCacheDelete$1,assocIndexOf$2=_assocIndexOf;function listCacheGet$1(e){var t=this.__data__,r=assocIndexOf$2(t,e);return r<0?void 0:t[r][1]}var _listCacheGet=listCacheGet$1,assocIndexOf$1=_assocIndexOf;function listCacheHas$1(e){return assocIndexOf$1(this.__data__,e)>-1}var _listCacheHas=listCacheHas$1,assocIndexOf=_assocIndexOf;function listCacheSet$1(e,t){var r=this.__data__,i=assocIndexOf(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}var _listCacheSet=listCacheSet$1,listCacheClear=_listCacheClear,listCacheDelete=_listCacheDelete,listCacheGet=_listCacheGet,listCacheHas=_listCacheHas,listCacheSet=_listCacheSet;function ListCache$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}ListCache$1.prototype.clear=listCacheClear,ListCache$1.prototype.delete=listCacheDelete,ListCache$1.prototype.get=listCacheGet,ListCache$1.prototype.has=listCacheHas,ListCache$1.prototype.set=listCacheSet;var _ListCache=ListCache$1,getNative=_getNative,root=_root,Map$1=getNative(root,"Map"),_Map=Map$1,Hash=_Hash,ListCache=_ListCache,Map=_Map;function mapCacheClear$1(){this.size=0,this.__data__={hash:new Hash,map:new(Map||ListCache),string:new Hash}}var _mapCacheClear=mapCacheClear$1;function isKeyable$1(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}var _isKeyable=isKeyable$1,isKeyable=_isKeyable;function getMapData$4(e,t){var r=e.__data__;return isKeyable(t)?r["string"==typeof t?"string":"hash"]:r.map}var _getMapData=getMapData$4,getMapData$3=_getMapData;function mapCacheDelete$1(e){var t=getMapData$3(this,e).delete(e);return this.size-=t?1:0,t}var _mapCacheDelete=mapCacheDelete$1,getMapData$2=_getMapData;function mapCacheGet$1(e){return getMapData$2(this,e).get(e)}var _mapCacheGet=mapCacheGet$1,getMapData$1=_getMapData;function mapCacheHas$1(e){return getMapData$1(this,e).has(e)}var _mapCacheHas=mapCacheHas$1,getMapData=_getMapData;function mapCacheSet$1(e,t){var r=getMapData(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}var _mapCacheSet=mapCacheSet$1,mapCacheClear=_mapCacheClear,mapCacheDelete=_mapCacheDelete,mapCacheGet=_mapCacheGet,mapCacheHas=_mapCacheHas,mapCacheSet=_mapCacheSet;function MapCache$1(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}MapCache$1.prototype.clear=mapCacheClear,MapCache$1.prototype.delete=mapCacheDelete,MapCache$1.prototype.get=mapCacheGet,MapCache$1.prototype.has=mapCacheHas,MapCache$1.prototype.set=mapCacheSet;var _MapCache=MapCache$1,MapCache=_MapCache,FUNC_ERROR_TEXT="Expected a function";function memoize$1(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError(FUNC_ERROR_TEXT);var r=function(){var i=arguments,n=t?t.apply(this,i):i[0],a=r.cache;if(a.has(n))return a.get(n);var s=e.apply(this,i);return r.cache=a.set(n,s)||a,s};return r.cache=new(memoize$1.Cache||MapCache),r}memoize$1.Cache=MapCache;var memoize_1=memoize$1,memoize=memoize_1,MAX_MEMOIZE_SIZE=500;function memoizeCapped$1(e){var t=memoize(e,(function(e){return r.size===MAX_MEMOIZE_SIZE&&r.clear(),e})),r=t.cache;return t}var _memoizeCapped=memoizeCapped$1,memoizeCapped=_memoizeCapped,rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,reEscapeChar=/\\(\\)?/g,stringToPath$1=memoizeCapped((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(rePropName,(function(e,r,i,n){t.push(i?n.replace(reEscapeChar,"$1"):r||e)})),t})),_stringToPath=stringToPath$1;function arrayMap$1(e,t){for(var r=-1,i=null==e?0:e.length,n=Array(i);++r<i;)n[r]=t(e[r],r,e);return n}var _arrayMap=arrayMap$1,Symbol$1=_Symbol,arrayMap=_arrayMap,isArray$1=isArray_1,isSymbol$1=isSymbol_1,INFINITY$1=1/0,symbolProto=Symbol$1?Symbol$1.prototype:void 0,symbolToString=symbolProto?symbolProto.toString:void 0;function baseToString$1(e){if("string"==typeof e)return e;if(isArray$1(e))return arrayMap(e,baseToString$1)+"";if(isSymbol$1(e))return symbolToString?symbolToString.call(e):"";var t=e+"";return"0"==t&&1/e==-INFINITY$1?"-0":t}var _baseToString=baseToString$1,baseToString=_baseToString;function toString$1(e){return null==e?"":baseToString(e)}var toString_1=toString$1,isArray=isArray_1,isKey=_isKey,stringToPath=_stringToPath,toString=toString_1;function castPath$1(e,t){return isArray(e)?e:isKey(e,t)?[e]:stringToPath(toString(e))}var _castPath=castPath$1,isSymbol=isSymbol_1,INFINITY=1/0;function toKey$1(e){if("string"==typeof e||isSymbol(e))return e;var t=e+"";return"0"==t&&1/e==-INFINITY?"-0":t}var _toKey=toKey$1,castPath=_castPath,toKey=_toKey;function baseGet$1(e,t){for(var r=0,i=(t=castPath(t,e)).length;null!=e&&r<i;)e=e[toKey(t[r++])];return r&&r==i?e:void 0}var _baseGet=baseGet$1,baseGet=_baseGet;function get(e,t,r){var i=null==e?void 0:baseGet(e,t);return void 0===i?r:i}var get_1=get;function debounce(e,t){t=t||100;let r,i=[];return function(...n){return clearTimeout(r),r=setTimeout((()=>{let t=e(...n);i.forEach((e=>e(t))),i=[]}),t),new Promise((e=>i.push(e)))}}function getInputDataWithName(e,t,r={}){if(e.includes("[")){let i=e.split("]").join("").split("[");return{name:i[0],value:getLeveledData(i.slice(1),t,r[i[0]])}}return{name:e,value:t}}function getLeveledData(e,t,r){let i=e[0];return r&&0==e.length?Array.isArray(r)?(r.push(t),r):[r,t]:Array.isArray(r)?(r.push(t),r):"string"==typeof r?[r,t]:r?(r[i]=getLeveledData(e.slice(1),t,r[i]),r):i?{[i]:getLeveledData(e.slice(1),t)}:""===i?[t]:t}function setNested(e,t,r){let i=e,n=t.split("."),a=n.length;for(let e=0;e<a-1;e++){let t=n[e];i[t]||(i[t]={}),i=i[t]}return i[n[a-1]]=r,e}function getNested(e,t,r){let i=get_1(e,t);return void 0!==i?i:r}function url(e){return salla.config.get("store.url",window.location.href.split("/").slice(0,-1).join("/")).rtrim("/")+"/"+e.ltrim("/")}function addParamToUrl(e,t){if(!t||!e)return window.location.href;let r=new RegExp("([?&])"+e+"=[^&]+[&]?","g"),i=window.location.href.replace(r,"$1").replace(/&$|\?$/,"");return i+=(i.includes("?")?"&":"?")+e+"="+encodeURIComponent(t),i.replace(/&$|\?$/,"")}function baseUrl$1(e){return window.location.origin+"/"+e.ltrim("/")}function asset(e){return baseUrl$1("themes/"+salla.config.get("theme.name")+"/"+e.ltrim("/"))}function cdn(e){return"https://cdn.salla.network/"+e.ltrim("/")}function api$1(e){return salla.config.get("store.api",url("")).rtrim("/")+"/"+e.ltrim("/")}function is_page(e){return e&&salla.config.get("page.slug")===e}window.onbeforeunload=function(e){if(salla.document.event.leaving(e),!salla.config.get("canLeave"))return e.preventDefault(),!1};var Helpers={digitsOnly:digitsOnly,inputDigitsOnly:inputDigitsOnly,number:number,money:money,setNested:setNested,getNested:getNested,inputData:getInputDataWithName,url:{get:url,asset:asset,cdn:cdn,is_page:is_page,api:api$1},addParamToUrl:addParamToUrl,debounce:debounce};class AppHelpers{toggleClassIf(e,t,r,i){return document.querySelectorAll(e).forEach((e=>this.toggleElementClassIf(e,t,r,i))),this}toggleElementClassIf(e,t,r,i){t=Array.isArray(t)?t:t.split(" "),r=Array.isArray(r)?r:r.split(" ");let n=i(e);return e?.classList.remove(...n?r:t),e?.classList.add(...n?t:r),this}isValidEmail(e){return/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(e).toLowerCase())}element(e){return"object"==typeof e?e:document.querySelector(e)}watchElement(e,t){return this[e]=this.element(t),this}watchElements(e){return Object.entries(e).forEach((e=>this.watchElement(e[0],e[1]))),this}on(e,t,r,i={}){return"object"==typeof t?(this.element(t).addEventListener(e,r,i),this):(document.querySelectorAll(t).forEach((t=>t.addEventListener(e,r,i))),this)}onClick(e,t){return this.on("click",e,t)}onKeyUp(e,t){return this.on("keyup",e,t)}onEnter(e,t){return this.onKeyUp(e,(e=>13===e.keyCode&&t(e))),this}all(e,t){return document.querySelectorAll(e).forEach(t),this}hideElement(e){return this.element(e).style.display="none",this}showElement(e,t="block"){return this.element(e).style.display=t,this}removeClass(e,t){return this.element(e).classList.remove(...Array.from(arguments).slice(1)),this}addClass(e,t){return this.element(e).classList.add(...Array.from(arguments).slice(1)),this}debounce(e,...t){return this.debounce_||(this.debounce_=salla.helpers.debounce(((e,...t)=>e(...t)),500)),this.debounce_(e,...t)}}class SallaForm{async submit(e,t=null){let r=t;if("SubmitEvent"===t?.constructor?.name){if(t.preventDefault(),"FORM"!==t.target?.tagName)return salla.logger.warn("Failed find the target element for submit action. make sure you submit a form element"),new Promise((()=>{throw"Failed find the target element for submit action. make sure you submit a form element"}));"SALLA-BUTTON"===t?.submitter?.parentElement?.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.twilight.request(e,r,"post").finally((()=>{loaderSupported&&t?.submitter?.parentElement.stop()}));let i=e.split("."),n=i.splice(-1);return await salla.call(i.join("."))[n](r).finally((()=>t?.submitter?.parentElement?.stop())).catch((e=>{throw salla.logger.warn(e),e}))}onSubmit(e,t){return salla.form.submit(e,t),!1}onChange(e,t){return t?.currentTarget?"FORM"!==t?.currentTarget?.tagName||t.currentTarget.checkValidity()?(salla.form.submit(e,t.currentTarget.getElementSallaData()),!0):(salla.logger.warn(`Trying to trigger '${e}' without filling required fields!`),!1):(salla.logger.warn(`Trying to trigger '${e}' without event!`),!1)}}class SallaCookie{constructor(e){e.on("cookies::remove",(e=>this.remove(e))),e.on("cookies::add",((e,t)=>this.set(e,t)))}get(e){return document.cookie.split("; ").find((t=>t.startsWith(e+"=")))?.split("=")[1]}set(e,t="",r=10){let i="";if(r){let e=new Date;e.setTime(e.getTime()+24*r*60*60*1e3),i="; expires="+e.toUTCString()}return document.cookie=`${e}=${t}${i}"; path=/; secure; SameSite=Lax"`,this}remove(e){return document.cookie=`${e}=; Max-Age=0; path=/;`,this}}class SallaConfig{constructor(e={}){this.triedToGetCurrencies_=!1,this.languages_=[],this.triedToGetLanguages_=!1,this.currencies_={},this.default_properties={debug:"development"===process.env.NODE_ENV,token:null,fastRequests:!0,canLeave:!0,store:{api:"https://api.salla.dev/store/v1/"},currencies:{SAR:{code:"SAR",name:"ريال سعودي",symbol:"ر.س",amount:1,country_code:"sa"}}},this.properties_={...this.default_properties,...e}}merge(e){return Object.assign(this.properties_,e),this.properties_.store={...this.default_properties.store,...this.properties_.store},this}set(e,t){return e.includes(".")?(salla.helpers.setNested(this.properties_,e,t),this):(this.properties_[e]=t,this)}get(e,t=null){return e.includes(".")?salla.helpers.getNested(this.properties_,e,t):this.properties_.hasOwnProperty(e)?this.properties_[e]||t:t||void 0}isUser(){return"user"===this.get("user.type")}isGuest(){return!this.isUser()}async languages(){if(this.triedToGetLanguages_)return this.languages_;this.triedToGetLanguages_=!0;let e=!0;return(await salla.document.api.request("languages",null,"get"))?.data?.map((t=>{e&&(this.languages_=[],e=!1),t.code=t.code||t.iso_code,t.url=salla.url.get(t.code),t.is_rtl=t.is_rtl||t.rtl,this.languages_.push(t)})),this.set("languages",this.languages_),this.languages_}async currencies(){if(this.triedToGetCurrencies_)return this.currencies_;this.triedToGetCurrencies_=!0;let e=!0;return(await salla.currency.api.list())?.data?.map((t=>{e&&(this.currencies_={},e=!1),t.country_code=t.code.substr(0,2).toLowerCase(),this.currencies_[t.code]=t})),this.set("currencies",this.currencies_),this.currencies_}currency(e){return e=e||this.get("user.currency_code"),this.get("currencies."+e)||Object.values(this.get("currencies"))[0]}}var lang={exports:{}};
|
|
18
|
+
*/!function(e){window,e.exports&&(e.exports=function(e){return e}(or(),ur(),fr(),mr(),br(),Er()))}(Xt);var Sr=Xt.exports;function xr(e,t=!1){e+="";let r,n=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],i=["0","1","2","3","4","5","6","7","8","9"],s=(t=t||!salla.config.get("store.settings.arabic_numbers_enabled"))?n:i,a=t?i:n;for(let t=0;t<s.length;t++)r=new RegExp(s[t],"g"),e=e.replace(r,a[t]);return e}function Ar(e){let t=(e.match(/\./g)||[]).length;return t&&1!==t?Ar(e.replace(/\.(.+)\./g,".$1")):e}String.prototype.toStudlyCase=function(){return this.trim().replace(/([^a-zA-Z\d].)/g,(function(e){return e.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:"#"+this},String.prototype.replaceArray=function(e,t){for(var r,n=this,i=0;i<e.length;i++)r=new RegExp(e[i],"g"),n=n.replace(r,t[i]);return n},String.prototype.rtrim=function(e){return void 0===e&&(e="\\s"),this.replace(new RegExp("["+e+"]*$"),"")},String.prototype.ltrim=function(e){return void 0===e&&(e="\\s"),this.replace(new RegExp("^["+e+"]*"),"")},String.prototype.digitsOnly=function(){return salla.helpers.digitsOnly(this)},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,...t){if(!this.getAttribute)return;if(this.hasAttribute("data-json"))try{return JSON.parse(this.getAttribute("data-json"))}catch(e){}let r=this.getAttribute("data-function");if(r&&window[r])return"function"==typeof window[r]?this.getFilteredData(window[r].call(this,...t)):this.getFilteredData(window[r]);let n=this.hasAttribute("data-form-selector")?document.querySelector(this.dataset.formSelector):void 0;if(n="FORM"===this.tagName?this:n||this.closest("form")||this.closest("[salla-form-data]")||this,n&&"FORM"===n.tagName)return this.getFilteredData(new FormData(n),null,n);let i=n.querySelectorAll("[name]");if(!i.length)return this.getFilteredData();let s=Object.assign({},this.dataset);return i.forEach((e=>{if(!["checkbox","radio"].includes(e.type)||e.checked)try{let 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 r=0;r<this.attributes.length;r++){let n=this.attributes[r].name.toLowerCase();if(0===n.indexOf(e))return!t||n}return!1},HTMLFormElement.prototype.getAjaxFormData=function(e){var t=this.querySelectorAll('input[type="file"]');t.forEach((e=>{e.files.length||e.setAttribute("disabled","")}));var r=new FormData(this);return t.forEach((e=>{e.files.length||e.removeAttribute("disabled")})),{formData:this.getFilteredData(r,e),url:this.getAttribute("action"),method:this.getAttribute("method")||"post",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}},Element.prototype.getFilteredData=function(e=null,t=null,r=null){return e=e||r?.dataset||this.dataset,r&&this.name&&void 0!==this.value&&(e=function(e,t,r){e instanceof FormData?e.append(t,r):e[t]=r;return e}(e,this.name,this.value)),["filterBeforeSubmit","filterBeforeSend"].forEach((n=>{let i=r?.dataset[n]||this.dataset[n];if(i){var s=window[i];if("function"==typeof s){if(!s(e,r||this,t)&&e)throw`Data failed to be pass verify function window.${i}(formData, element, event)!`;return s(e,r||this,t)}salla.log("window."+i+"() 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 Pr=Array.isArray,Fr="object"==typeof w&&w&&w.Object===Object&&w,Lr="object"==typeof self&&self&&self.Object===Object&&self,Or=Fr||Lr||Function("return this")(),kr=Or.Symbol,Tr=kr,jr=Object.prototype,Cr=jr.hasOwnProperty,Rr=jr.toString,Ir=Tr?Tr.toStringTag:void 0;var qr=function(e){var t=Cr.call(e,Ir),r=e[Ir];try{e[Ir]=void 0;var n=!0}catch(e){}var i=Rr.call(e);return n&&(t?e[Ir]=r:delete e[Ir]),i},Nr=Object.prototype.toString;var Dr=qr,Ur=function(e){return Nr.call(e)},Mr=kr?kr.toStringTag:void 0;var $r=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Mr&&Mr in Object(e)?Dr(e):Ur(e)};var zr=$r,Hr=function(e){return null!=e&&"object"==typeof e};var Br=function(e){return"symbol"==typeof e||Hr(e)&&"[object Symbol]"==zr(e)},Gr=Pr,Vr=Br,Wr=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Jr=/^\w*$/;var Qr=function(e,t){if(Gr(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!Vr(e))||(Jr.test(e)||!Wr.test(e)||null!=t&&e in Object(t))};var Kr=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},Yr=$r,Zr=Kr;var Xr,en=function(e){if(!Zr(e))return!1;var t=Yr(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},tn=Or["__core-js_shared__"],rn=(Xr=/[^.]+$/.exec(tn&&tn.keys&&tn.keys.IE_PROTO||""))?"Symbol(src)_1."+Xr:"";var nn=function(e){return!!rn&&rn in e},sn=Function.prototype.toString;var an=en,on=nn,ln=Kr,cn=function(e){if(null!=e){try{return sn.call(e)}catch(e){}try{return e+""}catch(e){}}return""},un=/^\[object .+?Constructor\]$/,hn=Function.prototype,dn=Object.prototype,fn=hn.toString,pn=dn.hasOwnProperty,gn=RegExp("^"+fn.call(pn).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var mn=function(e){return!(!ln(e)||on(e))&&(an(e)?gn:un).test(cn(e))},vn=function(e,t){return null==e?void 0:e[t]};var yn=function(e,t){var r=vn(e,t);return mn(r)?r:void 0},bn=yn(Object,"create"),wn=bn;var _n=function(){this.__data__=wn?wn(null):{},this.size=0};var En=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Sn=bn,xn=Object.prototype.hasOwnProperty;var An=function(e){var t=this.__data__;if(Sn){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return xn.call(t,e)?t[e]:void 0},Pn=bn,Fn=Object.prototype.hasOwnProperty;var Ln=function(e){var t=this.__data__;return Pn?void 0!==t[e]:Fn.call(t,e)},On=bn;var kn=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=On&&void 0===t?"__lodash_hash_undefined__":t,this},Tn=_n,jn=En,Cn=An,Rn=Ln,In=kn;function qn(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}qn.prototype.clear=Tn,qn.prototype.delete=jn,qn.prototype.get=Cn,qn.prototype.has=Rn,qn.prototype.set=In;var Nn=qn;var Dn=function(){this.__data__=[],this.size=0};var Un=function(e,t){return e===t||e!=e&&t!=t};var Mn=function(e,t){for(var r=e.length;r--;)if(Un(e[r][0],t))return r;return-1},$n=Mn,zn=Array.prototype.splice;var Hn=function(e){var t=this.__data__,r=$n(t,e);return!(r<0)&&(r==t.length-1?t.pop():zn.call(t,r,1),--this.size,!0)},Bn=Mn;var Gn=function(e){var t=this.__data__,r=Bn(t,e);return r<0?void 0:t[r][1]},Vn=Mn;var Wn=Mn;var Jn=function(e,t){var r=this.__data__,n=Wn(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},Qn=Dn,Kn=Hn,Yn=Gn,Zn=function(e){return Vn(this.__data__,e)>-1},Xn=Jn;function ei(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}ei.prototype.clear=Qn,ei.prototype.delete=Kn,ei.prototype.get=Yn,ei.prototype.has=Zn,ei.prototype.set=Xn;var ti=ei,ri=yn(Or,"Map"),ni=Nn,ii=ti,si=ri;var ai=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};var oi=function(e,t){var r=e.__data__;return ai(t)?r["string"==typeof t?"string":"hash"]:r.map},li=oi;var ci=oi;var ui=oi;var hi=oi;var di=function(e,t){var r=hi(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},fi=function(){this.size=0,this.__data__={hash:new ni,map:new(si||ii),string:new ni}},pi=function(e){var t=li(this,e).delete(e);return this.size-=t?1:0,t},gi=function(e){return ci(this,e).get(e)},mi=function(e){return ui(this,e).has(e)},vi=di;function yi(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}yi.prototype.clear=fi,yi.prototype.delete=pi,yi.prototype.get=gi,yi.prototype.has=mi,yi.prototype.set=vi;var bi=yi;function wi(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],s=r.cache;if(s.has(i))return s.get(i);var a=e.apply(this,n);return r.cache=s.set(i,a)||s,a};return r.cache=new(wi.Cache||bi),r}wi.Cache=bi;var _i=wi;var Ei=function(e){var t=_i(e,(function(e){return 500===r.size&&r.clear(),e})),r=t.cache;return t},Si=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,xi=/\\(\\)?/g,Ai=Ei((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(Si,(function(e,r,n,i){t.push(n?i.replace(xi,"$1"):r||e)})),t})),Pi=Ai;var Fi=function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i},Li=Pr,Oi=Br,ki=kr?kr.prototype:void 0,Ti=ki?ki.toString:void 0;var ji=function e(t){if("string"==typeof t)return t;if(Li(t))return Fi(t,e)+"";if(Oi(t))return Ti?Ti.call(t):"";var r=t+"";return"0"==r&&1/t==-Infinity?"-0":r},Ci=ji;var Ri=Pr,Ii=Qr,qi=Pi,Ni=function(e){return null==e?"":Ci(e)};var Di=Br;var Ui=function(e,t){return Ri(e)?e:Ii(e,t)?[e]:qi(Ni(e))},Mi=function(e){if("string"==typeof e||Di(e))return e;var t=e+"";return"0"==t&&1/e==-Infinity?"-0":t};var $i=function(e,t){for(var r=0,n=(t=Ui(t,e)).length;null!=e&&r<n;)e=e[Mi(t[r++])];return r&&r==n?e:void 0};var zi=function(e,t,r){var n=null==e?void 0:$i(e,t);return void 0===n?r:n};function Hi(e,t,r){let n=e[0];return r&&0==e.length?Array.isArray(r)?(r.push(t),r):[r,t]:Array.isArray(r)?(r.push(t),r):"string"==typeof r?[r,t]:r?(r[n]=Hi(e.slice(1),t,r[n]),r):n?{[n]:Hi(e.slice(1),t)}:""===n?[t]:t}function Bi(e){return salla.config.get("store.url",window.location.href.split("/").slice(0,-1).join("/")).rtrim("/")+"/"+e.ltrim("/")}window.onbeforeunload=function(e){if(salla.document.event.leaving(e),!salla.config.get("canLeave"))return e.preventDefault(),!1};var Gi={digitsOnly:function(e){return xr(e,!0).replace(/[^0-9.]/g,"").replace("..",".").rtrim(".")},inputDigitsOnly:function e(t,r=!1){if("string"==typeof t)return document.querySelectorAll(t).forEach((t=>e(t,r)));if(!t)return void salla.logger.warn("Can't find Object With Id: "+t);let n=salla.helpers.digitsOnly(t.value);return t.min&&n<t.min?t.value=t.min:t.max&&n>t.max?t.value=t.max:t.maxLength>=1&&n.toString().length>t.maxLength?t.value=n.toString().substring(0,t.maxLength):t.value=r||t.dataset.hasOwnProperty("digitsWithDecimal")?Ar(n):n.replace(/\D/g,"")},number:xr,money:function(e){return xr(e?.amount|e)+" "+salla.config.currency(e?.currency).symbol},setNested:function(e,t,r){let n=e,i=t.split("."),s=i.length;for(let e=0;e<s-1;e++){let t=i[e];n[t]||(n[t]={}),n=n[t]}return n[i[s-1]]=r,e},getNested:function(e,t,r){let n=zi(e,t);return void 0!==n?n:r},inputData:function(e,t,r={}){if(e.includes("[")){let n=e.split("]").join("").split("[");return{name:n[0],value:Hi(n.slice(1),t,r[n[0]])}}return{name:e,value:t}},url:{get:Bi,asset:function(e){return function(e){return window.location.origin+"/"+e.ltrim("/")}("themes/"+salla.config.get("theme.name")+"/"+e.ltrim("/"))},cdn:function(e){return"https://cdn.salla.network/"+e.ltrim("/")},is_page:function(e){return e&&salla.config.get("page.slug")===e},api:function(e){return salla.config.get("store.api",Bi("")).rtrim("/")+"/"+e.ltrim("/")}},addParamToUrl:function(e,t){if(!t||!e)return window.location.href;let r=new RegExp("([?&])"+e+"=[^&]+[&]?","g"),n=window.location.href.replace(r,"$1").replace(/&$|\?$/,"");return n+=(n.includes("?")?"&":"?")+e+"="+encodeURIComponent(t),n.replace(/&$|\?$/,"")},debounce:function(e,t){t=t||100;let r,n=[];return function(...i){return clearTimeout(r),r=setTimeout((()=>{let t=e(...i);n.forEach((e=>e(t))),n=[]}),t),new Promise((e=>n.push(e)))}}};var Vi={exports:{}};
|
|
20
19
|
/*!
|
|
21
20
|
* Lang.js for Laravel localization in JavaScript.
|
|
22
21
|
*
|
|
@@ -24,5 +23,5 @@
|
|
|
24
23
|
* @license MIT https://github.com/rmariuzzo/Lang.js/blob/master/LICENSE
|
|
25
24
|
* @site https://github.com/rmariuzzo/Lang.js
|
|
26
25
|
* @author Rubens Mariuzzo <rubens@mariuzzo.com>
|
|
27
|
-
*/!function(e,t){e.exports=function(){function e(){if("undefined"!=typeof document&&document.documentElement)return document.documentElement.lang}function t(e){return"-Inf"===e?-1/0:"+Inf"===e||"Inf"===e||"*"===e?1/0:parseInt(e,10)}var r=/^({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])$/,i=/({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])/,n={locale:"en"},a=function(t){t=t||{},this.locale=t.locale||e()||n.locale,this.fallback=t.fallback,this.messages=t.messages};return a.prototype.setMessages=function(e){this.messages=e},a.prototype.getLocale=function(){return this.locale||this.fallback},a.prototype.setLocale=function(e){this.locale=e},a.prototype.getFallback=function(){return this.fallback},a.prototype.setFallback=function(e){this.fallback=e},a.prototype.has=function(e,t){return!("string"!=typeof e||!this.messages)&&null!==this._getMessage(e,t)},a.prototype.get=function(e,t,r){if(!this.has(e,r))return e;var i=this._getMessage(e,r);return null===i?e:(t&&(i=this._applyReplacements(i,t)),i)},a.prototype.trans=function(e,t){return this.get(e,t)},a.prototype.choice=function(e,t,r,n){(r=void 0!==r?r:{}).count=t;var a=this.get(e,r,n);if(null==a)return a;for(var s=a.split("|"),o=[],l=0;l<s.length;l++)if(s[l]=s[l].trim(),i.test(s[l])){var c=s[l].split(/\s/);o.push(c.shift()),s[l]=c.join(" ")}if(1===s.length)return a;for(var u=0;u<o.length;u++)if(this._testInterval(t,o[u]))return s[u];return n=n||this._getLocale(e),s[this._getPluralForm(t,n)]},a.prototype.transChoice=function(e,t,r){return this.choice(e,t,r)},a.prototype._parseKey=function(e,t){if("string"!=typeof e||"string"!=typeof t)return null;var r=e.split("."),i=r[0].replace(/\//g,".");return{source:t+"."+i,sourceFallback:this.getFallback()+"."+i,entries:r.slice(1)}},a.prototype._getMessage=function(e,t){if(t=t||this.getLocale(),e=this._parseKey(e,t),void 0===this.messages[e.source]&&void 0===this.messages[e.sourceFallback])return null;var r=this.messages[e.source],i=e.entries.slice(),n=i.join(".");if("string"!=typeof(r=void 0!==r?this._getValueInKey(r,n):void 0)&&this.messages[e.sourceFallback])for(r=this.messages[e.sourceFallback],i=e.entries.slice(),n="";i.length&&void 0!==r;)r[n=n?n.concat(".",i.shift()):i.shift()]&&(r=r[n],n="");return"string"!=typeof r?null:r},a.prototype._getValueInKey=function(e,t){if("string"==typeof e[t])return e[t];for(var r=(t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"")).split("."),i=0,n=r.length;i<n;++i){var a=r.slice(0,i+1).join("."),s=r.slice(i+1,r.length).join(".");if(e[a])return this._getValueInKey(e[a],s)}return e},a.prototype._getLocale=function(e){return e=this._parseKey(e,this.locale),this.messages[e.source]?this.locale:this.messages[e.sourceFallback]?this.fallback:null},a.prototype._findMessageInTree=function(e,t){for(;e.length&&void 0!==t;){var r=e.join(".");if(t[r]){t=t[r];break}t=t[e.shift()]}return t},a.prototype._sortReplacementKeys=function(e,t){return t.length-e.length},a.prototype._applyReplacements=function(e,t){return Object.keys(t).sort(this._sortReplacementKeys).forEach((function(r){e=e.replace(new RegExp(":"+r,"gi"),(function(e){var i=t[r];return e===e.toUpperCase()?i.toUpperCase():e===e.replace(/\w/i,(function(e){return e.toUpperCase()}))?i.charAt(0).toUpperCase()+i.slice(1):i}))})),e},a.prototype._testInterval=function(e,i){if("string"!=typeof i)throw"Invalid interval: should be a string.";var n=(i=i.trim()).match(r);if(!n)throw"Invalid interval: "+i;if(!n[2]){var a=(n=n.filter((function(e){return!!e})))[1],s=t(n[2]);s===1/0&&(s=-1/0);var o=t(n[3]),l=n[4];return("["===a?e>=s:e>s)&&("]"===l?e<=o:e<o)}for(var c=n[2].split(","),u=0;u<c.length;u++)if(parseInt(c[u],10)===e)return!0;return!1},a.prototype._getPluralForm=function(e,t){switch(t){case"az":case"bo":case"dz":case"id":case"ja":case"jv":case"ka":case"km":case"kn":case"ko":case"ms":case"th":case"tr":case"vi":case"zh":default:return 0;case"af":case"bn":case"bg":case"ca":case"da":case"de":case"el":case"en":case"eo":case"es":case"et":case"eu":case"fa":case"fi":case"fo":case"fur":case"fy":case"gl":case"gu":case"ha":case"he":case"hu":case"is":case"it":case"ku":case"lb":case"ml":case"mn":case"mr":case"nah":case"nb":case"ne":case"nl":case"nn":case"no":case"om":case"or":case"pa":case"pap":case"ps":case"pt":case"so":case"sq":case"sv":case"sw":case"ta":case"te":case"tk":case"ur":case"zu":return 1==e?0:1;case"am":case"bh":case"fil":case"fr":case"gun":case"hi":case"hy":case"ln":case"mg":case"nso":case"xbr":case"ti":case"wa":return 0===e||1===e?0:1;case"be":case"bs":case"hr":case"ru":case"sr":case"uk":return e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2;case"cs":case"sk":return 1==e?0:e>=2&&e<=4?1:2;case"ga":return 1==e?0:2==e?1:2;case"lt":return e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2;case"sl":return e%100==1?0:e%100==2?1:e%100==3||e%100==4?2:3;case"mk":return e%10==1?0:1;case"mt":return 1==e?0:0===e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3;case"lv":return 0===e?0:e%10==1&&e%100!=11?1:2;case"pl":return 1==e?0:e%10>=2&&e%10<=4&&(e%100<12||e%100>14)?1:2;case"cy":return 1==e?0:2==e?1:8==e||11==e?2:3;case"ro":return 1==e?0:0===e||e%100>0&&e%100<20?1:2;case"ar":return 0===e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11&&e%100<=99?4:5}},a}()}(lang);var Lang=lang.exports;class SallaLang extends Lang{constructor(e){(e=e||{}).messages=e.messages||window.translations,e.locale=e.locale||(window.locale||navigator.language||navigator.userLanguage||"ar").split("-")[0],e.fallback=e.fallback||e.locale,super(e),this.translationsLoaded=!1}onLoaded(e){if(this.translationsLoaded)return e();salla.event.once("languages::translations.loaded",e)}loadStoreTranslations(){if(this.messages)return void window.addEventListener("load",(e=>{salla.event.dispatch("languages::translations.loaded"),salla.logger.info("The messages of transactions is already loaded")}));if(!salla.url.get(""))return this.messages&&salla.event.dispatch("languages::translations.loaded"),this.translationsLoaded=!0,void salla.logger.warn("There is no `store.url` to auto loading translations from it!");let e=salla.config.get("theme.translations_hash",salla.config.get("store.id","twilight")),t=document.createElement("script");t.src=salla.url.get(`languages/assets/${e}.js`),t.onload=()=>{if(window.translations)return this.setMessages(window.translations),salla.event.dispatch("languages::translations.loaded"),void(this.translationsLoaded=!0);console.warn('You should load Salla Translations Before!\nUse: <script src="{{ link("languages/assets/{theme.translations_hash}.js") }}"><\/script>\nor: salla.lang.setMessages({....}), see https://github.com/rmariuzzo/Lang.js for more informations.')},document.head.appendChild(t)}get(e,t,r){return window.translations&&(e="trans."+e),super.get(e,t,r)}set(e,t){return salla.helpers.setNested(this.messages[this.getLocale()+".trans"],e,t),this}}var assign=make_assign(),create$1=make_create(),trim$1=make_trim(),Global$5="undefined"!=typeof window?window:commonjsGlobal,util$6={assign:assign,create:create$1,trim:trim$1,bind:bind$1,slice:slice$1,each:each$7,map:map,pluck:pluck$1,isList:isList$1,isFunction:isFunction$1,isObject:isObject$1,Global:Global$5};function make_assign(){return Object.assign?Object.assign:function(e,t,r,i){for(var n=1;n<arguments.length;n++)each$7(Object(arguments[n]),(function(t,r){e[r]=t}));return e}}function make_create(){if(Object.create)return function(e,t,r,i){var n=slice$1(arguments,1);return assign.apply(this,[Object.create(e)].concat(n))};{function e(){}return function(t,r,i,n){var a=slice$1(arguments,1);return e.prototype=t,assign.apply(this,[new e].concat(a))}}}function make_trim(){return String.prototype.trim?function(e){return String.prototype.trim.call(e)}:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}}function bind$1(e,t){return function(){return t.apply(e,Array.prototype.slice.call(arguments,0))}}function slice$1(e,t){return Array.prototype.slice.call(e,t||0)}function each$7(e,t){pluck$1(e,(function(e,r){return t(e,r),!1}))}function map(e,t){var r=isList$1(e)?[]:{};return pluck$1(e,(function(e,i){return r[i]=t(e,i),!1})),r}function pluck$1(e,t){if(isList$1(e)){for(var r=0;r<e.length;r++)if(t(e[r],r))return e[r]}else for(var i in e)if(e.hasOwnProperty(i)&&t(e[i],i))return e[i]}function isList$1(e){return null!=e&&"function"!=typeof e&&"number"==typeof e.length}function isFunction$1(e){return e&&"[object Function]"==={}.toString.call(e)}function isObject$1(e){return e&&"[object Object]"==={}.toString.call(e)}var util$5=util$6,slice=util$5.slice,pluck=util$5.pluck,each$6=util$5.each,bind=util$5.bind,create=util$5.create,isList=util$5.isList,isFunction=util$5.isFunction,isObject=util$5.isObject,storeEngine={createStore:createStore},storeAPI={version:"2.0.12",enabled:!1,get:function(e,t){var r=this.storage.read(this._namespacePrefix+e);return this._deserialize(r,t)},set:function(e,t){return void 0===t?this.remove(e):(this.storage.write(this._namespacePrefix+e,this._serialize(t)),t)},remove:function(e){this.storage.remove(this._namespacePrefix+e)},each:function(e){var t=this;this.storage.each((function(r,i){e.call(t,t._deserialize(r),(i||"").replace(t._namespaceRegexp,""))}))},clearAll:function(){this.storage.clearAll()},hasNamespace:function(e){return this._namespacePrefix=="__storejs_"+e+"_"},createStore:function(){return createStore.apply(this,arguments)},addPlugin:function(e){this._addPlugin(e)},namespace:function(e){return createStore(this.storage,this.plugins,e)}};function _warn(){var e="undefined"==typeof console?null:console;if(e){var t=e.warn?e.warn:e.log;t.apply(e,arguments)}}function createStore(e,t,r){r||(r=""),e&&!isList(e)&&(e=[e]),t&&!isList(t)&&(t=[t]);var i=r?"__storejs_"+r+"_":"",n=r?new RegExp("^"+i):null;if(!/^[a-zA-Z0-9_\-]*$/.test(r))throw new Error("store.js namespaces can only have alphanumerics + underscores and dashes");var a={_namespacePrefix:i,_namespaceRegexp:n,_testStorage:function(e){try{var t="__storejs__test__";e.write(t,t);var r=e.read(t)===t;return e.remove(t),r}catch(e){return!1}},_assignPluginFnProp:function(e,t){var r=this[t];this[t]=function(){var t=slice(arguments,0),i=this;function n(){if(r)return each$6(arguments,(function(e,r){t[r]=e})),r.apply(i,t)}var a=[n].concat(t);return e.apply(i,a)}},_serialize:function(e){return JSON.stringify(e)},_deserialize:function(e,t){if(!e)return t;var r="";try{r=JSON.parse(e)}catch(t){r=e}return void 0!==r?r:t},_addStorage:function(e){this.enabled||this._testStorage(e)&&(this.storage=e,this.enabled=!0)},_addPlugin:function(e){var t=this;if(isList(e))each$6(e,(function(e){t._addPlugin(e)}));else if(!pluck(this.plugins,(function(t){return e===t}))){if(this.plugins.push(e),!isFunction(e))throw new Error("Plugins must be function values that return objects");var r=e.call(this);if(!isObject(r))throw new Error("Plugins must return an object of function properties");each$6(r,(function(r,i){if(!isFunction(r))throw new Error("Bad plugin property: "+i+" from plugin "+e.name+". Plugins should only return functions.");t._assignPluginFnProp(r,i)}))}},addStorage:function(e){_warn("store.addStorage(storage) is deprecated. Use createStore([storages])"),this._addStorage(e)}},s=create(a,storeAPI,{plugins:[]});return s.raw={},each$6(s,(function(e,t){isFunction(e)&&(s.raw[t]=bind(s,e))})),each$6(e,(function(e){s._addStorage(e)})),each$6(t,(function(e){s._addPlugin(e)})),s}var util$4=util$6,Global$4=util$4.Global,localStorage_1={name:"localStorage",read:read$5,write:write$5,each:each$5,remove:remove$5,clearAll:clearAll$5};function localStorage(){return Global$4.localStorage}function read$5(e){return localStorage().getItem(e)}function write$5(e,t){return localStorage().setItem(e,t)}function each$5(e){for(var t=localStorage().length-1;t>=0;t--){var r=localStorage().key(t);e(read$5(r),r)}}function remove$5(e){return localStorage().removeItem(e)}function clearAll$5(){return localStorage().clear()}var util$3=util$6,Global$3=util$3.Global,oldFFGlobalStorage={name:"oldFF-globalStorage",read:read$4,write:write$4,each:each$4,remove:remove$4,clearAll:clearAll$4},globalStorage=Global$3.globalStorage;function read$4(e){return globalStorage[e]}function write$4(e,t){globalStorage[e]=t}function each$4(e){for(var t=globalStorage.length-1;t>=0;t--){var r=globalStorage.key(t);e(globalStorage[r],r)}}function remove$4(e){return globalStorage.removeItem(e)}function clearAll$4(){each$4((function(e,t){delete globalStorage[e]}))}var util$2=util$6,Global$2=util$2.Global,oldIEUserDataStorage={name:"oldIE-userDataStorage",write:write$3,read:read$3,each:each$3,remove:remove$3,clearAll:clearAll$3},storageName="storejs",doc$1=Global$2.document,_withStorageEl=_makeIEStorageElFunction(),disable=(Global$2.navigator?Global$2.navigator.userAgent:"").match(/ (MSIE 8|MSIE 9|MSIE 10)\./);function write$3(e,t){if(!disable){var r=fixKey(e);_withStorageEl((function(e){e.setAttribute(r,t),e.save(storageName)}))}}function read$3(e){if(!disable){var t=fixKey(e),r=null;return _withStorageEl((function(e){r=e.getAttribute(t)})),r}}function each$3(e){_withStorageEl((function(t){for(var r=t.XMLDocument.documentElement.attributes,i=r.length-1;i>=0;i--){var n=r[i];e(t.getAttribute(n.name),n.name)}}))}function remove$3(e){var t=fixKey(e);_withStorageEl((function(e){e.removeAttribute(t),e.save(storageName)}))}function clearAll$3(){_withStorageEl((function(e){var t=e.XMLDocument.documentElement.attributes;e.load(storageName);for(var r=t.length-1;r>=0;r--)e.removeAttribute(t[r].name);e.save(storageName)}))}var forbiddenCharsRegex=new RegExp("[!\"#$%&'()*+,/\\\\:;<=>?@[\\]^`{|}~]","g");function fixKey(e){return e.replace(/^\d/,"___$&").replace(forbiddenCharsRegex,"___")}function _makeIEStorageElFunction(){if(!doc$1||!doc$1.documentElement||!doc$1.documentElement.addBehavior)return null;var e,t,r;try{(t=new ActiveXObject("htmlfile")).open(),t.write('<script>document.w=window<\/script><iframe src="/favicon.ico"></iframe>'),t.close(),e=t.w.frames[0].document,r=e.createElement("div")}catch(t){r=doc$1.createElement("div"),e=doc$1.body}return function(t){var i=[].slice.call(arguments,0);i.unshift(r),e.appendChild(r),r.addBehavior("#default#userData"),r.load(storageName),t.apply(this,i),e.removeChild(r)}}var util$1=util$6,Global$1=util$1.Global,trim=util$1.trim,cookieStorage={name:"cookieStorage",read:read$2,write:write$2,each:each$2,remove:remove$2,clearAll:clearAll$2},doc=Global$1.document;function read$2(e){if(!e||!_has(e))return null;var t="(?:^|.*;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(doc.cookie.replace(new RegExp(t),"$1"))}function each$2(e){for(var t=doc.cookie.split(/; ?/g),r=t.length-1;r>=0;r--)if(trim(t[r])){var i=t[r].split("="),n=unescape(i[0]);e(unescape(i[1]),n)}}function write$2(e,t){e&&(doc.cookie=escape(e)+"="+escape(t)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/")}function remove$2(e){e&&_has(e)&&(doc.cookie=escape(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function clearAll$2(){each$2((function(e,t){remove$2(t)}))}function _has(e){return new RegExp("(?:^|;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(doc.cookie)}var util=util$6,Global=util.Global,sessionStorage_1={name:"sessionStorage",read:read$1,write:write$1,each:each$1,remove:remove$1,clearAll:clearAll$1};function sessionStorage(){return Global.sessionStorage}function read$1(e){return sessionStorage().getItem(e)}function write$1(e,t){return sessionStorage().setItem(e,t)}function each$1(e){for(var t=sessionStorage().length-1;t>=0;t--){var r=sessionStorage().key(t);e(read$1(r),r)}}function remove$1(e){return sessionStorage().removeItem(e)}function clearAll$1(){return sessionStorage().clear()}var memoryStorage_1={name:"memoryStorage",read:read,write:write,each:each,remove:remove,clearAll:clearAll},memoryStorage={};function read(e){return memoryStorage[e]}function write(e,t){memoryStorage[e]=t}function each(e){for(var t in memoryStorage)memoryStorage.hasOwnProperty(t)&&e(memoryStorage[t],t)}function remove(e){delete memoryStorage[e]}function clearAll(e){memoryStorage={}}var all=[localStorage_1,oldFFGlobalStorage,oldIEUserDataStorage,cookieStorage,sessionStorage_1,memoryStorage_1],json2$1={},hasRequiredJson2;function requireJson2(){return hasRequiredJson2||(hasRequiredJson2=1,"object"!=typeof JSON&&(JSON={}),function(){var rx_one=/^[\],:{}\s]*$/,rx_two=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,rx_three=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,rx_four=/(?:^|:|,)(?:\s*\[)+/g,rx_escapable=/[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,rx_dangerous=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta,rep;function f(e){return e<10?"0"+e:e}function this_value(){return this.valueOf()}function quote(e){return rx_escapable.lastIndex=0,rx_escapable.test(e)?'"'+e.replace(rx_escapable,(function(e){var t=meta[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)}))+'"':'"'+e+'"'}function str(e,t){var r,i,n,a,s,o=gap,l=t[e];switch(l&&"object"==typeof l&&"function"==typeof l.toJSON&&(l=l.toJSON(e)),"function"==typeof rep&&(l=rep.call(t,e,l)),typeof l){case"string":return quote(l);case"number":return isFinite(l)?String(l):"null";case"boolean":case"null":return String(l);case"object":if(!l)return"null";if(gap+=indent,s=[],"[object Array]"===Object.prototype.toString.apply(l)){for(a=l.length,r=0;r<a;r+=1)s[r]=str(r,l)||"null";return n=0===s.length?"[]":gap?"[\n"+gap+s.join(",\n"+gap)+"\n"+o+"]":"["+s.join(",")+"]",gap=o,n}if(rep&&"object"==typeof rep)for(a=rep.length,r=0;r<a;r+=1)"string"==typeof rep[r]&&(n=str(i=rep[r],l))&&s.push(quote(i)+(gap?": ":":")+n);else for(i in l)Object.prototype.hasOwnProperty.call(l,i)&&(n=str(i,l))&&s.push(quote(i)+(gap?": ":":")+n);return n=0===s.length?"{}":gap?"{\n"+gap+s.join(",\n"+gap)+"\n"+o+"}":"{"+s.join(",")+"}",gap=o,n}}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},Boolean.prototype.toJSON=this_value,Number.prototype.toJSON=this_value,String.prototype.toJSON=this_value),"function"!=typeof JSON.stringify&&(meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},JSON.stringify=function(e,t,r){var i;if(gap="",indent="","number"==typeof r)for(i=0;i<r;i+=1)indent+=" ";else"string"==typeof r&&(indent=r);if(rep=t,t&&"function"!=typeof t&&("object"!=typeof t||"number"!=typeof t.length))throw new Error("JSON.stringify");return str("",{"":e})}),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){var j;function walk(e,t){var r,i,n=e[t];if(n&&"object"==typeof n)for(r in n)Object.prototype.hasOwnProperty.call(n,r)&&(void 0!==(i=walk(n,r))?n[r]=i:delete n[r]);return reviver.call(e,t,n)}if(text=String(text),rx_dangerous.lastIndex=0,rx_dangerous.test(text)&&(text=text.replace(rx_dangerous,(function(e){return"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)}))),rx_one.test(text.replace(rx_two,"@").replace(rx_three,"]").replace(rx_four,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}()),json2$1}var json2=json2Plugin;function json2Plugin(){return requireJson2(),{}}var engine=storeEngine,storages=all,plugins=[json2],store_legacy=engine.createStore(storages,plugins);class SallaStorage{constructor(e){e.on("storage::item.remove",(e=>this.remove(e))),e.on("storage::item.set",((e,t)=>this.set(e,t))),this.store=store_legacy}set(e,t){if(e.includes(".")){let r=e.split(".")[0],i={[r]:store_legacy.get(r)};return i=salla.helpers.setNested(i,e,t),store_legacy.set(r,i[r])}return store_legacy.set(e,t)}remove(e){return store_legacy.remove(e)}get(e,t){if(e.includes(".")){let t=e.split(".")[0];return salla.helpers.getNested({[t]:store_legacy.get(t)},e)}return store_legacy.get(e,t)}}let event$1=new sallaEmitter,api=new SallaApi(event$1);window.Salla=window.salla={notify:Notify,api:api,event:event$1,helpers:Helpers,config:new SallaConfig,storage:new SallaStorage(event$1),cookie:new SallaCookie(event$1),lang:new SallaLang,form:new SallaForm,cart:new Action(api.cart,event$1.cart),auth:new Action(api.auth,event$1.auth),gift:new Action(api.gift,event$1.gift),order:new Action(api.order,event$1.order),scope:new Action(api.scope,event$1.scope),rating:new Action(api.rating,event$1.rating),comment:new Action(api.comment,event$1.comment),loyalty:new Action(api.loyalty,event$1.loyalty),product:new Action(api.product,event$1.product),profile:new Action(api.profile,event$1.profile),currency:new Action(api.currency,event$1.currency),document:new Action(api.document,event$1.document),twilight:new Action(api.twilight,event$1.twilight),wishlist:new Action(api.wishlist,event$1.wishlist),logger:Logger,log:Logger.log,success:Notify.success,error:Notify.error,onReady:e=>salla.isInitiated?e():salla.event.once("twilight::initiated",e),isInitiated:!1,AppHelpers:AppHelpers,infiniteScroll:new InfiniteScroll(void 0,event$1.infiniteScroll),money:Helpers.money,url:Helpers.url,init:e=>api.twilight.init(e),call:e=>{let t=salla,r=e.split(".");for(;r.length&&(t=t[r.shift()]););return t},version:version};var salla$1=salla;exports.default=salla$1}));
|
|
26
|
+
*/!function(e,t){e.exports=function(){function e(){if("undefined"!=typeof document&&document.documentElement)return document.documentElement.lang}function t(e){return"-Inf"===e?-1/0:"+Inf"===e||"Inf"===e||"*"===e?1/0:parseInt(e,10)}var r=/^({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])$/,n=/({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])/,i={locale:"en"},s=function(t){t=t||{},this.locale=t.locale||e()||i.locale,this.fallback=t.fallback,this.messages=t.messages};return s.prototype.setMessages=function(e){this.messages=e},s.prototype.getLocale=function(){return this.locale||this.fallback},s.prototype.setLocale=function(e){this.locale=e},s.prototype.getFallback=function(){return this.fallback},s.prototype.setFallback=function(e){this.fallback=e},s.prototype.has=function(e,t){return!("string"!=typeof e||!this.messages)&&null!==this._getMessage(e,t)},s.prototype.get=function(e,t,r){if(!this.has(e,r))return e;var n=this._getMessage(e,r);return null===n?e:(t&&(n=this._applyReplacements(n,t)),n)},s.prototype.trans=function(e,t){return this.get(e,t)},s.prototype.choice=function(e,t,r,i){(r=void 0!==r?r:{}).count=t;var s=this.get(e,r,i);if(null==s)return s;for(var a=s.split("|"),o=[],l=0;l<a.length;l++)if(a[l]=a[l].trim(),n.test(a[l])){var c=a[l].split(/\s/);o.push(c.shift()),a[l]=c.join(" ")}if(1===a.length)return s;for(var u=0;u<o.length;u++)if(this._testInterval(t,o[u]))return a[u];return i=i||this._getLocale(e),a[this._getPluralForm(t,i)]},s.prototype.transChoice=function(e,t,r){return this.choice(e,t,r)},s.prototype._parseKey=function(e,t){if("string"!=typeof e||"string"!=typeof t)return null;var r=e.split("."),n=r[0].replace(/\//g,".");return{source:t+"."+n,sourceFallback:this.getFallback()+"."+n,entries:r.slice(1)}},s.prototype._getMessage=function(e,t){if(t=t||this.getLocale(),e=this._parseKey(e,t),void 0===this.messages[e.source]&&void 0===this.messages[e.sourceFallback])return null;var r=this.messages[e.source],n=e.entries.slice(),i=n.join(".");if("string"!=typeof(r=void 0!==r?this._getValueInKey(r,i):void 0)&&this.messages[e.sourceFallback])for(r=this.messages[e.sourceFallback],n=e.entries.slice(),i="";n.length&&void 0!==r;)r[i=i?i.concat(".",n.shift()):n.shift()]&&(r=r[i],i="");return"string"!=typeof r?null:r},s.prototype._getValueInKey=function(e,t){if("string"==typeof e[t])return e[t];for(var r=(t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"")).split("."),n=0,i=r.length;n<i;++n){var s=r.slice(0,n+1).join("."),a=r.slice(n+1,r.length).join(".");if(e[s])return this._getValueInKey(e[s],a)}return e},s.prototype._getLocale=function(e){return e=this._parseKey(e,this.locale),this.messages[e.source]?this.locale:this.messages[e.sourceFallback]?this.fallback:null},s.prototype._findMessageInTree=function(e,t){for(;e.length&&void 0!==t;){var r=e.join(".");if(t[r]){t=t[r];break}t=t[e.shift()]}return t},s.prototype._sortReplacementKeys=function(e,t){return t.length-e.length},s.prototype._applyReplacements=function(e,t){return Object.keys(t).sort(this._sortReplacementKeys).forEach((function(r){e=e.replace(new RegExp(":"+r,"gi"),(function(e){var n=t[r];return e===e.toUpperCase()?n.toUpperCase():e===e.replace(/\w/i,(function(e){return e.toUpperCase()}))?n.charAt(0).toUpperCase()+n.slice(1):n}))})),e},s.prototype._testInterval=function(e,n){if("string"!=typeof n)throw"Invalid interval: should be a string.";var i=(n=n.trim()).match(r);if(!i)throw"Invalid interval: "+n;if(!i[2]){var s=(i=i.filter((function(e){return!!e})))[1],a=t(i[2]);a===1/0&&(a=-1/0);var o=t(i[3]),l=i[4];return("["===s?e>=a:e>a)&&("]"===l?e<=o:e<o)}for(var c=i[2].split(","),u=0;u<c.length;u++)if(parseInt(c[u],10)===e)return!0;return!1},s.prototype._getPluralForm=function(e,t){switch(t){case"az":case"bo":case"dz":case"id":case"ja":case"jv":case"ka":case"km":case"kn":case"ko":case"ms":case"th":case"tr":case"vi":case"zh":default:return 0;case"af":case"bn":case"bg":case"ca":case"da":case"de":case"el":case"en":case"eo":case"es":case"et":case"eu":case"fa":case"fi":case"fo":case"fur":case"fy":case"gl":case"gu":case"ha":case"he":case"hu":case"is":case"it":case"ku":case"lb":case"ml":case"mn":case"mr":case"nah":case"nb":case"ne":case"nl":case"nn":case"no":case"om":case"or":case"pa":case"pap":case"ps":case"pt":case"so":case"sq":case"sv":case"sw":case"ta":case"te":case"tk":case"ur":case"zu":return 1==e?0:1;case"am":case"bh":case"fil":case"fr":case"gun":case"hi":case"hy":case"ln":case"mg":case"nso":case"xbr":case"ti":case"wa":return 0===e||1===e?0:1;case"be":case"bs":case"hr":case"ru":case"sr":case"uk":return e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2;case"cs":case"sk":return 1==e?0:e>=2&&e<=4?1:2;case"ga":return 1==e?0:2==e?1:2;case"lt":return e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2;case"sl":return e%100==1?0:e%100==2?1:e%100==3||e%100==4?2:3;case"mk":return e%10==1?0:1;case"mt":return 1==e?0:0===e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3;case"lv":return 0===e?0:e%10==1&&e%100!=11?1:2;case"pl":return 1==e?0:e%10>=2&&e%10<=4&&(e%100<12||e%100>14)?1:2;case"cy":return 1==e?0:2==e?1:8==e||11==e?2:3;case"ro":return 1==e?0:0===e||e%100>0&&e%100<20?1:2;case"ar":return 0===e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11&&e%100<=99?4:5}},s}()}(Vi);var Wi=Vi.exports;var Ji=Object.assign?Object.assign:function(e,t,r,n){for(var i=1;i<arguments.length;i++)es(Object(arguments[i]),(function(t,r){e[r]=t}));return e},Qi=function(){if(Object.create)return function(e,t,r,n){var i=Xi(arguments,1);return Ji.apply(this,[Object.create(e)].concat(i))};{function e(){}return function(t,r,n,i){var s=Xi(arguments,1);return e.prototype=t,Ji.apply(this,[new e].concat(s))}}}(),Ki=String.prototype.trim?function(e){return String.prototype.trim.call(e)}:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},Yi="undefined"!=typeof window?window:w,Zi={assign:Ji,create:Qi,trim:Ki,bind:function(e,t){return function(){return t.apply(e,Array.prototype.slice.call(arguments,0))}},slice:Xi,each:es,map:function(e,t){var r=rs(e)?[]:{};return ts(e,(function(e,n){return r[n]=t(e,n),!1})),r},pluck:ts,isList:rs,isFunction:function(e){return e&&"[object Function]"==={}.toString.call(e)},isObject:function(e){return e&&"[object Object]"==={}.toString.call(e)},Global:Yi};function Xi(e,t){return Array.prototype.slice.call(e,t||0)}function es(e,t){ts(e,(function(e,r){return t(e,r),!1}))}function ts(e,t){if(rs(e)){for(var r=0;r<e.length;r++)if(t(e[r],r))return e[r]}else for(var n in e)if(e.hasOwnProperty(n)&&t(e[n],n))return e[n]}function rs(e){return null!=e&&"function"!=typeof e&&"number"==typeof e.length}var ns=Zi.slice,is=Zi.pluck,ss=Zi.each,as=Zi.bind,os=Zi.create,ls=Zi.isList,cs=Zi.isFunction,us=Zi.isObject,hs={createStore:fs},ds={version:"2.0.12",enabled:!1,get:function(e,t){var r=this.storage.read(this._namespacePrefix+e);return this._deserialize(r,t)},set:function(e,t){return void 0===t?this.remove(e):(this.storage.write(this._namespacePrefix+e,this._serialize(t)),t)},remove:function(e){this.storage.remove(this._namespacePrefix+e)},each:function(e){var t=this;this.storage.each((function(r,n){e.call(t,t._deserialize(r),(n||"").replace(t._namespaceRegexp,""))}))},clearAll:function(){this.storage.clearAll()},hasNamespace:function(e){return this._namespacePrefix=="__storejs_"+e+"_"},createStore:function(){return fs.apply(this,arguments)},addPlugin:function(e){this._addPlugin(e)},namespace:function(e){return fs(this.storage,this.plugins,e)}};function fs(e,t,r){r||(r=""),e&&!ls(e)&&(e=[e]),t&&!ls(t)&&(t=[t]);var n=r?"__storejs_"+r+"_":"",i=r?new RegExp("^"+n):null;if(!/^[a-zA-Z0-9_\-]*$/.test(r))throw new Error("store.js namespaces can only have alphanumerics + underscores and dashes");var s={_namespacePrefix:n,_namespaceRegexp:i,_testStorage:function(e){try{var t="__storejs__test__";e.write(t,t);var r=e.read(t)===t;return e.remove(t),r}catch(e){return!1}},_assignPluginFnProp:function(e,t){var r=this[t];this[t]=function(){var t=ns(arguments,0),n=this;function i(){if(r)return ss(arguments,(function(e,r){t[r]=e})),r.apply(n,t)}var s=[i].concat(t);return e.apply(n,s)}},_serialize:function(e){return JSON.stringify(e)},_deserialize:function(e,t){if(!e)return t;var r="";try{r=JSON.parse(e)}catch(t){r=e}return void 0!==r?r:t},_addStorage:function(e){this.enabled||this._testStorage(e)&&(this.storage=e,this.enabled=!0)},_addPlugin:function(e){var t=this;if(ls(e))ss(e,(function(e){t._addPlugin(e)}));else if(!is(this.plugins,(function(t){return e===t}))){if(this.plugins.push(e),!cs(e))throw new Error("Plugins must be function values that return objects");var r=e.call(this);if(!us(r))throw new Error("Plugins must return an object of function properties");ss(r,(function(r,n){if(!cs(r))throw new Error("Bad plugin property: "+n+" from plugin "+e.name+". Plugins should only return functions.");t._assignPluginFnProp(r,n)}))}},addStorage:function(e){!function(){var e="undefined"==typeof console?null:console;if(e){(e.warn?e.warn:e.log).apply(e,arguments)}}("store.addStorage(storage) is deprecated. Use createStore([storages])"),this._addStorage(e)}},a=os(s,ds,{plugins:[]});return a.raw={},ss(a,(function(e,t){cs(e)&&(a.raw[t]=as(a,e))})),ss(e,(function(e){a._addStorage(e)})),ss(t,(function(e){a._addPlugin(e)})),a}var ps=Zi.Global,gs={name:"localStorage",read:vs,write:function(e,t){return ms().setItem(e,t)},each:function(e){for(var t=ms().length-1;t>=0;t--){var r=ms().key(t);e(vs(r),r)}},remove:function(e){return ms().removeItem(e)},clearAll:function(){return ms().clear()}};function ms(){return ps.localStorage}function vs(e){return ms().getItem(e)}var ys=Zi.Global,bs={name:"sessionStorage",read:_s,write:function(e,t){return ws().setItem(e,t)},each:function(e){for(var t=ws().length-1;t>=0;t--){var r=ws().key(t);e(_s(r),r)}},remove:function(e){return ws().removeItem(e)},clearAll:function(){return ws().clear()}};function ws(){return ys.sessionStorage}function _s(e){return ws().getItem(e)}var Es=Zi.trim,Ss={name:"cookieStorage",read:function(e){if(!e||!Fs(e))return null;var t="(?:^|.*;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(xs.cookie.replace(new RegExp(t),"$1"))},write:function(e,t){if(!e)return;xs.cookie=escape(e)+"="+escape(t)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:As,remove:Ps,clearAll:function(){As((function(e,t){Ps(t)}))}},xs=Zi.Global.document;function As(e){for(var t=xs.cookie.split(/; ?/g),r=t.length-1;r>=0;r--)if(Es(t[r])){var n=t[r].split("="),i=unescape(n[0]);e(unescape(n[1]),i)}}function Ps(e){e&&Fs(e)&&(xs.cookie=escape(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function Fs(e){return new RegExp("(?:^|;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(xs.cookie)}var Ls={name:"memoryStorage",read:function(e){return Os[e]},write:function(e,t){Os[e]=t},each:function(e){for(var t in Os)Os.hasOwnProperty(t)&&e(Os[t],t)},remove:function(e){delete Os[e]},clearAll:function(e){Os={}}},Os={};const ks=hs.createStore([gs,bs,Ss,Ls],[]);let Ts=new class extends S{constructor(){super({wildcard:!0,delimiter:"::",newListener:!1,removeListener:!1,maxListeners:10,verboseMemoryLeak:!1,ignoreErrors:!1}),this.globalListners={},this.delimiter="::",this.auth=new o(this),this.cart=new l(this),this.order=new c(this),this.scope=new u(this),this.rating=new h(this),this.comment=new d(this),this.loyalty=new f(this),this.product=new g(this),this.profile=new p(this),this.currency=new y(this),this.document=new m(this),this.twilight=new b(this),this.wishlist=new v(this),this.infiniteScroll=new x(this),this.body=document.querySelector("body"),this.logableEvents=["cart::item.added.failed","cart::item.deleted.failed"],this.ingoreLogEvents=["document::click","document::keyup","document::change"],this.noneFireableActions=["document.request"],this.on("twilight::initiated",this.initiateSallaInAllClasses)}initiateSallaInAllClasses(){let e=this;Object.keys(salla).forEach((t=>{"object"==typeof(t=salla[t])&&(e.callSallaInitiate(t),Object.keys(t).forEach((r=>{e.callSallaInitiate(t[r])})))}))}callSallaInitiate(e){e&&e.sallaInitiated&&!e.initiated&&(e.sallaInitiated(),e.initiated=!0)}createAndDispatch(e,...t){this.dispatch(e,...t)}dispatch(e,...t){let r=e.replace("::",".");if(!this.noneFireableActions.includes(r)&&"function"==typeof salla.call(r))return salla.log(`'salla.${r}(...)' triggered using event '${e}'`),r=r.split("."),void salla[r[0]][r[1]](...t);this.emit(e,...t),window.dataLayer=window.dataLayer||[],window.dataLayer.push(Object.assign({event:e},...t.values())),this.ingoreLogEvents.includes(e)||!salla.config.get("debug")&&!this.logableEvents.includes(e)||salla.logger.event(e,...t);let n=this;Object.keys(this.globalListners).forEach((function(r){n.globalListners[r](e,...t)})),this.dispatchMobileEvent(e,{...t.values()})}dispatchEvents(e){if(e&&"object"==typeof e)for(const[t,r]of Object.entries(e))this.dispatch(t,r);else salla.log("No Events To Dispatch!",e)}addListener(e,t){this.on(e,t)}addEventListener(e,t){this.addListener(e,t)}listen(e,t){this.addListener(e,t)}registerGlobalListener(e,t){this.globalListners[e]=t}dispatchMobileEvent(e,t={}){if(!(window.dataLayer&&dataLayer[0]&&dataLayer[0].page&&dataLayer[0].page.mobileApp))return"";if(window.webkit)try{window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:e,details:t}))}catch(e){console.log(e,"The native context does not exist yet")}else if(Android)try{Android.customEventWithData(e,JSON.stringify({details:t}))}catch(e){console.log(e,"The native context does not exist yet")}}},js=new class extends class{constructor(e){return e.on("twilight::initiated",(()=>this.initiateRequest())),e.on("profile::info.fetched",this.setCurrencyAndLanguage),e.on("auth::token.fetched",(e=>this.handleToken(e))),e.on("document::request.failed",((e,t)=>{salla.logger.warn(t,e)})),Vt.create({headers:{common:{"X-Requested-With":"XMLHttpRequest","S-SOURCE":"twilight","S-APP-VERSION":"v2.0.0","S-APP-OS":"browser"}}})}initiateRequest(){salla.api.defaults.baseURL=salla.config.get("store.api",salla.config.get("store.url")),salla.api.defaults.headers.common["Store-Identifier"]=salla.config.get("store.id"),salla.api.defaults.headers.common.currency=salla.config.get("user.currency_code","SAR"),salla.infiniteScroll.fetchOptions.headers["Accept-Language"]=salla.api.defaults.headers.common["accept-language"]=salla.lang.getLocale(),salla.api.defaults.headers.common["s-user-id"]=salla.config.get("user.id"),salla.api.defaults.headers.common["s-scope"]=salla.storage.get("scope"),this.injectTokenToTheRequests()}injectTokenToTheRequests(){let e=salla.storage.get("token"),t=salla.config.isGuest(),r=salla.storage.get("cart");if(r&&(r.user_id!==salla.config.get("user.id")||r.store_id!==salla.config.get("store.id")))return salla.log("Auth:: The cart is not belong to current "+(r.user_id!==salla.config.get("user.id")?"user":"store")+"!"),void salla.cart.api.reset();if(t&&!e)return;if(t&&e)return salla.log("Auth:: Token without user!"),salla.storage.remove("token"),void salla.cart.api.reset();if(!e)return salla.cart.api.reset(),void salla.auth.api.refresh();let n=function(e,t){if("string"!=typeof e)throw new Kt("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(Qt(e.split(".")[r]))}catch(e){throw new Kt("Invalid token specified: "+e.message)}}(e);return Date.now()/1e3>n.exp?(salla.log("Auth:: An expired token!"),salla.storage.remove("token"),salla.cart.api.reset(),void salla.auth.api.refresh()):n.sub!==salla.config.get("user.id")?(salla.log("Auth:: The user id is not match the token details!"),salla.storage.remove("token"),salla.cart.api.reset(),void salla.auth.api.refresh()):void this.setToken(e)}handleToken(e){salla.storage.set("token",e),this.setToken(e),salla.cart.api.reset()}setToken(e){salla.api.defaults.headers.common.Authorization="Bearer "+e}setCurrencyAndLanguage(e){salla.api.defaults.headers.common.currency=e.data.currency,salla.api.defaults.headers.common["accept-language"]=e.data.language,salla.infiniteScroll.fetchOptions.headers["Accept-Language"]=e.data.language}}{constructor(e){super(e),this.apis={auth:new L(this),cart:new P(this),loyalty:new F(this),order:new O(this),rating:new I(this),product:new k(this),profile:new T(this),comment:new j(this),currency:new C(this),document:new R(this),twilight:new N(this),wishlist:new D(this),scope:new U(this),withoutNotifier:async e=>(salla.config.set("sdk.notifier_handler_disabled",!0),await e().finally((()=>{salla.config.set("sdk.notifier_handler_disabled",!1)})))},Object.assign(this,this.apis),this.getHeaders=()=>this.defaults.headers.common}}(Ts);window.Salla=window.salla={notify:i,api:js,event:Ts,helpers:Gi,config:new class{constructor(e={}){this.triedToGetCurrencies_=!1,this.languages_=[],this.triedToGetLanguages_=!1,this.currencies_={},this.default_properties={debug:"undefined"!=typeof process&&"development"===process.env.NODE_ENV,token:null,fastRequests:!0,canLeave:!0,store:{api:"https://api.salla.dev/store/v1/"},currencies:{SAR:{code:"SAR",name:"ريال سعودي",symbol:"ر.س",amount:1,country_code:"sa"}}},this.properties_={...this.default_properties,...e}}merge(e){return Object.assign(this.properties_,e),this.properties_.store={...this.default_properties.store,...this.properties_.store},this}set(e,t){return e.includes(".")?(salla.helpers.setNested(this.properties_,e,t),this):(this.properties_[e]=t,this)}get(e,t=null){return e.includes(".")?salla.helpers.getNested(this.properties_,e,t):this.properties_.hasOwnProperty(e)?this.properties_[e]||t:t||void 0}isUser(){return"user"===this.get("user.type")}isGuest(){return!this.isUser()}async languages(){if(this.triedToGetLanguages_)return this.languages_;this.triedToGetLanguages_=!0;let e=!0;return(await salla.document.api.request("languages",null,"get"))?.data?.map((t=>{e&&(this.languages_=[],e=!1),t.code=t.code||t.iso_code,t.url=salla.url.get(t.code),t.is_rtl=t.is_rtl||t.rtl,this.languages_.push(t)})),this.set("languages",this.languages_),this.languages_}async currencies(){if(this.triedToGetCurrencies_)return this.currencies_;this.triedToGetCurrencies_=!0;let e=!0;return(await salla.currency.api.list())?.data?.map((t=>{e&&(this.currencies_={},e=!1),t.country_code=t.code.substr(0,2).toLowerCase(),this.currencies_[t.code]=t})),this.set("currencies",this.currencies_),this.currencies_}currency(e){return e=e||this.get("user.currency_code"),this.get("currencies."+e)||Object.values(this.get("currencies"))[0]}},storage:new class{constructor(e){e.on("storage::item.remove",(e=>this.remove(e))),e.on("storage::item.set",((e,t)=>this.set(e,t))),this.store=ks}set(e,t){if(e.includes(".")){let r=e.split(".")[0],n={[r]:ks.get(r)};return n=salla.helpers.setNested(n,e,t),ks.set(r,n[r])}return ks.set(e,t)}remove(e){return ks.remove(e)}get(e,t){if(e.includes(".")){let t=e.split(".")[0];return salla.helpers.getNested({[t]:ks.get(t)},e)}return ks.get(e,t)}}(Ts),cookie:new class{constructor(e){e.on("cookies::remove",(e=>this.remove(e))),e.on("cookies::add",((e,t)=>this.set(e,t)))}get(e){return document.cookie.split("; ").find((t=>t.startsWith(e+"=")))?.split("=")[1]}set(e,t="",r=10){let n="";if(r){let e=new Date;e.setTime(e.getTime()+24*r*60*60*1e3),n="; expires="+e.toUTCString()}return document.cookie=`${e}=${t}${n}"; path=/; secure; SameSite=Lax"`,this}remove(e){return document.cookie=`${e}=; Max-Age=0; path=/;`,this}}(Ts),lang:new class extends Wi{constructor(e){(e=e||{}).messages=e.messages||window.translations,e.locale=e.locale||(window.locale||navigator.language||navigator.userLanguage||"ar").split("-")[0],e.fallback=e.fallback||e.locale,super(e),this.translationsLoaded=!1}onLoaded(e){if(this.translationsLoaded)return e();salla.event.once("languages::translations.loaded",e)}loadStoreTranslations(){if(this.messages)return void window.addEventListener("load",(e=>{salla.event.dispatch("languages::translations.loaded"),salla.logger.info("The messages of transactions is already loaded")}));if(!salla.url.get(""))return this.messages&&salla.event.dispatch("languages::translations.loaded"),this.translationsLoaded=!0,void salla.logger.warn("There is no `store.url` to auto loading translations from it!");let e=salla.config.get("theme.translations_hash",salla.config.get("store.id","twilight")),t=document.createElement("script");t.src=salla.url.get(`languages/assets/${e}.js`),t.onload=()=>{if(window.translations)return this.setMessages(window.translations),salla.event.dispatch("languages::translations.loaded"),void(this.translationsLoaded=!0);console.warn('You should load Salla Translations Before!\nUse: <script src="{{ link("languages/assets/{theme.translations_hash}.js") }}"><\/script>\nor: salla.lang.setMessages({....}), see https://github.com/rmariuzzo/Lang.js for more informations.')},document.head.appendChild(t)}get(e,t,r){return window.translations&&(e="trans."+e),super.get(e,t,r)}set(e,t){return salla.helpers.setNested(this.messages[this.getLocale()+".trans"],e,t),this}},form:new class{async submit(e,t=null){let r=t;if("SubmitEvent"===t?.constructor?.name){if(t.preventDefault(),"FORM"!==t.target?.tagName)return salla.logger.warn("Failed find the target element for submit action. make sure you submit a form element"),new Promise((()=>{throw"Failed find the target element for submit action. make sure you submit a form element"}));"SALLA-BUTTON"===t?.submitter?.parentElement?.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.twilight.request(e,r,"post").finally((()=>{loaderSupported&&t?.submitter?.parentElement.stop()}));let n=e.split("."),i=n.splice(-1);return await salla.call(n.join("."))[i](r).finally((()=>t?.submitter?.parentElement?.stop())).catch((e=>{throw salla.logger.warn(e),e}))}onSubmit(e,t){return salla.form.submit(e,t),!1}onChange(e,t){return t?.currentTarget?"FORM"!==t?.currentTarget?.tagName||t.currentTarget.checkValidity()?(salla.form.submit(e,t.currentTarget.getElementSallaData()),!0):(salla.logger.warn(`Trying to trigger '${e}' without filling required fields!`),!1):(salla.logger.warn(`Trying to trigger '${e}' without event!`),!1)}},cart:new Yt(js.cart,Ts.cart),auth:new Yt(js.auth,Ts.auth),gift:new Yt(js.gift,Ts.gift),order:new Yt(js.order,Ts.order),scope:new Yt(js.scope,Ts.scope),rating:new Yt(js.rating,Ts.rating),comment:new Yt(js.comment,Ts.comment),loyalty:new Yt(js.loyalty,Ts.loyalty),product:new Yt(js.product,Ts.product),profile:new Yt(js.profile,Ts.profile),currency:new Yt(js.currency,Ts.currency),document:new Yt(js.document,Ts.document),twilight:new Yt(js.twilight,Ts.twilight),wishlist:new Yt(js.wishlist,Ts.wishlist),logger:s,log:s.log,success:i.success,error:i.error,onReady:e=>salla.isInitiated?e():salla.event.once("twilight::initiated",e),isInitiated:!1,AppHelpers:class{toggleClassIf(e,t,r,n){return document.querySelectorAll(e).forEach((e=>this.toggleElementClassIf(e,t,r,n))),this}toggleElementClassIf(e,t,r,n){t=Array.isArray(t)?t:t.split(" "),r=Array.isArray(r)?r:r.split(" ");let i=n(e);return e?.classList.remove(...i?r:t),e?.classList.add(...i?t:r),this}isValidEmail(e){return/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(e).toLowerCase())}element(e){return"object"==typeof e?e:document.querySelector(e)}watchElement(e,t){return this[e]=this.element(t),this}watchElements(e){return Object.entries(e).forEach((e=>this.watchElement(e[0],e[1]))),this}on(e,t,r,n={}){return"object"==typeof t?(this.element(t).addEventListener(e,r,n),this):(document.querySelectorAll(t).forEach((t=>t.addEventListener(e,r,n))),this)}onClick(e,t){return this.on("click",e,t)}onKeyUp(e,t){return this.on("keyup",e,t)}onEnter(e,t){return this.onKeyUp(e,(e=>13===e.keyCode&&t(e))),this}all(e,t){return document.querySelectorAll(e).forEach(t),this}hideElement(e){return this.element(e).style.display="none",this}showElement(e,t="block"){return this.element(e).style.display=t,this}removeClass(e,t){return this.element(e).classList.remove(...Array.from(arguments).slice(1)),this}addClass(e,t){return this.element(e).classList.add(...Array.from(arguments).slice(1)),this}debounce(e,...t){return this.debounce_||(this.debounce_=salla.helpers.debounce(((e,...t)=>e(...t)),500)),this.debounce_(e,...t)}},infiniteScroll:new class extends Yt{constructor(e,t){super(e,t),this.options={path:".infinite-scroll-btn",history:"push",status:".infinite-scroll-status",append:".list-block"},this.fetchOptions={headers:{"S-INFINITE-SCROLL":!0}},this.instances=[]}initiate(e,t,r){r=this.getCustomOptions(t,r);let n="string"!=typeof e?e:document.querySelector(e),i=r.path;if(!n||!i||"string"==typeof i&&!document.querySelector(i))return void salla.logger.warn(n?"Path Option (a link that has next page link) Not Existed!":"Container For InfiniteScroll not Existed!");let s=new Sr(n,r);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}getCustomOptions(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}}(void 0,Ts.infiniteScroll),money:Gi.money,url:Gi.url,init:e=>js.twilight.init(e),call:e=>{let t=salla,r=e.split(".");for(;r.length&&(t=t[r.shift()]););return t}};var Cs=salla;e.default=Cs,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
28
27
|
//# sourceMappingURL=twilight.min.js.map
|