import React from "react";
import { createRicosFunctionalExtension } from "./../tiptap-extensions/index.js";
import { aiSuggestionsPluginKey } from "./plugin-key.js";
import { SuggestionsGlobalComponent } from "./suggestions-global-component.js";
import {
  AI_SUGGESTIONS
} from "./types.js";
const pluginAiSuggestions = (config) => {
  const onStateChange = config?.onStateChange ?? (() => {
  });
  const SuggestionComponent = config?.SuggestionComponent ?? (() => /* @__PURE__ */ React.createElement("div", null, "Suggestion component not provided"));
  return {
    config: {
      onStateChange,
      initiallyVisible: !!config?.initiallyVisible,
      SuggestionComponent,
      getPortalElement: config?.getPortalElement ?? (() => null),
      interceptAction: config?.interceptAction
    },
    type: AI_SUGGESTIONS,
    selectable: false,
    tiptapExtensions: [
      createRicosFunctionalExtension({
        name: "AI_SUGGESTIONS",
        type: "extension",
        groups: [],
        reconfigure: (config2, _extensions, _ricosProps, _settings, services) => {
          return {
            ...config2,
            addOptions: () => {
              return { services };
            }
          };
        },
        createExtensionConfig() {
          return {
            name: "AI_SUGGESTIONS",
            addCommands() {
              return {
                toggleSuggestions: (visible) => ({ chain }) => {
                  const chainedAction = chain().setMeta(aiSuggestionsPluginKey, {
                    type: "toggle-suggestions",
                    visible
                  });
                  return chainedAction.run();
                }
              };
            }
          };
        }
      })
    ],
    GlobalComponent: SuggestionsGlobalComponent
  };
};
export {
  pluginAiSuggestions
};
//# sourceMappingURL=editor.js.map
