@salla.sa/twilight 2.0.214 → 2.0.215
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@salla.sa/twilight.min.js +1 -1
- package/dist/@salla.sa/twilight.min.js.map +1 -1
- package/dist/cjs/main.js +1 -1
- package/dist/cjs/main.js.map +1 -1
- package/dist/esm/main.js +1 -1
- package/dist/esm/main.js.map +1 -1
- package/package.json +1 -1
- package/types/api/cart.d.ts +31 -15
- package/types/api/order.d.ts +14 -0
- package/types/common.d.ts +0 -2
- package/types/event/cart.d.ts +28 -5
- package/types/event/order.d.ts +12 -0
- package/types/index.d.ts +37 -14
- package/types/api/cart/cart-details-response.d.ts +0 -22
- package/types/api/cart/cart-status-response.d.ts +0 -7
- package/types/api/cart/item.d.ts +0 -0
- package/types/api/cart/responses.d.ts +0 -0
- package/types/api/order/re-order-response.d.ts +0 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).salla={})}(this,function(exports){"use strict";let notifier=function(e,t,s){return alert(e,t,s)},setNotifier=function(e){notifier=e},fire=function(e,t,s){return notifier(e,t,s)},error$1=function(e,t){return notifier(e,types.error,t)},info=function(e,t){return notifier(e,types.info,t)},success=function(e,t){return notifier(e,types.success,t)},logger=function(...e){return console.log(console.trace()),console.log(...["%cTwilight","color: white;background:#040c20;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px"].concat(...e))},setLogger=function(e){logger=e},log=function(...e){return logger(...e)};var sallaInitiated=function(){var e=window.location.href.match(/([\?\&]danger=)[^&]+/g);e&&e.forEach(e=>{error$1(decodeURI(e.replace("?danger=","").replace("&danger=","")))})},types={error:"error",success:"success",info:"info"},Notify={fire:fire,setNotifier:setNotifier,log:log,setLogger:setLogger,error:error$1,success:success,info:info,sallaInitiated:sallaInitiated,types:types};class BaseEvent{constructor(e){this.parent=e,this.events={},this.namespace="";e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&1<e.length?e[1]:"").toLowerCase()}after_init(){this.createDynamicFunctions()}createDynamicFunctions(){Object.keys(this.events).forEach(e=>{this.createDynamicEventFuns(e),this.createDynamicListenerFuns(e)})}createDynamicEventFuns(s){if(!this[s]){let t=this;this[s]=function(...e){return t.dispatch(s,...e)}}}createDynamicListenerFuns(s){var e="on"+s.charAt(0).toUpperCase()+s.slice(1);if(!this[e]){let t=this;this[e]=function(e){return t.on(s,e)}}}getEventName(e){return e=this.events[e]||e,!this.namespace||e.includes("::")?e:this.namespace+this.parent.delimiter+e}dispatch(e,...t){return this.parent.dispatch(this.getEventName(e),...t)}on(e,t){this.parent.addListener(this.getEventName(e),t)}register(e,t){this.on(e,t)}registerEventTemporary(e,t,s){s=s||1,emitter.many(e,s,t)}}class CartEvents extends BaseEvent{constructor(e){super(e),this.namespace="cart",this.events={latestFetched:"latest.fetched",latestFailed:"latest.failed",updated:"updated",itemUpdated:"item.updated",itemUpdatedFailed:"item.updated.failed",itemAdded:"item.added",itemAddedFailed:"item.added.failed",itemDeleted:"item.deleted",itemDeletedFailed:"item.deleted.failed",submitted:"submitted",submitFailed:"submit.failed",imageDeleted:"image.deleted",imageNotDeleted:"image.not.deleted",summaryFetched:"summary.fetched",summaryNotFetched:"summary.not.fetched",detailsFetched:"details.fetched",detailsNotFetched:"details.not.fetched",successReset:"success.reset"},this.after_init()}updated(e){return salla.cookie.set("fresh_summary",1),e&&"object"==typeof e?(e.offer&&salla.offer.event.existed(e.offer),salla.storage.set("cart.summary",e={total:e.cart.total,items_total:e.cart.sub_total,total_discount:e.cart.discount,real_shipping_cost:e.cart.real_shipping_cost,count:e.cart.count,shipping_cost:e.cart.free_shipping_bar?.has_free_shipping?0:e.cart.real_shipping_cost}),this.dispatch("updated",e)):(salla.log("Cart summary not an object!",e),this.dispatch("updated"))}itemAdded(e,t){return this.updated(e.data),this.dispatch("itemAdded",e,t)}itemDeleted(e,t){return this.updated(e.data),this.dispatch("itemDeleted",e,t)}itemUpdated(e,t){return this.updated(e.data),this.dispatch("itemUpdated",e,t)}summaryFetched(e){this.updated(e)}fullSummaryFetched(e){this.updated(e)}clearCartSummary(){var e=salla.storage.get("cart_widget_summary");e&&(e.count||e.items||e.items_count)&&salla.cart.api.summary()}}class GiftEvents extends BaseEvent{constructor(e){super(e),this.namespace="gift",this.events={buyingSucceeded:"buying.succeeded",buyingFailed:"buying.failed"},this.after_init()}}class LoyaltyEvents extends BaseEvent{constructor(e){super(e),this.namespace="loyalty",this.events={exchangeSucceeded:"exchange.succeeded",exchangeFailed:"exchange.failed"},this.after_init()}}class AuthEvents extends BaseEvent{constructor(e){super(e),this.namespace="auth",this.events={login:"login",logout:"logout",codeSent:"code.sent",codeNotSent:"code.not-sent",codeReSent:"code.re-sent",codeNotReSent:"code.not.re-sent",verified:"verified",verificationFailed:"verification.failed",loggedIn:"logged.in",registered:"registered",registrationFailed:"registration.failed",loggedOut:"logged.out",failedLogout:"failed.logout",tokenFetched:"token.fetched",refreshFailed:"refresh.failed"},this.after_init()}login(e){return e?(e.type&&this.setTypeActionOnVerified(e.type),this.next_event=e.next_event||null):this.next_event=null,this.dispatch("login",...arguments)}verified(e){return dataLayer&&(dataLayer[0].customer=e.customer),this.dispatch("verified",...arguments)}setTypeActionOnVerified(e){this.type_action_on_verified=e}getTypeActionOnVerified(){return this.type_action_on_verified||"redirect"}}class SearchEvents extends BaseEvent{constructor(e){super(e),this.namespace="search",this.events={finished:"finished",failed:"failed"},this.after_init()}}class WishlistEvents extends BaseEvent{constructor(e){super(e),this.namespace="wishlist",this.events={added:"added",removed:"removed",additionFailed:"addition.failed",removingFailed:"removing.failed"},this.after_init()}}class CommentEvents extends BaseEvent{constructor(e){super(e),this.namespace="comment",this.events={added:"added",additionFailed:"addition.failed"},this.after_init()}}class OrderEvents extends BaseEvent{constructor(e){super(e),this.namespace="order",this.events={canceled:"canceled",notCanceled:"not.canceled",reOrdered:"re.ordered",reOrderFailed:"re.order.failed"},this.after_init()}}class InfiniteScrollEvents extends BaseEvent{constructor(e){super(e),this.namespace="infiniteScroll",this.events={scrollThreshold:"scroll.threshold",request:"request",load:"load",append:"append",error:"error",last:"last",history:"history"},this.after_init()}}class DocumentEvents extends BaseEvent{constructor(e){super(e),this.namespace="document",this.events={click:"click",change:"change",submit:"submit",keyup:"keyup",leaving:"leaving",request:"request",requestFailed:"request.failed"},this.after_init()}onClick(e,t){this.fireCallableFuns("click",e,t)}onChange(e,t){this.fireCallableFuns("change",e,t)}onSubmit(e,t){this.fireCallableFuns("submit",e,t)}onKeyup(e,t){this.fireCallableFuns("keyup",e,t)}fireCallableFuns(e,t,s){this.on(e,e=>{"function"!=typeof t?"function"==typeof s&&e.target.matches(t)&&s(e):t(e)})}fireEvent(e,t,...s){return this.fireEventForElements(e,t,!1,...s)}fireEventForAll(e,t,...s){return this.fireEventForElements(e,t,!0,...s)}fireEventForElements(e,t,s,...r){if("string"==typeof e){if(s)return document.querySelectorAll(e).forEach(e=>this.fireEventForElements(e,t,!1,...r));e=document.querySelector(e)}{if(e)return s=new CustomEvent(t,...r),e.dispatchEvent(s);salla.log("Failed To get element to fire event: "+t)}}}class ProductEvents extends BaseEvent{constructor(e){super(e),this.namespace="product",this.events={priceUpdated:"price.updated",priceUpdateFailed:"price.updated.failed",availabilitySubscribed:"availability.subscribed",availabilitySubscribeFailed:"availability.subscribe.failed"},this.after_init()}}class OfferEvents extends BaseEvent{constructor(e){super(e),this.namespace="offer",this.events={existed:"existed",increased:"increase",increaseFailed:"increase.failed",fetchDetailsFailed:"fetch.details.failed",detailsFetched:"details.fetched"},this.after_init()}}class CouponEvents extends BaseEvent{constructor(e){super(e),this.namespace="coupon",this.events={added:"added",removed:"removed",addedFailed:"added.failed",removedFailed:"removed.failed"},this.after_init()}added(e,t){return salla.event.cart.updated(e.data),this.dispatch("added",e,t)}removed(e,t){return salla.event.cart.updated(e.data),this.dispatch("removed",e,t)}}class FeedbackEvents extends BaseEvent{constructor(e){super(e),this.namespace="feedback",this.events={orderNotFetched:"order.not.fetched",orderFetched:"order.fetched",storeRated:"store.rated",storeFailed:"store.failed",productRated:"product.rated",productFailed:"product.failed",shippingRated:"shipping.rated",shippingFailed:"shipping.failed"},this.after_init()}}class CurrencyEvents extends BaseEvent{constructor(e){super(e),this.namespace="currency",this.events={changed:"changed",failed:"failed",fetched:"fetched",failedToFetch:"failed.to.fetch"},this.after_init()}changed(...e){return salla.cart.api.summary().then(()=>this.dispatch("changed",...e))}}class TwilightEvents extends BaseEvent{constructor(e){super(e),this.namespace="twilight",this.events={initiated:"initiated"},this.after_init()}}class ScopeEvents extends BaseEvent{constructor(e){super(e),this.namespace="scope",this.events={},this.after_init()}}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},eventemitter2$1={exports:{}},eventemitter2=(!function(e){function h(){this._events={},this._conf&&t.call(this,this._conf)}function t(e){e&&((this._conf=e).delimiter&&(this.delimiter=e.delimiter),e.maxListeners!==y&&(this._maxListeners=e.maxListeners),e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),e.ignoreErrors&&(this.ignoreErrors=e.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function d(e,t){var s="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";this.verboseMemoryLeak&&(s+=" Event name: "+t+"."),"undefined"!=typeof process&&process.emitWarning?((t=new Error(s)).name="MaxListenersExceededWarning",t.emitter=this,t.count=e,process.emitWarning(t)):(console.error(s),console.trace&&console.trace())}function c(e,t,s){var r=arguments.length;switch(r){case 0:return[];case 1:return[e];case 2:return[e,t];case 3:return[e,t,s];default:for(var i=new Array(r);r--;)i[r]=arguments[r];return i}}function s(e,t){for(var s={},r=e.length,i=t?value.length:0,n=0;n<r;n++)s[e[n]]=n<i?t[n]:y;return s}function p(e,t,s){var r,i;if(this._emitter=e,this._target=t,this._listeners={},this._listenersCount=0,(s.on||s.off)&&(r=s.on,i=s.off),t.addEventListener?(r=t.addEventListener,i=t.removeEventListener):t.addListener?(r=t.addListener,i=t.removeListener):t.on&&(r=t.on,i=t.off),!r&&!i)throw Error("target does not implement any known event API");if("function"!=typeof r)throw TypeError("on method must be a function");if("function"!=typeof i)throw TypeError("off method must be a function");this._on=r,this._off=i;s=e._observers;s?s.push(this):e._observers=[this]}function f(e,t,s,r){var i=Object.assign({},t);if(!e)return i;if("object"!=typeof e)throw TypeError("options must be an object");var n,a,o,l=Object.keys(e),c=l.length;function u(e){throw Error('Invalid "'+n+'" option value'+(e?". Reason: "+e:""))}for(var h=0;h<c;h++){if(n=l[h],!r&&!b.call(t,n))throw Error('Unknown "'+n+'" option');(a=e[n])!==y&&(o=s[n],i[n]=o?o(a,u):a)}return i}function r(e,t){return"function"==typeof e&&e.hasOwnProperty("prototype")||t("value must be a constructor"),e}function i(i){var n="value must be type of "+i.join("|"),a=i.length,r=i[0],o=i[1];return 1===a?function(e,t){if(typeof e===r)return e;t(n)}:2===a?function(e,t){var s=typeof e;if(s===r||s===o)return e;t(n)}:function(e,t){for(var s=typeof e,r=a;0<r--;)if(s===i[r])return e;t(n)}}function l(a,o,l){var c,u,h,d=0,p=new a(function(t,s,e){function r(){u=u&&null,d&&(clearTimeout(d),d=0)}l=f(l,{timeout:0,overload:!1},{timeout:function(e,t){return("number"!=typeof(e*=1)||e<0||!Number.isFinite(e))&&t("timeout must be a positive number"),e}}),c=!l.overload&&"function"==typeof a.prototype.cancel&&"function"==typeof e;function i(e){r(),t(e)}function n(e){r(),s(e)}c?o(i,n,e):(u=[function(e){n(e||Error("canceled"))}],o(i,n,function(e){if(h)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof e)throw TypeError("onCancel callback must be a function");u.push(e)}),h=!0),0<l.timeout&&(d=setTimeout(function(){var e=Error("timeout");e.code="ETIMEDOUT",d=0,p.cancel(e),s(e)},l.timeout))});return c||(p.cancel=function(e){if(u){for(var t=u.length,s=1;s<t;s++)u[s](e);u[0](e),u=null}}),p}function g(e){var t=this._observers;if(!t)return-1;for(var s=t.length,r=0;r<s;r++)if(t[r]._target===e)return r;return-1}function _(e,t,s,r,i){if(!s)return null;if(0===r){var n=typeof t;if("string"==n){var a,o,l=0,c=0,u=this.delimiter,h=u.length;if(-1!==(o=t.indexOf(u))){for(a=new Array(5);a[l++]=t.slice(c,o),-1!==(o=t.indexOf(u,c=o+h)););a[l++]=t.slice(c),t=a,i=l}else t=[t],i=1}else i="object"==n?t.length:(t=[t],1)}var d,p,f,g,m,v,y=null,b=t[r],w=t[r+1];if(r===i)s._listeners&&(y=("function"==typeof s._listeners?e&&e.push(s._listeners):e&&e.push.apply(e,s._listeners),[s]));else{if("*"===b){for(o=(m=A(s)).length;0<o--;)"_listeners"!==(d=m[o])&&(v=_(e,t,s[d],r+1,i))&&(y?y.push.apply(y,v):y=v);return y}if("**"===b){for((g=r+1===i||r+2===i&&"*"===w)&&s._listeners&&(y=_(e,t,s,i,i)),o=(m=A(s)).length;0<o--;)"_listeners"!==(d=m[o])&&((v="*"===d||"**"===d?(s[d]._listeners&&!g&&(v=_(e,t,s[d],i,i))&&(y?y.push.apply(y,v):y=v),_(e,t,s[d],r,i)):_(e,t,s[d],d===w?r+2:r,i))&&(y?y.push.apply(y,v):y=v));return y}s[b]&&(y=_(e,t,s[b],r+1,i))}if((n=s["*"])&&_(e,t,n,r+1,i),p=s["**"])if(r<i)for(p._listeners&&_(e,t,p,i,i),o=(m=A(p)).length;0<o--;)"_listeners"!==(d=m[o])&&(d===w?_(e,t,p[d],r+2,i):d===b?_(e,t,p[d],r+1,i):((f={})[d]=p[d],_(e,t,{"**":f},r+1,i)));else p._listeners?_(e,t,p,i,i):p["*"]&&p["*"]._listeners&&_(e,t,p["*"],i,i);return y}function u(e,t,s,r){for(var i,n,a,o=A(e),l=o.length,c=e._listeners;0<l--;)i=e[a=o[l]],n="_listeners"===a?s:s?s.concat(a):[a],a=r||"symbol"==typeof a,c&&t.push(a?n:n.join(this.delimiter)),"object"==typeof i&&u.call(this,i,t,n,a);return t}function m(e){for(var t,s,r,i=A(e),n=i.length;0<n--;)(t=e[s=i[n]])&&(r=!0,"_listeners"===s||m(t)||delete e[s]);return r}function v(e,t,s){this.emitter=e,this.event=t,this.listener=s}function n(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,t.call(this,e)}var y,b,w,S,E,a,x,A,o,k,L;b=Object.hasOwnProperty,w=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},S="object"==typeof process&&"function"==typeof process.nextTick,E="function"==typeof Symbol,a="object"==typeof Reflect,x="function"==typeof setImmediate?setImmediate:setTimeout,A=E?a&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys:function(e){var t=Object.getOwnPropertyNames(e);return t.push.apply(t,Object.getOwnPropertySymbols(e)),t}:Object.keys,Object.assign(p.prototype,{subscribe:function(s,r,i){function t(){var e=c.apply(null,arguments),t={data:e,name:r,original:s};i?!1!==i.call(a,t)&&o.emit.apply(o,[t.name].concat(e)):o.emit.apply(o,[r].concat(e))}var n=this,a=this._target,o=this._emitter,l=this._listeners;if(l[s])throw Error("Event '"+s+"' is already listening");this._listenersCount++,o._newListener&&o._removeListener&&!n._onNewListener?(this._onNewListener=function(e){e===r&&null===l[s]&&(l[s]=t,n._on.call(a,s,t))},o.on("newListener",this._onNewListener),this._onRemoveListener=function(e){e===r&&!o.hasListeners(e)&&l[s]&&(l[s]=null,n._off.call(a,s,t))},l[s]=null,o.on("removeListener",this._onRemoveListener)):(l[s]=t,n._on.call(a,s,t))},unsubscribe:function(e){var t,s,r,i=this,n=this._listeners,a=this._emitter,o=this._off,l=this._target;if(e&&"string"!=typeof e)throw TypeError("event must be a string");function c(){i._onNewListener&&(a.off("newListener",i._onNewListener),a.off("removeListener",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var e=g.call(a,i);a._observers.splice(e,1)}if(e)(t=n[e])&&(o.call(l,e,t),delete n[e],--this._listenersCount||c());else{for(r=(s=A(n)).length;0<r--;)e=s[r],o.call(l,e,n[e]);this._listeners={},this._listenersCount=0,c()}}}),o=i(["function"]),k=i(["object","function"]),v.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},(n.EventEmitter2=n).prototype.listenTo=function(c,e,u){if("object"!=typeof c)throw TypeError("target musts be an object");var h=this;function t(e){if("object"!=typeof e)throw TypeError("events must be an object");for(var t,s=u.reducers,r=g.call(h,c),i=-1===r?new p(h,c,u):h._observers[r],n=A(e),a=n.length,o="function"==typeof s,l=0;l<a;l++)t=n[l],i.subscribe(t,e[t]||t,o?s:s&&s[t])}return u=f(u,{on:y,off:y,reducers:y},{on:o,off:o,reducers:k}),w(e)?t(s(e)):t("string"==typeof e?s(e.split(/\s+/)):e),this},n.prototype.stopListeningTo=function(e,t){var s=this._observers;if(!s)return!1;var r,i=s.length,n=!1;if(e&&"object"!=typeof e)throw TypeError("target should be an object");for(;0<i--;)r=s[i],e&&r._target!==e||(r.unsubscribe(t),n=!0);return n},n.prototype.delimiter=".",n.prototype.setMaxListeners=function(e){e!==y&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},n.prototype.getMaxListeners=function(){return this._maxListeners},n.prototype.event="",n.prototype.once=function(e,t,s){return this._once(e,t,!1,s)},n.prototype.prependOnceListener=function(e,t,s){return this._once(e,t,!0,s)},n.prototype._once=function(e,t,s,r){return this._many(e,1,t,s,r)},n.prototype.many=function(e,t,s,r){return this._many(e,t,s,!1,r)},n.prototype.prependMany=function(e,t,s,r){return this._many(e,t,s,!0,r)},n.prototype._many=function(e,t,s,r,i){var n=this;if("function"!=typeof s)throw new Error("many only accepts instances of Function");function a(){return 0==--t&&n.off(e,a),s.apply(this,arguments)}return a._origin=s,this._on(e,a,r,i)},n.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||h.call(this);var e,t,s,r,i,n,a=arguments[0],o=this.wildcard;if("newListener"===a&&!this._newListener&&!this._events.newListener)return!1;if(o&&("newListener"!==(e=a)&&"removeListener"!==a&&"object"==typeof a)){if(s=a.length,E)for(r=0;r<s;r++)if("symbol"==typeof a[r]){n=!0;break}n||(a=a.join(this.delimiter))}var l,c=arguments.length;if(this._all&&this._all.length)for(r=0,s=(l=this._all.slice()).length;r<s;r++)switch(this.event=a,c){case 1:l[r].call(this,a);break;case 2:l[r].call(this,a,arguments[1]);break;case 3:l[r].call(this,a,arguments[1],arguments[2]);break;default:l[r].apply(this,arguments)}if(o)_.call(this,l=[],e,this.listenerTree,0,s);else{if("function"==typeof(l=this._events[a])){switch(this.event=a,c){case 1:l.call(this);break;case 2:l.call(this,arguments[1]);break;case 3:l.call(this,arguments[1],arguments[2]);break;default:for(t=new Array(c-1),i=1;i<c;i++)t[i-1]=arguments[i];l.apply(this,t)}return!0}l=l&&l.slice()}if(l&&l.length){if(3<c)for(t=new Array(c-1),i=1;i<c;i++)t[i-1]=arguments[i];for(r=0,s=l.length;r<s;r++)switch(this.event=a,c){case 1:l[r].call(this);break;case 2:l[r].call(this,arguments[1]);break;case 3:l[r].call(this,arguments[1],arguments[2]);break;default:l[r].apply(this,t)}return!0}if(this.ignoreErrors||this._all||"error"!==a)return!!this._all;throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.")},n.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||h.call(this);var e,t,s,r,i,n,a=arguments[0],o=this.wildcard;if("newListener"===a&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(o&&("newListener"!==(e=a)&&"removeListener"!==a&&"object"==typeof a)){if(r=a.length,E)for(i=0;i<r;i++)if("symbol"==typeof a[i]){t=!0;break}t||(a=a.join(this.delimiter))}var l,c=[],u=arguments.length;if(this._all)for(i=0,r=this._all.length;i<r;i++)switch(this.event=a,u){case 1:c.push(this._all[i].call(this,a));break;case 2:c.push(this._all[i].call(this,a,arguments[1]));break;case 3:c.push(this._all[i].call(this,a,arguments[1],arguments[2]));break;default:c.push(this._all[i].apply(this,arguments))}if(o?_.call(this,l=[],e,this.listenerTree,0):l=this._events[a],"function"==typeof l)switch(this.event=a,u){case 1:c.push(l.call(this));break;case 2:c.push(l.call(this,arguments[1]));break;case 3:c.push(l.call(this,arguments[1],arguments[2]));break;default:for(s=new Array(u-1),n=1;n<u;n++)s[n-1]=arguments[n];c.push(l.apply(this,s))}else if(l&&l.length){if(l=l.slice(),3<u)for(s=new Array(u-1),n=1;n<u;n++)s[n-1]=arguments[n];for(i=0,r=l.length;i<r;i++)switch(this.event=a,u){case 1:c.push(l[i].call(this));break;case 2:c.push(l[i].call(this,arguments[1]));break;case 3:c.push(l[i].call(this,arguments[1],arguments[2]));break;default:c.push(l[i].apply(this,s))}}else if(!this.ignoreErrors&&!this._all&&"error"===a)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(c)},n.prototype.on=function(e,t,s){return this._on(e,t,!1,s)},n.prototype.prependListener=function(e,t,s){return this._on(e,t,!0,s)},n.prototype.onAny=function(e){return this._onAny(e,!1)},n.prototype.prependAny=function(e){return this._onAny(e,!0)},n.prototype.addListener=n.prototype.on,n.prototype._onAny=function(e,t){if("function"!=typeof e)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),t?this._all.unshift(e):this._all.push(e),this},n.prototype._on=function(e,t,s,r){if("function"==typeof e)return this._onAny(e,t),this;if("function"!=typeof t)throw new Error("on only accepts instances of Function");this._events||h.call(this);var i=this;return r!==y&&(t=(r=function(e,t,s){if(!0===s)i=!0;else if(!1===s)r=!0;else{if(!s||"object"!=typeof s)throw TypeError("options should be an object or true");var r=s.async,i=s.promisify,n=s.nextTick,a=s.objectify}if(r||n||i){var o=t,s=t._origin||t;if(n&&!S)throw Error("process.nextTick is not supported");i===y&&(i="AsyncFunction"===t.constructor.name),(t=function(){var e=arguments,t=this,s=this.event;return i?n?Promise.resolve():new Promise(function(e){x(e)}).then(function(){return t.event=s,o.apply(t,e)}):(n?process.nextTick:x)(function(){t.event=s,o.apply(t,e)})})._async=!0,t._origin=s}return[t,a?new v(this,e,t):this]}.call(this,e,t,r))[0],i=r[1]),this._newListener&&this.emit("newListener",e,t),this.wildcard?function(e,t,s){var r,i=0,n=0,a=this.delimiter,o=a.length;if("string"==typeof e)if(-1!==(u=e.indexOf(a))){for(r=new Array(5);r[i++]=e.slice(n,u),-1!==(u=e.indexOf(a,n=u+o)););r[i++]=e.slice(n)}else r=[e],i=1;else i=(r=e).length;if(1<i)for(u=0;u+1<i;u++)if("**"===r[u]&&"**"===r[u+1])return;for(var l,c=this.listenerTree,u=0;u<i;u++)if(c=c[l=r[u]]||(c[l]={}),u===i-1)return c._listeners?("function"==typeof c._listeners&&(c._listeners=[c._listeners]),s?c._listeners.unshift(t):c._listeners.push(t),!c._listeners.warned&&0<this._maxListeners&&c._listeners.length>this._maxListeners&&(c._listeners.warned=!0,d.call(this,c._listeners.length,l))):c._listeners=t,!0;return!0}.call(this,e,t,s):this._events[e]?("function"==typeof this._events[e]&&(this._events[e]=[this._events[e]]),s?this._events[e].unshift(t):this._events[e].push(t),!this._events[e].warned&&0<this._maxListeners&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,d.call(this,this._events[e].length,e))):this._events[e]=t,i},n.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var s=[];if(this.wildcard){var r="string"==typeof e?e.split(this.delimiter):e.slice();if(!(s=_.call(this,null,r,this.listenerTree,0)))return this}else{if(!this._events[e])return this;a=this._events[e],s.push({_listeners:a})}for(var i=0;i<s.length;i++){var n=s[i],a=n._listeners;if(w(a)){for(var o=-1,l=0,c=a.length;l<c;l++)if(a[l]===t||a[l].listener&&a[l].listener===t||a[l]._origin&&a[l]._origin===t){o=l;break}if(o<0)continue;return(this.wildcard?n._listeners:this._events[e]).splice(o,1),0===a.length&&(this.wildcard?delete n._listeners:delete this._events[e]),this._removeListener&&this.emit("removeListener",e,t),this}(a===t||a.listener&&a.listener===t||a._origin&&a._origin===t)&&(this.wildcard?delete n._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return this.listenerTree&&m(this.listenerTree),this},n.prototype.offAny=function(e){var t,s=0,r=0;if(e&&this._all&&0<this._all.length){for(s=0,r=(t=this._all).length;s<r;s++)if(e===t[s])return t.splice(s,1),this._removeListener&&this.emit("removeListenerAny",e),this}else{if(t=this._all,this._removeListener)for(s=0,r=t.length;s<r;s++)this.emit("removeListenerAny",t[s]);this._all=[]}return this},n.prototype.removeListener=n.prototype.off,n.prototype.removeAllListeners=function(e){if(e===y)return this._events&&h.call(this),this;if(this.wildcard){var t,s=_.call(this,null,e,this.listenerTree,0);if(!s)return this;for(t=0;t<s.length;t++)s[t]._listeners=null;this.listenerTree&&m(this.listenerTree)}else this._events&&(this._events[e]=null);return this},n.prototype.listeners=function(e){var t,s,r,i,n,a=this._events;if(e===y){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!a)return[];for(i=(t=A(a)).length,r=[];0<i--;)"function"==typeof(s=a[t[i]])?r.push(s):r.push.apply(r,s);return r}if(this.wildcard){if(!(n=this.listenerTree))return[];var o=[],l="string"==typeof e?e.split(this.delimiter):e.slice();return _.call(this,o,l,n,0),o}return a&&(s=a[e])?"function"==typeof s?[s]:s:[]},n.prototype.eventNames=function(e){var t=this._events;return this.wildcard?u.call(this,this.listenerTree,[],null,e):t?A(t):[]},n.prototype.listenerCount=function(e){return this.listeners(e).length},n.prototype.hasListeners=function(e){if(this.wildcard)return s=[],t="string"==typeof e?e.split(this.delimiter):e.slice(),_.call(this,s,t,this.listenerTree,0),0<s.length;var t=this._events,s=this._all;return!!(s&&s.length||t&&(e===y?A(t).length:t[e]))},n.prototype.listenersAny=function(){return this._all||[]},n.prototype.waitFor=function(i,n){var a=this,e=typeof n;return"number"==e?n={timeout:n}:"function"==e&&(n={filter:n}),l((n=f(n,{timeout:0,filter:y,handleError:!1,Promise:Promise,overload:!1},{filter:o,Promise:r})).Promise,function(t,s,e){function r(){var e=n.filter;e&&!e.apply(a,arguments)||(a.off(i,r),n.handleError?(e=arguments[0])?s(e):t(c.apply(null,arguments).slice(1)):t(c.apply(null,arguments)))}e(function(){a.off(i,r)}),a._on(i,r,!1)},{timeout:n.timeout,overload:n.overload})},L=n.prototype,Object.defineProperties(n,{defaultMaxListeners:{get:function(){return L._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");L._maxListeners=e},enumerable:!0},once:{value:function(a,o,e){return l((e=f(e,{Promise:Promise,timeout:0,overload:!1},{Promise:r})).Promise,function(e,t,s){var r;if("function"==typeof a.addEventListener)return r=function(){e(c.apply(null,arguments))},s(function(){a.removeEventListener(o,r)}),a.addEventListener(o,r,{once:!0});function i(){n&&a.removeListener("error",n),e(c.apply(null,arguments))}var n;"error"!==o&&(n=function(e){a.removeListener(o,i),t(e)},a.once("error",n)),s(function(){n&&a.removeListener("error",n),a.removeListener(o,i)}),a.once(o,i)},{timeout:e.timeout,overload:e.overload})},writable:!0,configurable:!0}}),Object.defineProperties(L,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),e.exports=n}(eventemitter2$1),eventemitter2$1.exports);class sallaEmitter extends eventemitter2{constructor(){super({wildcard:!0,delimiter:"::",newListener:!1,removeListener:!1,maxListeners:10,verboseMemoryLeak:!1,ignoreErrors:!1}),this.globalListners={},this.delimiter="::",this.cart=new CartEvents(this),this.gift=new GiftEvents(this),this.loyalty=new LoyaltyEvents(this),this.auth=new AuthEvents(this),this.search=new SearchEvents(this),this.wishlist=new WishlistEvents(this),this.comment=new CommentEvents(this),this.order=new OrderEvents(this),this.infiniteScroll=new InfiniteScrollEvents(this),this.document=new DocumentEvents(this),this.product=new ProductEvents(this),this.offer=new OfferEvents(this),this.coupon=new CouponEvents(this),this.feedback=new FeedbackEvents(this),this.currency=new CurrencyEvents(this),this.twilight=new TwilightEvents(this),this.scope=new ScopeEvents(this),this.body=document.querySelector("body"),this.logableEvents=["cart::item.added.failed","cart::item.deleted.failed"],this.ingoreLogEvents=["document::click","document::keyup","document::change"],this.on("twilight::initiated",this.initiateSallaInAllClasses)}initiateSallaInAllClasses(){let s=this;Object.keys(salla).forEach(t=>{"object"==typeof(t=salla[t])&&(s.callSallaInitiate(t),Object.keys(t).forEach(e=>{s.callSallaInitiate(t[e])}))})}callSallaInitiate(e){e&&e.sallaInitiated&&!e.initiated&&(e.sallaInitiated(),e.initiated=!0)}createAndDispatch(e,...t){this.dispatch(e,...t)}dispatch(s,...r){let t=s.split("::")[0],i=salla.api.apis[t],n=!1;if(i&&Object.keys(i.hooksSelectores).forEach(e=>{i.hooksSelectores[e]===s&&(salla.log(`'salla.${t}.${e}(...)' triggered using event '${s}'`),i[e].call(i,...r),n=!0)}),!n){this.emit(s,...r),window.dataLayer=window.dataLayer||[],window.dataLayer.push(Object.assign({event:s},...r.values())),this.ingoreLogEvents.includes(s)||!salla.config.get("debug")&&!this.logableEvents.includes(s)||salla.notify.log(s,...r);let t=this;Object.keys(this.globalListners).forEach(function(e){t.globalListners[e](s,...r)}),this.dispatchMobileEvent(s,{...r.values()})}}dispatchEvents(e){if(e&&"object"==typeof e)for(var[t,s]of Object.entries(e))this.dispatch(t,s);else salla.log("No Events To Dispatch!",e)}addListener(e,t){this.on(e,t)}addEventListener(e,t){this.addListener(e,t)}listen(e,t){this.addListener(e,t)}registerGlobalListener(e,t){this.globalListners[e]=t}dispatchMobileEvent(e,t={}){if(!(window.dataLayer&&dataLayer[0]&&dataLayer[0].page&&dataLayer[0].page.mobileApp))return"";if(window.webkit)try{window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:e,details:t}))}catch(e){console.log(e),console.log("The native context does not exist yet")}else if(Android)try{Android.customEventWithData(e,JSON.stringify({details:t}))}catch(e){console.log(e),console.log("The native context does not exist yet")}}}class BaseApi{constructor(e){this.parent=e,this.endpoints={},this.webEndpoints=[],this.namespace="BaseApi",this.hooksSelectores={},this.endpointsMethods={},this.endpointsHeaders={};e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&1<e.length?e[1]:"").toLowerCase(),this.debounce={request:void 0,time:300,enabled:!0,exclude:[]}}after_init(){}normalRequest(e,t,s=null){let r=this,i=Array.isArray(e),n=i?this.getUrl(...e):this.getUrl(e);e=i?e[0]:e,s=s||this.endpointsMethods[e]||"post";var a,o=this.endpointsHeaders[e];"get"===s&&t instanceof FormData&&(a={},Array.from(t.entries()).forEach(function(e){a[e[0]]=e[1]}),t={params:a}),o&&"get"===s&&(t=t?Object.assign(t,o):o);let l={namespace:this.namespace,action:e,hook:this.hooksSelectores[e]||e,url:n,payload:t,method:s,headers:o};try{salla.event.document.request(l)}catch(e){return salla.event.document.requestFailed(l),new Promise(()=>{throw e})}this.webEndpoints.includes(e)||"http"===n.substring(0,4)||(n=salla.config.get("store.api")+n);let c=event?.currentTarget,u=!1;return(u="SALLA-BUTTON"===c?.tagName?!0:u)&&c?.load(),this.parent[s](n,t,{headers:o}).then(e=>(u&&c?.stop(),e.data&&e.request&&(e=e.data),r.handleAfterResponseActions(e),e)).catch(e=>{throw u&&c?.stop(),salla.event.document.requestFailed(l,e),r.handleErrorResponse(e),e})}request(e,t,s=null){return!this.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,s)):this.normalRequest(e,t,s)}getUrl(e){let t=this.endpoints[e]||e;var s=/{[^{}]+}/i;for(let e=1;e<arguments.length;e++)t=t.replace(s,arguments[e]);return t}withInjectData(e,t){return{element:e,data:e.getElementSallaData(t)}}handleAfterResponseActions(response){if(!response)return;let{data,googleTags=null}=response,withGoogleTags=data&&data.googleTags?data.googleTags:googleTags;if(dataLayer&&withGoogleTags&&dataLayer.push(withGoogleTags),this.renderSections(response),response.events||response.error&&response.error.events){let e=response.events||response.error.events;e=JSON.parse(e),Object.keys(e).forEach(function(t){salla.event.dispatch(t,e[t])})}if(this.showAlert(response),response.runJavascript)try{eval(response.runJavascript)}catch(e){salla.log(e)}response.token&&salla.event.auth.tokenFetched(response.token)}renderSections(s){s.sections&&Object.keys(s.sections).forEach(t=>{document.querySelectorAll(t.toSelector()).forEach(function(e){e.innerHTML=s.sections[t]})})}handleErrorResponse(e){if(e.response&&e.response.data)return e.response.data.error&&e.response.data.error.fields?this.handleInvalidFields(e):this.handleAfterResponseActions(e.response.data)}showAlert(e){if(e)return e.case&&e.msg?salla.notify.fire(e.msg,e.case,e):e.message&&e.hasOwnProperty("success")?salla.notify.fire(e.message,e.success?salla.notify.types.success:salla.notify.types.error,e):e.error&&e.error.message&&"FORBIDDEN"!==e.error.message?salla.error(e.error.message,e):void 0}handleInvalidFields(e){let s=e.response.data.error.fields,r=[];Object.keys(s).forEach(e=>{let t=s[e];Array.isArray(t)?t.forEach(e=>r.push(e)):r.push(t)});var t=(1<r.length?"* ":"")+r.join("\n* ");salla.error(t,e)}event(){return salla.event[this.className]}getPossibleValue(s,r,e=!1){if(s){if("object"!=typeof s)return s;let t;for(let e=0;e<r.length&&!(t=s[r[e]])&&!(s instanceof FormData&&(t=s.get(r[e])));e++);return"object"!=typeof(t=t||s)||e?t:void 0}}isFastRequestsAllowed(){return salla.config.get("fastRequests")}promise(s,r=!0){return new Promise((e,t)=>(r?e:t)(s))}errorPromise(e){return this.promise(e,!1)}successPromise(e){return this.promise(e,!1)}}class CartApi extends BaseApi{constructor(e){super(e),this.namespace="cart",this.endpoints={latest:"cart/latest",details:"cart/{cart}",summary:"cart/{cart}/summary",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}",status:"cart/{cart}/status"},this.endpointsMethods={latest:"get",details:"get",summary:"get",status:"get",updateItem:"post",deleteItem:"delete",deleteImage:"delete"},this.webEndpoints=["latest"],this.hooksSelectores={addItem:"cart::add.item",quickAdd:"cart::quick.add",deleteItem:"cart::delete.item",updateItem:"cart::update.item",submit:"cart::submit",deleteImage:"cart::delete.file",reset:"cart::reset"},this.after_init()}async getCurrentCartId(){return salla.storage.get("cart.id")||(await this.latest()).data.cart.id}latest(){return this.request("latest",{params:{source:""}}).then(e=>(salla.storage.set("cart",e.data.cart),salla.event.cart.latestFetched(e),e)).catch(e=>{throw salla.storage.set("cart",""),salla.event.cart.latestFailed(e),e})}async details(){var e=await this.getCurrentCartId();return this.request(["details",e]).then(function(e){return salla.cart.event.detailsFetched(e),e}).catch(function(e){throw salla.cart.event.detailsNotFetched(e),e})}async summary(){var e=await this.getCurrentCartId();return this.request(["summary",e]).then(function(e){return salla.cart.event.summaryFetched(e),e}).catch(function(e){throw salla.cart.event.summaryNotFetched(e),e})}async quickAdd(e){return this.addItem(e)}async addItem(e){let t=this.getCartRequestData(e);if(!t.id)return salla.cart.event.itemAddedFailed('There is no product "id"!'),!1;var e=this.getPossibleValue(t.formData,["quantity","donating_amount"])?"addItem":"quickAdd",s=await this.getCurrentCartId();return this.request([e,s,t.id],t.formData).then(function(e){return salla.cart.event.itemAdded(e,t.id),e}).catch(function(e){throw salla.cart.event.itemAddedFailed(e,t.id),e})}async deleteItem(e){let t=this.getCartRequestData(e);if(!t.id)return salla.cart.event.itemDeletedFailed('There is no "id"!'),!1;e=await this.getCurrentCartId();return this.request(["deleteItem",e,t.id]).then(function(e){return salla.cart.event.itemDeleted(e,t.id),e}).catch(function(e){throw salla.cart.event.itemDeletedFailed(e,t.id),e})}async updateItem(e){let t=this.getCartRequestData(e);if(!t.id)return salla.cart.event.itemUpdatedFailed('There is no "id"!'),!1;e=await this.getCurrentCartId();return"object"==typeof t.formData&&("Object"===t.formData.constructor?.name?t.formData._method="PUT":t.formData.append("_method","PUT")),this.request(["updateItem",e,t.id],t.formData).then(function(e){return salla.cart.event.itemUpdated(e,t.id),e}).catch(function(e){throw salla.cart.event.itemUpdatedFailed(e,t.id),e})}async deleteImage(t){if(!(t=this.getPossibleValue(t,["id","image_id","photo_id"])))return salla.cart.event.imageNotDeleted('There is no "id"!'),!1;var e=await this.getCurrentCartId();return this.request(["deleteImage",e,t]).then(function(e){return salla.cart.event.imageDeleted(e,t),e}).catch(function(e){throw salla.cart.event.imageNotDeleted(e,t),e})}async status(e){return this.request(["status",e||await this.getCurrentCartId()])}async submit({}){var e=await this.getCurrentCartId();this.status(e).then(e=>{if("checkout"===e.data.next_step.to)return window.location.href=e.data.next_step.url+(window.ApplePaySession?"?has_apple_pay=true":"");if("refresh"===e.data.next_step.to)return window.location.reload();if("login"===e.data.next_step.to)return salla.event.dispatch("login::show");throw"Can't find next_step );"}).catch(function(e){throw salla.cart.event.submitFailed(e),e})}getCartRequestData(e){let t=e?.data||("object"==typeof e?e:void 0);return{id:e=t?this.getPossibleValue(t,["prod_id","item_id","id"]):e,formData:t="object"==typeof t?t:void 0}}handleAfterResponseActions(e){var t;if(403===e.status)throw salla.storage.remove("cart"),t=salla.lang.get("pages.checkout.try_again"),salla.error(t),t;super.handleAfterResponseActions(e)}reset(){salla.storage.remove("cart"),salla.cart.event.successReset()}}class GiftApi extends BaseApi{constructor(e){super(e),this.namespace="gift",this.endpoints={buy:"{id}/buy-as-gift"},this.webEndpoints=["buy"],this.hooksSelectores={buy:"gift::buy"},this.after_init()}buy(e){let t=this.getGiftRequestData(e);return t.id?this.request(["buy",t.id],t.formData).then(function(e){return salla.gift.event.buyingSucceeded(e,t.id),e}).catch(function(e){throw salla.gift.event.buyingFailed(e,t.id),e}):(salla.gift.event.buyingFailed('There is no "id"!'),!1)}getGiftRequestData(e){let t=e.data||("object"==typeof e?e:void 0);return{id:e=t?this.getPossibleValue(t,["prod_id","item_id","id"]):e,formData:t="object"==typeof t?t:void 0}}}class LoyalityApi extends BaseApi{constructor(e){super(e),this.namespace="loyalty",this.endpoints={exchange:"cart/prize/exchange_loyalty_point"},this.webEndpoints=["exchange"],this.hooksSelectores={exchange:"loyalty::exchange"},this.after_init()}exchange(e){let t=e.data||{id:e};return t.id?(t.loyalty_prize_id=t.id,this.request("exchange",t).then(function(e){return salla.loyalty.event.exchangeSucceeded(e,t.id),e}).catch(function(e){throw salla.loyalty.event.exchangeFailed(e,t.id),e})):(salla.loyalty.event.exchangeFailed('There is no "id"!'),!1)}}class AuthApi extends BaseApi{constructor(e){super(e),this.namespace="auth",this.endpoints={login:"auth/{type}/send_verification",resend:"auth/resend_verification",verify:"auth/{type}/verify",register:"auth/register",logout:"logout",refresh:"auth/refresh"},this.webEndpoints=["login","resend","verify","register","logout","profile/verify-mobile","auth/mobile/verify","auth/email/verify","refresh"],this.endpointsMethods={logout:"get"},this.hooksSelectores={login:"auth::login",resend:"auth::resend",verify:"auth::verify",register:"auth::register",logout:"auth::logout"},this.after_init()}login(t,e){let s;return t.data&&(s=t.element,e=t.data,t=this.getPossibleValue(e,["type"])),e||"object"!=typeof t||(e=t),(t=this.getPossibleValue(t,["type"]))?this.request(["login",t],e).then(function(e){return salla.auth.event.codeSent.call(s,e,t),e}).catch(function(e){throw salla.auth.event.codeNotSent.call(s,e,t),e}):(e="Failed to know what's login type!",salla.auth.event.codeNotSent(e),this.errorPromise(e))}verify(t,e){return t.data&&(e=t.data,t=this.getPossibleValue(e,["type"])),t?(salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event),this.request(["verify",t],e).then(function(e){return salla.auth.event.verified(e,t),e}).catch(function(e){throw salla.auth.event.verificationFailed(e,t),e})):(e="Failed to know what's login type!",salla.auth.event.verificationFailed(e),this.errorPromise(e))}resend(t){return(t=t.data||t).phone?t.country_code?(t.resend_by=t.resend_by||"sms",this.request("resend",t).then(function(e){return salla.auth.event.codeReSent(e,t),e}).catch(function(e){throw salla.auth.event.codeNotReSent(e,t),e})):(salla.auth.event.codeNotReSent("Failed to know what's country_code!",t),!1):(salla.auth.event.codeNotReSent("Failed to know what's phone!",t),!1)}register(e){let t;return e.data&&(t=e.element,e=e.data),salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event),this.request("register",e).then(function(e){return salla.auth.event.registered.call(t,e),e}).catch(function(e){throw salla.auth.event.registrationFailed.call(t,e),e})}logout(){return this.request("logout").then(function(e){return salla.auth.event.loggedOut(e),salla.log("Reloading after 0.1 sec..."),setTimeout(()=>location.reload(),100),e}).catch(function(e){throw salla.auth.event.failedLogout(e),e})}refresh(){return this.request("refresh").catch(function(e){throw salla.auth.event.refreshFailed(e),e})}}class OrderApi extends BaseApi{constructor(e){super(e),this.namespace="order",this.endpoints={cancel:"orders/cancel/{id}",reOrder:"reorder/{id}"},this.endpointsMethods={reOrder:"get"},this.hooksSelectores={cancel:"order::cancel",reOrder:"order::re.order",show:"order::show"},this.after_init()}show(e,t=null){salla.event.dispatch("mobile::order.placed",{order_id:e||salla.config.get("page.id")}),location.href=t||location.href.replace("thankyou","order")}cancel(t){return this.request(["cancel",t],{params:{has_apple_pay:!!window.ApplePaySession}}).then(function(e){return salla.event.order.canceled(e,t),e}).catch(function(e){throw salla.event.order.notCanceled(e,t),e})}reOrder(t){return this.request(["reOrder",t]).then(function(e){return salla.storage.set("cart",{id:e.data.cart_id,user_id:salla.config.get("user.id")}),salla.event.order.reOrdered(e,t),window.location.href=e.data.url,e}).catch(function(e){throw salla.event.order.reOrderFailed(e,t),e})}}class OfferApi extends BaseApi{constructor(e){super(e),this.namespace="offer",this.endpoints={popup:"products/special-offer-popup/{product_id}",increase:"products/special-offer-popup/{product_id}/increase",details:"products/{product_id}/specialoffer"},this.webEndpoints=["popup","increase"],this.endpointsMethods={increase:"get"},this.endpointsHeaders={popup:{"s-ajax-view":!0}},this.hooksSelectores={popup:"offer::popup",increase:"offer::increase",details:"offer::details"},this.after_init()}details(e){let t=e.data|e;return(e=this.getPossibleValue(t,["product_id"]))?this.request(["details",e],t).then(function(e){return salla.offer.event.detailsFetched(e,t),e}).catch(function(e){throw salla.offer.event.fetchDetailsFailed(e,t),e}):(salla.offer.event.fetchDetailsFailed('There is no "prodId"!'),!1)}increase(e){let t;return e.data&&(t=e.data,e=this.getPossibleValue(t,["id","product_id"])),e?this.request(["increase",e],t).then(function(e){return salla.offer.event.increased(e,t),e}).catch(function(e){throw salla.offer.event.increaseFailed(e,t),e}):(salla.offer.event.increaseFailed('There is no "prodId"!'),!1)}}class SearchApi extends BaseApi{constructor(e){super(e),this.namespace="search",this.endpoints={search:"products/search"},this.endpointsMethods={search:"get"},this.hooksSelectores={search:"search::products"},this.after_init()}search(t){let e=t.data||{params:{query:t}};var s;return(t=e instanceof FormData?e.get("query"):e.query||e.params.query)?t===this.previousQuery?(s="Query Same As Previous!",salla.search.event.failed(s),this.errorPromise(s)):(this.previousQuery=t,this.request("search",e).then(function(e){return salla.search.event.finished(e,t),e}).catch(function(e){throw salla.search.event.failed(e,t),e})):(s='There is no "query"!',salla.search.event.failed(s),this.errorPromise(s))}}class CouponApi extends BaseApi{constructor(e){super(e),this.namespace="coupon",this.endpoints={add:"cart/{id}/coupon",remove:"cart/{id}/coupon"},this.endpointsMethods={remove:"put"},this.hooksSelectores={add:"coupon::add",remove:"coupon::remove"},this.after_init()}async add(e){if(e=e.data||e,!(e=this.getPossibleValue(e,["coupon"]))){let e=new Error('There is no "Coupon Code"!');return e.name="EmptyCoupon",salla.event.coupon.addedFailed(e),this.errorPromise(e)}let t=await salla.cart.api.getCurrentCartId();return this.request(["add",t],{coupon:e}).then(function(e){return salla.event.coupon.added(e,t),e}).catch(function(e){throw salla.event.coupon.addedFailed(e,t),e})}async remove(){let t=await salla.cart.api.getCurrentCartId();return this.request(["remove",t],{}).then(function(e){return salla.event.coupon.removed(e,t),e}).catch(function(e){throw salla.event.coupon.removedFailed(e,t),e})}}class ProductApi extends BaseApi{constructor(e){super(e),this.namespace="product",this.endpoints={getPrice:"product-price/{id}",availabilitySubscribe:"products/{id}/availability-notify",purchaseNow:"checkout/quick-purchase/{id}"},this.webEndpoints=["getPrice","purchaseNow"],this.hooksSelectores={getPrice:"product::get.price",availabilitySubscribe:"product::availability.subscribe",purchaseNow:"product::purchase.now"},this.after_init()}getPrice(t){var e=t.data||t;return t=this.getPossibleValue(e,["id","prod_id"]),this.request(["getPrice",t],"object"==typeof e?e:void 0).then(function(e){return salla.product.event.priceUpdated(e,t),e}).catch(function(e){throw salla.product.event.priceUpdateFailed(e,t),e})}availabilitySubscribe(t){var e=t.data||t;return t=this.getPossibleValue(e,["id","prod_id"]),this.request(["availabilitySubscribe",t],"object"==typeof e?e:void 0).then(function(e){return salla.product.event.availabilitySubscribed(e,t),e}).catch(function(e){throw salla.product.event.availabilitySubscribedFailed(e,t),e})}purchaseNow(e){if(salla.auth.isGuest())return salla.auth.event.dispatch("login");let t=e.product_data,s=this.getPossibleValue(t,["id","prod_id"]);if(!e.is_applepay)return this.request(["quickPurchase",s],"object"==typeof t?t:void 0).then(function(e){return e}).catch(function(e){throw e});salla.event.dispatch("payments::apple-pay.start-transaction",{amount:e.total,currency:e.currency,requiredShippingContactFields:e.require_shipping?["postalAddress"]:null,shippingMethods:e.require_shipping?[]:null,supportedNetworks:e.applepay_supported_networks,validateMerchant:{url:baseUrl+"checkout/applepay/validate",onFailed:({})=>{console.log("validateMerchant Failed!")},onSuccess:e=>(console.log("validateMerchant Success"),this.request(["quickPurchase",s],"object"==typeof t?t:void 0))},authorized:{url:baseUrl+"/checkout/{id}/payments/submit",onFailed:e=>{console.log("authorized Failed!"),window.Salla.Payments.ApplePay.onCancel({},e.data.error.message)},onSuccess:e=>{console.log(e),window.location.href=e.redirect.url,console.log("authorized Success:: redirect to thank you page, order placed")}},shippingMethodSelected:e.require_shipping?{url:baseUrl+"/checkout/{id}/shipping/details",onFailed:e=>{console.log("select shipping method failed!")},onSuccess:e=>{console.log("select shipping method success")}}:null,shippingContactSelected:e.require_shipping?{url:baseUrl+"/checkout/{id}/address/add",onFailed:e=>{console.log("created contact failed!")},onSuccess:e=>{console.log("created contact success : ",e.data.address_id)}}:null,recalculateTotal:{url:baseUrl+"/checkout/{id}/payments/recalculate"},onError:function(e){console.log(e),salla.notify.error(e)}})}}class CommentApi extends BaseApi{constructor(e){super(e),this.namespace="comment",this.endpoints={send:"{type}/{id}/comments"},this.hooksSelectores={send:"comment::send"},this.after_init()}send(e){let t;e?.data&&(t=e.element,e=e.data);let s,{id:r,type:i,comment:n}=Object.fromEntries(e);return r?i&&["products","pages","product","page"].includes(i)?n?(i+=["product","page"].includes(i)?"s":"",this.request(["send",i,r],{comment:n}).then(function(e){return salla.event.comment.added.call(t,e,r),e}).catch(function(e){throw salla.event.comment.additionFailed.call(t,e,r),e})):(salla.event.comment.additionFailed(s="can't find comment content!"),this.errorPromise(s)):(salla.event.comment.additionFailed(s="Failed to get type one of:(products, product, page, pages)!"),this.errorPromise(s)):(salla.event.comment.additionFailed(s="Failed to get id!"),this.errorPromise(s))}}class CurrencyApi extends BaseApi{constructor(e){super(e),this.namespace="currency",this.endpoints={change:"/",list:"currencies"},this.endpointsMethods={change:"get",list:"get"},this.webEndpoints=["change"],this.hooksSelectores={change:"currency::change"},this.after_init()}change(t){var e;return(t=this.getPossibleValue(t.data||t,["currency","code"]))?this.request("change",{params:{change_currency:"",currency:t}}).then(function(e){return salla.currency.event.changed(e,t),e}).catch(function(e){throw salla.currency.event.failed(e,t),e}):(e="Can't find currency code!",salla.currency.event.failed(e),this.errorPromise(e))}list(){return this.request("list").then(function(e){return salla.currency.event.fetched(e),e}).catch(function(e){throw salla.currency.event.failedToFetch(e),e})}}class DocumentApi extends BaseApi{constructor(e){super(e),this.namespace="document"}}class FeedbackApi extends BaseApi{constructor(e){super(e),this.namespace="feedback",this.endpoints={store:"rating/store",product:"rating/products",shipping:"rating/shipping",order:"rating/{order_id}"},this.hooksSelectores={store:"feedback::store",product:"feedback::product",shipping:"feedback::shipping",order:"feedback::order"},this.endpointsMethods={order:"get"},this.after_init()}order(t){var e="object"==typeof t?t:{};return(t=this.getPossibleValue(t,["order_id","id"]))?this.request(["order",t],e).then(function(e){return salla.event.feedback.orderFetched(e,t),e}).catch(function(e){throw salla.event.feedback.orderNotFetched(e,t),e}):(e='There is no "order_id"!',salla.event.feedback.orderNotFetched(e),this.errorPromise(e))}store(t){var e;return(t=t.data||t)?this.request("store",t).then(function(e){return salla.event.feedback.storeRated(e,t),e}).catch(function(e){throw salla.event.feedback.storeFailed(e,t),e}):(e='There is no "data"!',salla.event.feedback.storeFailed(e),this.errorPromise(e))}products(){return this.product(...arguments)}product(t){var e;return(t=t.data||t)?this.request("product",t).then(function(e){return salla.event.feedback.productRated(e,t),e}).catch(function(e){throw salla.event.feedback.productFailed(e,t),e}):(e='There is no "data"!',salla.event.feedback.productFailed(e),this.errorPromise(e))}shipping(t){var e;return(t=t.data||t)?this.request("shipping",t).then(function(e){return salla.event.feedback.shippingRated(e,t),e}).catch(function(e){throw salla.event.feedback.shippingFailed(e,t),e}):(e='There is no "data"!',salla.event.feedback.shippingFailed(e),this.errorPromise(e))}}class SallaInit{constructor(e){salla.config.merge(e),this.connectHooksWithElements(),this.initiated=!0,e&&(e._token&&(salla.api.defaults.headers.common["X-CSRF-TOKEN"]=e._token),this.injectMaintenanceAlert(),this.injectThemePreviewAlert(),this.injectEditAlert(),salla.lang.loadStoreTranslations()),salla.twilight.event.initiated(e)}injectMaintenanceAlert(){var e;salla.config.get("maintenance")&&(document.querySelector(".store-notify")?salla.log("store-notify Existed before!"):((e=document.createElement("div")).classList.add("store-notify"),e.style="background-color: #d63031; color: #fff; padding: 10px 15px; text-align: center; font-size: 17px;",e.innerHTML=`<p style="margin:0 !important;">${salla.lang.get("blocks.header.maintenance_alert")}</p>`,document.body.prepend(e)))}injectThemePreviewAlert(){"preview"===salla.config.get("theme.mode")&&(document.querySelector("#s-theme_preview_bar")?salla.log("s-theme_preview_bar Existed before!"):salla.lang.onLoaded(()=>{let e=document.createElement("div");e.id="s-theme_preview_bar",e.style={display:"flex",justifyContent:"space-between",textAlign:"center",backgroundColor:"#232323",color:"#fff",padding:"10px",fontSize:"0.875rem",lineHeight:"1.25rem",position:"relative"},e.innerHTML=`
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).salla={})}(this,function(exports){"use strict";let notifier=function(e,t,s){return alert(e,t,s)},setNotifier=function(e){notifier=e},fire=function(e,t,s){return notifier(e,t,s)},error$1=function(e,t){return notifier(e,types.error,t)},info=function(e,t){return notifier(e,types.info,t)},success=function(e,t){return notifier(e,types.success,t)},logger=function(...e){return salla.config.get("trace_console")&&console.log(console.trace()),console.log(...["%cTwilight","color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;"].concat(...e))},setLogger=function(e){logger=e},log=function(...e){return logger(...e)};var sallaInitiated=function(){var e=window.location.href.match(/([\?\&]danger=)[^&]+/g);e&&e.forEach(e=>{error$1(decodeURI(e.replace("?danger=","").replace("&danger=","")))})},types={error:"error",success:"success",info:"info"},Notify={fire:fire,setNotifier:setNotifier,log:log,setLogger:setLogger,error:error$1,success:success,info:info,sallaInitiated:sallaInitiated,types:types};class BaseEvent{constructor(e){this.parent=e,this.events={},this.namespace="";e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&1<e.length?e[1]:"").toLowerCase()}after_init(){this.createDynamicFunctions()}createDynamicFunctions(){Object.keys(this.events).forEach(e=>{this.createDynamicEventFuns(e),this.createDynamicListenerFuns(e)})}createDynamicEventFuns(s){if(!this[s]){let t=this;this[s]=function(...e){return t.dispatch(s,...e)}}}createDynamicListenerFuns(s){var e="on"+s.charAt(0).toUpperCase()+s.slice(1);if(!this[e]){let t=this;this[e]=function(e){return t.on(s,e)}}}getEventName(e){return e=this.events[e]||e,!this.namespace||e.includes("::")?e:this.namespace+this.parent.delimiter+e}dispatch(e,...t){return this.parent.dispatch(this.getEventName(e),...t)}on(e,t){this.parent.addListener(this.getEventName(e),t)}register(e,t){this.on(e,t)}registerEventTemporary(e,t,s){s=s||1,emitter.many(e,s,t)}}class CartEvents extends BaseEvent{constructor(e){super(e),this.namespace="cart",this.events={latestFetched:"latest.fetched",latestFailed:"latest.failed",updated:"updated",itemUpdated:"item.updated",itemUpdatedFailed:"item.updated.failed",itemAdded:"item.added",itemAddedFailed:"item.added.failed",itemDeleted:"item.deleted",itemDeletedFailed:"item.deleted.failed",submitted:"submitted",submitFailed:"submit.failed",imageDeleted:"image.deleted",imageNotDeleted:"image.not.deleted",summaryFetched:"summary.fetched",summaryNotFetched:"summary.not.fetched",detailsFetched:"details.fetched",detailsNotFetched:"details.not.fetched",successReset:"success.reset"},this.after_init()}updated(e){return salla.cookie.set("fresh_summary",1),e&&"object"==typeof e?(e.offer&&salla.offer.event.existed(e.offer),salla.storage.set("cart.summary",e={total:e.cart.total,items_total:e.cart.sub_total,total_discount:e.cart.discount,real_shipping_cost:e.cart.real_shipping_cost,count:e.cart.count,shipping_cost:e.cart.free_shipping_bar?.has_free_shipping?0:e.cart.real_shipping_cost}),this.dispatch("updated",e)):(salla.log("Cart summary not an object!",e),this.dispatch("updated"))}itemAdded(e,t){return this.updated(e.data),this.dispatch("itemAdded",e,t)}itemDeleted(e,t){return this.updated(e.data),this.dispatch("itemDeleted",e,t)}itemUpdated(e,t){return this.updated(e.data),this.dispatch("itemUpdated",e,t)}summaryFetched(e){this.updated(e)}fullSummaryFetched(e){this.updated(e)}clearCartSummary(){var e=salla.storage.get("cart_widget_summary");e&&(e.count||e.items||e.items_count)&&salla.cart.api.summary()}}class GiftEvents extends BaseEvent{constructor(e){super(e),this.namespace="gift",this.events={buyingSucceeded:"buying.succeeded",buyingFailed:"buying.failed"},this.after_init()}}class LoyaltyEvents extends BaseEvent{constructor(e){super(e),this.namespace="loyalty",this.events={exchangeSucceeded:"exchange.succeeded",exchangeFailed:"exchange.failed"},this.after_init()}}class AuthEvents extends BaseEvent{constructor(e){super(e),this.namespace="auth",this.events={login:"login",logout:"logout",codeSent:"code.sent",codeNotSent:"code.not-sent",codeReSent:"code.re-sent",codeNotReSent:"code.not.re-sent",verified:"verified",verificationFailed:"verification.failed",loggedIn:"logged.in",registered:"registered",registrationFailed:"registration.failed",loggedOut:"logged.out",failedLogout:"failed.logout",tokenFetched:"token.fetched",refreshFailed:"refresh.failed"},this.after_init()}login(e){return e?(e.type&&this.setTypeActionOnVerified(e.type),this.next_event=e.next_event||null):this.next_event=null,this.dispatch("login",...arguments)}verified(e){return dataLayer&&(dataLayer[0].customer=e.customer),this.dispatch("verified",...arguments)}setTypeActionOnVerified(e){this.type_action_on_verified=e}getTypeActionOnVerified(){return this.type_action_on_verified||"redirect"}}class SearchEvents extends BaseEvent{constructor(e){super(e),this.namespace="search",this.events={finished:"finished",failed:"failed"},this.after_init()}}class WishlistEvents extends BaseEvent{constructor(e){super(e),this.namespace="wishlist",this.events={added:"added",removed:"removed",additionFailed:"addition.failed",removingFailed:"removing.failed"},this.after_init()}}class CommentEvents extends BaseEvent{constructor(e){super(e),this.namespace="comment",this.events={added:"added",additionFailed:"addition.failed"},this.after_init()}}class OrderEvents extends BaseEvent{constructor(e){super(e),this.namespace="order",this.events={canceled:"canceled",notCanceled:"not.canceled",reOrdered:"re.ordered",reOrderFailed:"re.order.failed",sent:"sent",notSent:"not.sent"},this.after_init()}}class InfiniteScrollEvents extends BaseEvent{constructor(e){super(e),this.namespace="infiniteScroll",this.events={scrollThreshold:"scroll.threshold",request:"request",load:"load",append:"append",error:"error",last:"last",history:"history"},this.after_init()}}class DocumentEvents extends BaseEvent{constructor(e){super(e),this.namespace="document",this.events={click:"click",change:"change",submit:"submit",keyup:"keyup",leaving:"leaving",request:"request",requestFailed:"request.failed"},this.after_init()}onClick(e,t){this.fireCallableFuns("click",e,t)}onChange(e,t){this.fireCallableFuns("change",e,t)}onSubmit(e,t){this.fireCallableFuns("submit",e,t)}onKeyup(e,t){this.fireCallableFuns("keyup",e,t)}fireCallableFuns(e,t,s){this.on(e,e=>{"function"!=typeof t?"function"==typeof s&&e.target.matches(t)&&s(e):t(e)})}fireEvent(e,t,...s){return this.fireEventForElements(e,t,!1,...s)}fireEventForAll(e,t,...s){return this.fireEventForElements(e,t,!0,...s)}fireEventForElements(e,t,s,...r){if("string"==typeof e){if(s)return document.querySelectorAll(e).forEach(e=>this.fireEventForElements(e,t,!1,...r));e=document.querySelector(e)}{if(e)return s=new CustomEvent(t,...r),e.dispatchEvent(s);salla.log("Failed To get element to fire event: "+t)}}}class ProductEvents extends BaseEvent{constructor(e){super(e),this.namespace="product",this.events={priceUpdated:"price.updated",priceUpdateFailed:"price.updated.failed",availabilitySubscribed:"availability.subscribed",availabilitySubscribeFailed:"availability.subscribe.failed"},this.after_init()}}class OfferEvents extends BaseEvent{constructor(e){super(e),this.namespace="offer",this.events={existed:"existed",increased:"increase",increaseFailed:"increase.failed",fetchDetailsFailed:"fetch.details.failed",detailsFetched:"details.fetched"},this.after_init()}}class CouponEvents extends BaseEvent{constructor(e){super(e),this.namespace="coupon",this.events={added:"added",removed:"removed",addedFailed:"added.failed",removedFailed:"removed.failed"},this.after_init()}added(e,t){return salla.event.cart.updated(e.data),this.dispatch("added",e,t)}removed(e,t){return salla.event.cart.updated(e.data),this.dispatch("removed",e,t)}}class FeedbackEvents extends BaseEvent{constructor(e){super(e),this.namespace="feedback",this.events={orderNotFetched:"order.not.fetched",orderFetched:"order.fetched",storeRated:"store.rated",storeFailed:"store.failed",productRated:"product.rated",productFailed:"product.failed",shippingRated:"shipping.rated",shippingFailed:"shipping.failed"},this.after_init()}}class CurrencyEvents extends BaseEvent{constructor(e){super(e),this.namespace="currency",this.events={changed:"changed",failed:"failed",fetched:"fetched",failedToFetch:"failed.to.fetch"},this.after_init()}changed(...e){return salla.cart.api.summary().then(()=>this.dispatch("changed",...e))}}class TwilightEvents extends BaseEvent{constructor(e){super(e),this.namespace="twilight",this.events={initiated:"initiated"},this.after_init()}}class ScopeEvents extends BaseEvent{constructor(e){super(e),this.namespace="scope",this.events={},this.after_init()}}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},eventemitter2$1={exports:{}},eventemitter2=(!function(e){function h(){this._events={},this._conf&&t.call(this,this._conf)}function t(e){e&&((this._conf=e).delimiter&&(this.delimiter=e.delimiter),e.maxListeners!==y&&(this._maxListeners=e.maxListeners),e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),e.ignoreErrors&&(this.ignoreErrors=e.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function d(e,t){var s="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";this.verboseMemoryLeak&&(s+=" Event name: "+t+"."),"undefined"!=typeof process&&process.emitWarning?((t=new Error(s)).name="MaxListenersExceededWarning",t.emitter=this,t.count=e,process.emitWarning(t)):(console.error(s),console.trace&&console.trace())}function c(e,t,s){var r=arguments.length;switch(r){case 0:return[];case 1:return[e];case 2:return[e,t];case 3:return[e,t,s];default:for(var i=new Array(r);r--;)i[r]=arguments[r];return i}}function s(e,t){for(var s={},r=e.length,i=t?value.length:0,n=0;n<r;n++)s[e[n]]=n<i?t[n]:y;return s}function p(e,t,s){var r,i;if(this._emitter=e,this._target=t,this._listeners={},this._listenersCount=0,(s.on||s.off)&&(r=s.on,i=s.off),t.addEventListener?(r=t.addEventListener,i=t.removeEventListener):t.addListener?(r=t.addListener,i=t.removeListener):t.on&&(r=t.on,i=t.off),!r&&!i)throw Error("target does not implement any known event API");if("function"!=typeof r)throw TypeError("on method must be a function");if("function"!=typeof i)throw TypeError("off method must be a function");this._on=r,this._off=i;s=e._observers;s?s.push(this):e._observers=[this]}function f(e,t,s,r){var i=Object.assign({},t);if(!e)return i;if("object"!=typeof e)throw TypeError("options must be an object");var n,a,o,l=Object.keys(e),c=l.length;function u(e){throw Error('Invalid "'+n+'" option value'+(e?". Reason: "+e:""))}for(var h=0;h<c;h++){if(n=l[h],!r&&!b.call(t,n))throw Error('Unknown "'+n+'" option');(a=e[n])!==y&&(o=s[n],i[n]=o?o(a,u):a)}return i}function r(e,t){return"function"==typeof e&&e.hasOwnProperty("prototype")||t("value must be a constructor"),e}function i(i){var n="value must be type of "+i.join("|"),a=i.length,r=i[0],o=i[1];return 1===a?function(e,t){if(typeof e===r)return e;t(n)}:2===a?function(e,t){var s=typeof e;if(s===r||s===o)return e;t(n)}:function(e,t){for(var s=typeof e,r=a;0<r--;)if(s===i[r])return e;t(n)}}function l(a,o,l){var c,u,h,d=0,p=new a(function(t,s,e){function r(){u=u&&null,d&&(clearTimeout(d),d=0)}l=f(l,{timeout:0,overload:!1},{timeout:function(e,t){return("number"!=typeof(e*=1)||e<0||!Number.isFinite(e))&&t("timeout must be a positive number"),e}}),c=!l.overload&&"function"==typeof a.prototype.cancel&&"function"==typeof e;function i(e){r(),t(e)}function n(e){r(),s(e)}c?o(i,n,e):(u=[function(e){n(e||Error("canceled"))}],o(i,n,function(e){if(h)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof e)throw TypeError("onCancel callback must be a function");u.push(e)}),h=!0),0<l.timeout&&(d=setTimeout(function(){var e=Error("timeout");e.code="ETIMEDOUT",d=0,p.cancel(e),s(e)},l.timeout))});return c||(p.cancel=function(e){if(u){for(var t=u.length,s=1;s<t;s++)u[s](e);u[0](e),u=null}}),p}function g(e){var t=this._observers;if(!t)return-1;for(var s=t.length,r=0;r<s;r++)if(t[r]._target===e)return r;return-1}function _(e,t,s,r,i){if(!s)return null;if(0===r){var n=typeof t;if("string"==n){var a,o,l=0,c=0,u=this.delimiter,h=u.length;if(-1!==(o=t.indexOf(u))){for(a=new Array(5);a[l++]=t.slice(c,o),-1!==(o=t.indexOf(u,c=o+h)););a[l++]=t.slice(c),t=a,i=l}else t=[t],i=1}else i="object"==n?t.length:(t=[t],1)}var d,p,f,g,m,v,y=null,b=t[r],w=t[r+1];if(r===i)s._listeners&&(y=("function"==typeof s._listeners?e&&e.push(s._listeners):e&&e.push.apply(e,s._listeners),[s]));else{if("*"===b){for(o=(m=A(s)).length;0<o--;)"_listeners"!==(d=m[o])&&(v=_(e,t,s[d],r+1,i))&&(y?y.push.apply(y,v):y=v);return y}if("**"===b){for((g=r+1===i||r+2===i&&"*"===w)&&s._listeners&&(y=_(e,t,s,i,i)),o=(m=A(s)).length;0<o--;)"_listeners"!==(d=m[o])&&((v="*"===d||"**"===d?(s[d]._listeners&&!g&&(v=_(e,t,s[d],i,i))&&(y?y.push.apply(y,v):y=v),_(e,t,s[d],r,i)):_(e,t,s[d],d===w?r+2:r,i))&&(y?y.push.apply(y,v):y=v));return y}s[b]&&(y=_(e,t,s[b],r+1,i))}if((n=s["*"])&&_(e,t,n,r+1,i),p=s["**"])if(r<i)for(p._listeners&&_(e,t,p,i,i),o=(m=A(p)).length;0<o--;)"_listeners"!==(d=m[o])&&(d===w?_(e,t,p[d],r+2,i):d===b?_(e,t,p[d],r+1,i):((f={})[d]=p[d],_(e,t,{"**":f},r+1,i)));else p._listeners?_(e,t,p,i,i):p["*"]&&p["*"]._listeners&&_(e,t,p["*"],i,i);return y}function u(e,t,s,r){for(var i,n,a,o=A(e),l=o.length,c=e._listeners;0<l--;)i=e[a=o[l]],n="_listeners"===a?s:s?s.concat(a):[a],a=r||"symbol"==typeof a,c&&t.push(a?n:n.join(this.delimiter)),"object"==typeof i&&u.call(this,i,t,n,a);return t}function m(e){for(var t,s,r,i=A(e),n=i.length;0<n--;)(t=e[s=i[n]])&&(r=!0,"_listeners"===s||m(t)||delete e[s]);return r}function v(e,t,s){this.emitter=e,this.event=t,this.listener=s}function n(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,t.call(this,e)}var y,b,w,S,E,a,x,A,o,k,L;b=Object.hasOwnProperty,w=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},S="object"==typeof process&&"function"==typeof process.nextTick,E="function"==typeof Symbol,a="object"==typeof Reflect,x="function"==typeof setImmediate?setImmediate:setTimeout,A=E?a&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys:function(e){var t=Object.getOwnPropertyNames(e);return t.push.apply(t,Object.getOwnPropertySymbols(e)),t}:Object.keys,Object.assign(p.prototype,{subscribe:function(s,r,i){function t(){var e=c.apply(null,arguments),t={data:e,name:r,original:s};i?!1!==i.call(a,t)&&o.emit.apply(o,[t.name].concat(e)):o.emit.apply(o,[r].concat(e))}var n=this,a=this._target,o=this._emitter,l=this._listeners;if(l[s])throw Error("Event '"+s+"' is already listening");this._listenersCount++,o._newListener&&o._removeListener&&!n._onNewListener?(this._onNewListener=function(e){e===r&&null===l[s]&&(l[s]=t,n._on.call(a,s,t))},o.on("newListener",this._onNewListener),this._onRemoveListener=function(e){e===r&&!o.hasListeners(e)&&l[s]&&(l[s]=null,n._off.call(a,s,t))},l[s]=null,o.on("removeListener",this._onRemoveListener)):(l[s]=t,n._on.call(a,s,t))},unsubscribe:function(e){var t,s,r,i=this,n=this._listeners,a=this._emitter,o=this._off,l=this._target;if(e&&"string"!=typeof e)throw TypeError("event must be a string");function c(){i._onNewListener&&(a.off("newListener",i._onNewListener),a.off("removeListener",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var e=g.call(a,i);a._observers.splice(e,1)}if(e)(t=n[e])&&(o.call(l,e,t),delete n[e],--this._listenersCount||c());else{for(r=(s=A(n)).length;0<r--;)e=s[r],o.call(l,e,n[e]);this._listeners={},this._listenersCount=0,c()}}}),o=i(["function"]),k=i(["object","function"]),v.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},(n.EventEmitter2=n).prototype.listenTo=function(c,e,u){if("object"!=typeof c)throw TypeError("target musts be an object");var h=this;function t(e){if("object"!=typeof e)throw TypeError("events must be an object");for(var t,s=u.reducers,r=g.call(h,c),i=-1===r?new p(h,c,u):h._observers[r],n=A(e),a=n.length,o="function"==typeof s,l=0;l<a;l++)t=n[l],i.subscribe(t,e[t]||t,o?s:s&&s[t])}return u=f(u,{on:y,off:y,reducers:y},{on:o,off:o,reducers:k}),w(e)?t(s(e)):t("string"==typeof e?s(e.split(/\s+/)):e),this},n.prototype.stopListeningTo=function(e,t){var s=this._observers;if(!s)return!1;var r,i=s.length,n=!1;if(e&&"object"!=typeof e)throw TypeError("target should be an object");for(;0<i--;)r=s[i],e&&r._target!==e||(r.unsubscribe(t),n=!0);return n},n.prototype.delimiter=".",n.prototype.setMaxListeners=function(e){e!==y&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},n.prototype.getMaxListeners=function(){return this._maxListeners},n.prototype.event="",n.prototype.once=function(e,t,s){return this._once(e,t,!1,s)},n.prototype.prependOnceListener=function(e,t,s){return this._once(e,t,!0,s)},n.prototype._once=function(e,t,s,r){return this._many(e,1,t,s,r)},n.prototype.many=function(e,t,s,r){return this._many(e,t,s,!1,r)},n.prototype.prependMany=function(e,t,s,r){return this._many(e,t,s,!0,r)},n.prototype._many=function(e,t,s,r,i){var n=this;if("function"!=typeof s)throw new Error("many only accepts instances of Function");function a(){return 0==--t&&n.off(e,a),s.apply(this,arguments)}return a._origin=s,this._on(e,a,r,i)},n.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||h.call(this);var e,t,s,r,i,n,a=arguments[0],o=this.wildcard;if("newListener"===a&&!this._newListener&&!this._events.newListener)return!1;if(o&&("newListener"!==(e=a)&&"removeListener"!==a&&"object"==typeof a)){if(s=a.length,E)for(r=0;r<s;r++)if("symbol"==typeof a[r]){n=!0;break}n||(a=a.join(this.delimiter))}var l,c=arguments.length;if(this._all&&this._all.length)for(r=0,s=(l=this._all.slice()).length;r<s;r++)switch(this.event=a,c){case 1:l[r].call(this,a);break;case 2:l[r].call(this,a,arguments[1]);break;case 3:l[r].call(this,a,arguments[1],arguments[2]);break;default:l[r].apply(this,arguments)}if(o)_.call(this,l=[],e,this.listenerTree,0,s);else{if("function"==typeof(l=this._events[a])){switch(this.event=a,c){case 1:l.call(this);break;case 2:l.call(this,arguments[1]);break;case 3:l.call(this,arguments[1],arguments[2]);break;default:for(t=new Array(c-1),i=1;i<c;i++)t[i-1]=arguments[i];l.apply(this,t)}return!0}l=l&&l.slice()}if(l&&l.length){if(3<c)for(t=new Array(c-1),i=1;i<c;i++)t[i-1]=arguments[i];for(r=0,s=l.length;r<s;r++)switch(this.event=a,c){case 1:l[r].call(this);break;case 2:l[r].call(this,arguments[1]);break;case 3:l[r].call(this,arguments[1],arguments[2]);break;default:l[r].apply(this,t)}return!0}if(this.ignoreErrors||this._all||"error"!==a)return!!this._all;throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.")},n.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||h.call(this);var e,t,s,r,i,n,a=arguments[0],o=this.wildcard;if("newListener"===a&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(o&&("newListener"!==(e=a)&&"removeListener"!==a&&"object"==typeof a)){if(r=a.length,E)for(i=0;i<r;i++)if("symbol"==typeof a[i]){t=!0;break}t||(a=a.join(this.delimiter))}var l,c=[],u=arguments.length;if(this._all)for(i=0,r=this._all.length;i<r;i++)switch(this.event=a,u){case 1:c.push(this._all[i].call(this,a));break;case 2:c.push(this._all[i].call(this,a,arguments[1]));break;case 3:c.push(this._all[i].call(this,a,arguments[1],arguments[2]));break;default:c.push(this._all[i].apply(this,arguments))}if(o?_.call(this,l=[],e,this.listenerTree,0):l=this._events[a],"function"==typeof l)switch(this.event=a,u){case 1:c.push(l.call(this));break;case 2:c.push(l.call(this,arguments[1]));break;case 3:c.push(l.call(this,arguments[1],arguments[2]));break;default:for(s=new Array(u-1),n=1;n<u;n++)s[n-1]=arguments[n];c.push(l.apply(this,s))}else if(l&&l.length){if(l=l.slice(),3<u)for(s=new Array(u-1),n=1;n<u;n++)s[n-1]=arguments[n];for(i=0,r=l.length;i<r;i++)switch(this.event=a,u){case 1:c.push(l[i].call(this));break;case 2:c.push(l[i].call(this,arguments[1]));break;case 3:c.push(l[i].call(this,arguments[1],arguments[2]));break;default:c.push(l[i].apply(this,s))}}else if(!this.ignoreErrors&&!this._all&&"error"===a)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(c)},n.prototype.on=function(e,t,s){return this._on(e,t,!1,s)},n.prototype.prependListener=function(e,t,s){return this._on(e,t,!0,s)},n.prototype.onAny=function(e){return this._onAny(e,!1)},n.prototype.prependAny=function(e){return this._onAny(e,!0)},n.prototype.addListener=n.prototype.on,n.prototype._onAny=function(e,t){if("function"!=typeof e)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),t?this._all.unshift(e):this._all.push(e),this},n.prototype._on=function(e,t,s,r){if("function"==typeof e)return this._onAny(e,t),this;if("function"!=typeof t)throw new Error("on only accepts instances of Function");this._events||h.call(this);var i=this;return r!==y&&(t=(r=function(e,t,s){if(!0===s)i=!0;else if(!1===s)r=!0;else{if(!s||"object"!=typeof s)throw TypeError("options should be an object or true");var r=s.async,i=s.promisify,n=s.nextTick,a=s.objectify}if(r||n||i){var o=t,s=t._origin||t;if(n&&!S)throw Error("process.nextTick is not supported");i===y&&(i="AsyncFunction"===t.constructor.name),(t=function(){var e=arguments,t=this,s=this.event;return i?n?Promise.resolve():new Promise(function(e){x(e)}).then(function(){return t.event=s,o.apply(t,e)}):(n?process.nextTick:x)(function(){t.event=s,o.apply(t,e)})})._async=!0,t._origin=s}return[t,a?new v(this,e,t):this]}.call(this,e,t,r))[0],i=r[1]),this._newListener&&this.emit("newListener",e,t),this.wildcard?function(e,t,s){var r,i=0,n=0,a=this.delimiter,o=a.length;if("string"==typeof e)if(-1!==(u=e.indexOf(a))){for(r=new Array(5);r[i++]=e.slice(n,u),-1!==(u=e.indexOf(a,n=u+o)););r[i++]=e.slice(n)}else r=[e],i=1;else i=(r=e).length;if(1<i)for(u=0;u+1<i;u++)if("**"===r[u]&&"**"===r[u+1])return;for(var l,c=this.listenerTree,u=0;u<i;u++)if(c=c[l=r[u]]||(c[l]={}),u===i-1)return c._listeners?("function"==typeof c._listeners&&(c._listeners=[c._listeners]),s?c._listeners.unshift(t):c._listeners.push(t),!c._listeners.warned&&0<this._maxListeners&&c._listeners.length>this._maxListeners&&(c._listeners.warned=!0,d.call(this,c._listeners.length,l))):c._listeners=t,!0;return!0}.call(this,e,t,s):this._events[e]?("function"==typeof this._events[e]&&(this._events[e]=[this._events[e]]),s?this._events[e].unshift(t):this._events[e].push(t),!this._events[e].warned&&0<this._maxListeners&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,d.call(this,this._events[e].length,e))):this._events[e]=t,i},n.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var s=[];if(this.wildcard){var r="string"==typeof e?e.split(this.delimiter):e.slice();if(!(s=_.call(this,null,r,this.listenerTree,0)))return this}else{if(!this._events[e])return this;a=this._events[e],s.push({_listeners:a})}for(var i=0;i<s.length;i++){var n=s[i],a=n._listeners;if(w(a)){for(var o=-1,l=0,c=a.length;l<c;l++)if(a[l]===t||a[l].listener&&a[l].listener===t||a[l]._origin&&a[l]._origin===t){o=l;break}if(o<0)continue;return(this.wildcard?n._listeners:this._events[e]).splice(o,1),0===a.length&&(this.wildcard?delete n._listeners:delete this._events[e]),this._removeListener&&this.emit("removeListener",e,t),this}(a===t||a.listener&&a.listener===t||a._origin&&a._origin===t)&&(this.wildcard?delete n._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return this.listenerTree&&m(this.listenerTree),this},n.prototype.offAny=function(e){var t,s=0,r=0;if(e&&this._all&&0<this._all.length){for(s=0,r=(t=this._all).length;s<r;s++)if(e===t[s])return t.splice(s,1),this._removeListener&&this.emit("removeListenerAny",e),this}else{if(t=this._all,this._removeListener)for(s=0,r=t.length;s<r;s++)this.emit("removeListenerAny",t[s]);this._all=[]}return this},n.prototype.removeListener=n.prototype.off,n.prototype.removeAllListeners=function(e){if(e===y)return this._events&&h.call(this),this;if(this.wildcard){var t,s=_.call(this,null,e,this.listenerTree,0);if(!s)return this;for(t=0;t<s.length;t++)s[t]._listeners=null;this.listenerTree&&m(this.listenerTree)}else this._events&&(this._events[e]=null);return this},n.prototype.listeners=function(e){var t,s,r,i,n,a=this._events;if(e===y){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!a)return[];for(i=(t=A(a)).length,r=[];0<i--;)"function"==typeof(s=a[t[i]])?r.push(s):r.push.apply(r,s);return r}if(this.wildcard){if(!(n=this.listenerTree))return[];var o=[],l="string"==typeof e?e.split(this.delimiter):e.slice();return _.call(this,o,l,n,0),o}return a&&(s=a[e])?"function"==typeof s?[s]:s:[]},n.prototype.eventNames=function(e){var t=this._events;return this.wildcard?u.call(this,this.listenerTree,[],null,e):t?A(t):[]},n.prototype.listenerCount=function(e){return this.listeners(e).length},n.prototype.hasListeners=function(e){if(this.wildcard)return s=[],t="string"==typeof e?e.split(this.delimiter):e.slice(),_.call(this,s,t,this.listenerTree,0),0<s.length;var t=this._events,s=this._all;return!!(s&&s.length||t&&(e===y?A(t).length:t[e]))},n.prototype.listenersAny=function(){return this._all||[]},n.prototype.waitFor=function(i,n){var a=this,e=typeof n;return"number"==e?n={timeout:n}:"function"==e&&(n={filter:n}),l((n=f(n,{timeout:0,filter:y,handleError:!1,Promise:Promise,overload:!1},{filter:o,Promise:r})).Promise,function(t,s,e){function r(){var e=n.filter;e&&!e.apply(a,arguments)||(a.off(i,r),n.handleError?(e=arguments[0])?s(e):t(c.apply(null,arguments).slice(1)):t(c.apply(null,arguments)))}e(function(){a.off(i,r)}),a._on(i,r,!1)},{timeout:n.timeout,overload:n.overload})},L=n.prototype,Object.defineProperties(n,{defaultMaxListeners:{get:function(){return L._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");L._maxListeners=e},enumerable:!0},once:{value:function(a,o,e){return l((e=f(e,{Promise:Promise,timeout:0,overload:!1},{Promise:r})).Promise,function(e,t,s){var r;if("function"==typeof a.addEventListener)return r=function(){e(c.apply(null,arguments))},s(function(){a.removeEventListener(o,r)}),a.addEventListener(o,r,{once:!0});function i(){n&&a.removeListener("error",n),e(c.apply(null,arguments))}var n;"error"!==o&&(n=function(e){a.removeListener(o,i),t(e)},a.once("error",n)),s(function(){n&&a.removeListener("error",n),a.removeListener(o,i)}),a.once(o,i)},{timeout:e.timeout,overload:e.overload})},writable:!0,configurable:!0}}),Object.defineProperties(L,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),e.exports=n}(eventemitter2$1),eventemitter2$1.exports);class sallaEmitter extends eventemitter2{constructor(){super({wildcard:!0,delimiter:"::",newListener:!1,removeListener:!1,maxListeners:10,verboseMemoryLeak:!1,ignoreErrors:!1}),this.globalListners={},this.delimiter="::",this.cart=new CartEvents(this),this.gift=new GiftEvents(this),this.loyalty=new LoyaltyEvents(this),this.auth=new AuthEvents(this),this.search=new SearchEvents(this),this.wishlist=new WishlistEvents(this),this.comment=new CommentEvents(this),this.order=new OrderEvents(this),this.infiniteScroll=new InfiniteScrollEvents(this),this.document=new DocumentEvents(this),this.product=new ProductEvents(this),this.offer=new OfferEvents(this),this.coupon=new CouponEvents(this),this.feedback=new FeedbackEvents(this),this.currency=new CurrencyEvents(this),this.twilight=new TwilightEvents(this),this.scope=new ScopeEvents(this),this.body=document.querySelector("body"),this.logableEvents=["cart::item.added.failed","cart::item.deleted.failed"],this.ingoreLogEvents=["document::click","document::keyup","document::change"],this.on("twilight::initiated",this.initiateSallaInAllClasses)}initiateSallaInAllClasses(){let s=this;Object.keys(salla).forEach(t=>{"object"==typeof(t=salla[t])&&(s.callSallaInitiate(t),Object.keys(t).forEach(e=>{s.callSallaInitiate(t[e])}))})}callSallaInitiate(e){e&&e.sallaInitiated&&!e.initiated&&(e.sallaInitiated(),e.initiated=!0)}createAndDispatch(e,...t){this.dispatch(e,...t)}dispatch(s,...r){let t=s.split("::")[0],i=salla.api.apis[t],n=!1;if(i&&Object.keys(i.hooksSelectores).forEach(e=>{i.hooksSelectores[e]===s&&(salla.log(`'salla.${t}.${e}(...)' triggered using event '${s}'`),i[e].call(i,...r),n=!0)}),!n){this.emit(s,...r),window.dataLayer=window.dataLayer||[],window.dataLayer.push(Object.assign({event:s},...r.values())),this.ingoreLogEvents.includes(s)||!salla.config.get("debug")&&!this.logableEvents.includes(s)||salla.notify.log(s,...r);let t=this;Object.keys(this.globalListners).forEach(function(e){t.globalListners[e](s,...r)}),this.dispatchMobileEvent(s,{...r.values()})}}dispatchEvents(e){if(e&&"object"==typeof e)for(var[t,s]of Object.entries(e))this.dispatch(t,s);else salla.log("No Events To Dispatch!",e)}addListener(e,t){this.on(e,t)}addEventListener(e,t){this.addListener(e,t)}listen(e,t){this.addListener(e,t)}registerGlobalListener(e,t){this.globalListners[e]=t}dispatchMobileEvent(e,t={}){if(!(window.dataLayer&&dataLayer[0]&&dataLayer[0].page&&dataLayer[0].page.mobileApp))return"";if(window.webkit)try{window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:e,details:t}))}catch(e){console.log(e),console.log("The native context does not exist yet")}else if(Android)try{Android.customEventWithData(e,JSON.stringify({details:t}))}catch(e){console.log(e),console.log("The native context does not exist yet")}}}class BaseApi{constructor(e){this.parent=e,this.endpoints={},this.webEndpoints=[],this.namespace="BaseApi",this.hooksSelectores={},this.endpointsMethods={},this.endpointsHeaders={};e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&1<e.length?e[1]:"").toLowerCase(),this.debounce={request:void 0,time:300,enabled:!0,exclude:[]}}after_init(){}normalRequest(e,t,s=null){let r=this,i=Array.isArray(e),n=i?this.getUrl(...e):this.getUrl(e);e=i?e[0]:e,s=s||this.endpointsMethods[e]||"post";var a,o=this.endpointsHeaders[e];"get"===s&&t instanceof FormData&&(a={},Array.from(t.entries()).forEach(function(e){a[e[0]]=e[1]}),t={params:a}),o&&"get"===s&&(t=t?Object.assign(t,o):o);let l={namespace:this.namespace,action:e,hook:this.hooksSelectores[e]||e,url:n,payload:t,method:s,headers:o};try{salla.event.document.request(l)}catch(e){return salla.event.document.requestFailed(l),new Promise(()=>{throw e})}this.webEndpoints.includes(e)||"http"===n.substring(0,4)||(n=salla.config.get("store.api")+n);let c=event?.currentTarget,u=!1;return(u="SALLA-BUTTON"===c?.tagName?!0:u)&&c?.load(),this.parent[s](n,t,{headers:o}).then(e=>(u&&c?.stop(),e.data&&e.request&&(e=e.data),r.handleAfterResponseActions(e),e)).catch(e=>{throw u&&c?.stop(),salla.event.document.requestFailed(l,e),r.handleErrorResponse(e),e})}request(e,t,s=null){return!this.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,s)):this.normalRequest(e,t,s)}getUrl(e){let t=this.endpoints[e]||e;var s=/{[^{}]+}/i;for(let e=1;e<arguments.length;e++)t=t.replace(s,arguments[e]);return t}withInjectData(e,t){return{element:e,data:e.getElementSallaData(t)}}handleAfterResponseActions(response){if(!response)return;let{data,googleTags=null}=response,withGoogleTags=data&&data.googleTags?data.googleTags:googleTags;if(dataLayer&&withGoogleTags&&dataLayer.push(withGoogleTags),this.renderSections(response),response.events||response.error&&response.error.events){let e=response.events||response.error.events;e=JSON.parse(e),Object.keys(e).forEach(function(t){salla.event.dispatch(t,e[t])})}if(this.showAlert(response),response.runJavascript)try{eval(response.runJavascript)}catch(e){salla.log(e)}response.token&&salla.event.auth.tokenFetched(response.token)}renderSections(s){s.sections&&Object.keys(s.sections).forEach(t=>{document.querySelectorAll(t.toSelector()).forEach(function(e){e.innerHTML=s.sections[t]})})}handleErrorResponse(e){if(e.response&&e.response.data)return e.response.data.error&&e.response.data.error.fields?this.handleInvalidFields(e):this.handleAfterResponseActions(e.response.data)}showAlert(e){if(e)return e.case&&e.msg?salla.notify.fire(e.msg,e.case,e):e.message&&e.hasOwnProperty("success")?salla.notify.fire(e.message,e.success?salla.notify.types.success:salla.notify.types.error,e):e.error&&e.error.message&&"FORBIDDEN"!==e.error.message?salla.error(e.error.message,e):void 0}handleInvalidFields(e){let s=e.response.data.error.fields,r=[];Object.keys(s).forEach(e=>{let t=s[e];Array.isArray(t)?t.forEach(e=>r.push(e)):r.push(t)});var t=(1<r.length?"* ":"")+r.join("\n* ");salla.error(t,e)}event(){return salla.event[this.className]}getPossibleValue(s,r,e=!1){if(s){if("object"!=typeof s)return s;let t;for(let e=0;e<r.length&&!(t=s[r[e]])&&!(s instanceof FormData&&(t=s.get(r[e])));e++);return"object"!=typeof(t=t||s)||e?t:void 0}}isFastRequestsAllowed(){return salla.config.get("fastRequests")}promise(s,r=!0){return new Promise((e,t)=>(r?e:t)(s))}errorPromise(e){return this.promise(e,!1)}successPromise(e){return this.promise(e,!1)}}class CartApi extends BaseApi{constructor(e){super(e),this.namespace="cart",this.endpoints={latest:"cart/latest",details:"cart/{cart}",summary:"cart/{cart}/summary",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}",status:"cart/{cart}/status"},this.endpointsMethods={latest:"get",details:"get",summary:"get",status:"get",updateItem:"post",deleteItem:"delete",deleteImage:"delete"},this.webEndpoints=["latest"],this.hooksSelectores={addItem:"cart::add.item",quickAdd:"cart::quick.add",deleteItem:"cart::delete.item",updateItem:"cart::update.item",submit:"cart::submit",deleteImage:"cart::delete.file",reset:"cart::reset"},this.after_init()}async getCurrentCartId(){return salla.storage.get("cart.id")||(await this.latest()).data.cart.id}latest(){return this.request("latest",{params:{source:""}}).then(e=>(salla.storage.set("cart",e.data.cart),salla.event.cart.latestFetched(e),e)).catch(e=>{throw salla.storage.set("cart",""),salla.event.cart.latestFailed(e),e})}async details(){var e=await this.getCurrentCartId();return this.request(["details",e]).then(function(e){return salla.cart.event.detailsFetched(e),e}).catch(function(e){throw salla.cart.event.detailsNotFetched(e),e})}async summary(){var e=await this.getCurrentCartId();return this.request(["summary",e]).then(function(e){return salla.cart.event.summaryFetched(e),e}).catch(function(e){throw salla.cart.event.summaryNotFetched(e),e})}async quickAdd(e){return this.addItem(e)}async addItem(e){let t=this.getCartRequestData(e);if(!t.id)return e='There is no product "id"!',salla.cart.event.itemAddedFailed(e),this.errorPromise(e);var e=this.getPossibleValue(t.formData,["quantity","donating_amount"])?"addItem":"quickAdd",s=await this.getCurrentCartId();return this.request([e,s,t.id],t.formData).then(function(e){return salla.cart.event.itemAdded(e,t.id),e}).catch(function(e){throw salla.cart.event.itemAddedFailed(e,t.id),e})}async deleteItem(e){let t=this.getCartRequestData(e);if(!t.id)return e='There is no "id"!',salla.cart.event.itemDeletedFailed(e),this.errorPromise(e);e=await this.getCurrentCartId();return this.request(["deleteItem",e,t.id]).then(function(e){return salla.cart.event.itemDeleted(e,t.id),e}).catch(function(e){throw salla.cart.event.itemDeletedFailed(e,t.id),e})}async updateItem(e){let t=this.getCartRequestData(e);if(!t.id)return e='There is no "id"!',salla.cart.event.itemUpdatedFailed(e),this.errorPromise(e);e=await this.getCurrentCartId();return"object"==typeof t.formData&&("Object"===t.formData.constructor?.name?t.formData._method="PUT":t.formData.append("_method","PUT")),this.request(["updateItem",e,t.id],t.formData).then(function(e){return salla.cart.event.itemUpdated(e,t.id),e}).catch(function(e){throw salla.cart.event.itemUpdatedFailed(e,t.id),e})}async deleteImage(t){if(!(t=this.getPossibleValue(t,["id","image_id","photo_id"])))return e='There is no "id"!',salla.cart.event.imageNotDeleted(e),this.errorPromise(e);var e=await this.getCurrentCartId();return this.request(["deleteImage",e,t]).then(function(e){return salla.cart.event.imageDeleted(e,t),e}).catch(function(e){throw salla.cart.event.imageNotDeleted(e,t),e})}async status(e){return this.request(["status",e||await this.getCurrentCartId()])}async submit(){this.status(await this.getCurrentCartId()).then(e=>{var t=e.data.next_step.to;if(["checkout","refresh","login"].includes(t))return salla.cart.event.submitted(e),"checkout"===t?window.location.href=e.data.next_step.url+(window.ApplePaySession?"?has_apple_pay=true":""):"refresh"===t?window.location.reload():"login"===t?salla.event.dispatch("login::show"):void 0;throw e="Can't find next_step );",salla.cart.event.submitFailed(e),e}).catch(function(e){throw salla.cart.event.submitFailed(e),e})}getCartRequestData(e){let t=e?.data||("object"==typeof e?e:void 0);return{id:e=t?this.getPossibleValue(t,["prod_id","item_id","id"]):e,formData:t="object"==typeof t?t:void 0}}handleAfterResponseActions(e){var t;if(403===e.status)throw salla.storage.remove("cart"),t=salla.lang.get("pages.checkout.try_again"),salla.error(t),t;super.handleAfterResponseActions(e)}reset(){salla.storage.remove("cart"),salla.cart.event.successReset()}}class GiftApi extends BaseApi{constructor(e){super(e),this.namespace="gift",this.endpoints={buy:"{id}/buy-as-gift"},this.webEndpoints=["buy"],this.hooksSelectores={buy:"gift::buy"},this.after_init()}buy(e){let t=this.getGiftRequestData(e);return t.id?this.request(["buy",t.id],t.formData).then(function(e){return salla.gift.event.buyingSucceeded(e,t.id),e}).catch(function(e){throw salla.gift.event.buyingFailed(e,t.id),e}):(salla.gift.event.buyingFailed('There is no "id"!'),!1)}getGiftRequestData(e){let t=e.data||("object"==typeof e?e:void 0);return{id:e=t?this.getPossibleValue(t,["prod_id","item_id","id"]):e,formData:t="object"==typeof t?t:void 0}}}class LoyalityApi extends BaseApi{constructor(e){super(e),this.namespace="loyalty",this.endpoints={exchange:"cart/prize/exchange_loyalty_point"},this.webEndpoints=["exchange"],this.hooksSelectores={exchange:"loyalty::exchange"},this.after_init()}exchange(e){let t=e.data||{id:e};return t.id?(t.loyalty_prize_id=t.id,this.request("exchange",t).then(function(e){return salla.loyalty.event.exchangeSucceeded(e,t.id),e}).catch(function(e){throw salla.loyalty.event.exchangeFailed(e,t.id),e})):(salla.loyalty.event.exchangeFailed('There is no "id"!'),!1)}}class AuthApi extends BaseApi{constructor(e){super(e),this.namespace="auth",this.endpoints={login:"auth/{type}/send_verification",resend:"auth/resend_verification",verify:"auth/{type}/verify",register:"auth/register",logout:"logout",refresh:"auth/refresh"},this.webEndpoints=["login","resend","verify","register","logout","profile/verify-mobile","auth/mobile/verify","auth/email/verify","refresh"],this.endpointsMethods={logout:"get"},this.hooksSelectores={login:"auth::login",resend:"auth::resend",verify:"auth::verify",register:"auth::register",logout:"auth::logout"},this.after_init()}login(t,e){let s;return t.data&&(s=t.element,e=t.data,t=this.getPossibleValue(e,["type"])),e||"object"!=typeof t||(e=t),(t=this.getPossibleValue(t,["type"]))?this.request(["login",t],e).then(function(e){return salla.auth.event.codeSent.call(s,e,t),e}).catch(function(e){throw salla.auth.event.codeNotSent.call(s,e,t),e}):(e="Failed to know what's login type!",salla.auth.event.codeNotSent(e),this.errorPromise(e))}verify(t,e){return t.data&&(e=t.data,t=this.getPossibleValue(e,["type"])),t?(salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event),this.request(["verify",t],e).then(function(e){return salla.auth.event.verified(e,t),e}).catch(function(e){throw salla.auth.event.verificationFailed(e,t),e})):(e="Failed to know what's login type!",salla.auth.event.verificationFailed(e),this.errorPromise(e))}resend(t){return(t=t.data||t).phone?t.country_code?(t.resend_by=t.resend_by||"sms",this.request("resend",t).then(function(e){return salla.auth.event.codeReSent(e,t),e}).catch(function(e){throw salla.auth.event.codeNotReSent(e,t),e})):(salla.auth.event.codeNotReSent("Failed to know what's country_code!",t),!1):(salla.auth.event.codeNotReSent("Failed to know what's phone!",t),!1)}register(e){let t;return e.data&&(t=e.element,e=e.data),salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event),this.request("register",e).then(function(e){return salla.auth.event.registered.call(t,e),e}).catch(function(e){throw salla.auth.event.registrationFailed.call(t,e),e})}logout(){return this.request("logout").then(function(e){return salla.auth.event.loggedOut(e),salla.log("Reloading after 0.1 sec..."),setTimeout(()=>location.reload(),100),e}).catch(function(e){throw salla.auth.event.failedLogout(e),e})}refresh(){return this.request("refresh").catch(function(e){throw salla.auth.event.refreshFailed(e),e})}}class OrderApi extends BaseApi{constructor(e){super(e),this.namespace="order",this.endpoints={cancel:"orders/cancel/{id}",reOrder:"reorder/{id}",send:"orders/send/{id}"},this.endpointsMethods={reOrder:"get"},this.hooksSelectores={cancel:"order::cancel",reOrder:"order::re.order",show:"order::show",send:"order::send"},this.after_init()}show(e,t=null){salla.event.dispatch("mobile::order.placed",{order_id:e||salla.config.get("page.id")}),location.href=t||location.href.replace("thankyou","order")}cancel(t){return t=t||salla.config.get("page.id"),this.request(["cancel",t],{params:{has_apple_pay:!!window.ApplePaySession}}).then(function(e){return salla.event.order.canceled(e,t),e}).catch(function(e){throw salla.event.order.notCanceled(e,t),e})}reOrder(t){return t=t||salla.config.get("page.id"),this.request(["reOrder",t]).then(function(e){return salla.storage.set("cart",{id:e.data.cart_id,user_id:salla.config.get("user.id")}),salla.event.order.reOrdered(e,t),window.location.href=e.data.url,e}).catch(function(e){throw salla.event.order.reOrderFailed(e,t),e})}send(e){let t=this.getPossibleValue(e,["id"])||salla.config.get("page.id");var s;return!t||isNaN(t)?(s="There is no id!",salla.order.event.notSent(s),this.errorPromise(s)):this.request(["send",t],e).then(e=>(salla.event.order.sent(e,t),e)).catch(e=>{throw salla.event.order.notSent(e,t),e})}}class OfferApi extends BaseApi{constructor(e){super(e),this.namespace="offer",this.endpoints={popup:"products/special-offer-popup/{product_id}",increase:"products/special-offer-popup/{product_id}/increase",details:"products/{product_id}/specialoffer"},this.webEndpoints=["popup","increase"],this.endpointsMethods={increase:"get"},this.endpointsHeaders={popup:{"s-ajax-view":!0}},this.hooksSelectores={popup:"offer::popup",increase:"offer::increase",details:"offer::details"},this.after_init()}details(e){let t=e.data|e;return(e=this.getPossibleValue(t,["product_id"]))?this.request(["details",e],t).then(function(e){return salla.offer.event.detailsFetched(e,t),e}).catch(function(e){throw salla.offer.event.fetchDetailsFailed(e,t),e}):(salla.offer.event.fetchDetailsFailed('There is no "prodId"!'),!1)}increase(e){let t;return e.data&&(t=e.data,e=this.getPossibleValue(t,["id","product_id"])),e?this.request(["increase",e],t).then(function(e){return salla.offer.event.increased(e,t),e}).catch(function(e){throw salla.offer.event.increaseFailed(e,t),e}):(salla.offer.event.increaseFailed('There is no "prodId"!'),!1)}}class SearchApi extends BaseApi{constructor(e){super(e),this.namespace="search",this.endpoints={search:"products/search"},this.endpointsMethods={search:"get"},this.hooksSelectores={search:"search::products"},this.after_init()}search(t){let e=t.data||{params:{query:t}};var s;return(t=e instanceof FormData?e.get("query"):e.query||e.params.query)?t===this.previousQuery?(s="Query Same As Previous!",salla.search.event.failed(s),this.errorPromise(s)):(this.previousQuery=t,this.request("search",e).then(function(e){return salla.search.event.finished(e,t),e}).catch(function(e){throw salla.search.event.failed(e,t),e})):(s='There is no "query"!',salla.search.event.failed(s),this.errorPromise(s))}}class CouponApi extends BaseApi{constructor(e){super(e),this.namespace="coupon",this.endpoints={add:"cart/{id}/coupon",remove:"cart/{id}/coupon"},this.endpointsMethods={remove:"put"},this.hooksSelectores={add:"coupon::add",remove:"coupon::remove"},this.after_init()}async add(e){if(e=e.data||e,!(e=this.getPossibleValue(e,["coupon"]))){let e=new Error('There is no "Coupon Code"!');return e.name="EmptyCoupon",salla.event.coupon.addedFailed(e),this.errorPromise(e)}let t=await salla.cart.api.getCurrentCartId();return this.request(["add",t],{coupon:e}).then(function(e){return salla.event.coupon.added(e,t),e}).catch(function(e){throw salla.event.coupon.addedFailed(e,t),e})}async remove(){let t=await salla.cart.api.getCurrentCartId();return this.request(["remove",t],{}).then(function(e){return salla.event.coupon.removed(e,t),e}).catch(function(e){throw salla.event.coupon.removedFailed(e,t),e})}}class ProductApi extends BaseApi{constructor(e){super(e),this.namespace="product",this.endpoints={getPrice:"product-price/{id}",availabilitySubscribe:"products/{id}/availability-notify",purchaseNow:"checkout/quick-purchase/{id}"},this.webEndpoints=["getPrice","purchaseNow"],this.hooksSelectores={getPrice:"product::get.price",availabilitySubscribe:"product::availability.subscribe",purchaseNow:"product::purchase.now"},this.after_init()}getPrice(t){var e=t.data||t;return t=this.getPossibleValue(e,["id","prod_id"]),this.request(["getPrice",t],"object"==typeof e?e:void 0).then(function(e){return salla.product.event.priceUpdated(e,t),e}).catch(function(e){throw salla.product.event.priceUpdateFailed(e,t),e})}availabilitySubscribe(t){var e=t.data||t;return t=this.getPossibleValue(e,["id","prod_id"]),this.request(["availabilitySubscribe",t],"object"==typeof e?e:void 0).then(function(e){return salla.product.event.availabilitySubscribed(e,t),e}).catch(function(e){throw salla.product.event.availabilitySubscribedFailed(e,t),e})}purchaseNow(e){if(salla.auth.isGuest())return salla.auth.event.dispatch("login");let t=e.product_data,s=this.getPossibleValue(t,["id","prod_id"]);if(!e.is_applepay)return this.request(["quickPurchase",s],"object"==typeof t?t:void 0).then(function(e){return e}).catch(function(e){throw e});salla.event.dispatch("payments::apple-pay.start-transaction",{amount:e.total,currency:e.currency,requiredShippingContactFields:e.require_shipping?["postalAddress"]:null,shippingMethods:e.require_shipping?[]:null,supportedNetworks:e.applepay_supported_networks,validateMerchant:{url:baseUrl+"checkout/applepay/validate",onFailed:({})=>{console.log("validateMerchant Failed!")},onSuccess:e=>(console.log("validateMerchant Success"),this.request(["quickPurchase",s],"object"==typeof t?t:void 0))},authorized:{url:baseUrl+"/checkout/{id}/payments/submit",onFailed:e=>{console.log("authorized Failed!"),window.Salla.Payments.ApplePay.onCancel({},e.data.error.message)},onSuccess:e=>{console.log(e),window.location.href=e.redirect.url,console.log("authorized Success:: redirect to thank you page, order placed")}},shippingMethodSelected:e.require_shipping?{url:baseUrl+"/checkout/{id}/shipping/details",onFailed:e=>{console.log("select shipping method failed!")},onSuccess:e=>{console.log("select shipping method success")}}:null,shippingContactSelected:e.require_shipping?{url:baseUrl+"/checkout/{id}/address/add",onFailed:e=>{console.log("created contact failed!")},onSuccess:e=>{console.log("created contact success : ",e.data.address_id)}}:null,recalculateTotal:{url:baseUrl+"/checkout/{id}/payments/recalculate"},onError:function(e){console.log(e),salla.notify.error(e)}})}}class CommentApi extends BaseApi{constructor(e){super(e),this.namespace="comment",this.endpoints={send:"{type}/{id}/comments"},this.hooksSelectores={send:"comment::send"},this.after_init()}send(e){let t;e?.data&&(t=e.element,e=e.data);let s,{id:r,type:i,comment:n}=Object.fromEntries(e);return r?i&&["products","pages","product","page"].includes(i)?n?(i+=["product","page"].includes(i)?"s":"",this.request(["send",i,r],{comment:n}).then(function(e){return salla.event.comment.added.call(t,e,r),e}).catch(function(e){throw salla.event.comment.additionFailed.call(t,e,r),e})):(salla.event.comment.additionFailed(s="can't find comment content!"),this.errorPromise(s)):(salla.event.comment.additionFailed(s="Failed to get type one of:(products, product, page, pages)!"),this.errorPromise(s)):(salla.event.comment.additionFailed(s="Failed to get id!"),this.errorPromise(s))}}class CurrencyApi extends BaseApi{constructor(e){super(e),this.namespace="currency",this.endpoints={change:"/",list:"currencies"},this.endpointsMethods={change:"get",list:"get"},this.webEndpoints=["change"],this.hooksSelectores={change:"currency::change"},this.after_init()}change(t){var e;return(t=this.getPossibleValue(t.data||t,["currency","code"]))?this.request("change",{params:{change_currency:"",currency:t}}).then(function(e){return salla.currency.event.changed(e,t),e}).catch(function(e){throw salla.currency.event.failed(e,t),e}):(e="Can't find currency code!",salla.currency.event.failed(e),this.errorPromise(e))}list(){return this.request("list").then(function(e){return salla.currency.event.fetched(e),e}).catch(function(e){throw salla.currency.event.failedToFetch(e),e})}}class DocumentApi extends BaseApi{constructor(e){super(e),this.namespace="document"}}class FeedbackApi extends BaseApi{constructor(e){super(e),this.namespace="feedback",this.endpoints={store:"rating/store",product:"rating/products",shipping:"rating/shipping",order:"rating/{order_id}"},this.hooksSelectores={store:"feedback::store",product:"feedback::product",shipping:"feedback::shipping",order:"feedback::order"},this.endpointsMethods={order:"get"},this.after_init()}order(t){var e="object"==typeof t?t:{};return(t=this.getPossibleValue(t,["order_id","id"]))?this.request(["order",t],e).then(function(e){return salla.event.feedback.orderFetched(e,t),e}).catch(function(e){throw salla.event.feedback.orderNotFetched(e,t),e}):(e='There is no "order_id"!',salla.event.feedback.orderNotFetched(e),this.errorPromise(e))}store(t){var e;return(t=t.data||t)?this.request("store",t).then(function(e){return salla.event.feedback.storeRated(e,t),e}).catch(function(e){throw salla.event.feedback.storeFailed(e,t),e}):(e='There is no "data"!',salla.event.feedback.storeFailed(e),this.errorPromise(e))}products(){return this.product(...arguments)}product(t){var e;return(t=t.data||t)?this.request("product",t).then(function(e){return salla.event.feedback.productRated(e,t),e}).catch(function(e){throw salla.event.feedback.productFailed(e,t),e}):(e='There is no "data"!',salla.event.feedback.productFailed(e),this.errorPromise(e))}shipping(t){var e;return(t=t.data||t)?this.request("shipping",t).then(function(e){return salla.event.feedback.shippingRated(e,t),e}).catch(function(e){throw salla.event.feedback.shippingFailed(e,t),e}):(e='There is no "data"!',salla.event.feedback.shippingFailed(e),this.errorPromise(e))}}class SallaInit{constructor(e){salla.config.merge(e),this.connectHooksWithElements(),this.initiated=!0,e&&(e._token&&(salla.api.defaults.headers.common["X-CSRF-TOKEN"]=e._token),this.injectMaintenanceAlert(),this.injectThemePreviewAlert(),this.injectEditAlert(),salla.lang.loadStoreTranslations()),salla.twilight.event.initiated(e)}injectMaintenanceAlert(){salla.config.get("maintenance")&&(document.querySelector(".store-notify")?salla.log("store-notify Existed before!"):salla.lang.onLoaded(()=>{var e=document.createElement("div");e.classList.add("store-notify"),e.style="background-color: #d63031; color: #fff; padding: 10px 15px; text-align: center; font-size: 17px;",e.innerHTML=`<p style="margin:0 !important;">${salla.lang.get("blocks.header.maintenance_alert")}</p>`,document.body.prepend(e)}))}injectThemePreviewAlert(){"preview"===salla.config.get("theme.mode")&&(document.querySelector("#s-theme_preview_bar")?salla.log("s-theme_preview_bar Existed before!"):salla.lang.onLoaded(()=>{let e=document.createElement("div");e.id="s-theme_preview_bar",e.style={display:"flex",justifyContent:"space-between",textAlign:"center",backgroundColor:"#232323",color:"#fff",padding:"10px",fontSize:"0.875rem",lineHeight:"1.25rem",position:"relative"},e.innerHTML=`
|
|
2
2
|
<div style="display:flex; align-items:center;">
|
|
3
3
|
<img width="32" src="https://assets.salla.sa/cp/assets/images/logo-new.png">
|
|
4
4
|
<span style="margin:0 10px;">${salla.lang.get("blocks.header.preview_mode")}: <span style="background:rgba(255,255,255,0.25);border-radius:15px; padding:2px 15px 4px">${salla.config.get("theme.name")}</span></span>
|