lexical 0.32.0 → 0.32.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Lexical.prod.js CHANGED
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";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.`)}const e="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,n=e&&"documentMode"in document?document.documentMode:null,r=e&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),i=e&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),o=!(!e||!("InputEvent"in window)||n)&&"getTargetRanges"in new window.InputEvent("input"),s=e&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),l=e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,c=e&&/Android/.test(navigator.userAgent),a=e&&/^(?=.*Chrome).*/i.test(navigator.userAgent),u=e&&c&&a,f=e&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!a;function d(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}const h=1,g=3,_=9,p=11,y=0,m=1,x=2,C=0,S=1,T=2,N=4,v=8,k=128,E=1792|(112|(3|N|v)|k),b=1,M=2,O=3,A=4,w=5,D=6,P=s||l||f?" ":"​",I="\n\n",L=i?" ":P,F="֑-߿יִ-﷽ﹰ-ﻼ",R="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",K=new RegExp("^[^"+R+"]*["+F+"]"),B=new RegExp("^[^"+F+"]*["+R+"]"),z={bold:1,capitalize:1024,code:16,highlight:k,italic:2,lowercase:256,strikethrough:N,subscript:32,superscript:64,underline:v,uppercase:512},W={directionless:1,unmergeable:2},$={center:M,end:D,justify:A,left:b,right:O,start:w},U={[M]:"center",[D]:"end",[A]:"justify",[b]:"left",[O]:"right",[w]:"start"},Y={normal:0,segmented:2,token:1},J={[C]:"normal",[T]:"segmented",[S]:"token"},H="$";function j(t,e,n,r,i,o){let s=t.getFirstChild();for(;null!==s;){const t=s.__key;s.__parent===e&&(Zr(s)&&j(s,t,n,r,i,o),n.has(t)||o.delete(t),i.push(t)),s=s.getNextSibling()}}const V=100;let G=!1,q=0;function X(t){q=t.timeStamp}function Q(t,e,n){const r="BR"===t.nodeName,i=e.__lexicalLineBreak;return i&&(t===i||r&&t.previousSibling===i)||r&&void 0!==Bi(t,n)}function Z(t,e,n){const r=wo(To(n));let i=null,o=null;null!==r&&r.anchorNode===t&&(i=r.anchorOffset,o=r.focusOffset);const s=t.nodeValue;null!==s&&Zi(e,s,i,o,!1)}function tt(t,e,n){if(tr(t)){const e=t.anchor.getNode();if(e.is(n)&&t.format!==e.getFormat())return!1}return Mi(e)&&n.isAttached()}function et(t,e,n,r){for(let i=t;i&&!Jo(i);i=po(i)){const t=Bi(i,e);if(void 0!==t){const e=Ri(t,n);if(e)return ni(e)||!Po(i)?void 0:[i,e]}else if(i===r)return[r,Yi(n)]}}function nt(t,e,n){G=!0;const r=performance.now()-q>V;try{Gr(t,(()=>{const o=pr()||function(t){return t.getEditorState().read((()=>{const t=pr();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,_=et(g,t,c,l);if(!_)continue;const[p,y]=_;if("characterData"===h)r&&Yn(y)&&Mi(g)&&tt(o,g,y)&&Z(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],o=Ki(r),s=r.parentNode;if(null!=s&&r!==a&&null===o&&!Q(r,s,t)){if(i){const t=(Po(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];(Q(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||Q(n,i,t)||o.removeChild(n)}}n.takeRecords()}null!==o&&(u&&Ji(o),i&&fo(t)&&o.insertRawText(f))}))}finally{G=!1}}function rt(t){const e=t._observer;if(null!==e){nt(t,e.takeRecords(),e)}}function it(t){!function(t){0===q&&To(t).addEventListener("textInput",X,!0)}(t),t._observer=new MutationObserver(((e,n)=>{nt(t,e,n)}))}function ot(t){return t}class st{constructor(t,e){this.key=t,this.parse=e.parse.bind(e),this.unparse=(e.unparse||ot).bind(e),this.isEqual=(e.isEqual||Object.is).bind(e),this.defaultValue=this.parse(void 0)}}function lt(t,e,n="latest"){const r=("latest"===n?t.getLatest():t).__state;return r?r.getValue(e):e.defaultValue}class ct{constructor(t,e=new Map,n=void 0,r=new Map,i=void 0){this.node=t,this.sharedConfigMap=e,this.unknownState=n,this.knownState=r;const o=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}(e,n,r);this.size=o}getValue(t){const e=this.knownState.get(t);if(void 0!==e)return e;this.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};for(const[e,n]of this.knownState)e.isEqual(n,e.defaultValue)?delete t[e.key]:t[e.key]=e.unparse(n);return at(t)?{[H]:t}:{}}getWritable(t){if(this.node===t)return this;const e=new Map(this.knownState),n=at(r=this.unknownState)&&{...r};var r;if(n)for(const t of e.keys())delete n[t.key];return new ct(t,this.sharedConfigMap,at(n),e,this.size)}updateFromKnown(t,e){const n=t.key;this.sharedConfigMap.set(n,t);const{knownState:r,unknownState:i}=this;r.has(t)||i&&n in i||this.size++,r.set(t,e)}updateFromUnknown(t,e){const n=this.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={},t)for(const[e,n]of Object.entries(t))this.updateFromUnknown(e,n);this.unknownState=at(this.unknownState)}}function at(t){if(t)for(const e in t)return t}function ut(t){const e=t.getWritable(),n=e.__state?e.__state.getWritable(e):new ct(e);return e.__state=n,n}function ft(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;if(t&&e&&t.size!==e.size)return!1;const n=new Set,r=(t,e)=>{for(const[r,i]of t.knownState){if(n.has(r.key))continue;n.add(r.key);const t=e?e.getValue(r):r.defaultValue;if(t!==i&&!r.isEqual(t,i))return!0}return!1},i=(t,e)=>{const{unknownState:r}=t,i=e?e.unknownState:void 0;if(r)for(const[t,e]of Object.entries(r))if(!n.has(t)&&(n.add(t),e!==(i?i[t]:void 0)))return!0;return!1};return!(t&&r(t,e)||e&&r(e,t)||t&&i(t,e)||e&&i(e,t))}(c,a))}function dt(t,e){const n=t.mergeWithSibling(e),r=Rr()._normalizedNodes;return r.add(t.__key),r.add(e.__key),n}function ht(t){let e,n,r=t;if(""!==r.__text||!r.isSimpleText()||r.isUnmergeable()){for(;null!==(e=r.getPreviousSibling())&&Yn(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(""!==e.__text){if(ft(e,r)){r=dt(e,r);break}break}e.remove()}for(;null!==(n=r.getNextSibling())&&Yn(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(""!==n.__text){if(ft(r,n)){r=dt(r,n);break}break}n.remove()}}else r.remove()}function gt(t){return _t(t.anchor),_t(t.focus),t}function _t(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),Yn(r)){t.set(r.__key,i?r.getTextContentSize():0,"text",!0);break}if(!Zr(r))break;t.set(r.__key,i?r.getChildrenSize():0,"element",!0)}}let pt,yt,mt,xt,Ct,St,Tt,Nt,vt,kt,Et="",bt="",Mt=null,Ot="",At="",wt=!1,Dt=!1,Pt=null;function It(t,e){const n=Tt.get(t);if(null!==e){const n=Xt(t);n.parentNode===e&&e.removeChild(n)}if(Nt.has(t)||yt._keyToDOMMap.delete(t),Zr(n)){const t=Ht(n,Tt);Lt(t,0,t.length-1,null)}void 0!==n&&co(kt,mt,xt,n,"destroyed")}function Lt(t,e,n,r){let i=e;for(;i<=n;++i){const e=t[i];void 0!==e&&It(e,r)}}function Ft(t,e){t.setProperty("text-align",e)}const Rt="40px";function Kt(t,e){const n=pt.theme.indent;if("string"==typeof n){const r=t.classList.contains(n);e>0&&!r?t.classList.add(n):e<1&&r&&t.classList.remove(n)}const r=getComputedStyle(t).getPropertyValue("--lexical-indent-base-value")||Rt;t.style.setProperty("padding-inline-start",0===e?"":`calc(${e} * ${r})`)}function Bt(t,e){const n=t.style;0===e?Ft(n,""):e===b?Ft(n,"left"):e===M?Ft(n,"center"):e===O?Ft(n,"right"):e===A?Ft(n,"justify"):e===w?Ft(n,"start"):e===D&&Ft(n,"end")}function zt(e,n){const r=Nt.get(e);void 0===r&&t(60);const i=r.createDOM(pt,yt);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,yt),Yn(r)?i.setAttribute("data-lexical-text","true"):ni(r)&&i.setAttribute("data-lexical-decorator","true"),Zr(r)){const t=r.__indent,e=r.__size;if(0!==t&&Kt(i,t),0!==e){const t=e-1;!function(t,e,n,r){const i=bt;bt="",Wt(t,n,0,e,n.getDOMSlot(r)),Yt(n,r),bt=i}(Ht(r,Nt),t,r,i)}const n=r.__format;0!==n&&Bt(i,n),r.isInline()||Ut(null,r,i),go(r)&&(Et+=I,At+=I)}else{const t=r.getTextContent();if(ni(r)){const t=r.decorate(yt,pt);null!==t&&Vt(e,t),i.contentEditable="false"}else Yn(r)&&(r.isDirectionless()||(bt+=t));Et+=t,At+=t}return null!==n&&n.insertChild(i),co(kt,mt,xt,r,"created"),i}function Wt(t,e,n,r,i){const o=Et;Et="";let s=n;for(;s<=r;++s){zt(t[s],i);const e=Nt.get(t[s]);null!==e&&Yn(e)&&(null===Mt&&(Mt=e.getFormat()),""===Ot&&(Ot=e.getStyle()))}go(e)&&(Et+=I);i.element.__lexicalTextContent=Et,Et=o+Et}function $t(t,e){if(t){const n=t.__last;if(n){const t=e.get(n);if(t)return En(t)?"line-break":ni(t)&&t.isInline()?"decorator":null}return"empty"}return null}function Ut(t,e,n){const r=$t(t,Tt),i=$t(e,Nt);r!==i&&e.getDOMSlot(n).setManagedLineBreak(i)}function Yt(t,e){const n=e.__lexicalDirTextContent||"",r=e.__lexicalDir||"";if(n!==bt||r!==Pt){const n=""===bt,i=n?Pt:function(t){if(K.test(t))return"rtl";if(B.test(t))return"ltr";return null}(bt);if(i!==r){const o=e.classList,s=pt.theme;let l=null!==r?s[r]:void 0,c=null!==i?s[i]:void 0;if(void 0!==l){if("string"==typeof l){const t=d(l);l=s[r]=t}o.remove(...l)}if(null===i||n&&"ltr"===i)e.removeAttribute("dir");else{if(void 0!==c){if("string"==typeof c){const t=d(c);c=s[i]=t}void 0!==c&&o.add(...c)}e.dir=i}if(!Dt){t.getWritable().__dir=i}}Pt=i,e.__lexicalDirTextContent=bt,e.__lexicalDir=i}}function Jt(e,n,r){const i=bt;var o;bt="",Mt=null,Ot="",function(e,n,r){const i=Et,o=e.__size,s=n.__size;Et="";const l=r.element;if(1===o&&1===s){const t=e.__first,r=n.__first;if(t===r)jt(t,l);else{const e=Xt(t),n=zt(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}It(t,null)}const i=Nt.get(r);Yn(i)&&(null===Mt&&(Mt=i.getFormat()),""===Ot&&(Ot=i.getStyle()))}else{const i=Ht(e,Tt),c=Ht(n,Nt);if(i.length!==o&&t(227),c.length!==s&&t(228),0===o)0!==s&&Wt(c,n,0,s-1,r);else if(0===s){if(0!==o){const t=null==r.after&&null==r.before&&null==r.element.__lexicalLineBreak;Lt(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=Gt(jt(r,o.element)),f++,d++;else{void 0===c&&(c=new Set(e)),void 0===a&&(a=new Set(n));const i=a.has(t),s=c.has(r);if(i)if(s){const t=_o(yt,r);t===u?u=Gt(jt(r,o.element)):(o.withBefore(u).insertChild(t),jt(r,o.element)),f++,d++}else zt(r,o.withBefore(u)),d++;else u=Gt(Xt(t)),It(t,o.element),f++}const i=Nt.get(r);null!==i&&Yn(i)&&(null===Mt&&(Mt=i.getFormat()),""===Ot&&(Ot=i.getStyle()))}const h=f>s,g=d>l;if(h&&!g){const e=n[l+1],r=void 0===e?null:yt.getElementByKey(e);Wt(n,t,d,l,o.withBefore(r))}else g&&!h&&Lt(e,f,s,o.element)}(n,i,c,o,s,r)}go(n)&&(Et+=I);l.__lexicalTextContent=Et,Et=i+Et}(e,n,n.getDOMSlot(r)),Yt(n,r),o=n,null==Mt||Mt===o.__textFormat||Dt||o.setTextFormat(Mt),function(t){""===Ot||Ot===t.__textStyle||Dt||t.setTextStyle(Ot)}(n),bt=i}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 jt(e,n){const r=Tt.get(e);let i=Nt.get(e);void 0!==r&&void 0!==i||t(61);const o=wt||St.has(e)||Ct.has(e),s=_o(yt,e);if(r===i&&!o){if(Zr(r)){const t=s.__lexicalTextContent;void 0!==t&&(Et+=t,At+=t);const e=s.__lexicalDirTextContent;void 0!==e&&(bt+=e)}else{const t=r.getTextContent();Yn(r)&&!r.isDirectionless()&&(bt+=t),At+=t,Et+=t}return s}if(r!==i&&o&&co(kt,mt,xt,i,"updated"),i.updateDOM(r,s,pt)){const r=zt(e,null);return null===n&&t(62),n.replaceChild(r,s),It(e,null),r}if(Zr(r)&&Zr(i)){const t=i.__indent;t!==r.__indent&&Kt(s,t);const e=i.__format;e!==r.__format&&Bt(s,e),o&&(Jt(r,i,s),ii(i)||i.isInline()||Ut(r,i,s)),go(i)&&(Et+=I,At+=I)}else{const t=i.getTextContent();if(ni(i)){const t=i.decorate(yt,pt);null!==t&&Vt(e,t)}else Yn(i)&&!i.isDirectionless()&&(bt+=t);Et+=t,At+=t}if(!Dt&&ii(i)&&i.__cachedText!==At){const t=i.getWritable();t.__cachedText=At,i=t}return s}function Vt(t,e){let n=yt._pendingDecorators;const r=yt._decorators;if(null===n){if(r[t]===e)return;n=Wi(yt)}n[t]=e}function Gt(t){let e=t.nextSibling;return null!==e&&e===yt._blockCursorElement&&(e=e.nextSibling),e}function qt(t,e,n,r,i,o){Et="",At="",bt="",wt=r===x,Pt=null,yt=n,pt=n._config,mt=n._nodes,xt=yt._listeners.mutation,Ct=i,St=o,Tt=t._nodeMap,Nt=e._nodeMap,Dt=e._readOnly,vt=new Map(n._keyToDOMMap);const s=new Map;return kt=s,jt("root",null),yt=void 0,mt=void 0,Ct=void 0,St=void 0,Tt=void 0,Nt=void 0,pt=void 0,vt=void 0,kt=void 0,s}function Xt(e){const n=vt.get(e);return void 0===n&&t(75,e),n}function Qt(t){return{type:t}}const Zt=Qt("SELECTION_CHANGE_COMMAND"),te=Qt("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),ee=Qt("CLICK_COMMAND"),ne=Qt("DELETE_CHARACTER_COMMAND"),re=Qt("INSERT_LINE_BREAK_COMMAND"),ie=Qt("INSERT_PARAGRAPH_COMMAND"),oe=Qt("CONTROLLED_TEXT_INSERTION_COMMAND"),se=Qt("PASTE_COMMAND"),le=Qt("REMOVE_TEXT_COMMAND"),ce=Qt("DELETE_WORD_COMMAND"),ae=Qt("DELETE_LINE_COMMAND"),ue=Qt("FORMAT_TEXT_COMMAND"),fe=Qt("UNDO_COMMAND"),de=Qt("REDO_COMMAND"),he=Qt("KEYDOWN_COMMAND"),ge=Qt("KEY_ARROW_RIGHT_COMMAND"),_e=Qt("MOVE_TO_END"),pe=Qt("KEY_ARROW_LEFT_COMMAND"),ye=Qt("MOVE_TO_START"),me=Qt("KEY_ARROW_UP_COMMAND"),xe=Qt("KEY_ARROW_DOWN_COMMAND"),Ce=Qt("KEY_ENTER_COMMAND"),Se=Qt("KEY_SPACE_COMMAND"),Te=Qt("KEY_BACKSPACE_COMMAND"),Ne=Qt("KEY_ESCAPE_COMMAND"),ve=Qt("KEY_DELETE_COMMAND"),ke=Qt("KEY_TAB_COMMAND"),Ee=Qt("INSERT_TAB_COMMAND"),be=Qt("INDENT_CONTENT_COMMAND"),Me=Qt("OUTDENT_CONTENT_COMMAND"),Oe=Qt("DROP_COMMAND"),Ae=Qt("FORMAT_ELEMENT_COMMAND"),we=Qt("DRAGSTART_COMMAND"),De=Qt("DRAGOVER_COMMAND"),Pe=Qt("DRAGEND_COMMAND"),Ie=Qt("COPY_COMMAND"),Le=Qt("CUT_COMMAND"),Fe=Qt("SELECT_ALL_COMMAND"),Re=Qt("CLEAR_EDITOR_COMMAND"),Ke=Qt("CLEAR_HISTORY_COMMAND"),Be=Qt("CAN_REDO_COMMAND"),ze=Qt("CAN_UNDO_COMMAND"),We=Qt("FOCUS_COMMAND"),$e=Qt("BLUR_COMMAND"),Ue=Qt("KEY_MODIFIER_COMMAND"),Ye=Object.freeze({}),Je=30,He=[["keydown",function(t,e){if(je=t.timeStamp,Ve=t.key,e.isComposing())return;if(ho(e,he,t))return;if(null==t.key)return;if(nn&&oo(t))return Gr(e,(()=>{hn(e,rn)})),nn=!1,void(rn="");if(function(t){return no(t,"ArrowRight",{shiftKey:"any"})}(t))ho(e,ge,t);else if(function(t){return no(t,"ArrowRight",ro)}(t))ho(e,_e,t);else if(function(t){return no(t,"ArrowLeft",{shiftKey:"any"})}(t))ho(e,pe,t);else if(function(t){return no(t,"ArrowLeft",ro)}(t))ho(e,ye,t);else if(function(t){return no(t,"ArrowUp",{altKey:"any",shiftKey:"any"})}(t))ho(e,me,t);else if(function(t){return no(t,"ArrowDown",{altKey:"any",shiftKey:"any"})}(t))ho(e,xe,t);else if(function(t){return no(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any",shiftKey:!0})}(t))tn=!0,ho(e,Ce,t);else if(function(t){return" "===t.key}(t))ho(e,Se,t);else if(function(t){return r&&no(t,"o",{ctrlKey:!0})}(t))t.preventDefault(),tn=!0,ho(e,re,!0);else if(function(t){return no(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any"})}(t))tn=!1,ho(e,Ce,t);else if(function(t){return no(t,"Backspace",{shiftKey:"any"})||r&&no(t,"h",{ctrlKey:!0})}(t))oo(t)?ho(e,Te,t):(t.preventDefault(),ho(e,ne,!0));else if(function(t){return"Escape"===t.key}(t))ho(e,Ne,t);else if(function(t){return no(t,"Delete",{})||r&&no(t,"d",{ctrlKey:!0})}(t))!function(t){return"Delete"===t.key}(t)?(t.preventDefault(),ho(e,ne,!1)):ho(e,ve,t);else if(function(t){return no(t,"Backspace",io)}(t))t.preventDefault(),ho(e,ce,!0);else if(function(t){return no(t,"Delete",io)}(t))t.preventDefault(),ho(e,ce,!1);else if(function(t){return r&&no(t,"Backspace",{metaKey:!0})}(t))t.preventDefault(),ho(e,ae,!0);else if(function(t){return r&&(no(t,"Delete",{metaKey:!0})||no(t,"k",{ctrlKey:!0}))}(t))t.preventDefault(),ho(e,ae,!1);else if(function(t){return no(t,"b",ro)}(t))t.preventDefault(),ho(e,ue,"bold");else if(function(t){return no(t,"u",ro)}(t))t.preventDefault(),ho(e,ue,"underline");else if(function(t){return no(t,"i",ro)}(t))t.preventDefault(),ho(e,ue,"italic");else if(function(t){return no(t,"Tab",{shiftKey:"any"})}(t))ho(e,ke,t);else if(function(t){return no(t,"z",ro)}(t))t.preventDefault(),ho(e,fe,void 0);else if(function(t){if(r)return no(t,"z",{metaKey:!0,shiftKey:!0});return no(t,"y",{ctrlKey:!0})||no(t,"z",{ctrlKey:!0,shiftKey:!0})}(t))t.preventDefault(),ho(e,de,void 0);else{const n=e._editorState._selection;null===n||tr(n)?!i&&so(t)&&(t.preventDefault(),ho(e,Fe,t)):!function(t){return no(t,"c",ro)}(t)?!function(t){return no(t,"x",ro)}(t)?so(t)&&(t.preventDefault(),ho(e,Fe,t)):(t.preventDefault(),ho(e,Le,t)):(t.preventDefault(),ho(e,Ie,t))}(function(t){return t.ctrlKey||t.shiftKey||t.altKey||t.metaKey})(t)&&ho(e,Ue,t)}],["pointerdown",function(t,e){const n=t.target,r=t.pointerType;Io(n)&&"touch"!==r&&"pen"!==r&&0===t.button&&Gr(e,(()=>{Si(n)||(Ze=!0)}))}],["compositionstart",function(t,e){Gr(e,(()=>{const n=pr();if(tr(n)&&!e.isComposing()){const r=n.anchor,i=n.anchor.getNode();Li(r.key),(t.timeStamp<je+Je||"element"===r.type||!n.isCollapsed()||i.getFormat()!==n.format||Yn(i)&&i.getStyle()!==n.style)&&ho(e,oe,L)}}))}],["compositionend",function(t,e){i?en=!0:l||!s&&!f?Gr(e,(()=>{hn(e,t.data)})):(nn=!0,rn=t.data)}],["input",function(t,e){t.stopPropagation(),Gr(e,(()=>{if(Po(t.target)&&Si(t.target))return;const n=pr(),r=t.data,c=dn(t);if(null!=r&&tr(n)&&ln(n,c,r,t.timeStamp,!1)){en&&(hn(e,r),en=!1);const c=n.anchor.getNode(),a=wo(To(e));if(null===a)return;const u=n.isBackward(),d=u?n.anchor.offset:n.focus.offset,h=u?n.focus.offset:n.anchor.offset;o&&!n.isCollapsed()&&Yn(c)&&null!==a.anchorNode&&c.getTextContent().slice(0,d)+r+c.getTextContent().slice(d+h)===Xi(a.anchorNode)||ho(e,oe,r);const g=r.length;i&&g>1&&"insertCompositionText"===t.inputType&&!e.isComposing()&&(n.anchor.offset-=g),s||l||f||!e.isComposing()||(je=0,Li(null))}else{Qi(!1,e,null!==r?r:void 0),en&&(hn(e,r||void 0),en=!1)}!function(){Ir();const t=Rr();rt(t)}()}),{event:t}),qe=null}],["click",function(t,e){Gr(e,(()=>{const n=pr(),r=wo(To(e)),i=yr();if(r)if(tr(n)){const e=n.anchor,o=e.getNode();if("element"===e.type&&0===e.offset&&n.isCollapsed()&&!ii(o)&&1===Ui().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=function(t,e){let n=t;for(;n!==Ui()&&null!=n;){if(e(n))return n;n=n.getParent()}return null}(o,(t=>Zr(t)&&!t.isInline()));Zr(t)&&t.select(0)}}}else if("touch"===t.pointerType||"pen"===t.pointerType){const n=r.anchorNode;if(Po(n)||Mi(n)){Ji(_r(i,r,e,t))}}ho(e,ee,t)}))}],["cut",Ye],["copy",Ye],["dragstart",Ye],["dragover",Ye],["dragend",Ye],["paste",Ye],["focus",Ye],["blur",Ye],["drop",Ye]];o&&He.push(["beforeinput",(e,n)=>function(e,n){const r=e.inputType,o=dn(e);if("deleteCompositionText"===r||i&&fo(n))return;if("insertCompositionText"===r)return;Gr(n,(()=>{const i=pr();if("deleteContentBackward"===r){if(null===i){const t=yr();if(!tr(t))return;Ji(t.clone())}if(tr(i)){const r=i.anchor.key===i.focus.key;if(s=e.timeStamp,"MediaLast"===Ve&&s<je+Je&&n.isComposing()&&r){if(Li(null),je=0,setTimeout((()=>{Gr(n,(()=>{Li(null)}))}),Je),tr(i)){const e=i.anchor.getNode();e.markDirty(),Yn(e)||t(142),fn(i,e)}}else{Li(null),e.preventDefault();const t=i.anchor.getNode(),o=t.getTextContent(),s=t.canInsertTextAfter(),l=0===i.anchor.offset&&i.focus.offset===o.length;let c=u&&r&&!l&&s;if(c&&i.isCollapsed()&&(c=!ni(uo(i.anchor,!0))),!c){ho(n,ne,!0);const t=pr();u&&tr(t)&&t.isCollapsed()&&(on=t,setTimeout((()=>on=null)))}}return}}var s;if(!tr(i))return;const c=e.data;null!==qe&&Qi(!1,n,qe),i.dirty&&null===qe||!i.isCollapsed()||ii(i.anchor.getNode())||null===o||i.applyDOMRange(o),qe=null;const a=i.anchor,f=i.focus,d=a.getNode(),h=f.getNode();if("insertText"!==r&&"insertTranspose"!==r)switch(e.preventDefault(),r){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":ho(n,oe,e);break;case"insertFromComposition":Li(null),ho(n,oe,e);break;case"insertLineBreak":Li(null),ho(n,re,!1);break;case"insertParagraph":Li(null),tn&&!l?(tn=!1,ho(n,re,!1)):ho(n,ie,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":ho(n,se,e);break;case"deleteByComposition":(function(t,e){return t!==e||Zr(t)||Zr(e)||!t.isToken()||!e.isToken()})(d,h)&&ho(n,le,e);break;case"deleteByDrag":case"deleteByCut":ho(n,le,e);break;case"deleteContent":ho(n,ne,!1);break;case"deleteWordBackward":ho(n,ce,!0);break;case"deleteWordForward":ho(n,ce,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":ho(n,ae,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":ho(n,ae,!1);break;case"formatStrikeThrough":ho(n,ue,"strikethrough");break;case"formatBold":ho(n,ue,"bold");break;case"formatItalic":ho(n,ue,"italic");break;case"formatUnderline":ho(n,ue,"underline");break;case"historyUndo":ho(n,fe,void 0);break;case"historyRedo":ho(n,de,void 0)}else{if("\n"===c)e.preventDefault(),ho(n,re,!1);else if(c===I)e.preventDefault(),ho(n,ie,void 0);else if(null==c&&e.dataTransfer){const t=e.dataTransfer.getData("text/plain");e.preventDefault(),i.insertRawText(t)}else null!=c&&ln(i,o,c,e.timeStamp,!0)?(e.preventDefault(),ho(n,oe,c)):qe=c;Ge=e.timeStamp}}))}(e,n)]);let je=0,Ve=null,Ge=0,qe=null;const Xe=new WeakMap;let Qe=!1,Ze=!1,tn=!1,en=!1,nn=!1,rn="",on=null,sn=[0,"",0,"root",0];function ln(t,e,n,r,i){const s=t.anchor,l=t.focus,c=s.getNode(),a=Rr(),u=wo(To(a)),f=null!==u?u.anchorNode:null,d=s.key,h=a.getElementByKey(d),g=n.length;return d!==l.key||!Yn(c)||(!i&&(!o||Ge<r+50)||c.isDirty()&&g<2||Vi(n))&&s.offset!==l.offset&&!c.isComposing()||bi(c)||c.isDirty()&&g>1||(i||!o)&&null!==h&&!c.isComposing()&&f!==Ai(h)||null!==u&&null!==e&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||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=e.isToken();return 0===n?!e.canInsertTextBefore()||!r.canInsertTextBefore()&&!e.isComposing()||i||function(t){const e=t.getPreviousSibling();return(Yn(e)||Zr(e)&&e.isInline())&&!e.canInsertTextAfter()}(e):n===e.getTextContentSize()&&(!e.canInsertTextAfter()||!r.canInsertTextAfter()&&!e.isComposing()||i)}(t,c)}function cn(t,e){return Mi(t)&&null!==t.nodeValue&&0!==e&&e!==t.nodeValue.length}function an(e,n,r){const{anchorNode:i,anchorOffset:o,focusNode:s,focusOffset:l}=e;Qe&&(Qe=!1,cn(i,o)&&cn(s,l)&&!on)||Gr(n,(()=>{if(!r)return void Ji(null);if(!Ni(n,i,s))return;let c=pr();if(on&&tr(c)&&c.isCollapsed()){const t=c.anchor,e=on.anchor;(t.key===e.key&&t.offset===e.offset+1||1===t.offset&&e.getNode().is(t.getNode().getPreviousSibling()))&&(c=on.clone(),Ji(c))}if(on=null,tr(c)){const r=c.anchor,i=r.getNode();if(c.isCollapsed()){"Range"===e.type&&e.anchorNode===e.focusNode&&(c.dirty=!0);const o=To(n).event,s=o?o.timeStamp:performance.now(),[l,a,u,f,d]=sn,h=Ui(),g=!1===n.isComposing()&&""===h.getTextContent();if(s<d+200&&r.offset===u&&r.key===f)un(c,l,a);else if("text"===r.type)Yn(i)||t(141),fn(c,i);else if("element"===r.type&&!g){Zr(i)||t(259);const e=r.getNode();e.isEmpty()?function(t,e){const n=e.getTextFormat(),r=e.getTextStyle();un(t,n,r)}(c,e):un(c,0,"")}}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=E,g=!1;for(let t=0;t<i;t++){const e=n[t],r=e.getTextContentSize();if(Yn(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}}ho(n,Zt,void 0)}))}function un(t,e,n){t.format===e&&t.style===n||(t.format=e,t.style=n,t.dirty=!0)}function fn(t,e){un(t,e.getFormat(),e.getStyle())}function dn(t){if(!t.getTargetRanges)return null;const e=t.getTargetRanges();return 0===e.length?null:e[0]}function hn(t,e){const n=t._compositionKey;if(Li(null),null!==n&&null!=e){if(""===e){const e=Ri(n),r=Ai(t.getElementByKey(n));return void(null!==r&&null!==r.nodeValue&&Yn(e)&&Zi(e,r.nodeValue,null,null,!0))}if("\n"===e[e.length-1]){const e=pr();if(tr(e)){const n=e.focus;return e.anchor.set(n.key,n.offset,n.type),void ho(t,Ce,null)}}}Qi(!0,t,e)}function gn(t){let e=t.__lexicalEventHandles;return void 0===e&&(e=[],t.__lexicalEventHandles=e),e}const _n=new Map;function pn(t){const e=Do(t.target);if(null===e)return;const n=ki(e.anchorNode);if(null===n)return;Ze&&(Ze=!1,Gr(n,(()=>{const r=yr(),i=e.anchorNode;if(Po(i)||Mi(i)){Ji(_r(r,e,n,t))}})));const r=Gi(n),i=r[r.length-1],o=i._key,s=_n.get(o),l=s||i;l!==n&&an(e,l,!1),an(e,n,!0),n!==i?_n.set(o,n):s&&_n.delete(o)}function yn(t){t._lexicalHandled=!0}function mn(t){return!0===t._lexicalHandled}const xn=()=>{};function Cn(e){const n=e.ownerDocument,r=Xe.get(n);if(void 0===r)return void xn();const i=r-1;i>=0||t(164),Xe.set(n,i),0===i&&n.removeEventListener("selectionchange",pn);const o=Ei(e);vi(o)?(!function(t){if(null!==t._parentEditor){const e=Gi(t),n=e[e.length-1]._key;_n.get(n)===t&&_n.delete(n)}else _n.delete(t._key)}(o),e.__lexicalEditor=null):o&&t(198);const s=gn(e);for(let t=0;t<s.length;t++)s[t]();e.__lexicalEventHandles=[]}function Sn(t,e,n){Ir();const r=t.__key,i=t.getParent();if(null===i)return;const o=function(t){const e=pr();if(!tr(e)||!Zr(t))return e;const{anchor:n,focus:r}=e,i=n.getNode(),o=r.getNode();Co(i,t)&&n.set(t.__key,0,"element");Co(o,t)&&r.set(t.__key,0,"element");return e}(t);let s=!1;if(tr(o)&&e){const e=o.anchor,n=o.focus;e.key===r&&(Cr(e,t,i,t.getPreviousSibling(),t.getNextSibling()),s=!0),n.key===r&&(Cr(n,t,i,t.getPreviousSibling(),t.getNextSibling()),s=!0)}else nr(o)&&e&&t.isSelected()&&t.selectPrevious();if(tr(o)&&e&&!s){const e=t.getIndexWithinParent();Pi(t),mr(o,i,e,-1)}else Pi(t);n||vo(i)||i.canBeEmpty()||!i.isEmpty()||Sn(i,e),e&&o&&ii(i)&&i.isEmpty()&&i.selectEnd()}class Tn{static getType(){t(64,this.name)}static clone(e){t(65,this.name)}afterCloneFrom(t){this.__parent=t.__parent,this.__next=t.__next,this.__prev=t.__prev,this.__state=t.__state}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}),Di(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=Ri(t);if(null===e)break;t=e.__parent}return!1}isSelected(t){const e=t||pr();if(null==e)return!1;const n=e.getNodes().some((t=>t.__key===this.__key));if(Yn(this))return n;if(tr(e)&&"element"===e.anchor.type&&"element"===e.focus.type){if(e.isCollapsed())return!1;const t=this.getParent();if(ni(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:Ri(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(vo(n))return Zr(e)||e===this&&ni(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:Ri(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:Ri(t)}getNextSiblings(){const t=[];let e=this.getNextSibling();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getCommonAncestor(t){const e=Zr(this)?this:this.getParent(),n=Zr(t)?t:t.getParent(),r=e&&n?Ns(e,n):null;return r?r.commonAncestor:null}is(t){return null!=t&&this.__key===t.__key}isBefore(e){const n=Ns(this,e);return null!==n&&("descendant"===n.type||("branch"===n.type?-1===Cs(n):("same"!==n.type&&"ancestor"!==n.type&&t(279),!1)))}isParentOf(t){const e=Ns(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=Zr(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=Rr()._dirtyLeaves;return null!==t&&t.has(this.__key)}getLatest(){const e=Ri(this.__key);return null===e&&t(113),e}getWritable(){Ir();const t=Fr(),e=Rr(),n=t._nodeMap,r=this.__key,i=this.getLatest(),o=e._cloneNotNeeded,s=pr();if(null!==s&&s.setCachedNodes(null),o.has(r))return Ii(i),i;const l=Uo(i);return o.add(r),Ii(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();return(e||n.__state)&&ut(t).updateFromJSON(e),n}(this,t.$)}static transform(){return null}remove(t){Sn(this,!0,t)}replace(e,n){Ir();let r=pr();null!==r&&(r=r.clone()),bo(this,e);const i=this.getLatest(),o=this.__key,s=e.__key,l=e.getWritable(),c=this.getParentOrThrow().getWritable(),a=c.__size;Pi(l);const u=i.getPreviousSibling(),f=i.getNextSibling(),d=i.__prev,h=i.__next,g=i.__parent;if(Sn(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&&(Zr(this)&&Zr(l)||t(139),this.getChildren().forEach((t=>{l.append(t)}))),tr(r)){Ji(r);const t=r.anchor,e=r.focus;t.key===o&&Qn(t,l),e.key===o&&Qn(e,l)}return Fi()===o&&Li(s),l}insertAfter(t,e=!0){Ir(),bo(this,t);const n=this.getWritable(),r=t.getWritable(),i=r.getParent(),o=pr();let s=!1,l=!1;if(null!==i){const e=t.getIndexWithinParent();if(Pi(r),tr(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&&tr(o)){const t=this.getIndexWithinParent();mr(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){Ir(),bo(this,t);const n=this.getWritable(),r=t.getWritable(),i=r.__key;Pi(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=pr();if(e&&tr(a)){mr(a,this.getParentOrThrow(),c)}return t}isParentRequired(){return!1}createParentElementNode(){return pi()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(t,e){Ir();const n=this.getPreviousSibling(),r=this.getParentOrThrow();if(null===n)return r.select(0,0);if(Zr(n))return n.select();if(!Yn(n)){const t=n.getIndexWithinParent()+1;return r.select(t,t)}return n.select(t,e)}selectNext(t,e){Ir();const n=this.getNextSibling(),r=this.getParentOrThrow();if(null===n)return r.select();if(Zr(n))return n.select(0,0);if(!Yn(n)){const t=n.getIndexWithinParent();return r.select(t,t)}return n.select(t,e)}markDirty(){this.getWritable()}reconcileObservedMutation(t,e){this.markDirty()}}class Nn extends Tn{static getType(){return"linebreak"}static clone(t){return new Nn(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&&Ro(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&bn(n)){const n=e.lastChild;if(n===t||n.previousSibling===t&&bn(n))return!0}}return!1}(t)||function(t){const e=t.parentElement;if(null!==e&&Ro(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&bn(n))return!1;const r=e.lastChild;if(r===t||r.previousSibling===t&&bn(r))return!0}return!1}(t)?null:{conversion:vn,priority:0}}}static importJSON(t){return kn().updateFromJSON(t)}}function vn(t){return{node:kn()}}function kn(){return Eo(new Nn)}function En(t){return t instanceof Nn}function bn(t){return Mi(t)&&/^( |\t|\r?\n)+$/.test(t.textContent||"")}function Mn(t,e){return 16&e?"code":e&k?"mark":32&e?"sub":64&e?"sup":null}function On(t,e){return 1&e?"strong":2&e?"em":"span"}function An(t,e,n,r,i){const o=r.classList;let s=lo(i,"base");void 0!==s&&o.add(...s),s=lo(i,"underlineStrikethrough");let l=!1;const c=e&v&&e&N;void 0!==s&&(n&v&&n&N?(l=!0,c||o.add(...s)):c&&o.remove(...s));for(const t in z){const r=z[t];if(s=lo(i,t),void 0!==s)if(n&r){if(l&&("underline"===t||"strikethrough"===t)){e&r&&o.remove(...s);continue}e&r&&(!c||"underline"!==t)&&"strikethrough"!==t||o.add(...s)}else e&r&&o.remove(...s)}}function wn(t,e,n){const r=e.firstChild,o=n.isComposing(),s=t+(o?P:"");if(null==r)e.textContent=s;else{const t=r.nodeValue;if(t!==s)if(o||i){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 Dn(t,e,n,r,i,o){wn(i,t,e);const s=o.theme.text;void 0!==s&&An(0,0,r,t,s)}function Pn(t,e){const n=document.createElement(e);return n.appendChild(t),n}class In extends Tn{static getType(){return"text"}static clone(t){return new In(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===Fi()}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!!(this.getFormat()&e)}isSimpleText(){return"text"===this.__type&&0===this.__mode}getTextContent(){return this.getLatest().__text}getFormatFlags(t,e){return wi(this.getLatest().__format,t,e)}canHaveFormat(){return!0}isInline(){return!0}createDOM(t,e){const n=this.__format,r=Mn(0,n),i=On(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));Dn(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=Mn(0,o),c=Mn(0,s),a=On(0,o),u=On(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 Dn(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)),wn(i,f,this);const d=r.theme.text;void 0!==d&&o!==s&&An(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:Bn,priority:0}),b:()=>({conversion:Fn,priority:0}),code:()=>({conversion:$n,priority:0}),em:()=>({conversion:$n,priority:0}),i:()=>({conversion:$n,priority:0}),mark:()=>({conversion:$n,priority:0}),s:()=>({conversion:$n,priority:0}),span:()=>({conversion:Ln,priority:0}),strong:()=>({conversion:$n,priority:0}),sub:()=>({conversion:$n,priority:0}),sup:()=>({conversion:$n,priority:0}),u:()=>({conversion:$n,priority:0})}}static importJSON(t){return Un().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 Po(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=Pn(n,"b")),this.hasFormat("italic")&&(n=Pn(n,"i")),this.hasFormat("strikethrough")&&(n=Pn(n,"s")),this.hasFormat("underline")&&(n=Pn(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?W[t]:t,e}setStyle(t){const e=this.getWritable();return e.__style=t,e}toggleFormat(t){const e=wi(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=Y[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){Ir();let n=t,r=e;const i=pr(),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(!tr(i))return dr(s,n,s,r,"text","text");{const t=Fi();t!==i.anchor.key&&t!==i.focus.key||Li(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=pr();if(r&&tr(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){Ir();const e=this.getLatest(),n=e.getTextContent();if(""===n)return[];const r=e.__key,i=Fi(),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=pr();if(tr(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=Un(a),f.__format=d,f.__style=h,f.__detail=g,_=!0):(f=e.getWritable(),f.__text=a);const x=[f];for(let t=1;t<c;t++){const e=Un(s[t]);e.__format=d,e.__style=h,e.__detail=g;const n=e.__key;i===r&&Li(n),x.push(e)}const C=p?p.offset:null,S=y?y.offset:null;let T=0;for(const t of x){if(!p&&!y)break;const e=T+t.getTextContentSize();if(null!==p&&null!==C&&C<=e&&C>=T&&(p.set(t.getKey(),C-T,"text"),C<e&&(p=null)),null!==y&&null!==S&&S<=e&&S>=T){y.set(t.getKey(),S-T,"text");break}T=e}if(null!==u){!function(t){const e=t.getPreviousSibling(),n=t.getNextSibling();null!==e&&Ii(e);null!==n&&Ii(n)}(this);const t=u.getWritable(),e=this.getIndexWithinParent();_?(t.splice(e,0,x),this.remove()):t.splice(e,1,x),tr(m)&&mr(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;Fi()===i&&Li(r);const l=pr();if(tr(l)){const t=l.anchor,o=l.focus;null!==t&&t.key===i&&Sr(t,n,r,e,s),null!==o&&o.key===i&&Sr(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 Ln(t){return{forChild:Jn(t.style),node:null}}function Fn(t){const e=t,n="normal"===e.style.fontWeight;return{forChild:Jn(e.style,n?void 0:"bold"),node:null}}const Rn=new WeakMap;function Kn(t){if(!Po(t))return!1;if("PRE"===t.nodeName)return!0;const e=t.style.whiteSpace;return"string"==typeof e&&e.startsWith("pre")}function Bn(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=Rn.get(n))&&!Kn(n);)r.push(n),n=n.parentNode;const i=void 0===e?n:e;for(let t=0;t<r.length;t++)Rn.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(kn()):"\t"===n?e.push(jn()):""!==n&&e.push(Un(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=zn(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=zn(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:Un(r)}}function zn(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,Po(n)){const t=n.style.display;if(""===t&&!Fo(n)||""!==t&&!t.startsWith("inline"))return null}let r=n;for(;null!==(r=e?n.firstChild:n.lastChild);)n=r;if(Mi(n))return n;if("BR"===n.nodeName)return null}}const Wn={code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function $n(t){const e=Wn[t.nodeName.toLowerCase()];return void 0===e?{node:null}:{forChild:Jn(t.style,e),node:null}}function Un(t=""){return Eo(new In(t))}function Yn(t){return t instanceof In}function Jn(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=>Yn(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 Hn extends In{static getType(){return"tab"}static clone(t){return new Hn(t.__key)}constructor(t){super("\t",t),this.__detail=2}static importDOM(){return null}createDOM(t){const e=super.createDOM(t),n=lo(t.theme,"tab");if(void 0!==n){e.classList.add(...n)}return e}static importJSON(t){return jn().updateFromJSON(t)}setTextContent(e){return"\t"!==e&&""!==e&&t(126),super.setTextContent(e)}setDetail(e){return 2!==e&&t(127),this}setMode(e){return"normal"!==e&&t(128),this}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function jn(){return Eo(new Hn)}function Vn(t){return t instanceof Hn}class Gn{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 xs(Ps(vs(this,"next")),Ps(vs(t,"next")))<0}getNode(){const e=Ri(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,Pr()||(Fi()===o&&Li(t),null!==i&&(i.setCachedNodes(null),i.dirty=!0)))}}function qn(t,e,n){return new Gn(t,e,n)}function Xn(t,e){let n=e.__key,r=t.offset,i="element";if(Yn(e)){i="text";const t=e.getTextContentSize();r>t&&(r=t)}else if(!Zr(e)){const t=e.getNextSibling();if(Yn(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 Qn(t,e){if(Zr(e)){const n=e.getLastDescendant();Zr(n)||Yn(n)?Xn(t,n):Xn(t,e)}else Xn(t,e)}class Zn{constructor(t){this._cachedNodes=null,this._nodes=t,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){if(!nr(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 Zn(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(Yn(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=Ri(t);null!==e&&n.push(e)}return Pr()||(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((pr()||yr())===this&&t[0]){const e=ss(t[0],"next");Es(ys(e,e))}for(const e of t)e.remove()}}function tr(t){return t instanceof er}class er{constructor(t,e,n,r){this.anchor=t,this.focus=e,t._selection=this,e._selection=this,this._cachedNodes=null,this.format=n,this.style=r,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){return!!tr(t)&&(this.anchor.is(t.anchor)&&this.focus.is(t.focus)&&this.format===t.format&&this.style===t.style)}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){const t=this._cachedNodes;if(null!==t)return t;const e=function(t){const e=[],[n,r]=t.getTextSlices();n&&e.push(n.caret.origin);const i=new Set,o=new Set;for(const n of t)if(ns(n)){const{origin:t}=n;0===e.length?i.add(t):(o.add(t),e.push(t))}else{const{origin:t}=n;Zr(t)&&o.has(t)||e.push(t)}r&&e.push(r.caret.origin);if(es(t.focus)&&Zr(t.focus.origin)&&null===t.focus.getNodeAtCaret())for(let n=us(t.focus.origin,"previous");ns(n)&&i.has(n.origin)&&!n.origin.isEmpty()&&n.origin.is(e[e.length-1]);n=ds(n))i.delete(n.origin),e.pop();for(;e.length>1;){const t=e[e.length-1];if(!Zr(t)||o.has(t)||t.isEmpty()||i.has(t))break;e.pop()}if(0===e.length&&t.isCollapsed()){const n=Ps(t.anchor),r=Ps(t.anchor.getFlipped()),i=t=>ts(t)?t.origin:t.getNodeAtCaret(),o=i(n)||i(r)||(t.anchor.getNodeAtCaret()?n.origin:r.origin);e.push(o)}return e}(Fs(Ms(this),"next"));return Pr()||(this._cachedNodes=e),e}setTextNodeRange(t,e,n,r){this.anchor.set(t.__key,e,"text"),this.focus.set(n.__key,r,"text")}getTextContent(){const t=this.getNodes();if(0===t.length)return"";const e=t[0],n=t[t.length-1],r=this.anchor,i=this.focus,o=r.isBefore(i),[s,l]=ir(this);let c="",a=!0;for(let u=0;u<t.length;u++){const f=t[u];if(Zr(f)&&!f.isInline())a||(c+="\n"),a=!f.isEmpty();else if(a=!1,Yn(f)){let t=f.getTextContent();f===e?f===n?"element"===r.type&&"element"===i.type&&i.offset!==r.offset||(t=s<l?t.slice(s,l):t.slice(l,s)):t=o?t.slice(s):t.slice(l):f===n&&(t=o?t.slice(0,l):t.slice(0,s)),c+=t}else!ni(f)&&!En(f)||f===n&&this.isCollapsed()||(c+=f.getTextContent())}return c}applyDOMRange(t){const e=Rr(),n=e.getEditorState()._selection,r=fr(t.startContainer,t.startOffset,t.endContainer,t.endOffset,e,n);if(null===r)return;const[i,o]=r;this.anchor.set(i.key,i.offset,i.type,!0),this.focus.set(o.key,o.offset,o.type,!0),gt(this)}clone(){const t=this.anchor,e=this.focus;return new er(qn(t.key,t.offset,t.type),qn(e.key,e.offset,e.type),this.format,this.style)}toggleFormat(t){this.format=wi(this.format,t,null),this.dirty=!0}setStyle(t){this.style=t,this.dirty=!0}hasFormat(t){const e=z[t];return!!(this.format&e)}insertRawText(t){const e=t.split(/(\r?\n|\t)/),n=[],r=e.length;for(let t=0;t<r;t++){const r=e[t];"\n"===r||"\r\n"===r?n.push(kn()):"\t"===r?n.push(jn()):n.push(Un(r))}this.insertNodes(n)}insertText(e){const n=this.anchor,r=this.focus,i=this.format,o=this.style;let s=n,l=r;!this.isCollapsed()&&r.isBefore(n)&&(s=r,l=n),"element"===s.type&&function(t,e,n,r){const i=t.getNode(),o=i.getChildAtIndex(t.offset),s=Un(),l=ii(i)?pi().append(s):s;s.setFormat(n),s.setStyle(r),null===o?i.append(l):o.insertBefore(l),t.is(e)&&e.set(s.__key,0,"text"),t.set(s.__key,0,"text")}(s,l,i,o),"element"===l.type&&ks(l,Ps(vs(l,"next")));const c=s.offset;let a=l.offset;const u=this.getNodes(),f=u.length;let d=u[0];Yn(d)||t(26);const h=d.getTextContent().length,g=d.getParentOrThrow();let _=u[f-1];if(1===f&&"element"===l.type&&(a=h,l.set(s.key,a,"text")),this.isCollapsed()&&c===h&&(d.isSegmented()||d.isToken()||!d.canInsertTextAfter()||!g.canInsertTextAfter()&&null===d.getNextSibling())){let t=d.getNextSibling();if(Yn(t)&&t.canInsertTextBefore()&&!bi(t)||(t=Un(),t.setFormat(i),t.setStyle(o),g.canInsertTextAfter()?d.insertAfter(t):g.insertAfter(t)),t.select(0,0),d=t,""!==e)return void this.insertText(e)}else if(this.isCollapsed()&&0===c&&(d.isSegmented()||d.isToken()||!d.canInsertTextBefore()||!g.canInsertTextBefore()&&null===d.getPreviousSibling())){let t=d.getPreviousSibling();if(Yn(t)&&!bi(t)||(t=Un(),t.setFormat(i),g.canInsertTextBefore()?d.insertBefore(t):g.insertBefore(t)),t.select(),d=t,""!==e)return void this.insertText(e)}else if(d.isSegmented()&&c!==h){const t=Un(d.getTextContent());t.setFormat(i),d.replace(t),d=t}else if(!this.isCollapsed()&&""!==e){const t=_.getParent();if(!g.canInsertTextBefore()||!g.canInsertTextAfter()||Zr(t)&&(!t.canInsertTextBefore()||!t.canInsertTextAfter()))return this.insertText(""),ur(this.anchor,this.focus,null),void this.insertText(e)}if(1===f){if(d.isToken()){const t=Un(e);return t.select(),void d.replace(t)}const t=d.getFormat(),n=d.getStyle();if(c!==a||t===i&&n===o){if(Vn(d)){const t=Un(e);return t.setFormat(i),t.setStyle(o),t.select(),void d.replace(t)}}else{if(""!==d.getTextContent()){const t=Un(e);if(t.setFormat(i),t.setStyle(o),t.select(),0===c)d.insertBefore(t,!1);else{const[e]=d.splitText(c);e.insertAfter(t,!1)}return void(t.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=e.length))}d.setFormat(i),d.setStyle(o)}const r=a-c;d=d.spliceText(c,r,e,!0),""===d.getTextContent()?d.remove():"text"===this.anchor.type&&(d.isComposing()?this.anchor.offset-=e.length:(this.format=t,this.style=n))}else{const t=new Set([...d.getParentKeys(),..._.getParentKeys()]),n=Zr(d)?d:d.getParentOrThrow();let r=Zr(_)?_:_.getParentOrThrow(),i=_;if(!n.is(r)&&r.isInline())do{i=r,r=r.getParentOrThrow()}while(r.isInline());if("text"===l.type&&(0!==a||""===_.getTextContent())||"element"===l.type&&_.getIndexWithinParent()<a)if(Yn(_)&&!_.isToken()&&a!==_.getTextContentSize()){if(_.isSegmented()){const t=Un(_.getTextContent());_.replace(t),_=t}ii(l.getNode())||"text"!==l.type||(_=_.spliceText(0,a,"")),t.add(_.__key)}else{const t=_.getParentOrThrow();t.canBeEmpty()||1!==t.getChildrenSize()?_.remove():t.remove()}else t.add(_.__key);const o=r.getChildren(),s=new Set(u),g=n.is(r),p=n.isInline()&&null===d.getNextSibling()?n:d;for(let t=o.length-1;t>=0;t--){const e=o[t];if(e.is(d)||Zr(e)&&e.isParentOf(d))break;e.isAttached()&&(!s.has(e)||e.is(i)?g||p.insertAfter(e,!1):e.remove())}if(!g){let e=r,n=null;for(;null!==e;){const r=e.getChildren(),i=r.length;(0===i||r[i-1].is(n))&&(t.delete(e.__key),n=e),e=e.getParent()}}if(d.isToken())if(c===h)d.select();else{const t=Un(e);t.select(),d.replace(t)}else d=d.spliceText(c,h-c,e,!0),""===d.getTextContent()?d.remove():d.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=e.length);for(let e=1;e<f;e++){const n=u[e],r=n.__key;t.has(r)||n.remove()}}}removeText(){const t=pr()===this;bs(this,Ds(Ms(this))),t&&pr()!==this&&Ji(this)}formatText(t,e=null){if(this.isCollapsed())return this.toggleFormat(t),void Li(null);const n=this.getNodes(),r=[];for(const t of n)Yn(t)&&r.push(t);const i=e=>{n.forEach((n=>{if(Zr(n)){const r=n.getFormatFlags(t,e);n.setTextFormat(r)}}))},o=r.length;if(0===o)return this.toggleFormat(t),Li(null),void i(e);const s=this.anchor,l=this.focus,c=this.isBackward(),a=c?l:s,u=c?s:l;let f=0,d=r[0],h="element"===a.type?0:a.offset;if("text"===a.type&&h===d.getTextContentSize()&&(f=1,d=r[1],h=0),null==d)return;const g=d.getFormatFlags(t,e);i(g);const _=o-1;let p=r[_];const y="text"===u.type?u.offset:p.getTextContentSize();if(d.is(p)){if(h===y)return;if(bi(d)||0===h&&y===d.getTextContentSize())d.setFormat(g);else{const t=d.splitText(h,y),e=0===h?t[0]:t[1];e.setFormat(g),"text"===a.type&&a.set(e.__key,0,"text"),"text"===u.type&&u.set(e.__key,y-h,"text")}return void(this.format=g)}0===h||bi(d)||([,d]=d.splitText(h),h=0),d.setFormat(g);const m=p.getFormatFlags(t,g);y>0&&(y===p.getTextContentSize()||bi(p)||([p]=p.splitText(y)),p.setFormat(m));for(let e=f+1;e<_;e++){const n=r[e],i=n.getFormatFlags(t,m);n.setFormat(i)}"text"===a.type&&a.set(d.__key,h,"text"),"text"===u.type&&u.set(p.__key,y,"text"),this.format=g|m}insertNodes(e){if(0===e.length)return;if(this.isCollapsed()||this.removeText(),"root"===this.anchor.key){this.insertParagraph();const n=pr();return tr(n)||t(134),n.insertNodes(e)}const n=(this.isBackward()?this.focus:this.anchor).getNode(),r=Bo(n,Ko),i=e[e.length-1];if(Zr(r)&&"__language"in r){if("__language"in e[0])this.insertText(e[0].getTextContent());else{const t=vr(this);r.splice(t,0,e),i.selectEnd()}return}if(!e.some((t=>(Zr(t)||ni(t))&&!t.isInline()))){Zr(r)||t(211,n.constructor.name,n.getType());const o=vr(this);return r.splice(o,0,e),void i.selectEnd()}const o=function(t){const e=pi();let n=null;for(let r=0;r<t.length;r++){const i=t[r],o=En(i);if(o||ni(i)&&i.isInline()||Zr(i)&&i.isInline()||Yn(i)||i.isParentRequired()){if(null===n&&(n=i.createParentElementNode(),e.append(n),o))continue;null!==n&&n.append(i)}else e.append(i),n=null}return e}(e),s=o.getLastDescendant(),l=o.getChildren(),c=!Zr(r)||!r.isEmpty()?this.insertParagraph():null,a=l[l.length-1];let u=l[0];var f;Zr(f=u)&&Ko(f)&&!f.isEmpty()&&Zr(r)&&(!r.isEmpty()||r.canMergeWhenEmpty())&&(Zr(r)||t(211,n.constructor.name,n.getType()),r.append(...u.getChildren()),u=l[1]),u&&(null===r&&t(212,n.constructor.name,n.getType()),function(e,n,r){const i=n.getParentOrThrow().getLastChild();let o=n;const s=[n];for(;o!==i;)o.getNextSibling()||t(140),o=o.getNextSibling(),s.push(o);let l=e;for(const t of s)l=l.insertAfter(t)}(r,u));const d=Bo(s,Ko);c&&Zr(d)&&(c.canMergeWhenEmpty()||Ko(a))&&(d.append(...c.getChildren()),c.remove()),Zr(r)&&r.isEmpty()&&r.remove(),s.selectEnd();const h=Zr(r)?r.getLastChild():null;En(h)&&d!==r&&h.remove()}insertParagraph(){if("root"===this.anchor.key){const t=pi();return Ui().splice(this.anchor.offset,0,[t]),t.select(),t}const e=vr(this),n=Bo(this.anchor.getNode(),Ko);Zr(n)||t(213);const r=n.getChildAtIndex(e),i=r?[r,...r.getNextSiblings()]:[],o=n.insertNewAfter(this,!1);return o?(o.append(...i),o.selectStart(),o):null}insertLineBreak(t){const e=kn();if(this.insertNodes([e]),t){const t=e.getParentOrThrow(),n=e.getIndexWithinParent();t.select(n,n)}}extract(){const t=this.getNodes(),e=t.length,n=e-1,r=this.anchor,i=this.focus;let o=t[0],s=t[n];const[l,c]=ir(this);if(0===e)return[];if(1===e){if(Yn(o)&&!this.isCollapsed()){const t=l>c?c:l,e=l>c?l:c,n=o.splitText(t,e),r=0===t?n[0]:n[1];return null!=r?[r]:[]}return[o]}const a=r.isBefore(i);if(Yn(o)){const e=a?l:c;e===o.getTextContentSize()?t.shift():0!==e&&([,o]=o.splitText(e),t[0]=o)}if(Yn(s)){const e=s.getTextContent().length,r=a?c:l;0===r?t.pop():r!==e&&([s]=s.splitText(r),t[n]=s)}return t}modify(t,e,n){if(Er(this,t,e,n))return;const r="move"===t,i=Rr(),o=wo(To(i));if(!o)return;const s=i._blockCursorElement,l=i._rootElement,c=this.focus.getNode();if(null===l||null===s||!Zr(c)||c.isInline()||c.canBeEmpty()||Ao(s,i,l),this.dirty){let t=_o(i,this.anchor.key),e=_o(i,this.focus.key);"text"===this.anchor.type&&(t=Ai(t)),"text"===this.focus.type&&(e=Ai(e)),t&&e&&Tr(o,t,this.anchor.offset,e,this.focus.offset)}if(function(t,e,n,r){t.modify(e,n,r)}(o,t,e?"backward":"forward",n),o.rangeCount>0){const t=o.getRangeAt(0),n=this.anchor.getNode(),i=ii(n)?n:No(n);if(this.applyDOMRange(t),this.dirty=!0,!r){const n=this.getNodes(),r=[];let s=!1;for(let t=0;t<n.length;t++){const e=n[t];Co(e,i)?r.push(e):s=!0}if(s&&r.length>0)if(e){const t=r[0];Zr(t)?t.selectStart():t.getParentOrThrow().selectStart()}else{const t=r[r.length-1];Zr(t)?t.selectEnd():t.getParentOrThrow().selectEnd()}o.anchorNode===t.startContainer&&o.anchorOffset===t.startOffset||function(t){const e=t.focus,n=t.anchor,r=n.key,i=n.offset,o=n.type;n.set(e.key,e.offset,e.type,!0),e.set(r,i,o,!0)}(this)}}"lineboundary"===n&&Er(this,t,e,n,"decorators")}forwardDeletion(t,e,n){if(!n&&("element"===t.type&&Zr(e)&&t.offset===e.getChildrenSize()||"text"===t.type&&t.offset===e.getTextContentSize())){const t=e.getParent(),n=e.getNextSibling()||(null===t?null:t.getNextSibling());if(Zr(n)&&n.isShadowRoot())return!0}return!1}deleteCharacter(t){const e=this.isCollapsed();if(this.isCollapsed()){const e=this.anchor;let n=e.getNode();if(this.forwardDeletion(e,n,t))return;const r=_s(vs(e,t?"previous":"next"));if(r.getTextSlices().every((t=>null===t||0===t.distance))){let t={type:"initial"};for(const e of r.iterNodeCarets("shadowRoot"))if(ns(e))if(e.origin.isInline());else{if(e.origin.isShadowRoot()){if("merge-block"===t.type)break;if(Zr(r.anchor.origin)&&r.anchor.origin.isEmpty()){const t=Ps(e);bs(this,ys(t,t)),r.anchor.origin.remove()}return}"merge-next-block"!==t.type&&"merge-block"!==t.type||(t={block:t.block,caret:e,type:"merge-block"})}else{if("merge-block"===t.type)break;if(es(e)){if(Zr(e.origin)){if(e.origin.isInline()){if(!e.origin.isParentOf(r.anchor.origin))break}else t={block:e.origin,type:"merge-next-block"};continue}if(ni(e.origin)){if(e.origin.isIsolated());else if("merge-next-block"===t.type&&(e.origin.isKeyboardSelectable()||!e.origin.isInline())&&Zr(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();const t=gr();t.add(e.origin.getKey()),Ji(t)}else e.origin.remove();return}break}}if("merge-block"===t.type){const{caret:e,block:n}=t;return bs(this,ys(!e.origin.isEmpty()&&n.isEmpty()?Os(ss(n,e.direction)):r.anchor,e)),this.removeText()}}const i=this.focus;if(this.modify("extend",t,"character"),this.isCollapsed()){if(t&&0===e.offset&&or(this,e.getNode()))return}else{const r="text"===i.type?i.getNode():null;if(n="text"===e.type?e.getNode():null,null!==r&&r.isSegmented()){const e=i.offset,o=r.getTextContentSize();if(r.is(n)||t&&e!==o||!t&&0!==e)return void lr(r,t,e)}else if(null!==n&&n.isSegmented()){const i=e.offset,o=n.getTextContentSize();if(n.is(r)||t&&0!==i||!t&&i!==o)return void lr(n,t,i)}!function(t,e){const n=t.anchor,r=t.focus,i=n.getNode(),o=r.getNode();if(i===o&&"text"===n.type&&"text"===r.type){const t=n.offset,o=r.offset,s=t<o,l=s?t:o,c=s?o:t,a=c-1;if(l!==a){(function(t){return!(Vi(t)||sr(t))})(i.getTextContent().slice(l,c))&&(e?r.set(r.key,a,r.type):n.set(n.key,a,n.type))}}}(this,t)}}if(this.removeText(),t&&!e&&this.isCollapsed()&&"element"===this.anchor.type&&0===this.anchor.offset){const t=this.anchor.getNode();t.isEmpty()&&ii(t.getParent())&&null===t.getPreviousSibling()&&or(this,t)}}deleteLine(t){this.isCollapsed()&&this.modify("extend",t,"lineboundary"),this.isCollapsed()?this.deleteCharacter(t):this.removeText()}deleteWord(t){if(this.isCollapsed()){const e=this.anchor,n=e.getNode();if(this.forwardDeletion(e,n,t))return;this.modify("extend",t,"word")}this.removeText()}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return[this.anchor,this.focus]}}function nr(t){return t instanceof Zn}function rr(t){const e=t.offset;if("text"===t.type)return e;const n=t.getNode();return e===n.getChildrenSize()?n.getTextContent().length:0}function ir(t){const e=t.getStartEndPoints();if(null===e)return[0,0];const[n,r]=e;return"element"===n.type&&"element"===r.type&&n.key===r.key&&n.offset===r.offset?[0,0]:[rr(n),rr(r)]}function or(t,e){for(let n=e;n;n=n.getParent()){if(Zr(n)){if(n.collapseAtStart(t))return!0;if(vo(n))break}if(n.getPreviousSibling())break}return!1}const sr=(()=>{try{const t=new RegExp("\\p{Emoji}","u"),e=t.test.bind(t);if(e("❤️")&&e("#️⃣")&&e("👍"))return e}catch(t){}return()=>!1})();function lr(t,e,n){const r=t,i=r.getTextContent().split(/(?=\s)/g),o=i.length;let s=0,l=0;for(let t=0;t<o;t++){const r=t===o-1;if(l=s,s+=i[t].length,e&&s===n||s>n||r){i.splice(t,1),r&&(l=void 0);break}}const c=i.join("").trim();""===c?r.remove():(r.setTextContent(c),r.select(l,l))}function cr(e,n,r,i){let o,s=n;if(Po(e)){let l=!1;const c=e.childNodes,a=c.length,u=i._blockCursorElement;s===a&&(l=!0,s=a-1);let f=c[s],d=!1;if(f===u)f=c[s+1],d=!0;else if(null!==u){const t=u.parentNode;if(e===t){n>Array.prototype.indexOf.call(t.children,u)&&s--}}if(o=Hi(f),Yn(o))s=ji(o,l);else{let c=Hi(e);if(null===c)return null;if(Zr(c)){const a=i.getElementByKey(c.getKey());null===a&&t(214);const u=c.getDOMSlot(a);[c,s]=u.resolveChildIndex(c,a,e,n),Zr(c)||t(215),l&&s>=c.getChildrenSize()&&(s=Math.max(0,c.getChildrenSize()-1));let f=c.getChildAtIndex(s);if(Zr(f)&&function(t,e,n){const r=t.getParent();return null===n||null===r||!r.canBeEmpty()||r!==n.getNode()}(f,0,r)){const t=l?f.getLastDescendant():f.getFirstDescendant();null===t?c=f:(f=t,c=Zr(f)?f:f.getParentOrThrow()),s=0}Yn(f)?(o=f,c=null,s=ji(f,l)):f!==c&&l&&!d&&(Zr(c)||t(216),s=Math.min(c.getChildrenSize(),s+1))}else{const t=c.getIndexWithinParent();s=0===n&&ni(c)&&Hi(e)===c?t:t+1,c=c.getParentOrThrow()}if(Zr(c))return qn(c.__key,s,"element")}}else o=Hi(e);return Yn(o)?qn(o.__key,s,"text"):null}function ar(t,e,n){const r=t.offset,i=t.getNode();if(0===r){const r=i.getPreviousSibling(),o=i.getParent();if(e){if((n||!e)&&null===r&&Zr(o)&&o.isInline()){const e=o.getPreviousSibling();Yn(e)&&t.set(e.__key,e.getTextContent().length,"text")}}else Zr(r)&&!n&&r.isInline()?t.set(r.__key,r.getChildrenSize(),"element"):Yn(r)&&t.set(r.__key,r.getTextContent().length,"text")}else if(r===i.getTextContent().length){const r=i.getNextSibling(),o=i.getParent();if(e&&Zr(r)&&r.isInline())t.set(r.__key,0,"element");else if((n||e)&&null===r&&Zr(o)&&o.isInline()&&!o.canInsertTextAfter()){const e=o.getNextSibling();Yn(e)&&t.set(e.__key,0,"text")}}}function ur(t,e,n){if("text"===t.type&&"text"===e.type){const r=t.isBefore(e),i=t.is(e);ar(t,r,i),ar(e,!r,i),i&&e.set(t.key,t.offset,t.type);const o=Rr();if(o.isComposing()&&o._compositionKey!==t.key&&tr(n)){const r=n.anchor,i=n.focus;t.set(r.key,r.offset,r.type,!0),e.set(i.key,i.offset,i.type,!0)}}}function fr(t,e,n,r,i,o){if(null===t||null===n||!Ni(i,t,n))return null;const s=cr(t,e,tr(o)?o.anchor:null,i);if(null===s)return null;const l=cr(n,r,tr(o)?o.focus:null,i);if(null===l)return null;if("element"===s.type&&"element"===l.type){const e=Hi(t),r=Hi(n);if(ni(e)&&ni(r))return null}return ur(s,l,o),[s,l]}function dr(t,e,n,r,i,o){const s=Fr(),l=new er(qn(t,e,i),qn(n,r,o),0,"");return l.dirty=!0,s._selection=l,l}function hr(){const t=qn("root",0,"element"),e=qn("root",0,"element");return new er(t,e,0,"")}function gr(){return new Zn(new Set)}function _r(t,e,n,r){const i=n._window;if(null===i)return null;const o=r||i.event,s=o?o.type:void 0,l="selectionchange"===s,c=!G&&(l||"beforeinput"===s||"compositionstart"===s||"compositionend"===s||"click"===s&&o&&3===o.detail||"drop"===s||void 0===s);let a,u,f,d;if(tr(t)&&!c)return t.clone();if(null===e)return null;if(a=e.anchorNode,u=e.focusNode,f=e.anchorOffset,d=e.focusOffset,l&&tr(t)&&!Ni(n,a,u))return t.clone();const h=fr(a,f,u,d,n,t);if(null===h)return null;const[g,_]=h;return new er(g,_,tr(t)?t.format:0,tr(t)?t.style:"")}function pr(){return Fr()._selection}function yr(){return Rr()._editorState._selection}function mr(t,e,n,r=1){const i=t.anchor,o=t.focus,s=i.getNode(),l=o.getNode();if(!e.is(s)&&!e.is(l))return;const c=e.__key;if(t.isCollapsed()){const e=i.offset;if(n<=e&&r>0||n<e&&r<0){const n=Math.max(0,e+r);i.set(c,n,"element"),o.set(c,n,"element"),xr(t)}}else{const s=t.isBackward(),l=s?o:i,a=l.getNode(),u=s?i:o,f=u.getNode();if(e.is(a)){const t=l.offset;(n<=t&&r>0||n<t&&r<0)&&l.set(c,Math.max(0,t+r),"element")}if(e.is(f)){const t=u.offset;(n<=t&&r>0||n<t&&r<0)&&u.set(c,Math.max(0,t+r),"element")}}xr(t)}function xr(t){const e=t.anchor,n=e.offset,r=t.focus,i=r.offset,o=e.getNode(),s=r.getNode();if(t.isCollapsed()){if(!Zr(o))return;const t=o.getChildrenSize(),i=n>=t,s=i?o.getChildAtIndex(t-1):o.getChildAtIndex(n);if(Yn(s)){let t=0;i&&(t=s.getTextContentSize()),e.set(s.__key,t,"text"),r.set(s.__key,t,"text")}}else{if(Zr(o)){const t=o.getChildrenSize(),r=n>=t,i=r?o.getChildAtIndex(t-1):o.getChildAtIndex(n);if(Yn(i)){let t=0;r&&(t=i.getTextContentSize()),e.set(i.__key,t,"text")}}if(Zr(s)){const t=s.getChildrenSize(),e=i>=t,n=e?s.getChildAtIndex(t-1):s.getChildAtIndex(i);if(Yn(n)){let t=0;e&&(t=n.getTextContentSize()),r.set(n.__key,t,"text")}}}}function Cr(t,e,n,r,i){let o=null,s=0,l=null;null!==r?(o=r.__key,Yn(r)?(s=r.getTextContentSize(),l="text"):Zr(r)&&(s=r.getChildrenSize(),l="element")):null!==i&&(o=i.__key,Yn(i)?l="text":Zr(i)&&(l="element")),null!==o&&null!==l?t.set(o,s,l):(s=e.getIndexWithinParent(),-1===s&&(s=n.getChildrenSize()),t.set(n.__key,s,"element"))}function Sr(t,e,n,r,i){"text"===t.type?t.set(n,t.offset+(e?0:i),"text"):t.offset>r.getIndexWithinParent()&&t.set(t.key,t.offset-1,"element")}function Tr(t,e,n,r,i){try{t.setBaseAndExtent(e,n,r,i)}catch(t){}}function Nr(t,e,n,r,i,o,s){const l=r.anchorNode,c=r.focusNode,a=r.anchorOffset,u=r.focusOffset,f=document.activeElement;if(i.has(ui)&&f!==o||null!==f&&Ti(f))return;if(!tr(e))return void(null!==t&&Ni(n,l,c)&&r.removeAllRanges());const d=e.anchor,h=e.focus,g=d.key,_=h.key,p=_o(n,g),y=_o(n,_),m=d.offset,x=h.offset,C=e.format,S=e.style,T=e.isCollapsed();let N=p,v=y,k=!1;if("text"===d.type){N=Ai(p);const t=d.getNode();k=t.getFormat()!==C||t.getStyle()!==S}else tr(t)&&"text"===t.anchor.type&&(k=!0);var E,b,M,O,A;if(("text"===h.type&&(v=Ai(y)),null!==N&&null!==v)&&(T&&(null===t||k||tr(t)&&(t.format!==C||t.style!==S))&&(E=C,b=S,M=m,O=g,A=performance.now(),sn=[E,b,M,O,A]),a!==m||u!==x||l!==N||c!==v||"Range"===r.type&&T||(null!==f&&o.contains(f)||o.focus({preventScroll:!0}),"element"===d.type))){if(Tr(r,N,m,v,x),!i.has(fi)&&e.isCollapsed()&&null!==o&&o===document.activeElement){const t=tr(e)&&"element"===e.anchor.type?N.childNodes[m]||null:r.rangeCount>0?r.getRangeAt(0):null;if(null!==t){let e;if(t instanceof Text){const n=document.createRange();n.selectNode(t),e=n.getBoundingClientRect()}else e=t.getBoundingClientRect();!function(t,e,n){const r=yo(n),i=So(r);if(null===r||null===i)return;let{top:o,bottom:s}=e,l=0,c=0,a=n;for(;null!==a;){const e=a===r.body;if(e)l=0,c=To(t).innerHeight;else{const t=a.getBoundingClientRect();l=t.top,c=t.bottom}let n=0;if(o<l?n=-(l-o):s>c&&(n=s-c),0!==n)if(e)i.scrollBy(0,n);else{const t=a.scrollTop;a.scrollTop+=n;const e=a.scrollTop-t;o-=e,s-=e}if(e)break;a=po(a)}}(n,e,o)}}Qe=!0}}function vr(e){let n=e;e.isCollapsed()||n.removeText();const r=pr();tr(r)&&(n=r),tr(n)||t(161);const i=n.anchor;let o=i.getNode(),s=i.offset;for(;!Ko(o);){const t=o;if([o,s]=kr(o,s),t.is(o))break}return s}function kr(t,e){const n=t.getParent();if(!n){const t=pi();return Ui().append(t),t.select(),[Ui(),0]}if(Yn(t)){const r=t.splitText(e);if(0===r.length)return[n,t.getIndexWithinParent()];const i=0===e?0:1;return[n,r[0].getIndexWithinParent()+i]}if(!Zr(t)||0===e)return[n,t.getIndexWithinParent()];const r=t.getChildAtIndex(e);if(r){const n=new er(qn(t.__key,e,"element"),qn(t.__key,e,"element"),0,""),i=t.insertNewAfter(n);i&&i.append(r,...r.getNextSiblings())}return[n,t.getIndexWithinParent()+1]}function Er(t,e,n,r,i="decorators-and-blocks"){if("move"===e&&"character"===r&&!t.isCollapsed()){const[e,r]=n===t.isBackward()?[t.focus,t.anchor]:[t.anchor,t.focus];return r.set(e.key,e.offset,e.type),!0}const o=vs(t.focus,n?"previous":"next"),s="lineboundary"===r,l="move"===e;let c=o,a="decorators-and-blocks"===i;if(!Is(c)){for(const t of c){a=!1;const{origin:e}=t;if(!ni(e)||e.isIsolated()||(c=t,!s||!e.isInline()))break}if(a)for(const t of _s(o).iterNodeCarets("extend"===e?"shadowRoot":"root")){if(ns(t))t.origin.isInline()||(c=t);else{if(Zr(t.origin))continue;ni(t.origin)&&!t.origin.isInline()&&(c=t)}break}}if(c===o)return!1;if(l&&!s&&ni(c.origin)&&c.origin.isKeyboardSelectable()){const t=gr();return t.add(c.origin.getKey()),Ji(t),!0}return c=Ps(c),l&&ks(t.anchor,c),ks(t.focus,c),a||!s}let br=null,Mr=null,Or=!1,Ar=!1,wr=0;const Dr={characterData:!0,childList:!0,subtree:!0};function Pr(){return Or||null!==br&&br._readOnly}function Ir(){Or&&t(13)}function Lr(){wr>99&&t(14)}function Fr(){return null===br&&t(195,Kr()),br}function Rr(){return null===Mr&&t(196,Kr()),Mr}function Kr(){let t=0;const e=new Set,n=mi.version;if("undefined"!=typeof window)for(const r of document.querySelectorAll("[contenteditable]")){const i=Ei(r);if(vi(i))t++;else if(i){let t=String(i.constructor.version||"<0.17.1");t===n&&(t+=" (separately built, likely a bundler configuration issue)"),e.add(t)}}let r=` Detected on the page: ${t} compatible editor(s) with version ${n}`;return e.size&&(r+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),r}function Br(){return Mr}function zr(e,n,r){const i=n.__type,o=function(e,n){const r=e._nodes.get(n);void 0===r&&t(30,n);return r}(e,i);let s=r.get(i);void 0===s&&(s=Array.from(o.transforms),r.set(i,s));const l=s.length;for(let t=0;t<l&&(s[t](n),n.isAttached());t++);}function Wr(t,e){return void 0!==t&&t.__key!==e&&t.isAttached()}function $r(t,e){if(!e)return;const n=t._updateTags;let r=e;Array.isArray(e)||(r=[e]);for(const t of r)n.add(t)}function Ur(e,n){const r=e.type,i=n.get(r);void 0===i&&t(17,r);const o=i.klass;e.type!==o.getType()&&t(18,o.name);const s=o.importJSON(e),l=e.children;if(Zr(s)&&Array.isArray(l))for(let t=0;t<l.length;t++){const e=Ur(l[t],n);s.append(e)}return s}function Yr(t,e,n){const r=br,i=Or,o=Mr;br=e,Or=!0,Mr=t;try{return n()}finally{br=r,Or=i,Mr=o}}function Jr(t,e){const n=t._pendingEditorState,r=t._rootElement,i=t._headless||null===r;if(null===n)return;const o=t._editorState,s=o._selection,l=n._selection,c=t._dirtyType!==y,a=br,u=Or,f=Mr,h=t._updating,g=t._observer;let _=null;if(t._pendingEditorState=null,t._editorState=n,!i&&c&&null!==g){Mr=t,br=n,Or=!1,t._updating=!0;try{const e=t._dirtyType,r=t._dirtyElements,i=t._dirtyLeaves;g.disconnect(),_=qt(o,n,t,e,r,i)}catch(e){if(e instanceof Error&&t._onError(e),Ar)throw e;return yi(t,null,r,n),it(t),t._dirtyType=x,Ar=!0,Jr(t,o),void(Ar=!1)}finally{g.observe(r,Dr),t._updating=h,br=a,Or=u,Mr=f}}n._readOnly||(n._readOnly=!0);const p=t._dirtyLeaves,m=t._dirtyElements,C=t._normalizedNodes,S=t._updateTags,T=t._deferred;c&&(t._dirtyType=y,t._cloneNotNeeded.clear(),t._dirtyLeaves=new Set,t._dirtyElements=new Map,t._normalizedNodes=new Set,t._updateTags=new Set),function(t,e){const n=t._decorators;let r=t._pendingDecorators||n;const i=e._nodeMap;let o;for(o in r)i.has(o)||(r===n&&(r=Wi(t)),delete r[o])}(t,n);const N=i?null:wo(To(t));if(t._editable&&null!==N&&(c||null===l||l.dirty)&&null!==r&&!S.has(di)){Mr=t,br=n;try{if(null!==g&&g.disconnect(),c||null===l||l.dirty){const e=t._blockCursorElement;null!==e&&Ao(e,t,r),Nr(s,l,t,N,S,r)}!function(t,e,n){let r=t._blockCursorElement;if(tr(n)&&n.isCollapsed()&&"element"===n.anchor.type&&e.contains(document.activeElement)){const i=n.anchor,o=i.getNode(),s=i.offset;let l=!1,c=null;if(s===o.getChildrenSize()){Oo(o.getChildAtIndex(s-1))&&(l=!0)}else{const e=o.getChildAtIndex(s);if(null!==e&&Oo(e)){const n=e.getPreviousSibling();(null===n||Oo(n))&&(l=!0,c=t.getElementByKey(e.__key))}}if(l){const n=t.getElementByKey(o.__key);return null===r&&(t._blockCursorElement=r=function(t){const e=t.theme,n=document.createElement("div");n.contentEditable="false",n.setAttribute("data-lexical-cursor","true");let r=e.blockCursor;if(void 0!==r){if("string"==typeof r){const t=d(r);r=e.blockCursor=t}void 0!==r&&n.classList.add(...r)}return n}(t._config)),e.style.caretColor="transparent",void(null===c?n.appendChild(r):n.insertBefore(r,c))}}null!==r&&Ao(r,t,e)}(t,r,l)}finally{null!==g&&g.observe(r,Dr),Mr=f,br=a}}null!==_&&function(t,e,n,r,i){const o=Array.from(t._listeners.mutation),s=o.length;for(let t=0;t<s;t++){const[s,l]=o[t],c=e.get(l);void 0!==c&&s(c,{dirtyLeaves:r,prevEditorState:i,updateTags:n})}}(t,_,S,p,o),tr(l)||null===l||null!==s&&s.is(l)||t.dispatchCommand(Zt,void 0);const v=t._pendingDecorators;null!==v&&(t._decorators=v,t._pendingDecorators=null,Hr("decorator",t,!0,v)),function(t,e,n){const r=$i(e),i=$i(n);r!==i&&Hr("textcontent",t,!0,i)}(t,e||o,n),Hr("update",t,!0,{dirtyElements:m,dirtyLeaves:p,editorState:n,mutatedNodes:_,normalizedNodes:C,prevEditorState:e||o,tags:S}),function(t,e){if(t._deferred=[],0!==e.length){const n=t._updating;t._updating=!0;try{for(let t=0;t<e.length;t++)e[t]()}finally{t._updating=n}}}(t,T),function(t){const e=t._updates;if(0!==e.length){const n=e.shift();if(n){const[e,r]=n;Vr(t,e,r)}}}(t)}function Hr(t,e,n,...r){const i=e._updating;e._updating=n;try{const n=Array.from(e._listeners[t]);for(let t=0;t<n.length;t++)n[t].apply(null,r)}finally{e._updating=i}}function jr(e,n){const r=e._updates;let i=n||!1;for(;0!==r.length;){const n=r.shift();if(n){const[r,o]=n;let s;if(void 0!==o){if(s=o.onUpdate,o.skipTransforms&&(i=!0),o.discrete){const n=e._pendingEditorState;null===n&&t(191),n._flushSync=!0}s&&e._deferred.push(s),$r(e,o.tag)}r()}}return i}function Vr(e,n,r){const i=e._updateTags;let o,s=!1,l=!1;void 0!==r&&(o=r.onUpdate,$r(e,r.tag),s=r.skipTransforms||!1,l=r.discrete||!1),o&&e._deferred.push(o);const c=e._editorState;let a=e._pendingEditorState,u=!1;(null===a||a._readOnly)&&(a=e._pendingEditorState=oi(a||c),u=!0),a._flushSync=l;const f=br,d=Or,h=Mr,g=e._updating;br=a,Or=!1,e._updating=!0,Mr=e;const _=e._headless||null===e.getRootElement();try{u&&(_?null!==c._selection&&(a._selection=c._selection.clone()):a._selection=function(t,e){const n=t.getEditorState()._selection,r=wo(To(t));return tr(n)||null==n?_r(n,r,t,e):n.clone()}(e,r&&r.event||null));const i=e._compositionKey;n(),s=jr(e,s),function(t,e){const n=e.getEditorState()._selection,r=t._selection;if(tr(r)){const t=r.anchor,e=r.focus;let i;if("text"===t.type&&(i=t.getNode(),i.selectionTransform(n,r)),"text"===e.type){const t=e.getNode();i!==t&&t.selectionTransform(n,r)}}}(a,e),e._dirtyType!==y&&(s?function(t,e){const n=e._dirtyLeaves,r=t._nodeMap;for(const t of n){const e=r.get(t);Yn(e)&&e.isAttached()&&e.isSimpleText()&&!e.isUnmergeable()&&ht(e)}}(a,e):function(t,e){const n=e._dirtyLeaves,r=e._dirtyElements,i=t._nodeMap,o=Fi(),s=new Map;let l=n,c=l.size,a=r,u=a.size;for(;c>0||u>0;){if(c>0){e._dirtyLeaves=new Set;for(const t of l){const r=i.get(t);Yn(r)&&r.isAttached()&&r.isSimpleText()&&!r.isUnmergeable()&&ht(r),void 0!==r&&Wr(r,o)&&zr(e,r,s),n.add(t)}if(l=e._dirtyLeaves,c=l.size,c>0){wr++;continue}}e._dirtyLeaves=new Set,e._dirtyElements=new Map,a.delete("root")&&a.set("root",!0);for(const t of a){const n=t[0],l=t[1];if(r.set(n,l),!l)continue;const c=i.get(n);void 0!==c&&Wr(c,o)&&zr(e,c,s)}l=e._dirtyLeaves,c=l.size,a=e._dirtyElements,u=a.size,wr++}e._dirtyLeaves=n,e._dirtyElements=r}(a,e),jr(e),function(t,e,n,r){const i=t._nodeMap,o=e._nodeMap,s=[];for(const[t]of r){const e=o.get(t);void 0!==e&&(e.isAttached()||(Zr(e)&&j(e,t,i,o,s,r),i.has(t)||r.delete(t),s.push(t)))}for(const t of s)o.delete(t);for(const t of n){const e=o.get(t);void 0===e||e.isAttached()||(i.has(t)||n.delete(t),o.delete(t))}}(c,a,e._dirtyLeaves,e._dirtyElements));i!==e._compositionKey&&(a._flushSync=!0);const o=a._selection;if(tr(o)){const e=a._nodeMap,n=o.anchor.key,r=o.focus.key;void 0!==e.get(n)&&void 0!==e.get(r)||t(19)}else nr(o)&&0===o._nodes.size&&(a._selection=null)}catch(t){return t instanceof Error&&e._onError(t),e._pendingEditorState=c,e._dirtyType=x,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),void Jr(e)}finally{br=f,Or=d,Mr=h,e._updating=g,wr=0}const p=e._dirtyType!==y||e._deferred.length>0||function(t,e){const n=e.getEditorState()._selection,r=t._selection;if(null!==r){if(r.dirty||!r.is(n))return!0}else if(null!==n)return!0;return!1}(a,e);p?a._flushSync?(a._flushSync=!1,Jr(e)):u&&Ci((()=>{Jr(e)})):(a._flushSync=!1,u&&(i.clear(),e._deferred=[],e._pendingEditorState=null))}function Gr(t,e,n){Mr===t&&void 0===n?e():Vr(t,e,n)}class qr{constructor(t,e,n){this.element=t,this.before=e||null,this.after=n||null}withBefore(t){return new qr(this.element,t,this.after)}withAfter(t){return new qr(this.element,this.before,t)}withElement(t){return this.element===t?this:new qr(t,this.before,this.after)}insertChild(e){const n=this.before||this.getManagedLineBreak();return null!==n&&n.parentElement!==this.element&&t(222),this.element.insertBefore(e,n),this}removeChild(e){return e.parentElement!==this.element&&t(223),this.element.removeChild(e),this}replaceChild(e,n){return n.parentElement!==this.element&&t(224),this.element.replaceChild(e,n),this}getFirstChild(){const t=this.after?this.after.nextSibling:this.element.firstChild;return t===this.before||t===this.getManagedLineBreak()?null:t}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(t){if(null===t)this.removeManagedLineBreak();else{const e="decorator"===t&&(l||s);this.insertManagedLineBreak(e)}}removeManagedLineBreak(){const t=this.getManagedLineBreak();if(t){const e=this.element,n="IMG"===t.nodeName?t.nextSibling:null;n&&e.removeChild(n),e.removeChild(t),e.__lexicalLineBreak=void 0}}insertManagedLineBreak(t){const e=this.getManagedLineBreak();if(e){if(t===("IMG"===e.nodeName))return;this.removeManagedLineBreak()}const n=this.element,r=this.before,i=document.createElement("br");if(n.insertBefore(i,r),t){const t=document.createElement("img");t.setAttribute("data-lexical-linebreak","true"),t.style.cssText="display: inline !important; border: 0px !important; margin: 0px !important;",t.alt="",n.insertBefore(t,i),n.__lexicalLineBreak=t}else n.__lexicalLineBreak=i}getFirstChildOffset(){let t=0;for(let e=this.after;null!==e;e=e.previousSibling)t++;return t}resolveChildIndex(t,e,n,r){if(n===this.element){const e=this.getFirstChildOffset();return[t,Math.min(e+t.getChildrenSize(),Math.max(e,r))]}const i=Xr(e,n);i.push(r);const o=Xr(e,this.element);let s=t.getIndexWithinParent();for(let t=0;t<o.length;t++){const e=i[t],n=o[t];if(void 0===e||e<n)break;if(e>n){s+=1;break}}return[t.getParentOrThrow(),s]}}function Xr(e,n){const r=[];let i=n;for(;i!==e&&null!==i;i=i.parentNode){let t=0;for(let e=i.previousSibling;null!==e;e=e.previousSibling)t++;r.push(t)}return i!==e&&t(225),r.reverse()}class Qr extends Tn{constructor(t){super(t),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null,this.__textFormat=0,this.__textStyle=""}afterCloneFrom(t){super.afterCloneFrom(t),this.__first=t.__first,this.__last=t.__last,this.__size=t.__size,this.__indent=t.__indent,this.__format=t.__format,this.__style=t.__style,this.__dir=t.__dir,this.__textFormat=t.__textFormat,this.__textStyle=t.__textStyle}getFormat(){return this.getLatest().__format}getFormatType(){const t=this.getFormat();return U[t]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getChildrenKeys(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e.__key),e=e.getNextSibling();return t}getChildrenSize(){return this.getLatest().__size}isEmpty(){return 0===this.getChildrenSize()}isDirty(){const t=Rr()._dirtyElements;return null!==t&&t.has(this.__key)}isLastChild(){const t=this.getLatest(),e=this.getParentOrThrow().getLastChild();return null!==e&&e.is(t)}getAllTextNodes(){const t=[];let e=this.getFirstChild();for(;null!==e;){if(Yn(e)&&t.push(e),Zr(e)){const n=e.getAllTextNodes();t.push(...n)}e=e.getNextSibling()}return t}getFirstDescendant(){let t=this.getFirstChild();for(;Zr(t);){const e=t.getFirstChild();if(null===e)break;t=e}return t}getLastDescendant(){let t=this.getLastChild();for(;Zr(t);){const e=t.getLastChild();if(null===e)break;t=e}return t}getDescendantByIndex(t){const e=this.getChildren(),n=e.length;if(t>=n){const t=e[n-1];return Zr(t)&&t.getLastDescendant()||t||null}const r=e[t];return Zr(r)&&r.getFirstDescendant()||r||null}getFirstChild(){const t=this.getLatest().__first;return null===t?null:Ri(t)}getFirstChildOrThrow(){const e=this.getFirstChild();return null===e&&t(45,this.__key),e}getLastChild(){const t=this.getLatest().__last;return null===t?null:Ri(t)}getLastChildOrThrow(){const e=this.getLastChild();return null===e&&t(96,this.__key),e}getChildAtIndex(t){const e=this.getChildrenSize();let n,r;if(t<e/2){for(n=this.getFirstChild(),r=0;null!==n&&r<=t;){if(r===t)return n;n=n.getNextSibling(),r++}return null}for(n=this.getLastChild(),r=e-1;null!==n&&r>=t;){if(r===t)return n;n=n.getPreviousSibling(),r--}return null}getTextContent(){let t="";const e=this.getChildren(),n=e.length;for(let r=0;r<n;r++){const i=e[r];t+=i.getTextContent(),Zr(i)&&r!==n-1&&!i.isInline()&&(t+=I)}return t}getTextContentSize(){let t=0;const e=this.getChildren(),n=e.length;for(let r=0;r<n;r++){const i=e[r];t+=i.getTextContentSize(),Zr(i)&&r!==n-1&&!i.isInline()&&(t+=I.length)}return t}getDirection(){return this.getLatest().__dir}getTextFormat(){return this.getLatest().__textFormat}hasFormat(t){if(""!==t){const e=$[t];return!!(this.getFormat()&e)}return!1}hasTextFormat(t){const e=z[t];return!!(this.getTextFormat()&e)}getFormatFlags(t,e){return wi(this.getLatest().__textFormat,t,e)}getTextStyle(){return this.getLatest().__textStyle}select(t,e){Ir();const n=pr();let r=t,i=e;const o=this.getChildrenSize();if(!this.canBeEmpty())if(0===t&&0===e){const t=this.getFirstChild();if(Yn(t)||Zr(t))return t.select(0,0)}else if(!(void 0!==t&&t!==o||void 0!==e&&e!==o)){const t=this.getLastChild();if(Yn(t)||Zr(t))return t.select()}void 0===r&&(r=o),void 0===i&&(i=o);const s=this.__key;return tr(n)?(n.anchor.set(s,r,"element"),n.focus.set(s,i,"element"),n.dirty=!0,n):dr(s,r,s,i,"element","element")}selectStart(){const t=this.getFirstDescendant();return t?t.selectStart():this.select()}selectEnd(){const t=this.getLastDescendant();return t?t.selectEnd():this.select()}clear(){const t=this.getWritable();return this.getChildren().forEach((t=>t.remove())),t}append(...t){return this.splice(this.getChildrenSize(),0,t)}setDirection(t){const e=this.getWritable();return e.__dir=t,e}setFormat(t){return this.getWritable().__format=""!==t?$[t]:0,this}setStyle(t){return this.getWritable().__style=t||"",this}setTextFormat(t){const e=this.getWritable();return e.__textFormat=t,e}setTextStyle(t){const e=this.getWritable();return e.__textStyle=t,e}setIndent(t){return this.getWritable().__indent=t,this}splice(e,n,r){const i=r.length,o=this.getChildrenSize(),s=this.getWritable();e+n<=o||t(226,String(e),String(n),String(o));const l=s.__key,c=[],a=[],u=this.getChildAtIndex(e+n);let f=null,d=o-n+i;if(0!==e)if(e===o)f=this.getLastChild();else{const t=this.getChildAtIndex(e);null!==t&&(f=t.getPreviousSibling())}if(n>0){let e=null===f?this.getFirstChild():f.getNextSibling();for(let r=0;r<n;r++){null===e&&t(100);const n=e.getNextSibling(),r=e.__key;Pi(e.getWritable()),a.push(r),e=n}}let h=f;for(let e=0;e<i;e++){const n=r[e];null!==h&&n.is(h)&&(f=h=h.getPreviousSibling());const i=n.getWritable();i.__parent===l&&d--,Pi(i);const o=n.__key;if(null===h)s.__first=o,i.__prev=null;else{const t=h.getWritable();t.__next=o,i.__prev=t.__key}n.__key===l&&t(76),i.__parent=l,c.push(o),h=n}if(e+n===o){if(null!==h){h.getWritable().__next=null,s.__last=h.__key}}else if(null!==u){const t=u.getWritable();if(null!==h){const e=h.getWritable();t.__prev=h.__key,e.__next=u.__key}else t.__prev=null}if(s.__size=d,a.length){const t=pr();if(tr(t)){const e=new Set(a),n=new Set(c),{anchor:r,focus:i}=t;ti(r,e,n)&&Cr(r,r.getNode(),this,f,u),ti(i,e,n)&&Cr(i,i.getNode(),this,f,u),0!==d||this.canBeEmpty()||vo(this)||this.remove()}}return s}getDOMSlot(t){return new qr(t)}exportDOM(t){const{element:e}=super.exportDOM(t);if(Po(e)){const t=this.getIndent();t>0&&(e.style.paddingInlineStart=40*t+"px");const n=this.getDirection();n&&(e.dir=n)}return{element:e}}exportJSON(){const t={children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),...super.exportJSON()},e=this.getTextFormat(),n=this.getTextStyle();return 0!==e&&(t.textFormat=e),""!==n&&(t.textStyle=n),t}updateFromJSON(t){return super.updateFromJSON(t).setFormat(t.format).setIndent(t.indent).setDirection(t.direction).setTextFormat(t.textFormat||0).setTextStyle(t.textStyle||"")}insertNewAfter(t,e){return null}canIndent(){return!0}collapseAtStart(t){return!1}excludeFromCopy(t){return!1}canReplaceWith(t){return!0}canInsertAfter(t){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(t){return!1}extractWithChild(t,e,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(t,e){const n=this.getDOMSlot(t);let r=n.getFirstChild();for(let t=this.getFirstChild();t;t=t.getNextSibling()){const i=e.getElementByKey(t.getKey());null!==i&&(null==r?(n.insertChild(i),r=i):r!==i&&n.replaceChild(i,r),r=r.nextSibling)}}}function Zr(t){return t instanceof Qr}function ti(t,e,n){let r=t.getNode();for(;r;){const t=r.__key;if(e.has(t)&&!n.has(t))return!0;r=r.getParent()}return!1}class ei extends Tn{decorate(e,n){t(47)}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function ni(t){return t instanceof ei}class ri extends Qr{static getType(){return"root"}static clone(){return new ri}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){t(51)}getTextContent(){const t=this.__cachedText;return!Pr()&&Rr()._dirtyType!==y||null===t?super.getTextContent():t}remove(){t(52)}replace(e){t(53)}insertBefore(e){t(54)}insertAfter(e){t(55)}updateDOM(t,e){return!1}splice(e,n,r){for(const e of r)Zr(e)||ni(e)||t(282);return super.splice(e,n,r)}static importJSON(t){return Ui().updateFromJSON(t)}collapseAtStart(){return!0}}function ii(t){return t instanceof ri}function oi(t){return new ci(new Map(t._nodeMap))}function si(){return new ci(new Map([["root",new ri]]))}function li(e){const n=e.exportJSON(),r=e.constructor;if(n.type!==r.getType()&&t(130,r.name),Zr(e)){const i=n.children;Array.isArray(i)||t(59,r.name);const o=e.getChildren();for(let t=0;t<o.length;t++){const e=li(o[t]);i.push(e)}}return n}class ci{constructor(t,e){this._nodeMap=t,this._selection=e||null,this._flushSync=!1,this._readOnly=!1}isEmpty(){return 1===this._nodeMap.size&&null===this._selection}read(t,e){return Yr(e&&e.editor||null,this,t)}clone(t){const e=new ci(this._nodeMap,void 0===t?this._selection:t);return e._readOnly=!0,e}toJSON(){return Yr(null,this,(()=>({root:li(Ui())})))}}const ai="history-merge",ui="collaboration",fi="skip-scroll-into-view",di="skip-dom-selection";class hi extends Qr{static getType(){return"artificial"}createDOM(t){return document.createElement("div")}}class gi extends Qr{static getType(){return"paragraph"}static clone(t){return new gi(t.__key)}createDOM(t){const e=document.createElement("p"),n=lo(t.theme,"paragraph");if(void 0!==n){e.classList.add(...n)}return e}updateDOM(t,e,n){return!1}static importDOM(){return{p:t=>({conversion:_i,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(Po(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t)}return{element:e}}static importJSON(t){return pi().updateFromJSON(t)}exportJSON(){return{...super.exportJSON(),textFormat:this.getTextFormat(),textStyle:this.getTextStyle()}}insertNewAfter(t,e){const n=pi();n.setTextFormat(t.format),n.setTextStyle(t.style);const r=this.getDirection();return n.setDirection(r),n.setFormat(this.getFormatType()),n.setStyle(this.getStyle()),this.insertAfter(n,e),n}collapseAtStart(){const t=this.getChildren();if(0===t.length||Yn(t[0])&&""===t[0].getTextContent().trim()){if(null!==this.getNextSibling())return this.selectNext(),this.remove(),!0;if(null!==this.getPreviousSibling())return this.selectPrevious(),this.remove(),!0}return!1}}function _i(t){const e=pi();return t.style&&(e.setFormat(t.style.textAlign),Yo(t,e)),{node:e}}function pi(){return Eo(new gi)}function yi(t,e,n,r){const i=t._keyToDOMMap;i.clear(),t._editorState=si(),t._pendingEditorState=r,t._compositionKey=null,t._dirtyType=y,t._cloneNotNeeded.clear(),t._dirtyLeaves=new Set,t._dirtyElements.clear(),t._normalizedNodes=new Set,t._updateTags=new Set,t._updates=[],t._blockCursorElement=null;const o=t._observer;null!==o&&(o.disconnect(),t._observer=null),null!==e&&(e.textContent=""),null!==n&&(n.textContent="",i.set("root",n))}class mi{constructor(t,e,n,r,i,o,s,l){this._createEditorArgs=l,this._parentEditor=e,this._rootElement=null,this._editorState=t,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=r,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=y,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=qi(),this._onError=i,this._htmlConversions=o,this._editable=s,this._headless=null!==e&&e._headless,this._window=null,this._blockCursorElement=null}isComposing(){return null!=this._compositionKey}registerUpdateListener(t){const e=this._listeners.update;return e.add(t),()=>{e.delete(t)}}registerEditableListener(t){const e=this._listeners.editable;return e.add(t),()=>{e.delete(t)}}registerDecoratorListener(t){const e=this._listeners.decorator;return e.add(t),()=>{e.delete(t)}}registerTextContentListener(t){const e=this._listeners.textcontent;return e.add(t),()=>{e.delete(t)}}registerRootListener(t){const e=this._listeners.root;return t(this._rootElement,null),e.add(t),()=>{t(null,this._rootElement),e.delete(t)}}registerCommand(e,n,r){void 0===r&&t(35);const i=this._commands;i.has(e)||i.set(e,[new Set,new Set,new Set,new Set,new Set]);const o=i.get(e);void 0===o&&t(36,String(e));const s=o[r];return s.add(n),()=>{s.delete(n),o.every((t=>0===t.size))&&i.delete(e)}}registerMutationListener(t,e,n){const r=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(t)).klass,i=this._listeners.mutation;i.set(e,r);const o=n&&n.skipInitialization;return void 0!==o&&o||this.initializeMutationListener(e,r),()=>{i.delete(e)}}getRegisteredNode(e){const n=this._nodes.get(e.getType());return void 0===n&&t(37,e.name),n}resolveRegisteredNodeAfterReplacements(t){for(;t.replaceWithKlass;)t=this.getRegisteredNode(t.replaceWithKlass);return t}initializeMutationListener(t,e){const n=this._editorState,r=$o(n).get(e.getType());if(!r)return;const i=new Map;for(const t of r.keys())i.set(t,"created");i.size>0&&t(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(t,e){const n=this.getRegisteredNode(t);return n.transforms.add(e),n}registerNodeTransform(t,e){const n=this.registerNodeTransformToKlass(t,e),r=[n],i=n.replaceWithKlass;if(null!=i){const t=this.registerNodeTransformToKlass(i,e);r.push(t)}return function(t,e){const n=$o(t.getEditorState()),r=[];for(const t of e){const e=n.get(t);e&&r.push(e)}if(0===r.length)return;t.update((()=>{for(const t of r)for(const e of t.keys()){const t=Ri(e);t&&t.markDirty()}}),null===t._pendingEditorState?{tag:ai}:void 0)}(this,r.map((t=>t.klass.getType()))),()=>{r.forEach((t=>t.transforms.delete(e)))}}hasNode(t){return this._nodes.has(t.getType())}hasNodes(t){return t.every(this.hasNode.bind(this))}dispatchCommand(t,e){return ho(this,t,e)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(t){const e=this._rootElement;if(t!==e){const n=lo(this._config.theme,"root"),r=this._pendingEditorState||this._editorState;if(this._rootElement=t,yi(this,e,t,r),null!==e&&(this._config.disableEvents||Cn(e),null!=n&&e.classList.remove(...n)),null!==t){const e=So(t),r=t.style;r.userSelect="text",r.whiteSpace="pre-wrap",r.wordBreak="break-word",t.setAttribute("data-lexical-editor","true"),this._window=e,this._dirtyType=x,it(this),this._updateTags.add(ai),Jr(this),this._config.disableEvents||function(t,e){const n=t.ownerDocument,r=Xe.get(n);(void 0===r||r<1)&&n.addEventListener("selectionchange",pn),Xe.set(n,(r||0)+1),t.__lexicalEditor=e;const i=gn(t);for(let n=0;n<He.length;n++){const[r,o]=He[n],s="function"==typeof o?t=>{mn(t)||(yn(t),(e.isEditable()||"click"===r)&&o(t,e))}:t=>{if(mn(t))return;yn(t);const n=e.isEditable();switch(r){case"cut":return n&&ho(e,Le,t);case"copy":return ho(e,Ie,t);case"paste":return n&&ho(e,se,t);case"dragstart":return n&&ho(e,we,t);case"dragover":return n&&ho(e,De,t);case"dragend":return n&&ho(e,Pe,t);case"focus":return n&&ho(e,We,t);case"blur":return n&&ho(e,$e,t);case"drop":return n&&ho(e,Oe,t)}};t.addEventListener(r,s),i.push((()=>{t.removeEventListener(r,s)}))}}(t,this),null!=n&&t.classList.add(...n)}else this._window=null,this._updateTags.add(ai),Jr(this);Hr("root",this,!1,t,e)}}getElementByKey(t){return this._keyToDOMMap.get(t)||null}getEditorState(){return this._editorState}setEditorState(e,n){e.isEmpty()&&t(38);let r=e;r._readOnly&&(r=oi(e),r._selection=e._selection?e._selection.clone():null),rt(this);const i=this._pendingEditorState,o=this._updateTags,s=void 0!==n?n.tag:null;null===i||i.isEmpty()||(null!=s&&o.add(s),Jr(this)),this._pendingEditorState=r,this._dirtyType=x,this._dirtyElements.set("root",!1),this._compositionKey=null,null!=s&&o.add(s),this._updating||Jr(this)}parseEditorState(t,e){return function(t,e,n){const r=si(),i=br,o=Or,s=Mr,l=e._dirtyElements,c=e._dirtyLeaves,a=e._cloneNotNeeded,u=e._dirtyType;e._dirtyElements=new Map,e._dirtyLeaves=new Set,e._cloneNotNeeded=new Set,e._dirtyType=0,br=r,Or=!1,Mr=e;try{const i=e._nodes;Ur(t.root,i),n&&n(),r._readOnly=!0}catch(t){t instanceof Error&&e._onError(t)}finally{e._dirtyElements=l,e._dirtyLeaves=c,e._cloneNotNeeded=a,e._dirtyType=u,br=i,Or=o,Mr=s}return r}("string"==typeof t?JSON.parse(t):t,this,e)}read(t){return Jr(this),this.getEditorState().read(t,{editor:this})}update(t,e){!function(t,e,n){t._updating?t._updates.push([e,n]):Vr(t,e,n)}(this,t,e)}focus(t,e={}){const n=this._rootElement;null!==n&&(n.setAttribute("autocapitalize","off"),Gr(this,(()=>{const r=pr(),i=Ui();null!==r?r.dirty||Ji(r.clone()):0!==i.getChildrenSize()&&("rootStart"===e.defaultSelection?i.selectStart():i.selectEnd()),mo("focus"),xo((()=>{n.removeAttribute("autocapitalize"),t&&t()}))})),null===this._pendingEditorState&&n.removeAttribute("autocapitalize"))}blur(){const t=this._rootElement;null!==t&&t.blur();const e=wo(this._window);null!==e&&e.removeAllRanges()}isEditable(){return this._editable}setEditable(t){this._editable!==t&&(this._editable=t,Hr("editable",this,!0,t))}toJSON(){return{editorState:this._editorState.toJSON()}}}mi.version="0.32.0+prod.cjs";let xi=1;const Ci="function"==typeof queueMicrotask?queueMicrotask:t=>{Promise.resolve().then(t)};function Si(t){return ni(zi(t))}function Ti(t){const e=document.activeElement;if(!Po(e))return!1;const n=e.nodeName;return ni(zi(t))&&("INPUT"===n||"TEXTAREA"===n||"true"===e.contentEditable&&null==Ei(e))}function Ni(t,e,n){const r=t.getRootElement();try{return null!==r&&r.contains(e)&&r.contains(n)&&null!==e&&!Ti(e)&&ki(e)===t}catch(t){return!1}}function vi(t){return t instanceof mi}function ki(t){let e=t;for(;null!=e;){const t=Ei(e);if(vi(t))return t;e=po(e)}return null}function Ei(t){return t?t.__lexicalEditor:null}function bi(t){return t.isToken()||t.isSegmented()}function Mi(t){return Io(t)&&t.nodeType===g}function Oi(t){return Io(t)&&t.nodeType===_}function Ai(t){let e=t;for(;null!=e;){if(Mi(e))return e;e=e.firstChild}return null}function wi(t,e,n){const r=z[e];if(null!==n&&(t&r)==(n&r))return t;let i=t^r;return"subscript"===e?i&=~z.superscript:"superscript"===e?i&=~z.subscript:"lowercase"===e?(i&=~z.uppercase,i&=~z.capitalize):"uppercase"===e?(i&=~z.lowercase,i&=~z.capitalize):"capitalize"===e&&(i&=~z.lowercase,i&=~z.uppercase),i}function Di(t,e){if(null!=e)return void(t.__key=e);Ir(),Lr();const n=Rr(),r=Fr(),i=""+xi++;r._nodeMap.set(i,t),Zr(t)?n._dirtyElements.set(i,!0):n._dirtyLeaves.add(i),n._cloneNotNeeded.add(i),n._dirtyType=m,t.__key=i}function Pi(t){const e=t.getParent();if(null!==e){const n=t.getWritable(),r=e.getWritable(),i=t.getPreviousSibling(),o=t.getNextSibling(),s=null!==o?o.__key:null,l=null!==i?i.__key:null,c=null!==i?i.getWritable():null,a=null!==o?o.getWritable():null;null===i&&(r.__first=s),null===o&&(r.__last=l),null!==c&&(c.__next=s),null!==a&&(a.__prev=l),n.__prev=null,n.__next=null,n.__parent=null,r.__size--}}function Ii(t){Lr();const e=t.getLatest(),n=e.__parent,r=Fr(),i=Rr(),o=r._nodeMap,s=i._dirtyElements;null!==n&&function(t,e,n){let r=t;for(;null!==r;){if(n.has(r))return;const t=e.get(r);if(void 0===t)break;n.set(r,!1),r=t.__parent}}(n,o,s);const l=e.__key;i._dirtyType=m,Zr(t)?s.set(l,!0):i._dirtyLeaves.add(l)}function Li(t){Ir();const e=Rr(),n=e._compositionKey;if(t!==n){if(e._compositionKey=t,null!==n){const t=Ri(n);null!==t&&t.getWritable()}if(null!==t){const e=Ri(t);null!==e&&e.getWritable()}}}function Fi(){if(Pr())return null;return Rr()._compositionKey}function Ri(t,e){const n=(e||Fr())._nodeMap.get(t);return void 0===n?null:n}function Ki(t,e){const n=Bi(t,Rr());return void 0!==n?Ri(n,e):null}function Bi(t,e){return t[`__lexicalKey_${e._key}`]}function zi(t,e){let n=t;for(;null!=n;){const t=Ki(n,e);if(null!==t)return t;n=po(n)}return null}function Wi(t){const e=t._decorators,n=Object.assign({},e);return t._pendingDecorators=n,n}function $i(t){return t.read((()=>Ui().getTextContent()))}function Ui(){return Yi(Fr())}function Yi(t){return t._nodeMap.get("root")}function Ji(t){Ir();const e=Fr();null!==t&&(t.dirty=!0,t.setCachedNodes(null)),e._selection=t}function Hi(t){const e=Rr(),n=function(t,e){let n=t;for(;null!=n;){const t=Bi(n,e);if(void 0!==t)return t;n=po(n)}return null}(t,e);if(null===n){return t===e.getRootElement()?Ri("root"):null}return Ri(n)}function ji(t,e){return e?t.getTextContentSize():0}function Vi(t){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(t)}function Gi(t){const e=[];let n=t;for(;null!==n;)e.push(n),n=n._parentEditor;return e}function qi(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,5)}function Xi(t){return Mi(t)?t.nodeValue:null}function Qi(t,e,n){const r=wo(To(e));if(null===r)return;const i=r.anchorNode;let{anchorOffset:o,focusOffset:s}=r;if(null!==i){let e=Xi(i);const r=zi(i);if(null!==e&&Yn(r)){if(e===P&&n){const t=n.length;e=n,o=t,s=t}null!==e&&Zi(r,e,o,s,t)}}}function Zi(t,e,n,r,i){let o=t;if(o.isAttached()&&(i||!o.isDirty())){const c=o.isComposing();let a=e;(c||i)&&e[e.length-1]===P&&(a=e.slice(0,-1));const u=o.getTextContent();if(i||a!==u){if(""===a){if(Li(null),s||l||f)o.remove();else{const t=Rr();setTimeout((()=>{t.update((()=>{o.isAttached()&&o.remove()}))}),20)}return}const e=o.getParent(),i=yr(),u=o.getTextContentSize(),d=Fi(),h=o.getKey();if(o.isToken()||null!==d&&h===d&&!c||tr(i)&&(null!==e&&!e.canInsertTextBefore()&&0===i.anchor.offset||i.anchor.key===t.__key&&0===i.anchor.offset&&!o.canInsertTextBefore()&&!c||i.focus.key===t.__key&&i.focus.offset===u&&!o.canInsertTextAfter()&&!c))return void o.markDirty();const g=pr();if(!tr(g)||null===n||null===r)return void o.setTextContent(a);if(g.setTextNodeRange(o,n,o,r),o.isSegmented()){const t=Un(o.getTextContent());o.replace(t),o=t}o.setTextContent(a)}}}function to(t,e,n){const r=e[n]||!1;return"any"===r||r===t[n]}function eo(t,e){return to(t,e,"altKey")&&to(t,e,"ctrlKey")&&to(t,e,"shiftKey")&&to(t,e,"metaKey")}function no(t,e,n){return eo(t,n)&&t.key.toLowerCase()===e.toLowerCase()}const ro={ctrlKey:!r,metaKey:r},io={altKey:r,ctrlKey:!r};function oo(t){return"Backspace"===t.key}function so(t){return no(t,"a",ro)}function lo(t,e){void 0===t.__lexicalClassNameCache&&(t.__lexicalClassNameCache={});const n=t.__lexicalClassNameCache,r=n[e];if(void 0!==r)return r;const i=t[e];if("string"==typeof i){const t=d(i);return n[e]=t,t}return i}function co(e,n,r,i,o){if(0===r.size)return;const s=i.__type,l=i.__key,c=n.get(s);void 0===c&&t(33,s);const a=c.klass;let u=e.get(a);void 0===u&&(u=new Map,e.set(a,u));const f=u.get(l),d="destroyed"===f&&"created"===o;(void 0===f||d)&&u.set(l,d?"updated":o)}function ao(t,e,n){const r=t.getParent();let i=n,o=t;return null!==r&&(e&&0===n?(i=o.getIndexWithinParent(),o=r):e||n!==o.getChildrenSize()||(i=o.getIndexWithinParent()+1,o=r)),o.getChildAtIndex(e?i-1:i)}function uo(t,e){const n=t.offset;if("element"===t.type){return ao(t.getNode(),e,n)}{const r=t.getNode();if(e&&0===n||!e&&n===r.getTextContentSize()){const t=e?r.getPreviousSibling():r.getNextSibling();return null===t?ao(r.getParentOrThrow(),e,r.getIndexWithinParent()+(e?0:1)):t}}return null}function fo(t){const e=To(t).event,n=e&&e.inputType;return"insertFromPaste"===n||"insertFromPasteAsQuotation"===n}function ho(t,e,n){return function(t,e,n){const r=Gi(t);for(let i=4;i>=0;i--)for(let o=0;o<r.length;o++){const s=r[o],l=s._commands.get(e);if(void 0!==l){const e=l[i];if(void 0!==e){const r=Array.from(e),i=r.length;let o=!1;if(Gr(s,(()=>{for(let e=0;e<i;e++)if(r[e](n,t))return void(o=!0)})),o)return o}}}return!1}(t,e,n)}function go(t){return!ii(t)&&!t.isLastChild()&&!t.isInline()}function _o(e,n){const r=e._keyToDOMMap.get(n);return void 0===r&&t(75,n),r}function po(t){const e=t.assignedSlot||t.parentElement;return Lo(e)?e.host:e}function yo(t){return Oi(t)?t:Po(t)?t.ownerDocument:null}function mo(t){Ir();Rr()._updateTags.add(t)}function xo(t){Ir();Rr()._deferred.push(t)}function Co(t,e){let n=t.getParent();for(;null!==n;){if(n.is(e))return!0;n=n.getParent()}return!1}function So(t){const e=yo(t);return e?e.defaultView:null}function To(e){const n=e._window;return null===n&&t(78),n}function No(t){let e=t.getParentOrThrow();for(;null!==e;){if(vo(e))return e;e=e.getParentOrThrow()}return e}function vo(t){return ii(t)||Zr(t)&&t.isShadowRoot()}function ko(t){const e=t.constructor.clone(t);return Di(e,null),e}function Eo(e){const n=Rr(),r=e.constructor.getType(),i=n._nodes.get(r);void 0===i&&t(200,e.constructor.name,r);const{replace:o,replaceWithKlass:s}=i;if(null!==o){const n=o(e),i=n.constructor;return null!==s?n instanceof s||t(201,s.name,s.getType(),i.name,i.getType(),e.constructor.name,r):n instanceof e.constructor&&i!==e.constructor||t(202,i.name,i.getType(),e.constructor.name,r),n.__key===e.__key&&t(203,e.constructor.name,r,i.name,i.getType()),n}return e}function bo(e,n){!ii(e.getParent())||Zr(n)||ni(n)||t(99)}function Mo(e){const n=Ri(e);return null===n&&t(63,e),n}function Oo(t){return(ni(t)||Zr(t)&&!t.canBeEmpty())&&!t.isInline()}function Ao(t,e,n){n.style.removeProperty("caret-color"),e._blockCursorElement=null;const r=t.parentElement;null!==r&&r.removeChild(t)}function wo(t){return e?(t||window).getSelection():null}function Do(t){const e=So(t);return e?e.getSelection():null}function Po(t){return Io(t)&&t.nodeType===h}function Io(t){return"object"==typeof t&&null!==t&&"nodeType"in t&&"number"==typeof t.nodeType}function Lo(t){return Io(t)&&t.nodeType===p}function Fo(t){const e=new RegExp(/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|mark|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/,"i");return null!==t.nodeName.match(e)}function Ro(t){const e=new RegExp(/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/,"i");return null!==t.nodeName.match(e)}function Ko(t){if(ni(t)&&!t.isInline())return!0;if(!Zr(t)||vo(t))return!1;const e=t.getFirstChild(),n=null===e||En(e)||Yn(e)||e.isInline();return!t.isInline()&&!1!==t.canBeEmpty()&&n}function Bo(t,e){let n=t;for(;null!==n&&null!==n.getParent()&&!e(n);)n=n.getParentOrThrow();return e(n)?n:null}const zo=new WeakMap,Wo=new Map;function $o(e){if(!e._readOnly&&e.isEmpty())return Wo;e._readOnly||t(192);let n=zo.get(e);return n||(n=function(t){const e=new Map;for(const[n,r]of t._nodeMap){const t=r.__type;let i=e.get(t);i||(i=new Map,e.set(t,i)),i.set(n,r)}return e}(e),zo.set(e,n)),n}function Uo(t){const e=t.constructor.clone(t);return e.afterCloneFrom(t),e}function Yo(t,e){const n=parseInt(t.style.paddingInlineStart,10)||0,r=Math.round(n/40);e.setIndent(r)}function Jo(t){return!0===t.__lexicalUnmanaged}const Ho={next:"previous",previous:"next"};class jo{constructor(t){this.origin=t}[Symbol.iterator](){return ms({hasNext:es,initial:this.getAdjacentCaret(),map:t=>t,step:t=>t.getAdjacentCaret()})}getAdjacentCaret(){return ss(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return ss(this.origin,this.direction)}remove(){const t=this.getNodeAtCaret();return t&&t.remove(),this}replaceOrInsert(t,e){const n=this.getNodeAtCaret();return t.is(this.origin)||t.is(n)||(null===n?this.insert(t):n.replace(t,e)),this}splice(e,n,r="next"){const i=r===this.direction?n:Array.from(n).reverse();let o=this;const s=this.getParentAtCaret(),l=new Map;for(let t=o.getAdjacentCaret();null!==t&&l.size<e;t=t.getAdjacentCaret()){const e=t.origin.getWritable();l.set(e.getKey(),e)}for(const e of i){if(l.size>0){const n=o.getNodeAtCaret();if(n)if(l.delete(n.getKey()),l.delete(e.getKey()),n.is(e)||o.origin.is(e));else{const t=e.getParent();t&&t.is(s)&&e.remove(),n.replace(e)}else null===n&&t(263,Array.from(l).join(" "))}else o.insert(e);o=ss(e,this.direction)}for(const t of l.values())t.remove();return this}}class Vo extends jo{type="child";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:us(t,this.direction)}getParentCaret(t="root"){return ss(Xo(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=qo(this.direction);return ss(this.getNodeAtCaret(),t)||us(this.origin,t)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(t){return t instanceof Vo&&this.direction===t.direction&&this.origin.is(t.origin)}isSamePointCaret(t){return this.isSameNodeCaret(t)}}const Go={root:ii,shadowRoot:vo};function qo(t){return Ho[t]}function Xo(t,e="root"){return Go[e](t)?null:t}class Qo extends jo{type="sibling";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:ss(t,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return Zr(this.origin)?us(this.origin,this.direction):null}getParentCaret(t="root"){return ss(Xo(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=qo(this.direction);return ss(this.getNodeAtCaret(),t)||us(this.origin.getParentOrThrow(),t)}isSamePointCaret(t){return t instanceof Qo&&this.direction===t.direction&&this.origin.is(t.origin)}isSameNodeCaret(t){return(t instanceof Qo||t instanceof Zo)&&this.direction===t.direction&&this.origin.is(t.origin)}}class Zo extends jo{type="text";constructor(t,e){super(t),this.offset=e}getLatest(){const t=this.origin.getLatest();return t===this.origin?this:ls(t,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(t="root"){return ss(Xo(this.getParentAtCaret(),t),this.direction)}getFlipped(){return ls(this.origin,qo(this.direction),this.offset)}isSamePointCaret(t){return t instanceof Zo&&this.direction===t.direction&&this.origin.is(t.origin)&&this.offset===t.offset}isSameNodeCaret(t){return(t instanceof Qo||t instanceof Zo)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return ss(this.origin,this.direction)}}function ts(t){return t instanceof Zo}function es(t){return t instanceof Qo}function ns(t){return t instanceof Vo}const rs={next:class extends Zo{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Zo{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},is={next:class extends Qo{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Qo{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},os={next:class extends Vo{direction="next";getNodeAtCaret(){return this.origin.getFirstChild()}insert(t){return this.origin.splice(0,0,[t]),this}},previous:class extends Vo{direction="previous";getNodeAtCaret(){return this.origin.getLastChild()}insert(t){return this.origin.splice(this.origin.getChildrenSize(),0,[t]),this}}};function ss(t,e){return t?new is[e](t):null}function ls(t,e,n){return t?new rs[e](t,cs(t,n)):null}function cs(t,e){const n=t.getTextContentSize();let r="next"===e?n:"previous"===e?0:e;return(r<0||r>n)&&(!function(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.`)}(284,String(e),String(n),t.getKey()),r=r<0?0:n),r}function as(t,e){return new gs(t,e)}function us(t,e){return Zr(t)?new os[e](t):null}function fs(t){return t&&t.getChildCaret()||t}function ds(t){return t&&fs(t.getAdjacentCaret())}class hs{type="node-caret-range";constructor(t,e,n){this.anchor=t,this.focus=e,this.direction=n}getLatest(){const t=this.anchor.getLatest(),e=this.focus.getLatest();return t===this.anchor&&e===this.focus?this:new hs(t,e,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){const t=t=>{const e=this[t].getLatest();return ts(e)?function(t,e){const{direction:n,origin:r}=t,i=cs(r,"focus"===e?qo(n):n);return as(t,i-t.offset)}(e,t):null},e=t("anchor"),n=t("focus");if(e&&n){const{caret:t}=e,{caret:r}=n;if(t.isSameNodeCaret(r))return[as(t,r.offset-t.offset),null]}return[e,n]}iterNodeCarets(t="root"){const e=ts(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),r=ts(n),i=e=>e.isSameNodeCaret(n)?null:ds(e)||e.getParentCaret(t);return ms({hasNext:t=>null!==t&&!(r&&n.isSameNodeCaret(t)),initial:e.isSameNodeCaret(n)?null:i(e),map:t=>t,step:i})}[Symbol.iterator](){return this.iterNodeCarets("root")}}class gs{type="slice";constructor(t,e){this.caret=t,this.distance=e}getSliceIndices(){const{distance:t,caret:{offset:e}}=this,n=e+t;return n<e?[n,e]:[e,n]}getTextContent(){const[t,e]=this.getSliceIndices();return this.caret.origin.getTextContent().slice(t,e)}getTextContentSize(){return Math.abs(this.distance)}removeTextSlice(){const{caret:{origin:t,direction:e}}=this,[n,r]=this.getSliceIndices(),i=t.getTextContent();return ls(t.setTextContent(i.slice(0,n)+i.slice(r)),e,n)}}function _s(t){return ys(t,ss(Ui(),t.direction))}function ps(t){return ys(t,t)}function ys(e,n){return e.direction!==n.direction&&t(265),new hs(e,n,e.direction)}function ms(t){const{initial:e,hasNext:n,step:r,map:i}=t;let o=e;return{[Symbol.iterator](){return this},next(){if(!n(o))return{done:!0,value:void 0};const t={done:!1,value:i(o)};return o=r(o),t}}}function xs(e,n){const r=Ns(e.origin,n.origin);switch(null===r&&t(275,e.origin.getKey(),n.origin.getKey()),r.type){case"same":{const t="text"===e.type,r="text"===n.type;return t&&r?function(t,e){return Math.sign(t-e)}(e.offset,n.offset):e.type===n.type?0:t?-1:r?1:"child"===e.type?-1:1}case"ancestor":return"child"===e.type?-1:1;case"descendant":return"child"===n.type?1:-1;case"branch":return Cs(r)}}function Cs(t){const{a:e,b:n}=t,r=e.__key,i=n.__key;let o=e,s=n;for(;o&&s;o=o.getNextSibling(),s=s.getNextSibling()){if(o.__key===i)return-1;if(s.__key===r)return 1}return null===o?1:-1}function Ss(t,e){return e.is(t)}function Ts(t){return Zr(t)?[t.getLatest(),null]:[t.getParent(),t.getLatest()]}function Ns(e,n){if(e.is(n))return{commonAncestor:e,type:"same"};const r=new Map;for(let[t,n]=Ts(e);t;n=t,t=t.getParent())r.set(t,n);for(let[i,o]=Ts(n);i;o=i,i=i.getParent()){const s=r.get(i);if(void 0!==s)return null===s?(Ss(e,i)||t(276),{commonAncestor:i,type:"ancestor"}):null===o?(Ss(n,i)||t(277),{commonAncestor:i,type:"descendant"}):((Zr(s)||Ss(e,s))&&(Zr(o)||Ss(n,o))&&i.is(s.getParent())&&i.is(o.getParent())||t(278),{a:s,b:o,commonAncestor:i,type:"branch"})}return null}function vs(e,n){const{type:r,key:i,offset:o}=e,s=Mo(e.key);return"text"===r?(Yn(s)||t(266,s.getType(),i),ls(s,n,o)):(Zr(s)||t(267,s.getType(),i),Rs(s,e.offset,n))}function ks(e,n){const{origin:r,direction:i}=n,o="next"===i;ts(n)?e.set(r.getKey(),n.offset,"text"):es(n)?Yn(r)?e.set(r.getKey(),cs(r,i),"text"):e.set(r.getParentOrThrow().getKey(),r.getIndexWithinParent()+(o?1:0),"element"):(ns(n)&&Zr(r)||t(268),e.set(r.getKey(),o?0:r.getChildrenSize(),"element"))}function Es(t){const e=pr(),n=tr(e)?e:hr();return bs(n,t),Ji(n),n}function bs(t,e){ks(t.anchor,e.anchor),ks(t.focus,e.focus)}function Ms(t){const{anchor:e,focus:n}=t,r=vs(e,"next"),i=vs(n,"next"),o=xs(r,i)<=0?"next":"previous";return ys(Ls(r,o),Ls(i,o))}function Os(t){const{direction:e,origin:n}=t,r=ss(n,qo(e)).getNodeAtCaret();return r?ss(r,e):us(n.getParentOrThrow(),e)}function As(t,e="root"){const n=[t];for(let r=ns(t)?t.getParentCaret(e):t.getSiblingCaret();null!==r;r=r.getParentCaret(e))n.push(Os(r));return n}function ws(t){return!!t&&t.origin.isAttached()}function Ds(e,n="removeEmptySlices"){if(e.isCollapsed())return e;const r="root",i="next";let o=n;const s=Fs(e,i),l=As(s.anchor,r),c=As(s.focus.getFlipped(),r),a=new Set,u=[];for(const t of s.iterNodeCarets(r))if(ns(t))a.add(t.origin.getKey());else if(es(t)){const{origin:e}=t;Zr(e)&&!a.has(e.getKey())||u.push(e)}for(const t of u)t.remove();for(const t of s.getTextSlices()){if(!t)continue;const{origin:e}=t.caret,n=e.getTextContentSize(),r=Os(ss(e,i)),s=e.getMode();if(Math.abs(t.distance)===n&&"removeEmptySlices"===o||"token"===s&&0!==t.distance)r.remove();else if(0!==t.distance){o="removeEmptySlices";let e=t.removeTextSlice();const n=t.caret.origin;if("segmented"===s){const t=e.origin,n=Un(t.getTextContent()).setStyle(t.getStyle()).setFormat(t.getFormat());r.replaceOrInsert(n),e=ls(n,i,e.offset)}n.is(l[0].origin)&&(l[0]=e),n.is(c[0].origin)&&(c[0]=e.getFlipped())}}let f,d;for(const t of l)if(ws(t)){f=Ps(t);break}for(const t of c)if(ws(t)){d=Ps(t);break}const h=function(t,e,n){if(!t||!e)return null;const r=t.getParentAtCaret(),i=e.getParentAtCaret();if(!r||!i)return null;const o=r.getParents().reverse();o.push(r);const s=i.getParents().reverse();s.push(i);const l=Math.min(o.length,s.length);let c;for(c=0;c<l&&o[c]===s[c];c++);const a=(t,e)=>{let n;for(let r=c;r<t.length;r++){const i=t[r];if(vo(i))return;!n&&e(i)&&(n=i)}return n},u=a(o,Ko),f=u&&a(s,(t=>n.has(t.getKey())&&Ko(t)));return u&&f?[u,f]:null}(f,d,a);if(h){const[t,e]=h;us(t,"previous").splice(0,e.getChildren()),e.remove()}const g=[f,d,...l,...c].find(ws);if(g){return ps(Ls(Ps(g),e.direction))}t(269,JSON.stringify(l.map((t=>t.origin.__key))))}function Ps(t){const e=function(t){let e=t;for(;ns(e);){const t=ds(e);if(!ns(t))break;e=t}return e}(t.getLatest()),{direction:n}=e;if(Yn(e.origin))return ts(e)?e:ls(e.origin,n,n);const r=e.getAdjacentCaret();return es(r)&&Yn(r.origin)?ls(r.origin,n,qo(n)):e}function Is(t){return ts(t)&&t.offset!==cs(t.origin,t.direction)}function Ls(t,e){return t.direction===e?t:t.getFlipped()}function Fs(t,e){return t.direction===e?t:ys(Ls(t.focus,e),Ls(t.anchor,e))}function Rs(t,e,n){let r=us(t,"next");for(let t=0;t<e;t++){const t=r.getAdjacentCaret();if(null===t)break;r=t}return Ls(r,n)}function Ks(e){const{origin:n,offset:r,direction:i}=e;if(r===cs(n,i))return e.getSiblingCaret();if(r===cs(n,qo(i)))return Os(e.getSiblingCaret());const[o]=n.splitText(r);return Yn(o)||t(281),Ls(ss(o,"next"),i)}function Bs(t,e){return!0}exports.$addUpdateTag=mo,exports.$applyNodeReplacement=Eo,exports.$caretFromPoint=vs,exports.$caretRangeFromSelection=Ms,exports.$cloneWithProperties=Uo,exports.$comparePointCaretNext=xs,exports.$copyNode=ko,exports.$createLineBreakNode=kn,exports.$createNodeSelection=gr,exports.$createParagraphNode=pi,exports.$createPoint=qn,exports.$createRangeSelection=hr,exports.$createRangeSelectionFromDom=function(t,e){return _r(null,t,e,null)},exports.$createTabNode=jn,exports.$createTextNode=Un,exports.$extendCaretToRange=_s,exports.$getAdjacentChildCaret=ds,exports.$getAdjacentNode=uo,exports.$getAdjacentSiblingOrParentSiblingCaret=function(t,e="root"){let n=0,r=t,i=ds(r);for(;null===i;){if(n--,i=r.getParentCaret(e),!i)return null;r=i,i=ds(r)}return i&&[i,n]},exports.$getCaretInDirection=Ls,exports.$getCaretRange=ys,exports.$getCaretRangeInDirection=Fs,exports.$getCharacterOffsets=ir,exports.$getChildCaret=us,exports.$getChildCaretAtIndex=Rs,exports.$getChildCaretOrSelf=fs,exports.$getCollapsedCaretRange=ps,exports.$getCommonAncestor=Ns,exports.$getCommonAncestorResultBranchOrder=Cs,exports.$getEditor=function(){return Rr()},exports.$getNearestNodeFromDOMNode=zi,exports.$getNearestRootOrShadowRoot=No,exports.$getNodeByKey=Ri,exports.$getNodeByKeyOrThrow=Mo,exports.$getPreviousSelection=yr,exports.$getRoot=Ui,exports.$getSelection=pr,exports.$getSiblingCaret=ss,exports.$getState=lt,exports.$getStateChange=function(t,e,n){const r=lt(t,n,"direct"),i=lt(e,n,"direct");return n.isEqual(r,i)?null:[r,i]},exports.$getTextContent=function(){const t=pr();return null===t?"":t.getTextContent()},exports.$getTextNodeOffset=cs,exports.$getTextPointCaret=ls,exports.$getTextPointCaretSlice=as,exports.$getWritableNodeState=ut,exports.$hasAncestor=Co,exports.$hasUpdateTag=function(t){return Rr()._updateTags.has(t)},exports.$insertNodes=function(t){let e=pr()||yr();null===e&&(e=Ui().selectEnd()),e.insertNodes(t)},exports.$isBlockElementNode=function(t){return Zr(t)&&!t.isInline()},exports.$isChildCaret=ns,exports.$isDecoratorNode=ni,exports.$isElementNode=Zr,exports.$isExtendableTextPointCaret=Is,exports.$isInlineElementOrDecoratorNode=function(t){return Zr(t)&&t.isInline()||ni(t)&&t.isInline()},exports.$isLeafNode=function(t){return Yn(t)||En(t)||ni(t)},exports.$isLineBreakNode=En,exports.$isNodeCaret=function(t){return t instanceof jo},exports.$isNodeSelection=nr,exports.$isParagraphNode=function(t){return t instanceof gi},exports.$isRangeSelection=tr,exports.$isRootNode=ii,exports.$isRootOrShadowRoot=vo,exports.$isSiblingCaret=es,exports.$isTabNode=Vn,exports.$isTextNode=Yn,exports.$isTextPointCaret=ts,exports.$isTextPointCaretSlice=function(t){return t instanceof gs},exports.$isTokenOrSegmented=bi,exports.$nodesOfType=function(t){const e=t.getType(),n=Fr();if(n._readOnly){const t=$o(n).get(e);return t?Array.from(t.values()):[]}const r=n._nodeMap,i=[];for(const[,n]of r)n instanceof t&&n.__type===e&&n.isAttached()&&i.push(n);return i},exports.$normalizeCaret=Ps,exports.$normalizeSelection__EXPERIMENTAL=gt,exports.$onUpdate=xo,exports.$parseSerializedNode=function(t){return Ur(t,Rr()._nodes)},exports.$removeTextFromCaretRange=Ds,exports.$rewindSiblingCaret=Os,exports.$selectAll=function(t){const e=Ui();if(tr(t)){const e=t.anchor,n=t.focus,r=e.getNode().getTopLevelElementOrThrow().getParentOrThrow();return e.set(r.getKey(),0,"element"),n.set(r.getKey(),r.getChildrenSize(),"element"),gt(t),t}{const t=e.select(0,e.getChildrenSize());return Ji(gt(t)),t}},exports.$setCompositionKey=Li,exports.$setPointFromCaret=ks,exports.$setSelection=Ji,exports.$setSelectionFromCaretRange=Es,exports.$setState=function(t,e,n){let r;if(Ir(),"function"==typeof n){const i=t.getLatest(),o=lt(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},exports.$splitAtPointCaretNext=function(t,{$copyElementNode:e=ko,$splitTextPointCaretNext:n=Ks,rootMode:r="shadowRoot",$shouldSplit:i=Bs}={}){if(ts(t))return n(t);const o=t.getParentCaret(r);if(o){const{origin:n}=o;if(ns(t)&&(!n.canBeEmpty()||!i(n,"first")))return Os(o);const r=function(t){const e=[];for(let n=t.getAdjacentCaret();n;n=n.getAdjacentCaret())e.push(n.origin);return e}(t);(r.length>0||n.canBeEmpty()&&i(n,"last"))&&o.insert(e(n).splice(0,0,r))}return o},exports.$splitNode=function(e,n){let r=e.getChildAtIndex(n);null==r&&(r=e),vo(e)&&t(102);const i=e=>{const n=e.getParentOrThrow(),o=vo(n),s=e!==r||o?ko(e):e;if(o)return Zr(e)&&Zr(s)||t(133),e.insertAfter(s),[e,s,s];{const[t,r,o]=i(n),l=e.getNextSiblings();return o.append(s,...l),[t,r,s]}},[o,s]=i(r);return[o,s]},exports.$updateRangeSelectionFromCaretRange=bs,exports.ArtificialNode__DO_NOT_USE=hi,exports.BLUR_COMMAND=$e,exports.CAN_REDO_COMMAND=Be,exports.CAN_UNDO_COMMAND=ze,exports.CLEAR_EDITOR_COMMAND=Re,exports.CLEAR_HISTORY_COMMAND=Ke,exports.CLICK_COMMAND=ee,exports.COLLABORATION_TAG=ui,exports.COMMAND_PRIORITY_CRITICAL=4,exports.COMMAND_PRIORITY_EDITOR=0,exports.COMMAND_PRIORITY_HIGH=3,exports.COMMAND_PRIORITY_LOW=1,exports.COMMAND_PRIORITY_NORMAL=2,exports.CONTROLLED_TEXT_INSERTION_COMMAND=oe,exports.COPY_COMMAND=Ie,exports.CUT_COMMAND=Le,exports.DELETE_CHARACTER_COMMAND=ne,exports.DELETE_LINE_COMMAND=ae,exports.DELETE_WORD_COMMAND=ce,exports.DRAGEND_COMMAND=Pe,exports.DRAGOVER_COMMAND=De,exports.DRAGSTART_COMMAND=we,exports.DROP_COMMAND=Oe,exports.DecoratorNode=ei,exports.ElementNode=Qr,exports.FOCUS_COMMAND=We,exports.FORMAT_ELEMENT_COMMAND=Ae,exports.FORMAT_TEXT_COMMAND=ue,exports.HISTORIC_TAG="historic",exports.HISTORY_MERGE_TAG=ai,exports.HISTORY_PUSH_TAG="history-push",exports.INDENT_CONTENT_COMMAND=be,exports.INSERT_LINE_BREAK_COMMAND=re,exports.INSERT_PARAGRAPH_COMMAND=ie,exports.INSERT_TAB_COMMAND=Ee,exports.INTERNAL_$isBlock=Ko,exports.IS_ALL_FORMATTING=E,exports.IS_BOLD=1,exports.IS_CODE=16,exports.IS_HIGHLIGHT=k,exports.IS_ITALIC=2,exports.IS_STRIKETHROUGH=N,exports.IS_SUBSCRIPT=32,exports.IS_SUPERSCRIPT=64,exports.IS_UNDERLINE=v,exports.KEY_ARROW_DOWN_COMMAND=xe,exports.KEY_ARROW_LEFT_COMMAND=pe,exports.KEY_ARROW_RIGHT_COMMAND=ge,exports.KEY_ARROW_UP_COMMAND=me,exports.KEY_BACKSPACE_COMMAND=Te,exports.KEY_DELETE_COMMAND=ve,exports.KEY_DOWN_COMMAND=he,exports.KEY_ENTER_COMMAND=Ce,exports.KEY_ESCAPE_COMMAND=Ne,exports.KEY_MODIFIER_COMMAND=Ue,exports.KEY_SPACE_COMMAND=Se,exports.KEY_TAB_COMMAND=ke,exports.LineBreakNode=Nn,exports.MOVE_TO_END=_e,exports.MOVE_TO_START=ye,exports.NODE_STATE_KEY="$",exports.OUTDENT_CONTENT_COMMAND=Me,exports.PASTE_COMMAND=se,exports.PASTE_TAG="paste",exports.ParagraphNode=gi,exports.REDO_COMMAND=de,exports.REMOVE_TEXT_COMMAND=le,exports.RootNode=ri,exports.SELECTION_CHANGE_COMMAND=Zt,exports.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND=te,exports.SELECT_ALL_COMMAND=Fe,exports.SKIP_COLLAB_TAG="skip-collab",exports.SKIP_DOM_SELECTION_TAG=di,exports.SKIP_SCROLL_INTO_VIEW_TAG=fi,exports.TEXT_TYPE_TO_FORMAT=z,exports.TabNode=Hn,exports.TextNode=In,exports.UNDO_COMMAND=fe,exports.createCommand=Qt,exports.createEditor=function(t){const e=t||{},n=Br(),r=e.theme||{},i=void 0===t?n:e.parentEditor||null,o=e.disableEvents||!1,s=si(),l=e.namespace||(null!==i?i._config.namespace:qi()),c=e.editorState,a=[ri,In,Nn,Hn,gi,hi,...e.nodes||[]],{onError:u,html:f}=e,d=void 0===e.editable||e.editable;let h;if(void 0===t&&null!==n)h=n._nodes;else{h=new Map;for(let t=0;t<a.length;t++){let e=a[t],n=null,r=null;if("function"!=typeof e){const t=e;e=t.replace,n=t.with,r=t.withKlass||null}const i=e.getType(),o=e.transform(),s=new Set;null!==o&&s.add(o),h.set(i,{exportDOM:f&&f.export?f.export.get(e):void 0,klass:e,replace:n,replaceWithKlass:r,transforms:s})}}const g=new mi(s,i,h,{disableEvents:o,namespace:l,theme:r},u||console.error,function(t,e){const n=new Map,r=new Set,i=t=>{Object.keys(t).forEach((e=>{let r=n.get(e);void 0===r&&(r=[],n.set(e,r)),r.push(t[e])}))};return t.forEach((t=>{const e=t.klass.importDOM;if(null==e||r.has(e))return;r.add(e);const n=e.call(t.klass);null!==n&&i(n)})),e&&i(e),n}(h,f?f.import:void 0),d,t);return void 0!==c&&(g._pendingEditorState=c,g._dirtyType=x),g},exports.createState=function(t,e){return new st(t,e)},exports.flipDirection=qo,exports.getDOMOwnerDocument=yo,exports.getDOMSelection=wo,exports.getDOMSelectionFromTarget=Do,exports.getDOMTextNode=Ai,exports.getEditorPropertyFromDOMNode=Ei,exports.getNearestEditorFromDOMNode=ki,exports.isBlockDomNode=Ro,exports.isCurrentlyReadOnlyMode=Pr,exports.isDOMDocumentNode=Oi,exports.isDOMNode=Io,exports.isDOMTextNode=Mi,exports.isDOMUnmanaged=Jo,exports.isDocumentFragment=Lo,exports.isExactShortcutMatch=no,exports.isHTMLAnchorElement=function(t){return Po(t)&&"A"===t.tagName},exports.isHTMLElement=Po,exports.isInlineDomNode=Fo,exports.isLexicalEditor=vi,exports.isModifierMatch=eo,exports.isSelectionCapturedInDecoratorInput=Ti,exports.isSelectionWithinEditor=Ni,exports.makeStepwiseIterator=ms,exports.removeFromParent=Pi,exports.resetRandomKey=function(){xi=1},exports.setDOMUnmanaged=function(t){t.__lexicalUnmanaged=!0},exports.setNodeIndentFromDOM=Yo;
9
+ "use strict";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.`)}const e="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,n=e&&"documentMode"in document?document.documentMode:null,r=e&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),i=e&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),o=!(!e||!("InputEvent"in window)||n)&&"getTargetRanges"in new window.InputEvent("input"),s=e&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),l=e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,c=e&&/Android/.test(navigator.userAgent),a=e&&/^(?=.*Chrome).*/i.test(navigator.userAgent),u=e&&c&&a,f=e&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!a;function d(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}const h=1,g=3,_=9,p=11,y=0,m=1,x=2,C=0,S=1,N=2,T=4,v=8,k=128,E=1792|(112|(3|T|v)|k),b=1,M=2,O=3,A=4,w=5,D=6,P=s||l||f?" ":"​",I="\n\n",L=i?" ":P,F="֑-߿יִ-﷽ﹰ-ﻼ",R="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",K=new RegExp("^[^"+R+"]*["+F+"]"),B=new RegExp("^[^"+F+"]*["+R+"]"),z={bold:1,capitalize:1024,code:16,highlight:k,italic:2,lowercase:256,strikethrough:T,subscript:32,superscript:64,underline:v,uppercase:512},W={directionless:1,unmergeable:2},$={center:M,end:D,justify:A,left:b,right:O,start:w},U={[M]:"center",[D]:"end",[A]:"justify",[b]:"left",[O]:"right",[w]:"start"},Y={normal:0,segmented:2,token:1},J={[C]:"normal",[N]:"segmented",[S]:"token"},H="$";function j(t,e,n,r,i,o){let s=t.getFirstChild();for(;null!==s;){const t=s.__key;s.__parent===e&&(Zr(s)&&j(s,t,n,r,i,o),n.has(t)||o.delete(t),i.push(t)),s=s.getNextSibling()}}const V=100;let G=!1,q=0;function X(t){q=t.timeStamp}function Q(t,e,n){const r="BR"===t.nodeName,i=e.__lexicalLineBreak;return i&&(t===i||r&&t.previousSibling===i)||r&&void 0!==zi(t,n)}function Z(t,e,n){const r=Do(To(n));let i=null,o=null;null!==r&&r.anchorNode===t&&(i=r.anchorOffset,o=r.focusOffset);const s=t.nodeValue;null!==s&&to(e,s,i,o,!1)}function tt(t,e,n){if(tr(t)){const e=t.anchor.getNode();if(e.is(n)&&t.format!==e.getFormat())return!1}return Oi(e)&&n.isAttached()}function et(t,e,n,r){for(let i=t;i&&!Ho(i);i=yo(i)){const t=zi(i,e);if(void 0!==t){const e=Ki(t,n);if(e)return ni(e)||!Io(i)?void 0:[i,e]}else if(i===r)return[r,Ji(n)]}}function nt(t,e,n){G=!0;const r=performance.now()-q>V;try{Gr(t,(()=>{const o=pr()||function(t){return t.getEditorState().read((()=>{const t=pr();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,_=et(g,t,c,l);if(!_)continue;const[p,y]=_;if("characterData"===h)r&&Yn(y)&&Oi(g)&&tt(o,g,y)&&Z(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],o=Bi(r),s=r.parentNode;if(null!=s&&r!==a&&null===o&&!Q(r,s,t)){if(i){const t=(Io(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];(Q(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||Q(n,i,t)||o.removeChild(n)}}n.takeRecords()}null!==o&&(u&&Hi(o),i&&ho(t)&&o.insertRawText(f))}))}finally{G=!1}}function rt(t){const e=t._observer;if(null!==e){nt(t,e.takeRecords(),e)}}function it(t){!function(t){0===q&&To(t).addEventListener("textInput",X,!0)}(t),t._observer=new MutationObserver(((e,n)=>{nt(t,e,n)}))}function ot(t){return t}class st{constructor(t,e){this.key=t,this.parse=e.parse.bind(e),this.unparse=(e.unparse||ot).bind(e),this.isEqual=(e.isEqual||Object.is).bind(e),this.defaultValue=this.parse(void 0)}}function lt(t,e,n="latest"){const r=("latest"===n?t.getLatest():t).__state;return r?r.getValue(e):e.defaultValue}class ct{constructor(t,e=new Map,n=void 0,r=new Map,i=void 0){this.node=t,this.sharedConfigMap=e,this.unknownState=n,this.knownState=r;const o=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}(e,n,r);this.size=o}getValue(t){const e=this.knownState.get(t);if(void 0!==e)return e;this.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};for(const[e,n]of this.knownState)e.isEqual(n,e.defaultValue)?delete t[e.key]:t[e.key]=e.unparse(n);return at(t)?{[H]:t}:{}}getWritable(t){if(this.node===t)return this;const e=new Map(this.knownState),n=at(r=this.unknownState)&&{...r};var r;if(n)for(const t of e.keys())delete n[t.key];return new ct(t,this.sharedConfigMap,at(n),e,this.size)}updateFromKnown(t,e){const n=t.key;this.sharedConfigMap.set(n,t);const{knownState:r,unknownState:i}=this;r.has(t)||i&&n in i||this.size++,r.set(t,e)}updateFromUnknown(t,e){const n=this.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={},t)for(const[e,n]of Object.entries(t))this.updateFromUnknown(e,n);this.unknownState=at(this.unknownState)}}function at(t){if(t)for(const e in t)return t}function ut(t){const e=t.getWritable(),n=e.__state?e.__state.getWritable(e):new ct(e);return e.__state=n,n}function ft(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;if(t&&e&&t.size!==e.size)return!1;const n=new Set,r=(t,e)=>{for(const[r,i]of t.knownState){if(n.has(r.key))continue;n.add(r.key);const t=e?e.getValue(r):r.defaultValue;if(t!==i&&!r.isEqual(t,i))return!0}return!1},i=(t,e)=>{const{unknownState:r}=t,i=e?e.unknownState:void 0;if(r)for(const[t,e]of Object.entries(r))if(!n.has(t)&&(n.add(t),e!==(i?i[t]:void 0)))return!0;return!1};return!(t&&r(t,e)||e&&r(e,t)||t&&i(t,e)||e&&i(e,t))}(c,a))}function dt(t,e){const n=t.mergeWithSibling(e),r=Rr()._normalizedNodes;return r.add(t.__key),r.add(e.__key),n}function ht(t){let e,n,r=t;if(""!==r.__text||!r.isSimpleText()||r.isUnmergeable()){for(;null!==(e=r.getPreviousSibling())&&Yn(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(""!==e.__text){if(ft(e,r)){r=dt(e,r);break}break}e.remove()}for(;null!==(n=r.getNextSibling())&&Yn(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(""!==n.__text){if(ft(r,n)){r=dt(r,n);break}break}n.remove()}}else r.remove()}function gt(t){return _t(t.anchor),_t(t.focus),t}function _t(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),Yn(r)){t.set(r.__key,i?r.getTextContentSize():0,"text",!0);break}if(!Zr(r))break;t.set(r.__key,i?r.getChildrenSize():0,"element",!0)}}let pt,yt,mt,xt,Ct,St,Nt,Tt,vt,kt,Et="",bt="",Mt=null,Ot="",At="",wt=!1,Dt=!1,Pt=null;function It(t,e){const n=Nt.get(t);if(null!==e){const n=Xt(t);n.parentNode===e&&e.removeChild(n)}if(Tt.has(t)||yt._keyToDOMMap.delete(t),Zr(n)){const t=Ht(n,Nt);Lt(t,0,t.length-1,null)}void 0!==n&&ao(kt,mt,xt,n,"destroyed")}function Lt(t,e,n,r){let i=e;for(;i<=n;++i){const e=t[i];void 0!==e&&It(e,r)}}function Ft(t,e){t.setProperty("text-align",e)}const Rt="40px";function Kt(t,e){const n=pt.theme.indent;if("string"==typeof n){const r=t.classList.contains(n);e>0&&!r?t.classList.add(n):e<1&&r&&t.classList.remove(n)}const r=getComputedStyle(t).getPropertyValue("--lexical-indent-base-value")||Rt;t.style.setProperty("padding-inline-start",0===e?"":`calc(${e} * ${r})`)}function Bt(t,e){const n=t.style;0===e?Ft(n,""):e===b?Ft(n,"left"):e===M?Ft(n,"center"):e===O?Ft(n,"right"):e===A?Ft(n,"justify"):e===w?Ft(n,"start"):e===D&&Ft(n,"end")}function zt(e,n){const r=Tt.get(e);void 0===r&&t(60);const i=r.createDOM(pt,yt);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,yt),Yn(r)?i.setAttribute("data-lexical-text","true"):ni(r)&&i.setAttribute("data-lexical-decorator","true"),Zr(r)){const t=r.__indent,e=r.__size;if(0!==t&&Kt(i,t),0!==e){const t=e-1;!function(t,e,n,r){const i=bt;bt="",Wt(t,n,0,e,n.getDOMSlot(r)),Yt(n,r),bt=i}(Ht(r,Tt),t,r,i)}const n=r.__format;0!==n&&Bt(i,n),r.isInline()||Ut(null,r,i),_o(r)&&(Et+=I,At+=I)}else{const t=r.getTextContent();if(ni(r)){const t=r.decorate(yt,pt);null!==t&&Vt(e,t),i.contentEditable="false"}else Yn(r)&&(r.isDirectionless()||(bt+=t));Et+=t,At+=t}return null!==n&&n.insertChild(i),ao(kt,mt,xt,r,"created"),i}function Wt(t,e,n,r,i){const o=Et;Et="";let s=n;for(;s<=r;++s){zt(t[s],i);const e=Tt.get(t[s]);null!==e&&Yn(e)&&(null===Mt&&(Mt=e.getFormat()),""===Ot&&(Ot=e.getStyle()))}_o(e)&&(Et+=I);i.element.__lexicalTextContent=Et,Et=o+Et}function $t(t,e){if(t){const n=t.__last;if(n){const t=e.get(n);if(t)return En(t)?"line-break":ni(t)&&t.isInline()?"decorator":null}return"empty"}return null}function Ut(t,e,n){const r=$t(t,Nt),i=$t(e,Tt);r!==i&&e.getDOMSlot(n).setManagedLineBreak(i)}function Yt(t,e){const n=e.__lexicalDirTextContent||"",r=e.__lexicalDir||"";if(n!==bt||r!==Pt){const n=""===bt,i=n?Pt:function(t){if(K.test(t))return"rtl";if(B.test(t))return"ltr";return null}(bt);if(i!==r){const o=e.classList,s=pt.theme;let l=null!==r?s[r]:void 0,c=null!==i?s[i]:void 0;if(void 0!==l){if("string"==typeof l){const t=d(l);l=s[r]=t}o.remove(...l)}if(null===i||n&&"ltr"===i)e.removeAttribute("dir");else{if(void 0!==c){if("string"==typeof c){const t=d(c);c=s[i]=t}void 0!==c&&o.add(...c)}e.dir=i}if(!Dt){t.getWritable().__dir=i}}Pt=i,e.__lexicalDirTextContent=bt,e.__lexicalDir=i}}function Jt(e,n,r){const i=bt;var o;bt="",Mt=null,Ot="",function(e,n,r){const i=Et,o=e.__size,s=n.__size;Et="";const l=r.element;if(1===o&&1===s){const t=e.__first,r=n.__first;if(t===r)jt(t,l);else{const e=Xt(t),n=zt(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}It(t,null)}const i=Tt.get(r);Yn(i)&&(null===Mt&&(Mt=i.getFormat()),""===Ot&&(Ot=i.getStyle()))}else{const i=Ht(e,Nt),c=Ht(n,Tt);if(i.length!==o&&t(227),c.length!==s&&t(228),0===o)0!==s&&Wt(c,n,0,s-1,r);else if(0===s){if(0!==o){const t=null==r.after&&null==r.before&&null==r.element.__lexicalLineBreak;Lt(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=Gt(jt(r,o.element)),f++,d++;else{void 0===c&&(c=new Set(e)),void 0===a&&(a=new Set(n));const i=a.has(t),s=c.has(r);if(i)if(s){const t=po(yt,r);t===u?u=Gt(jt(r,o.element)):(o.withBefore(u).insertChild(t),jt(r,o.element)),f++,d++}else zt(r,o.withBefore(u)),d++;else u=Gt(Xt(t)),It(t,o.element),f++}const i=Tt.get(r);null!==i&&Yn(i)&&(null===Mt&&(Mt=i.getFormat()),""===Ot&&(Ot=i.getStyle()))}const h=f>s,g=d>l;if(h&&!g){const e=n[l+1],r=void 0===e?null:yt.getElementByKey(e);Wt(n,t,d,l,o.withBefore(r))}else g&&!h&&Lt(e,f,s,o.element)}(n,i,c,o,s,r)}_o(n)&&(Et+=I);l.__lexicalTextContent=Et,Et=i+Et}(e,n,n.getDOMSlot(r)),Yt(n,r),o=n,null==Mt||Mt===o.__textFormat||Dt||o.setTextFormat(Mt),function(t){""===Ot||Ot===t.__textStyle||Dt||t.setTextStyle(Ot)}(n),bt=i}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 jt(e,n){const r=Nt.get(e);let i=Tt.get(e);void 0!==r&&void 0!==i||t(61);const o=wt||St.has(e)||Ct.has(e),s=po(yt,e);if(r===i&&!o){if(Zr(r)){const t=s.__lexicalTextContent;void 0!==t&&(Et+=t,At+=t);const e=s.__lexicalDirTextContent;void 0!==e&&(bt+=e)}else{const t=r.getTextContent();Yn(r)&&!r.isDirectionless()&&(bt+=t),At+=t,Et+=t}return s}if(r!==i&&o&&ao(kt,mt,xt,i,"updated"),i.updateDOM(r,s,pt)){const r=zt(e,null);return null===n&&t(62),n.replaceChild(r,s),It(e,null),r}if(Zr(r)&&Zr(i)){const t=i.__indent;t!==r.__indent&&Kt(s,t);const e=i.__format;e!==r.__format&&Bt(s,e),o&&(Jt(r,i,s),ii(i)||i.isInline()||Ut(r,i,s)),_o(i)&&(Et+=I,At+=I)}else{const t=i.getTextContent();if(ni(i)){const t=i.decorate(yt,pt);null!==t&&Vt(e,t)}else Yn(i)&&!i.isDirectionless()&&(bt+=t);Et+=t,At+=t}if(!Dt&&ii(i)&&i.__cachedText!==At){const t=i.getWritable();t.__cachedText=At,i=t}return s}function Vt(t,e){let n=yt._pendingDecorators;const r=yt._decorators;if(null===n){if(r[t]===e)return;n=$i(yt)}n[t]=e}function Gt(t){let e=t.nextSibling;return null!==e&&e===yt._blockCursorElement&&(e=e.nextSibling),e}function qt(t,e,n,r,i,o){Et="",At="",bt="",wt=r===x,Pt=null,yt=n,pt=n._config,mt=n._nodes,xt=yt._listeners.mutation,Ct=i,St=o,Nt=t._nodeMap,Tt=e._nodeMap,Dt=e._readOnly,vt=new Map(n._keyToDOMMap);const s=new Map;return kt=s,jt("root",null),yt=void 0,mt=void 0,Ct=void 0,St=void 0,Nt=void 0,Tt=void 0,pt=void 0,vt=void 0,kt=void 0,s}function Xt(e){const n=vt.get(e);return void 0===n&&t(75,e),n}function Qt(t){return{type:t}}const Zt=Qt("SELECTION_CHANGE_COMMAND"),te=Qt("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),ee=Qt("CLICK_COMMAND"),ne=Qt("DELETE_CHARACTER_COMMAND"),re=Qt("INSERT_LINE_BREAK_COMMAND"),ie=Qt("INSERT_PARAGRAPH_COMMAND"),oe=Qt("CONTROLLED_TEXT_INSERTION_COMMAND"),se=Qt("PASTE_COMMAND"),le=Qt("REMOVE_TEXT_COMMAND"),ce=Qt("DELETE_WORD_COMMAND"),ae=Qt("DELETE_LINE_COMMAND"),ue=Qt("FORMAT_TEXT_COMMAND"),fe=Qt("UNDO_COMMAND"),de=Qt("REDO_COMMAND"),he=Qt("KEYDOWN_COMMAND"),ge=Qt("KEY_ARROW_RIGHT_COMMAND"),_e=Qt("MOVE_TO_END"),pe=Qt("KEY_ARROW_LEFT_COMMAND"),ye=Qt("MOVE_TO_START"),me=Qt("KEY_ARROW_UP_COMMAND"),xe=Qt("KEY_ARROW_DOWN_COMMAND"),Ce=Qt("KEY_ENTER_COMMAND"),Se=Qt("KEY_SPACE_COMMAND"),Ne=Qt("KEY_BACKSPACE_COMMAND"),Te=Qt("KEY_ESCAPE_COMMAND"),ve=Qt("KEY_DELETE_COMMAND"),ke=Qt("KEY_TAB_COMMAND"),Ee=Qt("INSERT_TAB_COMMAND"),be=Qt("INDENT_CONTENT_COMMAND"),Me=Qt("OUTDENT_CONTENT_COMMAND"),Oe=Qt("DROP_COMMAND"),Ae=Qt("FORMAT_ELEMENT_COMMAND"),we=Qt("DRAGSTART_COMMAND"),De=Qt("DRAGOVER_COMMAND"),Pe=Qt("DRAGEND_COMMAND"),Ie=Qt("COPY_COMMAND"),Le=Qt("CUT_COMMAND"),Fe=Qt("SELECT_ALL_COMMAND"),Re=Qt("CLEAR_EDITOR_COMMAND"),Ke=Qt("CLEAR_HISTORY_COMMAND"),Be=Qt("CAN_REDO_COMMAND"),ze=Qt("CAN_UNDO_COMMAND"),We=Qt("FOCUS_COMMAND"),$e=Qt("BLUR_COMMAND"),Ue=Qt("KEY_MODIFIER_COMMAND"),Ye=Object.freeze({}),Je=30,He=[["keydown",function(t,e){if(je=t.timeStamp,Ve=t.key,e.isComposing())return;if(go(e,he,t))return;if(null==t.key)return;if(nn&&so(t))return Gr(e,(()=>{hn(e,rn)})),nn=!1,void(rn="");if(function(t){return ro(t,"ArrowRight",{shiftKey:"any"})}(t))go(e,ge,t);else if(function(t){return ro(t,"ArrowRight",io)}(t))go(e,_e,t);else if(function(t){return ro(t,"ArrowLeft",{shiftKey:"any"})}(t))go(e,pe,t);else if(function(t){return ro(t,"ArrowLeft",io)}(t))go(e,ye,t);else if(function(t){return ro(t,"ArrowUp",{altKey:"any",shiftKey:"any"})}(t))go(e,me,t);else if(function(t){return ro(t,"ArrowDown",{altKey:"any",shiftKey:"any"})}(t))go(e,xe,t);else if(function(t){return ro(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any",shiftKey:!0})}(t))tn=!0,go(e,Ce,t);else if(function(t){return" "===t.key}(t))go(e,Se,t);else if(function(t){return r&&ro(t,"o",{ctrlKey:!0})}(t))t.preventDefault(),tn=!0,go(e,re,!0);else if(function(t){return ro(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any"})}(t))tn=!1,go(e,Ce,t);else if(function(t){return ro(t,"Backspace",{shiftKey:"any"})||r&&ro(t,"h",{ctrlKey:!0})}(t))so(t)?go(e,Ne,t):(t.preventDefault(),go(e,ne,!0));else if(function(t){return"Escape"===t.key}(t))go(e,Te,t);else if(function(t){return ro(t,"Delete",{})||r&&ro(t,"d",{ctrlKey:!0})}(t))!function(t){return"Delete"===t.key}(t)?(t.preventDefault(),go(e,ne,!1)):go(e,ve,t);else if(function(t){return ro(t,"Backspace",oo)}(t))t.preventDefault(),go(e,ce,!0);else if(function(t){return ro(t,"Delete",oo)}(t))t.preventDefault(),go(e,ce,!1);else if(function(t){return r&&ro(t,"Backspace",{metaKey:!0})}(t))t.preventDefault(),go(e,ae,!0);else if(function(t){return r&&(ro(t,"Delete",{metaKey:!0})||ro(t,"k",{ctrlKey:!0}))}(t))t.preventDefault(),go(e,ae,!1);else if(function(t){return ro(t,"b",io)}(t))t.preventDefault(),go(e,ue,"bold");else if(function(t){return ro(t,"u",io)}(t))t.preventDefault(),go(e,ue,"underline");else if(function(t){return ro(t,"i",io)}(t))t.preventDefault(),go(e,ue,"italic");else if(function(t){return ro(t,"Tab",{shiftKey:"any"})}(t))go(e,ke,t);else if(function(t){return ro(t,"z",io)}(t))t.preventDefault(),go(e,fe,void 0);else if(function(t){if(r)return ro(t,"z",{metaKey:!0,shiftKey:!0});return ro(t,"y",{ctrlKey:!0})||ro(t,"z",{ctrlKey:!0,shiftKey:!0})}(t))t.preventDefault(),go(e,de,void 0);else{const n=e._editorState._selection;null===n||tr(n)?lo(t)&&(t.preventDefault(),go(e,Fe,t)):!function(t){return ro(t,"c",io)}(t)?!function(t){return ro(t,"x",io)}(t)?lo(t)&&(t.preventDefault(),go(e,Fe,t)):(t.preventDefault(),go(e,Le,t)):(t.preventDefault(),go(e,Ie,t))}(function(t){return t.ctrlKey||t.shiftKey||t.altKey||t.metaKey})(t)&&go(e,Ue,t)}],["pointerdown",function(t,e){const n=t.target,r=t.pointerType;Lo(n)&&"touch"!==r&&"pen"!==r&&0===t.button&&Gr(e,(()=>{Si(n)||(Ze=!0)}))}],["compositionstart",function(t,e){Gr(e,(()=>{const n=pr();if(tr(n)&&!e.isComposing()){const r=n.anchor,i=n.anchor.getNode();Fi(r.key),(t.timeStamp<je+Je||"element"===r.type||!n.isCollapsed()||i.getFormat()!==n.format||Yn(i)&&i.getStyle()!==n.style)&&go(e,oe,L)}}))}],["compositionend",function(t,e){i?en=!0:l||!s&&!f?Gr(e,(()=>{hn(e,t.data)})):(nn=!0,rn=t.data)}],["input",function(t,e){t.stopPropagation(),Gr(e,(()=>{if(Io(t.target)&&Si(t.target))return;const n=pr(),r=t.data,c=dn(t);if(null!=r&&tr(n)&&ln(n,c,r,t.timeStamp,!1)){en&&(hn(e,r),en=!1);const c=n.anchor.getNode(),a=Do(To(e));if(null===a)return;const u=n.isBackward(),d=u?n.anchor.offset:n.focus.offset,h=u?n.focus.offset:n.anchor.offset;o&&!n.isCollapsed()&&Yn(c)&&null!==a.anchorNode&&c.getTextContent().slice(0,d)+r+c.getTextContent().slice(d+h)===Qi(a.anchorNode)||go(e,oe,r);const g=r.length;i&&g>1&&"insertCompositionText"===t.inputType&&!e.isComposing()&&(n.anchor.offset-=g),s||l||f||!e.isComposing()||(je=0,Fi(null))}else{Zi(!1,e,null!==r?r:void 0),en&&(hn(e,r||void 0),en=!1)}!function(){Ir();const t=Rr();rt(t)}()}),{event:t}),qe=null}],["click",function(t,e){Gr(e,(()=>{const n=pr(),r=Do(To(e)),i=yr();if(r)if(tr(n)){const e=n.anchor,o=e.getNode();if("element"===e.type&&0===e.offset&&n.isCollapsed()&&!ii(o)&&1===Yi().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=function(t,e){let n=t;for(;n!==Yi()&&null!=n;){if(e(n))return n;n=n.getParent()}return null}(o,(t=>Zr(t)&&!t.isInline()));Zr(t)&&t.select(0)}}}else if("touch"===t.pointerType||"pen"===t.pointerType){const n=r.anchorNode;if(Io(n)||Oi(n)){Hi(_r(i,r,e,t))}}go(e,ee,t)}))}],["cut",Ye],["copy",Ye],["dragstart",Ye],["dragover",Ye],["dragend",Ye],["paste",Ye],["focus",Ye],["blur",Ye],["drop",Ye]];o&&He.push(["beforeinput",(e,n)=>function(e,n){const r=e.inputType,o=dn(e);if("deleteCompositionText"===r||i&&ho(n))return;if("insertCompositionText"===r)return;Gr(n,(()=>{const i=pr();if("deleteContentBackward"===r){if(null===i){const t=yr();if(!tr(t))return;Hi(t.clone())}if(tr(i)){const r=i.anchor.key===i.focus.key;if(s=e.timeStamp,"MediaLast"===Ve&&s<je+Je&&n.isComposing()&&r){if(Fi(null),je=0,setTimeout((()=>{Gr(n,(()=>{Fi(null)}))}),Je),tr(i)){const e=i.anchor.getNode();e.markDirty(),Yn(e)||t(142),fn(i,e)}}else{Fi(null),e.preventDefault();const t=i.anchor.getNode(),o=t.getTextContent(),s=t.canInsertTextAfter(),l=0===i.anchor.offset&&i.focus.offset===o.length;let c=u&&r&&!l&&s;if(c&&i.isCollapsed()&&(c=!ni(fo(i.anchor,!0))),!c){go(n,ne,!0);const t=pr();u&&tr(t)&&t.isCollapsed()&&(on=t,setTimeout((()=>on=null)))}}return}}var s;if(!tr(i))return;const c=e.data;null!==qe&&Zi(!1,n,qe),i.dirty&&null===qe||!i.isCollapsed()||ii(i.anchor.getNode())||null===o||i.applyDOMRange(o),qe=null;const a=i.anchor,f=i.focus,d=a.getNode(),h=f.getNode();if("insertText"!==r&&"insertTranspose"!==r)switch(e.preventDefault(),r){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":go(n,oe,e);break;case"insertFromComposition":Fi(null),go(n,oe,e);break;case"insertLineBreak":Fi(null),go(n,re,!1);break;case"insertParagraph":Fi(null),tn&&!l?(tn=!1,go(n,re,!1)):go(n,ie,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":go(n,se,e);break;case"deleteByComposition":(function(t,e){return t!==e||Zr(t)||Zr(e)||!bi(t)||!bi(e)})(d,h)&&go(n,le,e);break;case"deleteByDrag":case"deleteByCut":go(n,le,e);break;case"deleteContent":go(n,ne,!1);break;case"deleteWordBackward":go(n,ce,!0);break;case"deleteWordForward":go(n,ce,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":go(n,ae,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":go(n,ae,!1);break;case"formatStrikeThrough":go(n,ue,"strikethrough");break;case"formatBold":go(n,ue,"bold");break;case"formatItalic":go(n,ue,"italic");break;case"formatUnderline":go(n,ue,"underline");break;case"historyUndo":go(n,fe,void 0);break;case"historyRedo":go(n,de,void 0)}else{if("\n"===c)e.preventDefault(),go(n,re,!1);else if(c===I)e.preventDefault(),go(n,ie,void 0);else if(null==c&&e.dataTransfer){const t=e.dataTransfer.getData("text/plain");e.preventDefault(),i.insertRawText(t)}else null!=c&&ln(i,o,c,e.timeStamp,!0)?(e.preventDefault(),go(n,oe,c)):qe=c;Ge=e.timeStamp}}))}(e,n)]);let je=0,Ve=null,Ge=0,qe=null;const Xe=new WeakMap;let Qe=!1,Ze=!1,tn=!1,en=!1,nn=!1,rn="",on=null,sn=[0,"",0,"root",0];function ln(t,e,n,r,i){const s=t.anchor,l=t.focus,c=s.getNode(),a=Rr(),u=Do(To(a)),f=null!==u?u.anchorNode:null,d=s.key,h=a.getElementByKey(d),g=n.length;return d!==l.key||!Yn(c)||(!i&&(!o||Ge<r+50)||c.isDirty()&&g<2||Gi(n))&&s.offset!==l.offset&&!c.isComposing()||Mi(c)||c.isDirty()&&g>1||(i||!o)&&null!==h&&!c.isComposing()&&f!==wi(h)||null!==u&&null!==e&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||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=bi(e);return 0===n?!e.canInsertTextBefore()||!r.canInsertTextBefore()&&!e.isComposing()||i||function(t){const e=t.getPreviousSibling();return(Yn(e)||Zr(e)&&e.isInline())&&!e.canInsertTextAfter()}(e):n===e.getTextContentSize()&&(!e.canInsertTextAfter()||!r.canInsertTextAfter()&&!e.isComposing()||i)}(t,c)}function cn(t,e){return Oi(t)&&null!==t.nodeValue&&0!==e&&e!==t.nodeValue.length}function an(e,n,r){const{anchorNode:i,anchorOffset:o,focusNode:s,focusOffset:l}=e;Qe&&(Qe=!1,cn(i,o)&&cn(s,l)&&!on)||Gr(n,(()=>{if(!r)return void Hi(null);if(!Ti(n,i,s))return;let c=pr();if(on&&tr(c)&&c.isCollapsed()){const t=c.anchor,e=on.anchor;(t.key===e.key&&t.offset===e.offset+1||1===t.offset&&e.getNode().is(t.getNode().getPreviousSibling()))&&(c=on.clone(),Hi(c))}if(on=null,tr(c)){const r=c.anchor,i=r.getNode();if(c.isCollapsed()){"Range"===e.type&&e.anchorNode===e.focusNode&&(c.dirty=!0);const o=To(n).event,s=o?o.timeStamp:performance.now(),[l,a,u,f,d]=sn,h=Yi(),g=!1===n.isComposing()&&""===h.getTextContent();if(s<d+200&&r.offset===u&&r.key===f)un(c,l,a);else if("text"===r.type)Yn(i)||t(141),fn(c,i);else if("element"===r.type&&!g){Zr(i)||t(259);const e=r.getNode();e.isEmpty()?function(t,e){const n=e.getTextFormat(),r=e.getTextStyle();un(t,n,r)}(c,e):un(c,0,"")}}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=E,g=!1;for(let t=0;t<i;t++){const e=n[t],r=e.getTextContentSize();if(Yn(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}}go(n,Zt,void 0)}))}function un(t,e,n){t.format===e&&t.style===n||(t.format=e,t.style=n,t.dirty=!0)}function fn(t,e){un(t,e.getFormat(),e.getStyle())}function dn(t){if(!t.getTargetRanges)return null;const e=t.getTargetRanges();return 0===e.length?null:e[0]}function hn(t,e){const n=t._compositionKey;if(Fi(null),null!==n&&null!=e){if(""===e){const e=Ki(n),r=wi(t.getElementByKey(n));return void(null!==r&&null!==r.nodeValue&&Yn(e)&&to(e,r.nodeValue,null,null,!0))}if("\n"===e[e.length-1]){const e=pr();if(tr(e)){const n=e.focus;return e.anchor.set(n.key,n.offset,n.type),void go(t,Ce,null)}}}Zi(!0,t,e)}function gn(t){let e=t.__lexicalEventHandles;return void 0===e&&(e=[],t.__lexicalEventHandles=e),e}const _n=new Map;function pn(t){const e=Po(t.target);if(null===e)return;const n=ki(e.anchorNode);if(null===n)return;Ze&&(Ze=!1,Gr(n,(()=>{const r=yr(),i=e.anchorNode;if(Io(i)||Oi(i)){Hi(_r(r,e,n,t))}})));const r=qi(n),i=r[r.length-1],o=i._key,s=_n.get(o),l=s||i;l!==n&&an(e,l,!1),an(e,n,!0),n!==i?_n.set(o,n):s&&_n.delete(o)}function yn(t){t._lexicalHandled=!0}function mn(t){return!0===t._lexicalHandled}const xn=()=>{};function Cn(e){const n=e.ownerDocument,r=Xe.get(n);if(void 0===r)return void xn();const i=r-1;i>=0||t(164),Xe.set(n,i),0===i&&n.removeEventListener("selectionchange",pn);const o=Ei(e);vi(o)?(!function(t){if(null!==t._parentEditor){const e=qi(t),n=e[e.length-1]._key;_n.get(n)===t&&_n.delete(n)}else _n.delete(t._key)}(o),e.__lexicalEditor=null):o&&t(198);const s=gn(e);for(let t=0;t<s.length;t++)s[t]();e.__lexicalEventHandles=[]}function Sn(t,e,n){Ir();const r=t.__key,i=t.getParent();if(null===i)return;const o=function(t){const e=pr();if(!tr(e)||!Zr(t))return e;const{anchor:n,focus:r}=e,i=n.getNode(),o=r.getNode();So(i,t)&&n.set(t.__key,0,"element");So(o,t)&&r.set(t.__key,0,"element");return e}(t);let s=!1;if(tr(o)&&e){const e=o.anchor,n=o.focus;e.key===r&&(Cr(e,t,i,t.getPreviousSibling(),t.getNextSibling()),s=!0),n.key===r&&(Cr(n,t,i,t.getPreviousSibling(),t.getNextSibling()),s=!0)}else nr(o)&&e&&t.isSelected()&&t.selectPrevious();if(tr(o)&&e&&!s){const e=t.getIndexWithinParent();Ii(t),mr(o,i,e,-1)}else Ii(t);n||ko(i)||i.canBeEmpty()||!i.isEmpty()||Sn(i,e),e&&o&&ii(i)&&i.isEmpty()&&i.selectEnd()}class Nn{static getType(){t(64,this.name)}static clone(e){t(65,this.name)}afterCloneFrom(t){this.__parent=t.__parent,this.__next=t.__next,this.__prev=t.__prev,this.__state=t.__state}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}),Pi(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=Ki(t);if(null===e)break;t=e.__parent}return!1}isSelected(t){const e=t||pr();if(null==e)return!1;const n=e.getNodes().some((t=>t.__key===this.__key));if(Yn(this))return n;if(tr(e)&&"element"===e.anchor.type&&"element"===e.focus.type){if(e.isCollapsed())return!1;const t=this.getParent();if(ni(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:Ki(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(ko(n))return Zr(e)||e===this&&ni(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:Ki(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:Ki(t)}getNextSiblings(){const t=[];let e=this.getNextSibling();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getCommonAncestor(t){const e=Zr(this)?this:this.getParent(),n=Zr(t)?t:t.getParent(),r=e&&n?vs(e,n):null;return r?r.commonAncestor:null}is(t){return null!=t&&this.__key===t.__key}isBefore(e){const n=vs(this,e);return null!==n&&("descendant"===n.type||("branch"===n.type?-1===Ss(n):("same"!==n.type&&"ancestor"!==n.type&&t(279),!1)))}isParentOf(t){const e=vs(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=Zr(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=Rr()._dirtyLeaves;return null!==t&&t.has(this.__key)}getLatest(){const e=Ki(this.__key);return null===e&&t(113),e}getWritable(){Ir();const t=Fr(),e=Rr(),n=t._nodeMap,r=this.__key,i=this.getLatest(),o=e._cloneNotNeeded,s=pr();if(null!==s&&s.setCachedNodes(null),o.has(r))return Li(i),i;const l=Yo(i);return o.add(r),Li(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();return(e||n.__state)&&ut(t).updateFromJSON(e),n}(this,t.$)}static transform(){return null}remove(t){Sn(this,!0,t)}replace(e,n){Ir();let r=pr();null!==r&&(r=r.clone()),Mo(this,e);const i=this.getLatest(),o=this.__key,s=e.__key,l=e.getWritable(),c=this.getParentOrThrow().getWritable(),a=c.__size;Ii(l);const u=i.getPreviousSibling(),f=i.getNextSibling(),d=i.__prev,h=i.__next,g=i.__parent;if(Sn(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&&(Zr(this)&&Zr(l)||t(139),this.getChildren().forEach((t=>{l.append(t)}))),tr(r)){Hi(r);const t=r.anchor,e=r.focus;t.key===o&&Qn(t,l),e.key===o&&Qn(e,l)}return Ri()===o&&Fi(s),l}insertAfter(t,e=!0){Ir(),Mo(this,t);const n=this.getWritable(),r=t.getWritable(),i=r.getParent(),o=pr();let s=!1,l=!1;if(null!==i){const e=t.getIndexWithinParent();if(Ii(r),tr(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&&tr(o)){const t=this.getIndexWithinParent();mr(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){Ir(),Mo(this,t);const n=this.getWritable(),r=t.getWritable(),i=r.__key;Ii(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=pr();if(e&&tr(a)){mr(a,this.getParentOrThrow(),c)}return t}isParentRequired(){return!1}createParentElementNode(){return pi()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(t,e){Ir();const n=this.getPreviousSibling(),r=this.getParentOrThrow();if(null===n)return r.select(0,0);if(Zr(n))return n.select();if(!Yn(n)){const t=n.getIndexWithinParent()+1;return r.select(t,t)}return n.select(t,e)}selectNext(t,e){Ir();const n=this.getNextSibling(),r=this.getParentOrThrow();if(null===n)return r.select();if(Zr(n))return n.select(0,0);if(!Yn(n)){const t=n.getIndexWithinParent();return r.select(t,t)}return n.select(t,e)}markDirty(){this.getWritable()}reconcileObservedMutation(t,e){this.markDirty()}}class Tn extends Nn{static getType(){return"linebreak"}static clone(t){return new Tn(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&&Ko(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&bn(n)){const n=e.lastChild;if(n===t||n.previousSibling===t&&bn(n))return!0}}return!1}(t)||function(t){const e=t.parentElement;if(null!==e&&Ko(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&bn(n))return!1;const r=e.lastChild;if(r===t||r.previousSibling===t&&bn(r))return!0}return!1}(t)?null:{conversion:vn,priority:0}}}static importJSON(t){return kn().updateFromJSON(t)}}function vn(t){return{node:kn()}}function kn(){return bo(new Tn)}function En(t){return t instanceof Tn}function bn(t){return Oi(t)&&/^( |\t|\r?\n)+$/.test(t.textContent||"")}function Mn(t,e){return 16&e?"code":e&k?"mark":32&e?"sub":64&e?"sup":null}function On(t,e){return 1&e?"strong":2&e?"em":"span"}function An(t,e,n,r,i){const o=r.classList;let s=co(i,"base");void 0!==s&&o.add(...s),s=co(i,"underlineStrikethrough");let l=!1;const c=e&v&&e&T;void 0!==s&&(n&v&&n&T?(l=!0,c||o.add(...s)):c&&o.remove(...s));for(const t in z){const r=z[t];if(s=co(i,t),void 0!==s)if(n&r){if(l&&("underline"===t||"strikethrough"===t)){e&r&&o.remove(...s);continue}e&r&&(!c||"underline"!==t)&&"strikethrough"!==t||o.add(...s)}else e&r&&o.remove(...s)}}function wn(t,e,n){const r=e.firstChild,o=n.isComposing(),s=t+(o?P:"");if(null==r)e.textContent=s;else{const t=r.nodeValue;if(t!==s)if(o||i){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 Dn(t,e,n,r,i,o){wn(i,t,e);const s=o.theme.text;void 0!==s&&An(0,0,r,t,s)}function Pn(t,e){const n=document.createElement(e);return n.appendChild(t),n}class In extends Nn{static getType(){return"text"}static clone(t){return new In(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===Ri()}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!!(this.getFormat()&e)}isSimpleText(){return"text"===this.__type&&0===this.__mode}getTextContent(){return this.getLatest().__text}getFormatFlags(t,e){return Di(this.getLatest().__format,t,e)}canHaveFormat(){return!0}isInline(){return!0}createDOM(t,e){const n=this.__format,r=Mn(0,n),i=On(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));Dn(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=Mn(0,o),c=Mn(0,s),a=On(0,o),u=On(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 Dn(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)),wn(i,f,this);const d=r.theme.text;void 0!==d&&o!==s&&An(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:Bn,priority:0}),b:()=>({conversion:Fn,priority:0}),code:()=>({conversion:$n,priority:0}),em:()=>({conversion:$n,priority:0}),i:()=>({conversion:$n,priority:0}),mark:()=>({conversion:$n,priority:0}),s:()=>({conversion:$n,priority:0}),span:()=>({conversion:Ln,priority:0}),strong:()=>({conversion:$n,priority:0}),sub:()=>({conversion:$n,priority:0}),sup:()=>({conversion:$n,priority:0}),u:()=>({conversion:$n,priority:0})}}static importJSON(t){return Un().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 Io(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=Pn(n,"b")),this.hasFormat("italic")&&(n=Pn(n,"i")),this.hasFormat("strikethrough")&&(n=Pn(n,"s")),this.hasFormat("underline")&&(n=Pn(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?W[t]:t,e}setStyle(t){const e=this.getWritable();return e.__style=t,e}toggleFormat(t){const e=Di(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=Y[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){Ir();let n=t,r=e;const i=pr(),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(!tr(i))return dr(s,n,s,r,"text","text");{const t=Ri();t!==i.anchor.key&&t!==i.focus.key||Fi(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=pr();if(r&&tr(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){Ir();const e=this.getLatest(),n=e.getTextContent();if(""===n)return[];const r=e.__key,i=Ri(),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=pr();if(tr(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=Un(a),f.__format=d,f.__style=h,f.__detail=g,_=!0):f=e.setTextContent(a);const x=[f];for(let t=1;t<c;t++){const e=Un(s[t]);e.__format=d,e.__style=h,e.__detail=g;const n=e.__key;i===r&&Fi(n),x.push(e)}const C=p?p.offset:null,S=y?y.offset:null;let N=0;for(const t of x){if(!p&&!y)break;const e=N+t.getTextContentSize();if(null!==p&&null!==C&&C<=e&&C>=N&&(p.set(t.getKey(),C-N,"text"),C<e&&(p=null)),null!==y&&null!==S&&S<=e&&S>=N){y.set(t.getKey(),S-N,"text");break}N=e}if(null!==u){!function(t){const e=t.getPreviousSibling(),n=t.getNextSibling();null!==e&&Li(e);null!==n&&Li(n)}(this);const t=u.getWritable(),e=this.getIndexWithinParent();_?(t.splice(e,0,x),this.remove()):t.splice(e,1,x),tr(m)&&mr(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;Ri()===i&&Fi(r);const l=pr();if(tr(l)){const t=l.anchor,o=l.focus;null!==t&&t.key===i&&Sr(t,n,r,e,s),null!==o&&o.key===i&&Sr(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 Ln(t){return{forChild:Jn(t.style),node:null}}function Fn(t){const e=t,n="normal"===e.style.fontWeight;return{forChild:Jn(e.style,n?void 0:"bold"),node:null}}const Rn=new WeakMap;function Kn(t){if(!Io(t))return!1;if("PRE"===t.nodeName)return!0;const e=t.style.whiteSpace;return"string"==typeof e&&e.startsWith("pre")}function Bn(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=Rn.get(n))&&!Kn(n);)r.push(n),n=n.parentNode;const i=void 0===e?n:e;for(let t=0;t<r.length;t++)Rn.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(kn()):"\t"===n?e.push(jn()):""!==n&&e.push(Un(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=zn(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=zn(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:Un(r)}}function zn(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,Io(n)){const t=n.style.display;if(""===t&&!Ro(n)||""!==t&&!t.startsWith("inline"))return null}let r=n;for(;null!==(r=e?n.firstChild:n.lastChild);)n=r;if(Oi(n))return n;if("BR"===n.nodeName)return null}}const Wn={code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function $n(t){const e=Wn[t.nodeName.toLowerCase()];return void 0===e?{node:null}:{forChild:Jn(t.style,e),node:null}}function Un(t=""){return bo(new In(t))}function Yn(t){return t instanceof In}function Jn(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=>Yn(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 Hn extends In{static getType(){return"tab"}static clone(t){return new Hn(t.__key)}constructor(t){super("\t",t),this.__detail=2}static importDOM(){return null}createDOM(t){const e=super.createDOM(t),n=co(t.theme,"tab");if(void 0!==n){e.classList.add(...n)}return e}static importJSON(t){return jn().updateFromJSON(t)}setTextContent(e){return"\t"!==e&&""!==e&&t(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 jn(){return bo(new Hn)}function Vn(t){return t instanceof Hn}class Gn{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 Cs(Is(ks(this,"next")),Is(ks(t,"next")))<0}getNode(){const e=Ki(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,Pr()||(Ri()===o&&Fi(t),null!==i&&(i.setCachedNodes(null),i.dirty=!0)))}}function qn(t,e,n){return new Gn(t,e,n)}function Xn(t,e){let n=e.__key,r=t.offset,i="element";if(Yn(e)){i="text";const t=e.getTextContentSize();r>t&&(r=t)}else if(!Zr(e)){const t=e.getNextSibling();if(Yn(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 Qn(t,e){if(Zr(e)){const n=e.getLastDescendant();Zr(n)||Yn(n)?Xn(t,n):Xn(t,e)}else Xn(t,e)}class Zn{constructor(t){this._cachedNodes=null,this._nodes=t,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){if(!nr(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 Zn(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(Yn(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=Ki(t);null!==e&&n.push(e)}return Pr()||(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((pr()||yr())===this&&t[0]){const e=ls(t[0],"next");bs(ms(e,e))}for(const e of t)e.remove()}}function tr(t){return t instanceof er}class er{constructor(t,e,n,r){this.anchor=t,this.focus=e,t._selection=this,e._selection=this,this._cachedNodes=null,this.format=n,this.style=r,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){return!!tr(t)&&(this.anchor.is(t.anchor)&&this.focus.is(t.focus)&&this.format===t.format&&this.style===t.style)}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){const t=this._cachedNodes;if(null!==t)return t;const e=function(t){const e=[],[n,r]=t.getTextSlices();n&&e.push(n.caret.origin);const i=new Set,o=new Set;for(const n of t)if(rs(n)){const{origin:t}=n;0===e.length?i.add(t):(o.add(t),e.push(t))}else{const{origin:t}=n;Zr(t)&&o.has(t)||e.push(t)}r&&e.push(r.caret.origin);if(ns(t.focus)&&Zr(t.focus.origin)&&null===t.focus.getNodeAtCaret())for(let n=fs(t.focus.origin,"previous");rs(n)&&i.has(n.origin)&&!n.origin.isEmpty()&&n.origin.is(e[e.length-1]);n=hs(n))i.delete(n.origin),e.pop();for(;e.length>1;){const t=e[e.length-1];if(!Zr(t)||o.has(t)||t.isEmpty()||i.has(t))break;e.pop()}if(0===e.length&&t.isCollapsed()){const n=Is(t.anchor),r=Is(t.anchor.getFlipped()),i=t=>es(t)?t.origin:t.getNodeAtCaret(),o=i(n)||i(r)||(t.anchor.getNodeAtCaret()?n.origin:r.origin);e.push(o)}return e}(Rs(Os(this),"next"));return Pr()||(this._cachedNodes=e),e}setTextNodeRange(t,e,n,r){this.anchor.set(t.__key,e,"text"),this.focus.set(n.__key,r,"text")}getTextContent(){const t=this.getNodes();if(0===t.length)return"";const e=t[0],n=t[t.length-1],r=this.anchor,i=this.focus,o=r.isBefore(i),[s,l]=ir(this);let c="",a=!0;for(let u=0;u<t.length;u++){const f=t[u];if(Zr(f)&&!f.isInline())a||(c+="\n"),a=!f.isEmpty();else if(a=!1,Yn(f)){let t=f.getTextContent();f===e?f===n?"element"===r.type&&"element"===i.type&&i.offset!==r.offset||(t=s<l?t.slice(s,l):t.slice(l,s)):t=o?t.slice(s):t.slice(l):f===n&&(t=o?t.slice(0,l):t.slice(0,s)),c+=t}else!ni(f)&&!En(f)||f===n&&this.isCollapsed()||(c+=f.getTextContent())}return c}applyDOMRange(t){const e=Rr(),n=e.getEditorState()._selection,r=fr(t.startContainer,t.startOffset,t.endContainer,t.endOffset,e,n);if(null===r)return;const[i,o]=r;this.anchor.set(i.key,i.offset,i.type,!0),this.focus.set(o.key,o.offset,o.type,!0),gt(this)}clone(){const t=this.anchor,e=this.focus;return new er(qn(t.key,t.offset,t.type),qn(e.key,e.offset,e.type),this.format,this.style)}toggleFormat(t){this.format=Di(this.format,t,null),this.dirty=!0}setStyle(t){this.style=t,this.dirty=!0}hasFormat(t){const e=z[t];return!!(this.format&e)}insertRawText(t){const e=t.split(/(\r?\n|\t)/),n=[],r=e.length;for(let t=0;t<r;t++){const r=e[t];"\n"===r||"\r\n"===r?n.push(kn()):"\t"===r?n.push(jn()):n.push(Un(r))}this.insertNodes(n)}insertText(e){const n=this.anchor,r=this.focus,i=this.format,o=this.style;let s=n,l=r;!this.isCollapsed()&&r.isBefore(n)&&(s=r,l=n),"element"===s.type&&function(t,e,n,r){const i=t.getNode(),o=i.getChildAtIndex(t.offset),s=Un(),l=ii(i)?pi().append(s):s;s.setFormat(n),s.setStyle(r),null===o?i.append(l):o.insertBefore(l),t.is(e)&&e.set(s.__key,0,"text"),t.set(s.__key,0,"text")}(s,l,i,o),"element"===l.type&&Es(l,Is(ks(l,"next")));const c=s.offset;let a=l.offset;const u=this.getNodes(),f=u.length;let d=u[0];Yn(d)||t(26);const h=d.getTextContent().length,g=d.getParentOrThrow();let _=u[f-1];if(1===f&&"element"===l.type&&(a=h,l.set(s.key,a,"text")),this.isCollapsed()&&c===h&&(Mi(d)||!d.canInsertTextAfter()||!g.canInsertTextAfter()&&null===d.getNextSibling())){let t=d.getNextSibling();if(Yn(t)&&t.canInsertTextBefore()&&!Mi(t)||(t=Un(),t.setFormat(i),t.setStyle(o),g.canInsertTextAfter()?d.insertAfter(t):g.insertAfter(t)),t.select(0,0),d=t,""!==e)return void this.insertText(e)}else if(this.isCollapsed()&&0===c&&(Mi(d)||!d.canInsertTextBefore()||!g.canInsertTextBefore()&&null===d.getPreviousSibling())){let t=d.getPreviousSibling();if(Yn(t)&&!Mi(t)||(t=Un(),t.setFormat(i),g.canInsertTextBefore()?d.insertBefore(t):g.insertBefore(t)),t.select(),d=t,""!==e)return void this.insertText(e)}else if(d.isSegmented()&&c!==h){const t=Un(d.getTextContent());t.setFormat(i),d.replace(t),d=t}else if(!this.isCollapsed()&&""!==e){const t=_.getParent();if(!g.canInsertTextBefore()||!g.canInsertTextAfter()||Zr(t)&&(!t.canInsertTextBefore()||!t.canInsertTextAfter()))return this.insertText(""),ur(this.anchor,this.focus,null),void this.insertText(e)}if(1===f){if(bi(d)){const t=Un(e);return t.select(),void d.replace(t)}const t=d.getFormat(),n=d.getStyle();if(c!==a||t===i&&n===o){if(Vn(d)){const t=Un(e);return t.setFormat(i),t.setStyle(o),t.select(),void d.replace(t)}}else{if(""!==d.getTextContent()){const t=Un(e);if(t.setFormat(i),t.setStyle(o),t.select(),0===c)d.insertBefore(t,!1);else{const[e]=d.splitText(c);e.insertAfter(t,!1)}return void(t.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=e.length))}d.setFormat(i),d.setStyle(o)}const r=a-c;d=d.spliceText(c,r,e,!0),""===d.getTextContent()?d.remove():"text"===this.anchor.type&&(d.isComposing()?this.anchor.offset-=e.length:(this.format=t,this.style=n))}else{const t=new Set([...d.getParentKeys(),..._.getParentKeys()]),n=Zr(d)?d:d.getParentOrThrow();let r=Zr(_)?_:_.getParentOrThrow(),i=_;if(!n.is(r)&&r.isInline())do{i=r,r=r.getParentOrThrow()}while(r.isInline());if("text"===l.type&&(0!==a||""===_.getTextContent())||"element"===l.type&&_.getIndexWithinParent()<a)if(Yn(_)&&!bi(_)&&a!==_.getTextContentSize()){if(_.isSegmented()){const t=Un(_.getTextContent());_.replace(t),_=t}ii(l.getNode())||"text"!==l.type||(_=_.spliceText(0,a,"")),t.add(_.__key)}else{const t=_.getParentOrThrow();t.canBeEmpty()||1!==t.getChildrenSize()?_.remove():t.remove()}else t.add(_.__key);const o=r.getChildren(),s=new Set(u),g=n.is(r),p=n.isInline()&&null===d.getNextSibling()?n:d;for(let t=o.length-1;t>=0;t--){const e=o[t];if(e.is(d)||Zr(e)&&e.isParentOf(d))break;e.isAttached()&&(!s.has(e)||e.is(i)?g||p.insertAfter(e,!1):e.remove())}if(!g){let e=r,n=null;for(;null!==e;){const r=e.getChildren(),i=r.length;(0===i||r[i-1].is(n))&&(t.delete(e.__key),n=e),e=e.getParent()}}if(bi(d))if(c===h)d.select();else{const t=Un(e);t.select(),d.replace(t)}else d=d.spliceText(c,h-c,e,!0),""===d.getTextContent()?d.remove():d.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=e.length);for(let e=1;e<f;e++){const n=u[e],r=n.__key;t.has(r)||n.remove()}}}removeText(){const t=pr()===this;Ms(this,Ps(Os(this))),t&&pr()!==this&&Hi(this)}formatText(t,e=null){if(this.isCollapsed())return this.toggleFormat(t),void Fi(null);const n=this.getNodes(),r=[];for(const t of n)Yn(t)&&r.push(t);const i=e=>{n.forEach((n=>{if(Zr(n)){const r=n.getFormatFlags(t,e);n.setTextFormat(r)}}))},o=r.length;if(0===o)return this.toggleFormat(t),Fi(null),void i(e);const s=this.anchor,l=this.focus,c=this.isBackward(),a=c?l:s,u=c?s:l;let f=0,d=r[0],h="element"===a.type?0:a.offset;if("text"===a.type&&h===d.getTextContentSize()&&(f=1,d=r[1],h=0),null==d)return;const g=d.getFormatFlags(t,e);i(g);const _=o-1;let p=r[_];const y="text"===u.type?u.offset:p.getTextContentSize();if(d.is(p)){if(h===y)return;if(Mi(d)||0===h&&y===d.getTextContentSize())d.setFormat(g);else{const t=d.splitText(h,y),e=0===h?t[0]:t[1];e.setFormat(g),"text"===a.type&&a.set(e.__key,0,"text"),"text"===u.type&&u.set(e.__key,y-h,"text")}return void(this.format=g)}0===h||Mi(d)||([,d]=d.splitText(h),h=0),d.setFormat(g);const m=p.getFormatFlags(t,g);y>0&&(y===p.getTextContentSize()||Mi(p)||([p]=p.splitText(y)),p.setFormat(m));for(let e=f+1;e<_;e++){const n=r[e],i=n.getFormatFlags(t,m);n.setFormat(i)}"text"===a.type&&a.set(d.__key,h,"text"),"text"===u.type&&u.set(p.__key,y,"text"),this.format=g|m}insertNodes(e){if(0===e.length)return;if(this.isCollapsed()||this.removeText(),"root"===this.anchor.key){this.insertParagraph();const n=pr();return tr(n)||t(134),n.insertNodes(e)}const n=(this.isBackward()?this.focus:this.anchor).getNode(),r=zo(n,Bo),i=e[e.length-1];if(Zr(r)&&"__language"in r){if("__language"in e[0])this.insertText(e[0].getTextContent());else{const t=vr(this);r.splice(t,0,e),i.selectEnd()}return}if(!e.some((t=>(Zr(t)||ni(t))&&!t.isInline()))){Zr(r)||t(211,n.constructor.name,n.getType());const o=vr(this);return r.splice(o,0,e),void i.selectEnd()}const o=function(t){const e=pi();let n=null;for(let r=0;r<t.length;r++){const i=t[r],o=En(i);if(o||ni(i)&&i.isInline()||Zr(i)&&i.isInline()||Yn(i)||i.isParentRequired()){if(null===n&&(n=i.createParentElementNode(),e.append(n),o))continue;null!==n&&n.append(i)}else e.append(i),n=null}return e}(e),s=o.getLastDescendant(),l=o.getChildren(),c=!Zr(r)||!r.isEmpty()?this.insertParagraph():null,a=l[l.length-1];let u=l[0];var f;Zr(f=u)&&Bo(f)&&!f.isEmpty()&&Zr(r)&&(!r.isEmpty()||r.canMergeWhenEmpty())&&(Zr(r)||t(211,n.constructor.name,n.getType()),r.append(...u.getChildren()),u=l[1]),u&&(null===r&&t(212,n.constructor.name,n.getType()),function(e,n,r){const i=n.getParentOrThrow().getLastChild();let o=n;const s=[n];for(;o!==i;)o.getNextSibling()||t(140),o=o.getNextSibling(),s.push(o);let l=e;for(const t of s)l=l.insertAfter(t)}(r,u));const d=zo(s,Bo);c&&Zr(d)&&(c.canMergeWhenEmpty()||Bo(a))&&(d.append(...c.getChildren()),c.remove()),Zr(r)&&r.isEmpty()&&r.remove(),s.selectEnd();const h=Zr(r)?r.getLastChild():null;En(h)&&d!==r&&h.remove()}insertParagraph(){if("root"===this.anchor.key){const t=pi();return Yi().splice(this.anchor.offset,0,[t]),t.select(),t}const e=vr(this),n=zo(this.anchor.getNode(),Bo);Zr(n)||t(213);const r=n.getChildAtIndex(e),i=r?[r,...r.getNextSiblings()]:[],o=n.insertNewAfter(this,!1);return o?(o.append(...i),o.selectStart(),o):null}insertLineBreak(t){const e=kn();if(this.insertNodes([e]),t){const t=e.getParentOrThrow(),n=e.getIndexWithinParent();t.select(n,n)}}extract(){const t=this.getNodes(),e=t.length,n=e-1,r=this.anchor,i=this.focus;let o=t[0],s=t[n];const[l,c]=ir(this);if(0===e)return[];if(1===e){if(Yn(o)&&!this.isCollapsed()){const t=l>c?c:l,e=l>c?l:c,n=o.splitText(t,e),r=0===t?n[0]:n[1];return null!=r?[r]:[]}return[o]}const a=r.isBefore(i);if(Yn(o)){const e=a?l:c;e===o.getTextContentSize()?t.shift():0!==e&&([,o]=o.splitText(e),t[0]=o)}if(Yn(s)){const e=s.getTextContent().length,r=a?c:l;0===r?t.pop():r!==e&&([s]=s.splitText(r),t[n]=s)}return t}modify(t,e,n){if(Er(this,t,e,n))return;const r="move"===t,i=Rr(),o=Do(To(i));if(!o)return;const s=i._blockCursorElement,l=i._rootElement,c=this.focus.getNode();if(null===l||null===s||!Zr(c)||c.isInline()||c.canBeEmpty()||wo(s,i,l),this.dirty){let t=po(i,this.anchor.key),e=po(i,this.focus.key);"text"===this.anchor.type&&(t=wi(t)),"text"===this.focus.type&&(e=wi(e)),t&&e&&Nr(o,t,this.anchor.offset,e,this.focus.offset)}if(function(t,e,n,r){t.modify(e,n,r)}(o,t,e?"backward":"forward",n),o.rangeCount>0){const t=o.getRangeAt(0),n=this.anchor.getNode(),i=ii(n)?n:vo(n);if(this.applyDOMRange(t),this.dirty=!0,!r){const n=this.getNodes(),r=[];let s=!1;for(let t=0;t<n.length;t++){const e=n[t];So(e,i)?r.push(e):s=!0}if(s&&r.length>0)if(e){const t=r[0];Zr(t)?t.selectStart():t.getParentOrThrow().selectStart()}else{const t=r[r.length-1];Zr(t)?t.selectEnd():t.getParentOrThrow().selectEnd()}o.anchorNode===t.startContainer&&o.anchorOffset===t.startOffset||function(t){const e=t.focus,n=t.anchor,r=n.key,i=n.offset,o=n.type;n.set(e.key,e.offset,e.type,!0),e.set(r,i,o,!0)}(this)}}"lineboundary"===n&&Er(this,t,e,n,"decorators")}forwardDeletion(t,e,n){if(!n&&("element"===t.type&&Zr(e)&&t.offset===e.getChildrenSize()||"text"===t.type&&t.offset===e.getTextContentSize())){const t=e.getParent(),n=e.getNextSibling()||(null===t?null:t.getNextSibling());if(Zr(n)&&n.isShadowRoot())return!0}return!1}deleteCharacter(t){const e=this.isCollapsed();if(this.isCollapsed()){const e=this.anchor;let n=e.getNode();if(this.forwardDeletion(e,n,t))return;const r=ps(ks(e,t?"previous":"next"));if(r.getTextSlices().every((t=>null===t||0===t.distance))){let t={type:"initial"};for(const e of r.iterNodeCarets("shadowRoot"))if(rs(e))if(e.origin.isInline());else{if(e.origin.isShadowRoot()){if("merge-block"===t.type)break;if(Zr(r.anchor.origin)&&r.anchor.origin.isEmpty()){const t=Is(e);Ms(this,ms(t,t)),r.anchor.origin.remove()}return}"merge-next-block"!==t.type&&"merge-block"!==t.type||(t={block:t.block,caret:e,type:"merge-block"})}else{if("merge-block"===t.type)break;if(ns(e)){if(Zr(e.origin)){if(e.origin.isInline()){if(!e.origin.isParentOf(r.anchor.origin))break}else t={block:e.origin,type:"merge-next-block"};continue}if(ni(e.origin)){if(e.origin.isIsolated());else if("merge-next-block"===t.type&&(e.origin.isKeyboardSelectable()||!e.origin.isInline())&&Zr(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();const t=gr();t.add(e.origin.getKey()),Hi(t)}else e.origin.remove();return}break}}if("merge-block"===t.type){const{caret:e,block:n}=t;return Ms(this,ms(!e.origin.isEmpty()&&n.isEmpty()?As(ls(n,e.direction)):r.anchor,e)),this.removeText()}}const i=this.focus;if(this.modify("extend",t,"character"),this.isCollapsed()){if(t&&0===e.offset&&or(this,e.getNode()))return}else{const r="text"===i.type?i.getNode():null;if(n="text"===e.type?e.getNode():null,null!==r&&r.isSegmented()){const e=i.offset,o=r.getTextContentSize();if(r.is(n)||t&&e!==o||!t&&0!==e)return void lr(r,t,e)}else if(null!==n&&n.isSegmented()){const i=e.offset,o=n.getTextContentSize();if(n.is(r)||t&&0!==i||!t&&i!==o)return void lr(n,t,i)}!function(t,e){const n=t.anchor,r=t.focus,i=n.getNode(),o=r.getNode();if(i===o&&"text"===n.type&&"text"===r.type){const t=n.offset,o=r.offset,s=t<o,l=s?t:o,c=s?o:t,a=c-1;if(l!==a){(function(t){return!(Gi(t)||sr(t))})(i.getTextContent().slice(l,c))&&(e?r.set(r.key,a,r.type):n.set(n.key,a,n.type))}}}(this,t)}}if(this.removeText(),t&&!e&&this.isCollapsed()&&"element"===this.anchor.type&&0===this.anchor.offset){const t=this.anchor.getNode();t.isEmpty()&&ii(t.getParent())&&null===t.getPreviousSibling()&&or(this,t)}}deleteLine(t){this.isCollapsed()&&this.modify("extend",t,"lineboundary"),this.isCollapsed()?this.deleteCharacter(t):this.removeText()}deleteWord(t){if(this.isCollapsed()){const e=this.anchor,n=e.getNode();if(this.forwardDeletion(e,n,t))return;this.modify("extend",t,"word")}this.removeText()}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return[this.anchor,this.focus]}}function nr(t){return t instanceof Zn}function rr(t){const e=t.offset;if("text"===t.type)return e;const n=t.getNode();return e===n.getChildrenSize()?n.getTextContent().length:0}function ir(t){const e=t.getStartEndPoints();if(null===e)return[0,0];const[n,r]=e;return"element"===n.type&&"element"===r.type&&n.key===r.key&&n.offset===r.offset?[0,0]:[rr(n),rr(r)]}function or(t,e){for(let n=e;n;n=n.getParent()){if(Zr(n)){if(n.collapseAtStart(t))return!0;if(ko(n))break}if(n.getPreviousSibling())break}return!1}const sr=(()=>{try{const t=new RegExp("\\p{Emoji}","u"),e=t.test.bind(t);if(e("❤️")&&e("#️⃣")&&e("👍"))return e}catch(t){}return()=>!1})();function lr(t,e,n){const r=t,i=r.getTextContent().split(/(?=\s)/g),o=i.length;let s=0,l=0;for(let t=0;t<o;t++){const r=t===o-1;if(l=s,s+=i[t].length,e&&s===n||s>n||r){i.splice(t,1),r&&(l=void 0);break}}const c=i.join("").trim();""===c?r.remove():(r.setTextContent(c),r.select(l,l))}function cr(e,n,r,i){let o,s=n;if(Io(e)){let l=!1;const c=e.childNodes,a=c.length,u=i._blockCursorElement;s===a&&(l=!0,s=a-1);let f=c[s],d=!1;if(f===u)f=c[s+1],d=!0;else if(null!==u){const t=u.parentNode;if(e===t){n>Array.prototype.indexOf.call(t.children,u)&&s--}}if(o=ji(f),Yn(o))s=Vi(o,l);else{let c=ji(e);if(null===c)return null;if(Zr(c)){const a=i.getElementByKey(c.getKey());null===a&&t(214);const u=c.getDOMSlot(a);[c,s]=u.resolveChildIndex(c,a,e,n),Zr(c)||t(215),l&&s>=c.getChildrenSize()&&(s=Math.max(0,c.getChildrenSize()-1));let f=c.getChildAtIndex(s);if(Zr(f)&&function(t,e,n){const r=t.getParent();return null===n||null===r||!r.canBeEmpty()||r!==n.getNode()}(f,0,r)){const t=l?f.getLastDescendant():f.getFirstDescendant();null===t?c=f:(f=t,c=Zr(f)?f:f.getParentOrThrow()),s=0}Yn(f)?(o=f,c=null,s=Vi(f,l)):f!==c&&l&&!d&&(Zr(c)||t(216),s=Math.min(c.getChildrenSize(),s+1))}else{const t=c.getIndexWithinParent();s=0===n&&ni(c)&&ji(e)===c?t:t+1,c=c.getParentOrThrow()}if(Zr(c))return qn(c.__key,s,"element")}}else o=ji(e);return Yn(o)?qn(o.__key,s,"text"):null}function ar(t,e,n){const r=t.offset,i=t.getNode();if(0===r){const r=i.getPreviousSibling(),o=i.getParent();if(e){if((n||!e)&&null===r&&Zr(o)&&o.isInline()){const e=o.getPreviousSibling();Yn(e)&&t.set(e.__key,e.getTextContent().length,"text")}}else Zr(r)&&!n&&r.isInline()?t.set(r.__key,r.getChildrenSize(),"element"):Yn(r)&&t.set(r.__key,r.getTextContent().length,"text")}else if(r===i.getTextContent().length){const r=i.getNextSibling(),o=i.getParent();if(e&&Zr(r)&&r.isInline())t.set(r.__key,0,"element");else if((n||e)&&null===r&&Zr(o)&&o.isInline()&&!o.canInsertTextAfter()){const e=o.getNextSibling();Yn(e)&&t.set(e.__key,0,"text")}}}function ur(t,e,n){if("text"===t.type&&"text"===e.type){const r=t.isBefore(e),i=t.is(e);ar(t,r,i),ar(e,!r,i),i&&e.set(t.key,t.offset,t.type);const o=Rr();if(o.isComposing()&&o._compositionKey!==t.key&&tr(n)){const r=n.anchor,i=n.focus;t.set(r.key,r.offset,r.type,!0),e.set(i.key,i.offset,i.type,!0)}}}function fr(t,e,n,r,i,o){if(null===t||null===n||!Ti(i,t,n))return null;const s=cr(t,e,tr(o)?o.anchor:null,i);if(null===s)return null;const l=cr(n,r,tr(o)?o.focus:null,i);if(null===l)return null;if("element"===s.type&&"element"===l.type){const e=ji(t),r=ji(n);if(ni(e)&&ni(r))return null}return ur(s,l,o),[s,l]}function dr(t,e,n,r,i,o){const s=Fr(),l=new er(qn(t,e,i),qn(n,r,o),0,"");return l.dirty=!0,s._selection=l,l}function hr(){const t=qn("root",0,"element"),e=qn("root",0,"element");return new er(t,e,0,"")}function gr(){return new Zn(new Set)}function _r(t,e,n,r){const i=n._window;if(null===i)return null;const o=r||i.event,s=o?o.type:void 0,l="selectionchange"===s,c=!G&&(l||"beforeinput"===s||"compositionstart"===s||"compositionend"===s||"click"===s&&o&&3===o.detail||"drop"===s||void 0===s);let a,u,f,d;if(tr(t)&&!c)return t.clone();if(null===e)return null;if(a=e.anchorNode,u=e.focusNode,f=e.anchorOffset,d=e.focusOffset,l&&tr(t)&&!Ti(n,a,u))return t.clone();const h=fr(a,f,u,d,n,t);if(null===h)return null;const[g,_]=h;return new er(g,_,tr(t)?t.format:0,tr(t)?t.style:"")}function pr(){return Fr()._selection}function yr(){return Rr()._editorState._selection}function mr(t,e,n,r=1){const i=t.anchor,o=t.focus,s=i.getNode(),l=o.getNode();if(!e.is(s)&&!e.is(l))return;const c=e.__key;if(t.isCollapsed()){const e=i.offset;if(n<=e&&r>0||n<e&&r<0){const n=Math.max(0,e+r);i.set(c,n,"element"),o.set(c,n,"element"),xr(t)}}else{const s=t.isBackward(),l=s?o:i,a=l.getNode(),u=s?i:o,f=u.getNode();if(e.is(a)){const t=l.offset;(n<=t&&r>0||n<t&&r<0)&&l.set(c,Math.max(0,t+r),"element")}if(e.is(f)){const t=u.offset;(n<=t&&r>0||n<t&&r<0)&&u.set(c,Math.max(0,t+r),"element")}}xr(t)}function xr(t){const e=t.anchor,n=e.offset,r=t.focus,i=r.offset,o=e.getNode(),s=r.getNode();if(t.isCollapsed()){if(!Zr(o))return;const t=o.getChildrenSize(),i=n>=t,s=i?o.getChildAtIndex(t-1):o.getChildAtIndex(n);if(Yn(s)){let t=0;i&&(t=s.getTextContentSize()),e.set(s.__key,t,"text"),r.set(s.__key,t,"text")}}else{if(Zr(o)){const t=o.getChildrenSize(),r=n>=t,i=r?o.getChildAtIndex(t-1):o.getChildAtIndex(n);if(Yn(i)){let t=0;r&&(t=i.getTextContentSize()),e.set(i.__key,t,"text")}}if(Zr(s)){const t=s.getChildrenSize(),e=i>=t,n=e?s.getChildAtIndex(t-1):s.getChildAtIndex(i);if(Yn(n)){let t=0;e&&(t=n.getTextContentSize()),r.set(n.__key,t,"text")}}}}function Cr(t,e,n,r,i){let o=null,s=0,l=null;null!==r?(o=r.__key,Yn(r)?(s=r.getTextContentSize(),l="text"):Zr(r)&&(s=r.getChildrenSize(),l="element")):null!==i&&(o=i.__key,Yn(i)?l="text":Zr(i)&&(l="element")),null!==o&&null!==l?t.set(o,s,l):(s=e.getIndexWithinParent(),-1===s&&(s=n.getChildrenSize()),t.set(n.__key,s,"element"))}function Sr(t,e,n,r,i){"text"===t.type?t.set(n,t.offset+(e?0:i),"text"):t.offset>r.getIndexWithinParent()&&t.set(t.key,t.offset-1,"element")}function Nr(t,e,n,r,i){try{t.setBaseAndExtent(e,n,r,i)}catch(t){}}function Tr(t,e,n,r,i,o,s){const l=r.anchorNode,c=r.focusNode,a=r.anchorOffset,u=r.focusOffset,f=document.activeElement;if(i.has(ui)&&f!==o||null!==f&&Ni(f))return;if(!tr(e))return void(null!==t&&Ti(n,l,c)&&r.removeAllRanges());const d=e.anchor,h=e.focus,g=d.key,_=h.key,p=po(n,g),y=po(n,_),m=d.offset,x=h.offset,C=e.format,S=e.style,N=e.isCollapsed();let T=p,v=y,k=!1;if("text"===d.type){T=wi(p);const t=d.getNode();k=t.getFormat()!==C||t.getStyle()!==S}else tr(t)&&"text"===t.anchor.type&&(k=!0);var E,b,M,O,A;if(("text"===h.type&&(v=wi(y)),null!==T&&null!==v)&&(N&&(null===t||k||tr(t)&&(t.format!==C||t.style!==S))&&(E=C,b=S,M=m,O=g,A=performance.now(),sn=[E,b,M,O,A]),a!==m||u!==x||l!==T||c!==v||"Range"===r.type&&N||(null!==f&&o.contains(f)||o.focus({preventScroll:!0}),"element"===d.type))){if(Nr(r,T,m,v,x),!i.has(fi)&&e.isCollapsed()&&null!==o&&o===document.activeElement){const t=tr(e)&&"element"===e.anchor.type?T.childNodes[m]||null:r.rangeCount>0?r.getRangeAt(0):null;if(null!==t){let e;if(t instanceof Text){const n=document.createRange();n.selectNode(t),e=n.getBoundingClientRect()}else e=t.getBoundingClientRect();!function(t,e,n){const r=mo(n),i=No(r);if(null===r||null===i)return;let{top:o,bottom:s}=e,l=0,c=0,a=n;for(;null!==a;){const e=a===r.body;if(e)l=0,c=To(t).innerHeight;else{const t=a.getBoundingClientRect();l=t.top,c=t.bottom}let n=0;if(o<l?n=-(l-o):s>c&&(n=s-c),0!==n)if(e)i.scrollBy(0,n);else{const t=a.scrollTop;a.scrollTop+=n;const e=a.scrollTop-t;o-=e,s-=e}if(e)break;a=yo(a)}}(n,e,o)}}Qe=!0}}function vr(e){let n=e;e.isCollapsed()||n.removeText();const r=pr();tr(r)&&(n=r),tr(n)||t(161);const i=n.anchor;let o=i.getNode(),s=i.offset;for(;!Bo(o);){const t=o;if([o,s]=kr(o,s),t.is(o))break}return s}function kr(t,e){const n=t.getParent();if(!n){const t=pi();return Yi().append(t),t.select(),[Yi(),0]}if(Yn(t)){const r=t.splitText(e);if(0===r.length)return[n,t.getIndexWithinParent()];const i=0===e?0:1;return[n,r[0].getIndexWithinParent()+i]}if(!Zr(t)||0===e)return[n,t.getIndexWithinParent()];const r=t.getChildAtIndex(e);if(r){const n=new er(qn(t.__key,e,"element"),qn(t.__key,e,"element"),0,""),i=t.insertNewAfter(n);i&&i.append(r,...r.getNextSiblings())}return[n,t.getIndexWithinParent()+1]}function Er(t,e,n,r,i="decorators-and-blocks"){if("move"===e&&"character"===r&&!t.isCollapsed()){const[e,r]=n===t.isBackward()?[t.focus,t.anchor]:[t.anchor,t.focus];return r.set(e.key,e.offset,e.type),!0}const o=ks(t.focus,n?"previous":"next"),s="lineboundary"===r,l="move"===e;let c=o,a="decorators-and-blocks"===i;if(!Ls(c)){for(const t of c){a=!1;const{origin:e}=t;if(!ni(e)||e.isIsolated()||(c=t,!s||!e.isInline()))break}if(a)for(const t of ps(o).iterNodeCarets("extend"===e?"shadowRoot":"root")){if(rs(t))t.origin.isInline()||(c=t);else{if(Zr(t.origin))continue;ni(t.origin)&&!t.origin.isInline()&&(c=t)}break}}if(c===o)return!1;if(l&&!s&&ni(c.origin)&&c.origin.isKeyboardSelectable()){const t=gr();return t.add(c.origin.getKey()),Hi(t),!0}return c=Is(c),l&&Es(t.anchor,c),Es(t.focus,c),a||!s}let br=null,Mr=null,Or=!1,Ar=!1,wr=0;const Dr={characterData:!0,childList:!0,subtree:!0};function Pr(){return Or||null!==br&&br._readOnly}function Ir(){Or&&t(13)}function Lr(){wr>99&&t(14)}function Fr(){return null===br&&t(195,Kr()),br}function Rr(){return null===Mr&&t(196,Kr()),Mr}function Kr(){let t=0;const e=new Set,n=mi.version;if("undefined"!=typeof window)for(const r of document.querySelectorAll("[contenteditable]")){const i=Ei(r);if(vi(i))t++;else if(i){let t=String(i.constructor.version||"<0.17.1");t===n&&(t+=" (separately built, likely a bundler configuration issue)"),e.add(t)}}let r=` Detected on the page: ${t} compatible editor(s) with version ${n}`;return e.size&&(r+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),r}function Br(){return Mr}function zr(e,n,r){const i=n.__type,o=function(e,n){const r=e._nodes.get(n);void 0===r&&t(30,n);return r}(e,i);let s=r.get(i);void 0===s&&(s=Array.from(o.transforms),r.set(i,s));const l=s.length;for(let t=0;t<l&&(s[t](n),n.isAttached());t++);}function Wr(t,e){return void 0!==t&&t.__key!==e&&t.isAttached()}function $r(t,e){if(!e)return;const n=t._updateTags;let r=e;Array.isArray(e)||(r=[e]);for(const t of r)n.add(t)}function Ur(e,n){const r=e.type,i=n.get(r);void 0===i&&t(17,r);const o=i.klass;e.type!==o.getType()&&t(18,o.name);const s=o.importJSON(e),l=e.children;if(Zr(s)&&Array.isArray(l))for(let t=0;t<l.length;t++){const e=Ur(l[t],n);s.append(e)}return s}function Yr(t,e,n){const r=br,i=Or,o=Mr;br=e,Or=!0,Mr=t;try{return n()}finally{br=r,Or=i,Mr=o}}function Jr(t,e){const n=t._pendingEditorState,r=t._rootElement,i=t._headless||null===r;if(null===n)return;const o=t._editorState,s=o._selection,l=n._selection,c=t._dirtyType!==y,a=br,u=Or,f=Mr,h=t._updating,g=t._observer;let _=null;if(t._pendingEditorState=null,t._editorState=n,!i&&c&&null!==g){Mr=t,br=n,Or=!1,t._updating=!0;try{const e=t._dirtyType,r=t._dirtyElements,i=t._dirtyLeaves;g.disconnect(),_=qt(o,n,t,e,r,i)}catch(e){if(e instanceof Error&&t._onError(e),Ar)throw e;return yi(t,null,r,n),it(t),t._dirtyType=x,Ar=!0,Jr(t,o),void(Ar=!1)}finally{g.observe(r,Dr),t._updating=h,br=a,Or=u,Mr=f}}n._readOnly||(n._readOnly=!0);const p=t._dirtyLeaves,m=t._dirtyElements,C=t._normalizedNodes,S=t._updateTags,N=t._deferred;c&&(t._dirtyType=y,t._cloneNotNeeded.clear(),t._dirtyLeaves=new Set,t._dirtyElements=new Map,t._normalizedNodes=new Set,t._updateTags=new Set),function(t,e){const n=t._decorators;let r=t._pendingDecorators||n;const i=e._nodeMap;let o;for(o in r)i.has(o)||(r===n&&(r=$i(t)),delete r[o])}(t,n);const T=i?null:Do(To(t));if(t._editable&&null!==T&&(c||null===l||l.dirty)&&null!==r&&!S.has(di)){Mr=t,br=n;try{if(null!==g&&g.disconnect(),c||null===l||l.dirty){const e=t._blockCursorElement;null!==e&&wo(e,t,r),Tr(s,l,t,T,S,r)}!function(t,e,n){let r=t._blockCursorElement;if(tr(n)&&n.isCollapsed()&&"element"===n.anchor.type&&e.contains(document.activeElement)){const i=n.anchor,o=i.getNode(),s=i.offset;let l=!1,c=null;if(s===o.getChildrenSize()){Ao(o.getChildAtIndex(s-1))&&(l=!0)}else{const e=o.getChildAtIndex(s);if(null!==e&&Ao(e)){const n=e.getPreviousSibling();(null===n||Ao(n))&&(l=!0,c=t.getElementByKey(e.__key))}}if(l){const n=t.getElementByKey(o.__key);return null===r&&(t._blockCursorElement=r=function(t){const e=t.theme,n=document.createElement("div");n.contentEditable="false",n.setAttribute("data-lexical-cursor","true");let r=e.blockCursor;if(void 0!==r){if("string"==typeof r){const t=d(r);r=e.blockCursor=t}void 0!==r&&n.classList.add(...r)}return n}(t._config)),e.style.caretColor="transparent",void(null===c?n.appendChild(r):n.insertBefore(r,c))}}null!==r&&wo(r,t,e)}(t,r,l)}finally{null!==g&&g.observe(r,Dr),Mr=f,br=a}}null!==_&&function(t,e,n,r,i){const o=Array.from(t._listeners.mutation),s=o.length;for(let t=0;t<s;t++){const[s,l]=o[t],c=e.get(l);void 0!==c&&s(c,{dirtyLeaves:r,prevEditorState:i,updateTags:n})}}(t,_,S,p,o),tr(l)||null===l||null!==s&&s.is(l)||t.dispatchCommand(Zt,void 0);const v=t._pendingDecorators;null!==v&&(t._decorators=v,t._pendingDecorators=null,Hr("decorator",t,!0,v)),function(t,e,n){const r=Ui(e),i=Ui(n);r!==i&&Hr("textcontent",t,!0,i)}(t,e||o,n),Hr("update",t,!0,{dirtyElements:m,dirtyLeaves:p,editorState:n,mutatedNodes:_,normalizedNodes:C,prevEditorState:e||o,tags:S}),function(t,e){if(t._deferred=[],0!==e.length){const n=t._updating;t._updating=!0;try{for(let t=0;t<e.length;t++)e[t]()}finally{t._updating=n}}}(t,N),function(t){const e=t._updates;if(0!==e.length){const n=e.shift();if(n){const[e,r]=n;Vr(t,e,r)}}}(t)}function Hr(t,e,n,...r){const i=e._updating;e._updating=n;try{const n=Array.from(e._listeners[t]);for(let t=0;t<n.length;t++)n[t].apply(null,r)}finally{e._updating=i}}function jr(e,n){const r=e._updates;let i=n||!1;for(;0!==r.length;){const n=r.shift();if(n){const[r,o]=n;let s;if(void 0!==o){if(s=o.onUpdate,o.skipTransforms&&(i=!0),o.discrete){const n=e._pendingEditorState;null===n&&t(191),n._flushSync=!0}s&&e._deferred.push(s),$r(e,o.tag)}r()}}return i}function Vr(e,n,r){const i=e._updateTags;let o,s=!1,l=!1;void 0!==r&&(o=r.onUpdate,$r(e,r.tag),s=r.skipTransforms||!1,l=r.discrete||!1),o&&e._deferred.push(o);const c=e._editorState;let a=e._pendingEditorState,u=!1;(null===a||a._readOnly)&&(a=e._pendingEditorState=oi(a||c),u=!0),a._flushSync=l;const f=br,d=Or,h=Mr,g=e._updating;br=a,Or=!1,e._updating=!0,Mr=e;const _=e._headless||null===e.getRootElement();try{u&&(_?null!==c._selection&&(a._selection=c._selection.clone()):a._selection=function(t,e){const n=t.getEditorState()._selection,r=Do(To(t));return tr(n)||null==n?_r(n,r,t,e):n.clone()}(e,r&&r.event||null));const i=e._compositionKey;n(),s=jr(e,s),function(t,e){const n=e.getEditorState()._selection,r=t._selection;if(tr(r)){const t=r.anchor,e=r.focus;let i;if("text"===t.type&&(i=t.getNode(),i.selectionTransform(n,r)),"text"===e.type){const t=e.getNode();i!==t&&t.selectionTransform(n,r)}}}(a,e),e._dirtyType!==y&&(s?function(t,e){const n=e._dirtyLeaves,r=t._nodeMap;for(const t of n){const e=r.get(t);Yn(e)&&e.isAttached()&&e.isSimpleText()&&!e.isUnmergeable()&&ht(e)}}(a,e):function(t,e){const n=e._dirtyLeaves,r=e._dirtyElements,i=t._nodeMap,o=Ri(),s=new Map;let l=n,c=l.size,a=r,u=a.size;for(;c>0||u>0;){if(c>0){e._dirtyLeaves=new Set;for(const t of l){const r=i.get(t);Yn(r)&&r.isAttached()&&r.isSimpleText()&&!r.isUnmergeable()&&ht(r),void 0!==r&&Wr(r,o)&&zr(e,r,s),n.add(t)}if(l=e._dirtyLeaves,c=l.size,c>0){wr++;continue}}e._dirtyLeaves=new Set,e._dirtyElements=new Map,a.delete("root")&&a.set("root",!0);for(const t of a){const n=t[0],l=t[1];if(r.set(n,l),!l)continue;const c=i.get(n);void 0!==c&&Wr(c,o)&&zr(e,c,s)}l=e._dirtyLeaves,c=l.size,a=e._dirtyElements,u=a.size,wr++}e._dirtyLeaves=n,e._dirtyElements=r}(a,e),jr(e),function(t,e,n,r){const i=t._nodeMap,o=e._nodeMap,s=[];for(const[t]of r){const e=o.get(t);void 0!==e&&(e.isAttached()||(Zr(e)&&j(e,t,i,o,s,r),i.has(t)||r.delete(t),s.push(t)))}for(const t of s)o.delete(t);for(const t of n){const e=o.get(t);void 0===e||e.isAttached()||(i.has(t)||n.delete(t),o.delete(t))}}(c,a,e._dirtyLeaves,e._dirtyElements));i!==e._compositionKey&&(a._flushSync=!0);const o=a._selection;if(tr(o)){const e=a._nodeMap,n=o.anchor.key,r=o.focus.key;void 0!==e.get(n)&&void 0!==e.get(r)||t(19)}else nr(o)&&0===o._nodes.size&&(a._selection=null)}catch(t){return t instanceof Error&&e._onError(t),e._pendingEditorState=c,e._dirtyType=x,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),void Jr(e)}finally{br=f,Or=d,Mr=h,e._updating=g,wr=0}const p=e._dirtyType!==y||e._deferred.length>0||function(t,e){const n=e.getEditorState()._selection,r=t._selection;if(null!==r){if(r.dirty||!r.is(n))return!0}else if(null!==n)return!0;return!1}(a,e);p?a._flushSync?(a._flushSync=!1,Jr(e)):u&&Ci((()=>{Jr(e)})):(a._flushSync=!1,u&&(i.clear(),e._deferred=[],e._pendingEditorState=null))}function Gr(t,e,n){Mr===t&&void 0===n?e():Vr(t,e,n)}class qr{constructor(t,e,n){this.element=t,this.before=e||null,this.after=n||null}withBefore(t){return new qr(this.element,t,this.after)}withAfter(t){return new qr(this.element,this.before,t)}withElement(t){return this.element===t?this:new qr(t,this.before,this.after)}insertChild(e){const n=this.before||this.getManagedLineBreak();return null!==n&&n.parentElement!==this.element&&t(222),this.element.insertBefore(e,n),this}removeChild(e){return e.parentElement!==this.element&&t(223),this.element.removeChild(e),this}replaceChild(e,n){return n.parentElement!==this.element&&t(224),this.element.replaceChild(e,n),this}getFirstChild(){const t=this.after?this.after.nextSibling:this.element.firstChild;return t===this.before||t===this.getManagedLineBreak()?null:t}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(t){if(null===t)this.removeManagedLineBreak();else{const e="decorator"===t&&(l||s);this.insertManagedLineBreak(e)}}removeManagedLineBreak(){const t=this.getManagedLineBreak();if(t){const e=this.element,n="IMG"===t.nodeName?t.nextSibling:null;n&&e.removeChild(n),e.removeChild(t),e.__lexicalLineBreak=void 0}}insertManagedLineBreak(t){const e=this.getManagedLineBreak();if(e){if(t===("IMG"===e.nodeName))return;this.removeManagedLineBreak()}const n=this.element,r=this.before,i=document.createElement("br");if(n.insertBefore(i,r),t){const t=document.createElement("img");t.setAttribute("data-lexical-linebreak","true"),t.style.cssText="display: inline !important; border: 0px !important; margin: 0px !important;",t.alt="",n.insertBefore(t,i),n.__lexicalLineBreak=t}else n.__lexicalLineBreak=i}getFirstChildOffset(){let t=0;for(let e=this.after;null!==e;e=e.previousSibling)t++;return t}resolveChildIndex(t,e,n,r){if(n===this.element){const e=this.getFirstChildOffset();return[t,Math.min(e+t.getChildrenSize(),Math.max(e,r))]}const i=Xr(e,n);i.push(r);const o=Xr(e,this.element);let s=t.getIndexWithinParent();for(let t=0;t<o.length;t++){const e=i[t],n=o[t];if(void 0===e||e<n)break;if(e>n){s+=1;break}}return[t.getParentOrThrow(),s]}}function Xr(e,n){const r=[];let i=n;for(;i!==e&&null!==i;i=i.parentNode){let t=0;for(let e=i.previousSibling;null!==e;e=e.previousSibling)t++;r.push(t)}return i!==e&&t(225),r.reverse()}class Qr extends Nn{constructor(t){super(t),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null,this.__textFormat=0,this.__textStyle=""}afterCloneFrom(t){super.afterCloneFrom(t),this.__first=t.__first,this.__last=t.__last,this.__size=t.__size,this.__indent=t.__indent,this.__format=t.__format,this.__style=t.__style,this.__dir=t.__dir,this.__textFormat=t.__textFormat,this.__textStyle=t.__textStyle}getFormat(){return this.getLatest().__format}getFormatType(){const t=this.getFormat();return U[t]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getChildrenKeys(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e.__key),e=e.getNextSibling();return t}getChildrenSize(){return this.getLatest().__size}isEmpty(){return 0===this.getChildrenSize()}isDirty(){const t=Rr()._dirtyElements;return null!==t&&t.has(this.__key)}isLastChild(){const t=this.getLatest(),e=this.getParentOrThrow().getLastChild();return null!==e&&e.is(t)}getAllTextNodes(){const t=[];let e=this.getFirstChild();for(;null!==e;){if(Yn(e)&&t.push(e),Zr(e)){const n=e.getAllTextNodes();t.push(...n)}e=e.getNextSibling()}return t}getFirstDescendant(){let t=this.getFirstChild();for(;Zr(t);){const e=t.getFirstChild();if(null===e)break;t=e}return t}getLastDescendant(){let t=this.getLastChild();for(;Zr(t);){const e=t.getLastChild();if(null===e)break;t=e}return t}getDescendantByIndex(t){const e=this.getChildren(),n=e.length;if(t>=n){const t=e[n-1];return Zr(t)&&t.getLastDescendant()||t||null}const r=e[t];return Zr(r)&&r.getFirstDescendant()||r||null}getFirstChild(){const t=this.getLatest().__first;return null===t?null:Ki(t)}getFirstChildOrThrow(){const e=this.getFirstChild();return null===e&&t(45,this.__key),e}getLastChild(){const t=this.getLatest().__last;return null===t?null:Ki(t)}getLastChildOrThrow(){const e=this.getLastChild();return null===e&&t(96,this.__key),e}getChildAtIndex(t){const e=this.getChildrenSize();let n,r;if(t<e/2){for(n=this.getFirstChild(),r=0;null!==n&&r<=t;){if(r===t)return n;n=n.getNextSibling(),r++}return null}for(n=this.getLastChild(),r=e-1;null!==n&&r>=t;){if(r===t)return n;n=n.getPreviousSibling(),r--}return null}getTextContent(){let t="";const e=this.getChildren(),n=e.length;for(let r=0;r<n;r++){const i=e[r];t+=i.getTextContent(),Zr(i)&&r!==n-1&&!i.isInline()&&(t+=I)}return t}getTextContentSize(){let t=0;const e=this.getChildren(),n=e.length;for(let r=0;r<n;r++){const i=e[r];t+=i.getTextContentSize(),Zr(i)&&r!==n-1&&!i.isInline()&&(t+=I.length)}return t}getDirection(){return this.getLatest().__dir}getTextFormat(){return this.getLatest().__textFormat}hasFormat(t){if(""!==t){const e=$[t];return!!(this.getFormat()&e)}return!1}hasTextFormat(t){const e=z[t];return!!(this.getTextFormat()&e)}getFormatFlags(t,e){return Di(this.getLatest().__textFormat,t,e)}getTextStyle(){return this.getLatest().__textStyle}select(t,e){Ir();const n=pr();let r=t,i=e;const o=this.getChildrenSize();if(!this.canBeEmpty())if(0===t&&0===e){const t=this.getFirstChild();if(Yn(t)||Zr(t))return t.select(0,0)}else if(!(void 0!==t&&t!==o||void 0!==e&&e!==o)){const t=this.getLastChild();if(Yn(t)||Zr(t))return t.select()}void 0===r&&(r=o),void 0===i&&(i=o);const s=this.__key;return tr(n)?(n.anchor.set(s,r,"element"),n.focus.set(s,i,"element"),n.dirty=!0,n):dr(s,r,s,i,"element","element")}selectStart(){const t=this.getFirstDescendant();return t?t.selectStart():this.select()}selectEnd(){const t=this.getLastDescendant();return t?t.selectEnd():this.select()}clear(){const t=this.getWritable();return this.getChildren().forEach((t=>t.remove())),t}append(...t){return this.splice(this.getChildrenSize(),0,t)}setDirection(t){const e=this.getWritable();return e.__dir=t,e}setFormat(t){return this.getWritable().__format=""!==t?$[t]:0,this}setStyle(t){return this.getWritable().__style=t||"",this}setTextFormat(t){const e=this.getWritable();return e.__textFormat=t,e}setTextStyle(t){const e=this.getWritable();return e.__textStyle=t,e}setIndent(t){return this.getWritable().__indent=t,this}splice(e,n,r){const i=r.length,o=this.getChildrenSize(),s=this.getWritable();e+n<=o||t(226,String(e),String(n),String(o));const l=s.__key,c=[],a=[],u=this.getChildAtIndex(e+n);let f=null,d=o-n+i;if(0!==e)if(e===o)f=this.getLastChild();else{const t=this.getChildAtIndex(e);null!==t&&(f=t.getPreviousSibling())}if(n>0){let e=null===f?this.getFirstChild():f.getNextSibling();for(let r=0;r<n;r++){null===e&&t(100);const n=e.getNextSibling(),r=e.__key;Ii(e.getWritable()),a.push(r),e=n}}let h=f;for(let e=0;e<i;e++){const n=r[e];null!==h&&n.is(h)&&(f=h=h.getPreviousSibling());const i=n.getWritable();i.__parent===l&&d--,Ii(i);const o=n.__key;if(null===h)s.__first=o,i.__prev=null;else{const t=h.getWritable();t.__next=o,i.__prev=t.__key}n.__key===l&&t(76),i.__parent=l,c.push(o),h=n}if(e+n===o){if(null!==h){h.getWritable().__next=null,s.__last=h.__key}}else if(null!==u){const t=u.getWritable();if(null!==h){const e=h.getWritable();t.__prev=h.__key,e.__next=u.__key}else t.__prev=null}if(s.__size=d,a.length){const t=pr();if(tr(t)){const e=new Set(a),n=new Set(c),{anchor:r,focus:i}=t;ti(r,e,n)&&Cr(r,r.getNode(),this,f,u),ti(i,e,n)&&Cr(i,i.getNode(),this,f,u),0!==d||this.canBeEmpty()||ko(this)||this.remove()}}return s}getDOMSlot(t){return new qr(t)}exportDOM(t){const{element:e}=super.exportDOM(t);if(Io(e)){const t=this.getIndent();t>0&&(e.style.paddingInlineStart=40*t+"px");const n=this.getDirection();n&&(e.dir=n)}return{element:e}}exportJSON(){const t={children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),...super.exportJSON()},e=this.getTextFormat(),n=this.getTextStyle();return 0!==e&&(t.textFormat=e),""!==n&&(t.textStyle=n),t}updateFromJSON(t){return super.updateFromJSON(t).setFormat(t.format).setIndent(t.indent).setDirection(t.direction).setTextFormat(t.textFormat||0).setTextStyle(t.textStyle||"")}insertNewAfter(t,e){return null}canIndent(){return!0}collapseAtStart(t){return!1}excludeFromCopy(t){return!1}canReplaceWith(t){return!0}canInsertAfter(t){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(t){return!1}extractWithChild(t,e,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(t,e){const n=this.getDOMSlot(t);let r=n.getFirstChild();for(let t=this.getFirstChild();t;t=t.getNextSibling()){const i=e.getElementByKey(t.getKey());null!==i&&(null==r?(n.insertChild(i),r=i):r!==i&&n.replaceChild(i,r),r=r.nextSibling)}}}function Zr(t){return t instanceof Qr}function ti(t,e,n){let r=t.getNode();for(;r;){const t=r.__key;if(e.has(t)&&!n.has(t))return!0;r=r.getParent()}return!1}class ei extends Nn{decorate(e,n){t(47)}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function ni(t){return t instanceof ei}class ri extends Qr{static getType(){return"root"}static clone(){return new ri}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){t(51)}getTextContent(){const t=this.__cachedText;return!Pr()&&Rr()._dirtyType!==y||null===t?super.getTextContent():t}remove(){t(52)}replace(e){t(53)}insertBefore(e){t(54)}insertAfter(e){t(55)}updateDOM(t,e){return!1}splice(e,n,r){for(const e of r)Zr(e)||ni(e)||t(282);return super.splice(e,n,r)}static importJSON(t){return Yi().updateFromJSON(t)}collapseAtStart(){return!0}}function ii(t){return t instanceof ri}function oi(t){return new ci(new Map(t._nodeMap))}function si(){return new ci(new Map([["root",new ri]]))}function li(e){const n=e.exportJSON(),r=e.constructor;if(n.type!==r.getType()&&t(130,r.name),Zr(e)){const i=n.children;Array.isArray(i)||t(59,r.name);const o=e.getChildren();for(let t=0;t<o.length;t++){const e=li(o[t]);i.push(e)}}return n}class ci{constructor(t,e){this._nodeMap=t,this._selection=e||null,this._flushSync=!1,this._readOnly=!1}isEmpty(){return 1===this._nodeMap.size&&null===this._selection}read(t,e){return Yr(e&&e.editor||null,this,t)}clone(t){const e=new ci(this._nodeMap,void 0===t?this._selection:t);return e._readOnly=!0,e}toJSON(){return Yr(null,this,(()=>({root:li(Yi())})))}}const ai="history-merge",ui="collaboration",fi="skip-scroll-into-view",di="skip-dom-selection";class hi extends Qr{static getType(){return"artificial"}createDOM(t){return document.createElement("div")}}class gi extends Qr{static getType(){return"paragraph"}static clone(t){return new gi(t.__key)}createDOM(t){const e=document.createElement("p"),n=co(t.theme,"paragraph");if(void 0!==n){e.classList.add(...n)}return e}updateDOM(t,e,n){return!1}static importDOM(){return{p:t=>({conversion:_i,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(Io(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t)}return{element:e}}static importJSON(t){return pi().updateFromJSON(t)}exportJSON(){return{...super.exportJSON(),textFormat:this.getTextFormat(),textStyle:this.getTextStyle()}}insertNewAfter(t,e){const n=pi();n.setTextFormat(t.format),n.setTextStyle(t.style);const r=this.getDirection();return n.setDirection(r),n.setFormat(this.getFormatType()),n.setStyle(this.getStyle()),this.insertAfter(n,e),n}collapseAtStart(){const t=this.getChildren();if(0===t.length||Yn(t[0])&&""===t[0].getTextContent().trim()){if(null!==this.getNextSibling())return this.selectNext(),this.remove(),!0;if(null!==this.getPreviousSibling())return this.selectPrevious(),this.remove(),!0}return!1}}function _i(t){const e=pi();return t.style&&(e.setFormat(t.style.textAlign),Jo(t,e)),{node:e}}function pi(){return bo(new gi)}function yi(t,e,n,r){const i=t._keyToDOMMap;i.clear(),t._editorState=si(),t._pendingEditorState=r,t._compositionKey=null,t._dirtyType=y,t._cloneNotNeeded.clear(),t._dirtyLeaves=new Set,t._dirtyElements.clear(),t._normalizedNodes=new Set,t._updateTags=new Set,t._updates=[],t._blockCursorElement=null;const o=t._observer;null!==o&&(o.disconnect(),t._observer=null),null!==e&&(e.textContent=""),null!==n&&(n.textContent="",i.set("root",n))}class mi{constructor(t,e,n,r,i,o,s,l){this._createEditorArgs=l,this._parentEditor=e,this._rootElement=null,this._editorState=t,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=r,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=y,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=Xi(),this._onError=i,this._htmlConversions=o,this._editable=s,this._headless=null!==e&&e._headless,this._window=null,this._blockCursorElement=null}isComposing(){return null!=this._compositionKey}registerUpdateListener(t){const e=this._listeners.update;return e.add(t),()=>{e.delete(t)}}registerEditableListener(t){const e=this._listeners.editable;return e.add(t),()=>{e.delete(t)}}registerDecoratorListener(t){const e=this._listeners.decorator;return e.add(t),()=>{e.delete(t)}}registerTextContentListener(t){const e=this._listeners.textcontent;return e.add(t),()=>{e.delete(t)}}registerRootListener(t){const e=this._listeners.root;return t(this._rootElement,null),e.add(t),()=>{t(null,this._rootElement),e.delete(t)}}registerCommand(e,n,r){void 0===r&&t(35);const i=this._commands;i.has(e)||i.set(e,[new Set,new Set,new Set,new Set,new Set]);const o=i.get(e);void 0===o&&t(36,String(e));const s=o[r];return s.add(n),()=>{s.delete(n),o.every((t=>0===t.size))&&i.delete(e)}}registerMutationListener(t,e,n){const r=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(t)).klass,i=this._listeners.mutation;i.set(e,r);const o=n&&n.skipInitialization;return void 0!==o&&o||this.initializeMutationListener(e,r),()=>{i.delete(e)}}getRegisteredNode(e){const n=this._nodes.get(e.getType());return void 0===n&&t(37,e.name),n}resolveRegisteredNodeAfterReplacements(t){for(;t.replaceWithKlass;)t=this.getRegisteredNode(t.replaceWithKlass);return t}initializeMutationListener(t,e){const n=this._editorState,r=Uo(n).get(e.getType());if(!r)return;const i=new Map;for(const t of r.keys())i.set(t,"created");i.size>0&&t(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(t,e){const n=this.getRegisteredNode(t);return n.transforms.add(e),n}registerNodeTransform(t,e){const n=this.registerNodeTransformToKlass(t,e),r=[n],i=n.replaceWithKlass;if(null!=i){const t=this.registerNodeTransformToKlass(i,e);r.push(t)}return function(t,e){const n=Uo(t.getEditorState()),r=[];for(const t of e){const e=n.get(t);e&&r.push(e)}if(0===r.length)return;t.update((()=>{for(const t of r)for(const e of t.keys()){const t=Ki(e);t&&t.markDirty()}}),null===t._pendingEditorState?{tag:ai}:void 0)}(this,r.map((t=>t.klass.getType()))),()=>{r.forEach((t=>t.transforms.delete(e)))}}hasNode(t){return this._nodes.has(t.getType())}hasNodes(t){return t.every(this.hasNode.bind(this))}dispatchCommand(t,e){return go(this,t,e)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(t){const e=this._rootElement;if(t!==e){const n=co(this._config.theme,"root"),r=this._pendingEditorState||this._editorState;if(this._rootElement=t,yi(this,e,t,r),null!==e&&(this._config.disableEvents||Cn(e),null!=n&&e.classList.remove(...n)),null!==t){const e=No(t),r=t.style;r.userSelect="text",r.whiteSpace="pre-wrap",r.wordBreak="break-word",t.setAttribute("data-lexical-editor","true"),this._window=e,this._dirtyType=x,it(this),this._updateTags.add(ai),Jr(this),this._config.disableEvents||function(t,e){const n=t.ownerDocument,r=Xe.get(n);(void 0===r||r<1)&&n.addEventListener("selectionchange",pn),Xe.set(n,(r||0)+1),t.__lexicalEditor=e;const i=gn(t);for(let n=0;n<He.length;n++){const[r,o]=He[n],s="function"==typeof o?t=>{mn(t)||(yn(t),(e.isEditable()||"click"===r)&&o(t,e))}:t=>{if(mn(t))return;yn(t);const n=e.isEditable();switch(r){case"cut":return n&&go(e,Le,t);case"copy":return go(e,Ie,t);case"paste":return n&&go(e,se,t);case"dragstart":return n&&go(e,we,t);case"dragover":return n&&go(e,De,t);case"dragend":return n&&go(e,Pe,t);case"focus":return n&&go(e,We,t);case"blur":return n&&go(e,$e,t);case"drop":return n&&go(e,Oe,t)}};t.addEventListener(r,s),i.push((()=>{t.removeEventListener(r,s)}))}}(t,this),null!=n&&t.classList.add(...n)}else this._window=null,this._updateTags.add(ai),Jr(this);Hr("root",this,!1,t,e)}}getElementByKey(t){return this._keyToDOMMap.get(t)||null}getEditorState(){return this._editorState}setEditorState(e,n){e.isEmpty()&&t(38);let r=e;r._readOnly&&(r=oi(e),r._selection=e._selection?e._selection.clone():null),rt(this);const i=this._pendingEditorState,o=this._updateTags,s=void 0!==n?n.tag:null;null===i||i.isEmpty()||(null!=s&&o.add(s),Jr(this)),this._pendingEditorState=r,this._dirtyType=x,this._dirtyElements.set("root",!1),this._compositionKey=null,null!=s&&o.add(s),this._updating||Jr(this)}parseEditorState(t,e){return function(t,e,n){const r=si(),i=br,o=Or,s=Mr,l=e._dirtyElements,c=e._dirtyLeaves,a=e._cloneNotNeeded,u=e._dirtyType;e._dirtyElements=new Map,e._dirtyLeaves=new Set,e._cloneNotNeeded=new Set,e._dirtyType=0,br=r,Or=!1,Mr=e;try{const i=e._nodes;Ur(t.root,i),n&&n(),r._readOnly=!0}catch(t){t instanceof Error&&e._onError(t)}finally{e._dirtyElements=l,e._dirtyLeaves=c,e._cloneNotNeeded=a,e._dirtyType=u,br=i,Or=o,Mr=s}return r}("string"==typeof t?JSON.parse(t):t,this,e)}read(t){return Jr(this),this.getEditorState().read(t,{editor:this})}update(t,e){!function(t,e,n){t._updating?t._updates.push([e,n]):Vr(t,e,n)}(this,t,e)}focus(t,e={}){const n=this._rootElement;null!==n&&(n.setAttribute("autocapitalize","off"),Gr(this,(()=>{const r=pr(),i=Yi();null!==r?r.dirty||Hi(r.clone()):0!==i.getChildrenSize()&&("rootStart"===e.defaultSelection?i.selectStart():i.selectEnd()),xo("focus"),Co((()=>{n.removeAttribute("autocapitalize"),t&&t()}))})),null===this._pendingEditorState&&n.removeAttribute("autocapitalize"))}blur(){const t=this._rootElement;null!==t&&t.blur();const e=Do(this._window);null!==e&&e.removeAllRanges()}isEditable(){return this._editable}setEditable(t){this._editable!==t&&(this._editable=t,Hr("editable",this,!0,t))}toJSON(){return{editorState:this._editorState.toJSON()}}}mi.version="0.32.1+prod.cjs";let xi=1;const Ci="function"==typeof queueMicrotask?queueMicrotask:t=>{Promise.resolve().then(t)};function Si(t){return ni(Wi(t))}function Ni(t){const e=document.activeElement;if(!Io(e))return!1;const n=e.nodeName;return ni(Wi(t))&&("INPUT"===n||"TEXTAREA"===n||"true"===e.contentEditable&&null==Ei(e))}function Ti(t,e,n){const r=t.getRootElement();try{return null!==r&&r.contains(e)&&r.contains(n)&&null!==e&&!Ni(e)&&ki(e)===t}catch(t){return!1}}function vi(t){return t instanceof mi}function ki(t){let e=t;for(;null!=e;){const t=Ei(e);if(vi(t))return t;e=yo(e)}return null}function Ei(t){return t?t.__lexicalEditor:null}function bi(t){return Vn(t)||t.isToken()}function Mi(t){return bi(t)||t.isSegmented()}function Oi(t){return Lo(t)&&t.nodeType===g}function Ai(t){return Lo(t)&&t.nodeType===_}function wi(t){let e=t;for(;null!=e;){if(Oi(e))return e;e=e.firstChild}return null}function Di(t,e,n){const r=z[e];if(null!==n&&(t&r)==(n&r))return t;let i=t^r;return"subscript"===e?i&=~z.superscript:"superscript"===e?i&=~z.subscript:"lowercase"===e?(i&=~z.uppercase,i&=~z.capitalize):"uppercase"===e?(i&=~z.lowercase,i&=~z.capitalize):"capitalize"===e&&(i&=~z.lowercase,i&=~z.uppercase),i}function Pi(t,e){if(null!=e)return void(t.__key=e);Ir(),Lr();const n=Rr(),r=Fr(),i=""+xi++;r._nodeMap.set(i,t),Zr(t)?n._dirtyElements.set(i,!0):n._dirtyLeaves.add(i),n._cloneNotNeeded.add(i),n._dirtyType=m,t.__key=i}function Ii(t){const e=t.getParent();if(null!==e){const n=t.getWritable(),r=e.getWritable(),i=t.getPreviousSibling(),o=t.getNextSibling(),s=null!==o?o.__key:null,l=null!==i?i.__key:null,c=null!==i?i.getWritable():null,a=null!==o?o.getWritable():null;null===i&&(r.__first=s),null===o&&(r.__last=l),null!==c&&(c.__next=s),null!==a&&(a.__prev=l),n.__prev=null,n.__next=null,n.__parent=null,r.__size--}}function Li(t){Lr();const e=t.getLatest(),n=e.__parent,r=Fr(),i=Rr(),o=r._nodeMap,s=i._dirtyElements;null!==n&&function(t,e,n){let r=t;for(;null!==r;){if(n.has(r))return;const t=e.get(r);if(void 0===t)break;n.set(r,!1),r=t.__parent}}(n,o,s);const l=e.__key;i._dirtyType=m,Zr(t)?s.set(l,!0):i._dirtyLeaves.add(l)}function Fi(t){Ir();const e=Rr(),n=e._compositionKey;if(t!==n){if(e._compositionKey=t,null!==n){const t=Ki(n);null!==t&&t.getWritable()}if(null!==t){const e=Ki(t);null!==e&&e.getWritable()}}}function Ri(){if(Pr())return null;return Rr()._compositionKey}function Ki(t,e){const n=(e||Fr())._nodeMap.get(t);return void 0===n?null:n}function Bi(t,e){const n=zi(t,Rr());return void 0!==n?Ki(n,e):null}function zi(t,e){return t[`__lexicalKey_${e._key}`]}function Wi(t,e){let n=t;for(;null!=n;){const t=Bi(n,e);if(null!==t)return t;n=yo(n)}return null}function $i(t){const e=t._decorators,n=Object.assign({},e);return t._pendingDecorators=n,n}function Ui(t){return t.read((()=>Yi().getTextContent()))}function Yi(){return Ji(Fr())}function Ji(t){return t._nodeMap.get("root")}function Hi(t){Ir();const e=Fr();null!==t&&(t.dirty=!0,t.setCachedNodes(null)),e._selection=t}function ji(t){const e=Rr(),n=function(t,e){let n=t;for(;null!=n;){const t=zi(n,e);if(void 0!==t)return t;n=yo(n)}return null}(t,e);if(null===n){return t===e.getRootElement()?Ki("root"):null}return Ki(n)}function Vi(t,e){return e?t.getTextContentSize():0}function Gi(t){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(t)}function qi(t){const e=[];let n=t;for(;null!==n;)e.push(n),n=n._parentEditor;return e}function Xi(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,5)}function Qi(t){return Oi(t)?t.nodeValue:null}function Zi(t,e,n){const r=Do(To(e));if(null===r)return;const i=r.anchorNode;let{anchorOffset:o,focusOffset:s}=r;if(null!==i){let e=Qi(i);const r=Wi(i);if(null!==e&&Yn(r)){if(e===P&&n){const t=n.length;e=n,o=t,s=t}null!==e&&to(r,e,o,s,t)}}}function to(t,e,n,r,i){let o=t;if(o.isAttached()&&(i||!o.isDirty())){const c=o.isComposing();let a=e;(c||i)&&e[e.length-1]===P&&(a=e.slice(0,-1));const u=o.getTextContent();if(i||a!==u){if(""===a){if(Fi(null),s||l||f)o.remove();else{const t=Rr();setTimeout((()=>{t.update((()=>{o.isAttached()&&o.remove()}))}),20)}return}const e=o.getParent(),i=yr(),u=o.getTextContentSize(),d=Ri(),h=o.getKey();if(o.isToken()||null!==d&&h===d&&!c||tr(i)&&(null!==e&&!e.canInsertTextBefore()&&0===i.anchor.offset||i.anchor.key===t.__key&&0===i.anchor.offset&&!o.canInsertTextBefore()&&!c||i.focus.key===t.__key&&i.focus.offset===u&&!o.canInsertTextAfter()&&!c))return void o.markDirty();const g=pr();if(!tr(g)||null===n||null===r)return void o.setTextContent(a);if(g.setTextNodeRange(o,n,o,r),o.isSegmented()){const t=Un(o.getTextContent());o.replace(t),o=t}o.setTextContent(a)}}}function eo(t,e,n){const r=e[n]||!1;return"any"===r||r===t[n]}function no(t,e){return eo(t,e,"altKey")&&eo(t,e,"ctrlKey")&&eo(t,e,"shiftKey")&&eo(t,e,"metaKey")}function ro(t,e,n){return no(t,n)&&t.key.toLowerCase()===e.toLowerCase()}const io={ctrlKey:!r,metaKey:r},oo={altKey:r,ctrlKey:!r};function so(t){return"Backspace"===t.key}function lo(t){return ro(t,"a",io)}function co(t,e){void 0===t.__lexicalClassNameCache&&(t.__lexicalClassNameCache={});const n=t.__lexicalClassNameCache,r=n[e];if(void 0!==r)return r;const i=t[e];if("string"==typeof i){const t=d(i);return n[e]=t,t}return i}function ao(e,n,r,i,o){if(0===r.size)return;const s=i.__type,l=i.__key,c=n.get(s);void 0===c&&t(33,s);const a=c.klass;let u=e.get(a);void 0===u&&(u=new Map,e.set(a,u));const f=u.get(l),d="destroyed"===f&&"created"===o;(void 0===f||d)&&u.set(l,d?"updated":o)}function uo(t,e,n){const r=t.getParent();let i=n,o=t;return null!==r&&(e&&0===n?(i=o.getIndexWithinParent(),o=r):e||n!==o.getChildrenSize()||(i=o.getIndexWithinParent()+1,o=r)),o.getChildAtIndex(e?i-1:i)}function fo(t,e){const n=t.offset;if("element"===t.type){return uo(t.getNode(),e,n)}{const r=t.getNode();if(e&&0===n||!e&&n===r.getTextContentSize()){const t=e?r.getPreviousSibling():r.getNextSibling();return null===t?uo(r.getParentOrThrow(),e,r.getIndexWithinParent()+(e?0:1)):t}}return null}function ho(t){const e=To(t).event,n=e&&e.inputType;return"insertFromPaste"===n||"insertFromPasteAsQuotation"===n}function go(t,e,n){return function(t,e,n){const r=qi(t);for(let i=4;i>=0;i--)for(let o=0;o<r.length;o++){const s=r[o],l=s._commands.get(e);if(void 0!==l){const e=l[i];if(void 0!==e){const r=Array.from(e),i=r.length;let o=!1;if(Gr(s,(()=>{for(let e=0;e<i;e++)if(r[e](n,t))return void(o=!0)})),o)return o}}}return!1}(t,e,n)}function _o(t){return!ii(t)&&!t.isLastChild()&&!t.isInline()}function po(e,n){const r=e._keyToDOMMap.get(n);return void 0===r&&t(75,n),r}function yo(t){const e=t.assignedSlot||t.parentElement;return Fo(e)?e.host:e}function mo(t){return Ai(t)?t:Io(t)?t.ownerDocument:null}function xo(t){Ir();Rr()._updateTags.add(t)}function Co(t){Ir();Rr()._deferred.push(t)}function So(t,e){let n=t.getParent();for(;null!==n;){if(n.is(e))return!0;n=n.getParent()}return!1}function No(t){const e=mo(t);return e?e.defaultView:null}function To(e){const n=e._window;return null===n&&t(78),n}function vo(t){let e=t.getParentOrThrow();for(;null!==e;){if(ko(e))return e;e=e.getParentOrThrow()}return e}function ko(t){return ii(t)||Zr(t)&&t.isShadowRoot()}function Eo(t){const e=t.constructor.clone(t);return Pi(e,null),e}function bo(e){const n=Rr(),r=e.constructor.getType(),i=n._nodes.get(r);void 0===i&&t(200,e.constructor.name,r);const{replace:o,replaceWithKlass:s}=i;if(null!==o){const n=o(e),i=n.constructor;return null!==s?n instanceof s||t(201,s.name,s.getType(),i.name,i.getType(),e.constructor.name,r):n instanceof e.constructor&&i!==e.constructor||t(202,i.name,i.getType(),e.constructor.name,r),n.__key===e.__key&&t(203,e.constructor.name,r,i.name,i.getType()),n}return e}function Mo(e,n){!ii(e.getParent())||Zr(n)||ni(n)||t(99)}function Oo(e){const n=Ki(e);return null===n&&t(63,e),n}function Ao(t){return(ni(t)||Zr(t)&&!t.canBeEmpty())&&!t.isInline()}function wo(t,e,n){n.style.removeProperty("caret-color"),e._blockCursorElement=null;const r=t.parentElement;null!==r&&r.removeChild(t)}function Do(t){return e?(t||window).getSelection():null}function Po(t){const e=No(t);return e?e.getSelection():null}function Io(t){return Lo(t)&&t.nodeType===h}function Lo(t){return"object"==typeof t&&null!==t&&"nodeType"in t&&"number"==typeof t.nodeType}function Fo(t){return Lo(t)&&t.nodeType===p}function Ro(t){const e=new RegExp(/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|mark|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/,"i");return null!==t.nodeName.match(e)}function Ko(t){const e=new RegExp(/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/,"i");return null!==t.nodeName.match(e)}function Bo(t){if(ni(t)&&!t.isInline())return!0;if(!Zr(t)||ko(t))return!1;const e=t.getFirstChild(),n=null===e||En(e)||Yn(e)||e.isInline();return!t.isInline()&&!1!==t.canBeEmpty()&&n}function zo(t,e){let n=t;for(;null!==n&&null!==n.getParent()&&!e(n);)n=n.getParentOrThrow();return e(n)?n:null}const Wo=new WeakMap,$o=new Map;function Uo(e){if(!e._readOnly&&e.isEmpty())return $o;e._readOnly||t(192);let n=Wo.get(e);return n||(n=function(t){const e=new Map;for(const[n,r]of t._nodeMap){const t=r.__type;let i=e.get(t);i||(i=new Map,e.set(t,i)),i.set(n,r)}return e}(e),Wo.set(e,n)),n}function Yo(t){const e=t.constructor.clone(t);return e.afterCloneFrom(t),e}function Jo(t,e){const n=parseInt(t.style.paddingInlineStart,10)||0,r=Math.round(n/40);e.setIndent(r)}function Ho(t){return!0===t.__lexicalUnmanaged}const jo={next:"previous",previous:"next"};class Vo{constructor(t){this.origin=t}[Symbol.iterator](){return xs({hasNext:ns,initial:this.getAdjacentCaret(),map:t=>t,step:t=>t.getAdjacentCaret()})}getAdjacentCaret(){return ls(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return ls(this.origin,this.direction)}remove(){const t=this.getNodeAtCaret();return t&&t.remove(),this}replaceOrInsert(t,e){const n=this.getNodeAtCaret();return t.is(this.origin)||t.is(n)||(null===n?this.insert(t):n.replace(t,e)),this}splice(e,n,r="next"){const i=r===this.direction?n:Array.from(n).reverse();let o=this;const s=this.getParentAtCaret(),l=new Map;for(let t=o.getAdjacentCaret();null!==t&&l.size<e;t=t.getAdjacentCaret()){const e=t.origin.getWritable();l.set(e.getKey(),e)}for(const e of i){if(l.size>0){const n=o.getNodeAtCaret();if(n)if(l.delete(n.getKey()),l.delete(e.getKey()),n.is(e)||o.origin.is(e));else{const t=e.getParent();t&&t.is(s)&&e.remove(),n.replace(e)}else null===n&&t(263,Array.from(l).join(" "))}else o.insert(e);o=ls(e,this.direction)}for(const t of l.values())t.remove();return this}}class Go extends Vo{type="child";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:fs(t,this.direction)}getParentCaret(t="root"){return ls(Qo(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=Xo(this.direction);return ls(this.getNodeAtCaret(),t)||fs(this.origin,t)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(t){return t instanceof Go&&this.direction===t.direction&&this.origin.is(t.origin)}isSamePointCaret(t){return this.isSameNodeCaret(t)}}const qo={root:ii,shadowRoot:ko};function Xo(t){return jo[t]}function Qo(t,e="root"){return qo[e](t)?null:t}class Zo extends Vo{type="sibling";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:ls(t,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return Zr(this.origin)?fs(this.origin,this.direction):null}getParentCaret(t="root"){return ls(Qo(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=Xo(this.direction);return ls(this.getNodeAtCaret(),t)||fs(this.origin.getParentOrThrow(),t)}isSamePointCaret(t){return t instanceof Zo&&this.direction===t.direction&&this.origin.is(t.origin)}isSameNodeCaret(t){return(t instanceof Zo||t instanceof ts)&&this.direction===t.direction&&this.origin.is(t.origin)}}class ts extends Vo{type="text";constructor(t,e){super(t),this.offset=e}getLatest(){const t=this.origin.getLatest();return t===this.origin?this:cs(t,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(t="root"){return ls(Qo(this.getParentAtCaret(),t),this.direction)}getFlipped(){return cs(this.origin,Xo(this.direction),this.offset)}isSamePointCaret(t){return t instanceof ts&&this.direction===t.direction&&this.origin.is(t.origin)&&this.offset===t.offset}isSameNodeCaret(t){return(t instanceof Zo||t instanceof ts)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return ls(this.origin,this.direction)}}function es(t){return t instanceof ts}function ns(t){return t instanceof Zo}function rs(t){return t instanceof Go}const is={next:class extends ts{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends ts{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},os={next:class extends Zo{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Zo{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},ss={next:class extends Go{direction="next";getNodeAtCaret(){return this.origin.getFirstChild()}insert(t){return this.origin.splice(0,0,[t]),this}},previous:class extends Go{direction="previous";getNodeAtCaret(){return this.origin.getLastChild()}insert(t){return this.origin.splice(this.origin.getChildrenSize(),0,[t]),this}}};function ls(t,e){return t?new os[e](t):null}function cs(t,e,n){return t?new is[e](t,as(t,n)):null}function as(t,e){const n=t.getTextContentSize();let r="next"===e?n:"previous"===e?0:e;return(r<0||r>n)&&(!function(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.`)}(284,String(e),String(n),t.getKey()),r=r<0?0:n),r}function us(t,e){return new _s(t,e)}function fs(t,e){return Zr(t)?new ss[e](t):null}function ds(t){return t&&t.getChildCaret()||t}function hs(t){return t&&ds(t.getAdjacentCaret())}class gs{type="node-caret-range";constructor(t,e,n){this.anchor=t,this.focus=e,this.direction=n}getLatest(){const t=this.anchor.getLatest(),e=this.focus.getLatest();return t===this.anchor&&e===this.focus?this:new gs(t,e,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){const t=t=>{const e=this[t].getLatest();return es(e)?function(t,e){const{direction:n,origin:r}=t,i=as(r,"focus"===e?Xo(n):n);return us(t,i-t.offset)}(e,t):null},e=t("anchor"),n=t("focus");if(e&&n){const{caret:t}=e,{caret:r}=n;if(t.isSameNodeCaret(r))return[us(t,r.offset-t.offset),null]}return[e,n]}iterNodeCarets(t="root"){const e=es(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),r=es(n),i=e=>e.isSameNodeCaret(n)?null:hs(e)||e.getParentCaret(t);return xs({hasNext:t=>null!==t&&!(r&&n.isSameNodeCaret(t)),initial:e.isSameNodeCaret(n)?null:i(e),map:t=>t,step:i})}[Symbol.iterator](){return this.iterNodeCarets("root")}}class _s{type="slice";constructor(t,e){this.caret=t,this.distance=e}getSliceIndices(){const{distance:t,caret:{offset:e}}=this,n=e+t;return n<e?[n,e]:[e,n]}getTextContent(){const[t,e]=this.getSliceIndices();return this.caret.origin.getTextContent().slice(t,e)}getTextContentSize(){return Math.abs(this.distance)}removeTextSlice(){const{caret:{origin:t,direction:e}}=this,[n,r]=this.getSliceIndices(),i=t.getTextContent();return cs(t.setTextContent(i.slice(0,n)+i.slice(r)),e,n)}}function ps(t){return ms(t,ls(Yi(),t.direction))}function ys(t){return ms(t,t)}function ms(e,n){return e.direction!==n.direction&&t(265),new gs(e,n,e.direction)}function xs(t){const{initial:e,hasNext:n,step:r,map:i}=t;let o=e;return{[Symbol.iterator](){return this},next(){if(!n(o))return{done:!0,value:void 0};const t={done:!1,value:i(o)};return o=r(o),t}}}function Cs(e,n){const r=vs(e.origin,n.origin);switch(null===r&&t(275,e.origin.getKey(),n.origin.getKey()),r.type){case"same":{const t="text"===e.type,r="text"===n.type;return t&&r?function(t,e){return Math.sign(t-e)}(e.offset,n.offset):e.type===n.type?0:t?-1:r?1:"child"===e.type?-1:1}case"ancestor":return"child"===e.type?-1:1;case"descendant":return"child"===n.type?1:-1;case"branch":return Ss(r)}}function Ss(t){const{a:e,b:n}=t,r=e.__key,i=n.__key;let o=e,s=n;for(;o&&s;o=o.getNextSibling(),s=s.getNextSibling()){if(o.__key===i)return-1;if(s.__key===r)return 1}return null===o?1:-1}function Ns(t,e){return e.is(t)}function Ts(t){return Zr(t)?[t.getLatest(),null]:[t.getParent(),t.getLatest()]}function vs(e,n){if(e.is(n))return{commonAncestor:e,type:"same"};const r=new Map;for(let[t,n]=Ts(e);t;n=t,t=t.getParent())r.set(t,n);for(let[i,o]=Ts(n);i;o=i,i=i.getParent()){const s=r.get(i);if(void 0!==s)return null===s?(Ns(e,i)||t(276),{commonAncestor:i,type:"ancestor"}):null===o?(Ns(n,i)||t(277),{commonAncestor:i,type:"descendant"}):((Zr(s)||Ns(e,s))&&(Zr(o)||Ns(n,o))&&i.is(s.getParent())&&i.is(o.getParent())||t(278),{a:s,b:o,commonAncestor:i,type:"branch"})}return null}function ks(e,n){const{type:r,key:i,offset:o}=e,s=Oo(e.key);return"text"===r?(Yn(s)||t(266,s.getType(),i),cs(s,n,o)):(Zr(s)||t(267,s.getType(),i),Ks(s,e.offset,n))}function Es(e,n){const{origin:r,direction:i}=n,o="next"===i;es(n)?e.set(r.getKey(),n.offset,"text"):ns(n)?Yn(r)?e.set(r.getKey(),as(r,i),"text"):e.set(r.getParentOrThrow().getKey(),r.getIndexWithinParent()+(o?1:0),"element"):(rs(n)&&Zr(r)||t(268),e.set(r.getKey(),o?0:r.getChildrenSize(),"element"))}function bs(t){const e=pr(),n=tr(e)?e:hr();return Ms(n,t),Hi(n),n}function Ms(t,e){Es(t.anchor,e.anchor),Es(t.focus,e.focus)}function Os(t){const{anchor:e,focus:n}=t,r=ks(e,"next"),i=ks(n,"next"),o=Cs(r,i)<=0?"next":"previous";return ms(Fs(r,o),Fs(i,o))}function As(t){const{direction:e,origin:n}=t,r=ls(n,Xo(e)).getNodeAtCaret();return r?ls(r,e):fs(n.getParentOrThrow(),e)}function ws(t,e="root"){const n=[t];for(let r=rs(t)?t.getParentCaret(e):t.getSiblingCaret();null!==r;r=r.getParentCaret(e))n.push(As(r));return n}function Ds(t){return!!t&&t.origin.isAttached()}function Ps(e,n="removeEmptySlices"){if(e.isCollapsed())return e;const r="root",i="next";let o=n;const s=Rs(e,i),l=ws(s.anchor,r),c=ws(s.focus.getFlipped(),r),a=new Set,u=[];for(const t of s.iterNodeCarets(r))if(rs(t))a.add(t.origin.getKey());else if(ns(t)){const{origin:e}=t;Zr(e)&&!a.has(e.getKey())||u.push(e)}for(const t of u)t.remove();for(const t of s.getTextSlices()){if(!t)continue;const{origin:e}=t.caret,n=e.getTextContentSize(),r=As(ls(e,i)),s=e.getMode();if(Math.abs(t.distance)===n&&"removeEmptySlices"===o||"token"===s&&0!==t.distance)r.remove();else if(0!==t.distance){o="removeEmptySlices";let e=t.removeTextSlice();const n=t.caret.origin;if("segmented"===s){const t=e.origin,n=Un(t.getTextContent()).setStyle(t.getStyle()).setFormat(t.getFormat());r.replaceOrInsert(n),e=cs(n,i,e.offset)}n.is(l[0].origin)&&(l[0]=e),n.is(c[0].origin)&&(c[0]=e.getFlipped())}}let f,d;for(const t of l)if(Ds(t)){f=Is(t);break}for(const t of c)if(Ds(t)){d=Is(t);break}const h=function(t,e,n){if(!t||!e)return null;const r=t.getParentAtCaret(),i=e.getParentAtCaret();if(!r||!i)return null;const o=r.getParents().reverse();o.push(r);const s=i.getParents().reverse();s.push(i);const l=Math.min(o.length,s.length);let c;for(c=0;c<l&&o[c]===s[c];c++);const a=(t,e)=>{let n;for(let r=c;r<t.length;r++){const i=t[r];if(ko(i))return;!n&&e(i)&&(n=i)}return n},u=a(o,Bo),f=u&&a(s,(t=>n.has(t.getKey())&&Bo(t)));return u&&f?[u,f]:null}(f,d,a);if(h){const[t,e]=h;fs(t,"previous").splice(0,e.getChildren()),e.remove()}const g=[f,d,...l,...c].find(Ds);if(g){return ys(Fs(Is(g),e.direction))}t(269,JSON.stringify(l.map((t=>t.origin.__key))))}function Is(t){const e=function(t){let e=t;for(;rs(e);){const t=hs(e);if(!rs(t))break;e=t}return e}(t.getLatest()),{direction:n}=e;if(Yn(e.origin))return es(e)?e:cs(e.origin,n,n);const r=e.getAdjacentCaret();return ns(r)&&Yn(r.origin)?cs(r.origin,n,Xo(n)):e}function Ls(t){return es(t)&&t.offset!==as(t.origin,t.direction)}function Fs(t,e){return t.direction===e?t:t.getFlipped()}function Rs(t,e){return t.direction===e?t:ms(Fs(t.focus,e),Fs(t.anchor,e))}function Ks(t,e,n){let r=fs(t,"next");for(let t=0;t<e;t++){const t=r.getAdjacentCaret();if(null===t)break;r=t}return Fs(r,n)}function Bs(e){const{origin:n,offset:r,direction:i}=e;if(r===as(n,i))return e.getSiblingCaret();if(r===as(n,Xo(i)))return As(e.getSiblingCaret());const[o]=n.splitText(r);return Yn(o)||t(281),Fs(ls(o,"next"),i)}function zs(t,e){return!0}exports.$addUpdateTag=xo,exports.$applyNodeReplacement=bo,exports.$caretFromPoint=ks,exports.$caretRangeFromSelection=Os,exports.$cloneWithProperties=Yo,exports.$comparePointCaretNext=Cs,exports.$copyNode=Eo,exports.$createLineBreakNode=kn,exports.$createNodeSelection=gr,exports.$createParagraphNode=pi,exports.$createPoint=qn,exports.$createRangeSelection=hr,exports.$createRangeSelectionFromDom=function(t,e){return _r(null,t,e,null)},exports.$createTabNode=jn,exports.$createTextNode=Un,exports.$extendCaretToRange=ps,exports.$getAdjacentChildCaret=hs,exports.$getAdjacentNode=fo,exports.$getAdjacentSiblingOrParentSiblingCaret=function(t,e="root"){let n=0,r=t,i=hs(r);for(;null===i;){if(n--,i=r.getParentCaret(e),!i)return null;r=i,i=hs(r)}return i&&[i,n]},exports.$getCaretInDirection=Fs,exports.$getCaretRange=ms,exports.$getCaretRangeInDirection=Rs,exports.$getCharacterOffsets=ir,exports.$getChildCaret=fs,exports.$getChildCaretAtIndex=Ks,exports.$getChildCaretOrSelf=ds,exports.$getCollapsedCaretRange=ys,exports.$getCommonAncestor=vs,exports.$getCommonAncestorResultBranchOrder=Ss,exports.$getEditor=function(){return Rr()},exports.$getNearestNodeFromDOMNode=Wi,exports.$getNearestRootOrShadowRoot=vo,exports.$getNodeByKey=Ki,exports.$getNodeByKeyOrThrow=Oo,exports.$getPreviousSelection=yr,exports.$getRoot=Yi,exports.$getSelection=pr,exports.$getSiblingCaret=ls,exports.$getState=lt,exports.$getStateChange=function(t,e,n){const r=lt(t,n,"direct"),i=lt(e,n,"direct");return n.isEqual(r,i)?null:[r,i]},exports.$getTextContent=function(){const t=pr();return null===t?"":t.getTextContent()},exports.$getTextNodeOffset=as,exports.$getTextPointCaret=cs,exports.$getTextPointCaretSlice=us,exports.$getWritableNodeState=ut,exports.$hasAncestor=So,exports.$hasUpdateTag=function(t){return Rr()._updateTags.has(t)},exports.$insertNodes=function(t){let e=pr()||yr();null===e&&(e=Yi().selectEnd()),e.insertNodes(t)},exports.$isBlockElementNode=function(t){return Zr(t)&&!t.isInline()},exports.$isChildCaret=rs,exports.$isDecoratorNode=ni,exports.$isElementNode=Zr,exports.$isExtendableTextPointCaret=Ls,exports.$isInlineElementOrDecoratorNode=function(t){return Zr(t)&&t.isInline()||ni(t)&&t.isInline()},exports.$isLeafNode=function(t){return Yn(t)||En(t)||ni(t)},exports.$isLineBreakNode=En,exports.$isNodeCaret=function(t){return t instanceof Vo},exports.$isNodeSelection=nr,exports.$isParagraphNode=function(t){return t instanceof gi},exports.$isRangeSelection=tr,exports.$isRootNode=ii,exports.$isRootOrShadowRoot=ko,exports.$isSiblingCaret=ns,exports.$isTabNode=Vn,exports.$isTextNode=Yn,exports.$isTextPointCaret=es,exports.$isTextPointCaretSlice=function(t){return t instanceof _s},exports.$isTokenOrSegmented=Mi,exports.$isTokenOrTab=bi,exports.$nodesOfType=function(t){const e=t.getType(),n=Fr();if(n._readOnly){const t=Uo(n).get(e);return t?Array.from(t.values()):[]}const r=n._nodeMap,i=[];for(const[,n]of r)n instanceof t&&n.__type===e&&n.isAttached()&&i.push(n);return i},exports.$normalizeCaret=Is,exports.$normalizeSelection__EXPERIMENTAL=gt,exports.$onUpdate=Co,exports.$parseSerializedNode=function(t){return Ur(t,Rr()._nodes)},exports.$removeTextFromCaretRange=Ps,exports.$rewindSiblingCaret=As,exports.$selectAll=function(t){const e=Yi();if(tr(t)){const e=t.anchor,n=t.focus,r=e.getNode().getTopLevelElementOrThrow().getParentOrThrow();return e.set(r.getKey(),0,"element"),n.set(r.getKey(),r.getChildrenSize(),"element"),gt(t),t}{const t=e.select(0,e.getChildrenSize());return Hi(gt(t)),t}},exports.$setCompositionKey=Fi,exports.$setPointFromCaret=Es,exports.$setSelection=Hi,exports.$setSelectionFromCaretRange=bs,exports.$setState=function(t,e,n){let r;if(Ir(),"function"==typeof n){const i=t.getLatest(),o=lt(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},exports.$splitAtPointCaretNext=function(t,{$copyElementNode:e=Eo,$splitTextPointCaretNext:n=Bs,rootMode:r="shadowRoot",$shouldSplit:i=zs}={}){if(es(t))return n(t);const o=t.getParentCaret(r);if(o){const{origin:n}=o;if(rs(t)&&(!n.canBeEmpty()||!i(n,"first")))return As(o);const r=function(t){const e=[];for(let n=t.getAdjacentCaret();n;n=n.getAdjacentCaret())e.push(n.origin);return e}(t);(r.length>0||n.canBeEmpty()&&i(n,"last"))&&o.insert(e(n).splice(0,0,r))}return o},exports.$splitNode=function(e,n){let r=e.getChildAtIndex(n);null==r&&(r=e),ko(e)&&t(102);const i=e=>{const n=e.getParentOrThrow(),o=ko(n),s=e!==r||o?Eo(e):e;if(o)return Zr(e)&&Zr(s)||t(133),e.insertAfter(s),[e,s,s];{const[t,r,o]=i(n),l=e.getNextSiblings();return o.append(s,...l),[t,r,s]}},[o,s]=i(r);return[o,s]},exports.$updateRangeSelectionFromCaretRange=Ms,exports.ArtificialNode__DO_NOT_USE=hi,exports.BLUR_COMMAND=$e,exports.CAN_REDO_COMMAND=Be,exports.CAN_UNDO_COMMAND=ze,exports.CLEAR_EDITOR_COMMAND=Re,exports.CLEAR_HISTORY_COMMAND=Ke,exports.CLICK_COMMAND=ee,exports.COLLABORATION_TAG=ui,exports.COMMAND_PRIORITY_CRITICAL=4,exports.COMMAND_PRIORITY_EDITOR=0,exports.COMMAND_PRIORITY_HIGH=3,exports.COMMAND_PRIORITY_LOW=1,exports.COMMAND_PRIORITY_NORMAL=2,exports.CONTROLLED_TEXT_INSERTION_COMMAND=oe,exports.COPY_COMMAND=Ie,exports.CUT_COMMAND=Le,exports.DELETE_CHARACTER_COMMAND=ne,exports.DELETE_LINE_COMMAND=ae,exports.DELETE_WORD_COMMAND=ce,exports.DRAGEND_COMMAND=Pe,exports.DRAGOVER_COMMAND=De,exports.DRAGSTART_COMMAND=we,exports.DROP_COMMAND=Oe,exports.DecoratorNode=ei,exports.ElementNode=Qr,exports.FOCUS_COMMAND=We,exports.FORMAT_ELEMENT_COMMAND=Ae,exports.FORMAT_TEXT_COMMAND=ue,exports.HISTORIC_TAG="historic",exports.HISTORY_MERGE_TAG=ai,exports.HISTORY_PUSH_TAG="history-push",exports.INDENT_CONTENT_COMMAND=be,exports.INSERT_LINE_BREAK_COMMAND=re,exports.INSERT_PARAGRAPH_COMMAND=ie,exports.INSERT_TAB_COMMAND=Ee,exports.INTERNAL_$isBlock=Bo,exports.IS_ALL_FORMATTING=E,exports.IS_BOLD=1,exports.IS_CODE=16,exports.IS_HIGHLIGHT=k,exports.IS_ITALIC=2,exports.IS_STRIKETHROUGH=T,exports.IS_SUBSCRIPT=32,exports.IS_SUPERSCRIPT=64,exports.IS_UNDERLINE=v,exports.KEY_ARROW_DOWN_COMMAND=xe,exports.KEY_ARROW_LEFT_COMMAND=pe,exports.KEY_ARROW_RIGHT_COMMAND=ge,exports.KEY_ARROW_UP_COMMAND=me,exports.KEY_BACKSPACE_COMMAND=Ne,exports.KEY_DELETE_COMMAND=ve,exports.KEY_DOWN_COMMAND=he,exports.KEY_ENTER_COMMAND=Ce,exports.KEY_ESCAPE_COMMAND=Te,exports.KEY_MODIFIER_COMMAND=Ue,exports.KEY_SPACE_COMMAND=Se,exports.KEY_TAB_COMMAND=ke,exports.LineBreakNode=Tn,exports.MOVE_TO_END=_e,exports.MOVE_TO_START=ye,exports.NODE_STATE_KEY="$",exports.OUTDENT_CONTENT_COMMAND=Me,exports.PASTE_COMMAND=se,exports.PASTE_TAG="paste",exports.ParagraphNode=gi,exports.REDO_COMMAND=de,exports.REMOVE_TEXT_COMMAND=le,exports.RootNode=ri,exports.SELECTION_CHANGE_COMMAND=Zt,exports.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND=te,exports.SELECT_ALL_COMMAND=Fe,exports.SKIP_COLLAB_TAG="skip-collab",exports.SKIP_DOM_SELECTION_TAG=di,exports.SKIP_SCROLL_INTO_VIEW_TAG=fi,exports.TEXT_TYPE_TO_FORMAT=z,exports.TabNode=Hn,exports.TextNode=In,exports.UNDO_COMMAND=fe,exports.createCommand=Qt,exports.createEditor=function(t){const e=t||{},n=Br(),r=e.theme||{},i=void 0===t?n:e.parentEditor||null,o=e.disableEvents||!1,s=si(),l=e.namespace||(null!==i?i._config.namespace:Xi()),c=e.editorState,a=[ri,In,Tn,Hn,gi,hi,...e.nodes||[]],{onError:u,html:f}=e,d=void 0===e.editable||e.editable;let h;if(void 0===t&&null!==n)h=n._nodes;else{h=new Map;for(let t=0;t<a.length;t++){let e=a[t],n=null,r=null;if("function"!=typeof e){const t=e;e=t.replace,n=t.with,r=t.withKlass||null}const i=e.getType(),o=e.transform(),s=new Set;null!==o&&s.add(o),h.set(i,{exportDOM:f&&f.export?f.export.get(e):void 0,klass:e,replace:n,replaceWithKlass:r,transforms:s})}}const g=new mi(s,i,h,{disableEvents:o,namespace:l,theme:r},u||console.error,function(t,e){const n=new Map,r=new Set,i=t=>{Object.keys(t).forEach((e=>{let r=n.get(e);void 0===r&&(r=[],n.set(e,r)),r.push(t[e])}))};return t.forEach((t=>{const e=t.klass.importDOM;if(null==e||r.has(e))return;r.add(e);const n=e.call(t.klass);null!==n&&i(n)})),e&&i(e),n}(h,f?f.import:void 0),d,t);return void 0!==c&&(g._pendingEditorState=c,g._dirtyType=x),g},exports.createState=function(t,e){return new st(t,e)},exports.flipDirection=Xo,exports.getDOMOwnerDocument=mo,exports.getDOMSelection=Do,exports.getDOMSelectionFromTarget=Po,exports.getDOMTextNode=wi,exports.getEditorPropertyFromDOMNode=Ei,exports.getNearestEditorFromDOMNode=ki,exports.isBlockDomNode=Ko,exports.isCurrentlyReadOnlyMode=Pr,exports.isDOMDocumentNode=Ai,exports.isDOMNode=Lo,exports.isDOMTextNode=Oi,exports.isDOMUnmanaged=Ho,exports.isDocumentFragment=Fo,exports.isExactShortcutMatch=ro,exports.isHTMLAnchorElement=function(t){return Io(t)&&"A"===t.tagName},exports.isHTMLElement=Io,exports.isInlineDomNode=Ro,exports.isLexicalEditor=vi,exports.isModifierMatch=no,exports.isSelectionCapturedInDecoratorInput=Ni,exports.isSelectionWithinEditor=Ti,exports.makeStepwiseIterator=xs,exports.removeFromParent=Ii,exports.resetRandomKey=function(){xi=1},exports.setDOMUnmanaged=function(t){t.__lexicalUnmanaged=!0},exports.setNodeIndentFromDOM=Jo;