motion 10.10.0 → 10.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  Motion One adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ ## [10.10.1] [2022-06-24]
6
+
7
+ ### Fixed
8
+
9
+ - Fixed incorrect handling of `easing` string vs array in polyfill. [Issue (sponsors only)](https://github.com/motiondivision/motionone/issues/96)
10
+
5
11
  ## [10.10.0] [2022-05-28]
6
12
 
7
13
  ### Added
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Motion={})}(this,(function(t){"use strict";class e{setAnimation(t){this.animation=t,null==t||t.finished.then((()=>this.clearAnimation())).catch((()=>{}))}clearAnimation(){this.animation=this.generator=void 0}}const n=new WeakMap;function a(t){return n.has(t)||n.set(t,{transforms:[],values:new Map}),n.get(t)}function i(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const r={duration:.3,delay:0,endDelay:0,repeat:0,easing:"ease"},s=t=>"number"==typeof t,o=t=>"string"==typeof t,c=t=>"object"==typeof t&&Boolean(t.createAnimation),l=t=>Array.isArray(t)&&!s(t[0]),u=(t,e,n)=>-n*t+n*e+t,h=()=>{},f=t=>t,d=(t,e,n)=>e-t==0?1:(n-t)/(e-t);function p(t,e){const n=t[t.length-1];for(let a=1;a<=e;a++){const i=d(0,e,a);t.push(u(n,1,i))}}function m(t){const e=[0];return p(e,t-1),e}const g=t=>1e3*t,y=t=>t/1e3;const v=["","X","Y","Z"],b={x:"translateX",y:"translateY",z:"translateZ"},M={syntax:"<angle>",initialValue:"0deg",toDefaultUnit:t=>t+"deg"},T={translate:{syntax:"<length-percentage>",initialValue:"0px",toDefaultUnit:t=>t+"px"},rotate:M,scale:{syntax:"<number>",initialValue:1,toDefaultUnit:f},skew:M},w=new Map,O=t=>`--motion-${t}`,S=["x","y","z"];["translate","scale","rotate","skew"].forEach((t=>{v.forEach((e=>{S.push(t+e),w.set(O(t+e),T[t])}))}));const x=(t,e)=>S.indexOf(t)-S.indexOf(e),A=new Set(S),j=t=>A.has(t),k=t=>t.sort(x).reduce(D,"").trim(),D=(t,e)=>`${t} ${e}(var(${O(e)}))`,R=t=>t.startsWith("--"),P=new Set;const $=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t;function E(t,e,n,a){if(t===e&&n===a)return f;const i=e=>function(t,e,n,a,i){let r,s,o=0;do{s=e+(n-e)/2,r=$(s,a,i)-t,r>0?n=s:e=s}while(Math.abs(r)>1e-7&&++o<12);return s}(e,0,1,t,n);return t=>0===t||1===t?t:$(i(t),e,a)}const q=(t,e="end")=>n=>{const a=(n="end"===e?Math.min(n,.999):Math.max(n,.001))*t,i="end"===e?Math.floor(a):Math.ceil(a);return r=0,s=1,o=i/t,Math.min(Math.max(o,r),s);var r,s,o},V={ease:E(.25,.1,.25,1),"ease-in":E(.42,0,1,1),"ease-in-out":E(.42,0,.58,1),"ease-out":E(0,0,.58,1)},F=/\((.*?)\)/;function W(t){if("function"==typeof t)return t;if(Array.isArray(t))return E(...t);if(V[t])return V[t];if(t.startsWith("steps")){const e=F.exec(t);if(e){const t=e[1].split(",");return q(parseFloat(t[0]),t[1].trim())}}return f}function _(t,e){return l(t)?t[((t,e,n)=>{const a=e-t;return((n-t)%a+a)%a+t})(0,t.length,e)]:t}function U(t,e=m(t.length),n=f){const a=t.length,i=a-e.length;return i>0&&p(e,i),i=>{let r=0;for(;r<a-2&&!(i<e[r+1]);r++);let s=(o=d(e[r],e[r+1],i),Math.min(1,Math.max(o,0)));var o;return s=_(n,r)(s),u(t[r],t[r+1],s)}}class C{constructor(t,e=[0,1],{easing:n=r.easing,duration:a=r.duration,delay:i=r.delay,endDelay:s=r.endDelay,repeat:o=r.repeat,offset:u,direction:h="normal"}={}){if(this.startTime=null,this.rate=1,this.t=0,this.cancelTimestamp=null,this.playState="idle",this.finished=new Promise(((t,e)=>{this.resolve=t,this.reject=e})),c(n)){const t=n.createAnimation(e,(()=>"0"),!0);n=t.easing,void 0!==t.keyframes&&(e=t.keyframes),void 0!==t.duration&&(a=t.duration)}const f=a*(o+1),d=U(e,u,l(n)?n.map(W):W(n));this.tick=e=>{var n;this.pauseTime&&(e=this.pauseTime);let r=(e-this.startTime)*this.rate;this.t=r,r/=1e3,r=Math.max(r-i,0),"finished"===this.playState&&(r=f);const o=r/a;let c=Math.floor(o),l=o%1;!l&&o>=1&&(l=1),1===l&&c--;const u=c%2;("reverse"===h||"alternate"===h&&u||"alternate-reverse"===h&&!u)&&(l=1-l);const p=d(r>=f?1:Math.min(l,1));t(p);"finished"===this.playState||r>=f+s?(this.playState="finished",null===(n=this.resolve)||void 0===n||n.call(this,p)):"idle"!==this.playState&&(this.frameRequestId=requestAnimationFrame(this.tick))},this.play()}play(){var t;const e=performance.now();this.playState="running",this.pauseTime?this.startTime=e-(this.pauseTime-(null!==(t=this.startTime)&&void 0!==t?t:0)):this.startTime||(this.startTime=e),this.cancelTimestamp=this.startTime,this.pauseTime=void 0,requestAnimationFrame(this.tick)}pause(){this.playState="paused",this.pauseTime=performance.now()}finish(){this.playState="finished",this.tick(0)}stop(){var t;this.playState="idle",void 0!==this.frameRequestId&&cancelAnimationFrame(this.frameRequestId),null===(t=this.reject)||void 0===t||t.call(this,!1)}cancel(){this.stop(),this.tick(this.cancelTimestamp)}reverse(){this.rate*=-1}commitStyles(){}get currentTime(){return this.t}set currentTime(t){this.pauseTime||0===this.rate?this.pauseTime=t:this.startTime=performance.now()-t/this.rate}get playbackRate(){return this.rate}set playbackRate(t){this.rate=t}}const I=t=>(t=>Array.isArray(t)&&s(t[0]))(t)?B(t):t,B=([t,e,n,a])=>`cubic-bezier(${t}, ${e}, ${n}, ${a})`,z=t=>document.createElement("div").animate(t,{duration:.001}),K={cssRegisterProperty:()=>"undefined"!=typeof CSS&&Object.hasOwnProperty.call(CSS,"registerProperty"),waapi:()=>Object.hasOwnProperty.call(Element.prototype,"animate"),partialKeyframes:()=>{try{z({opacity:[1]})}catch(t){return!1}return!0},finished:()=>Boolean(z({opacity:[0,1]}).finished)},X={},Y={};for(const t in K)Y[t]=()=>(void 0===X[t]&&(X[t]=K[t]()),X[t]);const Z=t=>Array.isArray(t)?t:[t];function L(t){return b[t]&&(t=b[t]),j(t)?O(t):t}const N={get:(t,e)=>{e=L(e);let n=R(e)?t.style.getPropertyValue(e):getComputedStyle(t)[e];if(!n&&0!==n){const t=w.get(e);t&&(n=t.initialValue)}return n},set:(t,e,n)=>{e=L(e),R(e)?t.style.setProperty(e,n):t.style[e]=n}};function G(t,e=!0){if(t&&"finished"!==t.playState)try{t.stop?t.stop():(e&&t.commitStyles(),t.cancel())}catch(t){}}function H(t,n,i,o={}){const u=window.__MOTION_DEV_TOOLS_RECORD,f=!1!==o.record&&u;let d,{duration:p=r.duration,delay:m=r.delay,endDelay:y=r.endDelay,repeat:v=r.repeat,easing:M=r.easing,direction:T,offset:O,allowWebkitAcceleration:S=!1}=o;const x=a(t);let A=Y.waapi();const D=j(n);D&&((t,e)=>{b[e]&&(e=b[e]);const{transforms:n}=a(t);var i,r;r=e,-1===(i=n).indexOf(r)&&i.push(r),t.style.transform=k(n)})(t,n);const $=L(n),E=function(t,n){return t.has(n)||t.set(n,new e),t.get(n)}(x.values,$),q=w.get($);return G(E.animation,!(c(M)&&E.generator)&&!1!==o.record),()=>{const e=()=>{var e,n;return null!==(n=null!==(e=N.get(t,$))&&void 0!==e?e:null==q?void 0:q.initialValue)&&void 0!==n?n:0};let a=function(t,e){for(let n=0;n<t.length;n++)null===t[n]&&(t[n]=n?t[n-1]:e());return t}(Z(i),e);if(c(M)){const t=M.createAnimation(a,e,D,$,E);M=t.easing,void 0!==t.keyframes&&(a=t.keyframes),void 0!==t.duration&&(p=t.duration)}if(R($)&&(Y.cssRegisterProperty()?function(t){if(!P.has(t)){P.add(t);try{const{syntax:e,initialValue:n}=w.has(t)?w.get(t):{};CSS.registerProperty({name:t,inherits:!1,syntax:e,initialValue:n})}catch(t){}}}($):A=!1),A){q&&(a=a.map((t=>s(t)?q.toDefaultUnit(t):t))),1!==a.length||Y.partialKeyframes()&&!f||a.unshift(e());const n={delay:g(m),duration:g(p),endDelay:g(y),easing:l(M)?void 0:I(M),direction:T,iterations:v+1,fill:"both"};d=t.animate({[$]:a,offset:O,easing:l(M)?M.map(I):void 0},n),d.finished||(d.finished=new Promise(((t,e)=>{d.onfinish=t,d.oncancel=e})));const i=a[a.length-1];d.finished.then((()=>{N.set(t,$,i),d.cancel()})).catch(h),S||(d.playbackRate=1.000001)}else if(D){a=a.map((t=>"string"==typeof t?parseFloat(t):t)),1===a.length&&a.unshift(parseFloat(e()));d=new C((e=>{q&&(e=q.toDefaultUnit(e)),N.set(t,$,e)}),a,Object.assign(Object.assign({},o),{duration:p,easing:M}))}else{const e=a[a.length-1];N.set(t,$,q&&s(e)?q.toDefaultUnit(e):e)}return f&&u(t,n,a,{duration:p,delay:m,easing:M,repeat:v,offset:O},"motion-one"),E.setAnimation(d),d}}const J=(t,e)=>t[e]?Object.assign(Object.assign({},t),t[e]):Object.assign({},t);function Q(t,e){var n;return"string"==typeof t?e?(null!==(n=e[t])&&void 0!==n||(e[t]=document.querySelectorAll(t)),t=e[t]):t=document.querySelectorAll(t):t instanceof Element&&(t=[t]),Array.from(t)}const tt=t=>t(),et=(t,e=r.duration)=>new Proxy({animations:t.map(tt).filter(Boolean),duration:e},nt),nt={get:(t,e)=>{const n=t.animations[0];switch(e){case"duration":return t.duration;case"currentTime":let a=(null==n?void 0:n[e])||0;return a?a/1e3:0;case"playbackRate":case"playState":return null==n?void 0:n[e];case"finished":return t.finished||(t.finished=Promise.all(t.animations.map(at)).catch(h)),t.finished;case"stop":return()=>t.animations.forEach((t=>G(t)));default:return void 0===(null==n?void 0:n[e])?void 0:()=>t.animations.forEach((t=>t[e]()))}},set:(t,e,n)=>{switch(e){case"currentTime":n=g(n);case"currentTime":case"playbackRate":for(let a=0;a<t.animations.length;a++)t.animations[a][e]=n;return!0}return!1}},at=t=>t.finished;function it(t,e,n){return"function"==typeof t?t(e,n):t}function rt(t,e,n={}){const a=(t=Q(t)).length,i=[];for(let r=0;r<a;r++){const s=t[r];for(const t in e){const o=J(n,t);o.delay=it(o.delay,r,a);const c=H(s,t,e[t],o);i.push(c)}}return et(i,n.duration)}function st(t,e,n,a){var i;return s(e)?e:e.startsWith("-")||e.startsWith("+")?Math.max(0,t+parseFloat(e)):"<"===e?n:null!==(i=a.get(e))&&void 0!==i?i:t}function ot(t,e,n,a,r,s){!function(t,e,n){for(let a=0;a<t.length;a++){const r=t[a];r.at>e&&r.at<n&&(i(t,r),a--)}}(t,r,s);for(let i=0;i<e.length;i++)t.push({value:e[i],at:u(r,s,a[i]),easing:_(n,i)})}function ct(t,e){return t.at===e.at?null===t.value?1:-1:t.at-e.at}function lt(t,e){return!e.has(t)&&e.set(t,{}),e.get(t)}function ut(t,e){return e[t]||(e[t]=[]),e[t]}function ht(t,e,n){const a=Math.max(e-5,0);return i=n-t(a),(r=e-a)?i*(1e3/r):0;var i,r}const ft=100,dt=10,pt=1;const mt=({stiffness:t=ft,damping:e=dt,mass:n=pt,from:a=0,to:i=1,velocity:r=0,restSpeed:s=2,restDistance:o=.5}={})=>{r=r?y(r):0;const c={done:!1,hasReachedTarget:!1,current:a,target:i},l=i-a,u=Math.sqrt(t/n)/1e3,h=((t=ft,e=dt,n=pt)=>e/(2*Math.sqrt(t*n)))(t,e,n);let f;if(h<1){const t=u*Math.sqrt(1-h*h);f=e=>i-Math.exp(-h*u*e)*((h*u*l-r)/t*Math.sin(t*e)+l*Math.cos(t*e))}else f=t=>i-Math.exp(-u*t)*(l+(u*l-r)*t);return t=>{c.current=f(t);const e=0===t?r:ht(f,t,c.current),n=Math.abs(e)<=s,l=Math.abs(i-c.current)<=o;var u,h,d;return c.done=n&&l,c.hasReachedTarget=(u=a,h=i,d=c.current,u<h&&d>=h||u>h&&d<=h),c}};function gt(t){const e=new WeakMap;return(n={})=>{const a=new Map,i=(e=0,i=100,r=0,s=!1)=>{const o=`${e}-${i}-${r}-${s}`;return a.has(o)||a.set(o,t(Object.assign({from:e,to:i,velocity:r,restSpeed:s?.05:2,restDistance:s?.01:.5},n))),a.get(o)},r=t=>(e.has(t)||e.set(t,function(t){let e,n=10,a=t(0);const i=[a.current];for(;!a.done&&n<1e4;)a=t(n),i.push(a.done?a.target:a.current),void 0===e&&a.hasReachedTarget&&(e=n),n+=10;const r=n-10;return 1===i.length&&i.push(a.current),{keyframes:i,duration:r/1e3,overshootDuration:(null!=e?e:r)/1e3}}(t)),e.get(t));return{createAnimation:(t,e,n,a,s)=>{var o,c;let l;const u=t.length;if(n&&u<=2&&t.every(yt)){const n=t[u-1],h=1===u?null:t[0];let f=0,d=0;const p=null==s?void 0:s.generator;if(p){const{animation:e,generatorStartTime:n}=s,a=(null==e?void 0:e.startTime)||n||0,i=(null==e?void 0:e.currentTime)||performance.now()-a,r=p(i).current;d=null!==(o=h)&&void 0!==o?o:r,(1===u||2===u&&null===t[0])&&(f=ht((t=>p(t).current),i,r))}else d=null!==(c=h)&&void 0!==c?c:parseFloat(e());const m=i(d,n,f,null==a?void 0:a.includes("scale")),g=r(m);l=Object.assign(Object.assign({},g),{easing:"linear"}),s&&(s.generator=m,s.generatorStartTime=performance.now())}else{l={easing:"ease",duration:r(i(0,100)).overshootDuration}}return l}}}}const yt=t=>"string"!=typeof t,vt=gt(mt),bt=gt((({from:t=0,velocity:e=0,power:n=.8,decay:a=.325,bounceDamping:i,bounceStiffness:r,changeTarget:s,min:o,max:c,restDistance:l=.5,restSpeed:u})=>{a=g(a);const h={hasReachedTarget:!1,done:!1,current:t,target:t},f=t=>void 0===o?c:void 0===c||Math.abs(o-t)<Math.abs(c-t)?o:c;let d=n*e;const p=t+d,m=void 0===s?p:s(p);h.target=m,m!==p&&(d=m-t);const y=t=>-d*Math.exp(-t/a),v=t=>m+y(t),b=t=>{const e=y(t),n=v(t);h.done=Math.abs(e)<=l,h.current=h.done?m:n};let M,T;const w=t=>{var e;(e=h.current,void 0!==o&&e<o||void 0!==c&&e>c)&&(M=t,T=mt({from:h.current,to:f(h.current),velocity:ht(v,t,h.current),damping:i,stiffness:r,restDistance:l,restSpeed:u}))};return w(0),t=>{let e=!1;return T||void 0!==M||(e=!0,b(t),w(t)),void 0!==M&&t>M?(h.hasReachedTarget=!0,T(t-M)):(h.hasReachedTarget=!1,!e&&b(t),h)}}));function Mt(t,e){return et([()=>{const n=new C(t,[0,1],e);return n.finished.catch((()=>{})),n}],null==e?void 0:e.duration)}t.MotionValue=e,t.animate=function(t,e,n){return("function"==typeof t?Mt:rt)(t,e,n)},t.glide=bt,t.spring=vt,t.stagger=function(t=.1,{start:e=0,from:n=0,easing:a}={}){return(i,r)=>{const o=s(n)?n:function(t,e){if("first"===t)return 0;{const n=e-1;return"last"===t?n:n/2}}(n,r),c=Math.abs(o-i);let l=t*c;if(a){const e=r*t;l=W(a)(l/e)*e}return e+l}},t.style=N,t.timeline=function(t,e={}){var n;const a=function(t,e={}){var{defaultOptions:n={}}=e,a=function(t,e){var n={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&e.indexOf(a)<0&&(n[a]=t[a]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(t);i<a.length;i++)e.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(t,a[i])&&(n[a[i]]=t[a[i]])}return n}(e,["defaultOptions"]);const i=[],s=new Map,l={},u=new Map;let h=0,f=0,g=0;for(let e=0;e<t.length;e++){const a=t[e];if(o(a)){u.set(a,f);continue}if(!Array.isArray(a)){u.set(a.name,st(f,a.at,h,u));continue}const[i,d,y={}]=a;void 0!==y.at&&(f=st(f,y.at,h,u));let v=0;const b=Q(i,l),M=b.length;for(let t=0;t<M;t++){const e=lt(b[t],s);for(const a in d){const i=ut(a,e);let s=Z(d[a]);const o=J(y,a);let{duration:l=n.duration||r.duration,easing:u=n.easing||r.easing}=o;if(c(u)){const t=j(a);s.length;const e=u.createAnimation(s,(()=>"0"),t);u=e.easing,void 0!==e.keyframes&&(s=e.keyframes),void 0!==e.duration&&(l=e.duration)}const h=it(y.delay,t,M)||0,b=f+h,T=b+l;let{offset:w=m(s.length)}=o;1===w.length&&0===w[0]&&(w[1]=1);const O=length-s.length;O>0&&p(w,O),1===s.length&&s.unshift(null),ot(i,s,u,w,b,T),v=Math.max(h+l,v),g=Math.max(T,g)}}h=f,f+=v}return s.forEach(((t,e)=>{for(const s in t){const o=t[s];o.sort(ct);const c=[],l=[],u=[];for(let t=0;t<o.length;t++){const{at:e,value:n,easing:a}=o[t];c.push(n),l.push(d(0,g,e)),u.push(a||r.easing)}0!==l[0]&&(l.unshift(0),c.unshift(c[0]),u.unshift("linear")),1!==l[l.length-1]&&(l.push(1),c.push(null)),i.push([e,s,c,Object.assign(Object.assign(Object.assign({},n),{duration:g,easing:u,offset:l}),a)])}})),i}(t,e),i=a.map((t=>H(...t))).filter(Boolean);return et(i,null===(n=a[0])||void 0===n?void 0:n[3].duration)},Object.defineProperty(t,"__esModule",{value:!0})}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Motion={})}(this,(function(t){"use strict";class e{setAnimation(t){this.animation=t,null==t||t.finished.then((()=>this.clearAnimation())).catch((()=>{}))}clearAnimation(){this.animation=this.generator=void 0}}const n=new WeakMap;function a(t){return n.has(t)||n.set(t,{transforms:[],values:new Map}),n.get(t)}function i(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const r={duration:.3,delay:0,endDelay:0,repeat:0,easing:"ease"},s=t=>"number"==typeof t,o=t=>"string"==typeof t,c=t=>"object"==typeof t&&Boolean(t.createAnimation),l=t=>Array.isArray(t)&&!s(t[0]),u=(t,e,n)=>-n*t+n*e+t,h=()=>{},f=t=>t,d=(t,e,n)=>e-t==0?1:(n-t)/(e-t);function p(t,e){const n=t[t.length-1];for(let a=1;a<=e;a++){const i=d(0,e,a);t.push(u(n,1,i))}}function m(t){const e=[0];return p(e,t-1),e}const g=t=>1e3*t,y=t=>t/1e3;const v=["","X","Y","Z"],b={x:"translateX",y:"translateY",z:"translateZ"},M={syntax:"<angle>",initialValue:"0deg",toDefaultUnit:t=>t+"deg"},T={translate:{syntax:"<length-percentage>",initialValue:"0px",toDefaultUnit:t=>t+"px"},rotate:M,scale:{syntax:"<number>",initialValue:1,toDefaultUnit:f},skew:M},w=new Map,O=t=>`--motion-${t}`,S=["x","y","z"];["translate","scale","rotate","skew"].forEach((t=>{v.forEach((e=>{S.push(t+e),w.set(O(t+e),T[t])}))}));const x=(t,e)=>S.indexOf(t)-S.indexOf(e),A=new Set(S),j=t=>A.has(t),k=t=>t.sort(x).reduce(D,"").trim(),D=(t,e)=>`${t} ${e}(var(${O(e)}))`,R=t=>t.startsWith("--"),P=new Set;const $=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t;function E(t,e,n,a){if(t===e&&n===a)return f;const i=e=>function(t,e,n,a,i){let r,s,o=0;do{s=e+(n-e)/2,r=$(s,a,i)-t,r>0?n=s:e=s}while(Math.abs(r)>1e-7&&++o<12);return s}(e,0,1,t,n);return t=>0===t||1===t?t:$(i(t),e,a)}const q=(t,e="end")=>n=>{const a=(n="end"===e?Math.min(n,.999):Math.max(n,.001))*t,i="end"===e?Math.floor(a):Math.ceil(a);return r=0,s=1,o=i/t,Math.min(Math.max(o,r),s);var r,s,o},V={ease:E(.25,.1,.25,1),"ease-in":E(.42,0,1,1),"ease-in-out":E(.42,0,.58,1),"ease-out":E(0,0,.58,1)},F=/\((.*?)\)/;function W(t){if("function"==typeof t)return t;if(Array.isArray(t))return E(...t);if(V[t])return V[t];if(t.startsWith("steps")){const e=F.exec(t);if(e){const t=e[1].split(",");return q(parseFloat(t[0]),t[1].trim())}}return f}function _(t,e){return l(t)?t[((t,e,n)=>{const a=e-t;return((n-t)%a+a)%a+t})(0,t.length,e)]:t}function U(t,e=m(t.length),n=f){const a=t.length,i=a-e.length;return i>0&&p(e,i),i=>{let r=0;for(;r<a-2&&!(i<e[r+1]);r++);let s=(o=d(e[r],e[r+1],i),Math.min(1,Math.max(o,0)));var o;return s=_(n,r)(s),u(t[r],t[r+1],s)}}class C{constructor(t,e=[0,1],{easing:n=r.easing,duration:a=r.duration,delay:i=r.delay,endDelay:s=r.endDelay,repeat:o=r.repeat,offset:u,direction:h="normal"}={}){if(this.startTime=null,this.rate=1,this.t=0,this.cancelTimestamp=null,this.playState="idle",this.finished=new Promise(((t,e)=>{this.resolve=t,this.reject=e})),c(n)){const t=n.createAnimation(e,(()=>"0"),!0);n=t.easing,void 0!==t.keyframes&&(e=t.keyframes),void 0!==t.duration&&(a=t.duration)}const d=l(n)?f:W(n),p=a*(o+1),m=U(e,u,l(n)?n.map(W):f);this.tick=e=>{var n;this.pauseTime&&(e=this.pauseTime);let r=(e-this.startTime)*this.rate;this.t=r,r/=1e3,r=Math.max(r-i,0),"finished"===this.playState&&(r=p);const o=r/a;let c=Math.floor(o),l=o%1;!l&&o>=1&&(l=1),1===l&&c--;const u=c%2;("reverse"===h||"alternate"===h&&u||"alternate-reverse"===h&&!u)&&(l=1-l);const f=r>=p?1:Math.min(l,1),g=m(d(f));t(g);"finished"===this.playState||r>=p+s?(this.playState="finished",null===(n=this.resolve)||void 0===n||n.call(this,g)):"idle"!==this.playState&&(this.frameRequestId=requestAnimationFrame(this.tick))},this.play()}play(){var t;const e=performance.now();this.playState="running",this.pauseTime?this.startTime=e-(this.pauseTime-(null!==(t=this.startTime)&&void 0!==t?t:0)):this.startTime||(this.startTime=e),this.cancelTimestamp=this.startTime,this.pauseTime=void 0,requestAnimationFrame(this.tick)}pause(){this.playState="paused",this.pauseTime=performance.now()}finish(){this.playState="finished",this.tick(0)}stop(){var t;this.playState="idle",void 0!==this.frameRequestId&&cancelAnimationFrame(this.frameRequestId),null===(t=this.reject)||void 0===t||t.call(this,!1)}cancel(){this.stop(),this.tick(this.cancelTimestamp)}reverse(){this.rate*=-1}commitStyles(){}get currentTime(){return this.t}set currentTime(t){this.pauseTime||0===this.rate?this.pauseTime=t:this.startTime=performance.now()-t/this.rate}get playbackRate(){return this.rate}set playbackRate(t){this.rate=t}}const I=t=>(t=>Array.isArray(t)&&s(t[0]))(t)?B(t):t,B=([t,e,n,a])=>`cubic-bezier(${t}, ${e}, ${n}, ${a})`,z=t=>document.createElement("div").animate(t,{duration:.001}),K={cssRegisterProperty:()=>"undefined"!=typeof CSS&&Object.hasOwnProperty.call(CSS,"registerProperty"),waapi:()=>Object.hasOwnProperty.call(Element.prototype,"animate"),partialKeyframes:()=>{try{z({opacity:[1]})}catch(t){return!1}return!0},finished:()=>Boolean(z({opacity:[0,1]}).finished)},X={},Y={};for(const t in K)Y[t]=()=>(void 0===X[t]&&(X[t]=K[t]()),X[t]);const Z=t=>Array.isArray(t)?t:[t];function L(t){return b[t]&&(t=b[t]),j(t)?O(t):t}const N={get:(t,e)=>{e=L(e);let n=R(e)?t.style.getPropertyValue(e):getComputedStyle(t)[e];if(!n&&0!==n){const t=w.get(e);t&&(n=t.initialValue)}return n},set:(t,e,n)=>{e=L(e),R(e)?t.style.setProperty(e,n):t.style[e]=n}};function G(t,e=!0){if(t&&"finished"!==t.playState)try{t.stop?t.stop():(e&&t.commitStyles(),t.cancel())}catch(t){}}function H(t,n,i,o={}){const u=window.__MOTION_DEV_TOOLS_RECORD,f=!1!==o.record&&u;let d,{duration:p=r.duration,delay:m=r.delay,endDelay:y=r.endDelay,repeat:v=r.repeat,easing:M=r.easing,direction:T,offset:O,allowWebkitAcceleration:S=!1}=o;const x=a(t);let A=Y.waapi();const D=j(n);D&&((t,e)=>{b[e]&&(e=b[e]);const{transforms:n}=a(t);var i,r;r=e,-1===(i=n).indexOf(r)&&i.push(r),t.style.transform=k(n)})(t,n);const $=L(n),E=function(t,n){return t.has(n)||t.set(n,new e),t.get(n)}(x.values,$),q=w.get($);return G(E.animation,!(c(M)&&E.generator)&&!1!==o.record),()=>{const e=()=>{var e,n;return null!==(n=null!==(e=N.get(t,$))&&void 0!==e?e:null==q?void 0:q.initialValue)&&void 0!==n?n:0};let a=function(t,e){for(let n=0;n<t.length;n++)null===t[n]&&(t[n]=n?t[n-1]:e());return t}(Z(i),e);if(c(M)){const t=M.createAnimation(a,e,D,$,E);M=t.easing,void 0!==t.keyframes&&(a=t.keyframes),void 0!==t.duration&&(p=t.duration)}if(R($)&&(Y.cssRegisterProperty()?function(t){if(!P.has(t)){P.add(t);try{const{syntax:e,initialValue:n}=w.has(t)?w.get(t):{};CSS.registerProperty({name:t,inherits:!1,syntax:e,initialValue:n})}catch(t){}}}($):A=!1),A){q&&(a=a.map((t=>s(t)?q.toDefaultUnit(t):t))),1!==a.length||Y.partialKeyframes()&&!f||a.unshift(e());const n={delay:g(m),duration:g(p),endDelay:g(y),easing:l(M)?void 0:I(M),direction:T,iterations:v+1,fill:"both"};d=t.animate({[$]:a,offset:O,easing:l(M)?M.map(I):void 0},n),d.finished||(d.finished=new Promise(((t,e)=>{d.onfinish=t,d.oncancel=e})));const i=a[a.length-1];d.finished.then((()=>{N.set(t,$,i),d.cancel()})).catch(h),S||(d.playbackRate=1.000001)}else if(D){a=a.map((t=>"string"==typeof t?parseFloat(t):t)),1===a.length&&a.unshift(parseFloat(e()));d=new C((e=>{q&&(e=q.toDefaultUnit(e)),N.set(t,$,e)}),a,Object.assign(Object.assign({},o),{duration:p,easing:M}))}else{const e=a[a.length-1];N.set(t,$,q&&s(e)?q.toDefaultUnit(e):e)}return f&&u(t,n,a,{duration:p,delay:m,easing:M,repeat:v,offset:O},"motion-one"),E.setAnimation(d),d}}const J=(t,e)=>t[e]?Object.assign(Object.assign({},t),t[e]):Object.assign({},t);function Q(t,e){var n;return"string"==typeof t?e?(null!==(n=e[t])&&void 0!==n||(e[t]=document.querySelectorAll(t)),t=e[t]):t=document.querySelectorAll(t):t instanceof Element&&(t=[t]),Array.from(t)}const tt=t=>t(),et=(t,e=r.duration)=>new Proxy({animations:t.map(tt).filter(Boolean),duration:e},nt),nt={get:(t,e)=>{const n=t.animations[0];switch(e){case"duration":return t.duration;case"currentTime":let a=(null==n?void 0:n[e])||0;return a?a/1e3:0;case"playbackRate":case"playState":return null==n?void 0:n[e];case"finished":return t.finished||(t.finished=Promise.all(t.animations.map(at)).catch(h)),t.finished;case"stop":return()=>t.animations.forEach((t=>G(t)));default:return void 0===(null==n?void 0:n[e])?void 0:()=>t.animations.forEach((t=>t[e]()))}},set:(t,e,n)=>{switch(e){case"currentTime":n=g(n);case"currentTime":case"playbackRate":for(let a=0;a<t.animations.length;a++)t.animations[a][e]=n;return!0}return!1}},at=t=>t.finished;function it(t,e,n){return"function"==typeof t?t(e,n):t}function rt(t,e,n={}){const a=(t=Q(t)).length,i=[];for(let r=0;r<a;r++){const s=t[r];for(const t in e){const o=J(n,t);o.delay=it(o.delay,r,a);const c=H(s,t,e[t],o);i.push(c)}}return et(i,n.duration)}function st(t,e,n,a){var i;return s(e)?e:e.startsWith("-")||e.startsWith("+")?Math.max(0,t+parseFloat(e)):"<"===e?n:null!==(i=a.get(e))&&void 0!==i?i:t}function ot(t,e,n,a,r,s){!function(t,e,n){for(let a=0;a<t.length;a++){const r=t[a];r.at>e&&r.at<n&&(i(t,r),a--)}}(t,r,s);for(let i=0;i<e.length;i++)t.push({value:e[i],at:u(r,s,a[i]),easing:_(n,i)})}function ct(t,e){return t.at===e.at?null===t.value?1:-1:t.at-e.at}function lt(t,e){return!e.has(t)&&e.set(t,{}),e.get(t)}function ut(t,e){return e[t]||(e[t]=[]),e[t]}function ht(t,e,n){const a=Math.max(e-5,0);return i=n-t(a),(r=e-a)?i*(1e3/r):0;var i,r}const ft=100,dt=10,pt=1;const mt=({stiffness:t=ft,damping:e=dt,mass:n=pt,from:a=0,to:i=1,velocity:r=0,restSpeed:s=2,restDistance:o=.5}={})=>{r=r?y(r):0;const c={done:!1,hasReachedTarget:!1,current:a,target:i},l=i-a,u=Math.sqrt(t/n)/1e3,h=((t=ft,e=dt,n=pt)=>e/(2*Math.sqrt(t*n)))(t,e,n);let f;if(h<1){const t=u*Math.sqrt(1-h*h);f=e=>i-Math.exp(-h*u*e)*((h*u*l-r)/t*Math.sin(t*e)+l*Math.cos(t*e))}else f=t=>i-Math.exp(-u*t)*(l+(u*l-r)*t);return t=>{c.current=f(t);const e=0===t?r:ht(f,t,c.current),n=Math.abs(e)<=s,l=Math.abs(i-c.current)<=o;var u,h,d;return c.done=n&&l,c.hasReachedTarget=(u=a,h=i,d=c.current,u<h&&d>=h||u>h&&d<=h),c}};function gt(t){const e=new WeakMap;return(n={})=>{const a=new Map,i=(e=0,i=100,r=0,s=!1)=>{const o=`${e}-${i}-${r}-${s}`;return a.has(o)||a.set(o,t(Object.assign({from:e,to:i,velocity:r,restSpeed:s?.05:2,restDistance:s?.01:.5},n))),a.get(o)},r=t=>(e.has(t)||e.set(t,function(t){let e,n=10,a=t(0);const i=[a.current];for(;!a.done&&n<1e4;)a=t(n),i.push(a.done?a.target:a.current),void 0===e&&a.hasReachedTarget&&(e=n),n+=10;const r=n-10;return 1===i.length&&i.push(a.current),{keyframes:i,duration:r/1e3,overshootDuration:(null!=e?e:r)/1e3}}(t)),e.get(t));return{createAnimation:(t,e,n,a,s)=>{var o,c;let l;const u=t.length;if(n&&u<=2&&t.every(yt)){const n=t[u-1],h=1===u?null:t[0];let f=0,d=0;const p=null==s?void 0:s.generator;if(p){const{animation:e,generatorStartTime:n}=s,a=(null==e?void 0:e.startTime)||n||0,i=(null==e?void 0:e.currentTime)||performance.now()-a,r=p(i).current;d=null!==(o=h)&&void 0!==o?o:r,(1===u||2===u&&null===t[0])&&(f=ht((t=>p(t).current),i,r))}else d=null!==(c=h)&&void 0!==c?c:parseFloat(e());const m=i(d,n,f,null==a?void 0:a.includes("scale")),g=r(m);l=Object.assign(Object.assign({},g),{easing:"linear"}),s&&(s.generator=m,s.generatorStartTime=performance.now())}else{l={easing:"ease",duration:r(i(0,100)).overshootDuration}}return l}}}}const yt=t=>"string"!=typeof t,vt=gt(mt),bt=gt((({from:t=0,velocity:e=0,power:n=.8,decay:a=.325,bounceDamping:i,bounceStiffness:r,changeTarget:s,min:o,max:c,restDistance:l=.5,restSpeed:u})=>{a=g(a);const h={hasReachedTarget:!1,done:!1,current:t,target:t},f=t=>void 0===o?c:void 0===c||Math.abs(o-t)<Math.abs(c-t)?o:c;let d=n*e;const p=t+d,m=void 0===s?p:s(p);h.target=m,m!==p&&(d=m-t);const y=t=>-d*Math.exp(-t/a),v=t=>m+y(t),b=t=>{const e=y(t),n=v(t);h.done=Math.abs(e)<=l,h.current=h.done?m:n};let M,T;const w=t=>{var e;(e=h.current,void 0!==o&&e<o||void 0!==c&&e>c)&&(M=t,T=mt({from:h.current,to:f(h.current),velocity:ht(v,t,h.current),damping:i,stiffness:r,restDistance:l,restSpeed:u}))};return w(0),t=>{let e=!1;return T||void 0!==M||(e=!0,b(t),w(t)),void 0!==M&&t>M?(h.hasReachedTarget=!0,T(t-M)):(h.hasReachedTarget=!1,!e&&b(t),h)}}));function Mt(t,e){return et([()=>{const n=new C(t,[0,1],e);return n.finished.catch((()=>{})),n}],null==e?void 0:e.duration)}t.MotionValue=e,t.animate=function(t,e,n){return("function"==typeof t?Mt:rt)(t,e,n)},t.glide=bt,t.spring=vt,t.stagger=function(t=.1,{start:e=0,from:n=0,easing:a}={}){return(i,r)=>{const o=s(n)?n:function(t,e){if("first"===t)return 0;{const n=e-1;return"last"===t?n:n/2}}(n,r),c=Math.abs(o-i);let l=t*c;if(a){const e=r*t;l=W(a)(l/e)*e}return e+l}},t.style=N,t.timeline=function(t,e={}){var n;const a=function(t,e={}){var{defaultOptions:n={}}=e,a=function(t,e){var n={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&e.indexOf(a)<0&&(n[a]=t[a]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(t);i<a.length;i++)e.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(t,a[i])&&(n[a[i]]=t[a[i]])}return n}(e,["defaultOptions"]);const i=[],s=new Map,l={},u=new Map;let h=0,f=0,g=0;for(let e=0;e<t.length;e++){const a=t[e];if(o(a)){u.set(a,f);continue}if(!Array.isArray(a)){u.set(a.name,st(f,a.at,h,u));continue}const[i,d,y={}]=a;void 0!==y.at&&(f=st(f,y.at,h,u));let v=0;const b=Q(i,l),M=b.length;for(let t=0;t<M;t++){const e=lt(b[t],s);for(const a in d){const i=ut(a,e);let s=Z(d[a]);const o=J(y,a);let{duration:l=n.duration||r.duration,easing:u=n.easing||r.easing}=o;if(c(u)){const t=j(a);s.length;const e=u.createAnimation(s,(()=>"0"),t);u=e.easing,void 0!==e.keyframes&&(s=e.keyframes),void 0!==e.duration&&(l=e.duration)}const h=it(y.delay,t,M)||0,b=f+h,T=b+l;let{offset:w=m(s.length)}=o;1===w.length&&0===w[0]&&(w[1]=1);const O=length-s.length;O>0&&p(w,O),1===s.length&&s.unshift(null),ot(i,s,u,w,b,T),v=Math.max(h+l,v),g=Math.max(T,g)}}h=f,f+=v}return s.forEach(((t,e)=>{for(const s in t){const o=t[s];o.sort(ct);const c=[],l=[],u=[];for(let t=0;t<o.length;t++){const{at:e,value:n,easing:a}=o[t];c.push(n),l.push(d(0,g,e)),u.push(a||r.easing)}0!==l[0]&&(l.unshift(0),c.unshift(c[0]),u.unshift("linear")),1!==l[l.length-1]&&(l.push(1),c.push(null)),i.push([e,s,c,Object.assign(Object.assign(Object.assign({},n),{duration:g,easing:u,offset:l}),a)])}})),i}(t,e),i=a.map((t=>H(...t))).filter(Boolean);return et(i,null===(n=a[0])||void 0===n?void 0:n[3].duration)},Object.defineProperty(t,"__esModule",{value:!0})}));
@@ -331,10 +331,11 @@
331
331
  if (custom.duration !== undefined)
332
332
  duration = custom.duration;
333
333
  }
334
+ const animationEasing = isEasingList(easing)
335
+ ? noopReturn
336
+ : getEasingFunction(easing);
334
337
  const totalDuration = duration * (repeat + 1);
335
- const interpolate$1 = interpolate(keyframes, offset, isEasingList(easing)
336
- ? easing.map(getEasingFunction)
337
- : getEasingFunction(easing));
338
+ const interpolate$1 = interpolate(keyframes, offset, isEasingList(easing) ? easing.map(getEasingFunction) : noopReturn);
338
339
  this.tick = (timestamp) => {
339
340
  var _a;
340
341
  // TODO: Temporary fix for OptionsResolver typing
@@ -387,7 +388,8 @@
387
388
  (direction === "alternate-reverse" && !iterationIsOdd)) {
388
389
  iterationProgress = 1 - iterationProgress;
389
390
  }
390
- const latest = interpolate$1(t >= totalDuration ? 1 : Math.min(iterationProgress, 1));
391
+ const p = t >= totalDuration ? 1 : Math.min(iterationProgress, 1);
392
+ const latest = interpolate$1(animationEasing(p));
391
393
  output(latest);
392
394
  const isAnimationFinished = this.playState === "finished" || t >= totalDuration + endDelay;
393
395
  if (isAnimationFinished) {
@@ -1 +1 @@
1
- class t{setAnimation(t){this.animation=t,null==t||t.finished.then((()=>this.clearAnimation())).catch((()=>{}))}clearAnimation(){this.animation=this.generator=void 0}}const e=new WeakMap;function n(t){return e.has(t)||e.set(t,{transforms:[],values:new Map}),e.get(t)}function a(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const i={duration:.3,delay:0,endDelay:0,repeat:0,easing:"ease"},r=t=>"number"==typeof t,s=t=>"string"==typeof t,o=t=>"object"==typeof t&&Boolean(t.createAnimation),c=t=>Array.isArray(t)&&!r(t[0]),l=(t,e,n)=>-n*t+n*e+t,u=()=>{},h=t=>t,f=(t,e,n)=>e-t==0?1:(n-t)/(e-t);function d(t,e){const n=t[t.length-1];for(let a=1;a<=e;a++){const i=f(0,e,a);t.push(l(n,1,i))}}function m(t){const e=[0];return d(e,t-1),e}const p=t=>1e3*t,g=t=>t/1e3;const y=["","X","Y","Z"],v={x:"translateX",y:"translateY",z:"translateZ"},b={syntax:"<angle>",initialValue:"0deg",toDefaultUnit:t=>t+"deg"},w={translate:{syntax:"<length-percentage>",initialValue:"0px",toDefaultUnit:t=>t+"px"},rotate:b,scale:{syntax:"<number>",initialValue:1,toDefaultUnit:h},skew:b},M=new Map,T=t=>`--motion-${t}`,O=["x","y","z"];["translate","scale","rotate","skew"].forEach((t=>{y.forEach((e=>{O.push(t+e),M.set(T(t+e),w[t])}))}));const S=(t,e)=>O.indexOf(t)-O.indexOf(e),x=new Set(O),A=t=>x.has(t),k=t=>t.sort(S).reduce(D,"").trim(),D=(t,e)=>`${t} ${e}(var(${T(e)}))`,j=t=>t.startsWith("--"),R=new Set;const P=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t;function E(t,e,n,a){if(t===e&&n===a)return h;const i=e=>function(t,e,n,a,i){let r,s,o=0;do{s=e+(n-e)/2,r=P(s,a,i)-t,r>0?n=s:e=s}while(Math.abs(r)>1e-7&&++o<12);return s}(e,0,1,t,n);return t=>0===t||1===t?t:P(i(t),e,a)}const $=(t,e="end")=>n=>{const a=(n="end"===e?Math.min(n,.999):Math.max(n,.001))*t,i="end"===e?Math.floor(a):Math.ceil(a);return r=0,s=1,o=i/t,Math.min(Math.max(o,r),s);var r,s,o},q={ease:E(.25,.1,.25,1),"ease-in":E(.42,0,1,1),"ease-in-out":E(.42,0,.58,1),"ease-out":E(0,0,.58,1)},V=/\((.*?)\)/;function F(t){if("function"==typeof t)return t;if(Array.isArray(t))return E(...t);if(q[t])return q[t];if(t.startsWith("steps")){const e=V.exec(t);if(e){const t=e[1].split(",");return $(parseFloat(t[0]),t[1].trim())}}return h}function W(t,e){return c(t)?t[((t,e,n)=>{const a=e-t;return((n-t)%a+a)%a+t})(0,t.length,e)]:t}function U(t,e=m(t.length),n=h){const a=t.length,i=a-e.length;return i>0&&d(e,i),i=>{let r=0;for(;r<a-2&&!(i<e[r+1]);r++);let s=(o=f(e[r],e[r+1],i),Math.min(1,Math.max(o,0)));var o;return s=W(n,r)(s),l(t[r],t[r+1],s)}}class _{constructor(t,e=[0,1],{easing:n=i.easing,duration:a=i.duration,delay:r=i.delay,endDelay:s=i.endDelay,repeat:l=i.repeat,offset:u,direction:h="normal"}={}){if(this.startTime=null,this.rate=1,this.t=0,this.cancelTimestamp=null,this.playState="idle",this.finished=new Promise(((t,e)=>{this.resolve=t,this.reject=e})),o(n)){const t=n.createAnimation(e,(()=>"0"),!0);n=t.easing,void 0!==t.keyframes&&(e=t.keyframes),void 0!==t.duration&&(a=t.duration)}const f=a*(l+1),d=U(e,u,c(n)?n.map(F):F(n));this.tick=e=>{var n;this.pauseTime&&(e=this.pauseTime);let i=(e-this.startTime)*this.rate;this.t=i,i/=1e3,i=Math.max(i-r,0),"finished"===this.playState&&(i=f);const o=i/a;let c=Math.floor(o),l=o%1;!l&&o>=1&&(l=1),1===l&&c--;const u=c%2;("reverse"===h||"alternate"===h&&u||"alternate-reverse"===h&&!u)&&(l=1-l);const m=d(i>=f?1:Math.min(l,1));t(m);"finished"===this.playState||i>=f+s?(this.playState="finished",null===(n=this.resolve)||void 0===n||n.call(this,m)):"idle"!==this.playState&&(this.frameRequestId=requestAnimationFrame(this.tick))},this.play()}play(){var t;const e=performance.now();this.playState="running",this.pauseTime?this.startTime=e-(this.pauseTime-(null!==(t=this.startTime)&&void 0!==t?t:0)):this.startTime||(this.startTime=e),this.cancelTimestamp=this.startTime,this.pauseTime=void 0,requestAnimationFrame(this.tick)}pause(){this.playState="paused",this.pauseTime=performance.now()}finish(){this.playState="finished",this.tick(0)}stop(){var t;this.playState="idle",void 0!==this.frameRequestId&&cancelAnimationFrame(this.frameRequestId),null===(t=this.reject)||void 0===t||t.call(this,!1)}cancel(){this.stop(),this.tick(this.cancelTimestamp)}reverse(){this.rate*=-1}commitStyles(){}get currentTime(){return this.t}set currentTime(t){this.pauseTime||0===this.rate?this.pauseTime=t:this.startTime=performance.now()-t/this.rate}get playbackRate(){return this.rate}set playbackRate(t){this.rate=t}}const C=t=>(t=>Array.isArray(t)&&r(t[0]))(t)?I(t):t,I=([t,e,n,a])=>`cubic-bezier(${t}, ${e}, ${n}, ${a})`,B=t=>document.createElement("div").animate(t,{duration:.001}),z={cssRegisterProperty:()=>"undefined"!=typeof CSS&&Object.hasOwnProperty.call(CSS,"registerProperty"),waapi:()=>Object.hasOwnProperty.call(Element.prototype,"animate"),partialKeyframes:()=>{try{B({opacity:[1]})}catch(t){return!1}return!0},finished:()=>Boolean(B({opacity:[0,1]}).finished)},N={},K={};for(const t in z)K[t]=()=>(void 0===N[t]&&(N[t]=z[t]()),N[t]);const X=t=>Array.isArray(t)?t:[t];function Y(t){return v[t]&&(t=v[t]),A(t)?T(t):t}const Z={get:(t,e)=>{e=Y(e);let n=j(e)?t.style.getPropertyValue(e):getComputedStyle(t)[e];if(!n&&0!==n){const t=M.get(e);t&&(n=t.initialValue)}return n},set:(t,e,n)=>{e=Y(e),j(e)?t.style.setProperty(e,n):t.style[e]=n}};function L(t,e=!0){if(t&&"finished"!==t.playState)try{t.stop?t.stop():(e&&t.commitStyles(),t.cancel())}catch(t){}}function G(e,a,s,l={}){const h=window.__MOTION_DEV_TOOLS_RECORD,f=!1!==l.record&&h;let d,{duration:m=i.duration,delay:g=i.delay,endDelay:y=i.endDelay,repeat:b=i.repeat,easing:w=i.easing,direction:T,offset:O,allowWebkitAcceleration:S=!1}=l;const x=n(e);let D=K.waapi();const P=A(a);P&&((t,e)=>{v[e]&&(e=v[e]);const{transforms:a}=n(t);var i,r;r=e,-1===(i=a).indexOf(r)&&i.push(r),t.style.transform=k(a)})(e,a);const E=Y(a),$=function(e,n){return e.has(n)||e.set(n,new t),e.get(n)}(x.values,E),q=M.get(E);return L($.animation,!(o(w)&&$.generator)&&!1!==l.record),()=>{const t=()=>{var t,n;return null!==(n=null!==(t=Z.get(e,E))&&void 0!==t?t:null==q?void 0:q.initialValue)&&void 0!==n?n:0};let n=function(t,e){for(let n=0;n<t.length;n++)null===t[n]&&(t[n]=n?t[n-1]:e());return t}(X(s),t);if(o(w)){const e=w.createAnimation(n,t,P,E,$);w=e.easing,void 0!==e.keyframes&&(n=e.keyframes),void 0!==e.duration&&(m=e.duration)}if(j(E)&&(K.cssRegisterProperty()?function(t){if(!R.has(t)){R.add(t);try{const{syntax:e,initialValue:n}=M.has(t)?M.get(t):{};CSS.registerProperty({name:t,inherits:!1,syntax:e,initialValue:n})}catch(t){}}}(E):D=!1),D){q&&(n=n.map((t=>r(t)?q.toDefaultUnit(t):t))),1!==n.length||K.partialKeyframes()&&!f||n.unshift(t());const a={delay:p(g),duration:p(m),endDelay:p(y),easing:c(w)?void 0:C(w),direction:T,iterations:b+1,fill:"both"};d=e.animate({[E]:n,offset:O,easing:c(w)?w.map(C):void 0},a),d.finished||(d.finished=new Promise(((t,e)=>{d.onfinish=t,d.oncancel=e})));const i=n[n.length-1];d.finished.then((()=>{Z.set(e,E,i),d.cancel()})).catch(u),S||(d.playbackRate=1.000001)}else if(P){n=n.map((t=>"string"==typeof t?parseFloat(t):t)),1===n.length&&n.unshift(parseFloat(t()));d=new _((t=>{q&&(t=q.toDefaultUnit(t)),Z.set(e,E,t)}),n,Object.assign(Object.assign({},l),{duration:m,easing:w}))}else{const t=n[n.length-1];Z.set(e,E,q&&r(t)?q.toDefaultUnit(t):t)}return f&&h(e,a,n,{duration:m,delay:g,easing:w,repeat:b,offset:O},"motion-one"),$.setAnimation(d),d}}const H=(t,e)=>t[e]?Object.assign(Object.assign({},t),t[e]):Object.assign({},t);function J(t,e){var n;return"string"==typeof t?e?(null!==(n=e[t])&&void 0!==n||(e[t]=document.querySelectorAll(t)),t=e[t]):t=document.querySelectorAll(t):t instanceof Element&&(t=[t]),Array.from(t)}const Q=t=>t(),tt=(t,e=i.duration)=>new Proxy({animations:t.map(Q).filter(Boolean),duration:e},et),et={get:(t,e)=>{const n=t.animations[0];switch(e){case"duration":return t.duration;case"currentTime":let a=(null==n?void 0:n[e])||0;return a?a/1e3:0;case"playbackRate":case"playState":return null==n?void 0:n[e];case"finished":return t.finished||(t.finished=Promise.all(t.animations.map(nt)).catch(u)),t.finished;case"stop":return()=>t.animations.forEach((t=>L(t)));default:return void 0===(null==n?void 0:n[e])?void 0:()=>t.animations.forEach((t=>t[e]()))}},set:(t,e,n)=>{switch(e){case"currentTime":n=p(n);case"currentTime":case"playbackRate":for(let a=0;a<t.animations.length;a++)t.animations[a][e]=n;return!0}return!1}},nt=t=>t.finished;function at(t=.1,{start:e=0,from:n=0,easing:a}={}){return(i,s)=>{const o=r(n)?n:function(t,e){if("first"===t)return 0;{const n=e-1;return"last"===t?n:n/2}}(n,s),c=Math.abs(o-i);let l=t*c;if(a){const e=s*t;l=F(a)(l/e)*e}return e+l}}function it(t,e,n){return"function"==typeof t?t(e,n):t}function rt(t,e,n={}){const a=(t=J(t)).length,i=[];for(let r=0;r<a;r++){const s=t[r];for(const t in e){const o=H(n,t);o.delay=it(o.delay,r,a);const c=G(s,t,e[t],o);i.push(c)}}return tt(i,n.duration)}var st=function(){};function ot(t,e,n,a){var i;return r(e)?e:e.startsWith("-")||e.startsWith("+")?Math.max(0,t+parseFloat(e)):"<"===e?n:null!==(i=a.get(e))&&void 0!==i?i:t}function ct(t,e,n,i,r,s){!function(t,e,n){for(let i=0;i<t.length;i++){const r=t[i];r.at>e&&r.at<n&&(a(t,r),i--)}}(t,r,s);for(let a=0;a<e.length;a++)t.push({value:e[a],at:l(r,s,i[a]),easing:W(n,a)})}function lt(t,e){return t.at===e.at?null===t.value?1:-1:t.at-e.at}function ut(t,e={}){var n;const a=function(t,e={}){var{defaultOptions:n={}}=e,a=function(t,e){var n={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&e.indexOf(a)<0&&(n[a]=t[a]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(t);i<a.length;i++)e.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(t,a[i])&&(n[a[i]]=t[a[i]])}return n}(e,["defaultOptions"]);const r=[],c=new Map,l={},u=new Map;let h=0,p=0,g=0;for(let e=0;e<t.length;e++){const a=t[e];if(s(a)){u.set(a,p);continue}if(!Array.isArray(a)){u.set(a.name,ot(p,a.at,h,u));continue}const[r,f,y={}]=a;void 0!==y.at&&(p=ot(p,y.at,h,u));let v=0;const b=J(r,l),w=b.length;for(let t=0;t<w;t++){const e=ht(b[t],c);for(const a in f){const r=ft(a,e);let s=X(f[a]);const c=H(y,a);let{duration:l=n.duration||i.duration,easing:u=n.easing||i.easing}=c;if(o(u)){const t=A(a);st(2===s.length||!t,"spring must be provided 2 keyframes within timeline");const e=u.createAnimation(s,(()=>"0"),t);u=e.easing,void 0!==e.keyframes&&(s=e.keyframes),void 0!==e.duration&&(l=e.duration)}const h=it(y.delay,t,w)||0,b=p+h,M=b+l;let{offset:T=m(s.length)}=c;1===T.length&&0===T[0]&&(T[1]=1);const O=length-s.length;O>0&&d(T,O),1===s.length&&s.unshift(null),ct(r,s,u,T,b,M),v=Math.max(h+l,v),g=Math.max(M,g)}}h=p,p+=v}return c.forEach(((t,e)=>{for(const s in t){const o=t[s];o.sort(lt);const c=[],l=[],u=[];for(let t=0;t<o.length;t++){const{at:e,value:n,easing:a}=o[t];c.push(n),l.push(f(0,g,e)),u.push(a||i.easing)}0!==l[0]&&(l.unshift(0),c.unshift(c[0]),u.unshift("linear")),1!==l[l.length-1]&&(l.push(1),c.push(null)),r.push([e,s,c,Object.assign(Object.assign(Object.assign({},n),{duration:g,easing:u,offset:l}),a)])}})),r}(t,e),r=a.map((t=>G(...t))).filter(Boolean);return tt(r,null===(n=a[0])||void 0===n?void 0:n[3].duration)}function ht(t,e){return!e.has(t)&&e.set(t,{}),e.get(t)}function ft(t,e){return e[t]||(e[t]=[]),e[t]}"production"!==process.env.NODE_ENV&&(st=function(t,e){if(!t)throw new Error(e)});function dt(t,e,n){const a=Math.max(e-5,0);return i=n-t(a),(r=e-a)?i*(1e3/r):0;var i,r}const mt=100,pt=10,gt=1;const yt=({stiffness:t=mt,damping:e=pt,mass:n=gt,from:a=0,to:i=1,velocity:r=0,restSpeed:s=2,restDistance:o=.5}={})=>{r=r?g(r):0;const c={done:!1,hasReachedTarget:!1,current:a,target:i},l=i-a,u=Math.sqrt(t/n)/1e3,h=((t=mt,e=pt,n=gt)=>e/(2*Math.sqrt(t*n)))(t,e,n);let f;if(h<1){const t=u*Math.sqrt(1-h*h);f=e=>i-Math.exp(-h*u*e)*((h*u*l-r)/t*Math.sin(t*e)+l*Math.cos(t*e))}else f=t=>i-Math.exp(-u*t)*(l+(u*l-r)*t);return t=>{c.current=f(t);const e=0===t?r:dt(f,t,c.current),n=Math.abs(e)<=s,l=Math.abs(i-c.current)<=o;var u,h,d;return c.done=n&&l,c.hasReachedTarget=(u=a,h=i,d=c.current,u<h&&d>=h||u>h&&d<=h),c}};function vt(t){const e=new WeakMap;return(n={})=>{const a=new Map,i=(e=0,i=100,r=0,s=!1)=>{const o=`${e}-${i}-${r}-${s}`;return a.has(o)||a.set(o,t(Object.assign({from:e,to:i,velocity:r,restSpeed:s?.05:2,restDistance:s?.01:.5},n))),a.get(o)},r=t=>(e.has(t)||e.set(t,function(t){let e,n=10,a=t(0);const i=[a.current];for(;!a.done&&n<1e4;)a=t(n),i.push(a.done?a.target:a.current),void 0===e&&a.hasReachedTarget&&(e=n),n+=10;const r=n-10;return 1===i.length&&i.push(a.current),{keyframes:i,duration:r/1e3,overshootDuration:(null!=e?e:r)/1e3}}(t)),e.get(t));return{createAnimation:(t,e,n,a,s)=>{var o,c;let l;const u=t.length;if(n&&u<=2&&t.every(bt)){const n=t[u-1],h=1===u?null:t[0];let f=0,d=0;const m=null==s?void 0:s.generator;if(m){const{animation:e,generatorStartTime:n}=s,a=(null==e?void 0:e.startTime)||n||0,i=(null==e?void 0:e.currentTime)||performance.now()-a,r=m(i).current;d=null!==(o=h)&&void 0!==o?o:r,(1===u||2===u&&null===t[0])&&(f=dt((t=>m(t).current),i,r))}else d=null!==(c=h)&&void 0!==c?c:parseFloat(e());const p=i(d,n,f,null==a?void 0:a.includes("scale")),g=r(p);l=Object.assign(Object.assign({},g),{easing:"linear"}),s&&(s.generator=p,s.generatorStartTime=performance.now())}else{l={easing:"ease",duration:r(i(0,100)).overshootDuration}}return l}}}}const bt=t=>"string"!=typeof t,wt=vt(yt),Mt=vt((({from:t=0,velocity:e=0,power:n=.8,decay:a=.325,bounceDamping:i,bounceStiffness:r,changeTarget:s,min:o,max:c,restDistance:l=.5,restSpeed:u})=>{a=p(a);const h={hasReachedTarget:!1,done:!1,current:t,target:t},f=t=>void 0===o?c:void 0===c||Math.abs(o-t)<Math.abs(c-t)?o:c;let d=n*e;const m=t+d,g=void 0===s?m:s(m);h.target=g,g!==m&&(d=g-t);const y=t=>-d*Math.exp(-t/a),v=t=>g+y(t),b=t=>{const e=y(t),n=v(t);h.done=Math.abs(e)<=l,h.current=h.done?g:n};let w,M;const T=t=>{var e;(e=h.current,void 0!==o&&e<o||void 0!==c&&e>c)&&(w=t,M=yt({from:h.current,to:f(h.current),velocity:dt(v,t,h.current),damping:i,stiffness:r,restDistance:l,restSpeed:u}))};return T(0),t=>{let e=!1;return M||void 0!==w||(e=!0,b(t),T(t)),void 0!==w&&t>w?(h.hasReachedTarget=!0,M(t-w)):(h.hasReachedTarget=!1,!e&&b(t),h)}}));function Tt(t,e){return tt([()=>{const n=new _(t,[0,1],e);return n.finished.catch((()=>{})),n}],null==e?void 0:e.duration)}function Ot(t,e,n){return("function"==typeof t?Tt:rt)(t,e,n)}export{t as MotionValue,Ot as animate,Mt as glide,wt as spring,at as stagger,Z as style,ut as timeline};
1
+ class t{setAnimation(t){this.animation=t,null==t||t.finished.then((()=>this.clearAnimation())).catch((()=>{}))}clearAnimation(){this.animation=this.generator=void 0}}const e=new WeakMap;function n(t){return e.has(t)||e.set(t,{transforms:[],values:new Map}),e.get(t)}function a(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const i={duration:.3,delay:0,endDelay:0,repeat:0,easing:"ease"},r=t=>"number"==typeof t,s=t=>"string"==typeof t,o=t=>"object"==typeof t&&Boolean(t.createAnimation),c=t=>Array.isArray(t)&&!r(t[0]),l=(t,e,n)=>-n*t+n*e+t,u=()=>{},h=t=>t,f=(t,e,n)=>e-t==0?1:(n-t)/(e-t);function d(t,e){const n=t[t.length-1];for(let a=1;a<=e;a++){const i=f(0,e,a);t.push(l(n,1,i))}}function m(t){const e=[0];return d(e,t-1),e}const p=t=>1e3*t,g=t=>t/1e3;const y=["","X","Y","Z"],v={x:"translateX",y:"translateY",z:"translateZ"},b={syntax:"<angle>",initialValue:"0deg",toDefaultUnit:t=>t+"deg"},w={translate:{syntax:"<length-percentage>",initialValue:"0px",toDefaultUnit:t=>t+"px"},rotate:b,scale:{syntax:"<number>",initialValue:1,toDefaultUnit:h},skew:b},M=new Map,T=t=>`--motion-${t}`,O=["x","y","z"];["translate","scale","rotate","skew"].forEach((t=>{y.forEach((e=>{O.push(t+e),M.set(T(t+e),w[t])}))}));const S=(t,e)=>O.indexOf(t)-O.indexOf(e),x=new Set(O),A=t=>x.has(t),k=t=>t.sort(S).reduce(D,"").trim(),D=(t,e)=>`${t} ${e}(var(${T(e)}))`,j=t=>t.startsWith("--"),R=new Set;const P=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t;function E(t,e,n,a){if(t===e&&n===a)return h;const i=e=>function(t,e,n,a,i){let r,s,o=0;do{s=e+(n-e)/2,r=P(s,a,i)-t,r>0?n=s:e=s}while(Math.abs(r)>1e-7&&++o<12);return s}(e,0,1,t,n);return t=>0===t||1===t?t:P(i(t),e,a)}const $=(t,e="end")=>n=>{const a=(n="end"===e?Math.min(n,.999):Math.max(n,.001))*t,i="end"===e?Math.floor(a):Math.ceil(a);return r=0,s=1,o=i/t,Math.min(Math.max(o,r),s);var r,s,o},q={ease:E(.25,.1,.25,1),"ease-in":E(.42,0,1,1),"ease-in-out":E(.42,0,.58,1),"ease-out":E(0,0,.58,1)},V=/\((.*?)\)/;function F(t){if("function"==typeof t)return t;if(Array.isArray(t))return E(...t);if(q[t])return q[t];if(t.startsWith("steps")){const e=V.exec(t);if(e){const t=e[1].split(",");return $(parseFloat(t[0]),t[1].trim())}}return h}function W(t,e){return c(t)?t[((t,e,n)=>{const a=e-t;return((n-t)%a+a)%a+t})(0,t.length,e)]:t}function U(t,e=m(t.length),n=h){const a=t.length,i=a-e.length;return i>0&&d(e,i),i=>{let r=0;for(;r<a-2&&!(i<e[r+1]);r++);let s=(o=f(e[r],e[r+1],i),Math.min(1,Math.max(o,0)));var o;return s=W(n,r)(s),l(t[r],t[r+1],s)}}class _{constructor(t,e=[0,1],{easing:n=i.easing,duration:a=i.duration,delay:r=i.delay,endDelay:s=i.endDelay,repeat:l=i.repeat,offset:u,direction:f="normal"}={}){if(this.startTime=null,this.rate=1,this.t=0,this.cancelTimestamp=null,this.playState="idle",this.finished=new Promise(((t,e)=>{this.resolve=t,this.reject=e})),o(n)){const t=n.createAnimation(e,(()=>"0"),!0);n=t.easing,void 0!==t.keyframes&&(e=t.keyframes),void 0!==t.duration&&(a=t.duration)}const d=c(n)?h:F(n),m=a*(l+1),p=U(e,u,c(n)?n.map(F):h);this.tick=e=>{var n;this.pauseTime&&(e=this.pauseTime);let i=(e-this.startTime)*this.rate;this.t=i,i/=1e3,i=Math.max(i-r,0),"finished"===this.playState&&(i=m);const o=i/a;let c=Math.floor(o),l=o%1;!l&&o>=1&&(l=1),1===l&&c--;const u=c%2;("reverse"===f||"alternate"===f&&u||"alternate-reverse"===f&&!u)&&(l=1-l);const h=i>=m?1:Math.min(l,1),g=p(d(h));t(g);"finished"===this.playState||i>=m+s?(this.playState="finished",null===(n=this.resolve)||void 0===n||n.call(this,g)):"idle"!==this.playState&&(this.frameRequestId=requestAnimationFrame(this.tick))},this.play()}play(){var t;const e=performance.now();this.playState="running",this.pauseTime?this.startTime=e-(this.pauseTime-(null!==(t=this.startTime)&&void 0!==t?t:0)):this.startTime||(this.startTime=e),this.cancelTimestamp=this.startTime,this.pauseTime=void 0,requestAnimationFrame(this.tick)}pause(){this.playState="paused",this.pauseTime=performance.now()}finish(){this.playState="finished",this.tick(0)}stop(){var t;this.playState="idle",void 0!==this.frameRequestId&&cancelAnimationFrame(this.frameRequestId),null===(t=this.reject)||void 0===t||t.call(this,!1)}cancel(){this.stop(),this.tick(this.cancelTimestamp)}reverse(){this.rate*=-1}commitStyles(){}get currentTime(){return this.t}set currentTime(t){this.pauseTime||0===this.rate?this.pauseTime=t:this.startTime=performance.now()-t/this.rate}get playbackRate(){return this.rate}set playbackRate(t){this.rate=t}}const C=t=>(t=>Array.isArray(t)&&r(t[0]))(t)?I(t):t,I=([t,e,n,a])=>`cubic-bezier(${t}, ${e}, ${n}, ${a})`,B=t=>document.createElement("div").animate(t,{duration:.001}),z={cssRegisterProperty:()=>"undefined"!=typeof CSS&&Object.hasOwnProperty.call(CSS,"registerProperty"),waapi:()=>Object.hasOwnProperty.call(Element.prototype,"animate"),partialKeyframes:()=>{try{B({opacity:[1]})}catch(t){return!1}return!0},finished:()=>Boolean(B({opacity:[0,1]}).finished)},N={},K={};for(const t in z)K[t]=()=>(void 0===N[t]&&(N[t]=z[t]()),N[t]);const X=t=>Array.isArray(t)?t:[t];function Y(t){return v[t]&&(t=v[t]),A(t)?T(t):t}const Z={get:(t,e)=>{e=Y(e);let n=j(e)?t.style.getPropertyValue(e):getComputedStyle(t)[e];if(!n&&0!==n){const t=M.get(e);t&&(n=t.initialValue)}return n},set:(t,e,n)=>{e=Y(e),j(e)?t.style.setProperty(e,n):t.style[e]=n}};function L(t,e=!0){if(t&&"finished"!==t.playState)try{t.stop?t.stop():(e&&t.commitStyles(),t.cancel())}catch(t){}}function G(e,a,s,l={}){const h=window.__MOTION_DEV_TOOLS_RECORD,f=!1!==l.record&&h;let d,{duration:m=i.duration,delay:g=i.delay,endDelay:y=i.endDelay,repeat:b=i.repeat,easing:w=i.easing,direction:T,offset:O,allowWebkitAcceleration:S=!1}=l;const x=n(e);let D=K.waapi();const P=A(a);P&&((t,e)=>{v[e]&&(e=v[e]);const{transforms:a}=n(t);var i,r;r=e,-1===(i=a).indexOf(r)&&i.push(r),t.style.transform=k(a)})(e,a);const E=Y(a),$=function(e,n){return e.has(n)||e.set(n,new t),e.get(n)}(x.values,E),q=M.get(E);return L($.animation,!(o(w)&&$.generator)&&!1!==l.record),()=>{const t=()=>{var t,n;return null!==(n=null!==(t=Z.get(e,E))&&void 0!==t?t:null==q?void 0:q.initialValue)&&void 0!==n?n:0};let n=function(t,e){for(let n=0;n<t.length;n++)null===t[n]&&(t[n]=n?t[n-1]:e());return t}(X(s),t);if(o(w)){const e=w.createAnimation(n,t,P,E,$);w=e.easing,void 0!==e.keyframes&&(n=e.keyframes),void 0!==e.duration&&(m=e.duration)}if(j(E)&&(K.cssRegisterProperty()?function(t){if(!R.has(t)){R.add(t);try{const{syntax:e,initialValue:n}=M.has(t)?M.get(t):{};CSS.registerProperty({name:t,inherits:!1,syntax:e,initialValue:n})}catch(t){}}}(E):D=!1),D){q&&(n=n.map((t=>r(t)?q.toDefaultUnit(t):t))),1!==n.length||K.partialKeyframes()&&!f||n.unshift(t());const a={delay:p(g),duration:p(m),endDelay:p(y),easing:c(w)?void 0:C(w),direction:T,iterations:b+1,fill:"both"};d=e.animate({[E]:n,offset:O,easing:c(w)?w.map(C):void 0},a),d.finished||(d.finished=new Promise(((t,e)=>{d.onfinish=t,d.oncancel=e})));const i=n[n.length-1];d.finished.then((()=>{Z.set(e,E,i),d.cancel()})).catch(u),S||(d.playbackRate=1.000001)}else if(P){n=n.map((t=>"string"==typeof t?parseFloat(t):t)),1===n.length&&n.unshift(parseFloat(t()));d=new _((t=>{q&&(t=q.toDefaultUnit(t)),Z.set(e,E,t)}),n,Object.assign(Object.assign({},l),{duration:m,easing:w}))}else{const t=n[n.length-1];Z.set(e,E,q&&r(t)?q.toDefaultUnit(t):t)}return f&&h(e,a,n,{duration:m,delay:g,easing:w,repeat:b,offset:O},"motion-one"),$.setAnimation(d),d}}const H=(t,e)=>t[e]?Object.assign(Object.assign({},t),t[e]):Object.assign({},t);function J(t,e){var n;return"string"==typeof t?e?(null!==(n=e[t])&&void 0!==n||(e[t]=document.querySelectorAll(t)),t=e[t]):t=document.querySelectorAll(t):t instanceof Element&&(t=[t]),Array.from(t)}const Q=t=>t(),tt=(t,e=i.duration)=>new Proxy({animations:t.map(Q).filter(Boolean),duration:e},et),et={get:(t,e)=>{const n=t.animations[0];switch(e){case"duration":return t.duration;case"currentTime":let a=(null==n?void 0:n[e])||0;return a?a/1e3:0;case"playbackRate":case"playState":return null==n?void 0:n[e];case"finished":return t.finished||(t.finished=Promise.all(t.animations.map(nt)).catch(u)),t.finished;case"stop":return()=>t.animations.forEach((t=>L(t)));default:return void 0===(null==n?void 0:n[e])?void 0:()=>t.animations.forEach((t=>t[e]()))}},set:(t,e,n)=>{switch(e){case"currentTime":n=p(n);case"currentTime":case"playbackRate":for(let a=0;a<t.animations.length;a++)t.animations[a][e]=n;return!0}return!1}},nt=t=>t.finished;function at(t=.1,{start:e=0,from:n=0,easing:a}={}){return(i,s)=>{const o=r(n)?n:function(t,e){if("first"===t)return 0;{const n=e-1;return"last"===t?n:n/2}}(n,s),c=Math.abs(o-i);let l=t*c;if(a){const e=s*t;l=F(a)(l/e)*e}return e+l}}function it(t,e,n){return"function"==typeof t?t(e,n):t}function rt(t,e,n={}){const a=(t=J(t)).length,i=[];for(let r=0;r<a;r++){const s=t[r];for(const t in e){const o=H(n,t);o.delay=it(o.delay,r,a);const c=G(s,t,e[t],o);i.push(c)}}return tt(i,n.duration)}var st=function(){};function ot(t,e,n,a){var i;return r(e)?e:e.startsWith("-")||e.startsWith("+")?Math.max(0,t+parseFloat(e)):"<"===e?n:null!==(i=a.get(e))&&void 0!==i?i:t}function ct(t,e,n,i,r,s){!function(t,e,n){for(let i=0;i<t.length;i++){const r=t[i];r.at>e&&r.at<n&&(a(t,r),i--)}}(t,r,s);for(let a=0;a<e.length;a++)t.push({value:e[a],at:l(r,s,i[a]),easing:W(n,a)})}function lt(t,e){return t.at===e.at?null===t.value?1:-1:t.at-e.at}function ut(t,e={}){var n;const a=function(t,e={}){var{defaultOptions:n={}}=e,a=function(t,e){var n={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&e.indexOf(a)<0&&(n[a]=t[a]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(t);i<a.length;i++)e.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(t,a[i])&&(n[a[i]]=t[a[i]])}return n}(e,["defaultOptions"]);const r=[],c=new Map,l={},u=new Map;let h=0,p=0,g=0;for(let e=0;e<t.length;e++){const a=t[e];if(s(a)){u.set(a,p);continue}if(!Array.isArray(a)){u.set(a.name,ot(p,a.at,h,u));continue}const[r,f,y={}]=a;void 0!==y.at&&(p=ot(p,y.at,h,u));let v=0;const b=J(r,l),w=b.length;for(let t=0;t<w;t++){const e=ht(b[t],c);for(const a in f){const r=ft(a,e);let s=X(f[a]);const c=H(y,a);let{duration:l=n.duration||i.duration,easing:u=n.easing||i.easing}=c;if(o(u)){const t=A(a);st(2===s.length||!t,"spring must be provided 2 keyframes within timeline");const e=u.createAnimation(s,(()=>"0"),t);u=e.easing,void 0!==e.keyframes&&(s=e.keyframes),void 0!==e.duration&&(l=e.duration)}const h=it(y.delay,t,w)||0,b=p+h,M=b+l;let{offset:T=m(s.length)}=c;1===T.length&&0===T[0]&&(T[1]=1);const O=length-s.length;O>0&&d(T,O),1===s.length&&s.unshift(null),ct(r,s,u,T,b,M),v=Math.max(h+l,v),g=Math.max(M,g)}}h=p,p+=v}return c.forEach(((t,e)=>{for(const s in t){const o=t[s];o.sort(lt);const c=[],l=[],u=[];for(let t=0;t<o.length;t++){const{at:e,value:n,easing:a}=o[t];c.push(n),l.push(f(0,g,e)),u.push(a||i.easing)}0!==l[0]&&(l.unshift(0),c.unshift(c[0]),u.unshift("linear")),1!==l[l.length-1]&&(l.push(1),c.push(null)),r.push([e,s,c,Object.assign(Object.assign(Object.assign({},n),{duration:g,easing:u,offset:l}),a)])}})),r}(t,e),r=a.map((t=>G(...t))).filter(Boolean);return tt(r,null===(n=a[0])||void 0===n?void 0:n[3].duration)}function ht(t,e){return!e.has(t)&&e.set(t,{}),e.get(t)}function ft(t,e){return e[t]||(e[t]=[]),e[t]}"production"!==process.env.NODE_ENV&&(st=function(t,e){if(!t)throw new Error(e)});function dt(t,e,n){const a=Math.max(e-5,0);return i=n-t(a),(r=e-a)?i*(1e3/r):0;var i,r}const mt=100,pt=10,gt=1;const yt=({stiffness:t=mt,damping:e=pt,mass:n=gt,from:a=0,to:i=1,velocity:r=0,restSpeed:s=2,restDistance:o=.5}={})=>{r=r?g(r):0;const c={done:!1,hasReachedTarget:!1,current:a,target:i},l=i-a,u=Math.sqrt(t/n)/1e3,h=((t=mt,e=pt,n=gt)=>e/(2*Math.sqrt(t*n)))(t,e,n);let f;if(h<1){const t=u*Math.sqrt(1-h*h);f=e=>i-Math.exp(-h*u*e)*((h*u*l-r)/t*Math.sin(t*e)+l*Math.cos(t*e))}else f=t=>i-Math.exp(-u*t)*(l+(u*l-r)*t);return t=>{c.current=f(t);const e=0===t?r:dt(f,t,c.current),n=Math.abs(e)<=s,l=Math.abs(i-c.current)<=o;var u,h,d;return c.done=n&&l,c.hasReachedTarget=(u=a,h=i,d=c.current,u<h&&d>=h||u>h&&d<=h),c}};function vt(t){const e=new WeakMap;return(n={})=>{const a=new Map,i=(e=0,i=100,r=0,s=!1)=>{const o=`${e}-${i}-${r}-${s}`;return a.has(o)||a.set(o,t(Object.assign({from:e,to:i,velocity:r,restSpeed:s?.05:2,restDistance:s?.01:.5},n))),a.get(o)},r=t=>(e.has(t)||e.set(t,function(t){let e,n=10,a=t(0);const i=[a.current];for(;!a.done&&n<1e4;)a=t(n),i.push(a.done?a.target:a.current),void 0===e&&a.hasReachedTarget&&(e=n),n+=10;const r=n-10;return 1===i.length&&i.push(a.current),{keyframes:i,duration:r/1e3,overshootDuration:(null!=e?e:r)/1e3}}(t)),e.get(t));return{createAnimation:(t,e,n,a,s)=>{var o,c;let l;const u=t.length;if(n&&u<=2&&t.every(bt)){const n=t[u-1],h=1===u?null:t[0];let f=0,d=0;const m=null==s?void 0:s.generator;if(m){const{animation:e,generatorStartTime:n}=s,a=(null==e?void 0:e.startTime)||n||0,i=(null==e?void 0:e.currentTime)||performance.now()-a,r=m(i).current;d=null!==(o=h)&&void 0!==o?o:r,(1===u||2===u&&null===t[0])&&(f=dt((t=>m(t).current),i,r))}else d=null!==(c=h)&&void 0!==c?c:parseFloat(e());const p=i(d,n,f,null==a?void 0:a.includes("scale")),g=r(p);l=Object.assign(Object.assign({},g),{easing:"linear"}),s&&(s.generator=p,s.generatorStartTime=performance.now())}else{l={easing:"ease",duration:r(i(0,100)).overshootDuration}}return l}}}}const bt=t=>"string"!=typeof t,wt=vt(yt),Mt=vt((({from:t=0,velocity:e=0,power:n=.8,decay:a=.325,bounceDamping:i,bounceStiffness:r,changeTarget:s,min:o,max:c,restDistance:l=.5,restSpeed:u})=>{a=p(a);const h={hasReachedTarget:!1,done:!1,current:t,target:t},f=t=>void 0===o?c:void 0===c||Math.abs(o-t)<Math.abs(c-t)?o:c;let d=n*e;const m=t+d,g=void 0===s?m:s(m);h.target=g,g!==m&&(d=g-t);const y=t=>-d*Math.exp(-t/a),v=t=>g+y(t),b=t=>{const e=y(t),n=v(t);h.done=Math.abs(e)<=l,h.current=h.done?g:n};let w,M;const T=t=>{var e;(e=h.current,void 0!==o&&e<o||void 0!==c&&e>c)&&(w=t,M=yt({from:h.current,to:f(h.current),velocity:dt(v,t,h.current),damping:i,stiffness:r,restDistance:l,restSpeed:u}))};return T(0),t=>{let e=!1;return M||void 0!==w||(e=!0,b(t),T(t)),void 0!==w&&t>w?(h.hasReachedTarget=!0,M(t-w)):(h.hasReachedTarget=!1,!e&&b(t),h)}}));function Tt(t,e){return tt([()=>{const n=new _(t,[0,1],e);return n.finished.catch((()=>{})),n}],null==e?void 0:e.duration)}function Ot(t,e,n){return("function"==typeof t?Tt:rt)(t,e,n)}export{t as MotionValue,Ot as animate,Mt as glide,wt as spring,at as stagger,Z as style,ut as timeline};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "motion",
3
3
  "description": "A tiny, performant animation library for the web",
4
- "version": "10.10.0",
4
+ "version": "10.10.1",
5
5
  "license": "MIT",
6
6
  "author": "Matt Perry",
7
7
  "main": "dist/main.cjs.js",
@@ -23,12 +23,12 @@
23
23
  "dev": "concurrently -c blue,red -n tsc,rollup --kill-others \"tsc --watch -p . --preserveWatchOutput\" \"rollup --c --watch --no-watch.clearScreen\""
24
24
  },
25
25
  "dependencies": {
26
- "@motionone/animation": "^10.9.0",
27
- "@motionone/dom": "^10.10.0",
28
- "@motionone/react": "^10.10.0",
29
- "@motionone/svelte": "^10.10.0",
26
+ "@motionone/animation": "^10.10.1",
27
+ "@motionone/dom": "^10.10.1",
28
+ "@motionone/react": "^10.10.1",
29
+ "@motionone/svelte": "^10.10.1",
30
30
  "@motionone/types": "^10.9.0",
31
- "@motionone/vue": "^10.10.0"
31
+ "@motionone/vue": "^10.10.1"
32
32
  },
33
- "gitHead": "a405d387c402bd1b89a5ab27833c5b4612ee599a"
33
+ "gitHead": "80f2fa071ff960c9260bb70d12b09464e0076f91"
34
34
  }