"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../AsyncMotionValueAnimation.mjs.js"),i=require("../JSAnimation.mjs.js"),t=require("../utils/get-value-transition.mjs.js"),n=require("../utils/make-animation-instant.mjs.js"),o=require("../utils/default-transitions.mjs.js"),s=require("../keyframes/get-final.mjs.js"),a=require("../utils/is-transition-defined.mjs.js"),r=require("../../frameloop/frame.mjs.js"),l=require("../../../../../motion-utils/dist/es/time-conversion.mjs.js"),m=require("../../../../../motion-utils/dist/es/global-config.mjs.js");exports.animateMotionValue=function(u,d,y){let p=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},f=arguments.length>4?arguments[4]:void 0,j=arguments.length>5?arguments[5]:void 0;return c=>{const g=t.getValueTransition(p,u)||{},A=g.delay||p.delay||0;let{elapsed:v=0}=p;v-=l.secondsToMilliseconds(A);const k={keyframes:Array.isArray(y)?y:[null,y],ease:"easeOut",velocity:d.getVelocity(),...g,delay:-v,onUpdate:e=>{d.set(e),g.onUpdate&&g.onUpdate(e)},onComplete:()=>{c(),g.onComplete&&g.onComplete()},name:u,motionValue:d,element:j?void 0:f};a.isTransitionDefined(g)||Object.assign(k,o.getDefaultTransition(u,k)),k.duration&&(k.duration=l.secondsToMilliseconds(k.duration)),k.repeatDelay&&(k.repeatDelay=l.secondsToMilliseconds(k.repeatDelay)),void 0!==k.from&&(k.keyframes[0]=k.from);let q=!1;if((!1===k.type||0===k.duration&&!k.repeatDelay)&&(n.makeAnimationInstant(k),0===k.delay&&(q=!0)),(m.MotionGlobalConfig.instantAnimations||m.MotionGlobalConfig.skipAnimations||f?.shouldSkipAnimations||g.skipAnimations)&&(q=!0,n.makeAnimationInstant(k),k.delay=0),k.allowFlatten=!g.type&&!g.ease,q&&!j&&void 0!==d.get()){const e=s.getFinalKeyframe(k.keyframes,g);if(void 0!==e)return void r.frame.update((()=>{k.onUpdate(e),k.onComplete()}))}return g.isSync?new i.JSAnimation(k):new e.AsyncMotionValueAnimation(k)}};
//# sourceMappingURL=motion-value.mjs.js.map
