@salla.sa/twilight-components 2.13.111 → 2.13.113

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.
Files changed (48) hide show
  1. package/dist/cjs/{app-globals-ebe117cc.js → app-globals-ba5ab328.js} +2 -2
  2. package/dist/cjs/app-globals-ba5ab328.js.map +1 -0
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/salla-add-product-button_49.cjs.entry.js.map +1 -1
  5. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  6. package/dist/cjs/salla-installment.cjs.entry.js.map +1 -1
  7. package/dist/cjs/twilight.cjs.js +1 -1
  8. package/dist/collection/components/salla-installment/salla-installment.js +1 -1
  9. package/dist/collection/components/salla-installment/salla-installment.js.map +1 -1
  10. package/dist/components/index.js +1 -1
  11. package/dist/components/index.js.map +1 -1
  12. package/dist/components/salla-installment.js +1 -1
  13. package/dist/components/salla-installment.js.map +1 -1
  14. package/dist/components/salla-quick-buy2.js.map +1 -1
  15. package/dist/esm/{app-globals-060c6f67.js → app-globals-fe94bf06.js} +2 -2
  16. package/dist/esm/app-globals-fe94bf06.js.map +1 -0
  17. package/dist/esm/loader.js +1 -1
  18. package/dist/esm/salla-add-product-button_49.entry.js.map +1 -1
  19. package/dist/esm/salla-installment.entry.js +1 -1
  20. package/dist/esm/salla-installment.entry.js.map +1 -1
  21. package/dist/esm/twilight.js +1 -1
  22. package/dist/esm-es5/{app-globals-060c6f67.js → app-globals-fe94bf06.js} +2 -2
  23. package/dist/esm-es5/app-globals-fe94bf06.js.map +1 -0
  24. package/dist/esm-es5/loader.js +1 -1
  25. package/dist/esm-es5/salla-add-product-button_49.entry.js.map +1 -1
  26. package/dist/esm-es5/salla-installment.entry.js +1 -1
  27. package/dist/esm-es5/salla-installment.entry.js.map +1 -1
  28. package/dist/esm-es5/twilight.js +1 -1
  29. package/dist/twilight/{p-7d7e2304.js → p-0908d404.js} +2 -2
  30. package/dist/twilight/p-0908d404.js.map +1 -0
  31. package/dist/twilight/p-466a720a.entry.js.map +1 -1
  32. package/dist/twilight/{p-2cb87af3.entry.js → p-5f863b52.entry.js} +2 -2
  33. package/dist/twilight/{p-2cb87af3.entry.js.map → p-5f863b52.entry.js.map} +1 -1
  34. package/dist/twilight/p-680a2e1e.system.entry.js.map +1 -1
  35. package/dist/twilight/{p-a454c35c.system.js → p-6877e716.system.js} +2 -2
  36. package/dist/twilight/{p-4faf6cdc.system.js → p-737b1e1a.system.js} +2 -2
  37. package/dist/twilight/p-737b1e1a.system.js.map +1 -0
  38. package/dist/twilight/{p-c63f84a6.system.entry.js → p-7da8b73b.system.entry.js} +2 -2
  39. package/dist/twilight/{p-c63f84a6.system.entry.js.map → p-7da8b73b.system.entry.js.map} +1 -1
  40. package/dist/twilight/twilight.esm.js +1 -1
  41. package/dist/twilight/twilight.js +1 -1
  42. package/package.json +5 -5
  43. package/dist/cjs/app-globals-ebe117cc.js.map +0 -1
  44. package/dist/esm/app-globals-060c6f67.js.map +0 -1
  45. package/dist/esm-es5/app-globals-060c6f67.js.map +0 -1
  46. package/dist/twilight/p-4faf6cdc.system.js.map +0 -1
  47. package/dist/twilight/p-7d7e2304.js.map +0 -1
  48. /package/dist/twilight/{p-a454c35c.system.js.map → p-6877e716.system.js.map} +0 -0
