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