text: const slidesData=document.querySelectorAll(".slideHref"),slides=Array.from(document.querySelectorAll(".slide")),slideTotal=slides.length,caption=Array.from(document.querySelectorAll(".art-info")),articleImages=document.getElementsByClassName("article-images"),carouselOverlay=document.getElementById("carousel-overlay"),figureCurrent=document.getElementById("figure-current"),carouselFigcaptionCurrent=document.getElementById("carousel-caption"),currentSlide=document.getElementById("current-slide"),nextSlide=document.getElementById("next-slide"),prevSlide=document.getElementById("prev-slide"),nextButton=document.getElementById("carousel-button-next"),prevButton=document.getElementById("carousel-button-prev"),closeButton=document.getElementById("carousel-button-close");let targetIndex=0;for(let e=0;e<articleImages.length;e++)articleImages[e].addEventListener("click",(e=>{e.preventDefault();let t=e.target.closest("figure");if(!t)return;document.body.style.overflow="hidden",document.body.style.height="100%",carouselOverlay.style.display="grid",targetIndex=slides.findIndex((e=>e===t));let r=caption[targetIndex].innerHTML;carouselFigcaptionCurrent.innerHTML=r,currentSlide.src=slideHrefs[targetIndex],0===targetIndex?(prevButton.style="visibility:hidden",nextSlide.src=slideHrefs[targetIndex+1]):targetIndex===slideTotal-1?(nextButton.style="visibility:hidden",prevSlide.src=slideHrefs[targetIndex-1]):(nextSlide.src=slideHrefs[targetIndex+1],prevSlide.src=slideHrefs[targetIndex-1])}));let slideHrefs=[];for(let e=0;e<slidesData.length;e++)slideHrefs.push(slidesData[e].getAttribute("href"));function moveToNextSlide(){figureCurrent.setAttribute("style","opacity: 0; transform: translateX(100vw)"),prevButton.style="visibility:visible",targetIndex++,currentSlide.src=slideHrefs[targetIndex],prevSlide.src=slideHrefs[targetIndex-1],targetIndex===slideTotal-1?nextButton.style="visibility:hidden":nextSlide.src=slideHrefs[targetIndex+1],carouselFigcaptionCurrent.innerHTML=caption[targetIndex].innerHTML,currentSlide.onload=function(){setTimeout(fadeIn,200)}}function moveToPrevSlide(){figureCurrent.setAttribute("style","opacity: 0; transform: translateX(-100vw)"),nextButton.style="visibility:visible",targetIndex--,currentSlide.src=slideHrefs[targetIndex],nextSlide.src=slideHrefs[targetIndex+1],targetIndex<1?prevButton.style="visibility:hidden":prevSlide.src=slideHrefs[targetIndex-1],carouselFigcaptionCurrent.innerHTML=caption[targetIndex].innerHTML,currentSlide.onload=function(){setTimeout(fadeIn,200)}}function fadeIn(){figureCurrent.setAttribute("style","opacity: 1;transform: translateX(0); transition: opacity .2s, transform .2s")}function close(){carouselOverlay.style.display="none",document.body.style.overflow="auto",document.body.style.height="auto",prevButton.style="visibility:visible",nextButton.style="visibility:visible",currentSlide.src="#",prevSlide.src="#",nextSlide.src="#"}nextButton.addEventListener("click",moveToNextSlide),prevButton.addEventListener("click",moveToPrevSlide),closeButton.addEventListener("click",close),window.addEventListener("keydown",(function(e){"Escape"===e.key&&close()}));