PageSourceSearch

https://www.wasparfum.nl/cdn/shop/t/24/assets/product-recommendations.js?v=32920125159305318421782125274

js wasparfum.nl collected 2026-10-05 08:03:31 UTC 4,390 bytes, 2 lines download raw bytes

1import{Component}from"@theme/component";class ProductRecommendations extends Component{#intersectionObserver=null;#mutationObserver=new MutationObserver(mutations=>{for(const mutation of mutations)if(!(mutation.target!==this||mutation.type!=="attributes")&&mutation.attributeName!=="data-error"&&!(mutation.attributeName==="class"&&this.classList.contains("hidden"))&&!(mutation.attributeName==="data-recommendations-performed"&&this.dataset.recommendationsPerformed==="true")){mutation.attributeName==="data-product-id"&&this.dataset.context==="cart"&&this.#resetRecommendationsState(),this.#loadRecommendations();break}});#cachedRecommendations={};#activeFetch=null;#cartDrawerOpenHandler=null;connectedCallback(){super.connectedCallback(),this.dataset.context==="cart"?(this.#resolveCartSectionId(),this.#bindCartDrawerOpen(),this.#loadRecommendations()):(this.#intersectionObserver=new IntersectionObserver((entries,observer)=>{entries[0]?.isIntersecting&&(observer.disconnect(),this.#loadRecommendations())},{rootMargin:"0px 0px 400px 0px"}),this.#intersectionObserver.observe(this)),this.#mutationObserver.observe(this,{attributes:!0}),this.dataset.recommendationsPerformed==="true"&&this.#syncVisibility()}disconnectedCallback(){super.disconnectedCallback(),this.#intersectionObserver?.disconnect(),this.#mutationObserver.disconnect(),this.#unbindCartDrawerOpen()}#resolveCartSectionId(){if(this.dataset.sectionId)return;const layout=this.dataset.layout||"carousel",hostSectionId=document.querySelector(`[data-cart-recommendations-host] product-recommendations[data-layout="${layout}"]`)?.dataset.sectionId;hostSectionId&&(this.dataset.sectionId=hostSectionId)}#resetRecommendationsState(){delete this.dataset.recommendationsPerformed,this.classList.remove("hidden"),delete this.dataset.error}#bindCartDrawerOpen(){this.dataset.context==="cart"&&(this.#cartDrawerOpenHandler=()=>{this.#loadRecommendations()},document.querySelector("cart-drawer-component")?.addEventListener("dialog:open",this.#cartDrawerOpenHandler))}#unbindCartDrawerOpen(){this.#cartDrawerOpenHandler&&(document.querySelector("cart-drawer-component")?.removeEventListener("dialog:open",this.#cartDrawerOpenHandler),this.#cartDrawerOpenHandler=null)}#syncVisibility(){!!this.querySelector('[data-has-recommendations="true"]')?this.classList.remove("hidden"):this.classList.add("hidden")}#loadRecommendations(){const{productId,recommendationsPerformed,sectionId,intent}=this.dataset,id=this.id;if(!productId||!id){this.dataset.context==="cart"&&this.classList.add("hidden");return}sectionId||this.#resolveCartSectionId(),this.dataset.sectionId&&recommendationsPerformed!=="true"&&this.#fetchCachedRecommendations(productId,this.dataset.sectionId,intent).then(result=>{if(!result.success){Shopify.designMode||this.#handleError(new Error(`Server returned ${result.status}`));return}const html=document.createElement("div");html.innerHTML=result.data||"";let recommendations=html.querySelector(`product-recommendations[id="${id}"]`);!recommendations?.innerHTML&&this.dataset.context==="cart"&&(recommendations=html.querySelector("product-recommendations")),recommendations?.innerHTML&&recommendations.innerHTML.trim().length?(this.dataset.recommendationsPerformed="true",this.innerHTML=recommendations.innerHTML,this.#syncVisibility()):this.#handleError(new Error("No recommendations available"))}).catch(e=>{this.#handleError(e)})}async#fetchCachedRecommendations(productId,sectionId,intent){const url=`${this.dataset.url}&product_id=${productId}&section_id=${sectionId}&intent=${intent}`,cachedResponse=this.#cachedRecommendations[url];if(cachedResponse)return{success:!0,data:cachedResponse};this.#activeFetch?.abort(),this.#activeFetch=new AbortController;try{const response=await fetch(url,{signal:this.#activeFetch.signal});if(!response.ok)return{success:!1,status:response.status};const text=await response.text();return this.#cachedRecommendations[url]=text,{success:!0,data:text}}finally{this.#activeFetch=null}}#handleError(error){console.error("Product recommendations error:",error.message),this.classList.add("hidden"),this.dataset.error="Error loading product recommendations"}}customElements.get("product-recommendations")||customElements.define("product-recommendations",ProductRecommendations);
2//# sourceMappingURL=/cdn/shop/t/24/assets/product-recommendations.js.map?v=32920125159305318421782125274

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.