import { __exports as s } from "./index-LexicalRichTextPlugin.dev2.js";
import { __require as v } from "./index-LexicalComposerContext2.js";
import { __require as D } from "./index-useLexicalEditable.js";
import T from "react";
import { __require as b } from "./index-LexicalText.js";
import { __require as U } from "./index-LexicalUtils.js";
import M from "react-dom";
import { __require as O } from "./index-LexicalDragon.js";
import { __require as K } from "./index-LexicalRichText2.js";
var p;
function J() {
  if (p) return s;
  p = 1;
  var l = v(), _ = D(), r = T, g = b(), f = U(), m = M, E = O(), L = K(), c = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u" ? r.useLayoutEffect : r.useEffect;
  function h(e) {
    return e.getEditorState().read(g.$canShowPlaceholderCurry(e.isComposing()));
  }
  function C(e) {
    const [o, n] = r.useState(() => h(e));
    return c(() => {
      function t() {
        const a = h(e);
        n(a);
      }
      return t(), f.mergeRegister(e.registerUpdateListener(() => {
        t();
      }), e.registerEditableListener(() => {
        t();
      }));
    }, [e]), o;
  }
  function S(e, o) {
    const [n, t] = r.useState(() => e.getDecorators());
    return c(() => e.registerDecoratorListener((a) => {
      m.flushSync(() => {
        t(a);
      });
    }), [e]), r.useEffect(() => {
      t(e.getDecorators());
    }, [e]), r.useMemo(() => {
      const a = [], d = Object.keys(n);
      for (let u = 0; u < d.length; u++) {
        const i = d[u], y = /* @__PURE__ */ r.createElement(o, {
          onError: (R) => e._onError(R)
        }, /* @__PURE__ */ r.createElement(r.Suspense, {
          fallback: null
        }, n[i])), x = e.getElementByKey(i);
        x !== null && a.push(/* @__PURE__ */ m.createPortal(y, x, i));
      }
      return a;
    }, [o, n, e]);
  }
  function P(e) {
    c(() => f.mergeRegister(L.registerRichText(e), E.registerDragonSupport(e)), [e]);
  }
  function w({
    contentEditable: e,
    placeholder: o,
    ErrorBoundary: n
  }) {
    const [t] = l.useLexicalComposerContext(), a = S(t, n);
    return P(t), /* @__PURE__ */ r.createElement(r.Fragment, null, e, /* @__PURE__ */ r.createElement(q, {
      content: o
    }), a);
  }
  function q({
    content: e
  }) {
    const [o] = l.useLexicalComposerContext(), n = C(o), t = _();
    return n ? typeof e == "function" ? e(t) : e : null;
  }
  return s.RichTextPlugin = w, s;
}
export {
  J as __require
};
