!function() { (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;ir.length)&&(a=r.length);for(var e=0,n=new Array(a);e=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),h=n.call(a,"finallyLoc");if(u&&h){if(this.prev=0;--e){var o=this.tryEntries[e];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),k(e),v}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;k(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:N(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),v}},t}("object"==typeof module?module.exports:{});try{regeneratorRuntime=runtime}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=runtime:Function("r","regeneratorRuntime = r")(runtime)} },{}],18:[function(require,module,exports){ "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault"),_typeof=require("@babel/runtime/helpers/typeof"),_slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")),_defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty")),_setup=_interopRequireDefault(require("./setup")),_store=_interopRequireWildcard(require("./store")),_shared=_interopRequireDefault(require("./shared")),_utils=require("./utils"),_pages=require("./pages");function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(_getRequireWildcardCache=function(e){return e?r:t})(e)}function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!==_typeof(e)&&"function"!=typeof e)return{default:e};var r=_getRequireWildcardCache(t);if(r&&r.has(e))return r.get(e);var o={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if("default"!==n&&Object.prototype.hasOwnProperty.call(e,n)){var i=a?Object.getOwnPropertyDescriptor(e,n):null;i&&(i.get||i.set)?Object.defineProperty(o,n,i):o[n]=e[n]}return o.default=e,r&&r.set(e,o),o}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,o)}return r}function _objectSpread(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{env:"store"};return(0,_store.setStore)(_objectSpread(_objectSpread({},_store.default),e)),(0,_setup.default)(),"store"===_store.default.env&&(0,_utils.onDOMReady)(t),{autorun:t,injectCSS:_utils.injectCSS,ProductPage:_pages.ProductPage,CartPage:_pages.CartPage,shared:_shared.default,store:_store.default};function t(){var e;if(null!==(e=window.AOV_BOOSTER)&&void 0!==e&&e.loaded)return(0,_utils.slog)("ABORT: APP ALREADY LOADED");window.AOV_BOOSTER.loaded=!0,window.AOV_BOOSTER.store=_store.default,console.log("%c AOV Booster","font-weight: bold; font-size: 50px;color: red; text-shadow: 3px 3px 0 rgb(217,31,38) , 6px 6px 0 rgb(226,91,14) , 9px 9px 0 rgb(245,221,8) , 12px 12px 0 rgb(5,148,68) , 15px 15px 0 rgb(2,135,206) , 18px 18px 0 rgb(4,77,145) , 21px 21px 0 rgb(42,21,113)"),console.log("Want to partner? Drop us a line at contact@macas.studio");var t=function(){var e,t=null===_store.default||void 0===_store.default?void 0:_store.default.prefetchedData,r=t.productPage,o=t.sync,a=document.location.pathname,n="other";if(null!=r&&r.active){var i;return n="product",e=null==o?void 0:null===(i=o.products)||void 0===i?void 0:i.find(function(e){var t=e.id;return t===(null==r?void 0:r.shopifyProductPageID)}).handle,{currentPage:n,handle:e}}if("/"===a)(e=_shared.default.getHandleFromProductJSON())&&(n="product");else if(a.includes("/products/"))e=document.location.pathname.split("/").pop(),n="product";else if(0===a.indexOf("/cart"))n="cart";else try{var u,l=Object.keys(null===(u=window)||void 0===u?void 0:u.__shgProducts),d=(0,_slicedToArray2.default)(l,1),c=d[0];if(c)return{currentPage:"product",handle:c}}catch(e){(0,_utils.slog)("not compatible with Shogun")}return{currentPage:n,handle:e}}(),r=t.handle,o=!0;switch(t.currentPage){case"product":(0,_utils.slog)("Handle found!"),_store.default.handle=r,window.AOV_BOOSTER.productPage=new _pages.ProductPage,(0,_utils.slog)({prefetchedData:_store.default.prefetchedData}),(0,_utils.injectCSS)(_store.default.css),window.AOV_BOOSTER.productPage.init();break;case"cart":window.AOV_BOOSTER.cartPage=new _pages.CartPage,(0,_utils.injectCSS)(_store.default.css),window.AOV_BOOSTER.cartPage.init();break;default:(0,_utils.slog)("Other page not tracked by AOV Booster"),o=!1}window.AOV_BOOSTER.allPage=new _pages.AllPage(o),window.AOV_BOOSTER.allPage.init()}}; },{"./pages":21,"./setup":23,"./shared":24,"./store":25,"./utils":26,"@babel/runtime/helpers/defineProperty":5,"@babel/runtime/helpers/interopRequireDefault":6,"@babel/runtime/helpers/slicedToArray":12,"@babel/runtime/helpers/typeof":14}],19:[function(require,module,exports){ "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=AllPage;var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")),_regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty")),_asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")),_store=_interopRequireDefault(require("../store")),_shared=_interopRequireDefault(require("../shared")),_utils=require("../utils");function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,a)}return r}function _objectSpread(e){for(var t=1;t0&&void 0!==arguments[0]&&arguments[0];this.selectors={postAddToCartBtns:"[name=checkout], #cart-dropdown .actions .product-btn, .ws-cs-checkout-btn, .cart__checkout, .mgn-minicart-checkout, .basket-popup__buy",externalSubtotalPrice:".slidecart-subtotal, #cart-dropdown .summary .price, .ajaxcart__price, [data-subtotal], .ws-cs-total, .drawer__footer .ajaxcart__price, .ajaxcart__footer-total .money, .cart-subtotal--price, .mgn-minicart-subtotal strong, #total_mini_cart, .basket-popup__price-cell--total .money, [data-cart-total]"},this.init=(0,_asyncToGenerator2.default)(_regenerator.default.mark(function e(){return _regenerator.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return _store.default.data=_objectSpread({},_store.default.prefetchedData),this.selectors=_shared.default.syncWithCustomSelectors(this.selectors,_store.default.data),e.next=4,_shared.default.refreshCartData();case 4:(0,_utils.slog)("GOT DATA"),window.AOV_BOOSTER.refreshCartInterval=setInterval(_shared.default.refreshCartData,2e3),this.setupListeners();case 7:case"end":return e.stop()}},e,this)})),this.setupListeners=function(){var e=this,t=[function(){e.$postAddToCartBtns=(0,_toConsumableArray2.default)(document.querySelectorAll(e.selectors.postAddToCartBtns)),e.$postAddToCartBtns=e.$postAddToCartBtns.map(function(t){return(0,_utils.resetAndAddEventListener)(t,"click",function(t){(0,_utils.slog)("Post ATC clicked"),t.target!==e.$addToCartBtn?((0,_utils.stopEvent)(t),_shared.default.redirectPostAddToCart("checkout")):(0,_utils.slog)("But it's the default, ATC -> abort")})})},function(){var t,r,a,o=_store.default.data.offers||{};if(Object.keys(o).length){e.$externalSubtotalPriceItems=document.querySelectorAll(e.selectors.externalSubtotalPrice);try{t=_store.default.cart.total_price/100,a=_shared.default.getGroupedLineItems(_store.default.cart,o),r=_shared.default.resolveCartRealTotalPrice(a,o)}catch(e){return(0,_utils.slog)("Error: Unable to estimate prices, data may not be updated yet."),void(0,_utils.slog)(e)}e.$externalSubtotalPriceItems.forEach(function(e){return _shared.default.replaceUIPriceItem(e,t,r,_store.default.data.sync)})}}];window.AOV_BOOSTER.listenersInterval=setInterval(function(){return t.forEach(function(t){return t.call(e)})},1e3)}} },{"../shared":24,"../store":25,"../utils":26,"@babel/runtime/helpers/asyncToGenerator":4,"@babel/runtime/helpers/defineProperty":5,"@babel/runtime/helpers/interopRequireDefault":6,"@babel/runtime/helpers/toConsumableArray":13,"@babel/runtime/regenerator":16}],20:[function(require,module,exports){ "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=CartPage;var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")),_regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty")),_asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")),_store=_interopRequireDefault(require("../store")),_shared=_interopRequireDefault(require("../shared")),_utils=require("../utils.js");function ownKeys(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,o)}return r}function _objectSpread(t){for(var e=1;e ",o),o.length){t.next=14;break}return t.abrupt("return");case 14:return t.next=16,_shared.default.fetchOffersData(o);case 16:_store.default.data.offers=t.sent,a=_shared.default.getGroupedLineItems(_store.default.cart,_store.default.data.offers),(s=function(){return c.replaceUIPrices(a,_store.default.cart.total_price/100)})(),this.preventOverrides(s);case 21:case"end":return t.stop()}},t,this)})),this.preventOverrides=function(t){var e=this;setInterval(function(){document.querySelector(e.selectors.goToCheckoutBtn)===e.$goToCheckoutBtn||(slog("Warning: Not same checkout button !"),e.$goToCheckoutBtn=document.querySelector(e.selectors.goToCheckoutBtn),e.$goToCheckoutBtn=(0,_utils.resetAndAddEventListener)(e.$goToCheckoutBtn,"click",e.onClickOnCheckout.bind(e))),e.$goToCheckoutBtn.onclick===onclick||(slog("Warning: Has not the event attached !"),e.$goToCheckoutBtn.onclick=onclick),document.querySelector(".b-app__subtotal-price--old")&&document.querySelector(".b-app__subtotal-price--new")||(slog("Warning: Has not the prices !"),t())},500)},this.onClickOnCheckout=function(){var t=(0,_asyncToGenerator2.default)(_regenerator.default.mark(function t(e){return _regenerator.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return slog("CLICK GO TO CHECKOUT, GETTING CART..."),(0,_utils.stopEvent)(e),slog("this.$goToCheckoutBtn"),slog(this.$goToCheckoutBtn),_shared.default.createLoader(this.$goToCheckoutBtn),t.next=7,_shared.default.fetchCartData();case 7:_store.default.cart=t.sent,slog("GOT CART -> ",_store.default.cart),_shared.default.hasOffersInCart(_store.default.cart)?(slog("GO TO GENERATED CHECKOUT"),_shared.default.generateCheckoutLink(_shared.default.formatCartForGeneratingCheckout(_store.default.cart),_store.default.apiURL,_store.default.shop).then(function(t){var e=t.checkoutLink;if(slog({data:t}),!e)throw"";window.location=e}).catch(function(t){slog("ERR IN FETCH CHECKOUT LINK"),window.location="/checkout"})):(slog("GO TO DIRECT CHECKOUT"),window.location="/checkout");case 10:case"end":return t.stop()}},t,this)}));return function(e){return t.apply(this,arguments)}}(),this.replaceUIPrices=function(t,e){var r=_store.default.data.offers,o=_shared.default.resolveCartRealTotalPrice(t,r);this.$subtotalPriceItems=(0,_toConsumableArray2.default)(document.querySelectorAll(this.selectors.subtotalPrice)),slog("Editing subtotal price items..."),slog(this.$subtotalPriceItems,this.selectors.subtotalPrice),o button[type=submit], .addtocart-button-active",secondaryAddToCartBtns:".sticky-submit, .stiky_button, .sticky-add-to-cart, .satcb_btn button",formPreview:".b-o-preview__form"},this.$form=null,this.$addToCartBtn=null,this.$secondaryAddToCartBtns=[],this.$postAddToCartBtns=[],this.init=(0,_asyncToGenerator2.default)(_regenerator.default.mark(function t(){var e;return _regenerator.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(e=_store.default.mockedData||{},_store.default.data=_objectSpread(_objectSpread({},_store.default.prefetchedData),e),this.selectors=_shared.default.syncWithCustomSelectors(this.selectors,_store.default.data),_store.default.data.productPage){t.next=7;break}return t.next=6,this.fetchProductPageData();case 6:_store.default.data.productPage=t.sent;case 7:if(_store.default.data.settings.customCSS&&(0,_utils.injectCSS)(_store.default.data.settings.customCSS),this.buildUI(),"store"!==_store.default.env){t.next=12;break}return t.next=12,_shared.default.refreshCartData();case 12:case"end":return t.stop()}},t,this)})),this.fetchProductPageData=function(){return fetch("".concat(_store.default.apiURL,"/api/public/product-page?shop=").concat(_store.default.shop,"&handle=").concat(_store.default.handle),{mode:"cors"}).then(function(t){return t.json()}).then(function(t){return t.productPage})},this.buildUI=function(){void 0===this.isFirstBuild&&(this.isFirstBuild=!0),"store"===_store.default.env?this.hideThemeElements():this.$form=document.querySelector(this.selectors.formPreview),this.$offerSelect=document.createElement("div"),"store"===_store.default.env?this.$addToCartBtn.parentNode.insertBefore(this.$offerSelect,this.$addToCartBtn):this.$form.insertBefore(this.$offerSelect,this.$form.firstChild),this.$offerSelect.outerHTML=this.buildMarkup(),this.$offerSelect=this.$form.querySelector(".b-app-os"),this.setupLogic(),this.isFirstBuild&&this.listenToDOMChanges(),this.isFirstBuild=!1},this.resetUI=function(){(0,_utils.slog)("RESET UI"),this.clearUI(),this.buildUI()},this.clearUI=function(){(0,_utils.slog)("CLEAR UI"),(0,_utils.slog)(this.$offerSelect),this.$offerSelect.remove()},this.hideThemeElements=function(){var t=this;this.$form=document.querySelector(this.selectors.form),this.$inputs=this.$form.querySelectorAll(this.selectors.formInputs),this.$addToCartBtn=this.$form.querySelector(this.selectors.addToCartBtn),this.$addToCartBtn.classList.add("b-app__ATC-btn"),this.$addToCartBtn.parentNode.classList.add("b-app__ATC-container"),this.$addToCartBtn.removeAttribute("data-skip-cart"),this.$addToCartBtn.onclick="",this.$addToCartBtn.disabled=!1;for(var e=this.$addToCartBtn;e;e=e.parentNode)e.getAttribute&&"1"===e.getAttribute("data-ajaxCart")&&e.setAttribute("data-ajaxCart","0");(0,_utils.slog)({$form:this.$form,$inputs:this.$inputs,$addToCartBtn:this.$addToCartBtn}),this.$form.addEventListener("submit",_utils.stopEvent),this.$form.onsubmit="event.preventDefault(); return false;",this.$form.classList.add("b-app-os__form"),this.$inputs.forEach(function(e){e!==t.$addToCartBtn&&(e.style.display="none")})},this.buildMarkup=function(){var t=_store.default.data.sync,e=_store.default.data.design,o=this.buildOffersWithOptions(),r=_store.default.data.productPage.preselectedOfferID,i=r?o.findIndex(function(t){return t._id===r}):0;return-1===i&&(0,_readOnlyError2.default)("preselectedOfferID"),this.injectStyleVars(),(0,_utils.slog)({offers:o}),'
\n

\n '.concat(_store.default.data.settings.descriptionText,'\n

\n
\n ').concat(o.map(function(o,r){var n,a=(n=o.products[0].shopifyProductID,t.products.find(function(t){return t.id===n})||{price:0,compareAtPrice:0}),s=o.isOriginalOffer?parseFloat(a.price):o.price,c=o.isOriginalOffer?parseFloat(a.compareAtPrice):o.compareAtPrice;(0,_utils.slog)("PRICE");var l=_shared.default.formatPrice(s);(0,_utils.slog)("COMPARE AT PRICE");var d=_shared.default.formatPrice(c);(0,_utils.slog)("DEBUG"),(0,_utils.slog)({compareAtPrice:c}),(0,_utils.slog)({formattedCompareAtPrice:d});var f="text"===o.highlightSettings.type?o.highlightSettings.text.content:"",p=o.isHighlighted&&("text"===o.highlightSettings.type&&f||"timer"===o.highlightSettings.type),u=0;return'\n
\n ').concat(p&&"top-bar"===e.highlightedOffer.highlightStyle?'
'.concat(f,"
"):"","\n ").concat(p&&"pill"===e.highlightedOffer.highlightStyle?'
'.concat(f,"
"):"",'\n\n
\n
').concat("checkmark"===e.offer.radioStyle?'':"","
\n ").concat(o.imageURL?'\n
\n \n
'):"",'\n
\n ').concat(p&&"above-title"===e.highlightedOffer.highlightStyle?'
'.concat(f,"
"):"",'\n
').concat(o.title,'
\n
').concat(o.tagline,'
\n
\n \x3c!--
\n \n
--\x3e\n
\n
').concat(l,"
\n ").concat(c?'
'.concat(d,"
"):"","\n ").concat(p&&"below-price"===e.highlightedOffer.highlightStyle?'
'.concat(f,"
"):"","\n
\n
\n ").concat(o._productsWithOptions.length?'
\n '.concat(o._productsWithOptions.map(function(t){for(var e="",r=function(r){u++,e+='\n
\n ').concat(o._productsWithOptions.length>1?'\n
'.concat(t.title," ").concat(t.quantity>1?r+1:"","
\n "):"",'\n
\n ').concat(t.options.map(function(e){return'\n
\n \n
\n ")}).join(""),"\n
\n
")},i=0;i"):"","\n
")}).join(""),"\n
\n
\n ")},this.injectStyleVars=function(){var t=_store.default.data.design,e="\n :root {\n --b-app-description-text-size: ".concat(t.description.textSize,";\n --b-app-description-color: ").concat(t.description.color,";\n --b-app-description-margin-bottom: ").concat(t.description.marginBottom,";\n\n /*--b-app-offer-spacing: ").concat(t.offer.spacing,";*/\n --b-app-offer-background: ").concat(t.offer.background,";\n --b-app-offer-border-radius: ").concat(t.offer.borderRadius,";\n --b-app-offer-border-color: ").concat(t.offer.borderColor,";\n --b-app-offer-border-width: ").concat(t.offer.borderWidth,";\n /*--b-app-offer-radio-style: ").concat(t.offer.radioStyle,";*/\n --b-app-offer-radio-color: ").concat(t.offer.radioColor,";\n --b-app-offer-radio-border-color: ").concat(t.offer.radioBorderColor,";\n --b-app-offer-title-size: ").concat(t.offer.titleSize,";\n --b-app-offer-title-color: ").concat(t.offer.titleColor,";\n --b-app-offer-tagline-size: ").concat(t.offer.taglineSize,";\n --b-app-offer-tagline-color: ").concat(t.offer.taglineColor,";\n --b-app-offer-price-size: ").concat(t.offer.priceSize,";\n --b-app-offer-price-color: ").concat(t.offer.priceColor,";\n --b-app-offer-compare-at-price-size: ").concat(t.offer.compareAtPriceSize,";\n --b-app-offer-compare-at-price-color: ").concat(t.offer.compareAtPriceColor,";\n --b-app-offer-option-title-size: ").concat(t.offer.optionTitleSize,";\n --b-app-offer-option-text-color: ").concat(t.offer.optionTextColor,";\n --b-app-offer-option-select-background: ").concat(t.offer.optionSelectBackground,";\n --b-app-offer-option-select-color: ").concat(t.offer.optionSelectColor,";\n\n /*--b-app-highlighted-offer-highlight-style: ").concat(t.highlightedOffer.highlightStyle,";*/\n --b-app-highlighted-offer-highlighted-box-background: ").concat(t.highlightedOffer.highlightedBoxBackground,";\n --b-app-highlighted-offer-highlighted-box-color: ").concat(t.highlightedOffer.highlightedBoxColor,";\n --b-app-highlighted-offer-highlighted-box-border-radius: ").concat(t.highlightedOffer.highlightedBoxBorderRadius,";\n --b-app-highlighted-offer-highlighted-box-size: ").concat(t.highlightedOffer.highlightedBoxSize,";\n --b-app-highlighted-offer-background: ").concat(t.highlightedOffer.background,";\n --b-app-highlighted-offer-border-color: ").concat(t.highlightedOffer.borderColor,";\n --b-app-highlighted-offer-title-color: ").concat(t.highlightedOffer.titleColor,";\n --b-app-highlighted-offer-tagline-color: ").concat(t.highlightedOffer.taglineColor,";\n --b-app-highlighted-offer-price-color: ").concat(t.highlightedOffer.priceColor,";\n --b-app-highlighted-offer-compare-at-price-color: ").concat(t.highlightedOffer.compareAtPriceColor,";\n\n --b-app-selected-offer-background: ").concat(t.selectedOffer.background,";\n --b-app-selected-offer-border-color: ").concat(t.selectedOffer.borderColor,";\n --b-app-selected-offer-title-color: ").concat(t.selectedOffer.titleColor,";\n --b-app-selected-offer-tagline-color: ").concat(t.selectedOffer.taglineColor,";\n --b-app-selected-offer-price-color: ").concat(t.selectedOffer.priceColor,";\n --b-app-selected-offer-compare-at-price-color: ").concat(t.selectedOffer.compareAtPriceColor,";\n --b-app-selected-offer-highlighted-box-background: ").concat(t.selectedOffer.highlightedBoxBackground,";\n --b-app-selected-offer-highlighted-box-color: ").concat(t.selectedOffer.highlightedBoxColor,";\n --b-app-loader-color: ").concat(t.loader.color,";\n }");(0,_utils.injectCSS)(e)},this.buildOffersWithOptions=function(){var t=this,e=_store.default.data.sync.products;return _store.default.data.productPage.offers.map(function(o){o._productsWithOptions=o.products.map(function(t){var o=e.find(function(e){return e.id===t.shopifyProductID});return{id:o.id,title:o.title,options:o.options,hasOnlyDefaultVariant:o.hasOnlyDefaultVariant,quantity:t.quantity}}).filter(function(t){return t});var r=t.resolveShallowOptions();return o._productsWithOptions[0].options=o._productsWithOptions[0].options.filter(function(t){return!t.isShallowOption}),(0,_utils.slog)({mainProductShallowOptions:r}),r.forEach(function(t){o._productsWithOptions[0].options.push(t)}),o})},this.resolveShallowOptions=function(){var t=Array.from(this.$form.querySelectorAll("select")).filter(function(t){return 0===t.name.indexOf("properties[")}),e=[];return(0,_utils.slog)({$form:this.$form}),(0,_utils.slog)({raw$selects:this.$form.querySelectorAll("select")}),(0,_utils.slog)({$selects:t}),t.forEach(function(t){var o=Array.from(t.options).map(function(t){return t.value}).filter(function(t){return t}),r=t.name.split("properties[")[1]||"";(r=r.split("]")[0])&&e.push({id:null,position:null,isShallowOption:!0,name:r,values:o})}),e},this.setupLogic=function(){this.setupOfferSelection(),this.setupHighlightTimers(),"store"===_store.default.env&&(this.listenToExternalElements(),this.setupAddToCart())},this.listenToDOMChanges=function(){var t=this;(0,_utils.slog)({$form:this.$form});var e=function(){return t.$form.querySelectorAll("select:not(.b-app-os__options-select), input").length};this.lastInputsLength=e();new MutationObserver(function(o){o.forEach(function(o){var r=e();r!==t.lastInputsLength&&(t.lastInputsLength=r,(0,_utils.slog)("SELECT NB HAS CHANGED, NEED TO UPDATE THE OFFER SELECT"),t.resetUI()),"childList"==o.type||o.type})}).observe(this.$form,{childList:!0,attributes:!0,subtree:!0})},this.setupOfferSelection=function(){var t=document.querySelectorAll(".b-app-os__offer");t.forEach(function(e){e.addEventListener("click",function(o){e.classList.contains("b-app-os__offer--selected")||(t.forEach(function(t){t.classList.remove("b-app-os__offer--selected")}),e.classList.add("b-app-os__offer--selected"))})})},this.setupHighlightTimers=function(){var t=_store.default.data.productPage.offers,e=document.querySelectorAll(".b-app-os__offer"),o=function(t){var e=t.days,o=t.hours,r=t.mins,i=t.secs,n=new Date;return n.setDate(n.getDate()+e),n.setHours(n.getHours()+o),n.setMinutes(n.getMinutes()+r),n.setSeconds(n.getSeconds()+i),n},r=function(t,e){var o,r,i=(o=e._id,(r=localStorage.getItem("B_APP_TIMER_".concat(o)))?JSON.parse(r):{}),n={};for(var a in t)n[a]=void 0!==i[a]?i[a]:t[a];return n},i=function(t){var e=Date.parse(t)-Date.parse(new Date),o=Math.floor(e/1e3%60),r=Math.floor(e/1e3/60%60),i=Math.floor(e/36e5%24);return{days:Math.floor(e/864e5),hours:i,mins:r,secs:o}};e.forEach(function(e,n){var a=t[n]||{},s=a.isHighlighted,c=a.highlightSettings;if(s&&"timer"===c.type){var l=c.timer.time,d=e.querySelector(".b-app-os__highlight-content");"store"===_store.default.env&&(l=r(l,a));var f=o(l),p=function(){var t=i(f);for(var e in t)t[e]<0&&(t=i(f=o(l)));var r,n,s=[c.timer.textBefore,t.days?t.days+"d":null,t.hours+"h",t.mins+"m",c.timer.hideSeconds?null:t.secs+"s"].filter(function(t){return null!==t&&0!==t}).join(" ");d.textContent=s,"store"===_store.default.env&&(r=t,n=a._id,localStorage.setItem("B_APP_TIMER_".concat(n),JSON.stringify(r)),function(t){return Object.values(t).every(function(t){return t<=0})}(t)&&(f=o(c.timer.time)))};p(),"store"===_store.default.env&&setInterval(p,1e3)}})},this.listenToExternalElements=function(){var t=this;if(this.isFirstBuild){var e=[function(){t.$secondaryAddToCartBtns=(0,_toConsumableArray2.default)(document.querySelectorAll(t.selectors.secondaryAddToCartBtns)),t.$secondaryAddToCartBtns=t.$secondaryAddToCartBtns.map(function(e){return(0,_utils.resetAndAddEventListener)(e,"click",function(e){(0,_utils.slog)("Secondary ATC clicked"),e.target!==t.$addToCartBtn?((0,_utils.stopEvent)(e),t.$addToCartBtn.click()):(0,_utils.slog)("But it's the default, ATC -> abort")})})}];setInterval(function(){return e.forEach(function(e){return e.call(t)})},1e3)}},this.setupAddToCart=function(){var t=this;this.$addToCartBtn=(0,_utils.resetAndAddEventListener)(this.$addToCartBtn,"click",function(e){(0,_utils.stopEvent)(e);var o=t.buildCartPayload();_shared.default.createLoader(t.$addToCartBtn),(0,_utils.slog)({payload:o}),t.trackAddToCart(o),t.addToCart(o).then(function(e){var o=e.items;t.mergeCartAndAddedItems(o),(0,_utils.slog)("Add to cart response (addedItems)",o),_shared.default.redirectPostAddToCart(),_shared.default.removeLoader(t.$addToCartBtn)}).catch(function(e){(0,_utils.slog)("Err add to cart"),(0,_utils.slog)(e),_shared.default.removeLoader(t.$addToCartBtn),window.location="/cart"})})},this.buildCartPayload=function(){for(var t=this,e=_store.default.data.productPage,o=this.resolveSelectedOfferIndex(),r=e.offers[o],i=document.querySelector(".b-app-os__selector").children[o],n=_store.default.data.settings.offerPropertyText||"Offer",a=[],s=function(e){var o=Math.floor(1e9*Math.random());Array.from(i.querySelectorAll(".b-app-os__options-group")).forEach(function(i){var s=i.getAttribute("data-product-id"),c=Array.from(i.querySelectorAll("select")).map(function(t){return{name:t.name,value:t.value,isShallowOption:t.hasAttribute("data-shallow-option")}}),l={id:t.resolveVariantFromOptions(s,c),quantity:1,properties:{}};r.isOriginalOffer||(l.properties._offerTypeID=r._id,l.properties._offerRelationalUUID=o),c.forEach(function(t){t.isShallowOption&&(l.properties[t.name]=t.value)}),l.properties[n]=[e+1,r.title],a.push(l)})},c=0;c<1;c++)s(c);for(var l=0;l=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){u=!0,a=e},f:function(){try{i||null==r.return||r.return()}finally{if(u)throw a}}}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r")}catch(e){console.error("Format price error"),console.error(e),t=r.meta.currencySymbol+a}"string"==typeof e&&(e=e.replace(".",""));var u="",c=/\{\{\s*(\w+)\s*\}\}/,l=function(e,t){return void 0===e?t:e},s=function(e,t,r,n){if(e=+e,e*=o,t=l(t,2),r=l(r,","),n=l(n,"."),isNaN(e)||null==e)return 0;var a=(e=(e/100).toFixed(t)).split(".");return a[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1"+r)+(a[1]?n+a[1]:"")};switch(t.match(c)[1]){case"amount":u=s(e,2);break;case"amount_no_decimals":u=s(e,0);break;case"amount_with_comma_separator":u=s(e,2,".",",");break;case"amount_no_decimals_with_comma_separator":u=s(e,0,".",",");break;case"amount_with_apostrophe_separator":u=s(e,2,"'",".")}return t.replace(c,u)},fetchCartData:function(){return fetch("/cart.js").then(function(e){return e.json()})},refreshCartData:function(){var e=(0,_asyncToGenerator2.default)(_regenerator.default.mark(function e(){var t,r,n,o;return _regenerator.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,shared.fetchCartData();case 2:if(t=e.sent,_store.default.cart=t,(0,_utils.isFunction)(window.SLIDECART_SET_CART)&&window.SLIDECART_SET_CART(_store.default.cart),r=shared.resolveOfferIDs(_store.default.cart),(n=shared.findUntrackedOfferIDs(r)).length){e.next=9;break}return e.abrupt("return");case 9:return _store.default.data.offers||(_store.default.data.offers={}),e.next=12,shared.fetchOffersData(n);case 12:o=e.sent,_store.default.data.offers=_objectSpread(_objectSpread({},_store.default.data.offers),o);case 14:case"end":return e.stop()}},e)}));return function(){return e.apply(this,arguments)}}(),hasOffersInCart:function(e){return e.items.some(function(e){return!!e.properties&&!!e.properties._offerTypeID})},resolveOfferIDs:function(e){return e.items.map(function(e){return e.properties?e.properties._offerTypeID:null}).filter(function(e){return e})},findUntrackedOfferIDs:function(e){var t=_store.default.data.offers||{};return e.filter(function(e){return-1===Object.values(t).findIndex(function(t){return t.id===e})})},fetchOffersData:function(e){return e=(0,_toConsumableArray2.default)(new Set(e)),fetch("".concat(_store.default.apiURL,"/api/public/offers?shop=").concat(_store.default.shop,"&offer_ids=").concat(e)).then(function(e){return e.json()}).then(function(e){return e.offers})},getGroupedLineItems:function(e,t){var r=shared.groupLineItemsByOffer(e.items);for(var n in r.offers){var o=r.offers[n],a=t[o[0].properties._offerTypeID];try{if(!shared.validateOffer(o,a))throw"Offer not validated by function."}catch(e){(0,_utils.slog)("OFFER NOT VALIDATED: WOOOOOPS"),(0,_utils.slog)(e);for(var i=0;i ').concat(shared.formatPrice(r),""))},generateCheckoutLink:function(e,t,r){return fetch("".concat(t,"/api/public/order?shop=").concat(r),{method:"POST",body:JSON.stringify(e)}).then(function(e){return e.json()})},formatCartForGeneratingCheckout:function(e){return e.items=e.items.map(function(e){return{id:e.id,properties:e.properties,quantity:e.quantity,variant_id:e.variant_id}}),e},syncWithCustomSelectors:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=(arguments.length>1?arguments[1]:void 0).settings.selectors||{},r=["subtotalPrice","form","addToCartBtn"];for(var n in e){var o=t[n];o&&(e[n]=r.includes(n)?o:o+","+e[n])}return e},createLoader:function(e){var t,r;(0,_utils.slog)("Create loader");var n=function(){t?((0,_utils.slog)("Update loader"),r=e.getBoundingClientRect(),t.style.left=r.left+window.scrollX+r.width/2+"px",t.style.top=r.top+window.scrollY+r.height/2+"px"):(0,_utils.slog)("Update but NO loader")};e.setAttribute("data-text-color",window.getComputedStyle(e).color),e.style.color="transparent",(t=document.createElement("div")).classList.add("b-app__loader"),n(),document.body.appendChild(t),(0,_utils.slog)(t),window.addEventListener("resize",n)},removeLoader:function(e){var t=document.querySelectorAll(".b-app__loader"),r=e.getAttribute("data-text-color");e.style.color=r,e.setAttribute("data-text-color",""),t.forEach(function(e){return e.remove()})},redirectPostAddToCart:function(e){if(e||(e=_store.default.data.settings.redirectTo),"cart"===e||"slide-cart"===e)(0,_utils.slog)("Redirecting to cart"),shared.openSlideCart();else if(shared.isCheckoutX(e))try{return shared.redirectToCheckoutX()}catch(e){console.error("unable to redirect to checkout x"),console.error(e)}else shared.hasOffersInCart(_store.default.cart)?((0,_utils.slog)("Redirecting to GENERATED CHECKOUT"),shared.generateCheckoutLink(shared.formatCartForGeneratingCheckout(_store.default.cart),_store.default.apiURL,_store.default.shop).then(function(e){var t=e.checkoutLink;if((0,_utils.slog)({data:e}),!t)throw"Error: No checkout link";(0,_utils.slog)({checkoutLink:t}),window.location=t}).catch(function(e){(0,_utils.slog)("Err generating checkout link"),(0,_utils.slog)(e),window.location="/cart"})):((0,_utils.slog)("Redirecting to DIRECT CHECKOUT"),window.location="/checkout")},isCheckoutX:function(){var e,t;return"checkout-x"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:_store.default.data.settings.redirectTo)&&(0,_utils.isFunction)(null===(e=CHKX)||void 0===e?void 0:null===(t=e.common)||void 0===t?void 0:t.redirectToCheckoutX)},redirectToCheckoutX:function(){return(0,_asyncToGenerator2.default)(_regenerator.default.mark(function e(){return _regenerator.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,CHKX.cartApi.syncCart();case 2:CHKX.common.redirectToCheckoutX();case 3:case"end":return e.stop()}},e)}))()},openSlideCart:function(){var e=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n0&&void 0!==arguments[0]?arguments[0]:{};for(var t in e)store[t]=e[t]}exports.default=_default; },{}],26:[function(require,module,exports){ "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.decodeData=decodeData,exports.injectCSS=injectCSS,exports.isFunction=isFunction,exports.onDOMReady=onDOMReady,exports.resetAndAddEventListener=resetAndAddEventListener,exports.slog=slog,exports.stopEvent=stopEvent,exports.wait=wait;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));function _createForOfIteratorHelper(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){c=!0,a=e},f:function(){try{i||null==r.return||r.return()}finally{if(c)throw a}}}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r