@salla.sa/base 2.12.47 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@salla.sa/base.min.js +1 -1
- package/dist/@salla.sa/base.min.js.map +1 -1
- package/dist/index.js/index.js +2 -0
- package/dist/index.js/index.js.map +1 -0
- package/dist/index.mjs/index.js +2 -0
- package/dist/index.mjs/index.js.map +1 -0
- package/package.json +31 -9
- package/types/config.d.ts +57 -50
- package/types/event.d.ts +8 -8
- package/types/global.d.ts +6 -5
- package/types/helpers.d.ts +53 -47
- package/types/index.d.ts +19 -14
- package/types/storage.d.ts +8 -4
- package/dist/cjs/index.js +0 -2
- package/dist/cjs/index.js.map +0 -1
- package/dist/esm/index.js +0 -2
- package/dist/esm/index.js.map +0 -1
- package/types/cookie.d.ts +0 -6
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Salla=t()}(this,(function(){"use strict";function e(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}))})),Object.freeze(e)}function t(e,t){void 0===t&&(t=!1),e+="";for(var r,n=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],i=["0","1","2","3","4","5","6","7","8","9"],o=(t=t||!Salla.config.get("store.settings.arabic_numbers_enabled"))?n:i,s=t?i:n,a=0;a<o.length;a++)r=new RegExp(o[a],"g"),e=e.replace(r,s[a]);return e.replace(t?"٫":".",t?".":"٫")}function r(e){var t=("".concat(e).match(/\./g)||[]).length;return t&&1!==t?r(e.replace(/\.(.+)\./g,".$1")):e}String.prototype.toStudlyCase=function(){return this.trim().replace(/([^a-zA-Z\d].)/g,(function(e){return e.toUpperCase().replace(/[^a-zA-Z\d]/g,"")}))},String.prototype.toDatasetName=function(){return this.startsWith("data-")?this.substr(5).toStudlyCase():this.toStudlyCase()},String.prototype.toSelector=function(){return this.trim().startsWith(".")||this.trim().startsWith("#")?this.toString():"#"+this.toString()},String.prototype.replaceArray=function(e,t){for(var r,n=this,i=0;i<e.length;i++)r=new RegExp(e[i],"g"),n=n.replace(r,t[i]);return n},String.prototype.rtrim=function(e){return void 0===e&&(e="\\s"),this.replace(new RegExp("["+e+"]*$"),"")},String.prototype.ltrim=function(e){return void 0===e&&(e="\\s"),this.replace(new RegExp("^["+e+"]*"),"")},String.prototype.digitsOnly=function(){return Salla.helpers.digitsOnly(this)};var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i=Array.isArray;function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}var s="object"==o(n)&&n&&n.Object===Object&&n,a="object"==("undefined"==typeof self?"undefined":o(self))&&self&&self.Object===Object&&self,l=s||a||Function("return this")(),c=l.Symbol,u=c,f=Object.prototype,h=f.hasOwnProperty,p=f.toString,v=u?u.toStringTag:void 0;var d=function(e){var t=h.call(e,v),r=e[v];try{e[v]=void 0;var n=!0}catch(e){}var i=p.call(e);return n&&(t?e[v]=r:delete e[v]),i},y=Object.prototype.toString;var g=d,m=function(e){return y.call(e)},_=c?c.toStringTag:void 0;var b=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":_&&_ in Object(e)?g(e):m(e)};var w=b,S=function(e){return null!=e&&"object"==o(e)};var L=function(e){return"symbol"==o(e)||S(e)&&"[object Symbol]"==w(e)},j=i,E=L,x=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,O=/^\w*$/;var A=function(e,t){if(j(e))return!1;var r=o(e);return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!E(e))||(O.test(e)||!x.test(e)||null!=t&&e in Object(t))};var T=function(e){var t=o(e);return null!=e&&("object"==t||"function"==t)},k=b,P=T;var N,F=function(e){if(!P(e))return!1;var t=k(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},z=l["__core-js_shared__"],R=(N=/[^.]+$/.exec(z&&z.keys&&z.keys.IE_PROTO||""))?"Symbol(src)_1."+N:"";var M=function(e){return!!R&&R in e},$=Function.prototype.toString;var C=F,I=M,D=T,U=function(e){if(null!=e){try{return $.call(e)}catch(e){}try{return e+""}catch(e){}}return""},W=/^\[object .+?Constructor\]$/,G=Function.prototype,J=Object.prototype,q=G.toString,Z=J.hasOwnProperty,H=RegExp("^"+q.call(Z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var K=function(e){return!(!D(e)||I(e))&&(C(e)?H:W).test(U(e))},B=function(e,t){return null==e?void 0:e[t]};var Q=function(e,t){var r=B(e,t);return K(r)?r:void 0},V=Q(Object,"create"),X=V;var Y=function(){this.__data__=X?X(null):{},this.size=0};var ee=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},te=V,re=Object.prototype.hasOwnProperty;var ne=function(e){var t=this.__data__;if(te){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return re.call(t,e)?t[e]:void 0},ie=V,oe=Object.prototype.hasOwnProperty;var se=V;var ae=Y,le=ee,ce=ne,ue=function(e){var t=this.__data__;return ie?void 0!==t[e]:oe.call(t,e)},fe=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=se&&void 0===t?"__lodash_hash_undefined__":t,this};function he(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}he.prototype.clear=ae,he.prototype.delete=le,he.prototype.get=ce,he.prototype.has=ue,he.prototype.set=fe;var pe=he;var ve=function(){this.__data__=[],this.size=0};var de=function(e,t){return e===t||e!=e&&t!=t};var ye=function(e,t){for(var r=e.length;r--;)if(de(e[r][0],t))return r;return-1},ge=ye,me=Array.prototype.splice;var _e=ye;var be=ye;var we=ye;var Se=ve,Le=function(e){var t=this.__data__,r=ge(t,e);return!(r<0)&&(r==t.length-1?t.pop():me.call(t,r,1),--this.size,!0)},je=function(e){var t=this.__data__,r=_e(t,e);return r<0?void 0:t[r][1]},Ee=function(e){return be(this.__data__,e)>-1},xe=function(e,t){var r=this.__data__,n=we(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};function Oe(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Oe.prototype.clear=Se,Oe.prototype.delete=Le,Oe.prototype.get=je,Oe.prototype.has=Ee,Oe.prototype.set=xe;var Ae=Oe,Te=Q(l,"Map"),ke=pe,Pe=Ae,Ne=Te;var Fe=function(e){var t=o(e);return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};var ze=function(e,t){var r=e.__data__;return Fe(t)?r["string"==typeof t?"string":"hash"]:r.map},Re=ze;var Me=ze;var $e=ze;var Ce=ze;var Ie=function(){this.size=0,this.__data__={hash:new ke,map:new(Ne||Pe),string:new ke}},De=function(e){var t=Re(this,e).delete(e);return this.size-=t?1:0,t},Ue=function(e){return Me(this,e).get(e)},We=function(e){return $e(this,e).has(e)},Ge=function(e,t){var r=Ce(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};function Je(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Je.prototype.clear=Ie,Je.prototype.delete=De,Je.prototype.get=Ue,Je.prototype.has=We,Je.prototype.set=Ge;var qe=Je;function Ze(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var r=function r(){var n=arguments,i=t?t.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=e.apply(this,n);return r.cache=o.set(i,s)||o,s};return r.cache=new(Ze.Cache||qe),r}Ze.Cache=qe;var He=Ze;var Ke=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Be=/\\(\\)?/g,Qe=function(e){var t=He(e,(function(e){return 500===r.size&&r.clear(),e})),r=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(Ke,(function(e,r,n,i){t.push(n?i.replace(Be,"$1"):r||e)})),t})),Ve=Qe;var Xe=function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i},Ye=i,et=L,tt=c?c.prototype:void 0,rt=tt?tt.toString:void 0;var nt=function e(t){if("string"==typeof t)return t;if(Ye(t))return Xe(t,e)+"";if(et(t))return rt?rt.call(t):"";var r=t+"";return"0"==r&&1/t==-Infinity?"-0":r},it=nt;var ot=i,st=A,at=Ve,lt=function(e){return null==e?"":it(e)};var ct=L;var ut=function(e,t){return ot(e)?e:st(e,t)?[e]:at(lt(e))},ft=function(e){if("string"==typeof e||ct(e))return e;var t=e+"";return"0"==t&&1/e==-Infinity?"-0":t};var ht=function(e,t){for(var r=0,n=(t=ut(t,e)).length;null!=e&&r<n;)e=e[ft(t[r++])];return r&&r==n?e:void 0};var pt=function(e,t,r){var n=null==e?void 0:ht(e,t);return void 0===n?r:n};function vt(e){return"".concat(e).startsWith("https://")||"".concat(e).startsWith("http://")}function dt(e){if(vt(e))return e;var t=Salla.config.get("store.url");return t||(t=window.location.href.split("/").slice(0,-1).join("/"),Salla.config.set("store.url",t)),t.rtrim("/")+"/"+(null==e?void 0:e.ltrim("/"))}function yt(e,t,r){if(r=r||window.location.href,!t||!e)return r;var n=new RegExp("([?&])"+e+"=[^&]+[&]?","g");return(r=r.replace(n,"$1").split("#")[0].replace(/&$|\?$/,"")).includes("?")?r+="&":r+=(r.endsWith("/")?"":"/")+"?",(r+e+"="+encodeURIComponent(t)).replace(/&$|\?$/,"")}function gt(e){return window.location.origin+"/"+(null==e?void 0:e.ltrim("/"))}function mt(e){return vt(e)?e:Salla.config.get("theme.assets")?Salla.config.get("theme.assets").replace(":path",null==e?void 0:e.ltrim("/")):gt("themes/"+Salla.config.get("theme.name")+"/"+(null==e?void 0:e.ltrim("/")))}function _t(e,t,r){var n,i=e[0];return r&&0==e.length?Array.isArray(r)?(r.push(t),r):[r,t]:Array.isArray(r)?(r.push(t),r):"string"==typeof r?[r,t]:r?(r[i]=_t(e.slice(1),t,r[i]),r):i?((n={})[i]=_t(e.slice(1),t),n):""===i?[t]:t}var bt={digitsOnly:function(e){return t(e,!0).replace(/[^0-9.]/g,"").replace("..",".").rtrim(".")},inputDigitsOnly:function e(t,n){if(void 0===n&&(n=!1),"string"==typeof t)return document.querySelectorAll(t).forEach((function(t){return e(t,n)}));if(t){var i=Salla.helpers.digitsOnly(t.value);return t.min&&i<parseInt(t.min)?t.value=t.min:t.max&&i>parseInt(t.max)?t.value=t.max:t.maxLength>=1&&i.toString().length>t.maxLength?t.value=i.toString().substring(0,t.maxLength):t.value=n||t.dataset.hasOwnProperty("digitsWithDecimal")?r(i):i.replace(/\D/g,"")}Salla.logger.warn("Can't find Object With Id: "+t)},number:t,money:function(e){var r=Salla.config.currency(null==e?void 0:e.currency).symbol;return t(e="object"==typeof e?e.amount:e)+" "+r},setNested:function(e,t,r){for(var n=e,i=t.split("."),o=i.length,s=0;s<o-1;s++){var a=i[s];n[a]||(n[a]={}),n=n[a]}return n[i[o-1]]=r,e},getNested:function(e,t,r){var n=pt(e,t);return void 0!==n?n:r},inputData:function(e,t,r){if(void 0===r&&(r={}),e.includes("[")){var n=e.split("]").join("").split("[");return{name:n[0],value:_t(n.slice(1),t,r[n[0]])}}return{name:e,value:t}},url:Object.freeze({__proto__:null,is_full_url:vt,base:function(e){return vt(e)?e:"https://"+new URL(dt("/")).hostname+"/"+(null==e?void 0:e.ltrim("/"))},get:dt,domain:function(e){return vt(e)?e:"".concat(Salla.config.get("store.url",window.location.href.split("/").slice(0,-1).join("/")).rtrim("/"),"/").concat(null==e?void 0:e.ltrim("/"))},addParamToUrl:yt,baseUrl:gt,asset:mt,cdn:function(e){return"https://cdn.salla.network/"+(null==e?void 0:e.ltrim("/"))},api:function(e){var t;return(null===(t=Salla.config.get("store.api",dt("")))||void 0===t?void 0:t.rtrim("/"))+"/"+(null==e?void 0:e.ltrim("/"))},is_page:function(e){return e&&Salla.config.get("page.slug")===e},is_placeholder:function(e){return mt(salla.config.get("theme.settings.placeholder"))===mt(e)}}),addParamToUrl:yt,debounce:function(e,t){t=t||100;var r,n=[];return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];return clearTimeout(r),r=setTimeout((function(){var t=e.apply(void 0,i);n.forEach((function(e){return e(t)})),n=[]}),t),new Promise((function(e){return n.push(e)}))}}},wt=function(e,t){return wt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},wt(e,t)};var St=function(){return St=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},St.apply(this,arguments)};function Lt(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var jt,Et,xt,Ot=(jt=console,Et=[],xt={log:function(e,t){if(jt&&salla.config.isDebug()){Et.push([t,e]),"trace"===salla.config.get("debug")&&(t="trace");var r=jt.log,n=void 0===t?r:this.__dict__[t]||r,i=["%cTwilight","color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;"],o={event:"#CFF680",backend:"#7b68ee"}[t];o&&(i[0]+="%c"+t[0].toUpperCase()+t.substring(1),i.push("margin-left: 5px;color: ".concat(o,";font-weight:bold; border:1px solid ").concat(o,"; padding: 2px 6px; border-radius: 5px;"))),n.call.apply(n,Lt([jt],i.concat.apply(i,e),!1))}},__dict__:{trace:jt.trace,debug:jt.debug,info:jt.info,warn:jt.warn,error:jt.error}},{event:function(){xt.log(arguments,"event")},trace:function(){xt.log(arguments,"trace")},debug:function(){xt.log(arguments,"debug")},info:function(){xt.log(arguments,"info")},warn:function(){xt.log(arguments,"warn")},error:function(){xt.log(arguments,"error")},log:function(){xt.log(arguments,void 0)},backend:function(){xt.log(arguments,"backend")},logs:function(e){[e].flat().forEach((function(e){return e&&xt.log([e].flat(),"backend")}))},history:function(){return Et.map((function(e){return jt.log.apply(jt,Lt([e[0]],e[1],!1))})),Et}}),At=function(){function e(e,t){void 0===e&&(e={}),void 0===t&&(t={}),this.default_properties=t,this.properties_=St(St({},this.default_properties),e)}return e.prototype.merge=function(e){var t;return this.properties_=St(St({},this.properties_),e),this.properties_.store=St(St({},(null===(t=this.default_properties)||void 0===t?void 0:t.store)||{}),this.properties_.store),this},e.prototype.set=function(e,t){return e.includes(".")?(Salla.helpers.setNested(this.properties_,e,t),this):(this.properties_[e]=t,this)},e.prototype.currency=function(e){return void 0===e&&(e=void 0),e=e||this.get("user.currency_code"),this.get("currencies."+e)||Object.values(this.get("currencies"))[0]},e.prototype.get=function(e,t){return void 0===t&&(t=null),e.includes(".")?Salla.helpers.getNested(this.properties_,e,t):this.properties_.hasOwnProperty(e)?this.properties_[e]||t:t||void 0},e.prototype.all=function(){return this.properties_},e.prototype.isDebug=function(){return this.get("debug")||Salla.storage.get("debug")},e}();function Tt(){throw new Error("setTimeout has not been defined")}function kt(){throw new Error("clearTimeout has not been defined")}var Pt=Tt,Nt=kt;function Ft(e){if(Pt===setTimeout)return setTimeout(e,0);if((Pt===Tt||!Pt)&&setTimeout)return Pt=setTimeout,setTimeout(e,0);try{return Pt(e,0)}catch(t){try{return Pt.call(null,e,0)}catch(t){return Pt.call(this,e,0)}}}"function"==typeof global.setTimeout&&(Pt=setTimeout),"function"==typeof global.clearTimeout&&(Nt=clearTimeout);var zt,Rt=[],Mt=!1,$t=-1;function Ct(){Mt&&zt&&(Mt=!1,zt.length?Rt=zt.concat(Rt):$t=-1,Rt.length&&It())}function It(){if(!Mt){var e=Ft(Ct);Mt=!0;for(var t=Rt.length;t;){for(zt=Rt,Rt=[];++$t<t;)zt&&zt[$t].run();$t=-1,t=Rt.length}zt=null,Mt=!1,function(e){if(Nt===clearTimeout)return clearTimeout(e);if((Nt===kt||!Nt)&&clearTimeout)return Nt=clearTimeout,clearTimeout(e);try{return Nt(e)}catch(t){try{return Nt.call(null,e)}catch(t){return Nt.call(this,e)}}}(e)}}function Dt(e,t){this.fun=e,this.array=t}Dt.prototype.run=function(){this.fun.apply(null,this.array)};function Ut(){}var Wt=Ut,Gt=Ut,Jt=Ut,qt=Ut,Zt=Ut,Ht=Ut,Kt=Ut;var Bt=global.performance||{},Qt=Bt.now||Bt.mozNow||Bt.msNow||Bt.oNow||Bt.webkitNow||function(){return(new Date).getTime()};var Vt=new Date;var Xt={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];Rt.push(new Dt(e,t)),1!==Rt.length||Mt||Ft(It)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:Wt,addListener:Gt,once:Jt,off:qt,removeListener:Zt,removeAllListeners:Ht,emit:Kt,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*Qt.call(Bt),r=Math.floor(t),n=Math.floor(t%1*1e9);return e&&(r-=e[0],(n-=e[1])<0&&(r--,n+=1e9)),[r,n]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-Vt)/1e3}},Yt=Xt,er={exports:{}};!function(e,t){!function(t){var r=Object.hasOwnProperty,n=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},i="object"==o(Yt)&&"function"==typeof Yt.nextTick,s="function"==typeof Symbol,a="object"===("undefined"==typeof Reflect?"undefined":o(Reflect)),l="function"==typeof setImmediate?setImmediate:setTimeout,c=s?a&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys:function(e){var t=Object.getOwnPropertyNames(e);return t.push.apply(t,Object.getOwnPropertySymbols(e)),t}:Object.keys;function u(){this._events={},this._conf&&f.call(this,this._conf)}function f(e){e&&(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),e.maxListeners!==t&&(this._maxListeners=e.maxListeners),e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),e.ignoreErrors&&(this.ignoreErrors=e.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function h(e,t){var r="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(r+=" Event name: "+t+"."),void 0!==Yt&&Yt.emitWarning){var n=new Error(r);n.name="MaxListenersExceededWarning",n.emitter=this,n.count=e,Yt.emitWarning(n)}else console.error(r),console.trace&&console.trace()}var p=function(e,t,r){var n=arguments.length;switch(n){case 0:return[];case 1:return[e];case 2:return[e,t];case 3:return[e,t,r];default:for(var i=new Array(n);n--;)i[n]=arguments[n];return i}};function v(e,r){for(var n={},i=e.length,o=r?r.length:0,s=0;s<i;s++)n[e[s]]=s<o?r[s]:t;return n}function d(e,t,r){var n,i;if(this._emitter=e,this._target=t,this._listeners={},this._listenersCount=0,(r.on||r.off)&&(n=r.on,i=r.off),t.addEventListener?(n=t.addEventListener,i=t.removeEventListener):t.addListener?(n=t.addListener,i=t.removeListener):t.on&&(n=t.on,i=t.off),!n&&!i)throw Error("target does not implement any known event API");if("function"!=typeof n)throw TypeError("on method must be a function");if("function"!=typeof i)throw TypeError("off method must be a function");this._on=n,this._off=i;var o=e._observers;o?o.push(this):e._observers=[this]}function y(e,n,i,s){var a=Object.assign({},n);if(!e)return a;if("object"!==o(e))throw TypeError("options must be an object");var l,c,u,f=Object.keys(e),h=f.length;function p(e){throw Error('Invalid "'+l+'" option value'+(e?". Reason: "+e:""))}for(var v=0;v<h;v++){if(l=f[v],!s&&!r.call(n,l))throw Error('Unknown "'+l+'" option');(c=e[l])!==t&&(u=i[l],a[l]=u?u(c,p):c)}return a}function g(e,t){return"function"==typeof e&&e.hasOwnProperty("prototype")||t("value must be a constructor"),e}function m(e){var t="value must be type of "+e.join("|"),r=e.length,n=e[0],i=e[1];return 1===r?function(e,r){if(o(e)===n)return e;r(t)}:2===r?function(e,r){var s=o(e);if(s===n||s===i)return e;r(t)}:function(n,i){for(var s=o(n),a=r;a-- >0;)if(s===e[a])return n;i(t)}}Object.assign(d.prototype,{subscribe:function(e,t,r){var n=this,i=this._target,o=this._emitter,s=this._listeners,a=function(){var n=p.apply(null,arguments),s={data:n,name:t,original:e};r?!1!==r.call(i,s)&&o.emit.apply(o,[s.name].concat(n)):o.emit.apply(o,[t].concat(n))};if(s[e])throw Error("Event '"+e+"' is already listening");this._listenersCount++,o._newListener&&o._removeListener&&!n._onNewListener?(this._onNewListener=function(r){r===t&&null===s[e]&&(s[e]=a,n._on.call(i,e,a))},o.on("newListener",this._onNewListener),this._onRemoveListener=function(r){r===t&&!o.hasListeners(r)&&s[e]&&(s[e]=null,n._off.call(i,e,a))},s[e]=null,o.on("removeListener",this._onRemoveListener)):(s[e]=a,n._on.call(i,e,a))},unsubscribe:function(e){var t,r,n,i=this,o=this._listeners,s=this._emitter,a=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=o[e]))return;a.call(l,e,t),delete o[e],--this._listenersCount||u()}else{for(n=(r=c(o)).length;n-- >0;)e=r[n],a.call(l,e,o[e]);this._listeners={},this._listenersCount=0,u()}}});var _=m(["function"]),b=m(["object","function"]);function w(e,t,r){var n,i,o,s=0,a=new e((function(l,c,u){function f(){i&&(i=null),s&&(clearTimeout(s),s=0)}r=y(r,{timeout:0,overload:!1},{timeout:function(e,t){return("number"!=typeof(e*=1)||e<0||!Number.isFinite(e))&&t("timeout must be a positive number"),e}}),n=!r.overload&&"function"==typeof e.prototype.cancel&&"function"==typeof u;var h=function(e){f(),l(e)},p=function(e){f(),c(e)};n?t(h,p,u):(i=[function(e){p(e||Error("canceled"))}],t(h,p,(function(e){if(o)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof e)throw TypeError("onCancel callback must be a function");i.push(e)})),o=!0),r.timeout>0&&(s=setTimeout((function(){var e=Error("timeout");e.code="ETIMEDOUT",s=0,a.cancel(e),c(e)}),r.timeout))}));return n||(a.cancel=function(e){if(i){for(var t=i.length,r=1;r<t;r++)i[r](e);i[0](e),i=null}}),a}function S(e){var t=this._observers;if(!t)return-1;for(var r=t.length,n=0;n<r;n++)if(t[n]._target===e)return n;return-1}function L(e,t,r,n,i){if(!r)return null;if(0===n){var s=o(t);if("string"===s){var a,l,u=0,f=0,h=this.delimiter,p=h.length;if(-1!==(l=t.indexOf(h))){a=new Array(5);do{a[u++]=t.slice(f,l),f=l+p}while(-1!==(l=t.indexOf(h,f)));a[u++]=t.slice(f),t=a,i=u}else t=[t],i=1}else"object"===s?i=t.length:(t=[t],i=1)}var v,d,y,g,m,_,b,w=null,S=t[n],j=t[n+1];if(n===i)r._listeners&&("function"==typeof r._listeners?(e&&e.push(r._listeners),w=[r]):(e&&e.push.apply(e,r._listeners),w=[r]));else{if("*"===S){for(l=(_=c(r)).length;l-- >0;)"_listeners"!==(v=_[l])&&(b=L(e,t,r[v],n+1,i))&&(w?w.push.apply(w,b):w=b);return w}if("**"===S){for((m=n+1===i||n+2===i&&"*"===j)&&r._listeners&&(w=L(e,t,r,i,i)),l=(_=c(r)).length;l-- >0;)"_listeners"!==(v=_[l])&&("*"===v||"**"===v?(r[v]._listeners&&!m&&(b=L(e,t,r[v],i,i))&&(w?w.push.apply(w,b):w=b),b=L(e,t,r[v],n,i)):b=L(e,t,r[v],v===j?n+2:n,i),b&&(w?w.push.apply(w,b):w=b));return w}r[S]&&(w=L(e,t,r[S],n+1,i))}if((d=r["*"])&&L(e,t,d,n+1,i),y=r["**"])if(n<i)for(y._listeners&&L(e,t,y,i,i),l=(_=c(y)).length;l-- >0;)"_listeners"!==(v=_[l])&&(v===j?L(e,t,y[v],n+2,i):v===S?L(e,t,y[v],n+1,i):((g={})[v]=y[v],L(e,t,{"**":g},n+1,i)));else y._listeners?L(e,t,y,i,i):y["*"]&&y["*"]._listeners&&L(e,t,y["*"],i,i);return w}function j(e,t,r){var n,i,o=0,s=0,a=this.delimiter,l=a.length;if("string"==typeof e)if(-1!==(n=e.indexOf(a))){i=new Array(5);do{i[o++]=e.slice(s,n),s=n+l}while(-1!==(n=e.indexOf(a,s)));i[o++]=e.slice(s)}else i=[e],o=1;else i=e,o=e.length;if(o>1)for(n=0;n+1<o;n++)if("**"===i[n]&&"**"===i[n+1])return;var c,u=this.listenerTree;for(n=0;n<o;n++)if(u=u[c=i[n]]||(u[c]={}),n===o-1)return u._listeners?("function"==typeof u._listeners&&(u._listeners=[u._listeners]),r?u._listeners.unshift(t):u._listeners.push(t),!u._listeners.warned&&this._maxListeners>0&&u._listeners.length>this._maxListeners&&(u._listeners.warned=!0,h.call(this,u._listeners.length,c))):u._listeners=t,!0;return!0}function E(e,t,r,n){for(var i,s,a,l,u=c(e),f=u.length,h=e._listeners;f-- >0;)i=e[s=u[f]],a="_listeners"===s?r:r?r.concat(s):[s],l=n||"symbol"===o(s),h&&t.push(l?a:a.join(this.delimiter)),"object"===o(i)&&E.call(this,i,t,a,l);return t}function x(e){for(var t,r,n,i=c(e),o=i.length;o-- >0;)(t=e[r=i[o]])&&(n=!0,"_listeners"===r||x(t)||delete e[r]);return n}function O(e,t,r){this.emitter=e,this.event=t,this.listener=r}function A(e,r,n){if(!0===n)a=!0;else if(!1===n)s=!0;else{if(!n||"object"!==o(n))throw TypeError("options should be an object or true");var s=n.async,a=n.promisify,c=n.nextTick,u=n.objectify}if(s||c||a){var f=r,h=r._origin||r;if(c&&!i)throw Error("process.nextTick is not supported");a===t&&(a="AsyncFunction"===r.constructor.name),r=function(){var e=arguments,t=this,r=this.event;return a?c?Promise.resolve():new Promise((function(e){l(e)})).then((function(){return t.event=r,f.apply(t,e)})):(c?Yt.nextTick:l)((function(){t.event=r,f.apply(t,e)}))},r._async=!0,r._origin=h}return[r,u?new O(this,e,r):this]}function T(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,f.call(this,e)}O.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},T.EventEmitter2=T,T.prototype.listenTo=function(e,r,i){if("object"!==o(e))throw TypeError("target musts be an object");var s=this;function a(t){if("object"!==o(t))throw TypeError("events must be an object");var r,n=i.reducers,a=S.call(s,e);r=-1===a?new d(s,e,i):s._observers[a];for(var l,u=c(t),f=u.length,h="function"==typeof n,p=0;p<f;p++)l=u[p],r.subscribe(l,t[l]||l,h?n:n&&n[l])}return i=y(i,{on:t,off:t,reducers:t},{on:_,off:_,reducers:b}),n(r)?a(v(r)):a("string"==typeof r?v(r.split(/\s+/)):r),this},T.prototype.stopListeningTo=function(e,t){var r=this._observers;if(!r)return!1;var n,i=r.length,s=!1;if(e&&"object"!==o(e))throw TypeError("target should be an object");for(;i-- >0;)n=r[i],e&&n._target!==e||(n.unsubscribe(t),s=!0);return s},T.prototype.delimiter=".",T.prototype.setMaxListeners=function(e){e!==t&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},T.prototype.getMaxListeners=function(){return this._maxListeners},T.prototype.event="",T.prototype.once=function(e,t,r){return this._once(e,t,!1,r)},T.prototype.prependOnceListener=function(e,t,r){return this._once(e,t,!0,r)},T.prototype._once=function(e,t,r,n){return this._many(e,1,t,r,n)},T.prototype.many=function(e,t,r,n){return this._many(e,t,r,!1,n)},T.prototype.prependMany=function(e,t,r,n){return this._many(e,t,r,!0,n)},T.prototype._many=function(e,t,r,n,i){var o=this;if("function"!=typeof r)throw new Error("many only accepts instances of Function");function s(){return 0==--t&&o.off(e,s),r.apply(this,arguments)}return s._origin=r,this._on(e,s,n,i)},T.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||u.call(this);var e,t,r,n,i,a,l=arguments[0],c=this.wildcard;if("newListener"===l&&!this._newListener&&!this._events.newListener)return!1;if(c&&(e=l,"newListener"!==l&&"removeListener"!==l&&"object"===o(l))){if(r=l.length,s)for(n=0;n<r;n++)if("symbol"===o(l[n])){a=!0;break}a||(l=l.join(this.delimiter))}var f,h=arguments.length;if(this._all&&this._all.length)for(n=0,r=(f=this._all.slice()).length;n<r;n++)switch(this.event=l,h){case 1:f[n].call(this,l);break;case 2:f[n].call(this,l,arguments[1]);break;case 3:f[n].call(this,l,arguments[1],arguments[2]);break;default:f[n].apply(this,arguments)}if(c)f=[],L.call(this,f,e,this.listenerTree,0,r);else{if("function"==typeof(f=this._events[l])){switch(this.event=l,h){case 1:f.call(this);break;case 2:f.call(this,arguments[1]);break;case 3:f.call(this,arguments[1],arguments[2]);break;default:for(t=new Array(h-1),i=1;i<h;i++)t[i-1]=arguments[i];f.apply(this,t)}return!0}f&&(f=f.slice())}if(f&&f.length){if(h>3)for(t=new Array(h-1),i=1;i<h;i++)t[i-1]=arguments[i];for(n=0,r=f.length;n<r;n++)switch(this.event=l,h){case 1:f[n].call(this);break;case 2:f[n].call(this,arguments[1]);break;case 3:f[n].call(this,arguments[1],arguments[2]);break;default:f[n].apply(this,t)}return!0}if(!this.ignoreErrors&&!this._all&&"error"===l)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},T.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||u.call(this);var e,t,r,n,i,a,l=arguments[0],c=this.wildcard;if("newListener"===l&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(c&&(e=l,"newListener"!==l&&"removeListener"!==l&&"object"===o(l))){if(n=l.length,s)for(i=0;i<n;i++)if("symbol"===o(l[i])){t=!0;break}t||(l=l.join(this.delimiter))}var f,h=[],p=arguments.length;if(this._all)for(i=0,n=this._all.length;i<n;i++)switch(this.event=l,p){case 1:h.push(this._all[i].call(this,l));break;case 2:h.push(this._all[i].call(this,l,arguments[1]));break;case 3:h.push(this._all[i].call(this,l,arguments[1],arguments[2]));break;default:h.push(this._all[i].apply(this,arguments))}if(c?(f=[],L.call(this,f,e,this.listenerTree,0)):f=this._events[l],"function"==typeof f)switch(this.event=l,p){case 1:h.push(f.call(this));break;case 2:h.push(f.call(this,arguments[1]));break;case 3:h.push(f.call(this,arguments[1],arguments[2]));break;default:for(r=new Array(p-1),a=1;a<p;a++)r[a-1]=arguments[a];h.push(f.apply(this,r))}else if(f&&f.length){if(f=f.slice(),p>3)for(r=new Array(p-1),a=1;a<p;a++)r[a-1]=arguments[a];for(i=0,n=f.length;i<n;i++)switch(this.event=l,p){case 1:h.push(f[i].call(this));break;case 2:h.push(f[i].call(this,arguments[1]));break;case 3:h.push(f[i].call(this,arguments[1],arguments[2]));break;default:h.push(f[i].apply(this,r))}}else if(!this.ignoreErrors&&!this._all&&"error"===l)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(h)},T.prototype.on=function(e,t,r){return this._on(e,t,!1,r)},T.prototype.prependListener=function(e,t,r){return this._on(e,t,!0,r)},T.prototype.onAny=function(e){return this._onAny(e,!1)},T.prototype.prependAny=function(e){return this._onAny(e,!0)},T.prototype.addListener=T.prototype.on,T.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},T.prototype._on=function(e,r,n,i){if("function"==typeof e)return this._onAny(e,r),this;if("function"!=typeof r)throw new Error("on only accepts instances of Function");this._events||u.call(this);var o,s=this;return i!==t&&(r=(o=A.call(this,e,r,i))[0],s=o[1]),this._newListener&&this.emit("newListener",e,r),this.wildcard?(j.call(this,e,r,n),s):(this._events[e]?("function"==typeof this._events[e]&&(this._events[e]=[this._events[e]]),n?this._events[e].unshift(r):this._events[e].push(r),!this._events[e].warned&&this._maxListeners>0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,h.call(this,this._events[e].length,e))):this._events[e]=r,s)},T.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var r,i=[];if(this.wildcard){var o="string"==typeof e?e.split(this.delimiter):e.slice();if(!(i=L.call(this,null,o,this.listenerTree,0)))return this}else{if(!this._events[e])return this;r=this._events[e],i.push({_listeners:r})}for(var s=0;s<i.length;s++){var a=i[s];if(r=a._listeners,n(r)){for(var l=-1,c=0,u=r.length;c<u;c++)if(r[c]===t||r[c].listener&&r[c].listener===t||r[c]._origin&&r[c]._origin===t){l=c;break}if(l<0)continue;return this.wildcard?a._listeners.splice(l,1):this._events[e].splice(l,1),0===r.length&&(this.wildcard?delete a._listeners:delete this._events[e]),this._removeListener&&this.emit("removeListener",e,t),this}(r===t||r.listener&&r.listener===t||r._origin&&r._origin===t)&&(this.wildcard?delete a._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return this.listenerTree&&x(this.listenerTree),this},T.prototype.offAny=function(e){var t,r=0,n=0;if(e&&this._all&&this._all.length>0){for(r=0,n=(t=this._all).length;r<n;r++)if(e===t[r])return t.splice(r,1),this._removeListener&&this.emit("removeListenerAny",e),this}else{if(t=this._all,this._removeListener)for(r=0,n=t.length;r<n;r++)this.emit("removeListenerAny",t[r]);this._all=[]}return this},T.prototype.removeListener=T.prototype.off,T.prototype.removeAllListeners=function(e){if(e===t)return!this._events||u.call(this),this;if(this.wildcard){var r,n=L.call(this,null,e,this.listenerTree,0);if(!n)return this;for(r=0;r<n.length;r++)n[r]._listeners=null;this.listenerTree&&x(this.listenerTree)}else this._events&&(this._events[e]=null);return this},T.prototype.listeners=function(e){var r,n,i,o,s,a=this._events;if(e===t){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!a)return[];for(o=(r=c(a)).length,i=[];o-- >0;)"function"==typeof(n=a[r[o]])?i.push(n):i.push.apply(i,n);return i}if(this.wildcard){if(!(s=this.listenerTree))return[];var l=[],u="string"==typeof e?e.split(this.delimiter):e.slice();return L.call(this,l,u,s,0),l}return a&&(n=a[e])?"function"==typeof n?[n]:n:[]},T.prototype.eventNames=function(e){var t=this._events;return this.wildcard?E.call(this,this.listenerTree,[],null,e):t?c(t):[]},T.prototype.listenerCount=function(e){return this.listeners(e).length},T.prototype.hasListeners=function(e){if(this.wildcard){var r=[],n="string"==typeof e?e.split(this.delimiter):e.slice();return L.call(this,r,n,this.listenerTree,0),r.length>0}var i=this._events,o=this._all;return!!(o&&o.length||i&&(e===t?c(i).length:i[e]))},T.prototype.listenersAny=function(){return this._all?this._all:[]},T.prototype.waitFor=function(e,r){var n=this,i=o(r);return"number"===i?r={timeout:r}:"function"===i&&(r={filter:r}),w((r=y(r,{timeout:0,filter:t,handleError:!1,Promise:Promise,overload:!1},{filter:_,Promise:g})).Promise,(function(t,i,o){function s(){var o=r.filter;if(!o||o.apply(n,arguments))if(n.off(e,s),r.handleError){var a=arguments[0];a?i(a):t(p.apply(null,arguments).slice(1))}else t(p.apply(null,arguments))}o((function(){n.off(e,s)})),n._on(e,s,!1)}),{timeout:r.timeout,overload:r.overload})};var k=T.prototype;Object.defineProperties(T,{defaultMaxListeners:{get:function(){return k._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");k._maxListeners=e},enumerable:!0},once:{value:function(e,t,r){return w((r=y(r,{Promise:Promise,timeout:0,overload:!1},{Promise:g})).Promise,(function(r,n,i){var o;if("function"==typeof e.addEventListener)return o=function(){r(p.apply(null,arguments))},i((function(){e.removeEventListener(t,o)})),void e.addEventListener(t,o,{once:!0});var s,a=function(){s&&e.removeListener("error",s),r(p.apply(null,arguments))};"error"!==t&&(s=function(r){e.removeListener(t,a),n(r)},e.once("error",s)),i((function(){s&&e.removeListener("error",s),e.removeListener(t,a)})),e.once(t,a)}),{timeout:r.timeout,overload:r.overload})},writable:!0,configurable:!0}}),Object.defineProperties(k,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),"function"==typeof t&&t.amd?t((function(){return T})):e.exports=T}()}(er);var tr=function(e){function t(){var t=this;return(t=e.call(this,{wildcard:!0,delimiter:"::",newListener:!1,removeListener:!1,maxListeners:10,verboseMemoryLeak:!1,ignoreErrors:!1})||this).delimiter="::","undefined"!=typeof document&&(t.body=document.querySelector("body")),t.logableEvents=["cart::item.added.failed","cart::item.deleted.failed"],t.ingoreLogEvents=["document::click","document::keyup","document::change"],t.noneFireableActions=["document.request"],t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}wt(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),t.prototype.createAndDispatch=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.dispatch.apply(this,Lt([e],t,!1))},t.prototype.emit=function(t){for(var r,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];var o=t.replace("::",".");if(!this.noneFireableActions.includes(o)&&Salla.call&&"function"==typeof Salla.call(o))return Salla.log("'Salla.".concat(o,"(...)' triggered using event '").concat(t,"'")),o=o.split("."),Array.isArray(n[0])&&(n=n[0]),void(r=salla[o[0]])[o[1]].apply(r,n);e.prototype.emit.apply(this,Lt([t],n,!1)),this.trackEvents.apply(this,Lt([t],n,!1))},t.prototype.emitAsync=function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var i=e.prototype.emitAsync.apply(this,Lt([t],r,!1));try{this.trackEvents.apply(this,Lt([t],r,!1))}catch(e){Salla.logger.warn("error on tracking event (".concat(t,")"),r,e)}return i},t.prototype.trackEvents=function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];if("undefined"!=typeof window)try{window.dataLayer=window.dataLayer||[];var i={event:e};r.map((function(e){return"object"==typeof e&&(i=St(St({},i),e))})),window.dataLayer.push(i)}catch(e){salla.logger.error(e.message)}Salla.logger&&!this.ingoreLogEvents.includes(e)&&(t=Salla.logger).event.apply(t,Lt([e],r,!1)),this.dispatchMobileEvent.apply(this,Lt([e],r,!1))},t.prototype.dispatch=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return this.emit.apply(this,Lt([e],t,!1))},t.prototype.dispatchEvents=function(e){if(e)if("object"!=typeof e||Array.isArray(e))Salla.log("Events object is wrong, it should be object of {event:payload}",e);else for(var t=0,r=Object.entries(e);t<r.length;t++){var n=r[t],i=n[0],o=n[1];this.dispatch(i,o)}else Salla.log("No Events To Dispatch!",e)},t.prototype.addListener=function(e,t,r){return this.on(e,t,r)},t.prototype.addEventListener=function(e,t,r){return this.on(e,t,r)},t.prototype.listen=function(e,t){return this.on(e,t)},t.prototype.registerGlobalListener=function(e,t){return this.onAny(t)},t.prototype.dispatchMobileEvent=function(e,t){if(void 0===t&&(t={}),!("undefined"!=typeof window&&window.dataLayer&&window.dataLayer[0]&&window.dataLayer[0].page&&window.dataLayer[0].page.mobileApp))return"";if(window.webkit)try{window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:e,details:t}))}catch(e){Salla.log(e,"The native context does not exist yet")}else if(void 0!==window.Android)try{window.Android.customEventWithData(e,JSON.stringify({details:t}))}catch(e){Salla.log(e,"The native context does not exist yet")}},t}(er.exports.EventEmitter2),rr=Object.assign?Object.assign:function(e,t,r,n){for(var i=1;i<arguments.length;i++)lr(Object(arguments[i]),(function(t,r){e[r]=t}));return e},nr=function(){if(Object.create)return function(e,t,r,n){var i=ar(arguments,1);return rr.apply(this,[Object.create(e)].concat(i))};var e=function(){};return function(t,r,n,i){var o=ar(arguments,1);return e.prototype=t,rr.apply(this,[new e].concat(o))}}(),ir=String.prototype.trim?function(e){return String.prototype.trim.call(e)}:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},or="undefined"!=typeof window?window:n,sr={assign:rr,create:nr,trim:ir,bind:function(e,t){return function(){return t.apply(e,Array.prototype.slice.call(arguments,0))}},slice:ar,each:lr,map:function(e,t){var r=ur(e)?[]:{};return cr(e,(function(e,n){return r[n]=t(e,n),!1})),r},pluck:cr,isList:ur,isFunction:function(e){return e&&"[object Function]"==={}.toString.call(e)},isObject:function(e){return e&&"[object Object]"==={}.toString.call(e)},Global:or};function ar(e,t){return Array.prototype.slice.call(e,t||0)}function lr(e,t){cr(e,(function(e,r){return t(e,r),!1}))}function cr(e,t){if(ur(e)){for(var r=0;r<e.length;r++)if(t(e[r],r))return e[r]}else for(var n in e)if(e.hasOwnProperty(n)&&t(e[n],n))return e[n]}function ur(e){return null!=e&&"function"!=typeof e&&"number"==typeof e.length}var fr=sr.slice,hr=sr.pluck,pr=sr.each,vr=sr.bind,dr=sr.create,yr=sr.isList,gr=sr.isFunction,mr=sr.isObject,_r={createStore:wr},br={version:"2.0.12",enabled:!1,get:function(e,t){var r=this.storage.read(this._namespacePrefix+e);return this._deserialize(r,t)},set:function(e,t){return void 0===t?this.remove(e):(this.storage.write(this._namespacePrefix+e,this._serialize(t)),t)},remove:function(e){this.storage.remove(this._namespacePrefix+e)},each:function(e){var t=this;this.storage.each((function(r,n){e.call(t,t._deserialize(r),(n||"").replace(t._namespaceRegexp,""))}))},clearAll:function(){this.storage.clearAll()},hasNamespace:function(e){return this._namespacePrefix=="__storejs_"+e+"_"},createStore:function(){return wr.apply(this,arguments)},addPlugin:function(e){this._addPlugin(e)},namespace:function(e){return wr(this.storage,this.plugins,e)}};function wr(e,t,r){r||(r=""),e&&!yr(e)&&(e=[e]),t&&!yr(t)&&(t=[t]);var n=r?"__storejs_"+r+"_":"",i=r?new RegExp("^"+n):null;if(!/^[a-zA-Z0-9_\-]*$/.test(r))throw new Error("store.js namespaces can only have alphanumerics + underscores and dashes");var o={_namespacePrefix:n,_namespaceRegexp:i,_testStorage:function(e){try{var t="__storejs__test__";e.write(t,t);var r=e.read(t)===t;return e.remove(t),r}catch(e){return!1}},_assignPluginFnProp:function(e,t){var r=this[t];this[t]=function(){var t=fr(arguments,0),n=this;var i=[function(){if(r)return pr(arguments,(function(e,r){t[r]=e})),r.apply(n,t)}].concat(t);return e.apply(n,i)}},_serialize:function(e){return JSON.stringify(e)},_deserialize:function(e,t){if(!e)return t;var r="";try{r=JSON.parse(e)}catch(t){r=e}return void 0!==r?r:t},_addStorage:function(e){this.enabled||this._testStorage(e)&&(this.storage=e,this.enabled=!0)},_addPlugin:function(e){var t=this;if(yr(e))pr(e,(function(e){t._addPlugin(e)}));else if(!hr(this.plugins,(function(t){return e===t}))){if(this.plugins.push(e),!gr(e))throw new Error("Plugins must be function values that return objects");var r=e.call(this);if(!mr(r))throw new Error("Plugins must return an object of function properties");pr(r,(function(r,n){if(!gr(r))throw new Error("Bad plugin property: "+n+" from plugin "+e.name+". Plugins should only return functions.");t._assignPluginFnProp(r,n)}))}},addStorage:function(e){!function(){var e="undefined"==typeof console?null:console;e&&(e.warn?e.warn:e.log).apply(e,arguments)}("store.addStorage(storage) is deprecated. Use createStore([storages])"),this._addStorage(e)}},s=dr(o,br,{plugins:[]});return s.raw={},pr(s,(function(e,t){gr(e)&&(s.raw[t]=vr(s,e))})),pr(e,(function(e){s._addStorage(e)})),pr(t,(function(e){s._addPlugin(e)})),s}var Sr=sr.Global,Lr={name:"localStorage",read:Er,write:function(e,t){return jr().setItem(e,t)},each:function(e){for(var t=jr().length-1;t>=0;t--){var r=jr().key(t);e(Er(r),r)}},remove:function(e){return jr().removeItem(e)},clearAll:function(){return jr().clear()}};function jr(){return Sr.localStorage}function Er(e){return jr().getItem(e)}var xr=e({__proto__:null,default:Lr},[Lr]),Or=sr.Global,Ar={name:"sessionStorage",read:kr,write:function(e,t){return Tr().setItem(e,t)},each:function(e){for(var t=Tr().length-1;t>=0;t--){var r=Tr().key(t);e(kr(r),r)}},remove:function(e){return Tr().removeItem(e)},clearAll:function(){return Tr().clear()}};function Tr(){return Or.sessionStorage}function kr(e){return Tr().getItem(e)}var Pr=e({__proto__:null,default:Ar},[Ar]),Nr=sr.trim,Fr={name:"cookieStorage",read:function(e){if(!e||!$r(e))return null;var t="(?:^|.*;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(zr.cookie.replace(new RegExp(t),"$1"))},write:function(e,t){if(!e)return;zr.cookie=escape(e)+"="+escape(t)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Rr,remove:Mr,clearAll:function(){Rr((function(e,t){Mr(t)}))}},zr=sr.Global.document;function Rr(e){for(var t=zr.cookie.split(/; ?/g),r=t.length-1;r>=0;r--)if(Nr(t[r])){var n=t[r].split("="),i=unescape(n[0]);e(unescape(n[1]),i)}}function Mr(e){e&&$r(e)&&(zr.cookie=escape(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function $r(e){return new RegExp("(?:^|;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(zr.cookie)}var Cr=e({__proto__:null,default:Fr},[Fr]),Ir={name:"memoryStorage",read:function(e){return Dr[e]},write:function(e,t){Dr[e]=t},each:function(e){for(var t in Dr)Dr.hasOwnProperty(t)&&e(Dr[t],t)},remove:function(e){delete Dr[e]},clearAll:function(e){Dr={}}},Dr={};var Ur=e({__proto__:null,default:Ir},[Ir]),Wr=_r.createStore([xr,Pr,Cr,Ur],[]),Gr=function(){function e(){var e=this;Salla.event.on("storage::item.remove",(function(t){return e.remove(t)})),Salla.event.on("storage::item.set",(function(t,r){return e.set(t,r)})),this.store=Wr}return e.prototype.set=function(e,t){var r;if(e.includes(".")){var n=e.split(".")[0],i=((r={})[n]=this.store.get(n),r);return i=Salla.helpers.setNested(i,e,t),this.store.set(n,i[n])}return this.store.set(e,t)},e.prototype.remove=function(e){return this.store.remove(e)},e.prototype.clearAll=function(){return this.store.clearAll()},e.prototype.get=function(e,t){var r;if(e.includes(".")){var n=e.split(".")[0];return Salla.helpers.getNested(((r={})[n]=this.store.get(n),r),e)}return this.store.get(e,t)},e}(),Jr=function(){function e(){var e=this;Salla.event.on("cookies::remove",(function(t){return e.remove(t)})),Salla.event.on("cookies::add",(function(t,r){return e.set(t,r)}))}return e.prototype.get=function(e){var t;return null===(t=document.cookie.split("; ").find((function(t){return t.startsWith(e+"=")})))||void 0===t?void 0:t.split("=")[1]},e.prototype.set=function(e,t,r){void 0===t&&(t=""),void 0===r&&(r=10);var n="";if(r){var i=new Date;i.setTime(i.getTime()+24*r*60*60*1e3),n="; expires="+i.toUTCString()}return document.cookie="".concat(e,"=").concat(t).concat(n,'"; path=/; secure; SameSite=Lax"'),this},e.prototype.remove=function(e){return document.cookie="".concat(e,"=; Max-Age=0; path=/;"),this},e.prototype.clearAll=function(){for(var e=document.cookie.split(";"),t=0;t<e.length;t++){var r=e[t],n=r.indexOf("="),i=n>-1?r.substr(0,n):r;this.remove(i)}},e}();return"undefined"!=typeof window&&(window.salla=window.salla||window.Salla||{},window.Salla=window.salla),"undefined"!=typeof global&&(global.salla=global.salla||global.Salla||{},global.Salla=global.salla),Salla.status="base",Salla.config=new At,Salla.logger=Ot,Salla.event=new tr,Salla.helpers=bt,Salla.storage=new Gr,Salla.cookie=new Jr,Salla.log=Salla.logger.log,Salla.money=Salla.helpers.money,Salla.url=Salla.helpers.url,Salla.versions={base:"2.12.45"},Salla}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("cookie")):"function"==typeof define&&define.amd?define(["cookie"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).Salla=t(e.cookie)}(this,(function(e){"use strict";function t(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}function n(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(n){if("default"!==n&&!(n in e)){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}}))})),Object.freeze(e)}var r=t(e);function i(e,t,n){if(!e)return;let r=e,i=t.split("."),s=i.length;for(let e=0;e<s-1;e++){let t=i[e];r[t]||(r[t]={}),r=r[t]}return r[i[s-1]]=n,e}function s(e,t,n){if(!e)return n;let r=function(e,t,n){if(!e||"object"!=typeof e)return n;const r=Array.isArray(t)?t:t.split(".");let i=e;for(const e of r)if(i=i[e],void 0===i)return n;return i}(e,t);return void 0!==r?r:n}function o(){return"object"==typeof document}class a{default_properties;properties_;static instance;constructor(e={},t={}){this.default_properties=t,this.properties_={...this.default_properties,...e}}static getInstance(e={},t={}){return a.instance||(a.instance=new a(e,t)),a.instance}merge(e){return this.properties_={...this.properties_,...e},this.properties_.store={...this.default_properties?.store||{},...this.properties_.store},this}set(e,t){return e.includes(".")?(i(this.properties_,e,t),this):(this.properties_[e]=t,this)}currency(e){return e=e||this.get("user.currency_code"),this.get("currencies."+e)||Object.values(this.get("currencies"))[0]}get(e,t=null){return e.includes(".")?s(this.properties_,e,t):this.properties_.hasOwnProperty(e)?this.properties_[e]||t:t||void 0}all(){return this.properties_}isDebug(){return this.get("debug")}isGuest(){return"user"!==this.get("user.type")}isUser(){return"user"===this.get("user.type")}}var l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},c=Object.assign?Object.assign:function(e,t,n,r){for(var i=1;i<arguments.length;i++)d(Object(arguments[i]),(function(t,n){e[n]=t}));return e},u=function(){if(Object.create)return function(e,t,n,r){var i=g(arguments,1);return c.apply(this,[Object.create(e)].concat(i))};var e=function(){};return function(t,n,r,i){var s=g(arguments,1);return e.prototype=t,c.apply(this,[new e].concat(s))}}(),f=String.prototype.trim?function(e){return String.prototype.trim.call(e)}:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},h="undefined"!=typeof window?window:l,p={assign:c,create:u,trim:f,bind:function(e,t){return function(){return t.apply(e,Array.prototype.slice.call(arguments,0))}},slice:g,each:d,map:function(e,t){var n=v(e)?[]:{};return m(e,(function(e,r){return n[r]=t(e,r),!1})),n},pluck:m,isList:v,isFunction:function(e){return e&&"[object Function]"==={}.toString.call(e)},isObject:function(e){return e&&"[object Object]"==={}.toString.call(e)},Global:h};function g(e,t){return Array.prototype.slice.call(e,t||0)}function d(e,t){m(e,(function(e,n){return t(e,n),!1}))}function m(e,t){if(v(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 v(e){return null!=e&&"function"!=typeof e&&"number"==typeof e.length}var y=p.slice,_=p.pluck,b=p.each,w=p.bind,L=p.create,k=p.isList,E=p.isFunction,O=p.isObject,j={createStore:T},x={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 T.apply(this,arguments)},addPlugin:function(e){this._addPlugin(e)},namespace:function(e){return T(this.storage,this.plugins,e)}};function T(e,t,n){n||(n=""),e&&!k(e)&&(e=[e]),t&&!k(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 s={_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=y(arguments,0),r=this;var i=[function(){if(n)return b(arguments,(function(e,n){t[n]=e})),n.apply(r,t)}].concat(t);return e.apply(r,i)}},_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(k(e))b(e,(function(e){t._addPlugin(e)}));else if(!_(this.plugins,(function(t){return e===t}))){if(this.plugins.push(e),!E(e))throw new Error("Plugins must be function values that return objects");var n=e.call(this);if(!O(n))throw new Error("Plugins must return an object of function properties");b(n,(function(n,r){if(!E(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;e&&(e.warn?e.warn:e.log).apply(e,arguments)}("store.addStorage(storage) is deprecated. Use createStore([storages])"),this._addStorage(e)}},o=L(s,x,{plugins:[]});return o.raw={},b(o,(function(e,t){E(e)&&(o.raw[t]=w(o,e))})),b(e,(function(e){o._addStorage(e)})),b(t,(function(e){o._addPlugin(e)})),o}var A=p.Global,S={name:"localStorage",read:I,write:function(e,t){return P().setItem(e,t)},each:function(e){for(var t=P().length-1;t>=0;t--){var n=P().key(t);e(I(n),n)}},remove:function(e){return P().removeItem(e)},clearAll:function(){return P().clear()}};function P(){return A.localStorage}function I(e){return P().getItem(e)}var N=n({__proto__:null,default:S},[S]),C=p.Global,D={name:"sessionStorage",read:U,write:function(e,t){return $().setItem(e,t)},each:function(e){for(var t=$().length-1;t>=0;t--){var n=$().key(t);e(U(n),n)}},remove:function(e){return $().removeItem(e)},clearAll:function(){return $().clear()}};function $(){return C.sessionStorage}function U(e){return $().getItem(e)}var F=n({__proto__:null,default:D},[D]),M=p.trim,R={name:"cookieStorage",read:function(e){if(!e||!G(e))return null;var t="(?:^|.*;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(z.cookie.replace(new RegExp(t),"$1"))},write:function(e,t){if(!e)return;z.cookie=escape(e)+"="+escape(t)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:W,remove:J,clearAll:function(){W((function(e,t){J(t)}))}},z=p.Global.document;function W(e){for(var t=z.cookie.split(/; ?/g),n=t.length-1;n>=0;n--)if(M(t[n])){var r=t[n].split("="),i=unescape(r[0]);e(unescape(r[1]),i)}}function J(e){e&&G(e)&&(z.cookie=escape(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function G(e){return new RegExp("(?:^|;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(z.cookie)}var H=n({__proto__:null,default:R},[R]),K={name:"memoryStorage",read:function(e){return q[e]},write:function(e,t){q[e]=t},each:function(e){for(var t in q)q.hasOwnProperty(t)&&e(q[t],t)},remove:function(e){delete q[e]},clearAll:function(e){q={}}},q={};var Z=n({__proto__:null,default:K},[K]);function B(e){return B="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},B(e)}function V(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Q(r.key),r)}}function Q(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function X(){throw new Error("setTimeout has not been defined")}function Y(){throw new Error("clearTimeout has not been defined")}var ee=X,te=Y;function ne(e){if(ee===setTimeout)return setTimeout(e,0);if((ee===X||!ee)&&setTimeout)return ee=setTimeout,setTimeout(e,0);try{return ee(e,0)}catch(t){try{return ee.call(null,e,0)}catch(t){return ee.call(this,e,0)}}}"function"==typeof global.setTimeout&&(ee=setTimeout),"function"==typeof global.clearTimeout&&(te=clearTimeout);var re,ie=[],se=!1,oe=-1;function ae(){se&&re&&(se=!1,re.length?ie=re.concat(ie):oe=-1,ie.length&&le())}function le(){if(!se){var e=ne(ae);se=!0;for(var t=ie.length;t;){for(re=ie,ie=[];++oe<t;)re&&re[oe].run();oe=-1,t=ie.length}re=null,se=!1,function(e){if(te===clearTimeout)return clearTimeout(e);if((te===Y||!te)&&clearTimeout)return te=clearTimeout,clearTimeout(e);try{return te(e)}catch(t){try{return te.call(null,e)}catch(t){return te.call(this,e)}}}(e)}}function ce(e,t){this.fun=e,this.array=t}ce.prototype.run=function(){this.fun.apply(null,this.array)};function ue(){}var fe=ue,he=ue,pe=ue,ge=ue,de=ue,me=ue,ve=ue;var ye=global.performance||{},_e=ye.now||ye.mozNow||ye.msNow||ye.oNow||ye.webkitNow||function(){return(new Date).getTime()};var be=new Date;var we={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];ie.push(new ce(e,t)),1!==ie.length||se||ne(le)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:fe,addListener:he,once:pe,off:ge,removeListener:de,removeAllListeners:me,emit:ve,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*_e.call(ye),n=Math.floor(t),r=Math.floor(t%1*1e9);return e&&(n-=e[0],(r-=e[1])<0&&(n--,r+=1e9)),[n,r]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-be)/1e3}},Le=we,ke={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)},i="object"==B(Le)&&"function"==typeof Le.nextTick,s="function"==typeof Symbol,o="object"===("undefined"==typeof Reflect?"undefined":B(Reflect)),a="function"==typeof setImmediate?setImmediate:setTimeout,l=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 c(){this._events={},this._conf&&u.call(this,this._conf)}function u(e){e&&(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),e.maxListeners!==t&&(this._maxListeners=e.maxListeners),e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),e.ignoreErrors&&(this.ignoreErrors=e.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function f(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!==Le&&Le.emitWarning){var r=new Error(n);r.name="MaxListenersExceededWarning",r.emitter=this,r.count=e,Le.emitWarning(r)}else console.error(n),console.trace&&console.trace()}var h=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,s=n?n.length:0,o=0;o<i;o++)r[e[o]]=o<s?n[o]: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 s=e._observers;s?s.push(this):e._observers=[this]}function d(e,r,i,s){var o=Object.assign({},r);if(!e)return o;if("object"!==B(e))throw TypeError("options must be an object");var a,l,c,u=Object.keys(e),f=u.length;function h(e){throw Error('Invalid "'+a+'" option value'+(e?". Reason: "+e:""))}for(var p=0;p<f;p++){if(a=u[p],!s&&!n.call(r,a))throw Error('Unknown "'+a+'" option');(l=e[a])!==t&&(c=i[a],o[a]=c?c(l,h):l)}return o}function m(e,t){return"function"==typeof e&&e.hasOwnProperty("prototype")||t("value must be a constructor"),e}function v(e){var t="value must be type of "+e.join("|"),n=e.length,r=e[0],i=e[1];return 1===n?function(e,n){if(B(e)===r)return e;n(t)}:2===n?function(e,n){var s=B(e);if(s===r||s===i)return e;n(t)}:function(r,i){for(var s=B(r),o=n;o-- >0;)if(s===e[o])return r;i(t)}}Object.assign(g.prototype,{subscribe:function(e,t,n){var r=this,i=this._target,s=this._emitter,o=this._listeners,a=function(){var r=h.apply(null,arguments),o={data:r,name:t,original:e};n?!1!==n.call(i,o)&&s.emit.apply(s,[o.name].concat(r)):s.emit.apply(s,[t].concat(r))};if(o[e])throw Error("Event '"+e+"' is already listening");this._listenersCount++,s._newListener&&s._removeListener&&!r._onNewListener?(this._onNewListener=function(n){n===t&&null===o[e]&&(o[e]=a,r._on.call(i,e,a))},s.on("newListener",this._onNewListener),this._onRemoveListener=function(n){n===t&&!s.hasListeners(n)&&o[e]&&(o[e]=null,r._off.call(i,e,a))},o[e]=null,s.on("removeListener",this._onRemoveListener)):(o[e]=a,r._on.call(i,e,a))},unsubscribe:function(e){var t,n,r,i=this,s=this._listeners,o=this._emitter,a=this._off,c=this._target;if(e&&"string"!=typeof e)throw TypeError("event must be a string");function u(){i._onNewListener&&(o.off("newListener",i._onNewListener),o.off("removeListener",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var e=w.call(o,i);o._observers.splice(e,1)}if(e){if(!(t=s[e]))return;a.call(c,e,t),delete s[e],--this._listenersCount||u()}else{for(r=(n=l(s)).length;r-- >0;)e=n[r],a.call(c,e,s[e]);this._listeners={},this._listenersCount=0,u()}}});var y=v(["function"]),_=v(["object","function"]);function b(e,t,n){var r,i,s,o=0,a=new e((function(l,c,u){function f(){i&&(i=null),o&&(clearTimeout(o),o=0)}n=d(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){f(),l(e)},p=function(e){f(),c(e)};r?t(h,p,u):(i=[function(e){p(e||Error("canceled"))}],t(h,p,(function(e){if(s)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof e)throw TypeError("onCancel callback must be a function");i.push(e)})),s=!0),n.timeout>0&&(o=setTimeout((function(){var e=Error("timeout");e.code="ETIMEDOUT",o=0,a.cancel(e),c(e)}),n.timeout))}));return r||(a.cancel=function(e){if(i){for(var t=i.length,n=1;n<t;n++)i[n](e);i[0](e),i=null}}),a}function w(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 L(e,t,n,r,i){if(!n)return null;if(0===r){var s=B(t);if("string"===s){var o,a,c=0,u=0,f=this.delimiter,h=f.length;if(-1!==(a=t.indexOf(f))){o=new Array(5);do{o[c++]=t.slice(u,a),u=a+h}while(-1!==(a=t.indexOf(f,u)));o[c++]=t.slice(u),t=o,i=c}else t=[t],i=1}else"object"===s?i=t.length:(t=[t],i=1)}var p,g,d,m,v,y,_,b=null,w=t[r],k=t[r+1];if(r===i)n._listeners&&("function"==typeof n._listeners?(e&&e.push(n._listeners),b=[n]):(e&&e.push.apply(e,n._listeners),b=[n]));else{if("*"===w){for(a=(y=l(n)).length;a-- >0;)"_listeners"!==(p=y[a])&&(_=L(e,t,n[p],r+1,i))&&(b?b.push.apply(b,_):b=_);return b}if("**"===w){for((v=r+1===i||r+2===i&&"*"===k)&&n._listeners&&(b=L(e,t,n,i,i)),a=(y=l(n)).length;a-- >0;)"_listeners"!==(p=y[a])&&("*"===p||"**"===p?(n[p]._listeners&&!v&&(_=L(e,t,n[p],i,i))&&(b?b.push.apply(b,_):b=_),_=L(e,t,n[p],r,i)):_=L(e,t,n[p],p===k?r+2:r,i),_&&(b?b.push.apply(b,_):b=_));return b}n[w]&&(b=L(e,t,n[w],r+1,i))}if((g=n["*"])&&L(e,t,g,r+1,i),d=n["**"])if(r<i)for(d._listeners&&L(e,t,d,i,i),a=(y=l(d)).length;a-- >0;)"_listeners"!==(p=y[a])&&(p===k?L(e,t,d[p],r+2,i):p===w?L(e,t,d[p],r+1,i):((m={})[p]=d[p],L(e,t,{"**":m},r+1,i)));else d._listeners?L(e,t,d,i,i):d["*"]&&d["*"]._listeners&&L(e,t,d["*"],i,i);return b}function k(e,t,n){var r,i,s=0,o=0,a=this.delimiter,l=a.length;if("string"==typeof e)if(-1!==(r=e.indexOf(a))){i=new Array(5);do{i[s++]=e.slice(o,r),o=r+l}while(-1!==(r=e.indexOf(a,o)));i[s++]=e.slice(o)}else i=[e],s=1;else i=e,s=e.length;if(s>1)for(r=0;r+1<s;r++)if("**"===i[r]&&"**"===i[r+1])return;var c,u=this.listenerTree;for(r=0;r<s;r++)if(u=u[c=i[r]]||(u[c]={}),r===s-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,f.call(this,u._listeners.length,c))):u._listeners=t,!0;return!0}function E(e,t,n,r){for(var i,s,o,a,c=l(e),u=c.length,f=e._listeners;u-- >0;)i=e[s=c[u]],o="_listeners"===s?n:n?n.concat(s):[s],a=r||"symbol"===B(s),f&&t.push(a?o:o.join(this.delimiter)),"object"===B(i)&&E.call(this,i,t,o,a);return t}function O(e){for(var t,n,r,i=l(e),s=i.length;s-- >0;)(t=e[n=i[s]])&&(r=!0,"_listeners"===n||O(t)||delete e[n]);return r}function j(e,t,n){this.emitter=e,this.event=t,this.listener=n}function x(e,n,r){if(!0===r)o=!0;else if(!1===r)s=!0;else{if(!r||"object"!==B(r))throw TypeError("options should be an object or true");var s=r.async,o=r.promisify,l=r.nextTick,c=r.objectify}if(s||l||o){var u=n,f=n._origin||n;if(l&&!i)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?l?Promise.resolve():new Promise((function(e){a(e)})).then((function(){return t.event=n,u.apply(t,e)})):(l?Le.nextTick:a)((function(){t.event=n,u.apply(t,e)}))},n._async=!0,n._origin=f}return[n,c?new j(this,e,n):this]}function T(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,u.call(this,e)}j.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},T.EventEmitter2=T,T.prototype.listenTo=function(e,n,i){if("object"!==B(e))throw TypeError("target musts be an object");var s=this;function o(t){if("object"!==B(t))throw TypeError("events must be an object");var n,r=i.reducers,o=w.call(s,e);n=-1===o?new g(s,e,i):s._observers[o];for(var a,c=l(t),u=c.length,f="function"==typeof r,h=0;h<u;h++)a=c[h],n.subscribe(a,t[a]||a,f?r:r&&r[a])}return i=d(i,{on:t,off:t,reducers:t},{on:y,off:y,reducers:_}),r(n)?o(p(n)):o("string"==typeof n?p(n.split(/\s+/)):n),this},T.prototype.stopListeningTo=function(e,t){var n=this._observers;if(!n)return!1;var r,i=n.length,s=!1;if(e&&"object"!==B(e))throw TypeError("target should be an object");for(;i-- >0;)r=n[i],e&&r._target!==e||(r.unsubscribe(t),s=!0);return s},T.prototype.delimiter=".",T.prototype.setMaxListeners=function(e){e!==t&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},T.prototype.getMaxListeners=function(){return this._maxListeners},T.prototype.event="",T.prototype.once=function(e,t,n){return this._once(e,t,!1,n)},T.prototype.prependOnceListener=function(e,t,n){return this._once(e,t,!0,n)},T.prototype._once=function(e,t,n,r){return this._many(e,1,t,n,r)},T.prototype.many=function(e,t,n,r){return this._many(e,t,n,!1,r)},T.prototype.prependMany=function(e,t,n,r){return this._many(e,t,n,!0,r)},T.prototype._many=function(e,t,n,r,i){var s=this;if("function"!=typeof n)throw new Error("many only accepts instances of Function");function o(){return 0==--t&&s.off(e,o),n.apply(this,arguments)}return o._origin=n,this._on(e,o,r,i)},T.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var e,t,n,r,i,o,a=arguments[0],l=this.wildcard;if("newListener"===a&&!this._newListener&&!this._events.newListener)return!1;if(l&&(e=a,"newListener"!==a&&"removeListener"!==a&&"object"===B(a))){if(n=a.length,s)for(r=0;r<n;r++)if("symbol"===B(a[r])){o=!0;break}o||(a=a.join(this.delimiter))}var u,f=arguments.length;if(this._all&&this._all.length)for(r=0,n=(u=this._all.slice()).length;r<n;r++)switch(this.event=a,f){case 1:u[r].call(this,a);break;case 2:u[r].call(this,a,arguments[1]);break;case 3:u[r].call(this,a,arguments[1],arguments[2]);break;default:u[r].apply(this,arguments)}if(l)u=[],L.call(this,u,e,this.listenerTree,0,n);else{if("function"==typeof(u=this._events[a])){switch(this.event=a,f){case 1:u.call(this);break;case 2:u.call(this,arguments[1]);break;case 3:u.call(this,arguments[1],arguments[2]);break;default:for(t=new Array(f-1),i=1;i<f;i++)t[i-1]=arguments[i];u.apply(this,t)}return!0}u&&(u=u.slice())}if(u&&u.length){if(f>3)for(t=new Array(f-1),i=1;i<f;i++)t[i-1]=arguments[i];for(r=0,n=u.length;r<n;r++)switch(this.event=a,f){case 1:u[r].call(this);break;case 2:u[r].call(this,arguments[1]);break;case 3:u[r].call(this,arguments[1],arguments[2]);break;default:u[r].apply(this,t)}return!0}if(!this.ignoreErrors&&!this._all&&"error"===a)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},T.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var e,t,n,r,i,o,a=arguments[0],l=this.wildcard;if("newListener"===a&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(l&&(e=a,"newListener"!==a&&"removeListener"!==a&&"object"===B(a))){if(r=a.length,s)for(i=0;i<r;i++)if("symbol"===B(a[i])){t=!0;break}t||(a=a.join(this.delimiter))}var u,f=[],h=arguments.length;if(this._all)for(i=0,r=this._all.length;i<r;i++)switch(this.event=a,h){case 1:f.push(this._all[i].call(this,a));break;case 2:f.push(this._all[i].call(this,a,arguments[1]));break;case 3:f.push(this._all[i].call(this,a,arguments[1],arguments[2]));break;default:f.push(this._all[i].apply(this,arguments))}if(l?(u=[],L.call(this,u,e,this.listenerTree,0)):u=this._events[a],"function"==typeof u)switch(this.event=a,h){case 1:f.push(u.call(this));break;case 2:f.push(u.call(this,arguments[1]));break;case 3:f.push(u.call(this,arguments[1],arguments[2]));break;default:for(n=new Array(h-1),o=1;o<h;o++)n[o-1]=arguments[o];f.push(u.apply(this,n))}else if(u&&u.length){if(u=u.slice(),h>3)for(n=new Array(h-1),o=1;o<h;o++)n[o-1]=arguments[o];for(i=0,r=u.length;i<r;i++)switch(this.event=a,h){case 1:f.push(u[i].call(this));break;case 2:f.push(u[i].call(this,arguments[1]));break;case 3:f.push(u[i].call(this,arguments[1],arguments[2]));break;default:f.push(u[i].apply(this,n))}}else if(!this.ignoreErrors&&!this._all&&"error"===a)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(f)},T.prototype.on=function(e,t,n){return this._on(e,t,!1,n)},T.prototype.prependListener=function(e,t,n){return this._on(e,t,!0,n)},T.prototype.onAny=function(e){return this._onAny(e,!1)},T.prototype.prependAny=function(e){return this._onAny(e,!0)},T.prototype.addListener=T.prototype.on,T.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},T.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||c.call(this);var s,o=this;return i!==t&&(n=(s=x.call(this,e,n,i))[0],o=s[1]),this._newListener&&this.emit("newListener",e,n),this.wildcard?(k.call(this,e,n,r),o):(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,f.call(this,this._events[e].length,e))):this._events[e]=n,o)},T.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 s="string"==typeof e?e.split(this.delimiter):e.slice();if(!(i=L.call(this,null,s,this.listenerTree,0)))return this}else{if(!this._events[e])return this;n=this._events[e],i.push({_listeners:n})}for(var o=0;o<i.length;o++){var a=i[o];if(n=a._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?a._listeners.splice(l,1):this._events[e].splice(l,1),0===n.length&&(this.wildcard?delete a._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 a._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return this.listenerTree&&O(this.listenerTree),this},T.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},T.prototype.removeListener=T.prototype.off,T.prototype.removeAllListeners=function(e){if(e===t)return!this._events||c.call(this),this;if(this.wildcard){var n,r=L.call(this,null,e,this.listenerTree,0);if(!r)return this;for(n=0;n<r.length;n++)r[n]._listeners=null;this.listenerTree&&O(this.listenerTree)}else this._events&&(this._events[e]=null);return this},T.prototype.listeners=function(e){var n,r,i,s,o,a=this._events;if(e===t){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!a)return[];for(s=(n=l(a)).length,i=[];s-- >0;)"function"==typeof(r=a[n[s]])?i.push(r):i.push.apply(i,r);return i}if(this.wildcard){if(!(o=this.listenerTree))return[];var c=[],u="string"==typeof e?e.split(this.delimiter):e.slice();return L.call(this,c,u,o,0),c}return a&&(r=a[e])?"function"==typeof r?[r]:r:[]},T.prototype.eventNames=function(e){var t=this._events;return this.wildcard?E.call(this,this.listenerTree,[],null,e):t?l(t):[]},T.prototype.listenerCount=function(e){return this.listeners(e).length},T.prototype.hasListeners=function(e){if(this.wildcard){var n=[],r="string"==typeof e?e.split(this.delimiter):e.slice();return L.call(this,n,r,this.listenerTree,0),n.length>0}var i=this._events,s=this._all;return!!(s&&s.length||i&&(e===t?l(i).length:i[e]))},T.prototype.listenersAny=function(){return this._all?this._all:[]},T.prototype.waitFor=function(e,n){var r=this,i=B(n);return"number"===i?n={timeout:n}:"function"===i&&(n={filter:n}),b((n=d(n,{timeout:0,filter:t,handleError:!1,Promise:Promise,overload:!1},{filter:y,Promise:m})).Promise,(function(t,i,s){function o(){var s=n.filter;if(!s||s.apply(r,arguments))if(r.off(e,o),n.handleError){var a=arguments[0];a?i(a):t(h.apply(null,arguments).slice(1))}else t(h.apply(null,arguments))}s((function(){r.off(e,o)})),r._on(e,o,!1)}),{timeout:n.timeout,overload:n.overload})};var A=T.prototype;Object.defineProperties(T,{defaultMaxListeners:{get:function(){return A._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");A._maxListeners=e},enumerable:!0},once:{value:function(e,t,n){return b((n=d(n,{Promise:Promise,timeout:0,overload:!1},{Promise:m})).Promise,(function(n,r,i){var s;if("function"==typeof e.addEventListener)return s=function(){n(h.apply(null,arguments))},i((function(){e.removeEventListener(t,s)})),void e.addEventListener(t,s,{once:!0});var o,a=function(){o&&e.removeListener("error",o),n(h.apply(null,arguments))};"error"!==t&&(o=function(n){e.removeListener(t,a),r(n)},e.once("error",o)),i((function(){o&&e.removeListener("error",o),e.removeListener(t,a)})),e.once(t,a)}),{timeout:n.timeout,overload:n.overload})},writable:!0,configurable:!0}}),Object.defineProperties(A,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),"function"==typeof t&&t.amd?t((function(){return T})):e.exports=T}()}(ke);class Ee{c=console;config;_proxy;historyData=[];get proxy(){return this._proxy}constructor(e=console){this.c=e,this.config=a.getInstance(),this._proxy={log:(e,t)=>{if(!this.config.isDebug())return;this.historyData.push([t,e]),"trace"===this.config.get("debug")&&(t="trace");let n=this.c.log,r=t?n:this.proxy.__dict__[t]||n,i=["%cTwilight","color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;"],s={event:"#CFF680",backend:"#7b68ee",trace:"#f9f9f9",debug:"#f9f9f9",info:"#f9f9f9",warn:"#f9f9f9",error:"#f9f9f9",history:"#f9f9f9"}[t];s&&(i[0]+="%c"+t.substring(0,1).toUpperCase()+t.substring(1),i.push(`margin-left: 5px;color: ${s};font-weight:bold; border:1px solid ${s}; padding: 2px 6px; border-radius: 5px;`)),r.call(this.c,...i.concat(...e))},__dict__:{trace:this.c.trace,debug:this.c.debug,info:this.c.info,warn:this.c.warn,error:this.c.error}}}event(...e){this.proxy.log(e,"event")}trace(...e){this.proxy.log(e,"trace")}debug(...e){this.proxy.log(e,"debug")}info(...e){this.proxy.log(e,"info")}warn(...e){this.proxy.log(e,"warn")}error(...e){this.proxy.log(e,"error")}log(...e){this.proxy.log(e,"")}backend(...e){this.proxy.log(e,"backend")}logs(e){[e].flat().forEach((e=>e&&this.proxy.log([e].flat(),"backend")))}history(){return this.historyData}}class Oe extends ke.exports.EventEmitter2{delimiter;loggableEvents;ignoreLogEvents;nonFireableActions;static instance;logger=new Ee;constructor(){super({wildcard:!0,delimiter:"::",newListener:!1,removeListener:!1,maxListeners:10,verboseMemoryLeak:!1,ignoreErrors:!1}),this.delimiter="::",this.loggableEvents=["cart::item.added.failed","cart::item.deleted.failed"],this.ignoreLogEvents=["document::click","document::keyup","document::change"],this.nonFireableActions=["document.request"]}static getInstance(){return Oe.instance||(Oe.instance=new Oe),Oe.instance}createAndDispatch(e,...t){this.dispatch(e,...t)}emit(e,...t){return super.emit(e,...t),this.trackEvents(e,...t),!0}emitAsync(e,...t){const n=super.emitAsync(e,...t);try{this.trackEvents(e,...t)}catch(n){this.logger.warn(`error on tracking event (${String(e)})`,t,n)}return n}trackEvents(e,...t){if("undefined"!=typeof window)try{window.dataLayer=window.dataLayer||[];let n={event:e};t.map((e=>"object"==typeof e&&(n={...n,...e}))),window.dataLayer.push(n)}catch(e){this.logger.error(e.message)}(Array.isArray(e)?e.filter((e=>this.ignoreLogEvents.includes(e))):this.ignoreLogEvents.includes(e))||this.logger.event(e,...t),this.dispatchMobileEvent(e,t)}dispatch(e,...t){return this.emit(e,...t)}dispatchEvents(e){if(e)if("object"!=typeof e||Array.isArray(e))this.logger.log("Events object is wrong, it should be object of {event:payload}",e);else for(const[t,n]of Object.entries(e))this.dispatch(t,n);else this.logger.log("No Events To Dispatch!",e)}listen(e,t){return this.on(e,t)}dispatchMobileEvent(e,t={}){if("undefined"!=typeof window&&window.dataLayer&&window.dataLayer[0]&&window.dataLayer[0].page&&window.dataLayer[0].page.mobileApp)if(window.webkit)try{window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:e,details:t}))}catch(e){this.logger.log(e,"The native context does not exist yet")}else if(window.Android)try{window.Android.customEventWithData(e,JSON.stringify({details:t}))}catch(e){this.logger.log(e,"The native context does not exist yet")}}}const je=[N,F,H,Z],xe=j.createStore(je,[],"salla");class Te{static instance;store;constructor(){this.store=xe;let e=Oe.getInstance();e.on("storage::item.remove",(e=>this.remove(e))),e.on("storage::item.set",((e,t)=>this.set(e,t)))}static getInstance(){return Te.instance||(Te.instance=new Te),Te.instance}set(e,t){if(e.includes(".")){const n=e.split(".")[0],r=i({[n]:this.store.get(n)},e,t);this.store.set(n,r[n])}else this.store.set(e,t)}remove(e){this.store.remove(e)}clearAll(){this.store.clearAll()}get(e,t){if(e.includes(".")){const t=e.split(".")[0];return s({[t]:this.store.get(t)},e,void 0)}return this.store.get(e,t)}}function Ae(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=function(e){if(e&&"j"===e[0]&&":"===e[1])return e.substr(2);return e}(e);if(!t.doNotParse)try{return JSON.parse(n)}catch(e){}return e}var Se=function(){function e(t){var n=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.changeListeners=[],this.HAS_DOCUMENT_COOKIE=!1,this.update=function(){if(n.HAS_DOCUMENT_COOKIE){var e=n.cookies;n.cookies=r.parse(document.cookie),n._checkChanges(e)}};var s="undefined"==typeof document?"":document.cookie;this.cookies=function(e){return"string"==typeof e?r.parse(e):"object"===B(e)&&null!==e?e:{}}(t||s),this.defaultSetOptions=i,this.HAS_DOCUMENT_COOKIE="object"===("undefined"==typeof document?"undefined":B(document))&&"string"==typeof document.cookie}var t,n,i;return t=e,n=[{key:"_emitChange",value:function(e){for(var t=0;t<this.changeListeners.length;++t)this.changeListeners[t](e)}},{key:"_checkChanges",value:function(e){var t=this;new Set(Object.keys(e).concat(Object.keys(this.cookies))).forEach((function(n){e[n]!==t.cookies[n]&&t._emitChange({name:n,value:Ae(e[n])})}))}},{key:"_startPolling",value:function(){this.pollingInterval=setInterval(this.update,300)}},{key:"_stopPolling",value:function(){this.pollingInterval&&clearInterval(this.pollingInterval)}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.doNotUpdate||this.update(),Ae(this.cookies[e],t)}},{key:"getAll",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.doNotUpdate||this.update();var t={};for(var n in this.cookies)t[n]=Ae(this.cookies[n],e);return t}},{key:"set",value:function(e,t,n){n=n?Object.assign(Object.assign({},this.defaultSetOptions),n):this.defaultSetOptions;var i="string"==typeof t?t:JSON.stringify(t);this.cookies=Object.assign(Object.assign({},this.cookies),function(e,t,n){return(t=Q(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}({},e,i)),this.HAS_DOCUMENT_COOKIE&&(document.cookie=r.serialize(e,i,n)),this._emitChange({name:e,value:t,options:n})}},{key:"remove",value:function(e,t){var n=t=Object.assign(Object.assign({},t),{expires:new Date(1970,1,1,0,0,1),maxAge:0});this.cookies=Object.assign({},this.cookies),delete this.cookies[e],this.HAS_DOCUMENT_COOKIE&&(document.cookie=r.serialize(e,"",n)),this._emitChange({name:e,value:void 0,options:t})}},{key:"addChangeListener",value:function(e){this.changeListeners.push(e),1===this.changeListeners.length&&("object"===("undefined"==typeof window?"undefined":B(window))&&"cookieStore"in window?window.cookieStore.addEventListener("change",this.update):this._startPolling())}},{key:"removeChangeListener",value:function(e){var t=this.changeListeners.indexOf(e);t>=0&&this.changeListeners.splice(t,1),0===this.changeListeners.length&&("object"===("undefined"==typeof window?"undefined":B(window))&&"cookieStore"in window?window.cookieStore.removeEventListener("change",this.update):this._stopPolling())}}],n&&V(t.prototype,n),i&&V(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}(),Pe=Se;const Ie=new Ee,Ne=a.getInstance();function Ce(e,t=!1){e=String(e);const n=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],r=["0","1","2","3","4","5","6","7","8","9"],i=(t=t||!Ne.get("store.settings.arabic_numbers_enabled"))?n:r,s=t?r:n;let o;for(let t=0;t<i.length;t++)o=new RegExp(i[t],"g"),e=e.replace(o,s[t]);return e.replace(t?"٫":".",t?".":"٫")}function De(e){return Ce(e,!0).replace(/[^0-9.]/g,"").replace("..",".").replace(/\.$/,"")}function $e(e){const t=(`${e}`.match(/\./g)||[]).length;return t&&1!==t?$e(e.replace(/\.(.+)\./g,".$1")):e}var Ue={number:Ce,digitsOnly:De,inputDigitsOnly:function e(t,n=!1){if(!o())return;if("string"==typeof t)return void document.querySelectorAll(t).forEach((t=>e(t,n)));if(!t)return void Ie.warn("Can't find Object With Id: "+t);let r=De(t.value);t.min&&parseInt(r)<parseInt(t.min)?t.value=t.min:t.max&&parseInt(r)>parseInt(t.max)?t.value=t.max:t.maxLength>=1&&r.length>t.maxLength?t.value=r.toString().substring(0,t.maxLength):t.value=n||t.dataset.hasOwnProperty("digitsWithDecimal")?$e(r):r.replace(/\D/g,"")},getOnlyDecimal:$e,money:function(e){const t=Ne.currency(e.currency).symbol;return Ce(e="object"==typeof e?e.amount:e)+" "+t}};class Fe{config;constructor(){this.config=a.getInstance()}isFullUrl(e){return e.startsWith("https://")||e.startsWith("http://")}getBase(e){if(this.isFullUrl(e))return e;const{hostname:t}=new URL(this.get("/"));return`https://${t}/${e?.ltrim("/")}`}get(e){if(this.isFullUrl(e))return e;let t=this.config.get("store.url");return!t&&o()&&(t=window.location.href.split("/").slice(0,-1).join("/"),this.config.set("store.url",t)),`${t.rtrim("/")}/${e?.ltrim("/")}`}getDomain(e){return this.isFullUrl(e)?e:`${this.config.get("store.url",(o()?window.location.href:"").split("/").slice(0,-1).join("/")).rtrim("/")}/${e?.ltrim("/")}`}static addParamToUrl(e,t,n){if(!n)return"";if(!t||!e)return n;const r=new RegExp(`([?&])${e}=[^&]+[&]?`,"g");return(n=n.replace(r,"$1").split("#")[0].replace(/&$|\?$/,"")).includes("?")?n+="&":n+=(n.endsWith("/")?"":"/")+"?",`${n}${e}=${encodeURIComponent(t)}`.replace(/&$|\?$/,"")}baseUrl(e){return`${o()?window.location.origin:"http://localhost"}/${e?.ltrim("/")}`}asset(e){return this.isFullUrl(e)?e:this.config.get("theme.assets")?this.config.get("theme.assets").replace(":path",e?.ltrim("/")):this.baseUrl(`themes/${this.config.get("theme.name")}/${e?.ltrim("/")}`)}cdn(e){return`https://cdn.salla.network/${e?.ltrim("/")}`}api(e){return`${this.config.get("store.api",this.get(""))?.rtrim("/")}/${e?.ltrim("/")}`}isPage(e){return!!e&&this.config.get("page.slug")===e}isPlaceholder(e){return this.asset(this.config.get("theme.settings.placeholder"))===this.asset(e)}isAValidUrl(e){try{return new URL(e),!0}catch(e){return!1}}}function Me(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]=Me(e.slice(1),t,n[r]),n):r?{[r]:Me(e.slice(1),t)}:""===r?[t]:t}var Re={digitsOnly:Ue.digitsOnly,inputDigitsOnly:Ue.inputDigitsOnly,number:Ue.number,money:Ue.money,getOnlyDecimal:Ue.getOnlyDecimal,setNested:i,getNested:s,getInputDataWithName:function(e,t,n={}){if(e.includes("[")){let r=e.split("]").join("").split("[");return{name:r[0],value:Me(r.slice(1),t,n[r[0]])}}return{name:e,value:t}},hasDocument:o,url:new Fe,addParamToUrl:Fe.addParamToUrl,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)))}}};String.prototype.toStudlyCase=function(){return this.trim().replace(/([^a-zA-Z\d].)/g,(e=>e.toUpperCase().replace(/[^a-zA-Z\d]/g,"")))},String.prototype.toDatasetName=function(){return this.startsWith("data-")?this.substr(5).toStudlyCase():this.toStudlyCase()},String.prototype.toSelector=function(){return this.trim().startsWith(".")||this.trim().startsWith("#")?this.toString():"#"+this.toString()},String.prototype.replaceArray=function(e,t){let n,r=this;for(let 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="\\s"){return this.replace(new RegExp("["+e+"]*$"),"")},String.prototype.ltrim=function(e="\\s"){return this.replace(new RegExp("^["+e+"]*"),"")},String.prototype.digitsOnly=function(){return Ue.digitsOnly(this)};return{Config:a,Logger:Ee,helpers:Re,Emitter:Oe,Storage:Te,SallaCookies:class extends Pe{constructor(){super();let e=Oe.getInstance();e.on("cookies::remove",(e=>this.remove(e))),e.on("cookies::add",((e,t)=>this.set(e,t)))}clearAll(){o()&&"string"==typeof document.cookie&&document.cookie.split(";").forEach((function(e){document.cookie=e.replace(/^ +/,"").replace(/=.*/,"=;expires="+(new Date).toUTCString()+";path=/")}));const e=this.getAll();for(let t in e)this.remove(t)}},url:new Fe,log:(new Ee).log,money:Re.money,error:(new Ee).error,isDebug:()=>a.getInstance().get("debug")||Te.getInstance().get("debug"),status:"base",versions:{base:"2.12.47"}}}));
|
|
2
2
|
//# sourceMappingURL=base.min.js.map
|