"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_editor_exports = {};
__export(ricos_editor_exports, {
  RicosEditor: () => RicosEditor
});
module.exports = __toCommonJS(ricos_editor_exports);
var import_tiptap_editor = require("./../tiptap-editor/index.js");
const topics = [
  "ricos.editor.instance.loaded",
  "ricos.editor.instance.error",
  "ricos.editor.functionality.firstEdit",
  "ricos.editor.content.saved"
];
const UPLOAD_TOPICS = [
  "ricos.upload.functionality.uploadStarted",
  "ricos.upload.functionality.uploadFinished"
];
class RicosEditor {
  constructor(editorProps, services, isDebugMode = false, getToolbarStateSelectorContextValue, getSelectionSelectorContextValue, getModalStateSelectorContextValue, getPmContentSelectorContextValue, getInlineAiStateSelectorContextValue) {
    this.id = "ricos-editor";
    this.topicsToPublish = topics;
    this.topicsToSubscribe = UPLOAD_TOPICS;
    this.getPublicCommands = () => this.tiptapAdapter.getEditorCommands();
    this.tiptapAdapter = (0, import_tiptap_editor.initializeTiptapAdapter)(
      editorProps,
      services,
      isDebugMode,
      getToolbarStateSelectorContextValue,
      getSelectionSelectorContextValue,
      getModalStateSelectorContextValue,
      getPmContentSelectorContextValue,
      getInlineAiStateSelectorContextValue
    );
  }
  publishLoaded() {
    return this.publishers.byTopic("ricos.editor.instance.loaded").publish({ msg: "🖖 editor mounted" });
  }
  publishFirstEdit() {
    return this.publishers.byTopic("ricos.editor.functionality.firstEdit").publishOnce({ msg: "📝 first content edit" });
  }
  publishError(error, errorInfo) {
    return this.publishers.byTopic("ricos.editor.instance.error").publish({ error, errorInfo });
  }
  publishContentSaved() {
    return this.publishers.byTopic("ricos.editor.content.saved").publish({ msg: "💾 content saved" });
  }
  get adapter() {
    return this.tiptapAdapter;
  }
}
//# sourceMappingURL=ricos-editor.js.map
