1(function(){"use strict";const DRAWER_SCOPE_SELECTOR="cart-drawer-component, .cart-drawer";function debounce(fn,wait){let timer=0;return function(){window.clearTimeout(timer),timer=window.setTimeout(fn,wait)}}function runIsolated(fn){try{fn()}catch(error){window.setTimeout(()=>{throw error})}}function setMiniCartActiveTab(root,name){const tabs=Array.from(root.querySelectorAll("[data-bv-tab]")),panels=Array.from(root.querySelectorAll("[data-bv-panel]"));if(!(!tabs.length||!panels.length)&&(tabs.forEach(btn=>{const isActive=btn.getAttribute("data-bv-tab")===name;btn.classList.toggle("is-active",isActive),btn.setAttribute("aria-selected",isActive?"true":"false")}),panels.forEach(panel=>{const isActive=panel.getAttribute("data-bv-panel")===name;panel.classList.toggle("is-active",isActive),panel.setAttribute("aria-hidden",isActive?"false":"true")}),name==="auctions")){const target=document.querySelector(".wishlist-replace");target&&loadMinicartWishlist(target)}}function initMiniCartTabs(root){const tabs=Array.from(root.querySelectorAll("[data-bv-tab]")),panels=Array.from(root.querySelectorAll("[data-bv-panel]"));if(!tabs.length||!panels.length)return;function activate(name){setMiniCartActiveTab(root,name)}tabs.forEach(btn=>{btn.addEventListener("click",()=>{const tab=btn.getAttribute("data-bv-tab");(tab==="cart"||tab==="auctions")&&activate(tab)})}),activate("cart")}function bootTabs(){document.querySelectorAll(".bv-mini-cart").forEach(initMiniCartTabs)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",bootTabs):bootTabs();function resetMiniCartTabs(){document.querySelectorAll(".bv-mini-cart").forEach(root=>{root instanceof HTMLElement&&setMiniCartActiveTab(root,"cart")})}let cartPriceRefreshInFlight=!1;function getCartSectionIds(){const sectionIds=Array.from(document.querySelectorAll("cart-items-component[data-section-id]")).map(element=>element.getAttribute("data-section-id")).filter(Boolean);return sectionIds.includes("cart-drawer")||sectionIds.push("cart-drawer"),sectionIds.filter((id,index,arr)=>arr.indexOf(id)===index)}async function refreshCartDrawerPricesOnOpen(){if(!cartPriceRefreshInFlight){cartPriceRefreshInFlight=!0,window.__BV_CART_PRICE_REFRESH_UNTIL=Date.now()+1500;try{const cartResponse=await fetch("/cart.js",{credentials:"same-origin",cache:"no-store",headers:{Accept:"application/json"}});if(!cartResponse.ok)throw new Error("Cart state could not be loaded");const cart=await cartResponse.json(),items=Array.isArray(cart&&cart.items)?cart.items:[],sections=getCartSectionIds(),updates={};items.forEach(item=>{item&&item.key&&(updates[item.key]=item.quantity)});const updateResponse=await fetch("/cart/update.js",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({updates,sections:sections.join(","),sections_url:window.location.pathname})}),updatedCart=await updateResponse.json();if(!updateResponse.ok)throw new Error(updatedCart.description||updatedCart.message||"Cart prices could not be refreshed");document.dispatchEvent(new CustomEvent("cart:update",{detail:{data:{itemCount:Number(updatedCart.item_count)||0,source:"cart-price-refresh",sections:updatedCart.sections||{}},cart:updatedCart}})),document.dispatchEvent(new CustomEvent("cart:updated",{detail:{cart:updatedCart}}))}catch(error){console.warn("[BV Mini Cart] Cart price refresh failed:",error)}finally{cartPriceRefreshInFlight=!1,window.__BV_CART_PRICE_REFRESH_UNTIL=Date.now()+300}}}function applyDeviceFingerpintToCart(){if(window.fn_device_fingerprint_sdk){var deviceData=window?.fn_device_fingerprint_sdk?.device;if(deviceData){const fingerprintValue=JSON.parse(deviceData),attributesToAdd={};if(fingerprintValue?.device?.screenHeight&&fingerprintValue?.device?.screenWidth&&(attributesToAdd.resolution=`${fingerprintValue.device.screenWidth}x${fingerprintValue.device.screenHeight}`),fingerprintValue?.user_agent&&(attributesToAdd.userAgent=fingerprintValue.user_agent),fingerprintValue?.fingerprint_id&&(attributesToAdd.fingerPrintID=fingerprintValue.fingerprint_id),fingerprintValue?.device?.hasSessionStorage&&(attributesToAdd.cookieSupport=!0),fingerprintValue?.device?.colorDepth&&(attributesToAdd.colorDepth=fingerprintValue?.device?.colorDepth),fingerprintValue?.device?.timezoneOffset&&(attributesToAdd.timezoneOffset=fingerprintValue.device.timezoneOffset),fingerprintValue?.device?.hasLocalStorage&&(attributesToAdd.localstorageSupport=!0),fingerprintValue?.device?.screenHeight&&(attributesToAdd.screenHeight=fingerprintValue?.device?.screenHeight),fingerprintValue?.device?.screenWidth&&(attributesToAdd.screenWidth=fingerprintValue?.device?.screenWidth),!Object.keys(attributesToAdd).length)return;fetch("/cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:attributesToAdd})}).catch(function(err){console.error("Failed to save device_id to cart attributes:",err)})}}}let minicartWishlistLoading=!1;const euroFormatter=new Intl.NumberFormat("de-DE",{style:"currency",currency:"EUR"});function getWishlistApiUrl(endpoint=""){const proxy=window.WISHLIST_PROXY||"/apps/wishlist",baseUrl=proxy.endsWith("/")?proxy.slice(0,-1):proxy,path=endpoint.startsWith("/")?endpoint:`/${endpoint}`;return`${baseUrl}${path}`}function escapeHtml(value){return String(value||"").replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function formatEuro(value){return euroFormatter.format(Number(value||0))}function renderWishlistProduct(item){const variant=item.variant;if(!variant||!variant.id)return"";const productUrl=`/products/${item.handle}?variant=${variant.id}`,title=item.title||"Untitled product",image=variant.image||window.themeAssetUrls?.noImage||"/assets/icon-noimage.png",price=Number(variant.price||0),compareAtPrice=Number(variant.compareAtPrice||0),showCompareAtPrice=compareAtPrice>price,availableForSale=variant.availableForSale!==!1&&Number(variant.quantity||0)>0;return` 2 <div 3 class="cart-wishlist__product wishlist-product" 4 data-pid="${escapeHtml(item.productId)}" 5 data-product-id="${escapeHtml(item.productId)}" 6 data-variant-id="${escapeHtml(variant.id)}" 7 > 8 <div class="wishlist-product__image"> 9 <a href="${productUrl}"> 10 <img 11 class="wishlist-product__image-img" 12 src="${escapeHtml(image)}" 13 alt="${escapeHtml(title)}" 14 title="${escapeHtml(title)}" 15 loading="lazy" 16 > 17 </a> 18 </div> 19 20 <div class="wishlist-product__content"> 21 <div class="wishlist-product__header"> 22 <div class="wishlist-product__name"> 23 <a href="${productUrl}"> 24 ${escapeHtml(title)} 25 </a> 26 </div> 27 28 <div class="wishlist-product__remove"> 29 <button 30 type="button" 31 class="js-remove-from-wishlist" 32 data-variant-id="${escapeHtml(variant.id)}" 33 aria-label="Remove from wishlist" 34 > 35 <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> 36 <path d="M3 6.09091H20M9.76136 15.9432V10.1477M13.2386 15.9432V10.1477M13.2386 3H9.76136C9.45395 3 9.15913 3.12212 8.94176 3.33949C8.72439 3.55686 8.60227 3.85168 8.60227 4.15909V6.09091H14.3977V4.15909C14.3977 3.85168 14.2756 3.55686 14.0582 3.33949C13.8409 3.12212 13.54
366 3 13.2386 3ZM16.8009 18.9336C16.7794 19.224 16.6487 19.4955 16.435 19.6934C16.2214 19.8912 15.9407 20.0008 15.6495 20H7.35045C7.05927 20.0008 6.77859 19.8912 6.56495 19.6934C6.35132 19.4955 6.22059 19.224 6.19909 18.9336L5.125 6.09091H17.875L16.8009 18.9336Z" stroke="#191919" stroke-linecap="round" stroke-linejoin="round"></path> 37 </svg> 38 </button> 39 </div> 40 </div> 41 42 <div class="wishlist-product__prices"> 43 <div class="wishlist-product__price salesPrice"> 44 ${formatEuro(price)} 45 </div> 46 47 ${showCompareAtPrice?`<div class="wishlist-product__price listPrice">${formatEuro(compareAtPrice)}</div>`:'<div class="wishlist-product__price originalPrice d-none"></div>'} 48 </div> 49 50 ${variant.title&&variant.title!=="Default Title"?` 51 <div class="wishlist-product__attributes"> 52 <div class="wishlist-product__attribute"> 53 Gr\xF6\xDFe: ${escapeHtml(variant.title)} 54 </div> 55 </div> 56 `:""} 57 58 <div class="error-message"></div> 59 60 <div class="wishlist-product__button"> 61 <button 62 type="button" 63 class="js-add-to-cart" 64 data-variant-id="${escapeHtml(variant.id)}" 65 ${Number(variant.quantity)>0?`data-quantity-left="${escapeHtml(String(Number(variant.quantity)))}"`:""} 66 ${availableForSale?"":"disabled"} 67 > 68 <span>${availableForSale?"In den Warenkorb":"Ausverkauft"}</span> 69 </button> 70 </div> 71 </div> 72 </div> 73 `}function renderWishlistShell(itemsHtml,isEmpty=!1){return` 74 <div class="cart-wishlist js-wishlist-container"> 75 <div class="cart-wishlist__messages" style="display:none;"> 76 <div class="cart-wishlist__messages-text"> 77 <span>Dieser Artikel wurde Ihrem Warenkorb hinzugef\xFCgt.</span> 78 </div> 79 </div> 80 81 <div class="cart-wishlist__products" ${isEmpty?'style="display:none;"':""}> 82 ${itemsHtml} 83 </div> 84 85 <div class="cart-wishlist__empty empty" ${isEmpty?"":'style="display:none;"'}> 86 <div class="minicart-text-container"> 87 Sieht aus, als w\xE4re Ihre Wunschliste leer - 88 <a href="/collections/all" class="link bold"> 89 finden Sie etwas, das Sie lieben werden, aus unseren Top-Tipps. 90 </a> 91 </div> 92 </div> 93 </div> 94 `}async function loadMinicartWishlist(target){if(minicartWishlistLoading)return;const injector=document.querySelector("[data-wishlist-injector]");if(!(!injector||!injector.getAttribute("data-customer-email"))){minicartWishlistLoading=!0,target.innerHTML=` 95 <div class="cart-wishlist"> 96 <div class="cart-wishlist__products"> 97 Loading... 98 </div> 99 </div> 100 `;try{const url=`${getWishlistApiUrl("v1/list")}?page=1&limit=20&moreInfo=true`,response=await fetch(url,{method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json","x-client-type":"web"}
100,credentials:"same-origin"});if(!response.ok)throw new Error(`Wishlist request failed: ${response.status}`);const items=(await response.json())?.data?.items||[];if(!items.length){target.innerHTML=renderWishlistShell("",!0);return}const itemsHtml=items.map(renderWishlistProduct).join("");target.innerHTML=renderWishlistShell(itemsHtml,!1),attachMinicartWishlistRemoveHandlers(target),attachMinicartWishlistAddToCartHandlers(target)}catch(error){console.error("[Minicart Wishlist] Failed to load wishlist:",error),target.innerHTML=` 101 <div class="cart-wishlist"> 102 <div class="cart-wishlist__products"> 103 Wishlist could not be loaded. 104 </div> 105 </div> 106 `}finally{minicartWishlistLoading=!1}}}function attachMinicartWishlistRemoveHandlers(container){container.querySelectorAll(".js-remove-from-wishlist").forEach(button=>{button.addEventListener("click",async function(event){event.preventDefault(),event.stopPropagation();const variantId=this.dataset.variantId;if(variantId){this.disabled=!0;try{const response=await fetch(getWishlistApiUrl(`v1/${variantId}`),{method:"DELETE",headers:{"Content-Type":"application/json",Accept:"application/json","x-client-type":"web"}
106,credentials:"same-origin"});if(!response.ok)throw new Error(`Remove failed: ${response.status}`);const result=await response.json();if(!result.success)throw new Error(result.error||"Failed to remove wishlist item");document.dispatchEvent(new CustomEvent("wishlist:updated",{detail:{action:"removed",variantId}}));const target=document.querySelector(".wishlist-replace");target&&await loadMinicartWishlist(target)}catch(error){console.error("[Minicart Wishlist] Remove failed:",error),this.disabled=!1}}})})}function attachMinicartWishlistAddToCartHandlers(container){container.querySelectorAll(".js-add-to-cart").forEach(button=>{button.addEventListener("click",async function(event){event.preventDefault(),event.stopPropagation();const variantId=this.dataset.variantId;if(!variantId)return;this.disabled=!0;const minicartItems=document.querySelector(".cart-items-component")?.querySelectorAll(`.cart-items__wrapper .mini-cart-item[data-variant-id='${variantId}']`);let quantityLeft=this.getAttribute("data-quantity-left"),itemTotalQuantity=0;if(minicartItems?.forEach(minicartItem=>{const rowQuantityLeft=minicartItem.getAttribute("data-quantity-left");rowQuantityLeft&&(quantityLeft=rowQuantityLeft);const minicartItemAddedQuantity=minicartItem.getAttribute("data-item-quantity");minicartItemAddedQuantity&&+minicartItemAddedQuantity&&(itemTotalQuantity+=+minicartItemAddedQuantity)}),+quantityLeft>0&&itemTotalQuantity+1>+quantityLeft){const errorMessageComponent=this.closest(".wishlist-product__content")?.querySelector(".error-message"),errorMessageText=document.querySelector(".wishlist-replace")?.getAttribute("data-exceeded-item-quantity-error")||"";errorMessageComponent&&(errorMessageText&&(errorMessageComponent.innerHTML=errorMessageText),errorMessageComponent.classList.add("shown"),setTimeout(()=>{errorMessageComponent.classList.remove("shown")},1e3)),this.disabled=!1;return}try{const response=await fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({items:[{id:Number(variantId),quantity:1}]})});if(!response.ok)throw new Error(`Add to cart failed: ${response.status}`);const message=this.closest(".cart-wishlist")?.querySelector(".cart-wishlist__messages");message&&(message.style.display="block"),document.dispatchEvent(new CustomEvent("cart:update")),document.dispatchEvent(new CustomEvent("cart:updated"))}catch(error){console.error("[Minicart Wishlist] Add to cart failed:",error),this.disabled=!1}})})}function closestCartDrawer(el){const drawer=el.closest("cart-drawer-component");return drawer instanceof HTMLElement?drawer:null}function findCheckoutErrorEl(drawer){const el=drawer.querySelector(".cart__checkout-error");return el instanceof HTMLElement?el:null}function findFirstOutOfStockItem(drawer){const item=drawer.querySelector(".mini-cart-item.out-of-stock");return item instanceof HTMLElement?item:null}function showCheckoutError(drawer,message){const errorEl=findCheckoutErrorEl(drawer);if(!errorEl){window.alert(message);return}errorEl.textContent=message,errorEl.classList.remove("hidden")}function maybeHideCheckoutError(drawer){const errorEl=findCheckoutErrorEl(drawer);errorEl&&(findFirstOutOfStockItem(drawer)||(errorEl.classList.add("hidden"),errorEl.textContent=""))}function guardCheckoutIfOutOfStock(drawer,checkoutButton){const outOfStockItem=findFirstOutOfStockItem(drawer);if(!outOfStockItem)return!0;const message=checkoutButton.getAttribute("data-oos-checkout-message")||"Bitte entfernen Sie nicht verfuegbare Artikel aus dem Warenkorb, um zur Kasse zu gehen.";return showCheckoutError(drawer,message),outOfStockItem.classList.add("bv-oos-highlight"),outOfStockItem.scrollIntoView({behavior:"smooth",block:"center"}),window.setTimeout(()=>outOfStockItem.classList.remove("bv-oos-highlight"),1800),!1}function handleCheckoutGuardClick(event,target){const button=target.closest('button[name="checkout"], button#checkout, .cart__checkout-button');if(!(button instanceof HTMLElement))return!1;const drawer=closestCartDrawer(button);return!drawer||guardCheckoutIfOutOfStock(drawer,button)?!1:(event.preventDefault(),event.stopPropagation(),event.stopImmediatePropagation?.(),!0)}function getMaxQuantityForSelector(quantitySelector){if(!(quantitySelector instanceof HTMLElement))return null;const input=quantitySelector.querySelector('input[name="updates[]"]');if(!(input instanceof HTMLInputElement))return null;const inventoryQty=parseInt(input.dataset.inventoryQuantity||"0",10),inventoryPolicy=input.dataset.inventoryPolicy,maxAttr=input.getAttribute("max");let effectiveMax=maxAttr?parseInt(maxAttr,10):null;return inventoryPolicy==="deny"&&inventoryQty>0&&(effectiveMax===null?effectiveMax=inventoryQty:effectiveMax=Math.min(effectiveMax,inventoryQty)),effectiveMax}function showMaxQtyMessageMiniCart(quantitySelector,message){let messageEl=null;const parentContainer=quantitySelector.closest(".cart-items__quantity-controls");if(parentContainer&&(messageEl=parentContainer.querySelector("[data-max-qty-message]")),!messageEl){let sibling=quantitySelector.nextElementSibling;for(;sibling;){if(sibling instanceof HTMLElement&&sibling.hasAttribute("data-max-qty-message")){messageEl=sibling;break}sibling=sibling.nextElementSibling}}if(!messageEl){const cartItem=quantitySelector.closest(".cart-item, .bv-cart-item");cartItem&&(messageEl=cartItem.querySelector("[data-max-qty-message]"))}messageEl instanceof HTMLElement&&(messageEl.textContent=message,messageEl.style.display="block",messageEl.classList.add("bv-cart-item__max-qty-message--active"),setTimeout(()=>{messageEl instanceof HTMLElement&&(messageEl.style.display="none",messageEl.classList.remove("bv-cart-item__max-qty-message--active"))},5e3))}function getMaxQtyMessage(){const cartDrawer=document.querySelector(".cart-drawer");if(cartDrawer instanceof HTMLElement&&cartDrawer.dataset.maxQtyMessage)return cartDrawer.dataset.maxQtyMessage;const cartPage=document.querySelector(".bv-cart-page");return cartPage instanceof HTMLElement&&cartPage.dataset.maxQtyMessage?cartPage.dataset.maxQtyMessage:"Maximum allowed quantity reached"}const ThemeEvents=window.ThemeEvents||window.Theme&&window.Theme.events,QuantitySelectorUpdateEvent=window.QuantitySelectorUpdateEvent||window.Theme&&window.Theme.events&&window.Theme.events.QuantitySelectorUpdateEvent,quantitySelectorUpdateEventName=ThemeEvents?.quantitySelectorUpdate||"quantity-selector:update";function handleQuantityGuardClick(e){if(!(e.target instanceof HTMLElement))return;const button=e.target.closest('button[name="minus"], button[name="plus"]');if(!button||!(button instanceof HTMLButtonElement))return;const quantitySelector=button.closest("quantity-selector-component")||button.closest("cart-quantity-selector-component")||button.closest(".quantity-selector");if(!quantitySelector||!(quantitySelector instanceof HTMLElement)||!quantitySelector.closest(".cart-drawer"))return;const input=quantitySelector.querySelector('input[name="updates[]"]');if(!(input instanceof HTMLInputElement))return;const currentQuantity=parseInt(input.value,10)||1,maxQty=getMaxQuantityForSelector(quantitySelector);if(button.name==="plus"&&maxQty!==null&¤tQuantity>=maxQty){e.preventDefault(),e.stopPropagation(),console.log("[BV Mini Cart] Max quantity reached, preventing increase");const message=getMaxQtyMessage();showMaxQtyMessageMiniCart(quantitySelector,message);return}setTimeout(()=>{const component=quantitySelector;component&&typeof component.updateButtonStates=="function"&&component.updateButtonStates()},50)}function onDrawerClickCapture(event){const target=event.target;target instanceof Element&&target.closest(DRAWER_SCOPE_SELECTOR)&&(handleCheckoutGuardClick(event,target)||handleQuantityGuardClick(event))}document.addEventListener("click",onDrawerClickCapture,!0),document.addEventListener(quantitySelectorUpdateEventName,e=>{if(!(e instanceof Event))return;let quantity;e instanceof CustomEvent&&e.detail&&(quantity=e.detail.quantity);let quantitySelector=null;if(e.target instanceof HTMLElement&&(quantitySelector=e.target.closest("quantity-selector-component")||e.target.closest("cart-quantity-selector-component")||e.target.closest(".quantity-selector")),!quantitySelector||!(quantitySelector instanceof HTMLElement)||!quantitySelector.closest(".cart-drawer"))return;const input=quantitySelector.querySelector('input[name="updates[]"]');if(!(input instanceof HTMLInputElement))return;const currentQuantity=quantity!==void 0?quantity:parseInt(input.value,10)||1,maxQty=getMaxQuantityForSelector(quantitySelector),component=quantitySelector;component&&typeof component.updateButtonStates=="function"&&component.updateButtonStates();const inputMax=input.getAttribute("max"),inputMaxQty=inputMax?parseInt(inputMax,10):null;if(maxQty!==null&¤tQuantity===maxQty&&inputMaxQty===maxQty){const previousValue=input.dataset.previousValue;if(previousValue&&parseInt(previousValue,10)<maxQty){console.log("[BV Mini Cart] Max quantity reached via input change");const message=getMaxQtyMessage();showMaxQtyMessageMiniCart(quantitySelector,message)}}if(input.dataset.previousValue=String(currentQuantity),maxQty===null||currentQuantity<maxQty){const messageEl=quantitySelector.parentElement?.querySelector("[data-max-qty-message]");messageEl instanceof HTMLElement&&(messageEl.style.display="none",messageEl.classList.remove("bv-cart-item__max-qty-message--active"))}},!0);function updateDrawerQuantityButtonStates(){document.querySelectorAll(".cart-drawer quantity-selector-component, .cart-drawer cart-quantity-selector-component").forEach(selector=>{if(selector instanceof HTMLElement){const component=selector;component&&typeof component.updateButtonStates=="function"&&component.updateButtonStates()}})}function handleImageError(img){if(!(img instanceof HTMLImageElement)||img.src.includes("no-image"))return;const placeholderSmall=img.dataset.placeholderSmall||"/assets/no-image-small.jpg",placeholderL
106arge=img.dataset.placeholderLarge||"/assets/no-image-large.jpg",placeholderSrc=window.innerWidth<=749?placeholderSmall:placeholderLarge;img.src=placeholderSrc,img.alt=img.alt||"Product image not available",img.onerror=null}function initCartImageErrorHandlers(){document.querySelectorAll(".cart-items__media-image, .bv-cart-item__image img").forEach(img=>{img instanceof HTMLImageElement&&(!img.complete||img.naturalHeight===0)&&img.addEventListener("error",()=>handleImageError(img),{once:!0})})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",initCartImageErrorHandlers):initCartImageErrorHandlers();const cartImageObserver=new MutationObserver(mutations=>{mutations.forEach(mutation=>{mutation.type==="childList"&&mutation.addedNodes.forEach(node=>{node instanceof HTMLElement&&((node.querySelectorAll?node.querySelectorAll(".cart-items__media-image, .bv-cart-item__image img"):[]).forEach(img=>{img instanceof HTMLImageElement&&img.addEventListener("error",()=>handleImageError(img),{once:!0})}),node instanceof HTMLImageElement&&(node.classList.contains("cart-items__media-image")||node.closest(".bv-cart-item__image"))&&node.addEventListener("error",()=>handleImageError(node),{once:!0}))})})});function setupCartImageObserver(){const cartDrawer=document.querySelector("cart-drawer-component"),cartPage=document.querySelector(".bv-cart-page");cartDrawer instanceof HTMLElement&&cartImageObserver.observe(cartDrawer,{childList:!0,subtree:!0}),cartPage instanceof HTMLElement&&cartImageObserver.observe(cartPage,{childList:!0,subtree:!0})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",setupCartImageObserver):setupCartImageObserver();async function removeDraftProductsFromCart(){const draftItems=document.querySelectorAll('[data-is-draft="true"]');if(draftItems.length===0)return;const cartItemsComponent=document.querySelector("cart-items-component"),sectionId=cartItemsComponent instanceof HTMLElement&&cartItemsComponent.dataset.sectionId||"main-cart",linesToRemove=[];if(draftItems.forEach(item=>{if(item instanceof HTMLElement){const lineNumber=parseInt(item.dataset.line||"0",10);lineNumber>0&&linesToRemove.push(lineNumber)}}),linesToRemove.length===0)return;const sortedLines=[...linesToRemove].sort((a,b)=>b-a);for(const line of sortedLines)try{const response=await fetch("/cart/change.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({line,quantity:0,sections:sectionId,sections_url:window.location.pathname})});if(!response.ok){console.warn("[BV Cart] Failed to remove draft product at line",line);continue}const responseText=await response.text(),parsedResponse=JSON.parse(responseText);if(parsedResponse.sections&&parsedResponse.sections[sectionId])if(window.morphSection||window.Theme&&window.Theme.morphSection){const morphSection=window.morphSection||window.Theme.morphSection;try{morphSection(sectionId,parsedResponse.sections[sectionId])}catch(error){console.warn("[BV Cart] Error morphing section:",error);const sectionElement=document.getElementById(`shopify-section-${sectionId}`);sectionElement&&parsedResponse.sections[sectionId]&&(sectionElement.innerHTML=parsedResponse.sections[sectionId])}}else{const sectionElement=document.getElementById(`shopify-section-${sectionId}`);sectionElement&&parsedResponse.sections[sectionId]&&(sectionElement.innerHTML=parsedResponse.sections[sectionId])}const CartUpdateEvent=window.CartUpdateEvent||window.Theme&&window.Theme.events&&window.Theme.events.CartUpdateEvent,ThemeEvents2=window.ThemeEvents||window.Theme&&window.Theme.events;CartUpdateEvent?document.dispatchEvent(new CartUpdateEvent(parsedResponse,sectionId,{source:"bv-draft-product-removal",sections:parsedResponse.sections})):ThemeEvents2&&ThemeEvents2.cartUpdate?document.dispatchEvent(new CustomEvent(ThemeEvents2.cartUpdate,{detail:{data:parsedResponse,source:"bv-draft-product-removal",sections:parsedResponse.sections}})):document.dispatchEvent(new CustomEvent("cart:update",{detail:{data:parsedResponse,source:"bv-draft-product-removal",sections:parsedResponse.sections}})),await new Promise(resolve=>setTimeout(resolve,100))}catch(error){console.error("[BV Cart] Error removing draft product at line",line,":",error)}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{setTimeout(removeDraftProductsFromCart,500)}):setTimeout(removeDraftProductsFromCart,500);function getCartForExternalUpdate(){return fetch("/cart.js",{credentials:"same-origin",headers:{Accept:"application/json"}}).then(response=>response.json())}function getSectionHtmlForExternalUpdate(sectionId){const url=new URL(window.location.href);return url.searchParams.set("section_id",sectionId),fetch(url.toString(),{credentials:"same-origin"}).then(response=>response.text())}function refreshCartAfterExternalAdd(source="rebuy"){return getCartForExternalUpdate().then(cart=>{const itemCount=Number(cart&&cart.item_count)||0;let sectionIds=Array.from(document.querySelectorAll("cart-items-component[data-section-id]")).map(element=>
106element.getAttribute("data-section-id")).filter(Boolean);sectionIds=sectionIds.filter((id,index,arr)=>arr.indexOf(id)===index);const sections={};return Promise.all(sectionIds.map(id=>getSectionHtmlForExternalUpdate(id).then(html=>{sections[id]=html}))).then(()=>{document.dispatchEvent(new CustomEvent("cart:update",{detail:{data:{itemCount,source,sections},cart}})),document.dispatchEvent(new CustomEvent("cart:refresh")),document.dispatchEvent(new CustomEvent("cart:updated",{detail:{cart}}));const drawer=document.querySelector("cart-drawer-component");drawer&&typeof drawer.open=="function"&&drawer.open()})}).catch(error=>{console.warn("[BV Mini Cart] External cart refresh failed:",error)})}document.addEventListener("rebuy.add",()=>{refreshCartAfterExternalAdd("rebuy")});async function handleBundleComponentRemove(event){const btn=(event.target instanceof Element?event.target:null)?.closest(".mini-cart-bundle__component-remove-btn");if(!btn)return;event.preventDefault(),event.stopPropagation();const card=btn.closest(".mini-cart-bundle-card");if(!card)return;const compEl=btn.closest(".mini-cart-bundle__component"),compIndex=parseInt(btn.getAttribute("data-component-index")||compEl&&compEl.getAttribute("data-component-index")||"0",10),lineIndex=parseInt(card.getAttribute("data-line-index")||card.dataset.lineIndex||"0",10),itemKey=card.getAttribute("data-key")||card.dataset.key||"";if(lineIndex){card.classList.add("mini-cart-bundle-card--updating");try{const currentCart=await(await fetch("/cart.js",{credentials:"same-origin",cache:"no-store",headers:{Accept:"application/json"}})).json(),currentLineItem=(currentCart.items||[]).find(it=>it.key===itemKey)||(currentCart.items||[])[lineIndex-1];let properties=Object.assign({},currentLineItem?.properties||{});const sectionIds=getCartSectionIds();if(properties._group){let group=[];try{group=typeof properties._group=="string"?JSON.parse(properties._group):properties._group}catch(e){console.warn("[MiniCartBundle] Failed to parse _group:",e)}if(Array.isArray(group)&&group.length>0)if(compIndex<group.length?group.splice(compIndex,1):group.pop(),group.length===0)await fetch("/cart/change.js",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({line:lineIndex,quantity:0,sections:sectionIds.join(","),sections_url:window.location.pathname})});else if(group.length===1){const remaining=group[0],remainingVariantId=parseInt(remaining.id,10);await fetch("/cart/change.js",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({line:lineIndex,quantity:0})}),await(await fetch("/cart/add.js",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({items:[{id:remainingVariantId,quantity:1}],sections:sectionIds.join(","),sections_url:window.location.pathname})})).json()}else{group.some(g=>g.is_main)||(group[0].is_main=!0);const mainItem=group.find(g=>g.is_main)||group[0],primaryVariantId=parseInt(mainItem.id,10);properties._group=JSON.stringify(group),await fetch("/cart/change.js",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({line:lineIndex,quantity:0})}),await(await fetch("/cart/add.js",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({items:[{id:primaryVariantId,quantity:1,properties}],sections:sectionIds.join(","),sections_url:window.location.pathname})})).json()}}else await fetch("/cart/change.js",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({line:lineIndex,quantity:0,sections:sectionIds.join(","),sections_url:window.location.pathname})});const updatedCart=await(await fetch("/cart.js",{credentials:"same-origin",cache:"no-store",headers:{Accept:"application/json"}})).json();document.dispatchEvent(new CustomEvent("cart:update",{detail:{data:{itemCount:Number(updatedCart.item_count)||0,source:"bundle-component-remove"},cart:updatedCart}})),document.dispatchEvent(new CustomEvent("cart:updated",{detail:{cart:updatedCart}}))}catch(err){console.error("[MiniCartBundle] Error removing bundle component:",err),refreshCartDrawerPricesOnOpen()}finally{card.classList.remove("mini-cart-bundle-card--updating")}}}
106async function handleBundleComponentQuantityChange(event){const bundleComp=(event.target instanceof Element?event.target:null)?.closest(".mini-cart-bundle__component");if(!bundleComp)return;event.stopImmediatePropagation(),event.preventDefault();const card=bundleComp.closest(".mini-cart-bundle-card");if(!card)return;const lineIndex=parseInt(card.getAttribute("data-line-index")||card.dataset.lineIndex||"0",10),itemKey=card.getAttribute("data-key")||card.dataset.key||"",compVariantId=parseInt(bundleComp.getAttribute("data-component-variant-id")||bundleComp.dataset.componentVariantId||"0",10),newQty=event.detail?.quantity;if(!(!lineIndex||!compVariantId||typeof newQty!="number")){card.classList.add("mini-cart-bundle-card--updating");try{const currentItems=(await(await fetch("/cart.js",{credentials:"same-origin",cache:"no-store",headers:{Accept:"application/json"}})).json()).items||[],currentLineItem=currentItems.find(it=>it.key===itemKey)||currentItems[lineIndex-1];if(!currentLineItem)return;const bundleQty=currentLineItem.quantity||1,delta=newQty-bundleQty;if(delta===0)return;const otherCompVariantIds=Array.from(card.querySelectorAll(".mini-cart-bundle__component")).map(el=>parseInt(el.getAttribute("data-component-variant-id")||el.dataset.componentVariantId||"0",10)).filter(Boolean).filter(id=>id!==compVariantId),getStandaloneItems=variantId=>currentItems.filter(it=>!(it.variant_id!==variantId||it.item_components&&it.item_components.length>0||it.properties&&it.properties._group));if(delta>0)if(otherCompVariantIds.length>0&&otherCompVariantIds.every(otherId=>getStandaloneItems(otherId).reduce((sum,it)=>sum+(it.quantity||0),0)>=delta)){const updates={};updates[currentLineItem.key]=bundleQty+delta;for(const otherId of otherCompVariantIds){let needed=delta;const standaloneItems=getStandaloneItems(otherId);for(const it of standaloneItems){if(needed<=0)break;const deduct=Math.min(it.quantity,needed);updates[it.key]=it.quantity-deduct,needed-=deduct}}await fetch("/cart/update.js",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({updates})})}else await fetch("/cart/add.js",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({items:[{id:compVariantId,quantity:delta}]})});else{const reduceAmount=Math.abs(delta),standaloneItems=getStandaloneItems(compVariantId);if(standaloneItems.reduce((sum,it)=>sum+(it.quantity||0),0)>=reduceAmount){const updates={};let needed=reduceAmount;for(const it of standaloneItems){if(needed<=0)break;const deduct=Math.min(it.quantity,needed);updates[it.key]=it.quantity-deduct,needed-=deduct}await fetch("/cart/update.js",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({updates})})}else if(bundleQty>reduceAmount){const updates={};updates[currentLineItem.key]=bundleQty-reduceAmount,await fetch("/cart/update.js",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({updates})});const itemsToAdd=otherCompVariantIds.map(id=>({id,quantity:reduceAmount}));itemsToAdd.length>0&&await fetch("/cart/add.js",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({items:itemsToAdd})})}else{const removeBtn=bundleComp.querySelector(".mini-cart-bundle__component-remove-btn");if(removeBtn&&removeBtn instanceof HTMLElement){removeBtn.click();return}}}await refreshCartAfterExternalAdd("bundle-component-quantity")}catch(err){console.error("[MiniCartBundle] Error updating bundle component quantity:",err),refreshCartDrawerPricesOnOpen()}finally{card.classList.remove("mini-cart-bundle-card--updating")}}}document.addEventListener("click",handleBundleComponentRemove),document.addEventListener("quantity-selector:update",handleBundleComponentQuantityChange,!0);const scheduleImageHandlers=debounce(initCartImageErrorHandlers,200),scheduleDraftRemoval=debounce(removeDraftProductsFromCart,300);document.addEventListener("cart-drawer:open",()=>{runIsolated(resetMiniCartTabs),runIsolated(refreshCartDrawerPricesOnOpen),runIsolated(applyDeviceFingerpintToCart),scheduleImageHandlers(),scheduleDraftRemoval()}),document.addEventListener("cart:update",()=>{runIsolated(()=>{document.querySelectorAll("cart-drawer-component").forEach(drawer=>{drawer instanceof HTMLElement&&maybeHideCheckoutError(drawer)})}),requestAnimationFrame(()=>{setTimeout(updateDrawerQuantityButtonStates,100)}),scheduleImageHandlers(),scheduleDraftRemoval()}),document.addEventListener("cart:refresh",()=>{scheduleImageHandlers(),scheduleDraftRemoval()}),document.addEventListener("shopify:section:load",e=>{runIsolated(bootTabs),e instanceof CustomEvent&&e.detail&&e.detail.sectionId&&e.detail.sectionId.includes("cart")&&(setTimeout(()=>{setupCartImageObserver(),initCartImageErrorHandlers()},100),scheduleDraftRemoval())})})(); 107//# sourceMappingURL=/cdn/shop/t/88/assets/bv-mini-cart.js.map?v=75161895507609871351791447122
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.