PageSourceSearch

https://riddleoil.com/cdn/shop/t/146/assets/custom.js?v=67156653615365453651787772355

js riddleoil.com collected 2026-09-26 06:51:09 UTC 32,191 bytes, 26 lines download raw bytes

1document.addEventListener("DOMContentLoaded",event=>{window.collectionPageCustomFilters();function applyRcWidgetChanges(){document.querySelector(".rc_widget .rc-option__subsave .rc_widget__option__selector label span").innerHTML="Subscribe",document.querySelector(".rc_widget .rc-option__subsave .rc-selling-plans").insertAdjacentHTML("afterbegin",`
2    <div class="subscription-details">
3        <div class="sub-details-item">
4          <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
5            <g opacity="0.72">
6            <path d="M12.6667 3.3335L3.33333 12.6668M11.3333 12.6668C10.9797 12.6668 10.6406 12.5264 10.3905 12.2763C10.1405 12.0263 10 11.6871 10 11.3335C10 10.9799 10.1405 10.6407 10.3905 10.3907C10.6406 10.1406 10.9797 10.0002 11.3333 10.0002C11.687 10.0002 12.0261 10.1406 12.2761 10.3907C12.5262 10.6407 12.6667 10.9799 12.6667 11.3335C12.6667 11.6871 12.5262 12.0263 12.2761 12.2763C12.0261 12.5264 11.687 12.6668 11.3333 12.6668ZM4.66666 6.00016C4.31304 6.00016 3.9739 5.85969 3.72385 5.60964C3.4738 5.35959 3.33333 5.02045 3.33333 4.66683C3.33333 4.31321 3.4738 3.97407 3.72385 3.72402C3.9739 3.47397 4.31304 3.3335 4.66666 3.3335C5.02028 3.3335 5.35942 3.47397 5.60947 3.72402C5.85952 3.97407 6 4.31321 6 4.66683C6 5.02045 5.85952 5.35959 5.60947 5.60964C5.35942 5.85969 5.02028 6.00016 4.66666 6.00016Z" stroke="#101820" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
7            </g>
8          </svg>
9          <span>Save 10% off your third order and all future orders.</span>
10        </div>
11        <div class="sub-details-item">
12          <svg xmlns="http://www.w3.org/2000/svg" width="16" height="17" viewBox="0 0 16 17" fill="none">
13            <g opacity="0.72">
14            <path fill-rule="evenodd" clip-rule="evenodd" d="M5.99999 3.8335C6.17681 3.8335 6.34637 3.90373 6.4714 4.02876C6.59642 4.15378 6.66666 4.32335 6.66666 4.50016V12.5002C6.66666 12.677 6.59642 12.8465 6.4714 12.9716C6.34637 13.0966 6.17681 13.1668 5.99999 13.1668C5.82318 13.1668 5.65361 13.0966 5.52859 12.9716C5.40357 12.8465 5.33333 12.677 5.33333 12.5002V4.50016C5.33333 4.32335 5.40357 4.15378 5.52859 4.02876C5.65361 3.90373 5.82318 3.8335 5.99999 3.8335ZM9.99999 3.8335C10.1768 3.8335 10.3464 3.90373 10.4714 4.02876C10.5964 4.15378 10.6667 4.32335 10.6667 4.50016V12.5002C10.6667 12.677 10.5964 12.8465 10.4714 12.9716C10.3464 13.0966 10.1768 13.1668 9.99999 13.1668C9.82318 13.1668 9.65361 13.0966 9.52859 12.9716C9.40357 12.8465 9.33333 12.677 9.33333 12.5002V4.50016C9.33333 4.32335 9.40357 4.15378 9.52859 4.02876C9.65361 3.90373 9.82318 3.8335 9.99999 3.8335Z" fill="#101820"/>
15            </g>
16          </svg>
17          <span>Pause, edit, or cancel anytime.</span>
18        </div>
19    </div>
20  `),document.querySelectorAll(".rc_widget .rc-selling-plans__dropdown option").forEach(item=>{let optionText=item.text.split("Delivery every")[1];item.text=optionText}),document.querySelectorAll(".rc_widget label.rc_widget__option__label").forEach(el=>{el.closest(".rc-option").addEventListener("click",function(e){if(!e.currentTarget.classList.contains("rc-option--active")){const label=e.currentTarget.querySelector("label");if(label){const clickEvent=new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window});label.dispatchEvent(clickEvent)}else console.warn("Label not found within the current target.")}})})}const intervalId=setInterval(()=>{document.querySelector(".rc_widget")&&(clearInterval(intervalId),applyRcWidgetChanges())},500),tabLinks=document.querySelectorAll('.link-tabs-items a[href*="#"]'),offset=110;tabLinks.forEach(function(link){link.addEventListener("click",function(event2){event2.preventDefault();const targetElement=document.querySelector(this.hash);if(targetElement){const topPosition=targetElement.getBoundingClientRect().top+window.scrollY-offset;window.scrollTo({top:topPosition,behavior:"smooth"})}})}),document.querySelectorAll("[data-disclosure-currency]").forEach(function(currencySelector){currencySelector.querySelectorAll("[data-disclosure-option]").forEach(function(option){option.addEventListener("click",function(event2){event2.preventDefault();const currencyCode=option.getAttribute("data-value"),newUrl=`${window.location.origin}?currency=${currencyCode}`;fetchCurrency(newUrl)})});function fetchCurrency(newUrl){fetch(newUrl).then(response=>{response.ok?location.reload():console.error("Failed to fetch currency data.")}).catch(error=>{console.error("Error fetching currency data: ",error)})}});function elementsToRender(selectedVariant,closestDiv){try{return[{element:closestDiv.querySelector(".grid-product__meta .grid-product__title"),content:selectedVariant.title,appendType:"innerHTML",attribute_name:""},{element:closestDiv.querySelector(".grid-meta-container .grid-product__title"),content:selectedVariant.title,appendType:"innerHTML",attribute_name:""},{element:closestDiv.querySelector(".grid-product__meta .grid-product__price"),content:`from ${theme.Currency.formatMoney(selectedVariant.price_min,theme.settings.moneyFormat)}`,appendType:"innerHTML",attribute_name:""},{element:closestDiv.querySelector(".grid-product__content .grid-product__image-mask"),content:window.collCustomGroupProductsImages[selectedVariant.id]?.custom_image||"",appendType:"innerHTML",attribute_name:""},{element:closestDiv.querySelector(".grid__item-image-wrapper .grid-product__link"),
20content:window.collCustomGroupProductsImages[selectedVariant.id]?.url||"#",appendType:"href",attribute_name:""},{element:closestDiv.querySelector(".grid-product__content .custom-product--tags"),content:window.collCustomGroupProductsImages[selectedVariant.id]?.product_tags||"#",appendType:"innerHTML",attribute_name:""},{element:closestDiv.querySelector(".product__card--url"),content:window.collCustomGroupProductsImages[selectedVariant.id]?.url||"#",appendType:"attribute",attribute_name:"data-url"},{element:closestDiv.querySelector(".product__card--url"),content:window.collCustomGroupProductsImages[selectedVariant.id]?.sku_id||"",appendType:"attribute",attribute_name:"data-sku"},{element:closestDiv.querySelector(".product__card--url"),content:window.collCustomGroupProductsImages[selectedVariant.id]?.name||"",appendType:"attribute",attribute_name:"data-name"},{element:closestDiv.querySelector(".product__card--url"),content:window.collCustomGroupProductsImages[selectedVariant.id]?.price||"",appendType:"attribute",attribute_name:"data-price"}]}catch(error){return console.error("Error generating elementsToRender array:",error),[]}}window.applyVariantChangeEvent=function(){const isHoverDevice=window.matchMedia("(hover: hover) and (pointer: fine)").matches;document.querySelectorAll("[custom-variant-change]").forEach(el=>{el.classList.contains("event-added")||(el.classList.add("event-added"),isHoverDevice&&(el.addEventListener("mouseover",function(e){try{const selectedVariant=window.collCustomGroupProducts[e.currentTarget.dataset.currentValue];let parentElement=e.currentTarget.closest(".grid__item-image-wrapper");if(!selectedVariant){console.error("Selected variant not found for:",e.currentTarget.dataset.currentValue);return}const activeOption=e.currentTarget.closest(".custom-variant-selector-wrapper")?.querySelector(".custom-variant-options.active");activeOption?activeOption.classList.remove("active"):console.warn("Active custom-variant-option not found!"),e.currentTarget.classList.add("active");const closestDiv=e.currentTarget.closest(".grid__item");if(closestDiv.classList.add("grid-hover"),!closestDiv){console.error("Closest .grid__item not found for the clicked element!");return}elementsToRender(selectedVariant,closestDiv).forEach(({element,content,appendType,attribute_name})=>{if(element)try{switch(appendType){case"innerHTML":const newElement2=document.createElement("div");newElement2.innerHTML=content,newElement2.querySelectorAll("image-element")&&newElement2.querySelectorAll("image-element").length>0&&newElement2.querySelectorAll("image-element").forEach(element2=>{element2.className="aos-init aos-animate"}),element.innerHTML=newElement2.innerHTML;break;case"href":element.setAttribute("href",content);break;case"src":element.setAttribute("src",content);break;case"replace":const newElement=document.createElement("div");newElement.innerHTML=content,element.replaceWith(newElement);break;case"attribute":element.setAttribute(attribute_name,content);break;default:console.warn(`Unknown appendType: ${appendType}`)}}catch(updateError){console.error("Error updating element:",element,updateError)}else console.warn("Target element not found for update!")}),this.quickView=parentElement.querySelector(".quick-product__btn"),theme.preloadProductModal(e.currentTarget.dataset.productHandle,e.currentTarget.dataset.productId,parentElement.querySelector(".quick-product__btn")),this.quickView.addEventListener("click",function(e2){this.modal=new theme.Modals(`QuickShopModal-${e2.target.dataset.productId}`),this.modal.open(e2)});const imageElement=closestDiv.querySelector(".grid-product__content .grid-product__image-mask .image-element");imageElement?imageElement.style.opacity=1:console.warn("Image element not found for opacity update!")}catch(error){console.error("Error in click event handler:",error)}}),el.addEventListener("mouseout",function(e){const closestDiv=e.currentTarget.closest(".grid__item");e.currentTarget.classList.remove("active"),closestDiv.classList.remove("grid-hover")})),el.addEventListener("click",function(e){window.location.href=e.currentTarget.getAttribute("data-product-url")}
20),el.addEventListener("touchend",function(e){e.preventDefault(),window.location.href=e.currentTarget.getAttribute("data-product-url")}))}),document.querySelectorAll(".grid__item").forEach(el=>{let firstButton=el.querySelectorAll("[custom-variant-change]")[0];firstButton&&isHoverDevice&&(firstButton.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0})),firstButton.classList.remove("active"))})},window.applyVariantChangeEvent()}),document.addEventListener("variant:change",function(e){try{const stickyProductBar=document.querySelector(".sticky-product-bar");if(!stickyProductBar)return;const stickyATCButton=stickyProductBar.querySelector(".sticky-ATC-btn .sticky-add-to-cart");if(!stickyATCButton)return;e.detail.variant&&e.detail.variant.available?(stickyATCButton.removeAttribute("disabled"),stickyATCButton.innerHTML="Add To Bag"):(stickyATCButton.setAttribute("disabled",""),stickyATCButton.innerHTML="Sold Out")}catch(error){console.error("An error occurred while handling the 'variant:change' event:",error)}}),window.matchHeight=function(selector){const elements=document.querySelectorAll(selector);function setEqualHeight(){let maxHeight=0;elements.forEach(element=>{element.style.height="auto";const elementHeight=element.clientHeight;elementHeight>maxHeight&&(maxHeight=elementHeight)}),elements.forEach(element=>{element.style.height=`${maxHeight}px`})}setEqualHeight(),window.addEventListener("resize",setEqualHeight)},window.matchHeight(".community-saying-item-desc"),window.matchHeight(".community-saying-item-content");const flickityViewport=document.querySelector(".rebuy-cart__flyout-recommendations .flickity-viewport");if(flickityViewport&&new ResizeObserver(()=>{const newHeight=flickityViewport.offsetHeight;document.querySelectorAll(".rebuy-cart__flyout-recommendations .flickity-viewport .rebuy-product-block").forEach(el=>{el.style.minHeight=`${newHeight}px`})}).observe(flickityViewport),window.updateCartDependencies=function(){setTimeout(function(){document.querySelector(".header-item .js-drawer-open-cart .cart-link__bubble").innerHTML=window.Rebuy.SmartCart.itemCount()==0?"":window.Rebuy.SmartCart.itemCount(),document.querySelector(".header-item .js-drawer-open-cart .cart-link__bubble").classList.remove("visually-hidden")},1e3),window.fetchShopPayCartWidget(),window.addTermsAndConditionsClickEvent()},window.fetchShopPayCartWidget=function(){fetch("/cart",{method:"GET",headers:{"Content-Type":"text/html"}}).then(response=>{if(!response.ok)throw new Error(`HTTP error! Status: ${response.status}`);return response.text()}).then(htmlContent=>{const shopPayWidget=new DOMParser().parseFromString(htmlContent,"text/html").querySelector("[shop-pay-cart-widget]");if(shopPayWidget){document.body.classList.add("shop-pay-widget-adding"),document.querySelector(".rebuy-cart__flyout [shopify-payment-terms-rebuy-smartcart] shopify-payment-terms")&&(document.querySelector(".rebuy-cart__flyout [shopify-payment-terms-rebuy-smartcart]").innerHTML=""),document.querySelector(".rebuy-cart__flyout [shopify-payment-terms-rebuy-smartcart]")&&(document.querySelector(".rebuy-cart__flyout [shopify-payment-terms-rebuy-smartcart]").innerHTML=shopPayWidget.innerHTML);const shopPayInstallmentsBanner=document.querySelector("div[shopify-payment-terms-rebuy-smartcart] shopify-payment-terms")?.shadowRoot?.querySelector("shop-pay-installments-banner")?.shadowRoot;if(shopPayInstallmentsBanner){const shopifyInstallments=shopPayInstallmentsBanner.querySelector(".shopify-installments"),prequalRowWrapper=shopPayInstallmentsBanner.querySelector(".shopify-installments__prequal-row-wrapper");shopifyInstallments&&(shopifyInstallments.style.fontSize="13px",shopifyInstallments.style.letterSpacing="-0.02em",shopifyInstallments.style.lineHeight="18.2px",shopifyInstallments.style.color="#101820"),prequalRowWrapper&&(prequalRowWrapper.style.display="none"),setTimeout(()=>{const boldText=shopifyInstallments?.querySelector("b");boldText&&(boldText.style.fontWeight="400")},100)}setTimeout(function(){document.body.classList.remove("shop-pay-widget-adding")},2e3)}else console.error("Shop Pay Cart Widget not found!")}).catch(error=>{console.error("Error fetching /cart:",error)})},window.addTermsAndConditionsClickEvent=function(){try{const tacButton=document.querySelector("#rebuy-cart .rebuy-cart__flyout-footer .rebuy-cart__flyout-actions a");if(!tacButton)throw new Error("The 'Terms and Conditions' button element is not found.");if(tacButton.classList.contains("event_added"))return;tacButton.classList.add("event_added"),tacButton.addEventListener("click",function(e){try{if(e.preventDefault(),window.tacModal&&window.tacModal.style)window.tacModal.style.transform="translateX(0)";else throw new Error("The 'Terms and Conditions' modal (tacModal) is not properly defined.")}catch{}})}catch{}},document.addEventListener("rebuy:smartcart.init",event=>{window.updateCartDependencies()}),document.addEventListener("rebuy:smartcart.show",event=>{window.updateCartDependencies(),document.querySelector("#rebuy-cart__progress-bar-meter-label")?.click()}),document.addEventListener("rebuy:cart.add",event=>{window.updateCartDependencies()}),document.addEventListener("rebuy:smartcart.line-item-increase",event=>{window.updateCartDependencies()}),document.addEventListener("rebuy:smartcart.line-item-decrease",event=>{window.updateCartDependencies()}),document.addEventListener("rebuy:smartcart.line-item-removed",event=>{window.updateCartDependencies()}),document.querySelectorAll(".link-tabs-items a").length>0){const tabLinks=document.querySelectorAll(".link-tabs-items a");tabLinks.forEach(link=>{link.addEventListener("click",function(event){tabLinks.forEach(link2=>link2.classList.remove("active")),this.classList.add("active")})})}document.addEventListener("DOMContentLoaded",event=>{window.location.href.includes("/products/")&&document.querySelector("#gift-box-product")&&document.querySelector("#gift-box-product").addEventListener("click",function(e){try{if(e.currentTarget.checked){const inputElement=document.querySelector(".variant-wrapper fieldset input[value*='with gift box']");if(!inputElement)return;const labelElement=inputElement.parentNode.querySelector("label");if(!labelElement)return;labelElement.click()}else{const labelElement=document.querySelector(".variant-wrapper fieldset .variant-input label");if(!labelElement){console.error("Default label not found.");return}labelElement.click()}}catch{}});
20try{if(document.querySelector("[data-custom-checked-variant-title]")&&document.querySelector("[data-custom-checked-variant-title]").dataset.customCheckedVariantTitle.trim()!=""){const inputElement=document.querySelector(`[data-value="${document.querySelector("[data-custom-checked-variant-title]").dataset.customCheckedVariantTitle.trim()}"] input`)||document.querySelector(`[data-value="${document.querySelector("[data-custom-checked-variant-title-with-zeros]").dataset.customCheckedVariantTitleWithZeros.trim()}"] input`);if(!inputElement)throw new Error("Element with [data-value='"+document.querySelector("[data-custom-checked-variant-title]").dataset.customCheckedVariantTitle.trim()+"'] input not found in the DOM.");const clickEvent=new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window});inputElement.dispatchEvent(clickEvent)}}catch(error){console.error("An error occurred:",error.message)}if("ontouchstart"in window||navigator.maxTouchPoints>0){let hideAllHoverTexts2=function(){propItems.forEach(item=>item.classList.remove("active"))};var hideAllHoverTexts=hideAllHoverTexts2;const propItems=document.querySelectorAll(".value-prop-item");console.log(propItems),propItems.forEach(item=>{const inner=item.querySelector(".value-prop-item-inner"),closeBtn=item.querySelector(".value-hover-text-close");inner?.addEventListener("click",function(e){e.stopPropagation();const isActive=item.classList.contains("active");hideAllHoverTexts2(),isActive?item.classList.remove("active"):(hideAllHoverTexts2(),item.classList.add("active"))}),closeBtn&&closeBtn?.addEventListener("click",function(e){e.stopPropagation(),item.classList.remove("active")})})}document.addEventListener("click",function(e){const isInsideHoverText=e.target.closest(".value-hover-text"),isInsideValuePropItem=e.target.closest(".value-prop-item");!isInsideHoverText&&!isInsideValuePropItem&&document.querySelector(".value-prop-item.active")?.classList.remove("active")})}),document.querySelectorAll(".load-more-wrapper .load-more").length>0&&(eventSelectors={_loadMoreButton:document.querySelector(".load-more-wrapper .load-more"),_currentPage:1},window.loadMoreProducts={_init:function(){this._eventBinder(),this._resetValuesOnFilterChange(),this._bindProductCardClick()}
20,_eventBinder:function(){eventSelectors._loadMoreButton=document.querySelector(".load-more-wrapper .load-more"),eventSelectors._loadMoreButton.addEventListener("click",this._handleLoadMore.bind(this),!0)},_updatePageQueryParam:function(url,newPage){const urlObj=new URL(url);return urlObj.searchParams.set("page",newPage),urlObj.toString()},_handleLoadMore:function(event){event.preventDefault(),document.querySelectorAll(".pagination-wrapper").length>0&&(eventSelectors._totalPages=parseInt(document.querySelector(".pagination-wrapper").dataset.total_pages),eventSelectors._currentPage<=eventSelectors._totalPages&&(eventSelectors._currentPage=eventSelectors._currentPage+1,fetchUrl=this._updatePageQueryParam(window.location.href,eventSelectors._currentPage),this._fetchAndAppendProductGrids(fetchUrl),this._showHideLoadMoreButton()))},_extractAndExecuteScript:function(htmlData){let scripts=htmlData.getElementsByTagName("script");for(let script of scripts){let scriptContent=script.innerText.trim();if(scriptContent)try{if(scriptContent.startsWith("{")&&scriptContent.endsWith("}"))continue;new Function(scriptContent)()}catch(error){console.error("Error executing script:",error,`
21Script Content:
22`,scriptContent)}}},_fetchAndAppendProductGrids:function(fetchUrl2){fetch(fetchUrl2).then(response=>response.text()).then(html=>{const tempDiv=document.createElement("div");tempDiv.innerHTML=html;const productGrid=tempDiv.querySelector("#product-grid");if(this._extractAndExecuteScript(tempDiv.querySelector("#CollectionAjaxContent")),productGrid){const childElements=productGrid.children,targetElement=document.querySelector("#product-grid");for(let i=0;i<childElements.length;i++)targetElement.appendChild(childElements[i].cloneNode(!0));document.querySelectorAll(".image-element").forEach(el=>{el.style.opacity=1}),this._bindProductCardClick(),window.applyVariantChangeEvent()}else console.log("#product-grid not found in the HTML.")}).catch(error=>{console.error("Error fetching data:",error)})},_showHideLoadMoreButton(){eventSelectors._currentPage>
22=eventSelectors._totalPages?eventSelectors._loadMoreButton.classList.add("hidden"):eventSelectors._loadMoreButton.classList.remove("hidden")},_resetValuesOnFilterChange:function(){document.querySelectorAll(".pagination-wrapper").length==0&&eventSelectors._loadMoreButton.classList.add("hidden"),eventSelectors._currentPage=1},_bindProductCardClick:function(){document.querySelectorAll(".product__card--url").forEach(card=>{card.addEventListener("click",function(event){event.target.closest(".custom-variant-options")})})}},window.loadMoreProducts._init()),document.addEventListener("filter:changed",()=>{window.loadMoreProducts._init(),window.collectionPageCustomFilters()}),window.collectionPageCustomFilters=function(){document.querySelector(".js-custom-drawer-open-collection-filters")&&document.querySelector(".js-custom-drawer-open-collection-filters").addEventListener("click",function(e){e.currentTarget.closest(".collection-filter__item").querySelector(".top__filter--content").classList.toggle("hidden"),e.currentTarget.classList.toggle("custom-filter-drawer-open")})},document.addEventListener("DOMContentLoaded",function(){document.querySelector(".product-review-label-review")?.addEventListener("click",function(event){event.preventDefault();const reviewsSection=document.querySelector("#okendo-reviews-section");if(reviewsSection){const topPosition=reviewsSection.getBoundingClientRect().top+window.scrollY-100;window.scrollTo({top:topPosition,behavior:"smooth"})}});try{window.tacModal=document.getElementById("tac-modal"),window.tacModalClose=document.querySelector(".tac-modal-close"),window.tacModalClose&&(window.tacModalClose.onclick=function(){window.tacModal&&(window.tacModal.style.transform="translateX(100%)")}),window.onclick=function(event){event.target===window.tacModal&&window.tacModal&&(window.tacModal.style.transform="translateX(100%)")}}catch{}}),document.querySelectorAll(".product__card--url").forEach(card=>{card.addEventListener("click",function(event){if(!event.target.closest(".custom-variant-options")){console.log("Event Fired !!");let closestCvo=event.currentTarget;gtag("event","select_item",{item_list_name:"Product Grid",send_to:["G-0GD84Z6336","MC-20KHS0MSN5"],items:[{item_id:`${closestCvo.dataset.sku?closestCvo.dataset.sku:""}`,item_name:`${closestCvo.dataset.name?closestCvo.dataset.name:""}`,price:`${closestCvo.dataset.price?closestCvo.dataset.price:""}`}]}),dataLayer.push({event:"select_item",item_list_name:"Product Grid",ecommerce:{items:[{item_id:`${closestCvo.dataset.sku?closestCvo.dataset.sku:""}`,item_name:`${closestCvo.dataset.name?closestCvo.dataset.name:""}`,price:`${closestCvo.dataset.price?closestCvo.dataset.price:""}`}]}})}})}),document.querySelectorAll('.link-tabs-items a[href^="#"]').forEach(link=>{const targetId=link.getAttribute("href").slice(1);document.getElementById(targetId)||link.classList.add("invalid-anchor")}),window.handleGiftBoxToggle=function(event,item,currentItemKey,newVariantId){event.target.disabled=!0;const isChecked=event.target.checked;window.rebuy&&window.rebuy.smartCart&&window.rebuy.smartCart.ui.showLoading(),fetch("/cart.json").then(response=>{if(!response.ok)throw new Error(`Failed to fetch cart. Status: ${response.status}`);return response.json()}).then(cartData=>{const currentItem=cartData.items.find(cartItem=>cartItem.key===currentItemKey);if(!currentItem)throw new Error(`Item with key ${currentItemKey} not found in cart`);const quantity=currentItem.quantity,sellingPlanId=currentItem.selling_plan_allocation?.selling_plan.id;return fetch("/cart/change.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:currentItemKey,quantity:0})}).then(response=>{if(!response.ok)throw new Error(`Failed to remove item. Status: ${response.status}`);return response.json()}).then(()=>{if(!newVariantId)throw new Error("New variant ID is missing or invalid");const newItemData={items:[{id:newVariantId,quantity}]};return sellingPlanId&&(newItemData.items[0].selling_plan=sellingPlanId),fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(newItemData)})}).then(response=>{if(!response.ok)throw new Error(`Failed to add new item. Status: ${response.status}`);return response.json()})}).then(()=>{window.rebuy&&window.rebuy.smartCart&&window.rebuy.smartCart.refresh()}).catch(error=>{event.target.checked=!isChecked,window.rebuy&&window.rebuy.smartCart&&window.rebuy.smartCart.ui.showError("Failed to update gift box option. Please try again.")}).finally(()=>{event.target.disabled=!1,window.rebuy&&window.rebuy.smartCart&&window.rebuy.smartCart.ui.hideLoading()})},window.isGiftBoxVariant=function(item){return item.title.toLowerCase().includes("gift box")},window.getGiftBoxVariantId=function(item){if(!item||!item.product||!item.product.variants)return null;const variant=item.product.variants.find(v=>v.title.toLowerCase().includes("gift box"));return variant?variant.id:null},window.getRegularVariantId=function(item){if(!item||!item.product||!item.product.variants)return null;const variant=item.product.variants.find(v=>!v.title.toLowerCase().includes("gift box"));return variant?variant.id:null},document.addEventListener("DOMContentLoaded",function(){const secondaryATC=document.querySelector(".custom-secondary-product-button");secondaryATC&&secondaryATC.addEventListener("click",function(){const variantId=this.dataset.variantId;fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({id:variantId,quantity:1})}).then(response=>response.json()).then(data=>{console.log("Added to cart:",data)}).catch(err=>console.error("Add to cart failed:",err))})}),document.querySelector("#custom-klaviyo-bis-button-container button")&&document.querySelector("#custom-klaviyo-bis-button-container button").addEventListener("click",function(e){klaviyo.openForm("WwkNej")}),document.addEventListener("DOMContentLoaded",function(){function observeElement(waitFor,callback,minElements=1,isVariable=!1,timer=5e4,frequency=25){const $this=this;let elements=isVariable?window[waitFor]:document.querySelectorAll(waitFor);timer<=0||(!isVariable&&elements.length>=minElements||isVariable&&typeof window[waitFor]<"u"?callback(elements):setTimeout(()=>
22observeElement(waitFor,callback,minElements,isVariable,timer-frequency),frequency))}function initializeUpgradeFeature(){let Data20ml=window.DataFromColl20ml,cartItemsCount=0;const btnIcon=`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
23      <path d="M7.917 4.25L9.095 7.238L12.083 8.417L9.095 9.595L7.917 12.583L6.738 9.595L3.75 8.417L6.738 7.238L7.917 4.25Z" fill="white"/>
24      <path d="M7.917 3.833C8.087 3.833 8.242 3.938 8.304 4.097L9.416 6.917L12.236 8.029C12.3136 8.05984 12.3801 8.11327 12.427 8.18235C12.4739 8.25144 12.4989 8.33301 12.4989 8.4165C12.4989 8.49999 12.4739 8.58156 12.427 8.65065C12.3801 8.71973 12.3136 8.77316 12.236 8.804L9.416 9.916L8.304 12.736C8.27316 12.8136 8.21973 12.8801 8.15065 12.927C8.08156 12.9739 7.99999 12.9989 7.9165 12.9989C7.83301 12.9989 7.75144 12.9739 7.68235 12.927C7.61327 12.8801 7.55984 12.8136 7.529 12.736L6.417 9.916L3.597 8.804C3.51942 8.77316 3.45288 8.71973 3.406 8.65065C3.35912 8.58156 3.33405 8.49999 3.33405 8.4165C3.33405 8.33301 3.35912 8.25144 3.406 8.18235C3.45288 8.11327 3.51942 8.05984 3.597 8.029L6.417 6.917L7.529 4.097C7.56005 4.01938 7.61357 3.95278 7.68269 3.90575C7.75181 3.85872 7.8334 3.83339 7.917 3.833ZM7.917 5.386L7.126 7.39C7.10488 7.4431 7.07314 7.49133 7.03273 7.53173C6.99233 7.5
247214 6.9441 7.60388 6.891 7.625L4.886 8.415L6.891 9.207C6.944 9.22801 6.99217 9.25959 7.03257 9.29982C7.07298 9.34005 7.10476 9.38809 7.126 9.441L7.916 11.447L8.708 9.441C8.72912 9.38818 8.76076 9.34021 8.80098 9.29998C8.84121 9.25976 8.88918 9.22812 8.942 9.207L10.948 8.416L8.942 7.625C8.88909 7.60376 8.84105 7.57198 8.80082 7.53157C8.76059 7.49117 8.72901 7.443 8.708 7.39L7.917 5.386ZM4.167 3L4.697 4.136L5.833 4.666L4.697 5.197L4.167 6.333L3.637 5.197L2.5 4.667L3.636 4.137L4.167 3Z" fill="white"/>
25      </svg>`;function checkIfSmallRollOn(item){if(!item||!item.querySelector(".rebuy-cart__title a"))return!1;const title=item.querySelector(".rebuy-cart__title a").textContent.toLowerCase();return title.includes("roll-on")&&title.includes("8ml")&&item.querySelector(".rebuy-cart__flyout-item-subscription .rebuy-button")}function hasGiftBoxVariant(item){return!item||!item.querySelector(".rebuy-cart__flyout-item-variant-title")?!1:item.querySelector(".rebuy-cart__flyout-item-variant-title").textContent.includes("gift box")}function convertToLargeSize(title){return title.replace("8ml","20ml")}function parsePrice(priceText){return Number(priceText.replace(/[^\d.-]/g,""))}function retrieveLargeProductData(item){const title=item.querySelector(".rebuy-cart__title a").textContent.toLowerCase(),title20ml=convertToLargeSize(title);return Data20ml[title20ml]}function submitProductToCart(id,productId,quantity=1,isSub=!1,sellingPlanId){const formData=new FormData;return formData.append("form_type","product"),formData.append("utf8","\u2713"),formData.append("id",id),formData.append("product-id",productId),formData.append("quantity",quantity),isSub&&formData.append("selling_plan",sellingPlanId),fetch("/cart/add.js",{method:"POST",body:formData}).then(response=>response.json()).catch(error=>{throw console.error("Error adding product:",error),error})}function renderUpgradeButtons(){cartItemsCount=parseInt(document.querySelector("div#rebuy-cart h2#rebuy-cart-title span.count")?.textContent)||0,document.querySelectorAll(".rebuy-cart ul[data-smartcart-items] > li").forEach((item,index)=>{if(item.classList.contains("_showUpgradeSubBtn")||item.classList.add("_showUpgradeSubBtn"),checkIfSmallRollOn(item)&&!item.querySelector(".upgrade20mlBtn")){const productPrice8ml=parsePrice(item.querySelector(".rebuy-money > span:last-child").textContent),product20ml=retrieveLargeProductData(item),labelEl=item.querySelector(".rebuy-cart__flyout-item-quantity-widget-label"),quantity=labelEl?labelEl.childNodes[labelEl.childNodes.length-1].textContent.trim():null;if(product20ml){item.classList.contains("_20mlBtnAdded")||item.classList.add("_20mlBtnAdded");const productPrice20ml=parsePrice(hasGiftBoxVariant(item)?product20ml.gift.price:product20ml.normal.price),id=hasGiftBoxVariant(item)?product20ml.gift.id:product20ml.normal.id,productId=product20ml.productId,formattedPriceDifference=(productPrice20ml-productPrice8ml).toFixed(2),upgradeBtn=`<button class="upgrade20mlBtn" data-id="${id}" data-product-id="${productId}"> ${btnIcon} Upgrade to 20ml +$${formattedPriceDifference}</button>`;item.querySelector(".rebuy-cart__flyout-item-subscription .rebuy-button").insertAdjacentHTML("afterend",upgradeBtn),item.querySelector(".upgrade20mlBtn").addEventListener("click",()=>processUpgradeClick(item,id,productId))}}item.classList.contains("_showUpgradeSubBtn")||item.classList.add("_showUpgradeSubBtn")})}function processUpgradeClick(item,id,productId){const labelEl=item.querySelector(".rebuy-cart__flyout-item-quantity-widget-label"),quantity=labelEl?labelEl.childNodes[labelEl.childNodes.length-1].textContent.trim():null;console.log(quantity),submitProductToCart(id,productId,quantity).then(()=>{item.querySelector("button.rebuy-cart__flyout-item-remove").click()}).catch(error=>{console.error("Error adding product:",error)})}renderUpgradeButtons(),observeElement("div#rebuy-cart",elements=>{var mutationCallback=function(mutationsList){renderUpgradeButtons()},observer=new MutationObserver(mutationCallback),observerOptions={childList:!0,attributes:!0,subtree:!0,characterData:!0};observer.observe(document.querySelector("div#rebuy-cart"),observerOptions)})}initializeUpgradeFeature()});
26//# sourceMappingURL=/cdn/shop/t/146/assets/custom.js.map?v=67156653615365453651787772355

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.