import{I as q,L as B}from"./chunk-ks5uwbwk.mjs";import{A as P,q as y,w as A,z as I}from"./chunk-ei2t6pks.mjs";import{c as l}from"./chunk-a3iiq6x3.mjs";function j(g,t,e){return Math.max(g,Math.min(t,e))}var k=class{constructor(){this.isRunning=!1,this.value=0,this.from=0,this.to=0,this.duration=0,this.currentTime=0}advance(t){var e;if(!this.isRunning)return;let s=!1;if(this.duration&&this.easing){this.currentTime+=t;let i=j(0,this.currentTime/this.duration,1);s=i>=1;let o=s?1:this.easing(i);this.value=this.from+(this.to-this.from)*o}else this.lerp?(this.value=function(o,n,r,h){return function(u,d,v){return(1-v)*u+v*d}(o,n,1-Math.exp(-r*h))}(this.value,this.to,60*this.lerp,t),Math.round(this.value)===this.to&&(this.value=this.to,s=!0)):(this.value=this.to,s=!0);s&&this.stop(),(e=this.onUpdate)===null||e===void 0||e.call(this,this.value,s)}stop(){this.isRunning=!1}fromTo(t,e,{lerp:s,duration:i,easing:o,onStart:n,onUpdate:r}){this.from=this.value=t,this.to=e,this.lerp=s,this.duration=i,this.easing=o,this.currentTime=0,this.isRunning=!0,n?.(),this.onUpdate=r}},O=class{constructor({wrapper:t,content:e,autoResize:s=!0,debounce:i=250}={}){this.width=0,this.height=0,this.scrollWidth=0,this.scrollHeight=0,this.resize=()=>{this.onWrapperResize(),this.onContentResize()},this.onWrapperResize=()=>{this.wrapper===l?(this.width=l.innerWidth,this.height=l.innerHeight):this.wrapper instanceof HTMLElement&&(this.width=this.wrapper.clientWidth,this.height=this.wrapper.clientHeight)},this.onContentResize=()=>{this.wrapper===l?(this.scrollHeight=this.content.scrollHeight,this.scrollWidth=this.content.scrollWidth):this.wrapper instanceof HTMLElement&&(this.scrollHeight=this.wrapper.scrollHeight,this.scrollWidth=this.wrapper.scrollWidth)},this.wrapper=t,this.content=e,s&&(this.debouncedResize=function(n,r){let h;return function(){let a=arguments,u=this;clearTimeout(h),h=setTimeout(function(){n.apply(u,a)},r)}}(this.resize,i),this.wrapper===l?l.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(){var t,e;(t=this.wrapperResizeObserver)===null||t===void 0||t.disconnect(),(e=this.contentResizeObserver)===null||e===void 0||e.disconnect(),l.removeEventListener("resize",this.debouncedResize,!1)}get limit(){return{x:this.scrollWidth-this.width,y:this.scrollHeight-this.height}}},L=class{constructor(){this.events={}}emit(t,...e){let s=this.events[t]||[];for(let i=0,o=s.length;i{var i;this.events[t]=(i=this.events[t])===null||i===void 0?void 0:i.filter(o=>e!==o)}}off(t,e){var s;this.events[t]=(s=this.events[t])===null||s===void 0?void 0:s.filter(i=>e!==i)}destroy(){this.events={}}},$=100/6,D=class{constructor(t,{wheelMultiplier:e=1,touchMultiplier:s=1}){this.lastDelta={x:0,y:0},this.windowWidth=0,this.windowHeight=0,this.onTouchStart=i=>{let{clientX:o,clientY:n}=i.targetTouches?i.targetTouches[0]:i;this.touchStart.x=o,this.touchStart.y=n,this.lastDelta={x:0,y:0},this.emitter.emit("scroll",{deltaX:0,deltaY:0,event:i})},this.onTouchMove=i=>{var o,n,r,h;let{clientX:a,clientY:u}=i.targetTouches?i.targetTouches[0]:i,d=-(a-((n=(o=this.touchStart)===null||o===void 0?void 0:o.x)!==null&&n!==void 0?n:0))*this.touchMultiplier,v=-(u-((h=(r=this.touchStart)===null||r===void 0?void 0:r.y)!==null&&h!==void 0?h:0))*this.touchMultiplier;this.touchStart.x=a,this.touchStart.y=u,this.lastDelta={x:d,y:v},this.emitter.emit("scroll",{deltaX:d,deltaY:v,event:i})},this.onTouchEnd=i=>{this.emitter.emit("scroll",{deltaX:this.lastDelta.x,deltaY:this.lastDelta.y,event:i})},this.onWheel=i=>{let{deltaX:o,deltaY:n,deltaMode:r}=i;o*=r===1?$:r===2?this.windowWidth:1,n*=r===1?$:r===2?this.windowHeight:1,o*=this.wheelMultiplier,n*=this.wheelMultiplier,this.emitter.emit("scroll",{deltaX:o,deltaY:n,event:i})},this.onWindowResize=()=>{this.windowWidth=l.innerWidth,this.windowHeight=l.innerHeight},this.element=t,this.wheelMultiplier=e,this.touchMultiplier=s,this.touchStart={x:null,y:null},this.emitter=new L,l.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(t,e){return this.emitter.on(t,e)}destroy(){this.emitter.destroy(),l.removeEventListener("resize",this.onWindowResize,!1),this.element.removeEventListener("wheel",this.onWheel),this.element.removeEventListener("touchstart",this.onTouchStart),this.element.removeEventListener("touchmove",this.onTouchMove),this.element.removeEventListener("touchend",this.onTouchEnd)}},M=class{constructor({wrapper:t=l,content:e=document.documentElement,wheelEventsTarget:s=t,eventsTarget:i=s,smoothWheel:o=!0,syncTouch:n=!1,syncTouchLerp:r=.075,touchInertiaMultiplier:h=35,duration:a,easing:u=f=>Math.min(1,1.001-Math.pow(2,-10*f)),lerp:d=.1,infinite:v=!1,orientation:p="vertical",gestureOrientation:S="vertical",touchMultiplier:_=1,wheelMultiplier:U=1,autoResize:F=!0,prevent:K,virtualScroll:G,__experimental__naiveDimensions:J=!1}={}){this.__isScrolling=!1,this.__isStopped=!1,this.__isLocked=!1,this.userData={},this.lastVelocity=0,this.velocity=0,this.direction=0,this.onPointerDown=f=>{f.button===1&&this.reset()},this.onVirtualScroll=f=>{if(typeof this.options.virtualScroll=="function"&&this.options.virtualScroll(f)===!1)return;let{deltaX:w,deltaY:E,event:c}=f;if(this.emitter.emit("virtual-scroll",{deltaX:w,deltaY:E,event:c}),c.ctrlKey)return;let T=c.type.includes("touch"),X=c.type.includes("wheel");if(this.isTouching=c.type==="touchstart"||c.type==="touchmove",this.options.syncTouch&&T&&c.type==="touchstart"&&!this.isStopped&&!this.isLocked)return void this.reset();let Q=w===0&&E===0,Z=this.options.gestureOrientation==="vertical"&&E===0||this.options.gestureOrientation==="horizontal"&&w===0;if(Q||Z)return;let b=c.composedPath();b=b.slice(0,b.indexOf(this.rootElement));let N=this.options.prevent;if(b.find(m=>{var R,x,H,W,C;return m instanceof Element&&(typeof N=="function"&&N?.(m)||((R=m.hasAttribute)===null||R===void 0?void 0:R.call(m,"data-lenis-prevent"))||T&&((x=m.hasAttribute)===null||x===void 0?void 0:x.call(m,"data-lenis-prevent-touch"))||X&&((H=m.hasAttribute)===null||H===void 0?void 0:H.call(m,"data-lenis-prevent-wheel"))||((W=m.classList)===null||W===void 0?void 0:W.contains("lenis"))&&!(!((C=m.classList)===null||C===void 0)&&C.contains("lenis-stopped")))}))return;if(this.isStopped||this.isLocked)return void c.preventDefault();if(!(this.options.syncTouch&&T||this.options.smoothWheel&&X))return this.isScrolling="native",void this.animate.stop();c.preventDefault();let z=E;this.options.gestureOrientation==="both"?z=Math.abs(E)>Math.abs(w)?E:w:this.options.gestureOrientation==="horizontal"&&(z=w);let tt=T&&this.options.syncTouch,Y=T&&c.type==="touchend"&&Math.abs(z)>5;Y&&(z=this.velocity*this.options.touchInertiaMultiplier),this.scrollTo(this.targetScroll+z,Object.assign({programmatic:!1},tt?{lerp:Y?this.options.syncTouchLerp:1}:{lerp:this.options.lerp,duration:this.options.duration,easing:this.options.easing}))},this.onNativeScroll=()=>{if(clearTimeout(this.__resetVelocityTimeout),delete this.__resetVelocityTimeout,this.__preventNextNativeScrollEvent)delete this.__preventNextNativeScrollEvent;else if(this.isScrolling===!1||this.isScrolling==="native"){let f=this.animatedScroll;this.animatedScroll=this.targetScroll=this.actualScroll,this.lastVelocity=this.velocity,this.velocity=this.animatedScroll-f,this.direction=Math.sign(this.animatedScroll-f),this.isScrolling="native",this.emit(),this.velocity!==0&&(this.__resetVelocityTimeout=setTimeout(()=>{this.lastVelocity=this.velocity,this.velocity=0,this.isScrolling=!1,this.emit()},400))}},l.lenisVersion="1.1.9",t&&t!==document.documentElement&&t!==document.body||(t=l),this.options={wrapper:t,content:e,wheelEventsTarget:s,eventsTarget:i,smoothWheel:o,syncTouch:n,syncTouchLerp:r,touchInertiaMultiplier:h,duration:a,easing:u,lerp:d,infinite:v,gestureOrientation:S,orientation:p,touchMultiplier:_,wheelMultiplier:U,autoResize:F,prevent:K,virtualScroll:G,__experimental__naiveDimensions:J},this.animate=new k,this.emitter=new L,this.dimensions=new O({wrapper:t,content:e,autoResize:F}),this.updateClassName(),this.userData={},this.time=0,this.velocity=this.lastVelocity=0,this.isLocked=!1,this.isStopped=!1,this.isScrolling=!1,this.targetScroll=this.animatedScroll=this.actualScroll,this.options.wrapper.addEventListener("scroll",this.onNativeScroll,!1),this.options.wrapper.addEventListener("pointerdown",this.onPointerDown,!1),this.virtualScroll=new D(i,{touchMultiplier:_,wheelMultiplier:U}),this.virtualScroll.on("scroll",this.onVirtualScroll)}destroy(){this.emitter.destroy(),this.options.wrapper.removeEventListener("scroll",this.onNativeScroll,!1),this.options.wrapper.removeEventListener("pointerdown",this.onPointerDown,!1),this.virtualScroll.destroy(),this.dimensions.destroy(),this.cleanUpClassName()}on(t,e){return this.emitter.on(t,e)}off(t,e){return this.emitter.off(t,e)}setScroll(t){this.isHorizontal?this.rootElement.scrollLeft=t:this.rootElement.scrollTop=t}resize(){this.dimensions.resize()}emit(){this.emitter.emit("scroll",this)}reset(){this.isLocked=!1,this.isScrolling=!1,this.animatedScroll=this.targetScroll=this.actualScroll,this.lastVelocity=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(t){let e=t-(this.time||t);this.time=t,this.animate.advance(.001*e)}scrollTo(t,{offset:e=0,immediate:s=!1,lock:i=!1,duration:o=this.options.duration,easing:n=this.options.easing,lerp:r=this.options.lerp,onStart:h,onComplete:a,force:u=!1,programmatic:d=!0,userData:v={}}={}){if(!this.isStopped&&!this.isLocked||u){if(typeof t=="string"&&["top","left","start"].includes(t))t=0;else if(typeof t=="string"&&["bottom","right","end"].includes(t))t=this.limit;else{let p;if(typeof t=="string"?p=document.querySelector(t):t instanceof HTMLElement&&t?.nodeType&&(p=t),p){if(this.options.wrapper!==l){let _=this.rootElement.getBoundingClientRect();e-=this.isHorizontal?_.left:_.top}let S=p.getBoundingClientRect();t=(this.isHorizontal?S.left:S.top)+this.animatedScroll}}if(typeof t=="number"&&(t+=e,t=Math.round(t),this.options.infinite?d&&(this.targetScroll=this.animatedScroll=this.scroll):t=j(0,t,this.limit),t!==this.targetScroll)){if(this.userData=v,s)return this.animatedScroll=this.targetScroll=t,this.setScroll(this.scroll),this.reset(),this.preventNextNativeScrollEvent(),this.emit(),a?.(this),void(this.userData={});d||(this.targetScroll=t),this.animate.fromTo(this.animatedScroll,t,{duration:o,easing:n,lerp:r,onStart:()=>{i&&(this.isLocked=!0),this.isScrolling="smooth",h?.(this)},onUpdate:(p,S)=>{this.isScrolling="smooth",this.lastVelocity=this.velocity,this.velocity=p-this.animatedScroll,this.direction=Math.sign(this.velocity),this.animatedScroll=p,this.setScroll(this.scroll),d&&(this.targetScroll=p),S||this.emit(),S&&(this.reset(),this.emit(),a?.(this),this.userData={},this.preventNextNativeScrollEvent())}})}}}preventNextNativeScrollEvent(){this.__preventNextNativeScrollEvent=!0,requestAnimationFrame(()=>{delete this.__preventNextNativeScrollEvent})}get rootElement(){return this.options.wrapper===l?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?function(e,s){return(e%s+s)%s}(this.animatedScroll,this.limit):this.animatedScroll}get progress(){return this.limit===0?1:this.scroll/this.limit}get isScrolling(){return this.__isScrolling}set isScrolling(t){this.__isScrolling!==t&&(this.__isScrolling=t,this.updateClassName())}get isStopped(){return this.__isStopped}set isStopped(t){this.__isStopped!==t&&(this.__isStopped=t,this.updateClassName())}get isLocked(){return this.__isLocked}set isLocked(t){this.__isLocked!==t&&(this.__isLocked=t,this.updateClassName())}get isSmooth(){return this.isScrolling==="smooth"}get className(){let t="lenis";return this.isStopped&&(t+=" lenis-stopped"),this.isLocked&&(t+=" lenis-locked"),this.isScrolling&&(t+=" lenis-scrolling"),this.isScrolling==="smooth"&&(t+=" lenis-smooth"),t}updateClassName(){this.cleanUpClassName(),this.rootElement.className=`${this.rootElement.className} ${this.className}`.trim()}cleanUpClassName(){this.rootElement.className=this.rootElement.className.replace(/lenis(-\w+)?/g,"").trim()}};function V(g){let{intensity:t}=g,e=A(null);return y(()=>{e.current&&e.current.scrollTo(0,{immediate:!0})},[e]),y(()=>{let s=document.getElementById("overlay");if(s){let i=()=>{l.getComputedStyle(document.documentElement).overflow==="hidden"&&s.setAttribute("data-lenis-prevent","true")},o=new MutationObserver(n=>{for(let r of n)r.type==="attributes"&&r.attributeName==="style"&&i()});return o.observe(document.documentElement,{attributes:!0,attributeFilter:["style"]}),i(),()=>{o.disconnect()}}},[]),y(()=>{let s=document.getElementsByTagName("*");for(let i=0;i{e.current=new M({duration:t/10});let s=i=>{e.current&&(e.current.raf(i),requestAnimationFrame(s))};return requestAnimationFrame(s),()=>{e.current&&(e.current.destroy(),e.current=null)}},[]),y(()=>{let s=document.createElement("style");return s.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(s),()=>{document.head.removeChild(s)}},[]),y(()=>{let s=[...document.querySelectorAll("a[href]")],i=(o,n)=>{o.preventDefault();let r=decodeURIComponent(n);e.current.scrollTo(r)};return s.filter(o=>o.href.includes("#")).forEach(o=>{let n=`#${o.href.split("#").pop()}`;o.addEventListener("click",r=>i(r,n))}),()=>{s.filter(o=>o.href.includes("#")).forEach(o=>{let n=`#${o.href.split("#").pop()}`;o.removeEventListener("click",r=>i(r,n))})}},[e]),P(I,{})}V.displayName="Smooth Scroll";B(V,{intensity:{title:"Intensity",type:q.Number,defaultValue:10,description:"More components at [Framer University](https://frameruni.link/cc)."}});export{V as a}; //# sourceMappingURL=chunk-OUJJENRF.mjs.map