1(()=>{"use strict";const drawer=document.getElementById("BWWishlistDrawer");if(!drawer)return;const host=drawer.querySelector("[data-bw-drawer-products]"),count=drawer.querySelector("[data-bw-drawer-count]"),notice=drawer.querySelector(".bw-drawer-notice"),noticeText=drawer.querySelector("[data-bw-drawer-notice]"),error=drawer.querySelector("[data-bw-drawer-error]"),undo=drawer.querySelector("[data-bw-wishlist-undo]");let sdk,trigger,clickedAt=0,latest=null,listId=null,items=[],revision=0,pending=!1;const key=p=>String(p.empi)+":"+String(p.epi);function setError(message){error.textContent=message,error.hidden=!message}function productHref(p){try{const url=new URL(p.du,location.origin);return url.protocol!=="https:"||![location.hostname,drawer.dataset.shopDomain].includes(url.hostname)||!/^\/products\/[^/]+/.test(url.pathname)?null:url.pathname+url.search}catch{return null}}function node(tag,cls,text){const el=document.createElement(tag);return cls&&(el.className=cls),text!=null&&(el.textContent=text),el}function render(){const sorted=items.slice().sort((a,b)=>(latest&&key(b)===key(latest)?1:0)-(latest&&key(a)===key(latest)?1:0));host.replaceChildren(),count.textContent=items.length+(items.length===1?" saved item":" saved items"),sorted.forEach(p=>{const href=productHref(p),row=node("li","bw-drawer-product");if(href){const imageLink=node("a","bw-drawer-image");imageLink.href=href;const img=node("img");img.alt=String(p.dt||"Product"),img.loading="lazy",img.width=96,img.height=96;try{const url=new URL(p.iu,location.origin);url.protocol==="https:"&&(img.src=url.href)}catch{}imageLink.append(img),row.append(imageLink)}const info=node("div","bw-drawer-info");if(latest&&key(p)===key(latest)&&info.append(node("span","bw-just-added","JUST ADDED")),info.append(node("h3","",p.dt||"Saved product")),Number.isFinite(Number(p.pr))){const price=new Intl.NumberFormat(document.documentElement.lang||"en-US",{style:"currency",currency:drawer.dataset.currency||"USD"}).format(Number(p.pr));info.append(node("p","bw-drawer-price",price))}if(href){const a=node("a","","View product \u2192");a.href=href,info.append(a)}row.append(info);const remove=node("button","bw-drawer-remove","\xD7");remove.type="button",remove.setAttribute("aria-label","Remove "+(p.dt||"product")+" from wishlist"),remove.disabled=pending,remove.addEventListener("click",()=>removeItem(p,remove)),row.append(remove),host.append(row);const image=row.querySelector("img");image&&window.BWWishlistImages?.watch(image,{id:p.empi},resolved=>{row.querySelectorAll("a").forEach(a=>{a.href=resolved.href})})}),items.length||host.append(node("li","bw-drawer-empty","Your wishlist is empty.")),notice.hidden=!latest||!items.some(p=>key(p)===key(latest)),undo.disabled=pending}function load(lid,generation){sdk.fetchListDetails({lid},response=>{if(generation!==revision)return;const products=response?.items||response?.list?.listcontents;if(!Array.isArray(products)){setError("Saved items could not be loaded. Please open My Wishlist.");return}
1listId=lid,items=products,render()},()=>{generation===revision&&setError("Saved items could not be loaded. Please open My Wishlist.")})}function refresh(product){const generation=++revision;if(product?.lid||listId){load(product?.lid||listId,generation);return}sdk.fetchLists({callbackFn(lists){if(generation!==revision)return;const list=lists.find(l=>(l.listcontents||[]).some(p=>key(p)===key(product)));list?load(list.lid,generation):setError("Please open My Wishlist to view this saved item.")},errorFn(){generation===revision&&setError("Saved items could not be loaded. Please open My Wishlist.")}})}function removeItem(product,control){if(pending||!listId)return;pending=!0,control.disabled=!0,undo.disabled=!0,setError("");const removedLatest=latest&&key(latest)===key(product);sdk.deleteFromList(listId,{epi:product.epi,empi:product.empi,du:product.du},()=>{pending=!1,++revision,items=items.filter(p=>key(p)!==key(product)),removedLatest&&(latest=null),render(),drawer.querySelector(".bw-drawer-view").focus(),typeof sdk.initializeActionButtons=="function"&&sdk.initializeActionButtons(document.getElementById("product-grid")?"#product-grid":"#MainContent")},()=>{pending=!1,control.disabled=!1,undo.disabled=!1,setError("This item could not be removed. Please try again.")})}document.addEventListener("click",event=>{const button=event.target.closest('[data-swaction="addToWishlist"],.swym-add-to-wishlist');button&&!drawer.contains(button)&&(trigger=button,clickedAt=Date.now())},!0),undo.addEventListener("click",()=>{latest&&removeItem(latest,undo)}),drawer.querySelector("[data-bw-drawer-continue]").addEventListener("click",()=>drawer.hide());const desktop=matchMedia("(min-width:1025px)"),toast=document.getElementById("BWWishlistToast"),toastStatus=document.getElementById("BWWishlistToastStatus");let toastTimer,nativeTimer,toastDeadline=0,toastRemaining=6e3;function hideToast(){if(clearTimeout(toastTimer),toast){const focused=toast.contains(document.activeElement);toast.hidden=!0,focused&&trigger?.isConnected&&typeof trigger.focus=="function"&&trigger.focus()}}function pauseToast(){clearTimeout(toastTimer),toastRemaining=Math.max(0,toastDeadline-Date.now())}function resumeToast(){!toast||toast.hidden||document.hidden||toast.contains(document.activeElement)||toast.matches(":hover")||(clearTimeout(toastTimer),toastDeadline=Date.now()+toastRemaining,toastTimer=setTimeout(hideToast,toastRemaining))}function positionToast(){if(!toast||toast.hidden)return;const header=document.querySelector(".shopify-section-header")||document.querySelector(".header-wrapper"),bottom=Math.max(0,header?.getBoundingClientRect().bottom||0);toast.style.setProperty("--bw-toast-top",Math.min(bottom+12,Math.max(12,innerHeight-toast.offsetHeight-12))+"px")}function suppressNativeWishlistNotice(){document.documentElement.classList.add("bw-mobile-wishlist-card-active"),clearTimeout(nativeTimer),nativeTimer=setTimeout(()=>document.documentElement.classList.remove("bw-mobile-wishlist-card-active"),9e3)}function showToast(product){if(!toast||!product.dt)return;const img=toast.querySelector("[data-bw-toast-image]");img.hidden=!0,img.removeAttribute("src");try{const url=new URL(product.iu,location.origin);product.iu&&url.protocol==="https:"&&(img.src=url.href,img.hidden=!1)}catch{}img.alt=String(product.dt),toast.querySelector("[data-bw-toast-title]").textContent=String(product.dt);const line=String(String(product.empi)===toast.dataset.productId?toast.dataset.productLine:product.bt||"").trim(),lineNode=toast.querySelector("[data-bw-toast-line]");lineNode.textContent=line,lineNode.hidden=!line,toast.hidden=!1,window.BWWishlistImages?.watch(img,{id:product.empi},null,!0),toastStatus.textContent="Added to wishlist: "+String(product.dt),toastRemaining=6e3,toastDeadline=Date.now()+toastRemaining,clearTimeout(toastTimer),toastTimer=setTimeout(hideToast,toastRemaining),positionToast()}toast&&(toast.querySelector("[data-bw-toast-close]").addEventListener("click",hideToast),toast.addEventListener("pointerenter",pauseToast),toast.addEventListener("pointerleave",resumeToast),toast.addEventListener("focusin",pauseToast),toast.addEventListener("focusout",()=>setTimeout(resumeToast,0)),toast.addEventListener("keydown",event=>{event.key==="Escape"&&hideToast()}),window.addEventListener("resize",positionToast,{passive:!0}),document.addEventListener("visibilitychange",()=>document.hidden?pauseToast():resumeToast()),desktop.addEventListener("change",positionToast)),desktop.addEventListener("change",()=>{desktop.matches?hideToast():drawer.hasAttribute("open")&&drawer.hide()});function ready(swat){if(sdk||!swat.evtLayer||typeof swat.fetchListDetails!="function"||typeof swat.deleteFromList!="function")return;sdk=swat;const configuredDuration=Number(sdk.retailerSettings?.UI?.NotificationDuration),originalDuration=configuredDuration>0?configuredDuration:3e3,updateNotificationDuration=()=>
1{[sdk.retailerSettings?.UI,sdk.ui?.uiRef?.settings?.UI].forEach(settings=>{!settings||typeof settings!="object"||(settings.NotificationDuration=desktop.matches?originalDuration:originalDuration*2)})};updateNotificationDuration(),desktop.addEventListener("change",updateNotificationDuration),sdk.evtLayer.addEventListener("sw:renderui",updateNotificationDuration),sdk.evtLayer.addEventListener("sw:readyui",updateNotificationDuration),sdk.evtLayer.addEventListener("sw:addedtowishlist",event=>{const product=event?.detail?.d;if(!(!product||!trigger||Date.now()-clickedAt>15e3||pending)){if(suppressNativeWishlistNotice(),!desktop.matches){showToast(product),clickedAt=0;return}hideToast(),clickedAt=0,latest=product,listId=product.lid||null,items=[],setError(""),count.textContent="Loading saved items\u2026",host.replaceChildren(),notice.hidden=!1,noticeText.textContent="Added to your wishlist",undo.disabled=!0,drawer.show(trigger),refresh(product)}})}window.SwymCallbacks=window.SwymCallbacks||[],window.SwymCallbacks.push(ready)})(); 2//# sourceMappingURL=/cdn/shop/t/59/assets/bw-wishlist-drawer.js.map?v=6450468548689748761790824528
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.