0&&(h!==g.getTextContentSize()&&!ze(g)&&([g]=g.splitText(h)),g.setFormat(C));for(let N=m+1;N(E(h)||B(h))&&!h.isInline();if(!e.some(i)){x(E(n),"Expected 'firstBlock' to be an ElementNode");let h=Ll(this);n.splice(h,0,e),r.selectEnd();return}let s=NN(e),l=s.getLastDescendant(),a=s.getChildren(),c=h=>E(h)&&$o(h)&&!h.isEmpty()&&E(n)&&(!n.isEmpty()||n.canMergeWhenEmpty()),f=!E(n)||!n.isEmpty()?this.insertParagraph():null,d=a[a.length-1],u=a[0];c(u)&&(x(E(n),"Expected 'firstBlock' to be an ElementNode"),n.append(...u.getChildren()),u=a[1]),u&&kd(n,u);let p=mi(l,$o);f&&E(p)&&(f.canMergeWhenEmpty()||$o(d))&&(p.append(...f.getChildren()),f.remove()),E(n)&&n.isEmpty()&&n.remove(),l.selectEnd();let g=E(n)?n.getLastChild():null;ve(g)&&p!==n&&g.remove()}insertParagraph(){if(this.anchor.key==="root"){let s=I();return F().splice(this.anchor.offset,0,[s]),s.select(),s}let e=Ll(this),t=mi(this.anchor.getNode(),$o);x(E(t),"Expected ancestor to be an ElementNode");let n=t.getChildAtIndex(e),r=n?[n,...n.getNextSiblings()]:[],i=t.insertNewAfter(this,!1);return i?(i.append(...r),i.selectStart(),i):null}insertLineBreak(e){let t=ut();if(this.insertNodes([t]),e){let n=t.getParentOrThrow(),r=t.getIndexWithinParent();n.select(r,r)}}extract(){let e=this.getNodes(),t=e.length,n=t-1,r=this.anchor,i=this.focus,s=e[0],l=e[n],[a,c]=Mr(this);if(t===0)return[];if(t===1){if(y(s)&&!this.isCollapsed()){let f=a>c?c:a,d=a>c?a:c,u=s.splitText(f,d),p=f===0?u[0]:u[1];return p!=null?[p]:[]}return[s]}let m=r.isBefore(i);if(y(s)){let f=m?a:c;f===s.getTextContentSize()?e.shift():f!==0&&([,s]=s.splitText(f),e[0]=s)}if(y(l)){let d=l.getTextContent().length,u=m?c:a;u===0?e.pop():u!==d&&([l]=l.splitText(u),e[n]=l)}return e}modify(e,t,n){let r=this.focus,i=this.anchor,s=e==="move",l=Yt(r,t);if(B(l)&&!l.isIsolated()){if(s&&l.isKeyboardSelectable()){let u=Ho();u.add(l.__key),Y(u);return}let d=t?l.getPreviousSibling():l.getNextSibling();if(y(d)){let u=d.__key,p=t?d.getTextContent().length:0;r.set(u,p,"text"),s&&i.set(u,p,"text");return}else{let u=l.getParentOrThrow(),p,g;E(d)?(g=d.__key,p=t?d.getChildrenSize():0):(p=l.getIndexWithinParent(),g=u.__key,t||p++),r.set(g,p,"element"),s&&i.set(g,p,"element");return}}let a=j(),c=be(a._window);if(!c)return;let m=a._blockCursorElement,f=a._rootElement;if(f!==null&&m!==null&&E(l)&&!l.isInline()&&!l.canBeEmpty()&&Er(m,a,f),mN(c,e,t?"backward":"forward",n),c.rangeCount>0){let d=c.getRangeAt(0),u=this.anchor.getNode(),p=oe(u)?u:ol(u);if(this.applyDOMRange(d),this.dirty=!0,!s){let g=this.getNodes(),h=[],C=!1;for(let N=0;N0)if(t){let N=h[0];E(N)?N.selectStart():N.getParentOrThrow().selectStart()}else{let N=h[h.length-1];E(N)?N.selectEnd():N.getParentOrThrow().selectEnd()}(c.anchorNode!==d.startContainer||c.anchorOffset!==d.startOffset)&&fN(this)}}}forwardDeletion(e,t,n){if(!n&&(e.type==="element"&&E(t)&&e.offset===t.getChildrenSize()||e.type==="text"&&e.offset===t.getTextContentSize())){let r=t.getParent(),i=t.getNextSibling()||(r===null?null:r.getNextSibling());if(E(i)&&i.isShadowRoot())return!0}return!1}deleteCharacter(e){let t=this.isCollapsed();if(this.isCollapsed()){let n=this.anchor,r=n.getNode();if(this.forwardDeletion(n,r,e))return;let i=this.focus,s=Yt(i,e);if(B(s)&&!s.isIsolated()){if(s.isKeyboardSelectable()&&E(r)&&r.getChildrenSize()===0){r.remove();let l=Ho();l.add(s.__key),Y(l)}else s.remove(),j().dispatchCommand(we,void 0);return}else if(!e&&E(s)&&E(r)&&r.isEmpty()){r.remove(),s.selectStart();return}if(this.modify("extend",e,"character"),this.isCollapsed()){if(e&&n.offset===0&&(n.type==="element"?n.getNode():n.getNode().getParentOrThrow()).collapseAtStart(this))return}else{let l=i.type==="text"?i.getNode():null;if(r=n.type==="text"?n.getNode():null,l!==null&&l.isSegmented()){let a=i.offset,c=l.getTextContentSize();if(l.is(r)||e&&a!==c||!e&&a!==0){Kd(l,e,a);return}}else if(r!==null&&r.isSegmented()){let a=n.offset,c=r.getTextContentSize();if(r.is(l)||e&&a!==0||!e&&a!==c){Kd(r,e,a);return}}pN(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type==="element"&&this.anchor.offset===0){let n=this.anchor.getNode();n.isEmpty()&&oe(n.getParent())&&n.getIndexWithinParent()===0&&n.collapseAtStart(this)}}deleteLine(e){if(this.isCollapsed()){let t=this.anchor.type==="element";if(t&&this.insertText(" "),this.modify("extend",e,"lineboundary"),(e?this.focus:this.anchor).offset===0&&this.modify("extend",e,"character"),t){let r=e?this.anchor:this.focus;r.set(r.key,r.offset+1,r.type)}}this.removeText()}deleteWord(e){if(this.isCollapsed()){let t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;this.modify("extend",e,"word")}this.removeText()}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return[this.anchor,this.focus]}};function Se(o){return o instanceof bi}function Hd(o){let e=o.offset;if(o.type==="text")return e;let t=o.getNode();return e===t.getChildrenSize()?t.getTextContent().length:0}function Mr(o){let e=o.getStartEndPoints();if(e===null)return[0,0];let[t,n]=e;return t.type==="element"&&n.type==="element"&&t.key===n.key&&t.offset===n.offset?[0,0]:[Hd(t),Hd(n)]}function fN(o){let e=o.focus,t=o.anchor,n=t.key,r=t.offset,i=t.type;xo(t,e.key,e.offset,e.type),xo(e,n,r,i),o._cachedNodes=null}function mN(o,e,t,n){o.modify(e,t,n)}function pN(o,e){let t=o.anchor,n=o.focus,r=t.getNode(),i=n.getNode();if(r===i&&t.type==="text"&&n.type==="text"){let s=t.offset,l=n.offset,a=st||d){i.splice(m,1),d&&(a=void 0);break}}let c=i.join("").trim();c===""?n.remove():(n.setTextContent(c),n.select(a,a))}function gN(o,e,t){let n=o.getParent();return t===null||n===null||!n.canBeEmpty()||n!==t.getNode()}function Ud(o,e,t,n){let r=e,i;if(o.nodeType===fo){let s=!1,l=o.childNodes,a=l.length,c=n._blockCursorElement;r===a&&(s=!0,r=a-1);let m=l[r],f=!1;if(m===c)m=l[r+1],f=!0;else if(c!==null){let d=c.parentNode;if(o===d){let u=Array.prototype.indexOf.call(d.children,c);e>u&&r--}}if(i=ko(m),y(i))r=js(i,s);else{let d=ko(o);if(d===null)return null;if(E(d)){r=Math.min(d.getChildrenSize(),r);let u=d.getChildAtIndex(r);if(E(u)&&gN(u,r,t)){let p=s?u.getLastDescendant():u.getFirstDescendant();p===null?d=u:(u=p,d=E(u)?u:u.getParentOrThrow()),r=0}y(u)?(i=u,d=null,r=js(u,s)):u!==d&&s&&!f&&r++}else{let u=d.getIndexWithinParent();e===0&&B(d)&&ko(o)===d?r=u:r=u+1,d=d.getParentOrThrow()}if(E(d))return De(d.__key,r,"element")}}else i=ko(o);return y(i)?De(i.__key,r,"text"):null}function zd(o,e,t){let n=o.offset,r=o.getNode();if(n===0){let i=r.getPreviousSibling(),s=r.getParent();if(!e)E(i)&&!t&&i.isInline()?(o.key=i.__key,o.offset=i.getChildrenSize(),o.type="element"):y(i)&&(o.key=i.__key,o.offset=i.getTextContent().length);else if((t||!e)&&i===null&&E(s)&&s.isInline()){let l=s.getPreviousSibling();y(l)&&(o.key=l.__key,o.offset=l.getTextContent().length)}}else if(n===r.getTextContent().length){let i=r.getNextSibling(),s=r.getParent();if(e&&E(i)&&i.isInline())o.key=i.__key,o.offset=0,o.type="element";else if((t||e)&&i===null&&E(s)&&s.isInline()&&!s.canInsertTextAfter()){let l=s.getNextSibling();y(l)&&(o.key=l.__key,o.offset=0)}}}function qd(o,e,t){if(o.type==="text"&&e.type==="text"){let n=o.isBefore(e),r=o.is(e);zd(o,n,r),zd(e,!n,r),r&&(e.key=o.key,e.offset=o.offset,e.type=o.type);let i=j();if(i.isComposing()&&i._compositionKey!==o.key&&_(t)){let s=t.anchor,l=t.focus;xo(o,s.key,s.offset,s.type),xo(e,l.key,l.offset,l.type)}}}function Yd(o,e,t,n,r,i){if(o===null||t===null||!Wt(r,o,t))return null;let s=Ud(o,e,_(i)?i.anchor:null,r);if(s===null)return null;let l=Ud(t,n,_(i)?i.focus:null,r);if(l===null)return null;if(s.type==="element"&&l.type==="element"){let a=ko(o),c=ko(t);if(B(a)&&B(c))return null}return qd(s,l,i),[s,l]}function Ko(o){return E(o)&&!o.isInline()}function _i(o,e,t,n,r,i){let s=je(),l=new Eo(De(o,e,r),De(t,n,i),0,"");return l.dirty=!0,s._selection=l,l}function Uo(){let o=De("root",0,"element"),e=De("root",0,"element");return new Eo(o,e,0,"")}function Ho(){return new bi(new Set)}function Zd(o){let t=o.getEditorState()._selection,n=be(o._window);return _(t)||t==null?Lr(t,n,o,null):t.clone()}function wl(o,e){return Lr(null,o,e,null)}function Lr(o,e,t,n){let r=t._window;if(r===null)return null;let i=n||r.event,s=i?i.type:void 0,l=s==="selectionchange",a=!gc()&&(l||s==="beforeinput"||s==="compositionstart"||s==="compositionend"||s==="click"&&i&&i.detail===3||s==="drop"||s===void 0),c,m,f,d;if(!_(o)||a){if(e===null)return null;if(c=e.anchorNode,m=e.focusNode,f=e.anchorOffset,d=e.focusOffset,l&&_(o)&&!Wt(t,c,m))return o.clone()}else return o.clone();let u=Yd(c,f,m,d,t,o);if(u===null)return null;let[p,g]=u;return new Eo(p,g,_(o)?o.format:0,_(o)?o.style:"")}function T(){return je()._selection}function We(){return j()._editorState._selection}function Ln(o,e,t,n=1){let r=o.anchor,i=o.focus,s=r.getNode(),l=i.getNode();if(!e.is(s)&&!e.is(l))return;let a=e.__key;if(o.isCollapsed()){let c=r.offset;if(t<=c&&n>0||t0||t0||t
=l,c=a?i.getChildAtIndex(l-1):i.getChildAtIndex(t);if(y(c)){let m=0;a&&(m=c.getTextContentSize()),e.set(c.__key,m,"text"),n.set(c.__key,m,"text")}return}if(E(i)){let l=i.getChildrenSize(),a=t>=l,c=a?i.getChildAtIndex(l-1):i.getChildAtIndex(t);if(y(c)){let m=0;a&&(m=c.getTextContentSize()),e.set(c.__key,m,"text")}}if(E(s)){let l=s.getChildrenSize(),a=r>=l,c=a?s.getChildAtIndex(l-1):s.getChildAtIndex(r);if(y(c)){let m=0;a&&(m=c.getTextContentSize()),n.set(c.__key,m,"text")}}}function Vd(o,e){let n=e.getEditorState()._selection,r=o._selection;if(_(r)){let i=r.anchor,s=r.focus,l;if(i.type==="text"&&(l=i.getNode(),l.selectionTransform(n,r)),s.type==="text"){let a=s.getNode();l!==a&&a.selectionTransform(n,r)}}}function Mn(o,e,t,n,r){let i=null,s=0,l=null;n!==null?(i=n.__key,y(n)?(s=n.getTextContentSize(),l="text"):E(n)&&(s=n.getChildrenSize(),l="element")):r!==null&&(i=r.__key,y(r)?l="text":E(r)&&(l="element")),i!==null&&l!==null?o.set(i,s,l):(s=e.getIndexWithinParent(),s===-1&&(s=t.getChildrenSize()),o.set(t.__key,s,"element"))}function _l(o,e,t,n,r){o.type==="text"?(o.key=t,e||(o.offset+=r)):o.offset>n.getIndexWithinParent()&&(o.offset-=1)}function Xd(o,e,t,n,r,i,s){let l=n.anchorNode,a=n.focusNode,c=n.anchorOffset,m=n.focusOffset,f=document.activeElement;if(r.has("collaboration")&&f!==i||f!==null&&En(f))return;if(!_(e)){o!==null&&Wt(t,l,a)&&n.removeAllRanges();return}let d=e.anchor,u=e.focus,p=d.key,g=u.key,h=_n(t,p),C=_n(t,g),N=d.offset,L=u.offset,M=e.format,S=e.style,A=e.isCollapsed(),O=h,R=C,P=!1;if(d.type==="text"){O=Cn(h);let k=d.getNode();P=k.getFormat()!==M||k.getStyle()!==S}else _(o)&&o.anchor.type==="text"&&(P=!0);if(u.type==="text"&&(R=Cn(C)),!(O===null||R===null)&&(A&&(o===null||P||_(o)&&(o.format!==M||o.style!==S))&&Rd(M,S,N,p,performance.now()),!(c===N&&m===L&&l===O&&a===R&&!(n.type==="Range"&&A)&&((f===null||!i.contains(f))&&i.focus({preventScroll:!0}),d.type!=="element")))){try{n.setBaseAndExtent(O,N,R,L)}catch(k){__DEV__&&console.warn(k)}if(!r.has("skip-scroll-into-view")&&e.isCollapsed()&&i!==null&&i===document.activeElement){let k=e instanceof Eo&&e.anchor.type==="element"?O.childNodes[N]||null:n.rangeCount>0?n.getRangeAt(0):null;if(k!==null){let W;if(k instanceof Text){let ie=document.createRange();ie.selectNode(k),W=ie.getBoundingClientRect()}else W=k.getBoundingClientRect();id(t,W,i)}}Ad()}}function Oe(o){let e=T()||We();e===null&&(e=F().selectEnd()),e.insertNodes(o)}function Ll(o){let e=o;o.isCollapsed()||e.removeText();let t=T();_(t)&&(e=t),x(_(e),"Unexpected dirty selection to be null");let n=e.anchor,r=n.getNode(),i=n.offset;for(;!$o(r);)[r,i]=hN(r,i);return i}function hN(o,e){let t=o.getParent();if(!t){let r=I();return F().append(r),r.select(),[F(),0]}if(y(o)){let r=o.splitText(e);if(r.length===0)return[t,o.getIndexWithinParent()];let i=e===0?0:1,s=r[0].getIndexWithinParent()+i;return[t,s]}if(!E(o)||e===0)return[t,o.getIndexWithinParent()];let n=o.getChildAtIndex(e);if(n){let r=new Eo(De(o.__key,e,"element"),De(o.__key,e,"element"),0,""),i=o.insertNewAfter(r);i&&i.append(n,...n.getNextSiblings())}return[t,o.getIndexWithinParent()+1]}function NN(o){let e=I(),t=null;for(let n=0;n99&&x(!1,"One or more transforms are endlessly triggering additional transforms. May have encountered infinite recursion caused by transforms that have their preconditions too lose and/or conflict with each other.")}function je(){return ue===null&&x(!1,"Unable to find an active editor state. State helpers or node methods can only be used synchronously during the callback of editor.update(), editor.read(), or editorState.read().%s",eu()),ue}function j(){return ge===null&&x(!1,"Unable to find an active editor. This method can only be used synchronously during the callback of editor.update() or editor.read().%s",eu()),ge}function eu(){let o=0,e=new Set,t=go.version;if(typeof window<"u")for(let r of document.querySelectorAll("[contenteditable]")){let i=Ro(r);if(Tn(i))o++;else if(i){let s=String(i.constructor.version||"<0.17.1");s===t&&(s+=" (separately built, likely a bundler configuration issue)"),e.add(s)}}let n=` Detected on the page: ${o} compatible editor(s) with version ${t}`;return e.size&&(n+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),n}function tu(){return ge}function dd(){return ue}function jd(o,e,t){let n=e.__type,r=_c(o,n),i=t.get(n);i===void 0&&(i=Array.from(r.transforms),t.set(n,i));let s=i.length;for(let l=0;l0||m>0;){if(a>0){e._dirtyLeaves=new Set;for(let f of l){let d=r.get(f);y(d)&&d.isAttached()&&d.isSimpleText()&&!d.isUnmergeable()&&Vs(d),d!==void 0&&Jd(d,i)&&jd(e,d,s),t.add(f)}if(l=e._dirtyLeaves,a=l.size,a>0){yi++;continue}}e._dirtyLeaves=new Set,e._dirtyElements=new Map;for(let f of c){let d=f[0],u=f[1];if(d!=="root"&&!u)continue;let p=r.get(d);p!==void 0&&Jd(p,i)&&jd(e,p,s),n.set(d,u)}l=e._dirtyLeaves,a=l.size,c=e._dirtyElements,m=c.size,yi++}e._dirtyLeaves=t,e._dirtyElements=n}function Dl(o){return Ol(o,j()._nodes)}function Ol(o,e){let t=o.type,n=e.get(t);n===void 0&&x(!1,'parseEditorState: type "%s" + not found',t);let r=n.klass;o.type!==r.getType()&&x(!1,"LexicalNode: Node %s does not implement .importJSON().",r.name);let i=r.importJSON(o),s=o.children;if(E(i)&&Array.isArray(s))for(let l=0;l{throw new Error("Cannot call set() on a frozen Lexical node map")},e.clear=()=>{throw new Error("Cannot call clear() on a frozen Lexical node map")},e.delete=()=>{throw new Error("Cannot call delete() on a frozen Lexical node map")}}function Lt(o,e){let t=o._pendingEditorState,n=o._rootElement,r=o._headless||n===null;if(t===null)return;let i=o._editorState,s=i._selection,l=t._selection,a=o._dirtyType!==_t,c=ue,m=Ae,f=ge,d=o._updating,u=o._observer,p=null;if(o._pendingEditorState=null,o._editorState=t,!r&&a&&u!==null){ge=o,ue=t,Ae=!1,o._updating=!0;try{let O=o._dirtyType,R=o._dirtyElements,P=o._dirtyLeaves;u.disconnect(),p=xd(i,t,o,O,R,P)}catch(O){if(O instanceof Error&&o._onError(O),!vl)Rl(o,null,n,t),ni(o),o._dirtyType=zt,vl=!0,Lt(o,i),vl=!1;else throw O;return}finally{u.observe(n,Gd),o._updating=d,ue=c,Ae=m,ge=f}}t._readOnly||(t._readOnly=!0,__DEV__&&(nu(t),_(l)&&(Object.freeze(l.anchor),Object.freeze(l.focus)),Object.freeze(l)));let g=o._dirtyLeaves,h=o._dirtyElements,C=o._normalizedNodes,N=o._updateTags,L=o._deferred,M=t._nodeMap.size;a&&(o._dirtyType=_t,o._cloneNotNeeded.clear(),o._dirtyLeaves=new Set,o._dirtyElements=new Map,o._normalizedNodes=new Set,o._updateTags=new Set),ud(o,t);let S=r?null:be(o._window);if(o._editable&&S!==null&&(a||l===null||l.dirty)){ge=o,ue=t;try{if(u!==null&&u.disconnect(),a||l===null||l.dirty){let O=o._blockCursorElement;O!==null&&Er(O,o,n),Xd(s,l,o,S,N,n,M)}ad(o,n,l),u!==null&&u.observe(n,Gd)}finally{ge=f,ue=c}}p!==null&&CN(o,p,N,g,i),!_(l)&&l!==null&&(s===null||!s.is(l))&&o.dispatchCommand(we,void 0);let A=o._pendingDecorators;A!==null&&(o._decorators=A,o._pendingDecorators=null,wn("decorator",o,!0,A)),TN(o,e||i,t),wn("update",o,!0,{dirtyElements:h,dirtyLeaves:g,editorState:t,normalizedNodes:C,prevEditorState:e||i,tags:N}),bN(o,L),_N(o)}function TN(o,e,t){let n=Gs(e),r=Gs(t);n!==r&&wn("textcontent",o,!0,r)}function CN(o,e,t,n,r){let i=Array.from(o._listeners.mutation),s=i.length;for(let l=0;l{r=il(o,e,t)}),r}let n=hr(o);for(let r=4;r>=0;r--)for(let i=0;i{Lt(o)}):(c._flushSync=!1,m&&(n.clear(),o._deferred=[],o._pendingEditorState=null))}function xe(o,e,t){o._updating?o._updates.push([e,t]):ru(o,e,t)}var Z=class extends yt{constructor(e){super(e),this.__first=null,this.__last=null,this.__size=0,this.__style="",this.__dir=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__first=e.__first,this.__last=e.__last,this.__size=e.__size,this.__style=e.__style,this.__dir=e.__dir}getStyle(){return this.getLatest().__style}getChildren(){let e=[],t=this.getFirstChild();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getChildrenKeys(){let e=[],t=this.getFirstChild();for(;t!==null;)e.push(t.__key),t=t.getNextSibling();return e}getChildrenSize(){return this.getLatest().__size}isEmpty(){return this.getChildrenSize()===0}isDirty(){let t=j()._dirtyElements;return t!==null&&t.has(this.__key)}isLastChild(){let e=this.getLatest(),t=this.getParentOrThrow().getLastChild();return t!==null&&t.is(e)}getAllTextNodes(){let e=[],t=this.getFirstChild();for(;t!==null;){if(y(t)&&e.push(t),E(t)){let n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;E(e);){let t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;E(e);){let t=e.getLastChild();if(t===null)break;e=t}return e}getDescendantByIndex(e){let t=this.getChildren(),n=t.length;if(e>=n){let i=t[n-1];return E(i)&&i.getLastDescendant()||i||null}let r=t[e];return E(r)&&r.getFirstDescendant()||r||null}getFirstChild(){let t=this.getLatest().__first;return t===null?null:J(t)}getFirstChildOrThrow(){let e=this.getFirstChild();return e===null&&x(!1,"Expected node %s to have a first child.",this.__key),e}getLastChild(){let t=this.getLatest().__last;return t===null?null:J(t)}getLastChildOrThrow(){let e=this.getLastChild();return e===null&&x(!1,"Expected node %s to have a last child.",this.__key),e}getChildAtIndex(e){let t=this.getChildrenSize(),n,r;if(e=e;){if(r===e)return n;n=n.getPreviousSibling(),r--}return null}getTextContent(){let e="",t=this.getChildren(),n=t.length;for(let r=0;rn.remove()),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){let t=this.getWritable();return t.__dir=e,t}setStyle(e){let t=this.getWritable();return t.__style=e||"",this}splice(e,t,n){let r=n.length,i=this.getChildrenSize(),s=this.getWritable(),l=s.__key,a=[],c=[],m=this.getChildAtIndex(e+t),f=null,d=i-t+r;if(e!==0)if(e===i)f=this.getLastChild();else{let p=this.getChildAtIndex(e);p!==null&&(f=p.getPreviousSibling())}if(t>0){let p=f===null?this.getFirstChild():f.getNextSibling();for(let g=0;g({root:cu(F())}))}};var To=class extends Z{static getType(){return"artificial"}createDOM(e){return document.createElement("div")}};function b(o,e={},t=[]){let n=document.createElement(o),r=Object.keys(e);for(let i of r)e[i]!==null&&n.setAttribute(i,e[i]);for(let i of t)typeof i=="string"?n.append(document.createTextNode(i)):n.append(i);return n}function du(o){return new DOMParser().parseFromString(o,"text/html")}function ft(o,e="px"){return typeof o=="number"||/^-?\d+$/.test(o)?`${o}${e}`:o}function Wo(o){return/^-?\d+$/.test(o)?Number(o):/^-?\d+\.\d+$/.test(o)?Math.round(Number(o)):/^-?\d+px\s*$/.test(o)?Number(o.trim().replace("px","")):0}function vn(o){let e=new Map,n=(o.getAttribute("style")||"").split(";");for(let r of n){let[i,s]=r.split(":");!i||!s||e.set(i.trim().toLowerCase(),s.trim())}return e}function uu(o,e,t){t?o.setAttribute(e,t):o.removeAttribute(e)}var yN=["left","right","center","justify"];function vr(o){let e=o.style.textAlign||"";return yN.includes(e)?e:o.classList.contains("align-left")?"left":o.classList.contains("align-right")?"right":o.classList.contains("align-center")?"center":o.classList.contains("align-justify")?"justify":""}function SN(o){let e=o.style.paddingLeft||"0";return Wo(e)}function Dr(o){let e=(o.dir||"").toLowerCase();return e==="rtl"||e==="ltr"?e:null}function Qe(o,e){o.id&&e.setId(o.id),e.setAlignment(vr(o)),e.setInset(SN(o)),e.setDirection(Dr(o))}function wt(o,e){return o.__id!==e.__id||o.__alignment!==e.__alignment||o.__inset!==e.__inset||o.__dir!==e.__dir}function et(o,e){e.__id&&o.setAttribute("id",e.__id),e.__alignment&&o.classList.add("align-"+e.__alignment),e.__inset&&(o.style.paddingLeft=`${e.__inset}px`),e.__dir&&(o.dir=e.__dir)}function tt(o,e){e.setId(o.id),e.setAlignment(o.alignment),e.setInset(o.inset),e.setDirection(o.direction)}var vt=class extends Z{constructor(){super(...arguments);this.__id="";this.__alignment="";this.__inset=0}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}setAlignment(t){let n=this.getWritable();n.__alignment=t}getAlignment(){return this.getLatest().__alignment}setInset(t){let n=this.getWritable();n.__inset=t}getInset(){return this.getLatest().__inset}exportJSON(){return{...super.exportJSON(),id:this.__id,alignment:this.__alignment,inset:this.__inset}}};function Co(o,e){e.__alignment=o.__alignment,e.__inset=o.__inset}var dt=class o extends vt{constructor(e){super(e),this.__textStyle=""}static getType(){return"paragraph"}getTextStyle(){return this.getLatest().__textStyle}setTextStyle(e){let t=this.getWritable();return t.__textStyle=e,t}static clone(e){return new o(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__textStyle=e.__textStyle,Co(e,this)}createDOM(e){let t=document.createElement("p"),n=mo(e.theme,"paragraph");return n!==void 0&&t.classList.add(...n),et(t,this),t}updateDOM(e,t,n){return wt(e,this)}static importDOM(){return{p:e=>({conversion:LN,priority:0})}}exportDOM(e){let{element:t}=super.exportDOM(e);return t&&pe(t)&&this.isEmpty()&&t.append(document.createElement("br")),{element:t}}static importJSON(e){let t=I();return tt(e,t),t}exportJSON(){return{...super.exportJSON(),textStyle:this.getTextStyle(),type:"paragraph",version:1}}insertNewAfter(e,t){let n=I();n.setTextStyle(e.style);let r=this.getDirection();return n.setDirection(r),n.setStyle(this.getTextStyle()),this.insertAfter(n,t),n}collapseAtStart(){let e=this.getChildren();if(e.length===0||y(e[0])&&e[0].getTextContent().trim()===""){if(this.getNextSibling()!==null)return this.selectNext(),this.remove(),!0;if(this.getPreviousSibling()!==null)return this.selectPrevious(),this.remove(),!0}return!1}};function LN(o){let e=I();return Qe(o,e),{node:e}}function I(){return ne(new dt)}function ct(o){return o instanceof dt}var MN=!0,X=0,Dt=1,Li=2,qe=3,Re=4;function Rl(o,e,t,n){let r=o._keyToDOMMap;r.clear(),o._editorState=wr(),o._pendingEditorState=n,o._compositionKey=null,o._dirtyType=_t,o._cloneNotNeeded.clear(),o._dirtyLeaves=new Set,o._dirtyElements.clear(),o._normalizedNodes=new Set,o._updateTags=new Set,o._updates=[],o._blockCursorElement=null;let i=o._observer;i!==null&&(i.disconnect(),o._observer=null),e!==null&&(e.textContent=""),t!==null&&(t.textContent="",r.set("root",t))}function wN(o,e){let t=new Map,n=new Set,r=i=>{Object.keys(i).forEach(s=>{let l=t.get(s);l===void 0&&(l=[],t.set(s,l)),l.push(i[s])})};return o.forEach(i=>{let s=i.klass.importDOM;if(s==null||n.has(s))return;n.add(s);let l=s.call(i.klass);l!==null&&r(l)}),e&&r(e),t}function kl(o){let e=o||{},t=tu(),n=e.theme||{},r=o===void 0?t:e.parentEditor||null,i=e.disableEvents||!1,s=wr(),l=e.namespace||(r!==null?r._config.namespace:Js()),a=e.editorState,c=[zo,Je,Bo,Fo,dt,To,...e.nodes||[]],{onError:m,html:f}=e,d=e.editable!==void 0?e.editable:!0,u;if(o===void 0&&t!==null)u=t._nodes;else{u=new Map;for(let g=0;g{h.hasOwnProperty(P)||console.warn(`${O} must implement static "${P}" method`)}),!h.hasOwnProperty("importDOM")&&h.hasOwnProperty("exportDOM")&&console.warn(`${O} should implement "importDOM" if using a custom "exportDOM" method to ensure HTML serialization (important for copy & paste) works as expected`),R instanceof Mt&&(R.hasOwnProperty("decorate")||console.warn(`${R.constructor.name} must implement "decorate" method`)),h.hasOwnProperty("importJSON")||console.warn(`${O} should implement "importJSON" method to ensure JSON and default HTML serialization works as expected`),R.hasOwnProperty("exportJSON")||console.warn(`${O} should implement "exportJSON" method to ensure JSON and default HTML serialization works as expected`)}}let L=h.getType(),M=h.transform(),S=new Set;M!==null&&S.add(M),u.set(L,{exportDOM:f&&f.export?f.export.get(h):void 0,klass:h,replace:C,replaceWithKlass:N,transforms:S})}}let p=new go(s,r,u,{disableEvents:i,namespace:l,theme:n},m||console.error,wN(u,f?f.import:void 0),d);return a!==void 0&&(p._pendingEditorState=a,p._dirtyType=zt),p}var go=class{constructor(e,t,n,r,i,s,l){this._parentEditor=t,this._rootElement=null,this._editorState=e,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=r,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=_t,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=Js(),this._onError=i,this._htmlConversions=s,this._editable=l,this._headless=t!==null&&t._headless,this._window=null,this._blockCursorElement=null}isComposing(){return this._compositionKey!=null}registerUpdateListener(e){let t=this._listeners.update;return t.add(e),()=>{t.delete(e)}}registerEditableListener(e){let t=this._listeners.editable;return t.add(e),()=>{t.delete(e)}}registerDecoratorListener(e){let t=this._listeners.decorator;return t.add(e),()=>{t.delete(e)}}registerTextContentListener(e){let t=this._listeners.textcontent;return t.add(e),()=>{t.delete(e)}}registerRootListener(e){let t=this._listeners.root;return e(this._rootElement,null),t.add(e),()=>{e(null,this._rootElement),t.delete(e)}}registerCommand(e,t,n){n===void 0&&x(!1,'Listener for type "command" requires a "priority".');let r=this._commands;r.has(e)||r.set(e,[new Set,new Set,new Set,new Set,new Set]);let i=r.get(e);i===void 0&&x(!1,"registerCommand: Command %s not found in command map",String(e));let s=i[n];return s.add(t),()=>{s.delete(t),i.every(l=>l.size===0)&&r.delete(e)}}registerMutationListener(e,t,n){let r=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,i=this._listeners.mutation;i.set(t,r);let s=n&&n.skipInitialization;return(s===void 0?MN:s)||this.initializeMutationListener(t,r),()=>{i.delete(t)}}getRegisteredNode(e){let t=this._nodes.get(e.getType());return t===void 0&&x(!1,"Node %s has not been registered. Ensure node has been passed to createEditor.",e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){let n=this._editorState,r=cd(n).get(t.getType());if(!r)return;let i=new Map;for(let s of r.keys())i.set(s,"created");i.size>0&&e(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(e,t){let n=this.getRegisteredNode(e);return n.transforms.add(t),n}registerNodeTransform(e,t){let n=this.registerNodeTransformToKlass(e,t),r=[n],i=n.replaceWithKlass;if(i!=null){let s=this.registerNodeTransformToKlass(i,t);r.push(s)}return Mc(this,e.getType()),()=>{r.forEach(s=>s.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,t){return D(this,e,t)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(e){let t=this._rootElement;if(e!==t){let n=mo(this._config.theme,"root"),r=this._pendingEditorState||this._editorState;if(this._rootElement=e,Rl(this,t,e,r),t!==null&&(this._config.disableEvents||Od(t),n!=null&&t.classList.remove(...n)),e!==null){let i=ld(e),s=e.style;s.userSelect="text",s.whiteSpace="pre-wrap",s.wordBreak="break-word",e.setAttribute("data-lexical-editor","true"),this._window=i,this._dirtyType=zt,ni(this),this._updateTags.add("history-merge"),Lt(this),this._config.disableEvents||Dd(e,this),n!=null&&e.classList.add(...n)}else this._editorState=r,this._pendingEditorState=null,this._window=null;wn("root",this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&x(!1,"setEditorState: the editor state is empty. Ensure the editor state's root node never becomes empty."),oi(this);let n=this._pendingEditorState,r=this._updateTags,i=t!==void 0?t.tag:null;n!==null&&!n.isEmpty()&&(i!=null&&r.add(i),Lt(this)),this._pendingEditorState=e,this._dirtyType=zt,this._dirtyElements.set("root",!1),this._compositionKey=null,i!=null&&r.add(i),Lt(this)}parseEditorState(e,t){let n=typeof e=="string"?JSON.parse(e):e;return ou(n,this,t)}read(e){return Lt(this),this.getEditorState().read(e,{editor:this})}update(e,t){xe(this,e,t)}updateAndCommit(e,t){this.update(e,t),this.commitUpdates()}focus(e,t={}){let n=this._rootElement;n!==null&&(n.setAttribute("autocapitalize","off"),xe(this,()=>{let r=T(),i=F();r!==null?r.dirty=!0:i.getChildrenSize()!==0&&(t.defaultSelection==="rootStart"?i.selectStart():i.selectEnd())},{onUpdate:()=>{n.removeAttribute("autocapitalize"),e&&e()},tag:"focus"}),this._pendingEditorState===null&&n.removeAttribute("autocapitalize"))}commitUpdates(){Lt(this)}blur(){let e=this._rootElement;e!==null&&e.blur();let t=be(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,wn("editable",this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}};go.version="0.17.1";function Gt(...o){return()=>{for(let e=o.length-1;e>=0;e--)o[e]();o.length=0}}var Dn=new Map;function Il(o){let e={},t=o.split(";");for(let n of t)if(n!==""){let[r,i]=n.split(/:([^]+)/);r&&i&&(e[r.trim()]=i.trim())}return e}function On(o){let e=Dn.get(o);return e===void 0&&(e=Il(o),Dn.set(o,e)),__DEV__&&Object.freeze(e),e}function mu(o){let e="";for(let t in o)t&&(e+=`${t}: ${o[t]};`);return e}function Or(o,e){let t=o.getStartEndPoints();if(e.isSelected(o)&&!e.isSegmented()&&!e.isToken()&&t!==null){let[n,r]=t,i=o.isBackward(),s=n.getNode(),l=r.getNode(),a=e.is(s),c=e.is(l);if(a||c){let[m,f]=Mr(o),d=s.is(l),u=e.is(i?l:s),p=e.is(i?s:l),g=0,h;if(d)g=m>f?f:m,h=m>f?m:f;else if(u)g=i?f:m,h=void 0;else if(p){let C=i?m:f;g=0,h=C}return e.__text=e.__text.slice(g,h),e}}return e}function $l(o){let e=o.getStyle(),t=Il(e);Dn.set(e,t)}function An(o,e){let t=On("getStyle"in o?o.getStyle():o.style),n=Object.entries(e).reduce((i,[s,l])=>(typeof l=="function"?i[s]=l(t[s],o):l===null?delete i[s]:i[s]=l,i),{...t}),r=mu(n);o.setStyle(r),Dn.set(r,n)}function Pl(o,e){let t=o.getNodes(),n=t.length,r=o.getStartEndPoints();if(r===null)return;let[i,s]=r,l=n-1,a=t[0],c=t[l];if(o.isCollapsed()&&_(o)){An(o,e);return}let f=a.getTextContent().length,d=s.offset,u=i.offset,p=i.isBefore(s),g=p?u:d,h=p?d:u,C=p?i.type:s.type,N=p?s.type:i.type,L=p?s.key:i.key;if(y(a)&&g===f){let M=a.getNextSibling();y(M)&&(u=0,g=0,a=M)}if(t.length===1){if(y(a)&&a.canHaveFormat()){if(g=C==="element"?0:u>d?d:u,h=N==="element"?f:u>d?u:d,g===h)return;if(ze(a)||g===0&&h===f)An(a,e),a.select(g,h);else{let M=a.splitText(g,h),S=g===0?M[0]:M[1];An(S,e),S.select(0,h-g)}}}else{if(y(a)&&g0&&o.classList.add(...t)}function Di(o,...e){let t=bt(...e);t.length>0&&o.classList.remove(...t)}function Nu(o,e){let t=o;for(;t!=null;){if(t instanceof e)return t;t=t.getParent()}return null}function xu(o){let e=H(o,t=>E(t)&&!t.isInline());return E(e)||x(!1,"Expected node %s to have closest block element node.",o.__key),e}var H=(o,e)=>{let t=o;for(;t!==F()&&t!=null;){if(e(t))return t;t=t.getParent()}return null};function mt(o,e){return o!==null?Object.getPrototypeOf(o).constructor.name===e.name:!1}var Oi=0,Fl=1,Hl=2,pt=0,kN=1,Eu=2,IN=3,$N=4;function PN(o,e,t){let n=o._nodeMap,r=[];for(let i of e){let s=n.get(i);s!==void 0&&r.push(s)}for(let[i,s]of t){if(!s)continue;let l=n.get(i);l!==void 0&&!oe(l)&&r.push(l)}return r}function BN(o,e,t,n,r){if(o===null||t.size===0&&n.size===0&&!r)return pt;let i=e._selection,s=o._selection;if(r)return kN;if(!_(i)||!_(s)||!s.isCollapsed()||!i.isCollapsed())return pt;let l=PN(e,t,n);if(l.length===0)return pt;if(l.length>1){let C=e._nodeMap,N=C.get(i.anchor.key),L=C.get(s.anchor.key);return N&&L&&!o._nodeMap.has(N.__key)&&y(N)&&N.__text.length===1&&i.anchor.offset===1?Eu:pt}let a=l[0],c=o._nodeMap.get(a.__key);if(!y(c)||!y(a)||c.__mode!==a.__mode)return pt;let m=c.__text,f=a.__text;if(m===f)return pt;let d=i.anchor,u=s.anchor;if(d.key!==u.key||d.type!=="text")return pt;let p=d.offset,g=u.offset,h=f.length-m.length;return h===1&&g===p-1?Eu:h===-1&&g===p+1?IN:h===-1&&g===p?$N:pt}function FN(o,e,t){let n=e._nodeMap.get(o),r=t._nodeMap.get(o),i=e._selection,s=t._selection;return!(_(i)&&_(s)&&i.anchor.type==="element"&&i.focus.type==="element"&&s.anchor.type==="text"&&s.focus.type==="text")&&y(n)&&y(r)&&n.__parent===r.__parent?JSON.stringify(e.read(()=>n.exportJSON()))===JSON.stringify(t.read(()=>r.exportJSON())):!1}function HN(o,e){let t=Date.now(),n=pt;return(r,i,s,l,a,c)=>{let m=Date.now();if(c.has("historic"))return n=pt,t=m,Hl;let f=BN(r,i,l,a,o.isComposing()),d=(()=>{let u=s===null||s.editor===o,p=c.has("history-push");if(!p&&u&&c.has("history-merge"))return Oi;if(r===null)return Fl;let h=i._selection;if(!(l.size>0||a.size>0))return h!==null?Oi:Hl;if(p===!1&&f!==pt&&f===n&&m{let f=e.current,d=e.redoStack,u=e.undoStack,p=f===null?null:f.editorState;if(f!==null&&s===p)return;let g=n(l,s,f,a,c,m);if(g===Fl)d.length!==0&&(e.redoStack=[],o.dispatchCommand(ao,!1)),f!==null&&(u.push({...f}),o.dispatchCommand(co,!0));else if(g===Hl)return;e.current={editor:o,editorState:s}};return Gt(o.registerCommand(ro,()=>(UN(o,e),!0),X),o.registerCommand(io,()=>(KN(o,e),!0),X),o.registerCommand(Is,()=>(Tu(e),!1),X),o.registerCommand($s,()=>(Tu(e),o.dispatchCommand(ao,!1),o.dispatchCommand(co,!1),!0),X),o.registerUpdateListener(r))}function _u(){return{current:null,redoStack:[],undoStack:[]}}function Ai(o,e){let t=e.body?e.body.childNodes:[],n=[],r=[];for(let i=0;i"u"||typeof window>"u"&&typeof global.window>"u")throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");let t=document.createElement("div"),r=F().getChildren();for(let i=0;i{let p=new To;return t.push(p),p}):d=bu(o,d,I)),l==null?d.length>0?s=s.concat(d):po(o)&&qN(o)&&(s=s.concat(ut())):E(l)&&l.append(...d),s}function bu(o,e,t){let n=[],r=[];for(let i=0;ife?(o||window).getSelection():null;function vu(o,e=T()){return e==null&&x(!1,"Expected valid LexicalSelection"),_(e)&&e.isCollapsed()||e.getNodes().length===0?"":Ri(o,e)}function Du(o,e=T()){return e==null&&x(!1,"Expected valid LexicalSelection"),_(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(Au(o,e))}function ki(o,e,t){let n=o.getData("application/x-lexical-editor");if(n)try{let s=JSON.parse(n);if(s.namespace===t._config.namespace&&Array.isArray(s.nodes)){let l=Ru(s.nodes);return Kl(t,l,e)}}catch{}let r=o.getData("text/html");if(r)try{let l=new DOMParser().parseFromString(r,"text/html"),a=Ai(t,l);return Kl(t,a,e)}catch{}let i=o.getData("text/plain")||o.getData("text/uri-list");if(i!=null)if(_(e)){let s=i.split(/(\r?\n|\t)/);s[s.length-1]===""&&s.pop();for(let l=0;l0?a.text=c:r=!1}for(let c=0;c{o.update(()=>{a(Mu(o,e,t))})});let n=o.getRootElement(),r=o._window==null?window.document:o._window.document,i=wu(o._window);if(n===null||i===null)return!1;let s=r.createElement("span");s.style.cssText="position: fixed; top: -1000px;",s.append(r.createTextNode("#")),n.append(s);let l=new Range;return l.setStart(s,0),l.setEnd(s,1),i.removeAllRanges(),i.addRange(l),new Promise((a,c)=>{let m=o.registerCommand(so,f=>(mt(f,ClipboardEvent)&&(m(),Rn!==null&&(window.clearTimeout(Rn),Rn=null),a(Mu(o,f,t))),!0),Re);Rn=window.setTimeout(()=>{m(),Rn=null,a(!1)},ZN),r.execCommand("copy"),s.remove()})}function Mu(o,e,t){if(t===void 0){let r=wu(o._window);if(!r)return!1;let i=r.anchorNode,s=r.focusNode;if(i!==null&&s!==null&&!Wt(o,i,s))return!1;let l=T();if(l===null)return!1;t=Ii(l)}e.preventDefault();let n=e.clipboardData;return n===null?!1:(ku(n,t),!0)}var VN=[["text/html",vu],["application/x-lexical-editor",Du]];function Ii(o=T()){let e={"text/plain":o?o.getTextContent():""};if(o){let t=nl();for(let[n,r]of VN){let i=r(t,o);i!==null&&(e[n]=i)}}return e}function ku(o,e){for(let t in e){let n=e[t];n!==void 0&&o.setData(t,n)}}function $i(o,e){if(typeof document.caretRangeFromPoint<"u"){let t=document.caretRangeFromPoint(o,e);return t===null?null:{node:t.startContainer,offset:t.startOffset}}else if(document.caretPositionFromPoint!=="undefined"){let t=document.caretPositionFromPoint(o,e);return t===null?null:{node:t.offsetNode,offset:t.offset}}else return null}var Iu=$("DRAG_DROP_PASTE_FILE");function XN(o,e){o.preventDefault(),e.update(()=>{let t=T(),n=mt(o,InputEvent)||mt(o,KeyboardEvent)?null:o.clipboardData;n!=null&&t!==null&&ki(n,t,e)},{tag:"paste"})}async function GN(o,e){await kn(e,mt(o,ClipboardEvent)?o:null),e.update(()=>{let t=T();_(t)?t.removeText():Se(t)&&t.getNodes().forEach(n=>n.remove())})}function Pi(o){let e=null;if(mt(o,DragEvent)?e=o.dataTransfer:mt(o,ClipboardEvent)&&(e=o.clipboardData),e===null)return[!1,[],!1];let t=e.types,n=t.includes("Files"),r=t.includes("text/html")||t.includes("text/plain");return[n,Array.from(e.files),r]}function Bi(o){let e=ee(o);return B(e)}function jN(o){let e=o.focus;return e.key==="root"&&e.offset===F().getChildrenSize()}function $u(o){return Gt(o.registerCommand(tr,t=>{let n=T();return Se(n)?(n.clear(),!0):!1},0),o.registerCommand(Ze,t=>{let n=T();return _(n)?(n.deleteCharacter(t),!0):!1},X),o.registerCommand(Tt,t=>{let n=T();return _(n)?(n.deleteWord(t),!0):!1},X),o.registerCommand(it,t=>{let n=T();return _(n)?(n.deleteLine(t),!0):!1},X),o.registerCommand(rt,t=>{let n=T();if(typeof t=="string")n!==null&&n.insertText(t);else{if(n===null)return!1;let r=t.dataTransfer;if(r!=null)ki(r,n,o);else if(_(n)){let i=t.data;return i&&n.insertText(i),!0}}return!0},X),o.registerCommand(cn,()=>{let t=T();return _(t)?(t.removeText(),!0):!1},X),o.registerCommand(Ne,t=>{let n=T();return _(n)?(n.formatText(t),!0):!1},X),o.registerCommand($t,t=>{let n=T();return _(n)?(n.insertLineBreak(t),!0):!1},X),o.registerCommand(Pt,()=>{let t=T();return _(t)?(t.insertParagraph(),!0):!1},X),o.registerCommand(Rs,()=>(Oe([St()]),!0),X),o.registerCommand(wo,t=>{let n=T();if(Se(n)&&!Bi(t.target)){let r=n.getNodes();if(r.length>0)return r[0].selectPrevious(),!0}else if(_(n)){let r=Yt(n.focus,!0);if(!t.shiftKey&&B(r)&&!r.isIsolated()&&!r.isInline())return r.selectPrevious(),t.preventDefault(),!0}return!1},X),o.registerCommand(Bt,t=>{let n=T();if(Se(n)){let r=n.getNodes();if(r.length>0)return r[0].selectNext(0,0),!0}else if(_(n)){if(jN(n))return t.preventDefault(),!0;let r=Yt(n.focus,!1);if(!t.shiftKey&&B(r)&&!r.isIsolated()&&!r.isInline())return r.selectNext(),t.preventDefault(),!0}return!1},X),o.registerCommand(Mo,t=>{let n=T();if(Se(n)){let r=n.getNodes();if(r.length>0)return t.preventDefault(),r[0].selectPrevious(),!0}if(!_(n))return!1;if(wi(n,!0)){let r=t.shiftKey;return t.preventDefault(),vi(n,r,!0),!0}return!1},X),o.registerCommand(Lo,t=>{let n=T();if(Se(n)&&!Bi(t.target)){let i=n.getNodes();if(i.length>0)return t.preventDefault(),i[0].selectNext(0,0),!0}if(!_(n))return!1;let r=t.shiftKey;return wi(n,!1)?(t.preventDefault(),vi(n,r,!1),!0):!1},X),o.registerCommand(Ft,t=>{if(Bi(t.target))return!1;let n=T();return _(n)?(t.preventDefault(),o.dispatchCommand(Ze,!0)):!1},X),o.registerCommand(Ht,t=>{if(Bi(t.target))return!1;let n=T();return _(n)?(t.preventDefault(),o.dispatchCommand(Ze,!1)):!1},X),o.registerCommand(Fe,t=>{let n=T();if(!_(n))return!1;if(t!==null){if((Ct||Kt||Ut)&&uo)return!1;if(t.preventDefault(),t.shiftKey)return o.dispatchCommand($t,!1)}return o.dispatchCommand(Pt,void 0)},X),o.registerCommand(vo,()=>{let t=T();return _(t)?(o.blur(),!0):!1},X),o.registerCommand(Oo,t=>{let[,n]=Pi(t);if(n.length>0){let i=t.clientX,s=t.clientY,l=$i(i,s);if(l!==null){let{offset:a,node:c}=l,m=ee(c);if(m!==null){let f=Uo();if(y(m))f.anchor.set(m.getKey(),a,"text"),f.focus.set(m.getKey(),a,"text");else{let u=m.getParentOrThrow().getKey(),p=m.getIndexWithinParent()+1;f.anchor.set(u,p,"element"),f.focus.set(u,p,"element")}let d=Ao(f);Y(d)}o.dispatchCommand(Iu,n)}return t.preventDefault(),!0}let r=T();return!!_(r)},X),o.registerCommand(nr,t=>{let[n]=Pi(t),r=T();return!(n&&!_(r))},X),o.registerCommand(rr,t=>{let[n]=Pi(t),r=T();if(n&&!_(r))return!1;let i=t.clientX,s=t.clientY,l=$i(i,s);if(l!==null){let a=ee(l.node);B(a)&&t.preventDefault()}return!0},X),o.registerCommand(dn,()=>(tl(),!0),X),o.registerCommand(so,t=>(kn(o,mt(t,ClipboardEvent)?t:null),!0),X),o.registerCommand(lo,t=>(GN(t,o),!0),X),o.registerCommand(no,t=>{let[,n,r]=Pi(t);return n.length>0&&!r?(o.dispatchCommand(Iu,n),!0):En(t.target)?!1:T()!==null?(XN(t,o),!0):!1},X))}var qo=class o extends Z{constructor(t,n){super(n);this.__id="";this.__category="info";this.__alignment="";this.__inset=0;this.__category=t}static getType(){return"callout"}static clone(t){let n=new o(t.__category,t.__key);return n.__id=t.__id,n.__alignment=t.__alignment,n.__inset=t.__inset,n}setCategory(t){let n=this.getWritable();n.__category=t}getCategory(){return this.getLatest().__category}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}setAlignment(t){let n=this.getWritable();n.__alignment=t}getAlignment(){return this.getLatest().__alignment}setInset(t){let n=this.getWritable();n.__inset=t}getInset(){return this.getLatest().__inset}createDOM(t,n){let r=document.createElement("p");return r.classList.add("callout",this.__category||""),et(r,this),r}updateDOM(t){return t.__category!==this.__category||wt(t,this)}insertNewAfter(t,n){let r=t?t.anchor.offset:0,i=r===this.getTextContentSize()||!t?I():In(this.__category);if(i.setDirection(this.getDirection()),this.insertAfter(i,n),r===0&&!this.isEmpty()&&t){let s=I();s.select(),this.replace(s,!0)}return i}static importDOM(){return{p(t){return t.classList.contains("callout")?{conversion:n=>{let r="info",i=["info","success","warning","danger"];for(let l of i)if(n.classList.contains(l)){r=l;break}let s=new o(r);return Qe(n,s),{node:s}},priority:3}:null}}}exportJSON(){return{...super.exportJSON(),type:"callout",version:1,category:this.__category,id:this.__id,alignment:this.__alignment,inset:this.__inset}}static importJSON(t){let n=In(t.category);return tt(t,n),n}};function In(o="info"){return new qo(o)}function Ul(o){return o instanceof qo}function zl(o,e="info"){return o instanceof qo&&o.getCategory()===e}var JN=new Set(["http:","https:","mailto:","sms:","tel:"]),$n=class o extends Z{static getType(){return"link"}static clone(e){return new o(e.__url,{rel:e.__rel,target:e.__target,title:e.__title},e.__key)}constructor(e,t={},n){super(n);let{target:r=null,rel:i=null,title:s=null}=t;this.__url=e,this.__target=r,this.__rel=i,this.__title=s}createDOM(e){let t=document.createElement("a");return t.href=this.sanitizeUrl(this.__url),this.__target!==null&&(t.target=this.__target),this.__rel!==null&&(t.rel=this.__rel),this.__title!==null&&(t.title=this.__title),Te(t,e.theme.link),t}updateDOM(e,t,n){if(t instanceof HTMLAnchorElement){let r=this.__url,i=this.__target,s=this.__rel,l=this.__title;r!==e.__url&&(t.href=r),i!==e.__target&&(i?t.target=i:t.removeAttribute("target")),s!==e.__rel&&(s?t.rel=s:t.removeAttribute("rel")),l!==e.__title&&(l?t.title=l:t.removeAttribute("title"))}return!1}static importDOM(){return{a:e=>({conversion:QN,priority:1})}}static importJSON(e){let t=gt(e.url,{rel:e.rel,target:e.target,title:e.title});return t.setDirection(e.direction),t}sanitizeUrl(e){try{let t=new URL(e);if(!JN.has(t.protocol))return"about:blank"}catch{return e}return e}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),type:"link",url:this.getURL(),version:1}}getURL(){return this.getLatest().__url}setURL(e){let t=this.getWritable();t.__url=e}getTarget(){return this.getLatest().__target}setTarget(e){let t=this.getWritable();t.__target=e}getRel(){return this.getLatest().__rel}setRel(e){let t=this.getWritable();t.__rel=e}getTitle(){return this.getLatest().__title}setTitle(e){let t=this.getWritable();t.__title=e}insertNewAfter(e,t=!0){let n=gt(this.__url,{rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(n,t),n}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,t,n){if(!_(t))return!1;let r=t.anchor.getNode(),i=t.focus.getNode();return this.isParentOf(r)&&this.isParentOf(i)&&t.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}};function QN(o){let e=null;if(fi(o)){let t=o.textContent;(t!==null&&t!==""||o.children.length>0)&&(e=gt(o.getAttribute("href")||"",{rel:o.getAttribute("rel"),target:o.getAttribute("target"),title:o.getAttribute("title")}))}return{node:e}}function gt(o,e){return ne(new $n(o,e))}function Ot(o){return o instanceof $n}var $S=$("TOGGLE_LINK_COMMAND");function ex(o){return o.map(e=>{if(y(e)){let t=I();return t.append(e),t}return e})}function _o(o,e){let t=du(e),n=Ai(o,t);return ex(n)}function At(o,e){for(let t of o.getParents())if(e(t))return t;return null}function Wl(o,e){e||(e=F());let t=[];for(let n of e.getChildren())o(n)&&t.push(n),E(n)&&t.push(...Wl(o,n));return t}function Pu(o,e,t){let n=F().getChildren();for(let r of n){let i=o.getElementByKey(r.__key);if(!i)continue;let s=i.getBoundingClientRect();if(t<=s.bottom)return r}return null}function Pn(o){let e=t=>(E(t)||B(t))&&!t.isInline()&&!oe(t);return e(o)?o:H(o,e)}function Ar(o){return"__alignment"in o}function Bu(o){return"__inset"in o}var Fu=new WeakMap;function le(o){return Fu.get(o)||null}function Hu(o,e){Fu.set(o,e)}function ae(o,e){return V(o,e)!==null}function V(o,e){if(!o)return null;for(let t of o.getNodes()){if(e(t))return t;let n=At(t,e);if(n)return n}return null}function Ku(o){return V(o,y)}function Uu(o,e){if(!o)return!1;for(let t of o.getNodes())if(y(t)&&t.hasFormat(e))return!0;return!1}function Bn(o,e){let t=T(),n=t?xu(t.getNodes()[0]):null;t&&o(n)?Mi(t,I):Mi(t,e)}function Yo(o,e=!0){ql([o],e)}function ql(o,e=!0){let t=T()?.getNodes()||[],n=t.length>0?Pn(t[0]):null;if(n)if(e)for(let r=o.length-1;r>=0;r--)n.insertAfter(o[r]);else for(let r of o)n.insertBefore(r);else F().append(...o)}function ke(o){let e=Ho();e.add(o.getKey()),Y(e)}function zu(o){for(let e of o){if(y(e))return e;if(E(e)){let t=e.getChildren(),n=zu(t);if(n!==null)return n}}return null}function Wu(o){let e=[...o].reverse();for(let t of e){if(y(t))return t;if(E(t)){let n=[...t.getChildren()].reverse(),r=Wu(n);if(r!==null)return r}}return null}function qu(o){if(o.length===0)return;let e=Uo(),t=zu(o),n=Wu(o);t&&n&&(e.setTextNodeRange(t,0,n,n.getTextContentSize()||0),Y(e))}function Yu(o){let e=le(o);e&&window.requestAnimationFrame(()=>{o.update(()=>{Y(e.clone())})})}function Fi(o,e){if(!o)return!1;let t=e.getKey();for(let n of o.getNodes())if(n.getKey()===t)return!0;return!1}function Rr(o,e){let t=[...o?.getNodes()||[],...Rt(o)];for(let n of t)if(Ar(n)&&n.getAlignment()===e)return!0;return!1}function Yl(o,e){let t=[...o?.getNodes()||[],...Rt(o)];for(let n of t)if(Ko(n)&&n.getDirection()===e)return!0;return!1}function Rt(o){if(!o)return[];let e=new Map;for(let t of o.getNodes()){let n=Pn(t);E(n)&&e.set(n.getKey(),n)}return Array.from(e.values())}var Zo=class o extends Z{constructor(t,n,r){super(r);this.__src="";this.__alt="";this.__width=0;this.__height=0;this.__alignment="";this.__src=t,n.alt&&(this.__alt=n.alt),n.width&&(this.__width=n.width),n.height&&(this.__height=n.height)}static getType(){return"image"}static clone(t){let n=new o(t.__src,{alt:t.__alt,width:t.__width,height:t.__height},t.__key);return n.__alignment=t.__alignment,n}setSrc(t){let n=this.getWritable();n.__src=t}getSrc(){return this.getLatest().__src}setAltText(t){let n=this.getWritable();n.__alt=t}getAltText(){return this.getLatest().__alt}setHeight(t){let n=this.getWritable();n.__height=t}getHeight(){return this.getLatest().__height}setWidth(t){let n=this.getWritable();n.__width=t}getWidth(){return this.getLatest().__width}setAlignment(t){let n=this.getWritable();n.__alignment=t}getAlignment(){return this.getLatest().__alignment}isInline(){return!0}createDOM(t,n){let r=document.createElement("img");return r.setAttribute("src",this.__src),this.__width&&r.setAttribute("width",String(this.__width)),this.__height&&r.setAttribute("height",String(this.__height)),this.__alt&&r.setAttribute("alt",this.__alt),this.__alignment&&r.classList.add("align-"+this.__alignment),r.addEventListener("click",i=>{n.update(()=>{ke(this)})}),r}updateDOM(t,n){return t.__src!==this.__src&&n.setAttribute("src",this.__src),t.__width!==this.__width&&(this.__width?n.setAttribute("width",String(this.__width)):n.removeAttribute("width")),t.__height!==this.__height&&(this.__height?n.setAttribute("height",String(this.__height)):n.removeAttribute("height")),t.__alt!==this.__alt&&(this.__alt?n.setAttribute("alt",String(this.__alt)):n.removeAttribute("alt")),t.__alignment!==this.__alignment&&(t.__alignment&&n.classList.remove("align-"+t.__alignment),this.__alignment&&n.classList.add("align-"+this.__alignment)),!1}static importDOM(){return{img(t){return{conversion:n=>{let r=n.getAttribute("src")||"",i={alt:n.getAttribute("alt")||"",height:Number.parseInt(n.getAttribute("height")||"0"),width:Number.parseInt(n.getAttribute("width")||"0")},s=new o(r,i);return s.setAlignment(vr(n)),{node:s}},priority:3}}}}exportJSON(){return{...super.exportJSON(),type:"image",version:1,src:this.__src,alt:this.__alt,height:this.__height,width:this.__width,alignment:this.__alignment}}static importJSON(t){let n=Fn(t.src,{alt:t.alt,width:t.width,height:t.height});return n.setAlignment(t.alignment),n}};function Fn(o,e={}){return new Zo(o,e)}function ht(o){return o instanceof Zo}var Hn=class o extends Z{constructor(){super(...arguments);this.__id="";this.__summary="";this.__open=!1}static getType(){return"details"}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}setSummary(t){let n=this.getWritable();n.__summary=t}getSummary(){return this.getLatest().__summary}setOpen(t){let n=this.getWritable();n.__open=t}getOpen(){return this.getLatest().__open}static clone(t){let n=new o(t.__key);return n.__id=t.__id,n.__dir=t.__dir,n.__summary=t.__summary,n.__open=t.__open,n}createDOM(t,n){let r=document.createElement("details");this.__id&&r.setAttribute("id",this.__id),this.__dir&&r.setAttribute("dir",this.__dir),this.__open&&r.setAttribute("open","true");let i=document.createElement("summary");return i.textContent=this.__summary,i.setAttribute("contenteditable","false"),i.addEventListener("click",s=>{s.preventDefault(),n.update(()=>{this.select()})}),r.append(i),r}updateDOM(t,n){return t.__open!==this.__open&&n.toggleAttribute("open",this.__open),t.__id!==this.__id||t.__dir!==this.__dir||t.__summary!==this.__summary}static importDOM(){return{details(t){return{conversion:n=>{let r=new o;n.id&&r.setId(n.id),n.dir&&r.setDirection(Dr(n));let i=Array.from(n.children).find(s=>s.nodeName==="SUMMARY");return r.setSummary(i?.textContent||""),{node:r}},priority:3}},summary(t){return{conversion:n=>({node:"ignore"}),priority:3}}}}exportDOM(t){let n=this.createDOM(t._config,t),r=n.querySelectorAll("[contenteditable]");for(let i of r)i.removeAttribute("contenteditable");return n.removeAttribute("open"),{element:n}}exportJSON(){return{...super.exportJSON(),type:"details",version:1,id:this.__id,summary:this.__summary}}static importJSON(t){let n=Zl();return n.setId(t.id),n.setDirection(t.direction),n}};function Zl(){return new Hn}function Ie(o){return o instanceof Hn}function Vl(o){let e=1,t=o.getParent();for(;t!=null;){if(G(t)){let n=t.getParent();if(U(n)){e++,t=n.getParent();continue}x(!1,"A ListItemNode must have a ListNode for a parent.")}return e}return e}function Xl(o){let e=o.getParent();U(e)||x(!1,"A ListItemNode must have a ListNode for a parent.");let t=e;for(;t!==null;)t=t.getParent(),U(t)&&(e=t);return e}function Gl(o){let e=[],t=o.getChildren().filter(G);for(let n=0;n{let t=T();if(t!==null){let n=t.getNodes();if(_(t)){let i=t.getStartEndPoints();x(i!==null,"insertList: anchor should be defined");let[s]=i,l=s.getNode(),a=l.getParent();if(Xu(l,n)){let c=Ce(e);if(me(a)){l.replace(c);let m=$e();c.append(m)}else if(G(l)){let m=l.getParentOrThrow();kr(c,m.getChildren()),m.replace(c)}return}}let r=new Set;for(let i=0;i0&&o.append(...r),e.remove()}function Jl(o){o.update(()=>{let e=T();if(_(e)){let t=new Set,n=e.getNodes(),r=e.anchor.getNode();if(Xu(r,n))t.add(Xl(r));else for(let i=0;i{if(x(G(e),"node is not a ListItemNode"),e.__checked==null)return;let t=e.getParent();U(t)&&t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:tx,priority:0})}}static importJSON(e){let t=$e();return t.setChecked(e.checked),t.setValue(e.value),t.setDirection(e.direction),t}exportDOM(e){let t=this.createDOM(e._config);if(t.classList.contains("task-list-item")){let n=b("input",{type:"checkbox",disabled:"disabled"});t.hasAttribute("checked")&&(n.setAttribute("checked","checked"),t.removeAttribute("checked")),t.prepend(n)}return{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(),version:1}}append(...e){for(let t=0;t{e.append(r)})),this.remove(),n.getChildrenSize()===0&&n.remove(),e}insertAfter(e,t=!0){let n=this.getParentOrThrow();if(U(n)||x(!1,"insertAfter: list node is not parent of list item node"),G(e))return super.insertAfter(e,t);let r=this.getNextSiblings();if(n.insertAfter(e,t),r.length!==0){let i=Ce(n.getListType());r.forEach(s=>i.append(s)),e.insertAfter(i,t)}return e}remove(e){let t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&Kn(t)&&Kn(n)&&(Hi(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){if(this.getTextContent().trim()===""&&this.isLastChild()){let r=this.getParentOrThrow(),i=r.getParent();if(G(i))return i.insertAfter(this),this.selectStart(),null;{let s=I();return r.insertAfter(s,t),this.remove(),s}}let n=$e(this.__checked==null?void 0:!1);return this.insertAfter(n,t),n}collapseAtStart(e){let t=I();this.getChildren().forEach(l=>t.append(l));let r=this.getParentOrThrow(),i=r.getParentOrThrow(),s=G(i);if(r.getChildrenSize()===1)if(s)r.remove(),i.select();else{r.insertBefore(t),r.remove();let l=e.anchor,a=e.focus,c=t.getKey();l.type==="element"&&l.getNode().is(this)&&l.set(c,l.offset,"element"),a.type==="element"&&a.getNode().is(this)&&a.set(c,a.offset,"element")}else r.insertBefore(t),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){let t=this.getWritable();t.__value=e}getChecked(){let e=this.getLatest(),t,n=this.getParent();return U(n)&&(t=n.getListType()),t==="check"?!!e.__checked:void 0}setChecked(e){let t=this.getWritable();t.__checked=e}toggleChecked(){this.setChecked(!this.__checked)}canInsertAfter(e){return G(e)}canReplaceWith(e){return G(e)}canMergeWith(e){return ct(e)||G(e)}extractWithChild(e,t){if(!_(t))return!1;let n=t.anchor.getNode(),r=t.focus.getNode();return this.isParentOf(n)&&this.isParentOf(r)&&this.getTextContent().length===t.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return Ce("bullet")}canMergeWhenEmpty(){return!0}};function Ju(o){let e=o.getChildren(),t=!1,n=!1;for(let r of e)U(r)?n=!0:r.getTextContent().trim().length>0&&(t=!0);return n&&!t}function Qu(o,e){let t=!U(e.getFirstChild());o.classList.toggle("task-list-item",t),e.__checked?o.setAttribute("checked","checked"):o.removeAttribute("checked")}function tx(o){if(o.classList.contains("task-list-item")){for(let r of o.children)if(r.tagName==="INPUT")return ox(r)}let t=o.getAttribute("aria-checked");return{node:$e(t==="true"?!0:t==="false"?!1:void 0)}}function ox(o){if(!(o.getAttribute("type")==="checkbox"))return{node:null};let t=o.hasAttribute("checked");return{node:$e(t)}}function $e(o){return ne(new jt(void 0,o))}function G(o){return o instanceof jt}var Vo=class o extends Z{constructor(t,n,r){super(r);this.__id="";let i=ix[t]||t;this.__listType=i,this.__tag=i==="number"?"ol":"ul",this.__start=n}static getType(){return"list"}static clone(t){let n=new o(t.__listType,t.__start,t.__key);return n.__id=t.__id,n.__dir=t.__dir,n}getTag(){return this.__tag}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}setListType(t){let n=this.getWritable();n.__listType=t,n.__tag=t==="number"?"ol":"ul"}getListType(){return this.__listType}getStart(){return this.__start}createDOM(t,n){let r=this.__tag,i=document.createElement(r);return this.__start!==1&&i.setAttribute("start",String(this.__start)),i.__lexicalListType=this.__listType,ef(i,t.theme,this),this.__id&&i.setAttribute("id",this.__id),this.__dir&&i.setAttribute("dir",this.__dir),i}updateDOM(t,n,r){return t.__tag!==this.__tag||t.__dir!==this.__dir||t.__id!==this.__id?!0:(ef(n,r.theme,this),!1)}static transform(){return t=>{x(U(t),"node is not a ListNode"),ju(t),Gu(t)}}static importDOM(){return{ol:()=>({conversion:tf,priority:0}),ul:()=>({conversion:tf,priority:0})}}static importJSON(t){let n=Ce(t.listType,t.start);return n.setId(t.id),n.setDirection(t.direction),n}exportDOM(t){let{element:n}=super.exportDOM(t);return n&&pe(n)&&(this.__start!==1&&n.setAttribute("start",String(this.__start)),this.__listType==="check"&&n.setAttribute("__lexicalListType","check")),{element:n}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag(),type:"list",version:1,id:this.__id}}canBeEmpty(){return!1}canIndent(){return!1}append(...t){for(let n=0;n1?n.push(...p):r.push(...p)}}r.length>0&&Di(o,...r),n.length>0&&Te(o,...n)}function nx(o){let e=[];for(let t of o)G(t)?e.push(t):e.push(Zu(t));return e}function rx(o){if(o.getAttribute("__lexicallisttype")==="check"||o.classList.contains("contains-task-list"))return!0;for(let e of o.childNodes)if(pe(e)&&e.hasAttribute("aria-checked"))return!0;return!1}function tf(o){let e=o.nodeName.toLowerCase(),t=null;if(e==="ol"){let n=o.start;t=Ce("number",n)}else e==="ul"&&(rx(o)?t=Ce("check"):t=Ce("bullet"));return o.id&&t&&t.setId(o.id),o.dir&&t&&t.setDirection(Dr(o)),{after:nx,node:t}}var ix={ol:"number",ul:"bullet"};function Ce(o,e=1){return ne(new Vo(o,e))}function U(o){return o instanceof Vo}var ML=$("INSERT_UNORDERED_LIST_COMMAND"),wL=$("INSERT_ORDERED_LIST_COMMAND"),vL=$("INSERT_CHECK_LIST_COMMAND"),DL=$("REMOVE_LIST_COMMAND");var re={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1},Jt=class o extends Z{constructor(t=re.NO_STATUS,n=1,r,i){super(i);this.__styles=new Map;this.__alignment="";this.__colSpan=n,this.__rowSpan=1,this.__headerState=t,this.__width=r,this.__backgroundColor=null}static getType(){return"tablecell"}static clone(t){let n=new o(t.__headerState,t.__colSpan,t.__width,t.__key);return n.__rowSpan=t.__rowSpan,n.__backgroundColor=t.__backgroundColor,n.__styles=new Map(t.__styles),n.__alignment=t.__alignment,n}static importDOM(){return{td:t=>({conversion:of,priority:0}),th:t=>({conversion:of,priority:0})}}static importJSON(t){let n=Pe(t.headerState,t.colSpan,t.width);return t.rowSpan&&n.setRowSpan(t.rowSpan),n.setStyles(new Map(Object.entries(t.styles))),n.setAlignment(t.alignment),n}createDOM(t){let n=document.createElement(this.getTag());this.__width&&(n.style.width=`${this.__width}px`),this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),this.__backgroundColor!==null&&(n.style.backgroundColor=this.__backgroundColor),Te(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader);for(let[r,i]of this.__styles.entries())n.style.setProperty(r,i);return this.__alignment&&n.classList.add("align-"+this.__alignment),n}exportDOM(t){let{element:n}=super.exportDOM(t);return{element:n}}exportJSON(){return{...super.exportJSON(),backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,type:"tablecell",width:this.getWidth(),styles:Object.fromEntries(this.__styles),alignment:this.__alignment}}getColSpan(){return this.__colSpan}setColSpan(t){return this.getWritable().__colSpan=t,this}getRowSpan(){return this.__rowSpan}setRowSpan(t){return this.getWritable().__rowSpan=t,this}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(t){let n=this.getWritable();return n.__headerState=t,this.__headerState}getHeaderStyles(){return this.getLatest().__headerState}setWidth(t){let n=this.getWritable();return n.__width=t,this.__width}getWidth(){return this.getLatest().__width}clearWidth(){let t=this.getWritable();t.__width=void 0}getStyles(){let t=this.getLatest();return new Map(t.__styles)}setStyles(t){let n=this.getWritable();n.__styles=new Map(t)}setAlignment(t){let n=this.getWritable();n.__alignment=t}getAlignment(){return this.getLatest().__alignment}updateTag(t){let r=t.toLowerCase()==="th"?re.ROW:re.NO_STATUS,i=this.getWritable();i.__headerState=r}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(t){this.getWritable().__backgroundColor=t}toggleHeaderStyle(t){let n=this.getWritable();return(n.__headerState&t)===t?n.__headerState-=t:n.__headerState+=t,n}hasHeaderState(t){return(this.getHeaderStyles()&t)===t}hasHeader(){return this.getLatest().__headerState!==re.NO_STATUS}updateDOM(t){return t.__headerState!==this.__headerState||t.__width!==this.__width||t.__colSpan!==this.__colSpan||t.__rowSpan!==this.__rowSpan||t.__backgroundColor!==this.__backgroundColor||t.__styles!==this.__styles||t.__alignment!==this.__alignment}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}};function of(o){let e=o,t=o.nodeName.toLowerCase(),n;/^(\d+(?:\.\d+)?)px$/.test(e.style.width)&&(n=parseFloat(e.style.width));let i=Pe(t==="th"?re.ROW:re.NO_STATUS,e.colSpan,n);i.__rowSpan=e.rowSpan;let s=e.style,l=s.textDecoration.split(" "),a=s.fontWeight==="700"||s.fontWeight==="bold",c=l.includes("line-through"),m=s.fontStyle==="italic",f=l.includes("underline");return o instanceof HTMLElement&&(i.setStyles(vn(o)),i.setAlignment(vr(o))),{after:d=>(d.length===0&&d.push(I()),d),forChild:(d,u)=>{if(v(u)&&!E(d)){let p=I();return ve(d)&&d.getTextContent()===`
-`?null:(y(d)&&(a&&d.toggleFormat("bold"),c&&d.toggleFormat("strikethrough"),m&&d.toggleFormat("italic"),f&&d.toggleFormat("underline")),p.append(d),p)}return d},node:i}}function Pe(o=re.NO_STATUS,e=1,t){return ne(new Jt(o,e,t))}function v(o){return o instanceof Jt}var sx=$("INSERT_TABLE_COMMAND");var Qt=class o extends Z{constructor(t){super(t);this.__styles=new Map}static getType(){return"tablerow"}static clone(t){let n=new o(t.__key);return n.__styles=new Map(t.__styles),n}static importDOM(){return{tr:t=>({conversion:lx,priority:0})}}static importJSON(t){let n=Xo();return n.setStyles(new Map(Object.entries(t.styles))),n}exportJSON(){return{...super.exportJSON(),type:"tablerow",version:1,styles:Object.fromEntries(this.__styles),height:this.__height||0}}createDOM(t){let n=document.createElement("tr");this.__height&&(n.style.height=`${this.__height}px`);for(let[r,i]of this.__styles.entries())n.style.setProperty(r,i);return Te(n,t.theme.tableRow),n}isShadowRoot(){return!0}getStyles(){let t=this.getLatest();return new Map(t.__styles)}setStyles(t){let n=this.getWritable();n.__styles=new Map(t)}setHeight(t){let n=this.getWritable();return n.__height=t,this.__height}getHeight(){return this.getLatest().__height}updateDOM(t){return t.__height!==this.__height||t.__styles!==this.__styles}canBeEmpty(){return!1}canIndent(){return!1}};function lx(o){let e=Xo(),n=Wo(o.style.height);return e.setHeight(n),o instanceof HTMLElement&&e.setStyles(vn(o)),{node:e}}function Xo(){return ne(new Qt)}function Q(o){return o instanceof Qt}function ea(o,e,t=!0){let n=$r();for(let r=0;ro===re.BOTH||o===e?e:re.NO_STATUS;function Ki(o=!0){let e=T();x(_(e)||z(e),"Expected a RangeSelection or TableSelection");let t=e.focus.getNode(),[n,,r]=Le(t),[i,s]=ot(r,n,n),l=i[0].length,{startRow:a}=s;if(o){let c=a+n.__rowSpan-1,m=i[c],f=Xo();for(let u=0;u1;)if(k-=S.__colSpan,k>=0){let{cell:W,startRow:ie}=N[k];R=W,P=ie}else{h.append(g(M));continue e}R.insertAfter(g(M))}else S.setColSpan(S.__colSpan+1)}p!==null&&Ir(p)}function ta(){let o=T();x(_(o)||z(o),"Expected a RangeSelection or TableSelection");let e=o.anchor.getNode(),t=o.focus.getNode(),[n,,r]=Le(e),[i]=Le(t),[s,l,a]=ot(r,n,i),{startRow:c}=l,{startRow:m}=a,f=m+i.__rowSpan-1;if(s.length===f-c+1){r.remove();return}let d=s[0].length,u=s[f+1],p=r.getChildAtIndex(f+1);for(let g=f;g>=c;g--){for(let C=d-1;C>=0;C--){let{cell:N,startRow:L,startColumn:M}=s[g][C];if(M===C&&(g===c&&L=c&&L+N.__rowSpan-1>f))if(N.setRowSpan(N.__rowSpan-(f-L+1)),x(p!==null,"Expected nextRowNode not to be null"),C===0)na(p,N);else{let{cell:S}=u[C-1];S.insertAfter(N)}}let h=r.getChildAtIndex(g);x(Q(h),"Expected GridNode childAtIndex(%s) to be RowNode",String(g)),h.remove()}if(u!==void 0){let{cell:g}=u[0];Ir(g)}else{let g=s[c-1],{cell:h}=g[0];Ir(h)}}function oa(){let o=T();x(_(o)||z(o),"Expected a RangeSelection or TableSelection");let e=o.anchor.getNode(),t=o.focus.getNode(),[n,,r]=Le(e),[i]=Le(t),[s,l,a]=ot(r,n,i),{startColumn:c}=l,{startRow:m,startColumn:f}=a,d=Math.min(c,f),u=Math.max(c+n.__colSpan-1,f+i.__colSpan-1),p=u-d+1;if(s[0].length===u-d+1){r.selectPrevious(),r.remove();return}let h=s.length;for(let L=0;Lu){if(M===u){let O=u-A+1;S.setColSpan(S.__colSpan-O)}}else S.remove()}let C=s[m],N=c>f?C[c+n.__colSpan]:C[f+i.__colSpan];if(N!==void 0){let{cell:L}=N;Ir(L)}else{let L=f1){for(let l=1;l1){let[l,a]=ot(r,t,t),{startColumn:c,startRow:m}=a,f;for(let d=1;d1&&(h+=N.__colSpan-1)}if(g===null)for(let h=0;hN||g>L;){if(dN){let O=L-C,R=N+1;for(let P=0;P<=O;P++)M(c[C+P][R]);N=R}if(g>L){let O=N-h,R=L+1;for(let P=0;P<=O;P++)M(c[R][h+P]);L=R}}let S=[l],A=null;for(let O=u;O<=g;O++)for(let R=d;R<=p;R++){let{cell:P}=c[O][R],k=P.getParent();x(Q(k),"Expected TableCellNode parent to be a TableRowNode"),k!==A&&S.push(k),S.push(P,...ax(P)),A=k}return st()||(this._cachedNodes=S),S}getTextContent(){let e=this.getNodes().filter(n=>v(n)),t="";for(let n=0;n0;){let n=t.pop();x(n!==void 0,"Stack.length > 0; can't be undefined"),E(n)&&t.unshift(...n.getChildren()),n!==o&&e.push(n)}return e}var Br=class{constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.trackTable(),this.isSelecting=!1}getTable(){return this.table}removeListeners(){Array.from(this.listenersToRemove).forEach(e=>e())}trackTable(){let e=new MutationObserver(t=>{this.editor.update(()=>{let n=!1;for(let i=0;i{let t=this.editor.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");this.table=Go(t),e.observe(t,{attributes:!0,childList:!0,subtree:!0})})}clearHighlight(){let e=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.enableHighlightStyle(),e.update(()=>{let t=J(this.tableNodeKey);if(!K(t))throw new Error("Expected TableNode.");let n=e.getElementByKey(this.tableNodeKey);if(!n)throw new Error("Expected to find TableElement in DOM");let r=Go(n);Pr(e,r,null),Y(null),e.dispatchCommand(we,void 0)})}enableHighlightStyle(){let e=this.editor;e.update(()=>{let t=e.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");Di(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1})}disableHighlightStyle(){let e=this.editor;e.update(()=>{let t=e.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");Te(t,e._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0})}updateTableTableSelection(e){if(e!==null&&e.tableKey===this.tableNodeKey){let t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.disableHighlightStyle(),Pr(t,this.table,this.tableSelection)}else e==null?this.clearHighlight():(this.tableNodeKey=e.tableKey,this.updateTableTableSelection(e))}setFocusCellForSelection(e,t=!1){let n=this.editor;n.update(()=>{let r=J(this.tableNodeKey);if(!K(r))throw new Error("Expected TableNode.");if(!n.getElementByKey(this.tableNodeKey))throw new Error("Expected to find TableElement in DOM");let s=e.x,l=e.y;if(this.focusCell=e,this.anchorCell!==null){let a=ia(n._window);a&&a.setBaseAndExtent(this.anchorCell.elem,0,this.focusCell.elem,0)}if(!this.isHighlightingCells&&(this.anchorX!==s||this.anchorY!==l||t))this.isHighlightingCells=!0,this.disableHighlightStyle();else if(s===this.focusX&&l===this.focusY)return;if(this.focusX=s,this.focusY=l,this.isHighlightingCells){let a=ee(e.elem);if(this.tableSelection!=null&&this.anchorCellNodeKey!=null&&v(a)&&r.is(bo(a))){let c=a.getKey();this.tableSelection=this.tableSelection.clone()||qi(),this.focusCellNodeKey=c,this.tableSelection.set(this.tableNodeKey,this.anchorCellNodeKey,this.focusCellNodeKey),Y(this.tableSelection),n.dispatchCommand(we,void 0),Pr(n,this.table,this.tableSelection)}}})}setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y,this.editor.update(()=>{let t=ee(e.elem);if(v(t)){let n=t.getKey();this.tableSelection=this.tableSelection!=null?this.tableSelection.clone():qi(),this.anchorCellNodeKey=n}})}formatCells(e){this.editor.update(()=>{let t=T();z(t)||x(!1,"Expected grid selection");let n=Uo(),r=n.anchor,i=n.focus;t.getNodes().forEach(s=>{v(s)&&s.getTextContentSize()!==0&&(r.set(s.getKey(),0,"element"),i.set(s.getKey(),s.getChildrenSize(),"element"),n.formatText(e))}),Y(t),this.editor.dispatchCommand(we,void 0)})}clearText(){let e=this.editor;e.update(()=>{let t=J(this.tableNodeKey);if(!K(t))throw new Error("Expected TableNode.");let n=T();z(n)||x(!1,"Expected grid selection");let r=n.getNodes().filter(v);if(r.length===this.table.columns*this.table.rows){t.selectPrevious(),t.remove(),F().selectStart();return}r.forEach(i=>{if(E(i)){let s=I(),l=q();s.append(l),i.append(s),i.getChildren().forEach(a=>{a!==s&&a.remove()})}}),Pr(e,this.table,null),Y(null),e.dispatchCommand(we,void 0)})}};var cx="__lexicalTableSelection",ia=o=>fe?(o||window).getSelection():null,dx=o=>(o.buttons&1)===1;function aa(o,e,t,n){let r=t.getRootElement();if(r===null)throw new Error("No root element.");let i=new Br(t,o.getKey()),s=t._window||window;ux(e,i);let l=()=>{let d=()=>{i.isSelecting=!1,s.removeEventListener("mouseup",d),s.removeEventListener("mousemove",u)},u=p=>{setTimeout(()=>{if(!dx(p)&&i.isSelecting){i.isSelecting=!1,s.removeEventListener("mouseup",d),s.removeEventListener("mousemove",u);return}let g=la(p.target);g!==null&&(i.anchorX!==g.x||i.anchorY!==g.y)&&(p.preventDefault(),i.setFocusCellForSelection(g))},0)};return{onMouseMove:u,onMouseUp:d}};e.addEventListener("mousedown",d=>{setTimeout(()=>{if(d.button!==0||!s)return;let u=la(d.target);u!==null&&(Jo(d),i.setAnchorCellForSelection(u));let{onMouseUp:p,onMouseMove:g}=l();i.isSelecting=!0,s.addEventListener("mouseup",p),s.addEventListener("mousemove",g)},0)});let a=d=>{d.button===0&&t.update(()=>{let u=T(),p=d.target;z(u)&&u.tableKey===i.tableNodeKey&&r.contains(p)&&i.clearHighlight()})};s.addEventListener("mousedown",a),i.listenersToRemove.add(()=>s.removeEventListener("mousedown",a)),i.listenersToRemove.add(t.registerCommand(Bt,d=>Fr(t,d,"down",o,i),qe)),i.listenersToRemove.add(t.registerCommand(wo,d=>Fr(t,d,"up",o,i),qe)),i.listenersToRemove.add(t.registerCommand(Mo,d=>Fr(t,d,"backward",o,i),qe)),i.listenersToRemove.add(t.registerCommand(Lo,d=>Fr(t,d,"forward",o,i),qe)),i.listenersToRemove.add(t.registerCommand(vo,d=>{let u=T();if(z(u)){let p=H(u.focus.getNode(),v);if(v(p))return Jo(d),p.selectEnd(),!0}return!1},qe));let c=d=>()=>{let u=T();if(!jo(u,o))return!1;if(z(u))return i.clearText(),!0;if(_(u)){let p=H(u.anchor.getNode(),A=>v(A));if(!v(p))return!1;let g=u.anchor.getNode(),h=u.focus.getNode(),C=o.isParentOf(g),N=o.isParentOf(h);if(C&&!N||N&&!C)return i.clearText(),!0;let M=H(u.anchor.getNode(),A=>E(A)),S=M&&H(M,A=>E(A)&&v(A.getParent()));if(!E(S)||!E(M))return!1;if(d===it&&S.getPreviousSibling()===null)return!0}return!1};[Tt,it,Ze].forEach(d=>{i.listenersToRemove.add(t.registerCommand(d,c(d),Re))});let m=d=>{let u=T();if(!jo(u,o)){let p=u?u.getNodes():null;if(p){let g=p.find(h=>K(h)&&h.getKey()===i.tableNodeKey);if(K(g)){if(!g.getParent())return!1;g.remove()}}return!1}if(z(u))return d&&(d.preventDefault(),d.stopPropagation()),i.clearText(),!0;if(_(u)){let p=H(u.anchor.getNode(),g=>v(g));if(!v(p))return!1}return!1};i.listenersToRemove.add(t.registerCommand(Ft,m,Re)),i.listenersToRemove.add(t.registerCommand(Ht,m,Re)),i.listenersToRemove.add(t.registerCommand(lo,d=>{let u=T();if(u){if(!(z(u)||_(u)))return!1;kn(t,mt(d,ClipboardEvent)?d:null,Ii(u));let p=m(d);return _(u)&&u.removeText(),p}return!1},Re)),i.listenersToRemove.add(t.registerCommand(Ne,d=>{let u=T();if(!jo(u,o))return!1;if(z(u))return i.formatCells(d),!0;if(_(u)){let p=H(u.anchor.getNode(),g=>v(g));if(!v(p))return!1}return!1},Re)),i.listenersToRemove.add(t.registerCommand(rt,d=>{let u=T();if(!jo(u,o))return!1;if(z(u))return i.clearHighlight(),!1;if(_(u)){let p=H(u.anchor.getNode(),g=>v(g));if(!v(p))return!1;if(typeof d=="string"){let g=lf(t,u,o);if(g)return sf(g,o,[q(d)]),!0}}return!1},Re)),n&&i.listenersToRemove.add(t.registerCommand(Do,d=>{let u=T();if(!_(u)||!u.isCollapsed()||!jo(u,o))return!1;let p=Zi(u.anchor.getNode());if(p===null)return!1;Jo(d);let g=o.getCordsFromCellNode(p,i.table);return af(i,o,g.x,g.y,d.shiftKey?"backward":"forward"),!0},Re)),i.listenersToRemove.add(t.registerCommand(ir,d=>o.isSelected(),qe));function f(d){let u=o.getCordsFromCellNode(d,i.table);return o.getDOMCellFromCordsOrThrow(u.x,u.y,i.table)}return i.listenersToRemove.add(t.registerCommand(er,d=>{let{nodes:u,selection:p}=d,g=p.getStartEndPoints(),h=z(p),N=_(p)&&H(p.anchor.getNode(),Be=>v(Be))!==null&&H(p.focus.getNode(),Be=>v(Be))!==null||h;if(u.length!==1||!K(u[0])||!N||g===null)return!1;let[L]=g,M=u[0],S=M.getChildren(),A=M.getFirstChildOrThrow().getChildrenSize(),O=M.getChildrenSize(),R=H(L.getNode(),Be=>v(Be)),P=R&&H(R,Be=>Q(Be)),k=P&&H(P,Be=>K(Be));if(!v(R)||!Q(P)||!K(k))return!1;let W=P.getIndexWithinParent(),ie=Math.min(k.getChildrenSize()-1,W+O-1),ln=R.getIndexWithinParent(),ec=Math.min(P.getChildrenSize()-1,ln+A-1),sh=Math.min(ln,ec),lh=Math.min(W,ie),ah=Math.max(ln,ec),ch=Math.max(W,ie),dh=k.getChildren(),tc=0;for(let Be=lh;Be<=ch;Be++){let oc=dh[Be];if(!Q(oc))return!1;let nc=S[tc];if(!Q(nc))return!1;let uh=oc.getChildren(),fh=nc.getChildren(),rc=0;for(let vs=sh;vs<=ah;vs++){let Jr=uh[vs];if(!v(Jr))return!1;let ic=fh[rc];if(!v(ic))return!1;let mh=Jr.getChildren();ic.getChildren().forEach(an=>{y(an)&&I().append(an),Jr.append(an)}),mh.forEach(an=>an.remove()),rc++}tc++}return!0},Re)),i.listenersToRemove.add(t.registerCommand(we,()=>{let d=T(),u=We();if(_(d)){let{anchor:p,focus:g}=d,h=p.getNode(),C=g.getNode(),N=Zi(h),L=Zi(C),M=!!(N&&o.is(bo(N))),S=!!(L&&o.is(bo(L))),A=M!==S,O=M&&S,R=d.isBackward();if(A){let P=d.clone();if(S){let[k]=ot(o,L,L),W=k[0][0].cell,ie=k[k.length-1].at(-1).cell;P.focus.set(R?W.getKey():ie.getKey(),R?W.getChildrenSize():ie.getChildrenSize(),"element")}Y(P),rf(t,i)}else O&&(N.is(L)||(i.setAnchorCellForSelection(f(N)),i.setFocusCellForSelection(f(L),!0),i.isSelecting||setTimeout(()=>{let{onMouseUp:P,onMouseMove:k}=l();i.isSelecting=!0,s.addEventListener("mouseup",P),s.addEventListener("mousemove",k)},0)))}else if(d&&z(d)&&d.is(u)&&d.tableKey===o.getKey()){let p=ia(t._window);if(p&&p.anchorNode&&p.focusNode){let g=ee(p.focusNode),h=g&&!o.is(bo(g)),C=ee(p.anchorNode),N=C&&o.is(bo(C));if(h&&N&&p.rangeCount>0){let L=wl(p,t);L&&(L.anchor.set(o.getKey(),d.isBackward()?o.getChildrenSize():0,"element"),p.removeAllRanges(),Y(L))}}}return d&&!d.is(u)&&(z(d)||z(u))&&i.tableSelection&&!i.tableSelection.is(u)?(z(d)&&d.tableKey===i.tableNodeKey?i.updateTableTableSelection(d):!z(d)&&z(u)&&u.tableKey===i.tableNodeKey&&i.updateTableTableSelection(null),!1):(i.hasHijackedSelectionStyles&&!o.isSelected()?fx(t,i):!i.hasHijackedSelectionStyles&&o.isSelected()&&rf(t,i),!1)},Re)),i.listenersToRemove.add(t.registerCommand(Pt,()=>{let d=T();if(!_(d)||!d.isCollapsed()||!jo(d,o))return!1;let u=lf(t,d,o);return u?(sf(u,o),!0):!1},Re)),i}function ux(o,e){o[cx]=e}function la(o){let e=o;for(;e!=null;){let t=e.nodeName;if(t==="TD"||t==="TH"){let n=e._cell;return n===void 0?null:n}e=e.parentNode}return null}function Go(o){let e=[],t={columns:0,domRows:e,rows:0},n=o.firstChild,r=0,i=0;for(e.length=0;n!=null;){let s=n.nodeName;if(s==="TD"||s==="TH"){let c=n,m={elem:c,hasBackgroundColor:c.style.backgroundColor!=="",highlighted:!1,x:r,y:i};n._cell=m;let f=e[i];f===void 0&&(f=e[i]=[]),f[r]=m}else{let c=n.firstChild;if(c!=null){n=c;continue}}let l=n.nextSibling;if(l!=null){r++,n=l;continue}let a=n.parentNode;if(a!=null){let c=a.nextSibling;if(c==null)break;i++,r=0,n=c}}return t.columns=r+1,t.rows=i+1,t}function Pr(o,e,t){let n=new Set(t?t.getNodes():[]);ca(e,(r,i)=>{let s=r.elem;n.has(i)?(r.highlighted=!0,cf(o,r)):(r.highlighted=!1,df(o,r),s.getAttribute("style")||s.removeAttribute("style"))})}function ca(o,e){let{domRows:t}=o;for(let n=0;n{t.highlighted=!0,cf(o,t)})}function fx(o,e){e.enableHighlightStyle(),ca(e.table,t=>{let n=t.elem;t.highlighted=!1,df(o,t),n.getAttribute("style")||n.removeAttribute("style")})}var af=(o,e,t,n,r)=>{let i=r==="forward";switch(r){case"backward":case"forward":return t!==(i?o.table.columns-1:0)?Yi(e.getCellNodeFromCordsOrThrow(t+(i?1:-1),n,o.table),i):n!==(i?o.table.rows-1:0)?Yi(e.getCellNodeFromCordsOrThrow(i?0:o.table.columns-1,n+(i?1:-1),o.table),i):i?e.selectNext():e.selectPrevious(),!0;case"up":return n!==0?Yi(e.getCellNodeFromCordsOrThrow(t,n-1,o.table),!1):e.selectPrevious(),!0;case"down":return n!==o.table.rows-1?Yi(e.getCellNodeFromCordsOrThrow(t,n+1,o.table),!0):e.selectNext(),!0;default:return!1}},mx=(o,e,t,n,r)=>{let i=r==="forward";switch(r){case"backward":case"forward":return t!==(i?o.table.columns-1:0)&&o.setFocusCellForSelection(e.getDOMCellFromCordsOrThrow(t+(i?1:-1),n,o.table)),!0;case"up":return n!==0?(o.setFocusCellForSelection(e.getDOMCellFromCordsOrThrow(t,n-1,o.table)),!0):!1;case"down":return n!==o.table.rows-1?(o.setFocusCellForSelection(e.getDOMCellFromCordsOrThrow(t,n+1,o.table)),!0):!1;default:return!1}};function jo(o,e){if(_(o)||z(o)){let t=e.isParentOf(o.anchor.getNode()),n=e.isParentOf(o.focus.getNode());return t&&n}return!1}function Yi(o,e){e?o.selectStart():o.selectEnd()}var sa="172,206,247";function cf(o,e){let t=e.elem,n=ee(t);x(v(n),"Expected to find LexicalNode from Table Cell DOMNode"),n.getBackgroundColor()===null?t.style.setProperty("background-color",`rgb(${sa})`):t.style.setProperty("background-image",`linear-gradient(to right, rgba(${sa},0.85), rgba(${sa},0.85))`),t.style.setProperty("caret-color","transparent")}function df(o,e){let t=e.elem,n=ee(t);x(v(n),"Expected to find LexicalNode from Table Cell DOMNode"),n.getBackgroundColor()===null&&t.style.removeProperty("background-color"),t.style.removeProperty("background-image"),t.style.removeProperty("caret-color")}function Zi(o){let e=H(o,v);return v(e)?e:null}function bo(o){let e=H(o,K);return K(e)?e:null}function Fr(o,e,t,n,r){if((t==="up"||t==="down")&&px(o))return!1;let i=T();if(!jo(i,n)){if(_(i)){if(i.isCollapsed()&&t==="backward"){let s=i.anchor.type,l=i.anchor.offset;if(s!=="element"&&!(s==="text"&&l===0))return!1;let a=i.anchor.getNode();if(!a)return!1;let c=H(a,f=>E(f)&&!f.isInline());if(!c)return!1;let m=c.getPreviousSibling();return!m||!K(m)?!1:(Jo(e),m.selectEnd(),!0)}else if(e.shiftKey&&(t==="up"||t==="down")){let s=i.focus.getNode();if(me(s)){let l=i.getNodes()[0];if(l){let a=H(l,v);if(a&&n.isParentOf(a)){let c=n.getFirstDescendant(),m=n.getLastDescendant();if(!c||!m)return!1;let[f]=Le(c),[d]=Le(m),u=n.getCordsFromCellNode(f,r.table),p=n.getCordsFromCellNode(d,r.table),g=n.getDOMCellFromCordsOrThrow(u.x,u.y,r.table),h=n.getDOMCellFromCordsOrThrow(p.x,p.y,r.table);return r.setAnchorCellForSelection(g),r.setFocusCellForSelection(h,!0),!0}}return!1}else{let l=H(s,c=>E(c)&&!c.isInline());if(!l)return!1;let a=t==="down"?l.getNextSibling():l.getPreviousSibling();if(K(a)&&r.tableNodeKey===a.getKey()){let c=a.getFirstDescendant(),m=a.getLastDescendant();if(!c||!m)return!1;let[f]=Le(c),[d]=Le(m),u=i.clone();return u.focus.set((t==="up"?f:d).getKey(),t==="up"?0:d.getChildrenSize(),"element"),Y(u),!0}}}}return!1}if(_(i)&&i.isCollapsed()){let{anchor:s,focus:l}=i,a=H(s.getNode(),v),c=H(l.getNode(),v);if(!v(a)||!a.is(c))return!1;let m=bo(a);if(m!==n&&m!=null){let N=o.getElementByKey(m.getKey());if(N!=null)return r.table=Go(N),Fr(o,e,t,m,r)}if(t==="backward"||t==="forward"){let N=s.type,L=s.offset,M=s.getNode();if(!M)return!1;let S=i.getNodes();return S.length===1&&B(S[0])?!1:gx(N,L,M,t)?xx(e,M,n,t):!1}let f=o.getElementByKey(a.__key),d=o.getElementByKey(s.key);if(d==null||f==null)return!1;let u;if(s.type==="element")u=d.getBoundingClientRect();else{let N=window.getSelection();if(N===null||N.rangeCount===0)return!1;u=N.getRangeAt(0).getBoundingClientRect()}let p=t==="up"?a.getFirstChild():a.getLastChild();if(p==null)return!1;let g=o.getElementByKey(p.__key);if(g==null)return!1;let h=g.getBoundingClientRect();if(t==="up"?h.top>u.top-u.height:u.bottom+u.height>h.bottom){Jo(e);let N=n.getCordsFromCellNode(a,r.table);if(e.shiftKey){let L=n.getDOMCellFromCordsOrThrow(N.x,N.y,r.table);r.setAnchorCellForSelection(L),r.setFocusCellForSelection(L,!0)}else return af(r,n,N.x,N.y,t);return!0}}else if(z(i)){let{anchor:s,focus:l}=i,a=H(s.getNode(),v),c=H(l.getNode(),v),[m]=i.getNodes(),f=o.getElementByKey(m.getKey());if(!v(a)||!v(c)||!K(m)||f==null)return!1;r.updateTableTableSelection(i);let d=Go(f),u=n.getCordsFromCellNode(a,d),p=n.getDOMCellFromCordsOrThrow(u.x,u.y,d);if(r.setAnchorCellForSelection(p),Jo(e),e.shiftKey){let g=n.getCordsFromCellNode(c,d);return mx(r,m,g.x,g.y,t)}else c.selectEnd();return!0}return!1}function Jo(o){o.preventDefault(),o.stopImmediatePropagation(),o.stopPropagation()}function px(o){let e=o.getRootElement();return e?e.hasAttribute("aria-controls")&&e.getAttribute("aria-controls")==="typeahead-menu":!1}function gx(o,e,t,n){return hx(o,t,n)||Nx(o,e,t,n)}function hx(o,e,t){return o==="element"&&(t==="backward"?e.getPreviousSibling()===null:e.getNextSibling()===null)}function Nx(o,e,t,n){let r=H(t,s=>E(s)&&!s.isInline());if(!r)return!1;let i=n==="backward"?e===0:e===t.getTextContentSize();return o==="text"&&i&&(n==="backward"?r.getPreviousSibling()===null:r.getNextSibling()===null)}function xx(o,e,t,n){let r=H(e,v);if(!v(r))return!1;let[i,s]=ot(t,r,r);if(!Ex(i,s,n))return!1;let l=Tx(e,n,t);return!l||K(l)?!1:(Jo(o),n==="backward"?l.selectEnd():l.selectStart(),!0)}function Ex(o,e,t){let n=o[0][0],r=o[o.length-1][o[0].length-1],{startColumn:i,startRow:s}=e;return t==="backward"?i===n.startColumn&&s===n.startRow:i===r.startColumn&&s===r.startRow}function Tx(o,e,t){let n=H(o,i=>E(i)&&!i.isInline());if(!n)return;let r=e==="backward"?n.getPreviousSibling():n.getNextSibling();return r&&K(r)?r:e==="backward"?t.getPreviousSibling():t.getNextSibling()}function sf(o,e,t){let n=I();o==="first"?e.insertBefore(n):e.insertAfter(n),n.append(...t||[]),n.selectEnd()}function lf(o,e,t){let n=t.getParent();if(!n)return;let r=o.getElementByKey(n.getKey());if(!r)return;let i=window.getSelection();if(!i||i.anchorNode!==r)return;let s=H(e.anchor.getNode(),h=>v(h));if(!s)return;let l=H(s,h=>K(h));if(!K(l)||!l.is(t))return;let[a,c]=ot(t,s,s),m=a[0][0],f=a[a.length-1][a[0].length-1],{startRow:d,startColumn:u}=c,p=d===m.startRow&&u===m.startColumn,g=d===f.startRow&&u===f.startColumn;return p?"first":g?"last":void 0}var kt=class{constructor(e){this.rowCount=0;this.columnCount=0;this.cells=[];this.buildCellMap(e)}buildCellMap(e){let t=[],n=(a,c,m)=>{typeof t[c]>"u"&&(t[c]=[]),t[c][a]=m},r=(a,c)=>!!(t[c]&&t[c][a]),i=e.getChildren().filter(a=>Q(a));for(let a=0;av(d)),f=0;for(let d=0;da.length));let s=[],l=t[0][0];for(let a=0;a=this.cells.length)throw new Error(`TableMap Error: Attempted to get cell ${n+1} of ${this.cells.length}`);return this.cells[n]}getCellsInRange(e){let t=Math.max(Math.min(e.fromX,e.toX),0),n=Math.min(Math.max(e.fromX,e.toX),this.columnCount-1),r=Math.max(Math.min(e.fromY,e.toY),0),i=Math.min(Math.max(e.fromY,e.toY),this.rowCount-1),s=new Set;for(let l=r;l<=i;l++)for(let a=t;a<=n;a++)s.add(this.getCellAtPosition(a,l));return[...s.values()]}getCellsInColumn(e){return this.getCellsInRange({fromX:e,toX:e,fromY:0,toY:this.rowCount-1})}getRangeForCell(e){let t=null,n=e.getKey();for(let r=0;rt&&(n=r,t=r.childElementCount);return n}function uf(o){return[...o.children].map(e=>Cx(e))}function Cx(o){let e=o.style.width||o.getAttribute("width");return e&&!Number.isNaN(Number(e))&&(e=e+"px"),e||""}function ua(o,e,t){let n=o.getChildren(),r=0;for(let s of n){let l=s.getChildren().length;l>r&&(r=l)}let i=o.getColWidths();(i.length===0||i.lengthi.length&&console.error(`Attempted to set table column width for column [${e}] but only ${i.length} columns found`),i[e]=ft(t),o.setColWidths(i)}function pf(o,e,t){let n=e.getColWidths();if(n.length>t&&n[t].endsWith("px"))return Number(n[t].replace("px",""));let r=o.getElementByKey(e.__key);if(r){let i=mf(r);if(i&&i.children.length>t)return i.children[t].clientWidth}return 0}function gf(o){let e=o.getParent();if(!Q(e))return-1;let t=0,n=e.getChildren();for(let r of n){let i=r.getColSpan()||1;if(t+=i,r.getKey()===o.getKey())break}return t-1}function hf(o,e){let t=da(o),n=gf(o);t&&n>=0&&ua(t,n,e)}function Nf(o,e){let t=da(e),n=gf(e);if(!t)return"";let r=t.getColWidths();return r.length>n?r[n]:""}function Qo(o){if(z(o))return o.getNodes().filter(n=>v(n));let e=V(o,v);return e?[e]:[]}function xf(o){let e=o.getShape(),t=Qo(o);if(t.length===0)return;let n=da(t[0]);if(!n)return;let r=new kt(n),i=r.getCellAtPosition(e.toX,e.toY);if(!i)return;let s=e.toX+((i.getColSpan()||1)-1),l=e.toY+((i.getRowSpan()||1)-1),a=r.getCellsInRange({fromX:e.fromX,fromY:e.fromY,toX:s,toY:l});if(a.length===0)return;let c=a[0],m=Math.abs(e.fromX-s)+1,f=Math.abs(e.fromY-l)+1;for(let d=1;dv(r));for(let r of n){let i=r.getStyles();i.delete("height"),i.delete("width"),r.setStyles(i),r.clearWidth()}}}function Tf(o){o.setColWidths([]),o.setStyles(new Map);for(let e of o.getChildren()){if(!Q(e))continue;e.setStyles(new Map);let t=e.getChildren().filter(n=>v(n));for(let n of t)n.setStyles(new Map),n.clearWidth()}}function fa(o,e){e:for(let t of o.getChildren()){if(!Q(t))continue;let n=t.getChildren();for(let r of n){if(!v(r))return;if(e(r)===!1)break e}}}function Cf(o){let e=null;return fa(o,t=>{let n=t.getStyles().get("padding")||"";if(e===null&&(e=n),n!==e)return e=null,!1}),e||""}var xt=class o extends vt{constructor(t){super(t);this.__colWidths=[];this.__styles=new Map}static getType(){return"table"}static clone(t){let n=new o(t.__key);return Co(t,n),n.__colWidths=t.__colWidths,n.__styles=new Map(t.__styles),n}static importDOM(){return{table:t=>({conversion:_x,priority:1})}}static importJSON(t){let n=$r();return tt(t,n),n.setColWidths(t.colWidths),n.setStyles(new Map(Object.entries(t.styles))),n}exportJSON(){return{...super.exportJSON(),type:"table",version:1,colWidths:this.__colWidths,styles:Object.fromEntries(this.__styles)}}createDOM(t,n){let r=document.createElement("table");Te(r,t.theme.table),et(r,this);let i=this.getColWidths();if(i.length>0){let s=b("colgroup");for(let l of i){let a=b("col");l&&(a.style.width=l),s.append(a)}r.append(s)}for(let[s,l]of this.__styles.entries())r.style.setProperty(s,l);return r}updateDOM(t){return wt(t,this)||this.__colWidths.join(":")!==t.__colWidths.join(":")||this.__styles.size!==t.__styles.size||Array.from(this.__styles.values()).join(":")!==Array.from(t.__styles.values()).join(":")}exportDOM(t){return{...super.exportDOM(t),after:n=>{if(!n)return;let r=n.cloneNode(),i=document.createElement("tbody");if(pe(n))for(let s of Array.from(n.children))s.nodeName==="TR"?i.append(s):s.nodeName==="CAPTION"?r.insertBefore(s,r.firstChild):r.append(s);return r.append(i),r}}}canBeEmpty(){return!1}isShadowRoot(){return!0}setColWidths(t){let n=this.getWritable();n.__colWidths=t}getColWidths(){return this.getLatest().__colWidths}getStyles(){let t=this.getLatest();return new Map(t.__styles)}setStyles(t){let n=this.getWritable();n.__styles=new Map(t)}getCordsFromCellNode(t,n){let{rows:r,domRows:i}=n;for(let s=0;s{if(!c)return;let{elem:m}=c;return ee(m)===t});if(a!==-1)return{x:a,y:s}}throw new Error("Cell not found in table.")}getDOMCellFromCords(t,n,r){let{domRows:i}=r,s=i[n];if(s==null)return null;let l=t{let r=new o;return n.id&&r.setId(n.id),{node:r}},priority:3}}}}exportJSON(){return{...super.exportJSON(),type:"horizontal-rule",version:1,id:this.__id}}static importJSON(t){let n=ma();return n.setId(t.id),n}};function ma(){return new Un}function _f(o){return o instanceof Un}var bf=o=>(o.split(" ").filter(t=>t.startsWith("language-"))[0]||"").replace("language-",""),en=class o extends Mt{constructor(t="",n="",r){super(r);this.__id="";this.__language="";this.__code="";this.__language=t,this.__code=n}static getType(){return"code-block"}static clone(t){let n=new o(t.__language,t.__code,t.__key);return n.__id=t.__id,n}setLanguage(t){let n=this.getWritable();n.__language=t}getLanguage(){return this.getLatest().__language}setCode(t){let n=this.getWritable();n.__code=t}getCode(){return this.getLatest().__code}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}decorate(t,n){return{type:"code",getNode:()=>this}}isInline(){return!1}isIsolated(){return!0}createDOM(t,n){let r=b("pre",{id:this.__id||null},[b("code",{class:this.__language?`language-${this.__language}`:null},[this.__code])]);return b("div",{class:"editor-code-block-wrap"},[r])}updateDOM(t,n){let r=n.querySelector("code");return r&&(t.__language!==this.__language&&(r.className=this.__language?`language-${this.__language}`:""),t.__id!==this.__id&&n.setAttribute("id",this.__id),t.__code!==this.__code&&(r.textContent=this.__code)),!1}exportDOM(t){return{element:this.createDOM(t._config,t).querySelector("pre")}}static importDOM(){return{pre(t){return{conversion:n=>{let r=n.querySelector("code"),i=bf(n.className)||r&&bf(r.className)||"",s=r?(r.textContent||"").trim():(n.textContent||"").trim(),l=Vi(i,s);return n.id&&l.setId(n.id),{node:l,after(a){return[]}}},priority:3}}}}exportJSON(){return{type:"code-block",version:1,id:this.__id,language:this.__language,code:this.__code}}static importJSON(t){let n=Vi(t.language,t.code);return n.setId(t.id||""),n}};function Vi(o="",e=""){return new en(o,e)}function Xi(o){return o instanceof en}function Hr(o,e){let t=e.getCode(),n=e.getLanguage();window.$components.first("code-editor").open(t,n,"ltr",(i,s)=>{o.update(()=>{e.setCode(i),e.setLanguage(s)})},()=>{})}var yo=class o extends Mt{constructor(t,n,r){super(r);this.__id="";this.__drawingId="";this.__drawingUrl="";this.__drawingId=t,this.__drawingUrl=n}static getType(){return"diagram"}static clone(t){let n=new o(t.__drawingId,t.__drawingUrl);return n.__id=t.__id,n}setDrawingIdAndUrl(t,n){let r=this.getWritable();r.__drawingUrl=n,r.__drawingId=t}getDrawingIdAndUrl(){let t=this.getLatest();return{id:t.__drawingId,url:t.__drawingUrl}}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}decorate(t,n){return{type:"diagram",getNode:()=>this}}isInline(){return!1}isIsolated(){return!0}createDOM(t,n){return b("div",{id:this.__id||null,"drawio-diagram":this.__drawingId},[b("img",{src:this.__drawingUrl})])}updateDOM(t,n){let r=n.querySelector("img");return r&&(t.__id!==this.__id&&n.setAttribute("id",this.__id),t.__drawingUrl!==this.__drawingUrl&&r.setAttribute("src",this.__drawingUrl),t.__drawingId!==this.__drawingId&&n.setAttribute("drawio-diagram",this.__drawingId)),!1}static importDOM(){return{div(t){return t.hasAttribute("drawio-diagram")?{conversion:n=>{let i=n.querySelector("img")?.getAttribute("src")||"",s=n.getAttribute("drawio-diagram")||"",l=zn(s,i);return n.id&&l.setId(n.id),{node:l}},priority:3}:null}}}exportJSON(){return{type:"diagram",version:1,id:this.__id,drawingId:this.__drawingId,drawingUrl:this.__drawingUrl}}static importJSON(t){let n=zn(t.drawingId,t.drawingUrl);return n.setId(t.id||""),n}};function zn(o="",e=""){return new yo(o,e)}var bx=["width","height","style","title","name","src","allow","allowfullscreen","loading","sandbox","type","data","controls","autoplay","controlslist","loop","muted","playsinline","poster","preload"];function yx(o){let e={};for(let t of Object.keys(o))bx.includes(t)&&(e[t]=o[t]);return e}function yf(o,e){let t=Sf(o),n={};for(let i of e.attributes)n[i.name]=i.value;t.setAttributes(n);let r=[];if(o==="video"||o==="audio"){for(let i of e.children)if(i.tagName==="SOURCE"){let s=i.getAttribute("src"),l=i.getAttribute("type");s&&l&&r.push({src:s,type:l})}t.setSources(r)}return Qe(e,t),t}var So=class o extends Z{constructor(t,n){super(n);this.__id="";this.__alignment="";this.__attributes={};this.__sources=[];this.__inset=0;this.__tag=t}static getType(){return"media"}static clone(t){let n=new o(t.__tag,t.__key);return n.__attributes=Object.assign({},t.__attributes),n.__sources=t.__sources.map(r=>Object.assign({},r)),n.__id=t.__id,n.__alignment=t.__alignment,n.__inset=t.__inset,n}setTag(t){let n=this.getWritable();n.__tag=t}getTag(){return this.getLatest().__tag}setAttributes(t){let n=this.getWritable();n.__attributes=yx(t)}getAttributes(){return this.getLatest().__attributes}setSources(t){let n=this.getWritable();n.__sources=t}getSources(){return this.getLatest().__sources}setSrc(t){let n=Object.assign({},this.getAttributes());this.__tag==="object"?n.data=t:n.src=t,this.setAttributes(n)}setWidthAndHeight(t,n){let r=Object.assign({},this.getAttributes(),{width:t,height:n});this.setAttributes(r)}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}setAlignment(t){let n=this.getWritable();n.__alignment=t}getAlignment(){return this.getLatest().__alignment}setInset(t){let n=this.getWritable();n.__inset=t}getInset(){return this.getLatest().__inset}setHeight(t){if(!t)return;let n=Object.assign({},this.getAttributes(),{height:t});this.setAttributes(n)}getHeight(){let t=this.getLatest();return Wo(t.__attributes.height||"0")}setWidth(t){let n=Object.assign({},this.getAttributes(),{width:t});this.setAttributes(n)}getWidth(){let t=this.getLatest();return Wo(t.__attributes.width||"0")}isInline(){return!0}isParentRequired(){return!0}createInnerDOM(){let n=(this.__tag==="video"||this.__tag==="audio"?this.__sources:[]).map(i=>b("source",i)),r=b(this.__tag,this.__attributes,n);return et(r,this),r}createDOM(t,n){let r=this.createInnerDOM(),i=b("span",{class:r.className+" editor-media-wrap"},[r]);return i.addEventListener("click",s=>{n.update(()=>ke(this))}),i}updateDOM(t,n){if(t.__tag!==this.__tag||JSON.stringify(t.__sources)!==JSON.stringify(this.__sources)||JSON.stringify(t.__attributes)!==JSON.stringify(this.__attributes))return!0;let r=n.firstElementChild;return t.__id!==this.__id&&uu(r,"id",this.__id),t.__alignment!==this.__alignment&&(t.__alignment&&(n.classList.remove(`align-${t.__alignment}`),r.classList.remove(`align-${t.__alignment}`)),this.__alignment&&(n.classList.add(`align-${this.__alignment}`),r.classList.add(`align-${this.__alignment}`))),t.__inset!==this.__inset&&(n.style.paddingLeft=`${this.__inset}px`),!1}static importDOM(){let t=n=>r=>({conversion:i=>({node:yf(n,i)}),priority:3});return{iframe:t("iframe"),embed:t("embed"),object:t("object"),video:t("video"),audio:t("audio")}}exportDOM(t){return{element:this.createInnerDOM()}}exportJSON(){return{...super.exportJSON(),type:"media",version:1,id:this.__id,alignment:this.__alignment,inset:this.__inset,tag:this.__tag,attributes:this.__attributes,sources:this.__sources}}static importJSON(t){let n=Sf(t.tag);return tt(t,n),n}};function Sf(o){return new So(o)}function Lf(o){let n=new DOMParser().parseFromString(`${o}`,"text/html").body.children[0];if(!(n instanceof HTMLElement))return null;let r=n.tagName.toLowerCase();return["embed","iframe","video","audio","object"].includes(r)?yf(r,n):null}var Sx=[{regex:/.*?youtu\.be\/([\w\-_\?&=.]+)/i,w:560,h:314,url:"https://www.youtube.com/embed/$1"},{regex:/.*youtube\.com(.+)v=([^&]+)(&([a-z0-9&=\-_]+))?.*/i,w:560,h:314,url:"https://www.youtube.com/embed/$2?$4"},{regex:/.*youtube.com\/embed\/([a-z0-9\?&=\-_]+).*/i,w:560,h:314,url:"https://www.youtube.com/embed/$1"}],Lx=["mp4","mpeg","m4v","m4p","mov"],Mx=["3gp","aac","flac","mp3","m4a","ogg","wav","webm"],wx=["html","htm","php","asp","aspx",""];function Mf(o){for(let s of Sx)if(o.match(s.regex)){let a=o.replace(s.regex,s.url),c=new So("iframe");return c.setSrc(a),c.setHeight(s.h),c.setWidth(s.w),c}let e="iframe",n=(o.split("?")[0].split("/").pop()||"").split("."),r=(n.length>1?n[n.length-1]:"").toLowerCase();Lx.includes(r)?e="video":Mx.includes(r)?e="audio":r&&!wx.includes(r)&&(e="embed");let i=new So(e);return i.setSrc(o),i}function to(o){return o instanceof So}var Yn=class o extends vt{static getType(){return"heading"}static clone(e){let t=new o(e.__tag,e.__key);return Co(e,t),t}constructor(e,t){super(t),this.__tag=e}getTag(){return this.__tag}createDOM(e){let t=this.__tag,n=document.createElement(t),i=e.theme.heading;if(i!==void 0){let s=i[t];Te(n,s)}return et(n,this),n}updateDOM(e,t){return wt(e,this)}static importDOM(){return{h1:e=>({conversion:Wn,priority:0}),h2:e=>({conversion:Wn,priority:0}),h3:e=>({conversion:Wn,priority:0}),h4:e=>({conversion:Wn,priority:0}),h5:e=>({conversion:Wn,priority:0}),h6:e=>({conversion:Wn,priority:0})}}exportDOM(e){let{element:t}=super.exportDOM(e);return t&&pe(t)&&this.isEmpty()&&t.append(document.createElement("br")),{element:t}}static importJSON(e){let t=qn(e.tag);return tt(e,t),t}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(e,t=!0){let n=e?e.anchor.offset:0,r=this.getLastDescendant(),s=!r||e&&e.anchor.key===r.getKey()&&n===r.getTextContentSize()||!e?I():qn(this.getTag()),l=this.getDirection();if(s.setDirection(l),this.insertAfter(s,t),n===0&&!this.isEmpty()&&e){let a=I();a.select(),this.replace(a,!0)}return s}collapseAtStart(){let e=this.isEmpty()?I():qn(this.getTag());return this.getChildren().forEach(n=>e.append(n)),this.replace(e),!0}extractWithChild(){return!0}};function Wn(o){let e=o.nodeName.toLowerCase(),t=null;return(e==="h1"||e==="h2"||e==="h3"||e==="h4"||e==="h5"||e==="h6")&&(t=qn(e),Qe(o,t)),{node:t}}function qn(o){return ne(new Yn(o))}function Zn(o){return o instanceof Yn}var Vn=class o extends vt{static getType(){return"quote"}static clone(e){let t=new o(e.__key);return Co(e,t),t}constructor(e){super(e)}createDOM(e){let t=document.createElement("blockquote");return Te(t,e.theme.quote),et(t,this),t}updateDOM(e,t){return wt(e,this)}static importDOM(){return{blockquote:e=>({conversion:vx,priority:0})}}exportDOM(e){let{element:t}=super.exportDOM(e);return t&&pe(t)&&this.isEmpty()&&t.append(document.createElement("br")),{element:t}}static importJSON(e){let t=Gi();return tt(e,t),t}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(e,t){let n=I(),r=this.getDirection();return n.setDirection(r),this.insertAfter(n,t),n}collapseAtStart(){let e=I();return this.getChildren().forEach(n=>e.append(n)),this.replace(e),!0}canMergeWhenEmpty(){return!0}};function Gi(){return ne(new Vn)}function ji(o){return o instanceof Vn}function vx(o){let e=Gi();return Qe(o,e),{node:e}}var Xn=class o extends Z{static getType(){return"caption"}static clone(e){return new o(e.__key)}createDOM(e,t){return document.createElement("caption")}updateDOM(e,t,n){return!1}isParentRequired(){return!0}canBeEmpty(){return!1}exportJSON(){return{...super.exportJSON(),type:"caption",version:1}}insertDOMIntoParent(e,t){return t.insertBefore(e,t.firstChild),!0}static importJSON(e){return pa()}static importDOM(){return{caption:e=>({conversion(t){return{node:pa()}},priority:0})}}};function pa(){return new Xn}function ga(o){return o instanceof Xn}function ha(o){for(let e of o.getChildren())if(ga(e))return!0;return!1}function wf(o,e=""){let t=pa(),n=q(e||" ");t.append(n),o.append(t)}function vf(){return[qo,Yn,Vn,Vo,jt,xt,Qt,Jt,Xn,Zo,Un,Hn,en,yo,So,dt,$n]}function Df(o){let e=[Zo,en,yo],t=n=>{for(let[r,i]of n)if(i==="destroyed"){let s=o.manager.getDecoratorByNodeKey(r);s&&s.destroy(o)}};for(let n of e)o.editor.registerMutationListener(n,r=>t(r))}function Na(o){return"build"in o}var Me=class{constructor(){this.dom=null;this.context=null}setContext(e){this.context=e}getContext(){if(this.context===null)throw new Error("Attempted to use EditorUIContext before it has been set");return this.context}getDOMElement(){return this.dom||(this.dom=this.buildDOM()),this.dom}rebuildDOM(){let e=this.buildDOM();return this.dom?.replaceWith(e),this.dom=e,this.dom}trans(e){return this.getContext().translate(e)}updateState(e){}},te=class extends Me{constructor(t){super();this.children=[];this.children.push(...t)}buildDOM(){return b("div",{},this.getChildren().map(t=>t.getDOMElement()))}getChildren(){return this.children}addChildren(...t){this.children.push(...t)}removeChildren(...t){for(let n of t)this.removeChild(n)}removeChild(t){let n=this.children.indexOf(t);n!==-1&&this.children.splice(n,1)}updateState(t){for(let n of this.children)n.updateState(t)}setContext(t){super.setContext(t);for(let n of this.getChildren())n.setContext(t)}},Ji=class extends te{constructor(e,t){super(t),this.className=e}buildDOM(){return b("div",{class:this.className},this.getChildren().map(e=>e.getDOMElement()))}};var w=class extends Me{constructor(t){super();this.active=!1;this.completedSetup=!1;this.disabled=!1;t.action!==void 0?this.definition=t:this.definition={...t,action(){return!1},isActive:()=>!1}}setContext(t){super.setContext(t),this.definition.setup&&!this.completedSetup&&(this.definition.setup(t,this),this.completedSetup=!0)}buildDOM(){let t=this.getLabel(),n=this.definition.format||"small",r=[];if(this.definition.icon||n==="long"){let s=b("div",{class:"editor-button-icon"});s.innerHTML=this.definition.icon||"",r.push(s)}if(!this.definition.icon||n==="long"){let s=b("div",{class:"editor-button-text"},[t]);r.push(s)}let i=b("button",{type:"button",class:`editor-button editor-button-${n}`,title:this.definition.icon?t:null,disabled:this.disabled?"true":null},r);return i.addEventListener("click",this.onClick.bind(this)),i}onClick(){this.definition.action(this.getContext(),this)}updateActiveState(t){let n=this.definition.isActive(t,this.getContext());this.setActiveState(n)}updateDisabledState(t){if(this.definition.isDisabled){let n=this.definition.isDisabled(t,this.getContext());this.toggleDisabled(n)}}setActiveState(t){this.active=t,this.dom?.classList.toggle("editor-button-active",this.active)}updateState(t){this.updateActiveState(t.selection),this.updateDisabledState(t.selection)}isActive(){return this.active}getLabel(){return this.trans(this.definition.label)}toggleDisabled(t){this.disabled=t,t?this.dom?.setAttribute("disabled","true"):this.dom?.removeAttribute("disabled")}};function Dx(o,e,t){let n=e.getBoundingClientRect(),r=o.getBoundingClientRect();if(o.style.position="fixed",t){let i=n.right;n.right+r.width>window.innerWidth&&(i=Math.max(n.left-r.width,0)),o.style.top=n.top+"px",o.style.left=i+"px"}else{let i=n.left+r.width>window.innerWidth,s=n.left;i&&(s=Math.max(n.right-r.width,0)),o.style.top=n.bottom+"px",o.style.left=s+"px"}}function Qi(o){let{menu:e,toggle:t,onClose:n,onOpen:r,showOnHover:i,showAside:s}=o,l=null,a=()=>{e.hidden=!0,e.style.removeProperty("position"),e.style.removeProperty("left"),e.style.removeProperty("top"),l&&window.removeEventListener("click",l),n&&n()},c=()=>{e.hidden=!1,Dx(e,t,!!s),l=f=>{!t.contains(f.target)&&!e.contains(f.target)&&a()},window.addEventListener("click",l),r&&r()},m=f=>{e.hasAttribute("hidden")?c():a()};t.addEventListener("click",m),i&&t.addEventListener("mouseenter",m),e.parentElement?.addEventListener("mouseleave",f=>{let d=t.getBoundingClientRect(),u=f.clientX<=d.right&&f.clientX>=d.left,p=f.clientY<=d.bottom&&f.clientY>=d.top;u&&p||a()})}var es=class extends te{buildDOM(){let e=this.getChildren().map(i=>i.getDOMElement()),t=b("div",{class:"editor-format-menu-dropdown editor-dropdown-menu editor-dropdown-menu-vertical",hidden:"true"},e),n=b("button",{class:"editor-format-menu-toggle editor-button",type:"button"},[this.trans("Formats")]),r=b("div",{class:"editor-format-menu editor-dropdown-menu-container"},[n,t]);return Qi({toggle:n,menu:t}),r}updateState(e){super.updateState(e);for(let t of this.children){if(t instanceof w&&t.isActive()){this.updateToggleLabel(t.getLabel());return}if(t instanceof te){for(let n of t.getChildren())if(n instanceof w&&n.isActive()){this.updateToggleLabel(n.getLabel());return}}}this.updateToggleLabel(this.trans("Formats"))}updateToggleLabel(e){let t=this.getDOMElement().querySelector("button");t&&(t.innerText=e)}};var Ye=class extends w{constructor(e,t){super(t),this.previewSampleElement=e}buildDOM(){let e=super.buildDOM();e.innerHTML="";let t=b("span",{class:"editor-button-format-preview"},[this.getLabel()]),n=this.getStylesFromPreview();for(let r of Object.keys(n))t.style.setProperty(r,n[r]);return e.append(t),e}getStylesFromPreview(){let e=b("div",{style:"display: none",hidden:"true",class:"page-content"}),t=this.previewSampleElement.cloneNode();t.textContent=this.getLabel(),e.append(t),document.body.append(e);let n=["color","font-size","background-color","border-inline-start"],r={},i=window.getComputedStyle(t);for(let s of n)r[s]=i.getPropertyValue(s);return e.remove(),r}};var Of='';var ts=class extends w{buildDOM(){let e=super.buildDOM(),t=b("div",{class:"editor-menu-button-icon"});return t.innerHTML=Of,e.append(t),e}};var Ax={showOnHover:!1,direction:"horizontal",showAside:void 0,button:{label:"Menu"}},Ee=class extends te{constructor(t,n){super(n);this.open=!1;if(this.childItems=n,this.options=Object.assign({},Ax,t),t.button instanceof w)this.button=t.button;else{let r=t.button.format==="long"?ts:w;this.button=new r({...t.button,action(){return!1},isActive:()=>this.open})}this.addChildren(this.button)}insertItems(...t){this.addChildren(...t),this.childItems.push(...t)}buildDOM(){let t=this.button.getDOMElement(),n=this.childItems.map(s=>s.getDOMElement()),r=b("div",{class:`editor-dropdown-menu editor-dropdown-menu-${this.options.direction}`,hidden:"true"},n),i=b("div",{class:"editor-dropdown-menu-container"},[t,r]);return Qi({toggle:t,menu:r,showOnHover:this.options.showOnHover,showAside:typeof this.options.showAside=="boolean"?this.options.showAside:this.options.direction==="vertical",onOpen:()=>{this.open=!0,this.getContext().manager.triggerStateUpdateForElement(this.button)},onClose:()=>{this.open=!1,this.getContext().manager.triggerStateUpdateForElement(this.button)}}),i}};var Af='';var Rf='';function kf(){let o=()=>((1+Math.random())*65536|0).toString(16).substring(1);return`${o()+o()}-${o()}-${o()}-${o()}-${o()}${o()}${o()}`}function os(){return((1+Math.random())*65536|0).toString(16).substring(1)}var If=["#000000","#ffffff","#BFEDD2","#FBEEB8","#F8CAC6","#ECCAFA","#C2E0F4","#2DC26B","#F1C40F","#E03E2D","#B96AD9","#3598DB","#169179","#E67E23","#BA372A","#843FA1","#236FA1","#ECF0F1","#CED4D9","#95A5A6","#7E8C8D","#34495E"],$f="bs-lexical-custom-colors",tn=class extends Me{constructor(e){super(),this.callback=e}buildDOM(){let e=os(),n=[...If,...this.getCustomColorChoices()].map(c=>b("div",{class:"editor-color-select-option",style:`background-color: ${c}`,"data-color":c,"aria-label":c})),r=b("div",{class:"editor-color-select-option","data-color":"",title:this.getContext().translate("Remove color")},[]);r.innerHTML=Af,n.push(r);let i=b("label",{class:"editor-color-select-option",for:`color-select-${e}`,"data-color":"",title:this.getContext().translate("Custom color")},[]);i.innerHTML=Rf,n.push(i);let s=b("input",{type:"color",hidden:"true",id:`color-select-${e}`});n.push(s),s.addEventListener("change",c=>{s.value&&(this.storeCustomColorChoice(s.value),this.setColor(s.value),this.rebuildDOM())});let l=[];for(let c=0;c{let l=s.target.closest(".editor-table-creator-cell");if(l){let a=Number(l.dataset.rows||0),c=Number(l.dataset.columns||0);this.updateGridSelection(a,c,n,r)}}),i.addEventListener("click",s=>{let l=s.target.closest(".editor-table-creator-cell");l&&this.onCellClick(l)}),i.addEventListener("mouseleave",s=>{this.updateGridSelection(0,0,n,r)}),b("div",{class:"editor-table-creator"},[i,r])}updateGridSelection(e,t,n,r){for(let i of n){let s=Number(i.dataset.rows)<=e&&Number(i.dataset.columns)<=t;i.classList.toggle("active",s)}r.textContent=`${e} x ${t}`}onCellClick(e){let t=Number(e.dataset.rows||0),n=Number(e.dataset.columns||0);if(t<1||n<1)return;let r=Math.min(Math.round(840/n),240),i=Array(n).fill(r+"px");this.getContext().editor.update(()=>{let s=ea(t,n,!1);s.setColWidths(i),Yo(s)})}};var Kr=class extends w{constructor(e,t){super(e),this.style=t}getColorBar(){let e=this.getDOMElement().querySelector("svg .editor-icon-color-bar");if(!e)throw new Error(`Could not find expected color bar in the icon for this ${this.definition.label} button`);return e}updateState(e){if(super.updateState(e),_(e.selection)){let t=Bl(e.selection,this.style);this.getColorBar().setAttribute("fill",t)}}};var Pf='';var nt=class extends te{constructor(e,t){super(t),this.size=e,this.content=t,this.overflowButton=new Ee({button:{label:"More",icon:Pf}},[]),this.addChildren(this.overflowButton)}buildDOM(){let e=this.content.length>this.size?this.size-1:this.size,t=this.content.slice(0,e),n=this.content.slice(e),r=t.map(i=>i.getDOMElement());return n.length>0&&(this.removeChildren(...n),this.overflowButton.insertItems(...n),r.push(this.overflowButton.getDOMElement())),b("div",{class:"editor-overflow-container"},r)}};var xa='';var rs='';var Bf='';var Ff='';var Hf='';var Kf='';var Uf='';var zf='';var It=class extends Me{constructor(e){super(),this.definition=e}setValue(e){let t=this.getDOMElement().querySelector("input,select,textarea");this.definition.type==="checkbox"?t.checked=!!e:t.value=e,t.dispatchEvent(new Event("change"))}getName(){return this.definition.name}buildDOM(){let e=`editor-form-field-${this.definition.name}-${Date.now()}`,t;if(this.definition.type==="select"){let n=this.definition.valuesByLabel,i=Object.keys(n).map(s=>b("option",{value:n[s]},[this.trans(s)]));t=b("select",{id:e,name:this.definition.name,class:"editor-form-field-input"},i)}else this.definition.type==="textarea"?t=b("textarea",{id:e,name:this.definition.name,class:"editor-form-field-input"}):this.definition.type==="checkbox"?t=b("input",{id:e,name:this.definition.name,type:"checkbox",class:"editor-form-field-input-checkbox",value:"true"}):t=b("input",{id:e,name:this.definition.name,class:"editor-form-field-input"});return b("div",{class:"editor-form-field-wrapper"},[b("label",{class:"editor-form-field-label",for:e},[this.trans(this.definition.label)]),t])}},is=class extends te{constructor(t){let n=t.fields.map(r=>Na(r)?r.build():new It(r));super(n);this.onCancel=null;this.onSuccessfulSubmit=null;this.definition=t}setValues(t){for(let n of Object.keys(t)){let r=this.getFieldByName(n);r&&r.setValue(t[n])}}setOnCancel(t){this.onCancel=t}setOnSuccessfulSubmit(t){this.onSuccessfulSubmit=t}getFieldByName(t){let n=r=>{for(let i of r){if(i instanceof It&&i.getName()===t)return i;if(i instanceof te){let s=n(i.getChildren());if(s)return s}}return null};return n(this.getChildren())}buildDOM(){let t=b("button",{type:"button",class:"editor-form-action-secondary"},[this.trans("Cancel")]),n=b("form",{},[...this.children.map(r=>r.getDOMElement()),b("div",{class:"editor-form-actions"},[t,b("button",{type:"submit",class:"editor-form-action-primary"},[this.trans(this.definition.submitText)])])]);return n.addEventListener("submit",async r=>{r.preventDefault();let i=new FormData(n);await this.definition.action(i,this.getContext())&&this.onSuccessfulSubmit&&this.onSuccessfulSubmit()}),t.addEventListener("click",r=>{this.onCancel&&this.onCancel()}),n}},Ea=class extends te{constructor(e){let t=e.contents.map(n=>Na(n)?n.build():new It(n));super(t),this.definition=e,this.fields=t,this.id=kf()}getLabel(){return this.getContext().translate(this.definition.label)}getId(){return this.id}buildDOM(){return b("div",{class:"editor-form-tab-content",role:"tabpanel",id:`editor-tabpanel-${this.id}`,"aria-labelledby":`editor-tab-${this.id}`},this.fields.map(e=>e.getDOMElement()))}},on=class extends te{constructor(t){let n=t.map(r=>new Ea(r));super(n);this.definitions=[];this.tabs=[];this.definitions=t,this.tabs=n}buildDOM(){let t=[],n=[],r=i=>{for(let s=0;s{r(t.indexOf(s))})}return r(0),b("div",{class:"editor-form-tab-container"},[b("div",{class:"editor-form-tab-controls"},t),b("div",{class:"editor-form-tab-contents"},n)])}};var Wf=`