@salla.sa/twilight 2.15.1-alpha.0 → 3.0.0-beta.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/README.md +37 -3
- package/dist/@salla.sa/twilight.min.js +1 -19
- package/dist/@salla.sa/twilight.min.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +74 -70
- package/types/api/cart/index.d.ts +1 -1
- package/types/api/index.d.ts +7 -1
- package/types/api/loyalty.d.ts +10 -1
- package/types/api/metadata.d.ts +33 -0
- package/types/api/order.d.ts +18 -2
- package/types/api/product/request.d.ts +2 -1
- package/types/api/profile.d.ts +5 -0
- package/types/common.d.ts +20 -1
- package/types/event/index.d.ts +3 -0
- package/types/event/loyalty.d.ts +5 -1
- package/types/event/metadata.d.ts +7 -0
- package/types/event/product.d.ts +1 -1
- package/types/lib/lang.d.ts +2 -1
- package/types/tiwlight-config.d.ts +221 -18
- package/watcher.js +1 -1
|
@@ -1,20 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("lodash/get.js"),require("eventemitter2"),require("store/src/store-engine"),require("store/storages/localStorage"),require("store/storages/sessionStorage"),require("store/storages/cookieStorage"),require("store/storages/memoryStorage"),require("ev-emitter"),require("fizzy-ui-utils")):"function"==typeof define&&define.amd?define(["lodash/get.js","eventemitter2","store/src/store-engine","store/storages/localStorage","store/storages/sessionStorage","store/storages/cookieStorage","store/storages/memoryStorage","ev-emitter","fizzy-ui-utils"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).Salla=t(e.t$1,e.eventemitter2,e.r$1,e.n$1,e.o$1,e.i,e.a,e.evEmitter,e.fizzyUiUtils)}(this,(function(e,t,r,a,n,i,s,o,l){"use strict";function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function u(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var d=c(e),h=u(r),f=u(a),p=u(n),g=u(i),m=u(s),v=u(o),y=u(l),w="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function b(e,t){void 0===t&&(t=!1),e+="";for(var r,a=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],n=["0","1","2","3","4","5","6","7","8","9"],i=(t=t||!Salla.config.get("store.settings.arabic_numbers_enabled"))?a:n,s=t?n:a,o=0;o<i.length;o++)r=new RegExp(i[o],"g"),e=e.replace(r,s[o]);return e.replace(t?"٫":".",t?".":"٫")}function S(e){var t=("".concat(e).match(/\./g)||[]).length;return t&&1!==t?S(e.replace(/\.(.+)\./g,".$1")):e}function E(e){return"".concat(e).startsWith("https://")||"".concat(e).startsWith("http://")}function _(e){if(E(e))return e;var t=Salla.config.get("store.url");return t||(t=window.location.href.split("/").slice(0,-1).join("/"),Salla.config.set("store.url",t)),t.rtrim("/")+"/"+(null==e?void 0:e.ltrim("/"))}function A(e,t,r){if(r=r||window.location.href,!t||!e)return r;var a=new RegExp("([?&])"+e+"=[^&]+[&]?","g");return(r=r.replace(a,"$1").split("#")[0].replace(/&$|\?$/,"")).includes("?")?r+="&":r+=(r.endsWith("/")?"":"/")+"?",(r+e+"="+encodeURIComponent(t)).replace(/&$|\?$/,"")}function F(e){return window.location.origin+"/"+(null==e?void 0:e.ltrim("/"))}function P(e){return E(e)?e:Salla.config.get("theme.assets")?Salla.config.get("theme.assets").replace(":path",null==e?void 0:e.ltrim("/")):F("themes/"+Salla.config.get("theme.name")+"/"+(null==e?void 0:e.ltrim("/")))}function x(e,t,r){var a,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]=x(e.slice(1),t,r[n]),r):n?((a={})[n]=x(e.slice(1),t),a):""===n?[t]:t}function T(){return window.self!==window.top}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.toString():"#"+this.toString()},String.prototype.replaceArray=function(e,t){for(var r,a=this,n=0;n<e.length;n++)r=new RegExp(e[n],"g"),a=a.replace(r,t[n]);return a},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)};var R={digitsOnly:function(e){return b(e,!0).replace(/[^0-9.]/g,"").replace("..",".").rtrim(".")},inputDigitsOnly:function e(t,r){if(void 0===r&&(r=!1),"string"==typeof t)return document.querySelectorAll(t).forEach((function(t){return e(t,r)}));if(t){var a=Salla.helpers.digitsOnly(t.value);return t.min&&a<parseInt(t.min)?t.value=t.min:t.max&&a>parseInt(t.max)?t.value=t.max:t.maxLength>=1&&a.toString().length>t.maxLength?t.value=a.toString().substring(0,t.maxLength):t.value=r||t.dataset.hasOwnProperty("digitsWithDecimal")?S(a):a.replace(/\D/g,"")}Salla.logger.warn("Can't find Object With Id: "+t)},number:b,money:function(e){var t=Salla.config.currency(null==e?void 0:e.currency).symbol;return b(e="object"==typeof e?e.amount:e)+" "+t},isIframe:T,isPreview:function(){return T()},setNested:function(e,t,r){for(var a=e,n=t.split("."),i=n.length,s=0;s<i-1;s++){var o=n[s];a[o]||(a[o]={}),a=a[o]}return a[n[i-1]]=r,e},getNested:function(e,t,r){var a=d.default(e,t);return void 0!==a?a:r},inputData:function(e,t,r){if(void 0===r&&(r={}),e.includes("[")){var a=e.split("]").join("").split("["),n=a[0],i=r&&"object"==typeof r?r[n]:void 0;return{name:n,value:x(a.slice(1),t,i)}}return{name:e,value:t}},url:Object.freeze({__proto__:null,is_full_url:E,base:function(e){return E(e)?e:"https://"+new URL(_("/")).hostname+"/"+(null==e?void 0:e.ltrim("/"))},get:_,domain:function(e){return E(e)?e:"".concat(Salla.config.get("store.url",window.location.href.split("/").slice(0,-1).join("/")).rtrim("/"),"/").concat(null==e?void 0:e.ltrim("/"))},addParamToUrl:A,baseUrl:F,asset:P,cdn:function(e,t,r){var a="https://cdn.salla.network/";return(t||r)&&(t=t?",width=".concat(t):"",r=r?",height=".concat(r):"",a+="cdn-cgi/image/fit=scale-down".concat(t).concat(r,",onerror=redirect,format=auto/")),a+(null==e?void 0:e.ltrim("/"))},api:function(e){var t;return(null===(t=Salla.config.get("store.api",_("")))||void 0===t?void 0:t.rtrim("/"))+"/"+(null==e?void 0:e.ltrim("/"))},is_page:function(e){return e&&Salla.config.get("page.slug")===e},is_placeholder:function(e){return P(salla.config.get("theme.settings.placeholder"))===P(e)}}),addParamToUrl:A,debounce:function(e,t){t=t||100;var r,a=[];return function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];return clearTimeout(r),r=setTimeout((function(){var t=e.apply(void 0,n);a.forEach((function(e){return e(t)})),a=[]}),t),new Promise((function(e){return a.push(e)}))}},hasApplePay:function(){var e;try{return!!(null===(e=window.ApplePaySession)||void 0===e?void 0:e.canMakePayments())&&!/snapchat/i.test(navigator.userAgent)}catch(e){return console.error(e),!1}}},C=function(e,t){return C=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},C(e,t)},O=function(){return O=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},O.apply(this,arguments)};function k(e,t,r){if(r||2===arguments.length)for(var a,n=0,i=t.length;n<i;n++)!a&&n in t||(a||(a=Array.prototype.slice.call(t,0,n)),a[n]=t[n]);return e.concat(a||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var I,L,q,D,U=(I=console,L=[],q=[],D={log:function(e,t){if(I&&salla.config.isDebug()){L.push([t,e]),"trace"===salla.config.get("debug")&&(t="trace");var r=I.log,a=void 0===t?r:this.__dict__[t]||r,n=["%cTwilight","color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;"];q.forEach((function(e){n[0]+=e[0],n.push(e[1])}));var i={event:"#CFF680",backend:"#7b68ee"}[t];i&&(n[0]+="%c"+t[0].toUpperCase()+t.substring(1),n.push("margin-left: 5px;color: ".concat(i,";font-weight:bold; border:1px solid ").concat(i,"; padding: 2px 6px; border-radius: 5px;"))),a.call.apply(a,k([I],n.concat.apply(n,e),!1))}},__dict__:{trace:I.trace,debug:I.debug,info:I.info,warn:I.warn,error:I.error}},{event:function(){D.log(arguments,"event")},trace:function(){D.log(arguments,"trace")},debug:function(){D.log(arguments,"debug")},info:function(){D.log(arguments,"info")},warn:function(){D.log(arguments,"warn")},error:function(){D.log(arguments,"error")},log:function(){D.log(arguments,void 0)},backend:function(){D.log(arguments,"backend")},logs:function(e){[e].flat().forEach((function(e){return e&&D.log([e].flat(),"backend")}))},history:function(){return L.map((function(e){return I.log.apply(I,k([e[0]],e[1],!1))})),L},addPrefix:function(e){return Array.isArray(e)?q.unshift(e):this.warn("addPrefix receives array only!"),this}}),N=function(){function e(e,t){void 0===e&&(e={}),void 0===t&&(t={}),this.default_properties=t,this.properties_=O(O({},this.default_properties),e)}return e.prototype.merge=function(e){var t;return this.properties_=O(O({},this.properties_),e),this.properties_.store=O(O({},(null===(t=this.default_properties)||void 0===t?void 0:t.store)||{}),this.properties_.store),this},e.prototype.set=function(e,t){return e.includes(".")?(Salla.helpers.setNested(this.properties_,e,t),this):(this.properties_[e]=t,this)},e.prototype.currency=function(e){return void 0===e&&(e=void 0),e=e||this.get("user.currency_code"),this.get("currencies."+e)||Object.values(this.get("currencies"))[0]},e.prototype.get=function(e,t){return void 0===t&&(t=null),e.includes(".")?Salla.helpers.getNested(this.properties_,e,t):this.properties_.hasOwnProperty(e)?this.properties_[e]||t:t||void 0},e.prototype.all=function(){return this.properties_},e.prototype.isDebug=function(){return this.get("debug")||Salla.storage.get("debug")},e}(),j=function(e){function t(){var t=this;return(t=e.call(this,{wildcard:!0,delimiter:"::",newListener:!1,removeListener:!1,maxListeners:10,verboseMemoryLeak:!1,ignoreErrors:!1})||this).delimiter="::","undefined"!=typeof document&&(t.body=document.querySelector("body")),t.logableEvents=["cart::item.added.failed","cart::item.deleted.failed"],t.ingoreLogEvents=["document::click","document::keyup","document::change"],t.noneFireableActions=["document.request"],t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}C(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),t.prototype.createAndDispatch=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.dispatch.apply(this,k([e],t,!1))},t.prototype.emit=function(t){for(var r,a=[],n=1;n<arguments.length;n++)a[n-1]=arguments[n];var i=t.replace("::",".");if(!this.noneFireableActions.includes(i)&&Salla.call&&"function"==typeof Salla.call(i))return Salla.log("'Salla.".concat(i,"(...)' triggered using event '").concat(t,"'")),i=i.split("."),Array.isArray(a[0])&&(a=a[0]),void(r=salla[i[0]])[i[1]].apply(r,a);e.prototype.emit.apply(this,k([t],a,!1)),this.trackEvents.apply(this,k([t],a,!1))},t.prototype.emitAsync=function(t){for(var r=[],a=1;a<arguments.length;a++)r[a-1]=arguments[a];var n=e.prototype.emitAsync.apply(this,k([t],r,!1));try{this.trackEvents.apply(this,k([t],r,!1))}catch(e){Salla.logger.warn("error on tracking event (".concat(t,")"),r,e)}return n},t.prototype.trackEvents=function(e){for(var t,r=[],a=1;a<arguments.length;a++)r[a-1]=arguments[a];if("undefined"!=typeof window)try{window.dataLayer=window.dataLayer||[];var n={event:e};r.map((function(e){return"object"==typeof e&&(n=O(O({},n),e))})),window.dataLayer.push(n)}catch(e){salla.logger.error(e.message)}Salla.logger&&!this.ingoreLogEvents.includes(e)&&(t=Salla.logger).event.apply(t,k([e],r,!1)),this.dispatchMobileEvent.apply(this,k([e],r,!1))},t.prototype.dispatch=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return this.emit.apply(this,k([e],t,!1))},t.prototype.dispatchEvents=function(e){if(e)if("object"!=typeof e||Array.isArray(e))Salla.log("Events object is wrong, it should be object of {event:payload}",e);else for(var t=0,r=Object.entries(e);t<r.length;t++){var a=r[t],n=a[0],i=a[1];this.dispatch(n,i)}else Salla.log("No Events To Dispatch!",e)},t.prototype.addListener=function(e,t,r){return this.on(e,t,r)},t.prototype.addEventListener=function(e,t,r){return this.on(e,t,r)},t.prototype.listen=function(e,t){return this.on(e,t)},t.prototype.registerGlobalListener=function(e,t){return this.onAny(t)},t.prototype.dispatchMobileEvent=function(e,t){if(void 0===t&&(t={}),!("undefined"!=typeof window&&window.dataLayer&&window.dataLayer[0]&&window.dataLayer[0].page&&window.dataLayer[0].page.mobileApp))return"";if(window.webkit)try{window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:e,details:t}))}catch(e){Salla.log(e,"The native context does not exist yet")}else if(void 0!==window.Android)try{window.Android.customEventWithData(e,JSON.stringify({details:t}))}catch(e){Salla.log(e,"The native context does not exist yet")}},t}(t.EventEmitter2),B=h.createStore([f,p,g,m],[]),M=h.createStore([p],[]),H=h.createStore([g],[]),$=function(){function e(){var e=this;this.clearableItems=["cart","user","salla::wishlist","token"],Salla.event.on("storage::item.remove",(function(t){return e.remove(t)})),Salla.event.on("storage::item.set",(function(t,r){return e.set(t,r)})),this.store=B,this.session=M,this.cookie=H}return e.prototype.set=function(e,t){var r;if(e.includes(".")){var a=e.split(".")[0],n=((r={})[a]=this.store.get(a),r);return n=Salla.helpers.setNested(n,e,t),this.store.set(a,n[a])}return this.store.set(e,t)},e.prototype.remove=function(e){return this.store.remove(e)},e.prototype.clearAll=function(e){var t=this;if(void 0===e&&(e=!1),e)return this.store.clearAll();this.clearableItems.forEach((function(e){t.store.remove(e)}))},e.prototype.get=function(e,t){var r;if(e.includes(".")){var a=e.split(".")[0];return Salla.helpers.getNested(((r={})[a]=this.store.get(a),r),e)}return this.store.get(e,t)},e.prototype.prefixKey=function(e){return"".concat(Salla.config.get("theme.translations_hash"),"_").concat(e,"_").concat(Salla.config.get("store.id"))},e.prototype.setWithTTL=function(e,t,r,a){void 0===r&&(r=10),void 0===a&&(a="store");var n=this.prefixKey(e),i=(new Date).getTime()+60*r*1e3;return this[a].set(n,{value:t,expiry:i})},e.prototype.getWithTTL=function(e,t,r){void 0===t&&(t=null),void 0===r&&(r="store");var a=this.prefixKey(e),n=this[r].get(a);return n?(new Date).getTime()>n.expiry?(this[r].remove(a),t):n.value:t},e}(),z=function(){function e(){var e=this;this.keysToRemove=["__said","__ssid","theme_edit","ws_port","s-token"],this.dynamicKeysToRemove=["affiliate"],Salla.event.on("cookies::remove",(function(t){return e.remove(t)})),Salla.event.on("cookies::add",(function(t,r){return e.set(t,r)}))}return e.prototype.get=function(e){var t;return null===(t=document.cookie.split("; ").find((function(t){return t.startsWith(e+"=")})))||void 0===t?void 0:t.split("=")[1]},e.prototype.set=function(e,t,r){void 0===t&&(t=""),void 0===r&&(r=10);var a="";if(r){var n=new Date;n.setTime(n.getTime()+24*r*60*60*1e3),a="; expires="+n.toUTCString()}var i=salla.helpers.isIframe()?"None":"Lax";return document.cookie="".concat(e,"=").concat(t).concat(a,"; path=/; SameSite=").concat(i,"; secure"),this},e.prototype.remove=function(e){var t=salla.helpers.isIframe()?"None":"Lax";return document.cookie="".concat(e,"=; Max-Age=0; path=/; SameSite=").concat(t,"; secure"),this},e.prototype.clearAll=function(e){return void 0===e&&(e=!1),this.clean(e)},e.prototype.clean=function(e){var t=this;return document.cookie.split(";").map((function(e){return e.split("=")[0].trim()})).filter((function(r){return e||t.keysToRemove.includes(r)||t.dynamicKeysToRemove.some((function(e){return r.startsWith(e)}))})).forEach((function(e){return t.remove(e)})),this},e}();"undefined"!=typeof window&&(window.salla=window.salla||window.Salla||{},window.Salla=window.salla),void 0!==w&&(w.salla=w.salla||w.Salla||{},w.Salla=w.salla),Salla.status="base",Salla.config=new N,Salla.logger=U,Salla.event=new j,Salla.helpers=R,Salla.storage=new $,Salla.cookie=new z,Salla.log=Salla.logger.log,Salla.money=Salla.helpers.money,Salla.url=Salla.helpers.url,Salla.versions={base:"2.15.0-alpha.0"};var Y=Salla;let W=function(e,t,r){return alert(e)},V=function(e,t){return W(e,G.error,t)},G={error:"error",success:"success",info:"info"};var Q={fire:function(e,t,r){return W(e,t,r)},setNotifier:function(e){W=e,salla.event.emit("twilight::notifier.changed")},error:V,success:function(e,t){return W(e,G.success,t)},info:function(e,t){return W(e,G.info,t)},sallaInitiated:function(){let e=window.location.href.match(/([\?\&]danger=)[^&]+/g);e&&(window.history.replaceState(null,document.title,window.location.pathname),salla.event.once("twilight::notifier.changed",(()=>{e.forEach((e=>{e=decodeURI(e.replace("?danger=","").replace("&danger=",""));let t=document.createElement("div");t.innerText=e,V(t.innerHTML),salla.event.emit("twilight::error",e)}))})))},types:G};class K{constructor(e,t){return this.api=e,this.event=t,new Proxy(this,{get:function(r,a){return"event"===a?t:"api"===a?e:e&&e[a]||r[a]}})}}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 a=this.hasAttribute("data-form-selector")?document.querySelector(this.dataset.formSelector):void 0;if(a="FORM"===this.tagName?this:a||this.closest("form")||this.closest("[salla-form-data]")||this,a&&"FORM"===a.tagName)return this.getFilteredData(new FormData(a),null,a);let n=a.querySelectorAll("[name]");if(!n.length)return this.getFilteredData();let i=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,i);i[t.name]=t.value}catch(t){Salla.log(e.name+" can't be send")}})),this.getFilteredData(i)},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 a=this.attributes[r].name.toLowerCase();if(0===a.indexOf(e))return!t||a}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((a=>{let n=r?.dataset[a]||this.dataset[a];if(n){var i=window[n];if("function"==typeof i){if(!i(e,r||this,t)&&e)throw`Data failed to be pass verify function window.${n}(formData, element, event)!`;return i(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}}};class J{constructor(){this.events={},this.namespace="";let e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&e.length>1?e[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,(async(...e)=>t(...e)))}}getEventName(e){return e=this.events[e]||e,!this.namespace||e.includes("::")?e:this.namespace+Salla.event.delimiter+e}dispatch(e,...t){return Salla.event.emitAsync(this.getEventName(e),...t)}on(e,t,r={}){return Salla.event.addListener(this.getEventName(e),t,r)}once(e,t){return Salla.event.once(this.getEventName(e),t)}}function X(e){e&&e.sallaInitiated&&!e.initiated&&(e.sallaInitiated(),e.initiated=!0)}Salla.event.auth=new class extends J{constructor(){super(),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",refreshFailed:"refresh.failed",tokenFetched:"token.fetched",tokenInvalid:"token.invalid"},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))}async loggedIn(e){return Salla.profile.info().finally((()=>this.dispatch("loggedIn",e)))}setTypeActionOnVerified(e){this.type_action_on_verified=e}getTypeActionOnVerified(){return this.type_action_on_verified||"redirect"}},Salla.event.cart=new class extends J{constructor(){super(),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",priceQuoteSucceeded:"price-quote.succeeded",priceQuoteFailed:"price-quote.failed",offersFetched:"offers.fetched",offersFailed:"offers.failed",couponAdded:"coupon.added",couponDeleted:"coupon.deleted",couponAdditionFailed:"coupon.addition.failed",couponDeletionFailed:"coupon.deletion.failed",quickOrderSettingFetched:"quick-order.fetched",quickOrderSettingFailed:"quick-order.failed",quickOrderSucceeded:"quick-order.succeeded",quickOrderFailed:"quick-order.failed"},this.after_init()}updated(e){return Salla.cookie.set("fresh_summary",1),e&&"object"==typeof e?(e.offer&&salla.product.event.offerExisted(e.offer),e.redirect&&(salla.log("The current cart is purchased!"),salla.cart.api.reset()),e.cart?(salla.storage.set("cart.summary",{total:e.cart.total,sub_total:e.cart.sub_total,discount:e.cart.discount,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)):void salla.log("Failed to get the cart summary!")):(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)}},Salla.event.order=new class extends J{constructor(){super(),this.namespace="order",this.events={canceled:"canceled",notCanceled:"not.canceled",orderCreated:"order.created",orderCreationFailed:"order.creation.failed",invoiceSent:"invoice.sent",invoiceNotSent:"invoice.not.sent",ordersFetched:"order.fetched",ordersNotFetched:"order.not.fetched"},this.after_init()}},Salla.event.scope=new class extends J{constructor(){super(),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()}},Salla.event.rating=new class extends J{constructor(){super(),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()}},Salla.event.booking=new class extends J{constructor(){super(),this.namespace="booking",this.events={added:"added",additionFailed:"addition.failed"},this.after_init()}},Salla.event.comment=new class extends J{constructor(){super(),this.namespace="comment",this.events={added:"added",additionFailed:"addition.failed",fetched:"fetched",fetchFailed:"fetch.failed"},this.after_init()}},Salla.event.landing=new class extends J{constructor(){super(),this.namespace="landing",this.events={detailsFetched:"order.fetched",getDetailsFailed:"get.details.failed",orderCreated:"order.created",orderCreationFailed:"order.creation.failed",breadcrumbFetched:"breadcrumb.fetched",breadcrumbFetchFailed:"breadcrumb.fetch.failed"},this.after_init()}},Salla.event.loyalty=new class extends J{constructor(){super(),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()}exchangeSucceeded(e,t){return salla.cart.event.updated(e.data),this.dispatch("exchangeSucceeded",e,t)}resetSucceeded(e){return salla.cart.event.updated(e.data),this.dispatch("resetSucceeded",e)}},Salla.event.product=new class extends J{constructor(){super(),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",detailFetched:"detail.fetched",detailFetchFailed:"detail.failed",addGiftToCartSucceeded:"gift.add-to-cart.succeeded",addGiftToCartFailed:"gift.add-to-cart.failed",giftImageUploadSucceeded:"gift.image-upload.succeeded",giftImageUploadFailed:"gift.image-upload.failed",productListFetchSucceeded:"fetch.succeeded",productListFetchFailed:"fetch.failed",productOptionsFetched:"options.fetched",productOptionsNotFetched:"options.not.fetched"},this.after_init()}},Salla.event.profile=new class extends J{constructor(){super(),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",settingsUpdated:"settings.updated",updateSettingsFailed:"update.settings.failed",deleted:"deleted",notDeleted:"not.deleted"},this.after_init()}},Salla.event.currency=new class extends J{constructor(){super(),this.namespace="currency",this.events={changed:"changed",failed:"failed",fetched:"fetched",failedToFetch:"failed.to.fetch"},this.after_init()}},Salla.event.document=new class extends J{constructor(){super(),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,...a){if("string"==typeof e){if(r)return document.querySelectorAll(e).forEach((e=>this.fireEventForElements(e,t,!1,...a)));e=document.querySelector(e)}if(!e)return void salla.log("Failed To get element to fire event: "+t);const n=new CustomEvent(t,...a);return e.dispatchEvent(n)}},Salla.event.wishlist=new class extends J{constructor(){super(),this.namespace="wishlist",this.events={added:"added",removed:"removed",additionFailed:"addition.failed",removingFailed:"removing.failed"},this.after_init()}},Salla.event.infiniteScroll=new class extends J{constructor(){super(),this.namespace="infiniteScroll",this.events={scrollThreshold:"scroll.threshold",request:"request",load:"load",append:"append",error:"error",last:"last",history:"history"},this.after_init()}},Salla.event.notifications=new class extends J{constructor(){super(),this.namespace="notifications",this.events={fetched:"fetched",fetchFailed:"fetch.failed"},this.after_init()}},Salla.event.component=new class extends J{constructor(){super(),this.namespace="component",this.events={menuFetched:"menus.fetched",menuFetchFailed:"menus.fetch.failed",reviewsFetched:"reviews.fetched",reviewsFetchFailed:"reviews.fetch.failed"},this.after_init()}},Salla.event.advertisement=new class extends J{constructor(){super(),this.namespace="advertisement",this.events={fetched:"advertisement.fetched",fetchFailed:"advertisement.not.fetched"},this.after_init()}},Salla.event.navigation=new class extends J{constructor(){super(),this.namespace="navigation",this.events={breadcrumbFetched:"breadcrumb.fetched",breadcrumbFetchFailed:"breadcrumb.fetch.failed"},this.after_init()}},Salla.event.on("twilight::initiated",(()=>{Object.keys(Salla).forEach((e=>{"object"==typeof(e=Salla[e])&&(X(e),Object.keys(e).forEach((t=>{X(e[t])})))}))})),Salla.config.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"}}},Salla.config.merge(Salla.config.default_properties),Salla.config.triedToGetCurrencies_=!1,Salla.config.triedToGetLanguages_=!1,Salla.config.isUser=()=>"user"===Salla.config.get("user.type"),Salla.config.isGuest=()=>!Salla.config.isUser(),Salla.config.languages=async()=>{if(Salla.config.triedToGetLanguages_)return Salla.config.get("languages");Salla.config.triedToGetLanguages_=!0;let e=!0,t=[];return(await salla.document.api.request("languages",null,"get"))?.data?.map((r=>{e&&(t=[],e=!1),r.code=r.code||r.iso_code,r.url=salla.url.get(r.code),r.is_rtl=r.is_rtl||r.rtl,t.push(r)})),Salla.config.set("languages",t),t},Salla.config.currencies=async()=>{if(Salla.config.triedToGetCurrencies_)return Salla.config.get("currencies");Salla.config.triedToGetCurrencies_=!0;let e=!0,t={};return(await salla.currency.api.list())?.data?.map((r=>{e&&(t={},e=!1),r.country_code=r.code.substr(0,2).toLowerCase(),t[r.code]=r})),Salla.config.set("currencies",t),t};"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function Z(e){return e&&Object.prototype.hasOwnProperty.call(e,"default")&&1===Object.keys(e).length?e.default:e}var ee,te={exports:{}},re={exports:{}},ae=Z(v),ne=Z(y);function ie(){return ee||(ee=1,function(e){!function(t,r){e.exports?e.exports=r(t,ae,ne):t.InfiniteScroll=r(t,t.EvEmitter,t.fizzyUIUtils)}(window,(function(e,t,r){let a=e.jQuery,n={};function i(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={...i.defaults},this.option(t),a&&(this.$element=a(this.element)),this.create()}else console.error("Bad element for InfiniteScroll: "+(s||e))}i.defaults={},i.create={},i.destroy={};let s=i.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 i.create)i.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),!a||!this.$element)return;let i=e+=".infiniteScroll";if(t){let r=a.Event(t);r.type=e,i=r}this.$element.trigger(i,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}`,a=l[e];a&&(r+=". "+a.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),a=location.href.match(r);a&&(this.pageIndex=parseInt(a[1],10),this.log("pageIndex",[this.pageIndex,"template string"]))};let c=[/^(.*?\/?page\/?)(\d\d?\d?)(.*?$)/,/^(.*?\/?\?page=)(\d\d?\d?)(.*?$)/,/(.*?)(\d\d?\d?)(?!.*\d)(.*?$)/],u=i.getPathParts=function(e){if(e)for(let t of c){let r=e.match(t);if(r){let[,e,t,a]=r;return{begin:e,index:t,end:a}}}};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"),a=u(r);if(!a)return void console.error(`InfiniteScroll unable to parse next link href: ${r}`);let{begin:n,index:i,end:s}=a;this.isPathSelector=!0,this.getPath=()=>n+(this.pageIndex+1)+s,this.pageIndex=parseInt(i,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(/^\?/),a=t.substring(0,t.lastIndexOf("/")),n=r?t:a+"/";this.getAbsolutePath=()=>n+this.getPath()},i.create.hideNav=function(){let e=r.getQueryElement(this.options.hideNav);e&&(e.style.display="none",this.nav=e)},i.destroy.hideNav=function(){this.nav&&(this.nav.style.display="")},s.destroy=function(){this.allOff();for(let e in i.destroy)i.destroy[e].call(this);delete this.element.infiniteScrollGUID,delete n[this.guid],a&&this.$element&&a.removeData(this.element,"infiniteScroll")},i.throttle=function(e,t){let r,a;return t=t||200,function(){let n=+new Date,i=arguments,s=()=>{r=n,e.apply(this,i)};r&&n<r+t?(clearTimeout(a),a=setTimeout(s,t)):s()}},i.data=function(e){let t=(e=r.getQueryElement(e))&&e.infiniteScrollGUID;return t&&n[t]},i.setJQuery=function(e){a=e},r.htmlInit(i,"infinite-scroll"),s._init=function(){};let{jQueryBridget:d}=e;return a&&d&&d("infiniteScroll",i,a),i}))}(re)),re.exports}re.exports;var se,oe={exports:{}};function le(){return se||(se=1,function(e){!function(t,r){e.exports?e.exports=r(t,ie()):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 a=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 i=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((i=>("text"==e&&t&&(i=a.parseFromString(i,"text/html")),204==r.status?(this.lastPageReached(i,n),{body:i,response:r}):this.onPageLoad(i,n,r))))})).catch((e=>{this.onPageError(e,n)}));return this.dispatchEvent("request",null,[n,i]),i},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:a,responseBody:i,domParseResponse:s}=this.options;if(!("text"==i&&s)||!a)return{body:e,response:r};let o=e.querySelectorAll(a),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,a){let n=t.imagesLoaded||e.imagesLoaded;return n?new Promise((function(e){n(r,(function(){let t=a();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:a,path:n}=this.options;if(a){if("function"==typeof n){if(!this.getPath())return void this.lastPageReached(e,t)}"string"==typeof a?r=a: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}))}(oe)),oe.exports}var ce,ue={exports:{}};function de(){return ce||(ce=1,function(e){!function(t,r){e.exports?e.exports=r(t,ie(),ne):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){let a=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()},a.enableScrollWatch=function(){this.isScrollWatching||(this.isScrollWatching=!0,this.updateMeasurements(),this.updateScroller(),this.on("last",this.disableScrollWatch),this.bindScrollWatchEvents(!0))},a.disableScrollWatch=function(){this.isScrollWatching&&(this.bindScrollWatchEvents(!1),delete this.isScrollWatching)},a.bindScrollWatchEvents=function(t){let r=t?"addEventListener":"removeEventListener";this.scroller[r]("scroll",this.pageScrollHandler),e[r]("resize",this.resizeHandler)},a.onPageScroll=t.throttle((function(){this.getBottomDistance()<=this.options.scrollThreshold&&this.dispatchEvent("scrollThreshold")})),a.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},a.onResize=function(){this.updateMeasurements()},r.debounceMethod(t,"onResize",150),t}))}(ue)),ue.exports}var he,fe={exports:{}};function pe(){return he||(he=1,function(e){!function(t,r){e.exports?e.exports=r(t,ie(),ne):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){let a=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.`)},a.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)},a.bindHistoryAppendEvents=function(t){let r=t?"addEventListener":"removeEventListener";this.scroller[r]("scroll",this.scrollHistoryHandler),e[r]("unload",this.unloadHandler)},a.createHistoryPageLoad=function(){this.on("load",this.onPageLoadHistory)},t.destroy.history=a.destroyHistory=function(){this.options.history&&this.options.append&&this.bindHistoryAppendEvents(!1)},a.onAppendHistory=function(e,t,r){if(!r||!r.length)return;let a=r[0],i=this.getElementScrollY(a);n.href=t,this.scrollPages.push({top:i,path:n.href,title:e.title})},a.getElementScrollY=function(t){if(this.options.elementScroll)return t.offsetTop-this.top;return t.getBoundingClientRect().top+e.scrollY},a.onScrollHistory=function(){let e=this.getClosestScrollPage();e!=this.scrollPage&&(this.scrollPage=e,this.setHistory(e.title,e.path))},r.debounceMethod(t,"onScrollHistory",150),a.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},a.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]))},a.onUnload=function(){if(0===this.scrollPage.top)return;let t=e.scrollY-this.scrollPage.top+this.top;this.destroyHistory(),scrollTo(0,t)},a.onPageLoadHistory=function(e,t){this.setHistory(e.title,t)},t}))}(fe)),fe.exports}var ge,me={exports:{}};function ve(){return ge||(ge=1,function(e){!function(t,r){e.exports?e.exports=r(t,ie(),ne):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){class a{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 a(e,this))},t.destroy.button=function(){this.button&&this.button.destroy()},t.Button=a,t}))}(me)),me.exports}var ye,we={exports:{}};function be(){return ye||(ye=1,function(e){!function(t,r){e.exports?e.exports=r(t,ie(),ne):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){let a=t.prototype;function n(e){s(e,"none")}function i(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"))},a.bindHideStatus=function(e){let t=this.options.append?"append":"load";this[e](t,this.hideAllStatus)},a.showRequestStatus=function(){this.showStatus("request")},a.showErrorStatus=function(){this.showStatus("error")},a.showLastStatus=function(){this.showStatus("last"),this.bindHideStatus("off")},a.showStatus=function(e){i(this.statusElement),this.hideStatusEventElements(),i(this.statusEventElements[e])},a.hideAllStatus=function(){n(this.statusElement),this.hideStatusEventElements()},a.hideStatusEventElements=function(){for(let e in this.statusEventElements){n(this.statusEventElements[e])}},t}))}(we)),we.exports}
|
|
2
|
-
/*!
|
|
3
|
-
* Infinite Scroll v4.0.1
|
|
4
|
-
* Automatically add next page
|
|
5
|
-
*
|
|
6
|
-
* Licensed GPLv3 for open source use
|
|
7
|
-
* or Infinite Scroll Commercial License for commercial use
|
|
8
|
-
*
|
|
9
|
-
* https://infinite-scroll.com
|
|
10
|
-
* Copyright 2018-2020 Metafizzy
|
|
11
|
-
*/!function(e){window,e.exports&&(e.exports=function(e){return e}(ie(),le(),de(),pe(),ve(),be()))}(te);var Se=te.exports;var Ee={exports:{}};
|
|
12
|
-
/*!
|
|
13
|
-
* Lang.js for Laravel localization in JavaScript.
|
|
14
|
-
*
|
|
15
|
-
* @version 1.1.12
|
|
16
|
-
* @license MIT https://github.com/rmariuzzo/Lang.js/blob/master/LICENSE
|
|
17
|
-
* @site https://github.com/rmariuzzo/Lang.js
|
|
18
|
-
* @author Rubens Mariuzzo <rubens@mariuzzo.com>
|
|
19
|
-
*/!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*([\[\]])$/,a=/({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])/,n={locale:"en"},i=function(t){t=t||{},this.locale=t.locale||e()||n.locale,this.fallback=t.fallback,this.messages=t.messages};return i.prototype.setMessages=function(e){this.messages=e},i.prototype.getLocale=function(){return this.locale||this.fallback},i.prototype.setLocale=function(e){this.locale=e},i.prototype.getFallback=function(){return this.fallback},i.prototype.setFallback=function(e){this.fallback=e},i.prototype.has=function(e,t){return!("string"!=typeof e||!this.messages)&&null!==this._getMessage(e,t)},i.prototype.get=function(e,t,r){if(!this.has(e,r))return e;var a=this._getMessage(e,r);return null===a?e:(t&&(a=this._applyReplacements(a,t)),a)},i.prototype.trans=function(e,t){return this.get(e,t)},i.prototype.choice=function(e,t,r,n){(r=void 0!==r?r:{}).count=t;var i=this.get(e,r,n);if(null==i)return i;for(var s=i.split("|"),o=[],l=0;l<s.length;l++)if(s[l]=s[l].trim(),a.test(s[l])){var c=s[l].split(/\s/);o.push(c.shift()),s[l]=c.join(" ")}if(1===s.length)return i;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)]},i.prototype.transChoice=function(e,t,r){return this.choice(e,t,r)},i.prototype._parseKey=function(e,t){if("string"!=typeof e||"string"!=typeof t)return null;var r=e.split("."),a=r[0].replace(/\//g,".");return{source:t+"."+a,sourceFallback:this.getFallback()+"."+a,entries:r.slice(1)}},i.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],a=e.entries.slice(),n=a.join(".");if("string"!=typeof(r=void 0!==r?this._getValueInKey(r,n):void 0)&&this.messages[e.sourceFallback])for(r=this.messages[e.sourceFallback],a=e.entries.slice(),n="";a.length&&void 0!==r;)r[n=n?n.concat(".",a.shift()):a.shift()]&&(r=r[n],n="");return"string"!=typeof r?null:r},i.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("."),a=0,n=r.length;a<n;++a){var i=r.slice(0,a+1).join("."),s=r.slice(a+1,r.length).join(".");if(e[i])return this._getValueInKey(e[i],s)}return e},i.prototype._getLocale=function(e){return e=this._parseKey(e,this.locale),this.messages[e.source]?this.locale:this.messages[e.sourceFallback]?this.fallback:null},i.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},i.prototype._sortReplacementKeys=function(e,t){return t.length-e.length},i.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 a=t[r];return e===e.toUpperCase()?a.toUpperCase():e===e.replace(/\w/i,(function(e){return e.toUpperCase()}))?a.charAt(0).toUpperCase()+a.slice(1):a}))})),e},i.prototype._testInterval=function(e,a){if("string"!=typeof a)throw"Invalid interval: should be a string.";var n=(a=a.trim()).match(r);if(!n)throw"Invalid interval: "+a;if(!n[2]){var i=(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("["===i?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},i.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}},i}()}(Ee);var _e=Ee.exports;class Ae{constructor(){this.endpoints={},this.webEndpoints=[],this.namespace="BaseApi",this.endpointsMethods={},this.endpointsHeaders={};let e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&e.length>1?e[1]:"").toLowerCase(),this.debounce={request:void 0,time:300,enabled:!0,exclude:[]}}after_init(){}normalRequest(e,t=void 0,r=null){let a=Array.isArray(e),n=a?this.getUrl(...e):this.getUrl(e);e=a?e[0]:e,r=r||this.endpointsMethods[e]||"post";let i=this.endpointsHeaders[e];if("get"===r&&t instanceof FormData){let e={};Array.from(t.entries()).forEach((function(t){e[t[0]]=t[1]})),t={params:e}}return i&&"get"===r&&(t=t?Object.assign(t,i):i),this.webEndpoints.includes(e)?n=salla.url.get(n):"http"!==n.substring(0,4)&&(n=salla.url.api(n)),Salla.api.request(n,t,r,{headers:i})}request(e,t=void 0,r=null){return!salla.api.isFastRequestsAllowed()&&this.debounce.enabled?(this.debounce.request||(this.debounce.request=salla.helpers.debounce(this.normalRequest.bind(this),this.debounce.time)),this.debounce.request(e,t,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}event(){return salla.event[this.className]}}class Fe extends Ae{constructor(){super(),this.addToCartTries=0,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",getQuickOrderSettings:"checkout/quick-order",createQuickOrder:"checkout/quick-order",priceQuote:"cart/{cartId}/price-quote",offers:"offers/cart/{cartId}"},this.endpointsMethods={latest:"get",details:"get",status:"get",updateItem:"post",deleteItem:"delete",deleteImage:"delete",deleteCoupon:"put",getQuickOrderSettings:"get",offers:"get"},this.webEndpoints=["latest"],this.latestCart=null,this.after_init(),salla.event.on("api::initiated",(()=>salla.api.cart.getCurrentCartId(!1,"api::initiated"))),salla.event.on("auth::token.fetched",this._checkCurrentCart),salla.event.on("auth::token.invalid",this._checkCurrentCart),salla.event.on("auth::verified",(()=>salla.api.cart.getCurrentCartId(!0,"auth::verified")),{async:!0}),salla.event.on("profile::info.fetched",this._checkCurrentCart),salla.event.on("twilight::error",(e=>(e.includes("Cart not available")||e.includes("السلة غير متاحة"))&&salla.cart.api.reset()))}_checkCurrentCart(){let e=salla.storage.get("cart"),t=salla.config.get("user")?.id,r=salla.config.get("store")?.id;e&&e.id&&(e.user_id!==t||e.store_id!==r)&&(salla.log("cart",{user_id:e.user_id,store_id:e.store_id}),salla.log("current",{user_id:t,store_id:r}),salla.log("Api:: case2 => The cart is not belong to current "+(e.user_id!==t?"user":"store")+"!"),salla.cart.api.reset())}async getCurrentCartId(e=!1,t="getCurrentCartId"){if(!e){if(salla.cart.api.latestCart)return salla.cart.api.latestCart.cart.id;let e=salla.storage.get("cart.id");if(e)return e}let r=await salla.cart.api.latest(t);return salla.cart.api.latestCart=r.data,salla.cart.api.latestCart.cart.id}getUploadImageEndpoint(e){return salla.url.api(this.getUrl("uploadImage",e||salla.storage.get("cart.id")))}latest(e="direct"){return this.request("latest",{params:{source:"",callerName:e}}).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(e,t=[]){return e=e||await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.details"),this.request(["details",e],{params:{with:t}}).then((function(e){return salla.cart.event.detailsFetched(e),e})).catch((function(e){throw salla.cart.event.detailsNotFetched(e),e}))}async quickAdd(e,t){return this.addItem({id:e,quantity:t,endpoint:"quickAdd"})}async addItem(e){let t=this.getCartPayload(e);if(!t.id){let e='There is no product "id"!';return salla.cart.event.itemAddedFailed(e),salla.api.errorPromise(e)}let r=salla.form.getPossibleValue(t.payload,["endpoint"]);r&&["addItem","quickAdd"].includes(r)||(r=salla.form.getPossibleValue(t.payload,["quantity","donating_amount"])?"addItem":"quickAdd");let a=await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.addItem");return this.request([r,a,t.id],t.payload).then((function(e){return salla.cart.api.addToCartTries=0,salla.cart.event.itemAdded(e,t.id),e})).catch((function(r){if(!salla.cart.api.addToCartTries)return salla.cart.api.addToCartTries++,salla.cart.reset(),salla.cart.api.addItem(e);throw salla.cart.event.itemAddedFailed(r,t.id),r}))}async deleteItem(e){let t=this.getCartPayload(e);if(!t.id){let e='There is no "id"!';return salla.cart.event.itemDeletedFailed(e),salla.api.errorPromise(e)}let r=await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.deleteItem");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),salla.api.errorPromise(e)}let r=await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.updateItem");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=salla.form.getPossibleValue(e,["id","image_id","photo_id"]))){let e='There is no "id"!';return salla.cart.event.imageNotDeleted(e),salla.api.errorPromise(e)}let t=await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.deleteImage");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){const t=(new Date).getTime(),r=Math.random().toString(36).substring(2,15);return this.request(["status",e||await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.status")],{params:{has_apple_pay:salla.helpers.hasApplePay(),"s-hash":`${r}_${t}`}})}async submit(){if(salla.config.isGuest())return salla.log("it looks that the current user is not logged-in, lets login then submit"),salla.cart.loginOnCartPage();this.status(await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.submit")).then((e=>{let t=e.data.next_step?.to;if(t||(window.history.pushState({},"",salla.url.addParamToUrl("reload","empty_next_step")),window.history.pushState({},"",salla.url.addParamToUrl("acitve",!1===e.data.active?"false":"true_or_undfined")),salla.cart.reset(),window.location.reload()),!["checkout","refresh","login"].includes(t)){let e="Can't find next_step );";throw salla.cart.reset(),salla.cart.event.submitFailed(e),e}return salla.cart.event.submitted(e),"login"===t?salla.cart.loginOnCartPage():"checkout"===t?window.location.href=e.data.next_step.url+(salla.helpers.hasApplePay()?"?has_apple_pay=true":""):(window.history.pushState({},"",salla.url.addParamToUrl("reload","refresh")),void window.location.reload())})).catch((function(e){salla.cart.api.tries=salla.cart.api.tries||0,salla.cart.reset();let t=404===e?.response?.data?.status;if(t&&0===salla.cart.api.tries)return salla.cart.api.tries++,salla.log("we recived that the current cart is not found, we will try to re-submit one more time"),salla.cart.submit();throw t&&salla.error(salla.lang.get("pages.checkout.try_again")),salla.cart.event.submitFailed(e),e}))}getCartPayload(e){let t=e?.data||("object"==typeof e?e:void 0);return e=t?salla.form.getPossibleValue(t,["prod_id","product_id","item_id","id"]):e,t="object"==typeof t?t:void 0,{id:e,payload:t}}normalRequest(e,t=void 0,r=null){return super.normalRequest(e,t,r).catch((async e=>{throw 403===e?.response?.status&&(this.reset(),salla.error(salla.lang.get("pages.checkout.try_again"))),e}))}reset(){salla.api.cart.latestCart=null,salla.storage.remove("cart"),salla.cart.event.successReset()}async addCoupon(e){if(e=e.data||e,!(e=salla.form.getPossibleValue(e,["coupon"]))){let e=new Error('There is no "Coupon Code"!');return e.name="EmptyCoupon",salla.event.cart.couponAdditionFailed(e),salla.api.errorPromise(e)}let t=await salla.cart.api.getCurrentCartId(!1,"salla.api.cart.addCoupon");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(!1,"salla.api.cart.deleteCoupon");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}))}getQuickOrderSettings(){return this.request("getQuickOrderSettings").then((e=>(salla.event.cart.quickOrderSettingFetched(e),e))).catch((e=>{throw salla.event.cart.quickOrderSettingFailed(e),e}))}createQuickOrder(e){return this.request("createQuickOrder",e).then((e=>(salla.event.cart.quickOrderSucceeded(e),e))).catch((e=>{throw salla.event.cart.quickOrderFailed(e),e}))}async priceQuote(e){return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("cart::priceQuote",e),void salla.event.dispatch("login::open")):this.request(["priceQuote",e||await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.priceQuote")]).then((e=>(salla.cart.api.reset(),salla.event.cart.priceQuoteSucceeded(e).then((()=>(setTimeout((()=>window.location.href=salla.url.get("/")),1e3),e)))))).catch((e=>salla.event.cart.priceQuoteFailed(e).then((()=>{throw 404===e.error?.code&&window.location.reload(),e}))))}loginOnCartPage(){salla.auth.setCanRedirect(!1),salla.event.dispatch("login::open"),salla.auth.event.onLoggedIn((e=>{salla.event.dispatch("login::close"),salla.cart.submit()}))}async offers(){const e=await salla.cart.api.getCurrentCartId(!1,"salla.api.cart.offers");return this.request(["offers",e]).then((e=>(salla.event.cart.offersFetched(e),e))).catch((e=>{throw salla.event.cart.offersFailed(e),e}))}}class Pe extends Ae{constructor(){super(),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=salla.form.getPossibleValue(e,["id","loyalty_prize_id","prize_id"]))){let e="Unable to find cart id. Please provide one.";return salla.loyalty.event.exchangeFailed(e),salla.api.errorPromise(e)}if(!(t=t||await salla.cart.getCurrentCartId(!1,"salla.api.loyalty.exchange"))){let e="Unable to find cart id. Please provide one.";return salla.loyalty.event.exchangeFailed(e),salla.api.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(!1,"salla.api.loyalty.reset"))){let e="Unable to find cart id. Please provide one.";return salla.loyalty.event.resetFailed(e),salla.api.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 xe extends Ae{constructor(){super(),this.namespace="auth",this.canRedirect_=!0,this.afterLoginEvent={event:null,payload:null},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.inIframe=salla.helpers.isIframe(),this.after_init()}setAfterLoginEvent(e,t){salla.api.auth.afterLoginEvent={event:e,payload:t}}setCanRedirect(e){salla.api.auth.canRedirect_=e}canRedirect(){return salla.api.auth.canRedirect_&&!salla.api.auth.afterLoginEvent.event}login(e){e?.data&&(e=e.data);let t=salla.form.getPossibleValue(e,["type"]);if(!["email","mobile"].includes(t)){let e="Login type should be in: [email, mobile]";return salla.auth.event.codeNotSent(e),salla.api.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=salla.form.getPossibleValue(e,["type"]);if(!r){let e="Failed to know what's login type!";return salla.auth.event.verificationFailed(e),salla.api.errorPromise(e)}t=!1!==salla.form.getPossibleValue(e,["supportWebAuth"])&&t,salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event);let a=await salla.auth.api.request(["verify",r],e);return 200!==a?.status?(salla.auth.event.verificationFailed(a,r),salla.api.errorPromise(a)):salla.auth.api.handlAfterAuthenticatedResponse(a,t)}async handlAfterAuthenticatedResponse(e,t){e.data||(e={data:e});let r="authenticated"===e.data?.case;return r&&salla.auth.event.tokenFetched(e.data.token),t&&!this.inIframe&&await salla.auth.api.request("auth/jwt",{callerName:"salla.auth.api.handlAfterAuthenticatedResponse"}),r&&await salla.auth.event.loggedIn(e).then((()=>salla.auth.api.afterUserLogin())),await salla.auth.event.verified(e,e.data.verification.type),salla.api.successPromise(e)}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),salla.api.errorPromise(t)):(salla.auth.event.codeNotSent(t="There is no phone or country_code!",e),salla.api.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((async e=>(salla.auth.event.registered.call(t,e),"authenticated"===e.data?.case&&(salla.auth.event.tokenFetched(e.data.token),!this.inIframe&&await salla.auth.request("auth/jwt",{callerName:"salla.auth.api.register"}),salla.auth.event.loggedIn(e),salla.auth.api.afterUserLogin()),e))).catch((function(e){throw salla.auth.event.registrationFailed.call(t,e),e}))}handleIframeReadyAction(e,t){e.contentWindow?.postMessage({source:"logout",type:"init",data:{id:salla.config.get("store.id"),lang:"ar",appUrl:t,apiUrl:salla.config.get("store.api").replace(/\/+$/,""),settings:salla.config.all(),storage:{}}},"*")}appendIframeAndLogout(){return new Promise((e=>{let t=salla.config.get("login.url","https://accounts.salla.com");const r=document.createElement("iframe");r.style.display="none",r.src=`${t}/logout`;const a=n=>{if("login"!==n.data.source)return;let i=n.data.type.replace("iframe::","");if(salla.log("iframe::logout-iframe message received",n.data),["logged-out","ready"].includes(i)){if("ready"===i)return this.handleIframeReadyAction(r,t);window.removeEventListener("message",a),r.remove(),e()}};window.addEventListener("message",a),document.body.appendChild(r)}))}logout(e="twilight"){return salla.storage.clearAll(),salla.cookie.clearAll(),e=encodeURI(e),salla.auth.event.loggedOut().then((()=>this.appendIframeAndLogout())).then((()=>{let t=salla.url.get(`logout?from=${e}`);console.log(`Going to ${t}, to do any thing before this action use: salla.auth.even.onLoggedOut(()=>{...})`);try{location.href=t}catch(e){salla.log(e)}})).catch((e=>console.error("Error during logout:",e)))}refresh(){return this.request("refresh").then((function(e){return salla.auth.event.tokenFetched(e.data.token),e})).catch((function(e){throw salla.auth.event.refreshFailed(e),e}))}afterUserLogin(){this.afterLoginEvent.event&&salla.event.emit(this.afterLoginEvent.event,this.afterLoginEvent.payload)}}class Te extends Ae{constructor(){super(),this.namespace="order",this.endpoints={cancel:"orders/cancel/{id}",createCartFromOrder:"reorder/{id}",sendInvoice:"orders/send/{id}",fetch:"orders"},this.endpointsMethods={createCartFromOrder:"get",fetch:"get"},this.after_init()}show(e){let t=salla.form.getPossibleValue(e?.data||e,["id","order_id"]);salla.event.dispatch("mobile::order.placed",{order_id:t}),location.href=salla.form.getPossibleValue(e?.data||e,["url"])}cancel(e){return e=e||Salla.config.get("page.id"),this.request(["cancel",e],{params:{has_apple_pay:salla.helpers.hasApplePay()}}).then((function(t){return salla.event.order.canceled(t,e),t})).catch((function(t){throw salla.event.order.notCanceled(t,e),t}))}createCartFromOrder(e){return e=e||salla.config.get("page.id"),this.request(["createCartFromOrder",e]).then((function(t){return salla.cart.reset(),salla.event.order.orderCreated(t,e),window.location.href=t.data.url,t})).catch((function(t){throw salla.event.order.orderCreationFailed(t,e),t}))}sendInvoice(e){let t=salla.form.getPossibleValue(e,["id"])||salla.config.get("page.id");if(!t||isNaN(t)){let e="There is no id!";return salla.order.event.invoiceNotSent(e),salla.api.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}))}fetch(e){return this.request(["fetch"],{params:e}).then((function(e){return salla.event.order.ordersFetched(e),e})).catch((function(e){throw salla.event.order.ordersNotFetched(e),e}))}}class Re extends Ae{constructor(){super(),this.namespace="product",this.previousQuery="",this.endpoints={getPrice:"products/{id}/price",availabilitySubscribe:"products/{id}/availability-notify",search:"products/search",details:"products/{product_id}/details",categories:"products/categories/{?id}",offers:"products/{product_id}/specialoffer",getSizeGuides:"products/{prod_id}/size-guides",giftDetail:"products/{product_id}/buy-as-gift",giftToCart:"products/{product_id}/buy-as-gift",giftImage:"products/buy-as-gift/image",buyNow:"products/{product_id}/buy-now",fetch:"products",fetchOptions:"products/options"},this.endpointsMethods={details:"get",giftDetail:"get",fetch:"get",offers:"get",fetchOptions:"get"},this.after_init()}getPrice(e){let t=e.data||e,r=salla.form.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=salla.form.getPossibleValue(t,["id","prod_id"]),this.request(["availabilitySubscribe",e],"object"==typeof t?t:void 0).then((function(t){return salla.product.event.availabilitySubscribed(t,e),t})).catch((function(t){throw salla.product.event.availabilitySubscribeFailed(t,e),t}))}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),salla.api.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,salla.api.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=salla.form.getPossibleValue(e?.data|e,["product_id","id"]))){let e='There is no "product_id"!';return salla.product.event.fetchOffersFailed(e),salla.api.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.fetchOffersFailed(t,e),t}))}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}))}getDetails(e,t=[]){if(!Array.isArray(t)){let e="withItems should be array.";return salla.product.event.detailFetchFailed(e),salla.api.errorPromise(e)}if(!e){let e="productId is not passed.";return salla.product.event.detailFetchFailed(e),salla.api.errorPromise(e)}return this.request(["details",e],{params:{with:t}}).then((function(t){return salla.product.event.detailFetched(t,e),t})).catch((function(t){throw salla.product.event.availabilitySubscribeFailed(t,e),t}))}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),t))).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}))}fetch(e){if(!e.source){const e="Source cannot be empty. Please provide one.";return salla.product.event.productListFetchFailed(e),salla.api.errorPromise(e)}const t=!e.source_value,r="string"==typeof e.source_value&&"[]"===e.source_value,a=Array.isArray(e.source_value)&&!e.source_value.length;if((t||r||a)&&!["offers","latest","sales","wishlist","top-rated"].includes(e.source)){const e="Source value cannot be empty. Please provide one.";return salla.product.event.productListFetchFailed(e),salla.api.errorPromise(e)}if(["categories","brands","tags","selected"].includes(e.source)&&!Array.isArray(e.source_value)){const e="SourceValue type error. Expected an array.";return salla.product.event.productListFetchFailed(e),salla.api.errorPromise(e)}if("search"===e.source&&"string"!=typeof e.source_value){const e="SourceValue type error. Expected a string.";return salla.product.event.productListFetchFailed(e),salla.api.errorPromise(e)}if("related"===e.source&&isNaN(e.source_value)){const e="SourceValue type error. Expected a number.";return salla.product.event.productListFetchFailed(e),salla.api.errorPromise(e)}return this.request(this.endpoints.fetch,{params:e},"get").then((async t=>{if(salla.product.event.productListFetchSucceeded(t),e.includes&&e.includes.includes("options")&&t.data){const e=t.data.map((e=>e.id)),r=await this.fetchOptions(e);this.updateProductOptions(t.data,r.data)}return t})).catch((e=>{throw salla.product.event.productListFetchFailed(e),e}))}updateProductOptions(e,t){const r=new Map(t.map((e=>[e.id,e.options])));for(const t of e)t.options=r.get(t.id)}fetchOptions(e){if(!e||0===e.length){const e="At least one product ID is required. Please provide a valid list of product IDs.";return salla.product.event.productOptionsNotFetched(e),salla.api.errorPromise(e)}const t={selected:e};return this.request(this.endpoints.fetchOptions,{params:t},"get").then((e=>(salla.product.event.productOptionsFetched(e),e))).catch((e=>{throw salla.product.event.productOptionsNotFetched(e),e}))}}class Ce extends Ae{constructor(){super(),this.namespace="profile",this.endpoints={info:"auth/user",update:"profile/update",updateContacts:"profile/contacts/update",updateSettings:"profile/settings",verify:"profile/verify",delete:"profile"},this.endpointsMethods={delete:"delete"},this.after_init()}info(){return this.request("info",null,"get").then((e=>{let t={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,notifications:e.data.notifications,pending_orders:e.data.pending_orders,avatar:e.data.avatar,first_name:e.data.first_name,last_name:e.data.last_name,fetched_at:Date.now()};return salla.config.set("user",t),salla.storage.set("user",t),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}))}updateSettings(e){return this.request("updateSettings",e).then((e=>(salla.event.profile.settingsUpdated(e),e))).catch((e=>{throw salla.event.profile.updateSettingsFailed(e),e}))}delete(){return this.request("delete").then((e=>(salla.storage.clearAll(),salla.cookie.clearAll(),salla.event.profile.deleted(e),window.location.href=salla.url.get("logout"),e))).catch((e=>{throw salla.event.profile.notDeleted(e),e}))}}class Oe extends Ae{constructor(){super(),this.namespace="comment",this.endpoints={addComment:"{type}/{id}/comments",comments:"/comments"},this.after_init()}add(e){if(e?.data&&(e=e.data),"string"==typeof(e=this.getCommentPayload(e,!0)))return salla.event.comment.additionFailed(e),salla.api.errorPromise(e);if(!e.comment){let e="can't find comment content!";return salla.event.comment.additionFailed(e),salla.api.errorPromise(e)}return this.request(["addComment",e.type,e.id],{comment:e.comment}).then((function(t){return salla.event.comment.added(t,e.id),t})).catch((function(t){throw salla.event.comment.additionFailed(t,e.id),t}))}getCommentPayload(e,t=!1){let r={};if(["id","type","comment","per_page","page","sort"].forEach((t=>{let a=salla.form.getPossibleValue(e,[t]);a&&(r[t]=a)})),!t){let t=e.ids;if(t&&(r.ids=Array.isArray(t)?t:[t]),!r.ids||!r.ids.length)return"Failed to get ids!"}return r.type&&["products","pages","product","page"].includes(r.type)?(r.type+=["product","page"].includes(r.type)?"s":"",r):"Failed to get type one of:(products, product, page, pages)!"}fetchComments(e){if("string"==typeof(e=this.getCommentPayload(e)))return salla.event.comment.fetchFailed(e),salla.api.errorPromise(e);const t={per_page:e.per_page||5,page:e.page||1,type:e.type,ids:e.ids};return e.sort&&(t.sort=e.sort),this.request(["comments"],{params:t},"get").then((function(t){return salla.event.comment.fetched(t,e),t})).catch((function(t){throw salla.event.comment.fetchFailed(t,e),t}))}getPageComments(e,t=1,r=5,a){return this.fetchComments({ids:[e],type:"pages",page:t,per_page:r,sort:a})}getProductComments(e,t=1,r=5,a){return this.fetchComments({ids:[e],type:"products",page:t,per_page:r,sort:a})}}class ke extends Ae{constructor(){super(),this.namespace="currency",this.endpoints={change:"/",list:"currencies"},this.endpointsMethods={change:"get",list:"get"},this.webEndpoints=["change"],this.after_init()}change(e){if(!(e=salla.form.getPossibleValue(e.data||e,["currency","code"]))){let e="Can't find currency code!";return salla.currency.event.failed(e),salla.api.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 Ie extends Ae{constructor(){super(),this.namespace="document"}}class Le extends Ae{constructor(){super(),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=salla.form.getPossibleValue(e?.data||e,["order_id","id"]);if(!r){let e='There is no "order_id"!';return salla.event.rating.orderNotFetched(e),salla.api.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),salla.api.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),salla.api.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),salla.api.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 qe extends Ae{constructor(){super(),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),salla.api.errorPromise(t)):(e=salla.form.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!"),salla.api.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),salla.api.errorPromise(t)):(e=salla.form.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!"),salla.api.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 De extends Ae{constructor(){super(),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),e}))}}class Ue extends Ae{constructor(){super(),this.namespace="booking",this.endpoints={add:"cart/booking/product/{id}"},this.endpointsMethods={add:"get"}}async add(e,t=!0){if(!e){let e="Please provide product id.";return salla.booking.event.additionFailed(e),salla.api.errorPromise(e)}return this.request(["add",e]).then((function(e){return salla.booking.event.added(e),t&&"booking"===e.data.redirect.to&&(window.location.href=e.data.redirect.url),e})).catch((function(e){throw salla.booking.event.additionFailed(e),e}))}}class Ne extends Ae{constructor(){super(),this.namespace="landing",this.endpoints={getDetails:"landing/{landing_page_id}",createCartFromPage:"landing/{landing_page_id}",breadcrumbs:"breadcrumbs"},this.endpointsMethods={getDetails:"get",breadcrumbs:"get"},this.after_init()}getDetails(e){if(!e){let e="page landing id not passed";return salla.event.landing.getDetailsFailed(e),salla.api.errorPromise(e)}return this.request(["getDetails",e]).then((function(t){return salla.event.landing.detailsFetched(t,e),t})).catch((function(t){throw salla.event.landing.getDetailsFailed(t,e),t}))}createCartFromPage(e){if(!e){let e="page landing id not passed";return salla.event.landing.orderCreationFailed(e),salla.api.errorPromise(e)}return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("landing::createCartFromPage",e),salla.event.dispatch("login::open"),salla.api.successPromise("")):this.request(["createCartFromPage",e]).then((function(t){return salla.event.landing.orderCreated(t,e).then((()=>location.href=t.data.url)),t})).catch((function(t){throw salla.event.landing.orderCreationFailed(t,e),t}))}fetchBreadcrumbs(e){if(!e.page){let e="The 'page' parameter is required for the Breadcrumb API. Please provide a valid 'page' parameter.";return salla.event.landing.breadcrumbFetchFailed(e),salla.api.errorPromise(e)}if("product.single"===e.page&&!e.id&&!e.parent_id){let e="The 'id' and 'parent_id' parameters are required when the 'page' parameter is set to 'product.single'. Please provide valid values for both parameters.";return salla.event.landing.breadcrumbFetchFailed(e),salla.api.errorPromise(e)}if(["product.index","customer.orders.single","product.index.tag","page-single","landing-page","brands.single","blog.single","blog.index.author","blog.index.category","blog.index.tag"].includes(e.page)&&!e.id){let t=`The 'id' parameter is required when the 'page' parameter is set to ${e.page}. Please provide valid value for the 'ID' parameter.`;return salla.event.landing.breadcrumbFetchFailed(t),salla.api.errorPromise(t)}return this.request("breadcrumbs",{params:e}).then((function(e){return salla.event.landing.breadcrumbFetched(e),e})).catch((function(e){throw salla.event.landing.breadcrumbFetchFailed(e),e}))}}class je extends Ae{constructor(){super(),this.namespace="notifications",this.endpoints={fetch:"notifications"},this.endpointsMethods={fetch:"get"},this.after_init()}fetch(e){return this.request(["fetch"],{params:e}).then((function(e){return salla.event.notifications.fetched(e),e})).catch((function(e){throw salla.event.notifications.fetchFailed(e),e}))}}var Be,Me={exports:{}},He=function(e,t){return function(){for(var r=new Array(arguments.length),a=0;a<r.length;a++)r[a]=arguments[a];return e.apply(t,r)}},$e=He,ze=Object.prototype.toString,Ye=(Be=Object.create(null),function(e){var t=ze.call(e);return Be[t]||(Be[t]=t.slice(8,-1).toLowerCase())});function We(e){return e=e.toLowerCase(),function(t){return Ye(t)===e}}function Ve(e){return Array.isArray(e)}function Ge(e){return void 0===e}var Qe=We("ArrayBuffer");function Ke(e){return null!==e&&"object"==typeof e}function Je(e){if("object"!==Ye(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}var Xe=We("Date"),Ze=We("File"),et=We("Blob"),tt=We("FileList");function rt(e){return"[object Function]"===ze.call(e)}var at=We("URLSearchParams");function nt(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),Ve(e))for(var r=0,a=e.length;r<a;r++)t.call(null,e[r],r,e);else for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.call(null,e[n],n,e)}var it,st=(it="undefined"!=typeof Uint8Array&&Object.getPrototypeOf(Uint8Array),function(e){return it&&e instanceof it}),ot={isArray:Ve,isArrayBuffer:Qe,isBuffer:function(e){return null!==e&&!Ge(e)&&null!==e.constructor&&!Ge(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||ze.call(e)===t||rt(e.toString)&&e.toString()===t)},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Qe(e.buffer)},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:Ke,isPlainObject:Je,isUndefined:Ge,isDate:Xe,isFile:Ze,isBlob:et,isFunction:rt,isStream:function(e){return Ke(e)&&rt(e.pipe)},isURLSearchParams:at,isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:nt,merge:function e(){var t={};function r(r,a){Je(t[a])&&Je(r)?t[a]=e(t[a],r):Je(r)?t[a]=e({},r):Ve(r)?t[a]=r.slice():t[a]=r}for(var a=0,n=arguments.length;a<n;a++)nt(arguments[a],r);return t},extend:function(e,t,r){return nt(t,(function(t,a){e[a]=r&&"function"==typeof t?$e(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,a){e.prototype=Object.create(t.prototype,a),e.prototype.constructor=e,r&&Object.assign(e.prototype,r)},toFlatObject:function(e,t,r){var a,n,i,s={};t=t||{};do{for(n=(a=Object.getOwnPropertyNames(e)).length;n-- >0;)s[i=a[n]]||(t[i]=e[i],s[i]=!0);e=Object.getPrototypeOf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:Ye,kindOfTest:We,endsWith:function(e,t,r){e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;var a=e.indexOf(t,r);return-1!==a&&a===r},toArray:function(e){if(!e)return null;var t=e.length;if(Ge(t))return null;for(var r=new Array(t);t-- >0;)r[t]=e[t];return r},isTypedArray:st,isFileList:tt},lt=ot;function ct(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var ut=function(e,t,r){if(!t)return e;var a;if(r)a=r(t);else if(lt.isURLSearchParams(t))a=t.toString();else{var n=[];lt.forEach(t,(function(e,t){null!=e&&(lt.isArray(e)?t+="[]":e=[e],lt.forEach(e,(function(e){lt.isDate(e)?e=e.toISOString():lt.isObject(e)&&(e=JSON.stringify(e)),n.push(ct(t)+"="+ct(e))})))})),a=n.join("&")}if(a){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+a}return e},dt=ot;function ht(){this.handlers=[]}ht.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},ht.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},ht.prototype.forEach=function(e){dt.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var ft=ht;function pt(){throw new Error("setTimeout has not been defined")}function gt(){throw new Error("clearTimeout has not been defined")}var mt=pt,vt=gt;function yt(e){if(mt===setTimeout)return setTimeout(e,0);if((mt===pt||!mt)&&setTimeout)return mt=setTimeout,setTimeout(e,0);try{return mt(e,0)}catch(t){try{return mt.call(null,e,0)}catch(t){return mt.call(this,e,0)}}}"function"==typeof global.setTimeout&&(mt=setTimeout),"function"==typeof global.clearTimeout&&(vt=clearTimeout);var wt,bt=[],St=!1,Et=-1;function _t(){St&&wt&&(St=!1,wt.length?bt=wt.concat(bt):Et=-1,bt.length&&At())}function At(){if(!St){var e=yt(_t);St=!0;for(var t=bt.length;t;){for(wt=bt,bt=[];++Et<t;)wt&&wt[Et].run();Et=-1,t=bt.length}wt=null,St=!1,function(e){if(vt===clearTimeout)return clearTimeout(e);if((vt===gt||!vt)&&clearTimeout)return vt=clearTimeout,clearTimeout(e);try{return vt(e)}catch(t){try{return vt.call(null,e)}catch(t){return vt.call(this,e)}}}(e)}}function Ft(e,t){this.fun=e,this.array=t}Ft.prototype.run=function(){this.fun.apply(null,this.array)};function Pt(){}var xt=Pt,Tt=Pt,Rt=Pt,Ct=Pt,Ot=Pt,kt=Pt,It=Pt;var Lt=global.performance||{},qt=Lt.now||Lt.mozNow||Lt.msNow||Lt.oNow||Lt.webkitNow||function(){return(new Date).getTime()};var Dt=new Date;var Ut,Nt,jt={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];bt.push(new Ft(e,t)),1!==bt.length||St||yt(At)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:xt,addListener:Tt,once:Rt,off:Ct,removeListener:Ot,removeAllListeners:kt,emit:It,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*qt.call(Lt),r=Math.floor(t),a=Math.floor(t%1*1e9);return e&&(r-=e[0],(a-=e[1])<0&&(r--,a+=1e9)),[r,a]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-Dt)/1e3}},Bt=jt,Mt=ot;function Ht(){if(Nt)return Ut;Nt=1;var e=ot;function t(e,t,r,a,n){Error.call(this),this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),a&&(this.request=a),n&&(this.response=n)}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,a={};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){a[e]={value:e}})),Object.defineProperties(t,a),Object.defineProperty(r,"isAxiosError",{value:!0}),t.from=function(a,n,i,s,o,l){var c=Object.create(r);return e.toFlatObject(a,c,(function(e){return e!==Error.prototype})),t.call(c,a.message,n,i,s,o),c.name=a.name,l&&Object.assign(c,l),c},Ut=t}var $t={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},zt=[],Yt=[],Wt="undefined"!=typeof Uint8Array?Uint8Array:Array,Vt=!1;function Gt(){Vt=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)zt[t]=e[t],Yt[e.charCodeAt(t)]=t;Yt["-".charCodeAt(0)]=62,Yt["_".charCodeAt(0)]=63}function Qt(e,t,r){for(var a,n,i=[],s=t;s<r;s+=3)a=(e[s]<<16)+(e[s+1]<<8)+e[s+2],i.push(zt[(n=a)>>18&63]+zt[n>>12&63]+zt[n>>6&63]+zt[63&n]);return i.join("")}function Kt(e){var t;Vt||Gt();for(var r=e.length,a=r%3,n="",i=[],s=16383,o=0,l=r-a;o<l;o+=s)i.push(Qt(e,o,o+s>l?l:o+s));return 1===a?(t=e[r-1],n+=zt[t>>2],n+=zt[t<<4&63],n+="=="):2===a&&(t=(e[r-2]<<8)+e[r-1],n+=zt[t>>10],n+=zt[t>>4&63],n+=zt[t<<2&63],n+="="),i.push(n),i.join("")}function Jt(e,t,r,a,n){var i,s,o=8*n-a-1,l=(1<<o)-1,c=l>>1,u=-7,d=r?n-1:0,h=r?-1:1,f=e[t+d];for(d+=h,i=f&(1<<-u)-1,f>>=-u,u+=o;u>0;i=256*i+e[t+d],d+=h,u-=8);for(s=i&(1<<-u)-1,i>>=-u,u+=a;u>0;s=256*s+e[t+d],d+=h,u-=8);if(0===i)i=1-c;else{if(i===l)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,a),i-=c}return(f?-1:1)*s*Math.pow(2,i-a)}function Xt(e,t,r,a,n,i){var s,o,l,c=8*i-n-1,u=(1<<c)-1,d=u>>1,h=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,f=a?0:i-1,p=a?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),(t+=s+d>=1?h/l:h*Math.pow(2,1-d))*l>=2&&(s++,l/=2),s+d>=u?(o=0,s=u):s+d>=1?(o=(t*l-1)*Math.pow(2,n),s+=d):(o=t*Math.pow(2,d-1)*Math.pow(2,n),s=0));n>=8;e[r+f]=255&o,f+=p,o/=256,n-=8);for(s=s<<n|o,c+=n;c>0;e[r+f]=255&s,f+=p,s/=256,c-=8);e[r+f-p]|=128*g}var Zt={}.toString,er=Array.isArray||function(e){return"[object Array]"==Zt.call(e)};function tr(){return ar.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function rr(e,t){if(tr()<t)throw new RangeError("Invalid typed array length");return ar.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=ar.prototype:(null===e&&(e=new ar(t)),e.length=t),e}function ar(e,t,r){if(!(ar.TYPED_ARRAY_SUPPORT||this instanceof ar))return new ar(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return sr(this,e)}return nr(this,e,t,r)}function nr(e,t,r,a){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,a){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(a||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===a?new Uint8Array(t):void 0===a?new Uint8Array(t,r):new Uint8Array(t,r,a);ar.TYPED_ARRAY_SUPPORT?(e=t).__proto__=ar.prototype:e=or(e,t);return e}(e,t,r,a):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!ar.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var a=0|ur(t,r);e=rr(e,a);var n=e.write(t,r);n!==a&&(e=e.slice(0,n));return e}(e,t,r):function(e,t){if(cr(t)){var r=0|lr(t.length);return 0===(e=rr(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(a=t.length)!=a?rr(e,0):or(e,t);if("Buffer"===t.type&&er(t.data))return or(e,t.data)}var a;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function ir(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function sr(e,t){if(ir(t),e=rr(e,t<0?0:0|lr(t)),!ar.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function or(e,t){var r=t.length<0?0:0|lr(t.length);e=rr(e,r);for(var a=0;a<r;a+=1)e[a]=255&t[a];return e}function lr(e){if(e>=tr())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+tr().toString(16)+" bytes");return 0|e}function cr(e){return!(null==e||!e._isBuffer)}function ur(e,t){if(cr(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var a=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return $r(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return zr(e).length;default:if(a)return $r(e).length;t=(""+t).toLowerCase(),a=!0}}function dr(e,t,r){var a=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Pr(this,t,r);case"utf8":case"utf-8":return Er(this,t,r);case"ascii":return Ar(this,t,r);case"latin1":case"binary":return Fr(this,t,r);case"base64":return Sr(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xr(this,t,r);default:if(a)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),a=!0}}function hr(e,t,r){var a=e[t];e[t]=e[r],e[r]=a}function fr(e,t,r,a,n){if(0===e.length)return-1;if("string"==typeof r?(a=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=n?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(n)return-1;r=e.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof t&&(t=ar.from(t,a)),cr(t))return 0===t.length?-1:pr(e,t,r,a,n);if("number"==typeof t)return t&=255,ar.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):pr(e,[t],r,a,n);throw new TypeError("val must be string, number or Buffer")}function pr(e,t,r,a,n){var i,s=1,o=e.length,l=t.length;if(void 0!==a&&("ucs2"===(a=String(a).toLowerCase())||"ucs-2"===a||"utf16le"===a||"utf-16le"===a)){if(e.length<2||t.length<2)return-1;s=2,o/=2,l/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(n){var u=-1;for(i=r;i<o;i++)if(c(e,i)===c(t,-1===u?0:i-u)){if(-1===u&&(u=i),i-u+1===l)return u*s}else-1!==u&&(i-=i-u),u=-1}else for(r+l>o&&(r=o-l),i=r;i>=0;i--){for(var d=!0,h=0;h<l;h++)if(c(e,i+h)!==c(t,h)){d=!1;break}if(d)return i}return-1}function gr(e,t,r,a){r=Number(r)||0;var n=e.length-r;a?(a=Number(a))>n&&(a=n):a=n;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");a>i/2&&(a=i/2);for(var s=0;s<a;++s){var o=parseInt(t.substr(2*s,2),16);if(isNaN(o))return s;e[r+s]=o}return s}function mr(e,t,r,a){return Yr($r(t,e.length-r),e,r,a)}function vr(e,t,r,a){return Yr(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,a)}function yr(e,t,r,a){return vr(e,t,r,a)}function wr(e,t,r,a){return Yr(zr(t),e,r,a)}function br(e,t,r,a){return Yr(function(e,t){for(var r,a,n,i=[],s=0;s<e.length&&!((t-=2)<0);++s)a=(r=e.charCodeAt(s))>>8,n=r%256,i.push(n),i.push(a);return i}(t,e.length-r),e,r,a)}function Sr(e,t,r){return 0===t&&r===e.length?Kt(e):Kt(e.slice(t,r))}function Er(e,t,r){r=Math.min(e.length,r);for(var a=[],n=t;n<r;){var i,s,o,l,c=e[n],u=null,d=c>239?4:c>223?3:c>191?2:1;if(n+d<=r)switch(d){case 1:c<128&&(u=c);break;case 2:128==(192&(i=e[n+1]))&&(l=(31&c)<<6|63&i)>127&&(u=l);break;case 3:i=e[n+1],s=e[n+2],128==(192&i)&&128==(192&s)&&(l=(15&c)<<12|(63&i)<<6|63&s)>2047&&(l<55296||l>57343)&&(u=l);break;case 4:i=e[n+1],s=e[n+2],o=e[n+3],128==(192&i)&&128==(192&s)&&128==(192&o)&&(l=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&o)>65535&&l<1114112&&(u=l)}null===u?(u=65533,d=1):u>65535&&(u-=65536,a.push(u>>>10&1023|55296),u=56320|1023&u),a.push(u),n+=d}return function(e){var t=e.length;if(t<=_r)return String.fromCharCode.apply(String,e);var r="",a=0;for(;a<t;)r+=String.fromCharCode.apply(String,e.slice(a,a+=_r));return r}(a)}ar.TYPED_ARRAY_SUPPORT=void 0===global.TYPED_ARRAY_SUPPORT||global.TYPED_ARRAY_SUPPORT,tr(),ar.poolSize=8192,ar._augment=function(e){return e.__proto__=ar.prototype,e},ar.from=function(e,t,r){return nr(null,e,t,r)},ar.TYPED_ARRAY_SUPPORT&&(ar.prototype.__proto__=Uint8Array.prototype,ar.__proto__=Uint8Array),ar.alloc=function(e,t,r){return function(e,t,r,a){return ir(t),t<=0?rr(e,t):void 0!==r?"string"==typeof a?rr(e,t).fill(r,a):rr(e,t).fill(r):rr(e,t)}(null,e,t,r)},ar.allocUnsafe=function(e){return sr(null,e)},ar.allocUnsafeSlow=function(e){return sr(null,e)},ar.isBuffer=function(e){return null!=e&&(!!e._isBuffer||Wr(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&Wr(e.slice(0,0))}(e))},ar.compare=function(e,t){if(!cr(e)||!cr(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,a=t.length,n=0,i=Math.min(r,a);n<i;++n)if(e[n]!==t[n]){r=e[n],a=t[n];break}return r<a?-1:a<r?1:0},ar.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},ar.concat=function(e,t){if(!er(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return ar.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var a=ar.allocUnsafe(t),n=0;for(r=0;r<e.length;++r){var i=e[r];if(!cr(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(a,n),n+=i.length}return a},ar.byteLength=ur,ar.prototype._isBuffer=!0,ar.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)hr(this,t,t+1);return this},ar.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)hr(this,t,t+3),hr(this,t+1,t+2);return this},ar.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)hr(this,t,t+7),hr(this,t+1,t+6),hr(this,t+2,t+5),hr(this,t+3,t+4);return this},ar.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?Er(this,0,e):dr.apply(this,arguments)},ar.prototype.equals=function(e){if(!cr(e))throw new TypeError("Argument must be a Buffer");return this===e||0===ar.compare(this,e)},ar.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},ar.prototype.compare=function(e,t,r,a,n){if(!cr(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===a&&(a=0),void 0===n&&(n=this.length),t<0||r>e.length||a<0||n>this.length)throw new RangeError("out of range index");if(a>=n&&t>=r)return 0;if(a>=n)return-1;if(t>=r)return 1;if(this===e)return 0;for(var i=(n>>>=0)-(a>>>=0),s=(r>>>=0)-(t>>>=0),o=Math.min(i,s),l=this.slice(a,n),c=e.slice(t,r),u=0;u<o;++u)if(l[u]!==c[u]){i=l[u],s=c[u];break}return i<s?-1:s<i?1:0},ar.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},ar.prototype.indexOf=function(e,t,r){return fr(this,e,t,r,!0)},ar.prototype.lastIndexOf=function(e,t,r){return fr(this,e,t,r,!1)},ar.prototype.write=function(e,t,r,a){if(void 0===t)a="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)a=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===a&&(a="utf8")):(a=r,r=void 0)}var n=this.length-t;if((void 0===r||r>n)&&(r=n),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");a||(a="utf8");for(var i=!1;;)switch(a){case"hex":return gr(this,e,t,r);case"utf8":case"utf-8":return mr(this,e,t,r);case"ascii":return vr(this,e,t,r);case"latin1":case"binary":return yr(this,e,t,r);case"base64":return wr(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return br(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+a);a=(""+a).toLowerCase(),i=!0}},ar.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var _r=4096;function Ar(e,t,r){var a="";r=Math.min(e.length,r);for(var n=t;n<r;++n)a+=String.fromCharCode(127&e[n]);return a}function Fr(e,t,r){var a="";r=Math.min(e.length,r);for(var n=t;n<r;++n)a+=String.fromCharCode(e[n]);return a}function Pr(e,t,r){var a=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>a)&&(r=a);for(var n="",i=t;i<r;++i)n+=Hr(e[i]);return n}function xr(e,t,r){for(var a=e.slice(t,r),n="",i=0;i<a.length;i+=2)n+=String.fromCharCode(a[i]+256*a[i+1]);return n}function Tr(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function Rr(e,t,r,a,n,i){if(!cr(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<i)throw new RangeError('"value" argument is out of bounds');if(r+a>e.length)throw new RangeError("Index out of range")}function Cr(e,t,r,a){t<0&&(t=65535+t+1);for(var n=0,i=Math.min(e.length-r,2);n<i;++n)e[r+n]=(t&255<<8*(a?n:1-n))>>>8*(a?n:1-n)}function Or(e,t,r,a){t<0&&(t=4294967295+t+1);for(var n=0,i=Math.min(e.length-r,4);n<i;++n)e[r+n]=t>>>8*(a?n:3-n)&255}function kr(e,t,r,a,n,i){if(r+a>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ir(e,t,r,a,n){return n||kr(e,0,r,4),Xt(e,t,r,a,23,4),r+4}function Lr(e,t,r,a,n){return n||kr(e,0,r,8),Xt(e,t,r,a,52,8),r+8}ar.prototype.slice=function(e,t){var r,a=this.length;if((e=~~e)<0?(e+=a)<0&&(e=0):e>a&&(e=a),(t=void 0===t?a:~~t)<0?(t+=a)<0&&(t=0):t>a&&(t=a),t<e&&(t=e),ar.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=ar.prototype;else{var n=t-e;r=new ar(n,void 0);for(var i=0;i<n;++i)r[i]=this[i+e]}return r},ar.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||Tr(e,t,this.length);for(var a=this[e],n=1,i=0;++i<t&&(n*=256);)a+=this[e+i]*n;return a},ar.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||Tr(e,t,this.length);for(var a=this[e+--t],n=1;t>0&&(n*=256);)a+=this[e+--t]*n;return a},ar.prototype.readUInt8=function(e,t){return t||Tr(e,1,this.length),this[e]},ar.prototype.readUInt16LE=function(e,t){return t||Tr(e,2,this.length),this[e]|this[e+1]<<8},ar.prototype.readUInt16BE=function(e,t){return t||Tr(e,2,this.length),this[e]<<8|this[e+1]},ar.prototype.readUInt32LE=function(e,t){return t||Tr(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ar.prototype.readUInt32BE=function(e,t){return t||Tr(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ar.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||Tr(e,t,this.length);for(var a=this[e],n=1,i=0;++i<t&&(n*=256);)a+=this[e+i]*n;return a>=(n*=128)&&(a-=Math.pow(2,8*t)),a},ar.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||Tr(e,t,this.length);for(var a=t,n=1,i=this[e+--a];a>0&&(n*=256);)i+=this[e+--a]*n;return i>=(n*=128)&&(i-=Math.pow(2,8*t)),i},ar.prototype.readInt8=function(e,t){return t||Tr(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ar.prototype.readInt16LE=function(e,t){t||Tr(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},ar.prototype.readInt16BE=function(e,t){t||Tr(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},ar.prototype.readInt32LE=function(e,t){return t||Tr(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ar.prototype.readInt32BE=function(e,t){return t||Tr(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ar.prototype.readFloatLE=function(e,t){return t||Tr(e,4,this.length),Jt(this,e,!0,23,4)},ar.prototype.readFloatBE=function(e,t){return t||Tr(e,4,this.length),Jt(this,e,!1,23,4)},ar.prototype.readDoubleLE=function(e,t){return t||Tr(e,8,this.length),Jt(this,e,!0,52,8)},ar.prototype.readDoubleBE=function(e,t){return t||Tr(e,8,this.length),Jt(this,e,!1,52,8)},ar.prototype.writeUIntLE=function(e,t,r,a){(e=+e,t|=0,r|=0,a)||Rr(this,e,t,r,Math.pow(2,8*r)-1,0);var n=1,i=0;for(this[t]=255&e;++i<r&&(n*=256);)this[t+i]=e/n&255;return t+r},ar.prototype.writeUIntBE=function(e,t,r,a){(e=+e,t|=0,r|=0,a)||Rr(this,e,t,r,Math.pow(2,8*r)-1,0);var n=r-1,i=1;for(this[t+n]=255&e;--n>=0&&(i*=256);)this[t+n]=e/i&255;return t+r},ar.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||Rr(this,e,t,1,255,0),ar.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},ar.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||Rr(this,e,t,2,65535,0),ar.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Cr(this,e,t,!0),t+2},ar.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||Rr(this,e,t,2,65535,0),ar.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Cr(this,e,t,!1),t+2},ar.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||Rr(this,e,t,4,4294967295,0),ar.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Or(this,e,t,!0),t+4},ar.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||Rr(this,e,t,4,4294967295,0),ar.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Or(this,e,t,!1),t+4},ar.prototype.writeIntLE=function(e,t,r,a){if(e=+e,t|=0,!a){var n=Math.pow(2,8*r-1);Rr(this,e,t,r,n-1,-n)}var i=0,s=1,o=0;for(this[t]=255&e;++i<r&&(s*=256);)e<0&&0===o&&0!==this[t+i-1]&&(o=1),this[t+i]=(e/s>>0)-o&255;return t+r},ar.prototype.writeIntBE=function(e,t,r,a){if(e=+e,t|=0,!a){var n=Math.pow(2,8*r-1);Rr(this,e,t,r,n-1,-n)}var i=r-1,s=1,o=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===o&&0!==this[t+i+1]&&(o=1),this[t+i]=(e/s>>0)-o&255;return t+r},ar.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||Rr(this,e,t,1,127,-128),ar.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},ar.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||Rr(this,e,t,2,32767,-32768),ar.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Cr(this,e,t,!0),t+2},ar.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||Rr(this,e,t,2,32767,-32768),ar.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Cr(this,e,t,!1),t+2},ar.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||Rr(this,e,t,4,2147483647,-2147483648),ar.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Or(this,e,t,!0),t+4},ar.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||Rr(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),ar.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Or(this,e,t,!1),t+4},ar.prototype.writeFloatLE=function(e,t,r){return Ir(this,e,t,!0,r)},ar.prototype.writeFloatBE=function(e,t,r){return Ir(this,e,t,!1,r)},ar.prototype.writeDoubleLE=function(e,t,r){return Lr(this,e,t,!0,r)},ar.prototype.writeDoubleBE=function(e,t,r){return Lr(this,e,t,!1,r)},ar.prototype.copy=function(e,t,r,a){if(r||(r=0),a||0===a||(a=this.length),t>=e.length&&(t=e.length),t||(t=0),a>0&&a<r&&(a=r),a===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(a<0)throw new RangeError("sourceEnd out of bounds");a>this.length&&(a=this.length),e.length-t<a-r&&(a=e.length-t+r);var n,i=a-r;if(this===e&&r<t&&t<a)for(n=i-1;n>=0;--n)e[n+t]=this[n+r];else if(i<1e3||!ar.TYPED_ARRAY_SUPPORT)for(n=0;n<i;++n)e[n+t]=this[n+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+i),t);return i},ar.prototype.fill=function(e,t,r,a){if("string"==typeof e){if("string"==typeof t?(a=t,t=0,r=this.length):"string"==typeof r&&(a=r,r=this.length),1===e.length){var n=e.charCodeAt(0);n<256&&(e=n)}if(void 0!==a&&"string"!=typeof a)throw new TypeError("encoding must be a string");if("string"==typeof a&&!ar.isEncoding(a))throw new TypeError("Unknown encoding: "+a)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var i;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{var s=cr(e)?e:$r(new ar(e,a).toString()),o=s.length;for(i=0;i<r-t;++i)this[i+t]=s[i%o]}return this};var qr,Dr,Ur,Nr,jr,Br,Mr=/[^+\/0-9A-Za-z-_]/g;function Hr(e){return e<16?"0"+e.toString(16):e.toString(16)}function $r(e,t){var r;t=t||1/0;for(var a=e.length,n=null,i=[],s=0;s<a;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!n){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===a){(t-=3)>-1&&i.push(239,191,189);continue}n=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(t-=3)>-1&&i.push(239,191,189);if(n=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function zr(e){return function(e){var t,r,a,n,i,s;Vt||Gt();var o=e.length;if(o%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i="="===e[o-2]?2:"="===e[o-1]?1:0,s=new Wt(3*o/4-i),a=i>0?o-4:o;var l=0;for(t=0,r=0;t<a;t+=4,r+=3)n=Yt[e.charCodeAt(t)]<<18|Yt[e.charCodeAt(t+1)]<<12|Yt[e.charCodeAt(t+2)]<<6|Yt[e.charCodeAt(t+3)],s[l++]=n>>16&255,s[l++]=n>>8&255,s[l++]=255&n;return 2===i?(n=Yt[e.charCodeAt(t)]<<2|Yt[e.charCodeAt(t+1)]>>4,s[l++]=255&n):1===i&&(n=Yt[e.charCodeAt(t)]<<10|Yt[e.charCodeAt(t+1)]<<4|Yt[e.charCodeAt(t+2)]>>2,s[l++]=n>>8&255,s[l++]=255&n),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Mr,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Yr(e,t,r,a){for(var n=0;n<a&&!(n+r>=t.length||n>=e.length);++n)t[n+r]=e[n];return n}function Wr(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Vr(){if(Dr)return qr;Dr=1;var e=ot;return qr=function(t,r){r=r||new FormData;var a=[];function n(t){return null===t?"":e.isDate(t)?t.toISOString():e.isArrayBuffer(t)||e.isTypedArray(t)?"function"==typeof Blob?new Blob([t]):ar.from(t):t}return function t(i,s){if(e.isPlainObject(i)||e.isArray(i)){if(-1!==a.indexOf(i))throw Error("Circular reference detected in "+s);a.push(i),e.forEach(i,(function(a,i){if(!e.isUndefined(a)){var o,l=s?s+"."+i:i;if(a&&!s&&"object"==typeof a)if(e.endsWith(i,"{}"))a=JSON.stringify(a);else if(e.endsWith(i,"[]")&&(o=e.toArray(a)))return void o.forEach((function(t){!e.isUndefined(t)&&r.append(l,n(t))}));t(a,l)}})),a.pop()}else r.append(s,n(i))}(t),r},qr}function Gr(){if(Nr)return Ur;Nr=1;var e=Ht();return Ur=function(t,r,a){var n=a.config.validateStatus;a.status&&n&&!n(a.status)?r(new e("Request failed with status code "+a.status,[e.ERR_BAD_REQUEST,e.ERR_BAD_RESPONSE][Math.floor(a.status/100)-4],a.config,a.request,a)):t(a)}}function Qr(){if(Br)return jr;Br=1;var e=ot;return jr=e.isStandardBrowserEnv()?{write:function(t,r,a,n,i,s){var o=[];o.push(t+"="+encodeURIComponent(r)),e.isNumber(a)&&o.push("expires="+new Date(a).toGMTString()),e.isString(n)&&o.push("path="+n),e.isString(i)&&o.push("domain="+i),!0===s&&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 Kr,Jr,Xr,Zr,ea,ta,ra,aa,na,ia,sa,oa,la=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},ca=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},ua=function(e,t){return e&&!la(t)?ca(e,t):t};function da(){if(Jr)return Kr;Jr=1;var e=ot,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 Kr=function(r){var a,n,i,s={};return r?(e.forEach(r.split("\n"),(function(r){if(i=r.indexOf(":"),a=e.trim(r.substr(0,i)).toLowerCase(),n=e.trim(r.substr(i+1)),a){if(s[a]&&t.indexOf(a)>=0)return;s[a]="set-cookie"===a?(s[a]?s[a]:[]).concat([n]):s[a]?s[a]+", "+n:n}})),s):s},Kr}function ha(){if(Zr)return Xr;Zr=1;var e=ot;return Xr=e.isStandardBrowserEnv()?function(){var t,r=/(msie|trident)/i.test(navigator.userAgent),a=document.createElement("a");function n(e){var t=e;return r&&(a.setAttribute("href",t),t=a.href),a.setAttribute("href",t),{href:a.href,protocol:a.protocol?a.protocol.replace(/:$/,""):"",host:a.host,search:a.search?a.search.replace(/^\?/,""):"",hash:a.hash?a.hash.replace(/^#/,""):"",hostname:a.hostname,port:a.port,pathname:"/"===a.pathname.charAt(0)?a.pathname:"/"+a.pathname}}return t=n(window.location.href),function(r){var a=e.isString(r)?n(r):r;return a.protocol===t.protocol&&a.host===t.host}}():function(){return!0}}function fa(){if(ta)return ea;ta=1;var e=Ht();function t(t){e.call(this,null==t?"canceled":t,e.ERR_CANCELED),this.name="CanceledError"}return ot.inherits(t,e,{__CANCEL__:!0}),ea=t}function pa(){return aa?ra:(aa=1,ra=function(e){var t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""})}function ga(){if(ia)return na;ia=1;var e=ot,t=Gr(),r=Qr(),a=ut,n=ua,i=da(),s=ha(),o=$t,l=Ht(),c=fa(),u=pa();return na=function(d){return new Promise((function(h,f){var p,g=d.data,m=d.headers,v=d.responseType;function y(){d.cancelToken&&d.cancelToken.unsubscribe(p),d.signal&&d.signal.removeEventListener("abort",p)}e.isFormData(g)&&e.isStandardBrowserEnv()&&delete m["Content-Type"];var w=new XMLHttpRequest;if(d.auth){var b=d.auth.username||"",S=d.auth.password?unescape(encodeURIComponent(d.auth.password)):"";m.Authorization="Basic "+btoa(b+":"+S)}var E=n(d.baseURL,d.url);function _(){if(w){var e="getAllResponseHeaders"in w?i(w.getAllResponseHeaders()):null,r={data:v&&"text"!==v&&"json"!==v?w.response:w.responseText,status:w.status,statusText:w.statusText,headers:e,config:d,request:w};t((function(e){h(e),y()}),(function(e){f(e),y()}),r),w=null}}if(w.open(d.method.toUpperCase(),a(E,d.params,d.paramsSerializer),!0),w.timeout=d.timeout,"onloadend"in w?w.onloadend=_:w.onreadystatechange=function(){w&&4===w.readyState&&(0!==w.status||w.responseURL&&0===w.responseURL.indexOf("file:"))&&setTimeout(_)},w.onabort=function(){w&&(f(new l("Request aborted",l.ECONNABORTED,d,w)),w=null)},w.onerror=function(){f(new l("Network Error",l.ERR_NETWORK,d,w,w)),w=null},w.ontimeout=function(){var e=d.timeout?"timeout of "+d.timeout+"ms exceeded":"timeout exceeded",t=d.transitional||o;d.timeoutErrorMessage&&(e=d.timeoutErrorMessage),f(new l(e,t.clarifyTimeoutError?l.ETIMEDOUT:l.ECONNABORTED,d,w)),w=null},e.isStandardBrowserEnv()){var A=(d.withCredentials||s(E))&&d.xsrfCookieName?r.read(d.xsrfCookieName):void 0;A&&(m[d.xsrfHeaderName]=A)}"setRequestHeader"in w&&e.forEach(m,(function(e,t){void 0===g&&"content-type"===t.toLowerCase()?delete m[t]:w.setRequestHeader(t,e)})),e.isUndefined(d.withCredentials)||(w.withCredentials=!!d.withCredentials),v&&"json"!==v&&(w.responseType=d.responseType),"function"==typeof d.onDownloadProgress&&w.addEventListener("progress",d.onDownloadProgress),"function"==typeof d.onUploadProgress&&w.upload&&w.upload.addEventListener("progress",d.onUploadProgress),(d.cancelToken||d.signal)&&(p=function(e){w&&(f(!e||e&&e.type?new c:e),w.abort(),w=null)},d.cancelToken&&d.cancelToken.subscribe(p),d.signal&&(d.signal.aborted?p():d.signal.addEventListener("abort",p))),g||(g=null);var F=u(E);F&&-1===["http","https","file"].indexOf(F)?f(new l("Unsupported protocol "+F+":",l.ERR_BAD_REQUEST,d)):w.send(g)}))},na}var ma=ot,va=function(e,t){Mt.forEach(e,(function(r,a){a!==t&&a.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[a])}))},ya=Ht(),wa=$t,ba=Vr(),Sa={"Content-Type":"application/x-www-form-urlencoded"};function Ea(e,t){!ma.isUndefined(e)&&ma.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var _a,Aa={transitional:wa,adapter:(("undefined"!=typeof XMLHttpRequest||void 0!==Bt&&"[object process]"===Object.prototype.toString.call(Bt))&&(_a=ga()),_a),transformRequest:[function(e,t){if(va(t,"Accept"),va(t,"Content-Type"),ma.isFormData(e)||ma.isArrayBuffer(e)||ma.isBuffer(e)||ma.isStream(e)||ma.isFile(e)||ma.isBlob(e))return e;if(ma.isArrayBufferView(e))return e.buffer;if(ma.isURLSearchParams(e))return Ea(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString();var r,a=ma.isObject(e),n=t&&t["Content-Type"];if((r=ma.isFileList(e))||a&&"multipart/form-data"===n){var i=this.env&&this.env.FormData;return ba(r?{"files[]":e}:e,i&&new i)}return a||"application/json"===n?(Ea(t,"application/json"),function(e,t,r){if(ma.isString(e))try{return(t||JSON.parse)(e),ma.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||Aa.transitional,r=t&&t.silentJSONParsing,a=t&&t.forcedJSONParsing,n=!r&&"json"===this.responseType;if(n||a&&ma.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw ya.from(e,ya.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:oa?sa:(oa=1,sa=null)},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};ma.forEach(["delete","get","head"],(function(e){Aa.headers[e]={}})),ma.forEach(["post","put","patch"],(function(e){Aa.headers[e]=ma.merge(Sa)}));var Fa,Pa,xa=Aa,Ta=ot,Ra=xa;function Ca(){return Pa?Fa:(Pa=1,Fa=function(e){return!(!e||!e.__CANCEL__)})}var Oa=ot,ka=function(e,t,r){var a=this||Ra;return Ta.forEach(r,(function(r){e=r.call(a,e,t)})),e},Ia=Ca(),La=xa,qa=fa();function Da(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new qa}var Ua,Na,ja=ot,Ba=function(e,t){t=t||{};var r={};function a(e,t){return ja.isPlainObject(e)&&ja.isPlainObject(t)?ja.merge(e,t):ja.isPlainObject(t)?ja.merge({},t):ja.isArray(t)?t.slice():t}function n(r){return ja.isUndefined(t[r])?ja.isUndefined(e[r])?void 0:a(void 0,e[r]):a(e[r],t[r])}function i(e){if(!ja.isUndefined(t[e]))return a(void 0,t[e])}function s(r){return ja.isUndefined(t[r])?ja.isUndefined(e[r])?void 0:a(void 0,e[r]):a(void 0,t[r])}function o(r){return r in t?a(e[r],t[r]):r in e?a(void 0,e[r]):void 0}var l={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:o};return ja.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=l[e]||n,a=t(e);ja.isUndefined(a)&&t!==o||(r[e]=a)})),r};function Ma(){return Na?Ua:(Na=1,Ua={version:"0.27.2"})}var Ha=Ma().version,$a=Ht(),za={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){za[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var Ya={};za.transitional=function(e,t,r){function a(e,t){return"[Axios v"+Ha+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return function(r,n,i){if(!1===e)throw new $a(a(n," has been removed"+(t?" in "+t:"")),$a.ERR_DEPRECATED);return t&&!Ya[n]&&(Ya[n]=!0,console.warn(a(n," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,n,i)}};var Wa,Va,Ga,Qa,Ka,Ja,Xa={assertOptions:function(e,t,r){if("object"!=typeof e)throw new $a("options must be an object",$a.ERR_BAD_OPTION_VALUE);for(var a=Object.keys(e),n=a.length;n-- >0;){var i=a[n],s=t[i];if(s){var o=e[i],l=void 0===o||s(o,i,e);if(!0!==l)throw new $a("option "+i+" must be "+l,$a.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new $a("Unknown option "+i,$a.ERR_BAD_OPTION)}},validators:za},Za=ot,en=ut,tn=ft,rn=function(e){return Da(e),e.headers=e.headers||{},e.data=ka.call(e,e.data,e.headers,e.transformRequest),e.headers=Oa.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Oa.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||La.adapter)(e).then((function(t){return Da(e),t.data=ka.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return Ia(t)||(Da(e),t&&t.response&&(t.response.data=ka.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},an=Ba,nn=ua,sn=Xa,on=sn.validators;function ln(e){this.defaults=e,this.interceptors={request:new tn,response:new tn}}ln.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=an(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&&sn.assertOptions(r,{silentJSONParsing:on.transitional(on.boolean),forcedJSONParsing:on.transitional(on.boolean),clarifyTimeoutError:on.transitional(on.boolean)},!1);var a=[],n=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(n=n&&e.synchronous,a.unshift(e.fulfilled,e.rejected))}));var i,s=[];if(this.interceptors.response.forEach((function(e){s.push(e.fulfilled,e.rejected)})),!n){var o=[rn,void 0];for(Array.prototype.unshift.apply(o,a),o=o.concat(s),i=Promise.resolve(t);o.length;)i=i.then(o.shift(),o.shift());return i}for(var l=t;a.length;){var c=a.shift(),u=a.shift();try{l=c(l)}catch(e){u(e);break}}try{i=rn(l)}catch(e){return Promise.reject(e)}for(;s.length;)i=i.then(s.shift(),s.shift());return i},ln.prototype.getUri=function(e){e=an(this.defaults,e);var t=nn(e.baseURL,e.url);return en(t,e.params,e.paramsSerializer)},Za.forEach(["delete","get","head","options"],(function(e){ln.prototype[e]=function(t,r){return this.request(an(r||{},{method:e,url:t,data:(r||{}).data}))}})),Za.forEach(["post","put","patch"],(function(e){function t(t){return function(r,a,n){return this.request(an(n||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:a}))}}ln.prototype[e]=t(),ln.prototype[e+"Form"]=t(!0)}));var cn=ot,un=He,dn=ln,hn=Ba;var fn=function e(t){var r=new dn(t),a=un(dn.prototype.request,r);return cn.extend(a,dn.prototype,r),cn.extend(a,r),a.create=function(r){return e(hn(t,r))},a}(xa);fn.Axios=dn,fn.CanceledError=fa(),fn.CancelToken=function(){if(Va)return Wa;Va=1;var e=fa();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 a=this;this.promise.then((function(e){if(a._listeners){var t,r=a._listeners.length;for(t=0;t<r;t++)a._listeners[t](e);a._listeners=null}})),this.promise.then=function(e){var t,r=new Promise((function(e){a.subscribe(e),t=e})).then(e);return r.cancel=function(){a.unsubscribe(t)},r},t((function(t){a.reason||(a.reason=new e(t),r(a.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,r=new t((function(t){e=t}));return{token:r,cancel:e}},Wa=t}(),fn.isCancel=Ca(),fn.VERSION=Ma().version,fn.toFormData=Vr(),fn.AxiosError=Ht(),fn.Cancel=fn.CanceledError,fn.all=function(e){return Promise.all(e)},fn.spread=Qa?Ga:(Qa=1,Ga=function(e){return function(t){return e.apply(null,t)}}),fn.isAxiosError=function(){if(Ja)return Ka;Ja=1;var e=ot;return Ka=function(t){return e.isObject(t)&&!0===t.isAxiosError}}(),Me.exports=fn,Me.exports.default=fn;var pn=Me.exports;function gn(e){this.message=e}gn.prototype=new Error,gn.prototype.name="InvalidCharacterError";var mn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new gn("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,a,n=0,i=0,s="";a=t.charAt(i++);~a&&(r=n%4?64*r+a:a,n++%4)?s+=String.fromCharCode(255&r>>(-2*n&6)):0)a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a);return s};function vn(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(mn(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 mn(t)}}function yn(e){this.message=e}yn.prototype=new Error,yn.prototype.name="InvalidTokenError";class wn{constructor(){this.inIframe=salla.helpers.isIframe(),salla.event.on("twilight::before.ready",(e=>this.initiateRequest(e))),salla.event.on("profile::info.fetched",(e=>this.setCurrencyAndLanguage(e))),salla.event.on("auth::token.fetched",(e=>{salla.storage.set("token",e),this.inIframe&&salla.log("token fetched iframe"),this.inIframe&&salla.cookie.set("s-token",e,60),this.setToken(e)})),salla.event.on("auth::token.invalid",(()=>{salla.storage.remove("user"),salla.storage.remove("token")})),this.notifier_handler_disabled=!1,this.axios=pn.create({headers:{common:{"X-Requested-With":"XMLHttpRequest","S-SOURCE":"twilight","S-APP-VERSION":"v2.0.0","S-APP-OS":"browser","cache-control":"no-cache"}}})}getHeaders(){return this.axios.defaults.headers.common}setHeaders(e){return Object.entries(e).forEach((e=>this.setHeader(e[0],e[1]))),this}setHeader(e,t){return salla.infiniteScroll.fetchOptions.headers[e]=this.axios.defaults.headers.common[e]=t,this}async withoutNotifier(e){return this.notifier_handler_disabled=!0,await e().finally((()=>{this.notifier_handler_disabled=!1}))}async initiateRequest(e){this.axios.defaults.baseURL=Salla.config.get("store.api",Salla.config.get("store.url")),this.setHeaders({"Store-Identifier":Salla.config.get("store.id"),currency:e.user?.currency_code||"SAR","accept-language":salla.lang.getLocale(),"s-user-id":e.user?.id,...e.headers||{}});const t=salla.storage.get("scope");t&&this.setHeaders({"s-scope-type":t.type,"s-scope-id":t.id});const r=salla.storage.session.get("s-utms");r&&this.setHeaders(r),await this.injectTokenToTheRequests(e),salla.storage.get("affiliate_code")&&this.setHeader("s-affiliate-code",salla.storage.get("affiliate_code"))}async injectTokenToTheRequests(e){let t=salla.storage.get("token"),r="guest"===e.user.type,a=e.user?.id,n=salla.storage.get("user.id"),i=e=>{this.setToken(e),salla.event.emit("api::initiated")},s=async()=>{!r&&a?(salla.log("Api:: case 1 => current is is guest & web session available"),await salla.auth.api.refresh().then((async()=>{await salla.profile.info()})).catch((()=>salla.auth.event.tokenInvalid()))):salla.auth.event.tokenInvalid()};if(!t)return salla.log("Api:: case 1 => current is is guest"),void await s();let o=function(e,t){if("string"!=typeof e)throw new yn("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(vn(e.split(".")[r]))}catch(e){throw new yn("Invalid token specified: "+e.message)}}(t);return Date.now()/1e3>o.exp?(salla.log("Api:: case 2 => current user is logged-in and there is a token, but it's expired"),void await s()):o.sub===a&&n===a&&n&&a?(salla.log("Api:: case 4 => current user is logged-in and there is a token, and it's not expired"),void i(t)):(salla.log("Api:: case 3 => there is a token and user in session/local missing or mismatch"),salla.log(`sub:${o.sub} userIdInWeb:${a} userIdInStorage:${n}`),this.setHeader("Authorization","Bearer "+t),void await salla.profile.info().then((async e=>{!this.inIframe&&await salla.auth.api.request("auth/jwt",{callerName:"salla.auth.request.injectTokenToTheRequests"}),i(t)})).catch((()=>{salla.log("Api:: case 3 => failed get fresh profile"),this.setHeader("Authorization",null),salla.auth.event.tokenInvalid()})))}setToken(e){return this.setHeader("Authorization","Bearer "+e),salla.event.emit("api::token.injected",e),this.token=e,this}setCurrencyAndLanguage(e){return this.setHeaders({currency:e.data.currency,"accept-language":e.data.language})}request(e,t=void 0,r="get",a={}){let n={endPoint:e,payload:t,method:r,options:a},i="undefined"!=typeof event?event.currentTarget:null,s=!1;return"SALLA-BUTTON"===i?.tagName&&(s=!0),s&&i?.load(),this.axios[n.method](n.endPoint,n.payload,n.options).then((e=>(s&&i?.stop(),e.data&&e.request&&(e=e.data),this.handleAfterResponseActions(e),e))).catch((e=>{throw s&&i?.stop(),salla.event.document.requestFailed(n,e),this.handleErrorResponse(e),e}))}handleAfterResponseActions(e){if(!e)return;let{data:t,googleTags:r=null}=e,a=t&&t.googleTags?t.googleTags:r;try{dataLayer&&a&&dataLayer.push(a)}catch(e){salla.logger.error(e.message)}this.fireEventsForResponse(e),this.showAlert(e)}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])))}handleErrorResponse(e){if(e.response&&e.response.data)return e.response.data.error&&e.response.data.error.fields&&!this.notifier_handler_disabled?this.handleInvalidFields(e):this.handleAfterResponseActions(e.response.data)}showAlert(e){if(e&&!this.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 a=t[e];Array.isArray(a)?a.forEach((e=>r.push(e))):r.push(a)}));let a=(r.length>1?"* ":"")+r.join("\n* ");salla.error(a,e)}isFastRequestsAllowed(){return Salla.config.get("fastRequests")}promise(e,t=!0){return new Promise(((r,a)=>t?r(e):a(e)))}errorPromise(e){return this.promise(e,!1)}successPromise(e){return this.promise(e,!0)}}class bn extends Ae{constructor(){super(),this.namespace="component",this.endpoints={getMenus:"menus/{headOrFoot}",reviews:"reviews"},this.endpointsMethods={getMenus:"get",reviews:"get"}}async getMenus(e="header"){return this.request(["getMenus",e]).then((function(e){return salla.event.component.menuFetched(e),e})).catch((function(e){throw salla.event.component.menuFetchFailed(e),e}))}async getReviews({per_page:e=5,type:t="all",items:r}){if(!t){const e="Review type cannot be empty. Please provide one.";return salla.event.component.reviewsFetchFailed(e),salla.api.errorPromise(e)}const a=!r||"string"==typeof r&&"[]"===r||Array.isArray(r)&&!r.length;if(!new Set(["all","store","categories","products","json"]).has(t)){const e="Invalid review type. Please provide a valid type.";return salla.event.component.reviewsFetchFailed(e),salla.api.errorPromise(e)}if("all"!==t&&"store"!==t&&a){const e="Items cannot be empty. Please provide one.";return salla.event.component.reviewsFetchFailed(e),salla.api.errorPromise(e)}if(new Set(["products","categories"]).has(t)&&!Array.isArray(r)){const e=`Items value must be an array of ${t} id for review type of ${t}.`;return salla.event.component.reviewsFetchFailed(e),salla.api.errorPromise(e)}return this.request(["reviews"],{params:{per_page:e,type:t,items:r}},"get").then((function(e){return salla.event.component.reviewsFetched(e),e})).catch((function(e){throw salla.event.component.reviewsFetchFailed(e),e}))}}class Sn extends Ae{constructor(){super(),this.namespace="booking",this.endpoints={fetch:"advertisements"},this.endpointsMethods={fetch:"get"}}async fetch(e=null){const t=e?{page:e}:{};return this.request(["fetch"],{params:t}).then((function(e){return salla.event.advertisement.fetched(e),e})).catch((function(e){throw salla.event.advertisement.fetchFailed(e),e}))}}class En extends Ae{constructor(){super(),this.namespace="navigation",this.endpoints={breadcrumbs:"breadcrumbs"},this.endpointsMethods={breadcrumbs:"get"},this.after_init()}fetchBreadcrumbs(e){if(!e.page){let e="The 'page' parameter is required for the Breadcrumb API. Please provide a valid 'page' parameter.";return salla.event.navigation.breadcrumbFetchFailed(e),salla.api.errorPromise(e)}if(["product.single","product.index","customer.orders.single","product.index.tag","page-single","landing-page","brands.single","blog.single","blog.index.author","blog.index.category","blog.index.tag"].includes(e.page)&&!e.id){let t=`The 'id' parameter is required when the 'page' parameter is set to ${e.page}. Please provide valid value for the 'ID' parameter.`;return salla.event.navigation.breadcrumbFetchFailed(t),salla.api.errorPromise(t)}return this.request("breadcrumbs",{params:e}).then((function(e){return salla.event.navigation.breadcrumbFetched(e),e})).catch((function(e){throw salla.event.navigation.breadcrumbFetchFailed(e),e}))}}class _n{constructor(e){"ready"!==Y.status?e?(Y.config.merge(e),e?.events&&Y.event.dispatchEvents(e?.events),e._token&&salla.api.setHeader("X-CSRF-TOKEN",e._token),this.injectMaintenanceAlert(),this.injectTemplateStoreAlert(),this.injectThemePreviewAlert(),this.injectAppInstallAlert(),this.injectEditAlert(),e?.user?.language_code&&salla.lang.setLocale(e?.user?.language_code),salla.lang.loadStoreTranslations(),this.setSallaReady(e)):this.setSallaReady(e):salla.log("Trying to re-initiate Salla, while its status === 'ready'!")}injectMaintenanceAlert(){salla.config.get("maintenance")&&(document.body.classList.add("has-maintenance-bar"),document.querySelector("salla-maintenance-alert")?salla.logger.warn("salla-maintenance-alert element Existed before!"):salla.lang.onLoaded((()=>document.body.prepend(document.createElement("salla-maintenance-alert")))))}injectTemplateStoreAlert(){salla.config.get("store.template")&&(document.body.classList.add("has-bottom-alert"),document.querySelector("salla-bottom-alert")?salla.logger.warn("salla-bottom-alert element Existed before!"):salla.lang.onLoaded((()=>document.body.append(document.createElement("salla-bottom-alert")))))}injectAppInstallAlert(){salla.config.get("store.app_install_prompt")&&salla.config.get("store.apps")&&!salla.storage.get("app_install_prompt_disabled")&&(document.body.classList.add("has-app-install-alert"),document.querySelector("salla-app-install-alert")?salla.logger.warn("salla-app-install-alert element Existed before!"):salla.lang.onLoaded((()=>document.body.append(document.createElement("salla-app-install-alert")))))}injectThemePreviewAlert(){"preview"===salla.config.get("theme.mode")&&(document.body.classList.add("has-preview-bar"),document.querySelector("#s-theme_preview_bar")?salla.logger.warn("#s-theme_preview_bar element Existed before!"):salla.lang.onLoaded((()=>{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://cdn.salla.network/images/logo/logo-light.svg">\n <span style="margin:0 10px;">${salla.lang.get("blocks.header.preview_mode")}: <span style="background:rgba(255,255,255,0.25);border-radius:15px; padding:2px 15px 4px">${salla.config.get("theme.name")}</span></span>\n </div>\n <a href="${salla.url.get("preview_theme/cancel/preview")}" style="line-height:32px; width:32px;"><i class="sicon-cancel"></i></a>\n `,document.body.prepend(e)})))}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),a=r.method?r.method.toLowerCase():void 0;salla.api.request(r.url,r.formData,a).then((e=>(e.data&&e.request&&(e=e.data),salla.api.handleAfterResponseActions(e),this.callAjaxEvent(r.events.success,e,r.formData),e))).catch((e=>{throw salla.api.handleErrorResponse(e),this.callAjaxEvent(r.events.fail,e,r.formData),e}))}callAjaxEvent(e,t,r){if(e){if(r instanceof FormData){const e={};Array.from(r.entries()).forEach((function(t){e[t[0]]=t[1]})),r=e}window[e]?window[e](t,r):salla.event.dispatch(e,t,r)}}setSallaReady(e){Y.event.dispatch("twilight::before.ready",e),Y.status="ready",Y.event.dispatch("twilight::initiated",e),window.dispatchEvent(new CustomEvent("twilight::initiated",{detail:e}))}storeUTMs(){const e={fbclid:"facebook",gad_source:"google",ttclid:"tiktok",twclid:"twitter",scid:"snapchat"},t=["fbclid","gad_source","ttclid","twclid","scid"],r=["utm_source","utm_medium","utm_campaign","utm_term","utm_content",...t],a={},n={};window.location.search.replace("?","").split("&").map((e=>e.split("="))).filter((([e])=>r.includes(e.toLowerCase()))).forEach((([e,t])=>a[e.toLowerCase()]=t));const i=t.some((e=>a[e]));!a.utm_source&&i&&(a.utm_source=e[i],a.utm_campaign=a.utm_campaign||`Using the CLICKID ${i} provided by ${a.utm_source}`,a.utm_term=a.utm_term||`${i}: ${a[i]}`),a.utm_source&&(Object.entries(a).filter((([e])=>!t.includes(e))).forEach((([e,t])=>n[`s-${e.replace("_","-")}`]=t)),salla.storage.session.set("s-utms",n))}}return Y.status="loading",Y.notify=Q,Y.lang=new class extends _e{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){return new Promise((t=>{if(this.translationsLoaded)return t(e?e():null);Salla.event.once("languages::translations.loaded",(()=>t(e?e():null)))}))}loadStoreTranslations(){if(this.hash=salla.config.get("theme.translations_hash",salla.config.get("store.id","twilight")),this.message||(salla.log("try to load translations from localstorage"),this.messages=salla.storage.get(`s_translations.${this.hash}`),this.messages&&(this.translationsLoaded=!0)&&super.setMessages(this.messages)),this.messages)return salla.event.dispatch("languages::translations.loaded"),void salla.logger.info("The messages of transactions is already loaded");salla.url.get("")?this.loadScript(salla.url.get(`languages/assets/${this.hash}.js`)):this.loadScript("https://cdn.salla.network/js/translations.js",!1)}setMessages(e){super.setMessages(e),salla.event.dispatch("languages::translations.loaded"),this.translationsLoaded=!0}loadScript(e,t=!0){let r=document.createElement("script");r.src=e,r.onload=()=>{if(window.translations)return salla.storage.remove("s_translations"),salla.storage.set("s_translations",{[this.hash]:window.translations}),this.setMessages(window.translations);r.onerror()},r.onerror=()=>{if(t)return salla.logger.warn("Failed to load Translations for store, lets try load it from CDN"),this.loadScript("https://cdn.salla.network/js/translations.js",!1);salla.logger.error("Failed to load Translations, check your network logs for more details\nor: salla.lang.setMessages({....}), see https://docs.salla.dev for more information's.")},document.head.appendChild(r)}getWithDefault(e,t,r,a){let n=this.get(e,r,a);return n!==e?n:t}get(e,t,r){let a=e;(window.translations||this.translationsLoaded)&&(a="trans."+e);let n=super.get(a,t,r);return n!==a?n:super.get(a,t,"en").replace(a,e)}set(e,t){return salla.helpers.setNested(this.messages[`${this.getLocale()}.trans`],e,t),this}add(e,t){return Object.entries(t).forEach((t=>salla.helpers.setNested(this.messages[t[0]+".trans"],e,t[1]))),this}addBulk(e){return Object.entries(e).forEach((([e,t])=>{this.add(e,t)})),this}},Y.form=new class{async submit(e,t=null){let r=t;if("SubmitEvent"===t?.constructor?.name||"submit"===t?.type){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.api.request(e,r,"post").finally((()=>{loaderSupported&&t?.submitter?.parentElement.stop()}));let a=e.split("."),n=a.splice(-1);return await salla.call(a.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)}getPossibleValue(e,t,r=!1){if(!e)return;if("object"!=typeof e)return e;let a;for(let r=0;r<t.length&&!(a=e[t[r]])&&!("undefined"!=typeof FormData&&e instanceof FormData&&(a=e.get(t[r])));r++);return a=a||e,"object"!=typeof a||r?a:void 0}},Y.infiniteScroll=new class extends K{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,"S-Source":"twilight","cache-control":"no-cache",pragma:"no-cache"}},this.instances=[]}initiate(e,t,r,a=!1){a?((r=r||{}).fetchOptions={...this.fetchOptions,...r.fetchOptions||{}},r.responseBody="json"):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 Se(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}loadNextPage(e){("string"!=typeof e?e:document.querySelector(e)).loadNextPage()}destroy(e){("string"!=typeof e?e:document.querySelector(e)).destroy()}}(void 0,salla.event.infiniteScroll),Y.api=new class extends wn{constructor(){super(),this.auth=new xe,this.cart=new Fe,this.loyalty=new Pe,this.order=new Te,this.rating=new Le,this.product=new Re,this.profile=new Ce,this.comment=new Oe,this.currency=new ke,this.document=new Ie,this.wishlist=new qe,this.scope=new De,this.booking=new Ue,this.landing=new Ne,this.notifications=new je,this.component=new bn,this.advertisement=new Sn,this.navigation=new En}},["cart","auth","order","scope","rating","comment","loyalty","product","profile","currency","document","wishlist","booking","landing"].forEach((e=>Y[e]=new K(Y.api[e],Y.event[e]))),Y.call=e=>{let t=Y,r=e.split(".");for(;r.length&&(t=t[r.shift()]););return t},Y.init=e=>new _n(e),salla.event.once("twilight::init",salla.init),salla.event.once("twilight::api",(e=>{let t=e?.events;t&&salla.event.dispatchEvents(t)})),Y.success=Y.notify.success,Y.error=Y.notify.error,Y.versions.twilight="2.15.0-alpha.0",Y.onInitiated=e=>salla.event.once("twilight::initiated",e),Y.onReady=Y.onReady||function(e){return new Promise((function(t){return"ready"===salla.status?t(e?e(salla.config.all()):salla.config.all()):Y.onInitiated((r=>t(e?e(r):r)))}))},window.dispatchEvent(new CustomEvent("salla::created")),Y}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Salla=t()}(this,function(){"use strict";function e(e,t){return t.forEach(function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach(function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}})}),Object.freeze(e)}var t,r,n,i,o,a,s,u,l,c,d,h,p,f,g,m,v,y,D,b,F,w,E,S,_,A,C,k,x,P,I,O,B,j,T,R,L,N,U,q,z,$,M,H,W,G,J,V,K,Q,X,Y,Z,ee,te,re,ne,ie,oe,ae,se,ue,le,ce,de,he,pe,fe,ge,me,ve,ye,De,be,Fe,we,Ee,Se,_e,Ae,Ce,ke,xe,Pe,Ie,Oe,Be,je,Te,Re,Le,Ne,Ue,qe,ze,$e,Me,He,We,Ge,Je,Ve,Ke,Qe,Xe="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Ye(){if(r)return t;r=1;var e=Array.isArray;return t=e}function Ze(){if(a)return o;a=1;var e=function(){if(i)return n;i=1;var e="object"==typeof Xe&&Xe&&Xe.Object===Object&&Xe;return n=e}(),t="object"==typeof self&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return o=r}function et(){if(u)return s;u=1;var e=Ze().Symbol;return s=e}function tt(){if(f)return p;f=1;var e=et(),t=function(){if(c)return l;c=1;var e=et(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,i=e?e.toStringTag:void 0;return l=function(e){var t=r.call(e,i),o=e[i];try{e[i]=void 0;var a=!0}catch(e){}var s=n.call(e);return a&&(t?e[i]=o:delete e[i]),s}}(),r=function(){if(h)return d;h=1;var e=Object.prototype.toString;return d=function(t){return e.call(t)}}(),n=e?e.toStringTag:void 0;return p=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":n&&n in Object(e)?t(e):r(e)}}function rt(){if(y)return v;y=1;var e=tt(),t=m?g:(m=1,g=function(e){return null!=e&&"object"==typeof e});return v=function(r){return"symbol"==typeof r||t(r)&&"[object Symbol]"==e(r)}}function nt(){if(w)return F;return w=1,F=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}}function it(){if(k)return C;k=1;var e,t=function(){if(A)return _;A=1;var e=Ze()["__core-js_shared__"];return _=e}(),r=(e=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||""))?"Symbol(src)_1."+e:"";return C=function(e){return!!r&&r in e}}function ot(){if(O)return I;O=1;var e=function(){if(S)return E;S=1;var e=tt(),t=nt();return E=function(r){if(!t(r))return!1;var n=e(r);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}(),t=it(),r=nt(),n=function(){if(P)return x;P=1;var e=Function.prototype.toString;return x=function(t){if(null!=t){try{return e.call(t)}catch(e){}try{return t+""}catch(e){}}return""}}(),i=/^\[object .+?Constructor\]$/,o=Function.prototype,a=Object.prototype,s=o.toString,u=a.hasOwnProperty,l=RegExp("^"+s.call(u).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return I=function(o){return!(!r(o)||t(o))&&(e(o)?l:i).test(n(o))}}function at(){if(R)return T;R=1;var e=ot(),t=j?B:(j=1,B=function(e,t){return null==e?void 0:e[t]});return T=function(r,n){var i=t(r,n);return e(i)?i:void 0}}function st(){if(N)return L;N=1;var e=at()(Object,"create");return L=e}function ut(){if(Q)return K;Q=1;var e=function(){if(q)return U;q=1;var e=st();return U=function(){this.__data__=e?e(null):{},this.size=0}}(),t=$?z:($=1,z=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}),r=function(){if(H)return M;H=1;var e=st(),t=Object.prototype.hasOwnProperty;return M=function(r){var n=this.__data__;if(e){var i=n[r];return"__lodash_hash_undefined__"===i?void 0:i}return t.call(n,r)?n[r]:void 0}}(),n=function(){if(G)return W;G=1;var e=st(),t=Object.prototype.hasOwnProperty;return W=function(r){var n=this.__data__;return e?void 0!==n[r]:t.call(n,r)}}(),i=function(){if(V)return J;V=1;var e=st();return J=function(t,r){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=e&&void 0===r?"__lodash_hash_undefined__":r,this}}();function o(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])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,K=o}function lt(){if(re)return te;re=1;var e=ee?Z:(ee=1,Z=function(e,t){return e===t||e!=e&&t!=t});return te=function(t,r){for(var n=t.length;n--;)if(e(t[n][0],r))return n;return-1}}function ct(){if(he)return de;he=1;var e=Y?X:(Y=1,X=function(){this.__data__=[],this.size=0}),t=function(){if(ie)return ne;ie=1;var e=lt(),t=Array.prototype.splice;return ne=function(r){var n=this.__data__,i=e(n,r);return!(i<0||(i==n.length-1?n.pop():t.call(n,i,1),--this.size,0))}}(),r=function(){if(ae)return oe;ae=1;var e=lt();return oe=function(t){var r=this.__data__,n=e(r,t);return n<0?void 0:r[n][1]}}(),n=function(){if(ue)return se;ue=1;var e=lt();return se=function(t){return e(this.__data__,t)>-1}}(),i=function(){if(ce)return le;ce=1;var e=lt();return le=function(t,r){var n=this.__data__,i=e(n,t);return i<0?(++this.size,n.push([t,r])):n[i][1]=r,this}}();function o(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])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,de=o}function dt(){if(me)return ge;me=1;var e=ut(),t=ct(),r=function(){if(fe)return pe;fe=1;var e=at()(Ze(),"Map");return pe=e}();return ge=function(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}}function ht(){if(be)return De;be=1;var e=ye?ve:(ye=1,ve=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e});return De=function(t,r){var n=t.__data__;return e(r)?n["string"==typeof r?"string":"hash"]:n.map}}function pt(){if(Pe)return xe;Pe=1;var e=dt(),t=function(){if(we)return Fe;we=1;var e=ht();return Fe=function(t){var r=e(this,t).delete(t);return this.size-=r?1:0,r}}(),r=function(){if(Se)return Ee;Se=1;var e=ht();return Ee=function(t){return e(this,t).get(t)}}(),n=function(){if(Ae)return _e;Ae=1;var e=ht();return _e=function(t){return e(this,t).has(t)}}(),i=function(){if(ke)return Ce;ke=1;var e=ht();return Ce=function(t,r){var n=e(this,t),i=n.size;return n.set(t,r),this.size+=n.size==i?0:1,this}}();function o(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])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,xe=o}function ft(){if(je)return Be;je=1;var e=function(){if(Oe)return Ie;Oe=1;var e=pt();function t(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var i=function e(){var t=arguments,i=n?n.apply(this,t):t[0],o=e.cache;if(o.has(i))return o.get(i);var a=r.apply(this,t);return e.cache=o.set(i,a)||o,a};return i.cache=new(t.Cache||e),i}return t.Cache=e,Ie=t}();return Be=function(t){var r=e(t,function(e){return 500===n.size&&n.clear(),e}),n=r.cache;return r}}function gt(){if(qe)return Ue;qe=1;var e=et(),t=Ne?Le:(Ne=1,Le=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}),r=Ye(),n=rt(),i=e?e.prototype:void 0,o=i?i.toString:void 0;return Ue=function e(i){if("string"==typeof i)return i;if(r(i))return t(i,e)+"";if(n(i))return o?o.call(i):"";var a=i+"";return"0"==a&&1/i==-1/0?"-0":a},Ue}function mt(){if(He)return Me;He=1;var e=Ye(),t=function(){if(b)return D;b=1;var e=Ye(),t=rt(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return D=function(i,o){if(e(i))return!1;var a=typeof i;return!("number"!=a&&"symbol"!=a&&"boolean"!=a&&null!=i&&!t(i))||n.test(i)||!r.test(i)||null!=o&&i in Object(o)}}(),r=function(){if(Re)return Te;Re=1;var e=ft(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e(function(e){var n=[];return 46===e.charCodeAt(0)&&n.push(""),e.replace(t,function(e,t,i,o){n.push(i?o.replace(r,"$1"):t||e)}),n});return Te=n}(),n=function(){if($e)return ze;$e=1;var e=gt();return ze=function(t){return null==t?"":e(t)}}();return Me=function(i,o){return e(i)?i:t(i,o)?[i]:r(n(i))}}function vt(){if(Ve)return Je;Ve=1;var e=mt(),t=function(){if(Ge)return We;Ge=1;var e=rt();return We=function(t){if("string"==typeof t||e(t))return t;var r=t+"";return"0"==r&&1/t==-1/0?"-0":r}}();return Je=function(r,n){for(var i=0,o=(n=e(n,r)).length;null!=r&&i<o;)r=r[t(n[i++])];return i&&i==o?r:void 0}}var yt,Dt=function(){if(Qe)return Ke;Qe=1;var e=vt();return Ke=function(t,r,n){var i=null==t?void 0:e(t,r);return void 0===i?n:i}}(),bt=Object.freeze({__proto__:null,default:Dt}),Ft={exports:{}};var wt,Et,St,_t,At=(yt||(yt=1,function(e){!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,o="function"==typeof Symbol,a="object"==typeof Reflect,s="function"==typeof setImmediate?setImmediate:setTimeout,u=o?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 l(){this._events={},this._conf&&c.call(this,this._conf)}function c(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 d(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 h=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 p(e,r){for(var n={},i=e.length,o=0;o<i;o++)n[e[o]]=o<0?r[o]:t;return n}function f(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 o=e._observers;o?o.push(this):e._observers=[this]}function g(e,n,i,o){var a=Object.assign({},n);if(!e)return a;if("object"!=typeof e)throw TypeError("options must be an object");var s,u,l,c=Object.keys(e),d=c.length;function h(e){throw Error('Invalid "'+s+'" option value'+(e?". Reason: "+e:""))}for(var p=0;p<d;p++){if(s=c[p],!r.call(n,s))throw Error('Unknown "'+s+'" option');(u=e[s])!==t&&(l=i[s],a[s]=l?l(u,h):u)}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 o=typeof e;if(o===n||o===i)return e;r(t)}:function(n,i){for(var o=typeof n,a=r;a-- >0;)if(o===e[a])return n;i(t)}}Object.assign(f.prototype,{subscribe:function(e,t,r){var n=this,i=this._target,o=this._emitter,a=this._listeners,s=function(){var n=h.apply(null,arguments),a={data:n,name:t,original:e};r?!1!==r.call(i,a)&&o.emit.apply(o,[a.name].concat(n)):o.emit.apply(o,[t].concat(n))};if(a[e])throw Error("Event '"+e+"' is already listening");this._listenersCount++,o._newListener&&o._removeListener&&!n._onNewListener?(this._onNewListener=function(r){r===t&&null===a[e]&&(a[e]=s,n._on.call(i,e,s))},o.on("newListener",this._onNewListener),this._onRemoveListener=function(r){r===t&&!o.hasListeners(r)&&a[e]&&(a[e]=null,n._off.call(i,e,s))},a[e]=null,o.on("removeListener",this._onRemoveListener)):(a[e]=s,n._on.call(i,e,s))},unsubscribe:function(e){var t,r,n,i=this,o=this._listeners,a=this._emitter,s=this._off,l=this._target;if(e&&"string"!=typeof e)throw TypeError("event must be a string");function c(){i._onNewListener&&(a.off("newListener",i._onNewListener),a.off("removeListener",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var e=F.call(a,i);a._observers.splice(e,1)}if(e){if(!(t=o[e]))return;s.call(l,e,t),delete o[e],--this._listenersCount||c()}else{for(n=(r=u(o)).length;n-- >0;)e=r[n],s.call(l,e,o[e]);this._listeners={},this._listenersCount=0,c()}}});var y=v(["function"]),D=v(["object","function"]);function b(e,t,r){var n,i,o,a=0,s=new e(function(u,l,c){function d(){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 c;var h=function(e){d(),u(e)},p=function(e){d(),l(e)};n?t(h,p,c):(i=[function(e){p(e||Error("canceled"))}],t(h,p,function(e){if(o)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof e)throw TypeError("onCancel callback must be a function");i.push(e)}),o=!0),r.timeout>0&&(a=setTimeout(function(){var e=Error("timeout");e.code="ETIMEDOUT",a=0,s.cancel(e),l(e)},r.timeout))});return n||(s.cancel=function(e){if(i){for(var t=i.length,r=1;r<t;r++)i[r](e);i[0](e),i=null}}),s}function F(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 w(e,t,r,n,i){if(!r)return null;if(0===n){var o=typeof t;if("string"===o){var a,s,l=0,c=0,d=this.delimiter,h=d.length;if(-1!==(s=t.indexOf(d))){a=new Array(5);do{a[l++]=t.slice(c,s),c=s+h}while(-1!==(s=t.indexOf(d,c)));a[l++]=t.slice(c),t=a,i=l}else t=[t],i=1}else"object"===o?i=t.length:(t=[t],i=1)}var p,f,g,m,v,y,D,b=null,F=t[n],E=t[n+1];if(n===i)r._listeners&&("function"==typeof r._listeners?(e&&e.push(r._listeners),b=[r]):(e&&e.push.apply(e,r._listeners),b=[r]));else{if("*"===F){for(s=(y=u(r)).length;s-- >0;)"_listeners"!==(p=y[s])&&(D=w(e,t,r[p],n+1,i))&&(b?b.push.apply(b,D):b=D);return b}if("**"===F){for((v=n+1===i||n+2===i&&"*"===E)&&r._listeners&&(b=w(e,t,r,i,i)),s=(y=u(r)).length;s-- >0;)"_listeners"!==(p=y[s])&&("*"===p||"**"===p?(r[p]._listeners&&!v&&(D=w(e,t,r[p],i,i))&&(b?b.push.apply(b,D):b=D),D=w(e,t,r[p],n,i)):D=w(e,t,r[p],p===E?n+2:n,i),D&&(b?b.push.apply(b,D):b=D));return b}r[F]&&(b=w(e,t,r[F],n+1,i))}if((f=r["*"])&&w(e,t,f,n+1,i),g=r["**"])if(n<i)for(g._listeners&&w(e,t,g,i,i),s=(y=u(g)).length;s-- >0;)"_listeners"!==(p=y[s])&&(p===E?w(e,t,g[p],n+2,i):p===F?w(e,t,g[p],n+1,i):((m={})[p]=g[p],w(e,t,{"**":m},n+1,i)));else g._listeners?w(e,t,g,i,i):g["*"]&&g["*"]._listeners&&w(e,t,g["*"],i,i);return b}function E(e,t,r){var n,i,o=0,a=0,s=this.delimiter,u=s.length;if("string"==typeof e)if(-1!==(n=e.indexOf(s))){i=new Array(5);do{i[o++]=e.slice(a,n),a=n+u}while(-1!==(n=e.indexOf(s,a)));i[o++]=e.slice(a)}else i=[e],o=1;else i=e,o=e.length;if(o>1)for(n=0;n+1<o;n++)if("**"===i[n]&&"**"===i[n+1])return;var l,c=this.listenerTree;for(n=0;n<o;n++)if(c=c[l=i[n]]||(c[l]={}),n===o-1)return c._listeners?("function"==typeof c._listeners&&(c._listeners=[c._listeners]),r?c._listeners.unshift(t):c._listeners.push(t),!c._listeners.warned&&this._maxListeners>0&&c._listeners.length>this._maxListeners&&(c._listeners.warned=!0,d.call(this,c._listeners.length,l))):c._listeners=t,!0;return!0}function S(e,t,r,n){for(var i,o,a,s,l=u(e),c=l.length,d=e._listeners;c-- >0;)i=e[o=l[c]],a="_listeners"===o?r:r?r.concat(o):[o],s=n||"symbol"==typeof o,d&&t.push(s?a:a.join(this.delimiter)),"object"==typeof i&&S.call(this,i,t,a,s);return t}function _(e){for(var t,r,n,i=u(e),o=i.length;o-- >0;)(t=e[r=i[o]])&&(n=!0,"_listeners"===r||_(t)||delete e[r]);return n}function A(e,t,r){this.emitter=e,this.event=t,this.listener=r}function C(e,r,n){if(!0===n)a=!0;else if(!1===n)o=!0;else{if(!n||"object"!=typeof n)throw TypeError("options should be an object or true");var o=n.async,a=n.promisify,u=n.nextTick,l=n.objectify}if(o||u||a){var c=r,d=r._origin||r;if(u&&!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?u?Promise.resolve():new Promise(function(e){s(e)}).then(function(){return t.event=r,c.apply(t,e)}):(u?process.nextTick:s)(function(){t.event=r,c.apply(t,e)})},r._async=!0,r._origin=d}return[r,l?new A(this,e,r):this]}function k(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,c.call(this,e)}A.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},k.EventEmitter2=k,k.prototype.listenTo=function(e,r,i){if("object"!=typeof e)throw TypeError("target musts be an object");var o=this;function a(t){if("object"!=typeof t)throw TypeError("events must be an object");var r,n=i.reducers,a=F.call(o,e);r=-1===a?new f(o,e,i):o._observers[a];for(var s,l=u(t),c=l.length,d="function"==typeof n,h=0;h<c;h++)s=l[h],r.subscribe(s,t[s]||s,d?n:n&&n[s])}return i=g(i,{on:t,off:t,reducers:t},{on:y,off:y,reducers:D}),n(r)?a(p(r)):a("string"==typeof r?p(r.split(/\s+/)):r),this},k.prototype.stopListeningTo=function(e,t){var r=this._observers;if(!r)return!1;var n,i=r.length,o=!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),o=!0);return o},k.prototype.delimiter=".",k.prototype.setMaxListeners=function(e){e!==t&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},k.prototype.getMaxListeners=function(){return this._maxListeners},k.prototype.event="",k.prototype.once=function(e,t,r){return this._once(e,t,!1,r)},k.prototype.prependOnceListener=function(e,t,r){return this._once(e,t,!0,r)},k.prototype._once=function(e,t,r,n){return this._many(e,1,t,r,n)},k.prototype.many=function(e,t,r,n){return this._many(e,t,r,!1,n)},k.prototype.prependMany=function(e,t,r,n){return this._many(e,t,r,!0,n)},k.prototype._many=function(e,t,r,n,i){var o=this;if("function"!=typeof r)throw new Error("many only accepts instances of Function");function a(){return 0===--t&&o.off(e,a),r.apply(this,arguments)}return a._origin=r,this._on(e,a,n,i)},k.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||l.call(this);var e,t,r,n,i,a,s=arguments[0],u=this.wildcard;if("newListener"===s&&!this._newListener&&!this._events.newListener)return!1;if(u&&(e=s,"newListener"!==s&&"removeListener"!==s&&"object"==typeof s)){if(r=s.length,o)for(n=0;n<r;n++)if("symbol"==typeof s[n]){a=!0;break}a||(s=s.join(this.delimiter))}var c,d=arguments.length;if(this._all&&this._all.length)for(n=0,r=(c=this._all.slice()).length;n<r;n++)switch(this.event=s,d){case 1:c[n].call(this,s);break;case 2:c[n].call(this,s,arguments[1]);break;case 3:c[n].call(this,s,arguments[1],arguments[2]);break;default:c[n].apply(this,arguments)}if(u)c=[],w.call(this,c,e,this.listenerTree,0,r);else{if("function"==typeof(c=this._events[s])){switch(this.event=s,d){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(t=new Array(d-1),i=1;i<d;i++)t[i-1]=arguments[i];c.apply(this,t)}return!0}c&&(c=c.slice())}if(c&&c.length){if(d>3)for(t=new Array(d-1),i=1;i<d;i++)t[i-1]=arguments[i];for(n=0,r=c.length;n<r;n++)switch(this.event=s,d){case 1:c[n].call(this);break;case 2:c[n].call(this,arguments[1]);break;case 3:c[n].call(this,arguments[1],arguments[2]);break;default:c[n].apply(this,t)}return!0}if(!this.ignoreErrors&&!this._all&&"error"===s)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},k.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||l.call(this);var e,t,r,n,i,a,s=arguments[0],u=this.wildcard;if("newListener"===s&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(u&&(e=s,"newListener"!==s&&"removeListener"!==s&&"object"==typeof s)){if(n=s.length,o)for(i=0;i<n;i++)if("symbol"==typeof s[i]){t=!0;break}t||(s=s.join(this.delimiter))}var c,d=[],h=arguments.length;if(this._all)for(i=0,n=this._all.length;i<n;i++)switch(this.event=s,h){case 1:d.push(this._all[i].call(this,s));break;case 2:d.push(this._all[i].call(this,s,arguments[1]));break;case 3:d.push(this._all[i].call(this,s,arguments[1],arguments[2]));break;default:d.push(this._all[i].apply(this,arguments))}if(u?(c=[],w.call(this,c,e,this.listenerTree,0)):c=this._events[s],"function"==typeof c)switch(this.event=s,h){case 1:d.push(c.call(this));break;case 2:d.push(c.call(this,arguments[1]));break;case 3:d.push(c.call(this,arguments[1],arguments[2]));break;default:for(r=new Array(h-1),a=1;a<h;a++)r[a-1]=arguments[a];d.push(c.apply(this,r))}else if(c&&c.length){if(c=c.slice(),h>3)for(r=new Array(h-1),a=1;a<h;a++)r[a-1]=arguments[a];for(i=0,n=c.length;i<n;i++)switch(this.event=s,h){case 1:d.push(c[i].call(this));break;case 2:d.push(c[i].call(this,arguments[1]));break;case 3:d.push(c[i].call(this,arguments[1],arguments[2]));break;default:d.push(c[i].apply(this,r))}}else if(!this.ignoreErrors&&!this._all&&"error"===s)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(d)},k.prototype.on=function(e,t,r){return this._on(e,t,!1,r)},k.prototype.prependListener=function(e,t,r){return this._on(e,t,!0,r)},k.prototype.onAny=function(e){return this._onAny(e,!1)},k.prototype.prependAny=function(e){return this._onAny(e,!0)},k.prototype.addListener=k.prototype.on,k.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},k.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||l.call(this);var o,a=this;return i!==t&&(r=(o=C.call(this,e,r,i))[0],a=o[1]),this._newListener&&this.emit("newListener",e,r),this.wildcard?(E.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,d.call(this,this._events[e].length,e))):this._events[e]=r,a)},k.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 o="string"==typeof e?e.split(this.delimiter):e.slice();if(!(i=w.call(this,null,o,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 s=i[a];if(r=s._listeners,n(r)){for(var u=-1,l=0,c=r.length;l<c;l++)if(r[l]===t||r[l].listener&&r[l].listener===t||r[l]._origin&&r[l]._origin===t){u=l;break}if(u<0)continue;return this.wildcard?s._listeners.splice(u,1):this._events[e].splice(u,1),0===r.length&&(this.wildcard?delete s._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 s._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return this.listenerTree&&_(this.listenerTree),this},k.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},k.prototype.removeListener=k.prototype.off,k.prototype.removeAllListeners=function(e){if(e===t)return!this._events||l.call(this),this;if(this.wildcard){var r,n=w.call(this,null,e,this.listenerTree,0);if(!n)return this;for(r=0;r<n.length;r++)n[r]._listeners=null;this.listenerTree&&_(this.listenerTree)}else this._events&&(this._events[e]=null);return this},k.prototype.listeners=function(e){var r,n,i,o,a,s=this._events;if(e===t){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!s)return[];for(o=(r=u(s)).length,i=[];o-- >0;)"function"==typeof(n=s[r[o]])?i.push(n):i.push.apply(i,n);return i}if(this.wildcard){if(!(a=this.listenerTree))return[];var l=[],c="string"==typeof e?e.split(this.delimiter):e.slice();return w.call(this,l,c,a,0),l}return s&&(n=s[e])?"function"==typeof n?[n]:n:[]},k.prototype.eventNames=function(e){var t=this._events;return this.wildcard?S.call(this,this.listenerTree,[],null,e):t?u(t):[]},k.prototype.listenerCount=function(e){return this.listeners(e).length},k.prototype.hasListeners=function(e){if(this.wildcard){var r=[],n="string"==typeof e?e.split(this.delimiter):e.slice();return w.call(this,r,n,this.listenerTree,0),r.length>0}var i=this._events,o=this._all;return!!(o&&o.length||i&&(e===t?u(i).length:i[e]))},k.prototype.listenersAny=function(){return this._all?this._all:[]},k.prototype.waitFor=function(e,r){var n=this,i=typeof r;return"number"===i?r={timeout:r}:"function"===i&&(r={filter:r}),b((r=g(r,{timeout:0,filter:t,handleError:!1,Promise:Promise,overload:!1},{filter:y,Promise:m})).Promise,function(t,i,o){function a(){var o=r.filter;if(!o||o.apply(n,arguments))if(n.off(e,a),r.handleError){var s=arguments[0];s?i(s):t(h.apply(null,arguments).slice(1))}else t(h.apply(null,arguments))}o(function(){n.off(e,a)}),n._on(e,a,!1)},{timeout:r.timeout,overload:r.overload})};var x=k.prototype;Object.defineProperties(k,{defaultMaxListeners:{get:function(){return x._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");x._maxListeners=e},enumerable:!0},once:{value:function(e,t,r){return b((r=g(r,{Promise:Promise,timeout:0,overload:!1},{Promise:m})).Promise,function(r,n,i){var o;if("function"==typeof e.addEventListener)return o=function(){r(h.apply(null,arguments))},i(function(){e.removeEventListener(t,o)}),void e.addEventListener(t,o,{once:!0});var a,s=function(){a&&e.removeListener("error",a),r(h.apply(null,arguments))};"error"!==t&&(a=function(r){e.removeListener(t,s),n(r)},e.once("error",a)),i(function(){a&&e.removeListener("error",a),e.removeListener(t,s)}),e.once(t,s)},{timeout:r.timeout,overload:r.overload})},writable:!0,configurable:!0}}),Object.defineProperties(x,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),e.exports=k}()}(Ft)),Ft.exports);function Ct(){if(Et)return wt;Et=1;var e=Object.assign?Object.assign:function(e,t,r,n){for(var i=1;i<arguments.length;i++)o(Object(arguments[i]),function(t,r){e[r]=t});return e},t=function(){if(Object.create)return function(t,r,n,o){var a=i(arguments,1);return e.apply(this,[Object.create(t)].concat(a))};{function t(){}return function(r,n,o,a){var s=i(arguments,1);return t.prototype=r,e.apply(this,[new t].concat(s))}}}(),r=String.prototype.trim?function(e){return String.prototype.trim.call(e)}:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},n="undefined"!=typeof window?window:Xe;function i(e,t){return Array.prototype.slice.call(e,t||0)}function o(e,t){a(e,function(e,r){return t(e,r),!1})}function a(e,t){if(s(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 s(e){return null!=e&&"function"!=typeof e&&"number"==typeof e.length}return wt={assign:e,create:t,trim:r,bind:function(e,t){return function(){return t.apply(e,Array.prototype.slice.call(arguments,0))}},slice:i,each:o,map:function(e,t){var r=s(e)?[]:{};return a(e,function(e,n){return r[n]=t(e,n),!1}),r},pluck:a,isList:s,isFunction:function(e){return e&&"[object Function]"==={}.toString.call(e)},isObject:function(e){return e&&"[object Object]"==={}.toString.call(e)},Global:n},wt}var kt,xt,Pt=function(){if(_t)return St;_t=1;var e=Ct(),t=e.slice,r=e.pluck,n=e.each,i=e.bind,o=e.create,a=e.isList,s=e.isFunction,u=e.isObject,l={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 c.apply(this,arguments)},addPlugin:function(e){this._addPlugin(e)},namespace:function(e){return c(this.storage,this.plugins,e)}};function c(e,c,d){d||(d=""),e&&!a(e)&&(e=[e]),c&&!a(c)&&(c=[c]);var h=d?"__storejs_"+d+"_":"",p=d?new RegExp("^"+h):null;if(!/^[a-zA-Z0-9_\-]*$/.test(d))throw new Error("store.js namespaces can only have alphanumerics + underscores and dashes");var f={_namespacePrefix:h,_namespaceRegexp:p,_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,r){var i=this[r];this[r]=function(){var r=t(arguments,0),o=this;var a=[function(){if(i)return n(arguments,function(e,t){r[t]=e}),i.apply(o,r)}].concat(r);return e.apply(o,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(a(e))n(e,function(e){t._addPlugin(e)});else if(!r(this.plugins,function(t){return e===t})){if(this.plugins.push(e),!s(e))throw new Error("Plugins must be function values that return objects");var i=e.call(this);if(!u(i))throw new Error("Plugins must return an object of function properties");n(i,function(r,n){if(!s(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;e&&(e.warn?e.warn:e.log).apply(e,arguments)}("store.addStorage(storage) is deprecated. Use createStore([storages])"),this._addStorage(e)}},g=o(f,l,{plugins:[]});return g.raw={},n(g,function(e,t){s(e)&&(g.raw[t]=i(g,e))}),n(e,function(e){g._addStorage(e)}),n(c,function(e){g._addPlugin(e)}),g}return St={createStore:c}}();var It,Ot,Bt=function(){if(xt)return kt;xt=1;var e=Ct().Global;function t(){return e.localStorage}function r(e){return t().getItem(e)}return kt={name:"localStorage",read:r,write:function(e,r){return t().setItem(e,r)},each:function(e){for(var n=t().length-1;n>=0;n--){var i=t().key(n);e(r(i),i)}},remove:function(e){return t().removeItem(e)},clearAll:function(){return t().clear()}},kt}(),jt=e({__proto__:null,default:Bt},[Bt]);var Tt,Rt,Lt=function(){if(Ot)return It;Ot=1;var e=Ct().Global;function t(){return e.sessionStorage}function r(e){return t().getItem(e)}return It={name:"sessionStorage",read:r,write:function(e,r){return t().setItem(e,r)},each:function(e){for(var n=t().length-1;n>=0;n--){var i=t().key(n);e(r(i),i)}},remove:function(e){return t().removeItem(e)},clearAll:function(){return t().clear()}},It}(),Nt=e({__proto__:null,default:Lt},[Lt]);var Ut,qt,zt=function(){if(Rt)return Tt;Rt=1;var e=Ct(),t=e.Global,r=e.trim;Tt={name:"cookieStorage",read:function(e){if(!e||!a(e))return null;var t="(?:^|.*;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(n.cookie.replace(new RegExp(t),"$1"))},write:function(e,t){if(!e)return;n.cookie=escape(e)+"="+escape(t)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:i,remove:o,clearAll:function(){i(function(e,t){o(t)})}};var n=t.document;function i(e){for(var t=n.cookie.split(/; ?/g),i=t.length-1;i>=0;i--)if(r(t[i])){var o=t[i].split("="),a=unescape(o[0]);e(unescape(o[1]),a)}}function o(e){e&&a(e)&&(n.cookie=escape(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function a(e){return new RegExp("(?:^|;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(n.cookie)}return Tt}(),$t=e({__proto__:null,default:zt},[zt]);var Mt=function(){if(qt)return Ut;qt=1,Ut={name:"memoryStorage",read:function(t){return e[t]},write:function(t,r){e[t]=r},each:function(t){for(var r in e)e.hasOwnProperty(r)&&t(e[r],r)},remove:function(t){delete e[t]},clearAll:function(t){e={}}};var e={};return Ut}(),Ht=e({__proto__:null,default:Mt},[Mt]);function Wt(e,t){void 0===t&&(t=!1),e+="";for(var r,n=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],i=["0","1","2","3","4","5","6","7","8","9"],o=(t=t||!Salla.config.get("store.settings.arabic_numbers_enabled"))?n:i,a=t?i:n,s=0;s<o.length;s++)r=new RegExp(o[s],"g"),e=e.replace(r,a[s]);return e.replace(t?"٫":".",t?".":"٫")}function Gt(e){var t=("".concat(e).match(/\./g)||[]).length;return t&&1!==t?Gt(e.replace(/\.(.+)\./g,".$1")):e}function Jt(e){return"".concat(e).startsWith("https://")||"".concat(e).startsWith("http://")}function Vt(e){if(Jt(e))return e;var t=Salla.config.get("store.url");return t||(t=window.location.href.split("/").slice(0,-1).join("/"),Salla.config.set("store.url",t)),t.rtrim("/")+"/"+(null==e?void 0:e.ltrim("/"))}function Kt(e,t,r){if(r=r||window.location.href,!t||!e)return r;var n=new RegExp("([?&])"+e+"=[^&]+[&]?","g");return(r=r.replace(n,"$1").split("#")[0].replace(/&$|\?$/,"")).includes("?")?r+="&":r+=(r.endsWith("/")?"":"/")+"?",(r+e+"="+encodeURIComponent(t)).replace(/&$|\?$/,"")}function Qt(e){return window.location.origin+"/"+(null==e?void 0:e.ltrim("/"))}function Xt(e){return Jt(e)?e:Salla.config.get("theme.assets")?Salla.config.get("theme.assets").replace(":path",null==e?void 0:e.ltrim("/")):Qt("themes/"+Salla.config.get("theme.name")+"/"+(null==e?void 0:e.ltrim("/")))}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.toString():"#"+this.toString()},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)};var Yt=Object.freeze({__proto__:null,addParamToUrl:Kt,api:function(e){var t;return(null===(t=Salla.config.get("store.api",Vt("")))||void 0===t?void 0:t.rtrim("/"))+"/"+(null==e?void 0:e.ltrim("/"))},asset:Xt,base:function(e){return Jt(e)?e:"https://"+new URL(Vt("/")).hostname+"/"+(null==e?void 0:e.ltrim("/"))},baseUrl:Qt,cdn:function(e,t,r){var n="https://cdn.salla.network/";return(t||r)&&(t=t?",width=".concat(t):"",r=r?",height=".concat(r):"",n+="cdn-cgi/image/fit=scale-down".concat(t).concat(r,",onerror=redirect,format=auto/")),n+(null==e?void 0:e.ltrim("/"))},create:function(e,t){return"custom"===e?t:Vt("offers"===e?e:"redirect/".concat(e,"/").concat(t))},domain:function(e){return Jt(e)?e:"".concat(Salla.config.get("store.url",window.location.href.split("/").slice(0,-1).join("/")).rtrim("/"),"/").concat(null==e?void 0:e.ltrim("/"))},get:Vt,is_full_url:Jt,is_page:function(e){return e&&Salla.config.get("page.slug")===e},is_placeholder:function(e){return Xt(salla.config.get("theme.settings.placeholder"))===Xt(e)}}),Zt=function(e,t){return Zt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},Zt(e,t)},er=function(){return er=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},er.apply(this,arguments)};function tr(e,t,r){if(2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}function rr(e){return e instanceof FormData}function nr(e){return e instanceof File}function ir(e){return e instanceof Blob}"function"==typeof SuppressedError&&SuppressedError;var or=function(){function e(e){this.data=e,this.proxy=this.createProxy()}return e.prototype.createProxy=function(){var e=this;return new Proxy(this,{get:function(t,r){return r in t?t[r]:"string"==typeof r?e.get(r):void 0},set:function(t,r,n){return"string"==typeof r&&(e.set(r,n),!0)},has:function(t,r){return"string"==typeof r?e.has(r):r in t},deleteProperty:function(t,r){return"string"==typeof r&&e.delete(r)}})},e.prototype.get=function(e){return rr(this.data)?this.data.get(e):this.data[e]},e.prototype.getAll=function(e){if(rr(this.data))return this.data.getAll(e);var t=this.data[e];return void 0===t?[]:[t]},e.prototype.set=function(e,t){var r=this;rr(this.data)?(this.data.delete(e),null!=t&&(Array.isArray(t)?t.forEach(function(t){nr(t)||ir(t)?r.data.append(e,t):r.data.append(e,String(t))}):nr(t)||ir(t)?this.data.append(e,t):this.data.append(e,String(t)))):this.data[e]=t},e.prototype.append=function(e,t){if(rr(this.data))nr(t)||ir(t)?this.data.append(e,t):null!=t&&this.data.append(e,String(t));else{var r=this.data[e];void 0===r?this.data[e]=t:Array.isArray(r)?r.push(t):this.data[e]=[r,t]}},e.prototype.setFile=function(e,t){this.set(e,t)},e.prototype.getFile=function(e){var t=this.get(e);return nr(t)?t:null},e.prototype.getFiles=function(e){return this.getAll(e).filter(nr)},e.prototype.has=function(e){return rr(this.data)?this.data.has(e):e in this.data},e.prototype.delete=function(e){return rr(this.data)?(this.data.delete(e),!0):delete this.data[e]},e.prototype.keys=function(){if(!rr(this.data))return Object.keys(this.data);for(var e=new Set,t=0,r=this.data.entries();t<r.length;t++){var n=r[t][0];e.add(n)}return Array.from(e)},e.prototype.values=function(){if(!rr(this.data))return Object.values(this.data);for(var e=[],t=0,r=this.data.entries();t<r.length;t++){var n=r[t][1];e.push(n)}return e},e.prototype.entries=function(){return rr(this.data)?Array.from(this.data.entries()):Object.entries(this.data)},e.prototype.toObject=function(){if(!rr(this.data))return er({},this.data);for(var e={},t=0,r=this.data.entries();t<r.length;t++){var n=r[t],i=n[0],o=n[1];void 0!==e[i]?(Array.isArray(e[i])||(e[i]=[e[i]]),e[i].push(o)):e[i]=o}return e},e.prototype.getFileInfo=function(e){var t=this.getFiles(e);return 0===t.length?null:t.map(function(e){return{name:e.name,size:e.size,type:e.type}})},e.prototype.isFile=function(e){var t=this.get(e);return nr(t)||ir(t)},e.prototype.getRawData=function(){return this.data},e.prototype.getProxy=function(){return this.proxy},e}();function ar(e,t,r){var n,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]=ar(e.slice(1),t,r[i]),r):i?((n={})[i]=ar(e.slice(1),t),n):""===i?[t]:t}function sr(){return window.self!==window.top}var ur,lr,cr,dr,hr={digitsOnly:function(e){return Wt(e,!0).replace(/[^0-9.]/g,"").replace("..",".").rtrim(".")},inputDigitsOnly:function e(t,r){if(void 0===r&&(r=!1),"string"==typeof t)return document.querySelectorAll(t).forEach(function(t){return e(t,r)});if(t){var n=Salla.helpers.digitsOnly(t.value);return t.min&&n<parseInt(t.min)?t.value=t.min:t.max&&n>parseInt(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")?Gt(n):n.replace(/\D/g,"")}Salla.logger.warn("Can't find Object With Id: "+t)},number:Wt,money:function(e,t){void 0===t&&(t=!0);var r=Salla.config.currency(null==e?void 0:e.currency).symbol;return e=Wt(e="object"==typeof e?e.amount:e)+" "+r,t&&["SAR","ر.س"].includes(r)&&Salla.config.get("store.settings.use_sar_symbol")&&(e=e.replace(r,"<i class=sicon-sar></i>")),e},isIframe:sr,isPreview:function(){return sr()},setNested:function(e,t,r){for(var n=e,i=t.split("."),o=i.length,a=0;a<o-1;a++){var s=i[a];n[s]||(n[s]={}),n=n[s]}return n[i[o-1]]=r,e},getNested:function(e,t,r){var n=(Dt||bt)(e,t);return void 0!==n?n:r},inputData:function(e,t,r){if(void 0===r&&(r={}),e.includes("[")){var n=e.split("]").join("").split("["),i=n[0],o=r&&"object"==typeof r?r[i]:void 0;return{name:i,value:ar(n.slice(1),t,o)}}return{name:e,value:t}},url:Yt,addParamToUrl:Kt,debounce:function(e,t){t=t||100;var r,n=[];return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];return clearTimeout(r),r=setTimeout(function(){var t=e.apply(void 0,i);n.forEach(function(e){return e(t)}),n=[]},t),new Promise(function(e){return n.push(e)})}},hasApplePay:function(){var e;try{return!!(null===(e=window.ApplePaySession)||void 0===e?void 0:e.canMakePayments())}catch(e){return console.error(e),!1}},createFormDataWrapper:function(e){return new or(e).getProxy()},isAppleDevice:function(){try{var e=navigator.userAgent||"",t=navigator.platform||"",r=/iPhone|iPad|iPod/i.test(e),n=/Mac/i.test(t);return r||n}catch(e){return console.error(e),!1}},isIOSDevice:function(){try{var e=navigator.userAgent||"";return/iPhone|iPad|iPod/i.test(e)}catch(e){return console.error(e),!1}},isWebView:function(){try{if(void 0===window.navigator)return!1;var e=window.navigator.userAgent,t=/iP(hone|od|ad)/.test(e)&&/AppleWebKit/.test(e)&&!/Safari/.test(e),r=/\bwv\b/.test(e)||/Android/.test(e)&&/AppleWebKit/.test(e)&&!/Chrome/.test(e);return t||r}catch(e){return console.error(e),!1}}},pr=(ur=console,lr=[],cr=[],dr={log:function(e,t){if(ur&&salla.config.isDebug()){lr.push([t,e]),"trace"===salla.config.get("debug")&&(t="trace");var r=ur.log,n=void 0===t?r:this.__dict__[t]||r,i=["%cTwilight","color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;"];cr.forEach(function(e){i[0]+=e[0],i.push(e[1])});var o={event:"#CFF680",backend:"#7b68ee"}[t];o&&(i[0]+="%c"+t[0].toUpperCase()+t.substring(1),i.push("margin-left: 5px;color: ".concat(o,";font-weight:bold; border:1px solid ").concat(o,"; padding: 2px 6px; border-radius: 5px;"))),n.call.apply(n,tr([ur],i.concat.apply(i,e),!1))}},__dict__:{trace:ur.trace,debug:ur.debug,info:ur.info,warn:ur.warn,error:ur.error}},{event:function(){dr.log(arguments,"event")},trace:function(){dr.log(arguments,"trace")},debug:function(){dr.log(arguments,"debug")},info:function(){dr.log(arguments,"info")},warn:function(){dr.log(arguments,"warn")},error:function(){dr.log(arguments,"error")},log:function(){dr.log(arguments,void 0)},backend:function(){dr.log(arguments,"backend")},logs:function(e){[e].flat().forEach(function(e){return e&&dr.log([e].flat(),"backend")})},history:function(){return lr.map(function(e){return ur.log.apply(ur,tr([e[0]],e[1],!1))}),lr},addPrefix:function(e){return Array.isArray(e)?cr.unshift(e):this.warn("addPrefix receives array only!"),this}}),fr=function(){function e(e,t){void 0===e&&(e={}),void 0===t&&(t={}),this.default_properties=t,this.properties_=er(er({},this.default_properties),e)}return e.prototype.merge=function(e){var t;return this.properties_=er(er({},this.properties_),e),this.properties_.store=er(er({},(null===(t=this.default_properties)||void 0===t?void 0:t.store)||{}),this.properties_.store),this},e.prototype.set=function(e,t){return e.includes(".")?(Salla.helpers.setNested(this.properties_,e,t),this):(this.properties_[e]=t,this)},e.prototype.currency=function(e){return void 0===e&&(e=void 0),e=e||this.get("user.currency_code"),this.get("currencies."+e)||Object.values(this.get("currencies"))[0]},e.prototype.get=function(e,t){return void 0===t&&(t=null),e.includes(".")?Salla.helpers.getNested(this.properties_,e,t):this.properties_.hasOwnProperty(e)?this.properties_[e]||t:t||void 0},e.prototype.all=function(){return this.properties_},e.prototype.isDebug=function(){return this.get("debug")||Salla.storage.get("debug")},e}(),gr=function(e){function t(){var t=this;return(t=e.call(this,{wildcard:!0,delimiter:"::",newListener:!1,removeListener:!1,maxListeners:10,verboseMemoryLeak:!1,ignoreErrors:!1})||this).delimiter="::","undefined"!=typeof document&&(t.body=document.querySelector("body")),t.logableEvents=["cart::item.added.failed","cart::item.deleted.failed"],t.ingoreLogEvents=["document::click","document::keyup","document::change"],t.noneFireableActions=["document.request"],t.emittedEvents=new Set,t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}Zt(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),t.prototype.createAndDispatch=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.dispatch.apply(this,tr([e],t,!1))},t.prototype.emit=function(t){for(var r,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];this.emittedEvents.add(t);var o=t.replace("::",".");if(!this.noneFireableActions.includes(o)&&Salla.call&&"function"==typeof Salla.call(o))return Salla.log("'Salla.".concat(o,"(...)' triggered using event '").concat(t,"'")),o=o.split("."),Array.isArray(n[0])&&(n=n[0]),void(r=salla[o[0]])[o[1]].apply(r,n);e.prototype.emit.apply(this,tr([t],n,!1)),this.trackEvents.apply(this,tr([t],n,!1))},t.prototype.onlyWhen=function(e,t){var r=this;return t=t||function(){},new Promise(function(n){return r.emittedEvents.has(e)?n(t()):r.once(e,function(){return n(t())})})},t.prototype.emitAsync=function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];this.emittedEvents.add(t);var i=e.prototype.emitAsync.apply(this,tr([t],r,!1));try{this.trackEvents.apply(this,tr([t],r,!1))}catch(e){Salla.logger.warn("error on tracking event (".concat(t,")"),r,e)}return i},t.prototype.trackEvents=function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];if("undefined"!=typeof window)try{window.dataLayer=window.dataLayer||[];var i={event:e};r.map(function(e){return"object"==typeof e&&(i=er(er({},i),e))}),window.dataLayer.push(i)}catch(e){salla.logger.error(e.message)}Salla.logger&&!this.ingoreLogEvents.includes(e)&&(t=Salla.logger).event.apply(t,tr([e],r,!1)),this.dispatchMobileEvent.apply(this,tr([e],r,!1))},t.prototype.dispatch=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return this.emit.apply(this,tr([e],t,!1))},t.prototype.dispatchEvents=function(e){if(e)if("object"!=typeof e||Array.isArray(e))Salla.log("Events object is wrong, it should be object of {event:payload}",e);else for(var t=0,r=Object.entries(e);t<r.length;t++){var n=r[t],i=n[0],o=n[1];this.dispatch(i,o)}else Salla.log("No Events To Dispatch!",e)},t.prototype.addListener=function(e,t,r){return this.on(e,t,r)},t.prototype.addEventListener=function(e,t,r){return this.on(e,t,r)},t.prototype.listen=function(e,t){return this.on(e,t)},t.prototype.registerGlobalListener=function(e,t){return this.onAny(t)},t.prototype.dispatchMobileEvent=function(e,t){var r;if(void 0===t&&(t={}),"undefined"!=typeof window){if(window.webkit)try{return void window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:e,details:t}))}catch(e){Salla.log(e,"The native context does not exist yet")}if(null===(r=window.Android)||void 0===r?void 0:r.customEventWithData)try{window.Android.customEventWithData(e,JSON.stringify({details:t}))}catch(e){Salla.log(e,"The native context does not exist yet")}else if(window.flutter_inappwebview)try{window.flutter_inappwebview.callHandler("sallaEvent",{event:e,details:t})}catch(e){Salla.log(e,"The Flutter context does not exist yet")}}},t}(At.EventEmitter2),mr=Pt.createStore([jt,Nt,$t,Ht],[]),vr=Pt.createStore([Nt],[]),yr=Pt.createStore([$t],[]),Dr=function(){function e(){var e=this;this.clearableItems=["cart","user","salla::wishlist","salla::wishlist-hydrated-user","salla::availability","token"],Salla.event.on("storage::item.remove",function(t){return e.remove(t)}),Salla.event.on("storage::item.set",function(t,r){return e.set(t,r)}),this.store=mr,this.session=vr,this.cookie=yr}return e.prototype.set=function(e,t){var r;if(e.includes(".")){var n=e.split(".")[0],i=((r={})[n]=this.store.get(n),r);return i=Salla.helpers.setNested(i,e,t),this.store.set(n,i[n])}return this.store.set(e,t)},e.prototype.remove=function(e){return this.store.remove(e)},e.prototype.clearAll=function(e){var t=this;if(void 0===e&&(e=!1),e)return this.store.clearAll();this.clearableItems.forEach(function(e){t.store.remove(e)})},e.prototype.get=function(e,t){var r;if(e.includes(".")){var n=e.split(".")[0];return Salla.helpers.getNested(((r={})[n]=this.store.get(n),r),e)}return this.store.get(e,t)},e.prototype.prefixKey=function(e){return"".concat(e,"_").concat(Salla.config.get("store.id"))},e.prototype.setWithTTL=function(e,t,r,n){void 0===r&&(r=10),void 0===n&&(n="store");var i=this.prefixKey(e),o=(new Date).getTime()+60*r*1e3;return this[n].set(i,{value:t,expiry:o})},e.prototype.getWithTTL=function(e,t,r){void 0===t&&(t=null),void 0===r&&(r="store");var n=this.prefixKey(e),i=this[r].get(n);return i?(new Date).getTime()>i.expiry?(this[r].remove(n),t):i.value:t},e}(),br=function(){function e(){var e=this;this.keysToRemove=["__said","__ssid","theme_edit","ws_port","s-token"],this.dynamicKeysToRemove=["affiliate","cart"],Salla.event.on("cookies::remove",function(t){return e.remove(t)}),Salla.event.on("cookies::add",function(t,r){return e.set(t,r)})}return e.prototype.get=function(e){var t;return null===(t=document.cookie.split("; ").find(function(t){return t.startsWith(e+"=")}))||void 0===t?void 0:t.split("=")[1]},e.prototype.set=function(e,t,r){void 0===t&&(t=""),void 0===r&&(r=10);var n="";if(r){var i=new Date;i.setTime(i.getTime()+24*r*60*60*1e3),n="; expires="+i.toUTCString()}var o=salla.helpers.isIframe()?"None":"Lax";return document.cookie="".concat(e,"=").concat(t).concat(n,"; path=/; SameSite=").concat(o,"; secure"),this},e.prototype.remove=function(e){var t=salla.helpers.isIframe()?"None":"Lax";return document.cookie="".concat(e,"=; Max-Age=0; path=/; SameSite=").concat(t,"; secure"),this},e.prototype.clearAll=function(e){return void 0===e&&(e=!1),this.clean(e)},e.prototype.clean=function(e){var t=this;return document.cookie.split(";").map(function(e){return e.split("=")[0].trim()}).filter(function(r){return e||t.keysToRemove.includes(r)||t.dynamicKeysToRemove.some(function(e){return r.startsWith(e)})}).forEach(function(e){return t.remove(e)}),this},e.prototype.getCookieByPrefix=function(e){return document.cookie.split("; ").map(function(e){return e.split("=")[0]}).filter(function(t){return t.startsWith(e)})},e.prototype.clearCookieByPrefix=function(e){var t=this;return this.getCookieByPrefix(e).forEach(function(e){return t.remove(e)})},e}();"undefined"!=typeof window&&(window.salla=window.salla||window.Salla||{},window.Salla=window.salla),"undefined"!=typeof global&&(global.salla=global.salla||global.Salla||{},global.Salla=global.salla),Salla.status="base",Salla.config=new fr,Salla.logger=pr,Salla.event=new gr,Salla.helpers=hr,Salla.storage=new Dr,Salla.cookie=new br,Salla.log=Salla.logger.log,Salla.money=Salla.helpers.money,Salla.url=Salla.helpers.url,Salla.versions={base:"3.0.0-beta.1"};var Fr=Salla;let wr=function(e,t,r){return alert(e)},Er=function(e,t){return wr(e,Sr.error,t)},Sr={error:"error",success:"success",info:"info"};var _r={fire:function(e,t,r){return wr(e,t,r)},setNotifier:function(e){wr=e,salla.event.emit("twilight::notifier.changed")},error:Er,success:function(e,t){return wr(e,Sr.success,t)},info:function(e,t){return wr(e,Sr.info,t)},sallaInitiated:function(){let e=window.location.href.match(/([\?\&]danger=)[^&]+/g);e&&(window.history.replaceState(null,document.title,window.location.pathname),salla.event.once("twilight::notifier.changed",()=>{e.forEach(e=>{e=decodeURI(e.replace("?danger=","").replace("&danger=",""));let t=document.createElement("div");t.innerText=e,Er(t.innerHTML),salla.event.emit("twilight::error",e)})}))},types:Sr};class Ar{constructor(e,t){return this.api=e,this.event=t,new Proxy(this,{get:function(r,n){return"event"===n?t:"api"===n?e:e&&e[n]||r[n]}})}}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 o=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,o);o[t.name]=t.value}catch(t){Salla.log(e.name+" can't be send")}}),this.getFilteredData(o)},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||(null==r?void 0: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=(null==r?void 0:r.dataset[n])||this.dataset[n];if(i){var o=window[i];if("function"==typeof o){if(!o(e,r||this,t)&&e)throw`Data failed to be pass verify function window.${i}(formData, element, event)!`;return o(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}}};class Cr{constructor(){this.events={},this.namespace="";let e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&e.length>1?e[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=e.charAt(0).toUpperCase()+e.slice(1),r="on"+t,n="off"+t,i=this;this[r]||(this[r]=function(t){return t.asyncWrapper=t.asyncWrapper||async function(...e){return t(...e)},i.on(e,t.asyncWrapper)}),this[n]||(this[n]=function(t){return Salla.event.off(i.getEventName(e),t.asyncWrapper||t)})}getEventName(e){return e=this.events[e]||e||"unknown-event",!this.namespace||e.includes("::")?e:this.namespace+Salla.event.delimiter+e}dispatch(e,...t){return Salla.event.emitAsync(this.getEventName(e),...t)}on(e,t,r={}){return Salla.event.addListener(this.getEventName(e),t,r)}once(e,t){return Salla.event.once(this.getEventName(e),t)}}function kr(e,t){this.v=e,this.k=t}function xr(e){var t={},r=!1;function n(t,n){return r=!0,n=new Promise(function(r){r(e[t](n))}),{done:!1,value:new kr(n,1)}}return t["undefined"!=typeof Symbol&&Symbol.iterator||"@@iterator"]=function(){return this},t.next=function(e){return r?(r=!1,e):n("next",e)},"function"==typeof e.throw&&(t.throw=function(e){if(r)throw r=!1,e;return n("throw",e)}),"function"==typeof e.return&&(t.return=function(e){return r?(r=!1,e):n("return",e)}),t}function Pr(e){var t,r,n,i=2;for("undefined"!=typeof Symbol&&(r=Symbol.asyncIterator,n=Symbol.iterator);i--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new Ir(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function Ir(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:t}})}return Ir=function(e){this.s=e,this.n=e.next},Ir.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var r=this.s.return;return void 0===r?Promise.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Promise.reject(e):t(r.apply(this.s,arguments))}},new Ir(e)}function Or(e){return new kr(e,0)}function Br(){return Br=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Br.apply(null,arguments)}function jr(e){return function(){return new Tr(e.apply(this,arguments))}}function Tr(e){var t,r;function n(t,r){try{var o=e[t](r),a=o.value,s=a instanceof kr;Promise.resolve(s?a.v:a).then(function(r){if(s){var u="return"===t&&a.k?t:"next";if(!a.k||r.done)return n(u,r);r=e[u](r).value}i(!!o.done,r)},function(e){n("throw",e)})}catch(e){i(2,e)}}function i(e,i){2===e?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?n(t.key,t.arg):r=null}this._invoke=function(e,i){return new Promise(function(o,a){var s={key:e,arg:i,resolve:o,reject:a,next:null};r?r=r.next=s:(t=r=s,n(e,i))})},"function"!=typeof e.return&&(this.return=void 0)}Tr.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},Tr.prototype.next=function(e){return this._invoke("next",e)},Tr.prototype.throw=function(e){return this._invoke("throw",e)},Tr.prototype.return=function(e){return this._invoke("return",e)};function Rr(e){e&&e.sallaInitiated&&!e.initiated&&(e.sallaInitiated(),e.initiated=!0)}Salla.event.auth=new class extends Cr{constructor(){super(),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",refreshFailed:"refresh.failed",tokenFetched:"token.fetched",tokenInvalid:"token.invalid"},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))}async loggedIn(e){return Salla.profile.info().catch(()=>{}).finally(()=>this.dispatch("loggedIn",e))}setTypeActionOnVerified(e){this.type_action_on_verified=e}getTypeActionOnVerified(){return this.type_action_on_verified||"redirect"}},Salla.event.cart=new class extends Cr{constructor(){super(),this.namespace="cart",this.events={latestFetched:"latest.fetched",latestFailed:"latest.failed",updated:"updated",itemUpdated:"item.updated",itemUpdatedFailed:"item.updated.failed",itemAdded:"item.added",beforeAddItem:"before.add.item",itemAddedFailed:"item.added.failed",itemDeleted:"item.deleted",itemDeletedFailed:"item.deleted.failed",submitted:"submitted",submitFailed:"submit.failed",imageDeleted:"image.deleted",imageNotDeleted:"image.not.deleted",detailsFetched:"details.fetched",detailsNotFetched:"details.not.fetched",successReset:"success.reset",priceQuoteSucceeded:"price-quote.succeeded",priceQuoteFailed:"price-quote.failed",offersFetched:"offers.fetched",offersFailed:"offers.failed",couponAdded:"coupon.added",couponDeleted:"coupon.deleted",couponAdditionFailed:"coupon.addition.failed",couponDeletionFailed:"coupon.deletion.failed",quickOrderSettingFetched:"quick-order.fetched",quickOrderSettingFailed:"quick-order.failed",quickOrderSucceeded:"quick-order.succeeded",quickOrderFailed:"quick-order.failed",beforeStartFastCheckout:"before.start.fast-checkout",submitting:"submitting"},this.after_init()}updated(e,t={}){var r;return Salla.cookie.set("fresh_summary",1),e&&"object"==typeof e?(e.offer&&salla.product.event.offerExisted(e.offer),e.redirect&&(salla.log("The current cart is purchased!"),salla.cart.api.reset()),e.cart?(salla.storage.set("cart.summary",{total:e.cart.total,sub_total:e.cart.sub_total,discount:e.cart.discount,tax_amount:e.cart.tax_amount,total_discount:e.cart.total_discount,real_shipping_cost:e.cart.real_shipping_cost,count:e.cart.count,shipping_cost:null!=(r=e.cart.free_shipping_bar)&&r.has_free_shipping?0:e.cart.real_shipping_cost}),this.dispatch("updated",Br({},e.cart,{fromLatestFetched:t.fromLatestFetched}))):void salla.log("Failed to get the cart summary!")):(Salla.logger.info("Cart summary not an object!",e),this.dispatch("updated",{fromLatestFetched:t.fromLatestFetched}))}latestFetched(e){return this.updated(e.data,{fromLatestFetched:!0}),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)}},Salla.event.order=new class extends Cr{constructor(){super(),this.namespace="order",this.events={canceled:"canceled",notCanceled:"not.canceled",orderCreated:"order.created",orderCreationFailed:"order.creation.failed",invoiceSent:"invoice.sent",invoiceNotSent:"invoice.not.sent",editSessionCanceled:"edit.session.canceled",editSessionNotCanceled:"edit.session.not.canceled",detailsFetched:"details.fetched",detailsNotFetched:"details.not.fetched",branchDetailsFetched:"branch.details.fetched",branchDetailsNotFetched:"branch.details.not.fetched",ordersFetched:"order.fetched",ordersNotFetched:"order.not.fetched",orderEdited:"order.edited",orderNotEdited:"order.not.edited"},this.after_init()}},Salla.event.scope=new class extends Cr{constructor(){super(),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()}},Salla.event.rating=new class extends Cr{constructor(){super(),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()}},Salla.event.booking=new class extends Cr{constructor(){super(),this.namespace="booking",this.events={added:"added",additionFailed:"addition.failed"},this.after_init()}},Salla.event.comment=new class extends Cr{constructor(){super(),this.namespace="comment",this.events={added:"added",additionFailed:"addition.failed",fetched:"fetched",fetchFailed:"fetch.failed"},this.after_init()}},Salla.event.landing=new class extends Cr{constructor(){super(),this.namespace="landing",this.events={detailsFetched:"order.fetched",getDetailsFailed:"get.details.failed",orderCreated:"order.created",orderCreationFailed:"order.creation.failed",breadcrumbFetched:"breadcrumb.fetched",breadcrumbFetchFailed:"breadcrumb.fetch.failed"},this.after_init()}},Salla.event.loyalty=new class extends Cr{constructor(){super(),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",loyaltyPointsFetched:"points.fetched",loyaltyPointsNotFetched:"points.not.fetched"},this.after_init()}exchangeSucceeded(e,t){return salla.cart.event.updated(e.data),this.dispatch("exchangeSucceeded",e,t)}resetSucceeded(e){return salla.cart.event.updated(e.data),this.dispatch("resetSucceeded",e)}},Salla.event.product=new class extends Cr{constructor(){super(),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",detailFetched:"detail.fetched",detailFetchFailed:"detail.failed",addGiftToCartSucceeded:"gift.add-to-cart.succeeded",addGiftToCartFailed:"gift.add-to-cart.failed",giftImageUploadSucceeded:"gift.image-upload.succeeded",giftImageUploadFailed:"gift.image-upload.failed",productListFetchSucceeded:"fetch.succeeded",productListFetchFailed:"fetch.failed",productOptionsFetched:"options.fetched",productOptionsNotFetched:"options.not.fetched"},this.after_init()}},Salla.event.profile=new class extends Cr{constructor(){super(),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",settingsUpdated:"settings.updated",updateSettingsFailed:"update.settings.failed",deleted:"deleted",notDeleted:"not.deleted"},this.after_init()}},Salla.event.currency=new class extends Cr{constructor(){super(),this.namespace="currency",this.events={changed:"changed",failed:"failed",fetched:"fetched",failedToFetch:"failed.to.fetch"},this.after_init()}},Salla.event.document=new class extends Cr{constructor(){super(),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)}},Salla.event.wishlist=new class extends Cr{constructor(){super(),this.namespace="wishlist",this.events={added:"added",removed:"removed",additionFailed:"addition.failed",removingFailed:"removing.failed",beforeRemoveItem:"before.remove.item",beforeAddItem:"before.add.item",beforeShare:"before.share",shared:"shared",sharingFailed:"sharing.failed"},this.after_init()}},Salla.event.infiniteScroll=new class extends Cr{constructor(){super(),this.namespace="infiniteScroll",this.events={scrollThreshold:"scroll.threshold",request:"request",load:"load",append:"append",error:"error",last:"last",history:"history"},this.after_init()}},Salla.event.notifications=new class extends Cr{constructor(){super(),this.namespace="notifications",this.events={fetched:"fetched",fetchFailed:"fetch.failed"},this.after_init()}},Salla.event.component=new class extends Cr{constructor(){super(),this.namespace="component",this.events={menuFetched:"menus.fetched",menuFetchFailed:"menus.fetch.failed",reviewsFetched:"reviews.fetched",reviewsFetchFailed:"reviews.fetch.failed"},this.after_init()}},Salla.event.advertisement=new class extends Cr{constructor(){super(),this.namespace="advertisement",this.events={fetched:"advertisement.fetched",fetchFailed:"advertisement.not.fetched"},this.after_init()}},Salla.event.navigation=new class extends Cr{constructor(){super(),this.namespace="navigation",this.events={breadcrumbFetched:"breadcrumb.fetched",breadcrumbFetchFailed:"breadcrumb.fetch.failed"},this.after_init()}},Salla.event.metadata=new class extends Cr{constructor(){super(),this.namespace="metadata",this.events={valueFetched:"value.fetched",valueNotFetch:"value.not.fetched"},this.after_init()}},Salla.event.recommendations=new class extends Cr{constructor(){super(),this.namespace="recommendations",this.events={customersAlsoBoughtFetched:"customers-also-bought.fetched",customersAlsoBoughtFailed:"customers-also-bought.failed",similarProductsFetched:"similar-products.fetched",similarProductsFailed:"similar-products.failed",buyAgainFetched:"buy-again.fetched",buyAgainFailed:"buy-again.failed",personalizedShoppersWhoBoughtFetched:"personalized-shoppers-who-bought.fetched",personalizedShoppersWhoBoughtFailed:"personalized-shoppers-who-bought.failed",boughtTogetherFetched:"bought-together.fetched",boughtTogetherFailed:"bought-together.failed"},this.after_init()}},Salla.event.on("twilight::initiated",()=>{Object.keys(Salla).forEach(e=>{"object"==typeof(e=Salla[e])&&(Rr(e),Object.keys(e).forEach(t=>{Rr(e[t])}))})}),Salla.config.default_properties={debug:"undefined"!=typeof process&&"development"===process.env.NODE_ENV,token:null,fastRequests:!0,canLeave:!0,store:{api:["group","test"].includes(window.location.hostname.split(".").pop())?window.location.origin+"/api/v1/":"https://api.salla.dev/store/v1/"},recommendations:{api:"https://api.salla.dev/recommendations/v1",optimusDecode:!0},currencies:{SAR:{code:"SAR",name:"ريال سعودي",symbol:"ر.س",amount:1,country_code:"sa"}}},Salla.config.merge(Salla.config.default_properties),Salla.config.triedToGetCurrencies_=!1,Salla.config.triedToGetLanguages_=!1,Salla.config.isUser=()=>"user"===Salla.config.get("user.type"),Salla.config.isGuest=()=>!Salla.config.isUser(),Salla.config.languages=async()=>{var e;if(Salla.config.triedToGetLanguages_||Salla.config.get("languages",[]).length>0)return Salla.config.get("languages",[]);Salla.config.triedToGetLanguages_=!0;let t=!0,r=[];return null==(e=await salla.document.api.request("languages",null,"get"))||null==(e=e.data)||e.map(e=>{t&&(r=[],t=!1),e.code=e.code||e.iso_code,e.url=salla.url.get(e.code),e.is_rtl=e.is_rtl||e.rtl,r.push(e)}),Salla.config.set("languages",r),r},Salla.config.currencies=async()=>{var e;if(Salla.config.triedToGetCurrencies_)return Salla.config.get("currencies");Salla.config.triedToGetCurrencies_=!0;let t=!0,r={};return null==(e=await salla.currency.api.list())||null==(e=e.data)||e.map(e=>{t&&(r={},t=!1),e.country_code=e.code.substr(0,2).toLowerCase(),r[e.code]=e}),t?Salla.config.get("currencies",{}):(Salla.config.set("currencies",r),r)},Salla.config.isMobileApp=()=>{var e;return["ios","android"].includes(null==(e=Salla.analytics)||null==(e=e.jitsuAnalytics)||null==(e=e.getContextProperty("app"))||null==(e=e.platform)?void 0:e.toLowerCase())||Salla.config.get("theme.is_spa_webview")};var Lr,Nr={exports:{}},Ur={exports:{}},qr={exports:{}},zr=qr.exports;function $r(){return Lr||(Lr=1,function(e){!function(t,r){e.exports?e.exports=r():t.EvEmitter=r()}("undefined"!=typeof window?window:zr,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})}(qr)),qr.exports}var Mr,Hr,Wr={exports:{}},Gr=Wr.exports;function Jr(){return Mr||(Mr=1,function(e){!function(t,r){e.exports?e.exports=r(t):t.fizzyUIUtils=r(t)}(Gr,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 o="data-"+t.toDashed(i),a=document.querySelectorAll(`[${o}]`),s=e.jQuery;[...a].forEach(e=>{let t,a=e.getAttribute(o);try{t=a&&JSON.parse(a)}catch(t){return void(r&&r.error(`Error parsing ${o} on ${e.className}: ${t}`))}let u=new n(e,t);s&&s.data(e,i,u)})})},t})}(Wr)),Wr.exports}function Vr(){return Hr||(Hr=1,function(e){!function(t,r){e.exports?e.exports=r(t,$r(),Jr()):t.InfiniteScroll=r(t,t.EvEmitter,t.fizzyUIUtils)}(window,function(e,t,r){let n=e.jQuery,i={};function o(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=Br({},o.defaults),this.option(t),n&&(this.$element=n(this.element)),this.create()}else console.error("Bad element for InfiniteScroll: "+(a||e))}o.defaults={},o.create={},o.destroy={};let a=o.prototype;Object.assign(a,t.prototype);let s=0;a.create=function(){let e=this.guid=++s;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 o.create)o.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 o=e+=".infiniteScroll";if(t){let r=n.Event(t);r.type=e,o=r}this.$element.trigger(o,r)};let u={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=u[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 l=[/^(.*?\/?page\/?)(\d\d?\d?)(.*?$)/,/^(.*?\/?\?page=)(\d\d?\d?)(.*?$)/,/(.*?)(\d\d?\d?)(?!.*\d)(.*?$)/],c=o.getPathParts=function(e){if(e)for(let t of l){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=c(r);if(!n)return void console.error(`InfiniteScroll unable to parse next link href: ${r}`);let{begin:i,index:o,end:a}=n;this.isPathSelector=!0,this.getPath=()=>i+(this.pageIndex+1)+a,this.pageIndex=parseInt(o,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()},o.create.hideNav=function(){let e=r.getQueryElement(this.options.hideNav);e&&(e.style.display="none",this.nav=e)},o.destroy.hideNav=function(){this.nav&&(this.nav.style.display="")},a.destroy=function(){this.allOff();for(let e in o.destroy)o.destroy[e].call(this);delete this.element.infiniteScrollGUID,delete i[this.guid],n&&this.$element&&n.removeData(this.element,"infiniteScroll")},o.throttle=function(e,t){let r,n;return t=t||200,function(){let i=+new Date,o=arguments,a=()=>{r=i,e.apply(this,o)};r&&i<r+t?(clearTimeout(n),n=setTimeout(a,t)):a()}},o.data=function(e){let t=(e=r.getQueryElement(e))&&e.infiniteScrollGUID;return t&&i[t]},o.setJQuery=function(e){n=e},r.htmlInit(o,"infinite-scroll"),a._init=function(){};let{jQueryBridget:d}=e;return n&&d&&d("infiniteScroll",o,n),o})}(Ur)),Ur.exports}var Kr,Qr={exports:{}};function Xr(){return Kr||(Kr=1,function(e){!function(t,r){e.exports?e.exports=r(t,Vr()):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 o=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(o=>("text"==e&&t&&(o=n.parseFromString(o,"text/html")),204==r.status?(this.lastPageReached(o,i),{body:o,response:r}):this.onPageLoad(o,i,r)))}).catch(e=>{this.onPageError(e,i)});return this.dispatchEvent("request",null,[i,o]),o},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:o,domParseResponse:a}=this.options;if(!("text"==o&&a)||!n)return{body:e,response:r};let s=e.querySelectorAll(n),u={body:e,response:r,items:s};if(!s||!s.length)return this.lastPageReached(e,t),u;let l=i(s),c=()=>(this.appendItems(s,l),this.isLoading=!1,this.dispatchEvent("append",null,[e,t,s,r]),u);return this.options.outlayer?this.appendOutlayerItems(l,c):c()},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})}(Qr)),Qr.exports}var Yr,Zr={exports:{}};function en(){return Yr||(Yr=1,function(e){!function(t,r){e.exports?e.exports=r(t,Vr(),Jr()):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})}(Zr)),Zr.exports}var tn,rn={exports:{}};function nn(){return tn||(tn=1,function(e){!function(t,r){e.exports?e.exports=r(t,Vr(),Jr()):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],o=this.getElementScrollY(n);i.href=t,this.scrollPages.push({top:o,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})}(rn)),rn.exports}var on,an={exports:{}};function sn(){return on||(on=1,function(e){!function(t,r){e.exports?e.exports=r(t,Vr(),Jr()):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})}(an)),an.exports}var un,ln,cn={exports:{}};function dn(){return un||(un=1,function(e){!function(t,r){e.exports?e.exports=r(t,Vr(),Jr()):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,function(e,t,r){let n=t.prototype;function i(e){a(e,"none")}function o(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){o(this.statusElement),this.hideStatusEventElements(),o(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})}(cn)),cn.exports}var hn=(ln||(ln=1,function(e){window,e.exports&&(e.exports=function(e){return e}(Vr(),Xr(),en(),nn(),sn(),dn()))}(Nr)),Nr.exports);var pn,fn={exports:{}};var gn=(pn||(pn=1,function(e){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"},o=function(t){t=t||{},this.locale=t.locale||e()||i.locale,this.fallback=t.fallback,this.messages=t.messages};return o.prototype.setMessages=function(e){this.messages=e},o.prototype.getLocale=function(){return this.locale||this.fallback},o.prototype.setLocale=function(e){this.locale=e},o.prototype.getFallback=function(){return this.fallback},o.prototype.setFallback=function(e){this.fallback=e},o.prototype.has=function(e,t){return!("string"!=typeof e||!this.messages)&&null!==this._getMessage(e,t)},o.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)},o.prototype.trans=function(e,t){return this.get(e,t)},o.prototype.choice=function(e,t,r,i){(r=void 0!==r?r:{}).count=t;var o=this.get(e,r,i);if(null==o)return o;for(var a=o.split("|"),s=[],u=0;u<a.length;u++)if(a[u]=a[u].trim(),n.test(a[u])){var l=a[u].split(/\s/);s.push(l.shift()),a[u]=l.join(" ")}if(1===a.length)return o;for(var c=0;c<s.length;c++)if(this._testInterval(t,s[c]))return a[c];return i=i||this._getLocale(e),a[this._getPluralForm(t,i)]},o.prototype.transChoice=function(e,t,r){return this.choice(e,t,r)},o.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)}},o.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},o.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 o=r.slice(0,n+1).join("."),a=r.slice(n+1,r.length).join(".");if(e[o])return this._getValueInKey(e[o],a)}return e},o.prototype._getLocale=function(e){return e=this._parseKey(e,this.locale),this.messages[e.source]?this.locale:this.messages[e.sourceFallback]?this.fallback:null},o.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},o.prototype._sortReplacementKeys=function(e,t){return t.length-e.length},o.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},o.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 o=(i=i.filter(function(e){return!!e}))[1],a=t(i[2]);a===1/0&&(a=-1/0);var s=t(i[3]),u=i[4];return("["===o?e>=a:e>a)&&("]"===u?e<=s:e<s)}for(var l=i[2].split(","),c=0;c<l.length;c++)if(parseInt(l[c],10)===e)return!0;return!1},o.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}},o}()}(fn)),fn.exports);class mn{constructor(){this.endpoints={},this.webEndpoints=[],this.namespace="BaseApi",this.endpointsMethods={},this.endpointsHeaders={};let e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&e.length>1?e[1]:"").toLowerCase(),this.debounce={request:void 0,time:300,enabled:!0,exclude:[]}}after_init(){}normalRequest(e,t=void 0,r=null){let n=Array.isArray(e),i=n?this.getUrl(...e):this.getUrl(e);e=n?e[0]:e,r=r||this.endpointsMethods[e]||"post";let o=this.endpointsHeaders[e];if("get"===r&&t instanceof FormData){let e={};Array.from(t.entries()).forEach(function(t){e[t[0]]=t[1]}),t={params:e}}return o&&"get"===r&&(t=t?Object.assign(t,o):o),this.webEndpoints.includes(e)?i=salla.url.get(i):"http"!==i.substring(0,4)&&(i=salla.url.api(i)),Salla.api.request(i,t,r,{headers:o})}request(e,t=void 0,r=null){return!salla.api.isFastRequestsAllowed()&&this.debounce.enabled?(this.debounce.request||(this.debounce.request=salla.helpers.debounce(this.normalRequest.bind(this),this.debounce.time)),this.debounce.request(e,t,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}event(){return salla.event[this.className]}}class vn extends mn{constructor(){super(),this.addToCartTries=0,this.guestCartAssigned=!1,this.namespace="cart",this._pendingCartIdRequest=null,this._pendingAssignRequest=null,this._pendingOffersRequest=null,this.endpoints={latest:"cart/latest",latestApi:"cart/latest",details:"cart/{cart}",quickAdd:"cart/{cart}/item/{product}/quick-add",addItem:"cart/{cart}/item/{product}/add",deleteItem:"cart/{cart}/item/{item}",updateItem:"cart/{cart}/item/{item}",deleteImage:"cart/{cart}/image/{image}",uploadImage:"cart/{cart}/image",status:"cart/{cart}/status",addCoupon:"cart/{id}/coupon",deleteCoupon:"cart/{id}/coupon",getQuickOrderSettings:"checkout/quick-order",createQuickOrder:"checkout/quick-order",priceQuote:"cart/{cartId}/price-quote",offers:"offers/cart/{cartId}",giftCartDetails:"cart/{cartId}/buy-as-gift",cartGiftToCart:"cart/{cart_id}/buy-as-gift",assign:"cart/{cartId}/assign?merge=1"},this.endpointsMethods={latest:"get",latestApi:"get",details:"get",status:"get",updateItem:"post",deleteItem:"delete",deleteImage:"delete",deleteCoupon:"put",getQuickOrderSettings:"get",offers:"get",giftCartDetails:"get"},this.webEndpoints=["latest"],this.latestCart=null,this.after_init(),salla.event.on("api::initiated",()=>salla.api.cart.getCurrentCartId(!1,"api::initiated")),salla.event.on("auth::token.fetched",this._checkCurrentCart),salla.event.on("auth::token.invalid",this._checkCurrentCart),salla.event.on("auth::verified",async function(){try{await Salla.api.cart.assign()}catch(e){Salla.log("Error on assign after verified",e)}return Salla.api.cart.getCurrentCartId(!0,"auth::verified")},{async:!0}),salla.event.on("twilight::initiated",()=>salla.api.cart.syncGuestCart()),salla.event.on("profile::info.fetched",()=>this._checkCurrentCart(!0)),salla.event.on("twilight::error",e=>(e.includes("Cart not available")||e.includes("السلة غير متاحة"))&&salla.cart.api.reset()),salla.event.on("cart::updated",()=>{Salla.api.cart._pendingOffersRequest=null})}_checkCurrentCart(e=!1){var t,r;let n=salla.storage.get("cart"),i=null==(t=salla.config.get("user"))?void 0:t.id,o=null==(r=salla.config.get("store"))?void 0:r.id,a=Salla.url.is_page("cart");n&&n.id&&!e&&(!a&&(n.store_id!==o||i&&n.user_id!==i)&&(salla.log("cart",{user_id:n.user_id,store_id:n.store_id}),salla.log("current",{user_id:i,store_id:o}),salla.log("Api:: case2 => The cart is not belong to current "+(n.user_id!==i?"user":"store")+"!"),salla.cart.api.reset()),a&&n.id!==Salla.config.get("page.id")&&(salla.log("cart",{user_id:n.user_id,store_id:n.store_id}),salla.log("current",{user_id:i,store_id:o}),salla.log(`Api:: case2 => The cart is different between storage:${n.id} & session:${salla.config.get("page.id")} !`),salla.cart.api.reset()))}async getCurrentCartId(e=!1,t="getCurrentCartId"){if(Salla.cart.api._pendingCartIdRequest)return Salla.cart.api._pendingCartIdRequest;Salla.cart.api._pendingCartIdRequest=async function(){try{if(!e){if(Salla.cart.api.latestCart)return Salla.cart.api.latestCart.cart.id;let e=Salla.storage.get("cart.id");if(e)return e}let r=await Salla.cart.api.latest(t);return Salla.cart.api.latestCart=r.data,Salla.cart.api.latestCart.cart.id}finally{Salla.cart.api._pendingCartIdRequest=null}}();let r=Salla.cart.api._pendingCartIdRequest;return Salla.cart.api._pendingCartIdRequest=null,r}getUploadImageEndpoint(e){return salla.url.api(this.getUrl("uploadImage",e||salla.storage.get("cart.id")))}latest(e="direct"){return this.request(salla.auth.api.isSessionless()?"latestApi":"latest",{params:{source:"",callerName:e}}).then(e=>(salla.api.cart.set(e.data.cart),salla.event.cart.latestFetched(e),e)).catch(e=>{throw salla.api.cart.reset(),salla.event.cart.latestFailed(e),e})}async details(e,t=[]){return e=e||await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.details"),this.request(["details",e],{params:{with:t}}).then(function(e){return salla.cart.event.detailsFetched(e),e}).catch(function(e){throw salla.cart.event.detailsNotFetched(e),e})}async quickAdd(e,t,r){return this.addItem({id:e,quantity:t,offerType:r,endpoint:"quickAdd"})}async addItem(e){var t;let r=this.getCartPayload(e);if(!r.id){let e='There is no product "id"!';return salla.cart.event.itemAddedFailed(e),salla.api.errorPromise(e)}let n=salla.form.getPossibleValue(r.payload,["endpoint"]);n&&["addItem","quickAdd"].includes(n)||(n=salla.form.getPossibleValue(r.payload,["quantity","donating_amount"])?"addItem":"quickAdd");let i=null==(t=r.payload)?void 0:t.source;r.payload&&delete r.payload.source,Salla.cart.api.addToCartSource=i||null;let o=await Salla.api.cart.getCurrentCartId(!1,"salla.api.cart.addItem");try{r.payload=Salla.helpers.createFormDataWrapper(r.payload||{}),await Salla.cart.event.beforeAddItem(r)}catch(e){}return this.request([n,o,r.id],r.payload.getRawData()).then(function(e){Salla.cart.api.addToCartTries=0;try{Salla.cart.event.itemAdded(e,r.id)}catch(e){Salla.log(e)}return e}).catch(function(t){var n;if(422!==(null==t||null==(n=t.response)?void 0:n.status)&&!Salla.cart.api.addToCartTries)return Salla.cart.api.addToCartTries++,Salla.cart.reset(),Salla.cart.api.addItem(e);throw Salla.cart.event.itemAddedFailed(t,r.id),t})}async deleteItem(e){let t=this.getCartPayload(e);if(!t.id){let e='There is no "id"!';return salla.cart.event.itemDeletedFailed(e),salla.api.errorPromise(e)}let r=await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.deleteItem");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){var t;let r=this.getCartPayload(e);if(!r.id){let e='There is no "id"!';return salla.cart.event.itemUpdatedFailed(e),salla.api.errorPromise(e)}let n=await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.updateItem");return"Object"===(null==(t=r.payload.constructor)?void 0:t.name)?r.payload._method="PUT":r.payload.append("_method","PUT"),this.request(["updateItem",n,r.id],r.payload).then(function(e){return salla.cart.event.itemUpdated(e,r.id),e}).catch(function(e){throw salla.cart.event.itemUpdatedFailed(e,r.id),e})}async deleteImage(e){if(!(e=salla.form.getPossibleValue(e,["id","image_id","photo_id"]))){let e='There is no "id"!';return salla.cart.event.imageNotDeleted(e),salla.api.errorPromise(e)}let t=await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.deleteImage");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,t=!1){e=e||await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.status");const r={has_apple_pay:salla.helpers.hasApplePay()};t&&(r.guest_checkout=1);try{await salla.cart.event.submitting()}catch(e){salla.log("Error on: salla.cart.event.submitting()")}return this.request(["status",e],{params:r})}async submit(e=!1,t=!1){const r=salla.config.get("store.features",[]).includes("embedded-login-checkout");if(salla.config.isGuest()){if(!(salla.config.get("store.features",[]).includes("cross-store-login")&&await salla.cart.tryCrossStoreLogin())&&salla.config.isGuest()){if(!r&&!t)return salla.cart.loginOnCartPage();try{await salla.api.cart.syncGuestCart()}catch(e){salla.log("Error on syncGuestCart during guest checkout",e)}}}let n;if(e)try{var i;const e=await Salla.api.cart.assign();n=null==e||null==(i=e.data)?void 0:i.cart_id}catch(e){Salla.log("Error on assign after login from submit",e)}const o=salla.config.isGuest()&&(t||r);this.status(null!=n?n:await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.submit"),o).then(e=>{var t;let r=null==(t=e.data.next_step)?void 0:t.to;if(!r)return window.history.pushState({},"",salla.url.addParamToUrl("reload","empty_next_step")),window.history.pushState({},"",salla.url.addParamToUrl("acitve",!1===e.data.active?"false":"true_or_undfined")),salla.cart.reset(),window.location.reload();if(!["checkout","refresh","login"].includes(r)){let e="Can't find next_step );";throw salla.cart.reset(),salla.cart.event.submitFailed(e),e}if(salla.cart.event.submitted(e),"login"===r)return salla.cart.loginOnCartPage();if("checkout"===r){var n,i;let t=null==(n=e.data.next_step)?void 0:n.url;if(!t){let e="Checkout URL is missing from response";throw salla.cart.event.submitFailed(e),e}return salla.helpers.hasApplePay()&&(t+=(t.includes("?")?"&":"?")+"has_apple_pay=true"),null!=(i=salla.mobile)&&null!=i.isSpaWebview&&i.isSpaWebview()&&salla.mobile.openCheckout?salla.mobile.openCheckout(t):window.location.href=t}window.history.pushState({},"",salla.url.addParamToUrl("reload","refresh")),window.location.reload()}).catch(function(r){var n;salla.cart.api.tries=salla.cart.api.tries||0,salla.cart.reset();let i=404===(null==r||null==(n=r.response)||null==(n=n.data)?void 0:n.status);if(i&&0===salla.cart.api.tries)return salla.cart.api.tries++,salla.log("we recived that the current cart is not found, we will try to re-submit one more time"),salla.cart.submit(e,t);throw i&&salla.error(salla.lang.get("pages.checkout.try_again")),salla.cart.event.submitFailed(r),r})}getCartPayload(e){var t;let r=(null==(t=e)?void 0:t.data)||("object"==typeof e?e:void 0);return e=r?salla.form.getPossibleValue(r,["prod_id","product_id","item_id","id"]):e,r="object"==typeof r?r:void 0,{id:e,payload:r}}normalRequest(e,t=void 0,r=null){var n=this;return super.normalRequest(e,t,r).catch(async function(e){var t;throw 403===(null==e||null==(t=e.response)?void 0:t.status)&&(n.reset(),salla.error(salla.lang.get("pages.checkout.try_again"))),e})}reset(){salla.api.cart.latestCart=null,salla.storage.remove("cart"),salla.cookie.clearCookieByPrefix(salla.api.cart.getCartCookiePrefix()),salla.cart.event.successReset()}async addCoupon(e){if(e=e.data||e,!(e=salla.form.getPossibleValue(e,["coupon"]))){let e=new Error('There is no "Coupon Code"!');return e.name="EmptyCoupon",salla.event.cart.couponAdditionFailed(e),salla.api.errorPromise(e)}let t=await salla.cart.api.getCurrentCartId(!1,"salla.api.cart.addCoupon");return this.request(["addCoupon",t],{coupon:e}).then(function(e){var r;let n=salla.storage.get("cart");return n&&null!=(r=e.data)&&null!=(r=r.cart)&&r.coupon&&(n.coupon=e.data.cart.coupon,salla.storage.set("cart",n)),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(!1,"salla.api.cart.deleteCoupon");return this.request(["deleteCoupon",e],{}).then(function(t){let r=salla.storage.get("cart");return r&&r.coupon&&(delete r.coupon,salla.storage.set("cart",r)),salla.event.cart.couponDeleted(t,e),t}).catch(function(t){throw salla.event.cart.couponDeletionFailed(t,e),t})}getQuickOrderSettings(){return this.request("getQuickOrderSettings").then(e=>(salla.event.cart.quickOrderSettingFetched(e),e)).catch(e=>{throw salla.event.cart.quickOrderSettingFailed(e),e})}createQuickOrder(e){return this.request("createQuickOrder",e).then(e=>(salla.event.cart.quickOrderSucceeded(e),e)).catch(e=>{throw salla.event.cart.quickOrderFailed(e),e})}async priceQuote(e){return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("cart::priceQuote",e),void salla.event.dispatch("login::open")):this.request(["priceQuote",e||await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.priceQuote")]).then(e=>(salla.cart.api.reset(),salla.event.cart.priceQuoteSucceeded(e).then(()=>(setTimeout(()=>window.location.href=salla.url.get("/"),1e3),e)))).catch(e=>salla.event.cart.priceQuoteFailed(e).then(()=>{var t;throw 404===(null==(t=e.error)?void 0:t.code)&&window.location.reload(),e}))}loginOnCartPage(){salla.auth.setCanRedirect(!1),salla.event.dispatch("login::open",{withoutReload:!0,source:"cart-submit"}),salla.auth.event.onLoggedIn(()=>{salla.event.dispatch("login::close"),salla.cart.submit(!0)})}tryCrossStoreLogin(e=1500){return salla.config.isGuest()?salla.config.get("store.features",[]).includes("sso-login")?Promise.resolve(!1):new Promise(t=>{const r=salla.config.get("login.url","https://accounts.salla.com");let n;try{n=new URL(r).origin}catch(e){n="https://accounts.salla.com"}const i=document.createElement("iframe");i.style.display="none",i.src=r;let o=!1,a=!1,s=!1;const u=e=>{o||(o=!0,clearTimeout(l),window.removeEventListener("message",c),i.remove(),!e&&s&&(salla.storage.remove("token"),salla.api.setHeader("Authorization",null)),t(e))};let l=setTimeout(()=>u(!1),e);const c=async function(t){var r,c;if(t.origin!==n||t.source!==i.contentWindow||"login"!==(null==(r=t.data)?void 0:r.source))return;const d=null==(c=t.data.type)?void 0:c.replace("iframe::","");var h;if("ready"===d)return clearTimeout(l),l=setTimeout(()=>u(!1),e),i.contentWindow.postMessage({source:"login",type:"init",data:{id:salla.config.get("store.id"),lang:salla.lang.locale,apiUrl:null==(h=salla.config.get("store.api"))?void 0:h.replace(/\/+$/,"")}},n);if("storage"===d){var p;if(o||a)return;const e=null==(p=t.data.message)?void 0:p.token,r="string"==typeof e?e.replace(/^"|"$/g,""):e;if(!r)return u(!1);a=!0,clearTimeout(l),l=setTimeout(()=>u(!1),8e3);try{var f;salla.auth.event.tokenFetched(r),s=!0;const e=await salla.api.cart.assign().catch(e=>(salla.log("cross-store login: cart assign failed",e),null));if(o)return;if(!salla.auth.api.isSessionless()&&(await salla.auth.api.request("auth/jwt").catch(e=>salla.log("cross-store login: auth/jwt (web session) failed",e)),o))return;if(await salla.auth.event.loggedIn({data:{token:r}}),o)return;if(salla.config.isGuest())return u(!1);const t=salla.config.get("user")||{};t.id&&(salla.api.setHeader("s-user-id",t.id),t.country_code&&salla.api.setHeader("s-country",t.country_code),t.currency_code&&salla.api.setHeader("currency",t.currency_code));const n=null==e||null==(f=e.data)?void 0:f.cart_id;n?(salla.api.cart.latestCart=null,salla.storage.set("cart",Br({},salla.storage.get("cart")||{},{id:n}))):await salla.api.cart.getCurrentCartId(!0,"cross-store-login").catch(e=>salla.log("cross-store login: cart id refresh failed",e)),u(!0)}catch(e){salla.log("Silent cross-store login failed",e),u(!1)}}};window.addEventListener("message",c),document.body.appendChild(i)}):Promise.resolve(!0)}set(e){salla.storage.set("cart",e),salla.api.cart.syncGuestCart()}async offers(){var e=this;return Salla.api.cart._pendingOffersRequest||(Salla.api.cart._pendingOffersRequest=async function(){try{const t=await salla.cart.api.getCurrentCartId(!1,"salla.api.cart.offers");return await e.request(["offers",t]).then(e=>(salla.event.cart.offersFetched(e),e)).catch(e=>{throw salla.event.cart.offersFailed(e),e})}finally{Salla.api.cart._pendingOffersRequest=null}}()),Salla.api.cart._pendingOffersRequest}async getGiftCartDetails(){let e=await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.getGiftCartDetails");return this.request(["giftCartDetails",e]).then(t=>(salla.product.event.giftFetched(t,e),t)).catch(t=>{throw salla.product.event.giftFetchFailed(t,e),t})}async addCartGiftToCart(e,t=!1){let r=await salla.api.cart.getCurrentCartId(!1,"salla.api.cart.addCartGiftToCart");return this.request(["cartGiftToCart",r],e).then(e=>(salla.product.event.addGiftToCartSucceeded(e,r),t&&(window.location.href=e.redirect),e)).catch(e=>{throw salla.product.event.addGiftToCartFailed(e,r),e})}async syncGuestCart(){if(!salla.config.isGuest())return;const e=salla.api.cart.getCartCookiePrefix(),t=salla.cookie.getCookieByPrefix(e),r=salla.storage.get("cart.id");if(!r&&t.length)try{var n;const t=null==(n=(await salla.api.cart.latest()).data)||null==(n=n.cart)?void 0:n.id;t&&salla.api.cart.setCartCookie(e,t)}catch(e){salla.log("Failed to fetch latest cart:",e)}salla.cookie.clearCookieByPrefix(e),r&&(salla.config.set("headers.s-cart-id",r),salla.api.cart.setCartCookie(e,r))}async assign(){var e=this;if(Salla.api.cart._pendingAssignRequest)return Salla.api.cart._pendingAssignRequest;let t=Salla.storage.get("cart.id");return!(!t||Salla.api.cart.guestCartAssigned)&&(Salla.api.cart._pendingAssignRequest=async function(){try{const r=await e.request(["assign",t]);return Salla.api.cart.guestCartAssigned=!0,r}catch(e){throw e}finally{Salla.api.cart._pendingAssignRequest=null}}(),Salla.api.cart._pendingAssignRequest)}setCartCookie(e,t){salla.cookie.set(`${e}-${t}`,t,1)}getCartCookiePrefix(){return"cart-id-"+salla.config.get("store.id")}}class yn extends mn{constructor(){super(),this.namespace="loyalty",this.endpoints={getProgram:"loyalty",exchange:"loyalty/exchange",reset:"loyalty/exchange",loyaltyPoints:"profile/loyalty/points"},this.endpointsMethods={getProgram:"get",reset:"put",loyaltyPoints:"get"},this.after_init()}getPoints(){if(salla.config.isGuest()){let e="Can't get points for guest user, please login to get points";return salla.loyalty.event.loyaltyPointsNotFetched(e),salla.api.errorPromise(e)}if(!this.isFeatureEnabled()){let e="Unable to get loyalty points";return salla.loyalty.event.loyaltyPointsNotFetched(e),salla.api.errorPromise(e)}return this.request("loyaltyPoints").then(e=>(salla.loyalty.event.loyaltyPointsFetched(e),e)).catch(e=>{throw salla.loyalty.event.loyaltyPointsNotFetched(e),e})}isFeatureEnabled(){return(salla.config.get("store.features")||[]).includes("loyalty-system")}getProgram(){if(!this.isFeatureEnabled()){let e="Unable to get loyalty program";return salla.loyalty.event.programNotFetched(e),salla.api.errorPromise(e)}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,r=null){if(!(e=salla.form.getPossibleValue(e,["id","loyalty_prize_id","prize_id"]))){let e="Unable to find prize id. Please provide one.";return salla.loyalty.event.exchangeFailed(e),salla.api.errorPromise(e)}if(!(t=t||await salla.cart.getCurrentCartId(!1,"salla.api.loyalty.exchange"))){let e="Unable to find cart id. Please provide one.";return salla.loyalty.event.exchangeFailed(e),salla.api.errorPromise(e)}const n={loyalty_prize_id:e,cart_id:t};return r&&(n.selected_product_id=r),this.request("exchange",n).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(!1,"salla.api.loyalty.reset"))){let e="Unable to find cart id. Please provide one.";return salla.loyalty.event.resetFailed(e),salla.api.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 Dn extends mn{constructor(){super(),this.namespace="auth",this.canRedirect_=!0,this.afterLoginEvent={event:null,payload:null},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.inIframe=salla.helpers.isIframe(),Salla.event.on("twilight::init",function(){if(Salla.config.isGuest()&&location.href.includes("force_logout"))return delete Salla.api.axios.defaults.headers.common.Authorization,Salla.api.auth.logout("twilight",!1)}),this.after_init()}setAfterLoginEvent(e,t){salla.api.auth.afterLoginEvent={event:e,payload:t}}setCanRedirect(e){salla.api.auth.canRedirect_=e}canRedirect(){return salla.api.auth.canRedirect_&&!salla.api.auth.afterLoginEvent.event}login(e){var t;null!=(t=e)&&t.data&&(e=e.data);let r=salla.form.getPossibleValue(e,["type"]);if(!["email","mobile"].includes(r)){let e="Login type should be in: [email, mobile]";return salla.auth.event.codeNotSent(e),salla.api.errorPromise(e)}return this.request(["login",r],e).then(function(e){return salla.auth.event.codeSent(e,r),e}).catch(function(e){throw salla.auth.event.codeNotSent(e,r),salla.auth.api.trackBlockedError(e,"login"),e})}async verify(e,t=!0){let r=salla.form.getPossibleValue(e,["type"]);if(!r){let e="Failed to know what's login type!";return salla.auth.event.verificationFailed(e),salla.api.errorPromise(e)}t=!1!==salla.form.getPossibleValue(e,["supportWebAuth"])&&t,salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event);let n=await salla.auth.api.request(["verify",r],e);return 200!==(null==n?void 0:n.status)?(salla.auth.event.verificationFailed(n,r),salla.api.errorPromise(n)):salla.auth.api.handlAfterAuthenticatedResponse(n,t)}async handlAfterAuthenticatedResponse(e,t){var r,n;e.data||(e={data:e});let i="authenticated"===(null==(r=e.data)?void 0:r.case);return i&&salla.auth.event.tokenFetched(e.data.token),t&&!this.inIframe&&!this.isSessionless()&&await salla.auth.api.request("auth/jwt",{callerName:"salla.auth.api.handlAfterAuthenticatedResponse"}),i&&await salla.auth.event.loggedIn(e).then(()=>salla.auth.api.afterUserLogin()),await salla.auth.event.verified(e,null==(n=e.data.verification)?void 0:n.type),salla.api.successPromise(e)}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),salla.auth.api.trackBlockedError(t,"resend"),t}):(salla.auth.event.codeNotSent(t="There is no email!",e),salla.api.errorPromise(t)):(salla.auth.event.codeNotSent(t="There is no phone or country_code!",e),salla.api.errorPromise(t))}register(e){var t=this;let r;return e.data&&(r=e.element,e=e.data),salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event),this.request("register",e).then(async function(e){var n;return salla.auth.event.registered.call(r,e),"authenticated"===(null==(n=e.data)?void 0:n.case)&&(salla.auth.event.tokenFetched(e.data.token),!t.inIframe&&!t.isSessionless()&&await salla.auth.request("auth/jwt",{callerName:"salla.auth.api.register"}),salla.auth.event.loggedIn(e),salla.auth.api.afterUserLogin()),e}).catch(function(e){throw salla.auth.event.registrationFailed.call(r,e),salla.auth.api.trackBlockedError(e,"register"),e})}handleIframeReadyAction(e,t){var r;null==(r=e.contentWindow)||r.postMessage({source:"logout",type:"init",data:{id:salla.config.get("store.id"),lang:"ar",appUrl:t,apiUrl:salla.config.get("store.api").replace(/\/+$/,""),settings:salla.config.all(),storage:{}}},"*")}appendIframeAndLogout(){return new Promise(e=>{let t=salla.config.get("login.url","https://accounts.salla.com");const r=document.createElement("iframe");r.style.display="none",r.src=`${t}/logout`;const n=i=>{if("login"!==i.data.source)return;let o=i.data.type.replace("iframe::","");if(salla.log("iframe::logout-iframe message received",i.data),["logged-out","ready"].includes(o)){if("ready"===o)return this.handleIframeReadyAction(r,t);window.removeEventListener("message",n),r.remove(),e()}};window.addEventListener("message",n),document.body.appendChild(r)})}logout(e="twilight",t=!0){return salla.storage.clearAll(),salla.cookie.clearAll(),e=encodeURI(e),salla.auth.event.loggedOut().then(()=>this.appendIframeAndLogout()).then(()=>{if(!t)return;let r=salla.url.get(`logout?from=${e}`);console.log(`Going to ${r}, to do any thing before this action use: salla.auth.even.onLoggedOut(()=>{...})`);try{location.href=r}catch(e){salla.log(e)}}).catch(e=>console.error("Error during logout:",e))}refresh(){return this.request("refresh").then(function(e){return salla.auth.event.tokenFetched(e.data.token),e}).catch(function(e){throw salla.auth.event.refreshFailed(e),e})}requireLoginThen(e,t){if(!salla.config.isGuest())return t();const r=()=>{salla.event.off(e,r),t()};salla.event.on(e,r),salla.api.auth.setAfterLoginEvent(e),salla.auth.event.dispatch("login::open",{withoutReload:!0})}afterUserLogin(){this.afterLoginEvent.event&&salla.event.emit(this.afterLoginEvent.event,this.afterLoginEvent.payload)}isSessionless(){var e;return"sessionless"===(null!=(e=salla.config.get("auth.mode"))?e:salla.config.get("login.mode"))}trackBlockedError(e,t){var r;void 0===(null==e||null==(r=e.response)||null==(r=r.headers)?void 0:r["s-ray"])&&salla.analytics.track("BlockedByProxy",{class:"auth",function:t,reason:"non-server-request",message:e.message})}}class bn extends mn{constructor(){super(),this.namespace="order",this.endpoints={cancel:"orders/cancel/{id}",createCartFromOrder:"reorder/{id}",reorderProduct:"reorder/product/{id}",sendInvoice:"orders/send/{id}",fetch:"orders",details:"orders/{id}",editOrder:"orders/{id}",cancelEditSession:"orders/cancel-edit-session",getBranchDetails:"orders/{id}/pickup"},this.endpointsMethods={createCartFromOrder:"get",fetch:"get",details:"get",editOrder:"put",cancel:"post",cancelEditSession:"post",getBranchDetails:"get"},this.after_init()}show(e){let t=salla.form.getPossibleValue((null==e?void 0:e.data)||e,["id","order_id"]);salla.event.dispatch("mobile::order.placed",{order_id:t}),location.href=salla.form.getPossibleValue((null==e?void 0:e.data)||e,["url"])}cancel(e,t){var r;e=e||Salla.config.get("page.id");const n={params:{has_apple_pay:salla.helpers.hasApplePay()}},i=null==t||null==(r=t.reasons)?void 0:r.filter(e=>null!=e&&""!==e);if(null!=i&&i.length){var o;n.reasons=i.map(String);const e=null==(o=t.reason_note)?void 0:o.trim();e&&(n.reason_note=e)}return this.request(["cancel",e],n).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.cart.reset(),salla.event.order.orderCreated(t,e),window.location.href=t.data.url,t}).catch(function(t){throw salla.event.order.orderCreationFailed(t,e),t})}reorderProduct(e){return e=e||salla.config.get("page.id"),this.request(["reorderProduct",e]).then(function(t){const r=Br({},t.data,{type:"reorder",id:e}),n=Br({},t,{data:r});return salla.event.order.orderCreated(n,t.data.order_id),window.location.href=t.data.url,t}).catch(function(t){throw salla.event.order.orderCreationFailed(t,e),t})}sendInvoice(e){let t=salla.form.getPossibleValue(e,["id"])||salla.config.get("page.id");if(!t){let e="There is no id!";return salla.order.event.invoiceNotSent(e),salla.api.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})}editOrder(e,t){return e=e||salla.config.get("page.id"),this.request(["editOrder",e],t).then(function(t){return salla.event.order.orderEdited(t,e),t}).catch(function(t){throw salla.event.order.orderNotEdited(t,e),t})}cancelEditSession(e){return this.request(["cancelEditSession"],{order_id:e}).then(function(t){return salla.event.order.editSessionCanceled(t,e),t}).catch(function(t){throw salla.event.order.editSessionNotCanceled(t,e),t})}fetch(e){return this.request(["fetch"],{params:e}).then(function(e){return salla.event.order.ordersFetched(e),e}).catch(function(e){throw salla.event.order.ordersNotFetched(e),e})}getDetails(e){if(!(e=e||salla.config.get("page.id"))){let e="There is no order id!";return salla.event.order.detailsNotFetched(e),salla.api.errorPromise(e)}return this.request(["details",e],null,"get").then(function(t){return salla.event.order.detailsFetched(t,e),t}).catch(function(t){throw salla.event.order.detailsNotFetched(t,e),t})}getBranchDetails(e){if(!(e=e||salla.config.get("page.id"))){let e="There is no order id!";return salla.event.order.branchDetailsNotFetched(e),salla.api.errorPromise(e)}return this.request(["getBranchDetails",e],null,"get").then(function(t){return salla.event.order.branchDetailsFetched(t,e),t}).catch(function(t){throw salla.event.order.branchDetailsNotFetched(t,e),t})}}class Fn extends mn{constructor(){super(),this.namespace="product",this.previousQuery="",this.endpoints={getPrice:"products/{id}/price",availabilitySubscribe:"products/{id}/availability-notify",search:"products/search",details:"products/{product_id}/details",categories:"products/categories/{?id}",offers:"products/{product_id}/specialoffer",getSizeGuides:"products/{prod_id}/size-guides",giftProductDetails:"products/{product_id}/buy-as-gift",productGiftToCart:"products/{product_id}/buy-as-gift",giftImage:"products/buy-as-gift/image",buyNow:"products/{product_id}/buy-now",fetch:"products",fetchOptions:"products/options",getOrderOptions:"product/order-options"},this.endpointsMethods={details:"get",giftProductDetails:"get",fetch:"get",offers:"get",fetchOptions:"get",getOrderOptions:"get"},this.after_init()}getPrice(e){let t=e.data||e,r=salla.form.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=salla.form.getPossibleValue(t,["id","prod_id"]),this.request(["availabilitySubscribe",e],"object"==typeof t?t:void 0).then(t=>(this.updateAvailabilityStorage(e),salla.product.event.availabilitySubscribed(t,e),t)).catch(function(t){throw salla.product.event.availabilitySubscribeFailed(t,e),t})}updateAvailabilityStorage(e){let t=salla.storage.get("salla::availability",[]);t.includes(Number(e))||(t.push(Number(e)),salla.storage.set("salla::availability",t))}isSubscribedToAvailability(e){return salla.storage.get("salla::availability",[]).includes(Number(e))||!!salla.storage.get(`product-${e}-subscribed`)}getAvailabilityChannels(){let e=salla.config.get("store.settings.product.availability_notify");if(!e)return"";let t=[];return e.email&&t.push("email"),(e.sms||e.mobile||e.whatsapp)&&t.push("sms"),t.join(",")}search(e){var t;let r=e.data;if(r||(r={params:"string"==typeof e?{query:e}:e}),!(e=r instanceof FormData?r.get("query"):r.query||(null==(t=r.params)?void 0:t.query))){let e='There is no "query"!';return salla.product.event.searchFailed(e),salla.api.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,salla.api.errorPromise(e)}return salla.api.product.previousQuery=e,this.request("search",r,"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){var t;if(!(e=salla.form.getPossibleValue((null==(t=e)?void 0:t.data)|e,["product_id","id"]))){let e='There is no "product_id"!';return salla.product.event.fetchOffersFailed(e),salla.api.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.fetchOffersFailed(t,e),t})}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})}getGiftProductDetails(e){return this.request(["giftProductDetails",e]).then(t=>(salla.product.event.giftFetched(t,e),t)).catch(t=>{throw salla.product.event.giftFetchFailed(t,e),t})}getDetails(e,t=[]){if(!Array.isArray(t)){let e="withItems should be array.";return salla.product.event.detailFetchFailed(e),salla.api.errorPromise(e)}if(!e){let e="productId is not passed.";return salla.product.event.detailFetchFailed(e),salla.api.errorPromise(e)}return this.request(["details",e],{params:{with:t}}).then(function(t){return salla.product.event.detailFetched(t,e),t}).catch(function(t){throw salla.product.event.availabilitySubscribeFailed(t,e),t})}addProductGiftToCart(e,t,r=!1){return this.request(["productGiftToCart",e],t).then(t=>(salla.product.event.addGiftToCartSucceeded(t,e),r&&(window.location.href=t.redirect),t)).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})}fetch(e){if(!e.source){const e="Source cannot be empty. Please provide one.";return salla.product.event.productListFetchFailed(e),salla.api.errorPromise(e)}const t=!e.source_value,r="string"==typeof e.source_value&&"[]"===e.source_value,n=Array.isArray(e.source_value)&&!e.source_value.length;if((t||r||n)&&!["offers","latest","sales","wishlist","top-rated","reorder"].includes(e.source)){const e="Source value cannot be empty. Please provide one.";return salla.product.event.productListFetchFailed(e),salla.api.errorPromise(e)}if(["categories","brands","tags","selected"].includes(e.source)&&!Array.isArray(e.source_value)){const e="SourceValue type error. Expected an array.";return salla.product.event.productListFetchFailed(e),salla.api.errorPromise(e)}if("search"===e.source&&"string"!=typeof e.source_value){const e="SourceValue type error. Expected a string.";return salla.product.event.productListFetchFailed(e),salla.api.errorPromise(e)}if("related"===e.source&&isNaN(e.source_value)){const e="SourceValue type error. Expected a number.";return salla.product.event.productListFetchFailed(e),salla.api.errorPromise(e)}return Salla.api.withoutNotifier(()=>this.request(this.endpoints.fetch,{params:e},"get").then(async function(e){return salla.product.event.productListFetchSucceeded(e),e}).catch(e=>{throw salla.product.event.productListFetchFailed(e),e}))}getOrderOptions(e){return this.request(this.endpoints.getOrderOptions,{params:{products:e}},"get")}fetchOptions(e,t={}){if(!e||0===e.length){const e="At least one product ID is required. Please provide a valid list of product IDs.";return salla.product.event.productOptionsNotFetched(e),salla.api.errorPromise(e)}const{with:r=[]}=t,n={selected:e};return r.length>0&&(n.with=r),this.request(this.endpoints.fetchOptions,{params:n},"get").then(e=>(salla.product.event.productOptionsFetched(e),e)).catch(e=>{throw salla.product.event.productOptionsNotFetched(e),e})}}class wn extends mn{constructor(){super(),this.namespace="profile",this.endpoints={info:"auth/user",fields:"profile/fields",update:"profile/update",updateContacts:"profile/contacts/update",updateCustomFields:"profile/fields",updateSettings:"profile/settings",verify:"profile/verify",delete:"profile"},this.endpointsMethods={delete:"delete"},this.after_init()}syncUserData(e){if(!e||!e.phone)return;let t={id:e.id,type:"user",email:e.email,mobile:e.phone.code+e.phone.number,country_code:e.phone.country,language_code:e.language,currency_code:e.currency,notifications:e.notifications,pending_orders:e.pending_orders,avatar:e.avatar,first_name:e.first_name,last_name:e.last_name,is_hidden_name:e.is_hidden_name,is_notifiable:e.is_notifiable,can_comment:salla.config.get("user.can_comment"),fetched_at:Date.now()};salla.config.set("user",t),salla.storage.set("user",t)}info(){return this.request("info",null,"get").then(e=>(this.syncUserData(e.data),salla.profile.event.infoFetched(e),e)).catch(e=>{throw salla.profile.event.infoNotFetched(e),e})}getFields(){return this.request("fields",null,"get").then(e=>e.data).catch(e=>(console.debug("[profile.getFields] Failed:",e),[]))}update(e){if(Salla.config.get("store.features",[]).includes("sso-login")){const e="SSO login is enabled. You cannot update your profile.";return Salla.error(e),Promise.reject(new Error(e))}return this.request("update",e).then(e=>(this.syncUserData(e.data),salla.profile.event.updated(e),e)).catch(e=>{throw salla.event.profile.updateFailed(e),e})}updateCustomFields(e){if(Salla.config.get("store.features",[]).includes("sso-login")){const e="SSO login is enabled. You cannot update your profile.";return Salla.error(e),Promise.reject(new Error(e))}return this.request("updateCustomFields",e).then(e=>(this.syncUserData(e.data),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})}updateSettings(e){return this.request("updateSettings",e).then(e=>(salla.event.profile.settingsUpdated(e),e)).catch(e=>{throw salla.event.profile.updateSettingsFailed(e),e})}delete(){return this.request("delete").then(e=>(salla.storage.clearAll(),salla.cookie.clearAll(),salla.auth.api.appendIframeAndLogout().then(()=>{salla.event.profile.deleted(e),window.location.href=salla.url.get("logout")}),e)).catch(e=>{throw salla.event.profile.notDeleted(e),e})}}class En extends mn{constructor(){super(),this.namespace="comment",this.endpoints={addComment:"{type}/{id}/comments",comments:"/comments"},this.after_init()}add(e){var t;if(null!=(t=e)&&t.data&&(e=e.data),"string"==typeof(e=this.getCommentPayload(e,!0)))return salla.event.comment.additionFailed(e),salla.api.errorPromise(e);if(!e.comment){let e="can't find comment content!";return salla.event.comment.additionFailed(e),salla.api.errorPromise(e)}return this.request(["addComment",["blog","blogs"].includes(e.type)?"blog/articles":e.type,e.id],{comment:e.comment}).then(function(t){return salla.event.comment.added(t,e.id),t}).catch(function(t){throw salla.event.comment.additionFailed(t,e.id),t})}getCommentPayload(e,t=!1){let r={};if(["id","type","comment","per_page","page","sort"].forEach(t=>{let n=salla.form.getPossibleValue(e,[t]);n&&(r[t]=n)}),!t){let t=e.ids;if(t&&(r.ids=Array.isArray(t)?t:[t]),!r.ids||!r.ids.length)return"Failed to get ids!"}return r.type&&["products","pages","product","page","blogs","blog"].includes(r.type)?(r.type+=["product","page"].includes(r.type)?"s":"",r):"Failed to get type one of:(products, product, page, pages, blog, blogs)!"}fetchComments(e){const t=e.customerId;if("string"==typeof(e=this.getCommentPayload(e)))return salla.event.comment.fetchFailed(e),salla.api.errorPromise(e);const r={per_page:e.per_page||5,page:e.page||1,type:e.type,ids:e.ids};return e.sort&&(r.sort=e.sort),t&&(r.private_comments=t),this.request(["comments"],{params:r},"get").then(function(t){return salla.event.comment.fetched(t,e),t}).catch(function(t){throw salla.event.comment.fetchFailed(t,e),t})}getComments(e,t,r=1,n=5,i,o=null){const a=Array.isArray(t)?t:[t];return this.fetchComments({ids:a,type:`${e}s`,page:r,per_page:n,sort:i,customerId:o})}}class Sn extends mn{constructor(){super(),this.namespace="currency",this.endpoints={change:"/",list:"currencies"},this.endpointsMethods={change:"get",list:"get"},this.webEndpoints=["change"],this.after_init()}change(e){if(!(e=salla.form.getPossibleValue(e.data||e,["currency","code"]))){let e="Can't find currency code!";return salla.currency.event.failed(e),salla.api.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 _n extends mn{constructor(){super(),this.namespace="document"}reload(){window.location.reload()}}class An extends mn{constructor(){super(),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=salla.form.getPossibleValue((null==e?void 0:e.data)||e,["order_id","id"]);if(!r){let e='There is no "order_id"!';return salla.event.rating.orderNotFetched(e),salla.api.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){var t;if(!(e=(null==(t=e)?void 0:t.data)||e)){let e='There is no "data"!';return salla.event.rating.storeFailed(e),salla.api.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){var t;if(!(e=(null==(t=e)?void 0:t.data)||e)){let e='There is no "data"!';return salla.event.rating.productsFailed(e),salla.api.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){var t;if(!(e=(null==(t=e)?void 0:t.data)||e)){let e='There is no "data"!';return salla.event.rating.shippingFailed(e),salla.api.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})}}const Cn="salla::wishlist-hydrated-user";class kn extends mn{constructor(){super(),this.namespace="wishlist",this.syncStorageFromServerPromise=null,this.endpoints={add:"products/favorites/{id}",remove:"products/favorites/{id}",share:"products/favorites/share"},this.endpointsMethods={remove:"delete"},Salla.onReady(()=>{var e;"customer.wishlist"===Salla.config.get("page.slug")&&(null!=(e=Salla.storage.getWithTTL("s-utms"))&&e["s-utm-source"]||this.injectSourceIntoRequest())}),salla.event.on("api::initiated",()=>this.syncStorageFromServer())}injectSourceIntoRequest(){Salla.api.axios.interceptors.request.use(e=>(e.headers=Br({},e.headers,{"s-utm-source":"wishlist"}),e),e=>Promise.reject(e))}getWishlistIds(){const e=salla.storage.get("salla::wishlist",[]);return Array.isArray(e)?e.filter(e=>"number"==typeof e):[]}has(e){return this.getWishlistIds().includes(Number(e))}async syncStorageFromServer(){const e=salla.config.get("user.id")||salla.storage.get("user.id"),t=salla.config.get("store.id"),r=e&&null!=t&&""!==t?`${t}--${e}`:null;return salla.config.isGuest()||!r?Promise.resolve():salla.storage.get(Cn)===r?this.notifyStorageSynced():(this.syncStorageFromServerPromise||(this.syncStorageFromServerPromise=this.request("products/favorites",void 0,"get").then(e=>{var t,n,i;const o=null!=(t=null!=(n=null==e||null==(i=e.data)?void 0:i.data)?n:null==e?void 0:e.data)?t:e,a=[...new Set((Array.isArray(o)?o:[]).map(e=>{var t,r;return null!=(t=null==e||null==(r=e.product)?void 0:r.id)?t:null==e?void 0:e.id}).filter(e=>"number"==typeof e))];return salla.storage.set("salla::wishlist",a),salla.storage.set(Cn,r),this.notifyStorageSynced()}).catch(e=>{const t=(null==e?void 0:e.code)||(null==e?void 0:e.name)||"";["ERR_CANCELED","CanceledError","AbortError"].includes(t)||salla.log("Wishlist hydration failed",e)}).finally(()=>{this.syncStorageFromServerPromise=null})),this.syncStorageFromServerPromise)}notifyStorageSynced(){return new Promise(e=>{queueMicrotask(()=>{salla.event.emit("wishlist::storage.synced"),e()})})}toggle(e){return this.has(e)?this.remove(e):this.add(e)}async add(e){var t;try{const t={preventDefault:!1,product_id:e};if(await Salla.wishlist.event.beforeAddItem(t),t.preventDefault)return}catch(r){}let r;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(r=salla.lang.get("common.messages.must_login")),salla.error(r),salla.api.errorPromise(r)):(e=salla.form.getPossibleValue((null==(t=e)?void 0:t.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(r="Failed to get product id!"),salla.api.errorPromise(r))}async remove(e){var t;try{const t={preventDefault:!1,product_id:e};if(await Salla.wishlist.event.beforeRemoveItem(t),t.preventDefault)return}catch(r){}let r;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(r=salla.lang.get("common.messages.must_login")),salla.error(r),salla.api.errorPromise(r)):(e=salla.form.getPossibleValue((null==(t=e)?void 0:t.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(r="Failed to get id!"),salla.api.errorPromise(r))}async share(e,t=!1){try{const r={preventDefault:!1,select_all:t,product_ids:e};if(await Salla.wishlist.event.beforeShare(r),r.preventDefault)return;t=r.select_all,e=r.product_ids}catch(r){}let r;return salla.config.isGuest()?(salla.wishlist.event.sharingFailed(r=salla.lang.get("common.messages.must_login")),salla.error(r),salla.api.errorPromise(r)):(Array.isArray(e)||(e=[]),t||e.length?this.request("share",{select_all:t,product_ids:e}).then(t=>(salla.wishlist.event.shared(t,e),t)).catch(function(t){throw salla.wishlist.event.sharingFailed(t,e),t}):(salla.wishlist.event.sharingFailed(r="No products selected to share!"),salla.api.errorPromise(r)))}updateWishlistStorage(e,t=!0){let r=this.getWishlistIds();t?r.includes(Number(e))||r.push(Number(e)):r=r.filter(t=>Number(t)!==Number(e)),salla.storage.set("salla::wishlist",r)}}class xn extends mn{constructor(){super(),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),e})}}class Pn extends mn{constructor(){super(),this.namespace="booking",this.endpoints={add:"cart/booking/product/{id}"},this.endpointsMethods={add:"get"}}async add(e,t=!0){if(!e){let e="Please provide product id.";return salla.booking.event.additionFailed(e),salla.api.errorPromise(e)}return this.request(["add",e]).then(function(e){return salla.booking.event.added(e),t&&"booking"===e.data.redirect.to&&(window.location.href=e.data.redirect.url),e}).catch(function(e){throw salla.booking.event.additionFailed(e),e})}}class In extends mn{constructor(){super(),this.namespace="landing",this.endpoints={getDetails:"landing/{landing_page_id}",createCartFromPage:"landing/{landing_page_id}",breadcrumbs:"breadcrumbs"},this.endpointsMethods={getDetails:"get",breadcrumbs:"get"},this.after_init()}getDetails(e){if(!e){let e="page landing id not passed";return salla.event.landing.getDetailsFailed(e),salla.api.errorPromise(e)}return this.request(["getDetails",e]).then(function(t){return salla.event.landing.detailsFetched(t,e),t}).catch(function(t){throw salla.event.landing.getDetailsFailed(t,e),t})}createCartFromPage(e){if(!e){let e="page landing id not passed";return salla.event.landing.orderCreationFailed(e),salla.api.errorPromise(e)}return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("landing::createCartFromPage",e),salla.event.dispatch("login::open"),salla.api.successPromise("")):this.request(["createCartFromPage",e]).then(function(t){return salla.event.landing.orderCreated(t,e).then(()=>location.href=t.data.url),t}).catch(function(t){throw salla.event.landing.orderCreationFailed(t,e),t})}fetchBreadcrumbs(e){if(!e.page){let e="The 'page' parameter is required for the Breadcrumb API. Please provide a valid 'page' parameter.";return salla.event.landing.breadcrumbFetchFailed(e),salla.api.errorPromise(e)}if("product.single"===e.page&&!e.id&&!e.parent_id){let e="The 'id' and 'parent_id' parameters are required when the 'page' parameter is set to 'product.single'. Please provide valid values for both parameters.";return salla.event.landing.breadcrumbFetchFailed(e),salla.api.errorPromise(e)}if(["product.index","customer.orders.single","product.index.tag","page-single","landing-page","brands.single","blog.single","blog.index.author","blog.index.category","blog.index.tag"].includes(e.page)&&!e.id){let t=`The 'id' parameter is required when the 'page' parameter is set to ${e.page}. Please provide valid value for the 'ID' parameter.`;return salla.event.landing.breadcrumbFetchFailed(t),salla.api.errorPromise(t)}return this.request("breadcrumbs",{params:e}).then(function(e){return salla.event.landing.breadcrumbFetched(e),e}).catch(function(e){throw salla.event.landing.breadcrumbFetchFailed(e),e})}}class On extends mn{constructor(){super(),this.namespace="notifications",this.endpoints={fetch:"notifications"},this.endpointsMethods={fetch:"get"},this.after_init()}fetch(e){return this.request(["fetch"],{params:e}).then(function(e){return salla.event.notifications.fetched(e),e}).catch(function(e){throw salla.event.notifications.fetchFailed(e),e})}}function Bn(e,t){return function(){return e.apply(t,arguments)}}const{toString:jn}=Object.prototype,{getPrototypeOf:Tn}=Object,{iterator:Rn,toStringTag:Ln}=Symbol,Nn=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),Un=(e,t)=>{let r=e;const n=[];for(;null!=r&&r!==Object.prototype;){if(-1!==n.indexOf(r))return!1;if(n.push(r),Nn(r,t))return!0;r=Tn(r)}return!1},qn=(zn=Object.create(null),e=>{const t=jn.call(e);return zn[t]||(zn[t]=t.slice(8,-1).toLowerCase())});var zn;const $n=e=>(e=e.toLowerCase(),t=>qn(t)===e),Mn=e=>t=>typeof t===e,{isArray:Hn}=Array,Wn=Mn("undefined");function Gn(e){return null!==e&&!Wn(e)&&null!==e.constructor&&!Wn(e.constructor)&&Kn(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Jn=$n("ArrayBuffer");const Vn=Mn("string"),Kn=Mn("function"),Qn=Mn("number"),Xn=e=>null!==e&&"object"==typeof e,Yn=e=>{if(!Xn(e))return!1;const t=Tn(e);return!(null!==t&&t!==Object.prototype&&null!==Tn(t)||Un(e,Ln)||Un(e,Rn))},Zn=$n("Date"),ei=$n("File"),ti=$n("Blob"),ri=$n("FileList");const ni="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},ii=void 0!==ni.FormData?ni.FormData:void 0,oi=$n("URLSearchParams"),[ai,si,ui,li]=["ReadableStream","Request","Response","Headers"].map($n);function ci(e,t,{allOwnKeys:r=!1}={}){if(null==e)return;let n,i;if("object"!=typeof e&&(e=[e]),Hn(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(Gn(e))return;const i=r?Object.getOwnPropertyNames(e):Object.keys(e),o=i.length;let a;for(n=0;n<o;n++)a=i[n],t.call(null,e[a],a,e)}}function di(e,t){if(Gn(e))return null;t=t.toLowerCase();const r=Object.keys(e);let n,i=r.length;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}const hi="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,pi=e=>!Wn(e)&&e!==hi;const fi=(gi="undefined"!=typeof Uint8Array&&Tn(Uint8Array),e=>gi&&e instanceof gi);var gi;const mi=$n("HTMLFormElement"),{propertyIsEnumerable:vi}=Object.prototype,yi=$n("RegExp"),Di=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};ci(r,(r,i)=>{let o;!1!==(o=t(r,i,e))&&(n[i]=o||r)}),Object.defineProperties(e,n)};const bi=$n("AsyncFunction"),Fi=(wi="function"==typeof setImmediate,Ei=Kn(hi.postMessage),wi?setImmediate:Ei?(Si=`axios@${Math.random()}`,_i=[],hi.addEventListener("message",({source:e,data:t})=>{e===hi&&t===Si&&_i.length&&_i.shift()()},!1),e=>{_i.push(e),hi.postMessage(Si,"*")}):e=>setTimeout(e));var wi,Ei,Si,_i;const Ai="undefined"!=typeof queueMicrotask?queueMicrotask.bind(hi):"undefined"!=typeof process&&process.nextTick||Fi,Ci=e=>null!=e&&Kn(e[Rn]);var ki={isArray:Hn,isArrayBuffer:Jn,isBuffer:Gn,isFormData:e=>{if(!e)return!1;if(ii&&e instanceof ii)return!0;const t=Tn(e);if(!t||t===Object.prototype)return!1;if(!Kn(e.append))return!1;const r=qn(e);return"formdata"===r||"object"===r&&Kn(e.toString)&&"[object FormData]"===e.toString()},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Jn(e.buffer),t},isString:Vn,isNumber:Qn,isBoolean:e=>!0===e||!1===e,isObject:Xn,isPlainObject:Yn,isEmptyObject:e=>{if(!Xn(e)||Gn(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:ai,isRequest:si,isResponse:ui,isHeaders:li,isUndefined:Wn,isDate:Zn,isFile:ei,isReactNativeBlob:e=>!(!e||void 0===e.uri),isReactNative:e=>e&&void 0!==e.getParts,isBlob:ti,isRegExp:yi,isFunction:Kn,isStream:e=>Xn(e)&&Kn(e.pipe),isURLSearchParams:oi,isTypedArray:fi,isFileList:ri,forEach:ci,merge:function e(...t){const{caseless:r,skipUndefined:n}=pi(this)&&this||{},i={},o=(t,o)=>{if("__proto__"===o||"constructor"===o||"prototype"===o)return;const a=r&&"string"==typeof o&&di(i,o)||o,s=Nn(i,a)?i[a]:void 0;Yn(s)&&Yn(t)?i[a]=e(s,t):Yn(t)?i[a]=e({},t):Hn(t)?i[a]=t.slice():n&&Wn(t)||(i[a]=t)};for(let e=0,r=t.length;e<r;e++){const r=t[e];if(!r||Gn(r))continue;if(ci(r,o),"object"!=typeof r||Hn(r))continue;const n=Object.getOwnPropertySymbols(r);for(let e=0;e<n.length;e++){const t=n[e];vi.call(r,t)&&o(r[t],t)}}return i},extend:(e,t,r,{allOwnKeys:n}={})=>(ci(t,(t,n)=>{r&&Kn(t)?Object.defineProperty(e,n,{__proto__:null,value:Bn(t,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,n,{__proto__:null,value:t,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),Object.defineProperty(e.prototype,"constructor",{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{__proto__:null,value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:(e,t,r,n)=>{let i,o,a;const s={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),o=i.length;o-- >0;)a=i[o],n&&!n(a,e,t)||s[a]||(t[a]=e[a],s[a]=!0);e=!1!==r&&Tn(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:qn,kindOfTest:$n,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return-1!==n&&n===r},toArray:e=>{if(!e)return null;if(Hn(e))return e;let t=e.length;if(!Qn(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{const r=(e&&e[Rn]).call(e);let n;for(;(n=r.next())&&!n.done;){const r=n.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{let r;const n=[];for(;null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:mi,hasOwnProperty:Nn,hasOwnProp:Nn,hasOwnInPrototypeChain:Un,getSafeProp:(e,t)=>null!=e&&Un(e,t)?e[t]:void 0,reduceDescriptors:Di,freezeMethods:e=>{Di(e,(t,r)=>{if(Kn(e)&&["arguments","caller","callee"].includes(r))return!1;const n=e[r];Kn(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))})},toObjectSet:(e,t)=>{const r={},n=e=>{e.forEach(e=>{r[e]=!0})};return Hn(e)?n(e):n(String(e).split(t)),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,r){return t.toUpperCase()+r}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:di,global:hi,isContextDefined:pi,isSpecCompliantForm:function(e){return!!(e&&Kn(e.append)&&"FormData"===e[Ln]&&e[Rn])},toJSONObject:e=>{const t=new WeakSet,r=e=>{if(Xn(e)){if(t.has(e))return;if(Gn(e))return e;if(!("toJSON"in e)){t.add(e);const n=Hn(e)?[]:{};return ci(e,(e,t)=>{const i=r(e);!Wn(i)&&(n[t]=i)}),t.delete(e),n}}return e};return r(e)},isAsyncFn:bi,isThenable:e=>e&&(Xn(e)||Kn(e))&&Kn(e.then)&&Kn(e.catch),setImmediate:Fi,asap:Ai,isIterable:Ci,isSafeIterable:e=>null!=e&&Un(e,Rn)&&Ci(e)};const xi=ki.toObjectSet(["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"]);const Pi=new RegExp("[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+","g"),Ii=new RegExp("[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+","g");function Oi(e,t){return ki.isArray(e)?e.map(e=>Oi(e,t)):function(e){let t=0,r=e.length;for(;t<r;){const r=e.charCodeAt(t);if(9!==r&&32!==r)break;t+=1}for(;r>t;){const t=e.charCodeAt(r-1);if(9!==t&&32!==t)break;r-=1}return 0===t&&r===e.length?e:e.slice(t,r)}(String(e).replace(t,""))}function Bi(e){const t=Object.create(null);return ki.forEach(e.toJSON(),(e,r)=>{t[r]=(e=>Oi(e,Ii))(e)}),t}const ji=Symbol("internals");function Ti(e){return e&&String(e).trim().toLowerCase()}function Ri(e){return!1===e||null==e?e:ki.isArray(e)?e.map(Ri):(e=>Oi(e,Pi))(String(e))}function Li(e,t,r,n,i){return ki.isFunction(n)?n.call(this,t,r):(i&&(t=r),ki.isString(t)?ki.isString(n)?-1!==t.indexOf(n):ki.isRegExp(n)?n.test(t):void 0:void 0)}let Ni=class{constructor(e){e&&this.set(e)}set(e,t,r){const n=this;function i(e,t,r){const i=Ti(t);if(!i)return;const o=ki.findKey(n,i);(!o||void 0===n[o]||!0===r||void 0===r&&!1!==n[o])&&(n[o||t]=Ri(e))}const o=(e,t)=>ki.forEach(e,(e,r)=>i(e,r,t));if(ki.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(ki.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))o((e=>{const t={};let r,n,i;return e&&e.split("\n").forEach(function(e){i=e.indexOf(":"),r=e.substring(0,i).trim().toLowerCase(),n=e.substring(i+1).trim(),!r||t[r]&&xi[r]||("set-cookie"===r?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t})(e),t);else if(ki.isObject(e)&&ki.isSafeIterable(e)){let r,n,i=Object.create(null);for(const t of e){if(!ki.isArray(t))throw new TypeError("Object iterator must return a key-value pair");n=t[0],ki.hasOwnProp(i,n)?(r=i[n],i[n]=ki.isArray(r)?[...r,t[1]]:[r,t[1]]):i[n]=t[1]}o(i,t)}else null!=e&&i(t,e,r);return this}get(e,t){if(e=Ti(e)){const r=ki.findKey(this,e);if(r){const e=this[r];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}(e);if(ki.isFunction(t))return t.call(this,e,r);if(ki.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Ti(e)){const r=ki.findKey(this,e);return!(!r||void 0===this[r]||t&&!Li(0,this[r],r,t))}return!1}delete(e,t){const r=this;let n=!1;function i(e){if(e=Ti(e)){const i=ki.findKey(r,e);!i||t&&!Li(0,r[i],i,t)||(delete r[i],n=!0)}}return ki.isArray(e)?e.forEach(i):i(e),n}clear(e){const t=Object.keys(this);let r=t.length,n=!1;for(;r--;){const i=t[r];e&&!Li(0,this[i],i,e,!0)||(delete this[i],n=!0)}return n}normalize(e){const t=this,r={};return ki.forEach(this,(n,i)=>{const o=ki.findKey(r,i);if(o)return t[o]=Ri(n),void delete t[i];const a=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,r)=>t.toUpperCase()+r)}(i):String(i).trim();a!==i&&delete t[i],t[a]=Ri(n),r[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return ki.forEach(this,(r,n)=>{null!=r&&!1!==r&&(t[n]=e&&ki.isArray(r)?r.join(", "):r)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach(e=>r.set(e)),r}static accessor(e){const t=(this[ji]=this[ji]={accessors:{}}).accessors,r=this.prototype;function n(e){const n=Ti(e);t[n]||(!function(e,t){const r=ki.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{__proto__:null,value:function(e,r,i){return this[n].call(this,t,e,r,i)},configurable:!0})})}(r,e),t[n]=!0)}return ki.isArray(e)?e.forEach(n):n(e),this}};Ni.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),ki.reduceDescriptors(Ni.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[r]=e}}}),ki.freezeMethods(Ni);function Ui(e,t){const r=new Set(t.map(e=>String(e).toLowerCase())),n=[],i=e=>{if(null===e||"object"!=typeof e)return e;if(ki.isBuffer(e))return e;if(-1!==n.indexOf(e))return;let t;if(e instanceof Ni&&(e=e.toJSON()),n.push(e),ki.isArray(e))t=[],e.forEach((e,r)=>{const n=i(e);ki.isUndefined(n)||(t[r]=n)});else{if(!ki.isPlainObject(e)&&function(e){if(ki.hasOwnProp(e,"toJSON"))return!0;let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype;){if(ki.hasOwnProp(t,"toJSON"))return!0;t=Object.getPrototypeOf(t)}return!1}(e))return n.pop(),e;t=Object.create(null);for(const[n,o]of Object.entries(e)){const e=r.has(n.toLowerCase())?"[REDACTED ****]":i(o);ki.isUndefined(e)||(t[n]=e)}}return n.pop(),t};return i(e)}let qi=class e extends Error{static from(t,r,n,i,o,a){const s=new e(t.message,r||t.code,n,i,o);return Object.defineProperty(s,"cause",{__proto__:null,value:t,writable:!0,enumerable:!1,configurable:!0}),s.name=t.name,null!=t.status&&null==s.status&&(s.status=t.status),a&&Object.assign(s,a),s}constructor(e,t,r,n,i){super(e),Object.defineProperty(this,"message",{__proto__:null,value:e,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status)}toJSON(){const e=this.config,t=e&&ki.hasOwnProp(e,"redact")?e.redact:void 0,r=ki.isArray(t)&&t.length>0?Ui(e,t):ki.toJSONObject(e);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:r,code:this.code,status:this.status}}};qi.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",qi.ERR_BAD_OPTION="ERR_BAD_OPTION",qi.ECONNABORTED="ECONNABORTED",qi.ETIMEDOUT="ETIMEDOUT",qi.ECONNREFUSED="ECONNREFUSED",qi.ERR_NETWORK="ERR_NETWORK",qi.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",qi.ERR_DEPRECATED="ERR_DEPRECATED",qi.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",qi.ERR_BAD_REQUEST="ERR_BAD_REQUEST",qi.ERR_CANCELED="ERR_CANCELED",qi.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",qi.ERR_INVALID_URL="ERR_INVALID_URL",qi.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";function zi(e){return ki.isPlainObject(e)||ki.isArray(e)}function $i(e){return ki.endsWith(e,"[]")?e.slice(0,-2):e}function Mi(e,t,r){return e?e.concat(t).map(function(e,t){return e=$i(e),!r&&t?"["+e+"]":e}).join(r?".":""):t}const Hi=ki.toFlatObject(ki,{},null,function(e){return/^is[A-Z]/.test(e)});function Wi(e,t,r){if(!ki.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(r=ki.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!ki.isUndefined(t[e])})).metaTokens,i=r.visitor||p,o=r.dots,a=r.indexes,s=r.Blob||"undefined"!=typeof Blob&&Blob,u=void 0===r.maxDepth?100:r.maxDepth,l=s&&ki.isSpecCompliantForm(t),c=[];if(!ki.isFunction(i))throw new TypeError("visitor must be a function");function d(e){if(null===e)return"";if(ki.isDate(e))return e.toISOString();if(ki.isBoolean(e))return e.toString();if(!l&&ki.isBlob(e))throw new qi("Blob is not supported. Use a Buffer instead.");if(ki.isArrayBuffer(e)||ki.isTypedArray(e)){if(l&&"function"==typeof s)return new s([e]);if("undefined"!=typeof Buffer)return Buffer.from(e);throw new qi("Blob is not supported. Use a Buffer instead.",qi.ERR_NOT_SUPPORT)}return e}function h(e){if(e>u)throw new qi("Object is too deeply nested ("+e+" levels). Max depth: "+u,qi.ERR_FORM_DATA_DEPTH_EXCEEDED)}function p(e,r,i){let s=e;if(ki.isReactNative(t)&&ki.isReactNativeBlob(e))return t.append(Mi(i,r,o),d(e)),!1;if(e&&!i&&"object"==typeof e)if(ki.endsWith(r,"{}"))r=n?r:r.slice(0,-2),e=function(e,t){if(u===1/0)return JSON.stringify(e);const r=[];return JSON.stringify(e,function(e,n){if(!ki.isObject(n))return n;for(;r.length&&r[r.length-1]!==this;)r.pop();return r.push(n),h(t+r.length-1),n})}(e,1);else if(ki.isArray(e)&&function(e){return ki.isArray(e)&&!e.some(zi)}(e)||(ki.isFileList(e)||ki.endsWith(r,"[]"))&&(s=ki.toArray(e)))return r=$i(r),s.forEach(function(e,n){!ki.isUndefined(e)&&null!==e&&t.append(!0===a?Mi([r],n,o):null===a?r:r+"[]",d(e))}),!1;return!!zi(e)||(t.append(Mi(i,r,o),d(e)),!1)}const f=Object.assign(Hi,{defaultVisitor:p,convertValue:d,isVisitable:zi});if(!ki.isObject(e))throw new TypeError("data must be an object");return function e(r,n,o=0){if(!ki.isUndefined(r)){if(h(o),-1!==c.indexOf(r))throw new Error("Circular reference detected in "+n.join("."));c.push(r),ki.forEach(r,function(r,a){!0===(!(ki.isUndefined(r)||null===r)&&i.call(t,r,ki.isString(a)?a.trim():a,n,f))&&e(r,n?n.concat(a):[a],o+1)}),c.pop()}}(e),t}function Gi(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(e).replace(/[!'()~]|%20/g,function(e){return t[e]})}function Ji(e,t){this._pairs=[],e&&Wi(e,this,t)}const Vi=Ji.prototype;function Ki(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Qi(e,t,r){if(!t)return e;e=e||"";const n=ki.isFunction(r)?{serialize:r}:r,i=ki.getSafeProp(n,"encode")||Ki,o=ki.getSafeProp(n,"serialize");let a;if(a=o?o(t,n):ki.isURLSearchParams(t)?t.toString():new Ji(t,n).toString(i),a){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+a}return e}Vi.append=function(e,t){this._pairs.push([e,t])},Vi.toString=function(e){const t=e?t=>e.call(this,t,Gi):Gi;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};class Xi{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){ki.forEach(this.handlers,function(t){null!==t&&e(t)})}}var Yi={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0,advertiseZstdAcceptEncoding:!1,validateStatusUndefinedResolves:!0},Zi={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Ji,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const eo="undefined"!=typeof window&&"undefined"!=typeof document,to="object"==typeof navigator&&navigator||void 0,ro=eo&&(!to||["ReactNative","NativeScript","NS"].indexOf(to.product)<0),no="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,io=eo&&window.location.href||"http://localhost";var oo=Br({},Object.freeze({__proto__:null,hasBrowserEnv:eo,hasStandardBrowserEnv:ro,hasStandardBrowserWebWorkerEnv:no,navigator:to,origin:io}),Zi);function ao(e){if(e>100)throw new qi("FormData field is too deeply nested ("+e+" levels). Max depth: 100",qi.ERR_FORM_DATA_DEPTH_EXCEEDED)}function so(e){function t(e,r,n,i){ao(i);let o=e[i++];if("__proto__"===o)return!0;const a=Number.isFinite(+o),s=i>=e.length;if(o=!o&&ki.isArray(n)?n.length:o,s)return ki.hasOwnProp(n,o)?n[o]=ki.isArray(n[o])?n[o].concat(r):[n[o],r]:n[o]=r,!a;ki.hasOwnProp(n,o)&&ki.isObject(n[o])||(n[o]=[]);return t(e,r,n[o],i)&&ki.isArray(n[o])&&(n[o]=function(e){const t={},r=Object.keys(e);let n;const i=r.length;let o;for(n=0;n<i;n++)o=r[n],t[o]=e[o];return t}(n[o])),!a}if(ki.isFormData(e)&&ki.isFunction(e.entries)){const r={};return ki.forEachEntry(e,(e,n)=>{t(function(e){const t=[],r=/\w+|\[(\w*)]/g;let n;for(;null!==(n=r.exec(e));)ao(t.length),t.push("[]"===n[0]?"":n[1]||n[0]);return t}(e),n,r,0)}),r}return null}const uo=(e,t)=>null!=e&&ki.hasOwnProp(e,t)?e[t]:void 0;const lo={transitional:Yi,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,i=ki.isObject(e);i&&ki.isHTMLForm(e)&&(e=new FormData(e));if(ki.isFormData(e))return n?JSON.stringify(so(e)):e;if(ki.isArrayBuffer(e)||ki.isBuffer(e)||ki.isStream(e)||ki.isFile(e)||ki.isBlob(e)||ki.isReadableStream(e))return e;if(ki.isArrayBufferView(e))return e.buffer;if(ki.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(i){const t=uo(this,"formSerializer");if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Wi(e,new oo.classes.URLSearchParams,Br({visitor:function(e,t,r,n){return oo.isNode&&ki.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},t))}(e,t).toString();if((o=ki.isFileList(e))||r.indexOf("multipart/form-data")>-1){const r=uo(this,"env"),n=r&&r.FormData;return Wi(o?{"files[]":e}:e,n&&new n,t)}}return i||n?(t.setContentType("application/json",!1),function(e,t,r){if(ki.isString(e))try{return(t||JSON.parse)(e),ki.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=uo(this,"transitional")||lo.transitional,r=t&&t.forcedJSONParsing,n=uo(this,"responseType"),i="json"===n;if(ki.isResponse(e)||ki.isReadableStream(e))return e;if(e&&ki.isString(e)&&(r&&!n||i)){const r=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(e,uo(this,"parseReviver"))}catch(e){if(r){if("SyntaxError"===e.name)throw qi.from(e,qi.ERR_BAD_RESPONSE,this,null,uo(this,"response"));throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:oo.classes.FormData,Blob:oo.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};function co(e,t){const r=this||lo,n=t||r,i=Ni.from(n.headers);let o=n.data;return ki.forEach(e,function(e){o=e.call(r,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function ho(e){return!(!e||!e.__CANCEL__)}ki.forEach(["delete","get","head","post","put","patch","query"],e=>{lo.headers[e]={}});let po=class extends qi{constructor(e,t,r){super(null==e?"canceled":e,qi.ERR_CANCELED,t,r),this.name="CanceledError",this.__CANCEL__=!0}};function fo(e,t,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new qi("Request failed with status code "+r.status,r.status>=400&&r.status<500?qi.ERR_BAD_REQUEST:qi.ERR_BAD_RESPONSE,r.config,r.request,r)):e(r)}const go=(e,t,r=3)=>{let n=0;const i=function(e,t){e=e||10;const r=new Array(e),n=new Array(e);let i,o=0,a=0;return t=void 0!==t?t:1e3,function(s){const u=Date.now(),l=n[a];i||(i=u),r[o]=s,n[o]=u;let c=a,d=0;for(;c!==o;)d+=r[c++],c%=e;if(o=(o+1)%e,o===a&&(a=(a+1)%e),u-i<t)return;const h=l&&u-l;return h?Math.round(1e3*d/h):void 0}}(50,250);return function(e,t){let r,n,i=0,o=1e3/t;const a=(t,o=Date.now())=>{i=o,r=null,n&&(clearTimeout(n),n=null),e(...t)};return[(...e)=>{const t=Date.now(),s=t-i;s>=o?a(e,t):(r=e,n||(n=setTimeout(()=>{n=null,a(r)},o-s)))},()=>r&&a(r)]}(r=>{if(!r||"number"!=typeof r.loaded)return;const o=r.loaded,a=r.lengthComputable?r.total:void 0,s=null!=a?Math.min(o,a):o,u=Math.max(0,s-n),l=i(u);n=Math.max(n,s);e({loaded:s,total:a,progress:a?s/a:void 0,bytes:u,rate:l||void 0,estimated:l&&a?(a-s)/l:void 0,event:r,lengthComputable:null!=a,[t?"download":"upload"]:!0})},r)},mo=(e,t)=>{const r=null!=e;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},vo=e=>(...t)=>ki.asap(()=>e(...t));var yo=oo.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,oo.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(oo.origin),oo.navigator&&/(msie|trident)/i.test(oo.navigator.userAgent)):()=>!0,Do=oo.hasStandardBrowserEnv?{write(e,t,r,n,i,o,a){if("undefined"==typeof document)return;const s=[`${e}=${encodeURIComponent(t)}`];ki.isNumber(r)&&s.push(`expires=${new Date(r).toUTCString()}`),ki.isString(n)&&s.push(`path=${n}`),ki.isString(i)&&s.push(`domain=${i}`),!0===o&&s.push("secure"),ki.isString(a)&&s.push(`SameSite=${a}`),document.cookie=s.join("; ")},read(e){if("undefined"==typeof document)return null;const t=document.cookie.split(";");for(let r=0;r<t.length;r++){const n=t[r].replace(/^\s+/,""),i=n.indexOf("=");if(-1!==i&&n.slice(0,i)===e)try{return decodeURIComponent(n.slice(i+1))}catch(e){return n.slice(i+1)}}return null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read:()=>null,remove(){}};const bo=/^https?:(?!\/\/)/i,Fo=/[\t\n\r]/g;function wo(e,t){if("string"==typeof e&&bo.test(function(e){return function(e){let t=0;for(;t<e.length&&e.charCodeAt(t)<=32;)t++;return e.slice(t)}(e).replace(Fo,"")}(e)))throw new qi('Invalid URL: missing "//" after protocol',qi.ERR_INVALID_URL,t)}function Eo(e,t,r,n){wo(t,n);let i=!("string"==typeof(o=t)&&/^([a-z][a-z\d+\-.]*:)?\/\//i.test(o));var o;return e&&(i||!1===r)?(wo(e,n),function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t)):t}const So=e=>e instanceof Ni?Br({},e):e;function _o(e,t){e=e||{},t=t||{};const r=Object.create(null);function n(e,t,r,n){return ki.isPlainObject(e)&&ki.isPlainObject(t)?ki.merge.call({caseless:n},e,t):ki.isPlainObject(t)?ki.merge({},t):ki.isArray(t)?t.slice():t}function i(e,t,r,i){return ki.isUndefined(t)?ki.isUndefined(e)?void 0:n(void 0,e,0,i):n(e,t,0,i)}function o(e,t){if(!ki.isUndefined(t))return n(void 0,t)}function a(e,t){return ki.isUndefined(t)?ki.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function s(r,i,o){return ki.hasOwnProp(t,o)?n(r,i):ki.hasOwnProp(e,o)?n(void 0,r):void 0}Object.defineProperty(r,"hasOwnProperty",{__proto__:null,value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});const u={url:o,method:o,data:o,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken: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,allowedSocketPaths:a,responseEncoding:a,validateStatus:s,headers:(e,t,r)=>i(So(e),So(t),0,!0)};return ki.forEach(Object.keys(Br({},e,t)),function(n){if("__proto__"===n||"constructor"===n||"prototype"===n)return;const o=ki.hasOwnProp(u,n)?u[n]:i,a=o(ki.hasOwnProp(e,n)?e[n]:void 0,ki.hasOwnProp(t,n)?t[n]:void 0,n);ki.isUndefined(a)&&o!==s||(r[n]=a)}),ki.hasOwnProp(t,"validateStatus")&&ki.isUndefined(t.validateStatus)&&!1===function(r){const n=ki.hasOwnProp(t,"transitional")?t.transitional:void 0;if(!ki.isUndefined(n)){if(!ki.isPlainObject(n))return;if(ki.hasOwnProp(n,r))return n[r]}const i=ki.hasOwnProp(e,"transitional")?e.transitional:void 0;if(ki.isPlainObject(i)&&ki.hasOwnProp(i,r))return i[r]}("validateStatusUndefinedResolves")&&(ki.hasOwnProp(e,"validateStatus")?r.validateStatus=n(void 0,e.validateStatus):delete r.validateStatus),r}const Ao=["content-type","content-length"];function Co(e){const t=_o({},e),r=e=>ki.hasOwnProp(t,e)?t[e]:void 0,n=r("data");let i=r("withXSRFToken");const o=r("xsrfHeaderName"),a=r("xsrfCookieName");let s=r("headers");const u=r("auth"),l=r("baseURL"),c=r("allowAbsoluteUrls"),d=r("url");if(t.headers=s=Ni.from(s),t.url=Qi(Eo(l,d,c,t),r("params"),r("paramsSerializer")),u){const t=ki.getSafeProp(u,"username")||"",r=ki.getSafeProp(u,"password")||"";try{s.set("Authorization","Basic "+btoa(t+":"+(r?encodeURIComponent(r).replace(/%([0-9A-F]{2})/gi,(e,t)=>String.fromCharCode(parseInt(t,16))):"")))}catch(t){throw qi.from(t,qi.ERR_BAD_OPTION_VALUE,e)}}if(ki.isFormData(n)&&(oo.hasStandardBrowserEnv||oo.hasStandardBrowserWebWorkerEnv||ki.isReactNative(n)?s.setContentType(void 0):ki.isFunction(n.getHeaders)&&function(e,t,r){"content-only"===r?Object.entries(t||{}).forEach(([t,r])=>{Ao.includes(t.toLowerCase())&&e.set(t,r)}):e.set(t)}(s,n.getHeaders(),r("formDataHeaderPolicy"))),oo.hasStandardBrowserEnv){ki.isFunction(i)&&(i=i(t));if(!0===i||null==i&&yo(t.url)){const e=o&&a&&Do.read(a);e&&s.set(o,e)}}return t}var ko="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,r){const n=Co(e);let i=n.data;const o=Ni.from(n.headers).normalize();let a,s,u,l,c,{responseType:d,onUploadProgress:h,onDownloadProgress:p}=n;function f(){l&&l(),c&&c(),n.cancelToken&&n.cancelToken.unsubscribe(a),n.signal&&n.signal.removeEventListener("abort",a)}let g=new XMLHttpRequest;function m(){if(!g)return;const n=Ni.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders());fo(function(e){t(e),f()},function(e){r(e),f()},{data:d&&"text"!==d&&"json"!==d?g.response:g.responseText,status:g.status,statusText:g.statusText,headers:n,config:e,request:g}),g=null}g.open(n.method.toUpperCase(),n.url,!0),g.timeout=n.timeout,"onloadend"in g?g.onloadend=m:g.onreadystatechange=function(){g&&4===g.readyState&&(0!==g.status||g.responseURL&&g.responseURL.startsWith("file:"))&&setTimeout(m)},g.onabort=function(){g&&(r(new qi("Request aborted",qi.ECONNABORTED,e,g)),f(),g=null)},g.onerror=function(t){const n=t&&t.message?t.message:"Network Error",i=new qi(n,qi.ERR_NETWORK,e,g);i.event=t||null,r(i),f(),g=null},g.ontimeout=function(){let t=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const i=n.transitional||Yi;n.timeoutErrorMessage&&(t=n.timeoutErrorMessage),r(new qi(t,i.clarifyTimeoutError?qi.ETIMEDOUT:qi.ECONNABORTED,e,g)),f(),g=null},void 0===i&&o.setContentType(null),"setRequestHeader"in g&&ki.forEach(Bi(o),function(e,t){g.setRequestHeader(t,e)}),ki.isUndefined(n.withCredentials)||(g.withCredentials=!!n.withCredentials),d&&"json"!==d&&(g.responseType=n.responseType),p&&([u,c]=go(p,!0),g.addEventListener("progress",u)),h&&g.upload&&([s,l]=go(h),g.upload.addEventListener("progress",s),g.upload.addEventListener("loadend",l)),(n.cancelToken||n.signal)&&(a=t=>{g&&(r(!t||t.type?new po(null,e,g):t),g.abort(),f(),g=null)},n.cancelToken&&n.cancelToken.subscribe(a),n.signal&&(n.signal.aborted?a():n.signal.addEventListener("abort",a)));const v=function(e){const t=/^([-+\w]{1,25}):(?:\/\/)?/.exec(e);return t&&t[1]||""}(n.url);if(v&&!oo.protocols.includes(v))return r(new qi("Unsupported protocol "+v+":",qi.ERR_BAD_REQUEST,e)),void f();g.send(i||null)})};const xo=(e,t)=>{if(e=e?e.filter(Boolean):[],!t&&!e.length)return;const r=new AbortController;let n=!1;const i=function(e){if(!n){n=!0,a();const t=e instanceof Error?e:this.reason;r.abort(t instanceof qi?t:new po(t instanceof Error?t.message:t))}};let o=t&&setTimeout(()=>{o=null,i(new qi(`timeout of ${t}ms exceeded`,qi.ETIMEDOUT))},t);const a=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener("abort",i)}),e=null)};e.forEach(e=>e.addEventListener("abort",i,{once:!0}));const{signal:s}=r;return s.unsubscribe=()=>ki.asap(a),s},Po=function*(e,t){let r=e.byteLength;if(!t||r<t)return void(yield e);let n,i=0;for(;i<r;)n=i+t,yield e.slice(i,n),i=n},Io=(Oo=jr(function*(e,t){var r,n=!1,i=!1;try{for(var o,a=Pr(Bo(e));n=!(o=yield Or(a.next())).done;n=!1){const e=o.value;yield*xr(Pr(Po(e,t)))}}catch(e){i=!0,r=e}finally{try{n&&null!=a.return&&(yield Or(a.return()))}finally{if(i)throw r}}}),function(e,t){return Oo.apply(this,arguments)});var Oo;const Bo=(jo=jr(function*(e){if(e[Symbol.asyncIterator])return void(yield*xr(Pr(e)));const t=e.getReader();try{for(;;){const{done:e,value:r}=yield Or(t.read());if(e)break;yield r}}finally{yield Or(t.cancel())}}),function(e){return jo.apply(this,arguments)});var jo;const To=(e,t,r,n)=>{const i=Io(e,t);let o,a=0,s=e=>{o||(o=!0,n&&n(e))};return new ReadableStream({async pull(e){try{const{done:t,value:n}=await i.next();if(t)return s(),void e.close();let o=n.byteLength;if(r){let e=a+=o;r(e)}e.enqueue(new Uint8Array(n))}catch(e){throw s(e),e}},cancel:e=>(s(e),i.return())},{highWaterMark:2})},Ro=e=>e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102,Lo=(e,t,r)=>t+2<r&&Ro(e.charCodeAt(t+1))&&Ro(e.charCodeAt(t+2));const No="1.18.1",{isFunction:Uo}=ki,qo=e=>{if(!ki.isString(e))return e;try{return decodeURIComponent(e)}catch(t){return e}},zo=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},$o=e=>{const t=void 0!==ki.global&&null!==ki.global?ki.global:globalThis,{ReadableStream:r,TextEncoder:n}=t;e=ki.merge.call({skipUndefined:!0},{Request:t.Request,Response:t.Response},e);const{fetch:i,Request:o,Response:a}=e,s=i?Uo(i):"function"==typeof fetch,u=Uo(o),l=Uo(a);if(!s)return!1;const c=s&&Uo(r),d=s&&("function"==typeof n?(h=new n,e=>h.encode(e)):async e=>new Uint8Array(await new o(e).arrayBuffer()));var h;const p=u&&c&&zo(()=>{let e=!1;const t=new o(oo.origin,{body:new r,method:"POST",get duplex(){return e=!0,"half"}}),n=t.headers.has("Content-Type");return null!=t.body&&t.body.cancel(),e&&!n}),f=l&&c&&zo(()=>ki.isReadableStream(new a("").body)),g={stream:f&&(e=>e.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!g[e]&&(g[e]=(t,r)=>{let n=t&&t[e];if(n)return n.call(t);throw new qi(`Response type '${e}' is not supported`,qi.ERR_NOT_SUPPORT,r)})});const m=async e=>{if(null==e)return 0;if(ki.isBlob(e))return e.size;if(ki.isSpecCompliantForm(e)){const t=new o(oo.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return ki.isArrayBufferView(e)||ki.isArrayBuffer(e)?e.byteLength:(ki.isURLSearchParams(e)&&(e+=""),ki.isString(e)?(await d(e)).byteLength:void 0)};return async e=>{let{url:t,method:r,data:s,signal:l,cancelToken:d,timeout:h,onDownloadProgress:v,onUploadProgress:y,responseType:D,headers:b,withCredentials:F="same-origin",fetchOptions:w,maxContentLength:E,maxBodyLength:S}=Co(e);const _=ki.isNumber(E)&&E>-1,A=ki.isNumber(S)&&S>-1;let C=i||fetch;D=D?(D+"").toLowerCase():"text";let k=xo([l,d&&d.toAbortSignal()],h),x=null;const P=k&&k.unsubscribe&&(()=>{k.unsubscribe()});let I,O=null;const B=()=>new qi("Request body larger than maxBodyLength limit",qi.ERR_BAD_REQUEST,e,x);try{let i;const l=(T="auth",ki.hasOwnProp(e,T)?e[T]:void 0);if(l){const e=ki.getSafeProp(l,"username")||"";i={username:e,password:ki.getSafeProp(l,"password")||""}}if((e=>{const t=e.indexOf("://");let r=e;return-1!==t&&(r=r.slice(t+3)),r.includes("@")||r.includes(":")})(t)){const e=new URL(t,oo.origin);if(!i&&(e.username||e.password)){const t=qo(e.username);i={username:t,password:qo(e.password)}}(e.username||e.password)&&(e.username="",e.password="",t=e.href)}if(i&&(b.delete("authorization"),b.set("Authorization","Basic "+btoa((j=(i.username||"")+":"+(i.password||""),encodeURIComponent(j).replace(/%([0-9A-F]{2})/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))))),_&&"string"==typeof t&&t.startsWith("data:")){const r=function(e){if(!e||"string"!=typeof e)return 0;if(!e.startsWith("data:"))return 0;const t=e.indexOf(",");if(t<0)return 0;const r=e.slice(5,t),n=e.slice(t+1);if(/;base64/i.test(r)){let e=n.length;const t=n.length;for(let r=0;r<t;r++)if(37===n.charCodeAt(r)&&r+2<t){const t=n.charCodeAt(r+1),i=n.charCodeAt(r+2);Ro(t)&&Ro(i)&&(e-=2,r+=2)}let r=0,i=t-1;const o=e=>e>=2&&37===n.charCodeAt(e-2)&&51===n.charCodeAt(e-1)&&(68===n.charCodeAt(e)||100===n.charCodeAt(e));i>=0&&(61===n.charCodeAt(i)?(r++,i--):o(i)&&(r++,i-=3)),1===r&&i>=0&&(61===n.charCodeAt(i)||o(i))&&r++;const a=3*Math.floor(e/4)-(r||0);return a>0?a:0}let i=0;for(let e=0,t=n.length;e<t;e++){const r=n.charCodeAt(e);if(37===r&&Lo(n,e,t))i+=1,e+=2;else if(r<128)i+=1;else if(r<2048)i+=2;else if(r>=55296&&r<=56319&&e+1<t){const t=n.charCodeAt(e+1);t>=56320&&t<=57343?(i+=4,e++):i+=3}else i+=3}return i}(t);if(r>E)throw new qi("maxContentLength size of "+E+" exceeded",qi.ERR_BAD_RESPONSE,e,x)}if(A&&"get"!==r&&"head"!==r){const e=await m(s);if("number"==typeof e&&isFinite(e)&&(I=e,e>S))throw B()}const d=A&&(ki.isReadableStream(s)||ki.isStream(s)),h=(e,t,r)=>To(e,65536,e=>{if(A&&e>S)throw O=B();t&&t(e)},r);if(p&&"get"!==r&&"head"!==r&&(y||d)){if(I=null==I?await(async(e,t)=>{const r=ki.toFiniteNumber(e.getContentLength());return null==r?m(t):r})(b,s):I,0!==I||d){let e,r=new o(t,{method:"POST",body:s,duplex:"half"});if(ki.isFormData(s)&&(e=r.headers.get("content-type"))&&b.setContentType(e),r.body){const[e,t]=y&&mo(I,go(vo(y)))||[];s=h(r.body,e,t)}}}else if(d&&!u&&c&&"get"!==r&&"head"!==r)s=h(s);else if(d&&u&&!p&&"get"!==r&&"head"!==r)throw new qi("Stream request bodies are not supported by the current fetch implementation",qi.ERR_NOT_SUPPORT,e,x);ki.isString(F)||(F=F?"include":"omit");const R=u&&"credentials"in o.prototype;if(ki.isFormData(s)){const e=b.getContentType();e&&/^multipart\/form-data/i.test(e)&&!/boundary=/i.test(e)&&b.delete("content-type")}b.set("User-Agent","axios/"+No,!1);const L=Br({},w,{signal:k,method:r.toUpperCase(),headers:Bi(b.normalize()),body:s,duplex:"half",credentials:R?F:void 0});x=u&&new o(t,L);let N=await(u?C(x,w):C(t,L));const U=Ni.from(N.headers);if(_){const t=ki.toFiniteNumber(U.getContentLength());if(null!=t&&t>E)throw new qi("maxContentLength size of "+E+" exceeded",qi.ERR_BAD_RESPONSE,e,x)}const q=f&&("stream"===D||"response"===D);if(f&&N.body&&(v||_||q&&P)){const t={};["status","statusText","headers"].forEach(e=>{t[e]=N[e]});const r=ki.toFiniteNumber(U.getContentLength()),[n,i]=v&&mo(r,go(vo(v),!0))||[];let o=0;const s=t=>{if(_&&(o=t,o>E))throw new qi("maxContentLength size of "+E+" exceeded",qi.ERR_BAD_RESPONSE,e,x);n&&n(t)};N=new a(To(N.body,65536,s,()=>{i&&i(),P&&P()}),t)}D=D||"text";let z=await g[ki.findKey(g,D)||"text"](N,e);if(_&&!f&&!q){let t;if(null!=z&&("number"==typeof z.byteLength?t=z.byteLength:"number"==typeof z.size?t=z.size:"string"==typeof z&&(t="function"==typeof n?(new n).encode(z).byteLength:z.length)),"number"==typeof t&&t>E)throw new qi("maxContentLength size of "+E+" exceeded",qi.ERR_BAD_RESPONSE,e,x)}return!q&&P&&P(),await new Promise((t,r)=>{fo(t,r,{data:z,headers:Ni.from(N.headers),status:N.status,statusText:N.statusText,config:e,request:x})})}catch(t){if(P&&P(),k&&k.aborted&&k.reason instanceof qi){const r=k.reason;throw r.config=e,x&&(r.request=x),t!==r&&Object.defineProperty(r,"cause",{__proto__:null,value:t,writable:!0,enumerable:!1,configurable:!0}),r}if(O)throw x&&!O.request&&(O.request=x),O;if(t instanceof qi)throw x&&!t.request&&(t.request=x),t;if(t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message)){const r=new qi("Network Error",qi.ERR_NETWORK,e,x,t&&t.response);throw Object.defineProperty(r,"cause",{__proto__:null,value:t.cause||t,writable:!0,enumerable:!1,configurable:!0}),r}throw qi.from(t,t&&t.code,e,x,t&&t.response)}var j,T}},Mo=new Map,Ho=e=>{let t=e&&e.env||{};const{fetch:r,Request:n,Response:i}=t,o=[n,i,r];let a,s,u=o.length,l=Mo;for(;u--;)a=o[u],s=l.get(a),void 0===s&&l.set(a,s=u?new Map:$o(t)),l=s;return s};Ho();const Wo={http:null,xhr:ko,fetch:{get:Ho}};ki.forEach(Wo,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{__proto__:null,value:t})}catch(e){}Object.defineProperty(e,"adapterName",{__proto__:null,value:t})}});const Go=e=>`- ${e}`,Jo=e=>ki.isFunction(e)||null===e||!1===e;var Vo={getAdapter:function(e,t){e=ki.isArray(e)?e:[e];const{length:r}=e;let n,i;const o={};for(let a=0;a<r;a++){let r;if(n=e[a],i=n,!Jo(n)&&(i=Wo[(r=String(n)).toLowerCase()],void 0===i))throw new qi(`Unknown adapter '${r}'`);if(i&&(ki.isFunction(i)||(i=i.get(t))))break;o[r||"#"+a]=i}if(!i){const e=Object.entries(o).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));let t=r?e.length>1?"since :\n"+e.map(Go).join("\n"):" "+Go(e[0]):"as no adapter specified";throw new qi("There is no suitable adapter to dispatch the request "+t,qi.ERR_NOT_SUPPORT)}return i},adapters:Wo};function Ko(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new po(null,e)}function Qo(e){Ko(e),e.headers=Ni.from(e.headers),e.data=co.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return Vo.getAdapter(e.adapter||lo.adapter,e)(e).then(function(t){Ko(e),e.response=t;try{t.data=co.call(e,e.transformResponse,t)}finally{delete e.response}return t.headers=Ni.from(t.headers),t},function(t){if(!ho(t)&&(Ko(e),t&&t.response)){e.response=t.response;try{t.response.data=co.call(e,e.transformResponse,t.response)}finally{delete e.response}t.response.headers=Ni.from(t.response.headers)}return Promise.reject(t)})}const Xo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Xo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Yo={};Xo.transitional=function(e,t,r){function n(e,t){return"[Axios v"+No+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(r,i,o)=>{if(!1===e)throw new qi(n(i," has been removed"+(t?" in "+t:"")),qi.ERR_DEPRECATED);return t&&!Yo[i]&&(Yo[i]=!0,console.warn(n(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,i,o)}},Xo.spelling=function(e){return(t,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};var Zo={assertOptions:function(e,t,r){if("object"!=typeof e||null===e)throw new qi("options must be an object",qi.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let i=n.length;for(;i-- >0;){const o=n[i],a=Object.prototype.hasOwnProperty.call(t,o)?t[o]:void 0;if(a){const t=e[o],r=void 0===t||a(t,o,e);if(!0!==r)throw new qi("option "+o+" must be "+r,qi.ERR_BAD_OPTION_VALUE);continue}if(!0!==r)throw new qi("Unknown option "+o,qi.ERR_BAD_OPTION)}},validators:Xo};const ea=Zo.validators;let ta=class{constructor(e){this.defaults=e||{},this.interceptors={request:new Xi,response:new Xi}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const r=(()=>{if(!t.stack)return"";const e=t.stack.indexOf("\n");return-1===e?"":t.stack.slice(e+1)})();try{if(e.stack){if(r){const t=r.indexOf("\n"),n=-1===t?-1:r.indexOf("\n",t+1),i=-1===n?"":r.slice(n+1);String(e.stack).endsWith(i)||(e.stack+="\n"+r)}}else e.stack=r}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=_o(this.defaults,t);const{transitional:r,paramsSerializer:n,headers:i}=t;void 0!==r&&Zo.assertOptions(r,{silentJSONParsing:ea.transitional(ea.boolean),forcedJSONParsing:ea.transitional(ea.boolean),clarifyTimeoutError:ea.transitional(ea.boolean),legacyInterceptorReqResOrdering:ea.transitional(ea.boolean),advertiseZstdAcceptEncoding:ea.transitional(ea.boolean),validateStatusUndefinedResolves:ea.transitional(ea.boolean)},!1),null!=n&&(ki.isFunction(n)?t.paramsSerializer={serialize:n}:Zo.assertOptions(n,{encode:ea.function,serialize:ea.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Zo.assertOptions(t,{baseUrl:ea.spelling("baseURL"),withXsrfToken:ea.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=i&&ki.merge(i.common,i[t.method]);i&&ki.forEach(["delete","get","head","post","put","patch","query","common"],e=>{delete i[e]}),t.headers=Ni.concat(o,i);const a=[];let s=!0;this.interceptors.request.forEach(function(e){if("function"==typeof e.runWhen&&!1===e.runWhen(t))return;s=s&&e.synchronous;const r=t.transitional||Yi;r&&r.legacyInterceptorReqResOrdering?a.unshift(e.fulfilled,e.rejected):a.push(e.fulfilled,e.rejected)});const u=[];let l;this.interceptors.response.forEach(function(e){u.push(e.fulfilled,e.rejected)});let c,d=0;if(!s){const e=[Qo.bind(this),void 0];for(e.unshift(...a),e.push(...u),c=e.length,l=Promise.resolve(t);d<c;)l=l.then(e[d++],e[d++]);return l}c=a.length;let h=t;for(;d<c;){const e=a[d++],t=a[d++];try{h=e(h)}catch(e){t.call(this,e);break}}try{l=Qo.call(this,h)}catch(e){return Promise.reject(e)}for(d=0,c=u.length;d<c;)l=l.then(u[d++],u[d++]);return l}getUri(e){return Qi(Eo((e=_o(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls,e),e.params,e.paramsSerializer)}};ki.forEach(["delete","get","head","options"],function(e){ta.prototype[e]=function(t,r){return this.request(_o(r||{},{method:e,url:t,data:r&&ki.hasOwnProp(r,"data")?r.data:void 0}))}}),ki.forEach(["post","put","patch","query"],function(e){function t(t){return function(r,n,i){return this.request(_o(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}ta.prototype[e]=t(),"query"!==e&&(ta.prototype[e+"Form"]=t(!0))});const ra={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(ra).forEach(([e,t])=>{ra[t]=e});const na=function e(t){const r=new ta(t),n=Bn(ta.prototype.request,r);return ki.extend(n,ta.prototype,r,{allOwnKeys:!0}),ki.extend(n,r,null,{allOwnKeys:!0}),n.create=function(r){return e(_o(t,r))},n}(lo);na.Axios=ta,na.CanceledError=po,na.CancelToken=class e{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const r=this;this.promise.then(e=>{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null}),this.promise.then=e=>{let t;const n=new Promise(e=>{r.subscribe(e),t=e}).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e(function(e,n,i){r.reason||(r.reason=new po(e,n,i),t(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;const r=new e(function(e){t=e});return{token:r,cancel:t}}},na.isCancel=ho,na.VERSION=No,na.toFormData=Wi,na.AxiosError=qi,na.Cancel=na.CanceledError,na.all=function(e){return Promise.all(e)},na.spread=function(e){return function(t){return e.apply(null,t)}},na.isAxiosError=function(e){return ki.isObject(e)&&!0===e.isAxiosError},na.mergeConfig=_o,na.AxiosHeaders=Ni,na.formToJSON=e=>so(ki.isHTMLForm(e)?new FormData(e):e),na.getAdapter=Vo.getAdapter,na.HttpStatusCode=ra,na.default=na;const{Axios:ia,AxiosError:oa,CanceledError:aa,isCancel:sa,CancelToken:ua,VERSION:la,all:ca,Cancel:da,isAxiosError:ha,spread:pa,toFormData:fa,AxiosHeaders:ga,HttpStatusCode:ma,formToJSON:va,getAdapter:ya,mergeConfig:Da,create:ba}=na;class Fa extends Error{}function wa(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,(e,t)=>{let r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}))}(t)}catch(e){return atob(t)}}function Ea(e,t){if("string"!=typeof e)throw new Fa("Invalid token specified: must be a string");t||(t={});const r=!0===t.header?0:1,n=e.split(".")[r];if("string"!=typeof n)throw new Fa(`Invalid token specified: missing part #${r+1}`);let i;try{i=wa(n)}catch(e){throw new Fa(`Invalid token specified: invalid base64 for part #${r+1} (${e.message})`)}try{return JSON.parse(i)}catch(e){throw new Fa(`Invalid token specified: invalid json for part #${r+1} (${e.message})`)}}Fa.prototype.name="InvalidTokenError";class Sa{constructor(){var e,t=this;this.inIframe=salla.helpers.isIframe(),salla.event.on("twilight::before.ready",async function(e){return await t.initiateRequest(e)}),salla.event.on("profile::info.fetched",e=>this.setCurrencyAndLanguage(e)),salla.event.on("auth::token.fetched",e=>{salla.storage.set("token",e),this.inIframe&&salla.log("token fetched iframe"),this.inIframe&&salla.cookie.set("s-token",e,60),this.setToken(e)}),salla.event.on("auth::token.invalid",()=>{salla.storage.remove("user"),salla.storage.remove("token")}),this.notifier_handler_disabled=!1,this.notifier_suppression_count=0,this.axios=na.create({baseURL:Salla.config.get("store.api",Salla.config.get("store.url")),headers:{common:{"X-Requested-With":"XMLHttpRequest","S-SOURCE":"twilight","S-APP-VERSION":(null==(e=Salla)||null==(e=e.versions)?void 0:e.twilight)||"2.0.0","S-APP-OS":"browser","cache-control":"no-cache"}}}),this.axios.interceptors.request.use(e=>{"preview"===Salla.config.get("theme.mode")&&(e.url=Salla.url.addParamToUrl("use_username_url",1,e.url));try{var t;const r=Salla.config.get("swoole",[]),n=new RegExp(r.join("|"),"i");r.length>0&&n.test(e.url)&&(e.headers["s-store-api-version"]="swoole");const i=null==(t=Salla.analytics)?void 0:t.getAnonymousId();i&&(e.headers["s-anonymous-id"]=i)}catch(e){Salla.log("Error in request interceptor:",e)}return e},e=>Promise.reject(e))}getHeaders(){let e=Br({},this.axios.defaults.headers.common);return delete e["Content-Type"],e}getHeader(e){var t;return null==(t=Object.entries(this.getHeaders()).filter(([t])=>t.toLowerCase()===e.toLowerCase())[0])?void 0:t[1]}setHeaders(e){return Object.entries(e).forEach(e=>this.setHeader(e[0],e[1])),this}setHeader(e,t){return salla.infiniteScroll.fetchOptions.headers[e]=this.axios.defaults.headers.common[e]=t,this}async withoutNotifier(e){return this.notifier_suppression_count++,this.notifier_handler_disabled=!0,await e().finally(()=>{this.notifier_suppression_count=Math.max(0,this.notifier_suppression_count-1),0===this.notifier_suppression_count&&(this.notifier_handler_disabled=!1)})}async initiateRequest(e){var t,r,n;this.axios.defaults.baseURL=Salla.config.get("store.api",Salla.config.get("store.url")),this.setHeaders(Br({"Store-Identifier":Salla.config.get("store.id"),currency:(null==(t=e.user)?void 0:t.currency_code)||"SAR","accept-language":salla.lang.getLocale(),"s-user-id":null==(r=e.user)?void 0:r.id,"s-country":null==(n=e.user)?void 0:n.country_code},e.headers||{}));const i=Salla.config.get("store.scope",Salla.storage.get("scope")),o=new URLSearchParams(window.location.search),a=o.get("scope"),s=o.get("allocation_type"),u=o.get("allocation_id");if(a&&i&&!Salla.url.is_page("cart")){const e=Salla.storage.get("scope")||{};Salla.storage.set("scope",Br({},e,{type:i.type,id:a},s&&{allocation_type:s},u&&{allocation_id:u})),String(a)!==String(i.id)&&Salla.cart.reset(),i.id=a}if((s||u)&&(Salla.url.is_page("cart")||!a||!i)){const e=Salla.storage.get("scope")||{};var l,c;if(null!=e&&e.id||null!=i&&i.id)Salla.storage.set("scope",Br({},e,{id:null!=(l=null==e?void 0:e.id)?l:null==i?void 0:i.id,type:null!=(c=null==e?void 0:e.type)?c:null==i?void 0:i.type},s&&{allocation_type:s},u&&{allocation_id:u}))}if(i){this.setHeaders({"s-scope-type":i.type,"s-scope-id":i.id});const e=Salla.storage.get("scope")||{};e.allocation_type&&this.setHeader("s-scope-allocation-type",e.allocation_type),e.allocation_id&&this.setHeader("s-scope-allocation-id",e.allocation_id)}const d=Salla.storage.getWithTTL("s-utms");if(d){const e={};Object.entries(d).forEach(([t,r])=>{e[t]="string"==typeof r&&/[^\x00-\x7F]/.test(r)?encodeURIComponent(r):r}),this.setHeaders(e)}await this.injectTokenToTheRequests(e),Salla.storage.get("affiliate_code")&&this.setHeader("s-affiliate-code",Salla.storage.get("affiliate_code"))}async injectTokenToTheRequests(e){var t,r,n=this;let i,o,a=this.getToken(),s="guest"===(null==(t=e.user)?void 0:t.type),u=parseInt((null==(r=e.user)?void 0:r.id)||0),l=parseInt(salla.storage.get("user.id")||0),c=salla.auth.api.isSessionless(),d=e=>{this.setToken(e),salla.event.emit("api::initiated")},h=async function(){s||c||!u?salla.auth.event.tokenInvalid():(salla.log("Api:: case 1 => current is is guest & web session available"),await salla.auth.api.refresh().then(async function(){await salla.profile.info()}).catch(()=>salla.auth.event.tokenInvalid()))};if(!a)return salla.log("Api:: case 1 => current is is guest"),void await h();try{i=Ea(a)}catch(e){return Salla.logger.warn("Failed to decode JWT token",e),void Salla.auth.event.tokenInvalid()}return Date.now()/1e3>i.exp?(salla.log("Api:: case 2 => current user is logged-in and there is a token, but it's expired"),void await h()):(o=c?parseInt(i.sub)!==l:!l||!u||l!==u||parseInt(i.sub)!==u,o?(salla.log("Api:: case 3 => there is a token and user in session/local missing or mismatch"),salla.log(`sub:${i.sub} userIdInWeb:${u} userIdInStorage:${l}, isSessionless:${c}`,i.sub,u,l),this.setHeader("Authorization","Bearer "+a),void await salla.profile.info().then(async function(e){!n.inIframe&&!c&&await salla.auth.api.request("auth/jwt",{callerName:"salla.auth.request.injectTokenToTheRequests"}),d(a)}).catch(()=>{salla.log("Api:: case 3 => failed get fresh profile"),this.setHeader("Authorization",null),salla.auth.event.tokenInvalid()})):(salla.log("Api:: case 4 => current user is logged-in and there is a token, and it's not expired"),void d(a)))}setToken(e){return this.setHeader("Authorization","Bearer "+e),salla.event.emit("api::token.injected",e),this.token=e,this}cleanupTokenFromUrl(){try{const e=new URL(window.location.href);if(!e.searchParams.has("token"))return;e.searchParams.delete("token"),window.history.replaceState({},document.title,e.toString())}catch(e){Salla.logger.warn("Failed to cleanup token from URL",e)}}setCurrencyAndLanguage(e){return this.setHeaders({currency:e.data.currency,"accept-language":e.data.language})}request(e,t=void 0,r="get",n={}){let i={endPoint:e,payload:t,method:r,options:n},o="undefined"!=typeof event?event.currentTarget:null,a=!1;return"SALLA-BUTTON"===(null==o?void 0:o.tagName)&&(a=!0),a&&(null==o||o.load()),this.axios[i.method](i.endPoint,i.payload,i.options).then(e=>(a&&(null==o||o.stop()),e.data&&e.request&&(e=e.data),this.handleAfterResponseActions(e),e)).catch(e=>{throw a&&(null==o||o.stop()),salla.event.document.requestFailed(i,e),this.handleErrorResponse(e),e})}handleAfterResponseActions(e){if(!e)return;let{data:t,googleTags:r=null}=e,n=t&&t.googleTags?t.googleTags:r;try{dataLayer&&n&&dataLayer.push(n)}catch(e){salla.logger.error(e.message)}this.fireEventsForResponse(e),this.showAlert(e)}fireEventsForResponse(e){var t,r;let n=(null==e?void 0:e.events)||(null==(t=e.data)?void 0:t.events)||(null==(r=e.error)?void 0:r.events);"string"==typeof n&&(n=JSON.parse(n)),n&&Object.keys(n).forEach(e=>salla.event.dispatch(e,n[e]))}handleErrorResponse(e){if(e.response&&e.response.data)return e.response.data.error&&e.response.data.error.fields&&!this.notifier_handler_disabled?this.handleInvalidFields(e):this.handleAfterResponseActions(e.response.data)}showAlert(e){var t,r;if(e&&!this.notifier_handler_disabled)return e.case&&e.msg?salla.notify.fire(e.msg,e.case,e):e.hasOwnProperty("success")&&null!=(t=e.data)&&t.message?salla.notify.fire(null==(r=e.data)?void 0:r.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)}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)}getToken(){if(Salla.storage.get("token"))return Salla.storage.get("token");try{var e;const t=null==(e=new URLSearchParams(window.location.search))?void 0:e.get("token");if(!t)return;if(3!==t.split(".").length)return;return this.cleanupTokenFromUrl(),t}catch(e){Salla.logger.warn("Failed to extract or validate token from URL",e)}}}class _a extends mn{constructor(){super(),this.namespace="component",this.endpoints={getMenus:"menus/{headOrFoot}?store_id={store}&lang={lang}",reviews:"reviews"},this.endpointsMethods={getMenus:"get",reviews:"get"}}async getMenus(e="header"){return this.request(["getMenus",e,salla.config.get("store.id"),salla.lang.getLocale()]).then(function(e){return salla.event.component.menuFetched(e),e}).catch(function(e){throw salla.event.component.menuFetchFailed(e),e})}async getReviews({per_page:e=5,type:t="all",items:r}){if(!t){const e="Review type cannot be empty. Please provide one.";return salla.event.component.reviewsFetchFailed(e),salla.api.errorPromise(e)}const n=!r||"string"==typeof r&&"[]"===r||Array.isArray(r)&&!r.length;if(!new Set(["all","store","categories","products","json"]).has(t)){const e="Invalid review type. Please provide a valid type.";return salla.event.component.reviewsFetchFailed(e),salla.api.errorPromise(e)}if("all"!==t&&"store"!==t&&n){const e="Items cannot be empty. Please provide one.";return salla.event.component.reviewsFetchFailed(e),salla.api.errorPromise(e)}if(new Set(["products","categories"]).has(t)&&!Array.isArray(r)){const e=`Items value must be an array of ${t} id for review type of ${t}.`;return salla.event.component.reviewsFetchFailed(e),salla.api.errorPromise(e)}return this.request(["reviews"],{params:{per_page:e,type:t,items:r}},"get").then(function(e){return salla.event.component.reviewsFetched(e),e}).catch(function(e){throw salla.event.component.reviewsFetchFailed(e),e})}}class Aa extends mn{constructor(){super(),this.namespace="booking",this.endpoints={fetch:"advertisements"},this.endpointsMethods={fetch:"get"}}async fetch(e=null){const t=e?{page:e}:{};return this.request(["fetch"],{params:t}).then(function(e){return salla.event.advertisement.fetched(e),e}).catch(function(e){throw salla.event.advertisement.fetchFailed(e),e})}}class Ca extends mn{constructor(){super(),this.namespace="navigation",this.endpoints={breadcrumbs:"breadcrumbs"},this.endpointsMethods={breadcrumbs:"get"},this.after_init()}fetchBreadcrumbs(e){if(!e.page){let e="The 'page' parameter is required for the Breadcrumb API. Please provide a valid 'page' parameter.";return salla.event.navigation.breadcrumbFetchFailed(e),salla.api.errorPromise(e)}if(["product.single","product.index","customer.orders.single","product.index.tag","page-single","landing-page","brands.single","blog.single","blog.index.author","blog.index.category","blog.index.tag"].includes(e.page)&&!e.id){let t=`The 'id' parameter is required when the 'page' parameter is set to ${e.page}. Please provide valid value for the 'ID' parameter.`;return salla.event.navigation.breadcrumbFetchFailed(t),salla.api.errorPromise(t)}return this.request("breadcrumbs",{params:e}).then(function(e){return salla.event.navigation.breadcrumbFetched(e),e}).catch(function(e){throw salla.event.navigation.breadcrumbFetchFailed(e),e})}}class ka extends mn{constructor(){super(),this.namespace="metadata",this.endpoints={fetchValues:"https://api.salla.dev/store/v1/metadata/values"},this.endpointsMethods={fetchValues:"get"}}async fetchValues(e,t){if(!e||!t){const e="Please provide entity type and entity ids.";return salla.metadata.event.valueNotFetch(e),salla.api.errorPromise(e)}const r={type:e,entities:Array.isArray(t)?t:[t]};return this.request(this.endpoints.fetchValues,{params:r},"get").then(e=>(salla.metadata.event.valueFetched(e),e)).catch(e=>{throw salla.metadata.event.valueNotFetch(e),e})}}const xa=["limit","max_recommendations"];class Pa extends mn{constructor(){super(),this.namespace="recommendations",this.endpoints={customersAlsoBought:"products/customers-also-bought",similarProducts:"products/similar-products",buyAgain:"customers/buy-again",personalizedShoppersWhoBought:"customers/personalized-shoppers-who-bought",boughtTogether:"carts/bought-together"},this.endpointsMethods={customersAlsoBought:"get",similarProducts:"get",buyAgain:"get",personalizedShoppersWhoBought:"get",boughtTogether:"get"}}getBaseUrl(){return Salla.config.get("recommendations.api").replace(/\/$/,"")}getRecommendationHeaders(){return{"s-store-id":Salla.config.get("store.id"),"X-Optimus-Decode":Salla.config.get("recommendations.optimusDecode",!0)?"true":"false"}}getUrl(e){const t=super.getUrl(...arguments);return`${this.getBaseUrl()}/${t}`}customersAlsoBought(e,t={}){return this.requestProductRecommendations("customersAlsoBought",e,t,{fetched:"customersAlsoBoughtFetched",failed:"customersAlsoBoughtFailed"},"Product id is required for customers-also-bought recommendations.")}similarProducts(e,t={}){return this.requestProductRecommendations("similarProducts",e,t,{fetched:"similarProductsFetched",failed:"similarProductsFailed"},"Product id is required for similar-products recommendations.")}buyAgain(e={}){return this.requestCustomerRecommendations("buyAgain",e,{fetched:"buyAgainFetched",failed:"buyAgainFailed"})}personalizedShoppersWhoBought(e={}){return this.requestCustomerRecommendations("personalizedShoppersWhoBought",e,{fetched:"personalizedShoppersWhoBoughtFetched",failed:"personalizedShoppersWhoBoughtFailed"})}boughtTogether(e,t={}){const r=this.normalizeProductIdsList(e);if(!r.length){const e="Product ids are required for bought-together recommendations.";return salla.event.recommendations.boughtTogetherFailed(e),this.wrapRecommendationResponse(salla.api.errorPromise(e))}return this.requestCartRecommendations("boughtTogether",Br({product_ids:r},this.normalizeRecommendationParams(t)),{fetched:"boughtTogetherFetched",failed:"boughtTogetherFailed"},r)}requestProductRecommendations(e,t,r,n,i){return t?this.wrapRecommendationResponse(this.request(e,{params:Br({product_id:t},this.normalizeRecommendationParams(r)),headers:this.getRecommendationHeaders()},"get").then(e=>(salla.event.recommendations[n.fetched](e,t),e)).catch(e=>{throw salla.event.recommendations[n.failed](e,t),e})):(salla.event.recommendations[n.failed](i),this.wrapRecommendationResponse(salla.api.errorPromise(i)))}requestCustomerRecommendations(e,t,r){return this.wrapRecommendationResponse(this.request(e,{params:this.normalizeRecommendationParams(t),headers:this.getRecommendationHeaders()},"get").then(e=>(salla.event.recommendations[r.fetched](e),e)).catch(e=>{throw salla.event.recommendations[r.failed](e),e}))}requestCartRecommendations(e,t,r,n=null){return this.wrapRecommendationResponse(this.request(e,{params:t,paramsSerializer:this.serializeRepeatedQueryParams,headers:this.getRecommendationHeaders()},"get").then(e=>(salla.event.recommendations[r.fetched](e,n),e)).catch(e=>{throw salla.event.recommendations[r.failed](e,n),e}))}normalizeRecommendationParams(e={}){const{limit:t,max_recommendations:r}=e,n=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}(e,xa),i=Br({},n);return i.max_recommendations=null!=t?t:null!=r?r:5,i}serializeRepeatedQueryParams(e){const t=new URLSearchParams;return Object.entries(e).forEach(([e,r])=>{Array.isArray(r)?r.forEach(r=>t.append(e,String(r))):null!=r&&t.append(e,String(r))}),t.toString()}normalizeProductIdsList(e){if(!e)return[];return(Array.isArray(e)?e:[e]).map(e=>this.parseProductId(e)).filter(e=>null!==e)}wrapRecommendationResponse(e){return e.extractProductIds=()=>e.then(e=>this.extractProductIds(e)),e}extractProductIds(e){var t,r,n;if(!e)return[];return(Array.isArray(e)?e:Array.isArray(e.data)?e.data:null!=(t=null!=(r=null!=(n=e.products)?n:e.items)?r:e.recommendations)?t:[]).map(e=>this.parseProductId(e)).filter(e=>null!==e)}parseProductId(e){if("number"==typeof e)return e;if("string"==typeof e){const t=Number(e);return Number.isNaN(t)?null:t}if(e&&"object"==typeof e){var t,r;const n=null!=(t=null!=(r=e.id)?r:e.product_id)?t:e.objectID;if(null==n||""===n)return null;const i=Number(n);return Number.isNaN(i)?null:i}return null}}class Ia{constructor(e){this.config=e,this.configKey="s-twilight-config",this.tempUser=e.user}async getConfig(){if(Object.entries(this.config.store).length>2)return this.config;let e=await this.getConfigFromSession();return e||(e=await this.getConfigFromApi()),e.user=this.tempUser,e}async getConfigFromSession(){var e;let t=salla.storage.getWithTTL("session",this.configKey);return t&&"object"==typeof t&&null!=(e=t.store)&&e.id?this.config.store.id==t.store.id?t:(salla.storage.session.remove(this.configKey),null):null}getConfigFromApi(){console.log("getting Twilight initiate config using store.id ...");const e=new URL(`${(this.config.store.api||Salla.config.get("store.api")).replace(/\/$/,"")}/store/settings`);return fetch(e,{headers:Salla.api.getHeaders()}).then(e=>e.json()).then(e=>{if(200!==e.status)throw{response:e};return this.setConfigToSession(e.data)}).catch(e=>{throw Salla.api.handleErrorResponse(e),e})}setConfigToSession(e){return Salla.storage.setWithTTL("session",this.configKey,e,1800),e}}class Oa{constructor(){Salla.event.on("twilight::before.ready",()=>this.renderAll())}async renderAll(){Salla.hooks.renderAutoComponents([{hook:"product:single.description",tag:"salla-delivery-promise",canRender:()=>Salla.url.is_page("product.single")&&Salla.config.get("store.features",[]).includes("delivery-promises")},{hook:"product:single.description",tag:"salla-loyalty-banner",canRender:()=>Salla.url.is_page("product.single")&&Salla.config.get("store.features",[]).includes("loyalty-system")},{hook:"product:single.description",tag:"salla-loyalty-points-banner",canRender:()=>Salla.url.is_page("product.single")&&Salla.config.get("store.features",[]).includes("loyalty-system")},{hook:"product:single.description",tag:"salla-cashback-banner",canRender:()=>Salla.url.is_page("product.single")},{hook:"product:single.form.end",tag:"salla-fulfillment-methods",canRender:()=>Salla.url.is_page("product.single")&&Salla.config.get("store.features",[]).includes("delivery-promises")},{hook:"body:end",tag:"salla-cookies-bar",canRender:()=>{var e;return null==(e=Salla.config.get("store.features"))?void 0:e.includes("website-cookies")}},{hook:"body:end",tag:"salla-bullet-delivery",canRender:()=>{var e;return(null==(e=Salla.config.get("store.features"))?void 0:e.includes("bullet-delivery-v2"))&&!0===Salla.config.get("store.settings.bullet_delivery.enabled")}},{hook:"product:single.description.end",tag:"salla-bought-together",canRender:()=>Salla.url.is_page("product.single")&&Salla.config.get("store.settings.product.bought_together")},{hook:"customer:wishlist.items.start",tag:"salla-wishlist-actions",canRender:()=>Salla.url.is_page("customer.wishlist")},{hook:"customer:orders.single.details.start",tag:"salla-order-cancel",canRender:()=>Salla.url.is_page("customer.orders.single")}]),await Salla.lang.onLoaded(),this.renderAppInstall(),this.renderEdit(),this.applyContentCopyright(),this.renderTemplateStore(),Salla.helpers.isIframe()||(this.renderMaintenance(),this.renderThemePreview())}renderMaintenance(){Salla.config.get("maintenance")&&(document.body.classList.add("has-maintenance-bar"),document.querySelector("salla-maintenance-alert")?Salla.logger.warn("salla-maintenance-alert element Existed before!"):document.body.prepend(document.createElement("salla-maintenance-alert")))}renderTemplateStore(){Salla.config.get("store.template")&&(document.body.classList.add("has-bottom-alert"),document.querySelector("salla-bottom-alert")?Salla.logger.warn("salla-bottom-alert element Existed before!"):document.body.append(document.createElement("salla-bottom-alert")))}renderAppInstall(){Salla.config.get("store.app_install_prompt")&&Salla.config.get("store.apps")&&!Salla.storage.get("app_install_prompt_disabled")&&!Salla.config.isMobileApp()&&(document.body.classList.add("has-app-install-alert"),document.querySelector("salla-app-install-alert")?Salla.logger.warn("salla-app-install-alert element Existed before!"):document.body.append(document.createElement("salla-app-install-alert")))}renderThemePreview(){if("preview"!==Salla.config.get("theme.mode"))return;if(document.body.classList.add("has-preview-bar"),document.querySelector("#s-theme_preview_bar"))return void Salla.logger.warn("#s-theme_preview_bar element Existed before!");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://cdn.salla.network/images/logo/logo-light.svg">\n <span style="margin:0 10px;">${Salla.lang.get("blocks.header.preview_mode")}: <span style="background:rgba(255,255,255,0.25);border-radius:15px; padding:2px 15px 4px">${Salla.config.get("theme.name")}</span></span>\n </div>\n <a href="${Salla.url.get("preview_theme/cancel/preview")}" style="line-height:32px; width:32px;"><i class="sicon-cancel"></i></a>\n `,document.body.prepend(e)}renderEdit(){let e=Salla.config.get("edit");if(!e)return;if(document.querySelector("#s-edit-alert"))return void Salla.logger.warn("#s-edit-alert element Existed before!");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)}applyContentCopyright(){if(!Salla.config.get("store.settings.content_copyright"))return;["contextmenu","selectstart","copy"].forEach(e=>{document.addEventListener(e,e=>{(e=>{var t;if(!e)return!1;const r=null==(t=e.tagName)?void 0:t.toLowerCase();return"input"===r||"textarea"===r})(e.target)||e.preventDefault()})}),document.addEventListener("keydown",e=>{const t=e.key.toLowerCase();("f12"===t||e.ctrlKey&&e.shiftKey&&["i","j","c"].includes(t)||e.ctrlKey&&"u"===t)&&(e.preventDefault(),e.stopPropagation())});const e=document.createElement("style");e.textContent="\n body {\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n }\n input, textarea {\n -webkit-touch-callout: auto;\n -webkit-user-select: auto;\n -moz-user-select: auto;\n -ms-user-select: auto;\n user-select: auto;\n }\n img {\n pointer-events: none;\n -webkit-user-drag: none;\n }\n ",document.head.appendChild(e)}}class Ba{constructor(e){this.storeUserKey="s-store-user",Salla.event.on("twilight::initiated",()=>this.embedStoreUser()),this.embedUser(e)}embedUser(e){return e.user||(e.user=this.getUser(),e.user.language_code=Salla.cookie.get("s-lang",e.user.language_code),e.user.currency_code=Salla.cookie.get("s-curr",e.user.currency_code)),e}getUser(){return Salla.storage.get("user",this.getDefaultUser())}getDefaultUser(){return{type:"guest",language_code:Salla.cookie.get("s-lang",Salla.lang.getLocale()),currency_code:Salla.cookie.get("s-curr","SAR")}}async embedStoreUser(){if(Salla.config.isGuest())return;let e=Salla.storage.getWithTTL("session",this.storeUserKey);e||(e=await this.getStoreUserFromApi()),Salla.config.set("user",Br({},Salla.config.get("user"),e)),Salla.log("Store user is embeded to the user object.")}async getStoreUserFromApi(){let e={};try{const t=await Salla.api.request("profile/notifications/unread");if(e.notification=t.data.count,e.is_notifiable=t.data.is_notifiable,Salla.config.get("store.features",[]).includes("loyalty-system")){const t=await Salla.api.request("profile/loyalty/points");t&&(e.loyalty_points=t.data.points)}}catch(e){Salla.log("Failed to get user services",e)}return Salla.storage.setWithTTL("session",this.storeUserKey,e,300),e}}class ja{constructor(){const e={fbclid:"facebook",gad_source:"google",ttclid:"tiktok",twclid:"twitter",scid:"snapchat",sccid:"snapchat"},t=Object.keys(e),r=["utm_source","utm_medium","utm_campaign","utm_term","utm_content",...t],n={},i={};this.extractQueryPairs(window.location.search).filter(([e])=>r.includes(e.toLowerCase())).forEach(([e,t])=>{n[e.toLowerCase()]=this.sanitizeValue(t||"")});const o=t.find(e=>n[e]);!n.utm_source&&o&&(n.utm_source=e[o],n.utm_campaign=n.utm_campaign||`Using the CLICKID ${o} provided by ${n.utm_source}`,n.utm_term=n.utm_term||`${o}: ${n[o]}`),n.utm_source&&(Object.entries(n).filter(([e])=>!t.includes(e)).forEach(([e,t])=>{i[`s-${e.replace("_","-")}`]=t}),i["s-utm-referrer"]=document.referrer,Salla.storage.setWithTTL("s-utms",i,129600),this.logUTMVisitData(i))}extractQueryPairs(e){if(!e)return[];try{if("undefined"!=typeof URLSearchParams)return Array.from(new URLSearchParams(e).entries()).map(([e,t])=>[e,this.decodeQueryValue(t)])}catch(e){Salla.log("Error parsing UTM params:",e)}return e.replace(/^\?/,"").split("&").filter(Boolean).map(e=>{const t=e.indexOf("=");return(-1===t?[e,""]:[e.slice(0,t),e.slice(t+1)]).map(e=>this.decodeMalformedURIComponent(e||"").decoded||"")})}decodeQueryValue(e){return e&&e.includes("%")?this.decodeMalformedURIComponent(e).decoded||"":e}decodeMalformedURIComponent(e){const t={raw:e,decoded:null,status:"valid",issues:[]};if(!/[+%]/.test(e))return t.decoded=e,t;const r=[];let n="";const i=()=>{if(!n.length)return;const e=this.encodeText(n);for(const t of e)r.push(t);n=""};for(let o=0;o<e.length;o++){const a=e[o];if("%"===a){const a=e.slice(o+1,o+3);if(/^[0-9A-Fa-f]{2}$/.test(a)){i(),r.push(parseInt(a,16)),o+=2;continue}t.issues.push(`invalid_percent_at_${o}`),n+="%"}else n+="+"===a?" ":a}return i(),t.decoded=this.decodeText(r),t.decoded.includes("�")&&t.issues.push("invalid_or_incomplete_utf8_sequence"),t.issues.length&&(t.status="repaired"),t}encodeText(e){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);const t=[];for(let r=0;r<e.length;r++){const n=e.codePointAt(r);n>65535&&(r+=1),n<128?t.push(n):n<2048?t.push(192|n>>6,128|63&n):n<65536?t.push(224|n>>12,128|n>>6&63,128|63&n):t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n)}return t}decodeText(e){if("undefined"!=typeof TextDecoder)return new TextDecoder("utf-8",{fatal:!1}).decode(new Uint8Array(e));let t="";const r=e=>128==(192&e);for(let n=0;n<e.length;n++){const i=e[n];i<128?t+=String.fromCharCode(i):i>=194&&i<=223&&r(e[n+1])?(t+=String.fromCharCode((31&i)<<6|63&e[n+1]),n+=1):i>=224&&i<=239&&r(e[n+1])&&r(e[n+2])?(t+=String.fromCharCode((15&i)<<12|(63&e[n+1])<<6|63&e[n+2]),n+=2):i>=240&&i<=244&&r(e[n+1])&&r(e[n+2])&&r(e[n+3])?(t+=String.fromCodePoint((7&i)<<18|(63&e[n+1])<<12|(63&e[n+2])<<6|63&e[n+3]),n+=3):t+="�"}return t}sanitizeValue(e){return e.replace(/(?:[\0-\x1F!-,\.\/:-@\[-`\{-\xA9\xAB-\xB1\xB4\xB6-\xB8\xBB\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u036F\u0375\u0378\u0379\u037E\u0380-\u0385\u0387\u038B\u038D\u03A2\u03F6\u0482-\u0489\u0530\u0557\u0558\u055A-\u055F\u0589-\u05CF\u05EB-\u05EE\u05F3-\u061F\u064B-\u065F\u066A-\u066D\u0670\u06D4\u06D6-\u06E4\u06E7-\u06ED\u06FD\u06FE\u0700-\u070F\u0711\u0730-\u074C\u07A6-\u07B0\u07B2-\u07BF\u07EB-\u07F3\u07F6-\u07F9\u07FB-\u07FF\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u083F\u0859-\u085F\u086B-\u086F\u0888\u0890-\u089F\u08CA-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962-\u0965\u0970\u0981-\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA-\u09BC\u09BE-\u09CD\u09CF-\u09DB\u09DE\u09E2-\u09E5\u09F2\u09F3\u09FA\u09FB\u09FD-\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A-\u0A58\u0A5D\u0A5F-\u0A65\u0A70\u0A71\u0A75-\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA-\u0ABC\u0ABE-\u0ACF\u0AD1-\u0ADF\u0AE2-\u0AE5\u0AF0-\u0AF8\u0AFA-\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A-\u0B3C\u0B3E-\u0B5B\u0B5E\u0B62-\u0B65\u0B70\u0B78-\u0B82\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BBA-\u0BCF\u0BD1-\u0BE5\u0BF3-\u0C04\u0C0D\u0C11\u0C29\u0C3A-\u0C3C\u0C3E-\u0C57\u0C5B\u0C5E\u0C5F\u0C62-\u0C65\u0C70-\u0C77\u0C7F\u0C81-\u0C84\u0C8D\u0C91\u0CA9\u0CB4\u0CBA-\u0CBC\u0CBE-\u0CDB\u0CDF\u0CE2-\u0CE5\u0CF0\u0CF3-\u0D03\u0D0D\u0D11\u0D3B\u0D3C\u0D3E-\u0D4D\u0D4F-\u0D53\u0D57\u0D62-\u0D65\u0D79\u0D80-\u0D84\u0D97-\u0D99\u0DB2\u0DBC\u0DBE\u0DBF\u0DC7-\u0DE5\u0DF0-\u0E00\u0E31\u0E34-\u0E3F\u0E47-\u0E4F\u0E5A-\u0E80\u0E83\u0E85\u0E8B\u0EA4\u0EA6\u0EB1\u0EB4-\u0EBC\u0EBE\u0EBF\u0EC5\u0EC7-\u0ECF\u0EDA\u0EDB\u0EE0-\u0EFF\u0F01-\u0F1F\u0F34-\u0F3F\u0F48\u0F6D-\u0F87\u0F8D-\u0FFF\u102B-\u103E\u104A-\u104F\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109F\u10C6\u10C8-\u10CC\u10CE\u10CF\u10FB\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B-\u1368\u137D-\u137F\u1390-\u139F\u13F6\u13F7\u13FE-\u1400\u166D\u166E\u1680\u169B-\u169F\u16EB-\u16ED\u16F9-\u16FF\u1712-\u171E\u1732-\u173F\u1752-\u175F\u176D\u1771-\u177F\u17B4-\u17D6\u17D8-\u17DB\u17DD-\u17DF\u17EA-\u17EF\u17FA-\u180F\u181A-\u181F\u1879-\u187F\u1885\u1886\u18A9\u18AB-\u18AF\u18F6-\u18FF\u191F-\u1945\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19CF\u19DB-\u19FF\u1A17-\u1A1F\u1A55-\u1A7F\u1A8A-\u1A8F\u1A9A-\u1AA6\u1AA8-\u1B04\u1B34-\u1B44\u1B4D-\u1B4F\u1B5A-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BFF\u1C24-\u1C3F\u1C4A-\u1C4C\u1C7E\u1C7F\u1C8B-\u1C8F\u1CBB\u1CBC\u1CC0-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1CFB-\u1CFF\u1DC0-\u1DFF\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FBD\u1FBF-\u1FC1\u1FC5\u1FCD-\u1FCF\u1FD4\u1FD5\u1FDC-\u1FDF\u1FED-\u1FF1\u1FF5\u1FFD-\u206F\u2072\u2073\u207A-\u207E\u208A-\u208F\u209D-\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A-\u245F\u249C-\u24E9\u2500-\u2775\u2794-\u2BFF\u2CE5-\u2CEA\u2CEF-\u2CF1\u2CF4-\u2CFC\u2CFE\u2CFF\u2D26\u2D28-\u2D2C\u2D2E\u2D2F\u2D68-\u2D6E\u2D70-\u2D7F\u2D97-\u2D9F\u2DA7\u2DAF\u2DB7\u2DBF\u2DC7\u2DCF\u2DD7\u2DDF-\u2E2E\u2E30-\u3004\u3008-\u3020\u302A-\u3030\u3036\u3037\u303D-\u3040\u3097-\u309C\u30A0\u30FB\u3100-\u3104\u3130\u318F-\u3191\u3196-\u319F\u31C0-\u31EF\u3200-\u321F\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA48D-\uA4CF\uA4FE\uA4FF\uA60D-\uA60F\uA62C-\uA63F\uA66F-\uA67E\uA69E\uA69F\uA6F0-\uA716\uA720\uA721\uA789\uA78A\uA7DD-\uA7F0\uA802\uA806\uA80B\uA823-\uA82F\uA836-\uA83F\uA874-\uA881\uA8B4-\uA8CF\uA8DA-\uA8F1\uA8F8-\uA8FA\uA8FC\uA8FF\uA926-\uA92F\uA947-\uA95F\uA97D-\uA983\uA9B3-\uA9CE\uA9DA-\uA9DF\uA9E5\uA9FF\uAA29-\uAA3F\uAA43\uAA4C-\uAA4F\uAA5A-\uAA5F\uAA77-\uAA79\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAC3-\uAADA\uAADE\uAADF\uAAEB-\uAAF1\uAAF5-\uAB00\uAB07\uAB08\uAB0F\uAB10\uAB17-\uAB1F\uAB27\uAB2F\uAB5B\uAB6A-\uAB6F\uABE3-\uABEF\uABFA-\uABFF\uD7A4-\uD7AF\uD7C7-\uD7CA\uD7FC-\uD7FF\uE000-\uF8FF\uFA6E\uFA6F\uFADA-\uFAFF\uFB07-\uFB12\uFB18-\uFB1C\uFB1E\uFB29\uFB37\uFB3D\uFB3F\uFB42\uFB45\uFBB2-\uFBD2\uFD3E-\uFD4F\uFD90\uFD91\uFDC8-\uFDEF\uFDFC-\uFE6F\uFE75\uFEFD-\uFF0F\uFF1A-\uFF20\uFF3B-\uFF40\uFF5B-\uFF65\uFFBF-\uFFC1\uFFC8\uFFC9\uFFD0\uFFD1\uFFD8\uFFD9\uFFDD-\uFFFF]|\uD800[\uDC0C\uDC27\uDC3B\uDC3E\uDC4E\uDC4F\uDC5E-\uDC7F\uDCFB-\uDD06\uDD34-\uDD3F\uDD79-\uDD89\uDD8C-\uDE7F\uDE9D-\uDE9F\uDED1-\uDEE0\uDEFC-\uDEFF\uDF24-\uDF2C\uDF4B-\uDF4F\uDF76-\uDF7F\uDF9E\uDF9F\uDFC4-\uDFC7\uDFD0\uDFD6-\uDFFF]|\uD801[\uDC9E\uDC9F\uDCAA-\uDCAF\uDCD4-\uDCD7\uDCFC-\uDCFF\uDD28-\uDD2F\uDD64-\uDD6F\uDD7B\uDD8B\uDD93\uDD96\uDDA2\uDDB2\uDDBA\uDDBD-\uDDBF\uDDF4-\uDDFF\uDF37-\uDF3F\uDF56-\uDF5F\uDF68-\uDF7F\uDF86\uDFB1\uDFBB-\uDFFF]|\uD802[\uDC06\uDC07\uDC09\uDC36\uDC39-\uDC3B\uDC3D\uDC3E\uDC56\uDC57\uDC77\uDC78\uDC9F-\uDCA6\uDCB0-\uDCDF\uDCF3\uDCF6-\uDCFA\uDD1C-\uDD1F\uDD3A-\uDD3F\uDD5A-\uDD7F\uDDB8-\uDDBB\uDDD0\uDDD1\uDE01-\uDE0F\uDE14\uDE18\uDE36-\uDE3F\uDE49-\uDE5F\uDE7F\uDEA0-\uDEBF\uDEC8\uDEE5-\uDEEA\uDEF0-\uDEFF\uDF36-\uDF3F\uDF56\uDF57\uDF73-\uDF77\uDF92-\uDFA8\uDFB0-\uDFFF]|\uD803[\uDC49-\uDC7F\uDCB3-\uDCBF\uDCF3-\uDCF9\uDD24-\uDD2F\uDD3A-\uDD3F\uDD66-\uDD6E\uDD86-\uDE5F\uDE7F\uDEAA-\uDEAF\uDEB2-\uDEC1\uDEC8-\uDEFF\uDF28-\uDF2F\uDF46-\uDF50\uDF55-\uDF6F\uDF82-\uDFAF\uDFCC-\uDFDF\uDFF7-\uDFFF]|\uD804[\uDC00-\uDC02\uDC38-\uDC51\uDC70\uDC73\uDC74\uDC76-\uDC82\uDCB0-\uDCCF\uDCE9-\uDCEF\uDCFA-\uDD02\uDD27-\uDD35\uDD40-\uDD43\uDD45\uDD46\uDD48-\uDD4F\uDD73-\uDD75\uDD77-\uDD82\uDDB3-\uDDC0\uDDC5-\uDDCF\uDDDB\uDDDD-\uDDE0\uDDF5-\uDDFF\uDE12\uDE2C-\uDE3E\uDE41-\uDE7F\uDE87\uDE89\uDE8E\uDE9E\uDEA9-\uDEAF\uDEDF-\uDEEF\uDEFA-\uDF04\uDF0D\uDF0E\uDF11\uDF12\uDF29\uDF31\uDF34\uDF3A-\uDF3C\uDF3E-\uDF4F\uDF51-\uDF5C\uDF62-\uDF7F\uDF8A\uDF8C\uDF8D\uDF8F\uDFB6\uDFB8-\uDFD0\uDFD2\uDFD4-\uDFFF]|\uD805[\uDC35-\uDC46\uDC4B-\uDC4F\uDC5A-\uDC5E\uDC62-\uDC7F\uDCB0-\uDCC3\uDCC6\uDCC8-\uDCCF\uDCDA-\uDD7F\uDDAF-\uDDD7\uDDDC-\uDDFF\uDE30-\uDE43\uDE45-\uDE4F\uDE5A-\uDE7F\uDEAB-\uDEB7\uDEB9-\uDEBF\uDECA-\uDECF\uDEE4-\uDEFF\uDF1B-\uDF2F\uDF3C-\uDF3F\uDF47-\uDFFF]|\uD806[\uDC2C-\uDC9F\uDCF3-\uDCFE\uDD07\uDD08\uDD0A\uDD0B\uDD14\uDD17\uDD30-\uDD3E\uDD40\uDD42-\uDD4F\uDD5A-\uDD9F\uDDA8\uDDA9\uDDD1-\uDDE0\uDDE2\uDDE4-\uDDFF\uDE01-\uDE0A\uDE33-\uDE39\uDE3B-\uDE4F\uDE51-\uDE5B\uDE8A-\uDE9C\uDE9E-\uDEAF\uDEF9-\uDFBF\uDFE1-\uDFEF\uDFFA-\uDFFF]|\uD807[\uDC09\uDC2F-\uDC3F\uDC41-\uDC4F\uDC6D-\uDC71\uDC90-\uDCFF\uDD07\uDD0A\uDD31-\uDD45\uDD47-\uDD4F\uDD5A-\uDD5F\uDD66\uDD69\uDD8A-\uDD97\uDD99-\uDD9F\uDDAA-\uDDAF\uDDDC-\uDDDF\uDDEA-\uDEDF\uDEF3-\uDF01\uDF03\uDF11\uDF34-\uDF4F\uDF5A-\uDFAF\uDFB1-\uDFBF\uDFD5-\uDFFF]|\uD808[\uDF9A-\uDFFF]|\uD809[\uDC6F-\uDC7F\uDD44-\uDFFF]|[\uD80A\uD812-\uD817\uD819\uD824-\uD82A\uD82D\uD82E\uD830-\uD832\uD836\uD83D\uD83F\uD87C\uD87D\uD87F\uD88E-\uDBFF][\uDC00-\uDFFF]|\uD80B[\uDC00-\uDF8F\uDFF1-\uDFFF]|\uD80D[\uDC30-\uDC40\uDC47-\uDC5F]|\uD810[\uDFFB-\uDFFF]|\uD811[\uDE47-\uDFFF]|\uD818[\uDC00-\uDCFF\uDD1E-\uDD2F\uDD3A-\uDFFF]|\uD81A[\uDE39-\uDE3F\uDE5F\uDE6A-\uDE6F\uDEBF\uDECA-\uDECF\uDEEE-\uDEFF\uDF30-\uDF3F\uDF44-\uDF4F\uDF5A\uDF62\uDF78-\uDF7C\uDF90-\uDFFF]|\uD81B[\uDC00-\uDD3F\uDD6D-\uDD6F\uDD7A-\uDE3F\uDE97-\uDE9F\uDEB9\uDEBA\uDED4-\uDEFF\uDF4B-\uDF4F\uDF51-\uDF92\uDFA0-\uDFDF\uDFE2\uDFE4-\uDFF1\uDFF7-\uDFFF]|\uD823[\uDCD6-\uDCFE\uDD1F-\uDD7F\uDDF3-\uDFFF]|\uD82B[\uDC00-\uDFEF\uDFF4\uDFFC\uDFFF]|\uD82C[\uDD23-\uDD31\uDD33-\uDD4F\uDD53\uDD54\uDD56-\uDD63\uDD68-\uDD6F\uDEFC-\uDFFF]|\uD82F[\uDC6B-\uDC6F\uDC7D-\uDC7F\uDC89-\uDC8F\uDC9A-\uDFFF]|\uD833[\uDC00-\uDCEF\uDCFA-\uDFFF]|\uD834[\uDC00-\uDEBF\uDED4-\uDEDF\uDEF4-\uDF5F\uDF79-\uDFFF]|\uD835[\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3\uDFCC\uDFCD]|\uD837[\uDC00-\uDEFF\uDF1F-\uDF24\uDF2B-\uDFFF]|\uD838[\uDC00-\uDC2F\uDC6E-\uDCFF\uDD2D-\uDD36\uDD3E\uDD3F\uDD4A-\uDD4D\uDD4F-\uDE8F\uDEAE-\uDEBF\uDEEC-\uDEEF\uDEFA-\uDFFF]|\uD839[\uDC00-\uDCCF\uDCEC-\uDCEF\uDCFA-\uDDCF\uDDEE\uDDEF\uDDFB-\uDEBF\uDEDF\uDEE3\uDEE6\uDEEE\uDEEF\uDEF5-\uDEFD\uDF00-\uDFDF\uDFE7\uDFEC\uDFEF\uDFFF]|\uD83A[\uDCC5\uDCC6\uDCD0-\uDCFF\uDD44-\uDD4A\uDD4C-\uDD4F\uDD5A-\uDFFF]|\uD83B[\uDC00-\uDC70\uDCAC\uDCB0\uDCB5-\uDD00\uDD2E\uDD3E-\uDDFF\uDE04\uDE20\uDE23\uDE25\uDE26\uDE28\uDE33\uDE38\uDE3A\uDE3C-\uDE41\uDE43-\uDE46\uDE48\uDE4A\uDE4C\uDE50\uDE53\uDE55\uDE56\uDE58\uDE5A\uDE5C\uDE5E\uDE60\uDE63\uDE65\uDE66\uDE6B\uDE73\uDE78\uDE7D\uDE7F\uDE8A\uDE9C-\uDEA0\uDEA4\uDEAA\uDEBC-\uDFFF]|\uD83C[\uDC00-\uDCFF\uDD0D-\uDFFF]|\uD83E[\uDC00-\uDFEF\uDFFA-\uDFFF]|\uD869[\uDEE0-\uDEFF]|\uD86E[\uDC1E\uDC1F]|\uD873[\uDEAE\uDEAF]|\uD87A[\uDFE1-\uDFEF]|\uD87B[\uDE5E-\uDFFF]|\uD87E[\uDE1E-\uDFFF]|\uD884[\uDF4B-\uDF4F]|\uD88D[\uDC7A-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/g," ").replace(/ +/g," ").trim()}async logUTMVisitData(e){const t=e["s-utm-source"],r=e["s-utm-medium"],n=e["s-utm-campaign"],i=Salla.config.get("store.id");e&&"affiliate"===t&&r&&n&&fetch(Salla.config.get("affiliate.utm_url"),{method:"POST",mode:"cors",headers:{"Content-Type":"application/json","s-utm-source":t,"s-utm-medium":r,"s-utm-campaign":n,"s-store-id":i}}).then(e=>{if(!e.ok)return;const t=new URL(window.location.href),r=window.history.state;t.searchParams.delete("utm_source"),t.searchParams.delete("utm_medium"),t.searchParams.delete("utm_campaign"),window.history.replaceState(r,"",t)})}}class Ta{constructor(e){var t,r,n,i;if("ready"===Salla.status)return void Salla.log("Trying to re-initiate Salla, while its status === 'ready'!");if(null==e||null==(t=e.store)||!t.id)return console.error("Trying to init Twilight without store.id!"),void console.log("you can initiate twilight using this line only: Salla.init({store:{id:1234}})");(Salla.config.merge(e),!["salla.sa","salla.group"].includes(location.hostname)||null!=(r=Salla.config.get("store.url"))&&r.includes(location.hostname)||!Salla.config.get("store.username")||Salla.config.set("store.url",window.location.origin+"/"+Salla.config.get("store.username")),(null==e?void 0:e.events)&&Salla.event.dispatchEvents(null==e?void 0:e.events),new Oa,new Ba(e),null!=e&&null!=(n=e.user)&&n.language_code)&&Salla.lang.setLocale(null==e||null==(i=e.user)?void 0:i.language_code);Salla.storage.get("scope.id")!=Salla.config.get("store.scope.id")&&Salla.storage.set("scope",Salla.config.get("store.scope",Salla.config.get("scope")));const o=Salla.storage.get("cart");null!=o&&o.id&&"string"!=typeof o.id&&String(o.id).length>15&&Salla.cart.reset(),new Ia(e).getConfig().then(e=>{Salla.config.merge(e),this.setSallaReady(e),this.afterInit()}).catch(e=>console.error("failed to initite twilight😢",e))}afterInit(){Salla.url.is_page("product.single")&&Salla.config.isGuest()&&window.addEventListener("mini-checkout::before-init",e=>{Salla.config.isGuest()&&(e.preventDefault(),Salla.event.emit("login::open"))})}setSallaReady(e){new ja,Salla.event.emitAsync("twilight::before.ready",e),Salla.status="ready",Salla.event.dispatch("twilight::initiated",e),window.dispatchEvent(new CustomEvent("twilight::initiated",{detail:e}))}}var Ra=Object.defineProperty,La=Object.defineProperties,Na=Object.getOwnPropertyDescriptors,Ua=Object.getOwnPropertySymbols,qa=Object.prototype.hasOwnProperty,za=Object.prototype.propertyIsEnumerable,$a=(e,t,r)=>t in e?Ra(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ma=(e,t)=>{for(var r in t||(t={}))qa.call(t,r)&&$a(e,r,t[r]);if(Ua)for(var r of Ua(t))za.call(t,r)&&$a(e,r,t[r]);return e},Ha=(e,t)=>La(e,Na(t)),Wa=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{s(r.next(e))}catch(e){i(e)}},a=e=>{try{s(r.throw(e))}catch(e){i(e)}},s=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,a);s((r=r.apply(e,t)).next())});function Ga(e,t,r,n,i){for(t=t.split?t.split("."):t,n=0;n<t.length;n++)e=e?e[t[n]]:i;return e===i?r:e}var Ja="undefined",Va="object",Ka="undefined"!=typeof process?process:{};Ka.env&&Ka.env.NODE_ENV;var Qa="undefined"!=typeof document;function Xa(e,t){return t.charAt(0)[e]()+t.slice(1)}null!=Ka.versions&&Ka.versions.node,"undefined"!=typeof Deno&&Deno.core,Qa&&"nodejs"===window.name||"undefined"!=typeof navigator&&void 0!==navigator.userAgent&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));var Ya=Xa.bind(null,"toUpperCase"),Za=Xa.bind(null,"toLowerCase");function es(e){return ss(e)?Ya("null"):"object"==typeof e?function(e){return ns(e.constructor)?e.constructor.name:null}(e):Object.prototype.toString.call(e).slice(8,-1)}function ts(e,t){void 0===t&&(t=!0);var r=es(e);return t?Za(r):r}function rs(e,t){return typeof t===e}var ns=rs.bind(null,"function"),is=rs.bind(null,"string"),os=rs.bind(null,"undefined"),as=rs.bind(null,"boolean");function ss(e){return null===e}function us(e){if(!function(e){return e&&("object"==typeof e||null!==e)}(e))return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function ls(e){return e instanceof Error||is(e.message)&&e.constructor&&function(e){return"number"===ts(e)&&!isNaN(e)}(e.constructor.stackTraceLimit)}function cs(e,t){if("object"!=typeof t||ss(t))return!1;if(t instanceof e)return!0;var r=ts(new e(""));if(ls(t))for(;t;){if(ts(t)===r)return!0;t=Object.getPrototypeOf(t)}return!1}function ds(e,t){var r=e instanceof Element||e instanceof HTMLDocument;return r&&t?function(e,t){return void 0===t&&(t=""),e&&e.nodeName===t.toUpperCase()}(e,t):r}function hs(e){var t=[].slice.call(arguments,1);return function(){return e.apply(void 0,[].slice.call(arguments).concat(t))}}function ps(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function fs(e,t,r){for(var n=t.length-1,i=0;i<n;++i){var o=t[i];if("__proto__"===o||"constructor"===o)break;o in e||(e[o]={}),e=e[o]}e[t[n]]=r}function gs(){for(var e="",t=0,r=4294967295*Math.random()|0;t++<36;){var n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[t-1],i=15&r;e+="-"==n||"4"==n?n:("x"==n?i:3&i|8).toString(16),r=t%8==0?4294967295*Math.random()|0:r>>4}return e}rs.bind(null,"symbol"),cs.bind(null,TypeError),cs.bind(null,SyntaxError),hs(ds,"form"),hs(ds,"button"),hs(ds,"input"),hs(ds,"select");var ms="global",vs="__global__",ys=typeof self===Va&&self.self===self&&self||typeof global===Va&&global.global===global&&global||void 0;function Ds(e){return ys[vs][e]}function bs(e,t){return ys[vs][e]=t}function Fs(e){delete ys[vs][e]}function ws(e,t,r){var n;try{if(Ss(e)){var i=window[e];n=i[t].bind(i)}}catch(e){}return n||r}ys[vs]||(ys[vs]={});var Es={};function Ss(e){if(typeof Es[e]!==Ja)return Es[e];try{var t=window[e];t.setItem(Ja,Ja),t.removeItem(Ja)}catch(t){return Es[e]=!1}return Es[e]=!0}function _s(){return _s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},_s.apply(this,arguments)}var As="function",Cs="undefined",ks="@@redux/"+Math.random().toString(36),xs=typeof Symbol===As&&Symbol.observable||"@@observable",Ps=" != "+As;function Is(e,t,r){var n;if(typeof t===As&&typeof r===Cs&&(r=t,t=void 0),typeof r!==Cs){if(typeof r!==As)throw new Error("enhancer"+Ps);return r(Is)(e,t)}if(typeof e!==As)throw new Error("reducer"+Ps);var i=e,o=t,a=[],s=a,u=!1;function l(){s===a&&(s=a.slice())}function c(){return o}function d(e){if(typeof e!==As)throw new Error("Listener"+Ps);var t=!0;return l(),s.push(e),function(){if(t){t=!1,l();var r=s.indexOf(e);s.splice(r,1)}}}function h(e){if(!us(e))throw new Error("Act != obj");if(typeof e.type===Cs)throw new Error("ActType "+Cs);if(u)throw new Error("Dispatch in reducer");try{u=!0,o=i(o,e)}finally{u=!1}for(var t=a=s,r=0;r<t.length;r++)(0,t[r])();return e}return h({type:"@@redux/INIT"}),(n={dispatch:h,subscribe:d,getState:c,replaceReducer:function(e){if(typeof e!==As)throw new Error("next reducer"+Ps);i=e,h({type:"@@redux/INIT"})}})[xs]=function(){var e,t=d;return(e={subscribe:function(e){if("object"!=typeof e)throw new TypeError("Observer != obj");function r(){e.next&&e.next(c())}return r(),{unsubscribe:t(r)}}})[xs]=function(){return this},e},n}function Os(e,t){var r=t&&t.type;return"action "+(r&&r.toString()||"?")+"reducer "+e+" returns "+Cs}function Bs(){var e=[].slice.call(arguments);return 0===e.length?function(e){return e}:1===e.length?e[0]:e.reduce(function(e,t){return function(){return e(t.apply(void 0,[].slice.call(arguments)))}})}function js(){var e=arguments;return function(t){return function(r,n,i){var o,a=t(r,n,i),s=a.dispatch,u={getState:a.getState,dispatch:function(e){return s(e)}};return o=[].slice.call(e).map(function(e){return e(u)}),_s({},a,{dispatch:s=Bs.apply(void 0,o)(a.dispatch)})}}}var Ts="__anon_id",Rs="__user_id",Ls="__user_traits",Ns="userId",Us="anonymousId",qs=["bootstrap","params","campaign","initializeStart","initialize","initializeEnd","ready","resetStart","reset","resetEnd","pageStart","page","pageEnd","pageAborted","trackStart","track","trackEnd","trackAborted","identifyStart","identify","identifyEnd","identifyAborted","userIdChanged","registerPlugins","enablePlugin","disablePlugin","online","offline","setItemStart","setItem","setItemEnd","setItemAborted","removeItemStart","removeItem","removeItemEnd","removeItemAborted"],zs=["name","EVENTS","config","loaded"],$s=qs.reduce(function(e,t){return e[t]=t,e},{registerPluginType:function(e){return"registerPlugin:"+e},pluginReadyType:function(e){return"ready:"+e}}),Ms=/^utm_/,Hs=/^an_prop_/,Ws=/^an_trait_/;function Gs(e){var t=e.storage.setItem;return function(r){return function(n){return function(i){if(i.type===$s.bootstrap){var o=i.params,a=i.user,s=i.persistedUser,u=i.initialUser,l=s.userId===a.userId;s.anonymousId!==a.anonymousId&&t(Ts,a.anonymousId),l||t(Rs,a.userId),u.traits&&t(Ls,_s({},l&&s.traits?s.traits:{},u.traits));var c=Object.keys(i.params);if(c.length){var d=o.an_uid,h=o.an_event,p=c.reduce(function(e,t){if(t.match(Ms)||t.match(/^(d|g)clid/)){var r=t.replace(Ms,"");e.campaign["campaign"===r?"name":r]=o[t]}return t.match(Hs)&&(e.props[t.replace(Hs,"")]=o[t]),t.match(Ws)&&(e.traits[t.replace(Ws,"")]=o[t]),e},{campaign:{},props:{},traits:{}});r.dispatch(_s({type:$s.params,raw:o},p,d?{userId:d}:{})),d&&setTimeout(function(){return e.identify(d,p.traits)},0),h&&setTimeout(function(){return e.track(h,p.props)},0),Object.keys(p.campaign).length&&r.dispatch({type:$s.campaign,campaign:p.campaign})}}return n(i)}}}}function Js(e){return function(t,r){if(void 0===t&&(t={}),void 0===r&&(r={}),r.type===$s.setItemEnd){if(r.key===Ts)return _s({},t,{anonymousId:r.value});if(r.key===Rs)return _s({},t,{userId:r.value})}switch(r.type){case $s.identify:return Object.assign({},t,{userId:r.userId,traits:_s({},t.traits,r.traits)});case $s.reset:return[Rs,Ts,Ls].forEach(function(t){e.removeItem(t)}),Object.assign({},t,{userId:null,anonymousId:null,traits:{}});default:return t}}}function Vs(e){return{userId:e.getItem(Rs),anonymousId:e.getItem(Ts),traits:e.getItem(Ls)}}var Ks=function(e){return"__TEMP__"+e};function Qs(e){var t=e.storage,r=t.setItem,n=t.removeItem,i=t.getItem;return function(e){return function(t){return function(o){var a=o.userId,s=o.traits,u=o.options;if(o.type===$s.reset&&([Rs,Ls,Ts].forEach(function(e){n(e)}),[Ns,Us,"traits"].forEach(function(e){Fs(Ks(e))})),o.type===$s.identify){i(Ts)||r(Ts,gs());var l=i(Rs),c=i(Ls)||{};l&&l!==a&&e.dispatch({type:$s.userIdChanged,old:{userId:l,traits:c},new:{userId:a,traits:s},options:u}),a&&r(Rs,a),s&&r(Ls,_s({},c,s))}return t(o)}}}}var Xs={};function Ys(e,t){Xs[e]&&ns(Xs[e])&&(Xs[e](t),delete Xs[e])}function Zs(e,t,r){return new Promise(function(n,i){return t()?n(e):r<1?i(_s({},e,{queue:!0})):new Promise(function(e){return setTimeout(e,10)}).then(function(o){return Zs(e,t,r-10).then(n,i)})})}function eu(e){return{abort:e}}var tu=function(e){var t,r,n=e.data,i=e.action,o=e.instance,a=e.state,s=e.allPlugins,u=e.allMatches,l=e.store,c=e.EVENTS;try{var d=a.plugins,h=a.context,p=i.type,f=p.match(ru),g=n.exact.map(function(e){return e.pluginName});f&&(g=u.during.map(function(e){return e.pluginName}));var m=(t=o,r=g,function(e,n,i){var o=n.config,a=n.name,s=a+"."+e.type;i&&(s=i.event);var u,l,c,d,h,p=e.type.match(ru)?(u=a,l=s,c=r,d=i,h=e,function(e,t){var r=d?d.name:u,n=t&&du(t)?t:c;if(d&&(!(n=t&&du(t)?t:[u]).includes(u)||1!==n.length))throw new Error("Method "+l+" can only abort "+u+" plugin. "+JSON.stringify(n)+" input valid");return _s({},h,{abort:{reason:e,plugins:n,caller:l,_:r}})}):function(e,t){return function(){throw new Error(e.type+" action not cancellable. Remove abort in "+t)}}(e,s);return{payload:fu(e),instance:t,config:o||{},abort:p}}),v=n.exact.reduce(function(e,t){var r=t.pluginName,n=t.methodName,i=!1;return n.match(/^initialize/)||n.match(/^reset/)||(i=!d[r].loaded),h.offline&&n.match(/^(page|track|identify)/)&&(i=!0),e[""+r]=i,e},{});return Promise.resolve(n.exact.reduce(function(e,t,r){try{var a=t.pluginName;return Promise.resolve(e).then(function(e){function t(){return Promise.resolve(e)}var r=function(){if(n.namespaced&&n.namespaced[a])return Promise.resolve(n.namespaced[a].reduce(function(e,t,r){try{return Promise.resolve(e).then(function(e){return t.method&&ns(t.method)?(function(e,t){var r=pu(e);if(r&&r.name===t){var n=pu(r.method);throw new Error([t+" plugin is calling method "+e,"Plugins cant call self","Use "+r.method+" "+(n?"or "+n.method:"")+" in "+t+" plugin insteadof "+e].join("\n"))}}(t.methodName,t.pluginName),Promise.resolve(t.method({payload:e,instance:o,abort:(r=e,n=a,i=t.pluginName,function(e,t){return _s({},r,{abort:{reason:e,plugins:t||[n],caller:p,from:i||n}})}),config:au(t.pluginName,d,s),plugins:d})).then(function(t){var r=us(t)?t:{};return Promise.resolve(_s({},e,r))})):e;var r,n,i})}catch(e){return Promise.reject(e)}},Promise.resolve(i))).then(function(t){e[a]=t});e[a]=i}();return r&&r.then?r.then(t):t()})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(e){return Promise.resolve(n.exact.reduce(function(t,r,i){try{var a=n.exact.length===i+1,u=r.pluginName,c=s[u];return Promise.resolve(t).then(function(t){var r=e[u]?e[u]:{};if(f&&(r=t),lu(r,u))return ou({data:r,method:p,instance:o,pluginName:u,store:l}),Promise.resolve(t);if(lu(t,u))return a&&ou({data:t,method:p,instance:o,store:l}),Promise.resolve(t);if(v.hasOwnProperty(u)&&!0===v[u])return l.dispatch({type:"queue",plugin:u,payload:r,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(t);var n=m(e[u],s[u]);return Promise.resolve(c[p]({abort:n.abort,payload:r,instance:o,config:au(u,d,s),plugins:d})).then(function(n){var i=us(n)?n:{},a=_s({},t,i),s=e[u];if(lu(s,u))ou({data:s,method:p,instance:o,pluginName:u,store:l});else{var c=p+":"+u;(c.match(/:/g)||[]).length<2&&!p.match(nu)&&!p.match(iu)&&o.dispatch(_s({},f?a:r,{type:c,_:{called:c,from:"submethod"}}))}return Promise.resolve(a)})})}catch(e){return Promise.reject(e)}},Promise.resolve(i))).then(function(e){if(!(p.match(ru)||p.match(/^registerPlugin/)||p.match(iu)||p.match(nu)||p.match(/^params/)||p.match(/^userIdChanged/))){if(c.plugins.includes(p),e._&&e._.originalAction===p)return e;var t=_s({},e,{_:{originalAction:e.type,called:e.type,from:"engineEnd"}});cu(e,n.exact.length)&&!p.match(/End$/)&&(t=_s({},t,{type:e.type+"Aborted"})),l.dispatch(t)}return e})})}catch(t){return Promise.reject(t)}},ru=/Start$/,nu=/^bootstrap/,iu=/^ready/;function ou(e){var t=e.pluginName,r=e.method+"Aborted"+(t?":"+t:"");e.store.dispatch(_s({},e.data,{type:r,_:{called:r,from:"abort"}}))}function au(e,t,r){var n=t[e]||r[e];return n&&n.config?n.config:{}}function su(e,t){return t.reduce(function(t,r){return r[e]?t.concat({methodName:e,pluginName:r.name,method:r[e]}):t},[])}function uu(e,t){var r=e.replace(ru,""),n=t?":"+t:"";return[""+e+n,""+r+n,r+"End"+n]}function lu(e,t){var r=e.abort;return!!r&&(!0===r||hu(r,t)||r&&hu(r.plugins,t))}function cu(e,t){var r=e.abort;if(!r)return!1;if(!0===r||is(r))return!0;var n=r.plugins;return du(r)&&r.length===t||du(n)&&n.length===t}function du(e){return Array.isArray(e)}function hu(e,t){return!(!e||!du(e))&&e.includes(t)}function pu(e){var t=e.match(/(.*):(.*)/);return!!t&&{method:t[1],name:t[2]}}function fu(e){return Object.keys(e).reduce(function(t,r){return"type"===r||(t[r]=us(e[r])?Object.assign({},e[r]):e[r]),t},{})}function gu(e,t,r){var n={};return function(i){return function(o){return function(a){try{var s,u=function(e){return s?e:o(d)},l=a.type,c=a.plugins,d=a;if(a.abort)return Promise.resolve(o(a));if(l===$s.enablePlugin&&i.dispatch({type:$s.initializeStart,plugins:c,disabled:[],fromEnable:!0,meta:a.meta}),l===$s.disablePlugin&&setTimeout(function(){return Ys(a.meta.rid,{payload:a})},0),l===$s.initializeEnd){var h=t(),p=Object.keys(h),f=p.filter(function(e){return c.includes(e)}).map(function(e){return h[e]}),g=[],m=[],v=a.disabled,y=f.map(function(e){var t=e.loaded,r=e.name,o=e.config;return Zs(e,function(){return t({config:o})},1e4).then(function(t){return n[r]||(i.dispatch({type:$s.pluginReadyType(r),name:r,events:Object.keys(e).filter(function(e){return!zs.includes(e)})}),n[r]=!0),g=g.concat(r),e}).catch(function(e){if(e instanceof Error)throw new Error(e);return m=m.concat(e.name),e})});Promise.all(y).then(function(e){var t={plugins:g,failed:m,disabled:v};setTimeout(function(){p.length===y.length+v.length&&i.dispatch(_s({},{type:$s.ready},t))},0)})}var D=function(){if(l!==$s.bootstrap)return/^ready:([^:]*)$/.test(l)&&setTimeout(function(){return function(e,t,r){var n={},i=t(),o=e.getState(),a=o.plugins,s=o.queue,u=o.user;if(!o.context.offline&&s&&s.actions&&s.actions.length){var l=s.actions.reduce(function(e,t,r){return a[t.plugin].loaded?(e.process.push(t),e.processIndex.push(r)):(e.requeue.push(t),e.requeueIndex.push(r)),e},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(l.processIndex&&l.processIndex.length){l.processIndex.forEach(function(t){var o,l,c=s.actions[t],d=c.plugin,h=c.payload.type,p=i[d][h];if(p&&ns(p)){var f,g=(void 0===(o=c.payload)&&(o={}),void 0===(l=u)&&(l={}),[Ns,Us].reduce(function(e,t){return o.hasOwnProperty(t)&&l[t]&&l[t]!==o[t]&&(e[t]=l[t]),e},o)),m=n[g.meta.rid];if(!m&&(f=p({payload:g,config:a[d].config,instance:r,abort:eu}))&&us(f)&&f.abort)return void(n[g.meta.rid]=!0);if(!m){var v=h+":"+d;e.dispatch(_s({},g,{type:v,_:{called:v,from:"queueDrain"}}))}}});var c=s.actions.filter(function(e,t){return!~l.processIndex.indexOf(t)});s.actions=c}}}(i,t,e)},0),Promise.resolve(function(e,t,r,n,i){try{var o=ns(t)?t():t,a=e.type,s=a.replace(ru,"");if(e._&&e._.called)return Promise.resolve(e);var u=r.getState(),l=(g=o,void 0===(m=u.plugins)&&(m={}),void 0===(v=e.options)&&(v={}),Object.keys(g).filter(function(e){var t=v.plugins||{};return as(t[e])?t[e]:!1!==t.all&&(!m[e]||!1!==m[e].enabled)}).map(function(e){return g[e]}));a===$s.initializeStart&&e.fromEnable&&(l=Object.keys(u.plugins).filter(function(t){var r=u.plugins[t];return e.plugins.includes(t)&&!r.initialized}).map(function(e){return o[e]}));var c=l.map(function(e){return e.name}),d=(p=l,f=uu(h=a).map(function(e){return su(e,p)}),p.reduce(function(e,t){var r=t.name,n=uu(h,r).map(function(e){return su(e,p)}),i=n[0],o=n[1],a=n[2];return i.length&&(e.beforeNS[r]=i),o.length&&(e.duringNS[r]=o),a.length&&(e.afterNS[r]=a),e},{before:f[0],beforeNS:{},during:f[1],duringNS:{},after:f[2],afterNS:{}}));return Promise.resolve(tu({action:e,data:{exact:d.before,namespaced:d.beforeNS},state:u,allPlugins:o,allMatches:d,instance:r,store:n,EVENTS:i})).then(function(e){function t(){var t=function(){if(a.match(ru))return Promise.resolve(tu({action:_s({},l,{type:s+"End"}),data:{exact:d.after,namespaced:d.afterNS},state:u,allPlugins:o,allMatches:d,instance:r,store:n,EVENTS:i})).then(function(e){e.meta&&e.meta.hasCallback&&Ys(e.meta.rid,{payload:e})})}();return t&&t.then?t.then(function(){return e}):e}if(cu(e,c.length))return e;var l,h=function(){if(a!==s)return Promise.resolve(tu({action:_s({},e,{type:s}),data:{exact:d.during,namespaced:d.duringNS},state:u,allPlugins:o,allMatches:d,instance:r,store:n,EVENTS:i})).then(function(e){l=e});l=e}();return h&&h.then?h.then(t):t()})}catch(h){return Promise.reject(h)}var h,p,f,g,m,v}(a,t,e,i,r)).then(function(e){return s=1,o(e)})}();return Promise.resolve(D&&D.then?D.then(u):u(D))}catch(e){return Promise.reject(e)}}}}}function mu(e){return function(t){return function(t){return function(r){var n=r.type,i=r.key,o=r.value,a=r.options;if(n===$s.setItem||n===$s.removeItem){if(r.abort)return t(r);n===$s.setItem?e.setItem(i,o,a):e.removeItem(i,a)}return t(r)}}}}var vu=function(){var e=this;this.before=[],this.after=[],this.addMiddleware=function(t,r){e[r]=e[r].concat(t)},this.removeMiddleware=function(t,r){var n=e[r].findIndex(function(e){return e===t});-1!==n&&(e[r]=[].concat(e[r].slice(0,n),e[r].slice(n+1)))},this.dynamicMiddlewares=function(t){return function(r){return function(n){return function(i){var o={getState:r.getState,dispatch:function(e){return r.dispatch(e)}},a=e[t].map(function(e){return e(o)});return Bs.apply(void 0,a)(n)(i)}}}}};function yu(e){return function(t,r){void 0===t&&(t={});var n={};if("initialize:aborted"===r.type)return t;if(/^registerPlugin:([^:]*)$/.test(r.type)){var i=Du(r.type,"registerPlugin"),o=e()[i];if(!o||!i)return t;var a=r.enabled,s=o.config;return n[i]={enabled:a,initialized:!!a&&Boolean(!o.initialize),loaded:!!a&&Boolean(o.loaded({config:s})),config:s},_s({},t,n)}if(/^initialize:([^:]*)$/.test(r.type)){var u=Du(r.type,$s.initialize),l=e()[u];return l&&u?(n[u]=_s({},t[u],{initialized:!0,loaded:Boolean(l.loaded({config:l.config}))}),_s({},t,n)):t}if(/^ready:([^:]*)$/.test(r.type))return n[r.name]=_s({},t[r.name],{loaded:!0}),_s({},t,n);switch(r.type){case $s.disablePlugin:return _s({},t,bu(r.plugins,!1,t));case $s.enablePlugin:return _s({},t,bu(r.plugins,!0,t));default:return t}}}function Du(e,t){return e.substring(t.length+1,e.length)}function bu(e,t,r){return e.reduce(function(e,n){return e[n]=_s({},r[n],{enabled:t}),e},r)}function Fu(e){try{return JSON.parse(JSON.stringify(e))}catch(e){}return e}var wu={last:{},history:[]};function Eu(e,t){void 0===e&&(e=wu);var r=t.options,n=t.meta;if(t.type===$s.track){var i=Fu(_s({event:t.event,properties:t.properties},Object.keys(r).length&&{options:r},{meta:n}));return _s({},e,{last:i,history:e.history.concat(i)})}return e}var Su={actions:[]};function _u(e,t){void 0===e&&(e=Su);var r=t.payload;switch(t.type){case"queue":var n;return n=r&&r.type&&r.type===$s.identify?[t].concat(e.actions):e.actions.concat(t),_s({},e,{actions:n});case"dequeue":return[];default:return e}}var Au,Cu=/#.*$/;function ku(e){var t=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e);return"/"+(t&&t[3]?t[3].split("?")[0].replace(Cu,""):"")}var xu=function(e){if(void 0===e&&(e={}),!Qa)return e;var t,r,n=document,i=n.title,o=n.referrer,a=window,s=a.location,u=a.innerWidth,l=a.innerHeight,c=s.hash,d=s.search,h=(t=d,(r=function(){if(Qa)for(var e,t=document.getElementsByTagName("link"),r=0;e=t[r];r++)if("canonical"===e.getAttribute("rel"))return e.getAttribute("href")}())?r.match(/\?/)?r:r+t:window.location.href.replace(Cu,"")),p={title:i,url:h,path:ku(h),hash:c,search:d,width:u,height:l};return o&&""!==o&&(p.referrer=o),_s({},p,e)},Pu={last:{},history:[]};function Iu(e,t){void 0===e&&(e=Pu);var r=t.options;if(t.type===$s.page){var n=Fu(_s({properties:t.properties,meta:t.meta},Object.keys(r).length&&{options:r}));return _s({},e,{last:n,history:e.history.concat(n)})}return e}Au={};var Ou={initialized:!1,sessionId:gs(),app:null,version:null,debug:!1,offline:!!Qa&&!navigator.onLine,os:{name:"na"},userAgent:Qa?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.14"},timezone:void 0,locale:void 0,campaign:{},referrer:Au};function Bu(e,t){void 0===e&&(e=Ou);var r=e.initialized,n=t.campaign;switch(t.type){case $s.campaign:return _s({},e,{campaign:n});case $s.offline:return _s({},e,{offline:!0});case $s.online:return _s({},e,{offline:!1});default:return r?e:_s({},Ou,e,{initialized:!0})}}var ju=["plugins","reducers","storage"];function Tu(){return bs("analytics",[]),function(e){return function(t,r,n){var i=e(t,r,n),o=i.dispatch;return Object.assign(i,{dispatch:function(e){return ys[vs].analytics.push(e.action||e),o(e)}})}}}function Ru(e){return function(){return Bs(Bs.apply(null,arguments),Tu())}}function Lu(e){return e?"array"===ts(e)?e:[e]:[]}function Nu(e,t,r){void 0===e&&(e={});var n,i,o=gs();return t&&(Xs[o]=(n=t,i=function(e){for(var t,r=e||Array.prototype.slice.call(arguments),n=0;n<r.length;n++)if(ns(r[n])){t=r[n];break}return t}(r),function(e){i&&i(e),n(e)})),_s({},e,{rid:o,ts:(new Date).getTime()},t?{hasCallback:!0}:{})}function Uu(e){void 0===e&&(e={});var t,r=e.reducers||{},n=e.initialUser||{},i=(e.plugins||[]).reduce(function(e,t){if(ns(t))return e.middlewares=e.middlewares.concat(t),e;if(t.NAMESPACE&&(t.name=t.NAMESPACE),!t.name)throw new Error("https://lytics.dev/errors/1");t.config||(t.config={});var r=t.EVENTS?Object.keys(t.EVENTS).map(function(e){return t.EVENTS[e]}):[];e.pluginEnabled[t.name]=!(!1===t.enabled||!1===t.config.enabled),delete t.enabled,t.methods&&(e.methods[t.name]=Object.keys(t.methods).reduce(function(e,r){var n;return e[r]=(n=t.methods[r],function(){for(var e=Array.prototype.slice.call(arguments),t=new Array(n.length),r=0;r<e.length;r++)t[r]=e[r];return t[t.length]=w,n.apply({instance:w},t)}),e},{}),delete t.methods);var n=Object.keys(t).concat(r),i=new Set(e.events.concat(n));if(e.events=Array.from(i),e.pluginsArray=e.pluginsArray.concat(t),e.plugins[t.name])throw new Error(t.name+"AlreadyLoaded");return e.plugins[t.name]=t,e.plugins[t.name].loaded||(e.plugins[t.name].loaded=function(){return!0}),e},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),o=e.storage?e.storage:{getItem:Ds,setItem:bs,removeItem:Fs},a=(t=o,function(e,r,n){return r.getState("user")[e]||(n&&us(n)&&n[e]?n[e]:Vs(t)[e]||Ds(Ks(e))||null)}),s=i.plugins,u=i.events.filter(function(e){return!zs.includes(e)}).sort(),l=new Set(u.concat(qs).filter(function(e){return!zs.includes(e)})),c=Array.from(l).sort(),d=function(){return s},h=new vu,p=h.addMiddleware,f=h.removeMiddleware,g=h.dynamicMiddlewares,m=function(){throw new Error("Abort disabled inListener")},v=function(e){for(var t,r=Object.create(null),n=/([^&=]+)=?([^&]*)/g;t=n.exec(e);){var i=ps(t[1]),o=ps(t[2]);"[]"===i.substring(i.length-2)?(r[i=i.substring(0,i.length-2)]||(r[i]=[])).push(o):r[i]=""===o||o}for(var a in r){var s=a.split("[");s.length>1&&(fs(r,s.map(function(e){return e.replace(/[?[\]\\ ]/g,"")}),r[a]),delete r[a])}return r}(Qa&&window.location.search.substring(1)),y=Vs(o),D=_s({},y,n,v.an_uid?{userId:v.an_uid}:{},v.an_aid?{anonymousId:v.an_aid}:{});D.anonymousId||(D.anonymousId=gs());var b=_s({enable:function(e,t){return new Promise(function(r){O.dispatch({type:$s.enablePlugin,plugins:Lu(e),_:{originalAction:$s.enablePlugin}},r,[t])})},disable:function(e,t){return new Promise(function(r){O.dispatch({type:$s.disablePlugin,plugins:Lu(e),_:{originalAction:$s.disablePlugin}},r,[t])})}},i.methods),F=!1,w={identify:function(e,t,r,n){try{var i=is(e)?e:null,o=us(e)?e:t,s=r||{},u=w.user();bs(Ks(Ns),i);var l=i||o.userId||a(Ns,w,o);return Promise.resolve(new Promise(function(e){O.dispatch(_s({type:$s.identifyStart,userId:l,traits:o||{},options:s,anonymousId:u.anonymousId},u.id&&u.id!==i&&{previousId:u.id}),e,[t,r,n])}))}catch(e){return Promise.reject(e)}},track:function(e,t,r,n){try{var i=us(e)?e.event:e;if(!i||!is(i))throw new Error("EventMissing");var o=us(e)?e:t||{},s=us(r)?r:{};return Promise.resolve(new Promise(function(e){O.dispatch({type:$s.trackStart,event:i,properties:o,options:s,userId:a(Ns,w,t),anonymousId:a(Us,w,t)},e,[t,r,n])}))}catch(e){return Promise.reject(e)}},page:function(e,t,r){try{var n=us(e)?e:{},i=us(t)?t:{};return Promise.resolve(new Promise(function(o){O.dispatch({type:$s.pageStart,properties:xu(n),options:i,userId:a(Ns,w,n),anonymousId:a(Us,w,n)},o,[e,t,r])}))}catch(e){return Promise.reject(e)}},user:function(e){if(e===Ns||"id"===e)return a(Ns,w);if(e===Us||"anonId"===e)return a(Us,w);var t=w.getState("user");return e?Ga(t,e):t},reset:function(e){return new Promise(function(t){O.dispatch({type:$s.resetStart},t,e)})},ready:function(e){return F&&e({plugins:b,instance:w}),w.on($s.ready,function(t){e(t),F=!0})},on:function(e,t){if(!e||!ns(t))return!1;if(e===$s.bootstrap)throw new Error(".on disabled for "+e);var r=/Start$|Start:/;if("*"===e){var n=function(e){return function(e){return function(n){return n.type.match(r)&&t({payload:n,instance:w,plugins:s}),e(n)}}},i=function(e){return function(e){return function(n){return n.type.match(r)||t({payload:n,instance:w,plugins:s}),e(n)}}};return p(n,qu),p(i,zu),function(){f(n,qu),f(i,zu)}}var o=e.match(r)?qu:zu,a=function(r){return function(r){return function(n){return n.type===e&&t({payload:n,instance:w,plugins:s,abort:m}),r(n)}}};return p(a,o),function(){return f(a,o)}},once:function(e,t){if(!e||!ns(t))return!1;if(e===$s.bootstrap)throw new Error(".once disabled for "+e);var r=w.on(e,function(e){t({payload:e.payload,instance:w,plugins:s,abort:m}),r()});return r},getState:function(e){var t=O.getState();return e?Ga(t,e):Object.assign({},t)},dispatch:function(e){var t=is(e)?{type:e}:e;if(qs.includes(t.type))throw new Error("reserved action "+t.type);var r=_s({},t,{_:_s({originalAction:t.type},e._||{})});O.dispatch(r)},enablePlugin:b.enable,disablePlugin:b.disable,plugins:b,storage:{getItem:o.getItem,setItem:function(e,t,r){O.dispatch({type:$s.setItemStart,key:e,value:t,options:r})},removeItem:function(e,t){O.dispatch({type:$s.removeItemStart,key:e,options:t})}},setAnonymousId:function(e,t){w.storage.setItem(Ts,e,t)},events:{core:qs,plugins:u}},E=i.middlewares.concat([function(e){return function(e){return function(t){return t.meta||(t.meta=Nu()),e(t)}}},g(qu),gu(w,d,{all:c,plugins:u}),mu(o),Gs(w),Qs(w),g(zu)]),S={context:Bu,user:Js(o),page:Iu,track:Eu,plugins:yu(d),queue:_u},_=Bs,A=Bs;if(Qa&&e.debug){var C=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;C&&(_=C({trace:!0,traceLimit:25})),A=function(){return 0===arguments.length?Tu():us(typeof arguments[0])?Ru():Ru().apply(null,arguments)}}var k,x=function(e){return Object.keys(e).reduce(function(t,r){return ju.includes(r)||(t[r]=e[r]),t},{})}(e),P=i.pluginsArray.reduce(function(e,t){var r=t.name,n=t.config,o=t.loaded,a=i.pluginEnabled[r];return e[r]={enabled:a,initialized:!!a&&Boolean(!t.initialize),loaded:Boolean(o({config:n})),config:n},e},{}),I={context:x,user:D,plugins:P},O=Is(function(e){for(var t=Object.keys(e),r={},n=0;n<t.length;n++){var i=t[n];typeof e[i]===As&&(r[i]=e[i])}var o,a,s=Object.keys(r);try{a=r,Object.keys(a).forEach(function(e){var t=a[e];if(typeof t(void 0,{type:"@@redux/INIT"})===Cs||typeof t(void 0,{type:ks})===Cs)throw new Error("reducer "+e+" "+Cs)})}catch(a){o=a}return function(e,t){if(void 0===e&&(e={}),o)throw o;for(var n=!1,i={},a=0;a<s.length;a++){var u=s[a],l=e[u],c=(0,r[u])(l,t);if(typeof c===Cs){var d=Os(u,t);throw new Error(d)}i[u]=c,n=n||c!==l}return n?i:e}}(_s({},S,r)),I,A(_(js.apply(void 0,E))));O.dispatch=(k=O.dispatch,function(e,t,r){var n=_s({},e,{meta:Nu(e.meta,t,Lu(r))});return k.apply(null,[n])});var B=Object.keys(s);O.dispatch({type:$s.bootstrap,plugins:B,config:x,params:v,user:D,initialUser:n,persistedUser:y});var j=B.filter(function(e){return i.pluginEnabled[e]}),T=B.filter(function(e){return!i.pluginEnabled[e]});return O.dispatch({type:$s.registerPlugins,plugins:B,enabled:i.pluginEnabled}),i.pluginsArray.map(function(e,t){var r=e.bootstrap,n=e.config,o=e.name;r&&ns(r)&&r({instance:w,config:n,payload:e}),O.dispatch({type:$s.registerPluginType(o),name:o,enabled:i.pluginEnabled[o],plugin:e}),i.pluginsArray.length===t+1&&O.dispatch({type:$s.initializeStart,plugins:j,disabled:T})}),w}var qu="before",zu="after",$u="cookie",Mu=Ju(),Hu=Vu,Wu=Vu;function Gu(e){return Mu?Vu(e,"",-1):Fs(e)}function Ju(){if(void 0!==Mu)return Mu;var e="cookiecookie";try{Vu(e,e),Mu=-1!==document.cookie.indexOf(e),Gu(e)}catch(e){Mu=!1}return Mu}function Vu(e,t,r,n,i,o){if("undefined"!=typeof window){var a=arguments.length>1;return!1===Mu&&(a?bs(e,t):Ds(e)),a?document.cookie=e+"="+encodeURIComponent(t)+(r?"; expires="+new Date(+new Date+1e3*r).toUTCString()+(n?"; path="+n:"")+(i?"; domain="+i:"")+(o?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+e+"=")[1]||"").split(";")[0])}}var Ku="localStorage",Qu=Ss.bind(null,"localStorage");ws("localStorage","getItem",Ds),ws("localStorage","setItem",bs),ws("localStorage","removeItem",Fs);var Xu="sessionStorage",Yu=Ss.bind(null,"sessionStorage");function Zu(e){var t=e;try{if("true"===(t=JSON.parse(e)))return!0;if("false"===t)return!1;if(us(t))return t;parseFloat(t)===t&&(t=parseFloat(t))}catch(e){}if(null!==t&&""!==t)return t}ws("sessionStorage","getItem",Ds),ws("sessionStorage","setItem",bs),ws("sessionStorage","removeItem",Fs);var el=Qu(),tl=Yu(),rl=Ju();function nl(e,t){if(e){var r=il(t),n=!ul(r),i=ol(r)?Zu(localStorage.getItem(e)):void 0;if(n&&!os(i))return i;var o=al(r)?Zu(Hu(e)):void 0;if(n&&o)return o;var a=sl(r)?Zu(sessionStorage.getItem(e)):void 0;if(n&&a)return a;var s=Ds(e);return n?s:{localStorage:i,sessionStorage:a,cookie:o,global:s}}}function il(e){return e?is(e)?e:e.storage:"any"}function ol(e){return el&&ll(e,Ku)}function al(e){return rl&&ll(e,$u)}function sl(e){return tl&&ll(e,Xu)}function ul(e){return"*"===e||"all"===e}function ll(e,t){return"any"===e||e===t||ul(e)}function cl(e,t,r){return{location:e,current:t,previous:r}}var dl={setItem:function(e,t,r){if(e&&!os(t)){var n={},i=il(r),o=JSON.stringify(t),a=!ul(i);return ol(i)&&(n[Ku]=cl(Ku,t,Zu(localStorage.getItem(e))),localStorage.setItem(e,o),a)?n[Ku]:al(i)&&(n[$u]=cl($u,t,Zu(Hu(e))),Wu(e,o),a)?n[$u]:sl(i)&&(n[Xu]=cl(Xu,t,Zu(sessionStorage.getItem(e))),sessionStorage.setItem(e,o),a)?n[Xu]:(n[ms]=cl(ms,t,Ds(e)),bs(e,t),a?n[ms]:n)}},getItem:nl,removeItem:function(e,t){if(e){var r=il(t),n=nl(e,"*"),i={};return!os(n.localStorage)&&ol(r)&&(localStorage.removeItem(e),i[Ku]=n.localStorage),!os(n.cookie)&&al(r)&&(Gu(e),i[$u]=n.cookie),!os(n.sessionStorage)&&sl(r)&&(sessionStorage.removeItem(e),i[Xu]=n.sessionStorage),!os(n.global)&&ll(r,ms)&&(Fs(e),i[ms]=n.global),i}}};function hl(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function pl(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function fl(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?pl(Object(r),!0).forEach(function(t){hl(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):pl(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function gl(e,t){const r=function(e){return Array.prototype.slice.call(window.document.querySelectorAll("script")).find(t=>t.src===e)}(e);if(void 0!==r){const e=null==r?void 0:r.getAttribute("status");if("loaded"===e)return Promise.resolve(r);if("loading"===e)return new Promise((e,t)=>{r.addEventListener("load",()=>e(r)),r.addEventListener("error",e=>t(e))})}return new Promise((r,n)=>{var i,o;const a=window.document.createElement("script");a.type="text/javascript",a.src=function(e,t){let r=e;return r.startsWith("http")||(r=`https://${(null==t?void 0:t.www)?"www.":""}${r}`),(null==t?void 0:t.min)?r+=".min.js":(null==t?void 0:t.js)&&(r+=".js"),(null==t?void 0:t.query)&&(r+="?"+t.query),r}(e,t),a.async=!0,a.setAttribute("status","loading");for(const[e,r]of Object.entries(null!=(i=null==t?void 0:t.attributes)?i:{}))a.setAttribute(e,r);a.onload=()=>{a.onerror=a.onload=null,a.setAttribute("status","loaded"),r(a)},a.onerror=()=>{a.onerror=a.onload=null,a.setAttribute("status","error"),n(new Error(`Failed to load ${e}`))};const s=window.document.getElementsByTagName("script")[0];null==(o=s.parentElement)||o.insertBefore(a,s)})}var ml={id:"tag",handle(e,t){return Wa(this,null,function*(){Ol(t,e)&&function(e,t,r={}){let n;try{n=JSON.parse(e)}catch(t){n={code:e,lang:"javascript"}}const i=r.debug||!1;if(gc())if("javascript"===n.lang)!function(e,t){const r=`jitsu_event_${kc()}`;window[r]=t;const n=`(function(){\n const event = ${r};\n ${e}\n })()`;try{yl(n)}catch(e){console.error(`[JITSU] Error executing JS code: ${e.message}. Code: `,n)}finally{delete window[r]}}(n.code,t);else{const e=document.createElement("span");e.innerHTML=function(e,t){return e.replace(/{{\s*event\s*}}/g,JSON.stringify(t))}(n.code,t),document.body.insertAdjacentElement("beforeend",e);e.querySelectorAll("script").forEach(e=>{const t=document.createElement("script");t.type=t.type||"text/javascript",e.hasAttribute("src")&&(t.src=e.src),t.text=e.text,i&&console.log("[JITSU] Executing script"+(e.hasAttribute("src")?` ${e.src}`:""),t.text),document.head.appendChild(t),document.head.removeChild(t)})}else i&&console.log("[JITSU] insertTags(): cannot insert tags in non-browser environment")}(e.code,t)})}};var vl="ve".split("").reverse().join(""),yl=globalThis[vl+"al"];var Dl="cdn.lr-ingest.io/",bl={id:"logrocket",handle(e,t){return Wa(this,null,function*(){if(!Ol(t,e))return;!function(e){Wa(this,null,function*(){"fresh"===Fl()&&(wl("loading"),gl(`${Dl}LogRocket`,{min:!0,attributes:{crossOrigin:"anonymous"}}).then(()=>{if(window.LogRocket){try{window.LogRocket.init(e)}catch(t){console.warn(`LogRocket (id=${e}) init failed: ${t.message}`,t),wl("failed")}wl("loaded"),Sl(window.LogRocket)}}).catch(t=>{console.warn(`LogRocket (id=${e}) init failed: ${t.message}`,t),wl("failed")}))})}(e.appId);El().push(e=>{"identify"===t.type&&t.userId&&e.identify(t.userId,t.traits||{})}),"loaded"===Fl()&&Sl(window.LogRocket)})}};function Fl(){return window.__jitsuLrState||"fresh"}function wl(e){window.__jitsuLrState=e}function El(){return window.__jitsuLrQueue||(window.__jitsuLrQueue=[])}function Sl(e){const t=El();for(;t.length>0;){const r=t.shift();if(r)try{const t=r(e);t&&t.catch(e=>console.warn(`Async LogRocket method failed: ${e.message}`,e))}catch(e){console.warn(`LogRocket method failed: ${e.message}`,e)}}}var _l={id:"gtm",handle(e,t){return Wa(this,null,function*(){var r,n,i,o,a,s,u,l,c,d,h,p,f,g;const m=!!e.debug;if(!Ol(t,e))return;yield function(e,t){return Wa(this,null,function*(){const r=e.dataLayerName||"dataLayer";if(!1===e.loadGtm)return void(window[r]=window[r]||[]);if("fresh"!==(window.__jitsuGtmState||"fresh"))return;Al("loading");const n=e.containerId;!function(e,r,i){e[r]=e[r]||[],e[r].push({user_id:t.userId}),e[r].push({"gtm.start":(new Date).getTime(),event:"gtm.js"});gl("googletagmanager.com/gtm",{www:!0,js:!0,query:"id="+i+("dataLayer"!=r?"&l="+r:"")}).then(()=>{Al("loaded")}).catch(e=>{console.warn(`GTM (containerId=${n}) init failed: ${e.message}`,e),Al("failed")})}(window,r,n)})}(e,t);const v=window[e.dataLayerName||"dataLayer"],y=Ma(Ma({},(null==t?void 0:t.traits)||{}),(null==(r=null==t?void 0:t.context)?void 0:r.traits)||{}),D=function(e,...t){return Object.fromEntries(Object.entries(e).filter(([e])=>!t.includes(e)))}(y,"id","userId","user_id","anonymousId","userId");m&&console.debug("GTM plugin will be applied to following payload",t);const b={email_address:y.email},F=Ha(Ma(Ma(Ma({},t.userId?{user_id:t.userId,userId:t.userId}:{}),t.anonymousId?{anonymousId:t.anonymousId}:{}),D),{user_data:Object.keys(b).length>0?b:void 0});m&&console.debug("GTM plugin will set following user-related data layer vars",F);const w=t.properties||{},E={page_location:w.url||(null==(i=null==(n=t.context)?void 0:n.page)?void 0:i.url),page_title:w.title||(null==(a=null==(o=t.context)?void 0:o.page)?void 0:a.title),page_path:w.path||(null==(u=null==(s=t.context)?void 0:s.page)?void 0:u.path),page_hash:w.hash||(null==(c=null==(l=t.context)?void 0:l.page)?void 0:c.hash),page_search:w.search||(null==(h=null==(d=t.context)?void 0:d.page)?void 0:h.search),page_referrer:null!=(g=null==(f=null==(p=null==t?void 0:t.context)?void 0:p.page)?void 0:f.referrer)?g:""};m&&console.debug("GTM plugin will set following context (page) related data layer vars",F);const S=new Set,_=e=>{Object.keys(e).forEach(e=>S.add(e)),v.push(e),m&&console.debug("GTM plugin will push following data to dataLayer",e)};switch(t.type){case"page":const{properties:e,context:r}=t;_(Ma(Ma({event:"page_view"},E),F));break;case"track":const{properties:n}=t;_(Ma(Ma(Ma({event:t.event},E),n),F));break;case"identify":const{traits:i}=t;_(Ma(Ma(Ma({event:"identify"},E),i),F))}if(!1!==e.resetDataLayer)if(!1===e.loadGtm){const e={};S.forEach(t=>{e[t]=void 0}),Object.keys(e).length>0&&v.push(e)}else v.push(function(){this.reset()})})}};function Al(e){window.__jitsuGtmState=e}var Cl=[new Uint8Array([109,111,99,46,114,101,103,97,110,97,109,103,97,116,101,108,103,111,111,103]),new Uint8Array([103,97,116,103]),new Uint8Array([115,106])];function kl(e){return(new TextDecoder).decode(e)}var xl={id:"ga4-tag",handle(e,t){return Wa(this,null,function*(){var r,n;if(!Ol(t,e))return;yield function(e,t){return Wa(this,null,function*(){if("fresh"!==(window.__jitsuGa4State||"fresh"))return;Pl("loading");const r=e.dataLayerName||"dataLayer",n="dataLayer"!==r?"&l="+r:"",i=e.measurementIds;window[r]=window[r]||[];const o=function(){window[r].push(arguments)};o("js",new Date),o("config",i,Ma(Ma({},t.userId?{user_id:t.userId}:{}),e.autoPageView?{}:{send_page_view:!1})),gl(Cl.map(e=>e.reverse()).map(kl).join("/"),{query:`id=${i}${n}`,www:!0}).then(()=>{Pl("loaded")}).catch(t=>{console.warn(`GA4 (containerId=${e.measurementIds}) init failed: ${t.message}`,t),Pl("failed")})})}(e,t);const i=window[e.dataLayerName||"dataLayer"],o=function(){i.push(arguments)},a=Ma(Ma({},t.userId?{user_id:t.userId,userId:t.userId}:{}),t.anonymousId?{anonymousId:t.anonymousId}:{});switch(t.userId&&o("set",{user_id:t.userId}),t.type){case"page":if(e.autoPageView){console.log("autoPageView");break}const{properties:i,context:s}=t;if(i){o("event","page_view",Ma({page_location:i.url,page_title:i.title,page_path:i.path,page_hash:i.hash,page_search:i.search,page_referrer:null!=(n=null==(r=null==s?void 0:s.page)?void 0:r.referrer)?n:""},a))}break;case"track":const{properties:u}=t,l=Ma(Ma({},u),a);o("event",t.event,l);break;case"identify":const{traits:c}=t;o("event","identify",Ma(Ma({},c),a))}})}};function Pl(e){window.__jitsuGa4State=e}function Il(e,t){return"*"===e||e.toLowerCase().trim()===(t||"").trim().toLowerCase()}function Ol(e,t){const{hosts:r="*",events:n="*"}=t;try{const t=Array.isArray(n)?n:n.split("\n");return!(!(Array.isArray(r)?r:r.split("\n")).find(t=>{var r,n,i,o;return i=t,o=null==(n=null==(r=e.context)?void 0:r.page)?void 0:n.host,"*"===i||(o=o||"",i.startsWith("*.")?o.endsWith(i.substring(1)):i===o)})||!t.find(t=>Il(t,e.type))&&!t.find(t=>Il(t,e.event)))}catch(e){throw console.warn(`Failed to apply filters: ${e.message}. Typeof events: ${typeof n}, typeof hosts: ${typeof r}. Values`,n,r),new Error(`Failed to apply filters: ${e.message}. Typeof events: ${typeof n}, typeof hosts: ${typeof r}`)}}var Bl={[ml.id]:ml,[_l.id]:_l,[xl.id]:xl,[bl.id]:bl},jl="webflow.io,vercel.app,myshopify.com,ac,com.ac,edu.ac,gov.ac,net.ac,mil.ac,org.ac,ad,nom.ad,ae,co.ae,net.ae,org.ae,sch.ae,ac.ae,gov.ae,mil.ae,aero,af,gov.af,com.af,org.af,net.af,edu.af,ag,com.ag,org.ag,net.ag,co.ag,nom.ag,ai,off.ai,com.ai,net.ai,org.ai,al,com.al,edu.al,gov.al,mil.al,net.al,org.al,am,co.am,com.am,commune.am,net.am,org.am,ao,ed.ao,gv.ao,og.ao,co.ao,pb.ao,it.ao,aq,ar,bet.ar,com.ar,coop.ar,edu.ar,gob.ar,gov.ar,int.ar,mil.ar,musica.ar,mutual.ar,net.ar,org.ar,senasa.ar,tur.ar,arpa,e164.arpa,in-addr.arpa,ip6.arpa,iris.arpa,uri.arpa,urn.arpa,as,gov.as,asia,at,ac.at,co.at,gv.at,or.at,sth.ac.at,au,com.au,net.au,org.au,edu.au,gov.au,asn.au,id.au,act.au,nsw.au,nt.au,qld.au,sa.au,tas.au,vic.au,wa.au,aw,com.aw,ax,az,com.az,net.az,int.az,gov.az,org.az,edu.az,info.az,pp.az,mil.az,name.az,pro.az,biz.az,ba,com.ba,edu.ba,gov.ba,mil.ba,net.ba,org.ba,bb,biz.bb,co.bb,com.bb,edu.bb,gov.bb,info.bb,net.bb,org.bb,store.bb,tv.bb,bd,be,ac.be,bf,gov.bf,bg,a.bg,b.bg,c.bg,d.bg,e.bg,f.bg,g.bg,h.bg,i.bg,j.bg,k.bg,l.bg,m.bg,n.bg,o.bg,p.bg,q.bg,r.bg,s.bg,t.bg,u.bg,v.bg,w.bg,x.bg,y.bg,z.bg,0.bg,1.bg,2.bg,3.bg,4.bg,5.bg,6.bg,7.bg,8.bg,9.bg,bh,com.bh,edu.bh,net.bh,org.bh,gov.bh,bi,co.bi,com.bi,edu.bi,or.bi,org.bi,biz,bj,africa.bj,agro.bj,architectes.bj,assur.bj,avocats.bj,co.bj,com.bj,eco.bj,econo.bj,edu.bj,info.bj,loisirs.bj,money.bj,net.bj,org.bj,ote.bj,resto.bj,restaurant.bj,tourism.bj,univ.bj,bm,com.bm,edu.bm,gov.bm,net.bm,org.bm,bn,com.bn,edu.bn,gov.bn,net.bn,org.bn,bo,com.bo,edu.bo,gob.bo,int.bo,org.bo,net.bo,mil.bo,tv.bo,web.bo,br,9guacu.br,abc.br,adm.br,adv.br,agr.br,aju.br,am.br,anani.br,aparecida.br,app.br,arq.br,art.br,ato.br,b.br,barueri.br,belem.br,bhz.br,bib.br,bio.br,blog.br,bmd.br,boavista.br,bsb.br,campinagrande.br,campinas.br,caxias.br,cim.br,cng.br,cnt.br,com.br,contagem.br,coop.br,coz.br,cri.br,cuiaba.br,curitiba.br,def.br,des.br,det.br,dev.br,ecn.br,eco.br,edu.br,emp.br,enf.br,eng.br,esp.br,etc.br,eti.br,far.br,feira.br,flog.br,floripa.br,fm.br,fnd.br,fortal.br,fot.br,foz.br,fst.br,g12.br,geo.br,ggf.br,goiania.br,gov.br,gru.br,imb.br,ind.br,inf.br,jab.br,jampa.br,jdf.br,joinville.br,jor.br,jus.br,leg.br,lel.br,log.br,londrina.br,macapa.br,maceio.br,manaus.br,maringa.br,mat.br,med.br,mil.br,morena.br,mp.br,mus.br,natal.br,net.br,niteroi.br,nom.br,not.br,ntr.br,odo.br,ong.br,org.br,osasco.br,palmas.br,poa.br,ppg.br,pro.br,psc.br,psi.br,pvh.br,qsl.br,radio.br,rec.br,recife.br,rep.br,ribeirao.br,rio.br,riobranco.br,riopreto.br,salvador.br,sampa.br,santamaria.br,santoandre.br,saobernardo.br,saogonca.br,seg.br,sjc.br,slg.br,slz.br,sorocaba.br,srv.br,taxi.br,tc.br,tec.br,teo.br,the.br,tmp.br,trd.br,tur.br,tv.br,udi.br,vet.br,vix.br,vlog.br,wiki.br,zlg.br,bs,com.bs,net.bs,org.bs,edu.bs,gov.bs,bt,com.bt,edu.bt,gov.bt,net.bt,org.bt,bv,bw,co.bw,org.bw,by,gov.by,mil.by,com.by,of.by,bz,com.bz,net.bz,org.bz,edu.bz,gov.bz,ca,ab.ca,bc.ca,mb.ca,nb.ca,nf.ca,nl.ca,ns.ca,nt.ca,nu.ca,on.ca,pe.ca,qc.ca,sk.ca,yk.ca,gc.ca,cat,cc,cd,gov.cd,cf,cg,ch,ci,org.ci,or.ci,com.ci,co.ci,edu.ci,ed.ci,ac.ci,net.ci,go.ci,asso.ci,aéroport.ci,int.ci,presse.ci,md.ci,gouv.ci,ck,cl,co.cl,gob.cl,gov.cl,mil.cl,cm,co.cm,com.cm,gov.cm,net.cm,cn,ac.cn,com.cn,edu.cn,gov.cn,net.cn,org.cn,mil.cn,co,arts.co,com.co,edu.co,firm.co,gov.co,info.co,int.co,mil.co,net.co,nom.co,org.co,rec.co,web.co,com,coop,cr,ac.cr,co.cr,ed.cr,fi.cr,go.cr,or.cr,sa.cr,cu,com.cu,edu.cu,org.cu,net.cu,gov.cu,inf.cu,cv,com.cv,edu.cv,int.cv,nome.cv,org.cv,cw,com.cw,edu.cw,net.cw,org.cw,cx,gov.cx,cy,ac.cy,biz.cy,com.cy,ekloges.cy,gov.cy,ltd.cy,mil.cy,net.cy,org.cy,press.cy,pro.cy,tm.cy,cz,de,dj,dk,dm,com.dm,net.dm,org.dm,edu.dm,gov.dm,do,art.do,com.do,edu.do,gob.do,gov.do,mil.do,net.do,org.do,sld.do,web.do,dz,art.dz,asso.dz,com.dz,edu.dz,gov.dz,org.dz,net.dz,pol.dz,soc.dz,tm.dz,ec,com.ec,info.ec,net.ec,fin.ec,k12.ec,med.ec,pro.ec,org.ec,edu.ec,gov.ec,gob.ec,mil.ec,edu,ee,edu.ee,gov.ee,riik.ee,lib.ee,med.ee,com.ee,pri.ee,aip.ee,org.ee,fie.ee,eg,com.eg,edu.eg,eun.eg,gov.eg,mil.eg,name.eg,net.eg,org.eg,sci.eg,er,es,com.es,nom.es,org.es,gob.es,edu.es,et,com.et,gov.et,org.et,edu.et,biz.et,name.et,info.et,net.et,eu,fi,aland.fi,fj,ac.fj,biz.fj,com.fj,gov.fj,info.fj,mil.fj,name.fj,net.fj,org.fj,pro.fj,fk,com.fm,edu.fm,net.fm,org.fm,fm,fo,fr,asso.fr,com.fr,gouv.fr,nom.fr,prd.fr,tm.fr,aeroport.fr,avocat.fr,avoues.fr,cci.fr,chambagri.fr,chirurgiens-dentistes.fr,experts-comptables.fr,geometre-expert.fr,greta.fr,huissier-justice.fr,medecin.fr,notaires.fr,pharmacien.fr,port.fr,veterinaire.fr,ga,gb,edu.gd,gov.gd,gd,ge,com.ge,edu.ge,gov.ge,org.ge,mil.ge,net.ge,pvt.ge,gf,gg,co.gg,net.gg,org.gg,gh,com.gh,edu.gh,gov.gh,org.gh,mil.gh,gi,com.gi,ltd.gi,gov.gi,mod.gi,edu.gi,org.gi,gl,co.gl,com.gl,edu.gl,net.gl,org.gl,gm,gn,ac.gn,com.gn,edu.gn,gov.gn,org.gn,net.gn,gov,gp,com.gp,net.gp,mobi.gp,edu.gp,org.gp,asso.gp,gq,gr,com.gr,edu.gr,net.gr,org.gr,gov.gr,gs,gt,com.gt,edu.gt,gob.gt,ind.gt,mil.gt,net.gt,org.gt,gu,com.gu,edu.gu,gov.gu,guam.gu,info.gu,net.gu,org.gu,web.gu,gw,gy,co.gy,com.gy,edu.gy,gov.gy,net.gy,org.gy,hk,com.hk,edu.hk,gov.hk,idv.hk,net.hk,org.hk,hm,hn,com.hn,edu.hn,org.hn,net.hn,mil.hn,gob.hn,hr,iz.hr,from.hr,name.hr,com.hr,ht,com.ht,shop.ht,firm.ht,info.ht,adult.ht,net.ht,pro.ht,org.ht,med.ht,art.ht,coop.ht,pol.ht,asso.ht,edu.ht,rel.ht,gouv.ht,perso.ht,hu,co.hu,info.hu,org.hu,priv.hu,sport.hu,tm.hu,2000.hu,agrar.hu,bolt.hu,casino.hu,city.hu,erotica.hu,erotika.hu,film.hu,forum.hu,games.hu,hotel.hu,ingatlan.hu,jogasz.hu,konyvelo.hu,lakas.hu,media.hu,news.hu,reklam.hu,sex.hu,shop.hu,suli.hu,szex.hu,tozsde.hu,utazas.hu,video.hu,id,ac.id,biz.id,co.id,desa.id,go.id,mil.id,my.id,net.id,or.id,ponpes.id,sch.id,web.id,ie,gov.ie,il,ac.il,co.il,gov.il,idf.il,k12.il,muni.il,net.il,org.il,im,ac.im,co.im,com.im,ltd.co.im,net.im,org.im,plc.co.im,tt.im,tv.im,in,5g.in,6g.in,ac.in,ai.in,am.in,bihar.in,biz.in,business.in,ca.in,cn.in,co.in,com.in,coop.in,cs.in,delhi.in,dr.in,edu.in,er.in,firm.in,gen.in,gov.in,gujarat.in,ind.in,info.in,int.in,internet.in,io.in,me.in,mil.in,net.in,nic.in,org.in,pg.in,post.in,pro.in,res.in,travel.in,tv.in,uk.in,up.in,us.in,info,int,eu.int,io,com.io,iq,gov.iq,edu.iq,mil.iq,com.iq,org.iq,net.iq,ir,ac.ir,co.ir,gov.ir,id.ir,net.ir,org.ir,sch.ir,is,net.is,com.is,edu.is,gov.is,org.is,int.is,it,gov.it,edu.it,je,co.je,net.je,org.je,jm,jo,com.jo,org.jo,net.jo,edu.jo,sch.jo,gov.jo,mil.jo,name.jo,jobs,jp,ac.jp,ad.jp,co.jp,ed.jp,go.jp,gr.jp,lg.jp,ne.jp,or.jp,ke,ac.ke,co.ke,go.ke,info.ke,me.ke,mobi.ke,ne.ke,or.ke,sc.ke,kg,org.kg,net.kg,com.kg,edu.kg,gov.kg,mil.kg,kh,ki,edu.ki,biz.ki,net.ki,org.ki,gov.ki,info.ki,com.ki,km,org.km,nom.km,gov.km,prd.km,tm.km,edu.km,mil.km,ass.km,com.km,kn,net.kn,org.kn,edu.kn,gov.kn,kp,com.kp,edu.kp,gov.kp,org.kp,rep.kp,tra.kp,kr,ac.kr,co.kr,es.kr,go.kr,hs.kr,kg.kr,mil.kr,ms.kr,ne.kr,or.kr,pe.kr,re.kr,sc.kr,kw,com.kw,edu.kw,emb.kw,gov.kw,ind.kw,net.kw,org.kw,ky,com.ky,edu.ky,net.ky,org.ky,kz,org.kz,edu.kz,net.kz,gov.kz,mil.kz,com.kz,la,int.la,net.la,info.la,edu.la,gov.la,per.la,com.la,org.la,lb,com.lb,edu.lb,gov.lb,net.lb,org.lb,lc,com.lc,net.lc,co.lc,org.lc,edu.lc,gov.lc,li,lk,gov.lk,sch.lk,net.lk,int.lk,com.lk,org.lk,edu.lk,ngo.lk,soc.lk,web.lk,ltd.lk,assn.lk,grp.lk,hotel.lk,ac.lk,lr,com.lr,edu.lr,gov.lr,org.lr,net.lr,ls,ac.ls,biz.ls,co.ls,edu.ls,gov.ls,info.ls,net.ls,org.ls,sc.ls,lt,gov.lt,lu,lv,com.lv,edu.lv,gov.lv,org.lv,mil.lv,id.lv,net.lv,asn.lv,conf.lv,ly,com.ly,net.ly,gov.ly,plc.ly,edu.ly,sch.ly,med.ly,org.ly,id.ly,ma,co.ma,net.ma,gov.ma,org.ma,ac.ma,press.ma,mc,tm.mc,asso.mc,md,me,co.me,net.me,org.me,edu.me,ac.me,gov.me,its.me,priv.me,mg,org.mg,nom.mg,gov.mg,prd.mg,tm.mg,edu.mg,mil.mg,com.mg,co.mg,mh,mil,mk,com.mk,org.mk,net.mk,edu.mk,gov.mk,inf.mk,name.mk,ml,com.ml,edu.ml,gouv.ml,gov.ml,net.ml,org.ml,presse.ml,mm,mn,gov.mn,edu.mn,org.mn,mo,com.mo,net.mo,org.mo,edu.mo,gov.mo,mobi,mp,mq,mr,gov.mr,ms,com.ms,edu.ms,gov.ms,net.ms,org.ms,mt,com.mt,edu.mt,net.mt,org.mt,mu,com.mu,net.mu,org.mu,gov.mu,ac.mu,co.mu,or.mu,museum,mv,aero.mv,biz.mv,com.mv,coop.mv,edu.mv,gov.mv,info.mv,int.mv,mil.mv,museum.mv,name.mv,net.mv,org.mv,pro.mv,mw,ac.mw,biz.mw,co.mw,com.mw,coop.mw,edu.mw,gov.mw,int.mw,museum.mw,net.mw,org.mw,mx,com.mx,org.mx,gob.mx,edu.mx,net.mx,my,biz.my,com.my,edu.my,gov.my,mil.my,name.my,net.my,org.my,mz,ac.mz,adv.mz,co.mz,edu.mz,gov.mz,mil.mz,net.mz,org.mz,na,info.na,pro.na,name.na,school.na,or.na,dr.na,us.na,mx.na,ca.na,in.na,cc.na,tv.na,ws.na,mobi.na,co.na,com.na,org.na,name,nc,asso.nc,nom.nc,ne,net,nf,com.nf,net.nf,per.nf,rec.nf,web.nf,arts.nf,firm.nf,info.nf,other.nf,store.nf,ng,com.ng,edu.ng,gov.ng,i.ng,mil.ng,mobi.ng,name.ng,net.ng,org.ng,sch.ng,ni,ac.ni,biz.ni,co.ni,com.ni,edu.ni,gob.ni,in.ni,info.ni,int.ni,mil.ni,net.ni,nom.ni,org.ni,web.ni,nl,no,fhs.no,vgs.no,fylkesbibl.no,folkebibl.no,museum.no,idrett.no,priv.no,mil.no,stat.no,dep.no,kommune.no,herad.no,np,nr,biz.nr,info.nr,gov.nr,edu.nr,org.nr,net.nr,com.nr,nu,nz,ac.nz,co.nz,cri.nz,geek.nz,gen.nz,govt.nz,health.nz,iwi.nz,kiwi.nz,maori.nz,mil.nz,māori.nz,net.nz,org.nz,parliament.nz,school.nz,om,co.om,com.om,edu.om,gov.om,med.om,museum.om,net.om,org.om,pro.om,onion,org,pa,ac.pa,gob.pa,com.pa,org.pa,sld.pa,edu.pa,net.pa,ing.pa,abo.pa,med.pa,nom.pa,pe,edu.pe,gob.pe,nom.pe,mil.pe,org.pe,com.pe,net.pe,pf,com.pf,org.pf,edu.pf,pg,ph,com.ph,net.ph,org.ph,gov.ph,edu.ph,ngo.ph,mil.ph,i.ph,pk,com.pk,net.pk,edu.pk,org.pk,fam.pk,biz.pk,web.pk,gov.pk,gob.pk,gok.pk,gon.pk,gop.pk,gos.pk,info.pk,pl,com.pl,net.pl,org.pl,aid.pl,agro.pl,atm.pl,auto.pl,biz.pl,edu.pl,gmina.pl,gsm.pl,info.pl,mail.pl,miasta.pl,media.pl,mil.pl,nieruchomosci.pl,nom.pl,pc.pl,powiat.pl,priv.pl,realestate.pl,rel.pl,sex.pl,shop.pl,sklep.pl,sos.pl,szkola.pl,targi.pl,tm.pl,tourism.pl,travel.pl,turystyka.pl,pm,pn,gov.pn,co.pn,org.pn,edu.pn,net.pn,post,pr,com.pr,net.pr,org.pr,gov.pr,edu.pr,isla.pr,pro.pr,biz.pr,info.pr,name.pr,est.pr,prof.pr,ac.pr,pro,aaa.pro,aca.pro,acct.pro,avocat.pro,bar.pro,cpa.pro,eng.pro,jur.pro,law.pro,med.pro,recht.pro,ps,edu.ps,gov.ps,sec.ps,plo.ps,com.ps,org.ps,net.ps,pt,net.pt,gov.pt,org.pt,edu.pt,int.pt,publ.pt,com.pt,nome.pt,pw,co.pw,ne.pw,or.pw,ed.pw,go.pw,belau.pw,py,com.py,coop.py,edu.py,gov.py,mil.py,net.py,org.py,qa,com.qa,edu.qa,gov.qa,mil.qa,name.qa,net.qa,org.qa,sch.qa,re,asso.re,com.re,nom.re,ro,arts.ro,com.ro,firm.ro,info.ro,nom.ro,nt.ro,org.ro,rec.ro,store.ro,tm.ro,www.ro,rs,ac.rs,co.rs,edu.rs,gov.rs,in.rs,org.rs,ru,rw,ac.rw,co.rw,coop.rw,gov.rw,mil.rw,net.rw,org.rw,sa,com.sa,net.sa,org.sa,gov.sa,med.sa,pub.sa,edu.sa,sch.sa,sb,com.sb,edu.sb,gov.sb,net.sb,org.sb,sc,com.sc,gov.sc,net.sc,org.sc,edu.sc,sd,com.sd,net.sd,org.sd,edu.sd,med.sd,tv.sd,gov.sd,info.sd,se,a.se,ac.se,b.se,bd.se,brand.se,c.se,d.se,e.se,f.se,fh.se,fhsk.se,fhv.se,g.se,h.se,i.se,k.se,komforb.se,kommunalforbund.se,komvux.se,l.se,lanbib.se,m.se,n.se,naturbruksgymn.se,o.se,org.se,p.se,parti.se,pp.se,press.se,r.se,s.se,t.se,tm.se,u.se,w.se,x.se,y.se,z.se,sg,com.sg,net.sg,org.sg,gov.sg,edu.sg,per.sg,sh,com.sh,net.sh,gov.sh,org.sh,mil.sh,si,sj,sk,sl,com.sl,net.sl,edu.sl,gov.sl,org.sl,sm,sn,art.sn,com.sn,edu.sn,gouv.sn,org.sn,perso.sn,univ.sn,so,com.so,edu.so,gov.so,me.so,net.so,org.so,sr,ss,biz.ss,com.ss,edu.ss,gov.ss,me.ss,net.ss,org.ss,sch.ss,st,co.st,com.st,consulado.st,edu.st,embaixada.st,mil.st,net.st,org.st,principe.st,saotome.st,store.st,su,sv,com.sv,edu.sv,gob.sv,org.sv,red.sv,sx,gov.sx,sy,edu.sy,gov.sy,net.sy,mil.sy,com.sy,org.sy,sz,co.sz,ac.sz,org.sz,tc,td,tel,tf,tg,th,ac.th,co.th,go.th,in.th,mi.th,net.th,or.th,tj,ac.tj,biz.tj,co.tj,com.tj,edu.tj,go.tj,gov.tj,int.tj,mil.tj,name.tj,net.tj,nic.tj,org.tj,test.tj,web.tj,tk,tl,gov.tl,tm,com.tm,co.tm,org.tm,net.tm,nom.tm,gov.tm,mil.tm,edu.tm,tn,com.tn,ens.tn,fin.tn,gov.tn,ind.tn,info.tn,intl.tn,mincom.tn,nat.tn,net.tn,org.tn,perso.tn,tourism.tn,to,com.to,gov.to,net.to,org.to,edu.to,mil.to,tr,av.tr,bbs.tr,bel.tr,biz.tr,com.tr,dr.tr,edu.tr,gen.tr,gov.tr,info.tr,mil.tr,k12.tr,kep.tr,name.tr,net.tr,org.tr,pol.tr,tel.tr,tsk.tr,tv.tr,web.tr,nc.tr,tt,co.tt,com.tt,org.tt,net.tt,biz.tt,info.tt,pro.tt,int.tt,coop.tt,jobs.tt,mobi.tt,travel.tt,museum.tt,aero.tt,name.tt,gov.tt,edu.tt,tv,tw,edu.tw,gov.tw,mil.tw,com.tw,net.tw,org.tw,idv.tw,game.tw,ebiz.tw,club.tw,tz,ac.tz,co.tz,go.tz,hotel.tz,info.tz,me.tz,mil.tz,mobi.tz,ne.tz,or.tz,sc.tz,tv.tz,ua,com.ua,edu.ua,gov.ua,in.ua,net.ua,org.ua,ug,co.ug,or.ug,ac.ug,sc.ug,go.ug,ne.ug,com.ug,org.ug,uk,ac.uk,co.uk,gov.uk,ltd.uk,me.uk,net.uk,nhs.uk,org.uk,plc.uk,police.uk,us,dni.us,fed.us,isa.us,kids.us,nsn.us,ak.us,al.us,ar.us,as.us,az.us,ca.us,co.us,ct.us,dc.us,de.us,fl.us,ga.us,gu.us,hi.us,ia.us,id.us,il.us,in.us,ks.us,ky.us,la.us,ma.us,md.us,me.us,mi.us,mn.us,mo.us,ms.us,mt.us,nc.us,nd.us,ne.us,nh.us,nj.us,nm.us,nv.us,ny.us,oh.us,ok.us,or.us,pa.us,pr.us,ri.us,sc.us,sd.us,tn.us,tx.us,ut.us,vi.us,vt.us,va.us,wa.us,wi.us,wv.us,wy.us,uy,com.uy,edu.uy,gub.uy,mil.uy,net.uy,org.uy,uz,co.uz,com.uz,net.uz,org.uz,va,vc,com.vc,net.vc,org.vc,gov.vc,mil.vc,edu.vc,ve,arts.ve,bib.ve,co.ve,com.ve,e12.ve,edu.ve,firm.ve,gob.ve,gov.ve,info.ve,int.ve,mil.ve,net.ve,nom.ve,org.ve,rar.ve,rec.ve,store.ve,tec.ve,web.ve,vg,vi,co.vi,com.vi,k12.vi,net.vi,org.vi,vn,ac.vn,ai.vn,biz.vn,com.vn,edu.vn,gov.vn,health.vn,id.vn,info.vn,int.vn,io.vn,name.vn,net.vn,org.vn,pro.vn,vu,com.vu,edu.vu,net.vu,org.vu,wf,ws,com.ws,net.ws,org.ws,gov.ws,edu.ws,yt,ye,com.ye,edu.ye,gov.ye,net.ye,mil.ye,org.ye,ac.za,agric.za,alt.za,co.za,edu.za,gov.za,grondar.za,law.za,mil.za,net.za,ngo.za,nic.za,nis.za,nom.za,org.za,school.za,tm.za,web.za,zm,ac.zm,biz.zm,co.zm,com.zm,edu.zm,gov.zm,info.zm,mil.zm,net.zm,org.zm,sch.zm,zw,ac.zw,co.zw,gov.zw,mil.zw,org.zw".split(","),Tl={};jl.forEach(e=>{Tl[e]=!0});var Rl=Tl;function Ll(e){const[t]=e.split(":"),r=t.split(".");if("localhost"===r[r.length-1]||r.length<2)return r[r.length-1];{const e=r[r.length-2]+"."+r[r.length-1];return r.length>2&&Rl[e]?r[r.length-3]+"."+e:e}}var Nl=class{constructor(e){this.selfOptions=e||{},this.pipes={}}options(e){return e&&(this.selfOptions=e),this.selfOptions}pipe(e,t){let r=t;if("string"==typeof e){if(void 0===r)return this.pipes[e];this.pipes[e]=r}if(e&&e.name){if(r=e,r.processor===this)return r;this.pipes[r.name]=r}return r.processor=this,r}process(e,t){let r=e;r.options=this.options();let n,i=t||e.pipe||"default";for(;i;)void 0!==r.nextAfterChildren&&(r.next=r.nextAfterChildren,r.nextAfterChildren=null),"string"==typeof i&&(i=this.pipe(i)),i.process(r),n=i,i=null,r&&r.next&&(r=r.next,i=r.pipe||n);return r.hasResult?r.result:void 0}},Ul=class{constructor(e){this.name=e,this.filters=[]}process(e){if(!this.processor)throw new Error("add this pipe to a processor before using it");const t=this.debug,r=this.filters.length,n=e;for(let e=0;e<r;e++){const r=this.filters[e];if(t&&this.log(`filter: ${r.filterName}`),r(n),"object"==typeof n&&n.exiting){n.exiting=!1;break}}!n.next&&this.resultCheck&&this.resultCheck(n)}log(e){console.log(`[jsondiffpatch] ${this.name} pipe, ${e}`)}append(...e){return this.filters.push(...e),this}prepend(...e){return this.filters.unshift(...e),this}indexOf(e){if(!e)throw new Error("a filter name is required");for(let t=0;t<this.filters.length;t++){if(this.filters[t].filterName===e)return t}throw new Error(`filter not found: ${e}`)}list(){return this.filters.map(e=>e.filterName)}after(e,...t){const r=this.indexOf(e);return this.filters.splice(r+1,0,...t),this}before(e,...t){const r=this.indexOf(e);return this.filters.splice(r,0,...t),this}replace(e,...t){const r=this.indexOf(e);return this.filters.splice(r,1,...t),this}remove(e){const t=this.indexOf(e);return this.filters.splice(t,1),this}clear(){return this.filters.length=0,this}shouldHaveResult(e){if(!1!==e){if(!this.resultCheck)return this.resultCheck=e=>{if(!e.hasResult){console.log(e);const t=new Error(`${this.name} failed`);throw t.noResult=!0,t}},this}else this.resultCheck=null}},ql=class{setResult(e){return this.result=e,this.hasResult=!0,this}exit(){return this.exiting=!0,this}push(e,t){return e.parent=this,void 0!==t&&(e.childName=t),e.root=this.root||this,e.options=e.options||this.options,this.children?(this.children[this.children.length-1].next=e,this.children.push(e)):(this.children=[e],this.nextAfterChildren=this.next||null,this.next=e),e.next=this,this}},zl=class extends ql{constructor(e,t){super(),this.left=e,this.right=t,this.pipe="diff"}setResult(e){return super.setResult(e)}},$l=class extends ql{constructor(e,t){super(),this.left=e,this.delta=t,this.pipe="patch"}};var Ml=function(e){if(e.left!==e.right)if(void 0!==e.left)if(void 0!==e.right){if("function"==typeof e.left||"function"==typeof e.right)throw new Error("functions are not supported");if(e.leftType=null===e.left?"null":typeof e.left,e.rightType=null===e.right?"null":typeof e.right,e.leftType===e.rightType)if("boolean"!==e.leftType&&"number"!==e.leftType&&"string"!==e.leftType){if("object"===e.leftType&&(e.leftIsArray=Array.isArray(e.left)),"object"===e.rightType&&(e.rightIsArray=Array.isArray(e.right)),e.leftIsArray===e.rightIsArray)return e.leftIsArray&&e.rightIsArray?function(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}(e.left,e.right)?void e.setResult(void 0).exit():void e.setResult([e.left,e.right]).exit():void(e.left instanceof RegExp&&(e.right instanceof RegExp?e.setResult([e.left.toString(),e.right.toString()]).exit():e.setResult([e.left,e.right]).exit()));e.setResult([e.left,e.right]).exit()}else e.setResult([e.left,e.right]).exit();else e.setResult([e.left,e.right]).exit()}else e.setResult([e.left,0,0]).exit();else{if("function"==typeof e.right)throw new Error("functions are not supported");e.setResult([e.right]).exit()}else e.setResult(void 0).exit()};Ml.filterName="trivial";var Hl=function(e){if(void 0===e.delta)return void e.setResult(e.left).exit();if(e.nested=!Array.isArray(e.delta),e.nested)return;const t=e.delta;if(1!==t.length)if(2!==t.length)3===t.length&&0===t[2]&&e.setResult(void 0).exit();else{if(e.left instanceof RegExp){const r=/^\/(.*)\/([gimyu]+)$/.exec(t[1]);if(r)return void e.setResult(new RegExp(r[1],r[2])).exit()}e.setResult(t[1]).exit()}else e.setResult(t[0]).exit()};Hl.filterName="trivial";var Wl=e=>{if(!e||!e.children)return;const t=e.children.length;let r,n=e.result;for(let i=0;i<t;i++)r=e.children[i],void 0!==r.result&&(n=n||{},n[r.childName]=r.result);n&&e.leftIsArray&&(n._t="a"),e.setResult(n).exit()};Wl.filterName="collectChildren";var Gl=e=>{if(e.leftIsArray||"object"!==e.leftType)return;const t=e.left,r=e.right;let n,i;const o=e.options.propertyFilter;for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&(o&&!o(n,e)||(i=new zl(t[n],r[n]),e.push(i,n)));for(n in r)Object.prototype.hasOwnProperty.call(r,n)&&(o&&!o(n,e)||void 0===t[n]&&(i=new zl(void 0,r[n]),e.push(i,n)));e.children&&0!==e.children.length?e.exit():e.setResult(void 0).exit()};Gl.filterName="objects";var Jl=function(e){if(!e.nested)return;const t=e.delta;if(t._t)return;const r=t;let n,i;for(n in r)i=new $l(e.left[n],r[n]),e.push(i,n);e.exit()};Jl.filterName="objects";var Vl=function(e){if(!e||!e.children)return;if(e.delta._t)return;const t=e.left,r=e.children.length;let n;for(let i=0;i<r;i++){n=e.children[i];const r=n.childName;Object.prototype.hasOwnProperty.call(e.left,r)&&void 0===n.result?delete t[r]:t[r]!==n.result&&(t[r]=n.result)}e.setResult(t).exit()};Vl.filterName="collectChildren";var Kl=function(e){e.left instanceof Date?(e.right instanceof Date?e.left.getTime()!==e.right.getTime()?e.setResult([e.left,e.right]):e.setResult(void 0):e.setResult([e.left,e.right]),e.exit()):e.right instanceof Date&&e.setResult([e.left,e.right]).exit()};Kl.filterName="dates";var Ql=class{constructor(e){this.processor=new Nl(e),this.processor.pipe(new Ul("diff").append(Wl,Ml,Kl,Gl).shouldHaveResult()),this.processor.pipe(new Ul("patch").append(Vl,Hl,Jl).shouldHaveResult())}options(e){return this.processor.options(e)}diff(e,t){return this.processor.process(new zl(e,t))}patch(e,t){return this.processor.process(new $l(e,t))}};var Xl,Yl=new Ql(Xl),Zl={writeKey:void 0,host:void 0,debug:!1,fetch:void 0,echoEvents:!1,cookieDomain:void 0,cookieNames:{},cookieCapture:{},runtime:void 0,fetchTimeoutMs:void 0,s2s:void 0,idEndpoint:void 0,errorPolicy:"log",defaultPayloadContext:{},privacy:{dontSend:!1,disableUserIds:!1,ipPolicy:"keep",consentCategories:{}}},ec=(e,t)=>{for(const r of Object.keys(Zl)){const n=t[r];"privacy"===r?"object"==typeof n?e.privacy=Ma(Ma(Ha(Ma({},Zl.privacy),{consentCategories:Ma({},Zl.privacy.consentCategories)}),e.privacy),n):void 0===n&&(!t.hasOwnProperty("privacy")&&e.hasOwnProperty("privacy")||(e.privacy=Ha(Ma({},Zl.privacy),{consentCategories:Ma({},Zl.privacy.consentCategories)}))):void 0===n?!t.hasOwnProperty(r)&&e.hasOwnProperty(r)||(e[r]=Zl[r]):e[r]=n}};function tc(e){const t=e.substring(4);return"campaign"===t?"name":t}function rc(e){return Object.entries(e).filter(([e])=>0===e.indexOf("utm_")).reduce((e,[t,r])=>Ha(Ma({},e),{[tc(t)]:r}),{})}function nc(e,t){try{return e()}catch(e){return t}}function ic(e){let t=e.getItem("__user_traits");"string"==typeof t&&(t=nc(()=>JSON.parse(t),{})),("object"!=typeof t||null===t||Array.isArray(t))&&(t={});let r=e.getItem("__group_traits");return"string"==typeof r&&(r=nc(()=>JSON.parse(r),{})),("object"!=typeof r||null===r||Array.isArray(r))&&(r={}),Ma(Ma({},r||{}),t||{})}function oc(e){var t;const r=`; ${document.cookie}`.split(`; ${e}=`);return 2===r.length?null==(t=r.pop())?void 0:t.split(";").shift():void 0}function ac(e,t){const r=Ma({fbc:"_fbc",fbp:"_fbp"},t),n=Object.entries(r).reduce((t,[r,n])=>(t[r]=e.getCookie(n),t),{});return Ma(Ma({},n),function(e){var t;const r=e.getCookies(),n=null==(t=r._ga)?void 0:t.split(".").slice(-2).join("."),i=Object.entries(r).filter(([e])=>e.startsWith("_ga_")),o=i.length>0?Object.fromEntries(i.map(([e,t])=>{const r=function(e){if("string"!=typeof e)return;if(e.startsWith("GA1")||e.startsWith("GS1"))return e.split(".")[2];{const t=e.match(/^GS\d+\.\d+\.(?:[\w_-]+[$])*s(\d+)(?:$|[$])/);return t?t[1]:void 0}}(t);return r?[e.substring(4),r]:null}).filter(e=>null!==e)):void 0;return n||o?{ga4:{clientId:n,sessionIds:o}}:void 0}(e))}function sc(e,{domain:t,secure:r}){document.cookie=e+"=;domain="+t+";path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT;SameSite="+(r?"None":"Lax")+(r?";secure":"")}function uc(e,t,{domain:r,secure:n}){document.cookie=e+"="+t+";domain="+r+";path=/;expires="+new Date((new Date).getTime()+15768e7).toUTCString()+";SameSite="+(n?"None":"Lax")+(n?";secure":"")}var lc={__anon_id:"__eventn_id",__user_id:"__eventn_uid",__user_traits:"__eventn_id_usr",__group_id:"__group_id",__group_traits:"__group_traits"};function cc(e){const t=t=>{var r,n,i,o,a;switch(t){case"__anon_id":return(null==(r=e.cookieNames)?void 0:r.anonymousId)||lc.__anon_id;case"__user_id":return(null==(n=e.cookieNames)?void 0:n.userId)||lc.__user_id;case"__user_traits":return(null==(i=e.cookieNames)?void 0:i.userTraits)||lc.__user_traits;case"__group_id":return(null==(o=e.cookieNames)?void 0:o.groupId)||lc.__group_id;case"__group_traits":return(null==(a=e.cookieNames)?void 0:a.groupTraits)||lc.__group_traits;default:return t}};return{getCookie(e){var t;const r=`; ${document.cookie}`.split(`; ${e}=`);return 2===r.length?null==(t=r.pop())?void 0:t.split(";").shift():void 0},getCookies(){const e={},t=`; ${document.cookie}`.matchAll(/(\w+)=([^;]+)/g);for(const r of t)e[r[1]]=r[2];return e},documentEncoding:()=>window.document.characterSet,timezoneOffset:()=>(new Date).getTimezoneOffset(),store(){return r=e.cookieDomain||Ll(window.location.hostname),n=t,{setItem(e,t){const i=n(e)||e;void 0!==t?uc(i,"object"==typeof t&&null!==t?encodeURIComponent(JSON.stringify(t)):t,{domain:r,secure:"https:"===window.location.protocol}):sc(i,{domain:r,secure:"https:"===window.location.protocol})},getItem(e){const t=oc(n(e)||e);if("__anon_id"===e)return t;if(void 0===t&&"__user_id"===e){const e=Ic(oc(n("__user_traits")||"__eventn_id_usr"))||{};return e.internal_id||e.user_id||e.id||e.userId}return Ic(t)},removeItem(e){sc(n(e)||e,{domain:r,secure:"https:"===window.location.protocol})},reset(){for(const e of Object.keys(lc))sc(n(e)||e,{domain:r,secure:"https:"===window.location.protocol})}};var r,n},language:()=>window.navigator.language,pageTitle:()=>window.document.title,pageUrl:()=>window.location.href,referrer:()=>window.document.referrer,screen:()=>({width:window.screen.width,height:window.screen.height,innerWidth:window.innerWidth,innerHeight:window.innerHeight,density:Math.floor(window.devicePixelRatio)}),userAgent:()=>window.navigator.userAgent}}function dc(e){const t={};return{reset(){Object.keys(t).forEach(e=>delete t[e])},setItem(r,n){e&&console.log(`[JITSU EMPTY RUNTIME] Set storage item ${r}=${JSON.stringify(n)}`),void 0===n?delete t[r]:t[r]=n},getItem(r){const n=t[r];return e&&console.log(`[JITSU EMPTY RUNTIME] Get storage item ${r}=${JSON.stringify(n)}`),n},removeItem(r){e&&console.log(`[JITSU EMPTY RUNTIME] Get storage item ${r}=${t[r]}`),delete t[r]}}}var hc=e=>({documentEncoding(){},timezoneOffset(){},getCookie(e){},getCookies:()=>({}),store:()=>dc(e.debug),language(){},pageTitle(){},pageUrl(){},referrer(){},screen(){},userAgent(){}});function pc(e){return"object"!=typeof e?e:e?JSON.parse(JSON.stringify(e)):e}function fc(e,t){return"object"!=typeof t||null===t||Array.isArray(t)||t instanceof Date||"object"!=typeof e||null===e||Array.isArray(e)||e instanceof Date?t:Object.entries(t).reduce((t,[r,n])=>(t[r]=fc(e[r],n),t),e)}function gc(){return"undefined"!=typeof document&&"undefined"!=typeof window}var mc=/#.*$/;function vc(){if(!gc())return;const e=function(){if(!gc())return;const e=document.getElementsByTagName("link");for(var t,r=0;t=e[r];r++)if("canonical"===t.getAttribute("rel"))return t.getAttribute("href")}();return e?e.match(/\?/)?e:e+window.location.search:window.location.href.replace(mc,"")}function yc(e,t,r,n){var i,o,a,s,u,l,c,d,h,p,f,g,m,v,y;const D=t.runtime||(gc()?cc(t):hc(t)),b=D.pageUrl(),F=b?nc(()=>new URL(b),void 0):void 0,w=F?(e=>{if(!e)return{};let t=e.length>0&&"?"===e.charAt(0)?e.substring(1):e,r={},n=("?"===t[0]?t.substr(1):t).split("&");for(let e=0;e<n.length;e++){let t=n[e].split("=");r[decodeURIComponent(t[0])]=decodeURIComponent(t[1]||"")}return r})(F.search):{},E=e.properties||{};if("page"===e.type&&(E.url||b)){let e=b||E.url;E.url&&E.url!==vc()&&(e=E.url),E.url=e.replace(mc,""),E.path=(S=function(e){const t=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e);return"/"+(t&&t[3]?t[3].split("?")[0].replace(mc,""):"")}(e),0===S.indexOf("//")&&1===S.lastIndexOf("/")?"/":S)}var S;const _=fc(t.defaultPayloadContext,(null==(i=e.properties)?void 0:i.context)||(null==(o=e.options)?void 0:o.context)||{});null==(a=e.properties)||delete a.context;const A=D.referrer(),C={library:{name:"@jitsu/js",version:"1.11.0",env:gc()?"browser":"node"},consent:"object"==typeof(null==(s=t.privacy)?void 0:s.consentCategories)&&Object.keys(null==(u=t.privacy)?void 0:u.consentCategories).length?{categoryPreferences:t.privacy.consentCategories}:void 0,userAgent:null==(l=D.userAgent)?void 0:l.call(D),locale:null==(c=D.language)?void 0:c.call(D),screen:null==(d=D.screen)?void 0:d.call(D),ip:null==(h=null==D?void 0:D.ip)?void 0:h.call(D),traits:"identify"!=e.type&&"group"!=e.type?Ma(Ma({},ic(r)||{}),(null==(p=null==e?void 0:e.options)?void 0:p.traits)||{}):void 0,page:{path:E.path||F&&F.pathname,referrer:A,referring_domain:nc(()=>A&&new URL(A).hostname),host:F&&F.host,search:E.search||F&&F.search,title:E.title||D.pageTitle(),url:E.url||b,encoding:E.encoding||D.documentEncoding()},clientIds:(null==(f=t.privacy)?void 0:f.disableUserIds)?void 0:ac(D,t.cookieCapture||{}),campaign:rc(w)},k=Ha(Ma({},e),{userId:(null==(g=null==e?void 0:e.options)?void 0:g.userId)||(null==e?void 0:e.userId),anonymousId:(null==(m=null==e?void 0:e.options)?void 0:m.anonymousId)||(null==e?void 0:e.anonymousId),groupId:(null==(v=null==e?void 0:e.options)?void 0:v.groupId)||r.getItem("__group_id"),timestamp:(new Date).toISOString(),sentAt:(new Date).toISOString(),messageId:kc(E.path||F&&F.pathname),writeKey:bc(t.writeKey),context:fc(C,_)});return delete k.meta,delete k.options,(null==(y=t.privacy)?void 0:y.disableUserIds)&&(delete k.userId,delete k.anonymousId,delete k.context.traits,delete k.groupId),k}function Dc(e){const t=Object.keys(e);return 1===t.length&&"__diff"===t[0]}function bc(e){if(e){const[t,r]=e.split(":",2);return r?`${t}:***`:"***"}return e}function Fc(e){const t=e.errorPolicy||"log";return"function"==typeof t?t:"rethrow"===t?(e,...t)=>{throw new Error(e)}:(e,...t)=>{console.error(e,...t)}}function wc(e,t,r,n,i,o){return Wa(this,null,function*(){var a,s;const u=!!r.s2s,l=r.debug?{"X-Enable-Debug":"true"}:{},c=yc(t,r,i);if(r.echoEvents)return void console.log(`[JITSU DEBUG] sending '${e}' event:`,c);const d=u?`${r.host}/api/s/s2s/${e}`:`${r.host}/api/s/${e}`,h=r.fetch||globalThis.fetch;if(!h)throw new Error("Please specify fetch function in jitsu plugin initialization, fetch isn't available in global scope");const p=r.fetchTimeoutMs?new AbortController:void 0,f=r.fetchTimeoutMs?setTimeout(()=>{null==p||p.abort()},r.fetchTimeoutMs):void 0,g=r.writeKey?{"X-Write-Key":r.writeKey}:{},m=void 0===(null==(a=r.privacy)?void 0:a.ipPolicy)||"keep"===(null==(s=r.privacy)?void 0:s.ipPolicy)?{}:{"X-IP-Policy":r.privacy.ipPolicy};let v,y,D;try{v=yield h(d,{method:"POST",headers:Ma(Ma(Ma({"Content-Type":"application/json"},g),l),m),body:JSON.stringify(c),signal:null==p?void 0:p.signal}),f&&clearTimeout(f)}catch(e){return(o?e=>console.warn(e):Fc(r))(`Call to ${d} failed with error ${e.message}`),Promise.resolve()}try{y=yield v.text()}catch(e){console.warn(`Can't read response text from ${d} (status - ${v.status} ${v.statusText}): ${null==e?void 0:e.message}`)}if(r.debug&&console.log(`[JITSU DEBUG] ${d} replied ${v.status}: ${y}. Original payload:\n${JSON.stringify(c,null,2)}`),!v.ok){return(o?e=>console.warn(e):Fc(r))(`Call to ${d} failed with error: ${v.status} - ${v.statusText}: ${y}`),Promise.resolve()}try{D=JSON.parse(y)}catch(e){return(o?e=>console.warn(e):Fc(r))(`Can't parse JSON: ${y}: ${null==e?void 0:e.message}`),Promise.resolve()}if(D.destinations&&D.destinations.length>0)if(r.s2s)console.warn(`[JITSU] ${t.type} responded with list of ${D.destinations.length} destinations. However, this code is running in server-to-server mode, so destinations will be ignored`,r.debug?JSON.stringify(D.destinations,null,2):void 0);else if(gc())return r.debug&&console.log("[JITSU] Processing device destinations: ",JSON.stringify(D.destinations,null,2)),function(e,t,r,n,i){return Wa(this,null,function*(){const o=[];for(const a of e){let e=[];if(a.newEvents)try{e=a.newEvents.map(e=>"same"===e?pc(r):Dc(e)?Yl.patch(pc(r),e.__diff):e)}catch(e){console.error(`[JITSU] Error applying '${a.id}' changes to event: ${null==e?void 0:e.message}`,e)}else e=[pc(r)];const s=Ma(Ma({},a.credentials),a.options);if("internal-plugin"===a.deviceOptions.type){const t=Bl[a.deviceOptions.name];if(t)for(const r of e)try{o.push(t.handle(Ha(Ma({},s),{debug:n}),r))}catch(e){console.warn(`[JITSU] Error processing event with internal plugin '${a.deviceOptions.name}': ${null==e?void 0:e.message}`,e)}else console.warn(`[JITSU] Unknown internal plugin '${a.deviceOptions.name}' for destination '${a.id}'`)}else if("analytics-plugin"===a.deviceOptions.type){yield gl(a.deviceOptions.packageCdn);const r=window[a.deviceOptions.moduleVarName];if(r){let o;try{o=("function"==typeof r?r:r.init)(s)}catch(e){console.warn(`[JITSU] Error creating plugin '${a.deviceOptions.moduleVarName}@${a.deviceOptions.packageCdn}' for destination '${a.id}': ${null==e?void 0:e.message}`,e)}try{n&&console.log(`[JITSU] Plugin '${a.deviceOptions.moduleVarName}@${a.deviceOptions.packageCdn}' for destination '${a.id}' initialized with config:`,o.config),o.initialize({config:o.config,instance:i})}catch(e){console.warn(`[JITSU] Error initializing plugin '${a.deviceOptions.moduleVarName}@${a.deviceOptions.packageCdn}' for destination '${a.id}': ${null==e?void 0:e.message}. Config: ${JSON.stringify(o.config)}`,e);continue}if(o[t])for(const r of e)try{o[t]({payload:r,config:o.config,instance:i})}catch(e){console.warn(`[JITSU] Error processing ${t}() with plugin '${a.deviceOptions.moduleVarName}@${a.deviceOptions.packageCdn}' for destination '${a.id}': ${null==e?void 0:e.message}`,e)}}else console.warn(`[JITSU] Broken plugin '${a.deviceOptions.packageCdn}' for destination '${a.id}' - it doesn't export '${a.deviceOptions.moduleVarName}' variable`)}}})}(D.destinations,e,c,!!r.debug,n);return c})}var Ec=["$doNotSend"];function Sc(e){const t=Ma({},e);for(const e of Ec)delete t[e];return t}var _c=(e={},t)=>(ec(e,e),{name:"jitsu",config:e,initialize:e=>Wa(null,null,function*(){const{config:t}=e;if(t.debug&&console.debug("[JITSU DEBUG] Initializing Jitsu plugin with config: ",JSON.stringify(t,null,2)),!t.host&&!t.echoEvents)throw new Error("Please specify host variable in jitsu plugin initialization, or set echoEvents to true");if(function(e){if(e){const[,r]=e.split(":",2);if(!r&&(25!==(t=e).length||"c"!==t.charAt(0)))throw new Error(`Legacy write key detected - ${e}! This format doesn't work anymore, it should be 'key:secret'. Please download a new key from Jitsu UI`)}var t}(t.writeKey),t.idEndpoint){if(!gc())return void console.error("[JITSU] 'idEndpoint' option can be used only in browser environment");try{const e=t.fetch||globalThis.fetch,r=new AbortController;setTimeout(()=>r.abort(),1e3);const n=t.cookieDomain||Ll(window.location.hostname),i=yield e(t.idEndpoint+"?domain="+encodeURIComponent(n),{credentials:"include",signal:r.signal});i.ok?t.debug&&console.log(`[JITSU DEBUG] Fetch idEndpoint: ${i.status}`):console.error(`[JITSU] Can't fetch idEndpoint: ${i.status} - ${i.statusText}`)}catch(e){console.error(`[JITSU] Can't fetch idEndpoint: ${e.message}`)}}}),page:e=>{var r;const{payload:n,config:i,instance:o}=e;if(null==(r=i.privacy)?void 0:r.dontSend)return;const a=wc("page",n,i,o,t);return a&&"function"==typeof a.catch&&a.catch(()=>{}),a},track:e=>{var r;const{payload:n,config:i,instance:o}=e;if(null==(r=i.privacy)?void 0:r.dontSend)return;const a=wc("track",n,i,o,t);return a&&"function"==typeof a.catch&&a.catch(()=>{}),a},identify:e=>{var r,n,i,o;const{payload:a,config:s,instance:u}=e;if((null==(r=s.privacy)?void 0:r.dontSend)||(null==(n=s.privacy)?void 0:n.disableUserIds))return;t.setItem("__user_id",a.userId);const l=null==(i=a.traits)?void 0:i.$doNotSend;if(a.traits&&"object"==typeof a.traits&&(a.traits=Sc(a.traits),t.setItem("__user_traits",a.traits)),l)return Promise.resolve();const c=!0===(null==(o=a.options)?void 0:o.autoIdentify),d=wc("identify",a,s,u,t,c);return d&&"function"==typeof d.catch&&d.catch(()=>{}),d},reset:e=>{const{config:r,instance:n}=e;t.reset(),r.debug&&console.log("[JITSU DEBUG] Resetting Jitsu plugin storage")},methods:{configure(r){var n,i,o,a;const s=(null==(n=e.privacy)?void 0:n.disableUserIds)||(null==(i=e.privacy)?void 0:i.dontSend);ec(e,r);if(!((null==(o=e.privacy)?void 0:o.disableUserIds)||(null==(a=e.privacy)?void 0:a.dontSend))&&s){e.debug&&console.log("[JITSU] Enabling Anonymous ID. Generating new Id.");const r=this.instance,n=xc(),i=r.user();i&&(i.anonymousId=n),t.setItem("__anon_id",n),r.setAnonymousId(n)}},group(r,n,i,o){var a,s;if((null==(a=e.privacy)?void 0:a.dontSend)||(null==(s=e.privacy)?void 0:s.disableUserIds))return;"number"==typeof r&&(r+="");const u=this.instance,l=u.user(),c=(null==i?void 0:i.userId)||(null==l?void 0:l.userId),d=(null==i?void 0:i.anonymousId)||(null==l?void 0:l.anonymousId)||t.getItem("__anon_id");t.setItem("__group_id",r);const h=null==n?void 0:n.$doNotSend;return n&&"object"==typeof n&&(n=Sc(n),t.setItem("__group_traits",n)),h?Promise.resolve():wc("group",Ma(Ma({type:"group",groupId:r,traits:n},d?{anonymousId:d}:{}),c?{userId:c}:{}),e,u,t)}}}),Ac=0;function Cc(){var e;Ac=(Ac+1)%Number.MAX_SAFE_INTEGER;const t=Date.now()%2147483647;return(gc()&&(null==(e=null==window?void 0:window.performance)?void 0:e.now())||t)+Ac}function kc(e=""){const t=Date.now();return(Math.random()*t*Pc(null!=e?e:"",Cc())%Number.MAX_SAFE_INTEGER).toString(36)+(Math.random()*t*Pc(null!=e?e:"",Cc())%Number.MAX_SAFE_INTEGER).toString(36)}function xc(){for(var e="",t=0,r=4294967295*Math.random()|0;t++<36;){var n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[t-1],i=15&r;e+="-"==n||"4"==n?n:("x"==n?i:3&i|8).toString(16),r=t%8==0?4294967295*Math.random()|0:r>>4}return e}function Pc(e,t=0){let r=3735928559^t,n=1103547991^t;for(let t,i=0;i<e.length;i++)t=e.charCodeAt(i),r=Math.imul(r^t,2654435761),n=Math.imul(n^t,1597334677);return r=Math.imul(r^r>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(r^r>>>13,3266489909),4294967296*(2097151&n)+(r>>>0)}function Ic(e){let t=e;0===(null==e?void 0:e.indexOf("%7B%22"))&&(t=decodeURIComponent(e));try{if(t=JSON.parse(t),"true"===t)return!0;if("false"===t)return!1;if("object"==typeof t)return t;parseFloat(t)===t&&(t=parseFloat(t))}catch(e){}if(null!==t&&""!==t)return t}function Oc(e,t,r=[]){var n,i,o,a,s;const u={};let l=!1;const c=t=>({setItem(r,n){var i,o;(null==(i=e.privacy)?void 0:i.dontSend)||(null==(o=e.privacy)?void 0:o.disableUserIds)||(e.debug&&console.log(`[JITSU DEBUG] [Caching storage] setItem: ${r}=${n}`),u[r]=n,t.setItem(r,n))},getItem(r){var n,i;if((null==(n=e.privacy)?void 0:n.dontSend)||(null==(i=e.privacy)?void 0:i.disableUserIds))return;const o=u[r]||t.getItem(r);return e.debug&&console.log(`[JITSU DEBUG] [Caching storage] getItem: ${r}=${o}. From cache: ${!!u[r]}`),o},reset(){for(const e of[...Object.keys(u)])delete u[e];t.reset()},removeItem(r){e.debug&&console.log(`[JITSU DEBUG] Caching storage removeItem: ${r}`),delete u[r],t.removeItem(r)}}),d=c((null==(n=t.store)?void 0:n.call(t))||dc(e.debug));!e.userId||(null==(i=e.privacy)?void 0:i.disableUserIds)||(null==(o=e.privacy)?void 0:o.dontSend)||d.setItem("__user_id",e.userId);const h=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Uu(fl(fl({},{storage:dl}),e))}({debug:!!e.debug,storage:d,plugins:[_c(e,d),...r]}),p=Ha(Ma({},h),{page:(...e)=>2===e.length&&"string"==typeof e[0]&&"object"==typeof e[1]?h.page(Ma({name:e[0]},e[1])):h.page(...e),identify:(...e)=>{e[0]&&"object"!=typeof e[0]&&"string"!=typeof e[0]&&(e[0]=e[0]+"");const t=h.storage,r=c(t);return"string"==typeof e[0]?r.setItem("__user_id",e[0]):"object"==typeof e[0]&&r.setItem("__user_traits",e[0]),2===e.length&&"object"==typeof e[1]&&r.setItem("__user_traits",e[1]),h.identify(...e)},setContextProperty(t,r){e.debug&&console.log(`[JITSU DEBUG] Setting context property '${t}':${JSON.stringify(r)}`),e.defaultPayloadContext?e.defaultPayloadContext[t]=r:e.defaultPayloadContext={[t]:r}},getContextProperty(t){var r;return e.debug&&console.log(`[JITSU DEBUG] Getting context property '${t}'`),null==(r=e.defaultPayloadContext)?void 0:r[t]},user(){var t,r;const n=h.user();return(null==(t=e.privacy)?void 0:t.disableUserIds)||(null==(r=e.privacy)?void 0:r.dontSend)?Ha(Ma({},n),{id:void 0}):n&&!n.id&&e.userId&&!l?Ha(Ma({},n),{id:e.userId}):n},setAnonymousId:t=>{e.debug&&console.log("[JITSU DEBUG] Setting anonymous id to "+t),d.setItem("__anon_id",t);const r=h.user();r&&(r.anonymousId=t),h.setAnonymousId(t)},reset(){return Wa(this,null,function*(){l=!0,e.debug&&console.log("[JITSU DEBUG] Called reset(). Storage state",JSON.stringify(h.user())),d.reset(),yield h.reset(),this.setAnonymousId(xc()),e.debug&&console.log("[JITSU DEBUG] User state after reset",JSON.stringify(h.user()))})},configure(t){return Wa(this,null,function*(){var r,n;e.debug&&console.log("[JITSU DEBUG] Update Jitsu config with",JSON.stringify(t)),((null==(r=t.privacy)?void 0:r.disableUserIds)||(null==(n=t.privacy)?void 0:n.dontSend))&&d.reset();for(const e of Object.values(h.plugins))"function"==typeof e.configure&&e.configure(t)})},group(e,t,r,n){return Wa(this,null,function*(){const i=[];for(const o of Object.values(h.plugins))o.group&&i.push(yield o.group(e,t,r,n));return i[0]})},getConfiguration:()=>e});return(null==(a=e.privacy)?void 0:a.disableUserIds)||(null==(s=e.privacy)?void 0:s.dontSend)?d.reset():e.userId&&p.identify(e.userId,{},{autoIdentify:!0}).catch(t=>{e.debug&&console.warn("[JITSU WARNING] Auto-identification failed on initialization:",t)}),p}function Bc(e){const t=function(e){var t,r;return Ha(Ma({},e),{host:0!==(null!=(t=e.host)?t:"").indexOf("https://")&&0!==(null!=(r=e.host)?r:"").indexOf("http://")?`https://${e.host}`:e.host})}(e);t.preInitAnonymousId&&function(e){var t;if(!gc())return;const r=(null==(t=e.cookieNames)?void 0:t.anonymousId)||lc.__anon_id,n=oc(r);if(n)return n;const i=xc(),o=e.cookieDomain||Ll(window.location.hostname);uc(r,i,{domain:o,secure:"https:"===window.location.protocol}),e.debug&&console.log(`[JITSU DEBUG] preInitAnonymousId: created anonymous ID cookie '${r}'=${i} on domain '${o}'`)}(t);const r=gc();return Oc(t,t.runtime||(r?cc(t):hc(t)))}function jc(e,t,r=(e=>null==(e=Salla.config.currency())?void 0:e.code)()){var n,i,o,a;return{product_id:null==(n=e.id)?void 0:n.toString(),name:e.name,price:e.price,position:t,url:e.url,image_url:null==(i=e.image)?void 0:i.url,currency:r,category:e.category,brand:null!=(o=null==(a=e.brand)?void 0:a.name)?o:e.brand,sku:e.sku}}class Tc{constructor(e){const t=null==e?void 0:e.nextPage;this.listId=salla.config.get("page.slug"),Salla.config.get("page.id")&&(this.listId+=`_${salla.config.get("page.id")}`),this.sorts=null;try{if(t){const e=new URL(t).searchParams.get("sort");e&&(this.sorts=[{type:"sort",value:e}])}e.source&&(this.listId=`${this.listId}_${e.source}`),e.sourceValue&&(this.listId=`${this.listId}_${Array.isArray(e.sourceValue)?e.sourceValue.join("_"):e.sourceValue}`)}catch(e){salla.logger.error(e)}this.products=null==e?void 0:e.data}toSegment(){const e=(salla.config.get("page.title")||"").split("|").map(e=>e.trim()),t=e[0],r=e[1]||null;return{event:"Product List Viewed",properties:{list_id:this.listId,category:t,sub_category:r,sorts:this.sorts,products:this.products.map(e=>{var t,r,n,i,o,a;return{product_id:e.id,category:null==(t=e.category)?void 0:t.name,currency:null==(r=Salla.config.currency())?void 0:r.code,name:e.name,brand:null==(n=e.brand)?void 0:n.name,variant:null==(i=e.variant)?void 0:i.toString(),coupon:null==(o=e.coupon)?void 0:o.toString(),price:e.price,quantity:Number(e.quantity),sku:e.sku,position:0,url:e.url,image_url:null==(a=e.image)?void 0:a.url}})}}}static shouldSend(e){return!((null==e?void 0:e.nextPage)||"").includes("filters")&&!["index","customer.wishlist"].includes(salla.config.get("page.slug"))}}class Rc{constructor(){this.user=JSON.parse(localStorage.getItem("user"))}toSegment(){var e,t,r,n,i;return{event:"Signed In",properties:{first_name:null==(e=this.user)?void 0:e.first_name,last_name:null==(t=this.user)?void 0:t.last_name,type:null==(r=this.user)?void 0:r.type,mobile:null==(n=this.user)?void 0:n.mobile,email:null==(i=this.user)?void 0:i.email}}}static shouldSend(){return"user"===Salla.config.get("user.type")?!Salla.analytics.history.find(({eventName:e})=>"Signed In"===e):(Salla.profile.event.onInfoFetched(()=>Salla.event.emit("Signed In")),!1)}}class Lc{constructor(e){this.details=null==e?void 0:e.data}toSegment(){const e=["first_name","last_name","birthday","gender"].filter(e=>{var t,r;return Lc.user[e]!==(null==(t=this.details)?void 0:t[e])&&(void 0!==Lc.user[e]||void 0!==(null==(r=this.details)?void 0:r[e]))});return Lc.setUser(this.details),{event:"User Profile Updated",properties:{updated_fields:e}}}static registerEvent(){Salla.onReady(()=>{salla.url.is_page("customer.profile")&&Lc.setUser(Salla.config.get("user"))})}static setUser(e){Lc.user={first_name:null==e?void 0:e.first_name,last_name:null==e?void 0:e.last_name,gender:null==e?void 0:e.gender,birthday:null==e?void 0:e.birthday,avatar:null==e?void 0:e.avatar}}static shouldSend(){return"user"===Salla.config.get("user.type")}}Lc.user={};class Nc{static registerEvents(){Object.values(this.events).forEach(e=>{e.forEach(e=>{"function"==typeof e.registerEvent&&e.registerEvent()})})}static transform(e,t){try{const r=this.events[e]||[];for(const e of r){if(!e||"function"==typeof e.shouldSend&&!e.shouldSend(t))continue;const r=new e(t).toSegment();return{event:r.event,properties:r.properties}}return null}catch(e){return console.error("Failed to transform event:",e),null}}}Nc.events={"Order Completed":[class{constructor(e){this.details=e[0]}toSegment(){return{event:"Order Completed",properties:this.details}}}],"Product Added":[class{constructor(e){this.item=e[0]}toSegment(){var e,t,r,n,i;const{product:o,position:a,cartItem:s,cartId:u}=this.item;return{event:"Product Added",properties:Br({},jc(o,a),{cart_id:null==u?void 0:u.toString(),cart_item_id:null==s||null==(e=s.id)?void 0:e.toString(),variant:null!=(t=null==s||null==(r=s.variant)?void 0:r.toString())?t:null,coupon:null!=(n=null==s?void 0:s.coupon)?n:null,quantity:null!=(i=null==s?void 0:s.quantity)?i:1,source:"pdp_fbt"})}}static shouldSend(e){var t;return!(null==e||null==(t=e[0])||!t.product)}},class{constructor(e){var t,r;this.item=e[0],this.source=(null==(t=Salla.cart)||null==(t=t.api)?void 0:t.addToCartSource)||null,null!=(r=Salla.cart)&&r.api&&(Salla.cart.api.addToCartSource=null)}toSegment(){var e,t,r,n,i;return{event:"Product Added",properties:{cart_id:null==(e=this.item.cart_id)?void 0:e.toString(),cart_item_id:null==(t=this.item.cart_item_id)?void 0:t.toString(),product_id:null==(r=this.item.id)?void 0:r.toString(),category:this.item.category,currency:null==(n=Salla.config.currency())?void 0:n.code,name:this.item.name,brand:this.item.brand,variant:null==(i=this.item.variant)?void 0:i.toString(),price:this.item.price,quantity:this.item.quantity,sku:this.item.sku,coupon:this.item.coupon,position:this.item.position,url:this.item.url,image_url:this.item.image_url,source:this.source}}}static shouldSend(e){var t,r;return"customer.wishlist"!==salla.config.get("page.slug")&&("pdp_fbt"!==(null==(t=Salla.cart)||null==(t=t.api)?void 0:t.addToCartSource)||(null!=(r=Salla.cart)&&r.api&&(Salla.cart.api.addToCartSource=null),!1))}},class{constructor(e){this.item=e[0]}toSegment(){var e,t;return{event:"Wishlist Product Added to Cart",properties:{wishlist_id:salla.config.get("store.id")+"_"+salla.config.get("user.id"),wishlist_name:salla.config.get("store.name"),cart_id:null==(e=this.item.cart_id)?void 0:e.toString(),product_id:null==(t=this.item.id)?void 0:t.toString(),category:this.item.category,name:this.item.name,brand:this.item.brand,variant:this.item.variant,price:this.item.price,quantity:this.item.quantity,sku:this.item.sku,coupon:this.item.coupon,position:this.item.position,url:this.item.url,image_url:this.item.image_url}}}static shouldSend(){return"customer.wishlist"===salla.config.get("page.slug")}}],"Product Removed":[class{constructor(e){this.item=e[0]}toSegment(){var e,t,r,n,i,o,a,s,u,l,c,d,h,p;return{event:"Product Removed",properties:{cart_id:null==(e=this.item)||null==(e=e.cart_id)?void 0:e.toString(),product_id:null==(t=this.item)||null==(t=t.id)?void 0:t.toString(),category:null==(r=this.item)?void 0:r.category,currency:null==(n=Salla.config.currency())?void 0:n.code,name:null==(i=this.item)?void 0:i.name,brand:null==(o=this.item)?void 0:o.brand,variant:null==(a=this.item)?void 0:a.variant,price:null==(s=this.item)?void 0:s.price,quantity:null==(u=this.item)?void 0:u.quantity,sku:null==(l=this.item)?void 0:l.sku,coupon:null==(c=this.item)?void 0:c.coupon,position:null==(d=this.item)?void 0:d.position,url:null==(h=this.item)?void 0:h.url,image_url:null==(p=this.item)?void 0:p.image_url}}}}],"Product Viewed":[class{constructor(e){this.product=e[0];try{this.source=sessionStorage.getItem("s-viewed-source")||null,sessionStorage.removeItem("s-viewed-source")}catch(e){this.source=null}}toSegment(){var e;return{event:"Product Viewed",properties:{product_id:null==(e=this.product.id)?void 0:e.toString(),category:this.product.category,name:this.product.name,brand:this.product.brand,variant:this.product.variant,price:this.product.price,quantity:this.product.quantity,currency:this.product.currency,coupon:this.product.coupon,position:this.product.position,value:this.product.value,sku:this.product.sku,url:this.product.url,image_url:this.product.image_url,source:this.source}}}}],"Product Added to Wishlist":[class{constructor(e){this.product=e.data.product}toSegment(){var e,t,r;return{event:"Product Added to Wishlist",properties:{wishlist_id:salla.config.get("store.id")+"_"+salla.config.get("user.id"),wishlist_name:salla.config.get("store.name"),product_id:null==(e=this.product.id)?void 0:e.toString(),name:this.product.name,brand:this.product.brand,variant:this.product.variant,price:this.product.price,quantity:Math.max(1,Number(this.product.quantity)),sku:this.product.sku||null,position:Number(this.product.position||0),url:this.product.url,image_url:(null==(t=this.product)?void 0:t.image)||null,category:this.product.category,currency:null==(r=Salla.config.currency())?void 0:r.code,brand:this.product.brand}}}}],"Product Removed from Wishlist":[class{constructor(e){this.product=e.data.product}toSegment(){var e,t,r;return{event:"Product Removed from Wishlist",properties:{wishlist_id:salla.config.get("store.id")+"_"+salla.config.get("user.id"),wishlist_name:salla.config.get("store.name"),product_id:null==(e=this.product.id)?void 0:e.toString(),name:this.product.name,brand:this.product.brand,variant:this.product.variant,price:this.product.price,quantity:Math.max(1,Number(this.product.quantity)),sku:this.product.sku||null,coupon:this.product.coupon||null,position:Number(this.product.position||0),currency:null==(t=Salla.config.currency())?void 0:t.code,url:this.product.url,image_url:(null==(r=this.product)?void 0:r.image)||null,category:this.product.category,brand:this.product.brand}}}}],"Cart Viewed":[class{constructor(e){this.cart=e[0]}toSegment(){var e;return{event:"Cart Viewed",properties:{cart_id:null==(e=this.cart.cart_id)?void 0:e.toString(),products:this.cart.products.map(e=>{var t,r,n;return{product_id:null==(t=e.id)?void 0:t.toString(),cart_item_id:null==(r=e.cart_item_id)?void 0:r.toString(),name:e.name,price:e.price,category:e.category,sku:e.sku,position:e.position,url:e.url,image_url:e.image_url,brand:e.brand,currency:null==(n=Salla.config.currency())?void 0:n.code,variant:e.variant,coupon:e.coupon,quantity:e.quantity}})}}}}],"Products Searched":[class{constructor(e){this.query=e}toSegment(){return{event:"Products Searched",properties:{query:this.query}}}}],"Product List Viewed":[Tc],"Product List Filtered":[class extends Tc{constructor(e){super(e);const t=(null==e?void 0:e.nextPage)||"";this.filters=this.extractFilters(t)}extractFilters(e){if(!e)return null;try{const t=new URL(e),r=[];return Array.from(t.searchParams.entries()).forEach(([e,t])=>{if(e.startsWith("filters[")){const n=e.match(/^filters\[(.*?)\]/),i=n?n[1]:e;r.push({type:i,value:t})}}),r.length>0?r:null}catch(e){return console.warn("Error extracting filters from URL:",e),null}}toSegment(){const e=super.toSegment();return{event:"Product List Filtered",properties:Br({},null==e?void 0:e.properties,{filters:this.filters})}}static shouldSend(e){return((null==e?void 0:e.nextPage)||"").includes("filters")}}],"Signed Up":[class extends Rc{toSegment(){const e=super.toSegment();return{event:"Signed Up",properties:null==e?void 0:e.properties}}static shouldSend(){return"user"===Salla.config.get("user.type")||(Salla.profile.event.onInfoFetched(()=>Salla.event.emit("Signed Up")),!1)}}],"Signed In":[Rc],"Signed Out":[class{toSegment(){return{event:"Signed Out",properties:{}}}}],"Product Reviewed":[class{constructor(e){this.details=e}toSegment(){return{event:"Product Reviewed",properties:this.details}}static registerEvent(){salla.event.rating.onProductsRated(function(e,t){const{products:r,order_id:n}=t;Object.values(r).forEach(e=>{var t;Salla.event.emit("Product Reviewed",{product_id:null==(t=e.product_id)?void 0:t.toString(),review_id:null==n?void 0:n.toString(),review_body:e.comment,rating:e.rating})})})}}],"Product Shared":[class{constructor(e){this.data=e}toSegment(){var e;const t=(null==(e=Salla.analytics.history.find(({eventName:e})=>"Product Viewed"===e))?void 0:e.payload)||{};return t.share_via=this.data.share_via,{event:"Product Shared",properties:t}}static shouldSend(){return"product.single"===salla.config.get("page.slug")}}],"Promotion Viewed":[class{constructor(e){this.promotion=e[0]}toSegment(){var e;return{event:"Promotion Viewed",properties:{promotion_id:null==(e=this.promotion.id)?void 0:e.toString(),creative:this.promotion.creative,name:this.promotion.name,position:this.promotion.position}}}}],"Promotion Clicked":[class{constructor(e){this.promotion=e[0]}toSegment(){var e;return{event:"Promotion Clicked",properties:{promotion_id:null==(e=this.promotion.id)?void 0:e.toString(),creative:this.promotion.creative,name:this.promotion.name,position:this.promotion.position}}}}],"Coupon Applied":[class{constructor(e){this.transaction=e}getCartId(){var e,t;return"cart"===salla.config.get("page.slug")?null==(t=salla.config.get("page.id"))?void 0:t.toString():(null==(e=this.transaction)||null==(e=e.data)||null==(e=e.cart)||null==(e=e.id)?void 0:e.toString())||""}toSegment(){var e,t;return{event:"Coupon Applied",properties:{cart_id:this.getCartId(),coupon_name:(null==(e=this.transaction)||null==(e=e.data)||null==(e=e.cart)?void 0:e.coupon)||"",discount:(null==(t=this.transaction)||null==(t=t.data)||null==(t=t.cart)?void 0:t.discount)||0,currency:salla.config.get("user.currency")||""}}}}],"Coupon Removed":[class{constructor(e){this.transaction=e}getCartId(){var e,t;return"cart"===salla.config.get("page.slug")?null==(t=salla.config.get("page.id"))?void 0:t.toString():(null==(e=this.transaction)||null==(e=e.data)||null==(e=e.cart)||null==(e=e.id)?void 0:e.toString())||""}toSegment(){var e,t;return{event:"Coupon Removed",properties:{cart_id:this.getCartId(),coupon_name:(null==(e=this.transaction)?void 0:e.coupon)||"",discount:(null==(t=this.transaction)||null==(t=t.data)||null==(t=t.cart)?void 0:t.discount)||0,currency:salla.config.get("user.currency")||""}}}}],"Coupon Denied":[class{constructor(e){this.transaction=e}getCartId(){var e;return"cart"===salla.config.get("page.slug")?null==(e=salla.config.get("page.id"))?void 0:e.toString():""}getCouponCode(){try{var e,t;const r=null==(e=this.transaction.response)||null==(e=e.config)?void 0:e.data;return r?null==(t=JSON.parse(r))?void 0:t.coupon:""}catch(e){return""}}toSegment(){var e;return{event:"Coupon Denied",properties:{cart_id:this.getCartId(),coupon_name:this.getCouponCode(),reason:(null==(e=this.transaction.response)||null==(e=e.data)||null==(e=e.error)?void 0:e.message)||"Unknown error"}}}}],"User Profile Updated":[Lc],"Cart Updated":[class{constructor(e){this.cart=e}toSegment(){var e,t,r,n;return{event:"Cart Updated",properties:{cart_id:null==(e=this.cart.id)?void 0:e.toString(),value:this.cart.total,revenue:this.cart.sub_total,tax:this.cart.tax_amount,discount:this.cart.total_discount,shipping:this.cart.real_shipping_cost,currency:null==(t=Salla.config.currency())?void 0:t.code,affiliation:null==(r=Salla.storage.getWithTTL("s-utms"))?void 0:r["s-utm-source"],products:null==(n=this.cart.items)?void 0:n.map(e=>{var t,r,n,i,o,a;return{product_id:null==(t=e.product_id)?void 0:t.toString(),name:e.product_name,price:e.product_price,category:null==(r=e.category)?void 0:r.toString(),sku:null==(n=e.product_sku)?void 0:n.toString(),position:e.position,url:e.url,image_url:e.product_image,brand:null==(i=e.brand)?void 0:i.toString(),currency:null==(o=Salla.config.currency())?void 0:o.code,variant:null==(a=e.variant)?void 0:a.toString(),coupon:this.cart.coupon,quantity:e.quantity}})}}}static shouldSend(e){return"cart"===salla.config.get("page.slug")&&!(null!=e&&e.fromLatestFetched)}}],"Market Selected":[class{constructor(e){this.scope=e.data}toSegment(){return{event:"Market Selected",properties:Br({},this.getScope(this.scope),{prev:this.getScope(Salla.config.get("store.scope"))})}}getScope(e){var t;return{id:null==(t=(e=e||{}).id)?void 0:t.toString(),country:this.getScopeAttribute(e,"countries"),currency:this.getScopeAttribute(e,"currencies"),locale:this.getScopeAttribute(e,"languages")}}getScopeAttribute(e,t){return e=e[t],Array.isArray(e)?e[0]:e}}],"Product Reordered":[class{constructor(e){this.details=e}toSegment(){var e;return{event:"Product Reordered",properties:{product_id:null==(e=this.details)||null==(e=e.data)||null==(e=e.id)?void 0:e.toString()}}}static shouldSend(e){const t=null==e?void 0:e.data;return(null==t?void 0:t.id)&&!isNaN(null==t?void 0:t.id)&&"reorder"===(null==t?void 0:t.type)}}],"Recommendation List Viewed":[class{constructor(e){var t;this.products=null!=(t=null==e?void 0:e.products)?t:[]}toSegment(){var e;const t=null==(e=Salla.config.currency())?void 0:e.code;return{event:"Recommendation List Viewed",properties:{recommendation_type:"fbt",source:"pdp_fbt",products:this.products.map((e,r)=>Br({},jc(e,r+1,t),{variant:"product"}))}}}}],"Product Clicked":[class{constructor(e){this.item=e[0]}static shouldSend(e){var t,r;return!(null==e||null==(t=e[0])||!t.product||null==e||null==(r=e[0])||!r.position)}toSegment(){const{product:e,position:t}=this.item;return{event:"Product Clicked",properties:Br({},jc(e,t),{source:"pdp_fbt"})}}}]};const Uc="s-session-id";const qc="mobile",zc=()=>({}),$c=[{event:"modal::close",action:"modal.close",method:"closeModal",wrap:zc},{action:"scope.open",method:"openScopes"},{event:"language::open",action:"language.open",method:"openLanguages"},{event:"currency::open",action:"currency.open",method:"openCurrencies"},{event:"checkout::open",action:"checkout.open",method:"openCheckout",wrap:e=>{const t="string"==typeof e?e:e&&e.url;return null==t?{}:{url:t}}},{event:"browser::open",action:"browser.open",method:"openBrowser",wrap:e=>"string"==typeof e?{url:e}:e||{}},{event:"ui::alert",action:"ui.alert",method:"alert"},{event:"ui::title",action:"ui.title",method:"setTitle",wrap:e=>"string"==typeof e?{title:e}:e||{}},{event:"ui::print",action:"ui.print",method:"print",wrap:e=>"string"==typeof e?{url:e}:e||{}}];return Fr.versions.twilight="3.0.0-beta.1",Fr.onInitiated=e=>salla.event.once("twilight::initiated",e),Fr.onReady=Fr.onReady||function(e){return new Promise(function(t){return"ready"===salla.status?t(e?e(salla.config.all()):salla.config.all()):Fr.onInitiated(r=>t(e?e(r):r))})},Fr.status="loading",Fr.notify=_r,Fr.lang=new class extends gn{constructor(e){e=e||{};const t=salla.cookie.get("s-lang");e.messages=e.messages||window.translations,e.locale=e.locale||(t||window.locale||navigator.language||navigator.userLanguage||"ar").split("-")[0],e.fallback=e.fallback||e.locale,super(e),this.translationsLoaded=!1,this._subscribers=new Set,Salla.event.on("twilight::before.ready",()=>this.loadStoreTranslations())}subscribe(e){return this._subscribers.add(e),this.translationsLoaded&&e(),()=>this._subscribers.delete(e)}_notifySubscribers(){this._subscribers.forEach(e=>e())}onLoaded(e){return new Promise(t=>{if(this.translationsLoaded)return t(e?e():null);Salla.event.once("languages::translations.loaded",()=>t(e?e():null))})}loadStoreTranslations(){if(this.hash=salla.config.get("theme.translations_hash",salla.config.get("store.id","twilight")),this.message||(salla.log("try to load translations from localstorage"),this.messages=salla.storage.get(`s_translations.${this.hash}`),this.messages&&(this.translationsLoaded=!0)&&super.setMessages(this.messages)),this.messages)return salla.event.dispatch("languages::translations.loaded"),this._notifySubscribers(),void salla.logger.info("The messages of transactions is already loaded");salla.url.get("")?this.loadScript(salla.url.get(`languages/assets/${this.hash}.js`)):this.loadScript("https://cdn.salla.network/js/translations.js",!1)}setMessages(e){super.setMessages(e),salla.event.dispatch("languages::translations.loaded"),this.translationsLoaded=!0,this._notifySubscribers()}loadScript(e,t=!0){let r=document.createElement("script");r.src=e,r.onload=()=>{if(window.translations)return salla.storage.remove("s_translations"),salla.storage.set("s_translations",{[this.hash]:window.translations}),this.setMessages(window.translations);r.onerror()},r.onerror=()=>{if(t)return salla.logger.warn("Failed to load Translations for store, lets try load it from CDN"),this.loadScript("https://cdn.salla.network/js/translations.js",!1);salla.logger.error("Failed to load Translations, check your network logs for more details\nor: salla.lang.setMessages({....}), see https://docs.salla.dev for more information's.")},document.head.appendChild(r)}getWithDefault(e,t,r,n){let i=this.get(e,r,n);return i!==e?i:t}get(e,t,r){let n=e;(window.translations||this.translationsLoaded)&&(n="trans."+e);let i=super.get(n,t,r);return i!==n?i:super.get(n,t,"en").replace(n,e)}set(e,t){return salla.helpers.setNested(this.messages[`${this.getLocale()}.trans`],e,t),this}add(e,t){return Object.entries(t).forEach(t=>salla.helpers.setNested(this.messages[t[0]+".trans"],e,t[1])),this}addBulk(e){return Object.entries(e).forEach(([e,t])=>{this.add(e,t)}),this}},Fr.form=new class{async submit(e,t=null){var r;let n=t;if("SubmitEvent"===(null==t||null==(r=t.constructor)?void 0:r.name)||"submit"===(null==t?void 0:t.type)){var i,o;if(t.preventDefault(),"FORM"!==(null==(i=t.target)?void 0:i.tagName))return Salla.logger.warn("Failed find the target element for submit action. make sure you submit a form element"),new Promise(()=>{throw"Failed find the target element for submit action. make sure you submit a form element"});"SALLA-BUTTON"===(null==t||null==(o=t.submitter)||null==(o=o.parentElement)?void 0:o.tagName)&&t.submitter.parentElement.load(),n=t.target.getElementSallaData(),salla.log("Data from element",n)}if(/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/gm.test(e))return salla.api.request(e,n,"post").finally(()=>{var e;"undefined"!=typeof loaderSupported&&loaderSupported&&(null==t||null==(e=t.submitter)||e.parentElement.stop())});let a=e.split("."),s=a.splice(-1);return await salla.call(a.join("."))[s](n).finally(()=>{var e;return null==t||null==(e=t.submitter)||null==(e=e.parentElement)?void 0:e.stop()}).catch(e=>{throw salla.logger.warn(e),e})}onSubmit(e,t){return salla.form.submit(e,t),!1}onChange(e,t){var r;return null!=t&&t.currentTarget?"FORM"!==(null==t||null==(r=t.currentTarget)?void 0:r.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)}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}},Fr.infiniteScroll=new class extends Ar{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,"S-Source":"twilight","cache-control":"no-cache",pragma:"no-cache"}},this.instances=[]}initiate(e,t,r,n=!1){n?((r=r||{}).fetchOptions=Br({},this.fetchOptions,r.fetchOptions||{}),r.responseBody="json"):r=this.getCustomOptions(t,r);let i="string"!=typeof e?e:document.querySelector(e),o=r.path;if(!i||!o||"string"==typeof o&&!document.querySelector(o))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 hn(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}loadNextPage(e){("string"!=typeof e?e:document.querySelector(e)).loadNextPage()}destroy(e){("string"!=typeof e?e:document.querySelector(e)).destroy()}}(void 0,salla.event.infiniteScroll),Fr.api=new class extends Sa{constructor(){super(),this.auth=new Dn,this.cart=new vn,this.loyalty=new yn,this.order=new bn,this.rating=new An,this.product=new Fn,this.profile=new wn,this.comment=new En,this.currency=new Sn,this.document=new _n,this.wishlist=new kn,this.scope=new xn,this.booking=new Pn,this.landing=new In,this.notifications=new On,this.component=new _a,this.advertisement=new Aa,this.navigation=new Ca,this.metadata=new ka,this.recommendations=new Pa}beaconRequest(e,t={}){var r;if(null==(r=window.navigator)||!r.sendBeacon)return fetch(e,t);const n="string"==typeof(null==t?void 0:t.body)?null==t?void 0:t.body:JSON.stringify((null==t?void 0:t.body)||{}),i=new Blob([n],{type:"application/json"});return Salla.log(`Beacon payload size: ${i.size} bytes (~${(i.size/1024).toFixed(2)} KB)`),navigator.sendBeacon(e,i),Promise.resolve(new Response('{"status":"sent_via_beacon"}',{status:200,headers:{"Content-Type":"application/json"}}))}},Fr.sso=new class{constructor(){Salla.onReady(()=>this.init())}init(){var e;if(salla.config.get("store.features",[]).includes("sso-login")){if(window.location.hostname.includes("salla"))return salla.log("SSO is not supported yet for stores without custom domain.");salla.auth.event.onLoggedOut(()=>new Promise(e=>{const t=document.createElement("iframe");t.style.display="none",t.src=salla.url.get("sso/logout"),document.body.appendChild(t),t.onload=()=>{document.body.removeChild(t),e()}})),null==(e=document.querySelector("salla-login-modal"))||e.remove(),Salla.event.removeAllListeners("login::open"),Salla.event.prependListener("login::open",()=>this.redirect()),window.addEventListener("mini-checkout::before-init",e=>{Salla.config.isUser()||(e.preventDefault(),this.redirect())})}}redirect(){const e=window.location.pathname+window.location.search,t=`${window.location.origin}/sso/login?intended_to=${encodeURIComponent(e)}`;return console.log("Redirecting to:",t),window.location.href=t,!0}},Fr.intend=new class{constructor(){Salla.onReady(()=>this.init())}init(){if(Salla.config.isUser())return;const e=new URLSearchParams(window.location.search);if(e.has("intended_to"))try{const t=new URL(e.get("intended_to"));if(t.hostname!==window.location.hostname)return;return this.handleAfterLoginEvent(t)}catch(e){return void console.warn("Invalid URL provided in intended_to parameter")}}handleAfterLoginEvent(e){let t="intend::user.logged.in";Salla.event.on(t,()=>window.location=e),Salla.api.auth.setAfterLoginEvent(t),Salla.api.auth.setCanRedirect(!1),Salla.event.on("salla-login::ready",()=>Salla.event.emit("login::open",{withoutReload:!0}))}},Fr.hooks=new class{constructor(){this._store=new Map,this._whitelist=new Map([["salla-add-product-button",new Set(["validate","componentDidLoad"])],["salla-product-options",new Set(["componentDidLoad"])],["salla-products-list",new Set(["componentDidLoad","beforeBuildListUrl"])],["salla-products-slider",new Set(["componentDidLoad"])],["salla-hook",new Set(["componentDidLoad"])],["salla-scopes",new Set(["componentDidLoad"])],["salla-user-menu",new Set(["componentDidLoad"])],["salla-menu",new Set(["afterFetchMenuItems"])]]),this._themeSlots=["head","head:start","head:end","body:start","body:end","product:index.items.start","product:index.items.end","product:single.description.start","product:single.description","product:single.description.end","product:single.form.start","product:single.form.end","blog:index.items.start","blog:index.items.end","blog:single.items.start","blog:single.items.end","brands:index.items.start","brands:index.items.end","brands:single.details.start","brands:single.details.end","brands:single.items.start","brands:single.items.end","cart:items.start","cart:items.end","cart:summary.start","cart:summary.end","cart:submit.start","cart:submit.end","customer:notifications.items.start","customer:notifications.items.end","customer:orders.index.items.start","customer:orders.index.items.end","customer:orders.single.details.start","customer:orders.single.details.end","customer:wishlist.items.start","customer:wishlist.items.end","customer:profile.form.start","customer:profile.form.fields.start","customer:profile.form.fields.end","customer:profile.form.submit.start","customer:profile.form.submit.end","customer:profile.form.end","thank-you:start","thank-you:items.start","thank-you:items.end","thank-you:end"];const e=Salla.config.get("page.slug");e&&(this._themeSlots.push(e+":start"),this._themeSlots.push(e+":end")),Salla.onReady(()=>{const e=Salla.config.get("page.slug");e&&(this._themeSlots.includes(e+":start")||this._themeSlots.push(e+":start"),this._themeSlots.includes(e+":end")||this._themeSlots.push(e+":end"))}),this._componentHistory=new Map}renderAutoComponents(e){Array.isArray(e)&&0!==e.length&&e.forEach(({hook:e,tag:t,canRender:r})=>{r&&!r()||this.mount(e,document.createElement(t))})}registerHook(e,t,r,n={}){if(!this._isAllowed(e,t))return console.warn(`[Hooks] Hook "${e}:${t}" is not allowed`),()=>{};const i=0|n.priority,o=!!n.once,a=this._ensureTag(e),s=a.get(t)||[];return s.push({cb:r,p:i,once:o}),s.sort((e,t)=>t.p-e.p),a.set(t,s),"componentDidLoad"===t&&this._callForLoadedComponents(e,r),()=>this.removeHook(e,t,r)}registerHookOnce(e,t,r,n={}){return this.registerHook(e,t,r,Br({},n,{once:!0}))}async call(e,t,r){const n=this._store.get(e);if(!n)return;const i=n.get(t);if(i&&0!==i.length)for(const n of[...i]){try{await n.cb(r)}catch(r){console.warn(`[Hooks] "${e}:${t}" callback failed:`,r)}n.once&&this.removeHook(e,t,n.cb)}}removeHook(e,t,r){const n=this._store.get(e);if(!n)return!1;if(!n.has(t))return!1;if(!r)return n.delete(t),0===n.size&&this._store.delete(e),!0;const i=n.get(t),o=i.findIndex(e=>e.cb===r);return o>-1&&(i.splice(o,1),0===i.length&&n.delete(t),0===n.size&&this._store.delete(e),!0)}clear(e){e?this._store.delete(e):this._store.clear()}get(e,t){var r;const n=this._store.get(e);return n&&(null==(r=n.get(t))?void 0:r.map(e=>e.cb))||[]}_ensureTag(e){let t=this._store.get(e);return t||(t=new Map,this._store.set(e,t)),t}_isAllowed(e,t){const r=this._whitelist.get(e);return r?!!r.has(t)||(console.warn(`[Hooks] Hook "${t}" is not allowed for tag "${e}"`),!1):(console.warn(`[Hooks] Tag "${e}" is not in the whitelist`),!1)}registerComponent(e,t){this._componentHistory.has(e)||this._componentHistory.set(e,new Set);const r=this._componentHistory.get(e);if(!r.has(t))return r.add(t),this.call(e,"componentDidLoad",t)}async _callForLoadedComponents(e,t){const r=this._componentHistory.get(e);if(r&&0!==r.size)for(const n of r)try{await t(n)}catch(t){console.warn(`[Hooks] "${e.replace(/[^a-zA-Z0-9-_]/g,"")}:componentDidLoad" callback failed:`,t)}}mount(e,t){return this._themeSlots.includes(e)?new Promise(r=>{this.registerHook("salla-hook","componentDidLoad",n=>{n.name===e&&(n.mount(t),r(t))})}):(console.warn(`[Hooks] Hook "${e}" is not allowed`),Promise.reject(t))}},["cart","auth","order","scope","rating","comment","loyalty","product","profile","currency","document","wishlist","booking","landing","metadata","recommendations"].forEach(e=>Fr[e]=new Ar(Fr.api[e],Fr.event[e])),Fr.call=e=>{let t=Fr,r=e.split(".");for(;r.length&&(t=t[r.shift()]););return t},Fr.analytics=new class{constructor(){this.history=[],this.customTrackers=[],this.context={},this._anonymousId=null,this._sessionId=null,this._jitsuConfig=null,this.mappedEvents={"wishlist::added":"Product Added to Wishlist","wishlist::removed":"Product Removed from Wishlist","salla-products-list::products.fetched":["Product List Viewed","Product List Filtered"],"auth::registered":"Signed Up","auth::logged.in":"Signed In","auth::logged.out":"Signed Out","share-element":"Product Shared","promotion::viewed":"Promotion Viewed","promotion::clicked":"Promotion Clicked","salla::offer.promotion.viewed":"Promotion Viewed","salla::offer.promotion.clicked":"Promotion Clicked","cart::coupon.added":"Coupon Applied","cart::coupon.deleted":"Coupon Removed","cart::coupon.addition.failed":"Coupon Denied","profile::updated":"User Profile Updated","cart::updated":"Cart Updated","scope::changed":"Market Selected","order::order.created":"Product Reordered","salla-bought-together::list.viewed":"Recommendation List Viewed","salla-bought-together::product.clicked":"Product Clicked","salla-bought-together::product.added":"Product Added"},Salla.event.onAny((e,t)=>{try{if(Object.keys(this.mappedEvents).includes(e)){const r=this.mappedEvents[e];return void(Array.isArray(r)?r:[r]).forEach(e=>Salla.event.emit(e,t))}if(!Salla.config.get("jitsu.events",[]).includes(e))return;const r=Nc.transform(e,t);r&&this.track(r.event,r.properties)}catch(e){Salla.log("Error in analytics event handling:",e)}}),Salla.event.on("salla-cookies-bar::accepted",()=>this.setConsent("accepted")),Salla.event.on("salla-cookies-bar::rejected",()=>this.setConsent("rejected")),Salla.event.on("auth::logged.out",()=>this.clearSessionId()),Salla.event.on("twilight::before.ready",e=>{var t,r,n,i,o,a,s;this.debugAnalytics=Bc({host:"https://st.salla.dev",writeKey:"bbLD6Xqr1OKsDJfxZBCy7SJN1RIsrkBp:WEa99iY220v9qX7KiuAlML9ldSFJKW2p"});const{host:u,key:l}=(null==e?void 0:e.jitsu)||{};if(this.jitsuAnalytics=null,!u||!l)return void salla.log("Jitsu configuration is missing. Analytics will not be tracked.");Nc.registerEvents(),this._jitsuConfig=Br({host:this.getAnalyticsHost(e),writeKey:l,cookieCapture:Object.fromEntries(Salla.cookie.getCookieByPrefix("sa_").map(e=>[e,e])),runtime:this.getSafeJitsuRuntime(e)},Salla.helpers.isIframe()&&{fetch:(e,t)=>this.customFetch(e,t)});const c=this.getConsentPolicies();var d;(this.jitsuAnalytics=Bc(Br({},this._jitsuConfig,c)),e.jitsu.anonymous_id&&this.jitsuAnalytics.setAnonymousId(e.jitsu.anonymous_id),this._anonymousId=(null==(t=this.jitsuAnalytics)||null==(t=t.user())?void 0:t.anonymousId)||null,e.jitsu.session_id&&this.setContext("session_id",e.jitsu.session_id),this._sessionId=null==(r=this.jitsuAnalytics)?void 0:r.getContextProperty("session_id"),this.setContext("store_id",null==(n=e.store)?void 0:n.id),this.setContext("version",null==(i=e.jitsu)?void 0:i.version),this.setContext("library",{twilight:Salla.versions}),null!=(o=e.jitsu)&&null!=(o=o.context)&&o.extra&&this.setExtraContext(e.jitsu.context.extra),null!=(a=e.store)&&null!=(a=a.scope)&&a.id)&&this.setContext("scope",null==(d=e.store)?void 0:d.scope);"user"===(null==e||null==(s=e.user)?void 0:s.type)&&this.setContext("traits",this.getFormattedUser(e.user)),this.registerTracker({name:"DefaultSallaTracker",track:(e,t)=>this.jitsuAnalytics.track(e,t),page:e=>this.jitsuAnalytics.page(e)})}),Salla.onReady(()=>{var e;this.initSessionId();const t={name:Salla.config.get("page.slug",""),id:null==(e=Salla.config.get("page.id",""))?void 0:e.toString()};this.setContext("page",t),this.attachViewedSource(),Salla.config.set("jitsu.anonymous_id",this._anonymousId),Salla.config.set("jitsu.session_id",this._sessionId),this.page(t)})}attachViewedSource(){try{const e=new URL(window.location.href),t=e.searchParams.get("_svs");if(!t)return;e.searchParams.delete("_svs"),window.history.replaceState(window.history.state,"",e.toString());const r=t.replace(/(?:[\0-\x1F!-,\.\/:-@\[-\^`\{-\xA9\xAB-\xB1\xB4\xB6-\xB8\xBB\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u036F\u0375\u0378\u0379\u037E\u0380-\u0385\u0387\u038B\u038D\u03A2\u03F6\u0482-\u0489\u0530\u0557\u0558\u055A-\u055F\u0589-\u05CF\u05EB-\u05EE\u05F3-\u061F\u064B-\u065F\u066A-\u066D\u0670\u06D4\u06D6-\u06E4\u06E7-\u06ED\u06FD\u06FE\u0700-\u070F\u0711\u0730-\u074C\u07A6-\u07B0\u07B2-\u07BF\u07EB-\u07F3\u07F6-\u07F9\u07FB-\u07FF\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u083F\u0859-\u085F\u086B-\u086F\u0888\u0890-\u089F\u08CA-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962-\u0965\u0970\u0981-\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA-\u09BC\u09BE-\u09CD\u09CF-\u09DB\u09DE\u09E2-\u09E5\u09F2\u09F3\u09FA\u09FB\u09FD-\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A-\u0A58\u0A5D\u0A5F-\u0A65\u0A70\u0A71\u0A75-\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA-\u0ABC\u0ABE-\u0ACF\u0AD1-\u0ADF\u0AE2-\u0AE5\u0AF0-\u0AF8\u0AFA-\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A-\u0B3C\u0B3E-\u0B5B\u0B5E\u0B62-\u0B65\u0B70\u0B78-\u0B82\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BBA-\u0BCF\u0BD1-\u0BE5\u0BF3-\u0C04\u0C0D\u0C11\u0C29\u0C3A-\u0C3C\u0C3E-\u0C57\u0C5B\u0C5E\u0C5F\u0C62-\u0C65\u0C70-\u0C77\u0C7F\u0C81-\u0C84\u0C8D\u0C91\u0CA9\u0CB4\u0CBA-\u0CBC\u0CBE-\u0CDB\u0CDF\u0CE2-\u0CE5\u0CF0\u0CF3-\u0D03\u0D0D\u0D11\u0D3B\u0D3C\u0D3E-\u0D4D\u0D4F-\u0D53\u0D57\u0D62-\u0D65\u0D79\u0D80-\u0D84\u0D97-\u0D99\u0DB2\u0DBC\u0DBE\u0DBF\u0DC7-\u0DE5\u0DF0-\u0E00\u0E31\u0E34-\u0E3F\u0E47-\u0E4F\u0E5A-\u0E80\u0E83\u0E85\u0E8B\u0EA4\u0EA6\u0EB1\u0EB4-\u0EBC\u0EBE\u0EBF\u0EC5\u0EC7-\u0ECF\u0EDA\u0EDB\u0EE0-\u0EFF\u0F01-\u0F1F\u0F34-\u0F3F\u0F48\u0F6D-\u0F87\u0F8D-\u0FFF\u102B-\u103E\u104A-\u104F\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109F\u10C6\u10C8-\u10CC\u10CE\u10CF\u10FB\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B-\u1368\u137D-\u137F\u1390-\u139F\u13F6\u13F7\u13FE-\u1400\u166D\u166E\u1680\u169B-\u169F\u16EB-\u16ED\u16F9-\u16FF\u1712-\u171E\u1732-\u173F\u1752-\u175F\u176D\u1771-\u177F\u17B4-\u17D6\u17D8-\u17DB\u17DD-\u17DF\u17EA-\u17EF\u17FA-\u180F\u181A-\u181F\u1879-\u187F\u1885\u1886\u18A9\u18AB-\u18AF\u18F6-\u18FF\u191F-\u1945\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19CF\u19DB-\u19FF\u1A17-\u1A1F\u1A55-\u1A7F\u1A8A-\u1A8F\u1A9A-\u1AA6\u1AA8-\u1B04\u1B34-\u1B44\u1B4D-\u1B4F\u1B5A-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BFF\u1C24-\u1C3F\u1C4A-\u1C4C\u1C7E\u1C7F\u1C8B-\u1C8F\u1CBB\u1CBC\u1CC0-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1CFB-\u1CFF\u1DC0-\u1DFF\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FBD\u1FBF-\u1FC1\u1FC5\u1FCD-\u1FCF\u1FD4\u1FD5\u1FDC-\u1FDF\u1FED-\u1FF1\u1FF5\u1FFD-\u206F\u2072\u2073\u207A-\u207E\u208A-\u208F\u209D-\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A-\u245F\u249C-\u24E9\u2500-\u2775\u2794-\u2BFF\u2CE5-\u2CEA\u2CEF-\u2CF1\u2CF4-\u2CFC\u2CFE\u2CFF\u2D26\u2D28-\u2D2C\u2D2E\u2D2F\u2D68-\u2D6E\u2D70-\u2D7F\u2D97-\u2D9F\u2DA7\u2DAF\u2DB7\u2DBF\u2DC7\u2DCF\u2DD7\u2DDF-\u2E2E\u2E30-\u3004\u3008-\u3020\u302A-\u3030\u3036\u3037\u303D-\u3040\u3097-\u309C\u30A0\u30FB\u3100-\u3104\u3130\u318F-\u3191\u3196-\u319F\u31C0-\u31EF\u3200-\u321F\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA48D-\uA4CF\uA4FE\uA4FF\uA60D-\uA60F\uA62C-\uA63F\uA66F-\uA67E\uA69E\uA69F\uA6F0-\uA716\uA720\uA721\uA789\uA78A\uA7DD-\uA7F0\uA802\uA806\uA80B\uA823-\uA82F\uA836-\uA83F\uA874-\uA881\uA8B4-\uA8CF\uA8DA-\uA8F1\uA8F8-\uA8FA\uA8FC\uA8FF\uA926-\uA92F\uA947-\uA95F\uA97D-\uA983\uA9B3-\uA9CE\uA9DA-\uA9DF\uA9E5\uA9FF\uAA29-\uAA3F\uAA43\uAA4C-\uAA4F\uAA5A-\uAA5F\uAA77-\uAA79\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAC3-\uAADA\uAADE\uAADF\uAAEB-\uAAF1\uAAF5-\uAB00\uAB07\uAB08\uAB0F\uAB10\uAB17-\uAB1F\uAB27\uAB2F\uAB5B\uAB6A-\uAB6F\uABE3-\uABEF\uABFA-\uABFF\uD7A4-\uD7AF\uD7C7-\uD7CA\uD7FC-\uD7FF\uE000-\uF8FF\uFA6E\uFA6F\uFADA-\uFAFF\uFB07-\uFB12\uFB18-\uFB1C\uFB1E\uFB29\uFB37\uFB3D\uFB3F\uFB42\uFB45\uFBB2-\uFBD2\uFD3E-\uFD4F\uFD90\uFD91\uFDC8-\uFDEF\uFDFC-\uFE6F\uFE75\uFEFD-\uFF0F\uFF1A-\uFF20\uFF3B-\uFF40\uFF5B-\uFF65\uFFBF-\uFFC1\uFFC8\uFFC9\uFFD0\uFFD1\uFFD8\uFFD9\uFFDD-\uFFFF]|\uD800[\uDC0C\uDC27\uDC3B\uDC3E\uDC4E\uDC4F\uDC5E-\uDC7F\uDCFB-\uDD06\uDD34-\uDD3F\uDD79-\uDD89\uDD8C-\uDE7F\uDE9D-\uDE9F\uDED1-\uDEE0\uDEFC-\uDEFF\uDF24-\uDF2C\uDF4B-\uDF4F\uDF76-\uDF7F\uDF9E\uDF9F\uDFC4-\uDFC7\uDFD0\uDFD6-\uDFFF]|\uD801[\uDC9E\uDC9F\uDCAA-\uDCAF\uDCD4-\uDCD7\uDCFC-\uDCFF\uDD28-\uDD2F\uDD64-\uDD6F\uDD7B\uDD8B\uDD93\uDD96\uDDA2\uDDB2\uDDBA\uDDBD-\uDDBF\uDDF4-\uDDFF\uDF37-\uDF3F\uDF56-\uDF5F\uDF68-\uDF7F\uDF86\uDFB1\uDFBB-\uDFFF]|\uD802[\uDC06\uDC07\uDC09\uDC36\uDC39-\uDC3B\uDC3D\uDC3E\uDC56\uDC57\uDC77\uDC78\uDC9F-\uDCA6\uDCB0-\uDCDF\uDCF3\uDCF6-\uDCFA\uDD1C-\uDD1F\uDD3A-\uDD3F\uDD5A-\uDD7F\uDDB8-\uDDBB\uDDD0\uDDD1\uDE01-\uDE0F\uDE14\uDE18\uDE36-\uDE3F\uDE49-\uDE5F\uDE7F\uDEA0-\uDEBF\uDEC8\uDEE5-\uDEEA\uDEF0-\uDEFF\uDF36-\uDF3F\uDF56\uDF57\uDF73-\uDF77\uDF92-\uDFA8\uDFB0-\uDFFF]|\uD803[\uDC49-\uDC7F\uDCB3-\uDCBF\uDCF3-\uDCF9\uDD24-\uDD2F\uDD3A-\uDD3F\uDD66-\uDD6E\uDD86-\uDE5F\uDE7F\uDEAA-\uDEAF\uDEB2-\uDEC1\uDEC8-\uDEFF\uDF28-\uDF2F\uDF46-\uDF50\uDF55-\uDF6F\uDF82-\uDFAF\uDFCC-\uDFDF\uDFF7-\uDFFF]|\uD804[\uDC00-\uDC02\uDC38-\uDC51\uDC70\uDC73\uDC74\uDC76-\uDC82\uDCB0-\uDCCF\uDCE9-\uDCEF\uDCFA-\uDD02\uDD27-\uDD35\uDD40-\uDD43\uDD45\uDD46\uDD48-\uDD4F\uDD73-\uDD75\uDD77-\uDD82\uDDB3-\uDDC0\uDDC5-\uDDCF\uDDDB\uDDDD-\uDDE0\uDDF5-\uDDFF\uDE12\uDE2C-\uDE3E\uDE41-\uDE7F\uDE87\uDE89\uDE8E\uDE9E\uDEA9-\uDEAF\uDEDF-\uDEEF\uDEFA-\uDF04\uDF0D\uDF0E\uDF11\uDF12\uDF29\uDF31\uDF34\uDF3A-\uDF3C\uDF3E-\uDF4F\uDF51-\uDF5C\uDF62-\uDF7F\uDF8A\uDF8C\uDF8D\uDF8F\uDFB6\uDFB8-\uDFD0\uDFD2\uDFD4-\uDFFF]|\uD805[\uDC35-\uDC46\uDC4B-\uDC4F\uDC5A-\uDC5E\uDC62-\uDC7F\uDCB0-\uDCC3\uDCC6\uDCC8-\uDCCF\uDCDA-\uDD7F\uDDAF-\uDDD7\uDDDC-\uDDFF\uDE30-\uDE43\uDE45-\uDE4F\uDE5A-\uDE7F\uDEAB-\uDEB7\uDEB9-\uDEBF\uDECA-\uDECF\uDEE4-\uDEFF\uDF1B-\uDF2F\uDF3C-\uDF3F\uDF47-\uDFFF]|\uD806[\uDC2C-\uDC9F\uDCF3-\uDCFE\uDD07\uDD08\uDD0A\uDD0B\uDD14\uDD17\uDD30-\uDD3E\uDD40\uDD42-\uDD4F\uDD5A-\uDD9F\uDDA8\uDDA9\uDDD1-\uDDE0\uDDE2\uDDE4-\uDDFF\uDE01-\uDE0A\uDE33-\uDE39\uDE3B-\uDE4F\uDE51-\uDE5B\uDE8A-\uDE9C\uDE9E-\uDEAF\uDEF9-\uDFBF\uDFE1-\uDFEF\uDFFA-\uDFFF]|\uD807[\uDC09\uDC2F-\uDC3F\uDC41-\uDC4F\uDC6D-\uDC71\uDC90-\uDCFF\uDD07\uDD0A\uDD31-\uDD45\uDD47-\uDD4F\uDD5A-\uDD5F\uDD66\uDD69\uDD8A-\uDD97\uDD99-\uDD9F\uDDAA-\uDDAF\uDDDC-\uDDDF\uDDEA-\uDEDF\uDEF3-\uDF01\uDF03\uDF11\uDF34-\uDF4F\uDF5A-\uDFAF\uDFB1-\uDFBF\uDFD5-\uDFFF]|\uD808[\uDF9A-\uDFFF]|\uD809[\uDC6F-\uDC7F\uDD44-\uDFFF]|[\uD80A\uD812-\uD817\uD819\uD824-\uD82A\uD82D\uD82E\uD830-\uD832\uD836\uD83D\uD83F\uD87C\uD87D\uD87F\uD88E-\uDBFF][\uDC00-\uDFFF]|\uD80B[\uDC00-\uDF8F\uDFF1-\uDFFF]|\uD80D[\uDC30-\uDC40\uDC47-\uDC5F]|\uD810[\uDFFB-\uDFFF]|\uD811[\uDE47-\uDFFF]|\uD818[\uDC00-\uDCFF\uDD1E-\uDD2F\uDD3A-\uDFFF]|\uD81A[\uDE39-\uDE3F\uDE5F\uDE6A-\uDE6F\uDEBF\uDECA-\uDECF\uDEEE-\uDEFF\uDF30-\uDF3F\uDF44-\uDF4F\uDF5A\uDF62\uDF78-\uDF7C\uDF90-\uDFFF]|\uD81B[\uDC00-\uDD3F\uDD6D-\uDD6F\uDD7A-\uDE3F\uDE97-\uDE9F\uDEB9\uDEBA\uDED4-\uDEFF\uDF4B-\uDF4F\uDF51-\uDF92\uDFA0-\uDFDF\uDFE2\uDFE4-\uDFF1\uDFF7-\uDFFF]|\uD823[\uDCD6-\uDCFE\uDD1F-\uDD7F\uDDF3-\uDFFF]|\uD82B[\uDC00-\uDFEF\uDFF4\uDFFC\uDFFF]|\uD82C[\uDD23-\uDD31\uDD33-\uDD4F\uDD53\uDD54\uDD56-\uDD63\uDD68-\uDD6F\uDEFC-\uDFFF]|\uD82F[\uDC6B-\uDC6F\uDC7D-\uDC7F\uDC89-\uDC8F\uDC9A-\uDFFF]|\uD833[\uDC00-\uDCEF\uDCFA-\uDFFF]|\uD834[\uDC00-\uDEBF\uDED4-\uDEDF\uDEF4-\uDF5F\uDF79-\uDFFF]|\uD835[\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3\uDFCC\uDFCD]|\uD837[\uDC00-\uDEFF\uDF1F-\uDF24\uDF2B-\uDFFF]|\uD838[\uDC00-\uDC2F\uDC6E-\uDCFF\uDD2D-\uDD36\uDD3E\uDD3F\uDD4A-\uDD4D\uDD4F-\uDE8F\uDEAE-\uDEBF\uDEEC-\uDEEF\uDEFA-\uDFFF]|\uD839[\uDC00-\uDCCF\uDCEC-\uDCEF\uDCFA-\uDDCF\uDDEE\uDDEF\uDDFB-\uDEBF\uDEDF\uDEE3\uDEE6\uDEEE\uDEEF\uDEF5-\uDEFD\uDF00-\uDFDF\uDFE7\uDFEC\uDFEF\uDFFF]|\uD83A[\uDCC5\uDCC6\uDCD0-\uDCFF\uDD44-\uDD4A\uDD4C-\uDD4F\uDD5A-\uDFFF]|\uD83B[\uDC00-\uDC70\uDCAC\uDCB0\uDCB5-\uDD00\uDD2E\uDD3E-\uDDFF\uDE04\uDE20\uDE23\uDE25\uDE26\uDE28\uDE33\uDE38\uDE3A\uDE3C-\uDE41\uDE43-\uDE46\uDE48\uDE4A\uDE4C\uDE50\uDE53\uDE55\uDE56\uDE58\uDE5A\uDE5C\uDE5E\uDE60\uDE63\uDE65\uDE66\uDE6B\uDE73\uDE78\uDE7D\uDE7F\uDE8A\uDE9C-\uDEA0\uDEA4\uDEAA\uDEBC-\uDFFF]|\uD83C[\uDC00-\uDCFF\uDD0D-\uDFFF]|\uD83E[\uDC00-\uDFEF\uDFFA-\uDFFF]|\uD869[\uDEE0-\uDEFF]|\uD86E[\uDC1E\uDC1F]|\uD873[\uDEAE\uDEAF]|\uD87A[\uDFE1-\uDFEF]|\uD87B[\uDE5E-\uDFFF]|\uD87E[\uDE1E-\uDFFF]|\uD884[\uDF4B-\uDF4F]|\uD88D[\uDC7A-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/g,"").trim().slice(0,100);if(!r)return;this.setContext("viewed_source",r)}catch(e){Salla.log("Error reading viewed_source from URL:",e)}}setExtraContext(e){var t;null!=e&&null!=(t=e.headers)&&t["s-app-os"]&&(this.setContext("app",{version:e.headers["s-app-os-version"],app_release_tag:e.headers["s-app-version"],platform:e.headers["s-app-os"].toLowerCase()}),delete e.headers["s-app-os"],delete e.headers["s-app-os-version"],delete e.headers["s-app-version"],delete e.headers["s-source"]),this.setContext("system",e)}getAnalyticsHost(e){var t;const r="https://salla.cloud/_app/e";var n,i;if(Salla.helpers.isIframe())return null!=(n=null==e||null==(i=e.jitsu)?void 0:i.host)?n:r;if(null==e||null==(t=e.store)||!t.url)return Salla.log("Error getting store url - no config or store URL provided"),r;const o=e.store.url;try{let e="";const t=o;if(/https:\/\/demostore\.salla\.sa/.test(t)){const e=t.match(/demostore\.salla\.sa\/(?:(ar|en)\/)?((?!ar$|en$)[a-zA-Z0-9.-]+)/);if(e&&e[2]){const r=e[2];return`${new URL(t).origin}/${r}/_app/e`}return r}const n=/(salla\.sa)\/(?:(ar|en)\/)?((?!ar$|en$)[a-zA-Z0-9.-]+)/,i=t.match(n);if(i){const n=i[3];if(!n||0===n.trim().length||"ar"===n||"en"===n)return Salla.log("Error: invalid or empty store name in salla.sa URL"),r;e=`${new URL(t).origin}/${n}`}else{e=new URL(t).origin}return`${e}/_app/e`}catch(e){return Salla.log("Error getting store url, forwarding to salla.cloud:",e),r}}setContext(e,t){var r,n;null==(r=this.jitsuAnalytics)||r.setContextProperty(e,t),null==(n=this.debugAnalytics)||n.setContextProperty(e,t),this.context[e]=t}setAppContext(e,t){if(!this.jitsuAnalytics)return void Salla.log("setAppContext: Analytics not initialized yet");if(!e||"string"!=typeof e)return void Salla.log("setAppContext: appId must be a non-empty string");if(!t||"object"!=typeof t)return void Salla.log("setAppContext: payload must be an object");const r=this.context.apps_context||{};r[e]=Br({},r[e],t),this.setContext("apps_context",r)}withAppScope(e,t){if(!e||"string"!=typeof e)return void Salla.log("withAppScope: appId must be a non-empty string");if("function"!=typeof t)return void Salla.log("withAppScope: callback must be a function");const r=null!=this.context.apps_context&&Object.prototype.hasOwnProperty.call(this.context.apps_context,e),n=r?this.context.apps_context[e]:void 0,i=this,o={appId:e,setContext(t,r){i.setAppContext(e,{[t]:r})}};i.setAppContext(e,{});const a=()=>setTimeout(()=>{const t=i.context.apps_context?Br({},i.context.apps_context):{};r?t[e]=n:delete t[e],i.setContext("apps_context",Object.keys(t).length?t:void 0)},0);let s;try{s=t(o)}catch(e){throw a(),e}return s&&"function"==typeof s.then?Promise.resolve(s).finally(a):(a(),s)}customFetch(e,t){return fetch(e,Br({},t,{keepalive:!0}))}getSafeJitsuRuntime(e={}){if("undefined"==typeof window)return;const t=cc(e);return Br({},t,{pageUrl:()=>this.normalizeUrlForDecodeURIComponent(t.pageUrl())})}normalizeUrlForDecodeURIComponent(e){try{const t=new URL(e);return t.search&&(t.search=new URLSearchParams(t.search).toString()),t.toString()}catch(t){return Salla.log("Error normalizing analytics page URL:",t),e}}track(e,t={}){t=this.finalPayload(t),this.history.push({action:"track",eventName:e,payload:t}),this.pushEventToCustomTrackers("track",e,t)}log(e,t={}){var r;return null==(r=this.debugAnalytics)?void 0:r.track(e,t).catch(e=>(Salla.log("Error tracking event:",e),Promise.reject(e)))}page(e={}){var t,r;(e=this.finalPayload(e)).id=null==(t=e.id||Salla.config.get("page.id",""))?void 0:t.toString(),e.name=e.name||Salla.config.get("page.slug"),e.keywords=e.keywords||(null==(r=document.querySelector("meta[name=keywords]"))?void 0:r.content),e.referrer=e.referrer||document.referrer,this.history.push({action:"page",payload:e}),this.pushEventToCustomTrackers("page",e)}finalPayload(e={}){return this.attachRealtimeContext(),Br({},{},e)}attachRealtimeContext(){try{const e="accepted"===Salla.storage.get("cookies-consent"),t=["user.id","cart.user_id"],r=["user.id","cart.id","cart.user_id","cart.count","cart.summary.count","scope.id","branch-choosed-before"].filter(r=>e||!t.includes(r)).reduce((e,t)=>{const r=Salla.storage.get(t);return r&&(e[t.replace(".","_")]=r),e},{});e||(delete r.user_id,delete r.cart_user_id),this.setContext("localStorage",Object.keys(r).length>0?r:void 0),["device","os","app"].forEach(e=>{const t=Salla.storage.get(e);t&&this.setContext(e,t)})}catch(e){Salla.analytics.log("attachRealtimeContext",{error:e.message}),Salla.log("Error attaching realtime context:",e)}const e=Salla.storage.getWithTTL("s-utms");if(!e)return;const{"s-utm-campaign":t,"s-utm-source":r,"s-utm-medium":n,"s-utm-term":i,"s-utm-content":o,"s-utm-referrer":a}=e;this.setContext("campaign",{name:t,source:r,medium:n,term:i,content:o,referrer:a})}registerTracker(e){"object"==typeof e?"string"==typeof e.name&&e.name?"function"==typeof e.track?"function"==typeof e.page?this.customTrackers.find(t=>t.name===e.name)?Salla.log("tracker with the same name already exists!"):(this.customTrackers.push(e),this.history.forEach(t=>"track"===t.action?e.track(t.eventName,t.payload):"page"===t.action?e.page(t.payload):void 0)):Salla.log("tracker.page most be a function!"):Salla.log("tracker.track most be a function!"):Salla.log("tracker.name most be a string!"):Salla.log('tracker most be an object {name:"tracker name", track: callback, page: callback}!')}pushEventToCustomTrackers(e,t,r={}){const n="page"===e?[t]:[t,r];return Promise.allSettled(this.customTrackers.map(t=>this.pushEventToCustomTracker(t[e],n))).then(t=>t.filter(e=>"rejected"===e.status).map(t=>Salla.log("Error on customTracker to send "+e,t)))}pushEventToCustomTracker(e,t){try{const r=e(...t);return Promise.resolve(r).catch(e=>Promise.reject(e))}catch(e){return Promise.reject(e)}}getConsentState(){return Salla.storage.get("cookies-consent","unknown")}getConsentPolicies(e=null){var t;if(null==(t=Salla.config.get("store.features"))||!t.includes("website-cookies"))return{};const r="accepted"===(e=e||this.getConsentState());return{privacy:{dontSend:!1,disableUserIds:!r,ipPolicy:r?"keep":"remove"}}}setConsent(e){var t;if(null==(t=Salla.config.get("store.features"))||!t.includes("website-cookies"))return;if(!["accepted","rejected"].includes(e))return;const r=this.getConsentState();if(this._jitsuConfig&&this.jitsuAnalytics&&r!==e)try{var n;const t=this.getConsentPolicies(e);this.jitsuAnalytics=Bc(Br({},this._jitsuConfig,t)),this._anonymousId=(null==(n=this.jitsuAnalytics)||null==(n=n.user())?void 0:n.anonymousId)||null,Salla.config.set("jitsu.anonymous_id",this._anonymousId),Object.entries(this.context).forEach(([e,t])=>{this.jitsuAnalytics.setContextProperty(e,t)})}catch(e){Salla.log("Error re-initializing Jitsu on consent change:",e)}}getFormattedUser(e){return e.phone=e.mobile,e.country=e.country_code,e.language=e.language_code,e.currency=e.currency_code,e}generateSessionId(){return"undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}initSessionId(){this._sessionId=this._sessionId||Salla.storage.getWithTTL(Uc)||this.generateSessionId(),Salla.storage.setWithTTL(Uc,this._sessionId,30),this.setContext("session_id",this._sessionId)}clearSessionId(){this._sessionId=null,Salla.storage.setWithTTL(Uc,null,0),this.setContext("session_id",null)}getAnonymousId(){try{if(this._anonymousId)return this._anonymousId;if(this.jitsuAnalytics){var e;const t=null==(e=this.jitsuAnalytics.user())?void 0:e.anonymousId;if(t)return this._anonymousId=t,t}return null}catch(e){return Salla.log("Error getting anonymous ID from Jitsu:",e),null}}},Fr.mobile=new class{constructor(){this._last={},this._tick=0,this._tickScheduled=!1,this.rows=[{on:"cart::updated",action:"cart.changed",map:this._cart},{on:"cart::latest.fetched",action:"cart.changed",pick:"data.cart",map:this._cart},{on:"cart::item.updated",action:"cart.changed",pick:"data.cart",map:this._cart},{on:"auth::verified",action:"auth.changed",pick:"data",map:this._auth},{on:"auth::registered",action:"auth.changed",pick:"data",map:this._auth},{on:"auth::logged.in",action:"auth.changed",pick:"data",map:this._auth},{on:"auth::logged.out",action:"auth.changed",map:()=>({token:null,refresh_token:null,expires_at:null})},{on:"scope::changed",action:"scope.changed",map:this._scope},{on:"currency::changed",action:"currency.changed",map:this._currency},{on:"salla::bullet-delivery.allocation.confirmed",action:"delivery.confirmed",map:this._pass},{on:"salla::bullet-delivery.open-sheet",action:"delivery.open",map:this._pass},{on:"modal::open",action:"modal.open",map:zc},{on:"share-element",action:"share.element",map:this._pass},{on:"booking::open",action:"booking.open",map:this._pass},{on:"booking::added",action:"booking.added",pick:"data",map:this._pass},{on:"booking::addition.failed",action:"booking.failed",map:this._error}],$c.forEach(e=>{const t=e.wrap||(e=>null==e?{}:e);e.event&&this.rows.push({on:e.event,action:e.action,map:e=>t(e)}),this[e.method]=r=>this.action(e.action,t(r))}),this.route("twilight.loaded",{}),Salla.onReady(e=>{if(!this.isEnabled())return void(Salla.log&&Salla.log("Salla.mobile: not a native webview, bridge is a no-op"));this.rows.forEach(e=>this._subscribe(e)),this.route("twilight.ready",{});const t=Salla.helpers.getNested(e,"page.title");t&&this.setTitle(t)})}isEnabled(){if("undefined"==typeof window)return!1;try{var e,t;return!!(null!=(e=Salla.helpers)&&null!=e.isWebView&&e.isWebView()||null!=(t=Salla.config)&&null!=t.isMobileApp&&t.isMobileApp())}catch(e){return!1}}isSpaWebview(){try{var e;return this.isEnabled()&&!(null==(e=Salla.config)||null==e.get||!e.get("theme.is_spa_webview"))}catch(e){return!1}}register(e){return this.rows.push(e),this.isEnabled()&&this._subscribe(e),this}action(e,t={}){return this.route(e,t),this}on(e,t){return Salla.event.on(`${qc}::${e}`,t),this}off(e,t){return Salla.event.off(`${qc}::${e}`,t),this}_subscribe(e){Salla.event.on(e.on,(...t)=>this.route(e.action,this._safeMap(e,t)))}_safeMap(e,t){try{const r=e.pick?Salla.helpers.getNested(t[0],e.pick):t[0];return e.map.call(this,r,t)}catch(t){return Salla.logger&&Salla.logger.warn&&Salla.logger.warn(`Salla.mobile: mapper failed for '${e.on}'`,t),null}}route(e,t){if(null==t||!this.isEnabled())return!1;if(!this._assertSafeAction(e))return!1;const r=this._fingerprint(t),n=this._currentTick(),i=this._last[e];return(!i||i.tick!==n||i.sig!==r)&&(this._last[e]={sig:r,tick:n},Salla.event.emit(`${qc}::${e}`,t),!0)}_assertSafeAction(e){if("string"!=typeof e||-1===e.indexOf("."))return Salla.logger&&Salla.logger.warn&&Salla.logger.warn(`Salla.mobile: action '${e}' rejected — must contain a '.' (e.g. 'cart.changed').`),!1;try{if("function"==typeof(Salla.call&&Salla.call(`${qc}.${e}`)))return Salla.logger&&Salla.logger.warn&&Salla.logger.warn(`Salla.mobile: action '${e}' collides with a real Salla.mobile member and would be hijacked by emit(); rejected.`),!1}catch(e){}return!0}_currentTick(){return this._tickScheduled||(this._tickScheduled=!0,Promise.resolve().then(()=>{this._tick++,this._tickScheduled=!1})),this._tick}_fingerprint(e){try{return JSON.stringify(e)}catch(t){return String(e)}}_cart(e){let t=(e=e||{}).id;null==t&&(t=this._get(()=>Salla.cart.api.latestCart.cart.id)),null==t&&(t=this._get(()=>Salla.storage.get("cart.id")));let r=e.count;return null==r&&(r=this._get(()=>Salla.storage.get("cart.summary.count"))),{cartId:null==t?null:t,count:Number(r)||0}}_auth(e){const t=(e=e||{}).token,r="string"==typeof t?t:t&&(t.access_token||t.token)||null;if(!r)return null;const n=e.refresh_token||t&&"object"==typeof t&&t.refresh_token||null;let i=null;try{var o;i=null!=(o=(Ea(r)||{}).exp)?o:null}catch(e){}return{token:r,refresh_token:n,expires_at:i}}_scope(e){let t=Salla.helpers.getNested(e,"data.id");return null==t&&(t=this._get(()=>Salla.config.get("scope.id"))),null==t&&(t=this._get(()=>Salla.storage.get("scope.id"))),{id:null==t?null:t}}_currency(e,t){let r=t&&t[1];return null==r&&(r=this._get(()=>Salla.config.get("user.currency_code"))),{code:null==r?null:r}}_pass(e){return null==e?{}:e}_error(e){return{message:"string"==typeof e?e:Salla.helpers.getNested(e,"response.data.error.message")||e&&e.message||null}}_get(e){try{const t=e();return null==t?null:t}catch(e){return null}}},Fr.init=e=>new Ta(e),new class{constructor(e={}){this.config=Br({WHITELIST:[location.hostname,"salla.com","salla.sa","salla.dev","salla.network","salla.group","mtjr.at"],POLL_INTERVAL_MS:500,WHITELIST_PAGES:["customer.orders.single","page-single","blog.single","blog.index"]},e),this.originalMethods={},this.isInitialized=!1,Salla.onReady(()=>this.init())}normalizeUrl(e){try{return new URL(e,location.href)}catch(e){return null}}shouldIgnoreUrl(e){if(!e)return!1;const t="string"==typeof e?e:e.href||String(e),r=t.toLowerCase();if(["tel:","mailto:","javascript:"].some(e=>r.startsWith(e)))return!0;try{const e=new URL(t,location.href).hostname.toLowerCase();return["facebook.com","fb.com","twitter.com","x.com","instagram.com","linkedin.com","youtube.com","youtu.be","tiktok.com","snapchat.com","pinterest.com","whatsapp.com","wa.me","iwtsp.com","telegram.org","t.me","discord.com","discord.gg","reddit.com","tumblr.com","google.com","forms.gle","maps.app.goo.gl","goo.gl","apple.com","smsaexpress.com","aramex.com","aj-ex.com","redboxsa.com","fastcoo-tech.com","express.dhl","najizxpress.net","jtexpress.me","jtexpress-sa.com","tamex.com.sa","aymakan.com.sa","fastlo.com","sls-express.com","logestechs.com","massuul.com","tamara.co","gov.sa","org.sa","stc.com.sa","sa","addtoany.com","wchat.freshchat.com","getbutton.io","heyzine.com","linktr.ee"].some(t=>e===t||e.endsWith("."+t))}catch(e){return!1}}isWhitelisted(e){if(!e)return!1;const t=e.hostname.toLowerCase();for(const e of this.config.WHITELIST){const r=String(e||"").toLowerCase().trim();if(r&&(t===r||t.endsWith("."+r)))return!0}return!1}emit(e){try{window.__redirectLogs||(window.__redirectLogs=[]),window.__redirectLogs.push(e);try{Salla.analytics.log("redirect",e)}catch(e){}}catch(e){}}logRedirect(e,t,r){if(this.shouldIgnoreUrl(t))return;const n=this.normalizeUrl(t),i=this.normalizeUrl(location.href),o=this.isWhitelisted(n),a={redirect_source:e,redirect_from:i?i.href:String(location.href),redirect_to:n?n.href:String(t),redirect_host:n?n.hostname:null,redirect_referrer:document.referrer||null,page_slug:Salla.config.get("page.slug"),whitelisted:o,stack:r&&r.stack?String(r.stack):void 0,meta:r||void 0};o||this.emit(a)}hookHistoryAPIs(){["pushState","replaceState"].forEach(e=>{try{const t=history[e];"function"==typeof t&&(this.originalMethods[`history.${e}`]=t,history[e]=(...r)=>{try{var n;this.logRedirect(e,null!=(n=r[2])?n:location.href)}catch(e){}return t.apply(history,r)})}catch(e){}}),window.addEventListener("popstate",()=>{this.logRedirect("popstate",location.href)}),window.addEventListener("hashchange",()=>{this.logRedirect("hashchange",location.href)})}hookLocationMethods(){try{const e=location.assign.bind(location);this.originalMethods["location.assign"]=e,location.assign=t=>(this.logRedirect("location.assign",t,{stack:(new Error).stack}),e(t))}catch(e){}try{const e=location.replace.bind(location);this.originalMethods["location.replace"]=e,location.replace=t=>(this.logRedirect("location.replace",t,{stack:(new Error).stack}),e(t))}catch(e){}}hookWindowOpen(){try{const e=window.open;this.originalMethods["window.open"]=e,window.open=(t,...r)=>(t&&this.logRedirect("window.open",t,{stack:(new Error).stack}),e.apply(window,[t,...r]))}catch(e){}}setupEventListeners(){this.handleLinkClick=e=>{const t=e.target&&e.target.closest?e.target.closest("a[href]"):null;if(!t)return;const r=t.getAttribute("href");if(!r||r.startsWith("#"))return;if(this.shouldIgnoreUrl(r))return;const n=t.getAttribute("target")||"_self";setTimeout(()=>{this.logRedirect("link-click",r,{target:n})},0)},document.addEventListener("click",this.handleLinkClick,!0),this.handleFormSubmit=e=>{const t=e.target,r=t&&t.getAttribute&&t.getAttribute("action")||location.href,n=(t&&t.method?String(t.method):"GET").toUpperCase();this.logRedirect("form-submit",r,{method:n})},document.addEventListener("submit",this.handleFormSubmit,!0)}setupPerformanceObserver(){try{this.performanceObserver=new PerformanceObserver(e=>{for(const t of e.getEntries())"navigation"===t.entryType&&this.logRedirect("performance-navigation",location.href,{type:t.type,redirectCount:t.redirectCount})}),this.performanceObserver.observe({type:"navigation",buffered:!0})}catch(e){}}init(){if(this.config.WHITELIST_PAGES.includes(Salla.config.get("page.slug")))return;if(this.isInitialized)return;const e=new URL(Salla.config.get("store.url")).hostname.split(".").slice(-2).join(".");this.config.WHITELIST.includes(e)||this.config.WHITELIST.push(e),this.hookHistoryAPIs(),this.hookLocationMethods(),this.hookWindowOpen(),this.setupEventListeners(),this.setupPerformanceObserver(),this.isInitialized=!0}destroy(){this.isInitialized&&(Object.keys(this.originalMethods).forEach(e=>{const[t,r]=e.split(".");"history"===t&&this.originalMethods[e]?history[r]=this.originalMethods[e]:"location"===t&&this.originalMethods[e]?location[r]=this.originalMethods[e]:"window"===t&&"open"===r&&this.originalMethods[e]&&(window.open=this.originalMethods[e])}),this.handleLinkClick&&document.removeEventListener("click",this.handleLinkClick,!0),this.handleFormSubmit&&document.removeEventListener("submit",this.handleFormSubmit,!0),this.performanceObserver&&this.performanceObserver.disconnect(),this.isInitialized=!1)}},salla.event.once("twilight::init",salla.init),salla.event.on("twilight::api",e=>{let t=null==e?void 0:e.events;t&&salla.event.dispatchEvents(t)}),Fr.success=Fr.notify.success,Fr.error=Fr.notify.error,window.dispatchEvent(new CustomEvent("salla::created")),Fr});
|
|
20
2
|
//# sourceMappingURL=twilight.min.js.map
|