"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var ricos_toolbar_exports = {};
__export(ricos_toolbar_exports, {
  RicosToolbar: () => RicosToolbar
});
module.exports = __toCommonJS(ricos_toolbar_exports);
var import_event_emitter = require("./lib/event-emitter.js");
const _RicosToolbar = class _RicosToolbar extends import_event_emitter.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;
//# sourceMappingURL=ricos-toolbar.js.map