@@ -21,5 +21,5 @@ var __extends=this&&this.__extends||function(){var e=function(t,r){e=Object.setP
21
21
  * @site https://github.com/rmariuzzo/Lang.js
22
22
  * @author Rubens Mariuzzo <rubens@mariuzzo.com>
23
23
  */
24
- (function(t,r){{e.exports=r()}})(commonjsGlobal,(function(){function e(){if(typeof document!=="undefined"&&document.documentElement){return document.documentElement.lang}}function t(e){if(e==="-Inf"){return-Infinity}else if(e==="+Inf"||e==="Inf"||e==="*"){return Infinity}return parseInt(e,10)}var r=/^({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])$/;var n=/({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])/;var a={locale:"en"};var i=function(t){t=t||{};this.locale=t.locale||e()||a.locale;this.fallback=t.fallback;this.messages=t.messages};i.prototype.setMessages=function(e){this.messages=e};i.prototype.getLocale=function(){return this.locale||this.fallback};i.prototype.setLocale=function(e){this.locale=e};i.prototype.getFallback=function(){return this.fallback};i.prototype.setFallback=function(e){this.fallback=e};i.prototype.has=function(e,t){if(typeof e!=="string"||!this.messages){return false}return this._getMessage(e,t)!==null};i.prototype.get=function(e,t,r){if(!this.has(e,r)){return e}var n=this._getMessage(e,r);if(n===null){return e}if(t){n=this._applyReplacements(n,t)}return n};i.prototype.trans=function(e,t){return this.get(e,t)};i.prototype.choice=function(e,t,r,a){r=typeof r!=="undefined"?r:{};r.count=t;var i=this.get(e,r,a);if(i===null||i===undefined){return i}var o=i.split("|");var s=[];for(var l=0;l<o.length;l++){o[l]=o[l].trim();if(n.test(o[l])){var c=o[l].split(/\s/);s.push(c.shift());o[l]=c.join(" ")}}if(o.length===1){return i}for(var u=0;u<s.length;u++){if(this._testInterval(t,s[u])){return o[u]}}a=a||this._getLocale(e);var d=this._getPluralForm(t,a);return o[d]};i.prototype.transChoice=function(e,t,r){return this.choice(e,t,r)};i.prototype._parseKey=function(e,t){if(typeof e!=="string"||typeof t!=="string"){return null}var r=e.split(".");var n=r[0].replace(/\//g,".");return{source:t+"."+n,sourceFallback:this.getFallback()+"."+n,entries:r.slice(1)}};i.prototype._getMessage=function(e,t){t=t||this.getLocale();e=this._parseKey(e,t);if(this.messages[e.source]===undefined&&this.messages[e.sourceFallback]===undefined){return null}var r=this.messages[e.source];var n=e.entries.slice();var a=n.join(".");r=r!==undefined?this._getValueInKey(r,a):undefined;if(typeof r!=="string"&&this.messages[e.sourceFallback]){r=this.messages[e.sourceFallback];n=e.entries.slice();a="";while(n.length&&r!==undefined){var a=!a?n.shift():a.concat(".",n.shift());if(r[a]){r=r[a];a=""}}}if(typeof r!=="string"){return null}return r};i.prototype._getValueInKey=function(e,t){if(typeof e[t]==="string"){return e[t]}t=t.replace(/\[(\w+)\]/g,".$1");t=t.replace(/^\./,"");var r=t.split(".");for(var n=0,a=r.length;n<a;++n){var i=r.slice(0,n+1).join(".");var o=r.slice(n+1,r.length).join(".");if(e[i]){return this._getValueInKey(e[i],o)}}return e};i.prototype._getLocale=function(e){e=this._parseKey(e,this.locale);if(this.messages[e.source]){return this.locale}if(this.messages[e.sourceFallback]){return this.fallback}return null};i.prototype._findMessageInTree=function(e,t){while(e.length&&t!==undefined){var r=e.join(".");if(t[r]){t=t[r];break}t=t[e.shift()]}return t};i.prototype._sortReplacementKeys=function(e,t){return t.length-e.length};i.prototype._applyReplacements=function(e,t){var r=Object.keys(t).sort(this._sortReplacementKeys);r.forEach((function(r){e=e.replace(new RegExp(":"+r,"gi"),(function(e){var n=t[r];var a=e===e.toUpperCase();if(a){return n.toUpperCase()}var i=e===e.replace(/\w/i,(function(e){return e.toUpperCase()}));if(i){return n.charAt(0).toUpperCase()+n.slice(1)}return n}))}));return e};i.prototype._testInterval=function(e,n){if(typeof n!=="string"){throw"Invalid interval: should be a string."}n=n.trim();var a=n.match(r);if(!a){throw"Invalid interval: "+n}if(a[2]){var i=a[2].split(",");for(var o=0;o<i.length;o++){if(parseInt(i[o],10)===e){return true}}}else{a=a.filter((function(e){return!!e}));var s=a[1];var l=t(a[2]);if(l===Infinity){l=-Infinity}var c=t(a[3]);var u=a[4];return(s==="["?e>=l:e>l)&&(u==="]"?e<=c:e<c)}return false};i.prototype._getPluralForm=function(e,t){switch(t){case"az":case"bo":case"dz":case"id":case"ja":case"jv":case"ka":case"km":case"kn":case"ko":case"ms":case"th":case"tr":case"vi":case"zh":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 e==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 e===0||e===1?0:1;case"be":case"bs":case"hr":case"ru":case"sr":case"uk":return e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2;case"cs":case"sk":return e==1?0:e>=2&&e<=4?1:2;case"ga":return e==1?0:e==2?1:2;case"lt":return e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2;case"sl":return e%100==1?0:e%100==2?1:e%100==3||e%100==4?2:3;case"mk":return e%10==1?0:1;case"mt":return e==1?0:e===0||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3;case"lv":return e===0?0:e%10==1&&e%100!=11?1:2;case"pl":return e==1?0:e%10>=2&&e%10<=4&&(e%100<12||e%100>14)?1:2;case"cy":return e==1?0:e==2?1:e==8||e==11?2:3;case"ro":return e==1?0:e===0||e%100>0&&e%100<20?1:2;case"ar":return e===0?0:e==1?1:e==2?2:e%100>=3&&e%100<=10?3:e%100>=11&&e%100<=99?4:5;default:return 0}};return i}))}));var bind=function e(t,r){return function e(){var n=new Array(arguments.length);for(var a=0;a<n.length;a++){n[a]=arguments[a]}return t.apply(r,n)}};var toString=Object.prototype.toString;var kindOf=function(e){return function(t){var r=toString.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())}}(Object.create(null));function kindOfTest(e){e=e.toLowerCase();return function t(r){return kindOf(r)===e}}function isArray(e){return Array.isArray(e)}function isUndefined(e){return typeof e==="undefined"}function isBuffer(e){return e!==null&&!isUndefined(e)&&e.constructor!==null&&!isUndefined(e.constructor)&&typeof e.constructor.isBuffer==="function"&&e.constructor.isBuffer(e)}var isArrayBuffer=kindOfTest("ArrayBuffer");function isArrayBufferView(e){var t;if(typeof ArrayBuffer!=="undefined"&&ArrayBuffer.isView){t=ArrayBuffer.isView(e)}else{t=e&&e.buffer&&isArrayBuffer(e.buffer)}return t}function isString(e){return typeof e==="string"}function isNumber(e){return typeof e==="number"}function isObject(e){return e!==null&&typeof e==="object"}function isPlainObject(e){if(kindOf(e)!=="object"){return false}var t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}var isDate=kindOfTest("Date");var isFile=kindOfTest("File");var isBlob=kindOfTest("Blob");var isFileList=kindOfTest("FileList");function isFunction(e){return toString.call(e)==="[object Function]"}function isStream(e){return isObject(e)&&isFunction(e.pipe)}function isFormData(e){var t="[object FormData]";return e&&(typeof FormData==="function"&&e instanceof FormData||toString.call(e)===t||isFunction(e.toString)&&e.toString()===t)}var isURLSearchParams=kindOfTest("URLSearchParams");function trim(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function isStandardBrowserEnv(){if(typeof navigator!=="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")){return false}return typeof window!=="undefined"&&typeof document!=="undefined"}function forEach(e,t){if(e===null||typeof e==="undefined"){return}if(typeof e!=="object"){e=[e]}if(isArray(e)){for(var r=0,n=e.length;r<n;r++){t.call(null,e[r],r,e)}}else{for(var a in e){if(Object.prototype.hasOwnProperty.call(e,a)){t.call(null,e[a],a,e)}}}}function merge(){var e={};function t(t,r){if(isPlainObject(e[r])&&isPlainObject(t)){e[r]=merge(e[r],t)}else if(isPlainObject(t)){e[r]=merge({},t)}else if(isArray(t)){e[r]=t.slice()}else{e[r]=t}}for(var r=0,n=arguments.length;r<n;r++){forEach(arguments[r],t)}return e}function extend(e,t,r){forEach(t,(function t(n,a){if(r&&typeof n==="function"){e[a]=bind(n,r)}else{e[a]=n}}));return e}function stripBOM(e){if(e.charCodeAt(0)===65279){e=e.slice(1)}return e}function inherits(e,t,r,n){e.prototype=Object.create(t.prototype,n);e.prototype.constructor=e;r&&Object.assign(e.prototype,r)}function toFlatObject(e,t,r){var n;var a;var i;var o={};t=t||{};do{n=Object.getOwnPropertyNames(e);a=n.length;while(a-- >0){i=n[a];if(!o[i]){t[i]=e[i];o[i]=true}}e=Object.getPrototypeOf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t}function endsWith(e,t,r){e=String(e);if(r===undefined||r>e.length){r=e.length}r-=t.length;var n=e.indexOf(t,r);return n!==-1&&n===r}function toArray(e){if(!e)return null;var t=e.length;if(isUndefined(t))return null;var r=new Array(t);while(t-- >0){r[t]=e[t]}return r}var isTypedArray=function(e){return function(t){return e&&t instanceof e}}(typeof Uint8Array!=="undefined"&&Object.getPrototypeOf(Uint8Array));var utils={isArray:isArray,isArrayBuffer:isArrayBuffer,isBuffer:isBuffer,isFormData:isFormData,isArrayBufferView:isArrayBufferView,isString:isString,isNumber:isNumber,isObject:isObject,isPlainObject:isPlainObject,isUndefined:isUndefined,isDate:isDate,isFile:isFile,isBlob:isBlob,isFunction:isFunction,isStream:isStream,isURLSearchParams:isURLSearchParams,isStandardBrowserEnv:isStandardBrowserEnv,forEach:forEach,merge:merge,extend:extend,trim:trim,stripBOM:stripBOM,inherits:inherits,toFlatObject:toFlatObject,kindOf:kindOf,kindOfTest:kindOfTest,endsWith:endsWith,toArray:toArray,isTypedArray:isTypedArray,isFileList:isFileList};function encode(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var buildURL=function e(t,r,n){if(!r){return t}var a;if(n){a=n(r)}else if(utils.isURLSearchParams(r)){a=r.toString()}else{var i=[];utils.forEach(r,(function e(t,r){if(t===null||typeof t==="undefined"){return}if(utils.isArray(t)){r=r+"[]"}else{t=[t]}utils.forEach(t,(function e(t){if(utils.isDate(t)){t=t.toISOString()}else if(utils.isObject(t)){t=JSON.stringify(t)}i.push(encode(r)+"="+encode(t))}))}));a=i.join("&")}if(a){var o=t.indexOf("#");if(o!==-1){t=t.slice(0,o)}t+=(t.indexOf("?")===-1?"?":"&")+a}return t};function InterceptorManager(){this.handlers=[]}InterceptorManager.prototype.use=function e(t,r,n){this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:false,runWhen:n?n.runWhen:null});return this.handlers.length-1};InterceptorManager.prototype.eject=function e(t){if(this.handlers[t]){this.handlers[t]=null}};InterceptorManager.prototype.forEach=function e(t){utils.forEach(this.handlers,(function e(r){if(r!==null){t(r)}}))};var InterceptorManager_1=InterceptorManager;var normalizeHeaderName=function e(t,r){utils.forEach(t,(function e(n,a){if(a!==r&&a.toUpperCase()===r.toUpperCase()){t[r]=n;delete t[a]}}))};function AxiosError(e,t,r,n,a){Error.call(this);this.message=e;this.name="AxiosError";t&&(this.code=t);r&&(this.config=r);n&&(this.request=n);a&&(this.response=a)}utils.inherits(AxiosError,Error,{toJSON:function e(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var prototype=AxiosError.prototype;var descriptors={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED"].forEach((function(e){descriptors[e]={value:e}}));Object.defineProperties(AxiosError,descriptors);Object.defineProperty(prototype,"isAxiosError",{value:true});AxiosError.from=function(e,t,r,n,a,i){var o=Object.create(prototype);utils.toFlatObject(e,o,(function e(t){return t!==Error.prototype}));AxiosError.call(o,e.message,t,r,n,a);o.name=e.name;i&&Object.assign(o,i);return o};var AxiosError_1=AxiosError;var transitional={silentJSONParsing:true,forcedJSONParsing:true,clarifyTimeoutError:false};function toFormData(e,t){t=t||new FormData;var r=[];function n(e){if(e===null)return"";if(utils.isDate(e)){return e.toISOString()}if(utils.isArrayBuffer(e)||utils.isTypedArray(e)){return typeof Blob==="function"?new Blob([e]):Buffer.from(e)}return e}function a(e,i){if(utils.isPlainObject(e)||utils.isArray(e)){if(r.indexOf(e)!==-1){throw Error("Circular reference detected in "+i)}r.push(e);utils.forEach(e,(function e(r,o){if(utils.isUndefined(r))return;var s=i?i+"."+o:o;var l;if(r&&!i&&typeof r==="object"){if(utils.endsWith(o,"{}")){r=JSON.stringify(r)}else if(utils.endsWith(o,"[]")&&(l=utils.toArray(r))){l.forEach((function(e){!utils.isUndefined(e)&&t.append(s,n(e))}));return}}a(r,s)}));r.pop()}else{t.append(i,n(e))}}a(e);return t}var toFormData_1=toFormData;var settle=function e(t,r,n){var a=n.config.validateStatus;if(!n.status||!a||a(n.status)){t(n)}else{r(new AxiosError_1("Request failed with status code "+n.status,[AxiosError_1.ERR_BAD_REQUEST,AxiosError_1.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}};var cookies=utils.isStandardBrowserEnv()?function e(){return{write:function e(t,r,n,a,i,o){var s=[];s.push(t+"="+encodeURIComponent(r));if(utils.isNumber(n)){s.push("expires="+new Date(n).toGMTString())}if(utils.isString(a)){s.push("path="+a)}if(utils.isString(i)){s.push("domain="+i)}if(o===true){s.push("secure")}document.cookie=s.join("; ")},read:function e(t){var r=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function e(t){this.write(t,"",Date.now()-864e5)}}}():function e(){return{write:function e(){},read:function e(){return null},remove:function e(){}}}();var isAbsoluteURL=function e(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)};var combineURLs=function e(t,r){return r?t.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):t};var buildFullPath=function e(t,r){if(t&&!isAbsoluteURL(r)){return combineURLs(t,r)}return r};var ignoreDuplicateOf=["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 parseHeaders=function e(t){var r={};var n;var a;var i;if(!t){return r}utils.forEach(t.split("\n"),(function e(t){i=t.indexOf(":");n=utils.trim(t.substr(0,i)).toLowerCase();a=utils.trim(t.substr(i+1));if(n){if(r[n]&&ignoreDuplicateOf.indexOf(n)>=0){return}if(n==="set-cookie"){r[n]=(r[n]?r[n]:[]).concat([a])}else{r[n]=r[n]?r[n]+", "+a:a}}}));return r};var isURLSameOrigin=utils.isStandardBrowserEnv()?function e(){var t=/(msie|trident)/i.test(navigator.userAgent);var r=document.createElement("a");var n;function a(e){var n=e;if(t){r.setAttribute("href",n);n=r.href}r.setAttribute("href",n);return{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}n=a(window.location.href);return function e(t){var r=utils.isString(t)?a(t):t;return r.protocol===n.protocol&&r.host===n.host}}():function e(){return function e(){return true}}();function CanceledError(e){AxiosError_1.call(this,e==null?"canceled":e,AxiosError_1.ERR_CANCELED);this.name="CanceledError"}utils.inherits(CanceledError,AxiosError_1,{__CANCEL__:true});var CanceledError_1=CanceledError;var parseProtocol=function e(t){var r=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return r&&r[1]||""};var xhr=function e(t){return new Promise((function e(r,n){var a=t.data;var i=t.headers;var o=t.responseType;var s;function l(){if(t.cancelToken){t.cancelToken.unsubscribe(s)}if(t.signal){t.signal.removeEventListener("abort",s)}}if(utils.isFormData(a)&&utils.isStandardBrowserEnv()){delete i["Content-Type"]}var c=new XMLHttpRequest;if(t.auth){var u=t.auth.username||"";var d=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";i.Authorization="Basic "+btoa(u+":"+d)}var f=buildFullPath(t.baseURL,t.url);c.open(t.method.toUpperCase(),buildURL(f,t.params,t.paramsSerializer),true);c.timeout=t.timeout;function h(){if(!c){return}var e="getAllResponseHeaders"in c?parseHeaders(c.getAllResponseHeaders()):null;var a=!o||o==="text"||o==="json"?c.responseText:c.response;var i={data:a,status:c.status,statusText:c.statusText,headers:e,config:t,request:c};settle((function e(t){r(t);l()}),(function e(t){n(t);l()}),i);c=null}if("onloadend"in c){c.onloadend=h}else{c.onreadystatechange=function e(){if(!c||c.readyState!==4){return}if(c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)){return}setTimeout(h)}}c.onabort=function e(){if(!c){return}n(new AxiosError_1("Request aborted",AxiosError_1.ECONNABORTED,t,c));c=null};c.onerror=function e(){n(new AxiosError_1("Network Error",AxiosError_1.ERR_NETWORK,t,c,c));c=null};c.ontimeout=function e(){var r=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded";var a=t.transitional||transitional;if(t.timeoutErrorMessage){r=t.timeoutErrorMessage}n(new AxiosError_1(r,a.clarifyTimeoutError?AxiosError_1.ETIMEDOUT:AxiosError_1.ECONNABORTED,t,c));c=null};if(utils.isStandardBrowserEnv()){var p=(t.withCredentials||isURLSameOrigin(f))&&t.xsrfCookieName?cookies.read(t.xsrfCookieName):undefined;if(p){i[t.xsrfHeaderName]=p}}if("setRequestHeader"in c){utils.forEach(i,(function e(t,r){if(typeof a==="undefined"&&r.toLowerCase()==="content-type"){delete i[r]}else{c.setRequestHeader(r,t)}}))}if(!utils.isUndefined(t.withCredentials)){c.withCredentials=!!t.withCredentials}if(o&&o!=="json"){c.responseType=t.responseType}if(typeof t.onDownloadProgress==="function"){c.addEventListener("progress",t.onDownloadProgress)}if(typeof t.onUploadProgress==="function"&&c.upload){c.upload.addEventListener("progress",t.onUploadProgress)}if(t.cancelToken||t.signal){s=function(e){if(!c){return}n(!e||e&&e.type?new CanceledError_1:e);c.abort();c=null};t.cancelToken&&t.cancelToken.subscribe(s);if(t.signal){t.signal.aborted?s():t.signal.addEventListener("abort",s)}}if(!a){a=null}var v=parseProtocol(f);if(v&&["http","https","file"].indexOf(v)===-1){n(new AxiosError_1("Unsupported protocol "+v+":",AxiosError_1.ERR_BAD_REQUEST,t));return}c.send(a)}))};var _null=null;var DEFAULT_CONTENT_TYPE={"Content-Type":"application/x-www-form-urlencoded"};function setContentTypeIfUnset(e,t){if(!utils.isUndefined(e)&&utils.isUndefined(e["Content-Type"])){e["Content-Type"]=t}}function getDefaultAdapter(){var e;if(typeof XMLHttpRequest!=="undefined"){e=xhr}else if(typeof process!=="undefined"&&Object.prototype.toString.call(process)==="[object process]"){e=xhr}return e}function stringifySafely(e,t,r){if(utils.isString(e)){try{(t||JSON.parse)(e);return utils.trim(e)}catch(e){if(e.name!=="SyntaxError"){throw e}}}return(r||JSON.stringify)(e)}var defaults={transitional:transitional,adapter:getDefaultAdapter(),transformRequest:[function e(t,r){normalizeHeaderName(r,"Accept");normalizeHeaderName(r,"Content-Type");if(utils.isFormData(t)||utils.isArrayBuffer(t)||utils.isBuffer(t)||utils.isStream(t)||utils.isFile(t)||utils.isBlob(t)){return t}if(utils.isArrayBufferView(t)){return t.buffer}if(utils.isURLSearchParams(t)){setContentTypeIfUnset(r,"application/x-www-form-urlencoded;charset=utf-8");return t.toString()}var n=utils.isObject(t);var a=r&&r["Content-Type"];var i;if((i=utils.isFileList(t))||n&&a==="multipart/form-data"){var o=this.env&&this.env.FormData;return toFormData_1(i?{"files[]":t}:t,o&&new o)}else if(n||a==="application/json"){setContentTypeIfUnset(r,"application/json");return stringifySafely(t)}return t}],transformResponse:[function e(t){var r=this.transitional||defaults.transitional;var n=r&&r.silentJSONParsing;var a=r&&r.forcedJSONParsing;var i=!n&&this.responseType==="json";if(i||a&&utils.isString(t)&&t.length){try{return JSON.parse(t)}catch(e){if(i){if(e.name==="SyntaxError"){throw AxiosError_1.from(e,AxiosError_1.ERR_BAD_RESPONSE,this,null,this.response)}throw e}}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:_null},validateStatus:function e(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};utils.forEach(["delete","get","head"],(function e(t){defaults.headers[t]={}}));utils.forEach(["post","put","patch"],(function e(t){defaults.headers[t]=utils.merge(DEFAULT_CONTENT_TYPE)}));var defaults_1=defaults;var transformData=function e(t,r,n){var a=this||defaults_1;utils.forEach(n,(function e(n){t=n.call(a,t,r)}));return t};var isCancel=function e(t){return!!(t&&t.__CANCEL__)};function throwIfCancellationRequested(e){if(e.cancelToken){e.cancelToken.throwIfRequested()}if(e.signal&&e.signal.aborted){throw new CanceledError_1}}var dispatchRequest=function e(t){throwIfCancellationRequested(t);t.headers=t.headers||{};t.data=transformData.call(t,t.data,t.headers,t.transformRequest);t.headers=utils.merge(t.headers.common||{},t.headers[t.method]||{},t.headers);utils.forEach(["delete","get","head","post","put","patch","common"],(function e(r){delete t.headers[r]}));var r=t.adapter||defaults_1.adapter;return r(t).then((function e(r){throwIfCancellationRequested(t);r.data=transformData.call(t,r.data,r.headers,t.transformResponse);return r}),(function e(r){if(!isCancel(r)){throwIfCancellationRequested(t);if(r&&r.response){r.response.data=transformData.call(t,r.response.data,r.response.headers,t.transformResponse)}}return Promise.reject(r)}))};var mergeConfig=function e(t,r){r=r||{};var n={};function a(e,t){if(utils.isPlainObject(e)&&utils.isPlainObject(t)){return utils.merge(e,t)}else if(utils.isPlainObject(t)){return utils.merge({},t)}else if(utils.isArray(t)){return t.slice()}return t}function i(e){if(!utils.isUndefined(r[e])){return a(t[e],r[e])}else if(!utils.isUndefined(t[e])){return a(undefined,t[e])}}function o(e){if(!utils.isUndefined(r[e])){return a(undefined,r[e])}}function s(e){if(!utils.isUndefined(r[e])){return a(undefined,r[e])}else if(!utils.isUndefined(t[e])){return a(undefined,t[e])}}function l(e){if(e in r){return a(t[e],r[e])}else if(e in t){return a(undefined,t[e])}}var c={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:l};utils.forEach(Object.keys(t).concat(Object.keys(r)),(function e(t){var r=c[t]||i;var a=r(t);utils.isUndefined(a)&&r!==l||(n[t]=a)}));return n};var data={version:"0.27.2"};var VERSION=data.version;var validators$1={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){validators$1[e]=function r(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));var deprecatedWarnings={};validators$1.transitional=function e(t,r,n){function a(e,t){return"[Axios v"+VERSION+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(e,n,i){if(t===false){throw new AxiosError_1(a(n," has been removed"+(r?" in "+r:"")),AxiosError_1.ERR_DEPRECATED)}if(r&&!deprecatedWarnings[n]){deprecatedWarnings[n]=true;console.warn(a(n," has been deprecated since v"+r+" and will be removed in the near future"))}return t?t(e,n,i):true}};function assertOptions(e,t,r){if(typeof e!=="object"){throw new AxiosError_1("options must be an object",AxiosError_1.ERR_BAD_OPTION_VALUE)}var n=Object.keys(e);var a=n.length;while(a-- >0){var i=n[a];var o=t[i];if(o){var s=e[i];var l=s===undefined||o(s,i,e);if(l!==true){throw new AxiosError_1("option "+i+" must be "+l,AxiosError_1.ERR_BAD_OPTION_VALUE)}continue}if(r!==true){throw new AxiosError_1("Unknown option "+i,AxiosError_1.ERR_BAD_OPTION)}}}var validator={assertOptions:assertOptions,validators:validators$1};var validators=validator.validators;function Axios(e){this.defaults=e;this.interceptors={request:new InterceptorManager_1,response:new InterceptorManager_1}}Axios.prototype.request=function e(t,r){if(typeof t==="string"){r=r||{};r.url=t}else{r=t||{}}r=mergeConfig(this.defaults,r);if(r.method){r.method=r.method.toLowerCase()}else if(this.defaults.method){r.method=this.defaults.method.toLowerCase()}else{r.method="get"}var n=r.transitional;if(n!==undefined){validator.assertOptions(n,{silentJSONParsing:validators.transitional(validators.boolean),forcedJSONParsing:validators.transitional(validators.boolean),clarifyTimeoutError:validators.transitional(validators.boolean)},false)}var a=[];var i=true;this.interceptors.request.forEach((function e(t){if(typeof t.runWhen==="function"&&t.runWhen(r)===false){return}i=i&&t.synchronous;a.unshift(t.fulfilled,t.rejected)}));var o=[];this.interceptors.response.forEach((function e(t){o.push(t.fulfilled,t.rejected)}));var s;if(!i){var l=[dispatchRequest,undefined];Array.prototype.unshift.apply(l,a);l=l.concat(o);s=Promise.resolve(r);while(l.length){s=s.then(l.shift(),l.shift())}return s}var c=r;while(a.length){var u=a.shift();var d=a.shift();try{c=u(c)}catch(e){d(e);break}}try{s=dispatchRequest(c)}catch(e){return Promise.reject(e)}while(o.length){s=s.then(o.shift(),o.shift())}return s};Axios.prototype.getUri=function e(t){t=mergeConfig(this.defaults,t);var r=buildFullPath(t.baseURL,t.url);return buildURL(r,t.params,t.paramsSerializer)};utils.forEach(["delete","get","head","options"],(function e(t){Axios.prototype[t]=function(e,r){return this.request(mergeConfig(r||{},{method:t,url:e,data:(r||{}).data}))}}));utils.forEach(["post","put","patch"],(function e(t){function r(e){return function r(n,a,i){return this.request(mergeConfig(i||{},{method:t,headers:e?{"Content-Type":"multipart/form-data"}:{},url:n,data:a}))}}Axios.prototype[t]=r();Axios.prototype[t+"Form"]=r(true)}));var Axios_1=Axios;function CancelToken(e){if(typeof e!=="function"){throw new TypeError("executor must be a function.")}var t;this.promise=new Promise((function e(r){t=r}));var r=this;this.promise.then((function(e){if(!r._listeners)return;var t;var n=r._listeners.length;for(t=0;t<n;t++){r._listeners[t](e)}r._listeners=null}));this.promise.then=function(e){var t;var n=new Promise((function(e){r.subscribe(e);t=e})).then(e);n.cancel=function e(){r.unsubscribe(t)};return n};e((function e(n){if(r.reason){return}r.reason=new CanceledError_1(n);t(r.reason)}))}CancelToken.prototype.throwIfRequested=function e(){if(this.reason){throw this.reason}};CancelToken.prototype.subscribe=function e(t){if(this.reason){t(this.reason);return}if(this._listeners){this._listeners.push(t)}else{this._listeners=[t]}};CancelToken.prototype.unsubscribe=function e(t){if(!this._listeners){return}var r=this._listeners.indexOf(t);if(r!==-1){this._listeners.splice(r,1)}};CancelToken.source=function e(){var t;var r=new CancelToken((function e(r){t=r}));return{token:r,cancel:t}};var CancelToken_1=CancelToken;var spread=function e(t){return function e(r){return t.apply(null,r)}};var isAxiosError=function e(t){return utils.isObject(t)&&t.isAxiosError===true};function createInstance(e){var t=new Axios_1(e);var r=bind(Axios_1.prototype.request,t);utils.extend(r,Axios_1.prototype,t);utils.extend(r,t);r.create=function t(r){return createInstance(mergeConfig(e,r))};return r}var axios$1=createInstance(defaults_1);axios$1.Axios=Axios_1;axios$1.CanceledError=CanceledError_1;axios$1.CancelToken=CancelToken_1;axios$1.isCancel=isCancel;axios$1.VERSION=data.version;axios$1.toFormData=toFormData_1;axios$1.AxiosError=AxiosError_1;axios$1.Cancel=axios$1.CanceledError;axios$1.all=function e(t){return Promise.all(t)};axios$1.spread=spread;axios$1.isAxiosError=isAxiosError;var axios_1=axios$1;var _default=axios$1;axios_1.default=_default;var axios=axios_1;function e(e){this.message=e}e.prototype=new Error,e.prototype.name="InvalidCharacterError";var r="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var r=String(t).replace(/=+$/,"");if(r.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,a,i=0,o=0,s="";a=r.charAt(o++);~a&&(n=i%4?64*n+a:a,i++%4)?s+=String.fromCharCode(255&n>>(-2*i&6)):0)a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a);return s};function t(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(r(e).replace(/(.)/g,(function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(t)}catch(e){return r(t)}}function n$1(e){this.message=e}function o$1(e,r){if("string"!=typeof e)throw new n$1("Invalid token specified");var n=!0===(r=r||{}).header?0:1;try{return JSON.parse(t(e.split(".")[n]))}catch(e){throw new n$1("Invalid token specified: "+e.message)}}n$1.prototype=new Error,n$1.prototype.name="InvalidTokenError";var i=function(e,t,r){return alert(e)},n=function(e,t){return i(e,l.error,t)},l={error:"error",success:"success",info:"info"};var o={fire:function(e,t,r){return i(e,t,r)},setNotifier:function(e){i=e,salla.event.emit("twilight::notifier.changed")},error:n,success:function(e,t){return i(e,l.success,t)},info:function(e,t){return i(e,l.info,t)},sallaInitiated:function(){var e=window.location.href.match(/([\?\&]danger=)[^&]+/g);e&&(window.history.replaceState(null,document.title,window.location.pathname),salla.event.once("twilight::notifier.changed",(function(){e.forEach((function(e){e=decodeURI(e.replace("?danger=","").replace("&danger=",""));var t=document.createElement("div");t.innerText=e,n(t.innerHTML),salla.event.emit("twilight::error",e)}))})))},types:l};var d=function(){function e(e,t){return this.api=e,this.event=t,new Proxy(this,{get:function(r,n){return"event"===n?t:"api"===n?e:e&&e[n]||r[n]}})}return e}();Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){for(var t=this;t;){if(t.matches(e))return t;t=t.parentElement}}),Element.prototype.getElementSallaData=function(e){var t;var r=[];for(var n=1;n<arguments.length;n++){r[n-1]=arguments[n]}if(!this.getAttribute)return;if(this.hasAttribute("data-json"))try{return JSON.parse(this.getAttribute("data-json"))}catch(e){}var a=this.getAttribute("data-function");if(a&&window[a])return"function"==typeof window[a]?this.getFilteredData((t=window[a]).call.apply(t,__spreadArray([this],r,false))):this.getFilteredData(window[a]);var 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);var o=i.querySelectorAll("[name]");if(!o.length)return this.getFilteredData();var s=Object.assign({},this.dataset);return o.forEach((function(e){if(!["checkbox","radio"].includes(e.type)||e.checked)try{var t=Salla.helpers.inputData(e.name,e.value,s);s[t.name]=t.value}catch(t){Salla.log(e.name+" can't be send")}})),this.getFilteredData(s)},Element.prototype.canEventFireHook=function(e){return!!this.hasAttribute&&this.hasAttribute(Salla.api.hooksPrefix+e.type)},Element.prototype.hasAttributeStartsWith=function(e,t){e=e.toLowerCase();for(var r=0;r<this.attributes.length;r++){var n=this.attributes[r].name.toLowerCase();if(0===n.indexOf(e))return!t||n}return!1},HTMLFormElement.prototype.getAjaxFormData=function(e){var t=this.querySelectorAll('input[type="file"]');t.forEach((function(e){e.files.length||e.setAttribute("disabled","")}));var r=new FormData(this);return t.forEach((function(e){e.files.length||e.removeAttribute("disabled")})),{formData:this.getFilteredData(r,e),url:this.getAttribute("action"),method:this.getAttribute("method")||"post",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}},Element.prototype.getFilteredData=function(e,t,r){var n=this;if(e===void 0){e=null}if(t===void 0){t=null}if(r===void 0){r=null}return e=e||(r===null||r===void 0?void 0:r.dataset)||this.dataset,r&&this.name&&void 0!==this.value&&(e=function(e,t,r){e instanceof FormData?e.append(t,r):e[t]=r;return e}(e,this.name,this.value)),["filterBeforeSubmit","filterBeforeSend"].forEach((function(a){var i=(r===null||r===void 0?void 0:r.dataset[a])||n.dataset[a];if(i){var o=window[i];if("function"==typeof o){if(!o(e,r||n,t)&&e)throw"Data failed to be pass verify function window.".concat(i,"(formData, element, event)!");return o(e,r||n,t)}Salla.log("window."+i+"() not found!")}})),e},HTMLAnchorElement.prototype.getAjaxFormData=function(e){return{formData:this.getFilteredData(null,e),url:this.getAttribute("href"),method:this.dataset.type||"get",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}};var c=function(){function e(){this.events={},this.namespace="";var e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&e.length>1?e[1]:"").toLowerCase()}e.prototype.after_init=function(){this.createDynamicFunctions()};e.prototype.createDynamicFunctions=function(){var e=this;Object.keys(this.events).forEach((function(t){e.createDynamicEventFuns(t),e.createDynamicListenerFuns(t)}))};e.prototype.createDynamicEventFuns=function(e){if(this[e])return;var t=this;this[e]=function(){var r=[];for(var n=0;n<arguments.length;n++){r[n]=arguments[n]}return t.dispatch.apply(t,__spreadArray([e],r,false))}};e.prototype.createDynamicListenerFuns=function(e){var t="on"+e.charAt(0).toUpperCase()+e.slice(1);if(this[t])return;var r=this;this[t]=function(t){var n=this;return r.on(e,(function(){var e=[];for(var r=0;r<arguments.length;r++){e[r]=arguments[r]}return __awaiter(n,void 0,void 0,(function(){return __generator(this,(function(r){return[2,t.apply(void 0,e)]}))}))}))}};e.prototype.getEventName=function(e){return e=this.events[e]||e,!this.namespace||e.includes("::")?e:this.namespace+Salla.event.delimiter+e};e.prototype.dispatch=function(e){var t;var r=[];for(var n=1;n<arguments.length;n++){r[n-1]=arguments[n]}return(t=Salla.event).emitAsync.apply(t,__spreadArray([this.getEventName(e)],r,false))};e.prototype.on=function(e,t,r){if(r===void 0){r={}}return Salla.event.addListener(this.getEventName(e),t,r)};e.prototype.once=function(e,t){return Salla.event.once(this.getEventName(e),t)};return e}();function u(e){e&&e.sallaInitiated&&!e.initiated&&(e.sallaInitiated(),e.initiated=!0)}Salla.event.auth=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="auth",t.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"},t.after_init();return t}t.prototype.login=function(e){return e?(e.type&&this.setTypeActionOnVerified(e.type),this.next_event=e.next_event||null,this.dispatch.apply(this,__spreadArray(["login"],arguments,false))):(this.next_event=null,this.dispatch.apply(this,__spreadArray(["login"],arguments,false)))};t.prototype.loggedIn=function(e){var t=this;return Salla.profile.info().finally((function(){return t.dispatch("loggedIn",e)}))};t.prototype.setTypeActionOnVerified=function(e){this.type_action_on_verified=e};t.prototype.getTypeActionOnVerified=function(){return this.type_action_on_verified||"redirect"};return t}(c)),Salla.event.cart=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="cart",t.events={latestFetched:"latest.fetched",latestFailed:"latest.failed",updated:"updated",itemUpdated:"item.updated",itemUpdatedFailed:"item.updated.failed",itemAdded:"item.added",itemAddedFailed:"item.added.failed",itemDeleted:"item.deleted",itemDeletedFailed:"item.deleted.failed",submitted:"submitted",submitFailed:"submit.failed",imageDeleted:"image.deleted",imageNotDeleted:"image.not.deleted",detailsFetched:"details.fetched",detailsNotFetched:"details.not.fetched",successReset:"success.reset",priceQuoteSucceeded:"price-quote.succeeded",priceQuoteFailed:"price-quote.failed",offersFetched:"offers.fetched",offersFailed:"offers.failed",couponAdded:"coupon.added",couponDeleted:"coupon.deleted",couponAdditionFailed:"coupon.addition.failed",couponDeletionFailed:"coupon.deletion.failed",quickOrderSettingFetched:"quick-order.fetched",quickOrderSettingFailed:"quick-order.failed",quickOrderSucceeded:"quick-order.succeeded",quickOrderFailed:"quick-order.failed"},t.after_init();return t}t.prototype.updated=function(e){var t;return Salla.cookie.set("fresh_summary",1),e&&"object"==typeof e?(e.offer&&salla.product.event.offerExisted(e.offer),e.redirect&&(salla.log("The current cart is purchased!"),salla.cart.api.reset()),e.cart?(salla.storage.set("cart.summary",{total:e.cart.total,sub_total:e.cart.sub_total,discount:e.cart.discount,real_shipping_cost:e.cart.real_shipping_cost,count:e.cart.count,shipping_cost:((t=e.cart.free_shipping_bar)===null||t===void 0?void 0:t.has_free_shipping)?0:e.cart.real_shipping_cost}),this.dispatch("updated",e.cart)):void salla.log("Failed to get the cart summary!")):(Salla.logger.info("Cart summary not an object!",e),this.dispatch("updated"))};t.prototype.latestFetched=function(e){return this.updated(e.data),this.dispatch("latestFetched",e)};t.prototype.itemAdded=function(e,t){return this.updated(e.data),this.dispatch("itemAdded",e,t)};t.prototype.itemDeleted=function(e,t){return this.updated(e.data),this.dispatch("itemDeleted",e,t)};t.prototype.itemUpdated=function(e,t){return this.updated(e.data),this.dispatch("itemUpdated",e,t)};t.prototype.couponAdded=function(e,t){return this.updated(e.data),this.dispatch("couponAdded",e,t)};t.prototype.couponDeleted=function(e,t){return this.updated(e.data),this.dispatch("couponDeleted",e,t)};return t}(c)),Salla.event.order=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="order",t.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"},t.after_init();return t}return t}(c)),Salla.event.scope=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="scope",t.events={fetched:"fetched",notFetched:"not.fetched",productAvailabilityFetched:"product-availability.fetched",productAvailabilityNotFetched:"product-availability.not.fetched",changeSucceeded:"changed",changeFailed:"not.changed"},t.after_init();return t}return t}(c)),Salla.event.rating=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="rating",t.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"},t.after_init();return t}return t}(c)),Salla.event.booking=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="booking",t.events={added:"added",additionFailed:"addition.failed"},t.after_init();return t}return t}(c)),Salla.event.comment=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="comment",t.events={added:"added",additionFailed:"addition.failed",fetched:"fetched",fetchFailed:"fetch.failed"},t.after_init();return t}return t}(c)),Salla.event.landing=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="landing",t.events={detailsFetched:"order.fetched",getDetailsFailed:"get.details.failed",orderCreated:"order.created",orderCreationFailed:"order.creation.failed",breadcrumbFetched:"breadcrumb.fetched",breadcrumbFetchFailed:"breadcrumb.fetch.failed"},t.after_init();return t}return t}(c)),Salla.event.loyalty=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="loyalty",t.events={exchangeSucceeded:"exchange.succeeded",exchangeFailed:"exchange.failed",programFetched:"program.fetched",programNotFetched:"program.not.fetched",resetSucceeded:"exchange-reset.succeeded",resetFailed:"exchange-reset.failed"},t.after_init();return t}t.prototype.exchangeSucceeded=function(e,t){return salla.cart.event.updated(e.data),this.dispatch("exchangeSucceeded",e,t)};t.prototype.resetSucceeded=function(e){return salla.cart.event.updated(e.data),this.dispatch("resetSucceeded",e)};return t}(c)),Salla.event.product=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="product",t.events={priceUpdated:"price.updated",priceUpdateFailed:"price.updated.failed",availabilitySubscribed:"availability.subscribed",availabilitySubscribeFailed:"availability.subscribe.failed",categoriesFetched:"categories.fetched",categoriesFailed:"categories.failed",searchFailed:"search.failed",searchResults:"search.results",offerExisted:"offer.existed",fetchOffersFailed:"fetch.offers.failed",offersFetched:"offers.fetched",sizeGuideFetched:"size-guide.fetched",sizeGuideFetchFailed:"size-guide.failed",giftFetched:"gift.fetched",giftFetchFailed:"gift.failed",detailFetched:"detail.fetched",detailFetchFailed:"detail.failed",addGiftToCartSucceeded:"gift.add-to-cart.succeeded",addGiftToCartFailed:"gift.add-to-cart.failed",giftImageUploadSucceeded:"gift.image-upload.succeeded",giftImageUploadFailed:"gift.image-upload.failed",productListFetchSucceeded:"fetch.succeeded",productListFetchFailed:"fetch.failed",productOptionsFetched:"options.fetched",productOptionsNotFetched:"options.not.fetched"},t.after_init();return t}return t}(c)),Salla.event.profile=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="profile",t.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"},t.after_init();return t}return t}(c)),Salla.event.currency=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="currency",t.events={changed:"changed",failed:"failed",fetched:"fetched",failedToFetch:"failed.to.fetch"},t.after_init();return t}return t}(c)),Salla.event.document=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="document",t.events={click:"click",change:"change",submit:"submit",keyup:"keyup",leaving:"leaving",request:"request",requestFailed:"request.failed"},t.after_init();return t}t.prototype.onClick=function(e,t){this.fireCallableFuns("click",e,t)};t.prototype.onChange=function(e,t){this.fireCallableFuns("change",e,t)};t.prototype.onSubmit=function(e,t){this.fireCallableFuns("submit",e,t)};t.prototype.onKeyup=function(e,t){this.fireCallableFuns("keyup",e,t)};t.prototype.fireCallableFuns=function(e,t,r){this.on(e,(function(e){"function"!=typeof t?"function"==typeof r&&e.target.matches(t)&&r(e):t(e)}))};t.prototype.fireEvent=function(e,t){var r=[];for(var n=2;n<arguments.length;n++){r[n-2]=arguments[n]}return this.fireEventForElements.apply(this,__spreadArray([e,t,!1],r,false))};t.prototype.fireEventForAll=function(e,t){var r=[];for(var n=2;n<arguments.length;n++){r[n-2]=arguments[n]}return this.fireEventForElements.apply(this,__spreadArray([e,t,!0],r,false))};t.prototype.fireEventForElements=function(e,t,r){var n=this;var a=[];for(var i=3;i<arguments.length;i++){a[i-3]=arguments[i]}if("string"==typeof e){if(r)return document.querySelectorAll(e).forEach((function(e){return n.fireEventForElements.apply(n,__spreadArray([e,t,!1],a,false))}));e=document.querySelector(e)}if(!e)return void salla.log("Failed To get element to fire event: "+t);var o=new(CustomEvent.bind.apply(CustomEvent,__spreadArray([void 0,t],a,false)));return e.dispatchEvent(o)};return t}(c)),Salla.event.wishlist=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="wishlist",t.events={added:"added",removed:"removed",additionFailed:"addition.failed",removingFailed:"removing.failed"},t.after_init();return t}return t}(c)),Salla.event.infiniteScroll=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="infiniteScroll",t.events={scrollThreshold:"scroll.threshold",request:"request",load:"load",append:"append",error:"error",last:"last",history:"history"},t.after_init();return t}return t}(c)),Salla.event.notifications=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="notifications",t.events={fetched:"fetched",fetchFailed:"fetch.failed"},t.after_init();return t}return t}(c)),Salla.event.component=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="component",t.events={menuFetched:"menus.fetched",menuFetchFailed:"menus.fetch.failed",reviewsFetched:"reviews.fetched",reviewsFetchFailed:"reviews.fetch.failed"},t.after_init();return t}return t}(c)),Salla.event.advertisement=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="advertisement",t.events={fetched:"advertisement.fetched",fetchFailed:"advertisement.not.fetched"},t.after_init();return t}return t}(c)),Salla.event.navigation=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="navigation",t.events={breadcrumbFetched:"breadcrumb.fetched",breadcrumbFetchFailed:"breadcrumb.fetch.failed"},t.after_init();return t}return t}(c)),Salla.event.on("twilight::initiated",(function(){Object.keys(Salla).forEach((function(e){"object"==typeof(e=Salla[e])&&(u(e),Object.keys(e).forEach((function(t){u(e[t])})))}))})),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=function(){return"user"===Salla.config.get("user.type")},Salla.config.isGuest=function(){return!Salla.config.isUser()},Salla.config.languages=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t;var r,n;return __generator(this,(function(a){switch(a.label){case 0:if(Salla.config.triedToGetLanguages_)return[2,Salla.config.get("languages")];Salla.config.triedToGetLanguages_=!0;e=!0,t=[];return[4,salla.document.api.request("languages",null,"get")];case 1:return[2,((n=(r=a.sent())===null||r===void 0?void 0:r.data)===null||n===void 0?void 0:n.map((function(r){e&&(t=[],e=!1),r.code=r.code||r.iso_code,r.url=salla.url.get(r.code),r.is_rtl=r.is_rtl||r.rtl,t.push(r)})),Salla.config.set("languages",t),t)]}}))}))},Salla.config.currencies=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t;var r,n;return __generator(this,(function(a){switch(a.label){case 0:if(Salla.config.triedToGetCurrencies_)return[2,Salla.config.get("currencies")];Salla.config.triedToGetCurrencies_=!0;e=!0,t={};return[4,salla.currency.api.list()];case 1:return[2,((n=(r=a.sent())===null||r===void 0?void 0:r.data)===null||n===void 0?void 0:n.map((function(r){e&&(t={},e=!1),r.country_code=r.code.substr(0,2).toLowerCase(),t[r.code]=r})),Salla.config.set("currencies",t),t)]}}))}))};var h=function(){function e(){this.endpoints={},this.webEndpoints=[],this.namespace="BaseApi",this.endpointsMethods={},this.endpointsHeaders={};var e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&e.length>1?e[1]:"").toLowerCase(),this.debounce={request:void 0,time:300,enabled:!0,exclude:[]}}e.prototype.after_init=function(){};e.prototype.normalRequest=function(e,t,r){if(t===void 0){t=void 0}if(r===void 0){r=null}var n=Array.isArray(e),a=n?this.getUrl.apply(this,e):this.getUrl(e);e=n?e[0]:e,r=r||this.endpointsMethods[e]||"post";var i=this.endpointsHeaders[e];if("get"===r&&t instanceof FormData){var o={};Array.from(t.entries()).forEach((function(e){o[e[0]]=e[1]})),t={params:o}}return i&&"get"===r&&(t=t?Object.assign(t,i):i),this.webEndpoints.includes(e)?a=salla.url.get(a):"http"!==a.substring(0,4)&&(a=salla.url.api(a)),Salla.api.request(a,t,r,{headers:i})};e.prototype.request=function(e,t,r){if(t===void 0){t=void 0}if(r===void 0){r=null}return!salla.api.isFastRequestsAllowed()&&this.debounce.enabled?(this.debounce.request||(this.debounce.request=salla.helpers.debounce(this.normalRequest.bind(this),this.debounce.time)),this.debounce.request(e,t,r)):this.normalRequest(e,t,r)};e.prototype.getUrl=function(e){var t=this.endpoints[e]||e;var r=/{[^{}]+}/i;for(var n=1;n<arguments.length;n++)t=t.replace(r,arguments[n]);return t};e.prototype.event=function(){return salla.event[this.className]};return e}();var p=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.addToCartTries=0,t.namespace="cart",t.endpoints={latest:"cart/latest",details:"cart/{cart}",quickAdd:"cart/{cart}/item/{product}/quick-add",addItem:"cart/{cart}/item/{product}/add",deleteItem:"cart/{cart}/item/{item}",updateItem:"cart/{cart}/item/{item}",deleteImage:"cart/{cart}/image/{image}",uploadImage:"cart/{cart}/image",status:"cart/{cart}/status",addCoupon:"cart/{id}/coupon",deleteCoupon:"cart/{id}/coupon",getQuickOrderSettings:"checkout/quick-order",createQuickOrder:"checkout/quick-order",priceQuote:"cart/{cartId}/price-quote",offers:"offers/cart/{cartId}"},t.endpointsMethods={latest:"get",details:"get",status:"get",updateItem:"post",deleteItem:"delete",deleteImage:"delete",deleteCoupon:"put",getQuickOrderSettings:"get",offers:"get"},t.webEndpoints=["latest"],t.latestCart=null,t.after_init(),salla.event.on("api::initiated",(function(){return salla.api.cart.getCurrentCartId(!1,"api::initiated")})),salla.event.on("auth::token.fetched",t._checkCurrentCart),salla.event.on("auth::token.invalid",t._checkCurrentCart),salla.event.on("auth::verified",(function(){return salla.api.cart.getCurrentCartId(!0,"auth::verified")}),{async:!0}),salla.event.on("profile::info.fetched",t._checkCurrentCart),salla.event.on("twilight::error",(function(e){return(e.includes("Cart not available")||e.includes("السلة غير متاحة"))&&salla.cart.api.reset()}));return t}t.prototype._checkCurrentCart=function(){var e,t;var r=salla.storage.get("cart"),n=(e=salla.config.get("user"))===null||e===void 0?void 0:e.id,a=(t=salla.config.get("store"))===null||t===void 0?void 0:t.id;r&&r.id&&(r.user_id!==n||r.store_id!==a)&&(salla.log("cart",{user_id:r.user_id,store_id:r.store_id}),salla.log("current",{user_id:n,store_id:a}),salla.log("Api:: case2 => The cart is not belong to current "+(r.user_id!==n?"user":"store")+"!"),salla.cart.api.reset())};t.prototype.getCurrentCartId=function(e,t){if(e===void 0){e=!1}if(t===void 0){t="getCurrentCartId"}return __awaiter(this,void 0,void 0,(function(){var r,n;return __generator(this,(function(a){switch(a.label){case 0:if(!e){if(salla.cart.api.latestCart)return[2,salla.cart.api.latestCart.cart.id];r=salla.storage.get("cart.id");if(r)return[2,r]}return[4,salla.cart.api.latest(t)];case 1:n=a.sent();return[2,(salla.cart.api.latestCart=n.data,salla.cart.api.latestCart.cart.id)]}}))}))};t.prototype.getUploadImageEndpoint=function(e){return salla.url.api(this.getUrl("uploadImage",e||salla.storage.get("cart.id")))};t.prototype.latest=function(e){if(e===void 0){e="direct"}return this.request("latest",{params:{source:"",callerName:e}}).then((function(e){return salla.storage.set("cart",e.data.cart),salla.event.cart.latestFetched(e),e})).catch((function(e){throw salla.storage.set("cart",""),salla.event.cart.latestFailed(e),e}))};t.prototype.details=function(e,t){if(t===void 0){t=[]}return __awaiter(this,void 0,void 0,(function(){var r;return __generator(this,(function(n){switch(n.label){case 0:r=e;if(r)return[3,2];return[4,salla.api.cart.getCurrentCartId(!1,"salla.api.cart.details")];case 1:r=n.sent();n.label=2;case 2:return[2,(e=r,this.request(["details",e],{params:{with:t}}).then((function(e){return salla.cart.event.detailsFetched(e),e})).catch((function(e){throw salla.cart.event.detailsNotFetched(e),e})))]}}))}))};t.prototype.quickAdd=function(e,t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){return[2,this.addItem({id:e,quantity:t,endpoint:"quickAdd"})]}))}))};t.prototype.addItem=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r,n,a;return __generator(this,(function(i){switch(i.label){case 0:t=this.getCartPayload(e);if(!t.id){r='There is no product "id"!';return[2,(salla.cart.event.itemAddedFailed(r),salla.api.errorPromise(r))]}n=salla.form.getPossibleValue(t.payload,["endpoint"]);n&&["addItem","quickAdd"].includes(n)||(n=salla.form.getPossibleValue(t.payload,["quantity","donating_amount"])?"addItem":"quickAdd");return[4,salla.api.cart.getCurrentCartId(!1,"salla.api.cart.addItem")];case 1:a=i.sent();return[2,this.request([n,a,t.id],t.payload).then((function(e){return salla.cart.api.addToCartTries=0,salla.cart.event.itemAdded(e,t.id),e})).catch((function(r){if(!salla.cart.api.addToCartTries)return salla.cart.api.addToCartTries++,salla.cart.reset(),salla.cart.api.addItem(e);throw salla.cart.event.itemAddedFailed(r,t.id),r}))]}}))}))};t.prototype.deleteItem=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r,n;return __generator(this,(function(a){switch(a.label){case 0:t=this.getCartPayload(e);if(!t.id){r='There is no "id"!';return[2,(salla.cart.event.itemDeletedFailed(r),salla.api.errorPromise(r))]}return[4,salla.api.cart.getCurrentCartId(!1,"salla.api.cart.deleteItem")];case 1:n=a.sent();return[2,this.request(["deleteItem",n,t.id]).then((function(e){return salla.cart.event.itemDeleted(e,t.id),e})).catch((function(e){throw salla.cart.event.itemDeletedFailed(e,t.id),e}))]}}))}))};t.prototype.updateItem=function(e){var t;return __awaiter(this,void 0,void 0,(function(){var r,n,a;return __generator(this,(function(i){switch(i.label){case 0:r=this.getCartPayload(e);if(!r.id){n='There is no "id"!';return[2,(salla.cart.event.itemUpdatedFailed(n),salla.api.errorPromise(n))]}return[4,salla.api.cart.getCurrentCartId(!1,"salla.api.cart.updateItem")];case 1:a=i.sent();return[2,("Object"===((t=r.payload.constructor)===null||t===void 0?void 0:t.name)?r.payload._method="PUT":r.payload.append("_method","PUT"),this.request(["updateItem",a,r.id],r.payload).then((function(e){return salla.cart.event.itemUpdated(e,r.id),e})).catch((function(e){throw salla.cart.event.itemUpdatedFailed(e,r.id),e})))]}}))}))};t.prototype.deleteImage=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r;return __generator(this,(function(n){switch(n.label){case 0:if(!(e=salla.form.getPossibleValue(e,["id","image_id","photo_id"]))){t='There is no "id"!';return[2,(salla.cart.event.imageNotDeleted(t),salla.api.errorPromise(t))]}return[4,salla.api.cart.getCurrentCartId(!1,"salla.api.cart.deleteImage")];case 1:r=n.sent();return[2,this.request(["deleteImage",r,e]).then((function(t){return salla.cart.event.imageDeleted(t,e),t})).catch((function(t){throw salla.cart.event.imageNotDeleted(t,e),t}))]}}))}))};t.prototype.status=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r,n,a,i;return __generator(this,(function(o){switch(o.label){case 0:t=(new Date).getTime(),r=Math.random().toString(36).substring(2,15);n=this.request;a=["status"];i=e;if(i)return[3,2];return[4,salla.api.cart.getCurrentCartId(!1,"salla.api.cart.status")];case 1:i=o.sent();o.label=2;case 2:return[2,n.apply(this,[a.concat([i]),{params:{has_apple_pay:salla.helpers.hasApplePay(),"s-hash":"".concat(r,"_").concat(t)}}])]}}))}))};t.prototype.submit=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:if(salla.config.isGuest())return[2,(salla.log("it looks that the current user is not logged-in, lets login then submit"),salla.cart.loginOnCartPage())];e=this.status;return[4,salla.api.cart.getCurrentCartId(!1,"salla.api.cart.submit")];case 1:e.apply(this,[t.sent()]).then((function(e){var t;var r=(t=e.data.next_step)===null||t===void 0?void 0:t.to;if(r||(window.history.pushState({},"",salla.url.addParamToUrl("reload","empty_next_step")),window.history.pushState({},"",salla.url.addParamToUrl("acitve",!1===e.data.active?"false":"true_or_undfined")),salla.cart.reset(),window.location.reload()),!["checkout","refresh","login"].includes(r)){var n="Can't find next_step );";throw salla.cart.reset(),salla.cart.event.submitFailed(n),n}return salla.cart.event.submitted(e),"login"===r?salla.cart.loginOnCartPage():"checkout"===r?window.location.href=e.data.next_step.url+(salla.helpers.hasApplePay()?"?has_apple_pay=true":""):(window.history.pushState({},"",salla.url.addParamToUrl("reload","refresh")),void window.location.reload())})).catch((function(e){var t,r;salla.cart.api.tries=salla.cart.api.tries||0,salla.cart.reset();var n=404===((r=(t=e===null||e===void 0?void 0:e.response)===null||t===void 0?void 0:t.data)===null||r===void 0?void 0:r.status);if(n&&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 n&&salla.error(salla.lang.get("pages.checkout.try_again")),salla.cart.event.submitFailed(e),e}));return[2]}}))}))};t.prototype.getCartPayload=function(e){var t=(e===null||e===void 0?void 0:e.data)||("object"==typeof e?e:void 0);return e=t?salla.form.getPossibleValue(t,["prod_id","product_id","item_id","id"]):e,t="object"==typeof t?t:void 0,{id:e,payload:t}};t.prototype.normalRequest=function(t,r,n){var a=this;if(r===void 0){r=void 0}if(n===void 0){n=null}return e.prototype.normalRequest.call(this,t,r,n).catch((function(e){return __awaiter(a,void 0,void 0,(function(){var t;return __generator(this,(function(r){throw 403===((t=e===null||e===void 0?void 0:e.response)===null||t===void 0?void 0:t.status)&&(this.reset(),salla.error(salla.lang.get("pages.checkout.try_again"))),e}))}))}))};t.prototype.reset=function(){salla.api.cart.latestCart=null,salla.storage.remove("cart"),salla.cart.event.successReset()};t.prototype.addCoupon=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r;return __generator(this,(function(n){switch(n.label){case 0:if(e=e.data||e,!(e=salla.form.getPossibleValue(e,["coupon"]))){t=new Error('There is no "Coupon Code"!');return[2,(t.name="EmptyCoupon",salla.event.cart.couponAdditionFailed(t),salla.api.errorPromise(t))]}return[4,salla.cart.api.getCurrentCartId(!1,"salla.api.cart.addCoupon")];case 1:r=n.sent();return[2,this.request(["addCoupon",r],{coupon:e}).then((function(e){return salla.event.cart.couponAdded(e,r),e})).catch((function(e){throw salla.event.cart.couponAdditionFailed(e,r),e}))]}}))}))};t.prototype.deleteCoupon=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:return[4,salla.cart.api.getCurrentCartId(!1,"salla.api.cart.deleteCoupon")];case 1:e=t.sent();return[2,this.request(["deleteCoupon",e],{}).then((function(t){return salla.event.cart.couponDeleted(t,e),t})).catch((function(t){throw salla.event.cart.couponDeletionFailed(t,e),t}))]}}))}))};t.prototype.getQuickOrderSettings=function(){return this.request("getQuickOrderSettings").then((function(e){return salla.event.cart.quickOrderSettingFetched(e),e})).catch((function(e){throw salla.event.cart.quickOrderSettingFailed(e),e}))};t.prototype.createQuickOrder=function(e){return this.request("createQuickOrder",e).then((function(e){return salla.event.cart.quickOrderSucceeded(e),e})).catch((function(e){throw salla.event.cart.quickOrderFailed(e),e}))};t.prototype.priceQuote=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r,n,a;return __generator(this,(function(i){switch(i.label){case 0:if(!salla.config.isGuest())return[3,1];t=(salla.auth.api.setAfterLoginEvent("cart::priceQuote",e),void salla.event.dispatch("login::open"));return[3,4];case 1:r=this.request;n=["priceQuote"];a=e;if(a)return[3,3];return[4,salla.api.cart.getCurrentCartId(!1,"salla.api.cart.priceQuote")];case 2:a=i.sent();i.label=3;case 3:t=r.apply(this,[n.concat([a])]).then((function(e){return salla.cart.api.reset(),salla.event.cart.priceQuoteSucceeded(e).then((function(){return setTimeout((function(){return window.location.href=salla.url.get("/")}),1e3),e}))})).catch((function(e){return salla.event.cart.priceQuoteFailed(e).then((function(){var t;throw 404===((t=e.error)===null||t===void 0?void 0:t.code)&&window.location.reload(),e}))}));i.label=4;case 4:return[2,t]}}))}))};t.prototype.loginOnCartPage=function(){salla.auth.setCanRedirect(!1),salla.event.dispatch("login::open"),salla.auth.event.onLoggedIn((function(e){salla.event.dispatch("login::close"),salla.cart.submit()}))};t.prototype.offers=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:return[4,salla.cart.api.getCurrentCartId(!1,"salla.api.cart.offers")];case 1:e=t.sent();return[2,this.request(["offers",e]).then((function(e){return salla.event.cart.offersFetched(e),e})).catch((function(e){throw salla.event.cart.offersFailed(e),e}))]}}))}))};return t}(h);var g=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="loyalty",t.endpoints={getProgram:"loyalty",exchange:"loyalty/exchange",reset:"loyalty/exchange"},t.endpointsMethods={getProgram:"get",reset:"put"},t.after_init();return t}t.prototype.getProgram=function(){return this.request("getProgram").then((function(e){return salla.loyalty.event.programFetched(e),e})).catch((function(e){throw salla.loyalty.event.programNotFetched(e),e}))};t.prototype.exchange=function(e,t){if(t===void 0){t=null}return __awaiter(this,void 0,void 0,(function(){var r,n,a;return __generator(this,(function(i){switch(i.label){case 0:if(!(e=salla.form.getPossibleValue(e,["id","loyalty_prize_id","prize_id"]))){r="Unable to find cart id. Please provide one.";return[2,(salla.loyalty.event.exchangeFailed(r),salla.api.errorPromise(r))]}n=t;if(n)return[3,2];return[4,salla.cart.getCurrentCartId(!1,"salla.api.loyalty.exchange")];case 1:n=i.sent();i.label=2;case 2:if(!(t=n)){a="Unable to find cart id. Please provide one.";return[2,(salla.loyalty.event.exchangeFailed(a),salla.api.errorPromise(a))]}return[2,this.request("exchange",{loyalty_prize_id:e,cart_id:t}).then((function(t){return salla.loyalty.event.exchangeSucceeded(t,e),t})).catch((function(t){throw salla.loyalty.event.exchangeFailed(t,e),t}))]}}))}))};t.prototype.reset=function(e){if(e===void 0){e=null}return __awaiter(this,void 0,void 0,(function(){var t,r;return __generator(this,(function(n){switch(n.label){case 0:t=e;if(t)return[3,2];return[4,salla.cart.getCurrentCartId(!1,"salla.api.loyalty.reset")];case 1:t=n.sent();n.label=2;case 2:if(!(e=t)){r="Unable to find cart id. Please provide one.";return[2,(salla.loyalty.event.resetFailed(r),salla.api.errorPromise(r))]}return[2,this.request("reset",{cart_id:e}).then((function(e){return salla.loyalty.event.resetSucceeded(e),e})).catch((function(e){throw salla.loyalty.event.resetFailed(e),e}))]}}))}))};return t}(h);var f=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="auth",t.canRedirect_=!0,t.afterLoginEvent={event:null,payload:null},t.endpoints={login:"auth/{type}/send_verification",resend:"auth/resend_verification",verify:"auth/{type}/verify",register:"auth/register",logout:"logout",refresh:"auth/refresh"},t.webEndpoints=["logout","auth/jwt","refresh"],t.endpointsMethods={logout:"get"},t.after_init();return t}t.prototype.setAfterLoginEvent=function(e,t){salla.api.auth.afterLoginEvent={event:e,payload:t}};t.prototype.setCanRedirect=function(e){salla.api.auth.canRedirect_=e};t.prototype.canRedirect=function(){return salla.api.auth.canRedirect_&&!salla.api.auth.afterLoginEvent.event};t.prototype.login=function(e){(e===null||e===void 0?void 0:e.data)&&(e=e.data);var t=salla.form.getPossibleValue(e,["type"]);if(!["email","mobile"].includes(t)){var r="Login type should be in: [email, mobile]";return salla.auth.event.codeNotSent(r),salla.api.errorPromise(r)}return this.request(["login",t],e).then((function(e){return salla.auth.event.codeSent(e,t),e})).catch((function(e){throw salla.auth.event.codeNotSent(e,t),e}))};t.prototype.verify=function(e,t){if(t===void 0){t=!0}return __awaiter(this,void 0,void 0,(function(){var r,n,a;return __generator(this,(function(i){switch(i.label){case 0:r=salla.form.getPossibleValue(e,["type"]);if(!r){n="Failed to know what's login type!";return[2,(salla.auth.event.verificationFailed(n),salla.api.errorPromise(n))]}t=!1!==salla.form.getPossibleValue(e,["supportWebAuth"])&&t,salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event);return[4,salla.auth.api.request(["verify",r],e)];case 1:a=i.sent();return[2,200!==(a===null||a===void 0?void 0:a.status)?(salla.auth.event.verificationFailed(a,r),salla.api.errorPromise(a)):salla.auth.api.handlAfterAuthenticatedResponse(a,t,r)]}}))}))};t.prototype.handlAfterAuthenticatedResponse=function(e,t,r){var n;return __awaiter(this,void 0,void 0,(function(){var a,i;return __generator(this,(function(o){switch(o.label){case 0:a="authenticated"===((n=e.data)===null||n===void 0?void 0:n.case);a&&salla.auth.event.tokenFetched(e.data.token);i=t;if(!i)return[3,2];return[4,salla.auth.api.request("auth/jwt")];case 1:i=o.sent();o.label=2;case 2:i,a&&salla.auth.event.loggedIn(e).then((function(){return salla.auth.api.afterUserLogin()}));return[4,salla.auth.event.verified(e,r)];case 3:return[2,(o.sent(),salla.api.successPromise(e))]}}))}))};t.prototype.resend=function(e){var t;return(e=e.data||e).type=e.type||"mobile","mobile"!==e.type||e.phone&&e.country_code?"email"!==e.type||e.email?this.request("resend",e).then((function(t){return salla.auth.event.codeSent(t,e),t})).catch((function(t){throw salla.auth.event.codeNotSent(t,e),t})):(salla.auth.event.codeNotSent(t="There is no email!",e),salla.api.errorPromise(t)):(salla.auth.event.codeNotSent(t="There is no phone or country_code!",e),salla.api.errorPromise(t))};t.prototype.register=function(e){var t;return e.data&&(t=e.element,e=e.data),salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event),this.request("register",e).then((function(e){var r;return __awaiter(this,void 0,void 0,(function(){var n;return __generator(this,(function(a){switch(a.label){case 0:salla.auth.event.registered.call(t,e);n="authenticated"===((r=e.data)===null||r===void 0?void 0:r.case);if(!n)return[3,2];salla.auth.event.tokenFetched(e.data.token);return[4,salla.auth.request("auth/jwt")];case 1:n=(a.sent(),salla.auth.event.loggedIn(e),salla.auth.api.afterUserLogin());a.label=2;case 2:return[2,(n,e)]}}))}))})).catch((function(e){throw salla.auth.event.registrationFailed.call(t,e),e}))};t.prototype.logout=function(e){if(e===void 0){e="twilight"}return salla.storage.clearAll(),salla.cookie.clearAll(),e=encodeURI(e),salla.auth.event.loggedOut().then((function(){var t=salla.url.get("logout?from=".concat(e));console.log("Going to ".concat(t,", to do any thing before this action use: salla.auth.even.onLoggedOut(()=>{...})"));try{location.href=t}catch(e){salla.log(e)}}))};t.prototype.refresh=function(){return this.request("refresh").then((function(e){return salla.auth.event.tokenFetched(e.data.token),e})).catch((function(e){throw salla.auth.event.refreshFailed(e),e}))};t.prototype.afterUserLogin=function(){this.afterLoginEvent.event&&salla.event.emit(this.afterLoginEvent.event,this.afterLoginEvent.payload)};return t}(h);var m=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="order",t.endpoints={cancel:"orders/cancel/{id}",createCartFromOrder:"reorder/{id}",sendInvoice:"orders/send/{id}",fetch:"orders"},t.endpointsMethods={createCartFromOrder:"get",fetch:"get"},t.after_init();return t}t.prototype.show=function(e){var t=salla.form.getPossibleValue((e===null||e===void 0?void 0:e.data)||e,["id","order_id"]);salla.event.dispatch("mobile::order.placed",{order_id:t}),location.href=salla.form.getPossibleValue((e===null||e===void 0?void 0:e.data)||e,["url"])};t.prototype.cancel=function(e){return e=e||Salla.config.get("page.id"),this.request(["cancel",e],{params:{has_apple_pay:salla.helpers.hasApplePay()}}).then((function(t){return salla.event.order.canceled(t,e),t})).catch((function(t){throw salla.event.order.notCanceled(t,e),t}))};t.prototype.createCartFromOrder=function(e){return e=e||salla.config.get("page.id"),this.request(["createCartFromOrder",e]).then((function(t){return salla.cart.reset(),salla.event.order.orderCreated(t,e),window.location.href=t.data.url,t})).catch((function(t){throw salla.event.order.orderCreationFailed(t,e),t}))};t.prototype.sendInvoice=function(e){var t=salla.form.getPossibleValue(e,["id"])||salla.config.get("page.id");if(!t||isNaN(t)){var r="There is no id!";return salla.order.event.invoiceNotSent(r),salla.api.errorPromise(r)}return this.request(["sendInvoice",t],e).then((function(e){return salla.event.order.invoiceSent(e,t),e})).catch((function(e){throw salla.event.order.invoiceNotSent(e,t),e}))};t.prototype.fetch=function(e){return this.request(["fetch"],{params:e}).then((function(e){return salla.event.order.ordersFetched(e),e})).catch((function(e){throw salla.event.order.ordersNotFetched(e),e}))};return t}(h);var v=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="product",t.previousQuery="",t.endpoints={getPrice:"products/{id}/price",availabilitySubscribe:"products/{id}/availability-notify",search:"products/search",details:"products/{product_id}/details",categories:"products/categories/{?id}",offers:"products/{product_id}/specialoffer",getSizeGuides:"products/{prod_id}/size-guides",giftDetail:"products/{product_id}/buy-as-gift",giftToCart:"products/{product_id}/buy-as-gift",giftImage:"products/buy-as-gift/image",buyNow:"products/{product_id}/buy-now",fetch:"products",fetchOptions:"products/options"},t.endpointsMethods={details:"get",giftDetail:"get",fetch:"get",offers:"get",fetchOptions:"get"},t.after_init();return t}t.prototype.getPrice=function(e){var t=e.data||e,r=salla.form.getPossibleValue(t,["id","prod_id","product_id"]);return this.request(["getPrice",r],"object"==typeof t?t:void 0).then((function(e){return salla.product.event.priceUpdated(e,r),e})).catch((function(e){throw salla.product.event.priceUpdateFailed(e,r),e}))};t.prototype.categories=function(e){return this.request(["categories",e||""],null,"get").then((function(e){return salla.product.event.categoriesFetched(e),e})).catch((function(e){throw salla.product.event.categoriesFailed(e),e}))};t.prototype.availabilitySubscribe=function(e){var t=e.data||e;return e=salla.form.getPossibleValue(t,["id","prod_id"]),this.request(["availabilitySubscribe",e],"object"==typeof t?t:void 0).then((function(t){return salla.product.event.availabilitySubscribed(t,e),t})).catch((function(t){throw salla.product.event.availabilitySubscribeFailed(t,e),t}))};t.prototype.search=function(e){var t;var r=e.data;if(r||(r={params:"string"==typeof e?{query:e}:e}),!(e=r instanceof FormData?r.get("query"):r.query||((t=r.params)===null||t===void 0?void 0:t.query))){var n='There is no "query"!';return salla.product.event.searchFailed(n),salla.api.errorPromise(n)}if(e===salla.api.product.previousQuery){var a="Query is same as previous one!";return salla.product.event.searchFailed(a),salla.api.product.previousQuery=null,salla.api.errorPromise(a)}return salla.api.product.previousQuery=e,this.request("search",r,"get").then((function(t){return salla.product.event.searchResults(t,e),t})).catch((function(t){throw salla.product.event.searchFailed(t,e),t}))};t.prototype.offers=function(e){if(!(e=salla.form.getPossibleValue((e===null||e===void 0?void 0:e.data)|e,["product_id","id"]))){var t='There is no "product_id"!';return salla.product.event.fetchOffersFailed(t),salla.api.errorPromise(t)}return this.request(["offers",e]).then((function(t){return salla.product.event.offersFetched(t,e),t})).catch((function(t){throw salla.product.event.fetchOffersFailed(t,e),t}))};t.prototype.getSizeGuides=function(e){return this.request("products/".concat(e,"/size-guides"),null,"get").then((function(t){return salla.product.event.sizeGuideFetched(t,e),t})).catch((function(t){throw salla.product.event.sizeGuideFetchFailed(t,e),t}))};t.prototype.getGiftDetails=function(e){return this.request(["giftDetail",e]).then((function(t){return salla.product.event.giftFetched(t,e),t})).catch((function(t){throw salla.product.event.giftFetchFailed(t,e),t}))};t.prototype.getDetails=function(e,t){if(t===void 0){t=[]}if(!Array.isArray(t)){var r="withItems should be array.";return salla.product.event.detailFetchFailed(r),salla.api.errorPromise(r)}if(!e){var n="productId is not passed.";return salla.product.event.detailFetchFailed(n),salla.api.errorPromise(n)}return this.request(["details",e],{params:{with:t}}).then((function(t){return salla.product.event.detailFetched(t,e),t})).catch((function(t){throw salla.product.event.availabilitySubscribeFailed(t,e),t}))};t.prototype.addGiftToCart=function(e,t,r){if(r===void 0){r=!1}return this.request(["giftToCart",e],t).then((function(t){return salla.product.event.addGiftToCartSucceeded(t,e),r&&(window.location.href=t.redirect),t})).catch((function(t){throw salla.product.event.addGiftToCartFailed(t,e),t}))};t.prototype.uploadGiftImage=function(e){return this.request("giftImage",e).then((function(e){return salla.product.event.giftImageUploadSucceeded(e),e})).catch((function(e){throw salla.product.event.giftImageUploadFailed(e),e}))};t.prototype.fetch=function(e){var t=this;if(!e.source){var r="Source cannot be empty. Please provide one.";return salla.product.event.productListFetchFailed(r),salla.api.errorPromise(r)}var n=!e.source_value,a="string"==typeof e.source_value&&"[]"===e.source_value,i=Array.isArray(e.source_value)&&!e.source_value.length;if((n||a||i)&&!["offers","latest","sales","wishlist","top-rated"].includes(e.source)){var o="Source value cannot be empty. Please provide one.";return salla.product.event.productListFetchFailed(o),salla.api.errorPromise(o)}if(["categories","brands","tags","selected"].includes(e.source)&&!Array.isArray(e.source_value)){var s="SourceValue type error. Expected an array.";return salla.product.event.productListFetchFailed(s),salla.api.errorPromise(s)}if("search"===e.source&&"string"!=typeof e.source_value){var l="SourceValue type error. Expected a string.";return salla.product.event.productListFetchFailed(l),salla.api.errorPromise(l)}if("related"===e.source&&isNaN(e.source_value)){var c="SourceValue type error. Expected a number.";return salla.product.event.productListFetchFailed(c),salla.api.errorPromise(c)}return this.request(this.endpoints.fetch,{params:e},"get").then((function(r){return __awaiter(t,void 0,void 0,(function(){var t,n;return __generator(this,(function(a){switch(a.label){case 0:if(!(salla.product.event.productListFetchSucceeded(r),e.includes&&e.includes.includes("options")&&r.data))return[3,2];t=r.data.map((function(e){return e.id}));return[4,this.fetchOptions(t)];case 1:n=a.sent();this.updateProductOptions(r.data,n.data);a.label=2;case 2:return[2,r]}}))}))})).catch((function(e){throw salla.product.event.productListFetchFailed(e),e}))};t.prototype.updateProductOptions=function(e,t){var r=new Map(t.map((function(e){return[e.id,e.options]})));for(var n=0,a=e;n<a.length;n++){var i=a[n];i.options=r.get(i.id)}};t.prototype.fetchOptions=function(e){if(!e||0===e.length){var t="At least one product ID is required. Please provide a valid list of product IDs.";return salla.product.event.productOptionsNotFetched(t),salla.api.errorPromise(t)}var r={selected:e};return this.request(this.endpoints.fetchOptions,{params:r},"get").then((function(e){return salla.product.event.productOptionsFetched(e),e})).catch((function(e){throw salla.product.event.productOptionsNotFetched(e),e}))};return t}(h);var y=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="profile",t.endpoints={info:"auth/user",update:"profile/update",updateContacts:"profile/contacts/update",updateSettings:"profile/settings",verify:"profile/verify",delete:"profile"},t.endpointsMethods={delete:"delete"},t.after_init();return t}t.prototype.info=function(){return this.request("info",null,"get").then((function(e){var t={id:e.data.id,type:"user",email:e.data.email,mobile:e.data.phone.code+e.data.phone.number,country_code:e.data.phone.country,language_code:e.data.language,currency_code:e.data.currency,notifications:e.data.notifications,pending_orders:e.data.pending_orders,avatar:e.data.avatar,first_name:e.data.first_name,last_name:e.data.last_name,fetched_at:Date.now()};return salla.config.set("user",t),salla.storage.set("user",t),salla.profile.event.infoFetched(e),e})).catch((function(e){throw salla.profile.event.infoNotFetched(e),e}))};t.prototype.update=function(e){return this.request("update",e).then((function(e){return salla.profile.event.updated(e),e})).catch((function(e){throw salla.event.profile.updateFailed(e),e}))};t.prototype.updateContacts=function(e){return this.request("updateContacts",e).then((function(e){return salla.profile.event.verificationCodeSent(e),e})).catch((function(e){throw salla.event.profile.updateContactsFailed(e),e}))};t.prototype.verify=function(e){return this.request("verify",e).then((function(e){return salla.profile.event.verified(e),e})).catch((function(e){throw salla.event.profile.unverified(e),e}))};t.prototype.updateSettings=function(e){return this.request("updateSettings",e).then((function(e){return salla.event.profile.settingsUpdated(e),e})).catch((function(e){throw salla.event.profile.updateSettingsFailed(e),e}))};t.prototype.delete=function(){return this.request("delete").then((function(e){return salla.storage.clearAll(),salla.cookie.clearAll(),salla.event.profile.deleted(e),window.location.href=salla.url.get("logout"),e})).catch((function(e){throw salla.event.profile.notDeleted(e),e}))};return t}(h);var w=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="comment",t.endpoints={addComment:"{type}/{id}/comments",comments:"/comments"},t.after_init();return t}t.prototype.add=function(e){if((e===null||e===void 0?void 0:e.data)&&(e=e.data),"string"==typeof(e=this.getCommentPayload(e,!0)))return salla.event.comment.additionFailed(e),salla.api.errorPromise(e);if(!e.comment){var t="can't find comment content!";return salla.event.comment.additionFailed(t),salla.api.errorPromise(t)}return this.request(["addComment",e.type,e.id],{comment:e.comment}).then((function(t){return salla.event.comment.added(t,e.id),t})).catch((function(t){throw salla.event.comment.additionFailed(t,e.id),t}))};t.prototype.getCommentPayload=function(e,t){if(t===void 0){t=!1}var r={};if(["id","type","comment","per_page","page","sort"].forEach((function(t){var n=salla.form.getPossibleValue(e,[t]);n&&(r[t]=n)})),!t){var n=e.ids;if(n&&(r.ids=Array.isArray(n)?n:[n]),!r.ids||!r.ids.length)return"Failed to get ids!"}return r.type&&["products","pages","product","page"].includes(r.type)?(r.type+=["product","page"].includes(r.type)?"s":"",r):"Failed to get type one of:(products, product, page, pages)!"};t.prototype.fetchComments=function(e){if("string"==typeof(e=this.getCommentPayload(e)))return salla.event.comment.fetchFailed(e),salla.api.errorPromise(e);var t={per_page:e.per_page||5,page:e.page||1,type:e.type,ids:e.ids};return e.sort&&(t.sort=e.sort),this.request(["comments"],{params:t},"get").then((function(t){return salla.event.comment.fetched(t,e),t})).catch((function(t){throw salla.event.comment.fetchFailed(t,e),t}))};t.prototype.getPageComments=function(e,t,r,n){if(t===void 0){t=1}if(r===void 0){r=5}return this.fetchComments({ids:[e],type:"pages",page:t,per_page:r,sort:n})};t.prototype.getProductComments=function(e,t,r,n){if(t===void 0){t=1}if(r===void 0){r=5}return this.fetchComments({ids:[e],type:"products",page:t,per_page:r,sort:n})};return t}(h);var b=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="currency",t.endpoints={change:"/",list:"currencies"},t.endpointsMethods={change:"get",list:"get"},t.webEndpoints=["change"],t.after_init();return t}t.prototype.change=function(e){if(!(e=salla.form.getPossibleValue(e.data||e,["currency","code"]))){var t="Can't find currency code!";return salla.currency.event.failed(t),salla.api.errorPromise(t)}return this.request("change",{params:{change_currency:"",currency:e}}).then((function(t){return salla.cookie.set("fresh_summary",1),salla.storage.set("cart",""),salla.currency.event.changed(t,e),t})).catch((function(t){throw salla.currency.event.failed(t,e),t}))};t.prototype.list=function(){return this.request("list").then((function(e){return salla.currency.event.fetched(e),e})).catch((function(e){throw salla.currency.event.failedToFetch(e),e}))};return t}(h);var F=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="document";return t}return t}(h);var _=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="rating",t.endpoints={store:"rating/store",products:"rating/products",shipping:"rating/shipping",order:"rating/{order_id}"},t.endpointsMethods={order:"get"},t.after_init();return t}t.prototype.order=function(e){var t="object"==typeof e?e:{},r=salla.form.getPossibleValue((e===null||e===void 0?void 0:e.data)||e,["order_id","id"]);if(!r){var n='There is no "order_id"!';return salla.event.rating.orderNotFetched(n),salla.api.errorPromise(n)}return this.request(["order",r],t).then((function(e){return salla.event.rating.orderFetched(e,r),e})).catch((function(e){throw salla.event.rating.orderNotFetched(e,r),e}))};t.prototype.store=function(e){if(!(e=(e===null||e===void 0?void 0:e.data)||e)){var t='There is no "data"!';return salla.event.rating.storeFailed(t),salla.api.errorPromise(t)}return this.request("store",e).then((function(t){return salla.event.rating.storeRated(t,e),t})).catch((function(t){throw salla.event.rating.storeFailed(t,e),t}))};t.prototype.products=function(e){if(!(e=(e===null||e===void 0?void 0:e.data)||e)){var t='There is no "data"!';return salla.event.rating.productsFailed(t),salla.api.errorPromise(t)}return this.request("products",e).then((function(t){return salla.event.rating.productsRated(t,e),t})).catch((function(t){throw salla.event.rating.productsFailed(t,e),t}))};t.prototype.shipping=function(e){if(!(e=(e===null||e===void 0?void 0:e.data)||e)){var t='There is no "data"!';return salla.event.rating.shippingFailed(t),salla.api.errorPromise(t)}return this.request("shipping",e).then((function(t){return salla.event.rating.shippingRated(t,e),t})).catch((function(t){throw salla.event.rating.shippingFailed(t,e),t}))};return t}(h);var S=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="wishlist",t.endpoints={add:"products/favorites/{id}",remove:"products/favorites/{id}"},t.endpointsMethods={remove:"delete"},t.after_init();return t}t.prototype.toggle=function(e){return salla.storage.get("salla::wishlist",[]).includes(e)?this.remove(e):this.add(e)};t.prototype.add=function(e){var t=this;var r;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(r=salla.lang.get("common.messages.must_login")),salla.error(r),salla.api.errorPromise(r)):(e=salla.form.getPossibleValue((e===null||e===void 0?void 0:e.data)||e,["product_id","id"]))?this.request(["add",e]).then((function(r){return t.updateWishlistStorage(e),salla.wishlist.event.added(r,e),r})).catch((function(t){throw salla.wishlist.event.additionFailed(t,e),t})):(salla.wishlist.event.additionFailed(r="Failed to get product id!"),salla.api.errorPromise(r))};t.prototype.remove=function(e){var t=this;var r;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(r=salla.lang.get("common.messages.must_login")),salla.error(r),salla.api.errorPromise(r)):(e=salla.form.getPossibleValue((e===null||e===void 0?void 0:e.data)||e,["product_id","id"]))?this.request(["remove",e]).then((function(r){return t.updateWishlistStorage(e,!1),salla.wishlist.event.removed(r,e),r})).catch((function(t){throw salla.wishlist.event.removingFailed(t,e),t})):(salla.wishlist.event.removingFailed(r="Failed to get id!"),salla.api.errorPromise(r))};t.prototype.updateWishlistStorage=function(e,t){if(t===void 0){t=!0}var r=salla.storage.get("salla::wishlist",[]);t?r.push(e):r.splice(r.indexOf(e),1),salla.storage.set("salla::wishlist",r)};return t}(h);var q=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="scopes",t.endpoints={get:"scopes",change:"scopes",getProductAvailability:"scopes/availability?product_id={id}"},t.after_init();return t}t.prototype.get=function(){return this.request("scopes",null,"get").then((function(e){return salla.scope.event.fetched(e),e})).catch((function(e){throw salla.scope.event.notFetched(e),e}))};t.prototype.change=function(e){return this.request("scopes",e).then((function(e){return salla.scope.event.changeSucceeded(e),e})).catch((function(e){throw salla.scope.event.changeFailed(e),e}))};t.prototype.getProductAvailability=function(e){if(e===void 0){e=null}return this.request("scopes/availability?product_id=".concat(e),null,"get").then((function(t){return salla.scope.event.productAvailabilityFetched(t,e),t})).catch((function(e){throw salla.scope.event.productAvailabilityNotFetched(e),e}))};return t}(h);var C=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="booking",t.endpoints={add:"cart/booking/product/{id}"},t.endpointsMethods={add:"get"};return t}t.prototype.add=function(e,t){if(t===void 0){t=!0}return __awaiter(this,void 0,void 0,(function(){var r;return __generator(this,(function(n){if(!e){r="Please provide product id.";return[2,(salla.booking.event.additionFailed(r),salla.api.errorPromise(r))]}return[2,this.request(["add",e]).then((function(e){return salla.booking.event.added(e),t&&"booking"===e.data.redirect.to&&(window.location.href=e.data.redirect.url),e})).catch((function(e){throw salla.booking.event.additionFailed(e),e}))]}))}))};return t}(h);var P=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="landing",t.endpoints={getDetails:"landing/{landing_page_id}",createCartFromPage:"landing/{landing_page_id}",breadcrumbs:"breadcrumbs"},t.endpointsMethods={getDetails:"get",breadcrumbs:"get"},t.after_init();return t}t.prototype.getDetails=function(e){if(!e){var t="page landing id not passed";return salla.event.landing.getDetailsFailed(t),salla.api.errorPromise(t)}return this.request(["getDetails",e]).then((function(t){return salla.event.landing.detailsFetched(t,e),t})).catch((function(t){throw salla.event.landing.getDetailsFailed(t,e),t}))};t.prototype.createCartFromPage=function(e){if(!e){var 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",e),salla.event.dispatch("login::open"),salla.api.successPromise("")):this.request(["createCartFromPage",e]).then((function(t){return salla.event.landing.orderCreated(t,e).then((function(){return location.href=t.data.url})),t})).catch((function(t){throw salla.event.landing.orderCreationFailed(t,e),t}))};t.prototype.fetchBreadcrumbs=function(e){if(!e.page){var 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"===e.page&&!e.id&&!e.parent_id){var r="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(r),salla.api.errorPromise(r)}if(["product.index","customer.orders.single","product.index.tag","page-single","landing-page","brands.single","blog.single","blog.index.author","blog.index.category","blog.index.tag"].includes(e.page)&&!e.id){var n="The 'id' parameter is required when the 'page' parameter is set to ".concat(e.page,". Please provide valid value for the 'ID' parameter.");return salla.event.landing.breadcrumbFetchFailed(n),salla.api.errorPromise(n)}return this.request("breadcrumbs",{params:e}).then((function(e){return salla.event.landing.breadcrumbFetched(e),e})).catch((function(e){throw salla.event.landing.breadcrumbFetchFailed(e),e}))};return t}(h);var A=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="notifications",t.endpoints={fetch:"notifications"},t.endpointsMethods={fetch:"get"},t.after_init();return t}t.prototype.fetch=function(e){return this.request(["fetch"],{params:e}).then((function(e){return salla.event.notifications.fetched(e),e})).catch((function(e){throw salla.event.notifications.fetchFailed(e),e}))};return t}(h);var x=function(){function e(){var e=this;salla.event.on("twilight::before.ready",(function(t){return e.initiateRequest(t)})),salla.event.on("profile::info.fetched",(function(t){return e.setCurrencyAndLanguage(t)})),salla.event.on("auth::token.fetched",(function(t){salla.storage.set("token",t),e.setToken(t)})),salla.event.on("auth::token.invalid",(function(){salla.storage.remove("user"),salla.storage.remove("token")})),this.notifier_handler_disabled=!1,this.axios=axios.create({headers:{common:{"X-Requested-With":"XMLHttpRequest","S-SOURCE":"twilight","S-APP-VERSION":"v2.0.0","S-APP-OS":"browser","cache-control":"no-cache"}}})}e.prototype.getHeaders=function(){return this.axios.defaults.headers.common};e.prototype.setHeaders=function(e){var t=this;return Object.entries(e).forEach((function(e){return t.setHeader(e[0],e[1])})),this};e.prototype.setHeader=function(e,t){return salla.infiniteScroll.fetchOptions.headers[e]=this.axios.defaults.headers.common[e]=t,this};e.prototype.withoutNotifier=function(e){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(r){switch(r.label){case 0:this.notifier_handler_disabled=!0;return[4,e().finally((function(){t.notifier_handler_disabled=!1}))];case 1:return[2,r.sent()]}}))}))};e.prototype.initiateRequest=function(e){var t,r;return __awaiter(this,void 0,void 0,(function(){var n;return __generator(this,(function(a){switch(a.label){case 0:this.axios.defaults.baseURL=Salla.config.get("store.api",Salla.config.get("store.url")),this.setHeaders(__assign({"Store-Identifier":Salla.config.get("store.id"),currency:((t=e.user)===null||t===void 0?void 0:t.currency_code)||"SAR","accept-language":salla.lang.getLocale(),"s-user-id":(r=e.user)===null||r===void 0?void 0:r.id},e.headers||{}));n=salla.storage.get("scope");n&&this.setHeaders({"s-scope-type":n.type,"s-scope-id":n.id});return[4,this.injectTokenToTheRequests(e)];case 1:a.sent(),salla.storage.get("affiliate_code")&&this.setHeader("s-affiliate-code",salla.storage.get("affiliate_code"));return[2]}}))}))};e.prototype.injectTokenToTheRequests=function(e){var t;return __awaiter(this,void 0,void 0,(function(){var r,n,a,i,o,s,l,c,u;var d=this;return __generator(this,(function(f){switch(f.label){case 0:r=salla.storage.get("token"),n="guest"===e.user.type,a=(t=e.user)===null||t===void 0?void 0:t.id,i=salla.storage.get("user.id"),o=function(e){d.setToken(e),salla.event.emit("api::initiated")},s=function(){return __awaiter(d,void 0,void 0,(function(){var e;var t=this;return __generator(this,(function(r){switch(r.label){case 0:if(!(!n&&a))return[3,2];salla.log("Api:: case 1 => current is is guest & web session available");return[4,salla.auth.api.refresh().then((function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:return[4,salla.profile.info()];case 1:e.sent();return[2]}}))}))})).catch((function(){return salla.auth.event.tokenInvalid()}))];case 1:e=r.sent();return[3,3];case 2:e=salla.auth.event.tokenInvalid();r.label=3;case 3:e;return[2]}}))}))};if(!!r)return[3,2];salla.log("Api:: case 1 => current is is guest");return[4,s()];case 1:return[2,void f.sent()];case 2:l=o$1(r);if(!(Date.now()/1e3>l.exp))return[3,4];salla.log("Api:: case 2 => current user is logged-in and there is a token, but it's expired");return[4,s()];case 3:c=void f.sent();return[3,8];case 4:if(!(l.sub===a&&i===a&&i&&a))return[3,5];u=(salla.log("Api:: case 4 => current user is logged-in and there is a token, and it's not expired"),void o(r));return[3,7];case 5:salla.log("Api:: case 3 => there is a token and user in session/local missing or mismatch"),salla.log("sub:".concat(l.sub," userIdInWeb:").concat(a," userIdInStorage:").concat(i)),this.setHeader("Authorization","Bearer "+r);return[4,salla.profile.info().then((function(e){return __awaiter(d,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:return[4,salla.auth.api.request("auth/jwt")];case 1:e.sent(),o(r);return[2]}}))}))})).catch((function(){salla.log("Api:: case 3 => failed get fresh profile"),d.setHeader("Authorization",null),salla.auth.event.tokenInvalid()}))];case 6:u=void f.sent();f.label=7;case 7:c=u;f.label=8;case 8:return[2,c]}}))}))};e.prototype.setToken=function(e){return this.setHeader("Authorization","Bearer "+e),salla.event.emit("api::token.injected",e),this.token=e,this};e.prototype.setCurrencyAndLanguage=function(e){return this.setHeaders({currency:e.data.currency,"accept-language":e.data.language})};e.prototype.request=function(e,t,r,n){var a=this;if(t===void 0){t=void 0}if(r===void 0){r="get"}if(n===void 0){n={}}var i={endPoint:e,payload:t,method:r,options:n},o="undefined"!=typeof event?event.currentTarget:null,s=!1;return"SALLA-BUTTON"===(o===null||o===void 0?void 0:o.tagName)&&(s=!0),s&&(o===null||o===void 0?void 0:o.load()),this.axios[i.method](i.endPoint,i.payload,i.options).then((function(e){return s&&(o===null||o===void 0?void 0:o.stop()),e.data&&e.request&&(e=e.data),a.handleAfterResponseActions(e),e})).catch((function(e){throw s&&(o===null||o===void 0?void 0:o.stop()),salla.event.document.requestFailed(i,e),a.handleErrorResponse(e),e}))};e.prototype.handleAfterResponseActions=function(e){if(!e)return;var t=e.data,r=e.googleTags,n=r===void 0?null:r,a=t&&t.googleTags?t.googleTags:n;try{dataLayer&&a&&dataLayer.push(a)}catch(e){salla.logger.error(e.message)}this.fireEventsForResponse(e),this.showAlert(e)};e.prototype.fireEventsForResponse=function(e){var t,r;var n=(e===null||e===void 0?void 0:e.events)||((t=e.data)===null||t===void 0?void 0:t.events)||((r=e.error)===null||r===void 0?void 0:r.events);"string"==typeof n&&(n=JSON.parse(n)),n&&Object.keys(n).forEach((function(e){return salla.event.dispatch(e,n[e])}))};e.prototype.handleErrorResponse=function(e){if(e.response&&e.response.data)return e.response.data.error&&e.response.data.error.fields&&!this.notifier_handler_disabled?this.handleInvalidFields(e):this.handleAfterResponseActions(e.response.data)};e.prototype.showAlert=function(e){var t,r;if(e&&!this.notifier_handler_disabled)return e.case&&e.msg?salla.notify.fire(e.msg,e.case,e):e.hasOwnProperty("success")&&((t=e.data)===null||t===void 0?void 0:t.message)?salla.notify.fire((r=e.data)===null||r===void 0?void 0:r.message,e.success?salla.notify.types.success:salla.notify.types.error,e):e.error&&e.error.message&&"FORBIDDEN"!==e.error.message?salla.error(e.error.message,e):void 0};e.prototype.handleInvalidFields=function(e){var t=e.response.data.error.fields,r=[];Object.keys(t).forEach((function(e){var n=t[e];Array.isArray(n)?n.forEach((function(e){return r.push(e)})):r.push(n)}));var n=(r.length>1?"* ":"")+r.join("\n* ");salla.error(n,e)};e.prototype.isFastRequestsAllowed=function(){return Salla.config.get("fastRequests")};e.prototype.promise=function(e,t){if(t===void 0){t=!0}return new Promise((function(r,n){return t?r(e):n(e)}))};e.prototype.errorPromise=function(e){return this.promise(e,!1)};e.prototype.successPromise=function(e){return this.promise(e,!0)};return e}();var k=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="component",t.endpoints={getMenus:"menus/{headOrFoot}",reviews:"reviews"},t.endpointsMethods={getMenus:"get",reviews:"get"};return t}t.prototype.getMenus=function(e){if(e===void 0){e="header"}return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,this.request(["getMenus",e]).then((function(e){return salla.event.component.menuFetched(e),e})).catch((function(e){throw salla.event.component.menuFetchFailed(e),e}))]}))}))};t.prototype.getReviews=function(e){var t=e.per_page,r=t===void 0?5:t,n=e.type,a=n===void 0?"all":n,i=e.items;return __awaiter(this,void 0,void 0,(function(){var e,t,n,o,s;return __generator(this,(function(l){if(!a){e="Review type cannot be empty. Please provide one.";return[2,(salla.event.component.reviewsFetchFailed(e),salla.api.errorPromise(e))]}t=!i||"string"==typeof i&&"[]"===i||Array.isArray(i)&&!i.length;if(!new Set(["all","store","categories","products","json"]).has(a)){n="Invalid review type. Please provide a valid type.";return[2,(salla.event.component.reviewsFetchFailed(n),salla.api.errorPromise(n))]}if("all"!==a&&"store"!==a&&t){o="Items cannot be empty. Please provide one.";return[2,(salla.event.component.reviewsFetchFailed(o),salla.api.errorPromise(o))]}if(new Set(["products","categories"]).has(a)&&!Array.isArray(i)){s="Items value must be an array of ".concat(a," id for review type of ").concat(a,".");return[2,(salla.event.component.reviewsFetchFailed(s),salla.api.errorPromise(s))]}return[2,this.request(["reviews"],{params:{per_page:r,type:a,items:i}},"get").then((function(e){return salla.event.component.reviewsFetched(e),e})).catch((function(e){throw salla.event.component.reviewsFetchFailed(e),e}))]}))}))};return t}(h);var E=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="booking",t.endpoints={fetch:"advertisements"},t.endpointsMethods={fetch:"get"};return t}t.prototype.fetch=function(e){if(e===void 0){e=null}return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(r){t=e?{page:e}:{};return[2,this.request(["fetch"],{params:t}).then((function(e){return salla.event.advertisement.fetched(e),e})).catch((function(e){throw salla.event.advertisement.fetchFailed(e),e}))]}))}))};return t}(h);var T=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="navigation",t.endpoints={breadcrumbs:"breadcrumbs"},t.endpointsMethods={breadcrumbs:"get"},t.after_init();return t}t.prototype.fetchBreadcrumbs=function(e){if(!e.page){var 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(e.page)&&!e.id){var r="The 'id' parameter is required when the 'page' parameter is set to ".concat(e.page,". Please provide valid value for the 'ID' parameter.");return salla.event.navigation.breadcrumbFetchFailed(r),salla.api.errorPromise(r)}return this.request("breadcrumbs",{params:e}).then((function(e){return salla.event.navigation.breadcrumbFetched(e),e})).catch((function(e){throw salla.event.navigation.breadcrumbFetchFailed(e),e}))};return t}(h);var I=function(){function e(e){var t,r;"ready"!==D.status?e?(D.config.merge(e),(e===null||e===void 0?void 0:e.events)&&D.event.dispatchEvents(e===null||e===void 0?void 0:e.events),e._token&&salla.api.setHeader("X-CSRF-TOKEN",e._token),this.injectMaintenanceAlert(),this.injectTemplateStoreAlert(),this.injectThemePreviewAlert(),this.injectAppInstallAlert(),this.injectEditAlert(),((t=e===null||e===void 0?void 0:e.user)===null||t===void 0?void 0:t.language_code)&&salla.lang.setLocale((r=e===null||e===void 0?void 0:e.user)===null||r===void 0?void 0:r.language_code),salla.lang.loadStoreTranslations(),this.setSallaReady(e)):this.setSallaReady(e):salla.log("Trying to re-initiate Salla, while its status === 'ready'!")}e.prototype.injectMaintenanceAlert=function(){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((function(){return document.body.prepend(document.createElement("salla-maintenance-alert"))})))};e.prototype.injectTemplateStoreAlert=function(){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((function(){return document.body.append(document.createElement("salla-bottom-alert"))})))};e.prototype.injectAppInstallAlert=function(){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((function(){return document.body.append(document.createElement("salla-app-install-alert"))})))};e.prototype.injectThemePreviewAlert=function(){"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((function(){var e=document.createElement("div");e.id="s-theme_preview_bar",e.setAttribute("style","display: flex; justify-content: space-between; text-align: center; background-color: #232323; color: #fff; padding: 10px; font-size: 0.875rem; line-height: 1.25rem; position: relative;"),e.innerHTML='\n <div style="display:flex; align-items:center;">\n <img width="32" src="https://cdn.salla.network/images/logo/logo-light.svg">\n <span style="margin:0 10px;">'.concat(salla.lang.get("blocks.header.preview_mode"),': <span style="background:rgba(255,255,255,0.25);border-radius:15px; padding:2px 15px 4px">').concat(salla.config.get("theme.name"),'</span></span>\n </div>\n <a href="').concat(salla.url.get("preview_theme/cancel/preview"),'" style="line-height:32px; width:32px;"><i class="sicon-cancel"></i></a>\n '),document.body.prepend(e)})))};e.prototype.injectEditAlert=function(){var e=salla.config.get("edit");e&&(document.querySelector("#s-edit-alert")?salla.logger.warn("#s-edit-alert element Existed before!"):salla.lang.onLoaded((function(){var t=document.createElement("div");t.id="s-edit-alert",t.innerHTML='\n <a href="'.concat(e,'" style="display:block; background-color:').concat(salla.config.get("theme.color.primary","#5cd5c4"),"; color:").concat(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 ').concat(salla.lang.get("pages.products.quick_edit"),"\n </a>\n "),document.body.prepend(t)})))};e.prototype.handleElementAjaxRequest=function(e,t){var r=this;if(!(t instanceof HTMLFormElement||t instanceof HTMLAnchorElement))return salla.logger.warn("trying to call ajax from non Element!!"),!1;e.preventDefault();var n=t.getAjaxFormData(e),a=n.method?n.method.toLowerCase():void 0;salla.api.request(n.url,n.formData,a).then((function(e){return e.data&&e.request&&(e=e.data),salla.api.handleAfterResponseActions(e),r.callAjaxEvent(n.events.success,e,n.formData),e})).catch((function(e){throw salla.api.handleErrorResponse(e),r.callAjaxEvent(n.events.fail,e,n.formData),e}))};e.prototype.callAjaxEvent=function(e,t,r){if(e){if(r instanceof FormData){var n={};Array.from(r.entries()).forEach((function(e){n[e[0]]=e[1]})),r=n}window[e]?window[e](t,r):salla.event.dispatch(e,t,r)}};e.prototype.setSallaReady=function(e){D.event.dispatch("twilight::before.ready",e),D.status="ready",D.event.dispatch("twilight::initiated",e),window.dispatchEvent(new CustomEvent("twilight::initiated",{detail:e}))};return e}();D.status="loading",D.notify=o,D.lang=new(function(e){__extends(t,e);function t(t){var r=this;(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,r=e.call(this,t)||this,r.translationsLoaded=!1;return r}t.prototype.onLoaded=function(e){var t=this;return new Promise((function(r){if(t.translationsLoaded)return r(e?e():null);Salla.event.once("languages::translations.loaded",(function(){return r(e?e():null)}))}))};t.prototype.loadStoreTranslations=function(){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.".concat(this.hash)),this.messages&&(this.translationsLoaded=!0)&&e.prototype.setMessages.call(this,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/".concat(this.hash,".js"))):this.loadScript("https://cdn.salla.network/js/translations.js",!1)};t.prototype.setMessages=function(t){e.prototype.setMessages.call(this,t),salla.event.dispatch("languages::translations.loaded"),this.translationsLoaded=!0};t.prototype.loadScript=function(e,t){var r=this;if(t===void 0){t=!0}var n=document.createElement("script");n.src=e,n.onload=function(){var e;if(window.translations)return salla.storage.remove("s_translations"),salla.storage.set("s_translations",(e={},e[r.hash]=window.translations,e)),r.setMessages(window.translations);n.onerror()},n.onerror=function(){if(t)return salla.logger.warn("Failed to load Translations for store, lets try load it from CDN"),r.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)};t.prototype.getWithDefault=function(e,t,r,n){var a=this.get(e,r,n);return a!==e?a:t};t.prototype.get=function(t,r,n){var a=t;(window.translations||this.translationsLoaded)&&(a="trans."+t);var i=e.prototype.get.call(this,a,r,n);return i!==a?i:e.prototype.get.call(this,a,r,"en").replace(a,t)};t.prototype.set=function(e,t){return salla.helpers.setNested(this.messages["".concat(this.getLocale(),".trans")],e,t),this};t.prototype.add=function(e,t){var r=this;return Object.entries(t).forEach((function(t){return salla.helpers.setNested(r.messages[t[0]+".trans"],e,t[1])})),this};t.prototype.addBulk=function(e){var t=this;return Object.entries(e).forEach((function(e){var r=e[0],n=e[1];t.add(r,n)})),this};return t}(lang)),D.form=new(function(){function e(){}e.prototype.submit=function(e,t){var r,n,a,i;if(t===void 0){t=null}return __awaiter(this,void 0,void 0,(function(){var o,s,l;return __generator(this,(function(c){switch(c.label){case 0:o=t;if("SubmitEvent"===((r=t===null||t===void 0?void 0:t.constructor)===null||r===void 0?void 0:r.name)||"submit"===(t===null||t===void 0?void 0:t.type)){if(t.preventDefault(),"FORM"!==((n=t.target)===null||n===void 0?void 0:n.tagName))return[2,(Salla.logger.warn("Failed find the target element for submit action. make sure you submit a form element"),new Promise((function(){throw"Failed find the target element for submit action. make sure you submit a form element"})))];"SALLA-BUTTON"===((i=(a=t===null||t===void 0?void 0:t.submitter)===null||a===void 0?void 0:a.parentElement)===null||i===void 0?void 0:i.tagName)&&t.submitter.parentElement.load(),o=t.target.getElementSallaData(),salla.log("Data from element",o)}if(/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/gm.test(e))return[2,salla.api.request(e,o,"post").finally((function(){var e;loaderSupported&&((e=t===null||t===void 0?void 0:t.submitter)===null||e===void 0?void 0:e.parentElement.stop())}))];s=e.split("."),l=s.splice(-1);return[4,salla.call(s.join("."))[l](o).finally((function(){var e,r;return(r=(e=t===null||t===void 0?void 0:t.submitter)===null||e===void 0?void 0:e.parentElement)===null||r===void 0?void 0:r.stop()})).catch((function(e){throw salla.logger.warn(e),e}))];case 1:return[2,c.sent()]}}))}))};e.prototype.onSubmit=function(e,t){return salla.form.submit(e,t),!1};e.prototype.onChange=function(e,t){var r;return(t===null||t===void 0?void 0:t.currentTarget)?"FORM"!==((r=t===null||t===void 0?void 0:t.currentTarget)===null||r===void 0?void 0:r.tagName)||t.currentTarget.checkValidity()?(salla.form.submit(e,t.currentTarget.getElementSallaData()),!0):(salla.logger.warn("Trying to trigger '".concat(e,"' without filling required fields!")),!1):(salla.logger.warn("Trying to trigger '".concat(e,"' without event!")),!1)};e.prototype.getPossibleValue=function(e,t,r){if(r===void 0){r=!1}if(!e)return;if("object"!=typeof e)return e;var n;for(var a=0;a<t.length&&!(n=e[t[a]])&&!("undefined"!=typeof FormData&&e instanceof FormData&&(n=e.get(t[a])));a++);return n=n||e,"object"!=typeof n||r?n:void 0};return e}()),D.infiniteScroll=new(function(e){__extends(t,e);function t(t,r){var n=this;n=e.call(this,t,r)||this,n.options={path:".infinite-scroll-btn",history:"push",status:".infinite-scroll-status",append:".list-block"},n.fetchOptions={headers:{"S-INFINITE-SCROLL":!0,"S-Source":"twilight","cache-control":"no-cache",pragma:"no-cache"}},n.instances=[];return n}t.prototype.initiate=function(e,t,r,n){if(n===void 0){n=!1}n?((r=r||{}).fetchOptions=__assign(__assign({},this.fetchOptions),r.fetchOptions||{}),r.responseBody="json"):r=this.getCustomOptions(t,r);var a="string"!=typeof e?e:document.querySelector(e),i=r.path;if(!a||!i||"string"==typeof i&&!document.querySelector(i))return void Salla.logger.warn(a?"Path Option (a link that has next page link) Not Existed!":"Container For InfiniteScroll not Existed!");var o=new js(a,r);return o.on("scrollThreshold",Salla.infiniteScroll.event.scrollThreshold),o.on("request",Salla.infiniteScroll.event.request),o.on("load",Salla.infiniteScroll.event.load),o.on("append",Salla.infiniteScroll.event.append),o.on("error",Salla.infiniteScroll.event.error),o.on("last",Salla.infiniteScroll.event.last),o.on("history",Salla.infiniteScroll.event.history),this.instances.push(o),o};t.prototype.getCustomOptions=function(e,t){return(t="object"==typeof e&&e||t||this.options).fetchOptions=this.fetchOptions,t.path=t.path||this.options.path,t.button=t.button||t.path,t.status=t.status||this.options.status,t.hasOwnProperty("history")||(t.history=this.options.history),t.nextPage=t.nextPage||t.next_page,t.append="string"==typeof e&&e||t.append||this.options.append,t};t.prototype.loadNextPage=function(e){("string"!=typeof e?e:document.querySelector(e)).loadNextPage()};t.prototype.destroy=function(e){("string"!=typeof e?e:document.querySelector(e)).destroy()};return t}(d))(void 0,salla.event.infiniteScroll),D.api=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.auth=new f,t.cart=new p,t.loyalty=new g,t.order=new m,t.rating=new _,t.product=new v,t.profile=new y,t.comment=new w,t.currency=new b,t.document=new F,t.wishlist=new S,t.scope=new q,t.booking=new C,t.landing=new P,t.notifications=new A,t.component=new k,t.advertisement=new E,t.navigation=new T;return t}return t}(x)),["cart","auth","order","scope","rating","comment","loyalty","product","profile","currency","document","wishlist","booking","landing"].forEach((function(e){return D[e]=new d(D.api[e],D.event[e])})),D.call=function(e){var t=D,r=e.split(".");for(;r.length&&(t=t[r.shift()]););return t},D.init=function(e){return new I(e)},salla.event.once("twilight::init",salla.init),salla.event.once("twilight::api",(function(e){var t=e===null||e===void 0?void 0:e.events;t&&salla.event.dispatchEvents(t)})),D.success=D.notify.success,D.error=D.notify.error,D.versions.twilight="[VI]{version}[/VI]",D.onInitiated=function(e){return salla.event.once("twilight::initiated",e)},D.onReady=D.onReady||function(e){return new Promise((function(t){return"ready"===salla.status?t(e?e(salla.config.all()):salla.config.all()):D.onInitiated((function(r){return t(e?e(r):r)}))}))},window.dispatchEvent(new CustomEvent("salla::created"));var lazyload_min=createCommonjsModule((function(e,t){!function(t,r){e.exports=r()}(commonjsGlobal,(function(){function e(){return e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},e.apply(this,arguments)}var t="undefined"!=typeof window,r=t&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),n=t&&"IntersectionObserver"in window,a=t&&"classList"in document.createElement("p"),i=t&&window.devicePixelRatio>1,o={elements_selector:".lazy",container:r||t?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},s=function(t){return e({},o,t)},l=function(e,t){var r,n="LazyLoad::Initialized",a=new e(t);try{r=new CustomEvent(n,{detail:{instance:a}})}catch(e){(r=document.createEvent("CustomEvent")).initCustomEvent(n,!1,!1,{instance:a})}window.dispatchEvent(r)},c="src",u="srcset",d="sizes",f="poster",h="llOriginalAttrs",p="data",v="loading",g="loaded",m="applied",y="error",_="native",b="data-",w="ll-status",S=function(e,t){return e.getAttribute(b+t)},E=function(e){return S(e,w)},A=function(e,t){return function(e,t,r){var n="data-ll-status";null!==r?e.setAttribute(n,r):e.removeAttribute(n)}(e,0,t)},x=function(e){return A(e,null)},F=function(e){return null===E(e)},C=function(e){return E(e)===_},P=[v,g,m,y],O=function(e,t,r,n){e&&(void 0===n?void 0===r?e(t):e(t,r):e(t,r,n))},T=function(e,t){a?e.classList.add(t):e.className+=(e.className?" ":"")+t},k=function(e,t){a?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},L=function(e){return e.llTempImage},j=function(e,t){if(t){var r=t._observer;r&&r.unobserve(e)}},I=function(e,t){e&&(e.loadingCount+=t)},$=function(e,t){e&&(e.toLoadCount=t)},R=function(e){for(var t,r=[],n=0;t=e.children[n];n+=1)"SOURCE"===t.tagName&&r.push(t);return r},D=function(e,t){var r=e.parentNode;r&&"PICTURE"===r.tagName&&R(r).forEach(t)},q=function(e,t){R(e).forEach(t)},N=[c],M=[c,f],U=[c,u,d],H=[p],z=function(e){return!!e[h]},G=function(e){return e[h]},B=function(e){return delete e[h]},V=function(e,t){if(!z(e)){var r={};t.forEach((function(t){r[t]=e.getAttribute(t)})),e[h]=r}},W=function(e,t){if(z(e)){var r=G(e);t.forEach((function(t){!function(e,t,r){r?e.setAttribute(t,r):e.removeAttribute(t)}(e,t,r[t])}))}},K=function(e,t,r){T(e,t.class_applied),A(e,m),r&&(t.unobserve_completed&&j(e,t),O(t.callback_applied,e,r))},Q=function(e,t,r){T(e,t.class_loading),A(e,v),r&&(I(r,1),O(t.callback_loading,e,r))},J=function(e,t,r){r&&e.setAttribute(t,r)},Y=function(e,t){J(e,d,S(e,t.data_sizes)),J(e,u,S(e,t.data_srcset)),J(e,c,S(e,t.data_src))},X={IMG:function(e,t){D(e,(function(e){V(e,U),Y(e,t)})),V(e,U),Y(e,t)},IFRAME:function(e,t){V(e,N),J(e,c,S(e,t.data_src))},VIDEO:function(e,t){q(e,(function(e){V(e,N),J(e,c,S(e,t.data_src))})),V(e,M),J(e,f,S(e,t.data_poster)),J(e,c,S(e,t.data_src)),e.load()},OBJECT:function(e,t){V(e,H),J(e,p,S(e,t.data_src))}},Z=["IMG","IFRAME","VIDEO","OBJECT"],ee=function(e,t){!t||function(e){return e.loadingCount>0}(t)||function(e){return e.toLoadCount>0}(t)||O(e.callback_finish,t)},te=function(e,t,r){e.addEventListener(t,r),e.llEvLisnrs[t]=r},re=function(e,t,r){e.removeEventListener(t,r)},ne=function(e){return!!e.llEvLisnrs},ae=function(e){if(ne(e)){var t=e.llEvLisnrs;for(var r in t){var n=t[r];re(e,r,n)}delete e.llEvLisnrs}},ie=function(e,t,r){!function(e){delete e.llTempImage}(e),I(r,-1),function(e){e&&(e.toLoadCount-=1)}(r),k(e,t.class_loading),t.unobserve_completed&&j(e,r)},oe=function(e,t,r){var n=L(e)||e;ne(n)||function(e,t,r){ne(e)||(e.llEvLisnrs={});var n="VIDEO"===e.tagName?"loadeddata":"load";te(e,n,t),te(e,"error",r)}(n,(function(a){!function(e,t,r,n){var a=C(t);ie(t,r,n),T(t,r.class_loaded),A(t,g),O(r.callback_loaded,t,n),a||ee(r,n)}(0,e,t,r),ae(n)}),(function(a){!function(e,t,r,n){var a=C(t);ie(t,r,n),T(t,r.class_error),A(t,y),O(r.callback_error,t,n),r.restore_on_error&&W(t,U),a||ee(r,n)}(0,e,t,r),ae(n)}))},se=function(e,t,r){!function(e){return Z.indexOf(e.tagName)>-1}(e)?function(e,t,r){!function(e){e.llTempImage=document.createElement("IMG")}(e),oe(e,t,r),function(e){z(e)||(e[h]={backgroundImage:e.style.backgroundImage})}(e),function(e,t,r){var n=S(e,t.data_bg),a=S(e,t.data_bg_hidpi),o=i&&a?a:n;o&&(e.style.backgroundImage='url("'.concat(o,'")'),L(e).setAttribute(c,o),Q(e,t,r))}(e,t,r),function(e,t,r){var n=S(e,t.data_bg_multi),a=S(e,t.data_bg_multi_hidpi),o=i&&a?a:n;o&&(e.style.backgroundImage=o,K(e,t,r))}(e,t,r),function(e,t,r){var n=S(e,t.data_bg_set);if(n){var a=n.split("|"),i=a.map((function(e){return"image-set(".concat(e,")")}));e.style.backgroundImage=i.join(),""===e.style.backgroundImage&&(i=a.map((function(e){return"-webkit-image-set(".concat(e,")")})),e.style.backgroundImage=i.join()),K(e,t,r)}}(e,t,r)}(e,t,r):function(e,t,r){oe(e,t,r),function(e,t,r){var n=X[e.tagName];n&&(n(e,t),Q(e,t,r))}(e,t,r)}(e,t,r)},le=function(e){e.removeAttribute(c),e.removeAttribute(u),e.removeAttribute(d)},ce=function(e){D(e,(function(e){W(e,U)})),W(e,U)},ue={IMG:ce,IFRAME:function(e){W(e,N)},VIDEO:function(e){q(e,(function(e){W(e,N)})),W(e,M),e.load()},OBJECT:function(e){W(e,H)}},de=function(e,t){(function(e){var t=ue[e.tagName];t?t(e):function(e){if(z(e)){var t=G(e);e.style.backgroundImage=t.backgroundImage}}(e)})(e),function(e,t){F(e)||C(e)||(k(e,t.class_entered),k(e,t.class_exited),k(e,t.class_applied),k(e,t.class_loading),k(e,t.class_loaded),k(e,t.class_error))}(e,t),x(e),B(e)},fe=["IMG","IFRAME","VIDEO"],he=function(e){return e.use_native&&"loading"in HTMLImageElement.prototype},pe=function(e,t,r){e.forEach((function(e){return function(e){return e.isIntersecting||e.intersectionRatio>0}(e)?function(e,t,r,n){var a=function(e){return P.indexOf(E(e))>=0}(e);A(e,"entered"),T(e,r.class_entered),k(e,r.class_exited),function(e,t,r){t.unobserve_entered&&j(e,r)}(e,r,n),O(r.callback_enter,e,t,n),a||se(e,r,n)}(e.target,e,t,r):function(e,t,r,n){F(e)||(T(e,r.class_exited),function(e,t,r,n){r.cancel_on_exit&&function(e){return E(e)===v}(e)&&"IMG"===e.tagName&&(ae(e),function(e){D(e,(function(e){le(e)})),le(e)}(e),ce(e),k(e,r.class_loading),I(n,-1),x(e),O(r.callback_cancel,e,t,n))}(e,t,r,n),O(r.callback_exit,e,t,n))}(e.target,e,t,r)}))},ve=function(e){return Array.prototype.slice.call(e)},ge=function(e){return e.container.querySelectorAll(e.elements_selector)},me=function(e){return function(e){return E(e)===y}(e)},ye=function(e,t){return function(e){return ve(e).filter(F)}(e||ge(t))},_e=function(e,r){var a=s(e);this._settings=a,this.loadingCount=0,function(e,t){n&&!he(e)&&(t._observer=new IntersectionObserver((function(r){pe(r,e,t)}),function(e){return{root:e.container===document?null:e.container,rootMargin:e.thresholds||e.threshold+"px"}}(e)))}(a,this),function(e,r){t&&(r._onlineHandler=function(){!function(e,t){var r;(r=ge(e),ve(r).filter(me)).forEach((function(t){k(t,e.class_error),x(t)})),t.update()}(e,r)},window.addEventListener("online",r._onlineHandler))}(a,this),this.update(r)};return _e.prototype={update:function(e){var t,a,i=this._settings,o=ye(e,i);$(this,o.length),!r&&n?he(i)?function(e,t,r){e.forEach((function(e){-1!==fe.indexOf(e.tagName)&&function(e,t,r){e.setAttribute("loading","lazy"),oe(e,t,r),function(e,t){var r=X[e.tagName];r&&r(e,t)}(e,t),A(e,_)}(e,t,r)})),$(r,0)}(o,i,this):(a=o,function(e){e.disconnect()}(t=this._observer),function(e,t){t.forEach((function(t){e.observe(t)}))}(t,a)):this.loadAll(o)},destroy:function(){this._observer&&this._observer.disconnect(),t&&window.removeEventListener("online",this._onlineHandler),ge(this._settings).forEach((function(e){B(e)})),delete this._observer,delete this._settings,delete this._onlineHandler,delete this.loadingCount,delete this.toLoadCount},loadAll:function(e){var t=this,r=this._settings;ye(e,r).forEach((function(e){j(e,t),se(e,r,t)}))},restoreAll:function(){var e=this._settings;ge(e).forEach((function(t){de(t,e)}))}},_e.load=function(e,t){var r=s(t);se(e,r)},_e.resetStatus=function(e){x(e)},t&&function(e,t){if(t)if(t.length)for(var r,n=0;r=t[n];n+=1)l(e,r);else l(e,t)}(_e,window.lazyLoadOptions),_e}))}));function appGlobalScript(){if(!document.lazyLoadInstance){document.lazyLoadInstance=new lazyload_min({use_native:true});document.lazyLoadBackgrounds=new lazyload_min({elements_selector:".lazy[data-bg]:not(.loaded)"})}if(document.readyState!=="complete"){document.addEventListener("DOMContentLoaded",(function(){return document.lazyLoadInstance.update()}));document.addEventListener("DOMContentLoaded",(function(){return document.lazyLoadBackgrounds.update()}))}salla.infiniteScroll.event.onAppend((function(){document.lazyLoadInstance.update();document.lazyLoadBackgrounds.update()}))}var globalScripts=appGlobalScript;export{globalScripts as g};
25
- //# sourceMappingURL=app-globals-060c6f67.js.map
24
+ (function(t,r){{e.exports=r()}})(commonjsGlobal,(function(){function e(){if(typeof document!=="undefined"&&document.documentElement){return document.documentElement.lang}}function t(e){if(e==="-Inf"){return-Infinity}else if(e==="+Inf"||e==="Inf"||e==="*"){return Infinity}return parseInt(e,10)}var r=/^({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])$/;var n=/({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])/;var a={locale:"en"};var i=function(t){t=t||{};this.locale=t.locale||e()||a.locale;this.fallback=t.fallback;this.messages=t.messages};i.prototype.setMessages=function(e){this.messages=e};i.prototype.getLocale=function(){return this.locale||this.fallback};i.prototype.setLocale=function(e){this.locale=e};i.prototype.getFallback=function(){return this.fallback};i.prototype.setFallback=function(e){this.fallback=e};i.prototype.has=function(e,t){if(typeof e!=="string"||!this.messages){return false}return this._getMessage(e,t)!==null};i.prototype.get=function(e,t,r){if(!this.has(e,r)){return e}var n=this._getMessage(e,r);if(n===null){return e}if(t){n=this._applyReplacements(n,t)}return n};i.prototype.trans=function(e,t){return this.get(e,t)};i.prototype.choice=function(e,t,r,a){r=typeof r!=="undefined"?r:{};r.count=t;var i=this.get(e,r,a);if(i===null||i===undefined){return i}var o=i.split("|");var s=[];for(var l=0;l<o.length;l++){o[l]=o[l].trim();if(n.test(o[l])){var c=o[l].split(/\s/);s.push(c.shift());o[l]=c.join(" ")}}if(o.length===1){return i}for(var u=0;u<s.length;u++){if(this._testInterval(t,s[u])){return o[u]}}a=a||this._getLocale(e);var d=this._getPluralForm(t,a);return o[d]};i.prototype.transChoice=function(e,t,r){return this.choice(e,t,r)};i.prototype._parseKey=function(e,t){if(typeof e!=="string"||typeof t!=="string"){return null}var r=e.split(".");var n=r[0].replace(/\//g,".");return{source:t+"."+n,sourceFallback:this.getFallback()+"."+n,entries:r.slice(1)}};i.prototype._getMessage=function(e,t){t=t||this.getLocale();e=this._parseKey(e,t);if(this.messages[e.source]===undefined&&this.messages[e.sourceFallback]===undefined){return null}var r=this.messages[e.source];var n=e.entries.slice();var a=n.join(".");r=r!==undefined?this._getValueInKey(r,a):undefined;if(typeof r!=="string"&&this.messages[e.sourceFallback]){r=this.messages[e.sourceFallback];n=e.entries.slice();a="";while(n.length&&r!==undefined){var a=!a?n.shift():a.concat(".",n.shift());if(r[a]){r=r[a];a=""}}}if(typeof r!=="string"){return null}return r};i.prototype._getValueInKey=function(e,t){if(typeof e[t]==="string"){return e[t]}t=t.replace(/\[(\w+)\]/g,".$1");t=t.replace(/^\./,"");var r=t.split(".");for(var n=0,a=r.length;n<a;++n){var i=r.slice(0,n+1).join(".");var o=r.slice(n+1,r.length).join(".");if(e[i]){return this._getValueInKey(e[i],o)}}return e};i.prototype._getLocale=function(e){e=this._parseKey(e,this.locale);if(this.messages[e.source]){return this.locale}if(this.messages[e.sourceFallback]){return this.fallback}return null};i.prototype._findMessageInTree=function(e,t){while(e.length&&t!==undefined){var r=e.join(".");if(t[r]){t=t[r];break}t=t[e.shift()]}return t};i.prototype._sortReplacementKeys=function(e,t){return t.length-e.length};i.prototype._applyReplacements=function(e,t){var r=Object.keys(t).sort(this._sortReplacementKeys);r.forEach((function(r){e=e.replace(new RegExp(":"+r,"gi"),(function(e){var n=t[r];var a=e===e.toUpperCase();if(a){return n.toUpperCase()}var i=e===e.replace(/\w/i,(function(e){return e.toUpperCase()}));if(i){return n.charAt(0).toUpperCase()+n.slice(1)}return n}))}));return e};i.prototype._testInterval=function(e,n){if(typeof n!=="string"){throw"Invalid interval: should be a string."}n=n.trim();var a=n.match(r);if(!a){throw"Invalid interval: "+n}if(a[2]){var i=a[2].split(",");for(var o=0;o<i.length;o++){if(parseInt(i[o],10)===e){return true}}}else{a=a.filter((function(e){return!!e}));var s=a[1];var l=t(a[2]);if(l===Infinity){l=-Infinity}var c=t(a[3]);var u=a[4];return(s==="["?e>=l:e>l)&&(u==="]"?e<=c:e<c)}return false};i.prototype._getPluralForm=function(e,t){switch(t){case"az":case"bo":case"dz":case"id":case"ja":case"jv":case"ka":case"km":case"kn":case"ko":case"ms":case"th":case"tr":case"vi":case"zh":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 e==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 e===0||e===1?0:1;case"be":case"bs":case"hr":case"ru":case"sr":case"uk":return e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2;case"cs":case"sk":return e==1?0:e>=2&&e<=4?1:2;case"ga":return e==1?0:e==2?1:2;case"lt":return e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2;case"sl":return e%100==1?0:e%100==2?1:e%100==3||e%100==4?2:3;case"mk":return e%10==1?0:1;case"mt":return e==1?0:e===0||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3;case"lv":return e===0?0:e%10==1&&e%100!=11?1:2;case"pl":return e==1?0:e%10>=2&&e%10<=4&&(e%100<12||e%100>14)?1:2;case"cy":return e==1?0:e==2?1:e==8||e==11?2:3;case"ro":return e==1?0:e===0||e%100>0&&e%100<20?1:2;case"ar":return e===0?0:e==1?1:e==2?2:e%100>=3&&e%100<=10?3:e%100>=11&&e%100<=99?4:5;default:return 0}};return i}))}));var bind=function e(t,r){return function e(){var n=new Array(arguments.length);for(var a=0;a<n.length;a++){n[a]=arguments[a]}return t.apply(r,n)}};var toString=Object.prototype.toString;var kindOf=function(e){return function(t){var r=toString.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())}}(Object.create(null));function kindOfTest(e){e=e.toLowerCase();return function t(r){return kindOf(r)===e}}function isArray(e){return Array.isArray(e)}function isUndefined(e){return typeof e==="undefined"}function isBuffer(e){return e!==null&&!isUndefined(e)&&e.constructor!==null&&!isUndefined(e.constructor)&&typeof e.constructor.isBuffer==="function"&&e.constructor.isBuffer(e)}var isArrayBuffer=kindOfTest("ArrayBuffer");function isArrayBufferView(e){var t;if(typeof ArrayBuffer!=="undefined"&&ArrayBuffer.isView){t=ArrayBuffer.isView(e)}else{t=e&&e.buffer&&isArrayBuffer(e.buffer)}return t}function isString(e){return typeof e==="string"}function isNumber(e){return typeof e==="number"}function isObject(e){return e!==null&&typeof e==="object"}function isPlainObject(e){if(kindOf(e)!=="object"){return false}var t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}var isDate=kindOfTest("Date");var isFile=kindOfTest("File");var isBlob=kindOfTest("Blob");var isFileList=kindOfTest("FileList");function isFunction(e){return toString.call(e)==="[object Function]"}function isStream(e){return isObject(e)&&isFunction(e.pipe)}function isFormData(e){var t="[object FormData]";return e&&(typeof FormData==="function"&&e instanceof FormData||toString.call(e)===t||isFunction(e.toString)&&e.toString()===t)}var isURLSearchParams=kindOfTest("URLSearchParams");function trim(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function isStandardBrowserEnv(){if(typeof navigator!=="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")){return false}return typeof window!=="undefined"&&typeof document!=="undefined"}function forEach(e,t){if(e===null||typeof e==="undefined"){return}if(typeof e!=="object"){e=[e]}if(isArray(e)){for(var r=0,n=e.length;r<n;r++){t.call(null,e[r],r,e)}}else{for(var a in e){if(Object.prototype.hasOwnProperty.call(e,a)){t.call(null,e[a],a,e)}}}}function merge(){var e={};function t(t,r){if(isPlainObject(e[r])&&isPlainObject(t)){e[r]=merge(e[r],t)}else if(isPlainObject(t)){e[r]=merge({},t)}else if(isArray(t)){e[r]=t.slice()}else{e[r]=t}}for(var r=0,n=arguments.length;r<n;r++){forEach(arguments[r],t)}return e}function extend(e,t,r){forEach(t,(function t(n,a){if(r&&typeof n==="function"){e[a]=bind(n,r)}else{e[a]=n}}));return e}function stripBOM(e){if(e.charCodeAt(0)===65279){e=e.slice(1)}return e}function inherits(e,t,r,n){e.prototype=Object.create(t.prototype,n);e.prototype.constructor=e;r&&Object.assign(e.prototype,r)}function toFlatObject(e,t,r){var n;var a;var i;var o={};t=t||{};do{n=Object.getOwnPropertyNames(e);a=n.length;while(a-- >0){i=n[a];if(!o[i]){t[i]=e[i];o[i]=true}}e=Object.getPrototypeOf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t}function endsWith(e,t,r){e=String(e);if(r===undefined||r>e.length){r=e.length}r-=t.length;var n=e.indexOf(t,r);return n!==-1&&n===r}function toArray(e){if(!e)return null;var t=e.length;if(isUndefined(t))return null;var r=new Array(t);while(t-- >0){r[t]=e[t]}return r}var isTypedArray=function(e){return function(t){return e&&t instanceof e}}(typeof Uint8Array!=="undefined"&&Object.getPrototypeOf(Uint8Array));var utils={isArray:isArray,isArrayBuffer:isArrayBuffer,isBuffer:isBuffer,isFormData:isFormData,isArrayBufferView:isArrayBufferView,isString:isString,isNumber:isNumber,isObject:isObject,isPlainObject:isPlainObject,isUndefined:isUndefined,isDate:isDate,isFile:isFile,isBlob:isBlob,isFunction:isFunction,isStream:isStream,isURLSearchParams:isURLSearchParams,isStandardBrowserEnv:isStandardBrowserEnv,forEach:forEach,merge:merge,extend:extend,trim:trim,stripBOM:stripBOM,inherits:inherits,toFlatObject:toFlatObject,kindOf:kindOf,kindOfTest:kindOfTest,endsWith:endsWith,toArray:toArray,isTypedArray:isTypedArray,isFileList:isFileList};function encode(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var buildURL=function e(t,r,n){if(!r){return t}var a;if(n){a=n(r)}else if(utils.isURLSearchParams(r)){a=r.toString()}else{var i=[];utils.forEach(r,(function e(t,r){if(t===null||typeof t==="undefined"){return}if(utils.isArray(t)){r=r+"[]"}else{t=[t]}utils.forEach(t,(function e(t){if(utils.isDate(t)){t=t.toISOString()}else if(utils.isObject(t)){t=JSON.stringify(t)}i.push(encode(r)+"="+encode(t))}))}));a=i.join("&")}if(a){var o=t.indexOf("#");if(o!==-1){t=t.slice(0,o)}t+=(t.indexOf("?")===-1?"?":"&")+a}return t};function InterceptorManager(){this.handlers=[]}InterceptorManager.prototype.use=function e(t,r,n){this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:false,runWhen:n?n.runWhen:null});return this.handlers.length-1};InterceptorManager.prototype.eject=function e(t){if(this.handlers[t]){this.handlers[t]=null}};InterceptorManager.prototype.forEach=function e(t){utils.forEach(this.handlers,(function e(r){if(r!==null){t(r)}}))};var InterceptorManager_1=InterceptorManager;var normalizeHeaderName=function e(t,r){utils.forEach(t,(function e(n,a){if(a!==r&&a.toUpperCase()===r.toUpperCase()){t[r]=n;delete t[a]}}))};function AxiosError(e,t,r,n,a){Error.call(this);this.message=e;this.name="AxiosError";t&&(this.code=t);r&&(this.config=r);n&&(this.request=n);a&&(this.response=a)}utils.inherits(AxiosError,Error,{toJSON:function e(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var prototype=AxiosError.prototype;var descriptors={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED"].forEach((function(e){descriptors[e]={value:e}}));Object.defineProperties(AxiosError,descriptors);Object.defineProperty(prototype,"isAxiosError",{value:true});AxiosError.from=function(e,t,r,n,a,i){var o=Object.create(prototype);utils.toFlatObject(e,o,(function e(t){return t!==Error.prototype}));AxiosError.call(o,e.message,t,r,n,a);o.name=e.name;i&&Object.assign(o,i);return o};var AxiosError_1=AxiosError;var transitional={silentJSONParsing:true,forcedJSONParsing:true,clarifyTimeoutError:false};function toFormData(e,t){t=t||new FormData;var r=[];function n(e){if(e===null)return"";if(utils.isDate(e)){return e.toISOString()}if(utils.isArrayBuffer(e)||utils.isTypedArray(e)){return typeof Blob==="function"?new Blob([e]):Buffer.from(e)}return e}function a(e,i){if(utils.isPlainObject(e)||utils.isArray(e)){if(r.indexOf(e)!==-1){throw Error("Circular reference detected in "+i)}r.push(e);utils.forEach(e,(function e(r,o){if(utils.isUndefined(r))return;var s=i?i+"."+o:o;var l;if(r&&!i&&typeof r==="object"){if(utils.endsWith(o,"{}")){r=JSON.stringify(r)}else if(utils.endsWith(o,"[]")&&(l=utils.toArray(r))){l.forEach((function(e){!utils.isUndefined(e)&&t.append(s,n(e))}));return}}a(r,s)}));r.pop()}else{t.append(i,n(e))}}a(e);return t}var toFormData_1=toFormData;var settle=function e(t,r,n){var a=n.config.validateStatus;if(!n.status||!a||a(n.status)){t(n)}else{r(new AxiosError_1("Request failed with status code "+n.status,[AxiosError_1.ERR_BAD_REQUEST,AxiosError_1.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}};var cookies=utils.isStandardBrowserEnv()?function e(){return{write:function e(t,r,n,a,i,o){var s=[];s.push(t+"="+encodeURIComponent(r));if(utils.isNumber(n)){s.push("expires="+new Date(n).toGMTString())}if(utils.isString(a)){s.push("path="+a)}if(utils.isString(i)){s.push("domain="+i)}if(o===true){s.push("secure")}document.cookie=s.join("; ")},read:function e(t){var r=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function e(t){this.write(t,"",Date.now()-864e5)}}}():function e(){return{write:function e(){},read:function e(){return null},remove:function e(){}}}();var isAbsoluteURL=function e(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)};var combineURLs=function e(t,r){return r?t.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):t};var buildFullPath=function e(t,r){if(t&&!isAbsoluteURL(r)){return combineURLs(t,r)}return r};var ignoreDuplicateOf=["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 parseHeaders=function e(t){var r={};var n;var a;var i;if(!t){return r}utils.forEach(t.split("\n"),(function e(t){i=t.indexOf(":");n=utils.trim(t.substr(0,i)).toLowerCase();a=utils.trim(t.substr(i+1));if(n){if(r[n]&&ignoreDuplicateOf.indexOf(n)>=0){return}if(n==="set-cookie"){r[n]=(r[n]?r[n]:[]).concat([a])}else{r[n]=r[n]?r[n]+", "+a:a}}}));return r};var isURLSameOrigin=utils.isStandardBrowserEnv()?function e(){var t=/(msie|trident)/i.test(navigator.userAgent);var r=document.createElement("a");var n;function a(e){var n=e;if(t){r.setAttribute("href",n);n=r.href}r.setAttribute("href",n);return{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}n=a(window.location.href);return function e(t){var r=utils.isString(t)?a(t):t;return r.protocol===n.protocol&&r.host===n.host}}():function e(){return function e(){return true}}();function CanceledError(e){AxiosError_1.call(this,e==null?"canceled":e,AxiosError_1.ERR_CANCELED);this.name="CanceledError"}utils.inherits(CanceledError,AxiosError_1,{__CANCEL__:true});var CanceledError_1=CanceledError;var parseProtocol=function e(t){var r=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return r&&r[1]||""};var xhr=function e(t){return new Promise((function e(r,n){var a=t.data;var i=t.headers;var o=t.responseType;var s;function l(){if(t.cancelToken){t.cancelToken.unsubscribe(s)}if(t.signal){t.signal.removeEventListener("abort",s)}}if(utils.isFormData(a)&&utils.isStandardBrowserEnv()){delete i["Content-Type"]}var c=new XMLHttpRequest;if(t.auth){var u=t.auth.username||"";var d=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";i.Authorization="Basic "+btoa(u+":"+d)}var f=buildFullPath(t.baseURL,t.url);c.open(t.method.toUpperCase(),buildURL(f,t.params,t.paramsSerializer),true);c.timeout=t.timeout;function h(){if(!c){return}var e="getAllResponseHeaders"in c?parseHeaders(c.getAllResponseHeaders()):null;var a=!o||o==="text"||o==="json"?c.responseText:c.response;var i={data:a,status:c.status,statusText:c.statusText,headers:e,config:t,request:c};settle((function e(t){r(t);l()}),(function e(t){n(t);l()}),i);c=null}if("onloadend"in c){c.onloadend=h}else{c.onreadystatechange=function e(){if(!c||c.readyState!==4){return}if(c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)){return}setTimeout(h)}}c.onabort=function e(){if(!c){return}n(new AxiosError_1("Request aborted",AxiosError_1.ECONNABORTED,t,c));c=null};c.onerror=function e(){n(new AxiosError_1("Network Error",AxiosError_1.ERR_NETWORK,t,c,c));c=null};c.ontimeout=function e(){var r=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded";var a=t.transitional||transitional;if(t.timeoutErrorMessage){r=t.timeoutErrorMessage}n(new AxiosError_1(r,a.clarifyTimeoutError?AxiosError_1.ETIMEDOUT:AxiosError_1.ECONNABORTED,t,c));c=null};if(utils.isStandardBrowserEnv()){var p=(t.withCredentials||isURLSameOrigin(f))&&t.xsrfCookieName?cookies.read(t.xsrfCookieName):undefined;if(p){i[t.xsrfHeaderName]=p}}if("setRequestHeader"in c){utils.forEach(i,(function e(t,r){if(typeof a==="undefined"&&r.toLowerCase()==="content-type"){delete i[r]}else{c.setRequestHeader(r,t)}}))}if(!utils.isUndefined(t.withCredentials)){c.withCredentials=!!t.withCredentials}if(o&&o!=="json"){c.responseType=t.responseType}if(typeof t.onDownloadProgress==="function"){c.addEventListener("progress",t.onDownloadProgress)}if(typeof t.onUploadProgress==="function"&&c.upload){c.upload.addEventListener("progress",t.onUploadProgress)}if(t.cancelToken||t.signal){s=function(e){if(!c){return}n(!e||e&&e.type?new CanceledError_1:e);c.abort();c=null};t.cancelToken&&t.cancelToken.subscribe(s);if(t.signal){t.signal.aborted?s():t.signal.addEventListener("abort",s)}}if(!a){a=null}var v=parseProtocol(f);if(v&&["http","https","file"].indexOf(v)===-1){n(new AxiosError_1("Unsupported protocol "+v+":",AxiosError_1.ERR_BAD_REQUEST,t));return}c.send(a)}))};var _null=null;var DEFAULT_CONTENT_TYPE={"Content-Type":"application/x-www-form-urlencoded"};function setContentTypeIfUnset(e,t){if(!utils.isUndefined(e)&&utils.isUndefined(e["Content-Type"])){e["Content-Type"]=t}}function getDefaultAdapter(){var e;if(typeof XMLHttpRequest!=="undefined"){e=xhr}else if(typeof process!=="undefined"&&Object.prototype.toString.call(process)==="[object process]"){e=xhr}return e}function stringifySafely(e,t,r){if(utils.isString(e)){try{(t||JSON.parse)(e);return utils.trim(e)}catch(e){if(e.name!=="SyntaxError"){throw e}}}return(r||JSON.stringify)(e)}var defaults={transitional:transitional,adapter:getDefaultAdapter(),transformRequest:[function e(t,r){normalizeHeaderName(r,"Accept");normalizeHeaderName(r,"Content-Type");if(utils.isFormData(t)||utils.isArrayBuffer(t)||utils.isBuffer(t)||utils.isStream(t)||utils.isFile(t)||utils.isBlob(t)){return t}if(utils.isArrayBufferView(t)){return t.buffer}if(utils.isURLSearchParams(t)){setContentTypeIfUnset(r,"application/x-www-form-urlencoded;charset=utf-8");return t.toString()}var n=utils.isObject(t);var a=r&&r["Content-Type"];var i;if((i=utils.isFileList(t))||n&&a==="multipart/form-data"){var o=this.env&&this.env.FormData;return toFormData_1(i?{"files[]":t}:t,o&&new o)}else if(n||a==="application/json"){setContentTypeIfUnset(r,"application/json");return stringifySafely(t)}return t}],transformResponse:[function e(t){var r=this.transitional||defaults.transitional;var n=r&&r.silentJSONParsing;var a=r&&r.forcedJSONParsing;var i=!n&&this.responseType==="json";if(i||a&&utils.isString(t)&&t.length){try{return JSON.parse(t)}catch(e){if(i){if(e.name==="SyntaxError"){throw AxiosError_1.from(e,AxiosError_1.ERR_BAD_RESPONSE,this,null,this.response)}throw e}}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:_null},validateStatus:function e(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};utils.forEach(["delete","get","head"],(function e(t){defaults.headers[t]={}}));utils.forEach(["post","put","patch"],(function e(t){defaults.headers[t]=utils.merge(DEFAULT_CONTENT_TYPE)}));var defaults_1=defaults;var transformData=function e(t,r,n){var a=this||defaults_1;utils.forEach(n,(function e(n){t=n.call(a,t,r)}));return t};var isCancel=function e(t){return!!(t&&t.__CANCEL__)};function throwIfCancellationRequested(e){if(e.cancelToken){e.cancelToken.throwIfRequested()}if(e.signal&&e.signal.aborted){throw new CanceledError_1}}var dispatchRequest=function e(t){throwIfCancellationRequested(t);t.headers=t.headers||{};t.data=transformData.call(t,t.data,t.headers,t.transformRequest);t.headers=utils.merge(t.headers.common||{},t.headers[t.method]||{},t.headers);utils.forEach(["delete","get","head","post","put","patch","common"],(function e(r){delete t.headers[r]}));var r=t.adapter||defaults_1.adapter;return r(t).then((function e(r){throwIfCancellationRequested(t);r.data=transformData.call(t,r.data,r.headers,t.transformResponse);return r}),(function e(r){if(!isCancel(r)){throwIfCancellationRequested(t);if(r&&r.response){r.response.data=transformData.call(t,r.response.data,r.response.headers,t.transformResponse)}}return Promise.reject(r)}))};var mergeConfig=function e(t,r){r=r||{};var n={};function a(e,t){if(utils.isPlainObject(e)&&utils.isPlainObject(t)){return utils.merge(e,t)}else if(utils.isPlainObject(t)){return utils.merge({},t)}else if(utils.isArray(t)){return t.slice()}return t}function i(e){if(!utils.isUndefined(r[e])){return a(t[e],r[e])}else if(!utils.isUndefined(t[e])){return a(undefined,t[e])}}function o(e){if(!utils.isUndefined(r[e])){return a(undefined,r[e])}}function s(e){if(!utils.isUndefined(r[e])){return a(undefined,r[e])}else if(!utils.isUndefined(t[e])){return a(undefined,t[e])}}function l(e){if(e in r){return a(t[e],r[e])}else if(e in t){return a(undefined,t[e])}}var c={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:l};utils.forEach(Object.keys(t).concat(Object.keys(r)),(function e(t){var r=c[t]||i;var a=r(t);utils.isUndefined(a)&&r!==l||(n[t]=a)}));return n};var data={version:"0.27.2"};var VERSION=data.version;var validators$1={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){validators$1[e]=function r(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));var deprecatedWarnings={};validators$1.transitional=function e(t,r,n){function a(e,t){return"[Axios v"+VERSION+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(e,n,i){if(t===false){throw new AxiosError_1(a(n," has been removed"+(r?" in "+r:"")),AxiosError_1.ERR_DEPRECATED)}if(r&&!deprecatedWarnings[n]){deprecatedWarnings[n]=true;console.warn(a(n," has been deprecated since v"+r+" and will be removed in the near future"))}return t?t(e,n,i):true}};function assertOptions(e,t,r){if(typeof e!=="object"){throw new AxiosError_1("options must be an object",AxiosError_1.ERR_BAD_OPTION_VALUE)}var n=Object.keys(e);var a=n.length;while(a-- >0){var i=n[a];var o=t[i];if(o){var s=e[i];var l=s===undefined||o(s,i,e);if(l!==true){throw new AxiosError_1("option "+i+" must be "+l,AxiosError_1.ERR_BAD_OPTION_VALUE)}continue}if(r!==true){throw new AxiosError_1("Unknown option "+i,AxiosError_1.ERR_BAD_OPTION)}}}var validator={assertOptions:assertOptions,validators:validators$1};var validators=validator.validators;function Axios(e){this.defaults=e;this.interceptors={request:new InterceptorManager_1,response:new InterceptorManager_1}}Axios.prototype.request=function e(t,r){if(typeof t==="string"){r=r||{};r.url=t}else{r=t||{}}r=mergeConfig(this.defaults,r);if(r.method){r.method=r.method.toLowerCase()}else if(this.defaults.method){r.method=this.defaults.method.toLowerCase()}else{r.method="get"}var n=r.transitional;if(n!==undefined){validator.assertOptions(n,{silentJSONParsing:validators.transitional(validators.boolean),forcedJSONParsing:validators.transitional(validators.boolean),clarifyTimeoutError:validators.transitional(validators.boolean)},false)}var a=[];var i=true;this.interceptors.request.forEach((function e(t){if(typeof t.runWhen==="function"&&t.runWhen(r)===false){return}i=i&&t.synchronous;a.unshift(t.fulfilled,t.rejected)}));var o=[];this.interceptors.response.forEach((function e(t){o.push(t.fulfilled,t.rejected)}));var s;if(!i){var l=[dispatchRequest,undefined];Array.prototype.unshift.apply(l,a);l=l.concat(o);s=Promise.resolve(r);while(l.length){s=s.then(l.shift(),l.shift())}return s}var c=r;while(a.length){var u=a.shift();var d=a.shift();try{c=u(c)}catch(e){d(e);break}}try{s=dispatchRequest(c)}catch(e){return Promise.reject(e)}while(o.length){s=s.then(o.shift(),o.shift())}return s};Axios.prototype.getUri=function e(t){t=mergeConfig(this.defaults,t);var r=buildFullPath(t.baseURL,t.url);return buildURL(r,t.params,t.paramsSerializer)};utils.forEach(["delete","get","head","options"],(function e(t){Axios.prototype[t]=function(e,r){return this.request(mergeConfig(r||{},{method:t,url:e,data:(r||{}).data}))}}));utils.forEach(["post","put","patch"],(function e(t){function r(e){return function r(n,a,i){return this.request(mergeConfig(i||{},{method:t,headers:e?{"Content-Type":"multipart/form-data"}:{},url:n,data:a}))}}Axios.prototype[t]=r();Axios.prototype[t+"Form"]=r(true)}));var Axios_1=Axios;function CancelToken(e){if(typeof e!=="function"){throw new TypeError("executor must be a function.")}var t;this.promise=new Promise((function e(r){t=r}));var r=this;this.promise.then((function(e){if(!r._listeners)return;var t;var n=r._listeners.length;for(t=0;t<n;t++){r._listeners[t](e)}r._listeners=null}));this.promise.then=function(e){var t;var n=new Promise((function(e){r.subscribe(e);t=e})).then(e);n.cancel=function e(){r.unsubscribe(t)};return n};e((function e(n){if(r.reason){return}r.reason=new CanceledError_1(n);t(r.reason)}))}CancelToken.prototype.throwIfRequested=function e(){if(this.reason){throw this.reason}};CancelToken.prototype.subscribe=function e(t){if(this.reason){t(this.reason);return}if(this._listeners){this._listeners.push(t)}else{this._listeners=[t]}};CancelToken.prototype.unsubscribe=function e(t){if(!this._listeners){return}var r=this._listeners.indexOf(t);if(r!==-1){this._listeners.splice(r,1)}};CancelToken.source=function e(){var t;var r=new CancelToken((function e(r){t=r}));return{token:r,cancel:t}};var CancelToken_1=CancelToken;var spread=function e(t){return function e(r){return t.apply(null,r)}};var isAxiosError=function e(t){return utils.isObject(t)&&t.isAxiosError===true};function createInstance(e){var t=new Axios_1(e);var r=bind(Axios_1.prototype.request,t);utils.extend(r,Axios_1.prototype,t);utils.extend(r,t);r.create=function t(r){return createInstance(mergeConfig(e,r))};return r}var axios$1=createInstance(defaults_1);axios$1.Axios=Axios_1;axios$1.CanceledError=CanceledError_1;axios$1.CancelToken=CancelToken_1;axios$1.isCancel=isCancel;axios$1.VERSION=data.version;axios$1.toFormData=toFormData_1;axios$1.AxiosError=AxiosError_1;axios$1.Cancel=axios$1.CanceledError;axios$1.all=function e(t){return Promise.all(t)};axios$1.spread=spread;axios$1.isAxiosError=isAxiosError;var axios_1=axios$1;var _default=axios$1;axios_1.default=_default;var axios=axios_1;function e(e){this.message=e}e.prototype=new Error,e.prototype.name="InvalidCharacterError";var r="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var r=String(t).replace(/=+$/,"");if(r.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,a,i=0,o=0,s="";a=r.charAt(o++);~a&&(n=i%4?64*n+a:a,i++%4)?s+=String.fromCharCode(255&n>>(-2*i&6)):0)a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a);return s};function t(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(r(e).replace(/(.)/g,(function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(t)}catch(e){return r(t)}}function n$1(e){this.message=e}function o$1(e,r){if("string"!=typeof e)throw new n$1("Invalid token specified");var n=!0===(r=r||{}).header?0:1;try{return JSON.parse(t(e.split(".")[n]))}catch(e){throw new n$1("Invalid token specified: "+e.message)}}n$1.prototype=new Error,n$1.prototype.name="InvalidTokenError";var i=function(e,t,r){return alert(e)},n=function(e,t){return i(e,l.error,t)},l={error:"error",success:"success",info:"info"};var o={fire:function(e,t,r){return i(e,t,r)},setNotifier:function(e){i=e,salla.event.emit("twilight::notifier.changed")},error:n,success:function(e,t){return i(e,l.success,t)},info:function(e,t){return i(e,l.info,t)},sallaInitiated:function(){var e=window.location.href.match(/([\?\&]danger=)[^&]+/g);e&&(window.history.replaceState(null,document.title,window.location.pathname),salla.event.once("twilight::notifier.changed",(function(){e.forEach((function(e){e=decodeURI(e.replace("?danger=","").replace("&danger=",""));var t=document.createElement("div");t.innerText=e,n(t.innerHTML),salla.event.emit("twilight::error",e)}))})))},types:l};var d=function(){function e(e,t){return this.api=e,this.event=t,new Proxy(this,{get:function(r,n){return"event"===n?t:"api"===n?e:e&&e[n]||r[n]}})}return e}();Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){for(var t=this;t;){if(t.matches(e))return t;t=t.parentElement}}),Element.prototype.getElementSallaData=function(e){var t;var r=[];for(var n=1;n<arguments.length;n++){r[n-1]=arguments[n]}if(!this.getAttribute)return;if(this.hasAttribute("data-json"))try{return JSON.parse(this.getAttribute("data-json"))}catch(e){}var a=this.getAttribute("data-function");if(a&&window[a])return"function"==typeof window[a]?this.getFilteredData((t=window[a]).call.apply(t,__spreadArray([this],r,false))):this.getFilteredData(window[a]);var 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);var o=i.querySelectorAll("[name]");if(!o.length)return this.getFilteredData();var s=Object.assign({},this.dataset);return o.forEach((function(e){if(!["checkbox","radio"].includes(e.type)||e.checked)try{var t=Salla.helpers.inputData(e.name,e.value,s);s[t.name]=t.value}catch(t){Salla.log(e.name+" can't be send")}})),this.getFilteredData(s)},Element.prototype.canEventFireHook=function(e){return!!this.hasAttribute&&this.hasAttribute(Salla.api.hooksPrefix+e.type)},Element.prototype.hasAttributeStartsWith=function(e,t){e=e.toLowerCase();for(var r=0;r<this.attributes.length;r++){var n=this.attributes[r].name.toLowerCase();if(0===n.indexOf(e))return!t||n}return!1},HTMLFormElement.prototype.getAjaxFormData=function(e){var t=this.querySelectorAll('input[type="file"]');t.forEach((function(e){e.files.length||e.setAttribute("disabled","")}));var r=new FormData(this);return t.forEach((function(e){e.files.length||e.removeAttribute("disabled")})),{formData:this.getFilteredData(r,e),url:this.getAttribute("action"),method:this.getAttribute("method")||"post",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}},Element.prototype.getFilteredData=function(e,t,r){var n=this;if(e===void 0){e=null}if(t===void 0){t=null}if(r===void 0){r=null}return e=e||(r===null||r===void 0?void 0:r.dataset)||this.dataset,r&&this.name&&void 0!==this.value&&(e=function(e,t,r){e instanceof FormData?e.append(t,r):e[t]=r;return e}(e,this.name,this.value)),["filterBeforeSubmit","filterBeforeSend"].forEach((function(a){var i=(r===null||r===void 0?void 0:r.dataset[a])||n.dataset[a];if(i){var o=window[i];if("function"==typeof o){if(!o(e,r||n,t)&&e)throw"Data failed to be pass verify function window.".concat(i,"(formData, element, event)!");return o(e,r||n,t)}Salla.log("window."+i+"() not found!")}})),e},HTMLAnchorElement.prototype.getAjaxFormData=function(e){return{formData:this.getFilteredData(null,e),url:this.getAttribute("href"),method:this.dataset.type||"get",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}};var c=function(){function e(){this.events={},this.namespace="";var e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&e.length>1?e[1]:"").toLowerCase()}e.prototype.after_init=function(){this.createDynamicFunctions()};e.prototype.createDynamicFunctions=function(){var e=this;Object.keys(this.events).forEach((function(t){e.createDynamicEventFuns(t),e.createDynamicListenerFuns(t)}))};e.prototype.createDynamicEventFuns=function(e){if(this[e])return;var t=this;this[e]=function(){var r=[];for(var n=0;n<arguments.length;n++){r[n]=arguments[n]}return t.dispatch.apply(t,__spreadArray([e],r,false))}};e.prototype.createDynamicListenerFuns=function(e){var t="on"+e.charAt(0).toUpperCase()+e.slice(1);if(this[t])return;var r=this;this[t]=function(t){var n=this;return r.on(e,(function(){var e=[];for(var r=0;r<arguments.length;r++){e[r]=arguments[r]}return __awaiter(n,void 0,void 0,(function(){return __generator(this,(function(r){return[2,t.apply(void 0,e)]}))}))}))}};e.prototype.getEventName=function(e){return e=this.events[e]||e,!this.namespace||e.includes("::")?e:this.namespace+Salla.event.delimiter+e};e.prototype.dispatch=function(e){var t;var r=[];for(var n=1;n<arguments.length;n++){r[n-1]=arguments[n]}return(t=Salla.event).emitAsync.apply(t,__spreadArray([this.getEventName(e)],r,false))};e.prototype.on=function(e,t,r){if(r===void 0){r={}}return Salla.event.addListener(this.getEventName(e),t,r)};e.prototype.once=function(e,t){return Salla.event.once(this.getEventName(e),t)};return e}();function u(e){e&&e.sallaInitiated&&!e.initiated&&(e.sallaInitiated(),e.initiated=!0)}Salla.event.auth=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="auth",t.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"},t.after_init();return t}t.prototype.login=function(e){return e?(e.type&&this.setTypeActionOnVerified(e.type),this.next_event=e.next_event||null,this.dispatch.apply(this,__spreadArray(["login"],arguments,false))):(this.next_event=null,this.dispatch.apply(this,__spreadArray(["login"],arguments,false)))};t.prototype.loggedIn=function(e){var t=this;return Salla.profile.info().finally((function(){return t.dispatch("loggedIn",e)}))};t.prototype.setTypeActionOnVerified=function(e){this.type_action_on_verified=e};t.prototype.getTypeActionOnVerified=function(){return this.type_action_on_verified||"redirect"};return t}(c)),Salla.event.cart=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="cart",t.events={latestFetched:"latest.fetched",latestFailed:"latest.failed",updated:"updated",itemUpdated:"item.updated",itemUpdatedFailed:"item.updated.failed",itemAdded:"item.added",itemAddedFailed:"item.added.failed",itemDeleted:"item.deleted",itemDeletedFailed:"item.deleted.failed",submitted:"submitted",submitFailed:"submit.failed",imageDeleted:"image.deleted",imageNotDeleted:"image.not.deleted",detailsFetched:"details.fetched",detailsNotFetched:"details.not.fetched",successReset:"success.reset",priceQuoteSucceeded:"price-quote.succeeded",priceQuoteFailed:"price-quote.failed",offersFetched:"offers.fetched",offersFailed:"offers.failed",couponAdded:"coupon.added",couponDeleted:"coupon.deleted",couponAdditionFailed:"coupon.addition.failed",couponDeletionFailed:"coupon.deletion.failed",quickOrderSettingFetched:"quick-order.fetched",quickOrderSettingFailed:"quick-order.failed",quickOrderSucceeded:"quick-order.succeeded",quickOrderFailed:"quick-order.failed"},t.after_init();return t}t.prototype.updated=function(e){var t;return Salla.cookie.set("fresh_summary",1),e&&"object"==typeof e?(e.offer&&salla.product.event.offerExisted(e.offer),e.redirect&&(salla.log("The current cart is purchased!"),salla.cart.api.reset()),e.cart?(salla.storage.set("cart.summary",{total:e.cart.total,sub_total:e.cart.sub_total,discount:e.cart.discount,real_shipping_cost:e.cart.real_shipping_cost,count:e.cart.count,shipping_cost:((t=e.cart.free_shipping_bar)===null||t===void 0?void 0:t.has_free_shipping)?0:e.cart.real_shipping_cost}),this.dispatch("updated",e.cart)):void salla.log("Failed to get the cart summary!")):(Salla.logger.info("Cart summary not an object!",e),this.dispatch("updated"))};t.prototype.latestFetched=function(e){return this.updated(e.data),this.dispatch("latestFetched",e)};t.prototype.itemAdded=function(e,t){return this.updated(e.data),this.dispatch("itemAdded",e,t)};t.prototype.itemDeleted=function(e,t){return this.updated(e.data),this.dispatch("itemDeleted",e,t)};t.prototype.itemUpdated=function(e,t){return this.updated(e.data),this.dispatch("itemUpdated",e,t)};t.prototype.couponAdded=function(e,t){return this.updated(e.data),this.dispatch("couponAdded",e,t)};t.prototype.couponDeleted=function(e,t){return this.updated(e.data),this.dispatch("couponDeleted",e,t)};return t}(c)),Salla.event.order=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="order",t.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"},t.after_init();return t}return t}(c)),Salla.event.scope=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="scope",t.events={fetched:"fetched",notFetched:"not.fetched",productAvailabilityFetched:"product-availability.fetched",productAvailabilityNotFetched:"product-availability.not.fetched",changeSucceeded:"changed",changeFailed:"not.changed"},t.after_init();return t}return t}(c)),Salla.event.rating=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="rating",t.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"},t.after_init();return t}return t}(c)),Salla.event.booking=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="booking",t.events={added:"added",additionFailed:"addition.failed"},t.after_init();return t}return t}(c)),Salla.event.comment=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="comment",t.events={added:"added",additionFailed:"addition.failed",fetched:"fetched",fetchFailed:"fetch.failed"},t.after_init();return t}return t}(c)),Salla.event.landing=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="landing",t.events={detailsFetched:"order.fetched",getDetailsFailed:"get.details.failed",orderCreated:"order.created",orderCreationFailed:"order.creation.failed",breadcrumbFetched:"breadcrumb.fetched",breadcrumbFetchFailed:"breadcrumb.fetch.failed"},t.after_init();return t}return t}(c)),Salla.event.loyalty=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="loyalty",t.events={exchangeSucceeded:"exchange.succeeded",exchangeFailed:"exchange.failed",programFetched:"program.fetched",programNotFetched:"program.not.fetched",resetSucceeded:"exchange-reset.succeeded",resetFailed:"exchange-reset.failed"},t.after_init();return t}t.prototype.exchangeSucceeded=function(e,t){return salla.cart.event.updated(e.data),this.dispatch("exchangeSucceeded",e,t)};t.prototype.resetSucceeded=function(e){return salla.cart.event.updated(e.data),this.dispatch("resetSucceeded",e)};return t}(c)),Salla.event.product=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="product",t.events={priceUpdated:"price.updated",priceUpdateFailed:"price.updated.failed",availabilitySubscribed:"availability.subscribed",availabilitySubscribeFailed:"availability.subscribe.failed",categoriesFetched:"categories.fetched",categoriesFailed:"categories.failed",searchFailed:"search.failed",searchResults:"search.results",offerExisted:"offer.existed",fetchOffersFailed:"fetch.offers.failed",offersFetched:"offers.fetched",sizeGuideFetched:"size-guide.fetched",sizeGuideFetchFailed:"size-guide.failed",giftFetched:"gift.fetched",giftFetchFailed:"gift.failed",detailFetched:"detail.fetched",detailFetchFailed:"detail.failed",addGiftToCartSucceeded:"gift.add-to-cart.succeeded",addGiftToCartFailed:"gift.add-to-cart.failed",giftImageUploadSucceeded:"gift.image-upload.succeeded",giftImageUploadFailed:"gift.image-upload.failed",productListFetchSucceeded:"fetch.succeeded",productListFetchFailed:"fetch.failed",productOptionsFetched:"options.fetched",productOptionsNotFetched:"options.not.fetched"},t.after_init();return t}return t}(c)),Salla.event.profile=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="profile",t.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"},t.after_init();return t}return t}(c)),Salla.event.currency=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="currency",t.events={changed:"changed",failed:"failed",fetched:"fetched",failedToFetch:"failed.to.fetch"},t.after_init();return t}return t}(c)),Salla.event.document=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="document",t.events={click:"click",change:"change",submit:"submit",keyup:"keyup",leaving:"leaving",request:"request",requestFailed:"request.failed"},t.after_init();return t}t.prototype.onClick=function(e,t){this.fireCallableFuns("click",e,t)};t.prototype.onChange=function(e,t){this.fireCallableFuns("change",e,t)};t.prototype.onSubmit=function(e,t){this.fireCallableFuns("submit",e,t)};t.prototype.onKeyup=function(e,t){this.fireCallableFuns("keyup",e,t)};t.prototype.fireCallableFuns=function(e,t,r){this.on(e,(function(e){"function"!=typeof t?"function"==typeof r&&e.target.matches(t)&&r(e):t(e)}))};t.prototype.fireEvent=function(e,t){var r=[];for(var n=2;n<arguments.length;n++){r[n-2]=arguments[n]}return this.fireEventForElements.apply(this,__spreadArray([e,t,!1],r,false))};t.prototype.fireEventForAll=function(e,t){var r=[];for(var n=2;n<arguments.length;n++){r[n-2]=arguments[n]}return this.fireEventForElements.apply(this,__spreadArray([e,t,!0],r,false))};t.prototype.fireEventForElements=function(e,t,r){var n=this;var a=[];for(var i=3;i<arguments.length;i++){a[i-3]=arguments[i]}if("string"==typeof e){if(r)return document.querySelectorAll(e).forEach((function(e){return n.fireEventForElements.apply(n,__spreadArray([e,t,!1],a,false))}));e=document.querySelector(e)}if(!e)return void salla.log("Failed To get element to fire event: "+t);var o=new(CustomEvent.bind.apply(CustomEvent,__spreadArray([void 0,t],a,false)));return e.dispatchEvent(o)};return t}(c)),Salla.event.wishlist=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="wishlist",t.events={added:"added",removed:"removed",additionFailed:"addition.failed",removingFailed:"removing.failed"},t.after_init();return t}return t}(c)),Salla.event.infiniteScroll=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="infiniteScroll",t.events={scrollThreshold:"scroll.threshold",request:"request",load:"load",append:"append",error:"error",last:"last",history:"history"},t.after_init();return t}return t}(c)),Salla.event.notifications=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="notifications",t.events={fetched:"fetched",fetchFailed:"fetch.failed"},t.after_init();return t}return t}(c)),Salla.event.component=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="component",t.events={menuFetched:"menus.fetched",menuFetchFailed:"menus.fetch.failed",reviewsFetched:"reviews.fetched",reviewsFetchFailed:"reviews.fetch.failed"},t.after_init();return t}return t}(c)),Salla.event.advertisement=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="advertisement",t.events={fetched:"advertisement.fetched",fetchFailed:"advertisement.not.fetched"},t.after_init();return t}return t}(c)),Salla.event.navigation=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="navigation",t.events={breadcrumbFetched:"breadcrumb.fetched",breadcrumbFetchFailed:"breadcrumb.fetch.failed"},t.after_init();return t}return t}(c)),Salla.event.on("twilight::initiated",(function(){Object.keys(Salla).forEach((function(e){"object"==typeof(e=Salla[e])&&(u(e),Object.keys(e).forEach((function(t){u(e[t])})))}))})),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=function(){return"user"===Salla.config.get("user.type")},Salla.config.isGuest=function(){return!Salla.config.isUser()},Salla.config.languages=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t;var r,n;return __generator(this,(function(a){switch(a.label){case 0:if(Salla.config.triedToGetLanguages_)return[2,Salla.config.get("languages")];Salla.config.triedToGetLanguages_=!0;e=!0,t=[];return[4,salla.document.api.request("languages",null,"get")];case 1:return[2,((n=(r=a.sent())===null||r===void 0?void 0:r.data)===null||n===void 0?void 0:n.map((function(r){e&&(t=[],e=!1),r.code=r.code||r.iso_code,r.url=salla.url.get(r.code),r.is_rtl=r.is_rtl||r.rtl,t.push(r)})),Salla.config.set("languages",t),t)]}}))}))},Salla.config.currencies=function(){return __awaiter(void 0,void 0,void 0,(function(){var e,t;var r,n;return __generator(this,(function(a){switch(a.label){case 0:if(Salla.config.triedToGetCurrencies_)return[2,Salla.config.get("currencies")];Salla.config.triedToGetCurrencies_=!0;e=!0,t={};return[4,salla.currency.api.list()];case 1:return[2,((n=(r=a.sent())===null||r===void 0?void 0:r.data)===null||n===void 0?void 0:n.map((function(r){e&&(t={},e=!1),r.country_code=r.code.substr(0,2).toLowerCase(),t[r.code]=r})),Salla.config.set("currencies",t),t)]}}))}))};var h=function(){function e(){this.endpoints={},this.webEndpoints=[],this.namespace="BaseApi",this.endpointsMethods={},this.endpointsHeaders={};var e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&e.length>1?e[1]:"").toLowerCase(),this.debounce={request:void 0,time:300,enabled:!0,exclude:[]}}e.prototype.after_init=function(){};e.prototype.normalRequest=function(e,t,r){if(t===void 0){t=void 0}if(r===void 0){r=null}var n=Array.isArray(e),a=n?this.getUrl.apply(this,e):this.getUrl(e);e=n?e[0]:e,r=r||this.endpointsMethods[e]||"post";var i=this.endpointsHeaders[e];if("get"===r&&t instanceof FormData){var o={};Array.from(t.entries()).forEach((function(e){o[e[0]]=e[1]})),t={params:o}}return i&&"get"===r&&(t=t?Object.assign(t,i):i),this.webEndpoints.includes(e)?a=salla.url.get(a):"http"!==a.substring(0,4)&&(a=salla.url.api(a)),Salla.api.request(a,t,r,{headers:i})};e.prototype.request=function(e,t,r){if(t===void 0){t=void 0}if(r===void 0){r=null}return!salla.api.isFastRequestsAllowed()&&this.debounce.enabled?(this.debounce.request||(this.debounce.request=salla.helpers.debounce(this.normalRequest.bind(this),this.debounce.time)),this.debounce.request(e,t,r)):this.normalRequest(e,t,r)};e.prototype.getUrl=function(e){var t=this.endpoints[e]||e;var r=/{[^{}]+}/i;for(var n=1;n<arguments.length;n++)t=t.replace(r,arguments[n]);return t};e.prototype.event=function(){return salla.event[this.className]};return e}();var p=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.addToCartTries=0,t.namespace="cart",t.endpoints={latest:"cart/latest",details:"cart/{cart}",quickAdd:"cart/{cart}/item/{product}/quick-add",addItem:"cart/{cart}/item/{product}/add",deleteItem:"cart/{cart}/item/{item}",updateItem:"cart/{cart}/item/{item}",deleteImage:"cart/{cart}/image/{image}",uploadImage:"cart/{cart}/image",status:"cart/{cart}/status",addCoupon:"cart/{id}/coupon",deleteCoupon:"cart/{id}/coupon",getQuickOrderSettings:"checkout/quick-order",createQuickOrder:"checkout/quick-order",priceQuote:"cart/{cartId}/price-quote",offers:"offers/cart/{cartId}"},t.endpointsMethods={latest:"get",details:"get",status:"get",updateItem:"post",deleteItem:"delete",deleteImage:"delete",deleteCoupon:"put",getQuickOrderSettings:"get",offers:"get"},t.webEndpoints=["latest"],t.latestCart=null,t.after_init(),salla.event.on("api::initiated",(function(){return salla.api.cart.getCurrentCartId(!1,"api::initiated")})),salla.event.on("auth::token.fetched",t._checkCurrentCart),salla.event.on("auth::token.invalid",t._checkCurrentCart),salla.event.on("auth::verified",(function(){return salla.api.cart.getCurrentCartId(!0,"auth::verified")}),{async:!0}),salla.event.on("profile::info.fetched",t._checkCurrentCart),salla.event.on("twilight::error",(function(e){return(e.includes("Cart not available")||e.includes("السلة غير متاحة"))&&salla.cart.api.reset()}));return t}t.prototype._checkCurrentCart=function(){var e,t;var r=salla.storage.get("cart"),n=(e=salla.config.get("user"))===null||e===void 0?void 0:e.id,a=(t=salla.config.get("store"))===null||t===void 0?void 0:t.id;r&&r.id&&(r.user_id!==n||r.store_id!==a)&&(salla.log("cart",{user_id:r.user_id,store_id:r.store_id}),salla.log("current",{user_id:n,store_id:a}),salla.log("Api:: case2 => The cart is not belong to current "+(r.user_id!==n?"user":"store")+"!"),salla.cart.api.reset())};t.prototype.getCurrentCartId=function(e,t){if(e===void 0){e=!1}if(t===void 0){t="getCurrentCartId"}return __awaiter(this,void 0,void 0,(function(){var r,n;return __generator(this,(function(a){switch(a.label){case 0:if(!e){if(salla.cart.api.latestCart)return[2,salla.cart.api.latestCart.cart.id];r=salla.storage.get("cart.id");if(r)return[2,r]}return[4,salla.cart.api.latest(t)];case 1:n=a.sent();return[2,(salla.cart.api.latestCart=n.data,salla.cart.api.latestCart.cart.id)]}}))}))};t.prototype.getUploadImageEndpoint=function(e){return salla.url.api(this.getUrl("uploadImage",e||salla.storage.get("cart.id")))};t.prototype.latest=function(e){if(e===void 0){e="direct"}return this.request("latest",{params:{source:"",callerName:e}}).then((function(e){return salla.storage.set("cart",e.data.cart),salla.event.cart.latestFetched(e),e})).catch((function(e){throw salla.storage.set("cart",""),salla.event.cart.latestFailed(e),e}))};t.prototype.details=function(e,t){if(t===void 0){t=[]}return __awaiter(this,void 0,void 0,(function(){var r;return __generator(this,(function(n){switch(n.label){case 0:r=e;if(r)return[3,2];return[4,salla.api.cart.getCurrentCartId(!1,"salla.api.cart.details")];case 1:r=n.sent();n.label=2;case 2:return[2,(e=r,this.request(["details",e],{params:{with:t}}).then((function(e){return salla.cart.event.detailsFetched(e),e})).catch((function(e){throw salla.cart.event.detailsNotFetched(e),e})))]}}))}))};t.prototype.quickAdd=function(e,t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){return[2,this.addItem({id:e,quantity:t,endpoint:"quickAdd"})]}))}))};t.prototype.addItem=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r,n,a;return __generator(this,(function(i){switch(i.label){case 0:t=this.getCartPayload(e);if(!t.id){r='There is no product "id"!';return[2,(salla.cart.event.itemAddedFailed(r),salla.api.errorPromise(r))]}n=salla.form.getPossibleValue(t.payload,["endpoint"]);n&&["addItem","quickAdd"].includes(n)||(n=salla.form.getPossibleValue(t.payload,["quantity","donating_amount"])?"addItem":"quickAdd");return[4,salla.api.cart.getCurrentCartId(!1,"salla.api.cart.addItem")];case 1:a=i.sent();return[2,this.request([n,a,t.id],t.payload).then((function(e){return salla.cart.api.addToCartTries=0,salla.cart.event.itemAdded(e,t.id),e})).catch((function(r){if(!salla.cart.api.addToCartTries)return salla.cart.api.addToCartTries++,salla.cart.reset(),salla.cart.api.addItem(e);throw salla.cart.event.itemAddedFailed(r,t.id),r}))]}}))}))};t.prototype.deleteItem=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r,n;return __generator(this,(function(a){switch(a.label){case 0:t=this.getCartPayload(e);if(!t.id){r='There is no "id"!';return[2,(salla.cart.event.itemDeletedFailed(r),salla.api.errorPromise(r))]}return[4,salla.api.cart.getCurrentCartId(!1,"salla.api.cart.deleteItem")];case 1:n=a.sent();return[2,this.request(["deleteItem",n,t.id]).then((function(e){return salla.cart.event.itemDeleted(e,t.id),e})).catch((function(e){throw salla.cart.event.itemDeletedFailed(e,t.id),e}))]}}))}))};t.prototype.updateItem=function(e){var t;return __awaiter(this,void 0,void 0,(function(){var r,n,a;return __generator(this,(function(i){switch(i.label){case 0:r=this.getCartPayload(e);if(!r.id){n='There is no "id"!';return[2,(salla.cart.event.itemUpdatedFailed(n),salla.api.errorPromise(n))]}return[4,salla.api.cart.getCurrentCartId(!1,"salla.api.cart.updateItem")];case 1:a=i.sent();return[2,("Object"===((t=r.payload.constructor)===null||t===void 0?void 0:t.name)?r.payload._method="PUT":r.payload.append("_method","PUT"),this.request(["updateItem",a,r.id],r.payload).then((function(e){return salla.cart.event.itemUpdated(e,r.id),e})).catch((function(e){throw salla.cart.event.itemUpdatedFailed(e,r.id),e})))]}}))}))};t.prototype.deleteImage=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r;return __generator(this,(function(n){switch(n.label){case 0:if(!(e=salla.form.getPossibleValue(e,["id","image_id","photo_id"]))){t='There is no "id"!';return[2,(salla.cart.event.imageNotDeleted(t),salla.api.errorPromise(t))]}return[4,salla.api.cart.getCurrentCartId(!1,"salla.api.cart.deleteImage")];case 1:r=n.sent();return[2,this.request(["deleteImage",r,e]).then((function(t){return salla.cart.event.imageDeleted(t,e),t})).catch((function(t){throw salla.cart.event.imageNotDeleted(t,e),t}))]}}))}))};t.prototype.status=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r,n,a,i;return __generator(this,(function(o){switch(o.label){case 0:t=(new Date).getTime(),r=Math.random().toString(36).substring(2,15);n=this.request;a=["status"];i=e;if(i)return[3,2];return[4,salla.api.cart.getCurrentCartId(!1,"salla.api.cart.status")];case 1:i=o.sent();o.label=2;case 2:return[2,n.apply(this,[a.concat([i]),{params:{has_apple_pay:salla.helpers.hasApplePay(),"s-hash":"".concat(r,"_").concat(t)}}])]}}))}))};t.prototype.submit=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:if(salla.config.isGuest())return[2,(salla.log("it looks that the current user is not logged-in, lets login then submit"),salla.cart.loginOnCartPage())];e=this.status;return[4,salla.api.cart.getCurrentCartId(!1,"salla.api.cart.submit")];case 1:e.apply(this,[t.sent()]).then((function(e){var t;var r=(t=e.data.next_step)===null||t===void 0?void 0:t.to;if(r||(window.history.pushState({},"",salla.url.addParamToUrl("reload","empty_next_step")),window.history.pushState({},"",salla.url.addParamToUrl("acitve",!1===e.data.active?"false":"true_or_undfined")),salla.cart.reset(),window.location.reload()),!["checkout","refresh","login"].includes(r)){var n="Can't find next_step );";throw salla.cart.reset(),salla.cart.event.submitFailed(n),n}return salla.cart.event.submitted(e),"login"===r?salla.cart.loginOnCartPage():"checkout"===r?window.location.href=e.data.next_step.url+(salla.helpers.hasApplePay()?"?has_apple_pay=true":""):(window.history.pushState({},"",salla.url.addParamToUrl("reload","refresh")),void window.location.reload())})).catch((function(e){var t,r;salla.cart.api.tries=salla.cart.api.tries||0,salla.cart.reset();var n=404===((r=(t=e===null||e===void 0?void 0:e.response)===null||t===void 0?void 0:t.data)===null||r===void 0?void 0:r.status);if(n&&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 n&&salla.error(salla.lang.get("pages.checkout.try_again")),salla.cart.event.submitFailed(e),e}));return[2]}}))}))};t.prototype.getCartPayload=function(e){var t=(e===null||e===void 0?void 0:e.data)||("object"==typeof e?e:void 0);return e=t?salla.form.getPossibleValue(t,["prod_id","product_id","item_id","id"]):e,t="object"==typeof t?t:void 0,{id:e,payload:t}};t.prototype.normalRequest=function(t,r,n){var a=this;if(r===void 0){r=void 0}if(n===void 0){n=null}return e.prototype.normalRequest.call(this,t,r,n).catch((function(e){return __awaiter(a,void 0,void 0,(function(){var t;return __generator(this,(function(r){throw 403===((t=e===null||e===void 0?void 0:e.response)===null||t===void 0?void 0:t.status)&&(this.reset(),salla.error(salla.lang.get("pages.checkout.try_again"))),e}))}))}))};t.prototype.reset=function(){salla.api.cart.latestCart=null,salla.storage.remove("cart"),salla.cart.event.successReset()};t.prototype.addCoupon=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r;return __generator(this,(function(n){switch(n.label){case 0:if(e=e.data||e,!(e=salla.form.getPossibleValue(e,["coupon"]))){t=new Error('There is no "Coupon Code"!');return[2,(t.name="EmptyCoupon",salla.event.cart.couponAdditionFailed(t),salla.api.errorPromise(t))]}return[4,salla.cart.api.getCurrentCartId(!1,"salla.api.cart.addCoupon")];case 1:r=n.sent();return[2,this.request(["addCoupon",r],{coupon:e}).then((function(e){return salla.event.cart.couponAdded(e,r),e})).catch((function(e){throw salla.event.cart.couponAdditionFailed(e,r),e}))]}}))}))};t.prototype.deleteCoupon=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:return[4,salla.cart.api.getCurrentCartId(!1,"salla.api.cart.deleteCoupon")];case 1:e=t.sent();return[2,this.request(["deleteCoupon",e],{}).then((function(t){return salla.event.cart.couponDeleted(t,e),t})).catch((function(t){throw salla.event.cart.couponDeletionFailed(t,e),t}))]}}))}))};t.prototype.getQuickOrderSettings=function(){return this.request("getQuickOrderSettings").then((function(e){return salla.event.cart.quickOrderSettingFetched(e),e})).catch((function(e){throw salla.event.cart.quickOrderSettingFailed(e),e}))};t.prototype.createQuickOrder=function(e){return this.request("createQuickOrder",e).then((function(e){return salla.event.cart.quickOrderSucceeded(e),e})).catch((function(e){throw salla.event.cart.quickOrderFailed(e),e}))};t.prototype.priceQuote=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r,n,a;return __generator(this,(function(i){switch(i.label){case 0:if(!salla.config.isGuest())return[3,1];t=(salla.auth.api.setAfterLoginEvent("cart::priceQuote",e),void salla.event.dispatch("login::open"));return[3,4];case 1:r=this.request;n=["priceQuote"];a=e;if(a)return[3,3];return[4,salla.api.cart.getCurrentCartId(!1,"salla.api.cart.priceQuote")];case 2:a=i.sent();i.label=3;case 3:t=r.apply(this,[n.concat([a])]).then((function(e){return salla.cart.api.reset(),salla.event.cart.priceQuoteSucceeded(e).then((function(){return setTimeout((function(){return window.location.href=salla.url.get("/")}),1e3),e}))})).catch((function(e){return salla.event.cart.priceQuoteFailed(e).then((function(){var t;throw 404===((t=e.error)===null||t===void 0?void 0:t.code)&&window.location.reload(),e}))}));i.label=4;case 4:return[2,t]}}))}))};t.prototype.loginOnCartPage=function(){salla.auth.setCanRedirect(!1),salla.event.dispatch("login::open"),salla.auth.event.onLoggedIn((function(e){salla.event.dispatch("login::close"),salla.cart.submit()}))};t.prototype.offers=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:return[4,salla.cart.api.getCurrentCartId(!1,"salla.api.cart.offers")];case 1:e=t.sent();return[2,this.request(["offers",e]).then((function(e){return salla.event.cart.offersFetched(e),e})).catch((function(e){throw salla.event.cart.offersFailed(e),e}))]}}))}))};return t}(h);var g=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="loyalty",t.endpoints={getProgram:"loyalty",exchange:"loyalty/exchange",reset:"loyalty/exchange"},t.endpointsMethods={getProgram:"get",reset:"put"},t.after_init();return t}t.prototype.getProgram=function(){return this.request("getProgram").then((function(e){return salla.loyalty.event.programFetched(e),e})).catch((function(e){throw salla.loyalty.event.programNotFetched(e),e}))};t.prototype.exchange=function(e,t){if(t===void 0){t=null}return __awaiter(this,void 0,void 0,(function(){var r,n,a;return __generator(this,(function(i){switch(i.label){case 0:if(!(e=salla.form.getPossibleValue(e,["id","loyalty_prize_id","prize_id"]))){r="Unable to find cart id. Please provide one.";return[2,(salla.loyalty.event.exchangeFailed(r),salla.api.errorPromise(r))]}n=t;if(n)return[3,2];return[4,salla.cart.getCurrentCartId(!1,"salla.api.loyalty.exchange")];case 1:n=i.sent();i.label=2;case 2:if(!(t=n)){a="Unable to find cart id. Please provide one.";return[2,(salla.loyalty.event.exchangeFailed(a),salla.api.errorPromise(a))]}return[2,this.request("exchange",{loyalty_prize_id:e,cart_id:t}).then((function(t){return salla.loyalty.event.exchangeSucceeded(t,e),t})).catch((function(t){throw salla.loyalty.event.exchangeFailed(t,e),t}))]}}))}))};t.prototype.reset=function(e){if(e===void 0){e=null}return __awaiter(this,void 0,void 0,(function(){var t,r;return __generator(this,(function(n){switch(n.label){case 0:t=e;if(t)return[3,2];return[4,salla.cart.getCurrentCartId(!1,"salla.api.loyalty.reset")];case 1:t=n.sent();n.label=2;case 2:if(!(e=t)){r="Unable to find cart id. Please provide one.";return[2,(salla.loyalty.event.resetFailed(r),salla.api.errorPromise(r))]}return[2,this.request("reset",{cart_id:e}).then((function(e){return salla.loyalty.event.resetSucceeded(e),e})).catch((function(e){throw salla.loyalty.event.resetFailed(e),e}))]}}))}))};return t}(h);var f=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="auth",t.canRedirect_=!0,t.afterLoginEvent={event:null,payload:null},t.endpoints={login:"auth/{type}/send_verification",resend:"auth/resend_verification",verify:"auth/{type}/verify",register:"auth/register",logout:"logout",refresh:"auth/refresh"},t.webEndpoints=["logout","auth/jwt","refresh"],t.endpointsMethods={logout:"get"},t.after_init();return t}t.prototype.setAfterLoginEvent=function(e,t){salla.api.auth.afterLoginEvent={event:e,payload:t}};t.prototype.setCanRedirect=function(e){salla.api.auth.canRedirect_=e};t.prototype.canRedirect=function(){return salla.api.auth.canRedirect_&&!salla.api.auth.afterLoginEvent.event};t.prototype.login=function(e){(e===null||e===void 0?void 0:e.data)&&(e=e.data);var t=salla.form.getPossibleValue(e,["type"]);if(!["email","mobile"].includes(t)){var r="Login type should be in: [email, mobile]";return salla.auth.event.codeNotSent(r),salla.api.errorPromise(r)}return this.request(["login",t],e).then((function(e){return salla.auth.event.codeSent(e,t),e})).catch((function(e){throw salla.auth.event.codeNotSent(e,t),e}))};t.prototype.verify=function(e,t){if(t===void 0){t=!0}return __awaiter(this,void 0,void 0,(function(){var r,n,a;return __generator(this,(function(i){switch(i.label){case 0:r=salla.form.getPossibleValue(e,["type"]);if(!r){n="Failed to know what's login type!";return[2,(salla.auth.event.verificationFailed(n),salla.api.errorPromise(n))]}t=!1!==salla.form.getPossibleValue(e,["supportWebAuth"])&&t,salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event);return[4,salla.auth.api.request(["verify",r],e)];case 1:a=i.sent();return[2,200!==(a===null||a===void 0?void 0:a.status)?(salla.auth.event.verificationFailed(a,r),salla.api.errorPromise(a)):salla.auth.api.handlAfterAuthenticatedResponse(a,t,r)]}}))}))};t.prototype.handlAfterAuthenticatedResponse=function(e,t,r){var n;return __awaiter(this,void 0,void 0,(function(){var a,i;return __generator(this,(function(o){switch(o.label){case 0:a="authenticated"===((n=e.data)===null||n===void 0?void 0:n.case);a&&salla.auth.event.tokenFetched(e.data.token);i=t;if(!i)return[3,2];return[4,salla.auth.api.request("auth/jwt")];case 1:i=o.sent();o.label=2;case 2:i,a&&salla.auth.event.loggedIn(e).then((function(){return salla.auth.api.afterUserLogin()}));return[4,salla.auth.event.verified(e,r)];case 3:return[2,(o.sent(),salla.api.successPromise(e))]}}))}))};t.prototype.resend=function(e){var t;return(e=e.data||e).type=e.type||"mobile","mobile"!==e.type||e.phone&&e.country_code?"email"!==e.type||e.email?this.request("resend",e).then((function(t){return salla.auth.event.codeSent(t,e),t})).catch((function(t){throw salla.auth.event.codeNotSent(t,e),t})):(salla.auth.event.codeNotSent(t="There is no email!",e),salla.api.errorPromise(t)):(salla.auth.event.codeNotSent(t="There is no phone or country_code!",e),salla.api.errorPromise(t))};t.prototype.register=function(e){var t;return e.data&&(t=e.element,e=e.data),salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event),this.request("register",e).then((function(e){var r;return __awaiter(this,void 0,void 0,(function(){var n;return __generator(this,(function(a){switch(a.label){case 0:salla.auth.event.registered.call(t,e);n="authenticated"===((r=e.data)===null||r===void 0?void 0:r.case);if(!n)return[3,2];salla.auth.event.tokenFetched(e.data.token);return[4,salla.auth.request("auth/jwt")];case 1:n=(a.sent(),salla.auth.event.loggedIn(e),salla.auth.api.afterUserLogin());a.label=2;case 2:return[2,(n,e)]}}))}))})).catch((function(e){throw salla.auth.event.registrationFailed.call(t,e),e}))};t.prototype.logout=function(e){if(e===void 0){e="twilight"}return salla.storage.clearAll(),salla.cookie.clearAll(),e=encodeURI(e),salla.auth.event.loggedOut().then((function(){var t=salla.url.get("logout?from=".concat(e));console.log("Going to ".concat(t,", to do any thing before this action use: salla.auth.even.onLoggedOut(()=>{...})"));try{location.href=t}catch(e){salla.log(e)}}))};t.prototype.refresh=function(){return this.request("refresh").then((function(e){return salla.auth.event.tokenFetched(e.data.token),e})).catch((function(e){throw salla.auth.event.refreshFailed(e),e}))};t.prototype.afterUserLogin=function(){this.afterLoginEvent.event&&salla.event.emit(this.afterLoginEvent.event,this.afterLoginEvent.payload)};return t}(h);var m=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="order",t.endpoints={cancel:"orders/cancel/{id}",createCartFromOrder:"reorder/{id}",sendInvoice:"orders/send/{id}",fetch:"orders"},t.endpointsMethods={createCartFromOrder:"get",fetch:"get"},t.after_init();return t}t.prototype.show=function(e){var t=salla.form.getPossibleValue((e===null||e===void 0?void 0:e.data)||e,["id","order_id"]);salla.event.dispatch("mobile::order.placed",{order_id:t}),location.href=salla.form.getPossibleValue((e===null||e===void 0?void 0:e.data)||e,["url"])};t.prototype.cancel=function(e){return e=e||Salla.config.get("page.id"),this.request(["cancel",e],{params:{has_apple_pay:salla.helpers.hasApplePay()}}).then((function(t){return salla.event.order.canceled(t,e),t})).catch((function(t){throw salla.event.order.notCanceled(t,e),t}))};t.prototype.createCartFromOrder=function(e){return e=e||salla.config.get("page.id"),this.request(["createCartFromOrder",e]).then((function(t){return salla.cart.reset(),salla.event.order.orderCreated(t,e),window.location.href=t.data.url,t})).catch((function(t){throw salla.event.order.orderCreationFailed(t,e),t}))};t.prototype.sendInvoice=function(e){var t=salla.form.getPossibleValue(e,["id"])||salla.config.get("page.id");if(!t||isNaN(t)){var r="There is no id!";return salla.order.event.invoiceNotSent(r),salla.api.errorPromise(r)}return this.request(["sendInvoice",t],e).then((function(e){return salla.event.order.invoiceSent(e,t),e})).catch((function(e){throw salla.event.order.invoiceNotSent(e,t),e}))};t.prototype.fetch=function(e){return this.request(["fetch"],{params:e}).then((function(e){return salla.event.order.ordersFetched(e),e})).catch((function(e){throw salla.event.order.ordersNotFetched(e),e}))};return t}(h);var v=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="product",t.previousQuery="",t.endpoints={getPrice:"products/{id}/price",availabilitySubscribe:"products/{id}/availability-notify",search:"products/search",details:"products/{product_id}/details",categories:"products/categories/{?id}",offers:"products/{product_id}/specialoffer",getSizeGuides:"products/{prod_id}/size-guides",giftDetail:"products/{product_id}/buy-as-gift",giftToCart:"products/{product_id}/buy-as-gift",giftImage:"products/buy-as-gift/image",buyNow:"products/{product_id}/buy-now",fetch:"products",fetchOptions:"products/options"},t.endpointsMethods={details:"get",giftDetail:"get",fetch:"get",offers:"get",fetchOptions:"get"},t.after_init();return t}t.prototype.getPrice=function(e){var t=e.data||e,r=salla.form.getPossibleValue(t,["id","prod_id","product_id"]);return this.request(["getPrice",r],"object"==typeof t?t:void 0).then((function(e){return salla.product.event.priceUpdated(e,r),e})).catch((function(e){throw salla.product.event.priceUpdateFailed(e,r),e}))};t.prototype.categories=function(e){return this.request(["categories",e||""],null,"get").then((function(e){return salla.product.event.categoriesFetched(e),e})).catch((function(e){throw salla.product.event.categoriesFailed(e),e}))};t.prototype.availabilitySubscribe=function(e){var t=e.data||e;return e=salla.form.getPossibleValue(t,["id","prod_id"]),this.request(["availabilitySubscribe",e],"object"==typeof t?t:void 0).then((function(t){return salla.product.event.availabilitySubscribed(t,e),t})).catch((function(t){throw salla.product.event.availabilitySubscribeFailed(t,e),t}))};t.prototype.search=function(e){var t;var r=e.data;if(r||(r={params:"string"==typeof e?{query:e}:e}),!(e=r instanceof FormData?r.get("query"):r.query||((t=r.params)===null||t===void 0?void 0:t.query))){var n='There is no "query"!';return salla.product.event.searchFailed(n),salla.api.errorPromise(n)}if(e===salla.api.product.previousQuery){var a="Query is same as previous one!";return salla.product.event.searchFailed(a),salla.api.product.previousQuery=null,salla.api.errorPromise(a)}return salla.api.product.previousQuery=e,this.request("search",r,"get").then((function(t){return salla.product.event.searchResults(t,e),t})).catch((function(t){throw salla.product.event.searchFailed(t,e),t}))};t.prototype.offers=function(e){if(!(e=salla.form.getPossibleValue((e===null||e===void 0?void 0:e.data)|e,["product_id","id"]))){var t='There is no "product_id"!';return salla.product.event.fetchOffersFailed(t),salla.api.errorPromise(t)}return this.request(["offers",e]).then((function(t){return salla.product.event.offersFetched(t,e),t})).catch((function(t){throw salla.product.event.fetchOffersFailed(t,e),t}))};t.prototype.getSizeGuides=function(e){return this.request("products/".concat(e,"/size-guides"),null,"get").then((function(t){return salla.product.event.sizeGuideFetched(t,e),t})).catch((function(t){throw salla.product.event.sizeGuideFetchFailed(t,e),t}))};t.prototype.getGiftDetails=function(e){return this.request(["giftDetail",e]).then((function(t){return salla.product.event.giftFetched(t,e),t})).catch((function(t){throw salla.product.event.giftFetchFailed(t,e),t}))};t.prototype.getDetails=function(e,t){if(t===void 0){t=[]}if(!Array.isArray(t)){var r="withItems should be array.";return salla.product.event.detailFetchFailed(r),salla.api.errorPromise(r)}if(!e){var n="productId is not passed.";return salla.product.event.detailFetchFailed(n),salla.api.errorPromise(n)}return this.request(["details",e],{params:{with:t}}).then((function(t){return salla.product.event.detailFetched(t,e),t})).catch((function(t){throw salla.product.event.availabilitySubscribeFailed(t,e),t}))};t.prototype.addGiftToCart=function(e,t,r){if(r===void 0){r=!1}return this.request(["giftToCart",e],t).then((function(t){return salla.product.event.addGiftToCartSucceeded(t,e),r&&(window.location.href=t.redirect),t})).catch((function(t){throw salla.product.event.addGiftToCartFailed(t,e),t}))};t.prototype.uploadGiftImage=function(e){return this.request("giftImage",e).then((function(e){return salla.product.event.giftImageUploadSucceeded(e),e})).catch((function(e){throw salla.product.event.giftImageUploadFailed(e),e}))};t.prototype.fetch=function(e){var t=this;if(!e.source){var r="Source cannot be empty. Please provide one.";return salla.product.event.productListFetchFailed(r),salla.api.errorPromise(r)}var n=!e.source_value,a="string"==typeof e.source_value&&"[]"===e.source_value,i=Array.isArray(e.source_value)&&!e.source_value.length;if((n||a||i)&&!["offers","latest","sales","wishlist","top-rated"].includes(e.source)){var o="Source value cannot be empty. Please provide one.";return salla.product.event.productListFetchFailed(o),salla.api.errorPromise(o)}if(["categories","brands","tags","selected"].includes(e.source)&&!Array.isArray(e.source_value)){var s="SourceValue type error. Expected an array.";return salla.product.event.productListFetchFailed(s),salla.api.errorPromise(s)}if("search"===e.source&&"string"!=typeof e.source_value){var l="SourceValue type error. Expected a string.";return salla.product.event.productListFetchFailed(l),salla.api.errorPromise(l)}if("related"===e.source&&isNaN(e.source_value)){var c="SourceValue type error. Expected a number.";return salla.product.event.productListFetchFailed(c),salla.api.errorPromise(c)}return this.request(this.endpoints.fetch,{params:e},"get").then((function(r){return __awaiter(t,void 0,void 0,(function(){var t,n;return __generator(this,(function(a){switch(a.label){case 0:if(!(salla.product.event.productListFetchSucceeded(r),e.includes&&e.includes.includes("options")&&r.data))return[3,2];t=r.data.map((function(e){return e.id}));return[4,this.fetchOptions(t)];case 1:n=a.sent();this.updateProductOptions(r.data,n.data);a.label=2;case 2:return[2,r]}}))}))})).catch((function(e){throw salla.product.event.productListFetchFailed(e),e}))};t.prototype.updateProductOptions=function(e,t){var r=new Map(t.map((function(e){return[e.id,e.options]})));for(var n=0,a=e;n<a.length;n++){var i=a[n];i.options=r.get(i.id)}};t.prototype.fetchOptions=function(e){if(!e||0===e.length){var t="At least one product ID is required. Please provide a valid list of product IDs.";return salla.product.event.productOptionsNotFetched(t),salla.api.errorPromise(t)}var r={selected:e};return this.request(this.endpoints.fetchOptions,{params:r},"get").then((function(e){return salla.product.event.productOptionsFetched(e),e})).catch((function(e){throw salla.product.event.productOptionsNotFetched(e),e}))};return t}(h);var y=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="profile",t.endpoints={info:"auth/user",update:"profile/update",updateContacts:"profile/contacts/update",updateSettings:"profile/settings",verify:"profile/verify",delete:"profile"},t.endpointsMethods={delete:"delete"},t.after_init();return t}t.prototype.info=function(){return this.request("info",null,"get").then((function(e){var t={id:e.data.id,type:"user",email:e.data.email,mobile:e.data.phone.code+e.data.phone.number,country_code:e.data.phone.country,language_code:e.data.language,currency_code:e.data.currency,notifications:e.data.notifications,pending_orders:e.data.pending_orders,avatar:e.data.avatar,first_name:e.data.first_name,last_name:e.data.last_name,fetched_at:Date.now()};return salla.config.set("user",t),salla.storage.set("user",t),salla.profile.event.infoFetched(e),e})).catch((function(e){throw salla.profile.event.infoNotFetched(e),e}))};t.prototype.update=function(e){return this.request("update",e).then((function(e){return salla.profile.event.updated(e),e})).catch((function(e){throw salla.event.profile.updateFailed(e),e}))};t.prototype.updateContacts=function(e){return this.request("updateContacts",e).then((function(e){return salla.profile.event.verificationCodeSent(e),e})).catch((function(e){throw salla.event.profile.updateContactsFailed(e),e}))};t.prototype.verify=function(e){return this.request("verify",e).then((function(e){return salla.profile.event.verified(e),e})).catch((function(e){throw salla.event.profile.unverified(e),e}))};t.prototype.updateSettings=function(e){return this.request("updateSettings",e).then((function(e){return salla.event.profile.settingsUpdated(e),e})).catch((function(e){throw salla.event.profile.updateSettingsFailed(e),e}))};t.prototype.delete=function(){return this.request("delete").then((function(e){return salla.storage.clearAll(),salla.cookie.clearAll(),salla.event.profile.deleted(e),window.location.href=salla.url.get("logout"),e})).catch((function(e){throw salla.event.profile.notDeleted(e),e}))};return t}(h);var w=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="comment",t.endpoints={addComment:"{type}/{id}/comments",comments:"/comments"},t.after_init();return t}t.prototype.add=function(e){if((e===null||e===void 0?void 0:e.data)&&(e=e.data),"string"==typeof(e=this.getCommentPayload(e,!0)))return salla.event.comment.additionFailed(e),salla.api.errorPromise(e);if(!e.comment){var t="can't find comment content!";return salla.event.comment.additionFailed(t),salla.api.errorPromise(t)}return this.request(["addComment",e.type,e.id],{comment:e.comment}).then((function(t){return salla.event.comment.added(t,e.id),t})).catch((function(t){throw salla.event.comment.additionFailed(t,e.id),t}))};t.prototype.getCommentPayload=function(e,t){if(t===void 0){t=!1}var r={};if(["id","type","comment","per_page","page","sort"].forEach((function(t){var n=salla.form.getPossibleValue(e,[t]);n&&(r[t]=n)})),!t){var n=e.ids;if(n&&(r.ids=Array.isArray(n)?n:[n]),!r.ids||!r.ids.length)return"Failed to get ids!"}return r.type&&["products","pages","product","page"].includes(r.type)?(r.type+=["product","page"].includes(r.type)?"s":"",r):"Failed to get type one of:(products, product, page, pages)!"};t.prototype.fetchComments=function(e){if("string"==typeof(e=this.getCommentPayload(e)))return salla.event.comment.fetchFailed(e),salla.api.errorPromise(e);var t={per_page:e.per_page||5,page:e.page||1,type:e.type,ids:e.ids};return e.sort&&(t.sort=e.sort),this.request(["comments"],{params:t},"get").then((function(t){return salla.event.comment.fetched(t,e),t})).catch((function(t){throw salla.event.comment.fetchFailed(t,e),t}))};t.prototype.getPageComments=function(e,t,r,n){if(t===void 0){t=1}if(r===void 0){r=5}return this.fetchComments({ids:[e],type:"pages",page:t,per_page:r,sort:n})};t.prototype.getProductComments=function(e,t,r,n){if(t===void 0){t=1}if(r===void 0){r=5}return this.fetchComments({ids:[e],type:"products",page:t,per_page:r,sort:n})};return t}(h);var b=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="currency",t.endpoints={change:"/",list:"currencies"},t.endpointsMethods={change:"get",list:"get"},t.webEndpoints=["change"],t.after_init();return t}t.prototype.change=function(e){if(!(e=salla.form.getPossibleValue(e.data||e,["currency","code"]))){var t="Can't find currency code!";return salla.currency.event.failed(t),salla.api.errorPromise(t)}return this.request("change",{params:{change_currency:"",currency:e}}).then((function(t){return salla.cookie.set("fresh_summary",1),salla.storage.set("cart",""),salla.currency.event.changed(t,e),t})).catch((function(t){throw salla.currency.event.failed(t,e),t}))};t.prototype.list=function(){return this.request("list").then((function(e){return salla.currency.event.fetched(e),e})).catch((function(e){throw salla.currency.event.failedToFetch(e),e}))};return t}(h);var F=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="document";return t}return t}(h);var _=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="rating",t.endpoints={store:"rating/store",products:"rating/products",shipping:"rating/shipping",order:"rating/{order_id}"},t.endpointsMethods={order:"get"},t.after_init();return t}t.prototype.order=function(e){var t="object"==typeof e?e:{},r=salla.form.getPossibleValue((e===null||e===void 0?void 0:e.data)||e,["order_id","id"]);if(!r){var n='There is no "order_id"!';return salla.event.rating.orderNotFetched(n),salla.api.errorPromise(n)}return this.request(["order",r],t).then((function(e){return salla.event.rating.orderFetched(e,r),e})).catch((function(e){throw salla.event.rating.orderNotFetched(e,r),e}))};t.prototype.store=function(e){if(!(e=(e===null||e===void 0?void 0:e.data)||e)){var t='There is no "data"!';return salla.event.rating.storeFailed(t),salla.api.errorPromise(t)}return this.request("store",e).then((function(t){return salla.event.rating.storeRated(t,e),t})).catch((function(t){throw salla.event.rating.storeFailed(t,e),t}))};t.prototype.products=function(e){if(!(e=(e===null||e===void 0?void 0:e.data)||e)){var t='There is no "data"!';return salla.event.rating.productsFailed(t),salla.api.errorPromise(t)}return this.request("products",e).then((function(t){return salla.event.rating.productsRated(t,e),t})).catch((function(t){throw salla.event.rating.productsFailed(t,e),t}))};t.prototype.shipping=function(e){if(!(e=(e===null||e===void 0?void 0:e.data)||e)){var t='There is no "data"!';return salla.event.rating.shippingFailed(t),salla.api.errorPromise(t)}return this.request("shipping",e).then((function(t){return salla.event.rating.shippingRated(t,e),t})).catch((function(t){throw salla.event.rating.shippingFailed(t,e),t}))};return t}(h);var S=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="wishlist",t.endpoints={add:"products/favorites/{id}",remove:"products/favorites/{id}"},t.endpointsMethods={remove:"delete"},t.after_init();return t}t.prototype.toggle=function(e){return salla.storage.get("salla::wishlist",[]).includes(e)?this.remove(e):this.add(e)};t.prototype.add=function(e){var t=this;var r;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(r=salla.lang.get("common.messages.must_login")),salla.error(r),salla.api.errorPromise(r)):(e=salla.form.getPossibleValue((e===null||e===void 0?void 0:e.data)||e,["product_id","id"]))?this.request(["add",e]).then((function(r){return t.updateWishlistStorage(e),salla.wishlist.event.added(r,e),r})).catch((function(t){throw salla.wishlist.event.additionFailed(t,e),t})):(salla.wishlist.event.additionFailed(r="Failed to get product id!"),salla.api.errorPromise(r))};t.prototype.remove=function(e){var t=this;var r;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(r=salla.lang.get("common.messages.must_login")),salla.error(r),salla.api.errorPromise(r)):(e=salla.form.getPossibleValue((e===null||e===void 0?void 0:e.data)||e,["product_id","id"]))?this.request(["remove",e]).then((function(r){return t.updateWishlistStorage(e,!1),salla.wishlist.event.removed(r,e),r})).catch((function(t){throw salla.wishlist.event.removingFailed(t,e),t})):(salla.wishlist.event.removingFailed(r="Failed to get id!"),salla.api.errorPromise(r))};t.prototype.updateWishlistStorage=function(e,t){if(t===void 0){t=!0}var r=salla.storage.get("salla::wishlist",[]);t?r.push(e):r.splice(r.indexOf(e),1),salla.storage.set("salla::wishlist",r)};return t}(h);var q=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="scopes",t.endpoints={get:"scopes",change:"scopes",getProductAvailability:"scopes/availability?product_id={id}"},t.after_init();return t}t.prototype.get=function(){return this.request("scopes",null,"get").then((function(e){return salla.scope.event.fetched(e),e})).catch((function(e){throw salla.scope.event.notFetched(e),e}))};t.prototype.change=function(e){return this.request("scopes",e).then((function(e){return salla.scope.event.changeSucceeded(e),e})).catch((function(e){throw salla.scope.event.changeFailed(e),e}))};t.prototype.getProductAvailability=function(e){if(e===void 0){e=null}return this.request("scopes/availability?product_id=".concat(e),null,"get").then((function(t){return salla.scope.event.productAvailabilityFetched(t,e),t})).catch((function(e){throw salla.scope.event.productAvailabilityNotFetched(e),e}))};return t}(h);var C=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="booking",t.endpoints={add:"cart/booking/product/{id}"},t.endpointsMethods={add:"get"};return t}t.prototype.add=function(e,t){if(t===void 0){t=!0}return __awaiter(this,void 0,void 0,(function(){var r;return __generator(this,(function(n){if(!e){r="Please provide product id.";return[2,(salla.booking.event.additionFailed(r),salla.api.errorPromise(r))]}return[2,this.request(["add",e]).then((function(e){return salla.booking.event.added(e),t&&"booking"===e.data.redirect.to&&(window.location.href=e.data.redirect.url),e})).catch((function(e){throw salla.booking.event.additionFailed(e),e}))]}))}))};return t}(h);var P=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="landing",t.endpoints={getDetails:"landing/{landing_page_id}",createCartFromPage:"landing/{landing_page_id}",breadcrumbs:"breadcrumbs"},t.endpointsMethods={getDetails:"get",breadcrumbs:"get"},t.after_init();return t}t.prototype.getDetails=function(e){if(!e){var t="page landing id not passed";return salla.event.landing.getDetailsFailed(t),salla.api.errorPromise(t)}return this.request(["getDetails",e]).then((function(t){return salla.event.landing.detailsFetched(t,e),t})).catch((function(t){throw salla.event.landing.getDetailsFailed(t,e),t}))};t.prototype.createCartFromPage=function(e){if(!e){var 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",e),salla.event.dispatch("login::open"),salla.api.successPromise("")):this.request(["createCartFromPage",e]).then((function(t){return salla.event.landing.orderCreated(t,e).then((function(){return location.href=t.data.url})),t})).catch((function(t){throw salla.event.landing.orderCreationFailed(t,e),t}))};t.prototype.fetchBreadcrumbs=function(e){if(!e.page){var 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"===e.page&&!e.id&&!e.parent_id){var r="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(r),salla.api.errorPromise(r)}if(["product.index","customer.orders.single","product.index.tag","page-single","landing-page","brands.single","blog.single","blog.index.author","blog.index.category","blog.index.tag"].includes(e.page)&&!e.id){var n="The 'id' parameter is required when the 'page' parameter is set to ".concat(e.page,". Please provide valid value for the 'ID' parameter.");return salla.event.landing.breadcrumbFetchFailed(n),salla.api.errorPromise(n)}return this.request("breadcrumbs",{params:e}).then((function(e){return salla.event.landing.breadcrumbFetched(e),e})).catch((function(e){throw salla.event.landing.breadcrumbFetchFailed(e),e}))};return t}(h);var A=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="notifications",t.endpoints={fetch:"notifications"},t.endpointsMethods={fetch:"get"},t.after_init();return t}t.prototype.fetch=function(e){return this.request(["fetch"],{params:e}).then((function(e){return salla.event.notifications.fetched(e),e})).catch((function(e){throw salla.event.notifications.fetchFailed(e),e}))};return t}(h);var x=function(){function e(){var e=this;salla.event.on("twilight::before.ready",(function(t){return e.initiateRequest(t)})),salla.event.on("profile::info.fetched",(function(t){return e.setCurrencyAndLanguage(t)})),salla.event.on("auth::token.fetched",(function(t){salla.storage.set("token",t),e.setToken(t)})),salla.event.on("auth::token.invalid",(function(){salla.storage.remove("user"),salla.storage.remove("token")})),this.notifier_handler_disabled=!1,this.axios=axios.create({headers:{common:{"X-Requested-With":"XMLHttpRequest","S-SOURCE":"twilight","S-APP-VERSION":"v2.0.0","S-APP-OS":"browser","cache-control":"no-cache"}}})}e.prototype.getHeaders=function(){return this.axios.defaults.headers.common};e.prototype.setHeaders=function(e){var t=this;return Object.entries(e).forEach((function(e){return t.setHeader(e[0],e[1])})),this};e.prototype.setHeader=function(e,t){return salla.infiniteScroll.fetchOptions.headers[e]=this.axios.defaults.headers.common[e]=t,this};e.prototype.withoutNotifier=function(e){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(r){switch(r.label){case 0:this.notifier_handler_disabled=!0;return[4,e().finally((function(){t.notifier_handler_disabled=!1}))];case 1:return[2,r.sent()]}}))}))};e.prototype.initiateRequest=function(e){var t,r;return __awaiter(this,void 0,void 0,(function(){var n,a;return __generator(this,(function(i){switch(i.label){case 0:this.axios.defaults.baseURL=Salla.config.get("store.api",Salla.config.get("store.url")),this.setHeaders(__assign({"Store-Identifier":Salla.config.get("store.id"),currency:((t=e.user)===null||t===void 0?void 0:t.currency_code)||"SAR","accept-language":salla.lang.getLocale(),"s-user-id":(r=e.user)===null||r===void 0?void 0:r.id},e.headers||{}));n=salla.storage.get("scope");n&&this.setHeaders({"s-scope-type":n.type,"s-scope-id":n.id});a=salla.storage.session.get("s-utms");a&&this.setHeaders(a);return[4,this.injectTokenToTheRequests(e)];case 1:i.sent(),salla.storage.get("affiliate_code")&&this.setHeader("s-affiliate-code",salla.storage.get("affiliate_code"));return[2]}}))}))};e.prototype.injectTokenToTheRequests=function(e){var t;return __awaiter(this,void 0,void 0,(function(){var r,n,a,i,o,s,l,c,u;var d=this;return __generator(this,(function(f){switch(f.label){case 0:r=salla.storage.get("token"),n="guest"===e.user.type,a=(t=e.user)===null||t===void 0?void 0:t.id,i=salla.storage.get("user.id"),o=function(e){d.setToken(e),salla.event.emit("api::initiated")},s=function(){return __awaiter(d,void 0,void 0,(function(){var e;var t=this;return __generator(this,(function(r){switch(r.label){case 0:if(!(!n&&a))return[3,2];salla.log("Api:: case 1 => current is is guest & web session available");return[4,salla.auth.api.refresh().then((function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:return[4,salla.profile.info()];case 1:e.sent();return[2]}}))}))})).catch((function(){return salla.auth.event.tokenInvalid()}))];case 1:e=r.sent();return[3,3];case 2:e=salla.auth.event.tokenInvalid();r.label=3;case 3:e;return[2]}}))}))};if(!!r)return[3,2];salla.log("Api:: case 1 => current is is guest");return[4,s()];case 1:return[2,void f.sent()];case 2:l=o$1(r);if(!(Date.now()/1e3>l.exp))return[3,4];salla.log("Api:: case 2 => current user is logged-in and there is a token, but it's expired");return[4,s()];case 3:c=void f.sent();return[3,8];case 4:if(!(l.sub===a&&i===a&&i&&a))return[3,5];u=(salla.log("Api:: case 4 => current user is logged-in and there is a token, and it's not expired"),void o(r));return[3,7];case 5:salla.log("Api:: case 3 => there is a token and user in session/local missing or mismatch"),salla.log("sub:".concat(l.sub," userIdInWeb:").concat(a," userIdInStorage:").concat(i)),this.setHeader("Authorization","Bearer "+r);return[4,salla.profile.info().then((function(e){return __awaiter(d,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:return[4,salla.auth.api.request("auth/jwt")];case 1:e.sent(),o(r);return[2]}}))}))})).catch((function(){salla.log("Api:: case 3 => failed get fresh profile"),d.setHeader("Authorization",null),salla.auth.event.tokenInvalid()}))];case 6:u=void f.sent();f.label=7;case 7:c=u;f.label=8;case 8:return[2,c]}}))}))};e.prototype.setToken=function(e){return this.setHeader("Authorization","Bearer "+e),salla.event.emit("api::token.injected",e),this.token=e,this};e.prototype.setCurrencyAndLanguage=function(e){return this.setHeaders({currency:e.data.currency,"accept-language":e.data.language})};e.prototype.request=function(e,t,r,n){var a=this;if(t===void 0){t=void 0}if(r===void 0){r="get"}if(n===void 0){n={}}var i={endPoint:e,payload:t,method:r,options:n},o="undefined"!=typeof event?event.currentTarget:null,s=!1;return"SALLA-BUTTON"===(o===null||o===void 0?void 0:o.tagName)&&(s=!0),s&&(o===null||o===void 0?void 0:o.load()),this.axios[i.method](i.endPoint,i.payload,i.options).then((function(e){return s&&(o===null||o===void 0?void 0:o.stop()),e.data&&e.request&&(e=e.data),a.handleAfterResponseActions(e),e})).catch((function(e){throw s&&(o===null||o===void 0?void 0:o.stop()),salla.event.document.requestFailed(i,e),a.handleErrorResponse(e),e}))};e.prototype.handleAfterResponseActions=function(e){if(!e)return;var t=e.data,r=e.googleTags,n=r===void 0?null:r,a=t&&t.googleTags?t.googleTags:n;try{dataLayer&&a&&dataLayer.push(a)}catch(e){salla.logger.error(e.message)}this.fireEventsForResponse(e),this.showAlert(e)};e.prototype.fireEventsForResponse=function(e){var t,r;var n=(e===null||e===void 0?void 0:e.events)||((t=e.data)===null||t===void 0?void 0:t.events)||((r=e.error)===null||r===void 0?void 0:r.events);"string"==typeof n&&(n=JSON.parse(n)),n&&Object.keys(n).forEach((function(e){return salla.event.dispatch(e,n[e])}))};e.prototype.handleErrorResponse=function(e){if(e.response&&e.response.data)return e.response.data.error&&e.response.data.error.fields&&!this.notifier_handler_disabled?this.handleInvalidFields(e):this.handleAfterResponseActions(e.response.data)};e.prototype.showAlert=function(e){var t,r;if(e&&!this.notifier_handler_disabled)return e.case&&e.msg?salla.notify.fire(e.msg,e.case,e):e.hasOwnProperty("success")&&((t=e.data)===null||t===void 0?void 0:t.message)?salla.notify.fire((r=e.data)===null||r===void 0?void 0:r.message,e.success?salla.notify.types.success:salla.notify.types.error,e):e.error&&e.error.message&&"FORBIDDEN"!==e.error.message?salla.error(e.error.message,e):void 0};e.prototype.handleInvalidFields=function(e){var t=e.response.data.error.fields,r=[];Object.keys(t).forEach((function(e){var n=t[e];Array.isArray(n)?n.forEach((function(e){return r.push(e)})):r.push(n)}));var n=(r.length>1?"* ":"")+r.join("\n* ");salla.error(n,e)};e.prototype.isFastRequestsAllowed=function(){return Salla.config.get("fastRequests")};e.prototype.promise=function(e,t){if(t===void 0){t=!0}return new Promise((function(r,n){return t?r(e):n(e)}))};e.prototype.errorPromise=function(e){return this.promise(e,!1)};e.prototype.successPromise=function(e){return this.promise(e,!0)};return e}();var k=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="component",t.endpoints={getMenus:"menus/{headOrFoot}",reviews:"reviews"},t.endpointsMethods={getMenus:"get",reviews:"get"};return t}t.prototype.getMenus=function(e){if(e===void 0){e="header"}return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,this.request(["getMenus",e]).then((function(e){return salla.event.component.menuFetched(e),e})).catch((function(e){throw salla.event.component.menuFetchFailed(e),e}))]}))}))};t.prototype.getReviews=function(e){var t=e.per_page,r=t===void 0?5:t,n=e.type,a=n===void 0?"all":n,i=e.items;return __awaiter(this,void 0,void 0,(function(){var e,t,n,o,s;return __generator(this,(function(l){if(!a){e="Review type cannot be empty. Please provide one.";return[2,(salla.event.component.reviewsFetchFailed(e),salla.api.errorPromise(e))]}t=!i||"string"==typeof i&&"[]"===i||Array.isArray(i)&&!i.length;if(!new Set(["all","store","categories","products","json"]).has(a)){n="Invalid review type. Please provide a valid type.";return[2,(salla.event.component.reviewsFetchFailed(n),salla.api.errorPromise(n))]}if("all"!==a&&"store"!==a&&t){o="Items cannot be empty. Please provide one.";return[2,(salla.event.component.reviewsFetchFailed(o),salla.api.errorPromise(o))]}if(new Set(["products","categories"]).has(a)&&!Array.isArray(i)){s="Items value must be an array of ".concat(a," id for review type of ").concat(a,".");return[2,(salla.event.component.reviewsFetchFailed(s),salla.api.errorPromise(s))]}return[2,this.request(["reviews"],{params:{per_page:r,type:a,items:i}},"get").then((function(e){return salla.event.component.reviewsFetched(e),e})).catch((function(e){throw salla.event.component.reviewsFetchFailed(e),e}))]}))}))};return t}(h);var E=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="booking",t.endpoints={fetch:"advertisements"},t.endpointsMethods={fetch:"get"};return t}t.prototype.fetch=function(e){if(e===void 0){e=null}return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(r){t=e?{page:e}:{};return[2,this.request(["fetch"],{params:t}).then((function(e){return salla.event.advertisement.fetched(e),e})).catch((function(e){throw salla.event.advertisement.fetchFailed(e),e}))]}))}))};return t}(h);var T=function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.namespace="navigation",t.endpoints={breadcrumbs:"breadcrumbs"},t.endpointsMethods={breadcrumbs:"get"},t.after_init();return t}t.prototype.fetchBreadcrumbs=function(e){if(!e.page){var 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(e.page)&&!e.id){var r="The 'id' parameter is required when the 'page' parameter is set to ".concat(e.page,". Please provide valid value for the 'ID' parameter.");return salla.event.navigation.breadcrumbFetchFailed(r),salla.api.errorPromise(r)}return this.request("breadcrumbs",{params:e}).then((function(e){return salla.event.navigation.breadcrumbFetched(e),e})).catch((function(e){throw salla.event.navigation.breadcrumbFetchFailed(e),e}))};return t}(h);var I=function(){function e(e){var t,r;"ready"!==D.status?e?(D.config.merge(e),(e===null||e===void 0?void 0:e.events)&&D.event.dispatchEvents(e===null||e===void 0?void 0:e.events),e._token&&salla.api.setHeader("X-CSRF-TOKEN",e._token),this.injectMaintenanceAlert(),this.injectTemplateStoreAlert(),this.injectThemePreviewAlert(),this.injectAppInstallAlert(),this.injectEditAlert(),((t=e===null||e===void 0?void 0:e.user)===null||t===void 0?void 0:t.language_code)&&salla.lang.setLocale((r=e===null||e===void 0?void 0:e.user)===null||r===void 0?void 0:r.language_code),salla.lang.loadStoreTranslations(),this.setSallaReady(e)):this.setSallaReady(e):salla.log("Trying to re-initiate Salla, while its status === 'ready'!")}e.prototype.injectMaintenanceAlert=function(){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((function(){return document.body.prepend(document.createElement("salla-maintenance-alert"))})))};e.prototype.injectTemplateStoreAlert=function(){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((function(){return document.body.append(document.createElement("salla-bottom-alert"))})))};e.prototype.injectAppInstallAlert=function(){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((function(){return document.body.append(document.createElement("salla-app-install-alert"))})))};e.prototype.injectThemePreviewAlert=function(){"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((function(){var e=document.createElement("div");e.id="s-theme_preview_bar",e.setAttribute("style","display: flex; justify-content: space-between; text-align: center; background-color: #232323; color: #fff; padding: 10px; font-size: 0.875rem; line-height: 1.25rem; position: relative;"),e.innerHTML='\n <div style="display:flex; align-items:center;">\n <img width="32" src="https://cdn.salla.network/images/logo/logo-light.svg">\n <span style="margin:0 10px;">'.concat(salla.lang.get("blocks.header.preview_mode"),': <span style="background:rgba(255,255,255,0.25);border-radius:15px; padding:2px 15px 4px">').concat(salla.config.get("theme.name"),'</span></span>\n </div>\n <a href="').concat(salla.url.get("preview_theme/cancel/preview"),'" style="line-height:32px; width:32px;"><i class="sicon-cancel"></i></a>\n '),document.body.prepend(e)})))};e.prototype.injectEditAlert=function(){var e=salla.config.get("edit");e&&(document.querySelector("#s-edit-alert")?salla.logger.warn("#s-edit-alert element Existed before!"):salla.lang.onLoaded((function(){var t=document.createElement("div");t.id="s-edit-alert",t.innerHTML='\n <a href="'.concat(e,'" style="display:block; background-color:').concat(salla.config.get("theme.color.primary","#5cd5c4"),"; color:").concat(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 ').concat(salla.lang.get("pages.products.quick_edit"),"\n </a>\n "),document.body.prepend(t)})))};e.prototype.handleElementAjaxRequest=function(e,t){var r=this;if(!(t instanceof HTMLFormElement||t instanceof HTMLAnchorElement))return salla.logger.warn("trying to call ajax from non Element!!"),!1;e.preventDefault();var n=t.getAjaxFormData(e),a=n.method?n.method.toLowerCase():void 0;salla.api.request(n.url,n.formData,a).then((function(e){return e.data&&e.request&&(e=e.data),salla.api.handleAfterResponseActions(e),r.callAjaxEvent(n.events.success,e,n.formData),e})).catch((function(e){throw salla.api.handleErrorResponse(e),r.callAjaxEvent(n.events.fail,e,n.formData),e}))};e.prototype.callAjaxEvent=function(e,t,r){if(e){if(r instanceof FormData){var n={};Array.from(r.entries()).forEach((function(e){n[e[0]]=e[1]})),r=n}window[e]?window[e](t,r):salla.event.dispatch(e,t,r)}};e.prototype.setSallaReady=function(e){this.storeUTMs(),D.event.dispatch("twilight::before.ready",e),D.status="ready",D.event.dispatch("twilight::initiated",e),window.dispatchEvent(new CustomEvent("twilight::initiated",{detail:e}))};e.prototype.storeUTMs=function(){var e={fbclid:"facebook",gad_source:"google",ttclid:"tiktok",twclid:"twitter",scid:"snapchat"},t=["fbclid","gad_source","ttclid","twclid","scid"],r=__spreadArray(["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],t,true),n={},a={};__spreadArray([],new URLSearchParams(window.location.search).entries(),true).filter((function(e){var t=e[0];return r.includes(t.toLowerCase())})).forEach((function(e){var t=e[0],r=e[1];return n[t.toLowerCase()]=r}));var i=t.some((function(e){return n[e]}));!n.utm_source&&i&&(n.utm_source=e[i],n.utm_campaign=n.utm_campaign||"Using the CLICKID ".concat(i," provided by ").concat(n.utm_source),n.utm_term=n.utm_term||"".concat(i,": ").concat(n[i])),n.utm_source&&(Object.entries(n).filter((function(e){var r=e[0];return!t.includes(r)})).forEach((function(e){var t=e[0],r=e[1];return a["s-".concat(t.replace("_","-"))]=r})),salla.storage.session.set("s-utms",a))};return e}();D.status="loading",D.notify=o,D.lang=new(function(e){__extends(t,e);function t(t){var r=this;(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,r=e.call(this,t)||this,r.translationsLoaded=!1;return r}t.prototype.onLoaded=function(e){var t=this;return new Promise((function(r){if(t.translationsLoaded)return r(e?e():null);Salla.event.once("languages::translations.loaded",(function(){return r(e?e():null)}))}))};t.prototype.loadStoreTranslations=function(){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.".concat(this.hash)),this.messages&&(this.translationsLoaded=!0)&&e.prototype.setMessages.call(this,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/".concat(this.hash,".js"))):this.loadScript("https://cdn.salla.network/js/translations.js",!1)};t.prototype.setMessages=function(t){e.prototype.setMessages.call(this,t),salla.event.dispatch("languages::translations.loaded"),this.translationsLoaded=!0};t.prototype.loadScript=function(e,t){var r=this;if(t===void 0){t=!0}var n=document.createElement("script");n.src=e,n.onload=function(){var e;if(window.translations)return salla.storage.remove("s_translations"),salla.storage.set("s_translations",(e={},e[r.hash]=window.translations,e)),r.setMessages(window.translations);n.onerror()},n.onerror=function(){if(t)return salla.logger.warn("Failed to load Translations for store, lets try load it from CDN"),r.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)};t.prototype.getWithDefault=function(e,t,r,n){var a=this.get(e,r,n);return a!==e?a:t};t.prototype.get=function(t,r,n){var a=t;(window.translations||this.translationsLoaded)&&(a="trans."+t);var i=e.prototype.get.call(this,a,r,n);return i!==a?i:e.prototype.get.call(this,a,r,"en").replace(a,t)};t.prototype.set=function(e,t){return salla.helpers.setNested(this.messages["".concat(this.getLocale(),".trans")],e,t),this};t.prototype.add=function(e,t){var r=this;return Object.entries(t).forEach((function(t){return salla.helpers.setNested(r.messages[t[0]+".trans"],e,t[1])})),this};t.prototype.addBulk=function(e){var t=this;return Object.entries(e).forEach((function(e){var r=e[0],n=e[1];t.add(r,n)})),this};return t}(lang)),D.form=new(function(){function e(){}e.prototype.submit=function(e,t){var r,n,a,i;if(t===void 0){t=null}return __awaiter(this,void 0,void 0,(function(){var o,s,l;return __generator(this,(function(c){switch(c.label){case 0:o=t;if("SubmitEvent"===((r=t===null||t===void 0?void 0:t.constructor)===null||r===void 0?void 0:r.name)||"submit"===(t===null||t===void 0?void 0:t.type)){if(t.preventDefault(),"FORM"!==((n=t.target)===null||n===void 0?void 0:n.tagName))return[2,(Salla.logger.warn("Failed find the target element for submit action. make sure you submit a form element"),new Promise((function(){throw"Failed find the target element for submit action. make sure you submit a form element"})))];"SALLA-BUTTON"===((i=(a=t===null||t===void 0?void 0:t.submitter)===null||a===void 0?void 0:a.parentElement)===null||i===void 0?void 0:i.tagName)&&t.submitter.parentElement.load(),o=t.target.getElementSallaData(),salla.log("Data from element",o)}if(/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/gm.test(e))return[2,salla.api.request(e,o,"post").finally((function(){var e;loaderSupported&&((e=t===null||t===void 0?void 0:t.submitter)===null||e===void 0?void 0:e.parentElement.stop())}))];s=e.split("."),l=s.splice(-1);return[4,salla.call(s.join("."))[l](o).finally((function(){var e,r;return(r=(e=t===null||t===void 0?void 0:t.submitter)===null||e===void 0?void 0:e.parentElement)===null||r===void 0?void 0:r.stop()})).catch((function(e){throw salla.logger.warn(e),e}))];case 1:return[2,c.sent()]}}))}))};e.prototype.onSubmit=function(e,t){return salla.form.submit(e,t),!1};e.prototype.onChange=function(e,t){var r;return(t===null||t===void 0?void 0:t.currentTarget)?"FORM"!==((r=t===null||t===void 0?void 0:t.currentTarget)===null||r===void 0?void 0:r.tagName)||t.currentTarget.checkValidity()?(salla.form.submit(e,t.currentTarget.getElementSallaData()),!0):(salla.logger.warn("Trying to trigger '".concat(e,"' without filling required fields!")),!1):(salla.logger.warn("Trying to trigger '".concat(e,"' without event!")),!1)};e.prototype.getPossibleValue=function(e,t,r){if(r===void 0){r=!1}if(!e)return;if("object"!=typeof e)return e;var n;for(var a=0;a<t.length&&!(n=e[t[a]])&&!("undefined"!=typeof FormData&&e instanceof FormData&&(n=e.get(t[a])));a++);return n=n||e,"object"!=typeof n||r?n:void 0};return e}()),D.infiniteScroll=new(function(e){__extends(t,e);function t(t,r){var n=this;n=e.call(this,t,r)||this,n.options={path:".infinite-scroll-btn",history:"push",status:".infinite-scroll-status",append:".list-block"},n.fetchOptions={headers:{"S-INFINITE-SCROLL":!0,"S-Source":"twilight","cache-control":"no-cache",pragma:"no-cache"}},n.instances=[];return n}t.prototype.initiate=function(e,t,r,n){if(n===void 0){n=!1}n?((r=r||{}).fetchOptions=__assign(__assign({},this.fetchOptions),r.fetchOptions||{}),r.responseBody="json"):r=this.getCustomOptions(t,r);var a="string"!=typeof e?e:document.querySelector(e),i=r.path;if(!a||!i||"string"==typeof i&&!document.querySelector(i))return void Salla.logger.warn(a?"Path Option (a link that has next page link) Not Existed!":"Container For InfiniteScroll not Existed!");var o=new js(a,r);return o.on("scrollThreshold",Salla.infiniteScroll.event.scrollThreshold),o.on("request",Salla.infiniteScroll.event.request),o.on("load",Salla.infiniteScroll.event.load),o.on("append",Salla.infiniteScroll.event.append),o.on("error",Salla.infiniteScroll.event.error),o.on("last",Salla.infiniteScroll.event.last),o.on("history",Salla.infiniteScroll.event.history),this.instances.push(o),o};t.prototype.getCustomOptions=function(e,t){return(t="object"==typeof e&&e||t||this.options).fetchOptions=this.fetchOptions,t.path=t.path||this.options.path,t.button=t.button||t.path,t.status=t.status||this.options.status,t.hasOwnProperty("history")||(t.history=this.options.history),t.nextPage=t.nextPage||t.next_page,t.append="string"==typeof e&&e||t.append||this.options.append,t};t.prototype.loadNextPage=function(e){("string"!=typeof e?e:document.querySelector(e)).loadNextPage()};t.prototype.destroy=function(e){("string"!=typeof e?e:document.querySelector(e)).destroy()};return t}(d))(void 0,salla.event.infiniteScroll),D.api=new(function(e){__extends(t,e);function t(){var t=this;t=e.call(this)||this,t.auth=new f,t.cart=new p,t.loyalty=new g,t.order=new m,t.rating=new _,t.product=new v,t.profile=new y,t.comment=new w,t.currency=new b,t.document=new F,t.wishlist=new S,t.scope=new q,t.booking=new C,t.landing=new P,t.notifications=new A,t.component=new k,t.advertisement=new E,t.navigation=new T;return t}return t}(x)),["cart","auth","order","scope","rating","comment","loyalty","product","profile","currency","document","wishlist","booking","landing"].forEach((function(e){return D[e]=new d(D.api[e],D.event[e])})),D.call=function(e){var t=D,r=e.split(".");for(;r.length&&(t=t[r.shift()]););return t},D.init=function(e){return new I(e)},salla.event.once("twilight::init",salla.init),salla.event.once("twilight::api",(function(e){var t=e===null||e===void 0?void 0:e.events;t&&salla.event.dispatchEvents(t)})),D.success=D.notify.success,D.error=D.notify.error,D.versions.twilight="[VI]{version}[/VI]",D.onInitiated=function(e){return salla.event.once("twilight::initiated",e)},D.onReady=D.onReady||function(e){return new Promise((function(t){return"ready"===salla.status?t(e?e(salla.config.all()):salla.config.all()):D.onInitiated((function(r){return t(e?e(r):r)}))}))},window.dispatchEvent(new CustomEvent("salla::created"));var lazyload_min=createCommonjsModule((function(e,t){!function(t,r){e.exports=r()}(commonjsGlobal,(function(){function e(){return e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},e.apply(this,arguments)}var t="undefined"!=typeof window,r=t&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),n=t&&"IntersectionObserver"in window,a=t&&"classList"in document.createElement("p"),i=t&&window.devicePixelRatio>1,o={elements_selector:".lazy",container:r||t?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},s=function(t){return e({},o,t)},l=function(e,t){var r,n="LazyLoad::Initialized",a=new e(t);try{r=new CustomEvent(n,{detail:{instance:a}})}catch(e){(r=document.createEvent("CustomEvent")).initCustomEvent(n,!1,!1,{instance:a})}window.dispatchEvent(r)},c="src",u="srcset",d="sizes",f="poster",h="llOriginalAttrs",p="data",v="loading",g="loaded",m="applied",y="error",_="native",b="data-",w="ll-status",S=function(e,t){return e.getAttribute(b+t)},E=function(e){return S(e,w)},A=function(e,t){return function(e,t,r){var n="data-ll-status";null!==r?e.setAttribute(n,r):e.removeAttribute(n)}(e,0,t)},x=function(e){return A(e,null)},F=function(e){return null===E(e)},C=function(e){return E(e)===_},P=[v,g,m,y],O=function(e,t,r,n){e&&(void 0===n?void 0===r?e(t):e(t,r):e(t,r,n))},T=function(e,t){a?e.classList.add(t):e.className+=(e.className?" ":"")+t},k=function(e,t){a?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},L=function(e){return e.llTempImage},j=function(e,t){if(t){var r=t._observer;r&&r.unobserve(e)}},I=function(e,t){e&&(e.loadingCount+=t)},$=function(e,t){e&&(e.toLoadCount=t)},R=function(e){for(var t,r=[],n=0;t=e.children[n];n+=1)"SOURCE"===t.tagName&&r.push(t);return r},D=function(e,t){var r=e.parentNode;r&&"PICTURE"===r.tagName&&R(r).forEach(t)},q=function(e,t){R(e).forEach(t)},N=[c],M=[c,f],U=[c,u,d],H=[p],z=function(e){return!!e[h]},G=function(e){return e[h]},B=function(e){return delete e[h]},V=function(e,t){if(!z(e)){var r={};t.forEach((function(t){r[t]=e.getAttribute(t)})),e[h]=r}},W=function(e,t){if(z(e)){var r=G(e);t.forEach((function(t){!function(e,t,r){r?e.setAttribute(t,r):e.removeAttribute(t)}(e,t,r[t])}))}},K=function(e,t,r){T(e,t.class_applied),A(e,m),r&&(t.unobserve_completed&&j(e,t),O(t.callback_applied,e,r))},Q=function(e,t,r){T(e,t.class_loading),A(e,v),r&&(I(r,1),O(t.callback_loading,e,r))},J=function(e,t,r){r&&e.setAttribute(t,r)},Y=function(e,t){J(e,d,S(e,t.data_sizes)),J(e,u,S(e,t.data_srcset)),J(e,c,S(e,t.data_src))},X={IMG:function(e,t){D(e,(function(e){V(e,U),Y(e,t)})),V(e,U),Y(e,t)},IFRAME:function(e,t){V(e,N),J(e,c,S(e,t.data_src))},VIDEO:function(e,t){q(e,(function(e){V(e,N),J(e,c,S(e,t.data_src))})),V(e,M),J(e,f,S(e,t.data_poster)),J(e,c,S(e,t.data_src)),e.load()},OBJECT:function(e,t){V(e,H),J(e,p,S(e,t.data_src))}},Z=["IMG","IFRAME","VIDEO","OBJECT"],ee=function(e,t){!t||function(e){return e.loadingCount>0}(t)||function(e){return e.toLoadCount>0}(t)||O(e.callback_finish,t)},te=function(e,t,r){e.addEventListener(t,r),e.llEvLisnrs[t]=r},re=function(e,t,r){e.removeEventListener(t,r)},ne=function(e){return!!e.llEvLisnrs},ae=function(e){if(ne(e)){var t=e.llEvLisnrs;for(var r in t){var n=t[r];re(e,r,n)}delete e.llEvLisnrs}},ie=function(e,t,r){!function(e){delete e.llTempImage}(e),I(r,-1),function(e){e&&(e.toLoadCount-=1)}(r),k(e,t.class_loading),t.unobserve_completed&&j(e,r)},oe=function(e,t,r){var n=L(e)||e;ne(n)||function(e,t,r){ne(e)||(e.llEvLisnrs={});var n="VIDEO"===e.tagName?"loadeddata":"load";te(e,n,t),te(e,"error",r)}(n,(function(a){!function(e,t,r,n){var a=C(t);ie(t,r,n),T(t,r.class_loaded),A(t,g),O(r.callback_loaded,t,n),a||ee(r,n)}(0,e,t,r),ae(n)}),(function(a){!function(e,t,r,n){var a=C(t);ie(t,r,n),T(t,r.class_error),A(t,y),O(r.callback_error,t,n),r.restore_on_error&&W(t,U),a||ee(r,n)}(0,e,t,r),ae(n)}))},se=function(e,t,r){!function(e){return Z.indexOf(e.tagName)>-1}(e)?function(e,t,r){!function(e){e.llTempImage=document.createElement("IMG")}(e),oe(e,t,r),function(e){z(e)||(e[h]={backgroundImage:e.style.backgroundImage})}(e),function(e,t,r){var n=S(e,t.data_bg),a=S(e,t.data_bg_hidpi),o=i&&a?a:n;o&&(e.style.backgroundImage='url("'.concat(o,'")'),L(e).setAttribute(c,o),Q(e,t,r))}(e,t,r),function(e,t,r){var n=S(e,t.data_bg_multi),a=S(e,t.data_bg_multi_hidpi),o=i&&a?a:n;o&&(e.style.backgroundImage=o,K(e,t,r))}(e,t,r),function(e,t,r){var n=S(e,t.data_bg_set);if(n){var a=n.split("|"),i=a.map((function(e){return"image-set(".concat(e,")")}));e.style.backgroundImage=i.join(),""===e.style.backgroundImage&&(i=a.map((function(e){return"-webkit-image-set(".concat(e,")")})),e.style.backgroundImage=i.join()),K(e,t,r)}}(e,t,r)}(e,t,r):function(e,t,r){oe(e,t,r),function(e,t,r){var n=X[e.tagName];n&&(n(e,t),Q(e,t,r))}(e,t,r)}(e,t,r)},le=function(e){e.removeAttribute(c),e.removeAttribute(u),e.removeAttribute(d)},ce=function(e){D(e,(function(e){W(e,U)})),W(e,U)},ue={IMG:ce,IFRAME:function(e){W(e,N)},VIDEO:function(e){q(e,(function(e){W(e,N)})),W(e,M),e.load()},OBJECT:function(e){W(e,H)}},de=function(e,t){(function(e){var t=ue[e.tagName];t?t(e):function(e){if(z(e)){var t=G(e);e.style.backgroundImage=t.backgroundImage}}(e)})(e),function(e,t){F(e)||C(e)||(k(e,t.class_entered),k(e,t.class_exited),k(e,t.class_applied),k(e,t.class_loading),k(e,t.class_loaded),k(e,t.class_error))}(e,t),x(e),B(e)},fe=["IMG","IFRAME","VIDEO"],he=function(e){return e.use_native&&"loading"in HTMLImageElement.prototype},pe=function(e,t,r){e.forEach((function(e){return function(e){return e.isIntersecting||e.intersectionRatio>0}(e)?function(e,t,r,n){var a=function(e){return P.indexOf(E(e))>=0}(e);A(e,"entered"),T(e,r.class_entered),k(e,r.class_exited),function(e,t,r){t.unobserve_entered&&j(e,r)}(e,r,n),O(r.callback_enter,e,t,n),a||se(e,r,n)}(e.target,e,t,r):function(e,t,r,n){F(e)||(T(e,r.class_exited),function(e,t,r,n){r.cancel_on_exit&&function(e){return E(e)===v}(e)&&"IMG"===e.tagName&&(ae(e),function(e){D(e,(function(e){le(e)})),le(e)}(e),ce(e),k(e,r.class_loading),I(n,-1),x(e),O(r.callback_cancel,e,t,n))}(e,t,r,n),O(r.callback_exit,e,t,n))}(e.target,e,t,r)}))},ve=function(e){return Array.prototype.slice.call(e)},ge=function(e){return e.container.querySelectorAll(e.elements_selector)},me=function(e){return function(e){return E(e)===y}(e)},ye=function(e,t){return function(e){return ve(e).filter(F)}(e||ge(t))},_e=function(e,r){var a=s(e);this._settings=a,this.loadingCount=0,function(e,t){n&&!he(e)&&(t._observer=new IntersectionObserver((function(r){pe(r,e,t)}),function(e){return{root:e.container===document?null:e.container,rootMargin:e.thresholds||e.threshold+"px"}}(e)))}(a,this),function(e,r){t&&(r._onlineHandler=function(){!function(e,t){var r;(r=ge(e),ve(r).filter(me)).forEach((function(t){k(t,e.class_error),x(t)})),t.update()}(e,r)},window.addEventListener("online",r._onlineHandler))}(a,this),this.update(r)};return _e.prototype={update:function(e){var t,a,i=this._settings,o=ye(e,i);$(this,o.length),!r&&n?he(i)?function(e,t,r){e.forEach((function(e){-1!==fe.indexOf(e.tagName)&&function(e,t,r){e.setAttribute("loading","lazy"),oe(e,t,r),function(e,t){var r=X[e.tagName];r&&r(e,t)}(e,t),A(e,_)}(e,t,r)})),$(r,0)}(o,i,this):(a=o,function(e){e.disconnect()}(t=this._observer),function(e,t){t.forEach((function(t){e.observe(t)}))}(t,a)):this.loadAll(o)},destroy:function(){this._observer&&this._observer.disconnect(),t&&window.removeEventListener("online",this._onlineHandler),ge(this._settings).forEach((function(e){B(e)})),delete this._observer,delete this._settings,delete this._onlineHandler,delete this.loadingCount,delete this.toLoadCount},loadAll:function(e){var t=this,r=this._settings;ye(e,r).forEach((function(e){j(e,t),se(e,r,t)}))},restoreAll:function(){var e=this._settings;ge(e).forEach((function(t){de(t,e)}))}},_e.load=function(e,t){var r=s(t);se(e,r)},_e.resetStatus=function(e){x(e)},t&&function(e,t){if(t)if(t.length)for(var r,n=0;r=t[n];n+=1)l(e,r);else l(e,t)}(_e,window.lazyLoadOptions),_e}))}));function appGlobalScript(){if(!document.lazyLoadInstance){document.lazyLoadInstance=new lazyload_min({use_native:true});document.lazyLoadBackgrounds=new lazyload_min({elements_selector:".lazy[data-bg]:not(.loaded)"})}if(document.readyState!=="complete"){document.addEventListener("DOMContentLoaded",(function(){return document.lazyLoadInstance.update()}));document.addEventListener("DOMContentLoaded",(function(){return document.lazyLoadBackgrounds.update()}))}salla.infiniteScroll.event.onAppend((function(){document.lazyLoadInstance.update();document.lazyLoadBackgrounds.update()}))}var globalScripts=appGlobalScript;export{globalScripts as g};
25
+ //# sourceMappingURL=app-globals-fe94bf06.js.map