https://modway.com/cdn/shop/t/303/assets/recently-viewed-carousel.js?v=30420166232348831421780686672
1import{Component}from"@theme/component";import{RecentlyViewed}from"@theme/recently-viewed-products";import{sectionRenderer}from"@theme/section-renderer";class RecentlyViewedProducts extends Component{#loaded=!1;connectedCallback(){super.connectedCallback(),this.#load()}async#load(){if(this.#loaded)return;this.#loaded=!0;const{sectionId,currentProductId}=this.dataset;if(!sectionId)return;const ids=RecentlyViewed.getProducts().filter(id=>String(id)!==String(currentProductId));if(ids.length!==0)try{const url=new URL(Theme.routes.search_url,location.origin);url.searchParams.set("q",ids.map(id=>`id:${id}`).join(" OR ")),url.searchParams.set("resources[type]","product");const html=await sectionRenderer.getSectionHTML(sectionId,!1,url),root=new DOMParser().parseFromString(html,"text/html").querySelector("recently-viewed-products");if(!root||!root.querySelector("product-card, .resource-list__item"))return;this.#reorderByRecency(root,ids);const heading=this.querySelector(".section-resource-list__content")?.innerHTML;this.innerHTML=root.innerHTML;const headingTarget=this.querySelector(".section-resource-list__content");heading&&headingTarget&&(headingTarget.innerHTML=heading);for(const card of this.querySelectorAll('product-card[id="product-card-"]')){const productId=card.getAttribute("data-product-id");productId&&(card.id=`product-card-rv-${productId}`)}this.classList.remove("hidden")}catch(error){console.error("Recently viewed products error:",error instanceof Error?error.message:error)}}#reorderByRecency(root,orderedIds){const rank=new Map(orderedIds.map((id,index)=>[String(id),index])),rankOf=node=>{const id=node.querySelector("[data-product-id]")?.getAttribute("data-product-id");return id!=null&&rank.has(id)?rank.get(id):Number.MAX_SAFE_INTEGER},slides=Array.from(root.querySelectorAll("slideshow-slide"));if(slides.length>1){const parent=slides[0]?.parentElement;if(!parent)return;slides.sort((a,b)=>rankOf(a)-rankOf(b)),slides.forEach((slide,index)=>{slide.setAttribute("aria-hidden",index===0?"false":"true"),slide.toggleAttribute("inert",index!==0);const style=slide.getAttribute("style");style&&slide.setAttribute("style",style.replace(/--slide-\d+/g,`--slide-${index}`)),parent.appendChild(slide)});return}const items=Array.from(root.querySelectorAll(".resource-list__item"));if(items.length>1){const parent=items[0]?.parentElement;if(!parent)return;items.sort((a,b)=>rankOf(a)-rankOf(b));for(const item of items)parent.appendChild(item)}}}customElements.get("recently-viewed-products")||customElements.define("recently-viewed-products",RecentlyViewedProducts); 2//# sourceMappingURL=/cdn/shop/t/303/assets/recently-viewed-carousel.js.map?v=30420166232348831421780686672
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.