framer-motion
Version:
A simple and powerful JavaScript animation library
1 lines • 97.6 kB
JavaScript
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 h,B as l,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 A,H as b,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),Z=t=>/^0[^.\s]+$/u.test(t);function J(t){let e;return()=>(void 0===e&&(e=t()),e)}const Q=t=>t,tt=(t,e)=>i=>e(t(i)),et=(...t)=>t.reduce(tt),it=(t,e,i)=>{const s=e-t;return 0===s?1:(i-t)/s};class st{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 nt=t=>1e3*t,ot=t=>t/1e3;function rt(t,e){return e?t*(1e3/e):0}const at=(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 Q;const n=e=>function(t,e,i,s,n){let o,r,a=0;do{r=e+(i-e)/2,o=at(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:at(n(t),e,s)}const lt=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,ut=t=>e=>1-t(1-e),ct=ht(.33,1.53,.69,.99),dt=ut(ct),pt=lt(dt),mt=t=>(t*=2)<1?.5*dt(t):.5*(2-Math.pow(2,-10*(t-1))),ft=t=>1-Math.sin(Math.acos(t)),yt=ut(ft),gt=lt(ft),vt=ht(.42,0,1,1),xt=ht(0,0,.58,1),Tt=ht(.42,0,.58,1),Pt=t=>Array.isArray(t)&&"number"==typeof t[0],St={linear:Q,easeIn:vt,easeInOut:Tt,easeOut:xt,circIn:ft,circInOut:gt,circOut:yt,backIn:dt,backInOut:pt,backOut:ct,anticipate:mt},wt=t=>{if(Pt(t)){t.length;const[e,i,s,n]=t;return ht(e,i,s,n)}return"string"==typeof t?St[t]:t},{schedule:At,cancel:bt,state:Vt,steps:Et}=t("undefined"!=typeof requestAnimationFrame?requestAnimationFrame:Q,!0);let Mt;function Dt(){Mt=void 0}const Ct={now:()=>(void 0===Mt&&Ct.set(Vt.isProcessing||e.useManualTiming?Vt.timestamp:performance.now()),Mt),set:t=>{Mt=t,queueMicrotask(Dt)}},kt=t=>Math.round(1e5*t)/1e5,Rt=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;const Lt=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,jt=(t,e)=>i=>Boolean("string"==typeof i&&Lt.test(i)&&i.startsWith(t)||e&&!function(t){return null==t}(i)&&Object.prototype.hasOwnProperty.call(i,e)),Bt=(t,e,i)=>s=>{if("string"!=typeof s)return s;const[n,o,r,a]=s.match(Rt);return{[t]:parseFloat(n),[e]:parseFloat(o),[i]:parseFloat(r),alpha:void 0!==a?parseFloat(a):1}},Ft={...i,transform:t=>Math.round((t=>n(0,255,t))(t))},Ot={test:jt("rgb","red"),parse:Bt("red","green","blue"),transform:({red:t,green:e,blue:i,alpha:n=1})=>"rgba("+Ft.transform(t)+", "+Ft.transform(e)+", "+Ft.transform(i)+", "+kt(s.transform(n))+")"};const It={test:jt("#"),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:Ot.transform},Ut={test:jt("hsl","hue"),parse:Bt("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:i,alpha:n=1})=>"hsla("+Math.round(t)+", "+o.transform(kt(e))+", "+o.transform(kt(i))+", "+kt(s.transform(n))+")"},Nt={test:t=>Ot.test(t)||It.test(t)||Ut.test(t),parse:t=>Ot.test(t)?Ot.parse(t):Ut.test(t)?Ut.parse(t):It.parse(t),transform:t=>"string"==typeof t?t:t.hasOwnProperty("red")?Ot.transform(t):Ut.transform(t)},Kt=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;const $t="number",Wt="color",zt=/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 Yt(t){const e=t.toString(),i=[],s={color:[],number:[],var:[]},n=[];let o=0;const r=e.replace(zt,(t=>(Nt.test(t)?(s.color.push(o),n.push(Wt),i.push(Nt.parse(t))):t.startsWith("var(")?(s.var.push(o),n.push("var"),i.push(t)):(s.number.push(o),n.push($t),i.push(parseFloat(t))),++o,"${}"))).split("${}");return{values:i,split:r,indexes:s,types:n}}function Xt(t){return Yt(t).values}function Ht(t){const{split:e,types:i}=Yt(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===$t?kt(t[o]):e===Wt?Nt.transform(t[o]):t[o]}return n}}const Gt=t=>"number"==typeof t?0:t;const qt={test:function(t){return isNaN(t)&&"string"==typeof t&&(t.match(Rt)?.length||0)+(t.match(Kt)?.length||0)>0},parse:Xt,createTransformer:Ht,getAnimatableNone:function(t){const e=Xt(t);return Ht(t)(e.map(Gt))}};function _t(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 Zt(t,e){return i=>i>0?e:t}const Jt=(t,e,i)=>t+(e-t)*i,Qt=(t,e,i)=>{const s=t*t,n=i*(e*e-s)+s;return n<0?0:Math.sqrt(n)},te=[It,Ot,Ut];function ee(t){const e=(i=t,te.find((t=>t.test(i))));var i;if(!Boolean(e))return!1;let s=e.parse(t);return e===Ut&&(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=_t(a,s,t+1/3),o=_t(a,s,t),r=_t(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 ie=(t,e)=>{const i=ee(t),s=ee(e);if(!i||!s)return Zt(t,e);const n={...i};return t=>(n.red=Qt(i.red,s.red,t),n.green=Qt(i.green,s.green,t),n.blue=Qt(i.blue,s.blue,t),n.alpha=Jt(i.alpha,s.alpha,t),Ot.transform(n))},se=new Set(["none","hidden"]);function ne(t,e){return i=>Jt(t,e,i)}function oe(t){return"number"==typeof t?ne:"string"==typeof t?r(t)?Zt:Nt.test(t)?ie:he:Array.isArray(t)?re:"object"==typeof t?Nt.test(t)?ie:ae:Zt}function re(t,e){const i=[...t],s=i.length,n=t.map(((t,i)=>oe(t)(t,e[i])));return t=>{for(let e=0;e<s;e++)i[e]=n[e](t);return i}}function ae(t,e){const i={...t,...e},s={};for(const n in i)void 0!==t[n]&&void 0!==e[n]&&(s[n]=oe(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=qt.createTransformer(e),s=Yt(t),n=Yt(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?se.has(t)&&!n.values.length||se.has(e)&&!s.values.length?function(t,e){return se.has(t)?i=>i<=0?t:e:i=>i>=1?e:t}(t,e):et(re(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):Zt(t,e)};function le(t,e,i){if("number"==typeof t&&"number"==typeof e&&"number"==typeof i)return Jt(t,e,i);return oe(t)(t,e)}const ue=t=>{const e=({timestamp:e})=>t(e);return{start:(t=!0)=>At.update(e,t),stop:()=>bt(e),now:()=>Vt.isProcessing?Vt.timestamp:Ct.now()}},ce=(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)})`},de=2e4;function pe(t){let e=0;let i=t.next(e);for(;!i.done&&e<de;)e+=50,i=t.next(e);return e>=de?1/0:e}function me(t,e,i){const s=Math.max(e-5,0);return rt(i-t(s),e-s)}const fe=100,ye=10,ge=1,ve=0,xe=800,Te=.3,Pe=.3,Se={granular:.01,default:2},we={granular:.005,default:.5},Ae=.01,be=10,Ve=.05,Ee=1,Me=.001;function De({duration:t=xe,bounce:e=Te,velocity:i=ve,mass:s=ge}){let o,r,a=1-e;a=n(Ve,Ee,a),t=n(Ae,be,ot(t)),a<1?(o=e=>{const s=e*a,n=s*t,o=s-i,r=ke(e,a),h=Math.exp(-n);return Me-o/r*h},r=e=>{const s=e*a*t,n=s*i+i,r=Math.pow(a,2)*Math.pow(e,2)*t,h=Math.exp(-s),l=ke(Math.pow(e,2),a);return(-o(e)+Me>0?-1:1)*((n-r)*h)/l}):(o=e=>Math.exp(-e*t)*((e-i)*t+1)-.001,r=e=>Math.exp(-e*t)*(t*t*(i-e)));const h=function(t,e,i){let s=i;for(let i=1;i<Ce;i++)s-=t(s)/e(s);return s}(o,r,5/t);if(t=nt(t),isNaN(h))return{stiffness:fe,damping:ye,duration:t};{const e=Math.pow(h,2)*s;return{stiffness:e,damping:2*a*Math.sqrt(s*e),duration:t}}}const Ce=12;function ke(t,e){return t*Math.sqrt(1-e*e)}const Re=["duration","bounce"],Le=["stiffness","damping","mass"];function je(t,e){return e.some((e=>void 0!==t[e]))}function Be(t=Pe,e=Te){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],h={done:!1,value:r},{stiffness:l,damping:u,mass:c,duration:d,velocity:p,isResolvedFromDuration:m}=function(t){let e={velocity:ve,stiffness:fe,damping:ye,mass:ge,isResolvedFromDuration:!1,...t};if(!je(t,Le)&&je(t,Re))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:ge,stiffness:o,damping:r}}else{const i=De(t);e={...e,...i,mass:ge},e.isResolvedFromDuration=!0}return e}({...i,velocity:-ot(i.velocity||0)}),f=p||0,y=u/(2*Math.sqrt(l*c)),g=a-r,v=ot(Math.sqrt(l/c)),x=Math.abs(g)<5;let T;if(s||(s=x?Se.granular:Se.default),o||(o=x?we.granular:we.default),y<1){const t=ke(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)h.done=t>=d;else{let i=0===t?f:0;y<1&&(i=0===t?nt(f):me(T,t,e));const n=Math.abs(i)<=s,r=Math.abs(a-e)<=o;h.done=n&&r}return h.value=h.done?a:e,h},toString:()=>{const t=Math.min(pe(P),de),e=ce((e=>P.next(t*e).value),t,30);return t+"ms "+e},toTransition:()=>{}};return P}function Fe({keyframes:t,velocity:e=0,power:i=.8,timeConstant:s=325,bounceDamping:n=10,bounceStiffness:o=500,modifyTarget:r,min:a,max:h,restDelta:l=.5,restSpeed:u}){const c=t[0],d={done:!1,value:c},p=t=>void 0===a?h:void 0===h||Math.abs(a-t)<Math.abs(h-t)?a:h;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)<=l,d.value=d.done?y:i};let T,P;const S=t=>{var e;(e=d.value,void 0!==a&&e<a||void 0!==h&&e>h)&&(T=t,P=Be({keyframes:[d.value,p(d.value)],velocity:me(v,t,d.value),damping:n,stiffness:o,restDelta:l,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 Oe(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 h=t[0]===t[1];t[0]>t[a-1]&&(t=[...t].reverse(),i=[...i].reverse());const l=function(t,i,s){const n=[],o=s||e.mix||le,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]||Q:i;s=et(t,s)}n.push(s)}return n}(i,o,r),u=l.length,c=e=>{if(h&&e<t[0])return i[0];let s=0;if(u>1)for(;s<t.length-2&&!(e<t[s+1]);s++);const n=it(t[s],t[s+1],e);return l[s](n)};return s?e=>c(n(t[0],t[a-1],e)):c}function Ie(t){const e=[0];return function(t,e){const i=t[t.length-1];for(let s=1;s<=e;s++){const n=it(0,e,s);t.push(Jt(i,1,n))}}(e,t.length-1),e}function Ue({duration:t=300,keyframes:e,times:i,ease:s="easeInOut"}){const n=(t=>Array.isArray(t)&&"number"!=typeof t[0])(s)?s.map(wt):wt(s),o={done:!1,value:e[0]},r=function(t,e){return t.map((t=>t*e))}(i&&i.length===e.length?i:Ie(e),t),a=Oe(r,e,{ease:Array.isArray(n)?n:(h=e,l=n,h.map((()=>l||Tt)).splice(0,h.length-1))});var h,l;return{calculatedDuration:t,next:e=>(o.value=a(e),o.done=e>=t,o)}}Be.applyToOptions=t=>{const e=function(t,e=100,i){const s=i({...t,keyframes:[0,e]}),n=Math.min(pe(s),de);return{type:"keyframes",ease:t=>s.next(n*t).value/e,duration:ot(n)}}(t,100,Be);return t.ease=e.ease,t.duration=nt(e.duration),t.type="keyframes",t};const Ne=t=>null!==t;function Ke(t,{repeat:e,repeatType:i="loop"},s,n=1){const o=t.filter(Ne),r=n<0||e&&"loop"!==i&&e%2==1?0:o.length-1;return r&&void 0!==s?s:o[r]}const $e={decay:Fe,inertia:Fe,tween:Ue,keyframes:Ue,spring:Be};function We(t){"string"==typeof t.type&&(t.type=$e[t.type])}class ze{constructor(){this.count=0,this.updateFinished()}get finished(){return this._finished}updateFinished(){this.count++,this._finished=new Promise((t=>{this.resolve=t}))}notifyFinished(){this.resolve()}then(t,e){return this.finished.then(t,e)}}const Ye=t=>t/100;class Xe extends ze{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=(t=!0)=>{if(t){const{motionValue:t}=this.options;t&&t.updatedAt!==Ct.now()&&this.tick(Ct.now())}if(this.isStopped=!0,"idle"===this.state)return;this.teardown();const{onStop:e}=this.options;e&&e()},this.options=t,this.initAnimation(),this.play(),!1===t.autoplay&&this.pause()}initAnimation(){const{options:t}=this;We(t);const{type:e=Ue,repeat:i=0,repeatDelay:s=0,repeatType:n,velocity:o=0}=t;let{keyframes:r}=t;const a=e||Ue;a!==Ue&&"number"!=typeof r[0]&&(this.mixKeyframes=et(Ye,le(r[0],r[1])),r=[0,100]);const h=a({...t,keyframes:r});"mirror"===n&&(this.mirroredGenerator=a({...t,keyframes:[...r].reverse(),velocity:-o})),null===h.calculatedDuration&&(h.calculatedDuration=pe(h));const{calculatedDuration:l}=h;this.calculatedDuration=l,this.resolvedDuration=l+s,this.totalDuration=this.resolvedDuration*(i+1)-s,this.generator=h}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:h}=this;if(null===this.startTime)return i.next(0);const{delay:l=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-l*(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===h||(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!==Fe&&(P.value=Ke(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 ot(this.calculatedDuration)}get time(){return ot(this.currentTime)}set time(t){t=nt(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(Ct.now());const e=this.playbackSpeed!==t;this.playbackSpeed=t,e&&(this.time=ot(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=ue,onPlay:e,startTime:i}=this.options;this.driver||(this.driver=t((t=>this.tick(t)))),e&&e();const s=this.driver.now();"finished"===this.state?(this.updateFinished(),this.startTime=s):null!==this.holdTime?this.startTime=s-this.holdTime:this.startTime||(this.startTime=i??s),"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(Ct.now()),this.holdTime=this.currentTime}complete(){"running"!==this.state&&this.play(),this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";const{onComplete:t}=this.options;t&&t()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown()}teardown(){this.notifyFinished(),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 He=t=>180*t/Math.PI,Ge=t=>{const e=He(Math.atan2(t[1],t[0]));return _e(e)},qe={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:Ge,rotateZ:Ge,skewX:t=>He(Math.atan(t[1])),skewY:t=>He(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},_e=t=>((t%=360)<0&&(t+=360),t),Ze=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),Je=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),Qe={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Ze,scaleY:Je,scale:t=>(Ze(t)+Je(t))/2,rotateX:t=>_e(He(Math.atan2(t[6],t[5]))),rotateY:t=>_e(He(Math.atan2(-t[2],t[0]))),rotateZ:Ge,rotate:Ge,skewX:t=>He(Math.atan(t[4])),skewY:t=>He(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function ti(t){return t.includes("scale")?1:0}function ei(t,e){if(!t||"none"===t)return ti(e);const i=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,n;if(i)s=Qe,n=i;else{const e=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=qe,n=e}if(!n)return ti(e);const o=s[e],r=n[1].split(",").map(ii);return"function"==typeof o?o(r):r[o]}function ii(t){return parseFloat(t.trim())}const si=t=>t===i||t===a,ni=new Set(["x","y","z"]),oi=h.filter((t=>!ni.has(t)));const ri={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})=>ei(e,"x"),y:(t,{transform:e})=>ei(e,"y")};ri.translateX=ri.x,ri.translateY=ri.y;const ai=new Set;let hi=!1,li=!1,ui=!1;function ci(){if(li){const t=Array.from(ai).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 oi.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)}))}li=!1,hi=!1,ai.forEach((t=>t.complete(ui))),ai.clear()}function di(){ai.forEach((t=>{t.readKeyframes(),t.needsMeasurement&&(li=!0)}))}class pi{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?(ai.add(this),hi||(hi=!0,At.read(di),At.resolveKeyframes(ci))):(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),ai.delete(this)}cancel(){"scheduled"===this.state&&(ai.delete(this),this.state="pending")}resume(){"pending"===this.state&&this.scheduleResolve()}}const mi=J((()=>void 0!==window.ScrollTimeline)),fi={};function yi(t,e){const i=J(t);return()=>fi[e]??i()}const gi=yi((()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch(t){return!1}return!0}),"linearEasing"),vi=([t,e,i,s])=>`cubic-bezier(${t}, ${e}, ${i}, ${s})`,xi={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:vi([0,.65,.55,1]),circOut:vi([.55,0,1,.45]),backIn:vi([.31,.01,.66,-.59]),backOut:vi([.33,1.53,.69,.99])};function Ti(t,e){return t?"function"==typeof t?gi()?ce(t,e):"ease-out":Pt(t)?vi(t):Array.isArray(t)?t.map((t=>Ti(t,e)||xi.easeOut)):xi[t]:void 0}function Pi(t,e,i,{delay:s=0,duration:n=300,repeat:o=0,repeatType:r="loop",ease:a="easeOut",times:h}={},l=void 0){const u={[e]:i};h&&(u.offset=h);const c=Ti(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"};l&&(d.pseudoElement=l);return t.animate(u,d)}function Si(t){return"function"==typeof t&&"applyToOptions"in t}class wi extends ze{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 h=function({type:t,...e}){return Si(t)&&gi()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}(t);this.animation=Pi(e,i,s,h,n),!1===h.autoplay&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!n){const t=Ke(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()},this.animation.oncancel=()=>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 ot(Number(t))}get time(){return ot(Number(this.animation.currentTime)||0)}set time(t){this.finishedTime=null,this.animation.currentTime=nt(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&&mi()?(this.animation.timeline=t,Q):e(this)}}const Ai={anticipate:mt,backInOut:pt,circInOut:gt};function bi(t){"string"==typeof t.ease&&t.ease in Ai&&(t.ease=Ai[t.ease])}class Vi extends wi{constructor(t){bi(t),We(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 Xe({...o,autoplay:!1}),a=nt(this.finishedTime??this.time);e.setWithVelocity(r.sample(a-10).value,r.sample(a).value,10),r.stop()}}const Ei=(t,e)=>"zIndex"!==e&&(!("number"!=typeof t&&!Array.isArray(t))||!("string"!=typeof t||!qt.test(t)&&"0"!==t||t.startsWith("url(")));const Mi=new Set(["opacity","clipPath","filter","transform"]),Di=J((()=>Object.hasOwnProperty.call(Element.prototype,"animate")));class Ci extends ze{constructor({autoplay:t=!0,delay:e=0,type:i="keyframes",repeat:s=0,repeatDelay:n=0,repeatType:o="loop",keyframes:r,name:a,motionValue:h,element:l,...u}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Ct.now();const c={autoplay:t,delay:e,type:i,repeat:s,repeatDelay:n,repeatType:o,name:a,motionValue:h,element:l,...u},d=l?.KeyframeResolver||pi;this.keyframeResolver=new d(r,((t,e,i)=>this.onKeyframesResolved(t,e,c,!i)),a,h,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(t,i,s,n){this.keyframeResolver=void 0;const{name:o,type:r,velocity:a,delay:h,isHandoff:l,onUpdate:u}=s;this.resolvedAt=Ct.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=Ei(n,e),a=Ei(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||Si(i))&&s)}(t,o,r,a)||(!e.instantAnimations&&h||u?.(Ke(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=!l&&function(t){const{motionValue:e,name:i,repeatDelay:s,repeatType:n,damping:o,type:r}=t;if(!(e&&e.owner&&e.owner.current instanceof HTMLElement))return!1;const{onUpdate:a,transformTemplate:h}=e.owner.getProps();return Di()&&i&&Mi.has(i)&&("transform"!==i||!h)&&!a&&!s&&"mirror"!==n&&0!==o&&"inertia"!==r}(c)?new Vi({...c,element:c.motionValue.owner.current}):new Xe(c);d.finished.then((()=>this.notifyFinished())).catch(Q),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(),ui=!0,di(),ci(),ui=!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 ki=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Ri(t,e,i=1){const[s,n]=function(t){const e=ki.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)?Ri(n,e,i+1):n}function Li(t,e){return t?.[e]??t?.default??t}const ji=new Set(["width","height","top","left","right","bottom",...h]),Bi=t=>e=>e.test(t),Fi=[i,a,o,l,u,c,{test:t=>"auto"===t,parse:t=>t}],Oi=t=>Fi.find(Bi(t));const Ii=new Set(["brightness","contrast","saturate","opacity"]);function Ui(t){const[e,i]=t.slice(0,-1).split("(");if("drop-shadow"===e)return t;const[s]=i.match(Rt)||[];if(!s)return t;const n=i.replace(s,"");let o=Ii.has(e)?1:0;return s!==i&&(o*=100),e+"("+o+n+")"}const Ni=/\b([a-z-]*)\(.*?\)/gu,Ki={...qt,getAnimatableNone:t=>{const e=t.match(Ni);return e?e.map(Ui).join(" "):t}},$i={...d,color:Nt,backgroundColor:Nt,outlineColor:Nt,fill:Nt,stroke:Nt,borderColor:Nt,borderTopColor:Nt,borderRightColor:Nt,borderBottomColor:Nt,borderLeftColor:Nt,filter:Ki,WebkitFilter:Ki},Wi=t=>$i[t];function zi(t,e){let i=Wi(t);return i!==Ki&&(i=qt),i.getAnimatableNone?i.getAnimatableNone(e):void 0}const Yi=new Set(["auto","none","0"]);class Xi extends pi{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=Ri(s,e.current);void 0!==n&&(t[i]=n),i===t.length-1&&(this.finalKeyframe=s)}}if(this.resolveNoneKeyframes(),!ji.has(i)||2!==t.length)return;const[s,n]=t,o=Oi(s),a=Oi(n);if(o!==a)if(si(o)&&si(a))for(let e=0;e<t.length;e++){const i=t[e];"string"==typeof i&&(t[e]=parseFloat(i))}else ri[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||Z(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&&!Yi.has(e)&&Yt(e).values.length&&(s=t[n]),n++}if(s&&i)for(const n of e)t[n]=zi(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=ri[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]=ri[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 Hi{constructor(t,e={}){this.version="__VERSION__",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(t,e=!0)=>{const i=Ct.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=Ct.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 st);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=Ct.now();if(!this.canTrackVelocity||void 0===this.prevFrameValue||t-this.updatedAt>30)return 0;const e=Math.min(this.updatedAt-this.prevUpdatedAt,30);return rt(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 Gi(t,e){return new Hi(t,e)}const qi={x:!1,y:!1};function _i(){return qi.x||qi.y}function Zi(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 Ji(t){return!("touch"===t.pointerType||_i())}const Qi=(t,e)=>!!e&&(t===e||Qi(t,e.parentElement)),ts=t=>"mouse"===t.pointerType?"number"!=typeof t.button||t.button<=0:!1!==t.isPrimary,es=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);const is=new WeakSet;function ss(t){return e=>{"Enter"===e.key&&t(e)}}function ns(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}function os(t){return ts(t)&&!_i()}function rs(t,e,i={}){const[s,n,o]=Zi(t,i),r=t=>{const s=t.currentTarget;if(!os(t))return;is.add(s);const o=e(s,t),r=(t,e)=>{window.removeEventListener("pointerup",a),window.removeEventListener("pointercancel",h),is.has(s)&&is.delete(s),os(t)&&"function"==typeof o&&o(t,{success:e})},a=t=>{r(t,s===window||s===document||i.useGlobalTarget||Qi(s,t.target))},h=t=>{r(t,!1)};window.addEventListener("pointerup",a,n),window.addEventListener("pointercancel",h,n)};return s.forEach((t=>{var e;(i.useGlobalTarget?window:t).addEventListener("pointerdown",r,n),t instanceof HTMLElement&&(t.addEventListener("focus",(t=>((t,e)=>{const i=t.currentTarget;if(!i)return;const s=ss((()=>{if(is.has(i))return;ns(i,"down");const t=ss((()=>{ns(i,"up")}));i.addEventListener("keyup",t,e),i.addEventListener("blur",(()=>ns(i,"cancel")),e)}));i.addEventListener("keydown",s,e),i.addEventListener("blur",(()=>i.removeEventListener("keydown",s)),e)})(t,n))),e=t,es.has(e.tagName)||-1!==e.tabIndex||t.hasAttribute("tabindex")||(t.tabIndex=0))})),o}const as=[...Fi,Nt,qt];class hs{constructor(t){this.isMounted=!1,this.node=t}update(){}}const ls=t=>null!==t;const us={type:"spring",stiffness:500,damping:25,restSpeed:10},cs={type:"keyframes",duration:.8},ds={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},ps=(t,{keyframes:e})=>e.length>2?cs:p.has(t)?t.startsWith("scale")?{type:"spring",stiffness:550,damping:0===e[1]?2*Math.sqrt(550):30,restSpeed:10}:us:ds;const ms=(t,i,s,n={},o,r)=>a=>{const h=Li(n,t)||{},l=h.delay||n.delay||0;let{elapsed:u=0}=n;u-=nt(l);const c={keyframes:Array.isArray(s)?s:[null,s],ease:"easeOut",velocity:i.getVelocity(),...h,delay:-u,onUpdate:t=>{i.set(t),h.onUpdate&&h.onUpdate(t)},onComplete:()=>{a(),h.onComplete&&h.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:h,elapsed:l,...u}){return!!Object.keys(u).length})(h)||Object.assign(c,ps(t,c)),c.duration&&(c.duration=nt(c.duration)),c.repeatDelay&&(c.repeatDelay=nt(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=!h.type&&!h.ease,d&&!r&&void 0!==i.get()){const t=function(t,{repeat:e,repeatType:i="loop"},s){const n=t.filter(ls),o=e&&"loop"!==i&&e%2==1?0:n.length-1;return o&&void 0!==s?s:n[o]}(c.keyframes,h);if(void 0!==t)return void At.update((()=>{c.onUpdate(t),c.onComplete()}))}return h.isSync?new Xe(c):new Ci(c)};function fs(t,e,i,s={passive:!0}){return t.addEventListener(e,i,s),()=>t.removeEventListener(e,i)}function ys(t){return{point:{x:t.pageX,y:t.pageY}}}function gs(t,e,i,s){return fs(t,e,(t=>e=>ts(e)&&t(e,ys(e)))(i),s)}function vs({top:t,left:e,right:i,bottom:s}){return{x:{min:e,max:i},y:{min:t,max:s}}}function xs(t){return t.max-t.min}function Ts(t,e,i,s=.5){t.origin=s,t.originPoint=Jt(e.min,e.max,t.origin),t.scale=xs(i)/xs(e),t.translate=Jt(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 Ps(t,e,i,s){Ts(t.x,e.x,i.x,s?s.originX:void 0),Ts(t.y,e.y,i.y,s?s.originY:void 0)}function Ss(t,e,i){t.min=i.min+e.min,t.max=t.min+xs(e)}function ws(t,e,i){t.min=e.min-i.min,t.max=t.min+xs(e)}function As(t,e,i){ws(t.x,e.x,i.x),ws(t.y,e.y,i.y)}const bs=()=>({x:{min:0,max:0},y:{min:0,max:0}});function Vs(t){return[t("x"),t("y")]}function Es(t){return void 0===t||1===t}function Ms({scale:t,scaleX:e,scaleY:i}){return!Es(t)||!Es(e)||!Es(i)}function Ds(t){return Ms(t)||Cs(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Cs(t){return ks(t.x)||ks(t.y)}function ks(t){return t&&"0%"!==t}function Rs(t,e,i){return i+e*(t-i)}function Ls(t,e,i,s,n){return void 0!==n&&(t=Rs(t,n,s)),Rs(t,i,s)+e}function js(t,e=0,i=1,s,n){t.min=Ls(t.min,e,i,s,n),t.max=Ls(t.max,e,i,s,n)}function Bs(t,{x:e,y:i}){js(t.x,e.translate,e.scale,e.originPoint),js(t.y,i.translate,i.scale,i.originPoint)}const Fs=.999999999999,Os=1.0000000000001;function Is(t,e){t.min=t.min+e,t.max=t.max+e}function Us(t,e,i,s,n=.5){js(t,e,i,Jt(t.min,t.max,n),s)}function Ns(t,e){Us(t.x,e.x,e.scaleX,e.scale,e.originX),Us(t.y,e.y,e.scaleY,e.scale,e.originY)}function Ks(t,e){return vs(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 $s=({current:t})=>t?t.ownerDocument.defaultView:null;function Ws(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 zs=(t,e)=>Math.abs(t-e);class Ys{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=Gs(this.lastMoveEventInfo,this.history),e=null!==this.startEvent,i=function(t,e){const i=zs(t.x,e.x),s=zs(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}=Vt;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=Xs(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=Gs("pointercancel"===t.type?this.lastMoveEventInfo:Xs(e,this.transformPagePoint),this.history);this.startEvent&&i&&i(t,o),s&&s(t,o)},!ts(t))return;this.dragSnapToOrigin=n,this.handlers=e,this.transformPagePoint=i,this.contextWindow=s||window;const o=Xs(ys(t),this.transformPagePoint),{point:r}=o,{timestamp:a}=Vt;this.history=[{...r,timestamp:a}];const{onSessionStart:h}=e;h&&h(t,Gs(o,this.history)),this.removeListeners=et(gs(this.contextWindow,"pointermove",this.handlePointerMove),gs(this.contextWindow,"pointerup",this.handlePointerUp),gs(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),bt(this.updatePoint)}}function Xs(t,e){return e?{point:e(t.point)}:t}function Hs(t,e){return{x:t.x-e.x,y:t.y-e.y}}function Gs({point:t},e){return{point:t,delta:Hs(t,_s(e)),offset:Hs(t,qs(e)),velocity:Zs(e,.1)}}function qs(t){return t[0]}function _s(t){return t[t.length-1]}function Zs(t,e){if(t.length<2)return{x:0,y:0};let i=t.length-1,s=null;const n=_s(t);for(;i>=0&&(s=t[i],!(n.timestamp-s.timestamp>nt(e)));)i--;if(!s)return{x:0,y:0};const o=ot(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 Js(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 Qs(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 tn=.35;function en(t,e,i){return{min:sn(t,e),max:sn(t,i)}}function sn(t,e){return"number"==typeof t?t:t[e]||0}const nn=new WeakMap;class on{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 Ys(t,{onSessionStart:t=>{const{dragSnapToOrigin:i}=this.getProps();i?this.pauseAnimation():this.stopAnimation(),e&&this.snapToCursor(ys(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?qi[r]?null:(qi[r]=!0,()=>{qi[r]=!1}):qi.x||qi.y?null:(qi.x=qi.y=!0,()=>{qi.x=qi.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),Vs((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=xs(s)*(parseFloat(e)/100)}}}this.originPoint[t]=e})),n&&At.postRender((()=>n(t,e))),Ws(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:()=>Vs((t=>"paused"===this.getAnimationState(t)&&this.getAxisMotionValue(t).animation?.play()))},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:s,contextWindow:$s(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||!rn(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?Jt(e,t,s.min):Math.max(t,e):void 0!==i&&t>i&&(t=s?Jt(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:Js(t.x,i,n),y:Js(t.y,e,s)}}(i.layoutBox,t),this.elastic=function(t=tn){return!1===t?t=0:!0===t&&(t=tn),{x:en(t,"left","right"),y:en(t,"top","bottom")}}(e),s!==this.constraints&&i&&this.constraints&&!this.hasMutatedConstraints&&Vs((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=Ks(t,i),{scroll:n}=e;return n&&(Is(s.x,n.offset.x),Is(s.y,n.offset.y)),s}(i,s.root,this.visualElement.getTransformPagePoint());let o=function(t,e){return{x:Qs(t.x,e.x),y:Qs(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=vs(t))}return o}startAnimation(t){const{drag:e,dragMomentum:i,dragElastic:s,dragTransition:n,dragSnapToOrigin:o,onDragTransitionEnd:r}=this.getProps(),a=this.constraints||{},h=Vs((r=>{if(!rn(r,e,this.currentDirection))return;let h=a&&a[r]||{};o&&(h={min:0,max:0});const l=s?200:1e6,u=s?40:1e7,c={type:"inertia",velocity:i?t[r]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...n,...h};return this.startAxisValueAnimation(r,c)}));return Promise.all(h).then(r)}startAxisValueAnimation(t,e){const i=this.getAxisMotionValue(t);return Ws(this.visualElement,t),i.start(ms(t,i,0,e,this.visualElement,!1))}stopAnimation(){Vs((t=>this.getAxisMotionValue(t).stop()))}pauseAnimation(){Vs((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){Vs((e=>{const{drag:i}=this.getProps();if(!rn(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]-Jt(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};Vs((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=xs(t),o=xs(e);return o>s?i=it(e.min,e.max-s,t.min):s>o&&(i=it(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(),Vs((e=>{if(!rn(e,t,null))return;const i=this.getAxisMotionValue(e),{min:n,max:o}=this.constraints[e];i.set(Jt(n,o,s[e]))}))}addListeners(){if(!this.visualElement.current)return;nn.set(this.visualElement,this);const t=gs(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=fs(window,"resize",(()=>this.scalePositionWithinConstraints())),o=i.addEventListener("didUpdate",(({delta:t,hasLayoutChanged:e})=>{this.isDragging&&e&&(Vs((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=tn,dragMomentum:r=!0}=t;return{...t,drag:e,dragDirectionLock:i,dragPropagation:s,dragConstraints:n,dragElastic:o,dragMomentum:r}}}function rn(t,e,i){return!(!0!==e&&e!==t||null!==i&&i!==t)}const an=t=>(e,i)=>{t&&At.postRender((()=>t(e,i)))};function hn(t){return t.props[y]}const ln=(t,e)=>t.depth-e.depth;class un{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(ln),this.isDirty=!1,this.children.forEach(t)}}const cn=["TopLeft","TopRight","BottomLeft","BottomRight"],dn=cn.length,pn=t=>"string"==typeof t?parseFloat(t):t,mn=t=>"number"==typeof t||a.test(t);function fn(t,e){return void 0!==t[e]?t[e]:t.borderRadius}const yn=vn(0,.5,yt),gn=vn(.5,.95,Q);function vn(t,e,i){return s=>s<t?0:s>e?1:i(it(t,e,s))}function xn(t,e){t.min=e.min,t.max=e.max}function Tn(t,e){xn(t.x,e.x),xn(t.y,e.y)}function Pn(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function Sn(t,e,i,s,n){return t=Rs(t-=e,1/i,s),void 0!==n&&(t=Rs(t,1/n,s)),t}function wn(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=Jt(a.min,a.max,e/100)-a.min);if("number"!=typeof e)return;let h=Jt(r.min,r.max,s);t===r&&(h-=e),t.min=Sn(t.min,e,i,h,n),t.max=Sn(t.max,e,i,h,n)}(t,e[i],e[s],e[n],e.scale,r,a)}const An=["x","scaleX","originX"],bn=["y","scaleY","originY"];function Vn(t,e,i,s){wn(t.x,e,An,i?i.x:void 0,s?s.x:void 0),wn(t.y,e,bn,i?i.y:void 0,s?s.y:void 0)}function En(t){return 0===t.translate&&1===t.scale}function Mn(t){return En(t.x)&&En(t.y)}function Dn(t,e){return t.min===e.min&&t.max===e.max}function Cn(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function kn(t,e){return Cn(t.x,e.x)&&Cn(t.y,e.y)}function Rn(t){return xs(t.x)/xs(t.y)}function Ln(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class jn{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