import{q as t,t as e,u as i,v as n,w as s,x as o,y as r,z as a,A as l,B as h,C as u,D as c,E as d,F as m,G as p,H as f,I as y,J as g,K as v,M as x,N as T,O as P,W as w,Q as S,R as E,T as D,U as A,V as b,X as M,Y as k,Z as C,_ as V,k as L,$ as R,a0 as j,b as B,o as I,a1 as O,a2 as F,a3 as U,a4 as W,a5 as z,a6 as $,a7 as N,a8 as G,a9 as H,aa as K,d as Y,s as X,ab as q,ac as _,l as Z,e as J,f as Q,ad as tt,a as et,ae as it,j as nt,af as st,ag as ot,ah as rt,ai as at,aj as lt,ak as ht,al as ut,am as ct,an as dt,r as mt,ao as pt,p as ft,P as yt,L as gt,S as vt,g as xt}from"./size-rollup-dom-max-assets.js";import{jsx as Tt}from"react/jsx-runtime";import{useContext as Pt,useId as wt,useEffect as St,useCallback as Et,Component as Dt,Fragment as At}from"react";function bt(t){return"object"==typeof t&&null!==t}const Mt=(t,e)=>i=>e(t(i)),kt=(...t)=>t.reduce(Mt),Ct=(t,e,i)=>{const n=e-t;return 0===n?1:(i-t)/n},Vt=(t,e,i)=>(((1-3*i+3*e)*t+(3*i-6*e))*t+3*e)*t;function Lt(e,i,n,s){if(e===i&&n===s)return t;const o=t=>function(t,e,i,n,s){let o,r,a=0;do{r=e+(i-e)/2,o=Vt(r,n,s)-t,o>0?i=r:e=r}while(Math.abs(o)>1e-7&&++a<12);return r}(t,0,1,e,n);return t=>0===t||1===t?t:Vt(o(t),i,s)}const Rt=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,jt=t=>e=>1-t(1-e),Bt=Lt(.33,1.53,.69,.99),It=jt(Bt),Ot=Rt(It),Ft=t=>t>=1?1:(t*=2)<1?.5*It(t):.5*(2-Math.pow(2,-10*(t-1))),Ut=t=>1-Math.sin(Math.acos(t)),Wt=jt(Ut),zt=Rt(Ut),$t=Lt(.42,0,1,1),Nt=Lt(0,0,.58,1),Gt=Lt(.42,0,.58,1),Ht={linear:t,easeIn:$t,easeInOut:Gt,easeOut:Nt,circIn:Ut,circInOut:zt,circOut:Wt,backIn:It,backInOut:Ot,backOut:Bt,anticipate:Ft},Kt=t=>{if(e(t)){i(4===t.length,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,s,o]=t;return Lt(e,n,s,o)}return"string"==typeof t?(i(void 0!==Ht[t],`Invalid easing type '${t}'`,"invalid-easing-type"),Ht[t]):t};function Yt(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}function Xt(t,e){return i=>i>0?e:t}const qt=(t,e,i)=>{const n=t*t,s=i*(e*e-n)+n;return s<0?0:Math.sqrt(s)},_t=[r,s,o];function Zt(t){const e=(i=t,_t.find(t=>t.test(i)));var i;if(a(Boolean(e),`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!Boolean(e))return!1;let n=e.parse(t);return e===o&&(n=function({hue:t,saturation:e,lightness:i,alpha:n}){t/=360,i/=100;let s=0,o=0,r=0;if(e/=100){const n=i<.5?i*(1+e):i+e-i*e,a=2*i-n;s=Yt(a,n,t+1/3),o=Yt(a,n,t),r=Yt(a,n,t-1/3)}else s=o=r=i;return{red:Math.round(255*s),green:Math.round(255*o),blue:Math.round(255*r),alpha:n}}(n)),n}const Jt=(t,e)=>{const i=Zt(t),o=Zt(e);if(!i||!o)return Xt(t,e);const r={...i};return t=>(r.red=qt(i.red,o.red,t),r.green=qt(i.green,o.green,t),r.blue=qt(i.blue,o.blue,t),r.alpha=n(i.alpha,o.alpha,t),s.transform(r))},Qt=new Set(["none","hidden"]);function te(t,e){return i=>n(t,e,i)}function ee(t){return"number"==typeof t?te:"string"==typeof t?l(t)?Xt:h.test(t)?Jt:se:Array.isArray(t)?ie:"object"==typeof t?h.test(t)?Jt:ne:Xt}function ie(t,e){const i=[...t],n=i.length,s=t.map((t,i)=>ee(t)(t,e[i]));return t=>{for(let e=0;e{for(const e in n)i[e]=n[e](t);return i}}const se=(t,e)=>{const i=u.createTransformer(e),n=c(t),s=c(e);return n.indexes.var.length===s.indexes.var.length&&n.indexes.color.length===s.indexes.color.length&&n.indexes.number.length>=s.indexes.number.length?Qt.has(t)&&!s.values.length||Qt.has(e)&&!n.values.length?function(t,e){return Qt.has(t)?i=>i<=0?t:e:i=>i>=1?e:t}(t,e):kt(ie(function(t,e){const i=[],n={color:0,var:0,number:0};for(let s=0;s{const e=({timestamp:e})=>t(e);return{start:(t=!0)=>f.update(e,t),stop:()=>p(e),now:()=>d.isProcessing?d.timestamp:m.now()}},ae=2e4;function le(t){let e=0;let i=t.next(e);for(;!i.done&&e=ae?1/0:e}const he=100,ue=10,ce=1,de=0,me=800,pe=.3,fe=.3,ye={granular:.01,default:2},ge={granular:.005,default:.5},ve=.01,xe=10,Te=.05,Pe=1;function we(t,e){return t*Math.sqrt(1-e*e)}const Se=.001;const Ee=["duration","bounce"],De=["stiffness","damping","mass"];function Ae(t,e){return e.some(e=>void 0!==t[e])}function be(t){let e={velocity:de,stiffness:he,damping:ue,mass:ce,isResolvedFromDuration:!1,...t};if(!Ae(t,De)&&Ae(t,Ee))if(e.velocity=0,t.visualDuration){const i=t.visualDuration,n=2*Math.PI/(1.2*i),s=n*n,o=2*g(.05,1,1-(t.bounce||0))*Math.sqrt(s);e={...e,mass:ce,stiffness:s,damping:o}}else{const i=function({duration:t=me,bounce:e=pe,velocity:i=de,mass:n=ce}){let s,o;a(t<=x(xe),"Spring duration must be 10 seconds or less","spring-duration-limit");let r=1-e;r=g(Te,Pe,r),t=g(ve,xe,y(t)),r<1?(s=e=>{const n=e*r,s=n*t,o=n-i,a=we(e,r),l=Math.exp(-s);return Se-o/a*l},o=e=>{const n=e*r*t,o=n*i+i,a=Math.pow(r,2)*Math.pow(e,2)*t,l=Math.exp(-n),h=we(Math.pow(e,2),r);return(-s(e)+Se>0?-1:1)*((o-a)*l)/h}):(s=e=>Math.exp(-e*t)*((e-i)*t+1)-.001,o=e=>Math.exp(-e*t)*(t*t*(i-e)));const l=function(t,e,i){let n=i;for(let i=1;i<12;i++)n-=t(n)/e(n);return n}(s,o,5/t);if(t=x(t),isNaN(l))return{stiffness:he,damping:ue,duration:t};{const e=Math.pow(l,2)*n;return{stiffness:e,damping:2*r*Math.sqrt(n*e),duration:t}}}({...t,velocity:0});e={...e,...i,mass:ce},e.isResolvedFromDuration=!0}return e}function Me(t=fe,e=pe){const i="object"!=typeof t?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:n,restDelta:s}=i;const o=i.keyframes[0],r=i.keyframes[i.keyframes.length-1],a={done:!1,value:o},{stiffness:l,damping:h,mass:u,duration:c,velocity:d,isResolvedFromDuration:m}=be({...i,velocity:-y(i.velocity||0)}),p=d||0,f=h/(2*Math.sqrt(l*u)),g=r-o,T=y(Math.sqrt(l/u)),P=Math.abs(g)<5;let w,S,E,D,A,b;if(n||(n=P?ye.granular:ye.default),s||(s=P?ge.granular:ge.default),f<1)E=we(T,f),D=(p+f*T*g)/E,w=t=>{const e=Math.exp(-f*T*t);return r-e*(D*Math.sin(E*t)+g*Math.cos(E*t))},A=f*T*D+g*E,b=f*T*g-D*E,S=t=>Math.exp(-f*T*t)*(A*Math.sin(E*t)+b*Math.cos(E*t));else if(1===f){w=t=>r-Math.exp(-T*t)*(g+(p+T*g)*t);const t=p+T*g;S=e=>Math.exp(-T*e)*(T*t*e-p)}else{const t=T*Math.sqrt(f*f-1);w=e=>{const i=Math.exp(-f*T*e),n=Math.min(t*e,300);return r-i*((p+f*T*g)*Math.sinh(n)+t*g*Math.cosh(n))/t};const e=(p+f*T*g)/t,i=f*T*e-g*t,n=f*T*g-e*t;S=e=>{const s=Math.exp(-f*T*e),o=Math.min(t*e,300);return s*(i*Math.sinh(o)+n*Math.cosh(o))}}const M={calculatedDuration:m&&c||null,velocity:t=>x(S(t)),next:t=>{if(!m&&f<1){const e=Math.exp(-f*T*t),i=Math.sin(E*t),o=Math.cos(E*t),l=r-e*(D*i+g*o),h=x(e*(A*i+b*o));return a.done=Math.abs(h)<=n&&Math.abs(r-l)<=s,a.value=a.done?r:l,a}const e=w(t);if(m)a.done=t>=c;else{const i=x(S(t));a.done=Math.abs(i)<=n&&Math.abs(r-e)<=s}return a.value=a.done?r:e,a},toString:()=>{const t=Math.min(le(M),ae),e=v(e=>M.next(t*e).value,t,30);return t+"ms "+e},toTransition:()=>{}};return M}Me.applyToOptions=t=>{const e=function(t,e=100,i){const n=i({...t,keyframes:[0,e]}),s=Math.min(le(n),ae);return{type:"keyframes",ease:t=>n.next(s*t).value/e,duration:y(s)}}(t,100,Me);return t.ease=e.ease,t.duration=x(e.duration),t.type="keyframes",t};function ke(t,e,i){const n=Math.max(e-5,0);return T(i-t(n),e-n)}function Ce({keyframes:t,velocity:e=0,power:i=.8,timeConstant:n=325,bounceDamping:s=10,bounceStiffness:o=500,modifyTarget:r,min:a,max:l,restDelta:h=.5,restSpeed:u}){const c=t[0],d={done:!1,value:c},m=t=>void 0===a?l:void 0===l||Math.abs(a-t)-p*Math.exp(-t/n),v=t=>y+g(t),x=t=>{const e=g(t),i=v(t);d.done=Math.abs(e)<=h,d.value=d.done?y:i};let T,P;const w=t=>{var e;(e=d.value,void 0!==a&&el)&&(T=t,P=Me({keyframes:[d.value,m(d.value)],velocity:ke(v,t,d.value),damping:s,stiffness:o,restDelta:h,restSpeed:u}))};return w(0),{calculatedDuration:null,next:t=>{let e=!1;return P||void 0!==T||(e=!0,x(t),w(t)),void 0!==T&&t>=T?P.next(t-T):(!e&&x(t),d)}}}function Ve(e,n,{clamp:s=!0,ease:o,mixer:r}={}){const a=e.length;if(i(a===n.length,"Both input and output ranges must be the same length","range-length"),1===a)return()=>n[0];if(2===a&&n[0]===n[1])return()=>n[1];const l=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),n=[...n].reverse());const h=function(e,i,n){const s=[],o=n||P.mix||oe,r=e.length-1;for(let n=0;n{if(l&&t1)for(;ic(g(e[0],e[a-1],t)):c}function Le(t){const e=[0];return function(t,e){const i=t[t.length-1];for(let s=1;s<=e;s++){const o=Ct(0,e,s);t.push(n(i,1,o))}}(e,t.length-1),e}function Re({duration:t=300,keyframes:e,times:i,ease:n="easeInOut"}){const s=(t=>Array.isArray(t)&&"number"!=typeof t[0])(n)?n.map(Kt):Kt(n),o={done:!1,value:e[0]},r=function(t,e){return t.map(t=>t*e)}(i&&i.length===e.length?i:Le(e),t),a=Ve(r,e,{ease:Array.isArray(s)?s:(l=e,h=s,l.map(()=>h||Gt).splice(0,l.length-1))});var l,h;return{calculatedDuration:t,next:e=>(o.value=a(e),o.done=e>=t,o)}}const je={decay:Ce,inertia:Ce,tween:Re,keyframes:Re,spring:Me};function Be(t){"string"==typeof t.type&&(t.type=je[t.type])}const Ie=t=>t/100;class Oe extends w{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:t}=this.options;t&&t.updatedAt!==m.now()&&this.tick(m.now()),this.isStopped=!0,"idle"!==this.state&&(this.teardown(),this.options.onStop?.())},this.options=t,this.initAnimation(),this.play(),!1===t.autoplay&&this.pause()}initAnimation(){const{options:t}=this;Be(t);const{type:e=Re,repeat:i=0,repeatDelay:n=0,repeatType:s,velocity:o=0}=t;let{keyframes:r}=t;const a=e||Re;a!==Re&&"number"!=typeof r[0]&&(this.mixKeyframes=kt(Ie,oe(r[0],r[1])),r=[0,100]);const l=a({...t,keyframes:r});"mirror"===s&&(this.mirroredGenerator=a({...t,keyframes:[...r].reverse(),velocity:-o})),null===l.calculatedDuration&&(l.calculatedDuration=le(l));const{calculatedDuration:h}=l;this.calculatedDuration=h,this.resolvedDuration=h+n,this.totalDuration=this.resolvedDuration*(i+1)-n,this.generator=l}updateTime(t){const e=Math.round(t-this.startTime)*this.playbackSpeed;null!==this.holdTime?this.currentTime=this.holdTime:this.currentTime=e}tick(t,e=!1){const{generator:i,totalDuration:n,mixKeyframes:s,mirroredGenerator:o,resolvedDuration:r,calculatedDuration:a}=this;if(null===this.startTime)return i.next(0);const{delay:l=0,keyframes:h,repeat:u,repeatType:c,repeatDelay:d,type:m,onUpdate:p,finalKeyframe:f}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-n/this.speed,this.startTime)),e?this.currentTime=t:this.updateTime(t);const y=this.currentTime-l*(this.playbackSpeed>=0?1:-1),v=this.playbackSpeed>=0?y<0:y>n;this.currentTime=Math.max(y,0),"finished"===this.state&&null===this.holdTime&&(this.currentTime=n);let x=this.currentTime,T=i;if(u){const t=Math.min(this.currentTime,n)/r;let e=Math.floor(t),i=t%1;!i&&t>=1&&(i=1),1===i&&e--,e=Math.min(e,u+1);Boolean(e%2)&&("reverse"===c?(i=1-i,d&&(i-=d/r)):"mirror"===c&&(T=o)),x=g(0,1,i)*r}const P=v?{done:!1,value:h[0]}:T.next(x);s&&!v&&(P.value=s(P.value));let{done:w}=P;v||null===a||(w=this.playbackSpeed>=0?this.currentTime>=n:this.currentTime<=0);const E=null===this.holdTime&&("finished"===this.state||"running"===this.state&&w);return E&&m!==Ce&&(P.value=S(h,this.options,f,this.speed)),p&&p(P.value),E&&this.finish(),P}then(t,e){return this.finished.then(t,e)}get duration(){return y(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+y(t)}get time(){return y(this.currentTime)}set time(t){t=x(t),this.currentTime=t,null===this.startTime||null!==this.holdTime||0===this.playbackSpeed?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=t,this.tick(t))}getGeneratorVelocity(){const t=this.currentTime;if(t<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(t);return ke(t=>this.generator.next(t).value,t,this.generator.next(t).value)}get speed(){return this.playbackSpeed}set speed(t){const e=this.playbackSpeed!==t;e&&this.driver&&this.updateTime(m.now()),this.playbackSpeed=t,e&&this.driver&&(this.time=y(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=re,startTime:e}=this.options;this.driver||(this.driver=t(t=>this.tick(t))),this.options.onPlay?.();const i=this.driver.now();"finished"===this.state?(this.updateFinished(),this.startTime=i):null!==this.holdTime?this.startTime=i-this.holdTime:this.startTime||(this.startTime=e??i),"finished"===this.state&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(m.now()),this.holdTime=this.currentTime}complete(){"running"!==this.state&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),t.observe(this)}}const Fe={anticipate:Ft,backInOut:Ot,circInOut:zt};function Ue(t){"string"==typeof t.ease&&t.ease in Fe&&(t.ease=Fe[t.ease])}class We extends E{constructor(t){Ue(t),Be(t),super(t),void 0!==t.startTime&&!1!==t.autoplay&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:e,onUpdate:i,onComplete:n,element:s,...o}=this.options;if(!e)return;if(void 0!==t)return void e.set(t);const r=new Oe({...o,autoplay:!1}),a=Math.max(10,m.now()-this.startTime),l=g(0,10,a-10),h=r.sample(a).value,{name:u}=this.options;s&&u&&D(s,u,h),e.setWithVelocity(r.sample(Math.max(0,a-l)).value,h,l),r.stop()}}const ze=(t,e)=>"zIndex"!==e&&(!("number"!=typeof t&&!Array.isArray(t))||!("string"!=typeof t||!u.test(t)&&"0"!==t||t.startsWith("url(")));function $e(t){t.duration=0,t.type="keyframes"}const Ne=new Set(["opacity","clipPath","filter","transform"]),Ge=b(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));class He extends w{constructor({autoplay:t=!0,delay:e=0,type:i="keyframes",repeat:n=0,repeatDelay:s=0,repeatType:o="loop",keyframes:r,name:a,motionValue:l,element:h,...u}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=m.now();const c={autoplay:t,delay:e,type:i,repeat:n,repeatDelay:s,repeatType:o,name:a,motionValue:l,element:h,...u},d=h?.KeyframeResolver||M;this.keyframeResolver=new d(r,(t,e,i)=>this.onKeyframesResolved(t,e,c,!i),a,l,h),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,i,n,s){this.keyframeResolver=void 0;const{name:o,type:r,velocity:l,delay:h,isHandoff:u,onUpdate:c}=n;this.resolvedAt=m.now();let d=!0;(function(t,e,i,n){const s=t[0];if(null===s)return!1;if("display"===e||"visibility"===e)return!0;const o=t[t.length-1],r=ze(s,e),l=ze(o,e);return a(r===l,`You are trying to animate ${e} from "${s}" to "${o}". "${r?o:s}" is not an animatable value.`,"value-not-animatable"),!(!r||!l)&&(function(t){const e=t[0];if(1===t.length)return!0;for(let i=0;i40?this.resolvedAt:this.createdAt:void 0,finalKeyframe:i,...n,keyframes:e},f=d&&!u&&function(t){const{motionValue:e,name:i,repeatDelay:n,repeatType:s,damping:o,type:r}=t,a=e?.owner?.current;if(!(a instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:h}=e.owner.getProps();return Ge()&&i&&Ne.has(i)&&("transform"!==i||!h)&&!l&&!n&&"mirror"!==s&&0!==o&&"inertia"!==r}(p),y=p.motionValue?.owner?.current,g=f?new We({...p,element:y}):new Oe(p);g.finished.then(()=>{this.notifyFinished()}).catch(t),this.pendingTimeline&&(this.stopTimeline=g.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=g}get finished(){return this._animation?this.animation.finished:this._finished}then(t,e){return this.finished.finally(t).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),k()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}function Ke(t,e,i,n=0,s=1){const o=Array.from(t).sort((t,e)=>t.sortNodePosition(e)).indexOf(e),r=t.size,a=(r-1)*n;return"function"==typeof i?i(o,r):1===s?o*n:a-o*n}const Ye=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Xe(t,e,n=1){i(n<=4,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,o]=function(t){const e=Ye.exec(t);if(!e)return[,];const[,i,n,s]=e;return[`--${i??n}`,s]}(t);if(!s)return;const r=window.getComputedStyle(e).getPropertyValue(s);if(r){const t=r.trim();return C(t)?parseFloat(t):t}return l(o)?Xe(o,e,n+1):o}const qe={type:"spring",stiffness:500,damping:25,restSpeed:10},_e={type:"keyframes",duration:.8},Ze={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Je=(t,{keyframes:e})=>e.length>2?_e:V.has(t)?t.startsWith("scale")?{type:"spring",stiffness:550,damping:0===e[1]?2*Math.sqrt(550):30,restSpeed:10}:qe:Ze,Qe=t=>null!==t;function ti(t,e){if(t?.inherit&&e){const{inherit:i,...n}=t;return{...e,...n}}return t}function ei(t,e){const i=t?.[e]??t?.default??t;return i!==t?ti(i,t):i}const ii=(t,e,i,n={},s,o)=>r=>{const a=ei(n,t)||{},l=a.delay||n.delay||0;let{elapsed:h=0}=n;h-=x(l);const u={keyframes:Array.isArray(i)?i:[null,i],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-h,onUpdate:t=>{e.set(t),a.onUpdate&&a.onUpdate(t)},onComplete:()=>{r(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:o?void 0:s};(function({when:t,delay:e,delayChildren:i,staggerChildren:n,staggerDirection:s,repeat:o,repeatType:r,repeatDelay:a,from:l,elapsed:h,...u}){return!!Object.keys(u).length})(a)||Object.assign(u,Je(t,u)),u.duration&&(u.duration=x(u.duration)),u.repeatDelay&&(u.repeatDelay=x(u.repeatDelay)),void 0!==u.from&&(u.keyframes[0]=u.from);let c=!1;if((!1===u.type||0===u.duration&&!u.repeatDelay)&&($e(u),0===u.delay&&(c=!0)),(P.instantAnimations||P.skipAnimations||s?.shouldSkipAnimations)&&(c=!0,$e(u),u.delay=0),u.allowFlatten=!a.type&&!a.ease,c&&!o&&void 0!==e.get()){const t=function(t,{repeat:e,repeatType:i="loop"}){const n=t.filter(Qe);return n[e&&"loop"!==i&&e%2==1?0:n.length-1]}(u.keyframes,a);if(void 0!==t)return void f.update(()=>{u.onUpdate(t),u.onComplete()})}return a.isSync?new Oe(u):new He(u)};function ni(t,e,i){const n=t.getProps();return L(n,e,void 0!==i?i:n.custom,t)}const si=new Set(["width","height","top","left","right","bottom",...R]),oi=t=>Array.isArray(t);function ri(t,e,i){t.hasValue(e)?t.getValue(e).set(i):t.addValue(e,j(i))}function ai(t){return oi(t)?t[t.length-1]||0:t}function li(t,e){const i=t.getValue("willChange");if(n=i,Boolean(B(n)&&n.add))return i.add(e);if(!i&&P.WillChange){const i=new P.WillChange("auto");t.addValue("willChange",i),i.add(e)}var n}function hi(t){return t.props[I]}function ui({protectedKeys:t,needsAnimating:e},i){const n=t.hasOwnProperty(i)&&!0!==e[i];return e[i]=!1,n}function ci(t,e,{delay:i=0,transitionOverride:n,type:s}={}){let{transition:o,transitionEnd:r,...a}=e;const l=t.getDefaultTransition();o=o?ti(o,l):l;const h=o?.reduceMotion;n&&(o=n);const u=[],c=s&&t.animationState&&t.animationState.getState()[s];for(const e in a){const n=t.getValue(e,t.latestValues[e]??null),s=a[e];if(void 0===s||c&&ui(c,e))continue;const r={delay:i,...ei(o||{},e)},l=n.get();if(void 0!==l&&!n.isAnimating&&!Array.isArray(s)&&s===l&&!r.velocity)continue;let d=!1;if(window.MotionHandoffAnimation){const i=hi(t);if(i){const t=window.MotionHandoffAnimation(i,e,f);null!==t&&(r.startTime=t,d=!0)}}li(t,e);const m=h??t.shouldReduceMotion;n.start(ii(e,n,s,m&&si.has(e)?{type:!1}:r,t,d));const p=n.animation;p&&u.push(p)}if(r){const e=()=>f.update(()=>{r&&function(t,e){const i=ni(t,e);let{transitionEnd:n={},transition:s={},...o}=i||{};o={...o,...n};for(const e in o)ri(t,e,ai(o[e]))}(t,r)});u.length?Promise.all(u).then(e):e()}return u}function di(t,e,i={}){const n=ni(t,e,"exit"===i.type?t.presenceContext?.custom:void 0);let{transition:s=t.getDefaultTransition()||{}}=n||{};i.transitionOverride&&(s=i.transitionOverride);const o=n?()=>Promise.all(ci(t,n,i)):()=>Promise.resolve(),r=t.variantChildren&&t.variantChildren.size?(n=0)=>{const{delayChildren:o=0,staggerChildren:r,staggerDirection:a}=s;return function(t,e,i=0,n=0,s=0,o=1,r){const a=[];for(const l of t.variantChildren)l.notify("AnimationStart",e),a.push(di(l,e,{...r,delay:i+("function"==typeof n?0:n)+Ke(t.variantChildren,l,n,s,o)}).then(()=>l.notify("AnimationComplete",e)));return Promise.all(a)}(t,e,n,o,r,a,i)}:()=>Promise.resolve(),{when:a}=s;if(a){const[t,e]="beforeChildren"===a?[o,r]:[r,o];return t().then(()=>e())}return Promise.all([o(),r(i.delay)])}function mi(t){return"number"==typeof t?0===t:null===t||("none"===t||"0"===t||O(t))}const pi=new Set(["auto","none","0"]);class fi extends M{constructor(t,e,i,n,s){super(t,e,i,n,s,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:e,name:i}=this;if(!e||!e.current)return;super.readKeyframes();for(let i=0;i{t.getValue(e).set(i)}),this.resolveNoneKeyframes()}}function yi(t,e,i){if(null==t)return[];if(t instanceof EventTarget)return[t];if("string"==typeof t){let e=document;const n=i?.[t]??e.querySelectorAll(t);return n?Array.from(n):[]}return Array.from(t).filter(t=>null!=t)}const gi={x:!1,y:!1};function vi(){return gi.x||gi.y}function xi(t,e){const i=yi(t),n=new AbortController;return[i,{passive:!0,...e,signal:n.signal},()=>n.abort()]}function Ti(t,e,i={}){const[n,s,o]=xi(t,i);return n.forEach(t=>{let i,n=!1,o=!1;const r=e=>{i&&(i(e),i=void 0),t.removeEventListener("pointerleave",l)},a=t=>{n=!1,window.removeEventListener("pointerup",a),window.removeEventListener("pointercancel",a),o&&(o=!1,r(t))},l=t=>{"touch"!==t.pointerType&&(n?o=!0:r(t))};t.addEventListener("pointerenter",n=>{if("touch"===n.pointerType||vi())return;o=!1;const r=e(t,n);"function"==typeof r&&(i=r,t.addEventListener("pointerleave",l,s))},s),t.addEventListener("pointerdown",()=>{n=!0,window.addEventListener("pointerup",a,s),window.addEventListener("pointercancel",a,s)},s)}),o}const Pi=(t,e)=>!!e&&(t===e||Pi(t,e.parentElement)),wi=t=>"mouse"===t.pointerType?"number"!=typeof t.button||t.button<=0:!1!==t.isPrimary,Si=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);const Ei=new Set(["INPUT","SELECT","TEXTAREA"]);const Di=new WeakSet;function Ai(t){return e=>{"Enter"===e.key&&t(e)}}function bi(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}function Mi(t){return wi(t)&&!vi()}const ki=new WeakSet;function Ci(t,e,i={}){const[n,s,o]=xi(t,i),r=t=>{const n=t.currentTarget;if(!Mi(t))return;if(ki.has(t))return;Di.add(n),i.stopPropagation&&ki.add(t);const o=e(n,t),r=(t,e)=>{window.removeEventListener("pointerup",a),window.removeEventListener("pointercancel",l),Di.has(n)&&Di.delete(n),Mi(t)&&"function"==typeof o&&o(t,{success:e})},a=t=>{r(t,n===window||n===document||i.useGlobalTarget||Pi(n,t.target))},l=t=>{r(t,!1)};window.addEventListener("pointerup",a,s),window.addEventListener("pointercancel",l,s)};return n.forEach(t=>{var e;(i.useGlobalTarget?window:t).addEventListener("pointerdown",r,s),bt(e=t)&&"offsetHeight"in e&&!("ownerSVGElement"in e)&&(t.addEventListener("focus",t=>((t,e)=>{const i=t.currentTarget;if(!i)return;const n=Ai(()=>{if(Di.has(i))return;bi(i,"down");const t=Ai(()=>{bi(i,"up")});i.addEventListener("keyup",t,e),i.addEventListener("blur",()=>bi(i,"cancel"),e)});i.addEventListener("keydown",n,e),i.addEventListener("blur",()=>i.removeEventListener("keydown",n),e)})(t,s)),function(t){return Si.has(t.tagName)||!0===t.isContentEditable}(t)||t.hasAttribute("tabindex")||(t.tabIndex=0))}),o}function Vi(t){return bt(t)&&"ownerSVGElement"in t}const Li=new WeakMap;let Ri;const ji=(t,e,i)=>(n,s)=>s&&s[0]?s[0][t+"Size"]:Vi(n)&&"getBBox"in n?n.getBBox()[e]:n[i],Bi=ji("inline","width","offsetWidth"),Ii=ji("block","height","offsetHeight");function Oi({target:t,borderBoxSize:e}){Li.get(t)?.forEach(i=>{i(t,{get width(){return Bi(t,e)},get height(){return Ii(t,e)}})})}function Fi(t){t.forEach(Oi)}function Ui(t,e){Ri||"undefined"!=typeof ResizeObserver&&(Ri=new ResizeObserver(Fi));const i=yi(t);return i.forEach(t=>{let i=Li.get(t);i||(i=new Set,Li.set(t,i)),i.add(e),Ri?.observe(t)}),()=>{i.forEach(t=>{const i=Li.get(t);i?.delete(e),i?.size||Ri?.unobserve(t)})}}const Wi=new Set;let zi;function $i(t){return Wi.add(t),zi||(zi=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};Wi.forEach(e=>e(t))},window.addEventListener("resize",zi)),()=>{Wi.delete(t),Wi.size||"function"!=typeof zi||(window.removeEventListener("resize",zi),zi=void 0)}}function Ni(t,e){return"function"==typeof t?$i(t):Ui(t,e)}class Gi extends N{constructor(){super(...arguments),this.KeyframeResolver=fi}sortInstanceNodePosition(t,e){return 2&t.compareDocumentPosition(e)?1:-1}getBaseTargetFromProps(t,e){const i=t.style;return i?i[e]:void 0}removeValueFromRenderState(t,{vars:e,style:i}){delete e[t],delete i[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;B(t)&&(this.childSubscription=t.on("change",t=>{this.current&&(this.current.textContent=`${t}`)}))}}class Hi{constructor(t){this.isMounted=!1,this.node=t}update(){}}function Ki({top:t,left:e,right:i,bottom:n}){return{x:{min:e,max:i},y:{min:t,max:n}}}function Yi(t){return void 0===t||1===t}function Xi({scale:t,scaleX:e,scaleY:i}){return!Yi(t)||!Yi(e)||!Yi(i)}function qi(t){return Xi(t)||_i(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function _i(t){return Zi(t.x)||Zi(t.y)}function Zi(t){return t&&"0%"!==t}function Ji(t,e,i){return i+e*(t-i)}function Qi(t,e,i,n,s){return void 0!==s&&(t=Ji(t,s,n)),Ji(t,i,n)+e}function tn(t,e=0,i=1,n,s){t.min=Qi(t.min,e,i,n,s),t.max=Qi(t.max,e,i,n,s)}function en(t,{x:e,y:i}){tn(t.x,e.translate,e.scale,e.originPoint),tn(t.y,i.translate,i.scale,i.originPoint)}const nn=.999999999999,sn=1.0000000000001;function on(t,e){t.min=t.min+e,t.max=t.max+e}function rn(t,e,i,s,o=.5){tn(t,e,i,n(t.min,t.max,o),s)}function an(t,e){return"string"==typeof t?parseFloat(t)/100*(e.max-e.min):t}function ln(t,e,i){const n=i??t;rn(t.x,an(e.x,n.x),e.scaleX,e.scale,e.originX),rn(t.y,an(e.y,n.y),e.scaleY,e.scale,e.originY)}function hn(t,e){return Ki(function(t,e){if(!e)return t;const i=e({x:t.left,y:t.top}),n=e({x:t.right,y:t.bottom});return{top:i.y,left:i.x,bottom:n.y,right:n.x}}(t.getBoundingClientRect(),e))}function un(t,{style:e,vars:i},n,s){const o=t.style;let r;for(r in e)o[r]=e[r];for(r in s?.applyProjectionStyles(o,n),i)o.setProperty(r,i[r])}class cn extends Gi{constructor(){super(...arguments),this.type="html",this.renderInstance=un}readValueFromInstance(t,e){if(V.has(e))return this.projection?.isProjecting?G(e):H(t,e);{const n=(i=t,window.getComputedStyle(i)),s=(K(e)?n.getPropertyValue(e):n[e])||0;return"string"==typeof s?s.trim():s}var i}measureInstanceViewportBox(t,{transformPagePoint:e}){return hn(t,e)}build(t,e,i){Y(t,e,i.transformTemplate)}scrapeMotionValuesFromProps(t,e,i){return X(t,e,i)}}const dn=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);class mn extends Gi{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=_}getBaseTargetFromProps(t,e){return t[e]}readValueFromInstance(t,e){if(V.has(e)){const t=tt(e);return t&&t.default||0}return e=dn.has(e)?e:q(e),t.getAttribute(e)}scrapeMotionValuesFromProps(t,e,i){return Z(t,e,i)}build(t,e,i){J(t,e,this.isSVGTag,i.transformTemplate,i.style)}renderInstance(t,e,i,n){!function(t,e,i,n){un(t,e,void 0,n);for(const i in e.attrs)t.setAttribute(dn.has(i)?i:q(i),e.attrs[i])}(t,e,0,n)}mount(t){this.isSVGTag=Q(t.tagName),super.mount(t)}}const pn=it.length;function fn(t){if(!t)return;if(!t.isControllingVariants){const e=t.parent&&fn(t.parent)||{};return void 0!==t.props.initial&&(e.initial=t.props.initial),e}const e={};for(let i=0;iPromise.all(e.map(({animation:e,options:i})=>function(t,e,i={}){let n;if(t.notify("AnimationStart",e),Array.isArray(e)){const s=e.map(e=>di(t,e,i));n=Promise.all(s)}else if("string"==typeof e)n=di(t,e,i);else{const s="function"==typeof e?ni(t,e,i.custom):e;n=Promise.all(ci(t,s,i))}return n.then(()=>{t.notify("AnimationComplete",e)})}(t,e,i)))}function Tn(t){let e=xn(t),i=Sn(),n=!0,s=!1;const o=e=>(i,n)=>{const s=ni(t,n,"exit"===e?t.presenceContext?.custom:void 0);if(s){const{transition:t,transitionEnd:e,...n}=s;i={...i,...n,...e}}return i};function r(r){const{props:a}=t,l=fn(t.parent)||{},h=[],u=new Set;let c={},d=1/0;for(let e=0;ed&&y,P=!1;const w=Array.isArray(f)?f:[f];let S=w.reduce(o(m),{});!1===g&&(S={});const{prevResolvedValues:E={}}=p,D={...E,...S},A=e=>{T=!0,u.has(e)&&(P=!0,u.delete(e)),p.needsAnimating[e]=!0;const i=t.getValue(e);i&&(i.liveStyle=!1)};for(const t in D){const e=S[t],i=E[t];if(c.hasOwnProperty(t))continue;let n=!1;n=oi(e)&&oi(i)?!yn(e,i):e!==i,n?null!=e?A(t):u.add(t):void 0!==e&&u.has(t)?A(t):p.protectedKeys[t]=!0}p.prevProp=f,p.prevResolvedValues=S,p.isActive&&(c={...c,...S}),(n||s)&&t.blockInitialAnimation&&(T=!1);const b=v&&x;T&&(!b||P)&&h.push(...w.map(e=>{const i={type:m};if("string"==typeof e&&(n||s)&&!b&&t.manuallyAnimateOnMount&&t.parent){const{parent:n}=t,s=ni(n,e);if(n.enteringChildren&&s){const{delayChildren:e}=s.transition||{};i.delay=Ke(n.enteringChildren,t,e)}}return{animation:e,options:i}}))}if(u.size){const e={};if("boolean"!=typeof a.initial){const i=ni(t,Array.isArray(a.initial)?a.initial[0]:a.initial);i&&i.transition&&(e.transition=i.transition)}u.forEach(i=>{const n=t.getBaseTarget(i),s=t.getValue(i);s&&(s.liveStyle=!0),e[i]=n??null}),h.push({animation:e})}let m=Boolean(h.length);return!n||!1!==a.initial&&a.initial!==a.animate||t.manuallyAnimateOnMount||(m=!1),n=!1,s=!1,m?e(h):Promise.resolve()}return{animateChanges:r,setActive:function(e,n){if(i[e].isActive===n)return Promise.resolve();t.variantChildren?.forEach(t=>t.animationState?.setActive(e,n)),i[e].isActive=n;const s=r(e);for(const t in i)i[t].protectedKeys={};return s},setAnimateFunction:function(i){e=i(t)},getState:()=>i,reset:()=>{i=Sn(),s=!0}}}function Pn(t,e){return"string"==typeof e?e!==t:!!Array.isArray(e)&&!yn(e,t)}function wn(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Sn(){return{animate:wn(!0),whileInView:wn(),whileHover:wn(),whileTap:wn(),whileDrag:wn(),whileFocus:wn(),exit:wn()}}function En(t,e){t.min=e.min,t.max=e.max}function Dn(t,e){En(t.x,e.x),En(t.y,e.y)}function An(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function bn(t){return t.max-t.min}function Mn(t,e,i,s=.5){t.origin=s,t.originPoint=n(e.min,e.max,t.origin),t.scale=bn(i)/bn(e),t.translate=n(i.min,i.max,t.origin)-t.originPoint,(t.scale>=.9999&&t.scale<=1.0001||isNaN(t.scale))&&(t.scale=1),(t.translate>=-.01&&t.translate<=.01||isNaN(t.translate))&&(t.translate=0)}function kn(t,e,i,n){Mn(t.x,e.x,i.x,n?n.originX:void 0),Mn(t.y,e.y,i.y,n?n.originY:void 0)}function Cn(t,e,i){t.min=i.min+e.min,t.max=t.min+bn(e)}function Vn(t,e,i){t.min=e.min-i.min,t.max=t.min+bn(e)}function Ln(t,e,i){Vn(t.x,e.x,i.x),Vn(t.y,e.y,i.y)}function Rn(t,e,i,n,s){return t=Ji(t-=e,1/i,n),void 0!==s&&(t=Ji(t,1/s,n)),t}function jn(t,e,[i,s,o],r,a){!function(t,e=0,i=1,s=.5,o,r=t,a=t){ot.test(e)&&(e=parseFloat(e),e=n(a.min,a.max,e/100)-a.min);if("number"!=typeof e)return;let l=n(r.min,r.max,s);t===r&&(l-=e),t.min=Rn(t.min,e,i,l,o),t.max=Rn(t.max,e,i,l,o)}(t,e[i],e[s],e[o],e.scale,r,a)}const Bn=["x","scaleX","originX"],In=["y","scaleY","originY"];function On(t,e,i,n){jn(t.x,e,Bn,i?i.x:void 0,n?n.x:void 0),jn(t.y,e,In,i?i.y:void 0,n?n.y:void 0)}function Fn(t){return 0===t.translate&&1===t.scale}function Un(t){return Fn(t.x)&&Fn(t.y)}function Wn(t,e){return t.min===e.min&&t.max===e.max}function zn(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function $n(t,e){return zn(t.x,e.x)&&zn(t.y,e.y)}function Nn(t){return bn(t.x)/bn(t.y)}function Gn(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}function Hn(t){return[t("x"),t("y")]}const Kn=["TopLeft","TopRight","BottomLeft","BottomRight"],Yn=Kn.length,Xn=t=>"string"==typeof t?parseFloat(t):t,qn=t=>"number"==typeof t||rt.test(t);function _n(t,e){return void 0!==t[e]?t[e]:t.borderRadius}const Zn=Qn(0,.5,Wt),Jn=Qn(.5,.95,t);function Qn(t,e,i){return n=>ne?1:i(Ct(t,e,n))}function ts(t,e,i,n={passive:!0}){return t.addEventListener(e,i,n),()=>t.removeEventListener(e,i)}const es=(t,e)=>t.depth-e.depth;class is{constructor(){this.children=[],this.isDirty=!1}add(t){at(this.children,t),this.isDirty=!0}remove(t){lt(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(es),this.isDirty=!1,this.children.forEach(t)}}class ns{constructor(){this.members=[]}add(t){at(this.members,t);for(let e=this.members.length-1;e>=0;e--){const i=this.members[e];if(i===t||i===this.lead||i===this.prevLead)continue;const n=i.instance;n&&!1!==n.isConnected||i.snapshot||(lt(this.members,i),i.unmount())}t.scheduleRender()}remove(t){if(lt(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const t=this.members[this.members.length-1];t&&this.promote(t)}}relegate(t){for(let e=this.members.indexOf(t)-1;e>=0;e--){const t=this.members[e];if(!1!==t.isPresent&&!1!==t.instance?.isConnected)return this.promote(t),!0}return!1}promote(t,e){const i=this.lead;if(t!==i&&(this.prevLead=i,this.lead=t,t.show(),i)){i.updateSnapshot(),t.scheduleRender();const{layoutDependency:n}=i.options,{layoutDependency:s}=t.options;void 0!==n&&n===s||(t.resumeFrom=i,e&&(i.preserveOpacity=!0),i.snapshot&&(t.snapshot=i.snapshot,t.snapshot.latestValues=i.animationValues||i.latestValues),t.root?.isUpdating&&(t.isLayoutDirty=!0)),!1===t.options.crossfade&&i.hide()}}exitAnimationComplete(){this.members.forEach(t=>{t.options.onExitComplete?.(),t.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(t=>t.instance&&t.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}}const ss={hasAnimatedSinceResize:!0,hasEverUpdated:!1},os=["","X","Y","Z"];let rs=0;function as(t,e,i,n){const{latestValues:s}=e;s[t]&&(i[t]=s[t],e.setStaticValue(t,0),n&&(n[t]=0))}function ls(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const i=hi(e);if(window.MotionHasOptimisedAnimation(i,"transform")){const{layout:e,layoutId:n}=t.options;window.MotionCancelOptimisedAnimation(i,"transform",f,!(e||n))}const{parent:n}=t;n&&!n.hasCheckedOptimisedAppear&&ls(n)}function hs({attachResizeListener:t,defaultParent:e,measureScroll:i,checkIsScrollRoot:s,resetTransform:o}){return class{constructor(t={},i=e?.()){this.id=rs++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(ds),this.nodes.forEach(xs),this.nodes.forEach(Ts),this.nodes.forEach(ms)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=t,this.root=i?i.root||i:this,this.path=i?[...i.path,i]:[],this.parent=i,this.depth=i?i.depth+1:0;for(let t=0;tthis.root.updateBlockedByResize=!1;f.read(()=>{n=window.innerWidth}),t(e,()=>{const t=window.innerWidth;t!==n&&(n=t,this.root.updateBlockedByResize=!0,i&&i(),i=function(t,e){const i=m.now(),n=({timestamp:s})=>{const o=s-i;o>=e&&(p(n),t(o-e))};return f.setup(n,!0),()=>p(n)}(s,250),ss.hasAnimatedSinceResize&&(ss.hasAnimatedSinceResize=!1,this.nodes.forEach(vs)))})}n&&this.root.registerSharedNode(n,this),!1!==this.options.animate&&o&&(n||s)&&this.addEventListener("didUpdate",({delta:t,hasLayoutChanged:e,hasRelativeLayoutChanged:i,layout:n})=>{if(this.isTreeAnimationBlocked())return this.target=void 0,void(this.relativeTarget=void 0);const s=this.options.transition||o.getDefaultTransition()||As,{onLayoutAnimationStart:r,onLayoutAnimationComplete:a}=o.getProps(),l=!this.targetLayout||!$n(this.targetLayout,n),h=!e&&i;if(this.options.layoutRoot||this.resumeFrom||h||e&&(l||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const e={...ei(s,"layout"),onPlay:r,onComplete:a};(o.shouldReduceMotion||this.options.layoutRoot)&&(e.delay=0,e.type=!1),this.startAnimation(e),this.setAnimationOrigin(t,h)}else e||vs(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=n})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const t=this.getStack();t&&t.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),p(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Ps),this.animationId++)}getTransformTemplate(){const{visualElement:t}=this.options;return t&&t.getProps().transformTemplate}willUpdate(t=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked())return void(this.options.onExitComplete&&this.options.onExitComplete());if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&ls(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let t=0;t{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure(),!this.snapshot||bn(this.snapshot.measuredBox.x)||bn(this.snapshot.measuredBox.y)||(this.snapshot=void 0))}updateLayout(){if(!this.instance)return;if(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead()||this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let t=0;tnn&&(e.x=1),e.ynn&&(e.y=1)}(this.layoutCorrected,this.treeScale,this.path,e),!t.layout||t.target||1===this.treeScale.x&&1===this.treeScale.y||(t.target=t.layout.layoutBox,t.targetWithTransforms=_());const{target:a}=t;a?(this.projectionDelta&&this.prevProjectionDelta?(An(this.prevProjectionDelta.x,this.projectionDelta.x),An(this.prevProjectionDelta.y,this.projectionDelta.y)):this.createProjectionDeltas(),kn(this.projectionDelta,this.layoutCorrected,a,this.latestValues),this.treeScale.x===o&&this.treeScale.y===r&&Gn(this.projectionDelta.x,this.prevProjectionDelta.x)&&Gn(this.projectionDelta.y,this.prevProjectionDelta.y)||(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",a))):this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender())}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(t=!0){if(this.options.visualElement?.scheduleRender(),t){const t=this.getStack();t&&t.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=dt(),this.projectionDelta=dt(),this.projectionDeltaWithTransform=dt()}setAnimationOrigin(t,e=!1){const i=this.snapshot,s=i?i.latestValues:{},o={...this.latestValues},r=dt();this.relativeParent&&this.relativeParent.options.layoutRoot||(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!e;const a=_(),l=(i?i.source:void 0)!==(this.layout?this.layout.source:void 0),h=this.getStack(),u=!h||h.members.length<=1,c=Boolean(l&&!u&&!0===this.options.crossfade&&!this.path.some(Ds));let d;this.animationProgress=0,this.mixTargetDelta=e=>{const i=e/1e3;var h,m,p,f,y,g;Ss(r.x,t.x,i),Ss(r.y,t.y,i),this.setTargetDelta(r),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Ln(a,this.layout.layoutBox,this.relativeParent.layout.layoutBox),p=this.relativeTarget,f=this.relativeTargetOrigin,y=a,g=i,Es(p.x,f.x,y.x,g),Es(p.y,f.y,y.y,g),d&&(h=this.relativeTarget,m=d,Wn(h.x,m.x)&&Wn(h.y,m.y))&&(this.isProjectionDirty=!1),d||(d=_()),Dn(d,this.relativeTarget)),l&&(this.animationValues=o,function(t,e,i,s,o,r){o?(t.opacity=n(0,i.opacity??1,Zn(s)),t.opacityExit=n(e.opacity??1,0,Jn(s))):r&&(t.opacity=n(e.opacity??1,i.opacity??1,s));for(let o=0;o{ss.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=j(0)),this.motionValue.jump(0,!1),this.currentAnimation=function(t,e,i){const n=B(t)?t:j(t);return n.start(ii("",n,e,i)),n.animation}(this.motionValue,[0,1e3],{...t,velocity:0,isSync:!0,onUpdate:e=>{this.mixTargetDelta(e),t.onUpdate&&t.onUpdate(e)},onStop:()=>{},onComplete:()=>{t.onComplete&&t.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const t=this.getStack();t&&t.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(1e3),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const t=this.getLead();let{targetWithTransforms:e,target:i,layout:n,latestValues:s}=t;if(e&&i&&n){if(this!==t&&this.layout&&n&&Cs(this.options.animationType,this.layout.layoutBox,n.layoutBox)){i=this.target||_();const e=bn(this.layout.layoutBox.x);i.x.min=t.target.x.min,i.x.max=i.x.min+e;const n=bn(this.layout.layoutBox.y);i.y.min=t.target.y.min,i.y.max=i.y.min+n}Dn(e,i),ln(e,s),kn(this.projectionDeltaWithTransform,this.layoutCorrected,e,s)}}registerSharedNode(t,e){this.sharedNodes.has(t)||this.sharedNodes.set(t,new ns);this.sharedNodes.get(t).add(e);const i=e.options.initialPromotionConfig;e.promote({transition:i?i.transition:void 0,preserveFollowOpacity:i&&i.shouldPreserveFollowOpacity?i.shouldPreserveFollowOpacity(e):void 0})}isLead(){const t=this.getStack();return!t||t.lead===this}getLead(){const{layoutId:t}=this.options;return t&&this.getStack()?.lead||this}getPrevLead(){const{layoutId:t}=this.options;return t?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:t}=this.options;if(t)return this.root.sharedNodes.get(t)}promote({needsReset:t,transition:e,preserveFollowOpacity:i}={}){const n=this.getStack();n&&n.promote(this,i),t&&(this.projectionDelta=void 0,this.needsReset=!0),e&&this.setOptions({transition:e})}relegate(){const t=this.getStack();return!!t&&t.relegate(this)}resetSkewAndRotation(){const{visualElement:t}=this.options;if(!t)return;let e=!1;const{latestValues:i}=t;if((i.z||i.rotate||i.rotateX||i.rotateY||i.rotateZ||i.skewX||i.skewY)&&(e=!0),!e)return;const n={};i.z&&as("z",t,n,this.animationValues);for(let e=0;et.currentAnimation?.stop()),this.root.nodes.forEach(fs),this.root.sharedNodes.clear()}}}function us(t){t.updateLayout()}function cs(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:i,measuredBox:n}=t.layout,{animationType:s}=t.options,o=e.source!==t.layout.source;if("size"===s)Hn(t=>{const n=o?e.measuredBox[t]:e.layoutBox[t],s=bn(n);n.min=i[t].min,n.max=n.min+s});else if("x"===s||"y"===s){const t="x"===s?"y":"x";En(o?e.measuredBox[t]:e.layoutBox[t],i[t])}else Cs(s,e.layoutBox,i)&&Hn(n=>{const s=o?e.measuredBox[n]:e.layoutBox[n],r=bn(i[n]);s.max=s.min+r,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[n].max=t.relativeTarget[n].min+r)});const r=dt();kn(r,i,e.layoutBox);const a=dt();o?kn(a,t.applyTransform(n,!0),e.measuredBox):kn(a,i,e.layoutBox);const l=!Un(r);let h=!1;if(!t.resumeFrom){const n=t.getClosestProjectingParent();if(n&&!n.resumeFrom){const{snapshot:s,layout:o}=n;if(s&&o){const r=_();Ln(r,e.layoutBox,s.layoutBox);const a=_();Ln(a,i,o.layoutBox),$n(r,a)||(h=!0),n.options.layoutRoot&&(t.relativeTarget=a,t.relativeTargetOrigin=r,t.relativeParent=n)}}}t.notifyListeners("didUpdate",{layout:i,snapshot:e,delta:a,layoutDelta:r,hasLayoutChanged:l,hasRelativeLayoutChanged:h})}else if(t.isLead()){const{onExitComplete:e}=t.options;e&&e()}t.options.transition=void 0}function ds(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=Boolean(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function ms(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function ps(t){t.clearSnapshot()}function fs(t){t.clearMeasurements()}function ys(t){t.isLayoutDirty=!1}function gs(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function vs(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function xs(t){t.resolveTargetDelta()}function Ts(t){t.calcProjection()}function Ps(t){t.resetSkewAndRotation()}function ws(t){t.removeLeadSnapshot()}function Ss(t,e,i){t.translate=n(e.translate,0,i),t.scale=n(e.scale,1,i),t.origin=e.origin,t.originPoint=e.originPoint}function Es(t,e,i,s){t.min=n(e.min,i.min,s),t.max=n(e.max,i.max,s)}function Ds(t){return t.animationValues&&void 0!==t.animationValues.opacityExit}const As={duration:.45,ease:[.4,0,.1,1]},bs=t=>"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),Ms=bs("applewebkit/")&&!bs("chrome/")?Math.round:t;function ks(t){t.min=Ms(t.min),t.max=Ms(t.max)}function Cs(t,e,i){return"position"===t||"preserve-aspect"===t&&(n=Nn(e),s=Nn(i),o=.2,!(Math.abs(n-s)<=o));var n,s,o}function Vs(t){return t!==t.root&&t.scroll?.wasRoot}const Ls=hs({attachResizeListener:(t,e)=>ts(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),Rs={current:void 0},js=hs({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Rs.current){const t=new Ls({});t.mount(window),t.setOptions({layoutScroll:!0}),Rs.current=t}return Rs.current},resetTransform:(t,e)=>{t.style.transform=void 0!==e?e:"none"},checkIsScrollRoot:t=>Boolean("fixed"===window.getComputedStyle(t).position)});function Bs(t){return{point:{x:t.pageX,y:t.pageY}}}function Is(t,e,i,n){return ts(t,e,(t=>e=>wi(e)&&t(e,Bs(e)))(i),n)}const Os=({current:t})=>t?t.ownerDocument.defaultView:null,Fs=(t,e)=>Math.abs(t-e);const Us=new Set(["auto","scroll"]);class Ws{constructor(t,e,{transformPagePoint:i,contextWindow:n=window,dragSnapToOrigin:s=!1,distanceThreshold:o=3,element:r}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=t=>{this.handleScroll(t.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!this.lastMoveEvent||!this.lastMoveEventInfo)return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=zs(this.lastRawMoveEventInfo,this.transformPagePoint));const t=Ns(this.lastMoveEventInfo,this.history),e=null!==this.startEvent,i=function(t,e){const i=Fs(t.x,e.x),n=Fs(t.y,e.y);return Math.sqrt(i**2+n**2)}(t.offset,{x:0,y:0})>=this.distanceThreshold;if(!e&&!i)return;const{point:n}=t,{timestamp:s}=d;this.history.push({...n,timestamp:s});const{onStart:o,onMove:r}=this.handlers;e||(o&&o(this.lastMoveEvent,t),this.startEvent=this.lastMoveEvent),r&&r(this.lastMoveEvent,t)},this.handlePointerMove=(t,e)=>{this.lastMoveEvent=t,this.lastRawMoveEventInfo=e,this.lastMoveEventInfo=zs(e,this.transformPagePoint),f.update(this.updatePoint,!0)},this.handlePointerUp=(t,e)=>{this.end();const{onEnd:i,onSessionEnd:n,resumeAnimation:s}=this.handlers;if(!this.dragSnapToOrigin&&this.startEvent||s&&s(),!this.lastMoveEvent||!this.lastMoveEventInfo)return;const o=Ns("pointercancel"===t.type?this.lastMoveEventInfo:zs(e,this.transformPagePoint),this.history);this.startEvent&&i&&i(t,o),n&&n(t,o)},!wi(t))return;this.dragSnapToOrigin=s,this.handlers=e,this.transformPagePoint=i,this.distanceThreshold=o,this.contextWindow=n||window;const a=zs(Bs(t),this.transformPagePoint),{point:l}=a,{timestamp:h}=d;this.history=[{...l,timestamp:h}];const{onSessionStart:u}=e;u&&u(t,Ns(a,this.history)),this.removeListeners=kt(Is(this.contextWindow,"pointermove",this.handlePointerMove),Is(this.contextWindow,"pointerup",this.handlePointerUp),Is(this.contextWindow,"pointercancel",this.handlePointerUp)),r&&this.startScrollTracking(r)}startScrollTracking(t){let e=t.parentElement;for(;e;){const t=getComputedStyle(e);(Us.has(t.overflowX)||Us.has(t.overflowY))&&this.scrollPositions.set(e,{x:e.scrollLeft,y:e.scrollTop}),e=e.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const e=this.scrollPositions.get(t);if(!e)return;const i=t===window,n=i?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},s=n.x-e.x,o=n.y-e.y;0===s&&0===o||(i?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=s,this.lastMoveEventInfo.point.y+=o):this.history.length>0&&(this.history[0].x-=s,this.history[0].y-=o),this.scrollPositions.set(t,n),f.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),p(this.updatePoint)}}function zs(t,e){return e?{point:e(t.point)}:t}function $s(t,e){return{x:t.x-e.x,y:t.y-e.y}}function Ns({point:t},e){return{point:t,delta:$s(t,Hs(e)),offset:$s(t,Gs(e)),velocity:Ks(e,.1)}}function Gs(t){return t[0]}function Hs(t){return t[t.length-1]}function Ks(t,e){if(t.length<2)return{x:0,y:0};let i=t.length-1,n=null;const s=Hs(t);for(;i>=0&&(n=t[i],!(s.timestamp-n.timestamp>x(e)));)i--;if(!n)return{x:0,y:0};n===t[0]&&t.length>2&&s.timestamp-n.timestamp>2*x(e)&&(n=t[1]);const o=y(s.timestamp-n.timestamp);if(0===o)return{x:0,y:0};const r={x:(s.x-n.x)/o,y:(s.y-n.y)/o};return r.x===1/0&&(r.x=0),r.y===1/0&&(r.y=0),r}function Ys(t,e,i){return{min:void 0!==e?t.min+e:void 0,max:void 0!==i?t.max+i-(t.max-t.min):void 0}}function Xs(t,e){let i=e.min-t.min,n=e.max-t.max;return e.max-e.min{e&&this.snapToCursor(Bs(t).point),this.stopAnimation()},onStart:(t,e)=>{const{drag:i,dragPropagation:n,onDragStart:s}=this.getProps();if(i&&!n&&(this.openDragLock&&this.openDragLock(),this.openDragLock="x"===(o=i)||"y"===o?gi[o]?null:(gi[o]=!0,()=>{gi[o]=!1}):gi.x||gi.y?null:(gi.x=gi.y=!0,()=>{gi.x=gi.y=!1}),!this.openDragLock))return;var o;this.latestPointerEvent=t,this.latestPanInfo=e,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Hn(t=>{let e=this.getAxisMotionValue(t).get()||0;if(ot.test(e)){const{projection:i}=this.visualElement;if(i&&i.layout){const n=i.layout.layoutBox[t];if(n){e=bn(n)*(parseFloat(e)/100)}}}this.originPoint[t]=e}),s&&f.update(()=>s(t,e),!1,!0),li(this.visualElement,"transform");const{animationState:r}=this.visualElement;r&&r.setActive("whileDrag",!0)},onMove:(t,e)=>{this.latestPointerEvent=t,this.latestPanInfo=e;const{dragPropagation:i,dragDirectionLock:n,onDirectionLock:s,onDrag:o}=this.getProps();if(!i&&!this.openDragLock)return;const{offset:r}=e;if(n&&null===this.currentDirection)return this.currentDirection=function(t,e=10){let i=null;Math.abs(t.y)>e?i="y":Math.abs(t.x)>e&&(i="x");return i}(r),void(null!==this.currentDirection&&s&&s(this.currentDirection));this.updateAxis("x",e.point,r),this.updateAxis("y",e.point,r),this.visualElement.render(),o&&f.update(()=>o(t,e),!1,!0)},onSessionEnd:(t,e)=>{this.latestPointerEvent=t,this.latestPanInfo=e,this.stop(t,e),this.latestPointerEvent=null,this.latestPanInfo=null},resumeAnimation:()=>{const{dragSnapToOrigin:t}=this.getProps();(t||this.constraints)&&this.startAnimation({x:0,y:0})}},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:s,distanceThreshold:i,contextWindow:Os(this.visualElement),element:this.visualElement.current})}stop(t,e){const i=t||this.latestPointerEvent,n=e||this.latestPanInfo,s=this.isDragging;if(this.cancel(),!s||!n||!i)return;const{velocity:o}=n;this.startAnimation(o);const{onDragEnd:r}=this.getProps();r&&f.postRender(()=>r(i,n))}cancel(){this.isDragging=!1;const{projection:t,animationState:e}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:i}=this.getProps();!i&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),e&&e.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,e,i){const{drag:s}=this.getProps();if(!i||!eo(t,s,this.currentDirection))return;const o=this.getAxisMotionValue(t);let r=this.originPoint[t]+i[t];this.constraints&&this.constraints[t]&&(r=function(t,{min:e,max:i},s){return void 0!==e&&ti&&(t=s?n(i,t,s.max):Math.min(t,i)),t}(r,this.constraints[t],this.elastic[t])),o.set(r)}resolveConstraints(){const{dragConstraints:t,dragElastic:e}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,n=this.constraints;t&&ft(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):this.constraints=!(!t||!i)&&function(t,{top:e,left:i,bottom:n,right:s}){return{x:Ys(t.x,i,s),y:Ys(t.y,e,n)}}(i.layoutBox,t),this.elastic=function(t=qs){return!1===t?t=0:!0===t&&(t=qs),{x:_s(t,"left","right"),y:_s(t,"top","bottom")}}(e),n!==this.constraints&&!ft(t)&&i&&this.constraints&&!this.hasMutatedConstraints&&Hn(t=>{!1!==this.constraints&&this.getAxisMotionValue(t)&&(this.constraints[t]=function(t,e){const i={};return void 0!==e.min&&(i.min=e.min-t.min),void 0!==e.max&&(i.max=e.max-t.min),i}(i.layoutBox[t],this.constraints[t]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:e}=this.getProps();if(!t||!ft(t))return!1;const n=t.current;i(null!==n,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:s}=this.visualElement;if(!s||!s.layout)return!1;const o=function(t,e,i){const n=hn(t,i),{scroll:s}=e;return s&&(on(n.x,s.offset.x),on(n.y,s.offset.y)),n}(n,s.root,this.visualElement.getTransformPagePoint());let r=function(t,e){return{x:Xs(t.x,e.x),y:Xs(t.y,e.y)}}(s.layout.layoutBox,o);if(e){const t=e(function({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}(r));this.hasMutatedConstraints=!!t,t&&(r=Ki(t))}return r}startAnimation(t){const{drag:e,dragMomentum:i,dragElastic:n,dragTransition:s,dragSnapToOrigin:o,onDragTransitionEnd:r}=this.getProps(),a=this.constraints||{},l=Hn(r=>{if(!eo(r,e,this.currentDirection))return;let l=a&&a[r]||{};!0!==o&&o!==r||(l={min:0,max:0});const h=n?200:1e6,u=n?40:1e7,c={type:"inertia",velocity:i?t[r]:0,bounceStiffness:h,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...s,...l};return this.startAxisValueAnimation(r,c)});return Promise.all(l).then(r)}startAxisValueAnimation(t,e){const i=this.getAxisMotionValue(t);return li(this.visualElement,t),i.start(ii(t,i,0,e,this.visualElement,!1))}stopAnimation(){Hn(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const e=`_drag${t.toUpperCase()}`,i=this.visualElement.getProps(),n=i[e];return n||this.visualElement.getValue(t,(i.initial?i.initial[t]:void 0)||0)}snapToCursor(t){Hn(e=>{const{drag:i}=this.getProps();if(!eo(e,i,this.currentDirection))return;const{projection:s}=this.visualElement,o=this.getAxisMotionValue(e);if(s&&s.layout){const{min:i,max:r}=s.layout.layoutBox[e],a=o.get()||0;o.set(t[e]-n(i,r,.5)+a)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:e}=this.getProps(),{projection:i}=this.visualElement;if(!ft(e)||!i||!this.constraints)return;this.stopAnimation();const s={x:0,y:0};Hn(t=>{const e=this.getAxisMotionValue(t);if(e&&!1!==this.constraints){const i=e.get();s[t]=function(t,e){let i=.5;const n=bn(t),s=bn(e);return s>n?i=Ct(e.min,e.max-n,t.min):n>s&&(i=Ct(t.min,t.max-s,e.min)),g(0,1,i)}({min:i,max:i},this.constraints[t])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",i.root&&i.root.updateScroll(),i.updateLayout(),this.constraints=!1,this.resolveConstraints(),Hn(e=>{if(!eo(e,t,null))return;const i=this.getAxisMotionValue(e),{min:o,max:r}=this.constraints[e];i.set(n(o,r,s[e]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Js.set(this.visualElement,this);const t=this.visualElement.current,e=Is(t,"pointerdown",e=>{const{drag:i,dragListener:n=!0}=this.getProps(),s=e.target,o=s!==t&&function(t){return Ei.has(t.tagName)||!0===t.isContentEditable}(s);i&&n&&!o&&this.start(e)});let i;const n=()=>{const{dragConstraints:e}=this.getProps();ft(e)&&e.current&&(this.constraints=this.resolveRefConstraints(),i||(i=function(t,e,i){const n=Ni(t,to(i)),s=Ni(e,to(i));return()=>{n(),s()}}(t,e.current,()=>this.scalePositionWithinConstraints())))},{projection:s}=this.visualElement,o=s.addEventListener("measure",n);s&&!s.layout&&(s.root&&s.root.updateScroll(),s.updateLayout()),f.read(n);const r=ts(window,"resize",()=>this.scalePositionWithinConstraints()),a=s.addEventListener("didUpdate",({delta:t,hasLayoutChanged:e})=>{this.isDragging&&e&&(Hn(e=>{const i=this.getAxisMotionValue(e);i&&(this.originPoint[e]+=t[e].translate,i.set(i.get()+t[e].translate))}),this.visualElement.render())});return()=>{r(),e(),o(),a&&a(),i&&i()}}getProps(){const t=this.visualElement.getProps(),{drag:e=!1,dragDirectionLock:i=!1,dragPropagation:n=!1,dragConstraints:s=!1,dragElastic:o=qs,dragMomentum:r=!0}=t;return{...t,drag:e,dragDirectionLock:i,dragPropagation:n,dragConstraints:s,dragElastic:o,dragMomentum:r}}}function to(t){let e=!0;return()=>{e?e=!1:t()}}function eo(t,e,i){return!(!0!==e&&e!==t||null!==i&&i!==t)}const io=t=>(e,i)=>{t&&f.update(()=>t(e,i),!1,!0)};let no=!1;class so extends Dt{componentDidMount(){const{visualElement:t,layoutGroup:e,switchLayoutGroup:i,layoutId:n}=this.props,{projection:s}=t;s&&(e.group&&e.group.add(s),i&&i.register&&n&&i.register(s),no&&s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),ss.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:e,visualElement:i,drag:n,isPresent:s}=this.props,{projection:o}=i;return o?(o.isPresent=s,t.layoutDependency!==e&&o.setOptions({...o.options,layoutDependency:e}),no=!0,n||t.layoutDependency!==e||void 0===e||t.isPresent!==s?o.willUpdate():this.safeToRemove(),t.isPresent!==s&&(s?o.promote():o.relegate()||f.postRender(()=>{const t=o.getStack();t&&t.members.length||this.safeToRemove()})),null):null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),ct.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:e,switchLayoutGroup:i}=this.props,{projection:n}=t;no=!0,n&&(n.scheduleCheckAfterUnmount(),e&&e.group&&e.group.remove(n),i&&i.deregister&&i.deregister(n))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function oo(t){const[e,i]=function(t=!0){const e=Pt(yt);if(null===e)return[!0,null];const{isPresent:i,onExitComplete:n,register:s}=e,o=wt();St(()=>{if(t)return s(o)},[t]);const r=Et(()=>t&&n&&n(o),[o,n,t]);return!i&&n?[!1,r]:[!0]}(),n=Pt(gt);return Tt(so,{...t,layoutGroup:n,switchLayoutGroup:Pt(vt),isPresent:e,safeToRemove:i})}const ro={pan:{Feature:class extends Hi{constructor(){super(...arguments),this.removePointerDownListener=t}onPointerDown(t){this.session=new Ws(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Os(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:e,onPan:i,onPanEnd:n}=this.node.getProps();return{onSessionStart:io(t),onStart:io(e),onMove:io(i),onEnd:(t,e)=>{delete this.session,n&&f.postRender(()=>n(t,e))}}}mount(){this.removePointerDownListener=Is(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}},drag:{Feature:class extends Hi{constructor(e){super(e),this.removeGroupControls=t,this.removeListeners=t,this.controls=new Qs(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||t}update(){const{dragControls:t}=this.node.getProps(),{dragControls:e}=this.node.prevProps||{};t!==e&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},ProjectionNode:js,MeasureLayout:oo}},ao={layout:{ProjectionNode:js,MeasureLayout:oo}};let lo=0;const ho={animation:{Feature:class extends Hi{constructor(t){super(t),t.animationState||(t.animationState=Tn(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();nt(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:e}=this.node.prevProps||{};t!==e&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}},exit:{Feature:class extends Hi{constructor(){super(...arguments),this.id=lo++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:e}=this.node.presenceContext,{isPresent:i}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===i)return;if(t&&!1===i){if(this.isExitComplete){const{initial:t,custom:e}=this.node.getProps();if("string"==typeof t){const i=ni(this.node,t,e);if(i){const{transition:t,transitionEnd:e,...n}=i;for(const t in n)this.node.getValue(t)?.jump(n[t])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);return void(this.isExitComplete=!1)}const n=this.node.animationState.setActive("exit",!t);e&&!t&&n.then(()=>{this.isExitComplete=!0,e(this.id)})}mount(){const{register:t,onExitComplete:e}=this.node.presenceContext||{};e&&e(this.id),t&&(this.unmount=t(this.id))}unmount(){}}}};function uo(t,e,i){const{props:n}=t;t.animationState&&n.whileHover&&t.animationState.setActive("whileHover","Start"===i);const s=n["onHover"+i];s&&f.postRender(()=>s(e,Bs(e)))}function co(t,e,i){const{props:n}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&n.whileTap&&t.animationState.setActive("whileTap","Start"===i);const s=n["onTap"+("End"===i?"":i)];s&&f.postRender(()=>s(e,Bs(e)))}const mo=new WeakMap,po=new WeakMap,fo=t=>{const e=mo.get(t.target);e&&e(t)},yo=t=>{t.forEach(fo)};function go(t,e,i){const n=function({root:t,...e}){const i=t||document;po.has(i)||po.set(i,{});const n=po.get(i),s=JSON.stringify(e);return n[s]||(n[s]=new IntersectionObserver(yo,{root:t,...e})),n[s]}(e);return mo.set(t,i),n.observe(t),()=>{mo.delete(t),n.unobserve(t)}}const vo={some:0,all:1};const xo={renderer:(t,e)=>e.isSVG??xt(t)?new mn(e):new cn(e,{allowProjection:t!==At}),...ho,...{inView:{Feature:class extends Hi{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:e,margin:i,amount:n="some",once:s}=t,o={root:e?e.current:void 0,rootMargin:i,threshold:"number"==typeof n?n:vo[n]};return go(this.node.current,o,t=>{const{isIntersecting:e}=t;if(this.isInView===e)return;if(this.isInView=e,s&&!e&&this.hasEnteredView)return;e&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",e);const{onViewportEnter:i,onViewportLeave:n}=this.node.getProps(),o=e?i:n;o&&o(t)})}mount(){this.startObserver()}update(){if("undefined"==typeof IntersectionObserver)return;const{props:t,prevProps:e}=this.node;["amount","margin","root"].some(function({viewport:t={}},{viewport:e={}}={}){return i=>t[i]!==e[i]}(t,e))&&this.startObserver()}unmount(){}}},tap:{Feature:class extends Hi{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:e,propagate:i}=this.node.props;this.unmount=Ci(t,(t,e)=>(co(this.node,e,"Start"),(t,{success:e})=>co(this.node,t,e?"End":"Cancel")),{useGlobalTarget:e,stopPropagation:!1===i?.tap})}unmount(){}}},focus:{Feature:class extends Hi{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch(e){t=!0}t&&this.node.animationState&&(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){this.isActive&&this.node.animationState&&(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=kt(ts(this.node.current,"focus",()=>this.onFocus()),ts(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}},hover:{Feature:class extends Hi{mount(){const{current:t}=this.node;t&&(this.unmount=Ti(t,(t,e)=>(uo(this.node,e,"Start"),t=>uo(this.node,t,"End"))))}unmount(){}}}}},To={...xo,...ro,...ao};export{To as domMax};