lexical
Version:
Lexical is an extensible text editor framework that provides excellent reliability, accessible and performance.
9 lines (8 loc) • 137 kB
JavaScript
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
function t(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);throw n.search=r.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function e(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);n.search=r.toString(),console.warn(`Minified Lexical warning #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const n="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,r=n&&"documentMode"in document?document.documentMode:null,i=n&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),o=n&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),s=!(!n||!("InputEvent"in window)||r)&&"getTargetRanges"in new window.InputEvent("input"),l=n&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,c=n&&/Android/.test(navigator.userAgent),a=n&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!c,u=n&&/^(?=.*Chrome).*/i.test(navigator.userAgent),f=n&&c&&u,d=n&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&i&&!u,h=0,g=1,_=2,p=1,y=2,m=4,x=8,C=16,S=32,v=64,k=128,T=2047,N=1,b=2,w=3,E=4,O=5,M=6,A=a||l||d?"\xa0":"\u200b",D="\n\n",P=o?"\xa0":A,F="\u0591-\u07ff\ufb1d-\ufdfd\ufe70-\ufefc",L="A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02b8\u0300-\u0590\u0800-\u1fff\u200e\u2c00-\ufb1c\ufe00-\ufe6f\ufefd-\uffff",I=new RegExp("^[^"+L+"]*["+F+"]"),K=new RegExp("^[^"+F+"]*["+L+"]"),z={bold:1,capitalize:1024,code:16,highlight:k,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},R={directionless:1,unmergeable:2},B={center:2,end:6,justify:4,left:1,right:3,start:5},W={[b]:"center",[M]:"end",[E]:"justify",[N]:"left",[w]:"right",[O]:"start"},$={normal:0,segmented:2,token:1},J={[h]:"normal",[_]:"segmented",[g]:"token"},j="$",U="$config";class V{_front=new Set;_back=new Set;_cache;get size(){return this._front.size+this._back.size}addBack(t){return delete this._cache,this._front.has(t)||this._back.add(t),this}addFront(t){return delete this._cache,this._back.has(t)||this._front.add(t),this}delete(t){return delete this._cache,this._front.delete(t)||this._back.delete(t)}toArray(){const t=Array.from(this._front).reverse();for(const e of this._back)t.push(e);return t}toReadonlyArray(){return this._cache=this._cache||this.toArray(),this._cache}[Symbol.iterator](){return this.toReadonlyArray()[Symbol.iterator]()}}function Y(t,e,n,r,i,o){let s=t.getFirstChild();for(;null!==s;){const t=s.__key;s.__parent===e&&(Wi(s)&&Y(s,t,n,r,i,o),n.has(t)||o.delete(t),i.push(t)),s=s.getNextSibling()}}let q=!1,H=0;function G(t){H=t.timeStamp}function X(t,e,n){const r="BR"===t.nodeName,i=e.__lexicalLineBreak;return i&&(t===i||r&&t.previousSibling===i)||r&&void 0!==Ho(t,n)}function Q(t,e,n){const r=Js(Ps(n));let i=null,o=null;null!==r&&r.anchorNode===t&&(i=r.anchorOffset,o=r.focusOffset);const s=t.nodeValue;null!==s&&cs(e,s,i,o,!1)}function Z(t,e,n){if(Fr(t)){const e=t.anchor.getNode();if(e.is(n)&&t.format!==e.getFormat())return!1}return Ko(e)&&n.isAttached()}function tt(t,e,n,r){for(let i=t;i&&!cl(i);i=bs(i)){const t=Ho(i,e);if(void 0!==t){const e=Yo(t,n);if(e)return ji(e)||!Ys(i)?void 0:[i,e]}else if(i===r)return[r,ts(n)]}}function et(t,e,n){q=!0;const r=performance.now()-H>100;try{Ki(t,()=>{const i=Qr()||function(t){return t.getEditorState().read(()=>{const t=Qr();return null!==t?t.clone():null})}(t),s=new Map,l=t.getRootElement(),c=t._editorState,a=t._blockCursorElement;let u=!1,f="";for(let n=0;n<e.length;n++){const d=e[n],h=d.type,g=d.target,_=tt(g,t,c,l);if(!_)continue;const[p,y]=_;if("characterData"===h)r&&Tr(y)&&Ko(g)&&Z(i,g,y)&&Q(g,y,t);else if("childList"===h){u=!0;const e=d.addedNodes;for(let n=0;n<e.length;n++){const r=e[n],i=qo(r),s=r.parentNode;if(null!=s&&r!==a&&null===i&&!X(r,s,t)){if(o){const t=(Ys(r)?r.innerText:null)||r.nodeValue;t&&(f+=t)}s.removeChild(r)}}const n=d.removedNodes,r=n.length;if(r>0){let e=0;for(let i=0;i<r;i++){const r=n[i];(X(r,g,t)||a===r)&&(g.appendChild(r),e++)}r!==e&&s.set(p,y)}}}if(s.size>0)for(const[e,n]of s)n.reconcileObservedMutation(e,t);const d=n.takeRecords();if(d.length>0){for(let e=0;e<d.length;e++){const n=d[e],r=n.addedNodes,i=n.target;for(let e=0;e<r.length;e++){const n=r[e],o=n.parentNode;null==o||"BR"!==n.nodeName||X(n,i,t)||o.removeChild(n)}}n.takeRecords()}null!==i&&(u&&es(i),o&&ks(t)&&i.insertRawText(f))})}finally{q=!1}}function nt(t){const e=t._observer;if(null!==e){et(t,e.takeRecords(),e)}}function rt(t){!function(t){0===H&&Ps(t).addEventListener("textInput",G,!0)}(t),t._observer=new MutationObserver((e,n)=>{et(t,e,n)})}class it{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;constructor(t,e){this.key=t,this.parse=e.parse.bind(e),this.unparse=(e.unparse||gt).bind(e),this.isEqual=(e.isEqual||Object.is).bind(e),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=e.resetOnCopyNode||!1}}function ot(t,e){return new it(t,e)}function st(t,e,n="latest"){const r=("latest"===n?t.getLatest():t).__state;return r?r.getValue(e):e.defaultValue}function lt(t,e,n){const r=st(t,n,"direct"),i=st(e,n,"direct");return n.isEqual(r,i)?null:[r,i]}function ct(t,e,n){let r;if(xi(),"function"==typeof n){const i=t.getLatest(),o=st(i,e);if(r=n(o),e.isEqual(o,r))return i}else r=n;const i=t.getWritable();return ft(i).updateFromKnown(e,r),i}function at(t){const e=new Map,n=new Set;for(let r="function"==typeof t?t:t.replace;r.prototype&&void 0!==r.prototype.getType;r=Object.getPrototypeOf(r)){const{ownNodeConfig:t}=ul(r);if(t&&t.stateConfigs)for(const r of t.stateConfigs){let t;"stateConfig"in r?(t=r.stateConfig,r.flat&&n.add(t.key)):t=r,e.set(t.key,t)}}return{flatKeys:n,sharedConfigMap:e}}class ut{node;knownState;unknownState;sharedNodeState;size;constructor(t,e,n=void 0,r=new Map,i=void 0){this.node=t,this.sharedNodeState=e,this.unknownState=n,this.knownState=r;const{sharedConfigMap:o}=this.sharedNodeState,s=void 0!==i?i:function(t,e,n){let r=n.size;if(e)for(const i in e){const e=t.get(i);e&&n.has(e)||r++}return r}(o,n,r);this.size=s}getValue(t){const e=this.knownState.get(t);if(void 0!==e)return e;this.sharedNodeState.sharedConfigMap.set(t.key,t);let n=t.defaultValue;if(this.unknownState&&t.key in this.unknownState){const e=this.unknownState[t.key];void 0!==e&&(n=t.parse(e)),this.updateFromKnown(t,n)}return n}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){const t={...this.unknownState},e={};for(const[e,n]of this.knownState)e.isEqual(n,e.defaultValue)?delete t[e.key]:t[e.key]=e.unparse(n);for(const n of this.sharedNodeState.flatKeys)n in t&&(e[n]=t[n],delete t[n]);return ht(t)&&(e.$=t),e}getWritable(t){if(this.node===t)return this;const{sharedNodeState:e,unknownState:n}=this,r=new Map(this.knownState);return new ut(t,e,function(t,e,n){let r;if(n)for(const[i,o]of Object.entries(n)){const n=t.get(i);n?e.has(n)||e.set(n,n.parse(o)):(r=r||{},r[i]=o)}return r}(e.sharedConfigMap,r,n),r,this.size)}resetOnCopyNode(){for(const t of this.knownState.keys())t.resetOnCopyNode&&this.knownState.set(t,t.defaultValue);return this}updateFromKnown(t,e){const n=t.key;this.sharedNodeState.sharedConfigMap.set(n,t);const{knownState:r,unknownState:i}=this;r.has(t)||i&&n in i||(i&&(delete i[n],this.unknownState=ht(i)),this.size++),r.set(t,e)}updateFromUnknown(t,e){const n=this.sharedNodeState.sharedConfigMap.get(t);n?this.updateFromKnown(n,n.parse(e)):(this.unknownState=this.unknownState||{},t in this.unknownState||this.size++,this.unknownState[t]=e)}updateFromJSON(t){const{knownState:e}=this;for(const t of e.keys())e.set(t,t.defaultValue);if(this.size=e.size,this.unknownState=void 0,t)for(const[e,n]of Object.entries(t))this.updateFromUnknown(e,n)}}function ft(t){const e=t.getWritable(),n=e.__state?e.__state.getWritable(e):new ut(e,dt(e));return e.__state=n,n}function dt(t){return t.__state?t.__state.sharedNodeState:No(Zs(),t.getType()).sharedNodeState}function ht(t){if(t)for(const e in t)return t}function gt(t){return t}function _t(t,e,n){for(const[r,i]of e.knownState){if(t.has(r.key))continue;t.add(r.key);const e=n?n.getValue(r):r.defaultValue;if(e!==i&&!r.isEqual(e,i))return!0}return!1}function pt(t,e,n){const{unknownState:r}=e,i=n?n.unknownState:void 0;if(r)for(const[e,n]of Object.entries(r)){if(t.has(e))continue;t.add(e);if(n!==(i?i[e]:void 0))return!0}return!1}function yt(t,e){const n=t.__state;return n&&n.node===t?n.getWritable(e):n}function mt(t,e){const n=t.__mode,r=t.__format,i=t.__style,o=e.__mode,s=e.__format,l=e.__style,c=t.__state,a=e.__state;return(null===n||n===o)&&(null===r||r===s)&&(null===i||i===l)&&(null===t.__state||c===a||function(t,e){if(t===e)return!0;const n=new Set;return!(t&&_t(n,t,e)||e&&_t(n,e,t)||t&&pt(n,t,e)||e&&pt(n,e,t))}(c,a))}function xt(t,e){const n=t.mergeWithSibling(e),r=vi()._normalizedNodes;return r.add(t.__key),r.add(e.__key),n}function Ct(t){let e,n,r=t;if(""!==r.__text||!r.isSimpleText()||r.isUnmergeable()){for(;null!==(e=r.getPreviousSibling())&&Tr(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(""!==e.__text){if(mt(e,r)){r=xt(e,r);break}break}e.remove()}for(;null!==(n=r.getNextSibling())&&Tr(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(""!==n.__text){if(mt(r,n)){r=xt(r,n);break}break}n.remove()}}else r.remove()}function St(t){return vt(t.anchor),vt(t.focus),t}function vt(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),Tr(r)){t.set(r.__key,i?r.getTextContentSize():0,"text",!0);break}if(!Wi(r))break;t.set(r.__key,i?r.getChildrenSize():0,"element",!0)}}let kt,Tt,Nt,bt,wt,Et,Ot,Mt,At,Dt,Pt,Ft="",Lt=null,It=null,Kt=!1,zt=!1;function Rt(t,e){const n=Ot.get(t);if(null!==e){const n=ne(t);n.parentNode===e&&e.removeChild(n)}if(Mt.has(t)||Tt._keyToDOMMap.delete(t),Wi(n)){const t=hl(n,Ot);Bt(t,0,t.length-1,null)}void 0!==n&&xs(Dt,Nt,bt,n,"destroyed")}function Bt(t,e,n,r){for(let i=e;i<=n;++i){const e=t[i];void 0!==e&&Rt(e,r)}}function Wt(t,e){t.setProperty("text-align",e)}const $t="40px";function Jt(t,e){const n=kt.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)}if(0===e)return void t.style.setProperty("padding-inline-start","");const r=getComputedStyle(Tt._rootElement||t).getPropertyValue("--lexical-indent-base-value")||$t;t.style.setProperty("padding-inline-start",`calc(${e} * ${r})`)}function jt(t,e){const n=t.style;0===e?Wt(n,""):1===e?Wt(n,"left"):2===e?Wt(n,"center"):3===e?Wt(n,"right"):4===e?Wt(n,"justify"):5===e?Wt(n,"start"):6===e&&Wt(n,"end")}function Ut(t,e){const n=function(t){const e=t.__dir;if(null!==e)return e;if(Vi(t))return null;const n=t.getParentOrThrow();return Vi(n)&&null===n.__dir?"auto":null}(e);null!==n?t.dir=n:t.removeAttribute("dir")}function Vt(e,n){const r=Mt.get(e);void 0===r&&t(60);const i=Pt.$createDOM(r,Tt);if(function(t,e,n){const r=n._keyToDOMMap;(function(t,e,n){const r=`__lexicalKey_${e._key}`;t[r]=n})(e,n,t),r.set(t,e)}(e,i,Tt),Tr(r)?i.setAttribute("data-lexical-text","true"):ji(r)&&i.setAttribute("data-lexical-decorator","true"),Wi(r)){const t=r.__indent,e=r.__size;if(Ut(i,r),0!==t&&Jt(i,t),0!==e){const t=e-1;Yt(hl(r,Mt),r,0,t,Pt.$getDOMSlot(r,i,Tt))}const n=r.__format;0!==n&&jt(i,n),r.isInline()||Ht(null,r,i)}else{const t=r.getTextContent();if(ji(r)){const t=r.decorate(Tt,kt);null!==t&&Qt(e,t),i.contentEditable="false"}Ft+=t}return null!==n&&n.insertChild(i),Pt.$decorateDOM(r,null,i,Tt),xs(Dt,Nt,bt,r,"created"),i}function Yt(t,e,n,r,i){const o=Ft;Ft="";let s=n;for(;s<=r;++s){Vt(t[s],i);const e=Mt.get(t[s]);null!==e&&Tr(e)?null===Lt&&(Lt=e.getFormat(),It=e.getStyle()):Wi(e)&&s<r&&!e.isInline()&&(Ft+=D)}i.element.__lexicalTextContent=Ft,Ft=o+Ft}function qt(t,e){if(t){const n=t.__last;if(n){const t=e.get(n);if(t)return sr(t)?"line-break":ji(t)&&t.isInline()?"decorator":null}return"empty"}return null}function Ht(t,e,n){const r=qt(t,Ot),i=qt(e,Mt);r!==i&&Pt.$getDOMSlot(e,n,Tt).setManagedLineBreak(i)}function Gt(e,n,r){var i;Lt=null,It=null,function(e,n,r){const i=Ft,o=e.__size,s=n.__size;Ft="";const l=r.element;if(1===o&&1===s){const t=e.__first,r=n.__first;if(t===r)Xt(t,l);else{const e=ne(t),n=Vt(r,null);try{l.replaceChild(n,e)}catch(i){if("object"==typeof i&&null!=i){const o=`${i.toString()} Parent: ${l.tagName}, new child: {tag: ${n.tagName} key: ${r}}, old child: {tag: ${e.tagName}, key: ${t}}.`;throw new Error(o)}throw i}Rt(t,null)}const i=Mt.get(r);Tr(i)&&null===Lt&&(Lt=i.getFormat(),It=i.getStyle())}else{const i=hl(e,Ot),c=hl(n,Mt);if(i.length!==o&&t(227),c.length!==s&&t(228),0===o)0!==s&&Yt(c,0,0,s-1,r);else if(0===s){if(0!==o){const t=null==r.after&&null==r.before&&null==r.element.__lexicalLineBreak;Bt(i,0,o-1,t?null:l),t&&(l.textContent="")}}else!function(t,e,n,r,i,o){const s=r-1,l=i-1;let c,a,u=o.getFirstChild(),f=0,d=0;for(;f<=s&&d<=l;){const t=e[f],r=n[d];if(t===r)u=Zt(Xt(r,o.element)),f++,d++;else{if(void 0===a&&(a=te(n,d)),void 0===c)c=te(e,f);else if(!c.has(t)){f++;continue}if(!a.has(t)){u=Zt(ne(t)),Rt(t,o.element),f++,c.delete(t);continue}if(c.has(r)){const t=Ns(Tt,r);t!==u&&o.withBefore(u).insertChild(t),u=Zt(Xt(r,o.element)),f++,d++}else Vt(r,o.withBefore(u)),d++}const i=Mt.get(r);null!==i&&Tr(i)?null===Lt&&(Lt=i.getFormat(),It=i.getStyle()):Wi(i)&&d<=l&&!i.isInline()&&(Ft+=D)}const h=f>s,g=d>l;if(h&&!g){const t=n[l+1],e=void 0===t?null:Tt.getElementByKey(t);Yt(n,0,d,l,o.withBefore(e))}else g&&!h&&Bt(e,f,s,o.element)}(0,i,c,o,s,r)}l.__lexicalTextContent=Ft,Ft=i+Ft}(e,n,Pt.$getDOMSlot(n,r,Tt)),i=n,null==Lt||Lt===i.__textFormat||zt||i.setTextFormat(Lt),function(t){null==It||It===t.__textStyle||zt||t.setTextStyle(It)}(n)}function Xt(e,n){const r=Ot.get(e);let i=Mt.get(e);void 0!==r&&void 0!==i||t(61);const o=Kt||Et.has(e)||wt.has(e),s=Ns(Tt,e);if(r===i&&!o){let t;if(Wi(r)){const e=s.__lexicalTextContent;"string"==typeof e?t=e:(t=r.getTextContent(),s.__lexicalTextContent=t)}else t=r.getTextContent();return Ft+=t,s}if(r!==i&&o&&xs(Dt,Nt,bt,i,"updated"),Pt.$updateDOM(i,r,s,Tt)){const r=Vt(e,null);return null===n&&t(62),n.replaceChild(r,s),Rt(e,null),r}if(Wi(r)){Wi(i)||t(334,e);const n=i.__indent;(Kt||n!==r.__indent)&&Jt(s,n);const l=i.__format;if((Kt||l!==r.__format)&&jt(s,l),o)Gt(r,i,s),Vi(i)||i.isInline()||Ht(r,i,s);else{const t=s.__lexicalTextContent;let e;"string"==typeof t?e=t:(e=r.getTextContent(),s.__lexicalTextContent=e),Ft+=e}if((Kt||i.__dir!==r.__dir)&&(Ut(s,i),Vi(i)&&!Kt))for(const t of i.getChildren())if(Wi(t)){Ut(Ns(Tt,t.getKey()),t)}}else{const t=i.getTextContent();if(ji(i)){const t=i.decorate(Tt,kt);null!==t&&Qt(e,t)}Ft+=t}if(!zt&&Vi(i)&&i.__cachedText!==Ft){const t=i.getWritable();t.__cachedText=Ft,i=t}return Pt.$decorateDOM(i,r,s,Tt),s}function Qt(t,e){let n=Tt._pendingDecorators;const r=Tt._decorators;if(null===n){if(r[t]===e)return;n=Xo(Tt)}n[t]=e}function Zt(t){let e=t.nextSibling;return null!==e&&e===Tt._blockCursorElement&&(e=e.nextSibling),e}function te(t,e){const n=new Set;for(let r=e;r<t.length;r++)n.add(t[r]);return n}function ee(t,e,n,r,i,o){Ft="",Kt=2===r,Tt=n,kt=n._config,Pt=n._config.dom||po,Nt=n._nodes,bt=Tt._listeners.mutation,wt=i,Et=o,Ot=t._nodeMap,Mt=e._nodeMap,zt=e._readOnly,At=new Map(n._keyToDOMMap);const s=new Map;return Dt=s,Xt("root",null),Tt=void 0,Nt=void 0,wt=void 0,Et=void 0,Ot=void 0,Mt=void 0,kt=void 0,At=void 0,Dt=void 0,Pt=po,s}function ne(e){const n=At.get(e);return void 0===n&&t(75,e),n}function re(t){return{type:t}}const ie=re("SELECTION_CHANGE_COMMAND"),oe=re("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),se=re("CLICK_COMMAND"),le=re("BEFORE_INPUT_COMMAND"),ce=re("INPUT_COMMAND"),ae=re("COMPOSITION_START_COMMAND"),ue=re("COMPOSITION_END_COMMAND"),fe=re("DELETE_CHARACTER_COMMAND"),de=re("INSERT_LINE_BREAK_COMMAND"),he=re("INSERT_PARAGRAPH_COMMAND"),ge=re("CONTROLLED_TEXT_INSERTION_COMMAND"),_e=re("PASTE_COMMAND"),pe=re("REMOVE_TEXT_COMMAND"),ye=re("DELETE_WORD_COMMAND"),me=re("DELETE_LINE_COMMAND"),xe=re("FORMAT_TEXT_COMMAND"),Ce=re("UNDO_COMMAND"),Se=re("REDO_COMMAND"),ve=re("KEYDOWN_COMMAND"),ke=re("KEY_ARROW_RIGHT_COMMAND"),Te=re("MOVE_TO_END"),Ne=re("KEY_ARROW_LEFT_COMMAND"),be=re("MOVE_TO_START"),we=re("KEY_ARROW_UP_COMMAND"),Ee=re("KEY_ARROW_DOWN_COMMAND"),Oe=re("KEY_ENTER_COMMAND"),Me=re("KEY_SPACE_COMMAND"),Ae=re("KEY_BACKSPACE_COMMAND"),De=re("KEY_ESCAPE_COMMAND"),Pe=re("KEY_DELETE_COMMAND"),Fe=re("KEY_TAB_COMMAND"),Le=re("INSERT_TAB_COMMAND"),Ie=re("INDENT_CONTENT_COMMAND"),Ke=re("OUTDENT_CONTENT_COMMAND"),ze=re("DROP_COMMAND"),Re=re("FORMAT_ELEMENT_COMMAND"),Be=re("DRAGSTART_COMMAND"),We=re("DRAGOVER_COMMAND"),$e=re("DRAGEND_COMMAND"),Je=re("COPY_COMMAND"),je=re("CUT_COMMAND"),Ue=re("SELECT_ALL_COMMAND"),Ve=re("CLEAR_EDITOR_COMMAND"),Ye=re("CLEAR_HISTORY_COMMAND"),qe=re("CAN_REDO_COMMAND"),He=re("CAN_UNDO_COMMAND"),Ge=re("FOCUS_COMMAND"),Xe=re("BLUR_COMMAND"),Qe=re("KEY_MODIFIER_COMMAND"),Ze=Object.freeze({}),tn=[["keydown",function(t,e){if(en=t.timeStamp,nn=t.key,e.isComposing())return;Ts(e,ve,t)}],["pointerdown",function(t,e){const n=t.target,r=t.pointerType;qs(n)&&"touch"!==r&&"pen"!==r&&0===t.button&&Ki(e,()=>{Eo(n)||(an=!0)})}],["compositionstart",function(t,e){Ts(e,ae,t)}],["compositionend",function(t,e){o?fn=!0:l||!a&&!d?Ts(e,ue,t):(dn=!0,hn=t.data)}],["input",function(t,e){t.stopPropagation(),Ki(e,()=>{e.dispatchCommand(ce,t)},{event:t}),on=null}],["click",function(t,e){Ki(e,()=>{const n=Qr(),r=Js(Ps(e)),i=Zr();if(r)if(Fr(n)){const e=n.anchor,o=e.getNode();if("element"===e.type&&0===e.offset&&n.isCollapsed()&&!Vi(o)&&1===Zo().getChildrenSize()&&o.getTopLevelElementOrThrow().isEmpty()&&null!==i&&n.is(i))r.removeAllRanges(),n.dirty=!0;else if(3===t.detail&&!n.isCollapsed()){if(o!==n.focus.getNode()){const t=dl(o,t=>Wi(t)&&!t.isInline());Wi(t)&&t.select(0)}}}else if("touch"===t.pointerType||"pen"===t.pointerType){const n=r.anchorNode;if(Ys(n)||Ko(n)){es(Xr(i,r,e,t))}}Ts(e,se,t)})}],["cut",Ze],["copy",Ze],["dragstart",Ze],["dragover",Ze],["dragend",Ze],["paste",Ze],["focus",Ze],["blur",Ze],["drop",Ze]];s&&tn.push(["beforeinput",(t,e)=>function(t,e){const n=t.inputType;if("deleteCompositionText"===n||o&&ks(e))return;if("insertCompositionText"===n)return;Ts(e,le,t)}(t,e)]);let en=0,nn=null,rn=0,on=null;const sn=new WeakMap,ln=new WeakMap;let cn=!1,an=!1,un=!1,fn=!1,dn=!1,hn="",gn=null,_n=[0,"",0,"root",0];function pn(t,e,n,r,i){const o=t.anchor,l=t.focus,c=o.getNode(),a=vi(),u=Js(Ps(a)),f=null!==u?u.anchorNode:null,d=o.key,h=a.getElementByKey(d),g=n.length;return d!==l.key||!Tr(c)||(!i&&(!s||rn<r+50)||c.isDirty()&&g<2||rs(n))&&o.offset!==l.offset&&!c.isComposing()||Io(c)||c.isDirty()&&g>1||(i||!s)&&null!==h&&!c.isComposing()&&f!==Ro(h)||null!==u&&null!==e&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||!c.isComposing()&&(c.getFormat()!==t.format||c.getStyle()!==t.style)||function(t,e){if(e.isSegmented())return!0;if(!t.isCollapsed())return!1;const n=t.anchor.offset,r=e.getParentOrThrow(),i=Lo(e);return 0===n?!e.canInsertTextBefore()||!r.canInsertTextBefore()&&!e.isComposing()||i||function(t){const e=t.getPreviousSibling();return(Tr(e)||Wi(e)&&e.isInline())&&!e.canInsertTextAfter()}(e):n===e.getTextContentSize()&&(!e.canInsertTextAfter()||!r.canInsertTextAfter()&&!e.isComposing()||i)}(t,c)}function yn(t,e){return Ko(t)&&null!==t.nodeValue&&0!==e&&e!==t.nodeValue.length}function mn(e,n,r){const{anchorNode:i,anchorOffset:o,focusNode:s,focusOffset:l}=e;cn&&(cn=!1,yn(i,o)&&yn(s,l)&&!gn)||Ki(n,()=>{if(!r)return void es(null);if(!Mo(n,i,s))return;let c=Qr();if(gn&&Fr(c)&&c.isCollapsed()){const t=c.anchor,e=gn.anchor;(t.key===e.key&&t.offset===e.offset+1||1===t.offset&&e.getNode().is(t.getNode().getPreviousSibling()))&&(c=gn.clone(),es(c))}if(gn=null,Fr(c)){const r=c.anchor,i=r.getNode();if(c.isCollapsed()){"Range"===e.type&&e.anchorNode===e.focusNode&&(c.dirty=!0);const o=Ps(n).event,s=o?o.timeStamp:performance.now(),[l,a,u,f,d]=_n,h=Zo(),g=!1===n.isComposing()&&""===h.getTextContent();if(s<d+200&&r.offset===u&&r.key===f)xn(c,l,a);else if("text"===r.type)Tr(i)||t(141),Cn(c,i);else if("element"===r.type&&!g){Wi(i)||t(259);const e=r.getNode();e.isEmpty()?function(t,e){const n=e.getTextFormat(),r=e.getTextStyle();xn(t,n,r)}(c,e):xn(c,c.format,"")}}else{const t=r.key,e=c.focus.key,n=c.getNodes(),i=n.length,s=c.isBackward(),a=s?l:o,u=s?o:l,f=s?e:t,d=s?t:e;let h=2047,g=!1;for(let t=0;t<i;t++){const e=n[t],r=e.getTextContentSize();if(Tr(e)&&0!==r&&!(0===t&&e.__key===f&&a===r||t===i-1&&e.__key===d&&0===u)&&(g=!0,h&=e.getFormat(),0===h))break}c.format=g?h:0}}Ts(n,ie,void 0)})}function xn(t,e,n){t.format===e&&t.style===n||(t.format=e,t.style=n,t.dirty=!0)}function Cn(t,e){xn(t,e.getFormat(),e.getStyle())}function Sn(t){if(!t.getTargetRanges)return null;const e=t.getTargetRanges();return 0===e.length?null:e[0]}function vn(e){const n=e.inputType,r=Sn(e),i=vi(),o=Qr();if("deleteContentBackward"===n){if(null===o){const t=Zr();if(!Fr(t))return!0;es(t.clone())}if(Fr(o)){const n=o.anchor.key===o.focus.key;if(s=e.timeStamp,"MediaLast"===nn&&s<en+30&&i.isComposing()&&n){if(Uo(null),en=0,setTimeout(()=>{Ki(i,()=>{Uo(null)})},30),Fr(o)){const e=o.anchor.getNode();e.markDirty(),Tr(e)||t(142),Cn(o,e)}}else{Uo(null),e.preventDefault();const t=o.anchor.getNode(),r=t.getTextContent(),s=t.canInsertTextAfter(),l=0===o.anchor.offset&&o.focus.offset===r.length;let c=f&&n&&!l&&s;if(c&&o.isCollapsed()&&(c=!ji(vs(o.anchor,!0))),!c){Ts(i,fe,!0);const t=Qr();f&&Fr(t)&&t.isCollapsed()&&(gn=t,setTimeout(()=>gn=null))}}return!0}}var s;if(!Fr(o))return!0;const c=e.data;null!==on&&ls(!1,i,on),o.dirty&&null===on||!o.isCollapsed()||Vi(o.anchor.getNode())||null===r||o.applyDOMRange(r),on=null;const a=o.anchor,u=o.focus,d=a.getNode(),h=u.getNode();if("insertText"===n||"insertTranspose"===n){if("\n"===c)e.preventDefault(),Ts(i,de,!1);else if(c===D)e.preventDefault(),Ts(i,he,void 0);else if(null==c&&e.dataTransfer){const t=e.dataTransfer.getData("text/plain");e.preventDefault(),o.insertRawText(t)}else null!=c&&pn(o,r,c,e.timeStamp,!0)?(e.preventDefault(),Ts(i,ge,c)):on=c;return rn=e.timeStamp,!0}switch(e.preventDefault(),n){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":Ts(i,ge,e);break;case"insertFromComposition":Uo(null),Ts(i,ge,e);break;case"insertLineBreak":Uo(null),Ts(i,de,!1);break;case"insertParagraph":Uo(null),un&&!l?(un=!1,Ts(i,de,!1)):Ts(i,he,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":Ts(i,_e,e);break;case"deleteByComposition":(function(t,e){return t!==e||Wi(t)||Wi(e)||!Lo(t)||!Lo(e)})(d,h)&&Ts(i,pe,e);break;case"deleteByDrag":Os(Hn),Ts(i,pe,e);break;case"deleteByCut":Ts(i,pe,e);break;case"deleteContent":Ts(i,fe,!1);break;case"deleteWordBackward":Ts(i,ye,!0);break;case"deleteWordForward":Ts(i,ye,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":Ts(i,me,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":Ts(i,me,!1);break;case"formatStrikeThrough":Ts(i,xe,"strikethrough");break;case"formatBold":Ts(i,xe,"bold");break;case"formatItalic":Ts(i,xe,"italic");break;case"formatUnderline":Ts(i,xe,"underline");break;case"historyUndo":Ts(i,Ce,void 0);break;case"historyRedo":Ts(i,Se,void 0)}return!0}function kn(t){if(Ys(t.target)&&Eo(t.target))return!0;const e=vi(),n=Qr(),r=t.data,i=Sn(t);if(null!=r&&Fr(n)&&pn(n,i,r,t.timeStamp,!1)){fn&&(bn(e,r),fn=!1);const i=n.anchor.getNode(),l=Js(Ps(e));if(null===l)return!0;const c=n.isBackward(),a=c?n.anchor.offset:n.focus.offset,u=c?n.focus.offset:n.anchor.offset;s&&!n.isCollapsed()&&Tr(i)&&null!==l.anchorNode&&i.getTextContent().slice(0,a)+r+i.getTextContent().slice(a+u)===ss(l.anchorNode)||Ts(e,ge,r);const d=r.length;o&&d>1&&"insertCompositionText"===t.inputType&&!e.isComposing()&&(n.anchor.offset-=d),f&&e.isComposing()&&(en=0,Uo(null))}else{ls(!1,e,null!==r?r:void 0),fn&&(bn(e,r||void 0),fn=!1)}return function(){xi();const t=vi();nt(t)}(),!0}function Tn(t){const e=vi(),n=Qr();if(Fr(n)&&!e.isComposing()){const r=n.anchor,i=n.anchor.getNode();Uo(r.key),Os(Gn),(t.timeStamp<en+30||"element"===r.type||!n.isCollapsed()||i.getFormat()!==n.format||Tr(i)&&i.getStyle()!==n.style)&&Ts(e,ge,P)}return!0}function Nn(t){return bn(vi(),t.data),Os(Xn),!0}function bn(t,e){const n=t._compositionKey;if(Uo(null),null!==n&&null!=e){if(""===e){const e=Yo(n),r=Ro(t.getElementByKey(n));if(null!==r&&null!==r.nodeValue&&Tr(e)){const n=Js(Ps(t));let i=null,o=null;null!==n&&n.anchorNode===r&&(i=n.anchorOffset,o=n.focusOffset),cs(e,r.nodeValue,i,o,!0)}return}if("\n"===e[e.length-1]){const e=Qr();if(Fr(e)||Ir(e)){if(Fr(e)){const t=e.focus;e.anchor.set(t.key,t.offset,t.type)}return void Ts(t,Oe,null)}}}ls(!0,t,e)}function wn(t){const e=vi();if(null==t.key)return!0;if(dn){if(_s(t))return Ki(e,()=>{bn(e,hn)}),dn=!1,hn="",!0;dn=!1,hn=""}if(function(t){return ds(t,"ArrowRight",{shiftKey:"any"})}(t))Ts(e,ke,t);else if(function(t){return ds(t,"ArrowRight",hs)}(t))Ts(e,Te,t);else if(function(t){return ds(t,"ArrowLeft",{shiftKey:"any"})}(t))Ts(e,Ne,t);else if(function(t){return ds(t,"ArrowLeft",hs)}(t))Ts(e,be,t);else if(function(t){return ds(t,"ArrowUp",{altKey:"any",shiftKey:"any"})}(t))Ts(e,we,t);else if(function(t){return ds(t,"ArrowDown",{altKey:"any",shiftKey:"any"})}(t))Ts(e,Ee,t);else if(function(t){return ds(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any",shiftKey:!0})}(t))un=!0,Ts(e,Oe,t);else if(function(t){return" "===t.key}(t))Ts(e,Me,t);else if(function(t){return i&&ds(t,"o",{ctrlKey:!0})}(t))t.preventDefault(),un=!0,Ts(e,de,!0);else if(function(t){return ds(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any"})}(t))un=!1,Ts(e,Oe,t);else if(function(t){return ds(t,"Backspace",{shiftKey:"any"})||i&&ds(t,"h",{ctrlKey:!0})}(t))_s(t)?Ts(e,Ae,t):(t.preventDefault(),Ts(e,fe,!0));else if(function(t){return"Escape"===t.key}(t))Ts(e,De,t);else if(function(t){return ds(t,"Delete",{})||i&&ds(t,"d",{ctrlKey:!0})}(t))!function(t){return"Delete"===t.key}(t)?(t.preventDefault(),Ts(e,fe,!1)):Ts(e,Pe,t);else if(function(t){return ds(t,"Backspace",gs)}(t))t.preventDefault(),Ts(e,ye,!0);else if(function(t){return ds(t,"Delete",gs)}(t))t.preventDefault(),Ts(e,ye,!1);else if(function(t){return i&&ds(t,"Backspace",{metaKey:!0})}(t))t.preventDefault(),Ts(e,me,!0);else if(function(t){return i&&(ds(t,"Delete",{metaKey:!0})||ds(t,"k",{ctrlKey:!0}))}(t))t.preventDefault(),Ts(e,me,!1);else if(function(t){return ds(t,"b",hs)}(t))t.preventDefault(),Ts(e,xe,"bold");else if(function(t){return ds(t,"u",hs)}(t))t.preventDefault(),Ts(e,xe,"underline");else if(function(t){return ds(t,"i",hs)}(t))t.preventDefault(),Ts(e,xe,"italic");else if(function(t){return ds(t,"Tab",{shiftKey:"any"})}(t))Ts(e,Fe,t);else if(function(t){return ds(t,"z",hs)}(t))t.preventDefault(),Ts(e,Ce,void 0);else if(function(t){if(i)return ds(t,"z",{metaKey:!0,shiftKey:!0});return ds(t,"y",{ctrlKey:!0})||ds(t,"z",{ctrlKey:!0,shiftKey:!0})}(t))t.preventDefault(),Ts(e,Se,void 0);else{const n=e._editorState._selection;null===n||Fr(n)?ps(t)&&(t.preventDefault(),Ts(e,Ue,t)):!function(t){return ds(t,"c",hs)}(t)?!function(t){return ds(t,"x",hs)}(t)?ps(t)&&(t.preventDefault(),Ts(e,Ue,t)):(t.preventDefault(),Ts(e,je,t)):(t.preventDefault(),Ts(e,Je,t))}return function(t){return t.ctrlKey||t.shiftKey||t.altKey||t.metaKey}(t)&&e.dispatchCommand(Qe,t),!0}function En(t){let e=t.__lexicalEventHandles;return void 0===e&&(e=[],t.__lexicalEventHandles=e),e}const On=new Map;function Mn(t){const e=js(t.target);if(null===e)return;const n=Do(e.anchorNode);if(null===n)return;an&&(an=!1,Ki(n,()=>{const r=Zr(),i=e.anchorNode;if(Ys(i)||Ko(i)){es(Xr(r,e,n,t))}}));const r=is(n),i=r[r.length-1],o=i._key,s=On.get(o),l=s||i;l!==n&&mn(e,l,!1),mn(e,n,!0),n!==i?On.set(o,n):s&&On.delete(o)}function An(t){t._lexicalHandled=!0}function Dn(t){return!0===t._lexicalHandled}const Pn=()=>{};function Fn(e){const n=sn.get(e);if(void 0===n)return void Pn();const r=ln.get(n);if(void 0===r)return void Pn();const i=r-1;i>=0||t(164),sn.delete(e),ln.set(n,i),0===i&&n.removeEventListener("selectionchange",Mn);const o=Po(e);Ao(o)?(!function(t){if(null!==t._parentEditor){const e=is(t),n=e[e.length-1]._key;On.get(n)===t&&On.delete(n)}else On.delete(t._key)}(o),e.__lexicalEditor=null):o&&t(198);const s=En(e);for(let t=0;t<s.length;t++)s[t]();e.__lexicalEventHandles=[]}function Ln(t,e,n){xi();const r=t.__key,i=t.getParent();if(null===i)return;const o=function(t){const e=Qr();if(!Fr(e)||!Wi(t))return e;const{anchor:n,focus:r}=e,i=n.getNode(),o=r.getNode();As(i,t)&&n.set(t.__key,0,"element");As(o,t)&&r.set(t.__key,0,"element");return e}(t);let s=!1;if(Fr(o)&&e){const e=o.anchor,n=o.focus;e.key===r&&(ni(e,t,i,t.getPreviousSibling(),t.getNextSibling()),s=!0),n.key===r&&(ni(n,t,i,t.getPreviousSibling(),t.getNextSibling()),s=!0)}else Ir(o)&&e&&t.isSelected()&&t.selectPrevious();if(Fr(o)&&e&&!s){const e=t.getIndexWithinParent();Jo(t),ti(o,i,e,-1)}else Jo(t);n||Is(i)||i.canBeEmpty()||!i.isEmpty()||Ln(i,e),e&&o&&Vi(i)&&i.isEmpty()&&i.selectEnd()}function In(t){return t}const Kn=Symbol.for("ephemeral");function zn(t){return t[Kn]||!1}class Rn{__type;__key;__parent;__prev;__next;__state;static getType(){const{ownNodeType:e}=ul(this);return void 0===e&&t(64,this.name),e}static clone(e){t(65,this.name)}$config(){return{}}config(t,e){const n=e.extends||Object.getPrototypeOf(this.constructor);return Object.assign(e,{extends:n,type:t}),{[t]:e}}afterCloneFrom(t){this.__key===t.__key?(this.__parent=t.__parent,this.__next=t.__next,this.__prev=t.__prev,this.__state=t.__state):t.__state&&(this.__state=t.__state.getWritable(this))}resetOnCopyNodeFrom(t){this.__state&&(this.__state=this.__state.getWritable(this).resetOnCopyNode())}static importDOM;constructor(t){this.__type=this.constructor.getType(),this.__parent=null,this.__prev=null,this.__next=null,Object.defineProperty(this,"__state",{configurable:!0,enumerable:!1,value:void 0,writable:!0}),$o(this,t)}getType(){return this.__type}isInline(){t(137,this.constructor.name)}isAttached(){let t=this.__key;for(;null!==t;){if("root"===t)return!0;const e=Yo(t);if(null===e)break;t=e.__parent}return!1}isSelected(t){const e=t||Qr();if(null==e)return!1;const n=e.getNodes().some(t=>t.__key===this.__key);if(Tr(this))return n;if(Fr(e)&&"element"===e.anchor.type&&"element"===e.focus.type){if(e.isCollapsed())return!1;const t=this.getParent();if(ji(this)&&this.isInline()&&t){const n=e.isBackward()?e.focus:e.anchor;if(t.is(n.getNode())&&n.offset===t.getChildrenSize()&&this.is(t.getLastChild()))return!1}}return 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:Yo(t)}getParentOrThrow(){const e=this.getParent();return null===e&&t(66,this.__key),e}getTopLevelElement(){let e=this;for(;null!==e;){const n=e.getParent();if(Is(n))return Wi(e)||e===this&&ji(e)||t(194),e;e=n}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return null===e&&t(67,this.__key),e}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:Yo(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:Yo(t)}getNextSiblings(){const t=[];let e=this.getNextSibling();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getCommonAncestor(t){const e=Wi(this)?this:this.getParent(),n=Wi(t)?t:t.getParent(),r=e&&n?Yl(e,n):null;return r?r.commonAncestor:null}is(t){return null!=t&&this.__key===t.__key}isBefore(e){const n=Yl(this,e);return null!==n&&("descendant"===n.type||("branch"===n.type?-1===jl(n):("same"!==n.type&&"ancestor"!==n.type&&t(279),!1)))}isParentOf(t){const e=Yl(this,t);return null!==e&&"ancestor"===e.type}getNodesBetween(e){const n=this.isBefore(e),r=[],i=new Set;let o=this;for(;null!==o;){const s=o.__key;if(i.has(s)||(i.add(s),r.push(o)),o===e)break;const l=Wi(o)?n?o.getFirstChild():o.getLastChild():null;if(null!==l){o=l;continue}const c=n?o.getNextSibling():o.getPreviousSibling();if(null!==c){o=c;continue}const a=o.getParentOrThrow();if(i.has(a.__key)||r.push(a),a===e)break;let u=null,f=a;do{if(null===f&&t(68),u=n?f.getNextSibling():f.getPreviousSibling(),f=f.getParent(),null===f)break;null!==u||i.has(f.__key)||r.push(f)}while(null===u);o=u}return n||r.reverse(),r}isDirty(){const t=vi()._dirtyLeaves;return null!==t&&t.has(this.__key)}getLatest(){if(zn(this))return this;const e=Yo(this.__key);return null===e&&t(113),e}getWritable(){if(zn(this))return this;xi();const t=Si(),e=vi(),n=t._nodeMap,r=this.__key,i=this.getLatest(),o=e._cloneNotNeeded,s=Qr();if(null!==s&&s.setCachedNodes(null),o.has(r))return jo(i),i;const l=il(i);return o.add(r),jo(l),n.set(r,l),l}getTextContent(){return""}getTextContentSize(){return this.getTextContent().length}createDOM(e,n){t(70)}updateDOM(e,n,r){t(71)}exportDOM(t){return{element:this.createDOM(t._config,t)}}exportJSON(){const t=this.__state?this.__state.toJSON():void 0;return{type:this.__type,version:1,...t}}static importJSON(e){t(18,this.name)}updateFromJSON(t){return function(t,e){const n=t.getWritable(),r=e.$;let i=r;for(const t of dt(n).flatKeys)t in e&&(void 0!==i&&i!==r||(i={...r}),i[t]=e[t]);return(n.__state||i)&&ft(t).updateFromJSON(i),n}(this,t)}static transform(){return null}remove(t){Ln(this,!0,t)}replace(e,n){xi();let r=Qr();null!==r&&(r=r.clone()),Rs(this,e);const i=this.getLatest(),o=this.__key,s=e.__key,l=e.getWritable(),c=this.getParentOrThrow().getWritable(),a=c.__size;Jo(l);const u=i.getPreviousSibling(),f=i.getNextSibling(),d=i.__prev,h=i.__next,g=i.__parent;if(Ln(i,!1,!0),null===u)c.__first=s;else{u.getWritable().__next=s}if(l.__prev=d,null===f)c.__last=s;else{f.getWritable().__prev=s}if(l.__next=h,l.__parent=g,c.__size=a,n&&(Wi(this)&&Wi(l)||t(139),this.getChildren().forEach(t=>{l.append(t)})),Fr(r)){es(r);const t=r.anchor,e=r.focus;t.key===o&&Dr(t,l),e.key===o&&Dr(e,l)}return Vo()===o&&Uo(s),l}insertAfter(t,e=!0){xi(),Rs(this,t);const n=this.getWritable(),r=t.getWritable(),i=r.getParent(),o=Qr();let s=!1,l=!1;if(null!==i){const e=t.getIndexWithinParent();if(Jo(r),Fr(o)){const t=i.__key,n=o.anchor,r=o.focus;s="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(),a=this.getParentOrThrow().getWritable(),u=r.__key,f=n.__next;if(null===c)a.__last=u;else{c.getWritable().__prev=u}if(a.__size++,n.__next=u,r.__next=f,r.__prev=n.__key,r.__parent=n.__parent,e&&Fr(o)){const t=this.getIndexWithinParent();ti(o,a,t+1);const e=a.__key;s&&o.anchor.set(e,t+2,"element"),l&&o.focus.set(e,t+2,"element")}return t}insertBefore(t,e=!0){xi(),Rs(this,t);const n=this.getWritable(),r=t.getWritable(),i=r.__key;Jo(r);const o=this.getPreviousSibling(),s=this.getParentOrThrow().getWritable(),l=n.__prev,c=this.getIndexWithinParent();if(null===o)s.__first=i;else{o.getWritable().__next=i}s.__size++,n.__prev=i,r.__prev=l,r.__next=n.__key,r.__parent=n.__parent;const a=Qr();if(e&&Fr(a)){ti(a,this.getParentOrThrow(),c)}return t}isParentRequired(){return!1}createParentElementNode(){return eo()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(t,e){xi();const n=this.getPreviousSibling(),r=this.getParentOrThrow();if(null===n)return r.select(0,0);if(Wi(n))return n.select();if(!Tr(n)){const t=n.getIndexWithinParent()+1;return r.select(t,t)}return n.select(t,e)}selectNext(t,e){xi();const n=this.getNextSibling(),r=this.getParentOrThrow();if(null===n)return r.select();if(Wi(n))return n.select(0,0);if(!Tr(n)){const t=n.getIndexWithinParent();return r.select(t,t)}return n.select(t,e)}markDirty(){this.getWritable()}reconcileObservedMutation(t,e){this.markDirty()}}function Bn(t){return t instanceof Rn}const Wn="historic",$n="history-push",Jn="history-merge",jn="paste",Un="collaboration",Vn="skip-collab",Yn="skip-scroll-into-view",qn="skip-dom-selection",Hn="skip-selection-focus",Gn="composition-start",Xn="composition-end",Qn=/\s*!important\s*$/i;function Zn(t){const e={};if(!t)return e;let n="",r="",i=null,o=!1,s=!1,l=!1,c=0;for(let a=0;a<t.length;a++){const u=t[a];if(o)"*"===u&&"/"===t[a+1]&&(o=!1,a++);else if(s)l?r+=u:n+=u,s=!1;else if(null===i)if("/"!==u||"*"!==t[a+1])if('"'!==u&&"'"!==u)if("("!==u)if(")"!==u)if(l||":"!==u||0!==c){if(";"===u&&0===c){const t=n.trim(),i=r.trim();""!==t&&""!==i&&(e[t]=i),n="",r="",l=!1;continue}l?r+=u:n+=u}else l=!0;else c=Math.max(0,c-1),l?r+=u:n+=u;else c++,l?r+=u:n+=u;else i=u,l?r+=u:n+=u;else o=!0,a++;else l?r+=u:n+=u,"\\"===u?s=!0:u===i&&(i=null)}const a=n.trim(),u=r.trim();return""!==a&&""!==u&&(e[a]=u),e}function tr(t,e,n){const r=Qn.test(n)?"important":"",i=""===r?n:n.replace(Qn,"").trim();t.setProperty(e,i,r)}function er(t,e){for(const n in e){const r=e[n];null==r?t.removeProperty(n):tr(t,n,r)}}function nr(t,e,n=""){if(e===n)return;const r=Zn(n),i=Zn(e);for(const e in i)delete r[e],tr(t,e,i[e]);for(const e in r)t.removeProperty(e)}class rr extends Rn{static getType(){return"linebreak"}static clone(t){return new rr(t.__key)}constructor(t){super(t)}getTextContent(){return"\n"}createDOM(){return document.createElement("br")}updateDOM(){return!1}isInline(){return!0}static importDOM(){return{br:t=>function(t){const e=t.parentElement;if(null!==e&&Xs(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&lr(n)){const n=e.lastChild;if(n===t||n.previousSibling===t&&lr(n))return!0}}return!1}(t)||function(t){const e=t.parentElement;if(null!==e&&Xs(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&lr(n))return!1;const r=e.lastChild;if(r===t||r.previousSibling===t&&lr(r))return!0}return!1}(t)?null:{conversion:ir,priority:0}}}static importJSON(t){return or().updateFromJSON(t)}}function ir(t){return{node:or()}}function or(){return zs(new rr)}function sr(t){return t instanceof rr}function lr(t){return Ko(t)&&/^( |\t|\r?\n)+$/.test(t.textContent||"")}function cr(t,e){return 16&e?"code":e&k?"mark":32&e?"sub":64&e?"sup":null}function ar(t,e){return 1&e?"strong":2&e?"em":"span"}function ur(t,e,n,r,i){const o=r.classList;let s=ms(i,"base");void 0!==s&&o.add(...s),s=ms(i,"underlineStrikethrough");let l=!1;const c=8&e&&4&e;void 0!==s&&(8&n&&4&n?(l=!0,c||o.add(...s)):c&&o.remove(...s));for(const t in z){const r=z[t];if(s=ms(i,t),void 0!==s)if(n&r){if(l&&("underline"===t||"strikethrough"===t)){e&r&&o.remove(...s);continue}(0===(e&r)||c&&"underline"===t||"strikethrough"===t)&&o.add(...s)}else e&r&&o.remove(...s)}}function fr(t,e,n){const r=e.firstChild,i=n.isComposing(),s=t+(i?A:"");if(null==r)e.textContent=s;else{const t=r.nodeValue;if(t!==s)if(i||o){const[e,n,i]=function(t,e){const n=t.length,r=e.length;let i=0,o=0;for(;i<n&&i<r&&t[i]===e[i];)i++;for(;o+i<n&&o+i<r&&t[n-o-1]===e[r-o-1];)o++;return[i,n-i-o,e.slice(i,r-o)]}(t,s);0!==n&&r.deleteData(e,n),r.insertData(e,i)}else r.nodeValue=s}}function dr(t,e,n,r,i,o){fr(i,t,e);const s=o.theme.text;void 0!==s&&ur(0,0,r,t,s)}function hr(t,e){const n=document.createElement(e);return n.appendChild(t),n}class gr extends Rn{__text;__format;__style;__mode;__detail;static getType(){return"text"}static clone(t){return new gr(t.__text,t.__key)}afterCloneFrom(t){super.afterCloneFrom(t),this.__text=t.__text,this.__format=t.__format,this.__style=t.__style,this.__mode=t.__mode,this.__detail=t.__detail}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 J[t.__mode]}getStyle(){return this.getLatest().__style}isToken(){return 1===this.getLatest().__mode}isComposing(){return this.__key===Vo()}isSegmented(){return 2===this.getLatest().__mode}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(t){const e=z[t];return 0!==(this.getFormat()&e)}isSimpleText(){return"text"===this.__type&&0===this.__mode}getTextContent(){return this.getLatest().__text}getFormatFlags(t,e){return Bo(this.getLatest().__format,t,e)}canHaveFormat(){return!0}isInline(){return!0}createDOM(t,e){const n=this.__format,r=cr(0,n),i=ar(0,n),o=null===r?i:r,s=document.createElement(o);let l=s;this.hasFormat("code")&&s.setAttribute("spellcheck","false"),null!==r&&(l=document.createElement(i),s.appendChild(l));dr(l,this,0,n,this.__text,t);const c=this.__style;return""!==c&&nr(s.style,c),s}updateDOM(e,n,r){const i=this.__text,o=e.__format,s=this.__format,l=cr(0,o),c=cr(0,s),a=ar(0,o),u=ar(0,s);if((null===l?a:l)!==(null===c?u:c))return!0;if(l===c&&a!==u){const e=n.firstChild;null==e&&t(48);const o=document.createElement(u);return dr(o,this,0,s,i,r),n.replaceChild(o,e),!1}let f=n;null!==c&&null!==l&&(f=n.firstChild,null==f&&t(49)),fr(i,f,this);const d=r.theme.text;void 0!==d&&o!==s&&ur(0,o,s,f,d);const h=e.__style,g=this.__style;return h!==g&&nr(n.style,g,h),!1}static importDOM(){return{"#text":()=>({conversion:xr,priority:0}),b:()=>({conversion:pr,priority:0}),code:()=>({conversion:vr,priority:0}),em:()=>({conversion:vr,priority:0}),i:()=>({conversion:vr,priority:0}),mark:()=>({conversion:vr,priority:0}),s:()=>({conversion:vr,priority:0}),span:()=>({conversion:_r,priority:0}),strong:()=>({conversion:vr,priority:0}),sub:()=>({conversion:vr,priority:0}),sup:()=>({conversion:vr,priority:0}),u:()=>({conversion:vr,priority:0})}}static importJSON(t){return kr().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setTextContent(t.text).setFormat(t.format).setDetail(t.detail).setMode(t.mode).setStyle(t.style)}exportDOM(e){let{element:n}=super.exportDOM(e);return Ys(n)||t(132),n.style.whiteSpace="pre-wrap",this.hasFormat("lowercase")?n.style.textTransform="lowercase":this.hasFormat("uppercase")?n.style.textTransform="uppercase":this.hasFormat("capitalize")&&(n.style.textTransform="capitalize"),this.hasFormat("bold")&&(n=hr(n,"b")),this.hasFormat("italic")&&(n=hr(n,"i")),this.hasFormat("strikethrough")&&(n=hr(n,"s")),this.hasFormat("underline")&&(n=hr(n,"u")),{element:n}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),...super.exportJSON()}}selectionTransform(t,e){}setFormat(t){const e=this.getWritable();return e.__format="string"==typeof t?z[t]:t,e}setDetail(t){const e=this.getWritable();return e.__detail="string"==typeof t?R[t]:t,e}setStyle(t){const e=this.getWritable();return e.__style=t,e}toggleFormat(t){const e=Bo(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=$[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){xi();let n=t,r=e;const i=Qr(),o=this.getTextContent(),s=this.__key;if("string"==typeof o){const t=o.length;void 0===n&&(n=t),void 0===r&&(r=t)}else n=0,r=0;if(!Fr(i))return Yr(s,n,s,r,"text","text");{const t=Vo();t!==i.anchor.key&&t!==i.focus.key||Uo(s),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(),o=i.__text,s=n.length;let l=t;l<0&&(l=s+l,l<0&&(l=0));const c=Qr();if(r&&Fr(c)){const e=t+s;c.setTextNodeRange(i,e,i,e)}const a=o.slice(0,l)+n+o.slice(l+e);return i.__text=a,i}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...t){xi();const e=this.getLatest(),n=e.getTextContent();if(""===n)return[];const r=e.__key,i=Vo(),o=n.length;t.sort((t,e)=>t-e),t.push(o);const s=[],l=t.length;for(let e=0,r=0;e<o&&r<=l;r++){const i=t[r];i>e&&(s.push(n.slice(e,i)),e=i)}const c=s.length;if(1===c)return[e];const a=s[0],u=e.getParent();let f;const d=e.getFormat(),h=e.getStyle(),g=e.__detail;let _=!1,p=null,y=null;const m=Qr();if(Fr(m)){const[t,e]=m.isBackward()?[m.focus,m.anchor]:[m.anchor,m.focus];"text"===t.type&&t.key===r&&(p=t),"text"===e.type&&e.key===r&&(y=e)}e.isSegmented()?(f=kr(a),f.__format=d,f.__style=h,f.__detail=g,f.__state=yt(e,f),_=!0):f=e.setTextContent(a);const x=[f];for(let t=1;t<c;t++){const n=kr(s[t]);n.__format=d,n.__style=h,n.__detail=g,n.__state=yt(e,n);const o=n.__key;i===r&&Uo(o),x.push(n)}const C=p?p.offset:null,S=y?y.offset:null;let v=0;for(const t of x){if(!p&&!y)break;const e=v+t.getTextContentSize();if(null!==p&&null!==C&&C<=e&&C>=v&&(p.set(t.getKey(),C-v,"text"),C<e&&(p=null)),null!==y&&null!==S&&S<=e&&S>=v){y.set(t.getKey(),S-v,"text");break}v=e}if(null!==u){!function(t){const e=t.getPreviousSibling(),n=t.getNextSibling();null!==e&&jo(e);null!==n&&jo(n)}(this);const t=u.getWritable(),e=this.getIndexWithinParent();_?(t.splice(e,0,x),this.remove()):t.splice(e,1,x),Fr(m)&&ti(m,u,e,c-1)}return x}mergeWithSibling(e){const n=e===this.getPreviousSibling();n||e===this.getNextSibling()||t(50);const r=this.__key,i=e.__key,o=this.__text,s=o.length;Vo()===i&&Uo(r);const l=Qr();if(Fr(l)){const t=l.anchor,o=l.focus;null!==t&&t.key===i&&ri(t,n,r,e,s),null!==o&&o.key===i&&ri(o,n,r,e,s)}const c=e.__text,a=n?c+o:o+c;this.setTextContent(a);const u=this.getWritable();return e.remove(),u}isTextEntity(){return!1}}function _r(t){return{forChild:Nr(t.style),node:null}}function pr(t){const e=t,n="normal"===e.style.fontWeight;return{forChild:Nr(e.style,n?void 0:"bold"),node:null}}const yr=new WeakMap;function mr(t){if(!Ys(t))return!1;if("PRE"===t.nodeName)return!0;const e=t.style.whiteSpace;return"string"==typeof e&&e.startsWith("pre")}function xr(e){const n=e;null===e.parentElement&&t(129);let r=n.textContent||"";if(null!==function(t){let e,n=t.parentNode;const r=[t];for(;null!==n&&void 0===(e=yr.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++)yr.set(r[t],i);return i}(n)){const t=r.split(/(\r?\n|\t)/),e=[],n=t.length;for(let r=0;r<n;r++){const n=t[r];"\n"===n||"\r\n"===n?e.push(or()):"\t"===n?e.push(wr()):""!==n&&e.push(kr(n))}return{node:e}}if(r=r.replace(/\r/g,"").replace(/[ \t\n]+/g," "),""===r)return{node:null};if(" "===r[0]){let t=n,e=!0;for(;null!==t&&null!==(t=Cr(t,!1));){const n=t.textContent||"";if(n.length>0){/[ \t\n]$/.test(n)&&(r=r.slice(1)),e=!1;break}}e&&(r=r.slice(1))}if(" "===r[r.length-1]){let t=n,e=!0;for(;null!==t&&null!==(t=Cr(t,!0));){if((t.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){e=!1;break}}e&&(r=r.slice(0,r.length-1))}return""===r?{node:null}:{node:kr(r)}}function Cr(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,Ys(n)){const t=n.style.display;if(""===t&&!Gs(n)||""!==t&&!t.startsWith("inline"))return null}let r=n;for(;null!==(r=e?n.firstChild:n.lastChild);)n=r;if(Ko(n))return n;if("BR"===n.nodeName)return null}}const Sr={code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function vr(t){const e=Sr[t.nodeName.toLowerCase()];return void 0===e?{node:null}:{forChild:Nr(t.style,e),node:null}}function kr(t=""){return zs(new gr(t))}function Tr(t){return t instanceof gr}function Nr(t,e){const n=t.fontWeight,r=t.textDecoration.split(" "),i="700"===n||"bold"===n,o=r.includes("line-through"),s="italic"===t.fontStyle,l=r.includes("underline"),c=t.verticalAlign;return t=>Tr(t)?(i&&!t.hasFormat("bold")&&t.toggleFormat("bold"),o&&!t.hasFormat("strikethrough")&&t.toggleFormat("strikethrough"),s&&!t.hasFormat("italic")&&t.toggleFormat("italic"),l&&!t.hasFormat("underline")&&t.toggleFormat("underline"),"sub"!==c||t.hasFormat("subscript")||t.toggleFormat("subscript"),"super"!==c||t.hasFormat("superscript")||t.toggleFormat("superscript"),e&&!t.hasFormat(e)&&t.toggleFormat(e),t):t}class br extends gr{static getType(){return"tab"}static clone(t){return new br(t.__key)}constructor(t){super("\t",t),this.__detail=2}static importDOM(){return null}createDOM(t){const e=super.createDOM(t),n=ms(t.theme,"tab");if(void 0!==n){e.classList.add(...n)}return e}static importJSON(t){return wr().updateFromJSON(t)}setTextContent(t){return"\t"!==t&&""!==t&&e(126),super.setTextContent("\t")}spliceText(e,n,r,i){return""===r&&0===n||"\t"===r&&1===n||t(286),this}setDetail(e){return 2!==e&&t(127),this}setMode(e){return"normal"!==e&&t(128),this}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function wr(){return zs(new br)}function Er(t){return t instanceof br}class Or{key;offset;type;_selection;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){if(this.key===t.key)return this.offset<t.offset;return Jl(rc(ql(this,"next")),rc(ql(t,"next")))<0}getNode(){const e=Yo(this.key);return null===e&&t(20),e}set(t,e,n,r){const i=this._selection,o=this.key;r&&this.key===t&&this.offset===e&&this.type===n||(this.key=t,this.offset=e,this.type=n,mi()||(Vo()===o&&Uo(t),null!==i&&(i.setCachedNodes(null),i.dirty=!0)))}}function Mr(t,e,n){return new Or(t,e,n)}function Ar(t,e){let n=e.__key,r=t.offset,i="element";if(Tr(e)){i="text";const t=e.getTextContentSize();r>t&&(r=t)}else if(!Wi(e)){const t=e.getNextSibling();if(Tr(t))n=t.__key,r=0,i="text";else{c