(()=>{var __webpack_modules__={681:(e,t,o)=>{const n=o(980),i=(o(645),o(298)),r=o(460);let d=e.exports={addCartAddSubmitClickListener:function(e,t){let o=e.querySelectorAll("button,input");if(o)for(let e=0;e<o.length;e++)"add"!==o[e].name&&"submit"!==o[e].type||"true"!==o[e].getAttribute("listener")&&(o[e].setAttribute("listener","true"),o[e].addEventListener?o[e].addEventListener("click",(function(n){t(n,o[e])}),!0):o[e].attachEvent("onclick",(function(n){t(n,o[e])}),!0))},addListenersToElements:function(e,t){for(let o of e)o&&"true"!==o.getAttribute(t)&&(o.setAttribute(t,"true"),o.addEventListener?o.addEventListener("click",(function(e){d.handleAddToCart(e,o)}),!0):o.attachEvent("onclick",(function(e){d.handleAddToCart(e,o)}),!0))},registerListeners:function(e){let t=n.getSetup(),o=n.getWidgetSetup(t,"product-page-addon-widget");if(o&&o.isEnabled&&"trigger"===o.addToCartAction&&t.offers&&t.offers.length&&t.offers.some((e=>"product-addons"===e.upsellType)))if(e||o.addToCartBtnSelector){let i=e&&o.addToCartBtnSelector?`${e}, ${o.addToCartBtnSelector}`:e||o.addToCartBtnSelector;n.log("custom Selectors",i);let r=t.version>=18?document.querySelectorAll(i):[document.querySelector(e),document.querySelector(o.addToCartBtnSelector)];r&&(n.log("Replaced submitButtons with custom addToCartBtnSelectors:",r),d.addListenersToElements(r,t.version>=18?"lb-upsell-custom-ATC-listener":"listener"))}else{let e=r.getProductCartAddForms();e&&e.length&&(d.addCartAddSubmitClickListener(e[0],d.handleAddToCart),n.upsellFunnelLog("Registered add to cart form listeners"))}else n.upsellFunnelLog("product-addons not setup, so not registering listeners")},handleAddToCart:function(e,t){if(n.isAddToCartClickForced)n.log("Add to cart click is forced"),n.isAddToCartClickForcedReset&&(n.isAddToCartClickForced=!1);else{e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopImmediatePropagation&&e.stopImmediatePropagation(),n.isAddToCartClickForcedReset=!1;let o=t||e.srcElement;i.ppaWidgetLib().handleAddToCart(o),n.log("------------")}}}},693:(e,t,o)=>{const n=o(980),i=o(645),r=o(460);let d,s=e.exports={getCartItems:function(){return d},isThankyouPage:function(){return-1!==window.location.pathname.indexOf("/orders/")||-1!==window.location.pathname.indexOf("/thank_you")&&-1!==window.location.pathname.indexOf("/checkouts/")},proceedToCheckout:function(e,t,o,r,d,s,l){n.upsellFunnelLog("Proceeding to cart"),t&&n.isDiscountStacked()&&window.lbUpsellComponents&&void 0===window.lbUpsellComponents.handleUpsellFunnelCheckout&&(n.log("Defining handleUpsellFunnelCheckout for stack discounts"),window.lbUpsellComponents.handleUpsellFunnelCheckout=function(e){return new Promise(((t,o)=>{n.log("handleUpsellFunnelCheckout called",e),setTimeout((()=>{t("proceed")}),2e3)}))});let a,c=n.getSetup(),u=n.getWidgetSetup(c,"popup-upsell-funnel-widget"),p=n.getWidgetSetup(c,"popup-cart-addons-widget"),g=!1;if(window.lbUpsellComponents&&window.lbUpsellComponents.isAnchorTagUsedForCheckout||o&&o.tagName&&"a"===o.tagName.toLowerCase()&&"/checkout"===o.getAttribute("href")){n.upsellFunnelLog("Anchor tag checkout is used"),g=!0;let e=i.getDiscountFromStorage();s&&e&&!t&&(t=e,n.upsellFunnelLog("Replacing anchor tag discount code",t))}window.lbUpsellComponents&&window.lbUpsellComponents.handleUpsellFunnelCheckout?(n.log("handleUpsellFunnelCheckout will be called"),a=window.lbUpsellComponents.handleUpsellFunnelCheckout({acceptedProducts:e,discount:t,isPPCSEOrPPADiscValid:s})):(n.log("proceeding to checkout without checkoutPromise"),a=Promise.resolve()),a.then((async i=>{if(n.log("result",i),r)n.upsellFunnelLog("Rendered by external app, triggering custom event"),n.triggerCustomEvent({acceptedProducts:e,discount:t},"selleasy-checkout-popup-completed");else if(("popup-upsell-funnel-widget"===d&&u&&u.isWindowRedirectUsedForCheckout||"popup-cart-addons-widget"===d&&p&&p.isWindowRedirectUsedForCheckout)&&e&&e.length&&l&&l.items&&e.some((e=>l.items.some((t=>`${t.product_id}`==`${e.id}`))))||g){n.upsellFunnelLog("Using window redirection for 1+1 offers");let e=n.getRootRoute();window.location.href=e&&"/"!==e?`${e}cart/checkout${t?`?discount=${t.code}`:""}`:"/cart/checkout"+(t?`?discount=${t.code}`:"")}else n.isCheckoutClickForced=!0,o.disabled=!1,o&&t&&t.code&&window&&window.location?(c&&c.isDealeasyIntegrated&&window.lbDealeasy&&"function"==typeof window.lbDealeasy.applyDiscountsToCart&&await window.lbDealeasy.applyDiscountsToCart([t.code],"selleasy"),o.click()):o.click();setTimeout((()=>{const e=document.querySelector("#lb-upsell-modal-bg-id");e&&(e.style.display="none");const t=document.querySelector(".lb-upsell-modal-container");t&&(t.style.display="none");const o=document.querySelector("#lb-addon-popup-bg-id");o&&(o.style.display="block");const n=document.querySelector("#lb-addon-popup-container-id");n&&(n.style.display="block"),document.body.classList.remove("lb-upsell-prevent-scroll")}),5e3)}))},getFormattedWidgetInput:function(e,t,o,i,s){return new Promise(((l,a)=>{const c=n.getSetup();let u={boughtTogether:[],discounts:"popup-cart-addons"===t.upsellType&&o?t.discounts:t.tpaeDiscounts,overrideWidgeTitle:t.overrideWidgeTitle},p={styles:e.styles,content:e.content,isQuantityPickerEnabled:e.isQuantityPickerEnabled||!0,imageResolution:e.imageResolution,isMultipleVariantsAdded:"tq-page-addon-embedded-widget"===e.type?!1!==e.isMultipleVariantsAdded:e.isMultipleVariantsAdded,isQtyPickerHidden:e.isQtyPickerHidden,metadata:{shopCurrencyFormat:c&&c.shopEmailCurrencyFormat?c.shopEmailCurrencyFormat:c.shopCurrencyFormat,isAmountNoDecimals:c&&c.isAmountNoDecimals,shopMoneyInEmailsFormat:c&&c.shopMoneyInEmailsFormat,shopCurrencyCode:c&&c.shopCurrencyCode,presentmentCurrency:void 0,isUnitPriceShown:c&&c.isUnitPriceShown,setupVersion:c.version,variantsGroupSeperator:c.variantsGroupSeperator}},g=n.getTranslations(c,e,t,u,p);u=g.offer,p=g.widget;let f=[];if(t.boughtTogether.offeredProducts.products&&t.boughtTogether.offeredProducts.products.length&&t.boughtTogether.offeredProducts.products.forEach((e=>{f.push(e.handle)})),"popup-cart-addons"===t.upsellType&&u.discounts&&Number(u.discounts.minimumCartAmount)>0){const e=n.getPresentmentCurrency();let t=100*Number(u.discounts.minimumCartAmount)*Number(e&&e.rate||1);t>i.total_price&&(n.ppaLog(`Discounts will not be shown due to minimumCartAmount cond. minimumCartAmount - ${t}, cart total - ${i.total_price}`),u.discounts=void 0)}let m=[];t.boughtTogether.shopifyProductRecommendations&&t.boughtTogether.shopifyProductRecommendations.isEnabled?m.push(r.getShopifyProductRecomendation(s.id,t.boughtTogether.shopifyProductRecommendations.limit)):m.push(n.getProducts(f)),Promise.all(m).then((o=>{let i;n.ppaLog("--------Processing best offer --------"),t.boughtTogether.shopifyProductRecommendations&&t.boughtTogether.shopifyProductRecommendations.isEnabled?(i=o&&o[0].products&&o[0].products.length?[s,...o[0].products]:[s],u.discounts={...t.discounts,discountType:"byProducts"},i.forEach((e=>{e.productId=e.id,t.discounts&&t.discounts.isEnabled&&t.discounts.value>0&&(e.discount={type:t.discounts.type,value:t.discounts.value})}))):i=o&&o[0].length?o[0]:[];let r=n.filterProducts(i,e);n.ppaLog("Filtered Products based on product/variant availablity & image:",r);let a=t.boughtTogether.shopifyProductRecommendations&&t.boughtTogether.shopifyProductRecommendations.isEnabled?JSON.parse(JSON.stringify(o[0].products)):JSON.parse(JSON.stringify(t.boughtTogether.offeredProducts.products));a=n.getBoughtProductsRandomSortOrder(a,t.isSortedRandomly),a.sort(((e,t)=>e.sortNo-t.sortNo));let c=t.boughtTogether.shopifyProductRecommendations&&t.boughtTogether.shopifyProductRecommendations.isEnabled?t.discounts&&t.discounts.isEnabled&&t.discounts.value>0:t.tpaeDiscounts&&t.tpaeDiscounts.isEnabled&&"byProducts"===t.tpaeDiscounts.discountType&&e.type;a=n.mapAvailableProducts(a,r,t.for.selectorType,void 0,c,d),a=n.removeExtraItems(a,e.maxItemsInOffer),u.boughtTogether=a,p.metadata.presentmentCurrency=n.getPresentmentCurrency(),p.addToCartAction=e.addToCartAction,p.layoutStyle=e.layoutStyle||"singleProductSlider",p.addActionStyle=e.addActionStyle||"button",p.productClickActionStyle=e.productClickActionStyle||"popup",l({widget:p,offer:{for:t.for,boughtTogether:u.boughtTogether,overrideWidgeTitle:u.overrideWidgeTitle,discounts:u.discounts}})})).catch((e=>{n.ppaLog("Error while getProducts",e),a(e)}))}))},getApplicableOffer:function(e,t,o){return new Promise(((i,r)=>{let s=e.offers&&e.offers.length?JSON.parse(JSON.stringify(e.offers.filter((e=>o.some((t=>t===e.upsellType)))))):[],l=[];if(s&&s.length&&t&&t.items){let e=[],a=[];t.items.forEach((t=>{a.push({productId:t.product_id,variantId:t.variant_id}),e.push(t.handle)})),(o.includes("tq-page-upsell")?Promise.resolve(t.items):n.getProducts(e)).then((e=>{d=e&&JSON.parse(JSON.stringify(e)),e.forEach((t=>{let o=s.filter((o=>{let n=o.for.triggerConditions||[];return!(n.length>0&&n.some((t=>"productExclusion"===t.type&&t.products&&t.products.length&&t.products.some((t=>e.some((e=>t.productId===`${e.id}`)))))))&&!l.some((e=>e.recordType===o.recordType))&&("products"===o.for.selectorType?o.for.products.some((e=>o.for.isVariantsSelection&&e.limitVariants?e.productId===`${t.id}`&&e.limitVariants.some((e=>e.id===`${a.filter((e=>e.productId===t.id))[0].variantId}`)):e.productId===`${t.id}`)):"tags"===o.for.selectorType&&t.tags&&t.tags.length?o.for.products.some((e=>t.tags.some((t=>(t||"").toLowerCase()===(e.name||"").toLowerCase())))):"all"===o.for.selectorType||void 0)}));o.length&&l.push(...o)})),n.upsellFunnelLog("applicableOffers:",l),l.length?i(n.sortByPriorityAndLatestOffer(l)[0]):i(void 0)})).catch((e=>{console.log("Err while getApplicableOffer:",e),r("Error while fetching products",e)}))}else i(void 0)}))},getOrderQueryResponse:function(e,t=void 0){return new Promise(((o,i)=>{let r=`${n.getHostName()}/order`+(t?`/${t}`:""),d=new XMLHttpRequest;d.open("POST",r,!0),d.setRequestHeader("Content-Type","application/json; charset=UTF-8"),d.setRequestHeader("Access-Control-Allow-Origin","*"),d.send(JSON.stringify(e)),d.onload=()=>{n.log("tqOrderReq.responseText",d.responseText),200===d.status?o(JSON.parse(d.responseText)):i(`Error while ${t} parsing`)},d.onerror=()=>{i(`Error while ${t}`)}}))},getleastPricedTriggerItem:function(e,t){let o;if(e.item_count&&t.for)if("products"===t.for.selectorType&&t.for.products&&t.for.products.length)e.items.forEach((e=>{t.for.products.some((t=>`${t.productId}`==`${e.product_id}`))&&(o&&e.line_price<o.line_price||void 0===o)&&(o=e)}));else if("tags"===t.for.selectorType&&t.for.products&&t.for.products.length&&s.getCartItems()&&s.getCartItems().length){let n=s.getCartItems().filter((e=>e.tags&&e.tags.length&&e.tags.some((e=>t.for.products.some((t=>t.name===e))))));n&&n.length&&n.forEach((t=>{let n=e.items.find((e=>`${e.product_id}`==`${t.id}`));n&&(o&&n.line_price<o.line_price||void 0===o)&&(o=n)}))}else"all"===t.for.selectorType&&e.items.forEach((e=>{(o&&e.line_price<o.line_price||void 0===o)&&(o=e)}));return o&&{id:o.id,quantity:o.quantity,variant_id:o.variant_id,title:o.title,line_price:o.line_price,product_title:o.product_title,product_id:o.product_id}},prerenderCartOffer:function(){if(n.isPrerenderingDisabled)n.log("Pre rendering diabled");else{let e,t=n.getSetup(),o=n.getWidgetSetup(t,"popup-cart-addons-widget");t.offers&&t.offers.length&&t.offers.some((e=>"popup-cart-addons"===e.upsellType))&&o&&o.isEnabled?n.getCart(window.location.hostname).then((r=>{if(n.log("prerenderCartOffer is Running"),r.item_count){let n=i.getDiscountFromStorage();!(n&&i.isDiscountValid(r,n))||n.code.includes("FUNDLL")||n.code.includes("CADDLL")||(e=!0),s.getApplicableOffer(t,r,["checkout-funnel","popup-cart-addons"]).then((t=>{t&&"popup-cart-addons"===t.upsellType&&o.isEnabled&&s.getFormattedWidgetInput(o,t,!e,r).then((e=>{localStorage.setItem("lb-upsell-cart-prerendered-data",JSON.stringify({widgetInput:e,setupOffer:t,expiry:new Date((new Date).getTime()+6e5).getTime()}))}))}))}})):n.isSnippetTesting()&&n.getCart(window.location.hostname).then((e=>{e.items[0].id=e.items[0].product_id,e.items[0].available=!0,r.showShopifyProductRecommendations(e.items[0],o).then((e=>{e.widget.isMultipleVariantsAdded=!0,n.ppaLog("Final offer input to wiget",e.offer),n.ppaLog("wiget settings",e.widget),n.ppaLog(JSON.stringify(e)),n.ppaLog("---------------"),localStorage.setItem("lb-upsell-cart-prerendered-data",JSON.stringify({widgetInput:e,setupOffer:{upsellType:"popup-cart-addons"}}))}))}))}},getPrerenderedData:function(){let e=localStorage.getItem("lb-upsell-cart-prerendered-data");return e&&(e=JSON.parse(e),(new Date).getTime()>e.expiry&&(localStorage.removeItem("lb-upsell-cart-prerendered-data"),e=void 0)),e},getFormattedTpaeOffer:function(e,t){return{boughtTogether:{offeredProducts:{products:e.map(((e,o)=>({discount:t,handle:e.handle,id:`gid://shopify/Product/${e.id}`,productId:`${e.id}`,sortNo:o+1,title:e.title})))}},for:{products:[],selectorType:"all"}}}}},903:(e,t,o)=>{const n=o(980),i=o(645),r=o(276),d=o(693);let s,l,a,c,u,p;e.exports={pcaWidgetLib:function(){let e={};function t(e,t){if(t.version>=15){let e=document.createElement("lb-upsell-addon-popup");document.body.append(e)}let o=document.querySelector("lb-upsell-addon-popup");if(o){o.renderAddonPopup(a),function(){let e=document.querySelector("lb-upsell-addon-popup");e&&e.addEventListener("pcaContinueClicked",(function(e){n.ppaLog("event",e.detail),e.detail.addedItems&&e.detail.addedItems.length?function(e,t,o){n.isPrerenderingDisabled=!0;let g={items:e.map((e=>({id:e.selectedVariantId,quantity:e.quantity||1})))};n.addItemsToCart(g).then((f=>{let m=n.getSetup(),h=a.offer.boughtTogether&&a.offer.boughtTogether.map((e=>e.id)),w=d.getleastPricedTriggerItem(s,c);r.pushEvent("offer-clicked",h,c.recordType,c,m,n.getWidgetSetup(m,"popup-cart-addons-widget"),!1,w,g.items);let b=[];if(t>0){let r=n.getSetup();b.push(i.getDiscountCode(r.myShopifyDomain,e,o,t,void 0,"popup-cart-addons-widget",c&&c.recordType))}else b.push(Promise.resolve(!0));Promise.all(b).then((o=>{let r=t>0&&o&&o[0]?o[0]:void 0;r&&r.code&&(r.endsAt=new Date((new Date).getTime()+6e4*(m.customDiscountEndTimeInMins||30)).getTime(),i.saveDiscountToStorage("popup-cart-addons-widget",e,r,void 0,w,a.offer.discounts.minimumCartAmount),i.addDiscountCodeToAllCartForms(!0,n.getCartForms(),r)),n.triggerCustomEvent({widgetType:"product-cart-addons-widget",discount:r}),n.ppaLog("addToCartReq status:",`${f}`),d.proceedToCheckout(e,r,l,p,"popup-cart-addons-widget",u,s)})).catch((t=>{n.ppaLog("Error while creating discount code.",t),n.triggerCustomEvent({widgetType:"product-cart-addons-widget",discount:{}}),n.ppaLog("addToCartReq status:",`${f}`),d.proceedToCheckout(e,void 0,l,p,"popup-cart-addons-widget",u,s)}))})).catch((e=>{n.ppaLog("Error - ppa widget addAllItemsToCart add to cart",e),d.proceedToCheckout(void 0,void 0,l,p,"popup-cart-addons-widget",u,s)}))}(e.detail.addedItems,e.detail.totalWithoutDiscount,e.detail.discounts,e.detail.forProduct):d.proceedToCheckout(void 0,void 0,l,p,"popup-cart-addons-widget",u,s)}))}();let g=a.offer.boughtTogether&&a.offer.boughtTogether.map((e=>e.id));r.pushEvent("offer-viewed",g,c.recordType,c,t,e,!1),n.ppaLog("Widget successfully rendered")}}return e.render=function(e,o,i,r,g,f,m,h){s=o,l=i,u=g,p=f,c=m;let w=n.getWidgetSetup(e,"popup-cart-addons-widget");h?h.widgetInput.offer&&h.widgetInput.offer.boughtTogether&&h.widgetInput.offer.boughtTogether.length?(c=h.setupOffer,a={offer:h.widgetInput.offer,widget:h.widgetInput.widget},n.log("rendering widget throught pre rendered data"),t(w,e)):d.proceedToCheckout(void 0,void 0,l,p,"popup-cart-addons-widget",u,s):d.getFormattedWidgetInput(w,m,r,o).then((o=>{n.log("widgetInputData:",o),o.offer&&o.offer.boughtTogether&&o.offer.boughtTogether.length?(a=o,t(w,e),n.ppaLog("Final offer input to wiget",o.offer),n.ppaLog("wiget settings",o.widget),n.ppaLog(JSON.stringify(o))):d.proceedToCheckout(void 0,void 0,l,p,"popup-cart-addons-widget",u,s)})).catch((e=>{n.log("Proceed to checkout",e),d.proceedToCheckout(void 0,void 0,l,p,"popup-cart-addons-widget",u,s)}))},e}}},380:(e,t,o)=>{const n=o(980),i=o(645),r=o(276),d=o(693);let s,l,a,c,u,p,g,f,m=e.exports={pufWidgetLib:function(){let e={};function t(e,t,o,i){if(e){let r=JSON.parse(JSON.stringify(e));return r.variants=r.variants.filter((e=>i&&i.length?e.available&&i.some((t=>t.id===`${e.id}`)):e.available)),r.available&&n.isImgAvailable(r)&&r.variants&&r.variants.length&&!function(e,t,o){return!(o&&o.isWindowRedirectUsedForCheckout&&"products"===t.for.selectorType&&t.for.products.some((t=>t.handle===decodeURI(e.handle))))&&e.variants.some((e=>l.items.some((t=>`${t.id}`==`${e.id}`))))}(e,t,o)?r:void 0}}function o(e,t){d.proceedToCheckout(e,t,a,f,"popup-upsell-funnel-widget",g,l)}function h(e,t){if(c=e,u=t,n.upsellFunnelLog("widgetInput:",JSON.stringify(e)),n.upsellFunnelLog("Rendering widget"),s.version>=15){let e=document.createElement("lb-upsell-modal");document.body.append(e)}let a=document.querySelector("lb-upsell-modal");a?(a.renderModal(e),function(e){e.addEventListener("upsellFunnelAddToCart",(function(e){e.detail&&e.detail&&(n.upsellFunnelLog("event.detail:",e.detail),function(e,t,a,g,f){n.isPrerenderingDisabled=!0;let m=n.getPresentmentCurrency();var h;(h=e,new Promise(((e,t)=>{if(!h)return e(200);p=!0;let o={items:[{id:h.selectedVariantId,quantity:h.quantity}]};n.addItemsToCart(o).then((()=>{e(200)})).catch((t=>{e(t),console.log("Error while adding to cart",err)}))}))).then((p=>{let h=document.querySelector("lb-upsell-modal");if(200===p)if(f){if(n.upsellFunnelLog("Upsell funnel ended"),t&&t.length){let e=d.getleastPricedTriggerItem(l,u),t=c.upsellFunnel.offers.map((e=>e.offeredProduct&&e.offeredProduct.id||e.declinedOffer&&e.declinedOffer.offeredProduct&&e.declinedOffer.offeredProduct.id));r.pushEvent("offer-clicked",t,u.recordType,u,s,n.getWidgetSetup(s,"popup-upsell-funnel-widget"),!1,e)}if(a&&t&&t.length){let e=t.filter((e=>l.items.some((t=>`${t.id}`==`${e.selectedVariantId}`))));e&&e.length&&e.forEach((e=>{g+=Math.floor(Number(n.formatPrice(e.selectedVariantPrice/Number(m&&m.rate||1),!1)||0))})),i.getDiscountCode(s.myShopifyDomain,t,c.upsellFunnel.discounts,g,void 0,"popup-upsell-funnel-widget",u&&u.recordType).then((e=>{if(e&&e.code){e.endsAt=new Date((new Date).getTime()+6e4*(s.customDiscountEndTimeInMins||30)).getTime();let r=d.getleastPricedTriggerItem(l,u);i.saveDiscountToStorage("popup-upsell-funnel-widget",t,e,void 0,r,c.upsellFunnel.discounts.minimumCartAmount),i.addDiscountCodeToAllCartForms(!0,n.getCartForms(),e),o(t,e)}else o(t)})).catch((()=>{o(t)}))}else o(t)}else h.handleAddToCart(!0,p);else 422===p?(w=[{id:e.selectedVariantId}],new Promise(((e,t)=>{let o=new XMLHttpRequest;o.open("POST",`${n.getHostName()}/inventory`,!0),o.setRequestHeader("Content-Type","application/json; charset=UTF-8"),o.send(JSON.stringify({myShopifyDomain:s.myShopifyDomain,variants:w})),o.onload=function(){200===o.status?e(JSON.parse(o.responseText)):t(o.status)},o.onerror=e=>{n.upsellFunnelLog("Error while adding items to cart",e)}}))).then((t=>{if(t.productVariantInventory&&Object.keys(t.productVariantInventory).length){let o;const n=t.productVariantInventory[e.selectedVariantId];n&&"DENY"===n.inventoryPolicy&&n.tracked&&Number(e.quantity)>=Number(n.available)&&(o=Number(n.available)),h.handleAddToCart(!1,p,o)}})).catch((e=>{console.log("Error while fetching inventory data",e),o()})):(console.log("Unknown error while adding items to cart.",p),o());var w}))}(e.detail.acceptedProduct,e.detail.acceptedProducts,e.detail.discounts,e.detail.totalWithoutDiscount,e.detail.isUpsellFunnelEnded))}))}(a)):(n.upsellFunnelLog("pufWidget not found"),o());let g=e.upsellFunnel.offers.map((e=>e.offeredProduct&&e.offeredProduct.id));r.pushEvent("offer-viewed",g,t.recordType,t,s,n.getWidgetSetup(s,"popup-upsell-funnel-widget"),!1),n.upsellFunnelLog("Widget successfully rendered")}return e.getPreRenderedWidgetInput=function(){let e=localStorage.getItem("lb-upsell-prerendered-data");return e=e?JSON.parse(e):void 0,e},e.initiateOffer=function(e,i,r,d,a){p?n.upsellFunnelLog("Ignoring as addtocart req is forced"):(n.upsellFunnelLog("Best offer:",a),function(e,o,i){return new Promise(((r,d)=>{let a=n.getPresentmentCurrency(),c=i&&o.upsellFunnel.discounts&&o.upsellFunnel.discounts.isEnabled&&o.upsellFunnel.discounts;if(c&&Number(c.minimumCartAmount)>0){let e=100*Number(c.minimumCartAmount)*Number(a&&a.rate||1);e>l.total_price&&(n.upsellFunnelLog(`Discounts will not be shown due to minimumCartAmount cond. minimumCartAmount - ${e}, cart total - ${l.total_price}`),c=void 0)}let u={offers:[],discounts:c,overrideWidgeTitle:o.overrideWidgeTitle},p={styles:e.styles,content:e.content,imageResolution:e.imageResolution,isQtyPickerHidden:e.isQtyPickerHidden,metadata:{isAmountNoDecimals:s&&s.isAmountNoDecimals,shopMoneyInEmailsFormat:s&&s.shopMoneyInEmailsFormat,shopCurrencyCode:s&&s.shopCurrencyCode,presentmentCurrency:a,isUnitPriceShown:s&&s.isUnitPriceShown,setupVersion:s.version,variantsGroupSeperator:s.variantsGroupSeperator}};if(s.shopLocales&&s.shopLocales.length>1){n.upsellFunnelLog("Checking shoplocale");const t=n.getCurrentLocale(),i=s.shopLocales.find((e=>e.primary));if(i&&i.locale!==t&&e.translations&&e.translations[t]){n.upsellFunnelLog("Replacing primaery locale");const o=p.content.countDownTimerMins&&JSON.parse(JSON.stringify(p.content.countDownTimerMins)),i=p.content.countDownTimerSecs&&JSON.parse(JSON.stringify(p.content.countDownTimerSecs));n.upsellFunnelLog("countDownTimerMins",o),p.content=e.translations[t],p.content.countDownTimerMins=o,p.content.countDownTimerSecs=i,n.upsellFunnelLog("formattedWidget.content",p.content)}if(o.upsellFunnel.offers&&o.upsellFunnel.offers.length&&o.translations&&o.translations[t]&&(o.translations[t].name&&(o.upsellFunnel.offers[0].name=o.translations[t].name),o.translations[t].discountTitle&&(o.upsellFunnel.offers[0].discountTitle=o.translations[t].discountTitle),o.translations[t].customDescription&&(o.upsellFunnel.offers[0].customDescription=o.translations[t].customDescription),o.upsellFunnel.offers.length>1))for(let e=1;e<=o.upsellFunnel.offers.length;e++)o.upsellFunnel.offers[e]&&(o.translations[t][`name-${e+1}a`]&&(o.upsellFunnel.offers[e].name=o.translations[t][`name-${e+1}a`]),o.translations[t][`discountTitle-${e+1}a`]&&(o.upsellFunnel.offers[e].discountTitle=o.translations[t][`discountTitle-${e+1}a`]),o.translations[t][`customDescription-${e+1}a`]&&(o.upsellFunnel.offers[e].customDescription=o.translations[t][`customDescription-${e+1}a`]),o.upsellFunnel.offers[e].declinedOffer&&(o.translations[t][`name-${e+1}b`]&&(o.upsellFunnel.offers[e].declinedOffer.name=o.translations[t][`name-${e+1}b`]),o.translations[t][`discountTitle-${e+1}b`]&&(o.upsellFunnel.offers[e].declinedOffer.discountTitle=o.translations[t][`discountTitle-${e+1}b`]),o.translations[t][`customDescription-${e+1}b`]&&(o.upsellFunnel.offers[e].declinedOffer.customDescription=o.translations[t][`customDescription-${e+1}b`])))}let g=[];o.upsellFunnel.offers.forEach((e=>{e.offeredProduct&&e.offeredProduct.handle&&!g.some((t=>t===e.offeredProduct.handle))&&g.push(e.offeredProduct.handle),e.declinedOffer&&e.declinedOffer.offeredProduct&&!g.some((t=>t===e.declinedOffer.offeredProduct.handle))&&g.push(e.declinedOffer.offeredProduct.handle)})),n.getProducts(g).then((n=>{let i=o.upsellFunnel.offers&&o.upsellFunnel.offers.length&&o.upsellFunnel.offers[0]&&o.upsellFunnel.offers[0].isVariantsSelection;JSON.parse(JSON.stringify(o)).upsellFunnel.offers.forEach((r=>{r.offeredProduct&&(r.offeredProduct=t(n.find((e=>`${e.id}`===r.offeredProduct.productId)),o,e,i&&r.offeredProduct.limitVariants)),r.declinedOffer&&r.declinedOffer.offeredProduct&&(r.declinedOffer.offeredProduct=t(n.find((e=>`${e.id}`===r.declinedOffer.offeredProduct.productId)),o,e,i&&r.declinedOffer.offeredProduct.limitVariants)),(r.offeredProduct||r.declinedOffer&&r.declinedOffer.offeredProduct)&&(0===u.offers.length?r.offeredProduct&&u.offers.push(r):u.offers.push(r))})),r({widget:p,upsellFunnel:u})})).catch((e=>{console.log("Err while get products",e),d(e)}))}))}(n.getWidgetSetup(e,"popup-upsell-funnel-widget"),a,r).then((e=>{n.log("widgetInput:",e),e.upsellFunnel&&e.upsellFunnel.offers[0]&&e.upsellFunnel.offers[0].offeredProduct&&e.widget?d?h(e,a):(n.upsellFunnelLog("Widget input"),n.upsellFunnelLog(JSON.stringify(e)),function(e,t){localStorage.setItem("lb-upsell-prerendered-data",JSON.stringify({widgetInput:e,setupOffer:t}))}(e,a)):(n.upsellFunnelLog("Coudn't find offer"),d&&(n.upsellFunnelLog("Proceeding to checkout"),o()))})).catch((e=>{console.log("Error while getFormattedWidgetInput",e),o()})))},e.render=function(e,t,o,i,r,d,c){s=e,l=t,a=o,g=r,f=d,n.upsellFunnelLog("Puf render called,","isDiscountShown:",i);let u=m.pufWidgetLib().getPreRenderedWidgetInput();n.upsellFunnelLog("preRenderedData",u),u?(n.upsellFunnelLog("Rendeering widget with prerendered widgetInput"),h(u.widgetInput,u.setupOffer)):(n.upsellFunnelLog("No prerendered widgetInput found, initating offer."),m.pufWidgetLib().initiateOffer(e,t,i,!0,c))},e}}},305:(e,t,o)=>{const n=o(980),i=o(693),r=o(276),d=o(460);let s,l,a,c,u,p,g,f;e.exports={TpaeWidgetLib:function(){let e={};function t(e){let t=n.getWidgetSetup(a,"tq-page-addon-embedded-widget"),o=c.offer.boughtTogether&&c.offer.boughtTogether.map((e=>e.id));r.pushEvent(e,o,l.isRecommendationOffer?g&&g.product_id:l.recordType,l,a,t,l.isRecommendationOffer,g,f)}function o(){return window.innerWidth<=768}function m(e,r,d){let a=i.getleastPricedTriggerItem(d,l);i.getFormattedWidgetInput(e,r,void 0,void 0,a).then((r=>{n.ppaLog("Tpae - widget input:",r),c=r,r.offer&&r.offer.boughtTogether&&r.offer.boughtTogether.length?(n.ppaLog("---------------"),function(e,r){n.removeExistingWidget("lb-tq-page-upsell");let d=o()?r.position.mobile.selector:r.position.desktop.selector,a=o()?r.position.mobile.insertPosition:r.position.desktop.insertPosition;n.ppaLog("----------Positioning widget----------"),function(e,o,r,d){n.ppaLog("added widget to custom selector");let a=document.querySelector(e);if(a){a.insertAdjacentHTML(o,"<lb-tq-page-upsell> \n </lb-tq-page-upsell>\n");let c=document.querySelector("lb-tq-page-upsell");c?(c.widget=r.widget,c.offer=r.offer,n.ppaLog(`Widget successfully added to selector , ${e}`),function(e,o){e.addEventListener("tqaeOrderClicked",(function(e){n.ppaLog("emited events",e,e.detail),f=e.detail.products,t("offer-clicked"),i.getOrderQueryResponse({order:e.detail,myShopifyDomain:s,customerId:p&&p.customer_id,orderId:u,recordType:l.recordType},o.orderType).then((e=>{"editOrder"===o.orderType?window.location.reload():(window.open(e.url,o.orderRedirectAction&&"redirect_same_tab"===o.orderRedirectAction||!o.orderRedirectAction?"_self":"_blank").focus(),n.removeExistingWidget("lb-tq-page-upsell"))})).catch((e=>{n.ppaLog("Error while getting draft order",e)}))})),e.addEventListener("tqaeModalProductClicked",(function(e){n.ppaLog("emited events",e,e.detail),t("offer-clicked")})),e.addEventListener("tqaeOfferExpired",(function(e){let t=document.querySelector(".lb-tpae-confirm-button");t?t.click():n.removeExistingWidget("lb-tq-page-upsell"),localStorage.setItem("lb-upsell-Tpae-Expired",!0)}))}(c,d)):n.ppaLog("tpaeWidget not found"),t("offer-viewed")}else n.ppaLog(`Could not find selector, ${e}`)}(d,a,e,r);let c=document.querySelector(".step__footer__continue-btn");c&&n.setBtnCSS(c,!0)}(r,e)):(n.ppaLog("Not enough products to position widgets"),n.ppaLog("---------------"))})).catch((e=>{n.ppaLog("Error while getFormattedWidgetInput",e)}))}function h(e,t){let o=Number(e.maxItemsInOffer)>0?e.maxItemsInOffer:2,r=i.getleastPricedTriggerItem(t,{for:{selectorType:"all"}});g=r,d.getShopifyProductRecomendation(r.product_id,o).then((t=>{if(n.log("ProductRecommendations result:",t),t.products.length>0){let o;e.useShopifyProductRecommendations&&e.recommendationDiscount&&e.recommendationDiscount.isEnabled&&(o=e.recommendationDiscount);let n=i.getFormattedTpaeOffer(t.products,o);n.tpaeDiscounts={isEnabled:e.useShopifyProductRecommendations,discountType:"byProducts"},l=n,l.isRecommendationOffer=!0,m(e,n)}}))}function w(){return a&&a.offers&&a.offers.length&&a.offers.some((e=>"tq-page-upsell"===e.upsellType))}return e.render=function(e){s=e.myShopifyDomain,a=e,p=function(){let e=window.Shopify&&window.Shopify.checkout||{};return e&&e.line_items&&e.line_items.length&&e.line_items.forEach((e=>{e.id=e.product_id})),e}();let t=n.getWidgetSetup(a,"tq-page-addon-embedded-widget");i.isThankyouPage()&&(n.ppaLog("thankyou page found"),(t.useShopifyProductRecommendations||w())&&new Promise(((e,t)=>{i.getOrderQueryResponse({myShopifyDomain:s,orderId:p.order_id}).then((t=>{let o=t.products;u=t.orderNumber,o&&o.length>0&&!function(e){return e&&e.orderTags&&e.orderTags.length&&e.orderTags.some((e=>e.includes("lb-upsell-parent-order")))}(t)?e({items:o,item_count:o&&o.length}):e(void 0)})).catch((e=>{n.ppaLog("Error while getting order",e),t("Error while getting current Order")}))})).then((e=>{e?w()?i.getApplicableOffer(a,e,["tq-page-upsell"]).then((o=>{n.ppaLog("Best offer:",o),o?(l=o,m(t,o,e)):(n.ppaLog("Coudn't find Tpae offer"),t.useShopifyProductRecommendations&&h(t,e))})).catch((e=>{n.ppaLog("Error while finding Tpae offer",e)})):(n.ppaLog("No offers found"),t.useShopifyProductRecommendations&&h(t,e)):n.ppaLog("upsold order found, so tpae not rendered")})).catch((e=>{n.ppaLog("Offer not rendered. error while getting current order.",e)})))},e}}},226:(e,t,o)=>{const n=o(980),i=o(645);let r=e.exports={isCartUpdateNotRequired:function(){if(void 0!==window.lbUpsellComponents)return window.lbUpsellComponents.isCartUpdateNotRequired},isCartUpdateForced:function(){if(void 0!==window.lbUpsellComponents)return window.lbUpsellComponents.isCartUpdateForced},addCartUpdateListener:function(){window.addEventListener("lb-upsell-added",(function(e){if(n.log("Cart update listener added"),(e.detail&&"ajax"===e.detail.currentAddToCartActionSetup&&"product-page-addon-widget"===e.detail.widgetType||r.isCartUpdateForced())&&!r.isCartUpdateNotRequired()){if(n.log("Updating cart from cart update listener"),"function"==typeof window.SLIDECART_UPDATE)try{window.SLIDECART_UPDATE()}catch(e){console.log("Error while updating cart",e)}if(void 0!==window.theme&&void 0!==window.theme.ajaxCart&&"function"==typeof window.theme.ajaxCart.update)try{window.theme.ajaxCart.update()}catch(e){console.log("Error while updating cart",e)}if("function"==typeof window.icartCartActivityEvent)try{window.icartCartActivityEvent()}catch(e){console.log("Error while updating cart",e)}try{document.dispatchEvent(new CustomEvent("cart:refresh"))}catch(e){console.log("Error while updating cart",e)}try{document.documentElement.dispatchEvent(new CustomEvent("cart:refresh",{bubbles:!0}))}catch(e){console.log("Error while updating cart",e)}if(void 0!==window.HsCartDrawer&&"function"==typeof window.HsCartDrawer.updateSlideCart&&globalDebounce("hscartdrawer",(function(){try{HsCartDrawer.updateSlideCart()}catch(e){console.log("Error while updating cart",e)}}),100),void 0!==window.HS_SLIDE_CART_OPEN&&"function"==typeof window.HS_SLIDE_CART_OPEN&&globalDebounce("hscartdraweropen",(function(){try{window.HS_SLIDE_CART_OPEN()}catch(e){console.log("Error while updating cart",e)}}),100),"undefined"!=typeof theme&&void 0!==theme.Cart&&"function"==typeof theme.Cart.updateCart)try{theme.Cart.updateCart()}catch(e){console.log("Error while updating cart",e)}if("function"==typeof window.updateMiniCartContents)try{window.updateMiniCartContents()}catch(e){console.log("Error while updating cart",e)}if("function"==typeof window.loadEgCartDrawer)try{window.loadEgCartDrawer()}catch(e){console.log("Error while updating cart",e)}try{document.dispatchEvent(new CustomEvent("cart:build"))}catch(e){console.log("Error while updating cart",e)}try{document.dispatchEvent(new CustomEvent("cart:open"))}catch(e){console.log("Error while updating cart",e)}try{document.documentElement.dispatchEvent(new CustomEvent("product:added",{bubbles:!0,detail:{source:"lb-upsell",quantity:"remove"==e.detail.addToCartAction?-1:1}}))}catch(e){console.log("Error while updating cart",e)}try{void 0!==window.cart&&void 0!==window.cart.getCart&&void 0!==window.cart.openCartDropdown&&(window.cart.getCart(),window.cart.openCartDropdown())}catch(e){console.log("Error while updating cart",e)}try{void 0!==window.ajaxCart&&window.ajaxCart.load()}catch(e){console.log("Error while updating cart",e)}try{document.dispatchEvent(new CustomEvent("obsidian:upsell:refresh")),document.dispatchEvent(new CustomEvent("obsidian:upsell:open"))}catch(e){console.log("Error while updating cart",e)}var t=document.getElementById("site-cart");if(null!==t)try{t.show()}catch(e){console.log("Error while updating cart",e)}if("undefined"!=typeof CartJS&&"function"==typeof CartJS.getCart)try{CartJS.getCart()}catch(e){console.log("Error while updating cart",e)}if(void 0!==window.SLIDECART_UPDATE)try{window.SLIDECART_UPDATE()}catch(e){console.log("Error while updating cart",e)}if(void 0!==window.SLIDECART_OPEN&&setTimeout((function(){try{window.SLIDECART_OPEN()}catch(e){console.log("Error while updating cart",e)}}),500),"undefined"!=typeof Shopify&&void 0!==Shopify.theme&&void 0!==Shopify.theme.jsAjaxCart&&"function"==typeof Shopify.theme.jsAjaxCart.updateView)try{Shopify.theme.jsAjaxCart.updateView()}catch(e){console.log("Error while updating cart",e)}if(void 0!==window.theme&&void 0!==window.theme.MiniCart&&"function"==typeof window.theme.MiniCart.update)try{theme.MiniCart.update()}catch(e){console.log("Error while updating cart",e)}if(void 0!==window.openCart&&void 0!==window.monster_setCartItems)try{fetch("/cart.js").then((function(e){return e.json()})).then((function(e){window.openCart(),window.monster_setCartItems(e.items)}))}catch(e){console.error(e)}if(void 0!==window.Shopify&&void 0!==window.Shopify.onCartUpdate)try{window.Shopify.onCartUpdate()}catch(e){console.error(e)}try{var o=document.querySelector("cart-notification")||document.querySelector("cart-drawer");null!==o&&"function"==typeof o.renderContents&&fetch("/cart?sections=cart-notification-product,cart-notification-button,cart-icon-bubble",{method:"GET",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"}}).then((function(e){try{return e.clone().json().then((function(e){fetch("/cart.js").then((function(e){return e.json()})).then((function(t){try{if(t&&t.item_count){var n={sections:e,key:t.items[0]&&t.items[0].key};o.renderContents(n)}else{const e=document.querySelector(".cart-count-bubble");e&&e.remove()}}catch(e){console.error(e)}}))}))}catch(e){console.error(e)}}))}catch(e){console.error(e)}try{window.dispatchEvent(new Event("update_cart"))}catch(e){console.log("Error while updating cart",e)}}n.getCart(window.location.hostname).then((e=>{i.process(n.getSetup(),e)}))}))}}},993:(module,__unused_webpack_exports,__webpack_require__)=>{const utils=__webpack_require__(980),discounts=__webpack_require__(645),pufWidget=__webpack_require__(380),pcaWidget=__webpack_require__(903),cartPageUtils=__webpack_require__(693);let _checkoutHandler=module.exports={registerListeners:function(e,t){let o=utils.getSetup(),n=utils.getWidgetSetup(o,"popup-upsell-funnel-widget"),i=utils.getWidgetSetup(o,"product-page-cross-sell-embedded-widget"),r=utils.getWidgetSetup(o,"product-page-addon-widget"),d=utils.getWidgetSetup(o,"popup-cart-addons-widget"),s=discounts.getDiscountFromStorage();if(i&&i.isEnabled||n&&n.isEnabled||r&&r.isEnabled||d&&d.isEnabled||s)if(e&&t){let e=t.querySelectorAll(o.checkoutBtnSelector);e.length&&utils.addCheckoutListenerToElements(e,"lb-upsell-mutation-checkout-listener",_checkoutHandler.handleCheckout),t&&t.matches&&t.matches(o.checkoutBtnSelector)&&utils.addCheckoutListenerToElements([t],"lb-upsell-mutation-checkout-listener",_checkoutHandler.handleCheckout)}else if(o.checkoutBtnSelector){let e=document.querySelectorAll(o.checkoutBtnSelector);e.length&&utils.addCheckoutListenerToElements(e,"lb-upsell-custom-checkout-listener",_checkoutHandler.handleCheckout)}else{let e=utils.getCartForms(),t=e.map((e=>e.getAttribute("id")));if(e&&e.length){if(utils.addCartSubmitClickListener(e[0],t,_checkoutHandler.handleCheckout),e.length>1){e=e.slice(1,5);for(let o of e)utils.addCartSubmitClickListener(o,t,_checkoutHandler.handleCheckout)}utils.upsellFunnelLog("Registered cart form listeners")}if(o.version>=5){let e=document.querySelectorAll('a[href="/checkout"]');utils.log("checkoutAnchors",e);for(let t=0;t<e.length;t++)"true"!==e[t].getAttribute("lb-upsell-listener")&&(e[t].setAttribute("lb-upsell-listener","true"),utils.setBtnCSS(e[t]),e[t].addEventListener?e[t].addEventListener("click",(function(o){_checkoutHandler.handleCheckout(o,e[t],void 0,!0)}),!0):e[t].attachEvent("onclick",(function(o){_checkoutHandler.handleCheckout(o,e[t],void 0,!0)}),!0))}}(n&&n.isEnabled||d&&d.isEnabled)&&window.addEventListener("pageshow",(function(e){let t=utils.getCartForms();e.persisted&&t&&t.length&&!window.lbUpsellComponents?.isBFRefreshIgnored&&(console.log("This page was restored from the bfcache so reloading manually."),window.location.reload())}))},isFormIgnored:function(cartForm){let isFormIgnored,setup=utils.getSetup();return setup&&setup.hiddenCartFormCustomJs&&(utils.log("Running hiddenCartFormCustomJs eval"),eval(setup.hiddenCartFormCustomJs)),utils.log("isFormIgnored",isFormIgnored),isFormIgnored},preventSubmit:function(e){e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopImmediatePropagation&&e.stopImmediatePropagation()},proceedToCheckout:async function(e,t,o=void 0){let n=utils.getSetup();if(e&&!t)if(window.lbUpsellComponents&&window.lbUpsellComponents.isAnchorTagUsedForCheckout||n&&n.version>14&&o&&e&&e.tagName&&"a"===e.tagName.toLowerCase()&&"/checkout"===e.getAttribute("href")){utils.upsellFunnelLog("window redirecting because of anchor tag");let e=utils.getRootRoute();window.location.href=e&&"/"!==e?`${e}cart/checkout${o?`?discount=${o.code}`:""}`:"/cart/checkout"+(o?`?discount=${o.code}`:"")}else if(utils.isCheckoutClickForced=!0,e.disabled=!1,e&&o&&o.code)if(n&&n.isDealeasyIntegrated&&window.lbDealeasy&&"function"==typeof window.lbDealeasy.applyDiscountsToCart)await window.lbDealeasy.applyDiscountsToCart([o.code],"selleasy"),e.click();else if(window.lbUpsellComponents&&window.lbUpsellComponents.isDiscountFetchPrevented)e.click();else{let t=utils.getRootRoute();fetch(`https://${window.location.hostname}${t||"/"}discount/${o.code}`).then((t=>{e.click()})).catch((t=>{utils.log("Error while fetching discount",t),e.click()}))}else e.click();if(t){const e={acceptedProducts:void 0,discount:void 0};utils.triggerCustomEvent(e,"selleasy-checkout-popup-completed")}},renderSelleasyCheckoutPopup:function(){_checkoutHandler.handleCheckout(void 0,void 0,void 0,!1,!0)},checkTAC:function(e){if(e&&e.TACSelectors&&(e.TACSelectors.cartDrawer||e.TACSelectors.cartPage)){let t=window.location.pathname.includes("/cart")?e.TACSelectors.cartPage&&document.querySelector(e.TACSelectors.cartPage):e.TACSelectors.cartDrawer&&document.querySelector(e.TACSelectors.cartDrawer);return!t||"INPUT"!==t.tagName||"checkbox"!==t.type||t.checked}return!0},handleCheckout:function(e,t,o,n,i){let r=utils.getSetup();if(_checkoutHandler.checkTAC(r))if(window.lbUpsellComponents&&window.lbUpsellComponents.isDefaultCheckoutListenerIgnored&&n)console.log("Not rendering as called by our own listeners");else{let n=discounts.getDiscountFromStorage();n||r.offers&&r.offers.length&&r.offers.some((e=>"checkout-funnel"===e.upsellType||"popup-cart-addons"))||utils.isSnippetTesting()?"undefined"==typeof handleUSCSKCheckout||handleUSCSKCheckout()?utils.isCheckoutClickForced||(utils.upsellFunnelLog("Checkout click handler called."),e&&(_checkoutHandler.preventSubmit(e),e.srcElement&&"checkout"===e.srcElement.getAttribute("name")&&(t=e.srcElement)),utils.getCart(window.location.hostname).then((e=>{discounts.validateAndFetchDiscount(e);let d,s=[];if(utils.isDiscountStacked()){const t=discounts.getStackDiscountValidationData(e);t&&t.invalidDiscountCodes&&t.invalidDiscountCodes.length?(t.invalidDiscountCodes.forEach((e=>{utils.removeStackDiscount(e),s.push(discounts.deleteDiscountCode(r.myShopifyDomain,e.priceRuleId,e.discountCodeId)),n&&e.code===n.code&&(utils.log("Deleting discount from storage",e.code),localStorage.removeItem("lb-upsell-offer-discount"))})),localStorage.setItem("lb-upsell-offer-discount-stack",JSON.stringify(t.validDiscountCodes))):s.push(Promise.resolve(!0))}else{let t=discounts.getDiscountFromStorage();const o=t&&discounts.isDiscountValid(e,t);o&&(t.code.includes("FUNDLL")||t.code.includes("CADDLL")||(d=!0),utils.upsellFunnelLog("Discount is valid, adding to form in checkoutSubmitHandler",t.code),discounts.addDiscountCodeToAllCartForms(!0,utils.getCartForms(),t)),t&&t.code&&!o?(utils.log("Discount code is not valid, calling removeDicountCodeFromAllCartForms"),discounts.removeDicountCodeFromAllCartForms(t.code),s.push(discounts.deleteDiscountCode(r.myShopifyDomain,t.priceRuleId,t.discountCodeId)),utils.log("Deleting discount from storage"),localStorage.removeItem("lb-upsell-offer-discount")):s.push(Promise.resolve(!0))}Promise.all(s).then((s=>{const l=!d||utils.isDiscountStacked();let a=utils.getWidgetSetup(r,"popup-upsell-funnel-widget"),c=utils.getWidgetSetup(r,"popup-cart-addons-widget");const u=cartPageUtils.getPrerenderedData();a&&a.isEnabled||c&&c.isEnabled?utils.isCartPage()&&u&&u.widgetInput.offer?(utils.log("prerenderedData:",u),"popup-cart-addons"===u.setupOffer.upsellType&&c&&c.isEnabled&&!_checkoutHandler.isFormIgnored(o)?pcaWidget.pcaWidgetLib().render(r,e,t,l,d,i,void 0,u):_checkoutHandler.proceedToCheckout(t,i,d&&n)):cartPageUtils.getApplicableOffer(r,e,["checkout-funnel","popup-cart-addons"]).then((s=>{utils.log("best offer:",s),s?"popup-cart-addons"===s.upsellType&&c&&c.isEnabled&&!_checkoutHandler.isFormIgnored(o)?pcaWidget.pcaWidgetLib().render(r,e,t,l,d,i,s):"checkout-funnel"===s.upsellType&&a&&a.isEnabled&&!_checkoutHandler.isFormIgnored(o)?pufWidget.pufWidgetLib().render(r,e,t,l,d,i,s):(utils.log("proceeding to checkout:",s),_checkoutHandler.proceedToCheckout(t,i,d&&n)):(utils.log("offer not found, proceeding to checkout:",s),_checkoutHandler.proceedToCheckout(t,i,d&&n))})).catch((e=>{console.log("Error while getApplicableOffer")})):(utils.log("puf/pca widget not enabled, proceeding to checkout"),_checkoutHandler.proceedToCheckout(t,i,d&&n))}))})).catch((e=>{utils.upsellFunnelLog("Error while handling checkout",e),_checkoutHandler.proceedToCheckout(t,i)}))):(console.log("Integrated app returned false"),e&&_checkoutHandler.preventSubmit(e)):(utils.upsellFunnelLog("No discount/funnel offers, so not preventing checkout btn"),_checkoutHandler.proceedToCheckout(t,i))}else console.log("Terms and condition not checked.")}}},491:e=>{e.exports={HOST_NAME:"https://upsell-app.logbase.io",IS_LOGS_REQUIRED:"false",API_VERSION:"2024-10"}},645:(e,t,o)=>{const n=o(491),i=o(980);let r,d=e.exports={getDiscountCodeQuery:function(){return"\n mutation cartDiscountCodesUpdate($id: ID!, $discountCodes:[String!]) {\n cartDiscountCodesUpdate(cartId: $id, discountCodes: $discountCodes) {\n cart {\n id\n }\n userErrors {\n field\n message\n }\n }\n }"},processStoreFrontAPI:async function(e,t,o){let i="\n query cart($id: ID!) {\n cart(id: $id) {\n id\n }\n }",s=e&&{id:e.token};o&&(i=d.getDiscountCodeQuery(),s={discountCodes:[t],id:o});var l=new XMLHttpRequest;l.open("POST",`https://${window.location.hostname}/api/${n.API_VERSION}/graphql.json`,!0),l.setRequestHeader("Content-Type","application/json; charset=UTF-8"),l.setRequestHeader("X-Shopify-Storefront-Access-Token",r.storeFrontAccessToken),l.setRequestHeader("Access-Control-Allow-Origin","*"),l.send(JSON.stringify({query:i,variables:s})),l.onload=()=>{if(200===l.status){let e=JSON.parse(l.responseText);e&&e.data&&e.data.cart&&e.data.cart.id&&d.processStoreFrontAPI(void 0,t,e.data.cart.id)}else console.log("Error while getting cart")},l.onerror=()=>{console.log("Error while getting cart")}},handleDiscountAfterClick:async function(){window.lbUpsellComponents&&void 0!==window.lbUpsellComponents.validateAndFetchDiscount&&i.getCart(window.location.hostname).then((e=>{window.lbUpsellComponents.validateAndFetchDiscount(e)})).catch((e=>{i.log("Error while fetching cart: discount",e)}))},validateAndFetchDiscount:async function(e,t=void 0,o=!1){if(r=i.getSetup(),r)try{if(!t){let o=d.getDiscountFromStorage(),n=o?d.isDiscountValid(e,o):void 0;n?t=o.code:o&&!n&&window&&(window.lbDiscountCreatedAt&&window.lbDiscountCreatedAt-(new Date).getTime()>5e3||void 0===window.lbDiscountCreatedAt)&&(d.deleteDiscountCode(r.myShopifyDomain,o.priceRuleId,o.discountCodeId),localStorage.removeItem("lb-upsell-offer-discount"))}i.log(`Validating code, ${t}.`);let n=i.getCookieValue("cart");if(t&&n)if(n=`gid://shopify/Cart/${n}`,e.token=n,r&&r.isDealeasyIntegrated&&window.lbDealeasy&&"function"==typeof window.lbDealeasy.applyDiscountsToCart)window.lbDealeasy.applyDiscountsToCart([t],"selleasy",n);else if(!window.lbUpsellComponents||!window.lbUpsellComponents.isDiscountFetchPrevented){let s=i.getRootRoute();fetch(`https://${window.location.hostname}${s||"/"}discount/${t}`),r&&r.storeFrontAccessToken&&d.processStoreFrontAPI(e,t,!!o&&n)}}catch(e){i.log("Error while processing: validateAndFetchDiscount",e)}},fetchDiscount:async function(e){let t=i.getSetup();if(t&&t.version>=15||window.lbUpsellComponents&&window.lbUpsellComponents.isDiscountFetchForced){let t=i.getCookieValue("discount_code");if(!t||t&&["FUNDLL","BUNDLL","ADDDLL","CADDLL"].some((e=>t.includes(e)))){if("function"==typeof fetch){let t=i.getRootRoute();i.log(`Fetching discount code, https://${window.location.hostname}${t||"/"}discount/${e.code}`),fetch(`https://${window.location.hostname}${t||"/"}discount/${e.code}`)}}else i.log("Existing cookie is present, so not fetching discount",t)}},getDiscountCode:function(e,t,o,n,r,d,s,l=void 0,a){return new Promise(((c,u)=>{let p=new XMLHttpRequest;"free_shipping"===o.type?(p.open("POST",`${i.getHostName()}/discounts/createShippingDiscountCode`,!0),p.setRequestHeader("Content-Type","application/json; charset=UTF-8"),p.setRequestHeader("Access-Control-Allow-Origin","*"),p.send(JSON.stringify({myShopifyDomain:e,minimumPurchaseValue:n,widgetType:d,recordType:s,triggerProduct:a}))):(p.open("POST",`${i.getHostName()}/discounts/createDiscountCode`,!0),p.setRequestHeader("Content-Type","application/json; charset=UTF-8"),p.setRequestHeader("Access-Control-Allow-Origin","*"),p.send(JSON.stringify({myShopifyDomain:e,products:t,minimumPurchaseValue:n,cheapestProduct:r,widgetType:d,recordType:s,triggerProduct:a}))),p.onload=()=>{if(i.log("discCodeReq.responseText",p.responseText),200===p.status){let e=JSON.parse(p.responseText),t=i.getSetup();if(t&&t.isDealeasyIntegrated&&window.lbDealeasy&&"function"==typeof window.lbDealeasy.applyDiscountsToCart)c(e),window.lbDealeasy.applyDiscountsToCart([e.code],"selleasy");else if(l)c(e);else{let t=i.getRootRoute();window.lbUpsellComponents&&window.lbUpsellComponents.isDiscountFetchPrevented?c(e):fetch(`https://${window.location.hostname}${t||"/"}discount/${e.code}`).then((()=>{c(e)})).catch((()=>{c(e)}))}}else u("Error while createDiscountCode")},p.onerror=()=>{u("Error while createDiscountCode")}}))},deleteDiscountCode:function(e,t,o){return new Promise(((n,r)=>{let d=new XMLHttpRequest;o?(d.open("POST",`${i.getHostName()}/discounts/deleteShippingDiscountCode`,!0),d.setRequestHeader("Content-Type","application/json; charset=UTF-8"),d.setRequestHeader("Access-Control-Allow-Origin","*"),d.send(JSON.stringify({myShopifyDomain:e,discountCodeId:o}))):(d.open("POST",`${i.getHostName()}/discounts/deleteDiscountCode`,!0),d.setRequestHeader("Content-Type","application/json; charset=UTF-8"),d.setRequestHeader("Access-Control-Allow-Origin","*"),d.send(JSON.stringify({myShopifyDomain:e,priceRuleId:t}))),d.timeout=3e3,d.onload=()=>{i.log("deleteDiscountCode responseText",d.responseText),200===d.status||console.log("Error while deleteDiscountCode",d.status),n(d.status)},d.onerror=()=>{console.log("Error while deleteDiscountCode",d.status),n(d.status)},d.ontimeout=()=>{console.log("deleteDiscountCode timeout",d.status),n(d.status)}}))},isDiscountShown:function(e,t){let o=d.getDiscountFromStorage(),n=o?d.isDiscountValid(t,o):void 0;return!o||o&&o.forProductId===e||!n},isWidgetDiscountValid:function(e,t){let o=d.getDiscountFromStorage();return o&&o.code&&o.code.includes(t)&&d.isDiscountValid(e,o)},isDiscountValid:function(e,t){let o=!0,n=(new Date).getTime();if(e&&e.item_count&&t&&t.products&&t.products.length&&n<t.endsAt){if(t.products.forEach((t=>{e.items.some((e=>`${e.id}`==`${t.selectedVariantId}`))||(o=!1)})),o&&t&&t.forProductVariants&&t.forProductVariants.length&&(o=t.forProductVariants.some((t=>e.items.some((e=>`${e.id}`==`${t}`))))),o&&t&&t.leastPricedTriggerItem){const n=e.items.filter((e=>`${e.product_id}`==`${t.leastPricedTriggerItem.product_id}`));if(n&&n.length){let e=t.products.find((e=>`${e.id}`==`${n[0].product_id}`));e&&(i.log("triggerItemInOfferedProduct check",n[0].quantity>e.quantity),o=n.length>1||n[0].quantity>e.quantity)}else i.log("For product is not in cart, so discount is not valid,"),o=!1}o&&t&&t.minimumCartAmount&&Number(t.minimumCartAmount)>0&&Number(t.minimumCartAmount)>Number(e.items_subtotal_price/100)&&(i.log("cart subtotal is less than minimumCartAmount, so discount is not valid",t.minimumCartAmount),o=!1)}else o=!1;return o},saveDiscountToStorage:function(e,t,o,n,r,s){const l={products:t,code:o.code,priceRuleId:o.priceRuleId,discountCodeId:o.discountCodeId,endsAt:o.endsAt,forProductId:e,forProductVariants:n,leastPricedTriggerItem:r,minimumCartAmount:s};window&&(window.lbDiscountCreatedAt=(new Date).getTime()),localStorage.setItem("lb-upsell-offer-discount",JSON.stringify(l)),d.saveStackDiscountToStorage(l),i.applyStackDiscount(l)},getDiscountFromStorage:function(){let e=localStorage.getItem("lb-upsell-offer-discount");return e?JSON.parse(e):void 0},saveStackDiscountToStorage:function(e){if(i.isDiscountStacked()){let t=d.getStackDiscountFromStorage();t.push(e),localStorage.setItem("lb-upsell-offer-discount-stack",JSON.stringify(t))}},getStackDiscountFromStorage:function(){const e=localStorage.getItem("lb-upsell-offer-discount-stack");return e?JSON.parse(e):[]},getStackDiscountValidationData:function(e){if(i.isDiscountStacked()){const t=d.getStackDiscountFromStorage();let o=[],n=[];return t&&t.length&&t.forEach((t=>{d.isDiscountValid(e,t)?o.push(t):n.push(t)})),i.log("validDiscountCodes",o),i.log("invalidDiscountCodes:",n),{validDiscountCodes:o,invalidDiscountCodes:n}}},validateStackDiscount:function(e,t){if(i.isDiscountStacked()){const o=d.getStackDiscountValidationData(t),n=d.getDiscountFromStorage();o&&o.invalidDiscountCodes&&o.invalidDiscountCodes.length&&(o.invalidDiscountCodes.forEach((t=>{i.removeStackDiscount(t),d.deleteDiscountCode(e.myShopifyDomain,t.priceRuleId,t.discountCodeId),n&&t.code===n.code&&(i.log("Deleting discount from storage",t.code),localStorage.removeItem("lb-upsell-offer-discount"))})),localStorage.setItem("lb-upsell-offer-discount-stack",JSON.stringify(o.validDiscountCodes)))}},getDiscountMsg:function(e,t){const o=i.getCurrentLocale(),n=e.shopLocales&&e.shopLocales.length>1&&e.shopLocales.find((e=>e.primary));return n&&n.locale!==o&&t.translations&&t.translations[o]?t.translations[o].cartDiscountMsg:t.content.cartDiscountMsg},process:function(e,t){const o=i.getWidgetSetup(e,"product-page-cross-sell-embedded-widget"),n=i.getWidgetSetup(e,"product-page-addon-widget");let r=d.getDiscountFromStorage();if((o&&o.isEnabled||n&&n.isEnabled)&&r){let s=d.getDiscountMsg(e,r.code&&r.code.startsWith("ADD")?n:o),l=d.isDiscountValid(t,r),a=i.getCartForms();a.map((e=>e.getAttribute("id"))),!function(e,t){if(e&&t){let t=i.getSetup();t&&t.customDiscountHelpSelector&&e?setTimeout((()=>{let o=document.querySelector(t.customDiscountHelpSelector);if(o){let n=document.querySelector(".lb-upsell-discount-help");n&&n.remove();let i=document.createElement("div");i.innerHTML=e,i.className="lb-upsell-discount-help",o.insertAdjacentElement(t.customDiscountHelpPosition,i)}}),500):setTimeout((()=>{let t=document.querySelector("ppcse-floting-toast");t&&(t.message=e,t.showFloatingToast())}),1e3)}}(s,l),d.addDiscountCodeToAllCartForms(l,a,r)}else i.log("Discounts wont be processed. ppcseWidget is not enabled / no discount in storage")},addDiscountCodeToAllCartForms:function(e,t,o){e&&t&&t.length&&t.forEach((e=>{i.log("Discount is valid, adding to cart form at page load");let t=`<input type="hidden" name="discount" value="${o.code}" > </input>`;e.insertAdjacentHTML("beforeend",t)}))},removeDicountCodeFromAllCartForms:function(e){let t=document.querySelectorAll(`input[value="${e}"]`);t&&t.length&&t.forEach((e=>{i.log("Rmeoving discount elements"),e.remove()}))}}},276:(e,t,o)=>{const n=o(980);let i=e.exports={getOfferHistory:function(){let e=sessionStorage.getItem("lb-upsell-offer-history");return e?JSON.parse(e):void 0},pushEvent:function(e,t,o,r,d,s,l,a,c){if(n.isSnippetTesting())console.log("Metrics wont be pushed in snippet tesing mode.");else{let u={eventType:e,eventData:{isShopifyRecosOffer:l,account:{metricId:d.accountMetricId,id:d.myShopifyDomain},offer:{id:l?void 0:r.recordType,metricId:l?void 0:r.offerMetricId,widget:{id:s.recordType,metricId:s.widgetMetricId,isMultipleVariantsAdded:"widget#tpae"===s.recordType?!1!==s.isMultipleVariantsAdded:s.isMultipleVariantsAdded},details:{offerUniqueId:l?`shopify#${o}`:`shopify#${s.recordType}-${o}`,offeredProducts:t,leastPricedTriggerItem:a,addedVariants:s.isMultipleVariantsAdded&&c}}}};if(n.log("event:",u),"offer-viewed"===u.eventType){let e=sessionStorage.getItem("lb-upsell-offer-viewed");e=e?JSON.parse(e):{},e[u.eventData.offer.details.offerUniqueId]?n.log("Event offer-viewed already pushed"):(n.log("Pushing offer-viewed event"),e[u.eventData.offer.details.offerUniqueId]={offerId:l?`shopify#${o}`:u.eventData.offer.id},sessionStorage.setItem("lb-upsell-offer-viewed",JSON.stringify(e)),d.isViewMetricNotTracked?n.log("View tracking is disabled"):i.apiRequest("/metrics",u))}else if("offer-clicked"===u.eventType){let e=localStorage.getItem("lb-upsell-offer-clicked");e=e?JSON.parse(e):{};let t=u.eventData.offer.details.offeredProducts;if(e[u.eventData.offer.details.offerUniqueId])n.log("Event offer-clicked already pushed");else{n.log("Pushing offer-clicked event"),e[u.eventData.offer.details.offerUniqueId]={products:t,addedVariants:u.eventData.offer.details.addedVariants,leastPricedTriggerItem:u.eventData.offer.details.leastPricedTriggerItem,offerSettings:l?void 0:{id:u.eventData.offer.id,metricId:u.eventData.offer.metricId},widgetSettings:{id:u.eventData.offer.widget.id,metricId:u.eventData.offer.widget.metricId,isMultipleVariantsAdded:u.eventData.offer.widget.isMultipleVariantsAdded},isShopifyRecosOffer:l},i.apiRequest("/metrics",u),localStorage.setItem("lb-upsell-offer-clicked",JSON.stringify(e));let o={id:u.eventData.account.id,metricId:u.eventData.account.metricId,shopCurrencyCode:d&&d.shopCurrencyCode,shopifyCurrency:n.getPresentmentCurrency()};localStorage.setItem("lb-upsell-account-settings",JSON.stringify(o))}}}},apiRequest:function(e,t){let o=new XMLHttpRequest;o.open("POST",`${n.getHostName()}${e}`,!0),o.setRequestHeader("Content-Type","application/json; charset=UTF-8"),o.setRequestHeader("X-Metrics-Event-From","storefront"),o.send(JSON.stringify(t)),o.onload=function(){200===o.status&&n.log("Successfully processed event.")},o.onerror=function(){n.log("Error while processing metrics.")}},getFormattedOfferClicks:function(e){let t={};return Object.keys(e).forEach((o=>{if(e[o].offerSettings||e[o].isShopifyRecosOffer){let i=e[o].isShopifyRecosOffer?e[o].widgetSettings.id:e[o].offerSettings.id;t[i]?e[o].products&&t[i].products&&(t[i].products=n.arrayUnique(t[i].products.concat(e[o].products))):t[i]=e[o]}})),t},isConversionValid:function(e,t){return!t||e.product_id!==t.product_id||(n.log("is 1+1 offer valid",e.quantity>t.quantity),e.quantity>t.quantity)},trackConversion:function(){let e=Shopify.checkout||{};n.log("checkout:",e);let t=localStorage.getItem("lb-upsell-offer-clicked");if(t=t?JSON.parse(t):void 0,e&&e.line_items&&e.line_items.length&&t&&Object.keys(t)&&Object.keys(t).length){let o=i.getFormattedOfferClicks(t),r=[];if(Object.keys(o).forEach((t=>{if(o[t].products&&o[t].products.length){let n=[],d=[],s=o[t];s.addedVariants&&s.addedVariants.length?s.addedVariants.forEach((n=>{let r=e.line_items.find((e=>`${e.variant_id}`==`${n.id}`));r&&i.isConversionValid(r,o[t].leastPricedTriggerItem)&&d.push(r)})):s.products.forEach((r=>{let d=e.line_items.find((e=>e.product_id===r));d&&i.isConversionValid(d,o[t].leastPricedTriggerItem)&&n.push(d)})),(n.length||d.length)&&r.push({id:s.isShopifyRecosOffer?void 0:s.offerSettings.id,metricId:s.isShopifyRecosOffer?void 0:s.offerSettings.metricId,widget:{id:s.widgetSettings.id,metricId:s.widgetSettings.metricId},details:{offeredProducts:s.products,converetedProducts:n,convertedVariants:d},isShopifyRecosOffer:s.isShopifyRecosOffer})}})),r&&r.length){let t=localStorage.getItem("lb-upsell-account-settings");t=t?JSON.parse(t):void 0;let o,d=localStorage.getItem("lb-upsell-offer-discount");d=d?JSON.parse(d):void 0,d&&d.code&&e.discount&&e.discount.applicable&&e.discount.code===d.code&&(o={code:d.code,priceRuleId:d.priceRuleId,discountCodeId:d.discountCodeId},localStorage.removeItem("lb-upsell-offer-discount"));let s={eventType:"offers-converted",eventData:{account:t,offers:r,order:{id:e.order_id,discount:e.discount},dicountToDelete:o}};n.log("event:",s),i.apiRequest("/metrics",s),localStorage.removeItem("lb-upsell-offer-clicked")}}}}},298:(e,t,o)=>{const n=o(460),i=o(980),r=o(276),d=o(645);let s,l,a;e.exports={ppaWidgetLib:function(){let e,t={};function o(e){i.ppaLog("---pushOfferViewedEvent---");let t=i.getSetup(),o=i.getWidgetSetup(t,"product-page-addon-widget"),n=e.offer.boughtTogether&&e.offer.boughtTogether.map((e=>e.id));r.pushEvent("offer-viewed",n,e.offer.for.id,l,t,o,!1)}function c(){i.ppaLog("---pushing OfferClickedEvent---");let e=s.boughtTogether&&s.boughtTogether.map((e=>e.id)),t=i.getSetup(),o=i.getWidgetSetup(t,"product-page-addon-widget");r.pushEvent("offer-clicked",e,s.for.id,l,t,o,!1)}function u(e,t,o){c();let n=document.querySelector("lb-upsell-product-page-addon");n&&n.handleAddToCartResponse(e.detail.products[0].id,"success"===t,e),i.triggerCustomEvent({widgetType:"product-page-addon-widget",currentAddToCartActionSetup:a,addToCartAction:e.detail.addToCartAction,discount:o})}function p(e){e.addEventListener("ppaModalAddToCartClicked",(function(e){if(e.detail&&e.detail.products&&e.detail.products.length){let t={items:e.detail.products.map((e=>({id:e.selectedVariantId,quantity:e.quantity})))};c(),i.addItemsToCart(t).then((e=>{i.triggerCustomEvent({widgetType:"product-page-addon-widget",isFromModal:!0});let t=document.querySelector("ppcse-modal");t&&t.addToCartOnSuccess()})).catch((e=>{i.ppaLog("Error - ppa widget modal add to cart")}))}})),e.addEventListener("ppaAjaxAddToCartClicked",(function(e){if(e.detail&&e.detail.products&&e.detail.products.length)if("add"===e.detail.addToCartAction){let t={items:e.detail.products.map((e=>({id:e.selectedVariantId,quantity:e.quantity})))};i.addItemsToCart(t,!0).then((t=>{let o=[];if("add"===e.detail.addToCartAction&&e.detail.totalWithoutDiscount>0){let t=i.getSetup();o.push(d.getDiscountCode(t.myShopifyDomain,e.detail.ajaxAddedItems,e.detail.discounts,e.detail.totalWithoutDiscount,void 0,"product-page-addon-widget",l&&l.recordType,void 0,s.for.id))}else o.push(Promise.resolve(!0));Promise.all(o).then((o=>{let n=e.detail.totalWithoutDiscount>0&&o&&o[0]?o[0]:void 0;if(n&&n.code){let t=i.getSetup();n.endsAt=new Date((new Date).getTime()+6e4*(t.customDiscountEndTimeInMins||30)).getTime(),d.saveDiscountToStorage(s.for.id,e.detail.ajaxAddedItems,n)}u(e,t,n)})).catch((o=>{i.ppaLog("Error while creating discount code:",o),u(e,t,void 0)}))})).catch((e=>{i.ppaLog("Error - ppa widget ajax add to cart")}))}else!function(e){i.getCart(window.location.hostname).then((t=>{let o={updates:{}};if("delete-all"===e.detail.addToCartAction)t.items&&t.items.length&&Object.keys(e.detail.addedVariants).forEach((n=>{let i=t.items.find((e=>`${e.id}`==`${n}`));i&&(o.updates[n]=Math.abs(e.detail.addedVariants[n].quantity-i.quantity))}));else{let n=0;if(t.items&&t.items.length){let o=t.items.find((t=>t.id===e.detail.products[0].selectedVariantId));o&&(n=e.detail.currentQty?Math.abs(e.detail.currentQty-o.quantity):o.quantity-1)}o={updates:{[e.detail.products[0].selectedVariantId]:n}}}i.updateCart(o).then((t=>{let o=document.querySelector("lb-upsell-product-page-addon");o&&o.handleAddToCartResponse(e.detail.products[0].id,"success"===t,e),i.triggerCustomEvent({widgetType:"product-page-addon-widget",currentAddToCartActionSetup:a,addToCartAction:e.detail.addToCartAction})}))}))}(e)})),e.addEventListener("ppaProductClicked",(function(e){e.detail&&c()}))}async function g(e,t,o=!1){if(i.isAddToCartClickForced=!0,i.isAddToCartClickForcedReset=!0,o)e&&(e.click(),d.handleDiscountAfterClick());else{c(),e&&(e.click(),d.handleDiscountAfterClick());let t=document.querySelector("lb-upsell-product-page-addon");t&&t.resetAddToCartAction()}}async function f(e,t,o,n,r){return new Promise(((t,c)=>{let u=[];if(o>0){let t=i.getSetup();0===l.minSelectable&&1===l.maxSelectable||1===l.minSelectable&&1===l.maxSelectable?u.push(d.getDiscountCode(t.myShopifyDomain,[e[0],r],n,o,e[0],"product-page-addon-widget",l&&l.recordType,!1,s.for.id)):u.push(d.getDiscountCode(t.myShopifyDomain,e,n,o,void 0,"product-page-addon-widget",l&&l.recordType,!1,s.for.id))}else u.push(Promise.resolve(!0));Promise.all(u).then((n=>{let r=o>0&&n&&n[0]?n[0]:void 0;if(r&&r.code){let t,o=i.getSetup();r.endsAt=new Date((new Date).getTime()+6e4*(o.customDiscountEndTimeInMins||30)).getTime();let n=i.getWidgetSetup(o,"product-page-addon-widget");n&&n.isDiscountForProductValidated&&(t=s.for.variants.map((e=>e.id))),d.saveDiscountToStorage(s.for.id,e,r,t)}i.triggerCustomEvent({widgetType:"product-page-addon-widget",currentAddToCartAction:a,discount:r}),t("success")})).catch((e=>{i.ppaLog("Error while creating discount code.",e),i.triggerCustomEvent({widgetType:"product-page-addon-widget",currentAddToCartAction:a,discount:void 0}),c("Falied")}))}))}function m(){return window.innerWidth<=768}function h(e,t,r,d){i.removeExistingWidget("lb-upsell-product-page-addon");let s=n.getAddToCartBtnCSS(".ppa-add-to-cart-btn");s&&i.appendCustomTextCssToHead(s,"lb-upsell-ppa-atc-css");let l=m()?t.position.mobile.selector:t.position.desktop.selector,c=m()?t.position.mobile.insertPosition:t.position.desktop.insertPosition;r&&d&&(i.ppaLog("Using custom positioning"),l=r,c=d),i.ppaLog("----------Positioning widget----------"),"addToCartBtn"===l&&"beforebegin"===c?function(e){return new Promise(((t,r)=>{i.ppaLog("Adding widget to addWidgetToCartFormSubmitBtn");let d=n.getProductCartAddForms(),s=document.createElement("lb-upsell-product-page-addon");if(d&&d.length){let n=d[0].querySelectorAll("button,input");for(let e=0;e<n.length;e++)if("add"===n[e].name||"submit"===n[e].type){i.ppaLog("Positioning before button",n[e]),n[e].insertAdjacentElement("beforebegin",s);break}let r=document.querySelector("lb-upsell-product-page-addon");r?(r.widget=e.widget,r.offer=e.offer,a=e.widget.addToCartAction,i.ppaLog("Widget successfully added to cart form"),p(r),o(e),t(!0)):(i.ppaLog("ppcseWidget not found"),t(!1))}else i.debugLog("Addons widget - Could not find cart add form"),i.ppaLog("Could not find cart add form"),t(!1)}))}(e).then((t=>{t||function(e){return new Promise(((t,n)=>{let r=function(){let e=[],t=document.querySelectorAll("form");if(t)for(let o=0;o<t.length;o++)"post"===t[o].method&&"string"==typeof t[o].action&&(t[o].action.endsWith("/cart/add")||t[o].action.endsWith("/cart/add/")||t[o].action.indexOf("/cart/add?")>-1)&&e.push(t[o]);return e&&e.length?e[0]:void 0}(),d=document.createElement("lb-upsell-product-page-addon");if(r){r.insertAdjacentElement("afterend",d);let n=document.querySelector("lb-upsell-product-page-addon");n?(n.widget=e.widget,n.offer=e.offer,n.widget.addToCartAction="ajax",a="ajax",i.ppaLog("Widget successfully added to cart form. Trigger changed to ajax"),p(n),o(e),t(!0)):(i.ppaLog("ppcseWidget not found"),t(!1))}else i.debugLog("Addons widget - Could not find cart add form"),i.ppaLog("Could not find cart add form"),t(!1)}))}(e).then((e=>{e||(i.debugLog("Addons widget - Cannot default position widget, check selectors"),i.ppaLog("Cannot default position widget check selectors"))}))})):function(e,t,n){return new Promise(((r,d)=>{i.ppaLog("added widget to custom selector");let s=document.querySelector(e);if(s){s.insertAdjacentHTML(t,"<lb-upsell-product-page-addon> \n </lb-upsell-product-page-addon>\n");let d=document.querySelector("lb-upsell-product-page-addon");d?(d.widget=n.widget,d.offer=n.offer,a=n.widget.addToCartAction,i.ppaLog(`Widget successfully added to selector , ${e}`),p(d),o(n),r(!0)):(i.ppaLog("ppcseWidget not found"),r(!1))}else i.ppaLog(`Could not find selector, ${e}`),r(!1)}))}(l,c,e).then((e=>{e||(i.debugLog("Addons widget - cannot find CSS ,check selectors"),i.ppaLog("Check custom CSS selector."))}))}return t.handleAddToCart=function(e){let t=document.querySelector("lb-upsell-product-page-addon");t?t.getAddedItems().then((t=>{i.ppaLog("Result",t),t.addedItems&&t.addedItems.length&&"trigger"===a?function(e,t,o,n,r){let d={items:e.map((e=>({id:e.selectedVariantId,quantity:e.quantity||1})))},s=[i.addItemsToCart(d,!0,!0),f(e,0,o,n,r)];Promise.all(s).then((e=>{g(t),i.log("ATC and discount promise complete.",e)})).catch((e=>{i.ppaLog("Error - ppa widget addAllItemsToCart add to cart",e),g(t,0,!0),i.triggerCustomEvent({widgetType:"product-page-addon-widget",currentAddToCartAction:a,discount:void 0})}))}(t.addedItems,e,t.totalWithoutDiscount,t.discounts,t.forProduct):(i.isAddToCartClickForced=!0,i.isAddToCartClickForcedReset=!0,e&&e.click())})):(i.isAddToCartClickForced=!0,i.isAddToCartClickForcedReset=!0,e&&e.click())},t.render=function(t,o,r,d){e=t;const a=i.getSetup();if(n.isProductPage()||o){i.ppaLog("product page found");const e=a.widgets.find((e=>"product-page-addon-widget"===e.type));if(e&&e.isEnabled){const c=o||n.getProductHandle();i.getProduct(c).then((async o=>{if(o.available)if(a.offers&&a.offers.length){const u=await i.getOffer(a,o,"product-addons");i.ppaLog("Best offer :",u),u&&(i.debugLog(`Initializing offer, ${u.name}`),n.getFormattedWidgetInput(e,u,c,o.id,t).then((t=>{s=t.offer,l=u,i.ppaLog("Final offer input to wiget",t.offer),i.ppaLog("wiget settings",t.widget),i.ppaLog(JSON.stringify(t)),i.ppaLog("---------------"),t.offer&&t.offer.boughtTogether&&t.offer.boughtTogether.length?(i.ppaLog("---------------"),a.version>=18&&window.lbUpsellComponents&&window.lbUpsellComponents.registerAddToCartListeners(),h(t,e,r,d)):(i.ppaLog("Not enough products to position widgets"),i.ppaLog("---------------"))})))}else i.ppaLog("No offer setup found"),e.useShopifyProductRecommendations&&n.showShopifyProductRecommendations(o,e).then((t=>{s=t.offer,i.ppaLog("Final offer input to wiget",t.offer),i.ppaLog("wiget settings",t.widget),i.ppaLog(JSON.stringify(t)),i.ppaLog("---------------"),a.version>=18&&window.lbUpsellComponents&&window.lbUpsellComponents.registerAddToCartListeners(),h(t,e,r,d)}));else i.ppaLog("For product is not available.")})).catch((e=>{i.ppaLog("Error while querying product from AJAX API",e)}))}}},t}}},156:(e,t,o)=>{const n=o(276),i=o(980),r=o(645),d=o(460);e.exports={ppcseWidgetLib:function(){let e,t,o,s,l,a,c={};function u(){let e=document.querySelector("lb-product-page-cross-sell-ew");e&&e.addToCartOnSuccess("success")}function p(o,r,a){i.log("Successfully added items to cart.");let c=t.boughtTogether&&t.boughtTogether.map((e=>e.id));switch(n.pushEvent("offer-clicked",c,t.for.id,s,e,o,l),i.triggerCustomEvent({widgetType:"product-page-cross-sell-embedded-widget",discount:r,isFromModal:a}),o.addToCartAction){case"stay":u();break;case"redirect":setTimeout((()=>{let e=i.getRootRoute();window.location=e&&"/"!==e?`https://${window.location.hostname}${e}cart`:`https://${window.location.hostname}/cart`}),1e3);break;case"reload":u(),setTimeout((()=>{window.location.reload()}),1500);break;case"autoAddToCart":{let e=d.isAutoAddToCartValid(t.for);e?(e.click(),u()):(u(),setTimeout((()=>{window.location.reload()}),1500));break}case"redirect_checkout":{let e=i.getRootRoute();window.location.href=e&&"/"!==e?`${e}cart/checkout${r?`?discount=${r.code}`:""}`:"/cart/checkout"+(r?`?discount=${r.code}`:"");break}}}function g(n,s,l,a,c){let u={items:n.map((e=>{if(t.for.id!==e.id||!d.isAutoAddToCartValid(t.for))return{id:e.selectedVariantId,quantity:s?Number(s):1}})).filter((e=>e))};i.addItemsToCart(u,!0).then((()=>{let i=l>0&&a&&a[0]?a[0]:void 0;i&&i.code&&(i.endsAt=new Date((new Date).getTime()+6e4*(e.customDiscountEndTimeInMins||30)).getTime(),r.saveDiscountToStorage(t.for.id,n,i)),p(o,i,c)})).catch((e=>{i.log("Error while adding items to cart",e),p(o,void 0,c)}))}function f(d){d.addEventListener("addToCartClicked",(function(o){o.detail&&o.detail.products&&o.detail.products.length&&(i.log("event.detail:",o.detail),function(o,n,d,l,a,c,u){let p=[];d>0?(a&&window.isDynamicCheapProduct&&(a=o.reduce(((e,t)=>t.selectedVariantPrice<e.selectedVariantPrice?t:e))),p.push(r.getDiscountCode(e.myShopifyDomain,o,c,d,a,"product-page-cross-sell-embedded-widget",s&&s.recordType,!1,t.for.id))):p.push(Promise.resolve(!0)),Promise.all(p).then((e=>{g(o,n,d,e,u)})).catch((e=>{i.log("Error while creatin g discount code.",e),g(o,n,d,void 0,u)}))}(o.detail.products,o.detail.quantity,o.detail.totalWithoutDiscount,o.detail.total,o.detail.cheapestProduct,o.detail.discounts,o.detail.isFromModal))})),d.addEventListener("productClicked",(function(i){if(i.detail){let i=t.boughtTogether&&t.boughtTogether.map((e=>e.id));n.pushEvent("offer-clicked",i,t.for.id,s,e,o,l)}}))}function m(){return window.innerWidth<=768}function h(t){return new Promise(((r,d)=>{let a=function(){let e=[],t=document.querySelectorAll("form");if(t)for(let o=0;o<t.length;o++)"post"===t[o].method&&"string"==typeof t[o].action&&(t[o].action.endsWith("/cart/add")||t[o].action.endsWith("/cart/add/")||t[o].action.indexOf("/cart/add?")>-1)&&e.push(t[o]);let o=window.Shopify&&window.Shopify.theme&&window.Shopify.theme.name&&"Dawn"===window.Shopify.theme.name,n=e&&e.length?e[0]:void 0;return o&&e&&e.length>0&&(n=e[1]),n}(),c=document.createElement("lb-product-page-cross-sell-ew");if(a){a.insertAdjacentElement("afterend",c);let d=document.querySelector("lb-product-page-cross-sell-ew");if(d){d.widget=t.widget,d.offer=t.offer,f(d);let a=t.offer.boughtTogether&&t.offer.boughtTogether.map((e=>e.id));n.pushEvent("offer-viewed",a,t.offer.for.id,s,e,o,l),i.log("Widget successfully added to cart form"),r(!0)}else i.log("ppcseWidget not found"),r(!1)}else i.log("Could not find cart add form"),i.debugLog("FBT widget - Could not find cart add form."),r(!1)}))}function w(t,r,d){return new Promise(((a,c)=>{let u=document.querySelector(t);if(u){u.insertAdjacentHTML(r,"<lb-product-page-cross-sell-ew> \n </lb-product-page-cross-sell-ew>\n");let c=document.querySelector("lb-product-page-cross-sell-ew");if(c){c.widget=d.widget,c.offer=d.offer,f(c);let r=d.offer.boughtTogether&&d.offer.boughtTogether.map((e=>e.id));n.pushEvent("offer-viewed",r,d.offer.for.id,s,e,o,l),i.log(`Widget successfully added to selector , ${t}`),a(!0)}else i.log("ppcseWidget not found"),a(!1)}else i.log(`Could not find selector, ${t}`),a(!1)}))}function b(t,o){if(i.removeExistingWidget("lb-product-page-cross-sell-ew"),e.version>=2){let e=d.getAddToCartBtnCSS(".ppcse-tot-btn");e&&i.appendCustomTextCssToHead(e,"lb-upsell-ppcse-atc-css")}const n=m()?o.position.mobile.selector:o.position.desktop.selector,r=m()?o.position.mobile.insertPosition:o.position.desktop.insertPosition;i.log("----------Positioning widget----------"),e.version>=2?".product-form"===n&&"afterend"===r?h(t).then((e=>{e||w(n,r,t).then((e=>{e||w(".product-single","afterend").then((e=>{e||(i.debugLog("FBT widget - Could not add widget to .product-single in version 2 with default positioning, no more retries"),i.log("Could not add widget to .product-single in version 2 with default positioning, no more retries"))}))}))})):w(n,r,t).then((e=>{e||i.log("Check custom CSS selector.")})):".product-single"===n&&"afterend"===r?w(n,r,t).then((e=>{e||h(t).then((e=>{e||i.log("Could not add widget to form in version 1 with default positioning, no more retries")}))})):w(n,r,t).then((e=>{e||i.log("Check custom CSS selector.")})),i.log("widgetInput:",JSON.stringify(t))}function y(e){d.showShopifyProductRecommendations(e,o,a).then((e=>{l=!0,t=e.offer,i.log("Final offer input to wiget",e.offer),i.log("wiget settings",e.widget),i.log("---------------"),b(e,o)}))}return c.render=function(n,r,l){if(e=n,a=r,d.isProductPage()||l){i.log("product page found");const n=e.widgets.find((e=>"product-page-cross-sell-embedded-widget"===e.type));if(n&&n.isEnabled){o=n;const a=l||d.getProductHandle();i.getProduct(a).then((async o=>{if(o.available)if(e.offers&&e.offers.length){const l=await i.getOffer(e,o,"frequently-bought-bundle");i.log("Best offer :",l),l?(i.debugLog(`Initializing offer, ${l.name}`),d.getFormattedWidgetInput(n,l,a,o.id,r,o).then((e=>{t=e.offer,s=l,e.offer&&e.offer.boughtTogether&&e.offer.boughtTogether.length?(i.log("Final offer input to wiget",e.offer),i.log("wiget settings",e.widget),i.log("---------------"),b(e,n)):(i.log("Not enough products to position widgets"),i.log("---------------"))}))):(i.log("------No matching offer found.----------"),n.useShopifyProductRecommendations&&y(o))}else i.log("No offer setup found"),n.useShopifyProductRecommendations&&y(o);else i.log("For product is not available.")})).catch((e=>{i.log("Error while querying product from AJAX API",e)}))}}},c}}},460:(e,t,o)=>{const n=o(980),i=o(645);let r=e.exports={isProductPage:function(){return-1!==window.location.pathname.indexOf("/products/")},getProductHandle:function(){const e=window.location.pathname.split("/");return e&&e.length&&e[e.length-(window.location.pathname.endsWith("/")?2:1)]},getProducts:function(e,t){return new Promise(((o,i)=>{let r=[n.getProduct(e)];t.boughtTogether.offeredProducts.products.forEach((e=>{r.push(n.getProduct(e.handle))})),Promise.all(r).then((e=>{e&&e.length&&(e=e.filter((e=>e))),o(e)}))}))},filterProducts:function(e,t){const o=!!t&&"product-page-addon-widget"===t.type&&t.isSoldOutProductsShown;return e.filter((e=>(e.available||o)&&n.isImgAvailable(e))).map((e=>(e.variants&&e.variants.length&&(e.variants=e.variants.filter((e=>e.available||o))),e)))},isAutoAddToCartValid:function(e){let t=n.getWidgetSetup(n.getSetup(),"product-page-cross-sell-embedded-widget");return"autoAddToCart"===t.addToCartAction&&(e.variants&&1===e.variants.length||!e.variants)&&document.querySelector(t.addToCartSelector)},getProductCartAddForms:function(){let e=[],t=document.querySelectorAll("form");if(t)for(let o=0;o<t.length;o++)if("post"===t[o].method&&"string"==typeof t[o].action&&(t[o].action.endsWith("/cart/add")||t[o].action.endsWith("/cart/add/")||t[o].action.indexOf("/cart/add?")>-1)){let n=t[o].querySelectorAll("button,input");for(let i=0;i<n.length;i++)if("add"===n[i].name||"submit"===n[i].type){e.push(t[o]);break}}return e&&e.length?e:void 0},getAddToCartBtnCSS:function(e){let t="",o="",i=["rgba(0, 0, 0, 0)","rgb(255, 255, 255)","white","#FFFFFF","#ffffff"],d=["border-color","background-color","color","background","font-size","font-family","letter-spacing","font-weight","border","box-shadow","text-transform","border-width","border-radius","border-style"],s=r.getProductCartAddForms(),l=n.getSetup();if(s&&s.length){let e=s[0].querySelectorAll("button,input");for(let r=0;r<e.length;r++)if("add"===e[r].name||"submit"===e[r].type){let s,a;d.forEach((d=>{let c=n.getStyle(e[r],d);"background-color"===d&&(s=c),"border-color"===d&&(a=c),l&&l.version>=4&&"color"===d&&i.includes(c)&&i.includes(s)&&(c=a),t+=`${d}:${c};`,"background-color"===d&&document.documentElement.style.setProperty("--lb-ppa-spc-cta-bg",`${c}`),"color"===d&&(o=`${c};`,document.documentElement.style.setProperty("--lb-ppa-spc-cta-btn-color",`${c}`)),"border-color"===d&&document.documentElement.style.setProperty("--lb-ppa-spc-cta-border",`${c}`)}));break}}return t.length?`${e}{\n${t}\n}\n.lb-upsell-tot-btn{\n${t}}\n.ppcse-spinner circle{\nstroke: ${o};\n}`:void 0},getFormattedWidgetInput:function(e,t,o,d,s,l){return new Promise(((a,c)=>{const u=n.getSetup();let p;p="product-page-addon-widget"===e.type?!i.isWidgetDiscountValid(s,"FUNDLL")&&!i.isWidgetDiscountValid(s,"BUNDLL")&&i.isDiscountShown(d,s,"ADDDLL")&&"view"!==e.addToCartAction:!i.isWidgetDiscountValid(s,"FUNDLL")&&!i.isWidgetDiscountValid(s,"ADDDLL")&&i.isDiscountShown(d,s,"BUNDLL"),n.isDiscountStacked()&&(p=!0);let g={boughtTogether:[],discounts:p&&t.discounts&&t.discounts.isEnabled&&t.discounts,overrideWidgeTitle:t.overrideWidgeTitle},f={styles:e.styles,content:e.content,isQuantityPickerEnabled:e.isQuantityPickerEnabled,isQtyPickerHidden:e.isQtyPickerHidden,discountCondition:e.discountCondition,imageResolution:e.imageResolution,isMultipleVariantsAdded:e.isMultipleVariantsAdded,metadata:{shopCurrencyFormat:u&&u.shopEmailCurrencyFormat?u.shopEmailCurrencyFormat:u.shopCurrencyFormat,isAmountNoDecimals:u&&u.isAmountNoDecimals,shopMoneyInEmailsFormat:u&&u.shopMoneyInEmailsFormat,shopCurrencyCode:u&&u.shopCurrencyCode,presentmentCurrency:void 0,isUnitPriceShown:u&&u.isUnitPriceShown,setupVersion:u.version,variantsGroupSeperator:u.variantsGroupSeperator}},m=n.getTranslations(u,e,t,g,f);g=m.offer,f=m.widget;let h=[];t.boughtTogether.shopifyProductRecommendations&&t.boughtTogether.shopifyProductRecommendations.isEnabled?h.push(r.getShopifyProductRecomendation(l.id,t.boughtTogether.shopifyProductRecommendations.limit)):h.push(r.getProducts(o,t)),Promise.all(h).then((i=>{let d;n.ppaLog("--------Processing best offer --------"),t.boughtTogether.shopifyProductRecommendations&&t.boughtTogether.shopifyProductRecommendations.isEnabled?(d=i&&i[0].products&&i[0].products.length?[l,...i[0].products]:[l],d.forEach((e=>{e.productId=e.id}))):d=i&&i[0].length?i[0]:[],n.ppaLog("Reference products fetch successfull",d);let s=n.filterProducts(d,e);n.ppaLog("Filtered Products based on product/variant availablity & image:",s);let c=s.find((e=>(e.handle||"").toLowerCase()===(decodeURI(o)||"").toLowerCase()));c=JSON.parse(JSON.stringify(c)),c.isForProduct=!0;let u=t.boughtTogether.shopifyProductRecommendations&&t.boughtTogether.shopifyProductRecommendations.isEnabled?JSON.parse(JSON.stringify(i[0].products)):JSON.parse(JSON.stringify(t.boughtTogether.offeredProducts.products));u=n.getBoughtProductsRandomSortOrder(u,t.isSortedRandomly),u.sort(((e,t)=>e.sortNo-t.sortNo)),u=n.mapAvailableProducts(u,s,t.for.selectorType,c,void 0,void 0),u=n.removeExtraItems(u,e.maxItemsInOffer),g.boughtTogether=u,f.metadata.presentmentCurrency=n.getPresentmentCurrency(),"product-page-addon-widget"===e.type?(f.addToCartAction=e.addToCartAction,f.layoutStyle=e.layoutStyle||"list",f.addActionStyle=e.addActionStyle||"button",f.productClickActionStyle=e.productClickActionStyle||"popup","trigger"!==f.addToCartAction||"checkbox"!==e.addActionStyle&&"checkbox-left"!==e.addActionStyle||!(0===t.minSelectable&&1===t.maxSelectable||1===t.minSelectable&&1===t.maxSelectable)||(f.addActionStyle="checkbox-left"===f.addActionStyle?"radio-left":"radio"),"view"===f.addToCartAction&&(f.addActionStyle="button",f.productClickActionStyle="redirect_new_tab")):f.addToCartAction=r.isAutoAddToCartValid(c,e)&&e.addToCartAction,"product-page-cross-sell-embedded-widget"===e.type&&(f.productClickActionStyle=e.productClickActionStyle||"popup",f.isProductDetailsCollpased=e.isProductDetailsCollpased,f.isImagesNotFiltered=e.isImagesNotFiltered,f.layoutStyle=e.layoutStyle||"classic"),a({widget:f,offer:{for:c,boughtTogether:g.boughtTogether,minSelectable:("radio"===f.addActionStyle||"radio-left"===f.addActionStyle)&&t.minSelectable,maxSelectable:("radio"===f.addActionStyle||"radio-left"===f.addActionStyle)&&t.maxSelectable,discounts:g.discounts,overrideWidgeTitle:g.overrideWidgeTitle}})})).catch((e=>{n.ppaLog("Error while getProducts",e),c(e)}))}))},getShopifyProductRecomendation:function(e,t){return new Promise(((o,i)=>{let r;var d=new XMLHttpRequest;let s=n.getRootRoute();r=s&&"/"!==s?`https://${window.location.hostname}${s}recommendations/products.json?product_id=${e}&limit=${t}`:`https://${window.location.hostname}/recommendations/products.json?product_id=${e}&limit=${t}`,d.open("GET",r,!0),d.setRequestHeader("Content-Type","application/json; charset=UTF-8"),d.setRequestHeader("Access-Control-Allow-Origin","*"),d.send(),d.onload=()=>{200===d.status&&o(JSON.parse(d.responseText))},d.onerror=()=>{i("Error while getting product recommendations"+e)}}))},showShopifyProductRecommendations:function(e,t,o){return new Promise(((d,s)=>{let l=n.getSetup();if(n.log("Fetching productRecommendations"),e&&n.isImgAvailable(e)){let s=Number(t.maxItemsInOffer)>0?t.maxItemsInOffer:2;r.getShopifyProductRecomendation(e.id,s).then((s=>{if(n.log("ProductRecommendations result:",s),s&&s.products&&s.products.length){let a=n.filterProducts([e],t)[0],c=n.filterProducts(s.products,t);if(a&&c.length){let e={for:a,boughtTogether:c,discounts:void 0},s={styles:t.styles,content:t.content,metadata:{shopCurrencyFormat:l&&l.shopEmailCurrencyFormat?l.shopEmailCurrencyFormat:l.shopCurrencyFormat,isAmountNoDecimals:l&&l.isAmountNoDecimals,shopMoneyInEmailsFormat:l&&l.shopMoneyInEmailsFormat,shopCurrencyCode:l&&l.shopCurrencyCode,presentmentCurrency:n.getPresentmentCurrency(),isUnitPriceShown:l&&l.isUnitPriceShown,setupVersion:l.version,variantsGroupSeperator:l.variantsGroupSeperator}};if(l.shopLocales&&l.shopLocales.length>1){n.log("Checking shoplocale");const e=n.getCurrentLocale(),o=l.shopLocales.find((e=>e.primary));o&&o.locale!==e&&t.translations&&t.translations[e]&&(n.log("Replacing primaery locale"),s.content=t.translations[e])}let u,p=e.for;p=JSON.parse(JSON.stringify(p)),p.isForProduct=!0,"product-page-addon-widget"===t.type?(s.addToCartAction=t.addToCartAction,s.layoutStyle=t.layoutStyle||"list",s.addActionStyle=t.addActionStyle||"button",s.productClickActionStyle=t.productClickActionStyle||"popup",u=!i.isWidgetDiscountValid(o,"FUNDLL")&&!i.isWidgetDiscountValid(o,"BUNDLL")&&i.isDiscountShown(p.id,o,"ADDDLL")):(s.addToCartAction=r.isAutoAddToCartValid(p,t)&&t.addToCartAction,s.productClickActionStyle=t.productClickActionStyle||"popup",s.isProductDetailsCollpased=t.isProductDetailsCollpased,s.isImagesNotFiltered=t.isImagesNotFiltered,u=!i.isWidgetDiscountValid(o,"FUNDLL")&&!i.isWidgetDiscountValid(o,"ADDDLL")&&i.isDiscountShown(p.id,o,"BUNDLL")),n.isDiscountStacked()&&(u=!0),u&&"product-page-cross-sell-embedded-widget"===t.type&&t.useShopifyProductRecommendations&&t.recommendationDiscount&&t.recommendationDiscount.isEnabled&&(e.discounts={...t.recommendationDiscount,isAutoRecommendationDiscount:!0}),d({offer:{for:p,boughtTogether:e.boughtTogether,discounts:e.discounts},widget:s})}}}))}else n.log("For product image not found, so no offer will be rendered")}))}}},738:(e,t,o)=>{const n=o(980),i=o(491);let r=e.exports={getLocalCache:function(){let e=localStorage.getItem("lb-upsell-setup"),t=localStorage.getItem("lb-upsell-setupFetchedAt");return e&&t&&Number(t)>(new Date).getTime()-72e5?JSON.parse(e):void 0},setLocalCache:async function(e){localStorage.setItem("lb-upsell-setup",JSON.stringify(e)),localStorage.setItem("lb-upsell-setupFetchedAt",(new Date).getTime())},clearLocalCache:function(){localStorage.removeItem("lb-upsell-setup"),localStorage.removeItem("lb-upsell-setupFetchedAt")},fetchObject:function(e,t,o=[],d=void 0){return new Promise(((s,l)=>{let a={cursor:d||null};var c=new XMLHttpRequest;c.open("POST",`https://${window.location.hostname}/api/${i.API_VERSION}/graphql.json`,!0),c.setRequestHeader("Content-Type","application/json; charset=UTF-8"),c.setRequestHeader("X-Shopify-Storefront-Access-Token",e),c.setRequestHeader("Access-Control-Allow-Origin","*"),c.send(JSON.stringify({query:t.queryString,variables:a})),c.onload=()=>{if(200===c.status){let i=JSON.parse(c.responseText);n.log("fetch from sf api ==>",i),i&&i.data&&i.data.metaobjects&&i.data.metaobjects.nodes?(i.data.metaobjects.nodes.length||s([]),t.isOffersFetch||s(i.data.metaobjects.nodes),i.data.metaobjects.pageInfo&&i.data.metaobjects.pageInfo.hasNextPage?r.fetchObject(e,t,i.data.metaobjects.nodes,i.data.metaobjects.pageInfo.endCursor).then((e=>{o=[...o,...e],n.log("Returning paginated offer",o),s(o)})).catch((e=>{n.log("Error while fetching paginated Offers!",e)})):s([...o,...i.data.metaobjects.nodes])):l(!1)}else n.log("Error while fetch setup from the SF api."),l("Error while fetch setup from the SF api.")},c.onerror=()=>{n.log("Error while fetch setup from the SF api."),l("Error while fetch setup from the SF api. ")}}))},isSetupCachedInClientSide:e=>!(e.createdAt>=(new Date).valueOf()-6048e5)&&(!e.lastAdminActiveAt||e.lastAdminActiveAt<(new Date).valueOf()-72e5),getSFSetup:function(e,t,o=void 0){let i=[{queryString:'{\n metaobjects(type: "$app:selleasy-setup", first: 1, sortKey: "updated_at") {\n nodes {\n field(key: "selleasy-setup") {\n value\n key\n }\n id\n handle\n }\n }\n }',isOffersFetch:!1}];void 0!==o&&i.push({queryString:'query getMetaObjects($cursor: String) {\n metaobjects(type: "$app:selleasy-offer", first: 250, after: $cursor, sortKey: "updated_at") {\n nodes {\n field(key: "selleasy-offer") {\n value\n key\n }\n id\n handle\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }',isOffersFetch:!0});let d=i.map((e=>r.fetchObject(t,e)));Promise.all(d).then((t=>{if(t&&t.length){let n=t[0]&&t[0][0];if(n){let i=JSON.parse(n&&n.field&&n.field.value||"{}");i.isStorefrontApiEnabled?(i.offers=t[1]&&t[1].map((e=>e&&e.handle&&e.handle.includes("selleasy-offer")&&e.field&&e.field.value&&JSON.parse(e.field.value||"{}")))||[],void 0!==o&&o("setup",i),r.isSetupCachedInClientSide(i)||r.clearLocalCache()):void 0!==o&&r.fetchSetup(e,o,!0)}else void 0!==o&&r.fetchSetup(e,o,!0)}else void 0!==o?r.fetchSetup(e,o,!0):r.validateSetup(e,!0),n.log("SF api failed!")})).catch((t=>{n.log("Error while resolving get setup proimses: fallback to Api fetch",t),void 0!==o?r.fetchSetup(e,o,!0):r.validateSetup(e,!0)}))},fetchSetup:function(e,t,o=!1){if(window&&window.lbupsellToken&&!o)n.log("Token",window.lbupsellToken),r.getSFSetup(e,window.lbupsellToken,t);else{let o=`${n.getHostName()}/setup?myShopifyDomain=${e}`;var i=new XMLHttpRequest;i.open("GET",o,!0),i.setRequestHeader("Content-Type","application/json; charset=UTF-8"),i.send(),i.onload=function(){if(200===i.status){let e=JSON.parse(i.responseText);n.log("Setup fetch successfull",e),t("setup",e),e.isSetupCachedInClientSide&&r.setLocalCache(e)}},i.onerror=function(){n.log("Failed while fetching setup")}}},validateSetup:async function(e,t=!1){if(window&&window.lbupsellToken&&!t)n.log("Token",window.lbupsellToken),r.getSFSetup(e,window.lbupsellToken,void 0);else{var o=new XMLHttpRequest;o.open("GET",`${n.getHostName()}/setupValidate?myShopifyDomain=${e}`,!0),o.setRequestHeader("Content-Type","application/json; charset=UTF-8"),o.send(),o.onload=function(){if(200===o.status){let e=JSON.parse(o.responseText);n.log("Setup validation response !!!",e),e&&!e.isSetupCachedInClientSide&&(n.log("Clearing cache !!!",e.isSetupCachedInClientSide),r.clearLocalCache())}},o.onerror=function(){n.log("Failed while fetching setup")}}},getSetup:function(e,t){let o=r.getLocalCache();o?(t("setup",o),n.log("Using local cache setup !!"),r.validateSetup(e)):(n.log("Fetchig setup !!"),r.fetchSetup(e,t))}}},980:(e,t,o)=>{const n=o(491),i=n.HOST_NAME,r="true"===n.IS_LOGS_REQUIRED;let d,s=e.exports={isCheckoutClickForced:!1,isAddToCartClickForced:!1,isAddToCartClickForcedReset:!1,isPrerenderingDisabled:!1,log:function(e,t){r&&console.log(e,t||"")},upsellFunnelLog:function(e,t){r&&console.log("[34m%s[0m",e,t||"")},ppaLog:function(e,t){r&&console.log("[35m%s[0m",e,t||"")},debugLog:function(e,t){localStorage.getItem("selleasyDebugLogsEnabled")&&console.log(e,t||"")},getCookieValue:function(e){for(var t=document.cookie.split(";"),o=0;o<t.length;o++){var n=t[o].split("=");if(e==n[0].trim())return decodeURIComponent(n[1])}return null},setSetup:function(e){d=e},getSetup:function(){return d},getHostName:function(){return i},isSnippetTesting:function(){return!1},sortByPriorityAndLatestOffer:function(e){return e.sort((function(e,t){return Number(t.priority||0)-Number(e.priority||0)||t.createdAt-e.createdAt}))},removeExistingWidget:function(e){let t=document.querySelector(e);t&&t.remove()},filterProducts:function(e,t){const o=!!t&&"product-page-addon-widget"===t.type&&t.isSoldOutProductsShown;return e.filter((e=>(e.available||s.debugLog(` ${e.title}, product is out of stock.`),s.isImgAvailable(e)||s.debugLog(` ${e.title}, product image not available.`),(e.available||o)&&s.isImgAvailable(e)))).map((e=>(e.variants&&e.variants.length&&(e.variants=e.variants.filter((t=>(t.available||s.debugLog(`${e.title} - ${t.title}, product variant not available.`),t.available||o)))),e)))},getTranslations:function(e,t,o,n,i){if(e.shopLocales&&e.shopLocales.length>1){s.log("Checking shoplocale");const r=s.getCurrentLocale(),d=e.shopLocales.find((e=>e.primary));d&&d.locale!==r&&(s.log("Replacing primaery locale"),t.translations&&t.translations[r]&&(i.content={...i.content,...t.translations[r]}),o.translations&&o.translations[r]&&(o.translations[r].overrideWidgeTitle&&(n.overrideWidgeTitle=o.translations[r].overrideWidgeTitle),n.discounts&&n.discounts.description&&o.translations[r].description&&(n.discounts.description=o.translations[r].description)),s.log("formattedOffer",n))}return{offer:n,widget:i}},getBoughtProductsRandomSortOrder:function(e,t){if(t){let t=s.getRandomSortOrder(e.length);return s.ppaLog("Random Sort Order:",t),s.ppaLog("True Sort Order",e.map((e=>e.sortNo))),e.map(((e,o)=>(e.sortNo=t[o],e)))}return e},mapAvailableProducts:function(e,t,o,n,i,r){return e.map((d=>{let l=t.find((e=>e.id==d.productId));const a=l&&("tags"===o||"all"===o||"products"===o&&1!==e.length)&&(r?r.some((e=>e.id===l.id)):n&&n.id===l.id);if(a&&s.debugLog(`${l.title}, product excluded because - ${r?"item already in cart":`selectorType = ${o}`}.`),l&&d.limitVariants&&d.limitVariants.length&&d.limitVariants.length<=l.variants.length){let e=l.variants.filter((e=>!d.limitVariants.some((t=>t.id==e.id))));console.log(`${l.title} - ${e&&e.length?e.map((e=>e.title)):""}, variants are limited`),l.variants=l.variants.filter((e=>d.limitVariants.some((t=>t.id==e.id))))}return l&&i&&(l.discount=d.discount),!a&&l})).filter((e=>e&&e.variants&&e.variants.length))},removeExtraItems:function(e,t){return Number(t)>0&&e.length>t?(s.ppaLog("Removed extra items (maxItemsInOffer) in boughttogether",e),e.slice(0,t)):e},getOffer:async function(e,t,o){if(s.log("--------Finding best offer------"),!t||"frequently-bought-bundle"===o&&!s.isImgAvailable(t))s.log("For product image not found, so no offer will be rendered");else{let n=[];if(e.offers&&e.offers.length){let i=JSON.parse(JSON.stringify(e.offers.filter((e=>!e.version||e.version>=2&&"product-page"===e.placementPage&&e.upsellType===o))));return i=s.sortByPriorityAndLatestOffer(i),i.forEach((e=>{"products"===e.for.selectorType?e.for.products.some((e=>e.handle===decodeURI(t.handle)||`${t.id}`===e.productId))&&n.push(e):"tags"===e.for.selectorType&&t.tags&&t.tags.length?e.for.products.some((e=>t.tags.some((t=>(t||"").toLowerCase()===(e.name||"").toLowerCase()))))&&n.push(e):"all"===e.for.selectorType&&n.push(e)})),s.log("applicableOffers:",n),n.length?n[0]:void 0}}},getCartForms:function(){let e=[],t=document.querySelectorAll("form");if(t)for(let o=0;o<t.length;o++)"post"===t[o].method&&"string"==typeof t[o].action&&(t[o].action.endsWith("/cart")||t[o].action.endsWith("/cart/")||t[o].action.indexOf("/cart?")>-1)&&e.push(t[o]);return e},getBtnCSS:function(e,t=!1){let o="",n="",i=["#fff","#ffffff","white","rgb(255, 255, 255)","rgba(255, 255, 255, 1)","rgba(0, 0, 0, 0)","transparent"];return["color","background","background-color","font-size","font-family","letter-spacing","font-weight","text-transform"].forEach((r=>{!t&&"background-color"===r&&i.includes(s.getStyle(e,r))?(o+="background-color: green;",o+="color: white;"):o+=`${r}:${s.getStyle(e,r)};`,"color"===r&&(n=`${s.getStyle(e,r)};`)})),o.length?{fetchedCSS:o,addToCartSpinnerStrokeColor:n}:void 0},setBtnCSS:function(e,t=!1){if(d&&d.version>=4){let o=s.getBtnCSS(e,t);if(o){let e=t?`.lb-tpae-confirm-button{\n${o.fetchedCSS}\n}\n.tpae-order-spinner circle{\nstroke: ${o.addToCartSpinnerStrokeColor}\n}`:`.lb-upsell-modal-product-primary{\n${o.fetchedCSS}\n}\n.lb-upsell-primary-spinner circle{\nstroke: ${o.addToCartSpinnerStrokeColor}\n}\n .lb-addon-popup-continue-btn{\n${o.fetchedCSS}\n}.lb-addon-popup-continue-spinner circle{\nstroke: ${o.addToCartSpinnerStrokeColor}\n}`;s.appendCustomTextCssToHead(e,"lb-upsell-checkout-css")}}},addCheckoutListenerToElements:function(e,t,o,n){for(let i=0;i<e.length;i++)e[i]&&"true"!==e[i].getAttribute(t)&&(e[i].setAttribute(t,"true"),s.setBtnCSS(e[i]),e[i].addEventListener?e[i].addEventListener("click",(function(t){o(t,e[i],n,!0)}),!0):e[i].attachEvent("onclick",(function(t){o(t,e[i],n,!0)}),!0))},addCartSubmitClickListener:function(e,t,o){let n=e.querySelectorAll("button[type='submit'][name='checkout'], input[type='submit'][name='checkout']");if(n&&s.addCheckoutListenerToElements(n,d.version>=18?"lb-upsell-default-checkout-listener":"listener",o,e),0===n.length){let n=e.querySelectorAll("button[name='checkout'], input[name='checkout']");if(n&&n.length)s.addCheckoutListenerToElements(n,d.version>=18?"lb-upsell-default-checkout-listener":"listener",o,e);else{let n=document.querySelectorAll("button[name='checkout'], input[name='checkout']"),i=[];for(let e=0;e<n.length;e++)"true"!==n[e].getAttribute(d.version>=18?"lb-upsell-default-checkout-listener":"lb-upsell-listener")&&t.some((t=>t===n[e].getAttribute("form")))&&i.push(n[e]);i&&i.length&&s.addCheckoutListenerToElements(i,d.version>=18?"lb-upsell-default-checkout-listener":"lb-upsell-listener",o,e)}}s.log("Added cart submit listeners.")},getFormattedProductHandle:function(e){const t=e.split("/");return t&&t.length&&t[t.length-1]},getGraphQLProduct:async function(e){return new Promise(((t,o)=>{let i=window&&window.Shopify&&window.Shopify.locale,r=window&&window.Shopify&&window.Shopify.country;if(i){let o=`query productDetails @inContext(country: ${r}, language: ${i.toLocaleUpperCase().replace("-","_")}) {\n productByHandle(handle: "${e}") {\n handle\n }\n }`;var s=new XMLHttpRequest;s.open("POST",`https://${window.location.hostname}/api/${n.API_VERSION}/graphql.json`,!0),s.setRequestHeader("Content-Type","application/json; charset=UTF-8"),s.setRequestHeader("X-Shopify-Storefront-Access-Token",d.storeFrontAccessToken),s.setRequestHeader("Access-Control-Allow-Origin","*"),s.send(JSON.stringify({query:o})),s.onload=()=>{if(200===s.status){let o=JSON.parse(s.responseText);o&&o.data&&o.data.productByHandle&&o.data.productByHandle.handle?t(o.data.productByHandle.handle):t(e)}else console.log("Error while getting cart")},s.onerror=()=>{console.log("Error while getting cart")}}}))},getProduct:function(e,t=void 0){return new Promise(((o,n)=>{let i=s.getRootRoute();if(!d.storeFrontAccessToken&&!t&&i&&"/"!==i&&d&&d.handleMultiLangProductHandle){let t=s.getProductRequestURL(e);t=t.replace(".js",""),(r=new XMLHttpRequest).open("GET",t,!0),r.setRequestHeader("Content-Type","application/json; charset=UTF-8"),r.send(),r.onload=()=>{if(200===r.status&&r.responseURL!==t){let e=s.getFormattedProductHandle(r.responseURL);s.getProduct(void 0,e).then((e=>{o(e)})).catch((()=>{o(void 0)}))}else s.getProduct(e,e).then((e=>{o(e)})).catch((()=>{o(void 0)}))}}else if(d.storeFrontAccessToken&&!t&&d&&d.handleMultiLangProductHandle)s.getGraphQLProduct(e).then((e=>{s.getProduct(void 0,e).then((e=>{o(e)})).catch((()=>{o(void 0)}))}));else{let n=s.getProductRequestURL(t||e);var r;(window.lbUpsellComponents&&window.lbUpsellComponents.isServerFetchForced||window&&window.navigator&&window.navigator.userAgent&&window.navigator.userAgent.includes("Mac","iPhone","iPad","iPod"))&&(n=`${n}?t=${(new Date).getTime()}`),(r=new XMLHttpRequest).open("GET",n,!0),r.setRequestHeader("Content-Type","application/json; charset=UTF-8"),r.send(),r.onload=()=>{200===r.status?o(JSON.parse(r.responseText)):(404===r.status&&s.debugLog(`${e}, product is out of stock.`),o(void 0))}}}))},getProducts:function(e){return new Promise(((t,o)=>{let n=[];e.forEach((e=>{n.push(s.getProduct(e))})),Promise.all(n).then((e=>{e&&e.length&&(e=e.filter((e=>e))),t(e)}))}))},isImgAvailable:function(e){return e&&e.featured_image||e&&e.media&&e.media.length&&e.media[0].src},getCart:function(e){return new Promise(((t,o)=>{var n=new XMLHttpRequest;n.open("GET",`https://${e}/cart.js`,!0),n.setRequestHeader("Content-Type","application/json; charset=UTF-8"),n.setRequestHeader("Access-Control-Allow-Origin","*"),n.send(),n.onload=()=>{200===n.status?t(JSON.parse(n.responseText)):o("Error while getting cart")},n.onerror=()=>{o("Error while getting cart")}}))},getWidgetSetup:function(e,t){return e&&e.widgets&&e.widgets.length?e.widgets.find((e=>e.type===t)):void 0},removeExistingStyleTag:function(e){let t=document.getElementById(e);t&&(s.log("Removing existing style tag"),t.remove())},appendCustomTextCssToHead:function(e,t){t&&s.removeExistingStyleTag(t);let o=e,n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");n.appendChild(i),i.type="text/css",i.id=t,i.styleSheet?i.styleSheet.cssText=o:i.appendChild(document.createTextNode(o))},formatPrice:function(e,t){e/=100;let o=(Math.round(100*e)/100).toFixed(2);return t?Math.round(Number(o||"0")):o},getStyle:function(e,t){var o,n=(e.ownerDocument||document).defaultView;return n&&n.getComputedStyle?(t=t.replace(/([A-Z])/g,"-$1").toLowerCase(),n.getComputedStyle(e,null).getPropertyValue(t)):e.currentStyle?(t=t.replace(/\-(\w)/g,(function(e,t){return t.toUpperCase()})),o=e.currentStyle[t],/^\d+(em|pt|%|ex)?$/i.test(o)?function(t){var o=e.style.left,n=e.runtimeStyle.left;return e.runtimeStyle.left=e.currentStyle.left,e.style.left=t||0,t=e.style.pixelLeft+"px",e.style.left=o,e.runtimeStyle.left=n,t}(o):o):void 0},getRandomSortOrder:function(e){let t=[];for(;t.length<e;){let o=Math.floor(Math.random()*e)+1;-1===t.indexOf(o)&&t.push(o)}return t},getPresentmentCurrency:function(){return window.Shopify&&window.Shopify.currency?window.Shopify.currency:void 0},getRootRoute:function(){return window.Shopify&&window.Shopify.routes?window.Shopify.routes.root:void 0},getCurrentLocale:function(){return window.Shopify&&window.Shopify.locale?window.Shopify.locale:void 0},isDiscountStacked:function(){return!(!window.discountOnCartProApp||!window.discountOnCartProApp.applyCode)},applyStackDiscount:function(e){s.isDiscountStacked()&&(s.log("Applying stacked discount"),window.discountOnCartProApp.applyCode(e.code))},removeStackDiscount:function(e){window.discountOnCartProApp&&window.discountOnCartProApp.removeCode&&window.discountOnCartProApp.removeCode(e.code)},getProductRequestURL:function(e){let t=s.getRootRoute(),o=`https://${window.location.hostname}/products/${e}.js`;return t&&"/"!==t&&(o=`https://${window.location.hostname}${t}products/${e}.js`),o},addItemsToCart:function(e,t=void 0,o=!1){return new Promise(((n,i)=>{let r=s.getRootRoute(),d=`https://${window.location.hostname}${r||"/"}cart/add.js${o&&window.lbDealeasy?"?src=selleasy":""}`,l=new XMLHttpRequest;l.open("POST",d,!0),l.setRequestHeader("Content-Type","application/json; charset=UTF-8"),l.send(JSON.stringify(e)),l.onload=function(){200===l.status?(n("success"),!t&&window.lbUpsellComponents&&void 0!==window.lbUpsellComponents.validateAndFetchDiscount&&s.getCart(window.location.hostname).then((e=>{window.lbUpsellComponents.validateAndFetchDiscount(e)})).catch((e=>{console.log("Error while fetching cart: discount",e)}))):i(l.status)},l.onerror=e=>{s.log("Error while adding items to cart",e)}}))},updateCart:function(e){return new Promise(((t,o)=>{let n=s.getRootRoute(),i=new XMLHttpRequest;i.open("POST",`https://${window.location.hostname}${n||"/"}cart/update.js`,!0),i.setRequestHeader("Content-Type","application/json; charset=UTF-8"),i.send(JSON.stringify(e)),i.onload=function(){200===i.status?t("success"):o(i.statusText)},i.onerror=e=>{s.log("Error while updateCart cart",e)}}))},arrayUnique:function(e){let t=e.concat();for(let e=0;e<t.length;++e)for(let o=e+1;o<t.length;++o)t[e]===t[o]&&t.splice(o--,1);return t},triggerCustomEvent:function(e,t){window.dispatchEvent&&window.dispatchEvent(new CustomEvent(t||"lb-upsell-added",{detail:e}))},getURLParam:function(e,t){if("shop"===e&&t&&t.includes("/assets/lb-upsell.js"))return window&&window.lbShopDomain&&window.lbShopDomain.length?window.lbShopDomain:Shopify&&Shopify.shop?Shopify.shop:void 0;var o=new RegExp("[?&]"+e+"=([^&#]*)").exec(t);return null==o?null:decodeURI(o[1])||0},getCSSEnhancements:function(e){let t=".lb-upsell-prevent-scroll{overflow:hidden!important}.lb-upsell-variants-select{padding-right:25px!important}.ppa-add-checkbox-input,.ppa-prod-checkbox-left,.ppa-prod-checkbox-left-grid{height:16px!important;width:16px!important}.ppcse-spinner{margin:0!important}.ppcse-close{font-weight:250!important;color:#5f5f5f!important}.ppcse-modal-prod-price{font-size:18px!important;margin:0 0 16px!important;padding:0!important}.ppcse-modal-prod-price b{font-weight:initial!important}.ppcse-modal-prod-title{margin:0 0 16px!important;padding:0!important;font-size:21px!important}.ppcse-modal-form-label,.stepper-label{font-weight:400!important;font-size:13px!important;margin-bottom:0!important}.lb-upsell-modal-form-label{margin-bottom:4px!important}.ppcse-modal-prod-desc iframe,.ppcse-modal-prod-desc img,select.ppcse-modal-form-control{width:100%!important}.ppcse-modal-cart-btn{margin-bottom:20px!important;line-height:normal!important;cursor:pointer!important}.ppcse-modal-prod-img{padding-right:15px!important;padding-left:15px!important}.lb-upsell-modal-container,.lb-upsell-modal-wrap,.ppcse-modal-wrap{z-index:2147483647!important}.lb-upsell-modal-bg,.ppcse-modal-bg{z-index:2147483646!important}.ppcse-img-lt{margin-right:0!important;margin-bottom:0!important}.ppcse-tot-container{padding-right:0!important}.ppcse-m{overflow:hidden}.ppa-prod-img{height:100px!important;width:100px!important}.ppa-add-btn-cont-grid,.ppa-add-checkbox-cont-grid{margin-top:auto!important}.ppa-add-checkbox-cont-grid{padding-top:6px}.ppa-prod-container-grid-margin{margin-bottom:15px!important}.ppa-add-checkbox-spinner{margin:3px 0!important}.lb-upsell-ppa-spinner-list-checkbox-left{margin:3px 10px 3px 3px!important}.ppa-prod-container{min-height:100px!important}.lb-upsell-modal-product-secondary:focus,.lb-upsell-modal-product-secondary:hover{background:var(--lb-upsell-puf-skip-btn-bg-color,#efefef)!important;color:var(--lb-upsell-puf-skip-btn-text-color,#000)!important}.lb-upsell-modal-product-details-variants select,.stepper-container-minus,.stepper-container-plus{border-color:#bbb!important}.stepper-container-input{border-left:0!important;border-right:0px!important;border-color:#bbb!important}.lb-upsell-modal-offer-name{padding:14px!important;font-weight:700!important}";return e>=8&&(s.log("Appendin css enhancements 2",d.version),t+=".ppcse-compare-at-price{display:inline!important}.lb-upsell-ppa-carousel{margin-right:5px!important}.lb-upsell-modal-product-details-title{font-size:large!important;padding-top:0!important}.lb-upsell-modal-offer-name{text-align:center!important}.lb-upsell-modal-timer-container{width:96%!important;border-radius:4px!important}.lb-upsell-modal-product-img{border:1px solid #f5f5f5!important}.lb-upsell-modal-product-details-variants select{width:100%!important}.ppcse-tot-container-tot{padding-top:0!important}@media only screen and (max-width:768px){.ppa-add-to-cart-btn,.ppcs-variants-form-select{width:100px!important}}"),e>=15&&(s.log("Appendin css enhancements 3",d.version),t+=".lb-upsell-addon-popup-card .lb-shared-variants-select,.lb-upsell-product-page-card .lb-shared-variants-select,lb-tq-page-upsell .lb-shared-variants-select{width:92px;padding-right:20px!important;background-image:unset!important;min-height:32px;border-color:#d3d3d3!important;outline:0!important;box-shadow:none;margin:0!important}.lb-upsell-product-page-card select{appearance:auto}.lb-upsell-product-page-card .lb-spc-carousel-cont{background-color:#fff;appearance:auto}.lb-upsell-addon-popup-card .lb-spc-details-name,.lb-upsell-addon-popup-card .lb-spc-details-price-cont,.lb-upsell-product-page-card .lb-spc-details-name,.lb-upsell-product-page-card .lb-spc-details-price-cont,lb-tq-page-upsell .lb-spc-details-name,lb-tq-page-upsell .lb-spc-details-price-cont{line-height:21px!important}.lb-prod-prev-price-cont,.lb-upsell-addon-popup-card .lb-spc-details-price-cont,.lb-upsell-product-page-card .lb-spc-details-price-cont,lb-tq-page-upsell .lb-spc-details-price-cont{margin-top:0}.lb-upsell-addon-popup-card .lb-spc-image-cont,.lb-upsell-product-page-card .lb-spc-image-cont,lb-tq-page-upsell .lb-spc-image-cont{margin:9px 0 9px 4px;height:75px;width:75px}.lb-upsell-addon-popup-card .lb-spc-image,.lb-upsell-product-page-card .lb-spc-image,lb-tq-page-upsell .lb-spc-image{height:75px;width:75px;background:#fff}.lb-upsell-addon-popup-card .lb-spc-details-cont,.lb-upsell-product-page-card .lb-spc-details-cont,lb-tq-page-upsell .lb-spc-details-cont{margin:8px}.lb-upsell-addon-popup-card .lb-spc-details-btm,.lb-upsell-product-page-card .lb-spc-details-btm,lb-tq-page-upsell .lb-spc-details-btm{margin-top:6px!important}.lb-upsell-product-page-card .lb-spc-added-var-cont{max-width:358px!important}.lb-upsell-product-page-card .lb-spc-details-btn,.lb-upsell-product-page-card .lb-spc-qty-cont{max-width:86px!important;width:92px;border-color:#d3d3d3!important}.lb-upsell-addon-popup-card .lb-spc-qty-cont,lb-tq-page-upsell .lb-spc-qty-cont{background:#fff;border-color:#d3d3d3!important}.lb-upsell-modal-product-details-title{font-size:18px;line-height:27px;font-weight:400;padding:4px 0 2px}.lb-tpae-upsell{max-width:400px}.lb-prod-prev-price-cont b{font-weight:400}.lb-prod-prev-img-wrap{border:none}.lb-prod-prev-img-index{margin:6px}.lb-prod-preview-desc{overflow-y:overlay}.lb-prod-prev-title{line-height:30px}.lb-prod-prev-price-cont{line-height:16px}.lb-upsell-modal-product-details-quantity{margin:16px 0}.lb-upsell-modal-product-details-variants{padding-top:8px}.lb-upsell-modal-product-details-variants .lb-shared-variants-select{width:100%;border-radius:8px;border-color:#d3d3d3!important}.stepper-container-input,.stepper-container-minus,.stepper-container-plus{border-color:#d3d3d3!important}.lb-prod-prev-variants-cont .lb-shared-variants-select{border-color:#d3d3d3!important;outline:0!important;box-shadow:none!important}.lb-upsell-ppa-card-cont{margin-bottom:var(--lb-upsell-ppa-margin-bottom,20px)}.lb-upsell-ppa-title-cont{margin-top:16px!important}.lb-spc-check-cont-bundle{width:16px;height:16px;border:1px solid var(--lb-spc-cta-bg)}.lb-spc-check-cont-class{background:#fff!important;border:1px solid #d3d3d3}.lb-spc-check-cont-disabled{pointer-events:none;opacity:.5}@media (max-width:480px){.lb-addon-popup-title,.lb-upsell-modal-title{font-size:16px}.lb-addon-popup-subtitle,.lb-upsell-modal-timer-container-new{font-size:14px}.lb-upsell-modal-product-img-cont{margin-right:0!important}.lb-upsell-modal-product-img{height:200px!important}.lb-upsell-modal-nav{top:-126.5px!important}lb-upsell-addon-popup .lb-spc-cont{width:100%!important}lb-upsell-addon-popup .lb-spc-details-variants .lb-shared-variants-select{width:92px!important;padding-right:25px!important}.lb-prod-prev-body-cont-height{min-height:50vh!important;max-height:54vh!important}.lb-upsell-modal-body{max-height:calc(60vh - 160px)}.lb-addon-popup-container{max-height:60vh!important}.lb-addon-popup-body{max-height:calc(60vh - 134px)!important}.lb-addon-popup-body-max-height{max-height:calc(60vh - var(--lb-addon-popup-body-max-height))!important}}@media (min-width:961px){.lb-addon-popup-container{max-height:82vh!important}.lb-addon-popup-body{max-height:calc(82vh - 134px)!important}.lb-addon-popup-body-max-height{max-height:calc(82vh - var(--lb-addon-popup-body-max-height))!important}.lb-upsell-modal-body{max-height:calc(82vh - 160px)}.lb-prod-prev-body-cont-height{max-height:70vh!important}}@media (min-width:1025px){.lb-addon-popup-container{max-height:77vh!important}.lb-addon-popup-body{max-height:calc(77vh - 134px)!important}.lb-addon-popup-body-max-height{max-height:calc(77vh - var(--lb-addon-popup-body-max-height))!important}.lb-upsell-modal-body{max-height:calc(77vh - 160px)}}"),t},isCartPage:function(){return-1!==window.location.pathname.indexOf("/cart")},getSampleSnippetSetup:function(){return{isEnabled:!0,isSubscribed:!0,shopCurrencyCode:"INR",version:15,shopCurrencyFormat:"Rs. ",shopEmailCurrencyFormat:"Rs. ",isAmountNoDecimals:!1,accountMetricId:"f6b96261-76f2-4498-a3ad-550d3510c839",widgets:[{content:{totalLabel:"Total price",addToCartSuccessMsg:"Added to your cart!",thisItemLabel:"",title:"Frequently Bought Together",buttonLabel:"Add to cart"},createdAt:1626088296638,myShopifyDomain:"lb-upsell-demo.myshopify.com",isEnabled:!0,styles:{mobile:{imageHeight:"75px",widgetMargin:"20px 0px 20px 0px "},desktop:{imageHeight:"100px",widgetMargin:"40px 0px 40px 0px "}},position:{mobile:{insertPosition:"afterend",selector:".product-form"},desktop:{insertPosition:"afterend",selector:".product-form"}},useShopifyProductRecommendations:!0,maxItemsInOffer:2,recordType:"widget#ppcse",widgetMetricId:"fd647d99-6991-4970-a2d6-cebf0890807a",type:"product-page-cross-sell-embedded-widget",addToCartAction:"redirect",recommendationDiscount:{isEnabled:!0,type:"percentage",value:10,description:"Get {{discount}} off on bundle!"}},{content:{addToCartSuccessMsg:"Added to cart",removeBtnLabel:"Remove",title:"Select addons",addToCartBtnLabel:"Add to cart",addedToCartBtnLabel:"Added"},myShopifyDomain:"hp-dev-1.myshopify.com",isEnabled:!0,position:{mobile:{insertPosition:"beforebegin",selector:"addToCartBtn"},desktop:{insertPosition:"beforebegin",selector:"addToCartBtn"}},layoutStyle:"card-list",addActionStyle:"checkbox",productClickActionStyle:"popup",useShopifyProductRecommendations:!0,recordType:"widget#ppa",type:"product-page-addon-widget",widgetMetricId:"e28a6f2f-547a-4201-b151-0643caf4e32a",addToCartAction:"trigger",recommendationDiscount:{isEnabled:!0,type:"percentage",value:10}},{content:{totalLabel:"Total",countDownTimerText:"Limited time offer! Expires in {{timer}}",continueBtnLabel:"Continue",countDownTimerMins:5,countDownTimerSecs:0,addToCartBtnLabel:"Add",widgetDiscountLabel:"Limited time offer! Expires in {{timer}}",widgetTitle:"You might also like these"},createdAt:1659774736998,myShopifyDomain:"hp-dev-2.myshopify.com",isMultipleVariantsAdded:!0,isEnabled:!0,recordType:"widget#cppa",widgetMetricId:"18e31faf-0a17-4e57-aa4f-f5fbd587401f",type:"popup-cart-addons-widget"}]}}}}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var o=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](o,o.exports,__webpack_require__),o.exports}(function(window){const ppcseWidget=__webpack_require__(156),ppaWidget=__webpack_require__(298),pufWidget=__webpack_require__(380),tpaeWidget=__webpack_require__(305),cartPageUtils=__webpack_require__(693),cartUpdate=__webpack_require__(226),metrics=__webpack_require__(276),utils=__webpack_require__(980),discounts=__webpack_require__(645),checkoutHandler=__webpack_require__(993),addToCartHandler=__webpack_require__(681),setupHandler=__webpack_require__(738);let HOST_NAME=utils.getHostName(),setup,cart,callbackResults={isWidgetScriptLoaded:!1,isSetupLoaded:!1,isCartLoaded:!1};function processPufWidget(){let e=utils.getWidgetSetup(setup,"popup-upsell-funnel-widget");if(e&&e.isEnabled){let t=document.createElement("lb-upsell-modal");if(document.body.append(t),e.isPreRenderingEnabled){let e,t=utils.getWidgetSetup(setup,"product-page-cross-sell-embedded-widget"),o=discounts.getDiscountFromStorage();t&&t.isEnabled&&o&&o.code&&(e=o.code.includes("BUNDLL")&&discounts.isDiscountValid(cart,o)),pufWidget.pufWidgetLib().initiateOffer(setup,cart,!e,!1)}}}function processPcaWidget(){let e=utils.getWidgetSetup(setup,"popup-cart-addons-widget");if(e&&e.isEnabled){let e=document.createElement("lb-upsell-addon-popup");document.body.append(e)}}function renderWidgets(){window.lbUpsellComponents&&(window.lbUpsellComponents.isEnabled=setup&&setup.isEnabled),setup&&setup.isEnabled?(discounts.process(setup,cart),ppcseWidget.ppcseWidgetLib().render(setup,cart),ppaWidget.ppaWidgetLib().render(cart),tpaeWidget.TpaeWidgetLib().render(setup),checkoutHandler.registerListeners(setup),!setup||setup.version>=18||addToCartHandler.registerListeners(),window.location.pathname.includes("/orders/")||window.location.pathname.includes("/checkouts/")?utils.log("Cart page widgets will not be loaded in TQ page"):setup&&setup.version<15&&(processPufWidget(),processPcaWidget()),executeCustomJs(),registerMutationObserver(),registerCartChangeListeners(),setup.version>=18&&cartUpdate.addCartUpdateListener(),discounts.validateStackDiscount(setup,cart),discounts.validateAndFetchDiscount(cart),utils.isCartPage()&&setup.version>=13&&cartPageUtils.prerenderCartOffer()):utils.log("App Not enabled in admin")}function registerCartChangeListeners(){if(window.lbUpsellComponents&&!window.lbUpsellComponents.isFetchIgnored){const e=["/cart/update","/cart/change"],t=window.XMLHttpRequest.prototype.open;window.XMLHttpRequest.prototype.open=function(){return this.addEventListener("load",(function(){if(this._url&&e.some((e=>this._url.includes(e)))){utils.log("XML listener URL",this._url);try{JSON.parse(this.responseText)&&discounts.handleDiscountAfterClick()}catch(e){utils.log("Error on network listener")}}})),t.apply(this,arguments)};const{fetch:o}=window;window.fetch=async(...t)=>{let[n,i]=t,r=await o(n,i);return r&&"function"==typeof r.clone&&r.clone().json().then((function(t){n&&e.some((e=>n.includes(e)))&&discounts.handleDiscountAfterClick()})).catch((e=>{})),r}}if(setup&&setup.version>=13&&utils.isCartPage()){utils.log("Registerred registerCartChangeListeners");const e=["/cart/add","/cart/update","/cart/change","/cart/clear"],t=window.XMLHttpRequest.prototype.open;window.XMLHttpRequest.prototype.open=function(){return this.addEventListener("load",(function(){e.some((e=>this._url&&this._url.includes(e)))&&(utils.log("XML listener URL",this._url),localStorage.removeItem("lb-upsell-cart-prerendered-data"),utils.triggerCustomEvent({url:this._url},"lb-upsell-cart-updated"))})),t.apply(this,arguments)},function(t,o){"function"==typeof o&&(utils.log("Running ns fetch"),t.fetch=function(){var t=o.apply(this,arguments);return t.then((t=>{t&&t.url&&e.some((e=>t.url.includes(e)))&&(utils.log("Fetch listener URL",t.url),utils.triggerCustomEvent({url:t.url},"lb-upsell-cart-updated"))})),t})}(window,window.fetch),window.addEventListener("lb-upsell-cart-updated",(function(e){utils.log("lb-upsell-cart-updated event:",e),localStorage.removeItem("lb-upsell-cart-prerendered-data"),cartPageUtils.prerenderCartOffer()}))}}function registerMutationObserver(){if(setup.version>=10){const e=new MutationObserver((e=>{e&&e.length&&e.forEach((e=>{if(e.addedNodes&&e.addedNodes.length)for(let t of e.addedNodes)if(t&&t.querySelectorAll)if(setup.checkoutBtnSelector)window.lbUpsellComponents.registerCheckoutListeners(!0,t);else{let e=t.querySelectorAll("button[type='submit'][name='checkout'], input[type='submit'][name='checkout'], a[href='/checkout']");e.length&&(utils.log("mutationObserver checkoutNodes",e),void 0!==window.lbUpsellComponents&&window.lbUpsellComponents.registerCheckoutListeners(),setup.customDiscountHelpPosition&&setup.customDiscountHelpSelector&&(utils.log("Calling discounts.process as customDiscountHelpPosition is set"),utils.getCart(window.location.hostname).then((e=>{discounts.process(setup,e)}))))}}))})),t=document.querySelector("body");e.observe(t,{childList:!0,subtree:!0})}}function executeCustomJs(){setup&&setup.isEnabled&&setup.customJs&&setup.customJs.length&&(utils.log("Running custom Js"),eval(setup.customJs))}function appendFloatingToastToBody(){if(window.location.pathname.includes("/cart")){let e=document.querySelector("ppcse-floting-toast");e&&e.remove();const t=document.createElement("ppcse-floting-toast");document.body.append(t)}}function appendProductDetailsModalToBody(){let e=utils.getWidgetSetup(setup,"product-page-cross-sell-embedded-widget"),t=utils.getWidgetSetup(setup,"product-page-addon-widget");if(!utils.isCartPage()&&setup&&setup.version<15&&(e&&e.isEnabled||t&&t.isEnabled)){utils.removeExistingWidget("ppcse-modal");const e=document.createElement("ppcse-modal");document.body.append(e)}if(setup&&setup.version>=15&&setup.offers&&setup.offers.length&&!utils.isCartPage()&&setup.offers.some((e=>"frequently-bought-bundle"===e.upsellType||"product-addons"===e.upsellType))&&(e&&e.isEnabled||t&&t.isEnabled)){utils.removeExistingWidget("lb-upsell-product-preview");const e=document.createElement("lb-upsell-product-preview");document.body.append(e)}}function callbackHandler(e,t){"widget"===e?callbackResults.isWidgetScriptLoaded=!0:"setup"===e?(setup=t||setup,callbackResults.isSetupLoaded=!0):"cart"===e&&(callbackResults.isCartLoaded=!0),callbackResults.isSetupLoaded&&(utils.setSetup(setup),setup.version>=6&&(utils.log("Appendin css enhancements",setup.version),utils.appendCustomTextCssToHead(utils.getCSSEnhancements(setup.version),"lb-upsell-enhancements-css"))),callbackResults.isSetupLoaded&&setup&&setup.isEnabled&&setup.diyCss&&setup.diyCss.formattedCss&&setup.diyCss.formattedCss.length&&utils.appendCustomTextCssToHead(`${setup.diyCss.formattedCss}`,"lb-upsell-diy-css"),callbackResults.isSetupLoaded&&setup&&setup.isEnabled&&setup.customCSS&&setup.customCSS.length&&utils.appendCustomTextCssToHead(setup.customCSS,"lb-upsell-custom-css"),callbackResults.isWidgetScriptLoaded&&callbackResults.isSetupLoaded&&setup&&setup.isEnabled&&appendFloatingToastToBody(),callbackResults.isSetupLoaded&&setup&&setup.isEnabled&&callbackResults.isWidgetScriptLoaded&&appendProductDetailsModalToBody(),callbackResults.isWidgetScriptLoaded&&callbackResults.isSetupLoaded&&callbackResults.isCartLoaded&&("complete"===document.readyState||"interactive"===document.readyState?renderWidgets():document.addEventListener("DOMContentLoaded",(function(){renderWidgets()})))}function initWidgets(){if(0===getScriptCount(scripts,!0)){var e=`${HOST_NAME}/lb-upsell-components/lb-upsell-components.esm.js`,t=document.createElement("script");t.defer=!0,t.readyState?t.onreadystatechange=function(){"loaded"!=t.readyState&&"complete"!=t.readyState||(utils.log("Widget script loaded successfully."),t.onreadystatechange=null,callbackHandler("widget"))}:t.onload=function(){utils.log("Widget script loaded successfully."),callbackHandler("widget")},t.src=e,t.type="module",document.getElementsByTagName("head")[0].appendChild(t)}else utils.log("componentScriptCount !== 0."),callbackHandler("widget")}function getScriptSrc(e){let t;for(let o=0;o<e.length;o++){let n=(e[o]?.src||e[o]?.getAttribute("data-src"))+"";if(n?.includes("/lb-upsell.js")){t=n;break}}return t}function getScriptCount(e,t=!1){let o=0;for(let n=0;n<e.length;n++)(t&&e[n].src&&e[n].src.includes("/lb-upsell-components.esm.js")||!t&&e[n].src&&(e[n].src.startsWith(`${HOST_NAME}/lb-upsell.js?shop=`)||e[n].src.includes("/assets/lb-upsell.js")))&&o++;return o}function getUserType(){const e=localStorage.getItem("lb-upsell-userType");if(e)return e;{const e=0===Math.round(Math.random())?"A":"B";return localStorage.setItem("lb-upsell-userType",e),e}}function initAssets(e){window.lbUpsell={isInitialized:!0},utils.isCartPage()&&localStorage.removeItem("lb-upsell-cart-prerendered-data"),initWidgets(e),getUserType(),setupHandler.getSetup(e,callbackHandler),utils.getCart(window.location.hostname).then((e=>{cart=e,cart&&cart.item_count&&cart.item_count>0&&discounts.validateAndFetchDiscount(cart),callbackHandler("cart")})).catch((e=>{utils.log("err while fetching cart:",e)}))}void 0===window.lbUpsellComponents&&(window.lbUpsellComponents={ppcseWidget:ppcseWidget.ppcseWidgetLib(),pufWidget:pufWidget.pufWidgetLib(),ppaWidget:ppaWidget.ppaWidgetLib(),tpaeWidget:tpaeWidget.TpaeWidgetLib(),registerCheckoutListeners:checkoutHandler.registerListeners,registerAddToCartListeners:addToCartHandler.registerListeners,handleUpsellFunnelCheckout:void 0,validateAndFetchDiscount:discounts.validateAndFetchDiscount,renderSelleasyCheckoutPopup:checkoutHandler.renderSelleasyCheckoutPopup});let scripts=document.getElementsByTagName("script"),IS_SNIPPET_TESTING=utils.isSnippetTesting();if(IS_SNIPPET_TESTING)console.log("Testing mode is enabled. Metrics will not work."),initWidgets(),setup=utils.getSampleSnippetSetup(),callbackResults.isCartLoaded=!0,callbackHandler("setup");else if("complete"===document.readyState&&getScriptCount(scripts)>1)utils.log("Script registered in head and scriptTag, so skipped running the script from scriptTag");else{const e=getScriptSrc(scripts);let t=utils.getURLParam("shop",e);if(t&&t.includes(" ")&&(t=t.replace(/\s/g,"")),window.location.pathname.includes("/orders/")||window.location.pathname.includes("/checkouts/")){const e=localStorage.getItem("lbUpselPixel");e?localStorage.removeItem("lbUpselPixel"):metrics.trackConversion()}const o="true"===utils.getURLParam("isNotRenderedInHome",e)&&"/"===window.location.pathname;o||window.lbUpsell&&(!window.lbUpsell||window.lbUpsell.isInitialized)?utils.log("Not initalising assests - isNotRenderedInHome - ",o):t?initAssets(t):utils.log("myShopifyDomain not found")}})(window)})();