lexical
Version:
Lexical is an extensible text editor framework that provides excellent reliability, accessible and performance.
10 lines (9 loc) • 177 kB
JavaScript
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
"use strict";function t(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function e(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);n.search=o.toString(),console.warn(`Minified Lexical warning #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const n="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,o=n&&"documentMode"in document?document.documentMode:null,r=n&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),s=n&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),i=!(!n||!("InputEvent"in window)||o)&&"getTargetRanges"in new window.InputEvent("input"),l=n&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,c=n&&/Android/.test(navigator.userAgent),a=n&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!c,u=n&&/^(?=.*Chrome).*/i.test(navigator.userAgent),f=n&&c&&u,d=n&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&r&&!u,h=0,g=1,_=2,p=128,m=1,y=2,x=3,C=4,S=5,T=6,N=a||l||d?"\xa0":"\u200b",v="\n\n",k=s?"\xa0":N,E="\u0591-\u07ff\ufb1d-\ufdfd\ufe70-\ufefc",O="A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02b8\u0300-\u0590\u0800-\u1fff\u200e\u2c00-\ufb1c\ufe00-\ufe6f\ufefd-\uffff",b=new RegExp("^[^"+O+"]*["+E+"]"),M=new RegExp("^[^"+E+"]*["+O+"]"),A={bold:1,capitalize:1024,code:16,highlight:p,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},w={directionless:1,unmergeable:2},D={center:2,end:6,justify:4,left:1,right:3,start:5},I={[y]:"center",[T]:"end",[C]:"justify",[m]:"left",[x]:"right",[S]:"start"},P={normal:0,segmented:2,token:1},F={[h]:"normal",[_]:"segmented",[g]:"token"},R="$config";function L(){return Ol()._blockCursorElement}function K(t){return null!==t&&1===t.nodeType&&t.hasAttribute("data-lexical-slot")}class B{element;before;after;constructor(t,e,n){this.element=t,this.before=e||null,this.after=n||null}withBefore(t){return new B(this.element,t,this.after)}withAfter(t){return new B(this.element,this.before,t)}withElement(t){return this.element===t?this:new B(t,this.before,this.after)}insertChild(e){const n=this.getInsertionAnchor();return null!==n&&n.parentElement!==this.element&&t(357),this.element.insertBefore(e,n),this}removeChild(e){return e.parentElement!==this.element&&t(358),this.element.removeChild(e),this}replaceChild(e,n){return n.parentElement!==this.element&&t(359),this.element.replaceChild(e,n),this}getFirstChild(){const t=this.getFirstChildAnchor(),e=t?t.nextSibling:this.element.firstChild;return e===this.getInsertionAnchor()?null:e}getFirstChildAnchor(){return this.after}resolveLeafPosition(t,e,n){if(this.element===t)return e===t&&0===n?"before":"after";const o=z(t,this.element);if(null===o)return"after";const r=Array.prototype.indexOf.call(t.childNodes,o);if(r<0)return"after";if(e===t)return n<=r?"before":"after";const s=z(t,e);if(null===s)return"after";const i=Array.prototype.indexOf.call(t.childNodes,s);return i>=0&&i<=r?"before":"after"}getInsertionAnchor(){return this.before}}function z(t,e){let n=e;for(;null!==n&&n.parentNode!==t;)n=n.parentNode;return n}class $ extends B{withBefore(t){return new $(this.element,t,this.after)}withAfter(t){return new $(this.element,this.before,t)}withElement(t){return this.element===t?this:new $(t,this.before,this.after)}getInsertionAnchor(){return super.getInsertionAnchor()||this.getManagedLineBreak()}getFirstChildAnchor(){let t=super.getFirstChildAnchor(),e=t?t.nextSibling:this.element.firstChild;for(;K(e);)t=e,e=e.nextSibling;const n=t?t.nextSibling:this.element.firstChild;return null!==n&&n===L()?n:t}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(t){if(this.element.__lexicalLastChildKind=t,null===t)this.removeManagedLineBreak();else{const e="decorator"===t&&(d||l||a);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,o=this.before,r=al().createElement("br");if(r.setAttribute("data-lexical-managed-linebreak","true"),n.insertBefore(r,o),t){const t=al().createElement("img");t.setAttribute("data-lexical-managed-linebreak","true"),t.style.setProperty("display","inline","important"),t.style.setProperty("border","0px","important"),t.style.setProperty("margin","0px","important"),t.alt="",n.insertBefore(t,r),n.__lexicalLineBreak=t}else n.__lexicalLineBreak=r}getFirstChildOffset(){const t=this.getFirstChild(),e=this.getInsertionAnchor();let n=0;for(let o=this.element.firstChild;null!==o&&o!==t&&o!==e;o=o.nextSibling)n++;return n}resolveChildIndex(t,e,n,o){if(n===this.element){const e=this.getFirstChildOffset(),n=L(),r=this.element.childNodes,s=Math.min(o,r.length);let i=0;for(let t=e;t<s;t++)r[t]!==n&&i++;return[t,Math.min(i,t.getChildrenSize())]}const r=W(e,n);r.push(o);const s=W(e,this.element);let i=t.getIndexWithinParent();for(let t=0;t<s.length;t++){const e=r[t],n=s[t];if(void 0===e||e<n)break;if(e>n){i+=1;break}}return[t.getParentOrThrow(),i]}}function W(e,n){const o=[];let r=n;for(;r!==e&&null!==r;r=r.parentNode){let t=0;for(let e=r.previousSibling;null!==e;e=e.previousSibling)t++;o.push(t)}return r!==e&&t(225),o.reverse()}let U;try{U="0.47.0+prod.cjs"}catch(t){}const H=U??'"<unknown>+source"';class j{_front=new Set;_back=new Set;_cache;get size(){return this._front.size+this._back.size}addBack(t){return delete this._cache,this._front.has(t)||this._back.add(t),this}addFront(t){return delete this._cache,this._back.has(t)||this._front.add(t),this}delete(t){return delete this._cache,this._front.delete(t)||this._back.delete(t)}toArray(){const t=Array.from(this._front).reverse();for(const e of this._back)t.push(e);return t}toReadonlyArray(){return this._cache=this._cache||this.toArray(),this._cache}[Symbol.iterator](){return this.toReadonlyArray()[Symbol.iterator]()}}const Y=null;function J(t,e=1e3){return t instanceof G?t.clone():t.size<e?new Map(t):(new G).init(new Map(t),void 0,t.size)}class G{_mutable=!1;_old=void 0;_nursery=void 0;_size=0;clone(){return this._mutable=!1,(new G).init(this._old,this._nursery,this._size)}init(t,e,n){return this._old=t,this._nursery=e,this._size=n,this}get size(){return this._size}has(t){return void 0!==this.get(t)}getWithTombstone(t){const e=this._nursery&&this._nursery.get(t);return void 0!==e?e:this._old&&this._old.get(t)}get(t){const e=this.getWithTombstone(t);return e===Y?void 0:e}shouldCompact(){return void 0!==this._nursery&&2*this._nursery.size>this._size}getNursery(){return this._mutable&&this._nursery||(this.compact(),this._nursery=new Map(this._nursery),this._mutable=!0),this._nursery}compact(t=!1){if(this._nursery&&this._nursery.size>0&&(t||this.shouldCompact())){const t=new Map(this._old);for(const[e,n]of this._nursery)n!==Y?t.set(e,n):t.delete(e);this._old=t,this._nursery=void 0}return this._mutable=!1,this}set(t,e){const n=this.getWithTombstone(t);if(n===e)return this;const o=this.getNursery();return n!==Y&&void 0!==n||(this._size++,n===Y&&o.delete(t)),o.set(t,e),this}delete(t){const e=this.has(t);return e&&(this.getNursery().set(t,Y),this._size--),e}getOrInsert(t,e){const n=this.get(t);return void 0!==n?n:(this.set(t,e),e)}getOrInsertComputed(t,e){const n=this.get(t);if(void 0!==n)return n;const o=e(t);return this.set(t,o),o}clear(){this._mutable=!1,this._old=void 0,this._nursery=void 0,this._size=0}*keys(){for(const t of this.entries())yield t[0]}*values(){for(const t of this.entries())yield t[1]}*entries(){const t=this._nursery,e=this._old;if(e)for(const n of e){const e=n[0],o=t?t.get(e):void 0;o!==Y&&(void 0!==o&&(n[1]=o),yield n)}if(t)for(const n of t)n[1]===Y||e&&e.has(n[0])||(yield n)}forEach(t,e){void 0!==e&&(t=t.bind(e));for(const[e,n]of this.entries())t(n,e,this)}get[Symbol.toStringTag](){return"GenMap"}[Symbol.iterator](){return this.entries()}}function V(t,e,n,o,r,s){if(cs(t)){let i=t.getFirstChild();for(;null!==i;){const t=i.__key;i.__parent===e&&((cs(i)||Xl(i)&&null!==i.__slots)&&V(i,t,n,o,r,s),n.has(t)||s.delete(t),r.push(t)),i=i.getNextSibling()}}for(const i of Xl(t)&&null!==t.__slots?t.__slots.values():[]){const t=o.get(i);void 0!==t&&Ql(t)&&t.__slotHost===e&&((cs(t)||Xl(t)&&null!==t.__slots)&&V(t,i,n,o,r,s),n.has(i)||s.delete(i),r.push(i))}}let q=!1,X=0;function Q(t){X=t.timeStamp}function Z(t,e,n){const o="BR"===t.nodeName,r=e.__lexicalLineBreak;return r&&(t===r||o&&t.previousSibling===r)||o&&void 0!==fi(t,n)}function tt(t,e,n){const o=nl(ji(n)),r=o&&dl(o,n._rootElement);let s=null,i=null;null!==r&&r.anchorNode===t&&(s=r.anchorOffset,i=r.focusOffset);const l=t.nodeValue;null!==l&&vi(e,l,s,i,!1)}function et(t,e,n){if(Uo(t)){const e=t.anchor.getNode();if(e.is(n)&&t.format!==e.getFormat())return!1}return Qs(e)&&n.isAttached()}function nt(t,e,n){for(let o=t;o&&!zl(o);o=Bi(o)){const t=fi(o,e);if(void 0!==t){const e=ci(t,n);if(e)return fs(e)||!xl(o)?void 0:[o,e]}}}function ot(t,e,n){q=!0;const o=performance.now()-X>100;try{ss(t,()=>{const r=_r()||function(t){return t.read("latest",()=>{const t=_r();return null!==t?t.clone():null})}(t),i=new Map,l=t._editorState,c=t._blockCursorElement;let a=!1,u="";for(let n=0;n<e.length;n++){const f=e[n],d=f.type,h=f.target,g=nt(h,t,l);if(!g)continue;const[_,p]=g;if("characterData"===d)o&&Do(p)&&Qs(h)&&et(r,h,p)&&tt(h,p,t);else if("childList"===d){a=!0;const e=f.addedNodes;for(let n=0;n<e.length;n++){const o=e[n],r=ai(o),i=o.parentNode;if(!(null==i||o===c||null!==r||Z(o,i,t)||t._slotsUsed&&xl(o)&&o.hasAttribute("data-lexical-slot")||zl(o))){if(s){const t=(xl(o)?o.innerText:null)||o.nodeValue;t&&(u+=t)}i.removeChild(o)}}const n=f.removedNodes,o=n.length;if(o>0){let e=0;for(let r=0;r<o;r++){const o=n[r];(Z(o,h,t)||c===o)&&(h.appendChild(o),e++)}o!==e&&i.set(_,p)}}}if(i.size>0)for(const[e,n]of i)n.reconcileObservedMutation(e,t);const f=n.takeRecords();if(f.length>0){for(let e=0;e<f.length;e++){const n=f[e],o=n.addedNodes,r=n.target;for(let e=0;e<o.length;e++){const n=o[e],s=n.parentNode;null==s||"BR"!==n.nodeName||Z(n,r,t)||s.removeChild(n)}}n.takeRecords()}null!==r&&(a&&pi(r),s&&Ri(t)&&r.insertRawText(u))})}finally{q=!1}}function rt(t){const e=t._observer;if(null!==e){ot(t,e.takeRecords(),e)}}function st(t){!function(t){0===X&&ji(t).addEventListener("textInput",Q,!0)}(t),t._observer=new MutationObserver((e,n)=>{ot(t,e,n)})}const it="direct",lt="latest";class ct{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;constructor(t,e){this.key=t,this.parse=e.parse.bind(e),this.unparse=(e.unparse||pt).bind(e),this.isEqual=(e.isEqual||Object.is).bind(e),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=e.resetOnCopyNode||!1}}function at(t,e,n=lt){const o=(n===lt?t.getLatest():t).__state;return o?o.getValue(e):e.defaultValue}function ut(t){const e=new Map,n=new Set;for(const{ownNodeConfig:o}of Yl("function"==typeof t?t:t.replace))if(o&&o.stateConfigs)for(const t of o.stateConfigs){let o;"stateConfig"in t?(o=t.stateConfig,t.flat&&n.add(o.key)):o=t,e.set(o.key,o)}return{flatKeys:n,sharedConfigMap:e}}const ft=new Set(["__proto__","constructor","prototype"]);class dt{node;knownState;unknownState;sharedNodeState;size;constructor(t,e,n=void 0,o=new Map,r=void 0){this.node=t,this.sharedNodeState=e,this.unknownState=n,this.knownState=o;const{sharedConfigMap:s}=this.sharedNodeState,i=void 0!==r?r:function(t,e,n){let o=n.size;if(e)for(const r in e){const e=t.get(r);e&&n.has(e)||o++}return o}(s,n,o);this.size=i}getValue(t){const e=this.knownState.get(t);if(void 0!==e)return e;this.sharedNodeState.sharedConfigMap.set(t.key,t);let n=t.defaultValue;if(this.unknownState&&t.key in this.unknownState){const e=this.unknownState[t.key];void 0!==e&&(n=t.parse(e)),this.updateFromKnown(t,n)}return n}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){const t={...this.unknownState},e={};for(const[e,n]of this.knownState)e.isEqual(n,e.defaultValue)?delete t[e.key]:t[e.key]=e.unparse(n);for(const n of this.sharedNodeState.flatKeys)n in t&&(e[n]=t[n],delete t[n]);return _t(t)&&(e.$=t),e}getWritable(t){if(this.node===t)return this;const{sharedNodeState:e,unknownState:n}=this,o=new Map(this.knownState);return new dt(t,e,function(t,e,n){let o;if(n)for(const[r,s]of Object.entries(n)){if(ft.has(r))continue;const n=t.get(r);n?e.has(n)||e.set(n,n.parse(s)):(o=o||{},o[r]=s)}return o}(e.sharedConfigMap,o,n),o,this.size)}resetOnCopyNode(){for(const t of this.knownState.keys())t.resetOnCopyNode&&this.knownState.set(t,t.defaultValue);return this}updateFromKnown(t,e){const n=t.key;this.sharedNodeState.sharedConfigMap.set(n,t);const{knownState:o,unknownState:r}=this;o.has(t)||r&&n in r||(r&&(delete r[n],this.unknownState=_t(r)),this.size++),o.set(t,e)}updateFromUnknown(t,e){if(ft.has(t))return;const n=this.sharedNodeState.sharedConfigMap.get(t);n?this.updateFromKnown(n,n.parse(e)):(this.unknownState=this.unknownState||{},t in this.unknownState||this.size++,this.unknownState[t]=e)}updateFromJSON(t){const{knownState:e}=this;for(const t of e.keys())e.set(t,t.defaultValue);if(this.size=e.size,this.unknownState=void 0,t)for(const[e,n]of Object.entries(t))this.updateFromUnknown(e,n)}}function ht(t){const e=t.getWritable(),n=e.__state?e.__state.getWritable(e):new dt(e,gt(e));return e.__state=n,n}function gt(t){return t.__state?t.__state.sharedNodeState:$s(Ol(),t.getType()).sharedNodeState}function _t(t){if(t)for(const e in t)return t}function pt(t){return t}function mt(t,e,n){for(const[o,r]of e.knownState){if(t.has(o.key))continue;t.add(o.key);const e=n?n.getValue(o):o.defaultValue;if(e!==r&&!o.isEqual(e,r))return!0}return!1}function yt(t,e,n){const{unknownState:o}=e,r=n?n.unknownState:void 0;if(o)for(const[e,n]of Object.entries(o)){if(t.has(e))continue;t.add(e);if(n!==(r?r[e]:void 0))return!0}return!1}function xt(t,e){const n=t.__state;return n&&n.node===t?n.getWritable(e):n}function Ct(t,e){const n=t.__mode,o=t.__format,r=t.__style,s=e.__mode,i=e.__format,l=e.__style,c=t.__state,a=e.__state;return(null===n||n===s)&&(null===o||o===i)&&(null===r||r===l)&&(null===t.__state||c===a||function(t,e){if(t===e)return!0;const n=new Set;return!(t&&mt(n,t,e)||e&&mt(n,e,t)||t&&yt(n,t,e)||e&&yt(n,e,t))}(c,a))}function St(t,e){const n=t.mergeWithSibling(e),o=Hr()._normalizedNodes;return o.add(t.__key),o.add(e.__key),n}function Tt(t){let e,n,o=t;if(""!==o.__text||!o.isSimpleText()||o.isUnmergeable()){for(;null!==(e=o.getPreviousSibling())&&Do(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(""!==e.__text){if(Ct(e,o)){o=St(e,o);break}break}e.remove()}for(;null!==(n=o.getNextSibling())&&Do(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(""!==n.__text){if(Ct(o,n)){o=St(o,n);break}break}n.remove()}}else o.remove()}function Nt(t){return vt(t.anchor),vt(t.focus),t}function vt(t){for(;"element"===t.type;){const e=t.getNode(),n=t.offset;let o,r;if(n===e.getChildrenSize()?(o=e.getChildAtIndex(n-1),r=!0):(o=e.getChildAtIndex(n),r=!1),Do(o)){t.set(o.__key,r?o.getTextContentSize():0,"text",!0);break}if(!cs(o))break;t.set(o.__key,r?o.getChildrenSize():0,"element",!0)}}const kt=Symbol.for("@lexical/CachedTextSize");function Et(e,n){return Ut.read(()=>{let o=0,r=e;for(let e=0;e<n&&null!==r;e++){const s=Wt.get(r);if(void 0===s&&t(345,r),cs(s)){const i=Ht.get(r);if(void 0!==i&&cs(i)&&i.__parent!==s.__parent)o+=s.getTextContentSize();else{const e=jt.get(r),n=e&&e.__lexicalTextContent;"string"!=typeof n&&t(346,s.getType()),o+=n.length}e<n-1&&!s.isInline()&&(o+=2)}else{const e=s[kt];void 0===e&&t(347,s.getType(),r),o+=e}r=s.__next}return o},{editor:At})}function Ot(t){cs(t)||void 0===t[kt]&&(t[kt]=Do(t)?t.__text.length:t.getTextContentSize())}const bt=4;let Mt,At,wt,Dt="",It=null,Pt=null,Ft=null;function Rt(){return{firstTextKey:Ft,format:It,style:Pt}}function Lt(t){null!==t.firstTextKey&&(It=t.format,Pt=t.style,Ft=t.firstTextKey)}function Kt(e){if(null!==Ft)return;const n=e.__lexicalFirstTextKey;if(void 0===n&&t(348),null===n)return;const o=Ht.get(n);Do(o)&&(It=o.getFormat(),Pt=o.getStyle(),Ft=n)}let Bt,zt,$t,Wt,Ut,Ht,jt,Yt,Jt,Gt,Vt=!1,qt=!1;function Xt(t,e){const n=Wt.get(t),o=Ht.has(t);if(null!==e){const n=Se(t);n.parentNode===e&&e.removeChild(n)}if(!o){if(At._keyToDOMMap.delete(t),cs(n)){const t=Gl(n,Wt);Qt(t,0,t.length-1,null)}if(void 0!==n){for(const t of le(n).values()){const e=ae(t);Xt(t,null),null!==e&&e.remove()}Ii(Jt,wt,Bt,n,"destroyed")}}}function Qt(t,e,n,o){for(let r=e;r<=n;++r){const e=t[r];void 0!==e&&Xt(e,o)}}function Zt(t,e){t.setProperty("text-align",e)}const te="40px";function ee(t,e){const n=Mt.theme.indent;if("string"==typeof n){const o=t.classList.contains(n);e>0&&!o?t.classList.add(n):e<1&&o&&t.classList.remove(n)}t.style.setProperty("padding-inline-start",0===e?"":`calc(${e} * var(--lexical-indent-base-value, ${te}))`)}function ne(t,e){const n=t.style;0===e?Zt(n,""):1===e?Zt(n,"left"):2===e?Zt(n,"center"):3===e?Zt(n,"right"):4===e?Zt(n,"justify"):5===e?Zt(n,"start"):6===e&&Zt(n,"end")}function oe(t,e){const n=function(t){const e=t.__dir;if(null!==e)return e;if(hs(t))return null;const n=t.getParent();return null===n||Vi(n)&&null===n.__dir?"auto":null}(e);null!==n?t.dir=n:t.removeAttribute("dir")}function re(t){const e=al().createElement("div");return e.setAttribute("data-lexical-slot",t),e.style.display="none",e}function se(t,e,n){e||"false"===t.contentEditable?$l(n,At):n.removeAttribute("contenteditable")}function ie(t,e,n){const o=Dt,r=Rt();Dt="";let s="";const i=fs(t);for(const[o,r]of n){const n=re(o);se(e,i,n),e.appendChild(n),Dt="";const l=Rt();fe(r,Ml(t,n,At)),Lt(l),ce(t,o,e,n),s+=Dt}return Lt(r),Dt=o,s}function le(t){return Xl(t)&&null!==t.__slots?t.__slots:ql}function ce(t,e,n,o){const r=Gt.$getSlotTargetElement(t,e,n,At);null!==r&&(o.parentElement!==r&&r.appendChild(o),o.style.display="")}function ae(t){const e=jt.get(t);return void 0!==e?e.parentElement:null}function ue(t,e,n){const o=le(t),r=le(e);for(const[t,e]of o)if(!r.has(t)){const t=ae(e);Xt(e,null),null!==t&&t.remove()}const s=Dt,i=Rt();let l="",c=null;const a=fs(e);for(const[t,s]of r){const r=o.get(t);let i=void 0!==r?ae(r):null;Dt="";const u=Rt();if(null===i){i=re(t);let o=null;for(const t of n.children)if(!t.hasAttribute("data-lexical-slot")){o=t;break}n.insertBefore(i,o),fe(s,Ml(e,i,At))}else r===s?pe(s,i):(void 0!==r&&Xt(r,i),fe(s,Ml(e,i,At)));if(Lt(u),se(n,a,i),ce(e,t,n,i),l+=Dt,i.parentElement===n){const t=null===c?n.firstChild:c.nextSibling;t!==i&&n.insertBefore(i,t),c=i}}return Lt(i),Dt=s,l}function fe(e,n){const o=Ht.get(e);if(void 0===o&&t(60),null!==n){const t=Wt.get(e);if(void 0!==t){const r=jt.get(e);if(void 0!==r){const s=Ql(t)?t.__slotHost:null,i=Ql(o)?o.__slotHost:null,l=t.__parent!==o.__parent||s!==i,c=null!==i&&r.parentElement!==n.element;if(l||c)return n.insertChild(r),pe(e,n.element)}}}const r=Gt.$createDOM(o,At);if(function(t,e,n){const o=n._keyToDOMMap;ui(e,n,t),o.set(t,e)}(e,r,At),Do(o)?r.setAttribute("data-lexical-text","true"):fs(o)&&(r.setAttribute("data-lexical-decorator","true"),Bl(r,{captureSelection:!0})),cs(o)){const t=o.__indent,e=o.__size;oe(r,o),0!==t&&ee(r,t);const n=le(o),s=n.size>0?ie(o,r,n):"";if(0===e)r.__lexicalTextContent=s,r.__lexicalFirstTextKey=null,Dt+=s,n.size>0&&(r.__lexicalSlotTextLength=s.length);else{const t=Dt,i=e-1;if(de(Gl(o,Ht),o,0,i,Ml(o,r,At)),""!==s){const e=r.__lexicalTextContent||"";r.__lexicalTextContent=s+e,Dt=t+s+e}n.size>0&&(r.__lexicalSlotTextLength=s.length)}const i=o.__format;0!==i&&ne(r,i),o.isInline()||he(null,o,r)}else{const t=o.getTextContent();if(fs(o)){const t=o.decorate(At,Mt);null!==t&&me(e,t),r.contentEditable="false";const n=le(o);n.size>0&&ie(o,r,n)}Dt+=t}return null!==n&&n.insertChild(r),Gt.$decorateDOM(o,null,r,At),Ot(o),Ii(Jt,wt,Bt,o,"created"),r}function de(e,n,o,r,s){const i=Dt,l=Rt();Dt="",It=null,Pt=null,Ft=null;let c=o;for(;c<=r;++c){const t=Rt();fe(e[c],s);const n=Ht.get(e[c]);null!==n&&Do(n)?null===It&&(It=n.getFormat(),Pt=n.getStyle(),Ft=n.__key):cs(n)&&c<r&&!n.isInline()&&(Dt+=v),Lt(t)}const a=At._keyToDOMMap.get(n.__key);void 0===a&&t(349,n.__key),a.__lexicalTextContent=Dt,a.__lexicalFirstTextKey=Ft,Dt=i+Dt,Lt(l)}function he(t,e,n){const o=Ml(e,n,At),r=o.element.__lexicalLastChildKind??null,s=function(t,e){if(t){const n=t.__last;if(n){const t=e.get(n);if(t)return Ts(t)?"line-break":fs(t)&&t.isInline()?"decorator":null}return le(t).size>0?null:"empty"}return null}(e,Ht);r!==s&&o.setManagedLineBreak(s)}function ge(e,n,o){var r;It=null,Pt=null,Ft=null,function(e,n,o){const r=Dt,s=e.__size,i=n.__size;Dt="";const l=o.element,c=At._keyToDOMMap.get(n.__key);void 0===c&&t(351,n.__key);const a=i-s;if(!Vt&&Math.abs(a)<=1&&s>=bt&&e.__first===n.__first&&(0!==a||!At._cloneNotNeeded.has(e.__key))){const s=c.__lexicalTextContent,u=Yt.get(e.__key);if(!Vt&&"string"==typeof s&&void 0!==u){const i=function(t,e){const n=e.size;if(0===n||n>=t.__size)return null;let o=t.__last,r=null,s=0;for(;null!==o&&s<n;){if(!e.has(o))return null;r=o;const t=Ht.get(o);if(void 0===t)return null;o=t.__prev,s++}if(s!==n)return null;if(null!==o&&e.has(o))return null;return r}(n,u);if(null!==i){const f=u.size;if(0===a){const e=Et(i,f);let o=i,a=0;for(;null!==o&&a<f;){const t=Ht.get(o);if(void 0===t)break;const e=Rt();pe(o,l),Do(t)&&null===It&&(It=t.getFormat(),Pt=t.getStyle(),Ft=t.__key),Lt(e),o=t.__next,a++}let d="";for(o=i,a=0;null!==o&&a<f;){const e=Ht.get(o);if(void 0===e)break;let n;if(cs(e)){const r=At._keyToDOMMap.get(o),s=r&&r.__lexicalTextContent;"string"!=typeof s&&t(352,e.getType()),n=s}else n=e.getTextContent();d+=n,a<f-1&&cs(e)&&!e.isInline()&&(d+=v),o=e.__next,a++}const h=c.__lexicalSlotTextLength||0,g=h>0?s.slice(h):s,_=g.slice(0,g.length-e)+d;return c.__lexicalTextContent=_,Dt=r+_,void _e(n,c,u)}if(function(e,n,o,r,s,i,l,c){if(1!==c&&-1!==c)return!1;const a=1===c?2:1;if(l!==a)return!1;const u=l-c;let f=e.__last;for(let t=0;t<u-1;t++){if(null===f)return!1;const t=Wt.get(f);if(void 0===t)return!1;f=t.__prev}if(null===f)return!1;const d=Ht.get(i),h=Wt.get(f);if(void 0===d||void 0===h)return!1;if(d.__prev!==h.__prev)return!1;const g=[];let _=i;for(let t=0;t<l;t++){if(null===_)return!1;g.push(_);const t=Ht.get(_);_=t?t.__next:null}const p=[];_=f;for(let t=0;t<u;t++){if(null===_)return!1;p.push(_);const t=Wt.get(_);_=t?t.__next:null}const m=new Set(p),y=new Set(g),x=[];let C=0,S=0;for(;C<u&&S<l;)if(g[S]===p[C])x.push({key:g[S],kind:"reconcile"}),C++,S++;else if(y.has(p[C])){if(m.has(g[S]))return!1;x.push({key:g[S],kind:"create",nextIndex:S}),S++}else x.push({key:p[C],kind:"destroy"}),C++;for(;C<u;)x.push({key:p[C++],kind:"destroy"});for(;S<l;)x.push({key:g[S],kind:"create",nextIndex:S}),S++;const T=Et(f,u);for(const t of x){const e=Rt();if("reconcile"===t.kind)pe(t.key,o.element);else if("destroy"===t.kind)Xt(t.key,o.element);else{let e=null;for(let n=t.nextIndex+1;n<l;n++){const t=At._keyToDOMMap.get(g[n]);if(void 0!==t){e=t;break}}fe(t.key,o.withBefore(e??o.before))}if("destroy"!==t.kind){const e=Ht.get(t.key);e&&Do(e)&&null===It&&(It=e.getFormat(),Pt=e.getStyle(),Ft=e.__key)}Lt(e)}let N="";for(let e=0;e<l;e++){const n=Ht.get(g[e]);if(void 0===n)return!1;let o;if(cs(n)){const r=At._keyToDOMMap.get(g[e]),s=r&&r.__lexicalTextContent;"string"!=typeof s&&t(350,n.getType()),o=s}else o=n.getTextContent();N+=o,e<l-1&&cs(n)&&!n.isInline()&&(N+=v)}const k=r.__lexicalSlotTextLength||0,E=k>0?s.slice(k):s;return r.__lexicalTextContent=E.slice(0,E.length-T)+N,!0}(e,0,o,c,s,i,f,a)){const e=c.__lexicalTextContent;return"string"!=typeof e&&t(353),Dt=r+e,void _e(n,c,u)}}}if(0===a){let n=e.__first,o=0;for(;null!==n;){const e=Ht.get(n);if(void 0===e)break;const r=Vt||$t.has(n)||zt.has(n),s=Rt();if(r)pe(n,l);else{let o,r;if(cs(e)){r=jt.get(n);const s=r&&r.__lexicalTextContent;"string"!=typeof s&&t(354,e.getType()),o=s}else o=e.getTextContent();Dt+=o,void 0!==r&&Kt(r)}Do(e)?null===It&&(It=e.getFormat(),Pt=e.getStyle(),Ft=e.__key):cs(e)&&o<i-1&&!e.isInline()&&(Dt+=v),Lt(s),n=e.__next,o++}return c.__lexicalTextContent=Dt,c.__lexicalFirstTextKey=Ft,void(Dt=r+Dt)}}if(1===s&&1===i){const t=e.__first,r=n.__first;if(t===r)pe(t,l);else{const e=Se(t),n=fe(r,null);try{e.parentNode===l?l.replaceChild(n,e):o.insertChild(n)}catch(o){if("object"==typeof o&&null!=o){const s=`${o.toString()} Parent: ${l.tagName}, new child: {tag: ${n.tagName} key: ${r}}, old child: {tag: ${e.tagName}, key: ${t}}.`;throw new Error(s)}throw o}Xt(t,null)}const s=Ht.get(r);Do(s)&&null===It&&(It=s.getFormat(),Pt=s.getStyle(),Ft=s.__key)}else{const r=Gl(e,Wt),c=Gl(n,Ht);if(r.length!==s&&t(227),c.length!==i&&t(228),0===s)0!==i&&de(c,n,0,i-1,o);else if(0===i){if(0!==s){const t=null==o.after&&null==o.before&&0===le(n).size&&null==o.element.__lexicalLineBreak;Qt(r,0,s-1,t?null:l),t&&(l.textContent="")}}else!function(t,e,n,o,r,s){const i=o-1,l=r-1;let c,a,u=s.getFirstChild(),f=0,d=0;for(;f<=i&&d<=l;){const t=e[f],o=n[d],r=Rt();if(t===o)u=ye(pe(o,s.element)),f++,d++;else{if(void 0===a&&(a=xe(n,d)),void 0===c)c=xe(e,f);else if(!c.has(t)){f++,Lt(r);continue}if(!a.has(t)){u=ye(Se(t)),Xt(t,s.element),f++,c.delete(t),Lt(r);continue}if(c.has(o)){const t=Ki(At,o);t!==u&&s.withBefore(u??s.before).insertChild(t),u=ye(pe(o,s.element)),f++,d++}else fe(o,s.withBefore(u??s.before)),d++}const i=Ht.get(o);null!==i&&Do(i)?null===It&&(It=i.getFormat(),Pt=i.getStyle(),Ft=i.__key):cs(i)&&d<=l&&!i.isInline()&&(Dt+=v),Lt(r)}const h=f>i,g=d>l;if(h&&!g){const e=n[l+1],o=void 0===e?null:At.getElementByKey(e);de(n,t,d,l,s.withBefore(o??s.before))}else g&&!h&&Qt(e,f,i,s.element)}(n,r,c,s,i,o)}c.__lexicalTextContent=Dt,c.__lexicalFirstTextKey=Ft,Dt=r+Dt}(e,n,Ml(n,o,At)),Vi(n)||(r=n,null==It||It===r.__textFormat||qt||r.setTextFormat(It),function(t){null==Pt||Pt===t.__textStyle||qt||t.setTextStyle(Pt)}(n))}function _e(t,e,n){const o=e.__lexicalFirstTextKey;if(null!=o){const e=t.__key;let r=o;for(;null!==r;){const t=Ht.get(r);if(void 0===t){r=null;break}if(t.__parent===e)break;r=t.__parent}if(null!==r&&!n.has(r)){const t=Ht.get(o);if(Do(t))return It=t.getFormat(),void(Pt=t.getStyle())}}e.__lexicalFirstTextKey=Ft}function pe(e,n){const o=Wt.get(e);let r=Ht.get(e);void 0!==o&&void 0!==r||t(61);const s=Vt||$t.has(e)||zt.has(e),i=Ki(At,e);if(o===r&&!s){let e;if(cs(o)){const n=i.__lexicalTextContent;"string"!=typeof n&&t(355,o.getType()),e=n,Kt(i)}else e=o.getTextContent();return Dt+=e,i}if(o!==r&&s&&Ii(Jt,wt,Bt,r,"updated"),Gt.$updateDOM(r,o,i,At)){const o=fe(e,null);return null===n&&t(62),n.replaceChild(o,i),Xt(e,null),o}if(cs(o)){cs(r)||t(334,e);const n=r.__indent;(Vt||n!==o.__indent)&&ee(i,n);const l=r.__format;(Vt||l!==o.__format)&&ne(i,l);const c=s&&(le(r).size>0||le(o).size>0)?ue(o,r,i):"";if(s){const t=Dt;if(ge(o,r,i),hs(r)||r.isInline()||he(0,r,i),""!==c){const e=i.__lexicalTextContent||"";i.__lexicalTextContent=c+e,Dt=t+c+e,i.__lexicalSlotTextLength=c.length}else(le(r).size>0||le(o).size>0)&&(i.__lexicalSlotTextLength=0)}else{const e=i.__lexicalTextContent;"string"!=typeof e&&t(356,o.getType()),Dt+=e,Kt(i)}if((Vt||r.__dir!==o.__dir||r.__parent!==o.__parent)&&(oe(i,r),hs(r)&&!Vt))for(const t of r.getChildren())if(cs(t)){oe(Ki(At,t.getKey()),t)}}else{const t=r.getTextContent();if(fs(r)){const t=r.decorate(At,Mt);null!==t&&me(e,t),s&&(le(r).size>0||le(o).size>0)&&ue(o,r,i)}Dt+=t}if(!qt&&hs(r)){const t=r.getLatest();if(t.__cachedText!==Dt){const e=t.getWritable();e.__cachedText=Dt,r=e}}return Gt.$decorateDOM(r,o,i,At),Ot(r),i}function me(t,e){let n=At._pendingDecorators;const o=At._decorators;if(null===n){if(o[t]===e)return;n=hi(At)}n[t]=e}function ye(t){let e=t.nextSibling;return null!==e&&e===At._blockCursorElement&&(e=e.nextSibling),e}function xe(t,e){const n=new Set;for(let o=e;o<t.length;o++)n.add(t[o]);return n}function Ce(t,e,n,o,r,s){Dt="",It=null,Pt=null,Ft=null,Vt=2===o,At=n,Mt=n._config,Gt=n._config.dom||Ps,wt=n._nodes,Bt=At._listeners.mutation,zt=r,$t=s,Wt=t._nodeMap,Ut=t,Ht=e._nodeMap,qt=e._readOnly,jt=J(n._keyToDOMMap),Yt=function(){const t=new Map,e=e=>{for(const n of e){const e=Ht.get(n);if(void 0===e)continue;const o=e.__parent;if(null===o)continue;let r=t.get(o);void 0===r&&(r=new Set,t.set(o,r)),r.add(n)}};return e(zt.keys()),e($t),t}();const i=new Map;return Jt=i,pe("root",null),At=void 0,wt=void 0,zt=void 0,$t=void 0,Wt=void 0,Ut=void 0,Ht=void 0,Mt=void 0,jt=void 0,Yt=void 0,Jt=void 0,Gt=Ps,i}function Se(e){const n=jt.get(e);return void 0===n&&t(75,e),n}
/*@__INLINE__*/function Te(t){return{type:t}}const Ne=/* @__PURE__ */Te("SELECTION_CHANGE_COMMAND"),ve=/* @__PURE__ */Te("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),ke=/* @__PURE__ */Te("CLICK_COMMAND"),Ee=/* @__PURE__ */Te("BEFORE_INPUT_COMMAND"),Oe=/* @__PURE__ */Te("INPUT_COMMAND"),be=/* @__PURE__ */Te("COMPOSITION_START_COMMAND"),Me=/* @__PURE__ */Te("COMPOSITION_END_COMMAND"),Ae=/* @__PURE__ */Te("DELETE_CHARACTER_COMMAND"),we=/* @__PURE__ */Te("INSERT_LINE_BREAK_COMMAND"),De=/* @__PURE__ */Te("INSERT_PARAGRAPH_COMMAND"),Ie=/* @__PURE__ */Te("CONTROLLED_TEXT_INSERTION_COMMAND"),Pe=/* @__PURE__ */Te("PASTE_COMMAND"),Fe=/* @__PURE__ */Te("REMOVE_TEXT_COMMAND"),Re=/* @__PURE__ */Te("DELETE_WORD_COMMAND"),Le=/* @__PURE__ */Te("DELETE_LINE_COMMAND"),Ke=/* @__PURE__ */Te("FORMAT_TEXT_COMMAND"),Be=/* @__PURE__ */Te("SET_TEXT_FORMAT_COMMAND"),ze=/* @__PURE__ */Te("UNDO_COMMAND"),$e=/* @__PURE__ */Te("REDO_COMMAND"),We=/* @__PURE__ */Te("KEYDOWN_COMMAND"),Ue=/* @__PURE__ */Te("KEY_ARROW_RIGHT_COMMAND"),He=/* @__PURE__ */Te("MOVE_TO_END"),je=/* @__PURE__ */Te("KEY_ARROW_LEFT_COMMAND"),Ye=/* @__PURE__ */Te("MOVE_TO_START"),Je=/* @__PURE__ */Te("KEY_ARROW_UP_COMMAND"),Ge=/* @__PURE__ */Te("KEY_ARROW_DOWN_COMMAND"),Ve=/* @__PURE__ */Te("KEY_ENTER_COMMAND"),qe=/* @__PURE__ */Te("KEY_SPACE_COMMAND"),Xe=/* @__PURE__ */Te("KEY_BACKSPACE_COMMAND"),Qe=/* @__PURE__ */Te("KEY_ESCAPE_COMMAND"),Ze=/* @__PURE__ */Te("KEY_DELETE_COMMAND"),tn=/* @__PURE__ */Te("KEY_TAB_COMMAND"),en=/* @__PURE__ */Te("INSERT_TAB_COMMAND"),nn=/* @__PURE__ */Te("INDENT_CONTENT_COMMAND"),on=/* @__PURE__ */Te("OUTDENT_CONTENT_COMMAND"),rn=/* @__PURE__ */Te("DROP_COMMAND"),sn=/* @__PURE__ */Te("FORMAT_ELEMENT_COMMAND"),ln=/* @__PURE__ */Te("DRAGSTART_COMMAND"),cn=/* @__PURE__ */Te("DRAGOVER_COMMAND"),an=/* @__PURE__ */Te("DRAGEND_COMMAND"),un=/* @__PURE__ */Te("COPY_COMMAND"),fn=/* @__PURE__ */Te("CUT_COMMAND"),dn=/* @__PURE__ */Te("SELECT_ALL_COMMAND"),hn=/* @__PURE__ */Te("CLEAR_EDITOR_COMMAND"),gn=/* @__PURE__ */Te("CLEAR_HISTORY_COMMAND"),_n=/* @__PURE__ */Te("CAN_REDO_COMMAND"),pn=/* @__PURE__ */Te("CAN_UNDO_COMMAND"),mn=/* @__PURE__ */Te("FOCUS_COMMAND"),yn=/* @__PURE__ */Te("BLUR_COMMAND"),xn=/* @__PURE__ */Te("KEY_MODIFIER_COMMAND");function Cn(t){const e=new Map;return{dispose(){for(const t of e.values())t.dispose();e.clear()},register(n,o){let r=e.get(n);void 0===r&&(r={dispose:t(n,o),holders:new Set},e.set(n,r));const s=()=>{const t=e.get(n);t&&t.holders.delete(s)&&0===t.holders.size&&(e.delete(n),t.dispose())};return r.holders.add(s),s}}}function Sn(t,e,n,o){return t.addEventListener(e,n,o),t.removeEventListener.bind(t,e,n,o)}const Tn=Object.freeze({}),Nn=[["keydown",function(t,e){const n=e._inputState;n.lastKeyDownTimeStamp=t.timeStamp,n.lastKeyCode=t.key,"Backspace"!==t.key&&Pn(n);if(e.isComposing())return;Li(e,We,t)}],["pointerdown",function(t,e){const n=yl(t),o=t.pointerType;Cl(n)&&"touch"!==o&&"pen"!==o&&0===t.button&&ss(e,()=>{Wl(n,e)||(e._inputState.isSelectionChangeFromMouseDown=!0)})}],["compositionstart",function(t,e){Li(e,be,t)}],["compositionend",function(t,e){const n=e._inputState;s?n.compositionPhase="ending-firefox":l||!a&&!d?Li(e,Me,t):(n.compositionPhase="ending-safari",n.compositionEndData=t.data)}],["input",function(t,e){t.stopPropagation();const n=e._inputState;Pn(n),ss(e,()=>{Rn(t,e)||e.dispatchCommand(Oe,t)},{event:t}),n.unprocessedBeforeInputData=null}],["click",function(t,e){ss(e,()=>{const n=_r(),o=nl(ji(e)),r=pr();if(o)if(Uo(n)){const t=n.anchor,e=t.getNode();"element"===t.type&&0===t.offset&&n.isCollapsed()&&!hs(e)&&1===_i().getChildrenSize()&&e.getTopLevelElementOrThrow().isEmpty()&&null!==r&&n.is(r)&&(o.removeAllRanges(),n.dirty=!0)}else if("touch"===t.pointerType||"pen"===t.pointerType){const n=dl(o,e._rootElement).anchorNode;if(xl(n)||Qs(n)){pi(gr(r,o,e,t))}}Li(e,ke,t)})}],["cut",Tn],["copy",Tn],["dragstart",Tn],["dragover",Tn],["dragend",Tn],["paste",Tn],["focus",Tn],["blur",Tn],["drop",Tn]];i&&Nn.push(["beforeinput",(t,e)=>function(t,e){const n=t.inputType;if("deleteCompositionText"===n||s&&Ri(e))return;if("insertCompositionText"===n)return;ss(e,()=>{Rn(t,e)||Li(e,Ee,t)},{event:t})}(t,e)]);const vn=new WeakMap,kn=new WeakMap,En=Cn(t=>(t.addEventListener("selectionchange",Yn),()=>t.removeEventListener("selectionchange",Yn)));function On(t,e,n,o,r,s){const l=t.anchor,c=t.focus,a=l.getNode(),u=Hr();let f;if(void 0!==s)f=s;else{const t=nl(ji(u));f=null!==t?dl(t,u._rootElement):null}const d=null!==f?f.anchorNode:null,h=l.key,g=u.getElementByKey(h),_=n.length;return h!==c.key||!Do(a)||(!r&&(!i||u._inputState.lastBeforeInputInsertTextTimeStamp<o+50)||a.isDirty()&&_<2||xi(n))&&l.offset!==c.offset&&!a.isComposing()||Xs(a)||a.isDirty()&&_>1||(r||!i)&&null!==g&&!a.isComposing()&&d!==wl(a,g,u)||null!==f&&null!==e&&(!e.collapsed||e.startContainer!==f.anchorNode||e.startOffset!==f.anchorOffset)||!a.isComposing()&&(a.getFormat()!==t.format||a.getStyle()!==t.style)||function(t,e){if(e.isSegmented())return!0;if(!t.isCollapsed())return!1;const n=t.anchor.offset,o=e.getParentOrThrow(),r=qs(e);return 0===n?!e.canInsertTextBefore()||!o.canInsertTextBefore()&&!e.isComposing()||r||function(t){const e=t.getPreviousSibling();return(Do(e)||cs(e)&&e.isInline())&&!e.canInsertTextAfter()}(e):n===e.getTextContentSize()&&(!e.canInsertTextAfter()||!o.canInsertTextAfter()&&!e.isComposing()||r)}(t,a)}function bn(t,e){return Qs(t)&&null!==t.nodeValue&&0!==e&&e!==t.nodeValue.length}function Mn(e,n,o){const{anchorNode:r,anchorOffset:s,focusNode:i,focusOffset:l}=dl(e,n._rootElement),c=n._inputState;c.isSelectionChangeFromDOMUpdate&&(c.isSelectionChangeFromDOMUpdate=!1,bn(r,s)&&bn(i,l)&&!c.postDeleteSelectionToRestore)||ss(n,()=>{if(!o)return void pi(null);if(!Ys(n,r,i))return;let a=_r();if(c.postDeleteSelectionToRestore&&Uo(a)&&a.isCollapsed()){const t=a.anchor,e=c.postDeleteSelectionToRestore.anchor;(t.key===e.key&&t.offset===e.offset+1||1===t.offset&&e.getNode().is(t.getNode().getPreviousSibling()))&&(a=c.postDeleteSelectionToRestore.clone(),pi(a))}if(c.postDeleteSelectionToRestore=null,Uo(a)){const o=a.anchor,u=o.getNode();if(a.isCollapsed()){"Range"===e.type&&r===i&&(a.dirty=!0);const s=ji(n).event,l=s?s.timeStamp:performance.now(),{format:f,style:d,offset:h,key:g,timeStamp:_}=c.collapsedSelectionFormat,p=_i(),m=!1===n.isComposing()&&""===p.getTextContent();if(l<_+200&&o.offset===h&&o.key===g)An(a,f,d);else if("text"===o.type)Do(u)||t(141),wn(a,u);else if("element"===o.type&&!m){cs(u)||t(259);const e=o.getNode();e.isEmpty()?function(t,e){const n=e.getTextFormat(),o=e.getTextStyle();An(t,n,o)}(a,e):An(a,a.format,"")}}else{const t=o.key,e=a.focus.key,n=a.getNodes(),r=n.length,i=a.isBackward(),c=i?l:s,u=i?s:l,f=i?e:t,d=i?t:e;let h=2047,g=!1;for(let t=0;t<r;t++){const e=n[t],o=e.getTextContentSize();if(Do(e)&&0!==o&&!(0===t&&e.__key===f&&c===o||t===r-1&&e.__key===d&&0===u)&&(g=!0,h&=e.getFormat(),0===h))break}a.format=g?h:0}}Li(n,Ne,void 0)})}function An(t,e,n){t.format===e&&t.style===n||(t.format=e,t.style=n,t.dirty=!0)}function wn(t,e){An(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 In(t){const{lastKeyCode:e}=Hr()._inputState;if(null==t||t.length<=1||null==e)return;const n=1===e.length?e:"Enter"===e?"\n":"Tab"===e?"\t":null;if(!n)return;const o=_r();if(!Uo(o)||!o.isCollapsed())return;const r=o.anchor.getNode();if(!Do(r))return;const{offset:s}=o.anchor;if(r.getTextContentSize()===s){const t=r.getNextSibling();if("\n"===n){if(Ts(t))t.selectEnd();else if(!t){const t=Jl(r,ur),e=t&&t.getNextSibling();cs(e)&&e.selectStart()}}else"\t"===n?Ro(t)&&t.selectEnd():Do(t)&&t.getTextContent()[0]===n&&t.select(1,1)}else r.getTextContent()[s]===n&&r.select(s+1,s+1)}function Pn(t){t.isInsertTextAfterHandledSelectionCommand=!1,null!==t.handledSelectionCommandTimeoutId&&(clearTimeout(t.handledSelectionCommandTimeoutId),t.handledSelectionCommandTimeoutId=null)}function Fn(t){Pn(t),t.isInsertTextAfterHandledSelectionCommand=!0,t.handledSelectionCommandTimeoutId=setTimeout(()=>Pn(t),0)}function Rn(t,e){const n=yl(t);if(xl(n)&&Wl(n,e))return!0;const o=e.getRootElement();if(null===o)return!1;const r=ml(o.ownerDocument);return null!==r&&o.contains(r)&&Wl(r,e)}function Ln(e){const n=e.inputType,o=Dn(e),r=Hr(),s=r._inputState,i=_r();if("insertText"===n&&e.data&&s.isInsertTextAfterHandledSelectionCommand){if(Pn(s),e.preventDefault(),Uo(i)&&!i.isCollapsed()){const t=i.isBackward()?i.anchor:i.focus;i.anchor.set(t.key,t.offset,t.type),i.focus.set(t.key,t.offset,t.type)}return!0}if("deleteContentBackward"===n){if(null===i){const t=pr();if(!Uo(t))return!0;pi(t.clone())}if(Uo(i)){const n=i.anchor.key===i.focus.key;if(function(t,e){return"MediaLast"===t.lastKeyCode&&e<t.lastKeyDownTimeStamp+30}(s,e.timeStamp)&&r.isComposing()&&n){if(ii(null),s.lastKeyDownTimeStamp=0,setTimeout(()=>{ss(r,()=>{ii(null)})},30),Uo(i)){const e=i.anchor.getNode();e.markDirty(),Do(e)||t(142),wn(i,e)}}else{if(ii(null),l&&null!==o&&!o.collapsed&&(i.applyDOMRange(o),!i.isCollapsed()))return e.preventDefault(),i.removeText(),!0;e.preventDefault();const t=i.anchor.getNode(),c=t.getTextContent(),a=t.canInsertTextAfter(),u=0===i.anchor.offset&&i.focus.offset===c.length;let d=f&&n&&!u&&a;if(d&&i.isCollapsed()&&(d=!fs(Fi(i.anchor,!0))),!d){Li(r,Ae,!0);const t=_r();f&&Uo(t)&&t.isCollapsed()&&(s.postDeleteSelectionToRestore=t,setTimeout(()=>s.postDeleteSelectionToRestore=null))}}return!0}}if(!Uo(i))return!0;const c=e.data;null!==s.unprocessedBeforeInputData&&Ni(!1,r,s.unprocessedBeforeInputData),i.dirty&&null===s.unprocessedBeforeInputData||!i.isCollapsed()||hs(i.anchor.getNode())||null===o||i.applyDOMRange(o),s.unprocessedBeforeInputData=null;const a=i.anchor,u=i.focus,d=a.getNode(),h=u.getNode();if("insertText"===n||"insertTranspose"===n){if("\n"===c)e.preventDefault(),Li(r,we,!1);else if(c===v)e.preventDefault(),Li(r,De,void 0);else if(null==c&&e.dataTransfer){const t=e.dataTransfer.getData("text/plain");e.preventDefault(),i.insertRawText(t)}else null!=c&&On(i,o,c,e.timeStamp,!0)?(e.preventDefault(),Li(r,Ie,c),In(c)):s.unprocessedBeforeInputData=c;return s.lastBeforeInputInsertTextTimeStamp=e.timeStamp,!0}switch(e.preventDefault(),n){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":Li(r,Ie,e);In((e.dataTransfer?e.dataTransfer.getData("text/plain"):null)??e.data);break;case"insertFromComposition":{const t=s.hadOrphanedCompositionEvents;s.hadOrphanedCompositionEvents=!1;const n=r._compositionKey;ii(null),t||Li(r,Ie,e),$n(n);break}case"insertLineBreak":ii(null),Li(r,we,!1);break;case"insertParagraph":ii(null),s.isInsertLineBreak&&!l?(s.isInsertLineBreak=!1,Li(r,we,!1)):Li(r,De,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":Li(r,Pe,e);break;case"deleteByComposition":(function(t,e){return t!==e||cs(t)||cs(e)||!qs(t)||!qs(e)})(d,h)&&Li(r,Fe,e);break;case"deleteByDrag":$i(lo),Li(r,Fe,e);break;case"deleteByCut":Li(r,Fe,e);break;case"deleteContent":Li(r,Ae,!1);break;case"deleteWordBackward":Li(r,Re,!0);break;case"deleteWordForward":Li(r,Re,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":Li(r,Le,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":Li(r,Le,!1);break;case"formatStrikeThrough":Li(r,Ke,"strikethrough");break;case"formatBold":Li(r,Ke,"bold");break;case"formatItalic":Li(r,Ke,"italic");break;case"formatUnderline":Li(r,Ke,"underline");break;case"historyUndo":Li(r,ze,void 0);break;case"historyRedo":Li(r,$e,void 0)}return!0}function Kn(t){const e=Hr(),n=e._inputState,o=_r(),r=t.data,l=Dn(t);let c=!1;if(null!=r&&Uo(o)){const a=nl(ji(e)),u=null!==a?dl(a,e._rootElement):null,d="insertCompositionText"===t.inputType&&"ending-firefox"!==n.compositionPhase&&!e.isComposing();d&&(n.hadOrphanedCompositionEvents=!0);const h=o.anchor.getNode(),g="insertCompositionText"===t.inputType&&"ending-firefox"!==n.compositionPhase&&e.isComposing()&&Do(h)&&Xs(h);if(!d&&!g&&On(o,l,r,t.timeStamp,!1,u)){if(c=!0,"ending-firefox"===n.compositionPhase){const t=Wn(e,r);if(n.compositionPhase="idle",t)return $i(ao),mi(),!0}const l=o.anchor.getNode();if(null===a||null===u)return!0;const d=o.isBackward(),h=d?o.anchor.offset:o.focus.offset,g=d?o.focus.offset:o.anchor.offset;i&&!o.isCollapsed()&&Do(l)&&null!==u.anchorNode&&l.getTextContent().slice(0,h)+r+l.getTextContent().slice(h+g)===Ti(u.anchorNode)||Li(e,Ie,r);const _=r.length;s&&_>1&&"insertCompositionText"===t.inputType&&!e.isComposing()&&(o.anchor.offset-=_,o._cachedNodes=null,o._cachedIsBackward=null),f&&e.isComposing()&&(n.lastKeyDownTimeStamp=0,ii(null))}}if(!c){Ni(!1,e,null!==r?r:void 0),"ending-firefox"===n.compositionPhase&&(Wn(e,r||void 0),$i(ao),n.compositionPhase="idle")}return mi(),!0}function Bn(t){const e=Hr(),n=e._inputState,o=_r();if(Uo(o)&&!e.isComposing()){n.compositionPhase="composing",n.hadOrphanedCompositionEvents=!1;const r=o.anchor,s=o.anchor.getNode();if(ii(r.key),$i(co),t.timeStamp<n.lastKeyDownTimeStamp+30||"element"===r.type||!o.isCollapsed()||!f&&(s.getFormat()!==o.format||Do(s)&&s.getStyle()!==o.style)||Do(s)&&(Xs(s)||0===r.offset&&!s.canInsertTextBefore()||r.offset===s.getTextContentSize()&&!s.canInsertTextAfter())){Li(e,Ie,k);const t=_r();Uo(t)&&ii(t.anchor.key)}}return!0}function zn(t){const e=Hr();return e._inputState.compositionPhase="idle",Wn(e,t.data),$i(ao),!0}function $n(t){if(null===t)return;const e=ci(t);if(!Do(e)||"text"===e.getType()||Xs(e)||!e.isAttached())return;const n=_r(),o=Uo(n)&&n.anchor.key===t?n.anchor.offset:null,r=wo(e.getTextContent());if(r.setFormat(e.getFormat()),r.setStyle(e.getStyle()),e.replace(r),null!==o){const t=Math.min(o,r.getTextContentSize());r.select(t,t)}}function Wn(t,e){const n=t._compositionKey;if(ii(null),null!==n&&null!=e){if(""===e){const e=ci(n),o=t.getElementByKey(n),r=null!==o&&Do(e)?wl(e,o,t):null;if(null!==r&&null!==r.nodeValue&&Do(e)){const n=nl(ji(t)),o=n&&dl(n,t._rootElement);let s=null,i=null;null!==o&&o.anchorNode===r&&(s=o.anchorOffset,i=o.focusOffset),vi(e,r.nodeValue,s,i,!0)}return $n(n),!1}if("\n"===e[e.length-1]){const e=_r();if(Uo(e)||jo(e)){if(Uo(e)){const t=e.focus;e.anchor.set(t.key,t.offset,t.type)}return Li(t,Ve,null),$n(n),!1}}const o=ci(n);if(null!==o&&Do(o)&&Xs(o)){o.markDirty();const t=_r(),r=o.getTextContentSize(),s=Uo(t)&&t.anchor.key===n?t.anchor.offset:r;return o.select(s,s).insertText(e),!0}}return Ni(!0,t,e),$n(n),!1}function Un(t){const e=Hr(),n=e._inputState;if(null==t.key)return!0;if("ending-safari"===n.compositionPhase){const o=wi(t);if(o&&ss(e,()=>{Wn(e,n.compositionEndData)}),n.compositionPhase="idle",n.compositionEndData="",o)return!0}if(function(t){return bi(t,"ArrowRight",{shiftKey:"any"})}(t))Li(e,Ue,t);else if(function(t){return bi(t,"ArrowRight",{...Mi,shiftKey:"any"})}(t))Li(e,He,t);else if(function(t){return bi(t,"ArrowLeft",{shiftKey:"any"})}(t))Li(e,je,t);else if(function(t){return bi(t,"ArrowLeft",{...Mi,shiftKey:"any"})}(t))Li(e,Ye,t);else if(function(t){return bi(t,"ArrowUp",{altKey:"any",shiftKey:"any"})}(t))Li(e,Je,t);else if(function(t){return bi(t,"ArrowDown",{altKey:"any",shiftKey:"any"})}(t))Li(e,Ge,t);else if(function(t){return bi(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any",shiftKey:!0})}(t))n.isInsertLineBreak=!0,Li(e,Ve,t);else if(function(t){return" "===t.key}(t))Li(e,qe,t);else if(function(t){return r&&bi(t,"o",{ctrlKey:!0})}(t))t.preventDefault(),n.isInsertLineBreak=!0,Li(e,we,!0);else if(function(t){return bi(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any"})}(t))n.isInsertLineBreak=!1,Li(e,Ve,t);else if(function(t){return bi(t,"Backspace",{shiftKey:"any"})||r&&bi(t,"h",{ctrlKey:!0})}(t))wi(t)?Li(e,Xe,t)&&Fn(n):(t.preventDefault(),Li(e,Ae,!0));else if(function(t){return"Escape"===t.key}(t))Li(e,Qe,t);else if(function(t){return bi(t,"Delete",{})||r&&bi(t,"d",{ctrlKey:!0})}(t))!function(t){return"Delete"===t.key}(t)?(t.preventDefault(),Li(e,Ae,!1)):Li(e,Ze,t);else if(function(t){return bi(t,"Backspace",Ai)}(t))t.preventDefault(),Li(e,Re,!0);else if(function(t){return bi(t,"Delete",Ai)}(t))t.preventDefault(),Li(e,Re,!1);else if(function(t){return r&&bi(t,"Backspace",{metaKey:!0})}(t))t.preventDefault(),Li(e,Le,!0);else if(function(t){return r&&(bi(t,"Delete",{metaKey:!0})||bi(t,"k",{ctrlKey:!0}))}(t))t.preventDefault(),Li(e,Le,!1);else if(function(t){return bi(t,"b",Mi)}(t))t.preventDefault(),Li(e,Ke,"bold");else if(function(t){return bi(t,"u",Mi)}(t))t.preventDefault(),Li(e,Ke,"underline");else if(function(t){return bi(t,"i",Mi)}(t))t.preventDefault(),Li(e,Ke,"italic");else if(function(t){return bi(t,"Tab",{shiftKey:"any"})}(t))Li(e,tn,t);else if(function(t){return bi(t,"z",Mi)}(t))t.preventDefault(),Li(e,ze,void 0);else if(function(t){if(r)return bi(t,"z",{metaKey:!0,shiftKey:!0});return bi(t,"y",{ctrlKey:!0})||bi(t,"z",{ctrlKey:!0,shiftKey:!0})}(t))t.preventDefault(),Li(e,$e,void 0);else{const o=e._editorState._selection;!function(t){return bi(t,"a",Mi)}(t)?null===o||Uo(o)||(!function(t){return bi(t,"c",Mi)}(t)?function(t){return bi(t,"x",Mi)}(t)&&(t.preventDefault(),Li(e,fn,t)):(t.preventDefault(),Li(e,un,t))):(t.preventDefault(),Li(e,dn,t)&&Fn(n))}return function(t){return t.ctrlKey||t.shiftKey||t.altKey||t.metaKey}(t)&&e.dispatchCommand(xn,t),!0}function Hn(t){let e=t.__lexicalEventHandles;return void 0===e&&(e=[],t.__lexicalEventHandles=e),e}const jn=new Map;function Yn(t){const e=ol(t.target);if(null===e)return;const n=zi(t.target);let o=null,r=null;const s=null!==n?kn.get(n):void 0;if(null!==n){if(void 0!==s){const t=s.editors;let n=s.hasShadowEditor;if(void 0===n){n=!1;for(const e of t)if(null!==e._rootElement&&rl(e._rootElement.getRootNode())){n=!0;break}s.hasShadowEditor=n}if(n){let n=null,s=null;for(const i of t){const t=i._rootElement;if(null===t)continue;const l=dl(e,t).anchorNode;if(null!==l&&Gs(l)===i){if(rl(t.getRootNode())){o=i,r=l;break}null===n&&(n=i,s=l)}}null===o&&null!==n&&(o=n,r=s)}else{const t=e.anchorNode;null===t||xl(t)&&null!==t.shadowRoot||(o=Gs(t),null!==o&&(r=t))}}if(null===o){const t=ml(n);o=null!==t?Gs(t):null}}if(null===o)return;if(o._inputState.isSelectionChangeFromMouseDown){if(void 0!==s)for(const t of s.editors)t._inputState.isSelectionChangeFromMouseDown=!1;ss(o,()=>{const n=pr(),s=r??dl(e,o._rootElement).anchorNode;if(xl(s)||Qs(s)){pi(gr(n,e,o,t))}})}const i=Ci(o),l=i[i.length-1],c=l._key,a=jn.get(c),u=a||l;u!==o&&Mn(e,u,!1),Mn(e,o,!0),o!==l?jn.set(c,o):a&&jn.delete(c)}function Jn(t){t._lexicalHandled=!0}function Gn(t){return!0===t._lexicalHandled}const Vn=()=>{};function qn(e){const n=vn.get(e);if(void 0===n)return void Vn();const o=kn.get(n);if(void 0===o)return void Vn();vn.delete(e);const r=Vs(e);Js(r)?(!function(t){if(null!==t._parentEditor){const e=Ci(t),n=e[e.length-1]._key;jn.get(n)===t&&jn.delete(n)}else jn.delete(t._key)}(r),o.editors.delete(r),o.hasShadowEditor=void 0,e.__lexicalEditor=null):r&&t(198);const s=Hn(e);for(let t=0;t<s.length;t++)s[t]();e.__lexicalEventHandles=[]}function Xn(e,n,o){$r();const r=e.__key,s=e.getParent();if(null===s)return void(null!==Zl(e)&&t(367,r,String(Zl(e))));const i=function(t){const e=_r();if(!Uo(e)||!cs(t))return e;const{anchor:n,focus:o}=e,r=n.getNode(),s=o.getNode();Ui(r,t)&&n.set(t.__key,0,"element");Ui(s,t)&&o.set(t.__key,0,"element");return e}(e);let l=!1;if(Uo(i)&&n){const t=i.anchor,n=i.focus;t.key===r&&(xr(t,e,s,e.getPreviousSibling(),e.getNextSibling()),l=!0),n.key===r&&(xr(n,e,s,e.getPreviousSibling(),e.getNextSibling()),l=!0)}else jo(i)&&n&&e.isSelected()&&e.selectPrevious();if(Uo(i)&&n&&!l){const t=e.getIndexWithinParent();oi(e),mr(i,s,t,-1)}else oi(e);o||Vi(s)||s.canBeEmpty()||!s.isEmpty()||Xn(s,n),n&&i&&hs(s)&&s.isEmpty()&&s.selectEnd()}const Qn=Symbol.for("ephemeral");function Zn(t){return t[Qn]||!1}const to={configurable:!0,enumerable:!1,value:void 0,writable:!0};class eo{__type;__key;__parent;__prev;__next;__state;[kt];static getType(){const{ownNodeType:e}=jl(this);return void 0===e&&t(64,this.name),e}static clone(e){t(65,this.name)}$config(){return{}}config(t,e){const n=e.extends||Vl(this.constructor);return Object.assign(e,{extends:n}),"string"==typeof t&&Object.assign(e,{type:t}),{[t]:e}}afterCloneFrom(t){this.__key===t.__key?(this.__parent=t.__parent,this.__next=t.__next,this.__prev=t.__prev,this.__state=t.__state):t.__state&&(this.__state=t.__state.getWritable(this))}resetOnCopyNodeFrom(t){this.__state&&(this.__state=this.__state.getWritable(this).resetOnCopyNode())}static importDOM;constructor(t){this.__type=this.constructor.getType(),this.__parent=null,this.__prev=null,this.__next=null,Object.defineProperty(this,"__state",to),Object.defineProperty(this,kt,to),ni(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=ci(t);if(null===e)break;t=null!==e.__parent?e.__parent:Zl(e)}return!1}isSelected(t){const e=t||_r();if(null==e)return!1;const n=e.getNodes().some(t=>t.__key===this.__key);if(Do(this))return n;if(Uo(e)&&"element"===e.anchor.type&&"element"===e.foc