import { EventEmitter } from "./lib/event-emitter.js";
const _RicosToolbar = class _RicosToolbar extends EventEmitter {
  constructor({
    toolbarItemCreators,
    content,
    tiptapEditor,
    editorQuery,
    modalService,
    publicCommands
  }) {
    super();
    this.toolbarItems = [];
    this.toolbarItems = [];
    this.toolbarItemCreators = toolbarItemCreators;
    this.content = content;
    this.tiptapEditor = tiptapEditor;
    this.editorQuery = editorQuery;
    this.modalService = modalService;
    this.publicCommands = publicCommands;
  }
  static create({
    toolbarItemCreators,
    content,
    tiptapEditor,
    editorQuery,
    modalService,
    publicCommands
  }) {
    return new _RicosToolbar({
      toolbarItemCreators,
      content,
      tiptapEditor,
      editorQuery,
      modalService,
      publicCommands
    });
  }
  destroyToolbarItems() {
    this.toolbarItems.forEach((toolbarItem) => {
      toolbarItem.destroy();
    });
    this.toolbarItems = [];
  }
  update() {
    this.toolbarItems.forEach((toolbarItem) => {
      toolbarItem.updateAttributes();
    });
  }
  createToolbarItems() {
    this.destroyToolbarItems();
    this.toolbarItems = this.toolbarItemCreators.map((toolbarItemCreator) => {
      const toolbarItem = toolbarItemCreator(
        this.content,
        this.tiptapEditor,
        this.editorQuery,
        this.modalService,
        this.publicCommands
      );
      toolbarItem.setup();
      return toolbarItem;
    });
  }
  shouldCreateToolbarItems() {
    return this.toolbarItems.length !== this.toolbarItemCreators.length;
  }
  getToolbarItemById(id) {
    return this.toolbarItems.find((item) => item.id === id);
  }
};
_RicosToolbar.EVENTS = {
  UPDATED: "UPDATED"
};
let RicosToolbar = _RicosToolbar;
export {
  RicosToolbar
};
//# sourceMappingURL=ricos-toolbar.js.map
