class i{parentSync;id;promiseResolver=null;constructor(n){this.parentSync=n,this.id=Symbol()}setScrollingDuration(n){n>0?this.parentSync._componentDurations.set(this.id,n):this.unregister()}maxDuration(){return this.parentSync._componentDurations.size===0?0:Math.max(...this.parentSync._componentDurations.values())}sync(){return new Promise(n=>{this.promiseResolver=n,this.parentSync._pendingSync.push(n),this.parentSync._tryResolveWaiting()})}unregister(){if(this.promiseResolver){const n=this.parentSync._pendingSync.indexOf(this.promiseResolver);n>-1&&this.parentSync._pendingSync.splice(n,1),this.promiseResolver(),this.promiseResolver=null}this.parentSync._componentDurations.delete(this.id),this.parentSync._tryResolveWaiting()}}class s{_componentDurations;_pendingSync;constructor(){this._componentDurations=new Map,this._pendingSync=[]}_registerAnimation(){return new i(this)}_tryResolveWaiting(){if(this._pendingSync?.length===this._componentDurations.size){const n=this._pendingSync;this._pendingSync=[];for(const t of n)t()}}}export{s as M};
