import { Emitter } from "../common/event.mjs";
class DomEmitter {
  constructor(element, type, useCapture) {
    const fn = (e) => this.emitter.fire(e);
    this.emitter = new Emitter({
      onFirstListenerAdd: () => element.addEventListener(type, fn, useCapture),
      onLastListenerRemove: () => element.removeEventListener(type, fn, useCapture)
    });
  }
  get event() {
    return this.emitter.event;
  }
  dispose() {
    this.emitter.dispose();
  }
}
function stopEvent(event) {
  event.preventDefault();
  event.stopPropagation();
  return event;
}
export {
  DomEmitter,
  stopEvent
};
