(function(n,e){typeof exports=="object"&&typeof module<"u"?e(exports):typeof define=="function"&&define.amd?define(["exports"],e):(n=typeof globalThis<"u"?globalThis:n||self,e(n.index={}))})(this,function(n){"use strict";var u=Object.defineProperty;var l=(n,e,a)=>e in n?u(n,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[e]=a;var r=(n,e,a)=>(l(n,typeof e!="symbol"?e+"":e,a),a);function e(m,t,i=60){const s=t*i;return 1-(1-m)**s}class a{constructor(){r(this,"time",0);r(this,"deltaTime",0);r(this,"lastTimestamp",0);r(this,"animationCount",0);r(this,"animationId",null);r(this,"animations",[])}get animationList(){return this.animations}get currentTime(){return this.time}get isAnimating(){return this.animationId!==null}getLerpCoeff(t,i=60){return e(t,this.deltaTime,i)}add(t,i,s){const o=this.animationId!==null;o&&this.stop();const d=s??this.animationCount;return this.animations.push({id:t,update:i,order:d}),this.sortAnimationsArray(),o&&this.start(),this.animationCount+=1,()=>{this.remove(t)}}remove(t){const i=this.animationId!==null;i&&this.stop();const s=this.animations.filter(o=>o.id!==t);this.animations=s,i&&this.start()}removeAll(){this.stop(),this.animations=[],this.animationCount=0}start(){this.lastTimestamp=performance.now(),this.animate()}stop(){typeof this.animationId=="number"&&cancelAnimationFrame(this.animationId),this.lastTimestamp=0,this.animationId=null}reset(t=!0){this.stop(),this.time=0,t&&this.removeAll()}reorder(){this.sortAnimationsArray();let t=0;const i=this.animations.map(s=>{const{order:o}=s;return Number.isFinite(o)?(t+=1,{...s,order:t-1}):s});this.animationCount=i.length,this.animations=i}animate(){const t=performance.now();this.animationId=requestAnimationFrame(this.animate.bind(this)),this.deltaTime=(t-this.lastTimestamp)*.001,this.time+=this.deltaTime,this.animations.forEach(i=>{i.update({deltaTime:this.deltaTime,time:this.time})}),this.lastTimestamp=t}sortAnimationsArray(){this.animations.sort((t,i)=>t.order-i.order)}}const h=new a;n.default=h,n.getLerpCoeff=e,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});