UNPKG

lexical

Version:

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

11 lines • 175 kB
/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 */

function t(t,...e){const n=new URL("https://lexical.dev/docs/error"),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),i=n&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),s=!(!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=1,y=2,m=4,x=8,C=16,S=32,v=64,T=128,k=2047,b=1,N=2,E=3,w=4,O=5,M=6,A=a||l||d?"\xa0":"\u200b",D="\n\n",F=i?"\xa0":A,P="\u0591-\u07ff\ufb1d-\ufdfd\ufe70-\ufefc",I="A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02b8\u0300-\u0590\u0800-\u1fff\u200e\u2c00-\ufb1c\ufe00-\ufe6f\ufefd-\uffff",L=new RegExp("^[^"+I+"]*["+P+"]"),K=new RegExp("^[^"+P+"]*["+I+"]"),z={bold:1,capitalize:1024,code:16,highlight:T,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},B={directionless:1,unmergeable:2},R={center:2,end:6,justify:4,left:1,right:3,start:5},W={[N]:"center",[M]:"end",[w]:"justify",[b]:"left",[E]:"right",[O]:"start"},$={normal:0,segmented:2,token:1},U={[h]:"normal",[_]:"segmented",[g]:"token"},H="$",j="$config";function J(){return vc()._blockCursorElement}function V(t){return null!==t&&1===t.nodeType&&t.hasAttribute("data-lexical-slot")}class q{element;before;after;constructor(t,e,n){this.element=t,this.before=e||null,this.after=n||null}withBefore(t){return new q(this.element,t,this.after)}withAfter(t){return new q(this.element,this.before,t)}withElement(t){return this.element===t?this:new q(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=Y(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 i=Y(t,e);if(null===i)return"after";const s=Array.prototype.indexOf.call(t.childNodes,i);return s>=0&&s<=r?"before":"after"}getInsertionAnchor(){return this.before}}function Y(t,e){let n=e;for(;null!==n&&n.parentNode!==t;)n=n.parentNode;return n}class G extends q{withBefore(t){return new G(this.element,t,this.after)}withAfter(t){return new G(this.element,this.before,t)}withElement(t){return this.element===t?this:new G(t,this.before,this.after)}getInsertionAnchor(){return super.getInsertionAnchor()||this.getManagedLineBreak()}getFirstChildAnchor(){let t=super.getFirstChildAnchor(),e=t?t.nextSibling:this.element.firstChild;for(;V(e);)t=e,e=e.nextSibling;const n=t?t.nextSibling:this.element.firstChild;return null!==n&&n===J()?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=Zl().createElement("br");if(r.setAttribute("data-lexical-managed-linebreak","true"),n.insertBefore(r,o),t){const t=Zl().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=J(),r=this.element.childNodes,i=Math.min(o,r.length);let s=0;for(let t=e;t<i;t++)r[t]!==n&&s++;return[t,Math.min(s,t.getChildrenSize())]}const r=X(e,n);r.push(o);const i=X(e,this.element);let s=t.getIndexWithinParent();for(let t=0;t<i.length;t++){const e=r[t],n=i[t];if(void 0===e||e<n)break;if(e>n){s+=1;break}}return[t.getParentOrThrow(),s]}}function X(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 Q;try{Q="0.49.0+prod.esm"}catch(t){}const Z=Q??'"<unknown>+source"';class tt{_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 et=null;function nt(t,e=1e3){return t instanceof ot?t.clone():t.size<e?new Map(t):(new ot).init(new Map(t),void 0,t.size)}class ot{_mutable=!1;_old=void 0;_nursery=void 0;_size=0;clone(){return this._mutable=!1,(new ot).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===et?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!==et?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!==et&&void 0!==n||(this._size++,n===et&&o.delete(t)),o.set(t,e),this}delete(t){const e=this.has(t);return e&&(this.getNursery().set(t,et),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!==et&&(void 0!==o&&(n[1]=o),yield n)}if(t)for(const n of t)n[1]===et||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 rt(t,e,n,o,r,i){if(Pi(t)){let s=t.getFirstChild();for(;null!==s;){const t=s.__key;s.__parent===e&&((Pi(s)||Qc(s)&&null!==s.__slots)&&rt(s,t,n,o,r,i),n.has(t)||i.delete(t),r.push(t)),s=s.getNextSibling()}}for(const s of Qc(t)&&null!==t.__slots?t.__slots.values():[]){const t=o.get(s);void 0!==t&&Zc(t)&&t.__slotHost===e&&((Pi(t)||Qc(t)&&null!==t.__slots)&&rt(t,s,n,o,r,i),n.has(s)||i.delete(s),r.push(s))}}let it=!1,st=0;function lt(t){st=t.timeStamp}function ct(t,e,n){const o="BR"===t.nodeName,r=e.__lexicalLineBreak;return r&&(t===r||o&&t.previousSibling===r)||o&&void 0!==Qs(t,n)}function at(t,e,n){const o=Jl(Il(n)),r=o&&nc(o,n._rootElement);let i=null,s=null;null!==r&&r.anchorNode===t&&(i=r.anchorOffset,s=r.focusOffset);const l=t.nodeValue;null!==l&&fl(e,l,i,s,!1)}function ut(t,e,n){if(ur(t)){const e=t.anchor.getNode();if(e.is(n)&&t.format!==e.getFormat())return!1}return zs(e)&&n.isAttached()}function ft(t,e,n){for(let o=t;o&&!zc(o);o=wl(o)){const t=Qs(o,e);if(void 0!==t){const e=Ys(t,n);if(e)return Ki(e)||!gc(o)?void 0:[o,e]}}}function dt(t,e,n){it=!0;const o=performance.now()-st>100;try{Ai(t,()=>{const r=Kr()||function(t){return t.read("latest",()=>{const t=Kr();return null!==t?t.clone():null})}(t),s=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=ft(h,t,l);if(!g)continue;const[_,p]=g;if("characterData"===d)o&&Xo(p)&&zs(h)&&ut(r,h,p)&&at(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=Gs(o),s=o.parentNode;if(!(null==s||o===c||null!==r||ct(o,s,t)||t._slotsUsed&&gc(o)&&o.hasAttribute("data-lexical-slot")||zc(o))){if(i){const t=(gc(o)?o.innerText:null)||o.nodeValue;t&&(u+=t)}s.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];(ct(o,h,t)||c===o)&&(h.appendChild(o),e++)}o!==e&&s.set(_,p)}}}if(s.size>0)for(const[e,n]of s)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],i=n.parentNode;null==i||"BR"!==n.nodeName||ct(n,r,t)||i.removeChild(n)}}n.takeRecords()}null!==r&&(a&&ol(r),i&&bl(t)&&r.insertRawText(u))})}finally{it=!1}}function ht(t){const e=t._observer;if(null!==e){dt(t,e.takeRecords(),e)}}function gt(t){!function(t){0===st&&Il(t).addEventListener("textInput",lt,!0)}(t),t._observer=new MutationObserver((e,n)=>{dt(t,e,n)})}const _t="direct",pt="latest";class yt{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;constructor(t,e){this.key=t,this.parse=e.parse.bind(e),this.unparse=(e.unparse||wt).bind(e),this.isEqual=(e.isEqual||Object.is).bind(e),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=e.resetOnCopyNode||!1}}function mt(t,e){return new yt(t,e)}function xt(t,e,n=pt){const o=(n===pt?t.getLatest():t).__state;return o?o.getValue(e):e.defaultValue}function Ct(t,e,n){const o=xt(t,n,_t),r=xt(e,n,_t);return n.isEqual(o,r)?null:[o,r]}function St(t,e,n){let o;if(fi(),"function"==typeof n){const r=t.getLatest(),i=xt(r,e);if(o=n(i),e.isEqual(i,o))return r}else o=n;const r=t.getWritable();return bt(r).updateFromKnown(e,o),r}function vt(t){const e=new Map,n=new Set;for(const{ownNodeConfig:o}of jc("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 Tt=new Set(["__proto__","constructor","prototype"]);class kt{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:i}=this.sharedNodeState,s=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}(i,n,o);this.size=s}getValue(t){const e=this.knownState.get(t);if(void 0!==e)return e;this.sharedNodeState.sharedConfigMap.set(t.key,t);let n=t.defaultValue;if(this.unknownState&&t.key in this.unknownState){const e=this.unknownState[t.key];void 0!==e&&(n=t.parse(e)),this.updateFromKnown(t,n)}return n}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){const t={...this.unknownState},e={};for(const[e,n]of this.knownState)e.isEqual(n,e.defaultValue)?delete t[e.key]:t[e.key]=e.unparse(n);for(const n of this.sharedNodeState.flatKeys)n in t&&(e[n]=t[n],delete t[n]);return Et(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 kt(t,e,function(t,e,n){let o;if(n)for(const[r,i]of Object.entries(n)){if(Tt.has(r))continue;const n=t.get(r);n?e.has(n)||e.set(n,n.parse(i)):(o=o||{},o[r]=i)}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=Et(r)),this.size++),o.set(t,e)}updateFromUnknown(t,e){if(Tt.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 bt(t){const e=t.getWritable(),n=e.__state?e.__state.getWritable(e):new kt(e,Nt(e));return e.__state=n,n}function Nt(t){return t.__state?t.__state.sharedNodeState:Ns(vc(),t.getType()).sharedNodeState}function Et(t){if(t)for(const e in t)return t}function wt(t){return t}function Ot(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 Mt(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 At(t,e){const n=t.__state;return n&&n.node===t?n.getWritable(e):n}function Dt(t,e){const n=t.__mode,o=t.__format,r=t.__style,i=e.__mode,s=e.__format,l=e.__style,c=t.__state,a=e.__state;return(null===n||n===i)&&(null===o||o===s)&&(null===r||r===l)&&(null===t.__state||c===a||function(t,e){if(t===e)return!0;const n=new Set;return!(t&&Ot(n,t,e)||e&&Ot(n,e,t)||t&&Mt(n,t,e)||e&&Mt(n,e,t))}(c,a))}function Ft(t,e){const n=t.mergeWithSibling(e),o=_i()._normalizedNodes;return o.add(t.__key),o.add(e.__key),n}function Pt(t){let e,n,o=t;if(""!==o.__text||!o.isSimpleText()||o.isUnmergeable()){for(;null!==(e=o.getPreviousSibling())&&Xo(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(""!==e.__text){if(Dt(e,o)){o=Ft(e,o);break}break}e.remove()}for(;null!==(n=o.getNextSibling())&&Xo(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(""!==n.__text){if(Dt(o,n)){o=Ft(o,n);break}break}n.remove()}}else o.remove()}function It(t){return Lt(t.anchor),Lt(t.focus),t}function Lt(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),Xo(o)){t.set(o.__key,r?o.getTextContentSize():0,"text",!0);break}if(!Pi(o))break;t.set(o.__key,r?o.getChildrenSize():0,"element",!0)}}const Kt=Symbol.for("@lexical/CachedTextSize");function zt(e,n){return ee.read(()=>{let o=0,r=e;for(let e=0;e<n&&null!==r;e++){const i=te.get(r);if(void 0===i&&t(345,r),Pi(i)){const s=ne.get(r);if(void 0!==s&&Pi(s)&&s.__parent!==i.__parent)o+=i.getTextContentSize();else{const e=oe.get(r),n=e&&e.__lexicalTextContent;"string"!=typeof n&&t(346,i.getType()),o+=n.length}e<n-1&&!i.isInline()&&(o+=2)}else{const e=i[Kt];void 0===e&&t(347,i.getType(),r),o+=e}r=i.__next}return o},{editor:$t})}function Bt(t){Pi(t)||void 0===t[Kt]&&(t[Kt]=Xo(t)?t.__text.length:t.getTextContentSize())}const Rt=4;let Wt,$t,Ut,Ht="",jt=null,Jt=null,Vt=null;function qt(){return{firstTextKey:Vt,format:jt,style:Jt}}function Yt(t){null!==t.firstTextKey&&(jt=t.format,Jt=t.style,Vt=t.firstTextKey)}function Gt(e){if(null!==Vt)return;const n=e.__lexicalFirstTextKey;if(void 0===n&&t(348),null===n)return;const o=ne.get(n);Xo(o)&&(jt=o.getFormat(),Jt=o.getStyle(),Vt=n)}let Xt,Qt,Zt,te,ee,ne,oe,re,ie,se,le=!1,ce=!1;function ae(t,e){const n=te.get(t),o=ne.has(t);if(null!==e){const n=Fe(t);n.parentNode===e&&e.removeChild(n)}if(!o){if($t._keyToDOMMap.delete(t),Pi(n)){const t=Yc(n,te);ue(t,0,t.length-1,null)}if(void 0!==n){for(const t of xe(n).values()){const e=Se(t);ae(t,null),null!==e&&e.remove()}Sl(ie,Ut,Xt,n,"destroyed")}}}function ue(t,e,n,o){for(let r=e;r<=n;++r){const e=t[r];void 0!==e&&ae(e,o)}}function fe(t,e){t.setProperty("text-align",e)}const de="40px";function he(t,e){const n=Wt.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, ${de}))`)}function ge(t,e){const n=t.style;0===e?fe(n,""):1===e?fe(n,"left"):2===e?fe(n,"center"):3===e?fe(n,"right"):4===e?fe(n,"justify"):5===e?fe(n,"start"):6===e&&fe(n,"end")}function _e(t,e){const n=function(t){const e=t.__dir;if(null!==e)return e;if(Bi(t))return null;const n=t.getParent();return null===n||Bl(n)&&null===n.__dir?"auto":null}(e);null!==n?t.dir=n:t.removeAttribute("dir")}function pe(t){const e=Zl().createElement("div");return e.setAttribute("data-lexical-slot",t),e.style.display="none",e}function ye(t,e,n){e||"false"===t.contentEditable?Bc(n,$t):n.removeAttribute("contenteditable")}function me(t,e,n){const o=Ht,r=qt();Ht="";let i="";const s=Ki(t);for(const[o,r]of n){const n=pe(o);ye(e,s,n),e.appendChild(n),Ht="";const l=qt();Te(r,kc(t,n,$t)),Yt(l),Ce(t,o,e,n),i+=Ht}return Yt(r),Ht=o,i}function xe(t){return Qc(t)&&null!==t.__slots?t.__slots:Xc}function Ce(t,e,n,o){const r=se.$getSlotTargetElement(t,e,n,$t);null!==r&&(o.parentElement!==r&&r.appendChild(o),o.style.display="")}function Se(t){const e=oe.get(t);return void 0!==e?e.parentElement:null}function ve(t,e,n){const o=xe(t),r=xe(e);for(const[t,e]of o)if(!r.has(t)){const t=Se(e);ae(e,null),null!==t&&t.remove()}const i=Ht,s=qt();let l="",c=null;const a=Ki(e);for(const[t,i]of r){const r=o.get(t);let s=void 0!==r?Se(r):null;Ht="";const u=qt();if(null===s){s=pe(t);let o=null;for(const t of n.children)if(!t.hasAttribute("data-lexical-slot")){o=t;break}n.insertBefore(s,o),Te(i,kc(e,s,$t))}else r===i?we(i,s):(void 0!==r&&ae(r,s),Te(i,kc(e,s,$t)));if(Yt(u),ye(n,a,s),Ce(e,t,n,s),l+=Ht,s.parentElement===n){const t=null===c?n.firstChild:c.nextSibling;t!==s&&n.insertBefore(s,t),c=s}}return Yt(s),Ht=i,l}function Te(e,n){const o=ne.get(e);if(void 0===o&&t(60),null!==n){const t=te.get(e);if(void 0!==t){const r=oe.get(e);if(void 0!==r){const i=Zc(t)?t.__slotHost:null,s=Zc(o)?o.__slotHost:null,l=t.__parent!==o.__parent||i!==s,c=null!==s&&r.parentElement!==n.element;if(l||c)return n.insertChild(r),we(e,n.element)}}}const r=se.$createDOM(o,$t);if(function(t,e,n){const o=n._keyToDOMMap;Xs(e,n,t),o.set(t,e)}(e,r,$t),Xo(o)?r.setAttribute("data-lexical-text","true"):Ki(o)&&(r.setAttribute("data-lexical-decorator","true"),Kc(r,{captureSelection:!0})),Pi(o)){const t=o.__indent,e=o.__size;_e(r,o),0!==t&&he(r,t);const n=xe(o),i=n.size>0?me(o,r,n):"";if(0===e)r.__lexicalTextContent=i,r.__lexicalFirstTextKey=null,Ht+=i,n.size>0&&(r.__lexicalSlotTextLength=i.length);else{const t=Ht,s=e-1;if(ke(Yc(o,ne),o,0,s,kc(o,r,$t)),""!==i){const e=r.__lexicalTextContent||"";r.__lexicalTextContent=i+e,Ht=t+i+e}n.size>0&&(r.__lexicalSlotTextLength=i.length)}const s=o.__format;0!==s&&ge(r,s),o.isInline()||be(null,o,r)}else{const t=o.getTextContent();if(Ki(o)){const t=o.decorate($t,Wt);null!==t&&Oe(e,t),r.contentEditable="false";const n=xe(o);n.size>0&&me(o,r,n)}Ht+=t}return null!==n&&n.insertChild(r),se.$decorateDOM(o,null,r,$t),Bt(o),Sl(ie,Ut,Xt,o,"created"),r}function ke(e,n,o,r,i){const s=Ht,l=qt();Ht="",jt=null,Jt=null,Vt=null;let c=o;for(;c<=r;++c){const t=qt();Te(e[c],i);const n=ne.get(e[c]);null!==n&&Xo(n)?null===jt&&(jt=n.getFormat(),Jt=n.getStyle(),Vt=n.__key):Pi(n)&&c<r&&!n.isInline()&&(Ht+=D),Yt(t)}const a=$t._keyToDOMMap.get(n.__key);void 0===a&&t(349,n.__key),a.__lexicalTextContent=Ht,a.__lexicalFirstTextKey=Vt,Ht=s+Ht,Yt(l)}function be(t,e,n){const o=kc(e,n,$t),r=o.element.__lexicalLastChildKind??null,i=function(t,e){if(t){const n=t.__last;if(n){const t=e.get(n);if(t)return Yi(t)?"line-break":Ki(t)&&t.isInline()?"decorator":null}return xe(t).size>0?null:"empty"}return null}(e,ne);r!==i&&o.setManagedLineBreak(i)}function Ne(e,n,o){var r;jt=null,Jt=null,Vt=null,function(e,n,o){const r=Ht,i=e.__size,s=n.__size;Ht="";const l=o.element,c=$t._keyToDOMMap.get(n.__key);void 0===c&&t(351,n.__key);const a=s-i;if(!le&&Math.abs(a)<=1&&i>=Rt&&e.__first===n.__first&&(0!==a||!$t._cloneNotNeeded.has(e.__key))){const i=c.__lexicalTextContent,u=re.get(e.__key);if(!le&&"string"==typeof i&&void 0!==u){const s=function(t,e){const n=e.size;if(0===n||n>=t.__size)return null;let o=t.__last,r=null,i=0;for(;null!==o&&i<n;){if(!e.has(o))return null;r=o;const t=ne.get(o);if(void 0===t)return null;o=t.__prev,i++}if(i!==n)return null;if(null!==o&&e.has(o))return null;return r}(n,u);if(null!==s){const f=u.size;if(0===a){const e=zt(s,f);let o=s,a=0;for(;null!==o&&a<f;){const t=ne.get(o);if(void 0===t)break;const e=qt();we(o,l),Xo(t)&&null===jt&&(jt=t.getFormat(),Jt=t.getStyle(),Vt=t.__key),Yt(e),o=t.__next,a++}let d="";for(o=s,a=0;null!==o&&a<f;){const e=ne.get(o);if(void 0===e)break;let n;if(Pi(e)){const r=$t._keyToDOMMap.get(o),i=r&&r.__lexicalTextContent;"string"!=typeof i&&t(352,e.getType()),n=i}else n=e.getTextContent();d+=n,a<f-1&&Pi(e)&&!e.isInline()&&(d+=D),o=e.__next,a++}const h=c.__lexicalSlotTextLength||0,g=h>0?i.slice(h):i,_=g.slice(0,g.length-e)+d;return c.__lexicalTextContent=_,Ht=r+_,void Ee(n,c,u)}if(function(e,n,o,r,i,s,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=te.get(f);if(void 0===t)return!1;f=t.__prev}if(null===f)return!1;const d=ne.get(s),h=te.get(f);if(void 0===d||void 0===h)return!1;if(d.__prev!==h.__prev)return!1;const g=[];let _=s;for(let t=0;t<l;t++){if(null===_)return!1;g.push(_);const t=ne.get(_);_=t?t.__next:null}const p=[];_=f;for(let t=0;t<u;t++){if(null===_)return!1;p.push(_);const t=te.get(_);_=t?t.__next:null}const y=new Set(p),m=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(m.has(p[C])){if(y.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 v=zt(f,u);for(const t of x){const e=qt();if("reconcile"===t.kind)we(t.key,o.element);else if("destroy"===t.kind)ae(t.key,o.element);else{let e=null;for(let n=t.nextIndex+1;n<l;n++){const t=$t._keyToDOMMap.get(g[n]);if(void 0!==t){e=t;break}}Te(t.key,o.withBefore(e??o.before))}if("destroy"!==t.kind){const e=ne.get(t.key);e&&Xo(e)&&null===jt&&(jt=e.getFormat(),Jt=e.getStyle(),Vt=e.__key)}Yt(e)}let T="";for(let e=0;e<l;e++){const n=ne.get(g[e]);if(void 0===n)return!1;let o;if(Pi(n)){const r=$t._keyToDOMMap.get(g[e]),i=r&&r.__lexicalTextContent;"string"!=typeof i&&t(350,n.getType()),o=i}else o=n.getTextContent();T+=o,e<l-1&&Pi(n)&&!n.isInline()&&(T+=D)}const k=r.__lexicalSlotTextLength||0,b=k>0?i.slice(k):i;return r.__lexicalTextContent=b.slice(0,b.length-v)+T,!0}(e,0,o,c,i,s,f,a)){const e=c.__lexicalTextContent;return"string"!=typeof e&&t(353),Ht=r+e,void Ee(n,c,u)}}}if(0===a){let n=e.__first,o=0;for(;null!==n;){const e=ne.get(n);if(void 0===e)break;const r=le||Zt.has(n)||Qt.has(n),i=qt();if(r)we(n,l);else{let o,r;if(Pi(e)){r=oe.get(n);const i=r&&r.__lexicalTextContent;"string"!=typeof i&&t(354,e.getType()),o=i}else o=e.getTextContent();Ht+=o,void 0!==r&&Gt(r)}Xo(e)?null===jt&&(jt=e.getFormat(),Jt=e.getStyle(),Vt=e.__key):Pi(e)&&o<s-1&&!e.isInline()&&(Ht+=D),Yt(i),n=e.__next,o++}return c.__lexicalTextContent=Ht,c.__lexicalFirstTextKey=Vt,void(Ht=r+Ht)}}if(1===i&&1===s){const t=e.__first,r=n.__first;if(t===r)we(t,l);else{const e=Fe(t),n=Te(r,null);try{e.parentNode===l?l.replaceChild(n,e):o.insertChild(n)}catch(o){if("object"==typeof o&&null!=o){const i=`${o.toString()} Parent: ${l.tagName}, new child: {tag: ${n.tagName} key: ${r}}, old child: {tag: ${e.tagName}, key: ${t}}.`;throw new Error(i)}throw o}ae(t,null)}const i=ne.get(r);Xo(i)&&null===jt&&(jt=i.getFormat(),Jt=i.getStyle(),Vt=i.__key)}else{const r=Yc(e,te),c=Yc(n,ne);if(r.length!==i&&t(227),c.length!==s&&t(228),0===i)0!==s&&ke(c,n,0,s-1,o);else if(0===s){if(0!==i){const t=null==o.after&&null==o.before&&0===xe(n).size&&null==o.element.__lexicalLineBreak;ue(r,0,i-1,t?null:l),t&&(l.textContent="")}}else!function(t,e,n,o,r,i){const s=o-1,l=r-1;let c,a,u=i.getFirstChild(),f=0,d=0;for(;f<=s&&d<=l;){const t=e[f],o=n[d],r=qt();if(t===o)u=Me(we(o,i.element)),f++,d++;else{if(void 0===a&&(a=Ae(n,d)),void 0===c)c=Ae(e,f);else if(!c.has(t)){f++,Yt(r);continue}if(!a.has(t)){u=Me(Fe(t)),ae(t,i.element),f++,c.delete(t),Yt(r);continue}if(c.has(o)){const t=El($t,o);t!==u&&i.withBefore(u??i.before).insertChild(t),u=Me(we(o,i.element)),f++,d++}else Te(o,i.withBefore(u??i.before)),d++}const s=ne.get(o);null!==s&&Xo(s)?null===jt&&(jt=s.getFormat(),Jt=s.getStyle(),Vt=s.__key):Pi(s)&&d<=l&&!s.isInline()&&(Ht+=D),Yt(r)}const h=f>s,g=d>l;if(h&&!g){const e=n[l+1],o=void 0===e?null:$t.getElementByKey(e);ke(n,t,d,l,i.withBefore(o??i.before))}else g&&!h&&ue(e,f,s,i.element)}(n,r,c,i,s,o)}c.__lexicalTextContent=Ht,c.__lexicalFirstTextKey=Vt,Ht=r+Ht}(e,n,kc(n,o,$t)),Bl(n)||(r=n,null==jt||jt===r.__textFormat||ce||r.setTextFormat(jt),function(t){null==Jt||Jt===t.__textStyle||ce||t.setTextStyle(Jt)}(n))}function Ee(t,e,n){const o=e.__lexicalFirstTextKey;if(null!=o){const e=t.__key;let r=o;for(;null!==r;){const t=ne.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=ne.get(o);if(Xo(t))return jt=t.getFormat(),void(Jt=t.getStyle())}}e.__lexicalFirstTextKey=Vt}function we(e,n){const o=te.get(e);let r=ne.get(e);void 0!==o&&void 0!==r||t(61);const i=le||Zt.has(e)||Qt.has(e),s=El($t,e);if(o===r&&!i){let e;if(Pi(o)){const n=s.__lexicalTextContent;"string"!=typeof n&&t(355,o.getType()),e=n,Gt(s)}else e=o.getTextContent();return Ht+=e,s}if(o!==r&&i&&Sl(ie,Ut,Xt,r,"updated"),se.$updateDOM(r,o,s,$t)){const o=Te(e,null);return null===n&&t(62),n.replaceChild(o,s),ae(e,null),o}if(Pi(o)){Pi(r)||t(334,e);const n=r.__indent;(le||n!==o.__indent)&&he(s,n);const l=r.__format;(le||l!==o.__format)&&ge(s,l);const c=i&&(xe(r).size>0||xe(o).size>0)?ve(o,r,s):"";if(i){const t=Ht;if(Ne(o,r,s),Bi(r)||r.isInline()||be(0,r,s),""!==c){const e=s.__lexicalTextContent||"";s.__lexicalTextContent=c+e,Ht=t+c+e,s.__lexicalSlotTextLength=c.length}else(xe(r).size>0||xe(o).size>0)&&(s.__lexicalSlotTextLength=0)}else{const e=s.__lexicalTextContent;"string"!=typeof e&&t(356,o.getType()),Ht+=e,Gt(s)}if((le||r.__dir!==o.__dir||r.__parent!==o.__parent)&&(_e(s,r),Bi(r)&&!le))for(const t of r.getChildren())if(Pi(t)){_e(El($t,t.getKey()),t)}}else{const t=r.getTextContent();if(Ki(r)){const t=r.decorate($t,Wt);null!==t&&Oe(e,t),i&&(xe(r).size>0||xe(o).size>0)&&ve(o,r,s)}Ht+=t}if(!ce&&Bi(r)){const t=r.getLatest();if(t.__cachedText!==Ht){const e=t.getWritable();e.__cachedText=Ht,r=e}}return se.$decorateDOM(r,o,s,$t),Bt(r),s}function Oe(t,e){let n=$t._pendingDecorators;const o=$t._decorators;if(null===n){if(o[t]===e)return;n=tl($t)}n[t]=e}function Me(t){let e=t.nextSibling;return null!==e&&e===$t._blockCursorElement&&(e=e.nextSibling),e}function Ae(t,e){const n=new Set;for(let o=e;o<t.length;o++)n.add(t[o]);return n}function De(t,e,n,o,r,i){Ht="",jt=null,Jt=null,Vt=null,le=2===o,$t=n,Wt=n._config,se=n._config.dom||ps,Ut=n._nodes,Xt=$t._listeners.mutation,Qt=r,Zt=i,te=t._nodeMap,ee=t,ne=e._nodeMap,ce=e._readOnly,oe=nt(n._keyToDOMMap),re=function(){const t=new Map,e=e=>{for(const n of e){const e=ne.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(Qt.keys()),e(Zt),t}();const s=new Map;return ie=s,we("root",null),$t=void 0,Ut=void 0,Qt=void 0,Zt=void 0,te=void 0,ee=void 0,ne=void 0,Wt=void 0,oe=void 0,re=void 0,ie=void 0,se=ps,s}function Fe(e){const n=oe.get(e);return void 0===n&&t(75,e),n}
/*@__INLINE__*/function Pe(t){return{type:t}}const Ie=/* @__PURE__ */Pe("SELECTION_CHANGE_COMMAND"),Le=/* @__PURE__ */Pe("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),Ke=/* @__PURE__ */Pe("CLICK_COMMAND"),ze=/* @__PURE__ */Pe("BEFORE_INPUT_COMMAND"),Be=/* @__PURE__ */Pe("INPUT_COMMAND"),Re=/* @__PURE__ */Pe("COMPOSITION_START_COMMAND"),We=/* @__PURE__ */Pe("COMPOSITION_END_COMMAND"),$e=/* @__PURE__ */Pe("DELETE_CHARACTER_COMMAND"),Ue=/* @__PURE__ */Pe("INSERT_LINE_BREAK_COMMAND"),He=/* @__PURE__ */Pe("INSERT_PARAGRAPH_COMMAND"),je=/* @__PURE__ */Pe("CONTROLLED_TEXT_INSERTION_COMMAND"),Je=/* @__PURE__ */Pe("PASTE_COMMAND"),Ve=/* @__PURE__ */Pe("REMOVE_TEXT_COMMAND"),qe=/* @__PURE__ */Pe("DELETE_WORD_COMMAND"),Ye=/* @__PURE__ */Pe("DELETE_LINE_COMMAND"),Ge=/* @__PURE__ */Pe("FORMAT_TEXT_COMMAND"),Xe=/* @__PURE__ */Pe("SET_TEXT_FORMAT_COMMAND"),Qe=/* @__PURE__ */Pe("UNDO_COMMAND"),Ze=/* @__PURE__ */Pe("REDO_COMMAND"),tn=/* @__PURE__ */Pe("KEYDOWN_COMMAND"),en=/* @__PURE__ */Pe("KEY_ARROW_RIGHT_COMMAND"),nn=/* @__PURE__ */Pe("MOVE_TO_END"),on=/* @__PURE__ */Pe("KEY_ARROW_LEFT_COMMAND"),rn=/* @__PURE__ */Pe("MOVE_TO_START"),sn=/* @__PURE__ */Pe("KEY_ARROW_UP_COMMAND"),ln=/* @__PURE__ */Pe("KEY_ARROW_DOWN_COMMAND"),cn=/* @__PURE__ */Pe("KEY_ENTER_COMMAND"),an=/* @__PURE__ */Pe("KEY_SPACE_COMMAND"),un=/* @__PURE__ */Pe("KEY_BACKSPACE_COMMAND"),fn=/* @__PURE__ */Pe("KEY_ESCAPE_COMMAND"),dn=/* @__PURE__ */Pe("KEY_DELETE_COMMAND"),hn=/* @__PURE__ */Pe("KEY_TAB_COMMAND"),gn=/* @__PURE__ */Pe("INSERT_TAB_COMMAND"),_n=/* @__PURE__ */Pe("INDENT_CONTENT_COMMAND"),pn=/* @__PURE__ */Pe("OUTDENT_CONTENT_COMMAND"),yn=/* @__PURE__ */Pe("DROP_COMMAND"),mn=/* @__PURE__ */Pe("FORMAT_ELEMENT_COMMAND"),xn=/* @__PURE__ */Pe("DRAGSTART_COMMAND"),Cn=/* @__PURE__ */Pe("DRAGOVER_COMMAND"),Sn=/* @__PURE__ */Pe("DRAGEND_COMMAND"),vn=/* @__PURE__ */Pe("COPY_COMMAND"),Tn=/* @__PURE__ */Pe("CUT_COMMAND"),kn=/* @__PURE__ */Pe("SELECT_ALL_COMMAND"),bn=/* @__PURE__ */Pe("CLEAR_EDITOR_COMMAND"),Nn=/* @__PURE__ */Pe("CLEAR_HISTORY_COMMAND"),En=/* @__PURE__ */Pe("CAN_REDO_COMMAND"),wn=/* @__PURE__ */Pe("CAN_UNDO_COMMAND"),On=/* @__PURE__ */Pe("FOCUS_COMMAND"),Mn=/* @__PURE__ */Pe("BLUR_COMMAND"),An=/* @__PURE__ */Pe("KEY_MODIFIER_COMMAND");function Dn(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 i=()=>{const t=e.get(n);t&&t.holders.delete(i)&&0===t.holders.size&&(e.delete(n),t.dispose())};return r.holders.add(i),i}}}function Fn(t,e,n,o){return t.addEventListener(e,n,o),t.removeEventListener.bind(t,e,n,o)}const Pn=Object.freeze({}),In=[["keydown",function(t,e){const n=e._inputState;n.lastKeyDownTimeStamp=t.timeStamp,n.lastKeyCode=t.key,"Backspace"!==t.key&&Jn(n);if(e.isComposing())return;Nl(e,tn,t)}],["pointerdown",function(t,e){const n=ac(t),o=t.pointerType;_c(n)&&"touch"!==o&&"pen"!==o&&0===t.button&&Ai(e,()=>{Rc(n,e)||(e._inputState.isSelectionChangeFromMouseDown=!0)})}],["compositionstart",function(t,e){Nl(e,Re,t)}],["compositionend",function(t,e){const n=e._inputState;i?n.compositionPhase="ending-firefox":l||!a&&!d?Nl(e,We,t):(n.compositionPhase="ending-safari",n.compositionEndData=t.data)}],["input",function(t,e){t.stopPropagation();const n=e._inputState;Jn(n),Ai(e,()=>{qn(t,e)||e.dispatchCommand(Be,t)},{event:t}),n.unprocessedBeforeInputData=null}],["click",function(t,e){Ai(e,()=>{const n=Kr(),o=Jl(Il(e)),r=zr();if(o)if(ur(n)){const t=n.anchor,e=t.getNode();"element"===t.type&&0===t.offset&&n.isCollapsed()&&!Bi(e)&&1===nl().getChildrenSize()&&e.getTopLevelElementOrThrow().isEmpty()&&null!==r&&n.is(r)&&(o.removeAllRanges(),n.dirty=!0)}else if("touch"===t.pointerType||"pen"===t.pointerType){const n=nc(o,e._rootElement).anchorNode;if(gc(n)||zs(n)){ol(Lr(r,o,e,t))}}if(i&&null!==o&&0===o.rangeCount){const n=e._rootElement;if(null!==n&&t.target===n){const i=t.clientY;let s=n.childNodes.length;for(let t=0;t<n.childNodes.length;t++){const e=n.childNodes[t];if(gc(e)){const n=e.getBoundingClientRect();if(i<=(n.top+n.bottom)/2){s=t;break}}}o.setBaseAndExtent(n,s,n,s);const l=Lr(r,o,e,t);null!==l?ol(l):o.removeAllRanges()}}Nl(e,Ke,t)})}],["cut",Pn],["copy",Pn],["dragstart",Pn],["dragover",Pn],["dragend",Pn],["paste",Pn],["focus",Pn],["blur",Pn],["drop",Pn]];s&&In.push(["beforeinput",(t,e)=>function(t,e){const n=t.inputType;if("deleteCompositionText"===n||i&&bl(e))return;if("insertCompositionText"===n)return;Ai(e,()=>{qn(t,e)||Nl(e,ze,t)},{event:t})}(t,e)]);const Ln=new WeakMap,Kn=new WeakMap,zn=Dn(t=>(t.addEventListener("selectionchange",ro),()=>t.removeEventListener("selectionchange",ro)));function Bn(t,e,n,o,r,i){const l=t.anchor,c=t.focus,a=l.getNode(),u=_i();let f;if(void 0!==i)f=i;else{const t=Jl(Il(u));f=null!==t?nc(t,u._rootElement):null}const d=null!==f?f.anchorNode:null,h=l.key,g=u.getElementByKey(h),_=n.length;return h!==c.key||!Xo(a)||(!r&&(!s||u._inputState.lastBeforeInputInsertTextTimeStamp<o+50)||a.isDirty()&&_<2||sl(n))&&l.offset!==c.offset&&!a.isComposing()||Ks(a)||a.isDirty()&&_>1||(r||!s)&&null!==g&&!a.isComposing()&&d!==wc(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=Ls(e);return 0===n?!e.canInsertTextBefore()||!o.canInsertTextBefore()&&!e.isComposing()||r||function(t){const e=t.getPreviousSibling();return(Xo(e)||Pi(e)&&e.isInline())&&!e.canInsertTextAfter()}(e):n===e.getTextContentSize()&&(!e.canInsertTextAfter()||!o.canInsertTextAfter()&&!e.isComposing()||r)}(t,a)}function Rn(t,e){return zs(t)&&null!==t.nodeValue&&0!==e&&e!==t.nodeValue.length}function Wn(e,n,o){const{anchorNode:r,anchorOffset:i,focusNode:s,focusOffset:l}=nc(e,n._rootElement),c=n._inputState;c.isSelectionChangeFromDOMUpdate&&(c.isSelectionChangeFromDOMUpdate=!1,Rn(r,i)&&Rn(s,l)&&!c.postDeleteSelectionToRestore)||Ai(n,()=>{if(!o)return void ol(null);if(!As(n,r,s))return;let a=Kr();if(c.postDeleteSelectionToRestore&&ur(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(),ol(a))}if(c.postDeleteSelectionToRestore=null,ur(a)){const o=a.anchor,u=o.getNode();if(a.isCollapsed()){"Range"===e.type&&r===s&&(a.dirty=!0);const i=Il(n).event,l=i?i.timeStamp:performance.now(),{format:f,style:d,offset:h,key:g,timeStamp:_}=c.collapsedSelectionFormat,p=nl(),y=!1===n.isComposing()&&""===p.getTextContent();if(l<_+200&&o.offset===h&&o.key===g)$n(a,f,d);else if("text"===o.type)Xo(u)||t(141),Un(a,u);else if("element"===o.type&&!y){Pi(u)||t(259);const e=o.getNode();e.isEmpty()?function(t,e){const n=e.getTextFormat(),o=e.getTextStyle();$n(t,n,o)}(a,e):$n(a,a.format,"")}}else{const t=o.key,e=a.focus.key,n=a.getNodes(),r=n.length,s=a.isBackward(),c=s?l:i,u=s?i:l,f=s?e:t,d=s?t:e;let h=2047,g=!1;for(let t=0;t<r;t++){const e=n[t],o=e.getTextContentSize();if(Xo(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}}Nl(n,Ie)})}function $n(t,e,n){t.format===e&&t.style===n||(t.format=e,t.style=n,t.dirty=!0)}function Un(t,e){$n(t,e.getFormat(),e.getStyle())}function Hn(t){if(!t.getTargetRanges)return null;const e=t.getTargetRanges();return 0===e.length?null:e[0]}function jn(t){const{lastKeyCode:e}=_i()._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=Kr();if(!ur(o)||!o.isCollapsed())return;const r=o.anchor.getNode();if(!Xo(r))return;const{offset:i}=o.anchor;if(r.getTextContentSize()===i){const t=r.getNextSibling();if("\n"===n){if(Yi(t))t.selectEnd();else if(!t){const t=qc(r,Ar),e=t&&t.getNextSibling();Pi(e)&&e.selectStart()}}else"\t"===n?er(t)&&t.selectEnd():Xo(t)&&t.getTextContent()[0]===n&&t.select(1,1)}else r.getTextContent()[i]===n&&r.select(i+1,i+1)}function Jn(t){t.isInsertTextAfterHandledSelectionCommand=!1,null!==t.handledSelectionCommandTimeoutId&&(clearTimeout(t.handledSelectionCommandTimeoutId),t.handledSelectionCommandTimeoutId=null)}function Vn(t){Jn(t),t.isInsertTextAfterHandledSelectionCommand=!0,t.handledSelectionCommandTimeoutId=setTimeout(()=>Jn(t),0)}function qn(t,e){const n=ac(t);if(gc(n)&&Rc(n,e))return!0;const o=e.getRootElement();if(null===o)return!1;const r=cc(o.ownerDocument);return null!==r&&o.contains(r)&&Rc(r,e)}function Yn(e){const n=e.inputType,o=Hn(e),r=_i(),i=r._inputState,s=Kr();if("insertText"===n&&e.data&&i.isInsertTextAfterHandledSelectionCommand){if(Jn(i),e.preventDefault(),ur(s)&&!s.isCollapsed()){const t=s.isBackward()?s.anchor:s.focus;s.anchor.set(t.key,t.offset,t.type),s.focus.set(t.key,t.offset,t.type)}return!0}if("deleteContentBackward"===n){if(null===s){const t=zr();if(!ur(t))return!0;ol(t.clone())}if(ur(s)){const n=s.anchor.key===s.focus.key;if(function(t,e){return"MediaLast"===t.lastKeyCode&&e<t.lastKeyDownTimeStamp+30}(i,e.timeStamp)&&r.isComposing()&&n){if(Vs(null),i.lastKeyDownTimeStamp=0,setTimeout(()=>{Ai(r,()=>{Vs(null)})},30),ur(s)){const e=s.anchor.getNode();e.markDirty(),Xo(e)||t(142),Un(s,e)}}else{if(Vs(null),l&&null!==o&&!o.collapsed&&(s.applyDOMRange(o),!s.isCollapsed()))return e.preventDefault(),s.removeText(),!0;e.preventDefault();const t=s.anchor.getNode(),c=t.getTextContent(),a=t.canInsertTextAfter(),u=0===s.anchor.offset&&s.focus.offset===c.length;let d=f&&n&&!u&&a;if(d&&s.isCollapsed()&&(d=!Ki(kl(s.anchor,!0))),!d){Nl(r,$e,!0);const t=Kr();f&&ur(t)&&t.isCollapsed()&&(i.postDeleteSelectionToRestore=t,setTimeout(()=>i.postDeleteSelectionToRestore=null))}}return!0}}if(!ur(s))return!0;const c=e.data;null!==i.unprocessedBeforeInputData&&ul(!1,r,i.unprocessedBeforeInputData),s.dirty&&null===i.unprocessedBeforeInputData||!s.isCollapsed()||Bi(s.anchor.getNode())||null===o||s.applyDOMRange(o),i.unprocessedBeforeInputData=null;const a=s.anchor,u=s.focus,d=a.getNode(),h=u.getNode();if("insertText"===n||"insertTranspose"===n){if("\n"===c)e.preventDefault(),Nl(r,Ue,!1);else if(c===D)e.preventDefault(),Nl(r,He);else if(null==c&&e.dataTransfer){const t=e.dataTransfer.getData("text/plain");e.preventDefault(),s.insertRawText(t)}else null!=c&&Bn(s,o,c,e.timeStamp,!0)?(e.preventDefault(),Nl(r,je,c),jn(c)):i.unprocessedBeforeInputData=c;return i.lastBeforeInputInsertTextTimeStamp=e.timeStamp,!0}switch(e.preventDefault(),n){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":Nl(r,je,e);jn((e.dataTransfer?e.dataTransfer.getData("text/plain"):null)??e.data);break;case"insertFromComposition":{const t=i.hadOrphanedCompositionEvents;i.hadOrphanedCompositionEvents=!1;const n=r._compositionKey;Vs(null),t||Nl(r,je,e),Zn(n);break}case"insertLineBreak":Vs(null),Nl(r,Ue,!1);break;case"insertParagraph":Vs(null),i.isInsertLineBreak&&!l?(i.isInsertLineBreak=!1,Nl(r,Ue,!1)):Nl(r,He);break;case"insertFromPaste":case"insertFromPasteAsQuotation":Nl(r,Je,e);break;case"deleteByComposition":(function(t,e){return t!==e||Pi(t)||Pi(e)||!Ls(t)||!Ls(e)})(d,h)&&Nl(r,Ve,e);break;case"deleteByDrag":Al(No),Nl(r,Ve,e);break;case"deleteByCut":Nl(r,Ve,e);break;case"deleteContent":Nl(r,$e,!1);break;case"deleteWordBackward":Nl(r,qe,!0);break;case"deleteWordForward":Nl(r,qe,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":Nl(r,Ye,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":Nl(r,Ye,!1);break;case"formatStrikeThrough":Nl(r,Ge,"strikethrough");break;case"formatBold":Nl(r,Ge,"bold");break;case"formatItalic":Nl(r,Ge,"italic");break;case"formatUnderline":Nl(r,Ge,"underline");break;case"historyUndo":Nl(r,Qe);break;case"historyRedo":Nl(r,Ze)}return!0}function Gn(t){const e=_i(),n=e._inputState,o=Kr(),r=t.data,l=Hn(t);let c=!1;if(null!=r&&ur(o)){const a=Jl(Il(e)),u=null!==a?nc(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()&&Xo(h)&&Ks(h);if(!d&&!g&&Bn(o,l,r,t.timeStamp,!1,u)){if(c=!0,"ending-firefox"===n.compositionPhase){const t=to(e,r);if(n.compositionPhase="idle",t)return Al(wo),rl(),!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;s&&!o.isCollapsed()&&Xo(l)&&null!==u.anchorNode&&l.getTextContent().slice(0,h)+r+l.getTextContent().slice(h+g)===al(u.anchorNode)||Nl(e,je,r);const _=r.length;i&&_>1&&"insertCompositionText"===t.inputType&&!e.isComposing()&&(o.anchor.offset-=_,o._cachedNodes=null,o._cachedIsBackward=null),f&&e.isComposing()&&(n.lastKeyDownTimeStamp=0,Vs(null))}}if(!c){ul(!1,e,null!==r?r:void 0),"ending-firefox"===n.compositionPhase&&(to(e,r||void 0),Al(wo),n.compositionPhase="idle")}return rl(),!0}function Xn(t){const e=_i(),n=e._inputState,o=Kr();if(ur(o)&&!e.isComposing()){n.compositionPhase="composing",n.hadOrphanedCompositionEvents=!1;const r=o.anchor,i=o.anchor.getNode();if(Vs(r.key),Al(Eo),t.timeStamp<n.lastKeyDownTimeStamp+30||"element"===r.type||!o.isCollapsed()||!f&&(i.getFormat()!==o.format||Xo(i)&&i.getStyle()!==o.style)||Xo(i)&&(Ks(i)||0===r.offset&&!i.canInsertTextBefore()||r.offset===i.getTextContentSize()&&!i.canInsertTextAfter())){Nl(e,je,F);const t=Kr();ur(t)&&Vs(t.anchor.key)}}return!0}function Qn(t){const e=_i();return e._inputState.compositionPhase="idle",to(e,t.data),Al(wo),!0}function Zn(t){if(null===t)return;const e=Ys(t);if(!Xo(e)||"text"===e.getType()||Ks(e)||!e.isAttached())return;const n=Kr(),o=ur(n)&&n.anchor.key===t?n.anchor.offset:null,r=Go(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 to(t,e){const n=t._compositionKey;if(Vs(null),null!==n&&null!=e){if(""===e){const e=Ys(n),o=t.getElementByKey(n),r=null!==o&&Xo(e)?wc(e,o,t):null;if(null!==r&&null!==r.nodeValue&&Xo(e)){const n=Jl(Il(t)),o=n&&nc(n,t._rootElement);let i=null,s=null;null!==o&&o.anchorNode===r&&(i=o.anchorOffset,s=o.focusOffset),fl(e,r.nodeValue,i,s,!0)}return Zn(n),!1}if("\n"===e[e.length-1]){const e=Kr();if(ur(e)||dr(e)){if(ur(e)){const t=e.focus;e.anchor.set(t.key,t.offset,t.type)}return Nl(t,cn,null),Zn(n),!1}}const o=Ys(n);if(null!==o&&Xo(o)&&Ks(o)){o.markDirty();const t=Kr(),r=o.getTextContentSize(),i=ur(t)&&t.anchor.key===n?t.anchor.offset:r;return o.select(i,i).insertText(e),!0}}return ul(!0,t,e),Zn(n),!1}function eo(t){const e=_i(),n=e._inputState;if(null==t.key)return!0;if("ending-safari"===n.compositionPhase){const o=ml(t);if(o&&Ai(e,()=>{to(e,n.compositionEndData)}),n.compositionPhase="idle",n.compositionEndData="",o)return!0}if(function(t){return _l(t,"ArrowRight",{shiftKey:"any"})}(t))Nl(e,en,t);else if(function(t){return _l(t,"ArrowRight",{...pl,shiftKey:"any"})}(t))Nl(e,nn,t);else if(function(t){return _l(t,"ArrowLeft",{shiftKey:"any"})}(t))Nl(e,on,t);else if(function(t){return _l(t,"ArrowLeft",{...pl,shiftKey:"any"})}(t))Nl(e,rn,t);else if(function(t){return _l(t,"ArrowUp",{altKey:"any",shiftKey:"any"})}(t))Nl(e,sn,t);else if(function(t){return _l(t,"ArrowDown",{altKey:"any",shiftKey:"any"})}(t))Nl(e,ln,t);else if(function(t){return _l(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any",shiftKey:!0})}(t))n.isInsertLineBreak=!0,Nl(e,cn,t);else if(function(t){return" "===t.key}(t))Nl(e,an,t);else if(function(t){return r&&_l(t,"o",{ctrlKey:!0})}(t))t.preventDefault(),n.isInsertLineBreak=!0,Nl(e,Ue,!0);else if(function(t){return _l(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any"})}(t))n.isInsertLineBreak=!1,Nl(e,cn,t);else if(function(t){return _l(t,"Backspace",{shiftKey:"any"})||r&&_l(t,"h",{ctrlKey:!0})}(t))ml(t)?Nl(e,un,t)&&Vn(n):(t.preventDefault(),Nl(e,$e,!0));else if(function(t){return"Escape"===t.key}(t))Nl(e,fn,t);else if(function(t){return _l(t,"Delete",{})||r&&_l(t,"d",{ctrlKey:!0})}(t))!function(t){return"Delete"===t.key}(t)?(t.preventDefault(),Nl(e,$e,!1)):Nl(e,dn,t);else if(function(t){return _l(t,"Backspace",yl)}(t))t.preventDefault(),Nl(e,qe,!0);else if(function(t){return _l(t,"Delete",yl)}(t))t.preventDefault(),Nl(e,qe,!1);else if(function(t){return r&&_l(t,"Backspace",{metaKey:!0})}(t))t.preventDefault(),Nl(e,Ye,!0);else if(function(t){return r&&(_l(t,"Delete",{metaKey:!0})||_l(t,"k",{ctrlKey:!0}))}(t))t.preventDefault(),Nl(e,Ye,!1);else if(function(t){return _l(t,"b",pl)}(t))t.preventDefault(),Nl(e,Ge,"bold");else if(function(t){return _l(t,"u",pl)}(t))t.preventDefault(),Nl(e,Ge,"underline");else if(function(t){return _l(t,"i",pl)}(t))t.preventDefault(),Nl(e,Ge,"italic");else if(function(t){return _l(t,"Tab",{shiftKey:"any"})}(t))Nl(e,hn,t);else if(function(t){return _l(t,"z",pl)}(t))t.preventDefault(),Nl(e,Qe);else if(function(t){if(r)return _l(t,"z",{metaKey:!0,shiftKey:!0});return _l(t,"y",{ctrlKey:!0})||_l(t,"z",{ctrlKey:!0,shiftKey:!0})}(t))t.preventDefault(),Nl(e,Ze);else{const o=e._editorState._selection;!function(t){return _l(t,"a",pl)}(t)?null===o||ur(o)||(!function(t){return _l(t,"c",pl)}(t)?function(t){return _l(t,"x",pl)}(t)&&(t.preventDefault(),Nl(e,Tn,t)):(t.preventDefault(),Nl(e,vn,t))):(t.preventDefault(),Nl(e,kn,t)&&Vn(n))}return function(t){return t.ctrlKey||t.shiftKey||t.altKey||t.metaKey}(t)&&e.dispatchCommand(An,t),!0}function no(t){let e=t.__lexicalEventHandles;return void 0===e&&(e=[],t.__lexicalEventHandles=e),e}const oo=new Map;function ro(t){const e=Vl(t.target);if(null===e)return;const n=Ol(t.target);let o=null,r=null;const i=null!==n?Kn.get(n):void 0;if(null!==n){if(void 0!==i){const t=i.editors;let n=i.hasShadowEditor;if(void 0===n){n=!1;for(const e of t)if(null!==e._rootElement&&ql(e._rootElement.getRootNode())){n=!0;break}i.hasShadowEditor=n}if(n){let n=null,i=null;for(const s of t){const t=s._rootElement;if(null===t)continue;const l=nc(e,t).anchorNode;if(null!==l&&Fs(l)===s){if(ql(t.getRootNode())){o=s,r=l;break}null===n&&(n=s,i=l)}}null===o&&null!==n&&(o=n,r=i)}else{const t=e.anchorNode;null===t||gc(t)&&null!==t.shadowRoot||(o=Fs(t),null!==o&&(r=t))}}if(null===o){const t=cc(n);o=null!==t?Fs(t):null}}if(null===o)return;if(o._inputState.isSelectionChangeFromMouseDown){if(void 0!==i)for(const t of i.editors)t._inputState.isSelectionChangeFromMouseDown=!1;Ai(o,()=>{const n=zr(),i=r??nc(e,o._rootElement).anchorNode;if(gc(i)||zs(i)){ol(Lr(n,e,o,t))}})}const s=ll(o),l=s[s.length-1],c=l._key,a=oo.get(c),u=a||l;u!==o&&Wn(e,u,!1),Wn(e,o,!0),o!==l?oo.set(c,o):a&&oo.delete(c)}function io(t){t._lexicalHandled=!0}function so(t){return!0===t._lexicalHandled}const lo=()=>{};function co(e){const n=Ln.get(e);if(void 0===n)return void lo();const o=Kn.get(n);if(void 0===o)return void lo();Ln.delete(e);const r=Ps(e);Ds(r)?(!function(t){if(null!==t._parentEditor){const e=ll(t),n=e[e.length-1]._key;oo.get(n)===t&&oo.delete(n)}else oo.delete(t._key)}(r),o.editors.delete(r),o.hasShadowEditor=void 0,e.__lexicalEditor=null):r&&t(198);const i=no(e);for(let t=0;t<i.length;t++)i[t]();e.__lexicalEventHandles=[]}function ao(e,n,o){fi();const r=e.__key,i=e.getParent();if(null===i)return void(null!==ta(e)&&t(367,r,String(ta(e))));const s=function(t){const e=Kr();if(!ur(e)||!Pi(t))return e;const{anchor:n,focus:o}=e,r=n.getNode(),i=o.getNode();Fl(r,t)&&n.set(t.__key,0,"element");Fl(i,t)&&o.set(t.__key,0,"element");return e}(e);let l=!1;if(ur(s)&&n){const t=s.anchor,n=s.focus;t.key===r&&(Wr(t,e,i,e.getPreviousSibling(),e.getNextSibling()),l=!0),n.key===r&&(Wr(n,e,i,e.getPreviousSibling(),e.getNextSibling()),l=!0)}else dr(s)&&n&&e.isSelected()&&e.selectPrevious();if(ur(s)&&n&&!l){const t=e.getIndexWithinParent();Hs(e),Br(s,i,t,-1)}else Hs(e);o||Bl(i)||i.canBeEmpty()||!i.isEmpty()||ao(i,n),n&&s&&Bi(i)&&i.isEmpty()&&i.selectEnd()}function uo(t){return t}const fo=Symbol.for("ephemeral");function ho(t){return t[fo]||!1}const go={configurable:!0,enumerable:!1,value:void 0,writable:!0};class _o{__type;__key;__parent;__prev;__next;__state;[Kt];static getType(){const{ownNodeType:e}=Hc(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||Gc(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",go),Object.defineProperty(this,Kt,go),Us(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=Ys(t);if(null===e)break;t=null!==e.__parent?e.__parent:ta(e)}return!1}isSelected(t){const e=t||Kr();if(null==e)return!1;const n=e.getNodes().some(t=>t.__key===this.__key);if(Xo(this))return n;if(ur(e)&&"element"===e.anchor.type&&"element"===e.focus.type){if(e.isCollapsed())return!1;const t=this.getParent();if(Ki(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:Ys(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(Bl(n)||null!==ta(e))return Pi(e)||e===this&&Ki(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:Ys(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:Ys(t)}getNextSiblings(){const t=[];let e=this.getNextSibling();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getCommonAncestor(t){const e=Pi(this)?this:this.getParent(),n=Pi(t)?t:t.getParent(),o=e&&n?Za(e,n):null;return o?o.commonAncestor:null}is(t){return null!=t&&this.__key===t.__key}isBefore(e){const n=Za(this,e);return null!==n&&("descendant"===n.type||("branch"===n.type?-1===Ga(n):("same"!==n.type&&"ancestor"!==n.type&&t(279),!1)))}isParentOf(t){return Fl(t,this)}getNodesBetween(e){const n=this.isBefore(e),o=[],r=new Set;let i=this;for(;null!==i;){const s=i.__key;if(r.has(s)||(r.add(s),o.push(i)),i===e)break;const l=Pi(i)?n?i.getFirstChild():i.getLastChild():null;if(null!==l){i=l;continue}const c=n?i.getNextSibling():i.getPreviousSibling();if(null!==c){i=c;continue}const a=i.getParentOrThrow();if(r.has(a.__key)||o.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||r.has(f.__key)||o.push(f)}while(null===u);i=u}return n||o.reverse(),o}isDirty(){const t=_i()._dirtyLeaves;return null!==t&&t.has(this.__key)}getLatest(){if(ho(this))return this;const e=Ys(this.__key);return null===e&&t(113),e}getWritable(){if(ho(this))return this;fi();const t=hi(),e=_i(),n=t._nodeMap,o=this.__key,r=this.getLatest(),i=e._cloneNotNeeded,s=Kr();if(null!==s&&s.setCachedNodes(null),i.has(o))return Js(r),r;const l=Dc(r);return i.add(o),Js(l),n.set(o,l),l}getTextContent(){return ha(this)}getTextContentSize(){return this.getTextContent().length}createDOM(e,n){t(70)}updateDOM(e,n,o){t(71)}getDOMSlot(t){return new q(t)}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(),o=e.$;let r=o;for(const t of Nt(n).flatKeys)t in e&&(void 0!==r&&r!==o||(r={...o}),r[t]=e[t]);return(n.__state||r)&&bt(t).updateFromJSON(r),n}(this,t)}static transform(){return null}remove(t){ao(this,!0,t)}replace(e,n){fi();let o=Kr();null!==o&&(o=o.clone()),$l(this,e);const r=this.getLatest(),i=this.__key,s=e.__key,l=e.getWritable(),c=this.getParentOrThrow().getWritable(),a=c.__size,u=l.getParent(),f=null!==u?l.getIndexWithinParent():-1;Hs(l),null!==u&&ur(o)&&Br(o,u,f,-1);const d=r.getPreviousSibling(),h=r.getNextSibling(),g=r.__prev,_=r.__next,p=r.__parent;if(ao(r,!1,!0),null===d)c.__first=s;else{d.getWritable().__next=s}if(l.__prev=g,null===h)c.__last=s;else{h.getWritable().__prev=s}l.__next=_,l.__parent=p,c.__size=a;let y=0;n&&(Pi(this)&&Pi(l)||t(139),y=l.getChildrenSize(),l.splice(y,0,this.getChildren()));const m=ia(this);if(m.length>0){Qc(this)&&Qc(l)||t(368,this.__key,l.__key);for(const t of m){const e=sa(this,t);null!==e&&(ya(this,t),pa(l,t,e))}}if(ur(o)){ol(o);const t=o.anchor,e=o.focus;t.key===i&&(n&&"element"===t.type?t.set(l.__key,y+t.offset,"element"):ir(t,l)),e.key===i&&(n&&"element"===e.type?e.set(l.__key,y+e.offset,"element"):ir(e,l))}return qs()===i&&Vs(s),l}insertAfter(t,e=!0){fi(),$l(this,t);const n=this.getWritable(),o=t.getWritable();ma(this.getParentOrThrow());const r=o.getParent(),i=Kr();let s=!1,l=!1;if(null!==r){const n=t.getIndexWithinParent();if(ur(i)){const t=r.__key,e=i.anchor,o=i.focus;s="element"===e.type&&e.key===t&&e.offset===n+1,l="element"===o.type&&o.key===t&&o.offset===n+1}Hs(o),e&&ur(i)&&Br(i,r,n,-1)}else Hs(o);const c=this.getNextSibling(),a=this.getParentOrThrow().getWritable(),u=o.__key,f=n.__next;if(null===c)a.__last=u;else{c.getWritable().__prev=u}if(a.__size++,n.__next=u,o.__next=f,o.__prev=n.__key,o.__parent=n.__parent,e&&ur(i)){const t=this.getIndexWithinParent();Br(i,a,t+1);const e=a.__key;s&&i.anchor.set(e,t+2,"element"),l&&i.focus.set(e,t+2,"element")}return t}insertBefore(t,e=!0){fi(),$l(this,t);const n=this.getWritable(),o=t.getWritable();ma(this.getParentOrThrow());const r=o.__key,i=Kr(),s=o.getParent(),l=null!==s?o.getIndexWithinParent():-1;Hs(o),null!==s&&e&&ur(i)&&Br(i,s,l,-1);const c=this.getPreviousSibling(),a=this.getParentOrThrow().getWritable(),u=n.__prev,f=this.getIndexWithinParent();if(null===c)a.__first=r;else{c.getWritable().__next=r}if(a.__size++,n.__prev=r,o.__prev=u,o.__next=n.__key,o.__parent=n.__parent,e&&ur(i)){Br(i,this.getParentOrThrow(),f)}return t}isParentRequired(){return!1}createParentElementNode(){return es()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(t,e){fi();const n=ea(this);if(null!==n)return n.selectPrevious(t,e);const o=this.getPreviousSibling(),r=this.getParentOrThrow();if(null===o)return r.select(0,0);if(Pi(o))return o.select();if(!Xo(o)){const t=o.getIndexWithinParent()+1;return r.select(t,t)}return o.select(t,e)}selectNext(t,e){fi();const n=ea(this);if(null!==n)return n.selectNext(t,e);const o=this.getNextSibling(),r=this.getParentOrThrow();if(null===o)return r.select();if(Pi(o))return o.select(0,0);if(!Xo(o)){const t=o.getIndexWithinParent();return r.select(t,t)}return o.select(t,e)}markDirty(){this.getWritable()}reconcileObservedMutation(t,e){this.markDirty()}}function po(t){return t instanceof _o}const yo="historic",mo="history-push",xo="history-merge",Co="paste",So="cut",vo="collaboration",To="skip-collab",ko="skip-scroll-into-view",bo="skip-dom-selection",No="skip-selection-focus",Eo="composition-start",wo="composition-end",Oo="!important";function Mo(t){const e={};if(!t)return e;let n="",o="",r=null,i=!1,s=!1,l=!1,c=0;const a=t.length;let u=-1;for(let f=0;f<a;f++){const a=t[f];if(i)"*"===a&&"/"===t[f+1]&&(i=!1,f++);else if(s)-1===u&&(u=f),s=!1;else if(null===r)if("/"!==a||"*"!==t[f+1])if('"'!==a&&"'"!==a)if("("!==a)if(")"!==a)if(l||":"!==a||0!==c){if(";"===a&&0===c){-1!==u&&(l?o+=t.slice(u,f):n+=t.slice(u,f),u=-1);const r=n.trim(),i=o.trim();""!==r&&""!==i&&(e[r]=i),n="",o="",l=!1;continue}-1===u&&(u=f)}else-1!==u&&(n+=t.slice(u,f),u=-1),l=!0;else-1===u&&(u=f),c=Math.max(0,c-1);else-1===u&&(u=f),c++;else-1===u&&(u=f),r=a;else-1!==u&&(l?o+=t.slice(u,f):n+=t.slice(u,f),u=-1),i=!0,f++;else-1===u&&(u=f),"\\"===a?s=!0:a===r&&(r=null)}-1!==u&&(l?o+=t.slice(u,a):n+=t.slice(u,a));const f=n.trim(),d=o.trim();return""!==f&&""!==d&&(e[f]=d),e}function Ao(t,e,n){const o=n.trimEnd(),r=o.length-10;r>=0&&o.slice(r).toLowerCase()===Oo?t.setProperty(e,o.slice(0,r).trim(),"important"):t.setProperty(e,n,"")}function Do(t,e){for(const n in e){const o=e[n];null==o?t.removeProperty(n):Ao(t,n,o)}}function Fo(t,e,n=""){if(e===n)return;const o=Mo(n),r=Mo(e);for(const e in r)delete o[e],Ao(t,e,r[e]);for(const e in o)t.removeProperty(e)}function Po(t,e){return 16&e?"code":e&T?"mark":32&e?"sub":64&e?"sup":null}function Io(t,e){return 1&e?"strong":2&e?"em":"span"}function Lo(t,e,n,o,r){const i=o.classList;let s=Cl(r,"base");void 0!==s&&i.add(...s),s=Cl(r,"underlineStrikethrough");let l=!1;const c=8&e&&4&e;void 0!==s&&(8&n&&4&n?(l=!0,c||i.add(...s)):c&&i.remove(...s));for(const t in z){const o=z[t];if(s=Cl(r,t),void 0!==s)if(n&o){if(l&&("underline"===t||"strikethrough"===t)){e&o&&i.remove(...s);continue}(0===(e&o)||c&&"underline"===t||"strikethrough"===t)&&i.add(...s)}else e&o&&i.remove(...s)}}function Ko(t,e,n){const o=n.isComposing(),r=t+(o?A:""),s=vc(),l=Tc(s).$getDOMSlot(n,e,s),c=l.getFirstChild();if(null===c||c.nodeType!==Node.TEXT_NODE)return void l.insertChild(Zl().createTextNode(r));const a=c,u=a.nodeValue;if(u!==r)if(o||i){const[t,e,n]=function(t,e){const n=t.length,o=e.length;let r=0,i=0;for(;r<n&&r<o&&t[r]===e[r];)r++;for(;i+r<n&&i+r<o&&t[n-i-1]===e[o-i-1];)i++;return[r,n-r-i,e.slice(r,o-i)]}(u,r);0!==e&&a.deleteData(t,e),a.insertData(t,n)}else a.nodeValue=r}function zo(t,e,n,o,r,i){Ko(r,t,e);const s=i.theme.text;void 0!==s&&Lo(0,0,o,t,s)}function Bo(t,e){const n=Zl().createElement(e);return n.appendChild(t),n}function Ro(t){return null!=t&&!0===t.__isInlineFormattable}class Wo extends _o{__text;__format;__style;__mode;__detail;get __isInlineFormattable(){return!0}$config(){return this.config("text",{importDOM:{"#text":()=>({conversion:Jo,priority:0}),b:()=>({conversion:Uo,priority:0}),code:()=>({conversion:Yo,priority:0}),em:()=>({conversion:Yo,priority:0}),i:()=>({conversion:Yo,priority:0}),mark:()=>({conversion:Yo,priority:0}),s:()=>({conversion:Yo,priority:0}),span:()=>({conversion:$o,priority:0}),strong:()=>({conversion:Yo,priority:0}),sub:()=>({conversion:Yo,priority:0}),sup:()=>({conversion:Yo,priority:0}),u:()=>({conversion:Yo,priority:0})}})}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 U[t.__mode]}getStyle(){return this.getLatest().__style}isToken(){return 1===this.getLatest().__mode}isComposing(){return this.__key===qs()}isSegmented(){return 2===this.getLatest().__mode}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(t){const e=z[t];return 0!==(this.getFormat()&e)}isSimpleText(){return"text"===this.__type&&0===this.__mode}getTextContent(){return this.getLatest().__text}getFormatFlags(t,e){return Ws(this.getLatest().__format,t,e)}canHaveFormat(){return!0}isInline(){return!0}createDOM(t,e){const n=this.__format,o=Po(0,n),r=Io(0,n),i=null===o?r:o,s=Zl().createElement(i);let l=s;this.hasFormat("code")&&s.setAttribute("spellcheck","false"),null!==o&&(l=Zl().createElement(r),s.appendChild(l));zo(l,this,0,n,this.__text,t);const c=this.__style;return""!==c&&Fo(s.style,c),s}updateDOM(e,n,o){const r=this.__text,i=e.__format,s=this.__format,l=Po(0,i),c=Po(0,s),a=Io(0,i),u=Io(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 i=Zl().createElement(u);return zo(i,this,0,s,r,o),n.replaceChild(i,e),!1}let f=n;null!==c&&null!==l&&(f=n.firstChild,null==f&&t(49)),Ko(r,f,this);const d=o.theme.text;void 0!==d&&i!==s&&Lo(0,i,s,f,d);const h=e.__style,g=this.__style;return h!==g&&Fo(n.style,g,h),!1}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 gc(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=Bo(n,"b")),this.hasFormat("italic")&&(n=Bo(n,"i")),this.hasFormat("strikethrough")&&(n=Bo(n,"s")),this.hasFormat("underline")&&(n=Bo(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?B[t]:t,e}setStyle(t){const e=this.getWritable();return e.__style=t,e}toggleFormat(t){const e=Ws(this.getFormat(),t,null);return this.setFormat(e)}toggleDirectionless(){const t=this.getWritable();return t.__detail^=1,t}toggleUnmergeable(){const t=this.getWritable();return t.__detail^=2,t}setMode(t){const e=$[t];if(this.__mode===e)return this;const n=this.getWritable();return n.__mode=e,n}setTextContent(t){if(this.__text===t)return this;const e=this.getWritable();return e.__text=t,e}select(t,e){fi();let n=t,o=e;const r=Kr(),i=this.getTextContent(),s=this.__key;if("string"==typeof i){const t=i.length;void 0===n&&(n=t),void 0===o&&(o=t)}else n=0,o=0;if(!ur(r))return Dr(s,n,s,o,"text","text");{const t=qs();t!==r.anchor.key&&t!==r.focus.key||Vs(s),r.setTextNodeRange(this,n,this,o)}return r}selectStart(){return this.select(0,0)}selectEnd(){const t=this.getTextContentSize();return this.select(t,t)}spliceText(t,e,n,o){const r=this.getWritable(),i=r.__text,s=n.length;let l=t;l<0&&(l=s+l,l<0&&(l=0));const c=Kr();if(o&&ur(c)){const e=t+s;c.setTextNodeRange(r,e,r,e)}const a=i.slice(0,l)+n+i.slice(l+e);return r.__text=a,r}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...t){fi();const e=this.getLatest(),n=e.getTextContent();if(""===n)return[];const o=e.__key,r=qs(),i=n.length;t.sort((t,e)=>t-e),t.push(i);const s=[],l=t.length;for(let e=0,o=0;e<i&&o<=l;o++){const r=t[o];r>e&&(s.push(n.slice(e,r)),e=r)}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=Kr();if(ur(m)){const[t,e]=m.isBackward()?[m.focus,m.anchor]:[m.anchor,m.focus];"text"===t.type&&t.key===o&&(p=t),"text"===e.type&&e.key===o&&(y=e)}e.isSegmented()?(f=Go(a),f.__format=d,f.__style=h,f.__detail=g,f.__state=At(e,f),_=!0):f=e.setTextContent(a);const x=[f];for(let t=1;t<c;t++){const n=Go(s[t]);n.__format=d,n.__style=h,n.__detail=g,n.__state=At(e,n);const i=n.__key;r===o&&Vs(i),x.push(n)}const C=p?p.offset:null,S=y?y.offset:null;let v=0;for(const t of x){if(!p&&!y)break;const e=v+t.getTextContentSize();if(null!==p&&null!==C&&C<=e&&C>=v&&(p.set(t.getKey(),C-v,"text"),C<e&&(p=null)),null!==y&&null!==S&&S<=e&&S>=v){y.set(t.getKey(),S-v,"text");break}v=e}if(null!==u){!function(t){const e=t.getPreviousSibling(),n=t.getNextSibling();null!==e&&Js(e);null!==n&&Js(n)}(this);const t=u.getWritable(),e=this.getIndexWithinParent();_?(t.splice(e,0,x),this.remove()):t.splice(e,1,x),ur(m)&&Br(m,u,e,c-1)}return x}mergeWithSibling(e){const n=e===this.getPreviousSibling();n||e===this.getNextSibling()||t(50);const o=this.__key,r=e.__key,i=this.__text,s=i.length;qs()===r&&Vs(o);const l=Kr();if(ur(l)){const t=l.anchor,i=l.focus;null!==t&&t.key===r&&$r(t,n,o,e,s),null!==i&&i.key===r&&$r(i,n,o,e,s)}const c=e.__text,a=n?c+i:i+c;this.setTextContent(a);const u=this.getWritable();return e.remove(),u}isTextEntity(){return!1}}function $o(t){return{forChild:Qo(t.style),node:null}}function Uo(t){const e=t,n="normal"===e.style.fontWeight;return{forChild:Qo(e.style,n?void 0:"bold"),node:null}}const Ho=new WeakMap;function jo(t){if(!gc(t))return!1;if("PRE"===t.nodeName)return!0;const e=t.style.whiteSpace;return"string"==typeof e&&e.startsWith("pre")}function Jo(e){const n=e;null===e.parentElement&&t(129);let o=n.textContent||"";if(null!==function(t){let e,n=t.parentNode;const o=[t];for(;null!==n&&void 0===(e=Ho.get(n))&&!jo(n);)o.push(n),n=n.parentNode;const r=void 0===e?n:e;for(let t=0;t<o.length;t++)Ho.set(o[t],r);return r}(n))return{node:qr(o)};if(o=o.replace(/\r/g,"").replace(/[ \t\n]+/g," "),""===o)return{node:null};if(" "===o[0]){let t=n,e=!0;for(;null!==t&&null!==(t=Vo(t,!1));){const n=t.textContent||"";if(n.length>0){/[ \t\n]$/.test(n)&&(o=o.slice(1)),e=!1;break}}e&&(o=o.slice(1))}if(" "===o[o.length-1]){let t=n,e=!0;for(;null!==t&&null!==(t=Vo(t,!0));){if((t.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){e=!1;break}}e&&(o=o.slice(0,o.length-1))}return""===o?{node:null}:{node:Go(o)}}function Vo(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,gc(n)){const t=n.style.display;if(""===t&&!mc(n)||""!==t&&!t.startsWith("inline"))return null}let o=n;for(;null!==(o=e?n.firstChild:n.lastChild);)n=o;if(zs(n))return n;if("BR"===n.nodeName)return null}}const qo={code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function Yo(t){const e=qo[t.nodeName.toLowerCase()];return void 0===e?{node:null}:{forChild:Qo(t.style,e),node:null}}function Go(t=""){return Wl(new Wo(t))}function Xo(t){return t instanceof Wo}function Qo(t,e){const n=t.fontWeight,o=t.textDecoration.split(" "),r="700"===n||"bold"===n,i=o.includes("line-through"),s="italic"===t.fontStyle,l=o.includes("underline"),c=t.verticalAlign;return t=>Xo(t)||Ro(t)?(r&&!t.hasFormat("bold")&&t.toggleFormat("bold"),i&&!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 Zo extends Wo{$config(){return this.config("tab",{extends:Wo})}constructor(t=void 0){super("\t",t),this.__detail=2}createDOM(t){const e=super.createDOM(t),n=Cl(t.theme,"tab");if(void 0!==n){e.classList.add(...n)}return e}setTextContent(t){return super.setTextContent("\t")}spliceText(e,n,o,r){return""===o&&0===n||"\t"===o&&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 tr(){return Wl(new Zo)}function er(t){return t instanceof Zo}class nr{key;offset;type;_selection;constructor(t,e,n){this._selection=null,this.key=t,this.offset=e,this.type=n}is(t){return this.key===t.key&&this.offset===t.offset&&this.type===t.type}isBefore(t){if(this.key===t.key)return this.offset<t.offset;return Ya(au(tu(this,"next")),au(tu(t,"next")))<0}getNode(){const e=Ys(this.key);return null===e&&t(20),e}set(t,e,n,o){const r=this._selection,i=this.key;o&&this.key===t&&this.offset===e&&this.type===n||(this.key=t,this.offset=e,this.type=n,ui()||(qs()===i&&Vs(t),null!==r&&(r.setCachedNodes(null),ur(r)&&(r._cachedIsBackward=null),r.dirty=!0)))}}function or(t,e,n){return new nr(t,e,n)}function rr(t,e){let n=e.__key,o=t.offset,r="element";if(Xo(e)){r="text";const t=e.getTextContentSize();o>t&&(o=t)}else if(!Pi(e)){const t=e.getNextSibling();if(Xo(t))n=t.__key,o=0,r="text";else{const t=e.getParent();t&&(n=t.__key,o=e.getIndexWithinParent()+1)}}t.set(n,o,r)}function ir(t,e){if(Pi(e)){const n=e.getLastDescendant();Pi(n)||Xo(n)?rr(t,n):rr(t,e)}else rr(t,e)}function sr(t,e,n,o){const r=t.getNode(),i=r.getChildAtIndex(t.offset),s=Go();if(s.setFormat(n),s.setStyle(o),ns(i))i.splice(0,0,[s]);else if(null!==i){const t=Bl(r)?es().append(s):s;i.insertBefore(t)}else if(Bl(r)){const t=r.getLastChild();Pi(t)&&!t.isInline()&&t.isEmpty()?t.append(s):r.append(es().append(s))}else r.append(s);t.is(e)&&e.set(s.__key,0,"text"),t.set(s.__key,0,"text")}function lr(e,n,o,r){const i=e.anchor.getNode();Xo(i)||t(398);const s=e.anchor.offset,l=Go(n);l.setFormat(o),l.setStyle(r);const c=i.getParentOrThrow();if(0===s)c.isInline()&&!i.__prev?c.insertBefore(l):i.insertBefore(l,!1);else if(s===i.getTextContentSize())c.isInline()&&!i.__next?c.insertAfter(l):i.insertAfter(l,!1);else{const[t]=i.splitText(s);t.insertAfter(l,!1)}""===i.getTextContent()&&i.isAttached()&&i.remove(),l.selectEnd(),l.isComposing()&&"text"===e.anchor.type&&e.anchor.set(e.anchor.key,e.anchor.offset-n.length,e.anchor.type)}class cr{_nodes;_cachedNodes;dirty;constructor(t){this._cachedNodes=null,this._nodes=t,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){if(!dr(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 cr(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(t){}insertText(){}insertNodes(t){const e=this.getNodes().filter(t=>null===ta(t)),n=e.length;if(0===n)return;const o=e[n-1];let r;if(Xo(o))r=o.select();else{const t=o.getIndexWithinParent()+1;r=o.getParentOrThrow().select(t,t)}r.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=Ys(t);null!==e&&n.push(e)}return ui()||(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().filter(t=>null===ta(t));if((Kr()||zr())===this&&t[0]){const e=Ia(t[0],"next");nu(Va(e,e))}for(const e of t)e.remove();ar()}}function ar(){const t=nl();if(t.isEmpty()){const e=es();t.append(e),e.select()}}function ur(t){return t instanceof fr}class fr{format;style;anchor;focus;_cachedNodes;_cachedIsBackward;dirty;constructor(t,e,n,o){this.anchor=t,this.focus=e,t._selection=this,e._selection=this,this._cachedNodes=null,this._cachedIsBackward=null,this.format=n,this.style=o,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){return!!ur(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,o]=t.getTextSlices();n&&e.push(n.caret.origin);const r=new Set,i=new Set;for(const n of t)if(Aa(n)){const{origin:t}=n;0===e.length?r.add(t):(i.add(t),e.push(t))}else{const{origin:t}=n;Pi(t)&&i.has(t)||e.push(t)}o&&e.push(o.caret.origin);if(Ma(t.focus)&&Pi(t.focus.origin)&&null===t.focus.getNodeAtCaret())for(let n=Ba(t.focus.origin,"previous");Aa(n)&&r.has(n.origin)&&!n.origin.isEmpty()&&n.origin.is(e[e.length-1]);n=Wa(n))r.delete(n.origin),e.pop();for(;e.length>1;){const t=e[e.length-1];if(!Pi(t)||i.has(t)||t.isEmpty()||r.has(t))break;e.pop()}if(0===e.length&&t.isCollapsed()){const n=au(t.anchor),o=au(t.anchor.getFlipped()),r=t=>wa(t)?t.origin:t.getNodeAtCaret(),i=r(n)||r(o)||(t.anchor.getNodeAtCaret()?n.origin:o.origin);e.push(i)}return e}(du(ru(this),"next"));return ui()||(this._cachedNodes=e),e}setTextNodeRange(t,e,n,o){return this.anchor.set(t.__key,e,"text"),this.focus.set(n.__key,o,"text"),this}getTextContent(){const t=this.getNodes();if(0===t.length)return"";const e=t[0],n=t[t.length-1],o=this.anchor,r=this.focus,i=o.isBefore(r),[s,l]=yr(this);let c="",a=!0;for(let u=0;u<t.length;u++){const f=t[u];if(Pi(f)&&!f.isInline()){a||(c+="\n");let t="";for(const e of ia(f)){const n=sa(f,e);null!==n&&(t+=n.getTextContent())}""!==t?(c+=t,a=!1):a=!f.isEmpty()}else if(a=!1,Xo(f)){let t=f.getTextContent();f===e?f===n?"element"===o.type&&"element"===r.type&&r.offset!==o.offset||(t=s<l?t.slice(s,l):t.slice(l,s)):t=i?t.slice(s):t.slice(l):f===n&&(t=i?t.slice(0,l):t.slice(0,s)),c+=t}else!Ki(f)&&!Yi(f)||f===n&&this.isCollapsed()||(c+=f.getTextContent())}return c}applyDOMRange(t){const e=_i(),n=e.getEditorState()._selection,o=Mr(t.startContainer,t.startOffset,t.endContainer,t.endOffset,e,n);if(null===o)return;const[r,i,s]=o;this.anchor.set(r.key,r.offset,r.type,!0),this.focus.set(i.key,i.offset,i.type,!0),s&&(this.dirty=!0),It(this)}clone(){const t=this.anchor,e=this.focus;return new fr(or(t.key,t.offset,t.type),or(e.key,e.offset,e.type),this.format,this.style)}toggleFormat(t){this.format=Ws(this.format,t,null),this.dirty=!0}setFormat(t){this.format=t,this.dirty=!0}setStyle(t){this.style=t,this.dirty=!0}hasFormat(t){const e=z[t];return 0!==(this.format&e)}insertRawText(t){this.insertNodes(qr(t))}insertText(e){let n=this.format,o=this.style;if(!this.isCollapsed()){const t=(this.focus.isBefore(this.anchor)?this.focus:this.anchor).getNode();if(Xo(t)&&(n=t.getFormat(),o=t.getStyle()),this.removeText(),this.format=n,this.style=o,""===e)return;if(null===qs())return"element"===this.anchor.type&&sr(this.anchor,this.focus,n,o),void lr(this,e,n,o)}"element"===this.anchor.type&&sr(this.anchor,this.focus,n,o);const r=this.anchor.getNode();Xo(r)||t(398);const i=this.anchor.offset,s=r.getParentOrThrow(),l=r.getTextContentSize();if(Ks(r)||0===i&&(!r.canInsertTextBefore()||!s.canInsertTextBefore()&&!r.__prev)||i===l&&(!r.canInsertTextAfter()||!s.canInsertTextAfter()&&!r.__next)){if(r.isSegmented()&&0!==i&&i!==l){if(null!==qs())r.setMode("normal").setFormat(n).setStyle(o);else{const t=Go(r.getTextContent());t.setFormat(n),t.setStyle(o),r.replace(t),t.select(i,i)}return void(""!==e&&this.insertText(e))}if(""===e)return;if(0===i){const t=r.getPreviousSibling();if(Xo(t)&&t.canInsertTextAfter()&&!Ks(t))t.select();else{const t=Go();t.setFormat(n),t.setStyle(o),s.canInsertTextBefore()?r.insertBefore(t):s.insertBefore(t),t.select()}return void this.insertText(e)}if(i===l){const t=r.getNextSibling();if(Xo(t)&&t.canInsertTextBefore()&&!Ks(t))t.select(0,0);else{const t=Go();t.setFormat(n),t.setStyle(o),s.canInsertTextAfter()?r.insertAfter(t):s.insertAfter(t),t.select(0,0)}return void this.insertText(e)}const t=Go(e);return t.setFormat(n),t.setStyle(o),r.replace(t),void t.select()}if(""===e)return;const c=s.isInline()&&0===i&&!r.__prev,a=s.isInline()&&i===l&&!r.__next,u=r.getFormat()!==n||r.getStyle()!==o;if(c||a||u){if(""!==r.getTextContent()||c||a)return void lr(this,e,n,o);r.setFormat(n),r.setStyle(o)}r.spliceText(i,0,e,!0),r.isComposing()&&"text"===this.anchor.type&&this.anchor.set(this.anchor.key,this.anchor.offset-e.length,this.anchor.type)}removeText(){const t=Kr()===this;ou(this,cu(ru(this))),t&&Kr()!==this&&ol(this)}formatText(t,e=null){_r(this,t,e)}insertNodes(e){if(0===e.length)return;this.isCollapsed()||this.removeText();const n=this.anchor.getNode();if("element"===this.anchor.type&&Pi(n)&&null!==ta(n)){let o=n.isShadowRoot()?n.getFirstChild()??n.append(es()).getFirstChild():n.getFirstChild();if(n.isShadowRoot()&&null!==o&&!Pi(o)){const t=es();o.insertBefore(t),o=t}if(null!==o){o.selectStart();const n=Kr();return ur(n)||t(369),n.insertNodes(e)}}if("element"===this.anchor.type&&Bl(n)){const t=ti(e),o=t.getLastDescendant();return n.splice(this.anchor.offset,0,t.getChildren()),void(null!==o&&o.selectEnd())}let o=(this.isBackward()?this.focus:this.anchor).getNode(),r=qc(o,Sc);const i=e[e.length-1];if(Pi(r)&&"__language"in r){if("__language"in e[0])this.insertText(e[0].getTextContent());else{const t=Xr(this);r.splice(t,0,e),i.selectEnd()}return}if(!e.some(t=>(Pi(t)||Ki(t))&&!t.isInline())){Pi(r)||t(211,o.constructor.name,o.getType());const n=Xr(this);return r.splice(n,0,e),void i.selectEnd()}if(Pi(r)&&null!==ta(r)){const t=Xr(this),n=Gr(e);r.splice(t,0,n);const o=n[n.length-1];return void(void 0!==o?o.selectEnd():r.select(t,t))}if(null===r){const t=ti(e),n=t.getLastDescendant();let o=tu(this.anchor,"next");for(const e of t.getChildren())o=mu(e,o);return void(null!==n&&n.selectEnd())}if(Pi(r)&&!r.isParentRequired()&&!Bl(r.getParentOrThrow())){const t=Xr(this),n=Gr(e);r.splice(t,0,n);const o=n[n.length-1];return void(void 0!==o?o.selectEnd():r.select(t,t))}const s=ti(e),l=s.getLastDescendant(),c=s.getChildren(),a=!Pi(r)||!r.isEmpty()?this.insertParagraph():null;a&&!r.isAttached()&&(o=this.anchor.getNode(),r=qc(o,Sc));const u=c[c.length-1];let f=c[0];var d;Pi(d=f)&&Sc(d)&&!d.isEmpty()&&Pi(r)&&(!r.isEmpty()||r.canMergeWhenEmpty())&&(Pi(r)||t(211,o.constructor.name,o.getType()),r.append(...f.getChildren()),f=c[1]),f&&(null===r&&t(212,o.constructor.name,o.getType()),function(e,n){const o=n.getParentOrThrow().getLastChild();let r=n;const i=[n];for(;r!==o;)r.getNextSibling()||t(140),r=r.getNextSibling(),i.push(r);let s=e;for(const t of i)s=s.insertAfter(t)}(r,f));const h=qc(l,Sc);a&&Pi(h)&&(a.canMergeWhenEmpty()||Sc(u))&&(h.append(...a.getChildren()),a.remove()),Pi(r)&&r.isEmpty()&&r.remove(),l.selectEnd();const g=Pi(r)?r.getLastChild():null;Yi(g)&&h!==r&&g.remove()}insertParagraph(){const e=this.anchor.getNode();if("element"===this.anchor.type&&Bl(e)){const t=es();return e.splice(this.anchor.offset,0,[t]),t.select(),t}const n=Xr(this),o=qc(this.anchor.getNode(),Sc);if(null!==o&&null!==ta(o))return null;Pi(o)||t(213);const r=o.getChildAtIndex(n),i=r?[r,...r.getNextSiblings()]:[],s=o.insertNewAfter(this,!1);return s?(s.append(...i),s.selectStart(),s):null}insertLineBreak(t){const e=qi();if(this.insertNodes([e]),t){const t=e.getParentOrThrow(),n=e.getIndexWithinParent();t.select(n,n)}}extract(){const t=[...this.getNodes()],e=t.length;let n=t[0],o=t[e-1];const[r,i]=yr(this),s=this.isBackward(),[l,c]=s?[this.focus,this.anchor]:[this.anchor,this.focus],[a,u]=s?[i,r]:[r,i];if(0===e)return[];if(1===e){if(Xo(n)&&!this.isCollapsed()){const t=n.splitText(a,u),e=0===a?t[0]:t[1];return e?(l.set(e.getKey(),0,"text"),c.set(e.getKey(),e.getTextContentSize(),"text"),[e]):[]}return[n]}if(Xo(n)&&(a===n.getTextContentSize()?t.shift():0!==a&&([,n]=n.splitText(a),t[0]=n,l.set(n.getKey(),0,"text"))),Xo(o)){const e=o.getTextContent().length;0===u?t.pop():u!==e&&([o]=o.splitText(u),t[t.length-1]=o,c.set(o.getKey(),o.getTextContentSize(),"text"))}return t}modify(t,e,n){if(ei(this,t,e,n))return;const o="move"===t,r=_i(),i=Jl(Il(r));if(!i)return;const s=r._blockCursorElement,l=r._rootElement,c=this.focus.getNode();null===l||null===s||!Pi(c)||c.isInline()||c.canBeEmpty()||jl(s,r,l);const a=El(r,this.focus.key);let u=a;if("text"===this.focus.type&&(u=Xo(c)?wc(c,a,r):null),this.dirty){const t=El(r,this.anchor.key);let e=t;if("text"===this.anchor.type){const n=this.anchor.getNode();e=Xo(n)?wc(n,t,r):null}e&&u&&Ur(i,e,this.anchor.offset,u,this.focus.offset)}if("character"===n&&Xo(c)&&c.isUnmergeable()){if(e?0===this.focus.offset:this.focus.offset===c.getTextContentSize()){const t=Ia(c,e?"previous":"next").getNodeAtCaret();if(Xo(t)){if(!o){const n=t.getTextContentSize();return e?this.focus.set(t.__key,n-1,"text"):this.focus.set(t.__key,1,"text"),void(this.dirty=!0)}{const n=r.getElementByKey(t.getKey()),o=n?wc(t,n,r):null;if(o){const t=e?o.length:0;Ur(i,o,t,o,t)}}}}}if(Cr(i,t,e?"backward":"forward",n),i.rangeCount>0){const t=tc(i,r._rootElement),n=t||i.getRangeAt(0),s=this.anchor.getNode(),l=Bi(s)?s:Kl(s);if(this.applyDOMRange(n),this.dirty=!0,!o){Sr(this,e,l);(t?"backward"!==i.direction:i.anchorNode===n.startContainer&&i.anchorOffset===n.startOffset)||xr(this)}}"lineboundary"===n&&ei(this,t,e,n,"decorators")}forwardDeletion(t,e,n){if(!n&&("element"===t.type&&Pi(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(Pi(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 o=ja(tu(e,t?"previous":"next"));if(o.getTextSlices().every(t=>null===t||0===t.distance)){let t={type:"initial"};for(const e of o.iterNodeCarets("shadowRoot"))if(Aa(e))if(e.origin.isInline());else{if(e.origin.isShadowRoot()){if("merge-block"===t.type)break;if(Pi(o.anchor.origin)&&o.anchor.origin.isEmpty()){const t=au(e);ou(this,Va(t,t)),o.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(Ma(e)){if(Pi(e.origin)){if(e.origin.isInline()){if(!e.origin.isParentOf(o.anchor.origin))break}else t={block:e.origin,type:"merge-next-block"};continue}if(Ki(e.origin)){if(e.origin.isIsolated());else if(ia(e.origin).length>0){if(Pi(o.anchor.origin)&&o.anchor.origin.isEmpty()){o.anchor.origin.remove();const t=Pr();t.add(e.origin.getKey()),ol(t)}}else if("merge-next-block"===t.type&&(e.origin.isKeyboardSelectable()||!e.origin.isInline())&&Pi(o.anchor.origin)&&o.anchor.origin.isEmpty()){o.anchor.origin.remove();const t=Pr();t.add(e.origin.getKey()),ol(t)}else e.origin.remove();return}break}}if("merge-block"===t.type){const{caret:e,block:n}=t;if(ia(n).length>0)return;return e.origin.isEmpty()&&!n.isEmpty()&&e.origin.getParent()===n.getParent()?void e.origin.remove(!0):(ou(this,Va(!e.origin.isEmpty()&&n.isEmpty()?iu(Ia(n,e.direction)):o.anchor,e)),this.removeText())}for(let t=e.getNode();null!==t;){if(null!==ta(t))return;if(Pi(t)&&t.isShadowRoot())break;t=t.getParent()}}const r=this.focus;if(vr(this,t,"character"),this.isCollapsed()){if(t&&0===e.offset&&mr(this,e.getNode()))return}else{const o="text"===r.type?r.getNode():null;if(n="text"===e.type?e.getNode():null,null!==o&&o.isSegmented()){const e=r.offset,i=o.getTextContentSize();if(o.is(n)||t&&e!==i||!t&&0!==e)return void kr(o,t,e)}else if(null!==n&&n.isSegmented()){const r=e.offset,i=n.getTextContentSize();if(n.is(o)||t&&0!==r||!t&&r!==i)return void kr(n,t,r)}!function(t,e){const n=t.anchor,o=t.focus,r=n.getNode(),i=o.getNode();if(r===i&&"text"===n.type&&"text"===o.type){const t=n.offset,i=o.offset,s=t<i,l=s?t:i,c=s?i:t,a=c-1;if(l!==a){(function(t){return!(sl(t)||Tr(t))})(r.getTextContent().slice(l,c))&&(e?o.set(o.key,a,o.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()&&Bi(t.getParent())&&null===t.getPreviousSibling()&&mr(this,t),ar()}}deleteLine(t){const e=Er(this.anchor);if(null!==e&&Ki(ea(e)))return this.isCollapsed()||this.focus.set(this.anchor.key,this.anchor.offset,this.anchor.type),void this.deleteCharacter(t);if(this.isCollapsed()&&vr(this,t,"lineboundary"),this.isCollapsed())this.deleteCharacter(t);else{qc(this.anchor.getNode(),Sc)!==qc(this.focus.getNode(),Sc)?(this.focus.set(this.anchor.key,this.anchor.offset,this.anchor.type),this.deleteCharacter(t)):this.removeText()}}deleteWord(t){if(this.isCollapsed()){const e=this.anchor,n=e.getNode();if(this.forwardDeletion(e,n,t))return;vr(this,t,"word")}this.isCollapsed()?this.deleteCharacter(t):this.removeText()}isBackward(){const t=this._cachedIsBackward;if(null!==t)return t;const e=this.focus.isBefore(this.anchor);return ui()||(this._cachedIsBackward=e),e}getStartEndPoints(){return[this.anchor,this.focus]}}function dr(t){return t instanceof cr}function hr(t,e){if(dr(t)){for(const n of t.getNodes())Ro(n)&&n.setFormat(e(n.getFormat()));return}if(t.isCollapsed())return t.setFormat(e(t.format)),void Vs(null);const n=[];for(const o of t.getNodes())Xo(o)?n.push(o):Pi(o)?o.setTextFormat(e(o.getTextFormat())):Ro(o)&&o.setFormat(e(o.getFormat()));const o=n.length;if(0===o)return t.setFormat(e(t.format)),void Vs(null);const r=t.anchor,i=t.focus,s=t.isBackward(),l=s?i:r,c=s?r:i;let a=0,u=n[0],f="element"===l.type?0:l.offset;if("text"===l.type&&f===u.getTextContentSize()&&(a=1,u=n[1],f=0),null==u)return;const d=o-1;let h=n[d];const g="text"===c.type?c.offset:h.getTextContentSize();if(u.is(h)){if(f===g)return;const n=e(u.getFormat());if(Ks(u)||0===f&&g===u.getTextContentSize())u.setFormat(n);else{const t=u.splitText(f,g),e=0===f?t[0]:t[1];e.setFormat(n),"text"===l.type&&l.set(e.__key,0,"text"),"text"===c.type&&c.set(e.__key,g-f,"text")}return void(t.format=n)}0===f||Ks(u)||([,u]=u.splitText(f),f=0);const _=e(u.getFormat());u.setFormat(_);const p=e(h.getFormat());g>0&&(g===h.getTextContentSize()||Ks(h)||([h]=h.splitText(g)),h.setFormat(p));for(let t=a+1;t<d;t++){const o=n[t];o.setFormat(e(o.getFormat()))}"text"===l.type&&l.set(u.__key,f,"text"),"text"===c.type&&c.set(h.__key,g,"text"),t.format=_|p}function gr(t,e){const n=[];for(const[t,o]of Object.entries(e))"boolean"==typeof o&&n.push([t,o]);0!==n.length&&hr(t,t=>{for(const[e,o]of n)t=Ws(t,e,o?z[e]:0);return t})}function _r(t,e,n=null){const o=null===n&&ur(t)?Ws(t.format,e,null):n;hr(t,t=>Ws(t,e,o))}function pr(t){const e=t.offset;if("text"===t.type)return e;const n=t.getNode();return e===n.getChildrenSize()?n.getTextContent().length:0}function yr(t){const e=t.getStartEndPoints();if(null===e)return[0,0];const[n,o]=e;return"element"===n.type&&"element"===o.type&&n.key===o.key&&n.offset===o.offset?[0,0]:[pr(n),pr(o)]}function mr(t,e){for(let n=e;n;n=n.getParent()){if(Pi(n)){if(n.collapseAtStart(t))return!0;if(Bl(n))break}if(n.getPreviousSibling())break}return!1}function xr(t){const e=t.focus,n=t.anchor,o=n.key,r=n.offset,i=n.type;n.set(e.key,e.offset,e.type,!0),e.set(o,r,i,!0)}function Cr(t,e,n,o){t.modify(e,n,o)}function Sr(t,e,n){const o=t.getNodes(),r=o.filter(t=>Fl(t,n));if(0===r.length||r.length===o.length)return!1;const i=e?r[0]:r[r.length-1],s=Pi(i)?i:i.getParentOrThrow();return e?s.selectStart():s.selectEnd(),!0}function vr(t,e,n){if(ei(t,"extend",e,n))return;const o=_i(),r=Jl(Il(o));if(!r||"function"!=typeof r.modify)return;const i=o._blockCursorElement,s=o._rootElement,l=t.anchor,c=t.focus.getNode();null===s||null===i||!Pi(c)||c.isInline()||c.canBeEmpty()||jl(i,o,s);const a=t=>{const e=t.getNode(),n=o.getElementByKey(t.key);return null!==n&&"text"===t.type&&Xo(e)?wc(e,n,o):n},u=l.getNode(),f=a(l);if(null===f)return;const d=l.offset,h=t.isCollapsed(),g=t.focus,_=h?f:a(g);if(null===_)return;const p=g.offset;if(Ur(r,_,p,_,p),Cr(r,"move",e?"backward":"forward",n),0===r.rangeCount)return;const y=tc(r,s)||r.getRangeAt(0),m=y.startContainer,x=y.startOffset;if(h&&"character"===n&&"text"===l.type&&Xo(u)&&u.isUnmergeable()){if(d===(e?0:u.getTextContentSize())){const n=Ia(u,e?"previous":"next").getNodeAtCaret();if(Xo(n)){const o=e?n.getTextContentSize()-1:1;return t.focus.set(n.__key,o,"text"),void(t.dirty=!0)}}}if(h&&"character"===n&&"text"===l.type){const n=e?0:u.getTextContentSize(),o=m===f?x:d!==n?n:-1;if(o>=0)return void(o!==d&&(t.focus.set(l.key,o,"text"),t.dirty=!0))}const[C,S,v,T]=e?[m,x,f,d]:[f,d,m,x],k=Bi(u)?u:Kl(u);t.applyDOMRange({collapsed:!1,endContainer:v,endOffset:T,startContainer:C,startOffset:S}),t.dirty=!0,!Sr(t,e,k)&&e&&xr(t),"lineboundary"===n&&ei(t,"extend",e,n,"decorators")}const Tr=(()=>{try{const t=new RegExp("\\p{Emoji}","u"),e=t.test.bind(t);if(e("\u2764\ufe0f")&&e("#\ufe0f\u20e3")&&e("\u{1f44d}"))return e}catch(t){}return()=>!1})();function kr(t,e,n){const o=t,r=o.getTextContent().split(/(?=\s)/g),i=r.length;let s=0,l=0;for(let t=0;t<i;t++){const o=t===i-1;if(l=s,s+=r[t].length,e&&s===n||s>n||o){r.splice(t,1),o&&(l=void 0);break}}const c=r.join("").trim();""===c?o.remove():(o.setTextContent(c),o.select(l,l))}function br(e,n,o,r){let i,s=n,l=!1;if(gc(e)){let c=!1;const a=e.childNodes,u=a.length,f=r._blockCursorElement;s===u&&u>0&&(c=!0,s=u-1),void 0!==Qs(e,r)||Rc(e,r)||(l=!0);let d=a[s],h=!1;if(d===f)d=a[s+1],h=!0;else if(null!==f){const t=f.parentNode;if(e===t){n>Array.prototype.indexOf.call(t.children,f)&&s--}}if(i=il(d),Xo(i))s=Ka(i,c?"next":"previous");else{let a=il(e);if(null===a)return null;if(Pi(a)){const l=r.getElementByKey(a.getKey());null===l&&t(214);const u=kc(a,l,r);[a,s]=u.resolveChildIndex(a,l,e,n),Pi(a)||t(215),c&&s>=a.getChildrenSize()&&(s=Math.max(0,a.getChildrenSize()-1));let f=a.getChildAtIndex(s);if(Pi(f)&&function(t,e,n){const o=t.getParent();return null===n||null===o||!o.canBeEmpty()||o!==n.getNode()}(f,0,o)){const t=c?f.getLastDescendant():f.getFirstDescendant();null===t?a=f:(f=t,a=Pi(f)?f:f.getParentOrThrow()),s=0}Xo(f)?(i=f,a=null,s=Ka(f,c?"next":"previous")):f!==a&&c&&!h&&(Pi(a)||t(216),s=Math.min(a.getChildrenSize(),s+1))}else{const t=ea(a),o=null!==t?t:a,i=o.getIndexWithinParent(),l=r.getElementByKey(a.getKey());let c="after";if(null!==l&&il(e)===a){const t=kc(a,l,r);t.element!==l?c=t.resolveLeafPosition(l,e,n):0===n&&Ki(a)&&(c="before")}s="before"===c?i:i+1,a=o.getParentOrThrow()}if(Pi(a))return[or(a.__key,s,"element"),l]}}else i=il(e);return Xo(i)?[or(i.__key,Ka(i,s,"clamp"),"text"),l]:null}function Nr(t,e,n){const o=t.offset,r=t.getNode();if(0===o){const o=r.getPreviousSibling(),i=r.getParent();if(e){if((n||!e)&&null===o&&Pi(i)&&i.isInline()){const e=i.getPreviousSibling();Xo(e)&&t.set(e.__key,e.getTextContent().length,"text")}}else Pi(o)&&!n&&o.isInline()?t.set(o.__key,o.getChildrenSize(),"element"):Xo(o)&&!r.isUnmergeable()&&t.set(o.__key,o.getTextContent().length,"text")}else if(o===r.getTextContent().length){const o=r.getNextSibling(),i=r.getParent();if(e&&Pi(o)&&o.isInline())t.set(o.__key,0,"element");else if((n||e)&&null===o&&Pi(i)&&i.isInline()&&!i.canInsertTextAfter()&&i.getTextContentSize()>1){const e=i.getNextSibling();Xo(e)&&t.set(e.__key,0,"text")}}}function Er(t){const e=Ys(t.key);return null===e?null:oa(e)}function wr(t,e,n){const o=Er(t),r=Er(e);if(o===r||null!==o&&null!==r&&o.is(r))return!1;const i=n(o,r);if(null!==o)return Pi(o)?e.set(o.getKey(),i?o.getChildrenSize():0,"element"):e.set(o.getKey(),i?o.getTextContentSize():0,"text"),!0;const s=ea(r);if(null===s)return!1;const l=s.getParent();if(null===l)return!1;const c=s.getIndexWithinParent();return e.set(l.getKey(),i?c+1:c,"element"),!0}function Or(t){const e=wr(t.anchor,t.focus,(e,n)=>function(t,e,n,o){if(null!==n&&null!==o){const t=ea(n),e=ea(o);if(null!==t&&t.is(e)){for(const e of ra(t).values()){if(e===n.getKey())return!0;if(e===o.getKey())return!1}return!0}return null===t||null===e||t.isBefore(e)}if(null!==n){const t=ea(n),o=Ys(e.key);return null===t||null===o||!(!t.is(o)&&!t.isParentOf(o))||t.isBefore(o)}const r=ea(o),i=Ys(t.key);return null!==r&&null!==i&&!r.is(i)&&!r.isParentOf(i)&&i.isBefore(r)}(t.anchor,t.focus,e,n));return e&&(t.dirty=!0),e}function Mr(t,e,n,o,r,i){if(null===t||null===n||!As(r,t,n))return null;const s=br(t,e,ur(i)?i.anchor:null,r);if(null===s)return null;const l=br(n,o,ur(i)?i.focus:null,r);if(null===l)return null;const[c,a]=s,[u,f]=l;if("element"===c.type&&"element"===u.type){const e=il(t),o=il(n);if(Ki(e)&&Ki(o))return null}const d=r._slotsUsed&&wr(c,u,()=>0!==(t.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_FOLLOWING));return function(t,e){if("text"===t.type&&"text"===e.type){const n=t.isBefore(e),o=t.is(e);Nr(t,n,o),Nr(e,!n,o),o&&e.set(t.key,t.offset,t.type)}}(c,u),[c,u,a||f||d]}function Ar(t){return Pi(t)&&!t.isInline()}function Dr(t,e,n,o,r,i){const s=hi(),l=new fr(or(t,e,r),or(n,o,i),0,"");return l.dirty=!0,s._selection=l,l}function Fr(){const t=or("root",0,"element"),e=or("root",0,"element");return new fr(t,e,0,"")}function Pr(){return new cr(new Set)}function Ir(t,e){return Lr(null,t,e,null)}function Lr(t,e,n,o){const r=n._window;if(null===r)return null;const i=o||r.event,s=i?i.type:void 0,l="selectionchange"===s,c=!it&&(l||"beforeinput"===s||"compositionstart"===s||"compositionend"===s||"click"===s&&i&&3===i.detail||"drop"===s||void 0===s);let a,u,f,d;if(ur(t)&&!c)return t.clone();{if(null===e)return null;const o=nc(e,n._rootElement);if(a=o.anchorNode,u=o.focusNode,f=o.anchorOffset,d=o.focusOffset,(l||void 0===s)&&ur(t)&&!As(n,a,u))return t.clone()}const h=Mr(a,f,u,d,n,t);if(null===h)return null;const[g,_,p]=h;let y=0,m="";if(ur(t)){const e=t.anchor;if(g.key===e.key)y=t.format,m=t.style;else{const t=g.getNode();Xo(t)?(y=t.getFormat(),m=t.getStyle()):Pi(t)&&(y=t.getTextFormat(),m=t.getTextStyle())}}const x=new fr(g,_,y,m);return p&&(x.dirty=!0),x}function Kr(){return hi()._selection}function zr(){return _i()._editorState._selection}function Br(t,e,n,o=1){const r=t.anchor,i=t.focus,s=r.getNode(),l=i.getNode();if(!e.is(s)&&!e.is(l))return;const c=e.__key;if(t.isCollapsed()){const e=r.offset;if(n<=e&&o>0||n<e&&o<0){const n=Math.max(0,e+o);r.set(c,n,"element"),i.set(c,n,"element"),Rr(t)}}else{const s=t.isBackward(),l=s?i:r,a=l.getNode(),u=s?r:i,f=u.getNode();if(e.is(a)){const t=l.offset;(n<=t&&o>0||n<t&&o<0)&&l.set(c,Math.max(0,t+o),"element")}if(e.is(f)){const t=u.offset;(n<=t&&o>0||n<t&&o<0)&&u.set(c,Math.max(0,t+o),"element")}}Rr(t)}function Rr(t){const e=t.anchor,n=e.offset,o=t.focus,r=o.offset,i=e.getNode(),s=o.getNode();if(t.isCollapsed()){if(!Pi(i))return;const t=i.getChildrenSize(),r=n>=t,s=r?i.getChildAtIndex(t-1):i.getChildAtIndex(n);if(Xo(s)){let t=0;r&&(t=s.getTextContentSize()),e.set(s.__key,t,"text"),o.set(s.__key,t,"text")}return}if(Pi(i)){const t=i.getChildrenSize(),o=n>=t,r=o?i.getChildAtIndex(t-1):i.getChildAtIndex(n);if(Xo(r)){let t=0;o&&(t=r.getTextContentSize()),e.set(r.__key,t,"text")}}if(Pi(s)){const t=s.getChildrenSize(),e=r>=t,n=e?s.getChildAtIndex(t-1):s.getChildAtIndex(r);if(Xo(n)){let t=0;e&&(t=n.getTextContentSize()),o.set(n.__key,t,"text")}}}function Wr(t,e,n,o,r){let i=null,s=0,l=null;null!==o?(i=o.__key,Xo(o)?(s=o.getTextContentSize(),l="text"):Pi(o)&&(s=o.getChildrenSize(),l="element")):null!==r&&(i=r.__key,Xo(r)?l="text":Pi(r)&&(l="element")),null!==i&&null!==l?t.set(i,s,l):(s=e.getIndexWithinParent(),-1===s&&(s=n.getChildrenSize()),t.set(n.__key,s,"element"))}function $r(t,e,n,o,r){"text"===t.type?t.set(n,t.offset+(e?0:r),"text"):t.offset>o.getIndexWithinParent()&&t.set(t.key,t.offset-1,"element")}function Ur(t,e,n,o,r){try{t.setBaseAndExtent(e,n,o,r)}catch(t){}}function Hr(t,e,n){const o=El(t,e.getKey());if(Pi(e)){const r=kc(e,o,t);return[r.element,n+r.getFirstChildOffset()]}return[o,n]}function jr(t,e,n,o,r,s){const l=s.getRootNode(),c=Bs(l)||ql(l)?cc(l):null;if(r.has(vo)&&c!==s||null!==c&&Os(c,c))return;const a=nc(o,s);let u;if(!ur(e))return void(null!==t&&As(n,a.anchorNode,a.focusNode)&&o.removeAllRanges());const f=e.anchor,d=e.focus,h=f.getNode(),g=d.getNode(),[_,p]=Hr(n,h,f.offset),[y,m]=Hr(n,g,d.offset),x=e.format,C=e.style,S=e.isCollapsed();let v=_,T=y,k=!1;if("text"===f.type?(v=Xo(h)?wc(h,_,n):null,k=h.getFormat()!==x||h.getStyle()!==C):ur(t)&&"text"===t.anchor.type&&(k=!0),"text"===d.type&&(T=Xo(g)?wc(g,y,n):null),null!==v&&null!==T){if(S&&(null===t||k||ur(t)&&(t.format!==x||t.style!==C))&&function(t,e,n,o,r,i){t._inputState.collapsedSelectionFormat={format:e,key:r,offset:o,style:n,timeStamp:i}}(n,x,C,p,f.key,performance.now()),("Range"!==o.type||!S)&&a.anchorOffset===p&&a.focusOffset===m&&a.anchorNode===v&&a.focusNode===T){if(null===c||!s.contains(c)){const t=null!==c?Fs(c):null;null!==t&&t!==n||r.has(No)||s.focus({preventScroll:!0})}if("element"!==f.type)return}if(Ur(o,v,p,T,m),i&&e.isCollapsed()&&null!==s&&!r.has(No)){const t=lc(s);if(null===t||!s.contains(t)){const t=cc(s.ownerDocument),e=null!==t?Fs(t):null;null!==e&&e!==n||s.focus({preventScroll:!0})}}if(!r.has(ko)&&e.isCollapsed()&&null!==s&&s===lc(s)){const t=ur(e)&&"element"===e.anchor.type?v.childNodes[p]||null:(void 0===u&&(u=ec(o,s)),u);if(null!==t){let e;if(zs(t)){const n=t.ownerDocument.createRange();n.selectNode(t),e=n.getBoundingClientRect()}else e=t.getBoundingClientRect();!function(t,e,n){const o=Ol(n),r=Pl(o);if(null===o||null===r)return;const i=n.getBoundingClientRect();if(e.bottom<i.top)return;let{top:s,bottom:l}=e,c=0,a=0,u=n;for(;null!==u;){const e=u===o.body;if(e){const e=r.visualViewport;if(e){const t=e.offsetTop;c=t,a=t+e.height}else c=0,a=Il(t).innerHeight;const n=r.getComputedStyle(o.documentElement),i=parseFloat(n.scrollPaddingTop),s=parseFloat(n.scrollPaddingBottom);isFinite(i)&&(c+=i),isFinite(s)&&(a-=s)}else{const t=u===n?i:u.getBoundingClientRect();c=t.top,a=t.bottom}let f=0;if(s<c?f=-(c-s):l>a&&(f=l-a),0!==f)if(e)r.scrollBy(0,f);else{const t=u.scrollTop;u.scrollTop+=f;const e=u.scrollTop-t;s-=e,l-=e}if(e)break;u=wl(u)}}(n,e,s)}}!function(t){t._inputState.isSelectionChangeFromDOMUpdate=!0}(n)}}function Jr(t){let e=Kr()||zr();null===e&&(e=nl().selectEnd()),e.insertNodes(t)}function Vr(t,e){for(const n of t.split(/(\r?\n|\t)/))"\n"===n||"\r\n"===n?e.linebreak():"\t"===n?e.tab():""!==n&&e.text(n)}function qr(t){const e=[];return Vr(t,{linebreak:()=>e.push(qi()),tab:()=>e.push(tr()),text:t=>e.push(Go(t))}),e}function Yr(){const t=Kr();return null===t?"":t.getTextContent()}function Gr(t){const e=[];for(const n of t)Yi(n)||(!Pi(n)&&!Ki(n)||n.isInline()?e.push(n):Pi(n)&&e.push(...Gr(n.getChildren())));return e}function Xr(e){let n=e;e.isCollapsed()||n.removeText();const o=Kr();ur(o)&&(n=o),ur(n)||t(161);const r=n.anchor;let i=r.getNode(),s=r.offset;for(;!Sc(i)&&null===ta(i);){const t=i;if([i,s]=Qr(i,s),t.is(i))break}return s}function Qr(t,e){const n=t.getParent();if(!n){const t=es();return nl().append(t),t.select(),[nl(),0]}if(Xo(t)){const o=t.splitText(e);if(0===o.length)return[n,t.getIndexWithinParent()];const r=0===e?0:1;return[n,o[0].getIndexWithinParent()+r]}if(!Pi(t)||0===e)return[n,t.getIndexWithinParent()];const o=t.getChildAtIndex(e);if(o){const n=new fr(or(t.__key,e,"element"),or(t.__key,e,"element"),0,""),r=t.insertNewAfter(n);r&&r.append(o,...o.getNextSiblings())}return[n,t.getIndexWithinParent()+1]}function Zr(t){return Yi(t)||Ll(t)||Xo(t)||t.isParentRequired()}function ti(t){const e=es();let n=null;for(let o=0;o<t.length;o++){const r=t[o];if(Zr(r)){if(null===n){n=r.createParentElementNode(),e.append(n);const i=t[o+1];if(Yi(r)&&(void 0===i||!Zr(i)))continue}n.append(r)}else e.append(r),n=null}return e}function ei(t,e,n,o,r="decorators-and-blocks"){if("move"===e&&"character"===o&&!t.isCollapsed()){const[e,o]=n===t.isBackward()?[t.focus,t.anchor]:[t.anchor,t.focus];return o.set(e.key,e.offset,e.type),!0}const i=tu(t.focus,n?"previous":"next"),s="lineboundary"===o,l="move"===e;let c=i,a="decorators-and-blocks"===r;if(!uu(c)){for(const t of c){a=!1;const{origin:e}=t;if(!Ki(e)||e.isIsolated()||(c=t,!s||!e.isInline()))break}if(a)for(const t of ja(i).iterNodeCarets("extend"===e?"shadowRoot":"root")){if(Aa(t))t.origin.isInline()||(c=t);else{if(Pi(t.origin))continue;Ki(t.origin)&&!t.origin.isInline()&&(c=t)}break}}if(c===i)return!1;if(l&&!s&&Ki(c.origin)&&c.origin.isKeyboardSelectable()){const t=Pr();return t.add(c.origin.getKey()),ol(t),!0}return c=au(c),l&&eu(t.anchor,c),eu(t.focus,c),a||!s}let ni=null,oi=null,ri=!1,ii=!1,si=!1;const li=new Set;let ci=0;const ai={characterData:!0,childList:!0,subtree:!0};function ui(){return ri||null!==ni&&ni._readOnly}function fi(){ri&&t(13)}function di(){ci>99&&t(14)}function hi(){return null===ni&&t(195,yi()),ni}function gi(t){null!==hi()&&null===oi&&(oi=t),oi!==t&&e(378)}function _i(){return null===oi&&t(337,yi()),oi}function pi(){_i()._dirtyType=2}function yi(){let t=0;const e=new Set,n=Cs.version;if("undefined"!=typeof window)for(const o of Xl(document)){const r=Ps(o);if(Ds(r))t++;else if(r){let t=String(r.constructor.version||"<0.17.1");t===n&&(t+=" (separately built, likely a bundler configuration issue)"),e.add(t)}}let o=` Detected on the page: ${t} compatible editor(s) with version ${n}`;return e.size&&(o+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),o}function mi(){return oi}function xi(t,e,n){const o=e.__type,r=Ns(t,o);let i=n.get(o);void 0===i&&(i=Array.from(r.transforms),n.set(o,i));const s=i.length;for(let t=0;t<s&&(i[t](e),e.isAttached());t++);}function Ci(t,e){return void 0!==t&&t.__key!==e&&t.isAttached()}function Si(t,e){if(!e)return;const n=t._updateTags;let o=e;Array.isArray(e)||(o=[e]);for(const t of o)n.add(t)}function vi(t){return Ti(t,_i()._nodes)}function Ti(e,n){const o=e.type,r=n.get(o);void 0===r&&t(17,o);const i=r.klass;e.type!==i.getType()&&t(18,i.name);const s=i.importJSON(e),l=e.children;if(Pi(s)&&Array.isArray(l))for(let t=0;t<l.length;t++){const e=Ti(l[t],n);s.append(e)}const c=e.$slots;if(c){Qc(s)||t(379,i.name);for(const t in c){pa(s,t,Ti(c[t],n))}}return s}function ki(t,e,n){const o=ni,r=ri,i=oi;ni=e,ri=!0,oi=t;try{return n()}finally{ni=o,ri=r,oi=i}}function bi(t,e){const n=si;si=!0;try{!function(t,e){const n=t._pendingEditorState,o=t._rootElement,r=t._headless||null===o;if(null===n)return void(!t._updating&&t._deferred.length>0&&wi(t,t._deferred));const i=t._editorState,s=i._selection,l=n._selection,c=0!==t._dirtyType,a=ni,u=ri,f=oi,d=t._updating,h=t._observer;let g=null;if(t._pendingEditorState=null,t._editorState=n,!r&&c&&null!==h){oi=t,ni=n,ri=!1,t._updating=!0;try{const e=t._dirtyType,o=t._dirtyElements,r=t._dirtyLeaves;h.disconnect(),g=De(i,n,t,e,o,r)}catch(e){if(e instanceof Error&&t._onError(e),ii)throw e;return gs(t,null,o,n),gt(t),t._dirtyType=2,ii=!0,bi(t,i),void(ii=!1)}finally{h.observe(o,ai),t._updating=d,ni=a,ri=u,oi=f}}n._readOnly||(n._readOnly=!0);const _=t._dirtyLeaves,p=t._dirtyElements,y=t._normalizedNodes,m=t._updateTags;c&&(t._dirtyType=0,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 o=t._pendingDecorators||n;const r=e._nodeMap;let i;for(i in o)r.has(i)||(o===n&&(o=tl(t)),delete o[i])}(t,n);const x=r?null:Jl(Il(t));if(t._editable&&null!==x&&(c||null===l||l.dirty||!l.is(s))&&null!==o&&!m.has(bo)){oi=t,ni=n;try{if(null!==h&&h.disconnect(),c||null===l||l.dirty){const e=t._blockCursorElement;null!==e&&jl(e,t,o),jr(s,l,t,x,m,o)}!function(t,e,n){let o=t._blockCursorElement;if(ur(n)&&n.isCollapsed()&&"element"===n.anchor.type&&e.contains(lc(e))){const r=n.anchor,i=r.getNode(),s=r.offset;let l=!1,c=null;if(s===i.getChildrenSize()){Hl(i.getChildAtIndex(s-1))&&(l=!0)}else{const e=i.getChildAtIndex(s);if(null!==e&&Hl(e)){const n=e.getPreviousSibling();(null===n||Hl(n))&&(l=!0,c=t.getElementByKey(e.__key))}}if(l){const n=kc(i,t.getElementByKey(i.__key),t).element;return null===o&&(t._blockCursorElement=o=function(t){const e=t.theme,n=Zl().createElement("div");n.contentEditable="false",n.setAttribute("data-lexical-cursor","true");let o=e.blockCursor;if(void 0!==o){if("string"==typeof o){const t=ku(o);o=e.blockCursor=t}void 0!==o&&n.classList.add(...o)}return n}(t._config)),e.style.caretColor="transparent",void(null===c?n.appendChild(o):n.insertBefore(o,c))}}null!==o&&jl(o,t,e)}(t,o,l)}finally{null!==h&&h.observe(o,ai),oi=f,ni=a}}null!==g&&function(t,e,n,o,r){const i=Array.from(t._listeners.mutation),s=i.length;for(let t=0;t<s;t++){const[s,l]=i[t];for(const t of l){const i=e.get(t);void 0!==i&&s(i,{dirtyLeaves:o,prevEditorState:r,updateTags:n})}}}(t,g,m,_,i);ur(l)||null===l||null!==s&&s.is(l)||t.dispatchCommand(Ie);const C=t._pendingDecorators;null!==C&&(t._decorators=C,t._pendingDecorators=null,Ni("decorator",t,!0,C));if(function(t,e,n){const o=el(e),r=el(n);o!==r&&Ni("textcontent",t,!0,r)}(t,e||i,n),Ni("update",t,!0,{dirtyElements:p,dirtyLeaves:_,editorState:n,mutatedNodes:g,normalizedNodes:y,prevEditorState:e||i,tags:m}),!d){wi(t,t._deferred)}!function(t){const e=t._updates;if(0===e.length)return void(t._cascadeCount=0);if(function(t){if(li.has(t))return;li.add(t),setTimeout(()=>{li.delete(t),t._cascadeCount=0},0)}(t),t._cascadeCount++>99)return t._updates=[],t._cascadeCount=0,void t._onWarn(new Error(`One or more update listeners are endlessly enqueueing more updates. May have encountered infinite recursion caused by update listeners that trigger additional updates without a stop condition. Editor namespace: ${t._config.namespace}`));const n=e.shift();if(n){const[e,o]=n;Mi(t,e,o)}}(t)}(t,e)}finally{si=n}}function Ni(t,e,n,...o){const r=e._updating;e._updating=n;try{const n=e._listeners[t],r=Array.from(n);for(const[t,e]of r){e&&e();const r=t(...o);n.has(t)?n.set(t,r):r&&r()}}finally{e._updating=r}}function Ei(t,e,n,o){const r=ll(t);let i;if(!si)for(let t=0;t<r.length;t++)r[t]._updating||(r[t]._cascadeCount=0);for(let t=4;t>=0;t--)for(let s=0;s<r.length;s++){const l=r[s];if(s>0&&l._updating){i=l;break}const c=l._commands.get(e);if(void 0!==c){const e=c[t];if(e.size>0){let t=!1;if(Ai(l,()=>{for(const r of e)if(r(n,o))return void(t=!0)}),t)return t}}}return i&&i.update(()=>{Ei(i,e,n,o)}),!1}function wi(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}}}function Oi(e,n){const o=e._updates;let r=n||!1;for(;0!==o.length;){const n=o.shift();if(n){const[o,i]=n,s=e._pendingEditorState;let l;void 0!==i&&(l=i.onUpdate,i.skipTransforms&&(r=!0),i.discrete&&(null===s&&t(191),s._flushSync=!0),l&&e._deferred.push(l),Si(e,i.tag)),null==s?Mi(e,o,i):o()}}return r}function Mi(e,n,o){const r=e._updateTags;let i,s=!1,l=!1;void 0!==o&&(i=o.onUpdate,Si(e,o.tag),s=o.skipTransforms||!1,l=o.discrete||!1),i&&e._deferred.push(i);const c=e._editorState;let a=e._pendingEditorState,u=!1;(null===a||a._readOnly)&&(a=e._pendingEditorState=Ri(a||c),u=!0),a._flushSync=l;const f=ni,d=ri,h=oi,g=e._updating;ni=a,ri=!1,e._updating=!0,oi=e;const _=e._headless||null===e.getRootElement();vs(null);try{u&&(_?null!==c._selection&&(a._selection=c._selection.clone()):a._selection=function(t,e){const n=t.getEditorState()._selection,o=Jl(Il(t));return ur(n)||null==n?Lr(n,o,t,e):n.clone()}(e,o&&o.event||null));const r=e._compositionKey;n(),s=Oi(e,s),function(t,e){const n=e.getEditorState()._selection,o=t._selection;if(ur(o)){const t=o.anchor,e=o.focus;let r;if("text"===t.type&&(r=t.getNode(),r.selectionTransform(n,o)),"text"===e.type){const t=e.getNode();r!==t&&t.selectionTransform(n,o)}}}(a,e),0!==e._dirtyType&&(s?function(t,e){const n=e._dirtyLeaves,o=t._nodeMap;for(const t of n){const e=o.get(t);Xo(e)&&e.isAttached()&&e.isSimpleText()&&!e.isUnmergeable()&&Pt(e)}}(a,e):function(t,e){const n=e._dirtyLeaves,o=e._dirtyElements,r=t._nodeMap,i=qs(),s=new Map;let l=n,c=l.size,a=o,u=a.size;for(;c>0||u>0;){if(c>0){e._dirtyLeaves=new Set;for(const t of l){const o=r.get(t);Xo(o)&&o.isAttached()&&o.isSimpleText()&&!o.isUnmergeable()&&Pt(o),void 0!==o&&Ci(o,i)&&xi(e,o,s),n.add(t)}if(l=e._dirtyLeaves,c=l.size,c>0){ci++;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(o.set(n,l),!l)continue;const c=r.get(n);void 0!==c&&Ci(c,i)&&xi(e,c,s)}l=e._dirtyLeaves,c=l.size,a=e._dirtyElements,u=a.size,ci++}e._dirtyLeaves=n,e._dirtyElements=o}(a,e),Oi(e),function(t,e,n,o){const r=t._nodeMap,i=e._nodeMap,s=[];for(const[t]of o){const e=i.get(t);void 0!==e&&(e.isAttached()||(Pi(e)&&rt(e,t,r,i,s,o),r.has(t)||o.delete(t),s.push(t)))}for(const t of n){const e=i.get(t);void 0===e||e.isAttached()||(Qc(e)&&null!==e.__slots&&rt(e,t,r,i,s,n),r.has(t)||n.delete(t),s.push(t))}for(const t of s)i.delete(t);const l=_i(),c=l._compositionKey;null===c||i.has(c)||(l._compositionKey=null)}(c,a,e._dirtyLeaves,e._dirtyElements));r!==e._compositionKey&&(a._flushSync=!0);const i=a._selection;if(ur(i)){e._slotsUsed&&Or(i);const n=a._nodeMap,o=i.anchor.key,r=i.focus.key;void 0!==n.get(o)&&void 0!==n.get(r)||t(19)}else dr(i)&&0===i._nodes.size&&(a._selection=null)}catch(t){return t instanceof Error&&e._onError(t),e._pendingEditorState=c,e._dirtyType=2,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),void bi(e)}finally{ni=f,ri=d,oi=h,e._updating=g,ci=0}const p=0!==e._dirtyType||e._deferred.length>0||function(t,e){const n=e.getEditorState()._selection,o=t._selection;if(null!==o){if(o.dirty||!o.is(n))return!0}else if(null!==n)return!0;return!1}(a,e);p?a._flushSync?(a._flushSync=!1,bi(e)):u&&ws(()=>{bi(e)}):(a._flushSync=!1,u&&(r.clear(),e._deferred=[],e._pendingEditorState=null))}function Ai(t,e,n){oi===t&&void 0===n?ui()?Mi(t,e,n):e():Mi(t,e,n)}function Di(t){if(Bl(t)){let e=null;for(const n of t.getChildren())e=n.isInline()?(e||n.replace(n.createParentElementNode())).append(n):null}}class Fi extends _o{__first;__last;__size;__format;__style;__indent;__dir;__textFormat;__textStyle;__slotHost;__slots;$config(){return this.config(Symbol.for("ElementNode"),{$transform:Di,extends:_o})}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="",this.__slotHost=null,this.__slots=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__first=e.__first,this.__last=e.__last,this.__size=e.__size,this.__slotHost=e.__slotHost,null!==this.__slotHost&&null!==this.__parent&&t(384,this.__key,String(this.__slotHost),String(this.__parent)),this.__slots=e.__slots),this.__indent=e.__indent,this.__format=e.__format,this.__style=e.__style,this.__dir=e.__dir,this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}getFormat(){return this.getLatest().__format}getFormatType(){const t=this.getFormat();return W[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()&&0===ia(this).length}isDirty(){const t=_i()._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=[];for(const e of ia(this)){const n=sa(this,e);Pi(n)&&t.push(...n.getAllTextNodes())}let e=this.getFirstChild();for(;null!==e;){if(Xo(e)&&t.push(e),Pi(e)){const n=e.getAllTextNodes();t.push(...n)}e=e.getNextSibling()}return t}getFirstDescendant(){let t=this.getFirstChild();for(;Pi(t);){const e=t.getFirstChild();if(null===e)break;t=e}return t}getLastDescendant(){let t=this.getLastChild();for(;Pi(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 Pi(t)&&t.getLastDescendant()||t||null}const o=e[t];return Pi(o)&&o.getFirstDescendant()||o||null}getFirstChild(){const t=this.getLatest().__first;return null===t?null:Ys(t)}getFirstChildOrThrow(){const e=this.getFirstChild();return null===e&&t(45,this.__key),e}getLastChild(){const t=this.getLatest().__last;return null===t?null:Ys(t)}getLastChildOrThrow(){const e=this.getLastChild();return null===e&&t(96,this.__key),e}getChildAtIndex(t){const e=this.getChildrenSize();let n,o;if(t<e/2){for(n=this.getFirstChild(),o=0;null!==n&&o<=t;){if(o===t)return n;n=n.getNextSibling(),o++}return null}for(n=this.getLastChild(),o=e-1;null!==n&&o>=t;){if(o===t)return n;n=n.getPreviousSibling(),o--}return null}getTextContent(){let t=ha(this);const e=this.getChildren(),n=e.length;for(let o=0;o<n;o++){const r=e[o];t+=r.getTextContent(),Pi(r)&&o!==n-1&&!r.isInline()&&(t+=D)}return t}getTextContentSize(){let t=function(t){let e=0;for(const n of ia(t)){const o=sa(t,n);null!==o&&(e+=o.getTextContentSize())}return e}(this);const e=this.getChildren(),n=e.length;for(let o=0;o<n;o++){const r=e[o];t+=r.getTextContentSize(),Pi(r)&&o!==n-1&&!r.isInline()&&(t+=2)}return t}getDirection(){return this.getLatest().__dir}getTextFormat(){return this.getLatest().__textFormat}hasFormat(t){if(""!==t){const e=R[t];return 0!==(this.getFormat()&e)}return!1}hasTextFormat(t){const e=z[t];return 0!==(this.getTextFormat()&e)}getFormatFlags(t,e){return Ws(this.getLatest().__textFormat,t,e)}getTextStyle(){return this.getLatest().__textStyle}select(t,e){fi();const n=Kr();let o=t,r=e;const i=this.getChildrenSize();if(!this.canBeEmpty())if(0===t&&0===e){const t=this.getFirstChild();if(Xo(t)||Pi(t))return t.select(0,0)}else if(!(void 0!==t&&t!==i||void 0!==e&&e!==i)){const t=this.getLastChild();if(Xo(t)||Pi(t))return t.select()}void 0===o&&(o=i),void 0===r&&(r=i);const s=this.__key;return ur(n)?(n.anchor.set(s,o,"element"),n.focus.set(s,r,"element"),n.dirty=!0,n):Dr(s,o,s,r,"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&&R[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,o){ho(this)&&t(324,this.__key,this.__type);const r=this.getChildrenSize(),i=this.getWritable();e+n<=r||t(226,String(e),String(n),String(r));for(const t of o);const s=i.__key,l=[],c=[],a=this.getChildAtIndex(e+n);let u=null,f=r-n+o.length;if(0!==e)if(e===r)u=this.getLastChild();else{const t=this.getChildAtIndex(e);null!==t&&(u=t.getPreviousSibling())}if(n>0){let e=null===u?this.getFirstChild():u.getNextSibling();for(let o=0;o<n;o++){null===e&&t(100);const n=e.getNextSibling(),o=e.__key;Hs(e.getWritable()),c.push(o),e=n}}let d=u;for(const e of o){null!==d&&e.is(d)&&(u=d=d.getPreviousSibling());const n=e.getWritable();n.__parent===s&&f--,Hs(n);const o=e.__key;if(null===d)i.__first=o,n.__prev=null;else{const t=d.getWritable();t.__next=o,n.__prev=t.__key}e.__key===s&&t(76),n.__parent=s,l.push(o),d=e}if(e+n===r){if(null!==d){d.getWritable().__next=null,i.__last=d.__key}}else if(null!==a){const t=a.getWritable();if(null!==d){const e=d.getWritable();t.__prev=d.__key,e.__next=a.__key}else t.__prev=null}if(i.__size=f,c.length){const t=Kr();if(ur(t)){const e=new Set(c),n=new Set(l),{anchor:o,focus:r}=t;Ii(o,e,n)&&Wr(o,o.getNode(),this,u,a),Ii(r,e,n)&&Wr(r,r.getNode(),this,u,a),0!==f||this.canBeEmpty()||Bl(this)||this.remove()}}return i}getDOMSlot(t){return new G(t)}exportDOM(t){const{element:e}=super.exportDOM(t);if(gc(e)){const t=this.getIndent();t>0&&(e.style.paddingInlineStart=40*t+"px",e.setAttribute("data-lexical-indent",String(t)));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&&""===n||Bl(this)||this.getChildren().some(Xo)||(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=kc(this,t,e);let o=n.getFirstChild();for(let t=this.getFirstChild();t;t=t.getNextSibling()){const r=e.getElementByKey(t.getKey());null!==r&&(null==o?(n.insertChild(r),o=r):o!==r&&n.replaceChild(r,o),o=o.nextSibling)}}}function Pi(t){return t instanceof Fi}function Ii(t,e,n){let o=t.getNode();for(;o;){const t=o.__key;if(e.has(t)&&!n.has(t))return!0;o=o.getParent()}return!1}class Li extends _o{__slotHost;__slots;constructor(t){super(t),this.__slotHost=null,this.__slots=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__slotHost=e.__slotHost,null!==this.__slotHost&&null!==this.__parent&&t(383,this.__key,String(this.__slotHost),String(this.__parent)),this.__slots=e.__slots)}decorate(t,e){return null}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function Ki(t){return t instanceof Li}class zi extends Fi{__cachedText;$config(){return this.config("root",{extends:Fi})}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){t(51)}getTextContent(){const t=this.__cachedText;return null===t||!ui()&&0!==_i()._dirtyType?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,o){for(const e of o)Pi(e)||Ki(e)||t(282);return super.splice(e,n,o)}static importJSON(t){return nl().updateFromJSON(t)}collapseAtStart(){return!0}}function Bi(t){return t instanceof zi}function Ri(t){return new Hi(nt(t._nodeMap),null,t._slotsUsed)}function Wi(){return new Hi(new Map([["root",new zi]]),null,!1)}function $i(e){const n=e.exportJSON(),o=e.constructor;if(n.type!==o.getType()&&t(130,o.name),Pi(e)){const r=n.children;Array.isArray(r)||t(59,o.name);const i=e.getChildren();for(let t=0;t<i.length;t++){const e=$i(i[t]);r.push(e)}}const r=ia(e);if(r.length>0){const i={};for(const n of r){const r=sa(e,n);null===r&&t(366,o.name,n),i[n]=$i(r)}n.$slots=i}return n}function Ui(t){return t instanceof Hi}class Hi{_nodeMap;_selection;_flushSync;_readOnly;_parsed;_slotsUsed;constructor(t,e=null,n=!1){this._nodeMap=t,this._selection=e||null,this._flushSync=!1,this._readOnly=!1,this._parsed=!1,this._slotsUsed=n}isEmpty(){return 1===this._nodeMap.size&&null===this._selection}read(t,e){return ki(e&&e.editor||null,this,t)}clone(t){const e=new Hi(this._nodeMap,void 0===t?this._selection:t,this._slotsUsed);return e._readOnly=!0,e}toJSON(){return ki(null,this,()=>({root:$i(nl())}))}}class ji extends Fi{$config(){return this.config("artificial",{extends:Fi})}createDOM(t){return Zl().createElement("div")}}class Ji extends _o{$config(){return this.config("linebreak",{importDOM:{br:t=>Gi(t)||Xi(t)?null:{conversion:Vi,priority:0}}})}getTextContent(){return"\n"}createDOM(){return Zl().createElement("br")}updateDOM(){return!1}isInline(){return!0}}function Vi(t){return{node:qi()}}function qi(){return Wl(new Ji)}function Yi(t){return t instanceof Ji}function Gi(t){const e=t.parentElement;if(null!==e&&Cc(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&Qi(n)){const n=e.lastChild;if(n===t||n.previousSibling===t&&Qi(n))return!0}}return!1}function Xi(t){const e=t.parentElement;if(null!==e&&Cc(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&Qi(n))return!1;const o=e.lastChild;if(o===t||o.previousSibling===t&&Qi(o))return!0}return!1}function Qi(t){return zs(t)&&/^( |\t|\r?\n)+$/.test(t.textContent||"")}class Zi extends Fi{$config(){return this.config("paragraph",{extends:Fi,importDOM:{p:()=>({conversion:ts,priority:0})}})}createDOM(t){const e=Zl().createElement("p"),n=Cl(t.theme,"paragraph");if(void 0!==n){e.classList.add(...n)}return e}updateDOM(t,e,n){return!1}exportDOM(t){const{element:e}=super.exportDOM(t);if(gc(e)){this.isEmpty()&&e.append(Zl().createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t)}return{element:e}}exportJSON(){const t=super.exportJSON();if(void 0===t.textFormat||void 0===t.textStyle){const e=this.getChildren().find(Xo);e?(t.textFormat=e.getFormat(),t.textStyle=e.getStyle()):(t.textFormat=this.getTextFormat(),t.textStyle=this.getTextStyle())}return t}insertNewAfter(t,e){const n=es();n.setTextFormat(t.format),n.setTextStyle(t.style);const o=this.getDirection();return n.setDirection(o),n.setFormat(this.getFormatType()),n.setStyle(this.getStyle()),this.insertAfter(n,e),n}collapseAtStart(){const t=this.getChildren();if(0===t.length||Xo(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 ts(t){const e=es();if(Lc(e,t),Pc(t,e),""===e.getFormatType()){const n=t.getAttribute("align");n&&n&&n in R&&e.setFormat(n)}return Ic(e,t),{node:e}}function es(){return Wl(new Zi)}function ns(t){return t instanceof Zi}function os(t){console.warn(t)}const rs=0,is=1,ss=2,ls=3,cs=4,as=-8,us=-7,fs=-6,ds=-5,hs=-4;function gs(t,e,n,o,r){const i=t._keyToDOMMap;i.clear(),t._editorState=Wi(),t._pendingEditorState=o,t._compositionKey=null,t._dirtyType=0,t._cloneNotNeeded.clear(),t._dirtyLeaves=new Set,t._dirtyElements.clear(),t._normalizedNodes=new Set,r&&r.preserveUpdateQueue||(t._updateTags=new Set,t._updates=[],t._cascadeCount=0),t._blockCursorElement=null,null!==t._inputState.handledSelectionCommandTimeoutId&&clearTimeout(t._inputState.handledSelectionCommandTimeoutId),t._inputState={collapsedSelectionFormat:{format:0,key:"root",offset:0,style:"",timeStamp:0},compositionEndData:"",compositionPhase:"idle",hadOrphanedCompositionEvents:!1,handledSelectionCommandTimeoutId:null,isInsertLineBreak:!1,isInsertTextAfterHandledSelectionCommand:!1,isSelectionChangeFromDOMUpdate:!1,isSelectionChangeFromMouseDown:!1,lastBeforeInputInsertTextTimeStamp:0,lastKeyCode:null,lastKeyDownTimeStamp:0,postDeleteSelectionToRestore:null,unprocessedBeforeInputData:null};const s=t._observer;null!==s&&(s.disconnect(),t._observer=null),null!==e&&(e.textContent="",function(t,e){const n=`__lexicalKey_${e._key}`;delete t[n]}(e,t)),null!==n&&(n.textContent="",i.set("root",n),Xs(n,t,"root"))}function _s(t){const e=new Set,n=new Set;for(const{klass:o,ownNodeConfig:r}of jc(t)){const t=o.transform;if(!n.has(t)){n.add(t);const r=o.transform();r&&e.add(r)}if(r){const t=r.$transform;t&&e.add(t)}}return e}const ps={$createDOM:(t,e)=>t.createDOM(e._config,e),$decorateDOM:(t,e,n,o)=>{},$exportDOM:(t,e)=>{const n=Es(e,t.getType());return n&&void 0!==n.exportDOM?n.exportDOM(e,t):t.exportDOM(e)},$extractWithChild:(t,e,n,o,r)=>Pi(t)&&t.extractWithChild(e,n,o),$getDOMSlot:(t,e,n)=>t.getDOMSlot(e),$getSlotTargetElement:(t,e,n,o)=>null,$shouldExclude:(t,e,n)=>Pi(t)&&t.excludeFromCopy("html"),$shouldInclude:(t,e,n)=>!e||t.isSelected(e),$updateDOM:(t,e,n,o)=>t.updateDOM(e,n,o._config)};function ys(e){const n=e||{},o=mi(),r=n.theme||{},i=void 0===e?o:n.parentEditor||null,s=n.disableEvents||!1,l=Wi(),c=n.namespace||(null!==i?i._config.namespace:cl()),a=n.editorState,u=[zi,Wo,Ji,Zo,Zi,ji,...n.nodes||[]],{onError:f,onWarn:d,html:h}=n,g=void 0===n.editable||n.editable;let _;if(void 0===e&&null!==o)_=o._nodes;else{_=new Map;for(let e=0;e<u.length;e++){let o=u[e],r=null,i=null;if(o&&"object"==typeof o){const t=o;o=t.replace,r=t.with,i=t.withKlass||null}if("function"!=typeof o||!o.prototype||!(o===_o||o.prototype instanceof _o)){let r="<unknown>";try{r=JSON.parse(Z)}catch(t){}t(365,String(e-u.length+(n.nodes?n.nodes.length:0)),"function"==typeof o?`${o.name}${"function"==typeof o.getType?` (type ${String(o.getType())})`:""}`:String(o),String(r))}Hc(o);const s=o.getType(),l=_s(o);_.set(s,{exportDOM:h&&h.export?h.export.get(o):void 0,klass:o,replace:r,replaceWithKlass:i,sharedNodeState:vt(u[e]),transforms:l})}}const p=new Cs(l,i,_,{disableEvents:s,dom:{...ps,...e&&e.dom},namespace:c,theme:r},f||console.error,d||os,function(t,e){const n=new Map,o=new Set,r=t=>{Object.keys(t).forEach(e=>{let o=n.get(e);void 0===o&&(o=[],n.set(e,o)),o.push(t[e])})};return t.forEach(t=>{const e=t.klass.importDOM;if(null==e||o.has(e))return;o.add(e);const n=e.call(t.klass);null!==n&&r(n)}),e&&r(e),n}(_,h?h.import:void 0),g,e);return void 0!==a&&(p._pendingEditorState=a,p._dirtyType=2),function(t){t.registerCommand(ze,Yn,rs),t.registerCommand(Be,Gn,rs),t.registerCommand(Re,Xn,rs),t.registerCommand(We,Qn,rs),t.registerCommand(tn,eo,rs)}(p),p}function ms(t,e){const n=t.get(e);t.delete(e),n&&n()}function xs(t,e,n){return t.set(e,n),ms.bind(null,t,e)}class Cs{static version;_headless;_parentEditor;_rootElement;_editorState;_pendingEditorState;_compositionKey;_deferred;_keyToDOMMap;_updates;_updating;_cascadeCount;_listeners;_commands;_nodes;_decorators;_pendingDecorators;_config;_dirtyType;_cloneNotNeeded;_dirtyLeaves;_dirtyElements;_normalizedNodes;_updateTags;_observer;_key;_onError;_onWarn;_htmlConversions;_window;_editable;_blockCursorElement;_slotsUsed;_inputState;_createEditorArgs;constructor(t,e,n,o,r,i,s,l,c){this._createEditorArgs=c,this._parentEditor=e,this._rootElement=null,this._editorState=t,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new ot,this._updates=[],this._updating=!1,this._cascadeCount=0,this._listeners={decorator:new Map,editable:new Map,mutation:new Map,root:new Map,textcontent:new Map,update:new Map},this._commands=new Map,this._config=o,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=0,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=cl(),this._onError=r,this._onWarn=i,this._htmlConversions=s,this._editable=l,this._headless=null!==e&&e._headless,this._window=null,this._blockCursorElement=null,this._slotsUsed=!1,this._inputState={collapsedSelectionFormat:{format:0,key:"root",offset:0,style:"",timeStamp:0},compositionEndData:"",compositionPhase:"idle",hadOrphanedCompositionEvents:!1,handledSelectionCommandTimeoutId:null,isInsertLineBreak:!1,isInsertTextAfterHandledSelectionCommand:!1,isSelectionChangeFromDOMUpdate:!1,isSelectionChangeFromMouseDown:!1,lastBeforeInputInsertTextTimeStamp:0,lastKeyCode:null,lastKeyDownTimeStamp:0,postDeleteSelectionToRestore:null,unprocessedBeforeInputData:null}}isComposing(){return null!=this._compositionKey}registerUpdateListener(t){return xs(this._listeners.update,t)}registerEditableListener(t){return xs(this._listeners.editable,t)}registerDecoratorListener(t){return xs(this._listeners.decorator,t)}registerTextContentListener(t){return xs(this._listeners.textcontent,t)}registerRootListener(t){const e=this._listeners.root;return Eu(xs(e,t,t(this._rootElement,null)||void 0),()=>function(t,e,n){const o=t.get(e);o&&o(),t.set(e,e(...n)||void 0)}(e,t,[null,this._rootElement]))}registerCommand(e,n,o){void 0===o&&t(35);const r=this._commands;r.has(e)||r.set(e,[new tt,new tt,new tt,new tt,new tt]);const i=r.get(e);void 0===i&&t(36,String(e));const s=function(t){return 7&t}(o),l=i[s];return s!==o?l.addFront(n):l.addBack(n),()=>{l.delete(n),i.every(t=>0===t.size)&&r.delete(e)}}registerMutationListener(t,e,n){const o=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(t)).klass,r=this._listeners.mutation;let i=r.get(e);void 0===i&&(i=new Set,r.set(e,i)),i.add(o);const s=n&&n.skipInitialization;return void 0!==s&&s||this.initializeMutationListener(e,o),()=>{i.delete(o),0===i.size&&r.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,o=Ac(n).get(e.getType());if(!o)return;const r=new Map;for(const t of o.keys())r.set(t,"created");r.size>0&&t(r,{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),o=[n],r=n.replaceWithKlass;if(null!=r){const t=this.registerNodeTransformToKlass(r,e);o.push(t)}return function(t,e){const n=Ac(t.getEditorState()),o=[];for(const t of e){const e=n.get(t);e&&o.push(e)}if(0===o.length)return;t.update(()=>{for(const t of o)for(const e of t.keys()){const t=Ys(e);t&&t.markDirty()}},null===t._pendingEditorState?{tag:xo}:void 0)}(this,o.map(t=>t.klass.getType())),()=>{o.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 Nl(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=Cl(this._config.theme,"root"),o=this._pendingEditorState||this._editorState;if(this._rootElement=t,gs(this,e,t,o,{preserveUpdateQueue:!0}),null!==e&&(this._config.disableEvents||co(e),null!=n&&e.classList.remove(...n)),null!==t){const e=Pl(t),o=t.style;o.userSelect="text",o.whiteSpace="pre-wrap",o.wordBreak="break-word",t.setAttribute("data-lexical-editor","true"),this._window=e,this._dirtyType=2,gt(this),this._updateTags.add(xo),bi(this),this._config.disableEvents||function(t,e){const n=t.ownerDocument;Ln.set(t,n);let o=Kn.get(n);void 0===o&&(o={editors:new Set,hasShadowEditor:void 0},Kn.set(n,o)),o.editors.add(e),o.hasShadowEditor=void 0,t.__lexicalEditor=e;const r=no(t);r.push(zn.register(n));for(let n=0;n<In.length;n++){const[o,i]=In[n],s="function"==typeof i?t=>{so(t)||(io(t),(e.isEditable()||"click"===o)&&i(t,e))}:t=>{if(so(t))return;io(t);const n=e.isEditable();switch(o){case"cut":return n&&Nl(e,Tn,t);case"copy":return Nl(e,vn,t);case"paste":return n&&Nl(e,Je,t);case"dragstart":return n&&Nl(e,xn,t);case"dragover":return n&&Nl(e,Cn,t);case"dragend":return n&&Nl(e,Sn,t);case"focus":return n&&Nl(e,On,t);case"blur":return n&&Nl(e,Mn,t);case"drop":return n&&Nl(e,yn,t)}};r.push(Fn(t,o,s))}}(t,this),null!=n&&t.classList.add(...n)}else this._window=null,this._updateTags.add(xo),bi(this);Ni("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 o=e;o._readOnly&&(o=Ri(e),o._selection=e._selection?e._selection.clone():null),ht(this);const r=this._pendingEditorState,i=void 0!==n?n.tag:null;null===r||r.isEmpty()||(null!=i&&this._updateTags.add(i),bi(this)),this._pendingEditorState=o,this._dirtyType=2,this._dirtyElements.set("root",!1),this._compositionKey=null,this._slotsUsed=this._slotsUsed||e._slotsUsed,Ai(this,()=>{if(i&&this._updateTags.add(i),e._parsed)for(const[t,e]of o._nodeMap.entries())Pi(e)?this._dirtyElements.set(t,!0):this._dirtyLeaves.add(t)},{discrete:!this._updating||void 0})}parseEditorState(t,e){return function(t,e,n){const o=Wi(),r=ni,i=ri,s=oi,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,ni=o,ri=!1,oi=e,vs(null);try{const r=e._nodes;Ti(t.root,r),n&&n(),o._readOnly=!0,o._parsed=!0}catch(t){t instanceof Error&&e._onError(t)}finally{e._dirtyElements=l,e._dirtyLeaves=c,e._cloneNotNeeded=a,e._dirtyType=u,ni=r,ri=i,oi=s}return o}("string"==typeof t?JSON.parse(t):t,this,e)}read(...t){const[e,n]=1===t.length?["force-commit",t[0]]:t;"force-commit"===e&&bi(this);return("pending"===e?this._pendingEditorState||this._editorState:this.getEditorState()).read(n,{editor:this})}update(t,e){!function(t,e,n){t._updating?t._updates.push([e,n]):Mi(t,e,n)}(this,t,e)}focus(t,e={}){const n=this._rootElement;null!==n&&(n.setAttribute("autocapitalize","off"),Ai(this,()=>{const o=Kr(),r=nl();null!==o?o.dirty||ol(o.clone()):0!==r.getChildrenSize()&&("rootStart"===e.defaultSelection?r.selectStart():r.selectEnd()),Al("focus"),Dl(()=>{n.removeAttribute("autocapitalize"),t&&t()})}),null===this._pendingEditorState&&n.removeAttribute("autocapitalize"))}blur(){const t=this._rootElement;null!==t&&t.blur();const e=Jl(this._window);null!==e&&e.removeAllRanges()}isEditable(){return this._editable}setEditable(t){this._editable!==t&&(this._editable=t,Ni("editable",this,!0,t),this._slotsUsed&&this.update(()=>pi()))}toJSON(){return{editorState:this._editorState.toJSON()}}}Cs.version=Z;let Ss=null;function vs(t){Ss=t}const Ts=Symbol("INTERNAL_SKIP_AFTER_CLONE_FROM");let ks=1;function bs(){ks=1}function Ns(e,n){const o=Es(e,n);return void 0===o&&t(30,n),o}function Es(t,e){return t._nodes.get(e)}const ws="function"==typeof queueMicrotask?queueMicrotask:t=>{Promise.resolve().then(t)};function Os(t,e){const n=void 0!==e?e:(()=>{const e=t.getRootNode();return Bs(e)||ql(e)?cc(e):null})();if(!gc(n))return!1;if(n.hasAttribute("data-lexical-slot"))return!1;const o=Zs(n),r=n.nodeName;return po(o)&&("INPUT"===r||"TEXTAREA"===r||"true"===n.contentEditable&&null==Ps(n))}const Ms=Os;function As(t,e,n){const o=t.getRootElement();if(!o)return!1;try{if(!e||!o.contains(e)||!o.contains(n))return!1}catch(t){return!1}return Fs(e)===t&&t.read("latest",()=>!Os(e))}function Ds(t){return t instanceof Cs}function Fs(t){let e=t;for(;null!=e;){const t=Ps(e);if(Ds(t))return t;e=wl(e)}return null}function Ps(t){return t?t.__lexicalEditor:null}function Is(t){return L.test(t)?"rtl":K.test(t)?"ltr":null}function Ls(t){return er(t)||t.isToken()}function Ks(t){return Ls(t)||t.isSegmented()}function zs(t){return _c(t)&&3===t.nodeType}function Bs(t){return _c(t)&&9===t.nodeType}function Rs(t){let e=t;for(;null!=e;){if(zs(e))return e;e=e.firstChild}return null}function Ws(t,e,n){const o=z[e];if(null!==n&&(t&o)===(n&o))return t;let r=t^o;return"subscript"===e?r&=~z.superscript:"superscript"===e?r&=~z.subscript:"lowercase"===e?(r&=~z.uppercase,r&=~z.capitalize):"uppercase"===e?(r&=~z.lowercase,r&=~z.capitalize):"capitalize"===e&&(r&=~z.lowercase,r&=~z.uppercase),r}function $s(t){return Xo(t)||Yi(t)||Ki(t)}function Us(t,e){const n=function(){const t=Ss;return Ss=null,t}();if(null!=(e=e||n&&n.__key))return void(t.__key=e);fi(),di();const o=_i(),r=hi(),i=""+ks++;r._nodeMap.set(i,t),Pi(t)?o._dirtyElements.set(i,!0):o._dirtyLeaves.add(i),o._cloneNotNeeded.add(i),0===o._dirtyType&&(o._dirtyType=1),t.__key=i}function Hs(e){null!==ta(e)&&t(380,e.__key,String(ta(e)));const n=e.getParent();if(null!==n){const t=e.getWritable(),o=n.getWritable(),r=e.getPreviousSibling(),i=e.getNextSibling(),s=null!==i?i.__key:null,l=null!==r?r.__key:null,c=null!==r?r.getWritable():null,a=null!==i?i.getWritable():null;null===r&&(o.__first=s),null===i&&(o.__last=l),null!==c&&(c.__next=s),null!==a&&(a.__prev=l),t.__prev=null,t.__next=null,t.__parent=null,o.__size--}}const js=Hs;function Js(e){di(),ho(e)&&t(323,e.__key,e.__type);const n=e.getLatest(),o=null!==n.__parent?n.__parent:Zc(n)?n.__slotHost:null,r=hi(),i=_i(),s=r._nodeMap,l=i._dirtyElements;null!==o&&function(t,e,n){let o=t;for(;null!==o;){if(n.has(o))return;const t=e.get(o);if(void 0===t)break;n.set(o,!1),o=null!==t.__parent?t.__parent:Zc(t)?t.__slotHost:null}}(o,s,l);const c=n.__key;0===i._dirtyType&&(i._dirtyType=1),Pi(e)?l.set(c,!0):i._dirtyLeaves.add(c)}function Vs(t){fi();const e=_i(),n=e._compositionKey;if(t!==n){if(e._compositionKey=t,null!==n){const t=Ys(n);null!==t&&t.getWritable()}if(null!==t){const e=Ys(t);null!==e&&e.getWritable()}}}function qs(){if(ui())return null;return _i()._compositionKey}function Ys(t,e){const n=(e||hi())._nodeMap.get(t);return void 0===n?null:n}function Gs(t,e){const n=Qs(t,_i());return void 0!==n?Ys(n,e):null}function Xs(t,e,n){t[`__lexicalKey_${e._key}`]=n}function Qs(t,e){return t[`__lexicalKey_${e._key}`]}function Zs(t,e){let n=t;for(;null!=n;){const t=Gs(n,e);if(null!==t)return t;n=wl(n)}return null}function tl(t){const e=t._decorators,n=Object.assign({},e);return t._pendingDecorators=n,n}function el(t){return t.read(()=>nl().getTextContent())}function nl(){return hi()._nodeMap.get("root")}function ol(t){fi();const e=hi();null!==t&&(t.dirty=!0,t.setCachedNodes(null),ur(t)&&_i()._slotsUsed&&Or(t)),e._selection=t}function rl(){fi();ht(_i())}function il(t){const e=function(t,e){let n=t;for(;null!=n;){const t=Qs(n,e);if(void 0!==t)return t;n=wl(n)}return null}(t,_i());return null===e?null:Ys(e)}function sl(t){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(t)}function ll(t){const e=[];for(let n=t;null!==n;n=n._parentEditor)e.push(n);return e}function cl(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,5)}function al(t){return zs(t)?t.nodeValue:null}function ul(t,e,n){const o=Jl(Il(e));if(null===o)return;const r=nc(o,e._rootElement),i=r.anchorNode;let{anchorOffset:s,focusOffset:l}=r;if(null!==i){let e=al(i);const o=Zs(i);if(null!==e&&Xo(o)){if((e===A||e===F)&&n){const t=n.length;e=n,s=t,l=t}null!==e&&fl(o,e,s,l,t)}}}function fl(t,e,n,o,r){let i=t;if(i.isAttached()&&(r||!i.isDirty())){const s=i.isComposing();if(i.isToken()&&s)return;let c=e;if((s||r)&&(e.endsWith(A)&&(c=e.slice(0,-A.length)),r)){const t=F;let e;for(;-1!==(e=c.indexOf(t));)c=c.slice(0,e)+c.slice(e+t.length),null!==n&&n>e&&(n=Math.max(e,n-t.length)),null!==o&&o>e&&(o=Math.max(e,o-t.length))}const u=i.getTextContent();if(r||c!==u){const e=Kr();if(""===c){if(Vs(null),a||l||d)i.remove();else{const t=_i();dl(i,"",e),setTimeout(()=>{t.update(()=>{i.isAttached()&&""===i.getTextContent()&&i.remove()})},20)}return}const r=i.getParent(),u=zr(),f=i.getTextContentSize(),h=qs(),g=i.getKey();if(i.isToken()&&!s||null!==h&&g===h&&!s||ur(u)&&(null!==r&&!r.canInsertTextBefore()&&0===u.anchor.offset||u.anchor.key===t.__key&&0===u.anchor.offset&&!i.canInsertTextBefore()&&!s||u.focus.key===t.__key&&u.focus.offset===f&&!i.canInsertTextAfter()&&!s))return void i.markDirty();if(!ur(e)||null===n||null===o)return void dl(i,c,e);if(e.setTextNodeRange(i,n,i,o),i.isSegmented()){const t=Go(i.getTextContent());i.replace(t),i=t}dl(i,c,e)}}}function dl(t,e,n){if(t.setTextContent(e),ur(n)){const e=t.getKey();let o=!1;for(const r of["anchor","focus"]){const i=n[r];"text"===i.type&&i.key===e&&(i.offset=Ka(t,i.offset,"clamp"),o=!0)}o&&(n._cachedNodes=null,n._cachedIsBackward=null)}}function hl(t,e,n){const o=e[n]||!1;return"any"===o||o===t[n]}function gl(t,e){return hl(t,e,"altKey")&&hl(t,e,"ctrlKey")&&hl(t,e,"shiftKey")&&hl(t,e,"metaKey")}function _l(t,e,n){if(!gl(t,n))return!1;if(t.key.toLowerCase()===e.toLowerCase())return!0;if(e.length>1)return!1;if(1===t.key.length&&t.key.charCodeAt(0)<=127)return!1;if(t.code.startsWith("Digit")&&/^\d$/.test(e))return t.code===`Digit${e}`;const o="Key"+e.toUpperCase();return t.code===o}const pl={ctrlKey:!r,metaKey:r},yl={altKey:r,ctrlKey:!r};function ml(t){return"Backspace"===t.key}function xl(t){const e=nl();if(ur(t)){const e=t.anchor,n=t.focus,o=e.getNode();if(Bi(o))return e.set(o.getKey(),0,"element"),n.set(o.getKey(),o.getChildrenSize(),"element"),It(t),t;const r=o.getTopLevelElementOrThrow(),i=r.getParent();if(null===i)return Pi(r)&&(e.set(r.getKey(),0,"element"),n.set(r.getKey(),r.getChildrenSize(),"element"),It(t)),t;const s=i;return e.set(s.getKey(),0,"element"),n.set(s.getKey(),s.getChildrenSize(),"element"),It(t),t}{const t=e.select(0,e.getChildrenSize());return ol(It(t)),t}}function Cl(t,e){void 0===t.__lexicalClassNameCache&&(t.__lexicalClassNameCache={});const n=t.__lexicalClassNameCache,o=n[e];if(void 0!==o)return o;const r=t[e];if("string"==typeof r){const t=ku(r);return n[e]=t,t}return r}function Sl(e,n,o,r,i){if(0===o.size)return;const s=r.__type,l=r.__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"===i;(void 0===f||d)&&u.set(l,d?"updated":i)}function vl(t){const e=t.getType(),n=hi();if(n._readOnly){const t=Ac(n).get(e);return t?Array.from(t.values()):[]}const o=n._nodeMap,r=[];for(const[,n]of o)n instanceof t&&n.__type===e&&n.isAttached()&&r.push(n);return r}function Tl(t,e,n){const o=t.getParent();let r=n,i=t;return null!==o&&(e&&0===n?(r=i.getIndexWithinParent(),i=o):e||n!==i.getChildrenSize()||(r=i.getIndexWithinParent()+1,i=o)),i.getChildAtIndex(e?r-1:r)}function kl(t,e){const n=t.offset;if("element"===t.type){return Tl(t.getNode(),e,n)}{const o=t.getNode();if(e&&0===n||!e&&n===o.getTextContentSize()){const t=e?o.getPreviousSibling():o.getNextSibling();return null===t?Tl(o.getParentOrThrow(),e,o.getIndexWithinParent()+(e?0:1)):t}}return null}function bl(t){const e=Il(t).event,n=e&&e.inputType;return"insertFromPaste"===n||"insertFromPasteAsQuotation"===n}function Nl(t,e,...n){return Ei(t,e,n[0],t)}function El(e,n){const o=e._keyToDOMMap.get(n);return void 0===o&&t(75,n),o}function wl(t){const e=t.assignedSlot||t.parentElement;if(null!==e)return e;const n=t.parentNode;return ql(n)?n.host:null}function Ol(t){return Bs(t)?t:gc(t)?t.ownerDocument:null}function Ml(t){return _i()._updateTags.has(t)}function Al(t){fi();_i()._updateTags.add(t)}function Dl(t){fi();_i()._deferred.push(t)}function Fl(t,e){let n=t.getParent();for(;null!==n;){if(n.is(e))return!0;n=n.getParent()}return!1}function Pl(t){const e=Ol(t);return e?e.defaultView:null}function Il(e){const n=e._window;return null===n&&t(78),n}function Ll(t){return Pi(t)&&t.isInline()||Ki(t)&&t.isInline()}function Kl(t){let e=t.getLatest();for(;null!==e;){if(null!==ta(e)&&Pi(e))return e;const t=e.getParentOrThrow();if(Bl(t))return t;e=t}return e}function zl(t){return Pi(t)&&t.isShadowRoot()}function Bl(t){return Bi(t)||zl(t)}function Rl(t,e=!1){const n=t.constructor.clone(t,Ts);return Us(n,null),n.afterCloneFrom(t),e||n.resetOnCopyNodeFrom(t),n}function Wl(e){const n=_i(),o=e.getType(),r=Es(n,o);void 0===r&&t(200,e.constructor.name,o);const{replace:i,replaceWithKlass:s}=r;if(null!==i){const n=i(e),r=n.constructor;return null!==s?n instanceof s||t(201,s.name,s.getType(),r.name,r.getType(),e.constructor.name,o):n instanceof e.constructor&&r!==e.constructor||t(202,r.name,r.getType(),e.constructor.name,o),n.__key===e.__key&&t(203,e.constructor.name,o,r.name,r.getType()),n}return e}function $l(e,n){!Bi(e.getParent())||Pi(n)||Ki(n)||t(99)}function Ul(e){const n=Ys(e);return null===n&&t(63,e),n}function Hl(t){if(!t||t.isInline())return!1;if(Ki(t))return!0;if(Pi(t)){if(t.isShadowRoot()){const e=t.getParent();return!(Pi(e)&&e.isShadowRoot())}return!t.canBeEmpty()}return!1}function jl(t,e,n){n.style.removeProperty("caret-color"),e._blockCursorElement=null;const o=t.parentElement;null!==o&&o.removeChild(t)}function Jl(t){return n?(t||window).getSelection():null}function Vl(t){const e=Pl(t);return e?e.getSelection():null}function ql(t){return pc(t)&&"host"in t}const Yl=[];function Gl(t){const e=t.getRootNode();if(e===t||!ql(e))return Yl;const n=[e];let o=e.host;for(;;){const t=o.getRootNode();if(t===o||!ql(t))break;n.push(t),o=t.host}return n}function*Xl(t){const e=[t];let n;for(;n=e.pop();){yield*n.querySelectorAll('[data-lexical-editor="true"]');const t=(Bs(n)?n:n.ownerDocument).createTreeWalker(n,NodeFilter.SHOW_ELEMENT);let o;for(;o=t.nextNode();)o.shadowRoot&&e.push(o.shadowRoot)}}function Ql(t){return null!==t?t.ownerDocument:document}function Zl(){const t=mi();return Ql(null!==t?t._rootElement:null)}function tc(t,e){if(null===e||"function"!=typeof t.getComposedRanges)return null;const n=Gl(e);if(0===n.length)return null;const o=t.getComposedRanges;try{const e=o.call(t,{shadowRoots:n})[0];if(void 0!==e)return e}catch(t){}try{const e=o.apply(t,n)[0];if(void 0!==e)return e}catch(t){}return null}function ec(t,e){const n=tc(t,e);if(null!==n){const t=rc(n);if(null!==t)return t}return t.rangeCount>0?t.getRangeAt(0):null}function nc(t,e){const n=tc(t,e);return null===n?t:ic(n,sc(t))}function oc(t,e){const n=tc(t,e);if(null===n)return{points:t,range:t.rangeCount>0?t.getRangeAt(0):null};const o=rc(n)??(t.rangeCount>0?t.getRangeAt(0):null);return{points:ic(n,sc(t)),range:o}}function rc(t){const e=t.startContainer.ownerDocument;if(null===e)return null;const n=e.createRange();try{return n.setStart(t.startContainer,t.startOffset),n.setEnd(t.endContainer,t.endOffset),n}catch(t){return null}}function ic(t,e){const{startContainer:n,startOffset:o,endContainer:r,endOffset:i}=t;return"backward"===e?{anchorNode:r,anchorOffset:i,direction:e,focusNode:n,focusOffset:o}:{anchorNode:n,anchorOffset:o,direction:e,focusNode:r,focusOffset:i}}function sc(t){return t.direction}function lc(t){const e=t.getRootNode();return Bs(e)||ql(e)?e.activeElement:null}function cc(t){let e=t.activeElement;for(;null!==e&&null!==e.shadowRoot;){const t=e.shadowRoot.activeElement;if(null===t)break;e=t}return e}function ac(t){const e=t.target;if(null!==e&&gc(e)&&null!==e.shadowRoot&&"function"==typeof t.composedPath){const e=t.composedPath();if(e.length>0)return e[0]}return e}function uc(e,n){let o=e.getChildAtIndex(n);null==o&&(o=e),Bl(e)&&t(102);const r=e=>{const n=e.getParentOrThrow(),i=Bl(n),s=e!==o||i?Rl(e):e;if(i)return Pi(e)&&Pi(s)||t(133),e.insertAfter(s),[e,s,s];{const[t,o,i]=r(n),l=e.getNextSiblings();return i.append(s,...l),[t,o,s]}},[i,s]=r(o);return[i,s]}function fc(t){return gc(t)&&"A"===t.tagName}function dc(t){return gc(t)&&"TR"===t.tagName}function hc(t){return gc(t)&&("TD"===t.tagName||"TH"===t.tagName)}function gc(t){return _c(t)&&1===t.nodeType}function _c(t){return"object"==typeof t&&null!==t&&"nodeType"in t&&"number"==typeof t.nodeType}function pc(t){return _c(t)&&11===t.nodeType}const yc=/^(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;function mc(t){return!(!gc(t)||!t.style.display.startsWith("inline"))||yc.test(t.nodeName)}const xc=/^(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;function Cc(t){return(!gc(t)||!t.style.display.startsWith("inline"))&&xc.test(t.nodeName)}function Sc(t){if(Ki(t)&&!t.isInline())return!0;if(!Pi(t)||Bl(t))return!1;const e=t.getFirstChild(),n=null===e||Yi(e)||Xo(e)||e.isInline();return!t.isInline()&&!1!==t.canBeEmpty()&&n}function vc(){return _i()}function Tc(t=vc()){return t._config.dom||ps}function kc(e,n,o=vc()){const r=Tc(o).$getDOMSlot(e,n,o);return Pi(e)&&(Ec(r)||t(344,e.getKey(),e.getType())),r}function bc(t,e,n,o){const r=t.read("latest",()=>{const o=Ys(e);return null!==o?function(t,e,n=vc()){const o=sa(t,e);if(null===o)return null;const r=n.getElementByKey(o.getKey());return null!==r?r.parentElement:null}(o,n,t):null});return null!==r&&(r.parentElement!==o&&o.appendChild(r),r.style.display=""),r}function Nc(t,e,n){n.style.display="none";const o=t.getElementByKey(e);null!==o&&n.parentElement!==o&&o.insertBefore(n,o.firstChild)}function Ec(t){return t instanceof G}function wc(t,e,n=vc()){return Rs(kc(t,e,n).element)}const Oc=new WeakMap,Mc=new Map;function Ac(e){if(!e._readOnly&&e.isEmpty())return Mc;e._readOnly||t(192);let n=Oc.get(e);return n||(n=function(t){const e=new Map;for(const[n,o]of t._nodeMap){const t=o.__type;let r=e.get(t);r||(r=new Map,e.set(t,r)),r.set(n,o)}return e}(e),Oc.set(e,n)),n}function Dc(t){const e=t.constructor.clone(t,Ts);return e.afterCloneFrom(t),e}function Fc(t){return(e=Dc(t))[fo]=!0,e;var e}function Pc(t,e){const n=t.getAttribute("data-lexical-indent");if(null!==n){const t=parseInt(n,10);if(Number.isFinite(t)&&t>=0)return void e.setIndent(t)}const o=parseInt(t.style.paddingInlineStart,10)||0,r=Math.round(o/40);e.setIndent(r)}function Ic(t,e){const n=e.getAttribute("dir");return"ltr"===n||"rtl"===n?t.setDirection(n):t}function Lc(t,e){const n=e.style.textAlign;return n&&n in R?t.setFormat(n):t}function Kc(t,e){t.__lexicalUnmanaged=!0,e&&void 0!==e.captureSelection&&(t.__lexicalCapturedSelection=e.captureSelection)}function zc(t){return!0===t.__lexicalUnmanaged}function Bc(t,e=vc()){const n=e.isEditable();t.contentEditable=n?"true":"false",n?t.__lexicalEditor=e:delete t.__lexicalEditor}function Rc(t,e){let n=t;for(;null!=n;){if(!0===n.__lexicalCapturedSelection)return!0;if(gc(n)&&n.hasAttribute("data-lexical-slot"))return!1;if(void 0!==Qs(n,e))return!1;n=wl(n)}return!1}function Wc(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)&&t[e]!==_o[e]}const $c=new WeakMap,Uc=Symbol("lexical.synthesizedGetType");function Hc(e){const n=$c.get(e);if(n)return n;const o=null!=e.prototype&&j in e.prototype?e.prototype[j]():void 0,r=function(e){if(!(e===_o||e.prototype instanceof _o)){let n="<unknown>",o="<unknown>";try{n=e.getType()}catch(t){}try{Cs.version&&(o=JSON.parse(Cs.version))}catch(t){}t(290,e.name,n,o)}return e===Li||e===Fi||e===_o}(e),i=!r&&Wc(e,"getType")?e.getType:void 0,s=i&&!(Uc in i)?i.call(e):void 0;let l,c=s;if(o)if(s)l=o[s];else{for(const[t,e]of Object.entries(o))c=t,l=e;if(!l)for(const t of Object.getOwnPropertySymbols(o)){const e=o[t];if(e){l=e;break}}}if(!r&&c){if(!Wc(e,"getType")){const t=e,n=function(){return this!==t?_o.getType.call(this):c};n[Uc]=!0,e.getType=n}if(Wc(e,"clone")||(e.clone=(t,n)=>{vs(t);const o=new e;return n!==Ts&&o.afterCloneFrom(t),o}),Wc(e,"importJSON")||(e.importJSON=l&&l.$importJSON||(t=>(new e).updateFromJSON(t))),!Wc(e,"importDOM")&&l){const{importDOM:t}=l;t&&(e.importDOM=()=>t)}}const a={klass:e,ownNodeConfig:l,ownNodeType:c};return $c.set(e,a),a}function*jc(t){for(let e=t;e&&(e===_o||po(e.prototype));){const t=Hc(e);yield t,e=t.ownNodeConfig&&t.ownNodeConfig.extends||Gc(e)}}function Jc(t){const e=new Map,n=new Map;for(const o of t){const{ownNodeType:t}=Hc(o);t&&(n.set(t,o),e.set(t,new Set))}for(const[t,o]of n)for(const{ownNodeType:n}of jc(o)){const o=n&&e.get(n);o&&o.add(t)}return e}function Vc(t){const e=vc();fi();return new(e.resolveRegisteredNodeAfterReplacements(e.getRegisteredNode(t)).klass)}const qc=(t,e)=>{let n=t;for(;null!=n&&!Bi(n);){if(e(n))return n;n=n.getParent()}return null};function Yc(e,n){const o=[];let r=e.__first;for(;null!==r;){const e=null===n?Ys(r):n.get(r);null==e&&t(174),o.push(r),r=e.__next}return o}function Gc(t){const e=Object.getPrototypeOf(t);if("function"==typeof e&&e!==Function.prototype)return e;const n=t.prototype&&Object.getPrototypeOf(t.prototype);return n?n.constructor:null}const Xc=new Map;function Qc(t){return Pi(t)||Ki(t)}function Zc(t){return Pi(t)||Ki(t)}function ta(t){const e=t.getLatest();return Zc(e)?e.__slotHost:null}function ea(e){const n=ta(e);if(null===n)return null;const o=Ys(n);return Pi(o)||Ki(o)||t(370),o}function na(t){const e=ea(t);if(null===e)return null;const n=t.getLatest().__key;for(const[t,o]of ra(e))if(o===n)return t;return null}function oa(t){let e=t.getLatest();for(;null!==e;){if(null!==ta(e))return e;e=e.getParent()}return null}function ra(t){const e=t.getLatest();return Qc(e)&&null!==e.__slots?e.__slots:Xc}function ia(t){return Array.from(ra(t).keys())}function sa(t,e){const n=ra(t).get(e);return void 0===n?null:Ys(n)}const la=["__proto__","constructor","prototype"],ca=Symbol("slotMapOwner");function aa(t){let e=t.__slots;return null!==e&&e[ca]===t||(e=new Map(e),e[ca]=t,t.__slots=e),e}const ua=new WeakMap,fa=[];function da(t){for(const{ownNodeConfig:e}of jc(t)){const t=e&&e.slots;if(t)return t}return fa}function ha(t){let e="";for(const n of ia(t)){const o=sa(t,n);null!==o&&(e+=o.getTextContent())}return e}function ga(t,e,n){const o=n.get(t),r=n.get(e);return void 0!==o?void 0!==r?o-r:-1:void 0!==r?1:t<e?-1:t>e?1:0}function _a(e){const n=e.__slots;if(null===n||n.size<2)return;const o=function(e){let n=ua.get(e);if(void 0===n){const o=da(e),r=new Map;for(const n of o)la.includes(n)&&t(371,e.name,n),r.has(n)&&t(372,e.name,n),r.set(n,r.size);n=r,ua.set(e,n)}return n}(e.constructor);let r=null,i=!0;for(const t of n.keys()){if(null!==r&&ga(r,t,o)>0){i=!1;break}r=t}if(i)return;const s=Array.from(n).sort(([t],[e])=>ga(t,e,o));n.clear();for(const[t,e]of s)n.set(t,e)}function pa(e,n,o){"__proto__"!==n&&"constructor"!==n&&"prototype"!==n||t(373,n);const r=e.getLatest();if(null!==r.__slots&&r.__slots.get(n)===o.getLatest().__key)return r;(!Pi(o)&&!Ki(o)||o.isInline())&&t(374,o.__key);const i=e.getWritable(),s=aa(i),l=s.get(n);void 0!==l&&xa(l);const c=o.getWritable(),a=ea(c);if(null!==a){const t=na(c);null!==t&&aa(a.getWritable()).delete(t),c.__slotHost=null}return Hs(c),c.__slotHost=i.__key,s.set(n,c.__key),_a(i),function(){const t=vc();t._slotsUsed=!0,t._pendingEditorState&&(t._pendingEditorState._slotsUsed=!0)}(),i}function ya(t,e){const n=t.getWritable();if(null===n.__slots)return n;const o=n.__slots.get(e);return void 0!==o&&(xa(o),aa(n).delete(e)),n}function ma(t,e){}function xa(e){const n=Ys(e);if(null===n)return;const o=n.getWritable();Zc(o)||t(377,e),o.__slotHost=null,o.remove()}const Ca={next:"previous",previous:"next"};class Sa{origin;constructor(t){this.origin=t}[Symbol.iterator](){return qa({hasNext:Ma,initial:this.getAdjacentCaret(),map:t=>t,step:t=>t.getAdjacentCaret()})}getAdjacentCaret(){return Ia(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return Ia(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,o="next"){const r=o===this.direction?n:Array.from(n).reverse();let i=this;const s=this.getParentAtCaret(),l=new Map;for(let t=i.getAdjacentCaret();null!==t&&l.size<e;t=t.getAdjacentCaret()){const e=t.origin.getWritable();l.set(e.getKey(),e)}for(const e of r){if(l.size>0){const n=i.getNodeAtCaret();if(n)if(l.delete(n.getKey()),l.delete(e.getKey()),n.is(e)||i.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 i.insert(e);i=Ia(e,this.direction)}for(const t of l.values())t.remove();return this}}class va extends Sa{type="child";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:Ba(t,this.direction)}getParentCaret(t="root"){return Ia(ba(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=ka(this.direction);return Ia(this.getNodeAtCaret(),t)||Ba(this.origin,t)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(t){return t instanceof va&&this.direction===t.direction&&this.origin.is(t.origin)}isSamePointCaret(t){return this.isSameNodeCaret(t)}}const Ta={root:Bi,shadowRoot:Bl};function ka(t){return Ca[t]}function ba(t,e="root"){return null===t||Ta[e](t)?null:null===ta(t)?t:null}class Na extends Sa{type="sibling";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:Ia(t,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return Pi(this.origin)?Ba(this.origin,this.direction):null}getParentCaret(t="root"){return Ia(ba(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=ka(this.direction);return Ia(this.getNodeAtCaret(),t)||Ba(this.origin.getParentOrThrow(),t)}isSamePointCaret(t){return t instanceof Na&&this.direction===t.direction&&this.origin.is(t.origin)}isSameNodeCaret(t){return(t instanceof Na||t instanceof Ea)&&this.direction===t.direction&&this.origin.is(t.origin)}}class Ea extends Sa{type="text";offset;constructor(t,e){super(t),this.offset=e}getLatest(){const t=this.origin.getLatest();return t===this.origin?this:La(t,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(t="root"){return Ia(ba(this.getParentAtCaret(),t),this.direction)}getFlipped(){return La(this.origin,ka(this.direction),this.offset)}isSamePointCaret(t){return t instanceof Ea&&this.direction===t.direction&&this.origin.is(t.origin)&&this.offset===t.offset}isSameNodeCaret(t){return(t instanceof Na||t instanceof Ea)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return Ia(this.origin,this.direction)}}function wa(t){return t instanceof Ea}function Oa(t){return t instanceof Sa}function Ma(t){return t instanceof Na}function Aa(t){return t instanceof va}const Da={next:class extends Ea{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Ea{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},Fa={next:class extends Na{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Na{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},Pa={next:class extends va{direction="next";getNodeAtCaret(){return this.origin.getFirstChild()}insert(t){return this.origin.splice(0,0,[t]),this}},previous:class extends va{direction="previous";getNodeAtCaret(){return this.origin.getLastChild()}insert(t){return this.origin.splice(this.origin.getChildrenSize(),0,[t]),this}}};function Ia(t,e){return t?new Fa[e](t):null}function La(t,e,n){return t?new Da[e](t,Ka(t,n)):null}function Ka(t,n,o="error"){const r=t.getTextContentSize();let i="next"===n?r:"previous"===n?0:n;return(i<0||i>r)&&("clamp"!==o&&e(284,String(n),String(r),t.getKey()),i=i<0?0:r),i}function za(t,e){return new Ua(t,e)}function Ba(t,e){return Pi(t)?new Pa[e](t):null}function Ra(t){return t&&t.getChildCaret()||t}function Wa(t){return t&&Ra(t.getAdjacentCaret())}class $a{type="node-caret-range";direction;anchor;focus;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 $a(t,e,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){const t=t=>{const e=this[t].getLatest();return wa(e)?function(t,e){const{direction:n,origin:o}=t,r=Ka(o,"focus"===e?ka(n):n);return za(t,r-t.offset)}(e,t):null},e=t("anchor"),n=t("focus");if(e&&n){const{caret:t}=e,{caret:o}=n;if(t.isSameNodeCaret(o))return[za(t,o.offset-t.offset),null]}return[e,n]}iterNodeCarets(t="root"){const e=wa(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),o=wa(n),r=e=>e.isSameNodeCaret(n)?null:Wa(e)||e.getParentCaret(t);return qa({hasNext:t=>null!==t&&!(o&&n.isSameNodeCaret(t)),initial:e.isSameNodeCaret(n)?null:r(e),map:t=>t,step:r})}[Symbol.iterator](){return this.iterNodeCarets("root")}}class Ua{type="slice";caret;distance;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,o]=this.getSliceIndices(),r=t.getTextContent();return La(t.setTextContent(r.slice(0,n)+r.slice(o)),e,n)}}function Ha(t){return t instanceof Ua}function ja(t){return Va(t,Ia(nl(),t.direction))}function Ja(t){return Va(t,t)}function Va(e,n){return e.direction!==n.direction&&t(265),new $a(e,n,e.direction)}function qa(t){const{initial:e,hasNext:n,step:o,map:r}=t;let i=e;return{[Symbol.iterator](){return this},next(){if(!n(i))return{done:!0,value:void 0};const t={done:!1,value:r(i)};return i=o(i),t}}}function Ya(e,n){const o=Za(e.origin,n.origin);switch(null===o&&t(275,e.origin.getKey(),n.origin.getKey()),o.type){case"same":{const t="text"===e.type,o="text"===n.type;return t&&o?function(t,e){return Math.sign(t-e)}(e.offset,n.offset):e.type===n.type?0:t?-1:o?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 Ga(o)}}function Ga(t){const{a:e,b:n}=t,o=e.__key,r=n.__key;let i=e,s=n;for(;i&&s;i=i.getNextSibling(),s=s.getNextSibling()){if(i.__key===r)return-1;if(s.__key===o)return 1}return null===i?1:-1}function Xa(t,e){return e.is(t)}function Qa(t){return Pi(t)?[t.getLatest(),null]:[t.getParent(),t.getLatest()]}function Za(e,n){if(e.is(n))return{commonAncestor:e,type:"same"};const o=new Map;for(let[t,n]=Qa(e);t;n=t,t=t.getParent())o.set(t,n);for(let[r,i]=Qa(n);r;i=r,r=r.getParent()){const s=o.get(r);if(void 0!==s)return null===s?(Xa(e,r)||t(276),{commonAncestor:r,type:"ancestor"}):null===i?(Xa(n,r)||t(277),{commonAncestor:r,type:"descendant"}):((Pi(s)||Xa(e,s))&&(Pi(i)||Xa(n,i))&&r.is(s.getParent())&&r.is(i.getParent())||t(278),{a:s,b:i,commonAncestor:r,type:"branch"})}return null}function tu(e,n){const{type:o,key:r,offset:i}=e,s=Ul(e.key);return"text"===o?(Xo(s)||t(266,s.getType(),r),La(s,n,i)):(Pi(s)||t(267,s.getType(),r),hu(s,e.offset,n))}function eu(e,n){const{origin:o,direction:r}=n,i="next"===r;wa(n)?e.set(o.getKey(),n.offset,"text"):Ma(n)?Xo(o)?e.set(o.getKey(),Ka(o,r),"text"):e.set(o.getParentOrThrow().getKey(),o.getIndexWithinParent()+(i?1:0),"element"):(Aa(n)&&Pi(o)||t(268),e.set(o.getKey(),i?0:o.getChildrenSize(),"element"))}function nu(t){const e=Kr(),n=ur(e)?e:Fr();return ou(n,t),ol(n),n}function ou(t,e){eu(t.anchor,e.anchor),eu(t.focus,e.focus)}function ru(t){const{anchor:e,focus:n}=t,o=tu(e,"next"),r=tu(n,"next"),i=Ya(o,r)<=0?"next":"previous";return Va(fu(o,i),fu(r,i))}function iu(t){const{direction:e,origin:n}=t,o=Ia(n,ka(e)).getNodeAtCaret();return o?Ia(o,e):Ba(n.getParentOrThrow(),e)}function su(t,e="root"){const n=[t];for(let o=Aa(t)?t.getParentCaret(e):t.getSiblingCaret();null!==o;o=o.getParentCaret(e))n.push(iu(o));return n}function lu(t){return!!t&&t.origin.isAttached()}function cu(e,n="removeEmptySlices"){if(e.isCollapsed())return e;const o="root",r="next";let i=n;const s=du(e,r),l=su(s.anchor,o),c=su(s.focus.getFlipped(),o),a=new Set,u=[];for(const t of s.iterNodeCarets(o))if(Aa(t))a.add(t.origin.getKey());else if(Ma(t)){const{origin:e}=t;Pi(e)&&!a.has(e.getKey())||u.push(e)}const f=new Set;for(const t of u){const e=t.getParent();null===e||a.has(e.getKey())||f.add(e),Hs(t)}for(const t of f)!t.canBeEmpty()&&!Bl(t)&&t.isEmpty()&&t.isAttached()&&t.remove();for(const t of s.getTextSlices()){if(!t)continue;const{origin:e}=t.caret,n=e.getTextContentSize(),o=iu(Ia(e,r)),s=e.getMode();if(Math.abs(t.distance)===n&&"removeEmptySlices"===i||"token"===s&&0!==t.distance)o.remove();else if(0!==t.distance){i="removeEmptySlices";let e=t.removeTextSlice();const n=t.caret.origin;if("segmented"===s){const t=e.origin,n=Go(t.getTextContent()).setStyle(t.getStyle()).setFormat(t.getFormat());o.replaceOrInsert(n),e=La(n,r,e.offset)}n.is(l[0].origin)&&(l[0]=e),n.is(c[0].origin)&&(c[0]=e.getFlipped())}}let d,h;for(const t of l)if(lu(t)){d=au(t);break}for(const t of c)if(lu(t)){h=au(t);break}const g=function(t,e,n){if(!t||!e)return null;const o=t.getParentAtCaret(),r=e.getParentAtCaret();if(!o||!r)return null;const i=o.getParents().reverse();i.push(o);const s=r.getParents().reverse();s.push(r);const l=Math.min(i.length,s.length);let c;for(c=0;c<l&&i[c]===s[c];c++);const a=(t,e)=>{let n;for(let o=c;o<t.length;o++){const r=t[o];if(Bl(r))return;!n&&e(r)&&(n=r)}return n},u=a(i,Sc),f=u&&a(s,t=>n.has(t.getKey())&&Sc(t));if(f&&ia(f).length>0)return null;return u&&f?[u,f]:null}(d,h,a);if(g){const[t,e]=g;Ba(t,"previous").splice(0,e.getChildren());let n=e.getParent();for(e.remove(!0);n&&n.isEmpty();){const t=n;n=n.getParent(),t.remove(!0)}}else if(h){const t=function(t){if(Aa(t)){const e=t.origin;if(Sc(e))return e}else{const e=t.getParentAtCaret();if(e&&Sc(e))return e}return null}(h),e=t&&t.getParent(),n=t&&t.getParents().findLast(zl);if(t&&e&&!Bi(e)&&t.isEmpty()&&a.has(t.getKey())&&0===ia(t).length&&(!n||a.has(n.getKey()))){t.remove(!0);let n=e;for(;n&&!Bi(n)&&n.isEmpty();){const t=n.getParent();if(t&&Bi(t)&&t.getChildrenSize()<=1)break;const e=n;n=t,e.remove(!0)}}}const _=[d,h,...l,...c].find(lu);if(_){return Ja(fu(au(_),e.direction))}t(269,JSON.stringify(l.map(t=>t.origin.__key)))}function au(t){const e=function(t){let e=t;for(;Aa(e);){const t=Wa(e);if(!Aa(t))break;e=t}return e}(t.getLatest()),{direction:n}=e;if(Xo(e.origin))return wa(e)?e:La(e.origin,n,n);const o=e.getAdjacentCaret();return Ma(o)&&Xo(o.origin)?La(o.origin,n,ka(n)):e}function uu(t){return wa(t)&&t.offset!==Ka(t.origin,t.direction)}function fu(t,e){return t.direction===e?t:t.getFlipped()}function du(t,e){return t.direction===e?t:Va(fu(t.focus,e),fu(t.anchor,e))}function hu(t,e,n){let o=Ba(t,"next");for(let t=0;t<e;t++){const t=o.getAdjacentCaret();if(null===t)break;o=t}return fu(o,n)}function gu(t,e="root"){let n=0,o=t,r=Wa(o);for(;null===r;){if(n--,r=o.getParentCaret(e),!r)return null;o=r,r=Wa(o)}return r&&[r,n]}function _u(e){const{origin:n,offset:o,direction:r}=e;if(o===Ka(n,r))return e.getSiblingCaret();if(o===Ka(n,ka(r)))return iu(e.getSiblingCaret());const[i]=n.splitText(o);return Xo(i)||t(281),fu(Ia(i,"next"),r)}function pu(t,e){return!0}function yu(t,{$copyElementNode:e=Rl,$splitTextPointCaretNext:n=_u,rootMode:o="shadowRoot",$shouldSplit:r=pu,removeEmptyDestination:i=!1}={}){if(wa(t))return n(t);const s=t.getParentCaret(o);if(s){const{origin:n}=s;if(Aa(t)){const t=iu(s);if(i&&n.isEmpty())return n.remove(),t;if(!n.canBeEmpty()||!r(n,"first"))return t}const o=function(t){const e=[];for(let n=t.getAdjacentCaret();n;n=n.getAdjacentCaret())e.push(n.origin);return e}(t);(o.length>0||!i&&n.canBeEmpty()&&r(n,"last"))&&s.insert(e(n).splice(0,0,o))}return s}function mu(e,n,o){let r=fu(n,"next");wa(r)&&(0===r.offset?r=Ia(r.origin,"previous").getFlipped():r.offset===r.origin.getTextContentSize()&&(r=Ia(r.origin,"next"))),r.origin.is(e)&&(Ma(r)||t(342,e.getKey(),e.getType()),r=iu(r)),(e.is(r.getNodeAtCaret())||e.is(r.getFlipped().getNodeAtCaret()))&&e.remove(!0);for(let t=r;t;t=yu(t,o))r=t;return wa(r)&&t(283),r.insert(e.isInline()?es().append(e):e),fu(Ia(e.getLatest(),"next"),n.direction)}function xu(t){return t}function Cu(...t){return t}function Su(t,e){return[t,e]}function vu(t){return t}function Tu(t,e){if(!e||t===e)return t;for(const n in e)if(t[n]!==e[n])return{...t,...e};return t}function ku(...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}function bu(t,...e){const n=ku(...e);n.length>0&&t.classList.add(...n)}function Nu(t,...e){const n=ku(...e);n.length>0&&t.classList.remove(...n)}function Eu(...t){return()=>{for(let e=t.length-1;e>=0;e--)t[e]();t.length=0}}function wu(t,e,n){return Eu(...Object.entries(e).map(([e,o])=>Fn(t,e,o,n)))}export{Al as $addUpdateTag,Wl as $applyNodeReplacement,gi as $assumeActiveEditor,tu as $caretFromPoint,ru as $caretRangeFromSelection,Dc as $cloneWithProperties,Fc as $cloneWithPropertiesEphemeral,Ya as $comparePointCaretNext,Rl as $copyNode,Vc as $create,Yc as $createChildrenArray,qi as $createLineBreakNode,Pr as $createNodeSelection,es as $createParagraphNode,or as $createPoint,Fr as $createRangeSelection,Ir as $createRangeSelectionFromDom,tr as $createTabNode,Go as $createTextNode,ja as $extendCaretToRange,qc as $findMatchingParent,_r as $formatText,pi as $fullReconcile,qr as $generateNodesFromRawText,Wa as $getAdjacentChildCaret,kl as $getAdjacentNode,gu as $getAdjacentSiblingOrParentSiblingCaret,fu as $getCaretInDirection,Va as $getCaretRange,du as $getCaretRangeInDirection,yr as $getCharacterOffsets,Ba as $getChildCaret,hu as $getChildCaretAtIndex,Ra as $getChildCaretOrSelf,Ja as $getCollapsedCaretRange,Za as $getCommonAncestor,Ga as $getCommonAncestorResultBranchOrder,kc as $getDOMSlot,wc as $getDOMTextNode,Zl as $getDocument,vc as $getEditor,Tc as $getEditorDOMRenderConfig,Zs as $getNearestNodeFromDOMNode,Kl as $getNearestRootOrShadowRoot,Ys as $getNodeByKey,Ul as $getNodeByKeyOrThrow,Gs as $getNodeFromDOMNode,zr as $getPreviousSelection,nl as $getRoot,Kr as $getSelection,Ia as $getSiblingCaret,sa as $getSlot,oa as $getSlotFrame,ea as $getSlotHost,na as $getSlotNameWithinHost,ia as $getSlotNames,xt as $getState,Ct as $getStateChange,Yr as $getTextContent,Ka as $getTextNodeOffset,La as $getTextPointCaret,za as $getTextPointCaretSlice,bt as $getWritableNodeState,Fl as $hasAncestor,Ml as $hasUpdateTag,mu as $insertNodeToNearestRootAtCaret,Jr as $insertNodes,Ar as $isBlockElementNode,Aa as $isChildCaret,Ki as $isDecoratorNode,Ui as $isEditorState,Ec as $isElementDOMSlot,Pi as $isElementNode,uu as $isExtendableTextPointCaret,Ll as $isInlineElementOrDecoratorNode,Ro as $isInlineFormattable,$s as $isLeafNode,po as $isLexicalNode,Yi as $isLineBreakNode,Oa as $isNodeCaret,dr as $isNodeSelection,ns as $isParagraphNode,ur as $isRangeSelection,Bi as $isRootNode,Bl as $isRootOrShadowRoot,Os as $isSelectionCapturedInDecoratorInput,zl as $isShadowRootNode,Ma as $isSiblingCaret,Zc as $isSlotChild,Qc as $isSlotHost,er as $isTabNode,Xo as $isTextNode,wa as $isTextPointCaret,Ha as $isTextPointCaretSlice,Ks as $isTokenOrSegmented,Ls as $isTokenOrTab,Bc as $markSlotEditable,Hl as $needsBlockCursorBeside,vl as $nodesOfType,au as $normalizeCaret,It as $normalizeSelection__EXPERIMENTAL,Dl as $onUpdate,vi as $parseSerializedNode,Hs as $removeFromParent,ya as $removeSlot,cu as $removeTextFromCaretRange,iu as $rewindSiblingCaret,xl as $selectAll,Vs as $setCompositionKey,Ic as $setDirectionFromDOM,Lc as $setFormatFromDOM,eu as $setPointFromCaret,ol as $setSelection,nu as $setSelectionFromCaretRange,pa as $setSlot,St as $setState,gr as $setTextFormat,yu as $splitAtPointCaretNext,uc as $splitNode,jr as $updateDOMSelection,ou as $updateRangeSelectionFromCaretRange,ji as ArtificialNode__DO_NOT_USE,ze as BEFORE_INPUT_COMMAND,Mn as BLUR_COMMAND,En as CAN_REDO_COMMAND,wn as CAN_UNDO_COMMAND,s as CAN_USE_BEFORE_INPUT,n as CAN_USE_DOM,bn as CLEAR_EDITOR_COMMAND,Nn as CLEAR_HISTORY_COMMAND,Ke as CLICK_COMMAND,vo as COLLABORATION_TAG,hs as COMMAND_PRIORITY_BEFORE_CRITICAL,as as COMMAND_PRIORITY_BEFORE_EDITOR,ds as COMMAND_PRIORITY_BEFORE_HIGH,us as COMMAND_PRIORITY_BEFORE_LOW,fs as COMMAND_PRIORITY_BEFORE_NORMAL,cs as COMMAND_PRIORITY_CRITICAL,rs as COMMAND_PRIORITY_EDITOR,ls as COMMAND_PRIORITY_HIGH,is as COMMAND_PRIORITY_LOW,ss as COMMAND_PRIORITY_NORMAL,We as COMPOSITION_END_COMMAND,wo as COMPOSITION_END_TAG,Re as COMPOSITION_START_COMMAND,Eo as COMPOSITION_START_TAG,je as CONTROLLED_TEXT_INSERTION_COMMAND,vn as COPY_COMMAND,Tn as CUT_COMMAND,So as CUT_TAG,ps as DEFAULT_EDITOR_DOM_CONFIG,$e as DELETE_CHARACTER_COMMAND,Ye as DELETE_LINE_COMMAND,qe as DELETE_WORD_COMMAND,Sn as DRAGEND_COMMAND,Cn as DRAGOVER_COMMAND,xn as DRAGSTART_COMMAND,yn as DROP_COMMAND,Li as DecoratorNode,Fi as ElementNode,On as FOCUS_COMMAND,mn as FORMAT_ELEMENT_COMMAND,Ge as FORMAT_TEXT_COMMAND,yo as HISTORIC_TAG,xo as HISTORY_MERGE_TAG,mo as HISTORY_PUSH_TAG,_n as INDENT_CONTENT_COMMAND,Be as INPUT_COMMAND,Ue as INSERT_LINE_BREAK_COMMAND,He as INSERT_PARAGRAPH_COMMAND,gn as INSERT_TAB_COMMAND,Sc as INTERNAL_$isBlock,k as IS_ALL_FORMATTING,c as IS_ANDROID,f as IS_ANDROID_CHROME,r as IS_APPLE,d as IS_APPLE_WEBKIT,p as IS_BOLD,u as IS_CHROME,C as IS_CODE,i as IS_FIREFOX,T as IS_HIGHLIGHT,l as IS_IOS,y as IS_ITALIC,a as IS_SAFARI,m as IS_STRIKETHROUGH,S as IS_SUBSCRIPT,v as IS_SUPERSCRIPT,x as IS_UNDERLINE,ln as KEY_ARROW_DOWN_COMMAND,on as KEY_ARROW_LEFT_COMMAND,en as KEY_ARROW_RIGHT_COMMAND,sn as KEY_ARROW_UP_COMMAND,un as KEY_BACKSPACE_COMMAND,dn as KEY_DELETE_COMMAND,tn as KEY_DOWN_COMMAND,cn as KEY_ENTER_COMMAND,fn as KEY_ESCAPE_COMMAND,An as KEY_MODIFIER_COMMAND,an as KEY_SPACE_COMMAND,hn as KEY_TAB_COMMAND,Ji as LineBreakNode,nn as MOVE_TO_END,rn as MOVE_TO_START,_t as NODE_STATE_DIRECT,H as NODE_STATE_KEY,pt as NODE_STATE_LATEST,pn as OUTDENT_CONTENT_COMMAND,Je as PASTE_COMMAND,Co as PASTE_TAG,Zi as ParagraphNode,Ze as REDO_COMMAND,Ve as REMOVE_TEXT_COMMAND,zi as RootNode,Ie as SELECTION_CHANGE_COMMAND,Le as SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,kn as SELECT_ALL_COMMAND,Xe as SET_TEXT_FORMAT_COMMAND,To as SKIP_COLLAB_TAG,bo as SKIP_DOM_SELECTION_TAG,ko as SKIP_SCROLL_INTO_VIEW_TAG,No as SKIP_SELECTION_FOCUS_TAG,z as TEXT_TYPE_TO_FORMAT,Zo as TabNode,Wo as TextNode,Qe as UNDO_COMMAND,bu as addClassNamesToElement,uo as buildImportMap,Cu as configExtension,Pe as createCommand,ys as createEditor,Dn as createRefCountedRegistry,vt as createSharedNodeState,mt as createState,Su as declarePeerDependency,xu as defineExtension,Xl as findAllLexicalElementsDeep,ka as flipDirection,lc as getActiveElement,cc as getActiveElementDeep,ac as getComposedEventTarget,tc as getComposedStaticRange,Ol as getDOMOwnerDocument,Jl as getDOMSelection,Vl as getDOMSelectionFromTarget,nc as getDOMSelectionPoints,ec as getDOMSelectionRange,oc as getDOMSelectionRangeAndPoints,Gl as getDOMShadowRoots,Rs as getDOMTextNode,da as getDeclaredSlots,Ps as getEditorPropertyFromDOMNode,Fs as getNearestEditorFromDOMNode,wl as getParentElement,Es as getRegisteredNode,Ns as getRegisteredNodeOrThrow,Jc as getRegisteredSubtypeMap,Ql as getRootOwnerDocument,Hc as getStaticNodeConfig,Mo as getStyleObjectFromCSS,Is as getTextDirection,_s as getTransformSetFromKlass,Cc as isBlockDomNode,ui as isCurrentlyReadOnlyMode,Rc as isDOMCapturingSelection,Bs as isDOMDocumentNode,_c as isDOMNode,ql as isDOMShadowRoot,zs as isDOMTextNode,zc as isDOMUnmanaged,pc as isDocumentFragment,_l as isExactShortcutMatch,fc as isHTMLAnchorElement,gc as isHTMLElement,hc as isHTMLTableCellElement,dc as isHTMLTableRowElement,mc as isInlineDomNode,Xi as isLastChildInBlockNode,Ds as isLexicalEditor,gl as isModifierMatch,Gi as isOnlyChildInBlockNode,Ms as isSelectionCapturedInDecoratorInput,As as isSelectionWithinEditor,jc as iterStaticNodeConfigChain,qa as makeStepwiseIterator,Eu as mergeRegister,bc as mountSlotContainer,ku as normalizeClassNames,Fn as registerEventListener,wu as registerEventListeners,Nu as removeClassNamesFromElement,js as removeFromParent,bs as resetRandomKey,vu as safeCast,Fo as setDOMStyleFromCSS,Do as setDOMStyleObject,Kc as setDOMUnmanaged,Pc as setNodeIndentFromDOM,Tu as shallowMergeConfig,io as stopLexicalPropagation,Ws as toggleTextFormatType,Vr as tokenizeRawText,Nc as unmountSlotContainer};