UNPKG

lexical

Version:

Lexical is an extensible text editor framework that provides excellent reliability, accessible and performance.

9 lines (8 loc) • 134 kB
/** * 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",P="\n\n",D=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"},J={normal:0,segmented:2,token:1},j={[h]:"normal",[_]:"segmented",[g]:"token"},U="$",$="$config";function V(t,e,n,r,i,o){let s=t.getFirstChild();for(;null!==s;){const t=s.__key;s.__parent===e&&(Di(s)&&V(s,t,n,r,i,o),n.has(t)||o.delete(t),i.push(t)),s=s.getNextSibling()}}let Y=!1,q=0;function H(t){q=t.timeStamp}function G(t,e,n){const r="BR"===t.nodeName,i=e.__lexicalLineBreak;return i&&(t===i||r&&t.previousSibling===i)||r&&void 0!==Lo(t,n)}function X(t,e,n){const r=Os(xs(n));let i=null,o=null;null!==r&&r.anchorNode===t&&(i=r.anchorOffset,o=r.focusOffset);const s=t.nodeValue;null!==s&&qo(e,s,i,o,!1)}function Q(t,e,n){if(wr(t)){const e=t.anchor.getNode();if(e.is(n)&&t.format!==e.getFormat())return!1}return ko(e)&&n.isAttached()}function Z(t,e,n,r){for(let i=t;i&&!Ys(i);i=ds(i)){const t=Lo(i,e);if(void 0!==t){const e=Do(t,n);if(e)return Ii(e)||!Ds(i)?void 0:[i,e]}else if(i===r)return[r,Bo(n)]}}function tt(t,e,n){Y=!0;const r=performance.now()-q>100;try{Oi(t,()=>{const i=$r()||function(t){return t.getEditorState().read(()=>{const t=$r();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,_=Z(g,t,c,l);if(!_)continue;const[p,y]=_;if("characterData"===h)r&&yr(y)&&ko(g)&&Q(i,g,y)&&X(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=Fo(r),s=r.parentNode;if(null!=s&&r!==a&&null===i&&!G(r,s,t)){if(o){const t=(Ds(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];(G(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||G(n,i,t)||o.removeChild(n)}}n.takeRecords()}null!==i&&(u&&Wo(i),o&&as(t)&&i.insertRawText(f))})}finally{Y=!1}}function et(t){const e=t._observer;if(null!==e){tt(t,e.takeRecords(),e)}}function nt(t){!function(t){0===q&&xs(t).addEventListener("textInput",H,!0)}(t),t._observer=new MutationObserver((e,n)=>{tt(t,e,n)})}class rt{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;constructor(t,e){this.key=t,this.parse=e.parse.bind(e),this.unparse=(e.unparse||ht).bind(e),this.isEqual=(e.isEqual||Object.is).bind(e),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=e.resetOnCopyNode||!1}}function it(t,e){return new rt(t,e)}function ot(t,e,n="latest"){const r=("latest"===n?t.getLatest():t).__state;return r?r.getValue(e):e.defaultValue}function st(t,e,n){const r=ot(t,n,"direct"),i=ot(e,n,"direct");return n.isEqual(r,i)?null:[r,i]}function lt(t,e,n){let r;if(di(),"function"==typeof n){const i=t.getLatest(),o=ot(i,e);if(r=n(o),e.isEqual(o,r))return i}else r=n;const i=t.getWritable();return ut(i).updateFromKnown(e,r),i}function ct(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}=Hs(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 at{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 dt(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 at(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=dt(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 ut(t){const e=t.getWritable(),n=e.__state?e.__state.getWritable(e):new at(e,ft(e));return e.__state=n,n}function ft(t){return t.__state?t.__state.sharedNodeState:uo(Rs(),t.getType()).sharedNodeState}function dt(t){if(t)for(const e in t)return t}function ht(t){return t}function gt(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 _t(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 pt(t,e){const n=t.__state;return n&&n.node===t?n.getWritable(e):n}function yt(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&&gt(n,t,e)||e&&gt(n,e,t)||t&&_t(n,t,e)||e&&_t(n,e,t))}(c,a))}function mt(t,e){const n=t.mergeWithSibling(e),r=_i()._normalizedNodes;return r.add(t.__key),r.add(e.__key),n}function xt(t){let e,n,r=t;if(""!==r.__text||!r.isSimpleText()||r.isUnmergeable()){for(;null!==(e=r.getPreviousSibling())&&yr(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(""!==e.__text){if(yt(e,r)){r=mt(e,r);break}break}e.remove()}for(;null!==(n=r.getNextSibling())&&yr(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(""!==n.__text){if(yt(r,n)){r=mt(r,n);break}break}n.remove()}}else r.remove()}function Ct(t){return St(t.anchor),St(t.focus),t}function St(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),yr(r)){t.set(r.__key,i?r.getTextContentSize():0,"text",!0);break}if(!Di(r))break;t.set(r.__key,i?r.getChildrenSize():0,"element",!0)}}let vt,kt,Tt,Nt,bt,wt,Et,Ot,Mt,At,Pt="",Dt=null,Ft=null,Lt=!1,It=!1;function Kt(t,e){const n=Et.get(t);if(null!==e){const n=ee(t);n.parentNode===e&&e.removeChild(n)}if(Ot.has(t)||kt._keyToDOMMap.delete(t),Di(n)){const t=Ht(n,Et);zt(t,0,t.length-1,null)}void 0!==n&&os(At,Tt,Nt,n,"destroyed")}function zt(t,e,n,r){for(let i=e;i<=n;++i){const e=t[i];void 0!==e&&Kt(e,r)}}function Rt(t,e){t.setProperty("text-align",e)}const Bt="40px";function Wt(t,e){const n=vt.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(kt._rootElement||t).getPropertyValue("--lexical-indent-base-value")||Bt;t.style.setProperty("padding-inline-start",`calc(${e} * ${r})`)}function Jt(t,e){const n=t.style;0===e?Rt(n,""):1===e?Rt(n,"left"):2===e?Rt(n,"center"):3===e?Rt(n,"right"):4===e?Rt(n,"justify"):5===e?Rt(n,"start"):6===e&&Rt(n,"end")}function jt(t,e){const n=function(t){const e=t.__dir;if(null!==e)return e;if(zi(t))return null;const n=t.getParentOrThrow();return zi(n)&&null===n.__dir?"auto":null}(e);null!==n?t.dir=n:t.removeAttribute("dir")}function Ut(e,n){const r=Ot.get(e);void 0===r&&t(60);const i=r.createDOM(vt,kt);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,kt),yr(r)?i.setAttribute("data-lexical-text","true"):Ii(r)&&i.setAttribute("data-lexical-decorator","true"),Di(r)){const t=r.__indent,e=r.__size;if(jt(i,r),0!==t&&Wt(i,t),0!==e){const t=e-1;$t(Ht(r,Ot),r,0,t,r.getDOMSlot(i))}const n=r.__format;0!==n&&Jt(i,n),r.isInline()||Yt(null,r,i)}else{const t=r.getTextContent();if(Ii(r)){const t=r.decorate(kt,vt);null!==t&&Xt(e,t),i.contentEditable="false"}Pt+=t}return null!==n&&n.insertChild(i),os(At,Tt,Nt,r,"created"),i}function $t(t,e,n,r,i){const o=Pt;Pt="";let s=n;for(;s<=r;++s){Ut(t[s],i);const e=Ot.get(t[s]);null!==e&&yr(e)?null===Dt&&(Dt=e.getFormat(),Ft=e.getStyle()):Di(e)&&s<r&&!e.isInline()&&(Pt+=P)}i.element.__lexicalTextContent=Pt,Pt=o+Pt}function Vt(t,e){if(t){const n=t.__last;if(n){const t=e.get(n);if(t)return Zn(t)?"line-break":Ii(t)&&t.isInline()?"decorator":null}return"empty"}return null}function Yt(t,e,n){const r=Vt(t,Et),i=Vt(e,Ot);r!==i&&e.getDOMSlot(n).setManagedLineBreak(i)}function qt(e,n,r){var i;Dt=null,Ft=null,function(e,n,r){const i=Pt,o=e.__size,s=n.__size;Pt="";const l=r.element;if(1===o&&1===s){const t=e.__first,r=n.__first;if(t===r)Gt(t,l);else{const e=ee(t),n=Ut(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}Kt(t,null)}const i=Ot.get(r);yr(i)&&null===Dt&&(Dt=i.getFormat(),Ft=i.getStyle())}else{const i=Ht(e,Et),c=Ht(n,Ot);if(i.length!==o&&t(227),c.length!==s&&t(228),0===o)0!==s&&$t(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;zt(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=Qt(Gt(r,o.element)),f++,d++;else{if(void 0===a&&(a=Zt(n,d)),void 0===c)c=Zt(e,f);else if(!c.has(t)){f++;continue}if(!a.has(t)){u=Qt(ee(t)),Kt(t,o.element),f++,c.delete(t);continue}if(c.has(r)){const t=fs(kt,r);t!==u&&o.withBefore(u).insertChild(t),u=Qt(Gt(r,o.element)),f++,d++}else Ut(r,o.withBefore(u)),d++}const i=Ot.get(r);null!==i&&yr(i)?null===Dt&&(Dt=i.getFormat(),Ft=i.getStyle()):Di(i)&&d<=l&&!i.isInline()&&(Pt+=P)}const h=f>s,g=d>l;if(h&&!g){const t=n[l+1],e=void 0===t?null:kt.getElementByKey(t);$t(n,0,d,l,o.withBefore(e))}else g&&!h&&zt(e,f,s,o.element)}(0,i,c,o,s,r)}l.__lexicalTextContent=Pt,Pt=i+Pt}(e,n,n.getDOMSlot(r)),i=n,null==Dt||Dt===i.__textFormat||It||i.setTextFormat(Dt),function(t){null==Ft||Ft===t.__textStyle||It||t.setTextStyle(Ft)}(n)}function Ht(e,n){const r=[];let i=e.__first;for(;null!==i;){const e=n.get(i);void 0===e&&t(101),r.push(i),i=e.__next}return r}function Gt(e,n){const r=Et.get(e);let i=Ot.get(e);void 0!==r&&void 0!==i||t(61);const o=Lt||wt.has(e)||bt.has(e),s=fs(kt,e);if(r===i&&!o){let t;if(Di(r)){const e=s.__lexicalTextContent;"string"==typeof e?t=e:(t=r.getTextContent(),s.__lexicalTextContent=t)}else t=r.getTextContent();return Pt+=t,s}if(r!==i&&o&&os(At,Tt,Nt,i,"updated"),i.updateDOM(r,s,vt)){const r=Ut(e,null);return null===n&&t(62),n.replaceChild(r,s),Kt(e,null),r}if(Di(r)){Di(i)||t(334,e);const n=i.__indent;(Lt||n!==r.__indent)&&Wt(s,n);const l=i.__format;if((Lt||l!==r.__format)&&Jt(s,l),o)qt(r,i,s),zi(i)||i.isInline()||Yt(r,i,s);else{const t=s.__lexicalTextContent;let e;"string"==typeof t?e=t:(e=r.getTextContent(),s.__lexicalTextContent=e),Pt+=e}if((Lt||i.__dir!==r.__dir)&&(jt(s,i),zi(i)&&!Lt))for(const t of i.getChildren())if(Di(t)){jt(fs(kt,t.getKey()),t)}}else{const t=i.getTextContent();if(Ii(i)){const t=i.decorate(kt,vt);null!==t&&Xt(e,t)}Pt+=t}if(!It&&zi(i)&&i.__cachedText!==Pt){const t=i.getWritable();t.__cachedText=Pt,i=t}return s}function Xt(t,e){let n=kt._pendingDecorators;const r=kt._decorators;if(null===n){if(r[t]===e)return;n=Ko(kt)}n[t]=e}function Qt(t){let e=t.nextSibling;return null!==e&&e===kt._blockCursorElement&&(e=e.nextSibling),e}function Zt(t,e){const n=new Set;for(let r=e;r<t.length;r++)n.add(t[r]);return n}function te(t,e,n,r,i,o){Pt="",Lt=2===r,kt=n,vt=n._config,Tt=n._nodes,Nt=kt._listeners.mutation,bt=i,wt=o,Et=t._nodeMap,Ot=e._nodeMap,It=e._readOnly,Mt=new Map(n._keyToDOMMap);const s=new Map;return At=s,Gt("root",null),kt=void 0,Tt=void 0,bt=void 0,wt=void 0,Et=void 0,Ot=void 0,vt=void 0,Mt=void 0,At=void 0,s}function ee(e){const n=Mt.get(e);return void 0===n&&t(75,e),n}function ne(t){return{type:t}}const re=ne("SELECTION_CHANGE_COMMAND"),ie=ne("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),oe=ne("CLICK_COMMAND"),se=ne("BEFORE_INPUT_COMMAND"),le=ne("INPUT_COMMAND"),ce=ne("COMPOSITION_START_COMMAND"),ae=ne("COMPOSITION_END_COMMAND"),ue=ne("DELETE_CHARACTER_COMMAND"),fe=ne("INSERT_LINE_BREAK_COMMAND"),de=ne("INSERT_PARAGRAPH_COMMAND"),he=ne("CONTROLLED_TEXT_INSERTION_COMMAND"),ge=ne("PASTE_COMMAND"),_e=ne("REMOVE_TEXT_COMMAND"),pe=ne("DELETE_WORD_COMMAND"),ye=ne("DELETE_LINE_COMMAND"),me=ne("FORMAT_TEXT_COMMAND"),xe=ne("UNDO_COMMAND"),Ce=ne("REDO_COMMAND"),Se=ne("KEYDOWN_COMMAND"),ve=ne("KEY_ARROW_RIGHT_COMMAND"),ke=ne("MOVE_TO_END"),Te=ne("KEY_ARROW_LEFT_COMMAND"),Ne=ne("MOVE_TO_START"),be=ne("KEY_ARROW_UP_COMMAND"),we=ne("KEY_ARROW_DOWN_COMMAND"),Ee=ne("KEY_ENTER_COMMAND"),Oe=ne("KEY_SPACE_COMMAND"),Me=ne("KEY_BACKSPACE_COMMAND"),Ae=ne("KEY_ESCAPE_COMMAND"),Pe=ne("KEY_DELETE_COMMAND"),De=ne("KEY_TAB_COMMAND"),Fe=ne("INSERT_TAB_COMMAND"),Le=ne("INDENT_CONTENT_COMMAND"),Ie=ne("OUTDENT_CONTENT_COMMAND"),Ke=ne("DROP_COMMAND"),ze=ne("FORMAT_ELEMENT_COMMAND"),Re=ne("DRAGSTART_COMMAND"),Be=ne("DRAGOVER_COMMAND"),We=ne("DRAGEND_COMMAND"),Je=ne("COPY_COMMAND"),je=ne("CUT_COMMAND"),Ue=ne("SELECT_ALL_COMMAND"),$e=ne("CLEAR_EDITOR_COMMAND"),Ve=ne("CLEAR_HISTORY_COMMAND"),Ye=ne("CAN_REDO_COMMAND"),qe=ne("CAN_UNDO_COMMAND"),He=ne("FOCUS_COMMAND"),Ge=ne("BLUR_COMMAND"),Xe=ne("KEY_MODIFIER_COMMAND"),Qe=Object.freeze({}),Ze=[["keydown",function(t,e){if(tn=t.timeStamp,en=t.key,e.isComposing())return;us(e,Se,t)}],["pointerdown",function(t,e){const n=t.target,r=t.pointerType;Fs(n)&&"touch"!==r&&"pen"!==r&&0===t.button&&Oi(e,()=>{go(n)||(cn=!0)})}],["compositionstart",function(t,e){us(e,ce,t)}],["compositionend",function(t,e){o?un=!0:l||!a&&!d?us(e,ae,t):(fn=!0,dn=t.data)}],["input",function(t,e){t.stopPropagation(),Oi(e,()=>{e.dispatchCommand(le,t)},{event:t}),rn=null}],["click",function(t,e){Oi(e,()=>{const n=$r(),r=Os(xs(e)),i=Vr();if(r)if(wr(n)){const e=n.anchor,o=e.getNode();if("element"===e.type&&0===e.offset&&n.isCollapsed()&&!zi(o)&&1===Ro().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=Xs(o,t=>Di(t)&&!t.isInline());Di(t)&&t.select(0)}}}else if("touch"===t.pointerType||"pen"===t.pointerType){const n=r.anchorNode;if(Ds(n)||ko(n)){Wo(Ur(i,r,e,t))}}us(e,oe,t)})}],["cut",Qe],["copy",Qe],["dragstart",Qe],["dragover",Qe],["dragend",Qe],["paste",Qe],["focus",Qe],["blur",Qe],["drop",Qe]];s&&Ze.push(["beforeinput",(t,e)=>function(t,e){const n=t.inputType;if("deleteCompositionText"===n||o&&as(e))return;if("insertCompositionText"===n)return;us(e,se,t)}(t,e)]);let tn=0,en=null,nn=0,rn=null;const on=new WeakMap,sn=new WeakMap;let ln=!1,cn=!1,an=!1,un=!1,fn=!1,dn="",hn=null,gn=[0,"",0,"root",0];function _n(t,e,n,r,i){const o=t.anchor,l=t.focus,c=o.getNode(),a=_i(),u=Os(xs(a)),f=null!==u?u.anchorNode:null,d=o.key,h=a.getElementByKey(d),g=n.length;return d!==l.key||!yr(c)||(!i&&(!s||nn<r+50)||c.isDirty()&&g<2||jo(n))&&o.offset!==l.offset&&!c.isComposing()||vo(c)||c.isDirty()&&g>1||(i||!s)&&null!==h&&!c.isComposing()&&f!==No(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=So(e);return 0===n?!e.canInsertTextBefore()||!r.canInsertTextBefore()&&!e.isComposing()||i||function(t){const e=t.getPreviousSibling();return(yr(e)||Di(e)&&e.isInline())&&!e.canInsertTextAfter()}(e):n===e.getTextContentSize()&&(!e.canInsertTextAfter()||!r.canInsertTextAfter()&&!e.isComposing()||i)}(t,c)}function pn(t,e){return ko(t)&&null!==t.nodeValue&&0!==e&&e!==t.nodeValue.length}function yn(e,n,r){const{anchorNode:i,anchorOffset:o,focusNode:s,focusOffset:l}=e;ln&&(ln=!1,pn(i,o)&&pn(s,l)&&!hn)||Oi(n,()=>{if(!r)return void Wo(null);if(!po(n,i,s))return;let c=$r();if(hn&&wr(c)&&c.isCollapsed()){const t=c.anchor,e=hn.anchor;(t.key===e.key&&t.offset===e.offset+1||1===t.offset&&e.getNode().is(t.getNode().getPreviousSibling()))&&(c=hn.clone(),Wo(c))}if(hn=null,wr(c)){const r=c.anchor,i=r.getNode();if(c.isCollapsed()){"Range"===e.type&&e.anchorNode===e.focusNode&&(c.dirty=!0);const o=xs(n).event,s=o?o.timeStamp:performance.now(),[l,a,u,f,d]=gn,h=Ro(),g=!1===n.isComposing()&&""===h.getTextContent();if(s<d+200&&r.offset===u&&r.key===f)mn(c,l,a);else if("text"===r.type)yr(i)||t(141),xn(c,i);else if("element"===r.type&&!g){Di(i)||t(259);const e=r.getNode();e.isEmpty()?function(t,e){const n=e.getTextFormat(),r=e.getTextStyle();mn(t,n,r)}(c,e):mn(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(yr(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}}us(n,re,void 0)})}function mn(t,e,n){t.format===e&&t.style===n||(t.format=e,t.style=n,t.dirty=!0)}function xn(t,e){mn(t,e.getFormat(),e.getStyle())}function Cn(t){if(!t.getTargetRanges)return null;const e=t.getTargetRanges();return 0===e.length?null:e[0]}function Sn(e){const n=e.inputType,r=Cn(e),i=_i(),o=$r();if("deleteContentBackward"===n){if(null===o){const t=Vr();if(!wr(t))return!0;Wo(t.clone())}if(wr(o)){const n=o.anchor.key===o.focus.key;if(s=e.timeStamp,"MediaLast"===en&&s<tn+30&&i.isComposing()&&n){if(Ao(null),tn=0,setTimeout(()=>{Oi(i,()=>{Ao(null)})},30),wr(o)){const e=o.anchor.getNode();e.markDirty(),yr(e)||t(142),xn(o,e)}}else{Ao(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=!Ii(cs(o.anchor,!0))),!c){us(i,ue,!0);const t=$r();f&&wr(t)&&t.isCollapsed()&&(hn=t,setTimeout(()=>hn=null))}}return!0}}var s;if(!wr(o))return!0;const c=e.data;null!==rn&&Yo(!1,i,rn),o.dirty&&null===rn||!o.isCollapsed()||zi(o.anchor.getNode())||null===r||o.applyDOMRange(r),rn=null;const a=o.anchor,u=o.focus,d=a.getNode(),h=u.getNode();if("insertText"===n||"insertTranspose"===n){if("\n"===c)e.preventDefault(),us(i,fe,!1);else if(c===P)e.preventDefault(),us(i,de,void 0);else if(null==c&&e.dataTransfer){const t=e.dataTransfer.getData("text/plain");e.preventDefault(),o.insertRawText(t)}else null!=c&&_n(o,r,c,e.timeStamp,!0)?(e.preventDefault(),us(i,he,c)):rn=c;return nn=e.timeStamp,!0}switch(e.preventDefault(),n){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":us(i,he,e);break;case"insertFromComposition":Ao(null),us(i,he,e);break;case"insertLineBreak":Ao(null),us(i,fe,!1);break;case"insertParagraph":Ao(null),an&&!l?(an=!1,us(i,fe,!1)):us(i,de,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":us(i,ge,e);break;case"deleteByComposition":(function(t,e){return t!==e||Di(t)||Di(e)||!So(t)||!So(e)})(d,h)&&us(i,_e,e);break;case"deleteByDrag":case"deleteByCut":us(i,_e,e);break;case"deleteContent":us(i,ue,!1);break;case"deleteWordBackward":us(i,pe,!0);break;case"deleteWordForward":us(i,pe,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":us(i,ye,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":us(i,ye,!1);break;case"formatStrikeThrough":us(i,me,"strikethrough");break;case"formatBold":us(i,me,"bold");break;case"formatItalic":us(i,me,"italic");break;case"formatUnderline":us(i,me,"underline");break;case"historyUndo":us(i,xe,void 0);break;case"historyRedo":us(i,Ce,void 0)}return!0}function vn(t){if(Ds(t.target)&&go(t.target))return!0;const e=_i(),n=$r(),r=t.data,i=Cn(t);if(null!=r&&wr(n)&&_n(n,i,r,t.timeStamp,!1)){un&&(Nn(e,r),un=!1);const i=n.anchor.getNode(),l=Os(xs(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()&&yr(i)&&null!==l.anchorNode&&i.getTextContent().slice(0,a)+r+i.getTextContent().slice(a+u)===Vo(l.anchorNode)||us(e,he,r);const d=r.length;o&&d>1&&"insertCompositionText"===t.inputType&&!e.isComposing()&&(n.anchor.offset-=d),f&&e.isComposing()&&(tn=0,Ao(null))}else{Yo(!1,e,null!==r?r:void 0),un&&(Nn(e,r||void 0),un=!1)}return function(){di();const t=_i();et(t)}(),!0}function kn(t){const e=_i(),n=$r();if(wr(n)&&!e.isComposing()){const r=n.anchor,i=n.anchor.getNode();Ao(r.key),_s(qn),(t.timeStamp<tn+30||"element"===r.type||!n.isCollapsed()||i.getFormat()!==n.format||yr(i)&&i.getStyle()!==n.style)&&us(e,he,D)}return!0}function Tn(t){return Nn(_i(),t.data),_s(Hn),!0}function Nn(t,e){const n=t._compositionKey;if(Ao(null),null!==n&&null!=e){if(""===e){const e=Do(n),r=No(t.getElementByKey(n));if(null!==r&&null!==r.nodeValue&&yr(e)){const n=Os(xs(t));let i=null,o=null;null!==n&&n.anchorNode===r&&(i=n.anchorOffset,o=n.focusOffset),qo(e,r.nodeValue,i,o,!0)}return}if("\n"===e[e.length-1]){const e=$r();if(wr(e)||Or(e)){if(wr(e)){const t=e.focus;e.anchor.set(t.key,t.offset,t.type)}return void us(t,Ee,null)}}}Yo(!0,t,e)}function bn(t){const e=_i();if(null==t.key)return!0;if(fn){if(es(t))return Oi(e,()=>{Nn(e,dn)}),fn=!1,dn="",!0;fn=!1,dn=""}if(function(t){return Qo(t,"ArrowRight",{shiftKey:"any"})}(t))us(e,ve,t);else if(function(t){return Qo(t,"ArrowRight",Zo)}(t))us(e,ke,t);else if(function(t){return Qo(t,"ArrowLeft",{shiftKey:"any"})}(t))us(e,Te,t);else if(function(t){return Qo(t,"ArrowLeft",Zo)}(t))us(e,Ne,t);else if(function(t){return Qo(t,"ArrowUp",{altKey:"any",shiftKey:"any"})}(t))us(e,be,t);else if(function(t){return Qo(t,"ArrowDown",{altKey:"any",shiftKey:"any"})}(t))us(e,we,t);else if(function(t){return Qo(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any",shiftKey:!0})}(t))an=!0,us(e,Ee,t);else if(function(t){return" "===t.key}(t))us(e,Oe,t);else if(function(t){return i&&Qo(t,"o",{ctrlKey:!0})}(t))t.preventDefault(),an=!0,us(e,fe,!0);else if(function(t){return Qo(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any"})}(t))an=!1,us(e,Ee,t);else if(function(t){return Qo(t,"Backspace",{shiftKey:"any"})||i&&Qo(t,"h",{ctrlKey:!0})}(t))es(t)?us(e,Me,t):(t.preventDefault(),us(e,ue,!0));else if(function(t){return"Escape"===t.key}(t))us(e,Ae,t);else if(function(t){return Qo(t,"Delete",{})||i&&Qo(t,"d",{ctrlKey:!0})}(t))!function(t){return"Delete"===t.key}(t)?(t.preventDefault(),us(e,ue,!1)):us(e,Pe,t);else if(function(t){return Qo(t,"Backspace",ts)}(t))t.preventDefault(),us(e,pe,!0);else if(function(t){return Qo(t,"Delete",ts)}(t))t.preventDefault(),us(e,pe,!1);else if(function(t){return i&&Qo(t,"Backspace",{metaKey:!0})}(t))t.preventDefault(),us(e,ye,!0);else if(function(t){return i&&(Qo(t,"Delete",{metaKey:!0})||Qo(t,"k",{ctrlKey:!0}))}(t))t.preventDefault(),us(e,ye,!1);else if(function(t){return Qo(t,"b",Zo)}(t))t.preventDefault(),us(e,me,"bold");else if(function(t){return Qo(t,"u",Zo)}(t))t.preventDefault(),us(e,me,"underline");else if(function(t){return Qo(t,"i",Zo)}(t))t.preventDefault(),us(e,me,"italic");else if(function(t){return Qo(t,"Tab",{shiftKey:"any"})}(t))us(e,De,t);else if(function(t){return Qo(t,"z",Zo)}(t))t.preventDefault(),us(e,xe,void 0);else if(function(t){if(i)return Qo(t,"z",{metaKey:!0,shiftKey:!0});return Qo(t,"y",{ctrlKey:!0})||Qo(t,"z",{ctrlKey:!0,shiftKey:!0})}(t))t.preventDefault(),us(e,Ce,void 0);else{const n=e._editorState._selection;null===n||wr(n)?ns(t)&&(t.preventDefault(),us(e,Ue,t)):!function(t){return Qo(t,"c",Zo)}(t)?!function(t){return Qo(t,"x",Zo)}(t)?ns(t)&&(t.preventDefault(),us(e,Ue,t)):(t.preventDefault(),us(e,je,t)):(t.preventDefault(),us(e,Je,t))}return function(t){return t.ctrlKey||t.shiftKey||t.altKey||t.metaKey}(t)&&e.dispatchCommand(Xe,t),!0}function wn(t){let e=t.__lexicalEventHandles;return void 0===e&&(e=[],t.__lexicalEventHandles=e),e}const En=new Map;function On(t){const e=Ms(t.target);if(null===e)return;const n=mo(e.anchorNode);if(null===n)return;cn&&(cn=!1,Oi(n,()=>{const r=Vr(),i=e.anchorNode;if(Ds(i)||ko(i)){Wo(Ur(r,e,n,t))}}));const r=Uo(n),i=r[r.length-1],o=i._key,s=En.get(o),l=s||i;l!==n&&yn(e,l,!1),yn(e,n,!0),n!==i?En.set(o,n):s&&En.delete(o)}function Mn(t){t._lexicalHandled=!0}function An(t){return!0===t._lexicalHandled}const Pn=()=>{};function Dn(e){const n=on.get(e);if(void 0===n)return void Pn();const r=sn.get(n);if(void 0===r)return void Pn();const i=r-1;i>=0||t(164),on.delete(e),sn.set(n,i),0===i&&n.removeEventListener("selectionchange",On);const o=xo(e);yo(o)?(!function(t){if(null!==t._parentEditor){const e=Uo(t),n=e[e.length-1]._key;En.get(n)===t&&En.delete(n)}else En.delete(t._key)}(o),e.__lexicalEditor=null):o&&t(198);const s=wn(e);for(let t=0;t<s.length;t++)s[t]();e.__lexicalEventHandles=[]}function Fn(t,e,n){di();const r=t.__key,i=t.getParent();if(null===i)return;const o=function(t){const e=$r();if(!wr(e)||!Di(t))return e;const{anchor:n,focus:r}=e,i=n.getNode(),o=r.getNode();ys(i,t)&&n.set(t.__key,0,"element");ys(o,t)&&r.set(t.__key,0,"element");return e}(t);let s=!1;if(wr(o)&&e){const e=o.anchor,n=o.focus;e.key===r&&(Hr(e,t,i,t.getPreviousSibling(),t.getNextSibling()),s=!0),n.key===r&&(Hr(n,t,i,t.getPreviousSibling(),t.getNextSibling()),s=!0)}else Or(o)&&e&&t.isSelected()&&t.selectPrevious();if(wr(o)&&e&&!s){const e=t.getIndexWithinParent();Oo(t),Yr(o,i,e,-1)}else Oo(t);n||vs(i)||i.canBeEmpty()||!i.isEmpty()||Fn(i,e),e&&o&&zi(i)&&i.isEmpty()&&i.selectEnd()}function Ln(t){return t}const In=Symbol.for("ephemeral");function Kn(t){return t[In]||!1}class zn{__type;__key;__parent;__prev;__next;__state;static getType(){const{ownNodeType:e}=Hs(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}),Eo(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=Do(t);if(null===e)break;t=e.__parent}return!1}isSelected(t){const e=t||$r();if(null==e)return!1;const n=e.getNodes().some(t=>t.__key===this.__key);if(yr(this))return n;if(wr(e)&&"element"===e.anchor.type&&"element"===e.focus.type){if(e.isCollapsed())return!1;const t=this.getParent();if(Ii(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:Do(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(vs(n))return Di(e)||e===this&&Ii(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:Do(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:Do(t)}getNextSiblings(){const t=[];let e=this.getNextSibling();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getCommonAncestor(t){const e=Di(this)?this:this.getParent(),n=Di(t)?t:t.getParent(),r=e&&n?Al(e,n):null;return r?r.commonAncestor:null}is(t){return null!=t&&this.__key===t.__key}isBefore(e){const n=Al(this,e);return null!==n&&("descendant"===n.type||("branch"===n.type?-1===El(n):("same"!==n.type&&"ancestor"!==n.type&&t(279),!1)))}isParentOf(t){const e=Al(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=Di(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=_i()._dirtyLeaves;return null!==t&&t.has(this.__key)}getLatest(){if(Kn(this))return this;const e=Do(this.__key);return null===e&&t(113),e}getWritable(){if(Kn(this))return this;di();const t=gi(),e=_i(),n=t._nodeMap,r=this.__key,i=this.getLatest(),o=e._cloneNotNeeded,s=$r();if(null!==s&&s.setCachedNodes(null),o.has(r))return Mo(i),i;const l=js(i);return o.add(r),Mo(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 ft(n).flatKeys)t in e&&(void 0!==i&&i!==r||(i={...r}),i[t]=e[t]);return(n.__state||i)&&ut(t).updateFromJSON(i),n}(this,t)}static transform(){return null}remove(t){Fn(this,!0,t)}replace(e,n){di();let r=$r();null!==r&&(r=r.clone()),Ns(this,e);const i=this.getLatest(),o=this.__key,s=e.__key,l=e.getWritable(),c=this.getParentOrThrow().getWritable(),a=c.__size;Oo(l);const u=i.getPreviousSibling(),f=i.getNextSibling(),d=i.__prev,h=i.__next,g=i.__parent;if(Fn(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&&(Di(this)&&Di(l)||t(139),this.getChildren().forEach(t=>{l.append(t)})),wr(r)){Wo(r);const t=r.anchor,e=r.focus;t.key===o&&Nr(t,l),e.key===o&&Nr(e,l)}return Po()===o&&Ao(s),l}insertAfter(t,e=!0){di(),Ns(this,t);const n=this.getWritable(),r=t.getWritable(),i=r.getParent(),o=$r();let s=!1,l=!1;if(null!==i){const e=t.getIndexWithinParent();if(Oo(r),wr(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&&wr(o)){const t=this.getIndexWithinParent();Yr(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){di(),Ns(this,t);const n=this.getWritable(),r=t.getWritable(),i=r.__key;Oo(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=$r();if(e&&wr(a)){Yr(a,this.getParentOrThrow(),c)}return t}isParentRequired(){return!1}createParentElementNode(){return Yi()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(t,e){di();const n=this.getPreviousSibling(),r=this.getParentOrThrow();if(null===n)return r.select(0,0);if(Di(n))return n.select();if(!yr(n)){const t=n.getIndexWithinParent()+1;return r.select(t,t)}return n.select(t,e)}selectNext(t,e){di();const n=this.getNextSibling(),r=this.getParentOrThrow();if(null===n)return r.select();if(Di(n))return n.select(0,0);if(!yr(n)){const t=n.getIndexWithinParent();return r.select(t,t)}return n.select(t,e)}markDirty(){this.getWritable()}reconcileObservedMutation(t,e){this.markDirty()}}const Rn="historic",Bn="history-push",Wn="history-merge",Jn="paste",jn="collaboration",Un="skip-collab",$n="skip-scroll-into-view",Vn="skip-dom-selection",Yn="skip-selection-focus",qn="composition-start",Hn="composition-end";class Gn extends zn{static getType(){return"linebreak"}static clone(t){return new Gn(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&&Ks(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&tr(n)){const n=e.lastChild;if(n===t||n.previousSibling===t&&tr(n))return!0}}return!1}(t)||function(t){const e=t.parentElement;if(null!==e&&Ks(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&tr(n))return!1;const r=e.lastChild;if(r===t||r.previousSibling===t&&tr(r))return!0}return!1}(t)?null:{conversion:Xn,priority:0}}}static importJSON(t){return Qn().updateFromJSON(t)}}function Xn(t){return{node:Qn()}}function Qn(){return Ts(new Gn)}function Zn(t){return t instanceof Gn}function tr(t){return ko(t)&&/^( |\t|\r?\n)+$/.test(t.textContent||"")}function er(t,e){return 16&e?"code":e&k?"mark":32&e?"sub":64&e?"sup":null}function nr(t,e){return 1&e?"strong":2&e?"em":"span"}function rr(t,e,n,r,i){const o=r.classList;let s=is(i,"base");void 0!==s&&o.add(...s),s=is(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=is(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 ir(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 or(t,e,n,r,i,o){ir(i,t,e);const s=o.theme.text;void 0!==s&&rr(0,0,r,t,s)}function sr(t,e){const n=document.createElement(e);return n.appendChild(t),n}class lr extends zn{__text;__format;__style;__mode;__detail;static getType(){return"text"}static clone(t){return new lr(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===Po()}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=er(0,n),i=nr(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));or(l,this,0,n,this.__text,t);const c=this.__style;return""!==c&&(s.style.cssText=c),s}updateDOM(e,n,r){const i=this.__text,o=e.__format,s=this.__format,l=er(0,o),c=er(0,s),a=nr(0,o),u=nr(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 or(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)),ir(i,f,this);const d=r.theme.text;void 0!==d&&o!==s&&rr(0,o,s,f,d);const h=e.__style,g=this.__style;return h!==g&&(n.style.cssText=g),!1}static importDOM(){return{"#text":()=>({conversion:dr,priority:0}),b:()=>({conversion:ar,priority:0}),code:()=>({conversion:_r,priority:0}),em:()=>({conversion:_r,priority:0}),i:()=>({conversion:_r,priority:0}),mark:()=>({conversion:_r,priority:0}),s:()=>({conversion:_r,priority:0}),span:()=>({conversion:cr,priority:0}),strong:()=>({conversion:_r,priority:0}),sub:()=>({conversion:_r,priority:0}),sup:()=>({conversion:_r,priority:0}),u:()=>({conversion:_r,priority:0})}}static importJSON(t){return pr().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 Ds(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=sr(n,"b")),this.hasFormat("italic")&&(n=sr(n,"i")),this.hasFormat("strikethrough")&&(n=sr(n,"s")),this.hasFormat("underline")&&(n=sr(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=J[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){di();let n=t,r=e;const i=$r(),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(!wr(i))return Br(s,n,s,r,"text","text");{const t=Po();t!==i.anchor.key&&t!==i.focus.key||Ao(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=$r();if(r&&wr(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){di();const e=this.getLatest(),n=e.getTextContent();if(""===n)return[];const r=e.__key,i=Po(),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=$r();if(wr(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=pr(a),f.__format=d,f.__style=h,f.__detail=g,f.__state=pt(e,f),_=!0):f=e.setTextContent(a);const x=[f];for(let t=1;t<c;t++){const n=pr(s[t]);n.__format=d,n.__style=h,n.__detail=g,n.__state=pt(e,n);const o=n.__key;i===r&&Ao(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&&Mo(e);null!==n&&Mo(n)}(this);const t=u.getWritable(),e=this.getIndexWithinParent();_?(t.splice(e,0,x),this.remove()):t.splice(e,1,x),wr(m)&&Yr(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;Po()===i&&Ao(r);const l=$r();if(wr(l)){const t=l.anchor,o=l.focus;null!==t&&t.key===i&&Gr(t,n,r,e,s),null!==o&&o.key===i&&Gr(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 cr(t){return{forChild:mr(t.style),node:null}}function ar(t){const e=t,n="normal"===e.style.fontWeight;return{forChild:mr(e.style,n?void 0:"bold"),node:null}}const ur=new WeakMap;function fr(t){if(!Ds(t))return!1;if("PRE"===t.nodeName)return!0;const e=t.style.whiteSpace;return"string"==typeof e&&e.startsWith("pre")}function dr(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=ur.get(n))&&!fr(n);)r.push(n),n=n.parentNode;const i=void 0===e?n:e;for(let t=0;t<r.length;t++)ur.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(Qn()):"\t"===n?e.push(Cr()):""!==n&&e.push(pr(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=hr(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=hr(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:pr(r)}}function hr(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,Ds(n)){const t=n.style.display;if(""===t&&!Is(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 gr={code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function _r(t){const e=gr[t.nodeName.toLowerCase()];return void 0===e?{node:null}:{forChild:mr(t.style,e),node:null}}function pr(t=""){return Ts(new lr(t))}function yr(t){return t instanceof lr}function mr(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=>yr(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 xr extends lr{static getType(){return"tab"}static clone(t){return new xr(t.__key)}constructor(t){super("\t",t),this.__detail=2}static importDOM(){return null}createDOM(t){const e=super.createDOM(t),n=is(t.theme,"tab");if(void 0!==n){e.classList.add(...n)}return e}static importJSON(t){return Cr().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 Cr(){return Ts(new xr)}function Sr(t){return t instanceof xr}class vr{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 wl(Wl(Pl(this,"next")),Wl(Pl(t,"next")))<0}getNode(){const e=Do(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,fi()||(Po()===o&&Ao(t),null!==i&&(i.setCachedNodes(null),i.dirty=!0)))}}function kr(t,e,n){return new vr(t,e,n)}function Tr(t,e){let n=e.__key,r=t.offset,i="element";if(yr(e)){i="text";const t=e.getTextContentSize();r>t&&(r=t)}else if(!Di(e)){const t=e.getNextSibling();if(yr(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 Nr(t,e){if(Di(e)){const n=e.getLastDescendant();Di(n)||yr(n)?Tr(t,n):Tr(t,e)}else Tr(t,e)}class br{_nodes;_cachedNodes;dirty;constructor(t){this._cachedNodes=null,this._nodes=t,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){if(!Or(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 br(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(yr(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=Do(t);null!==e&&n.push(e)}return fi()||(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}deleteNodes(){const t=this.getNodes();if(($r()||Vr())===this&&t[0]){const e=hl(t[0],"next");Fl(Nl(e,e))}for(const e of t)e.remove()}}function wr(t){return t instanceof Er}class Er{format;style;anchor;focus