1class ProductRecommendations extends HTMLElement{constructor(){super(),this.productHandle=this.getAttribute("data-product-handle")}async showRecentlyViewedProducts(){var e=this.getAttribute("data-limit"),e=(JSON.parse(localStorage.getItem("RecentlyViewedSJ"))||[]).filter(e=>e!==this.productHandle).slice(-e),t=".related-products-"+this.getAttribute("data-section-id"),r=document.querySelector(t);e.length&&(this.querySelector(t+"-nproducts").innerHTML=e.length,r.classList.remove("hidden"),t=await fetch(window.routes.route_url+"search?view=product-cards&ids="+e.join(",")),this.querySelector(".product-grid").innerHTML=await t.text(),e=Array.from(this.querySelectorAll(".product-card-wrapper")),this.querySelector(".title-link-header--extended").innerHTML=e.length+" "+window.searchStrings.products,e.length)||r.classList.add("hidden")}connectedCallback(){new IntersectionObserver(((e,t)=>{e[0].isIntersecting&&(t.unobserve(this),"recently-viewed"===this.getAttribute("data-view-logic")?this.showRecentlyViewedProducts():fetch(this.dataset.url).then(e=>e.text()).then(e=>{var t=document.createElement("div"),e=(t.innerHTML=e,t.querySelector("product-recommendations"));e&&e.innerHTML.trim().length&&(this.innerHTML=e.innerHTML),!this.querySelector("slideshow-component")&&this.classList.contains("complementary-products")&&this.remove(),t.querySelector(".grid__item")&&this.classList.add("product-recommendations--loaded")}).catch(e=>{console.error(e)}))}).bind(this),{rootMargin:"0px 0px 400px 0px"}).observe(this)}}customElements.define("product-recommendations",ProductRecommendations);
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.