/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
'use strict';var b=require("@lexical/react/LexicalComposerContext"),h=require("@lexical/react/useLexicalEditable"),l=require("react"),m=require("@lexical/text"),n=require("@lexical/utils"),p=require("react-dom"),r=require("@lexical/dragon"),t=require("@lexical/plain-text"),u="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?l.useLayoutEffect:l.useEffect;
function v(a){return a.getEditorState().read(m.$canShowPlaceholderCurry(a.isComposing()))}function w(a){let [d,c]=l.useState(()=>v(a));u(()=>{function e(){let f=v(a);c(f)}e();return n.mergeRegister(a.registerUpdateListener(()=>{e()}),a.registerEditableListener(()=>{e()}))},[a]);return d}
function x(a,d){let [c,e]=l.useState(()=>a.getDecorators());u(()=>a.registerDecoratorListener(f=>{p.flushSync(()=>{e(f)})}),[a]);l.useEffect(()=>{e(a.getDecorators())},[a]);return l.useMemo(()=>{let f=[],q=Object.keys(c);for(let k=0;k<q.length;k++){var g=q[k];let z=l.createElement(d,{onError:y=>a._onError(y)},l.createElement(l.Suspense,{fallback:null},c[g]));g=a.getElementByKey(g);null!==g&&f.push(p.createPortal(z,g))}return f},[d,c,a])}
function A(a){u(()=>n.mergeRegister(t.registerPlainText(a),r.registerDragonSupport(a)),[a])}function B({content:a}){var [d]=b.useLexicalComposerContext();d=w(d);let c=h();return d?"function"===typeof a?a(c):a:null}exports.PlainTextPlugin=function({contentEditable:a,placeholder:d,ErrorBoundary:c}){let [e]=b.useLexicalComposerContext();c=x(e,c);A(e);return l.createElement(l.Fragment,null,a,l.createElement(B,{content:d}),c)}
