@salla.sa/twilight 2.9.43 → 2.9.45

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.
@@ -1,4 +1,4 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("process"),require("buffer")):"function"==typeof define&&define.amd?define(["exports","process","buffer"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Salla={},e.process$1,e.buffer)}(this,(function(e,t,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=r(t),a="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},o=Array.isArray,l="object"==typeof s&&s&&s.Object===Object&&s,c="object"==typeof self&&self&&self.Object===Object&&self,u=l||c||Function("return this")(),d=u.Symbol,h=d,f=Object.prototype,p=f.hasOwnProperty,g=f.toString,m=h?h.toStringTag:void 0;var v=function(e){var t=p.call(e,m),n=e[m];try{e[m]=void 0;var r=!0}catch(e){}var i=g.call(e);return r&&(t?e[m]=n:delete e[m]),i},y=Object.prototype.toString;var b=v,w=function(e){return y.call(e)},_=d?d.toStringTag:void 0;var S=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":_&&_ in Object(e)?b(e):w(e)};var E=S,x=function(e){return null!=e&&"object"==typeof e};var A=function(e){return"symbol"==typeof e||x(e)&&"[object Symbol]"==E(e)},P=o,F=A,L=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,k=/^\w*$/;var O=function(e,t){if(P(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!F(e))||(k.test(e)||!L.test(e)||null!=t&&e in Object(t))};var T=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},j=S,C=T;var R,I=function(e){if(!C(e))return!1;var t=j(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},q=u["__core-js_shared__"],N=(R=/[^.]+$/.exec(q&&q.keys&&q.keys.IE_PROTO||""))?"Symbol(src)_1."+R:"";var D=function(e){return!!N&&N in e},U=Function.prototype.toString;var H=I,$=D,M=T,z=function(e){if(null!=e){try{return U.call(e)}catch(e){}try{return e+""}catch(e){}}return""},B=/^\[object .+?Constructor\]$/,G=Function.prototype,V=Object.prototype,W=G.toString,J=V.hasOwnProperty,Q=RegExp("^"+W.call(J).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var K=function(e){return!(!M(e)||$(e))&&(H(e)?Q:B).test(z(e))},Z=function(e,t){return null==e?void 0:e[t]};var X=function(e,t){var n=Z(e,t);return K(n)?n:void 0},Y=X(Object,"create"),ee=Y;var te=function(){this.__data__=ee?ee(null):{},this.size=0};var ne=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},re=Y,ie=Object.prototype.hasOwnProperty;var ae=function(e){var t=this.__data__;if(re){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return ie.call(t,e)?t[e]:void 0},se=Y,oe=Object.prototype.hasOwnProperty;var le=function(e){var t=this.__data__;return se?void 0!==t[e]:oe.call(t,e)},ce=Y;var ue=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=ce&&void 0===t?"__lodash_hash_undefined__":t,this},de=te,he=ne,fe=ae,pe=le,ge=ue;function me(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}me.prototype.clear=de,me.prototype.delete=he,me.prototype.get=fe,me.prototype.has=pe,me.prototype.set=ge;var ve=me;var ye=function(){this.__data__=[],this.size=0};var be=function(e,t){return e===t||e!=e&&t!=t};var we=function(e,t){for(var n=e.length;n--;)if(be(e[n][0],t))return n;return-1},_e=we,Se=Array.prototype.splice;var Ee=function(e){var t=this.__data__,n=_e(t,e);return!(n<0)&&(n==t.length-1?t.pop():Se.call(t,n,1),--this.size,!0)},xe=we;var Ae=function(e){var t=this.__data__,n=xe(t,e);return n<0?void 0:t[n][1]},Pe=we;var Fe=we;var Le=function(e,t){var n=this.__data__,r=Fe(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},ke=ye,Oe=Ee,Te=Ae,je=function(e){return Pe(this.__data__,e)>-1},Ce=Le;function Re(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Re.prototype.clear=ke,Re.prototype.delete=Oe,Re.prototype.get=Te,Re.prototype.has=je,Re.prototype.set=Ce;var Ie=Re,qe=X(u,"Map"),Ne=ve,De=Ie,Ue=qe;var He=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};var $e=function(e,t){var n=e.__data__;return He(t)?n["string"==typeof t?"string":"hash"]:n.map},Me=$e;var ze=$e;var Be=$e;var Ge=$e;var Ve=function(e,t){var n=Ge(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},We=function(){this.size=0,this.__data__={hash:new Ne,map:new(Ue||De),string:new Ne}},Je=function(e){var t=Me(this,e).delete(e);return this.size-=t?1:0,t},Qe=function(e){return ze(this,e).get(e)},Ke=function(e){return Be(this,e).has(e)},Ze=Ve;function Xe(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Xe.prototype.clear=We,Xe.prototype.delete=Je,Xe.prototype.get=Qe,Xe.prototype.has=Ke,Xe.prototype.set=Ze;var Ye=Xe;function et(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var s=e.apply(this,r);return n.cache=a.set(i,s)||a,s};return n.cache=new(et.Cache||Ye),n}et.Cache=Ye;var tt=et;var nt=function(e){var t=tt(e,(function(e){return 500===n.size&&n.clear(),e})),n=t.cache;return t},rt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,it=/\\(\\)?/g,at=nt((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(rt,(function(e,n,r,i){t.push(r?i.replace(it,"$1"):n||e)})),t}));var st=function(e,t){for(var n=-1,r=null==e?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i},ot=o,lt=A,ct=d?d.prototype:void 0,ut=ct?ct.toString:void 0;var dt=function e(t){if("string"==typeof t)return t;if(ot(t))return st(t,e)+"";if(lt(t))return ut?ut.call(t):"";var n=t+"";return"0"==n&&1/t==-Infinity?"-0":n},ht=dt;var ft=o,pt=O,gt=at,mt=function(e){return null==e?"":ht(e)};var vt=A;var yt=function(e,t){return ft(e)?e:pt(e,t)?[e]:gt(mt(e))},bt=function(e){if("string"==typeof e||vt(e))return e;var t=e+"";return"0"==t&&1/e==-Infinity?"-0":t};var wt=function(e,t){for(var n=0,r=(t=yt(t,e)).length;null!=e&&n<r;)e=e[bt(t[n++])];return n&&n==r?e:void 0};var _t=function(e,t,n){var r=null==e?void 0:wt(e,t);return void 0===r?n:r},St={exports:{}};!function(e,t){!function(t){var n=Object.hasOwnProperty,r=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},a="object"==typeof i.default&&"function"==typeof i.default.nextTick,s="function"==typeof Symbol,o="object"==typeof Reflect,l="function"==typeof setImmediate?setImmediate:setTimeout,c=s?o&&"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 u(){this._events={},this._conf&&d.call(this,this._conf)}function d(e){e&&(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),e.maxListeners!==t&&(this._maxListeners=e.maxListeners),e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),e.ignoreErrors&&(this.ignoreErrors=e.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function h(e,t){var n="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(n+=" Event name: "+t+"."),void 0!==i.default&&i.default.emitWarning){var r=new Error(n);r.name="MaxListenersExceededWarning",r.emitter=this,r.count=e,i.default.emitWarning(r)}else console.error(n),console.trace&&console.trace()}var f=function(e,t,n){var r=arguments.length;switch(r){case 0:return[];case 1:return[e];case 2:return[e,t];case 3:return[e,t,n];default:for(var i=new Array(r);r--;)i[r]=arguments[r];return i}};function p(e,n){for(var r={},i=e.length,a=n?n.length:0,s=0;s<i;s++)r[e[s]]=s<a?n[s]:t;return r}function g(e,t,n){var r,i;if(this._emitter=e,this._target=t,this._listeners={},this._listenersCount=0,(n.on||n.off)&&(r=n.on,i=n.off),t.addEventListener?(r=t.addEventListener,i=t.removeEventListener):t.addListener?(r=t.addListener,i=t.removeListener):t.on&&(r=t.on,i=t.off),!r&&!i)throw Error("target does not implement any known event API");if("function"!=typeof r)throw TypeError("on method must be a function");if("function"!=typeof i)throw TypeError("off method must be a function");this._on=r,this._off=i;var a=e._observers;a?a.push(this):e._observers=[this]}function m(e,r,i,a){var s=Object.assign({},r);if(!e)return s;if("object"!=typeof e)throw TypeError("options must be an object");var o,l,c,u=Object.keys(e),d=u.length;function h(e){throw Error('Invalid "'+o+'" option value'+(e?". Reason: "+e:""))}for(var f=0;f<d;f++){if(o=u[f],!a&&!n.call(r,o))throw Error('Unknown "'+o+'" option');(l=e[o])!==t&&(c=i[o],s[o]=c?c(l,h):l)}return s}function v(e,t){return"function"==typeof e&&e.hasOwnProperty("prototype")||t("value must be a constructor"),e}function y(e){var t="value must be type of "+e.join("|"),n=e.length,r=e[0],i=e[1];return 1===n?function(e,n){if(typeof e===r)return e;n(t)}:2===n?function(e,n){var a=typeof e;if(a===r||a===i)return e;n(t)}:function(r,i){for(var a=typeof r,s=n;s-- >0;)if(a===e[s])return r;i(t)}}Object.assign(g.prototype,{subscribe:function(e,t,n){var r=this,i=this._target,a=this._emitter,s=this._listeners,o=function(){var r=f.apply(null,arguments),s={data:r,name:t,original:e};if(n){var o=n.call(i,s);!1!==o&&a.emit.apply(a,[s.name].concat(r))}else a.emit.apply(a,[t].concat(r))};if(s[e])throw Error("Event '"+e+"' is already listening");this._listenersCount++,a._newListener&&a._removeListener&&!r._onNewListener?(this._onNewListener=function(n){n===t&&null===s[e]&&(s[e]=o,r._on.call(i,e,o))},a.on("newListener",this._onNewListener),this._onRemoveListener=function(n){n===t&&!a.hasListeners(n)&&s[e]&&(s[e]=null,r._off.call(i,e,o))},s[e]=null,a.on("removeListener",this._onRemoveListener)):(s[e]=o,r._on.call(i,e,o))},unsubscribe:function(e){var t,n,r,i=this,a=this._listeners,s=this._emitter,o=this._off,l=this._target;if(e&&"string"!=typeof e)throw TypeError("event must be a string");function u(){i._onNewListener&&(s.off("newListener",i._onNewListener),s.off("removeListener",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var e=S.call(s,i);s._observers.splice(e,1)}if(e){if(!(t=a[e]))return;o.call(l,e,t),delete a[e],--this._listenersCount||u()}else{for(r=(n=c(a)).length;r-- >0;)e=n[r],o.call(l,e,a[e]);this._listeners={},this._listenersCount=0,u()}}});var b=y(["function"]),w=y(["object","function"]);function _(e,t,n){var r,i,a,s=0,o=new e((function(l,c,u){function d(){i&&(i=null),s&&(clearTimeout(s),s=0)}n=m(n,{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}}),r=!n.overload&&"function"==typeof e.prototype.cancel&&"function"==typeof u;var h=function(e){d(),l(e)},f=function(e){d(),c(e)};r?t(h,f,u):(i=[function(e){f(e||Error("canceled"))}],t(h,f,(function(e){if(a)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof e)throw TypeError("onCancel callback must be a function");i.push(e)})),a=!0),n.timeout>0&&(s=setTimeout((function(){var e=Error("timeout");e.code="ETIMEDOUT",s=0,o.cancel(e),c(e)}),n.timeout))}));return r||(o.cancel=function(e){if(i){for(var t=i.length,n=1;n<t;n++)i[n](e);i[0](e),i=null}}),o}function S(e){var t=this._observers;if(!t)return-1;for(var n=t.length,r=0;r<n;r++)if(t[r]._target===e)return r;return-1}function E(e,t,n,r,i){if(!n)return null;if(0===r){var a=typeof t;if("string"===a){var s,o,l=0,u=0,d=this.delimiter,h=d.length;if(-1!==(o=t.indexOf(d))){s=new Array(5);do{s[l++]=t.slice(u,o),u=o+h}while(-1!==(o=t.indexOf(d,u)));s[l++]=t.slice(u),t=s,i=l}else t=[t],i=1}else"object"===a?i=t.length:(t=[t],i=1)}var f,p,g,m,v,y,b,w=null,_=t[r],S=t[r+1];if(r===i)n._listeners&&("function"==typeof n._listeners?(e&&e.push(n._listeners),w=[n]):(e&&e.push.apply(e,n._listeners),w=[n]));else{if("*"===_){for(o=(y=c(n)).length;o-- >0;)"_listeners"!==(f=y[o])&&(b=E(e,t,n[f],r+1,i))&&(w?w.push.apply(w,b):w=b);return w}if("**"===_){for((v=r+1===i||r+2===i&&"*"===S)&&n._listeners&&(w=E(e,t,n,i,i)),o=(y=c(n)).length;o-- >0;)"_listeners"!==(f=y[o])&&("*"===f||"**"===f?(n[f]._listeners&&!v&&(b=E(e,t,n[f],i,i))&&(w?w.push.apply(w,b):w=b),b=E(e,t,n[f],r,i)):b=E(e,t,n[f],f===S?r+2:r,i),b&&(w?w.push.apply(w,b):w=b));return w}n[_]&&(w=E(e,t,n[_],r+1,i))}if((p=n["*"])&&E(e,t,p,r+1,i),g=n["**"])if(r<i)for(g._listeners&&E(e,t,g,i,i),o=(y=c(g)).length;o-- >0;)"_listeners"!==(f=y[o])&&(f===S?E(e,t,g[f],r+2,i):f===_?E(e,t,g[f],r+1,i):((m={})[f]=g[f],E(e,t,{"**":m},r+1,i)));else g._listeners?E(e,t,g,i,i):g["*"]&&g["*"]._listeners&&E(e,t,g["*"],i,i);return w}function x(e,t,n){var r,i,a=0,s=0,o=this.delimiter,l=o.length;if("string"==typeof e)if(-1!==(r=e.indexOf(o))){i=new Array(5);do{i[a++]=e.slice(s,r),s=r+l}while(-1!==(r=e.indexOf(o,s)));i[a++]=e.slice(s)}else i=[e],a=1;else i=e,a=e.length;if(a>1)for(r=0;r+1<a;r++)if("**"===i[r]&&"**"===i[r+1])return;var c,u=this.listenerTree;for(r=0;r<a;r++)if(u=u[c=i[r]]||(u[c]={}),r===a-1)return u._listeners?("function"==typeof u._listeners&&(u._listeners=[u._listeners]),n?u._listeners.unshift(t):u._listeners.push(t),!u._listeners.warned&&this._maxListeners>0&&u._listeners.length>this._maxListeners&&(u._listeners.warned=!0,h.call(this,u._listeners.length,c))):u._listeners=t,!0;return!0}function A(e,t,n,r){for(var i,a,s,o,l=c(e),u=l.length,d=e._listeners;u-- >0;)i=e[a=l[u]],s="_listeners"===a?n:n?n.concat(a):[a],o=r||"symbol"==typeof a,d&&t.push(o?s:s.join(this.delimiter)),"object"==typeof i&&A.call(this,i,t,s,o);return t}function P(e){for(var t,n,r,i=c(e),a=i.length;a-- >0;)(t=e[n=i[a]])&&(r=!0,"_listeners"===n||P(t)||delete e[n]);return r}function F(e,t,n){this.emitter=e,this.event=t,this.listener=n}function L(e,n,r){if(!0===r)o=!0;else if(!1===r)s=!0;else{if(!r||"object"!=typeof r)throw TypeError("options should be an object or true");var s=r.async,o=r.promisify,c=r.nextTick,u=r.objectify}if(s||c||o){var d=n,h=n._origin||n;if(c&&!a)throw Error("process.nextTick is not supported");o===t&&(o="AsyncFunction"===n.constructor.name),n=function(){var e=arguments,t=this,n=this.event;return o?c?Promise.resolve():new Promise((function(e){l(e)})).then((function(){return t.event=n,d.apply(t,e)})):(c?i.default.nextTick:l)((function(){t.event=n,d.apply(t,e)}))},n._async=!0,n._origin=h}return[n,u?new F(this,e,n):this]}function k(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,d.call(this,e)}F.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},k.EventEmitter2=k,k.prototype.listenTo=function(e,n,i){if("object"!=typeof e)throw TypeError("target musts be an object");var a=this;function s(t){if("object"!=typeof t)throw TypeError("events must be an object");var n,r=i.reducers,s=S.call(a,e);n=-1===s?new g(a,e,i):a._observers[s];for(var o,l=c(t),u=l.length,d="function"==typeof r,h=0;h<u;h++)o=l[h],n.subscribe(o,t[o]||o,d?r:r&&r[o])}return i=m(i,{on:t,off:t,reducers:t},{on:b,off:b,reducers:w}),r(n)?s(p(n)):s("string"==typeof n?p(n.split(/\s+/)):n),this},k.prototype.stopListeningTo=function(e,t){var n=this._observers;if(!n)return!1;var r,i=n.length,a=!1;if(e&&"object"!=typeof e)throw TypeError("target should be an object");for(;i-- >0;)r=n[i],e&&r._target!==e||(r.unsubscribe(t),a=!0);return a},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,n){return this._once(e,t,!1,n)},k.prototype.prependOnceListener=function(e,t,n){return this._once(e,t,!0,n)},k.prototype._once=function(e,t,n,r){return this._many(e,1,t,n,r)},k.prototype.many=function(e,t,n,r){return this._many(e,t,n,!1,r)},k.prototype.prependMany=function(e,t,n,r){return this._many(e,t,n,!0,r)},k.prototype._many=function(e,t,n,r,i){var a=this;if("function"!=typeof n)throw new Error("many only accepts instances of Function");function s(){return 0==--t&&a.off(e,s),n.apply(this,arguments)}return s._origin=n,this._on(e,s,r,i)},k.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||u.call(this);var e,t,n,r,i,a,o=arguments[0],l=this.wildcard;if("newListener"===o&&!this._newListener&&!this._events.newListener)return!1;if(l&&(e=o,"newListener"!==o&&"removeListener"!==o&&"object"==typeof o)){if(n=o.length,s)for(r=0;r<n;r++)if("symbol"==typeof o[r]){a=!0;break}a||(o=o.join(this.delimiter))}var c,d=arguments.length;if(this._all&&this._all.length)for(r=0,n=(c=this._all.slice()).length;r<n;r++)switch(this.event=o,d){case 1:c[r].call(this,o);break;case 2:c[r].call(this,o,arguments[1]);break;case 3:c[r].call(this,o,arguments[1],arguments[2]);break;default:c[r].apply(this,arguments)}if(l)c=[],E.call(this,c,e,this.listenerTree,0,n);else{if("function"==typeof(c=this._events[o])){switch(this.event=o,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(r=0,n=c.length;r<n;r++)switch(this.event=o,d){case 1:c[r].call(this);break;case 2:c[r].call(this,arguments[1]);break;case 3:c[r].call(this,arguments[1],arguments[2]);break;default:c[r].apply(this,t)}return!0}if(!this.ignoreErrors&&!this._all&&"error"===o)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},k.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||u.call(this);var e,t,n,r,i,a,o=arguments[0],l=this.wildcard;if("newListener"===o&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(l&&(e=o,"newListener"!==o&&"removeListener"!==o&&"object"==typeof o)){if(r=o.length,s)for(i=0;i<r;i++)if("symbol"==typeof o[i]){t=!0;break}t||(o=o.join(this.delimiter))}var c,d=[],h=arguments.length;if(this._all)for(i=0,r=this._all.length;i<r;i++)switch(this.event=o,h){case 1:d.push(this._all[i].call(this,o));break;case 2:d.push(this._all[i].call(this,o,arguments[1]));break;case 3:d.push(this._all[i].call(this,o,arguments[1],arguments[2]));break;default:d.push(this._all[i].apply(this,arguments))}if(l?(c=[],E.call(this,c,e,this.listenerTree,0)):c=this._events[o],"function"==typeof c)switch(this.event=o,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(n=new Array(h-1),a=1;a<h;a++)n[a-1]=arguments[a];d.push(c.apply(this,n))}else if(c&&c.length){if(c=c.slice(),h>3)for(n=new Array(h-1),a=1;a<h;a++)n[a-1]=arguments[a];for(i=0,r=c.length;i<r;i++)switch(this.event=o,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,n))}}else if(!this.ignoreErrors&&!this._all&&"error"===o)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(d)},k.prototype.on=function(e,t,n){return this._on(e,t,!1,n)},k.prototype.prependListener=function(e,t,n){return this._on(e,t,!0,n)},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,n,r,i){if("function"==typeof e)return this._onAny(e,n),this;if("function"!=typeof n)throw new Error("on only accepts instances of Function");this._events||u.call(this);var a,s=this;return i!==t&&(n=(a=L.call(this,e,n,i))[0],s=a[1]),this._newListener&&this.emit("newListener",e,n),this.wildcard?(x.call(this,e,n,r),s):(this._events[e]?("function"==typeof this._events[e]&&(this._events[e]=[this._events[e]]),r?this._events[e].unshift(n):this._events[e].push(n),!this._events[e].warned&&this._maxListeners>0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,h.call(this,this._events[e].length,e))):this._events[e]=n,s)},k.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,i=[];if(this.wildcard){var a="string"==typeof e?e.split(this.delimiter):e.slice();if(!(i=E.call(this,null,a,this.listenerTree,0)))return this}else{if(!this._events[e])return this;n=this._events[e],i.push({_listeners:n})}for(var s=0;s<i.length;s++){var o=i[s];if(n=o._listeners,r(n)){for(var l=-1,c=0,u=n.length;c<u;c++)if(n[c]===t||n[c].listener&&n[c].listener===t||n[c]._origin&&n[c]._origin===t){l=c;break}if(l<0)continue;return this.wildcard?o._listeners.splice(l,1):this._events[e].splice(l,1),0===n.length&&(this.wildcard?delete o._listeners:delete this._events[e]),this._removeListener&&this.emit("removeListener",e,t),this}(n===t||n.listener&&n.listener===t||n._origin&&n._origin===t)&&(this.wildcard?delete o._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return this.listenerTree&&P(this.listenerTree),this},k.prototype.offAny=function(e){var t,n=0,r=0;if(e&&this._all&&this._all.length>0){for(n=0,r=(t=this._all).length;n<r;n++)if(e===t[n])return t.splice(n,1),this._removeListener&&this.emit("removeListenerAny",e),this}else{if(t=this._all,this._removeListener)for(n=0,r=t.length;n<r;n++)this.emit("removeListenerAny",t[n]);this._all=[]}return this},k.prototype.removeListener=k.prototype.off,k.prototype.removeAllListeners=function(e){if(e===t)return!this._events||u.call(this),this;if(this.wildcard){var n,r=E.call(this,null,e,this.listenerTree,0);if(!r)return this;for(n=0;n<r.length;n++)r[n]._listeners=null;this.listenerTree&&P(this.listenerTree)}else this._events&&(this._events[e]=null);return this},k.prototype.listeners=function(e){var n,r,i,a,s,o=this._events;if(e===t){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!o)return[];for(a=(n=c(o)).length,i=[];a-- >0;)"function"==typeof(r=o[n[a]])?i.push(r):i.push.apply(i,r);return i}if(this.wildcard){if(!(s=this.listenerTree))return[];var l=[],u="string"==typeof e?e.split(this.delimiter):e.slice();return E.call(this,l,u,s,0),l}return o&&(r=o[e])?"function"==typeof r?[r]:r:[]},k.prototype.eventNames=function(e){var t=this._events;return this.wildcard?A.call(this,this.listenerTree,[],null,e):t?c(t):[]},k.prototype.listenerCount=function(e){return this.listeners(e).length},k.prototype.hasListeners=function(e){if(this.wildcard){var n=[],r="string"==typeof e?e.split(this.delimiter):e.slice();return E.call(this,n,r,this.listenerTree,0),n.length>0}var i=this._events,a=this._all;return!!(a&&a.length||i&&(e===t?c(i).length:i[e]))},k.prototype.listenersAny=function(){return this._all?this._all:[]},k.prototype.waitFor=function(e,n){var r=this,i=typeof n;return"number"===i?n={timeout:n}:"function"===i&&(n={filter:n}),_((n=m(n,{timeout:0,filter:t,handleError:!1,Promise:Promise,overload:!1},{filter:b,Promise:v})).Promise,(function(t,i,a){function s(){var a=n.filter;if(!a||a.apply(r,arguments))if(r.off(e,s),n.handleError){var o=arguments[0];o?i(o):t(f.apply(null,arguments).slice(1))}else t(f.apply(null,arguments))}a((function(){r.off(e,s)})),r._on(e,s,!1)}),{timeout:n.timeout,overload:n.overload})};var O=k.prototype;Object.defineProperties(k,{defaultMaxListeners:{get:function(){return O._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");O._maxListeners=e},enumerable:!0},once:{value:function(e,t,n){return _((n=m(n,{Promise:Promise,timeout:0,overload:!1},{Promise:v})).Promise,(function(n,r,i){var a;if("function"==typeof e.addEventListener)return a=function(){n(f.apply(null,arguments))},i((function(){e.removeEventListener(t,a)})),void e.addEventListener(t,a,{once:!0});var s,o=function(){s&&e.removeListener("error",s),n(f.apply(null,arguments))};"error"!==t&&(s=function(n){e.removeListener(t,o),r(n)},e.once("error",s)),i((function(){s&&e.removeListener("error",s),e.removeListener(t,o)})),e.once(t,o)}),{timeout:n.timeout,overload:n.overload})},writable:!0,configurable:!0}}),Object.defineProperties(O,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),e.exports=k}()}(St);var Et=St.exports,xt=Object.assign?Object.assign:function(e,t,n,r){for(var i=1;i<arguments.length;i++)Ot(Object(arguments[i]),(function(t,n){e[n]=t}));return e},At=function(){if(Object.create)return function(e,t,n,r){var i=kt(arguments,1);return xt.apply(this,[Object.create(e)].concat(i))};{function e(){}return function(t,n,r,i){var a=kt(arguments,1);return e.prototype=t,xt.apply(this,[new e].concat(a))}}}(),Pt=String.prototype.trim?function(e){return String.prototype.trim.call(e)}:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},Ft="undefined"!=typeof window?window:s,Lt={assign:xt,create:At,trim:Pt,bind:function(e,t){return function(){return t.apply(e,Array.prototype.slice.call(arguments,0))}},slice:kt,each:Ot,map:function(e,t){var n=jt(e)?[]:{};return Tt(e,(function(e,r){return n[r]=t(e,r),!1})),n},pluck:Tt,isList:jt,isFunction:function(e){return e&&"[object Function]"==={}.toString.call(e)},isObject:function(e){return e&&"[object Object]"==={}.toString.call(e)},Global:Ft};function kt(e,t){return Array.prototype.slice.call(e,t||0)}function Ot(e,t){Tt(e,(function(e,n){return t(e,n),!1}))}function Tt(e,t){if(jt(e)){for(var n=0;n<e.length;n++)if(t(e[n],n))return e[n]}else for(var r in e)if(e.hasOwnProperty(r)&&t(e[r],r))return e[r]}function jt(e){return null!=e&&"function"!=typeof e&&"number"==typeof e.length}var Ct=Lt.slice,Rt=Lt.pluck,It=Lt.each,qt=Lt.bind,Nt=Lt.create,Dt=Lt.isList,Ut=Lt.isFunction,Ht=Lt.isObject,$t={createStore:zt},Mt={version:"2.0.12",enabled:!1,get:function(e,t){var n=this.storage.read(this._namespacePrefix+e);return this._deserialize(n,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(n,r){e.call(t,t._deserialize(n),(r||"").replace(t._namespaceRegexp,""))}))},clearAll:function(){this.storage.clearAll()},hasNamespace:function(e){return this._namespacePrefix=="__storejs_"+e+"_"},createStore:function(){return zt.apply(this,arguments)},addPlugin:function(e){this._addPlugin(e)},namespace:function(e){return zt(this.storage,this.plugins,e)}};function zt(e,t,n){n||(n=""),e&&!Dt(e)&&(e=[e]),t&&!Dt(t)&&(t=[t]);var r=n?"__storejs_"+n+"_":"",i=n?new RegExp("^"+r):null;if(!/^[a-zA-Z0-9_\-]*$/.test(n))throw new Error("store.js namespaces can only have alphanumerics + underscores and dashes");var a={_namespacePrefix:r,_namespaceRegexp:i,_testStorage:function(e){try{var t="__storejs__test__";e.write(t,t);var n=e.read(t)===t;return e.remove(t),n}catch(e){return!1}},_assignPluginFnProp:function(e,t){var n=this[t];this[t]=function(){var t=Ct(arguments,0),r=this;function i(){if(n)return It(arguments,(function(e,n){t[n]=e})),n.apply(r,t)}var a=[i].concat(t);return e.apply(r,a)}},_serialize:function(e){return JSON.stringify(e)},_deserialize:function(e,t){if(!e)return t;var n="";try{n=JSON.parse(e)}catch(t){n=e}return void 0!==n?n:t},_addStorage:function(e){this.enabled||this._testStorage(e)&&(this.storage=e,this.enabled=!0)},_addPlugin:function(e){var t=this;if(Dt(e))It(e,(function(e){t._addPlugin(e)}));else if(!Rt(this.plugins,(function(t){return e===t}))){if(this.plugins.push(e),!Ut(e))throw new Error("Plugins must be function values that return objects");var n=e.call(this);if(!Ht(n))throw new Error("Plugins must return an object of function properties");It(n,(function(n,r){if(!Ut(n))throw new Error("Bad plugin property: "+r+" from plugin "+e.name+". Plugins should only return functions.");t._assignPluginFnProp(n,r)}))}},addStorage:function(e){!function(){var e="undefined"==typeof console?null:console;if(e){(e.warn?e.warn:e.log).apply(e,arguments)}}("store.addStorage(storage) is deprecated. Use createStore([storages])"),this._addStorage(e)}},s=Nt(a,Mt,{plugins:[]});return s.raw={},It(s,(function(e,t){Ut(e)&&(s.raw[t]=qt(s,e))})),It(e,(function(e){s._addStorage(e)})),It(t,(function(e){s._addPlugin(e)})),s}var Bt=Lt.Global,Gt={name:"localStorage",read:Wt,write:function(e,t){return Vt().setItem(e,t)},each:function(e){for(var t=Vt().length-1;t>=0;t--){var n=Vt().key(t);e(Wt(n),n)}},remove:function(e){return Vt().removeItem(e)},clearAll:function(){return Vt().clear()}};function Vt(){return Bt.localStorage}function Wt(e){return Vt().getItem(e)}var Jt=Lt.Global,Qt={name:"sessionStorage",read:Zt,write:function(e,t){return Kt().setItem(e,t)},each:function(e){for(var t=Kt().length-1;t>=0;t--){var n=Kt().key(t);e(Zt(n),n)}},remove:function(e){return Kt().removeItem(e)},clearAll:function(){return Kt().clear()}};function Kt(){return Jt.sessionStorage}function Zt(e){return Kt().getItem(e)}var Xt=Lt.trim,Yt={name:"cookieStorage",read:function(e){if(!e||!rn(e))return null;var t="(?:^|.*;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(en.cookie.replace(new RegExp(t),"$1"))},write:function(e,t){if(!e)return;en.cookie=escape(e)+"="+escape(t)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:tn,remove:nn,clearAll:function(){tn((function(e,t){nn(t)}))}},en=Lt.Global.document;function tn(e){for(var t=en.cookie.split(/; ?/g),n=t.length-1;n>=0;n--)if(Xt(t[n])){var r=t[n].split("="),i=unescape(r[0]);e(unescape(r[1]),i)}}function nn(e){e&&rn(e)&&(en.cookie=escape(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function rn(e){return new RegExp("(?:^|;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(en.cookie)}var an={name:"memoryStorage",read:function(e){return sn[e]},write:function(e,t){sn[e]=t},each:function(e){for(var t in sn)sn.hasOwnProperty(t)&&e(sn[t],t)},remove:function(e){delete sn[e]},clearAll:function(e){sn={}}},sn={};function on(e,t=!1){e+="";let n,r=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],i=["0","1","2","3","4","5","6","7","8","9"],a=(t=t||!Salla.config.get("store.settings.arabic_numbers_enabled"))?r:i,s=t?i:r;for(let t=0;t<a.length;t++)n=new RegExp(a[t],"g"),e=e.replace(n,s[t]);return e}function ln(e){let t=(e.match(/\./g)||[]).length;return t&&1!==t?ln(e.replace(/\.(.+)\./g,".$1")):e}function cn(e,t,n){let r=e[0];return n&&0==e.length?Array.isArray(n)?(n.push(t),n):[n,t]:Array.isArray(n)?(n.push(t),n):"string"==typeof n?[n,t]:n?(n[r]=cn(e.slice(1),t,n[r]),n):r?{[r]:cn(e.slice(1),t)}:""===r?[t]:t}function un(e){return Salla.config.get("store.url",window.location.href.split("/").slice(0,-1).join("/")).rtrim("/")+"/"+e.ltrim("/")}var dn={digitsOnly:function(e){return on(e,!0).replace(/[^0-9.]/g,"").replace("..",".").rtrim(".")},inputDigitsOnly:function e(t,n=!1){if("string"==typeof t)return document.querySelectorAll(t).forEach((t=>e(t,n)));if(!t)return void Salla.logger.warn("Can't find Object With Id: "+t);let r=Salla.helpers.digitsOnly(t.value);return t.min&&r<t.min?t.value=t.min:t.max&&r>t.max?t.value=t.max:t.maxLength>=1&&r.toString().length>t.maxLength?t.value=r.toString().substring(0,t.maxLength):t.value=n||t.dataset.hasOwnProperty("digitsWithDecimal")?ln(r):r.replace(/\D/g,"")},number:on,money:function(e){let t=Salla.config.currency(e?.currency).symbol;return on(e="object"==typeof e?e.amount:e)+" "+t},setNested:function(e,t,n){let r=e,i=t.split("."),a=i.length;for(let e=0;e<a-1;e++){let t=i[e];r[t]||(r[t]={}),r=r[t]}return r[i[a-1]]=n,e},getNested:function(e,t,n){let r=_t(e,t);return void 0!==r?r:n},inputData:function(e,t,n={}){if(e.includes("[")){let r=e.split("]").join("").split("[");return{name:r[0],value:cn(r.slice(1),t,n[r[0]])}}return{name:e,value:t}},url:{get:un,asset:function(e){return function(e){return window.location.origin+"/"+e.ltrim("/")}("themes/"+Salla.config.get("theme.name")+"/"+e.ltrim("/"))},cdn:function(e){return"https://cdn.salla.network/"+e.ltrim("/")},is_page:function(e){return e&&Salla.config.get("page.slug")===e},api:function(e){return Salla.config.get("store.api",un("")).rtrim("/")+"/"+e.ltrim("/")}},addParamToUrl:function(e,t){if(!t||!e)return window.location.href;let n=new RegExp("([?&])"+e+"=[^&]+[&]?","g"),r=window.location.href.replace(n,"$1").replace(/&$|\?$/,"");return r+=(r.includes("?")?"&":"?")+e+"="+encodeURIComponent(t),r.replace(/&$|\?$/,"")},debounce:function(e,t){t=t||100;let n,r=[];return function(...i){return clearTimeout(n),n=setTimeout((()=>{let t=e(...i);r.forEach((e=>e(t))),r=[]}),t),new Promise((e=>r.push(e)))}}},hn=function(e){let t={log:function(t,n){if(!e)return;if(!salla.config.isDebug())return;"trace"===salla.config.get("debug")&&(n="trace");let r=e.log,i=void 0===n?r:this.__dict__[n]||r,a=["%cTwilight","color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;"],s={event:"#CFF680",backend:"#7b68ee"}[n];s&&(a[0]+="%c"+n[0].toUpperCase()+n.substring(1),a.push(`margin-left: 5px;color: ${s};font-weight:bold; border:1px solid ${s}; padding: 2px 6px; border-radius: 5px;`)),i.call(e,...a.concat(...t))},__dict__:{trace:e.trace,debug:e.debug,info:e.info,warn:e.warn,error:e.error}};return{event:function(){t.log(arguments,"event")},trace:function(){t.log(arguments,"trace")},debug:function(){t.log(arguments,"debug")},info:function(){t.log(arguments,"info")},warn:function(){t.log(arguments,"warn")},error:function(){t.log(arguments,"error")},log:function(){t.log(arguments,void 0)},backend:function(){t.log(arguments,"backend")},logs:function(e){[e].flat().forEach((e=>e&&t.log([e].flat(),"backend")))}}}(console);const fn=$t.createStore([Gt,Qt,Yt,an],[]);void 0===a?(window.salla=window.salla||window.Salla||{},window.Salla=window.salla):(a.salla=a.salla||a.Salla||{},a.Salla=a.salla),Salla.status="base",Salla.config=new class{constructor(e={},t={}){this.default_properties=t,this.properties_={...this.default_properties,...e}}merge(e){return Object.assign(this.properties_,e),this.properties_.store={...this.default_properties.store,...this.properties_.store},this}set(e,t){return e.includes(".")?(Salla.helpers.setNested(this.properties_,e,t),this):(this.properties_[e]=t,this)}get(e,t=null){return e.includes(".")?Salla.helpers.getNested(this.properties_,e,t):this.properties_.hasOwnProperty(e)?this.properties_[e]||t:t||void 0}all(){return this.properties_}isDebug(){return this.get("debug")||Salla.storage.get("debug")}},Salla.logger=hn,Salla.event=new class extends Et{constructor(){super({wildcard:!0,delimiter:"::",newListener:!1,removeListener:!1,maxListeners:10,verboseMemoryLeak:!1,ignoreErrors:!1}),this.delimiter="::","undefined"!=typeof document&&(this.body=document.querySelector("body")),this.logableEvents=["cart::item.added.failed","cart::item.deleted.failed"],this.ingoreLogEvents=["document::click","document::keyup","document::change"],this.noneFireableActions=["document.request"]}createAndDispatch(e,...t){this.dispatch(e,...t)}emit(e,...t){let n=e.replace("::",".");if(!this.noneFireableActions.includes(n)&&void 0!==Salla.call&&"function"==typeof Salla.call(n))return Salla.log(`'Salla.${n}(...)' triggered using event '${e}'`),n=n.split("."),void salla[n[0]][n[1]](...t);if(super.emit(e,...t),"undefined"!=typeof window){window.dataLayer=window.dataLayer||[];let n={event:e};t.map((e=>{"object"==typeof e?n={...n,...e}:salla.log(`Skipped to add item (${e}) to the dataLayerObject, because it's not an object.`)})),window.dataLayer.push(n)}Salla.logger&&!this.ingoreLogEvents.includes(e)&&Salla.logger.event(e,...t),this.dispatchMobileEvent(e,{...t.values()})}dispatch(e,...t){return this.emit(e,...t)}dispatchEvents(e){if(e&&"object"==typeof e)for(const[t,n]of Object.entries(e))this.dispatch(t,n);else Salla.log("No Events To Dispatch!",e)}addListener(e,t){return this.on(e,t)}addEventListener(e,t){return this.on(e,t)}listen(e,t){return this.on(e,t)}registerGlobalListener(e,t){return this.onAny(t)}dispatchMobileEvent(e,t={}){if(!("undefined"!=typeof window&&window.dataLayer&&dataLayer[0]&&dataLayer[0].page&&dataLayer[0].page.mobileApp))return"";if(window.webkit)try{window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:e,details:t}))}catch(e){Salla.log(e,"The native context does not exist yet")}else if(Android)try{Android.customEventWithData(e,JSON.stringify({details:t}))}catch(e){Salla.log(e,"The native context does not exist yet")}}},Salla.storage=new class{constructor(){Salla.event.on("storage::item.remove",(e=>this.remove(e))),Salla.event.on("storage::item.set",((e,t)=>this.set(e,t))),this.store=fn}set(e,t){if(e.includes(".")){let n=e.split(".")[0],r={[n]:this.store.get(n)};return r=Salla.helpers.setNested(r,e,t),this.store.set(n,r[n])}return this.store.set(e,t)}remove(e){return this.store.remove(e)}clearAll(){return this.store.clearAll()}get(e,t){if(e.includes(".")){let t=e.split(".")[0];return Salla.helpers.getNested({[t]:this.store.get(t)},e)}return this.store.get(e,t)}},Salla.cookie=new class{constructor(){Salla.event.on("cookies::remove",(e=>this.remove(e))),Salla.event.on("cookies::add",((e,t)=>this.set(e,t)))}get(e){return document.cookie.split("; ").find((t=>t.startsWith(e+"=")))?.split("=")[1]}set(e,t="",n=10){let r="";if(n){let e=new Date;e.setTime(e.getTime()+24*n*60*60*1e3),r="; expires="+e.toUTCString()}return document.cookie=`${e}=${t}${r}"; path=/; secure; SameSite=Lax"`,this}remove(e){return document.cookie=`${e}=; Max-Age=0; path=/;`,this}clearAll(){let e=document.cookie.split(";");for(let t=0;t<e.length;t++){let n=e[t],r=n.indexOf("="),i=r>-1?n.substr(0,r):n;this.remove(i)}}},Salla.helpers=dn,Salla.log=Salla.logger.log,Salla.money=Salla.helpers.money,Salla.url=Salla.helpers.url,Salla.versions={base:"2.9.42"};var pn=Salla;let gn=function(e,t,n){return alert(e)},mn=function(e,t){return gn(e,vn.error,t)},vn={error:"error",success:"success",info:"info"};var yn={fire:function(e,t,n){return gn(e,t,n)},setNotifier:function(e){gn=e},error:mn,success:function(e,t){return gn(e,vn.success,t)},info:function(e,t){return gn(e,vn.info,t)},sallaInitiated:function(){let e=window.location.href.match(/([\?\&]danger=)[^&]+/g);e&&e.forEach((e=>{mn(decodeURI(e.replace("?danger=","").replace("&danger=","")))}))},types:vn};class bn{constructor(e,t){return this.api=e,this.event=t,new Proxy(this,{get:function(n,r){return"event"===r?t:"api"===r?e:e&&e[r]||n[r]}})}}String.prototype.toStudlyCase=function(){return this.trim().replace(/([^a-zA-Z\d].)/g,(function(e){return e.toUpperCase().replace(/[^a-zA-Z\d]/g,"")}))},String.prototype.toDatasetName=function(){return this.startsWith("data-")?this.substr(5).toStudlyCase():this.toStudlyCase()},String.prototype.toSelector=function(){return this.trim().startsWith(".")||this.trim().startsWith("#")?this:"#"+this},String.prototype.replaceArray=function(e,t){for(var n,r=this,i=0;i<e.length;i++)n=new RegExp(e[i],"g"),r=r.replace(n,t[i]);return r},String.prototype.rtrim=function(e){return void 0===e&&(e="\\s"),this.replace(new RegExp("["+e+"]*$"),"")},String.prototype.ltrim=function(e){return void 0===e&&(e="\\s"),this.replace(new RegExp("^["+e+"]*"),"")},String.prototype.digitsOnly=function(){return Salla.helpers.digitsOnly(this)},Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){for(var t=this;t;){if(t.matches(e))return t;t=t.parentElement}}),Element.prototype.getElementSallaData=function(e,...t){if(!this.getAttribute)return;if(this.hasAttribute("data-json"))try{return JSON.parse(this.getAttribute("data-json"))}catch(e){}let n=this.getAttribute("data-function");if(n&&window[n])return"function"==typeof window[n]?this.getFilteredData(window[n].call(this,...t)):this.getFilteredData(window[n]);let r=this.hasAttribute("data-form-selector")?document.querySelector(this.dataset.formSelector):void 0;if(r="FORM"===this.tagName?this:r||this.closest("form")||this.closest("[salla-form-data]")||this,r&&"FORM"===r.tagName)return this.getFilteredData(new FormData(r),null,r);let i=r.querySelectorAll("[name]");if(!i.length)return this.getFilteredData();let a=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,a);a[t.name]=t.value}catch(t){Salla.log(e.name+" can't be send")}})),this.getFilteredData(a)},Element.prototype.canEventFireHook=function(e){return!!this.hasAttribute&&this.hasAttribute(Salla.api.hooksPrefix+e.type)},Element.prototype.hasAttributeStartsWith=function(e,t){e=e.toLowerCase();for(var n=0;n<this.attributes.length;n++){let r=this.attributes[n].name.toLowerCase();if(0===r.indexOf(e))return!t||r}return!1},HTMLFormElement.prototype.getAjaxFormData=function(e){var t=this.querySelectorAll('input[type="file"]');t.forEach((e=>{e.files.length||e.setAttribute("disabled","")}));var n=new FormData(this);return t.forEach((e=>{e.files.length||e.removeAttribute("disabled")})),{formData:this.getFilteredData(n,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,n=null){return e=e||n?.dataset||this.dataset,n&&this.name&&void 0!==this.value&&(e=function(e,t,n){e instanceof FormData?e.append(t,n):e[t]=n;return e}(e,this.name,this.value)),["filterBeforeSubmit","filterBeforeSend"].forEach((r=>{let i=n?.dataset[r]||this.dataset[r];if(i){var a=window[i];if("function"==typeof a){if(!a(e,n||this,t)&&e)throw`Data failed to be pass verify function window.${i}(formData, element, event)!`;return a(e,n||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 wn{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(...n){return t.dispatch(e,...n)}}createDynamicListenerFuns(e){let t="on"+e.charAt(0).toUpperCase()+e.slice(1);if(this[t])return;let n=this;this[t]=function(t){return n.on(e,t)}}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.dispatch(this.getEventName(e),...t)}on(e,t){return Salla.event.addListener(this.getEventName(e),t)}once(e,t){return Salla.event.once(this.getEventName(e),t)}}function _n(e){e&&e.sallaInitiated&&!e.initiated&&(e.sallaInitiated(),e.initiated=!0)}Salla.event.auth=new class extends wn{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"},this.after_init()}login(e){return e?(e.type&&this.setTypeActionOnVerified(e.type),this.next_event=e.next_event||null,this.dispatch("login",...arguments)):(this.next_event=null,this.dispatch("login",...arguments))}loggedIn(e){Salla.profile.info().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 wn{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",couponAdded:"coupon.added",couponDeleted:"coupon.deleted",couponAdditionFailed:"coupon.addition.failed",couponDeletionFailed:"coupon.deletion.failed"},this.after_init()}updated(e){return Salla.cookie.set("fresh_summary",1),e&&"object"==typeof e?(e.offer&&salla.product.event.offerExisted(e.offer),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 wn{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"},this.after_init()}},Salla.event.scope=new class extends wn{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 wn{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.comment=new class extends wn{constructor(){super(),this.namespace="comment",this.events={added:"added",additionFailed:"addition.failed"},this.after_init()}},Salla.event.loyalty=new class extends wn{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()}},Salla.event.product=new class extends wn{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",addGiftToCartSucceeded:"gift.add-to-cart.succeeded",addGiftToCartFailed:"gift.add-to-cart.failed",giftImageUploadSucceeded:"gift.image-upload.succeeded",giftImageUploadFailed:"gift.image-upload.failed"},this.after_init()}},Salla.event.profile=new class extends wn{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 wn{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 wn{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,n){this.on(e,(e=>{"function"!=typeof t?"function"==typeof n&&e.target.matches(t)&&n(e):t(e)}))}fireEvent(e,t,...n){return this.fireEventForElements(e,t,!1,...n)}fireEventForAll(e,t,...n){return this.fireEventForElements(e,t,!0,...n)}fireEventForElements(e,t,n,...r){if("string"==typeof e){if(n)return document.querySelectorAll(e).forEach((e=>this.fireEventForElements(e,t,!1,...r)));e=document.querySelector(e)}if(!e)return void salla.log("Failed To get element to fire event: "+t);const i=new CustomEvent(t,...r);return e.dispatchEvent(i)}},Salla.event.wishlist=new class extends wn{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 wn{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.booking=new class extends wn{constructor(){super(),this.namespace="booking",this.events={added:"added",additionFailed:"addition.failed"},this.after_init()}},Salla.event.on("twilight::initiated",(()=>{Object.keys(Salla).forEach((e=>{"object"==typeof(e=Salla[e])&&(_n(e),Object.keys(e).forEach((t=>{_n(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((n=>{e&&(t=[],e=!1),n.code=n.code||n.iso_code,n.url=salla.url.get(n.code),n.is_rtl=n.is_rtl||n.rtl,t.push(n)})),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((n=>{e&&(t={},e=!1),n.country_code=n.code.substr(0,2).toLowerCase(),t[n.code]=n})),Salla.config.set("currencies",t),t},Salla.config.currency=e=>(e=e||Salla.config.get("user.currency_code"),Salla.config.get("currencies."+e)||Object.values(Salla.config.get("currencies"))[0]);var Sn,En={exports:{}},xn={exports:{}},An={exports:{}};function Pn(){return Sn||(Sn=1,function(e){!function(t,n){e.exports?e.exports=n():t.EvEmitter=n()}("undefined"!=typeof window?window:s,(function(){function e(){}let t=e.prototype;return t.on=function(e,t){if(!e||!t)return this;let n=this._events=this._events||{},r=n[e]=n[e]||[];return r.includes(t)||r.push(t),this},t.once=function(e,t){if(!e||!t)return this;this.on(e,t);let n=this._onceEvents=this._onceEvents||{};return(n[e]=n[e]||{})[t]=!0,this},t.off=function(e,t){let n=this._events&&this._events[e];if(!n||!n.length)return this;let r=n.indexOf(t);return-1!=r&&n.splice(r,1),this},t.emitEvent=function(e,t){let n=this._events&&this._events[e];if(!n||!n.length)return this;n=n.slice(0),t=t||[];let r=this._onceEvents&&this._onceEvents[e];for(let i of n){r&&r[i]&&(this.off(e,i),delete r[i]),i.apply(this,t)}return this},t.allOff=function(){return delete this._events,delete this._onceEvents,this},e}))}(An)),An.exports}var Fn,Ln,kn={exports:{}};function On(){return Fn||(Fn=1,function(e){!function(t,n){e.exports?e.exports=n(t):t.fizzyUIUtils=n(t)}(s,(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 n=e.indexOf(t);-1!=n&&e.splice(n,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,n){return(e=t.makeArray(e)).filter((e=>e instanceof HTMLElement)).reduce(((e,t)=>{if(!n)return e.push(t),e;t.matches(n)&&e.push(t);let r=t.querySelectorAll(n);return e=e.concat(...r)}),[])},debounceMethod:function(e,t,n){n=n||100;let r=e.prototype[t],i=t+"Timeout";e.prototype[t]=function(){clearTimeout(this[i]);let e=arguments;this[i]=setTimeout((()=>{r.apply(this,e),delete this[i]}),n)}},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,n){return t+"-"+n})).toLowerCase()}},n=e.console;return t.htmlInit=function(r,i){t.docReady((function(){let a="data-"+t.toDashed(i),s=document.querySelectorAll(`[${a}]`),o=e.jQuery;[...s].forEach((e=>{let t,s=e.getAttribute(a);try{t=s&&JSON.parse(s)}catch(t){return void(n&&n.error(`Error parsing ${a} on ${e.className}: ${t}`))}let l=new r(e,t);o&&o.data(e,i,l)}))}))},t}))}(kn)),kn.exports}function Tn(){return Ln||(Ln=1,function(e){!function(t,n){e.exports?e.exports=n(t,Pn(),On()):t.InfiniteScroll=n(t,t.EvEmitter,t.fizzyUIUtils)}(window,(function(e,t,n){let r=e.jQuery,i={};function a(e,t){let s=n.getQueryElement(e);if(s){if((e=s).infiniteScrollGUID){let n=i[e.infiniteScrollGUID];return n.option(t),n}this.element=e,this.options={...a.defaults},this.option(t),r&&(this.$element=r(this.element)),this.create()}else console.error("Bad element for InfiniteScroll: "+(s||e))}a.defaults={},a.create={},a.destroy={};let s=a.prototype;Object.assign(s,t.prototype);let o=0;s.create=function(){let e=this.guid=++o;if(this.element.infiniteScrollGUID=e,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 a.create)a.create[e].call(this)}else console.error("Disabling InfiniteScroll")},s.option=function(e){Object.assign(this.options,e)},s.callOnInit=function(){let e=this.options.onInit;e&&e.call(this,this)},s.dispatchEvent=function(e,t,n){this.log(e,n);let i=t?[t].concat(n):n;if(this.emitEvent(e,i),!r||!this.$element)return;let a=e+=".infiniteScroll";if(t){let n=r.Event(t);n.type=e,a=n}this.$element.trigger(a,n)};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,n)=>`${n.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 n=`[InfiniteScroll] ${e}`,r=l[e];r&&(n+=". "+r.apply(this,t)),console.log(n)},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:n.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?)"),n=new RegExp(t),r=location.href.match(n);r&&(this.pageIndex=parseInt(r[1],10),this.log("pageIndex",[this.pageIndex,"template string"]))};let c=[/^(.*?\/?page\/?)(\d\d?\d?)(.*?$)/,/^(.*?\/?\?page=)(\d\d?\d?)(.*?$)/,/(.*?)(\d\d?\d?)(?!.*\d)(.*?$)/],u=a.getPathParts=function(e){if(e)for(let t of c){let n=e.match(t);if(n){let[,e,t,r]=n;return{begin:e,index:t,end:r}}}};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 n=t.getAttribute("href"),r=u(n);if(!r)return void console.error(`InfiniteScroll unable to parse next link href: ${n}`);let{begin:i,index:a,end:s}=r;this.isPathSelector=!0,this.getPath=()=>i+(this.pageIndex+1)+s,this.pageIndex=parseInt(a,10)-1,this.log("pageIndex",[this.pageIndex,"next link"])},s.updateGetAbsolutePath=function(){let e=this.getPath();if(e.match(/^http/)||e.match(/^\//))return void(this.getAbsolutePath=this.getPath);let{pathname:t}=location,n=e.match(/^\?/),r=t.substring(0,t.lastIndexOf("/")),i=n?t:r+"/";this.getAbsolutePath=()=>i+this.getPath()},a.create.hideNav=function(){let e=n.getQueryElement(this.options.hideNav);e&&(e.style.display="none",this.nav=e)},a.destroy.hideNav=function(){this.nav&&(this.nav.style.display="")},s.destroy=function(){this.allOff();for(let e in a.destroy)a.destroy[e].call(this);delete this.element.infiniteScrollGUID,delete i[this.guid],r&&this.$element&&r.removeData(this.element,"infiniteScroll")},a.throttle=function(e,t){let n,r;return t=t||200,function(){let i=+new Date,a=arguments,s=()=>{n=i,e.apply(this,a)};n&&i<n+t?(clearTimeout(r),r=setTimeout(s,t)):s()}},a.data=function(e){let t=(e=n.getQueryElement(e))&&e.infiniteScrollGUID;return t&&i[t]},a.setJQuery=function(e){r=e},n.htmlInit(a,"infinite-scroll"),s._init=function(){};let{jQueryBridget:d}=e;return r&&d&&d("infiniteScroll",a,r),a}))}(xn)),xn.exports}var jn,Cn={exports:{}};function Rn(){return jn||(jn=1,function(e){!function(t,n){e.exports?e.exports=n(t,Tn()):n(t,t.InfiniteScroll)}(window,(function(e,t){let n=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)},n.onScrollThresholdLoad=function(){this.options.loadOnScroll&&this.loadNextPage()};let r=new DOMParser;function i(e){let t=document.createDocumentFragment();return e&&t.append(...e),t}return n.loadNextPage=function(){if(this.isLoading||!this.canLoad)return;let{responseBody:e,domParseResponse:t,fetchOptions:n}=this.options,i=this.getAbsolutePath();this.isLoading=!0,"function"==typeof n&&(n=n());let a=fetch(i,n).then((n=>{if(!n.ok){let e=new Error(n.statusText);return this.onPageError(e,i,n),{response:n}}return n[e]().then((a=>("text"==e&&t&&(a=r.parseFromString(a,"text/html")),204==n.status?(this.lastPageReached(a,i),{body:a,response:n}):this.onPageLoad(a,i,n))))})).catch((e=>{this.onPageError(e,i)}));return this.dispatchEvent("request",null,[i,a]),a},n.onPageLoad=function(e,t,n){return this.options.append||(this.isLoading=!1),this.pageIndex++,this.loadCount++,this.dispatchEvent("load",null,[e,t,n]),this.appendNextPage(e,t,n)},n.appendNextPage=function(e,t,n){let{append:r,responseBody:a,domParseResponse:s}=this.options;if(!("text"==a&&s)||!r)return{body:e,response:n};let o=e.querySelectorAll(r),l={body:e,response:n,items:o};if(!o||!o.length)return this.lastPageReached(e,t),l;let c=i(o),u=()=>(this.appendItems(o,c),this.isLoading=!1,this.dispatchEvent("append",null,[e,t,o,n]),l);return this.options.outlayer?this.appendOutlayerItems(c,u):u()},n.appendItems=function(e,t){e&&e.length&&(function(e){let t=e.querySelectorAll("script");for(let e of t){let t=document.createElement("script"),n=e.attributes;for(let e of n)t.setAttribute(e.name,e.value);t.innerHTML=e.innerHTML,e.parentNode.replaceChild(t,e)}}(t=t||i(e)),this.element.appendChild(t))},n.appendOutlayerItems=function(n,r){let i=t.imagesLoaded||e.imagesLoaded;return i?new Promise((function(e){i(n,(function(){let t=r();e(t)}))})):(console.error("[InfiniteScroll] imagesLoaded required for outlayer option"),void(this.isLoading=!1))},n.onAppendOutlayer=function(e,t,n){this.options.outlayer.appended(n)},n.checkLastPage=function(e,t){let n,{checkLastPage:r,path:i}=this.options;if(r){if("function"==typeof i){if(!this.getPath())return void this.lastPageReached(e,t)}"string"==typeof r?n=r:this.isPathSelector&&(n=i),n&&e.querySelector&&(e.querySelector(n)||this.lastPageReached(e,t))}},n.lastPageReached=function(e,t){this.canLoad=!1,this.dispatchEvent("last",null,[e,t])},n.onPageError=function(e,t,n){return this.isLoading=!1,this.canLoad=!1,this.dispatchEvent("error",null,[e,t,n]),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}`)},n.prefill=function(){let e=this.getPrefillDistance();this.isPrefilling=e>=0,this.isPrefilling?(this.log("prefill"),this.loadNextPage()):this.stopPrefill()},n.getPrefillDistance=function(){return this.options.elementScroll?this.scroller.clientHeight-this.scroller.scrollHeight:this.windowHeight-this.element.clientHeight},n.stopPrefill=function(){this.log("stopPrefill"),this.off("append",this.prefill)},t}))}(Cn)),Cn.exports}var In,qn={exports:{}};function Nn(){return In||(In=1,function(e){!function(t,n){e.exports?e.exports=n(t,Tn(),On()):n(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,n){let r=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()},r.enableScrollWatch=function(){this.isScrollWatching||(this.isScrollWatching=!0,this.updateMeasurements(),this.updateScroller(),this.on("last",this.disableScrollWatch),this.bindScrollWatchEvents(!0))},r.disableScrollWatch=function(){this.isScrollWatching&&(this.bindScrollWatchEvents(!1),delete this.isScrollWatching)},r.bindScrollWatchEvents=function(t){let n=t?"addEventListener":"removeEventListener";this.scroller[n]("scroll",this.pageScrollHandler),e[n]("resize",this.resizeHandler)},r.onPageScroll=t.throttle((function(){this.getBottomDistance()<=this.options.scrollThreshold&&this.dispatchEvent("scrollThreshold")})),r.getBottomDistance=function(){let t,n;return this.options.elementScroll?(t=this.scroller.scrollHeight,n=this.scroller.scrollTop+this.scroller.clientHeight):(t=this.top+this.element.clientHeight,n=e.scrollY+this.windowHeight),t-n},r.onResize=function(){this.updateMeasurements()},n.debounceMethod(t,"onResize",150),t}))}(qn)),qn.exports}var Dn,Un={exports:{}};function Hn(){return Dn||(Dn=1,function(e){!function(t,n){e.exports?e.exports=n(t,Tn(),On()):n(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,n){let r=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.`)},r.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)},r.bindHistoryAppendEvents=function(t){let n=t?"addEventListener":"removeEventListener";this.scroller[n]("scroll",this.scrollHistoryHandler),e[n]("unload",this.unloadHandler)},r.createHistoryPageLoad=function(){this.on("load",this.onPageLoadHistory)},t.destroy.history=r.destroyHistory=function(){this.options.history&&this.options.append&&this.bindHistoryAppendEvents(!1)},r.onAppendHistory=function(e,t,n){if(!n||!n.length)return;let r=n[0],a=this.getElementScrollY(r);i.href=t,this.scrollPages.push({top:a,path:i.href,title:e.title})},r.getElementScrollY=function(t){if(this.options.elementScroll)return t.offsetTop-this.top;return t.getBoundingClientRect().top+e.scrollY},r.onScrollHistory=function(){let e=this.getClosestScrollPage();e!=this.scrollPage&&(this.scrollPage=e,this.setHistory(e.title,e.path))},n.debounceMethod(t,"onScrollHistory",150),r.getClosestScrollPage=function(){let t,n;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;n=e}return n},r.setHistory=function(e,t){let n=this.options.history;n&&history[n+"State"]&&(history[n+"State"](null,e,t),this.options.historyTitle&&(document.title=e),this.dispatchEvent("history",null,[e,t]))},r.onUnload=function(){if(0===this.scrollPage.top)return;let t=e.scrollY-this.scrollPage.top+this.top;this.destroyHistory(),scrollTo(0,t)},r.onPageLoadHistory=function(e,t){this.setHistory(e.title,t)},t}))}(Un)),Un.exports}var $n,Mn={exports:{}};function zn(){return $n||($n=1,function(e){!function(t,n){e.exports?e.exports=n(t,Tn(),On()):n(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,n){class r{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=n.getQueryElement(this.options.button);e&&(this.button=new r(e,this))},t.destroy.button=function(){this.button&&this.button.destroy()},t.Button=r,t}))}(Mn)),Mn.exports}var Bn,Gn={exports:{}};function Vn(){return Bn||(Bn=1,function(e){!function(t,n){e.exports?e.exports=n(t,Tn(),On()):n(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,n){let r=t.prototype;function i(e){s(e,"none")}function a(e){s(e,"block")}function s(e,t){e&&(e.style.display=t)}return t.create.status=function(){let e=n.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"))},r.bindHideStatus=function(e){let t=this.options.append?"append":"load";this[e](t,this.hideAllStatus)},r.showRequestStatus=function(){this.showStatus("request")},r.showErrorStatus=function(){this.showStatus("error")},r.showLastStatus=function(){this.showStatus("last"),this.bindHideStatus("off")},r.showStatus=function(e){a(this.statusElement),this.hideStatusEventElements(),a(this.statusEventElements[e])},r.hideAllStatus=function(){i(this.statusElement),this.hideStatusEventElements()},r.hideStatusEventElements=function(){for(let e in this.statusEventElements){i(this.statusEventElements[e])}},t}))}(Gn)),Gn.exports}
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("process"),require("buffer")):"function"==typeof define&&define.amd?define(["exports","process","buffer"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Salla={},e.process$1,e.buffer)}(this,(function(e,t,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=r(t),a="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},o=Array.isArray,l="object"==typeof s&&s&&s.Object===Object&&s,c="object"==typeof self&&self&&self.Object===Object&&self,u=l||c||Function("return this")(),d=u.Symbol,h=d,f=Object.prototype,p=f.hasOwnProperty,g=f.toString,m=h?h.toStringTag:void 0;var v=function(e){var t=p.call(e,m),n=e[m];try{e[m]=void 0;var r=!0}catch(e){}var i=g.call(e);return r&&(t?e[m]=n:delete e[m]),i},y=Object.prototype.toString;var b=v,w=function(e){return y.call(e)},_=d?d.toStringTag:void 0;var S=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":_&&_ in Object(e)?b(e):w(e)};var E=S,x=function(e){return null!=e&&"object"==typeof e};var A=function(e){return"symbol"==typeof e||x(e)&&"[object Symbol]"==E(e)},k=o,F=A,P=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,L=/^\w*$/;var O=function(e,t){if(k(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!F(e))||(L.test(e)||!P.test(e)||null!=t&&e in Object(t))};var T=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},C=S,j=T;var R,q=function(e){if(!j(e))return!1;var t=C(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},I=u["__core-js_shared__"],N=(R=/[^.]+$/.exec(I&&I.keys&&I.keys.IE_PROTO||""))?"Symbol(src)_1."+R:"";var D=function(e){return!!N&&N in e},U=Function.prototype.toString;var H=q,$=D,M=T,z=function(e){if(null!=e){try{return U.call(e)}catch(e){}try{return e+""}catch(e){}}return""},B=/^\[object .+?Constructor\]$/,G=Function.prototype,V=Object.prototype,W=G.toString,Q=V.hasOwnProperty,J=RegExp("^"+W.call(Q).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var K=function(e){return!(!M(e)||$(e))&&(H(e)?J:B).test(z(e))},Z=function(e,t){return null==e?void 0:e[t]};var X=function(e,t){var n=Z(e,t);return K(n)?n:void 0},Y=X(Object,"create"),ee=Y;var te=function(){this.__data__=ee?ee(null):{},this.size=0};var ne=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},re=Y,ie=Object.prototype.hasOwnProperty;var ae=function(e){var t=this.__data__;if(re){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return ie.call(t,e)?t[e]:void 0},se=Y,oe=Object.prototype.hasOwnProperty;var le=function(e){var t=this.__data__;return se?void 0!==t[e]:oe.call(t,e)},ce=Y;var ue=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=ce&&void 0===t?"__lodash_hash_undefined__":t,this},de=te,he=ne,fe=ae,pe=le,ge=ue;function me(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}me.prototype.clear=de,me.prototype.delete=he,me.prototype.get=fe,me.prototype.has=pe,me.prototype.set=ge;var ve=me;var ye=function(){this.__data__=[],this.size=0};var be=function(e,t){return e===t||e!=e&&t!=t};var we=function(e,t){for(var n=e.length;n--;)if(be(e[n][0],t))return n;return-1},_e=we,Se=Array.prototype.splice;var Ee=function(e){var t=this.__data__,n=_e(t,e);return!(n<0)&&(n==t.length-1?t.pop():Se.call(t,n,1),--this.size,!0)},xe=we;var Ae=function(e){var t=this.__data__,n=xe(t,e);return n<0?void 0:t[n][1]},ke=we;var Fe=we;var Pe=function(e,t){var n=this.__data__,r=Fe(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},Le=ye,Oe=Ee,Te=Ae,Ce=function(e){return ke(this.__data__,e)>-1},je=Pe;function Re(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Re.prototype.clear=Le,Re.prototype.delete=Oe,Re.prototype.get=Te,Re.prototype.has=Ce,Re.prototype.set=je;var qe=Re,Ie=X(u,"Map"),Ne=ve,De=qe,Ue=Ie;var He=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};var $e=function(e,t){var n=e.__data__;return He(t)?n["string"==typeof t?"string":"hash"]:n.map},Me=$e;var ze=$e;var Be=$e;var Ge=$e;var Ve=function(e,t){var n=Ge(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},We=function(){this.size=0,this.__data__={hash:new Ne,map:new(Ue||De),string:new Ne}},Qe=function(e){var t=Me(this,e).delete(e);return this.size-=t?1:0,t},Je=function(e){return ze(this,e).get(e)},Ke=function(e){return Be(this,e).has(e)},Ze=Ve;function Xe(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Xe.prototype.clear=We,Xe.prototype.delete=Qe,Xe.prototype.get=Je,Xe.prototype.has=Ke,Xe.prototype.set=Ze;var Ye=Xe;function et(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var s=e.apply(this,r);return n.cache=a.set(i,s)||a,s};return n.cache=new(et.Cache||Ye),n}et.Cache=Ye;var tt=et;var nt=function(e){var t=tt(e,(function(e){return 500===n.size&&n.clear(),e})),n=t.cache;return t},rt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,it=/\\(\\)?/g,at=nt((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(rt,(function(e,n,r,i){t.push(r?i.replace(it,"$1"):n||e)})),t}));var st=function(e,t){for(var n=-1,r=null==e?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i},ot=o,lt=A,ct=d?d.prototype:void 0,ut=ct?ct.toString:void 0;var dt=function e(t){if("string"==typeof t)return t;if(ot(t))return st(t,e)+"";if(lt(t))return ut?ut.call(t):"";var n=t+"";return"0"==n&&1/t==-Infinity?"-0":n},ht=dt;var ft=o,pt=O,gt=at,mt=function(e){return null==e?"":ht(e)};var vt=A;var yt=function(e,t){return ft(e)?e:pt(e,t)?[e]:gt(mt(e))},bt=function(e){if("string"==typeof e||vt(e))return e;var t=e+"";return"0"==t&&1/e==-Infinity?"-0":t};var wt=function(e,t){for(var n=0,r=(t=yt(t,e)).length;null!=e&&n<r;)e=e[bt(t[n++])];return n&&n==r?e:void 0};var _t=function(e,t,n){var r=null==e?void 0:wt(e,t);return void 0===r?n:r},St={exports:{}};!function(e,t){!function(t){var n=Object.hasOwnProperty,r=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},a="object"==typeof i.default&&"function"==typeof i.default.nextTick,s="function"==typeof Symbol,o="object"==typeof Reflect,l="function"==typeof setImmediate?setImmediate:setTimeout,c=s?o&&"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 u(){this._events={},this._conf&&d.call(this,this._conf)}function d(e){e&&(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),e.maxListeners!==t&&(this._maxListeners=e.maxListeners),e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),e.ignoreErrors&&(this.ignoreErrors=e.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function h(e,t){var n="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(n+=" Event name: "+t+"."),void 0!==i.default&&i.default.emitWarning){var r=new Error(n);r.name="MaxListenersExceededWarning",r.emitter=this,r.count=e,i.default.emitWarning(r)}else console.error(n),console.trace&&console.trace()}var f=function(e,t,n){var r=arguments.length;switch(r){case 0:return[];case 1:return[e];case 2:return[e,t];case 3:return[e,t,n];default:for(var i=new Array(r);r--;)i[r]=arguments[r];return i}};function p(e,n){for(var r={},i=e.length,a=n?n.length:0,s=0;s<i;s++)r[e[s]]=s<a?n[s]:t;return r}function g(e,t,n){var r,i;if(this._emitter=e,this._target=t,this._listeners={},this._listenersCount=0,(n.on||n.off)&&(r=n.on,i=n.off),t.addEventListener?(r=t.addEventListener,i=t.removeEventListener):t.addListener?(r=t.addListener,i=t.removeListener):t.on&&(r=t.on,i=t.off),!r&&!i)throw Error("target does not implement any known event API");if("function"!=typeof r)throw TypeError("on method must be a function");if("function"!=typeof i)throw TypeError("off method must be a function");this._on=r,this._off=i;var a=e._observers;a?a.push(this):e._observers=[this]}function m(e,r,i,a){var s=Object.assign({},r);if(!e)return s;if("object"!=typeof e)throw TypeError("options must be an object");var o,l,c,u=Object.keys(e),d=u.length;function h(e){throw Error('Invalid "'+o+'" option value'+(e?". Reason: "+e:""))}for(var f=0;f<d;f++){if(o=u[f],!a&&!n.call(r,o))throw Error('Unknown "'+o+'" option');(l=e[o])!==t&&(c=i[o],s[o]=c?c(l,h):l)}return s}function v(e,t){return"function"==typeof e&&e.hasOwnProperty("prototype")||t("value must be a constructor"),e}function y(e){var t="value must be type of "+e.join("|"),n=e.length,r=e[0],i=e[1];return 1===n?function(e,n){if(typeof e===r)return e;n(t)}:2===n?function(e,n){var a=typeof e;if(a===r||a===i)return e;n(t)}:function(r,i){for(var a=typeof r,s=n;s-- >0;)if(a===e[s])return r;i(t)}}Object.assign(g.prototype,{subscribe:function(e,t,n){var r=this,i=this._target,a=this._emitter,s=this._listeners,o=function(){var r=f.apply(null,arguments),s={data:r,name:t,original:e};if(n){var o=n.call(i,s);!1!==o&&a.emit.apply(a,[s.name].concat(r))}else a.emit.apply(a,[t].concat(r))};if(s[e])throw Error("Event '"+e+"' is already listening");this._listenersCount++,a._newListener&&a._removeListener&&!r._onNewListener?(this._onNewListener=function(n){n===t&&null===s[e]&&(s[e]=o,r._on.call(i,e,o))},a.on("newListener",this._onNewListener),this._onRemoveListener=function(n){n===t&&!a.hasListeners(n)&&s[e]&&(s[e]=null,r._off.call(i,e,o))},s[e]=null,a.on("removeListener",this._onRemoveListener)):(s[e]=o,r._on.call(i,e,o))},unsubscribe:function(e){var t,n,r,i=this,a=this._listeners,s=this._emitter,o=this._off,l=this._target;if(e&&"string"!=typeof e)throw TypeError("event must be a string");function u(){i._onNewListener&&(s.off("newListener",i._onNewListener),s.off("removeListener",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var e=S.call(s,i);s._observers.splice(e,1)}if(e){if(!(t=a[e]))return;o.call(l,e,t),delete a[e],--this._listenersCount||u()}else{for(r=(n=c(a)).length;r-- >0;)e=n[r],o.call(l,e,a[e]);this._listeners={},this._listenersCount=0,u()}}});var b=y(["function"]),w=y(["object","function"]);function _(e,t,n){var r,i,a,s=0,o=new e((function(l,c,u){function d(){i&&(i=null),s&&(clearTimeout(s),s=0)}n=m(n,{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}}),r=!n.overload&&"function"==typeof e.prototype.cancel&&"function"==typeof u;var h=function(e){d(),l(e)},f=function(e){d(),c(e)};r?t(h,f,u):(i=[function(e){f(e||Error("canceled"))}],t(h,f,(function(e){if(a)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof e)throw TypeError("onCancel callback must be a function");i.push(e)})),a=!0),n.timeout>0&&(s=setTimeout((function(){var e=Error("timeout");e.code="ETIMEDOUT",s=0,o.cancel(e),c(e)}),n.timeout))}));return r||(o.cancel=function(e){if(i){for(var t=i.length,n=1;n<t;n++)i[n](e);i[0](e),i=null}}),o}function S(e){var t=this._observers;if(!t)return-1;for(var n=t.length,r=0;r<n;r++)if(t[r]._target===e)return r;return-1}function E(e,t,n,r,i){if(!n)return null;if(0===r){var a=typeof t;if("string"===a){var s,o,l=0,u=0,d=this.delimiter,h=d.length;if(-1!==(o=t.indexOf(d))){s=new Array(5);do{s[l++]=t.slice(u,o),u=o+h}while(-1!==(o=t.indexOf(d,u)));s[l++]=t.slice(u),t=s,i=l}else t=[t],i=1}else"object"===a?i=t.length:(t=[t],i=1)}var f,p,g,m,v,y,b,w=null,_=t[r],S=t[r+1];if(r===i)n._listeners&&("function"==typeof n._listeners?(e&&e.push(n._listeners),w=[n]):(e&&e.push.apply(e,n._listeners),w=[n]));else{if("*"===_){for(o=(y=c(n)).length;o-- >0;)"_listeners"!==(f=y[o])&&(b=E(e,t,n[f],r+1,i))&&(w?w.push.apply(w,b):w=b);return w}if("**"===_){for((v=r+1===i||r+2===i&&"*"===S)&&n._listeners&&(w=E(e,t,n,i,i)),o=(y=c(n)).length;o-- >0;)"_listeners"!==(f=y[o])&&("*"===f||"**"===f?(n[f]._listeners&&!v&&(b=E(e,t,n[f],i,i))&&(w?w.push.apply(w,b):w=b),b=E(e,t,n[f],r,i)):b=E(e,t,n[f],f===S?r+2:r,i),b&&(w?w.push.apply(w,b):w=b));return w}n[_]&&(w=E(e,t,n[_],r+1,i))}if((p=n["*"])&&E(e,t,p,r+1,i),g=n["**"])if(r<i)for(g._listeners&&E(e,t,g,i,i),o=(y=c(g)).length;o-- >0;)"_listeners"!==(f=y[o])&&(f===S?E(e,t,g[f],r+2,i):f===_?E(e,t,g[f],r+1,i):((m={})[f]=g[f],E(e,t,{"**":m},r+1,i)));else g._listeners?E(e,t,g,i,i):g["*"]&&g["*"]._listeners&&E(e,t,g["*"],i,i);return w}function x(e,t,n){var r,i,a=0,s=0,o=this.delimiter,l=o.length;if("string"==typeof e)if(-1!==(r=e.indexOf(o))){i=new Array(5);do{i[a++]=e.slice(s,r),s=r+l}while(-1!==(r=e.indexOf(o,s)));i[a++]=e.slice(s)}else i=[e],a=1;else i=e,a=e.length;if(a>1)for(r=0;r+1<a;r++)if("**"===i[r]&&"**"===i[r+1])return;var c,u=this.listenerTree;for(r=0;r<a;r++)if(u=u[c=i[r]]||(u[c]={}),r===a-1)return u._listeners?("function"==typeof u._listeners&&(u._listeners=[u._listeners]),n?u._listeners.unshift(t):u._listeners.push(t),!u._listeners.warned&&this._maxListeners>0&&u._listeners.length>this._maxListeners&&(u._listeners.warned=!0,h.call(this,u._listeners.length,c))):u._listeners=t,!0;return!0}function A(e,t,n,r){for(var i,a,s,o,l=c(e),u=l.length,d=e._listeners;u-- >0;)i=e[a=l[u]],s="_listeners"===a?n:n?n.concat(a):[a],o=r||"symbol"==typeof a,d&&t.push(o?s:s.join(this.delimiter)),"object"==typeof i&&A.call(this,i,t,s,o);return t}function k(e){for(var t,n,r,i=c(e),a=i.length;a-- >0;)(t=e[n=i[a]])&&(r=!0,"_listeners"===n||k(t)||delete e[n]);return r}function F(e,t,n){this.emitter=e,this.event=t,this.listener=n}function P(e,n,r){if(!0===r)o=!0;else if(!1===r)s=!0;else{if(!r||"object"!=typeof r)throw TypeError("options should be an object or true");var s=r.async,o=r.promisify,c=r.nextTick,u=r.objectify}if(s||c||o){var d=n,h=n._origin||n;if(c&&!a)throw Error("process.nextTick is not supported");o===t&&(o="AsyncFunction"===n.constructor.name),n=function(){var e=arguments,t=this,n=this.event;return o?c?Promise.resolve():new Promise((function(e){l(e)})).then((function(){return t.event=n,d.apply(t,e)})):(c?i.default.nextTick:l)((function(){t.event=n,d.apply(t,e)}))},n._async=!0,n._origin=h}return[n,u?new F(this,e,n):this]}function L(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,d.call(this,e)}F.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},L.EventEmitter2=L,L.prototype.listenTo=function(e,n,i){if("object"!=typeof e)throw TypeError("target musts be an object");var a=this;function s(t){if("object"!=typeof t)throw TypeError("events must be an object");var n,r=i.reducers,s=S.call(a,e);n=-1===s?new g(a,e,i):a._observers[s];for(var o,l=c(t),u=l.length,d="function"==typeof r,h=0;h<u;h++)o=l[h],n.subscribe(o,t[o]||o,d?r:r&&r[o])}return i=m(i,{on:t,off:t,reducers:t},{on:b,off:b,reducers:w}),r(n)?s(p(n)):s("string"==typeof n?p(n.split(/\s+/)):n),this},L.prototype.stopListeningTo=function(e,t){var n=this._observers;if(!n)return!1;var r,i=n.length,a=!1;if(e&&"object"!=typeof e)throw TypeError("target should be an object");for(;i-- >0;)r=n[i],e&&r._target!==e||(r.unsubscribe(t),a=!0);return a},L.prototype.delimiter=".",L.prototype.setMaxListeners=function(e){e!==t&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},L.prototype.getMaxListeners=function(){return this._maxListeners},L.prototype.event="",L.prototype.once=function(e,t,n){return this._once(e,t,!1,n)},L.prototype.prependOnceListener=function(e,t,n){return this._once(e,t,!0,n)},L.prototype._once=function(e,t,n,r){return this._many(e,1,t,n,r)},L.prototype.many=function(e,t,n,r){return this._many(e,t,n,!1,r)},L.prototype.prependMany=function(e,t,n,r){return this._many(e,t,n,!0,r)},L.prototype._many=function(e,t,n,r,i){var a=this;if("function"!=typeof n)throw new Error("many only accepts instances of Function");function s(){return 0==--t&&a.off(e,s),n.apply(this,arguments)}return s._origin=n,this._on(e,s,r,i)},L.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||u.call(this);var e,t,n,r,i,a,o=arguments[0],l=this.wildcard;if("newListener"===o&&!this._newListener&&!this._events.newListener)return!1;if(l&&(e=o,"newListener"!==o&&"removeListener"!==o&&"object"==typeof o)){if(n=o.length,s)for(r=0;r<n;r++)if("symbol"==typeof o[r]){a=!0;break}a||(o=o.join(this.delimiter))}var c,d=arguments.length;if(this._all&&this._all.length)for(r=0,n=(c=this._all.slice()).length;r<n;r++)switch(this.event=o,d){case 1:c[r].call(this,o);break;case 2:c[r].call(this,o,arguments[1]);break;case 3:c[r].call(this,o,arguments[1],arguments[2]);break;default:c[r].apply(this,arguments)}if(l)c=[],E.call(this,c,e,this.listenerTree,0,n);else{if("function"==typeof(c=this._events[o])){switch(this.event=o,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(r=0,n=c.length;r<n;r++)switch(this.event=o,d){case 1:c[r].call(this);break;case 2:c[r].call(this,arguments[1]);break;case 3:c[r].call(this,arguments[1],arguments[2]);break;default:c[r].apply(this,t)}return!0}if(!this.ignoreErrors&&!this._all&&"error"===o)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},L.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||u.call(this);var e,t,n,r,i,a,o=arguments[0],l=this.wildcard;if("newListener"===o&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(l&&(e=o,"newListener"!==o&&"removeListener"!==o&&"object"==typeof o)){if(r=o.length,s)for(i=0;i<r;i++)if("symbol"==typeof o[i]){t=!0;break}t||(o=o.join(this.delimiter))}var c,d=[],h=arguments.length;if(this._all)for(i=0,r=this._all.length;i<r;i++)switch(this.event=o,h){case 1:d.push(this._all[i].call(this,o));break;case 2:d.push(this._all[i].call(this,o,arguments[1]));break;case 3:d.push(this._all[i].call(this,o,arguments[1],arguments[2]));break;default:d.push(this._all[i].apply(this,arguments))}if(l?(c=[],E.call(this,c,e,this.listenerTree,0)):c=this._events[o],"function"==typeof c)switch(this.event=o,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(n=new Array(h-1),a=1;a<h;a++)n[a-1]=arguments[a];d.push(c.apply(this,n))}else if(c&&c.length){if(c=c.slice(),h>3)for(n=new Array(h-1),a=1;a<h;a++)n[a-1]=arguments[a];for(i=0,r=c.length;i<r;i++)switch(this.event=o,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,n))}}else if(!this.ignoreErrors&&!this._all&&"error"===o)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(d)},L.prototype.on=function(e,t,n){return this._on(e,t,!1,n)},L.prototype.prependListener=function(e,t,n){return this._on(e,t,!0,n)},L.prototype.onAny=function(e){return this._onAny(e,!1)},L.prototype.prependAny=function(e){return this._onAny(e,!0)},L.prototype.addListener=L.prototype.on,L.prototype._onAny=function(e,t){if("function"!=typeof e)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),t?this._all.unshift(e):this._all.push(e),this},L.prototype._on=function(e,n,r,i){if("function"==typeof e)return this._onAny(e,n),this;if("function"!=typeof n)throw new Error("on only accepts instances of Function");this._events||u.call(this);var a,s=this;return i!==t&&(n=(a=P.call(this,e,n,i))[0],s=a[1]),this._newListener&&this.emit("newListener",e,n),this.wildcard?(x.call(this,e,n,r),s):(this._events[e]?("function"==typeof this._events[e]&&(this._events[e]=[this._events[e]]),r?this._events[e].unshift(n):this._events[e].push(n),!this._events[e].warned&&this._maxListeners>0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,h.call(this,this._events[e].length,e))):this._events[e]=n,s)},L.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,i=[];if(this.wildcard){var a="string"==typeof e?e.split(this.delimiter):e.slice();if(!(i=E.call(this,null,a,this.listenerTree,0)))return this}else{if(!this._events[e])return this;n=this._events[e],i.push({_listeners:n})}for(var s=0;s<i.length;s++){var o=i[s];if(n=o._listeners,r(n)){for(var l=-1,c=0,u=n.length;c<u;c++)if(n[c]===t||n[c].listener&&n[c].listener===t||n[c]._origin&&n[c]._origin===t){l=c;break}if(l<0)continue;return this.wildcard?o._listeners.splice(l,1):this._events[e].splice(l,1),0===n.length&&(this.wildcard?delete o._listeners:delete this._events[e]),this._removeListener&&this.emit("removeListener",e,t),this}(n===t||n.listener&&n.listener===t||n._origin&&n._origin===t)&&(this.wildcard?delete o._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return this.listenerTree&&k(this.listenerTree),this},L.prototype.offAny=function(e){var t,n=0,r=0;if(e&&this._all&&this._all.length>0){for(n=0,r=(t=this._all).length;n<r;n++)if(e===t[n])return t.splice(n,1),this._removeListener&&this.emit("removeListenerAny",e),this}else{if(t=this._all,this._removeListener)for(n=0,r=t.length;n<r;n++)this.emit("removeListenerAny",t[n]);this._all=[]}return this},L.prototype.removeListener=L.prototype.off,L.prototype.removeAllListeners=function(e){if(e===t)return!this._events||u.call(this),this;if(this.wildcard){var n,r=E.call(this,null,e,this.listenerTree,0);if(!r)return this;for(n=0;n<r.length;n++)r[n]._listeners=null;this.listenerTree&&k(this.listenerTree)}else this._events&&(this._events[e]=null);return this},L.prototype.listeners=function(e){var n,r,i,a,s,o=this._events;if(e===t){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!o)return[];for(a=(n=c(o)).length,i=[];a-- >0;)"function"==typeof(r=o[n[a]])?i.push(r):i.push.apply(i,r);return i}if(this.wildcard){if(!(s=this.listenerTree))return[];var l=[],u="string"==typeof e?e.split(this.delimiter):e.slice();return E.call(this,l,u,s,0),l}return o&&(r=o[e])?"function"==typeof r?[r]:r:[]},L.prototype.eventNames=function(e){var t=this._events;return this.wildcard?A.call(this,this.listenerTree,[],null,e):t?c(t):[]},L.prototype.listenerCount=function(e){return this.listeners(e).length},L.prototype.hasListeners=function(e){if(this.wildcard){var n=[],r="string"==typeof e?e.split(this.delimiter):e.slice();return E.call(this,n,r,this.listenerTree,0),n.length>0}var i=this._events,a=this._all;return!!(a&&a.length||i&&(e===t?c(i).length:i[e]))},L.prototype.listenersAny=function(){return this._all?this._all:[]},L.prototype.waitFor=function(e,n){var r=this,i=typeof n;return"number"===i?n={timeout:n}:"function"===i&&(n={filter:n}),_((n=m(n,{timeout:0,filter:t,handleError:!1,Promise:Promise,overload:!1},{filter:b,Promise:v})).Promise,(function(t,i,a){function s(){var a=n.filter;if(!a||a.apply(r,arguments))if(r.off(e,s),n.handleError){var o=arguments[0];o?i(o):t(f.apply(null,arguments).slice(1))}else t(f.apply(null,arguments))}a((function(){r.off(e,s)})),r._on(e,s,!1)}),{timeout:n.timeout,overload:n.overload})};var O=L.prototype;Object.defineProperties(L,{defaultMaxListeners:{get:function(){return O._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");O._maxListeners=e},enumerable:!0},once:{value:function(e,t,n){return _((n=m(n,{Promise:Promise,timeout:0,overload:!1},{Promise:v})).Promise,(function(n,r,i){var a;if("function"==typeof e.addEventListener)return a=function(){n(f.apply(null,arguments))},i((function(){e.removeEventListener(t,a)})),void e.addEventListener(t,a,{once:!0});var s,o=function(){s&&e.removeListener("error",s),n(f.apply(null,arguments))};"error"!==t&&(s=function(n){e.removeListener(t,o),r(n)},e.once("error",s)),i((function(){s&&e.removeListener("error",s),e.removeListener(t,o)})),e.once(t,o)}),{timeout:n.timeout,overload:n.overload})},writable:!0,configurable:!0}}),Object.defineProperties(O,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),e.exports=L}()}(St);var Et=St.exports,xt=Object.assign?Object.assign:function(e,t,n,r){for(var i=1;i<arguments.length;i++)Ot(Object(arguments[i]),(function(t,n){e[n]=t}));return e},At=function(){if(Object.create)return function(e,t,n,r){var i=Lt(arguments,1);return xt.apply(this,[Object.create(e)].concat(i))};{function e(){}return function(t,n,r,i){var a=Lt(arguments,1);return e.prototype=t,xt.apply(this,[new e].concat(a))}}}(),kt=String.prototype.trim?function(e){return String.prototype.trim.call(e)}:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},Ft="undefined"!=typeof window?window:s,Pt={assign:xt,create:At,trim:kt,bind:function(e,t){return function(){return t.apply(e,Array.prototype.slice.call(arguments,0))}},slice:Lt,each:Ot,map:function(e,t){var n=Ct(e)?[]:{};return Tt(e,(function(e,r){return n[r]=t(e,r),!1})),n},pluck:Tt,isList:Ct,isFunction:function(e){return e&&"[object Function]"==={}.toString.call(e)},isObject:function(e){return e&&"[object Object]"==={}.toString.call(e)},Global:Ft};function Lt(e,t){return Array.prototype.slice.call(e,t||0)}function Ot(e,t){Tt(e,(function(e,n){return t(e,n),!1}))}function Tt(e,t){if(Ct(e)){for(var n=0;n<e.length;n++)if(t(e[n],n))return e[n]}else for(var r in e)if(e.hasOwnProperty(r)&&t(e[r],r))return e[r]}function Ct(e){return null!=e&&"function"!=typeof e&&"number"==typeof e.length}var jt=Pt.slice,Rt=Pt.pluck,qt=Pt.each,It=Pt.bind,Nt=Pt.create,Dt=Pt.isList,Ut=Pt.isFunction,Ht=Pt.isObject,$t={createStore:zt},Mt={version:"2.0.12",enabled:!1,get:function(e,t){var n=this.storage.read(this._namespacePrefix+e);return this._deserialize(n,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(n,r){e.call(t,t._deserialize(n),(r||"").replace(t._namespaceRegexp,""))}))},clearAll:function(){this.storage.clearAll()},hasNamespace:function(e){return this._namespacePrefix=="__storejs_"+e+"_"},createStore:function(){return zt.apply(this,arguments)},addPlugin:function(e){this._addPlugin(e)},namespace:function(e){return zt(this.storage,this.plugins,e)}};function zt(e,t,n){n||(n=""),e&&!Dt(e)&&(e=[e]),t&&!Dt(t)&&(t=[t]);var r=n?"__storejs_"+n+"_":"",i=n?new RegExp("^"+r):null;if(!/^[a-zA-Z0-9_\-]*$/.test(n))throw new Error("store.js namespaces can only have alphanumerics + underscores and dashes");var a={_namespacePrefix:r,_namespaceRegexp:i,_testStorage:function(e){try{var t="__storejs__test__";e.write(t,t);var n=e.read(t)===t;return e.remove(t),n}catch(e){return!1}},_assignPluginFnProp:function(e,t){var n=this[t];this[t]=function(){var t=jt(arguments,0),r=this;function i(){if(n)return qt(arguments,(function(e,n){t[n]=e})),n.apply(r,t)}var a=[i].concat(t);return e.apply(r,a)}},_serialize:function(e){return JSON.stringify(e)},_deserialize:function(e,t){if(!e)return t;var n="";try{n=JSON.parse(e)}catch(t){n=e}return void 0!==n?n:t},_addStorage:function(e){this.enabled||this._testStorage(e)&&(this.storage=e,this.enabled=!0)},_addPlugin:function(e){var t=this;if(Dt(e))qt(e,(function(e){t._addPlugin(e)}));else if(!Rt(this.plugins,(function(t){return e===t}))){if(this.plugins.push(e),!Ut(e))throw new Error("Plugins must be function values that return objects");var n=e.call(this);if(!Ht(n))throw new Error("Plugins must return an object of function properties");qt(n,(function(n,r){if(!Ut(n))throw new Error("Bad plugin property: "+r+" from plugin "+e.name+". Plugins should only return functions.");t._assignPluginFnProp(n,r)}))}},addStorage:function(e){!function(){var e="undefined"==typeof console?null:console;if(e){(e.warn?e.warn:e.log).apply(e,arguments)}}("store.addStorage(storage) is deprecated. Use createStore([storages])"),this._addStorage(e)}},s=Nt(a,Mt,{plugins:[]});return s.raw={},qt(s,(function(e,t){Ut(e)&&(s.raw[t]=It(s,e))})),qt(e,(function(e){s._addStorage(e)})),qt(t,(function(e){s._addPlugin(e)})),s}var Bt=Pt.Global,Gt={name:"localStorage",read:Wt,write:function(e,t){return Vt().setItem(e,t)},each:function(e){for(var t=Vt().length-1;t>=0;t--){var n=Vt().key(t);e(Wt(n),n)}},remove:function(e){return Vt().removeItem(e)},clearAll:function(){return Vt().clear()}};function Vt(){return Bt.localStorage}function Wt(e){return Vt().getItem(e)}var Qt=Pt.Global,Jt={name:"sessionStorage",read:Zt,write:function(e,t){return Kt().setItem(e,t)},each:function(e){for(var t=Kt().length-1;t>=0;t--){var n=Kt().key(t);e(Zt(n),n)}},remove:function(e){return Kt().removeItem(e)},clearAll:function(){return Kt().clear()}};function Kt(){return Qt.sessionStorage}function Zt(e){return Kt().getItem(e)}var Xt=Pt.trim,Yt={name:"cookieStorage",read:function(e){if(!e||!rn(e))return null;var t="(?:^|.*;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(en.cookie.replace(new RegExp(t),"$1"))},write:function(e,t){if(!e)return;en.cookie=escape(e)+"="+escape(t)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:tn,remove:nn,clearAll:function(){tn((function(e,t){nn(t)}))}},en=Pt.Global.document;function tn(e){for(var t=en.cookie.split(/; ?/g),n=t.length-1;n>=0;n--)if(Xt(t[n])){var r=t[n].split("="),i=unescape(r[0]);e(unescape(r[1]),i)}}function nn(e){e&&rn(e)&&(en.cookie=escape(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function rn(e){return new RegExp("(?:^|;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(en.cookie)}var an={name:"memoryStorage",read:function(e){return sn[e]},write:function(e,t){sn[e]=t},each:function(e){for(var t in sn)sn.hasOwnProperty(t)&&e(sn[t],t)},remove:function(e){delete sn[e]},clearAll:function(e){sn={}}},sn={};function on(e,t=!1){e+="";let n,r=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],i=["0","1","2","3","4","5","6","7","8","9"],a=(t=t||!Salla.config.get("store.settings.arabic_numbers_enabled"))?r:i,s=t?i:r;for(let t=0;t<a.length;t++)n=new RegExp(a[t],"g"),e=e.replace(n,s[t]);return e}function ln(e){let t=(e.match(/\./g)||[]).length;return t&&1!==t?ln(e.replace(/\.(.+)\./g,".$1")):e}function cn(e,t,n){let r=e[0];return n&&0==e.length?Array.isArray(n)?(n.push(t),n):[n,t]:Array.isArray(n)?(n.push(t),n):"string"==typeof n?[n,t]:n?(n[r]=cn(e.slice(1),t,n[r]),n):r?{[r]:cn(e.slice(1),t)}:""===r?[t]:t}function un(e){return Salla.config.get("store.url",window.location.href.split("/").slice(0,-1).join("/")).rtrim("/")+"/"+e.ltrim("/")}var dn={digitsOnly:function(e){return on(e,!0).replace(/[^0-9.]/g,"").replace("..",".").rtrim(".")},inputDigitsOnly:function e(t,n=!1){if("string"==typeof t)return document.querySelectorAll(t).forEach((t=>e(t,n)));if(!t)return void Salla.logger.warn("Can't find Object With Id: "+t);let r=Salla.helpers.digitsOnly(t.value);return t.min&&r<t.min?t.value=t.min:t.max&&r>t.max?t.value=t.max:t.maxLength>=1&&r.toString().length>t.maxLength?t.value=r.toString().substring(0,t.maxLength):t.value=n||t.dataset.hasOwnProperty("digitsWithDecimal")?ln(r):r.replace(/\D/g,"")},number:on,money:function(e){let t=Salla.config.currency(e?.currency).symbol;return on(e="object"==typeof e?e.amount:e)+" "+t},setNested:function(e,t,n){let r=e,i=t.split("."),a=i.length;for(let e=0;e<a-1;e++){let t=i[e];r[t]||(r[t]={}),r=r[t]}return r[i[a-1]]=n,e},getNested:function(e,t,n){let r=_t(e,t);return void 0!==r?r:n},inputData:function(e,t,n={}){if(e.includes("[")){let r=e.split("]").join("").split("[");return{name:r[0],value:cn(r.slice(1),t,n[r[0]])}}return{name:e,value:t}},url:{get:un,asset:function(e){return function(e){return window.location.origin+"/"+e.ltrim("/")}("themes/"+Salla.config.get("theme.name")+"/"+e.ltrim("/"))},cdn:function(e){return"https://cdn.salla.network/"+e.ltrim("/")},is_page:function(e){return e&&Salla.config.get("page.slug")===e},api:function(e){return Salla.config.get("store.api",un("")).rtrim("/")+"/"+e.ltrim("/")}},addParamToUrl:function(e,t){if(!t||!e)return window.location.href;let n=new RegExp("([?&])"+e+"=[^&]+[&]?","g"),r=window.location.href.replace(n,"$1").replace(/&$|\?$/,"");return r+=(r.includes("?")?"&":"?")+e+"="+encodeURIComponent(t),r.replace(/&$|\?$/,"")},debounce:function(e,t){t=t||100;let n,r=[];return function(...i){return clearTimeout(n),n=setTimeout((()=>{let t=e(...i);r.forEach((e=>e(t))),r=[]}),t),new Promise((e=>r.push(e)))}}},hn=function(e){let t={log:function(t,n){if(!e)return;if(!salla.config.isDebug())return;"trace"===salla.config.get("debug")&&(n="trace");let r=e.log,i=void 0===n?r:this.__dict__[n]||r,a=["%cTwilight","color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;"],s={event:"#CFF680",backend:"#7b68ee"}[n];s&&(a[0]+="%c"+n[0].toUpperCase()+n.substring(1),a.push(`margin-left: 5px;color: ${s};font-weight:bold; border:1px solid ${s}; padding: 2px 6px; border-radius: 5px;`)),i.call(e,...a.concat(...t))},__dict__:{trace:e.trace,debug:e.debug,info:e.info,warn:e.warn,error:e.error}};return{event:function(){t.log(arguments,"event")},trace:function(){t.log(arguments,"trace")},debug:function(){t.log(arguments,"debug")},info:function(){t.log(arguments,"info")},warn:function(){t.log(arguments,"warn")},error:function(){t.log(arguments,"error")},log:function(){t.log(arguments,void 0)},backend:function(){t.log(arguments,"backend")},logs:function(e){[e].flat().forEach((e=>e&&t.log([e].flat(),"backend")))}}}(console);const fn=$t.createStore([Gt,Jt,Yt,an],[]);void 0===a?(window.salla=window.salla||window.Salla||{},window.Salla=window.salla):(a.salla=a.salla||a.Salla||{},a.Salla=a.salla),Salla.status="base",Salla.config=new class{constructor(e={},t={}){this.default_properties=t,this.properties_={...this.default_properties,...e}}merge(e){return Object.assign(this.properties_,e),this.properties_.store={...this.default_properties.store,...this.properties_.store},this}set(e,t){return e.includes(".")?(Salla.helpers.setNested(this.properties_,e,t),this):(this.properties_[e]=t,this)}get(e,t=null){return e.includes(".")?Salla.helpers.getNested(this.properties_,e,t):this.properties_.hasOwnProperty(e)?this.properties_[e]||t:t||void 0}all(){return this.properties_}isDebug(){return this.get("debug")||Salla.storage.get("debug")}},Salla.logger=hn,Salla.event=new class extends Et{constructor(){super({wildcard:!0,delimiter:"::",newListener:!1,removeListener:!1,maxListeners:10,verboseMemoryLeak:!1,ignoreErrors:!1}),this.delimiter="::","undefined"!=typeof document&&(this.body=document.querySelector("body")),this.logableEvents=["cart::item.added.failed","cart::item.deleted.failed"],this.ingoreLogEvents=["document::click","document::keyup","document::change"],this.noneFireableActions=["document.request"]}createAndDispatch(e,...t){this.dispatch(e,...t)}emit(e,...t){let n=e.replace("::",".");if(!this.noneFireableActions.includes(n)&&void 0!==Salla.call&&"function"==typeof Salla.call(n))return Salla.log(`'Salla.${n}(...)' triggered using event '${e}'`),n=n.split("."),void salla[n[0]][n[1]](...t);if(super.emit(e,...t),"undefined"!=typeof window){window.dataLayer=window.dataLayer||[];let n={event:e};t.map((e=>{"object"==typeof e?n={...n,...e}:salla.log(`Skipped to add item (${e}) to the dataLayerObject, because it's not an object.`)})),window.dataLayer.push(n)}Salla.logger&&!this.ingoreLogEvents.includes(e)&&Salla.logger.event(e,...t),this.dispatchMobileEvent(e,{...t.values()})}dispatch(e,...t){return this.emit(e,...t)}dispatchEvents(e){if(e&&"object"==typeof e)for(const[t,n]of Object.entries(e))this.dispatch(t,n);else Salla.log("No Events To Dispatch!",e)}addListener(e,t){return this.on(e,t)}addEventListener(e,t){return this.on(e,t)}listen(e,t){return this.on(e,t)}registerGlobalListener(e,t){return this.onAny(t)}dispatchMobileEvent(e,t={}){if(!("undefined"!=typeof window&&window.dataLayer&&dataLayer[0]&&dataLayer[0].page&&dataLayer[0].page.mobileApp))return"";if(window.webkit)try{window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:e,details:t}))}catch(e){Salla.log(e,"The native context does not exist yet")}else if(Android)try{Android.customEventWithData(e,JSON.stringify({details:t}))}catch(e){Salla.log(e,"The native context does not exist yet")}}},Salla.storage=new class{constructor(){Salla.event.on("storage::item.remove",(e=>this.remove(e))),Salla.event.on("storage::item.set",((e,t)=>this.set(e,t))),this.store=fn}set(e,t){if(e.includes(".")){let n=e.split(".")[0],r={[n]:this.store.get(n)};return r=Salla.helpers.setNested(r,e,t),this.store.set(n,r[n])}return this.store.set(e,t)}remove(e){return this.store.remove(e)}clearAll(){return this.store.clearAll()}get(e,t){if(e.includes(".")){let t=e.split(".")[0];return Salla.helpers.getNested({[t]:this.store.get(t)},e)}return this.store.get(e,t)}},Salla.cookie=new class{constructor(){Salla.event.on("cookies::remove",(e=>this.remove(e))),Salla.event.on("cookies::add",((e,t)=>this.set(e,t)))}get(e){return document.cookie.split("; ").find((t=>t.startsWith(e+"=")))?.split("=")[1]}set(e,t="",n=10){let r="";if(n){let e=new Date;e.setTime(e.getTime()+24*n*60*60*1e3),r="; expires="+e.toUTCString()}return document.cookie=`${e}=${t}${r}"; path=/; secure; SameSite=Lax"`,this}remove(e){return document.cookie=`${e}=; Max-Age=0; path=/;`,this}clearAll(){let e=document.cookie.split(";");for(let t=0;t<e.length;t++){let n=e[t],r=n.indexOf("="),i=r>-1?n.substr(0,r):n;this.remove(i)}}},Salla.helpers=dn,Salla.log=Salla.logger.log,Salla.money=Salla.helpers.money,Salla.url=Salla.helpers.url,Salla.versions={base:"2.9.44"};var pn=Salla;let gn=function(e,t,n){return alert(e)},mn=function(e,t){return gn(e,vn.error,t)},vn={error:"error",success:"success",info:"info"};var yn={fire:function(e,t,n){return gn(e,t,n)},setNotifier:function(e){gn=e},error:mn,success:function(e,t){return gn(e,vn.success,t)},info:function(e,t){return gn(e,vn.info,t)},sallaInitiated:function(){let e=window.location.href.match(/([\?\&]danger=)[^&]+/g);e&&e.forEach((e=>{mn(decodeURI(e.replace("?danger=","").replace("&danger=","")))}))},types:vn};class bn{constructor(e,t){return this.api=e,this.event=t,new Proxy(this,{get:function(n,r){return"event"===r?t:"api"===r?e:e&&e[r]||n[r]}})}}String.prototype.toStudlyCase=function(){return this.trim().replace(/([^a-zA-Z\d].)/g,(function(e){return e.toUpperCase().replace(/[^a-zA-Z\d]/g,"")}))},String.prototype.toDatasetName=function(){return this.startsWith("data-")?this.substr(5).toStudlyCase():this.toStudlyCase()},String.prototype.toSelector=function(){return this.trim().startsWith(".")||this.trim().startsWith("#")?this:"#"+this},String.prototype.replaceArray=function(e,t){for(var n,r=this,i=0;i<e.length;i++)n=new RegExp(e[i],"g"),r=r.replace(n,t[i]);return r},String.prototype.rtrim=function(e){return void 0===e&&(e="\\s"),this.replace(new RegExp("["+e+"]*$"),"")},String.prototype.ltrim=function(e){return void 0===e&&(e="\\s"),this.replace(new RegExp("^["+e+"]*"),"")},String.prototype.digitsOnly=function(){return Salla.helpers.digitsOnly(this)},Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){for(var t=this;t;){if(t.matches(e))return t;t=t.parentElement}}),Element.prototype.getElementSallaData=function(e,...t){if(!this.getAttribute)return;if(this.hasAttribute("data-json"))try{return JSON.parse(this.getAttribute("data-json"))}catch(e){}let n=this.getAttribute("data-function");if(n&&window[n])return"function"==typeof window[n]?this.getFilteredData(window[n].call(this,...t)):this.getFilteredData(window[n]);let r=this.hasAttribute("data-form-selector")?document.querySelector(this.dataset.formSelector):void 0;if(r="FORM"===this.tagName?this:r||this.closest("form")||this.closest("[salla-form-data]")||this,r&&"FORM"===r.tagName)return this.getFilteredData(new FormData(r),null,r);let i=r.querySelectorAll("[name]");if(!i.length)return this.getFilteredData();let a=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,a);a[t.name]=t.value}catch(t){Salla.log(e.name+" can't be send")}})),this.getFilteredData(a)},Element.prototype.canEventFireHook=function(e){return!!this.hasAttribute&&this.hasAttribute(Salla.api.hooksPrefix+e.type)},Element.prototype.hasAttributeStartsWith=function(e,t){e=e.toLowerCase();for(var n=0;n<this.attributes.length;n++){let r=this.attributes[n].name.toLowerCase();if(0===r.indexOf(e))return!t||r}return!1},HTMLFormElement.prototype.getAjaxFormData=function(e){var t=this.querySelectorAll('input[type="file"]');t.forEach((e=>{e.files.length||e.setAttribute("disabled","")}));var n=new FormData(this);return t.forEach((e=>{e.files.length||e.removeAttribute("disabled")})),{formData:this.getFilteredData(n,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,n=null){return e=e||n?.dataset||this.dataset,n&&this.name&&void 0!==this.value&&(e=function(e,t,n){e instanceof FormData?e.append(t,n):e[t]=n;return e}(e,this.name,this.value)),["filterBeforeSubmit","filterBeforeSend"].forEach((r=>{let i=n?.dataset[r]||this.dataset[r];if(i){var a=window[i];if("function"==typeof a){if(!a(e,n||this,t)&&e)throw`Data failed to be pass verify function window.${i}(formData, element, event)!`;return a(e,n||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 wn{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(...n){return t.dispatch(e,...n)}}createDynamicListenerFuns(e){let t="on"+e.charAt(0).toUpperCase()+e.slice(1);if(this[t])return;let n=this;this[t]=function(t){return n.on(e,t)}}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.dispatch(this.getEventName(e),...t)}on(e,t){return Salla.event.addListener(this.getEventName(e),t)}once(e,t){return Salla.event.once(this.getEventName(e),t)}}function _n(e){e&&e.sallaInitiated&&!e.initiated&&(e.sallaInitiated(),e.initiated=!0)}Salla.event.auth=new class extends wn{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"},this.after_init()}login(e){return e?(e.type&&this.setTypeActionOnVerified(e.type),this.next_event=e.next_event||null,this.dispatch("login",...arguments)):(this.next_event=null,this.dispatch("login",...arguments))}loggedIn(e){Salla.profile.info().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 wn{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",couponAdded:"coupon.added",couponDeleted:"coupon.deleted",couponAdditionFailed:"coupon.addition.failed",couponDeletionFailed:"coupon.deletion.failed",quickCheckoutSettingFetched:"quick-checkout.fetched",quickCheckoutSettingFailed:"quick-checkout.failed",quickCheckoutSucceeded:"quick-checkout.succeeded",quickCheckoutFailed:"quick-checkout.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 wn{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"},this.after_init()}},Salla.event.scope=new class extends wn{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 wn{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.comment=new class extends wn{constructor(){super(),this.namespace="comment",this.events={added:"added",additionFailed:"addition.failed"},this.after_init()}},Salla.event.loyalty=new class extends wn{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()}},Salla.event.product=new class extends wn{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",addGiftToCartSucceeded:"gift.add-to-cart.succeeded",addGiftToCartFailed:"gift.add-to-cart.failed",giftImageUploadSucceeded:"gift.image-upload.succeeded",giftImageUploadFailed:"gift.image-upload.failed"},this.after_init()}},Salla.event.profile=new class extends wn{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 wn{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 wn{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,n){this.on(e,(e=>{"function"!=typeof t?"function"==typeof n&&e.target.matches(t)&&n(e):t(e)}))}fireEvent(e,t,...n){return this.fireEventForElements(e,t,!1,...n)}fireEventForAll(e,t,...n){return this.fireEventForElements(e,t,!0,...n)}fireEventForElements(e,t,n,...r){if("string"==typeof e){if(n)return document.querySelectorAll(e).forEach((e=>this.fireEventForElements(e,t,!1,...r)));e=document.querySelector(e)}if(!e)return void salla.log("Failed To get element to fire event: "+t);const i=new CustomEvent(t,...r);return e.dispatchEvent(i)}},Salla.event.wishlist=new class extends wn{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 wn{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.booking=new class extends wn{constructor(){super(),this.namespace="booking",this.events={added:"added",additionFailed:"addition.failed"},this.after_init()}},Salla.event.on("twilight::initiated",(()=>{Object.keys(Salla).forEach((e=>{"object"==typeof(e=Salla[e])&&(_n(e),Object.keys(e).forEach((t=>{_n(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((n=>{e&&(t=[],e=!1),n.code=n.code||n.iso_code,n.url=salla.url.get(n.code),n.is_rtl=n.is_rtl||n.rtl,t.push(n)})),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((n=>{e&&(t={},e=!1),n.country_code=n.code.substr(0,2).toLowerCase(),t[n.code]=n})),Salla.config.set("currencies",t),t},Salla.config.currency=e=>(e=e||Salla.config.get("user.currency_code"),Salla.config.get("currencies."+e)||Object.values(Salla.config.get("currencies"))[0]);var Sn,En={exports:{}},xn={exports:{}},An={exports:{}};function kn(){return Sn||(Sn=1,function(e){!function(t,n){e.exports?e.exports=n():t.EvEmitter=n()}("undefined"!=typeof window?window:s,(function(){function e(){}let t=e.prototype;return t.on=function(e,t){if(!e||!t)return this;let n=this._events=this._events||{},r=n[e]=n[e]||[];return r.includes(t)||r.push(t),this},t.once=function(e,t){if(!e||!t)return this;this.on(e,t);let n=this._onceEvents=this._onceEvents||{};return(n[e]=n[e]||{})[t]=!0,this},t.off=function(e,t){let n=this._events&&this._events[e];if(!n||!n.length)return this;let r=n.indexOf(t);return-1!=r&&n.splice(r,1),this},t.emitEvent=function(e,t){let n=this._events&&this._events[e];if(!n||!n.length)return this;n=n.slice(0),t=t||[];let r=this._onceEvents&&this._onceEvents[e];for(let i of n){r&&r[i]&&(this.off(e,i),delete r[i]),i.apply(this,t)}return this},t.allOff=function(){return delete this._events,delete this._onceEvents,this},e}))}(An)),An.exports}var Fn,Pn,Ln={exports:{}};function On(){return Fn||(Fn=1,function(e){!function(t,n){e.exports?e.exports=n(t):t.fizzyUIUtils=n(t)}(s,(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 n=e.indexOf(t);-1!=n&&e.splice(n,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,n){return(e=t.makeArray(e)).filter((e=>e instanceof HTMLElement)).reduce(((e,t)=>{if(!n)return e.push(t),e;t.matches(n)&&e.push(t);let r=t.querySelectorAll(n);return e=e.concat(...r)}),[])},debounceMethod:function(e,t,n){n=n||100;let r=e.prototype[t],i=t+"Timeout";e.prototype[t]=function(){clearTimeout(this[i]);let e=arguments;this[i]=setTimeout((()=>{r.apply(this,e),delete this[i]}),n)}},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,n){return t+"-"+n})).toLowerCase()}},n=e.console;return t.htmlInit=function(r,i){t.docReady((function(){let a="data-"+t.toDashed(i),s=document.querySelectorAll(`[${a}]`),o=e.jQuery;[...s].forEach((e=>{let t,s=e.getAttribute(a);try{t=s&&JSON.parse(s)}catch(t){return void(n&&n.error(`Error parsing ${a} on ${e.className}: ${t}`))}let l=new r(e,t);o&&o.data(e,i,l)}))}))},t}))}(Ln)),Ln.exports}function Tn(){return Pn||(Pn=1,function(e){!function(t,n){e.exports?e.exports=n(t,kn(),On()):t.InfiniteScroll=n(t,t.EvEmitter,t.fizzyUIUtils)}(window,(function(e,t,n){let r=e.jQuery,i={};function a(e,t){let s=n.getQueryElement(e);if(s){if((e=s).infiniteScrollGUID){let n=i[e.infiniteScrollGUID];return n.option(t),n}this.element=e,this.options={...a.defaults},this.option(t),r&&(this.$element=r(this.element)),this.create()}else console.error("Bad element for InfiniteScroll: "+(s||e))}a.defaults={},a.create={},a.destroy={};let s=a.prototype;Object.assign(s,t.prototype);let o=0;s.create=function(){let e=this.guid=++o;if(this.element.infiniteScrollGUID=e,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 a.create)a.create[e].call(this)}else console.error("Disabling InfiniteScroll")},s.option=function(e){Object.assign(this.options,e)},s.callOnInit=function(){let e=this.options.onInit;e&&e.call(this,this)},s.dispatchEvent=function(e,t,n){this.log(e,n);let i=t?[t].concat(n):n;if(this.emitEvent(e,i),!r||!this.$element)return;let a=e+=".infiniteScroll";if(t){let n=r.Event(t);n.type=e,a=n}this.$element.trigger(a,n)};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,n)=>`${n.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 n=`[InfiniteScroll] ${e}`,r=l[e];r&&(n+=". "+r.apply(this,t)),console.log(n)},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:n.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?)"),n=new RegExp(t),r=location.href.match(n);r&&(this.pageIndex=parseInt(r[1],10),this.log("pageIndex",[this.pageIndex,"template string"]))};let c=[/^(.*?\/?page\/?)(\d\d?\d?)(.*?$)/,/^(.*?\/?\?page=)(\d\d?\d?)(.*?$)/,/(.*?)(\d\d?\d?)(?!.*\d)(.*?$)/],u=a.getPathParts=function(e){if(e)for(let t of c){let n=e.match(t);if(n){let[,e,t,r]=n;return{begin:e,index:t,end:r}}}};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 n=t.getAttribute("href"),r=u(n);if(!r)return void console.error(`InfiniteScroll unable to parse next link href: ${n}`);let{begin:i,index:a,end:s}=r;this.isPathSelector=!0,this.getPath=()=>i+(this.pageIndex+1)+s,this.pageIndex=parseInt(a,10)-1,this.log("pageIndex",[this.pageIndex,"next link"])},s.updateGetAbsolutePath=function(){let e=this.getPath();if(e.match(/^http/)||e.match(/^\//))return void(this.getAbsolutePath=this.getPath);let{pathname:t}=location,n=e.match(/^\?/),r=t.substring(0,t.lastIndexOf("/")),i=n?t:r+"/";this.getAbsolutePath=()=>i+this.getPath()},a.create.hideNav=function(){let e=n.getQueryElement(this.options.hideNav);e&&(e.style.display="none",this.nav=e)},a.destroy.hideNav=function(){this.nav&&(this.nav.style.display="")},s.destroy=function(){this.allOff();for(let e in a.destroy)a.destroy[e].call(this);delete this.element.infiniteScrollGUID,delete i[this.guid],r&&this.$element&&r.removeData(this.element,"infiniteScroll")},a.throttle=function(e,t){let n,r;return t=t||200,function(){let i=+new Date,a=arguments,s=()=>{n=i,e.apply(this,a)};n&&i<n+t?(clearTimeout(r),r=setTimeout(s,t)):s()}},a.data=function(e){let t=(e=n.getQueryElement(e))&&e.infiniteScrollGUID;return t&&i[t]},a.setJQuery=function(e){r=e},n.htmlInit(a,"infinite-scroll"),s._init=function(){};let{jQueryBridget:d}=e;return r&&d&&d("infiniteScroll",a,r),a}))}(xn)),xn.exports}var Cn,jn={exports:{}};function Rn(){return Cn||(Cn=1,function(e){!function(t,n){e.exports?e.exports=n(t,Tn()):n(t,t.InfiniteScroll)}(window,(function(e,t){let n=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)},n.onScrollThresholdLoad=function(){this.options.loadOnScroll&&this.loadNextPage()};let r=new DOMParser;function i(e){let t=document.createDocumentFragment();return e&&t.append(...e),t}return n.loadNextPage=function(){if(this.isLoading||!this.canLoad)return;let{responseBody:e,domParseResponse:t,fetchOptions:n}=this.options,i=this.getAbsolutePath();this.isLoading=!0,"function"==typeof n&&(n=n());let a=fetch(i,n).then((n=>{if(!n.ok){let e=new Error(n.statusText);return this.onPageError(e,i,n),{response:n}}return n[e]().then((a=>("text"==e&&t&&(a=r.parseFromString(a,"text/html")),204==n.status?(this.lastPageReached(a,i),{body:a,response:n}):this.onPageLoad(a,i,n))))})).catch((e=>{this.onPageError(e,i)}));return this.dispatchEvent("request",null,[i,a]),a},n.onPageLoad=function(e,t,n){return this.options.append||(this.isLoading=!1),this.pageIndex++,this.loadCount++,this.dispatchEvent("load",null,[e,t,n]),this.appendNextPage(e,t,n)},n.appendNextPage=function(e,t,n){let{append:r,responseBody:a,domParseResponse:s}=this.options;if(!("text"==a&&s)||!r)return{body:e,response:n};let o=e.querySelectorAll(r),l={body:e,response:n,items:o};if(!o||!o.length)return this.lastPageReached(e,t),l;let c=i(o),u=()=>(this.appendItems(o,c),this.isLoading=!1,this.dispatchEvent("append",null,[e,t,o,n]),l);return this.options.outlayer?this.appendOutlayerItems(c,u):u()},n.appendItems=function(e,t){e&&e.length&&(function(e){let t=e.querySelectorAll("script");for(let e of t){let t=document.createElement("script"),n=e.attributes;for(let e of n)t.setAttribute(e.name,e.value);t.innerHTML=e.innerHTML,e.parentNode.replaceChild(t,e)}}(t=t||i(e)),this.element.appendChild(t))},n.appendOutlayerItems=function(n,r){let i=t.imagesLoaded||e.imagesLoaded;return i?new Promise((function(e){i(n,(function(){let t=r();e(t)}))})):(console.error("[InfiniteScroll] imagesLoaded required for outlayer option"),void(this.isLoading=!1))},n.onAppendOutlayer=function(e,t,n){this.options.outlayer.appended(n)},n.checkLastPage=function(e,t){let n,{checkLastPage:r,path:i}=this.options;if(r){if("function"==typeof i){if(!this.getPath())return void this.lastPageReached(e,t)}"string"==typeof r?n=r:this.isPathSelector&&(n=i),n&&e.querySelector&&(e.querySelector(n)||this.lastPageReached(e,t))}},n.lastPageReached=function(e,t){this.canLoad=!1,this.dispatchEvent("last",null,[e,t])},n.onPageError=function(e,t,n){return this.isLoading=!1,this.canLoad=!1,this.dispatchEvent("error",null,[e,t,n]),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}`)},n.prefill=function(){let e=this.getPrefillDistance();this.isPrefilling=e>=0,this.isPrefilling?(this.log("prefill"),this.loadNextPage()):this.stopPrefill()},n.getPrefillDistance=function(){return this.options.elementScroll?this.scroller.clientHeight-this.scroller.scrollHeight:this.windowHeight-this.element.clientHeight},n.stopPrefill=function(){this.log("stopPrefill"),this.off("append",this.prefill)},t}))}(jn)),jn.exports}var qn,In={exports:{}};function Nn(){return qn||(qn=1,function(e){!function(t,n){e.exports?e.exports=n(t,Tn(),On()):n(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,n){let r=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()},r.enableScrollWatch=function(){this.isScrollWatching||(this.isScrollWatching=!0,this.updateMeasurements(),this.updateScroller(),this.on("last",this.disableScrollWatch),this.bindScrollWatchEvents(!0))},r.disableScrollWatch=function(){this.isScrollWatching&&(this.bindScrollWatchEvents(!1),delete this.isScrollWatching)},r.bindScrollWatchEvents=function(t){let n=t?"addEventListener":"removeEventListener";this.scroller[n]("scroll",this.pageScrollHandler),e[n]("resize",this.resizeHandler)},r.onPageScroll=t.throttle((function(){this.getBottomDistance()<=this.options.scrollThreshold&&this.dispatchEvent("scrollThreshold")})),r.getBottomDistance=function(){let t,n;return this.options.elementScroll?(t=this.scroller.scrollHeight,n=this.scroller.scrollTop+this.scroller.clientHeight):(t=this.top+this.element.clientHeight,n=e.scrollY+this.windowHeight),t-n},r.onResize=function(){this.updateMeasurements()},n.debounceMethod(t,"onResize",150),t}))}(In)),In.exports}var Dn,Un={exports:{}};function Hn(){return Dn||(Dn=1,function(e){!function(t,n){e.exports?e.exports=n(t,Tn(),On()):n(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,n){let r=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.`)},r.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)},r.bindHistoryAppendEvents=function(t){let n=t?"addEventListener":"removeEventListener";this.scroller[n]("scroll",this.scrollHistoryHandler),e[n]("unload",this.unloadHandler)},r.createHistoryPageLoad=function(){this.on("load",this.onPageLoadHistory)},t.destroy.history=r.destroyHistory=function(){this.options.history&&this.options.append&&this.bindHistoryAppendEvents(!1)},r.onAppendHistory=function(e,t,n){if(!n||!n.length)return;let r=n[0],a=this.getElementScrollY(r);i.href=t,this.scrollPages.push({top:a,path:i.href,title:e.title})},r.getElementScrollY=function(t){if(this.options.elementScroll)return t.offsetTop-this.top;return t.getBoundingClientRect().top+e.scrollY},r.onScrollHistory=function(){let e=this.getClosestScrollPage();e!=this.scrollPage&&(this.scrollPage=e,this.setHistory(e.title,e.path))},n.debounceMethod(t,"onScrollHistory",150),r.getClosestScrollPage=function(){let t,n;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;n=e}return n},r.setHistory=function(e,t){let n=this.options.history;n&&history[n+"State"]&&(history[n+"State"](null,e,t),this.options.historyTitle&&(document.title=e),this.dispatchEvent("history",null,[e,t]))},r.onUnload=function(){if(0===this.scrollPage.top)return;let t=e.scrollY-this.scrollPage.top+this.top;this.destroyHistory(),scrollTo(0,t)},r.onPageLoadHistory=function(e,t){this.setHistory(e.title,t)},t}))}(Un)),Un.exports}var $n,Mn={exports:{}};function zn(){return $n||($n=1,function(e){!function(t,n){e.exports?e.exports=n(t,Tn(),On()):n(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,n){class r{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=n.getQueryElement(this.options.button);e&&(this.button=new r(e,this))},t.destroy.button=function(){this.button&&this.button.destroy()},t.Button=r,t}))}(Mn)),Mn.exports}var Bn,Gn={exports:{}};function Vn(){return Bn||(Bn=1,function(e){!function(t,n){e.exports?e.exports=n(t,Tn(),On()):n(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,n){let r=t.prototype;function i(e){s(e,"none")}function a(e){s(e,"block")}function s(e,t){e&&(e.style.display=t)}return t.create.status=function(){let e=n.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"))},r.bindHideStatus=function(e){let t=this.options.append?"append":"load";this[e](t,this.hideAllStatus)},r.showRequestStatus=function(){this.showStatus("request")},r.showErrorStatus=function(){this.showStatus("error")},r.showLastStatus=function(){this.showStatus("last"),this.bindHideStatus("off")},r.showStatus=function(e){a(this.statusElement),this.hideStatusEventElements(),a(this.statusEventElements[e])},r.hideAllStatus=function(){i(this.statusElement),this.hideStatusEventElements()},r.hideStatusEventElements=function(){for(let e in this.statusEventElements){i(this.statusEventElements[e])}},t}))}(Gn)),Gn.exports}
2
2
  /*!
3
3
  * Infinite Scroll v4.0.1
4
4
  * Automatically add next page
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * https://infinite-scroll.com
10
10
  * Copyright 2018-2020 Metafizzy
11
- */!function(e){window,e.exports&&(e.exports=function(e){return e}(Tn(),Rn(),Nn(),Hn(),zn(),Vn()))}(En);var Wn=En.exports;var Jn={exports:{}};
11
+ */!function(e){window,e.exports&&(e.exports=function(e){return e}(Tn(),Rn(),Nn(),Hn(),zn(),Vn()))}(En);var Wn=En.exports;var Qn={exports:{}};
12
12
  /*!
13
13
  * Lang.js for Laravel localization in JavaScript.
14
14
  *
@@ -16,5 +16,5 @@
16
16
  * @license MIT https://github.com/rmariuzzo/Lang.js/blob/master/LICENSE
17
17
  * @site https://github.com/rmariuzzo/Lang.js
18
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 n=/^({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])$/,r=/({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])/,i={locale:"en"},a=function(t){t=t||{},this.locale=t.locale||e()||i.locale,this.fallback=t.fallback,this.messages=t.messages};return a.prototype.setMessages=function(e){this.messages=e},a.prototype.getLocale=function(){return this.locale||this.fallback},a.prototype.setLocale=function(e){this.locale=e},a.prototype.getFallback=function(){return this.fallback},a.prototype.setFallback=function(e){this.fallback=e},a.prototype.has=function(e,t){return!("string"!=typeof e||!this.messages)&&null!==this._getMessage(e,t)},a.prototype.get=function(e,t,n){if(!this.has(e,n))return e;var r=this._getMessage(e,n);return null===r?e:(t&&(r=this._applyReplacements(r,t)),r)},a.prototype.trans=function(e,t){return this.get(e,t)},a.prototype.choice=function(e,t,n,i){(n=void 0!==n?n:{}).count=t;var a=this.get(e,n,i);if(null==a)return a;for(var s=a.split("|"),o=[],l=0;l<s.length;l++)if(s[l]=s[l].trim(),r.test(s[l])){var c=s[l].split(/\s/);o.push(c.shift()),s[l]=c.join(" ")}if(1===s.length)return a;for(var u=0;u<o.length;u++)if(this._testInterval(t,o[u]))return s[u];return i=i||this._getLocale(e),s[this._getPluralForm(t,i)]},a.prototype.transChoice=function(e,t,n){return this.choice(e,t,n)},a.prototype._parseKey=function(e,t){if("string"!=typeof e||"string"!=typeof t)return null;var n=e.split("."),r=n[0].replace(/\//g,".");return{source:t+"."+r,sourceFallback:this.getFallback()+"."+r,entries:n.slice(1)}},a.prototype._getMessage=function(e,t){if(t=t||this.getLocale(),e=this._parseKey(e,t),void 0===this.messages[e.source]&&void 0===this.messages[e.sourceFallback])return null;var n=this.messages[e.source],r=e.entries.slice(),i=r.join(".");if("string"!=typeof(n=void 0!==n?this._getValueInKey(n,i):void 0)&&this.messages[e.sourceFallback])for(n=this.messages[e.sourceFallback],r=e.entries.slice(),i="";r.length&&void 0!==n;)n[i=i?i.concat(".",r.shift()):r.shift()]&&(n=n[i],i="");return"string"!=typeof n?null:n},a.prototype._getValueInKey=function(e,t){if("string"==typeof e[t])return e[t];for(var n=(t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"")).split("."),r=0,i=n.length;r<i;++r){var a=n.slice(0,r+1).join("."),s=n.slice(r+1,n.length).join(".");if(e[a])return this._getValueInKey(e[a],s)}return e},a.prototype._getLocale=function(e){return e=this._parseKey(e,this.locale),this.messages[e.source]?this.locale:this.messages[e.sourceFallback]?this.fallback:null},a.prototype._findMessageInTree=function(e,t){for(;e.length&&void 0!==t;){var n=e.join(".");if(t[n]){t=t[n];break}t=t[e.shift()]}return t},a.prototype._sortReplacementKeys=function(e,t){return t.length-e.length},a.prototype._applyReplacements=function(e,t){return Object.keys(t).sort(this._sortReplacementKeys).forEach((function(n){e=e.replace(new RegExp(":"+n,"gi"),(function(e){var r=t[n];return e===e.toUpperCase()?r.toUpperCase():e===e.replace(/\w/i,(function(e){return e.toUpperCase()}))?r.charAt(0).toUpperCase()+r.slice(1):r}))})),e},a.prototype._testInterval=function(e,r){if("string"!=typeof r)throw"Invalid interval: should be a string.";var i=(r=r.trim()).match(n);if(!i)throw"Invalid interval: "+r;if(!i[2]){var a=(i=i.filter((function(e){return!!e})))[1],s=t(i[2]);s===1/0&&(s=-1/0);var o=t(i[3]),l=i[4];return("["===a?e>=s:e>s)&&("]"===l?e<=o:e<o)}for(var c=i[2].split(","),u=0;u<c.length;u++)if(parseInt(c[u],10)===e)return!0;return!1},a.prototype._getPluralForm=function(e,t){switch(t){case"az":case"bo":case"dz":case"id":case"ja":case"jv":case"ka":case"km":case"kn":case"ko":case"ms":case"th":case"tr":case"vi":case"zh":default:return 0;case"af":case"bn":case"bg":case"ca":case"da":case"de":case"el":case"en":case"eo":case"es":case"et":case"eu":case"fa":case"fi":case"fo":case"fur":case"fy":case"gl":case"gu":case"ha":case"he":case"hu":case"is":case"it":case"ku":case"lb":case"ml":case"mn":case"mr":case"nah":case"nb":case"ne":case"nl":case"nn":case"no":case"om":case"or":case"pa":case"pap":case"ps":case"pt":case"so":case"sq":case"sv":case"sw":case"ta":case"te":case"tk":case"ur":case"zu":return 1==e?0:1;case"am":case"bh":case"fil":case"fr":case"gun":case"hi":case"hy":case"ln":case"mg":case"nso":case"xbr":case"ti":case"wa":return 0===e||1===e?0:1;case"be":case"bs":case"hr":case"ru":case"sr":case"uk":return e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2;case"cs":case"sk":return 1==e?0:e>=2&&e<=4?1:2;case"ga":return 1==e?0:2==e?1:2;case"lt":return e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2;case"sl":return e%100==1?0:e%100==2?1:e%100==3||e%100==4?2:3;case"mk":return e%10==1?0:1;case"mt":return 1==e?0:0===e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3;case"lv":return 0===e?0:e%10==1&&e%100!=11?1:2;case"pl":return 1==e?0:e%10>=2&&e%10<=4&&(e%100<12||e%100>14)?1:2;case"cy":return 1==e?0:2==e?1:8==e||11==e?2:3;case"ro":return 1==e?0:0===e||e%100>0&&e%100<20?1:2;case"ar":return 0===e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11&&e%100<=99?4:5}},a}()}(Jn);var Qn=Jn.exports;class Kn{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,n=null){let r=Array.isArray(e),i=r?this.getUrl(...e):this.getUrl(e);e=r?e[0]:e,n=n||this.endpointsMethods[e]||"post";let a=this.endpointsHeaders[e];if("get"===n&&t instanceof FormData){let e={};Array.from(t.entries()).forEach((function(t){e[t[0]]=t[1]})),t={params:e}}return a&&"get"===n&&(t=t?Object.assign(t,a):a),this.webEndpoints.includes(e)?i=salla.url.get(i):"http"!==i.substring(0,4)&&(i=salla.url.api(i)),Salla.api.request(i,t,n,{headers:a})}request(e,t,n=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,n)):this.normalRequest(e,t,n)}getUrl(e){let t=this.endpoints[e]||e;const n=/{[^{}]+}/i;for(let e=1;e<arguments.length;e++)t=t.replace(n,arguments[e]);return t}event(){return salla.event[this.className]}}class Zn extends Kn{constructor(){super(),this.namespace="cart",this.endpoints={latest:"cart/latest",details:"cart/{cart}",quickAdd:"cart/{cart}/item/{product}/quick-add",addItem:"cart/{cart}/item/{product}/add",deleteItem:"cart/{cart}/item/{item}",updateItem:"cart/{cart}/item/{item}",deleteImage:"cart/{cart}/image/{image}",uploadImage:"cart/{cart}/image",status:"cart/{cart}/status",addCoupon:"cart/{id}/coupon",deleteCoupon:"cart/{id}/coupon"},this.endpointsMethods={latest:"get",details:"get",status:"get",updateItem:"post",deleteItem:"delete",deleteImage:"delete",deleteCoupon:"put"},this.webEndpoints=["latest"],this.latestCart=null,this.after_init()}async getCurrentCartId(){if(this.latestCart)return this.latestCart.cart.id;let e=await this.latest();return this.latestCart=e.data,this.latestCart.cart.id}getUploadImageEndpoint(e){return salla.url.api(this.getUrl("uploadImage",e||salla.storage.get("cart.id")))}latest(){return this.request("latest",{params:{source:""}}).then((e=>(salla.storage.set("cart",e.data.cart),salla.event.cart.latestFetched(e),e))).catch((e=>{throw salla.storage.set("cart",""),salla.event.cart.latestFailed(e),e}))}async details(){let e=await this.getCurrentCartId();return this.request(["details",e]).then((function(e){return salla.cart.event.detailsFetched(e),e})).catch((function(e){throw salla.cart.event.detailsNotFetched(e),e}))}async quickAdd(e,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 n=salla.form.getPossibleValue(t.payload,["endpoint"]);n&&["addItem","quickAdd"].includes(n)||(n=salla.form.getPossibleValue(t.payload,["quantity","donating_amount"])?"addItem":"quickAdd");let r=await this.getCurrentCartId();return this.request([n,r,t.id],t.payload).then((function(e){return salla.cart.event.itemAdded(e,t.id),e})).catch((function(e){throw salla.cart.event.itemAddedFailed(e,t.id),e}))}async deleteItem(e){let t=this.getCartPayload(e);if(!t.id){let e='There is no "id"!';return salla.cart.event.itemDeletedFailed(e),salla.api.errorPromise(e)}let n=await this.getCurrentCartId();return this.request(["deleteItem",n,t.id]).then((function(e){return salla.cart.event.itemDeleted(e,t.id),e})).catch((function(e){throw salla.cart.event.itemDeletedFailed(e,t.id),e}))}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 n=await this.getCurrentCartId();return"Object"===t.payload.constructor?.name?t.payload._method="PUT":t.payload.append("_method","PUT"),this.request(["updateItem",n,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 this.getCurrentCartId();return this.request(["deleteImage",t,e]).then((function(t){return salla.cart.event.imageDeleted(t,e),t})).catch((function(t){throw salla.cart.event.imageNotDeleted(t,e),t}))}async status(e){return this.request(["status",e||await this.getCurrentCartId()],{params:{has_apple_pay:!!window.ApplePaySession}})}async submit(){this.status(await this.getCurrentCartId()).then((e=>{let t=e.data.next_step.to;if(!["checkout","refresh","login"].includes(t)){let e="Can't find next_step );";throw salla.cart.event.submitFailed(e),e}if(salla.cart.event.submitted(e),"login"===t)return salla.auth.setCanRedirect(!1),salla.event.dispatch("login::open"),void salla.auth.event.onLoggedIn((e=>{salla.event.dispatch("login::close"),this.submit()}));"checkout"===t?window.location.href=e.data.next_step.url+(window.ApplePaySession?"?has_apple_pay=true":""):window.location.reload()})).catch((function(e){throw salla.cart.event.submitFailed(e),e}))}getCartPayload(e){let t=e?.data||("object"==typeof e?e:void 0);return e=t?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,n=null){return super.normalRequest(e,t,n).catch((e=>{throw 403===e?.response?.status&&(salla.storage.remove("cart"),salla.error(salla.lang.get("pages.checkout.try_again"))),e}))}reset(){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();return this.request(["addCoupon",t],{coupon:e}).then((function(e){return salla.event.cart.couponAdded(e,t),e})).catch((function(e){throw salla.event.cart.couponAdditionFailed(e,t),e}))}async deleteCoupon(){let e=await salla.cart.api.getCurrentCartId();return this.request(["deleteCoupon",e],{}).then((function(t){return salla.event.cart.couponDeleted(t,e),t})).catch((function(t){throw salla.event.cart.couponDeletionFailed(t,e),t}))}}class Xn extends Kn{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())){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())){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 Yn extends Kn{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.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 n=salla.form.getPossibleValue(e,["type"]);if(!n){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 r=await this.request(["verify",n],e);if(200!==r?.status)return salla.auth.event.verificationFailed(r,n),salla.api.errorPromise(r);let i="authenticated"===r.data?.case;return i&&salla.auth.event.tokenFetched(r.data.token),t&&await this.request("auth/jwt"),i&&salla.auth.event.loggedIn(r),salla.auth.event.verified(r,n),salla.auth.api.afterUserLogin(),salla.api.successPromise(r)}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 function(e){return salla.auth.event.registered.call(t,e),"authenticated"===e.data?.case&&(salla.auth.event.tokenFetched(e.data.token),await salla.auth.request("auth/jwt"),salla.auth.event.loggedIn(e),salla.auth.api.afterUserLogin()),e})).catch((function(e){throw salla.auth.event.registrationFailed.call(t,e),e}))}logout(){return this.request("logout").then((function(e){return salla.storage.clearAll(),salla.cookie.clearAll(),salla.auth.event.loggedOut(e),salla.log("Reloading after 0.2 sec..."),setTimeout((()=>location.reload()),200),e})).catch((function(e){throw salla.auth.event.failedLogout(e),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 er extends Kn{constructor(){super(),this.namespace="order",this.endpoints={cancel:"orders/cancel/{id}",createCartFromOrder:"reorder/{id}",sendInvoice:"orders/send/{id}"},this.endpointsMethods={createCartFromOrder:"get"},this.after_init()}show(e){let t=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:!!window.ApplePaySession}}).then((function(t){return salla.event.order.canceled(t,e),t})).catch((function(t){throw salla.event.order.notCanceled(t,e),t}))}createCartFromOrder(e){return e=e||salla.config.get("page.id"),this.request(["createCartFromOrder",e]).then((function(t){return salla.storage.set("cart",{id:t.data.cart_id,user_id:salla.config.get("user.id")}),salla.event.order.orderCreated(t,e),window.location.href=t.data.url,t})).catch((function(t){throw salla.event.order.orderCreationFailed(t,e),t}))}sendInvoice(e){let t=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}))}}class tr extends Kn{constructor(){super(),this.namespace="product",this.previousQuery="",this.endpoints={getPrice:"products/{id}/price",availabilitySubscribe:"products/{id}/availability-notify",search:"products/search",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"},this.endpointsMethods={giftDetail:"get"},this.after_init()}getPrice(e){let t=e.data||e,n=salla.form.getPossibleValue(t,["id","prod_id","product_id"]);return this.request(["getPrice",n],"object"==typeof t?t:void 0).then((function(e){return salla.product.event.priceUpdated(e,n),e})).catch((function(e){throw salla.product.event.priceUpdateFailed(e,n),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.availabilitySubscribedFailed(t,e),t}))}search(e){let t=e.data;if(t||(t={params:"string"==typeof e?{query:e}:e}),!(e=t instanceof FormData?t.get("query"):t.query||t.params?.query)){let e='There is no "query"!';return salla.product.event.searchFailed(e),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.offer.event.fetchDetailsFailed(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}))}addGiftToCart(e,t,n=!1){return this.request(["giftToCart",e],t).then((t=>(salla.product.event.addGiftToCartSucceeded(t,e),n&&(window.location.href=t.redirect),response))).catch((t=>{throw salla.product.event.addGiftToCartFailed(t,e),t}))}uploadGiftImage(e){return this.request("giftImage",e).then((e=>(salla.product.event.giftImageUploadSucceeded(e),e))).catch((e=>{throw salla.product.event.giftImageUploadFailed(e),e}))}}class nr extends Kn{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 rr extends Kn{constructor(){super(),this.namespace="comment",this.endpoints={add:"{type}/{id}/comments"},this.after_init()}add(e){e?.data&&(e=e.data);let t,n=salla.form.getPossibleValue(e,["id"]),r=salla.form.getPossibleValue(e,["type"]),i=salla.form.getPossibleValue(e,["comment"]);return n?r&&["products","pages","product","page"].includes(r)?i?(r+=["product","page"].includes(r)?"s":"",this.request(["add",r,n],{comment:i}).then((function(e){return salla.event.comment.added(e,n),e})).catch((function(e){throw salla.event.comment.additionFailed(e,n),e}))):(salla.event.comment.additionFailed(t="can't find comment content!"),salla.api.errorPromise(t)):(salla.event.comment.additionFailed(t="Failed to get type one of:(products, product, page, pages)!"),salla.api.errorPromise(t)):(salla.event.comment.additionFailed(t="Failed to get id!"),salla.api.errorPromise(t))}}class ir extends Kn{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 ar extends Kn{constructor(){super(),this.namespace="document"}}class sr extends Kn{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:{},n=salla.form.getPossibleValue(e?.data||e,["order_id","id"]);if(!n){let e='There is no "order_id"!';return salla.event.rating.orderNotFetched(e),salla.api.errorPromise(e)}return this.request(["order",n],t).then((function(e){return salla.event.rating.orderFetched(e,n),e})).catch((function(e){throw salla.event.rating.orderNotFetched(e,n),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 or extends Kn{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 n=salla.storage.get("salla::wishlist",[]);t?n.push(e):n.splice(n.indexOf(e),1),salla.storage.set("salla::wishlist",n)}}class lr extends Kn{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),resp}))}}class cr extends Kn{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}))}}var ur,dr={exports:{}},hr=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}},fr=hr,pr=Object.prototype.toString,gr=(ur=Object.create(null),function(e){var t=pr.call(e);return ur[t]||(ur[t]=t.slice(8,-1).toLowerCase())});function mr(e){return e=e.toLowerCase(),function(t){return gr(t)===e}}function vr(e){return Array.isArray(e)}function yr(e){return void 0===e}var br=mr("ArrayBuffer");function wr(e){return null!==e&&"object"==typeof e}function _r(e){if("object"!==gr(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}var Sr=mr("Date"),Er=mr("File"),xr=mr("Blob"),Ar=mr("FileList");function Pr(e){return"[object Function]"===pr.call(e)}var Fr=mr("URLSearchParams");function Lr(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),vr(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}var kr,Or=(kr="undefined"!=typeof Uint8Array&&Object.getPrototypeOf(Uint8Array),function(e){return kr&&e instanceof kr}),Tr={isArray:vr,isArrayBuffer:br,isBuffer:function(e){return null!==e&&!yr(e)&&null!==e.constructor&&!yr(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||pr.call(e)===t||Pr(e.toString)&&e.toString()===t)},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&br(e.buffer)},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:wr,isPlainObject:_r,isUndefined:yr,isDate:Sr,isFile:Er,isBlob:xr,isFunction:Pr,isStream:function(e){return wr(e)&&Pr(e.pipe)},isURLSearchParams:Fr,isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:Lr,merge:function e(){var t={};function n(n,r){_r(t[r])&&_r(n)?t[r]=e(t[r],n):_r(n)?t[r]=e({},n):vr(n)?t[r]=n.slice():t[r]=n}for(var r=0,i=arguments.length;r<i;r++)Lr(arguments[r],n);return t},extend:function(e,t,n){return Lr(t,(function(t,r){e[r]=n&&"function"==typeof t?fr(t,n):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,n,r){e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,n&&Object.assign(e.prototype,n)},toFlatObject:function(e,t,n){var r,i,a,s={};t=t||{};do{for(i=(r=Object.getOwnPropertyNames(e)).length;i-- >0;)s[a=r[i]]||(t[a]=e[a],s[a]=!0);e=Object.getPrototypeOf(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:gr,kindOfTest:mr,endsWith:function(e,t,n){e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;var r=e.indexOf(t,n);return-1!==r&&r===n},toArray:function(e){if(!e)return null;var t=e.length;if(yr(t))return null;for(var n=new Array(t);t-- >0;)n[t]=e[t];return n},isTypedArray:Or,isFileList:Ar},jr=Tr;function Cr(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var Rr=function(e,t,n){if(!t)return e;var r;if(n)r=n(t);else if(jr.isURLSearchParams(t))r=t.toString();else{var i=[];jr.forEach(t,(function(e,t){null!=e&&(jr.isArray(e)?t+="[]":e=[e],jr.forEach(e,(function(e){jr.isDate(e)?e=e.toISOString():jr.isObject(e)&&(e=JSON.stringify(e)),i.push(Cr(t)+"="+Cr(e))})))})),r=i.join("&")}if(r){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e},Ir=Tr;function qr(){this.handlers=[]}qr.prototype.use=function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1},qr.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},qr.prototype.forEach=function(e){Ir.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var Nr,Dr,Ur=qr,Hr=Tr;function $r(){if(Dr)return Nr;Dr=1;var e=Tr;function t(e,t,n,r,i){Error.call(this),this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i)}e.inherits(t,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var n=t.prototype,r={};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){r[e]={value:e}})),Object.defineProperties(t,r),Object.defineProperty(n,"isAxiosError",{value:!0}),t.from=function(r,i,a,s,o,l){var c=Object.create(n);return e.toFlatObject(r,c,(function(e){return e!==Error.prototype})),t.call(c,r.message,i,a,s,o),c.name=r.name,l&&Object.assign(c,l),c},Nr=t}var Mr,zr,Br,Gr,Vr,Wr,Jr={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};function Qr(){if(zr)return Mr;zr=1;var e=Tr;return Mr=function(t,r){r=r||new FormData;var i=[];function a(t){return null===t?"":e.isDate(t)?t.toISOString():e.isArrayBuffer(t)||e.isTypedArray(t)?"function"==typeof Blob?new Blob([t]):n.Buffer.from(t):t}return function t(n,s){if(e.isPlainObject(n)||e.isArray(n)){if(-1!==i.indexOf(n))throw Error("Circular reference detected in "+s);i.push(n),e.forEach(n,(function(n,i){if(!e.isUndefined(n)){var o,l=s?s+"."+i:i;if(n&&!s&&"object"==typeof n)if(e.endsWith(i,"{}"))n=JSON.stringify(n);else if(e.endsWith(i,"[]")&&(o=e.toArray(n)))return void o.forEach((function(t){!e.isUndefined(t)&&r.append(l,a(t))}));t(n,l)}})),i.pop()}else r.append(s,a(n))}(t),r},Mr}function Kr(){if(Gr)return Br;Gr=1;var e=$r();return Br=function(t,n,r){var i=r.config.validateStatus;r.status&&i&&!i(r.status)?n(new e("Request failed with status code "+r.status,[e.ERR_BAD_REQUEST,e.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):t(r)}}function Zr(){if(Wr)return Vr;Wr=1;var e=Tr;return Vr=e.isStandardBrowserEnv()?{write:function(t,n,r,i,a,s){var o=[];o.push(t+"="+encodeURIComponent(n)),e.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),e.isString(i)&&o.push("path="+i),e.isString(a)&&o.push("domain="+a),!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 Xr,Yr,ei,ti,ni,ri,ii,ai,si,oi,li,ci,ui=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},di=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},hi=function(e,t){return e&&!ui(t)?di(e,t):t};function fi(){if(Yr)return Xr;Yr=1;var e=Tr,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 Xr=function(n){var r,i,a,s={};return n?(e.forEach(n.split("\n"),(function(n){if(a=n.indexOf(":"),r=e.trim(n.substr(0,a)).toLowerCase(),i=e.trim(n.substr(a+1)),r){if(s[r]&&t.indexOf(r)>=0)return;s[r]="set-cookie"===r?(s[r]?s[r]:[]).concat([i]):s[r]?s[r]+", "+i:i}})),s):s}}function pi(){if(ti)return ei;ti=1;var e=Tr;return ei=e.isStandardBrowserEnv()?function(){var t,n=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function i(e){var t=e;return n&&(r.setAttribute("href",t),t=r.href),r.setAttribute("href",t),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return t=i(window.location.href),function(n){var r=e.isString(n)?i(n):n;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0}}function gi(){if(ri)return ni;ri=1;var e=$r();function t(t){e.call(this,null==t?"canceled":t,e.ERR_CANCELED),this.name="CanceledError"}return Tr.inherits(t,e,{__CANCEL__:!0}),ni=t}function mi(){return ai?ii:(ai=1,ii=function(e){var t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""})}function vi(){if(oi)return si;oi=1;var e=Tr,t=Kr(),n=Zr(),r=Rr,i=hi,a=fi(),s=pi(),o=Jr,l=$r(),c=gi(),u=mi();return si=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 b=new XMLHttpRequest;if(d.auth){var w=d.auth.username||"",_=d.auth.password?unescape(encodeURIComponent(d.auth.password)):"";m.Authorization="Basic "+btoa(w+":"+_)}var S=i(d.baseURL,d.url);function E(){if(b){var e="getAllResponseHeaders"in b?a(b.getAllResponseHeaders()):null,n={data:v&&"text"!==v&&"json"!==v?b.response:b.responseText,status:b.status,statusText:b.statusText,headers:e,config:d,request:b};t((function(e){h(e),y()}),(function(e){f(e),y()}),n),b=null}}if(b.open(d.method.toUpperCase(),r(S,d.params,d.paramsSerializer),!0),b.timeout=d.timeout,"onloadend"in b?b.onloadend=E:b.onreadystatechange=function(){b&&4===b.readyState&&(0!==b.status||b.responseURL&&0===b.responseURL.indexOf("file:"))&&setTimeout(E)},b.onabort=function(){b&&(f(new l("Request aborted",l.ECONNABORTED,d,b)),b=null)},b.onerror=function(){f(new l("Network Error",l.ERR_NETWORK,d,b,b)),b=null},b.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,b)),b=null},e.isStandardBrowserEnv()){var x=(d.withCredentials||s(S))&&d.xsrfCookieName?n.read(d.xsrfCookieName):void 0;x&&(m[d.xsrfHeaderName]=x)}"setRequestHeader"in b&&e.forEach(m,(function(e,t){void 0===g&&"content-type"===t.toLowerCase()?delete m[t]:b.setRequestHeader(t,e)})),e.isUndefined(d.withCredentials)||(b.withCredentials=!!d.withCredentials),v&&"json"!==v&&(b.responseType=d.responseType),"function"==typeof d.onDownloadProgress&&b.addEventListener("progress",d.onDownloadProgress),"function"==typeof d.onUploadProgress&&b.upload&&b.upload.addEventListener("progress",d.onUploadProgress),(d.cancelToken||d.signal)&&(p=function(e){b&&(f(!e||e&&e.type?new c:e),b.abort(),b=null)},d.cancelToken&&d.cancelToken.subscribe(p),d.signal&&(d.signal.aborted?p():d.signal.addEventListener("abort",p))),g||(g=null);var A=u(S);A&&-1===["http","https","file"].indexOf(A)?f(new l("Unsupported protocol "+A+":",l.ERR_BAD_REQUEST,d)):b.send(g)}))},si}var yi=Tr,bi=function(e,t){Hr.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))},wi=$r(),_i=Jr,Si=Qr(),Ei={"Content-Type":"application/x-www-form-urlencoded"};function xi(e,t){!yi.isUndefined(e)&&yi.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var Ai,Pi={transitional:_i,adapter:(("undefined"!=typeof XMLHttpRequest||void 0!==i.default&&"[object process]"===Object.prototype.toString.call(i.default))&&(Ai=vi()),Ai),transformRequest:[function(e,t){if(bi(t,"Accept"),bi(t,"Content-Type"),yi.isFormData(e)||yi.isArrayBuffer(e)||yi.isBuffer(e)||yi.isStream(e)||yi.isFile(e)||yi.isBlob(e))return e;if(yi.isArrayBufferView(e))return e.buffer;if(yi.isURLSearchParams(e))return xi(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString();var n,r=yi.isObject(e),i=t&&t["Content-Type"];if((n=yi.isFileList(e))||r&&"multipart/form-data"===i){var a=this.env&&this.env.FormData;return Si(n?{"files[]":e}:e,a&&new a)}return r||"application/json"===i?(xi(t,"application/json"),function(e,t,n){if(yi.isString(e))try{return(t||JSON.parse)(e),yi.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||Pi.transitional,n=t&&t.silentJSONParsing,r=t&&t.forcedJSONParsing,i=!n&&"json"===this.responseType;if(i||r&&yi.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(i){if("SyntaxError"===e.name)throw wi.from(e,wi.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:ci?li:(ci=1,li=null)},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};yi.forEach(["delete","get","head"],(function(e){Pi.headers[e]={}})),yi.forEach(["post","put","patch"],(function(e){Pi.headers[e]=yi.merge(Ei)}));var Fi,Li,ki=Pi,Oi=Tr,Ti=ki;function ji(){return Li?Fi:(Li=1,Fi=function(e){return!(!e||!e.__CANCEL__)})}var Ci=Tr,Ri=function(e,t,n){var r=this||Ti;return Oi.forEach(n,(function(n){e=n.call(r,e,t)})),e},Ii=ji(),qi=ki,Ni=gi();function Di(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Ni}var Ui,Hi,$i=Tr,Mi=function(e,t){t=t||{};var n={};function r(e,t){return $i.isPlainObject(e)&&$i.isPlainObject(t)?$i.merge(e,t):$i.isPlainObject(t)?$i.merge({},t):$i.isArray(t)?t.slice():t}function i(n){return $i.isUndefined(t[n])?$i.isUndefined(e[n])?void 0:r(void 0,e[n]):r(e[n],t[n])}function a(e){if(!$i.isUndefined(t[e]))return r(void 0,t[e])}function s(n){return $i.isUndefined(t[n])?$i.isUndefined(e[n])?void 0:r(void 0,e[n]):r(void 0,t[n])}function o(n){return n in t?r(e[n],t[n]):n in e?r(void 0,e[n]):void 0}var l={url:a,method:a,data:a,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 $i.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=l[e]||i,r=t(e);$i.isUndefined(r)&&t!==o||(n[e]=r)})),n};function zi(){return Hi?Ui:(Hi=1,Ui={version:"0.27.2"})}var Bi=zi().version,Gi=$r(),Vi={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){Vi[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));var Wi={};Vi.transitional=function(e,t,n){function r(e,t){return"[Axios v"+Bi+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(n,i,a){if(!1===e)throw new Gi(r(i," has been removed"+(t?" in "+t:"")),Gi.ERR_DEPRECATED);return t&&!Wi[i]&&(Wi[i]=!0,console.warn(r(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,i,a)}};var Ji,Qi,Ki,Zi,Xi,Yi,ea={assertOptions:function(e,t,n){if("object"!=typeof e)throw new Gi("options must be an object",Gi.ERR_BAD_OPTION_VALUE);for(var r=Object.keys(e),i=r.length;i-- >0;){var a=r[i],s=t[a];if(s){var o=e[a],l=void 0===o||s(o,a,e);if(!0!==l)throw new Gi("option "+a+" must be "+l,Gi.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new Gi("Unknown option "+a,Gi.ERR_BAD_OPTION)}},validators:Vi},ta=Tr,na=Rr,ra=Ur,ia=function(e){return Di(e),e.headers=e.headers||{},e.data=Ri.call(e,e.data,e.headers,e.transformRequest),e.headers=Ci.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Ci.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||qi.adapter)(e).then((function(t){return Di(e),t.data=Ri.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return Ii(t)||(Di(e),t&&t.response&&(t.response.data=Ri.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},aa=Mi,sa=hi,oa=ea,la=oa.validators;function ca(e){this.defaults=e,this.interceptors={request:new ra,response:new ra}}ca.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=aa(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var n=t.transitional;void 0!==n&&oa.assertOptions(n,{silentJSONParsing:la.transitional(la.boolean),forcedJSONParsing:la.transitional(la.boolean),clarifyTimeoutError:la.transitional(la.boolean)},!1);var r=[],i=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(i=i&&e.synchronous,r.unshift(e.fulfilled,e.rejected))}));var a,s=[];if(this.interceptors.response.forEach((function(e){s.push(e.fulfilled,e.rejected)})),!i){var o=[ia,void 0];for(Array.prototype.unshift.apply(o,r),o=o.concat(s),a=Promise.resolve(t);o.length;)a=a.then(o.shift(),o.shift());return a}for(var l=t;r.length;){var c=r.shift(),u=r.shift();try{l=c(l)}catch(e){u(e);break}}try{a=ia(l)}catch(e){return Promise.reject(e)}for(;s.length;)a=a.then(s.shift(),s.shift());return a},ca.prototype.getUri=function(e){e=aa(this.defaults,e);var t=sa(e.baseURL,e.url);return na(t,e.params,e.paramsSerializer)},ta.forEach(["delete","get","head","options"],(function(e){ca.prototype[e]=function(t,n){return this.request(aa(n||{},{method:e,url:t,data:(n||{}).data}))}})),ta.forEach(["post","put","patch"],(function(e){function t(t){return function(n,r,i){return this.request(aa(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}ca.prototype[e]=t(),ca.prototype[e+"Form"]=t(!0)}));var ua=Tr,da=hr,ha=ca,fa=Mi;var pa=function e(t){var n=new ha(t),r=da(ha.prototype.request,n);return ua.extend(r,ha.prototype,n),ua.extend(r,n),r.create=function(n){return e(fa(t,n))},r}(ki);pa.Axios=ha,pa.CanceledError=gi(),pa.CancelToken=function(){if(Qi)return Ji;Qi=1;var e=gi();function t(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var n;this.promise=new Promise((function(e){n=e}));var r=this;this.promise.then((function(e){if(r._listeners){var t,n=r._listeners.length;for(t=0;t<n;t++)r._listeners[t](e);r._listeners=null}})),this.promise.then=function(e){var t,n=new Promise((function(e){r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},t((function(t){r.reason||(r.reason=new e(t),n(r.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,n=new t((function(t){e=t}));return{token:n,cancel:e}},Ji=t}(),pa.isCancel=ji(),pa.VERSION=zi().version,pa.toFormData=Qr(),pa.AxiosError=$r(),pa.Cancel=pa.CanceledError,pa.all=function(e){return Promise.all(e)},pa.spread=Zi?Ki:(Zi=1,Ki=function(e){return function(t){return e.apply(null,t)}}),pa.isAxiosError=function(){if(Yi)return Xi;Yi=1;var e=Tr;return Xi=function(t){return e.isObject(t)&&!0===t.isAxiosError}}(),dr.exports=pa,dr.exports.default=pa;var ga=dr.exports;function ma(e){this.message=e}ma.prototype=new Error,ma.prototype.name="InvalidCharacterError";var va="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new ma("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,i=0,a=0,s="";r=t.charAt(a++);~r&&(n=i%4?64*n+r:r,i++%4)?s+=String.fromCharCode(255&n>>(-2*i&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return s};function ya(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(va(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return va(t)}}function ba(e){this.message=e}ba.prototype=new Error,ba.prototype.name="InvalidTokenError";class wa{constructor(e){"ready"!==pn.status?e?(pn.config.merge(e),e?.events&&pn.event.dispatchEvents(e?.events),e._token&&salla.api.setHeader("X-CSRF-TOKEN",e._token),this.injectMaintenanceAlert(),this.injectThemePreviewAlert(),this.injectEditAlert(),e?.user?.language_code&&salla.lang.setLocale(e?.user?.language_code),salla.lang.loadStoreTranslations(),this.setSallaReady(e)):this.setSallaReady(e):salla.log("Trying to re-initiate Salla, while its status === 'ready'!")}injectMaintenanceAlert(){salla.config.get("maintenance")&&(document.querySelector(".store-notify")?salla.logger.warn(".store-notify element Existed before!"):salla.lang.onLoaded((()=>{const e=document.createElement("div");e.classList.add("store-notify"),e.style="background-color: #d63031; color: #fff; padding: 10px 15px; text-align: center; font-size: 17px;",e.innerHTML=`<p style="margin:0 !important;">${salla.lang.get("blocks.header.maintenance_alert")}</p>`,document.body.prepend(e)})))}injectThemePreviewAlert(){"preview"===salla.config.get("theme.mode")&&(document.querySelector("#s-theme_preview_bar")?salla.logger.warn("#s-theme_preview_bar element Existed before!"):salla.lang.onLoaded((()=>{let e=document.createElement("div");e.id="s-theme_preview_bar",e.setAttribute("style","display: flex; justify-content: space-between; text-align: center; background-color: #232323; color: #fff; padding: 10px; font-size: 0.875rem; line-height: 1.25rem; position: relative;"),e.innerHTML=`\n <div style="display:flex; align-items:center;">\n <img width="32" src="https://assets.salla.sa/cp/assets/images/logo-new.png">\n <span style="margin:0 10px;">${salla.lang.get("blocks.header.preview_mode")}: <span style="background:rgba(255,255,255,0.25);border-radius:15px; padding:2px 15px 4px">${salla.config.get("theme.name")}</span></span>\n </div>\n <a href="${salla.url.get("preview_theme/cancel/preview")}" style="line-height:32px; width:32px;"><i class="sicon-cancel"></i></a>\n `,document.body.prepend(e)})))}injectEditAlert(){let e=salla.config.get("edit");e&&(document.querySelector("#s-edit-alert")?salla.logger.warn("#s-edit-alert element Existed before!"):salla.lang.onLoaded((()=>{let t=document.createElement("div");t.id="s-edit-alert",t.innerHTML=`\n <a href="${e}" style="display:block; background-color:${salla.config.get("theme.color.primary","#5cd5c4")}; color:${salla.config.get("theme.color.reverse","#fff")}; padding: 10px; text-align:center; font-size: 0.875rem; line-height: 1.25rem;">\n <i class="sicon-edit"></i> \n ${salla.lang.get("pages.products.quick_edit")}\n </a>\n `,document.body.prepend(t)})))}handleElementAjaxRequest(e,t){if(!(t instanceof HTMLFormElement||t instanceof HTMLAnchorElement))return salla.logger.warn("trying to call ajax from non Element!!"),!1;e.preventDefault();let n=t.getAjaxFormData(e),r=n.method?n.method.toLowerCase():void 0;salla.api.request(n.url,n.formData,r).then((e=>(e.data&&e.request&&(e=e.data),salla.api.handleAfterResponseActions(e),this.callAjaxEvent(n.events.success,e,n.formData),e))).catch((e=>{throw salla.api.handleErrorResponse(e),this.callAjaxEvent(n.events.fail,e,n.formData),e}))}callAjaxEvent(e,t,n){if(e){if(n instanceof FormData){const e={};Array.from(n.entries()).forEach((function(t){e[t[0]]=t[1]})),n=e}window[e]?window[e](t,n):salla.event.dispatch(e,t,n)}}setSallaReady(e){pn.status="ready",pn.event.dispatch("twilight::initiated",e),window.dispatchEvent(new CustomEvent("salla::ready"))}}pn.status="loading",pn.notify=yn,pn.lang=new class extends Qn{constructor(e){(e=e||{}).messages=e.messages||window.translations,e.locale=e.locale||(window.locale||navigator.language||navigator.userLanguage||"ar").split("-")[0],e.fallback=e.fallback||e.locale,super(e),this.translationsLoaded=!1}onLoaded(e){if(this.translationsLoaded)return e();Salla.event.once("languages::translations.loaded",e)}loadStoreTranslations(){if(this.messages)return void window.addEventListener("load",(e=>{salla.event.dispatch("languages::translations.loaded"),salla.logger.info("The messages of transactions is already loaded")}));if(!salla.url.get(""))return void this.loadScript("https://cdn.salla.network/js/translations.js",!1);let e=salla.config.get("theme.translations_hash",salla.config.get("store.id","twilight"));this.loadScript(salla.url.get(`languages/assets/${e}.js`))}setMessages(e){super.setMessages(e),salla.event.dispatch("languages::translations.loaded"),this.translationsLoaded=!0}loadScript(e,t=!0){let n=document.createElement("script");n.src=e,n.onload=()=>{if(window.translations)return this.setMessages(window.translations);n.onerror()},n.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(n)}get(e,t,n){return window.translations&&(e="trans."+e),super.get(e,t,n)}set(e,t){return salla.helpers.setNested(this.messages[this.getLocale()+".trans"],e,t),this}},pn.form=new class{async submit(e,t=null){let n=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(),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.normalRequest(e,n,"post").finally((()=>{loaderSupported&&t?.submitter?.parentElement.stop()}));let r=e.split("."),i=r.splice(-1);return await salla.call(r.join("."))[i](n).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,n=!1){if(!e)return;if("object"!=typeof e)return e;let r;for(let n=0;n<t.length&&!(r=e[t[n]])&&!("undefined"!=typeof FormData&&e instanceof FormData&&(r=e.get(t[n])));n++);return r=r||e,"object"!=typeof r||n?r:void 0}},pn.helpers.app=new class{toggleClassIf(e,t,n,r){return document.querySelectorAll(e).forEach((e=>this.toggleElementClassIf(e,t,n,r))),this}toggleElementClassIf(e,t,n,r){t=Array.isArray(t)?t:t.split(" "),n=Array.isArray(n)?n:n.split(" ");let i=r(e);return e?.classList.remove(...i?n:t),e?.classList.add(...i?t:n),this}isValidEmail(e){return/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(e).toLowerCase())}element(e){return"object"==typeof e?e:document.querySelector(e)}watchElement(e,t){return this[e]=this.element(t),this}watchElements(e){return Object.entries(e).forEach((e=>this.watchElement(e[0],e[1]))),this}on(e,t,n,r={}){return"object"==typeof t?(this.element(t).addEventListener(e,n,r),this):(document.querySelectorAll(t).forEach((t=>t.addEventListener(e,n,r))),this)}onClick(e,t){return this.on("click",e,t)}onKeyUp(e,t){return this.on("keyup",e,t)}onEnter(e,t){return this.onKeyUp(e,(e=>13===e.keyCode&&t(e))),this}all(e,t){return document.querySelectorAll(e).forEach(t),this}hideElement(e){return this.element(e).style.display="none",this}showElement(e,t="block"){return this.element(e).style.display=t,this}removeClass(e,t){return this.element(e).classList.remove(...Array.from(arguments).slice(1)),this}addClass(e,t){return this.element(e).classList.add(...Array.from(arguments).slice(1)),this}debounce(e,...t){return this.debounce_||(this.debounce_=Salla.helpers.debounce(((e,...t)=>e(...t)),500)),this.debounce_(e,...t)}},pn.infiniteScroll=new class extends bn{constructor(e,t){super(e,t),this.options={path:".infinite-scroll-btn",history:"push",status:".infinite-scroll-status",append:".list-block"},this.fetchOptions={headers:{"S-INFINITE-SCROLL":!0}},this.instances=[]}initiate(e,t,n){n=this.getCustomOptions(t,n);let r="string"!=typeof e?e:document.querySelector(e),i=n.path;if(!r||!i||"string"==typeof i&&!document.querySelector(i))return void Salla.logger.warn(r?"Path Option (a link that has next page link) Not Existed!":"Container For InfiniteScroll not Existed!");let a=new Wn(r,n);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}}(void 0,salla.event.infiniteScroll),pn.api=new class extends class{constructor(){salla.event.on("twilight::initiated",(()=>this.initiateRequest())),salla.event.on("profile::info.fetched",(e=>this.setCurrencyAndLanguage(e))),salla.event.on("auth::token.fetched",(e=>{salla.storage.set("token",e),this.setToken(e),salla.cart.api.reset()})),this.notifier_handler_disabled=!1,this.axios=ga.create({headers:{common:{"X-Requested-With":"XMLHttpRequest","S-SOURCE":"twilight","S-APP-VERSION":"v2.0.0","S-APP-OS":"browser"}}})}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}))}initiateRequest(){this.axios.defaults.baseURL=Salla.config.get("store.api",Salla.config.get("store.url")),this.setHeaders({"Store-Identifier":Salla.config.get("store.id"),currency:Salla.config.get("user.currency_code","SAR"),"accept-language":salla.lang.getLocale(),"s-user-id":Salla.config.get("user.id")});let e=salla.storage.get("scope");e&&this.setHeaders({"s-scope-type":e.type,"s-scope-id":e.id}),this.injectTokenToTheRequests()}injectTokenToTheRequests(){let e=salla.storage.get("token"),t=Salla.config.isGuest(),n=salla.storage.get("cart");if(n&&(n.user_id!==Salla.config.get("user.id")||n.store_id!==Salla.config.get("store.id")))return salla.log("Auth:: The cart is not belong to current "+(n.user_id!==Salla.config.get("user.id")?"user":"store")+"!"),void salla.cart.api.reset();if(t&&!e)return;if(t&&e)return salla.log("Auth:: Token without user!"),salla.storage.remove("token"),void salla.cart.api.reset();if(!e)return salla.cart.api.reset(),void salla.auth.api.refresh();let r=function(e,t){if("string"!=typeof e)throw new ba("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(ya(e.split(".")[n]))}catch(e){throw new ba("Invalid token specified: "+e.message)}}(e);return Date.now()/1e3>r.exp?(salla.log("Auth:: An expired token!"),salla.storage.remove("token"),salla.cart.api.reset(),void salla.auth.api.refresh()):r.sub!==Salla.config.get("user.id")?(salla.log("Auth:: The user id is not match the token details!"),salla.storage.remove("token"),salla.cart.api.reset(),void salla.auth.api.refresh()):void this.setToken(e)}setToken(e){return this.setHeader("Authorization","Bearer "+e)}setCurrencyAndLanguage(e){return this.setHeaders({currency:e.data.currency,"accept-language":e.data.language})}request(e,t,n="get",r={}){let i={endPoint:e,payload:t,method:n,options:r},a="undefined"!=typeof event?event.currentTarget:null,s=!1;return"SALLA-BUTTON"===a?.tagName&&(s=!0),s&&a?.load(),this.axios[i.method](i.endPoint,i.payload,i.options).then((e=>(s&&a?.stop(),e.data&&e.request&&(e=e.data),this.handleAfterResponseActions(e),e))).catch((e=>{throw s&&a?.stop(),salla.event.document.requestFailed(i,e),this.handleErrorResponse(e),e}))}handleAfterResponseActions(e){if(!e)return;let{data:t,googleTags:n=null}=e,r=t&&t.googleTags?t.googleTags:n;dataLayer&&r&&dataLayer.push(r),this.fireEventsForResponse(e),this.showAlert(e),this.renderSections(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,n=[];Object.keys(t).forEach((e=>{let r=t[e];Array.isArray(r)?r.forEach((e=>n.push(e))):n.push(r)}));let r=(n.length>1?"* ":"")+n.join("\n* ");salla.error(r,e)}isFastRequestsAllowed(){return Salla.config.get("fastRequests")}promise(e,t=!0){return new Promise(((n,r)=>t?n(e):r(e)))}errorPromise(e){return this.promise(e,!1)}successPromise(e){return this.promise(e,!0)}renderSections(e){e.sections&&Object.keys(e.sections).forEach((t=>{document.querySelectorAll(t.toSelector()).forEach((function(n){n.innerHTML=e.sections[t]}))}))}}{constructor(){super(),this.auth=new Yn,this.cart=new Zn,this.loyalty=new Xn,this.order=new er,this.rating=new sr,this.product=new tr,this.profile=new nr,this.comment=new rr,this.currency=new ir,this.document=new ar,this.wishlist=new or,this.scope=new lr,this.booking=new cr}},pn.cart=new bn(pn.api.cart,pn.event.cart),pn.auth=new bn(pn.api.auth,pn.event.auth),pn.order=new bn(pn.api.order,pn.event.order),pn.scope=new bn(pn.api.scope,pn.event.scope),pn.rating=new bn(pn.api.rating,pn.event.rating),pn.comment=new bn(pn.api.comment,pn.event.comment),pn.loyalty=new bn(pn.api.loyalty,pn.event.loyalty),pn.product=new bn(pn.api.product,pn.event.product),pn.profile=new bn(pn.api.profile,pn.event.profile),pn.currency=new bn(pn.api.currency,pn.event.currency),pn.document=new bn(pn.api.document,pn.event.document),pn.wishlist=new bn(pn.api.wishlist,pn.event.wishlist),pn.booking=new bn(pn.api.booking,pn.event.booking),pn.call=e=>{let t=pn,n=e.split(".");for(;n.length&&(t=t[n.shift()]););return t},pn.init=e=>new wa(e),salla.event.once("twilight::init",salla.init),salla.event.once("twilight::api",(e=>{let t=e?.events;t&&salla.event.dispatchEvents(t)})),pn.success=pn.notify.success,pn.error=pn.notify.error,pn.versions.twilight="2.9.42",pn.event.dispatch("twilight::ready"),pn.onInitiated=e=>salla.event.once("twilight::initiated",e),pn.onReady=pn.onReady||function(e){"ready"!==salla.status?pn.onInitiated(e):e()},window.dispatchEvent(new CustomEvent("salla::created")),e.default=pn,Object.defineProperty(e,"__esModule",{value:!0})}));
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 n=/^({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])$/,r=/({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])/,i={locale:"en"},a=function(t){t=t||{},this.locale=t.locale||e()||i.locale,this.fallback=t.fallback,this.messages=t.messages};return a.prototype.setMessages=function(e){this.messages=e},a.prototype.getLocale=function(){return this.locale||this.fallback},a.prototype.setLocale=function(e){this.locale=e},a.prototype.getFallback=function(){return this.fallback},a.prototype.setFallback=function(e){this.fallback=e},a.prototype.has=function(e,t){return!("string"!=typeof e||!this.messages)&&null!==this._getMessage(e,t)},a.prototype.get=function(e,t,n){if(!this.has(e,n))return e;var r=this._getMessage(e,n);return null===r?e:(t&&(r=this._applyReplacements(r,t)),r)},a.prototype.trans=function(e,t){return this.get(e,t)},a.prototype.choice=function(e,t,n,i){(n=void 0!==n?n:{}).count=t;var a=this.get(e,n,i);if(null==a)return a;for(var s=a.split("|"),o=[],l=0;l<s.length;l++)if(s[l]=s[l].trim(),r.test(s[l])){var c=s[l].split(/\s/);o.push(c.shift()),s[l]=c.join(" ")}if(1===s.length)return a;for(var u=0;u<o.length;u++)if(this._testInterval(t,o[u]))return s[u];return i=i||this._getLocale(e),s[this._getPluralForm(t,i)]},a.prototype.transChoice=function(e,t,n){return this.choice(e,t,n)},a.prototype._parseKey=function(e,t){if("string"!=typeof e||"string"!=typeof t)return null;var n=e.split("."),r=n[0].replace(/\//g,".");return{source:t+"."+r,sourceFallback:this.getFallback()+"."+r,entries:n.slice(1)}},a.prototype._getMessage=function(e,t){if(t=t||this.getLocale(),e=this._parseKey(e,t),void 0===this.messages[e.source]&&void 0===this.messages[e.sourceFallback])return null;var n=this.messages[e.source],r=e.entries.slice(),i=r.join(".");if("string"!=typeof(n=void 0!==n?this._getValueInKey(n,i):void 0)&&this.messages[e.sourceFallback])for(n=this.messages[e.sourceFallback],r=e.entries.slice(),i="";r.length&&void 0!==n;)n[i=i?i.concat(".",r.shift()):r.shift()]&&(n=n[i],i="");return"string"!=typeof n?null:n},a.prototype._getValueInKey=function(e,t){if("string"==typeof e[t])return e[t];for(var n=(t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"")).split("."),r=0,i=n.length;r<i;++r){var a=n.slice(0,r+1).join("."),s=n.slice(r+1,n.length).join(".");if(e[a])return this._getValueInKey(e[a],s)}return e},a.prototype._getLocale=function(e){return e=this._parseKey(e,this.locale),this.messages[e.source]?this.locale:this.messages[e.sourceFallback]?this.fallback:null},a.prototype._findMessageInTree=function(e,t){for(;e.length&&void 0!==t;){var n=e.join(".");if(t[n]){t=t[n];break}t=t[e.shift()]}return t},a.prototype._sortReplacementKeys=function(e,t){return t.length-e.length},a.prototype._applyReplacements=function(e,t){return Object.keys(t).sort(this._sortReplacementKeys).forEach((function(n){e=e.replace(new RegExp(":"+n,"gi"),(function(e){var r=t[n];return e===e.toUpperCase()?r.toUpperCase():e===e.replace(/\w/i,(function(e){return e.toUpperCase()}))?r.charAt(0).toUpperCase()+r.slice(1):r}))})),e},a.prototype._testInterval=function(e,r){if("string"!=typeof r)throw"Invalid interval: should be a string.";var i=(r=r.trim()).match(n);if(!i)throw"Invalid interval: "+r;if(!i[2]){var a=(i=i.filter((function(e){return!!e})))[1],s=t(i[2]);s===1/0&&(s=-1/0);var o=t(i[3]),l=i[4];return("["===a?e>=s:e>s)&&("]"===l?e<=o:e<o)}for(var c=i[2].split(","),u=0;u<c.length;u++)if(parseInt(c[u],10)===e)return!0;return!1},a.prototype._getPluralForm=function(e,t){switch(t){case"az":case"bo":case"dz":case"id":case"ja":case"jv":case"ka":case"km":case"kn":case"ko":case"ms":case"th":case"tr":case"vi":case"zh":default:return 0;case"af":case"bn":case"bg":case"ca":case"da":case"de":case"el":case"en":case"eo":case"es":case"et":case"eu":case"fa":case"fi":case"fo":case"fur":case"fy":case"gl":case"gu":case"ha":case"he":case"hu":case"is":case"it":case"ku":case"lb":case"ml":case"mn":case"mr":case"nah":case"nb":case"ne":case"nl":case"nn":case"no":case"om":case"or":case"pa":case"pap":case"ps":case"pt":case"so":case"sq":case"sv":case"sw":case"ta":case"te":case"tk":case"ur":case"zu":return 1==e?0:1;case"am":case"bh":case"fil":case"fr":case"gun":case"hi":case"hy":case"ln":case"mg":case"nso":case"xbr":case"ti":case"wa":return 0===e||1===e?0:1;case"be":case"bs":case"hr":case"ru":case"sr":case"uk":return e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2;case"cs":case"sk":return 1==e?0:e>=2&&e<=4?1:2;case"ga":return 1==e?0:2==e?1:2;case"lt":return e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2;case"sl":return e%100==1?0:e%100==2?1:e%100==3||e%100==4?2:3;case"mk":return e%10==1?0:1;case"mt":return 1==e?0:0===e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3;case"lv":return 0===e?0:e%10==1&&e%100!=11?1:2;case"pl":return 1==e?0:e%10>=2&&e%10<=4&&(e%100<12||e%100>14)?1:2;case"cy":return 1==e?0:2==e?1:8==e||11==e?2:3;case"ro":return 1==e?0:0===e||e%100>0&&e%100<20?1:2;case"ar":return 0===e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11&&e%100<=99?4:5}},a}()}(Qn);var Jn=Qn.exports;class Kn{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,n=null){let r=Array.isArray(e),i=r?this.getUrl(...e):this.getUrl(e);e=r?e[0]:e,n=n||this.endpointsMethods[e]||"post";let a=this.endpointsHeaders[e];if("get"===n&&t instanceof FormData){let e={};Array.from(t.entries()).forEach((function(t){e[t[0]]=t[1]})),t={params:e}}return a&&"get"===n&&(t=t?Object.assign(t,a):a),this.webEndpoints.includes(e)?i=salla.url.get(i):"http"!==i.substring(0,4)&&(i=salla.url.api(i)),Salla.api.request(i,t,n,{headers:a})}request(e,t,n=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,n)):this.normalRequest(e,t,n)}getUrl(e){let t=this.endpoints[e]||e;const n=/{[^{}]+}/i;for(let e=1;e<arguments.length;e++)t=t.replace(n,arguments[e]);return t}event(){return salla.event[this.className]}}class Zn extends Kn{constructor(){super(),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",getQuickCheckout:"checkout/quick-checkout",createQuickCheckout:"checkout/quick-checkout"},this.endpointsMethods={latest:"get",details:"get",status:"get",updateItem:"post",deleteItem:"delete",deleteImage:"delete",deleteCoupon:"put",getQuickCheckout:"get"},this.webEndpoints=["latest"],this.latestCart=null,this.after_init()}async getCurrentCartId(){if(this.latestCart)return this.latestCart.cart.id;let e=await this.latest();return this.latestCart=e.data,this.latestCart.cart.id}getUploadImageEndpoint(e){return salla.url.api(this.getUrl("uploadImage",e||salla.storage.get("cart.id")))}latest(){return this.request("latest",{params:{source:""}}).then((e=>(salla.storage.set("cart",e.data.cart),salla.event.cart.latestFetched(e),e))).catch((e=>{throw salla.storage.set("cart",""),salla.event.cart.latestFailed(e),e}))}async details(){let e=await this.getCurrentCartId();return this.request(["details",e]).then((function(e){return salla.cart.event.detailsFetched(e),e})).catch((function(e){throw salla.cart.event.detailsNotFetched(e),e}))}async quickAdd(e,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 n=salla.form.getPossibleValue(t.payload,["endpoint"]);n&&["addItem","quickAdd"].includes(n)||(n=salla.form.getPossibleValue(t.payload,["quantity","donating_amount"])?"addItem":"quickAdd");let r=await this.getCurrentCartId();return this.request([n,r,t.id],t.payload).then((function(e){return salla.cart.event.itemAdded(e,t.id),e})).catch((function(e){throw salla.cart.event.itemAddedFailed(e,t.id),e}))}async deleteItem(e){let t=this.getCartPayload(e);if(!t.id){let e='There is no "id"!';return salla.cart.event.itemDeletedFailed(e),salla.api.errorPromise(e)}let n=await this.getCurrentCartId();return this.request(["deleteItem",n,t.id]).then((function(e){return salla.cart.event.itemDeleted(e,t.id),e})).catch((function(e){throw salla.cart.event.itemDeletedFailed(e,t.id),e}))}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 n=await this.getCurrentCartId();return"Object"===t.payload.constructor?.name?t.payload._method="PUT":t.payload.append("_method","PUT"),this.request(["updateItem",n,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 this.getCurrentCartId();return this.request(["deleteImage",t,e]).then((function(t){return salla.cart.event.imageDeleted(t,e),t})).catch((function(t){throw salla.cart.event.imageNotDeleted(t,e),t}))}async status(e){return this.request(["status",e||await this.getCurrentCartId()],{params:{has_apple_pay:!!window.ApplePaySession}})}async submit(){this.status(await this.getCurrentCartId()).then((e=>{let t=e.data.next_step.to;if(!["checkout","refresh","login"].includes(t)){let e="Can't find next_step );";throw salla.cart.event.submitFailed(e),e}if(salla.cart.event.submitted(e),"login"===t)return salla.auth.setCanRedirect(!1),salla.event.dispatch("login::open"),void salla.auth.event.onLoggedIn((e=>{salla.event.dispatch("login::close"),this.submit()}));"checkout"===t?window.location.href=e.data.next_step.url+(window.ApplePaySession?"?has_apple_pay=true":""):window.location.reload()})).catch((function(e){throw salla.cart.event.submitFailed(e),e}))}getCartPayload(e){let t=e?.data||("object"==typeof e?e:void 0);return e=t?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,n=null){return super.normalRequest(e,t,n).catch((e=>{throw 403===e?.response?.status&&(salla.storage.remove("cart"),salla.error(salla.lang.get("pages.checkout.try_again"))),e}))}reset(){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();return this.request(["addCoupon",t],{coupon:e}).then((function(e){return salla.event.cart.couponAdded(e,t),e})).catch((function(e){throw salla.event.cart.couponAdditionFailed(e,t),e}))}async deleteCoupon(){let e=await salla.cart.api.getCurrentCartId();return this.request(["deleteCoupon",e],{}).then((function(t){return salla.event.cart.couponDeleted(t,e),t})).catch((function(t){throw salla.event.cart.couponDeletionFailed(t,e),t}))}getQuickCheckoutSettings(){return this.request("getQuickCheckout").then((e=>(salla.event.cart.quickCheckoutSettingFetched(e),e))).catch((e=>{throw salla.event.cart.quickCheckoutSettingFailed(e),e}))}createQuickCheckout(e){return this.request("createQuickCheckout",e).then((e=>(salla.event.cart.quickCheckoutSucceeded(e),e))).catch((e=>{throw salla.event.cart.quickCheckoutFailed(e),e}))}}class Xn extends Kn{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())){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())){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 Yn extends Kn{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.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 n=salla.form.getPossibleValue(e,["type"]);if(!n){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 r=await this.request(["verify",n],e);if(200!==r?.status)return salla.auth.event.verificationFailed(r,n),salla.api.errorPromise(r);let i="authenticated"===r.data?.case;return i&&salla.auth.event.tokenFetched(r.data.token),t&&await this.request("auth/jwt"),i&&salla.auth.event.loggedIn(r),salla.auth.event.verified(r,n),salla.auth.api.afterUserLogin(),salla.api.successPromise(r)}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 function(e){return salla.auth.event.registered.call(t,e),"authenticated"===e.data?.case&&(salla.auth.event.tokenFetched(e.data.token),await salla.auth.request("auth/jwt"),salla.auth.event.loggedIn(e),salla.auth.api.afterUserLogin()),e})).catch((function(e){throw salla.auth.event.registrationFailed.call(t,e),e}))}logout(){return this.request("logout").then((function(e){return salla.storage.clearAll(),salla.cookie.clearAll(),salla.auth.event.loggedOut(e),salla.log("Reloading after 0.2 sec..."),setTimeout((()=>location.reload()),200),e})).catch((function(e){throw salla.auth.event.failedLogout(e),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 er extends Kn{constructor(){super(),this.namespace="order",this.endpoints={cancel:"orders/cancel/{id}",createCartFromOrder:"reorder/{id}",sendInvoice:"orders/send/{id}"},this.endpointsMethods={createCartFromOrder:"get"},this.after_init()}show(e){let t=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:!!window.ApplePaySession}}).then((function(t){return salla.event.order.canceled(t,e),t})).catch((function(t){throw salla.event.order.notCanceled(t,e),t}))}createCartFromOrder(e){return e=e||salla.config.get("page.id"),this.request(["createCartFromOrder",e]).then((function(t){return salla.storage.set("cart",{id:t.data.cart_id,user_id:salla.config.get("user.id")}),salla.event.order.orderCreated(t,e),window.location.href=t.data.url,t})).catch((function(t){throw salla.event.order.orderCreationFailed(t,e),t}))}sendInvoice(e){let t=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}))}}class tr extends Kn{constructor(){super(),this.namespace="product",this.previousQuery="",this.endpoints={getPrice:"products/{id}/price",availabilitySubscribe:"products/{id}/availability-notify",search:"products/search",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"},this.endpointsMethods={giftDetail:"get"},this.after_init()}getPrice(e){let t=e.data||e,n=salla.form.getPossibleValue(t,["id","prod_id","product_id"]);return this.request(["getPrice",n],"object"==typeof t?t:void 0).then((function(e){return salla.product.event.priceUpdated(e,n),e})).catch((function(e){throw salla.product.event.priceUpdateFailed(e,n),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.availabilitySubscribedFailed(t,e),t}))}search(e){let t=e.data;if(t||(t={params:"string"==typeof e?{query:e}:e}),!(e=t instanceof FormData?t.get("query"):t.query||t.params?.query)){let e='There is no "query"!';return salla.product.event.searchFailed(e),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.offer.event.fetchDetailsFailed(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}))}addGiftToCart(e,t,n=!1){return this.request(["giftToCart",e],t).then((t=>(salla.product.event.addGiftToCartSucceeded(t,e),n&&(window.location.href=t.redirect),response))).catch((t=>{throw salla.product.event.addGiftToCartFailed(t,e),t}))}uploadGiftImage(e){return this.request("giftImage",e).then((e=>(salla.product.event.giftImageUploadSucceeded(e),e))).catch((e=>{throw salla.product.event.giftImageUploadFailed(e),e}))}}class nr extends Kn{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 rr extends Kn{constructor(){super(),this.namespace="comment",this.endpoints={add:"{type}/{id}/comments"},this.after_init()}add(e){e?.data&&(e=e.data);let t,n=salla.form.getPossibleValue(e,["id"]),r=salla.form.getPossibleValue(e,["type"]),i=salla.form.getPossibleValue(e,["comment"]);return n?r&&["products","pages","product","page"].includes(r)?i?(r+=["product","page"].includes(r)?"s":"",this.request(["add",r,n],{comment:i}).then((function(e){return salla.event.comment.added(e,n),e})).catch((function(e){throw salla.event.comment.additionFailed(e,n),e}))):(salla.event.comment.additionFailed(t="can't find comment content!"),salla.api.errorPromise(t)):(salla.event.comment.additionFailed(t="Failed to get type one of:(products, product, page, pages)!"),salla.api.errorPromise(t)):(salla.event.comment.additionFailed(t="Failed to get id!"),salla.api.errorPromise(t))}}class ir extends Kn{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 ar extends Kn{constructor(){super(),this.namespace="document"}}class sr extends Kn{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:{},n=salla.form.getPossibleValue(e?.data||e,["order_id","id"]);if(!n){let e='There is no "order_id"!';return salla.event.rating.orderNotFetched(e),salla.api.errorPromise(e)}return this.request(["order",n],t).then((function(e){return salla.event.rating.orderFetched(e,n),e})).catch((function(e){throw salla.event.rating.orderNotFetched(e,n),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 or extends Kn{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 n=salla.storage.get("salla::wishlist",[]);t?n.push(e):n.splice(n.indexOf(e),1),salla.storage.set("salla::wishlist",n)}}class lr extends Kn{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),resp}))}}class cr extends Kn{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}))}}var ur,dr={exports:{}},hr=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}},fr=hr,pr=Object.prototype.toString,gr=(ur=Object.create(null),function(e){var t=pr.call(e);return ur[t]||(ur[t]=t.slice(8,-1).toLowerCase())});function mr(e){return e=e.toLowerCase(),function(t){return gr(t)===e}}function vr(e){return Array.isArray(e)}function yr(e){return void 0===e}var br=mr("ArrayBuffer");function wr(e){return null!==e&&"object"==typeof e}function _r(e){if("object"!==gr(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}var Sr=mr("Date"),Er=mr("File"),xr=mr("Blob"),Ar=mr("FileList");function kr(e){return"[object Function]"===pr.call(e)}var Fr=mr("URLSearchParams");function Pr(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),vr(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}var Lr,Or=(Lr="undefined"!=typeof Uint8Array&&Object.getPrototypeOf(Uint8Array),function(e){return Lr&&e instanceof Lr}),Tr={isArray:vr,isArrayBuffer:br,isBuffer:function(e){return null!==e&&!yr(e)&&null!==e.constructor&&!yr(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||pr.call(e)===t||kr(e.toString)&&e.toString()===t)},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&br(e.buffer)},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:wr,isPlainObject:_r,isUndefined:yr,isDate:Sr,isFile:Er,isBlob:xr,isFunction:kr,isStream:function(e){return wr(e)&&kr(e.pipe)},isURLSearchParams:Fr,isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:Pr,merge:function e(){var t={};function n(n,r){_r(t[r])&&_r(n)?t[r]=e(t[r],n):_r(n)?t[r]=e({},n):vr(n)?t[r]=n.slice():t[r]=n}for(var r=0,i=arguments.length;r<i;r++)Pr(arguments[r],n);return t},extend:function(e,t,n){return Pr(t,(function(t,r){e[r]=n&&"function"==typeof t?fr(t,n):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,n,r){e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,n&&Object.assign(e.prototype,n)},toFlatObject:function(e,t,n){var r,i,a,s={};t=t||{};do{for(i=(r=Object.getOwnPropertyNames(e)).length;i-- >0;)s[a=r[i]]||(t[a]=e[a],s[a]=!0);e=Object.getPrototypeOf(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:gr,kindOfTest:mr,endsWith:function(e,t,n){e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;var r=e.indexOf(t,n);return-1!==r&&r===n},toArray:function(e){if(!e)return null;var t=e.length;if(yr(t))return null;for(var n=new Array(t);t-- >0;)n[t]=e[t];return n},isTypedArray:Or,isFileList:Ar},Cr=Tr;function jr(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var Rr=function(e,t,n){if(!t)return e;var r;if(n)r=n(t);else if(Cr.isURLSearchParams(t))r=t.toString();else{var i=[];Cr.forEach(t,(function(e,t){null!=e&&(Cr.isArray(e)?t+="[]":e=[e],Cr.forEach(e,(function(e){Cr.isDate(e)?e=e.toISOString():Cr.isObject(e)&&(e=JSON.stringify(e)),i.push(jr(t)+"="+jr(e))})))})),r=i.join("&")}if(r){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e},qr=Tr;function Ir(){this.handlers=[]}Ir.prototype.use=function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1},Ir.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},Ir.prototype.forEach=function(e){qr.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var Nr,Dr,Ur=Ir,Hr=Tr;function $r(){if(Dr)return Nr;Dr=1;var e=Tr;function t(e,t,n,r,i){Error.call(this),this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i)}e.inherits(t,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var n=t.prototype,r={};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){r[e]={value:e}})),Object.defineProperties(t,r),Object.defineProperty(n,"isAxiosError",{value:!0}),t.from=function(r,i,a,s,o,l){var c=Object.create(n);return e.toFlatObject(r,c,(function(e){return e!==Error.prototype})),t.call(c,r.message,i,a,s,o),c.name=r.name,l&&Object.assign(c,l),c},Nr=t}var Mr,zr,Br,Gr,Vr,Wr,Qr={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};function Jr(){if(zr)return Mr;zr=1;var e=Tr;return Mr=function(t,r){r=r||new FormData;var i=[];function a(t){return null===t?"":e.isDate(t)?t.toISOString():e.isArrayBuffer(t)||e.isTypedArray(t)?"function"==typeof Blob?new Blob([t]):n.Buffer.from(t):t}return function t(n,s){if(e.isPlainObject(n)||e.isArray(n)){if(-1!==i.indexOf(n))throw Error("Circular reference detected in "+s);i.push(n),e.forEach(n,(function(n,i){if(!e.isUndefined(n)){var o,l=s?s+"."+i:i;if(n&&!s&&"object"==typeof n)if(e.endsWith(i,"{}"))n=JSON.stringify(n);else if(e.endsWith(i,"[]")&&(o=e.toArray(n)))return void o.forEach((function(t){!e.isUndefined(t)&&r.append(l,a(t))}));t(n,l)}})),i.pop()}else r.append(s,a(n))}(t),r},Mr}function Kr(){if(Gr)return Br;Gr=1;var e=$r();return Br=function(t,n,r){var i=r.config.validateStatus;r.status&&i&&!i(r.status)?n(new e("Request failed with status code "+r.status,[e.ERR_BAD_REQUEST,e.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):t(r)}}function Zr(){if(Wr)return Vr;Wr=1;var e=Tr;return Vr=e.isStandardBrowserEnv()?{write:function(t,n,r,i,a,s){var o=[];o.push(t+"="+encodeURIComponent(n)),e.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),e.isString(i)&&o.push("path="+i),e.isString(a)&&o.push("domain="+a),!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 Xr,Yr,ei,ti,ni,ri,ii,ai,si,oi,li,ci,ui=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},di=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},hi=function(e,t){return e&&!ui(t)?di(e,t):t};function fi(){if(Yr)return Xr;Yr=1;var e=Tr,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 Xr=function(n){var r,i,a,s={};return n?(e.forEach(n.split("\n"),(function(n){if(a=n.indexOf(":"),r=e.trim(n.substr(0,a)).toLowerCase(),i=e.trim(n.substr(a+1)),r){if(s[r]&&t.indexOf(r)>=0)return;s[r]="set-cookie"===r?(s[r]?s[r]:[]).concat([i]):s[r]?s[r]+", "+i:i}})),s):s}}function pi(){if(ti)return ei;ti=1;var e=Tr;return ei=e.isStandardBrowserEnv()?function(){var t,n=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function i(e){var t=e;return n&&(r.setAttribute("href",t),t=r.href),r.setAttribute("href",t),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return t=i(window.location.href),function(n){var r=e.isString(n)?i(n):n;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0}}function gi(){if(ri)return ni;ri=1;var e=$r();function t(t){e.call(this,null==t?"canceled":t,e.ERR_CANCELED),this.name="CanceledError"}return Tr.inherits(t,e,{__CANCEL__:!0}),ni=t}function mi(){return ai?ii:(ai=1,ii=function(e){var t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""})}function vi(){if(oi)return si;oi=1;var e=Tr,t=Kr(),n=Zr(),r=Rr,i=hi,a=fi(),s=pi(),o=Qr,l=$r(),c=gi(),u=mi();return si=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 b=new XMLHttpRequest;if(d.auth){var w=d.auth.username||"",_=d.auth.password?unescape(encodeURIComponent(d.auth.password)):"";m.Authorization="Basic "+btoa(w+":"+_)}var S=i(d.baseURL,d.url);function E(){if(b){var e="getAllResponseHeaders"in b?a(b.getAllResponseHeaders()):null,n={data:v&&"text"!==v&&"json"!==v?b.response:b.responseText,status:b.status,statusText:b.statusText,headers:e,config:d,request:b};t((function(e){h(e),y()}),(function(e){f(e),y()}),n),b=null}}if(b.open(d.method.toUpperCase(),r(S,d.params,d.paramsSerializer),!0),b.timeout=d.timeout,"onloadend"in b?b.onloadend=E:b.onreadystatechange=function(){b&&4===b.readyState&&(0!==b.status||b.responseURL&&0===b.responseURL.indexOf("file:"))&&setTimeout(E)},b.onabort=function(){b&&(f(new l("Request aborted",l.ECONNABORTED,d,b)),b=null)},b.onerror=function(){f(new l("Network Error",l.ERR_NETWORK,d,b,b)),b=null},b.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,b)),b=null},e.isStandardBrowserEnv()){var x=(d.withCredentials||s(S))&&d.xsrfCookieName?n.read(d.xsrfCookieName):void 0;x&&(m[d.xsrfHeaderName]=x)}"setRequestHeader"in b&&e.forEach(m,(function(e,t){void 0===g&&"content-type"===t.toLowerCase()?delete m[t]:b.setRequestHeader(t,e)})),e.isUndefined(d.withCredentials)||(b.withCredentials=!!d.withCredentials),v&&"json"!==v&&(b.responseType=d.responseType),"function"==typeof d.onDownloadProgress&&b.addEventListener("progress",d.onDownloadProgress),"function"==typeof d.onUploadProgress&&b.upload&&b.upload.addEventListener("progress",d.onUploadProgress),(d.cancelToken||d.signal)&&(p=function(e){b&&(f(!e||e&&e.type?new c:e),b.abort(),b=null)},d.cancelToken&&d.cancelToken.subscribe(p),d.signal&&(d.signal.aborted?p():d.signal.addEventListener("abort",p))),g||(g=null);var A=u(S);A&&-1===["http","https","file"].indexOf(A)?f(new l("Unsupported protocol "+A+":",l.ERR_BAD_REQUEST,d)):b.send(g)}))},si}var yi=Tr,bi=function(e,t){Hr.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))},wi=$r(),_i=Qr,Si=Jr(),Ei={"Content-Type":"application/x-www-form-urlencoded"};function xi(e,t){!yi.isUndefined(e)&&yi.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var Ai,ki={transitional:_i,adapter:(("undefined"!=typeof XMLHttpRequest||void 0!==i.default&&"[object process]"===Object.prototype.toString.call(i.default))&&(Ai=vi()),Ai),transformRequest:[function(e,t){if(bi(t,"Accept"),bi(t,"Content-Type"),yi.isFormData(e)||yi.isArrayBuffer(e)||yi.isBuffer(e)||yi.isStream(e)||yi.isFile(e)||yi.isBlob(e))return e;if(yi.isArrayBufferView(e))return e.buffer;if(yi.isURLSearchParams(e))return xi(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString();var n,r=yi.isObject(e),i=t&&t["Content-Type"];if((n=yi.isFileList(e))||r&&"multipart/form-data"===i){var a=this.env&&this.env.FormData;return Si(n?{"files[]":e}:e,a&&new a)}return r||"application/json"===i?(xi(t,"application/json"),function(e,t,n){if(yi.isString(e))try{return(t||JSON.parse)(e),yi.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||ki.transitional,n=t&&t.silentJSONParsing,r=t&&t.forcedJSONParsing,i=!n&&"json"===this.responseType;if(i||r&&yi.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(i){if("SyntaxError"===e.name)throw wi.from(e,wi.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:ci?li:(ci=1,li=null)},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};yi.forEach(["delete","get","head"],(function(e){ki.headers[e]={}})),yi.forEach(["post","put","patch"],(function(e){ki.headers[e]=yi.merge(Ei)}));var Fi,Pi,Li=ki,Oi=Tr,Ti=Li;function Ci(){return Pi?Fi:(Pi=1,Fi=function(e){return!(!e||!e.__CANCEL__)})}var ji=Tr,Ri=function(e,t,n){var r=this||Ti;return Oi.forEach(n,(function(n){e=n.call(r,e,t)})),e},qi=Ci(),Ii=Li,Ni=gi();function Di(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Ni}var Ui,Hi,$i=Tr,Mi=function(e,t){t=t||{};var n={};function r(e,t){return $i.isPlainObject(e)&&$i.isPlainObject(t)?$i.merge(e,t):$i.isPlainObject(t)?$i.merge({},t):$i.isArray(t)?t.slice():t}function i(n){return $i.isUndefined(t[n])?$i.isUndefined(e[n])?void 0:r(void 0,e[n]):r(e[n],t[n])}function a(e){if(!$i.isUndefined(t[e]))return r(void 0,t[e])}function s(n){return $i.isUndefined(t[n])?$i.isUndefined(e[n])?void 0:r(void 0,e[n]):r(void 0,t[n])}function o(n){return n in t?r(e[n],t[n]):n in e?r(void 0,e[n]):void 0}var l={url:a,method:a,data:a,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 $i.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=l[e]||i,r=t(e);$i.isUndefined(r)&&t!==o||(n[e]=r)})),n};function zi(){return Hi?Ui:(Hi=1,Ui={version:"0.27.2"})}var Bi=zi().version,Gi=$r(),Vi={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){Vi[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));var Wi={};Vi.transitional=function(e,t,n){function r(e,t){return"[Axios v"+Bi+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(n,i,a){if(!1===e)throw new Gi(r(i," has been removed"+(t?" in "+t:"")),Gi.ERR_DEPRECATED);return t&&!Wi[i]&&(Wi[i]=!0,console.warn(r(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,i,a)}};var Qi,Ji,Ki,Zi,Xi,Yi,ea={assertOptions:function(e,t,n){if("object"!=typeof e)throw new Gi("options must be an object",Gi.ERR_BAD_OPTION_VALUE);for(var r=Object.keys(e),i=r.length;i-- >0;){var a=r[i],s=t[a];if(s){var o=e[a],l=void 0===o||s(o,a,e);if(!0!==l)throw new Gi("option "+a+" must be "+l,Gi.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new Gi("Unknown option "+a,Gi.ERR_BAD_OPTION)}},validators:Vi},ta=Tr,na=Rr,ra=Ur,ia=function(e){return Di(e),e.headers=e.headers||{},e.data=Ri.call(e,e.data,e.headers,e.transformRequest),e.headers=ji.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),ji.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||Ii.adapter)(e).then((function(t){return Di(e),t.data=Ri.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return qi(t)||(Di(e),t&&t.response&&(t.response.data=Ri.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},aa=Mi,sa=hi,oa=ea,la=oa.validators;function ca(e){this.defaults=e,this.interceptors={request:new ra,response:new ra}}ca.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=aa(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var n=t.transitional;void 0!==n&&oa.assertOptions(n,{silentJSONParsing:la.transitional(la.boolean),forcedJSONParsing:la.transitional(la.boolean),clarifyTimeoutError:la.transitional(la.boolean)},!1);var r=[],i=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(i=i&&e.synchronous,r.unshift(e.fulfilled,e.rejected))}));var a,s=[];if(this.interceptors.response.forEach((function(e){s.push(e.fulfilled,e.rejected)})),!i){var o=[ia,void 0];for(Array.prototype.unshift.apply(o,r),o=o.concat(s),a=Promise.resolve(t);o.length;)a=a.then(o.shift(),o.shift());return a}for(var l=t;r.length;){var c=r.shift(),u=r.shift();try{l=c(l)}catch(e){u(e);break}}try{a=ia(l)}catch(e){return Promise.reject(e)}for(;s.length;)a=a.then(s.shift(),s.shift());return a},ca.prototype.getUri=function(e){e=aa(this.defaults,e);var t=sa(e.baseURL,e.url);return na(t,e.params,e.paramsSerializer)},ta.forEach(["delete","get","head","options"],(function(e){ca.prototype[e]=function(t,n){return this.request(aa(n||{},{method:e,url:t,data:(n||{}).data}))}})),ta.forEach(["post","put","patch"],(function(e){function t(t){return function(n,r,i){return this.request(aa(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}ca.prototype[e]=t(),ca.prototype[e+"Form"]=t(!0)}));var ua=Tr,da=hr,ha=ca,fa=Mi;var pa=function e(t){var n=new ha(t),r=da(ha.prototype.request,n);return ua.extend(r,ha.prototype,n),ua.extend(r,n),r.create=function(n){return e(fa(t,n))},r}(Li);pa.Axios=ha,pa.CanceledError=gi(),pa.CancelToken=function(){if(Ji)return Qi;Ji=1;var e=gi();function t(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var n;this.promise=new Promise((function(e){n=e}));var r=this;this.promise.then((function(e){if(r._listeners){var t,n=r._listeners.length;for(t=0;t<n;t++)r._listeners[t](e);r._listeners=null}})),this.promise.then=function(e){var t,n=new Promise((function(e){r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},t((function(t){r.reason||(r.reason=new e(t),n(r.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,n=new t((function(t){e=t}));return{token:n,cancel:e}},Qi=t}(),pa.isCancel=Ci(),pa.VERSION=zi().version,pa.toFormData=Jr(),pa.AxiosError=$r(),pa.Cancel=pa.CanceledError,pa.all=function(e){return Promise.all(e)},pa.spread=Zi?Ki:(Zi=1,Ki=function(e){return function(t){return e.apply(null,t)}}),pa.isAxiosError=function(){if(Yi)return Xi;Yi=1;var e=Tr;return Xi=function(t){return e.isObject(t)&&!0===t.isAxiosError}}(),dr.exports=pa,dr.exports.default=pa;var ga=dr.exports;function ma(e){this.message=e}ma.prototype=new Error,ma.prototype.name="InvalidCharacterError";var va="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new ma("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,i=0,a=0,s="";r=t.charAt(a++);~r&&(n=i%4?64*n+r:r,i++%4)?s+=String.fromCharCode(255&n>>(-2*i&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return s};function ya(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(va(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return va(t)}}function ba(e){this.message=e}ba.prototype=new Error,ba.prototype.name="InvalidTokenError";class wa{constructor(e){"ready"!==pn.status?e?(pn.config.merge(e),e?.events&&pn.event.dispatchEvents(e?.events),e._token&&salla.api.setHeader("X-CSRF-TOKEN",e._token),this.injectMaintenanceAlert(),this.injectThemePreviewAlert(),this.injectEditAlert(),e?.user?.language_code&&salla.lang.setLocale(e?.user?.language_code),salla.lang.loadStoreTranslations(),this.setSallaReady(e)):this.setSallaReady(e):salla.log("Trying to re-initiate Salla, while its status === 'ready'!")}injectMaintenanceAlert(){salla.config.get("maintenance")&&(document.querySelector(".store-notify")?salla.logger.warn(".store-notify element Existed before!"):salla.lang.onLoaded((()=>{const e=document.createElement("div");e.classList.add("store-notify"),e.style="background-color: #d63031; color: #fff; padding: 10px 15px; text-align: center; font-size: 17px;",e.innerHTML=`<p style="margin:0 !important;">${salla.lang.get("blocks.header.maintenance_alert")}</p>`,document.body.prepend(e)})))}injectThemePreviewAlert(){"preview"===salla.config.get("theme.mode")&&(document.querySelector("#s-theme_preview_bar")?salla.logger.warn("#s-theme_preview_bar element Existed before!"):salla.lang.onLoaded((()=>{let e=document.createElement("div");e.id="s-theme_preview_bar",e.setAttribute("style","display: flex; justify-content: space-between; text-align: center; background-color: #232323; color: #fff; padding: 10px; font-size: 0.875rem; line-height: 1.25rem; position: relative;"),e.innerHTML=`\n <div style="display:flex; align-items:center;">\n <img width="32" src="https://assets.salla.sa/cp/assets/images/logo-new.png">\n <span style="margin:0 10px;">${salla.lang.get("blocks.header.preview_mode")}: <span style="background:rgba(255,255,255,0.25);border-radius:15px; padding:2px 15px 4px">${salla.config.get("theme.name")}</span></span>\n </div>\n <a href="${salla.url.get("preview_theme/cancel/preview")}" style="line-height:32px; width:32px;"><i class="sicon-cancel"></i></a>\n `,document.body.prepend(e)})))}injectEditAlert(){let e=salla.config.get("edit");e&&(document.querySelector("#s-edit-alert")?salla.logger.warn("#s-edit-alert element Existed before!"):salla.lang.onLoaded((()=>{let t=document.createElement("div");t.id="s-edit-alert",t.innerHTML=`\n <a href="${e}" style="display:block; background-color:${salla.config.get("theme.color.primary","#5cd5c4")}; color:${salla.config.get("theme.color.reverse","#fff")}; padding: 10px; text-align:center; font-size: 0.875rem; line-height: 1.25rem;">\n <i class="sicon-edit"></i> \n ${salla.lang.get("pages.products.quick_edit")}\n </a>\n `,document.body.prepend(t)})))}handleElementAjaxRequest(e,t){if(!(t instanceof HTMLFormElement||t instanceof HTMLAnchorElement))return salla.logger.warn("trying to call ajax from non Element!!"),!1;e.preventDefault();let n=t.getAjaxFormData(e),r=n.method?n.method.toLowerCase():void 0;salla.api.request(n.url,n.formData,r).then((e=>(e.data&&e.request&&(e=e.data),salla.api.handleAfterResponseActions(e),this.callAjaxEvent(n.events.success,e,n.formData),e))).catch((e=>{throw salla.api.handleErrorResponse(e),this.callAjaxEvent(n.events.fail,e,n.formData),e}))}callAjaxEvent(e,t,n){if(e){if(n instanceof FormData){const e={};Array.from(n.entries()).forEach((function(t){e[t[0]]=t[1]})),n=e}window[e]?window[e](t,n):salla.event.dispatch(e,t,n)}}setSallaReady(e){pn.status="ready",pn.event.dispatch("twilight::initiated",e),window.dispatchEvent(new CustomEvent("salla::ready"))}}pn.status="loading",pn.notify=yn,pn.lang=new class extends Jn{constructor(e){(e=e||{}).messages=e.messages||window.translations,e.locale=e.locale||(window.locale||navigator.language||navigator.userLanguage||"ar").split("-")[0],e.fallback=e.fallback||e.locale,super(e),this.translationsLoaded=!1}onLoaded(e){if(this.translationsLoaded)return e();Salla.event.once("languages::translations.loaded",e)}loadStoreTranslations(){if(this.messages)return void window.addEventListener("load",(e=>{salla.event.dispatch("languages::translations.loaded"),salla.logger.info("The messages of transactions is already loaded")}));if(!salla.url.get(""))return void this.loadScript("https://cdn.salla.network/js/translations.js",!1);let e=salla.config.get("theme.translations_hash",salla.config.get("store.id","twilight"));this.loadScript(salla.url.get(`languages/assets/${e}.js`))}setMessages(e){super.setMessages(e),salla.event.dispatch("languages::translations.loaded"),this.translationsLoaded=!0}loadScript(e,t=!0){let n=document.createElement("script");n.src=e,n.onload=()=>{if(window.translations)return this.setMessages(window.translations);n.onerror()},n.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(n)}get(e,t,n){return window.translations&&(e="trans."+e),super.get(e,t,n)}set(e,t){return salla.helpers.setNested(this.messages[this.getLocale()+".trans"],e,t),this}},pn.form=new class{async submit(e,t=null){let n=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(),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.normalRequest(e,n,"post").finally((()=>{loaderSupported&&t?.submitter?.parentElement.stop()}));let r=e.split("."),i=r.splice(-1);return await salla.call(r.join("."))[i](n).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,n=!1){if(!e)return;if("object"!=typeof e)return e;let r;for(let n=0;n<t.length&&!(r=e[t[n]])&&!("undefined"!=typeof FormData&&e instanceof FormData&&(r=e.get(t[n])));n++);return r=r||e,"object"!=typeof r||n?r:void 0}},pn.helpers.app=new class{toggleClassIf(e,t,n,r){return document.querySelectorAll(e).forEach((e=>this.toggleElementClassIf(e,t,n,r))),this}toggleElementClassIf(e,t,n,r){t=Array.isArray(t)?t:t.split(" "),n=Array.isArray(n)?n:n.split(" ");let i=r(e);return e?.classList.remove(...i?n:t),e?.classList.add(...i?t:n),this}isValidEmail(e){return/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(e).toLowerCase())}element(e){return"object"==typeof e?e:document.querySelector(e)}watchElement(e,t){return this[e]=this.element(t),this}watchElements(e){return Object.entries(e).forEach((e=>this.watchElement(e[0],e[1]))),this}on(e,t,n,r={}){return"object"==typeof t?(this.element(t).addEventListener(e,n,r),this):(document.querySelectorAll(t).forEach((t=>t.addEventListener(e,n,r))),this)}onClick(e,t){return this.on("click",e,t)}onKeyUp(e,t){return this.on("keyup",e,t)}onEnter(e,t){return this.onKeyUp(e,(e=>13===e.keyCode&&t(e))),this}all(e,t){return document.querySelectorAll(e).forEach(t),this}hideElement(e){return this.element(e).style.display="none",this}showElement(e,t="block"){return this.element(e).style.display=t,this}removeClass(e,t){return this.element(e).classList.remove(...Array.from(arguments).slice(1)),this}addClass(e,t){return this.element(e).classList.add(...Array.from(arguments).slice(1)),this}debounce(e,...t){return this.debounce_||(this.debounce_=Salla.helpers.debounce(((e,...t)=>e(...t)),500)),this.debounce_(e,...t)}},pn.infiniteScroll=new class extends bn{constructor(e,t){super(e,t),this.options={path:".infinite-scroll-btn",history:"push",status:".infinite-scroll-status",append:".list-block"},this.fetchOptions={headers:{"S-INFINITE-SCROLL":!0}},this.instances=[]}initiate(e,t,n){n=this.getCustomOptions(t,n);let r="string"!=typeof e?e:document.querySelector(e),i=n.path;if(!r||!i||"string"==typeof i&&!document.querySelector(i))return void Salla.logger.warn(r?"Path Option (a link that has next page link) Not Existed!":"Container For InfiniteScroll not Existed!");let a=new Wn(r,n);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}}(void 0,salla.event.infiniteScroll),pn.api=new class extends class{constructor(){salla.event.on("twilight::initiated",(()=>this.initiateRequest())),salla.event.on("profile::info.fetched",(e=>this.setCurrencyAndLanguage(e))),salla.event.on("auth::token.fetched",(e=>{salla.storage.set("token",e),this.setToken(e),salla.cart.api.reset()})),this.notifier_handler_disabled=!1,this.axios=ga.create({headers:{common:{"X-Requested-With":"XMLHttpRequest","S-SOURCE":"twilight","S-APP-VERSION":"v2.0.0","S-APP-OS":"browser"}}})}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}))}initiateRequest(){this.axios.defaults.baseURL=Salla.config.get("store.api",Salla.config.get("store.url")),this.setHeaders({"Store-Identifier":Salla.config.get("store.id"),currency:Salla.config.get("user.currency_code","SAR"),"accept-language":salla.lang.getLocale(),"s-user-id":Salla.config.get("user.id")});let e=salla.storage.get("scope");e&&this.setHeaders({"s-scope-type":e.type,"s-scope-id":e.id}),this.injectTokenToTheRequests()}injectTokenToTheRequests(){let e=salla.storage.get("token"),t=Salla.config.isGuest(),n=salla.storage.get("cart");if(n&&(n.user_id!==Salla.config.get("user.id")||n.store_id!==Salla.config.get("store.id")))return salla.log("Auth:: The cart is not belong to current "+(n.user_id!==Salla.config.get("user.id")?"user":"store")+"!"),void salla.cart.api.reset();if(t&&!e)return;if(t&&e)return salla.log("Auth:: Token without user!"),salla.storage.remove("token"),void salla.cart.api.reset();if(!e)return salla.cart.api.reset(),void salla.auth.api.refresh();let r=function(e,t){if("string"!=typeof e)throw new ba("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(ya(e.split(".")[n]))}catch(e){throw new ba("Invalid token specified: "+e.message)}}(e);return Date.now()/1e3>r.exp?(salla.log("Auth:: An expired token!"),salla.storage.remove("token"),salla.cart.api.reset(),void salla.auth.api.refresh()):r.sub!==Salla.config.get("user.id")?(salla.log("Auth:: The user id is not match the token details!"),salla.storage.remove("token"),salla.cart.api.reset(),void salla.auth.api.refresh()):void this.setToken(e)}setToken(e){return this.setHeader("Authorization","Bearer "+e)}setCurrencyAndLanguage(e){return this.setHeaders({currency:e.data.currency,"accept-language":e.data.language})}request(e,t,n="get",r={}){let i={endPoint:e,payload:t,method:n,options:r},a="undefined"!=typeof event?event.currentTarget:null,s=!1;return"SALLA-BUTTON"===a?.tagName&&(s=!0),s&&a?.load(),this.axios[i.method](i.endPoint,i.payload,i.options).then((e=>(s&&a?.stop(),e.data&&e.request&&(e=e.data),this.handleAfterResponseActions(e),e))).catch((e=>{throw s&&a?.stop(),salla.event.document.requestFailed(i,e),this.handleErrorResponse(e),e}))}handleAfterResponseActions(e){if(!e)return;let{data:t,googleTags:n=null}=e,r=t&&t.googleTags?t.googleTags:n;dataLayer&&r&&dataLayer.push(r),this.fireEventsForResponse(e),this.showAlert(e),this.renderSections(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,n=[];Object.keys(t).forEach((e=>{let r=t[e];Array.isArray(r)?r.forEach((e=>n.push(e))):n.push(r)}));let r=(n.length>1?"* ":"")+n.join("\n* ");salla.error(r,e)}isFastRequestsAllowed(){return Salla.config.get("fastRequests")}promise(e,t=!0){return new Promise(((n,r)=>t?n(e):r(e)))}errorPromise(e){return this.promise(e,!1)}successPromise(e){return this.promise(e,!0)}renderSections(e){e.sections&&Object.keys(e.sections).forEach((t=>{document.querySelectorAll(t.toSelector()).forEach((function(n){n.innerHTML=e.sections[t]}))}))}}{constructor(){super(),this.auth=new Yn,this.cart=new Zn,this.loyalty=new Xn,this.order=new er,this.rating=new sr,this.product=new tr,this.profile=new nr,this.comment=new rr,this.currency=new ir,this.document=new ar,this.wishlist=new or,this.scope=new lr,this.booking=new cr}},pn.cart=new bn(pn.api.cart,pn.event.cart),pn.auth=new bn(pn.api.auth,pn.event.auth),pn.order=new bn(pn.api.order,pn.event.order),pn.scope=new bn(pn.api.scope,pn.event.scope),pn.rating=new bn(pn.api.rating,pn.event.rating),pn.comment=new bn(pn.api.comment,pn.event.comment),pn.loyalty=new bn(pn.api.loyalty,pn.event.loyalty),pn.product=new bn(pn.api.product,pn.event.product),pn.profile=new bn(pn.api.profile,pn.event.profile),pn.currency=new bn(pn.api.currency,pn.event.currency),pn.document=new bn(pn.api.document,pn.event.document),pn.wishlist=new bn(pn.api.wishlist,pn.event.wishlist),pn.booking=new bn(pn.api.booking,pn.event.booking),pn.call=e=>{let t=pn,n=e.split(".");for(;n.length&&(t=t[n.shift()]););return t},pn.init=e=>new wa(e),salla.event.once("twilight::init",salla.init),salla.event.once("twilight::api",(e=>{let t=e?.events;t&&salla.event.dispatchEvents(t)})),pn.success=pn.notify.success,pn.error=pn.notify.error,pn.versions.twilight="2.9.44",pn.event.dispatch("twilight::ready"),pn.onInitiated=e=>salla.event.once("twilight::initiated",e),pn.onReady=pn.onReady||function(e){"ready"!==salla.status?pn.onInitiated(e):e()},window.dispatchEvent(new CustomEvent("salla::created")),e.default=pn,Object.defineProperty(e,"__esModule",{value:!0})}));
20
20
  //# sourceMappingURL=twilight.min.js.map