var O = Object.defineProperty;
var u = (r, t, e) => t in r ? O(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
var i = (r, t, e) => (u(r, typeof t != "symbol" ? t + "" : t, e), e);
import E from "../../../../eventemitter3@5.0.1/node_modules/eventemitter3/index.mjs";
import d from "./instances.mjs";
import L from "./logger.mjs";
const c = L("quill:events"), T = ["selectionchange", "mousedown", "mouseup", "click"];
T.forEach((r) => {
  document.addEventListener(r, function() {
    for (var t = arguments.length, e = new Array(t), o = 0; o < t; o++)
      e[o] = arguments[o];
    Array.from(document.querySelectorAll(".ql-container")).forEach((s) => {
      const n = d.get(s);
      n && n.emitter && n.emitter.handleDOM(...e);
    });
  });
});
class l extends E {
  constructor() {
    super(), this.domListeners = {}, this.on("error", c.error);
  }
  emit() {
    for (var t = arguments.length, e = new Array(t), o = 0; o < t; o++)
      e[o] = arguments[o];
    return c.log.call(c, ...e), super.emit(...e);
  }
  handleDOM(t) {
    for (var e = arguments.length, o = new Array(e > 1 ? e - 1 : 0), s = 1; s < e; s++)
      o[s - 1] = arguments[s];
    (this.domListeners[t.type] || []).forEach((n) => {
      let {
        node: a,
        handler: m
      } = n;
      (t.target === a || a.contains(t.target)) && m(t, ...o);
    });
  }
  listenDOM(t, e, o) {
    this.domListeners[t] || (this.domListeners[t] = []), this.domListeners[t].push({
      node: e,
      handler: o
    });
  }
}
i(l, "events", {
  EDITOR_CHANGE: "editor-change",
  SCROLL_BEFORE_UPDATE: "scroll-before-update",
  SCROLL_BLOT_MOUNT: "scroll-blot-mount",
  SCROLL_BLOT_UNMOUNT: "scroll-blot-unmount",
  SCROLL_OPTIMIZE: "scroll-optimize",
  SCROLL_UPDATE: "scroll-update",
  SCROLL_EMBED_UPDATE: "scroll-embed-update",
  SELECTION_CHANGE: "selection-change",
  TEXT_CHANGE: "text-change",
  COMPOSITION_BEFORE_START: "composition-before-start",
  COMPOSITION_START: "composition-start",
  COMPOSITION_BEFORE_END: "composition-before-end",
  COMPOSITION_END: "composition-end"
}), i(l, "sources", {
  API: "api",
  SILENT: "silent",
  USER: "user"
});
export {
  l as default
};
