import{t as e}from"./rolldown-runtime.Dh6celcD.mjs";import{E as t,F as n,L as r,S as i,c as a,j as o,o as s,s as c}from"./react.BpKPsBQp.mjs";import{O as l,Y as u,s as d}from"./framer.UluLglJe.mjs";function f(e,t,n){return Math.max(e,Math.min(t,n))}var p,m,h,g,_,v,y=e((()=>{n(),p=class{advance(e){if(!this.isRunning)return;let t=!1;if(this.lerp)this.value=(n=this.value,r=this.to,i=60*this.lerp,a=e,function(e,t,n){return(1-n)*e+n*t}(n,r,1-Math.exp(-i*a))),Math.round(this.value)===this.to&&(this.value=this.to,t=!0);else{this.currentTime+=e;let n=f(0,this.currentTime/this.duration,1);t=n>=1;let r=t?1:this.easing(n);this.value=this.from+(this.to-this.from)*r}var n,r,i,a;this.onUpdate?.(this.value,t),t&&this.stop()}stop(){this.isRunning=!1}fromTo(e,t,{lerp:n=.1,duration:r=1,easing:i=(e=>e),onStart:a,onUpdate:o}){this.from=this.value=e,this.to=t,this.lerp=n,this.duration=r,this.easing=i,this.currentTime=0,this.isRunning=!0,a?.(),this.onUpdate=o}},m=class{constructor({wrapper:e,content:t,autoResize:n=!0,debounce:i=250}={}){this.wrapper=e,this.content=t,n&&(this.debouncedResize=function(e,t){let n;return function(){let r=arguments,i=this;clearTimeout(n),n=setTimeout((function(){e.apply(i,r)}),t)}}(this.resize,i),this.wrapper===r?r.addEventListener(`resize`,this.debouncedResize,!1):(this.wrapperResizeObserver=new ResizeObserver(this.debouncedResize),this.wrapperResizeObserver.observe(this.wrapper)),this.contentResizeObserver=new ResizeObserver(this.debouncedResize),this.contentResizeObserver.observe(this.content)),this.resize()}destroy(){this.wrapperResizeObserver?.disconnect(),this.contentResizeObserver?.disconnect(),r.removeEventListener(`resize`,this.debouncedResize,!1)}resize=()=>{this.onWrapperResize(),this.onContentResize()};onWrapperResize=()=>{this.wrapper===r?(this.width=r.innerWidth,this.height=r.innerHeight):(this.width=this.wrapper.clientWidth,this.height=this.wrapper.clientHeight)};onContentResize=()=>{this.wrapper===r?(this.scrollHeight=this.content.scrollHeight,this.scrollWidth=this.content.scrollWidth):(this.scrollHeight=this.wrapper.scrollHeight,this.scrollWidth=this.wrapper.scrollWidth)};get limit(){return{x:this.scrollWidth-this.width,y:this.scrollHeight-this.height}}},h=class{constructor(){this.events={}}emit(e,...t){let n=this.events[e]||[];for(let e=0,r=n.length;e{this.events[e]=this.events[e]?.filter((e=>t!==e))}}off(e,t){this.events[e]=this.events[e]?.filter((e=>t!==e))}destroy(){this.events={}}},g=100/6,_=class{constructor(e,{wheelMultiplier:t=1,touchMultiplier:n=1}){this.element=e,this.wheelMultiplier=t,this.touchMultiplier=n,this.touchStart={x:null,y:null},this.emitter=new h,r.addEventListener(`resize`,this.onWindowResize,!1),this.onWindowResize(),this.element.addEventListener(`wheel`,this.onWheel,{passive:!1}),this.element.addEventListener(`touchstart`,this.onTouchStart,{passive:!1}),this.element.addEventListener(`touchmove`,this.onTouchMove,{passive:!1}),this.element.addEventListener(`touchend`,this.onTouchEnd,{passive:!1})}on(e,t){return this.emitter.on(e,t)}destroy(){this.emitter.destroy(),r.removeEventListener(`resize`,this.onWindowResize,!1),this.element.removeEventListener(`wheel`,this.onWheel,{passive:!1}),this.element.removeEventListener(`touchstart`,this.onTouchStart,{passive:!1}),this.element.removeEventListener(`touchmove`,this.onTouchMove,{passive:!1}),this.element.removeEventListener(`touchend`,this.onTouchEnd,{passive:!1})}onTouchStart=e=>{let{clientX:t,clientY:n}=e.targetTouches?e.targetTouches[0]:e;this.touchStart.x=t,this.touchStart.y=n,this.lastDelta={x:0,y:0},this.emitter.emit(`scroll`,{deltaX:0,deltaY:0,event:e})};onTouchMove=e=>{let{clientX:t,clientY:n}=e.targetTouches?e.targetTouches[0]:e,r=-(t-this.touchStart.x)*this.touchMultiplier,i=-(n-this.touchStart.y)*this.touchMultiplier;this.touchStart.x=t,this.touchStart.y=n,this.lastDelta={x:r,y:i},this.emitter.emit(`scroll`,{deltaX:r,deltaY:i,event:e})};onTouchEnd=e=>{this.emitter.emit(`scroll`,{deltaX:this.lastDelta.x,deltaY:this.lastDelta.y,event:e})};onWheel=e=>{let{deltaX:t,deltaY:n,deltaMode:r}=e;t*=r===1?g:r===2?this.windowWidth:1,n*=r===1?g:r===2?this.windowHeight:1,t*=this.wheelMultiplier,n*=this.wheelMultiplier,this.emitter.emit(`scroll`,{deltaX:t,deltaY:n,event:e})};onWindowResize=()=>{this.windowWidth=r.innerWidth,this.windowHeight=r.innerHeight}},v=class{constructor({wrapper:e=r,content:t=document.documentElement,wheelEventsTarget:n=e,eventsTarget:i=n,smoothWheel:a=!0,syncTouch:o=!1,syncTouchLerp:s=.075,touchInertiaMultiplier:c=35,duration:l,easing:u=(e=>Math.min(1,1.001-2**(-10*e))),lerp:d=!l&&.1,infinite:f=!1,orientation:g=`vertical`,gestureOrientation:v=`vertical`,touchMultiplier:y=1,wheelMultiplier:b=1,autoResize:x=!0,__experimental__naiveDimensions:S=!1}={}){this.__isSmooth=!1,this.__isScrolling=!1,this.__isStopped=!1,this.__isLocked=!1,this.onVirtualScroll=({deltaX:e,deltaY:t,event:n})=>{if(n.ctrlKey)return;let r=n.type.includes(`touch`),i=n.type.includes(`wheel`);if(this.options.syncTouch&&r&&n.type===`touchstart`&&!this.isStopped&&!this.isLocked)return void this.reset();let a=e===0&&t===0,o=this.options.gestureOrientation===`vertical`&&t===0||this.options.gestureOrientation===`horizontal`&&e===0;if(a||o)return;let s=n.composedPath();if(s=s.slice(0,s.indexOf(this.rootElement)),s.find((e=>e.hasAttribute?.call(e,`data-lenis-prevent`)||r&&e.hasAttribute?.call(e,`data-lenis-prevent-touch`)||i&&e.hasAttribute?.call(e,`data-lenis-prevent-wheel`)||e.classList?.contains(`lenis`)&&!e.classList?.contains(`lenis-stopped`))))return;if(this.isStopped||this.isLocked)return void n.preventDefault();if(this.isSmooth=this.options.syncTouch&&r||this.options.smoothWheel&&i,!this.isSmooth)return this.isScrolling=!1,void this.animate.stop();n.preventDefault();let c=t;this.options.gestureOrientation===`both`?c=Math.abs(t)>Math.abs(e)?t:e:this.options.gestureOrientation===`horizontal`&&(c=e);let l=r&&this.options.syncTouch,u=r&&n.type===`touchend`&&Math.abs(c)>5;u&&(c=this.velocity*this.options.touchInertiaMultiplier),this.scrollTo(this.targetScroll+c,Object.assign({programmatic:!1},l?{lerp:u?this.options.syncTouchLerp:1}:{lerp:this.options.lerp,duration:this.options.duration,easing:this.options.easing}))},this.onNativeScroll=()=>{if(!this.__preventNextScrollEvent&&!this.isScrolling){let e=this.animatedScroll;this.animatedScroll=this.targetScroll=this.actualScroll,this.velocity=0,this.direction=Math.sign(this.animatedScroll-e),this.emit()}},r.lenisVersion=`1.0.42`,e!==document.documentElement&&e!==document.body||(e=r),this.options={wrapper:e,content:t,wheelEventsTarget:n,eventsTarget:i,smoothWheel:a,syncTouch:o,syncTouchLerp:s,touchInertiaMultiplier:c,duration:l,easing:u,lerp:d,infinite:f,gestureOrientation:v,orientation:g,touchMultiplier:y,wheelMultiplier:b,autoResize:x,__experimental__naiveDimensions:S},this.animate=new p,this.emitter=new h,this.dimensions=new m({wrapper:e,content:t,autoResize:x}),this.toggleClassName(`lenis`,!0),this.velocity=0,this.isLocked=!1,this.isStopped=!1,this.isSmooth=o||a,this.isScrolling=!1,this.targetScroll=this.animatedScroll=this.actualScroll,this.options.wrapper.addEventListener(`scroll`,this.onNativeScroll,!1),this.virtualScroll=new _(i,{touchMultiplier:y,wheelMultiplier:b}),this.virtualScroll.on(`scroll`,this.onVirtualScroll)}destroy(){this.emitter.destroy(),this.options.wrapper.removeEventListener(`scroll`,this.onNativeScroll,!1),this.virtualScroll.destroy(),this.dimensions.destroy(),this.toggleClassName(`lenis`,!1),this.toggleClassName(`lenis-smooth`,!1),this.toggleClassName(`lenis-scrolling`,!1),this.toggleClassName(`lenis-stopped`,!1),this.toggleClassName(`lenis-locked`,!1)}on(e,t){return this.emitter.on(e,t)}off(e,t){return this.emitter.off(e,t)}setScroll(e){this.isHorizontal?this.rootElement.scrollLeft=e:this.rootElement.scrollTop=e}resize(){this.dimensions.resize()}emit(){this.emitter.emit(`scroll`,this)}reset(){this.isLocked=!1,this.isScrolling=!1,this.animatedScroll=this.targetScroll=this.actualScroll,this.velocity=0,this.animate.stop()}start(){this.isStopped&&(this.isStopped=!1,this.reset())}stop(){this.isStopped||(this.isStopped=!0,this.animate.stop(),this.reset())}raf(e){let t=e-(this.time||e);this.time=e,this.animate.advance(.001*t)}scrollTo(e,{offset:t=0,immediate:n=!1,lock:i=!1,duration:a=this.options.duration,easing:o=this.options.easing,lerp:s=!a&&this.options.lerp,onComplete:c,force:l=!1,programmatic:u=!0}={}){if(!this.isStopped&&!this.isLocked||l){if([`top`,`left`,`start`].includes(e))e=0;else if([`bottom`,`right`,`end`].includes(e))e=this.limit;else{let n;if(typeof e==`string`?n=document.querySelector(e):e!=null&&e.nodeType&&(n=e),n){if(this.options.wrapper!==r){let e=this.options.wrapper.getBoundingClientRect();t-=this.isHorizontal?e.left:e.top}let i=n.getBoundingClientRect();e=(this.isHorizontal?i.left:i.top)+this.animatedScroll}}if(typeof e==`number`){if(e+=t,e=Math.round(e),this.options.infinite?u&&(this.targetScroll=this.animatedScroll=this.scroll):e=f(0,e,this.limit),n)return this.animatedScroll=this.targetScroll=e,this.setScroll(this.scroll),this.reset(),void(c==null||c(this));if(!u){if(e===this.targetScroll)return;this.targetScroll=e}this.animate.fromTo(this.animatedScroll,e,{duration:a,easing:o,lerp:s,onStart:()=>{i&&(this.isLocked=!0),this.isScrolling=!0},onUpdate:(e,t)=>{this.isScrolling=!0,this.velocity=e-this.animatedScroll,this.direction=Math.sign(this.velocity),this.animatedScroll=e,this.setScroll(this.scroll),u&&(this.targetScroll=e),t||this.emit(),t&&(this.reset(),this.emit(),c?.(this),this.__preventNextScrollEvent=!0,requestAnimationFrame((()=>{delete this.__preventNextScrollEvent})))}})}}}get rootElement(){return this.options.wrapper===r?document.documentElement:this.options.wrapper}get limit(){return this.options.__experimental__naiveDimensions?this.isHorizontal?this.rootElement.scrollWidth-this.rootElement.clientWidth:this.rootElement.scrollHeight-this.rootElement.clientHeight:this.dimensions.limit[this.isHorizontal?`x`:`y`]}get isHorizontal(){return this.options.orientation===`horizontal`}get actualScroll(){return this.isHorizontal?this.rootElement.scrollLeft:this.rootElement.scrollTop}get scroll(){return this.options.infinite?(e=this.animatedScroll,t=this.limit,(e%t+t)%t):this.animatedScroll;var e,t}get progress(){return this.limit===0?1:this.scroll/this.limit}get isSmooth(){return this.__isSmooth}set isSmooth(e){this.__isSmooth!==e&&(this.__isSmooth=e,this.toggleClassName(`lenis-smooth`,e))}get isScrolling(){return this.__isScrolling}set isScrolling(e){this.__isScrolling!==e&&(this.__isScrolling=e,this.toggleClassName(`lenis-scrolling`,e))}get isStopped(){return this.__isStopped}set isStopped(e){this.__isStopped!==e&&(this.__isStopped=e,this.toggleClassName(`lenis-stopped`,e))}get isLocked(){return this.__isLocked}set isLocked(e){this.__isLocked!==e&&(this.__isLocked=e,this.toggleClassName(`lenis-locked`,e))}get className(){let e=`lenis`;return this.isStopped&&(e+=` lenis-stopped`),this.isLocked&&(e+=` lenis-locked`),this.isScrolling&&(e+=` lenis-scrolling`),this.isSmooth&&(e+=` lenis-smooth`),e}toggleClassName(e,t){this.rootElement.classList.toggle(e,t),this.emitter.emit(`className change`,this)}}}));function b(e){let{intensity:n}=e,i=t(null);return o(()=>{i.current&&i.current.scrollTo(0,{immediate:!0})},[i]),o(()=>{let e=document.getElementById(`overlay`);if(e){let t=new MutationObserver((t,n)=>{for(let n of t)if(n.type===`childList`&&e.children.length>0){let t=document.documentElement;r.getComputedStyle(t).getPropertyValue(`overflow`)===`hidden`&&e.setAttribute(`data-lenis-prevent`,`true`)}});return t.observe(e,{childList:!0}),()=>t.disconnect()}},[]),o(()=>{let e=document.getElementsByTagName(`*`);for(let t=0;t{i.current=new v({duration:n/10});let e=t=>{i.current&&(i.current.raf(t),requestAnimationFrame(e))};return requestAnimationFrame(e),()=>{i.current&&=(i.current.destroy(),null)}},[]),o(()=>{let e=document.createElement(`style`);return e.textContent=` html.lenis { height: auto; } .lenis.lenis-smooth { scroll-behavior: auto !important; } .lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; } .lenis.lenis-stopped { overflow: hidden; } .lenis.lenis-scrolling iframe { pointer-events: none; } `,document.head.appendChild(e),()=>{document.head.removeChild(e)}},[]),o(()=>{let e=[...document.querySelectorAll(`a[href]`)],t=(e,t)=>{e.preventDefault(),i.current.scrollTo(t)};return e.filter(e=>e.href.includes(`#`)).forEach(e=>{let n=`#${e.href.split(`#`).pop()}`;e.addEventListener(`click`,e=>t(e,n))}),()=>{e.filter(e=>e.href.includes(`#`)).forEach(e=>{e.removeEventListener(`click`,t)})}},[i]),a(c,{})}var x=e((()=>{n(),s(),u(),y(),i(),b.displayName=`Smooth Scroll`,l(b,{intensity:{title:`Intensity`,type:d.Number,defaultValue:10}})}));export{x as n,b as t}; //# sourceMappingURL=Smooth_Scroll.DxaYng6A.mjs.map