(()=>{"use strict";class t{constructor(t){this.imageScroll=t,this.imageContainer=this.imageScroll.querySelector(".ablocks-block-container"),this.imageContainerWidth=this.imageContainer.getBoundingClientRect().width,this.imageFigure=this.imageScroll.querySelector(".ablocks-image-scroll__figure"),this.scrollOption=this.imageFigure.getAttribute("data-scroll-option");const e=this.imageFigure.getAttribute("data-scroll-height");try{const t=JSON.parse(e);this.scrollHeight="object"==typeof t?t.value:t}catch(t){this.scrollHeight=parseInt(e)||0}this.transitionTime=parseInt(this.imageFigure.getAttribute("data-transition-time")),this.image=this.imageScroll.querySelector(".ablocks-image-scroll__figure img"),this.image&&(this.imageSize=null,this.imageWidth=null,this.image.onload=()=>this.onImageLoad(),this.image.complete&&this.onImageLoad(),this.imageFigure.style.transitionDuration=`${this.transitionTime}s`,this.imageScroll.addEventListener("mouseenter",()=>this.handleMouseEnter()),this.imageScroll.addEventListener("mouseleave",()=>this.handleMouseLeave()))}onImageLoad(){this.imageSize=this.image.offsetHeight,this.imageWidth=this.image.offsetWidth,this.applyTransformations()}applyTransformations(){switch(this.scrollOption){case"mouse-scroll":case"horizontal-scroll":this.imageFigure.style.transform="translateX(0) translateY(0)";break;case"bottom-to-top":const t=this.imageSize-this.scrollHeight;this.imageFigure.style.transform=`translateY(${-Math.max(t,0)}px)`;break;case"right-to-left":const e=this.imageContainerWidth-this.imageWidth;this.imageFigure.style.transform=`translateX(${e}px)`}}handleMouseEnter(){switch(this.scrollOption){case"mouse-scroll":case"horizontal-scroll":this.imageFigure.style.transform="translateX(0) translateY(0)";break;case"top-to-bottom":const t=Math.max(this.imageSize-this.scrollHeight,0);this.imageFigure.style.transform=`translateY(${-t}px)`;break;case"bottom-to-top":this.imageFigure.style.transform="translateY(0)";break;case"left-to-right":const e=this.imageContainerWidth-this.imageWidth;this.imageFigure.style.transform=`translateX(${e}px)`;break;case"right-to-left":this.imageFigure.style.transform="translateX(0)"}}handleMouseLeave(){switch(this.scrollOption){case"mouse-scroll":case"horizontal-scroll":this.imageFigure.style.transform="translateX(0) translateY(0)";break;case"top-to-bottom":this.imageFigure.style.transform="translateY(0)";break;case"bottom-to-top":const t=this.imageSize-this.scrollHeight;this.imageFigure.style.transform=`translateY(${-Math.max(t,0)}px)`;break;case"left-to-right":this.imageFigure.style.transform="translateX(0)";break;case"right-to-left":const e=this.imageContainerWidth-this.imageWidth;this.imageFigure.style.transform=`translateX(${e}px)`}}imageLoaded(){return new Promise(t=>{this.imageSize?t(this.imageSize):this.image.onload=()=>{t(this.image.offsetHeight)}})}}document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll(".ablocks-block--image-scroll").forEach(e=>{new t(e,!1)})})})();