lexical 0.14.2 → 0.14.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ function t(t){return{}}const e={},n={},r={},i={},s={},o={},l={},c={},u={},a={},f={},d={},h={},g={},_={},p={},y={},m={},x={},v={},T={},S={},k={},C={},b={},N={},w={},E={},P={},D={},F={},I={},O={},L={},A={},M={},W={},z={},B={},R={},K={},J={},U={},V={},$={};var H=function(t){const e=new URLSearchParams;e.append("code",t);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${t}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)};const j="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,q=j&&"documentMode"in document?document.documentMode:null,Q=j&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),X=j&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Y=!(!j||!("InputEvent"in window)||q)&&"getTargetRanges"in new window.InputEvent("input"),Z=j&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),G=j&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,tt=j&&/Android/.test(navigator.userAgent),et=j&&/^(?=.*Chrome).*/i.test(navigator.userAgent),nt=j&&tt&&et,rt=j&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!et,it=1,st=3,ot=0,lt=1,ct=2,ut=0,at=1,ft=2,dt=4,ht=8,gt=240|(3|dt|ht),_t=1,pt=2,yt=3,mt=4,xt=5,vt=6,Tt=Z||G||rt?" ":"​",St="\n\n",kt=X?" ":Tt,Ct="֑-߿יִ-﷽ﹰ-ﻼ",bt="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",Nt=new RegExp("^[^"+bt+"]*["+Ct+"]"),wt=new RegExp("^[^"+Ct+"]*["+bt+"]"),Et={bold:1,code:16,highlight:128,italic:2,strikethrough:dt,subscript:32,superscript:64,underline:ht},Pt={directionless:1,unmergeable:2},Dt={center:pt,end:vt,justify:mt,left:_t,right:yt,start:xt},Ft={[pt]:"center",[vt]:"end",[mt]:"justify",[_t]:"left",[yt]:"right",[xt]:"start"},It={normal:0,segmented:2,token:1},Ot={[ut]:"normal",[ft]:"segmented",[at]:"token"};function Lt(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}const At=100;let Mt=!1,Wt=0;function zt(t){Wt=t.timeStamp}function Bt(t,e,n){return e.__lexicalLineBreak===t||void 0!==t[`__lexicalKey_${n._key}`]}function Rt(t,e,n){const r=on(n._window);let i=null,s=null;null!==r&&r.anchorNode===t&&(i=r.anchorOffset,s=r.focusOffset);const o=t.nodeValue;null!==o&&Ne(e,o,i,s,!1)}function Kt(t,e,n){if(ti(t)){const e=t.anchor.getNode();if(e.is(n)&&t.format!==e.getFormat())return!1}return e.nodeType===st&&n.isAttached()}function Jt(t,e,n){Mt=!0;const r=performance.now()-Wt>At;try{Qi(t,(()=>{const i=pi()||function(t){return t.getEditorState().read((()=>{const t=pi();return null!==t?t.clone():null}))}(t),s=new Map,o=t.getRootElement(),l=t._editorState,c=t._blockCursorElement;let u=!1,a="";for(let n=0;n<e.length;n++){const f=e[n],d=f.type,h=f.target;let g=he(h,l);if(!(null===g&&h!==o||Yi(g)))if("characterData"===d)r&&Ur(g)&&Kt(i,h,g)&&Rt(h,g,t);else if("childList"===d){u=!0;const e=f.addedNodes;for(let n=0;n<e.length;n++){const r=e[n],i=de(r),s=r.parentNode;if(null!=s&&r!==c&&null===i&&("BR"!==r.nodeName||!Bt(r,s,t))){if(X){const t=r.innerText||r.nodeValue;t&&(a+=t)}s.removeChild(r)}}const n=f.removedNodes,r=n.length;if(r>0){let e=0;for(let i=0;i<r;i++){const r=n[i];("BR"===r.nodeName&&Bt(r,h,t)||c===r)&&(h.appendChild(r),e++)}r!==e&&(h===o&&(g=ye(l)),s.set(h,g))}}}if(s.size>0)for(const[e,n]of s)if(Gi(n)){const r=n.getChildrenKeys();let i=e.firstChild;for(let n=0;n<r.length;n++){const s=r[n],o=t.getElementByKey(s);null!==o&&(null==i?(e.appendChild(o),i=o):i!==o&&e.replaceChild(o,i),i=i.nextSibling)}}else Ur(n)&&n.markDirty();const f=n.takeRecords();if(f.length>0){for(let e=0;e<f.length;e++){const n=f[e],r=n.addedNodes,i=n.target;for(let e=0;e<r.length;e++){const n=r[e],s=n.parentNode;null==s||"BR"!==n.nodeName||Bt(n,i,t)||s.removeChild(n)}}n.takeRecords()}null!==i&&(u&&(i.dirty=!0,me(i)),X&&Ke(t)&&i.insertRawText(a))}))}finally{Mt=!1}}function Ut(t){const e=t._observer;if(null!==e){Jt(t,e.takeRecords(),e)}}function Vt(t){!function(t){0===Wt&&Qe(t).addEventListener("textInput",zt,!0)}(t),t._observer=new MutationObserver(((e,n)=>{Jt(t,e,n)}))}function $t(t,e){const n=t.__mode,r=t.__format,i=t.__style,s=e.__mode,o=e.__format,l=e.__style;return!(null!==n&&n!==s||null!==r&&r!==o||null!==i&&i!==l)}function Ht(t,e){const n=t.mergeWithSibling(e),r=Wi()._normalizedNodes;return r.add(t.__key),r.add(e.__key),n}function jt(t){let e,n,r=t;if(""!==r.__text||!r.isSimpleText()||r.isUnmergeable()){for(;null!==(e=r.getPreviousSibling())&&Ur(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(""!==e.__text){if($t(e,r)){r=Ht(e,r);break}break}e.remove()}for(;null!==(n=r.getNextSibling())&&Ur(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(""!==n.__text){if($t(r,n)){r=Ht(r,n);break}break}n.remove()}}else r.remove()}function qt(t){return Qt(t.anchor),Qt(t.focus),t}function Qt(t){for(;"element"===t.type;){const e=t.getNode(),n=t.offset;let r,i;if(n===e.getChildrenSize()?(r=e.getChildAtIndex(n-1),i=!0):(r=e.getChildAtIndex(n),i=!1),Ur(r)){t.set(r.__key,i?r.getTextContentSize():0,"text");break}if(!Gi(r))break;t.set(r.__key,i?r.getChildrenSize():0,"element")}}let Xt=1;const Yt="function"==typeof queueMicrotask?queueMicrotask:t=>{Promise.resolve().then(t)};function Zt(t){const e=document.activeElement;if(null===e)return!1;const n=e.nodeName;return Yi(he(t))&&("INPUT"===n||"TEXTAREA"===n||"true"===e.contentEditable&&null==e.__lexicalEditor)}function Gt(t,e,n){const r=t.getRootElement();try{return null!==r&&r.contains(e)&&r.contains(n)&&null!==e&&!Zt(e)&&te(e)===t}catch(t){return!1}}function te(t){let e=t;for(;null!=e;){const t=e.__lexicalEditor;if(null!=t)return t;e=$e(e)}return null}function ee(t){return t.isToken()||t.isSegmented()}function ne(t){return t.nodeType===st}function re(t){let e=t;for(;null!=e;){if(ne(e))return e;e=e.firstChild}return null}function ie(t,e,n){const r=Et[e];if(null!==n&&(t&r)==(n&r))return t;let i=t^r;return"subscript"===e?i&=~Et.superscript:"superscript"===e&&(i&=~Et.subscript),i}function se(t){return Ur(t)||Cr(t)||Yi(t)}function oe(t,e){if(null!=e)return void(t.__key=e);Li(),Ai();const n=Wi(),r=Mi(),i=""+Xt++;r._nodeMap.set(i,t),Gi(t)?n._dirtyElements.set(i,!0):n._dirtyLeaves.add(i),n._cloneNotNeeded.add(i),n._dirtyType=lt,t.__key=i}function le(t){const e=t.getParent();if(null!==e){const n=t.getWritable(),r=e.getWritable(),i=t.getPreviousSibling(),s=t.getNextSibling();if(null===i)if(null!==s){const t=s.getWritable();r.__first=s.__key,t.__prev=null}else r.__first=null;else{const t=i.getWritable();if(null!==s){const e=s.getWritable();e.__prev=t.__key,t.__next=e.__key}else t.__next=null;n.__prev=null}if(null===s)if(null!==i){const t=i.getWritable();r.__last=i.__key,t.__next=null}else r.__last=null;else{const t=s.getWritable();if(null!==i){const e=i.getWritable();e.__next=t.__key,t.__prev=e.__key}else t.__prev=null;n.__next=null}r.__size--,n.__parent=null}}function ce(t){Ai();const e=t.getLatest(),n=e.__parent,r=Mi(),i=Wi(),s=r._nodeMap,o=i._dirtyElements;null!==n&&function(t,e,n){let r=t;for(;null!==r;){if(n.has(r))return;const t=e.get(r);if(void 0===t)break;n.set(r,!1),r=t.__parent}}(n,s,o);const l=e.__key;i._dirtyType=lt,Gi(t)?o.set(l,!0):i._dirtyLeaves.add(l)}function ue(t){Li();const e=Wi(),n=e._compositionKey;if(t!==n){if(e._compositionKey=t,null!==n){const t=fe(n);null!==t&&t.getWritable()}if(null!==t){const e=fe(t);null!==e&&e.getWritable()}}}function ae(){if(Oi())return null;return Wi()._compositionKey}function fe(t,e){const n=(e||Mi())._nodeMap.get(t);return void 0===n?null:n}function de(t,e){const n=t[`__lexicalKey_${Wi()._key}`];return void 0!==n?fe(n,e):null}function he(t,e){let n=t;for(;null!=n;){const t=de(n,e);if(null!==t)return t;n=$e(n)}return null}function ge(t){const e=t._decorators,n=Object.assign({},e);return t._pendingDecorators=n,n}function _e(t){return t.read((()=>pe().getTextContent()))}function pe(){return ye(Mi())}function ye(t){return t._nodeMap.get("root")}function me(t){Li();const e=Mi();null!==t&&(t.dirty=!0,t.setCachedNodes(null)),e._selection=t}function xe(t){const e=Wi(),n=function(t,e){let n=t;for(;null!=n;){const t=n[`__lexicalKey_${e._key}`];if(void 0!==t)return t;n=$e(n)}return null}(t,e);if(null===n){return t===e.getRootElement()?fe("root"):null}return fe(n)}function ve(t,e){return e?t.getTextContentSize():0}function Te(t){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(t)}function Se(t){const e=[];let n=t;for(;null!==n;)e.push(n),n=n._parentEditor;return e}function ke(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function Ce(t){return t.nodeType===st?t.nodeValue:null}function be(t,e,n){const r=on(e._window);if(null===r)return;const i=r.anchorNode;let{anchorOffset:s,focusOffset:o}=r;if(null!==i){let e=Ce(i);const r=he(i);if(null!==e&&Ur(r)){if(e===Tt&&n){const t=n.length;e=n,s=t,o=t}null!==e&&Ne(r,e,s,o,t)}}}function Ne(t,e,n,r,i){let s=t;if(s.isAttached()&&(i||!s.isDirty())){const o=s.isComposing();let l=e;(o||i)&&e[e.length-1]===Tt&&(l=e.slice(0,-1));const c=s.getTextContent();if(i||l!==c){if(""===l){if(ue(null),Z||G||rt)s.remove();else{const t=Wi();setTimeout((()=>{t.update((()=>{s.isAttached()&&s.remove()}))}),20)}return}const e=s.getParent(),i=yi(),c=s.getTextContentSize(),u=ae(),a=s.getKey();if(s.isToken()||null!==u&&a===u&&!o||ti(i)&&(null!==e&&!e.canInsertTextBefore()&&0===i.anchor.offset||i.anchor.key===t.__key&&0===i.anchor.offset&&!s.canInsertTextBefore()&&!o||i.focus.key===t.__key&&i.focus.offset===c&&!s.canInsertTextAfter()&&!o))return void s.markDirty();const f=pi();if(!ti(f)||null===n||null===r)return void s.setTextContent(l);if(f.setTextNodeRange(s,n,s,r),s.isSegmented()){const t=Jr(s.getTextContent());s.replace(t),s=t}s.setTextContent(l)}}}function we(t,e){if(e.isSegmented())return!0;if(!t.isCollapsed())return!1;const n=t.anchor.offset,r=e.getParentOrThrow(),i=e.isToken();return 0===n?!e.canInsertTextBefore()||!r.canInsertTextBefore()&&!e.isComposing()||i||function(t){const e=t.getPreviousSibling();return(Ur(e)||Gi(e)&&e.isInline())&&!e.canInsertTextAfter()}(e):n===e.getTextContentSize()&&(!e.canInsertTextAfter()||!r.canInsertTextAfter()&&!e.isComposing()||i)}function Ee(t){return 37===t}function Pe(t){return 39===t}function De(t,e){return Q?t:e}function Fe(t){return 13===t}function Ie(t){return 8===t}function Oe(t){return 46===t}function Le(t,e,n){return 65===t&&De(e,n)}function Ae(){const t=pe();me(qt(t.select(0,t.getChildrenSize())))}function Me(t,e){void 0===t.__lexicalClassNameCache&&(t.__lexicalClassNameCache={});const n=t.__lexicalClassNameCache,r=n[e];if(void 0!==r)return r;const i=t[e];if("string"==typeof i){const t=Lt(i);return n[e]=t,t}return i}function We(t,e,n,r,i){if(0===n.size)return;const s=r.__type,o=r.__key,l=e.get(s);void 0===l&&H(33,s);const c=l.klass;let u=t.get(c);void 0===u&&(u=new Map,t.set(c,u));const a=u.get(o),f="destroyed"===a&&"created"===i;(void 0===a||f)&&u.set(o,f?"updated":i)}function ze(t){const e=Mi(),n=e._readOnly,r=t.getType(),i=e._nodeMap,s=[];for(const[,e]of i)e instanceof t&&e.__type===r&&(n||e.isAttached())&&s.push(e);return s}function Be(t,e,n){const r=t.getParent();let i=n,s=t;return null!==r&&(e&&0===n?(i=s.getIndexWithinParent(),s=r):e||n!==s.getChildrenSize()||(i=s.getIndexWithinParent()+1,s=r)),s.getChildAtIndex(e?i-1:i)}function Re(t,e){const n=t.offset;if("element"===t.type){return Be(t.getNode(),e,n)}{const r=t.getNode();if(e&&0===n||!e&&n===r.getTextContentSize()){const t=e?r.getPreviousSibling():r.getNextSibling();return null===t?Be(r.getParentOrThrow(),e,r.getIndexWithinParent()+(e?0:1)):t}}return null}function Ke(t){const e=Qe(t).event,n=e&&e.inputType;return"insertFromPaste"===n||"insertFromPasteAsQuotation"===n}function Je(t,e,n){return Hi(t,e,n)}function Ue(t){return!ns(t)&&!t.isLastChild()&&!t.isInline()}function Ve(t,e){const n=t._keyToDOMMap.get(e);return void 0===n&&H(75,e),n}function $e(t){const e=t.assignedSlot||t.parentElement;return null!==e&&11===e.nodeType?e.host:e}function He(t){return Wi()._updateTags.has(t)}function je(t){Li();Wi()._updateTags.add(t)}function qe(t,e){let n=t.getParent();for(;null!==n;){if(n.is(e))return!0;n=n.getParent()}return!1}function Qe(t){const e=t._window;return null===e&&H(78),e}function Xe(t){return Gi(t)&&t.isInline()||Yi(t)&&t.isInline()}function Ye(t){let e=t.getParentOrThrow();for(;null!==e;){if(Ze(e))return e;e=e.getParentOrThrow()}return e}function Ze(t){return ns(t)||Gi(t)&&t.isShadowRoot()}function Ge(t){const e=t.constructor.clone(t);return oe(e,null),e}function tn(t){const e=Wi(),n=t.constructor.getType(),r=e._nodes.get(n);void 0===r&&H(97);const i=r.replace;if(null!==i){const e=i(t);return e instanceof t.constructor||H(98),e}return t}function en(t,e){!ns(t.getParent())||Gi(e)||Yi(e)||H(99)}function nn(t){return(Yi(t)||Gi(t)&&!t.canBeEmpty())&&!t.isInline()}function rn(t,e,n){n.style.removeProperty("caret-color"),e._blockCursorElement=null;const r=t.parentElement;null!==r&&r.removeChild(t)}function sn(t,e,n){let r=t._blockCursorElement;if(ti(n)&&n.isCollapsed()&&"element"===n.anchor.type&&e.contains(document.activeElement)){const i=n.anchor,s=i.getNode(),o=i.offset;let l=!1,c=null;if(o===s.getChildrenSize()){nn(s.getChildAtIndex(o-1))&&(l=!0)}else{const e=s.getChildAtIndex(o);if(nn(e)){const n=e.getPreviousSibling();(null===n||nn(n))&&(l=!0,c=t.getElementByKey(e.__key))}}if(l){const n=t.getElementByKey(s.__key);return null===r&&(t._blockCursorElement=r=function(t){const e=t.theme,n=document.createElement("div");n.contentEditable="false",n.setAttribute("data-lexical-cursor","true");let r=e.blockCursor;if(void 0!==r){if("string"==typeof r){const t=Lt(r);r=e.blockCursor=t}void 0!==r&&n.classList.add(...r)}return n}(t._config)),e.style.caretColor="transparent",void(null===c?n.appendChild(r):n.insertBefore(r,c))}}null!==r&&rn(r,t,e)}function on(t){return j?(t||window).getSelection():null}function ln(t,e){let n=t.getChildAtIndex(e);null==n&&(n=t),Ze(t)&&H(102);const r=t=>{const e=t.getParentOrThrow(),i=Ze(e),s=t!==n||i?Ge(t):t;if(i)return Gi(t)&&Gi(s)||H(133),t.insertAfter(s),[t,s,s];{const[n,i,o]=r(e),l=t.getNextSiblings();return o.append(s,...l),[n,i,s]}},[i,s]=r(n);return[i,s]}function cn(t){return un(t)&&"A"===t.tagName}function un(t){return 1===t.nodeType}function an(t){if(Yi(t)&&!t.isInline())return!0;if(!Gi(t)||Ze(t))return!1;const e=t.getFirstChild(),n=null===e||Cr(e)||Ur(e)||e.isInline();return!t.isInline()&&!1!==t.canBeEmpty()&&n}function fn(t,e){let n=t;for(;null!==n&&null!==n.getParent()&&!e(n);)n=n.getParentOrThrow();return e(n)?n:null}function dn(){return Wi()}function hn(t,e,n,r,i,s){let o=t.getFirstChild();for(;null!==o;){const t=o.__key;o.__parent===e&&(Gi(o)&&hn(o,t,n,r,i,s),n.has(t)||s.delete(t),i.push(t)),o=o.getNextSibling()}}let gn,_n,pn,yn,mn,xn,vn,Tn,Sn,kn,Cn="",bn="",Nn=null,wn="",En=!1,Pn=!1,Dn=null;function Fn(t,e){const n=vn.get(t);if(null!==e){const n=qn(t);n.parentNode===e&&e.removeChild(n)}if(Tn.has(t)||_n._keyToDOMMap.delete(t),Gi(n)){const t=Un(n,vn);In(t,0,t.length-1,null)}void 0!==n&&We(kn,pn,yn,n,"destroyed")}function In(t,e,n,r){let i=e;for(;i<=n;++i){const e=t[i];void 0!==e&&Fn(e,r)}}function On(t,e){t.setProperty("text-align",e)}const Ln="40px";function An(t,e){const n=gn.theme.indent;if("string"==typeof n){const r=t.classList.contains(n);e>0&&!r?t.classList.add(n):e<1&&r&&t.classList.remove(n)}const r=getComputedStyle(t).getPropertyValue("--lexical-indent-base-value")||Ln;t.style.setProperty("padding-inline-start",0===e?"":`calc(${e} * ${r})`)}function Mn(t,e){const n=t.style;0===e?On(n,""):e===_t?On(n,"left"):e===pt?On(n,"center"):e===yt?On(n,"right"):e===mt?On(n,"justify"):e===xt?On(n,"start"):e===vt&&On(n,"end")}function Wn(t,e,n){const r=Tn.get(t);void 0===r&&H(60);const i=r.createDOM(gn,_n);if(function(t,e,n){const r=n._keyToDOMMap;e["__lexicalKey_"+n._key]=t,r.set(t,e)}(t,i,_n),Ur(r)?i.setAttribute("data-lexical-text","true"):Yi(r)&&i.setAttribute("data-lexical-decorator","true"),Gi(r)){const t=r.__indent,e=r.__size;if(0!==t&&An(i,t),0!==e){const t=e-1;!function(t,e,n,r){const i=bn;bn="",zn(t,n,0,e,r,null),Kn(n,r),bn=i}(Un(r,Tn),t,r,i)}const n=r.__format;0!==n&&Mn(i,n),r.isInline()||Rn(null,r,i),Ue(r)&&(Cn+=St,wn+=St)}else{const e=r.getTextContent();if(Yi(r)){const e=r.decorate(_n,gn);null!==e&&$n(t,e),i.contentEditable="false"}else Ur(r)&&(r.isDirectionless()||(bn+=e));Cn+=e,wn+=e}if(null!==e)if(null!=n)e.insertBefore(i,n);else{const t=e.__lexicalLineBreak;null!=t?e.insertBefore(i,t):e.appendChild(i)}return We(kn,pn,yn,r,"created"),i}function zn(t,e,n,r,i,s){const o=Cn;Cn="";let l=n;for(;l<=r;++l){Wn(t[l],i,s);const e=Tn.get(t[l]);null!==e&&null===Nn&&Ur(e)&&(Nn=e.getFormat())}Ue(e)&&(Cn+=St),i.__lexicalTextContent=Cn,Cn=o+Cn}function Bn(t,e){const n=e.get(t);return Cr(n)||Yi(n)&&n.isInline()}function Rn(t,e,n){const r=null!==t&&(0===t.__size||Bn(t.__last,vn)),i=0===e.__size||Bn(e.__last,Tn);if(r){if(!i){const t=n.__lexicalLineBreak;null!=t&&n.removeChild(t),n.__lexicalLineBreak=null}}else if(i){const t=document.createElement("br");n.__lexicalLineBreak=t,n.appendChild(t)}}function Kn(t,e){const n=e.__lexicalDirTextContent,r=e.__lexicalDir;if(n!==bn||r!==Dn){const n=""===bn,s=n?Dn:(i=bn,Nt.test(i)?"rtl":wt.test(i)?"ltr":null);if(s!==r){const i=e.classList,o=gn.theme;let l=null!==r?o[r]:void 0,c=null!==s?o[s]:void 0;if(void 0!==l){if("string"==typeof l){const t=Lt(l);l=o[r]=t}i.remove(...l)}if(null===s||n&&"ltr"===s)e.removeAttribute("dir");else{if(void 0!==c){if("string"==typeof c){const t=Lt(c);c=o[s]=t}void 0!==c&&i.add(...c)}e.dir=s}if(!Pn){t.getWritable().__dir=s}}Dn=s,e.__lexicalDirTextContent=bn,e.__lexicalDir=s}var i}function Jn(t,e,n){const r=bn;var i;bn="",Nn=null,function(t,e,n){const r=Cn,i=t.__size,s=e.__size;if(Cn="",1===i&&1===s){const r=t.__first,i=e.__first;if(r===i)Vn(r,n);else{const t=qn(r),e=Wn(i,null,null);n.replaceChild(e,t),Fn(r,null)}const s=Tn.get(i);null===Nn&&Ur(s)&&(Nn=s.getFormat())}else{const r=Un(t,vn),o=Un(e,Tn);if(0===i)0!==s&&zn(o,e,0,s-1,n,null);else if(0===s){if(0!==i){const t=null==n.__lexicalLineBreak;In(r,0,i-1,t?null:n),t&&(n.textContent="")}}else!function(t,e,n,r,i,s){const o=r-1,l=i-1;let c,u,a=(h=s,h.firstChild),f=0,d=0;var h;for(;f<=o&&d<=l;){const t=e[f],r=n[d];if(t===r)a=Hn(Vn(r,s)),f++,d++;else{void 0===c&&(c=new Set(e)),void 0===u&&(u=new Set(n));const i=u.has(t),o=c.has(r);if(i)if(o){const t=Ve(_n,r);t===a?a=Hn(Vn(r,s)):(null!=a?s.insertBefore(t,a):s.appendChild(t),Vn(r,s)),f++,d++}else Wn(r,s,a),d++;else a=Hn(qn(t)),Fn(t,s),f++}const i=Tn.get(r);null!==i&&null===Nn&&Ur(i)&&(Nn=i.getFormat())}const g=f>o,_=d>l;if(g&&!_){const e=n[l+1];zn(n,t,d,l,s,void 0===e?null:_n.getElementByKey(e))}else _&&!g&&In(e,f,o,s)}(e,r,o,i,s,n)}Ue(e)&&(Cn+=St);n.__lexicalTextContent=Cn,Cn=r+Cn}(t,e,n),Kn(e,n),us(i=e)&&null!=Nn&&Nn!==i.__textFormat&&i.setTextFormat(Nn),bn=r,Nn=null}function Un(t,e){const n=[];let r=t.__first;for(;null!==r;){const t=e.get(r);void 0===t&&H(101),n.push(r),r=t.__next}return n}function Vn(t,e){const n=vn.get(t);let r=Tn.get(t);void 0!==n&&void 0!==r||H(61);const i=En||xn.has(t)||mn.has(t),s=Ve(_n,t);if(n===r&&!i){if(Gi(n)){const t=s.__lexicalTextContent;void 0!==t&&(Cn+=t,wn+=t);const e=s.__lexicalDirTextContent;void 0!==e&&(bn+=e)}else{const t=n.getTextContent();Ur(n)&&!n.isDirectionless()&&(bn+=t),wn+=t,Cn+=t}return s}if(n!==r&&i&&We(kn,pn,yn,r,"updated"),r.updateDOM(n,s,gn)){const n=Wn(t,null,null);return null===e&&H(62),e.replaceChild(n,s),Fn(t,null),n}if(Gi(n)&&Gi(r)){const t=r.__indent;t!==n.__indent&&An(s,t);const e=r.__format;e!==n.__format&&Mn(s,e),i&&(Jn(n,r,s),ns(r)||r.isInline()||Rn(n,r,s)),Ue(r)&&(Cn+=St,wn+=St)}else{const e=r.getTextContent();if(Yi(r)){const e=r.decorate(_n,gn);null!==e&&$n(t,e)}else Ur(r)&&!r.isDirectionless()&&(bn+=e);Cn+=e,wn+=e}if(!Pn&&ns(r)&&r.__cachedText!==wn){const t=r.getWritable();t.__cachedText=wn,r=t}return s}function $n(t,e){let n=_n._pendingDecorators;const r=_n._decorators;if(null===n){if(r[t]===e)return;n=ge(_n)}n[t]=e}function Hn(t){let e=t.nextSibling;return null!==e&&e===_n._blockCursorElement&&(e=e.nextSibling),e}function jn(t,e,n,r,i,s){Cn="",wn="",bn="",En=r===ct,Dn=null,_n=n,gn=n._config,pn=n._nodes,yn=_n._listeners.mutation,mn=i,xn=s,vn=t._nodeMap,Tn=e._nodeMap,Pn=e._readOnly,Sn=new Map(n._keyToDOMMap);const o=new Map;return kn=o,Vn("root",null),_n=void 0,pn=void 0,mn=void 0,xn=void 0,vn=void 0,Tn=void 0,gn=void 0,Sn=void 0,kn=void 0,o}function qn(t){const e=Sn.get(t);return void 0===e&&H(75,t),e}const Qn=Object.freeze({}),Xn=30,Yn=[["keydown",function(t,e){if(Zn=t.timeStamp,Gn=t.keyCode,e.isComposing())return;const{keyCode:n,shiftKey:r,ctrlKey:o,metaKey:l,altKey:c}=t;if(Je(e,_,t))return;if(function(t,e,n,r){return Pe(t)&&!e&&!r&&!n}(n,o,c,l))Je(e,p,t);else if(function(t,e,n,r,i){return Pe(t)&&!r&&!n&&(e||i)}(n,o,r,c,l))Je(e,y,t);else if(function(t,e,n,r){return Ee(t)&&!e&&!r&&!n}(n,o,c,l))Je(e,m,t);else if(function(t,e,n,r,i){return Ee(t)&&!r&&!n&&(e||i)}(n,o,r,c,l))Je(e,x,t);else if(function(t,e,n){return function(t){return 38===t}(t)&&!e&&!n}(n,o,l))Je(e,v,t);else if(function(t,e,n){return function(t){return 40===t}(t)&&!e&&!n}(n,o,l))Je(e,T,t);else if(function(t,e){return Fe(t)&&e}(n,r))sr=!0,Je(e,S,t);else if(function(t){return 32===t}(n))Je(e,k,t);else if(function(t,e){return Q&&e&&79===t}(n,o))t.preventDefault(),sr=!0,Je(e,s,!0);else if(function(t,e){return Fe(t)&&!e}(n,r))sr=!1,Je(e,S,t);else if(function(t,e,n,r){return Q?!e&&!n&&(Ie(t)||72===t&&r):!(r||e||n)&&Ie(t)}(n,c,l,o))Ie(n)?Je(e,C,t):(t.preventDefault(),Je(e,i,!0));else if(function(t){return 27===t}(n))Je(e,b,t);else if(function(t,e,n,r,i){return Q?!(n||r||i)&&(Oe(t)||68===t&&e):!(e||r||i)&&Oe(t)}(n,o,r,c,l))Oe(n)?Je(e,N,t):(t.preventDefault(),Je(e,i,!1));else if(function(t,e,n){return Ie(t)&&(Q?e:n)}(n,c,o))t.preventDefault(),Je(e,a,!0);else if(function(t,e,n){return Oe(t)&&(Q?e:n)}(n,c,o))t.preventDefault(),Je(e,a,!1);else if(function(t,e){return Q&&e&&Ie(t)}(n,l))t.preventDefault(),Je(e,f,!0);else if(function(t,e){return Q&&e&&Oe(t)}(n,l))t.preventDefault(),Je(e,f,!1);else if(function(t,e,n,r){return 66===t&&!e&&De(n,r)}(n,c,l,o))t.preventDefault(),Je(e,d,"bold");else if(function(t,e,n,r){return 85===t&&!e&&De(n,r)}(n,c,l,o))t.preventDefault(),Je(e,d,"underline");else if(function(t,e,n,r){return 73===t&&!e&&De(n,r)}(n,c,l,o))t.preventDefault(),Je(e,d,"italic");else if(function(t,e,n,r){return 9===t&&!e&&!n&&!r}(n,c,o,l))Je(e,w,t);else if(function(t,e,n,r){return 90===t&&!e&&De(n,r)}(n,r,l,o))t.preventDefault(),Je(e,h,void 0);else if(function(t,e,n,r){return Q?90===t&&n&&e:89===t&&r||90===t&&r&&e}(n,r,l,o))t.preventDefault(),Je(e,g,void 0);else{ni(e._editorState._selection)?!function(t,e,n,r){return!e&&67===t&&(Q?n:r)}(n,r,l,o)?!function(t,e,n,r){return!e&&88===t&&(Q?n:r)}(n,r,l,o)?Le(n,l,o)&&(t.preventDefault(),Je(e,z,t)):(t.preventDefault(),Je(e,W,t)):(t.preventDefault(),Je(e,M,t)):!X&&Le(n,l,o)&&(t.preventDefault(),Je(e,z,t))}(function(t,e,n,r){return t||e||n||r})(o,r,c,l)&&Je(e,$,t)}],["pointerdown",function(t,e){const n=t.target,r=t.pointerType;n instanceof Node&&"touch"!==r&&Qi(e,(()=>{Yi(he(n))||(ir=!0)}))}],["compositionstart",function(t,e){Qi(e,(()=>{const n=pi();if(ti(n)&&!e.isComposing()){const r=n.anchor,i=n.anchor.getNode();ue(r.key),(t.timeStamp<Zn+Xn||"element"===r.type||!n.isCollapsed()||i.getFormat()!==n.format||Ur(i)&&i.getStyle()!==n.style)&&Je(e,l,kt)}}))}],["compositionend",function(t,e){X?or=!0:Qi(e,(()=>{dr(e,t.data)}))}],["input",function(t,e){t.stopPropagation(),Qi(e,(()=>{const n=pi(),r=t.data,i=fr(t);if(null!=r&&ti(n)&&cr(n,i,r,t.timeStamp,!1)){or&&(dr(e,r),or=!1);const i=n.anchor,s=i.getNode(),o=on(e._window);if(null===o)return;const c=i.offset;Y&&!n.isCollapsed()&&Ur(s)&&null!==o.anchorNode&&s.getTextContent().slice(0,c)+r+s.getTextContent().slice(c+n.focus.offset)===Ce(o.anchorNode)||Je(e,l,r);const u=r.length;X&&u>1&&"insertCompositionText"===t.inputType&&!e.isComposing()&&(n.anchor.offset-=u),Z||G||rt||!e.isComposing()||(Zn=0,ue(null))}else{be(!1,e,null!==r?r:void 0),or&&(dr(e,r||void 0),or=!1)}Li(),Ut(Wi())})),er=null}],["click",function(t,e){Qi(e,(()=>{const n=pi(),i=on(e._window),s=yi();if(i)if(ti(n)){const e=n.anchor,r=e.getNode();if("element"===e.type&&0===e.offset&&n.isCollapsed()&&!ns(r)&&1===pe().getChildrenSize()&&r.getTopLevelElementOrThrow().isEmpty()&&null!==s&&n.is(s))i.removeAllRanges(),n.dirty=!0;else if(3===t.detail&&!n.isCollapsed()){r!==n.focus.getNode()&&(Gi(r)?r.select(0):r.getParentOrThrow().select(0))}}else if("touch"===t.pointerType){const n=i.anchorNode;if(null!==n){const r=n.nodeType;if(r===it||r===st){me(_i(s,i,e,t))}}}Je(e,r,t)}))}],["cut",Qn],["copy",Qn],["dragstart",Qn],["dragover",Qn],["dragend",Qn],["paste",Qn],["focus",Qn],["blur",Qn],["drop",Qn]];Y&&Yn.push(["beforeinput",(t,e)=>function(t,e){const n=t.inputType,r=fr(t);if("deleteCompositionText"===n||X&&Ke(e))return;if("insertCompositionText"===n)return;Qi(e,(()=>{const _=pi();if("deleteContentBackward"===n){if(null===_){const t=yi();if(!ti(t))return;me(t.clone())}if(ti(_)){const n=_.anchor.key===_.focus.key;if(p=t.timeStamp,229===Gn&&p<Zn+Xn&&e.isComposing()&&n){if(ue(null),Zn=0,setTimeout((()=>{Qi(e,(()=>{ue(null)}))}),Xn),ti(_)){const t=_.anchor.getNode();t.markDirty(),_.format=t.getFormat(),Ur(t)||H(142),_.style=t.getStyle()}}else{ue(null),t.preventDefault();const r=_.anchor.getNode().getTextContent(),s=0===_.anchor.offset&&_.focus.offset===r.length;nt&&n&&!s||Je(e,i,!0)}return}}var p;if(!ti(_))return;const y=t.data;null!==er&&be(!1,e,er),_.dirty&&null===er||!_.isCollapsed()||ns(_.anchor.getNode())||null===r||_.applyDOMRange(r),er=null;const m=_.anchor,x=_.focus,v=m.getNode(),T=x.getNode();if("insertText"!==n&&"insertTranspose"!==n)switch(t.preventDefault(),n){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":Je(e,l,t);break;case"insertFromComposition":ue(null),Je(e,l,t);break;case"insertLineBreak":ue(null),Je(e,s,!1);break;case"insertParagraph":ue(null),sr&&!G?(sr=!1,Je(e,s,!1)):Je(e,o,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":Je(e,c,t);break;case"deleteByComposition":(function(t,e){return t!==e||Gi(t)||Gi(e)||!t.isToken()||!e.isToken()})(v,T)&&Je(e,u,t);break;case"deleteByDrag":case"deleteByCut":Je(e,u,t);break;case"deleteContent":Je(e,i,!1);break;case"deleteWordBackward":Je(e,a,!0);break;case"deleteWordForward":Je(e,a,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":Je(e,f,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":Je(e,f,!1);break;case"formatStrikeThrough":Je(e,d,"strikethrough");break;case"formatBold":Je(e,d,"bold");break;case"formatItalic":Je(e,d,"italic");break;case"formatUnderline":Je(e,d,"underline");break;case"historyUndo":Je(e,h,void 0);break;case"historyRedo":Je(e,g,void 0)}else{if("\n"===y)t.preventDefault(),Je(e,s,!1);else if(y===St)t.preventDefault(),Je(e,o,void 0);else if(null==y&&t.dataTransfer){const e=t.dataTransfer.getData("text/plain");t.preventDefault(),_.insertRawText(e)}else null!=y&&cr(_,r,y,t.timeStamp,!0)?(t.preventDefault(),Je(e,l,y)):er=y;tr=t.timeStamp}}))}(t,e)]);let Zn=0,Gn=0,tr=0,er=null;const nr=new WeakMap;let rr=!1,ir=!1,sr=!1,or=!1,lr=[0,"",0,"root",0];function cr(t,e,n,r,i){const s=t.anchor,o=t.focus,l=s.getNode(),c=Wi(),u=on(c._window),a=null!==u?u.anchorNode:null,f=s.key,d=c.getElementByKey(f),h=n.length;return f!==o.key||!Ur(l)||(!i&&(!Y||tr<r+50)||l.isDirty()&&h<2||Te(n))&&s.offset!==o.offset&&!l.isComposing()||ee(l)||l.isDirty()&&h>1||(i||!Y)&&null!==d&&!l.isComposing()&&a!==re(d)||null!==u&&null!==e&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||l.getFormat()!==t.format||l.getStyle()!==t.style||we(t,l)}function ur(t,e){return null!==t&&null!==t.nodeValue&&t.nodeType===st&&0!==e&&e!==t.nodeValue.length}function ar(t,n,r){const{anchorNode:i,anchorOffset:s,focusNode:o,focusOffset:l}=t;rr&&(rr=!1,ur(i,s)&&ur(o,l))||Qi(n,(()=>{if(!r)return void me(null);if(!Gt(n,i,o))return;const c=pi();if(ti(c)){const e=c.anchor,r=e.getNode();if(c.isCollapsed()){"Range"===t.type&&t.anchorNode===t.focusNode&&(c.dirty=!0);const i=Qe(n).event,s=i?i.timeStamp:performance.now(),[o,l,u,a,f]=lr,d=pe(),h=!1===n.isComposing()&&""===d.getTextContent();if(s<f+200&&e.offset===u&&e.key===a)c.format=o,c.style=l;else if("text"===e.type)Ur(r)||H(141),c.format=r.getFormat(),c.style=r.getStyle();else if("element"===e.type&&!h){const t=e.getNode();t instanceof os&&0===t.getChildrenSize()?c.format=t.getTextFormat():c.format=0,c.style=""}}else{const t=e.key,n=c.focus.key,r=c.getNodes(),i=r.length,o=c.isBackward(),u=o?l:s,a=o?s:l,f=o?n:t,d=o?t:n;let h=gt,g=!1;for(let t=0;t<i;t++){const e=r[t],n=e.getTextContentSize();if(Ur(e)&&0!==n&&!(0===t&&e.__key===f&&u===n||t===i-1&&e.__key===d&&0===a)&&(g=!0,h&=e.getFormat(),0===h))break}c.format=g?h:0}}Je(n,e,void 0)}))}function fr(t){if(!t.getTargetRanges)return null;const e=t.getTargetRanges();return 0===e.length?null:e[0]}function dr(t,e){const n=t._compositionKey;if(ue(null),null!==n&&null!=e){if(""===e){const e=fe(n),r=re(t.getElementByKey(n));return void(null!==r&&null!==r.nodeValue&&Ur(e)&&Ne(e,r.nodeValue,null,null,!0))}if("\n"===e[e.length-1]){const e=pi();if(ti(e)){const n=e.focus;return e.anchor.set(n.key,n.offset,n.type),void Je(t,S,null)}}}be(!0,t,e)}function hr(t){let e=t.__lexicalEventHandles;return void 0===e&&(e=[],t.__lexicalEventHandles=e),e}const gr=new Map;function _r(t){const e=t.target,n=on(null==e?null:9===e.nodeType?e.defaultView:e.ownerDocument.defaultView);if(null===n)return;const r=te(n.anchorNode);if(null===r)return;ir&&(ir=!1,Qi(r,(()=>{const e=yi(),i=n.anchorNode;if(null===i)return;const s=i.nodeType;if(s!==it&&s!==st)return;me(_i(e,n,r,t))})));const i=Se(r),s=i[i.length-1],o=s._key,l=gr.get(o),c=l||s;c!==r&&ar(n,c,!1),ar(n,r,!0),r!==s?gr.set(o,r):l&&gr.delete(o)}function pr(t){t._lexicalHandled=!0}function yr(t){return!0===t._lexicalHandled}function mr(t){const e=t.ownerDocument,n=nr.get(e);if(void 0===n)throw Error("Root element not registered");nr.set(e,n-1),0===nr.get(e)&&e.removeEventListener("selectionchange",_r);const r=t.__lexicalEditor;null!=r&&(!function(t){if(null!==t._parentEditor){const e=Se(t),n=e[e.length-1]._key;gr.get(n)===t&&gr.delete(n)}else gr.delete(t._key)}(r),t.__lexicalEditor=null);const i=hr(t);for(let t=0;t<i.length;t++)i[t]();t.__lexicalEventHandles=[]}function xr(t,e,n){Li();const r=t.__key,i=t.getParent();if(null===i)return;const s=function(t){const e=pi();if(!ti(e)||!Gi(t))return e;const{anchor:n,focus:r}=e,i=n.getNode(),s=r.getNode();return qe(i,t)&&n.set(t.__key,0,"element"),qe(s,t)&&r.set(t.__key,0,"element"),e}(t);let o=!1;if(ti(s)&&e){const e=s.anchor,n=s.focus;e.key===r&&(vi(e,t,i,t.getPreviousSibling(),t.getNextSibling()),o=!0),n.key===r&&(vi(n,t,i,t.getPreviousSibling(),t.getNextSibling()),o=!0)}else ni(s)&&e&&t.isSelected()&&t.selectPrevious();if(ti(s)&&e&&!o){const e=t.getIndexWithinParent();le(t),mi(s,i,e,-1)}else le(t);n||Ze(i)||i.canBeEmpty()||!i.isEmpty()||xr(i,e),e&&ns(i)&&i.isEmpty()&&i.selectEnd()}class vr{static getType(){H(64,this.name)}static clone(t){H(65,this.name)}constructor(t){this.__type=this.constructor.getType(),this.__parent=null,this.__prev=null,this.__next=null,oe(this,t)}getType(){return this.__type}isInline(){H(137,this.constructor.name)}isAttached(){let t=this.__key;for(;null!==t;){if("root"===t)return!0;const e=fe(t);if(null===e)break;t=e.__parent}return!1}isSelected(t){const e=t||pi();if(null==e)return!1;const n=e.getNodes().some((t=>t.__key===this.__key));return(Ur(this)||!ti(e)||"element"!==e.anchor.type||"element"!==e.focus.type||e.anchor.key!==e.focus.key||e.anchor.offset!==e.focus.offset)&&n}getKey(){return this.__key}getIndexWithinParent(){const t=this.getParent();if(null===t)return-1;let e=t.getFirstChild(),n=0;for(;null!==e;){if(this.is(e))return n;n++,e=e.getNextSibling()}return-1}getParent(){const t=this.getLatest().__parent;return null===t?null:fe(t)}getParentOrThrow(){const t=this.getParent();return null===t&&H(66,this.__key),t}getTopLevelElement(){let t=this;for(;null!==t;){const e=t.getParent();if(Ze(e))return Gi(t)||H(138),t;t=e}return null}getTopLevelElementOrThrow(){const t=this.getTopLevelElement();return null===t&&H(67,this.__key),t}getParents(){const t=[];let e=this.getParent();for(;null!==e;)t.push(e),e=e.getParent();return t}getParentKeys(){const t=[];let e=this.getParent();for(;null!==e;)t.push(e.__key),e=e.getParent();return t}getPreviousSibling(){const t=this.getLatest().__prev;return null===t?null:fe(t)}getPreviousSiblings(){const t=[],e=this.getParent();if(null===e)return t;let n=e.getFirstChild();for(;null!==n&&!n.is(this);)t.push(n),n=n.getNextSibling();return t}getNextSibling(){const t=this.getLatest().__next;return null===t?null:fe(t)}getNextSiblings(){const t=[];let e=this.getNextSibling();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getCommonAncestor(t){const e=this.getParents(),n=t.getParents();Gi(this)&&e.unshift(this),Gi(t)&&n.unshift(t);const r=e.length,i=n.length;if(0===r||0===i||e[r-1]!==n[i-1])return null;const s=new Set(n);for(let t=0;t<r;t++){const n=e[t];if(s.has(n))return n}return null}is(t){return null!=t&&this.__key===t.__key}isBefore(t){if(this===t)return!1;if(t.isParentOf(this))return!0;if(this.isParentOf(t))return!1;const e=this.getCommonAncestor(t);let n=0,r=0,i=this;for(;;){const t=i.getParentOrThrow();if(t===e){n=i.getIndexWithinParent();break}i=t}for(i=t;;){const t=i.getParentOrThrow();if(t===e){r=i.getIndexWithinParent();break}i=t}return n<r}isParentOf(t){const e=this.__key;if(e===t.__key)return!1;let n=t;for(;null!==n;){if(n.__key===e)return!0;n=n.getParent()}return!1}getNodesBetween(t){const e=this.isBefore(t),n=[],r=new Set;let i=this;for(;null!==i;){const s=i.__key;if(r.has(s)||(r.add(s),n.push(i)),i===t)break;const o=Gi(i)?e?i.getFirstChild():i.getLastChild():null;if(null!==o){i=o;continue}const l=e?i.getNextSibling():i.getPreviousSibling();if(null!==l){i=l;continue}const c=i.getParentOrThrow();if(r.has(c.__key)||n.push(c),c===t)break;let u=null,a=c;do{if(null===a&&H(68),u=e?a.getNextSibling():a.getPreviousSibling(),a=a.getParent(),null===a)break;null!==u||r.has(a.__key)||n.push(a)}while(null===u);i=u}return e||n.reverse(),n}isDirty(){const t=Wi()._dirtyLeaves;return null!==t&&t.has(this.__key)}getLatest(){const t=fe(this.__key);return null===t&&H(113),t}getWritable(){Li();const t=Mi(),e=Wi(),n=t._nodeMap,r=this.__key,i=this.getLatest(),s=i.__parent,o=e._cloneNotNeeded,l=pi();if(null!==l&&l.setCachedNodes(null),o.has(r))return ce(i),i;const c=i.constructor.clone(i);return c.__parent=s,c.__next=i.__next,c.__prev=i.__prev,Gi(i)&&Gi(c)?(us(i)&&us(c)&&(c.__textFormat=i.__textFormat),c.__first=i.__first,c.__last=i.__last,c.__size=i.__size,c.__indent=i.__indent,c.__format=i.__format,c.__dir=i.__dir):Ur(i)&&Ur(c)&&(c.__format=i.__format,c.__style=i.__style,c.__mode=i.__mode,c.__detail=i.__detail),o.add(r),c.__key=r,ce(c),n.set(r,c),c}getTextContent(){return""}getTextContentSize(){return this.getTextContent().length}createDOM(t,e){H(70)}updateDOM(t,e,n){H(71)}exportDOM(t){return{element:this.createDOM(t._config,t)}}exportJSON(){H(72)}static importJSON(t){H(18,this.name)}static transform(){return null}remove(t){xr(this,!0,t)}replace(t,e){Li();let n=pi();null!==n&&(n=n.clone()),en(this,t);const r=this.getLatest(),i=this.__key,s=t.__key,o=t.getWritable(),l=this.getParentOrThrow().getWritable(),c=l.__size;le(o);const u=r.getPreviousSibling(),a=r.getNextSibling(),f=r.__prev,d=r.__next,h=r.__parent;if(xr(r,!1,!0),null===u)l.__first=s;else{u.getWritable().__next=s}if(o.__prev=f,null===a)l.__last=s;else{a.getWritable().__prev=s}if(o.__next=d,o.__parent=h,l.__size=c,e&&(Gi(this)&&Gi(o)||H(139),this.getChildren().forEach((t=>{o.append(t)}))),ti(n)){me(n);const t=n.anchor,e=n.focus;t.key===i&&Xr(t,o),e.key===i&&Xr(e,o)}return ae()===i&&ue(s),o}insertAfter(t,e=!0){Li(),en(this,t);const n=this.getWritable(),r=t.getWritable(),i=r.getParent(),s=pi();let o=!1,l=!1;if(null!==i){const e=t.getIndexWithinParent();if(le(r),ti(s)){const t=i.__key,n=s.anchor,r=s.focus;o="element"===n.type&&n.key===t&&n.offset===e+1,l="element"===r.type&&r.key===t&&r.offset===e+1}}const c=this.getNextSibling(),u=this.getParentOrThrow().getWritable(),a=r.__key,f=n.__next;if(null===c)u.__last=a;else{c.getWritable().__prev=a}if(u.__size++,n.__next=a,r.__next=f,r.__prev=n.__key,r.__parent=n.__parent,e&&ti(s)){const t=this.getIndexWithinParent();mi(s,u,t+1);const e=u.__key;o&&s.anchor.set(e,t+2,"element"),l&&s.focus.set(e,t+2,"element")}return t}insertBefore(t,e=!0){Li(),en(this,t);const n=this.getWritable(),r=t.getWritable(),i=r.__key;le(r);const s=this.getPreviousSibling(),o=this.getParentOrThrow().getWritable(),l=n.__prev,c=this.getIndexWithinParent();if(null===s)o.__first=i;else{s.getWritable().__next=i}o.__size++,n.__prev=i,r.__prev=l,r.__next=n.__key,r.__parent=n.__parent;const u=pi();if(e&&ti(u)){mi(u,this.getParentOrThrow(),c)}return t}isParentRequired(){return!1}createParentElementNode(){return cs()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(t,e){Li();const n=this.getPreviousSibling(),r=this.getParentOrThrow();if(null===n)return r.select(0,0);if(Gi(n))return n.select();if(!Ur(n)){const t=n.getIndexWithinParent()+1;return r.select(t,t)}return n.select(t,e)}selectNext(t,e){Li();const n=this.getNextSibling(),r=this.getParentOrThrow();if(null===n)return r.select();if(Gi(n))return n.select(0,0);if(!Ur(n)){const t=n.getIndexWithinParent();return r.select(t,t)}return n.select(t,e)}markDirty(){this.getWritable()}}class Tr extends vr{static getType(){return"linebreak"}static clone(t){return new Tr(t.__key)}constructor(t){super(t)}getTextContent(){return"\n"}createDOM(){return document.createElement("br")}updateDOM(){return!1}static importDOM(){return{br:t=>function(t){const e=t.parentElement;if(null!==e){const n=e.firstChild;if(n===t||n.nextSibling===t&&br(n)){const n=e.lastChild;if(n===t||n.previousSibling===t&&br(n))return!0}}return!1}(t)?null:{conversion:Sr,priority:0}}}static importJSON(t){return kr()}exportJSON(){return{type:"linebreak",version:1}}}function Sr(t){return{node:kr()}}function kr(){return tn(new Tr)}function Cr(t){return t instanceof Tr}function br(t){return t.nodeType===st&&/^( |\t|\r?\n)+$/.test(t.textContent||"")}function Nr(t,e){return 16&e?"code":128&e?"mark":32&e?"sub":64&e?"sup":null}function wr(t,e){return 1&e?"strong":2&e?"em":"span"}function Er(t,e,n,r,i){const s=r.classList;let o=Me(i,"base");void 0!==o&&s.add(...o),o=Me(i,"underlineStrikethrough");let l=!1;const c=e&ht&&e&dt;void 0!==o&&(n&ht&&n&dt?(l=!0,c||s.add(...o)):c&&s.remove(...o));for(const t in Et){const r=Et[t];if(o=Me(i,t),void 0!==o)if(n&r){if(l&&("underline"===t||"strikethrough"===t)){e&r&&s.remove(...o);continue}e&r&&(!c||"underline"!==t)&&"strikethrough"!==t||s.add(...o)}else e&r&&s.remove(...o)}}function Pr(t,e,n){const r=e.firstChild,i=n.isComposing(),s=t+(i?Tt:"");if(null==r)e.textContent=s;else{const t=r.nodeValue;if(t!==s)if(i||X){const[e,n,i]=function(t,e){const n=t.length,r=e.length;let i=0,s=0;for(;i<n&&i<r&&t[i]===e[i];)i++;for(;s+i<n&&s+i<r&&t[n-s-1]===e[r-s-1];)s++;return[i,n-i-s,e.slice(i,r-s)]}(t,s);0!==n&&r.deleteData(e,n),r.insertData(e,i)}else r.nodeValue=s}}function Dr(t,e,n,r,i,s){Pr(i,t,e);const o=s.theme.text;void 0!==o&&Er(0,0,r,t,o)}function Fr(t,e){const n=document.createElement(e);return n.appendChild(t),n}class Ir extends vr{static getType(){return"text"}static clone(t){return new Ir(t.__text,t.__key)}constructor(t,e){super(e),this.__text=t,this.__format=0,this.__style="",this.__mode=0,this.__detail=0}getFormat(){return this.getLatest().__format}getDetail(){return this.getLatest().__detail}getMode(){const t=this.getLatest();return Ot[t.__mode]}getStyle(){return this.getLatest().__style}isToken(){return 1===this.getLatest().__mode}isComposing(){return this.__key===ae()}isSegmented(){return 2===this.getLatest().__mode}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(t){const e=Et[t];return!!(this.getFormat()&e)}isSimpleText(){return"text"===this.__type&&0===this.__mode}getTextContent(){return this.getLatest().__text}getFormatFlags(t,e){return ie(this.getLatest().__format,t,e)}canHaveFormat(){return!0}createDOM(t,e){const n=this.__format,r=Nr(0,n),i=wr(0,n),s=null===r?i:r,o=document.createElement(s);let l=o;this.hasFormat("code")&&o.setAttribute("spellcheck","false"),null!==r&&(l=document.createElement(i),o.appendChild(l));Dr(l,this,0,n,this.__text,t);const c=this.__style;return""!==c&&(o.style.cssText=c),o}updateDOM(t,e,n){const r=this.__text,i=t.__format,s=this.__format,o=Nr(0,i),l=Nr(0,s),c=wr(0,i),u=wr(0,s);if((null===o?c:o)!==(null===l?u:l))return!0;if(o===l&&c!==u){const t=e.firstChild;null==t&&H(48);const i=document.createElement(u);return Dr(i,this,0,s,r,n),e.replaceChild(i,t),!1}let a=e;null!==l&&null!==o&&(a=e.firstChild,null==a&&H(49)),Pr(r,a,this);const f=n.theme.text;void 0!==f&&i!==s&&Er(0,i,s,a,f);const d=t.__style,h=this.__style;return d!==h&&(e.style.cssText=h),!1}static importDOM(){return{"#text":()=>({conversion:Wr,priority:0}),b:()=>({conversion:Lr,priority:0}),code:()=>({conversion:Kr,priority:0}),em:()=>({conversion:Kr,priority:0}),i:()=>({conversion:Kr,priority:0}),s:()=>({conversion:Kr,priority:0}),span:()=>({conversion:Or,priority:0}),strong:()=>({conversion:Kr,priority:0}),sub:()=>({conversion:Kr,priority:0}),sup:()=>({conversion:Kr,priority:0}),u:()=>({conversion:Kr,priority:0})}}static importJSON(t){const e=Jr(t.text);return e.setFormat(t.format),e.setDetail(t.detail),e.setMode(t.mode),e.setStyle(t.style),e}exportDOM(t){let{element:e}=super.exportDOM(t);return null!==e&&un(e)||H(132),e.style.whiteSpace="pre-wrap",this.hasFormat("bold")&&(e=Fr(e,"b")),this.hasFormat("italic")&&(e=Fr(e,"i")),this.hasFormat("strikethrough")&&(e=Fr(e,"s")),this.hasFormat("underline")&&(e=Fr(e,"u")),{element:e}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),type:"text",version:1}}selectionTransform(t,e){}setFormat(t){const e=this.getWritable();return e.__format="string"==typeof t?Et[t]:t,e}setDetail(t){const e=this.getWritable();return e.__detail="string"==typeof t?Pt[t]:t,e}setStyle(t){const e=this.getWritable();return e.__style=t,e}toggleFormat(t){const e=ie(this.getFormat(),t,null);return this.setFormat(e)}toggleDirectionless(){const t=this.getWritable();return t.__detail^=1,t}toggleUnmergeable(){const t=this.getWritable();return t.__detail^=2,t}setMode(t){const e=It[t];if(this.__mode===e)return this;const n=this.getWritable();return n.__mode=e,n}setTextContent(t){if(this.__text===t)return this;const e=this.getWritable();return e.__text=t,e}select(t,e){Li();let n=t,r=e;const i=pi(),s=this.getTextContent(),o=this.__key;if("string"==typeof s){const t=s.length;void 0===n&&(n=t),void 0===r&&(r=t)}else n=0,r=0;if(!ti(i))return fi(o,n,o,r,"text","text");{const t=ae();t!==i.anchor.key&&t!==i.focus.key||ue(o),i.setTextNodeRange(this,n,this,r)}return i}selectStart(){return this.select(0,0)}selectEnd(){const t=this.getTextContentSize();return this.select(t,t)}spliceText(t,e,n,r){const i=this.getWritable(),s=i.__text,o=n.length;let l=t;l<0&&(l=o+l,l<0&&(l=0));const c=pi();if(r&&ti(c)){const e=t+o;c.setTextNodeRange(i,e,i,e)}const u=s.slice(0,l)+n+s.slice(l+e);return i.__text=u,i}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...t){Li();const e=this.getLatest(),n=e.getTextContent(),r=e.__key,i=ae(),s=new Set(t),o=[],l=n.length;let c="";for(let t=0;t<l;t++)""!==c&&s.has(t)&&(o.push(c),c=""),c+=n[t];""!==c&&o.push(c);const u=o.length;if(0===u)return[];if(o[0]===n)return[e];const a=o[0],f=e.getParentOrThrow();let d;const h=e.getFormat(),g=e.getStyle(),_=e.__detail;let p=!1;e.isSegmented()?(d=Jr(a),d.__format=h,d.__style=g,d.__detail=_,p=!0):(d=e.getWritable(),d.__text=a);const y=pi(),m=[d];let x=a.length;for(let t=1;t<u;t++){const e=o[t],n=e.length,s=Jr(e).getWritable();s.__format=h,s.__style=g,s.__detail=_;const l=s.__key,c=x+n;if(ti(y)){const t=y.anchor,e=y.focus;t.key===r&&"text"===t.type&&t.offset>x&&t.offset<=c&&(t.key=l,t.offset-=x,y.dirty=!0),e.key===r&&"text"===e.type&&e.offset>x&&e.offset<=c&&(e.key=l,e.offset-=x,y.dirty=!0)}i===r&&ue(l),x=c,m.push(s)}!function(t){const e=t.getPreviousSibling(),n=t.getNextSibling();null!==e&&ce(e),null!==n&&ce(n)}(this);const v=f.getWritable(),T=this.getIndexWithinParent();return p?(v.splice(T,0,m),this.remove()):v.splice(T,1,m),ti(y)&&mi(y,f,T,u-1),m}mergeWithSibling(t){const e=t===this.getPreviousSibling();e||t===this.getNextSibling()||H(50);const n=this.__key,r=t.__key,i=this.__text,s=i.length;ae()===r&&ue(n);const o=pi();if(ti(o)){const i=o.anchor,l=o.focus;null!==i&&i.key===r&&(Ti(i,e,n,t,s),o.dirty=!0),null!==l&&l.key===r&&(Ti(l,e,n,t,s),o.dirty=!0)}const l=t.__text,c=e?l+i:i+l;this.setTextContent(c);const u=this.getWritable();return t.remove(),u}isTextEntity(){return!1}}function Or(t){const e=t.style,n=e.fontWeight,r="700"===n||"bold"===n,i="line-through"===e.textDecoration,s="italic"===e.fontStyle,o="underline"===e.textDecoration,l=e.verticalAlign;return{forChild:t=>Ur(t)?(r&&t.toggleFormat("bold"),i&&t.toggleFormat("strikethrough"),s&&t.toggleFormat("italic"),o&&t.toggleFormat("underline"),"sub"===l&&t.toggleFormat("subscript"),"super"===l&&t.toggleFormat("superscript"),t):t,node:null}}function Lr(t){const e="normal"===t.style.fontWeight;return{forChild:t=>(Ur(t)&&!e&&t.toggleFormat("bold"),t),node:null}}const Ar=new WeakMap;function Mr(t){return"PRE"===t.nodeName||t.nodeType===it&&void 0!==t.style&&void 0!==t.style.whiteSpace&&t.style.whiteSpace.startsWith("pre")}function Wr(t){const e=t;null===t.parentElement&&H(129);let n=e.textContent||"";if(null!==function(t){let e,n=t.parentNode;const r=[t];for(;null!==n&&void 0===(e=Ar.get(n))&&!Mr(n);)r.push(n),n=n.parentNode;const i=void 0===e?n:e;for(let t=0;t<r.length;t++)Ar.set(r[t],i);return i}(e)){const t=n.split(/(\r?\n|\t)/),e=[],r=t.length;for(let n=0;n<r;n++){const r=t[n];"\n"===r||"\r\n"===r?e.push(kr()):"\t"===r?e.push($r()):""!==r&&e.push(Jr(r))}return{node:e}}if(n=n.replace(/\r/g,"").replace(/[ \t\n]+/g," "),""===n)return{node:null};if(" "===n[0]){let t=e,r=!0;for(;null!==t&&null!==(t=Br(t,!1));){const e=t.textContent||"";if(e.length>0){/[ \t\n]$/.test(e)&&(n=n.slice(1)),r=!1;break}}r&&(n=n.slice(1))}if(" "===n[n.length-1]){let t=e,r=!0;for(;null!==t&&null!==(t=Br(t,!0));){if((t.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){r=!1;break}}r&&(n=n.slice(0,n.length-1))}return""===n?{node:null}:{node:Jr(n)}}const zr=new RegExp(/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/,"i");function Br(t,e){let n=t;for(;;){let t;for(;null===(t=e?n.nextSibling:n.previousSibling);){const t=n.parentElement;if(null===t)return null;n=t}if(n=t,n.nodeType===it){const t=n.style.display;if(""===t&&null===n.nodeName.match(zr)||""!==t&&!t.startsWith("inline"))return null}let r=n;for(;null!==(r=e?n.firstChild:n.lastChild);)n=r;if(n.nodeType===st)return n;if("BR"===n.nodeName)return null}}const Rr={code:"code",em:"italic",i:"italic",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function Kr(t){const e=Rr[t.nodeName.toLowerCase()];return void 0===e?{node:null}:{forChild:t=>(Ur(t)&&!t.hasFormat(e)&&t.toggleFormat(e),t),node:null}}function Jr(t=""){return tn(new Ir(t))}function Ur(t){return t instanceof Ir}class Vr extends Ir{static getType(){return"tab"}static clone(t){const e=new Vr(t.__key);return e.__text=t.__text,e.__format=t.__format,e.__style=t.__style,e}constructor(t){super("\t",t),this.__detail=2}static importDOM(){return null}static importJSON(t){const e=$r();return e.setFormat(t.format),e.setStyle(t.style),e}exportJSON(){return{...super.exportJSON(),type:"tab",version:1}}setTextContent(t){H(126)}setDetail(t){H(127)}setMode(t){H(128)}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function $r(){return tn(new Vr)}function Hr(t){return t instanceof Vr}class jr{constructor(t,e,n){this._selection=null,this.key=t,this.offset=e,this.type=n}is(t){return this.key===t.key&&this.offset===t.offset&&this.type===t.type}isBefore(t){let e=this.getNode(),n=t.getNode();const r=this.offset,i=t.offset;if(Gi(e)){const t=e.getDescendantByIndex(r);e=null!=t?t:e}if(Gi(n)){const t=n.getDescendantByIndex(i);n=null!=t?t:n}return e===n?r<i:e.isBefore(n)}getNode(){const t=fe(this.key);return null===t&&H(20),t}set(t,e,n){const r=this._selection,i=this.key;this.key=t,this.offset=e,this.type=n,Oi()||(ae()===i&&ue(t),null!==r&&(r.setCachedNodes(null),r.dirty=!0))}}function qr(t,e,n){return new jr(t,e,n)}function Qr(t,e){let n=e.__key,r=t.offset,i="element";if(Ur(e)){i="text";const t=e.getTextContentSize();r>t&&(r=t)}else if(!Gi(e)){const t=e.getNextSibling();if(Ur(t))n=t.__key,r=0,i="text";else{const t=e.getParent();t&&(n=t.__key,r=e.getIndexWithinParent()+1)}}t.set(n,r,i)}function Xr(t,e){if(Gi(e)){const n=e.getLastDescendant();Gi(n)||Ur(n)?Qr(t,n):Qr(t,e)}else Qr(t,e)}function Yr(t,e,n,r){const i=t.getNode(),s=i.getChildAtIndex(t.offset),o=Jr(),l=ns(i)?cs().append(o):o;o.setFormat(n),o.setStyle(r),null===s?i.append(l):s.insertBefore(l),t.is(e)&&e.set(o.__key,0,"text"),t.set(o.__key,0,"text")}function Zr(t,e,n,r){t.key=e,t.offset=n,t.type=r}class Gr{constructor(t){this._cachedNodes=null,this._nodes=t,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){if(!ni(t))return!1;const e=this._nodes,n=t._nodes;return e.size===n.size&&Array.from(e).every((t=>n.has(t)))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(t){this.dirty=!0,this._nodes.add(t),this._cachedNodes=null}delete(t){this.dirty=!0,this._nodes.delete(t),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(t){return this._nodes.has(t)}clone(){return new Gr(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(t){}insertText(){}insertNodes(t){const e=this.getNodes(),n=e.length,r=e[n-1];let i;if(Ur(r))i=r.select();else{const t=r.getIndexWithinParent()+1;i=r.getParentOrThrow().select(t,t)}i.insertNodes(t);for(let t=0;t<n;t++)e[t].remove()}getNodes(){const t=this._cachedNodes;if(null!==t)return t;const e=this._nodes,n=[];for(const t of e){const e=fe(t);null!==e&&n.push(e)}return Oi()||(this._cachedNodes=n),n}getTextContent(){const t=this.getNodes();let e="";for(let n=0;n<t.length;n++)e+=t[n].getTextContent();return e}}function ti(t){return t instanceof ei}class ei{constructor(t,e,n,r){this.anchor=t,this.focus=e,t._selection=this,e._selection=this,this._cachedNodes=null,this.format=n,this.style=r,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){return!!ti(t)&&(this.anchor.is(t.anchor)&&this.focus.is(t.focus)&&this.format===t.format&&this.style===t.style)}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){const t=this._cachedNodes;if(null!==t)return t;const e=this.anchor,n=this.focus,r=e.isBefore(n),i=r?e:n,s=r?n:e;let o=i.getNode(),l=s.getNode();const c=i.offset,u=s.offset;if(Gi(o)){const t=o.getDescendantByIndex(c);o=null!=t?t:o}if(Gi(l)){let t=l.getDescendantByIndex(u);null!==t&&t!==o&&l.getChildAtIndex(u)===t&&(t=t.getPreviousSibling()),l=null!=t?t:l}let a;return a=o.is(l)?Gi(o)&&o.getChildrenSize()>0?[]:[o]:o.getNodesBetween(l),Oi()||(this._cachedNodes=a),a}setTextNodeRange(t,e,n,r){Zr(this.anchor,t.__key,e,"text"),Zr(this.focus,n.__key,r,"text"),this._cachedNodes=null,this.dirty=!0}getTextContent(){const t=this.getNodes();if(0===t.length)return"";const e=t[0],n=t[t.length-1],r=this.anchor,i=this.focus,s=r.isBefore(i),[o,l]=ii(this);let c="",u=!0;for(let a=0;a<t.length;a++){const f=t[a];if(Gi(f)&&!f.isInline())u||(c+="\n"),u=!f.isEmpty();else if(u=!1,Ur(f)){let t=f.getTextContent();f===e?f===n?"element"===r.type&&"element"===i.type&&i.offset!==r.offset||(t=o<l?t.slice(o,l):t.slice(l,o)):t=s?t.slice(o):t.slice(l):f===n&&(t=s?t.slice(0,l):t.slice(0,o)),c+=t}else!Yi(f)&&!Cr(f)||f===n&&this.isCollapsed()||(c+=f.getTextContent())}return c}applyDOMRange(t){const e=Wi(),n=e.getEditorState()._selection,r=ui(t.startContainer,t.startOffset,t.endContainer,t.endOffset,e,n);if(null===r)return;const[i,s]=r;Zr(this.anchor,i.key,i.offset,i.type),Zr(this.focus,s.key,s.offset,s.type),this._cachedNodes=null}clone(){const t=this.anchor,e=this.focus;return new ei(qr(t.key,t.offset,t.type),qr(e.key,e.offset,e.type),this.format,this.style)}toggleFormat(t){this.format=ie(this.format,t,null),this.dirty=!0}setStyle(t){this.style=t,this.dirty=!0}hasFormat(t){const e=Et[t];return!!(this.format&e)}insertRawText(t){const e=t.split(/(\r?\n|\t)/),n=[],r=e.length;for(let t=0;t<r;t++){const r=e[t];"\n"===r||"\r\n"===r?n.push(kr()):"\t"===r?n.push($r()):n.push(Jr(r))}this.insertNodes(n)}insertText(t){const e=this.anchor,n=this.focus,r=this.isCollapsed()||e.isBefore(n),i=this.format,s=this.style;r&&"element"===e.type?Yr(e,n,i,s):r||"element"!==n.type||Yr(n,e,i,s);const o=this.getNodes(),l=o.length,c=r?n:e,u=(r?e:n).offset,a=c.offset;let f=o[0];Ur(f)||H(26);const d=f.getTextContent().length,h=f.getParentOrThrow();let g=o[l-1];if(this.isCollapsed()&&u===d&&(f.isSegmented()||f.isToken()||!f.canInsertTextAfter()||!h.canInsertTextAfter()&&null===f.getNextSibling())){let e=f.getNextSibling();if(Ur(e)&&e.canInsertTextBefore()&&!ee(e)||(e=Jr(),e.setFormat(i),h.canInsertTextAfter()?f.insertAfter(e):h.insertAfter(e)),e.select(0,0),f=e,""!==t)return void this.insertText(t)}else if(this.isCollapsed()&&0===u&&(f.isSegmented()||f.isToken()||!f.canInsertTextBefore()||!h.canInsertTextBefore()&&null===f.getPreviousSibling())){let e=f.getPreviousSibling();if(Ur(e)&&!ee(e)||(e=Jr(),e.setFormat(i),h.canInsertTextBefore()?f.insertBefore(e):h.insertBefore(e)),e.select(),f=e,""!==t)return void this.insertText(t)}else if(f.isSegmented()&&u!==d){const t=Jr(f.getTextContent());t.setFormat(i),f.replace(t),f=t}else if(!this.isCollapsed()&&""!==t){const e=g.getParent();if(!h.canInsertTextBefore()||!h.canInsertTextAfter()||Gi(e)&&(!e.canInsertTextBefore()||!e.canInsertTextAfter()))return this.insertText(""),ci(this.anchor,this.focus,null),void this.insertText(t)}if(1===l){if(f.isToken()){const e=Jr(t);return e.select(),void f.replace(e)}const e=f.getFormat(),n=f.getStyle();if(u!==a||e===i&&n===s){if(Hr(f)){const e=Jr(t);return e.setFormat(i),e.setStyle(s),e.select(),void f.replace(e)}}else{if(""!==f.getTextContent()){const e=Jr(t);if(e.setFormat(i),e.setStyle(s),e.select(),0===u)f.insertBefore(e,!1);else{const[t]=f.splitText(u);t.insertAfter(e,!1)}return void(e.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=t.length))}f.setFormat(i),f.setStyle(s)}const r=a-u;f=f.spliceText(u,r,t,!0),""===f.getTextContent()?f.remove():"text"===this.anchor.type&&(f.isComposing()?this.anchor.offset-=t.length:(this.format=e,this.style=n))}else{const e=new Set([...f.getParentKeys(),...g.getParentKeys()]),n=Gi(f)?f:f.getParentOrThrow();let r=Gi(g)?g:g.getParentOrThrow(),i=g;if(!n.is(r)&&r.isInline())do{i=r,r=r.getParentOrThrow()}while(r.isInline());if("text"===c.type&&(0!==a||""===g.getTextContent())||"element"===c.type&&g.getIndexWithinParent()<a)if(Ur(g)&&!g.isToken()&&a!==g.getTextContentSize()){if(g.isSegmented()){const t=Jr(g.getTextContent());g.replace(t),g=t}ns(c.getNode())||"text"!==c.type||(g=g.spliceText(0,a,"")),e.add(g.__key)}else{const t=g.getParentOrThrow();t.canBeEmpty()||1!==t.getChildrenSize()?g.remove():t.remove()}else e.add(g.__key);const s=r.getChildren(),h=new Set(o),_=n.is(r),p=n.isInline()&&null===f.getNextSibling()?n:f;for(let t=s.length-1;t>=0;t--){const e=s[t];if(e.is(f)||Gi(e)&&e.isParentOf(f))break;e.isAttached()&&(!h.has(e)||e.is(i)?_||p.insertAfter(e,!1):e.remove())}if(!_){let t=r,n=null;for(;null!==t;){const r=t.getChildren(),i=r.length;(0===i||r[i-1].is(n))&&(e.delete(t.__key),n=t),t=t.getParent()}}if(f.isToken())if(u===d)f.select();else{const e=Jr(t);e.select(),f.replace(e)}else f=f.spliceText(u,d-u,t,!0),""===f.getTextContent()?f.remove():f.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=t.length);for(let t=1;t<l;t++){const n=o[t],r=n.__key;e.has(r)||n.remove()}}}removeText(){this.insertText("")}formatText(t){if(this.isCollapsed())return this.toggleFormat(t),void ue(null);const e=this.getNodes(),n=[];for(const t of e)Ur(t)&&n.push(t);const r=n.length;if(0===r)return this.toggleFormat(t),void ue(null);const i=this.anchor,s=this.focus,o=this.isBackward(),l=o?s:i,c=o?i:s;let u=0,a=n[0],f="element"===l.type?0:l.offset;if("text"===l.type&&f===a.getTextContentSize()&&(u=1,a=n[1],f=0),null==a)return;const d=a.getFormatFlags(t,null),h=r-1;let g=n[h];const _="text"===c.type?c.offset:g.getTextContentSize();if(a.is(g)){if(f===_)return;if(0===f&&_===a.getTextContentSize())a.setFormat(d);else{const t=a.splitText(f,_),e=0===f?t[0]:t[1];e.setFormat(d),"text"===l.type&&l.set(e.__key,0,"text"),"text"===c.type&&c.set(e.__key,_-f,"text")}return void(this.format=d)}0!==f&&([,a]=a.splitText(f),f=0),a.setFormat(d);const p=g.getFormatFlags(t,d);_>0&&(_!==g.getTextContentSize()&&([g]=g.splitText(_)),g.setFormat(p));for(let e=u+1;e<h;e++){const r=n[e];if(!r.isToken()){const e=r.getFormatFlags(t,p);r.setFormat(e)}}"text"===l.type&&l.set(a.__key,f,"text"),"text"===c.type&&c.set(g.__key,_,"text"),this.format=d|p}insertNodes(t){if(0===t.length)return;if("root"===this.anchor.key){this.insertParagraph();const e=pi();return ti(e)||H(134),e.insertNodes(t)}const e=fn((this.isBackward()?this.focus:this.anchor).getNode(),an),n=t[t.length-1];if("__language"in e&&Gi(e)){if("__language"in t[0])this.insertText(t[0].getTextContent());else{const r=bi(this);e.splice(r,0,t),n.selectEnd()}return}if(!t.some((t=>(Gi(t)||Yi(t))&&!t.isInline()))){Gi(e)||H(135);const r=bi(this);return e.splice(r,0,t),void n.selectEnd()}const r=function(t){const e=cs();let n=null;for(let r=0;r<t.length;r++){const i=t[r],s=Cr(i);if(s||Yi(i)&&i.isInline()||Gi(i)&&i.isInline()||Ur(i)||i.isParentRequired()){if(null===n&&(n=i.createParentElementNode(),e.append(n),s))continue;null!==n&&n.append(i)}else e.append(i),n=null}return e}(t),i=r.getLastDescendant(),s=r.getChildren(),o=t=>"__value"in t&&"__checked"in t,l=!Gi(e)||!e.isEmpty()?this.insertParagraph():null,c=s[s.length-1];let u=s[0];var a;Gi(a=u)&&an(a)&&!a.isEmpty()&&Gi(e)&&(!e.isEmpty()||o(e))&&(Gi(e)||H(135),e.append(...u.getChildren()),u=s[1]),u&&function(t,e,n){const r=n||e.getParentOrThrow().getLastChild();let i=e;const s=[e];for(;i!==r;)i.getNextSibling()||H(140),i=i.getNextSibling(),s.push(i);let o=t;for(const t of s)o=o.insertAfter(t)}(e,u);const f=fn(i,an);l&&Gi(f)&&(o(l)||an(c))&&(f.append(...l.getChildren()),l.remove()),Gi(e)&&e.isEmpty()&&e.remove(),i.selectEnd();const d=Gi(e)?e.getLastChild():null;Cr(d)&&f!==e&&d.remove()}insertParagraph(){if("root"===this.anchor.key){const t=cs();return pe().splice(this.anchor.offset,0,[t]),t.select(),t}const t=bi(this),e=fn(this.anchor.getNode(),an);Gi(e)||H(136);const n=e.getChildAtIndex(t),r=n?[n,...n.getNextSiblings()]:[],i=e.insertNewAfter(this,!1);return i?(i.append(...r),i.selectStart(),i):null}insertLineBreak(t){const e=kr();if(this.insertNodes([e]),t){const t=e.getParentOrThrow(),n=e.getIndexWithinParent();t.select(n,n)}}extract(){const t=this.getNodes(),e=t.length,n=e-1,r=this.anchor,i=this.focus;let s=t[0],o=t[n];const[l,c]=ii(this);if(0===e)return[];if(1===e){if(Ur(s)&&!this.isCollapsed()){const t=l>c?c:l,e=l>c?l:c,n=s.splitText(t,e),r=0===t?n[0]:n[1];return null!=r?[r]:[]}return[s]}const u=r.isBefore(i);if(Ur(s)){const e=u?l:c;e===s.getTextContentSize()?t.shift():0!==e&&([,s]=s.splitText(e),t[0]=s)}if(Ur(o)){const e=o.getTextContent().length,r=u?c:l;0===r?t.pop():r!==e&&([o]=o.splitText(r),t[n]=o)}return t}modify(t,e,n){const r=this.focus,i=this.anchor,s="move"===t,o=Re(r,e);if(Yi(o)&&!o.isIsolated()){if(s&&o.isKeyboardSelectable()){const t=hi();return t.add(o.__key),void me(t)}const t=e?o.getPreviousSibling():o.getNextSibling();if(Ur(t)){const n=t.__key,o=e?t.getTextContent().length:0;return r.set(n,o,"text"),void(s&&i.set(n,o,"text"))}{const n=o.getParentOrThrow();let l,c;return Gi(t)?(c=t.__key,l=e?t.getChildrenSize():0):(l=o.getIndexWithinParent(),c=n.__key,e||l++),r.set(c,l,"element"),void(s&&i.set(c,l,"element"))}}const l=Wi(),c=on(l._window);if(!c)return;const u=l._blockCursorElement,a=l._rootElement;if(null===a||null===u||!Gi(o)||o.isInline()||o.canBeEmpty()||rn(u,l,a),function(t,e,n,r){t.modify(e,n,r)}(c,t,e?"backward":"forward",n),c.rangeCount>0){const t=c.getRangeAt(0),n=this.anchor.getNode(),r=ns(n)?n:Ye(n);if(this.applyDOMRange(t),this.dirty=!0,!s){const n=this.getNodes(),i=[];let s=!1;for(let t=0;t<n.length;t++){const e=n[t];qe(e,r)?i.push(e):s=!0}if(s&&i.length>0)if(e){const t=i[0];Gi(t)?t.selectStart():t.getParentOrThrow().selectStart()}else{const t=i[i.length-1];Gi(t)?t.selectEnd():t.getParentOrThrow().selectEnd()}c.anchorNode===t.startContainer&&c.anchorOffset===t.startOffset||function(t){const e=t.focus,n=t.anchor,r=n.key,i=n.offset,s=n.type;Zr(n,e.key,e.offset,e.type),Zr(e,r,i,s),t._cachedNodes=null}(this)}}}forwardDeletion(t,e,n){if(!n&&("element"===t.type&&Gi(e)&&t.offset===e.getChildrenSize()||"text"===t.type&&t.offset===e.getTextContentSize())){const t=e.getParent(),n=e.getNextSibling()||(null===t?null:t.getNextSibling());if(Gi(n)&&n.isShadowRoot())return!0}return!1}deleteCharacter(t){const n=this.isCollapsed();if(this.isCollapsed()){const n=this.anchor;let r=n.getNode();if(this.forwardDeletion(n,r,t))return;const i=this.focus,s=Re(i,t);if(Yi(s)&&!s.isIsolated()){if(s.isKeyboardSelectable()&&Gi(r)&&0===r.getChildrenSize()){r.remove();const t=hi();t.add(s.__key),me(t)}else{s.remove();Wi().dispatchCommand(e,void 0)}return}if(!t&&Gi(s)&&Gi(r)&&r.isEmpty())return r.remove(),void s.selectStart();if(this.modify("extend",t,"character"),this.isCollapsed()){if(t&&0===n.offset){if(("element"===n.type?n.getNode():n.getNode().getParentOrThrow()).collapseAtStart(this))return}}else{const e="text"===i.type?i.getNode():null;if(r="text"===n.type?n.getNode():null,null!==e&&e.isSegmented()){const n=i.offset,s=e.getTextContentSize();if(e.is(r)||t&&n!==s||!t&&0!==n)return void si(e,t,n)}else if(null!==r&&r.isSegmented()){const i=n.offset,s=r.getTextContentSize();if(r.is(e)||t&&0!==i||!t&&i!==s)return void si(r,t,i)}!function(t,e){const n=t.anchor,r=t.focus,i=n.getNode(),s=r.getNode();if(i===s&&"text"===n.type&&"text"===r.type){const t=n.offset,s=r.offset,o=t<s,l=o?t:s,c=o?s:t,u=c-1;if(l!==u){Te(i.getTextContent().slice(l,c))||(e?r.offset=u:n.offset=u)}}}(this,t)}}if(this.removeText(),t&&!n&&this.isCollapsed()&&"element"===this.anchor.type&&0===this.anchor.offset){const t=this.anchor.getNode();t.isEmpty()&&ns(t.getParent())&&0===t.getIndexWithinParent()&&t.collapseAtStart(this)}}deleteLine(t){if(this.isCollapsed()){"text"===this.anchor.type&&this.modify("extend",t,"lineboundary");0===(t?this.focus:this.anchor).offset&&this.modify("extend",t,"character")}this.removeText()}deleteWord(t){if(this.isCollapsed()){const e=this.anchor,n=e.getNode();if(this.forwardDeletion(e,n,t))return;this.modify("extend",t,"word")}this.removeText()}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return[this.anchor,this.focus]}}function ni(t){return t instanceof Gr}function ri(t){const e=t.offset;if("text"===t.type)return e;const n=t.getNode();return e===n.getChildrenSize()?n.getTextContent().length:0}function ii(t){const e=t.getStartEndPoints();if(null===e)return[0,0];const[n,r]=e;return"element"===n.type&&"element"===r.type&&n.key===r.key&&n.offset===r.offset?[0,0]:[ri(n),ri(r)]}function si(t,e,n){const r=t,i=r.getTextContent().split(/(?=\s)/g),s=i.length;let o=0,l=0;for(let t=0;t<s;t++){const r=t===s-1;if(l=o,o+=i[t].length,e&&o===n||o>n||r){i.splice(t,1),r&&(l=void 0);break}}const c=i.join("").trim();""===c?r.remove():(r.setTextContent(c),r.select(l,l))}function oi(t,e,n,r){let i,s=e;if(t.nodeType===it){let o=!1;const l=t.childNodes,c=l.length;s===c&&(o=!0,s=c-1);let u=l[s],a=!1;if(u===r._blockCursorElement?(u=l[s+1],a=!0):null!==r._blockCursorElement&&s--,i=xe(u),Ur(i))s=ve(i,o);else{let r=xe(t);if(null===r)return null;if(Gi(r)){s=Math.min(r.getChildrenSize(),s);let t=r.getChildAtIndex(s);if(Gi(t)&&function(t,e,n){const r=t.getParent();return null===n||null===r||!r.canBeEmpty()||r!==n.getNode()}(t,0,n)){const e=o?t.getLastDescendant():t.getFirstDescendant();null===e?(r=t,s=0):(t=e,r=Gi(t)?t:t.getParentOrThrow())}Ur(t)?(i=t,r=null,s=ve(t,o)):t!==r&&o&&!a&&s++}else{const n=r.getIndexWithinParent();s=0===e&&Yi(r)&&xe(t)===r?n:n+1,r=r.getParentOrThrow()}if(Gi(r))return qr(r.__key,s,"element")}}else i=xe(t);return Ur(i)?qr(i.__key,s,"text"):null}function li(t,e,n){const r=t.offset,i=t.getNode();if(0===r){const r=i.getPreviousSibling(),s=i.getParent();if(e){if((n||!e)&&null===r&&Gi(s)&&s.isInline()){const e=s.getPreviousSibling();Ur(e)&&(t.key=e.__key,t.offset=e.getTextContent().length)}}else Gi(r)&&!n&&r.isInline()?(t.key=r.__key,t.offset=r.getChildrenSize(),t.type="element"):Ur(r)&&(t.key=r.__key,t.offset=r.getTextContent().length)}else if(r===i.getTextContent().length){const r=i.getNextSibling(),s=i.getParent();if(e&&Gi(r)&&r.isInline())t.key=r.__key,t.offset=0,t.type="element";else if((n||e)&&null===r&&Gi(s)&&s.isInline()&&!s.canInsertTextAfter()){const e=s.getNextSibling();Ur(e)&&(t.key=e.__key,t.offset=0)}}}function ci(t,e,n){if("text"===t.type&&"text"===e.type){const r=t.isBefore(e),i=t.is(e);li(t,r,i),li(e,!r,i),i&&(e.key=t.key,e.offset=t.offset,e.type=t.type);const s=Wi();if(s.isComposing()&&s._compositionKey!==t.key&&ti(n)){const r=n.anchor,i=n.focus;Zr(t,r.key,r.offset,r.type),Zr(e,i.key,i.offset,i.type)}}}function ui(t,e,n,r,i,s){if(null===t||null===n||!Gt(i,t,n))return null;const o=oi(t,e,ti(s)?s.anchor:null,i);if(null===o)return null;const l=oi(n,r,ti(s)?s.focus:null,i);if(null===l)return null;if("element"===o.type&&"element"===l.type){const e=xe(t),r=xe(n);if(Yi(e)&&Yi(r))return null}return ci(o,l,s),[o,l]}function ai(t){return Gi(t)&&!t.isInline()}function fi(t,e,n,r,i,s){const o=Mi(),l=new ei(qr(t,e,i),qr(n,r,s),0,"");return l.dirty=!0,o._selection=l,l}function di(){const t=qr("root",0,"element"),e=qr("root",0,"element");return new ei(t,e,0,"")}function hi(){return new Gr(new Set)}function gi(t,e){return _i(null,t,e,null)}function _i(t,e,n,r){const i=n._window;if(null===i)return null;const s=r||i.event,o=s?s.type:void 0,l="selectionchange"===o,c=!Mt&&(l||"beforeinput"===o||"compositionstart"===o||"compositionend"===o||"click"===o&&s&&3===s.detail||"drop"===o||void 0===o);let u,a,f,d;if(ti(t)&&!c)return t.clone();if(null===e)return null;if(u=e.anchorNode,a=e.focusNode,f=e.anchorOffset,d=e.focusOffset,l&&ti(t)&&!Gt(n,u,a))return t.clone();const h=ui(u,f,a,d,n,t);if(null===h)return null;const[g,_]=h;return new ei(g,_,ti(t)?t.format:0,ti(t)?t.style:"")}function pi(){return Mi()._selection}function yi(){return Wi()._editorState._selection}function mi(t,e,n,r=1){const i=t.anchor,s=t.focus,o=i.getNode(),l=s.getNode();if(!e.is(o)&&!e.is(l))return;const c=e.__key;if(t.isCollapsed()){const e=i.offset;if(n<=e&&r>0||n<e&&r<0){const n=Math.max(0,e+r);i.set(c,n,"element"),s.set(c,n,"element"),xi(t)}}else{const o=t.isBackward(),l=o?s:i,u=l.getNode(),a=o?i:s,f=a.getNode();if(e.is(u)){const t=l.offset;(n<=t&&r>0||n<t&&r<0)&&l.set(c,Math.max(0,t+r),"element")}if(e.is(f)){const t=a.offset;(n<=t&&r>0||n<t&&r<0)&&a.set(c,Math.max(0,t+r),"element")}}xi(t)}function xi(t){const e=t.anchor,n=e.offset,r=t.focus,i=r.offset,s=e.getNode(),o=r.getNode();if(t.isCollapsed()){if(!Gi(s))return;const t=s.getChildrenSize(),i=n>=t,o=i?s.getChildAtIndex(t-1):s.getChildAtIndex(n);if(Ur(o)){let t=0;i&&(t=o.getTextContentSize()),e.set(o.__key,t,"text"),r.set(o.__key,t,"text")}}else{if(Gi(s)){const t=s.getChildrenSize(),r=n>=t,i=r?s.getChildAtIndex(t-1):s.getChildAtIndex(n);if(Ur(i)){let t=0;r&&(t=i.getTextContentSize()),e.set(i.__key,t,"text")}}if(Gi(o)){const t=o.getChildrenSize(),e=i>=t,n=e?o.getChildAtIndex(t-1):o.getChildAtIndex(i);if(Ur(n)){let t=0;e&&(t=n.getTextContentSize()),r.set(n.__key,t,"text")}}}}function vi(t,e,n,r,i){let s=null,o=0,l=null;null!==r?(s=r.__key,Ur(r)?(o=r.getTextContentSize(),l="text"):Gi(r)&&(o=r.getChildrenSize(),l="element")):null!==i&&(s=i.__key,Ur(i)?l="text":Gi(i)&&(l="element")),null!==s&&null!==l?t.set(s,o,l):(o=e.getIndexWithinParent(),-1===o&&(o=n.getChildrenSize()),t.set(n.__key,o,"element"))}function Ti(t,e,n,r,i){"text"===t.type?(t.key=n,e||(t.offset+=i)):t.offset>r.getIndexWithinParent()&&(t.offset-=1)}function Si(t,e,n,r,i,s,o){const l=r.anchorNode,c=r.focusNode,u=r.anchorOffset,a=r.focusOffset,f=document.activeElement;if(i.has("collaboration")&&f!==s||null!==f&&Zt(f))return;if(!ti(e))return void(null!==t&&Gt(n,l,c)&&r.removeAllRanges());const d=e.anchor,h=e.focus,g=d.key,_=h.key,p=Ve(n,g),y=Ve(n,_),m=d.offset,x=h.offset,v=e.format,T=e.style,S=e.isCollapsed();let k=p,C=y,b=!1;if("text"===d.type){k=re(p);const t=d.getNode();b=t.getFormat()!==v||t.getStyle()!==T}else ti(t)&&"text"===t.anchor.type&&(b=!0);var N,w,E,P,D;if(("text"===h.type&&(C=re(y)),null!==k&&null!==C)&&(S&&(null===t||b||ti(t)&&(t.format!==v||t.style!==T))&&(N=v,w=T,E=m,P=g,D=performance.now(),lr=[N,w,E,P,D]),u!==m||a!==x||l!==k||c!==C||"Range"===r.type&&S||(null!==f&&s.contains(f)||s.focus({preventScroll:!0}),"element"===d.type))){try{r.setBaseAndExtent(k,m,C,x)}catch(t){}if(!i.has("skip-scroll-into-view")&&e.isCollapsed()&&null!==s&&s===document.activeElement){const t=e instanceof ei&&"element"===e.anchor.type?k.childNodes[m]||null:r.rangeCount>0?r.getRangeAt(0):null;if(null!==t){let e;if(t instanceof Text){const n=document.createRange();n.selectNode(t),e=n.getBoundingClientRect()}else e=t.getBoundingClientRect();!function(t,e,n){const r=n.ownerDocument,i=r.defaultView;if(null===i)return;let{top:s,bottom:o}=e,l=0,c=0,u=n;for(;null!==u;){const e=u===r.body;if(e)l=0,c=Qe(t).innerHeight;else{const t=u.getBoundingClientRect();l=t.top,c=t.bottom}let n=0;if(s<l?n=-(l-s):o>c&&(n=o-c),0!==n)if(e)i.scrollBy(0,n);else{const t=u.scrollTop;u.scrollTop+=n;const e=u.scrollTop-t;s-=e,o-=e}if(e)break;u=$e(u)}}(n,e,s)}}rr=!0}}function ki(t){let e=pi()||yi();null===e&&(e=pe().selectEnd()),e.insertNodes(t)}function Ci(){const t=pi();return null===t?"":t.getTextContent()}function bi(t){t.isCollapsed()||t.removeText();const e=t.anchor;let n=e.getNode(),r=e.offset;for(;!an(n);)[n,r]=Ni(n,r);return r}function Ni(t,e){const n=t.getParent();if(!n){const t=cs();return pe().append(t),t.select(),[pe(),0]}if(Ur(t)){const r=t.splitText(e);if(0===r.length)return[n,t.getIndexWithinParent()];const i=0===e?0:1;return[n,r[0].getIndexWithinParent()+i]}if(!Gi(t)||0===e)return[n,t.getIndexWithinParent()];const r=t.getChildAtIndex(e);if(r){const n=new ei(qr(t.__key,e,"element"),qr(t.__key,e,"element"),0,""),i=t.insertNewAfter(n);i&&i.append(r,...r.getNextSiblings())}return[n,t.getIndexWithinParent()+1]}let wi=null,Ei=null,Pi=!1,Di=!1,Fi=0;const Ii={characterData:!0,childList:!0,subtree:!0};function Oi(){return Pi||null!==wi&&wi._readOnly}function Li(){Pi&&H(13)}function Ai(){Fi>99&&H(14)}function Mi(){return null===wi&&H(15),wi}function Wi(){return null===Ei&&H(16),Ei}function zi(){return Ei}function Bi(t,e,n){const r=e.__type,i=function(t,e){const n=t._nodes.get(e);return void 0===n&&H(30,e),n}(t,r);let s=n.get(r);void 0===s&&(s=Array.from(i.transforms),n.set(r,s));const o=s.length;for(let t=0;t<o&&(s[t](e),e.isAttached());t++);}function Ri(t,e){return void 0!==t&&t.__key!==e&&t.isAttached()}function Ki(t){return Ji(t,Wi()._nodes)}function Ji(t,e){const n=t.type,r=e.get(n);void 0===r&&H(17,n);const i=r.klass;t.type!==i.getType()&&H(18,i.name);const s=i.importJSON(t),o=t.children;if(Gi(s)&&Array.isArray(o))for(let t=0;t<o.length;t++){const n=Ji(o[t],e);s.append(n)}return s}function Ui(t,e){const n=wi,r=Pi,i=Ei;wi=t,Pi=!0,Ei=null;try{return e()}finally{wi=n,Pi=r,Ei=i}}function Vi(t,n){const r=t._pendingEditorState,i=t._rootElement,s=t._headless||null===i;if(null===r)return;const o=t._editorState,l=o._selection,c=r._selection,u=t._dirtyType!==ot,a=wi,f=Pi,d=Ei,h=t._updating,g=t._observer;let _=null;if(t._pendingEditorState=null,t._editorState=r,!s&&u&&null!==g){Ei=t,wi=r,Pi=!1,t._updating=!0;try{const e=t._dirtyType,n=t._dirtyElements,i=t._dirtyLeaves;g.disconnect(),_=jn(o,r,t,e,n,i)}catch(e){if(e instanceof Error&&t._onError(e),Di)throw e;return _s(t,null,i,r),Vt(t),t._dirtyType=ct,Di=!0,Vi(t,o),void(Di=!1)}finally{g.observe(i,Ii),t._updating=h,wi=a,Pi=f,Ei=d}}r._readOnly||(r._readOnly=!0);const p=t._dirtyLeaves,y=t._dirtyElements,m=t._normalizedNodes,x=t._updateTags,v=t._deferred;u&&(t._dirtyType=ot,t._cloneNotNeeded.clear(),t._dirtyLeaves=new Set,t._dirtyElements=new Map,t._normalizedNodes=new Set,t._updateTags=new Set),function(t,e){const n=t._decorators;let r=t._pendingDecorators||n;const i=e._nodeMap;let s;for(s in r)i.has(s)||(r===n&&(r=ge(t)),delete r[s])}(t,r);const T=s?null:on(t._window);if(t._editable&&null!==T&&(u||null===c||c.dirty)){Ei=t,wi=r;try{if(null!==g&&g.disconnect(),u||null===c||c.dirty){const e=t._blockCursorElement;null!==e&&rn(e,t,i),Si(l,c,t,T,x,i)}sn(t,i,c),null!==g&&g.observe(i,Ii)}finally{Ei=d,wi=a}}null!==_&&function(t,e,n,r,i){const s=Array.from(t._listeners.mutation),o=s.length;for(let t=0;t<o;t++){const[o,l]=s[t],c=e.get(l);void 0!==c&&o(c,{dirtyLeaves:r,prevEditorState:i,updateTags:n})}}(t,_,x,p,o),ti(c)||null===c||null!==l&&l.is(c)||t.dispatchCommand(e,void 0);const S=t._pendingDecorators;null!==S&&(t._decorators=S,t._pendingDecorators=null,$i("decorator",t,!0,S)),function(t,e,n){const r=_e(e),i=_e(n);r!==i&&$i("textcontent",t,!0,i)}(t,n||o,r),$i("update",t,!0,{dirtyElements:y,dirtyLeaves:p,editorState:r,normalizedNodes:m,prevEditorState:n||o,tags:x}),function(t,e){if(t._deferred=[],0!==e.length){const n=t._updating;t._updating=!0;try{for(let t=0;t<e.length;t++)e[t]()}finally{t._updating=n}}}(t,v),function(t){const e=t._updates;if(0!==e.length){const n=e.shift();if(n){const[e,r]=n;qi(t,e,r)}}}(t)}function $i(t,e,n,...r){const i=e._updating;e._updating=n;try{const n=Array.from(e._listeners[t]);for(let t=0;t<n.length;t++)n[t].apply(null,r)}finally{e._updating=i}}function Hi(t,e,n){if(!1===t._updating||Ei!==t){let r=!1;return t.update((()=>{r=Hi(t,e,n)})),r}const r=Se(t);for(let i=4;i>=0;i--)for(let s=0;s<r.length;s++){const o=r[s]._commands.get(e);if(void 0!==o){const e=o[i];if(void 0!==e){const r=Array.from(e),i=r.length;for(let e=0;e<i;e++)if(!0===r[e](n,t))return!0}}}return!1}function ji(t,e){const n=t._updates;let r=e||!1;for(;0!==n.length;){const e=n.shift();if(e){const[n,i]=e;let s,o;void 0!==i&&(s=i.onUpdate,o=i.tag,i.skipTransforms&&(r=!0),s&&t._deferred.push(s),o&&t._updateTags.add(o)),n()}}return r}function qi(t,e,n){const r=t._updateTags;let i,s,o=!1,l=!1;void 0!==n&&(i=n.onUpdate,s=n.tag,null!=s&&r.add(s),o=n.skipTransforms||!1,l=n.discrete||!1),i&&t._deferred.push(i);const c=t._editorState;let u=t._pendingEditorState,a=!1;(null===u||u._readOnly)&&(u=t._pendingEditorState=new ss(new Map((u||c)._nodeMap)),a=!0),u._flushSync=l;const f=wi,d=Pi,h=Ei,g=t._updating;wi=u,Pi=!1,t._updating=!0,Ei=t;try{a&&(t._headless?null!==c._selection&&(u._selection=c._selection.clone()):u._selection=function(t){const e=t.getEditorState()._selection,n=on(t._window);return ti(e)||null==e?_i(e,n,t,null):e.clone()}(t));const n=t._compositionKey;e(),o=ji(t,o),function(t,e){const n=e.getEditorState()._selection,r=t._selection;if(ti(r)){const t=r.anchor,e=r.focus;let i;if("text"===t.type&&(i=t.getNode(),i.selectionTransform(n,r)),"text"===e.type){const t=e.getNode();i!==t&&t.selectionTransform(n,r)}}}(u,t),t._dirtyType!==ot&&(o?function(t,e){const n=e._dirtyLeaves,r=t._nodeMap;for(const t of n){const e=r.get(t);Ur(e)&&e.isAttached()&&e.isSimpleText()&&!e.isUnmergeable()&&jt(e)}}(u,t):function(t,e){const n=e._dirtyLeaves,r=e._dirtyElements,i=t._nodeMap,s=ae(),o=new Map;let l=n,c=l.size,u=r,a=u.size;for(;c>0||a>0;){if(c>0){e._dirtyLeaves=new Set;for(const t of l){const r=i.get(t);Ur(r)&&r.isAttached()&&r.isSimpleText()&&!r.isUnmergeable()&&jt(r),void 0!==r&&Ri(r,s)&&Bi(e,r,o),n.add(t)}if(l=e._dirtyLeaves,c=l.size,c>0){Fi++;continue}}e._dirtyLeaves=new Set,e._dirtyElements=new Map;for(const t of u){const n=t[0],l=t[1];if("root"!==n&&!l)continue;const c=i.get(n);void 0!==c&&Ri(c,s)&&Bi(e,c,o),r.set(n,l)}l=e._dirtyLeaves,c=l.size,u=e._dirtyElements,a=u.size,Fi++}e._dirtyLeaves=n,e._dirtyElements=r}(u,t),ji(t),function(t,e,n,r){const i=t._nodeMap,s=e._nodeMap,o=[];for(const[t]of r){const e=s.get(t);void 0!==e&&(e.isAttached()||(Gi(e)&&hn(e,t,i,s,o,r),i.has(t)||r.delete(t),o.push(t)))}for(const t of o)s.delete(t);for(const t of n){const e=s.get(t);void 0===e||e.isAttached()||(i.has(t)||n.delete(t),s.delete(t))}}(c,u,t._dirtyLeaves,t._dirtyElements));n!==t._compositionKey&&(u._flushSync=!0);const r=u._selection;if(ti(r)){const t=u._nodeMap,e=r.anchor.key,n=r.focus.key;void 0!==t.get(e)&&void 0!==t.get(n)||H(19)}else ni(r)&&0===r._nodes.size&&(u._selection=null)}catch(e){return e instanceof Error&&t._onError(e),t._pendingEditorState=c,t._dirtyType=ct,t._cloneNotNeeded.clear(),t._dirtyLeaves=new Set,t._dirtyElements.clear(),void Vi(t)}finally{wi=f,Pi=d,Ei=h,t._updating=g,Fi=0}const _=t._dirtyType!==ot||function(t,e){const n=e.getEditorState()._selection,r=t._selection;if(null!==r){if(r.dirty||!r.is(n))return!0}else if(null!==n)return!0;return!1}(u,t);_?u._flushSync?(u._flushSync=!1,Vi(t)):a&&Yt((()=>{Vi(t)})):(u._flushSync=!1,a&&(r.clear(),t._deferred=[],t._pendingEditorState=null))}function Qi(t,e,n){t._updating?t._updates.push([e,n]):qi(t,e,n)}class Xi extends vr{constructor(t){super(t)}decorate(t,e){H(47)}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function Yi(t){return t instanceof Xi}class Zi extends vr{constructor(t){super(t),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__indent=0,this.__dir=null}getFormat(){return this.getLatest().__format}getFormatType(){const t=this.getFormat();return Ft[t]||""}getIndent(){return this.getLatest().__indent}getChildren(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getChildrenKeys(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e.__key),e=e.getNextSibling();return t}getChildrenSize(){return this.getLatest().__size}isEmpty(){return 0===this.getChildrenSize()}isDirty(){const t=Wi()._dirtyElements;return null!==t&&t.has(this.__key)}isLastChild(){const t=this.getLatest(),e=this.getParentOrThrow().getLastChild();return null!==e&&e.is(t)}getAllTextNodes(){const t=[];let e=this.getFirstChild();for(;null!==e;){if(Ur(e)&&t.push(e),Gi(e)){const n=e.getAllTextNodes();t.push(...n)}e=e.getNextSibling()}return t}getFirstDescendant(){let t=this.getFirstChild();for(;Gi(t);){const e=t.getFirstChild();if(null===e)break;t=e}return t}getLastDescendant(){let t=this.getLastChild();for(;Gi(t);){const e=t.getLastChild();if(null===e)break;t=e}return t}getDescendantByIndex(t){const e=this.getChildren(),n=e.length;if(t>=n){const t=e[n-1];return Gi(t)&&t.getLastDescendant()||t||null}const r=e[t];return Gi(r)&&r.getFirstDescendant()||r||null}getFirstChild(){const t=this.getLatest().__first;return null===t?null:fe(t)}getFirstChildOrThrow(){const t=this.getFirstChild();return null===t&&H(45,this.__key),t}getLastChild(){const t=this.getLatest().__last;return null===t?null:fe(t)}getLastChildOrThrow(){const t=this.getLastChild();return null===t&&H(96,this.__key),t}getChildAtIndex(t){const e=this.getChildrenSize();let n,r;if(t<e/2){for(n=this.getFirstChild(),r=0;null!==n&&r<=t;){if(r===t)return n;n=n.getNextSibling(),r++}return null}for(n=this.getLastChild(),r=e-1;null!==n&&r>=t;){if(r===t)return n;n=n.getPreviousSibling(),r--}return null}getTextContent(){let t="";const e=this.getChildren(),n=e.length;for(let r=0;r<n;r++){const i=e[r];t+=i.getTextContent(),Gi(i)&&r!==n-1&&!i.isInline()&&(t+=St)}return t}getTextContentSize(){let t=0;const e=this.getChildren(),n=e.length;for(let r=0;r<n;r++){const i=e[r];t+=i.getTextContentSize(),Gi(i)&&r!==n-1&&!i.isInline()&&(t+=St.length)}return t}getDirection(){return this.getLatest().__dir}hasFormat(t){if(""!==t){const e=Dt[t];return!!(this.getFormat()&e)}return!1}select(t,e){Li();const n=pi();let r=t,i=e;const s=this.getChildrenSize();if(!this.canBeEmpty())if(0===t&&0===e){const t=this.getFirstChild();if(Ur(t)||Gi(t))return t.select(0,0)}else if(!(void 0!==t&&t!==s||void 0!==e&&e!==s)){const t=this.getLastChild();if(Ur(t)||Gi(t))return t.select()}void 0===r&&(r=s),void 0===i&&(i=s);const o=this.__key;return ti(n)?(n.anchor.set(o,r,"element"),n.focus.set(o,i,"element"),n.dirty=!0,n):fi(o,r,o,i,"element","element")}selectStart(){const t=this.getFirstDescendant();return t?t.selectStart():this.select()}selectEnd(){const t=this.getLastDescendant();return t?t.selectEnd():this.select()}clear(){const t=this.getWritable();return this.getChildren().forEach((t=>t.remove())),t}append(...t){return this.splice(this.getChildrenSize(),0,t)}setDirection(t){const e=this.getWritable();return e.__dir=t,e}setFormat(t){return this.getWritable().__format=""!==t?Dt[t]:0,this}setIndent(t){return this.getWritable().__indent=t,this}splice(t,e,n){const r=n.length,i=this.getChildrenSize(),s=this.getWritable(),o=s.__key,l=[],c=[],u=this.getChildAtIndex(t+e);let a=null,f=i-e+r;if(0!==t)if(t===i)a=this.getLastChild();else{const e=this.getChildAtIndex(t);null!==e&&(a=e.getPreviousSibling())}if(e>0){let t=null===a?this.getFirstChild():a.getNextSibling();for(let n=0;n<e;n++){null===t&&H(100);const e=t.getNextSibling(),n=t.__key;le(t.getWritable()),c.push(n),t=e}}let d=a;for(let t=0;t<r;t++){const e=n[t];null!==d&&e.is(d)&&(a=d=d.getPreviousSibling());const r=e.getWritable();r.__parent===o&&f--,le(r);const i=e.__key;if(null===d)s.__first=i,r.__prev=null;else{const t=d.getWritable();t.__next=i,r.__prev=t.__key}e.__key===o&&H(76),r.__parent=o,l.push(i),d=e}if(t+e===i){if(null!==d){d.getWritable().__next=null,s.__last=d.__key}}else if(null!==u){const t=u.getWritable();if(null!==d){const e=d.getWritable();t.__prev=d.__key,e.__next=u.__key}else t.__prev=null}if(s.__size=f,c.length){const t=pi();if(ti(t)){const e=new Set(c),n=new Set(l),{anchor:r,focus:i}=t;ts(r,e,n)&&vi(r,r.getNode(),this,a,u),ts(i,e,n)&&vi(i,i.getNode(),this,a,u),0!==f||this.canBeEmpty()||Ze(this)||this.remove()}}return s}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"element",version:1}}insertNewAfter(t,e){return null}canIndent(){return!0}collapseAtStart(t){return!1}excludeFromCopy(t){return!1}canReplaceWith(t){return!0}canInsertAfter(t){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(t){return!1}extractWithChild(t,e,n){return!1}}function Gi(t){return t instanceof Zi}function ts(t,e,n){let r=t.getNode();for(;r;){const t=r.__key;if(e.has(t)&&!n.has(t))return!0;r=r.getParent()}return!1}class es extends Zi{static getType(){return"root"}static clone(){return new es}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){H(51)}getTextContent(){const t=this.__cachedText;return!Oi()&&Wi()._dirtyType!==ot||null===t?super.getTextContent():t}remove(){H(52)}replace(t){H(53)}insertBefore(t){H(54)}insertAfter(t){H(55)}updateDOM(t,e){return!1}append(...t){for(let e=0;e<t.length;e++){const n=t[e];Gi(n)||Yi(n)||H(56)}return super.append(...t)}static importJSON(t){const e=pe();return e.setFormat(t.format),e.setIndent(t.indent),e.setDirection(t.direction),e}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"root",version:1}}collapseAtStart(){return!0}}function ns(t){return t instanceof es}function rs(){return new ss(new Map([["root",new es]]))}function is(t){const e=t.exportJSON(),n=t.constructor;if(e.type!==n.getType()&&H(130,n.name),Gi(t)){const r=e.children;Array.isArray(r)||H(59,n.name);const i=t.getChildren();for(let t=0;t<i.length;t++){const e=is(i[t]);r.push(e)}}return e}class ss{constructor(t,e){this._nodeMap=t,this._selection=e||null,this._flushSync=!1,this._readOnly=!1}isEmpty(){return 1===this._nodeMap.size&&null===this._selection}read(t){return Ui(this,t)}clone(t){const e=new ss(this._nodeMap,void 0===t?this._selection:t);return e._readOnly=!0,e}toJSON(){return Ui(this,(()=>({root:is(pe())})))}}class os extends Zi{constructor(t){super(t),this.__textFormat=0}static getType(){return"paragraph"}getTextFormat(){return this.getLatest().__textFormat}setTextFormat(t){const e=this.getWritable();return e.__textFormat=t,e}hasTextFormat(t){const e=Et[t];return!!(this.getTextFormat()&e)}static clone(t){return new os(t.__key)}createDOM(t){const e=document.createElement("p"),n=Me(t.theme,"paragraph");if(void 0!==n){e.classList.add(...n)}return e}updateDOM(t,e,n){return!1}static importDOM(){return{p:t=>({conversion:ls,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(e&&un(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();e.style.textAlign=t;const n=this.getDirection();n&&(e.dir=n);const r=this.getIndent();r>0&&(e.style.textIndent=20*r+"px")}return{element:e}}static importJSON(t){const e=cs();return e.setFormat(t.format),e.setIndent(t.indent),e.setDirection(t.direction),e.setTextFormat(t.textFormat),e}exportJSON(){return{...super.exportJSON(),textFormat:this.getTextFormat(),type:"paragraph",version:1}}insertNewAfter(t,e){const n=cs();n.setTextFormat(t.format);const r=this.getDirection();return n.setDirection(r),n.setFormat(this.getFormatType()),this.insertAfter(n,e),n}collapseAtStart(){const t=this.getChildren();if(0===t.length||Ur(t[0])&&""===t[0].getTextContent().trim()){if(null!==this.getNextSibling())return this.selectNext(),this.remove(),!0;if(null!==this.getPreviousSibling())return this.selectPrevious(),this.remove(),!0}return!1}}function ls(t){const e=cs();if(t.style){e.setFormat(t.style.textAlign);const n=parseInt(t.style.textIndent,10)/20;n>0&&e.setIndent(n)}return{node:e}}function cs(){return tn(new os)}function us(t){return t instanceof os}const as=0,fs=1,ds=2,hs=3,gs=4;function _s(t,e,n,r){const i=t._keyToDOMMap;i.clear(),t._editorState=rs(),t._pendingEditorState=r,t._compositionKey=null,t._dirtyType=ot,t._cloneNotNeeded.clear(),t._dirtyLeaves=new Set,t._dirtyElements.clear(),t._normalizedNodes=new Set,t._updateTags=new Set,t._updates=[],t._blockCursorElement=null;const s=t._observer;null!==s&&(s.disconnect(),t._observer=null),null!==e&&(e.textContent=""),null!==n&&(n.textContent="",i.set("root",n))}function ps(t){const e=t||{},n=zi(),r=e.theme||{},i=void 0===t?n:e.parentEditor||null,s=e.disableEvents||!1,o=rs(),l=e.namespace||(null!==i?i._config.namespace:ke()),c=e.editorState,u=[es,Ir,Tr,Vr,os,...e.nodes||[]],{onError:a,html:f}=e,d=void 0===e.editable||e.editable;let h;if(void 0===t&&null!==n)h=n._nodes;else{h=new Map;for(let t=0;t<u.length;t++){let e=u[t],n=null,r=null;if("function"!=typeof e){const t=e;e=t.replace,n=t.with,r=t.withKlass||null}const i=e.getType(),s=e.transform(),o=new Set;null!==s&&o.add(s),h.set(i,{exportDOM:f&&f.export?f.export.get(e):void 0,klass:e,replace:n,replaceWithKlass:r,transforms:o})}}const g=new ys(o,i,h,{disableEvents:s,namespace:l,theme:r},a||console.error,function(t,e){const n=new Map,r=new Set,i=t=>{Object.keys(t).forEach((e=>{let r=n.get(e);void 0===r&&(r=[],n.set(e,r)),r.push(t[e])}))};return t.forEach((t=>{const e=t.klass.importDOM;if(null==e||r.has(e))return;r.add(e);const n=e.call(t.klass);null!==n&&i(n)})),e&&i(e),n}(h,f?f.import:void 0),d);return void 0!==c&&(g._pendingEditorState=c,g._dirtyType=ct),g}class ys{constructor(t,e,n,r,i,s,o){this._parentEditor=e,this._rootElement=null,this._editorState=t,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=r,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=ot,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=ke(),this._onError=i,this._htmlConversions=s,this._editable=o,this._headless=null!==e&&e._headless,this._window=null,this._blockCursorElement=null}isComposing(){return null!=this._compositionKey}registerUpdateListener(t){const e=this._listeners.update;return e.add(t),()=>{e.delete(t)}}registerEditableListener(t){const e=this._listeners.editable;return e.add(t),()=>{e.delete(t)}}registerDecoratorListener(t){const e=this._listeners.decorator;return e.add(t),()=>{e.delete(t)}}registerTextContentListener(t){const e=this._listeners.textcontent;return e.add(t),()=>{e.delete(t)}}registerRootListener(t){const e=this._listeners.root;return t(this._rootElement,null),e.add(t),()=>{t(null,this._rootElement),e.delete(t)}}registerCommand(t,e,n){void 0===n&&H(35);const r=this._commands;r.has(t)||r.set(t,[new Set,new Set,new Set,new Set,new Set]);const i=r.get(t);void 0===i&&H(36,String(t));const s=i[n];return s.add(e),()=>{s.delete(e),i.every((t=>0===t.size))&&r.delete(t)}}registerMutationListener(t,e){void 0===this._nodes.get(t.getType())&&H(37,t.name);const n=this._listeners.mutation;return n.set(e,t),()=>{n.delete(e)}}registerNodeTransformToKlass(t,e){const n=t.getType(),r=this._nodes.get(n);void 0===r&&H(37,t.name);return r.transforms.add(e),r}registerNodeTransform(t,e){const n=this.registerNodeTransformToKlass(t,e),r=[n],i=n.replaceWithKlass;if(null!=i){const t=this.registerNodeTransformToKlass(i,e);r.push(t)}var s,o;return s=this,o=t.getType(),Qi(s,(()=>{const t=Mi();if(t.isEmpty())return;if("root"===o)return void pe().markDirty();const e=t._nodeMap;for(const[,t]of e)t.markDirty()}),null===s._pendingEditorState?{tag:"history-merge"}:void 0),()=>{r.forEach((t=>t.transforms.delete(e)))}}hasNode(t){return this._nodes.has(t.getType())}hasNodes(t){return t.every(this.hasNode.bind(this))}dispatchCommand(t,e){return Je(this,t,e)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(t){const e=this._rootElement;if(t!==e){const n=Me(this._config.theme,"root"),r=this._pendingEditorState||this._editorState;if(this._rootElement=t,_s(this,e,t,r),null!==e&&(this._config.disableEvents||mr(e),null!=n&&e.classList.remove(...n)),null!==t){const e=function(t){const e=t.ownerDocument;return e&&e.defaultView||null}(t),r=t.style;r.userSelect="text",r.whiteSpace="pre-wrap",r.wordBreak="break-word",t.setAttribute("data-lexical-editor","true"),this._window=e,this._dirtyType=ct,Vt(this),this._updateTags.add("history-merge"),Vi(this),this._config.disableEvents||function(t,e){const n=t.ownerDocument,r=nr.get(n);(void 0===r||r<1)&&n.addEventListener("selectionchange",_r),nr.set(n,r||1),t.__lexicalEditor=e;const i=hr(t);for(let n=0;n<Yn.length;n++){const[r,s]=Yn[n],o="function"==typeof s?t=>{yr(t)||(pr(t),(e.isEditable()||"click"===r)&&s(t,e))}:t=>{if(!yr(t)&&(pr(t),e.isEditable()))switch(r){case"cut":return Je(e,W,t);case"copy":return Je(e,M,t);case"paste":return Je(e,c,t);case"dragstart":return Je(e,O,t);case"dragover":return Je(e,L,t);case"dragend":return Je(e,A,t);case"focus":return Je(e,U,t);case"blur":return Je(e,V,t);case"drop":return Je(e,F,t)}};t.addEventListener(r,o),i.push((()=>{t.removeEventListener(r,o)}))}}(t,this),null!=n&&t.classList.add(...n)}else this._editorState=r,this._pendingEditorState=null,this._window=null;$i("root",this,!1,t,e)}}getElementByKey(t){return this._keyToDOMMap.get(t)||null}getEditorState(){return this._editorState}setEditorState(t,e){t.isEmpty()&&H(38),Ut(this);const n=this._pendingEditorState,r=this._updateTags,i=void 0!==e?e.tag:null;null===n||n.isEmpty()||(null!=i&&r.add(i),Vi(this)),this._pendingEditorState=t,this._dirtyType=ct,this._dirtyElements.set("root",!1),this._compositionKey=null,null!=i&&r.add(i),Vi(this)}parseEditorState(t,e){return function(t,e,n){const r=rs(),i=wi,s=Pi,o=Ei,l=e._dirtyElements,c=e._dirtyLeaves,u=e._cloneNotNeeded,a=e._dirtyType;e._dirtyElements=new Map,e._dirtyLeaves=new Set,e._cloneNotNeeded=new Set,e._dirtyType=0,wi=r,Pi=!1,Ei=e;try{const i=e._nodes;Ji(t.root,i),n&&n(),r._readOnly=!0}catch(t){t instanceof Error&&e._onError(t)}finally{e._dirtyElements=l,e._dirtyLeaves=c,e._cloneNotNeeded=u,e._dirtyType=a,wi=i,Pi=s,Ei=o}return r}("string"==typeof t?JSON.parse(t):t,this,e)}update(t,e){Qi(this,t,e)}focus(t,e={}){const n=this._rootElement;null!==n&&(n.setAttribute("autocapitalize","off"),Qi(this,(()=>{const t=pi(),n=pe();null!==t?t.dirty=!0:0!==n.getChildrenSize()&&("rootStart"===e.defaultSelection?n.selectStart():n.selectEnd())}),{onUpdate:()=>{n.removeAttribute("autocapitalize"),t&&t()},tag:"focus"}),null===this._pendingEditorState&&n.removeAttribute("autocapitalize"))}blur(){const t=this._rootElement;null!==t&&t.blur();const e=on(this._window);null!==e&&e.removeAllRanges()}isEditable(){return this._editable}setEditable(t){this._editable!==t&&(this._editable=t,$i("editable",this,!0,t))}toJSON(){return{editorState:this._editorState.toJSON()}}}export{je as $addUpdateTag,tn as $applyNodeReplacement,Ge as $copyNode,kr as $createLineBreakNode,hi as $createNodeSelection,cs as $createParagraphNode,qr as $createPoint,di as $createRangeSelection,gi as $createRangeSelectionFromDom,$r as $createTabNode,Jr as $createTextNode,Re as $getAdjacentNode,ii as $getCharacterOffsets,dn as $getEditor,he as $getNearestNodeFromDOMNode,Ye as $getNearestRootOrShadowRoot,fe as $getNodeByKey,yi as $getPreviousSelection,pe as $getRoot,pi as $getSelection,Ci as $getTextContent,qe as $hasAncestor,He as $hasUpdateTag,ki as $insertNodes,ai as $isBlockElementNode,Yi as $isDecoratorNode,Gi as $isElementNode,Xe as $isInlineElementOrDecoratorNode,se as $isLeafNode,Cr as $isLineBreakNode,ni as $isNodeSelection,us as $isParagraphNode,ti as $isRangeSelection,ns as $isRootNode,Ze as $isRootOrShadowRoot,Hr as $isTabNode,Ur as $isTextNode,ze as $nodesOfType,qt as $normalizeSelection__EXPERIMENTAL,Ki as $parseSerializedNode,Ae as $selectAll,ue as $setCompositionKey,me as $setSelection,ln as $splitNode,V as BLUR_COMMAND,K as CAN_REDO_COMMAND,J as CAN_UNDO_COMMAND,B as CLEAR_EDITOR_COMMAND,R as CLEAR_HISTORY_COMMAND,r as CLICK_COMMAND,gs as COMMAND_PRIORITY_CRITICAL,as as COMMAND_PRIORITY_EDITOR,hs as COMMAND_PRIORITY_HIGH,fs as COMMAND_PRIORITY_LOW,ds as COMMAND_PRIORITY_NORMAL,l as CONTROLLED_TEXT_INSERTION_COMMAND,M as COPY_COMMAND,W as CUT_COMMAND,i as DELETE_CHARACTER_COMMAND,f as DELETE_LINE_COMMAND,a as DELETE_WORD_COMMAND,A as DRAGEND_COMMAND,L as DRAGOVER_COMMAND,O as DRAGSTART_COMMAND,F as DROP_COMMAND,Xi as DecoratorNode,Zi as ElementNode,U as FOCUS_COMMAND,I as FORMAT_ELEMENT_COMMAND,d as FORMAT_TEXT_COMMAND,P as INDENT_CONTENT_COMMAND,s as INSERT_LINE_BREAK_COMMAND,o as INSERT_PARAGRAPH_COMMAND,E as INSERT_TAB_COMMAND,T as KEY_ARROW_DOWN_COMMAND,m as KEY_ARROW_LEFT_COMMAND,p as KEY_ARROW_RIGHT_COMMAND,v as KEY_ARROW_UP_COMMAND,C as KEY_BACKSPACE_COMMAND,N as KEY_DELETE_COMMAND,_ as KEY_DOWN_COMMAND,S as KEY_ENTER_COMMAND,b as KEY_ESCAPE_COMMAND,$ as KEY_MODIFIER_COMMAND,k as KEY_SPACE_COMMAND,w as KEY_TAB_COMMAND,Tr as LineBreakNode,y as MOVE_TO_END,x as MOVE_TO_START,D as OUTDENT_CONTENT_COMMAND,c as PASTE_COMMAND,os as ParagraphNode,g as REDO_COMMAND,u as REMOVE_TEXT_COMMAND,es as RootNode,e as SELECTION_CHANGE_COMMAND,n as SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,z as SELECT_ALL_COMMAND,Vr as TabNode,Ir as TextNode,h as UNDO_COMMAND,t as createCommand,ps as createEditor,te as getNearestEditorFromDOMNode,Oi as isCurrentlyReadOnlyMode,cn as isHTMLAnchorElement,un as isHTMLElement,Zt as isSelectionCapturedInDecoratorInput,Gt as isSelectionWithinEditor};
@@ -272,6 +272,7 @@ export declare function internalMakeRangeSelection(anchorKey: NodeKey, anchorOff
272
272
  export declare function $createRangeSelection(): RangeSelection;
273
273
  export declare function $createNodeSelection(): NodeSelection;
274
274
  export declare function internalCreateSelection(editor: LexicalEditor): null | BaseSelection;
275
+ export declare function $createRangeSelectionFromDom(domSelection: Selection | null, editor: LexicalEditor): null | RangeSelection;
275
276
  export declare function internalCreateRangeSelection(lastSelection: null | BaseSelection, domSelection: Selection | null, editor: LexicalEditor, event: UIEvent | Event | null): null | RangeSelection;
276
277
  export declare function $getSelection(): null | BaseSelection;
277
278
  export declare function $getPreviousSelection(): null | BaseSelection;
package/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /** @module lexical */
2
1
  /**
3
2
  * Copyright (c) Meta Platforms, Inc. and affiliates.
4
3
  *
@@ -7,7 +6,7 @@
7
6
  *
8
7
  */
9
8
  export type { PasteCommandType } from './LexicalCommands';
10
- export type { CommandListener, CommandListenerPriority, CommandPayloadType, CreateEditorArgs, EditableListener, EditorConfig, EditorThemeClasses, HTMLConfig, Klass, KlassConstructor, LexicalCommand, LexicalEditor, LexicalNodeReplacement, MutationListener, NodeMutation, SerializedEditor, Spread, } from './LexicalEditor';
9
+ export type { CommandListener, CommandListenerPriority, CommandPayloadType, CreateEditorArgs, EditableListener, EditorConfig, EditorSetOptions, EditorThemeClasses, HTMLConfig, Klass, KlassConstructor, LexicalCommand, LexicalEditor, LexicalNodeReplacement, MutationListener, NodeMutation, SerializedEditor, Spread, Transform, } from './LexicalEditor';
11
10
  export type { EditorState, SerializedEditorState } from './LexicalEditorState';
12
11
  export type { DOMChildConversion, DOMConversion, DOMConversionFn, DOMConversionMap, DOMConversionOutput, DOMExportOutput, LexicalNode, NodeKey, NodeMap, SerializedLexicalNode, } from './LexicalNode';
13
12
  export type { BaseSelection, ElementPointType as ElementPoint, NodeSelection, Point, PointType, RangeSelection, TextPointType as TextPoint, } from './LexicalSelection';
@@ -18,7 +17,7 @@ export { BLUR_COMMAND, CAN_REDO_COMMAND, CAN_UNDO_COMMAND, CLEAR_EDITOR_COMMAND,
18
17
  export { COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_HIGH, COMMAND_PRIORITY_LOW, COMMAND_PRIORITY_NORMAL, createEditor, } from './LexicalEditor';
19
18
  export type { EventHandler } from './LexicalEvents';
20
19
  export { $normalizeSelection as $normalizeSelection__EXPERIMENTAL } from './LexicalNormalization';
21
- export { $createNodeSelection, $createPoint, $createRangeSelection, $getCharacterOffsets, $getPreviousSelection, $getSelection, $getTextContent, $insertNodes, $isBlockElementNode, $isNodeSelection, $isRangeSelection, } from './LexicalSelection';
20
+ export { $createNodeSelection, $createPoint, $createRangeSelection, $createRangeSelectionFromDom, $getCharacterOffsets, $getPreviousSelection, $getSelection, $getTextContent, $insertNodes, $isBlockElementNode, $isNodeSelection, $isRangeSelection, } from './LexicalSelection';
22
21
  export { $parseSerializedNode, isCurrentlyReadOnlyMode } from './LexicalUpdates';
23
22
  export { $addUpdateTag, $applyNodeReplacement, $copyNode, $getAdjacentNode, $getEditor, $getNearestNodeFromDOMNode, $getNearestRootOrShadowRoot, $getNodeByKey, $getRoot, $hasAncestor, $hasUpdateTag, $isInlineElementOrDecoratorNode, $isLeafNode, $isRootOrShadowRoot, $nodesOfType, $selectAll, $setCompositionKey, $setSelection, $splitNode, getNearestEditorFromDOMNode, isHTMLAnchorElement, isHTMLElement, isSelectionCapturedInDecoratorInput, isSelectionWithinEditor, } from './LexicalUtils';
24
23
  export { $isDecoratorNode, DecoratorNode } from './nodes/LexicalDecoratorNode';
@@ -8,7 +8,7 @@
8
8
  import type { NodeKey, SerializedLexicalNode } from '../LexicalNode';
9
9
  import type { BaseSelection, RangeSelection } from '../LexicalSelection';
10
10
  import type { KlassConstructor, Spread } from 'lexical';
11
- import { TextNode } from '../';
11
+ import { TextNode } from '../index';
12
12
  import { LexicalNode } from '../LexicalNode';
13
13
  export type SerializedElementNode<T extends SerializedLexicalNode = SerializedLexicalNode> = Spread<{
14
14
  children: Array<T>;
@@ -5,23 +5,33 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- import type { EditorConfig, LexicalEditor } from '../LexicalEditor';
9
- import type { DOMConversionMap, DOMExportOutput, LexicalNode } from '../LexicalNode';
8
+ import type { EditorConfig, KlassConstructor, LexicalEditor, Spread } from '../LexicalEditor';
9
+ import type { DOMConversionMap, DOMExportOutput, LexicalNode, NodeKey } from '../LexicalNode';
10
10
  import type { SerializedElementNode } from './LexicalElementNode';
11
11
  import type { RangeSelection } from 'lexical';
12
12
  import { ElementNode } from './LexicalElementNode';
13
- export type SerializedParagraphNode = SerializedElementNode;
13
+ import { TextFormatType } from './LexicalTextNode';
14
+ export type SerializedParagraphNode = Spread<{
15
+ textFormat: number;
16
+ }, SerializedElementNode>;
14
17
  /** @noInheritDoc */
15
18
  export declare class ParagraphNode extends ElementNode {
19
+ ['constructor']: KlassConstructor<typeof ParagraphNode>;
20
+ /** @internal */
21
+ __textFormat: number;
22
+ constructor(key?: NodeKey);
16
23
  static getType(): string;
24
+ getTextFormat(): number;
25
+ setTextFormat(type: number): this;
26
+ hasTextFormat(type: TextFormatType): boolean;
17
27
  static clone(node: ParagraphNode): ParagraphNode;
18
28
  createDOM(config: EditorConfig): HTMLElement;
19
29
  updateDOM(prevNode: ParagraphNode, dom: HTMLElement, config: EditorConfig): boolean;
20
30
  static importDOM(): DOMConversionMap | null;
21
31
  exportDOM(editor: LexicalEditor): DOMExportOutput;
22
32
  static importJSON(serializedNode: SerializedParagraphNode): ParagraphNode;
23
- exportJSON(): SerializedElementNode;
24
- insertNewAfter(_: RangeSelection, restoreSelection: boolean): ParagraphNode;
33
+ exportJSON(): SerializedParagraphNode;
34
+ insertNewAfter(rangeSelection: RangeSelection, restoreSelection: boolean): ParagraphNode;
25
35
  collapseAtStart(): boolean;
26
36
  }
27
37
  export declare function $createParagraphNode(): ParagraphNode;
@@ -155,7 +155,7 @@ export declare class TextNode extends LexicalNode {
155
155
  * Sets the node detail to the provided TextDetailType or 32-bit integer. Note that the TextDetailType
156
156
  * version of the argument can only specify one detail value and doing so will remove all other detail values that
157
157
  * may be applied to the node. For toggling behavior, consider using {@link TextNode.toggleDirectionless}
158
- * or {@link TextNode.togglerUnmergeable}
158
+ * or {@link TextNode.toggleUnmergeable}
159
159
  *
160
160
  * @param detail - TextDetailType or 32-bit integer representing the node detail.
161
161
  *
package/package.json CHANGED
@@ -9,13 +9,31 @@
9
9
  "rich-text"
10
10
  ],
11
11
  "license": "MIT",
12
- "version": "0.14.2",
12
+ "version": "0.14.4",
13
13
  "main": "Lexical.js",
14
+ "types": "index.d.ts",
14
15
  "repository": {
15
16
  "type": "git",
16
17
  "url": "https://github.com/facebook/lexical",
17
18
  "directory": "packages/lexical"
18
19
  },
19
- "module": "Lexical.esm.js",
20
- "sideEffects": false
20
+ "module": "Lexical.mjs",
21
+ "sideEffects": false,
22
+ "exports": {
23
+ ".": {
24
+ "import": {
25
+ "types": "./index.d.ts",
26
+ "development": "./Lexical.dev.mjs",
27
+ "production": "./Lexical.prod.mjs",
28
+ "node": "./Lexical.node.mjs",
29
+ "default": "./Lexical.mjs"
30
+ },
31
+ "require": {
32
+ "types": "./index.d.ts",
33
+ "development": "./Lexical.dev.js",
34
+ "production": "./Lexical.prod.js",
35
+ "default": "./Lexical.js"
36
+ }
37
+ }
38
+ }
21
39
  }