import{__rest as t,__assign as n}from"../../../../node_modules/tslib/tslib.es6.js";import{findSpring as e,calcAngularFreq as r}from"../utils/find-spring.js";var o=["duration","bounce"],s=["stiffness","damping","mass"];function a(t,n){return n.some((function(n){return void 0!==t[n]}))}function i(i){var f=i.from,v=void 0===f?0:f,d=i.to,c=void 0===d?1:d,h=i.restSpeed,l=void 0===h?2:h,m=i.restDelta,M=t(i,["from","to","restSpeed","restDelta"]),p={done:!1,value:v},g=function(t){var r=n({velocity:0,stiffness:100,damping:10,mass:1,isResolvedFromDuration:!1},t);if(!a(t,s)&&a(t,o)){var i=e(t);(r=n(n(n({},r),i),{velocity:0,mass:1})).isResolvedFromDuration=!0}return r}(M),b=g.stiffness,x=g.damping,y=g.mass,D=g.velocity,q=g.isResolvedFromDuration,F=u,R=u;function j(){var t=D?-D/1e3:0,n=c-v,e=x/(2*Math.sqrt(b*y)),o=Math.sqrt(b/y)/1e3;if(null!=m||(m=Math.abs(c-v)<=1?.01:.4),e<1){var s=r(o,e);F=function(r){var a=Math.exp(-e*o*r);return c-a*((t+e*o*n)/s*Math.sin(s*r)+n*Math.cos(s*r))},R=function(r){var a=Math.exp(-e*o*r);return e*o*a*(Math.sin(s*r)*(t+e*o*n)/s+n*Math.cos(s*r))-a*(Math.cos(s*r)*(t+e*o*n)-s*n*Math.sin(s*r))}}else if(1===e)F=function(e){return c-Math.exp(-o*e)*(n+(t+o*n)*e)};else{var a=o*Math.sqrt(e*e-1);F=function(r){var s=Math.exp(-e*o*r),i=Math.min(a*r,300);return c-s*((t+e*o*n)*Math.sinh(i)+a*n*Math.cosh(i))/a}}}return j(),{next:function(t){var n=F(t);if(q)p.done=t>=M.duration;else{var e=1e3*R(t),r=Math.abs(e)<=l,o=Math.abs(c-n)<=m;p.done=r&&o}return p.value=p.done?c:n,p},flipTarget:function(){var t;D=-D,v=(t=[c,v])[0],c=t[1],j()}}}i.needsInterpolation=function(t,n){return"string"==typeof t||"string"==typeof n};var u=function(t){return 0};export{i as spring};
//# sourceMappingURL=spring.js.map
