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