1(function(){const sectionInstances=new WeakMap;class PopularProductsSection{constructor(section){this.section=section,this.container=section.querySelector(".popular-products"),this.layoutEl=this.container?.querySelector(".popular-products__layout"),this.wrapper=this.container?.querySelector(".popular-products__wrapper"),!(!this.container||!this.layoutEl||!this.wrapper)&&(this.layout=this.layoutEl.dataset.layout||this.container.dataset.layout||"grid",this.filterItems=Array.from(this.section.querySelectorAll("[data-filter-target]")),this.allSlides=Array.from(this.wrapper.children),this.perRow=Number(this.layoutEl.dataset.cardsPerRow||1),this.breakpointMap=this.buildBreakpointMap(),this.activeFilter=this.getInitialFilter(),this.swiper=null,this.resizeObserver=null,this.bindFilters(),this.layout==="slider"?(this.renderSliderSlides(this.activeFilter),this.initSwiper(),this.bindResize()):this.applyGridFilter(this.activeFilter),this.buttonCursor=section.querySelector(".popular-products-cursor"),this.buttonCursor&&this.initCursor())}buildBreakpointMap(){return[{bp:0,cols:1},{bp:750,cols:2},{bp:1200,cols:3},{bp:1536,cols:4}].filter(step=>step.cols<=this.perRow)}getCurrentCols(){const viewportWidth=window.innerWidth;let cols=1;return this.breakpointMap.forEach(step=>{viewportWidth>=step.bp&&(cols=step.cols)}),cols}normalizeFilter(filterTarget){return!filterTarget||filterTarget==="_all"?null:filterTarget}getInitialFilter(){const activeFilterItem=this.filterItems.find(item=>item.classList.contains("active")),defaultFilterHandle=this.layoutEl.dataset.defaultFilterHandle;return this.normalizeFilter(activeFilterItem?.dataset.filterTarget||defaultFilterHandle)}matchesFilter(item,filterTarget){return filterTarget?(item.dataset.productFilter||"").split(",").map(value=>value.trim()).filter(Boolean).includes(filterTarget):!0}setActiveFilter(filterItem){this.filterItems.forEach(item=>item.classList.remove("active")),filterItem&&filterItem.classList.add("active")}applyGridFilter(filterTarget){this.allSlides.forEach(item=>{item.hidden=!this.matchesFilter(item,filterTarget)})}renderSliderSlides(filterTarget){const fragment=document.createDocumentFragment(),filteredSlides=this.allSlides.filter(item=>this.matchesFilter(item,filterTarget));this.wrapper.innerHTML="",filteredSlides.forEach(item=>{item.hidden=!1,fragment.appendChild(item)}),this.wrapper.appendChild(fragment)}updateOverflow(){if(this.layout!=="slider")return;const visibleSlides=this.wrapper.querySelectorAll(".popular-products__card").length,currentCols=this.getCurrentCols();this.layoutEl.classList.toggle("has-overflow",visibleSlides>currentCols)}initSwiper(){if(this.layout!=="slider"||!this.wrapper.children.length){this.layoutEl.classList.remove("has-overflow");return}this.swiper=new Swiper(this.layoutEl,{slidesPerView:"auto",spaceBetween:16,speed:1e3,watchOverflow:!0,centeredSlides:!0,centeredSlidesBounds:!0,mousewheel:{forceToAxis:!0},breakpoints:{750:{spaceBetween:24,centeredSlides:!1,centeredSlidesBounds:!1}},on:{init:()=>{this.updateOverflow()},resize:()=>{this.updateOverflow()}}})}destroySwiper(){const swiperInstance=this.swiper||this.layoutEl.swiper;swiperInstance&&typeof swiperInstance.destroy=="function"&&swiperInstance.destroy(!0,!0),this.swiper=null}switchFilter(filterTarget){const nextFilter=this.normalizeFilter(filterTarget);if(this.activeFilter!==nextFilter){if(this.activeFilter=nextFilter,this.layout!=="slider"){this.applyGridFilter(this.activeFilter);return}this.destroySwiper(),this.renderSliderSlides(this.activeFilter),this.initSwiper()}}bindFilters(){this.filterItems.length&&this.filterItems.forEach(filterItem=>{filterItem.addEventListener("click",()=>{filterItem.classList.contains("active")||(this.setActiveFilter(filterItem),this.switchFilter(filterItem.dataset.filterTarget))})})}bindResize(){typeof ResizeObserver>"u"||(this.resizeObserver=new ResizeObserver(()=>{this.swiper&&(this.swiper.update(),this.updateOverflow(),this.buttonCursor&&(this.cursorLayoutRect=this.layoutEl.getBoundingClientRect()))}),this.resizeObserver.observe(this.layoutEl))}destroy(){this.resizeObserver&&this.resizeObserver.disconnect(),this.destroySwiper(),this.buttonCursor&&this.deactivateCursor(
1)}initCursor(){this.cursorTargetX=0,this.cursorTargetY=0,this.cursorX=0,this.cursorY=0,this.cursorRaf=null,this.cursorLayoutRect=null,this.cursorVisible=!1,this.cursorPositioned=!1,this.cursorActive=!1,this.cursorMediaQuery=typeof window.matchMedia=="function"?window.matchMedia("(min-width: 1160px) and (hover: hover) and (pointer: fine)"):null,this.cursorHandleMove=this.onCursorMove.bind(this),this.cursorHandleLeave=this.onCursorLeave.bind(this),this.cursorHandlePointerDown=this.onCursorPointerDown.bind(this),this.cursorHandlePointerUp=this.onCursorPointerUp.bind(this),this.cursorHandleScroll=this.onCursorScroll.bind(this),this.cursorTick=this.onTick.bind(this),this.activateCursor()}isCursorEnabled(){return!!this.layoutEl&&(!this.cursorMediaQuery||this.cursorMediaQuery.matches)}activateCursor(){this.cursorActive||!this.isCursorEnabled()||(this.cursorActive=!0,this.cursorLayoutRect=this.layoutEl.getBoundingClientRect(),this.layoutEl.addEventListener("pointermove",this.cursorHandleMove),this.layoutEl.addEventListener("mouseleave",this.cursorHandleLeave),this.layoutEl.addEventListener("pointerdown",this.cursorHandlePointerDown),this.layoutEl.addEventListener("pointerup",this.cursorHandlePointerUp),window.addEventListener("scroll",this.cursorHandleScroll,{passive:!0}))}deactivateCursor(){this.layoutEl.removeEventListener("pointermove",this.cursorHandleMove),this.layoutEl.removeEventListener("mouseleave",this.cursorHandleLeave),this.layoutEl.removeEventListener("pointerdown",this.cursorHandlePointerDown),this.layoutEl.removeEventListener("pointerup",this.cursorHandlePointerUp),window.removeEventListener("scroll",this.cursorHandleScroll),this.cursorRaf!==null&&(cancelAnimationFrame(this.cursorRaf),this.cursorRaf=null),this.hideCursor(),this.cursorLayoutRect=null,this.cursorPositioned=!1,this.cursorActive=!1}showCursor(){this.cursorVisible||(this.buttonCursor.classList.add("is-visible"),this.layoutEl.classList.add("button-cursor-shown"),this.cursorVisible=!0)}hideCursor(){this.cursorVisible&&(this.buttonCursor.classList.remove("is-visible"),this.layoutEl.classList.remove("button-cursor-shown"),this.cursorVisible=!1)}onCursorPointerDown(){this.buttonCursor.classList.add("is-dragging")}onCursorPointerUp(){this.buttonCursor.classList.remove("is-dragging")}onCursorScroll(){this.cursorLayoutRect=this.layoutEl.getBoundingClientRect()}onCursorMove(event){const rect=this.cursorLayoutRect;this.cursorTargetX=event.clientX-rect.left,this.cursorTargetY=event.clientY-rect.top,this.cursorPositioned||(this.cursorX=this.cursorTargetX,this.cursorY=this.cursorTargetY,this.cursorPositioned=!0),this.cursorRaf||(this.cursorRaf=requestAnimationFrame(this.cursorTick)),event.target.closest(".product-card")?this.hideCursor():this.showCursor()}onCursorLeave(){this.hideCursor(),cancelAnimationFrame(this.cursorRaf),this.cursorRaf=null,this.cursorPositioned=!1}onTick(){this.cursorX+=(this.cursorTargetX-this.cursorX)*.25,this.cursorY+=(this.cursorTargetY-this.cursorY)*.25,this.buttonCursor.style.transform=`translate3d(${this.cursorX}px, ${this.cursorY}px, 0) translate(-50%, -50%)`,this.cursorRaf=requestAnimationFrame(this.cursorTick)}}window.PopularProductsSection=PopularProductsSection;const initPopularProductsSection=section=>{if(!section||!section.classList.contains("popular-products-section"))return;const existingInstance=sectionInstances.get(section);existingInstance&&existingInstance.destroy(),sectionInstances.set(section,new PopularProductsSection(section))},lazyInitSection=section=>{if(!section||!section.classList.contains("popular-products-section"))return;if(typeof IntersectionObserver!="function"){initPopularProductsSection(section);return}const observer=new IntersectionObserver(entries=>{entries.some(entry=>entry.isIntersecting)&&(observer.disconnect(),initPopularProductsSection(section))},{rootMargin:"400px 0px"});observer.observe(section)};lazyInitSection(document.currentScript.parentElement),document.addEventListener("shopify:section:load",function(event){lazyInitSection(event.target)})})(); 2//# sourceMappingURL=/cdn/shop/t/25/assets/popular-products.js.map?v=183915149323431226131789298794
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.