bookstack/public/dist/wysiwyg.js

22 lines
282 KiB
JavaScript

// See the "/licenses" URI for full package license details
function k(o){return __DEV__?{type:o}:{}}var De=k("SELECTION_CHANGE_COMMAND"),ar=k("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),dr=k("CLICK_COMMAND"),Ge=k("DELETE_CHARACTER_COMMAND"),$t=k("INSERT_LINE_BREAK_COMMAND"),Pt=k("INSERT_PARAGRAPH_COMMAND"),lt=k("CONTROLLED_TEXT_INSERTION_COMMAND"),ro=k("PASTE_COMMAND"),_n=k("REMOVE_TEXT_COMMAND"),bt=k("DELETE_WORD_COMMAND"),at=k("DELETE_LINE_COMMAND"),Ne=k("FORMAT_TEXT_COMMAND"),io=k("UNDO_COMMAND"),so=k("REDO_COMMAND"),Gs=k("KEYDOWN_COMMAND"),Ro=k("KEY_ARROW_RIGHT_COMMAND"),Js=k("MOVE_TO_END"),Io=k("KEY_ARROW_LEFT_COMMAND"),js=k("MOVE_TO_START"),ko=k("KEY_ARROW_UP_COMMAND"),$o=k("KEY_ARROW_DOWN_COMMAND"),dt=k("KEY_ENTER_COMMAND"),Qs=k("KEY_SPACE_COMMAND"),Ft=k("KEY_BACKSPACE_COMMAND"),Po=k("KEY_ESCAPE_COMMAND"),Bt=k("KEY_DELETE_COMMAND"),Fo=k("KEY_TAB_COMMAND"),el=k("INSERT_TAB_COMMAND"),tl=k("INDENT_CONTENT_COMMAND"),ui=k("OUTDENT_CONTENT_COMMAND"),Bo=k("DROP_COMMAND"),cr=k("FORMAT_ELEMENT_COMMAND"),ur=k("DRAGSTART_COMMAND"),fr=k("DRAGOVER_COMMAND"),ol=k("DRAGEND_COMMAND"),lo=k("COPY_COMMAND"),ao=k("CUT_COMMAND"),yn=k("SELECT_ALL_COMMAND"),nl=k("CLEAR_EDITOR_COMMAND"),rl=k("CLEAR_HISTORY_COMMAND"),co=k("CAN_REDO_COMMAND"),uo=k("CAN_UNDO_COMMAND"),mr=k("FOCUS_COMMAND"),il=k("BLUR_COMMAND"),sl=k("KEY_MODIFIER_COMMAND");var me=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";var wh=me&&"documentMode"in document?document.documentMode:null,Fe=me&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Be=me&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),fo=me&&"InputEvent"in window&&!wh?"getTargetRanges"in new window.InputEvent("input"):!1,Ht=me&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),St=me&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Ld=me&&/Android/.test(navigator.userAgent),ll=me&&/^(?=.*Chrome).*/i.test(navigator.userAgent),al=me&&Ld&&ll,Kt=me&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!ll;var mo=1,He=3,Lt=0,dl=1,Ut=2,Md=0,fi=1,mi=2,pr=1,gr=2,bn=4,Sn=8,hr=16,Nr=32,xr=64,Er=128,cl=pr|gr|bn|Sn|hr|Nr|xr|Er,pi=1,Ln=2,gi=1,hi=2,Ni=3,xi=4,Ei=5,Ti=6,vd="\xA0",Oh="\u200B",Mn=Ht||St||Kt?vd:Oh,Je=`
`,wd=Be?vd:Mn,Od="\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC",Dd="A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u0300-\u0590\u0800-\u1FFF\u200E\u2C00-\uFB1C\uFE00-\uFE6F\uFEFD-\uFFFF",Dh=new RegExp("^[^"+Dd+"]*["+Od+"]"),Ah=new RegExp("^[^"+Od+"]*["+Dd+"]"),Ae={bold:pr,code:hr,highlight:Er,italic:gr,strikethrough:bn,subscript:Nr,superscript:xr,underline:Sn},Ad={directionless:pi,unmergeable:Ln},ul={center:hi,end:Ti,justify:xi,left:gi,right:Ni,start:Ei},Rd={[hi]:"center",[Ti]:"end",[xi]:"justify",[gi]:"left",[Ni]:"right",[Ei]:"start"},Id={normal:Md,segmented:mi,token:fi},kd={[Md]:"normal",[mi]:"segmented",[fi]:"token"};function E(o,e,...t){if(!o)throw new Error("Internal Lexical error: invariant() is meant to be replaced at compile time. There is no runtime version. Error: "+e)}function Ke(...o){let e=[];for(let t of o)if(t&&typeof t=="string")for(let[n]of t.matchAll(/\S+/g))e.push(n);return e}var Rh=100,ml=!1,pl=0;function $d(){return ml}function Ih(o){pl=o.timeStamp}function kh(o){pl===0&&vn(o).addEventListener("textInput",Ih,!0)}function fl(o,e,t){return e.__lexicalLineBreak===o||o[`__lexicalKey_${t._key}`]!==void 0}function $h(o){return o.getEditorState().read(()=>{let e=T();return e!==null?e.clone():null})}function Ph(o,e,t){let n=Se(t._window),r=null,i=null;n!==null&&n.anchorNode===o&&(r=n.anchorOffset,i=n.focusOffset);let s=o.nodeValue;s!==null&&Tr(e,s,r,i,!1)}function Fh(o,e,t){if(_(o)){let n=o.anchor.getNode();if(n.is(t)&&o.format!==n.getFormat())return!1}return e.nodeType===He&&t.isAttached()}function Pd(o,e,t){ml=!0;let n=performance.now()-pl>Rh;try{xe(o,()=>{let r=T()||$h(o),i=new Map,s=o.getRootElement(),l=o._editorState,a=o._blockCursorElement,d=!1,f="";for(let c=0;c<e.length;c++){let u=e[c],p=u.type,g=u.target,h=J(g,l);if(!(h===null&&g!==s||F(h))){if(p==="characterData")n&&y(h)&&Fh(r,g,h)&&Ph(g,h,o);else if(p==="childList"){d=!0;let C=u.addedNodes;for(let M=0;M<C.length;M++){let S=C[M],D=gl(S),O=S.parentNode;if(O!=null&&S!==a&&D===null&&(S.nodeName!=="BR"||!fl(S,O,o))){if(Be){let A=S.innerText||S.nodeValue;A&&(f+=A)}O.removeChild(S)}}let N=u.removedNodes,L=N.length;if(L>0){let M=0;for(let S=0;S<L;S++){let D=N[S];(D.nodeName==="BR"&&fl(D,g,o)||a===D)&&(g.appendChild(D),M++)}L!==M&&(g===s&&(h=hl(l)),i.set(g,h))}}}}if(i.size>0)for(let[c,u]of i)if(x(u)){let p=u.getChildrenKeys(),g=c.firstChild;for(let h=0;h<p.length;h++){let C=p[h],N=o.getElementByKey(C);N!==null&&(g==null?(c.appendChild(N),g=N):g!==N&&c.replaceChild(N,g),g=g.nextSibling)}}else y(u)&&u.markDirty();let m=t.takeRecords();if(m.length>0){for(let c=0;c<m.length;c++){let u=m[c],p=u.addedNodes,g=u.target;for(let h=0;h<p.length;h++){let C=p[h],N=C.parentNode;N!=null&&C.nodeName==="BR"&&!fl(C,g,o)&&N.removeChild(C)}}t.takeRecords()}r!==null&&(d&&(r.dirty=!0,Y(r)),Be&&yi(o)&&r.insertRawText(f))})}finally{ml=!1}}function Ci(o){let e=o._observer;if(e!==null){let t=e.takeRecords();Pd(o,t,e)}}function _i(o){kh(o),o._observer=new MutationObserver((e,t)=>{Pd(o,e,t)})}function Fd(o,e){let t=o.__mode,n=o.__format,r=o.__style,i=e.__mode,s=e.__format,l=e.__style;return(t===null||t===i)&&(n===null||n===s)&&(r===null||r===l)}function Bd(o,e){let t=o.mergeWithSibling(e),n=V()._normalizedNodes;return n.add(o.__key),n.add(e.__key),t}function Nl(o){let e=o;if(e.__text===""&&e.isSimpleText()&&!e.isUnmergeable()){e.remove();return}let t;for(;(t=e.getPreviousSibling())!==null&&y(t)&&t.isSimpleText()&&!t.isUnmergeable();)if(t.__text==="")t.remove();else if(Fd(t,e)){e=Bd(t,e);break}else break;let n;for(;(n=e.getNextSibling())!==null&&y(n)&&n.isSimpleText()&&!n.isUnmergeable();)if(n.__text==="")n.remove();else if(Fd(e,n)){e=Bd(e,n);break}else break}function Ho(o){return Hd(o.anchor),Hd(o.focus),o}function Hd(o){for(;o.type==="element";){let e=o.getNode(),t=o.offset,n,r;if(t===e.getChildrenSize()?(n=e.getChildAtIndex(t-1),r=!0):(n=e.getChildAtIndex(t),r=!1),y(n)){o.set(n.__key,r?n.getTextContentSize():0,"text");break}else if(!x(n))break;o.set(n.__key,r?n.getChildrenSize():0,"element")}}var Bh=1;function Hh(){return""+Bh++}function zd(o,e){let t=o._nodes.get(e);return t===void 0&&E(!1,"registeredNode: Type %s not found",e),t}var jT=Array.isArray,Wd=typeof queueMicrotask=="function"?queueMicrotask:o=>{Promise.resolve().then(o)};function qd(o){return F(J(o))}function An(o){let e=document.activeElement;if(e===null)return!1;let t=e.nodeName;return F(J(o))&&(t==="INPUT"||t==="TEXTAREA"||e.contentEditable==="true"&&Ko(e)==null)}function zt(o,e,t){let n=o.getRootElement();try{return n!==null&&n.contains(e)&&n.contains(t)&&e!==null&&!An(e)&&bi(e)===o}catch{return!1}}function Rn(o){return o instanceof ho}function bi(o){let e=o;for(;e!=null;){let t=Ko(e);if(Rn(t))return t;e=wi(e)}return null}function Ko(o){return o?o.__lexicalEditor:null}function Ue(o){return o.isToken()||o.isSegmented()}function Kh(o){return o.nodeType===He}function In(o){let e=o;for(;e!=null;){if(Kh(e))return e;e=e.firstChild}return null}function _r(o,e,t){let n=Ae[e];if(t!==null&&(o&n)===(t&n))return o;let r=o^n;return e==="subscript"?r&=~Ae.superscript:e==="superscript"&&(r&=~Ae.subscript),r}function yr(o){return y(o)||Ce(o)||F(o)}function Yd(o,e){if(e!=null){__DEV__&&Uh(o,e),o.__key=e;return}de(),Ml();let t=V(),n=Qe(),r=Hh();n._nodeMap.set(r,o),x(o)?t._dirtyElements.set(r,!0):t._dirtyLeaves.add(r),t._cloneNotNeeded.add(r),t._dirtyType=dl,o.__key=r}function Uh(o,e){let t=Dc();if(!t)return;let n=t._nodeMap.get(e);n&&n.constructor!==o.constructor&&(o.constructor.name!==n.constructor.name?E(!1,"Lexical node with constructor %s attempted to re-use key from node in active editor state with constructor %s. Keys must not be re-used when the type is changed.",o.constructor.name,n.constructor.name):E(!1,"Lexical node with constructor %s attempted to re-use key from node in active editor state with different constructor with the same name (possibly due to invalid Hot Module Replacement). Keys must not be re-used when the type is changed.",o.constructor.name))}function zh(o,e,t){let n=o;for(;n!==null;){if(t.has(n))return;let r=e.get(n);if(r===void 0)break;t.set(n,!1),n=r.__parent}}function Wt(o){let e=o.getParent();if(e!==null){let t=o.getWritable(),n=e.getWritable(),r=o.getPreviousSibling(),i=o.getNextSibling();if(r===null)if(i!==null){let s=i.getWritable();n.__first=i.__key,s.__prev=null}else n.__first=null;else{let s=r.getWritable();if(i!==null){let l=i.getWritable();l.__prev=s.__key,s.__next=l.__key}else s.__next=null;t.__prev=null}if(i===null)if(r!==null){let s=r.getWritable();n.__last=r.__key,s.__next=null}else n.__last=null;else{let s=i.getWritable();if(r!==null){let l=r.getWritable();l.__next=s.__key,s.__prev=l.__key}else s.__prev=null;t.__next=null}n.__size--,t.__parent=null}}function Cr(o){Ml();let e=o.getLatest(),t=e.__parent,n=Qe(),r=V(),i=n._nodeMap,s=r._dirtyElements;t!==null&&zh(t,i,s);let l=e.__key;r._dirtyType=dl,x(o)?s.set(l,!0):r._dirtyLeaves.add(l)}function Vd(o){let e=o.getPreviousSibling(),t=o.getNextSibling();e!==null&&Cr(e),t!==null&&Cr(t)}function ie(o){de();let e=V(),t=e._compositionKey;if(o!==t){if(e._compositionKey=o,t!==null){let n=X(t);n!==null&&n.getWritable()}if(o!==null){let n=X(o);n!==null&&n.getWritable()}}}function je(){return ct()?null:V()._compositionKey}function X(o,e){let n=(e||Qe())._nodeMap.get(o);return n===void 0?null:n}function gl(o,e){let t=V(),n=o[`__lexicalKey_${t._key}`];return n!==void 0?X(n,e):null}function J(o,e){let t=o;for(;t!=null;){let n=gl(t,e);if(n!==null)return n;t=wi(t)}return null}function Si(o){let e=o._decorators,t=Object.assign({},e);return o._pendingDecorators=t,t}function El(o){return o.read(()=>B().getTextContent())}function Xd(o,e){xe(o,()=>{let t=Qe();if(t.isEmpty())return;if(e==="root"){B().markDirty();return}let n=t._nodeMap;for(let[,r]of n)r.markDirty()},o._pendingEditorState===null?{tag:"history-merge"}:void 0)}function B(){return hl(Qe())}function hl(o){return o._nodeMap.get("root")}function Y(o){de();let e=Qe();o!==null&&(__DEV__&&Object.isFrozen(o)&&E(!1,"$setSelection called on frozen selection object. Ensure selection is cloned before passing in."),o.dirty=!0,o.setCachedNodes(null)),e._selection=o}function Zd(){de();let o=V();Ci(o)}function Uo(o){let e=V(),t=Wh(o,e);if(t===null){let n=e.getRootElement();return o===n?X("root"):null}return X(t)}function Tl(o,e){return e?o.getTextContentSize():0}function Wh(o,e){let t=o;for(;t!=null;){let n=t[`__lexicalKey_${e._key}`];if(n!==void 0)return n;t=wi(t)}return null}function Li(o){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(o)}function br(o){let e=[],t=o;for(;t!==null;)e.push(t),t=t._parentEditor;return e}function Cl(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function _l(o){return o.nodeType===He?o.nodeValue:null}function Mi(o,e,t){let n=Se(e._window);if(n===null)return;let r=n.anchorNode,{anchorOffset:i,focusOffset:s}=n;if(r!==null){let l=_l(r),a=J(r);if(l!==null&&y(a)){if(l===Mn&&t){let d=t.length;l=t,i=d,s=d}l!==null&&Tr(a,l,i,s,o)}}}function Tr(o,e,t,n,r){let i=o;if(i.isAttached()&&(r||!i.isDirty())){let s=i.isComposing(),l=e;(s||r)&&e[e.length-1]===Mn&&(l=e.slice(0,-1));let a=i.getTextContent();if(r||l!==a){if(l===""){if(ie(null),!Ht&&!St&&!Kt){let g=V();setTimeout(()=>{g.update(()=>{i.isAttached()&&i.remove()})},20)}else i.remove();return}let d=i.getParent(),f=ze(),m=i.getTextContentSize(),c=je(),u=i.getKey();if(i.isToken()||c!==null&&u===c&&!s||_(f)&&(d!==null&&!d.canInsertTextBefore()&&f.anchor.offset===0||f.anchor.key===o.__key&&f.anchor.offset===0&&!i.canInsertTextBefore()&&!s||f.focus.key===o.__key&&f.focus.offset===m&&!i.canInsertTextAfter()&&!s)){i.markDirty();return}let p=T();if(!_(p)||t===null||n===null){i.setTextContent(l);return}if(p.setTextNodeRange(i,t,i,n),i.isSegmented()){let g=i.getTextContent(),h=Z(g);i.replace(h),i=h}i.setTextContent(l)}}}function qh(o){let e=o.getPreviousSibling();return(y(e)||x(e)&&e.isInline())&&!e.canInsertTextAfter()}function Gd(o,e){if(e.isSegmented())return!0;if(!o.isCollapsed())return!1;let t=o.anchor.offset,n=e.getParentOrThrow(),r=e.isToken();return t===0?!e.canInsertTextBefore()||!n.canInsertTextBefore()&&!e.isComposing()||r||qh(e):t===e.getTextContentSize()?!e.canInsertTextAfter()||!n.canInsertTextAfter()&&!e.isComposing()||r:!1}function Jd(o,e,t,n){return o==="Tab"&&!e&&!t&&!n}function jd(o,e,t,n){return o.toLowerCase()==="b"&&!e&&Sr(t,n)}function Qd(o,e,t,n){return o.toLowerCase()==="i"&&!e&&Sr(t,n)}function ec(o,e,t,n){return o.toLowerCase()==="u"&&!e&&Sr(t,n)}function tc(o,e){return bc(o)&&!e}function oc(o,e){return bc(o)&&e}function nc(o,e){return Fe&&e&&o.toLowerCase()==="o"}function rc(o,e,t){return wn(o)&&(Fe?e:t)}function ic(o,e,t){return On(o)&&(Fe?e:t)}function sc(o,e){return Fe&&e&&wn(o)}function lc(o,e){return Fe&&e&&On(o)}function ac(o,e,t,n){return Fe?e||t?!1:wn(o)||o.toLowerCase()==="h"&&n:n||e||t?!1:wn(o)}function dc(o,e,t,n,r){return Fe?t||n||r?!1:On(o)||o.toLowerCase()==="d"&&e:e||n||r?!1:On(o)}function cc(o,e,t,n){return o.toLowerCase()==="z"&&!e&&Sr(t,n)}function uc(o,e,t,n){return Fe?o.toLowerCase()==="z"&&t&&e:o.toLowerCase()==="y"&&n||o.toLowerCase()==="z"&&n&&e}function fc(o,e,t,n){return e?!1:o.toLowerCase()==="c"?Fe?t:n:!1}function mc(o,e,t,n){return e?!1:o.toLowerCase()==="x"?Fe?t:n:!1}function pc(o){return o==="ArrowLeft"}function gc(o){return o==="ArrowRight"}function Yh(o){return o==="ArrowUp"}function Vh(o){return o==="ArrowDown"}function hc(o,e,t,n){return pc(o)&&!e&&!n&&!t}function Nc(o,e,t,n,r){return pc(o)&&!n&&!t&&(e||r)}function xc(o,e,t,n){return gc(o)&&!e&&!n&&!t}function Ec(o,e,t,n,r){return gc(o)&&!n&&!t&&(e||r)}function Tc(o,e,t){return Yh(o)&&!e&&!t}function Cc(o,e,t){return Vh(o)&&!e&&!t}function _c(o,e,t,n){return o||e||t||n}function yc(o){return o===" "}function Sr(o,e){return Fe?o:e}function bc(o){return o==="Enter"}function wn(o){return o==="Backspace"}function Sc(o){return o==="Escape"}function On(o){return o==="Delete"}function yl(o,e,t){return o.toLowerCase()==="a"&&Sr(e,t)}function bl(){let o=B(),e=o.select(0,o.getChildrenSize());Y(Ho(e))}function po(o,e){o.__lexicalClassNameCache===void 0&&(o.__lexicalClassNameCache={});let t=o.__lexicalClassNameCache,n=t[e];if(n!==void 0)return n;let r=o[e];if(typeof r=="string"){let i=Ke(r);return t[e]=i,i}return r}function vi(o,e,t,n,r){if(t.size===0)return;let i=n.__type,s=n.__key,l=e.get(i);l===void 0&&E(!1,"Type %s not in registeredNodes",i);let a=l.klass,d=o.get(a);d===void 0&&(d=new Map,o.set(a,d));let f=d.get(s),m=f==="destroyed"&&r==="created";(f===void 0||m)&&d.set(s,m?"updated":r)}function Kd(o,e,t){let n=o.getParent(),r=t,i=o;return n!==null&&(e&&t===0?(r=i.getIndexWithinParent(),i=n):!e&&t===i.getChildrenSize()&&(r=i.getIndexWithinParent()+1,i=n)),i.getChildAtIndex(e?r-1:r)}function qt(o,e){let t=o.offset;if(o.type==="element"){let n=o.getNode();return Kd(n,e,t)}else{let n=o.getNode();if(e&&t===0||!e&&t===n.getTextContentSize()){let r=e?n.getPreviousSibling():n.getNextSibling();return r===null?Kd(n.getParentOrThrow(),e,n.getIndexWithinParent()+(e?0:1)):r}}return null}function yi(o){let e=vn(o).event,t=e&&e.inputType;return t==="insertFromPaste"||t==="insertFromPasteAsQuotation"}function w(o,e,t){return vl(o,e,t)}function Lr(o){return!G(o)&&!o.isLastChild()&&!o.isInline()}function kn(o,e){let t=o._keyToDOMMap.get(e);return t===void 0&&E(!1,"Reconciliation: could not find DOM element for node key %s",e),t}function wi(o){let e=o.assignedSlot||o.parentElement;return e!==null&&e.nodeType===11?e.host:e}function Lc(o,e,t){let n=t.ownerDocument,r=n.defaultView;if(r===null)return;let{top:i,bottom:s}=e,l=0,a=0,d=t;for(;d!==null;){let f=d===n.body;if(f)l=0,a=vn(o).innerHeight;else{let c=d.getBoundingClientRect();l=c.top,a=c.bottom}let m=0;if(i<l?m=-(l-i):s>a&&(m=s-a),m!==0)if(f)r.scrollBy(0,m);else{let c=d.scrollTop;d.scrollTop+=m;let u=d.scrollTop-c;i-=u,s-=u}if(f)break;d=wi(d)}}function Mc(o){let e=T();if(!_(e)||!x(o))return e;let{anchor:t,focus:n}=e,r=t.getNode(),i=n.getNode();return Dn(r,o)&&t.set(o.__key,0,"element"),Dn(i,o)&&n.set(o.__key,0,"element"),e}function Dn(o,e){let t=o.getParent();for(;t!==null;){if(t.is(e))return!0;t=t.getParent()}return!1}function vc(o){let e=o.ownerDocument;return e&&e.defaultView||null}function vn(o){let e=o._window;return e===null&&E(!1,"window object not found"),e}function Sl(o){let e=o.getParentOrThrow();for(;e!==null;){if(pe(e))return e;e=e.getParentOrThrow()}return e}var QT=Symbol.for("@lexical/ShadowRootNodeBrand");function pe(o){return G(o)||x(o)&&o.isShadowRoot()}function re(o){let e=V(),t=o.constructor.getType(),n=e._nodes.get(t);n===void 0&&E(!1,'$initializeNode failed. Ensure node has been registered to the editor. You can do this by passing the node class via the "nodes" array in the editor config.');let r=n.replace;if(r!==null){let i=r(o);return i instanceof o.constructor||E(!1,"$initializeNode failed. Ensure replacement node is a subclass of the original node."),i}return o}function Oi(o,e){let t=o.getParent();G(t)&&!x(e)&&!F(e)&&E(!1,"Only element or decorator nodes can be inserted in to the root node")}function Xh(o){let e=o.theme,t=document.createElement("div");t.contentEditable="false",t.setAttribute("data-lexical-cursor","true");let n=e.blockCursor;if(n!==void 0){if(typeof n=="string"){let r=Ke(n);n=e.blockCursor=r}n!==void 0&&t.classList.add(...n)}return t}function xl(o){return(F(o)||x(o)&&!o.canBeEmpty())&&!o.isInline()}function Mr(o,e,t){t.style.removeProperty("caret-color"),e._blockCursorElement=null;let n=o.parentElement;n!==null&&n.removeChild(o)}function wc(o,e,t){let n=o._blockCursorElement;if(_(t)&&t.isCollapsed()&&t.anchor.type==="element"&&e.contains(document.activeElement)){let r=t.anchor,i=r.getNode(),s=r.offset,l=i.getChildrenSize(),a=!1,d=null;if(s===l){let f=i.getChildAtIndex(s-1);xl(f)&&(a=!0)}else{let f=i.getChildAtIndex(s);if(xl(f)){let m=f.getPreviousSibling();(m===null||xl(m))&&(a=!0,d=o.getElementByKey(f.__key))}}if(a){let f=o.getElementByKey(i.__key);n===null&&(o._blockCursorElement=n=Xh(o._config)),e.style.caretColor="transparent",d===null?f.appendChild(n):f.insertBefore(n,d);return}}n!==null&&Mr(n,o,e)}function Se(o){return me?(o||window).getSelection():null}function Di(o){return Ee(o)&&o.tagName==="A"}function Ee(o){return o.nodeType===1}function zo(o){let e=new RegExp(/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/,"i");return o.nodeName.match(e)!==null}function go(o){let e=new RegExp(/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/,"i");return o.nodeName.match(e)!==null}function Wo(o){if(G(o)||F(o)&&!o.isInline())return!0;if(!x(o)||pe(o))return!1;let e=o.getFirstChild(),t=e===null||Ce(e)||y(e)||e.isInline();return!o.isInline()&&o.canBeEmpty()!==!1&&t}function Ai(o,e){let t=o;for(;t!==null&&t.getParent()!==null&&!e(t);)t=t.getParentOrThrow();return e(t)?t:null}function Ll(){return V()}var Ud=new WeakMap,Zh=new Map;function Oc(o){if(!o._readOnly&&o.isEmpty())return Zh;E(o._readOnly,"getCachedTypeToNodeMap called with a writable EditorState");let e=Ud.get(o);if(!e){e=new Map,Ud.set(o,e);for(let[t,n]of o._nodeMap){let r=n.__type,i=e.get(r);i||(i=new Map,e.set(r,i)),i.set(t,n)}}return e}function Yt(o){let e=o.constructor,t=e.clone(o);return t.afterCloneFrom(o),__DEV__&&(E(t.__key===o.__key,"$cloneWithProperties: %s.clone(node) (with type '%s') did not return a node with the same key, make sure to specify node.__key as the last argument to the constructor",e.name,e.getType()),E(t.__parent===o.__parent&&t.__next===o.__next&&t.__prev===o.__prev,"$cloneWithProperties: %s.clone(node) (with type '%s') overrided afterCloneFrom but did not call super.afterCloneFrom(prevNode)",e.name,e.getType())),t}function Ac(o,e){let t=o._decorators,r=o._pendingDecorators||t,i=e._nodeMap,s;for(s in r)i.has(s)||(r===t&&(r=Si(o)),delete r[s])}function Rc(o,e,t,n,r,i){let s=o.getFirstChild();for(;s!==null;){let l=s.__key;s.__parent===e&&(x(s)&&Rc(s,l,t,n,r,i),t.has(l)||i.delete(l),r.push(l)),s=s.getNextSibling()}}function Ic(o,e,t,n){let r=o._nodeMap,i=e._nodeMap,s=[];for(let[l]of n){let a=i.get(l);a!==void 0&&(a.isAttached()||(x(a)&&Rc(a,l,r,i,s,n),r.has(l)||n.delete(l),s.push(l)))}for(let l of s)i.delete(l);for(let l of t){let a=i.get(l);a!==void 0&&!a.isAttached()&&(r.has(l)||t.delete(l),i.delete(l))}}var ce="",Mt=null,ut="",Vt="",Yo,Le,wr,$c=!1,Ii=!1,ki,Ol,Dl,Vo,ft,Al,Or;function $i(o,e){let t=Vo.get(o);if(e!==null){let n=kl(o);n.parentNode===e&&e.removeChild(n)}if(ft.has(o)||Le._keyToDOMMap.delete(o),x(t)){let n=Ri(t,Vo);Rl(n,0,n.length-1,null)}t!==void 0&&vi(Or,wr,ki,t,"destroyed")}function Rl(o,e,t,n){let r=e;for(;r<=t;++r){let i=o[r];i!==void 0&&$i(i,n)}}function qo(o,e){o.setProperty("text-align",e)}var Gh="40px";function Pc(o,e){let t=Yo.theme.indent;if(typeof t=="string"){let r=o.classList.contains(t);e>0&&!r?o.classList.add(t):e<1&&r&&o.classList.remove(t)}let n=getComputedStyle(o).getPropertyValue("--lexical-indent-base-value")||Gh;o.style.setProperty("padding-inline-start",e===0?"":`calc(${e} * ${n})`)}function Fc(o,e){let t=o.style;e===0?qo(t,""):e===gi?qo(t,"left"):e===hi?qo(t,"center"):e===Ni?qo(t,"right"):e===xi?qo(t,"justify"):e===Ei?qo(t,"start"):e===Ti&&qo(t,"end")}function Pi(o,e,t){let n=ft.get(o);n===void 0&&E(!1,"createNode: node does not exist in nodeMap");let r=n.createDOM(Yo,Le);if(nN(o,r,Le),y(n)?r.setAttribute("data-lexical-text","true"):F(n)&&r.setAttribute("data-lexical-decorator","true"),x(n)){let i=n.__indent,s=n.__size;if(i!==0&&Pc(r,i),s!==0){let a=s-1,d=Ri(n,ft);Il(d,n,0,a,r,null)}let l=n.__format;l!==0&&Fc(r,l),n.isInline()||Bc(null,n,r),Lr(n)&&(ce+=Je,Vt+=Je)}else{let i=n.getTextContent();if(F(n)){let s=n.decorate(Le,Yo);s!==null&&Hc(o,s),r.contentEditable="false"}ce+=i,Vt+=i}if(e!==null)if(t!=null)e.insertBefore(r,t);else{let i=e.__lexicalLineBreak;i!=null?e.insertBefore(r,i):e.appendChild(r)}return __DEV__&&Object.freeze(n),vi(Or,wr,ki,n,"created"),r}function Il(o,e,t,n,r,i){let s=ce;ce="";let l=t;for(;l<=n;++l){Pi(o[l],r,i);let a=ft.get(o[l]);a!==null&&y(a)&&(Mt===null&&(Mt=a.getFormat()),ut===""&&(ut=a.getStyle()))}Lr(e)&&(ce+=Je),r.__lexicalTextContent=ce,ce=s+ce}function kc(o,e){let t=e.get(o);return Ce(t)||F(t)&&t.isInline()}function Bc(o,e,t){let n=o!==null&&(o.__size===0||kc(o.__last,Vo)),r=e.__size===0||kc(e.__last,ft);if(n){if(!r){let i=t.__lexicalLineBreak;if(i!=null)try{t.removeChild(i)}catch(s){if(typeof s=="object"&&s!=null){let l=`${s.toString()} Parent: ${t.tagName}, child: ${i.tagName}.`;throw new Error(l)}else throw s}t.__lexicalLineBreak=null}}else if(r){let i=document.createElement("br");t.__lexicalLineBreak=i,t.appendChild(i)}}function Jh(o){Xt(o)&&Mt!=null&&Mt!==o.__textFormat&&!Ii&&(o.setTextFormat(Mt),o.setTextStyle(ut))}function jh(o){Xt(o)&&ut!==""&&ut!==o.__textStyle&&!Ii&&o.setTextStyle(ut)}function Qh(o,e,t){Mt=null,ut="",eN(o,e,t),Jh(e),jh(e)}function Ri(o,e){let t=[],n=o.__first;for(;n!==null;){let r=e.get(n);r===void 0&&E(!1,"createChildrenArray: node does not exist in nodeMap"),t.push(n),n=r.__next}return t}function eN(o,e,t){let n=ce,r=o.__size,i=e.__size;if(ce="",r===1&&i===1){let s=o.__first,l=e.__first;if(s===l)vr(s,t);else{let d=kl(s),f=Pi(l,null,null);try{t.replaceChild(f,d)}catch(m){if(typeof m=="object"&&m!=null){let c=`${m.toString()} Parent: ${t.tagName}, new child: {tag: ${f.tagName} key: ${l}}, old child: {tag: ${d.tagName}, key: ${s}}.`;throw new Error(c)}else throw m}$i(s,null)}let a=ft.get(l);y(a)&&(Mt===null&&(Mt=a.getFormat()),ut===""&&(ut=a.getStyle()))}else{let s=Ri(o,Vo),l=Ri(e,ft);if(r===0)i!==0&&Il(l,e,0,i-1,t,null);else if(i===0){if(r!==0){let d=t.__lexicalLineBreak==null;Rl(s,0,r-1,d?null:t),d&&(t.textContent="")}}else oN(e,s,l,r,i,t)}Lr(e)&&(ce+=Je),t.__lexicalTextContent=ce,ce=n+ce}function vr(o,e){let t=Vo.get(o),n=ft.get(o);(t===void 0||n===void 0)&&E(!1,"reconcileNode: prevNode or nextNode does not exist in nodeMap");let r=$c||Dl.has(o)||Ol.has(o),i=kn(Le,o);if(t===n&&!r){if(x(t)){let s=i.__lexicalTextContent;s!==void 0&&(ce+=s,Vt+=s)}else{let s=t.getTextContent();Vt+=s,ce+=s}return i}if(t!==n&&r&&vi(Or,wr,ki,n,"updated"),n.updateDOM(t,i,Yo)){let s=Pi(o,null,null);return e===null&&E(!1,"reconcileNode: parentDOM is null"),e.replaceChild(s,i),$i(o,null),s}if(x(t)&&x(n)){let s=n.__indent;s!==t.__indent&&Pc(i,s);let l=n.__format;l!==t.__format&&Fc(i,l),r&&(Qh(t,n,i),!G(n)&&!n.isInline()&&Bc(t,n,i)),Lr(n)&&(ce+=Je,Vt+=Je)}else{let s=n.getTextContent();if(F(n)){let l=n.decorate(Le,Yo);l!==null&&Hc(o,l)}ce+=s,Vt+=s}if(!Ii&&G(n)&&n.__cachedText!==Vt){let s=n.getWritable();s.__cachedText=Vt,n=s}return __DEV__&&Object.freeze(n),i}function Hc(o,e){let t=Le._pendingDecorators,n=Le._decorators;if(t===null){if(n[o]===e)return;t=Si(Le)}t[o]=e}function tN(o){return o.firstChild}function wl(o){let e=o.nextSibling;return e!==null&&e===Le._blockCursorElement&&(e=e.nextSibling),e}function oN(o,e,t,n,r,i){let s=n-1,l=r-1,a,d,f=tN(i),m=0,c=0;for(;m<=s&&c<=l;){let g=e[m],h=t[c];if(g===h)f=wl(vr(h,i)),m++,c++;else{a===void 0&&(a=new Set(e)),d===void 0&&(d=new Set(t));let N=d.has(g),L=a.has(h);if(!N)f=wl(kl(g)),$i(g,i),m++;else if(!L)Pi(h,i,f),c++;else{let M=kn(Le,h);M===f?f=wl(vr(h,i)):(f!=null?i.insertBefore(M,f):i.appendChild(M),vr(h,i)),m++,c++}}let C=ft.get(h);C!==null&&y(C)&&(Mt===null&&(Mt=C.getFormat()),ut===""&&(ut=C.getStyle()))}let u=m>s,p=c>l;if(u&&!p){let g=t[l+1],h=g===void 0?null:Le.getElementByKey(g);Il(t,o,c,l,i,h)}else p&&!u&&Rl(e,m,s,i)}function Kc(o,e,t,n,r,i){ce="",Vt="",$c=n===Ut,Le=t,Yo=t._config,wr=t._nodes,ki=Le._listeners.mutation,Ol=r,Dl=i,Vo=o._nodeMap,ft=e._nodeMap,Ii=e._readOnly,Al=new Map(t._keyToDOMMap);let s=new Map;return Or=s,vr("root",null),Le=void 0,wr=void 0,Ol=void 0,Dl=void 0,Vo=void 0,ft=void 0,Yo=void 0,Al=void 0,Or=void 0,s}function nN(o,e,t){let n=t._keyToDOMMap;e["__lexicalKey_"+t._key]=o,n.set(o,e)}function kl(o){let e=Al.get(o);return e===void 0&&E(!1,"Reconciliation: could not find DOM element for node key %s",o),e}var Zt=Object.freeze({}),Hl=30,$l=[["keydown",fN],["pointerdown",iN],["compositionstart",cN],["compositionend",uN],["input",dN],["click",rN],["cut",Zt],["copy",Zt],["dragstart",Zt],["dragover",Zt],["dragend",Zt],["paste",Zt],["focus",Zt],["blur",Zt],["drop",Zt]];fo&&$l.push(["beforeinput",(o,e)=>aN(o,e)]);var Rr=0,Yc=null,Vc=0,$n=null,Fi=new WeakMap,Pl=!1,Fl=!1,Ar=!1,Dr=!1,Xc=[0,"",0,"root",0];function Zc(o,e,t,n,r){let i=o.anchor,s=o.focus,l=i.getNode(),a=V(),d=Se(a._window),f=d!==null?d.anchorNode:null,m=i.key,c=a.getElementByKey(m),u=t.length;return m!==s.key||!y(l)||(!r&&(!fo||Vc<n+50)||l.isDirty()&&u<2||Li(t))&&i.offset!==s.offset&&!l.isComposing()||Ue(l)||l.isDirty()&&u>1||(r||!fo)&&c!==null&&!l.isComposing()&&f!==In(c)||d!==null&&e!==null&&(!e.collapsed||e.startContainer!==d.anchorNode||e.startOffset!==d.anchorOffset)||l.getFormat()!==o.format||l.getStyle()!==o.style||Gd(o,l)}function Uc(o,e){return o!==null&&o.nodeValue!==null&&o.nodeType===He&&e!==0&&e!==o.nodeValue.length}function zc(o,e,t){let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}=o;Pl&&(Pl=!1,Uc(n,r)&&Uc(i,s))||xe(e,()=>{if(!t){Y(null);return}if(!zt(e,n,i))return;let l=T();if(_(l)){let a=l.anchor,d=a.getNode();if(l.isCollapsed()){o.type==="Range"&&o.anchorNode===o.focusNode&&(l.dirty=!0);let f=vn(e).event,m=f?f.timeStamp:performance.now(),[c,u,p,g,h]=Xc,C=B(),N=e.isComposing()===!1&&C.getTextContent()==="";if(m<h+200&&a.offset===p&&a.key===g)l.format=c,l.style=u;else if(a.type==="text")E(y(d),"Point.getNode() must return TextNode when type is text"),l.format=d.getFormat(),l.style=d.getStyle();else if(a.type==="element"&&!N){let L=a.getNode();l.style="",L instanceof We&&L.getChildrenSize()===0?(l.format=L.getTextFormat(),l.style=L.getTextStyle()):l.format=0}}else{let f=a.key,c=l.focus.key,u=l.getNodes(),p=u.length,g=l.isBackward(),h=g?s:r,C=g?r:s,N=g?c:f,L=g?f:c,M=cl,S=!1;for(let D=0;D<p;D++){let O=u[D],A=O.getTextContentSize();if(y(O)&&A!==0&&!(D===0&&O.__key===N&&h===A||D===p-1&&O.__key===L&&C===0)&&(S=!0,M&=O.getFormat(),M===0))break}l.format=S?M:0}}w(e,De,void 0)})}function rN(o,e){xe(e,()=>{let t=T(),n=Se(e._window),r=ze();if(n){if(_(t)){let i=t.anchor,s=i.getNode();if(i.type==="element"&&i.offset===0&&t.isCollapsed()&&!G(s)&&B().getChildrenSize()===1&&s.getTopLevelElementOrThrow().isEmpty()&&r!==null&&t.is(r))n.removeAllRanges(),t.dirty=!0;else if(o.detail===3&&!t.isCollapsed()){let a=t.focus.getNode();s!==a&&(x(s)?s.select(0):s.getParentOrThrow().select(0))}}else if(o.pointerType==="touch"){let i=n.anchorNode;if(i!==null){let s=i.nodeType;if(s===mo||s===He){let l=Ir(r,n,e,o);Y(l)}}}}w(e,dr,o)})}function iN(o,e){let t=o.target,n=o.pointerType;t instanceof Node&&n!=="touch"&&xe(e,()=>{qd(t)||(Fl=!0)})}function Gc(o){if(!o.getTargetRanges)return null;let e=o.getTargetRanges();return e.length===0?null:e[0]}function sN(o,e){return o!==e||x(o)||x(e)||!o.isToken()||!e.isToken()}function lN(o){return Yc==="MediaLast"&&o<Rr+Hl}function aN(o,e){let t=o.inputType,n=Gc(o);t==="deleteCompositionText"||Be&&yi(e)||t!=="insertCompositionText"&&xe(e,()=>{let r=T();if(t==="deleteContentBackward"){if(r===null){let f=ze();if(!_(f))return;Y(f.clone())}if(_(r)){let f=r.anchor.key===r.focus.key;if(lN(o.timeStamp)&&e.isComposing()&&f){if(ie(null),Rr=0,setTimeout(()=>{xe(e,()=>{ie(null)})},Hl),_(r)){let m=r.anchor.getNode();m.markDirty(),r.format=m.getFormat(),E(y(m),"Anchor node must be a TextNode"),r.style=m.getStyle()}}else{ie(null),o.preventDefault();let m=r.anchor.getNode().getTextContent(),c=r.anchor.offset===0&&r.focus.offset===m.length;al&&f&&!c||w(e,Ge,!0)}return}}if(!_(r))return;let i=o.data;$n!==null&&Mi(!1,e,$n),(!r.dirty||$n!==null)&&r.isCollapsed()&&!G(r.anchor.getNode())&&n!==null&&r.applyDOMRange(n),$n=null;let s=r.anchor,l=r.focus,a=s.getNode(),d=l.getNode();if(t==="insertText"||t==="insertTranspose"){if(i===`
`)o.preventDefault(),w(e,$t,!1);else if(i===Je)o.preventDefault(),w(e,Pt,void 0);else if(i==null&&o.dataTransfer){let f=o.dataTransfer.getData("text/plain");o.preventDefault(),r.insertRawText(f)}else i!=null&&Zc(r,n,i,o.timeStamp,!0)?(o.preventDefault(),w(e,lt,i)):$n=i;Vc=o.timeStamp;return}switch(o.preventDefault(),t){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":{w(e,lt,o);break}case"insertFromComposition":{ie(null),w(e,lt,o);break}case"insertLineBreak":{ie(null),w(e,$t,!1);break}case"insertParagraph":{ie(null),Ar&&!St?(Ar=!1,w(e,$t,!1)):w(e,Pt,void 0);break}case"insertFromPaste":case"insertFromPasteAsQuotation":{w(e,ro,o);break}case"deleteByComposition":{sN(a,d)&&w(e,_n,o);break}case"deleteByDrag":case"deleteByCut":{w(e,_n,o);break}case"deleteContent":{w(e,Ge,!1);break}case"deleteWordBackward":{w(e,bt,!0);break}case"deleteWordForward":{w(e,bt,!1);break}case"deleteHardLineBackward":case"deleteSoftLineBackward":{w(e,at,!0);break}case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":{w(e,at,!1);break}case"formatStrikeThrough":{w(e,Ne,"strikethrough");break}case"formatBold":{w(e,Ne,"bold");break}case"formatItalic":{w(e,Ne,"italic");break}case"formatUnderline":{w(e,Ne,"underline");break}case"historyUndo":{w(e,io,void 0);break}case"historyRedo":{w(e,so,void 0);break}default:}})}function dN(o,e){o.stopPropagation(),xe(e,()=>{let t=T(),n=o.data,r=Gc(o);if(n!=null&&_(t)&&Zc(t,r,n,o.timeStamp,!1)){Dr&&(Bl(e,n),Dr=!1);let s=t.anchor.getNode(),l=Se(e._window);if(l===null)return;let a=t.isBackward(),d=a?t.anchor.offset:t.focus.offset,f=a?t.focus.offset:t.anchor.offset;(!fo||t.isCollapsed()||!y(s)||l.anchorNode===null||s.getTextContent().slice(0,d)+n+s.getTextContent().slice(d+f)!==_l(l.anchorNode))&&w(e,lt,n);let m=n.length;Be&&m>1&&o.inputType==="insertCompositionText"&&!e.isComposing()&&(t.anchor.offset-=m),!Ht&&!St&&!Kt&&e.isComposing()&&(Rr=0,ie(null))}else Mi(!1,e,n!==null?n:void 0),Dr&&(Bl(e,n||void 0),Dr=!1);Zd()}),$n=null}function cN(o,e){xe(e,()=>{let t=T();if(_(t)&&!e.isComposing()){let n=t.anchor,r=t.anchor.getNode();ie(n.key),(o.timeStamp<Rr+Hl||n.type==="element"||!t.isCollapsed()||r.getFormat()!==t.format||y(r)&&r.getStyle()!==t.style)&&w(e,lt,wd)}})}function Bl(o,e){let t=o._compositionKey;if(ie(null),t!==null&&e!=null){if(e===""){let n=X(t),r=In(o.getElementByKey(t));r!==null&&r.nodeValue!==null&&y(n)&&Tr(n,r.nodeValue,null,null,!0);return}if(e[e.length-1]===`
`){let n=T();if(_(n)){let r=n.focus;n.anchor.set(r.key,r.offset,r.type),w(o,dt,null);return}}}Mi(!0,o,e)}function uN(o,e){Be?Dr=!0:xe(e,()=>{Bl(e,o.data)})}function fN(o,e){if(Rr=o.timeStamp,Yc=o.key,e.isComposing())return;let{key:t,shiftKey:n,ctrlKey:r,metaKey:i,altKey:s}=o;if(!w(e,Gs,o)&&t!=null){if(xc(t,r,s,i))w(e,Ro,o);else if(Ec(t,r,n,s,i))w(e,Js,o);else if(hc(t,r,s,i))w(e,Io,o);else if(Nc(t,r,n,s,i))w(e,js,o);else if(Tc(t,r,i))w(e,ko,o);else if(Cc(t,r,i))w(e,$o,o);else if(oc(t,n))Ar=!0,w(e,dt,o);else if(yc(t))w(e,Qs,o);else if(nc(t,r))o.preventDefault(),Ar=!0,w(e,$t,!0);else if(tc(t,n))Ar=!1,w(e,dt,o);else if(ac(t,s,i,r))wn(t)?w(e,Ft,o):(o.preventDefault(),w(e,Ge,!0));else if(Sc(t))w(e,Po,o);else if(dc(t,r,n,s,i))On(t)?w(e,Bt,o):(o.preventDefault(),w(e,Ge,!1));else if(rc(t,s,r))o.preventDefault(),w(e,bt,!0);else if(ic(t,s,r))o.preventDefault(),w(e,bt,!1);else if(sc(t,i))o.preventDefault(),w(e,at,!0);else if(lc(t,i))o.preventDefault(),w(e,at,!1);else if(jd(t,s,i,r))o.preventDefault(),w(e,Ne,"bold");else if(ec(t,s,i,r))o.preventDefault(),w(e,Ne,"underline");else if(Qd(t,s,i,r))o.preventDefault(),w(e,Ne,"italic");else if(Jd(t,s,r,i))w(e,Fo,o);else if(cc(t,n,i,r))o.preventDefault(),w(e,io,void 0);else if(uc(t,n,i,r))o.preventDefault(),w(e,so,void 0);else{let l=e._editorState._selection;_e(l)?fc(t,n,i,r)?(o.preventDefault(),w(e,lo,o)):mc(t,n,i,r)?(o.preventDefault(),w(e,ao,o)):yl(t,i,r)&&(o.preventDefault(),w(e,yn,o)):!Be&&yl(t,i,r)&&(o.preventDefault(),w(e,yn,o))}_c(r,n,s,i)&&w(e,sl,o)}}function Jc(o){let e=o.__lexicalEventHandles;return e===void 0&&(e=[],o.__lexicalEventHandles=e),e}var Pn=new Map;function jc(o){let e=o.target,t=e==null?null:e.nodeType===9?e.defaultView:e.ownerDocument.defaultView,n=Se(t);if(n===null)return;let r=bi(n.anchorNode);if(r===null)return;Fl&&(Fl=!1,xe(r,()=>{let f=ze(),m=n.anchorNode;if(m===null)return;let c=m.nodeType;if(c!==mo&&c!==He)return;let u=Ir(f,n,r,o);Y(u)}));let i=br(r),s=i[i.length-1],l=s._key,a=Pn.get(l),d=a||s;d!==r&&zc(n,d,!1),zc(n,r,!0),r!==s?Pn.set(l,r):a&&Pn.delete(l)}function Wc(o){o._lexicalHandled=!0}function qc(o){return o._lexicalHandled===!0}function Qc(o,e){let t=o.ownerDocument,n=Fi.get(t);(n===void 0||n<1)&&t.addEventListener("selectionchange",jc),Fi.set(t,(n||0)+1),o.__lexicalEditor=e;let r=Jc(o);for(let i=0;i<$l.length;i++){let[s,l]=$l[i],a=typeof l=="function"?d=>{qc(d)||(Wc(d),(e.isEditable()||s==="click")&&l(d,e))}:d=>{if(qc(d))return;Wc(d);let f=e.isEditable();switch(s){case"cut":return f&&w(e,ao,d);case"copy":return w(e,lo,d);case"paste":return f&&w(e,ro,d);case"dragstart":return f&&w(e,ur,d);case"dragover":return f&&w(e,fr,d);case"dragend":return f&&w(e,ol,d);case"focus":return f&&w(e,mr,d);case"blur":return f&&w(e,il,d);case"drop":return f&&w(e,Bo,d)}};o.addEventListener(s,a),r.push(()=>{o.removeEventListener(s,a)})}}function eu(o){let e=o.ownerDocument,t=Fi.get(e);E(t!==void 0,"Root element not registered");let n=t-1;E(n>=0,"Root element count less than 0"),Fi.set(e,n),n===0&&e.removeEventListener("selectionchange",jc);let r=Ko(o);Rn(r)?(mN(r),o.__lexicalEditor=null):r&&E(!1,"Attempted to remove event handlers from a node that does not belong to this build of Lexical");let i=Jc(o);for(let s=0;s<i.length;s++)i[s]();o.__lexicalEventHandles=[]}function mN(o){if(o._parentEditor!==null){let e=br(o),n=e[e.length-1]._key;Pn.get(n)===o&&Pn.delete(n)}else Pn.delete(o._key)}function tu(){Pl=!0}function ou(o,e,t,n,r){Xc=[o,e,t,n,r]}function Kl(o,e,t){de();let n=o.__key,r=o.getParent();if(r===null)return;let i=Mc(o),s=!1;if(_(i)&&e){let l=i.anchor,a=i.focus;l.key===n&&(Bn(l,o,r,o.getPreviousSibling(),o.getNextSibling()),s=!0),a.key===n&&(Bn(a,o,r,o.getPreviousSibling(),o.getNextSibling()),s=!0)}else _e(i)&&e&&o.isSelected()&&o.selectPrevious();if(_(i)&&e&&!s){let l=o.getIndexWithinParent();Wt(o),Fn(i,r,l,-1)}else Wt(o);!t&&!pe(r)&&!r.canBeEmpty()&&r.isEmpty()&&Kl(r,e),e&&G(r)&&r.isEmpty()&&r.selectEnd()}var vt=class{static getType(){E(!1,"LexicalNode: Node %s does not implement .getType().",this.name)}static clone(e){E(!1,"LexicalNode: Node %s does not implement .clone().",this.name)}afterCloneFrom(e){this.__parent=e.__parent,this.__next=e.__next,this.__prev=e.__prev}constructor(e){this.__type=this.constructor.getType(),this.__parent=null,this.__prev=null,this.__next=null,Yd(this,e),__DEV__&&this.__type!=="root"&&(de(),pN(this.__type,this.constructor))}getType(){return this.__type}isInline(){E(!1,"LexicalNode: Node %s does not implement .isInline().",this.constructor.name)}isAttached(){let e=this.__key;for(;e!==null;){if(e==="root")return!0;let t=X(e);if(t===null)break;e=t.__parent}return!1}isSelected(e){let t=e||T();if(t==null)return!1;let n=t.getNodes().some(i=>i.__key===this.__key);if(y(this))return n;if(_(t)&&t.anchor.type==="element"&&t.focus.type==="element"){if(t.isCollapsed())return!1;let i=this.getParent();if(F(this)&&this.isInline()&&i){let s=t.isBackward()?t.focus:t.anchor,l=s.getNode();if(s.offset===l.getChildrenSize()&&l.is(i)&&l.getLastChildOrThrow().is(this))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){let e=this.getParent();if(e===null)return-1;let t=e.getFirstChild(),n=0;for(;t!==null;){if(this.is(t))return n;n++,t=t.getNextSibling()}return-1}getParent(){let e=this.getLatest().__parent;return e===null?null:X(e)}getParentOrThrow(){let e=this.getParent();return e===null&&E(!1,"Expected node %s to have a parent.",this.__key),e}getTopLevelElement(){let e=this;for(;e!==null;){let t=e.getParent();if(pe(t))return E(x(e)||e===this&&F(e),"Children of root nodes must be elements or decorators"),e;e=t}return null}getTopLevelElementOrThrow(){let e=this.getTopLevelElement();return e===null&&E(!1,"Expected node %s to have a top parent element.",this.__key),e}getParents(){let e=[],t=this.getParent();for(;t!==null;)e.push(t),t=t.getParent();return e}getParentKeys(){let e=[],t=this.getParent();for(;t!==null;)e.push(t.__key),t=t.getParent();return e}getPreviousSibling(){let t=this.getLatest().__prev;return t===null?null:X(t)}getPreviousSiblings(){let e=[],t=this.getParent();if(t===null)return e;let n=t.getFirstChild();for(;n!==null&&!n.is(this);)e.push(n),n=n.getNextSibling();return e}getNextSibling(){let t=this.getLatest().__next;return t===null?null:X(t)}getNextSiblings(){let e=[],t=this.getNextSibling();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getCommonAncestor(e){let t=this.getParents(),n=e.getParents();x(this)&&t.unshift(this),x(e)&&n.unshift(e);let r=t.length,i=n.length;if(r===0||i===0||t[r-1]!==n[i-1])return null;let s=new Set(n);for(let l=0;l<r;l++){let a=t[l];if(s.has(a))return a}return null}is(e){return e==null?!1:this.__key===e.__key}isBefore(e){if(this===e)return!1;if(e.isParentOf(this))return!0;if(this.isParentOf(e))return!1;let t=this.getCommonAncestor(e),n=0,r=0,i=this;for(;;){let s=i.getParentOrThrow();if(s===t){n=i.getIndexWithinParent();break}i=s}for(i=e;;){let s=i.getParentOrThrow();if(s===t){r=i.getIndexWithinParent();break}i=s}return n<r}isParentOf(e){let t=this.__key;if(t===e.__key)return!1;let n=e;for(;n!==null;){if(n.__key===t)return!0;n=n.getParent()}return!1}getNodesBetween(e){let t=this.isBefore(e),n=[],r=new Set,i=this;for(;i!==null;){let s=i.__key;if(r.has(s)||(r.add(s),n.push(i)),i===e)break;let l=x(i)?t?i.getFirstChild():i.getLastChild():null;if(l!==null){i=l;continue}let a=t?i.getNextSibling():i.getPreviousSibling();if(a!==null){i=a;continue}let d=i.getParentOrThrow();if(r.has(d.__key)||n.push(d),d===e)break;let f=null,m=d;do if(m===null&&E(!1,"getNodesBetween: ancestor is null"),f=t?m.getNextSibling():m.getPreviousSibling(),m=m.getParent(),m!==null)f===null&&!r.has(m.__key)&&n.push(m);else break;while(f===null);i=f}return t||n.reverse(),n}isDirty(){let t=V()._dirtyLeaves;return t!==null&&t.has(this.__key)}getLatest(){let e=X(this.__key);return e===null&&E(!1,"Lexical node does not exist in active editor state. Avoid using the same node references between nested closures from editorState.read/editor.update."),e}getWritable(){de();let e=Qe(),t=V(),n=e._nodeMap,r=this.__key,i=this.getLatest(),s=t._cloneNotNeeded,l=T();if(l!==null&&l.setCachedNodes(null),s.has(r))return Cr(i),i;let a=Yt(i);return s.add(r),Cr(a),n.set(r,a),a}getTextContent(){return""}getTextContentSize(){return this.getTextContent().length}createDOM(e,t){E(!1,"createDOM: base method not extended")}updateDOM(e,t,n){E(!1,"updateDOM: base method not extended")}exportDOM(e){return{element:this.createDOM(e._config,e)}}exportJSON(){E(!1,"exportJSON: base method not extended")}static importJSON(e){E(!1,"LexicalNode: Node %s does not implement .importJSON().",this.name)}static transform(){return null}remove(e){Kl(this,!0,e)}replace(e,t){de();let n=T();n!==null&&(n=n.clone()),Oi(this,e);let r=this.getLatest(),i=this.__key,s=e.__key,l=e.getWritable(),a=this.getParentOrThrow().getWritable(),d=a.__size;Wt(l);let f=r.getPreviousSibling(),m=r.getNextSibling(),c=r.__prev,u=r.__next,p=r.__parent;if(Kl(r,!1,!0),f===null)a.__first=s;else{let g=f.getWritable();g.__next=s}if(l.__prev=c,m===null)a.__last=s;else{let g=m.getWritable();g.__prev=s}if(l.__next=u,l.__parent=p,a.__size=d,t&&(E(x(this)&&x(l),"includeChildren should only be true for ElementNodes"),this.getChildren().forEach(g=>{l.append(g)})),_(n)){Y(n);let g=n.anchor,h=n.focus;g.key===i&&Ul(g,l),h.key===i&&Ul(h,l)}return je()===i&&ie(s),l}insertAfter(e,t=!0){de(),Oi(this,e);let n=this.getWritable(),r=e.getWritable(),i=r.getParent(),s=T(),l=!1,a=!1;if(i!==null){let u=e.getIndexWithinParent();if(Wt(r),_(s)){let p=i.__key,g=s.anchor,h=s.focus;l=g.type==="element"&&g.key===p&&g.offset===u+1,a=h.type==="element"&&h.key===p&&h.offset===u+1}}let d=this.getNextSibling(),f=this.getParentOrThrow().getWritable(),m=r.__key,c=n.__next;if(d===null)f.__last=m;else{let u=d.getWritable();u.__prev=m}if(f.__size++,n.__next=m,r.__next=c,r.__prev=n.__key,r.__parent=n.__parent,t&&_(s)){let u=this.getIndexWithinParent();Fn(s,f,u+1);let p=f.__key;l&&s.anchor.set(p,u+2,"element"),a&&s.focus.set(p,u+2,"element")}return e}insertBefore(e,t=!0){de(),Oi(this,e);let n=this.getWritable(),r=e.getWritable(),i=r.__key;Wt(r);let s=this.getPreviousSibling(),l=this.getParentOrThrow().getWritable(),a=n.__prev,d=this.getIndexWithinParent();if(s===null)l.__first=i;else{let m=s.getWritable();m.__next=i}l.__size++,n.__prev=i,r.__prev=a,r.__next=n.__key,r.__parent=n.__parent;let f=T();if(t&&_(f)){let m=this.getParentOrThrow();Fn(f,m,d)}return e}isParentRequired(){return!1}createParentElementNode(){return P()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(e,t){de();let n=this.getPreviousSibling(),r=this.getParentOrThrow();if(n===null)return r.select(0,0);if(x(n))return n.select();if(!y(n)){let i=n.getIndexWithinParent()+1;return r.select(i,i)}return n.select(e,t)}selectNext(e,t){de();let n=this.getNextSibling(),r=this.getParentOrThrow();if(n===null)return r.select();if(x(n))return n.select(0,0);if(!y(n)){let i=n.getIndexWithinParent();return r.select(i,i)}return n.select(e,t)}markDirty(){this.getWritable()}};function pN(o,e){let t=V()._nodes.get(o);t===void 0&&E(!1,"Create node: Attempted to create node %s that was not configured to be used on the editor.",e.name);let n=t.klass;n!==e&&E(!1,"Create node: Type %s in node %s does not match registered node %s with the same type",o,e.name,n.name)}function nu(o,e,t){let n=t||e.getParentOrThrow().getLastChild(),r=e,i=[e];for(;r!==n;)r.getNextSibling()||E(!1,"insertRangeAfter: lastToInsert must be a later sibling of firstToInsert"),r=r.getNextSibling(),i.push(r);let s=o;for(let l of i)s=s.insertAfter(l)}var Xo=class o extends vt{static getType(){return"linebreak"}static clone(e){return new o(e.__key)}constructor(e){super(e)}getTextContent(){return`
`}createDOM(){return document.createElement("br")}updateDOM(){return!1}static importDOM(){return{br:e=>hN(e)||NN(e)?null:{conversion:gN,priority:0}}}static importJSON(e){return mt()}exportJSON(){return{type:"linebreak",version:1}}};function gN(o){return{node:mt()}}function mt(){return re(new Xo)}function Ce(o){return o instanceof Xo}function hN(o){let e=o.parentElement;if(e!==null&&go(e)){let t=e.firstChild;if(t===o||t.nextSibling===o&&Bi(t)){let n=e.lastChild;if(n===o||n.previousSibling===o&&Bi(n))return!0}}return!1}function NN(o){let e=o.parentElement;if(e!==null&&go(e)){let t=e.firstChild;if(t===o||t.nextSibling===o&&Bi(t))return!1;let n=e.lastChild;if(n===o||n.previousSibling===o&&Bi(n))return!0}return!1}function Bi(o){return o.nodeType===He&&/^( |\t|\r?\n)+$/.test(o.textContent||"")}function zl(o,e){return e&hr?"code":e&Er?"mark":e&Nr?"sub":e&xr?"sup":null}function Wl(o,e){return e&pr?"strong":e&gr?"em":"span"}function lu(o,e,t,n,r){let i=n.classList,s=po(r,"base");s!==void 0&&i.add(...s),s=po(r,"underlineStrikethrough");let l=!1,a=e&Sn&&e&bn,d=t&Sn&&t&bn;s!==void 0&&(d?(l=!0,a||i.add(...s)):a&&i.remove(...s));for(let f in Ae){let c=Ae[f];if(s=po(r,f),s!==void 0)if(t&c){if(l&&(f==="underline"||f==="strikethrough")){e&c&&i.remove(...s);continue}(!(e&c)||a&&f==="underline"||f==="strikethrough")&&i.add(...s)}else e&c&&i.remove(...s)}}function xN(o,e){let t=o.length,n=e.length,r=0,i=0;for(;r<t&&r<n&&o[r]===e[r];)r++;for(;i+r<t&&i+r<n&&o[t-i-1]===e[n-i-1];)i++;return[r,t-r-i,e.slice(r,n-i)]}function au(o,e,t){let n=e.firstChild,r=t.isComposing(),s=o+(r?Mn:"");if(n==null)e.textContent=s;else{let l=n.nodeValue;if(l!==s)if(r||Be){let[a,d,f]=xN(l,s);d!==0&&n.deleteData(a,d),n.insertData(a,f)}else n.nodeValue=s}}function ru(o,e,t,n,r,i){au(r,o,e);let l=i.theme.text;l!==void 0&&lu(t,0,n,o,l)}function Hi(o,e){let t=document.createElement(e);return t.appendChild(o),t}var wt=class o extends vt{static getType(){return"text"}static clone(e){return new o(e.__text,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__format=e.__format,this.__style=e.__style,this.__mode=e.__mode,this.__detail=e.__detail}constructor(e,t){super(t),this.__text=e,this.__format=0,this.__style="",this.__mode=0,this.__detail=0}getFormat(){return this.getLatest().__format}getDetail(){return this.getLatest().__detail}getMode(){let e=this.getLatest();return kd[e.__mode]}getStyle(){return this.getLatest().__style}isToken(){return this.getLatest().__mode===fi}isComposing(){return this.__key===je()}isSegmented(){return this.getLatest().__mode===mi}isDirectionless(){return(this.getLatest().__detail&pi)!==0}isUnmergeable(){return(this.getLatest().__detail&Ln)!==0}hasFormat(e){let t=Ae[e];return(this.getFormat()&t)!==0}isSimpleText(){return this.__type==="text"&&this.__mode===0}getTextContent(){return this.getLatest().__text}getFormatFlags(e,t){let r=this.getLatest().__format;return _r(r,e,t)}canHaveFormat(){return!0}createDOM(e,t){let n=this.__format,r=zl(this,n),i=Wl(this,n),s=r===null?i:r,l=document.createElement(s),a=l;this.hasFormat("code")&&l.setAttribute("spellcheck","false"),r!==null&&(a=document.createElement(i),l.appendChild(a));let d=this.__text;ru(a,this,i,n,d,e);let f=this.__style;return f!==""&&(l.style.cssText=f),l}updateDOM(e,t,n){let r=this.__text,i=e.__format,s=this.__format,l=zl(this,i),a=zl(this,s),d=Wl(this,i),f=Wl(this,s);if((l===null?d:l)!==(a===null?f:a))return!0;if(l===a&&d!==f){let N=t.firstChild;N==null&&E(!1,"updateDOM: prevInnerDOM is null or undefined");let L=document.createElement(f);return ru(L,this,f,s,r,n),t.replaceChild(L,N),!1}let u=t;a!==null&&l!==null&&(u=t.firstChild,u==null&&E(!1,"updateDOM: innerDOM is null or undefined")),au(r,u,this);let g=n.theme.text;g!==void 0&&i!==s&&lu(f,i,s,u,g);let h=e.__style,C=this.__style;return h!==C&&(t.style.cssText=C),!1}static importDOM(){return{"#text":()=>({conversion:yN,priority:0}),b:()=>({conversion:TN,priority:0}),code:()=>({conversion:No,priority:0}),em:()=>({conversion:No,priority:0}),i:()=>({conversion:No,priority:0}),s:()=>({conversion:No,priority:0}),span:()=>({conversion:EN,priority:0}),strong:()=>({conversion:No,priority:0}),sub:()=>({conversion:No,priority:0}),sup:()=>({conversion:No,priority:0}),u:()=>({conversion:No,priority:0})}}static importJSON(e){let t=Z(e.text);return t.setFormat(e.format),t.setDetail(e.detail),t.setMode(e.mode),t.setStyle(e.style),t}exportDOM(e){let{element:t}=super.exportDOM(e);E(t!==null&&Ee(t),"Expected TextNode createDOM to always return a HTMLElement");let n=this.getTextContent();/^\s|\s$/.test(n)&&(t.style.whiteSpace="pre-wrap");for(let r of Array.from(t.classList.values()))r.startsWith("editor-theme-")&&t.classList.remove(r);return t.classList.length===0&&t.removeAttribute("class"),t.nodeName==="SPAN"&&!t.getAttribute("style")&&(t=document.createTextNode(n)),this.hasFormat("bold")&&(t=Hi(t,"b")),this.hasFormat("italic")&&(t=Hi(t,"em")),this.hasFormat("strikethrough")&&(t=Hi(t,"s")),this.hasFormat("underline")&&(t=Hi(t,"u")),{element:t}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),type:"text",version:1}}selectionTransform(e,t){}setFormat(e){let t=this.getWritable();return t.__format=typeof e=="string"?Ae[e]:e,t}setDetail(e){let t=this.getWritable();return t.__detail=typeof e=="string"?Ad[e]:e,t}setStyle(e){let t=this.getWritable();return t.__style=e,t}toggleFormat(e){let t=this.getFormat(),n=_r(t,e,null);return this.setFormat(n)}toggleDirectionless(){let e=this.getWritable();return e.__detail^=pi,e}toggleUnmergeable(){let e=this.getWritable();return e.__detail^=Ln,e}setMode(e){let t=Id[e];if(this.__mode===t)return this;let n=this.getWritable();return n.__mode=t,n}setTextContent(e){if(this.__text===e)return this;let t=this.getWritable();return t.__text=e,t}select(e,t){de();let n=e,r=t,i=T(),s=this.getTextContent(),l=this.__key;if(typeof s=="string"){let a=s.length;n===void 0&&(n=a),r===void 0&&(r=a)}else n=0,r=0;if(_(i)){let a=je();(a===i.anchor.key||a===i.focus.key)&&ie(l),i.setTextNodeRange(this,n,this,r)}else return Ki(l,n,l,r,"text","text");return i}selectStart(){return this.select(0,0)}selectEnd(){let e=this.getTextContentSize();return this.select(e,e)}spliceText(e,t,n,r){let i=this.getWritable(),s=i.__text,l=n.length,a=e;a<0&&(a=l+a,a<0&&(a=0));let d=T();if(r&&_(d)){let m=e+l;d.setTextNodeRange(i,m,i,m)}let f=s.slice(0,a)+n+s.slice(a+t);return i.__text=f,i}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...e){de();let t=this.getLatest(),n=t.getTextContent(),r=t.__key,i=je(),s=new Set(e),l=[],a=n.length,d="";for(let S=0;S<a;S++)d!==""&&s.has(S)&&(l.push(d),d=""),d+=n[S];d!==""&&l.push(d);let f=l.length;if(f===0)return[];if(l[0]===n)return[t];let m=l[0],c=t.getParent(),u,p=t.getFormat(),g=t.getStyle(),h=t.__detail,C=!1;t.isSegmented()?(u=Z(m),u.__format=p,u.__style=g,u.__detail=h,C=!0):(u=t.getWritable(),u.__text=m);let N=T(),L=[u],M=m.length;for(let S=1;S<f;S++){let D=l[S],O=D.length,A=Z(D).getWritable();A.__format=p,A.__style=g,A.__detail=h;let $=A.__key,R=M+O;if(_(N)){let U=N.anchor,ee=N.focus;U.key===r&&U.type==="text"&&U.offset>M&&U.offset<=R&&(U.key=$,U.offset-=M,N.dirty=!0),ee.key===r&&ee.type==="text"&&ee.offset>M&&ee.offset<=R&&(ee.key=$,ee.offset-=M,N.dirty=!0)}i===r&&ie($),M=R,L.push(A)}if(c!==null){Vd(this);let S=c.getWritable(),D=this.getIndexWithinParent();C?(S.splice(D,0,L),this.remove()):S.splice(D,1,L),_(N)&&Fn(N,c,D,f-1)}return L}mergeWithSibling(e){let t=e===this.getPreviousSibling();!t&&e!==this.getNextSibling()&&E(!1,"mergeWithSibling: sibling must be a previous or next sibling");let n=this.__key,r=e.__key,i=this.__text,s=i.length;je()===r&&ie(n);let a=T();if(_(a)){let c=a.anchor,u=a.focus;c!==null&&c.key===r&&(ql(c,t,n,e,s),a.dirty=!0),u!==null&&u.key===r&&(ql(u,t,n,e,s),a.dirty=!0)}let d=e.__text,f=t?d+i:i+d;this.setTextContent(f);let m=this.getWritable();return e.remove(),m}isTextEntity(){return!1}};function EN(o){let t=o.style;return{forChild:Yl(t),node:null}}function TN(o){let e=o,t=e.style.fontWeight==="normal";return{forChild:Yl(e.style,t?void 0:"bold"),node:null}}var iu=new WeakMap;function CN(o){return o.nodeName==="PRE"||o.nodeType===mo&&o.style!==void 0&&o.style.whiteSpace!==void 0&&o.style.whiteSpace.startsWith("pre")}function _N(o){let e,t=o.parentNode,n=[o];for(;t!==null&&(e=iu.get(t))===void 0&&!CN(t);)n.push(t),t=t.parentNode;let r=e===void 0?t:e;for(let i=0;i<n.length;i++)iu.set(n[i],r);return r}function yN(o){let e=o,t=o.parentElement;E(t!==null,"Expected parentElement of Text not to be null");let n=e.textContent||"";if(_N(e)!==null){let r=n.split(/(\r?\n|\t)/),i=[],s=r.length;for(let l=0;l<s;l++){let a=r[l];a===`
`||a===`\r
`?i.push(mt()):a===" "?i.push(Ot()):a!==""&&i.push(Z(a))}return{node:i}}if(n=n.replace(/\r/g,"").replace(/[ \t\n]+/g," "),n==="")return{node:null};if(n[0]===" "){let r=e,i=!0;for(;r!==null&&(r=su(r,!1))!==null;){let s=r.textContent||"";if(s.length>0){/[ \t\n]$/.test(s)&&(n=n.slice(1)),i=!1;break}}i&&(n=n.slice(1))}if(n[n.length-1]===" "){let r=e,i=!0;for(;r!==null&&(r=su(r,!0))!==null;)if((r.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){i=!1;break}i&&(n=n.slice(0,n.length-1))}return n===""?{node:null}:{node:Z(n)}}function su(o,e){let t=o;for(;;){let n;for(;(n=e?t.nextSibling:t.previousSibling)===null;){let i=t.parentElement;if(i===null)return null;t=i}if(t=n,t.nodeType===mo){let i=t.style.display;if(i===""&&!zo(t)||i!==""&&!i.startsWith("inline"))return null}let r=t;for(;(r=e?t.firstChild:t.lastChild)!==null;)t=r;if(t.nodeType===He)return t;if(t.nodeName==="BR")return null}}var bN={code:"code",em:"italic",i:"italic",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function No(o){let e=bN[o.nodeName.toLowerCase()];return e===void 0?{node:null}:{forChild:Yl(o.style,e),node:null}}function Z(o=""){return re(new wt(o))}function y(o){return o instanceof wt}function Yl(o,e){let t=o.fontWeight,n=o.textDecoration.split(" "),r=t==="700"||t==="bold",i=n.includes("line-through"),s=o.fontStyle==="italic",l=n.includes("underline"),a=o.verticalAlign,d=o.color,f=o.backgroundColor;return m=>{if(!y(m))return m;r&&!m.hasFormat("bold")&&m.toggleFormat("bold"),i&&!m.hasFormat("strikethrough")&&m.toggleFormat("strikethrough"),s&&!m.hasFormat("italic")&&m.toggleFormat("italic"),l&&!m.hasFormat("underline")&&m.toggleFormat("underline"),a==="sub"&&!m.hasFormat("subscript")&&m.toggleFormat("subscript"),a==="super"&&!m.hasFormat("superscript")&&m.toggleFormat("superscript");let c=m.getStyle();return d&&(c+=`color: ${d};`),f&&f!=="transparent"&&(c+=`background-color: ${f};`),c&&m.setStyle(c),e&&!m.hasFormat(e)&&m.toggleFormat(e),m}}var Zo=class o extends wt{static getType(){return"tab"}static clone(e){return new o(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__text=e.__text}constructor(e){super(" ",e),this.__detail=Ln}static importDOM(){return null}static importJSON(e){let t=Ot();return t.setFormat(e.format),t.setStyle(e.style),t}exportJSON(){return{...super.exportJSON(),type:"tab",version:1}}setTextContent(e){E(!1,"TabNode does not support setTextContent")}setDetail(e){E(!1,"TabNode does not support setDetail")}setMode(e){E(!1,"TabNode does not support setMode")}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}};function Ot(){return re(new Zo)}function Vl(o){return o instanceof Zo}var Gl=class{constructor(e,t,n){this._selection=null,this.key=e,this.offset=t,this.type=n}is(e){return this.key===e.key&&this.offset===e.offset&&this.type===e.type}isBefore(e){let t=this.getNode(),n=e.getNode(),r=this.offset,i=e.offset;if(x(t)){let s=t.getDescendantByIndex(r);t=s??t}if(x(n)){let s=n.getDescendantByIndex(i);n=s??n}return t===n?r<i:t.isBefore(n)}getNode(){let e=this.key,t=X(e);return t===null&&E(!1,"Point.getNode: node not found"),t}set(e,t,n){let r=this._selection,i=this.key;this.key=e,this.offset=t,this.type=n,ct()||(je()===i&&ie(e),r!==null&&(r.setCachedNodes(null),r.dirty=!0))}};function Re(o,e,t){return new Gl(o,e,t)}function Xl(o,e){let t=e.__key,n=o.offset,r="element";if(y(e)){r="text";let i=e.getTextContentSize();n>i&&(n=i)}else if(!x(e)){let i=e.getNextSibling();if(y(i))t=i.__key,n=0,r="text";else{let s=e.getParent();s&&(t=s.__key,n=e.getIndexWithinParent()+1)}}o.set(t,n,r)}function Ul(o,e){if(x(e)){let t=e.getLastDescendant();x(t)||y(t)?Xl(o,t):Xl(o,e)}else Xl(o,e)}function SN(o,e,t,n){let r=o.getNode(),i=r.getChildAtIndex(o.offset),s=Z(),l=G(r)?P().append(s):s;s.setFormat(t),s.setStyle(n),i===null?r.append(l):i.insertBefore(l),o.is(e)&&e.set(s.__key,0,"text"),o.set(s.__key,0,"text")}function xo(o,e,t,n){o.key=e,o.offset=t,o.type=n}var Ui=class o{constructor(e){this._cachedNodes=null,this._nodes=e,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){if(!_e(e))return!1;let t=this._nodes,n=e._nodes;return t.size===n.size&&Array.from(t).every(r=>n.has(r))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(e){this.dirty=!0,this._nodes.add(e),this._cachedNodes=null}delete(e){this.dirty=!0,this._nodes.delete(e),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(e){return this._nodes.has(e)}clone(){return new o(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(e){}insertText(){}insertNodes(e){let t=this.getNodes(),n=t.length,r=t[n-1],i;if(y(r))i=r.select();else{let s=r.getIndexWithinParent()+1;i=r.getParentOrThrow().select(s,s)}i.insertNodes(e);for(let s=0;s<n;s++)t[s].remove()}getNodes(){let e=this._cachedNodes;if(e!==null)return e;let t=this._nodes,n=[];for(let r of t){let i=X(r);i!==null&&n.push(i)}return ct()||(this._cachedNodes=n),n}getTextContent(){let e=this.getNodes(),t="";for(let n=0;n<e.length;n++)t+=e[n].getTextContent();return t}};function _(o){return o instanceof Eo}var Eo=class o{constructor(e,t,n,r){this.anchor=e,this.focus=t,e._selection=this,t._selection=this,this._cachedNodes=null,this.format=n,this.style=r,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return _(e)?this.anchor.is(e.anchor)&&this.focus.is(e.focus)&&this.format===e.format&&this.style===e.style:!1}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){let e=this._cachedNodes;if(e!==null)return e;let t=this.anchor,n=this.focus,r=t.isBefore(n),i=r?t:n,s=r?n:t,l=i.getNode(),a=s.getNode(),d=i.offset,f=s.offset;if(x(l)){let c=l.getDescendantByIndex(d);l=c??l}if(x(a)){let c=a.getDescendantByIndex(f);c!==null&&c!==l&&a.getChildAtIndex(f)===c&&(c=c.getPreviousSibling()),a=c??a}let m;return l.is(a)?x(l)&&l.getChildrenSize()>0?m=[]:m=[l]:m=l.getNodesBetween(a),ct()||(this._cachedNodes=m),m}setTextNodeRange(e,t,n,r){xo(this.anchor,e.__key,t,"text"),xo(this.focus,n.__key,r,"text"),this._cachedNodes=null,this.dirty=!0}getTextContent(){let e=this.getNodes();if(e.length===0)return"";let t=e[0],n=e[e.length-1],r=this.anchor,i=this.focus,s=r.isBefore(i),[l,a]=kr(this),d="",f=!0;for(let m=0;m<e.length;m++){let c=e[m];if(x(c)&&!c.isInline())f||(d+=`
`),c.isEmpty()?f=!1:f=!0;else if(f=!1,y(c)){let u=c.getTextContent();c===t?c===n?(r.type!=="element"||i.type!=="element"||i.offset===r.offset)&&(u=l<a?u.slice(l,a):u.slice(a,l)):u=s?u.slice(l):u.slice(a):c===n&&(u=s?u.slice(0,a):u.slice(0,l)),d+=u}else(F(c)||Ce(c))&&(c!==n||!this.isCollapsed())&&(d+=c.getTextContent())}return d}applyDOMRange(e){let t=V(),r=t.getEditorState()._selection,i=gu(e.startContainer,e.startOffset,e.endContainer,e.endOffset,t,r);if(i===null)return;let[s,l]=i;xo(this.anchor,s.key,s.offset,s.type),xo(this.focus,l.key,l.offset,l.type),this._cachedNodes=null}clone(){let e=this.anchor,t=this.focus;return new o(Re(e.key,e.offset,e.type),Re(t.key,t.offset,t.type),this.format,this.style)}toggleFormat(e){this.format=_r(this.format,e,null),this.dirty=!0}setStyle(e){this.style=e,this.dirty=!0}hasFormat(e){let t=Ae[e];return(this.format&t)!==0}insertRawText(e){let t=e.split(/(\r?\n|\t)/),n=[],r=t.length;for(let i=0;i<r;i++){let s=t[i];s===`
`||s===`\r
`?n.push(mt()):s===" "?n.push(Ot()):n.push(Z(s))}this.insertNodes(n)}insertText(e){let t=this.anchor,n=this.focus,r=this.format,i=this.style,s=t,l=n;!this.isCollapsed()&&n.isBefore(t)&&(s=n,l=t),s.type==="element"&&SN(s,l,r,i);let a=s.offset,d=l.offset,f=this.getNodes(),m=f.length,c=f[0];y(c)||E(!1,"insertText: first node is not a text node");let p=c.getTextContent().length,g=c.getParentOrThrow(),h=m-1,C=f[h];if(m===1&&l.type==="element"&&(d=p,l.set(s.key,d,"text")),this.isCollapsed()&&a===p&&(c.isSegmented()||c.isToken()||!c.canInsertTextAfter()||!g.canInsertTextAfter()&&c.getNextSibling()===null)){let N=c.getNextSibling();if((!y(N)||!N.canInsertTextBefore()||Ue(N))&&(N=Z(),N.setFormat(r),N.setStyle(i),g.canInsertTextAfter()?c.insertAfter(N):g.insertAfter(N)),N.select(0,0),c=N,e!==""){this.insertText(e);return}}else if(this.isCollapsed()&&a===0&&(c.isSegmented()||c.isToken()||!c.canInsertTextBefore()||!g.canInsertTextBefore()&&c.getPreviousSibling()===null)){let N=c.getPreviousSibling();if((!y(N)||Ue(N))&&(N=Z(),N.setFormat(r),g.canInsertTextBefore()?c.insertBefore(N):g.insertBefore(N)),N.select(),c=N,e!==""){this.insertText(e);return}}else if(c.isSegmented()&&a!==p){let N=Z(c.getTextContent());N.setFormat(r),c.replace(N),c=N}else if(!this.isCollapsed()&&e!==""){let N=C.getParent();if(!g.canInsertTextBefore()||!g.canInsertTextAfter()||x(N)&&(!N.canInsertTextBefore()||!N.canInsertTextAfter())){this.insertText(""),pu(this.anchor,this.focus,null),this.insertText(e);return}}if(m===1){if(c.isToken()){let S=Z(e);S.select(),c.replace(S);return}let N=c.getFormat(),L=c.getStyle();if(a===d&&(N!==r||L!==i))if(c.getTextContent()==="")c.setFormat(r),c.setStyle(i);else{let S=Z(e);if(S.setFormat(r),S.setStyle(i),S.select(),a===0)c.insertBefore(S,!1);else{let[D]=c.splitText(a);D.insertAfter(S,!1)}S.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length);return}else if(Vl(c)){let S=Z(e);S.setFormat(r),S.setStyle(i),S.select(),c.replace(S);return}let M=d-a;c=c.spliceText(a,M,e,!0),c.getTextContent()===""?c.remove():this.anchor.type==="text"&&(c.isComposing()?this.anchor.offset-=e.length:(this.format=N,this.style=L))}else{let N=new Set([...c.getParentKeys(),...C.getParentKeys()]),L=x(c)?c:c.getParentOrThrow(),M=x(C)?C:C.getParentOrThrow(),S=C;if(!L.is(M)&&M.isInline())do S=M,M=M.getParentOrThrow();while(M.isInline());if(l.type==="text"&&(d!==0||C.getTextContent()==="")||l.type==="element"&&C.getIndexWithinParent()<d)if(y(C)&&!C.isToken()&&d!==C.getTextContentSize()){if(C.isSegmented()){let R=Z(C.getTextContent());C.replace(R),C=R}!G(l.getNode())&&l.type==="text"&&(C=C.spliceText(0,d,"")),N.add(C.__key)}else{let R=C.getParentOrThrow();!R.canBeEmpty()&&R.getChildrenSize()===1?R.remove():C.remove()}else N.add(C.__key);let D=M.getChildren(),O=new Set(f),A=L.is(M),$=L.isInline()&&c.getNextSibling()===null?L:c;for(let R=D.length-1;R>=0;R--){let U=D[R];if(U.is(c)||x(U)&&U.isParentOf(c))break;U.isAttached()&&(!O.has(U)||U.is(S)?A||$.insertAfter(U,!1):U.remove())}if(!A){let R=M,U=null;for(;R!==null;){let ee=R.getChildren(),Tn=ee.length;(Tn===0||ee[Tn-1].is(U))&&(N.delete(R.__key),U=R),R=R.getParent()}}if(!c.isToken())c=c.spliceText(a,p-a,e,!0),c.getTextContent()===""?c.remove():c.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length);else if(a===p)c.select();else{let R=Z(e);R.select(),c.replace(R)}for(let R=1;R<m;R++){let U=f[R],ee=U.__key;N.has(ee)||U.remove()}}}removeText(){this.insertText("")}formatText(e){if(this.isCollapsed()){this.toggleFormat(e),ie(null);return}let t=this.getNodes(),n=[];for(let N of t)y(N)&&n.push(N);let r=n.length;if(r===0){this.toggleFormat(e),ie(null);return}let i=this.anchor,s=this.focus,l=this.isBackward(),a=l?s:i,d=l?i:s,f=0,m=n[0],c=a.type==="element"?0:a.offset;if(a.type==="text"&&c===m.getTextContentSize()&&(f=1,m=n[1],c=0),m==null)return;let u=m.getFormatFlags(e,null),p=r-1,g=n[p],h=d.type==="text"?d.offset:g.getTextContentSize();if(m.is(g)){if(c===h)return;if(Ue(m)||c===0&&h===m.getTextContentSize())m.setFormat(u);else{let N=m.splitText(c,h),L=c===0?N[0]:N[1];L.setFormat(u),a.type==="text"&&a.set(L.__key,0,"text"),d.type==="text"&&d.set(L.__key,h-c,"text")}this.format=u;return}c!==0&&!Ue(m)&&([,m]=m.splitText(c),c=0),m.setFormat(u);let C=g.getFormatFlags(e,u);h>0&&(h!==g.getTextContentSize()&&!Ue(g)&&([g]=g.splitText(h)),g.setFormat(C));for(let N=f+1;N<p;N++){let L=n[N],M=L.getFormatFlags(e,C);L.setFormat(M)}a.type==="text"&&a.set(m.__key,c,"text"),d.type==="text"&&d.set(g.__key,h,"text"),this.format=u|C}insertNodes(e){if(e.length===0)return;if(this.anchor.key==="root"){this.insertParagraph();let h=T();return E(_(h),"Expected RangeSelection after insertParagraph"),h.insertNodes(e)}let t=this.isBackward()?this.focus:this.anchor,n=Ai(t.getNode(),Wo),r=e[e.length-1];if("__language"in n&&x(n)){if("__language"in e[0])this.insertText(e[0].getTextContent());else{let h=Zl(this);n.splice(h,0,e),r.selectEnd()}return}let i=h=>(x(h)||F(h))&&!h.isInline();if(!e.some(i)){E(x(n),"Expected 'firstBlock' to be an ElementNode");let h=Zl(this);n.splice(h,0,e),r.selectEnd();return}let s=DN(e),l=s.getLastDescendant(),a=s.getChildren(),d=h=>x(h)&&Wo(h)&&!h.isEmpty()&&x(n)&&(!n.isEmpty()||n.canMergeWhenEmpty()),m=!x(n)||!n.isEmpty()?this.insertParagraph():null,c=a[a.length-1],u=a[0];d(u)&&(E(x(n),"Expected 'firstBlock' to be an ElementNode"),n.append(...u.getChildren()),u=a[1]),u&&nu(n,u);let p=Ai(l,Wo);m&&x(p)&&(m.canMergeWhenEmpty()||Wo(c))&&(p.append(...m.getChildren()),m.remove()),x(n)&&n.isEmpty()&&n.remove(),l.selectEnd();let g=x(n)?n.getLastChild():null;Ce(g)&&p!==n&&g.remove()}insertParagraph(){if(this.anchor.key==="root"){let s=P();return B().splice(this.anchor.offset,0,[s]),s.select(),s}let e=Zl(this),t=Ai(this.anchor.getNode(),Wo);E(x(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=mt();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,d]=kr(this);if(t===0)return[];if(t===1){if(y(s)&&!this.isCollapsed()){let m=a>d?d:a,c=a>d?a:d,u=s.splitText(m,c),p=m===0?u[0]:u[1];return p!=null?[p]:[]}return[s]}let f=r.isBefore(i);if(y(s)){let m=f?a:d;m===s.getTextContentSize()?e.shift():m!==0&&([,s]=s.splitText(m),e[0]=s)}if(y(l)){let c=l.getTextContent().length,u=f?d:a;u===0?e.pop():u!==c&&([l]=l.splitText(u),e[n]=l)}return e}modify(e,t,n){let r=this.focus,i=this.anchor,s=e==="move",l=qt(r,t);if(F(l)&&!l.isIsolated()){if(s&&l.isKeyboardSelectable()){let u=Go();u.add(l.__key),Y(u);return}let c=t?l.getPreviousSibling():l.getNextSibling();if(y(c)){let u=c.__key,p=t?c.getTextContent().length:0;r.set(u,p,"text"),s&&i.set(u,p,"text");return}else{let u=l.getParentOrThrow(),p,g;x(c)?(g=c.__key,p=t?c.getChildrenSize():0):(p=l.getIndexWithinParent(),g=u.__key,t||p++),r.set(g,p,"element"),s&&i.set(g,p,"element");return}}let a=V(),d=Se(a._window);if(!d)return;let f=a._blockCursorElement,m=a._rootElement;if(m!==null&&f!==null&&x(l)&&!l.isInline()&&!l.canBeEmpty()&&Mr(f,a,m),MN(d,e,t?"backward":"forward",n),d.rangeCount>0){let c=d.getRangeAt(0),u=this.anchor.getNode(),p=G(u)?u:Sl(u);if(this.applyDOMRange(c),this.dirty=!0,!s){let g=this.getNodes(),h=[],C=!1;for(let N=0;N<g.length;N++){let L=g[N];Dn(L,p)?h.push(L):C=!0}if(C&&h.length>0)if(t){let N=h[0];x(N)?N.selectStart():N.getParentOrThrow().selectStart()}else{let N=h[h.length-1];x(N)?N.selectEnd():N.getParentOrThrow().selectEnd()}(d.anchorNode!==c.startContainer||d.anchorOffset!==c.startOffset)&&LN(this)}}}forwardDeletion(e,t,n){if(!n&&(e.type==="element"&&x(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(x(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=qt(i,e);if(F(s)&&!s.isIsolated()){if(s.isKeyboardSelectable()&&x(r)&&r.getChildrenSize()===0){r.remove();let l=Go();l.add(s.__key),Y(l)}else s.remove(),V().dispatchCommand(De,void 0);return}else if(!e&&x(s)&&x(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,d=l.getTextContentSize();if(l.is(r)||e&&a!==d||!e&&a!==0){cu(l,e,a);return}}else if(r!==null&&r.isSegmented()){let a=n.offset,d=r.getTextContentSize();if(r.is(l)||e&&a!==0||!e&&a!==d){cu(r,e,a);return}}vN(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type==="element"&&this.anchor.offset===0){let n=this.anchor.getNode();n.isEmpty()&&G(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 _e(o){return o instanceof Ui}function du(o){let e=o.offset;if(o.type==="text")return e;let t=o.getNode();return e===t.getChildrenSize()?t.getTextContent().length:0}function kr(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]:[du(t),du(n)]}function LN(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 vN(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=s<l,d=a?s:l,f=a?l:s,m=f-1;if(d!==m){let c=r.getTextContent().slice(d,f);Li(c)||(e?n.offset=m:t.offset=m)}}}function cu(o,e,t){let n=o,i=n.getTextContent().split(/(?=\s)/g),s=i.length,l=0,a=0;for(let f=0;f<s;f++){let m=i[f],c=f===s-1;if(a=l,l+=m.length,e&&l===t||l>t||c){i.splice(f,1),c&&(a=void 0);break}}let d=i.join("").trim();d===""?n.remove():(n.setTextContent(d),n.select(a,a))}function wN(o,e,t){let n=o.getParent();return t===null||n===null||!n.canBeEmpty()||n!==t.getNode()}function uu(o,e,t,n){let r=e,i;if(o.nodeType===mo){let s=!1,l=o.childNodes,a=l.length,d=n._blockCursorElement;r===a&&(s=!0,r=a-1);let f=l[r],m=!1;if(f===d)f=l[r+1],m=!0;else if(d!==null){let c=d.parentNode;if(o===c){let u=Array.prototype.indexOf.call(c.children,d);e>u&&r--}}if(i=Uo(f),y(i))r=Tl(i,s);else{let c=Uo(o);if(c===null)return null;if(x(c)){r=Math.min(c.getChildrenSize(),r);let u=c.getChildAtIndex(r);if(x(u)&&wN(u,r,t)){let p=s?u.getLastDescendant():u.getFirstDescendant();p===null?c=u:(u=p,c=x(u)?u:u.getParentOrThrow()),r=0}y(u)?(i=u,c=null,r=Tl(u,s)):u!==c&&s&&!m&&r++}else{let u=c.getIndexWithinParent();e===0&&F(c)&&Uo(o)===c?r=u:r=u+1,c=c.getParentOrThrow()}if(x(c))return Re(c.__key,r,"element")}}else i=Uo(o);return y(i)?Re(i.__key,r,"text"):null}function fu(o,e,t){let n=o.offset,r=o.getNode();if(n===0){let i=r.getPreviousSibling(),s=r.getParent();if(!e)x(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&&x(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&&x(i)&&i.isInline())o.key=i.__key,o.offset=0,o.type="element";else if((t||e)&&i===null&&x(s)&&s.isInline()&&!s.canInsertTextAfter()){let l=s.getNextSibling();y(l)&&(o.key=l.__key,o.offset=0)}}}function pu(o,e,t){if(o.type==="text"&&e.type==="text"){let n=o.isBefore(e),r=o.is(e);fu(o,n,r),fu(e,!n,r),r&&(e.key=o.key,e.offset=o.offset,e.type=o.type);let i=V();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 gu(o,e,t,n,r,i){if(o===null||t===null||!zt(r,o,t))return null;let s=uu(o,e,_(i)?i.anchor:null,r);if(s===null)return null;let l=uu(t,n,_(i)?i.focus:null,r);if(l===null)return null;if(s.type==="element"&&l.type==="element"){let a=Uo(o),d=Uo(t);if(F(a)&&F(d))return null}return pu(s,l,i),[s,l]}function Jo(o){return x(o)&&!o.isInline()}function Ki(o,e,t,n,r,i){let s=Qe(),l=new Eo(Re(o,e,r),Re(t,n,i),0,"");return l.dirty=!0,s._selection=l,l}function jo(){let o=Re("root",0,"element"),e=Re("root",0,"element");return new Eo(o,e,0,"")}function Go(){return new Ui(new Set)}function hu(o){let t=o.getEditorState()._selection,n=Se(o._window);return _(t)||t==null?Ir(t,n,o,null):t.clone()}function Jl(o,e){return Ir(null,o,e,null)}function Ir(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=!$d()&&(l||s==="beforeinput"||s==="compositionstart"||s==="compositionend"||s==="click"&&i&&i.detail===3||s==="drop"||s===void 0),d,f,m,c;if(!_(o)||a){if(e===null)return null;if(d=e.anchorNode,f=e.focusNode,m=e.anchorOffset,c=e.focusOffset,l&&_(o)&&!zt(t,d,f))return o.clone()}else return o.clone();let u=gu(d,m,f,c,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 Qe()._selection}function ze(){return V()._editorState._selection}function Fn(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 d=r.offset;if(t<=d&&n>0||t<d&&n<0){let f=Math.max(0,d+n);r.set(a,f,"element"),i.set(a,f,"element"),mu(o)}}else{let d=o.isBackward(),f=d?i:r,m=f.getNode(),c=d?r:i,u=c.getNode();if(e.is(m)){let p=f.offset;(t<=p&&n>0||t<p&&n<0)&&f.set(a,Math.max(0,p+n),"element")}if(e.is(u)){let p=c.offset;(t<=p&&n>0||t<p&&n<0)&&c.set(a,Math.max(0,p+n),"element")}}mu(o)}function mu(o){let e=o.anchor,t=e.offset,n=o.focus,r=n.offset,i=e.getNode(),s=n.getNode();if(o.isCollapsed()){if(!x(i))return;let l=i.getChildrenSize(),a=t>=l,d=a?i.getChildAtIndex(l-1):i.getChildAtIndex(t);if(y(d)){let f=0;a&&(f=d.getTextContentSize()),e.set(d.__key,f,"text"),n.set(d.__key,f,"text")}return}if(x(i)){let l=i.getChildrenSize(),a=t>=l,d=a?i.getChildAtIndex(l-1):i.getChildAtIndex(t);if(y(d)){let f=0;a&&(f=d.getTextContentSize()),e.set(d.__key,f,"text")}}if(x(s)){let l=s.getChildrenSize(),a=r>=l,d=a?s.getChildAtIndex(l-1):s.getChildAtIndex(r);if(y(d)){let f=0;a&&(f=d.getTextContentSize()),n.set(d.__key,f,"text")}}}function Nu(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 Bn(o,e,t,n,r){let i=null,s=0,l=null;n!==null?(i=n.__key,y(n)?(s=n.getTextContentSize(),l="text"):x(n)&&(s=n.getChildrenSize(),l="element")):r!==null&&(i=r.__key,y(r)?l="text":x(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 ql(o,e,t,n,r){o.type==="text"?(o.key=t,e||(o.offset+=r)):o.offset>n.getIndexWithinParent()&&(o.offset-=1)}function xu(o,e,t,n,r,i,s){let l=n.anchorNode,a=n.focusNode,d=n.anchorOffset,f=n.focusOffset,m=document.activeElement;if(r.has("collaboration")&&m!==i||m!==null&&An(m))return;if(!_(e)){o!==null&&zt(t,l,a)&&n.removeAllRanges();return}let c=e.anchor,u=e.focus,p=c.key,g=u.key,h=kn(t,p),C=kn(t,g),N=c.offset,L=u.offset,M=e.format,S=e.style,D=e.isCollapsed(),O=h,A=C,$=!1;if(c.type==="text"){O=In(h);let R=c.getNode();$=R.getFormat()!==M||R.getStyle()!==S}else _(o)&&o.anchor.type==="text"&&($=!0);if(u.type==="text"&&(A=In(C)),!(O===null||A===null)&&(D&&(o===null||$||_(o)&&(o.format!==M||o.style!==S))&&ou(M,S,N,p,performance.now()),!(d===N&&f===L&&l===O&&a===A&&!(n.type==="Range"&&D)&&((m===null||!i.contains(m))&&i.focus({preventScroll:!0}),c.type!=="element")))){try{n.setBaseAndExtent(O,N,A,L)}catch(R){__DEV__&&console.warn(R)}if(!r.has("skip-scroll-into-view")&&e.isCollapsed()&&i!==null&&i===document.activeElement){let R=e instanceof Eo&&e.anchor.type==="element"?O.childNodes[N]||null:n.rangeCount>0?n.getRangeAt(0):null;if(R!==null){let U;if(R instanceof Text){let ee=document.createRange();ee.selectNode(R),U=ee.getBoundingClientRect()}else U=R.getBoundingClientRect();Lc(t,U,i)}}tu()}}function Ie(o){let e=T()||ze();e===null&&(e=B().selectEnd()),e.insertNodes(o)}function Zl(o){let e=o;o.isCollapsed()||e.removeText();let t=T();_(t)&&(e=t),E(_(e),"Unexpected dirty selection to be null");let n=e.anchor,r=n.getNode(),i=n.offset;for(;!Wo(r);)[r,i]=ON(r,i);return i}function ON(o,e){let t=o.getParent();if(!t){let r=P();return B().append(r),r.select(),[B(),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(!x(o)||e===0)return[t,o.getIndexWithinParent()];let n=o.getChildAtIndex(e);if(n){let r=new Eo(Re(o.__key,e,"element"),Re(o.__key,e,"element"),0,""),i=o.insertNewAfter(r);i&&i.append(n,...n.getNextSiblings())}return[t,o.getIndexWithinParent()+1]}function DN(o){let e=P(),t=null;for(let n=0;n<o.length;n++){let r=o[n],i=Ce(r);if(i||F(r)&&r.isInline()||x(r)&&r.isInline()||y(r)||r.isParentRequired()){if(t===null&&(t=r.createParentElementNode(),e.append(t),i))continue;t!==null&&t.append(r)}else e.append(r),t=null}return e}var ue=null,ge=null,ke=!1,jl=!1,zi=0,Eu={characterData:!0,childList:!0,subtree:!0};function ct(){return ke||ue!==null&&ue._readOnly}function de(){ke&&E(!1,"Cannot use method in read-only mode.")}function Ml(){zi>99&&E(!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 Qe(){return ue===null&&E(!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",yu()),ue}function V(){return ge===null&&E(!1,"Unable to find an active editor. This method can only be used synchronously during the callback of editor.update() or editor.read().%s",yu()),ge}function yu(){let o=0,e=new Set,t=ho.version;if(typeof window<"u")for(let r of document.querySelectorAll("[contenteditable]")){let i=Ko(r);if(Rn(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 bu(){return ge}function Dc(){return ue}function Tu(o,e,t){let n=e.__type,r=zd(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;l<s&&(i[l](e),!!e.isAttached());l++);}function Cu(o,e){return o!==void 0&&o.__key!==e&&o.isAttached()}function AN(o,e){let t=e._dirtyLeaves,n=o._nodeMap;for(let r of t){let i=n.get(r);y(i)&&i.isAttached()&&i.isSimpleText()&&!i.isUnmergeable()&&Nl(i)}}function RN(o,e){let t=e._dirtyLeaves,n=e._dirtyElements,r=o._nodeMap,i=je(),s=new Map,l=t,a=l.size,d=n,f=d.size;for(;a>0||f>0;){if(a>0){e._dirtyLeaves=new Set;for(let m of l){let c=r.get(m);y(c)&&c.isAttached()&&c.isSimpleText()&&!c.isUnmergeable()&&Nl(c),c!==void 0&&Cu(c,i)&&Tu(e,c,s),t.add(m)}if(l=e._dirtyLeaves,a=l.size,a>0){zi++;continue}}e._dirtyLeaves=new Set,e._dirtyElements=new Map;for(let m of d){let c=m[0],u=m[1];if(c!=="root"&&!u)continue;let p=r.get(c);p!==void 0&&Cu(p,i)&&Tu(e,p,s),n.set(c,u)}l=e._dirtyLeaves,a=l.size,d=e._dirtyElements,f=d.size,zi++}e._dirtyLeaves=t,e._dirtyElements=n}function Ql(o){return ea(o,V()._nodes)}function ea(o,e){let t=o.type,n=e.get(t);n===void 0&&E(!1,'parseEditorState: type "%s" + not found',t);let r=n.klass;o.type!==r.getType()&&E(!1,"LexicalNode: Node %s does not implement .importJSON().",r.name);let i=r.importJSON(o),s=o.children;if(x(i)&&Array.isArray(s))for(let l=0;l<s.length;l++){let a=s[l],d=ea(a,e);i.append(d)}return i}function Su(o,e,t){let n=$r(),r=ue,i=ke,s=ge,l=e._dirtyElements,a=e._dirtyLeaves,d=e._cloneNotNeeded,f=e._dirtyType;e._dirtyElements=new Map,e._dirtyLeaves=new Set,e._cloneNotNeeded=new Set,e._dirtyType=0,ue=n,ke=!1,ge=e;try{let m=e._nodes,c=o.root;ea(c,m),t&&t(),n._readOnly=!0,__DEV__&&Lu(n)}catch(m){m instanceof Error&&e._onError(m)}finally{e._dirtyElements=l,e._dirtyLeaves=a,e._cloneNotNeeded=d,e._dirtyType=f,ue=r,ke=i,ge=s}return n}function ta(o,e,t){let n=ue,r=ke,i=ge;ue=e,ke=!0,ge=o;try{return t()}finally{ue=n,ke=r,ge=i}}function Lu(o){let e=o._nodeMap;e.set=()=>{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 Dt(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!==Lt,d=ue,f=ke,m=ge,c=o._updating,u=o._observer,p=null;if(o._pendingEditorState=null,o._editorState=t,!r&&a&&u!==null){ge=o,ue=t,ke=!1,o._updating=!0;try{let O=o._dirtyType,A=o._dirtyElements,$=o._dirtyLeaves;u.disconnect(),p=Kc(i,t,o,O,A,$)}catch(O){if(O instanceof Error&&o._onError(O),!jl)oa(o,null,n,t),_i(o),o._dirtyType=Ut,jl=!0,Dt(o,i),jl=!1;else throw O;return}finally{u.observe(n,Eu),o._updating=c,ue=d,ke=f,ge=m}}t._readOnly||(t._readOnly=!0,__DEV__&&(Lu(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=Lt,o._cloneNotNeeded.clear(),o._dirtyLeaves=new Set,o._dirtyElements=new Map,o._normalizedNodes=new Set,o._updateTags=new Set),Ac(o,t);let S=r?null:Se(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&&Mr(O,o,n),xu(s,l,o,S,N,n,M)}wc(o,n,l),u!==null&&u.observe(n,Eu)}finally{ge=m,ue=d}}p!==null&&kN(o,p,N,g,i),!_(l)&&l!==null&&(s===null||!s.is(l))&&o.dispatchCommand(De,void 0);let D=o._pendingDecorators;D!==null&&(o._decorators=D,o._pendingDecorators=null,Hn("decorator",o,!0,D)),IN(o,e||i,t),Hn("update",o,!0,{dirtyElements:h,dirtyLeaves:g,editorState:t,normalizedNodes:C,prevEditorState:e||i,tags:N}),PN(o,L),$N(o)}function IN(o,e,t){let n=El(e),r=El(t);n!==r&&Hn("textcontent",o,!0,r)}function kN(o,e,t,n,r){let i=Array.from(o._listeners.mutation),s=i.length;for(let l=0;l<s;l++){let[a,d]=i[l],f=e.get(d);f!==void 0&&a(f,{dirtyLeaves:n,prevEditorState:r,updateTags:t})}}function Hn(o,e,t,...n){let r=e._updating;e._updating=t;try{let i=Array.from(e._listeners[o]);for(let s=0;s<i.length;s++)i[s].apply(null,n)}finally{e._updating=r}}function vl(o,e,t){if(o._updating===!1||ge!==o){let r=!1;return o.update(()=>{r=vl(o,e,t)}),r}let n=br(o);for(let r=4;r>=0;r--)for(let i=0;i<n.length;i++){let a=n[i]._commands.get(e);if(a!==void 0){let d=a[r];if(d!==void 0){let f=Array.from(d),m=f.length;for(let c=0;c<m;c++)if(f[c](t,o)===!0)return!0}}}return!1}function $N(o){let e=o._updates;if(e.length!==0){let t=e.shift();if(t){let[n,r]=t;Mu(o,n,r)}}}function PN(o,e){if(o._deferred=[],e.length!==0){let t=o._updating;o._updating=!0;try{for(let n=0;n<e.length;n++)e[n]()}finally{o._updating=t}}}function _u(o,e){let t=o._updates,n=e||!1;for(;t.length!==0;){let r=t.shift();if(r){let[i,s]=r,l,a;if(s!==void 0){if(l=s.onUpdate,a=s.tag,s.skipTransforms&&(n=!0),s.discrete){let d=o._pendingEditorState;E(d!==null,"Unexpected empty pending editor state on discrete nested update"),d._flushSync=!0}l&&o._deferred.push(l),a&&o._updateTags.add(a)}i()}}return n}function Mu(o,e,t){let n=o._updateTags,r,i,s=!1,l=!1;t!==void 0&&(r=t.onUpdate,i=t.tag,i!=null&&n.add(i),s=t.skipTransforms||!1,l=t.discrete||!1),r&&o._deferred.push(r);let a=o._editorState,d=o._pendingEditorState,f=!1;(d===null||d._readOnly)&&(d=o._pendingEditorState=wu(d||a),f=!0),d._flushSync=l;let m=ue,c=ke,u=ge,p=o._updating;ue=d,ke=!1,o._updating=!0,ge=o;try{f&&(o._headless?a._selection!==null&&(d._selection=a._selection.clone()):d._selection=hu(o));let h=o._compositionKey;e(),s=_u(o,s),Nu(d,o),o._dirtyType!==Lt&&(s?AN(d,o):RN(d,o),_u(o),Ic(a,d,o._dirtyLeaves,o._dirtyElements));let C=o._compositionKey;h!==C&&(d._flushSync=!0);let N=d._selection;if(_(N)){let L=d._nodeMap,M=N.anchor.key,S=N.focus.key;(L.get(M)===void 0||L.get(S)===void 0)&&E(!1,"updateEditor: selection has been lost because the previously selected nodes have been removed and selection wasn't moved to another node. Ensure selection changes after removing/replacing a selected node.")}else _e(N)&&N._nodes.size===0&&(d._selection=null)}catch(h){h instanceof Error&&o._onError(h),o._pendingEditorState=a,o._dirtyType=Ut,o._cloneNotNeeded.clear(),o._dirtyLeaves=new Set,o._dirtyElements.clear(),Dt(o);return}finally{ue=m,ke=c,ge=u,o._updating=p,zi=0}o._dirtyType!==Lt||vu(d,o)?d._flushSync?(d._flushSync=!1,Dt(o)):f&&Wd(()=>{Dt(o)}):(d._flushSync=!1,f&&(n.clear(),o._deferred=[],o._pendingEditorState=null))}function xe(o,e,t){o._updating?o._updates.push([e,t]):Mu(o,e,t)}var z=class extends vt{constructor(e){super(e),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__first=e.__first,this.__last=e.__last,this.__size=e.__size,this.__indent=e.__indent,this.__format=e.__format,this.__style=e.__style,this.__dir=e.__dir}getFormat(){return this.getLatest().__format}getFormatType(){let e=this.getFormat();return Rd[e]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}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=V()._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),x(t)){let n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;x(e);){let t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;x(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 x(i)&&i.getLastDescendant()||i||null}let r=t[e];return x(r)&&r.getFirstDescendant()||r||null}getFirstChild(){let t=this.getLatest().__first;return t===null?null:X(t)}getFirstChildOrThrow(){let e=this.getFirstChild();return e===null&&E(!1,"Expected node %s to have a first child.",this.__key),e}getLastChild(){let t=this.getLatest().__last;return t===null?null:X(t)}getLastChildOrThrow(){let e=this.getLastChild();return e===null&&E(!1,"Expected node %s to have a last child.",this.__key),e}getChildAtIndex(e){let t=this.getChildrenSize(),n,r;if(e<t/2){for(n=this.getFirstChild(),r=0;n!==null&&r<=e;){if(r===e)return n;n=n.getNextSibling(),r++}return null}for(n=this.getLastChild(),r=t-1;n!==null&&r>=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;r<n;r++){let i=t[r];e+=i.getTextContent(),x(i)&&r!==n-1&&!i.isInline()&&(e+=Je)}return e}getTextContentSize(){let e=0,t=this.getChildren(),n=t.length;for(let r=0;r<n;r++){let i=t[r];e+=i.getTextContentSize(),x(i)&&r!==n-1&&!i.isInline()&&(e+=Je.length)}return e}getDirection(){return this.getLatest().__dir}hasFormat(e){if(e!==""){let t=ul[e];return(this.getFormat()&t)!==0}return!1}select(e,t){de();let n=T(),r=e,i=t,s=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){let a=this.getFirstChild();if(y(a)||x(a))return a.select(0,0)}else if((e===void 0||e===s)&&(t===void 0||t===s)){let a=this.getLastChild();if(y(a)||x(a))return a.select()}}r===void 0&&(r=s),i===void 0&&(i=s);let l=this.__key;if(_(n))n.anchor.set(l,r,"element"),n.focus.set(l,i,"element"),n.dirty=!0;else return Ki(l,r,l,i,"element","element");return n}selectStart(){let e=this.getFirstDescendant();return e?e.selectStart():this.select()}selectEnd(){let e=this.getLastDescendant();return e?e.selectEnd():this.select()}clear(){let e=this.getWritable();return this.getChildren().forEach(n=>n.remove()),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){let t=this.getWritable();return t.__dir=e,t}setFormat(e){let t=this.getWritable();return t.__format=e!==""?ul[e]:0,this}setStyle(e){let t=this.getWritable();return t.__style=e||"",this}setIndent(e){let t=this.getWritable();return t.__indent=e,this}splice(e,t,n){let r=n.length,i=this.getChildrenSize(),s=this.getWritable(),l=s.__key,a=[],d=[],f=this.getChildAtIndex(e+t),m=null,c=i-t+r;if(e!==0)if(e===i)m=this.getLastChild();else{let p=this.getChildAtIndex(e);p!==null&&(m=p.getPreviousSibling())}if(t>0){let p=m===null?this.getFirstChild():m.getNextSibling();for(let g=0;g<t;g++){p===null&&E(!1,"splice: sibling not found");let h=p.getNextSibling(),C=p.__key,N=p.getWritable();Wt(N),d.push(C),p=h}}let u=m;for(let p=0;p<r;p++){let g=n[p];u!==null&&g.is(u)&&(m=u=u.getPreviousSibling());let h=g.getWritable();h.__parent===l&&c--,Wt(h);let C=g.__key;if(u===null)s.__first=C,h.__prev=null;else{let N=u.getWritable();N.__next=C,h.__prev=N.__key}g.__key===l&&E(!1,"append: attempting to append self"),h.__parent=l,a.push(C),u=g}if(e+t===i){if(u!==null){let p=u.getWritable();p.__next=null,s.__last=u.__key}}else if(f!==null){let p=f.getWritable();if(u!==null){let g=u.getWritable();p.__prev=u.__key,g.__next=f.__key}else p.__prev=null}if(s.__size=c,d.length){let p=T();if(_(p)){let g=new Set(d),h=new Set(a),{anchor:C,focus:N}=p;Ou(C,g,h)&&Bn(C,C.getNode(),this,m,f),Ou(N,g,h)&&Bn(N,N.getNode(),this,m,f),c===0&&!this.canBeEmpty()&&!pe(this)&&this.remove()}}return s}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"element",version:1}}insertNewAfter(e,t){return null}canIndent(){return!0}collapseAtStart(e){return!1}excludeFromCopy(e){return!1}canReplaceWith(e){return!0}canInsertAfter(e){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(e){return!1}extractWithChild(e,t,n){return!1}canMergeWhenEmpty(){return!1}};function x(o){return o instanceof z}function Ou(o,e,t){let n=o.getNode();for(;n;){let r=n.__key;if(e.has(r)&&!t.has(r))return!0;n=n.getParent()}return!1}var At=class extends vt{constructor(e){super(e)}decorate(e,t){E(!1,"decorate: base method not extended")}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}};function F(o){return o instanceof At}var Qo=class o extends z{static getType(){return"root"}static clone(){return new o}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){E(!1,"getTopLevelElementOrThrow: root nodes are not top level elements")}getTextContent(){let e=this.__cachedText;return(ct()||V()._dirtyType===Lt)&&e!==null?e:super.getTextContent()}remove(){E(!1,"remove: cannot be called on root nodes")}replace(e){E(!1,"replace: cannot be called on root nodes")}insertBefore(e){E(!1,"insertBefore: cannot be called on root nodes")}insertAfter(e){E(!1,"insertAfter: cannot be called on root nodes")}updateDOM(e,t){return!1}append(...e){for(let t=0;t<e.length;t++){let n=e[t];!x(n)&&!F(n)&&E(!1,"rootNode.append: Only element or decorator nodes can be appended to the root node")}return super.append(...e)}static importJSON(e){let t=B();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"root",version:1}}collapseAtStart(){return!0}};function Du(){return new Qo}function G(o){return o instanceof Qo}function vu(o,e){let t=e.getEditorState()._selection,n=o._selection;if(n!==null){if(n.dirty||!n.is(t))return!0}else if(t!==null)return!0;return!1}function wu(o){return new Wi(new Map(o._nodeMap))}function $r(){return new Wi(new Map([["root",Du()]]))}function Au(o){let e=o.exportJSON(),t=o.constructor;if(e.type!==t.getType()&&E(!1,"LexicalNode: Node %s does not match the serialized type. Check if .exportJSON() is implemented and it is returning the correct type.",t.name),x(o)){let n=e.children;Array.isArray(n)||E(!1,"LexicalNode: Node %s is an element but .exportJSON() does not have a children array.",t.name);let r=o.getChildren();for(let i=0;i<r.length;i++){let s=r[i],l=Au(s);n.push(l)}}return e}var Wi=class o{constructor(e,t){this._nodeMap=e,this._selection=t||null,this._flushSync=!1,this._readOnly=!1}isEmpty(){return this._nodeMap.size===1&&this._selection===null}read(e,t){return ta(t&&t.editor||null,this,e)}clone(e){let t=new o(this._nodeMap,e===void 0?this._selection:e);return t._readOnly=!0,t}toJSON(){return ta(null,this,()=>({root:Au(B())}))}};var To=class extends z{static getType(){return"artificial"}createDOM(e){return document.createElement("div")}};var We=class o extends z{constructor(e){super(e),this.__textFormat=0,this.__textStyle=""}static getType(){return"paragraph"}getTextFormat(){return this.getLatest().__textFormat}setTextFormat(e){let t=this.getWritable();return t.__textFormat=e,t}hasTextFormat(e){let t=Ae[e];return(this.getTextFormat()&t)!==0}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.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}createDOM(e){let t=document.createElement("p"),n=po(e.theme,"paragraph");return n!==void 0&&t.classList.add(...n),t}updateDOM(e,t,n){return!1}static importDOM(){return{p:e=>({conversion:FN,priority:0})}}exportDOM(e){let{element:t}=super.exportDOM(e);if(t&&Ee(t)){this.isEmpty()&&t.append(document.createElement("br"));let n=this.getFormatType();t.style.textAlign=n;let r=this.getIndent();r>0&&(t.style.textIndent=`${r*20}px`)}return{element:t}}static importJSON(e){let t=P();return t.setFormat(e.format),t.setIndent(e.indent),t.setTextFormat(e.textFormat),t}exportJSON(){return{...super.exportJSON(),textFormat:this.getTextFormat(),textStyle:this.getTextStyle(),type:"paragraph",version:1}}insertNewAfter(e,t){let n=P();n.setTextFormat(e.format),n.setTextStyle(e.style);let r=this.getDirection();return n.setDirection(r),n.setFormat(this.getFormatType()),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 FN(o){let e=P();if(o.style){e.setFormat(o.style.textAlign);let t=parseInt(o.style.textIndent,10)/20;t>0&&e.setIndent(t)}return{node:e}}function P(){return re(new We)}function Xt(o){return o instanceof We}var BN=!0,q=0,Gt=1;var qe=3,Me=4;function oa(o,e,t,n){let r=o._keyToDOMMap;r.clear(),o._editorState=$r(),o._pendingEditorState=n,o._compositionKey=null,o._dirtyType=Lt,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 HN(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 na(o){let e=o||{},t=bu(),n=e.theme||{},r=o===void 0?t:e.parentEditor||null,i=e.disableEvents||!1,s=$r(),l=e.namespace||(r!==null?r._config.namespace:Cl()),a=e.editorState,d=[Qo,wt,Xo,Zo,We,To,...e.nodes||[]],{onError:f,html:m}=e,c=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<d.length;g++){let h=d[g],C=null,N=null;if(typeof h!="function"){let D=h;h=D.replace,C=D.with,N=D.withKlass||null}if(__DEV__){let D=Object.prototype.hasOwnProperty.call(h,"getType")&&h.getType(),O=h.name;if(N&&E(N.prototype instanceof h,"%s doesn't extend the %s",N.name,O),O!=="RootNode"&&D!=="root"&&D!=="artificial"){let A=h.prototype;["getType","clone"].forEach($=>{h.hasOwnProperty($)||console.warn(`${O} must implement static "${$}" 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`),A instanceof At&&(A.hasOwnProperty("decorate")||console.warn(`${A.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`),A.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:m&&m.export?m.export.get(h):void 0,klass:h,replace:C,replaceWithKlass:N,transforms:S})}}let p=new ho(s,r,u,{disableEvents:i,namespace:l,theme:n},f||console.error,HN(u,m?m.import:void 0),c);return a!==void 0&&(p._pendingEditorState=a,p._dirtyType=Ut),p}var ho=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=Lt,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=Cl(),this._onError=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&&E(!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&&E(!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?BN:s)||this.initializeMutationListener(t,r),()=>{i.delete(t)}}getRegisteredNode(e){let t=this._nodes.get(e.getType());return t===void 0&&E(!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=Oc(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 Xd(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 w(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=po(this._config.theme,"root"),r=this._pendingEditorState||this._editorState;if(this._rootElement=e,oa(this,t,e,r),t!==null&&(this._config.disableEvents||eu(t),n!=null&&t.classList.remove(...n)),e!==null){let i=vc(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=Ut,_i(this),this._updateTags.add("history-merge"),Dt(this),this._config.disableEvents||Qc(e,this),n!=null&&e.classList.add(...n)}else this._editorState=r,this._pendingEditorState=null,this._window=null;Hn("root",this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&E(!1,"setEditorState: the editor state is empty. Ensure the editor state's root node never becomes empty."),Ci(this);let n=this._pendingEditorState,r=this._updateTags,i=t!==void 0?t.tag:null;n!==null&&!n.isEmpty()&&(i!=null&&r.add(i),Dt(this)),this._pendingEditorState=e,this._dirtyType=Ut,this._dirtyElements.set("root",!1),this._compositionKey=null,i!=null&&r.add(i),Dt(this)}parseEditorState(e,t){let n=typeof e=="string"?JSON.parse(e):e;return Su(n,this,t)}read(e){return Dt(this),this.getEditorState().read(e,{editor:this})}update(e,t){xe(this,e,t)}focus(e,t={}){let n=this._rootElement;n!==null&&(n.setAttribute("autocapitalize","off"),xe(this,()=>{let r=T(),i=B();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(){Dt(this)}blur(){let e=this._rootElement;e!==null&&e.blur();let t=Se(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,Hn("editable",this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}};ho.version="0.17.1";function Jt(...o){return()=>{for(let e=o.length-1;e>=0;e--)o[e]();o.length=0}}var Kn=new Map;function ra(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 Un(o){let e=Kn.get(o);return e===void 0&&(e=ra(o),Kn.set(o,e)),__DEV__&&Object.freeze(e),e}function Iu(o){let e="";for(let t in o)t&&(e+=`${t}: ${o[t]};`);return e}function Pr(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),d=e.is(l);if(a||d){let[f,m]=kr(o),c=s.is(l),u=e.is(i?l:s),p=e.is(i?s:l),g=0,h;if(c)g=f>m?m:f,h=f>m?f:m;else if(u)g=i?m:f,h=void 0;else if(p){let C=i?f:m;g=0,h=C}return e.__text=e.__text.slice(g,h),e}}return e}function ia(o){let e=o.getStyle(),t=ra(e);Kn.set(e,t)}function zn(o,e){let t=Un("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=Iu(n);o.setStyle(r),Kn.set(r,n)}function sa(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],d=t[l];if(o.isCollapsed()&&_(o)){zn(o,e);return}let m=a.getTextContent().length,c=s.offset,u=i.offset,p=i.isBefore(s),g=p?u:c,h=p?c:u,C=p?i.type:s.type,N=p?s.type:i.type,L=p?s.key:i.key;if(y(a)&&g===m){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>c?c:u,h=N==="element"?m:u>c?u:c,g===h)return;if(Ue(a)||g===0&&h===m)zn(a,e),a.select(g,h);else{let M=a.splitText(g,h),S=g===0?M[0]:M[1];zn(S,e),S.select(0,h-g)}}}else{if(y(a)&&g<a.getTextContentSize()&&a.canHaveFormat()&&(g!==0&&!Ue(a)&&(a=a.splitText(g)[1],g=0,p?i.set(a.getKey(),g,"text"):s.set(a.getKey(),g,"text")),zn(a,e)),y(d)&&d.canHaveFormat()){let S=d.getTextContent().length;d.__key!==L&&h!==0&&(h=S),h!==S&&!Ue(d)&&([d]=d.splitText(h)),(h!==0||N==="element")&&zn(d,e)}for(let M=1;M<l;M++){let S=t[M],D=S.getKey();y(S)&&S.canHaveFormat()&&D!==a.getKey()&&D!==d.getKey()&&!S.isToken()&&zn(S,e)}}}function qi(o,e){if(o===null)return;let t=o.getStartEndPoints(),n=t?t[0]:null;if(n!==null&&n.key==="root"){let s=e(),l=B(),a=l.getFirstChild();a?a.replace(s,!0):l.append(s);return}let r=o.getNodes(),i=n!==null?UN(n.getNode(),ku):!1;i&&r.indexOf(i)===-1&&r.push(i);for(let s=0;s<r.length;s++){let l=r[s];if(!ku(l))continue;E(x(l),"Expected block node to be an ElementNode");let a=e();a.setFormat(l.getFormatType()),a.setIndent(l.getIndent()),l.replace(a,!0)}}function Yi(o,e){let t=qt(o.focus,e);return F(t)&&!t.isIsolated()||x(t)&&!t.isInline()&&!t.canBeEmpty()}function $u(o,e,t,n){o.modify(e?"extend":"move",t,n)}function Pu(o){let e=o.anchor.getNode();return(G(e)?e:e.getParentOrThrow()).getDirection()==="rtl"}function Vi(o,e,t){let n=Pu(o);$u(o,e,t?!n:n,"character")}function KN(o,e,t){let n=o.getStyle(),r=Un(n);return r!==null&&r[e]||t}function la(o,e,t=""){let n=null,r=o.getNodes(),i=o.anchor,s=o.focus,l=o.isBackward(),a=l?s.offset:i.offset,d=l?s.getNode():i.getNode();if(_(o)&&o.isCollapsed()&&o.style!==""){let f=o.style,m=Un(f);if(m!==null&&e in m)return m[e]}for(let f=0;f<r.length;f++){let m=r[f];if(!(f!==0&&a===0&&m.is(d))&&y(m)){let c=KN(m,e,t);if(n===null)n=c;else if(n!==c){n="";break}}}return n===null?t:n}function ku(o){if(F(o)||!x(o)||pe(o))return!1;let e=o.getFirstChild(),t=e===null||Ce(e)||y(e)||e.isInline();return!o.isInline()&&o.canBeEmpty()!==!1&&t}function UN(o,e){let t=o;for(;t!==null&&t.getParent()!==null&&!e(t);)t=t.getParentOrThrow();return e(t)?t:null}function Te(o,...e){let t=Ke(...e);t.length>0&&o.classList.add(...t)}function Wn(o,...e){let t=Ke(...e);t.length>0&&o.classList.remove(...t)}function Fu(o,e){let t=o;for(;t!=null;){if(t instanceof e)return t;t=t.getParent()}return null}function Xi(o){let e=K(o,t=>x(t)&&!t.isInline());return x(e)||E(!1,"Expected node %s to have closest block element node.",o.__key),e}var K=(o,e)=>{let t=o;for(;t!==B()&&t!=null;){if(e(t))return t;t=t.getParent()}return null};function pt(o,e){return o!==null?Object.getPrototypeOf(o).constructor.name===e.name:!1}var Zi=0,aa=1,da=2,gt=0,YN=1,Bu=2,VN=3,XN=4;function ZN(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&&!G(l)&&r.push(l)}return r}function GN(o,e,t,n,r){if(o===null||t.size===0&&n.size===0&&!r)return gt;let i=e._selection,s=o._selection;if(r)return YN;if(!_(i)||!_(s)||!s.isCollapsed()||!i.isCollapsed())return gt;let l=ZN(e,t,n);if(l.length===0)return gt;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?Bu:gt}let a=l[0],d=o._nodeMap.get(a.__key);if(!y(d)||!y(a)||d.__mode!==a.__mode)return gt;let f=d.__text,m=a.__text;if(f===m)return gt;let c=i.anchor,u=s.anchor;if(c.key!==u.key||c.type!=="text")return gt;let p=c.offset,g=u.offset,h=m.length-f.length;return h===1&&g===p-1?Bu:h===-1&&g===p+1?VN:h===-1&&g===p?XN:gt}function JN(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 jN(o,e){let t=Date.now(),n=gt;return(r,i,s,l,a,d)=>{let f=Date.now();if(d.has("historic"))return n=gt,t=f,da;let m=GN(r,i,l,a,o.isComposing()),c=(()=>{let u=s===null||s.editor===o,p=d.has("history-push");if(!p&&u&&d.has("history-merge"))return Zi;if(r===null)return aa;let h=i._selection;if(!(l.size>0||a.size>0))return h!==null?Zi:da;if(p===!1&&m!==gt&&m===n&&f<t+e&&u)return Zi;if(l.size===1){let N=Array.from(l)[0];if(JN(N,r,i))return Zi}return aa})();return t=f,n=m,c}}function QN(o,e){let t=e.redoStack,n=e.undoStack;if(t.length!==0){let r=e.current;r!==null&&(n.push(r),o.dispatchCommand(uo,!0));let i=t.pop();t.length===0&&o.dispatchCommand(co,!1),e.current=i||null,i&&i.editor.setEditorState(i.editorState,{tag:"historic"})}}function ex(o,e){let t=e.redoStack,n=e.undoStack;if(n.length!==0){let i=e.current,s=n.pop();i!==null&&(t.push(i),o.dispatchCommand(co,!0)),n.length===0&&o.dispatchCommand(uo,!1),e.current=s||null,s&&s.editor.setEditorState(s.editorState,{tag:"historic"})}}function Hu(o){o.undoStack=[],o.redoStack=[],o.current=null}function Ku(o,e,t){let n=jN(o,t),r=({editorState:s,prevEditorState:l,dirtyLeaves:a,dirtyElements:d,tags:f})=>{let m=e.current,c=e.redoStack,u=e.undoStack,p=m===null?null:m.editorState;if(m!==null&&s===p)return;let g=n(l,s,m,a,d,f);if(g===aa)c.length!==0&&(e.redoStack=[],o.dispatchCommand(co,!1)),m!==null&&(u.push({...m}),o.dispatchCommand(uo,!0));else if(g===da)return;e.current={editor:o,editorState:s}};return Jt(o.registerCommand(io,()=>(ex(o,e),!0),q),o.registerCommand(so,()=>(QN(o,e),!0),q),o.registerCommand(nl,()=>(Hu(e),!1),q),o.registerCommand(rl,()=>(Hu(e),o.dispatchCommand(co,!1),o.dispatchCommand(uo,!1),!0),q),o.registerUpdateListener(r))}function Uu(){return{current:null,redoStack:[],undoStack:[]}}function Gi(o,e){let t=e.body?e.body.childNodes:[],n=[],r=[];for(let i=0;i<t.length;i++){let s=t[i];if(!qu.has(s.nodeName)){let l=Yu(s,o,r,!1);l!==null&&(n=n.concat(l))}}return ox(r),n}function Ji(o,e){if(typeof document>"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=B().getChildren();for(let i=0;i<r.length;i++){let s=r[i];Wu(o,s,t,e)}return t.innerHTML}function Wu(o,e,t,n=null){let r=n!==null?e.isSelected(n):!0,i=x(e)&&e.excludeFromCopy("html"),s=e;if(n!==null){let u=Yt(e);u=y(u)&&n!==null?Pr(n,u):u,s=u}let l=x(s)?s.getChildren():[],a=o._nodes.get(s.getType()),d;a&&a.exportDOM!==void 0?d=a.exportDOM(o,s):d=s.exportDOM(o);let{element:f,after:m}=d;if(!f)return!1;let c=document.createDocumentFragment();for(let u=0;u<l.length;u++){let p=l[u],g=Wu(o,p,c,n);!r&&x(e)&&g&&e.extractWithChild(p,n,"html")&&(r=!0)}if(r&&!i){if(Ee(f)&&f.append(c),t.append(f),m){let u=m.call(s,f);u&&f.replaceWith(u)}}else t.append(c);return r}function tx(o,e){let{nodeName:t}=o,n=e._htmlConversions.get(t.toLowerCase()),r=null;if(n!==void 0)for(let i of n){let s=i(o);s!==null&&(r===null||(r.priority||0)<(s.priority||0))&&(r=s)}return r!==null?r.conversion:null}var qu=new Set(["STYLE","SCRIPT"]);function Yu(o,e,t,n,r=new Map,i){let s=[];if(qu.has(o.nodeName))return s;let l=null,a=tx(o,e),d=a?a(o):null,f=null;if(d!==null){f=d.after;let p=d.node;if(l=Array.isArray(p)?p[p.length-1]:p,l!==null){for(let[,g]of r)if(l=g(l,i),!l)break;l&&s.push(...Array.isArray(p)?p:[l])}d.forChild!=null&&r.set(o.nodeName,d.forChild)}let m=o.childNodes,c=[],u=l!=null&&pe(l)?!1:l!=null&&Jo(l)||n;for(let p=0;p<m.length;p++)c.push(...Yu(m[p],e,t,u,new Map(r),l));return f!=null&&(c=f(c)),go(o)&&(u?c=zu(o,c,()=>{let p=new To;return t.push(p),p}):c=zu(o,c,P)),l==null?c.length>0?s=s.concat(c):go(o)&&nx(o)&&(s=s.concat(mt())):x(l)&&l.append(...c),s}function zu(o,e,t){let n=o.style.textAlign,r=[],i=[];for(let s=0;s<e.length;s++){let l=e[s];if(Jo(l))n&&!l.getFormat()&&l.setFormat(n),r.push(l);else if(i.push(l),s===e.length-1||s<e.length-1&&Jo(e[s+1])){let a=t();a.setFormat(n),a.append(...i),r.push(a),i=[]}}return r}function ox(o){for(let e of o)e.getNextSibling()instanceof To&&e.insertAfter(mt());for(let e of o){let t=e.getChildren();for(let n of t)e.insertBefore(n);e.remove()}}function nx(o){return o.nextSibling==null||o.previousSibling==null?!1:zo(o.nextSibling)&&zo(o.previousSibling)}var Xu=o=>me?(o||window).getSelection():null;function Zu(o,e=T()){return e==null&&E(!1,"Expected valid LexicalSelection"),_(e)&&e.isCollapsed()||e.getNodes().length===0?"":Ji(o,e)}function Gu(o,e=T()){return e==null&&E(!1,"Expected valid LexicalSelection"),_(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(ju(o,e))}function ji(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=Qu(s.nodes);return ca(t,l,e)}}catch{}let r=o.getData("text/html");if(r)try{let l=new DOMParser().parseFromString(r,"text/html"),a=Gi(t,l);return ca(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;l<s.length;l++){let a=T();if(_(a)){let d=s[l];d===`
`||d===`\r
`?a.insertParagraph():d===" "?a.insertNodes([Ot()]):a.insertText(d)}}}else e.insertRawText(i)}function ca(o,e,t){o.dispatchCommand(ar,{nodes:e,selection:t})||t.insertNodes(e)}function rx(o){let e=o.exportJSON(),t=o.constructor;if(e.type!==t.getType()&&E(!1,"LexicalNode: Node %s does not implement .exportJSON().",t.name),x(o)){let n=e.children;Array.isArray(n)||E(!1,"LexicalNode: Node %s is an element but .exportJSON() does not have a children array.",t.name)}return e}function Ju(o,e,t,n=[]){let r=e!==null?t.isSelected(e):!0,i=x(t)&&t.excludeFromCopy("html"),s=t;if(e!==null){let d=Yt(t);d=y(d)&&e!==null?Pr(e,d):d,s=d}let l=x(s)?s.getChildren():[],a=rx(s);if(y(s)){let d=s.__text;d.length>0?a.text=d:r=!1}for(let d=0;d<l.length;d++){let f=l[d],m=Ju(o,e,f,a.children);!r&&x(t)&&m&&t.extractWithChild(f,e,"clone")&&(r=!0)}if(r&&!i)n.push(a);else if(Array.isArray(a.children))for(let d=0;d<a.children.length;d++){let f=a.children[d];n.push(f)}return r}function ju(o,e){let t=[],r=B().getChildren();for(let i=0;i<r.length;i++){let s=r[i];Ju(o,e,s,t)}return{namespace:o._config.namespace,nodes:t}}function Qu(o){let e=[];for(let t=0;t<o.length;t++){let n=o[t],r=Ql(n);y(r)&&ia(r),e.push(r)}return e}var ix=50,qn=null;async function Yn(o,e,t){if(qn!==null)return!1;if(e!==null)return new Promise((a,d)=>{o.update(()=>{a(Vu(o,e,t))})});let n=o.getRootElement(),r=o._window==null?window.document:o._window.document,i=Xu(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,d)=>{let f=o.registerCommand(lo,m=>(pt(m,ClipboardEvent)&&(f(),qn!==null&&(window.clearTimeout(qn),qn=null),a(Vu(o,m,t))),!0),Me);qn=window.setTimeout(()=>{f(),qn=null,a(!1)},ix),r.execCommand("copy"),s.remove()})}function Vu(o,e,t){if(t===void 0){let r=Xu(o._window);if(!r)return!1;let i=r.anchorNode,s=r.focusNode;if(i!==null&&s!==null&&!zt(o,i,s))return!1;let l=T();if(l===null)return!1;t=Qi(l)}e.preventDefault();let n=e.clipboardData;return n===null?!1:(ef(n,t),!0)}var sx=[["text/html",Zu],["application/x-lexical-editor",Gu]];function Qi(o=T()){let e={"text/plain":o?o.getTextContent():""};if(o){let t=Ll();for(let[n,r]of sx){let i=r(t,o);i!==null&&(e[n]=i)}}return e}function ef(o,e){for(let t in e){let n=e[t];n!==void 0&&o.setData(t,n)}}function es(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 tf=k("DRAG_DROP_PASTE_FILE"),Co=class o extends z{static getType(){return"quote"}static clone(e){return new o(e.__key)}constructor(e){super(e)}createDOM(e){let t=document.createElement("blockquote");return Te(t,e.theme.quote),t}updateDOM(e,t){return!1}static importDOM(){return{blockquote:e=>({conversion:lx,priority:0})}}exportDOM(e){let{element:t}=super.exportDOM(e);if(t&&Ee(t)){this.isEmpty()&&t.append(document.createElement("br"));let n=this.getFormatType();t.style.textAlign=n}return{element:t}}static importJSON(e){let t=rf();return t.setFormat(e.format),t.setIndent(e.indent),t}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(e,t){let n=P(),r=this.getDirection();return n.setDirection(r),this.insertAfter(n,t),n}collapseAtStart(){let e=P();return this.getChildren().forEach(n=>e.append(n)),this.replace(e),!0}canMergeWhenEmpty(){return!0}};function rf(){return re(new Co)}function ns(o){return o instanceof Co}var _o=class o extends z{static getType(){return"heading"}static clone(e){return new o(e.__tag,e.__key)}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 n}updateDOM(e,t){return!1}static importDOM(){return{h1:e=>({conversion:Vn,priority:0}),h2:e=>({conversion:Vn,priority:0}),h3:e=>({conversion:Vn,priority:0}),h4:e=>({conversion:Vn,priority:0}),h5:e=>({conversion:Vn,priority:0}),h6:e=>({conversion:Vn,priority:0}),p:e=>{let n=e.firstChild;return n!==null&&of(n)?{conversion:()=>({node:null}),priority:3}:null},span:e=>of(e)?{conversion:t=>({node:Fr("h1")}),priority:3}:null}}exportDOM(e){let{element:t}=super.exportDOM(e);if(t&&Ee(t)){this.isEmpty()&&t.append(document.createElement("br"));let n=this.getFormatType();t.style.textAlign=n}return{element:t}}static importJSON(e){let t=Fr(e.tag);return t.setFormat(e.format),t.setIndent(e.indent),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?P():Fr(this.getTag()),l=this.getDirection();if(s.setDirection(l),this.insertAfter(s,t),n===0&&!this.isEmpty()&&e){let a=P();a.select(),this.replace(a,!0)}return s}collapseAtStart(){let e=this.isEmpty()?P():Fr(this.getTag());return this.getChildren().forEach(n=>e.append(n)),this.replace(e),!0}extractWithChild(){return!0}};function of(o){return o.nodeName.toLowerCase()==="span"?o.style.fontSize==="26pt":!1}function Vn(o){let e=o.nodeName.toLowerCase(),t=null;return(e==="h1"||e==="h2"||e==="h3"||e==="h4"||e==="h5"||e==="h6")&&(t=Fr(e),o.style!==null&&t.setFormat(o.style.textAlign)),{node:t}}function lx(o){let e=rf();return o.style!==null&&e.setFormat(o.style.textAlign),{node:e}}function Fr(o){return re(new _o(o))}function rs(o){return o instanceof _o}function ax(o,e){o.preventDefault(),e.update(()=>{let t=T(),n=pt(o,InputEvent)||pt(o,KeyboardEvent)?null:o.clipboardData;n!=null&&t!==null&&ji(n,t,e)},{tag:"paste"})}async function dx(o,e){await Yn(e,pt(o,ClipboardEvent)?o:null),e.update(()=>{let t=T();_(t)?t.removeText():_e(t)&&t.getNodes().forEach(n=>n.remove())})}function ts(o){let e=null;if(pt(o,DragEvent)?e=o.dataTransfer:pt(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 nf(o){let e=T();if(!_(e))return!1;let t=new Set,n=e.getNodes();for(let r=0;r<n.length;r++){let i=n[r],s=i.getKey();if(t.has(s))continue;let l=K(i,d=>x(d)&&!d.isInline());if(l===null)continue;let a=l.getKey();l.canIndent()&&!t.has(a)&&(t.add(a),o(l))}return t.size>0}function os(o){let e=J(o);return F(e)}function cx(o){let e=o.focus;return e.key==="root"&&e.offset===B().getChildrenSize()}function sf(o){return Jt(o.registerCommand(dr,t=>{let n=T();return _e(n)?(n.clear(),!0):!1},0),o.registerCommand(Ge,t=>{let n=T();return _(n)?(n.deleteCharacter(t),!0):!1},q),o.registerCommand(bt,t=>{let n=T();return _(n)?(n.deleteWord(t),!0):!1},q),o.registerCommand(at,t=>{let n=T();return _(n)?(n.deleteLine(t),!0):!1},q),o.registerCommand(lt,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)ji(r,n,o);else if(_(n)){let i=t.data;return i&&n.insertText(i),!0}}return!0},q),o.registerCommand(_n,()=>{let t=T();return _(t)?(t.removeText(),!0):!1},q),o.registerCommand(Ne,t=>{let n=T();return _(n)?(n.formatText(t),!0):!1},q),o.registerCommand(cr,t=>{let n=T();if(!_(n)&&!_e(n))return!1;let r=n.getNodes();for(let i of r){let s=K(i,l=>x(l)&&!l.isInline());s!==null&&s.setFormat(t)}return!0},q),o.registerCommand($t,t=>{let n=T();return _(n)?(n.insertLineBreak(t),!0):!1},q),o.registerCommand(Pt,()=>{let t=T();return _(t)?(t.insertParagraph(),!0):!1},q),o.registerCommand(el,()=>(Ie([Ot()]),!0),q),o.registerCommand(tl,()=>nf(t=>{let n=t.getIndent();t.setIndent(n+1)}),q),o.registerCommand(ui,()=>nf(t=>{let n=t.getIndent();n>0&&t.setIndent(n-1)}),q),o.registerCommand(ko,t=>{let n=T();if(_e(n)&&!os(t.target)){let r=n.getNodes();if(r.length>0)return r[0].selectPrevious(),!0}else if(_(n)){let r=qt(n.focus,!0);if(!t.shiftKey&&F(r)&&!r.isIsolated()&&!r.isInline())return r.selectPrevious(),t.preventDefault(),!0}return!1},q),o.registerCommand($o,t=>{let n=T();if(_e(n)){let r=n.getNodes();if(r.length>0)return r[0].selectNext(0,0),!0}else if(_(n)){if(cx(n))return t.preventDefault(),!0;let r=qt(n.focus,!1);if(!t.shiftKey&&F(r)&&!r.isIsolated()&&!r.isInline())return r.selectNext(),t.preventDefault(),!0}return!1},q),o.registerCommand(Io,t=>{let n=T();if(_e(n)){let r=n.getNodes();if(r.length>0)return t.preventDefault(),r[0].selectPrevious(),!0}if(!_(n))return!1;if(Yi(n,!0)){let r=t.shiftKey;return t.preventDefault(),Vi(n,r,!0),!0}return!1},q),o.registerCommand(Ro,t=>{let n=T();if(_e(n)&&!os(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 Yi(n,!1)?(t.preventDefault(),Vi(n,r,!1),!0):!1},q),o.registerCommand(Ft,t=>{if(os(t.target))return!1;let n=T();if(!_(n))return!1;t.preventDefault();let{anchor:r}=n,i=r.getNode();return n.isCollapsed()&&r.offset===0&&!G(i)&&Xi(i).getIndent()>0?o.dispatchCommand(ui,void 0):o.dispatchCommand(Ge,!0)},q),o.registerCommand(Bt,t=>{if(os(t.target))return!1;let n=T();return _(n)?(t.preventDefault(),o.dispatchCommand(Ge,!1)):!1},q),o.registerCommand(dt,t=>{let n=T();if(!_(n))return!1;if(t!==null){if((St||Ht||Kt)&&fo)return!1;if(t.preventDefault(),t.shiftKey)return o.dispatchCommand($t,!1)}return o.dispatchCommand(Pt,void 0)},q),o.registerCommand(Po,()=>{let t=T();return _(t)?(o.blur(),!0):!1},q),o.registerCommand(Bo,t=>{let[,n]=ts(t);if(n.length>0){let i=t.clientX,s=t.clientY,l=es(i,s);if(l!==null){let{offset:a,node:d}=l,f=J(d);if(f!==null){let m=jo();if(y(f))m.anchor.set(f.getKey(),a,"text"),m.focus.set(f.getKey(),a,"text");else{let u=f.getParentOrThrow().getKey(),p=f.getIndexWithinParent()+1;m.anchor.set(u,p,"element"),m.focus.set(u,p,"element")}let c=Ho(m);Y(c)}o.dispatchCommand(tf,n)}return t.preventDefault(),!0}let r=T();return!!_(r)},q),o.registerCommand(ur,t=>{let[n]=ts(t),r=T();return!(n&&!_(r))},q),o.registerCommand(fr,t=>{let[n]=ts(t),r=T();if(n&&!_(r))return!1;let i=t.clientX,s=t.clientY,l=es(i,s);if(l!==null){let a=J(l.node);F(a)&&t.preventDefault()}return!0},q),o.registerCommand(yn,()=>(bl(),!0),q),o.registerCommand(lo,t=>(Yn(o,pt(t,ClipboardEvent)?t:null),!0),q),o.registerCommand(ao,t=>(dx(t,o),!0),q),o.registerCommand(ro,t=>{let[,n,r]=ts(t);return n.length>0&&!r?(o.dispatchCommand(tf,n),!0):An(t.target)?!1:T()!==null?(ax(t,o),!0):!1},q))}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 lf(o){return new DOMParser().parseFromString(o,"text/html")}function ht(o,e="px"){return typeof o=="number"||/^-?\d+$/.test(o)?`${o}${e}`:o}function Br(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 Xn(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 af(o,e,t){t?o.setAttribute(e,t):o.removeAttribute(e)}var ux=["left","right","center","justify"];function Hr(o){let e=o.style.textAlign||"";return ux.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 fx(o){let e=o.style.paddingLeft||"0";return Br(e)}function Kr(o){let e=(o.dir||"").toLowerCase();return e==="rtl"||e==="ltr"?e:null}function et(o,e){o.id&&e.setId(o.id),e.setAlignment(Hr(o)),e.setInset(fx(o)),e.setDirection(Kr(o))}function yo(o,e){return o.__id!==e.__id||o.__alignment!==e.__alignment||o.__inset!==e.__inset||o.__dir!==e.__dir}function tt(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 ot(o,e){e.setId(o.id),e.setAlignment(o.alignment),e.setInset(o.inset),e.setDirection(o.direction)}var en=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||""),tt(r,this),r}updateDOM(t){return t.__category!==this.__category||yo(t,this)}insertNewAfter(t,n){let r=t?t.anchor.offset:0,i=r===this.getTextContentSize()||!t?P():Zn(this.__category);if(i.setDirection(this.getDirection()),this.insertAfter(i,n),r===0&&!this.isEmpty()&&t){let s=P();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 et(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=Zn(t.category);return ot(t,n),n}};function Zn(o="info"){return new en(o)}function ua(o){return o instanceof en}function fa(o,e="info"){return o instanceof en&&o.getCategory()===e}var tn=class o extends We{constructor(){super(...arguments);this.__id="";this.__alignment="";this.__inset=0}static getType(){return"custom-paragraph"}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}static clone(t){let n=new o(t.__key);return n.__id=t.__id,n.__alignment=t.__alignment,n.__inset=t.__inset,n}createDOM(t){let n=super.createDOM(t);return tt(n,this),n}updateDOM(t,n,r){return super.updateDOM(t,n,r)||yo(t,this)}exportJSON(){return{...super.exportJSON(),type:"custom-paragraph",version:1,id:this.__id,alignment:this.__alignment,inset:this.__inset}}static importJSON(t){let n=nt();return ot(t,n),n}static importDOM(){return{p(t){return{conversion:n=>{let r=nt();if(n.style.textIndent){let i=parseInt(n.style.textIndent,10)/20;i>0&&r.setIndent(i)}return et(n,r),{node:r}},priority:1}}}}};function nt(){return new tn}function df(o){return o instanceof tn}var mx=new Set(["http:","https:","mailto:","sms:","tel:"]),Gn=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:px,priority:1})}}static importJSON(e){let t=jt(e.url,{rel:e.rel,target:e.target,title:e.title});return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}sanitizeUrl(e){try{let t=new URL(e);if(!mx.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=jt(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 px(o){let e=null;if(Di(o)){let t=o.textContent;(t!==null&&t!==""||o.children.length>0)&&(e=jt(o.getAttribute("href")||"",{rel:o.getAttribute("rel"),target:o.getAttribute("target"),title:o.getAttribute("title")}))}return{node:e}}function jt(o,e){return re(new Gn(o,e))}function Rt(o){return o instanceof Gn}var oL=k("TOGGLE_LINK_COMMAND");function gx(o){return o.map(e=>{if(y(e)){let t=nt();return t.append(e),t}return e})}function bo(o,e){let t=lf(e),n=Gi(o,t);return gx(n)}function So(o,e){for(let t of o.getParents())if(e(t))return t;return null}function ma(o,e){e||(e=B());let t=[];for(let n of e.getChildren())o(n)&&t.push(n),x(n)&&t.push(...ma(o,n));return t}function cf(o,e,t){let n=B().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 Ur(o){let e=t=>(x(t)||F(t))&&!t.isInline()&&!G(t);return e(o)?o:K(o,e)}function zr(o){return"__alignment"in o}function uf(o){return"__inset"in o}var ff=new WeakMap;function fe(o){return ff.get(o)||null}function mf(o,e){ff.set(o,e)}function ae(o,e){return j(o,e)!==null}function j(o,e){if(!o)return null;for(let t of o.getNodes()){if(e(t))return t;let n=So(t,e);if(n)return n}return null}function pf(o,e){if(!o)return!1;for(let t of o.getNodes())if(y(t)&&t.hasFormat(e))return!0;return!1}function Jn(o,e){let t=T(),n=t?Xi(t.getNodes()[0]):null;t&&o(n)?qi(t,nt):qi(t,e)}function on(o,e=!0){pa([o],e)}function pa(o,e=!0){let t=T()?.getNodes()||[],n=t.length>0?Ur(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 B().append(...o)}function $e(o){let e=Go();e.add(o.getKey()),Y(e)}function gf(o){for(let e of o){if(y(e))return e;if(x(e)){let t=e.getChildren(),n=gf(t);if(n!==null)return n}}return null}function hf(o){let e=[...o].reverse();for(let t of e){if(y(t))return t;if(x(t)){let n=[...t.getChildren()].reverse(),r=hf(n);if(r!==null)return r}}return null}function Nf(o){if(o.length===0)return;let e=jo(),t=gf(o),n=hf(o);t&&n&&(e.setTextNodeRange(t,0,n,n.getTextContentSize()||0),Y(e))}function xf(o){let e=fe(o);e&&window.requestAnimationFrame(()=>{o.update(()=>{Y(e.clone())})})}function is(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 Wr(o,e){let t=[...o?.getNodes()||[],...It(o)];for(let n of t)if(zr(n)&&n.getAlignment()===e)return!0;return!1}function ga(o,e){let t=[...o?.getNodes()||[],...It(o)];for(let n of t)if(Jo(n)&&n.getDirection()===e)return!0;return!1}function It(o){if(!o)return[];let e=new Map;for(let t of o.getNodes()){let n=Ur(t);x(n)&&e.set(n.getKey(),n)}return Array.from(e.values())}var nn=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(()=>{$e(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(Hr(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=jn(t.src,{alt:t.alt,width:t.width,height:t.height});return n.setAlignment(t.alignment),n}};function jn(o,e={}){return new nn(o,e)}function Nt(o){return o instanceof nn}var Qn=class o extends z{constructor(){super(...arguments);this.__id=""}static getType(){return"details"}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}static clone(t){let n=new o(t.__key);return n.__id=t.__id,n.__dir=t.__dir,n}createDOM(t,n){let r=document.createElement("details");return this.__id&&r.setAttribute("id",this.__id),this.__dir&&r.setAttribute("dir",this.__dir),r}updateDOM(t,n){return t.__id!==this.__id||t.__dir!==this.__dir}static importDOM(){return{details(t){return{conversion:n=>{let r=new o;return n.id&&r.setId(n.id),n.dir&&r.setDirection(Kr(n)),{node:r}},priority:3}}}}exportJSON(){return{...super.exportJSON(),type:"details",version:1,id:this.__id}}static importJSON(t){let n=ha();return n.setId(t.id),n.setDirection(t.direction),n}};function ha(){return new Qn}function Ef(o){return o instanceof Qn}var qr=class o extends z{static getType(){return"summary"}static clone(e){return new o(e.__key)}createDOM(e,t){return b("summary")}updateDOM(e,t){return!1}static importDOM(){return{summary(e){return{conversion:t=>({node:new o}),priority:3}}}}exportJSON(){return{...super.exportJSON(),type:"summary",version:1}}static importJSON(e){return hx()}};function hx(){return new qr}function Na(o){let e=1,t=o.getParent();for(;t!=null;){if(te(t)){let n=t.getParent();if(H(n)){e++,t=n.getParent();continue}E(!1,"A ListItemNode must have a ListNode for a parent.")}return e}return e}function xa(o){let e=o.getParent();H(e)||E(!1,"A ListItemNode must have a ListNode for a parent.");let t=e;for(;t!==null;)t=t.getParent(),H(t)&&(e=t);return e}function Ea(o){let e=[],t=o.getChildren().filter(te);for(let n=0;n<t.length;n++){let r=t[n],i=r.getFirstChild();H(i)?e=e.concat(Ea(i)):e.push(r)}return e}var n0=Symbol.for("@lexical/NestedListNodeBrand");function rt(o){return te(o)&&H(o.getFirstChild())}function Ta(o){return ve().append(o)}function Cf(o,e){return te(o)&&(e.length===0||e.length===1&&o.is(e[0])&&o.getChildrenSize()===0)}function Ca(o,e){o.update(()=>{let t=T();if(t!==null){let n=t.getNodes();if(_(t)){let i=t.getStartEndPoints();E(i!==null,"insertList: anchor should be defined");let[s]=i,l=s.getNode(),a=l.getParent();if(Cf(l,n)){let d=ye(e);if(pe(a)){l.replace(d);let f=ve();x(l)&&(f.setFormat(l.getFormatType()),f.setIndent(l.getIndent())),d.append(f)}else if(te(l)){let f=l.getParentOrThrow();rn(d,f.getChildren()),f.replace(d)}return}}let r=new Set;for(let i=0;i<n.length;i++){let s=n[i];if(x(s)&&s.isEmpty()&&!te(s)&&!r.has(s.getKey())){Tf(s,e);continue}if(yr(s)){let l=s.getParent();for(;l!=null;){let a=l.getKey();if(H(l)){if(!r.has(a)){let d=ye(e);rn(d,l.getChildren()),l.replace(d),r.add(a)}break}else{let d=l.getParent();if(pe(d)&&!r.has(a)){r.add(a),Tf(l,e);break}l=d}}}}}})}function rn(o,e){o.splice(o.getChildrenSize(),0,e)}function Tf(o,e){if(H(o))return o;let t=o.getPreviousSibling(),n=o.getNextSibling(),r=ve();if(r.setFormat(o.getFormatType()),r.setIndent(o.getIndent()),rn(r,o.getChildren()),H(t)&&e===t.getListType())return t.append(r),o.remove(),H(n)&&e===n.getListType()&&(rn(t,n.getChildren()),n.remove()),t;if(H(n)&&e===n.getListType())return n.getFirstChildOrThrow().insertBefore(r),o.remove(),n;{let i=ye(e);return i.append(r),o.replace(i),i}}function ss(o,e){let t=o.getLastChild(),n=e.getFirstChild();t&&n&&rt(t)&&rt(n)&&(ss(t.getFirstChild(),n.getFirstChild()),n.remove());let r=e.getChildren();r.length>0&&o.append(...r),e.remove()}function _a(o){o.update(()=>{let e=T();if(_(e)){let t=new Set,n=e.getNodes(),r=e.anchor.getNode();if(Cf(r,n))t.add(xa(r));else for(let i=0;i<n.length;i++){let s=n[i];if(yr(s)){let l=Fu(s,xt);l!=null&&t.add(xa(l))}}for(let i of t){let s=i,l=Ea(i);for(let a of l){let d=P();rn(d,a.getChildren()),s.insertAfter(d),s=d,a.__key===e.anchor.key&&e.anchor.set(d.getKey(),0,"element"),a.__key===e.focus.key&&e.focus.set(d.getKey(),0,"element"),a.remove()}i.remove()}}})}function _f(o){let e=o.getListType()!=="check",t=o.getStart();for(let n of o.getChildren())te(n)&&(n.getValue()!==t&&n.setValue(t),e&&n.getLatest().__checked!=null&&n.setChecked(void 0),H(n.getFirstChild())||t++)}function yf(o){let e=o.getNextSibling();H(e)&&o.getListType()===e.getListType()&&ss(o,e)}function bf(o){let e=new Set;if(rt(o)||e.has(o.getKey()))return;let t=o.getParent(),n=o.getNextSibling(),r=o.getPreviousSibling();if(rt(n)&&rt(r)){let i=r.getFirstChild();if(H(i)){i.append(o);let s=n.getFirstChild();if(H(s)){let l=s.getChildren();rn(i,l),n.remove(),e.add(n.getKey())}}}else if(rt(n)){let i=n.getFirstChild();if(H(i)){let s=i.getFirstChild();s!==null&&s.insertBefore(o)}}else if(rt(r)){let i=r.getFirstChild();H(i)&&i.append(o)}else if(H(t)){let i=ve(),s=ye(t.getListType());i.append(s),s.append(o),r?r.insertAfter(i):n?n.insertBefore(i):t.append(i)}}function Sf(o){if(rt(o))return;let e=o.getParent(),t=e?e.getParent():void 0,n=t?t.getParent():void 0;if(H(n)&&te(t)&&H(e)){let r=e?e.getFirstChild():void 0,i=e?e.getLastChild():void 0;if(o.is(r))t.insertBefore(o),e.isEmpty()&&t.remove();else if(o.is(i))t.insertAfter(o),e.isEmpty()&&t.remove();else{let s=e.getListType(),l=ve(),a=ye(s);l.append(a),o.getPreviousSiblings().forEach(m=>a.append(m));let d=ve(),f=ye(s);d.append(f),rn(f,o.getNextSiblings()),t.insertBefore(l),t.insertAfter(d),t.replace(o)}}}var xt=class o extends z{static getType(){return"listitem"}static clone(e){return new o(e.__value,e.__checked,e.__key)}constructor(e,t,n){super(n),this.__value=e===void 0?1:e,this.__checked=t}createDOM(e){let t=document.createElement("li"),n=this.getParent();return H(n)&&n.getListType()==="check"&&Mf(t,this,null,n),t.value=this.__value,Lf(t,e.theme,this),t}updateDOM(e,t,n){let r=this.getParent();return H(r)&&r.getListType()==="check"&&Mf(t,this,e,r),t.value=this.__value,Lf(t,n.theme,this),!1}static transform(){return e=>{if(E(te(e),"node is not a ListItemNode"),e.__checked==null)return;let t=e.getParent();H(t)&&t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:Nx,priority:0})}}static importJSON(e){let t=ve();return t.setChecked(e.checked),t.setValue(e.value),t.setFormat(e.format),t.setDirection(e.direction),t}exportDOM(e){let t=this.createDOM(e._config);return t.style.textAlign=this.getFormatType(),{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(),version:1}}append(...e){for(let t=0;t<e.length;t++){let n=e[t];if(x(n)&&this.canMergeWith(n)){let r=n.getChildren();this.append(...r),n.remove()}else super.append(n)}return this}replace(e,t){if(te(e))return super.replace(e);this.setIndent(0);let n=this.getParentOrThrow();if(!H(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{let r=ye(n.getListType()),i=this.getNextSibling();for(;i;){let s=i;i=i.getNextSibling(),r.append(s)}n.insertAfter(e),e.insertAfter(r)}return t&&(E(x(e),"includeChildren should only be true for ElementNodes"),this.getChildren().forEach(r=>{e.append(r)})),this.remove(),n.getChildrenSize()===0&&n.remove(),e}insertAfter(e,t=!0){let n=this.getParentOrThrow();if(H(n)||E(!1,"insertAfter: list node is not parent of list item node"),te(e))return super.insertAfter(e,t);let r=this.getNextSiblings();if(n.insertAfter(e,t),r.length!==0){let i=ye(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&&rt(t)&&rt(n)&&(ss(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){if(this.getTextContent().trim()===""&&this.isLastChild()){let r=this.getParentOrThrow();if(!te(r.getParent())){let i=P();return r.insertAfter(i,t),this.remove(),i}}let n=ve(this.__checked==null?void 0:!1);return this.insertAfter(n,t),n}collapseAtStart(e){let t=P();this.getChildren().forEach(l=>t.append(l));let r=this.getParentOrThrow(),i=r.getParentOrThrow(),s=te(i);if(r.getChildrenSize()===1)if(s)r.remove(),i.select();else{r.insertBefore(t),r.remove();let l=e.anchor,a=e.focus,d=t.getKey();l.type==="element"&&l.getNode().is(this)&&l.set(d,l.offset,"element"),a.type==="element"&&a.getNode().is(this)&&a.set(d,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 H(n)&&(t=n.getListType()),t==="check"?!!e.__checked:void 0}setChecked(e){let t=this.getWritable();t.__checked=e}toggleChecked(){this.setChecked(!this.__checked)}getIndent(){let e=this.getParent();if(e===null)return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;te(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){E(typeof e=="number","Invalid indent value."),e=Math.floor(e),E(e>=0,"Indent value must be non-negative.");let t=this.getIndent();for(;t!==e;)t<e?(bf(this),t++):(Sf(this),t--);return this}canInsertAfter(e){return te(e)}canReplaceWith(e){return te(e)}canMergeWith(e){return Xt(e)||te(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 ye("bullet")}canMergeWhenEmpty(){return!0}};function Lf(o,e,t){let n=[],r=[],i=e.list,s=i?i.listitem:void 0,l;if(i&&i.nested&&(l=i.nested.listitem),s!==void 0&&n.push(...Ke(s)),i){let a=t.getParent(),d=H(a)&&a.getListType()==="check",f=t.getChecked();(!d||f)&&r.push(i.listitemUnchecked),(!d||!f)&&r.push(i.listitemChecked),d&&n.push(f?i.listitemChecked:i.listitemUnchecked)}if(l!==void 0){let a=Ke(l);t.getChildren().some(d=>H(d))?n.push(...a):r.push(...a)}r.length>0&&Wn(o,...r),n.length>0&&Te(o,...n)}function Mf(o,e,t,n){H(e.getFirstChild())?(o.removeAttribute("role"),o.removeAttribute("tabIndex"),o.removeAttribute("aria-checked")):(o.setAttribute("role","checkbox"),o.setAttribute("tabIndex","-1"),(!t||e.__checked!==t.__checked)&&o.setAttribute("aria-checked",e.getChecked()?"true":"false"))}function Nx(o){if(o.classList.contains("task-list-item")){for(let r of o.children)if(r.tagName==="INPUT")return xx(r)}let t=o.getAttribute("aria-checked");return{node:ve(t==="true"?!0:t==="false"?!1:void 0)}}function xx(o){if(!(o.getAttribute("type")==="checkbox"))return{node:null};let t=o.hasAttribute("checked");return{node:ve(t)}}function ve(o){return re(new xt(void 0,o))}function te(o){return o instanceof xt}var Qt=class o extends z{static getType(){return"list"}static clone(e){let t=e.__listType||Of[e.__tag];return new o(t,e.__start,e.__key)}constructor(e,t,n){super(n);let r=Of[e]||e;this.__listType=r,this.__tag=r==="number"?"ol":"ul",this.__start=t}getTag(){return this.__tag}setListType(e){let t=this.getWritable();t.__listType=e,t.__tag=e==="number"?"ol":"ul"}getListType(){return this.__listType}getStart(){return this.__start}createDOM(e,t){let n=this.__tag,r=document.createElement(n);return this.__start!==1&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,vf(r,e.theme,this),r}updateDOM(e,t,n){return e.__tag!==this.__tag?!0:(vf(t,n.theme,this),!1)}static transform(){return e=>{E(H(e),"node is not a ListNode"),yf(e),_f(e)}}static importDOM(){return{ol:()=>({conversion:wf,priority:0}),ul:()=>({conversion:wf,priority:0})}}static importJSON(e){let t=ye(e.listType,e.start);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportDOM(e){let{element:t}=super.exportDOM(e);return t&&Ee(t)&&(this.__start!==1&&t.setAttribute("start",String(this.__start)),this.__listType==="check"&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag(),type:"list",version:1}}canBeEmpty(){return!1}canIndent(){return!1}append(...e){for(let t=0;t<e.length;t++){let n=e[t];if(te(n))super.append(n);else{let r=ve();if(H(n))r.append(n);else if(x(n)){let i=Z(n.getTextContent());r.append(i)}else r.append(n);super.append(r)}}return this}extractWithChild(e){return te(e)}};function vf(o,e,t){let n=[],r=[],i=e.list;if(i!==void 0){let s=i[`${t.__tag}Depth`]||[],l=Na(t)-1,a=l%s.length,d=s[a],f=i[t.__tag],m,c=i.nested,u=i.checklist;if(c!==void 0&&c.list&&(m=c.list),f!==void 0&&n.push(f),u!==void 0&&t.__listType==="check"&&n.push(u),d!==void 0){n.push(...Ke(d));for(let p=0;p<s.length;p++)p!==a&&r.push(t.__tag+p)}if(m!==void 0){let p=Ke(m);l>1?n.push(...p):r.push(...p)}}r.length>0&&Wn(o,...r),n.length>0&&Te(o,...n)}function Ex(o){let e=[];for(let t=0;t<o.length;t++){let n=o[t];if(te(n)){e.push(n);let r=n.getChildren();r.length>1&&r.forEach(i=>{H(i)&&e.push(Ta(i))})}else e.push(Ta(n))}return e}function Tx(o){if(o.getAttribute("__lexicallisttype")==="check"||o.classList.contains("contains-task-list"))return!0;for(let e of o.childNodes)if(Ee(e)&&e.hasAttribute("aria-checked"))return!0;return!1}function wf(o){let e=o.nodeName.toLowerCase(),t=null;if(e==="ol"){let n=o.start;t=ye("number",n)}else e==="ul"&&(Tx(o)?t=ye("check"):t=ye("bullet"));return{after:Ex,node:t}}var Of={ol:"number",ul:"bullet"};function ye(o,e=1){return re(new Qt(o,e))}function H(o){return o instanceof Qt}var j0=k("INSERT_UNORDERED_LIST_COMMAND"),Q0=k("INSERT_ORDERED_LIST_COMMAND"),eM=k("INSERT_CHECK_LIST_COMMAND"),tM=k("REMOVE_LIST_COMMAND");var ls=/^(\d+(?:\.\d+)?)px$/;var oe={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1},Et=class o extends z{static getType(){return"tablecell"}static clone(e){let t=new o(e.__headerState,e.__colSpan,e.__width,e.__key);return t.__rowSpan=e.__rowSpan,t.__backgroundColor=e.__backgroundColor,t}static importDOM(){return{td:e=>({conversion:Df,priority:0}),th:e=>({conversion:Df,priority:0})}}static importJSON(e){let t=e.colSpan||1,n=e.rowSpan||1,r=Ye(e.headerState,t,e.width||void 0);return r.__rowSpan=n,r.__backgroundColor=e.backgroundColor||null,r}constructor(e=oe.NO_STATUS,t=1,n,r){super(r),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null}createDOM(e){let t=document.createElement(this.getTag());return this.__width&&(t.style.width=`${this.__width}px`),this.__colSpan>1&&(t.colSpan=this.__colSpan),this.__rowSpan>1&&(t.rowSpan=this.__rowSpan),this.__backgroundColor!==null&&(t.style.backgroundColor=this.__backgroundColor),Te(t,e.theme.tableCell,this.hasHeader()&&e.theme.tableCellHeader),t}exportDOM(e){let{element:t}=super.exportDOM(e);if(t){let n=t;n.style.border="1px solid black",this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),n.style.width=`${this.getWidth()||75}px`,n.style.verticalAlign="top",n.style.textAlign="start";let r=this.getBackgroundColor();r!==null?n.style.backgroundColor=r:this.hasHeader()&&(n.style.backgroundColor="#f2f3f5")}return{element:t}}exportJSON(){return{...super.exportJSON(),backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,type:"tablecell",width:this.getWidth()}}getColSpan(){return this.__colSpan}setColSpan(e){return this.getWritable().__colSpan=e,this}getRowSpan(){return this.__rowSpan}setRowSpan(e){return this.getWritable().__rowSpan=e,this}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e){let t=this.getWritable();return t.__headerState=e,this.__headerState}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){let t=this.getWritable();return t.__width=e,this.__width}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){this.getWritable().__backgroundColor=e}toggleHeaderStyle(e){let t=this.getWritable();return(t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==oe.NO_STATUS}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}};function Df(o){let e=o,t=o.nodeName.toLowerCase(),n;ls.test(e.style.width)&&(n=parseFloat(e.style.width));let r=Ye(t==="th"?oe.ROW:oe.NO_STATUS,e.colSpan,n);r.__rowSpan=e.rowSpan;let i=e.style.backgroundColor;i!==""&&(r.__backgroundColor=i);let s=e.style,l=s.textDecoration.split(" "),a=s.fontWeight==="700"||s.fontWeight==="bold",d=l.includes("line-through"),f=s.fontStyle==="italic",m=l.includes("underline");return{after:c=>(c.length===0&&c.push(P()),c),forChild:(c,u)=>{if(I(u)&&!x(c)){let p=P();return Ce(c)&&c.getTextContent()===`
`?null:(y(c)&&(a&&c.toggleFormat("bold"),d&&c.toggleFormat("strikethrough"),f&&c.toggleFormat("italic"),m&&c.toggleFormat("underline")),p.append(c),p)}return c},node:r}}function Ye(o,e=1,t){return re(new Et(o,e,t))}function I(o){return o instanceof Et}var _x=k("INSERT_TABLE_COMMAND");var Tt=class o extends z{static getType(){return"tablerow"}static clone(e){return new o(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:yx,priority:0})}}static importJSON(e){return sn(e.height)}constructor(e,t){super(t),this.__height=e}exportJSON(){return{...super.exportJSON(),...this.getHeight()&&{height:this.getHeight()},type:"tablerow",version:1}}createDOM(e){let t=document.createElement("tr");return this.__height&&(t.style.height=`${this.__height}px`),Te(t,e.theme.tableRow),t}isShadowRoot(){return!0}setHeight(e){let t=this.getWritable();return t.__height=e,this.__height}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}};function yx(o){let e=o,t;return ls.test(e.style.height)&&(t=parseFloat(e.style.height)),{node:sn(t)}}function sn(o){return re(new Tt(o))}function se(o){return o instanceof Tt}function ba(o,e,t=!0){let n=Vr();for(let r=0;r<o;r++){let i=sn();for(let s=0;s<e;s++){let l=oe.NO_STATUS;typeof t=="object"?(r===0&&t.rows&&(l|=oe.ROW),s===0&&t.columns&&(l|=oe.COLUMN)):t&&(r===0&&(l|=oe.ROW),s===0&&(l|=oe.COLUMN));let a=Ye(l),d=P();d.append(Z()),a.append(d),i.append(a)}n.append(i)}return n}var ya=(o,e)=>o===oe.BOTH||o===e?e:oe.NO_STATUS;function as(o=!0){let e=T();E(_(e)||W(e),"Expected a RangeSelection or TableSelection");let t=e.focus.getNode(),[n,,r]=we(t),[i,s]=Ve(r,n,n),l=i[0].length,{startRow:a}=s;if(o){let d=a+n.__rowSpan-1,f=i[d],m=sn();for(let u=0;u<l;u++){let{cell:p,startRow:g}=f[u];if(g+p.__rowSpan-1<=d){let C=f[u].cell.__headerState,N=ya(C,oe.COLUMN);m.append(Ye(N).append(P()))}else p.setRowSpan(p.__rowSpan+1)}let c=r.getChildAtIndex(d);E(se(c),"focusEndRow is not a TableRowNode"),c.insertAfter(m)}else{let d=i[a],f=sn();for(let c=0;c<l;c++){let{cell:u,startRow:p}=d[c];if(p===a){let h=d[c].cell.__headerState,C=ya(h,oe.COLUMN);f.append(Ye(C).append(P()))}else u.setRowSpan(u.__rowSpan+1)}let m=r.getChildAtIndex(a);E(se(m),"focusEndRow is not a TableRowNode"),m.insertBefore(f)}}function ds(o=!0){let e=T();E(_(e)||W(e),"Expected a RangeSelection or TableSelection");let t=e.anchor.getNode(),n=e.focus.getNode(),[r]=we(t),[i,,s]=we(n),[l,a,d]=Ve(s,i,r),f=l.length,m=o?Math.max(a.startColumn,d.startColumn):Math.min(a.startColumn,d.startColumn),c=o?m+i.__colSpan-1:m-1,u=s.getFirstChild();E(se(u),"Expected firstTable child to be a row");let p=null;function g(C=oe.NO_STATUS){let N=Ye(C).append(P());return p===null&&(p=N),N}let h=u;e:for(let C=0;C<f;C++){if(C!==0){let A=h.getNextSibling();E(se(A),"Expected row nextSibling to be a row"),h=A}let N=l[C],L=N[c<0?0:c].cell.__headerState,M=ya(L,oe.ROW);if(c<0){Ma(h,g(M));continue}let{cell:S,startColumn:D,startRow:O}=N[c];if(D+S.__colSpan-1<=c){let A=S,$=O,R=c;for(;$!==C&&A.__rowSpan>1;)if(R-=S.__colSpan,R>=0){let{cell:U,startRow:ee}=N[R];A=U,$=ee}else{h.append(g(M));continue e}A.insertAfter(g(M))}else S.setColSpan(S.__colSpan+1)}p!==null&&Yr(p)}function Sa(){let o=T();E(_(o)||W(o),"Expected a RangeSelection or TableSelection");let e=o.anchor.getNode(),t=o.focus.getNode(),[n,,r]=we(e),[i]=we(t),[s,l,a]=Ve(r,n,i),{startRow:d}=l,{startRow:f}=a,m=f+i.__rowSpan-1;if(s.length===m-d+1){r.remove();return}let c=s[0].length,u=s[m+1],p=r.getChildAtIndex(m+1);for(let g=m;g>=d;g--){for(let C=c-1;C>=0;C--){let{cell:N,startRow:L,startColumn:M}=s[g][C];if(M===C&&(g===d&&L<d&&N.setRowSpan(N.__rowSpan-(L-d)),L>=d&&L+N.__rowSpan-1>m))if(N.setRowSpan(N.__rowSpan-(m-L+1)),E(p!==null,"Expected nextRowNode not to be null"),C===0)Ma(p,N);else{let{cell:S}=u[C-1];S.insertAfter(N)}}let h=r.getChildAtIndex(g);E(se(h),"Expected GridNode childAtIndex(%s) to be RowNode",String(g)),h.remove()}if(u!==void 0){let{cell:g}=u[0];Yr(g)}else{let g=s[d-1],{cell:h}=g[0];Yr(h)}}function La(){let o=T();E(_(o)||W(o),"Expected a RangeSelection or TableSelection");let e=o.anchor.getNode(),t=o.focus.getNode(),[n,,r]=we(e),[i]=we(t),[s,l,a]=Ve(r,n,i),{startColumn:d}=l,{startRow:f,startColumn:m}=a,c=Math.min(d,m),u=Math.max(d+n.__colSpan-1,m+i.__colSpan-1),p=u-c+1;if(s[0].length===u-c+1){r.selectPrevious(),r.remove();return}let h=s.length;for(let L=0;L<h;L++)for(let M=c;M<=u;M++){let{cell:S,startColumn:D}=s[L][M];if(D<c){if(M===c){let O=c-D;S.setColSpan(S.__colSpan-Math.min(p,S.__colSpan-O))}}else if(D+S.__colSpan-1>u){if(M===u){let O=u-D+1;S.setColSpan(S.__colSpan-O)}}else S.remove()}let C=s[f],N=d>m?C[d+n.__colSpan]:C[m+i.__colSpan];if(N!==void 0){let{cell:L}=N;Yr(L)}else{let L=m<d?C[m-1]:C[d-1],{cell:M}=L;Yr(M)}}function Yr(o){let e=o.getFirstDescendant();e==null?o.selectStart():e.getParentOrThrow().selectStart()}function Ma(o,e){let t=o.getFirstChild();t!==null?t.insertBefore(e):o.append(e)}function va(){let o=T();E(_(o)||W(o),"Expected a RangeSelection or TableSelection");let e=o.anchor.getNode(),[t,n,r]=we(e),i=t.__colSpan,s=t.__rowSpan;if(i>1){for(let l=1;l<i;l++)t.insertAfter(Ye(oe.NO_STATUS).append(P()));t.setColSpan(1)}if(s>1){let[l,a]=Ve(r,t,t),{startColumn:d,startRow:f}=a,m;for(let c=1;c<s;c++){let u=f+c,p=l[u];m=(m||n).getNextSibling(),E(se(m),"Expected row next sibling to be a row");let g=null;for(let h=0;h<d;h++){let C=p[h],N=C.cell;C.startRow===u&&(g=N),N.__colSpan>1&&(h+=N.__colSpan-1)}if(g===null)for(let h=0;h<i;h++)Ma(m,Ye(oe.NO_STATUS).append(P()));else for(let h=0;h<i;h++)g.insertAfter(Ye(oe.NO_STATUS).append(P()))}t.setRowSpan(1)}}function Ve(o,e,t){let[n,r,i]=Af(o,e,t);return E(r!==null,"Anchor not found in Grid"),E(i!==null,"Focus not found in Grid"),[n,r,i]}function Af(o,e,t){let n=[],r=null,i=null;function s(d,f,m){let c={cell:m,startColumn:f,startRow:d},u=m.__rowSpan,p=m.__colSpan;for(let g=0;g<u;g++){n[d+g]===void 0&&(n[d+g]=[]);for(let h=0;h<p;h++)n[d+g][f+h]=c}e!==null&&e.is(m)&&(r=c),t!==null&&t.is(m)&&(i=c)}function l(d,f){return n[d]===void 0||n[d][f]===void 0}let a=o.getChildren();for(let d=0;d<a.length;d++){let f=a[d];E(se(f),"Expected GridNode children to be TableRowNode");let m=f.getChildren(),c=0;for(let u of m){for(E(I(u),"Expected TableRowNode children to be TableCellNode");!l(d,c);)c++;s(d,c,u),c+=u.__colSpan}}return[n,r,i]}function we(o){let e;if(o instanceof Et)e=o;else if("__type"in o){let r=K(o,I);E(I(r),"Expected to find a parent TableCellNode"),e=r}else{let r=K(o.getNode(),I);E(I(r),"Expected to find a parent TableCellNode"),e=r}let t=e.getParent();E(se(t),"Expected TableCellNode to have a parent TableRowNode");let n=t.getParent();return E(Q(n),"Expected TableRowNode to have a parent GridNode"),[e,t,n]}function cs(o){let[e,,t]=we(o),n=t.getChildren(),r=n.length,i=n[0].getChildren().length,s=new Array(r);for(let l=0;l<r;l++)s[l]=new Array(i);for(let l=0;l<r;l++){let d=n[l].getChildren(),f=0;for(let m=0;m<d.length;m++){for(;s[l][f];)f++;let c=d[m],u=c.__rowSpan||1,p=c.__colSpan||1;for(let g=0;g<u;g++)for(let h=0;h<p;h++)s[l+g][f+h]=c;if(e===c)return{colSpan:p,columnIndex:f,rowIndex:l,rowSpan:u};f+=p}}return null}var us=class o{constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return W(e)?this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus):!1}set(e,t,n){this.dirty=!0,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null}clone(){return new o(this.tableKey,this.anchor,this.focus)}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}insertNodes(e){let t=this.focus.getNode();E(x(t),"Expected TableSelection focus to be an ElementNode"),Ho(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){let e=X(this.anchor.key);E(I(e),"Expected TableSelection anchor to be (or a child of) TableCellNode");let t=cs(e);E(t!==null,"getCellRect: expected to find AnchorNode");let n=X(this.focus.key);E(I(n),"Expected TableSelection focus to be (or a child of) TableCellNode");let r=cs(n);E(r!==null,"getCellRect: expected to find focusCellNode");let i=Math.min(t.columnIndex,r.columnIndex),s=Math.max(t.columnIndex,r.columnIndex),l=Math.min(t.rowIndex,r.rowIndex),a=Math.max(t.rowIndex,r.rowIndex);return{fromX:Math.min(i,s),fromY:Math.min(l,a),toX:Math.max(i,s),toY:Math.max(l,a)}}getNodes(){let e=this._cachedNodes;if(e!==null)return e;let t=this.anchor.getNode(),n=this.focus.getNode(),r=K(t,I),i=K(n,I);E(I(r),"Expected TableSelection anchor to be (or a child of) TableCellNode"),E(I(i),"Expected TableSelection focus to be (or a child of) TableCellNode");let s=r.getParent();E(se(s),"Expected anchorCell to have a parent TableRowNode");let l=s.getParent();E(Q(l),"Expected tableNode to have a parent TableNode");let a=i.getParents()[1];if(a!==l){if(l.isParentOf(i)){let O=a.getParent();E(O!=null,"Expected focusCellParent to have a parent"),this.set(this.tableKey,i.getKey(),O.getKey())}else{let O=l.getParent();E(O!=null,"Expected gridParent to have a parent"),this.set(this.tableKey,O.getKey(),i.getKey())}return this.getNodes()}let[d,f,m]=Ve(l,r,i),c=Math.min(f.startColumn,m.startColumn),u=Math.min(f.startRow,m.startRow),p=Math.max(f.startColumn+f.cell.__colSpan-1,m.startColumn+m.cell.__colSpan-1),g=Math.max(f.startRow+f.cell.__rowSpan-1,m.startRow+m.cell.__rowSpan-1),h=c,C=u,N=c,L=u;function M(O){let{cell:A,startColumn:$,startRow:R}=O;c=Math.min(c,$),u=Math.min(u,R),p=Math.max(p,$+A.__colSpan-1),g=Math.max(g,R+A.__rowSpan-1)}for(;c<h||u<C||p>N||g>L;){if(c<h){let O=L-C,A=h-1;for(let $=0;$<=O;$++)M(d[C+$][A]);h=A}if(u<C){let O=N-h,A=C-1;for(let $=0;$<=O;$++)M(d[A][h+$]);C=A}if(p>N){let O=L-C,A=N+1;for(let $=0;$<=O;$++)M(d[C+$][A]);N=A}if(g>L){let O=N-h,A=L+1;for(let $=0;$<=O;$++)M(d[A][h+$]);L=A}}let S=[l],D=null;for(let O=u;O<=g;O++)for(let A=c;A<=p;A++){let{cell:$}=d[O][A],R=$.getParent();E(se(R),"Expected TableCellNode parent to be a TableRowNode"),R!==D&&S.push(R),S.push($,...bx($)),D=R}return ct()||(this._cachedNodes=S),S}getTextContent(){let e=this.getNodes().filter(n=>I(n)),t="";for(let n=0;n<e.length;n++){let r=e[n],i=r.__parent,s=(e[n+1]||{}).__parent;t+=r.getTextContent()+(s!==i?`
`:" ")}return t}};function W(o){return o instanceof us}function fs(){let o=Re("root",0,"element"),e=Re("root",0,"element");return new us("root",o,e)}function bx(o){let e=[],t=[o];for(;t.length>0;){let n=t.pop();E(n!==void 0,"Stack.length > 0; can't be undefined"),x(n)&&t.unshift(...n.getChildren()),n!==o&&e.push(n)}return e}var Zr=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<t.length;i++){let a=t[i].target.nodeName;if(a==="TABLE"||a==="TBODY"||a==="THEAD"||a==="TR"){n=!0;break}}if(!n)return;let r=this.editor.getElementByKey(this.tableNodeKey);if(!r)throw new Error("Expected to find TableElement in DOM");this.table=ln(r)})});this.editor.update(()=>{let t=this.editor.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");this.table=ln(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=X(this.tableNodeKey);if(!Q(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=ln(n);Xr(e,r,null),Y(null),e.dispatchCommand(De,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");Wn(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(),Xr(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=X(this.tableNodeKey);if(!Q(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=wa(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=J(e.elem);if(this.tableSelection!=null&&this.anchorCellNodeKey!=null&&I(a)&&r.is(Lo(a))){let d=a.getKey();this.tableSelection=this.tableSelection.clone()||fs(),this.focusCellNodeKey=d,this.tableSelection.set(this.tableNodeKey,this.anchorCellNodeKey,this.focusCellNodeKey),Y(this.tableSelection),n.dispatchCommand(De,void 0),Xr(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=J(e.elem);if(I(t)){let n=t.getKey();this.tableSelection=this.tableSelection!=null?this.tableSelection.clone():fs(),this.anchorCellNodeKey=n}})}formatCells(e){this.editor.update(()=>{let t=T();W(t)||E(!1,"Expected grid selection");let n=jo(),r=n.anchor,i=n.focus;t.getNodes().forEach(s=>{I(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(De,void 0)})}clearText(){let e=this.editor;e.update(()=>{let t=X(this.tableNodeKey);if(!Q(t))throw new Error("Expected TableNode.");let n=T();W(n)||E(!1,"Expected grid selection");let r=n.getNodes().filter(I);if(r.length===this.table.columns*this.table.rows){t.selectPrevious(),t.remove(),B().selectStart();return}r.forEach(i=>{if(x(i)){let s=P(),l=Z();s.append(l),i.append(s),i.getChildren().forEach(a=>{a!==s&&a.remove()})}}),Xr(e,this.table,null),Y(null),e.dispatchCommand(De,void 0)})}};var Sx="__lexicalTableSelection",wa=o=>me?(o||window).getSelection():null,Lx=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 Zr(t,o.getKey()),s=t._window||window;Mx(e,i);let l=()=>{let c=()=>{i.isSelecting=!1,s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",u)},u=p=>{setTimeout(()=>{if(!Lx(p)&&i.isSelecting){i.isSelecting=!1,s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",u);return}let g=Da(p.target);g!==null&&(i.anchorX!==g.x||i.anchorY!==g.y)&&(p.preventDefault(),i.setFocusCellForSelection(g))},0)};return{onMouseMove:u,onMouseUp:c}};e.addEventListener("mousedown",c=>{setTimeout(()=>{if(c.button!==0||!s)return;let u=Da(c.target);u!==null&&(an(c),i.setAnchorCellForSelection(u));let{onMouseUp:p,onMouseMove:g}=l();i.isSelecting=!0,s.addEventListener("mouseup",p),s.addEventListener("mousemove",g)},0)});let a=c=>{c.button===0&&t.update(()=>{let u=T(),p=c.target;W(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($o,c=>Gr(t,c,"down",o,i),qe)),i.listenersToRemove.add(t.registerCommand(ko,c=>Gr(t,c,"up",o,i),qe)),i.listenersToRemove.add(t.registerCommand(Io,c=>Gr(t,c,"backward",o,i),qe)),i.listenersToRemove.add(t.registerCommand(Ro,c=>Gr(t,c,"forward",o,i),qe)),i.listenersToRemove.add(t.registerCommand(Po,c=>{let u=T();if(W(u)){let p=K(u.focus.getNode(),I);if(I(p))return an(c),p.selectEnd(),!0}return!1},qe));let d=c=>()=>{let u=T();if(!Mo(u,o))return!1;if(W(u))return i.clearText(),!0;if(_(u)){let p=K(u.anchor.getNode(),D=>I(D));if(!I(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=K(u.anchor.getNode(),D=>x(D)),S=M&&K(M,D=>x(D)&&I(D.getParent()));if(!x(S)||!x(M))return!1;if(c===at&&S.getPreviousSibling()===null)return!0}return!1};[bt,at,Ge].forEach(c=>{i.listenersToRemove.add(t.registerCommand(c,d(c),Me))});let f=c=>{let u=T();if(!Mo(u,o)){let p=u?u.getNodes():null;if(p){let g=p.find(h=>Q(h)&&h.getKey()===i.tableNodeKey);if(Q(g)){if(!g.getParent())return!1;g.remove()}}return!1}if(W(u))return c&&(c.preventDefault(),c.stopPropagation()),i.clearText(),!0;if(_(u)){let p=K(u.anchor.getNode(),g=>I(g));if(!I(p))return!1}return!1};i.listenersToRemove.add(t.registerCommand(Ft,f,Me)),i.listenersToRemove.add(t.registerCommand(Bt,f,Me)),i.listenersToRemove.add(t.registerCommand(ao,c=>{let u=T();if(u){if(!(W(u)||_(u)))return!1;Yn(t,pt(c,ClipboardEvent)?c:null,Qi(u));let p=f(c);return _(u)&&u.removeText(),p}return!1},Me)),i.listenersToRemove.add(t.registerCommand(Ne,c=>{let u=T();if(!Mo(u,o))return!1;if(W(u))return i.formatCells(c),!0;if(_(u)){let p=K(u.anchor.getNode(),g=>I(g));if(!I(p))return!1}return!1},Me)),i.listenersToRemove.add(t.registerCommand(cr,c=>{let u=T();if(!W(u)||!Mo(u,o))return!1;let p=u.anchor.getNode(),g=u.focus.getNode();if(!I(p)||!I(g))return!1;let[h,C,N]=Ve(o,p,g),L=Math.max(C.startRow,N.startRow),M=Math.max(C.startColumn,N.startColumn),S=Math.min(C.startRow,N.startRow),D=Math.min(C.startColumn,N.startColumn);for(let O=S;O<=L;O++)for(let A=D;A<=M;A++){let $=h[O][A].cell;$.setFormat(c);let R=$.getChildren();for(let U=0;U<R.length;U++){let ee=R[U];x(ee)&&!ee.isInline()&&ee.setFormat(c)}}return!0},Me)),i.listenersToRemove.add(t.registerCommand(lt,c=>{let u=T();if(!Mo(u,o))return!1;if(W(u))return i.clearHighlight(),!1;if(_(u)){let p=K(u.anchor.getNode(),g=>I(g));if(!I(p))return!1;if(typeof c=="string"){let g=kf(t,u,o);if(g)return If(g,o,[Z(c)]),!0}}return!1},Me)),n&&i.listenersToRemove.add(t.registerCommand(Fo,c=>{let u=T();if(!_(u)||!u.isCollapsed()||!Mo(u,o))return!1;let p=ps(u.anchor.getNode());if(p===null)return!1;an(c);let g=o.getCordsFromCellNode(p,i.table);return $f(i,o,g.x,g.y,c.shiftKey?"backward":"forward"),!0},Me)),i.listenersToRemove.add(t.registerCommand(mr,c=>o.isSelected(),qe));function m(c){let u=o.getCordsFromCellNode(c,i.table);return o.getDOMCellFromCordsOrThrow(u.x,u.y,i.table)}return i.listenersToRemove.add(t.registerCommand(ar,c=>{let{nodes:u,selection:p}=c,g=p.getStartEndPoints(),h=W(p),N=_(p)&&K(p.anchor.getNode(),Pe=>I(Pe))!==null&&K(p.focus.getNode(),Pe=>I(Pe))!==null||h;if(u.length!==1||!Q(u[0])||!N||g===null)return!1;let[L]=g,M=u[0],S=M.getChildren(),D=M.getFirstChildOrThrow().getChildrenSize(),O=M.getChildrenSize(),A=K(L.getNode(),Pe=>I(Pe)),$=A&&K(A,Pe=>se(Pe)),R=$&&K($,Pe=>Q(Pe));if(!I(A)||!se($)||!Q(R))return!1;let U=$.getIndexWithinParent(),ee=Math.min(R.getChildrenSize()-1,U+O-1),Tn=A.getIndexWithinParent(),Td=Math.min($.getChildrenSize()-1,Tn+D-1),Ch=Math.min(Tn,Td),_h=Math.min(U,ee),yh=Math.max(Tn,Td),bh=Math.max(U,ee),Sh=R.getChildren(),Cd=0;for(let Pe=_h;Pe<=bh;Pe++){let _d=Sh[Pe];if(!se(_d))return!1;let yd=S[Cd];if(!se(yd))return!1;let Lh=_d.getChildren(),Mh=yd.getChildren(),bd=0;for(let Zs=Ch;Zs<=yh;Zs++){let ci=Lh[Zs];if(!I(ci))return!1;let Sd=Mh[bd];if(!I(Sd))return!1;let vh=ci.getChildren();Sd.getChildren().forEach(Cn=>{y(Cn)&&P().append(Cn),ci.append(Cn)}),vh.forEach(Cn=>Cn.remove()),bd++}Cd++}return!0},Me)),i.listenersToRemove.add(t.registerCommand(De,()=>{let c=T(),u=ze();if(_(c)){let{anchor:p,focus:g}=c,h=p.getNode(),C=g.getNode(),N=ps(h),L=ps(C),M=!!(N&&o.is(Lo(N))),S=!!(L&&o.is(Lo(L))),D=M!==S,O=M&&S,A=c.isBackward();if(D){let $=c.clone();if(S){let[R]=Ve(o,L,L),U=R[0][0].cell,ee=R[R.length-1].at(-1).cell;$.focus.set(A?U.getKey():ee.getKey(),A?U.getChildrenSize():ee.getChildrenSize(),"element")}Y($),Rf(t,i)}else O&&(N.is(L)||(i.setAnchorCellForSelection(m(N)),i.setFocusCellForSelection(m(L),!0),i.isSelecting||setTimeout(()=>{let{onMouseUp:$,onMouseMove:R}=l();i.isSelecting=!0,s.addEventListener("mouseup",$),s.addEventListener("mousemove",R)},0)))}else if(c&&W(c)&&c.is(u)&&c.tableKey===o.getKey()){let p=wa(t._window);if(p&&p.anchorNode&&p.focusNode){let g=J(p.focusNode),h=g&&!o.is(Lo(g)),C=J(p.anchorNode),N=C&&o.is(Lo(C));if(h&&N&&p.rangeCount>0){let L=Jl(p,t);L&&(L.anchor.set(o.getKey(),c.isBackward()?o.getChildrenSize():0,"element"),p.removeAllRanges(),Y(L))}}}return c&&!c.is(u)&&(W(c)||W(u))&&i.tableSelection&&!i.tableSelection.is(u)?(W(c)&&c.tableKey===i.tableNodeKey?i.updateTableTableSelection(c):!W(c)&&W(u)&&u.tableKey===i.tableNodeKey&&i.updateTableTableSelection(null),!1):(i.hasHijackedSelectionStyles&&!o.isSelected()?vx(t,i):!i.hasHijackedSelectionStyles&&o.isSelected()&&Rf(t,i),!1)},Me)),i.listenersToRemove.add(t.registerCommand(Pt,()=>{let c=T();if(!_(c)||!c.isCollapsed()||!Mo(c,o))return!1;let u=kf(t,c,o);return u?(If(u,o),!0):!1},Me)),i}function Mx(o,e){o[Sx]=e}function Da(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 ln(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 d=n,f={elem:d,hasBackgroundColor:d.style.backgroundColor!=="",highlighted:!1,x:r,y:i};n._cell=f;let m=e[i];m===void 0&&(m=e[i]=[]),m[r]=f}else{let d=n.firstChild;if(d!=null){n=d;continue}}let l=n.nextSibling;if(l!=null){r++,n=l;continue}let a=n.parentNode;if(a!=null){let d=a.nextSibling;if(d==null)break;i++,r=0,n=d}}return t.columns=r+1,t.rows=i+1,t}function Xr(o,e,t){let n=new Set(t?t.getNodes():[]);Ra(e,(r,i)=>{let s=r.elem;n.has(i)?(r.highlighted=!0,Pf(o,r)):(r.highlighted=!1,Ff(o,r),s.getAttribute("style")||s.removeAttribute("style"))})}function Ra(o,e){let{domRows:t}=o;for(let n=0;n<t.length;n++){let r=t[n];if(r)for(let i=0;i<r.length;i++){let s=r[i];if(!s)continue;let l=J(s.elem);l!==null&&e(s,l,{x:i,y:n})}}}function Rf(o,e){e.disableHighlightStyle(),Ra(e.table,t=>{t.highlighted=!0,Pf(o,t)})}function vx(o,e){e.enableHighlightStyle(),Ra(e.table,t=>{let n=t.elem;t.highlighted=!1,Ff(o,t),n.getAttribute("style")||n.removeAttribute("style")})}var $f=(o,e,t,n,r)=>{let i=r==="forward";switch(r){case"backward":case"forward":return t!==(i?o.table.columns-1:0)?ms(e.getCellNodeFromCordsOrThrow(t+(i?1:-1),n,o.table),i):n!==(i?o.table.rows-1:0)?ms(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?ms(e.getCellNodeFromCordsOrThrow(t,n-1,o.table),!1):e.selectPrevious(),!0;case"down":return n!==o.table.rows-1?ms(e.getCellNodeFromCordsOrThrow(t,n+1,o.table),!0):e.selectNext(),!0;default:return!1}},wx=(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 Mo(o,e){if(_(o)||W(o)){let t=e.isParentOf(o.anchor.getNode()),n=e.isParentOf(o.focus.getNode());return t&&n}return!1}function ms(o,e){e?o.selectStart():o.selectEnd()}var Oa="172,206,247";function Pf(o,e){let t=e.elem,n=J(t);E(I(n),"Expected to find LexicalNode from Table Cell DOMNode"),n.getBackgroundColor()===null?t.style.setProperty("background-color",`rgb(${Oa})`):t.style.setProperty("background-image",`linear-gradient(to right, rgba(${Oa},0.85), rgba(${Oa},0.85))`),t.style.setProperty("caret-color","transparent")}function Ff(o,e){let t=e.elem,n=J(t);E(I(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 ps(o){let e=K(o,I);return I(e)?e:null}function Lo(o){let e=K(o,Q);return Q(e)?e:null}function Gr(o,e,t,n,r){if((t==="up"||t==="down")&&Ox(o))return!1;let i=T();if(!Mo(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 d=K(a,m=>x(m)&&!m.isInline());if(!d)return!1;let f=d.getPreviousSibling();return!f||!Q(f)?!1:(an(e),f.selectEnd(),!0)}else if(e.shiftKey&&(t==="up"||t==="down")){let s=i.focus.getNode();if(pe(s)){let l=i.getNodes()[0];if(l){let a=K(l,I);if(a&&n.isParentOf(a)){let d=n.getFirstDescendant(),f=n.getLastDescendant();if(!d||!f)return!1;let[m]=we(d),[c]=we(f),u=n.getCordsFromCellNode(m,r.table),p=n.getCordsFromCellNode(c,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=K(s,d=>x(d)&&!d.isInline());if(!l)return!1;let a=t==="down"?l.getNextSibling():l.getPreviousSibling();if(Q(a)&&r.tableNodeKey===a.getKey()){let d=a.getFirstDescendant(),f=a.getLastDescendant();if(!d||!f)return!1;let[m]=we(d),[c]=we(f),u=i.clone();return u.focus.set((t==="up"?m:c).getKey(),t==="up"?0:c.getChildrenSize(),"element"),Y(u),!0}}}}return!1}if(_(i)&&i.isCollapsed()){let{anchor:s,focus:l}=i,a=K(s.getNode(),I),d=K(l.getNode(),I);if(!I(a)||!a.is(d))return!1;let f=Lo(a);if(f!==n&&f!=null){let N=o.getElementByKey(f.getKey());if(N!=null)return r.table=ln(N),Gr(o,e,t,f,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&&F(S[0])?!1:Dx(N,L,M,t)?Ix(e,M,n,t):!1}let m=o.getElementByKey(a.__key),c=o.getElementByKey(s.key);if(c==null||m==null)return!1;let u;if(s.type==="element")u=c.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){an(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 $f(r,n,N.x,N.y,t);return!0}}else if(W(i)){let{anchor:s,focus:l}=i,a=K(s.getNode(),I),d=K(l.getNode(),I),[f]=i.getNodes(),m=o.getElementByKey(f.getKey());if(!I(a)||!I(d)||!Q(f)||m==null)return!1;r.updateTableTableSelection(i);let c=ln(m),u=n.getCordsFromCellNode(a,c),p=n.getDOMCellFromCordsOrThrow(u.x,u.y,c);if(r.setAnchorCellForSelection(p),an(e),e.shiftKey){let g=n.getCordsFromCellNode(d,c);return wx(r,f,g.x,g.y,t)}else d.selectEnd();return!0}return!1}function an(o){o.preventDefault(),o.stopImmediatePropagation(),o.stopPropagation()}function Ox(o){let e=o.getRootElement();return e?e.hasAttribute("aria-controls")&&e.getAttribute("aria-controls")==="typeahead-menu":!1}function Dx(o,e,t,n){return Ax(o,t,n)||Rx(o,e,t,n)}function Ax(o,e,t){return o==="element"&&(t==="backward"?e.getPreviousSibling()===null:e.getNextSibling()===null)}function Rx(o,e,t,n){let r=K(t,s=>x(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 Ix(o,e,t,n){let r=K(e,I);if(!I(r))return!1;let[i,s]=Ve(t,r,r);if(!kx(i,s,n))return!1;let l=$x(e,n,t);return!l||Q(l)?!1:(an(o),n==="backward"?l.selectEnd():l.selectStart(),!0)}function kx(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 $x(o,e,t){let n=K(o,i=>x(i)&&!i.isInline());if(!n)return;let r=e==="backward"?n.getPreviousSibling():n.getNextSibling();return r&&Q(r)?r:e==="backward"?t.getPreviousSibling():t.getNextSibling()}function If(o,e,t){let n=P();o==="first"?e.insertBefore(n):e.insertAfter(n),n.append(...t||[]),n.selectEnd()}function kf(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=K(e.anchor.getNode(),h=>I(h));if(!s)return;let l=K(s,h=>Q(h));if(!Q(l)||!l.is(t))return;let[a,d]=Ve(t,s,s),f=a[0][0],m=a[a.length-1][a[0].length-1],{startRow:c,startColumn:u}=d,p=c===f.startRow&&u===f.startColumn,g=c===m.startRow&&u===m.startColumn;return p?"first":g?"last":void 0}var eo=class o extends z{static getType(){return"table"}static clone(e){return new o(e.__key)}static importDOM(){return{table:e=>({conversion:Px,priority:1})}}static importJSON(e){return Vr()}constructor(e){super(e)}exportJSON(){return{...super.exportJSON(),type:"table",version:1}}createDOM(e,t){let n=document.createElement("table");return Te(n,e.theme.table),n}updateDOM(){return!1}exportDOM(e){return{...super.exportDOM(e),after:t=>{if(!t)return;let n=t.cloneNode(),r=document.createElement("tbody");if(Ee(t))for(let i of Array.from(t.children))i.nodeName==="TR"?r.append(i):n.append(i);return n.append(r),n}}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(e,t){let{rows:n,domRows:r}=t;for(let i=0;i<n;i++){let s=r[i];if(s==null)continue;let l=s.findIndex(a=>{if(!a)return;let{elem:d}=a;return J(d)===e});if(l!==-1)return{x:l,y:i}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,t,n){let{domRows:r}=n,i=r[t];if(i==null)return null;let s=e<i.length?e:i.length-1,l=i[s];return l??null}getDOMCellFromCordsOrThrow(e,t,n){let r=this.getDOMCellFromCords(e,t,n);if(!r)throw new Error("Cell not found at cords.");return r}getCellNodeFromCords(e,t,n){let r=this.getDOMCellFromCords(e,t,n);if(r==null)return null;let i=J(r.elem);return I(i)?i:null}getCellNodeFromCordsOrThrow(e,t,n){let r=this.getCellNodeFromCords(e,t,n);if(!r)throw new Error("Node at cords not TableCellNode.");return r}canSelectBefore(){return!0}canIndent(){return!1}};function Px(o){return{node:Vr()}}function Vr(){return re(new eo)}function Q(o){return o instanceof eo}var vo=class o extends Et{constructor(){super(...arguments);this.__styles=new Map;this.__alignment=""}static getType(){return"custom-table-cell"}static clone(t){let n=new o(t.__headerState,t.__colSpan,t.__width,t.__key);return n.__rowSpan=t.__rowSpan,n.__styles=new Map(t.__styles),n.__alignment=t.__alignment,n}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"?oe.ROW:oe.NO_STATUS,i=this.getWritable();i.__headerState=r}createDOM(t){let n=super.createDOM(t);for(let[r,i]of this.__styles.entries())n.style.setProperty(r,i);return this.__alignment&&n.classList.add("align-"+this.__alignment),n}updateDOM(t){return super.updateDOM(t)||this.__styles!==t.__styles||this.__alignment!==t.__alignment}static importDOM(){return{td:t=>({conversion:Bf,priority:0}),th:t=>({conversion:Bf,priority:0})}}exportDOM(t){return{element:this.createDOM(t._config)}}static importJSON(t){let n=gs(t.headerState,t.colSpan,t.width);return n.setStyles(new Map(Object.entries(t.styles))),n.setAlignment(t.alignment),n}exportJSON(){return{...super.exportJSON(),type:"custom-table-cell",styles:Object.fromEntries(this.__styles),alignment:this.__alignment}}};function Bf(o){let e=Fx(o);return o instanceof HTMLElement&&e.node instanceof vo&&(e.node.setStyles(Xn(o)),e.node.setAlignment(Hr(o))),e}function Fx(o){let e=o,t=o.nodeName.toLowerCase(),n;/^(\d+(?:\.\d+)?)px$/.test(e.style.width)&&(n=parseFloat(e.style.width));let i=Ye(t==="th"?oe.ROW:oe.NO_STATUS,e.colSpan,n);i.__rowSpan=e.rowSpan;let s=e.style,l=s.textDecoration.split(" "),a=s.fontWeight==="700"||s.fontWeight==="bold",d=l.includes("line-through"),f=s.fontStyle==="italic",m=l.includes("underline");return{after:c=>(c.length===0&&c.push(P()),c),forChild:(c,u)=>{if(I(u)&&!x(c)){let p=P();return Ce(c)&&c.getTextContent()===`
`?null:(y(c)&&(a&&c.toggleFormat("bold"),d&&c.toggleFormat("strikethrough"),f&&c.toggleFormat("italic"),m&&c.toggleFormat("underline")),p.append(c),p)}return c},node:i}}function gs(o=oe.NO_STATUS,e=1,t){return new vo(o,e,t)}function le(o){return o instanceof vo}var kt=class{constructor(e){this.rowCount=0;this.columnCount=0;this.cells=[];this.buildCellMap(e)}buildCellMap(e){let t=[],n=(a,d,f)=>{typeof t[d]>"u"&&(t[d]=[]),t[d][a]=f},r=(a,d)=>!!(t[d]&&t[d][a]),i=e.getChildren().filter(a=>se(a));for(let a=0;a<i.length;a++){let f=i[a].getChildren().filter(c=>le(c)),m=0;for(let c=0;c<f.length;c++){let u=f[c],p=u.getColSpan()||1,g=u.getRowSpan()||1;for(let h=m;h<m+p;h++)for(let C=a;C<a+g;C++){for(;r(h,C);)m+=1,h+=1;n(h,C,u)}m+=p}}this.rowCount=t.length,this.columnCount=Math.max(...t.map(a=>a.length));let s=[],l=t[0][0];for(let a=0;a<this.rowCount;a++)for(let d=0;d<this.columnCount;d++)!t[a]||!t[a][d]?s.push(l):(s.push(t[a][d]),l=t[a][d]);this.cells=s}getCellAtPosition(e,t){let n=t*this.columnCount+e;if(n>=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;r<this.rowCount;r++)for(let i=0;i<this.columnCount;i++){let s=r*this.columnCount+i;this.cells[s].getKey()===n&&(t===null?t={fromX:i,toX:i,fromY:r,toY:r}:(t.fromX=Math.min(t.fromX,i),t.toX=Math.max(t.toX,i),t.fromY=Math.min(t.fromY,r),t.toY=Math.max(t.toY,r)))}return t}};var dn=class o extends Tt{constructor(t){super(0,t);this.__styles=new Map}static getType(){return"custom-table-row"}static clone(t){let n=new o(t.__key);return n.__styles=new Map(t.__styles),n}getStyles(){let t=this.getLatest();return new Map(t.__styles)}setStyles(t){let n=this.getWritable();n.__styles=new Map(t)}createDOM(t){let n=super.createDOM(t);for(let[r,i]of this.__styles.entries())n.style.setProperty(r,i);return n}updateDOM(t){return super.updateDOM(t)||this.__styles!==t.__styles}static importDOM(){return{tr:t=>({conversion:Bx,priority:0})}}static importJSON(t){let n=Hf();return n.setStyles(new Map(Object.entries(t.styles))),n}exportJSON(){return{...super.exportJSON(),height:0,type:"custom-table-row",styles:Object.fromEntries(this.__styles)}}};function Bx(o){let e=Hf();return o instanceof HTMLElement&&e.setStyles(Xn(o)),{node:e}}function Hf(){return new dn}function cn(o){return o instanceof dn}function Ia(o){return So(o,it)}function Uf(o){let e=zf(o),t=o.querySelector("colgroup"),n=[];return t&&(t.childElementCount===e?.childElementCount||!e)&&(n=Kf(t)),n.filter(Boolean).length===0&&e&&(n=Kf(e)),n}function zf(o){let e=o.querySelectorAll("tr"),t=0,n=null;for(let r of e)r.childElementCount>t&&(n=r,t=r.childElementCount);return n}function Kf(o){return[...o.children].map(e=>Hx(e))}function Hx(o){let e=o.style.width||o.getAttribute("width");return e&&!Number.isNaN(Number(e))&&(e=e+"px"),e||""}function ka(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.length<r)&&(i=Array(r).fill("")),e+1>i.length&&console.error(`Attempted to set table column width for column [${e}] but only ${i.length} columns found`),i[e]=ht(t),o.setColWidths(i)}function Wf(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=zf(r);if(i&&i.children.length>t)return i.children[t].clientWidth}return 0}function qf(o){let e=o.getParent();if(!se(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 Yf(o,e){let t=Ia(o),n=qf(o);t&&n>=0&&ka(t,n,e)}function Vf(o,e){let t=Ia(e),n=qf(e);if(!t)return"";let r=t.getColWidths();return r.length>n?r[n]:""}function un(o){if(W(o))return o.getNodes().filter(n=>le(n));let e=j(o,le);return e?[e]:[]}function Xf(o){let e=o.getShape(),t=un(o);if(t.length===0)return;let n=Ia(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 d=a[0],f=Math.abs(e.fromX-s)+1,m=Math.abs(e.fromY-l)+1;for(let c=1;c<a.length;c++){let u=a[c];d.append(...u.getChildren()),u.remove()}d.setColSpan(f),d.setRowSpan(m)}function to(o){let e=un(o),t={};for(let n of e){let r=n.getParent();cn(r)&&(t[r.getKey()]=r)}return Object.values(t)}function Ct(o){let e=un(o);if(e.length===0)return null;let t=So(e[0],it);return it(t)?t:null}function Zf(o){o.setColWidths([]);for(let e of o.getChildren()){if(!cn(e))continue;let t=e.getStyles();t.delete("height"),t.delete("width"),e.setStyles(t);let n=e.getChildren().filter(r=>le(r));for(let r of n){let i=r.getStyles();i.delete("height"),i.delete("width"),r.setStyles(i),r.clearWidth()}}}function Gf(o){o.setColWidths([]),o.setStyles(new Map);for(let e of o.getChildren()){if(!cn(e))continue;e.setStyles(new Map),e.setFormat("");let t=e.getChildren().filter(n=>le(n));for(let n of t)n.setStyles(new Map),n.clearWidth(),n.setFormat("")}}function $a(o,e){e:for(let t of o.getChildren()){if(!cn(t))continue;let n=t.getChildren();for(let r of n){if(!le(r))return;if(e(r)===!1)break e}}}function Jf(o){let e=null;return $a(o,t=>{let n=t.getStyles().get("padding")||"";if(e===null&&(e=n),n!==e)return e=null,!1}),e||""}var _t=class o extends eo{constructor(){super(...arguments);this.__id="";this.__colWidths=[];this.__styles=new Map;this.__alignment="";this.__inset=0}static getType(){return"custom-table"}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}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)}static clone(t){let n=new o(t.__key);return n.__id=t.__id,n.__colWidths=t.__colWidths,n.__styles=new Map(t.__styles),n.__alignment=t.__alignment,n.__inset=t.__inset,n}createDOM(t){let n=super.createDOM(t);tt(n,this);let r=this.getColWidths();if(r.length>0){let i=b("colgroup");for(let s of r){let l=b("col");s&&(l.style.width=s),i.append(l)}n.append(i)}for(let[i,s]of this.__styles.entries())n.style.setProperty(i,s);return n}updateDOM(){return!0}exportJSON(){return{...super.exportJSON(),type:"custom-table",version:1,id:this.__id,colWidths:this.__colWidths,styles:Object.fromEntries(this.__styles),alignment:this.__alignment,inset:this.__inset}}static importJSON(t){let n=jf();return ot(t,n),n.setColWidths(t.colWidths),n.setStyles(new Map(Object.entries(t.styles))),n}static importDOM(){return{table(t){return{conversion:n=>{let r=jf();et(n,r);let i=Uf(n);return r.setColWidths(i),r.setStyles(Xn(n)),{node:r}},priority:1}}}}};function jf(){return new _t}function it(o){return o instanceof _t}var er=class o extends z{constructor(){super(...arguments);this.__id=""}static getType(){return"horizontal-rule"}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}static clone(t){let n=new o(t.__key);return n.__id=t.__id,n}createDOM(t,n){let r=document.createElement("hr");return this.__id&&r.setAttribute("id",this.__id),r}updateDOM(t,n){return t.__id!==this.__id}static importDOM(){return{hr(t){return{conversion:n=>{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=Pa();return n.setId(t.id),n}};function Pa(){return new er}function Qf(o){return o instanceof er}var em=o=>(o.split(" ").filter(t=>t.startsWith("language-"))[0]||"").replace("language-",""),fn=class o extends At{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=em(n.className)||r&&em(r.className)||"",s=r?(r.textContent||"").trim():(n.textContent||"").trim(),l=hs(i,s);return n.id&&l.setId(n.id),{node:l}},priority:3}}}}exportJSON(){return{type:"code-block",version:1,id:this.__id,language:this.__language,code:this.__code}}static importJSON(t){let n=hs(t.language,t.code);return n.setId(t.id||""),n}};function hs(o="",e=""){return new fn(o,e)}function Ns(o){return o instanceof fn}function Jr(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 wo=class o extends At{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=tr(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=tr(t.drawingId,t.drawingUrl);return n.setId(t.id||""),n}};function tr(o="",e=""){return new wo(o,e)}var Kx=["width","height","style","title","name","src","allow","allowfullscreen","loading","sandbox","type","data","controls","autoplay","controlslist","loop","muted","playsinline","poster","preload"];function Ux(o){let e={};for(let t of Object.keys(o))Kx.includes(t)&&(e[t]=o[t]);return e}function tm(o,e){let t=om(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 et(e,t),t}var mn=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=Ux(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 Br(t.__attributes.height||"0")}setWidth(t){let n=Object.assign({},this.getAttributes(),{width:t});this.setAttributes(n)}getWidth(){let t=this.getLatest();return Br(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 tt(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(()=>$e(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&&af(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:tm(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=om(t.tag);return ot(t,n),n}};function om(o){return new mn(o)}function nm(o){let n=new DOMParser().parseFromString(`<body>${o}</body>`,"text/html").body.children[0];if(!(n instanceof HTMLElement))return null;let r=n.tagName.toLowerCase();return["embed","iframe","video","audio","object"].includes(r)?tm(r,n):null}var zx=["mp4","mpeg","m4v","m4p","mov"],Wx=["3gp","aac","flac","mp3","m4a","ogg","wav","webm"],qx=["html","htm","php","asp","aspx",""];function rm(o){let e="iframe",n=(o.split("?")[0].split("/").pop()||"").split("."),r=(n.length>1?n[n.length-1]:"").toLowerCase();return zx.includes(r)?e="video":Wx.includes(r)?e="audio":r&&!qx.includes(r)&&(e="embed"),new mn(e)}function oo(o){return o instanceof mn}var pn=class o extends Qt{constructor(){super(...arguments);this.__id=""}static getType(){return"custom-list"}setId(t){let n=this.getWritable();n.__id=t}getId(){return this.getLatest().__id}static clone(t){let n=new o(t.__listType,t.__start,t.__key);return n.__id=t.__id,n.__dir=t.__dir,n}createDOM(t){let n=super.createDOM(t);return this.__id&&n.setAttribute("id",this.__id),this.__dir&&n.setAttribute("dir",this.__dir),n}updateDOM(t,n,r){return super.updateDOM(t,n,r)||t.__dir!==this.__dir}exportJSON(){return{...super.exportJSON(),type:"custom-list",version:1,id:this.__id}}static importJSON(t){let n=Fa(t.listType);return n.setId(t.id),n.setDirection(t.direction),n}static importDOM(){let t=super.importDOM().ol().conversion,n=r=>{let i=t(r);return r.id&&i?.node&&i.node.setId(r.id),r.dir&&i?.node&&i.node.setDirection(Kr(r)),i&&(i.after=Yx),i};return{ol:()=>({conversion:n,priority:0}),ul:()=>({conversion:n,priority:0})}}};function Yx(o){let e=[];for(let t of o)te(t)?e.push(t):e.push(Vx(t));return e}function Vx(o){return xs().append(o)}function Fa(o){return new pn(o,1)}function Oo(o){return o instanceof pn}function im(o,e){let t=!H(e.getFirstChild());o.classList.toggle("task-list-item",t),e.__checked?o.setAttribute("checked","checked"):o.removeAttribute("checked")}var gn=class o extends xt{static getType(){return"custom-list-item"}static clone(e){return new o(e.__value,e.__checked,e.__key)}createDOM(e){let t=document.createElement("li"),n=this.getParent();return H(n)&&n.getListType()==="check"&&im(t,this),t.value=this.__value,sm(this)&&(t.style.listStyle="none"),t}updateDOM(e,t,n){let r=this.getParent();return H(r)&&r.getListType()==="check"&&im(t,this),t.style.listStyle=sm(this)?"none":"",t.value=this.__value,!1}exportDOM(e){let t=this.createDOM(e._config);if(t.style.textAlign=this.getFormatType(),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(),type:"custom-list-item"}}};function sm(o){let e=o.getChildren(),t=!1,n=!1;for(let r of e)Oo(r)?n=!0:r.getTextContent().trim().length>0&&(t=!0);return n&&!t}function Do(o){return o instanceof gn}function xs(){return new gn}var hn=class o extends _o{constructor(){super(...arguments);this.__id="";this.__alignment="";this.__inset=0}static getType(){return"custom-heading"}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}static clone(t){let n=new o(t.__tag,t.__key);return n.__alignment=t.__alignment,n.__inset=t.__inset,n}createDOM(t){let n=super.createDOM(t);return tt(n,this),n}updateDOM(t,n){return super.updateDOM(t,n)||yo(t,this)}exportJSON(){return{...super.exportJSON(),type:"custom-heading",version:1,id:this.__id,alignment:this.__alignment,inset:this.__inset}}static importJSON(t){let n=Es(t.tag);return ot(t,n),n}static importDOM(){return{h1:t=>({conversion:or,priority:0}),h2:t=>({conversion:or,priority:0}),h3:t=>({conversion:or,priority:0}),h4:t=>({conversion:or,priority:0}),h5:t=>({conversion:or,priority:0}),h6:t=>({conversion:or,priority:0})}}};function or(o){let e=o.nodeName.toLowerCase(),t=null;return(e==="h1"||e==="h2"||e==="h3"||e==="h4"||e==="h5"||e==="h6")&&(t=Es(e),et(o,t)),{node:t}}function Es(o){return new hn(o)}function lm(o){return o instanceof hn}var nr=class o extends Co{constructor(){super(...arguments);this.__id="";this.__alignment="";this.__inset=0}static getType(){return"custom-quote"}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}static clone(t){let n=new o(t.__key);return n.__id=t.__id,n.__alignment=t.__alignment,n.__inset=t.__inset,n}createDOM(t){let n=super.createDOM(t);return tt(n,this),n}updateDOM(t){return yo(t,this)}exportJSON(){return{...super.exportJSON(),type:"custom-quote",version:1,id:this.__id,alignment:this.__alignment,inset:this.__inset}}static importJSON(t){let n=Ts();return ot(t,n),n}static importDOM(){return{blockquote:t=>({conversion:Xx,priority:0})}}};function Xx(o){let e=Ts();return et(o,e),{node:e}}function Ts(){return new nr}function am(){return[en,hn,nr,pn,gn,_t,dn,vo,nn,er,Qn,qr,fn,wo,mn,tn,Gn,{replace:We,with:o=>new tn},{replace:_o,with:o=>new hn(o.__tag)},{replace:Co,with:o=>new nr},{replace:Qt,with:o=>new pn(o.getListType(),o.getStart())},{replace:xt,with:o=>new gn(o.__value,o.__checked)},{replace:eo,with(o){return new _t}},{replace:Tt,with(o){return new dn}},{replace:Et,with:o=>{let e=new vo(o.__headerState,o.__colSpan,o.__width);return e.__rowSpan=o.__rowSpan,e}}]}function dm(o){let e=[nn,fn,wo],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 cm(o){return"build"in o}var Xe=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}trans(e){return this.getContext().translate(e)}updateState(e){}},ne=class extends Xe{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)}},Cs=class extends ne{constructor(e,t){super(t),this.className=e}buildDOM(){return b("div",{class:this.className},this.getChildren().map(e=>e.getDOMElement()))}};var v=class extends Xe{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 _s(o){let{menu:e,toggle:t,onClose:n,onOpen:r,showOnHover:i}=o,s=null,l=()=>{e.hidden=!0,s&&window.removeEventListener("click",s),n&&n()},a=()=>{e.hidden=!1,s=f=>{!t.contains(f.target)&&!e.contains(f.target)&&l()},window.addEventListener("click",s),r&&r()},d=f=>{e.hasAttribute("hidden")?a():l()};t.addEventListener("click",d),i&&t.addEventListener("mouseenter",d),e.parentElement?.addEventListener("mouseleave",l)}var ys=class extends ne{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 _s({toggle:n,menu:t}),r}updateState(e){super.updateState(e);for(let t of this.children){if(t instanceof v&&t.isActive()){this.updateToggleLabel(t.getLabel());return}if(t instanceof ne){for(let n of t.getChildren())if(n instanceof v&&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 Ze=class extends v{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 um='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/><path d="M0 0h24v24H0z" fill="none"/></svg>';var bs=class extends v{buildDOM(){let e=super.buildDOM(),t=b("div",{class:"editor-menu-button-icon"});return t.innerHTML=um,e.append(t),e}};var Gx={showOnHover:!1,direction:"horizontal",button:{label:"Menu"}},Oe=class extends ne{constructor(t,n){super(n);this.open=!1;if(this.childItems=n,this.options=Object.assign({},Gx,t),t.button instanceof v)this.button=t.button;else{let r=t.button.format==="long"?bs:v;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 _s({toggle:t,menu:r,showOnHover:this.options.showOnHover,onOpen:()=>{this.open=!0,this.getContext().manager.triggerStateUpdateForElement(this.button)},onClose:()=>{this.open=!1,this.getContext().manager.triggerStateUpdateForElement(this.button)}}),i}};var fm='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M800-436q0 36-8 69t-22 63l-62-60q6-17 9-34.5t3-37.5q0-47-17.5-89T650-600L480-768l-88 86-56-56 144-142 226 222q44 42 69 99.5T800-436Zm-8 380L668-180q-41 29-88 44.5T480-120q-133 0-226.5-92.5T160-436q0-51 16-98t48-90L56-792l56-56 736 736-56 56ZM480-200q36 0 68.5-10t61.5-28L280-566q-21 32-30.5 64t-9.5 66q0 98 70 167t170 69Zm-37-204Zm110-116Z"/></svg>';var jx=["#000000","#ffffff","#BFEDD2","#FBEEB8","#F8CAC6","#ECCAFA","#C2E0F4","#2DC26B","#F1C40F","#E03E2D","#B96AD9","#3598DB","#169179","#E67E23","#BA372A","#843FA1","#236FA1","#ECF0F1","#CED4D9","#95A5A6","#7E8C8D","#34495E"],jr=class extends Xe{constructor(e){super(),this.styleProperty=e}buildDOM(){let e=jx.map(i=>b("div",{class:"editor-color-select-option",style:`background-color: ${i}`,"data-color":i,"aria-label":i})),t=b("div",{class:"editor-color-select-option","data-color":"",title:"Clear color"},[]);t.innerHTML=fm,e.push(t);let n=[];for(let i=0;i<e.length;i+=5){let s=e.slice(i,i+5);n.push(b("div",{class:"editor-color-select-row"},s))}let r=b("div",{class:"editor-color-select"},n);return r.addEventListener("click",this.onClick.bind(this)),r}onClick(e){let t=e.target.closest("[data-color]");if(!t)return;let n=t.dataset.color;this.getContext().editor.update(()=>{let r=T();r&&sa(r,{[this.styleProperty]:n||null})})}};var Ss=class extends Xe{buildDOM(){let t=[],n=[];for(let s=1;s<11;s++){let l=[];for(let a=1;a<11;a++){let d=b("div",{class:"editor-table-creator-cell","data-rows":String(s),"data-columns":String(a)});l.push(d),n.push(d)}t.push(b("div",{class:"editor-table-creator-row"},l))}let r=b("div",{class:"editor-table-creator-display"},["0 x 0"]),i=b("div",{class:"editor-table-creator-grid"},t);return i.addEventListener("mousemove",s=>{let l=s.target.closest(".editor-table-creator-cell");if(l){let a=Number(l.dataset.rows||0),d=Number(l.dataset.columns||0);this.updateGridSelection(a,d,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=ba(t,n,!1);s.setColWidths(i),on(s)})}};var Qr=class extends v{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=la(e.selection,this.style);this.getColorBar().setAttribute("fill",t)}}};var mm='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M240-400q-33 0-56.5-23.5T160-480q0-33 23.5-56.5T240-560q33 0 56.5 23.5T320-480q0 33-23.5 56.5T240-400Zm240 0q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm240 0q-33 0-56.5-23.5T640-480q0-33 23.5-56.5T720-560q33 0 56.5 23.5T800-480q0 33-23.5 56.5T720-400Z"/></svg>';var st=class extends ne{constructor(e,t){super(t),this.size=e,this.content=t,this.overflowButton=new Oe({button:{label:"More",icon:mm}},[]),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 Ba='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200q-33 0-56.5-23.5T120-200Zm80-400h560v-160H200v160Zm213 200h134v-120H413v120Zm0 200h134v-120H413v120ZM200-400h133v-120H200v120Zm427 0h133v-120H627v120ZM200-200h133v-120H200v120Zm427 0h133v-120H627v120Z"/></svg>';var pm='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14c0 1.1-.9 2-2 2zm0-2h14V5H5v14z"/><path d="m13.711 15.423-1.71-1.712-1.712 1.712c-1.14 1.14-2.852-.57-1.71-1.712l1.71-1.71-1.71-1.712c-1.143-1.142.568-2.853 1.71-1.71L12 10.288l1.711-1.71c1.141-1.142 2.852.57 1.712 1.71L13.71 12l1.626 1.626c1.345 1.345-.76 2.663-1.626 1.797z" style="fill-rule:nonzero;stroke-width:1.20992"/></svg>';var gm='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M21 19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14c1.1 0 2 .9 2 2zm-2 0V5h-4v2.2h-2V5h-2v2.2H9V5H5v14h4v-2.1h2V19h2v-2.1h2V19Z"/><path d="M14.829 10.585 13.415 12l1.414 1.414c.943.943-.472 2.357-1.414 1.414L12 13.414l-1.414 1.414c-.944.944-2.358-.47-1.414-1.414L10.586 12l-1.414-1.415c-.943-.942.471-2.357 1.414-1.414L12 10.585l1.344-1.343c1.111-1.112 2.2.627 1.485 1.343z" style="fill-rule:nonzero"/></svg>';var hm='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14c0 1.1-.9 2-2 2zm0-2h14v-4h-2.2v-2H19v-2h-2.2V9H19V5H5v4h2.1v2H5v2h2.1v2H5Z"/><path d="M13.415 14.829 12 13.415l-1.414 1.414c-.943.943-2.357-.472-1.414-1.414L10.586 12l-1.414-1.414c-.944-.944.47-2.358 1.414-1.414L12 10.586l1.415-1.414c.942-.943 2.357.471 1.414 1.414L13.415 12l1.343 1.344c1.112 1.111-.627 2.2-1.343 1.485z" style="fill-rule:nonzero"/></svg>';var Nm='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M16 5h-5v14h5c1.235 0 1.234 2 0 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11c1.229 0 1.236 2 0 2zm-7 6V5H5v6zm0 8v-6H5v6zm11.076-6h-2v2c0 1.333-2 1.333-2 0v-2h-2c-1.335 0-1.335-2 0-2h2V9c0-1.333 2-1.333 2 0v2h1.9c1.572 0 1.113 2 .1 2z"/></svg>';var xm='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M8 19h5V5H8C6.764 5 6.766 3 8 3h11a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H8c-1.229 0-1.236-2 0-2zm7-6v6h4v-6zm0-8v6h4V5ZM3.924 11h2V9c0-1.333 2-1.333 2 0v2h2c1.335 0 1.335 2 0 2h-2v2c0 1.333-2 1.333-2 0v-2h-1.9c-1.572 0-1.113-2-.1-2z"/></svg>';var Em='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5 8v5h14V8c0-1.235 2-1.234 2 0v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8C3 6.77 5 6.764 5 8zm6 7H5v4h6zm8 0h-6v4h6zM13 3.924v2h2c1.333 0 1.333 2 0 2h-2v2c0 1.335-2 1.335-2 0v-2H9c-1.333 0-1.333-2 0-2h2v-1.9c0-1.572 2-1.113 2-.1z"/></svg>';var Tm='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 16v-5H5v5c0 1.235-2 1.234-2 0V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v11c0 1.229-2 1.236-2 0zm-6-7h6V5h-6zM5 9h6V5H5Zm6 11.076v-2H9c-1.333 0-1.333-2 0-2h2v-2c0-1.335 2-1.335 2 0v2h2c1.333 0 1.333 2 0 2h-2v1.9c0 1.572-2 1.113-2 .1z"/></svg>';function Cm(){let o=()=>((1+Math.random())*65536|0).toString(16).substring(1);return`${o()+o()}-${o()}-${o()}-${o()}-${o()}${o()}${o()}`}function _m(){return((1+Math.random())*65536|0).toString(16).substring(1)}var Ao=class extends Xe{constructor(e){super(),this.definition=e}setValue(e){let t=this.getDOMElement().querySelector("input,select,textarea");t.value=e}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"}):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])}},Ls=class extends ne{constructor(t){let n=t.fields.map(r=>cm(r)?r.build():new Ao(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 Ao&&i.getName()===t)return i;if(i instanceof ne){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}},Ha=class extends ne{constructor(e){let t=e.contents.map(n=>new Ao(n));super(t),this.definition=e,this.fields=t,this.id=Cm()}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()))}},Nn=class extends ne{constructor(t){let n=t.map(r=>new Ha(r));super(n);this.definitions=[];this.tabs=[];this.definitions=t,this.tabs=n}buildDOM(){let t=[],n=[],r=i=>{for(let s=0;s<t.length;s++)t[s].setAttribute("aria-selected",s===i?"true":"false");for(let s=0;s<n.length;s++)n[s].hidden=s!==i};for(let i of this.tabs){let s=b("button",{class:"editor-form-tab-control",type:"button",role:"tab",id:`editor-tab-${i.getId()}`,"aria-controls":`editor-tabpanel-${i.getId()}`},[i.getLabel()]);n.push(i.getDOMElement()),t.push(s),s.addEventListener("click",l=>{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 Ka={label:"Border style",name:"border_style",type:"select",valuesByLabel:{"Select...":"",Solid:"solid",Dotted:"dotted",Dashed:"dashed",Double:"double",Groove:"groove",Ridge:"ridge",Inset:"inset",Outset:"outset",None:"none",Hidden:"hidden"}},Ua={label:"Border color",name:"border_color",type:"text"},za={label:"Background color",name:"background_color",type:"text"},ym={label:"Alignment",name:"align",type:"select",valuesByLabel:{None:"",Left:"left",Center:"center",Right:"right"}};function bm(o,e){let t=o.getStyles(),n=e.manager.createModal("cell_properties");return n.show({width:Vf(e.editor,o),height:t.get("height")||"",type:o.getTag(),h_align:o.getFormatType(),v_align:t.get("vertical-align")||"",border_width:t.get("border-width")||"",border_style:t.get("border-style")||"",border_color:t.get("border-color")||"",background_color:t.get("background-color")||""}),n}var Sm={submitText:"Save",async action(o,e){return e.editor.update(()=>{let t=un(T());for(let n of t){let r=o.get("width")?.toString()||"";Yf(n,r),n.updateTag(o.get("type")?.toString()||""),n.setFormat(o.get("h_align")?.toString()||"");let i=n.getStyles();i.set("height",ht(o.get("height")?.toString()||"")),i.set("vertical-align",o.get("v_align")?.toString()||""),i.set("border-width",ht(o.get("border_width")?.toString()||"")),i.set("border-style",o.get("border_style")?.toString()||""),i.set("border-color",o.get("border_color")?.toString()||""),i.set("background-color",o.get("background_color")?.toString()||""),n.setStyles(i)}}),!0},fields:[{build(){let o=[{label:"Width",name:"width",type:"text"},{label:"Height",name:"height",type:"text"},{label:"Cell type",name:"type",type:"select",valuesByLabel:{Cell:"td","Header cell":"th"}},{...ym,label:"Horizontal align",name:"h_align"},{label:"Vertical align",name:"v_align",type:"select",valuesByLabel:{None:"",Top:"top",Middle:"middle",Bottom:"bottom"}}],e=[{label:"Border width",name:"border_width",type:"text"},Ka,Ua,za];return new Nn([{label:"General",contents:o},{label:"Advanced",contents:e}])}}]};function Lm(o,e){let t=o.getStyles(),n=e.manager.createModal("row_properties");return n.show({height:t.get("height")||"",border_style:t.get("border-style")||"",border_color:t.get("border-color")||"",background_color:t.get("background-color")||""}),n}var Mm={submitText:"Save",async action(o,e){return e.editor.update(()=>{let t=to(T());for(let n of t){let r=n.getStyles();r.set("height",ht(o.get("height")?.toString()||"")),r.set("border-style",o.get("border_style")?.toString()||""),r.set("border-color",o.get("border_color")?.toString()||""),r.set("background-color",o.get("background_color")?.toString()||""),n.setStyles(r)}}),!0},fields:[{label:"Height",name:"height",type:"text"},Ka,Ua,za]};function vm(o,e){let t=o.getStyles(),n=e.manager.createModal("table_properties");return n.show({width:t.get("width")||"",height:t.get("height")||"",cell_spacing:t.get("cell-spacing")||"",cell_padding:Jf(o),border_width:t.get("border-width")||"",border_style:t.get("border-style")||"",border_color:t.get("border-color")||"",background_color:t.get("background-color")||"",align:o.getFormatType()}),n}var wm={submitText:"Save",async action(o,e){return e.editor.update(()=>{let t=Ct(T());if(!t)return;let n=t.getStyles();n.set("width",ht(o.get("width")?.toString()||"")),n.set("height",ht(o.get("height")?.toString()||"")),n.set("cell-spacing",ht(o.get("cell_spacing")?.toString()||"")),n.set("border-width",ht(o.get("border_width")?.toString()||"")),n.set("border-style",o.get("border_style")?.toString()||""),n.set("border-color",o.get("border_color")?.toString()||""),n.set("background-color",o.get("background_color")?.toString()||""),t.setStyles(n),t.setFormat(o.get("align"));let r=o.get("cell_padding")?.toString()||"";if(r){let i=ht(r);$a(t,s=>{let l=s.getStyles();l.set("padding",i),s.setStyles(l)})}}),!0},fields:[{build(){let o=[{label:"Width",name:"width",type:"text"},{label:"Height",name:"height",type:"text"},{label:"Cell spacing",name:"cell_spacing",type:"text"},{label:"Cell padding",name:"cell_padding",type:"text"},{label:"Border width",name:"border_width",type:"text"},{label:"caption",name:"caption",type:"text"},ym],e=[Ka,Ua,za];return new Nn([{label:"General",contents:o},{label:"Advanced",contents:e}])}}]};function Om(o){let e=x(o)?o.getChildren():[];return{node:o.exportJSON(),children:e.map(t=>Om(t))}}function Dm(o,{node:e,children:t}){let n=o._nodes.get(e.type)?.klass.importJSON(e);if(!n)return null;let r=t.map(i=>Dm(o,i));for(let i of r)i&&x(n)&&n.append(i);return n}var ei=class{constructor(){this.store=[]}set(...e){this.store.splice(0,this.store.length);for(let t of e)this.store.push(Om(t))}get(e){return this.store.map(t=>Dm(e,t)).filter(t=>t!==null)}size(){return this.store.length}};var ti=new ei;function Wa(){return ti.size()===0}function Am(o){let e=null;for(let t of o){let n=t.getChildren().filter(i=>le(i)),r=0;for(let i of n)if(r+=i.getColSpan()||1,i.getRowSpan()>1)throw Error("Cannot copy rows with merged cells");if(e===null)e=r;else if(e!==r)throw Error("Cannot copy rows with inconsistent sizes")}}function Rm(o,e){let t=new kt(e).columnCount;for(let n of o){let r=n.getChildren().filter(s=>le(s)),i=0;for(let s of r)i+=s.getColSpan()||1;if(i>t)throw Error("Cannot paste rows that are wider than target table");for(;i<t;)n.append(gs()),i++}}function Im(){let o=to(T());Am(o),ti.set(...o);for(let e of o)e.remove()}function km(){let o=to(T());Am(o),ti.set(...o)}function $m(o){let e=T(),t=to(e),n=Ct(e),r=t[t.length-1];if(r&&n){let i=ti.get(o);Rm(i,n);for(let s of i)r.insertBefore(s)}}function Pm(o){let e=T(),t=to(e),n=Ct(e),r=t[t.length-1];if(r&&n){let i=ti.get(o).reverse();Rm(i,n);for(let s of i)r.insertAfter(s)}}var Ms=[];function Fm(o){let e=o.map(t=>{let n=new ei;return n.set(...t),n});Ms.splice(0,Ms.length,...e)}function qa(){return Ms.length===0}function Bm(o){if(W(o)){let i=o.getShape();return{from:i.fromX,to:i.toX}}let e=j(o,le),t=Ct(o);if(!le(e)||!t)return null;let r=new kt(t).getRangeForCell(e);return r?{from:r.fromX,to:r.toX}:null}function Hm(o,e){let t=new kt(e),n=[];for(let r=o.from;r<=o.to;r++){let i=t.getCellsInColumn(r);n.push(i)}return n}function Km(o){let e=null;for(let t of o){let n=0;for(let r of t)if(n+=r.getRowSpan()||1,r.getColSpan()>1)throw Error("Cannot copy columns with merged cells");if(e===null)e=n;else if(e!==n)throw Error("Cannot copy columns with inconsistent sizes")}}function Um(){let o=T(),e=Bm(o),t=Ct(o);if(!e||!t)return;let n=t.getColWidths(),r=Hm(e,t);Km(r),Fm(r);for(let s of r)for(let l of s)l.remove();let i=[...n].splice(e.from,e.to-e.from+1);t.setColWidths(i)}function zm(){let o=T(),e=Bm(o),t=Ct(o);if(!e||!t)return;let n=Hm(e,t);Km(n),Fm(n)}function aE(o,e){let t=new kt(e).rowCount;for(let n of o){let r=0;for(let i of n)r+=i.getRowSpan()||1;if(r>t)throw Error("Cannot paste columns that are taller than target table");for(;r<t;)n.push(gs()),r++}}function Wm(o,e){let t=T(),n=Ct(t),r=un(t),i=r[e?0:r.length-1];if(!n||!i)return;let s=Ms.map(u=>u.get(o));e||s.reverse(),aE(s,n);let l=new kt(n),a=l.getRangeForCell(i);if(!a)return;let d=e?a.fromX:a.toX,f=n.getColWidths();for(let u=0;u<l.rowCount;u++){let p=l.getCellAtPosition(d,u);for(let g of s){let h=g[u];e?p.insertBefore(h):p.insertAfter(h)}}let m=f[d],c=s.map(u=>m);f.splice(e?d:d+1,0,...c)}function qm(o){Wm(o,!0)}function Ym(o){Wm(o,!1)}var he=()=>!1,be=o=>!ae(o,le),Vm={label:"Table",icon:Ba},Ya={label:"Table properties",icon:Ba,action(o){o.editor.getEditorState().read(()=>{let e=Ct(T());it(e)&&vm(e,o)})},isActive:he,isDisabled:be},Xm={label:"Clear table formatting",format:"long",action(o){o.editor.update(()=>{let e=j(T(),le);if(!le(e))return;let t=So(e,Q);it(t)&&Gf(t)})},isActive:he,isDisabled:be},Zm={label:"Resize to contents",format:"long",action(o){o.editor.update(()=>{let e=j(T(),le);if(!le(e))return;let t=So(e,it);it(t)&&Zf(t)})},isActive:he,isDisabled:be},Va={label:"Delete table",icon:pm,action(o){o.editor.update(()=>{let e=j(T(),it);e&&e.remove()})},isActive(){return!1}},Gm={...Va,format:"long",isDisabled(o){return!ae(o,Q)}},Xa={label:"Insert row before",icon:Em,action(o){o.editor.update(()=>{as(!1)})},isActive:he,isDisabled:be},Za={label:"Insert row after",icon:Tm,action(o){o.editor.update(()=>{as(!0)})},isActive:he,isDisabled:be},Ga={label:"Delete row",icon:hm,action(o){o.editor.update(()=>{Sa()})},isActive:he,isDisabled:be},Jm={label:"Row properties",format:"long",action(o){o.editor.getEditorState().read(()=>{let e=to(T());cn(e[0])&&Lm(e[0],o)})},isActive:he,isDisabled:be},jm={label:"Cut row",format:"long",action(o){o.editor.update(()=>{try{Im()}catch(e){o.error(e)}})},isActive:he,isDisabled:be},Qm={label:"Copy row",format:"long",action(o){o.editor.getEditorState().read(()=>{try{km()}catch(e){o.error(e)}})},isActive:he,isDisabled:be},ep={label:"Paste row before",format:"long",action(o){o.editor.update(()=>{try{$m(o.editor)}catch(e){o.error(e)}})},isActive:he,isDisabled:o=>be(o)||Wa()},tp={label:"Paste row after",format:"long",action(o){o.editor.update(()=>{try{Pm(o.editor)}catch(e){o.error(e)}})},isActive:he,isDisabled:o=>be(o)||Wa()},op={label:"Cut column",format:"long",action(o){o.editor.update(()=>{try{Um()}catch(e){o.error(e)}})},isActive:he,isDisabled:be},np={label:"Copy column",format:"long",action(o){o.editor.getEditorState().read(()=>{try{zm()}catch(e){o.error(e)}})},isActive:he,isDisabled:be},rp={label:"Paste column before",format:"long",action(o){o.editor.update(()=>{try{qm(o.editor)}catch(e){o.error(e)}})},isActive:he,isDisabled:o=>be(o)||qa()},ip={label:"Paste column after",format:"long",action(o){o.editor.update(()=>{try{Ym(o.editor)}catch(e){o.error(e)}})},isActive:he,isDisabled:o=>be(o)||qa()},Ja={label:"Insert column before",icon:xm,action(o){o.editor.update(()=>{ds(!1)})},isActive(){return!1}},ja={label:"Insert column after",icon:Nm,action(o){o.editor.update(()=>{ds(!0)})},isActive(){return!1}},Qa={label:"Delete column",icon:gm,action(o){o.editor.update(()=>{La()})},isActive(){return!1}},sp={label:"Cell properties",format:"long",action(o){o.editor.getEditorState().read(()=>{let e=j(T(),le);le(e)&&bm(e,o)})},isActive:he,isDisabled:be},lp={label:"Merge cells",format:"long",action(o){o.editor.update(()=>{let e=T();W(e)&&Xf(e)})},isActive:he,isDisabled(o){return!W(o)}},ap={label:"Split cell",format:"long",action(o){o.editor.update(()=>{va()})},isActive:he,isDisabled(o){let e=j(o,le);return e?!(e.getRowSpan()>1||e.getColSpan()>1):!0}};var dp='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M280-200v-80h284q63 0 109.5-40T720-420q0-60-46.5-100T564-560H312l104 104-56 56-200-200 200-200 56 56-104 104h252q97 0 166.5 63T800-420q0 94-69.5 157T564-200H280Z"/></svg>';var cp='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" ><path d="M396-200q-97 0-166.5-63T160-420q0-94 69.5-157T396-640h252L544-744l56-56 200 200-200 200-56-56 104-104H396q-63 0-109.5 40T240-420q0 60 46.5 100T396-280h284v80H396Z"/></svg>';var up='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="m384-336 56-58-86-86 86-86-56-58-144 144 144 144Zm192 0 144-144-144-144-56 58 86 86-86 86 56 58ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h168q13-36 43.5-58t68.5-22q38 0 68.5 22t43.5 58h168q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm280-590q13 0 21.5-8.5T510-820q0-13-8.5-21.5T480-850q-13 0-21.5 8.5T450-820q0 13 8.5 21.5T480-790ZM200-200v-560 560Z"/></svg>';function rr(o,e){o.update(()=>{let t=B();for(let r of t.getChildren())r.remove(!0);let n=bo(o,e);t.append(...n)})}function fp(o,e){o.update(()=>{let t=B(),n=bo(o,e);t.append(...n)})}function mp(o,e){o.update(()=>{let t=B(),n=bo(o,e),r=t.getChildren()[0];for(let i=n.length-1;i>=0;i--)r?r.insertBefore(n[i]):t.append(n[i]),r=n[i]})}function pp(o,e){o.update(()=>{let t=T(),n=bo(o,e),r=t?.getNodes()[0],i=r?.getParents()||[];if(i[i.length-1]&&r)for(let l=n.length-1;l>=0;l--)r.insertAfter(n[l])})}function vs(o){return new Promise((e,t)=>{o.getEditorState().read(()=>{let n=Ji(o);e(n)})})}function gp(o){o.focus(()=>{},{defaultSelection:"rootStart"})}var hp='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M120-120v-200h80v120h120v80H120Zm520 0v-80h120v-120h80v200H640ZM120-640v-200h200v80H200v120h-80Zm640 0v-120H640v-80h200v200h-80Z"/></svg>';var Np={label:"Undo",icon:dp,action(o){o.editor.dispatchCommand(io,void 0),o.manager.triggerFutureStateRefresh()},isActive(o){return!1},setup(o,e){e.toggleDisabled(!0),o.editor.registerCommand(uo,t=>(e.toggleDisabled(!t),!1),Gt)}},xp={label:"Redo",icon:cp,action(o){o.editor.dispatchCommand(so,void 0),o.manager.triggerFutureStateRefresh()},isActive(o){return!1},setup(o,e){e.toggleDisabled(!0),o.editor.registerCommand(co,t=>(e.toggleDisabled(!t),!1),Gt)}},Ep={label:"Source",icon:up,async action(o){let e=o.manager.createModal("source"),t=await vs(o.editor);e.show({source:t})},isActive(){return!1}},Tp={label:"Fullscreen",icon:hp,async action(o,e){let t=o.containerDOM.classList.contains("fullscreen");o.containerDOM.classList.toggle("fullscreen",!t),o.containerDOM.closest("body").classList.toggle("editor-is-fullscreen",!t),e.setActiveState(!t)},isActive(o,e){return e.containerDOM.classList.contains("fullscreen")}};var mE=(o,e)=>lm(o)&&o.getTag()===e;function ws(o,e){o.update(()=>{Jn(t=>mE(t,e),()=>Es(e))})}function oi(o){o.update(()=>{Jn(df,nt)})}function ni(o){o.update(()=>{Jn(ns,Ts)})}function ri(o,e){o.getEditorState().read(()=>{let t=T();ae(t,r=>Oo(r)&&r.getListType()===e)?_a(o):Ca(o,e)})}function ii(o){o.getEditorState().read(()=>{let e=T(),t=fe(o),n=j(t,Ns);n===null?o.update(()=>{let r=hs();r.setCode(e?.getTextContent()||"");let i=It(e),s=i[0],l=i.slice(1);s?(s.replace(r),l.forEach(a=>a.remove())):on(r,!0),Jr(o,r),$e(r)}):Jr(o,n)})}function Cp(o){o.update(()=>{let e=T(),t=It(e),n=!1;for(let i of t)ua(i)||(i.replace(Zn("info"),!0),n=!0);if(n)return;let r=["info","warning","danger","success"];for(let i of t)if(ua(i)){let s=i.getCategory(),a=(r.indexOf(s)+1)%r.length,d=r[a];i.setCategory(d)}})}function Os(o,e){o.update(()=>{let t=T(),n=j(t,Rt);if(Rt(n)?(n.setURL(e.url),n.setTarget(e.target),n.setTitle(e.title)):(n=jt(e.url,{title:e.title,target:e.target}),Ie([n])),Rt(n)){for(let r of n.getChildren())r.remove(!0);n.append(Z(e.text))}})}function Ds(o,e){return{label:e,action(t){t.editor.update(()=>{Jn(n=>fa(n,o),()=>Zn(o))})},isActive(t){return ae(t,n=>fa(n,o))}}}var _p=Ds("info","Info"),yp=Ds("danger","Danger"),bp=Ds("warning","Warning"),Sp=Ds("success","Success"),pE=(o,e)=>rs(o)&&o.getTag()===e;function As(o,e){return{label:e,action(t){ws(t.editor,o)},isActive(t){return ae(t,n=>pE(n,o))}}}var Lp=As("h2","Large Header"),Mp=As("h3","Medium Header"),vp=As("h4","Small Header"),wp=As("h5","Tiny Header"),Op={label:"Blockquote",action(o){ni(o.editor)},isActive(o){return ae(o,ns)}},Dp={label:"Paragraph",action(o){oi(o.editor)},isActive(o){return ae(o,Xt)}};var Ap='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M272-200v-560h221q65 0 120 40t55 111q0 51-23 78.5T602-491q25 11 55.5 41t30.5 90q0 89-65 124.5T501-200H272Zm121-112h104q48 0 58.5-24.5T566-372q0-11-10.5-35.5T494-432H393v120Zm0-228h93q33 0 48-17t15-38q0-24-17-39t-44-15h-95v109Z"/></svg>';var Rp='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"/></svg>';var Ip='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M200-120v-80h560v80H200Zm280-160q-101 0-157-63t-56-167v-330h103v336q0 56 28 91t82 35q54 0 82-35t28-91v-336h103v330q0 104-56 167t-157 63Z"/></svg>';var kp=`<svg version="1.1" viewBox="0 -960 960 960" xmlns="http://www.w3.org/2000/svg"><path class="editor-icon-color-bar" d="m80-3e-6v-160h800v160z"/><path d="m220-280 210-560h100l210 560h-96l-50-144h-226l-52 144zm176-224h168l-82-232h-4z"/></svg>
`;var $p='<svg version="1.1" viewBox="0 -960 960 960" xmlns="http://www.w3.org/2000/svg"><path class="editor-icon-color-bar" d="m80-2e-6v-160h800v160z"/><path d="m584-480-104-104-160 160 103 104zm-47-160 103 103 160-159-104-104zm-84-29 216 216-189 190c-16 16-34.833 24-56.5 24s-40.5-8-56.5-24l-27 23h-200l126-125c-16-16-24.333-35.167-25-57.5s7-41.5 23-57.5zm0 0 187-187c16-16 34.833-24 56.5-24s40.5 8 56.5 24l104 103c16 16 24 34.833 24 56.5s-8 40.5-24 56.5l-188 187z"/></svg>';var Pp='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M80-400v-80h800v80H80Zm340-160v-120H200v-120h560v120H540v120H420Zm0 400v-160h120v160H420Z"/></svg>';var Fp='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M760-600v-80q0-17 11.5-28.5T800-720h80v-40H760v-40h120q17 0 28.5 11.5T920-760v40q0 17-11.5 28.5T880-680h-80v40h120v40H760ZM235-160l185-291-172-269h106l124 200h4l123-200h107L539-451l186 291H618L482-377h-4L342-160H235Z"/></svg>';var Bp='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M760-160v-80q0-17 11.5-28.5T800-280h80v-40H760v-40h120q17 0 28.5 11.5T920-320v40q0 17-11.5 28.5T880-240h-80v40h120v40H760Zm-525-80 185-291-172-269h106l124 200h4l123-200h107L539-531l186 291H618L482-457h-4L342-240H235Z"/></svg>';var Hp='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M320-240 80-480l240-240 57 57-184 184 183 183-56 56Zm320 0-57-57 184-184-183-183 56-56 240 240-240 240Z"/></svg>';var Kp='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="m528-546-93-93-121-121h486v120H568l-40 94ZM792-56 460-388l-80 188H249l119-280L56-792l56-56 736 736-56 56Z"/></svg>';function xn(o,e,t){return{label:o,icon:t,action(n){n.editor.dispatchCommand(Ne,e)},isActive(n){return pf(n,e)}}}var Up=xn("Bold","bold",Ap),zp=xn("Italic","italic",Rp),Wp=xn("Underline","underline",Ip),qp={label:"Text color",icon:kp},Yp={label:"Background color",icon:$p},Vp=xn("Strikethrough","strikethrough",Pp),Xp=xn("Superscript","superscript",Fp),Zp=xn("Subscript","subscript",Bp),Gp=xn("Inline code","code",Hp),Jp={label:"Clear formatting",icon:Kp,action(o){o.editor.update(()=>{let e=T();for(let t of e?.getNodes()||[])y(t)&&(t.setFormat(0),t.setStyle(""))})},isActive(){return!1}};var jp='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"/></svg>';var Qp='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"/></svg>';var eg='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"/></svg>';var tg='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"/></svg>';var og='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M440-800v400q0 17-11.5 28.5T400-360q-17 0-28.5-11.5T360-400v-160q-66 0-113-47t-47-113q0-66 47-113t113-47h280q17 0 28.5 11.5T680-840q0 17-11.5 28.5T640-800h-40v400q0 17-11.5 28.5T560-360q-17 0-28.5-11.5T520-400v-400h-80Zm-80 160v-160q-33 0-56.5 23.5T280-720q0 33 23.5 56.5T360-640Zm0-80Zm328 520H160q-17 0-28.5-11.5T120-240q0-17 11.5-28.5T160-280h528l-36-36q-11-11-11-28t11-28q11-11 28-11t28 11l104 104q12 12 12 28t-12 28L708-108q-11 11-28 11t-28-11q-11-11-11-28t11-28l36-36Z"/></svg>';var ng='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M440-800v400q0 17-11.5 28.5T400-360q-17 0-28.5-11.5T360-400v-160q-66 0-113-47t-47-113q0-66 47-113t113-47h280q17 0 28.5 11.5T680-840q0 17-11.5 28.5T640-800h-40v400q0 17-11.5 28.5T560-360q-17 0-28.5-11.5T520-400v-400h-80ZM272-200l36 36q11 11 11 28t-11 28q-11 11-28 11t-28-11L148-212q-12-12-12-28t12-28l104-104q11-11 28-11t28 11q11 11 11 28t-11 28l-36 36h528q17 0 28.5 11.5T840-240q0 17-11.5 28.5T800-200H272Zm88-440v-160q-33 0-56.5 23.5T280-720q0 33 23.5 56.5T360-640Zm0-80Z"/></svg>';function Rs(o,e){let t=fe(o.editor),n=t?.getNodes()||[];if(n.length===1&&x(n[0])&&n[0].isInline()&&zr(n[0])){n[0].setAlignment(e),$e(n[0]),o.manager.triggerFutureStateRefresh();return}let i=It(t).filter(a=>zr(a)),l=i.every(a=>a.getAlignment()===e)?"":e;for(let a of i)a.setAlignment(l);o.manager.triggerFutureStateRefresh()}function rg(o,e){let t=fe(o.editor),n=It(t);for(let r of n)r.setDirection(e);o.manager.triggerFutureStateRefresh()}var ig={label:"Align left",icon:jp,action(o){o.editor.update(()=>Rs(o,"left"))},isActive(o){return Wr(o,"left")}},sg={label:"Align center",icon:Qp,action(o){o.editor.update(()=>Rs(o,"center"))},isActive(o){return Wr(o,"center")}},lg={label:"Align right",icon:eg,action(o){o.editor.update(()=>Rs(o,"right"))},isActive(o){return Wr(o,"right")}},ag={label:"Justify",icon:tg,action(o){o.editor.update(()=>Rs(o,"justify"))},isActive(o){return Wr(o,"justify")}},dg={label:"Left to right",icon:og,action(o){o.editor.update(()=>rg(o,"ltr"))},isActive(o){return ga(o,"ltr")}},cg={label:"Right to left",icon:ng,action(o){o.editor.update(()=>rg(o,"rtl"))},isActive(o){return ga(o,"rtl")}};var ug='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M360-200v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360ZM200-160q-33 0-56.5-23.5T120-240q0-33 23.5-56.5T200-320q33 0 56.5 23.5T280-240q0 33-23.5 56.5T200-160Zm0-240q-33 0-56.5-23.5T120-480q0-33 23.5-56.5T200-560q33 0 56.5 23.5T280-480q0 33-23.5 56.5T200-400Zm0-240q-33 0-56.5-23.5T120-720q0-33 23.5-56.5T200-800q33 0 56.5 23.5T280-720q0 33-23.5 56.5T200-640Z"/></svg>';var fg='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M120-80v-60h100v-30h-60v-60h60v-30H120v-60h120q17 0 28.5 11.5T280-280v40q0 17-11.5 28.5T240-200q17 0 28.5 11.5T280-160v40q0 17-11.5 28.5T240-80H120Zm0-280v-110q0-17 11.5-28.5T160-510h60v-30H120v-60h120q17 0 28.5 11.5T280-560v70q0 17-11.5 28.5T240-450h-60v30h100v60H120Zm60-280v-180h-60v-60h120v240h-60Zm180 440v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360Z"/></svg>';var mg='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M222-200 80-342l56-56 85 85 170-170 56 57-225 226Zm0-320L80-662l56-56 85 85 170-170 56 57-225 226Zm298 240v-80h360v80H520Zm0-320v-80h360v80H520Z"/></svg>';var pg='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"/></svg>';var gg='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z"/></svg>';function $E(o){let e=o.getParent();if(!Oo(e))return o;let t=e.getChildren(),n=t.findIndex(l=>l.getKey()===o.getKey()),r=n===0,i=xs(),s=Fa(e.getListType());return s.append(i),i.append(...o.getChildren()),r?o.append(s):(t[n-1].append(s),o.remove()),i}function PE(o){let e=o.getParent(),t=e?.getParent(),n=t?.getParent();return!Oo(e)||!Oo(n)||!Do(t)||(t.insertAfter(o),e.getChildren().length===0&&e.remove(),t.getChildren().length===0&&t.remove()),o}function FE(o){let e=o?.getNodes()||[],t=[];e:for(let n of e){if(Do(n)){t.push(n);continue}let r=n.getParents();for(let i of r)if(Do(i)){t.push(i);continue e}t.push(null)}return t}function BE(o){let e={};for(let t of o){if(t===null)continue;let n=t.getKey();typeof e[n]>"u"&&(e[n]=t)}return Object.values(e)}function si(o,e){let t=T(),n=FE(t);if(n.length>0&&!n.includes(null)){let s=[],l=BE(n);if(e>0)for(let a of l)s.push($E(a));else if(e<0){for(let a of[...l].reverse())s.push(PE(a));s.reverse()}Nf(s);return}let i=It(t);for(let s of i)if(uf(s)){let l=s.getInset(),a=Math.min(Math.max(l+e,0),500);s.setInset(a)}xf(o)}function ed(o,e,t){return{label:o,icon:t,action(n){ri(n.editor,e)},isActive(n){return ae(n,r=>H(r)&&r.getListType()===e)}}}var hg=ed("Bullet list","bullet",ug),Ng=ed("Numbered list","number",fg),xg=ed("Task list","check",mg),Eg={label:"Increase indent",icon:pg,action(o){o.editor.update(()=>{si(o.editor,40)})},isActive(){return!1}},Tg={label:"Decrease indent",icon:gg,action(o){o.editor.update(()=>{si(o.editor,-40)})},isActive(){return!1}};var Cg='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M680-160v-120H560v-80h120v-120h80v120h120v80H760v120h-80ZM440-280H280q-83 0-141.5-58.5T80-480q0-83 58.5-141.5T280-680h160v80H280q-50 0-85 35t-35 85q0 50 35 85t85 35h160v80ZM320-440v-80h320v80H320Zm560-40h-80q0-50-35-85t-85-35H520v-80h160q83 0 141.5 58.5T880-480Z"/></svg>';var _g='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="m770-302-60-62q40-11 65-42.5t25-73.5q0-50-35-85t-85-35H520v-80h160q83 0 141.5 58.5T880-480q0 57-29.5 105T770-302ZM634-440l-80-80h86v80h-6ZM792-56 56-792l56-56 736 736-56 56ZM440-280H280q-83 0-141.5-58.5T80-480q0-69 42-123t108-71l74 74h-24q-50 0-85 35t-35 85q0 50 35 85t85 35h160v80ZM320-440v-80h65l79 80H320Z"/></svg>';var yg='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h360v80H200v560h560v-360h80v360q0 33-23.5 56.5T760-120H200Zm480-480v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80ZM240-280h480L570-480 450-320l-90-120-120 160Zm-40-480v560-560Z"/></svg>';var bg='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M160-440v-80h640v80H160Z"/></svg>';var Sg='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="m384-336 56-57-87-87 87-87-56-57-144 144 144 144Zm192 0 144-144-144-144-56 57 87 87-87 87 56 57ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z"/></svg>';var Lg='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75zM20.71 7.04a.996.996 0 0 0 0-1.41l-2.34-2.34a.996.996 0 0 0-1.41 0l-1.83 1.83 3.75 3.75z"/><path fill="none" d="M0 0h24v24H0z"/></svg>';var Mg='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M480-60q-63 0-106.5-43.5T330-210q0-52 31-91.5t79-53.5v-85H200v-160H100v-280h280v280H280v80h400v-85q-48-14-79-53.5T570-750q0-63 43.5-106.5T720-900q63 0 106.5 43.5T870-750q0 52-31 91.5T760-605v165H520v85q48 14 79 53.5t31 91.5q0 63-43.5 106.5T480-60Zm240-620q29 0 49.5-20.5T790-750q0-29-20.5-49.5T720-820q-29 0-49.5 20.5T650-750q0 29 20.5 49.5T720-680Zm-540 0h120v-120H180v120Zm300 540q29 0 49.5-20.5T550-210q0-29-20.5-49.5T480-280q-29 0-49.5 20.5T410-210q0 29 20.5 49.5T480-140ZM240-740Zm480-10ZM480-210Z"/></svg>';var vg='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-480H200v480Zm80-280v-80h400v80H280Zm0 160v-80h240v80H280Z"/></svg>';var wg='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="m380-300 280-180-280-180v360ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z"/></svg>';var ir=class extends Error{constructor(e,t){super(e.statusText),this.data=t,this.headers=e.headers,this.redirected=e.redirected,this.status=e.status,this.statusText=e.statusText,this.url=e.url,this.original=e}};function Is(o){return new Promise((e,t)=>{o.oncomplete=o.onsuccess=()=>e(o.result),o.onabort=o.onerror=()=>t(o.error)})}function ZE(o,e){let t=indexedDB.open(o);t.onupgradeneeded=()=>t.result.createObjectStore(e);let n=Is(t);return(r,i)=>n.then(s=>i(s.transaction(e,r).objectStore(e)))}var td;function od(){return td||(td=ZE("keyval-store","keyval")),td}function nd(o,e=od()){return e("readonly",t=>Is(t.get(o)))}function rd(o,e,t=od()){return t("readwrite",n=>(n.put(e,o),Is(n.transaction)))}function id(o,e=od()){return e("readwrite",t=>(t.delete(o),Is(t.transaction)))}var yt=null,ad,ks,sd,ld="last-drawing-save";function dd(o){yt?.contentWindow?.postMessage(JSON.stringify(o),ad)}function JE(o){rd(ld,o.data),sd&&sd(o.data).then(()=>{id(ld)})}function jE(o){dd({action:"export",format:"xmlpng",xml:o.xml,spin:"Updating drawing"})}function QE(){ks&&ks().then(o=>{dd({action:"load",autosave:1,xml:o})})}function eT(){let o={};yt&&(window.$events.emitPublic(yt,"editor-drawio::configure",{config:o}),dd({action:"configure",config:o}))}function Og(){window.removeEventListener("message",Dg),yt&&document.body.removeChild(yt)}function Dg(o){if(!o.data||o.data.length<1||o.origin!==ad)return;let e=JSON.parse(o.data);e.event==="init"?QE():e.event==="exit"?Og():e.event==="save"?jE(e):e.event==="export"?JE(e):e.event==="configure"&&eT()}async function tT(){let o=await nd(ld),e=document.getElementById("unsaved-drawing-dialog");e||console.error("Missing expected unsaved-drawing dialog"),o&&e&&await window.$components.firstOnElement(e,"confirm-dialog").show()&&(ks=async()=>o)}async function Ag(o,e,t){ks=e,sd=t,await tT(),yt=document.createElement("iframe"),yt.setAttribute("frameborder","0"),window.addEventListener("message",Dg),yt.setAttribute("src",o),yt.setAttribute("class","fullscreen"),yt.style.backgroundColor="#FFFFFF",document.body.appendChild(yt),ad=new URL(o).origin}async function Rg(o,e){let t={image:o,uploaded_to:e};return(await window.$http.post(window.baseUrl("/images/drawio"),t)).data}function cd(){Og()}async function Ig(o){try{return`data:image/png;base64,${(await window.$http.get(window.baseUrl(`/images/drawio/base64/${o}`))).data.content}`}catch(e){throw e instanceof ir&&window.$events.showResponseError(e),cd(),e}}function li(o){return o instanceof wo}function nT(o,e){o.status===413?window.$events.emit("error",e.options.translations.serverUploadLimitText||""):window.$events.emit("error",e.options.translations.imageUploadErrorText||""),console.error(o)}async function rT(o,e){return await new Promise((n,r)=>{o.getEditorState().read(()=>{let{id:i}=e.getDrawingIdAndUrl();n(i)})})||""}async function iT(o,e,t,n){if(cd(),n){let r=window.baseUrl("/loading.gif");o.editor.update(()=>{e.setDrawingIdAndUrl("",r)})}try{let r=await Rg(t,o.options.pageId);o.editor.update(()=>{e.setDrawingIdAndUrl(String(r.id),r.url)})}catch(r){throw r instanceof ir&&nT(r,o),n&&o.editor.update(()=>{e.remove()}),new Error(`Failed to save image with error: ${r}`)}}function ai(o,e){let t=!1;Ag(o.options.drawioUrl,async()=>{let n=await rT(o.editor,e);return t=!n,t?"":Ig(n)},async n=>iT(o,e,n,t))}function sT(o){window.$components.first("image-manager").show(t=>{o(t)},"drawio")}function kg(o){let e=fe(o.editor);sT(t=>{o.editor.update(()=>{let n=tr(t.id,t.url),r=j(e,li);li(r)?r.replace(n):Ie([n])})})}function $s(o){window.$components.first("image-manager").show(t=>{o(t)},"gallery")}function $g(o){let e=o.thumbs?.display||o.url,t=jt(e,{target:"_blank"}),n=jn(e,{alt:o.name});return t.append(n),t}async function Pg(o,e){if(o===null||o.type.indexOf("image")!==0)throw new Error("Not an image file");let t=o.name||`image-${Date.now()}.png`,n=new FormData;return n.append("file",o,t),n.append("uploaded_to",e),(await window.$http.post("/images/gallery",n)).data}var di=class extends ne{constructor(e,t){super([e,t]),this.input=e,this.action=t}buildDOM(){return b("div",{class:"editor-action-input-container"},[this.input.getDOMElement(),this.action.getDOMElement()])}};var Fg='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h200v80H200v560h560v-214l80 80v134q0 33-23.5 56.5T760-120H200Zm40-160 120-160 90 120 120-160 150 200H240Zm622-144L738-548q-21 14-45 21t-51 7q-74 0-126-52.5T464-700q0-75 52.5-127.5T644-880q75 0 127.5 52.5T824-700q0 27-8 52t-20 46l122 122-56 56ZM644-600q42 0 71-29t29-71q0-42-29-71t-71-29q-42 0-71 29t-29 71q0 42 29 71t71 29Z"/></svg>';var Bg='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15.5 14h-.79l-.28-.27A6.47 6.47 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14"/><path fill="none" d="M0 0h24v24H0z"/></svg>';function Ps(o,e){window.$components.first("entity-selector-popup").show(n=>o(n),{initialValue:e,searchEndpoint:"/search/entity-selector",entityTypes:"page,book,chapter,bookshelf",entityPermission:"view"})}var Fs=class extends ne{constructor(t){super([t]);this.headerMap=new Map;this.input=t}buildDOM(){let t="editor-form-datalist-"+this.input.getName()+"-"+Date.now(),n=this.input.getDOMElement(),r=n.querySelector("input");r?.setAttribute("list",t),r?.setAttribute("autocomplete","off");let i=b("datalist",{id:t}),s=b("div",{class:"editor-link-field-container"},[n,i]);return r?.addEventListener("focusin",()=>{this.updateDataList(i)}),r?.addEventListener("input",()=>{let l=r.value,a=this.headerMap.get(l);a&&this.updateFormFromHeader(a)}),s}updateFormFromHeader(t){this.getHeaderIdAndText(t).then(({id:n,text:r})=>{console.log("updating form",n,r);let i=this.getContext().manager.getActiveModal("link");i&&i.getForm().setValues({url:`#${n}`,text:r,title:r})})}getHeaderIdAndText(t){return new Promise(n=>{this.getContext().editor.update(()=>{let r=t.getId();console.log("header",r,t.__id),r||(r="header-"+_m(),t.setId(r));let i=t.getTextContent();n({id:r,text:i})})})}updateDataList(t){this.getContext().editor.getEditorState().read(()=>{let n=ma(rs);this.headerMap.clear();let r=[];for(let i of n){let s="header-"+i.getKey();this.headerMap.set(s,i),r.push(b("option",{value:s,label:i.getTextContent().substring(0,54)}))}t.innerHTML="",t.append(...r)})}};function Hg(o,e){let t=e.manager.createModal("image"),n=o.getHeight(),r=o.getWidth(),i={src:o.getSrc(),alt:o.getAltText(),height:n===0?"":String(n),width:r===0?"":String(r)};t.show(i)}var Kg={submitText:"Apply",async action(o,e){return e.editor.update(()=>{let t=fe(e.editor),n=j(t,Nt);Nt(n)&&(n.setSrc(o.get("src")?.toString()||""),n.setAltText(o.get("alt")?.toString()||""),n.setWidth(Number(o.get("width")?.toString()||"0")),n.setHeight(Number(o.get("height")?.toString()||"0")))}),!0},fields:[{build(){return new di(new Ao({label:"Source",name:"src",type:"text"}),new v({label:"Browse files",icon:Fg,action(o){$s(e=>{let t=o.manager.getActiveModal("image");t&&t.getForm().setValues({src:e.thumbs?.display||e.url,alt:e.name})})}}))}},{label:"Alternative description",name:"alt",type:"text"},{label:"Width",name:"width",type:"text"},{label:"Height",name:"height",type:"text"}]};function Bs(o,e){let t=e.manager.createModal("link");if(o){let n={url:o.getURL(),text:o.getTextContent(),title:o.getTitle()||"",target:o.getTarget()||""};e.editor.update(()=>{let r=Go();r.add(o.getKey()),Y(r)}),t.show(n)}else e.editor.getEditorState().read(()=>{let i={text:T()?.getTextContent()||""};t.show(i)})}var Ug={submitText:"Apply",async action(o,e){return Os(e.editor,{url:o.get("url")?.toString()||"",title:o.get("title")?.toString()||"",target:o.get("target")?.toString()||"",text:o.get("text")?.toString()||""}),!0},fields:[{build(){return new di(new Fs(new Ao({label:"URL",name:"url",type:"text"})),new v({label:"Browse links",icon:Bg,action(o){Ps(e=>{let t=o.manager.getActiveModal("link");t&&t.getForm().setValues({url:e.link,text:e.name,title:e.name})})}}))}},{label:"Text to display",name:"text",type:"text"},{label:"Title",name:"title",type:"text"},{label:"Open link in...",name:"target",type:"select",valuesByLabel:{"Current window":"","New window":"_blank"}}]},zg={submitText:"Save",async action(o,e){let t=await new Promise((r,i)=>{e.editor.getEditorState().read(()=>{let s=j(T(),oo);r(s)})}),n=(o.get("embed")||"").toString().trim();return n?(e.editor.update(()=>{let r=nm(n);t&&r?t.replace(r):r&&Ie([r])}),!0):(e.editor.update(()=>{let r=(o.get("src")||"").toString().trim(),i=(o.get("height")||"").toString().trim(),s=(o.get("width")||"").toString().trim(),l=t||rm(r);l.setSrc(r),l.setWidthAndHeight(s,i),t||Ie([l])}),!0)},fields:[{build(){return new Nn([{label:"General",contents:[{label:"Source",name:"src",type:"text"},{label:"Width",name:"width",type:"text"},{label:"Height",name:"height",type:"text"}]},{label:"Embed",contents:[{label:"Paste your embed code below:",name:"embed",type:"textarea"}]}])}}]};var ud={label:"Insert/edit link",icon:Cg,action(o){o.editor.getEditorState().read(()=>{let e=j(T(),Rt);Bs(e,o)})},isActive(o){return ae(o,Rt)}},Wg={label:"Remove link",icon:_g,action(o){o.editor.update(()=>{let e=fe(o.editor),t=j(e,Rt);if(t){let n=t.getChildren().reverse();for(let r of n)t.insertAfter(r);t.remove(),n[n.length-1].selectStart(),o.manager.triggerFutureStateRefresh()}})},isActive(o){return!1}},fd={label:"Insert/Edit Image",icon:yg,action(o){o.editor.getEditorState().read(()=>{let e=fe(o.editor),t=j(e,Nt);if(t){Hg(t,o);return}$s(n=>{o.editor.update(()=>{let r=$g(n);Ie([r])})})})},isActive(o){return ae(o,Nt)}},qg={label:"Insert horizontal line",icon:bg,action(o){o.editor.update(()=>{on(Pa(),!1)})},isActive(o){return ae(o,Qf)}},md={label:"Insert code block",icon:Sg,action(o){ii(o.editor)},isActive(o){return ae(o,Ns)}},Yg=Object.assign({},md,{label:"Edit code block",icon:Lg}),Vg={label:"Insert/edit drawing",icon:Mg,action(o){o.editor.getEditorState().read(()=>{let e=fe(o.editor),t=j(e,li);t===null?o.editor.update(()=>{let n=tr();on(n,!0),ai(o,n),n.selectStart()}):ai(o,t)})},isActive(o){return ae(o,li)}},Xg={label:"Drawing manager",action(o){kg(o)},isActive(){return!1}},Zg={label:"Insert/edit Media",icon:wg,action(o){let e=o.manager.createModal("media");o.editor.getEditorState().read(()=>{let t=T(),n=j(t,oo),r={};if(n){let i=n.getAttributes();r={src:i.src||i.data||"",width:i.width,height:i.height,embed:""}}e.show(r)})},isActive(o){return ae(o,oo)}},Gg={label:"Insert collapsible block",icon:vg,action(o){o.editor.update(()=>{let e=T(),t=ha(),r=(e?.getNodes()||[]).map(s=>s.getTopLevelElement()).filter(s=>s!==null),i=[...new Set(r)];i.length>0?i[0].insertAfter(t):B().append(t);for(let s of i)t.append(s)})},isActive(o){return ae(o,Ef)}};var Jg=`<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="m2 6.9159 10 10.168 10-10.168z" stroke-width="2.0168"/></svg>
`;var Hs=class extends ne{constructor(e,t){super([e]),this.button=e,this.dropdownButton=new Oe({button:{label:"Menu",icon:Jg},showOnHover:!1,direction:"vertical"},t),this.addChildren(this.dropdownButton)}buildDOM(){return b("div",{class:"editor-button-with-menu-container"},[this.button.getDOMElement(),this.dropdownButton.getDOMElement()])}};var En=class extends Xe{buildDOM(){return b("div",{class:"editor-separator"})}};function jg(o){let e=o.manager.getDefaultDirection()==="rtl";return new Cs("editor-toolbar-main",[new st(2,[new v(Np),new v(xp)]),new ys([new Ze(b("h2"),Lp),new Ze(b("h3"),Mp),new Ze(b("h4"),vp),new Ze(b("h5"),wp),new Ze(b("blockquote"),Op),new Ze(b("p"),Dp),new Oe({button:{label:"Callouts",format:"long"},showOnHover:!0,direction:"vertical"},[new Ze(b("p",{class:"callout info"}),_p),new Ze(b("p",{class:"callout success"}),Sp),new Ze(b("p",{class:"callout warning"}),bp),new Ze(b("p",{class:"callout danger"}),yp)])]),new st(6,[new v(Up),new v(zp),new v(Wp),new Oe({button:new Qr(qp,"color")},[new jr("color")]),new Oe({button:new Qr(Yp,"background-color")},[new jr("background-color")]),new v(Vp),new v(Xp),new v(Zp),new v(Gp),new v(Jp)]),new st(6,[new v(ig),new v(sg),new v(lg),new v(ag),e?new v(dg):null,e?new v(cg):null].filter(t=>t!==null)),new st(3,[new v(hg),new v(Ng),new v(xg),new v(Tg),new v(Eg)]),new st(4,[new v(ud),new Oe({button:Vm,direction:"vertical"},[new Oe({button:{label:"Insert",format:"long"},showOnHover:!0},[new Ss]),new En,new Oe({button:{label:"Cell",format:"long"},direction:"vertical",showOnHover:!0},[new v(sp),new v(lp),new v(ap)]),new Oe({button:{label:"Row",format:"long"},direction:"vertical",showOnHover:!0},[new v({...Xa,format:"long"}),new v({...Za,format:"long"}),new v({...Ga,format:"long"}),new v(Jm),new En,new v(jm),new v(Qm),new v(ep),new v(tp)]),new Oe({button:{label:"Column",format:"long"},direction:"vertical",showOnHover:!0},[new v({...Ja,format:"long"}),new v({...ja,format:"long"}),new v({...Qa,format:"long"}),new En,new v(op),new v(np),new v(rp),new v(ip)]),new En,new v({...Ya,format:"long"}),new v(Xm),new v(Zm),new v(Gm)]),new v(fd),new v(qg),new v(md),new Hs(new v(Vg),[new v(Xg)]),new v(Zg),new v(Gg)]),new st(3,[new v(Ep),new v(Tp)])])}function Qg(){return[new v(fd)]}function eh(){return[new v(ud),new v(Wg)]}function th(){return[new v(Yg)]}function oh(){return[new st(2,[new v(Ya),new v(Va)]),new st(3,[new v(Xa),new v(Za),new v(Ga)]),new st(3,[new v(Ja),new v(ja),new v(Qa)])]}var nh='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>';var Ks=class extends ne{constructor(e,t){super([new Ls(e.form)]),this.definition=e,this.key=t}show(e){let t=this.getDOMElement();document.body.append(t);let n=this.getForm();n.setValues(e),n.setOnCancel(this.hide.bind(this)),n.setOnSuccessfulSubmit(this.hide.bind(this)),this.getContext().manager.setModalActive(this.key,this)}hide(){this.getDOMElement().remove(),this.getContext().manager.setModalInactive(this.key)}getForm(){return this.children[0]}buildDOM(){let e=b("button",{class:"editor-modal-close",type:"button",title:this.trans("Close")});e.innerHTML=nh,e.addEventListener("click",this.hide.bind(this));let t=b("div",{class:"editor-modal editor-form-modal"},[b("div",{class:"editor-modal-header"},[b("div",{class:"editor-modal-title"},[this.trans(this.definition.title)]),e]),b("div",{class:"editor-modal-body"},[this.getForm().getDOMElement()])]),n=b("div",{class:"editor-modal-wrapper"},[t]);return n.addEventListener("click",r=>{r.target&&!t.contains(r.target)&&this.hide()}),n}};var Us=class extends ne{constructor(e,t){super(t),this.target=e}buildDOM(){return b("div",{class:"editor-context-toolbar"},this.getChildren().map(e=>e.getDOMElement()))}updatePosition(){let e=this.getContext().scrollDOM.getBoundingClientRect(),t=this.target.getBoundingClientRect(),n=this.getDOMElement(),r=n.getBoundingClientRect(),i=t.bottom>e.top&&t.top<e.bottom;if(n.hidden=!i,!i)return;let s=t.bottom+6+r.height>e.bottom;n.classList.toggle("is-above",s);let a=t.left+t.width/2-r.width/2;s?n.style.top=t.top-6-r.height+"px":n.style.top=t.bottom+6+"px",n.style.left=a+"px"}insert(e){this.addChildren(...e),this.getDOMElement().append(...e.map(n=>n.getDOMElement()))}empty(){let e=this.getChildren();for(let t of e)t.getDOMElement().remove();this.removeChildren(...e)}destroy(){this.empty(),this.getDOMElement().remove()}};var zs=class{constructor(){this.modalDefinitionsByKey={};this.activeModalsByKey={};this.decoratorConstructorsByType={};this.decoratorInstancesByNodeKey={};this.context=null;this.toolbar=null;this.contextToolbarDefinitionsByKey={};this.activeContextToolbars=[];this.selectionChangeHandlers=new Set}setContext(e){this.context=e,this.setupEventListeners(e),this.setupEditor(e.editor)}getContext(){if(this.context===null)throw new Error("Context attempted to be used without being set");return this.context}triggerStateUpdateForElement(e){e.updateState({selection:null,editor:this.getContext().editor})}registerModal(e,t){this.modalDefinitionsByKey[e]=t}createModal(e){let t=this.modalDefinitionsByKey[e];if(!t)throw new Error(`Attempted to show modal of key [${e}] but no modal registered for that key`);let n=new Ks(t,e);return n.setContext(this.getContext()),n}setModalActive(e,t){this.activeModalsByKey[e]=t}setModalInactive(e){delete this.activeModalsByKey[e]}getActiveModal(e){return this.activeModalsByKey[e]}registerDecoratorType(e,t){this.decoratorConstructorsByType[e]=t}getDecorator(e,t){if(this.decoratorInstancesByNodeKey[t])return this.decoratorInstancesByNodeKey[t];let n=this.decoratorConstructorsByType[e];if(!n)throw new Error(`Attempted to use decorator of type [${e}] but not decorator registered for that type`);let r=new n(t);return this.decoratorInstancesByNodeKey[t]=r,r}getDecoratorByNodeKey(e){return this.decoratorInstancesByNodeKey[e]||null}setToolbar(e){this.toolbar&&this.toolbar.getDOMElement().remove(),this.toolbar=e,e.setContext(this.getContext()),this.getContext().containerDOM.prepend(e.getDOMElement())}registerContextToolbar(e,t){this.contextToolbarDefinitionsByKey[e]=t}triggerStateUpdate(e){mf(e.editor,e.selection),this.toolbar?.updateState(e),this.updateContextToolbars(e);for(let t of this.activeContextToolbars)t.updateState(e);this.triggerSelectionChange(e.selection)}triggerStateRefresh(){let e=this.getContext().editor,t={editor:e,selection:fe(e)};this.triggerStateUpdate(t),this.updateContextToolbars(t)}triggerFutureStateRefresh(){requestAnimationFrame(()=>{this.getContext().editor.getEditorState().read(()=>{this.triggerStateRefresh()})})}triggerSelectionChange(e){if(e)for(let t of this.selectionChangeHandlers)t(e)}onSelectionChange(e){this.selectionChangeHandlers.add(e)}offSelectionChange(e){this.selectionChangeHandlers.delete(e)}triggerLayoutUpdate(){window.requestAnimationFrame(()=>{for(let e of this.activeContextToolbars)e.updatePosition()})}getDefaultDirection(){return this.getContext().options.textDirection==="rtl"?"rtl":"ltr"}updateContextToolbars(e){for(let s=this.activeContextToolbars.length-1;s>=0;s--)this.activeContextToolbars[s].destroy(),this.activeContextToolbars.splice(s,1);let t=(e.selection?.getNodes()||[])[0]||null;if(!t)return;let n=e.editor.getElementByKey(t.getKey());if(!n)return;let r=Object.keys(this.contextToolbarDefinitionsByKey),i=new Map;for(let s of r){let l=this.contextToolbarDefinitionsByKey[s],a=n.closest(l.selector)||n.querySelector(l.selector);if(a){let d=l.displayTargetLocator?l.displayTargetLocator(a):a;i.has(d)||i.set(d,[]),i.get(d).push(...l.content)}}for(let[s,l]of i){let a=new Us(s,l);a.setContext(this.getContext()),this.activeContextToolbars.push(a),this.getContext().containerDOM.append(a.getDOMElement()),a.updatePosition()}}setupEditor(e){let t=n=>{e.getEditorState().read(()=>{let r=Object.keys(n);for(let i of r){let s=e.getElementByKey(i);if(!s)continue;let l=n[i],a=this.getDecorator(l.type,i);a.setNode(l.getNode());let d=a.render(this.getContext(),s);d&&s.append(d)}})};e.registerDecoratorListener(t)}setupEventListeners(e){let t=this.triggerLayoutUpdate.bind(this);window.addEventListener("scroll",t,{capture:!0,passive:!0}),window.addEventListener("resize",t,{passive:!0})}};var sr=class{constructor(e){this.node=null;this.onDestroyCallbacks=[];this.context=e}getNode(){if(!this.node)throw new Error("Attempted to get use node without it being set");return this.node}setNode(e){this.node=e}onDestroy(e){this.onDestroyCallbacks.push(e)}destroy(e){for(let t of this.onDestroyCallbacks)t()}};var Ws=class extends sr{constructor(){super(...arguments);this.completedSetup=!1;this.latestCode="";this.latestLanguage="";this.editor=null}setup(t,n){let r=this.getNode(),i=n.querySelector("pre");if(!i)return;i&&(i.hidden=!0),this.latestCode=r.__code,this.latestLanguage=r.__language;let l=this.latestCode.split(`
`).length*19.2+18+24;n.style.height=`${l}px`;let a=Date.now();n.addEventListener("click",m=>{requestAnimationFrame(()=>{t.editor.update(()=>{$e(this.getNode())})})}),n.addEventListener("dblclick",m=>{t.editor.getEditorState().read(()=>{Jr(t.editor,this.getNode())})});let d=m=>{n.classList.toggle("selected",is(m,r))};t.manager.onSelectionChange(d),this.onDestroy(()=>{t.manager.offSelectionChange(d)});let f=m=>{this.editor=m.wysiwygView(n,document,this.latestCode,this.latestLanguage),setTimeout(()=>{n.style.height=""},12)};window.importVersioned("code").then(m=>{let c=Date.now()-a<20?20:0;setTimeout(()=>f(m),c)}),this.completedSetup=!0}update(){let t=this.getNode(),n=t.getCode(),r=t.getLanguage();this.latestCode===n&&this.latestLanguage===r||(this.latestLanguage=r,this.latestCode=n,this.editor&&(this.editor.setContent(n),this.editor.setMode(r,n)))}render(t,n){this.completedSetup?this.update():this.setup(t,n)}};var qs=class extends sr{constructor(){super(...arguments);this.completedSetup=!1}setup(t,n){let r=this.getNode();n.classList.add("editor-diagram"),n.addEventListener("click",s=>{t.editor.update(()=>{$e(this.getNode())})}),n.addEventListener("dblclick",s=>{t.editor.getEditorState().read(()=>{ai(t,this.getNode())})});let i=s=>{n.classList.toggle("selected",is(s,r))};t.manager.onSelectionChange(i),this.onDestroy(()=>{t.manager.offSelectionChange(i)}),this.completedSetup=!0}update(){}render(t,n){this.completedSetup?this.update():this.setup(t,n)}};var rh={submitText:"Save",async action(o,e){return rr(e.editor,o.get("source")?.toString()||""),!0},fields:[{label:"Source",name:"source",type:"textarea"}]};var pd={link:{title:"Insert/Edit Link",form:Ug},image:{title:"Insert/Edit Image",form:Kg},media:{title:"Insert/Edit Media",form:zg},source:{title:"Source code",form:rh},cell_properties:{title:"Cell Properties",form:Sm},row_properties:{title:"Row Properties",form:Mm},table_properties:{title:"Table Properties",form:wm}};function ih(o,e,t,n,r){let i=new zs,s={editor:n,containerDOM:o,editorDOM:e,scrollDOM:t,manager:i,translate(l){return r.translations[l]||l},error(l){let a=l instanceof Error?l.message:l;window.$events.error(a)},options:r};i.setContext(s),i.setToolbar(jg(s));for(let l of Object.keys(pd))i.registerModal(l,pd[l]);return i.registerContextToolbar("image",{selector:"img:not([drawio-diagram] img)",content:Qg()}),i.registerContextToolbar("link",{selector:"a",content:eh(),displayTargetLocator(l){return l.querySelector("img")||l}}),i.registerContextToolbar("code",{selector:".editor-code-block-wrap",content:th()}),i.registerContextToolbar("table",{selector:"td,th",content:oh(),displayTargetLocator(l){return l.closest("table")}}),i.registerDecoratorType("code",Ws),i.registerDecoratorType("diagram",qs),s}var lr=class{constructor(e,t,n){this.startX=0;this.startY=0;this.target=null;this.container=e,this.dragTargetSelector=t,this.options=n,this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.container.addEventListener("mousedown",this.onMouseDown)}teardown(){this.container.removeEventListener("mousedown",this.onMouseDown),this.container.removeEventListener("mouseup",this.onMouseUp),this.container.removeEventListener("mousemove",this.onMouseMove)}onMouseDown(e){this.target=e.target.closest(this.dragTargetSelector),this.target&&(this.startX=e.screenX,this.startY=e.screenY,window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("mouseup",this.onMouseUp),this.options.down&&this.options.down(e,this.target))}onMouseMove(e){this.options.move&&this.target&&this.options.move(e,this.target,{x:e.screenX-this.startX,y:e.screenY-this.startY})}onMouseUp(e){window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp),this.options.up&&this.target&&this.options.up(e,this.target,{x:e.screenX-this.startX,y:e.screenY-this.startY})}};var gd=class{constructor(e,t){this.markerDom=null;this.mouseTracker=null;this.dragging=!1;this.targetCell=null;this.xMarkerAtStart=!1;this.yMarkerAtStart=!1;this.editor=e,this.editScrollContainer=t,this.setupListeners()}teardown(){this.editScrollContainer.removeEventListener("mousemove",this.onCellMouseMove),window.removeEventListener("scroll",this.onScrollOrResize,{capture:!0}),window.removeEventListener("resize",this.onScrollOrResize),this.mouseTracker&&this.mouseTracker.teardown()}setupListeners(){this.onCellMouseMove=this.onCellMouseMove.bind(this),this.onScrollOrResize=this.onScrollOrResize.bind(this),this.editScrollContainer.addEventListener("mousemove",this.onCellMouseMove),window.addEventListener("scroll",this.onScrollOrResize,{capture:!0,passive:!0}),window.addEventListener("resize",this.onScrollOrResize,{passive:!0})}onScrollOrResize(){this.updateCurrentMarkerTargetPosition()}onCellMouseMove(e){let t=e.target.closest("td,th");if(!t||this.dragging)return;let n=t.getBoundingClientRect(),r=n.left+n.width/2,i=n.top+n.height/2;this.targetCell=t,this.xMarkerAtStart=e.clientX<=r,this.yMarkerAtStart=e.clientY<=i;let s=this.xMarkerAtStart?n.left:n.right,l=this.yMarkerAtStart?n.top:n.bottom;this.updateMarkersTo(t,s,l)}updateMarkersTo(e,t,n){let r=this.getMarkers(),s=e.closest("table").getBoundingClientRect(),l=this.editScrollContainer.getBoundingClientRect(),a=Math.max(s.top,l.top),f=Math.min(s.bottom,l.bottom)-a;r.x.style.left=t+"px",r.x.style.top=a+"px",r.x.style.height=f+"px",r.y.style.top=n+"px",r.y.style.left=s.left+"px",r.y.style.width=s.width+"px",r.y.hidden=n<l.top||n>l.bottom,r.x.hidden=s.top>l.bottom||s.bottom<l.top}updateCurrentMarkerTargetPosition(){if(!this.targetCell)return;let e=this.targetCell.getBoundingClientRect(),t=this.xMarkerAtStart?e.left:e.right,n=this.yMarkerAtStart?e.top:e.bottom;this.updateMarkersTo(this.targetCell,t,n)}getMarkers(){if(!this.markerDom){this.markerDom={x:b("div",{class:"editor-table-marker editor-table-marker-column"}),y:b("div",{class:"editor-table-marker editor-table-marker-row"})};let e=b("div",{class:"editor-table-marker-wrap"},[this.markerDom.x,this.markerDom.y]);this.editScrollContainer.after(e),this.watchMarkerMouseDrags(e)}return this.markerDom}watchMarkerMouseDrags(e){let t=this,n=0,r="left";this.mouseTracker=new lr(e,".editor-table-marker",{down(i,s){s.classList.add("active"),t.dragging=!0,r=s.classList.contains("editor-table-marker-column")?"left":"top",n=Number(s.style[r].replace("px",""))},move(i,s,l){s.style[r]=n+l[r==="left"?"x":"y"]+"px"},up(i,s,l){s.classList.remove("active"),s.style.left="0",s.style.top="0",t.dragging=!1;let a=t.targetCell?.closest("table");if(r==="left"&&t.targetCell&&a){let d=t.getTargetCellColumnIndex(),f=l.x;t.xMarkerAtStart&&d>0?d-=1:t.xMarkerAtStart&&d===0&&(f=-f),t.editor.update(()=>{let m=J(a);if(m instanceof _t){let c=Wf(t.editor,m,d),u=Math.max(c+f,10);ka(m,d,u)}})}if(r==="top"&&t.targetCell){let d=t.targetCell;t.editor.update(()=>{let m=J(d)?.getParent(),c=m?.getIndexWithinParent()||0,u=l.y;t.yMarkerAtStart&&c>0?c-=1:t.yMarkerAtStart&&c===0&&(u=-u);let p=m?.getParent()?.getChildren()[c];if(p instanceof Tt){let g=p.getHeight()||0,h=Math.max(g+u,10);p.setHeight(h)}})}}})}getTargetCellColumnIndex(){let e=this.targetCell;if(e===null)return-1;let t=0,n=e.parentElement;for(let r of n?.children||[]){let i=Number(r.getAttribute("colspan"));if((Number.isNaN(i)||i<1)&&(i=1),t+=i,r===e)return t-1}return-1}};function sh(o,e){let t=new gd(o,e);return()=>{t.teardown()}}function Ys(o){return o.html||""}function lh(o){window.$events.listen("editor::replace",e=>{let t=Ys(e);rr(o,t)}),window.$events.listen("editor::append",e=>{let t=Ys(e);fp(o,t)}),window.$events.listen("editor::prepend",e=>{let t=Ys(e);mp(o,t)}),window.$events.listen("editor::insert",e=>{let t=Ys(e);pp(o,t)}),window.$events.listen("editor::focus",()=>{gp(o)})}var Vs=class{constructor(e){this.data=e}hasItems(){return!!this.data&&!!this.data.types&&this.data.types.length>0}containsTabularData(){let e=this.data.getData("text/rtf");return!!e&&e.includes("\\trowd")}getImages(){return this.getFiles().filter(e=>e.type.includes("image"))}getFiles(){let{files:e}=this.data;return[...e]}};function uT(o,e){let t=o.clientX,n=o.clientY;return document.elementFromPoint(t,n)?cf(e,o.clientX,o.clientY):null}function ah(o,e,t){let n=uT(e,t);n&&$e(n),pa(o,!0),(!F(n)||!n?.getTextContent())&&n?.remove()}async function fT(o,e,t){let i=((await window.$http.get(`/templates/${e}`)).data||{html:""}).html||"";o.update(()=>{let s=bo(o,i);ah(s,t,o)})}function dh(o,e){let t=new Vs(o),n=!1;if(!t.hasItems()||t.containsTabularData())return n;let r=t.getImages();return r.length>0&&(n=!0),e.editor.update(async()=>{for(let i of r){let s=window.baseUrl("/loading.gif"),l=jn(s),a=nt();a.append(l),Ie([a]);try{let d=await Pg(i,e.options.pageId),f=d.name.replace(/"/g,"");e.editor.update(()=>{let m=jn(d.thumbs?.display||"",{alt:f}),c=jt(d.url,{target:"_blank"});c.append(m),l.replace(c)})}catch(d){e.editor.update(()=>{l.remove(!1)}),window.$events.error(d?.data?.message||e.options.translations.imageUploadErrorText),console.error(d)}}}),n}function mT(o){let e=o.editor;return t=>{let n=t.dataTransfer?.getData("bookstack/template")||"";if(n)return fT(e,n,t),t.preventDefault(),t.stopPropagation(),!0;let r=t.dataTransfer?.getData("text/html")||"";return r?(e.update(()=>{let i=bo(e,r);ah(i,t,e)}),t.preventDefault(),t.stopPropagation(),!0):t.dataTransfer&&dh(t.dataTransfer,o)?(t.preventDefault(),t.stopPropagation(),!0):!1}}function pT(o){return e=>{if(!e.clipboardData)return!1;let t=dh(e.clipboardData,o);return t&&e.preventDefault(),t}}function ch(o){let e=mT(o),t=pT(o),n=o.editor.registerCommand(Bo,e,qe),r=o.editor.registerCommand(ro,t,qe);return o.scrollDOM.addEventListener("drop",e),()=>{n(),r(),o.scrollDOM.removeEventListener("drop",e)}}var hd=class{constructor(e,t){this.editor=e,this.editorContainer=t,this.setupListeners()}setupListeners(){this.handleClick=this.handleClick.bind(this),this.editorContainer.addEventListener("click",this.handleClick)}handleClick(e){let t=e.target;t instanceof HTMLElement&&t.nodeName==="LI"&&t.classList.contains("task-list-item")&&(this.handleTaskListItemClick(t,e),e.preventDefault())}handleTaskListItemClick(e,t){let n=e.getBoundingClientRect();t.clientX<=n.right&&t.clientX>=n.left&&t.clientY>=n.top&&t.clientY<=n.bottom||this.editor.update(()=>{let i=J(e);Do(i)&&i.setChecked(!i.getChecked())})}teardown(){this.editorContainer.removeEventListener("click",this.handleClick)}};function uh(o,e){let t=new hd(o,e);return()=>{t.teardown()}}var Nd=class{constructor(e){this.tableSelections=new Map;this.unregisterMutationListener=()=>{};this.editor=e,this.init()}init(){this.unregisterMutationListener=this.editor.registerMutationListener(_t,e=>{for(let[t,n]of e)if(n==="created")this.editor.getEditorState().read(()=>{let r=X(t);it(r)&&this.initializeTableNode(r)});else if(n==="destroyed"){let r=this.tableSelections.get(t);r!==void 0&&(r.removeListeners(),this.tableSelections.delete(t))}})}initializeTableNode(e){let t=e.getKey(),n=this.editor.getElementByKey(t);if(n&&!this.tableSelections.has(t)){let r=Aa(e,n,this.editor,!1);this.tableSelections.set(t,r)}}teardown(){this.unregisterMutationListener();for(let[,e]of this.tableSelections)e.removeListeners()}};function fh(o){let e=new Nd(o);return()=>{e.teardown()}}function Xs(o,e){return ws(o,e),!0}function no(o){return e=>(o(e),!0)}function mh(o){return o.dispatchCommand(Ne,"code"),!0}var ph={"meta+s":()=>(window.$events.emit("editor-save-draft"),!0),"meta+enter":()=>(window.$events.emit("editor-save-page"),!0),"meta+1":o=>Xs(o,"h1"),"meta+2":o=>Xs(o,"h2"),"meta+3":o=>Xs(o,"h3"),"meta+4":o=>Xs(o,"h4"),"meta+5":no(oi),"meta+d":no(oi),"meta+6":no(ni),"meta+q":no(ni),"meta+7":no(ii),"meta+e":no(ii),"meta+8":mh,"meta+shift+e":mh,"meta+9":no(Cp),"meta+o":no(o=>ri(o,"number")),"meta+p":no(o=>ri(o,"bullet")),"meta+k":(o,e)=>(o.getEditorState().read(()=>{let t=j(T(),Rt);Bs(t,e)}),!0),"meta+shift+k":(o,e)=>(Ps(t=>{Os(o,{text:t.name,title:t.link,target:"",url:t.link})}),!0)};function gT(o){return e=>{let t=hT(e);ph[t]&&ph[t](o.editor,o)&&(e.stopPropagation(),e.preventDefault())}}function hT(o){return[(gh()?o.metaKey:o.ctrlKey)?"meta":"",o.shiftKey?"shift":"",o.key].filter(Boolean).join("+").toLowerCase()}function gh(){return window.navigator.userAgent.includes("Mac OS X")}function NT(o){o.registerCommand(dt,e=>gh()?e?.metaKey||!1:e?.ctrlKey||!1,qe)}function hh(o){let e=gT(o);return NT(o.editor),o.editor.registerRootListener((t,n)=>{t?.addEventListener("keydown",e),n?.removeEventListener("keydown",e)})}function xT(o){return Nt(o)||oo(o)}var xd=class{constructor(e){this.dom=null;this.mouseTracker=null;this.activeSelection="";this.context=e,this.scrollContainer=e.scrollDOM,this.onSelectionChange=this.onSelectionChange.bind(this),e.manager.onSelectionChange(this.onSelectionChange)}onSelectionChange(e){let t=e?.getNodes()||[];if(this.activeSelection&&this.hide(),t.length===1&&xT(t[0])){let n=t[0],r=n.getKey(),i=this.context.editor.getElementByKey(r);i&&i.nodeName==="SPAN"&&(i=i.firstElementChild),i&&this.showForNode(n,i)}}teardown(){this.context.manager.offSelectionChange(this.onSelectionChange),this.hide()}showForNode(e,t){this.dom=this.buildDOM();let n=b("span",{class:"editor-node-resizer-ghost"});Nt(e)&&(n=b("img",{src:t.getAttribute("src"),class:"editor-node-resizer-ghost"})),this.dom.append(n),this.context.scrollDOM.append(this.dom),this.updateDOMPosition(t),this.mouseTracker=this.setupTracker(this.dom,e,t),this.activeSelection=e.getKey()}updateDOMPosition(e){if(!this.dom)return;let t=this.scrollContainer.getBoundingClientRect(),n=e.getBoundingClientRect(),r=n.top-(t.top-this.scrollContainer.scrollTop),i=n.left-t.left;this.dom.style.top=`${r}px`,this.dom.style.left=`${i}px`,this.dom.style.width=n.width+"px",this.dom.style.height=n.height+"px"}updateDOMSize(e,t){this.dom&&(this.dom.style.width=e+"px",this.dom.style.height=t+"px")}hide(){this.mouseTracker?.teardown(),this.dom?.remove(),this.activeSelection=""}buildDOM(){let t=["nw","ne","se","sw"].map(n=>b("div",{class:`editor-node-resizer-handle ${n}`}));return b("div",{class:"editor-node-resizer"},t)}setupTracker(e,t,n){let r=0,i=0,s=0,l=!1,a=this,d=!1,f=!1,m=c=>{let u=c.x;d&&(u=0-u);let p=c.y;f&&(p=0-p);let g=Math.sqrt(Math.pow(Math.abs(u),2)+Math.pow(Math.abs(p),2)),C=u+p>0?g:0-g,N=Math.max(5,Math.round(r+C)),L=Math.round(N*s);return{width:N,height:L}};return new lr(e,".editor-node-resizer-handle",{down(c,u){a.dom?.classList.add("active"),a.context.editor.getEditorState().read(()=>{let p=n.getBoundingClientRect();r=t.getWidth()||p.width,i=t.getHeight()||p.height,t.getHeight()&&(l=!0),s=i/r}),d=u.classList.contains("nw")||u.classList.contains("sw"),f=u.classList.contains("nw")||u.classList.contains("ne")},move(c,u,p){let g=m(p);a.updateDOMSize(g.width,g.height)},up(c,u,p){let g=m(p);a.context.editor.update(()=>{t.setWidth(g.width),t.setHeight(l?g.height:0),a.context.manager.triggerLayoutUpdate(),requestAnimationFrame(()=>{a.updateDOMPosition(n)})}),a.dom?.classList.remove("active")}})}};function Nh(o){let e=new xd(o);return()=>{e.teardown()}}function Eh(o){if(o.length===1){let e=o[0];if(F(e)||Nt(e)||oo(e))return!0}return!1}function xh(o){let e=fe(o)?.getNodes()||[];Eh(e)&&o.update(()=>{e[0].remove()})}function ET(o,e){let t=fe(o)?.getNodes()||[];if(Eh(t)){let n=t[0],r=Ur(n)||n;if(r)return requestAnimationFrame(()=>{o.update(()=>{let i=nt();r.insertAfter(i),i.select()})}),e?.preventDefault(),!0}return!1}function TT(o,e){let t=e?.shiftKey?-40:40,r=T()?.getNodes()||[];return r.length>1||r.length===1&&Do(r[0].getParent())?(o.update(()=>{si(o,t)}),e?.preventDefault(),!0):!1}function Th(o){let e=o.editor.registerCommand(Ft,()=>(xh(o.editor),!1),Gt),t=o.editor.registerCommand(Bt,()=>(xh(o.editor),!1),Gt),n=o.editor.registerCommand(dt,i=>ET(o.editor,i),Gt),r=o.editor.registerCommand(Fo,i=>TT(o.editor,i),Gt);return()=>{e(),t(),n(),r()}}function sF(o,e,t={}){let n={namespace:"BookStackPageEditor",nodes:am(),onError:console.error,theme:{text:{bold:"editor-theme-bold",code:"editor-theme-code",italic:"editor-theme-italic",strikethrough:"editor-theme-strikethrough",subscript:"editor-theme-subscript",superscript:"editor-theme-superscript",underline:"editor-theme-underline",underlineStrikethrough:"editor-theme-underline-strikethrough"}}},r=b("div",{contenteditable:"true",class:"editor-content-area page-content"}),i=b("div",{class:"editor-content-wrap"},[r]);o.append(i),o.classList.add("editor-container"),o.setAttribute("dir",t.textDirection),t.darkMode&&o.classList.add("editor-dark");let s=na(n);s.setRootElement(r);let l=ih(o,r,i,s,t);Jt(sf(s),Ku(s,Uu(),300),hh(l),Th(l),sh(s,i),fh(s),uh(s,r),ch(l),Nh(l)),lh(s),rr(s,e);let a=document.getElementById("lexical-debug");a&&(a.hidden=!0);let d=!0;return s.registerUpdateListener(({dirtyElements:f,dirtyLeaves:m,editorState:c,prevEditorState:u})=>{!u._selection?.is(c._selection)&&s.update(()=>{let g=T();l.manager.triggerStateUpdate({editor:s,selection:g})}),(f.size>0||m.size>0)&&(d?d=!1:window.$events.emit("editor-html-change","")),a&&(a.textContent=JSON.stringify(c.toJSON(),null,2))}),window.debugEditorState=()=>{console.log(s.getEditorState().toJSON())},dm(l),new Ed(s)}var Ed=class{constructor(e){this.editor=e}async getContentAsHtml(){return await vs(this.editor)}};export{Ed as SimpleWysiwygEditorInterface,sF as createPageEditorInstance};
//# sourceMappingURL=wysiwyg.js.map