1class SmartArticle{constructor(){this.selectors={floatingBtn:".sa-floating-btn",drawer:"#ArticleShoppingDrawer",drawerContent:"#ArticleDrawerContent",backdrop:".sc-drawer-backdrop",closeTriggers:".js-close-drawer, .sc-drawer-backdrop",hero:".smart-hero",heroImage:".parallax-img-container img",heroAmbient:".smart-hero__ambient-bg img",heroText:".parallax-text-container",articleLinks:".main-article a",staticContent:"#sa-static-content",templateProduct:"#sa-product-template",contentWrapper:".sa-content-wrapper"},this.state={productHandles:[],isDrawerLoading:!1},this.init()}init(){if(this.cacheElements(),this.hero&&this.checkHeroContrast(),!this.floatingBtn)return;this.bindEvents(),this.initScroll(),this.cleanProductLinks();const handlesStr=this.floatingBtn.dataset.products||"";this.state.productHandles=handlesStr.split(",").filter(h=>h.trim()!==""),this.fetchVideoTitles()}cacheElements(){this.floatingBtn=document.querySelector(this.selectors.floatingBtn),this.drawer=document.querySelector(this.selectors.drawer),this.drawerContent=document.querySelector(this.selectors.drawerContent),this.backdrop=document.querySelector(this.selectors.backdrop),this.staticContentContainer=document.querySelector(this.selectors.staticContent),this.productTemplate=document.querySelector(this.selectors.templateProduct)?.innerHTML,this.contentWrapper=document.querySelector(this.selectors.contentWrapper),this.hero=document.querySelector(this.selectors.hero),this.heroImg=document.querySelector(this.selectors.heroImage),this.heroAmbient=document.querySelector(this.selectors.heroAmbient),this.heroTxt=document.querySelector(this.selectors.heroText)}bindEvents(){this.floatingBtn.addEventListener("click",e=>{e.preventDefault(),this.openDrawerHub()}),document.querySelectorAll(this.selectors.closeTriggers).forEach(btn=>{btn.addEventListener("click",e=>{(e.target===this.backdrop||e.target.closest(".js-close-drawer"))&&(e.preventDefault(),this.closeDrawer())})}),document.addEventListener("keydown",e=>{e.key==="Escape"&&this.drawer?.classList.contains("is-open")&&this.closeDrawer()})}checkHeroContrast(){if(!this.hero||!this.heroImg)return;const img=new Image;img.crossOrigin="Anonymous",img.src=this.heroImg.currentSrc||this.heroImg.src,img.complete?this.analyzeImage(img):img.onload=()=>this.analyzeImage(img)}analyzeImage(img){try{const canvas=document.createElement("canvas"),ctx=canvas.getContext("2d");canvas.width=50,canvas.height=50,ctx.drawImage(img,0,0,50,50);const data=ctx.getImageData(0,0,50,50).data;let dangerousPixelCount=0;const totalPixels=data.length/4;for(let i=0;i<data.length;i+=4){const r=data[i]/255,g=data[i+1]/255,b=data[i+2]/255,max=Math.max(r,g,b),min=Math.min(r,g,b);let h,s,l=(max+min)/2;if(max===min)h=s=0;else{const d=max-min;s=l>.5?d/(2-max-min):d/(max+min)}l>.85&&s<.2&&dangerousPixelCount++}dangerousPixelCount/totalPixels*100>25?this.hero.classList.add("is-bright"):this.hero.classList.remove("is-bright")}catch{}}cleanProductLinks(){document.querySelectorAll(this.selectors.articleLinks).forEach(link=>{const href=link.getAttribute("href");href&&href.includes("/products/")&&link.removeAttribute("target")})}initScroll(){window.addEventListener("scroll",()=>{requestAnimationFrame(()=>{const scrollTop=window.scrollY;if(this.floatingBtn){let isFinished=!1;if(this.contentWrapper){const boundary=this.contentWrapper.offsetTop+this.contentWrapper.offsetHeight;scrollTop+window.innerHeight>=boundary&&(isFinished=!0)}scrollTop>300&&!isFinished?this.floatingBtn.classList.add("is-visible"):this.floatingBtn.classList.remove("is-visible")}this.hero&&scrollTop<=this.hero.offsetHeight&&(this.heroImg&&(this.heroImg.style.transform=`translate3d(0, ${scrollTop*.5}px, 0)`),this.heroTxt&&(this.heroTxt.style.transform=`translate3d(0, ${scrollTop*.15}px, 0)`),this.heroAmbient&&(this.heroAmbient.style.transform=`translate3d(0, ${scrollTop*.25}px, 0) scale(1.2) scaleX(-1)`))})})}async fetchVideoTitles(){if(!this.staticContentContainer)return;this.staticContentContainer.querySelectorAll(".js-youtube-title").forEach(async link=>{const url=link.href;if(url)try{const data=await(await fetch(`https://noembed.com/embed?url=${url}`)).json();data.title&&(link.textContent=data.title.length>60?data.title.substring(0,60)+"...":data.title)}catch{}})}toggleDrawer(open){this.drawer&&(open?(this.drawer.classList.add("is-open"),this.backdrop&&this.backdrop.classList.add("is-open"),document.body.style.overflow="hidden"):(this.drawer.classList.remove("is-open"),this.backdrop&&this.backdrop.classList.remove("is-open"),document.body.style.overflow=""))}closeDrawer(){this.toggleDrawer(!1)}async openDrawerHub(){if(this.toggleDrawer(!0),this.drawer.dataset.loaded==="true")return;this.drawerContent.innerHTML='<div class="loader-spinner"></div>';const staticHtml=this.staticContentContainer?this.staticContentContainer.innerHTML:"",handles=this.state.productHandles;let productsHtml="";const textShopping=this.drawer.dataset.textShopping,textEmpty=this.drawer.dataset.textEmpty,textError=this.drawer.dataset.textError,textSoldout=this.drawer.dataset.textSoldout,textViewProduct=this.drawer.dataset.textViewProduct;try{if(handles.length>0){const promises=handles.map(handle=>fetch(window.Shopify.routes.root+`products/${handle.trim()}.js`).then(r=>
1r.ok?r.json():null).catch(()=>null));(await Promise.all(promises)).forEach(p=>{if(!p)return;const price=(p.price/100).toFixed(2)+" "+(window.Shopify.currency.active||"\u20AC");let currentViewText=textViewProduct;p.available||(currentViewText=textSoldout);let card=this.productTemplate.replace(/__url__/g,p.url).replace(/__image__/g,p.featured_image).replace(/__title__/g,p.title).replace(/__price__/g,price).replace(/__view_text__/g,currentViewText);p.available?productsHtml+=card:productsHtml+=`<div style="opacity: 0.5; pointer-events: none;">${card}</div>`})}productsHtml!==""&&(productsHtml=`<div class="sa-drawer-section"><h3 class="sa-drawer-section-title">${textShopping}</h3>${productsHtml}</div>`);const finalHtml=productsHtml+staticHtml;finalHtml.trim()===""?this.drawerContent.innerHTML=`<p style="text-align:center; padding:30px; font-size:13px; color:#666;">${textEmpty}</p>`:(this.drawerContent.innerHTML=finalHtml,this.drawer.dataset.loaded="true")}catch{this.drawerContent.innerHTML=`<p style="text-align:center; padding:30px;">${textError}</p>`}}}document.addEventListener("DOMContentLoaded",()=>{new SmartArticle}); 2//# sourceMappingURL=/cdn/shop/t/78/assets/smart-article.js.map?v=142520349463092737321780840552
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.