@salla.sa/twilight-components 2.13.54 → 2.13.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{app-globals-db36c588.js → app-globals-9d2c1cb5.js} +2 -2
- package/dist/cjs/app-globals-9d2c1cb5.js.map +1 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/salla-add-product-button_47.cjs.entry.js.map +1 -1
- package/dist/cjs/salla-reviews.cjs.entry.js +1 -1
- package/dist/cjs/salla-reviews.cjs.entry.js.map +1 -1
- package/dist/cjs/twilight.cjs.js +1 -1
- package/dist/collection/components/salla-reviews/salla-reviews.js +1 -1
- package/dist/collection/components/salla-reviews/salla-reviews.js.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/salla-quick-buy2.js.map +1 -1
- package/dist/components/salla-reviews.js +1 -1
- package/dist/components/salla-reviews.js.map +1 -1
- package/dist/esm/{app-globals-29abf3e3.js → app-globals-ebede509.js} +2 -2
- package/dist/esm/app-globals-ebede509.js.map +1 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/salla-add-product-button_47.entry.js.map +1 -1
- package/dist/esm/salla-reviews.entry.js +1 -1
- package/dist/esm/salla-reviews.entry.js.map +1 -1
- package/dist/esm/twilight.js +1 -1
- package/dist/esm-es5/{app-globals-29abf3e3.js → app-globals-ebede509.js} +2 -2
- package/dist/esm-es5/{app-globals-29abf3e3.js.map → app-globals-ebede509.js.map} +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/salla-add-product-button_47.entry.js.map +1 -1
- package/dist/esm-es5/salla-reviews.entry.js +1 -1
- package/dist/esm-es5/salla-reviews.entry.js.map +1 -1
- package/dist/esm-es5/twilight.js +1 -1
- package/dist/twilight/{p-546db59b.entry.js → p-01bb73c0.entry.js} +2 -2
- package/dist/twilight/{p-546db59b.entry.js.map → p-01bb73c0.entry.js.map} +1 -1
- package/dist/twilight/{p-a7b263b2.system.js → p-0214de39.system.js} +2 -2
- package/dist/twilight/{p-a7b263b2.system.js.map → p-0214de39.system.js.map} +1 -1
- package/dist/twilight/{p-f51c9acb.system.js → p-3d7db383.system.js} +2 -2
- package/dist/twilight/p-5be05a17.system.entry.js.map +1 -1
- package/dist/twilight/{p-2866def3.system.entry.js → p-989d0264.system.entry.js} +2 -2
- package/dist/twilight/{p-2866def3.system.entry.js.map → p-989d0264.system.entry.js.map} +1 -1
- package/dist/twilight/p-bc7cb3df.entry.js.map +1 -1
- package/dist/twilight/{p-06221496.js → p-f6f43db8.js} +2 -2
- package/dist/twilight/{p-06221496.js.map → p-f6f43db8.js.map} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/twilight/twilight.js +1 -1
- package/package.json +5 -5
- package/dist/cjs/app-globals-db36c588.js.map +0 -1
- package/dist/esm/app-globals-29abf3e3.js.map +0 -1
- /package/dist/twilight/{p-f51c9acb.system.js.map → p-3d7db383.system.js.map} +0 -0
|
@@ -21,5 +21,5 @@ import{c as t,a as e}from"./p-f84bae34.js";var n=Array.isArray;var i=n;var r=typ
|
|
|
21
21
|
* @site https://github.com/rmariuzzo/Lang.js
|
|
22
22
|
* @author Rubens Mariuzzo <rubens@mariuzzo.com>
|
|
23
23
|
*/
|
|
24
|
-
(function(t,n){{e.exports=n()}})(t,(function(){function t(){if(typeof document!=="undefined"&&document.documentElement){return document.documentElement.lang}}function e(t){if(t==="-Inf"){return-Infinity}else if(t==="+Inf"||t==="Inf"||t==="*"){return Infinity}return parseInt(t,10)}var n=/^({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])$/;var i=/({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])/;var r={locale:"en"};var a=function(e){e=e||{};this.locale=e.locale||t()||r.locale;this.fallback=e.fallback;this.messages=e.messages};a.prototype.setMessages=function(t){this.messages=t};a.prototype.getLocale=function(){return this.locale||this.fallback};a.prototype.setLocale=function(t){this.locale=t};a.prototype.getFallback=function(){return this.fallback};a.prototype.setFallback=function(t){this.fallback=t};a.prototype.has=function(t,e){if(typeof t!=="string"||!this.messages){return false}return this._getMessage(t,e)!==null};a.prototype.get=function(t,e,n){if(!this.has(t,n)){return t}var i=this._getMessage(t,n);if(i===null){return t}if(e){i=this._applyReplacements(i,e)}return i};a.prototype.trans=function(t,e){return this.get(t,e)};a.prototype.choice=function(t,e,n,r){n=typeof n!=="undefined"?n:{};n.count=e;var a=this.get(t,n,r);if(a===null||a===undefined){return a}var s=a.split("|");var o=[];for(var l=0;l<s.length;l++){s[l]=s[l].trim();if(i.test(s[l])){var u=s[l].split(/\s/);o.push(u.shift());s[l]=u.join(" ")}}if(s.length===1){return a}for(var c=0;c<o.length;c++){if(this._testInterval(e,o[c])){return s[c]}}r=r||this._getLocale(t);var f=this._getPluralForm(e,r);return s[f]};a.prototype.transChoice=function(t,e,n){return this.choice(t,e,n)};a.prototype._parseKey=function(t,e){if(typeof t!=="string"||typeof e!=="string"){return null}var n=t.split(".");var i=n[0].replace(/\//g,".");return{source:e+"."+i,sourceFallback:this.getFallback()+"."+i,entries:n.slice(1)}};a.prototype._getMessage=function(t,e){e=e||this.getLocale();t=this._parseKey(t,e);if(this.messages[t.source]===undefined&&this.messages[t.sourceFallback]===undefined){return null}var n=this.messages[t.source];var i=t.entries.slice();var r=i.join(".");n=n!==undefined?this._getValueInKey(n,r):undefined;if(typeof n!=="string"&&this.messages[t.sourceFallback]){n=this.messages[t.sourceFallback];i=t.entries.slice();r="";while(i.length&&n!==undefined){var r=!r?i.shift():r.concat(".",i.shift());if(n[r]){n=n[r];r=""}}}if(typeof n!=="string"){return null}return n};a.prototype._getValueInKey=function(t,e){if(typeof t[e]==="string"){return t[e]}e=e.replace(/\[(\w+)\]/g,".$1");e=e.replace(/^\./,"");var n=e.split(".");for(var i=0,r=n.length;i<r;++i){var a=n.slice(0,i+1).join(".");var s=n.slice(i+1,n.length).join(".");if(t[a]){return this._getValueInKey(t[a],s)}}return t};a.prototype._getLocale=function(t){t=this._parseKey(t,this.locale);if(this.messages[t.source]){return this.locale}if(this.messages[t.sourceFallback]){return this.fallback}return null};a.prototype._findMessageInTree=function(t,e){while(t.length&&e!==undefined){var n=t.join(".");if(e[n]){e=e[n];break}e=e[t.shift()]}return e};a.prototype._sortReplacementKeys=function(t,e){return e.length-t.length};a.prototype._applyReplacements=function(t,e){var n=Object.keys(e).sort(this._sortReplacementKeys);n.forEach((function(n){t=t.replace(new RegExp(":"+n,"gi"),(function(t){var i=e[n];var r=t===t.toUpperCase();if(r){return i.toUpperCase()}var a=t===t.replace(/\w/i,(function(t){return t.toUpperCase()}));if(a){return i.charAt(0).toUpperCase()+i.slice(1)}return i}))}));return t};a.prototype._testInterval=function(t,i){if(typeof i!=="string"){throw"Invalid interval: should be a string."}i=i.trim();var r=i.match(n);if(!r){throw"Invalid interval: "+i}if(r[2]){var a=r[2].split(",");for(var s=0;s<a.length;s++){if(parseInt(a[s],10)===t){return true}}}else{r=r.filter((function(t){return!!t}));var o=r[1];var l=e(r[2]);if(l===Infinity){l=-Infinity}var u=e(r[3]);var c=r[4];return(o==="["?t>=l:t>l)&&(c==="]"?t<=u:t<u)}return false};a.prototype._getPluralForm=function(t,e){switch(e){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":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 t==1?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 t===0||t===1?0:1;case"be":case"bs":case"hr":case"ru":case"sr":case"uk":return t%10==1&&t%100!=11?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2;case"cs":case"sk":return t==1?0:t>=2&&t<=4?1:2;case"ga":return t==1?0:t==2?1:2;case"lt":return t%10==1&&t%100!=11?0:t%10>=2&&(t%100<10||t%100>=20)?1:2;case"sl":return t%100==1?0:t%100==2?1:t%100==3||t%100==4?2:3;case"mk":return t%10==1?0:1;case"mt":return t==1?0:t===0||t%100>1&&t%100<11?1:t%100>10&&t%100<20?2:3;case"lv":return t===0?0:t%10==1&&t%100!=11?1:2;case"pl":return t==1?0:t%10>=2&&t%10<=4&&(t%100<12||t%100>14)?1:2;case"cy":return t==1?0:t==2?1:t==8||t==11?2:3;case"ro":return t==1?0:t===0||t%100>0&&t%100<20?1:2;case"ar":return t===0?0:t==1?1:t==2?2:t%100>=3&&t%100<=10?3:t%100>=11&&t%100<=99?4:5;default:return 0}};return a}))}));var Di=function t(e,n){return function t(){var i=new Array(arguments.length);for(var r=0;r<i.length;r++){i[r]=arguments[r]}return e.apply(n,i)}};var Li=Object.prototype.toString;var $i=function(t){return function(e){var n=Li.call(e);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())}}(Object.create(null));function Ni(t){t=t.toLowerCase();return function e(n){return $i(n)===t}}function qi(t){return Array.isArray(t)}function Ui(t){return typeof t==="undefined"}function Mi(t){return t!==null&&!Ui(t)&&t.constructor!==null&&!Ui(t.constructor)&&typeof t.constructor.isBuffer==="function"&&t.constructor.isBuffer(t)}var zi=Ni("ArrayBuffer");function Bi(t){var e;if(typeof ArrayBuffer!=="undefined"&&ArrayBuffer.isView){e=ArrayBuffer.isView(t)}else{e=t&&t.buffer&&zi(t.buffer)}return e}function Ji(t){return typeof t==="string"}function Gi(t){return typeof t==="number"}function Hi(t){return t!==null&&typeof t==="object"}function Vi(t){if($i(t)!=="object"){return false}var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}var Qi=Ni("Date");var Wi=Ni("File");var Xi=Ni("Blob");var Zi=Ni("FileList");function Ki(t){return Li.call(t)==="[object Function]"}function Yi(t){return Hi(t)&&Ki(t.pipe)}function tr(t){var e="[object FormData]";return t&&(typeof FormData==="function"&&t instanceof FormData||Li.call(t)===e||Ki(t.toString)&&t.toString()===e)}var er=Ni("URLSearchParams");function nr(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function ir(){if(typeof navigator!=="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")){return false}return typeof window!=="undefined"&&typeof document!=="undefined"}function rr(t,e){if(t===null||typeof t==="undefined"){return}if(typeof t!=="object"){t=[t]}if(qi(t)){for(var n=0,i=t.length;n<i;n++){e.call(null,t[n],n,t)}}else{for(var r in t){if(Object.prototype.hasOwnProperty.call(t,r)){e.call(null,t[r],r,t)}}}}function ar(){var t={};function e(e,n){if(Vi(t[n])&&Vi(e)){t[n]=ar(t[n],e)}else if(Vi(e)){t[n]=ar({},e)}else if(qi(e)){t[n]=e.slice()}else{t[n]=e}}for(var n=0,i=arguments.length;n<i;n++){rr(arguments[n],e)}return t}function sr(t,e,n){rr(e,(function e(i,r){if(n&&typeof i==="function"){t[r]=Di(i,n)}else{t[r]=i}}));return t}function or(t){if(t.charCodeAt(0)===65279){t=t.slice(1)}return t}function lr(t,e,n,i){t.prototype=Object.create(e.prototype,i);t.prototype.constructor=t;n&&Object.assign(t.prototype,n)}function ur(t,e,n){var i;var r;var a;var s={};e=e||{};do{i=Object.getOwnPropertyNames(t);r=i.length;while(r-- >0){a=i[r];if(!s[a]){e[a]=t[a];s[a]=true}}t=Object.getPrototypeOf(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e}function cr(t,e,n){t=String(t);if(n===undefined||n>t.length){n=t.length}n-=e.length;var i=t.indexOf(e,n);return i!==-1&&i===n}function fr(t){if(!t)return null;var e=t.length;if(Ui(e))return null;var n=new Array(e);while(e-- >0){n[e]=t[e]}return n}var hr=function(t){return function(e){return t&&e instanceof t}}(typeof Uint8Array!=="undefined"&&Object.getPrototypeOf(Uint8Array));var dr={isArray:qi,isArrayBuffer:zi,isBuffer:Mi,isFormData:tr,isArrayBufferView:Bi,isString:Ji,isNumber:Gi,isObject:Hi,isPlainObject:Vi,isUndefined:Ui,isDate:Qi,isFile:Wi,isBlob:Xi,isFunction:Ki,isStream:Yi,isURLSearchParams:er,isStandardBrowserEnv:ir,forEach:rr,merge:ar,extend:sr,trim:nr,stripBOM:or,inherits:lr,toFlatObject:ur,kindOf:$i,kindOfTest:Ni,endsWith:cr,toArray:fr,isTypedArray:hr,isFileList:Zi};function pr(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var vr=function t(e,n,i){if(!n){return e}var r;if(i){r=i(n)}else if(dr.isURLSearchParams(n)){r=n.toString()}else{var a=[];dr.forEach(n,(function t(e,n){if(e===null||typeof e==="undefined"){return}if(dr.isArray(e)){n=n+"[]"}else{e=[e]}dr.forEach(e,(function t(e){if(dr.isDate(e)){e=e.toISOString()}else if(dr.isObject(e)){e=JSON.stringify(e)}a.push(pr(n)+"="+pr(e))}))}));r=a.join("&")}if(r){var s=e.indexOf("#");if(s!==-1){e=e.slice(0,s)}e+=(e.indexOf("?")===-1?"?":"&")+r}return e};function gr(){this.handlers=[]}gr.prototype.use=function t(e,n,i){this.handlers.push({fulfilled:e,rejected:n,synchronous:i?i.synchronous:false,runWhen:i?i.runWhen:null});return this.handlers.length-1};gr.prototype.eject=function t(e){if(this.handlers[e]){this.handlers[e]=null}};gr.prototype.forEach=function t(e){dr.forEach(this.handlers,(function t(n){if(n!==null){e(n)}}))};var mr=gr;var wr=function t(e,n){dr.forEach(e,(function t(i,r){if(r!==n&&r.toUpperCase()===n.toUpperCase()){e[n]=i;delete e[r]}}))};function yr(t,e,n,i,r){Error.call(this);this.message=t;this.name="AxiosError";e&&(this.code=e);n&&(this.config=n);i&&(this.request=i);r&&(this.response=r)}dr.inherits(yr,Error,{toJSON:function t(){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 br=yr.prototype;var Sr={};["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(t){Sr[t]={value:t}}));Object.defineProperties(yr,Sr);Object.defineProperty(br,"isAxiosError",{value:true});yr.from=function(t,e,n,i,r,a){var s=Object.create(br);dr.toFlatObject(t,s,(function t(e){return e!==Error.prototype}));yr.call(s,t.message,e,n,i,r);s.name=t.name;a&&Object.assign(s,a);return s};var _r=yr;var xr={silentJSONParsing:true,forcedJSONParsing:true,clarifyTimeoutError:false};function jr(t,e){e=e||new FormData;var n=[];function i(t){if(t===null)return"";if(dr.isDate(t)){return t.toISOString()}if(dr.isArrayBuffer(t)||dr.isTypedArray(t)){return typeof Blob==="function"?new Blob([t]):Buffer.from(t)}return t}function r(t,a){if(dr.isPlainObject(t)||dr.isArray(t)){if(n.indexOf(t)!==-1){throw Error("Circular reference detected in "+a)}n.push(t);dr.forEach(t,(function t(n,s){if(dr.isUndefined(n))return;var o=a?a+"."+s:s;var l;if(n&&!a&&typeof n==="object"){if(dr.endsWith(s,"{}")){n=JSON.stringify(n)}else if(dr.endsWith(s,"[]")&&(l=dr.toArray(n))){l.forEach((function(t){!dr.isUndefined(t)&&e.append(o,i(t))}));return}}r(n,o)}));n.pop()}else{e.append(a,i(t))}}r(t);return e}var Er=jr;var Or=function t(e,n,i){var r=i.config.validateStatus;if(!i.status||!r||r(i.status)){e(i)}else{n(new _r("Request failed with status code "+i.status,[_r.ERR_BAD_REQUEST,_r.ERR_BAD_RESPONSE][Math.floor(i.status/100)-4],i.config,i.request,i))}};var Fr=dr.isStandardBrowserEnv()?function t(){return{write:function t(e,n,i,r,a,s){var o=[];o.push(e+"="+encodeURIComponent(n));if(dr.isNumber(i)){o.push("expires="+new Date(i).toGMTString())}if(dr.isString(r)){o.push("path="+r)}if(dr.isString(a)){o.push("domain="+a)}if(s===true){o.push("secure")}document.cookie=o.join("; ")},read:function t(e){var n=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function t(e){this.write(e,"",Date.now()-864e5)}}}():function t(){return{write:function t(){},read:function t(){return null},remove:function t(){}}}();var kr=function t(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)};var Ar=function t(e,n){return n?e.replace(/\/+$/,"")+"/"+n.replace(/^\/+/,""):e};var Ir=function t(e,n){if(e&&!kr(n)){return Ar(e,n)}return n};var Tr=["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"];var Rr=function t(e){var n={};var i;var r;var a;if(!e){return n}dr.forEach(e.split("\n"),(function t(e){a=e.indexOf(":");i=dr.trim(e.substr(0,a)).toLowerCase();r=dr.trim(e.substr(a+1));if(i){if(n[i]&&Tr.indexOf(i)>=0){return}if(i==="set-cookie"){n[i]=(n[i]?n[i]:[]).concat([r])}else{n[i]=n[i]?n[i]+", "+r:r}}}));return n};var Pr=dr.isStandardBrowserEnv()?function t(){var e=/(msie|trident)/i.test(navigator.userAgent);var n=document.createElement("a");var i;function r(t){var i=t;if(e){n.setAttribute("href",i);i=n.href}n.setAttribute("href",i);return{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}i=r(window.location.href);return function t(e){var n=dr.isString(e)?r(e):e;return n.protocol===i.protocol&&n.host===i.host}}():function t(){return function t(){return true}}();function Cr(t){_r.call(this,t==null?"canceled":t,_r.ERR_CANCELED);this.name="CanceledError"}dr.inherits(Cr,_r,{__CANCEL__:true});var Dr=Cr;var Lr=function t(e){var n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return n&&n[1]||""};var $r=function t(e){return new Promise((function t(n,i){var r=e.data;var a=e.headers;var s=e.responseType;var o;function l(){if(e.cancelToken){e.cancelToken.unsubscribe(o)}if(e.signal){e.signal.removeEventListener("abort",o)}}if(dr.isFormData(r)&&dr.isStandardBrowserEnv()){delete a["Content-Type"]}var u=new XMLHttpRequest;if(e.auth){var c=e.auth.username||"";var f=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";a.Authorization="Basic "+btoa(c+":"+f)}var h=Ir(e.baseURL,e.url);u.open(e.method.toUpperCase(),vr(h,e.params,e.paramsSerializer),true);u.timeout=e.timeout;function d(){if(!u){return}var t="getAllResponseHeaders"in u?Rr(u.getAllResponseHeaders()):null;var r=!s||s==="text"||s==="json"?u.responseText:u.response;var a={data:r,status:u.status,statusText:u.statusText,headers:t,config:e,request:u};Or((function t(e){n(e);l()}),(function t(e){i(e);l()}),a);u=null}if("onloadend"in u){u.onloadend=d}else{u.onreadystatechange=function t(){if(!u||u.readyState!==4){return}if(u.status===0&&!(u.responseURL&&u.responseURL.indexOf("file:")===0)){return}setTimeout(d)}}u.onabort=function t(){if(!u){return}i(new _r("Request aborted",_r.ECONNABORTED,e,u));u=null};u.onerror=function t(){i(new _r("Network Error",_r.ERR_NETWORK,e,u,u));u=null};u.ontimeout=function t(){var n=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";var r=e.transitional||xr;if(e.timeoutErrorMessage){n=e.timeoutErrorMessage}i(new _r(n,r.clarifyTimeoutError?_r.ETIMEDOUT:_r.ECONNABORTED,e,u));u=null};if(dr.isStandardBrowserEnv()){var p=(e.withCredentials||Pr(h))&&e.xsrfCookieName?Fr.read(e.xsrfCookieName):undefined;if(p){a[e.xsrfHeaderName]=p}}if("setRequestHeader"in u){dr.forEach(a,(function t(e,n){if(typeof r==="undefined"&&n.toLowerCase()==="content-type"){delete a[n]}else{u.setRequestHeader(n,e)}}))}if(!dr.isUndefined(e.withCredentials)){u.withCredentials=!!e.withCredentials}if(s&&s!=="json"){u.responseType=e.responseType}if(typeof e.onDownloadProgress==="function"){u.addEventListener("progress",e.onDownloadProgress)}if(typeof e.onUploadProgress==="function"&&u.upload){u.upload.addEventListener("progress",e.onUploadProgress)}if(e.cancelToken||e.signal){o=function(t){if(!u){return}i(!t||t&&t.type?new Dr:t);u.abort();u=null};e.cancelToken&&e.cancelToken.subscribe(o);if(e.signal){e.signal.aborted?o():e.signal.addEventListener("abort",o)}}if(!r){r=null}var v=Lr(h);if(v&&["http","https","file"].indexOf(v)===-1){i(new _r("Unsupported protocol "+v+":",_r.ERR_BAD_REQUEST,e));return}u.send(r)}))};var Nr=null;var qr={"Content-Type":"application/x-www-form-urlencoded"};function Ur(t,e){if(!dr.isUndefined(t)&&dr.isUndefined(t["Content-Type"])){t["Content-Type"]=e}}function Mr(){var t;if(typeof XMLHttpRequest!=="undefined"){t=$r}else if(typeof process!=="undefined"&&Object.prototype.toString.call(process)==="[object process]"){t=$r}return t}function zr(t,e,n){if(dr.isString(t)){try{(e||JSON.parse)(t);return dr.trim(t)}catch(t){if(t.name!=="SyntaxError"){throw t}}}return(n||JSON.stringify)(t)}var Br={transitional:xr,adapter:Mr(),transformRequest:[function t(e,n){wr(n,"Accept");wr(n,"Content-Type");if(dr.isFormData(e)||dr.isArrayBuffer(e)||dr.isBuffer(e)||dr.isStream(e)||dr.isFile(e)||dr.isBlob(e)){return e}if(dr.isArrayBufferView(e)){return e.buffer}if(dr.isURLSearchParams(e)){Ur(n,"application/x-www-form-urlencoded;charset=utf-8");return e.toString()}var i=dr.isObject(e);var r=n&&n["Content-Type"];var a;if((a=dr.isFileList(e))||i&&r==="multipart/form-data"){var s=this.env&&this.env.FormData;return Er(a?{"files[]":e}:e,s&&new s)}else if(i||r==="application/json"){Ur(n,"application/json");return zr(e)}return e}],transformResponse:[function t(e){var n=this.transitional||Br.transitional;var i=n&&n.silentJSONParsing;var r=n&&n.forcedJSONParsing;var a=!i&&this.responseType==="json";if(a||r&&dr.isString(e)&&e.length){try{return JSON.parse(e)}catch(t){if(a){if(t.name==="SyntaxError"){throw _r.from(t,_r.ERR_BAD_RESPONSE,this,null,this.response)}throw t}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Nr},validateStatus:function t(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};dr.forEach(["delete","get","head"],(function t(e){Br.headers[e]={}}));dr.forEach(["post","put","patch"],(function t(e){Br.headers[e]=dr.merge(qr)}));var Jr=Br;var Gr=function t(e,n,i){var r=this||Jr;dr.forEach(i,(function t(i){e=i.call(r,e,n)}));return e};var Hr=function t(e){return!!(e&&e.__CANCEL__)};function Vr(t){if(t.cancelToken){t.cancelToken.throwIfRequested()}if(t.signal&&t.signal.aborted){throw new Dr}}var Qr=function t(e){Vr(e);e.headers=e.headers||{};e.data=Gr.call(e,e.data,e.headers,e.transformRequest);e.headers=dr.merge(e.headers.common||{},e.headers[e.method]||{},e.headers);dr.forEach(["delete","get","head","post","put","patch","common"],(function t(n){delete e.headers[n]}));var n=e.adapter||Jr.adapter;return n(e).then((function t(n){Vr(e);n.data=Gr.call(e,n.data,n.headers,e.transformResponse);return n}),(function t(n){if(!Hr(n)){Vr(e);if(n&&n.response){n.response.data=Gr.call(e,n.response.data,n.response.headers,e.transformResponse)}}return Promise.reject(n)}))};var Wr=function t(e,n){n=n||{};var i={};function r(t,e){if(dr.isPlainObject(t)&&dr.isPlainObject(e)){return dr.merge(t,e)}else if(dr.isPlainObject(e)){return dr.merge({},e)}else if(dr.isArray(e)){return e.slice()}return e}function a(t){if(!dr.isUndefined(n[t])){return r(e[t],n[t])}else if(!dr.isUndefined(e[t])){return r(undefined,e[t])}}function s(t){if(!dr.isUndefined(n[t])){return r(undefined,n[t])}}function o(t){if(!dr.isUndefined(n[t])){return r(undefined,n[t])}else if(!dr.isUndefined(e[t])){return r(undefined,e[t])}}function l(t){if(t in n){return r(e[t],n[t])}else if(t in e){return r(undefined,e[t])}}var u={url:s,method:s,data:s,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:l};dr.forEach(Object.keys(e).concat(Object.keys(n)),(function t(e){var n=u[e]||a;var r=n(e);dr.isUndefined(r)&&n!==l||(i[e]=r)}));return i};var Xr={version:"0.27.2"};var Zr=Xr.version;var Kr={};["object","boolean","number","function","string","symbol"].forEach((function(t,e){Kr[t]=function n(i){return typeof i===t||"a"+(e<1?"n ":" ")+t}}));var Yr={};Kr.transitional=function t(e,n,i){function r(t,e){return"[Axios v"+Zr+"] Transitional option '"+t+"'"+e+(i?". "+i:"")}return function(t,i,a){if(e===false){throw new _r(r(i," has been removed"+(n?" in "+n:"")),_r.ERR_DEPRECATED)}if(n&&!Yr[i]){Yr[i]=true;console.warn(r(i," has been deprecated since v"+n+" and will be removed in the near future"))}return e?e(t,i,a):true}};function ta(t,e,n){if(typeof t!=="object"){throw new _r("options must be an object",_r.ERR_BAD_OPTION_VALUE)}var i=Object.keys(t);var r=i.length;while(r-- >0){var a=i[r];var s=e[a];if(s){var o=t[a];var l=o===undefined||s(o,a,t);if(l!==true){throw new _r("option "+a+" must be "+l,_r.ERR_BAD_OPTION_VALUE)}continue}if(n!==true){throw new _r("Unknown option "+a,_r.ERR_BAD_OPTION)}}}var ea={assertOptions:ta,validators:Kr};var na=ea.validators;function ia(t){this.defaults=t;this.interceptors={request:new mr,response:new mr}}ia.prototype.request=function t(e,n){if(typeof e==="string"){n=n||{};n.url=e}else{n=e||{}}n=Wr(this.defaults,n);if(n.method){n.method=n.method.toLowerCase()}else if(this.defaults.method){n.method=this.defaults.method.toLowerCase()}else{n.method="get"}var i=n.transitional;if(i!==undefined){ea.assertOptions(i,{silentJSONParsing:na.transitional(na.boolean),forcedJSONParsing:na.transitional(na.boolean),clarifyTimeoutError:na.transitional(na.boolean)},false)}var r=[];var a=true;this.interceptors.request.forEach((function t(e){if(typeof e.runWhen==="function"&&e.runWhen(n)===false){return}a=a&&e.synchronous;r.unshift(e.fulfilled,e.rejected)}));var s=[];this.interceptors.response.forEach((function t(e){s.push(e.fulfilled,e.rejected)}));var o;if(!a){var l=[Qr,undefined];Array.prototype.unshift.apply(l,r);l=l.concat(s);o=Promise.resolve(n);while(l.length){o=o.then(l.shift(),l.shift())}return o}var u=n;while(r.length){var c=r.shift();var f=r.shift();try{u=c(u)}catch(t){f(t);break}}try{o=Qr(u)}catch(t){return Promise.reject(t)}while(s.length){o=o.then(s.shift(),s.shift())}return o};ia.prototype.getUri=function t(e){e=Wr(this.defaults,e);var n=Ir(e.baseURL,e.url);return vr(n,e.params,e.paramsSerializer)};dr.forEach(["delete","get","head","options"],(function t(e){ia.prototype[e]=function(t,n){return this.request(Wr(n||{},{method:e,url:t,data:(n||{}).data}))}}));dr.forEach(["post","put","patch"],(function t(e){function n(t){return function n(i,r,a){return this.request(Wr(a||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:i,data:r}))}}ia.prototype[e]=n();ia.prototype[e+"Form"]=n(true)}));var ra=ia;function aa(t){if(typeof t!=="function"){throw new TypeError("executor must be a function.")}var e;this.promise=new Promise((function t(n){e=n}));var n=this;this.promise.then((function(t){if(!n._listeners)return;var e;var i=n._listeners.length;for(e=0;e<i;e++){n._listeners[e](t)}n._listeners=null}));this.promise.then=function(t){var e;var i=new Promise((function(t){n.subscribe(t);e=t})).then(t);i.cancel=function t(){n.unsubscribe(e)};return i};t((function t(i){if(n.reason){return}n.reason=new Dr(i);e(n.reason)}))}aa.prototype.throwIfRequested=function t(){if(this.reason){throw this.reason}};aa.prototype.subscribe=function t(e){if(this.reason){e(this.reason);return}if(this._listeners){this._listeners.push(e)}else{this._listeners=[e]}};aa.prototype.unsubscribe=function t(e){if(!this._listeners){return}var n=this._listeners.indexOf(e);if(n!==-1){this._listeners.splice(n,1)}};aa.source=function t(){var e;var n=new aa((function t(n){e=n}));return{token:n,cancel:e}};var sa=aa;var oa=function t(e){return function t(n){return e.apply(null,n)}};var la=function t(e){return dr.isObject(e)&&e.isAxiosError===true};function ua(t){var e=new ra(t);var n=Di(ra.prototype.request,e);dr.extend(n,ra.prototype,e);dr.extend(n,e);n.create=function e(n){return ua(Wr(t,n))};return n}var ca=ua(Jr);ca.Axios=ra;ca.CanceledError=Dr;ca.CancelToken=sa;ca.isCancel=Hr;ca.VERSION=Xr.version;ca.toFormData=Er;ca.AxiosError=_r;ca.Cancel=ca.CanceledError;ca.all=function t(e){return Promise.all(e)};ca.spread=oa;ca.isAxiosError=la;var fa=ca;var ha=ca;fa.default=ha;var da=fa;function pa(t){this.message=t}pa.prototype=new Error,pa.prototype.name="InvalidCharacterError";var va="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new pa("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,r=0,a=0,s="";i=e.charAt(a++);~i&&(n=r%4?64*n+i:i,r++%4)?s+=String.fromCharCode(255&n>>(-2*r&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return s};function ga(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(va(t).replace(/(.)/g,(function(t,e){var n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return va(e)}}function ma(t){this.message=t}function wa(t,e){if("string"!=typeof t)throw new ma("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(ga(t.split(".")[n]))}catch(t){throw new ma("Invalid token specified: "+t.message)}}ma.prototype=new Error,ma.prototype.name="InvalidTokenError";let ya=function(t,e,n){return alert(t)},ba=function(t,e){return ya(t,Sa.error,e)},Sa={error:"error",success:"success",info:"info"};var _a={fire:function(t,e,n){return ya(t,e,n)},setNotifier:function(t){ya=t,salla.event.emit("twilight::notifier.changed")},error:ba,success:function(t,e){return ya(t,Sa.success,e)},info:function(t,e){return ya(t,Sa.info,e)},sallaInitiated:function(){let t=window.location.href.match(/([\?\&]danger=)[^&]+/g);t&&(window.history.replaceState(null,document.title,window.location.pathname),salla.event.once("twilight::notifier.changed",(()=>{t.forEach((t=>{t=decodeURI(t.replace("?danger=","").replace("&danger=",""));let e=document.createElement("div");e.innerText=t,ba(e.innerHTML)}))})))},types:Sa};class xa{constructor(t,e){return this.api=t,this.event=e,new Proxy(this,{get:function(n,i){return"event"===i?e:"api"===i?t:t&&t[i]||n[i]}})}}Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(t){for(var e=this;e;){if(e.matches(t))return e;e=e.parentElement}}),Element.prototype.getElementSallaData=function(t,...e){if(!this.getAttribute)return;if(this.hasAttribute("data-json"))try{return JSON.parse(this.getAttribute("data-json"))}catch(t){}let n=this.getAttribute("data-function");if(n&&window[n])return"function"==typeof window[n]?this.getFilteredData(window[n].call(this,...e)):this.getFilteredData(window[n]);let i=this.hasAttribute("data-form-selector")?document.querySelector(this.dataset.formSelector):void 0;if(i="FORM"===this.tagName?this:i||this.closest("form")||this.closest("[salla-form-data]")||this,i&&"FORM"===i.tagName)return this.getFilteredData(new FormData(i),null,i);let r=i.querySelectorAll("[name]");if(!r.length)return this.getFilteredData();let a=Object.assign({},this.dataset);return r.forEach((t=>{if(!["checkbox","radio"].includes(t.type)||t.checked)try{let e=Salla.helpers.inputData(t.name,t.value,a);a[e.name]=e.value}catch(e){Salla.log(t.name+" can't be send")}})),this.getFilteredData(a)},Element.prototype.canEventFireHook=function(t){return!!this.hasAttribute&&this.hasAttribute(Salla.api.hooksPrefix+t.type)},Element.prototype.hasAttributeStartsWith=function(t,e){t=t.toLowerCase();for(var n=0;n<this.attributes.length;n++){let i=this.attributes[n].name.toLowerCase();if(0===i.indexOf(t))return!e||i}return!1},HTMLFormElement.prototype.getAjaxFormData=function(t){var e=this.querySelectorAll('input[type="file"]');e.forEach((t=>{t.files.length||t.setAttribute("disabled","")}));var n=new FormData(this);return e.forEach((t=>{t.files.length||t.removeAttribute("disabled")})),{formData:this.getFilteredData(n,t),url:this.getAttribute("action"),method:this.getAttribute("method")||"post",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}},Element.prototype.getFilteredData=function(t=null,e=null,n=null){return t=t||n?.dataset||this.dataset,n&&this.name&&void 0!==this.value&&(t=function(t,e,n){t instanceof FormData?t.append(e,n):t[e]=n;return t}(t,this.name,this.value)),["filterBeforeSubmit","filterBeforeSend"].forEach((i=>{let r=n?.dataset[i]||this.dataset[i];if(r){var a=window[r];if("function"==typeof a){if(!a(t,n||this,e)&&t)throw`Data failed to be pass verify function window.${r}(formData, element, event)!`;return a(t,n||this,e)}Salla.log("window."+r+"() not found!")}})),t},HTMLAnchorElement.prototype.getAjaxFormData=function(t){return{formData:this.getFilteredData(null,t),url:this.getAttribute("href"),method:this.dataset.type||"get",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}};class ja{constructor(){this.events={},this.namespace="";let t=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(t&&t.length>1?t[1]:"").toLowerCase()}after_init(){this.createDynamicFunctions()}createDynamicFunctions(){Object.keys(this.events).forEach((t=>{this.createDynamicEventFuns(t),this.createDynamicListenerFuns(t)}))}createDynamicEventFuns(t){if(this[t])return;let e=this;this[t]=function(...n){return e.dispatch(t,...n)}}createDynamicListenerFuns(t){let e="on"+t.charAt(0).toUpperCase()+t.slice(1);if(this[e])return;let n=this;this[e]=function(e){return n.on(t,(async(...t)=>e(...t)))}}getEventName(t){return t=this.events[t]||t,!this.namespace||t.includes("::")?t:this.namespace+Salla.event.delimiter+t}dispatch(t,...e){return Salla.event.emitAsync(this.getEventName(t),...e)}on(t,e,n={}){return Salla.event.addListener(this.getEventName(t),e,n)}once(t,e){return Salla.event.once(this.getEventName(t),e)}}function Ea(t){t&&t.sallaInitiated&&!t.initiated&&(t.sallaInitiated(),t.initiated=!0)}Salla.event.auth=new class extends ja{constructor(){super(),this.namespace="auth",this.events={login:"login",logout:"logout",codeSent:"code.sent",codeNotSent:"code.not-sent",verified:"verified",verificationFailed:"verification.failed",loggedIn:"logged.in",registered:"registered",registrationFailed:"registration.failed",loggedOut:"logged.out",failedLogout:"failed.logout",refreshFailed:"refresh.failed",tokenFetched:"token.fetched",tokenInvalid:"token.invalid"},this.after_init()}login(t){return t?(t.type&&this.setTypeActionOnVerified(t.type),this.next_event=t.next_event||null,this.dispatch("login",...arguments)):(this.next_event=null,this.dispatch("login",...arguments))}loggedIn(t){return Salla.profile.info().finally((()=>this.dispatch("loggedIn",t)))}setTypeActionOnVerified(t){this.type_action_on_verified=t}getTypeActionOnVerified(){return this.type_action_on_verified||"redirect"}},Salla.event.cart=new class extends ja{constructor(){super(),this.namespace="cart",this.events={latestFetched:"latest.fetched",latestFailed:"latest.failed",updated:"updated",itemUpdated:"item.updated",itemUpdatedFailed:"item.updated.failed",itemAdded:"item.added",itemAddedFailed:"item.added.failed",itemDeleted:"item.deleted",itemDeletedFailed:"item.deleted.failed",submitted:"submitted",submitFailed:"submit.failed",imageDeleted:"image.deleted",imageNotDeleted:"image.not.deleted",detailsFetched:"details.fetched",detailsNotFetched:"details.not.fetched",successReset:"success.reset",priceQuoteSucceeded:"price-quote.succeeded",priceQuoteFailed:"price-quote.failed",couponAdded:"coupon.added",couponDeleted:"coupon.deleted",couponAdditionFailed:"coupon.addition.failed",couponDeletionFailed:"coupon.deletion.failed",quickOrderSettingFetched:"quick-order.fetched",quickOrderSettingFailed:"quick-order.failed",quickOrderSucceeded:"quick-order.succeeded",quickOrderFailed:"quick-order.failed"},this.after_init()}updated(t){return Salla.cookie.set("fresh_summary",1),t&&"object"==typeof t?(t.offer&&salla.product.event.offerExisted(t.offer),t.redirect&&(salla.log("The current cart is purchased!"),salla.cart.api.reset()),t.cart?(salla.storage.set("cart.summary",{total:t.cart.total,sub_total:t.cart.sub_total,discount:t.cart.discount,real_shipping_cost:t.cart.real_shipping_cost,count:t.cart.count,shipping_cost:t.cart.free_shipping_bar?.has_free_shipping?0:t.cart.real_shipping_cost}),this.dispatch("updated",t.cart)):void salla.log("Failed to get the cart summary!")):(Salla.logger.info("Cart summary not an object!",t),this.dispatch("updated"))}latestFetched(t){return this.updated(t.data),this.dispatch("latestFetched",t)}itemAdded(t,e){return this.updated(t.data),this.dispatch("itemAdded",t,e)}itemDeleted(t,e){return this.updated(t.data),this.dispatch("itemDeleted",t,e)}itemUpdated(t,e){return this.updated(t.data),this.dispatch("itemUpdated",t,e)}couponAdded(t,e){return this.updated(t.data),this.dispatch("couponAdded",t,e)}couponDeleted(t,e){return this.updated(t.data),this.dispatch("couponDeleted",t,e)}},Salla.event.order=new class extends ja{constructor(){super(),this.namespace="order",this.events={canceled:"canceled",notCanceled:"not.canceled",orderCreated:"order.created",orderCreationFailed:"order.creation.failed",invoiceSent:"invoice.sent",invoiceNotSent:"invoice.not.sent",ordersFetched:"order.fetched",ordersNotFetched:"order.not.fetched"},this.after_init()}},Salla.event.scope=new class extends ja{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 ja{constructor(){super(),this.namespace="rating",this.events={orderNotFetched:"order.not.fetched",orderFetched:"order.fetched",storeRated:"store.rated",storeFailed:"store.failed",productsRated:"products.rated",productsFailed:"products.failed",shippingRated:"shipping.rated",shippingFailed:"shipping.failed"},this.after_init()}},Salla.event.booking=new class extends ja{constructor(){super(),this.namespace="booking",this.events={added:"added",additionFailed:"addition.failed"},this.after_init()}},Salla.event.comment=new class extends ja{constructor(){super(),this.namespace="comment",this.events={added:"added",additionFailed:"addition.failed",fetched:"fetched",fetchFailed:"fetch.failed"},this.after_init()}},Salla.event.landing=new class extends ja{constructor(){super(),this.namespace="landing",this.events={detailsFetched:"order.fetched",getDetailsFailed:"get.details.failed",orderCreated:"order.created",orderCreationFailed:"order.creation.failed",breadcrumbFetched:"breadcrumb.fetched",breadcrumbFetchFailed:"breadcrumb.fetch.failed"},this.after_init()}},Salla.event.loyalty=new class extends ja{constructor(){super(),this.namespace="loyalty",this.events={exchangeSucceeded:"exchange.succeeded",exchangeFailed:"exchange.failed",programFetched:"program.fetched",programNotFetched:"program.not.fetched",resetSucceeded:"exchange-reset.succeeded",resetFailed:"exchange-reset.failed"},this.after_init()}exchangeSucceeded(t,e){return salla.cart.event.updated(t.data),this.dispatch("exchangeSucceeded",t,e)}resetSucceeded(t){return salla.cart.event.updated(t.data),this.dispatch("resetSucceeded",t)}},Salla.event.product=new class extends ja{constructor(){super(),this.namespace="product",this.events={priceUpdated:"price.updated",priceUpdateFailed:"price.updated.failed",availabilitySubscribed:"availability.subscribed",availabilitySubscribeFailed:"availability.subscribe.failed",categoriesFetched:"categories.fetched",categoriesFailed:"categories.failed",searchFailed:"search.failed",searchResults:"search.results",offerExisted:"offer.existed",fetchOffersFailed:"fetch.offers.failed",offersFetched:"offers.fetched",sizeGuideFetched:"size-guide.fetched",sizeGuideFetchFailed:"size-guide.failed",giftFetched:"gift.fetched",giftFetchFailed:"gift.failed",detailFetched:"detail.fetched",detailFetchFailed:"detail.failed",addGiftToCartSucceeded:"gift.add-to-cart.succeeded",addGiftToCartFailed:"gift.add-to-cart.failed",giftImageUploadSucceeded:"gift.image-upload.succeeded",giftImageUploadFailed:"gift.image-upload.failed",productListFetchSucceeded:"fetch.succeeded",productListFetchFailed:"fetch.failed"},this.after_init()}},Salla.event.profile=new class extends ja{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 ja{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 ja{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(t,e){this.fireCallableFuns("click",t,e)}onChange(t,e){this.fireCallableFuns("change",t,e)}onSubmit(t,e){this.fireCallableFuns("submit",t,e)}onKeyup(t,e){this.fireCallableFuns("keyup",t,e)}fireCallableFuns(t,e,n){this.on(t,(t=>{"function"!=typeof e?"function"==typeof n&&t.target.matches(e)&&n(t):e(t)}))}fireEvent(t,e,...n){return this.fireEventForElements(t,e,!1,...n)}fireEventForAll(t,e,...n){return this.fireEventForElements(t,e,!0,...n)}fireEventForElements(t,e,n,...i){if("string"==typeof t){if(n)return document.querySelectorAll(t).forEach((t=>this.fireEventForElements(t,e,!1,...i)));t=document.querySelector(t)}if(!t)return void salla.log("Failed To get element to fire event: "+e);const r=new CustomEvent(e,...i);return t.dispatchEvent(r)}},Salla.event.wishlist=new class extends ja{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 ja{constructor(){super(),this.namespace="infiniteScroll",this.events={scrollThreshold:"scroll.threshold",request:"request",load:"load",append:"append",error:"error",last:"last",history:"history"},this.after_init()}},Salla.event.notifications=new class extends ja{constructor(){super(),this.namespace="notifications",this.events={fetched:"fetched",fetchFailed:"fetch.failed"},this.after_init()}},Salla.event.component=new class extends ja{constructor(){super(),this.namespace="component",this.events={menuFetched:"menus.fetched",menuFetchFailed:"menus.fetch.failed",reviewsFetched:"reviews.fetched",reviewsFetchFailed:"reviews.fetch.failed"},this.after_init()}},Salla.event.advertisement=new class extends ja{constructor(){super(),this.namespace="advertisement",this.events={fetched:"advertisement.fetched",fetchFailed:"advertisement.not.fetched"},this.after_init()}},Salla.event.navigation=new class extends ja{constructor(){super(),this.namespace="navigation",this.events={breadcrumbFetched:"breadcrumb.fetched",breadcrumbFetchFailed:"breadcrumb.fetch.failed"},this.after_init()}},Salla.event.on("twilight::initiated",(()=>{Object.keys(Salla).forEach((t=>{"object"==typeof(t=Salla[t])&&(Ea(t),Object.keys(t).forEach((e=>{Ea(t[e])})))}))})),Salla.config.default_properties={debug:"undefined"!=typeof process&&"development"==="production",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 t=!0,e=[];return(await salla.document.api.request("languages",null,"get"))?.data?.map((n=>{t&&(e=[],t=!1),n.code=n.code||n.iso_code,n.url=salla.url.get(n.code),n.is_rtl=n.is_rtl||n.rtl,e.push(n)})),Salla.config.set("languages",e),e},Salla.config.currencies=async()=>{if(Salla.config.triedToGetCurrencies_)return Salla.config.get("currencies");Salla.config.triedToGetCurrencies_=!0;let t=!0,e={};return(await salla.currency.api.list())?.data?.map((n=>{t&&(e={},t=!1),n.country_code=n.code.substr(0,2).toLowerCase(),e[n.code]=n})),Salla.config.set("currencies",e),e};class Oa{constructor(){this.endpoints={},this.webEndpoints=[],this.namespace="BaseApi",this.endpointsMethods={},this.endpointsHeaders={};let t=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(t&&t.length>1?t[1]:"").toLowerCase(),this.debounce={request:void 0,time:300,enabled:!0,exclude:[]}}after_init(){}normalRequest(t,e=void 0,n=null){let i=Array.isArray(t),r=i?this.getUrl(...t):this.getUrl(t);t=i?t[0]:t,n=n||this.endpointsMethods[t]||"post";let a=this.endpointsHeaders[t];if("get"===n&&e instanceof FormData){let t={};Array.from(e.entries()).forEach((function(e){t[e[0]]=e[1]})),e={params:t}}return a&&"get"===n&&(e=e?Object.assign(e,a):a),this.webEndpoints.includes(t)?r=salla.url.get(r):"http"!==r.substring(0,4)&&(r=salla.url.api(r)),Salla.api.request(r,e,n,{headers:a})}request(t,e=void 0,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(t,e,n)):this.normalRequest(t,e,n)}getUrl(t){let e=this.endpoints[t]||t;const n=/{[^{}]+}/i;for(let t=1;t<arguments.length;t++)e=e.replace(n,arguments[t]);return e}event(){return salla.event[this.className]}}class Fa extends Oa{constructor(){super(),this.addToCartTries=0,this.namespace="cart",this.endpoints={latest:"cart/latest",details:"cart/{cart}",quickAdd:"cart/{cart}/item/{product}/quick-add",addItem:"cart/{cart}/item/{product}/add",deleteItem:"cart/{cart}/item/{item}",updateItem:"cart/{cart}/item/{item}",deleteImage:"cart/{cart}/image/{image}",uploadImage:"cart/{cart}/image",status:"cart/{cart}/status",addCoupon:"cart/{id}/coupon",deleteCoupon:"cart/{id}/coupon",getQuickOrderSettings:"checkout/quick-order",createQuickOrder:"checkout/quick-order",priceQuote:"cart/{cartId}/price-quote"},this.endpointsMethods={latest:"get",details:"get",status:"get",updateItem:"post",deleteItem:"delete",deleteImage:"delete",deleteCoupon:"put",getQuickOrderSettings:"get"},this.webEndpoints=["latest"],this.latestCart=null,this.after_init(),salla.event.on("api::initiated",this.getCurrentCartId),salla.event.on("auth::token.fetched",this._checkCurrentCart),salla.event.on("auth::token.invalid",this._checkCurrentCart),salla.event.on("auth::verified",(()=>this.getCurrentCartId(!0)),{async:!0}),salla.event.on("profile::info.fetched",this._checkCurrentCart)}_checkCurrentCart(){let t=salla.storage.get("cart"),e=salla.config.get("user")?.id,n=salla.config.get("store")?.id;t&&t.id&&(t.user_id!==e||t.store_id!==n)&&(salla.log("cart",{user_id:t.user_id,store_id:t.store_id}),salla.log("current",{user_id:e,store_id:n}),salla.log("Api:: case2 => The cart is not belong to current "+(t.user_id!==e?"user":"store")+"!"),salla.cart.api.reset())}async getCurrentCartId(t=!1){if(!t){if(salla.cart.api.latestCart)return salla.cart.api.latestCart.cart.id;let t=salla.storage.get("cart.id");if(t)return t}let e=await salla.cart.api.latest();return salla.cart.api.latestCart=e.data,salla.cart.api.latestCart.cart.id}getUploadImageEndpoint(t){return salla.url.api(this.getUrl("uploadImage",t||salla.storage.get("cart.id")))}latest(){return this.request("latest",{params:{source:""}}).then((t=>(salla.storage.set("cart",t.data.cart),salla.event.cart.latestFetched(t),t))).catch((t=>{throw salla.storage.set("cart",""),salla.event.cart.latestFailed(t),t}))}async details(t,e=[]){return t=t||await this.getCurrentCartId(),this.request(["details",t],{params:{with:e}}).then((function(t){return salla.cart.event.detailsFetched(t),t})).catch((function(t){throw salla.cart.event.detailsNotFetched(t),t}))}async quickAdd(t,e){return this.addItem({id:t,quantity:e,endpoint:"quickAdd"})}async addItem(t){let e=this.getCartPayload(t);if(!e.id){let t='There is no product "id"!';return salla.cart.event.itemAddedFailed(t),salla.api.errorPromise(t)}let n=salla.form.getPossibleValue(e.payload,["endpoint"]);n&&["addItem","quickAdd"].includes(n)||(n=salla.form.getPossibleValue(e.payload,["quantity","donating_amount"])?"addItem":"quickAdd");let i=await this.getCurrentCartId();return this.request([n,i,e.id],e.payload).then((function(t){return salla.cart.api.addToCartTries=0,salla.cart.event.itemAdded(t,e.id),t})).catch((function(n){if(!salla.cart.api.addToCartTries)return salla.cart.api.addToCartTries++,salla.cart.reset(),salla.cart.api.addItem(t);throw salla.cart.event.itemAddedFailed(n,e.id),n}))}async deleteItem(t){let e=this.getCartPayload(t);if(!e.id){let t='There is no "id"!';return salla.cart.event.itemDeletedFailed(t),salla.api.errorPromise(t)}let n=await this.getCurrentCartId();return this.request(["deleteItem",n,e.id]).then((function(t){return salla.cart.event.itemDeleted(t,e.id),t})).catch((function(t){throw salla.cart.event.itemDeletedFailed(t,e.id),t}))}async updateItem(t){let e=this.getCartPayload(t);if(!e.id){let t='There is no "id"!';return salla.cart.event.itemUpdatedFailed(t),salla.api.errorPromise(t)}let n=await this.getCurrentCartId();return"Object"===e.payload.constructor?.name?e.payload._method="PUT":e.payload.append("_method","PUT"),this.request(["updateItem",n,e.id],e.payload).then((function(t){return salla.cart.event.itemUpdated(t,e.id),t})).catch((function(t){throw salla.cart.event.itemUpdatedFailed(t,e.id),t}))}async deleteImage(t){if(!(t=salla.form.getPossibleValue(t,["id","image_id","photo_id"]))){let t='There is no "id"!';return salla.cart.event.imageNotDeleted(t),salla.api.errorPromise(t)}let e=await this.getCurrentCartId();return this.request(["deleteImage",e,t]).then((function(e){return salla.cart.event.imageDeleted(e,t),e})).catch((function(e){throw salla.cart.event.imageNotDeleted(e,t),e}))}async status(t){const e=(new Date).getTime(),n=Math.random().toString(36).substring(2,15);return this.request(["status",t||await this.getCurrentCartId()],{params:{has_apple_pay:salla.helpers.hasApplePay(),"s-hash":`${n}_${e}`}})}async submit(){if(salla.config.isGuest())return salla.log("it looks that the current user is not logged-in, lets login then submit"),salla.cart.loginOnCartPage();this.status(await this.getCurrentCartId()).then((t=>{let e=t.data.next_step?.to;if(e||(window.history.pushState({},"",salla.url.addParamToUrl("reload","empty_next_step")),window.history.pushState({},"",salla.url.addParamToUrl("acitve",!1===t.data.active?"false":"true_or_undfined")),salla.cart.reset(),window.location.reload()),!["checkout","refresh","login"].includes(e)){let t="Can't find next_step );";throw salla.cart.reset(),salla.cart.event.submitFailed(t),t}return salla.cart.event.submitted(t),"login"===e?salla.cart.loginOnCartPage():"checkout"===e?window.location.href=t.data.next_step.url+(salla.helpers.hasApplePay()?"?has_apple_pay=true":""):(window.history.pushState({},"",salla.url.addParamToUrl("reload","refresh")),void window.location.reload())})).catch((function(t){salla.cart.api.tries=salla.cart.api.tries||0,salla.cart.reset();let e=404===t?.response?.data?.status;if(e&&0===salla.cart.api.tries)return salla.cart.api.tries++,salla.log("we recived that the current cart is not found, we will try to re-submit one more time"),salla.cart.submit();throw e&&salla.error(salla.lang.get("pages.checkout.try_again")),salla.cart.event.submitFailed(t),t}))}getCartPayload(t){let e=t?.data||("object"==typeof t?t:void 0);return t=e?salla.form.getPossibleValue(e,["prod_id","product_id","item_id","id"]):t,e="object"==typeof e?e:void 0,{id:t,payload:e}}normalRequest(t,e=void 0,n=null){return super.normalRequest(t,e,n).catch((async t=>{throw 403===t?.response?.status&&(this.reset(),salla.error(salla.lang.get("pages.checkout.try_again"))),t}))}reset(){salla.api.cart.latestCart=null,salla.storage.remove("cart"),salla.cart.event.successReset()}async addCoupon(t){if(t=t.data||t,!(t=salla.form.getPossibleValue(t,["coupon"]))){let t=new Error('There is no "Coupon Code"!');return t.name="EmptyCoupon",salla.event.cart.couponAdditionFailed(t),salla.api.errorPromise(t)}let e=await salla.cart.api.getCurrentCartId();return this.request(["addCoupon",e],{coupon:t}).then((function(t){return salla.event.cart.couponAdded(t,e),t})).catch((function(t){throw salla.event.cart.couponAdditionFailed(t,e),t}))}async deleteCoupon(){let t=await salla.cart.api.getCurrentCartId();return this.request(["deleteCoupon",t],{}).then((function(e){return salla.event.cart.couponDeleted(e,t),e})).catch((function(e){throw salla.event.cart.couponDeletionFailed(e,t),e}))}getQuickOrderSettings(){return this.request("getQuickOrderSettings").then((t=>(salla.event.cart.quickOrderSettingFetched(t),t))).catch((t=>{throw salla.event.cart.quickOrderSettingFailed(t),t}))}createQuickOrder(t){return this.request("createQuickOrder",t).then((t=>(salla.event.cart.quickOrderSucceeded(t),t))).catch((t=>{throw salla.event.cart.quickOrderFailed(t),t}))}async priceQuote(t){return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("cart::priceQuote",t),void salla.event.dispatch("login::open")):this.request(["priceQuote",t||await this.getCurrentCartId()]).then((t=>(salla.cart.api.reset(),salla.event.cart.priceQuoteSucceeded(t).then((()=>(setTimeout((()=>window.location.href=salla.url.get("/")),1e3),t)))))).catch((t=>salla.event.cart.priceQuoteFailed(t).then((()=>{throw 404===t.error?.code&&window.location.reload(),t}))))}loginOnCartPage(){salla.auth.setCanRedirect(!1),salla.event.dispatch("login::open"),salla.auth.event.onLoggedIn((t=>{salla.event.dispatch("login::close"),salla.cart.submit()}))}}class ka extends Oa{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((t=>(salla.loyalty.event.programFetched(t),t))).catch((t=>{throw salla.loyalty.event.programNotFetched(t),t}))}async exchange(t,e=null){if(!(t=salla.form.getPossibleValue(t,["id","loyalty_prize_id","prize_id"]))){let t="Unable to find cart id. Please provide one.";return salla.loyalty.event.exchangeFailed(t),salla.api.errorPromise(t)}if(!(e=e||await salla.cart.getCurrentCartId())){let t="Unable to find cart id. Please provide one.";return salla.loyalty.event.exchangeFailed(t),salla.api.errorPromise(t)}return this.request("exchange",{loyalty_prize_id:t,cart_id:e}).then((function(e){return salla.loyalty.event.exchangeSucceeded(e,t),e})).catch((function(e){throw salla.loyalty.event.exchangeFailed(e,t),e}))}async reset(t=null){if(!(t=t||await salla.cart.getCurrentCartId())){let t="Unable to find cart id. Please provide one.";return salla.loyalty.event.resetFailed(t),salla.api.errorPromise(t)}return this.request("reset",{cart_id:t}).then((t=>(salla.loyalty.event.resetSucceeded(t),t))).catch((t=>{throw salla.loyalty.event.resetFailed(t),t}))}}class Aa extends Oa{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(t,e){salla.api.auth.afterLoginEvent={event:t,payload:e}}setCanRedirect(t){salla.api.auth.canRedirect_=t}canRedirect(){return salla.api.auth.canRedirect_&&!salla.api.auth.afterLoginEvent.event}login(t){t?.data&&(t=t.data);let e=salla.form.getPossibleValue(t,["type"]);if(!["email","mobile"].includes(e)){let t="Login type should be in: [email, mobile]";return salla.auth.event.codeNotSent(t),salla.api.errorPromise(t)}return this.request(["login",e],t).then((function(t){return salla.auth.event.codeSent(t,e),t})).catch((function(t){throw salla.auth.event.codeNotSent(t,e),t}))}async verify(t,e=!0){let n=salla.form.getPossibleValue(t,["type"]);if(!n){let t="Failed to know what's login type!";return salla.auth.event.verificationFailed(t),salla.api.errorPromise(t)}e=!1!==salla.form.getPossibleValue(t,["supportWebAuth"])&&e,salla.auth.event.next_event&&(t.next_event=salla.auth.event.next_event);let i=await salla.auth.api.request(["verify",n],t);return 200!==i?.status?(salla.auth.event.verificationFailed(i,n),salla.api.errorPromise(i)):salla.auth.api.handlAfterAuthenticatedResponse("authenticated"===i.data?.case,e)}async handlAfterAuthenticatedResponse(t,e){return t&&salla.auth.event.tokenFetched(response.data.token),e&&await salla.auth.api.request("auth/jwt"),t&&salla.auth.event.loggedIn(response).then((()=>salla.auth.api.afterUserLogin())),await salla.auth.event.verified(response,type),salla.api.successPromise(response)}resend(t){let e;return(t=t.data||t).type=t.type||"mobile","mobile"!==t.type||t.phone&&t.country_code?"email"!==t.type||t.email?this.request("resend",t).then((function(e){return salla.auth.event.codeSent(e,t),e})).catch((function(e){throw salla.auth.event.codeNotSent(e,t),e})):(salla.auth.event.codeNotSent(e="There is no email!",t),salla.api.errorPromise(e)):(salla.auth.event.codeNotSent(e="There is no phone or country_code!",t),salla.api.errorPromise(e))}register(t){let e;return t.data&&(e=t.element,t=t.data),salla.auth.event.next_event&&(t.next_event=salla.auth.event.next_event),this.request("register",t).then((async function(t){return salla.auth.event.registered.call(e,t),"authenticated"===t.data?.case&&(salla.auth.event.tokenFetched(t.data.token),await salla.auth.request("auth/jwt"),salla.auth.event.loggedIn(t),salla.auth.api.afterUserLogin()),t})).catch((function(t){throw salla.auth.event.registrationFailed.call(e,t),t}))}logout(t="twilight"){return salla.storage.clearAll(),salla.cookie.clearAll(),t=encodeURI(t),salla.auth.event.loggedOut().then((()=>{let e=salla.url.get(`logout?from=${t}`);console.log(`Going to ${e}, to do any thing before this action use: salla.auth.even.onLoggedOut(()=>{...})`);try{location.href=e}catch(t){salla.log(t)}}))}refresh(){return this.request("refresh").then((function(t){return salla.auth.event.tokenFetched(t.data.token),t})).catch((function(t){throw salla.auth.event.refreshFailed(t),t}))}afterUserLogin(){this.afterLoginEvent.event&&salla.event.emit(this.afterLoginEvent.event,this.afterLoginEvent.payload)}}class Ia extends Oa{constructor(){super(),this.namespace="order",this.endpoints={cancel:"orders/cancel/{id}",createCartFromOrder:"reorder/{id}",sendInvoice:"orders/send/{id}",fetch:"orders"},this.endpointsMethods={createCartFromOrder:"get",fetch:"get"},this.after_init()}show(t){let e=salla.form.getPossibleValue(t?.data||t,["id","order_id"]);salla.event.dispatch("mobile::order.placed",{order_id:e}),location.href=salla.form.getPossibleValue(t?.data||t,["url"])}cancel(t){return t=t||Salla.config.get("page.id"),this.request(["cancel",t],{params:{has_apple_pay:salla.helpers.hasApplePay()}}).then((function(e){return salla.event.order.canceled(e,t),e})).catch((function(e){throw salla.event.order.notCanceled(e,t),e}))}createCartFromOrder(t){return t=t||salla.config.get("page.id"),this.request(["createCartFromOrder",t]).then((function(e){return salla.cart.reset(),salla.event.order.orderCreated(e,t),window.location.href=e.data.url,e})).catch((function(e){throw salla.event.order.orderCreationFailed(e,t),e}))}sendInvoice(t){let e=salla.form.getPossibleValue(t,["id"])||salla.config.get("page.id");if(!e||isNaN(e)){let t="There is no id!";return salla.order.event.invoiceNotSent(t),salla.api.errorPromise(t)}return this.request(["sendInvoice",e],t).then((t=>(salla.event.order.invoiceSent(t,e),t))).catch((t=>{throw salla.event.order.invoiceNotSent(t,e),t}))}fetch(t){return this.request(["fetch"],{params:t}).then((function(t){return salla.event.order.ordersFetched(t),t})).catch((function(t){throw salla.event.order.ordersNotFetched(t),t}))}}class Ta extends Oa{constructor(){super(),this.namespace="product",this.previousQuery="",this.endpoints={getPrice:"products/{id}/price",availabilitySubscribe:"products/{id}/availability-notify",search:"products/search",details:"products/{product_id}/details",categories:"products/categories/{?id}",offers:"products/{product_id}/specialoffer",getSizeGuides:"products/{prod_id}/size-guides",giftDetail:"products/{product_id}/buy-as-gift",giftToCart:"products/{product_id}/buy-as-gift",giftImage:"products/buy-as-gift/image",buyNow:"products/{product_id}/buy-now",fetch:"products"},this.endpointsMethods={details:"get",giftDetail:"get",fetch:"get",offers:"get"},this.after_init()}getPrice(t){let e=t.data||t,n=salla.form.getPossibleValue(e,["id","prod_id","product_id"]);return this.request(["getPrice",n],"object"==typeof e?e:void 0).then((function(t){return salla.product.event.priceUpdated(t,n),t})).catch((function(t){throw salla.product.event.priceUpdateFailed(t,n),t}))}categories(t){return this.request(["categories",t||""],null,"get").then((function(t){return salla.product.event.categoriesFetched(t),t})).catch((function(t){throw salla.product.event.categoriesFailed(t),t}))}availabilitySubscribe(t){let e=t.data||t;return t=salla.form.getPossibleValue(e,["id","prod_id"]),this.request(["availabilitySubscribe",t],"object"==typeof e?e:void 0).then((function(e){return salla.product.event.availabilitySubscribed(e,t),e})).catch((function(e){throw salla.product.event.availabilitySubscribeFailed(e,t),e}))}search(t){let e=t.data;if(e||(e={params:"string"==typeof t?{query:t}:t}),!(t=e instanceof FormData?e.get("query"):e.query||e.params?.query)){let t='There is no "query"!';return salla.product.event.searchFailed(t),salla.api.errorPromise(t)}if(t===salla.api.product.previousQuery){let t="Query is same as previous one!";return salla.product.event.searchFailed(t),salla.api.product.previousQuery=null,salla.api.errorPromise(t)}return salla.api.product.previousQuery=t,this.request("search",e,"get").then((function(e){return salla.product.event.searchResults(e,t),e})).catch((function(e){throw salla.product.event.searchFailed(e,t),e}))}offers(t){if(!(t=salla.form.getPossibleValue(t?.data|t,["product_id","id"]))){let t='There is no "product_id"!';return salla.product.event.fetchOffersFailed(t),salla.api.errorPromise(t)}return this.request(["offers",t]).then((function(e){return salla.product.event.offersFetched(e,t),e})).catch((function(e){throw salla.product.event.fetchOffersFailed(e,t),e}))}getSizeGuides(t){return this.request(`products/${t}/size-guides`,null,"get").then((e=>(salla.product.event.sizeGuideFetched(e,t),e))).catch((e=>{throw salla.product.event.sizeGuideFetchFailed(e,t),e}))}getGiftDetails(t){return this.request(["giftDetail",t]).then((e=>(salla.product.event.giftFetched(e,t),e))).catch((e=>{throw salla.product.event.giftFetchFailed(e,t),e}))}getDetails(t,e=[]){if(!Array.isArray(e)){let t="withItems should be array.";return salla.product.event.detailFetchFailed(t),salla.api.errorPromise(t)}if(!t){let t="productId is not passed.";return salla.product.event.detailFetchFailed(t),salla.api.errorPromise(t)}return this.request(["details",t],{params:{with:e}}).then((function(e){return salla.product.event.detailFetched(e,t),e})).catch((function(e){throw salla.product.event.availabilitySubscribeFailed(e,t),e}))}addGiftToCart(t,e,n=!1){return this.request(["giftToCart",t],e).then((e=>(salla.product.event.addGiftToCartSucceeded(e,t),n&&(window.location.href=e.redirect),e))).catch((e=>{throw salla.product.event.addGiftToCartFailed(e,t),e}))}uploadGiftImage(t){return this.request("giftImage",t).then((t=>(salla.product.event.giftImageUploadSucceeded(t),t))).catch((t=>{throw salla.product.event.giftImageUploadFailed(t),t}))}fetch(t){if(!t.source){const t="Source cannot be empty. Please provide one.";return salla.product.event.productListFetchFailed(t),salla.api.errorPromise(t)}const e=!t.source_value,n="string"==typeof t.source_value&&"[]"===t.source_value,i=Array.isArray(t.source_value)&&!t.source_value.length;if((e||n||i)&&!["offers","latest","sales"].includes(t.source)){const t="Source value cannot be empty. Please provide one.";return salla.product.event.productListFetchFailed(t),salla.api.errorPromise(t)}if(["categories","brands","tags","selected"].includes(t.source)&&!Array.isArray(t.source_value)){const t="SourceValue type error. Expected an array.";return salla.product.event.productListFetchFailed(t),salla.api.errorPromise(t)}if("search"===t.source&&"string"!=typeof t.source_value){const t="SourceValue type error. Expected a string.";return salla.product.event.productListFetchFailed(t),salla.api.errorPromise(t)}if("related"===t.source&&isNaN(t.source_value)){const t="SourceValue type error. Expected a number.";return salla.product.event.productListFetchFailed(t),salla.api.errorPromise(t)}return this.request(this.endpoints.fetch,{params:t},"get").then((t=>(salla.product.event.productListFetchSucceeded(t),t))).catch((t=>{throw salla.product.event.productListFetchFailed(t),t}))}}class Ra extends Oa{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((t=>{let e={id:t.data.id,type:"user",email:t.data.email,mobile:t.data.phone.code+t.data.phone.number,country_code:t.data.phone.country,language_code:t.data.language,currency_code:t.data.currency,notifications:t.data.notifications,pending_orders:t.data.pending_orders,avatar:t.data.avatar,first_name:t.data.first_name,last_name:t.data.last_name,fetched_at:Date.now()};return salla.config.set("user",e),salla.storage.set("user",e),salla.profile.event.infoFetched(t),t})).catch((t=>{throw salla.profile.event.infoNotFetched(t),t}))}update(t){return this.request("update",t).then((t=>(salla.profile.event.updated(t),t))).catch((t=>{throw salla.event.profile.updateFailed(t),t}))}updateContacts(t){return this.request("updateContacts",t).then((t=>(salla.profile.event.verificationCodeSent(t),t))).catch((t=>{throw salla.event.profile.updateContactsFailed(t),t}))}verify(t){return this.request("verify",t).then((t=>(salla.profile.event.verified(t),t))).catch((t=>{throw salla.event.profile.unverified(t),t}))}updateSettings(t){return this.request("updateSettings",t).then((t=>(salla.event.profile.settingsUpdated(t),t))).catch((t=>{throw salla.event.profile.updateSettingsFailed(t),t}))}delete(){return this.request("delete").then((t=>(salla.storage.clearAll(),salla.cookie.clearAll(),salla.event.profile.deleted(t),window.location.href=salla.url.get("logout"),t))).catch((t=>{throw salla.event.profile.notDeleted(t),t}))}}class Pa extends Oa{constructor(){super(),this.namespace="comment",this.endpoints={addComment:"{type}/{id}/comments",comments:"/comments"},this.after_init()}add(t){if(t?.data&&(t=t.data),"string"==typeof(t=this.getCommentPayload(t,!0)))return salla.event.comment.additionFailed(t),salla.api.errorPromise(t);if(!t.comment){let t="can't find comment content!";return salla.event.comment.additionFailed(t),salla.api.errorPromise(t)}return this.request(["addComment",t.type,t.id],{comment:t.comment}).then((function(e){return salla.event.comment.added(e,t.id),e})).catch((function(e){throw salla.event.comment.additionFailed(e,t.id),e}))}getCommentPayload(t,e=!1){let n={};if(["id","type","comment","per_page","page"].forEach((e=>{let i=salla.form.getPossibleValue(t,[e]);i&&(n[e]=i)})),!e){let e=t.ids;if(e&&(n.ids=Array.isArray(e)?e:[e]),!n.ids||!n.ids.length)return"Failed to get ids!"}return n.type&&["products","pages","product","page"].includes(n.type)?(n.type+=["product","page"].includes(n.type)?"s":"",n):"Failed to get type one of:(products, product, page, pages)!"}fetchComments(t){if("string"==typeof(t=this.getCommentPayload(t)))return salla.event.comment.fetchFailed(t),salla.api.errorPromise(t);const e={per_page:t.per_page||5,page:t.page||1,type:t.type,ids:t.ids};return this.request(["comments"],{params:e},"get").then((function(e){return salla.event.comment.fetched(e,t),e})).catch((function(e){throw salla.event.comment.fetchFailed(e,t),e}))}getPageComments(t,e=1,n=5){return this.fetchComments({ids:[t],type:"pages",page:e,per_page:n})}getProductComments(t,e=1,n=5){return this.fetchComments({ids:[t],type:"products",page:e,per_page:n})}}class Ca extends Oa{constructor(){super(),this.namespace="currency",this.endpoints={change:"/",list:"currencies"},this.endpointsMethods={change:"get",list:"get"},this.webEndpoints=["change"],this.after_init()}change(t){if(!(t=salla.form.getPossibleValue(t.data||t,["currency","code"]))){let t="Can't find currency code!";return salla.currency.event.failed(t),salla.api.errorPromise(t)}return this.request("change",{params:{change_currency:"",currency:t}}).then((function(e){return salla.cookie.set("fresh_summary",1),salla.storage.set("cart",""),salla.currency.event.changed(e,t),e})).catch((function(e){throw salla.currency.event.failed(e,t),e}))}list(){return this.request("list").then((function(t){return salla.currency.event.fetched(t),t})).catch((function(t){throw salla.currency.event.failedToFetch(t),t}))}}class Da extends Oa{constructor(){super(),this.namespace="document"}}class La extends Oa{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(t){let e="object"==typeof t?t:{},n=salla.form.getPossibleValue(t?.data||t,["order_id","id"]);if(!n){let t='There is no "order_id"!';return salla.event.rating.orderNotFetched(t),salla.api.errorPromise(t)}return this.request(["order",n],e).then((function(t){return salla.event.rating.orderFetched(t,n),t})).catch((function(t){throw salla.event.rating.orderNotFetched(t,n),t}))}store(t){if(!(t=t?.data||t)){let t='There is no "data"!';return salla.event.rating.storeFailed(t),salla.api.errorPromise(t)}return this.request("store",t).then((function(e){return salla.event.rating.storeRated(e,t),e})).catch((function(e){throw salla.event.rating.storeFailed(e,t),e}))}products(t){if(!(t=t?.data||t)){let t='There is no "data"!';return salla.event.rating.productsFailed(t),salla.api.errorPromise(t)}return this.request("products",t).then((function(e){return salla.event.rating.productsRated(e,t),e})).catch((function(e){throw salla.event.rating.productsFailed(e,t),e}))}shipping(t){if(!(t=t?.data||t)){let t='There is no "data"!';return salla.event.rating.shippingFailed(t),salla.api.errorPromise(t)}return this.request("shipping",t).then((function(e){return salla.event.rating.shippingRated(e,t),e})).catch((function(e){throw salla.event.rating.shippingFailed(e,t),e}))}}class $a extends Oa{constructor(){super(),this.namespace="wishlist",this.endpoints={add:"products/favorites/{id}",remove:"products/favorites/{id}"},this.endpointsMethods={remove:"delete"},this.after_init()}toggle(t){return salla.storage.get("salla::wishlist",[]).includes(t)?this.remove(t):this.add(t)}add(t){let e;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(e=salla.lang.get("common.messages.must_login")),salla.error(e),salla.api.errorPromise(e)):(t=salla.form.getPossibleValue(t?.data||t,["product_id","id"]))?this.request(["add",t]).then((e=>(this.updateWishlistStorage(t),salla.wishlist.event.added(e,t),e))).catch((function(e){throw salla.wishlist.event.additionFailed(e,t),e})):(salla.wishlist.event.additionFailed(e="Failed to get product id!"),salla.api.errorPromise(e))}remove(t){let e;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(e=salla.lang.get("common.messages.must_login")),salla.error(e),salla.api.errorPromise(e)):(t=salla.form.getPossibleValue(t?.data||t,["product_id","id"]))?this.request(["remove",t]).then((e=>(this.updateWishlistStorage(t,!1),salla.wishlist.event.removed(e,t),e))).catch((function(e){throw salla.wishlist.event.removingFailed(e,t),e})):(salla.wishlist.event.removingFailed(e="Failed to get id!"),salla.api.errorPromise(e))}updateWishlistStorage(t,e=!0){let n=salla.storage.get("salla::wishlist",[]);e?n.push(t):n.splice(n.indexOf(t),1),salla.storage.set("salla::wishlist",n)}}class Na extends Oa{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((t=>(salla.scope.event.fetched(t),t))).catch((t=>{throw salla.scope.event.notFetched(t),t}))}change(t){return this.request("scopes",t).then((t=>(salla.scope.event.changeSucceeded(t),t))).catch((t=>{throw salla.scope.event.changeFailed(t),t}))}getProductAvailability(t=null){return this.request(`scopes/availability?product_id=${t}`,null,"get").then((e=>(salla.scope.event.productAvailabilityFetched(e,t),e))).catch((t=>{throw salla.scope.event.productAvailabilityNotFetched(t),t}))}}class qa extends Oa{constructor(){super(),this.namespace="booking",this.endpoints={add:"cart/booking/product/{id}"},this.endpointsMethods={add:"get"}}async add(t,e=!0){if(!t){let t="Please provide product id.";return salla.booking.event.additionFailed(t),salla.api.errorPromise(t)}return this.request(["add",t]).then((function(t){return salla.booking.event.added(t),e&&"booking"===t.data.redirect.to&&(window.location.href=t.data.redirect.url),t})).catch((function(t){throw salla.booking.event.additionFailed(t),t}))}}class Ua extends Oa{constructor(){super(),this.namespace="landing",this.endpoints={getDetails:"landing/{landing_page_id}",createCartFromPage:"landing/{landing_page_id}",breadcrumbs:"breadcrumbs"},this.endpointsMethods={getDetails:"get",breadcrumbs:"get"},this.after_init()}getDetails(t){if(!t){let t="page landing id not passed";return salla.event.landing.getDetailsFailed(t),salla.api.errorPromise(t)}return this.request(["getDetails",t]).then((function(e){return salla.event.landing.detailsFetched(e,t),e})).catch((function(e){throw salla.event.landing.getDetailsFailed(e,t),e}))}createCartFromPage(t){if(!t){let t="page landing id not passed";return salla.event.landing.orderCreationFailed(t),salla.api.errorPromise(t)}return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("landing::createCartFromPage",t),salla.event.dispatch("login::open"),salla.api.successPromise("")):this.request(["createCartFromPage",t]).then((function(e){return salla.event.landing.orderCreated(e,t).then((()=>location.href=e.data.url)),e})).catch((function(e){throw salla.event.landing.orderCreationFailed(e,t),e}))}fetchBreadcrumbs(t){if(!t.page){let t="The 'page' parameter is required for the Breadcrumb API. Please provide a valid 'page' parameter.";return salla.event.landing.breadcrumbFetchFailed(t),salla.api.errorPromise(t)}if("product.single"===t.page&&!t.id&&!t.parent_id){let t="The 'id' and 'parent_id' parameters are required when the 'page' parameter is set to 'product.single'. Please provide valid values for both parameters.";return salla.event.landing.breadcrumbFetchFailed(t),salla.api.errorPromise(t)}if(["product.index","customer.orders.single","product.index.tag","page-single","landing-page","brands.single","blog.single","blog.index.author","blog.index.category","blog.index.tag"].includes(t.page)&&!t.id){let e=`The 'id' parameter is required when the 'page' parameter is set to ${t.page}. Please provide valid value for the 'ID' parameter.`;return salla.event.landing.breadcrumbFetchFailed(e),salla.api.errorPromise(e)}return this.request("breadcrumbs",{params:t}).then((function(t){return salla.event.landing.breadcrumbFetched(t),t})).catch((function(t){throw salla.event.landing.breadcrumbFetchFailed(t),t}))}}class Ma extends Oa{constructor(){super(),this.namespace="notifications",this.endpoints={fetch:"notifications"},this.endpointsMethods={fetch:"get"},this.after_init()}fetch(t){return this.request(["fetch"],{params:t}).then((function(t){return salla.event.notifications.fetched(t),t})).catch((function(t){throw salla.event.notifications.fetchFailed(t),t}))}}class za{constructor(){salla.event.on("twilight::before.ready",(t=>this.initiateRequest(t))),salla.event.on("profile::info.fetched",(t=>this.setCurrencyAndLanguage(t))),salla.event.on("auth::token.fetched",(t=>{salla.storage.set("token",t),this.setToken(t)})),salla.event.on("auth::token.invalid",(()=>{salla.storage.remove("user"),salla.storage.remove("token")})),this.notifier_handler_disabled=!1,this.axios=da.create({headers:{common:{"X-Requested-With":"XMLHttpRequest","S-SOURCE":"twilight","S-APP-VERSION":"v2.0.0","S-APP-OS":"browser","cache-control":"no-cache"}}})}getHeaders(){return this.axios.defaults.headers.common}setHeaders(t){return Object.entries(t).forEach((t=>this.setHeader(t[0],t[1]))),this}setHeader(t,e){return salla.infiniteScroll.fetchOptions.headers[t]=this.axios.defaults.headers.common[t]=e,this}async withoutNotifier(t){return this.notifier_handler_disabled=!0,await t().finally((()=>{this.notifier_handler_disabled=!1}))}async initiateRequest(t){this.axios.defaults.baseURL=Salla.config.get("store.api",Salla.config.get("store.url")),this.setHeaders({"Store-Identifier":Salla.config.get("store.id"),currency:t.user?.currency_code||"SAR","accept-language":salla.lang.getLocale(),"s-user-id":t.user?.id,...t.headers||{}});let e=salla.storage.get("scope");e&&this.setHeaders({"s-scope-type":e.type,"s-scope-id":e.id}),await this.injectTokenToTheRequests(t),salla.storage.get("affiliate_code")&&this.setHeader("s-affiliate-code",salla.storage.get("affiliate_code"))}async injectTokenToTheRequests(t){let e=salla.storage.get("token"),n="guest"===t.user.type,i=t.user?.id,r=salla.storage.get("user.id"),a=t=>{this.setToken(t),salla.event.emit("api::initiated")},s=async()=>{!n&&i?(salla.log("Api:: case 1 => current is is guest & web session available"),await salla.auth.api.refresh().then((async()=>{await salla.profile.info()})).catch((()=>salla.auth.event.tokenInvalid()))):salla.auth.event.tokenInvalid()};if(!e)return salla.log("Api:: case 1 => current is is guest"),void await s();let o=wa(e);return Date.now()/1e3>o.exp?(salla.log("Api:: case 2 => current user is logged-in and there is a token, but it's expired"),void await s()):o.sub===i&&r===i&&r&&i?(salla.log("Api:: case 4 => current user is logged-in and there is a token, and it's not expired"),void a(e)):(salla.log("Api:: case 3 => there is a token and user in session/local missing or mismatch"),salla.log(`sub:${o.sub} userIdInWeb:${i} userIdInStorage:${r}`),this.setHeader("Authorization","Bearer "+e),void await salla.profile.info().then((async t=>{await salla.auth.api.request("auth/jwt"),a(e)})).catch((()=>{salla.log("Api:: case 3 => failed get fresh profile"),this.setHeader("Authorization",null),salla.auth.event.tokenInvalid()})))}setToken(t){return this.setHeader("Authorization","Bearer "+t),salla.event.emit("api::token.injected",t),this.token=t,this}setCurrencyAndLanguage(t){return this.setHeaders({currency:t.data.currency,"accept-language":t.data.language})}request(t,e=void 0,n="get",i={}){let r={endPoint:t,payload:e,method:n,options:i},a="undefined"!=typeof event?event.currentTarget:null,s=!1;return"SALLA-BUTTON"===a?.tagName&&(s=!0),s&&a?.load(),this.axios[r.method](r.endPoint,r.payload,r.options).then((t=>(s&&a?.stop(),t.data&&t.request&&(t=t.data),this.handleAfterResponseActions(t),t))).catch((t=>{throw s&&a?.stop(),salla.event.document.requestFailed(r,t),this.handleErrorResponse(t),t}))}handleAfterResponseActions(t){if(!t)return;let{data:e,googleTags:n=null}=t,i=e&&e.googleTags?e.googleTags:n;try{dataLayer&&i&&dataLayer.push(i)}catch(t){salla.logger.error(t.message)}this.fireEventsForResponse(t),this.showAlert(t)}fireEventsForResponse(t){let e=t?.events||t.data?.events||t.error?.events;"string"==typeof e&&(e=JSON.parse(e)),e&&Object.keys(e).forEach((t=>salla.event.dispatch(t,e[t])))}handleErrorResponse(t){if(t.response&&t.response.data)return t.response.data.error&&t.response.data.error.fields&&!this.notifier_handler_disabled?this.handleInvalidFields(t):this.handleAfterResponseActions(t.response.data)}showAlert(t){if(t&&!this.notifier_handler_disabled)return t.case&&t.msg?salla.notify.fire(t.msg,t.case,t):t.hasOwnProperty("success")&&t.data?.message?salla.notify.fire(t.data?.message,t.success?salla.notify.types.success:salla.notify.types.error,t):t.error&&t.error.message&&"FORBIDDEN"!==t.error.message?salla.error(t.error.message,t):void 0}handleInvalidFields(t){let e=t.response.data.error.fields,n=[];Object.keys(e).forEach((t=>{let i=e[t];Array.isArray(i)?i.forEach((t=>n.push(t))):n.push(i)}));let i=(n.length>1?"* ":"")+n.join("\n* ");salla.error(i,t)}isFastRequestsAllowed(){return Salla.config.get("fastRequests")}promise(t,e=!0){return new Promise(((n,i)=>e?n(t):i(t)))}errorPromise(t){return this.promise(t,!1)}successPromise(t){return this.promise(t,!0)}}class Ba extends Oa{constructor(){super(),this.namespace="component",this.endpoints={getMenus:"menus/{headOrFoot}",reviews:"reviews"},this.endpointsMethods={getMenus:"get",reviews:"get"}}async getMenus(t="header"){return this.request(["getMenus",t]).then((function(t){return salla.event.component.menuFetched(t),t})).catch((function(t){throw salla.event.component.menuFetchFailed(t),t}))}async getReviews({per_page:t=5,type:e="all",items:n}){if(!e){const t="Review type cannot be empty. Please provide one.";return salla.event.component.reviewsFetchFailed(t),salla.api.errorPromise(t)}const i=!n||"string"==typeof n&&"[]"===n||Array.isArray(n)&&!n.length;if(!new Set(["all","store","categories","products","json"]).has(e)){const t="Invalid review type. Please provide a valid type.";return salla.event.component.reviewsFetchFailed(t),salla.api.errorPromise(t)}if("all"!==e&&"store"!==e&&i){const t="Items cannot be empty. Please provide one.";return salla.event.component.reviewsFetchFailed(t),salla.api.errorPromise(t)}if(new Set(["products","categories"]).has(e)&&!Array.isArray(n)){const t=`Items value must be an array of ${e} id for review type of ${e}.`;return salla.event.component.reviewsFetchFailed(t),salla.api.errorPromise(t)}return this.request(["reviews"],{params:{per_page:t,type:e,items:n}},"get").then((function(t){return salla.event.component.reviewsFetched(t),t})).catch((function(t){throw salla.event.component.reviewsFetchFailed(t),t}))}}class Ja extends Oa{constructor(){super(),this.namespace="booking",this.endpoints={fetch:"advertisements"},this.endpointsMethods={fetch:"get"}}async fetch(t=null){const e=t?{page:t}:{};return this.request(["fetch"],{params:e}).then((function(t){return salla.event.advertisement.fetched(t),t})).catch((function(t){throw salla.event.advertisement.fetchFailed(t),t}))}}class Ga extends Oa{constructor(){super(),this.namespace="navigation",this.endpoints={breadcrumbs:"breadcrumbs"},this.endpointsMethods={breadcrumbs:"get"},this.after_init()}fetchBreadcrumbs(t){if(!t.page){let t="The 'page' parameter is required for the Breadcrumb API. Please provide a valid 'page' parameter.";return salla.event.navigation.breadcrumbFetchFailed(t),salla.api.errorPromise(t)}if(["product.single","product.index","customer.orders.single","product.index.tag","page-single","landing-page","brands.single","blog.single","blog.index.author","blog.index.category","blog.index.tag"].includes(t.page)&&!t.id){let e=`The 'id' parameter is required when the 'page' parameter is set to ${t.page}. Please provide valid value for the 'ID' parameter.`;return salla.event.navigation.breadcrumbFetchFailed(e),salla.api.errorPromise(e)}return this.request("breadcrumbs",{params:t}).then((function(t){return salla.event.navigation.breadcrumbFetched(t),t})).catch((function(t){throw salla.event.navigation.breadcrumbFetchFailed(t),t}))}}class Ha{constructor(t){"ready"!==ji.status?t?(ji.config.merge(t),t?.events&&ji.event.dispatchEvents(t?.events),t._token&&salla.api.setHeader("X-CSRF-TOKEN",t._token),this.injectMaintenanceAlert(),this.injectTemplateStoreAlert(),this.injectThemePreviewAlert(),this.injectAppInstallAlert(),this.injectEditAlert(),t?.user?.language_code&&salla.lang.setLocale(t?.user?.language_code),salla.lang.loadStoreTranslations(),this.setSallaReady(t)):this.setSallaReady(t):salla.log("Trying to re-initiate Salla, while its status === 'ready'!")}injectMaintenanceAlert(){salla.config.get("maintenance")&&(document.body.classList.add("has-maintenance-bar"),document.querySelector("salla-maintenance-alert")?salla.logger.warn("salla-maintenance-alert element Existed before!"):salla.lang.onLoaded((()=>document.body.prepend(document.createElement("salla-maintenance-alert")))))}injectTemplateStoreAlert(){salla.config.get("store.template")&&(document.body.classList.add("has-bottom-alert"),document.querySelector("salla-bottom-alert")?salla.logger.warn("salla-bottom-alert element Existed before!"):salla.lang.onLoaded((()=>document.body.append(document.createElement("salla-bottom-alert")))))}injectAppInstallAlert(){salla.config.get("store.app_install_prompt")&&salla.config.get("store.apps")&&!salla.storage.get("app_install_prompt_disabled")&&(document.body.classList.add("has-app-install-alert"),document.querySelector("salla-app-install-alert")?salla.logger.warn("salla-app-install-alert element Existed before!"):salla.lang.onLoaded((()=>document.body.append(document.createElement("salla-app-install-alert")))))}injectThemePreviewAlert(){"preview"===salla.config.get("theme.mode")&&(document.body.classList.add("has-preview-bar"),document.querySelector("#s-theme_preview_bar")?salla.logger.warn("#s-theme_preview_bar element Existed before!"):salla.lang.onLoaded((()=>{let t=document.createElement("div");t.id="s-theme_preview_bar",t.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;"),t.innerHTML=`\n <div style="display:flex; align-items:center;">\n <img width="32" src="https://cdn.salla.network/images/logo/logo-light.svg">\n <span style="margin:0 10px;">${salla.lang.get("blocks.header.preview_mode")}: <span style="background:rgba(255,255,255,0.25);border-radius:15px; padding:2px 15px 4px">${salla.config.get("theme.name")}</span></span>\n </div>\n <a href="${salla.url.get("preview_theme/cancel/preview")}" style="line-height:32px; width:32px;"><i class="sicon-cancel"></i></a>\n `,document.body.prepend(t)})))}injectEditAlert(){let t=salla.config.get("edit");t&&(document.querySelector("#s-edit-alert")?salla.logger.warn("#s-edit-alert element Existed before!"):salla.lang.onLoaded((()=>{let e=document.createElement("div");e.id="s-edit-alert",e.innerHTML=`\n <a href="${t}" 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(e)})))}handleElementAjaxRequest(t,e){if(!(e instanceof HTMLFormElement||e instanceof HTMLAnchorElement))return salla.logger.warn("trying to call ajax from non Element!!"),!1;t.preventDefault();let n=e.getAjaxFormData(t),i=n.method?n.method.toLowerCase():void 0;salla.api.request(n.url,n.formData,i).then((t=>(t.data&&t.request&&(t=t.data),salla.api.handleAfterResponseActions(t),this.callAjaxEvent(n.events.success,t,n.formData),t))).catch((t=>{throw salla.api.handleErrorResponse(t),this.callAjaxEvent(n.events.fail,t,n.formData),t}))}callAjaxEvent(t,e,n){if(t){if(n instanceof FormData){const t={};Array.from(n.entries()).forEach((function(e){t[e[0]]=e[1]})),n=t}window[t]?window[t](e,n):salla.event.dispatch(t,e,n)}}setSallaReady(t){ji.event.dispatch("twilight::before.ready",t),ji.status="ready",ji.event.dispatch("twilight::initiated",t),window.dispatchEvent(new CustomEvent("twilight::initiated",{detail:t}))}}ji.status="loading",ji.notify=_a,ji.lang=new class extends Ci{constructor(t){(t=t||{}).messages=t.messages||window.translations,t.locale=t.locale||(window.locale||navigator.language||navigator.userLanguage||"ar").split("-")[0],t.fallback=t.fallback||t.locale,super(t),this.translationsLoaded=!1}onLoaded(t){return new Promise((e=>{if(this.translationsLoaded)return e(t?t():null);Salla.event.once("languages::translations.loaded",(()=>e(t?t():null)))}))}loadStoreTranslations(){if(this.hash=salla.config.get("theme.translations_hash",salla.config.get("store.id","twilight")),this.message||(salla.log("try to load translations from localstorage"),this.messages=salla.storage.get(`s_translations.${this.hash}`),this.messages&&(this.translationsLoaded=!0)&&super.setMessages(this.messages)),this.messages)return salla.event.dispatch("languages::translations.loaded"),void salla.logger.info("The messages of transactions is already loaded");salla.url.get("")?this.loadScript(salla.url.get(`languages/assets/${this.hash}.js`)):this.loadScript("https://cdn.salla.network/js/translations.js",!1)}setMessages(t){super.setMessages(t),salla.event.dispatch("languages::translations.loaded"),this.translationsLoaded=!0}loadScript(t,e=!0){let n=document.createElement("script");n.src=t,n.onload=()=>{if(window.translations)return salla.storage.remove("s_translations"),salla.storage.set("s_translations",{[this.hash]:window.translations}),this.setMessages(window.translations);n.onerror()},n.onerror=()=>{if(e)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)}getWithDefault(t,e,n,i){let r=this.get(t,n,i);return r!==t?r:e}get(t,e,n){let i=t;(window.translations||this.translationsLoaded)&&(i="trans."+t);let r=super.get(i,e,n);return r!==i?r:super.get(i,e,"en").replace(i,t)}set(t,e){return salla.helpers.setNested(this.messages[this.getLocale()+".trans"],t,e),this}},ji.form=new class{async submit(t,e=null){let n=e;if("SubmitEvent"===e?.constructor?.name||"submit"===e?.type){if(e.preventDefault(),"FORM"!==e.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"===e?.submitter?.parentElement?.tagName&&e.submitter.parentElement.load(),n=e.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(t))return salla.api.request(t,n,"post").finally((()=>{loaderSupported&&e?.submitter?.parentElement.stop()}));let i=t.split("."),r=i.splice(-1);return await salla.call(i.join("."))[r](n).finally((()=>e?.submitter?.parentElement?.stop())).catch((t=>{throw salla.logger.warn(t),t}))}onSubmit(t,e){return salla.form.submit(t,e),!1}onChange(t,e){return e?.currentTarget?"FORM"!==e?.currentTarget?.tagName||e.currentTarget.checkValidity()?(salla.form.submit(t,e.currentTarget.getElementSallaData()),!0):(salla.logger.warn(`Trying to trigger '${t}' without filling required fields!`),!1):(salla.logger.warn(`Trying to trigger '${t}' without event!`),!1)}getPossibleValue(t,e,n=!1){if(!t)return;if("object"!=typeof t)return t;let i;for(let n=0;n<e.length&&!(i=t[e[n]])&&!("undefined"!=typeof FormData&&t instanceof FormData&&(i=t.get(e[n])));n++);return i=i||t,"object"!=typeof i||n?i:void 0}},ji.infiniteScroll=new class extends xa{constructor(t,e){super(t,e),this.options={path:".infinite-scroll-btn",history:"push",status:".infinite-scroll-status",append:".list-block"},this.fetchOptions={headers:{"S-INFINITE-SCROLL":!0,"S-Source":"twilight","cache-control":"no-cache",pragma:"no-cache"}},this.instances=[]}initiate(t,e,n,i=!1){i?((n=n||{}).fetchOptions={...this.fetchOptions,...n.fetchOptions||{}},n.responseBody="json"):n=this.getCustomOptions(e,n);let r="string"!=typeof t?t:document.querySelector(t),a=n.path;if(!r||!a||"string"==typeof a&&!document.querySelector(a))return void Salla.logger.warn(r?"Path Option (a link that has next page link) Not Existed!":"Container For InfiniteScroll not Existed!");let s=new Pi(r,n);return s.on("scrollThreshold",Salla.infiniteScroll.event.scrollThreshold),s.on("request",Salla.infiniteScroll.event.request),s.on("load",Salla.infiniteScroll.event.load),s.on("append",Salla.infiniteScroll.event.append),s.on("error",Salla.infiniteScroll.event.error),s.on("last",Salla.infiniteScroll.event.last),s.on("history",Salla.infiniteScroll.event.history),this.instances.push(s),s}getCustomOptions(t,e){return(e="object"==typeof t&&t||e||this.options).fetchOptions=this.fetchOptions,e.path=e.path||this.options.path,e.button=e.button||e.path,e.status=e.status||this.options.status,e.hasOwnProperty("history")||(e.history=this.options.history),e.nextPage=e.nextPage||e.next_page,e.append="string"==typeof t&&t||e.append||this.options.append,e}loadNextPage(t){("string"!=typeof t?t:document.querySelector(t)).loadNextPage()}destroy(t){("string"!=typeof t?t:document.querySelector(t)).destroy()}}(void 0,salla.event.infiniteScroll),ji.api=new class extends za{constructor(){super(),this.auth=new Aa,this.cart=new Fa,this.loyalty=new ka,this.order=new Ia,this.rating=new La,this.product=new Ta,this.profile=new Ra,this.comment=new Pa,this.currency=new Ca,this.document=new Da,this.wishlist=new $a,this.scope=new Na,this.booking=new qa,this.landing=new Ua,this.notifications=new Ma,this.component=new Ba,this.advertisement=new Ja,this.navigation=new Ga}},["cart","auth","order","scope","rating","comment","loyalty","product","profile","currency","document","wishlist","booking","landing"].forEach((t=>ji[t]=new xa(ji.api[t],ji.event[t]))),ji.call=t=>{let e=ji,n=t.split(".");for(;n.length&&(e=e[n.shift()]););return e},ji.init=t=>new Ha(t),salla.event.once("twilight::init",salla.init),salla.event.once("twilight::api",(t=>{let e=t?.events;e&&salla.event.dispatchEvents(e)})),ji.success=ji.notify.success,ji.error=ji.notify.error,ji.versions.twilight="[VI]{version}[/VI]",ji.onInitiated=t=>salla.event.once("twilight::initiated",t),ji.onReady=ji.onReady||function(t){return new Promise((function(e){return"ready"===salla.status?e(t?t(salla.config.all()):salla.config.all()):ji.onInitiated((n=>e(t?t(n):n)))}))},window.dispatchEvent(new CustomEvent("salla::created"));var Va=e((function(e,n){!function(t,n){e.exports=n()}(t,(function(){function t(){return t=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},t.apply(this,arguments)}var e="undefined"!=typeof window,n=e&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),i=e&&"IntersectionObserver"in window,r=e&&"classList"in document.createElement("p"),a=e&&window.devicePixelRatio>1,s={elements_selector:".lazy",container:n||e?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_bg_hidpi:"bg-hidpi",data_bg_multi:"bg-multi",data_bg_multi_hidpi:"bg-multi-hidpi",data_bg_set:"bg-set",data_poster:"poster",class_applied:"applied",class_loading:"loading",class_loaded:"loaded",class_error:"error",class_entered:"entered",class_exited:"exited",unobserve_completed:!0,unobserve_entered:!1,cancel_on_exit:!0,callback_enter:null,callback_exit:null,callback_applied:null,callback_loading:null,callback_loaded:null,callback_error:null,callback_finish:null,callback_cancel:null,use_native:!1,restore_on_error:!1},o=function(e){return t({},s,e)},l=function(t,e){var n,i="LazyLoad::Initialized",r=new t(e);try{n=new CustomEvent(i,{detail:{instance:r}})}catch(t){(n=document.createEvent("CustomEvent")).initCustomEvent(i,!1,!1,{instance:r})}window.dispatchEvent(n)},u="src",c="srcset",f="sizes",h="poster",d="llOriginalAttrs",p="data",v="loading",g="loaded",m="applied",w="error",y="native",b="data-",S="ll-status",_=function(t,e){return t.getAttribute(b+e)},x=function(t){return _(t,S)},j=function(t,e){return function(t,e,n){var i="data-ll-status";null!==n?t.setAttribute(i,n):t.removeAttribute(i)}(t,0,e)},E=function(t){return j(t,null)},O=function(t){return null===x(t)},F=function(t){return x(t)===y},k=[v,g,m,w],A=function(t,e,n,i){t&&(void 0===i?void 0===n?t(e):t(e,n):t(e,n,i))},I=function(t,e){r?t.classList.add(e):t.className+=(t.className?" ":"")+e},T=function(t,e){r?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\s+)"+e+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},R=function(t){return t.llTempImage},P=function(t,e){if(e){var n=e._observer;n&&n.unobserve(t)}},C=function(t,e){t&&(t.loadingCount+=e)},D=function(t,e){t&&(t.toLoadCount=e)},L=function(t){for(var e,n=[],i=0;e=t.children[i];i+=1)"SOURCE"===e.tagName&&n.push(e);return n},$=function(t,e){var n=t.parentNode;n&&"PICTURE"===n.tagName&&L(n).forEach(e)},N=function(t,e){L(t).forEach(e)},q=[u],U=[u,h],M=[u,c,f],z=[p],B=function(t){return!!t[d]},J=function(t){return t[d]},G=function(t){return delete t[d]},H=function(t,e){if(!B(t)){var n={};e.forEach((function(e){n[e]=t.getAttribute(e)})),t[d]=n}},V=function(t,e){if(B(t)){var n=J(t);e.forEach((function(e){!function(t,e,n){n?t.setAttribute(e,n):t.removeAttribute(e)}(t,e,n[e])}))}},Q=function(t,e,n){I(t,e.class_applied),j(t,m),n&&(e.unobserve_completed&&P(t,e),A(e.callback_applied,t,n))},W=function(t,e,n){I(t,e.class_loading),j(t,v),n&&(C(n,1),A(e.callback_loading,t,n))},X=function(t,e,n){n&&t.setAttribute(e,n)},Z=function(t,e){X(t,f,_(t,e.data_sizes)),X(t,c,_(t,e.data_srcset)),X(t,u,_(t,e.data_src))},K={IMG:function(t,e){$(t,(function(t){H(t,M),Z(t,e)})),H(t,M),Z(t,e)},IFRAME:function(t,e){H(t,q),X(t,u,_(t,e.data_src))},VIDEO:function(t,e){N(t,(function(t){H(t,q),X(t,u,_(t,e.data_src))})),H(t,U),X(t,h,_(t,e.data_poster)),X(t,u,_(t,e.data_src)),t.load()},OBJECT:function(t,e){H(t,z),X(t,p,_(t,e.data_src))}},Y=["IMG","IFRAME","VIDEO","OBJECT"],tt=function(t,e){!e||function(t){return t.loadingCount>0}(e)||function(t){return t.toLoadCount>0}(e)||A(t.callback_finish,e)},et=function(t,e,n){t.addEventListener(e,n),t.llEvLisnrs[e]=n},nt=function(t,e,n){t.removeEventListener(e,n)},it=function(t){return!!t.llEvLisnrs},rt=function(t){if(it(t)){var e=t.llEvLisnrs;for(var n in e){var i=e[n];nt(t,n,i)}delete t.llEvLisnrs}},at=function(t,e,n){!function(t){delete t.llTempImage}(t),C(n,-1),function(t){t&&(t.toLoadCount-=1)}(n),T(t,e.class_loading),e.unobserve_completed&&P(t,n)},st=function(t,e,n){var i=R(t)||t;it(i)||function(t,e,n){it(t)||(t.llEvLisnrs={});var i="VIDEO"===t.tagName?"loadeddata":"load";et(t,i,e),et(t,"error",n)}(i,(function(r){!function(t,e,n,i){var r=F(e);at(e,n,i),I(e,n.class_loaded),j(e,g),A(n.callback_loaded,e,i),r||tt(n,i)}(0,t,e,n),rt(i)}),(function(r){!function(t,e,n,i){var r=F(e);at(e,n,i),I(e,n.class_error),j(e,w),A(n.callback_error,e,i),n.restore_on_error&&V(e,M),r||tt(n,i)}(0,t,e,n),rt(i)}))},ot=function(t,e,n){!function(t){return Y.indexOf(t.tagName)>-1}(t)?function(t,e,n){!function(t){t.llTempImage=document.createElement("IMG")}(t),st(t,e,n),function(t){B(t)||(t[d]={backgroundImage:t.style.backgroundImage})}(t),function(t,e,n){var i=_(t,e.data_bg),r=_(t,e.data_bg_hidpi),s=a&&r?r:i;s&&(t.style.backgroundImage='url("'.concat(s,'")'),R(t).setAttribute(u,s),W(t,e,n))}(t,e,n),function(t,e,n){var i=_(t,e.data_bg_multi),r=_(t,e.data_bg_multi_hidpi),s=a&&r?r:i;s&&(t.style.backgroundImage=s,Q(t,e,n))}(t,e,n),function(t,e,n){var i=_(t,e.data_bg_set);if(i){var r=i.split("|"),a=r.map((function(t){return"image-set(".concat(t,")")}));t.style.backgroundImage=a.join(),""===t.style.backgroundImage&&(a=r.map((function(t){return"-webkit-image-set(".concat(t,")")})),t.style.backgroundImage=a.join()),Q(t,e,n)}}(t,e,n)}(t,e,n):function(t,e,n){st(t,e,n),function(t,e,n){var i=K[t.tagName];i&&(i(t,e),W(t,e,n))}(t,e,n)}(t,e,n)},lt=function(t){t.removeAttribute(u),t.removeAttribute(c),t.removeAttribute(f)},ut=function(t){$(t,(function(t){V(t,M)})),V(t,M)},ct={IMG:ut,IFRAME:function(t){V(t,q)},VIDEO:function(t){N(t,(function(t){V(t,q)})),V(t,U),t.load()},OBJECT:function(t){V(t,z)}},ft=function(t,e){(function(t){var e=ct[t.tagName];e?e(t):function(t){if(B(t)){var e=J(t);t.style.backgroundImage=e.backgroundImage}}(t)})(t),function(t,e){O(t)||F(t)||(T(t,e.class_entered),T(t,e.class_exited),T(t,e.class_applied),T(t,e.class_loading),T(t,e.class_loaded),T(t,e.class_error))}(t,e),E(t),G(t)},ht=["IMG","IFRAME","VIDEO"],dt=function(t){return t.use_native&&"loading"in HTMLImageElement.prototype},pt=function(t,e,n){t.forEach((function(t){return function(t){return t.isIntersecting||t.intersectionRatio>0}(t)?function(t,e,n,i){var r=function(t){return k.indexOf(x(t))>=0}(t);j(t,"entered"),I(t,n.class_entered),T(t,n.class_exited),function(t,e,n){e.unobserve_entered&&P(t,n)}(t,n,i),A(n.callback_enter,t,e,i),r||ot(t,n,i)}(t.target,t,e,n):function(t,e,n,i){O(t)||(I(t,n.class_exited),function(t,e,n,i){n.cancel_on_exit&&function(t){return x(t)===v}(t)&&"IMG"===t.tagName&&(rt(t),function(t){$(t,(function(t){lt(t)})),lt(t)}(t),ut(t),T(t,n.class_loading),C(i,-1),E(t),A(n.callback_cancel,t,e,i))}(t,e,n,i),A(n.callback_exit,t,e,i))}(t.target,t,e,n)}))},vt=function(t){return Array.prototype.slice.call(t)},gt=function(t){return t.container.querySelectorAll(t.elements_selector)},mt=function(t){return function(t){return x(t)===w}(t)},wt=function(t,e){return function(t){return vt(t).filter(O)}(t||gt(e))},yt=function(t,n){var r=o(t);this._settings=r,this.loadingCount=0,function(t,e){i&&!dt(t)&&(e._observer=new IntersectionObserver((function(n){pt(n,t,e)}),function(t){return{root:t.container===document?null:t.container,rootMargin:t.thresholds||t.threshold+"px"}}(t)))}(r,this),function(t,n){e&&(n._onlineHandler=function(){!function(t,e){var n;(n=gt(t),vt(n).filter(mt)).forEach((function(e){T(e,t.class_error),E(e)})),e.update()}(t,n)},window.addEventListener("online",n._onlineHandler))}(r,this),this.update(n)};return yt.prototype={update:function(t){var e,r,a=this._settings,s=wt(t,a);D(this,s.length),!n&&i?dt(a)?function(t,e,n){t.forEach((function(t){-1!==ht.indexOf(t.tagName)&&function(t,e,n){t.setAttribute("loading","lazy"),st(t,e,n),function(t,e){var n=K[t.tagName];n&&n(t,e)}(t,e),j(t,y)}(t,e,n)})),D(n,0)}(s,a,this):(r=s,function(t){t.disconnect()}(e=this._observer),function(t,e){e.forEach((function(e){t.observe(e)}))}(e,r)):this.loadAll(s)},destroy:function(){this._observer&&this._observer.disconnect(),e&&window.removeEventListener("online",this._onlineHandler),gt(this._settings).forEach((function(t){G(t)})),delete this._observer,delete this._settings,delete this._onlineHandler,delete this.loadingCount,delete this.toLoadCount},loadAll:function(t){var e=this,n=this._settings;wt(t,n).forEach((function(t){P(t,e),ot(t,n,e)}))},restoreAll:function(){var t=this._settings;gt(t).forEach((function(e){ft(e,t)}))}},yt.load=function(t,e){var n=o(e);ot(t,n)},yt.resetStatus=function(t){E(t)},e&&function(t,e){if(e)if(e.length)for(var n,i=0;n=e[i];i+=1)l(t,n);else l(t,e)}(yt,window.lazyLoadOptions),yt}))}));function Qa(){if(!document.lazyLoadInstance){document.lazyLoadInstance=new Va({use_native:true});document.lazyLoadBackgrounds=new Va({elements_selector:".lazy[data-bg]:not(.loaded)"})}if(document.readyState!=="complete"){document.addEventListener("DOMContentLoaded",(()=>document.lazyLoadInstance.update()));document.addEventListener("DOMContentLoaded",(()=>document.lazyLoadBackgrounds.update()))}salla.infiniteScroll.event.onAppend((()=>{document.lazyLoadInstance.update();document.lazyLoadBackgrounds.update()}))}const Wa=Qa;export{Wa as g};
|
|
25
|
-
//# sourceMappingURL=p-
|
|
24
|
+
(function(t,n){{e.exports=n()}})(t,(function(){function t(){if(typeof document!=="undefined"&&document.documentElement){return document.documentElement.lang}}function e(t){if(t==="-Inf"){return-Infinity}else if(t==="+Inf"||t==="Inf"||t==="*"){return Infinity}return parseInt(t,10)}var n=/^({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])$/;var i=/({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])/;var r={locale:"en"};var a=function(e){e=e||{};this.locale=e.locale||t()||r.locale;this.fallback=e.fallback;this.messages=e.messages};a.prototype.setMessages=function(t){this.messages=t};a.prototype.getLocale=function(){return this.locale||this.fallback};a.prototype.setLocale=function(t){this.locale=t};a.prototype.getFallback=function(){return this.fallback};a.prototype.setFallback=function(t){this.fallback=t};a.prototype.has=function(t,e){if(typeof t!=="string"||!this.messages){return false}return this._getMessage(t,e)!==null};a.prototype.get=function(t,e,n){if(!this.has(t,n)){return t}var i=this._getMessage(t,n);if(i===null){return t}if(e){i=this._applyReplacements(i,e)}return i};a.prototype.trans=function(t,e){return this.get(t,e)};a.prototype.choice=function(t,e,n,r){n=typeof n!=="undefined"?n:{};n.count=e;var a=this.get(t,n,r);if(a===null||a===undefined){return a}var s=a.split("|");var o=[];for(var l=0;l<s.length;l++){s[l]=s[l].trim();if(i.test(s[l])){var u=s[l].split(/\s/);o.push(u.shift());s[l]=u.join(" ")}}if(s.length===1){return a}for(var c=0;c<o.length;c++){if(this._testInterval(e,o[c])){return s[c]}}r=r||this._getLocale(t);var f=this._getPluralForm(e,r);return s[f]};a.prototype.transChoice=function(t,e,n){return this.choice(t,e,n)};a.prototype._parseKey=function(t,e){if(typeof t!=="string"||typeof e!=="string"){return null}var n=t.split(".");var i=n[0].replace(/\//g,".");return{source:e+"."+i,sourceFallback:this.getFallback()+"."+i,entries:n.slice(1)}};a.prototype._getMessage=function(t,e){e=e||this.getLocale();t=this._parseKey(t,e);if(this.messages[t.source]===undefined&&this.messages[t.sourceFallback]===undefined){return null}var n=this.messages[t.source];var i=t.entries.slice();var r=i.join(".");n=n!==undefined?this._getValueInKey(n,r):undefined;if(typeof n!=="string"&&this.messages[t.sourceFallback]){n=this.messages[t.sourceFallback];i=t.entries.slice();r="";while(i.length&&n!==undefined){var r=!r?i.shift():r.concat(".",i.shift());if(n[r]){n=n[r];r=""}}}if(typeof n!=="string"){return null}return n};a.prototype._getValueInKey=function(t,e){if(typeof t[e]==="string"){return t[e]}e=e.replace(/\[(\w+)\]/g,".$1");e=e.replace(/^\./,"");var n=e.split(".");for(var i=0,r=n.length;i<r;++i){var a=n.slice(0,i+1).join(".");var s=n.slice(i+1,n.length).join(".");if(t[a]){return this._getValueInKey(t[a],s)}}return t};a.prototype._getLocale=function(t){t=this._parseKey(t,this.locale);if(this.messages[t.source]){return this.locale}if(this.messages[t.sourceFallback]){return this.fallback}return null};a.prototype._findMessageInTree=function(t,e){while(t.length&&e!==undefined){var n=t.join(".");if(e[n]){e=e[n];break}e=e[t.shift()]}return e};a.prototype._sortReplacementKeys=function(t,e){return e.length-t.length};a.prototype._applyReplacements=function(t,e){var n=Object.keys(e).sort(this._sortReplacementKeys);n.forEach((function(n){t=t.replace(new RegExp(":"+n,"gi"),(function(t){var i=e[n];var r=t===t.toUpperCase();if(r){return i.toUpperCase()}var a=t===t.replace(/\w/i,(function(t){return t.toUpperCase()}));if(a){return i.charAt(0).toUpperCase()+i.slice(1)}return i}))}));return t};a.prototype._testInterval=function(t,i){if(typeof i!=="string"){throw"Invalid interval: should be a string."}i=i.trim();var r=i.match(n);if(!r){throw"Invalid interval: "+i}if(r[2]){var a=r[2].split(",");for(var s=0;s<a.length;s++){if(parseInt(a[s],10)===t){return true}}}else{r=r.filter((function(t){return!!t}));var o=r[1];var l=e(r[2]);if(l===Infinity){l=-Infinity}var u=e(r[3]);var c=r[4];return(o==="["?t>=l:t>l)&&(c==="]"?t<=u:t<u)}return false};a.prototype._getPluralForm=function(t,e){switch(e){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":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 t==1?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 t===0||t===1?0:1;case"be":case"bs":case"hr":case"ru":case"sr":case"uk":return t%10==1&&t%100!=11?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2;case"cs":case"sk":return t==1?0:t>=2&&t<=4?1:2;case"ga":return t==1?0:t==2?1:2;case"lt":return t%10==1&&t%100!=11?0:t%10>=2&&(t%100<10||t%100>=20)?1:2;case"sl":return t%100==1?0:t%100==2?1:t%100==3||t%100==4?2:3;case"mk":return t%10==1?0:1;case"mt":return t==1?0:t===0||t%100>1&&t%100<11?1:t%100>10&&t%100<20?2:3;case"lv":return t===0?0:t%10==1&&t%100!=11?1:2;case"pl":return t==1?0:t%10>=2&&t%10<=4&&(t%100<12||t%100>14)?1:2;case"cy":return t==1?0:t==2?1:t==8||t==11?2:3;case"ro":return t==1?0:t===0||t%100>0&&t%100<20?1:2;case"ar":return t===0?0:t==1?1:t==2?2:t%100>=3&&t%100<=10?3:t%100>=11&&t%100<=99?4:5;default:return 0}};return a}))}));var Di=function t(e,n){return function t(){var i=new Array(arguments.length);for(var r=0;r<i.length;r++){i[r]=arguments[r]}return e.apply(n,i)}};var Li=Object.prototype.toString;var $i=function(t){return function(e){var n=Li.call(e);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())}}(Object.create(null));function Ni(t){t=t.toLowerCase();return function e(n){return $i(n)===t}}function qi(t){return Array.isArray(t)}function Ui(t){return typeof t==="undefined"}function Mi(t){return t!==null&&!Ui(t)&&t.constructor!==null&&!Ui(t.constructor)&&typeof t.constructor.isBuffer==="function"&&t.constructor.isBuffer(t)}var zi=Ni("ArrayBuffer");function Bi(t){var e;if(typeof ArrayBuffer!=="undefined"&&ArrayBuffer.isView){e=ArrayBuffer.isView(t)}else{e=t&&t.buffer&&zi(t.buffer)}return e}function Ji(t){return typeof t==="string"}function Gi(t){return typeof t==="number"}function Hi(t){return t!==null&&typeof t==="object"}function Vi(t){if($i(t)!=="object"){return false}var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}var Qi=Ni("Date");var Wi=Ni("File");var Xi=Ni("Blob");var Zi=Ni("FileList");function Ki(t){return Li.call(t)==="[object Function]"}function Yi(t){return Hi(t)&&Ki(t.pipe)}function tr(t){var e="[object FormData]";return t&&(typeof FormData==="function"&&t instanceof FormData||Li.call(t)===e||Ki(t.toString)&&t.toString()===e)}var er=Ni("URLSearchParams");function nr(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function ir(){if(typeof navigator!=="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")){return false}return typeof window!=="undefined"&&typeof document!=="undefined"}function rr(t,e){if(t===null||typeof t==="undefined"){return}if(typeof t!=="object"){t=[t]}if(qi(t)){for(var n=0,i=t.length;n<i;n++){e.call(null,t[n],n,t)}}else{for(var r in t){if(Object.prototype.hasOwnProperty.call(t,r)){e.call(null,t[r],r,t)}}}}function ar(){var t={};function e(e,n){if(Vi(t[n])&&Vi(e)){t[n]=ar(t[n],e)}else if(Vi(e)){t[n]=ar({},e)}else if(qi(e)){t[n]=e.slice()}else{t[n]=e}}for(var n=0,i=arguments.length;n<i;n++){rr(arguments[n],e)}return t}function sr(t,e,n){rr(e,(function e(i,r){if(n&&typeof i==="function"){t[r]=Di(i,n)}else{t[r]=i}}));return t}function or(t){if(t.charCodeAt(0)===65279){t=t.slice(1)}return t}function lr(t,e,n,i){t.prototype=Object.create(e.prototype,i);t.prototype.constructor=t;n&&Object.assign(t.prototype,n)}function ur(t,e,n){var i;var r;var a;var s={};e=e||{};do{i=Object.getOwnPropertyNames(t);r=i.length;while(r-- >0){a=i[r];if(!s[a]){e[a]=t[a];s[a]=true}}t=Object.getPrototypeOf(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e}function cr(t,e,n){t=String(t);if(n===undefined||n>t.length){n=t.length}n-=e.length;var i=t.indexOf(e,n);return i!==-1&&i===n}function fr(t){if(!t)return null;var e=t.length;if(Ui(e))return null;var n=new Array(e);while(e-- >0){n[e]=t[e]}return n}var hr=function(t){return function(e){return t&&e instanceof t}}(typeof Uint8Array!=="undefined"&&Object.getPrototypeOf(Uint8Array));var dr={isArray:qi,isArrayBuffer:zi,isBuffer:Mi,isFormData:tr,isArrayBufferView:Bi,isString:Ji,isNumber:Gi,isObject:Hi,isPlainObject:Vi,isUndefined:Ui,isDate:Qi,isFile:Wi,isBlob:Xi,isFunction:Ki,isStream:Yi,isURLSearchParams:er,isStandardBrowserEnv:ir,forEach:rr,merge:ar,extend:sr,trim:nr,stripBOM:or,inherits:lr,toFlatObject:ur,kindOf:$i,kindOfTest:Ni,endsWith:cr,toArray:fr,isTypedArray:hr,isFileList:Zi};function pr(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var vr=function t(e,n,i){if(!n){return e}var r;if(i){r=i(n)}else if(dr.isURLSearchParams(n)){r=n.toString()}else{var a=[];dr.forEach(n,(function t(e,n){if(e===null||typeof e==="undefined"){return}if(dr.isArray(e)){n=n+"[]"}else{e=[e]}dr.forEach(e,(function t(e){if(dr.isDate(e)){e=e.toISOString()}else if(dr.isObject(e)){e=JSON.stringify(e)}a.push(pr(n)+"="+pr(e))}))}));r=a.join("&")}if(r){var s=e.indexOf("#");if(s!==-1){e=e.slice(0,s)}e+=(e.indexOf("?")===-1?"?":"&")+r}return e};function gr(){this.handlers=[]}gr.prototype.use=function t(e,n,i){this.handlers.push({fulfilled:e,rejected:n,synchronous:i?i.synchronous:false,runWhen:i?i.runWhen:null});return this.handlers.length-1};gr.prototype.eject=function t(e){if(this.handlers[e]){this.handlers[e]=null}};gr.prototype.forEach=function t(e){dr.forEach(this.handlers,(function t(n){if(n!==null){e(n)}}))};var mr=gr;var wr=function t(e,n){dr.forEach(e,(function t(i,r){if(r!==n&&r.toUpperCase()===n.toUpperCase()){e[n]=i;delete e[r]}}))};function yr(t,e,n,i,r){Error.call(this);this.message=t;this.name="AxiosError";e&&(this.code=e);n&&(this.config=n);i&&(this.request=i);r&&(this.response=r)}dr.inherits(yr,Error,{toJSON:function t(){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 br=yr.prototype;var Sr={};["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(t){Sr[t]={value:t}}));Object.defineProperties(yr,Sr);Object.defineProperty(br,"isAxiosError",{value:true});yr.from=function(t,e,n,i,r,a){var s=Object.create(br);dr.toFlatObject(t,s,(function t(e){return e!==Error.prototype}));yr.call(s,t.message,e,n,i,r);s.name=t.name;a&&Object.assign(s,a);return s};var _r=yr;var xr={silentJSONParsing:true,forcedJSONParsing:true,clarifyTimeoutError:false};function jr(t,e){e=e||new FormData;var n=[];function i(t){if(t===null)return"";if(dr.isDate(t)){return t.toISOString()}if(dr.isArrayBuffer(t)||dr.isTypedArray(t)){return typeof Blob==="function"?new Blob([t]):Buffer.from(t)}return t}function r(t,a){if(dr.isPlainObject(t)||dr.isArray(t)){if(n.indexOf(t)!==-1){throw Error("Circular reference detected in "+a)}n.push(t);dr.forEach(t,(function t(n,s){if(dr.isUndefined(n))return;var o=a?a+"."+s:s;var l;if(n&&!a&&typeof n==="object"){if(dr.endsWith(s,"{}")){n=JSON.stringify(n)}else if(dr.endsWith(s,"[]")&&(l=dr.toArray(n))){l.forEach((function(t){!dr.isUndefined(t)&&e.append(o,i(t))}));return}}r(n,o)}));n.pop()}else{e.append(a,i(t))}}r(t);return e}var Er=jr;var Or=function t(e,n,i){var r=i.config.validateStatus;if(!i.status||!r||r(i.status)){e(i)}else{n(new _r("Request failed with status code "+i.status,[_r.ERR_BAD_REQUEST,_r.ERR_BAD_RESPONSE][Math.floor(i.status/100)-4],i.config,i.request,i))}};var Fr=dr.isStandardBrowserEnv()?function t(){return{write:function t(e,n,i,r,a,s){var o=[];o.push(e+"="+encodeURIComponent(n));if(dr.isNumber(i)){o.push("expires="+new Date(i).toGMTString())}if(dr.isString(r)){o.push("path="+r)}if(dr.isString(a)){o.push("domain="+a)}if(s===true){o.push("secure")}document.cookie=o.join("; ")},read:function t(e){var n=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function t(e){this.write(e,"",Date.now()-864e5)}}}():function t(){return{write:function t(){},read:function t(){return null},remove:function t(){}}}();var kr=function t(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)};var Ar=function t(e,n){return n?e.replace(/\/+$/,"")+"/"+n.replace(/^\/+/,""):e};var Ir=function t(e,n){if(e&&!kr(n)){return Ar(e,n)}return n};var Tr=["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"];var Rr=function t(e){var n={};var i;var r;var a;if(!e){return n}dr.forEach(e.split("\n"),(function t(e){a=e.indexOf(":");i=dr.trim(e.substr(0,a)).toLowerCase();r=dr.trim(e.substr(a+1));if(i){if(n[i]&&Tr.indexOf(i)>=0){return}if(i==="set-cookie"){n[i]=(n[i]?n[i]:[]).concat([r])}else{n[i]=n[i]?n[i]+", "+r:r}}}));return n};var Pr=dr.isStandardBrowserEnv()?function t(){var e=/(msie|trident)/i.test(navigator.userAgent);var n=document.createElement("a");var i;function r(t){var i=t;if(e){n.setAttribute("href",i);i=n.href}n.setAttribute("href",i);return{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}i=r(window.location.href);return function t(e){var n=dr.isString(e)?r(e):e;return n.protocol===i.protocol&&n.host===i.host}}():function t(){return function t(){return true}}();function Cr(t){_r.call(this,t==null?"canceled":t,_r.ERR_CANCELED);this.name="CanceledError"}dr.inherits(Cr,_r,{__CANCEL__:true});var Dr=Cr;var Lr=function t(e){var n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return n&&n[1]||""};var $r=function t(e){return new Promise((function t(n,i){var r=e.data;var a=e.headers;var s=e.responseType;var o;function l(){if(e.cancelToken){e.cancelToken.unsubscribe(o)}if(e.signal){e.signal.removeEventListener("abort",o)}}if(dr.isFormData(r)&&dr.isStandardBrowserEnv()){delete a["Content-Type"]}var u=new XMLHttpRequest;if(e.auth){var c=e.auth.username||"";var f=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";a.Authorization="Basic "+btoa(c+":"+f)}var h=Ir(e.baseURL,e.url);u.open(e.method.toUpperCase(),vr(h,e.params,e.paramsSerializer),true);u.timeout=e.timeout;function d(){if(!u){return}var t="getAllResponseHeaders"in u?Rr(u.getAllResponseHeaders()):null;var r=!s||s==="text"||s==="json"?u.responseText:u.response;var a={data:r,status:u.status,statusText:u.statusText,headers:t,config:e,request:u};Or((function t(e){n(e);l()}),(function t(e){i(e);l()}),a);u=null}if("onloadend"in u){u.onloadend=d}else{u.onreadystatechange=function t(){if(!u||u.readyState!==4){return}if(u.status===0&&!(u.responseURL&&u.responseURL.indexOf("file:")===0)){return}setTimeout(d)}}u.onabort=function t(){if(!u){return}i(new _r("Request aborted",_r.ECONNABORTED,e,u));u=null};u.onerror=function t(){i(new _r("Network Error",_r.ERR_NETWORK,e,u,u));u=null};u.ontimeout=function t(){var n=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";var r=e.transitional||xr;if(e.timeoutErrorMessage){n=e.timeoutErrorMessage}i(new _r(n,r.clarifyTimeoutError?_r.ETIMEDOUT:_r.ECONNABORTED,e,u));u=null};if(dr.isStandardBrowserEnv()){var p=(e.withCredentials||Pr(h))&&e.xsrfCookieName?Fr.read(e.xsrfCookieName):undefined;if(p){a[e.xsrfHeaderName]=p}}if("setRequestHeader"in u){dr.forEach(a,(function t(e,n){if(typeof r==="undefined"&&n.toLowerCase()==="content-type"){delete a[n]}else{u.setRequestHeader(n,e)}}))}if(!dr.isUndefined(e.withCredentials)){u.withCredentials=!!e.withCredentials}if(s&&s!=="json"){u.responseType=e.responseType}if(typeof e.onDownloadProgress==="function"){u.addEventListener("progress",e.onDownloadProgress)}if(typeof e.onUploadProgress==="function"&&u.upload){u.upload.addEventListener("progress",e.onUploadProgress)}if(e.cancelToken||e.signal){o=function(t){if(!u){return}i(!t||t&&t.type?new Dr:t);u.abort();u=null};e.cancelToken&&e.cancelToken.subscribe(o);if(e.signal){e.signal.aborted?o():e.signal.addEventListener("abort",o)}}if(!r){r=null}var v=Lr(h);if(v&&["http","https","file"].indexOf(v)===-1){i(new _r("Unsupported protocol "+v+":",_r.ERR_BAD_REQUEST,e));return}u.send(r)}))};var Nr=null;var qr={"Content-Type":"application/x-www-form-urlencoded"};function Ur(t,e){if(!dr.isUndefined(t)&&dr.isUndefined(t["Content-Type"])){t["Content-Type"]=e}}function Mr(){var t;if(typeof XMLHttpRequest!=="undefined"){t=$r}else if(typeof process!=="undefined"&&Object.prototype.toString.call(process)==="[object process]"){t=$r}return t}function zr(t,e,n){if(dr.isString(t)){try{(e||JSON.parse)(t);return dr.trim(t)}catch(t){if(t.name!=="SyntaxError"){throw t}}}return(n||JSON.stringify)(t)}var Br={transitional:xr,adapter:Mr(),transformRequest:[function t(e,n){wr(n,"Accept");wr(n,"Content-Type");if(dr.isFormData(e)||dr.isArrayBuffer(e)||dr.isBuffer(e)||dr.isStream(e)||dr.isFile(e)||dr.isBlob(e)){return e}if(dr.isArrayBufferView(e)){return e.buffer}if(dr.isURLSearchParams(e)){Ur(n,"application/x-www-form-urlencoded;charset=utf-8");return e.toString()}var i=dr.isObject(e);var r=n&&n["Content-Type"];var a;if((a=dr.isFileList(e))||i&&r==="multipart/form-data"){var s=this.env&&this.env.FormData;return Er(a?{"files[]":e}:e,s&&new s)}else if(i||r==="application/json"){Ur(n,"application/json");return zr(e)}return e}],transformResponse:[function t(e){var n=this.transitional||Br.transitional;var i=n&&n.silentJSONParsing;var r=n&&n.forcedJSONParsing;var a=!i&&this.responseType==="json";if(a||r&&dr.isString(e)&&e.length){try{return JSON.parse(e)}catch(t){if(a){if(t.name==="SyntaxError"){throw _r.from(t,_r.ERR_BAD_RESPONSE,this,null,this.response)}throw t}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Nr},validateStatus:function t(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};dr.forEach(["delete","get","head"],(function t(e){Br.headers[e]={}}));dr.forEach(["post","put","patch"],(function t(e){Br.headers[e]=dr.merge(qr)}));var Jr=Br;var Gr=function t(e,n,i){var r=this||Jr;dr.forEach(i,(function t(i){e=i.call(r,e,n)}));return e};var Hr=function t(e){return!!(e&&e.__CANCEL__)};function Vr(t){if(t.cancelToken){t.cancelToken.throwIfRequested()}if(t.signal&&t.signal.aborted){throw new Dr}}var Qr=function t(e){Vr(e);e.headers=e.headers||{};e.data=Gr.call(e,e.data,e.headers,e.transformRequest);e.headers=dr.merge(e.headers.common||{},e.headers[e.method]||{},e.headers);dr.forEach(["delete","get","head","post","put","patch","common"],(function t(n){delete e.headers[n]}));var n=e.adapter||Jr.adapter;return n(e).then((function t(n){Vr(e);n.data=Gr.call(e,n.data,n.headers,e.transformResponse);return n}),(function t(n){if(!Hr(n)){Vr(e);if(n&&n.response){n.response.data=Gr.call(e,n.response.data,n.response.headers,e.transformResponse)}}return Promise.reject(n)}))};var Wr=function t(e,n){n=n||{};var i={};function r(t,e){if(dr.isPlainObject(t)&&dr.isPlainObject(e)){return dr.merge(t,e)}else if(dr.isPlainObject(e)){return dr.merge({},e)}else if(dr.isArray(e)){return e.slice()}return e}function a(t){if(!dr.isUndefined(n[t])){return r(e[t],n[t])}else if(!dr.isUndefined(e[t])){return r(undefined,e[t])}}function s(t){if(!dr.isUndefined(n[t])){return r(undefined,n[t])}}function o(t){if(!dr.isUndefined(n[t])){return r(undefined,n[t])}else if(!dr.isUndefined(e[t])){return r(undefined,e[t])}}function l(t){if(t in n){return r(e[t],n[t])}else if(t in e){return r(undefined,e[t])}}var u={url:s,method:s,data:s,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:l};dr.forEach(Object.keys(e).concat(Object.keys(n)),(function t(e){var n=u[e]||a;var r=n(e);dr.isUndefined(r)&&n!==l||(i[e]=r)}));return i};var Xr={version:"0.27.2"};var Zr=Xr.version;var Kr={};["object","boolean","number","function","string","symbol"].forEach((function(t,e){Kr[t]=function n(i){return typeof i===t||"a"+(e<1?"n ":" ")+t}}));var Yr={};Kr.transitional=function t(e,n,i){function r(t,e){return"[Axios v"+Zr+"] Transitional option '"+t+"'"+e+(i?". "+i:"")}return function(t,i,a){if(e===false){throw new _r(r(i," has been removed"+(n?" in "+n:"")),_r.ERR_DEPRECATED)}if(n&&!Yr[i]){Yr[i]=true;console.warn(r(i," has been deprecated since v"+n+" and will be removed in the near future"))}return e?e(t,i,a):true}};function ta(t,e,n){if(typeof t!=="object"){throw new _r("options must be an object",_r.ERR_BAD_OPTION_VALUE)}var i=Object.keys(t);var r=i.length;while(r-- >0){var a=i[r];var s=e[a];if(s){var o=t[a];var l=o===undefined||s(o,a,t);if(l!==true){throw new _r("option "+a+" must be "+l,_r.ERR_BAD_OPTION_VALUE)}continue}if(n!==true){throw new _r("Unknown option "+a,_r.ERR_BAD_OPTION)}}}var ea={assertOptions:ta,validators:Kr};var na=ea.validators;function ia(t){this.defaults=t;this.interceptors={request:new mr,response:new mr}}ia.prototype.request=function t(e,n){if(typeof e==="string"){n=n||{};n.url=e}else{n=e||{}}n=Wr(this.defaults,n);if(n.method){n.method=n.method.toLowerCase()}else if(this.defaults.method){n.method=this.defaults.method.toLowerCase()}else{n.method="get"}var i=n.transitional;if(i!==undefined){ea.assertOptions(i,{silentJSONParsing:na.transitional(na.boolean),forcedJSONParsing:na.transitional(na.boolean),clarifyTimeoutError:na.transitional(na.boolean)},false)}var r=[];var a=true;this.interceptors.request.forEach((function t(e){if(typeof e.runWhen==="function"&&e.runWhen(n)===false){return}a=a&&e.synchronous;r.unshift(e.fulfilled,e.rejected)}));var s=[];this.interceptors.response.forEach((function t(e){s.push(e.fulfilled,e.rejected)}));var o;if(!a){var l=[Qr,undefined];Array.prototype.unshift.apply(l,r);l=l.concat(s);o=Promise.resolve(n);while(l.length){o=o.then(l.shift(),l.shift())}return o}var u=n;while(r.length){var c=r.shift();var f=r.shift();try{u=c(u)}catch(t){f(t);break}}try{o=Qr(u)}catch(t){return Promise.reject(t)}while(s.length){o=o.then(s.shift(),s.shift())}return o};ia.prototype.getUri=function t(e){e=Wr(this.defaults,e);var n=Ir(e.baseURL,e.url);return vr(n,e.params,e.paramsSerializer)};dr.forEach(["delete","get","head","options"],(function t(e){ia.prototype[e]=function(t,n){return this.request(Wr(n||{},{method:e,url:t,data:(n||{}).data}))}}));dr.forEach(["post","put","patch"],(function t(e){function n(t){return function n(i,r,a){return this.request(Wr(a||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:i,data:r}))}}ia.prototype[e]=n();ia.prototype[e+"Form"]=n(true)}));var ra=ia;function aa(t){if(typeof t!=="function"){throw new TypeError("executor must be a function.")}var e;this.promise=new Promise((function t(n){e=n}));var n=this;this.promise.then((function(t){if(!n._listeners)return;var e;var i=n._listeners.length;for(e=0;e<i;e++){n._listeners[e](t)}n._listeners=null}));this.promise.then=function(t){var e;var i=new Promise((function(t){n.subscribe(t);e=t})).then(t);i.cancel=function t(){n.unsubscribe(e)};return i};t((function t(i){if(n.reason){return}n.reason=new Dr(i);e(n.reason)}))}aa.prototype.throwIfRequested=function t(){if(this.reason){throw this.reason}};aa.prototype.subscribe=function t(e){if(this.reason){e(this.reason);return}if(this._listeners){this._listeners.push(e)}else{this._listeners=[e]}};aa.prototype.unsubscribe=function t(e){if(!this._listeners){return}var n=this._listeners.indexOf(e);if(n!==-1){this._listeners.splice(n,1)}};aa.source=function t(){var e;var n=new aa((function t(n){e=n}));return{token:n,cancel:e}};var sa=aa;var oa=function t(e){return function t(n){return e.apply(null,n)}};var la=function t(e){return dr.isObject(e)&&e.isAxiosError===true};function ua(t){var e=new ra(t);var n=Di(ra.prototype.request,e);dr.extend(n,ra.prototype,e);dr.extend(n,e);n.create=function e(n){return ua(Wr(t,n))};return n}var ca=ua(Jr);ca.Axios=ra;ca.CanceledError=Dr;ca.CancelToken=sa;ca.isCancel=Hr;ca.VERSION=Xr.version;ca.toFormData=Er;ca.AxiosError=_r;ca.Cancel=ca.CanceledError;ca.all=function t(e){return Promise.all(e)};ca.spread=oa;ca.isAxiosError=la;var fa=ca;var ha=ca;fa.default=ha;var da=fa;function pa(t){this.message=t}pa.prototype=new Error,pa.prototype.name="InvalidCharacterError";var va="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new pa("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,r=0,a=0,s="";i=e.charAt(a++);~i&&(n=r%4?64*n+i:i,r++%4)?s+=String.fromCharCode(255&n>>(-2*r&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return s};function ga(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(va(t).replace(/(.)/g,(function(t,e){var n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return va(e)}}function ma(t){this.message=t}function wa(t,e){if("string"!=typeof t)throw new ma("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(ga(t.split(".")[n]))}catch(t){throw new ma("Invalid token specified: "+t.message)}}ma.prototype=new Error,ma.prototype.name="InvalidTokenError";let ya=function(t,e,n){return alert(t)},ba=function(t,e){return ya(t,Sa.error,e)},Sa={error:"error",success:"success",info:"info"};var _a={fire:function(t,e,n){return ya(t,e,n)},setNotifier:function(t){ya=t,salla.event.emit("twilight::notifier.changed")},error:ba,success:function(t,e){return ya(t,Sa.success,e)},info:function(t,e){return ya(t,Sa.info,e)},sallaInitiated:function(){let t=window.location.href.match(/([\?\&]danger=)[^&]+/g);t&&(window.history.replaceState(null,document.title,window.location.pathname),salla.event.once("twilight::notifier.changed",(()=>{t.forEach((t=>{t=decodeURI(t.replace("?danger=","").replace("&danger=",""));let e=document.createElement("div");e.innerText=t,ba(e.innerHTML)}))})))},types:Sa};class xa{constructor(t,e){return this.api=t,this.event=e,new Proxy(this,{get:function(n,i){return"event"===i?e:"api"===i?t:t&&t[i]||n[i]}})}}Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(t){for(var e=this;e;){if(e.matches(t))return e;e=e.parentElement}}),Element.prototype.getElementSallaData=function(t,...e){if(!this.getAttribute)return;if(this.hasAttribute("data-json"))try{return JSON.parse(this.getAttribute("data-json"))}catch(t){}let n=this.getAttribute("data-function");if(n&&window[n])return"function"==typeof window[n]?this.getFilteredData(window[n].call(this,...e)):this.getFilteredData(window[n]);let i=this.hasAttribute("data-form-selector")?document.querySelector(this.dataset.formSelector):void 0;if(i="FORM"===this.tagName?this:i||this.closest("form")||this.closest("[salla-form-data]")||this,i&&"FORM"===i.tagName)return this.getFilteredData(new FormData(i),null,i);let r=i.querySelectorAll("[name]");if(!r.length)return this.getFilteredData();let a=Object.assign({},this.dataset);return r.forEach((t=>{if(!["checkbox","radio"].includes(t.type)||t.checked)try{let e=Salla.helpers.inputData(t.name,t.value,a);a[e.name]=e.value}catch(e){Salla.log(t.name+" can't be send")}})),this.getFilteredData(a)},Element.prototype.canEventFireHook=function(t){return!!this.hasAttribute&&this.hasAttribute(Salla.api.hooksPrefix+t.type)},Element.prototype.hasAttributeStartsWith=function(t,e){t=t.toLowerCase();for(var n=0;n<this.attributes.length;n++){let i=this.attributes[n].name.toLowerCase();if(0===i.indexOf(t))return!e||i}return!1},HTMLFormElement.prototype.getAjaxFormData=function(t){var e=this.querySelectorAll('input[type="file"]');e.forEach((t=>{t.files.length||t.setAttribute("disabled","")}));var n=new FormData(this);return e.forEach((t=>{t.files.length||t.removeAttribute("disabled")})),{formData:this.getFilteredData(n,t),url:this.getAttribute("action"),method:this.getAttribute("method")||"post",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}},Element.prototype.getFilteredData=function(t=null,e=null,n=null){return t=t||n?.dataset||this.dataset,n&&this.name&&void 0!==this.value&&(t=function(t,e,n){t instanceof FormData?t.append(e,n):t[e]=n;return t}(t,this.name,this.value)),["filterBeforeSubmit","filterBeforeSend"].forEach((i=>{let r=n?.dataset[i]||this.dataset[i];if(r){var a=window[r];if("function"==typeof a){if(!a(t,n||this,e)&&t)throw`Data failed to be pass verify function window.${r}(formData, element, event)!`;return a(t,n||this,e)}Salla.log("window."+r+"() not found!")}})),t},HTMLAnchorElement.prototype.getAjaxFormData=function(t){return{formData:this.getFilteredData(null,t),url:this.getAttribute("href"),method:this.dataset.type||"get",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}};class ja{constructor(){this.events={},this.namespace="";let t=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(t&&t.length>1?t[1]:"").toLowerCase()}after_init(){this.createDynamicFunctions()}createDynamicFunctions(){Object.keys(this.events).forEach((t=>{this.createDynamicEventFuns(t),this.createDynamicListenerFuns(t)}))}createDynamicEventFuns(t){if(this[t])return;let e=this;this[t]=function(...n){return e.dispatch(t,...n)}}createDynamicListenerFuns(t){let e="on"+t.charAt(0).toUpperCase()+t.slice(1);if(this[e])return;let n=this;this[e]=function(e){return n.on(t,(async(...t)=>e(...t)))}}getEventName(t){return t=this.events[t]||t,!this.namespace||t.includes("::")?t:this.namespace+Salla.event.delimiter+t}dispatch(t,...e){return Salla.event.emitAsync(this.getEventName(t),...e)}on(t,e,n={}){return Salla.event.addListener(this.getEventName(t),e,n)}once(t,e){return Salla.event.once(this.getEventName(t),e)}}function Ea(t){t&&t.sallaInitiated&&!t.initiated&&(t.sallaInitiated(),t.initiated=!0)}Salla.event.auth=new class extends ja{constructor(){super(),this.namespace="auth",this.events={login:"login",logout:"logout",codeSent:"code.sent",codeNotSent:"code.not-sent",verified:"verified",verificationFailed:"verification.failed",loggedIn:"logged.in",registered:"registered",registrationFailed:"registration.failed",loggedOut:"logged.out",failedLogout:"failed.logout",refreshFailed:"refresh.failed",tokenFetched:"token.fetched",tokenInvalid:"token.invalid"},this.after_init()}login(t){return t?(t.type&&this.setTypeActionOnVerified(t.type),this.next_event=t.next_event||null,this.dispatch("login",...arguments)):(this.next_event=null,this.dispatch("login",...arguments))}loggedIn(t){return Salla.profile.info().finally((()=>this.dispatch("loggedIn",t)))}setTypeActionOnVerified(t){this.type_action_on_verified=t}getTypeActionOnVerified(){return this.type_action_on_verified||"redirect"}},Salla.event.cart=new class extends ja{constructor(){super(),this.namespace="cart",this.events={latestFetched:"latest.fetched",latestFailed:"latest.failed",updated:"updated",itemUpdated:"item.updated",itemUpdatedFailed:"item.updated.failed",itemAdded:"item.added",itemAddedFailed:"item.added.failed",itemDeleted:"item.deleted",itemDeletedFailed:"item.deleted.failed",submitted:"submitted",submitFailed:"submit.failed",imageDeleted:"image.deleted",imageNotDeleted:"image.not.deleted",detailsFetched:"details.fetched",detailsNotFetched:"details.not.fetched",successReset:"success.reset",priceQuoteSucceeded:"price-quote.succeeded",priceQuoteFailed:"price-quote.failed",couponAdded:"coupon.added",couponDeleted:"coupon.deleted",couponAdditionFailed:"coupon.addition.failed",couponDeletionFailed:"coupon.deletion.failed",quickOrderSettingFetched:"quick-order.fetched",quickOrderSettingFailed:"quick-order.failed",quickOrderSucceeded:"quick-order.succeeded",quickOrderFailed:"quick-order.failed"},this.after_init()}updated(t){return Salla.cookie.set("fresh_summary",1),t&&"object"==typeof t?(t.offer&&salla.product.event.offerExisted(t.offer),t.redirect&&(salla.log("The current cart is purchased!"),salla.cart.api.reset()),t.cart?(salla.storage.set("cart.summary",{total:t.cart.total,sub_total:t.cart.sub_total,discount:t.cart.discount,real_shipping_cost:t.cart.real_shipping_cost,count:t.cart.count,shipping_cost:t.cart.free_shipping_bar?.has_free_shipping?0:t.cart.real_shipping_cost}),this.dispatch("updated",t.cart)):void salla.log("Failed to get the cart summary!")):(Salla.logger.info("Cart summary not an object!",t),this.dispatch("updated"))}latestFetched(t){return this.updated(t.data),this.dispatch("latestFetched",t)}itemAdded(t,e){return this.updated(t.data),this.dispatch("itemAdded",t,e)}itemDeleted(t,e){return this.updated(t.data),this.dispatch("itemDeleted",t,e)}itemUpdated(t,e){return this.updated(t.data),this.dispatch("itemUpdated",t,e)}couponAdded(t,e){return this.updated(t.data),this.dispatch("couponAdded",t,e)}couponDeleted(t,e){return this.updated(t.data),this.dispatch("couponDeleted",t,e)}},Salla.event.order=new class extends ja{constructor(){super(),this.namespace="order",this.events={canceled:"canceled",notCanceled:"not.canceled",orderCreated:"order.created",orderCreationFailed:"order.creation.failed",invoiceSent:"invoice.sent",invoiceNotSent:"invoice.not.sent",ordersFetched:"order.fetched",ordersNotFetched:"order.not.fetched"},this.after_init()}},Salla.event.scope=new class extends ja{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 ja{constructor(){super(),this.namespace="rating",this.events={orderNotFetched:"order.not.fetched",orderFetched:"order.fetched",storeRated:"store.rated",storeFailed:"store.failed",productsRated:"products.rated",productsFailed:"products.failed",shippingRated:"shipping.rated",shippingFailed:"shipping.failed"},this.after_init()}},Salla.event.booking=new class extends ja{constructor(){super(),this.namespace="booking",this.events={added:"added",additionFailed:"addition.failed"},this.after_init()}},Salla.event.comment=new class extends ja{constructor(){super(),this.namespace="comment",this.events={added:"added",additionFailed:"addition.failed",fetched:"fetched",fetchFailed:"fetch.failed"},this.after_init()}},Salla.event.landing=new class extends ja{constructor(){super(),this.namespace="landing",this.events={detailsFetched:"order.fetched",getDetailsFailed:"get.details.failed",orderCreated:"order.created",orderCreationFailed:"order.creation.failed",breadcrumbFetched:"breadcrumb.fetched",breadcrumbFetchFailed:"breadcrumb.fetch.failed"},this.after_init()}},Salla.event.loyalty=new class extends ja{constructor(){super(),this.namespace="loyalty",this.events={exchangeSucceeded:"exchange.succeeded",exchangeFailed:"exchange.failed",programFetched:"program.fetched",programNotFetched:"program.not.fetched",resetSucceeded:"exchange-reset.succeeded",resetFailed:"exchange-reset.failed"},this.after_init()}exchangeSucceeded(t,e){return salla.cart.event.updated(t.data),this.dispatch("exchangeSucceeded",t,e)}resetSucceeded(t){return salla.cart.event.updated(t.data),this.dispatch("resetSucceeded",t)}},Salla.event.product=new class extends ja{constructor(){super(),this.namespace="product",this.events={priceUpdated:"price.updated",priceUpdateFailed:"price.updated.failed",availabilitySubscribed:"availability.subscribed",availabilitySubscribeFailed:"availability.subscribe.failed",categoriesFetched:"categories.fetched",categoriesFailed:"categories.failed",searchFailed:"search.failed",searchResults:"search.results",offerExisted:"offer.existed",fetchOffersFailed:"fetch.offers.failed",offersFetched:"offers.fetched",sizeGuideFetched:"size-guide.fetched",sizeGuideFetchFailed:"size-guide.failed",giftFetched:"gift.fetched",giftFetchFailed:"gift.failed",detailFetched:"detail.fetched",detailFetchFailed:"detail.failed",addGiftToCartSucceeded:"gift.add-to-cart.succeeded",addGiftToCartFailed:"gift.add-to-cart.failed",giftImageUploadSucceeded:"gift.image-upload.succeeded",giftImageUploadFailed:"gift.image-upload.failed",productListFetchSucceeded:"fetch.succeeded",productListFetchFailed:"fetch.failed"},this.after_init()}},Salla.event.profile=new class extends ja{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 ja{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 ja{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(t,e){this.fireCallableFuns("click",t,e)}onChange(t,e){this.fireCallableFuns("change",t,e)}onSubmit(t,e){this.fireCallableFuns("submit",t,e)}onKeyup(t,e){this.fireCallableFuns("keyup",t,e)}fireCallableFuns(t,e,n){this.on(t,(t=>{"function"!=typeof e?"function"==typeof n&&t.target.matches(e)&&n(t):e(t)}))}fireEvent(t,e,...n){return this.fireEventForElements(t,e,!1,...n)}fireEventForAll(t,e,...n){return this.fireEventForElements(t,e,!0,...n)}fireEventForElements(t,e,n,...i){if("string"==typeof t){if(n)return document.querySelectorAll(t).forEach((t=>this.fireEventForElements(t,e,!1,...i)));t=document.querySelector(t)}if(!t)return void salla.log("Failed To get element to fire event: "+e);const r=new CustomEvent(e,...i);return t.dispatchEvent(r)}},Salla.event.wishlist=new class extends ja{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 ja{constructor(){super(),this.namespace="infiniteScroll",this.events={scrollThreshold:"scroll.threshold",request:"request",load:"load",append:"append",error:"error",last:"last",history:"history"},this.after_init()}},Salla.event.notifications=new class extends ja{constructor(){super(),this.namespace="notifications",this.events={fetched:"fetched",fetchFailed:"fetch.failed"},this.after_init()}},Salla.event.component=new class extends ja{constructor(){super(),this.namespace="component",this.events={menuFetched:"menus.fetched",menuFetchFailed:"menus.fetch.failed",reviewsFetched:"reviews.fetched",reviewsFetchFailed:"reviews.fetch.failed"},this.after_init()}},Salla.event.advertisement=new class extends ja{constructor(){super(),this.namespace="advertisement",this.events={fetched:"advertisement.fetched",fetchFailed:"advertisement.not.fetched"},this.after_init()}},Salla.event.navigation=new class extends ja{constructor(){super(),this.namespace="navigation",this.events={breadcrumbFetched:"breadcrumb.fetched",breadcrumbFetchFailed:"breadcrumb.fetch.failed"},this.after_init()}},Salla.event.on("twilight::initiated",(()=>{Object.keys(Salla).forEach((t=>{"object"==typeof(t=Salla[t])&&(Ea(t),Object.keys(t).forEach((e=>{Ea(t[e])})))}))})),Salla.config.default_properties={debug:"undefined"!=typeof process&&"development"==="production",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 t=!0,e=[];return(await salla.document.api.request("languages",null,"get"))?.data?.map((n=>{t&&(e=[],t=!1),n.code=n.code||n.iso_code,n.url=salla.url.get(n.code),n.is_rtl=n.is_rtl||n.rtl,e.push(n)})),Salla.config.set("languages",e),e},Salla.config.currencies=async()=>{if(Salla.config.triedToGetCurrencies_)return Salla.config.get("currencies");Salla.config.triedToGetCurrencies_=!0;let t=!0,e={};return(await salla.currency.api.list())?.data?.map((n=>{t&&(e={},t=!1),n.country_code=n.code.substr(0,2).toLowerCase(),e[n.code]=n})),Salla.config.set("currencies",e),e};class Oa{constructor(){this.endpoints={},this.webEndpoints=[],this.namespace="BaseApi",this.endpointsMethods={},this.endpointsHeaders={};let t=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(t&&t.length>1?t[1]:"").toLowerCase(),this.debounce={request:void 0,time:300,enabled:!0,exclude:[]}}after_init(){}normalRequest(t,e=void 0,n=null){let i=Array.isArray(t),r=i?this.getUrl(...t):this.getUrl(t);t=i?t[0]:t,n=n||this.endpointsMethods[t]||"post";let a=this.endpointsHeaders[t];if("get"===n&&e instanceof FormData){let t={};Array.from(e.entries()).forEach((function(e){t[e[0]]=e[1]})),e={params:t}}return a&&"get"===n&&(e=e?Object.assign(e,a):a),this.webEndpoints.includes(t)?r=salla.url.get(r):"http"!==r.substring(0,4)&&(r=salla.url.api(r)),Salla.api.request(r,e,n,{headers:a})}request(t,e=void 0,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(t,e,n)):this.normalRequest(t,e,n)}getUrl(t){let e=this.endpoints[t]||t;const n=/{[^{}]+}/i;for(let t=1;t<arguments.length;t++)e=e.replace(n,arguments[t]);return e}event(){return salla.event[this.className]}}class Fa extends Oa{constructor(){super(),this.addToCartTries=0,this.namespace="cart",this.endpoints={latest:"cart/latest",details:"cart/{cart}",quickAdd:"cart/{cart}/item/{product}/quick-add",addItem:"cart/{cart}/item/{product}/add",deleteItem:"cart/{cart}/item/{item}",updateItem:"cart/{cart}/item/{item}",deleteImage:"cart/{cart}/image/{image}",uploadImage:"cart/{cart}/image",status:"cart/{cart}/status",addCoupon:"cart/{id}/coupon",deleteCoupon:"cart/{id}/coupon",getQuickOrderSettings:"checkout/quick-order",createQuickOrder:"checkout/quick-order",priceQuote:"cart/{cartId}/price-quote"},this.endpointsMethods={latest:"get",details:"get",status:"get",updateItem:"post",deleteItem:"delete",deleteImage:"delete",deleteCoupon:"put",getQuickOrderSettings:"get"},this.webEndpoints=["latest"],this.latestCart=null,this.after_init(),salla.event.on("api::initiated",this.getCurrentCartId),salla.event.on("auth::token.fetched",this._checkCurrentCart),salla.event.on("auth::token.invalid",this._checkCurrentCart),salla.event.on("auth::verified",(()=>this.getCurrentCartId(!0)),{async:!0}),salla.event.on("profile::info.fetched",this._checkCurrentCart)}_checkCurrentCart(){let t=salla.storage.get("cart"),e=salla.config.get("user")?.id,n=salla.config.get("store")?.id;t&&t.id&&(t.user_id!==e||t.store_id!==n)&&(salla.log("cart",{user_id:t.user_id,store_id:t.store_id}),salla.log("current",{user_id:e,store_id:n}),salla.log("Api:: case2 => The cart is not belong to current "+(t.user_id!==e?"user":"store")+"!"),salla.cart.api.reset())}async getCurrentCartId(t=!1){if(!t){if(salla.cart.api.latestCart)return salla.cart.api.latestCart.cart.id;let t=salla.storage.get("cart.id");if(t)return t}let e=await salla.cart.api.latest();return salla.cart.api.latestCart=e.data,salla.cart.api.latestCart.cart.id}getUploadImageEndpoint(t){return salla.url.api(this.getUrl("uploadImage",t||salla.storage.get("cart.id")))}latest(){return this.request("latest",{params:{source:""}}).then((t=>(salla.storage.set("cart",t.data.cart),salla.event.cart.latestFetched(t),t))).catch((t=>{throw salla.storage.set("cart",""),salla.event.cart.latestFailed(t),t}))}async details(t,e=[]){return t=t||await this.getCurrentCartId(),this.request(["details",t],{params:{with:e}}).then((function(t){return salla.cart.event.detailsFetched(t),t})).catch((function(t){throw salla.cart.event.detailsNotFetched(t),t}))}async quickAdd(t,e){return this.addItem({id:t,quantity:e,endpoint:"quickAdd"})}async addItem(t){let e=this.getCartPayload(t);if(!e.id){let t='There is no product "id"!';return salla.cart.event.itemAddedFailed(t),salla.api.errorPromise(t)}let n=salla.form.getPossibleValue(e.payload,["endpoint"]);n&&["addItem","quickAdd"].includes(n)||(n=salla.form.getPossibleValue(e.payload,["quantity","donating_amount"])?"addItem":"quickAdd");let i=await this.getCurrentCartId();return this.request([n,i,e.id],e.payload).then((function(t){return salla.cart.api.addToCartTries=0,salla.cart.event.itemAdded(t,e.id),t})).catch((function(n){if(!salla.cart.api.addToCartTries)return salla.cart.api.addToCartTries++,salla.cart.reset(),salla.cart.api.addItem(t);throw salla.cart.event.itemAddedFailed(n,e.id),n}))}async deleteItem(t){let e=this.getCartPayload(t);if(!e.id){let t='There is no "id"!';return salla.cart.event.itemDeletedFailed(t),salla.api.errorPromise(t)}let n=await this.getCurrentCartId();return this.request(["deleteItem",n,e.id]).then((function(t){return salla.cart.event.itemDeleted(t,e.id),t})).catch((function(t){throw salla.cart.event.itemDeletedFailed(t,e.id),t}))}async updateItem(t){let e=this.getCartPayload(t);if(!e.id){let t='There is no "id"!';return salla.cart.event.itemUpdatedFailed(t),salla.api.errorPromise(t)}let n=await this.getCurrentCartId();return"Object"===e.payload.constructor?.name?e.payload._method="PUT":e.payload.append("_method","PUT"),this.request(["updateItem",n,e.id],e.payload).then((function(t){return salla.cart.event.itemUpdated(t,e.id),t})).catch((function(t){throw salla.cart.event.itemUpdatedFailed(t,e.id),t}))}async deleteImage(t){if(!(t=salla.form.getPossibleValue(t,["id","image_id","photo_id"]))){let t='There is no "id"!';return salla.cart.event.imageNotDeleted(t),salla.api.errorPromise(t)}let e=await this.getCurrentCartId();return this.request(["deleteImage",e,t]).then((function(e){return salla.cart.event.imageDeleted(e,t),e})).catch((function(e){throw salla.cart.event.imageNotDeleted(e,t),e}))}async status(t){const e=(new Date).getTime(),n=Math.random().toString(36).substring(2,15);return this.request(["status",t||await this.getCurrentCartId()],{params:{has_apple_pay:salla.helpers.hasApplePay(),"s-hash":`${n}_${e}`}})}async submit(){if(salla.config.isGuest())return salla.log("it looks that the current user is not logged-in, lets login then submit"),salla.cart.loginOnCartPage();this.status(await this.getCurrentCartId()).then((t=>{let e=t.data.next_step?.to;if(e||(window.history.pushState({},"",salla.url.addParamToUrl("reload","empty_next_step")),window.history.pushState({},"",salla.url.addParamToUrl("acitve",!1===t.data.active?"false":"true_or_undfined")),salla.cart.reset(),window.location.reload()),!["checkout","refresh","login"].includes(e)){let t="Can't find next_step );";throw salla.cart.reset(),salla.cart.event.submitFailed(t),t}return salla.cart.event.submitted(t),"login"===e?salla.cart.loginOnCartPage():"checkout"===e?window.location.href=t.data.next_step.url+(salla.helpers.hasApplePay()?"?has_apple_pay=true":""):(window.history.pushState({},"",salla.url.addParamToUrl("reload","refresh")),void window.location.reload())})).catch((function(t){salla.cart.api.tries=salla.cart.api.tries||0,salla.cart.reset();let e=404===t?.response?.data?.status;if(e&&0===salla.cart.api.tries)return salla.cart.api.tries++,salla.log("we recived that the current cart is not found, we will try to re-submit one more time"),salla.cart.submit();throw e&&salla.error(salla.lang.get("pages.checkout.try_again")),salla.cart.event.submitFailed(t),t}))}getCartPayload(t){let e=t?.data||("object"==typeof t?t:void 0);return t=e?salla.form.getPossibleValue(e,["prod_id","product_id","item_id","id"]):t,e="object"==typeof e?e:void 0,{id:t,payload:e}}normalRequest(t,e=void 0,n=null){return super.normalRequest(t,e,n).catch((async t=>{throw 403===t?.response?.status&&(this.reset(),salla.error(salla.lang.get("pages.checkout.try_again"))),t}))}reset(){salla.api.cart.latestCart=null,salla.storage.remove("cart"),salla.cart.event.successReset()}async addCoupon(t){if(t=t.data||t,!(t=salla.form.getPossibleValue(t,["coupon"]))){let t=new Error('There is no "Coupon Code"!');return t.name="EmptyCoupon",salla.event.cart.couponAdditionFailed(t),salla.api.errorPromise(t)}let e=await salla.cart.api.getCurrentCartId();return this.request(["addCoupon",e],{coupon:t}).then((function(t){return salla.event.cart.couponAdded(t,e),t})).catch((function(t){throw salla.event.cart.couponAdditionFailed(t,e),t}))}async deleteCoupon(){let t=await salla.cart.api.getCurrentCartId();return this.request(["deleteCoupon",t],{}).then((function(e){return salla.event.cart.couponDeleted(e,t),e})).catch((function(e){throw salla.event.cart.couponDeletionFailed(e,t),e}))}getQuickOrderSettings(){return this.request("getQuickOrderSettings").then((t=>(salla.event.cart.quickOrderSettingFetched(t),t))).catch((t=>{throw salla.event.cart.quickOrderSettingFailed(t),t}))}createQuickOrder(t){return this.request("createQuickOrder",t).then((t=>(salla.event.cart.quickOrderSucceeded(t),t))).catch((t=>{throw salla.event.cart.quickOrderFailed(t),t}))}async priceQuote(t){return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("cart::priceQuote",t),void salla.event.dispatch("login::open")):this.request(["priceQuote",t||await this.getCurrentCartId()]).then((t=>(salla.cart.api.reset(),salla.event.cart.priceQuoteSucceeded(t).then((()=>(setTimeout((()=>window.location.href=salla.url.get("/")),1e3),t)))))).catch((t=>salla.event.cart.priceQuoteFailed(t).then((()=>{throw 404===t.error?.code&&window.location.reload(),t}))))}loginOnCartPage(){salla.auth.setCanRedirect(!1),salla.event.dispatch("login::open"),salla.auth.event.onLoggedIn((t=>{salla.event.dispatch("login::close"),salla.cart.submit()}))}}class ka extends Oa{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((t=>(salla.loyalty.event.programFetched(t),t))).catch((t=>{throw salla.loyalty.event.programNotFetched(t),t}))}async exchange(t,e=null){if(!(t=salla.form.getPossibleValue(t,["id","loyalty_prize_id","prize_id"]))){let t="Unable to find cart id. Please provide one.";return salla.loyalty.event.exchangeFailed(t),salla.api.errorPromise(t)}if(!(e=e||await salla.cart.getCurrentCartId())){let t="Unable to find cart id. Please provide one.";return salla.loyalty.event.exchangeFailed(t),salla.api.errorPromise(t)}return this.request("exchange",{loyalty_prize_id:t,cart_id:e}).then((function(e){return salla.loyalty.event.exchangeSucceeded(e,t),e})).catch((function(e){throw salla.loyalty.event.exchangeFailed(e,t),e}))}async reset(t=null){if(!(t=t||await salla.cart.getCurrentCartId())){let t="Unable to find cart id. Please provide one.";return salla.loyalty.event.resetFailed(t),salla.api.errorPromise(t)}return this.request("reset",{cart_id:t}).then((t=>(salla.loyalty.event.resetSucceeded(t),t))).catch((t=>{throw salla.loyalty.event.resetFailed(t),t}))}}class Aa extends Oa{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(t,e){salla.api.auth.afterLoginEvent={event:t,payload:e}}setCanRedirect(t){salla.api.auth.canRedirect_=t}canRedirect(){return salla.api.auth.canRedirect_&&!salla.api.auth.afterLoginEvent.event}login(t){t?.data&&(t=t.data);let e=salla.form.getPossibleValue(t,["type"]);if(!["email","mobile"].includes(e)){let t="Login type should be in: [email, mobile]";return salla.auth.event.codeNotSent(t),salla.api.errorPromise(t)}return this.request(["login",e],t).then((function(t){return salla.auth.event.codeSent(t,e),t})).catch((function(t){throw salla.auth.event.codeNotSent(t,e),t}))}async verify(t,e=!0){let n=salla.form.getPossibleValue(t,["type"]);if(!n){let t="Failed to know what's login type!";return salla.auth.event.verificationFailed(t),salla.api.errorPromise(t)}e=!1!==salla.form.getPossibleValue(t,["supportWebAuth"])&&e,salla.auth.event.next_event&&(t.next_event=salla.auth.event.next_event);let i=await salla.auth.api.request(["verify",n],t);return 200!==i?.status?(salla.auth.event.verificationFailed(i,n),salla.api.errorPromise(i)):salla.auth.api.handlAfterAuthenticatedResponse("authenticated"===i.data?.case,e)}async handlAfterAuthenticatedResponse(t,e){let n="authenticated"===t.data?.case;return n&&salla.auth.event.tokenFetched(t.data.token),e&&await salla.auth.api.request("auth/jwt"),n&&salla.auth.event.loggedIn(t).then((()=>salla.auth.api.afterUserLogin())),await salla.auth.event.verified(t,type),salla.api.successPromise(t)}resend(t){let e;return(t=t.data||t).type=t.type||"mobile","mobile"!==t.type||t.phone&&t.country_code?"email"!==t.type||t.email?this.request("resend",t).then((function(e){return salla.auth.event.codeSent(e,t),e})).catch((function(e){throw salla.auth.event.codeNotSent(e,t),e})):(salla.auth.event.codeNotSent(e="There is no email!",t),salla.api.errorPromise(e)):(salla.auth.event.codeNotSent(e="There is no phone or country_code!",t),salla.api.errorPromise(e))}register(t){let e;return t.data&&(e=t.element,t=t.data),salla.auth.event.next_event&&(t.next_event=salla.auth.event.next_event),this.request("register",t).then((async function(t){return salla.auth.event.registered.call(e,t),"authenticated"===t.data?.case&&(salla.auth.event.tokenFetched(t.data.token),await salla.auth.request("auth/jwt"),salla.auth.event.loggedIn(t),salla.auth.api.afterUserLogin()),t})).catch((function(t){throw salla.auth.event.registrationFailed.call(e,t),t}))}logout(t="twilight"){return salla.storage.clearAll(),salla.cookie.clearAll(),t=encodeURI(t),salla.auth.event.loggedOut().then((()=>{let e=salla.url.get(`logout?from=${t}`);console.log(`Going to ${e}, to do any thing before this action use: salla.auth.even.onLoggedOut(()=>{...})`);try{location.href=e}catch(t){salla.log(t)}}))}refresh(){return this.request("refresh").then((function(t){return salla.auth.event.tokenFetched(t.data.token),t})).catch((function(t){throw salla.auth.event.refreshFailed(t),t}))}afterUserLogin(){this.afterLoginEvent.event&&salla.event.emit(this.afterLoginEvent.event,this.afterLoginEvent.payload)}}class Ia extends Oa{constructor(){super(),this.namespace="order",this.endpoints={cancel:"orders/cancel/{id}",createCartFromOrder:"reorder/{id}",sendInvoice:"orders/send/{id}",fetch:"orders"},this.endpointsMethods={createCartFromOrder:"get",fetch:"get"},this.after_init()}show(t){let e=salla.form.getPossibleValue(t?.data||t,["id","order_id"]);salla.event.dispatch("mobile::order.placed",{order_id:e}),location.href=salla.form.getPossibleValue(t?.data||t,["url"])}cancel(t){return t=t||Salla.config.get("page.id"),this.request(["cancel",t],{params:{has_apple_pay:salla.helpers.hasApplePay()}}).then((function(e){return salla.event.order.canceled(e,t),e})).catch((function(e){throw salla.event.order.notCanceled(e,t),e}))}createCartFromOrder(t){return t=t||salla.config.get("page.id"),this.request(["createCartFromOrder",t]).then((function(e){return salla.cart.reset(),salla.event.order.orderCreated(e,t),window.location.href=e.data.url,e})).catch((function(e){throw salla.event.order.orderCreationFailed(e,t),e}))}sendInvoice(t){let e=salla.form.getPossibleValue(t,["id"])||salla.config.get("page.id");if(!e||isNaN(e)){let t="There is no id!";return salla.order.event.invoiceNotSent(t),salla.api.errorPromise(t)}return this.request(["sendInvoice",e],t).then((t=>(salla.event.order.invoiceSent(t,e),t))).catch((t=>{throw salla.event.order.invoiceNotSent(t,e),t}))}fetch(t){return this.request(["fetch"],{params:t}).then((function(t){return salla.event.order.ordersFetched(t),t})).catch((function(t){throw salla.event.order.ordersNotFetched(t),t}))}}class Ta extends Oa{constructor(){super(),this.namespace="product",this.previousQuery="",this.endpoints={getPrice:"products/{id}/price",availabilitySubscribe:"products/{id}/availability-notify",search:"products/search",details:"products/{product_id}/details",categories:"products/categories/{?id}",offers:"products/{product_id}/specialoffer",getSizeGuides:"products/{prod_id}/size-guides",giftDetail:"products/{product_id}/buy-as-gift",giftToCart:"products/{product_id}/buy-as-gift",giftImage:"products/buy-as-gift/image",buyNow:"products/{product_id}/buy-now",fetch:"products"},this.endpointsMethods={details:"get",giftDetail:"get",fetch:"get",offers:"get"},this.after_init()}getPrice(t){let e=t.data||t,n=salla.form.getPossibleValue(e,["id","prod_id","product_id"]);return this.request(["getPrice",n],"object"==typeof e?e:void 0).then((function(t){return salla.product.event.priceUpdated(t,n),t})).catch((function(t){throw salla.product.event.priceUpdateFailed(t,n),t}))}categories(t){return this.request(["categories",t||""],null,"get").then((function(t){return salla.product.event.categoriesFetched(t),t})).catch((function(t){throw salla.product.event.categoriesFailed(t),t}))}availabilitySubscribe(t){let e=t.data||t;return t=salla.form.getPossibleValue(e,["id","prod_id"]),this.request(["availabilitySubscribe",t],"object"==typeof e?e:void 0).then((function(e){return salla.product.event.availabilitySubscribed(e,t),e})).catch((function(e){throw salla.product.event.availabilitySubscribeFailed(e,t),e}))}search(t){let e=t.data;if(e||(e={params:"string"==typeof t?{query:t}:t}),!(t=e instanceof FormData?e.get("query"):e.query||e.params?.query)){let t='There is no "query"!';return salla.product.event.searchFailed(t),salla.api.errorPromise(t)}if(t===salla.api.product.previousQuery){let t="Query is same as previous one!";return salla.product.event.searchFailed(t),salla.api.product.previousQuery=null,salla.api.errorPromise(t)}return salla.api.product.previousQuery=t,this.request("search",e,"get").then((function(e){return salla.product.event.searchResults(e,t),e})).catch((function(e){throw salla.product.event.searchFailed(e,t),e}))}offers(t){if(!(t=salla.form.getPossibleValue(t?.data|t,["product_id","id"]))){let t='There is no "product_id"!';return salla.product.event.fetchOffersFailed(t),salla.api.errorPromise(t)}return this.request(["offers",t]).then((function(e){return salla.product.event.offersFetched(e,t),e})).catch((function(e){throw salla.product.event.fetchOffersFailed(e,t),e}))}getSizeGuides(t){return this.request(`products/${t}/size-guides`,null,"get").then((e=>(salla.product.event.sizeGuideFetched(e,t),e))).catch((e=>{throw salla.product.event.sizeGuideFetchFailed(e,t),e}))}getGiftDetails(t){return this.request(["giftDetail",t]).then((e=>(salla.product.event.giftFetched(e,t),e))).catch((e=>{throw salla.product.event.giftFetchFailed(e,t),e}))}getDetails(t,e=[]){if(!Array.isArray(e)){let t="withItems should be array.";return salla.product.event.detailFetchFailed(t),salla.api.errorPromise(t)}if(!t){let t="productId is not passed.";return salla.product.event.detailFetchFailed(t),salla.api.errorPromise(t)}return this.request(["details",t],{params:{with:e}}).then((function(e){return salla.product.event.detailFetched(e,t),e})).catch((function(e){throw salla.product.event.availabilitySubscribeFailed(e,t),e}))}addGiftToCart(t,e,n=!1){return this.request(["giftToCart",t],e).then((e=>(salla.product.event.addGiftToCartSucceeded(e,t),n&&(window.location.href=e.redirect),e))).catch((e=>{throw salla.product.event.addGiftToCartFailed(e,t),e}))}uploadGiftImage(t){return this.request("giftImage",t).then((t=>(salla.product.event.giftImageUploadSucceeded(t),t))).catch((t=>{throw salla.product.event.giftImageUploadFailed(t),t}))}fetch(t){if(!t.source){const t="Source cannot be empty. Please provide one.";return salla.product.event.productListFetchFailed(t),salla.api.errorPromise(t)}const e=!t.source_value,n="string"==typeof t.source_value&&"[]"===t.source_value,i=Array.isArray(t.source_value)&&!t.source_value.length;if((e||n||i)&&!["offers","latest","sales"].includes(t.source)){const t="Source value cannot be empty. Please provide one.";return salla.product.event.productListFetchFailed(t),salla.api.errorPromise(t)}if(["categories","brands","tags","selected"].includes(t.source)&&!Array.isArray(t.source_value)){const t="SourceValue type error. Expected an array.";return salla.product.event.productListFetchFailed(t),salla.api.errorPromise(t)}if("search"===t.source&&"string"!=typeof t.source_value){const t="SourceValue type error. Expected a string.";return salla.product.event.productListFetchFailed(t),salla.api.errorPromise(t)}if("related"===t.source&&isNaN(t.source_value)){const t="SourceValue type error. Expected a number.";return salla.product.event.productListFetchFailed(t),salla.api.errorPromise(t)}return this.request(this.endpoints.fetch,{params:t},"get").then((t=>(salla.product.event.productListFetchSucceeded(t),t))).catch((t=>{throw salla.product.event.productListFetchFailed(t),t}))}}class Ra extends Oa{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((t=>{let e={id:t.data.id,type:"user",email:t.data.email,mobile:t.data.phone.code+t.data.phone.number,country_code:t.data.phone.country,language_code:t.data.language,currency_code:t.data.currency,notifications:t.data.notifications,pending_orders:t.data.pending_orders,avatar:t.data.avatar,first_name:t.data.first_name,last_name:t.data.last_name,fetched_at:Date.now()};return salla.config.set("user",e),salla.storage.set("user",e),salla.profile.event.infoFetched(t),t})).catch((t=>{throw salla.profile.event.infoNotFetched(t),t}))}update(t){return this.request("update",t).then((t=>(salla.profile.event.updated(t),t))).catch((t=>{throw salla.event.profile.updateFailed(t),t}))}updateContacts(t){return this.request("updateContacts",t).then((t=>(salla.profile.event.verificationCodeSent(t),t))).catch((t=>{throw salla.event.profile.updateContactsFailed(t),t}))}verify(t){return this.request("verify",t).then((t=>(salla.profile.event.verified(t),t))).catch((t=>{throw salla.event.profile.unverified(t),t}))}updateSettings(t){return this.request("updateSettings",t).then((t=>(salla.event.profile.settingsUpdated(t),t))).catch((t=>{throw salla.event.profile.updateSettingsFailed(t),t}))}delete(){return this.request("delete").then((t=>(salla.storage.clearAll(),salla.cookie.clearAll(),salla.event.profile.deleted(t),window.location.href=salla.url.get("logout"),t))).catch((t=>{throw salla.event.profile.notDeleted(t),t}))}}class Pa extends Oa{constructor(){super(),this.namespace="comment",this.endpoints={addComment:"{type}/{id}/comments",comments:"/comments"},this.after_init()}add(t){if(t?.data&&(t=t.data),"string"==typeof(t=this.getCommentPayload(t,!0)))return salla.event.comment.additionFailed(t),salla.api.errorPromise(t);if(!t.comment){let t="can't find comment content!";return salla.event.comment.additionFailed(t),salla.api.errorPromise(t)}return this.request(["addComment",t.type,t.id],{comment:t.comment}).then((function(e){return salla.event.comment.added(e,t.id),e})).catch((function(e){throw salla.event.comment.additionFailed(e,t.id),e}))}getCommentPayload(t,e=!1){let n={};if(["id","type","comment","per_page","page"].forEach((e=>{let i=salla.form.getPossibleValue(t,[e]);i&&(n[e]=i)})),!e){let e=t.ids;if(e&&(n.ids=Array.isArray(e)?e:[e]),!n.ids||!n.ids.length)return"Failed to get ids!"}return n.type&&["products","pages","product","page"].includes(n.type)?(n.type+=["product","page"].includes(n.type)?"s":"",n):"Failed to get type one of:(products, product, page, pages)!"}fetchComments(t){if("string"==typeof(t=this.getCommentPayload(t)))return salla.event.comment.fetchFailed(t),salla.api.errorPromise(t);const e={per_page:t.per_page||5,page:t.page||1,type:t.type,ids:t.ids};return this.request(["comments"],{params:e},"get").then((function(e){return salla.event.comment.fetched(e,t),e})).catch((function(e){throw salla.event.comment.fetchFailed(e,t),e}))}getPageComments(t,e=1,n=5){return this.fetchComments({ids:[t],type:"pages",page:e,per_page:n})}getProductComments(t,e=1,n=5){return this.fetchComments({ids:[t],type:"products",page:e,per_page:n})}}class Ca extends Oa{constructor(){super(),this.namespace="currency",this.endpoints={change:"/",list:"currencies"},this.endpointsMethods={change:"get",list:"get"},this.webEndpoints=["change"],this.after_init()}change(t){if(!(t=salla.form.getPossibleValue(t.data||t,["currency","code"]))){let t="Can't find currency code!";return salla.currency.event.failed(t),salla.api.errorPromise(t)}return this.request("change",{params:{change_currency:"",currency:t}}).then((function(e){return salla.cookie.set("fresh_summary",1),salla.storage.set("cart",""),salla.currency.event.changed(e,t),e})).catch((function(e){throw salla.currency.event.failed(e,t),e}))}list(){return this.request("list").then((function(t){return salla.currency.event.fetched(t),t})).catch((function(t){throw salla.currency.event.failedToFetch(t),t}))}}class Da extends Oa{constructor(){super(),this.namespace="document"}}class La extends Oa{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(t){let e="object"==typeof t?t:{},n=salla.form.getPossibleValue(t?.data||t,["order_id","id"]);if(!n){let t='There is no "order_id"!';return salla.event.rating.orderNotFetched(t),salla.api.errorPromise(t)}return this.request(["order",n],e).then((function(t){return salla.event.rating.orderFetched(t,n),t})).catch((function(t){throw salla.event.rating.orderNotFetched(t,n),t}))}store(t){if(!(t=t?.data||t)){let t='There is no "data"!';return salla.event.rating.storeFailed(t),salla.api.errorPromise(t)}return this.request("store",t).then((function(e){return salla.event.rating.storeRated(e,t),e})).catch((function(e){throw salla.event.rating.storeFailed(e,t),e}))}products(t){if(!(t=t?.data||t)){let t='There is no "data"!';return salla.event.rating.productsFailed(t),salla.api.errorPromise(t)}return this.request("products",t).then((function(e){return salla.event.rating.productsRated(e,t),e})).catch((function(e){throw salla.event.rating.productsFailed(e,t),e}))}shipping(t){if(!(t=t?.data||t)){let t='There is no "data"!';return salla.event.rating.shippingFailed(t),salla.api.errorPromise(t)}return this.request("shipping",t).then((function(e){return salla.event.rating.shippingRated(e,t),e})).catch((function(e){throw salla.event.rating.shippingFailed(e,t),e}))}}class $a extends Oa{constructor(){super(),this.namespace="wishlist",this.endpoints={add:"products/favorites/{id}",remove:"products/favorites/{id}"},this.endpointsMethods={remove:"delete"},this.after_init()}toggle(t){return salla.storage.get("salla::wishlist",[]).includes(t)?this.remove(t):this.add(t)}add(t){let e;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(e=salla.lang.get("common.messages.must_login")),salla.error(e),salla.api.errorPromise(e)):(t=salla.form.getPossibleValue(t?.data||t,["product_id","id"]))?this.request(["add",t]).then((e=>(this.updateWishlistStorage(t),salla.wishlist.event.added(e,t),e))).catch((function(e){throw salla.wishlist.event.additionFailed(e,t),e})):(salla.wishlist.event.additionFailed(e="Failed to get product id!"),salla.api.errorPromise(e))}remove(t){let e;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(e=salla.lang.get("common.messages.must_login")),salla.error(e),salla.api.errorPromise(e)):(t=salla.form.getPossibleValue(t?.data||t,["product_id","id"]))?this.request(["remove",t]).then((e=>(this.updateWishlistStorage(t,!1),salla.wishlist.event.removed(e,t),e))).catch((function(e){throw salla.wishlist.event.removingFailed(e,t),e})):(salla.wishlist.event.removingFailed(e="Failed to get id!"),salla.api.errorPromise(e))}updateWishlistStorage(t,e=!0){let n=salla.storage.get("salla::wishlist",[]);e?n.push(t):n.splice(n.indexOf(t),1),salla.storage.set("salla::wishlist",n)}}class Na extends Oa{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((t=>(salla.scope.event.fetched(t),t))).catch((t=>{throw salla.scope.event.notFetched(t),t}))}change(t){return this.request("scopes",t).then((t=>(salla.scope.event.changeSucceeded(t),t))).catch((t=>{throw salla.scope.event.changeFailed(t),t}))}getProductAvailability(t=null){return this.request(`scopes/availability?product_id=${t}`,null,"get").then((e=>(salla.scope.event.productAvailabilityFetched(e,t),e))).catch((t=>{throw salla.scope.event.productAvailabilityNotFetched(t),t}))}}class qa extends Oa{constructor(){super(),this.namespace="booking",this.endpoints={add:"cart/booking/product/{id}"},this.endpointsMethods={add:"get"}}async add(t,e=!0){if(!t){let t="Please provide product id.";return salla.booking.event.additionFailed(t),salla.api.errorPromise(t)}return this.request(["add",t]).then((function(t){return salla.booking.event.added(t),e&&"booking"===t.data.redirect.to&&(window.location.href=t.data.redirect.url),t})).catch((function(t){throw salla.booking.event.additionFailed(t),t}))}}class Ua extends Oa{constructor(){super(),this.namespace="landing",this.endpoints={getDetails:"landing/{landing_page_id}",createCartFromPage:"landing/{landing_page_id}",breadcrumbs:"breadcrumbs"},this.endpointsMethods={getDetails:"get",breadcrumbs:"get"},this.after_init()}getDetails(t){if(!t){let t="page landing id not passed";return salla.event.landing.getDetailsFailed(t),salla.api.errorPromise(t)}return this.request(["getDetails",t]).then((function(e){return salla.event.landing.detailsFetched(e,t),e})).catch((function(e){throw salla.event.landing.getDetailsFailed(e,t),e}))}createCartFromPage(t){if(!t){let t="page landing id not passed";return salla.event.landing.orderCreationFailed(t),salla.api.errorPromise(t)}return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("landing::createCartFromPage",t),salla.event.dispatch("login::open"),salla.api.successPromise("")):this.request(["createCartFromPage",t]).then((function(e){return salla.event.landing.orderCreated(e,t).then((()=>location.href=e.data.url)),e})).catch((function(e){throw salla.event.landing.orderCreationFailed(e,t),e}))}fetchBreadcrumbs(t){if(!t.page){let t="The 'page' parameter is required for the Breadcrumb API. Please provide a valid 'page' parameter.";return salla.event.landing.breadcrumbFetchFailed(t),salla.api.errorPromise(t)}if("product.single"===t.page&&!t.id&&!t.parent_id){let t="The 'id' and 'parent_id' parameters are required when the 'page' parameter is set to 'product.single'. Please provide valid values for both parameters.";return salla.event.landing.breadcrumbFetchFailed(t),salla.api.errorPromise(t)}if(["product.index","customer.orders.single","product.index.tag","page-single","landing-page","brands.single","blog.single","blog.index.author","blog.index.category","blog.index.tag"].includes(t.page)&&!t.id){let e=`The 'id' parameter is required when the 'page' parameter is set to ${t.page}. Please provide valid value for the 'ID' parameter.`;return salla.event.landing.breadcrumbFetchFailed(e),salla.api.errorPromise(e)}return this.request("breadcrumbs",{params:t}).then((function(t){return salla.event.landing.breadcrumbFetched(t),t})).catch((function(t){throw salla.event.landing.breadcrumbFetchFailed(t),t}))}}class Ma extends Oa{constructor(){super(),this.namespace="notifications",this.endpoints={fetch:"notifications"},this.endpointsMethods={fetch:"get"},this.after_init()}fetch(t){return this.request(["fetch"],{params:t}).then((function(t){return salla.event.notifications.fetched(t),t})).catch((function(t){throw salla.event.notifications.fetchFailed(t),t}))}}class za{constructor(){salla.event.on("twilight::before.ready",(t=>this.initiateRequest(t))),salla.event.on("profile::info.fetched",(t=>this.setCurrencyAndLanguage(t))),salla.event.on("auth::token.fetched",(t=>{salla.storage.set("token",t),this.setToken(t)})),salla.event.on("auth::token.invalid",(()=>{salla.storage.remove("user"),salla.storage.remove("token")})),this.notifier_handler_disabled=!1,this.axios=da.create({headers:{common:{"X-Requested-With":"XMLHttpRequest","S-SOURCE":"twilight","S-APP-VERSION":"v2.0.0","S-APP-OS":"browser","cache-control":"no-cache"}}})}getHeaders(){return this.axios.defaults.headers.common}setHeaders(t){return Object.entries(t).forEach((t=>this.setHeader(t[0],t[1]))),this}setHeader(t,e){return salla.infiniteScroll.fetchOptions.headers[t]=this.axios.defaults.headers.common[t]=e,this}async withoutNotifier(t){return this.notifier_handler_disabled=!0,await t().finally((()=>{this.notifier_handler_disabled=!1}))}async initiateRequest(t){this.axios.defaults.baseURL=Salla.config.get("store.api",Salla.config.get("store.url")),this.setHeaders({"Store-Identifier":Salla.config.get("store.id"),currency:t.user?.currency_code||"SAR","accept-language":salla.lang.getLocale(),"s-user-id":t.user?.id,...t.headers||{}});let e=salla.storage.get("scope");e&&this.setHeaders({"s-scope-type":e.type,"s-scope-id":e.id}),await this.injectTokenToTheRequests(t),salla.storage.get("affiliate_code")&&this.setHeader("s-affiliate-code",salla.storage.get("affiliate_code"))}async injectTokenToTheRequests(t){let e=salla.storage.get("token"),n="guest"===t.user.type,i=t.user?.id,r=salla.storage.get("user.id"),a=t=>{this.setToken(t),salla.event.emit("api::initiated")},s=async()=>{!n&&i?(salla.log("Api:: case 1 => current is is guest & web session available"),await salla.auth.api.refresh().then((async()=>{await salla.profile.info()})).catch((()=>salla.auth.event.tokenInvalid()))):salla.auth.event.tokenInvalid()};if(!e)return salla.log("Api:: case 1 => current is is guest"),void await s();let o=wa(e);return Date.now()/1e3>o.exp?(salla.log("Api:: case 2 => current user is logged-in and there is a token, but it's expired"),void await s()):o.sub===i&&r===i&&r&&i?(salla.log("Api:: case 4 => current user is logged-in and there is a token, and it's not expired"),void a(e)):(salla.log("Api:: case 3 => there is a token and user in session/local missing or mismatch"),salla.log(`sub:${o.sub} userIdInWeb:${i} userIdInStorage:${r}`),this.setHeader("Authorization","Bearer "+e),void await salla.profile.info().then((async t=>{await salla.auth.api.request("auth/jwt"),a(e)})).catch((()=>{salla.log("Api:: case 3 => failed get fresh profile"),this.setHeader("Authorization",null),salla.auth.event.tokenInvalid()})))}setToken(t){return this.setHeader("Authorization","Bearer "+t),salla.event.emit("api::token.injected",t),this.token=t,this}setCurrencyAndLanguage(t){return this.setHeaders({currency:t.data.currency,"accept-language":t.data.language})}request(t,e=void 0,n="get",i={}){let r={endPoint:t,payload:e,method:n,options:i},a="undefined"!=typeof event?event.currentTarget:null,s=!1;return"SALLA-BUTTON"===a?.tagName&&(s=!0),s&&a?.load(),this.axios[r.method](r.endPoint,r.payload,r.options).then((t=>(s&&a?.stop(),t.data&&t.request&&(t=t.data),this.handleAfterResponseActions(t),t))).catch((t=>{throw s&&a?.stop(),salla.event.document.requestFailed(r,t),this.handleErrorResponse(t),t}))}handleAfterResponseActions(t){if(!t)return;let{data:e,googleTags:n=null}=t,i=e&&e.googleTags?e.googleTags:n;try{dataLayer&&i&&dataLayer.push(i)}catch(t){salla.logger.error(t.message)}this.fireEventsForResponse(t),this.showAlert(t)}fireEventsForResponse(t){let e=t?.events||t.data?.events||t.error?.events;"string"==typeof e&&(e=JSON.parse(e)),e&&Object.keys(e).forEach((t=>salla.event.dispatch(t,e[t])))}handleErrorResponse(t){if(t.response&&t.response.data)return t.response.data.error&&t.response.data.error.fields&&!this.notifier_handler_disabled?this.handleInvalidFields(t):this.handleAfterResponseActions(t.response.data)}showAlert(t){if(t&&!this.notifier_handler_disabled)return t.case&&t.msg?salla.notify.fire(t.msg,t.case,t):t.hasOwnProperty("success")&&t.data?.message?salla.notify.fire(t.data?.message,t.success?salla.notify.types.success:salla.notify.types.error,t):t.error&&t.error.message&&"FORBIDDEN"!==t.error.message?salla.error(t.error.message,t):void 0}handleInvalidFields(t){let e=t.response.data.error.fields,n=[];Object.keys(e).forEach((t=>{let i=e[t];Array.isArray(i)?i.forEach((t=>n.push(t))):n.push(i)}));let i=(n.length>1?"* ":"")+n.join("\n* ");salla.error(i,t)}isFastRequestsAllowed(){return Salla.config.get("fastRequests")}promise(t,e=!0){return new Promise(((n,i)=>e?n(t):i(t)))}errorPromise(t){return this.promise(t,!1)}successPromise(t){return this.promise(t,!0)}}class Ba extends Oa{constructor(){super(),this.namespace="component",this.endpoints={getMenus:"menus/{headOrFoot}",reviews:"reviews"},this.endpointsMethods={getMenus:"get",reviews:"get"}}async getMenus(t="header"){return this.request(["getMenus",t]).then((function(t){return salla.event.component.menuFetched(t),t})).catch((function(t){throw salla.event.component.menuFetchFailed(t),t}))}async getReviews({per_page:t=5,type:e="all",items:n}){if(!e){const t="Review type cannot be empty. Please provide one.";return salla.event.component.reviewsFetchFailed(t),salla.api.errorPromise(t)}const i=!n||"string"==typeof n&&"[]"===n||Array.isArray(n)&&!n.length;if(!new Set(["all","store","categories","products","json"]).has(e)){const t="Invalid review type. Please provide a valid type.";return salla.event.component.reviewsFetchFailed(t),salla.api.errorPromise(t)}if("all"!==e&&"store"!==e&&i){const t="Items cannot be empty. Please provide one.";return salla.event.component.reviewsFetchFailed(t),salla.api.errorPromise(t)}if(new Set(["products","categories"]).has(e)&&!Array.isArray(n)){const t=`Items value must be an array of ${e} id for review type of ${e}.`;return salla.event.component.reviewsFetchFailed(t),salla.api.errorPromise(t)}return this.request(["reviews"],{params:{per_page:t,type:e,items:n}},"get").then((function(t){return salla.event.component.reviewsFetched(t),t})).catch((function(t){throw salla.event.component.reviewsFetchFailed(t),t}))}}class Ja extends Oa{constructor(){super(),this.namespace="booking",this.endpoints={fetch:"advertisements"},this.endpointsMethods={fetch:"get"}}async fetch(t=null){const e=t?{page:t}:{};return this.request(["fetch"],{params:e}).then((function(t){return salla.event.advertisement.fetched(t),t})).catch((function(t){throw salla.event.advertisement.fetchFailed(t),t}))}}class Ga extends Oa{constructor(){super(),this.namespace="navigation",this.endpoints={breadcrumbs:"breadcrumbs"},this.endpointsMethods={breadcrumbs:"get"},this.after_init()}fetchBreadcrumbs(t){if(!t.page){let t="The 'page' parameter is required for the Breadcrumb API. Please provide a valid 'page' parameter.";return salla.event.navigation.breadcrumbFetchFailed(t),salla.api.errorPromise(t)}if(["product.single","product.index","customer.orders.single","product.index.tag","page-single","landing-page","brands.single","blog.single","blog.index.author","blog.index.category","blog.index.tag"].includes(t.page)&&!t.id){let e=`The 'id' parameter is required when the 'page' parameter is set to ${t.page}. Please provide valid value for the 'ID' parameter.`;return salla.event.navigation.breadcrumbFetchFailed(e),salla.api.errorPromise(e)}return this.request("breadcrumbs",{params:t}).then((function(t){return salla.event.navigation.breadcrumbFetched(t),t})).catch((function(t){throw salla.event.navigation.breadcrumbFetchFailed(t),t}))}}class Ha{constructor(t){"ready"!==ji.status?t?(ji.config.merge(t),t?.events&&ji.event.dispatchEvents(t?.events),t._token&&salla.api.setHeader("X-CSRF-TOKEN",t._token),this.injectMaintenanceAlert(),this.injectTemplateStoreAlert(),this.injectThemePreviewAlert(),this.injectAppInstallAlert(),this.injectEditAlert(),t?.user?.language_code&&salla.lang.setLocale(t?.user?.language_code),salla.lang.loadStoreTranslations(),this.setSallaReady(t)):this.setSallaReady(t):salla.log("Trying to re-initiate Salla, while its status === 'ready'!")}injectMaintenanceAlert(){salla.config.get("maintenance")&&(document.body.classList.add("has-maintenance-bar"),document.querySelector("salla-maintenance-alert")?salla.logger.warn("salla-maintenance-alert element Existed before!"):salla.lang.onLoaded((()=>document.body.prepend(document.createElement("salla-maintenance-alert")))))}injectTemplateStoreAlert(){salla.config.get("store.template")&&(document.body.classList.add("has-bottom-alert"),document.querySelector("salla-bottom-alert")?salla.logger.warn("salla-bottom-alert element Existed before!"):salla.lang.onLoaded((()=>document.body.append(document.createElement("salla-bottom-alert")))))}injectAppInstallAlert(){salla.config.get("store.app_install_prompt")&&salla.config.get("store.apps")&&!salla.storage.get("app_install_prompt_disabled")&&(document.body.classList.add("has-app-install-alert"),document.querySelector("salla-app-install-alert")?salla.logger.warn("salla-app-install-alert element Existed before!"):salla.lang.onLoaded((()=>document.body.append(document.createElement("salla-app-install-alert")))))}injectThemePreviewAlert(){"preview"===salla.config.get("theme.mode")&&(document.body.classList.add("has-preview-bar"),document.querySelector("#s-theme_preview_bar")?salla.logger.warn("#s-theme_preview_bar element Existed before!"):salla.lang.onLoaded((()=>{let t=document.createElement("div");t.id="s-theme_preview_bar",t.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;"),t.innerHTML=`\n <div style="display:flex; align-items:center;">\n <img width="32" src="https://cdn.salla.network/images/logo/logo-light.svg">\n <span style="margin:0 10px;">${salla.lang.get("blocks.header.preview_mode")}: <span style="background:rgba(255,255,255,0.25);border-radius:15px; padding:2px 15px 4px">${salla.config.get("theme.name")}</span></span>\n </div>\n <a href="${salla.url.get("preview_theme/cancel/preview")}" style="line-height:32px; width:32px;"><i class="sicon-cancel"></i></a>\n `,document.body.prepend(t)})))}injectEditAlert(){let t=salla.config.get("edit");t&&(document.querySelector("#s-edit-alert")?salla.logger.warn("#s-edit-alert element Existed before!"):salla.lang.onLoaded((()=>{let e=document.createElement("div");e.id="s-edit-alert",e.innerHTML=`\n <a href="${t}" 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(e)})))}handleElementAjaxRequest(t,e){if(!(e instanceof HTMLFormElement||e instanceof HTMLAnchorElement))return salla.logger.warn("trying to call ajax from non Element!!"),!1;t.preventDefault();let n=e.getAjaxFormData(t),i=n.method?n.method.toLowerCase():void 0;salla.api.request(n.url,n.formData,i).then((t=>(t.data&&t.request&&(t=t.data),salla.api.handleAfterResponseActions(t),this.callAjaxEvent(n.events.success,t,n.formData),t))).catch((t=>{throw salla.api.handleErrorResponse(t),this.callAjaxEvent(n.events.fail,t,n.formData),t}))}callAjaxEvent(t,e,n){if(t){if(n instanceof FormData){const t={};Array.from(n.entries()).forEach((function(e){t[e[0]]=e[1]})),n=t}window[t]?window[t](e,n):salla.event.dispatch(t,e,n)}}setSallaReady(t){ji.event.dispatch("twilight::before.ready",t),ji.status="ready",ji.event.dispatch("twilight::initiated",t),window.dispatchEvent(new CustomEvent("twilight::initiated",{detail:t}))}}ji.status="loading",ji.notify=_a,ji.lang=new class extends Ci{constructor(t){(t=t||{}).messages=t.messages||window.translations,t.locale=t.locale||(window.locale||navigator.language||navigator.userLanguage||"ar").split("-")[0],t.fallback=t.fallback||t.locale,super(t),this.translationsLoaded=!1}onLoaded(t){return new Promise((e=>{if(this.translationsLoaded)return e(t?t():null);Salla.event.once("languages::translations.loaded",(()=>e(t?t():null)))}))}loadStoreTranslations(){if(this.hash=salla.config.get("theme.translations_hash",salla.config.get("store.id","twilight")),this.message||(salla.log("try to load translations from localstorage"),this.messages=salla.storage.get(`s_translations.${this.hash}`),this.messages&&(this.translationsLoaded=!0)&&super.setMessages(this.messages)),this.messages)return salla.event.dispatch("languages::translations.loaded"),void salla.logger.info("The messages of transactions is already loaded");salla.url.get("")?this.loadScript(salla.url.get(`languages/assets/${this.hash}.js`)):this.loadScript("https://cdn.salla.network/js/translations.js",!1)}setMessages(t){super.setMessages(t),salla.event.dispatch("languages::translations.loaded"),this.translationsLoaded=!0}loadScript(t,e=!0){let n=document.createElement("script");n.src=t,n.onload=()=>{if(window.translations)return salla.storage.remove("s_translations"),salla.storage.set("s_translations",{[this.hash]:window.translations}),this.setMessages(window.translations);n.onerror()},n.onerror=()=>{if(e)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)}getWithDefault(t,e,n,i){let r=this.get(t,n,i);return r!==t?r:e}get(t,e,n){let i=t;(window.translations||this.translationsLoaded)&&(i="trans."+t);let r=super.get(i,e,n);return r!==i?r:super.get(i,e,"en").replace(i,t)}set(t,e){return salla.helpers.setNested(this.messages[this.getLocale()+".trans"],t,e),this}},ji.form=new class{async submit(t,e=null){let n=e;if("SubmitEvent"===e?.constructor?.name||"submit"===e?.type){if(e.preventDefault(),"FORM"!==e.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"===e?.submitter?.parentElement?.tagName&&e.submitter.parentElement.load(),n=e.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(t))return salla.api.request(t,n,"post").finally((()=>{loaderSupported&&e?.submitter?.parentElement.stop()}));let i=t.split("."),r=i.splice(-1);return await salla.call(i.join("."))[r](n).finally((()=>e?.submitter?.parentElement?.stop())).catch((t=>{throw salla.logger.warn(t),t}))}onSubmit(t,e){return salla.form.submit(t,e),!1}onChange(t,e){return e?.currentTarget?"FORM"!==e?.currentTarget?.tagName||e.currentTarget.checkValidity()?(salla.form.submit(t,e.currentTarget.getElementSallaData()),!0):(salla.logger.warn(`Trying to trigger '${t}' without filling required fields!`),!1):(salla.logger.warn(`Trying to trigger '${t}' without event!`),!1)}getPossibleValue(t,e,n=!1){if(!t)return;if("object"!=typeof t)return t;let i;for(let n=0;n<e.length&&!(i=t[e[n]])&&!("undefined"!=typeof FormData&&t instanceof FormData&&(i=t.get(e[n])));n++);return i=i||t,"object"!=typeof i||n?i:void 0}},ji.infiniteScroll=new class extends xa{constructor(t,e){super(t,e),this.options={path:".infinite-scroll-btn",history:"push",status:".infinite-scroll-status",append:".list-block"},this.fetchOptions={headers:{"S-INFINITE-SCROLL":!0,"S-Source":"twilight","cache-control":"no-cache",pragma:"no-cache"}},this.instances=[]}initiate(t,e,n,i=!1){i?((n=n||{}).fetchOptions={...this.fetchOptions,...n.fetchOptions||{}},n.responseBody="json"):n=this.getCustomOptions(e,n);let r="string"!=typeof t?t:document.querySelector(t),a=n.path;if(!r||!a||"string"==typeof a&&!document.querySelector(a))return void Salla.logger.warn(r?"Path Option (a link that has next page link) Not Existed!":"Container For InfiniteScroll not Existed!");let s=new Pi(r,n);return s.on("scrollThreshold",Salla.infiniteScroll.event.scrollThreshold),s.on("request",Salla.infiniteScroll.event.request),s.on("load",Salla.infiniteScroll.event.load),s.on("append",Salla.infiniteScroll.event.append),s.on("error",Salla.infiniteScroll.event.error),s.on("last",Salla.infiniteScroll.event.last),s.on("history",Salla.infiniteScroll.event.history),this.instances.push(s),s}getCustomOptions(t,e){return(e="object"==typeof t&&t||e||this.options).fetchOptions=this.fetchOptions,e.path=e.path||this.options.path,e.button=e.button||e.path,e.status=e.status||this.options.status,e.hasOwnProperty("history")||(e.history=this.options.history),e.nextPage=e.nextPage||e.next_page,e.append="string"==typeof t&&t||e.append||this.options.append,e}loadNextPage(t){("string"!=typeof t?t:document.querySelector(t)).loadNextPage()}destroy(t){("string"!=typeof t?t:document.querySelector(t)).destroy()}}(void 0,salla.event.infiniteScroll),ji.api=new class extends za{constructor(){super(),this.auth=new Aa,this.cart=new Fa,this.loyalty=new ka,this.order=new Ia,this.rating=new La,this.product=new Ta,this.profile=new Ra,this.comment=new Pa,this.currency=new Ca,this.document=new Da,this.wishlist=new $a,this.scope=new Na,this.booking=new qa,this.landing=new Ua,this.notifications=new Ma,this.component=new Ba,this.advertisement=new Ja,this.navigation=new Ga}},["cart","auth","order","scope","rating","comment","loyalty","product","profile","currency","document","wishlist","booking","landing"].forEach((t=>ji[t]=new xa(ji.api[t],ji.event[t]))),ji.call=t=>{let e=ji,n=t.split(".");for(;n.length&&(e=e[n.shift()]););return e},ji.init=t=>new Ha(t),salla.event.once("twilight::init",salla.init),salla.event.once("twilight::api",(t=>{let e=t?.events;e&&salla.event.dispatchEvents(e)})),ji.success=ji.notify.success,ji.error=ji.notify.error,ji.versions.twilight="[VI]{version}[/VI]",ji.onInitiated=t=>salla.event.once("twilight::initiated",t),ji.onReady=ji.onReady||function(t){return new Promise((function(e){return"ready"===salla.status?e(t?t(salla.config.all()):salla.config.all()):ji.onInitiated((n=>e(t?t(n):n)))}))},window.dispatchEvent(new CustomEvent("salla::created"));var Va=e((function(e,n){!function(t,n){e.exports=n()}(t,(function(){function t(){return t=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},t.apply(this,arguments)}var e="undefined"!=typeof window,n=e&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),i=e&&"IntersectionObserver"in window,r=e&&"classList"in document.createElement("p"),a=e&&window.devicePixelRatio>1,s={elements_selector:".lazy",container:n||e?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_bg_hidpi:"bg-hidpi",data_bg_multi:"bg-multi",data_bg_multi_hidpi:"bg-multi-hidpi",data_bg_set:"bg-set",data_poster:"poster",class_applied:"applied",class_loading:"loading",class_loaded:"loaded",class_error:"error",class_entered:"entered",class_exited:"exited",unobserve_completed:!0,unobserve_entered:!1,cancel_on_exit:!0,callback_enter:null,callback_exit:null,callback_applied:null,callback_loading:null,callback_loaded:null,callback_error:null,callback_finish:null,callback_cancel:null,use_native:!1,restore_on_error:!1},o=function(e){return t({},s,e)},l=function(t,e){var n,i="LazyLoad::Initialized",r=new t(e);try{n=new CustomEvent(i,{detail:{instance:r}})}catch(t){(n=document.createEvent("CustomEvent")).initCustomEvent(i,!1,!1,{instance:r})}window.dispatchEvent(n)},u="src",c="srcset",f="sizes",h="poster",d="llOriginalAttrs",p="data",v="loading",g="loaded",m="applied",w="error",y="native",b="data-",S="ll-status",_=function(t,e){return t.getAttribute(b+e)},x=function(t){return _(t,S)},j=function(t,e){return function(t,e,n){var i="data-ll-status";null!==n?t.setAttribute(i,n):t.removeAttribute(i)}(t,0,e)},E=function(t){return j(t,null)},O=function(t){return null===x(t)},F=function(t){return x(t)===y},k=[v,g,m,w],A=function(t,e,n,i){t&&(void 0===i?void 0===n?t(e):t(e,n):t(e,n,i))},I=function(t,e){r?t.classList.add(e):t.className+=(t.className?" ":"")+e},T=function(t,e){r?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\s+)"+e+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},R=function(t){return t.llTempImage},P=function(t,e){if(e){var n=e._observer;n&&n.unobserve(t)}},C=function(t,e){t&&(t.loadingCount+=e)},D=function(t,e){t&&(t.toLoadCount=e)},L=function(t){for(var e,n=[],i=0;e=t.children[i];i+=1)"SOURCE"===e.tagName&&n.push(e);return n},$=function(t,e){var n=t.parentNode;n&&"PICTURE"===n.tagName&&L(n).forEach(e)},N=function(t,e){L(t).forEach(e)},q=[u],U=[u,h],M=[u,c,f],z=[p],B=function(t){return!!t[d]},J=function(t){return t[d]},G=function(t){return delete t[d]},H=function(t,e){if(!B(t)){var n={};e.forEach((function(e){n[e]=t.getAttribute(e)})),t[d]=n}},V=function(t,e){if(B(t)){var n=J(t);e.forEach((function(e){!function(t,e,n){n?t.setAttribute(e,n):t.removeAttribute(e)}(t,e,n[e])}))}},Q=function(t,e,n){I(t,e.class_applied),j(t,m),n&&(e.unobserve_completed&&P(t,e),A(e.callback_applied,t,n))},W=function(t,e,n){I(t,e.class_loading),j(t,v),n&&(C(n,1),A(e.callback_loading,t,n))},X=function(t,e,n){n&&t.setAttribute(e,n)},Z=function(t,e){X(t,f,_(t,e.data_sizes)),X(t,c,_(t,e.data_srcset)),X(t,u,_(t,e.data_src))},K={IMG:function(t,e){$(t,(function(t){H(t,M),Z(t,e)})),H(t,M),Z(t,e)},IFRAME:function(t,e){H(t,q),X(t,u,_(t,e.data_src))},VIDEO:function(t,e){N(t,(function(t){H(t,q),X(t,u,_(t,e.data_src))})),H(t,U),X(t,h,_(t,e.data_poster)),X(t,u,_(t,e.data_src)),t.load()},OBJECT:function(t,e){H(t,z),X(t,p,_(t,e.data_src))}},Y=["IMG","IFRAME","VIDEO","OBJECT"],tt=function(t,e){!e||function(t){return t.loadingCount>0}(e)||function(t){return t.toLoadCount>0}(e)||A(t.callback_finish,e)},et=function(t,e,n){t.addEventListener(e,n),t.llEvLisnrs[e]=n},nt=function(t,e,n){t.removeEventListener(e,n)},it=function(t){return!!t.llEvLisnrs},rt=function(t){if(it(t)){var e=t.llEvLisnrs;for(var n in e){var i=e[n];nt(t,n,i)}delete t.llEvLisnrs}},at=function(t,e,n){!function(t){delete t.llTempImage}(t),C(n,-1),function(t){t&&(t.toLoadCount-=1)}(n),T(t,e.class_loading),e.unobserve_completed&&P(t,n)},st=function(t,e,n){var i=R(t)||t;it(i)||function(t,e,n){it(t)||(t.llEvLisnrs={});var i="VIDEO"===t.tagName?"loadeddata":"load";et(t,i,e),et(t,"error",n)}(i,(function(r){!function(t,e,n,i){var r=F(e);at(e,n,i),I(e,n.class_loaded),j(e,g),A(n.callback_loaded,e,i),r||tt(n,i)}(0,t,e,n),rt(i)}),(function(r){!function(t,e,n,i){var r=F(e);at(e,n,i),I(e,n.class_error),j(e,w),A(n.callback_error,e,i),n.restore_on_error&&V(e,M),r||tt(n,i)}(0,t,e,n),rt(i)}))},ot=function(t,e,n){!function(t){return Y.indexOf(t.tagName)>-1}(t)?function(t,e,n){!function(t){t.llTempImage=document.createElement("IMG")}(t),st(t,e,n),function(t){B(t)||(t[d]={backgroundImage:t.style.backgroundImage})}(t),function(t,e,n){var i=_(t,e.data_bg),r=_(t,e.data_bg_hidpi),s=a&&r?r:i;s&&(t.style.backgroundImage='url("'.concat(s,'")'),R(t).setAttribute(u,s),W(t,e,n))}(t,e,n),function(t,e,n){var i=_(t,e.data_bg_multi),r=_(t,e.data_bg_multi_hidpi),s=a&&r?r:i;s&&(t.style.backgroundImage=s,Q(t,e,n))}(t,e,n),function(t,e,n){var i=_(t,e.data_bg_set);if(i){var r=i.split("|"),a=r.map((function(t){return"image-set(".concat(t,")")}));t.style.backgroundImage=a.join(),""===t.style.backgroundImage&&(a=r.map((function(t){return"-webkit-image-set(".concat(t,")")})),t.style.backgroundImage=a.join()),Q(t,e,n)}}(t,e,n)}(t,e,n):function(t,e,n){st(t,e,n),function(t,e,n){var i=K[t.tagName];i&&(i(t,e),W(t,e,n))}(t,e,n)}(t,e,n)},lt=function(t){t.removeAttribute(u),t.removeAttribute(c),t.removeAttribute(f)},ut=function(t){$(t,(function(t){V(t,M)})),V(t,M)},ct={IMG:ut,IFRAME:function(t){V(t,q)},VIDEO:function(t){N(t,(function(t){V(t,q)})),V(t,U),t.load()},OBJECT:function(t){V(t,z)}},ft=function(t,e){(function(t){var e=ct[t.tagName];e?e(t):function(t){if(B(t)){var e=J(t);t.style.backgroundImage=e.backgroundImage}}(t)})(t),function(t,e){O(t)||F(t)||(T(t,e.class_entered),T(t,e.class_exited),T(t,e.class_applied),T(t,e.class_loading),T(t,e.class_loaded),T(t,e.class_error))}(t,e),E(t),G(t)},ht=["IMG","IFRAME","VIDEO"],dt=function(t){return t.use_native&&"loading"in HTMLImageElement.prototype},pt=function(t,e,n){t.forEach((function(t){return function(t){return t.isIntersecting||t.intersectionRatio>0}(t)?function(t,e,n,i){var r=function(t){return k.indexOf(x(t))>=0}(t);j(t,"entered"),I(t,n.class_entered),T(t,n.class_exited),function(t,e,n){e.unobserve_entered&&P(t,n)}(t,n,i),A(n.callback_enter,t,e,i),r||ot(t,n,i)}(t.target,t,e,n):function(t,e,n,i){O(t)||(I(t,n.class_exited),function(t,e,n,i){n.cancel_on_exit&&function(t){return x(t)===v}(t)&&"IMG"===t.tagName&&(rt(t),function(t){$(t,(function(t){lt(t)})),lt(t)}(t),ut(t),T(t,n.class_loading),C(i,-1),E(t),A(n.callback_cancel,t,e,i))}(t,e,n,i),A(n.callback_exit,t,e,i))}(t.target,t,e,n)}))},vt=function(t){return Array.prototype.slice.call(t)},gt=function(t){return t.container.querySelectorAll(t.elements_selector)},mt=function(t){return function(t){return x(t)===w}(t)},wt=function(t,e){return function(t){return vt(t).filter(O)}(t||gt(e))},yt=function(t,n){var r=o(t);this._settings=r,this.loadingCount=0,function(t,e){i&&!dt(t)&&(e._observer=new IntersectionObserver((function(n){pt(n,t,e)}),function(t){return{root:t.container===document?null:t.container,rootMargin:t.thresholds||t.threshold+"px"}}(t)))}(r,this),function(t,n){e&&(n._onlineHandler=function(){!function(t,e){var n;(n=gt(t),vt(n).filter(mt)).forEach((function(e){T(e,t.class_error),E(e)})),e.update()}(t,n)},window.addEventListener("online",n._onlineHandler))}(r,this),this.update(n)};return yt.prototype={update:function(t){var e,r,a=this._settings,s=wt(t,a);D(this,s.length),!n&&i?dt(a)?function(t,e,n){t.forEach((function(t){-1!==ht.indexOf(t.tagName)&&function(t,e,n){t.setAttribute("loading","lazy"),st(t,e,n),function(t,e){var n=K[t.tagName];n&&n(t,e)}(t,e),j(t,y)}(t,e,n)})),D(n,0)}(s,a,this):(r=s,function(t){t.disconnect()}(e=this._observer),function(t,e){e.forEach((function(e){t.observe(e)}))}(e,r)):this.loadAll(s)},destroy:function(){this._observer&&this._observer.disconnect(),e&&window.removeEventListener("online",this._onlineHandler),gt(this._settings).forEach((function(t){G(t)})),delete this._observer,delete this._settings,delete this._onlineHandler,delete this.loadingCount,delete this.toLoadCount},loadAll:function(t){var e=this,n=this._settings;wt(t,n).forEach((function(t){P(t,e),ot(t,n,e)}))},restoreAll:function(){var t=this._settings;gt(t).forEach((function(e){ft(e,t)}))}},yt.load=function(t,e){var n=o(e);ot(t,n)},yt.resetStatus=function(t){E(t)},e&&function(t,e){if(e)if(e.length)for(var n,i=0;n=e[i];i+=1)l(t,n);else l(t,e)}(yt,window.lazyLoadOptions),yt}))}));function Qa(){if(!document.lazyLoadInstance){document.lazyLoadInstance=new Va({use_native:true});document.lazyLoadBackgrounds=new Va({elements_selector:".lazy[data-bg]:not(.loaded)"})}if(document.readyState!=="complete"){document.addEventListener("DOMContentLoaded",(()=>document.lazyLoadInstance.update()));document.addEventListener("DOMContentLoaded",(()=>document.lazyLoadBackgrounds.update()))}salla.infiniteScroll.event.onAppend((()=>{document.lazyLoadInstance.update();document.lazyLoadBackgrounds.update()}))}const Wa=Qa;export{Wa as g};
|
|
25
|
+
//# sourceMappingURL=p-f6f43db8.js.map
|