class YouMightAlsoLike extends HTMLElement{constructor(){super(),this.getCrossSells=this.getCrossSells.bind(this),this.processCrossSells=this.processCrossSells.bind(this)}connectedCallback(){this.initializeElements()}initializeElements(){this.crossSellUpsellBox=this.querySelector(".cross-sell-upsell-box"),this.crossSellContainer=this.querySelector(".cross-sell-container"),this.crossSellUpsellBox&&(this.title=this.crossSellUpsellBox.dataset.title,this.type=this.crossSellUpsellBox.dataset.type),this.crossSellContainer&&this.render.bind(this)()}getCrossSells=async()=>{const query=`product_type:"${this.type}"`,host=window.location.hostname,data=(await(await fetch(`https://${host}/search?view=dictionary&type=product&q=${query}+NOT+title:"${this.title.split("&")[0]}"`,{method:"GET"})).text()).split("let products = ")[1].split("<\/script>")[0];return JSON.parse(data)};processCrossSells=crossSells=>{let processedCrossSells=crossSells,color;return this.title.indexOf("-")>0?color=this.title.split("-")[1].trim():color=this.title.split(" ")[1].trim(),color==="Gold"&&processedCrossSells.filter(el=>el.tags.includes("Gold")),processedCrossSells=this.constructor.shuffle(processedCrossSells),processedCrossSells=processedCrossSells.filter(item=>item.title.split("- ")[1]===color),processedCrossSells};static shuffle(array){const shuffledArray=array;let currentIndex=array.length,randomIndex;for(;currentIndex!==0;)randomIndex=Math.floor(Math.random()*currentIndex),currentIndex-=1,[shuffledArray[currentIndex],shuffledArray[randomIndex]]=[shuffledArray[randomIndex],shuffledArray[currentIndex]];return shuffledArray}buildHTMLContainer=crossSells=>{const crossSellContainerHTML=crossSells.slice(0,12).map(item=>this.constructor.buildHTMLforItem(item)).join("");document.querySelectorAll(".cross-sell-carousel").forEach(carousel=>{carousel.innerHTML=crossSellContainerHTML})};static buildHTMLforItem(item){let[productTitle]=item.title.split("-");const productSubtitle=item.title.split("-").slice(1);let fabric="";item.type!=="Swatch"&&item.tags.find(tag=>{if(tag.toLowerCase().startsWith("fabric:")){const{allFabrics}=window,fabricTag=tag.split("fabric:")[1];fabric=allFabrics.find(windowTag=>windowTag.toLowerCase().includes(fabricTag)).trim()}return fabric}),item.type==="Bridesmaid Dress"&&(productTitle=productTitle.replace(fabric,""));const titleHtml=`${productTitle}`,subtitleHtml=productSubtitle.length?`${fabric} ${productSubtitle.join("-").replace(" in "," ").trim()}`:"";return` `}static updateVisibility(){const youMightAlsoLike=document.querySelectorAll(".you-might-also-like"),youMightAlsoLikeMobileItems=document.querySelectorAll(".you-might-also-like-mobile .horizontal-carousel .cross-sell-carousel .carousel-item");function showElements(...elements){elements.forEach(el=>{el?.classList.remove("none")})}function hideElements(...elements){elements.forEach(el=>{el?.classList.add("none")})}function loadItemsInGrid(products,amountToLoad){if(products)for(let i=amountToLoad;i