"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./spring.mjs.js"),t=require("./utils/velocity.mjs.js");exports.inertia=function(s){let{keyframes:o,velocity:a=0,power:n=.8,timeConstant:i=325,bounceDamping:r=10,bounceStiffness:l=500,modifyTarget:u,min:v,max:d,restDelta:c=.5,restSpeed:p}=s;const m=o[0],f={done:!1,value:m},y=e=>void 0===v?d:void 0===d||Math.abs(v-e)<Math.abs(d-e)?v:d;let b=n*a;const g=m+b,x=void 0===u?g:u(g);x!==g&&(b=x-m);const j=e=>-b*Math.exp(-e/i),M=e=>x+j(e),h=e=>{const t=j(e),s=M(e);f.done=Math.abs(t)<=c,f.value=f.done?x:s};let D,S;const k=s=>{var o;(o=f.value,void 0!==v&&o<v||void 0!==d&&o>d)&&(D=s,S=e.spring({keyframes:[f.value,y(f.value)],velocity:t.getGeneratorVelocity(M,s,f.value),damping:r,stiffness:l,restDelta:c,restSpeed:p}))};return k(0),{calculatedDuration:null,next:e=>{let t=!1;return S||void 0!==D||(t=!0,h(e),k(e)),void 0!==D&&e>=D?S.next(e-D):(!t&&h(e),f)}}};
//# sourceMappingURL=inertia.mjs.js.map
