class MagicScroll{constructor(t){if(Object.assign(this,t),this.targetIsDocument=!1,this.target||(this.targetIsDocument=!0,this.target=document.scrollingElement||document.documentElement||document.body.parentNode||document.body),this.target.classList.add("smooth-scroll"),this.motionElement=document.getElementsByClassName("content-area")[0],this.isFirefox=navigator.userAgent.toLowerCase().indexOf("firefox")>-1,this.isSafari=(navigator.vendor.match(/apple/i)||"").length>0,this.isSafari)return;this.scrollingFast=!1,this.speed=120,this.smooth=12,this.accelerationDelta=40,this.stepSize=3,this.horizontal="true"===this.target.dataset.horizontalScroll,this.blurEffect="true"===this.target.dataset.blurEffect,this.skewEffect="true"===this.target.dataset.skewEffect,this.scaleEffect="true"===this.target.dataset.scaleEffect,this.blurEffect=!1,this.skewEffect=!1,this.scaleEffect=!1,this.isOverflowHidden=!1,this.horizontal?this.pos=this.current||window.document.scrollingElement.scrollLeft:this.pos=this.current||window.document.scrollingElement.scrollTop,this.frame=this.target===document.body&&document.documentElement?document.documentElement:this.target,this.min=this.min||0,this.horizontal?this.max=this.target.scrollWidth-this.target.clientWidth:this.max=this.target.scrollHeight-this.target.clientHeight,this.moving=!1,this.horizontal?this.target.scrollLeft=this.pos:this.target.scrollTop=this.pos,this.target.addEventListener("mousewheel",s,{passive:!1}),this.target.addEventListener("DOMMouseScroll",s,{passive:!1}),this.target.addEventListener("scroll",t=>{this.moving||(this.horizontal?this.pos=t.target.scrollLeft:this.pos=t.target.scrollTop)},{passive:!1});const e=this;function s(t){if(e.isOverflowHidden="hidden"===e.target.style.overflow,!e.isOverflowHidden){t.preventDefault();var s=e.normalizeWheelDelta(t);e.pos+=-s*e.speed*(e.stepSize/10),e.pos=Math.max(0,Math.min(e.pos,e.max)),e.moving||e.update()}}this.scrollbarActive=!1;this.targetIsDocument&&(document.onmousedown=function(t){e.horizontal?e.target.clientHeight<=t.clientY&&(e.scrollbarActive=!0):e.target.clientWidth<=t.clientX&&(e.scrollbarActive=!0)},document.onmouseup=function(){e.scrollbarActive=!1},document.addEventListener("scroll",t=>{e.moving||(this.horizontal?e.pos=window.document.scrollingElement.scrollLeft:e.pos=window.document.scrollingElement.scrollTop)},{passive:!1}));var i=function(){e.horizontal?e.max=e.target.scrollWidth-e.target.clientWidth:e.max=e.target.scrollHeight-e.target.clientHeight},o=null;window.addEventListener("resize",function(){clearTimeout(o),o=setTimeout(i,300)}),window.addEventListener("load",t=>{clearTimeout(o),o=setTimeout(i,300)})}normalizeWheelDelta(t){return t.detail?t.wheelDelta?t.wheelDelta/t.detail/40*(t.detail>0?1:-1):-t.detail/3:t.wheelDelta/this.accelerationDelta}update(){if(this.moving=!0,this.endScroll=!1,this.horizontal){var t=(this.pos-14-this.target.scrollLeft)/this.smooth;this.target.scrollLeft+=t,this.max=this.target.scrollWidth-this.target.clientWidth+42,(0==this.target.scrollLeft||this.target.scrollLeft>=this.max-43)&&(this.endScroll=!0)}else{t=(this.pos-14-this.target.scrollTop)/this.smooth;this.target.scrollTop+=t,this.max=this.target.scrollHeight-this.target.clientHeight+28,(0==this.target.scrollTop||this.target.scrollTop>=this.max-29)&&(this.endScroll=!0)}this.isOverflowHidden="hidden"===this.target.style.overflow;const e=this;Math.abs(t)>1&&!e.scrollbarActive&&!e.isOverflowHidden&&!this.endScroll?requestFrame(()=>{e.target.classList.add("scrolling"),Math.abs(t)>16&&(this.scrollingFast=!0);var s="";e.blurEffect&&this.scrollingFast&&(this.motionElement.style.filter="blur(calc(("+Math.abs(t)+" / 12) * 1px))"),e.skewEffect&&this.scrollingFast&&(e.horizontal?s+=" skewX(calc(("+t+" / 20) * 1deg))":s+=" skewY(calc(("+t+" / 24) * 1deg))"),e.scaleEffect&&this.scrollingFast&&(e.horizontal?s+=" scaleY("+(1-Math.abs(t)/400)+")":s+=" scaleX("+(1-t/600)+")"),""!==s&&!this.isFirefox&&this.scrollingFast&&(this.motionElement.style.transform=s),e.update()}):(this.moving=!1,this.scrollingFast=!1,this.target.classList.remove("scrolling"),this.blurEffect,(this.skewEffect||this.scaleEffect)&&(this.motionElement.style.transform="none"))}}var requestFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,100)};window.addEventListener("DOMContentLoaded",t=>{new MagicScroll({})});