import mitt from"../../vendor/mitt/src/index.js";export class EventEmitter{constructor(){this.eventsMap=new Map,this.emitter=mitt(this.eventsMap)}on(t,e){return this.emitter.on(t,e),this}off(t,e){return this.emitter.off(t,e),this}removeListener(t,e){return this.off(t,e),this}addListener(t,e){return this.on(t,e),this}emit(t,e){return this.emitter.emit(t,e),this.eventListenersCount(t)>0}once(t,e){const s=n=>{e(n),this.off(t,s)};return this.on(t,s)}listenerCount(t){return this.eventListenersCount(t)}removeAllListeners(t){return t?this.eventsMap.delete(t):this.eventsMap.clear(),this}eventListenersCount(t){return this.eventsMap.has(t)?this.eventsMap.get(t).length:0}}