class EventEmitter {
  constructor() {
    // oxlint-disable-next-line @typescript-oxlint/no-unsafe-function-type
    this.callbacks = {};
  }
  // oxlint-disable-next-line @typescript-oxlint/no-unsafe-function-type
  on(event, fn) {
    if (!this.callbacks[event]) {
      this.callbacks[event] = [];
    }
    this.callbacks[event].push(fn);
    return this;
  }
  emit(event, ...args) {
    const callbacks = this.callbacks[event];
    if (callbacks) {
      callbacks.forEach((callback) => callback.apply(this, args));
    }
    return this;
  }
  // oxlint-disable-next-line @typescript-oxlint/no-unsafe-function-type
  off(event, fn) {
    const callbacks = this.callbacks[event];
    if (callbacks) {
      if (fn) {
        this.callbacks[event] = callbacks.filter((callback) => callback !== fn);
      } else {
        delete this.callbacks[event];
      }
    }
    return this;
  }
  removeAllListeners() {
    this.callbacks = {};
  }
}
export {
  EventEmitter
};
//# sourceMappingURL=event-emitter.js.map
