UNPKG

framer-motion

Version:

A simple and powerful JavaScript animation library

1 lines • 97.7 kB
import{t,M as e,u as i,v as s,w as n,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 p,d as m,b as f,o as y,m as g,r as v,G as x,c as T,i as P,l as S,f as w,p as b,H as A,g as V,s as E,P as M,L as D,S as C,I as k,a as R,J as L,n as j,K as B,N as F,q as O,h as I,j as U,k as N}from"./size-rollup-dom-max-assets.js";import{jsx as K}from"react/jsx-runtime";import{useContext as $,useId as W,useEffect as z,useCallback as Y,Component as X,Fragment as H}from"react";function G(t,e){-1===t.indexOf(e)&&t.push(e)}function q(t,e){const i=t.indexOf(e);i>-1&&t.splice(i,1)}const _=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function Z(t){return"object"==typeof t&&null!==t}const J=t=>/^0[^.\s]+$/u.test(t);function Q(t){let e;return()=>(void 0===e&&(e=t()),e)}const tt=t=>t,et=(t,e)=>i=>e(t(i)),it=(...t)=>t.reduce(et),st=(t,e,i)=>{const s=e-t;return 0===s?1:(i-t)/s};class nt{constructor(){this.subscriptions=[]}add(t){return G(this.subscriptions,t),()=>q(this.subscriptions,t)}notify(t,e,i){const s=this.subscriptions.length;if(s)if(1===s)this.subscriptions[0](t,e,i);else for(let n=0;n<s;n++){const s=this.subscriptions[n];s&&s(t,e,i)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const ot=t=>1e3*t,rt=t=>t/1e3;function at(t,e){return e?t*(1e3/e):0}const lt=(t,e,i)=>(((1-3*i+3*e)*t+(3*i-6*e))*t+3*e)*t;function ht(t,e,i,s){if(t===e&&i===s)return tt;const n=e=>function(t,e,i,s,n){let o,r,a=0;do{r=e+(i-e)/2,o=lt(r,s,n)-t,o>0?i=r:e=r}while(Math.abs(o)>1e-7&&++a<12);return r}(e,0,1,t,i);return t=>0===t||1===t?t:lt(n(t),e,s)}const ut=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,ct=t=>e=>1-t(1-e),dt=ht(.33,1.53,.69,.99),pt=ct(dt),mt=ut(pt),ft=t=>(t*=2)<1?.5*pt(t):.5*(2-Math.pow(2,-10*(t-1))),yt=t=>1-Math.sin(Math.acos(t)),gt=ct(yt),vt=ut(yt),xt=ht(.42,0,1,1),Tt=ht(0,0,.58,1),Pt=ht(.42,0,.58,1),St=t=>Array.isArray(t)&&"number"==typeof t[0],wt={linear:tt,easeIn:xt,easeInOut:Pt,easeOut:Tt,circIn:yt,circInOut:vt,circOut:gt,backIn:pt,backInOut:mt,backOut:dt,anticipate:ft},bt=t=>{if(St(t)){t.length;const[e,i,s,n]=t;return ht(e,i,s,n)}return"string"==typeof t?wt[t]:t},{schedule:At,cancel:Vt,state:Et,steps:Mt}=t("undefined"!=typeof requestAnimationFrame?requestAnimationFrame:tt,!0);let Dt;function Ct(){Dt=void 0}const kt={now:()=>(void 0===Dt&&kt.set(Et.isProcessing||e.useManualTiming?Et.timestamp:performance.now()),Dt),set:t=>{Dt=t,queueMicrotask(Ct)}},Rt=t=>Math.round(1e5*t)/1e5,Lt=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;const jt=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Bt=(t,e)=>i=>Boolean("string"==typeof i&&jt.test(i)&&i.startsWith(t)||e&&!function(t){return null==t}(i)&&Object.prototype.hasOwnProperty.call(i,e)),Ft=(t,e,i)=>s=>{if("string"!=typeof s)return s;const[n,o,r,a]=s.match(Lt);return{[t]:parseFloat(n),[e]:parseFloat(o),[i]:parseFloat(r),alpha:void 0!==a?parseFloat(a):1}},Ot={...i,transform:t=>Math.round((t=>n(0,255,t))(t))},It={test:Bt("rgb","red"),parse:Ft("red","green","blue"),transform:({red:t,green:e,blue:i,alpha:n=1})=>"rgba("+Ot.transform(t)+", "+Ot.transform(e)+", "+Ot.transform(i)+", "+Rt(s.transform(n))+")"};const Ut={test:Bt("#"),parse:function(t){let e="",i="",s="",n="";return t.length>5?(e=t.substring(1,3),i=t.substring(3,5),s=t.substring(5,7),n=t.substring(7,9)):(e=t.substring(1,2),i=t.substring(2,3),s=t.substring(3,4),n=t.substring(4,5),e+=e,i+=i,s+=s,n+=n),{red:parseInt(e,16),green:parseInt(i,16),blue:parseInt(s,16),alpha:n?parseInt(n,16)/255:1}},transform:It.transform},Nt={test:Bt("hsl","hue"),parse:Ft("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:i,alpha:n=1})=>"hsla("+Math.round(t)+", "+o.transform(Rt(e))+", "+o.transform(Rt(i))+", "+Rt(s.transform(n))+")"},Kt={test:t=>It.test(t)||Ut.test(t)||Nt.test(t),parse:t=>It.test(t)?It.parse(t):Nt.test(t)?Nt.parse(t):Ut.parse(t),transform:t=>"string"==typeof t?t:t.hasOwnProperty("red")?It.transform(t):Nt.transform(t)},$t=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;const Wt="number",zt="color",Yt=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Xt(t){const e=t.toString(),i=[],s={color:[],number:[],var:[]},n=[];let o=0;const r=e.replace(Yt,(t=>(Kt.test(t)?(s.color.push(o),n.push(zt),i.push(Kt.parse(t))):t.startsWith("var(")?(s.var.push(o),n.push("var"),i.push(t)):(s.number.push(o),n.push(Wt),i.push(parseFloat(t))),++o,"${}"))).split("${}");return{values:i,split:r,indexes:s,types:n}}function Ht(t){return Xt(t).values}function Gt(t){const{split:e,types:i}=Xt(t),s=e.length;return t=>{let n="";for(let o=0;o<s;o++)if(n+=e[o],void 0!==t[o]){const e=i[o];n+=e===Wt?Rt(t[o]):e===zt?Kt.transform(t[o]):t[o]}return n}}const qt=t=>"number"==typeof t?0:t;const _t={test:function(t){return isNaN(t)&&"string"==typeof t&&(t.match(Lt)?.length||0)+(t.match($t)?.length||0)>0},parse:Ht,createTransformer:Gt,getAnimatableNone:function(t){const e=Ht(t);return Gt(t)(e.map(qt))}};function Zt(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 Jt(t,e){return i=>i>0?e:t}const Qt=(t,e,i)=>t+(e-t)*i,te=(t,e,i)=>{const s=t*t,n=i*(e*e-s)+s;return n<0?0:Math.sqrt(n)},ee=[Ut,It,Nt];function ie(t){const e=(i=t,ee.find((t=>t.test(i))));var i;if(!Boolean(e))return!1;let s=e.parse(t);return e===Nt&&(s=function({hue:t,saturation:e,lightness:i,alpha:s}){t/=360,i/=100;let n=0,o=0,r=0;if(e/=100){const s=i<.5?i*(1+e):i+e-i*e,a=2*i-s;n=Zt(a,s,t+1/3),o=Zt(a,s,t),r=Zt(a,s,t-1/3)}else n=o=r=i;return{red:Math.round(255*n),green:Math.round(255*o),blue:Math.round(255*r),alpha:s}}(s)),s}const se=(t,e)=>{const i=ie(t),s=ie(e);if(!i||!s)return Jt(t,e);const n={...i};return t=>(n.red=te(i.red,s.red,t),n.green=te(i.green,s.green,t),n.blue=te(i.blue,s.blue,t),n.alpha=Qt(i.alpha,s.alpha,t),It.transform(n))},ne=new Set(["none","hidden"]);function oe(t,e){return i=>Qt(t,e,i)}function re(t){return"number"==typeof t?oe:"string"==typeof t?r(t)?Jt:Kt.test(t)?se:he:Array.isArray(t)?ae:"object"==typeof t?Kt.test(t)?se:le:Jt}function ae(t,e){const i=[...t],s=i.length,n=t.map(((t,i)=>re(t)(t,e[i])));return t=>{for(let e=0;e<s;e++)i[e]=n[e](t);return i}}function le(t,e){const i={...t,...e},s={};for(const n in i)void 0!==t[n]&&void 0!==e[n]&&(s[n]=re(t[n])(t[n],e[n]));return t=>{for(const e in s)i[e]=s[e](t);return i}}const he=(t,e)=>{const i=_t.createTransformer(e),s=Xt(t),n=Xt(e);return s.indexes.var.length===n.indexes.var.length&&s.indexes.color.length===n.indexes.color.length&&s.indexes.number.length>=n.indexes.number.length?ne.has(t)&&!n.values.length||ne.has(e)&&!s.values.length?function(t,e){return ne.has(t)?i=>i<=0?t:e:i=>i>=1?e:t}(t,e):it(ae(function(t,e){const i=[],s={color:0,var:0,number:0};for(let n=0;n<e.values.length;n++){const o=e.types[n],r=t.indexes[o][s[o]],a=t.values[r]??0;i[n]=a,s[o]++}return i}(s,n),n.values),i):Jt(t,e)};function ue(t,e,i){if("number"==typeof t&&"number"==typeof e&&"number"==typeof i)return Qt(t,e,i);return re(t)(t,e)}const ce=t=>{const e=({timestamp:e})=>t(e);return{start:(t=!0)=>At.update(e,t),stop:()=>Vt(e),now:()=>Et.isProcessing?Et.timestamp:kt.now()}},de=(t,e,i=10)=>{let s="";const n=Math.max(Math.round(e/i),2);for(let e=0;e<n;e++)s+=t(e/(n-1))+", ";return`linear(${s.substring(0,s.length-2)})`},pe=2e4;function me(t){let e=0;let i=t.next(e);for(;!i.done&&e<pe;)e+=50,i=t.next(e);return e>=pe?1/0:e}function fe(t,e,i){const s=Math.max(e-5,0);return at(i-t(s),e-s)}const ye=100,ge=10,ve=1,xe=0,Te=800,Pe=.3,Se=.3,we={granular:.01,default:2},be={granular:.005,default:.5},Ae=.01,Ve=10,Ee=.05,Me=1,De=.001;function Ce({duration:t=Te,bounce:e=Pe,velocity:i=xe,mass:s=ve}){let o,r,a=1-e;a=n(Ee,Me,a),t=n(Ae,Ve,rt(t)),a<1?(o=e=>{const s=e*a,n=s*t,o=s-i,r=Re(e,a),l=Math.exp(-n);return De-o/r*l},r=e=>{const s=e*a*t,n=s*i+i,r=Math.pow(a,2)*Math.pow(e,2)*t,l=Math.exp(-s),h=Re(Math.pow(e,2),a);return(-o(e)+De>0?-1:1)*((n-r)*l)/h}):(o=e=>Math.exp(-e*t)*((e-i)*t+1)-.001,r=e=>Math.exp(-e*t)*(t*t*(i-e)));const l=function(t,e,i){let s=i;for(let i=1;i<ke;i++)s-=t(s)/e(s);return s}(o,r,5/t);if(t=ot(t),isNaN(l))return{stiffness:ye,damping:ge,duration:t};{const e=Math.pow(l,2)*s;return{stiffness:e,damping:2*a*Math.sqrt(s*e),duration:t}}}const ke=12;function Re(t,e){return t*Math.sqrt(1-e*e)}const Le=["duration","bounce"],je=["stiffness","damping","mass"];function Be(t,e){return e.some((e=>void 0!==t[e]))}function Fe(t=Se,e=Pe){const i="object"!=typeof t?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:s,restDelta:o}=i;const r=i.keyframes[0],a=i.keyframes[i.keyframes.length-1],l={done:!1,value:r},{stiffness:h,damping:u,mass:c,duration:d,velocity:p,isResolvedFromDuration:m}=function(t){let e={velocity:xe,stiffness:ye,damping:ge,mass:ve,isResolvedFromDuration:!1,...t};if(!Be(t,je)&&Be(t,Le))if(t.visualDuration){const i=t.visualDuration,s=2*Math.PI/(1.2*i),o=s*s,r=2*n(.05,1,1-(t.bounce||0))*Math.sqrt(o);e={...e,mass:ve,stiffness:o,damping:r}}else{const i=Ce(t);e={...e,...i,mass:ve},e.isResolvedFromDuration=!0}return e}({...i,velocity:-rt(i.velocity||0)}),f=p||0,y=u/(2*Math.sqrt(h*c)),g=a-r,v=rt(Math.sqrt(h/c)),x=Math.abs(g)<5;let T;if(s||(s=x?we.granular:we.default),o||(o=x?be.granular:be.default),y<1){const t=Re(v,y);T=e=>{const i=Math.exp(-y*v*e);return a-i*((f+y*v*g)/t*Math.sin(t*e)+g*Math.cos(t*e))}}else if(1===y)T=t=>a-Math.exp(-v*t)*(g+(f+v*g)*t);else{const t=v*Math.sqrt(y*y-1);T=e=>{const i=Math.exp(-y*v*e),s=Math.min(t*e,300);return a-i*((f+y*v*g)*Math.sinh(s)+t*g*Math.cosh(s))/t}}const P={calculatedDuration:m&&d||null,next:t=>{const e=T(t);if(m)l.done=t>=d;else{let i=0===t?f:0;y<1&&(i=0===t?ot(f):fe(T,t,e));const n=Math.abs(i)<=s,r=Math.abs(a-e)<=o;l.done=n&&r}return l.value=l.done?a:e,l},toString:()=>{const t=Math.min(me(P),pe),e=de((e=>P.next(t*e).value),t,30);return t+"ms "+e},toTransition:()=>{}};return P}function Oe({keyframes:t,velocity:e=0,power:i=.8,timeConstant:s=325,bounceDamping:n=10,bounceStiffness:o=500,modifyTarget:r,min:a,max:l,restDelta:h=.5,restSpeed:u}){const c=t[0],d={done:!1,value:c},p=t=>void 0===a?l:void 0===l||Math.abs(a-t)<Math.abs(l-t)?a:l;let m=i*e;const f=c+m,y=void 0===r?f:r(f);y!==f&&(m=y-c);const g=t=>-m*Math.exp(-t/s),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 S=t=>{var e;(e=d.value,void 0!==a&&e<a||void 0!==l&&e>l)&&(T=t,P=Fe({keyframes:[d.value,p(d.value)],velocity:fe(v,t,d.value),damping:n,stiffness:o,restDelta:h,restSpeed:u}))};return S(0),{calculatedDuration:null,next:t=>{let e=!1;return P||void 0!==T||(e=!0,x(t),S(t)),void 0!==T&&t>=T?P.next(t-T):(!e&&x(t),d)}}}function Ie(t,i,{clamp:s=!0,ease:o,mixer:r}={}){const a=t.length;if(i.length,1===a)return()=>i[0];if(2===a&&i[0]===i[1])return()=>i[1];const l=t[0]===t[1];t[0]>t[a-1]&&(t=[...t].reverse(),i=[...i].reverse());const h=function(t,i,s){const n=[],o=s||e.mix||ue,r=t.length-1;for(let e=0;e<r;e++){let s=o(t[e],t[e+1]);if(i){const t=Array.isArray(i)?i[e]||tt:i;s=it(t,s)}n.push(s)}return n}(i,o,r),u=h.length,c=e=>{if(l&&e<t[0])return i[0];let s=0;if(u>1)for(;s<t.length-2&&!(e<t[s+1]);s++);const n=st(t[s],t[s+1],e);return h[s](n)};return s?e=>c(n(t[0],t[a-1],e)):c}function Ue(t){const e=[0];return function(t,e){const i=t[t.length-1];for(let s=1;s<=e;s++){const n=st(0,e,s);t.push(Qt(i,1,n))}}(e,t.length-1),e}function Ne({duration:t=300,keyframes:e,times:i,ease:s="easeInOut"}){const n=(t=>Array.isArray(t)&&"number"!=typeof t[0])(s)?s.map(bt):bt(s),o={done:!1,value:e[0]},r=function(t,e){return t.map((t=>t*e))}(i&&i.length===e.length?i:Ue(e),t),a=Ie(r,e,{ease:Array.isArray(n)?n:(l=e,h=n,l.map((()=>h||Pt)).splice(0,l.length-1))});var l,h;return{calculatedDuration:t,next:e=>(o.value=a(e),o.done=e>=t,o)}}Fe.applyToOptions=t=>{const e=function(t,e=100,i){const s=i({...t,keyframes:[0,e]}),n=Math.min(me(s),pe);return{type:"keyframes",ease:t=>s.next(n*t).value/e,duration:rt(n)}}(t,100,Fe);return t.ease=e.ease,t.duration=ot(e.duration),t.type="keyframes",t};const Ke=t=>null!==t;function $e(t,{repeat:e,repeatType:i="loop"},s,n=1){const o=t.filter(Ke),r=n<0||e&&"loop"!==i&&e%2==1?0:o.length-1;return r&&void 0!==s?s:o[r]}const We={decay:Oe,inertia:Oe,tween:Ne,keyframes:Ne,spring:Fe};function ze(t){"string"==typeof t.type&&(t.type=We[t.type])}class Ye{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise((t=>{this.resolve=t}))}notifyFinished(){this.resolve()}then(t,e){return this.finished.then(t,e)}}const Xe=t=>t/100;class He extends Ye{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!==kt.now()&&this.tick(kt.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;ze(t);const{type:e=Ne,repeat:i=0,repeatDelay:s=0,repeatType:n,velocity:o=0}=t;let{keyframes:r}=t;const a=e||Ne;a!==Ne&&"number"!=typeof r[0]&&(this.mixKeyframes=it(Xe,ue(r[0],r[1])),r=[0,100]);const l=a({...t,keyframes:r});"mirror"===n&&(this.mirroredGenerator=a({...t,keyframes:[...r].reverse(),velocity:-o})),null===l.calculatedDuration&&(l.calculatedDuration=me(l));const{calculatedDuration:h}=l;this.calculatedDuration=h,this.resolvedDuration=h+s,this.totalDuration=this.resolvedDuration*(i+1)-s,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:s,mixKeyframes:o,mirroredGenerator:r,resolvedDuration:a,calculatedDuration:l}=this;if(null===this.startTime)return i.next(0);const{delay:h=0,keyframes:u,repeat:c,repeatType:d,repeatDelay:p,type:m,onUpdate:f,finalKeyframe:y}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-s/this.speed,this.startTime)),e?this.currentTime=t:this.updateTime(t);const g=this.currentTime-h*(this.playbackSpeed>=0?1:-1),v=this.playbackSpeed>=0?g<0:g>s;this.currentTime=Math.max(g,0),"finished"===this.state&&null===this.holdTime&&(this.currentTime=s);let x=this.currentTime,T=i;if(c){const t=Math.min(this.currentTime,s)/a;let e=Math.floor(t),i=t%1;!i&&t>=1&&(i=1),1===i&&e--,e=Math.min(e,c+1);Boolean(e%2)&&("reverse"===d?(i=1-i,p&&(i-=p/a)):"mirror"===d&&(T=r)),x=n(0,1,i)*a}const P=v?{done:!1,value:u[0]}:T.next(x);o&&(P.value=o(P.value));let{done:S}=P;v||null===l||(S=this.playbackSpeed>=0?this.currentTime>=s:this.currentTime<=0);const w=null===this.holdTime&&("finished"===this.state||"running"===this.state&&S);return w&&m!==Oe&&(P.value=$e(u,this.options,y,this.speed)),f&&f(P.value),w&&this.finish(),P}then(t,e){return this.finished.then(t,e)}get duration(){return rt(this.calculatedDuration)}get time(){return rt(this.currentTime)}set time(t){t=ot(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?.start(!1)}get speed(){return this.playbackSpeed}set speed(t){this.updateTime(kt.now());const e=this.playbackSpeed!==t;this.playbackSpeed=t,e&&(this.time=rt(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=ce,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(kt.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 Ge=t=>180*t/Math.PI,qe=t=>{const e=Ge(Math.atan2(t[1],t[0]));return Ze(e)},_e={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:qe,rotateZ:qe,skewX:t=>Ge(Math.atan(t[1])),skewY:t=>Ge(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},Ze=t=>((t%=360)<0&&(t+=360),t),Je=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),Qe=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),ti={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Je,scaleY:Qe,scale:t=>(Je(t)+Qe(t))/2,rotateX:t=>Ze(Ge(Math.atan2(t[6],t[5]))),rotateY:t=>Ze(Ge(Math.atan2(-t[2],t[0]))),rotateZ:qe,rotate:qe,skewX:t=>Ge(Math.atan(t[4])),skewY:t=>Ge(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function ei(t){return t.includes("scale")?1:0}function ii(t,e){if(!t||"none"===t)return ei(e);const i=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,n;if(i)s=ti,n=i;else{const e=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=_e,n=e}if(!n)return ei(e);const o=s[e],r=n[1].split(",").map(si);return"function"==typeof o?o(r):r[o]}function si(t){return parseFloat(t.trim())}const ni=t=>t===i||t===a,oi=new Set(["x","y","z"]),ri=l.filter((t=>!oi.has(t)));const ai={width:({x:t},{paddingLeft:e="0",paddingRight:i="0"})=>t.max-t.min-parseFloat(e)-parseFloat(i),height:({y:t},{paddingTop:e="0",paddingBottom:i="0"})=>t.max-t.min-parseFloat(e)-parseFloat(i),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>ii(e,"x"),y:(t,{transform:e})=>ii(e,"y")};ai.translateX=ai.x,ai.translateY=ai.y;const li=new Set;let hi=!1,ui=!1,ci=!1;function di(){if(ui){const t=Array.from(li).filter((t=>t.needsMeasurement)),e=new Set(t.map((t=>t.element))),i=new Map;e.forEach((t=>{const e=function(t){const e=[];return ri.forEach((i=>{const s=t.getValue(i);void 0!==s&&(e.push([i,s.get()]),s.set(i.startsWith("scale")?1:0))})),e}(t);e.length&&(i.set(t,e),t.render())})),t.forEach((t=>t.measureInitialState())),e.forEach((t=>{t.render();const e=i.get(t);e&&e.forEach((([e,i])=>{t.getValue(e)?.set(i)}))})),t.forEach((t=>t.measureEndState())),t.forEach((t=>{void 0!==t.suspendedScrollY&&window.scrollTo(0,t.suspendedScrollY)}))}ui=!1,hi=!1,li.forEach((t=>t.complete(ci))),li.clear()}function pi(){li.forEach((t=>{t.readKeyframes(),t.needsMeasurement&&(ui=!0)}))}class mi{constructor(t,e,i,s,n,o=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=e,this.name=i,this.motionValue=s,this.element=n,this.isAsync=o}scheduleResolve(){this.state="scheduled",this.isAsync?(li.add(this),hi||(hi=!0,At.read(pi),At.resolveKeyframes(di))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:e,element:i,motionValue:s}=this;if(null===t[0]){const n=s?.get(),o=t[t.length-1];if(void 0!==n)t[0]=n;else if(i&&e){const s=i.readValue(e,o);null!=s&&(t[0]=s)}void 0===t[0]&&(t[0]=o),s&&void 0===n&&s.set(t[0])}!function(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),li.delete(this)}cancel(){"scheduled"===this.state&&(li.delete(this),this.state="pending")}resume(){"pending"===this.state&&this.scheduleResolve()}}const fi=Q((()=>void 0!==window.ScrollTimeline)),yi={};function gi(t,e){const i=Q(t);return()=>yi[e]??i()}const vi=gi((()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch(t){return!1}return!0}),"linearEasing"),xi=([t,e,i,s])=>`cubic-bezier(${t}, ${e}, ${i}, ${s})`,Ti={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:xi([0,.65,.55,1]),circOut:xi([.55,0,1,.45]),backIn:xi([.31,.01,.66,-.59]),backOut:xi([.33,1.53,.69,.99])};function Pi(t,e){return t?"function"==typeof t?vi()?de(t,e):"ease-out":St(t)?xi(t):Array.isArray(t)?t.map((t=>Pi(t,e)||Ti.easeOut)):Ti[t]:void 0}function Si(t,e,i,{delay:s=0,duration:n=300,repeat:o=0,repeatType:r="loop",ease:a="easeOut",times:l}={},h=void 0){const u={[e]:i};l&&(u.offset=l);const c=Pi(a,n);Array.isArray(c)&&(u.easing=c);const d={delay:s,duration:n,easing:Array.isArray(c)?"linear":c,fill:"both",iterations:o+1,direction:"reverse"===r?"alternate":"normal"};h&&(d.pseudoElement=h);return t.animate(u,d)}function wi(t){return"function"==typeof t&&"applyToOptions"in t}class bi extends Ye{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,!t)return;const{element:e,name:i,keyframes:s,pseudoElement:n,allowFlatten:o=!1,finalKeyframe:r,onComplete:a}=t;this.isPseudoElement=Boolean(n),this.allowFlatten=o,this.options=t,t.type;const l=function({type:t,...e}){return wi(t)&&vi()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}(t);this.animation=Si(e,i,s,l,n),!1===l.autoplay&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!n){const t=$e(s,this.options,r,this.speed);this.updateMotionValue?this.updateMotionValue(t):function(t,e,i){(t=>t.startsWith("--"))(e)?t.style.setProperty(e,i):t.style[e]=i}(e,i,t),this.animation.cancel()}a?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),"finished"===this.state&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch(t){}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;"idle"!==t&&"finished"!==t&&(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const t=this.animation.effect?.getComputedTiming?.().duration||0;return rt(Number(t))}get time(){return rt(Number(this.animation.currentTime)||0)}set time(t){this.finishedTime=null,this.animation.currentTime=ot(t)}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return null!==this.finishedTime?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(t){this.animation.startTime=t}attachTimeline({timeline:t,observe:e}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,t&&fi()?(this.animation.timeline=t,tt):e(this)}}const Ai={anticipate:ft,backInOut:mt,circInOut:vt};function Vi(t){"string"==typeof t.ease&&t.ease in Ai&&(t.ease=Ai[t.ease])}class Ei extends bi{constructor(t){Vi(t),ze(t),super(t),t.startTime&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:e,onUpdate:i,onComplete:s,element:n,...o}=this.options;if(!e)return;if(void 0!==t)return void e.set(t);const r=new He({...o,autoplay:!1}),a=ot(this.finishedTime??this.time);e.setWithVelocity(r.sample(a-10).value,r.sample(a).value,10),r.stop()}}const Mi=(t,e)=>"zIndex"!==e&&(!("number"!=typeof t&&!Array.isArray(t))||!("string"!=typeof t||!_t.test(t)&&"0"!==t||t.startsWith("url(")));function Di(t){return Z(t)&&"offsetHeight"in t}const Ci=new Set(["opacity","clipPath","filter","transform"]),ki=Q((()=>Object.hasOwnProperty.call(Element.prototype,"animate")));class Ri extends Ye{constructor({autoplay:t=!0,delay:e=0,type:i="keyframes",repeat:s=0,repeatDelay:n=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=kt.now();const c={autoplay:t,delay:e,type:i,repeat:s,repeatDelay:n,repeatType:o,name:a,motionValue:l,element:h,...u},d=h?.KeyframeResolver||mi;this.keyframeResolver=new d(r,((t,e,i)=>this.onKeyframesResolved(t,e,c,!i)),a,l,h),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(t,i,s,n){this.keyframeResolver=void 0;const{name:o,type:r,velocity:a,delay:l,isHandoff:h,onUpdate:u}=s;this.resolvedAt=kt.now(),function(t,e,i,s){const n=t[0];if(null===n)return!1;if("display"===e||"visibility"===e)return!0;const o=t[t.length-1],r=Mi(n,e),a=Mi(o,e);return!(!r||!a)&&(function(t){const e=t[0];if(1===t.length)return!0;for(let i=0;i<t.length;i++)if(t[i]!==e)return!0}(t)||("spring"===i||wi(i))&&s)}(t,o,r,a)||(!e.instantAnimations&&l||u?.($e(t,s,i)),t[0]=t[t.length-1],s.duration=0,s.repeat=0);const c={startTime:n?this.resolvedAt&&this.resolvedAt-this.createdAt>40?this.resolvedAt:this.createdAt:void 0,finalKeyframe:i,...s,keyframes:t},d=!h&&function(t){const{motionValue:e,name:i,repeatDelay:s,repeatType:n,damping:o,type:r}=t;if(!Di(e?.owner?.current))return!1;const{onUpdate:a,transformTemplate:l}=e.owner.getProps();return ki()&&i&&Ci.has(i)&&("transform"!==i||!l)&&!a&&!s&&"mirror"!==n&&0!==o&&"inertia"!==r}(c)?new Ei({...c,element:c.motionValue.owner.current}):new He(c);d.finished.then((()=>this.notifyFinished())).catch(tt),this.pendingTimeline&&(this.stopTimeline=d.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=d}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(),ci=!0,pi(),di(),ci=!1),this._animation}get duration(){return this.animation.duration}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()}}const Li=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function ji(t,e,i=1){const[s,n]=function(t){const e=Li.exec(t);if(!e)return[,];const[,i,s,n]=e;return[`--${i??s}`,n]}(t);if(!s)return;const o=window.getComputedStyle(e).getPropertyValue(s);if(o){const t=o.trim();return _(t)?parseFloat(t):t}return r(n)?ji(n,e,i+1):n}function Bi(t,e){return t?.[e]??t?.default??t}const Fi=new Set(["width","height","top","left","right","bottom",...l]),Oi=t=>e=>e.test(t),Ii=[i,a,o,h,u,c,{test:t=>"auto"===t,parse:t=>t}],Ui=t=>Ii.find(Oi(t));const Ni=new Set(["brightness","contrast","saturate","opacity"]);function Ki(t){const[e,i]=t.slice(0,-1).split("(");if("drop-shadow"===e)return t;const[s]=i.match(Lt)||[];if(!s)return t;const n=i.replace(s,"");let o=Ni.has(e)?1:0;return s!==i&&(o*=100),e+"("+o+n+")"}const $i=/\b([a-z-]*)\(.*?\)/gu,Wi={..._t,getAnimatableNone:t=>{const e=t.match($i);return e?e.map(Ki).join(" "):t}},zi={...d,color:Kt,backgroundColor:Kt,outlineColor:Kt,fill:Kt,stroke:Kt,borderColor:Kt,borderTopColor:Kt,borderRightColor:Kt,borderBottomColor:Kt,borderLeftColor:Kt,filter:Wi,WebkitFilter:Wi},Yi=t=>zi[t];function Xi(t,e){let i=Yi(t);return i!==Wi&&(i=_t),i.getAnimatableNone?i.getAnimatableNone(e):void 0}const Hi=new Set(["auto","none","0"]);class Gi extends mi{constructor(t,e,i,s,n){super(t,e,i,s,n,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:e,name:i}=this;if(!e||!e.current)return;super.readKeyframes();for(let i=0;i<t.length;i++){let s=t[i];if("string"==typeof s&&(s=s.trim(),r(s))){const n=ji(s,e.current);void 0!==n&&(t[i]=n),i===t.length-1&&(this.finalKeyframe=s)}}if(this.resolveNoneKeyframes(),!Fi.has(i)||2!==t.length)return;const[s,n]=t,o=Ui(s),a=Ui(n);if(o!==a)if(ni(o)&&ni(a))for(let e=0;e<t.length;e++){const i=t[e];"string"==typeof i&&(t[e]=parseFloat(i))}else ai[i]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:e}=this,i=[];for(let e=0;e<t.length;e++)(null===t[e]||("number"==typeof(s=t[e])?0===s:null===s||"none"===s||"0"===s||J(s)))&&i.push(e);var s;i.length&&function(t,e,i){let s,n=0;for(;n<t.length&&!s;){const e=t[n];"string"==typeof e&&!Hi.has(e)&&Xt(e).values.length&&(s=t[n]),n++}if(s&&i)for(const n of e)t[n]=Xi(i,s)}(t,i,e)}measureInitialState(){const{element:t,unresolvedKeyframes:e,name:i}=this;if(!t||!t.current)return;"height"===i&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=ai[i](t.measureViewportBox(),window.getComputedStyle(t.current)),e[0]=this.measuredOrigin;const s=e[e.length-1];void 0!==s&&t.getValue(i,s).jump(s,!1)}measureEndState(){const{element:t,name:e,unresolvedKeyframes:i}=this;if(!t||!t.current)return;const s=t.getValue(e);s&&s.jump(this.measuredOrigin,!1);const n=i.length-1,o=i[n];i[n]=ai[e](t.measureViewportBox(),window.getComputedStyle(t.current)),null!==o&&void 0===this.finalKeyframe&&(this.finalKeyframe=o),this.removedTransforms?.length&&this.removedTransforms.forEach((([e,i])=>{t.getValue(e).set(i)})),this.resolveNoneKeyframes()}}class qi{constructor(t,e={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=(t,e=!0)=>{const i=kt.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(t),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const t of this.dependents)t.dirty();e&&this.events.renderRequest?.notify(this.current)},this.hasAnimated=!1,this.setCurrent(t),this.owner=e.owner}setCurrent(t){var e;this.current=t,this.updatedAt=kt.now(),null===this.canTrackVelocity&&void 0!==t&&(this.canTrackVelocity=(e=this.current,!isNaN(parseFloat(e))))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,e){this.events[t]||(this.events[t]=new nt);const i=this.events[t].add(e);return"change"===t?()=>{i(),At.read((()=>{this.events.change.getSize()||this.stop()}))}:i}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,e){this.passiveEffect=t,this.stopPassiveEffect=e}set(t,e=!0){e&&this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t,e)}setWithVelocity(t,e,i){this.set(e),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-i}jump(t,e=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,e&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=kt.now();if(!this.canTrackVelocity||void 0===this.prevFrameValue||t-this.updatedAt>30)return 0;const e=Math.min(this.updatedAt-this.prevUpdatedAt,30);return at(parseFloat(this.current)-parseFloat(this.prevFrameValue),e)}start(t){return this.stop(),new Promise((e=>{this.hasAnimated=!0,this.animation=t(e),this.events.animationStart&&this.events.animationStart.notify()})).then((()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()}))}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function _i(t,e){return new qi(t,e)}const Zi={x:!1,y:!1};function Ji(){return Zi.x||Zi.y}function Qi(t,e){const i=function(t,e,i){if(t instanceof EventTarget)return[t];if("string"==typeof t){let s=document;e&&(s=e.current);const n=i?.[t]??s.querySelectorAll(t);return n?Array.from(n):[]}return Array.from(t)}(t),s=new AbortController;return[i,{passive:!0,...e,signal:s.signal},()=>s.abort()]}function ts(t){return!("touch"===t.pointerType||Ji())}const es=(t,e)=>!!e&&(t===e||es(t,e.parentElement)),is=t=>"mouse"===t.pointerType?"number"!=typeof t.button||t.button<=0:!1!==t.isPrimary,ss=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);const ns=new WeakSet;function os(t){return e=>{"Enter"===e.key&&t(e)}}function rs(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}function as(t){return is(t)&&!Ji()}function ls(t,e,i={}){const[s,n,o]=Qi(t,i),r=t=>{const s=t.currentTarget;if(!as(t))return;ns.add(s);const o=e(s,t),r=(t,e)=>{window.removeEventListener("pointerup",a),window.removeEventListener("pointercancel",l),ns.has(s)&&ns.delete(s),as(t)&&"function"==typeof o&&o(t,{success:e})},a=t=>{r(t,s===window||s===document||i.useGlobalTarget||es(s,t.target))},l=t=>{r(t,!1)};window.addEventListener("pointerup",a,n),window.addEventListener("pointercancel",l,n)};return s.forEach((t=>{var e;(i.useGlobalTarget?window:t).addEventListener("pointerdown",r,n),Di(t)&&(t.addEventListener("focus",(t=>((t,e)=>{const i=t.currentTarget;if(!i)return;const s=os((()=>{if(ns.has(i))return;rs(i,"down");const t=os((()=>{rs(i,"up")}));i.addEventListener("keyup",t,e),i.addEventListener("blur",(()=>rs(i,"cancel")),e)}));i.addEventListener("keydown",s,e),i.addEventListener("blur",(()=>i.removeEventListener("keydown",s)),e)})(t,n))),e=t,ss.has(e.tagName)||-1!==e.tabIndex||t.hasAttribute("tabindex")||(t.tabIndex=0))})),o}function hs(t){return Z(t)&&"ownerSVGElement"in t}const us=[...Ii,Kt,_t];class cs{constructor(t){this.isMounted=!1,this.node=t}update(){}}const ds=t=>null!==t;const ps={type:"spring",stiffness:500,damping:25,restSpeed:10},ms={type:"keyframes",duration:.8},fs={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},ys=(t,{keyframes:e})=>e.length>2?ms:p.has(t)?t.startsWith("scale")?{type:"spring",stiffness:550,damping:0===e[1]?2*Math.sqrt(550):30,restSpeed:10}:ps:fs;const gs=(t,i,s,n={},o,r)=>a=>{const l=Bi(n,t)||{},h=l.delay||n.delay||0;let{elapsed:u=0}=n;u-=ot(h);const c={keyframes:Array.isArray(s)?s:[null,s],ease:"easeOut",velocity:i.getVelocity(),...l,delay:-u,onUpdate:t=>{i.set(t),l.onUpdate&&l.onUpdate(t)},onComplete:()=>{a(),l.onComplete&&l.onComplete()},name:t,motionValue:i,element:r?void 0:o};(function({when:t,delay:e,delayChildren:i,staggerChildren:s,staggerDirection:n,repeat:o,repeatType:r,repeatDelay:a,from:l,elapsed:h,...u}){return!!Object.keys(u).length})(l)||Object.assign(c,ys(t,c)),c.duration&&(c.duration=ot(c.duration)),c.repeatDelay&&(c.repeatDelay=ot(c.repeatDelay)),void 0!==c.from&&(c.keyframes[0]=c.from);let d=!1;if((!1===c.type||0===c.duration&&!c.repeatDelay)&&(c.duration=0,0===c.delay&&(d=!0)),(e.instantAnimations||e.skipAnimations)&&(d=!0,c.duration=0,c.delay=0),c.allowFlatten=!l.type&&!l.ease,d&&!r&&void 0!==i.get()){const t=function(t,{repeat:e,repeatType:i="loop"},s){const n=t.filter(ds),o=e&&"loop"!==i&&e%2==1?0:n.length-1;return o&&void 0!==s?s:n[o]}(c.keyframes,l);if(void 0!==t)return void At.update((()=>{c.onUpdate(t),c.onComplete()}))}return l.isSync?new He(c):new Ri(c)};function vs(t,e,i,s={passive:!0}){return t.addEventListener(e,i,s),()=>t.removeEventListener(e,i)}function xs(t){return{point:{x:t.pageX,y:t.pageY}}}function Ts(t,e,i,s){return vs(t,e,(t=>e=>is(e)&&t(e,xs(e)))(i),s)}function Ps({top:t,left:e,right:i,bottom:s}){return{x:{min:e,max:i},y:{min:t,max:s}}}function Ss(t){return t.max-t.min}function ws(t,e,i,s=.5){t.origin=s,t.originPoint=Qt(e.min,e.max,t.origin),t.scale=Ss(i)/Ss(e),t.translate=Qt(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 bs(t,e,i,s){ws(t.x,e.x,i.x,s?s.originX:void 0),ws(t.y,e.y,i.y,s?s.originY:void 0)}function As(t,e,i){t.min=i.min+e.min,t.max=t.min+Ss(e)}function Vs(t,e,i){t.min=e.min-i.min,t.max=t.min+Ss(e)}function Es(t,e,i){Vs(t.x,e.x,i.x),Vs(t.y,e.y,i.y)}const Ms=()=>({x:{min:0,max:0},y:{min:0,max:0}});function Ds(t){return[t("x"),t("y")]}function Cs(t){return void 0===t||1===t}function ks({scale:t,scaleX:e,scaleY:i}){return!Cs(t)||!Cs(e)||!Cs(i)}function Rs(t){return ks(t)||Ls(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Ls(t){return js(t.x)||js(t.y)}function js(t){return t&&"0%"!==t}function Bs(t,e,i){return i+e*(t-i)}function Fs(t,e,i,s,n){return void 0!==n&&(t=Bs(t,n,s)),Bs(t,i,s)+e}function Os(t,e=0,i=1,s,n){t.min=Fs(t.min,e,i,s,n),t.max=Fs(t.max,e,i,s,n)}function Is(t,{x:e,y:i}){Os(t.x,e.translate,e.scale,e.originPoint),Os(t.y,i.translate,i.scale,i.originPoint)}const Us=.999999999999,Ns=1.0000000000001;function Ks(t,e){t.min=t.min+e,t.max=t.max+e}function $s(t,e,i,s,n=.5){Os(t,e,i,Qt(t.min,t.max,n),s)}function Ws(t,e){$s(t.x,e.x,e.scaleX,e.scale,e.originX),$s(t.y,e.y,e.scaleY,e.scale,e.originY)}function zs(t,e){return Ps(function(t,e){if(!e)return t;const i=e({x:t.left,y:t.top}),s=e({x:t.right,y:t.bottom});return{top:i.y,left:i.x,bottom:s.y,right:s.x}}(t.getBoundingClientRect(),e))}const Ys=({current:t})=>t?t.ownerDocument.defaultView:null;function Xs(t,i){const s=t.getValue("willChange");if(n=s,Boolean(m(n)&&n.add))return s.add(i);if(!s&&e.WillChange){const s=new e.WillChange("auto");t.addValue("willChange",s),s.add(i)}var n}const Hs=(t,e)=>Math.abs(t-e);class Gs{constructor(t,e,{transformPagePoint:i,contextWindow:s,dragSnapToOrigin:n=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!this.lastMoveEvent||!this.lastMoveEventInfo)return;const t=Zs(this.lastMoveEventInfo,this.history),e=null!==this.startEvent,i=function(t,e){const i=Hs(t.x,e.x),s=Hs(t.y,e.y);return Math.sqrt(i**2+s**2)}(t.offset,{x:0,y:0})>=3;if(!e&&!i)return;const{point:s}=t,{timestamp:n}=Et;this.history.push({...s,timestamp:n});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.lastMoveEventInfo=qs(e,this.transformPagePoint),At.update(this.updatePoint,!0)},this.handlePointerUp=(t,e)=>{this.end();const{onEnd:i,onSessionEnd:s,resumeAnimation:n}=this.handlers;if(this.dragSnapToOrigin&&n&&n(),!this.lastMoveEvent||!this.lastMoveEventInfo)return;const o=Zs("pointercancel"===t.type?this.lastMoveEventInfo:qs(e,this.transformPagePoint),this.history);this.startEvent&&i&&i(t,o),s&&s(t,o)},!is(t))return;this.dragSnapToOrigin=n,this.handlers=e,this.transformPagePoint=i,this.contextWindow=s||window;const o=qs(xs(t),this.transformPagePoint),{point:r}=o,{timestamp:a}=Et;this.history=[{...r,timestamp:a}];const{onSessionStart:l}=e;l&&l(t,Zs(o,this.history)),this.removeListeners=it(Ts(this.contextWindow,"pointermove",this.handlePointerMove),Ts(this.contextWindow,"pointerup",this.handlePointerUp),Ts(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),Vt(this.updatePoint)}}function qs(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 Zs({point:t},e){return{point:t,delta:_s(t,Qs(e)),offset:_s(t,Js(e)),velocity:tn(e,.1)}}function Js(t){return t[0]}function Qs(t){return t[t.length-1]}function tn(t,e){if(t.length<2)return{x:0,y:0};let i=t.length-1,s=null;const n=Qs(t);for(;i>=0&&(s=t[i],!(n.timestamp-s.timestamp>ot(e)));)i--;if(!s)return{x:0,y:0};const o=rt(n.timestamp-s.timestamp);if(0===o)return{x:0,y:0};const r={x:(n.x-s.x)/o,y:(n.y-s.y)/o};return r.x===1/0&&(r.x=0),r.y===1/0&&(r.y=0),r}function en(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 sn(t,e){let i=e.min-t.min,s=e.max-t.max;return e.max-e.min<t.max-t.min&&([i,s]=[s,i]),{min:i,max:s}}const nn=.35;function on(t,e,i){return{min:rn(t,e),max:rn(t,i)}}function rn(t,e){return"number"==typeof t?t:t[e]||0}const an=new WeakMap;class ln{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic={x:{min:0,max:0},y:{min:0,max:0}},this.visualElement=t}start(t,{snapToCursor:e=!1}={}){const{presenceContext:i}=this.visualElement;if(i&&!1===i.isPresent)return;const{dragSnapToOrigin:s}=this.getProps();this.panSession=new Gs(t,{onSessionStart:t=>{const{dragSnapToOrigin:i}=this.getProps();i?this.pauseAnimation():this.stopAnimation(),e&&this.snapToCursor(xs(t).point)},onStart:(t,e)=>{const{drag:i,dragPropagation:s,onDragStart:n}=this.getProps();if(i&&!s&&(this.openDragLock&&this.openDragLock(),this.openDragLock="x"===(r=i)||"y"===r?Zi[r]?null:(Zi[r]=!0,()=>{Zi[r]=!1}):Zi.x||Zi.y?null:(Zi.x=Zi.y=!0,()=>{Zi.x=Zi.y=!1}),!this.openDragLock))return;var r;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Ds((t=>{let e=this.getAxisMotionValue(t).get()||0;if(o.test(e)){const{projection:i}=this.visualElement;if(i&&i.layout){const s=i.layout.layoutBox[t];if(s){e=Ss(s)*(parseFloat(e)/100)}}}this.originPoint[t]=e})),n&&At.postRender((()=>n(t,e))),Xs(this.visualElement,"transform");const{animationState:a}=this.visualElement;a&&a.setActive("whileDrag",!0)},onMove:(t,e)=>{const{dragPropagation:i,dragDirectionLock:s,onDirectionLock:n,onDrag:o}=this.getProps();if(!i&&!this.openDragLock)return;const{offset:r}=e;if(s&&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&&n&&n(this.currentDirection));this.updateAxis("x",e.point,r),this.updateAxis("y",e.point,r),this.visualElement.render(),o&&o(t,e)},onSessionEnd:(t,e)=>this.stop(t,e),resumeAnimation:()=>Ds((t=>"paused"===this.getAnimationState(t)&&this.getAxisMotionValue(t).animation?.play()))},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:s,contextWindow:Ys(this.visualElement)})}stop(t,e){const i=this.isDragging;if(this.cancel(),!i)return;const{velocity:s}=e;this.startAnimation(s);const{onDragEnd:n}=this.getProps();n&&At.postRender((()=>n(t,e)))}cancel(){this.isDragging=!1;const{projection:t,animationState:e}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:i}=this.getProps();!i&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),e&&e.setActive("whileDrag",!1)}updateAxis(t,e,i){const{drag:s}=this.getProps();if(!i||!hn(t,s,this.currentDirection))return;const n=this.getAxisMotionValue(t);let o=this.originPoint[t]+i[t];this.constraints&&this.constraints[t]&&(o=function(t,{min:e,max:i},s){return void 0!==e&&t<e?t=s?Qt(e,t,s.min):Math.max(t,e):void 0!==i&&t>i&&(t=s?Qt(i,t,s.max):Math.min(t,i)),t}(o,this.constraints[t],this.elastic[t])),n.set(o)}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,s=this.constraints;t&&f(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):this.constraints=!(!t||!i)&&function(t,{top:e,left:i,bottom:s,right:n}){return{x:en(t.x,i,n),y:en(t.y,e,s)}}(i.layoutBox,t),this.elastic=function(t=nn){return!1===t?t=0:!0===t&&(t=nn),{x:on(t,"left","right"),y:on(t,"top","bottom")}}(e),s!==this.constraints&&i&&this.constraints&&!this.hasMutatedConstraints&&Ds((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||!f(t))return!1;const i=t.current,{projection:s}=this.visualElement;if(!s||!s.layout)return!1;const n=function(t,e,i){const s=zs(t,i),{scroll:n}=e;return n&&(Ks(s.x,n.offset.x),Ks(s.y,n.offset.y)),s}(i,s.root,this.visualElement.getTransformPagePoint());let o=function(t,e){return{x:sn(t.x,e.x),y:sn(t.y,e.y)}}(s.layout.layoutBox,n);if(e){const t=e(function({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}(o));this.hasMutatedConstraints=!!t,t&&(o=Ps(t))}return o}startAnimation(t){const{drag:e,dragMomentum:i,dragElastic:s,dragTransition:n,dragSnapToOrigin:o,onDragTransitionEnd:r}=this.getProps(),a=this.constraints||{},l=Ds((r=>{if(!hn(r,e,this.currentDirection))return;let l=a&&a[r]||{};o&&(l={min:0,max:0});const h=s?200:1e6,u=s?40:1e7,c={type:"inertia",velocity:i?t[r]:0,bounceStiffness:h,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...n,...l};return this.startAxisValueAnimation(r,c)}));return Promise.all(l).then(r)}startAxisValueAnimation(t,e){const i=this.getAxisMotionValue(t);return Xs(this.visualElement,t),i.start(gs(t,i,0,e,this.visualElement,!1))}stopAnimation(){Ds((t=>this.getAxisMotionValue(t).stop()))}pauseAnimation(){Ds((t=>this.getAxisMotionValue(t).animation?.pause()))}getAnimationState(t){return this.getAxisMotionValue(t).animation?.state}getAxisMotionValue(t){const e=`_drag${t.toUpperCase()}`,i=this.visualElement.getProps(),s=i[e];return s||this.visualElement.getValue(t,(i.initial?i.initial[t]:void 0)||0)}snapToCursor(t){Ds((e=>{const{drag:i}=this.getProps();if(!hn(e,i,this.currentDirection))return;const{projection:s}=this.visualElement,n=this.getAxisMotionValue(e);if(s&&s.layout){const{min:i,max:o}=s.layout.layoutBox[e];n.set(t[e]-Qt(i,o,.5))}}))}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:e}=this.getProps(),{projection:i}=this.visualElement;if(!f(e)||!i||!this.constraints)return;this.stopAnimation();const s={x:0,y:0};Ds((t=>{const e=this.getAxisMotionValue(t);if(e&&!1!==this.constraints){const i=e.get();s[t]=function(t,e){let i=.5;const s=Ss(t),o=Ss(e);return o>s?i=st(e.min,e.max-s,t.min):s>o&&(i=st(t.min,t.max-o,e.min)),n(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.resolveConstraints(),Ds((e=>{if(!hn(e,t,null))return;const i=this.getAxisMotionValue(e),{min:n,max:o}=this.constraints[e];i.set(Qt(n,o,s[e]))}))}addListeners(){if(!this.visualElement.current)return;an.set(this.visualElement,this);const t=Ts(this.visualElement.current,"pointerdown",(t=>{const{drag:e,dragListener:i=!0}=this.getProps();e&&i&&this.start(t)})),e=()=>{const{dragConstraints:t}=this.getProps();f(t)&&t.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,s=i.addEventListener("measure",e);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),At.read(e);const n=vs(window,"resize",(()=>this.scalePositionWithinConstraints())),o=i.addEventListener("didUpdate",(({delta:t,hasLayoutChanged:e})=>{this.isDragging&&e&&(Ds((e=>{const i=this.getAxisMotionValue(e);i&&(this.originPoint[e]+=t[e].translate,i.set(i.get()+t[e].translate))})),this.visualElement.render())}));return()=>{n(),t(),s(),o&&o()}}getProps(){const t=this.visualElement.getProps(),{drag:e=!1,dragDirectionLock:i=!1,dragPropagation:s=!1,dragConstraints:n=!1,dragElastic:o=nn,dragMomentum:r=!0}=t;return{...t,drag:e,dragDirectionLock:i,dragPropagation:s,dragConstraints:n,dragElastic:o,dragMomentum:r}}}function hn(t,e,i){return!(!0!==e&&e!==t||null!==i&&i!==t)}const un=t=>(e,i)=>{t&&At.postRender((()=>t(e,i)))};function cn(t){return t.props[y]}const dn=(t,e)=>t.depth-e.depth;class pn{constructor(){this.children=[],this.isDirty=!1}add(t){G(this.children,t),this.isDirty=!0}remove(t){q(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(dn),this.isDirty=!1,this.children.forEach(t)}}const mn=["TopLeft","TopRight","BottomLeft","BottomRight"],fn=mn.length,yn=t=>"string"==typeof t?parseFloat(t):t,gn=t=>"number"==typeof t||a.test(t);function vn(t,e){return void 0!==t[e]?t[e]:t.borderRadius}const xn=Pn(0,.5,gt),Tn=Pn(.5,.95,tt);function Pn(t,e,i){return s=>s<t?0:s>e?1:i(st(t,e,s))}function Sn(t,e){t.min=e.min,t.max=e.max}function wn(t,e){Sn(t.x,e.x),Sn(t.y,e.y)}function bn(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function An(t,e,i,s,n){return t=Bs(t-=e,1/i,s),void 0!==n&&(t=Bs(t,1/n,s)),t}function Vn(t,e,[i,s,n],r,a){!function(t,e=0,i=1,s=.5,n,r=t,a=t){o.test(e)&&(e=parseFloat(e),e=Qt(a.min,a.max,e/100)-a.min);if("number"!=typeof e)return;let l=Qt(r.min,r.max,s);t===r&&(l-=e),t.min=An(t.min,e,i,l,n),t.max=An(t.max,e,i,l,n)}(t,e[i],e[s],e[n],e.scale,r,a)}const En=["x","scaleX","originX"],Mn=["y","scaleY","originY"];function Dn(t,e,i,s){Vn(t.x,e,En,i?i.x:void 0,s?s.x:void 0),Vn(t.y,e,Mn,i?i.y:void 0,s?s.y:void 0)}function Cn(t){return 0===t.translate&&1===t.scale}function kn(t){return Cn(t.x)&&Cn(t.y)}function Rn(t,e){return t.min===e.min&&t.max===e.max}function Ln(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function jn(t,e){return Ln(t.x,e.x)&&Ln(t.y,e.y)}function Bn(t){return Ss(t.x)/Ss(t.y)}function Fn(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class On{constructor(){this.members=[]}add(t){G(this.members,t),t.scheduleRender()}remove(t){if(q(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const t=this.members[thi