import { jsx as o, jsxs as g, Fragment as l } from "react/jsx-runtime";
/* empty css                            */
import { classNames as y } from "./index-classNames.js";
import { L as v } from "./index-LexicalAutoFocusPlugin.js";
import { L as A } from "./index-LexicalComposer.js";
import { L as F } from "./index-LexicalContentEditable.js";
import R from "./index-LexicalErrorBoundary.js";
import { L as H } from "./index-LexicalHashtagPlugin.js";
import { L as M } from "./index-LexicalHistoryPlugin.js";
import { L as B } from "./index-LexicalListPlugin.js";
import { L as w } from "./index-LexicalRichTextPlugin.js";
import { L as O } from "./index-LexicalTabIndentationPlugin.js";
import { L as V } from "./index-LexicalTablePlugin.js";
import { translationService as j } from "./index-translation.service.js";
import { ComponentContainer as S } from "./index-ComponentContainer.js";
import { L as r } from "./index-LexicalToolkit.js";
import { useState as n, useEffect as _ } from "react";
import { RTE_INITIAL_CONFIG as D } from "./index-RichTextEditor.config.js";
import e from "./index-RichTextEditor.module.scss.js";
import { RteAiAssistant as G } from "./index-RteAiAssistant.js";
import { RteLinkEditor as K } from "./index-RteLinkEditor.js";
import { RteToolbar as W } from "./index-RteToolbar.js";
const Eo = (x) => {
  const {
    id: s = "RichTextEditor",
    defaultValue: m,
    value: c,
    onChange: d,
    onFocus: P,
    onBlur: h,
    placeholder: u,
    toolbarPortalElem: a,
    toolbarContainerClassName: b,
    useAiAssistant: C = !1,
    keywords: T,
    keywordsToInclude: I
  } = x, [i, k] = n(), [p, E] = n(!1), [f, L] = n(a);
  return _(() => L(a), [a]), o(A.LexicalComposer, {
    initialConfig: D,
    children: g(S, {
      className: y(e.container, "vanguard-rich-text-editor-jump-reset notranslate"),
      testId: s,
      id: s,
      children: [o("div", {
        className: e.toolbar,
        ref: (t) => !f && t && L(t)
      }), g("div", {
        className: e.editorWrapper,
        ref: (t) => !i && t && k(t),
        children: [o(w.RichTextPlugin, {
          ErrorBoundary: R,
          contentEditable: o("div", {
            className: e.scroller,
            children: o("div", {
              className: e.editor,
              children: o(F.ContentEditable, {
                className: e.contentEditable,
                id: "yourContentEditableElementId"
              })
            })
          }),
          placeholder: u ? o("p", {
            className: e.placeholder,
            children: j.get(u).value
          }) : null
        }), o(W, {
          className: b,
          toolbarPortalElem: f ?? null,
          isLinkEditMode: p,
          setIsLinkEditMode: E
        }), m ? o(r.DefaultValuePlugin, {
          defaultValue: m
        }) : o(l, {}), c ? o(r.ControlledValuePlugin, {
          value: c
        }) : o(l, {}), C && i ? o(G, {
          anchorElem: i,
          keywordsToInclude: I ?? []
        }) : o(l, {}), o(r.HyperlinkPlugin, {}), i ? o(K, {
          anchorElem: i,
          isLinkEditMode: p,
          setIsLinkEditMode: E
        }) : o(l, {}), o(r.OnFocusOnBlurPlugin, {
          onFocus: P,
          onBlur: h
        }), o(r.OnChangeContentPlugin, {
          onHtmlChange: (t, N) => {
            d && d(t, N);
          }
        }), o(r.KeywordPlugin, {
          phrases: T
        }), o(O.TabIndentationPlugin, {}), o(M.HistoryPlugin, {}), o(B.ListPlugin, {}), o(V.TablePlugin, {}), o(H.HashtagPlugin, {}), o(v.AutoFocusPlugin, {})]
      })]
    })
  });
};
export {
  Eo as RichTextEditor
};
