diff --git a/dev/checksums/vendor b/dev/checksums/vendor index a07df076a..68c6fdc16 100644 --- a/dev/checksums/vendor +++ b/dev/checksums/vendor @@ -1 +1 @@ -df9854136249aa316fa799eacb046eb3c14a6248fe5f3038ab7f500e83e83866 \ No newline at end of file +e23b5dd20fcaa1ba71ecc9e992c96003c73d7c22d85b024003bca3f9b7ac25d0 \ No newline at end of file diff --git a/public/dist/app.js b/public/dist/app.js index 765e294b1..b25d712b7 100644 --- a/public/dist/app.js +++ b/public/dist/app.js @@ -4,7 +4,7 @@ var Yi=Object.defineProperty;var Ji=i=>{throw TypeError(i)};var xs=(i,t,e)=>t in In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var Os="1.15.6";function ct(i){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(i)}var dt=ct(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),he=ct(/Edge/i),ho=ct(/firefox/i),re=ct(/safari/i)&&!ct(/chrome/i)&&!ct(/android/i),$i=ct(/iP(ad|od|hone)/i),Eo=ct(/chrome/i)&&ct(/android/i),Co={capture:!1,passive:!1};function C(i,t,e){i.addEventListener(t,e,!dt&&Co)}function E(i,t,e){i.removeEventListener(t,e,!dt&&Co)}function Ve(i,t){if(t){if(t[0]===">"&&(t=t.substring(1)),i)try{if(i.matches)return i.matches(t);if(i.msMatchesSelector)return i.msMatchesSelector(t);if(i.webkitMatchesSelector)return i.webkitMatchesSelector(t)}catch{return!1}return!1}}function Lo(i){return i.host&&i!==document&&i.host.nodeType?i.host:i.parentNode}function z(i,t,e,n){if(i){e=e||document;do{if(t!=null&&(t[0]===">"?i.parentNode===e&&Ve(i,t):Ve(i,t))||n&&i===e)return i;if(i===e)break}while(i=Lo(i))}return null}var uo=/\s+/g;function P(i,t,e){if(i&&t)if(i.classList)i.classList[e?"add":"remove"](t);else{var n=(" "+i.className+" ").replace(uo," ").replace(" "+t+" "," ");i.className=(n+(e?" "+t:"")).replace(uo," ")}}function g(i,t,e){var n=i&&i.style;if(n){if(e===void 0)return document.defaultView&&document.defaultView.getComputedStyle?e=document.defaultView.getComputedStyle(i,""):i.currentStyle&&(e=i.currentStyle),t===void 0?e:e[t];!(t in n)&&t.indexOf("webkit")===-1&&(t="-webkit-"+t),n[t]=e+(typeof e=="string"?"":"px")}}function Mt(i,t){var e="";if(typeof i=="string")e=i;else do{var n=g(i,"transform");n&&n!=="none"&&(e=n+" "+e)}while(!t&&(i=i.parentNode));var o=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return o&&new o(e)}function xo(i,t,e){if(i){var n=i.getElementsByTagName(t),o=0,s=n.length;if(e)for(;o=s:r=o<=s,!r)return n;if(n===st())break;n=yt(n,!1)}return!1}function _t(i,t,e,n){for(var o=0,s=0,r=i.children;s2&&arguments[2]!==void 0?arguments[2]:{},o=n.evt,s=As(n,Us);ue.pluginEvent.bind(w)(t,e,rt({dragEl:m,parentEl:H,ghostEl:y,rootEl:D,nextEl:$t,lastDownEl:Ne,cloneEl:A,cloneHidden:bt,dragStarted:ie,putSortable:N,activeSortable:w.active,originalEvent:o,oldIndex:Ft,oldDraggableIndex:le,newIndex:Y,newDraggableIndex:wt,hideGhostForTarget:Ao,unhideGhostForTarget:Io,cloneNowHidden:function(){bt=!0},cloneNowShown:function(){bt=!1},dispatchSortableEvent:function(a){W({sortable:e,name:a,originalEvent:o})}},s))};function W(i){ne(rt({putSortable:N,cloneEl:A,targetEl:m,rootEl:D,oldIndex:Ft,oldDraggableIndex:le,newIndex:Y,newDraggableIndex:wt},i))}var m,H,y,D,$t,Ne,A,bt,Ft,Y,le,wt,Ae,N,Nt=!1,We=!1,Ue=[],St,tt,gi,vi,go,vo,ie,Rt,ce,de=!1,Ie=!1,Fe,_,wi=[],xi=!1,je=[],Ke=typeof document<"u",He=$i,wo=he||dt?"cssFloat":"float",js=Ke&&!Eo&&!$i&&"draggable"in document.createElement("div"),$o=(function(){if(Ke){if(dt)return!1;var i=document.createElement("x");return i.style.cssText="pointer-events:auto",i.style.pointerEvents==="auto"}})(),Mo=function(t,e){var n=g(t),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),s=_t(t,0,e),r=_t(t,1,e),a=s&&g(s),l=r&&g(r),d=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+M(s).width,u=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+M(r).width;if(n.display==="flex")return n.flexDirection==="column"||n.flexDirection==="column-reverse"?"vertical":"horizontal";if(n.display==="grid")return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(s&&a.float&&a.float!=="none"){var p=a.float==="left"?"left":"right";return r&&(l.clear==="both"||l.clear===p)?"vertical":"horizontal"}return s&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||d>=o&&n[wo]==="none"||r&&n[wo]==="none"&&d+u>o)?"vertical":"horizontal"},zs=function(t,e,n){var o=n?t.left:t.top,s=n?t.right:t.bottom,r=n?t.width:t.height,a=n?e.left:e.top,l=n?e.right:e.bottom,d=n?e.width:e.height;return o===a||s===l||o+r/2===a+d/2},Ks=function(t,e){var n;return Ue.some(function(o){var s=o[F].options.emptyInsertThreshold;if(!(!s||Mi(o))){var r=M(o),a=t>=r.left-s&&t<=r.right+s,l=e>=r.top-s&&e<=r.bottom+s;if(a&&l)return n=o}}),n},Do=function(t){function e(s,r){return function(a,l,d,u){var p=a.options.group.name&&l.options.group.name&&a.options.group.name===l.options.group.name;if(s==null&&(r||p))return!0;if(s==null||s===!1)return!1;if(r&&s==="clone")return s;if(typeof s=="function")return e(s(a,l,d,u),r)(a,l,d,u);var f=(r?a:l).options.group.name;return s===!0||typeof s=="string"&&s===f||s.join&&s.indexOf(f)>-1}}var n={},o=t.group;(!o||Oe(o)!="object")&&(o={name:o}),n.name=o.name,n.checkPull=e(o.pull,!0),n.checkPut=e(o.put),n.revertClone=o.revertClone,t.group=n},Ao=function(){!$o&&y&&g(y,"display","none")},Io=function(){!$o&&y&&g(y,"display","")};Ke&&!Eo&&document.addEventListener("click",function(i){if(We)return i.preventDefault(),i.stopPropagation&&i.stopPropagation(),i.stopImmediatePropagation&&i.stopImmediatePropagation(),We=!1,!1},!0);var kt=function(t){if(m){t=t.touches?t.touches[0]:t;var e=Ks(t.clientX,t.clientY);if(e){var n={};for(var o in t)t.hasOwnProperty(o)&&(n[o]=t[o]);n.target=n.rootEl=e,n.preventDefault=void 0,n.stopPropagation=void 0,e[F]._onDragOver(n)}}},Xs=function(t){m&&m.parentNode[F]._isOutsideThisEl(t.target)};function w(i,t){if(!(i&&i.nodeType&&i.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(i));this.el=i,this.options=t=nt({},t),i[F]=this;var e={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(i.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return Mo(i,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(r,a){r.setData("Text",a.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:w.supportPointer!==!1&&"PointerEvent"in window&&(!re||$i),emptyInsertThreshold:5};ue.initializePlugins(this,i,e);for(var n in e)!(n in t)&&(t[n]=e[n]);Do(t);for(var o in this)o.charAt(0)==="_"&&typeof this[o]=="function"&&(this[o]=this[o].bind(this));this.nativeDraggable=t.forceFallback?!1:js,this.nativeDraggable&&(this.options.touchStartThreshold=1),t.supportPointer?C(i,"pointerdown",this._onTapStart):(C(i,"mousedown",this._onTapStart),C(i,"touchstart",this._onTapStart)),this.nativeDraggable&&(C(i,"dragover",this),C(i,"dragenter",this)),Ue.push(this.el),t.store&&t.store.get&&this.sort(t.store.get(this)||[]),nt(this,qs())}w.prototype={constructor:w,_isOutsideThisEl:function(t){!this.el.contains(t)&&t!==this.el&&(Rt=null)},_getDirection:function(t,e){return typeof this.options.direction=="function"?this.options.direction.call(this,t,e,m):this.options.direction},_onTapStart:function(t){if(t.cancelable){var e=this,n=this.el,o=this.options,s=o.preventOnFilter,r=t.type,a=t.touches&&t.touches[0]||t.pointerType&&t.pointerType==="touch"&&t,l=(a||t).target,d=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||l,u=o.filter;if(nr(n),!m&&!(/mousedown|pointerdown/.test(r)&&t.button!==0||o.disabled)&&!d.isContentEditable&&!(!this.nativeDraggable&&re&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=z(l,o.draggable,n,!1),!(l&&l.animated)&&Ne!==l)){if(Ft=R(l),le=R(l,o.draggable),typeof u=="function"){if(u.call(this,t,l,this)){W({sortable:e,rootEl:d,name:"filter",targetEl:l,toEl:n,fromEl:n}),U("filter",e,{evt:t}),s&&t.preventDefault();return}}else if(u&&(u=u.split(",").some(function(p){if(p=z(d,p.trim(),n,!1),p)return W({sortable:e,rootEl:p,name:"filter",targetEl:l,fromEl:n,toEl:n}),U("filter",e,{evt:t}),!0}),u)){s&&t.preventDefault();return}o.handle&&!z(d,o.handle,n,!1)||this._prepareDragStart(t,a,l)}}},_prepareDragStart:function(t,e,n){var o=this,s=o.el,r=o.options,a=s.ownerDocument,l;if(n&&!m&&n.parentNode===s){var d=M(n);if(D=s,m=n,H=m.parentNode,$t=m.nextSibling,Ne=n,Ae=r.group,w.dragged=m,St={target:m,clientX:(e||t).clientX,clientY:(e||t).clientY},go=St.clientX-d.left,vo=St.clientY-d.top,this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,m.style["will-change"]="all",l=function(){if(U("delayEnded",o,{evt:t}),w.eventCanceled){o._onDrop();return}o._disableDelayedDragEvents(),!ho&&o.nativeDraggable&&(m.draggable=!0),o._triggerDragStart(t,e),W({sortable:o,name:"choose",originalEvent:t}),P(m,r.chosenClass,!0)},r.ignore.split(",").forEach(function(u){xo(m,u.trim(),bi)}),C(a,"dragover",kt),C(a,"mousemove",kt),C(a,"touchmove",kt),r.supportPointer?(C(a,"pointerup",o._onDrop),!this.nativeDraggable&&C(a,"pointercancel",o._onDrop)):(C(a,"mouseup",o._onDrop),C(a,"touchend",o._onDrop),C(a,"touchcancel",o._onDrop)),ho&&this.nativeDraggable&&(this.options.touchStartThreshold=4,m.draggable=!0),U("delayStart",this,{evt:t}),r.delay&&(!r.delayOnTouchOnly||e)&&(!this.nativeDraggable||!(he||dt))){if(w.eventCanceled){this._onDrop();return}r.supportPointer?(C(a,"pointerup",o._disableDelayedDrag),C(a,"pointercancel",o._disableDelayedDrag)):(C(a,"mouseup",o._disableDelayedDrag),C(a,"touchend",o._disableDelayedDrag),C(a,"touchcancel",o._disableDelayedDrag)),C(a,"mousemove",o._delayedDragTouchMoveHandler),C(a,"touchmove",o._delayedDragTouchMoveHandler),r.supportPointer&&C(a,"pointermove",o._delayedDragTouchMoveHandler),o._dragStartTimer=setTimeout(l,r.delay)}else l()}},_delayedDragTouchMoveHandler:function(t){var e=t.touches?t.touches[0]:t;Math.max(Math.abs(e.clientX-this._lastX),Math.abs(e.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){m&&bi(m),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;E(t,"mouseup",this._disableDelayedDrag),E(t,"touchend",this._disableDelayedDrag),E(t,"touchcancel",this._disableDelayedDrag),E(t,"pointerup",this._disableDelayedDrag),E(t,"pointercancel",this._disableDelayedDrag),E(t,"mousemove",this._delayedDragTouchMoveHandler),E(t,"touchmove",this._delayedDragTouchMoveHandler),E(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||t.pointerType=="touch"&&t,!this.nativeDraggable||e?this.options.supportPointer?C(document,"pointermove",this._onTouchMove):e?C(document,"touchmove",this._onTouchMove):C(document,"mousemove",this._onTouchMove):(C(m,"dragend",this),C(D,"dragstart",this._onDragStart));try{document.selection?_e(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(t,e){if(Nt=!1,D&&m){U("dragStarted",this,{evt:e}),this.nativeDraggable&&C(document,"dragover",Xs);var n=this.options;!t&&P(m,n.dragClass,!1),P(m,n.ghostClass,!0),w.active=this,t&&this._appendGhost(),W({sortable:this,name:"start",originalEvent:e})}else this._nulling()},_emulateDragOver:function(){if(tt){this._lastX=tt.clientX,this._lastY=tt.clientY,Ao();for(var t=document.elementFromPoint(tt.clientX,tt.clientY),e=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(tt.clientX,tt.clientY),t!==e);)e=t;if(m.parentNode[F]._isOutsideThisEl(t),e)do{if(e[F]){var n=void 0;if(n=e[F]._onDragOver({clientX:tt.clientX,clientY:tt.clientY,target:t,rootEl:e}),n&&!this.options.dragoverBubble)break}t=e}while(e=Lo(e));Io()}},_onTouchMove:function(t){if(St){var e=this.options,n=e.fallbackTolerance,o=e.fallbackOffset,s=t.touches?t.touches[0]:t,r=y&&Mt(y,!0),a=y&&r&&r.a,l=y&&r&&r.d,d=He&&_&&mo(_),u=(s.clientX-St.clientX+o.x)/(a||1)+(d?d[0]-wi[0]:0)/(a||1),p=(s.clientY-St.clientY+o.y)/(l||1)+(d?d[1]-wi[1]:0)/(l||1);if(!w.active&&!Nt){if(n&&Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))=0&&(W({rootEl:H,name:"add",toEl:H,fromEl:D,originalEvent:t}),W({sortable:this,name:"remove",toEl:H,originalEvent:t}),W({rootEl:H,name:"sort",toEl:H,fromEl:D,originalEvent:t}),W({sortable:this,name:"sort",toEl:H,originalEvent:t})),N&&N.save()):Y!==Ft&&Y>=0&&(W({sortable:this,name:"update",toEl:H,originalEvent:t}),W({sortable:this,name:"sort",toEl:H,originalEvent:t})),w.active&&((Y==null||Y===-1)&&(Y=Ft,wt=le),W({sortable:this,name:"end",toEl:H,originalEvent:t}),this.save()))),this._nulling()},_nulling:function(){U("nulling",this),D=m=H=y=$t=A=Ne=bt=St=tt=ie=Y=wt=Ft=le=Rt=ce=N=Ae=w.dragged=w.ghost=w.clone=w.active=null,je.forEach(function(t){t.checked=!0}),je.length=gi=vi=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":m&&(this._onDragOver(t),Gs(t));break;case"selectstart":t.preventDefault();break}},toArray:function(){for(var t=[],e,n=this.el.children,o=0,s=n.length,r=this.options;oo.right+s||i.clientY>n.bottom&&i.clientX>n.left:i.clientY>o.bottom+s||i.clientX>n.right&&i.clientY>n.top}function Qs(i,t,e,n,o,s,r,a){var l=n?i.clientY:i.clientX,d=n?e.height:e.width,u=n?e.top:e.left,p=n?e.bottom:e.right,f=!1;if(!r){if(a&&Feu+d*s/2:lp-Fe)return-ce}else if(l>u+d*(1-o)/2&&lp-d*s/2)?l>u+d/2?1:-1:0}function tr(i){return R(m)1&&(b.forEach(function(a){s.addAnimationState({target:a,rect:j?M(a):r}),mi(a),a.fromRect=r,n.removeAnimationState(a)}),j=!1,or(!this.options.removeCloneOnHide,o))},dragOverCompleted:function(e){var n=e.sortable,o=e.isOwner,s=e.insertion,r=e.activeSortable,a=e.parentEl,l=e.putSortable,d=this.options;if(s){if(o&&r._hideClone(),te=!1,d.animation&&b.length>1&&(j||!o&&!r.options.sort&&!l)){var u=M($,!1,!0,!0);b.forEach(function(f){f!==$&&(fo(f,u),a.appendChild(f))}),j=!0}if(!o)if(j||Re(),b.length>1){var p=Pe;r._showClone(n),r.options.animation&&!Pe&&p&&G.forEach(function(f){r.addAnimationState({target:f,rect:ee}),f.fromRect=ee,f.thisAnimationDuration=null})}else r._showClone(n)}},dragOverAnimationCapture:function(e){var n=e.dragRect,o=e.isOwner,s=e.activeSortable;if(b.forEach(function(a){a.thisAnimationDuration=null}),s.options.animation&&!o&&s.multiDrag.isMultiDrag){ee=nt({},n);var r=Mt($,!0);ee.top-=r.f,ee.left-=r.e}},dragOverAnimationComplete:function(){j&&(j=!1,Re())},drop:function(e){var n=e.originalEvent,o=e.rootEl,s=e.parentEl,r=e.sortable,a=e.dispatchSortableEvent,l=e.oldIndex,d=e.putSortable,u=d||this.sortable;if(n){var p=this.options,f=s.children;if(!Ot)if(p.multiDragKey&&!this.multiDragKeyDown&&this._deselectMultiDrag(),P($,p.selectedClass,!~b.indexOf($)),~b.indexOf($))b.splice(b.indexOf($),1),Qt=null,ne({sortable:r,rootEl:o,name:"deselect",targetEl:$,originalEvent:n});else{if(b.push($),ne({sortable:r,rootEl:o,name:"select",targetEl:$,originalEvent:n}),n.shiftKey&&Qt&&r.el.contains(Qt)){var v=R(Qt),L=R($);~v&&~L&&v!==L&&(function(){var x,k;L>v?(k=v,x=L):(k=L,x=v+1);for(var O=p.filter;k1){var S=M($),V=R($,":not(."+this.options.selectedClass+")");if(!te&&p.animation&&($.thisAnimationDuration=null),u.captureAnimationState(),!te&&(p.animation&&($.fromRect=S,b.forEach(function(x){if(x.thisAnimationDuration=null,x!==$){var k=j?M(x):S;x.fromRect=k,u.addAnimationState({target:x,rect:k})}})),Re(),b.forEach(function(x){f[V]?s.insertBefore(x,f[V]):s.appendChild(x),V++}),l===R($))){var J=!1;b.forEach(function(x){if(x.sortableIndex!==R(x)){J=!0;return}}),J&&(a("update"),a("sort"))}b.forEach(function(x){mi(x)}),u.animateAll()}et=u}(o===s||d&&d.lastPutMode!=="clone")&&G.forEach(function(x){x.parentNode&&x.parentNode.removeChild(x)})}},nullingGlobal:function(){this.isMultiDrag=Ot=!1,G.length=0},destroyGlobal:function(){this._deselectMultiDrag(),E(document,"pointerup",this._deselectMultiDrag),E(document,"mouseup",this._deselectMultiDrag),E(document,"touchend",this._deselectMultiDrag),E(document,"keydown",this._checkKeyDown),E(document,"keyup",this._checkKeyUp)},_deselectMultiDrag:function(e){if(!(typeof Ot<"u"&&Ot)&&et===this.sortable&&!(e&&z(e.target,this.options.draggable,this.sortable.el,!1))&&!(e&&e.button!==0))for(;b.length;){var n=b[0];P(n,this.options.selectedClass,!1),b.shift(),ne({sortable:this.sortable,rootEl:this.sortable.el,name:"deselect",targetEl:n,originalEvent:e})}},_checkKeyDown:function(e){e.key===this.options.multiDragKey&&(this.multiDragKeyDown=!0)},_checkKeyUp:function(e){e.key===this.options.multiDragKey&&(this.multiDragKeyDown=!1)}},nt(i,{pluginName:"multiDrag",utils:{select:function(e){var n=e.parentNode[F];!n||!n.options.multiDrag||~b.indexOf(e)||(et&&et!==n&&(et.multiDrag._deselectMultiDrag(),et=n),P(e,n.options.selectedClass,!0),b.push(e))},deselect:function(e){var n=e.parentNode[F],o=b.indexOf(e);!n||!n.options.multiDrag||!~o||(P(e,n.options.selectedClass,!1),b.splice(o,1))}},eventProperties:function(){var e=this,n=[],o=[];return b.forEach(function(s){n.push({multiDragElement:s,index:s.sortableIndex});var r;j&&s!==$?r=-1:j?r=R(s,":not(."+e.options.selectedClass+")"):r=R(s),o.push({multiDragElement:s,index:r})}),{items:Is(b),clones:[].concat(G),oldIndicies:n,newIndicies:o}},optionListeners:{multiDragKey:function(e){return e=e.toLowerCase(),e==="ctrl"?e="Control":e.length>1&&(e=e.charAt(0).toUpperCase()+e.substr(1)),e}}})}function or(i,t){b.forEach(function(e,n){var o=t.children[e.sortableIndex+(i?Number(n):0)];o?t.insertBefore(e,o):t.appendChild(e)})}function yo(i,t){G.forEach(function(e,n){var o=t.children[e.sortableIndex+(i?Number(n):0)];o?t.insertBefore(e,o):t.appendChild(e)})}function Re(){b.forEach(function(i){i!==$&&i.parentNode&&i.parentNode.removeChild(i)})}w.mount(new ir);w.mount(Ii,Ai);var ht=w;var Po={name(i,t){let e=i.getAttribute("data-name").trim().toLowerCase(),n=t.getAttribute("data-name").trim().toLowerCase();return e.localeCompare(n)},created(i,t){let e=Number(i.getAttribute("data-created"));return Number(t.getAttribute("data-created"))-e},updated(i,t){let e=Number(i.getAttribute("data-updated"));return Number(t.getAttribute("data-updated"))-e},chaptersFirst(i,t){let e=i.getAttribute("data-type"),n=t.getAttribute("data-type");return e===n?0:e==="chapter"?-1:1},chaptersLast(i,t){let e=i.getAttribute("data-type"),n=t.getAttribute("data-type");return e===n?0:e==="chapter"?1:-1}},Ro={up:{active(i,t){return!(i.previousElementSibling===null&&!t)},run(i,t){(i.previousElementSibling||t).insertAdjacentElement("beforebegin",i)}},down:{active(i,t){return!(i.nextElementSibling===null&&!t)},run(i,t){(i.nextElementSibling||t).insertAdjacentElement("afterend",i)}},next_book:{active(i,t,e){return e.nextElementSibling!==null},run(i,t,e){e.nextElementSibling.querySelector("ul").prepend(i)}},prev_book:{active(i,t,e){return e.previousElementSibling!==null},run(i,t,e){e.previousElementSibling.querySelector("ul").appendChild(i)}},next_chapter:{active(i,t){return i.dataset.type==="page"&&this.getNextChapter(i,t)},run(i,t){this.getNextChapter(i,t).querySelector("ul").prepend(i)},getNextChapter(i,t){let e=t||i,n=Array.from(e.parentElement.children),o=n.indexOf(e);return n.slice(o+1).find(s=>s.dataset.type==="chapter")}},prev_chapter:{active(i,t){return i.dataset.type==="page"&&this.getPrevChapter(i,t)},run(i,t){this.getPrevChapter(i,t).querySelector("ul").append(i)},getPrevChapter(i,t){let e=t||i,n=Array.from(e.parentElement.children),o=n.indexOf(e);return n.slice(0,o).reverse().find(s=>s.dataset.type==="chapter")}},book_end:{active(i,t){return t||t===null&&i.nextElementSibling},run(i,t,e){e.querySelector("ul").append(i)}},book_start:{active(i,t){return t||t===null&&i.previousElementSibling},run(i,t,e){e.querySelector("ul").prepend(i)}},before_chapter:{active(i,t){return t},run(i,t){t.insertAdjacentElement("beforebegin",i)}},after_chapter:{active(i,t){return t},run(i,t){t.insertAdjacentElement("afterend",i)}}},Xe=class extends h{setup(){this.container=this.$el,this.sortContainer=this.$refs.sortContainer,this.input=this.$refs.input,ht.mount(new Bo);let t=this.container.querySelector(".sort-box");this.setupBookSortable(t),this.setupSortPresets(),this.setupMoveActions(),window.$events.listen("entity-select-change",this.bookSelect.bind(this))}setupMoveActions(){this.container.addEventListener("click",t=>{if(t.target.matches("[data-move]")){let e=t.target.getAttribute("data-move"),n=t.target.closest("[data-id]");this.runSortAction(n,e)}}),this.updateMoveActionStateForAll()}setupSortPresets(){let t="",e=!1,n=["name","created","updated"];this.sortContainer.addEventListener("click",o=>{let s=o.target.closest(".sort-box-options [data-sort]");if(!s)return;o.preventDefault();let r=s.closest(".sort-box").querySelectorAll("ul"),a=s.getAttribute("data-sort");e=t===a?!e:!1;let l=Po[a];e&&n.includes(a)&&(l=function(u,p){return 0-Po[a](u,p)});for(let d of r)Array.from(d.children).filter(p=>p.matches("li")).sort(l).forEach(p=>{d.appendChild(p)});t=a,this.updateMapInput()})}bookSelect(t){if(this.container.querySelector(`[data-type="book"][data-id="${t.id}"]`)!==null)return;let n=`${t.link}/sort-item`;window.$http.get(n).then(o=>{let s=Q(o.data);this.sortContainer.append(s),this.setupBookSortable(s),this.updateMoveActionStateForAll(),s.querySelector("summary").focus()})}setupBookSortable(t){let e=Array.from(t.querySelectorAll(".sort-list, .sortable-page-sublist")),n={name:"book",pull:["book","chapter"],put:["book","chapter"]},o={name:"chapter",pull:["book","chapter"],put(s,r,a){return a.getAttribute("data-type")==="page"}};for(let s of e)ht.create(s,{group:s.classList.contains("sort-list")?n:o,animation:150,fallbackOnBody:!0,swapThreshold:.65,onSort:()=>{this.ensureNoNestedChapters(),this.updateMapInput(),this.updateMoveActionStateForAll()},dragClass:"bg-white",ghostClass:"primary-background-light",multiDrag:!0,multiDragKey:"Control",selectedClass:"sortable-selected"})}ensureNoNestedChapters(){let t=this.container.querySelectorAll('[data-type="chapter"] [data-type="chapter"]');for(let e of t)e.parentElement.closest('[data-type="chapter"]').insertAdjacentElement("afterend",e)}updateMapInput(){let t=this.buildEntityMap();this.input.value=JSON.stringify(t)}buildEntityMap(){let t=[],e=this.container.querySelectorAll(".sort-list");for(let n of e){let o=n.closest('[data-type="book"]').getAttribute("data-id"),s=Array.from(n.children).filter(r=>r.matches('[data-type="page"], [data-type="chapter"]'));for(let r=0;r{for(let r of o)i.style.removeProperty(r);i.style.removeProperty("transition"),i.removeEventListener("transitionend",s),Ge.delete(i),n&&n()};setTimeout(()=>{i.style.transition=`all ease-in-out ${e}ms`;for(let r of o)i.style.setProperty(r,t[r][1]);i.addEventListener("transitionend",s),Ge.set(i,s)},15)}function me(i){Ge.has(i)&&Ge.get(i)()}function Oo(i,t=400,e=null){me(i),i.style.display="block",pe(i,{opacity:["0","1"]},t,()=>{e&&e()})}function No(i,t=400,e=null){me(i),pe(i,{opacity:["1","0"]},t,()=>{i.style.display="none",e&&e()})}function qt(i,t=400){me(i);let e=i.getBoundingClientRect().height,n=getComputedStyle(i),o=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom"),r={"max-height":[`${e}px`,"0px"],overflow:["hidden","hidden"],"padding-top":[o,"0px"],"padding-bottom":[s,"0px"]};pe(i,r,t,()=>{i.style.display="none"})}function Vt(i,t=400){me(i),i.style.display="block";let e=i.getBoundingClientRect().height,n=getComputedStyle(i),o=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom"),r={"max-height":["0px",`${e}px`],overflow:["hidden","hidden"],"padding-top":["0px",o],"padding-bottom":["0px",s]};pe(i,r,t)}function Fo(i,t=400){let e=i.getBoundingClientRect().height,n=getComputedStyle(i),o=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom");return()=>{me(i);let r=i.getBoundingClientRect().height,a=getComputedStyle(i),l=a.getPropertyValue("padding-top"),d=a.getPropertyValue("padding-bottom"),u={height:[`${e}px`,`${r}px`],overflow:["hidden","hidden"],"padding-top":[o,l],"padding-bottom":[s,d]};pe(i,u,t)}}var Ye=class extends h{setup(){this.list=this.$refs.list,this.toggle=this.$refs.toggle,this.isOpen=this.toggle.classList.contains("open"),this.toggle.addEventListener("click",this.click.bind(this))}open(){this.toggle.classList.add("open"),this.toggle.setAttribute("aria-expanded","true"),Vt(this.list,180),this.isOpen=!0}close(){this.toggle.classList.remove("open"),this.toggle.setAttribute("aria-expanded","false"),qt(this.list,180),this.isOpen=!1}click(t){t.preventDefault(),this.isOpen?this.close():this.open()}};var Je=class extends h{constructor(){super(...arguments);c(this,"editor",null);c(this,"saveCallback",null);c(this,"cancelCallback",null);c(this,"history",{});c(this,"historyKey","code_history")}setup(){this.container=this.$refs.container,this.popup=this.$el,this.editorInput=this.$refs.editor,this.languageButtons=this.$manyRefs.languageButton,this.languageOptionsContainer=this.$refs.languageOptionsContainer,this.saveButton=this.$refs.saveButton,this.languageInput=this.$refs.languageInput,this.historyDropDown=this.$refs.historyDropDown,this.historyList=this.$refs.historyList,this.favourites=new Set(this.$opts.favourites.split(",")),this.setupListeners(),this.setupFavourites()}setupListeners(){this.container.addEventListener("keydown",e=>{e.ctrlKey&&e.key==="Enter"&&this.save()}),T(this.languageButtons,e=>{let n=e.target.dataset.lang;this.languageInput.value=n,this.languageInputChange(n)}),Ht(this.languageInput,()=>this.save()),this.languageInput.addEventListener("input",()=>this.languageInputChange(this.languageInput.value)),T(this.saveButton,()=>this.save()),I(this.historyList,"button","click",(e,n)=>{e.preventDefault();let o=n.dataset.time;this.editor&&this.editor.setContent(this.history[o])})}setupFavourites(){for(let e of this.languageButtons)this.setupFavouritesForButton(e);this.sortLanguageList()}setupFavouritesForButton(e){let n=e.dataset.lang,o=this.favourites.has(n);e.setAttribute("data-favourite",o?"true":"false"),I(e.parentElement,".lang-option-favorite-toggle","click",()=>{o=!o,o?this.favourites.add(n):this.favourites.delete(n),e.setAttribute("data-favourite",o?"true":"false"),window.$http.patch("/preferences/update-code-language-favourite",{language:n,active:o}),this.sortLanguageList(),o&&e.scrollIntoView({block:"center",behavior:"smooth"})})}sortLanguageList(){let e=this.languageButtons.sort((n,o)=>{let s=n.dataset.favourite==="true",r=o.dataset.favourite==="true";return s&&!r?-1:r&&!s||n.dataset.lang>o.dataset.lang?1:-1}).map(n=>n.parentElement);for(let n of e)this.languageOptionsContainer.append(n)}save(){this.saveCallback&&this.saveCallback(this.editor.getContent(),this.languageInput.value),this.hide()}async open(e,n,o,s,r){this.languageInput.value=n,this.saveCallback=s,this.cancelCallback=r,await this.show(),this.languageInputChange(n),this.editor.setContent(e),this.setDirection(o)}async show(){let e=await window.importVersioned("code");this.editor||(this.editor=e.popupEditor(this.editorInput,this.languageInput.value)),this.loadHistory(),this.getPopup().show(()=>{this.editor.focus()},()=>{this.addHistory(),this.cancelCallback&&this.cancelCallback()})}setDirection(e){let n=this.editorInput.parentElement;e?n.setAttribute("dir",e):n.removeAttribute("dir")}hide(){this.getPopup().hide(),this.addHistory()}getPopup(){return window.$components.firstOnElement(this.popup,"popup")}async updateEditorMode(e){this.editor.setMode(e,this.editor.getContent())}languageInputChange(e){this.updateEditorMode(e);let n=e.toLowerCase();for(let o of this.languageButtons){let s=o.dataset.lang.toLowerCase().trim(),r=n===s;o.classList.toggle("active",r),r&&o.scrollIntoView({block:"center",behavior:"smooth"})}}loadHistory(){this.history=JSON.parse(window.sessionStorage.getItem(this.historyKey)||"{}");let e=Object.keys(this.history).reverse();this.historyDropDown.classList.toggle("hidden",e.length===0),this.historyList.innerHTML=e.map(n=>{let o=new Date(parseInt(n,10)).toLocaleTimeString();return`
  • `}).join("")}addHistory(){if(!this.editor)return;let e=this.editor.getContent();if(!e)return;let n=Object.keys(this.history).pop();if(this.history[n]===e)return;this.history[String(Date.now())]=e;let o=JSON.stringify(this.history);window.sessionStorage.setItem(this.historyKey,o)}};var Ze=class extends h{setup(){let t=this.$el;t.querySelectorAll("pre").length>0&&window.importVersioned("code").then(n=>{n.highlightWithin(t)})}};var Qe=class extends h{async setup(){let{mode:t}=this.$opts;(await window.importVersioned("code")).inlineEditor(this.$el,t)}};var tn=class extends h{setup(){this.container=this.$el,this.trigger=this.$refs.trigger,this.content=this.$refs.content,this.trigger&&(this.trigger.addEventListener("click",this.toggle.bind(this)),this.openIfContainsError())}open(){this.container.classList.add("open"),this.trigger.setAttribute("aria-expanded","true"),Vt(this.content,300)}close(){this.container.classList.remove("open"),this.trigger.setAttribute("aria-expanded","false"),qt(this.content,300)}toggle(){this.container.classList.contains("open")?this.close():this.open()}openIfContainsError(){this.content.querySelector(".text-neg.text-small")&&this.open()}};var en=class extends h{setup(){this.container=this.$el,this.confirmButton=this.$refs.confirm,this.res=null,T(this.confirmButton,()=>{this.sendResult(!0),this.getPopup().hide()})}show(){return this.getPopup().show(null,()=>{this.sendResult(!1)}),new Promise(t=>{this.res=t})}getPopup(){return window.$components.firstOnElement(this.container,"popup")}sendResult(t){this.res&&(this.res(t),this.res=null)}};var nn=class extends h{setup(){this.container=this.$el,this.checkbox=this.container.querySelector("input[type=checkbox]"),this.display=this.container.querySelector('[role="checkbox"]'),this.checkbox.addEventListener("change",this.stateChange.bind(this)),this.container.addEventListener("keydown",this.onKeyDown.bind(this))}onKeyDown(t){(t.key===" "||t.key==="Enter")&&(t.preventDefault(),this.toggle())}toggle(){this.checkbox.checked=!this.checkbox.checked,this.checkbox.dispatchEvent(new Event("change")),this.stateChange()}stateChange(){let t=this.checkbox.checked?"true":"false";this.display.setAttribute("aria-checked",t)}};var on=class extends h{setup(){this.container=this.$el,this.dealtWith=!1,this.container.addEventListener("toggle",this.onToggle.bind(this))}onToggle(){this.dealtWith||(this.container.querySelector("pre")&&window.importVersioned("code").then(t=>{t.highlightWithin(this.container)}),this.dealtWith=!0)}};var sn=class extends h{setup(){this.container=this.$el,this.menu=this.$refs.menu,this.toggle=this.$refs.toggle,this.moveMenu=this.$opts.moveMenu,this.bubbleEscapes=this.$opts.bubbleEscapes==="true",this.direction=document.dir==="rtl"?"right":"left",this.body=document.body,this.showing=!1,this.hide=this.hide.bind(this),this.setupListeners()}show(t=null){this.hideAll(),this.menu.style.display="block",this.menu.classList.add("anim","menuIn"),this.toggle.setAttribute("aria-expanded","true");let e=this.menu.getBoundingClientRect(),n=0,o=this.toggle.getBoundingClientRect().height,s=lo(this.menu).getBoundingClientRect(),r=e.bottom>s.bottom,a=this.container.getBoundingClientRect();if(this.moveMenu&&(this.body.appendChild(this.menu),this.menu.style.position="fixed",this.menu.style.width=`${e.width}px`,this.menu.style.left=`${e.left}px`,r?n=window.innerHeight-e.top-o/2:n=e.top),r){this.menu.style.top="initial",this.menu.style.bottom=`${n}px`;let u=window.innerHeight-40-(window.innerHeight-a.bottom);this.menu.style.maxHeight=`${Math.floor(u)}px`}else{this.menu.style.top=`${n}px`,this.menu.style.bottom="initial";let u=window.innerHeight-40-a.top;this.menu.style.maxHeight=`${Math.floor(u)}px`}this.menu.addEventListener("mouseleave",this.hide),window.addEventListener("click",u=>{this.menu.contains(u.target)||this.hide()});let l=this.menu.querySelector("input");l!==null&&l.focus(),this.showing=!0;let d=new Event("show");this.container.dispatchEvent(d),t&&t.stopPropagation()}hideAll(){for(let t of window.$components.get("dropdown"))t.hide()}hide(){this.menu.style.display="none",this.menu.classList.remove("anim","menuIn"),this.toggle.setAttribute("aria-expanded","false"),this.menu.style.top="",this.menu.style.bottom="",this.menu.style.maxHeight="",this.moveMenu&&(this.menu.style.position="",this.menu.style[this.direction]="",this.menu.style.width="",this.menu.style.left="",this.container.appendChild(this.menu)),this.showing=!1}setupListeners(){let t=new gt(this.container,e=>{this.hide(),this.toggle.focus(),this.bubbleEscapes||e.stopPropagation()},e=>{e.target.nodeName==="INPUT"&&(e.preventDefault(),e.stopPropagation()),this.hide()});this.moveMenu&&t.shareHandlingToEl(this.menu),this.container.addEventListener("click",e=>{Array.from(this.menu.querySelectorAll("a")).includes(e.target)&&this.hide()}),T(this.toggle,e=>{e.stopPropagation(),e.preventDefault(),this.show(e),e instanceof KeyboardEvent&&t.focusNext()})}};var rn=class extends h{setup(){this.elem=this.$el,this.searchInput=this.$refs.searchInput,this.loadingElem=this.$refs.loading,this.listContainerElem=this.$refs.listContainer,this.localSearchSelector=this.$opts.localSearchSelector,this.url=this.$opts.url,this.elem.addEventListener("show",this.onShow.bind(this)),this.searchInput.addEventListener("input",this.onSearch.bind(this)),this.runAjaxSearch=mt(this.runAjaxSearch,300,!1)}onShow(){this.loadList()}onSearch(){let t=this.searchInput.value.toLowerCase().trim();this.localSearchSelector?this.runLocalSearch(t):(this.toggleLoading(!0),this.listContainerElem.innerHTML="",this.runAjaxSearch(t))}runAjaxSearch(t){this.loadList(t)}runLocalSearch(t){let e=this.listContainerElem.querySelectorAll(this.localSearchSelector);for(let n of e){let o=!t||n.textContent.toLowerCase().includes(t);n.style.display=o?"flex":"none",n.classList.toggle("hidden",!o)}}async loadList(t=""){this.listContainerElem.innerHTML="",this.toggleLoading(!0);try{let e=await window.$http.get(this.getAjaxUrl(t)),n=Fo(this.listContainerElem,80);this.listContainerElem.innerHTML=e.data,n()}catch(e){console.error(e)}this.toggleLoading(!1),this.localSearchSelector&&this.onSearch()}getAjaxUrl(t=null){if(!t)return this.url;let e=this.url.includes("?")?"&":"?";return`${this.url}${e}search=${encodeURIComponent(t)}`}toggleLoading(t=!1){this.loadingElem.style.display=t?"block":"none"}};var Wt=class{constructor(t){c(this,"data");this.data=t}hasItems(){return!!this.data&&!!this.data.types&&this.data.types.length>0}containsTabularData(){let t=this.data.getData("text/rtf");return!!t&&t.includes("\\trowd")}getImages(){return this.getFiles().filter(t=>t.type.includes("image"))}getFiles(){let{files:t}=this.data;return[...t]}};async function Hi(i){if(window.isSecureContext&&navigator.clipboard){await navigator.clipboard.writeText(i);return}let t=document.createElement("textarea");t.setAttribute("style","position: absolute; left: -1000px; top: -1000px;"),t.value=i,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}var an=class extends h{setup(){this.container=this.$el,this.statusArea=this.$refs.statusArea,this.dropTarget=this.$refs.dropTarget,this.selectButtons=this.$manyRefs.selectButton||[],this.isActive=!0,this.url=this.$opts.url,this.method=(this.$opts.method||"post").toUpperCase(),this.successMessage=this.$opts.successMessage,this.errorMessage=this.$opts.errorMessage,this.uploadLimitMb=Number(this.$opts.uploadLimit),this.uploadLimitMessage=this.$opts.uploadLimitMessage,this.zoneText=this.$opts.zoneText,this.fileAcceptTypes=this.$opts.fileAccept,this.allowMultiple=this.$opts.allowMultiple==="true",this.setupListeners()}toggleActive(t){this.isActive=t}setupListeners(){T(this.selectButtons,this.manualSelectHandler.bind(this)),this.setupDropTargetHandlers()}setupDropTargetHandlers(){let t=0,e=()=>{this.hideOverlay(),t=0};this.dropTarget.addEventListener("dragenter",n=>{n.preventDefault(),t+=1,t===1&&this.isActive&&this.showOverlay()}),this.dropTarget.addEventListener("dragover",n=>{n.preventDefault()}),this.dropTarget.addEventListener("dragend",e),this.dropTarget.addEventListener("dragleave",()=>{t-=1,t===0&&e()}),this.dropTarget.addEventListener("drop",n=>{if(n.preventDefault(),e(),!this.isActive)return;let s=new Wt(n.dataTransfer).getFiles();for(let r of s)this.createUploadFromFile(r)})}manualSelectHandler(){let t=ot("input",{type:"file",style:"left: -400px; visibility: hidden; position: fixed;",accept:this.fileAcceptTypes,multiple:this.allowMultiple?"":null});this.container.append(t),t.click(),t.addEventListener("change",()=>{for(let e of t.files)this.createUploadFromFile(e);t.remove()})}showOverlay(){if(!this.dropTarget.querySelector(".dropzone-overlay")){let e=ot("div",{class:"dropzone-overlay"},[this.zoneText]);this.dropTarget.append(e)}}hideOverlay(){let t=this.dropTarget.querySelector(".dropzone-overlay");t&&t.remove()}createUploadFromFile(t){let{dom:e,status:n,progress:o,dismiss:s}=this.createDomForFile(t);this.statusArea.append(e);let r=this,a={file:t,dom:e,updateProgress(l){o.textContent=`${l}%`,o.style.width=`${l}%`},markError(l){n.setAttribute("data-status","error"),n.textContent=l,Zt(e),this.updateProgress(100)},markSuccess(l){n.setAttribute("data-status","success"),n.textContent=l,Zt(e),setTimeout(s,2400),r.$emit("upload-success",{name:t.name})}};return t.size>this.uploadLimitMb*1e6?(a.markError(this.uploadLimitMessage),a):(this.startXhrForUpload(a),a)}startXhrForUpload(t){let e=new FormData;e.append("file",t.file,t.file.name),this.method!=="POST"&&e.append("_method",this.method);let n=this,o=window.$http.createXMLHttpRequest("POST",this.url,{error(){t.markError(n.errorMessage)},readystatechange(){this.readyState===XMLHttpRequest.DONE&&this.status===200?t.markSuccess(n.successMessage):this.readyState===XMLHttpRequest.DONE&&this.status>=400&&t.markError(window.$http.formatErrorResponseText(this.responseText))}});o.upload.addEventListener("progress",s=>{let r=Math.min(Math.ceil(s.loaded/s.total*100),100);t.updateProgress(r)}),o.setRequestHeader("Accept","application/json"),o.send(e)}createDomForFile(t){let e=ot("img",{src:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9.224 7.373a.924.924 0 0 0-.92.925l-.006 7.404c0 .509.412.925.921.925h5.557a.928.928 0 0 0 .926-.925v-5.553l-2.777-2.776Zm3.239 3.239V8.067l2.545 2.545z' style='fill:%23000;fill-opacity:.75'/%3E%3C/svg%3E"}),n=ot("div",{class:"dropzone-file-item-status"},[]),o=ot("div",{class:"dropzone-file-item-progress"}),s=ot("div",{class:"dropzone-file-item-image-wrap"},[e]),r=ot("div",{class:"dropzone-file-item"},[s,ot("div",{class:"dropzone-file-item-text-wrap"},[ot("div",{class:"dropzone-file-item-label"},[t.name]),Bt(),n]),o]);t.type.startsWith("image/")&&(e.src=URL.createObjectURL(t));let a=()=>{r.classList.add("dismiss"),r.addEventListener("animationend",()=>{r.remove()})};return r.addEventListener("click",a),{dom:r,progress:o,status:n,dismiss:a}}};var ln=class extends h{constructor(){super(...arguments);c(this,"container");c(this,"buttons");c(this,"contentElements");c(this,"toggleButton");c(this,"editorWrapEl");c(this,"open",!1);c(this,"tab","")}setup(){this.container=this.$el,this.buttons=this.$manyRefs.tabButton,this.contentElements=this.$manyRefs.tabContent,this.toggleButton=this.$refs.toggle,this.editorWrapEl=this.container.closest(".page-editor"),this.setupListeners(),this.setActiveTab(this.contentElements[0].dataset.tabContent||"")}setupListeners(){this.toggleButton.addEventListener("click",()=>this.toggle()),this.container.addEventListener("click",e=>{let n=e.target.closest("button");if(n instanceof HTMLButtonElement&&this.buttons.includes(n)){let o=n.dataset.tab||"";this.setActiveTab(o,!0)}})}toggle(){this.container.classList.toggle("open");let e=this.container.classList.contains("open");this.toggleButton.setAttribute("aria-expanded",e?"true":"false"),this.editorWrapEl.classList.toggle("toolbox-open",e),this.open=e,this.emitState()}setActiveTab(e,n=!1){for(let o of this.buttons)o.classList.remove("active"),o.dataset.tab===e&&o.classList.add("active");for(let o of this.contentElements)o.style.display="none",o.dataset.tabContent===e&&(o.style.display="block");n&&!this.container.classList.contains("open")&&this.toggle(),this.tab=e,this.emitState()}emitState(){let e={tab:this.tab,open:this.open};this.$emit("change",e)}};var cn=class extends h{setup(){this.container=this.$el,this.entityType=this.$opts.entityType,this.everyoneInheritToggle=this.$refs.everyoneInherit,this.roleSelect=this.$refs.roleSelect,this.roleContainer=this.$refs.roleContainer,this.setupListeners()}setupListeners(){this.everyoneInheritToggle.addEventListener("change",t=>{let e=t.target.checked,n=document.querySelectorAll('input[name^="permissions[0]["]');for(let o of n)o.disabled=e,o.checked=!1}),this.container.addEventListener("click",t=>{let e=t.target.closest("button");e&&e.dataset.roleId&&this.removeRowOnButtonClick(e)}),this.roleSelect.addEventListener("change",()=>{let t=this.roleSelect.value;t&&this.addRoleRow(t)})}async addRoleRow(t){this.roleSelect.disabled=!0;let e=this.roleSelect.querySelector(`option[value="${t}"]`);e&&e.remove();let n=await window.$http.get(`/permissions/form-row/${this.entityType}/${t}`),o=Q(n.data);this.roleContainer.append(o),this.roleSelect.disabled=!1}removeRowOnButtonClick(t){let e=t.closest(".item-list-row"),{roleId:n}=t.dataset,{roleName:o}=t.dataset,s=document.createElement("option");s.value=n,s.textContent=o,this.roleSelect.append(s),e.remove()}};var dn=class extends h{setup(){this.entityId=this.$opts.entityId,this.entityType=this.$opts.entityType,this.contentView=this.$refs.contentView,this.searchView=this.$refs.searchView,this.searchResults=this.$refs.searchResults,this.searchInput=this.$refs.searchInput,this.searchForm=this.$refs.searchForm,this.clearButton=this.$refs.clearButton,this.loadingBlock=this.$refs.loadingBlock,this.setupListeners()}setupListeners(){this.searchInput.addEventListener("change",this.runSearch.bind(this)),this.searchForm.addEventListener("submit",t=>{t.preventDefault(),this.runSearch()}),T(this.clearButton,this.clearSearch.bind(this))}runSearch(){let t=this.searchInput.value.trim();if(t.length===0){this.clearSearch();return}this.searchView.classList.remove("hidden"),this.contentView.classList.add("hidden"),this.loadingBlock.classList.remove("hidden");let e=window.baseUrl(`/search/${this.entityType}/${this.entityId}`);window.$http.get(e,{term:t}).then(n=>{this.searchResults.innerHTML=n.data}).catch(console.error).then(()=>{this.loadingBlock.classList.add("hidden")})}clearSearch(){this.searchView.classList.add("hidden"),this.contentView.classList.remove("hidden"),this.loadingBlock.classList.add("hidden"),this.searchInput.value=""}};var hn=class extends h{constructor(){super(...arguments);c(this,"elem");c(this,"input");c(this,"searchInput");c(this,"loading");c(this,"resultsContainer");c(this,"searchOptions");c(this,"search","");c(this,"lastClick",0)}setup(){this.elem=this.$el,this.input=this.$refs.input,this.searchInput=this.$refs.search,this.loading=this.$refs.loading,this.resultsContainer=this.$refs.results,this.searchOptions={entityTypes:this.$opts.entityTypes||"page,book,chapter",entityPermission:this.$opts.entityPermission||"view",searchEndpoint:this.$opts.searchEndpoint||"",initialValue:this.searchInput.value||""},this.setupListeners(),this.showLoading(),this.searchOptions.searchEndpoint&&this.initialLoad()}configureSearchOptions(e){Object.assign(this.searchOptions,e),this.reset(),this.searchInput.value=this.searchOptions.initialValue}setupListeners(){this.elem.addEventListener("click",this.onClick.bind(this));let e=0;this.searchInput.addEventListener("input",()=>{e=Date.now(),this.showLoading(),setTimeout(()=>{Date.now()-e<199||this.searchEntities(this.searchInput.value)},200)}),this.searchInput.addEventListener("keydown",n=>{n.keyCode===13&&n.preventDefault()}),I(this.$el,"[data-entity-type]","keydown",(n=>{if(n.ctrlKey&&n.code==="Enter"){let o=this.$el.closest("form");if(o){o.submit(),n.preventDefault();return}}n.code==="ArrowDown"&&this.focusAdjacent(!0),n.code==="ArrowUp"&&this.focusAdjacent(!1)})),this.searchInput.addEventListener("keydown",n=>{n.code==="ArrowDown"&&this.focusAdjacent(!0)})}focusAdjacent(e=!0){let n=Array.from(this.resultsContainer.querySelectorAll("[data-entity-type]")),o=n.indexOf(document.activeElement),s=n[o+(e?1:-1)]||n[0];s instanceof HTMLElement&&s.focus()}reset(){this.searchInput.value="",this.showLoading(),this.initialLoad()}focusSearch(){this.searchInput.focus()}showLoading(){this.loading.style.display="block",this.resultsContainer.style.display="none"}hideLoading(){this.loading.style.display="none",this.resultsContainer.style.display="block"}initialLoad(){if(!this.searchOptions.searchEndpoint)throw new Error("Search endpoint not set for entity-selector load");if(this.searchOptions.initialValue){this.searchEntities(this.searchOptions.initialValue);return}window.$http.get(this.searchUrl()).then(e=>{this.resultsContainer.innerHTML=e.data,this.hideLoading()})}searchUrl(){let e=`types=${encodeURIComponent(this.searchOptions.entityTypes)}&permission=${encodeURIComponent(this.searchOptions.entityPermission)}`;return`${this.searchOptions.searchEndpoint}?${e}`}searchEntities(e){if(!this.searchOptions.searchEndpoint)throw new Error("Search endpoint not set for entity-selector load");this.input.value="";let n=`${this.searchUrl()}&term=${encodeURIComponent(e)}`;window.$http.get(n).then(o=>{this.resultsContainer.innerHTML=o.data,this.hideLoading()})}isDoubleClick(){let e=Date.now(),n=e-this.lastClick<300;return this.lastClick=e,n}onClick(e){let n=e.target.closest("[data-entity-type]");n instanceof HTMLElement&&(e.preventDefault(),e.stopPropagation(),this.selectItem(n))}selectItem(e){let n=this.isDoubleClick(),o=e.getAttribute("data-entity-type"),s=e.getAttribute("data-entity-id"),r=!e.classList.contains("selected")||n;this.unselectAll(),this.input.value=r?`${o}:${s}`:"";let a=e.getAttribute("href")||"",l=e.querySelector(".entity-list-item-name")?.textContent||"",d={id:Number(s),name:l,link:a};r?e.classList.add("selected"):window.$events.emit("entity-select-change"),!(!n&&!r)&&(n&&this.confirmSelection(d),r&&window.$events.emit("entity-select-change",d))}confirmSelection(e){window.$events.emit("entity-select-confirm",e)}unselectAll(){let e=this.elem.querySelectorAll(".selected");for(let n of e)n.classList.remove("selected","primary-background")}};var un=class extends h{constructor(){super(...arguments);c(this,"container");c(this,"selectButton");c(this,"selectorEl");c(this,"callback",null);c(this,"selection",null)}setup(){this.container=this.$el,this.selectButton=this.$refs.select,this.selectorEl=this.$refs.selector,this.selectButton.addEventListener("click",this.onSelectButtonClick.bind(this)),window.$events.listen("entity-select-change",this.onSelectionChange.bind(this)),window.$events.listen("entity-select-confirm",this.handleConfirmedSelection.bind(this))}show(e,n={}){this.callback=e,this.getSelector().configureSearchOptions(n),this.getPopup().show(),this.getSelector().focusSearch()}hide(){this.getPopup().hide()}getPopup(){return window.$components.firstOnElement(this.container,"popup")}getSelector(){return window.$components.firstOnElement(this.selectorEl,"entity-selector")}onSelectButtonClick(){this.handleConfirmedSelection(this.selection)}onSelectionChange(e){this.selection=e.hasOwnProperty("id")?e:null,this.selection?this.selectButton.removeAttribute("disabled"):this.selectButton.setAttribute("disabled","true")}handleConfirmedSelection(e){this.hide(),this.getSelector().reset(),this.callback&&e&&this.callback(e)}};var pn=class extends h{setup(){this.container=this.$el,this.name=this.$opts.name,T(this.$el,()=>{this.$emit(this.name,this.$opts)})}};var mn=class extends h{setup(){this.targetSelector=this.$opts.targetSelector,this.isOpen=this.$opts.isOpen==="true",this.updateEndpoint=this.$opts.updateEndpoint,this.$el.addEventListener("click",this.click.bind(this))}open(t){Vt(t,200)}close(t){qt(t,200)}click(t){t.preventDefault();let e=document.querySelectorAll(this.targetSelector);for(let n of e)(this.isOpen?this.close:this.open)(n);this.isOpen=!this.isOpen,this.updateSystemAjax(this.isOpen)}updateSystemAjax(t){window.$http.patch(this.updateEndpoint,{expand:t?"true":"false"})}};var fn=class extends h{setup(){this.container=this.$el,this.input=this.$refs.input,this.suggestions=this.$refs.suggestions,this.suggestionResultsWrap=this.$refs.suggestionResults,this.loadingWrap=this.$refs.loading,this.button=this.$refs.button,this.setupListeners()}setupListeners(){let t=mt(this.updateSuggestions.bind(this),200,!1);this.input.addEventListener("input",()=>{let{value:e}=this.input;e.length>0?(this.loadingWrap.style.display="block",this.suggestionResultsWrap.style.opacity="0.5",t(e)):this.hideSuggestions()}),this.input.addEventListener("dblclick",()=>{this.input.setAttribute("autocomplete","on"),this.button.focus(),this.input.focus()}),new gt(this.container,()=>{this.hideSuggestions()})}async updateSuggestions(t){let{data:e}=await window.$http.get("/search/suggest",{term:t});if(!this.input.value)return;let n=Q(e);this.suggestionResultsWrap.innerHTML="",this.suggestionResultsWrap.style.opacity="1",this.loadingWrap.style.display="none",this.suggestionResultsWrap.append(n),this.container.classList.contains("search-active")||this.showSuggestions()}showSuggestions(){this.container.classList.add("search-active"),window.requestAnimationFrame(()=>{this.suggestions.classList.add("search-suggestions-animation")})}hideSuggestions(){this.container.classList.remove("search-active"),this.suggestions.classList.remove("search-suggestions-animation"),this.suggestionResultsWrap.innerHTML=""}};var gn=class extends h{setup(){this.elem=this.$el,this.toggleButton=this.$refs.toggle,this.menu=this.$refs.menu,this.open=!1,this.toggleButton.addEventListener("click",this.onToggle.bind(this)),this.onWindowClick=this.onWindowClick.bind(this),this.onKeyDown=this.onKeyDown.bind(this)}onToggle(t){this.open=!this.open,this.menu.classList.toggle("show",this.open),this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open?(this.elem.addEventListener("keydown",this.onKeyDown),window.addEventListener("click",this.onWindowClick)):(this.elem.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("click",this.onWindowClick)),t.stopPropagation()}onKeyDown(t){t.code==="Escape"&&this.onToggle(t)}onWindowClick(t){this.onToggle(t)}};var vn=class extends h{setup(){this.uploadedTo=this.$opts.uploadedTo,this.container=this.$el,this.popupEl=this.$refs.popup,this.searchForm=this.$refs.searchForm,this.searchInput=this.$refs.searchInput,this.cancelSearch=this.$refs.cancelSearch,this.listContainer=this.$refs.listContainer,this.filterTabs=this.$manyRefs.filterTabs,this.selectButton=this.$refs.selectButton,this.uploadButton=this.$refs.uploadButton,this.uploadHint=this.$refs.uploadHint,this.formContainer=this.$refs.formContainer,this.formContainerPlaceholder=this.$refs.formContainerPlaceholder,this.dropzoneContainer=this.$refs.dropzoneContainer,this.loadMore=this.$refs.loadMore,this.type="gallery",this.lastSelected={},this.lastSelectedTime=0,this.callback=null,this.resetState=()=>{this.hasData=!1,this.page=1,this.filter="all"},this.resetState(),this.setupListeners()}setupListeners(){T(this.filterTabs,n=>{this.resetAll(),this.filter=n.target.dataset.filter,this.setActiveFilterTab(this.filter),this.loadGallery()}),this.searchForm.addEventListener("submit",n=>{this.resetListView(),this.loadGallery(),this.cancelSearch.toggleAttribute("hidden",!this.searchInput.value),n.preventDefault()}),T(this.cancelSearch,()=>{this.resetListView(),this.resetSearchView(),this.loadGallery()}),I(this.container,".load-more button","click",this.runLoadMore.bind(this)),this.listContainer.addEventListener("event-emit-select-image",this.onImageSelectEvent.bind(this)),this.listContainer.addEventListener("error",n=>{n.target.src=window.baseUrl("loading_error.png")},!0),T(this.selectButton,()=>{this.callback&&this.callback(this.lastSelected),this.hide()}),I(this.formContainer,"#image-manager-delete","click",()=>{this.lastSelected&&this.loadImageEditForm(this.lastSelected.id,!0)}),I(this.formContainer,"#image-manager-rebuild-thumbs","click",async(n,o)=>{o.disabled=!0,this.lastSelected&&await this.rebuildThumbnails(this.lastSelected.id),o.disabled=!1}),this.formContainer.addEventListener("ajax-form-success",()=>{this.refreshGallery(),this.resetEditForm()}),this.container.addEventListener("dropzone-upload-success",this.refreshGallery.bind(this));let t=this.listContainer.parentElement,e=[];t.addEventListener("wheel",n=>{if(!(Math.ceil(t.scrollHeight-t.scrollTop)===t.clientHeight)||n.deltaY<1)return;let r=Date.now()-1e3;e.push(Date.now()),e=e.filter(a=>a>=r),e.length>5&&this.canLoadMore()&&this.runLoadMore()})}show(t,e="gallery"){this.resetAll(),this.callback=t,this.type=e,this.getPopup().show();let n=e!=="gallery";this.dropzoneContainer.classList.toggle("hidden",n),this.uploadButton.classList.toggle("hidden",n),this.uploadHint.classList.toggle("hidden",n),window.$components.firstOnElement(this.container,"dropzone").toggleActive(!n),this.hasData||(this.loadGallery(),this.hasData=!0)}hide(){this.getPopup().hide()}getPopup(){return window.$components.firstOnElement(this.popupEl,"popup")}async loadGallery(){let t={page:this.page,search:this.searchInput.value||null,uploaded_to:this.uploadedTo,filter_type:this.filter==="all"?null:this.filter},{data:e}=await window.$http.get(`images/${this.type}`,t);t.page===1&&(this.listContainer.innerHTML=""),this.addReturnedHtmlElementsToList(e),Zt(this.listContainer)}addReturnedHtmlElementsToList(t){let e=document.createElement("div");e.innerHTML=t;let n=e.querySelector(".load-more");n&&(n.remove(),this.loadMore.innerHTML=n.innerHTML),this.loadMore.toggleAttribute("hidden",!n),window.$components.init(e);for(let o of[...e.children])this.listContainer.appendChild(o)}setActiveFilterTab(t){for(let e of this.filterTabs){let n=e.dataset.filter===t;e.setAttribute("aria-selected",n?"true":"false")}}resetAll(){this.resetState(),this.resetListView(),this.resetSearchView(),this.resetEditForm(),this.setActiveFilterTab("all"),this.selectButton.classList.add("hidden")}resetSearchView(){this.searchInput.value="",this.cancelSearch.toggleAttribute("hidden",!0)}resetEditForm(){this.formContainer.innerHTML="",this.formContainerPlaceholder.removeAttribute("hidden")}resetListView(){Tt(this.listContainer),this.page=1}refreshGallery(){this.resetListView(),this.loadGallery()}async onImageSelectEvent(t){let e=JSON.parse(t.detail.data),n=e&&e.id===this.lastSelected.id&&Date.now()-this.lastSelectedTime<400,o=t.target.classList.contains("selected");[...this.listContainer.querySelectorAll(".selected")].forEach(s=>{s.classList.remove("selected")}),!o&&!n?(t.target.classList.add("selected"),e=await this.loadImageEditForm(e.id)):n?n&&(e=this.lastSelected):this.resetEditForm(),this.selectButton.classList.toggle("hidden",o),n&&this.callback&&(this.callback(e),this.hide()),this.lastSelected=e,this.lastSelectedTime=Date.now()}async loadImageEditForm(t,e=!1){e||(this.formContainer.innerHTML="");let n=e?{delete:!0}:{},{data:o}=await window.$http.get(`/images/edit/${t}`,n);this.formContainer.innerHTML=o,this.formContainerPlaceholder.setAttribute("hidden",""),window.$components.init(this.formContainer);let s=this.formContainer.querySelector("#image-manager-form-image-data");return JSON.parse(s.text)}runLoadMore(){Tt(this.loadMore),this.page+=1,this.loadGallery()}canLoadMore(){return this.loadMore.querySelector("button")&&!this.loadMore.hasAttribute("hidden")}async rebuildThumbnails(t){try{let e=await window.$http.put(`/images/${t}/rebuild-thumbnails`);window.$events.success(e.data),this.refreshGallery()}catch(e){window.$events.showResponseError(e)}}};var wn=class extends h{setup(){this.imageElem=this.$refs.image,this.imageInput=this.$refs.imageInput,this.resetInput=this.$refs.resetInput,this.removeInput=this.$refs.removeInput,this.resetButton=this.$refs.resetButton,this.removeButton=this.$refs.removeButton||null,this.defaultImage=this.$opts.defaultImage,this.setupListeners()}setupListeners(){this.resetButton.addEventListener("click",this.reset.bind(this)),this.removeButton&&this.removeButton.addEventListener("click",this.removeImage.bind(this)),this.imageInput.addEventListener("change",this.fileInputChange.bind(this))}fileInputChange(){this.resetInput.setAttribute("disabled","disabled"),this.removeInput&&this.removeInput.setAttribute("disabled","disabled");for(let t of this.imageInput.files)this.imageElem.src=window.URL.createObjectURL(t);this.imageElem.classList.remove("none")}reset(){this.imageInput.value="",this.imageElem.src=this.defaultImage,this.resetInput.removeAttribute("disabled"),this.removeInput&&this.removeInput.setAttribute("disabled","disabled"),this.imageElem.classList.remove("none")}removeImage(){this.imageInput.value="",this.imageElem.classList.add("none"),this.removeInput.removeAttribute("disabled"),this.resetInput.setAttribute("disabled","disabled")}};var bn=class extends h{setup(){this.elem=this.$el,this.menu=this.$refs.menu,this.sortInput=this.$refs.sort,this.orderInput=this.$refs.order,this.form=this.$refs.form,this.setupListeners()}setupListeners(){this.menu.addEventListener("click",t=>{t.target.closest("[data-sort-value]")!==null&&this.sortOptionClick(t)}),this.elem.addEventListener("click",t=>{t.target.closest("[data-sort-dir]")!==null&&this.sortDirectionClick(t)})}sortOptionClick(t){let e=t.target.closest("[data-sort-value]");this.sortInput.value=e.getAttribute("data-sort-value"),t.preventDefault(),this.form.submit()}sortDirectionClick(t){let e=this.orderInput.value;this.orderInput.value=e==="asc"?"desc":"asc",t.preventDefault(),this.form.submit()}};function q(i,t={},e=[]){let n=document.createElement(i),o=Object.keys(t);for(let s of o)t[s]!==null&&n.setAttribute(s,t[s]);for(let s of e)typeof s=="string"?n.append(document.createTextNode(s)):n.append(s);return n}var yn=class extends h{constructor(){super(...arguments);c(this,"button");c(this,"loadingEl",null)}setup(){this.button=this.$el;let e=this.button.form,n=()=>{setTimeout(()=>this.showLoadingState(),10)};this.button.addEventListener("click",n),e&&e.addEventListener("submit",n)}showLoadingState(){this.button.disabled=!0,this.loadingEl||(this.loadingEl=q("div",{class:"inline block"}),Tt(this.loadingEl),this.button.after(this.loadingEl))}};var En=class extends h{setup(){this.elem=this.$el,this.pageId=this.$opts.pageId,this.textDirection=this.$opts.textDirection,this.imageUploadErrorText=this.$opts.imageUploadErrorText,this.serverUploadLimitText=this.$opts.serverUploadLimitText,this.display=this.$refs.display,this.input=this.$refs.input,this.divider=this.$refs.divider,this.displayWrap=this.$refs.displayWrap;let{settingContainer:t}=this.$refs,e=t.querySelectorAll('input[type="checkbox"]');this.editor=null,window.importVersioned("markdown").then(n=>n.init({pageId:this.pageId,container:this.elem,displayEl:this.display,inputEl:this.input,drawioUrl:this.getDrawioUrl(),settingInputs:Array.from(e),text:{serverUploadLimit:this.serverUploadLimitText,imageUploadError:this.imageUploadErrorText}})).then(n=>{this.editor=n,this.setupListeners(),this.emitEditorEvents(),this.scrollToTextIfNeeded(),this.editor.actions.updateAndRender()})}emitEditorEvents(){window.$events.emitPublic(this.elem,"editor-markdown::setup",{markdownIt:this.editor.markdown.getRenderer(),displayEl:this.display,cmEditorView:this.editor.cm})}setupListeners(){this.elem.addEventListener("click",t=>{let e=t.target.closest("button[data-action]");if(e===null)return;let n=e.getAttribute("data-action");if(n==="insertImage"&&this.editor.actions.showImageInsert(),n==="insertLink"&&this.editor.actions.showLinkSelector(),n==="insertDrawing"&&(t.ctrlKey||t.metaKey)){this.editor.actions.showImageManager();return}n==="insertDrawing"&&this.editor.actions.startDrawing(),n==="fullscreen"&&this.editor.actions.fullScreen()}),this.elem.addEventListener("click",t=>{let e=t.target.closest(".editor-toolbar-label");if(!e)return;let n=this.elem.querySelectorAll(".markdown-editor-wrap");for(let o of n)o.classList.remove("active");e.closest(".markdown-editor-wrap").classList.add("active")}),this.handleDividerDrag()}handleDividerDrag(){this.divider.addEventListener("pointerdown",()=>{let e=this.elem.getBoundingClientRect(),n=s=>{let r=s.pageX-e.left,a=Math.min(Math.max(20,Math.floor(r/e.width*100)),80);this.displayWrap.style.flexBasis=`${100-a}%`,this.editor.settings.set("editorWidth",a)},o=()=>{window.removeEventListener("pointermove",n),window.removeEventListener("pointerup",o),this.display.style.pointerEvents=null,document.body.style.userSelect=null};this.display.style.pointerEvents="none",document.body.style.userSelect="none",window.addEventListener("pointermove",n),window.addEventListener("pointerup",o)});let t=this.editor.settings.get("editorWidth");t&&(this.displayWrap.style.flexBasis=`${100-t}%`)}scrollToTextIfNeeded(){let e=new URL(window.location).searchParams.get("content-text");e&&this.editor.actions.scrollToText(e)}getDrawioUrl(){let t=document.querySelector("[drawio-url]");return t&&t.getAttribute("drawio-url")||""}async getContent(){return this.editor.actions.getContent()}};var Cn=class extends h{setup(){this.container=this.$el,this.inputContainer=this.$refs.inputContainer,this.inviteOption=this.container.querySelector("input[name=send_invite]"),this.inviteOption&&(this.inviteOption.addEventListener("change",this.inviteOptionChange.bind(this)),this.inviteOptionChange())}inviteOptionChange(){let t=this.inviteOption.value==="true",e=this.container.querySelectorAll("input[type=password]");for(let n of e)n.disabled=t;this.inputContainer.style.display=t?"none":"block"}};var Ln=class extends h{setup(){this.container=this.$el,this.type=this.$opts.type,this.textElem=this.container.querySelector("span"),this.autoHide=this.$opts.autoHide==="true",this.initialShow=this.$opts.show==="true",this.container.style.display="grid",window.$events.listen(this.type,t=>{this.show(t)}),this.container.addEventListener("click",this.hide.bind(this)),this.initialShow&&setTimeout(()=>this.show(this.textElem.textContent),100),this.hideCleanup=this.hideCleanup.bind(this)}show(t=""){if(this.container.removeEventListener("transitionend",this.hideCleanup),this.textElem.textContent=t,this.container.style.display="grid",setTimeout(()=>{this.container.classList.add("showing")},1),this.autoHide){let e=t.split(" ").length,n=Math.max(2e3,1e3+250*e);setTimeout(this.hide.bind(this),n)}}hide(){this.container.classList.remove("showing"),this.container.addEventListener("transitionend",this.hideCleanup)}hideCleanup(){this.container.style.display="none",this.container.removeEventListener("transitionend",this.hideCleanup)}};var xn=class extends h{setup(){this.removeButton=this.$refs.remove,this.showButton=this.$refs.show,this.input=this.$refs.input,this.setupListeners()}setupListeners(){T(this.removeButton,()=>{this.input.value="",this.input.classList.add("hidden"),this.removeButton.classList.add("hidden"),this.showButton.classList.remove("hidden")}),T(this.showButton,()=>{this.input.classList.remove("hidden"),this.removeButton.classList.remove("hidden"),this.showButton.classList.add("hidden")})}};var Tn=class extends h{constructor(){super(...arguments);c(this,"commentId");c(this,"commentLocalId");c(this,"deletedText");c(this,"updatedText");c(this,"archiveText");c(this,"wysiwygEditor",null);c(this,"wysiwygTextDirection");c(this,"container");c(this,"contentContainer");c(this,"form");c(this,"formCancel");c(this,"editButton");c(this,"deleteButton");c(this,"replyButton");c(this,"archiveButton");c(this,"input")}setup(){this.commentId=this.$opts.commentId,this.commentLocalId=this.$opts.commentLocalId,this.deletedText=this.$opts.deletedText,this.updatedText=this.$opts.updatedText,this.archiveText=this.$opts.archiveText,this.wysiwygTextDirection=this.$opts.wysiwygTextDirection,this.container=this.$el,this.contentContainer=this.$refs.contentContainer,this.form=this.$refs.form,this.formCancel=this.$refs.formCancel,this.editButton=this.$refs.editButton,this.deleteButton=this.$refs.deleteButton,this.replyButton=this.$refs.replyButton,this.archiveButton=this.$refs.archiveButton,this.input=this.$refs.input,this.setupListeners()}setupListeners(){if(this.replyButton){let e={id:this.commentLocalId,element:this.container};this.replyButton.addEventListener("click",()=>this.$emit("reply",e))}this.editButton&&(this.editButton.addEventListener("click",this.startEdit.bind(this)),this.form.addEventListener("submit",this.update.bind(this)),this.formCancel.addEventListener("click",()=>this.toggleEditMode(!1))),this.deleteButton&&this.deleteButton.addEventListener("click",this.delete.bind(this)),this.archiveButton&&this.archiveButton.addEventListener("click",this.archive.bind(this))}toggleEditMode(e){this.contentContainer.toggleAttribute("hidden",e),this.form.toggleAttribute("hidden",!e)}async startEdit(){if(this.toggleEditMode(!0),this.wysiwygEditor){this.wysiwygEditor.focus();return}let e=await window.importVersioned("wysiwyg"),n=this.input.value,o=q("div",{class:"comment-editor-container"});this.input.parentElement?.appendChild(o),this.input.hidden=!0,this.wysiwygEditor=e.createCommentEditorInstance(o,n,{darkMode:document.documentElement.classList.contains("dark-mode"),textDirection:this.$opts.textDirection,translations:window.editor_translations}),this.wysiwygEditor.focus()}async update(e){e.preventDefault();let n=this.showLoading();this.form.toggleAttribute("hidden",!0);let o={html:await this.wysiwygEditor?.getContentAsHtml()||""};try{let s=await window.$http.put(`/comment/${this.commentId}`,o),r=Q(s.data);this.container.replaceWith(r),window.$events.success(this.updatedText)}catch(s){console.error(s),s instanceof Lt&&window.$events.showValidationErrors(s),this.form.toggleAttribute("hidden",!1),n.remove()}}async delete(){this.showLoading(),await window.$http.delete(`/comment/${this.commentId}`),this.$emit("delete");let e=this.container.closest(".comment-branch");if(e instanceof HTMLElement){let n=window.$components.allWithinElement(e,"page-comment-reference");for(let o of n)o.hideMarker();e.remove()}window.$events.success(this.deletedText)}async archive(){this.showLoading();let n=this.archiveButton.dataset.isArchived==="true"?"unarchive":"archive",o=await window.$http.put(`/comment/${this.commentId}/${n}`);window.$events.success(this.archiveText);let s={new_thread_dom:Q(o.data)};this.$emit(n,s);let r=this.container.closest(".comment-branch"),a=window.$components.allWithinElement(r,"page-comment-reference");for(let l of a)l.hideMarker();r.remove()}showLoading(){let e=Bt();return e.classList.add("px-l"),this.container.append(e),e}};var _o='';var qo='';var Ut=null,Sn=class extends h{constructor(){super(...arguments);c(this,"link");c(this,"reference");c(this,"markerWrap",null);c(this,"viewCommentText");c(this,"jumpToThreadText");c(this,"closeText")}setup(){this.link=this.$el,this.reference=this.$opts.reference,this.viewCommentText=this.$opts.viewCommentText,this.jumpToThreadText=this.$opts.jumpToThreadText,this.closeText=this.$opts.closeText,this.showForDisplay(),window.addEventListener("editor-toolbox-change",(e=>{let n=e.detail.tab,o=e.detail.open;n==="comments"&&o&&this.link.checkVisibility()?this.showForEditor():this.hideMarker()})),window.addEventListener("toggle",e=>{e.target instanceof HTMLElement&&e.target.contains(this.link)&&window.requestAnimationFrame(()=>{this.link.checkVisibility()?this.showForEditor():this.hideMarker()})},{capture:!0}),window.addEventListener("tabs-change",(e=>{let n=e.detail.showing;if(!n.startsWith("comment-tab-panel"))return;document.getElementById(n)?.contains(this.link)?this.showForDisplay():this.hideMarker()}))}showForDisplay(){let e=document.querySelector(".page-content");e instanceof HTMLElement&&this.link.checkVisibility()&&this.updateMarker(e)}showForEditor(){let e=document.querySelector(".editor-content-wrap");e instanceof HTMLElement&&this.updateMarker(e);let n=()=>{this.hideMarker(),setTimeout(()=>{window.$events.remove("editor-html-change",n)},1)};window.$events.listen("editor-html-change",n)}updateMarker(e){this.link.classList.remove("outdated","missing"),this.markerWrap&&this.markerWrap.remove();let[n,o,s]=this.reference.split(":"),r=document.getElementById(n);if(!r){this.link.classList.add("outdated","missing");return}Ee(r)!==o&&this.link.classList.add("outdated");let l=q("button",{type:"button",class:"content-comment-marker",title:this.viewCommentText});l.innerHTML=_o,l.addEventListener("click",u=>{this.showCommentAtMarker(l)}),this.markerWrap=q("div",{class:"content-comment-highlight"},[l]),e.append(this.markerWrap),this.positionMarker(r,s),this.link.href=`#${r.id}`,this.link.addEventListener("click",u=>{u.preventDefault(),xt(r)});let d=mt(()=>{this.positionMarker(r,s)},50,!1).bind(this);window.addEventListener("resize",d)}positionMarker(e,n){if(!this.markerWrap)return;let o=this.markerWrap.parentElement,s=o.getBoundingClientRect(),r=e.getBoundingClientRect(),[a,l]=n.split("-");if(a&&l){let p=new Range,f=ye(e,Number(a)),v=ye(e,Number(l));f&&v&&(p.setStart(f.node,f.offset),p.setEnd(v.node,v.offset),r=p.getBoundingClientRect())}let d=r.left-s.left,u=r.top-s.top+o.scrollTop;this.markerWrap.style.left=`${d}px`,this.markerWrap.style.top=`${u}px`,this.markerWrap.style.width=`${r.width}px`,this.markerWrap.style.height=`${r.height}px`}hideMarker(){Ut&&Ut(),this.markerWrap?.remove(),this.markerWrap=null}showCommentAtMarker(e){Ut&&Ut(),e.hidden=!0;let n=this.link.closest(".comment-box"),o=n.closest(".comment-branch").cloneNode(!0),s=o.querySelectorAll(".actions, form");for(let v of s)v.remove();let r=q("button",{type:"button",title:this.closeText});r.innerHTML=qo;let a=q("button",{type:"button","data-action":"jump"},[this.jumpToThreadText]),l=q("div",{class:"content-comment-window"},[q("div",{class:"content-comment-window-actions"},[a,r]),q("div",{class:"content-comment-window-content comment-container-compact comment-container-super-compact"},[o])]);e.parentElement?.append(l);let d=()=>{l.remove(),e.hidden=!1,window.removeEventListener("click",u),Ut=null},u=v=>{e.parentElement.contains(v.target)||d()};window.addEventListener("click",u),Ut=d,r.addEventListener("click",d.bind(this)),a.addEventListener("click",()=>{d(),n.scrollIntoView({behavior:"smooth"});let v=n.querySelector(".header");v.classList.add("anim-highlight"),v.addEventListener("animationend",()=>v.classList.remove("anim-highlight"))});let p=l.getBoundingClientRect(),f=document.querySelector(".page-content")?.getBoundingClientRect();if(f&&p.right>f.right){let v=p.right-f.right;l.style.left=`-${v}px`}}};var jt=class extends h{constructor(){super(...arguments);c(this,"container");c(this,"tabList");c(this,"tabs");c(this,"panels");c(this,"activeUnder");c(this,"active",null)}setup(){this.container=this.$el,this.tabList=this.container.querySelector('[role="tablist"]'),this.tabs=Array.from(this.tabList.querySelectorAll('[role="tab"]')),this.panels=Array.from(this.container.querySelectorAll(':scope > [role="tabpanel"], :scope > * > [role="tabpanel"]')),this.activeUnder=this.$opts.activeUnder?Number(this.$opts.activeUnder):1e4,this.container.addEventListener("click",e=>{let n=e.target.closest('[role="tab"]');n instanceof HTMLElement&&this.tabs.includes(n)&&this.show(n.getAttribute("aria-controls")||"")}),window.addEventListener("resize",this.updateActiveState.bind(this),{passive:!0}),this.updateActiveState()}show(e){for(let o of this.panels)o.toggleAttribute("hidden",o.id!==e);for(let o of this.tabs){let r=o.getAttribute("aria-controls")===e;o.setAttribute("aria-selected",r?"true":"false")}let n={showing:e};this.$emit("change",n)}updateActiveState(){let e=window.innerWidth!n.hasAttribute("hidden"))||this.panels[0];this.show(e.id),this.tabList.toggleAttribute("hidden",!1)}deactivate(){for(let e of this.panels)e.removeAttribute("hidden");for(let e of this.tabs)e.setAttribute("aria-selected","false");this.tabList.toggleAttribute("hidden",!0)}};var kn=class extends h{constructor(){super(...arguments);c(this,"elem");c(this,"pageId");c(this,"container");c(this,"commentCountBar");c(this,"activeTab");c(this,"archivedTab");c(this,"addButtonContainer");c(this,"archiveContainer");c(this,"activeContainer");c(this,"replyToRow");c(this,"referenceRow");c(this,"formContainer");c(this,"form");c(this,"formInput");c(this,"formReplyLink");c(this,"formReferenceLink");c(this,"addCommentButton");c(this,"hideFormButton");c(this,"removeReplyToButton");c(this,"removeReferenceButton");c(this,"wysiwygTextDirection");c(this,"wysiwygEditor",null);c(this,"createdText");c(this,"countText");c(this,"archivedCountText");c(this,"parentId",null);c(this,"contentReference","");c(this,"formReplyText","")}setup(){this.elem=this.$el,this.pageId=Number(this.$opts.pageId),this.container=this.$refs.commentContainer,this.commentCountBar=this.$refs.commentCountBar,this.activeTab=this.$refs.activeTab,this.archivedTab=this.$refs.archivedTab,this.addButtonContainer=this.$refs.addButtonContainer,this.archiveContainer=this.$refs.archiveContainer,this.activeContainer=this.$refs.activeContainer,this.replyToRow=this.$refs.replyToRow,this.referenceRow=this.$refs.referenceRow,this.formContainer=this.$refs.formContainer,this.form=this.$refs.form,this.formInput=this.$refs.formInput,this.formReplyLink=this.$refs.formReplyLink,this.formReferenceLink=this.$refs.formReferenceLink,this.addCommentButton=this.$refs.addCommentButton,this.hideFormButton=this.$refs.hideFormButton,this.removeReplyToButton=this.$refs.removeReplyToButton,this.removeReferenceButton=this.$refs.removeReferenceButton,this.wysiwygTextDirection=this.$opts.wysiwygTextDirection,this.createdText=this.$opts.createdText,this.countText=this.$opts.countText,this.archivedCountText=this.$opts.archivedCountText,this.formReplyText=this.formReplyLink?.textContent||"",this.setupListeners()}setupListeners(){this.elem.addEventListener("page-comment-delete",()=>{setTimeout(()=>{this.updateCount(),this.hideForm()},1)}),this.elem.addEventListener("page-comment-reply",(e=>{this.setReply(e.detail.id,e.detail.element)})),this.elem.addEventListener("page-comment-archive",(e=>{this.archiveContainer.append(e.detail.new_thread_dom),setTimeout(()=>this.updateCount(),1)})),this.elem.addEventListener("page-comment-unarchive",(e=>{this.container.append(e.detail.new_thread_dom),setTimeout(()=>this.updateCount(),1)})),this.form&&(this.removeReplyToButton.addEventListener("click",this.removeReplyTo.bind(this)),this.removeReferenceButton.addEventListener("click",()=>this.setContentReference("")),this.hideFormButton.addEventListener("click",this.hideForm.bind(this)),this.addCommentButton.addEventListener("click",this.showForm.bind(this)),this.form.addEventListener("submit",this.saveComment.bind(this)))}async saveComment(e){e.preventDefault(),e.stopPropagation();let n=Bt();n.classList.add("px-l"),this.form.after(n),this.form.toggleAttribute("hidden",!0);let o={html:await this.wysiwygEditor?.getContentAsHtml()||"",parent_id:this.parentId||null,content_ref:this.contentReference};window.$http.post(`/comment/${this.pageId}`,o).then(s=>{let r=Q(s.data);o.parent_id?this.formContainer.after(r):this.container.append(r);let a=window.$components.allWithinElement(r,"page-comment-reference");for(let l of a)l.showForDisplay();window.$events.success(this.createdText),this.hideForm(),this.updateCount()}).catch(s=>{this.form.toggleAttribute("hidden",!1),window.$events.showValidationErrors(s)}),this.form.toggleAttribute("hidden",!1),n.remove()}updateCount(){let e=this.getActiveThreadCount();this.activeTab.textContent=window.$trans.choice(this.countText,e);let n=this.getArchivedThreadCount();this.archivedTab.textContent=window.$trans.choice(this.archivedCountText,n)}resetForm(){this.removeEditor(),this.formInput.value="",this.parentId=null,this.replyToRow.toggleAttribute("hidden",!0),this.container.append(this.formContainer),this.setContentReference("")}showForm(){this.removeEditor(),this.formContainer.toggleAttribute("hidden",!1),this.addButtonContainer.toggleAttribute("hidden",!0),this.formContainer.scrollIntoView({behavior:"smooth",block:"nearest"}),this.loadEditor();let e=window.$components.firstOnElement(this.elem,"tabs");e instanceof jt&&this.formContainer.closest("#comment-tab-panel-active")&&e.show("comment-tab-panel-active")}hideForm(){this.resetForm(),this.formContainer.toggleAttribute("hidden",!0),this.getActiveThreadCount()>0?this.activeContainer.append(this.addButtonContainer):this.commentCountBar.append(this.addButtonContainer),this.addButtonContainer.toggleAttribute("hidden",!1)}async loadEditor(){if(this.wysiwygEditor){this.wysiwygEditor.focus();return}let e=await window.importVersioned("wysiwyg"),n=q("div",{class:"comment-editor-container"});this.formInput.parentElement?.appendChild(n),this.formInput.hidden=!0,this.wysiwygEditor=e.createCommentEditorInstance(n,"

    ",{darkMode:document.documentElement.classList.contains("dark-mode"),textDirection:this.wysiwygTextDirection,translations:window.editor_translations}),this.wysiwygEditor.focus()}removeEditor(){this.wysiwygEditor&&(this.wysiwygEditor.remove(),this.wysiwygEditor=null)}getActiveThreadCount(){return this.container.querySelectorAll(":scope > .comment-branch:not([hidden])").length}getArchivedThreadCount(){return this.archiveContainer.querySelectorAll(":scope > .comment-branch").length}setReply(e,n){n.closest(".comment-branch").querySelector(".comment-branch-children").append(this.formContainer),this.showForm(),this.parentId=Number(e),this.replyToRow.toggleAttribute("hidden",!1),this.formReplyLink.textContent=this.formReplyText.replace("1234",String(this.parentId)),this.formReplyLink.href=`#comment${this.parentId}`}removeReplyTo(){this.parentId=null,this.replyToRow.toggleAttribute("hidden",!0),this.container.append(this.formContainer),this.showForm()}startNewComment(e){this.resetForm(),this.showForm(),this.setContentReference(e)}setContentReference(e){this.contentReference=e,this.referenceRow.toggleAttribute("hidden",!e);let[n]=e.split(":");this.formReferenceLink.href=`#${n}`,this.formReferenceLink.onclick=function(o){o.preventDefault();let s=document.getElementById(n);s&&xt(s)}}};function ar(i,t){ai(`#page-navigation a[href="#${i}"]`,e=>{e.closest("li").classList.toggle("current-heading",t)})}function lr(i){for(let t of i){let e=t.intersectionRatio===1;ar(t.target.id,e)}}function cr(i){let t={rootMargin:"0px 0px 0px 0px",threshold:1},e=new IntersectionObserver(lr,t);for(let n of i)e.observe(n)}var $n=class extends h{setup(){if(this.container=this.$el,this.pageId=this.$opts.pageId,window.importVersioned("code").then(e=>e.highlight()),this.setupNavHighlighting(),window.location.hash){let e=window.location.hash.replace(/%20/g," ").substring(1);this.goToText(e)}let t=document.querySelector(".sidebar-page-nav");t&&I(t,"a","click",(e,n)=>{e.preventDefault(),window.$components.first("tri-layout").showContent();let o=n.getAttribute("href").substr(1);this.goToText(o),window.history.pushState(null,null,`#${o}`)})}goToText(t){let e=document.getElementById(t);if(ai(".page-content [data-highlighted]",n=>{n.removeAttribute("data-highlighted"),n.style.backgroundColor=null}),e!==null)xt(e);else{let n=ao(".page-content > div > *",t);n&&xt(n)}}setupNavHighlighting(){let t=document.querySelector(".sidebar-page-nav"),e=document.querySelector(".page-content").querySelectorAll("h1, h2, h3, h4, h5, h6");e.length>0&&t!==null&&cr(e)}};function Vo(i){let t=new Date(i*1e3),e=t.getHours(),n=t.getMinutes();return`${(e>9?"":"0")+e}:${(n>9?"":"0")+n}`}var Mn=class extends h{setup(){this.draftsEnabled=this.$opts.draftsEnabled==="true",this.editorType=this.$opts.editorType,this.pageId=Number(this.$opts.pageId),this.isNewDraft=this.$opts.pageNewDraft==="true",this.hasDefaultTitle=this.$opts.hasDefaultTitle||!1,this.container=this.$el,this.titleElem=this.$refs.titleContainer.querySelector("input"),this.saveDraftButton=this.$refs.saveDraft,this.discardDraftButton=this.$refs.discardDraft,this.discardDraftWrap=this.$refs.discardDraftWrap,this.deleteDraftButton=this.$refs.deleteDraft,this.deleteDraftWrap=this.$refs.deleteDraftWrap,this.draftDisplay=this.$refs.draftDisplay,this.draftDisplayIcon=this.$refs.draftDisplayIcon,this.changelogInput=this.$refs.changelogInput,this.changelogDisplay=this.$refs.changelogDisplay,this.changelogCounter=this.$refs.changelogCounter,this.changeEditorButtons=this.$manyRefs.changeEditor||[],this.switchDialogContainer=this.$refs.switchDialog,this.deleteDraftDialogContainer=this.$refs.deleteDraftDialog,this.draftText=this.$opts.draftText,this.autosaveFailText=this.$opts.autosaveFailText,this.editingPageText=this.$opts.editingPageText,this.draftDiscardedText=this.$opts.draftDiscardedText,this.draftDeleteText=this.$opts.draftDeleteText,this.draftDeleteFailText=this.$opts.draftDeleteFailText,this.setChangelogText=this.$opts.setChangelogText,this.autoSave={interval:null,frequency:3e4,last:0,pendingChange:!1},this.shownWarningsCache=new Set,this.pageId!==0&&this.draftsEnabled&&window.setTimeout(()=>{this.startAutoSave()},1e3),this.draftDisplay.innerHTML=this.draftText,this.setupListeners(),this.setInitialFocus()}setupListeners(){window.$events.listen("editor-save-draft",this.saveDraft.bind(this)),window.$events.listen("editor-save-page",this.savePage.bind(this));let t=()=>{this.autoSave.pendingChange=!0};window.$events.listen("editor-html-change",t),window.$events.listen("editor-markdown-change",t),this.titleElem.addEventListener("input",t);let e=mt(this.updateChangelogDisplay.bind(this),300,!1);this.changelogInput.addEventListener("input",()=>{let n=this.changelogInput.value.length;this.changelogCounter.innerText=`${n} / 180`,e()}),T(this.saveDraftButton,this.saveDraft.bind(this)),T(this.discardDraftButton,this.discardDraft.bind(this)),T(this.deleteDraftButton,this.deleteDraft.bind(this)),T(this.changeEditorButtons,this.changeEditor.bind(this))}setInitialFocus(){if(this.hasDefaultTitle){this.titleElem.select();return}window.setTimeout(()=>{window.$events.emit("editor::focus","")},500)}startAutoSave(){this.autoSave.interval=window.setInterval(this.runAutoSave.bind(this),this.autoSave.frequency)}runAutoSave(){Date.now()-this.autoSave.last{this.draftDisplayIcon.classList.remove("visible")},2e3)}async discardDraft(t=!0){let e;try{e=await window.$http.get(`/ajax/page/${this.pageId}`)}catch(n){console.error(n);return}this.autoSave.interval&&window.clearInterval(this.autoSave.interval),this.draftDisplay.innerText=this.editingPageText,this.discardDraftWrap.toggleAttribute("hidden",!0),window.$events.emit("editor::replace",{html:e.data.html,markdown:e.data.markdown}),this.titleElem.value=e.data.name,window.setTimeout(()=>{this.startAutoSave()},1e3),t&&window.$events.success(this.draftDiscardedText)}async deleteDraft(){if(await window.$components.firstOnElement(this.deleteDraftDialogContainer,"confirm-dialog").show())try{let n=this.discardDraft(!1),o=window.$http.delete(`/page-revisions/user-drafts/${this.pageId}`);await Promise.all([n,o]),window.$events.success(this.draftDeleteText),this.deleteDraftWrap.toggleAttribute("hidden",!0)}catch(n){console.error(n),window.$events.error(this.draftDeleteFailText)}}updateChangelogDisplay(){let t=this.changelogInput.value.trim();t.length===0?t=this.setChangelogText:t.length>16&&(t=`${t.slice(0,16)}...`),this.changelogDisplay.innerText=t}async changeEditor(t){t.preventDefault();let e=t.target.closest("a").href,n=window.$components.firstOnElement(this.switchDialogContainer,"confirm-dialog"),[o,s]=await Promise.all([this.saveDraft(),n.show()]);o&&s&&(window.location=e)}getEditorComponent(){return window.$components.first("markdown-editor")||window.$components.first("wysiwyg-editor")||window.$components.first("wysiwyg-editor-tinymce")}};function Dn(i,t){i.toggleAttribute("hidden",!t)}var An=class extends h{setup(){this.input=this.$refs.input,this.resetButton=this.$refs.resetButton,this.selectButton=this.$refs.selectButton,this.display=this.$refs.display,this.defaultDisplay=this.$refs.defaultDisplay,this.buttonSep=this.$refs.buttonSeperator,this.selectorEndpoint=this.$opts.selectorEndpoint,this.value=this.input.value,this.setupListeners()}setupListeners(){this.selectButton.addEventListener("click",this.showPopup.bind(this)),this.display.parentElement.addEventListener("click",this.showPopup.bind(this)),this.display.addEventListener("click",t=>t.stopPropagation()),this.resetButton.addEventListener("click",()=>{this.setValue("","")})}showPopup(){window.$components.first("entity-selector-popup").show(e=>{this.setValue(e.id,e.name)},{initialValue:"",searchEndpoint:this.selectorEndpoint,entityTypes:"page",entityPermission:"view"})}setValue(t,e){this.value=t,this.input.value=t,this.controlView(e)}controlView(t){let e=this.value&&this.value!==0;if(Dn(this.resetButton,e),Dn(this.buttonSep,e),Dn(this.defaultDisplay,!e),Dn(this.display,e),e){let n=this.getAssetIdFromVal();this.display.textContent=`#${n}, ${t}`,this.display.href=window.baseUrl(`/link/${n}`)}}getAssetIdFromVal(){return Number(this.value)}};var In=class extends h{setup(){this.container=this.$el,this.cellSelector=this.$opts.cellSelector||"td,th",this.rowSelector=this.$opts.rowSelector||"tr";for(let t of this.$manyRefs.toggleAll||[])t.addEventListener("click",this.toggleAllClick.bind(this));for(let t of this.$manyRefs.toggleRow||[])t.addEventListener("click",this.toggleRowClick.bind(this));for(let t of this.$manyRefs.toggleColumn||[])t.addEventListener("click",this.toggleColumnClick.bind(this))}toggleAllClick(t){t.preventDefault(),this.toggleAllInElement(this.container)}toggleRowClick(t){t.preventDefault(),this.toggleAllInElement(t.target.closest(this.rowSelector))}toggleColumnClick(t){t.preventDefault();let e=t.target.closest(this.cellSelector),n=Array.from(e.parentElement.children).indexOf(e),o=this.container.querySelectorAll(this.rowSelector),s=[];for(let r of o){let a=r.children[n];a&&s.push(...a.querySelectorAll("input[type=checkbox]"))}this.toggleAllInputs(s)}toggleAllInElement(t){let e=t.querySelectorAll("input[type=checkbox]");this.toggleAllInputs(e)}toggleAllInputs(t){let e=t.length>0?t[0].checked:!1;for(let n of t)n.checked=!e,n.dispatchEvent(new Event("change"))}};var Hn=class extends h{constructor(){super(...arguments);c(this,"showing",!1);c(this,"isMakingSelection",!1);c(this,"targetElement",null);c(this,"targetSelectionRange",null);c(this,"pointer");c(this,"linkInput");c(this,"linkButton");c(this,"includeInput");c(this,"includeButton");c(this,"sectionModeButton");c(this,"commentButton");c(this,"modeToggles");c(this,"modeSections");c(this,"pageId")}setup(){this.pointer=this.$refs.pointer,this.linkInput=this.$refs.linkInput,this.linkButton=this.$refs.linkButton,this.includeInput=this.$refs.includeInput,this.includeButton=this.$refs.includeButton,this.sectionModeButton=this.$refs.sectionModeButton,this.commentButton=this.$refs.commentButton,this.modeToggles=this.$manyRefs.modeToggle,this.modeSections=this.$manyRefs.modeSection,this.pageId=this.$opts.pageId,this.setupListeners()}setupListeners(){this.includeButton.addEventListener("click",()=>Hi(this.includeInput.value)),this.linkButton.addEventListener("click",()=>Hi(this.linkInput.value)),T([this.includeInput,this.linkInput],n=>{n.target.select(),n.stopPropagation()}),be(this.pointer,["click","focus"],n=>{n.stopPropagation()}),be(document.body,["click","focus"],()=>{!this.showing||this.isMakingSelection||this.hidePointer()}),ro(this.pointer,this.hidePointer.bind(this));let e=document.querySelector(".page-content");be(e,["mouseup","keyup"],n=>{n.stopPropagation();let o=n.target.closest('[id^="bkmrk"]');if(o instanceof HTMLElement&&(window.getSelection()||"").toString().length>0){let s=n instanceof MouseEvent?n.pageX:0;this.showPointerAtTarget(o,s,!1)}}),T(this.sectionModeButton,this.enterSectionSelectMode.bind(this)),T(this.modeToggles,n=>{let o=n.target;for(let r of this.modeSections){let a=!r.contains(o);r.toggleAttribute("hidden",!a)}let s=this.modeToggles.find(r=>r!==o);s&&s.focus()}),this.commentButton&&T(this.commentButton,this.createCommentAtPointer.bind(this))}hidePointer(){this.pointer.style.removeProperty("display"),this.showing=!1,this.targetElement=null,this.targetSelectionRange=null}showPointerAtTarget(e,n,o){this.targetElement=e,this.targetSelectionRange=window.getSelection()?.getRangeAt(0)||null,this.updateDomForTarget(e),this.pointer.style.display="block";let s=e.getBoundingClientRect(),r=this.pointer.getBoundingClientRect(),l=Math.min(Math.max(n,s.left),s.right)-r.width/2,d=s.top-r.height-16;this.pointer.style.left=`${l}px`,this.pointer.style.top=`${d}px`,this.showing=!0,this.isMakingSelection=!0,setTimeout(()=>{this.isMakingSelection=!1},100);let u=()=>{this.hidePointer(),window.removeEventListener("scroll",u)};e.parentElement?.insertBefore(this.pointer,e),o||window.addEventListener("scroll",u,{passive:!0})}updateDomForTarget(e){let n=window.baseUrl(`/link/${this.pageId}#${e.id}`),o=`{{@${this.pageId}#${e.id}}}`;this.linkInput.value=n,this.includeInput.value=o;let s=this.pointer.querySelector("#pointer-edit");if(s instanceof HTMLAnchorElement&&e){let{editHref:r}=s.dataset,a=e.id,l=(e.textContent||"").substring(0,50);s.href=`${r}?content-id=${a}&content-text=${encodeURIComponent(l)}`}}enterSectionSelectMode(){let e=Array.from(document.querySelectorAll('.page-content [id^="bkmrk"]'));for(let n of e)n.setAttribute("tabindex","0");e[0].focus(),Ht(e,n=>{this.showPointerAtTarget(n.target,0,!0),this.pointer.focus()})}createCommentAtPointer(){if(!this.targetElement)return;let e=this.targetElement.id,n=Ee(this.targetElement),o="";if(this.targetSelectionRange){let a=this.targetSelectionRange.commonAncestorContainer;if(this.targetElement.contains(a)){let l=li(this.targetSelectionRange.startContainer,this.targetSelectionRange.startOffset,this.targetElement),d=li(this.targetSelectionRange.endContainer,this.targetSelectionRange.endOffset,this.targetElement);o=`${l}-${d}`}}let s=`${e}:${n}:${o}`;window.$components.first("page-comments").startNewComment(s)}};var Bn=class extends h{setup(){this.container=this.$el,this.hideButtons=this.$manyRefs.hide||[],this.onkeyup=null,this.onHide=null,this.setupListeners()}setupListeners(){let t=null;this.container.addEventListener("mousedown",e=>{t=e.target}),this.container.addEventListener("click",e=>{e.target===this.container&&t===this.container&&this.hide()}),T(this.hideButtons,()=>this.hide())}hide(t=null){No(this.container,120,t),this.onkeyup&&(window.removeEventListener("keyup",this.onkeyup),this.onkeyup=null),this.onHide&&this.onHide()}show(t=null,e=null){Oo(this.container,120,t),this.onkeyup=n=>{n.key==="Escape"&&this.hide()},window.addEventListener("keyup",this.onkeyup),this.onHide=e}};var Pn=class extends h{setup(){this.container=this.$el,this.mode=this.$opts.mode,this.lightContainer=this.$refs.lightContainer,this.darkContainer=this.$refs.darkContainer,this.container.addEventListener("tabs-change",e=>{let o=e.detail.showing==="color-scheme-panel-light"?"light":"dark";this.handleModeChange(o)});let t=e=>{this.updateAppColorsFromInputs(),e.target.name.startsWith("setting-app-color")&&this.updateLightForInput(e.target)};this.container.addEventListener("change",t),this.container.addEventListener("input",t)}handleModeChange(t){this.mode=t;let e=t==="dark";document.documentElement.classList.toggle("dark-mode",e),this.updateAppColorsFromInputs()}updateAppColorsFromInputs(){let e=(this.mode==="dark"?this.darkContainer:this.lightContainer).querySelectorAll('input[type="color"]');for(let n of e){let o=n.name.split("-"),s=o.indexOf("color"),r=o.slice(1,s).join("-");r==="app"&&(r="primary");let a=`--color-${r}`;document.body.style.setProperty(a,n.value)}}updateLightForInput(t){let e=t.name.replace("-color","-color-light"),n=t.value,o=this.hexToRgb(n),s=`rgba(${[o.r,o.g,o.b,"0.15"].join(",")})`,r=this.container.querySelector(`input[name="${e}"][type="hidden"]`);r.value=s}hexToRgb(t){let e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return{r:e?parseInt(e[1],16):0,g:e?parseInt(e[2],16):0,b:e?parseInt(e[3],16):0}}};var Rn=class extends h{setup(){this.colorInput=this.$refs.input,this.resetButton=this.$refs.resetButton,this.defaultButton=this.$refs.defaultButton,this.currentColor=this.$opts.current,this.defaultColor=this.$opts.default,this.resetButton.addEventListener("click",()=>this.setValue(this.currentColor)),this.defaultButton.addEventListener("click",()=>this.setValue(this.defaultColor))}setValue(t){this.colorInput.value=t,this.colorInput.dispatchEvent(new Event("change",{bubbles:!0}))}};var On=class extends h{setup(){this.typeControl=this.$refs.typeControl,this.pagePickerContainer=this.$refs.pagePickerContainer,this.typeControl.addEventListener("change",this.controlPagePickerVisibility.bind(this)),this.controlPagePickerVisibility()}controlPagePickerVisibility(){let t=this.typeControl.value==="page";this.pagePickerContainer.style.display=t?"block":"none"}};function Nn(i,t){return{move_up(e){let n=e.parentNode,o=Array.from(n.children).indexOf(e),s=Math.max(o-1,0);n.insertBefore(e,n.children[s]||null)},move_down(e){let n=e.parentNode,o=Array.from(n.children).indexOf(e),s=Math.min(o+2,n.children.length);n.insertBefore(e,n.children[s]||null)},remove(e){i.appendChild(e)},add(e){t.appendChild(e)}}}function Fn(i,t){return e=>{let n=e.target.closest(".scroll-box-item button[data-action]");if(n){let o=n.closest(".scroll-box-item"),s=n.dataset.action;if(!s)throw new Error("No action defined for clicked button");let r=i[s];r(o),t()}}}var _n=class extends h{setup(){this.elem=this.$el,this.input=this.$refs.input,this.shelfBookList=this.$refs.shelfBookList,this.allBookList=this.$refs.allBookList,this.bookSearchInput=this.$refs.bookSearch,this.sortButtonContainer=this.$refs.sortButtonContainer,this.lastSort=null,this.initSortable(),this.setupListeners()}initSortable(){let t=this.elem.querySelectorAll(".scroll-box");for(let e of t)new ht(e,{group:"shelf-books",ghostClass:"primary-background-light",handle:".handle",animation:150,onSort:this.onChange.bind(this)})}setupListeners(){let t=Nn(this.allBookList,this.shelfBookList),e=Fn(t,this.onChange.bind(this));this.elem.addEventListener("click",e),this.bookSearchInput.addEventListener("input",()=>{this.filterBooksByName(this.bookSearchInput.value)}),this.sortButtonContainer.addEventListener("click",n=>{let o=n.target.closest("button[data-sort]");o&&this.sortShelfBooks(o.dataset.sort)})}filterBooksByName(t){this.allBookList.style.height||(this.allBookList.style.height=`${this.allBookList.getBoundingClientRect().height}px`);let e=this.allBookList.children,n=t.trim().toLowerCase();for(let o of e){let s=!t||o.textContent.toLowerCase().includes(n);o.style.display=s?null:"none"}}onChange(){let t=Array.from(this.shelfBookList.querySelectorAll("[data-id]"));this.input.value=t.map(e=>e.getAttribute("data-id")).join(",")}sortShelfBooks(t){let e=Array.from(this.shelfBookList.children),n=t===this.lastSort;e.sort((o,s)=>{let r=o.dataset[t].toLowerCase(),a=s.dataset[t].toLowerCase();return n?a.localeCompare(r):r.localeCompare(a)});for(let o of e)this.shelfBookList.append(o);this.lastSort=this.lastSort===t?null:t,this.onChange()}};function dr(i){let t={};for(let[e,n]of Object.entries(i))t[n]=e;return t}var qn=class extends h{setup(){this.container=this.$el,this.mapById=JSON.parse(this.$opts.keyMap),this.mapByShortcut=dr(this.mapById),this.hintsShowing=!1,this.hideHints=this.hideHints.bind(this),this.hintAbortController=null,this.setupListeners()}setupListeners(){window.addEventListener("keydown",t=>{if(!t.target.closest("input, select, textarea, .cm-editor, .editor-container")){if(t.key==="?"){this.hintsShowing?this.hideHints():this.showHints();return}this.handleShortcutPress(t)}})}handleShortcutPress(t){let n=[t.ctrlKey?"Ctrl":"",t.metaKey?"Cmd":"",t.key].filter(s=>!!s).join(" + "),o=this.mapByShortcut[n];o&&this.runShortcut(o)&&t.preventDefault()}runShortcut(t){let e=this.container.querySelector(`[data-shortcut="${t}"]`);return e?e.matches("input, textarea, select")?(e.focus(),!0):e.matches("a, button")?(e.click(),!0):e.matches("div[tabindex]")?(e.click(),e.focus(),!0):(console.error("Shortcut attempted to be ran for element type that does not have handling setup",e),!1):!1}showHints(){let t=document.createElement("div");t.classList.add("shortcut-container"),this.container.append(t);let e=this.container.querySelectorAll("[data-shortcut]"),n=new Set;for(let s of e){let r=s.getAttribute("data-shortcut");if(n.has(r))continue;let a=this.mapById[r];this.showHintLabel(s,a,t),n.add(r)}this.hintAbortController=new AbortController;let o=this.hintAbortController.signal;window.addEventListener("scroll",this.hideHints,{signal:o}),window.addEventListener("focus",this.hideHints,{signal:o}),window.addEventListener("blur",this.hideHints,{signal:o}),window.addEventListener("click",this.hideHints,{signal:o}),this.hintsShowing=!0}showHintLabel(t,e,n){let o=t.getBoundingClientRect(),s=document.createElement("div");s.classList.add("shortcut-hint"),s.textContent=e;let r=document.createElement("div");r.classList.add("shortcut-linkage"),r.style.left=`${o.x}px`,r.style.top=`${o.y}px`,r.style.width=`${o.width}px`,r.style.height=`${o.height}px`,n.append(s,r);let a=s.getBoundingClientRect();s.style.insetInlineStart=`${o.x+o.width-(a.width+6)}px`,s.style.insetBlockStart=`${o.y+(o.height-a.height)/2}px`}hideHints(){this.container.querySelector(".shortcut-container").remove(),this.hintAbortController?.abort(),this.hintsShowing=!1}};var hr=["Control","Alt","Shift","Meta","Super"," ","+","Tab","Escape"],Vn=class extends h{setup(){this.input=this.$el,this.setupListeners()}setupListeners(){this.listenerRecordKey=this.listenerRecordKey.bind(this),this.input.addEventListener("focus",()=>{this.startListeningForInput()}),this.input.addEventListener("blur",()=>{this.stopListeningForInput()})}startListeningForInput(){this.input.addEventListener("keydown",this.listenerRecordKey)}listenerRecordKey(t){if(hr.includes(t.key))return;let e=[t.ctrlKey?"Ctrl":"",t.metaKey?"Cmd":"",t.key];this.input.value=e.filter(n=>!!n).join(" + ")}stopListeningForInput(){this.input.removeEventListener("keydown",this.listenerRecordKey)}};var Wn=class extends h{setup(){this.container=this.$el,this.handleSelector=this.$opts.handleSelector;let t=new ht(this.container,{handle:this.handleSelector,animation:150,onSort:()=>{this.$emit("sort",{ids:t.toArray()})},setData(e,n){let o=n.getAttribute("data-drag-content");if(o){let s=JSON.parse(o);for(let[r,a]of Object.entries(s))e.setData(r,a)}},revertOnSpill:!0,dropBubble:!0,dragoverBubble:!1})}};var Un=class extends h{constructor(){super(...arguments);c(this,"input");c(this,"configuredList");c(this,"availableList")}setup(){this.input=this.$refs.input,this.configuredList=this.$refs.configuredOperationsList,this.availableList=this.$refs.availableOperationsList,this.initSortable();let e=Nn(this.availableList,this.configuredList),n=Fn(e,this.onChange.bind(this));this.$el.addEventListener("click",n)}initSortable(){let e=[this.configuredList,this.availableList];for(let n of e)new ht(n,{group:"sort-rule-operations",ghostClass:"primary-background-light",handle:".handle",animation:150,onSort:this.onChange.bind(this)})}onChange(){let e=Array.from(this.configuredList.querySelectorAll("[data-id]"));this.input.value=e.map(n=>n.getAttribute("data-id")).join(",")}};var jn=class extends h{setup(){this.filter=this.$opts.filter,this.$el.addEventListener("change",t=>{if(this.filter&&!t.target.matches(this.filter))return;let e=this.$el.closest("form");e&&e.submit()})}};var zn=class extends h{setup(){this.addRemoveComponentEl=this.$refs.addRemove,this.container=this.$el,this.rowSelector=this.$opts.rowSelector,this.setupListeners()}setupListeners(){this.container.addEventListener("input",t=>{let e=window.$components.firstOnElement(this.addRemoveComponentEl,"add-remove-rows");!this.hasEmptyRows()&&t.target.value&&e.add()})}hasEmptyRows(){return[...this.container.querySelectorAll(this.rowSelector)].find(n=>[...n.querySelectorAll("input")].filter(o=>o.value).length===0)!==void 0}};var Kn=class extends h{setup(){this.container=this.$el,this.list=this.$refs.list,this.searchInput=this.$refs.searchInput,this.searchButton=this.$refs.searchButton,this.searchCancel=this.$refs.searchCancel,this.setupListeners()}setupListeners(){I(this.container,"[template-action]","click",this.handleTemplateActionClick.bind(this)),I(this.container,".pagination a","click",this.handlePaginationClick.bind(this)),I(this.container,".template-item-content","click",this.handleTemplateItemClick.bind(this)),I(this.container,".template-item","dragstart",this.handleTemplateItemDragStart.bind(this)),this.searchInput.addEventListener("keypress",t=>{t.key==="Enter"&&(t.preventDefault(),this.performSearch())}),this.searchButton.addEventListener("click",()=>this.performSearch()),this.searchCancel.addEventListener("click",()=>{this.searchInput.value="",this.performSearch()})}handleTemplateItemClick(t,e){let n=e.closest("[template-id]").getAttribute("template-id");this.insertTemplate(n,"replace")}handleTemplateItemDragStart(t,e){let n=e.closest("[template-id]").getAttribute("template-id");t.dataTransfer.setData("bookstack/template",n),t.dataTransfer.setData("text/plain",n)}handleTemplateActionClick(t,e){t.stopPropagation();let n=e.getAttribute("template-action"),o=e.closest("[template-id]").getAttribute("template-id");this.insertTemplate(o,n)}async insertTemplate(t,e="replace"){let n=await window.$http.get(`/templates/${t}`),o=`editor::${e}`;window.$events.emit(o,n.data)}async handlePaginationClick(t,e){t.preventDefault();let n=e.getAttribute("href"),o=await window.$http.get(n);this.list.innerHTML=o.data}async performSearch(){let t=this.searchInput.value,e=await window.$http.get("/templates",{search:t});this.searchCancel.style.display=t?"block":"none",this.list.innerHTML=e.data}};var Xn=class extends h{setup(){this.input=this.$el.querySelector("input[type=hidden]"),this.checkbox=this.$el.querySelector("input[type=checkbox]"),this.checkbox.addEventListener("change",this.stateChange.bind(this))}stateChange(){this.input.value=this.checkbox.checked?"true":"false";let t=new Event("change");this.input.dispatchEvent(t)}};var Gn=class extends h{constructor(){super(...arguments);c(this,"container");c(this,"tabs");c(this,"sidebarScrollContainers");c(this,"lastLayoutType","none");c(this,"onDestroy",null);c(this,"scrollCache",{content:0,info:0});c(this,"lastTabShown","content")}setup(){this.container=this.$refs.container,this.tabs=this.$manyRefs.tab,this.sidebarScrollContainers=this.$manyRefs.sidebarScrollContainer,this.mobileTabClick=this.mobileTabClick.bind(this),this.updateLayout(),window.addEventListener("resize",()=>{this.updateLayout()},{passive:!0}),this.setupSidebarScrollHandlers()}updateLayout(){let e="tablet";window.innerWidth<=1e3&&(e="mobile"),window.innerWidth>1400&&(e="desktop"),e!==this.lastLayoutType&&(this.onDestroy&&(this.onDestroy(),this.onDestroy=null),e==="desktop"?this.setupDesktop():e==="mobile"&&this.setupMobile(),this.lastLayoutType=e)}setupMobile(){for(let e of this.tabs)e.addEventListener("click",this.mobileTabClick);this.onDestroy=()=>{for(let e of this.tabs)e.removeEventListener("click",this.mobileTabClick)}}setupDesktop(){}mobileTabClick(e){let n=e.target.dataset.tab||"";this.showTab(n)}showContent(){this.showTab("content",!1)}showTab(e,n=!0){this.scrollCache[this.lastTabShown]=document.documentElement.scrollTop;for(let s of this.tabs){let r=s.dataset.tab===e;s.setAttribute("aria-selected",r?"true":"false")}let o=e==="info";if(this.container.classList.toggle("show-info",o),n){let r=document.querySelector("header").getBoundingClientRect().bottom;document.documentElement.scrollTop=this.scrollCache[e]||r,setTimeout(()=>{document.documentElement.scrollTop=this.scrollCache[e]||r},50)}this.lastTabShown=e}setupSidebarScrollHandlers(){for(let e of this.sidebarScrollContainers)e.addEventListener("scroll",()=>this.handleSidebarScroll(e),{passive:!0}),this.handleSidebarScroll(e);window.addEventListener("resize",()=>{for(let e of this.sidebarScrollContainers)this.handleSidebarScroll(e)})}handleSidebarScroll(e){let n=e.clientHeight!==e.scrollHeight,o=e.scrollTop===0,s=e.scrollTop+e.clientHeight===e.scrollHeight;e.parentElement&&(e.parentElement.classList.toggle("scroll-away-from-top",!o&&n),e.parentElement.classList.toggle("scroll-away-from-bottom",!s&&n))}};var Yn=class extends h{setup(){this.container=this.$el,this.input=this.$refs.input,this.userInfoContainer=this.$refs.userInfo,I(this.container,"a.dropdown-search-item","click",this.selectUser.bind(this))}selectUser(t,e){t.preventDefault(),this.input.value=e.getAttribute("data-id"),this.userInfoContainer.innerHTML=e.innerHTML,this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.hide()}hide(){window.$components.firstOnElement(this.container,"dropdown").hide()}};var Jn=class extends h{setup(){this.checkboxes=this.$el.querySelectorAll('input[type="checkbox"]'),this.allCheckbox=this.$el.querySelector('input[type="checkbox"][value="all"]'),this.$el.addEventListener("change",t=>{t.target.checked&&t.target===this.allCheckbox?this.deselectIndividualEvents():t.target.checked&&(this.allCheckbox.checked=!1)})}deselectIndividualEvents(){for(let t of this.checkboxes)t!==this.allCheckbox&&(t.checked=!1)}};var Zn=class extends h{setup(){this.elem=this.$el,this.editContainer=this.$refs.editContainer,this.input=this.$refs.input,this.editor=null;let t={...window.editor_translations,imageUploadErrorText:this.$opts.imageUploadErrorText,serverUploadLimitText:this.$opts.serverUploadLimitText};window.importVersioned("wysiwyg").then(n=>{let o=this.input.value;this.editor=n.createPageEditorInstance(this.editContainer,o,{drawioUrl:this.getDrawIoUrl(),pageId:Number(this.$opts.pageId),darkMode:document.documentElement.classList.contains("dark-mode"),textDirection:this.$opts.textDirection,translations:t}),window.wysiwyg=this.editor});let e=!1;this.input.form.addEventListener("submit",n=>{this.editor&&(e?e=!1:(n.preventDefault(),e=!0,this.editor.getContentAsHtml().then(o=>{this.input.value=o,setTimeout(()=>{this.input.form.requestSubmit()},5)})))})}getDrawIoUrl(){let t=document.querySelector("[drawio-url]");return t?t.getAttribute("drawio-url"):""}async getContent(){return{html:await this.editor.getContentAsHtml()}}};function Wo(i){for(let t=1;t<5;t++)i.shortcuts.add(`meta+${t}`,"",["FormatBlock",!1,`h${t+1}`]);i.shortcuts.add("meta+5","",["FormatBlock",!1,"p"]),i.shortcuts.add("meta+d","",["FormatBlock",!1,"p"]),i.shortcuts.add("meta+6","",["FormatBlock",!1,"blockquote"]),i.shortcuts.add("meta+q","",["FormatBlock",!1,"blockquote"]),i.shortcuts.add("meta+7","",["codeeditor",!1,"pre"]),i.shortcuts.add("meta+e","",["codeeditor",!1,"pre"]),i.shortcuts.add("meta+8","",["FormatBlock",!1,"code"]),i.shortcuts.add("meta+shift+E","",["FormatBlock",!1,"code"]),i.shortcuts.add("meta+o","","InsertOrderedList"),i.shortcuts.add("meta+p","","InsertUnorderedList"),i.shortcuts.add("meta+S","",()=>{window.$events.emit("editor-save-draft")}),i.shortcuts.add("meta+13","",()=>{window.$events.emit("editor-save-page")}),i.shortcuts.add("meta+9","",()=>{let t=i.selection.getNode(),e=t?t.closest(".callout"):null,n=["info","success","warning","danger"],s=(n.findIndex(a=>e&&e.classList.contains(a))+1)%n.length,r=n[s];i.formatter.apply(`callout${r}`)}),i.shortcuts.add("meta+shift+K","",()=>{let t=window.$components.first("entity-selector-popup"),e=i.selection.getContent({format:"text"}).trim();t.show(n=>{i.selection.isCollapsed()?i.insertContent(i.dom.createHTML("a",{href:n.link},i.dom.encode(n.name))):i.formatter.apply("link",{href:n.link}),i.selection.collapse(!1),i.focus()},{initialValue:e,searchEndpoint:"/search/entity-selector",entityTypes:"page,book,chapter,bookshelf",entityPermission:"view"})})}function Uo(i){window.$events.listen("editor::replace",({html:t})=>{i.setContent(t)}),window.$events.listen("editor::append",({html:t})=>{let e=i.getContent()+t;i.setContent(e)}),window.$events.listen("editor::prepend",({html:t})=>{let e=t+i.getContent();i.setContent(e)}),window.$events.listen("editor::insert",({html:t})=>{i.insertContent(t)}),window.$events.listen("editor::focus",()=>{i.initialized&&i.focus()})}function ur(i,t){let e=i.dom.get(encodeURIComponent(t).replace(/!/g,"%21"));e&&(e.scrollIntoView(),i.selection.select(e,!0),i.selection.collapse(!1),i.focus())}function jo(i){let e=new URL(window.location).searchParams.get("content-id");e&&ur(i,e)}var Dt,Qn;function pr(i){return i&&!!(i.textContent||i.innerText)}async function mr(i,t){if(i===null||i.type.indexOf("image")!==0)throw new Error("Not an image file");let e=i.name||`image-${Date.now()}.png`,n=new FormData;return n.append("file",i,e),n.append("uploaded_to",t),(await window.$http.post(window.baseUrl("/images/gallery"),n)).data}function zo(i,t,e){let n=new Wt(e.clipboardData||e.dataTransfer);if(!n.hasItems()||n.containsTabularData())return;let o=n.getImages();for(let s of o){let r=`image-${Math.random().toString(16).slice(2)}`,a=window.baseUrl("/loading.gif");e.preventDefault(),setTimeout(()=>{i.insertContent(`

    `),mr(s,t.pageId).then(l=>{let d=l.name.replace(/"/g,""),u=`${d}`,p=i.dom.create("a",{target:"_blank",href:l.url},u);i.dom.replace(p,r)}).catch(l=>{i.dom.remove(r),window.$events.error(l?.data?.message||t.translations.imageUploadErrorText),console.error(l)})},10)}}function fr(i){let t=i.selection.getNode();t.nodeName==="IMG"&&(Dt=i.dom.getParent(t,".mceTemp"),!Dt&&t.parentNode.nodeName==="A"&&!pr(t.parentNode)&&(Dt=t.parentNode)),t.hasAttribute("contenteditable")&&t.getAttribute("contenteditable")==="false"&&(Qn=t)}function gr(i,t,e){let{dom:n}=i,o=window.tinymce.dom.RangeUtils.getCaretRangeFromPoint(e.clientX,e.clientY,i.getDoc()),s=e.dataTransfer&&e.dataTransfer.getData("bookstack/template");s&&(e.preventDefault(),window.$http.get(`/templates/${s}`).then(r=>{i.selection.setRng(o),i.undoManager.transact(()=>{i.execCommand("mceInsertContent",!1,r.data.html)})})),n.getParent(o.startContainer,".mceTemp")?e.preventDefault():Dt&&(e.preventDefault(),i.undoManager.transact(()=>{i.selection.setRng(o),i.selection.setNode(Dt),n.remove(Dt)})),!e.isDefaultPrevented()&&Qn&&(e.preventDefault(),i.undoManager.transact(()=>{let r=i.selection.getNode(),a=i.selection.getRng(),l=r.closest("body > *");a.startOffset>a.startContainer.length/2?l.after(Qn):l.before(Qn)})),e.isDefaultPrevented()||zo(i,t,e),Dt=null}function vr(i,t){t.preventDefault(),i.focus();let n=window.tinymce.dom.RangeUtils.getCaretRangeFromPoint(t.clientX??0,t.clientY??0,i.getDoc());i.selection.setRng(n)}function Ko(i,t){i.on("dragover",e=>vr(i,e)),i.on("dragstart",()=>fr(i)),i.on("drop",e=>gr(i,t,e)),i.on("paste",e=>zo(i,t,e))}function Xo(i){return["undo redo","styles","bold italic underline forecolor backcolor formatoverflow","alignleft aligncenter alignright alignjustify","bullist numlist listoverflow",i.textDirection==="rtl"?"ltr rtl":"","link customtable imagemanager-insert insertoverflow","code about fullscreen"].filter(n=>!!n).join(" | ")}function wr(i){i.ui.registry.addGroupToolbarButton("formatoverflow",{icon:"more-drawer",tooltip:"More",items:"strikethrough superscript subscript inlinecode removeformat"}),i.ui.registry.addGroupToolbarButton("listoverflow",{icon:"more-drawer",tooltip:"More",items:"tasklist outdent indent"}),i.ui.registry.addGroupToolbarButton("insertoverflow",{icon:"more-drawer",tooltip:"More",items:"customhr codeeditor drawio media details"})}function br(i){i.ui.registry.addContextToolbar("linkcontexttoolbar",{predicate(t){return t.closest("a")!==null},position:"node",scope:"node",items:"link unlink openlink"})}function yr(i){i.ui.registry.addContextToolbar("imagecontexttoolbar",{predicate(t){return t.closest("img")!==null&&!t.hasAttribute("data-mce-object")},position:"node",scope:"node",items:"image"})}function Er(i){i.ui.registry.addContextToolbar("objectcontexttoolbar",{predicate(t){return t.closest("img")!==null&&t.hasAttribute("data-mce-object")},position:"node",scope:"node",items:"media"})}function Go(i){wr(i),br(i),yr(i),Er(i)}var Cr={"table-delete-column":'',"table-delete-row":'',"table-insert-column-after":'',"table-insert-column-before":'',"table-insert-row-above":'',"table-insert-row-after":'',table:'',"table-delete-table":''};function Yo(i){for(let[t,e]of Object.entries(Cr))i.ui.registry.addIcon(t,e)}function Lr(i){i.serializer.addNodeFilter("br",t=>{for(let e of t)if(e.parent&&e.parent.name==="code"){let n=window.tinymce.html.Node.create("#text");n.value=` `,e.replace(n)}})}function xr(i){i.parser.addNodeFilter("div",t=>{for(let e of t){let n=e.attr("id")||"",o=e.attr("class")||"";(n==="pointer"||o.includes("pointer"))&&e.remove()}})}function Jo(i){Lr(i),xr(i)}function Zo(i){return i.tagName.toLowerCase()==="code-block"}function ts(i,t,e,n,o){let s=window.$components.first("code-editor"),r=i.selection.getBookmark();s.open(t,e,n,(a,l)=>{o(a,l),i.focus(),i.selection.moveToBookmark(r)},()=>{i.focus(),i.selection.moveToBookmark(r)})}function Qo(i,t){let e=t.getAttribute("dir")||"";ts(i,t.getContent(),t.getLanguage(),e,(n,o)=>{t.setContent(n,o)})}function Tr(i){let t=i.getDoc(),e=t.defaultView;class n extends e.HTMLElement{constructor(){super();c(this,"editor",null);this.attachShadow({mode:"open"});let r=document.head.querySelectorAll('link[rel="stylesheet"]:not([media="print"]),style'),a=Array.from(r).map(d=>d.cloneNode(!0)),l=document.createElement("div");l.style.pointerEvents="none",l.contentEditable="false",l.classList.add("CodeMirrorContainer"),l.classList.toggle("dark-mode",document.documentElement.classList.contains("dark-mode")),this.shadowRoot.append(...a,l)}getLanguage(){let r=d=>(d.split(" ").filter(p=>p.startsWith("language-"))[0]||"").replace("language-",""),a=this.querySelector("code"),l=this.querySelector("pre");return r(l.className)||a&&r(a.className)||""}setContent(r,a){this.editor&&(this.editor.setContent(r),this.editor.setMode(a,r));let l=this.querySelector("pre");l||(l=t.createElement("pre"),this.append(l)),l.innerHTML="";let d=t.createElement("code");l.append(d),d.innerText=r,d.className=`language-${a}`}getContent(){let r=this.querySelector("code")||this.querySelector("pre"),a=document.createElement("pre");a.innerHTML=r.innerHTML.replace(/\ufeff/g,"");let l=a.querySelectorAll("br");for(let d of l)d.replaceWith(` `);return a.textContent}connectedCallback(){let r=Date.now();if(this.editor)return;this.cleanChildContent();let a=this.getContent(),d=a.split(` -`).length*19.2+18+24;this.style.height=`${d}px`;let u=this.shadowRoot.querySelector(".CodeMirrorContainer"),p=f=>{this.editor=f.wysiwygView(u,this.shadowRoot,a,this.getLanguage()),setTimeout(()=>{this.style.height=null},12)};window.importVersioned("code").then(f=>{let v=Date.now()-r<20?20:0;setTimeout(()=>p(f),v)})}cleanChildContent(){let r=this.querySelector("pre");if(r)for(let a of r.childNodes)a.nodeName==="#text"&&a.textContent==="\uFEFF"&&a.remove()}}e.customElements.define("code-block",n)}function Sr(i){i.ui.registry.addIcon("codeblock",''),i.ui.registry.addButton("codeeditor",{tooltip:"Insert code block",icon:"codeblock",onAction(){i.execCommand("codeeditor")}}),i.ui.registry.addButton("editcodeeditor",{tooltip:"Edit code block",icon:"edit-block",onAction(){i.execCommand("codeeditor")}}),i.addCommand("codeeditor",()=>{let t=i.selection.getNode(),e=t.ownerDocument;if(Zo(t))Qo(i,t);else{let n=i.selection.getContent({format:"text"}),o=document.dir==="rtl"?"ltr":"";ts(i,n,"",o,(s,r)=>{let a=e.createElement("pre"),l=e.createElement("code");l.classList.add(`language-${r}`),l.innerText=s,o&&a.setAttribute("dir",o),a.append(l),i.insertContent(a.outerHTML)})}}),i.on("dblclick",()=>{let t=i.selection.getNode();Zo(t)&&Qo(i,t)}),i.on("PreInit",()=>{i.parser.addNodeFilter("pre",t=>{for(let e of t){let n=window.tinymce.html.Node.create("code-block",{contenteditable:"false"}),o=e.children().filter(a=>a.name==="code")[0]||null,s=e.attr("dir")||o&&o.attr("dir")||"";s&&n.attr("dir",s);let r=e.getAll("span");for(let a of r)a.unwrap();e.attr("style",null),e.wrap(n)}}),i.parser.addNodeFilter("code-block",t=>{for(let e of t)e.attr("contenteditable","false")}),i.serializer.addNodeFilter("code-block",t=>{for(let e of t){let n=e.attr("dir");n&&e.firstChild?e.firstChild.attr("dir",n):e.firstChild&&e.firstChild.attr("dir",null),e.unwrap()}})}),i.ui.registry.addContextToolbar("codeeditor",{predicate(t){return t.nodeName.toLowerCase()==="code-block"},items:"editcodeeditor",position:"node",scope:"node"}),i.on("PreInit",()=>{Tr(i)})}function es(){return Sr}function ti(i){return new Promise((t,e)=>{i.oncomplete=i.onsuccess=()=>t(i.result),i.onabort=i.onerror=()=>e(i.error)})}function kr(i,t){let e,n=()=>{if(e)return e;let o=indexedDB.open(i);return o.onupgradeneeded=()=>o.result.createObjectStore(t),e=ti(o),e.then(s=>{s.onclose=()=>e=void 0},()=>{}),e};return(o,s)=>n().then(r=>s(r.transaction(t,o).objectStore(t)))}var Bi;function Pi(){return Bi||(Bi=kr("keyval-store","keyval")),Bi}function Ri(i,t=Pi()){return t("readonly",e=>ti(e.get(i)))}function Oi(i,t,e=Pi()){return e("readwrite",n=>(n.put(t,i),ti(n.transaction)))}function Ni(i,t=Pi()){return t("readwrite",e=>(e.delete(i),ti(e.transaction)))}var it=null,qi,ei,Fi,_i="last-drawing-save";function Vi(i){it?.contentWindow?.postMessage(JSON.stringify(i),qi)}function Mr(i){Oi(_i,i.data),Fi&&Fi(i.data).then(()=>{Ni(_i)})}function Dr(i){Vi({action:"export",format:"xmlpng",xml:i.xml,spin:"Updating drawing"})}function Ar(){ei&&ei().then(i=>{Vi({action:"load",autosave:1,xml:i})})}function Ir(){let i={};it&&(window.$events.emitPublic(it,"editor-drawio::configure",{config:i}),Vi({action:"configure",config:i}))}function ns(){window.removeEventListener("message",is),it&&document.body.removeChild(it)}function is(i){if(!i.data||i.data.length<1||i.origin!==qi)return;let t=JSON.parse(i.data);t.event==="init"?Ar():t.event==="exit"?ns():t.event==="save"?Dr(t):t.event==="export"?Mr(t):t.event==="configure"&&Ir()}async function Hr(){let i=await Ri(_i),t=document.getElementById("unsaved-drawing-dialog");t||console.error("Missing expected unsaved-drawing dialog"),i&&t&&await window.$components.firstOnElement(t,"confirm-dialog").show()&&(ei=async()=>i)}async function os(i,t,e){ei=t,Fi=e,await Hr(),it=document.createElement("iframe"),it.setAttribute("frameborder","0"),window.addEventListener("message",is),it.setAttribute("src",i),it.setAttribute("class","fullscreen"),it.style.backgroundColor="#FFFFFF",document.body.appendChild(it),qi=new URL(i).origin}async function Wi(i,t){let e={image:i,uploaded_to:t};return(await window.$http.post(window.baseUrl("/images/drawio"),e)).data}function ni(){ns()}async function ss(i){try{return`data:image/png;base64,${(await window.$http.get(window.baseUrl(`/images/drawio/base64/${i}`))).data.content}`}catch(t){throw t instanceof Lt&&window.$events.showResponseError(t),ni(),t}}var K=null,It=null,At={};function Ui(i){return i.hasAttribute("drawio-diagram")}function Pr(i,t=null){K=i,It=t,window.$components.first("image-manager").show(n=>{if(t){let o=t.querySelector("img");K.undoManager.transact(()=>{K.dom.setAttrib(o,"src",n.url),K.dom.setAttrib(t,"drawio-diagram",n.id)})}else{let o=`
    `;K.insertContent(o)}},"drawio")}async function Rr(i){let t=window.baseUrl("/loading.gif"),e=s=>{s.status===413?window.$events.emit("error",At.translations.serverUploadLimitText):window.$events.emit("error",At.translations.imageUploadErrorText),console.error(s)};if(It){ni();let s=It.querySelector("img");try{let r=await Wi(i,At.pageId);K.undoManager.transact(()=>{K.dom.setAttrib(s,"src",r.url),K.dom.setAttrib(It,"drawio-diagram",r.id)})}catch(r){throw e(r),new Error(`Failed to save image with error: ${r}`,{cause:r})}return}await eo(5);let n=`drawing-${Math.random().toString(16).slice(2)}`,o=`drawing-wrap-${Math.random().toString(16).slice(2)}`;K.insertContent(`
    `),ni();try{let s=await Wi(i,At.pageId);K.undoManager.transact(()=>{K.dom.setAttrib(n,"src",s.url),K.dom.setAttrib(o,"drawio-diagram",s.id)})}catch(s){throw K.dom.remove(o),e(s),new Error(`Failed to save image with error: ${s}`,{cause:s})}}function Or(){if(!It)return Promise.resolve("");let i=It.getAttribute("drawio-diagram");return ss(i)}function rs(i,t=null){K=i,It=t,os(At.drawioUrl,Or,Rr)}function Nr(i){i.addCommand("drawio",()=>{let t=i.selection.getNode();rs(i,Ui(t)?t:null)}),i.ui.registry.addIcon("diagram",``),i.ui.registry.addSplitButton("drawio",{tooltip:"Insert/edit drawing",icon:"diagram",onAction(){i.execCommand("drawio"),window.document.body.dispatchEvent(new Event("mousedown",{bubbles:!0}))},fetch(t){t([{type:"choiceitem",text:"Drawing manager",value:"drawing-manager"}])},onItemAction(t,e){if(e==="drawing-manager"){let n=i.selection.getNode();Pr(i,Ui(n)?n:null)}}}),i.on("dblclick",()=>{let t=i.selection.getNode();Ui(t)&&rs(i,t)}),i.on("SetContent",()=>{let t=i.dom.select("body > div[drawio-diagram]");t.length&&i.undoManager.transact(()=>{for(let e of t)e.setAttribute("contenteditable","false")})})}function as(i){return At=i,Nr}function Fr(i){i.addCommand("InsertHorizontalRule",()=>{let t=document.createElement("hr"),e=i.selection.getNode(),{parentNode:n}=e;n.insertBefore(t,e)}),i.ui.registry.addButton("customhr",{icon:"horizontal-rule",tooltip:"Insert horizontal line",onAction(){i.execCommand("InsertHorizontalRule")}})}function ls(){return Fr}function _r(i){i.ui.registry.addButton("imagemanager-insert",{title:"Insert image",icon:"image",tooltip:"Insert image",onAction(){window.$components.first("image-manager").show(e=>{let n=e.thumbs?.display||e.url,o=``;o+=`${e.name}`,o+="",i.execCommand("mceInsertContent",!1,o)},"gallery")}})}function cs(){return _r}function qr(i){let t={title:"About the WYSIWYG Editor",url:window.baseUrl("/help/tinymce")};i.ui.registry.addButton("about",{icon:"help",tooltip:"About the editor",onAction(){window.tinymce.activeEditor.windowManager.openUrl(t)}})}function ds(){return qr}var hs=["p","h1","h2","h3","h4","h5","h6","div","blockquote","pre","code-block","details","ul","ol","table","hr"];function ii(i){return i.selection.getNode().closest("details")}function Vr(i,t){let e=ii(i);e&&i.undoManager.transact(()=>{let n=e.querySelector("summary");n||(n=document.createElement("summary"),e.prepend(n)),n.textContent=t})}function Wr(i){return{title:"Edit collapsible block",body:{type:"panel",items:[{type:"input",name:"summary",label:"Toggle label"}]},buttons:[{type:"cancel",text:"Cancel"},{type:"submit",text:"Save",primary:!0}],onSubmit(t){let{summary:e}=t.getData();Vr(i,e),t.close()}}}function Ur(i){let t=i.querySelector("summary");return t?t.textContent:""}function us(i){let t=ii(i);i.windowManager.open(Wr(i)).setData({summary:Ur(t)})}function jr(i){let t=i.selection.getNode().closest("details"),e=i.selection.getBookmark();if(t){let n=t.querySelectorAll("details > *:not(summary, doc-root), doc-root > *");i.undoManager.transact(()=>{for(let o of n)t.parentNode.insertBefore(o,t);t.remove()})}i.focus(),i.selection.moveToBookmark(e)}function ji(i){i.attr("contenteditable",null);let t=!1;for(let e of i.children())e.name==="doc-root"&&(e.unwrap(),t=!0);t&&ji(i)}function zr(i){ji(i),i.attr("contenteditable","false");let t=window.tinymce.html.Node.create("doc-root",{contenteditable:"true"}),e=null;for(let n of i.children()){if(n.name==="summary")continue;hs.includes(n.name)?(t.append(n),e=null):(e||(e=window.tinymce.html.Node.create("p"),t.append(e)),e.append(n))}i.append(t)}function Kr(i){i.parser.addNodeFilter("details",t=>{for(let e of t)zr(e)}),i.serializer.addNodeFilter("details",t=>{for(let e of t)ji(e),e.attr("open",null)}),i.serializer.addNodeFilter("doc-root",t=>{for(let e of t)e.unwrap()})}function Xr(i){i.ui.registry.addIcon("details",''),i.ui.registry.addIcon("togglefold",''),i.ui.registry.addIcon("togglelabel",''),i.ui.registry.addButton("details",{icon:"details",tooltip:"Insert collapsible block",onAction(){i.execCommand("InsertDetailsBlock")}}),i.ui.registry.addButton("removedetails",{icon:"table-delete-table",tooltip:"Unwrap",onAction(){jr(i)}}),i.ui.registry.addButton("editdetials",{icon:"togglelabel",tooltip:"Edit label",onAction(){us(i)}}),i.on("dblclick",t=>{!ii(i)||t.target.closest("doc-root")||us(i)}),i.ui.registry.addButton("toggledetails",{icon:"togglefold",tooltip:"Toggle open/closed",onAction(){ii(i).toggleAttribute("open"),i.focus()}}),i.addCommand("InsertDetailsBlock",()=>{let t=i.selection.getContent({format:"html"}),e=document.createElement("details"),n=document.createElement("summary"),o=`details-${Date.now()}`;e.setAttribute("data-id",o),e.appendChild(n),t||(t="


    "),e.innerHTML+=t,i.insertContent(e.outerHTML),i.focus();let s=i.dom.select(`[data-id="${o}"]`)[0]||null;if(s){let r=s.querySelector("doc-root > *");r&&r.focus(),s.removeAttribute("data-id")}}),i.ui.registry.addContextToolbar("details",{predicate(t){return t.nodeName.toLowerCase()==="details"},items:"editdetials toggledetails removedetails",position:"node",scope:"node"}),i.on("PreInit",()=>{Kr(i)})}function ps(){return Xr}function Gr(i){i.ui.registry.addIcon("tableclearformatting",'');let t={items:" | tablerowheader",predicate(n){let o=n.nodeName.toLowerCase()==="table",s=i.selection.getNode(),r=s.closest("table");return!o||!r?!1:r.querySelector("tr").contains(s)},position:"node",scope:"node"};i.ui.registry.addContextToolbar("customtabletoolbarfirstrow",t),i.addCommand("tableclearformatting",()=>{let n=i.dom.getParent(i.selection.getStart(),"table");if(!n)return;let o=["class","style","width","height"],s=[n,...n.querySelectorAll(o.map(r=>`[${r}]`).join(","))];for(let r of s)for(let a of o)r.removeAttribute(a)}),i.addCommand("tableclearsizes",()=>{let n=i.dom.getParent(i.selection.getStart(),"table");if(!n)return;let o=[n,...n.querySelectorAll("tr,td,th,tbody,thead,tfoot,th>*,td>*")];for(let s of o)s.removeAttribute("width"),s.removeAttribute("height"),s.style.height=null,s.style.width=null});let e=()=>{let n=i.ui.registry.getAll().buttons;i.ui.registry.addMenuButton("customtable",{...n.table,fetch:o=>o("inserttable | cell row column | advtablesort | tableprops tableclearformatting tableclearsizes deletetable")}),i.ui.registry.addMenuItem("tableclearformatting",{icon:"tableclearformatting",text:"Clear table formatting",onSetup:n.tableprops.onSetup,onAction(){i.execCommand("tableclearformatting")}}),i.ui.registry.addMenuItem("tableclearsizes",{icon:"resize",text:"Resize to contents",onSetup:n.tableprops.onSetup,onAction(){i.execCommand("tableclearsizes")}}),i.off("PreInit",e)};i.on("PreInit",e)}function ms(){return Gr}function Yr(i){let t=i.closest("li");return t&&t.parentNode.nodeName==="UL"&&t.classList.contains("task-list-item")}function Jr(i,t,e){let n=t.getBoundingClientRect();i.clientX<=n.right&&i.clientX>=n.left&&i.clientY>=n.top&&i.clientY<=n.bottom||e.undoManager.transact(()=>{t.hasAttribute("checked")?t.removeAttribute("checked"):t.setAttribute("checked","checked")})}function Zr(i){i.attr("class","task-list-item");for(let t of i.children())t.name==="input"&&(t.attr("checked")==="checked"&&i.attr("checked","checked"),t.remove())}function Qr(i){let t=i.attr("checked")==="checked";i.attr("checked",null);let e={type:"checkbox",disabled:"disabled"};t&&(e.checked="checked");let n=window.tinymce.html.Node.create("input",e);n.shortEnded=!0,i.firstChild?i.insert(n,i.firstChild,!0):i.append(n)}function ta(i){i.ui.registry.addIcon("tasklist",''),i.ui.registry.addToggleButton("tasklist",{tooltip:"Task list",icon:"tasklist",active:!1,onAction(n){n.isActive()?i.execCommand("RemoveList"):i.execCommand("InsertUnorderedList",null,{"list-item-attributes":{class:"task-list-item"},"list-style-type":"tasklist"})},onSetup(n){i.on("NodeChange",o=>{let s=o.parents.find(a=>a.nodeName==="LI"),r=s&&s.classList.contains("task-list-item");n.setActive(!!r)})}});let t=i.ui.registry.getAll().buttons.bullist;t.onSetup=function(o){i.on("NodeChange",s=>{let r=s.parents.find(d=>d.nodeName==="LI"),a=r&&r.classList.contains("task-list-item"),l=r&&r.parentNode.nodeName==="UL";o.setActive(!!(l&&!a))})},t.onAction=function(){Yr(i.selection.getNode())&&i.execCommand("InsertOrderedList",null,{"list-item-attributes":{class:null}}),i.execCommand("InsertUnorderedList",null,{"list-item-attributes":{class:null}})};let e=i.ui.registry.getAll().buttons.numlist;e.onAction=function(){i.execCommand("InsertOrderedList",null,{"list-item-attributes":{class:null}})},i.on("PreInit",()=>{i.parser.addNodeFilter("li",n=>{for(let o of n)o.attributes.map.class==="task-list-item"&&Zr(o)}),i.serializer.addNodeFilter("li",n=>{for(let o of n)o.attributes.map.class==="task-list-item"&&Qr(o)})}),i.on("click",n=>{let o=n.target;o.nodeName==="LI"&&o.classList.contains("task-list-item")&&(Jr(n,o,i),n.preventDefault())})}function fs(){return ta}function gs(i){function t(e){let n=e.querySelector("iframe, video");if(!n)return;let o=[...n.classList.values()].filter(r=>r.startsWith("align-")),s=[...e.classList.values()].filter(r=>r.startsWith("align-"));e.classList.remove(...s),e.classList.add(...o)}i.on("SetContent",()=>{let e=i.dom.select("span.mce-preview-object");for(let n of e)t(n)}),i.on("FormatApply",e=>{let n=e.format.startsWith("align");if(!(e.node instanceof i.dom.doc.defaultView.HTMLElement)||!n||!e.node.matches(".mce-preview-object"))return;let s=e.node.querySelector("iframe, video");if(s){let r=(i.formatter.get(e.format)[0]?.classes||[])[0],a=!s.classList.contains(r),d=(e.node.getAttribute("data-mce-p-class")||"").split(" ").filter(p=>!p.startsWith("align-"));a&&d.push(r);let u=d.join(" ");e.node.setAttribute("data-mce-p-class",u),s.setAttribute("class",u),i.formatter.apply(e.format,{},s),t(e.node)}})}function vs(i){let t=i.querySelectorAll('[align],[style*="text-align"],.align-center,.align-left,.align-right');for(let e of t)e.removeAttribute("align"),e.style.textAlign=null,e.classList.remove("align-center","align-right","align-left")}function zi(i){let t=i.querySelectorAll('[dir],[style*="direction"]');for(let e of t)e.removeAttribute("dir"),e.style.direction=null;vs(i),i.style.direction=null,i.style.textAlign=null,i.removeAttribute("align")}function ws(i){let t=[];i.on("TableSelectionChange",n=>{t=(n.cells||[]).map(o=>o.dom)}),i.on("TableSelectionClear",()=>{t=[]});let e={RemoveFormat:n=>{let o=["class","style","width","height","align"];for(let s of o)n.removeAttribute(s)},mceDirectionLTR:n=>{n.setAttribute("dir","ltr"),zi(n)},mceDirectionRTL:n=>{n.setAttribute("dir","rtl"),zi(n)},JustifyLeft:n=>{n.removeAttribute("align"),vs(n)}};e.JustifyRight=e.JustifyLeft,e.JustifyCenter=e.JustifyLeft,e.JustifyFull=e.JustifyLeft,i.on("ExecCommand",n=>{let o=e[n.command];if(o)for(let s of t)o(s)})}function bs(i){i.on("ExecCommand",t=>{let e=t.command;if(e!=="mceDirectionLTR"&&e!=="mceDirectionRTL")return;let n=i.selection.getSelectedBlocks();for(let o of n)zi(o)})}var ea=[{title:"Large Header",format:"h2",preview:"color: blue;"},{title:"Medium Header",format:"h3"},{title:"Small Header",format:"h4"},{title:"Tiny Header",format:"h5"},{title:"Paragraph",format:"p",exact:!0,classes:""},{title:"Blockquote",format:"blockquote"},{title:"Callouts",items:[{title:"Information",format:"calloutinfo"},{title:"Success",format:"calloutsuccess"},{title:"Warning",format:"calloutwarning"},{title:"Danger",format:"calloutdanger"}]}],na={alignleft:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img,iframe,video",classes:"align-left"},aligncenter:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img,iframe,video",classes:"align-center"},alignright:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img,iframe,video",classes:"align-right"},calloutsuccess:{block:"p",exact:!0,attributes:{class:"callout success"}},calloutinfo:{block:"p",exact:!0,attributes:{class:"callout info"}},calloutwarning:{block:"p",exact:!0,attributes:{class:"callout warning"}},calloutdanger:{block:"p",exact:!0,attributes:{class:"callout danger"}}},ia=["#BFEDD2","","#FBEEB8","","#F8CAC6","","#ECCAFA","","#C2E0F4","","#2DC26B","","#F1C40F","","#E03E2D","","#B96AD9","","#3598DB","","#169179","","#E67E23","","#BA372A","","#843FA1","","#236FA1","","#ECF0F1","","#CED4D9","","#95A5A6","","#7E8C8D","","#34495E","","#000000","","#ffffff",""];function oa(i,t,e){if(e.filetype==="file"){let n=window.$components.first("entity-selector-popup"),o=this.selection.getContent({format:"text"}).trim();n.show(s=>{i(s.link,{text:s.name,title:s.name})},{initialValue:o,searchEndpoint:"/search/entity-selector",entityTypes:"page,book,chapter,bookshelf",entityPermission:"view"})}e.filetype==="image"&&window.$components.first("image-manager").show(o=>{i(o.url,{alt:o.name})},"gallery")}function sa(i){let t=["image","table","link","autolink","fullscreen","code","customhr","autosave","lists","codeeditor","media","imagemanager","about","details","tasklist","tableadditions",i.textDirection==="rtl"?"directionality":""];return window.tinymce.PluginManager.add("codeeditor",es()),window.tinymce.PluginManager.add("customhr",ls()),window.tinymce.PluginManager.add("imagemanager",cs()),window.tinymce.PluginManager.add("about",ds()),window.tinymce.PluginManager.add("details",ps()),window.tinymce.PluginManager.add("tasklist",fs()),window.tinymce.PluginManager.add("tableadditions",ms()),i.drawioUrl&&(window.tinymce.PluginManager.add("drawio",as(i)),t.push("drawio")),t.filter(e=>!!e)}function ra(i){let t=document.head.innerHTML.split(` +`).length*19.2+18+24;this.style.height=`${d}px`;let u=this.shadowRoot.querySelector(".CodeMirrorContainer"),p=f=>{this.editor=f.wysiwygView(u,this.shadowRoot,a,this.getLanguage()),setTimeout(()=>{this.style.height=null},12)};window.importVersioned("code").then(f=>{let v=Date.now()-r<20?20:0;setTimeout(()=>p(f),v)})}cleanChildContent(){let r=this.querySelector("pre");if(r)for(let a of r.childNodes)a.nodeName==="#text"&&a.textContent==="\uFEFF"&&a.remove()}}e.customElements.define("code-block",n)}function Sr(i){i.ui.registry.addIcon("codeblock",''),i.ui.registry.addButton("codeeditor",{tooltip:"Insert code block",icon:"codeblock",onAction(){i.execCommand("codeeditor")}}),i.ui.registry.addButton("editcodeeditor",{tooltip:"Edit code block",icon:"edit-block",onAction(){i.execCommand("codeeditor")}}),i.addCommand("codeeditor",()=>{let t=i.selection.getNode(),e=t.ownerDocument;if(Zo(t))Qo(i,t);else{let n=i.selection.getContent({format:"text"}),o=document.dir==="rtl"?"ltr":"";ts(i,n,"",o,(s,r)=>{let a=e.createElement("pre"),l=e.createElement("code");l.classList.add(`language-${r}`),l.innerText=s,o&&a.setAttribute("dir",o),a.append(l),i.insertContent(a.outerHTML)})}}),i.on("dblclick",()=>{let t=i.selection.getNode();Zo(t)&&Qo(i,t)}),i.on("PreInit",()=>{i.parser.addNodeFilter("pre",t=>{for(let e of t){let n=window.tinymce.html.Node.create("code-block",{contenteditable:"false"}),o=e.children().filter(a=>a.name==="code")[0]||null,s=e.attr("dir")||o&&o.attr("dir")||"";s&&n.attr("dir",s);let r=e.getAll("span");for(let a of r)a.unwrap();e.attr("style",null),e.wrap(n)}}),i.parser.addNodeFilter("code-block",t=>{for(let e of t)e.attr("contenteditable","false")}),i.serializer.addNodeFilter("code-block",t=>{for(let e of t){let n=e.attr("dir");n&&e.firstChild?e.firstChild.attr("dir",n):e.firstChild&&e.firstChild.attr("dir",null),e.unwrap()}})}),i.ui.registry.addContextToolbar("codeeditor",{predicate(t){return t.nodeName.toLowerCase()==="code-block"},items:"editcodeeditor",position:"node",scope:"node"}),i.on("PreInit",()=>{Tr(i)})}function es(){return Sr}function ti(i){return new Promise((t,e)=>{i.oncomplete=i.onsuccess=()=>t(i.result),i.onabort=i.onerror=()=>e(i.error)})}function kr(i,t){let e,n=()=>{if(e)return e;let o=indexedDB.open(i);return o.onupgradeneeded=()=>o.result.createObjectStore(t),e=ti(o),e.then(s=>{s.onclose=()=>e=void 0},()=>{}),e};return(o,s)=>n().then(r=>s(r.transaction(t,o).objectStore(t)))}var Bi;function Pi(){return Bi||(Bi=kr("keyval-store","keyval")),Bi}function Ri(i,t=Pi()){return t("readonly",e=>ti(e.get(i)))}function Oi(i,t,e=Pi()){return e("readwrite",n=>(n.put(t,i),ti(n.transaction)))}function Ni(i,t=Pi()){return t("readwrite",e=>(e.delete(i),ti(e.transaction)))}var it=null,qi,ei,Fi,_i="last-drawing-save";function Vi(i){it?.contentWindow?.postMessage(JSON.stringify(i),qi)}function Mr(i){Oi(_i,i.data),Fi&&Fi(i.data).then(()=>{Ni(_i)})}function Dr(i){Vi({action:"export",format:"xmlpng",xml:i.xml,spin:"Updating drawing"})}function Ar(){ei&&ei().then(i=>{Vi({action:"load",autosave:1,xml:i})})}function Ir(){let i={};it&&(window.$events.emitPublic(it,"editor-drawio::configure",{config:i}),Vi({action:"configure",config:i}))}function ns(){window.removeEventListener("message",is),it&&document.body.removeChild(it)}function is(i){if(!i.data||i.data.length<1||i.origin!==qi)return;let t=JSON.parse(i.data);t.event==="init"?Ar():t.event==="exit"?ns():t.event==="save"?Dr(t):t.event==="export"?Mr(t):t.event==="configure"&&Ir()}async function Hr(){let i=await Ri(_i),t=document.getElementById("unsaved-drawing-dialog");t||console.error("Missing expected unsaved-drawing dialog"),i&&t&&await window.$components.firstOnElement(t,"confirm-dialog").show()&&(ei=async()=>i)}async function os(i,t,e){ei=t,Fi=e,await Hr(),it=document.createElement("iframe"),it.setAttribute("frameborder","0"),window.addEventListener("message",is),it.setAttribute("src",i),it.setAttribute("class","fullscreen"),it.style.backgroundColor="#FFFFFF",document.body.appendChild(it),qi=new URL(i).origin}async function Wi(i,t){let e={image:i,uploaded_to:t};return(await window.$http.post(window.baseUrl("/images/drawio"),e)).data}function ni(){ns()}async function ss(i){try{return`data:image/png;base64,${(await window.$http.get(window.baseUrl(`/images/drawio/base64/${i}`))).data.content}`}catch(t){throw t instanceof Lt&&window.$events.showResponseError(t),ni(),t}}var K=null,It=null,At={};function Ui(i){return i.hasAttribute("drawio-diagram")}function Pr(i,t=null){K=i,It=t,window.$components.first("image-manager").show(n=>{if(t){let o=t.querySelector("img");K.undoManager.transact(()=>{K.dom.setAttrib(o,"src",n.url),K.dom.setAttrib(t,"drawio-diagram",n.id)})}else{let o=`
    `;K.insertContent(o)}},"drawio")}async function Rr(i){let t=window.baseUrl("/loading.gif"),e=s=>{s.status===413?window.$events.emit("error",At.translations.serverUploadLimitText):window.$events.emit("error",At.translations.imageUploadErrorText),console.error(s)};if(It){ni();let s=It.querySelector("img");try{let r=await Wi(i,At.pageId);K.undoManager.transact(()=>{K.dom.setAttrib(s,"src",r.url),K.dom.setAttrib(It,"drawio-diagram",r.id)})}catch(r){throw e(r),new Error(`Failed to save image with error: ${r}`,{cause:r})}return}await eo(5);let n=`drawing-${Math.random().toString(16).slice(2)}`,o=`drawing-wrap-${Math.random().toString(16).slice(2)}`;K.insertContent(`
    `),ni();try{let s=await Wi(i,At.pageId);K.undoManager.transact(()=>{K.dom.setAttrib(n,"src",s.url),K.dom.setAttrib(o,"drawio-diagram",s.id)})}catch(s){throw K.dom.remove(o),e(s),new Error(`Failed to save image with error: ${s}`,{cause:s})}}function Or(){if(!It)return Promise.resolve("");let i=It.getAttribute("drawio-diagram");return ss(i)}function rs(i,t=null){K=i,It=t,os(At.drawioUrl,Or,Rr)}function Nr(i){i.addCommand("drawio",()=>{let t=i.selection.getNode();rs(i,Ui(t)?t:null)}),i.ui.registry.addIcon("diagram",``),i.ui.registry.addSplitButton("drawio",{tooltip:"Insert/edit drawing",icon:"diagram",onAction(){i.execCommand("drawio"),window.document.body.dispatchEvent(new Event("mousedown",{bubbles:!0}))},fetch(t){t([{type:"choiceitem",text:"Drawing manager",value:"drawing-manager"}])},onItemAction(t,e){if(e==="drawing-manager"){let n=i.selection.getNode();Pr(i,Ui(n)?n:null)}}}),i.on("dblclick",()=>{let t=i.selection.getNode();Ui(t)&&rs(i,t)}),i.on("SetContent",()=>{let t=i.dom.select("body > div[drawio-diagram]");t.length&&i.undoManager.transact(()=>{for(let e of t)e.setAttribute("contenteditable","false")})})}function as(i){return At=i,Nr}function Fr(i){i.addCommand("InsertHorizontalRule",()=>{let t=document.createElement("hr"),e=i.selection.getNode(),{parentNode:n}=e;n.insertBefore(t,e)}),i.ui.registry.addButton("customhr",{icon:"horizontal-rule",tooltip:"Insert horizontal line",onAction(){i.execCommand("InsertHorizontalRule")}})}function ls(){return Fr}function _r(i){i.ui.registry.addButton("imagemanager-insert",{title:"Insert image",icon:"image",tooltip:"Insert image",onAction(){window.$components.first("image-manager").show(e=>{let n=e.thumbs?.display||e.url,o=``;o+=`${e.name}`,o+="",i.execCommand("mceInsertContent",!1,o)},"gallery")}})}function cs(){return _r}function qr(i){let t={title:"About the WYSIWYG Editor",url:window.baseUrl("/help/tinymce")};i.ui.registry.addButton("about",{icon:"help",tooltip:"About the editor",onAction(){window.tinymce.activeEditor.windowManager.openUrl(t)}})}function ds(){return qr}var hs=["p","h1","h2","h3","h4","h5","h6","div","blockquote","pre","code-block","details","ul","ol","table","hr"];function ii(i){return i.selection.getNode().closest("details")}function Vr(i,t){let e=ii(i);e&&(i.undoManager.transact(()=>{let n=e.querySelector("summary");n||(n=document.createElement("summary"),e.prepend(n)),n.textContent=t}),i.selection.select(e))}function Wr(i){return{title:"Edit collapsible block",body:{type:"panel",items:[{type:"input",name:"summary",label:"Toggle label"}]},buttons:[{type:"cancel",text:"Cancel"},{type:"submit",text:"Save",primary:!0}],onSubmit(t){let{summary:e}=t.getData();Vr(i,e),t.close()}}}function Ur(i){let t=i.querySelector("summary");return t?t.textContent:""}function us(i){let t=ii(i);i.windowManager.open(Wr(i)).setData({summary:Ur(t)})}function jr(i){let t=i.selection.getNode().closest("details"),e=i.selection.getBookmark();if(t){let n=t.querySelectorAll("details > *:not(summary, doc-root), doc-root > *");i.undoManager.transact(()=>{for(let o of n)t.parentNode.insertBefore(o,t);t.remove()})}i.focus(),i.selection.moveToBookmark(e)}function ji(i){i.attr("contenteditable",null);let t=!1;for(let e of i.children())e.name==="doc-root"&&(e.unwrap(),t=!0);t&&ji(i)}function zr(i){ji(i),i.attr("contenteditable","false");let t=window.tinymce.html.Node.create("doc-root",{contenteditable:"true"}),e=null;for(let n of i.children()){if(n.name==="summary")continue;hs.includes(n.name)?(t.append(n),e=null):(e||(e=window.tinymce.html.Node.create("p"),t.append(e)),e.append(n))}i.append(t)}function Kr(i){i.parser.addNodeFilter("details",t=>{for(let e of t)zr(e)}),i.serializer.addNodeFilter("details",t=>{for(let e of t)ji(e),e.attr("open",null)}),i.serializer.addNodeFilter("doc-root",t=>{for(let e of t)e.unwrap()})}function Xr(i){i.ui.registry.addIcon("details",''),i.ui.registry.addIcon("togglefold",''),i.ui.registry.addIcon("togglelabel",''),i.ui.registry.addButton("details",{icon:"details",tooltip:"Insert collapsible block",onAction(){i.execCommand("InsertDetailsBlock")}}),i.ui.registry.addButton("removedetails",{icon:"table-delete-table",tooltip:"Unwrap",onAction(){jr(i)}}),i.ui.registry.addButton("editdetials",{icon:"togglelabel",tooltip:"Edit label",onAction(){us(i)}}),i.on("dblclick",t=>{let e=t?.target?.ownerDocument?.defaultView?.HTMLDetailsElement;e&&t.target instanceof e&&ii(i)&&(us(i),t.preventDefault(),t.stopPropagation())}),i.ui.registry.addButton("toggledetails",{icon:"togglefold",tooltip:"Toggle open/closed",onAction(){ii(i).toggleAttribute("open"),i.focus()}}),i.addCommand("InsertDetailsBlock",()=>{let t=i.selection.getContent({format:"html"}),e=document.createElement("details"),n=document.createElement("summary"),o=`details-${Date.now()}`;e.setAttribute("data-id",o),e.appendChild(n),t||(t="


    "),e.innerHTML+=t,i.insertContent(e.outerHTML),i.focus();let s=i.dom.select(`[data-id="${o}"]`)[0]||null;if(s){let r=s.querySelector("doc-root > *");r&&r.focus(),s.removeAttribute("data-id")}}),i.ui.registry.addContextToolbar("details",{predicate(t){return t.nodeName.toLowerCase()==="details"},items:"editdetials toggledetails removedetails",position:"node",scope:"node"}),i.on("PreInit",()=>{Kr(i)})}function ps(){return Xr}function Gr(i){i.ui.registry.addIcon("tableclearformatting",'');let t={items:" | tablerowheader",predicate(n){let o=n.nodeName.toLowerCase()==="table",s=i.selection.getNode(),r=s.closest("table");return!o||!r?!1:r.querySelector("tr").contains(s)},position:"node",scope:"node"};i.ui.registry.addContextToolbar("customtabletoolbarfirstrow",t),i.addCommand("tableclearformatting",()=>{let n=i.dom.getParent(i.selection.getStart(),"table");if(!n)return;let o=["class","style","width","height"],s=[n,...n.querySelectorAll(o.map(r=>`[${r}]`).join(","))];for(let r of s)for(let a of o)r.removeAttribute(a)}),i.addCommand("tableclearsizes",()=>{let n=i.dom.getParent(i.selection.getStart(),"table");if(!n)return;let o=[n,...n.querySelectorAll("tr,td,th,tbody,thead,tfoot,th>*,td>*")];for(let s of o)s.removeAttribute("width"),s.removeAttribute("height"),s.style.height=null,s.style.width=null});let e=()=>{let n=i.ui.registry.getAll().buttons;i.ui.registry.addMenuButton("customtable",{...n.table,fetch:o=>o("inserttable | cell row column | advtablesort | tableprops tableclearformatting tableclearsizes deletetable")}),i.ui.registry.addMenuItem("tableclearformatting",{icon:"tableclearformatting",text:"Clear table formatting",onSetup:n.tableprops.onSetup,onAction(){i.execCommand("tableclearformatting")}}),i.ui.registry.addMenuItem("tableclearsizes",{icon:"resize",text:"Resize to contents",onSetup:n.tableprops.onSetup,onAction(){i.execCommand("tableclearsizes")}}),i.off("PreInit",e)};i.on("PreInit",e)}function ms(){return Gr}function Yr(i){let t=i.closest("li");return t&&t.parentNode.nodeName==="UL"&&t.classList.contains("task-list-item")}function Jr(i,t,e){let n=t.getBoundingClientRect();i.clientX<=n.right&&i.clientX>=n.left&&i.clientY>=n.top&&i.clientY<=n.bottom||e.undoManager.transact(()=>{t.hasAttribute("checked")?t.removeAttribute("checked"):t.setAttribute("checked","checked")})}function Zr(i){i.attr("class","task-list-item");for(let t of i.children())t.name==="input"&&(t.attr("checked")==="checked"&&i.attr("checked","checked"),t.remove())}function Qr(i){let t=i.attr("checked")==="checked";i.attr("checked",null);let e={type:"checkbox",disabled:"disabled"};t&&(e.checked="checked");let n=window.tinymce.html.Node.create("input",e);n.shortEnded=!0,i.firstChild?i.insert(n,i.firstChild,!0):i.append(n)}function ta(i){i.ui.registry.addIcon("tasklist",''),i.ui.registry.addToggleButton("tasklist",{tooltip:"Task list",icon:"tasklist",active:!1,onAction(n){n.isActive()?i.execCommand("RemoveList"):i.execCommand("InsertUnorderedList",null,{"list-item-attributes":{class:"task-list-item"},"list-style-type":"tasklist"})},onSetup(n){i.on("NodeChange",o=>{let s=o.parents.find(a=>a.nodeName==="LI"),r=s&&s.classList.contains("task-list-item");n.setActive(!!r)})}});let t=i.ui.registry.getAll().buttons.bullist;t.onSetup=function(o){i.on("NodeChange",s=>{let r=s.parents.find(d=>d.nodeName==="LI"),a=r&&r.classList.contains("task-list-item"),l=r&&r.parentNode.nodeName==="UL";o.setActive(!!(l&&!a))})},t.onAction=function(){Yr(i.selection.getNode())&&i.execCommand("InsertOrderedList",null,{"list-item-attributes":{class:null}}),i.execCommand("InsertUnorderedList",null,{"list-item-attributes":{class:null}})};let e=i.ui.registry.getAll().buttons.numlist;e.onAction=function(){i.execCommand("InsertOrderedList",null,{"list-item-attributes":{class:null}})},i.on("PreInit",()=>{i.parser.addNodeFilter("li",n=>{for(let o of n)o.attributes.map.class==="task-list-item"&&Zr(o)}),i.serializer.addNodeFilter("li",n=>{for(let o of n)o.attributes.map.class==="task-list-item"&&Qr(o)})}),i.on("click",n=>{let o=n.target;o.nodeName==="LI"&&o.classList.contains("task-list-item")&&(Jr(n,o,i),n.preventDefault())})}function fs(){return ta}function gs(i){function t(e){let n=e.querySelector("iframe, video");if(!n)return;let o=[...n.classList.values()].filter(r=>r.startsWith("align-")),s=[...e.classList.values()].filter(r=>r.startsWith("align-"));e.classList.remove(...s),e.classList.add(...o)}i.on("SetContent",()=>{let e=i.dom.select("span.mce-preview-object");for(let n of e)t(n)}),i.on("FormatApply",e=>{let n=e.format.startsWith("align");if(!(e.node instanceof i.dom.doc.defaultView.HTMLElement)||!n||!e.node.matches(".mce-preview-object"))return;let s=e.node.querySelector("iframe, video");if(s){let r=(i.formatter.get(e.format)[0]?.classes||[])[0],a=!s.classList.contains(r),d=(e.node.getAttribute("data-mce-p-class")||"").split(" ").filter(p=>!p.startsWith("align-"));a&&d.push(r);let u=d.join(" ");e.node.setAttribute("data-mce-p-class",u),s.setAttribute("class",u),i.formatter.apply(e.format,{},s),t(e.node)}})}function vs(i){let t=i.querySelectorAll('[align],[style*="text-align"],.align-center,.align-left,.align-right');for(let e of t)e.removeAttribute("align"),e.style.textAlign=null,e.classList.remove("align-center","align-right","align-left")}function zi(i){let t=i.querySelectorAll('[dir],[style*="direction"]');for(let e of t)e.removeAttribute("dir"),e.style.direction=null;vs(i),i.style.direction=null,i.style.textAlign=null,i.removeAttribute("align")}function ws(i){let t=[];i.on("TableSelectionChange",n=>{t=(n.cells||[]).map(o=>o.dom)}),i.on("TableSelectionClear",()=>{t=[]});let e={RemoveFormat:n=>{let o=["class","style","width","height","align"];for(let s of o)n.removeAttribute(s)},mceDirectionLTR:n=>{n.setAttribute("dir","ltr"),zi(n)},mceDirectionRTL:n=>{n.setAttribute("dir","rtl"),zi(n)},JustifyLeft:n=>{n.removeAttribute("align"),vs(n)}};e.JustifyRight=e.JustifyLeft,e.JustifyCenter=e.JustifyLeft,e.JustifyFull=e.JustifyLeft,i.on("ExecCommand",n=>{let o=e[n.command];if(o)for(let s of t)o(s)})}function bs(i){i.on("ExecCommand",t=>{let e=t.command;if(e!=="mceDirectionLTR"&&e!=="mceDirectionRTL")return;let n=i.selection.getSelectedBlocks();for(let o of n)zi(o)})}var ea=[{title:"Large Header",format:"h2",preview:"color: blue;"},{title:"Medium Header",format:"h3"},{title:"Small Header",format:"h4"},{title:"Tiny Header",format:"h5"},{title:"Paragraph",format:"p",exact:!0,classes:""},{title:"Blockquote",format:"blockquote"},{title:"Callouts",items:[{title:"Information",format:"calloutinfo"},{title:"Success",format:"calloutsuccess"},{title:"Warning",format:"calloutwarning"},{title:"Danger",format:"calloutdanger"}]}],na={alignleft:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img,iframe,video",classes:"align-left"},aligncenter:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img,iframe,video",classes:"align-center"},alignright:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img,iframe,video",classes:"align-right"},calloutsuccess:{block:"p",exact:!0,attributes:{class:"callout success"}},calloutinfo:{block:"p",exact:!0,attributes:{class:"callout info"}},calloutwarning:{block:"p",exact:!0,attributes:{class:"callout warning"}},calloutdanger:{block:"p",exact:!0,attributes:{class:"callout danger"}}},ia=["#BFEDD2","","#FBEEB8","","#F8CAC6","","#ECCAFA","","#C2E0F4","","#2DC26B","","#F1C40F","","#E03E2D","","#B96AD9","","#3598DB","","#169179","","#E67E23","","#BA372A","","#843FA1","","#236FA1","","#ECF0F1","","#CED4D9","","#95A5A6","","#7E8C8D","","#34495E","","#000000","","#ffffff",""];function oa(i,t,e){if(e.filetype==="file"){let n=window.$components.first("entity-selector-popup"),o=this.selection.getContent({format:"text"}).trim();n.show(s=>{i(s.link,{text:s.name,title:s.name})},{initialValue:o,searchEndpoint:"/search/entity-selector",entityTypes:"page,book,chapter,bookshelf",entityPermission:"view"})}e.filetype==="image"&&window.$components.first("image-manager").show(o=>{i(o.url,{alt:o.name})},"gallery")}function sa(i){let t=["image","table","link","autolink","fullscreen","code","customhr","autosave","lists","codeeditor","media","imagemanager","about","details","tasklist","tableadditions",i.textDirection==="rtl"?"directionality":""];return window.tinymce.PluginManager.add("codeeditor",es()),window.tinymce.PluginManager.add("customhr",ls()),window.tinymce.PluginManager.add("imagemanager",cs()),window.tinymce.PluginManager.add("about",ds()),window.tinymce.PluginManager.add("details",ps()),window.tinymce.PluginManager.add("tasklist",fs()),window.tinymce.PluginManager.add("tableadditions",ms()),i.drawioUrl&&(window.tinymce.PluginManager.add("drawio",as(i)),t.push("drawio")),t.filter(e=>!!e)}function ra(i){let t=document.head.innerHTML.split(` `),e=t.findIndex(r=>r.trim()===""),n=t.findIndex(r=>r.trim()==="");if(e===-1||n===-1)return;let o=t.slice(e+1,n).join(` `),s=i.createElement("div");s.innerHTML=o,i.head.append(...s.children)}function aa(i){return function(e){function n(){i.darkMode&&e.contentDocument.documentElement.classList.add("dark-mode"),window.$events.emit("editor-html-change","")}e.on("ExecCommand change input NodeChange ObjectResized",n),Uo(e),Ko(e,i),e.on("init",()=>{n(),jo(e),window.editor=e,Wo(e)}),e.on("PreInit",()=>{Jo(e)}),gs(e),ws(e),bs(e),window.$events.emitPublic(i.containerElement,"editor-tinymce::setup",{editor:e}),e.ui.registry.addButton("inlinecode",{tooltip:"Inline code",icon:"sourcecode",onAction(){e.execCommand("mceToggleFormat",!1,"code")}})}}function la(i){return` html, body, html.dark-mode { diff --git a/public/dist/wysiwyg.js b/public/dist/wysiwyg.js index 44e9d4cdf..fbef742a6 100644 --- a/public/dist/wysiwyg.js +++ b/public/dist/wysiwyg.js @@ -1,20 +1,20 @@ // See the "/licenses" URI for full package license details -var lN=Object.defineProperty;var ac=o=>{throw TypeError(o)};var aN=(o,t,e)=>t in o?lN(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var p=(o,t,e)=>aN(o,typeof t!="symbol"?t+"":t,e),Nl=(o,t,e)=>t.has(o)||ac("Cannot "+e);var Me=(o,t,e)=>(Nl(o,t,"read from private field"),e?e.call(o):t.get(o)),vt=(o,t,e)=>t.has(o)?ac("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(o):t.set(o,e),po=(o,t,e,n)=>(Nl(o,t,"write to private field"),n?n.call(o,e):t.set(o,e),e),hr=(o,t,e)=>(Nl(o,t,"access private method"),e);function $(o){return __DEV__?{type:o}:{}}var _e=$("SELECTION_CHANGE_COMMAND"),Nr=$("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),Wt=$("CLICK_COMMAND"),tt=$("DELETE_CHARACTER_COMMAND"),qt=$("INSERT_LINE_BREAK_COMMAND"),Yt=$("INSERT_PARAGRAPH_COMMAND"),ft=$("CONTROLLED_TEXT_INSERTION_COMMAND"),go=$("PASTE_COMMAND"),Sn=$("REMOVE_TEXT_COMMAND"),Dt=$("DELETE_WORD_COMMAND"),mt=$("DELETE_LINE_COMMAND"),Ee=$("FORMAT_TEXT_COMMAND"),ho=$("UNDO_COMMAND"),No=$("REDO_COMMAND"),xl=$("KEYDOWN_COMMAND"),Fo=$("KEY_ARROW_RIGHT_COMMAND"),El=$("MOVE_TO_END"),Ko=$("KEY_ARROW_LEFT_COMMAND"),Tl=$("MOVE_TO_START"),Zt=$("KEY_ARROW_UP_COMMAND"),Vt=$("KEY_ARROW_DOWN_COMMAND"),we=$("KEY_ENTER_COMMAND"),xr=$("KEY_SPACE_COMMAND"),Xt=$("KEY_BACKSPACE_COMMAND"),Uo=$("KEY_ESCAPE_COMMAND"),jt=$("KEY_DELETE_COMMAND"),_i=$("KEY_AT_COMMAND"),zo=$("KEY_TAB_COMMAND"),Cl=$("INSERT_TAB_COMMAND"),dN=$("INDENT_CONTENT_COMMAND"),cN=$("OUTDENT_CONTENT_COMMAND"),Wo=$("DROP_COMMAND"),Er=$("DRAGSTART_COMMAND"),Tr=$("DRAGOVER_COMMAND"),bl=$("DRAGEND_COMMAND"),xo=$("COPY_COMMAND"),Eo=$("CUT_COMMAND"),Ln=$("SELECT_ALL_COMMAND"),_l=$("CLEAR_EDITOR_COMMAND"),yl=$("CLEAR_HISTORY_COMMAND"),To=$("CAN_REDO_COMMAND"),Co=$("CAN_UNDO_COMMAND"),Cr=$("FOCUS_COMMAND"),Sl=$("BLUR_COMMAND"),Ll=$("KEY_MODIFIER_COMMAND");var pe=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";var uN=pe&&"documentMode"in document?document.documentMode:null,Ye=pe&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Ze=pe&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),bo=pe&&"InputEvent"in window&&!uN?"getTargetRanges"in new window.InputEvent("input"):!1,Gt=pe&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Ot=pe&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,dc=pe&&/Android/.test(navigator.userAgent),Ml=pe&&/^(?=.*Chrome).*/i.test(navigator.userAgent),wl=pe&&dc&&Ml,Jt=pe&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Ml;var _o=1,Ve=3,At=0,vl=1,Qt=2,cc=0,yi=1,Si=2,br=1,_r=2,Mn=4,wn=8,yr=16,Sr=32,Lr=64,Mr=128,Dl=br|_r|Mn|wn|yr|Sr|Lr|Mr,Li=1,vn=2;var uc="\xA0",fN="\u200B",Dn=Gt||Ot||Jt?uc:fN,ot=` +var lN=Object.defineProperty;var dc=o=>{throw TypeError(o)};var aN=(o,t,e)=>t in o?lN(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var p=(o,t,e)=>aN(o,typeof t!="symbol"?t+"":t,e),xl=(o,t,e)=>t.has(o)||dc("Cannot "+e);var Me=(o,t,e)=>(xl(o,t,"read from private field"),e?e.call(o):t.get(o)),vt=(o,t,e)=>t.has(o)?dc("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(o):t.set(o,e),po=(o,t,e,n)=>(xl(o,t,"write to private field"),n?n.call(o,e):t.set(o,e),e),hr=(o,t,e)=>(xl(o,t,"access private method"),e);function $(o){return __DEV__?{type:o}:{}}var _e=$("SELECTION_CHANGE_COMMAND"),Nr=$("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),Wt=$("CLICK_COMMAND"),tt=$("DELETE_CHARACTER_COMMAND"),qt=$("INSERT_LINE_BREAK_COMMAND"),Yt=$("INSERT_PARAGRAPH_COMMAND"),ft=$("CONTROLLED_TEXT_INSERTION_COMMAND"),go=$("PASTE_COMMAND"),Sn=$("REMOVE_TEXT_COMMAND"),Dt=$("DELETE_WORD_COMMAND"),mt=$("DELETE_LINE_COMMAND"),Ee=$("FORMAT_TEXT_COMMAND"),ho=$("UNDO_COMMAND"),No=$("REDO_COMMAND"),El=$("KEYDOWN_COMMAND"),Fo=$("KEY_ARROW_RIGHT_COMMAND"),Tl=$("MOVE_TO_END"),Ko=$("KEY_ARROW_LEFT_COMMAND"),Cl=$("MOVE_TO_START"),Zt=$("KEY_ARROW_UP_COMMAND"),Vt=$("KEY_ARROW_DOWN_COMMAND"),we=$("KEY_ENTER_COMMAND"),xr=$("KEY_SPACE_COMMAND"),Xt=$("KEY_BACKSPACE_COMMAND"),Uo=$("KEY_ESCAPE_COMMAND"),jt=$("KEY_DELETE_COMMAND"),_i=$("KEY_AT_COMMAND"),zo=$("KEY_TAB_COMMAND"),bl=$("INSERT_TAB_COMMAND"),dN=$("INDENT_CONTENT_COMMAND"),cN=$("OUTDENT_CONTENT_COMMAND"),Wo=$("DROP_COMMAND"),Er=$("DRAGSTART_COMMAND"),Tr=$("DRAGOVER_COMMAND"),_l=$("DRAGEND_COMMAND"),xo=$("COPY_COMMAND"),Eo=$("CUT_COMMAND"),Ln=$("SELECT_ALL_COMMAND"),yl=$("CLEAR_EDITOR_COMMAND"),Sl=$("CLEAR_HISTORY_COMMAND"),To=$("CAN_REDO_COMMAND"),Co=$("CAN_UNDO_COMMAND"),Cr=$("FOCUS_COMMAND"),Ll=$("BLUR_COMMAND"),Ml=$("KEY_MODIFIER_COMMAND");var pe=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";var uN=pe&&"documentMode"in document?document.documentMode:null,Ye=pe&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Ze=pe&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),bo=pe&&"InputEvent"in window&&!uN?"getTargetRanges"in new window.InputEvent("input"):!1,Gt=pe&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Ot=pe&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,cc=pe&&/Android/.test(navigator.userAgent),wl=pe&&/^(?=.*Chrome).*/i.test(navigator.userAgent),vl=pe&&cc&&wl,Jt=pe&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!wl;var _o=1,Ve=3,At=0,Dl=1,Qt=2,uc=0,yi=1,Si=2,br=1,_r=2,Mn=4,wn=8,yr=16,Sr=32,Lr=64,Mr=128,Ol=br|_r|Mn|wn|yr|Sr|Lr|Mr,Li=1,vn=2;var fc="\xA0",fN="\u200B",Dn=Gt||Ot||Jt?fc:fN,ot=` -`,fc=Ze?uc:Dn,mc="\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC",pc="A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u0300-\u0590\u0800-\u1FFF\u200E\u2C00-\uFB1C\uFE00-\uFE6F\uFEFD-\uFFFF",mN=new RegExp("^[^"+pc+"]*["+mc+"]"),pN=new RegExp("^[^"+mc+"]*["+pc+"]"),$e={bold:br,code:yr,highlight:Mr,italic:_r,strikethrough:Mn,subscript:Sr,superscript:Lr,underline:wn},gc={directionless:Li,unmergeable:vn},hc={normal:cc,segmented:Si,token:yi},Nc={[cc]:"normal",[Si]:"segmented",[yi]:"token"};function T(o,t,...e){if(!o){for(let n of e)t=(t||"").replace("%s",n);throw new Error(t)}}function Rt(...o){let t=[];for(let e of o)if(e&&typeof e=="string")for(let[n]of e.matchAll(/\S+/g))t.push(n);return t}var gN=100,Al=!1,Rl=0;function xc(){return Al}function hN(o){Rl=o.timeStamp}function NN(o){Rl===0&&On(o).addEventListener("textInput",hN,!0)}function Ol(o,t,e){return t.__lexicalLineBreak===o||o[`__lexicalKey_${e._key}`]!==void 0}function xN(o){return o.getEditorState().read(()=>{let t=C();return t!==null?t.clone():null})}function EN(o,t,e){let n=ve(e._window),r=null,i=null;n!==null&&n.anchorNode===o&&(r=n.anchorOffset,i=n.focusOffset);let s=o.nodeValue;s!==null&&wr(t,s,r,i,!1)}function TN(o,t,e){return t.nodeType===Ve&&e.isAttached()}function Ec(o,t,e){Al=!0;let n=performance.now()-Rl>gN;try{Te(o,()=>{let r=C()||xN(o),i=new Map,s=o.getRootElement(),l=o._editorState,a=o._blockCursorElement,d=!1,u="";for(let c=0;c0){let v=0;for(let M=0;M0)for(let[c,f]of i)if(E(f)){let g=f.getChildrenKeys(),h=c.firstChild;for(let N=0;N0){for(let c=0;c{Ec(o,t,e)})}function Tc(o,t){let e=o.__mode,n=o.__format,r=o.__style,i=t.__mode,s=t.__format,l=t.__style;return(e===null||e===i)&&(n===null||n===s)&&(r===null||r===l)}function Cc(o,t){let e=o.mergeWithSibling(t),n=Q()._normalizedNodes;return n.add(o.__key),n.add(t.__key),e}function $l(o){let t=o;if(t.__text===""&&t.isSimpleText()&&!t.isUnmergeable()){t.remove();return}let e;for(;(e=t.getPreviousSibling())!==null&&L(e)&&e.isSimpleText()&&!e.isUnmergeable();)if(e.__text==="")e.remove();else if(Tc(e,t)){t=Cc(e,t);break}else break;let n;for(;(n=t.getNextSibling())!==null&&L(n)&&n.isSimpleText()&&!n.isUnmergeable();)if(n.__text==="")n.remove();else if(Tc(t,n)){t=Cc(t,n);break}else break}function qo(o){return bc(o.anchor),bc(o.focus),o}function bc(o){for(;o.type==="element";){let t=o.getNode(),e=o.offset,n,r;if(e===t.getChildrenSize()?(n=t.getChildAtIndex(e-1),r=!0):(n=t.getChildAtIndex(e),r=!1),L(n)){o.set(n.__key,r?n.getTextContentSize():0,"text");break}else if(!E(n))break;o.set(n.__key,r?n.getChildrenSize():0,"element")}}var CN=1;function bN(){return""+CN++}function Sc(o,t){let e=o._nodes.get(t);return e===void 0&&T(!1,"registeredNode: Type %s not found",t),e}var Lc=typeof queueMicrotask=="function"?queueMicrotask:o=>{Promise.resolve().then(o)};function Mc(o){return H(G(o))}function In(o){let t=document.activeElement;if(t===null)return!1;let e=t.nodeName;return H(G(o))&&(e==="INPUT"||e==="TEXTAREA"||t.contentEditable==="true"&&Yo(t)==null)}function eo(o,t,e){let n=o.getRootElement();try{return n!==null&&n.contains(t)&&n.contains(e)&&t!==null&&!In(t)&&Di(t)===o}catch{return!1}}function $n(o){return o instanceof ro}function Di(o){let t=o;for(;t!=null;){let e=Yo(t);if($n(e))return e;t=Ii(t)}return null}function Yo(o){return o?o.__lexicalEditor:null}function Xe(o){return o.isToken()||o.isSegmented()}function _N(o){return o.nodeType===Ve}function Pn(o){let t=o;for(;t!=null;){if(_N(t))return t;t=t.firstChild}return null}function Dr(o,t,e){let n=$e[t];if(e!==null&&(o&n)===(e&n))return o;let r=o^n;return t==="subscript"?r&=~$e.superscript:t==="superscript"&&(r&=~$e.subscript),r}function Or(o){return L(o)||Pe(o)||H(o)}function wc(o,t){if(t!=null){__DEV__&&yN(o,t),o.__key=t;return}ue(),Yl();let e=Q(),n=rt(),r=bN();n._nodeMap.set(r,o),E(o)?e._dirtyElements.set(r,!0):e._dirtyLeaves.add(r),e._cloneNotNeeded.add(r),e._dirtyType=vl,o.__key=r}function yN(o,t){let e=pu();if(!e)return;let n=e._nodeMap.get(t);n&&n.constructor!==o.constructor&&(o.constructor.name!==n.constructor.name?T(!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):T(!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 SN(o,t,e){let n=o;for(;n!==null;){if(e.has(n))return;let r=t.get(n);if(r===void 0)break;e.set(n,!1),n=r.__parent}}function to(o){let t=o.getParent();if(t!==null){let e=o.getWritable(),n=t.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;e.__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;e.__next=null}n.__size--,e.__parent=null}}function vr(o){Yl();let t=o.getLatest(),e=t.__parent,n=rt(),r=Q(),i=n._nodeMap,s=r._dirtyElements;e!==null&&SN(e,i,s);let l=t.__key;r._dirtyType=vl,E(o)?s.set(l,!0):r._dirtyLeaves.add(l)}function vc(o){let t=o.getPreviousSibling(),e=o.getNextSibling();t!==null&&vr(t),e!==null&&vr(e)}function le(o){ue();let t=Q(),e=t._compositionKey;if(o!==e){if(t._compositionKey=o,e!==null){let n=ee(e);n!==null&&n.getWritable()}if(o!==null){let n=ee(o);n!==null&&n.getWritable()}}}function nt(){return pt()?null:Q()._compositionKey}function ee(o,t){let n=(t||rt())._nodeMap.get(o);return n===void 0?null:n}function kl(o,t){let e=Q(),n=o[`__lexicalKey_${e._key}`];return n!==void 0?ee(n,t):null}function G(o,t){let e=o;for(;e!=null;){let n=kl(e,t);if(n!==null)return n;e=Ii(e)}return null}function Oi(o){let t=o._decorators,e=Object.assign({},t);return o._pendingDecorators=e,e}function Bl(o){return o.read(()=>F().getTextContent())}function Dc(o,t){Te(o,()=>{let e=rt();if(e.isEmpty())return;if(t==="root"){F().markDirty();return}let n=e._nodeMap;for(let[,r]of n)r.markDirty()},o._pendingEditorState===null?{tag:"history-merge"}:void 0)}function F(){return Il(rt())}function Il(o){return o._nodeMap.get("root")}function Y(o){ue();let t=rt();o!==null&&(__DEV__&&Object.isFrozen(o)&&T(!1,"$setSelection called on frozen selection object. Ensure selection is cloned before passing in."),o.dirty=!0,o.setCachedNodes(null)),t._selection=o}function Oc(){ue();let o=Q();Mi(o)}function Zo(o){let t=Q(),e=LN(o,t);if(e===null){let n=t.getRootElement();return o===n?ee("root"):null}return ee(e)}function Hl(o,t){return t?o.getTextContentSize():0}function LN(o,t){let e=o;for(;e!=null;){let n=e[`__lexicalKey_${t._key}`];if(n!==void 0)return n;e=Ii(e)}return null}function Ai(o){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(o)}function Ar(o){let t=[],e=o;for(;e!==null;)t.push(e),e=e._parentEditor;return t}function Fl(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function Kl(o){return o.nodeType===Ve?o.nodeValue:null}function Ri(o,t,e){let n=ve(t._window);if(n===null)return;let r=n.anchorNode,{anchorOffset:i,focusOffset:s}=n;if(r!==null){let l=Kl(r),a=G(r);if(l!==null&&L(a)){if(l===Dn&&e){let d=e.length;l=e,i=d,s=d}l!==null&&wr(a,l,i,s,o)}}}function wr(o,t,e,n,r){let i=o;if(i.isAttached()&&(r||!i.isDirty())){let s=i.isComposing(),l=t;(s||r)&&t[t.length-1]===Dn&&(l=t.slice(0,-1));let a=i.getTextContent();if(r||l!==a){if(l===""){if(le(null),!Gt&&!Ot&&!Jt){let h=Q();setTimeout(()=>{h.update(()=>{i.isAttached()&&i.remove()})},20)}else i.remove();return}let d=i.getParent(),u=je(),m=i.getTextContentSize(),c=nt(),f=i.getKey();if(i.isToken()||c!==null&&f===c&&!s||_(u)&&(d!==null&&!d.canInsertTextBefore()&&u.anchor.offset===0||u.anchor.key===o.__key&&u.anchor.offset===0&&!i.canInsertTextBefore()&&!s||u.focus.key===o.__key&&u.focus.offset===m&&!i.canInsertTextAfter()&&!s)){i.markDirty();return}let g=C();if(!_(g)||e===null||n===null){i.setTextContent(l);return}if(g.setTextNodeRange(i,e,i,n),i.isSegmented()){let h=i.getTextContent(),N=z(h);i.replace(N),i=N}i.setTextContent(l)}}}function MN(o){let t=o.getPreviousSibling();return(L(t)||E(t)&&t.isInline())&&!t.canInsertTextAfter()}function Ac(o,t){if(t.isSegmented())return!0;if(!o.isCollapsed())return!1;let e=o.anchor.offset,n=t.getParentOrThrow(),r=t.isToken();return e===0?!t.canInsertTextBefore()||!n.canInsertTextBefore()&&!t.isComposing()||r||MN(t):e===t.getTextContentSize()?!t.canInsertTextAfter()||!n.canInsertTextAfter()&&!t.isComposing()||r:!1}function Rc(o,t,e,n){return o==="Tab"&&!t&&!e&&!n}function kc(o,t,e,n){return o.toLowerCase()==="b"&&!t&&Rr(e,n)}function Ic(o,t,e,n){return o.toLowerCase()==="i"&&!t&&Rr(e,n)}function $c(o,t,e,n){return o.toLowerCase()==="u"&&!t&&Rr(e,n)}function Pc(o,t){return su(o)&&!t}function Bc(o,t){return su(o)&&t}function Hc(o,t){return Ye&&t&&o.toLowerCase()==="o"}function Fc(o,t,e){return An(o)&&(Ye?t:e)}function Kc(o,t,e){return Rn(o)&&(Ye?t:e)}function Uc(o,t){return Ye&&t&&An(o)}function zc(o,t){return Ye&&t&&Rn(o)}function Wc(o,t,e,n){return Ye?t||e?!1:An(o)||o.toLowerCase()==="h"&&n:n||t||e?!1:An(o)}function qc(o,t,e,n,r){return Ye?e||n||r?!1:Rn(o)||o.toLowerCase()==="d"&&t:t||n||r?!1:Rn(o)}function Yc(o,t,e,n){return o.toLowerCase()==="z"&&!t&&Rr(e,n)}function Zc(o,t,e,n){return Ye?o.toLowerCase()==="z"&&e&&t:o.toLowerCase()==="y"&&n||o.toLowerCase()==="z"&&n&&t}function Vc(o,t,e,n){return t?!1:o.toLowerCase()==="c"?Ye?e:n:!1}function Xc(o,t,e,n){return t?!1:o.toLowerCase()==="x"?Ye?e:n:!1}function jc(o){return o==="ArrowLeft"}function Gc(o){return o==="ArrowRight"}function wN(o){return o==="ArrowUp"}function vN(o){return o==="ArrowDown"}function Jc(o,t,e,n){return jc(o)&&!t&&!n&&!e}function Qc(o,t,e,n,r){return jc(o)&&!n&&!e&&(t||r)}function eu(o,t,e,n){return Gc(o)&&!t&&!n&&!e}function tu(o,t,e,n,r){return Gc(o)&&!n&&!e&&(t||r)}function ou(o,t,e){return wN(o)&&!t&&!e}function nu(o,t,e){return vN(o)&&!t&&!e}function ru(o,t,e,n){return o||t||e||n}function iu(o){return o===" "}function Rr(o,t){return Ye?o:t}function su(o){return o==="Enter"}function An(o){return o==="Backspace"}function lu(o){return o==="Escape"}function Rn(o){return o==="Delete"}function au(o){return o==="@"}function Ul(o,t,e){return o.toLowerCase()==="a"&&Rr(t,e)}function zl(){let o=F(),t=o.select(0,o.getChildrenSize());Y(qo(t))}function yo(o,t){o.__lexicalClassNameCache===void 0&&(o.__lexicalClassNameCache={});let e=o.__lexicalClassNameCache,n=e[t];if(n!==void 0)return n;let r=o[t];if(typeof r=="string"){let i=Rt(r);return e[t]=i,i}return r}function ki(o,t,e,n,r){if(e.size===0)return;let i=n.__type,s=n.__key,l=t.get(i);l===void 0&&T(!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 u=d.get(s),m=u==="destroyed"&&r==="created";(u===void 0||m)&&d.set(s,m?"updated":r)}function _c(o,t,e){let n=o.getParent(),r=e,i=o;return n!==null&&(t&&e===0?(r=i.getIndexWithinParent(),i=n):!t&&e===i.getChildrenSize()&&(r=i.getIndexWithinParent()+1,i=n)),i.getChildAtIndex(t?r-1:r)}function oo(o,t){let e=o.offset;if(o.type==="element"){let n=o.getNode();return _c(n,t,e)}else{let n=o.getNode();if(t&&e===0||!t&&e===n.getTextContentSize()){let r=t?n.getPreviousSibling():n.getNextSibling();return r===null?_c(n.getParentOrThrow(),t,n.getIndexWithinParent()+(t?0:1)):r}}return null}function vi(o){let t=On(o).event,e=t&&t.inputType;return e==="insertFromPaste"||e==="insertFromPasteAsQuotation"}function O(o,t,e){return Zl(o,t,e)}function kr(o){return!ne(o)&&!o.isLastChild()&&!o.isInline()}function Bn(o,t){let e=o._keyToDOMMap.get(t);return e===void 0&&T(!1,"Reconciliation: could not find DOM element for node key %s",t),e}function Ii(o){let t=o.assignedSlot||o.parentElement;return t!==null&&t.nodeType===11?t.host:t}function du(o,t,e){let n=e.ownerDocument,r=n.defaultView;if(r===null)return;let{top:i,bottom:s}=t,l=0,a=0,d=e;for(;d!==null;){let u=d===n.body;if(u)l=0,a=On(o).innerHeight;else{let c=d.getBoundingClientRect();l=c.top,a=c.bottom}let m=0;if(ia&&(m=s-a),m!==0)if(u)r.scrollBy(0,m);else{let c=d.scrollTop;d.scrollTop+=m;let f=d.scrollTop-c;i-=f,s-=f}if(u)break;d=Ii(d)}}function cu(o){let t=C();if(!_(t)||!E(o))return t;let{anchor:e,focus:n}=t,r=e.getNode(),i=n.getNode();return kn(r,o)&&e.set(o.__key,0,"element"),kn(i,o)&&n.set(o.__key,0,"element"),t}function kn(o,t){let e=o.getParent();for(;e!==null;){if(e.is(t))return!0;e=e.getParent()}return!1}function uu(o){let t=o.ownerDocument;return t&&t.defaultView||null}function On(o){let t=o._window;return t===null&&T(!1,"window object not found"),t}function Wl(o){let t=o.getParentOrThrow();for(;t!==null;){if(ge(t))return t;t=t.getParentOrThrow()}return t}var XC=Symbol.for("@lexical/ShadowRootNodeBrand");function ge(o){return ne(o)||E(o)&&o.isShadowRoot()}function re(o){let t=Q(),e=o.constructor.getType(),n=t._nodes.get(e);n===void 0&&T(!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||T(!1,"$initializeNode failed. Ensure replacement node is a subclass of the original node."),i}return o}function $i(o,t){let e=o.getParent();ne(e)&&!E(t)&&!H(t)&&T(!1,"Only element or decorator nodes can be inserted in to the root node")}function DN(o){let t=o.theme,e=document.createElement("div");e.contentEditable="false",e.setAttribute("data-lexical-cursor","true");let n=t.blockCursor;if(n!==void 0){if(typeof n=="string"){let r=Rt(n);n=t.blockCursor=r}n!==void 0&&e.classList.add(...n)}return e}function Pl(o){return(H(o)||E(o)&&!o.canBeEmpty())&&!o.isInline()}function Ir(o,t,e){e.style.removeProperty("caret-color"),t._blockCursorElement=null;let n=o.parentElement;n!==null&&n.removeChild(o)}function fu(o,t,e){let n=o._blockCursorElement;if(_(e)&&e.isCollapsed()&&e.anchor.type==="element"&&t.contains(document.activeElement)){let r=e.anchor,i=r.getNode(),s=r.offset,l=i.getChildrenSize(),a=!1,d=null;if(s===l){let u=i.getChildAtIndex(s-1);Pl(u)&&(a=!0)}else{let u=i.getChildAtIndex(s);if(Pl(u)){let m=u.getPreviousSibling();(m===null||Pl(m))&&(a=!0,d=o.getElementByKey(u.__key))}}if(a){let u=o.getElementByKey(i.__key);n===null&&(o._blockCursorElement=n=DN(o._config)),t.style.caretColor="transparent",d===null?u.appendChild(n):u.insertBefore(n,d);return}}n!==null&&Ir(n,o,t)}function ve(o){return pe?(o||window).getSelection():null}function Pi(o){return he(o)&&o.tagName==="A"}function he(o){return o.nodeType===1}function Vo(o){let t=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(t)!==null}function So(o){let t=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(t)!==null}function Xo(o){if(ne(o)||H(o)&&!o.isInline())return!0;if(!E(o)||ge(o))return!1;let t=o.getFirstChild(),e=t===null||Pe(t)||L(t)||t.isInline();return!o.isInline()&&o.canBeEmpty()!==!1&&e}function Bi(o,t){let e=o;for(;e!==null&&e.getParent()!==null&&!t(e);)e=e.getParentOrThrow();return t(e)?e:null}function ql(){return Q()}var yc=new WeakMap,ON=new Map;function mu(o){if(!o._readOnly&&o.isEmpty())return ON;T(o._readOnly,"getCachedTypeToNodeMap called with a writable EditorState");let t=yc.get(o);if(!t){t=new Map,yc.set(o,t);for(let[e,n]of o._nodeMap){let r=n.__type,i=t.get(r);i||(i=new Map,t.set(r,i)),i.set(e,n)}}return t}function no(o){let t=o.constructor,e=t.clone(o);return e.afterCloneFrom(o),__DEV__&&(T(e.__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",t.name,t.getType()),T(e.__parent===o.__parent&&e.__next===o.__next&&e.__prev===o.__prev,"$cloneWithProperties: %s.clone(node) (with type '%s') overrided afterCloneFrom but did not call super.afterCloneFrom(prevNode)",t.name,t.getType())),e}function gu(o,t){let e=o._decorators,r=o._pendingDecorators||e,i=t._nodeMap,s;for(s in r)i.has(s)||(r===e&&(r=Oi(o)),delete r[s])}function hu(o,t,e,n,r,i){let s=o.getFirstChild();for(;s!==null;){let l=s.__key;s.__parent===t&&(E(s)&&hu(s,l,e,n,r,i),e.has(l)||i.delete(l),r.push(l)),s=s.getNextSibling()}}function Nu(o,t,e,n){let r=o._nodeMap,i=t._nodeMap,s=[];for(let[l]of n){let a=i.get(l);a!==void 0&&(a.isAttached()||(E(a)&&hu(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 e){let a=i.get(l);a!==void 0&&!a.isAttached()&&(r.has(l)||e.delete(l),i.delete(l))}}var fe="",Lo=null,gt="",io="",Hn,De,Pr,Eu=!1,Fi=!1,Ki,Xl,jl,jo,ht,Gl,Br;function Ui(o,t){let e=jo.get(o);if(t!==null){let n=ea(o);n.parentNode===t&&t.removeChild(n)}if(ht.has(o)||De._keyToDOMMap.delete(o),E(e)){let n=Hi(e,jo);Jl(n,0,n.length-1,null)}e!==void 0&&ki(Br,Pr,Ki,e,"destroyed")}function Jl(o,t,e,n){let r=t;for(;r<=e;++r){let i=o[r];i!==void 0&&Ui(i,n)}}function zi(o,t,e){let n=ht.get(o);n===void 0&&T(!1,"createNode: node does not exist in nodeMap");let r=n.createDOM(Hn,De);if(BN(o,r,De),L(n)?r.setAttribute("data-lexical-text","true"):H(n)&&r.setAttribute("data-lexical-decorator","true"),E(n)){let i=n.__size;if(i!==0){let s=i-1,l=Hi(n,ht);Ql(l,n,0,s,r,null)}n.isInline()||Tu(null,n,r),kr(n)&&(fe+=ot,io+=ot)}else{let i=n.getTextContent();if(H(n)){let s=n.decorate(De,Hn);s!==null&&Cu(o,s),r.contentEditable="false"}fe+=i,io+=i}if(t!==null&&!n?.insertDOMIntoParent(r,t))if(e!=null)t.insertBefore(r,e);else{let s=t.__lexicalLineBreak;s!=null?t.insertBefore(r,s):t.appendChild(r)}return __DEV__&&Object.freeze(n),ki(Br,Pr,Ki,n,"created"),r}function Ql(o,t,e,n,r,i){let s=fe;fe="";let l=e;for(;l<=n;++l){zi(o[l],r,i);let a=ht.get(o[l]);a!==null&&L(a)&&(Lo===null&&(Lo=a.getFormat()),gt===""&&(gt=a.getStyle()))}kr(t)&&(fe+=ot),r.__lexicalTextContent=fe,fe=s+fe}function xu(o,t){let e=t.get(o);return Pe(e)||H(e)&&e.isInline()}function Tu(o,t,e){let n=o!==null&&(o.__size===0||xu(o.__last,jo)),r=t.__size===0||xu(t.__last,ht);if(n){if(!r){let i=e.__lexicalLineBreak;if(i!=null)try{e.removeChild(i)}catch(s){if(typeof s=="object"&&s!=null){let l=`${s.toString()} Parent: ${e.tagName}, child: ${i.tagName}.`;throw new Error(l)}else throw s}e.__lexicalLineBreak=null}}else if(r){let i=document.createElement("br");e.__lexicalLineBreak=i,e.appendChild(i)}}function AN(o){Ge(o)&&Lo!=null&&!Fi&&o.setTextStyle(gt)}function RN(o){Ge(o)&>!==""&>!==o.__textStyle&&!Fi&&o.setTextStyle(gt)}function kN(o,t,e){Lo=null,gt="",IN(o,t,e),AN(t),RN(t)}function Hi(o,t){let e=[],n=o.__first;for(;n!==null;){let r=t.get(n);r===void 0&&T(!1,"createChildrenArray: node does not exist in nodeMap"),e.push(n),n=r.__next}return e}function IN(o,t,e){let n=fe,r=o.__size,i=t.__size;if(fe="",r===1&&i===1){let s=o.__first,l=t.__first;if(s===l)$r(s,e);else{let d=ea(s),u=zi(l,null,null);try{e.replaceChild(u,d)}catch(m){if(typeof m=="object"&&m!=null){let c=`${m.toString()} Parent: ${e.tagName}, new child: {tag: ${u.tagName} key: ${l}}, old child: {tag: ${d.tagName}, key: ${s}}.`;throw new Error(c)}else throw m}Ui(s,null)}let a=ht.get(l);L(a)&&(Lo===null&&(Lo=a.getFormat()),gt===""&&(gt=a.getStyle()))}else{let s=Hi(o,jo),l=Hi(t,ht);if(r===0)i!==0&&Ql(l,t,0,i-1,e,null);else if(i===0){if(r!==0){let d=e.__lexicalLineBreak==null;Jl(s,0,r-1,d?null:e),d&&(e.textContent="")}}else PN(t,s,l,r,i,e)}kr(t)&&(fe+=ot),e.__lexicalTextContent=fe,fe=n+fe}function $r(o,t){let e=jo.get(o),n=ht.get(o);(e===void 0||n===void 0)&&T(!1,"reconcileNode: prevNode or nextNode does not exist in nodeMap");let r=Eu||jl.has(o)||Xl.has(o),i=Bn(De,o);if(e===n&&!r){if(E(e)){let s=i.__lexicalTextContent;s!==void 0&&(fe+=s,io+=s)}else{let s=e.getTextContent();io+=s,fe+=s}return i}if(e!==n&&r&&ki(Br,Pr,Ki,n,"updated"),n.updateDOM(e,i,Hn)){let s=zi(o,null,null);return t===null&&T(!1,"reconcileNode: parentDOM is null"),t.replaceChild(s,i),Ui(o,null),s}if(E(e)&&E(n))r&&(kN(e,n,i),!ne(n)&&!n.isInline()&&Tu(e,n,i)),kr(n)&&(fe+=ot,io+=ot);else{let s=n.getTextContent();if(H(n)){let l=n.decorate(De,Hn);l!==null&&Cu(o,l)}fe+=s,io+=s}if(!Fi&&ne(n)&&n.__cachedText!==io){let s=n.getWritable();s.__cachedText=io,n=s}return __DEV__&&Object.freeze(n),i}function Cu(o,t){let e=De._pendingDecorators,n=De._decorators;if(e===null){if(n[o]===t)return;e=Oi(De)}e[o]=t}function $N(o){return o.firstChild}function Vl(o){let t=o.nextSibling;return t!==null&&t===De._blockCursorElement&&(t=t.nextSibling),t}function PN(o,t,e,n,r,i){let s=n-1,l=r-1,a,d,u=$N(i),m=0,c=0;for(;m<=s&&c<=l;){let h=t[m],N=e[c];if(h===N)u=Vl($r(N,i)),m++,c++;else{a===void 0&&(a=new Set(t)),d===void 0&&(d=new Set(e));let x=d.has(h),S=a.has(N);if(!x)u=Vl(ea(h)),Ui(h,i),m++;else if(!S)zi(N,i,u),c++;else{let v=Bn(De,N);v===u?u=Vl($r(N,i)):(u!=null?i.insertBefore(v,u):i.appendChild(v),$r(N,i)),m++,c++}}let b=ht.get(N);b!==null&&L(b)&&(Lo===null&&(Lo=b.getFormat()),gt===""&&(gt=b.getStyle()))}let f=m>s,g=c>l;if(f&&!g){let h=e[l+1],N=h===void 0?null:De.getElementByKey(h);Ql(e,o,c,l,i,N)}else g&&!f&&Jl(t,m,s,i)}function bu(o,t,e,n,r,i){fe="",io="",Eu=n===Qt,De=e,Hn=e._config,Pr=e._nodes,Ki=De._listeners.mutation,Xl=r,jl=i,jo=o._nodeMap,ht=t._nodeMap,Fi=t._readOnly,Gl=new Map(e._keyToDOMMap);let s=new Map;return Br=s,$r("root",null),De=void 0,Pr=void 0,Xl=void 0,jl=void 0,jo=void 0,ht=void 0,Hn=void 0,Gl=void 0,Br=void 0,s}function BN(o,t,e){let n=e._keyToDOMMap;t["__lexicalKey_"+e._key]=o,n.set(o,t)}function ea(o){let t=Gl.get(o);return t===void 0&&T(!1,"Reconciliation: could not find DOM element for node key %s",o),t}var so=Object.freeze({}),ia=30,ta=[["keydown",ZN],["pointerdown",FN],["compositionstart",qN],["compositionend",YN],["input",WN],["click",HN],["cut",so],["copy",so],["dragstart",so],["dragover",so],["dragend",so],["paste",so],["focus",so],["blur",so],["drop",so]];bo&&ta.push(["beforeinput",(o,t)=>zN(o,t)]);var Kr=0,Mu=null,wu=0,Fn=null,Wi=new WeakMap,oa=!1,na=!1,Fr=!1,Hr=!1,vu=[0,"",0,"root",0];function Du(o,t,e,n,r){let i=o.anchor,s=o.focus,l=i.getNode(),a=Q(),d=ve(a._window),u=d!==null?d.anchorNode:null,m=i.key,c=a.getElementByKey(m),f=e.length;return m!==s.key||!L(l)||(!r&&(!bo||wu1||(r||!bo)&&c!==null&&!l.isComposing()&&u!==Pn(c)||d!==null&&t!==null&&(!t.collapsed||t.startContainer!==d.anchorNode||t.startOffset!==d.anchorOffset)||l.getFormat()!==o.format||l.getStyle()!==o.style||Ac(o,l)}function _u(o,t){return o!==null&&o.nodeValue!==null&&o.nodeType===Ve&&t!==0&&t!==o.nodeValue.length}function yu(o,t,e){let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}=o;oa&&(oa=!1,_u(n,r)&&_u(i,s))||Te(t,()=>{if(!e){Y(null);return}if(!eo(t,n,i))return;let l=C();if(_(l)){let a=l.anchor,d=a.getNode();if(l.isCollapsed()){o.type==="Range"&&o.anchorNode===o.focusNode&&(l.dirty=!0);let u=On(t).event,m=u?u.timeStamp:performance.now(),[c,f,g,h,N]=vu,b=F(),x=t.isComposing()===!1&&b.getTextContent()==="";if(m{let e=C(),n=ve(t._window),r=je();if(n){if(_(e)){let i=e.anchor,s=i.getNode();if(i.type==="element"&&i.offset===0&&e.isCollapsed()&&!ne(s)&&F().getChildrenSize()===1&&s.getTopLevelElementOrThrow().isEmpty()&&r!==null&&e.is(r))n.removeAllRanges(),e.dirty=!0;else if(o.detail===3&&!e.isCollapsed()){let a=e.focus.getNode();s!==a&&(E(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===_o||s===Ve){let l=Ur(r,n,t,o);Y(l)}}}}O(t,Wt,o)})}function FN(o,t){let e=o.target,n=o.pointerType;e instanceof Node&&n!=="touch"&&Te(t,()=>{Mc(e)||(na=!0)})}function Ou(o){if(!o.getTargetRanges)return null;let t=o.getTargetRanges();return t.length===0?null:t[0]}function KN(o,t){return o!==t||E(o)||E(t)||!o.isToken()||!t.isToken()}function UN(o){return Mu==="MediaLast"&&o{let r=C();if(e==="deleteContentBackward"){if(r===null){let u=je();if(!_(u))return;Y(u.clone())}if(_(r)){let u=r.anchor.key===r.focus.key;if(UN(o.timeStamp)&&t.isComposing()&&u){if(le(null),Kr=0,setTimeout(()=>{Te(t,()=>{le(null)})},ia),_(r)){let m=r.anchor.getNode();m.markDirty(),T(L(m),"Anchor node must be a TextNode"),r.style=m.getStyle()}}else{le(null),o.preventDefault();let m=r.anchor.getNode().getTextContent(),c=r.anchor.offset===0&&r.focus.offset===m.length;wl&&u&&!c||O(t,tt,!0)}return}}if(!_(r))return;let i=o.data;Fn!==null&&Ri(!1,t,Fn),(!r.dirty||Fn!==null)&&r.isCollapsed()&&!ne(r.anchor.getNode())&&n!==null&&r.applyDOMRange(n),Fn=null;let s=r.anchor,l=r.focus,a=s.getNode(),d=l.getNode();if(e==="insertText"||e==="insertTranspose"){if(i===` -`)o.preventDefault(),O(t,qt,!1);else if(i===ot)o.preventDefault(),O(t,Yt,void 0);else if(i==null&&o.dataTransfer){let u=o.dataTransfer.getData("text/plain");o.preventDefault(),r.insertRawText(u)}else i!=null&&Du(r,n,i,o.timeStamp,!0)?(o.preventDefault(),O(t,ft,i)):Fn=i;wu=o.timeStamp;return}switch(o.preventDefault(),e){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":{O(t,ft,o);break}case"insertFromComposition":{le(null),O(t,ft,o);break}case"insertLineBreak":{le(null),O(t,qt,!1);break}case"insertParagraph":{le(null),Fr&&!Ot?(Fr=!1,O(t,qt,!1)):O(t,Yt,void 0);break}case"insertFromPaste":case"insertFromPasteAsQuotation":{O(t,go,o);break}case"deleteByComposition":{KN(a,d)&&O(t,Sn,o);break}case"deleteByDrag":case"deleteByCut":{O(t,Sn,o);break}case"deleteContent":{O(t,tt,!1);break}case"deleteWordBackward":{O(t,Dt,!0);break}case"deleteWordForward":{O(t,Dt,!1);break}case"deleteHardLineBackward":case"deleteSoftLineBackward":{O(t,mt,!0);break}case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":{O(t,mt,!1);break}case"formatStrikeThrough":{O(t,Ee,"strikethrough");break}case"formatBold":{O(t,Ee,"bold");break}case"formatItalic":{O(t,Ee,"italic");break}case"formatUnderline":{O(t,Ee,"underline");break}case"historyUndo":{O(t,ho,void 0);break}case"historyRedo":{O(t,No,void 0);break}default:}})}function WN(o,t){o.stopPropagation(),Te(t,()=>{let e=C(),n=o.data,r=Ou(o);if(n!=null&&_(e)&&Du(e,r,n,o.timeStamp,!1)){Hr&&(ra(t,n),Hr=!1);let s=e.anchor.getNode(),l=ve(t._window);if(l===null)return;let a=e.isBackward(),d=a?e.anchor.offset:e.focus.offset,u=a?e.focus.offset:e.anchor.offset;(!bo||e.isCollapsed()||!L(s)||l.anchorNode===null||s.getTextContent().slice(0,d)+n+s.getTextContent().slice(d+u)!==Kl(l.anchorNode))&&O(t,ft,n);let m=n.length;Ze&&m>1&&o.inputType==="insertCompositionText"&&!t.isComposing()&&(e.anchor.offset-=m),!Gt&&!Ot&&!Jt&&t.isComposing()&&(Kr=0,le(null))}else Ri(!1,t,n!==null?n:void 0),Hr&&(ra(t,n||void 0),Hr=!1);Oc()}),Fn=null}function qN(o,t){Te(t,()=>{let e=C();if(_(e)&&!t.isComposing()){let n=e.anchor,r=e.anchor.getNode();le(n.key),(o.timeStamp{ra(t,o.data)})}function ZN(o,t){if(Kr=o.timeStamp,Mu=o.key,t.isComposing())return;let{key:e,shiftKey:n,ctrlKey:r,metaKey:i,altKey:s}=o;if(!O(t,xl,o)&&e!=null){if(eu(e,r,s,i))O(t,Fo,o);else if(tu(e,r,n,s,i))O(t,El,o);else if(Jc(e,r,s,i))O(t,Ko,o);else if(Qc(e,r,n,s,i))O(t,Tl,o);else if(ou(e,r,i))O(t,Zt,o);else if(nu(e,r,i))O(t,Vt,o);else if(Bc(e,n))Fr=!0,O(t,we,o);else if(iu(e))O(t,xr,o);else if(Hc(e,r))o.preventDefault(),Fr=!0,O(t,qt,!0);else if(Pc(e,n))Fr=!1,O(t,we,o);else if(Wc(e,s,i,r))An(e)?O(t,Xt,o):(o.preventDefault(),O(t,tt,!0));else if(lu(e))O(t,Uo,o);else if(qc(e,r,n,s,i))Rn(e)?O(t,jt,o):(o.preventDefault(),O(t,tt,!1));else if(Fc(e,s,r))o.preventDefault(),O(t,Dt,!0);else if(Kc(e,s,r))o.preventDefault(),O(t,Dt,!1);else if(Uc(e,i))o.preventDefault(),O(t,mt,!0);else if(zc(e,i))o.preventDefault(),O(t,mt,!1);else if(au(e))O(t,_i,o);else if(kc(e,s,i,r))o.preventDefault(),O(t,Ee,"bold");else if($c(e,s,i,r))o.preventDefault(),O(t,Ee,"underline");else if(Ic(e,s,i,r))o.preventDefault(),O(t,Ee,"italic");else if(Rc(e,s,r,i))O(t,zo,o);else if(Yc(e,n,i,r))o.preventDefault(),O(t,ho,void 0);else if(Zc(e,n,i,r))o.preventDefault(),O(t,No,void 0);else{let l=t._editorState._selection;Oe(l)?Vc(e,n,i,r)?(o.preventDefault(),O(t,xo,o)):Xc(e,n,i,r)?(o.preventDefault(),O(t,Eo,o)):Ul(e,i,r)&&(o.preventDefault(),O(t,Ln,o)):!Ze&&Ul(e,i,r)&&(o.preventDefault(),O(t,Ln,o))}ru(r,n,s,i)&&O(t,Ll,o)}}function Au(o){let t=o.__lexicalEventHandles;return t===void 0&&(t=[],o.__lexicalEventHandles=t),t}var Kn=new Map;function Ru(o){let t=o.target,e=t==null?null:t.nodeType===9?t.defaultView:t.ownerDocument.defaultView,n=ve(e);if(n===null)return;let r=Di(n.anchorNode);if(r===null)return;na&&(na=!1,Te(r,()=>{let u=je(),m=n.anchorNode;if(m===null)return;let c=m.nodeType;if(c!==_o&&c!==Ve)return;let f=Ur(u,n,r,o);Y(f)}));let i=Ar(r),s=i[i.length-1],l=s._key,a=Kn.get(l),d=a||s;d!==r&&yu(n,d,!1),yu(n,r,!0),r!==s?Kn.set(l,r):a&&Kn.delete(l)}function Su(o){o._lexicalHandled=!0}function Lu(o){return o._lexicalHandled===!0}function ku(o,t){let e=o.ownerDocument,n=Wi.get(e);(n===void 0||n<1)&&e.addEventListener("selectionchange",Ru),Wi.set(e,(n||0)+1),o.__lexicalEditor=t;let r=Au(o);for(let i=0;i{Lu(d)||(Su(d),(t.isEditable()||s==="click")&&l(d,t))}:d=>{if(Lu(d))return;Su(d);let u=t.isEditable();switch(s){case"cut":return u&&O(t,Eo,d);case"copy":return O(t,xo,d);case"paste":return u&&O(t,go,d);case"dragstart":return u&&O(t,Er,d);case"dragover":return u&&O(t,Tr,d);case"dragend":return u&&O(t,bl,d);case"focus":return u&&O(t,Cr,d);case"blur":return u&&O(t,Sl,d);case"drop":return u&&O(t,Wo,d)}};o.addEventListener(s,a),r.push(()=>{o.removeEventListener(s,a)})}}function Iu(o){let t=o.ownerDocument,e=Wi.get(t);T(e!==void 0,"Root element not registered");let n=e-1;T(n>=0,"Root element count less than 0"),Wi.set(t,n),n===0&&t.removeEventListener("selectionchange",Ru);let r=Yo(o);$n(r)?(VN(r),o.__lexicalEditor=null):r&&T(!1,"Attempted to remove event handlers from a node that does not belong to this build of Lexical");let i=Au(o);for(let s=0;si.__key===this.__key);if(L(this))return n;if(_(e)&&e.anchor.type==="element"&&e.focus.type==="element"){if(e.isCollapsed())return!1;let i=this.getParent();if(H(this)&&this.isInline()&&i){let s=e.isBackward()?e.focus:e.anchor,l=s.getNode();if(s.offset===l.getChildrenSize()&&l.is(i)&&l.getLastChildOrThrow().is(this))return!1}}return n}shouldSelectDirectly(){return!1}getKey(){return this.__key}getIndexWithinParent(){let t=this.getParent();if(t===null)return-1;let e=t.getFirstChild(),n=0;for(;e!==null;){if(this.is(e))return n;n++,e=e.getNextSibling()}return-1}getParent(){let t=this.getLatest().__parent;return t===null?null:ee(t)}getParentOrThrow(){let t=this.getParent();return t===null&&T(!1,"Expected node %s to have a parent.",this.__key),t}getTopLevelElement(){let t=this;for(;t!==null;){let e=t.getParent();if(ge(e))return T(E(t)||t===this&&H(t),"Children of root nodes must be elements or decorators"),t;t=e}return null}getTopLevelElementOrThrow(){let t=this.getTopLevelElement();return t===null&&T(!1,"Expected node %s to have a top parent element.",this.__key),t}getParents(){let t=[],e=this.getParent();for(;e!==null;)t.push(e),e=e.getParent();return t}getParentKeys(){let t=[],e=this.getParent();for(;e!==null;)t.push(e.__key),e=e.getParent();return t}getPreviousSibling(){let e=this.getLatest().__prev;return e===null?null:ee(e)}getPreviousSiblings(){let t=[],e=this.getParent();if(e===null)return t;let n=e.getFirstChild();for(;n!==null&&!n.is(this);)t.push(n),n=n.getNextSibling();return t}getNextSibling(){let e=this.getLatest().__next;return e===null?null:ee(e)}getNextSiblings(){let t=[],e=this.getNextSibling();for(;e!==null;)t.push(e),e=e.getNextSibling();return t}getCommonAncestor(t){let e=this.getParents(),n=t.getParents();E(this)&&e.unshift(this),E(t)&&n.unshift(t);let r=e.length,i=n.length;if(r===0||i===0||e[r-1]!==n[i-1])return null;let s=new Set(n);for(let l=0;l{l.append(h)})),_(n)){Y(n);let h=n.anchor,N=n.focus;h.key===i&&la(h,l),N.key===i&&la(N,l)}return nt()===i&&le(s),l}insertAfter(t,e=!0){ue(),$i(this,t);let n=this.getWritable(),r=t.getWritable(),i=r.getParent(),s=C(),l=!1,a=!1;if(i!==null){let f=t.getIndexWithinParent();if(to(r),_(s)){let g=i.__key,h=s.anchor,N=s.focus;l=h.type==="element"&&h.key===g&&h.offset===f+1,a=N.type==="element"&&N.key===g&&N.offset===f+1}}let d=this.getNextSibling(),u=this.getParentOrThrow().getWritable(),m=r.__key,c=n.__next;if(d===null)u.__last=m;else{let f=d.getWritable();f.__prev=m}if(u.__size++,n.__next=m,r.__next=c,r.__prev=n.__key,r.__parent=n.__parent,e&&_(s)){let f=this.getIndexWithinParent();Un(s,u,f+1);let g=u.__key;l&&s.anchor.set(g,f+2,"element"),a&&s.focus.set(g,f+2,"element")}return t}insertBefore(t,e=!0){ue(),$i(this,t);let n=this.getWritable(),r=t.getWritable(),i=r.__key;to(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 u=C();if(e&&_(u)){let m=this.getParentOrThrow();Un(u,m,d)}return t}isParentRequired(){return!1}createParentElementNode(){return I()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(t,e){ue();let n=this.getPreviousSibling(),r=this.getParentOrThrow();if(n===null)return r.select(0,0);if(E(n))return n.select();if(!L(n)){let i=n.getIndexWithinParent()+1;return r.select(i,i)}return n.select(t,e)}selectNext(t,e){ue();let n=this.getNextSibling(),r=this.getParentOrThrow();if(n===null)return r.select();if(E(n))return n.select(0,0);if(!L(n)){let i=n.getIndexWithinParent();return r.select(i,i)}return n.select(t,e)}markDirty(){this.getWritable()}insertDOMIntoParent(t,e){return!1}};p(Nt,"importDOM");function XN(o,t){let e=Q()._nodes.get(o);e===void 0&&T(!1,"Create node: Attempted to create node %s that was not configured to be used on the editor.",t.name);let n=e.klass;n!==t&&T(!1,"Create node: Type %s in node %s does not match registered node %s with the same type",o,t.name,n.name)}function Bu(o,t,e){let n=e||t.getParentOrThrow().getLastChild(),r=t,i=[t];for(;r!==n;)r.getNextSibling()||T(!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 Go=class o extends Nt{static getType(){return"linebreak"}static clone(t){return new o(t.__key)}constructor(t){super(t)}getTextContent(){return` -`}createDOM(){return document.createElement("br")}updateDOM(){return!1}static importDOM(){return{br:t=>GN(t)||JN(t)?null:{conversion:jN,priority:0}}}static importJSON(t){return xt()}exportJSON(){return{type:"linebreak",version:1}}};function jN(o){return{node:xt()}}function xt(){return re(new Go)}function Pe(o){return o instanceof Go}function GN(o){let t=o.parentElement;if(t!==null&&So(t)){let e=t.firstChild;if(e===o||e.nextSibling===o&&qi(e)){let n=t.lastChild;if(n===o||n.previousSibling===o&&qi(n))return!0}}return!1}function JN(o){let t=o.parentElement;if(t!==null&&So(t)){let e=t.firstChild;if(e===o||e.nextSibling===o&&qi(e))return!1;let n=t.lastChild;if(n===o||n.previousSibling===o&&qi(n))return!0}return!1}function qi(o){return o.nodeType===Ve&&/^( |\t|\r?\n)+$/.test(o.textContent||"")}function aa(o,t){return t&yr?"code":t&Mr?"mark":t&Sr?"sub":t&Lr?"sup":null}function da(o,t){return t&br?"strong":t&_r?"em":"span"}function Uu(o,t,e,n,r){let i=n.classList,s=yo(r,"base");s!==void 0&&i.add(...s),s=yo(r,"underlineStrikethrough");let l=!1,a=t&wn&&t&Mn,d=e&wn&&e&Mn;s!==void 0&&(d?(l=!0,a||i.add(...s)):a&&i.remove(...s));for(let u in $e){let c=$e[u];if(s=yo(r,u),s!==void 0)if(e&c){if(l&&(u==="underline"||u==="strikethrough")){t&c&&i.remove(...s);continue}((t&c)===0||a&&u==="underline"||u==="strikethrough")&&i.add(...s)}else t&c&&i.remove(...s)}}function QN(o,t){let e=o.length,n=t.length,r=0,i=0;for(;r({conversion:rx,priority:0}),b:()=>({conversion:tx,priority:0}),code:()=>({conversion:Mo,priority:0}),em:()=>({conversion:Mo,priority:0}),i:()=>({conversion:Mo,priority:0}),s:()=>({conversion:Mo,priority:0}),span:()=>({conversion:ex,priority:0}),strong:()=>({conversion:Mo,priority:0}),sub:()=>({conversion:Mo,priority:0}),sup:()=>({conversion:Mo,priority:0}),u:()=>({conversion:Mo,priority:0})}}static importJSON(e){let n=z(e.text);return n.setFormat(e.format),n.setDetail(e.detail),n.setMode(e.mode),n.setStyle(e.style),n}exportDOM(e){let{element:n}=super.exportDOM(e),r=(n?.nodeName||"").toLowerCase();T(n!==null&&he(n),"Expected TextNode createDOM to always return a HTMLElement");let i=this.getTextContent();/^\s|\s$/.test(i)&&(n.style.whiteSpace="pre-wrap");for(let s of Array.from(n.classList.values()))s.startsWith("editor-theme-")&&n.classList.remove(s);return n.classList.length===0&&n.removeAttribute("class"),n.nodeName==="SPAN"&&!n.getAttribute("style")&&(n=document.createTextNode(i)),this.hasFormat("bold")&&r!=="strong"&&(n=Yi(n,"strong")),this.hasFormat("italic")&&(n=Yi(n,"em")),this.hasFormat("strikethrough")&&(n=Yi(n,"s")),this.hasFormat("underline")&&(n=Yi(n,"u")),{element:n}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),type:"text",version:1}}selectionTransform(e,n){}setFormat(e){let n=this.getWritable();return n.__format=typeof e=="string"?$e[e]:e,n}setDetail(e){let n=this.getWritable();return n.__detail=typeof e=="string"?gc[e]:e,n}setStyle(e){let n=this.getWritable();return n.__style=e,n}toggleFormat(e){let n=this.getFormat(),r=Dr(n,e,null);return this.setFormat(r)}toggleDirectionless(){let e=this.getWritable();return e.__detail^=Li,e}toggleUnmergeable(){let e=this.getWritable();return e.__detail^=vn,e}setMode(e){let n=hc[e];if(this.__mode===n)return this;let r=this.getWritable();return r.__mode=n,r}setTextContent(e){if(this.__text===e)return this;let n=this.getWritable();return n.__text=e,n}select(e,n){ue();let r=e,i=n,s=C(),l=this.getTextContent(),a=this.__key;if(typeof l=="string"){let d=l.length;r===void 0&&(r=d),i===void 0&&(i=d)}else r=0,i=0;if(_(s)){let d=nt();(d===s.anchor.key||d===s.focus.key)&&le(a),s.setTextNodeRange(this,r,this,i)}else return Zi(a,r,a,i,"text","text");return s}selectStart(){return this.select(0,0)}selectEnd(){let e=this.getTextContentSize();return this.select(e,e)}spliceText(e,n,r,i){let s=this.getWritable(),l=s.__text,a=r.length,d=e;d<0&&(d=a+d,d<0&&(d=0));let u=C();if(i&&_(u)){let c=e+a;u.setTextNodeRange(s,c,s,c)}let m=l.slice(0,d)+r+l.slice(d+n);return s.__text=m,s}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...e){ue();let n=this.getLatest(),r=n.getTextContent(),i=n.__key,s=nt(),l=new Set(e),a=[],d=r.length,u="";for(let R=0;RM&&se.offset<=Z&&(se.key=k,se.offset-=M,S.dirty=!0),We.key===i&&We.type==="text"&&We.offset>M&&We.offset<=Z&&(We.key=k,We.offset-=M,S.dirty=!0)}s===i&&le(k),M=Z,v.push(B)}if(f!==null){vc(this);let R=f.getWritable(),A=this.getIndexWithinParent();x?(R.splice(A,0,v),this.remove()):R.splice(A,1,v),_(S)&&Un(S,f,A,m-1)}return v}mergeWithSibling(e){let n=e===this.getPreviousSibling();!n&&e!==this.getNextSibling()&&T(!1,"mergeWithSibling: sibling must be a previous or next sibling");let r=this.__key,i=e.__key,s=this.__text,l=s.length;nt()===i&&le(r);let d=C();if(_(d)){let f=d.anchor,g=d.focus;f!==null&&f.key===i&&(ca(f,n,r,e,l),d.dirty=!0),g!==null&&g.key===i&&(ca(g,n,r,e,l),d.dirty=!0)}let u=e.__text,m=n?u+s:s+u;this.setTextContent(m);let c=this.getWritable();return e.remove(),c}isTextEntity(){return!1}};function ex(o){let e=o.style;return{forChild:ua(e),node:null}}function tx(o){let t=o,e=t.style.fontWeight==="normal";return{forChild:ua(t.style,e?void 0:"bold"),node:null}}var Fu=new WeakMap;function ox(o){return o.nodeName==="PRE"||o.nodeType===_o&&o.style!==void 0&&o.style.whiteSpace!==void 0&&o.style.whiteSpace.startsWith("pre")}function nx(o){let t,e=o.parentNode,n=[o];for(;e!==null&&(t=Fu.get(e))===void 0&&!ox(e);)n.push(e),e=e.parentNode;let r=t===void 0?e:t;for(let i=0;i{let t=C();return t!==null?t.clone():null})}function EN(o,t,e){let n=ve(e._window),r=null,i=null;n!==null&&n.anchorNode===o&&(r=n.anchorOffset,i=n.focusOffset);let s=o.nodeValue;s!==null&&wr(t,s,r,i,!1)}function TN(o,t,e){return t.nodeType===Ve&&e.isAttached()}function Tc(o,t,e){Rl=!0;let n=performance.now()-kl>gN;try{Te(o,()=>{let r=C()||xN(o),i=new Map,s=o.getRootElement(),l=o._editorState,a=o._blockCursorElement,d=!1,u="";for(let c=0;c0){let v=0;for(let M=0;M0)for(let[c,f]of i)if(E(f)){let g=f.getChildrenKeys(),h=c.firstChild;for(let N=0;N0){for(let c=0;c{Tc(o,t,e)})}function Cc(o,t){let e=o.__mode,n=o.__format,r=o.__style,i=t.__mode,s=t.__format,l=t.__style;return(e===null||e===i)&&(n===null||n===s)&&(r===null||r===l)}function bc(o,t){let e=o.mergeWithSibling(t),n=Q()._normalizedNodes;return n.add(o.__key),n.add(t.__key),e}function Pl(o){let t=o;if(t.__text===""&&t.isSimpleText()&&!t.isUnmergeable()){t.remove();return}let e;for(;(e=t.getPreviousSibling())!==null&&L(e)&&e.isSimpleText()&&!e.isUnmergeable();)if(e.__text==="")e.remove();else if(Cc(e,t)){t=bc(e,t);break}else break;let n;for(;(n=t.getNextSibling())!==null&&L(n)&&n.isSimpleText()&&!n.isUnmergeable();)if(n.__text==="")n.remove();else if(Cc(t,n)){t=bc(t,n);break}else break}function qo(o){return _c(o.anchor),_c(o.focus),o}function _c(o){for(;o.type==="element";){let t=o.getNode(),e=o.offset,n,r;if(e===t.getChildrenSize()?(n=t.getChildAtIndex(e-1),r=!0):(n=t.getChildAtIndex(e),r=!1),L(n)){o.set(n.__key,r?n.getTextContentSize():0,"text");break}else if(!E(n))break;o.set(n.__key,r?n.getChildrenSize():0,"element")}}var CN=1;function bN(){return""+CN++}function Lc(o,t){let e=o._nodes.get(t);return e===void 0&&T(!1,"registeredNode: Type %s not found",t),e}var Mc=typeof queueMicrotask=="function"?queueMicrotask:o=>{Promise.resolve().then(o)};function wc(o){return H(G(o))}function In(o){let t=document.activeElement;if(t===null)return!1;let e=t.nodeName;return H(G(o))&&(e==="INPUT"||e==="TEXTAREA"||t.contentEditable==="true"&&Yo(t)==null)}function eo(o,t,e){let n=o.getRootElement();try{return n!==null&&n.contains(t)&&n.contains(e)&&t!==null&&!In(t)&&Di(t)===o}catch{return!1}}function $n(o){return o instanceof ro}function Di(o){let t=o;for(;t!=null;){let e=Yo(t);if($n(e))return e;t=Ii(t)}return null}function Yo(o){return o?o.__lexicalEditor:null}function Xe(o){return o.isToken()||o.isSegmented()}function _N(o){return o.nodeType===Ve}function Pn(o){let t=o;for(;t!=null;){if(_N(t))return t;t=t.firstChild}return null}function Dr(o,t,e){let n=$e[t];if(e!==null&&(o&n)===(e&n))return o;let r=o^n;return t==="subscript"?r&=~$e.superscript:t==="superscript"&&(r&=~$e.subscript),r}function Or(o){return L(o)||Pe(o)||H(o)}function vc(o,t){if(t!=null){__DEV__&&yN(o,t),o.__key=t;return}ue(),Zl();let e=Q(),n=rt(),r=bN();n._nodeMap.set(r,o),E(o)?e._dirtyElements.set(r,!0):e._dirtyLeaves.add(r),e._cloneNotNeeded.add(r),e._dirtyType=Dl,o.__key=r}function yN(o,t){let e=gu();if(!e)return;let n=e._nodeMap.get(t);n&&n.constructor!==o.constructor&&(o.constructor.name!==n.constructor.name?T(!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):T(!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 SN(o,t,e){let n=o;for(;n!==null;){if(e.has(n))return;let r=t.get(n);if(r===void 0)break;e.set(n,!1),n=r.__parent}}function to(o){let t=o.getParent();if(t!==null){let e=o.getWritable(),n=t.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;e.__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;e.__next=null}n.__size--,e.__parent=null}}function vr(o){Zl();let t=o.getLatest(),e=t.__parent,n=rt(),r=Q(),i=n._nodeMap,s=r._dirtyElements;e!==null&&SN(e,i,s);let l=t.__key;r._dirtyType=Dl,E(o)?s.set(l,!0):r._dirtyLeaves.add(l)}function Dc(o){let t=o.getPreviousSibling(),e=o.getNextSibling();t!==null&&vr(t),e!==null&&vr(e)}function le(o){ue();let t=Q(),e=t._compositionKey;if(o!==e){if(t._compositionKey=o,e!==null){let n=ee(e);n!==null&&n.getWritable()}if(o!==null){let n=ee(o);n!==null&&n.getWritable()}}}function nt(){return pt()?null:Q()._compositionKey}function ee(o,t){let n=(t||rt())._nodeMap.get(o);return n===void 0?null:n}function Il(o,t){let e=Q(),n=o[`__lexicalKey_${e._key}`];return n!==void 0?ee(n,t):null}function G(o,t){let e=o;for(;e!=null;){let n=Il(e,t);if(n!==null)return n;e=Ii(e)}return null}function Oi(o){let t=o._decorators,e=Object.assign({},t);return o._pendingDecorators=e,e}function Hl(o){return o.read(()=>F().getTextContent())}function Oc(o,t){Te(o,()=>{let e=rt();if(e.isEmpty())return;if(t==="root"){F().markDirty();return}let n=e._nodeMap;for(let[,r]of n)r.markDirty()},o._pendingEditorState===null?{tag:"history-merge"}:void 0)}function F(){return $l(rt())}function $l(o){return o._nodeMap.get("root")}function Y(o){ue();let t=rt();o!==null&&(__DEV__&&Object.isFrozen(o)&&T(!1,"$setSelection called on frozen selection object. Ensure selection is cloned before passing in."),o.dirty=!0,o.setCachedNodes(null)),t._selection=o}function Ac(){ue();let o=Q();Mi(o)}function Zo(o){let t=Q(),e=LN(o,t);if(e===null){let n=t.getRootElement();return o===n?ee("root"):null}return ee(e)}function Fl(o,t){return t?o.getTextContentSize():0}function LN(o,t){let e=o;for(;e!=null;){let n=e[`__lexicalKey_${t._key}`];if(n!==void 0)return n;e=Ii(e)}return null}function Ai(o){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(o)}function Ar(o){let t=[],e=o;for(;e!==null;)t.push(e),e=e._parentEditor;return t}function Kl(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function Ul(o){return o.nodeType===Ve?o.nodeValue:null}function Ri(o,t,e){let n=ve(t._window);if(n===null)return;let r=n.anchorNode,{anchorOffset:i,focusOffset:s}=n;if(r!==null){let l=Ul(r),a=G(r);if(l!==null&&L(a)){if(l===Dn&&e){let d=e.length;l=e,i=d,s=d}l!==null&&wr(a,l,i,s,o)}}}function wr(o,t,e,n,r){let i=o;if(i.isAttached()&&(r||!i.isDirty())){let s=i.isComposing(),l=t;(s||r)&&t[t.length-1]===Dn&&(l=t.slice(0,-1));let a=i.getTextContent();if(r||l!==a){if(l===""){if(le(null),!Gt&&!Ot&&!Jt){let h=Q();setTimeout(()=>{h.update(()=>{i.isAttached()&&i.remove()})},20)}else i.remove();return}let d=i.getParent(),u=je(),m=i.getTextContentSize(),c=nt(),f=i.getKey();if(i.isToken()||c!==null&&f===c&&!s||_(u)&&(d!==null&&!d.canInsertTextBefore()&&u.anchor.offset===0||u.anchor.key===o.__key&&u.anchor.offset===0&&!i.canInsertTextBefore()&&!s||u.focus.key===o.__key&&u.focus.offset===m&&!i.canInsertTextAfter()&&!s)){i.markDirty();return}let g=C();if(!_(g)||e===null||n===null){i.setTextContent(l);return}if(g.setTextNodeRange(i,e,i,n),i.isSegmented()){let h=i.getTextContent(),N=z(h);i.replace(N),i=N}i.setTextContent(l)}}}function MN(o){let t=o.getPreviousSibling();return(L(t)||E(t)&&t.isInline())&&!t.canInsertTextAfter()}function Rc(o,t){if(t.isSegmented())return!0;if(!o.isCollapsed())return!1;let e=o.anchor.offset,n=t.getParentOrThrow(),r=t.isToken();return e===0?!t.canInsertTextBefore()||!n.canInsertTextBefore()&&!t.isComposing()||r||MN(t):e===t.getTextContentSize()?!t.canInsertTextAfter()||!n.canInsertTextAfter()&&!t.isComposing()||r:!1}function kc(o,t,e,n){return o==="Tab"&&!t&&!e&&!n}function Ic(o,t,e,n){return o.toLowerCase()==="b"&&!t&&Rr(e,n)}function $c(o,t,e,n){return o.toLowerCase()==="i"&&!t&&Rr(e,n)}function Pc(o,t,e,n){return o.toLowerCase()==="u"&&!t&&Rr(e,n)}function Bc(o,t){return lu(o)&&!t}function Hc(o,t){return lu(o)&&t}function Fc(o,t){return Ye&&t&&o.toLowerCase()==="o"}function Kc(o,t,e){return An(o)&&(Ye?t:e)}function Uc(o,t,e){return Rn(o)&&(Ye?t:e)}function zc(o,t){return Ye&&t&&An(o)}function Wc(o,t){return Ye&&t&&Rn(o)}function qc(o,t,e,n){return Ye?t||e?!1:An(o)||o.toLowerCase()==="h"&&n:n||t||e?!1:An(o)}function Yc(o,t,e,n,r){return Ye?e||n||r?!1:Rn(o)||o.toLowerCase()==="d"&&t:t||n||r?!1:Rn(o)}function Zc(o,t,e,n){return o.toLowerCase()==="z"&&!t&&Rr(e,n)}function Vc(o,t,e,n){return Ye?o.toLowerCase()==="z"&&e&&t:o.toLowerCase()==="y"&&n||o.toLowerCase()==="z"&&n&&t}function Xc(o,t,e,n){return t?!1:o.toLowerCase()==="c"?Ye?e:n:!1}function jc(o,t,e,n){return t?!1:o.toLowerCase()==="x"?Ye?e:n:!1}function Gc(o){return o==="ArrowLeft"}function Jc(o){return o==="ArrowRight"}function wN(o){return o==="ArrowUp"}function vN(o){return o==="ArrowDown"}function Qc(o,t,e,n){return Gc(o)&&!t&&!n&&!e}function eu(o,t,e,n,r){return Gc(o)&&!n&&!e&&(t||r)}function tu(o,t,e,n){return Jc(o)&&!t&&!n&&!e}function ou(o,t,e,n,r){return Jc(o)&&!n&&!e&&(t||r)}function nu(o,t,e){return wN(o)&&!t&&!e}function ru(o,t,e){return vN(o)&&!t&&!e}function iu(o,t,e,n){return o||t||e||n}function su(o){return o===" "}function Rr(o,t){return Ye?o:t}function lu(o){return o==="Enter"}function An(o){return o==="Backspace"}function au(o){return o==="Escape"}function Rn(o){return o==="Delete"}function du(o){return o==="@"}function zl(o,t,e){return o.toLowerCase()==="a"&&Rr(t,e)}function Wl(){let o=F(),t=o.select(0,o.getChildrenSize());Y(qo(t))}function yo(o,t){o.__lexicalClassNameCache===void 0&&(o.__lexicalClassNameCache={});let e=o.__lexicalClassNameCache,n=e[t];if(n!==void 0)return n;let r=o[t];if(typeof r=="string"){let i=Rt(r);return e[t]=i,i}return r}function ki(o,t,e,n,r){if(e.size===0)return;let i=n.__type,s=n.__key,l=t.get(i);l===void 0&&T(!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 u=d.get(s),m=u==="destroyed"&&r==="created";(u===void 0||m)&&d.set(s,m?"updated":r)}function yc(o,t,e){let n=o.getParent(),r=e,i=o;return n!==null&&(t&&e===0?(r=i.getIndexWithinParent(),i=n):!t&&e===i.getChildrenSize()&&(r=i.getIndexWithinParent()+1,i=n)),i.getChildAtIndex(t?r-1:r)}function oo(o,t){let e=o.offset;if(o.type==="element"){let n=o.getNode();return yc(n,t,e)}else{let n=o.getNode();if(t&&e===0||!t&&e===n.getTextContentSize()){let r=t?n.getPreviousSibling():n.getNextSibling();return r===null?yc(n.getParentOrThrow(),t,n.getIndexWithinParent()+(t?0:1)):r}}return null}function vi(o){let t=On(o).event,e=t&&t.inputType;return e==="insertFromPaste"||e==="insertFromPasteAsQuotation"}function O(o,t,e){return Vl(o,t,e)}function kr(o){return!ne(o)&&!o.isLastChild()&&!o.isInline()}function Bn(o,t){let e=o._keyToDOMMap.get(t);return e===void 0&&T(!1,"Reconciliation: could not find DOM element for node key %s",t),e}function Ii(o){let t=o.assignedSlot||o.parentElement;return t!==null&&t.nodeType===11?t.host:t}function cu(o,t,e){let n=e.ownerDocument,r=n.defaultView;if(r===null)return;let{top:i,bottom:s}=t,l=0,a=0,d=e;for(;d!==null;){let u=d===n.body;if(u)l=0,a=On(o).innerHeight;else{let c=d.getBoundingClientRect();l=c.top,a=c.bottom}let m=0;if(ia&&(m=s-a),m!==0)if(u)r.scrollBy(0,m);else{let c=d.scrollTop;d.scrollTop+=m;let f=d.scrollTop-c;i-=f,s-=f}if(u)break;d=Ii(d)}}function uu(o){let t=C();if(!_(t)||!E(o))return t;let{anchor:e,focus:n}=t,r=e.getNode(),i=n.getNode();return kn(r,o)&&e.set(o.__key,0,"element"),kn(i,o)&&n.set(o.__key,0,"element"),t}function kn(o,t){let e=o.getParent();for(;e!==null;){if(e.is(t))return!0;e=e.getParent()}return!1}function fu(o){let t=o.ownerDocument;return t&&t.defaultView||null}function On(o){let t=o._window;return t===null&&T(!1,"window object not found"),t}function ql(o){let t=o.getParentOrThrow();for(;t!==null;){if(ge(t))return t;t=t.getParentOrThrow()}return t}var XC=Symbol.for("@lexical/ShadowRootNodeBrand");function ge(o){return ne(o)||E(o)&&o.isShadowRoot()}function re(o){let t=Q(),e=o.constructor.getType(),n=t._nodes.get(e);n===void 0&&T(!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||T(!1,"$initializeNode failed. Ensure replacement node is a subclass of the original node."),i}return o}function $i(o,t){let e=o.getParent();ne(e)&&!E(t)&&!H(t)&&T(!1,"Only element or decorator nodes can be inserted in to the root node")}function DN(o){let t=o.theme,e=document.createElement("div");e.contentEditable="false",e.setAttribute("data-lexical-cursor","true");let n=t.blockCursor;if(n!==void 0){if(typeof n=="string"){let r=Rt(n);n=t.blockCursor=r}n!==void 0&&e.classList.add(...n)}return e}function Bl(o){return(H(o)||E(o)&&!o.canBeEmpty())&&!o.isInline()}function Ir(o,t,e){e.style.removeProperty("caret-color"),t._blockCursorElement=null;let n=o.parentElement;n!==null&&n.removeChild(o)}function mu(o,t,e){let n=o._blockCursorElement;if(_(e)&&e.isCollapsed()&&e.anchor.type==="element"&&t.contains(document.activeElement)){let r=e.anchor,i=r.getNode(),s=r.offset,l=i.getChildrenSize(),a=!1,d=null;if(s===l){let u=i.getChildAtIndex(s-1);Bl(u)&&(a=!0)}else{let u=i.getChildAtIndex(s);if(Bl(u)){let m=u.getPreviousSibling();(m===null||Bl(m))&&(a=!0,d=o.getElementByKey(u.__key))}}if(a){let u=o.getElementByKey(i.__key);n===null&&(o._blockCursorElement=n=DN(o._config)),t.style.caretColor="transparent",d===null?u.appendChild(n):u.insertBefore(n,d);return}}n!==null&&Ir(n,o,t)}function ve(o){return pe?(o||window).getSelection():null}function Pi(o){return he(o)&&o.tagName==="A"}function he(o){return o.nodeType===1}function Vo(o){let t=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(t)!==null}function So(o){let t=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(t)!==null}function Xo(o){if(ne(o)||H(o)&&!o.isInline())return!0;if(!E(o)||ge(o))return!1;let t=o.getFirstChild(),e=t===null||Pe(t)||L(t)||t.isInline();return!o.isInline()&&o.canBeEmpty()!==!1&&e}function Bi(o,t){let e=o;for(;e!==null&&e.getParent()!==null&&!t(e);)e=e.getParentOrThrow();return t(e)?e:null}function Yl(){return Q()}var Sc=new WeakMap,ON=new Map;function pu(o){if(!o._readOnly&&o.isEmpty())return ON;T(o._readOnly,"getCachedTypeToNodeMap called with a writable EditorState");let t=Sc.get(o);if(!t){t=new Map,Sc.set(o,t);for(let[e,n]of o._nodeMap){let r=n.__type,i=t.get(r);i||(i=new Map,t.set(r,i)),i.set(e,n)}}return t}function no(o){let t=o.constructor,e=t.clone(o);return e.afterCloneFrom(o),__DEV__&&(T(e.__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",t.name,t.getType()),T(e.__parent===o.__parent&&e.__next===o.__next&&e.__prev===o.__prev,"$cloneWithProperties: %s.clone(node) (with type '%s') overrided afterCloneFrom but did not call super.afterCloneFrom(prevNode)",t.name,t.getType())),e}function hu(o,t){let e=o._decorators,r=o._pendingDecorators||e,i=t._nodeMap,s;for(s in r)i.has(s)||(r===e&&(r=Oi(o)),delete r[s])}function Nu(o,t,e,n,r,i){let s=o.getFirstChild();for(;s!==null;){let l=s.__key;s.__parent===t&&(E(s)&&Nu(s,l,e,n,r,i),e.has(l)||i.delete(l),r.push(l)),s=s.getNextSibling()}}function xu(o,t,e,n){let r=o._nodeMap,i=t._nodeMap,s=[];for(let[l]of n){let a=i.get(l);a!==void 0&&(a.isAttached()||(E(a)&&Nu(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 e){let a=i.get(l);a!==void 0&&!a.isAttached()&&(r.has(l)||e.delete(l),i.delete(l))}}var fe="",Lo=null,gt="",io="",Hn,De,Pr,Tu=!1,Fi=!1,Ki,jl,Gl,jo,ht,Jl,Br;function Ui(o,t){let e=jo.get(o);if(t!==null){let n=ta(o);n.parentNode===t&&t.removeChild(n)}if(ht.has(o)||De._keyToDOMMap.delete(o),E(e)){let n=Hi(e,jo);Ql(n,0,n.length-1,null)}e!==void 0&&ki(Br,Pr,Ki,e,"destroyed")}function Ql(o,t,e,n){let r=t;for(;r<=e;++r){let i=o[r];i!==void 0&&Ui(i,n)}}function zi(o,t,e){let n=ht.get(o);n===void 0&&T(!1,"createNode: node does not exist in nodeMap");let r=n.createDOM(Hn,De);if(BN(o,r,De),L(n)?r.setAttribute("data-lexical-text","true"):H(n)&&r.setAttribute("data-lexical-decorator","true"),E(n)){let i=n.__size;if(i!==0){let s=i-1,l=Hi(n,ht);ea(l,n,0,s,r,null)}n.isInline()||Cu(null,n,r),kr(n)&&(fe+=ot,io+=ot)}else{let i=n.getTextContent();if(H(n)){let s=n.decorate(De,Hn);s!==null&&bu(o,s),r.contentEditable="false"}fe+=i,io+=i}if(t!==null&&!n?.insertDOMIntoParent(r,t))if(e!=null)t.insertBefore(r,e);else{let s=t.__lexicalLineBreak;s!=null?t.insertBefore(r,s):t.appendChild(r)}return __DEV__&&Object.freeze(n),ki(Br,Pr,Ki,n,"created"),r}function ea(o,t,e,n,r,i){let s=fe;fe="";let l=e;for(;l<=n;++l){zi(o[l],r,i);let a=ht.get(o[l]);a!==null&&L(a)&&(Lo===null&&(Lo=a.getFormat()),gt===""&&(gt=a.getStyle()))}kr(t)&&(fe+=ot),r.__lexicalTextContent=fe,fe=s+fe}function Eu(o,t){let e=t.get(o);return Pe(e)||H(e)&&e.isInline()}function Cu(o,t,e){let n=o!==null&&(o.__size===0||Eu(o.__last,jo)),r=t.__size===0||Eu(t.__last,ht);if(n){if(!r){let i=e.__lexicalLineBreak;if(i!=null)try{e.removeChild(i)}catch(s){if(typeof s=="object"&&s!=null){let l=`${s.toString()} Parent: ${e.tagName}, child: ${i.tagName}.`;throw new Error(l)}else throw s}e.__lexicalLineBreak=null}}else if(r){let i=document.createElement("br");e.__lexicalLineBreak=i,e.appendChild(i)}}function AN(o){Ge(o)&&Lo!=null&&!Fi&&o.setTextStyle(gt)}function RN(o){Ge(o)&>!==""&>!==o.__textStyle&&!Fi&&o.setTextStyle(gt)}function kN(o,t,e){Lo=null,gt="",IN(o,t,e),AN(t),RN(t)}function Hi(o,t){let e=[],n=o.__first;for(;n!==null;){let r=t.get(n);r===void 0&&T(!1,"createChildrenArray: node does not exist in nodeMap"),e.push(n),n=r.__next}return e}function IN(o,t,e){let n=fe,r=o.__size,i=t.__size;if(fe="",r===1&&i===1){let s=o.__first,l=t.__first;if(s===l)$r(s,e);else{let d=ta(s),u=zi(l,null,null);try{e.replaceChild(u,d)}catch(m){if(typeof m=="object"&&m!=null){let c=`${m.toString()} Parent: ${e.tagName}, new child: {tag: ${u.tagName} key: ${l}}, old child: {tag: ${d.tagName}, key: ${s}}.`;throw new Error(c)}else throw m}Ui(s,null)}let a=ht.get(l);L(a)&&(Lo===null&&(Lo=a.getFormat()),gt===""&&(gt=a.getStyle()))}else{let s=Hi(o,jo),l=Hi(t,ht);if(r===0)i!==0&&ea(l,t,0,i-1,e,null);else if(i===0){if(r!==0){let d=e.__lexicalLineBreak==null;Ql(s,0,r-1,d?null:e),d&&(e.textContent="")}}else PN(t,s,l,r,i,e)}kr(t)&&(fe+=ot),e.__lexicalTextContent=fe,fe=n+fe}function $r(o,t){let e=jo.get(o),n=ht.get(o);(e===void 0||n===void 0)&&T(!1,"reconcileNode: prevNode or nextNode does not exist in nodeMap");let r=Tu||Gl.has(o)||jl.has(o),i=Bn(De,o);if(e===n&&!r){if(E(e)){let s=i.__lexicalTextContent;s!==void 0&&(fe+=s,io+=s)}else{let s=e.getTextContent();io+=s,fe+=s}return i}if(e!==n&&r&&ki(Br,Pr,Ki,n,"updated"),n.updateDOM(e,i,Hn)){let s=zi(o,null,null);return t===null&&T(!1,"reconcileNode: parentDOM is null"),t.replaceChild(s,i),Ui(o,null),s}if(E(e)&&E(n))r&&(kN(e,n,i),!ne(n)&&!n.isInline()&&Cu(e,n,i)),kr(n)&&(fe+=ot,io+=ot);else{let s=n.getTextContent();if(H(n)){let l=n.decorate(De,Hn);l!==null&&bu(o,l)}fe+=s,io+=s}if(!Fi&&ne(n)&&n.__cachedText!==io){let s=n.getWritable();s.__cachedText=io,n=s}return __DEV__&&Object.freeze(n),i}function bu(o,t){let e=De._pendingDecorators,n=De._decorators;if(e===null){if(n[o]===t)return;e=Oi(De)}e[o]=t}function $N(o){return o.firstChild}function Xl(o){let t=o.nextSibling;return t!==null&&t===De._blockCursorElement&&(t=t.nextSibling),t}function PN(o,t,e,n,r,i){let s=n-1,l=r-1,a,d,u=$N(i),m=0,c=0;for(;m<=s&&c<=l;){let h=t[m],N=e[c];if(h===N)u=Xl($r(N,i)),m++,c++;else{a===void 0&&(a=new Set(t)),d===void 0&&(d=new Set(e));let x=d.has(h),S=a.has(N);if(!x)u=Xl(ta(h)),Ui(h,i),m++;else if(!S)zi(N,i,u),c++;else{let v=Bn(De,N);v===u?u=Xl($r(N,i)):(u!=null?i.insertBefore(v,u):i.appendChild(v),$r(N,i)),m++,c++}}let b=ht.get(N);b!==null&&L(b)&&(Lo===null&&(Lo=b.getFormat()),gt===""&&(gt=b.getStyle()))}let f=m>s,g=c>l;if(f&&!g){let h=e[l+1],N=h===void 0?null:De.getElementByKey(h);ea(e,o,c,l,i,N)}else g&&!f&&Ql(t,m,s,i)}function _u(o,t,e,n,r,i){fe="",io="",Tu=n===Qt,De=e,Hn=e._config,Pr=e._nodes,Ki=De._listeners.mutation,jl=r,Gl=i,jo=o._nodeMap,ht=t._nodeMap,Fi=t._readOnly,Jl=new Map(e._keyToDOMMap);let s=new Map;return Br=s,$r("root",null),De=void 0,Pr=void 0,jl=void 0,Gl=void 0,jo=void 0,ht=void 0,Hn=void 0,Jl=void 0,Br=void 0,s}function BN(o,t,e){let n=e._keyToDOMMap;t["__lexicalKey_"+e._key]=o,n.set(o,t)}function ta(o){let t=Jl.get(o);return t===void 0&&T(!1,"Reconciliation: could not find DOM element for node key %s",o),t}var so=Object.freeze({}),sa=30,oa=[["keydown",ZN],["pointerdown",FN],["compositionstart",qN],["compositionend",YN],["input",WN],["click",HN],["cut",so],["copy",so],["dragstart",so],["dragover",so],["dragend",so],["paste",so],["focus",so],["blur",so],["drop",so]];bo&&oa.push(["beforeinput",(o,t)=>zN(o,t)]);var Kr=0,wu=null,vu=0,Fn=null,Wi=new WeakMap,na=!1,ra=!1,Fr=!1,Hr=!1,Du=[0,"",0,"root",0];function Ou(o,t,e,n,r){let i=o.anchor,s=o.focus,l=i.getNode(),a=Q(),d=ve(a._window),u=d!==null?d.anchorNode:null,m=i.key,c=a.getElementByKey(m),f=e.length;return m!==s.key||!L(l)||(!r&&(!bo||vu1||(r||!bo)&&c!==null&&!l.isComposing()&&u!==Pn(c)||d!==null&&t!==null&&(!t.collapsed||t.startContainer!==d.anchorNode||t.startOffset!==d.anchorOffset)||l.getFormat()!==o.format||l.getStyle()!==o.style||Rc(o,l)}function yu(o,t){return o!==null&&o.nodeValue!==null&&o.nodeType===Ve&&t!==0&&t!==o.nodeValue.length}function Su(o,t,e){let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}=o;na&&(na=!1,yu(n,r)&&yu(i,s))||Te(t,()=>{if(!e){Y(null);return}if(!eo(t,n,i))return;let l=C();if(_(l)){let a=l.anchor,d=a.getNode();if(l.isCollapsed()){o.type==="Range"&&o.anchorNode===o.focusNode&&(l.dirty=!0);let u=On(t).event,m=u?u.timeStamp:performance.now(),[c,f,g,h,N]=Du,b=F(),x=t.isComposing()===!1&&b.getTextContent()==="";if(m{let e=C(),n=ve(t._window),r=je();if(n){if(_(e)){let i=e.anchor,s=i.getNode();if(i.type==="element"&&i.offset===0&&e.isCollapsed()&&!ne(s)&&F().getChildrenSize()===1&&s.getTopLevelElementOrThrow().isEmpty()&&r!==null&&e.is(r))n.removeAllRanges(),e.dirty=!0;else if(o.detail===3&&!e.isCollapsed()){let a=e.focus.getNode();s!==a&&(E(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===_o||s===Ve){let l=Ur(r,n,t,o);Y(l)}}}}O(t,Wt,o)})}function FN(o,t){let e=o.target,n=o.pointerType;e instanceof Node&&n!=="touch"&&Te(t,()=>{wc(e)||(ra=!0)})}function Au(o){if(!o.getTargetRanges)return null;let t=o.getTargetRanges();return t.length===0?null:t[0]}function KN(o,t){return o!==t||E(o)||E(t)||!o.isToken()||!t.isToken()}function UN(o){return wu==="MediaLast"&&o{let r=C();if(e==="deleteContentBackward"){if(r===null){let u=je();if(!_(u))return;Y(u.clone())}if(_(r)){let u=r.anchor.key===r.focus.key;if(UN(o.timeStamp)&&t.isComposing()&&u){if(le(null),Kr=0,setTimeout(()=>{Te(t,()=>{le(null)})},sa),_(r)){let m=r.anchor.getNode();m.markDirty(),T(L(m),"Anchor node must be a TextNode"),r.style=m.getStyle()}}else{le(null),o.preventDefault();let m=r.anchor.getNode().getTextContent(),c=r.anchor.offset===0&&r.focus.offset===m.length;vl&&u&&!c||O(t,tt,!0)}return}}if(!_(r))return;let i=o.data;Fn!==null&&Ri(!1,t,Fn),(!r.dirty||Fn!==null)&&r.isCollapsed()&&!ne(r.anchor.getNode())&&n!==null&&r.applyDOMRange(n),Fn=null;let s=r.anchor,l=r.focus,a=s.getNode(),d=l.getNode();if(e==="insertText"||e==="insertTranspose"){if(i===` +`)o.preventDefault(),O(t,qt,!1);else if(i===ot)o.preventDefault(),O(t,Yt,void 0);else if(i==null&&o.dataTransfer){let u=o.dataTransfer.getData("text/plain");o.preventDefault(),r.insertRawText(u)}else i!=null&&Ou(r,n,i,o.timeStamp,!0)?(o.preventDefault(),O(t,ft,i)):Fn=i;vu=o.timeStamp;return}switch(o.preventDefault(),e){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":{O(t,ft,o);break}case"insertFromComposition":{le(null),O(t,ft,o);break}case"insertLineBreak":{le(null),O(t,qt,!1);break}case"insertParagraph":{le(null),Fr&&!Ot?(Fr=!1,O(t,qt,!1)):O(t,Yt,void 0);break}case"insertFromPaste":case"insertFromPasteAsQuotation":{O(t,go,o);break}case"deleteByComposition":{KN(a,d)&&O(t,Sn,o);break}case"deleteByDrag":case"deleteByCut":{O(t,Sn,o);break}case"deleteContent":{O(t,tt,!1);break}case"deleteWordBackward":{O(t,Dt,!0);break}case"deleteWordForward":{O(t,Dt,!1);break}case"deleteHardLineBackward":case"deleteSoftLineBackward":{O(t,mt,!0);break}case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":{O(t,mt,!1);break}case"formatStrikeThrough":{O(t,Ee,"strikethrough");break}case"formatBold":{O(t,Ee,"bold");break}case"formatItalic":{O(t,Ee,"italic");break}case"formatUnderline":{O(t,Ee,"underline");break}case"historyUndo":{O(t,ho,void 0);break}case"historyRedo":{O(t,No,void 0);break}default:}})}function WN(o,t){o.stopPropagation(),Te(t,()=>{let e=C(),n=o.data,r=Au(o);if(n!=null&&_(e)&&Ou(e,r,n,o.timeStamp,!1)){Hr&&(ia(t,n),Hr=!1);let s=e.anchor.getNode(),l=ve(t._window);if(l===null)return;let a=e.isBackward(),d=a?e.anchor.offset:e.focus.offset,u=a?e.focus.offset:e.anchor.offset;(!bo||e.isCollapsed()||!L(s)||l.anchorNode===null||s.getTextContent().slice(0,d)+n+s.getTextContent().slice(d+u)!==Ul(l.anchorNode))&&O(t,ft,n);let m=n.length;Ze&&m>1&&o.inputType==="insertCompositionText"&&!t.isComposing()&&(e.anchor.offset-=m),!Gt&&!Ot&&!Jt&&t.isComposing()&&(Kr=0,le(null))}else Ri(!1,t,n!==null?n:void 0),Hr&&(ia(t,n||void 0),Hr=!1);Ac()}),Fn=null}function qN(o,t){Te(t,()=>{let e=C();if(_(e)&&!t.isComposing()){let n=e.anchor,r=e.anchor.getNode();le(n.key),(o.timeStamp{ia(t,o.data)})}function ZN(o,t){if(Kr=o.timeStamp,wu=o.key,t.isComposing())return;let{key:e,shiftKey:n,ctrlKey:r,metaKey:i,altKey:s}=o;if(!O(t,El,o)&&e!=null){if(tu(e,r,s,i))O(t,Fo,o);else if(ou(e,r,n,s,i))O(t,Tl,o);else if(Qc(e,r,s,i))O(t,Ko,o);else if(eu(e,r,n,s,i))O(t,Cl,o);else if(nu(e,r,i))O(t,Zt,o);else if(ru(e,r,i))O(t,Vt,o);else if(Hc(e,n))Fr=!0,O(t,we,o);else if(su(e))O(t,xr,o);else if(Fc(e,r))o.preventDefault(),Fr=!0,O(t,qt,!0);else if(Bc(e,n))Fr=!1,O(t,we,o);else if(qc(e,s,i,r))An(e)?O(t,Xt,o):(o.preventDefault(),O(t,tt,!0));else if(au(e))O(t,Uo,o);else if(Yc(e,r,n,s,i))Rn(e)?O(t,jt,o):(o.preventDefault(),O(t,tt,!1));else if(Kc(e,s,r))o.preventDefault(),O(t,Dt,!0);else if(Uc(e,s,r))o.preventDefault(),O(t,Dt,!1);else if(zc(e,i))o.preventDefault(),O(t,mt,!0);else if(Wc(e,i))o.preventDefault(),O(t,mt,!1);else if(du(e))O(t,_i,o);else if(Ic(e,s,i,r))o.preventDefault(),O(t,Ee,"bold");else if(Pc(e,s,i,r))o.preventDefault(),O(t,Ee,"underline");else if($c(e,s,i,r))o.preventDefault(),O(t,Ee,"italic");else if(kc(e,s,r,i))O(t,zo,o);else if(Zc(e,n,i,r))o.preventDefault(),O(t,ho,void 0);else if(Vc(e,n,i,r))o.preventDefault(),O(t,No,void 0);else{let l=t._editorState._selection;Oe(l)?Xc(e,n,i,r)?(o.preventDefault(),O(t,xo,o)):jc(e,n,i,r)?(o.preventDefault(),O(t,Eo,o)):zl(e,i,r)&&(o.preventDefault(),O(t,Ln,o)):!Ze&&zl(e,i,r)&&(o.preventDefault(),O(t,Ln,o))}iu(r,n,s,i)&&O(t,Ml,o)}}function Ru(o){let t=o.__lexicalEventHandles;return t===void 0&&(t=[],o.__lexicalEventHandles=t),t}var Kn=new Map;function ku(o){let t=o.target,e=t==null?null:t.nodeType===9?t.defaultView:t.ownerDocument.defaultView,n=ve(e);if(n===null)return;let r=Di(n.anchorNode);if(r===null)return;ra&&(ra=!1,Te(r,()=>{let u=je(),m=n.anchorNode;if(m===null)return;let c=m.nodeType;if(c!==_o&&c!==Ve)return;let f=Ur(u,n,r,o);Y(f)}));let i=Ar(r),s=i[i.length-1],l=s._key,a=Kn.get(l),d=a||s;d!==r&&Su(n,d,!1),Su(n,r,!0),r!==s?Kn.set(l,r):a&&Kn.delete(l)}function Lu(o){o._lexicalHandled=!0}function Mu(o){return o._lexicalHandled===!0}function Iu(o,t){let e=o.ownerDocument,n=Wi.get(e);(n===void 0||n<1)&&e.addEventListener("selectionchange",ku),Wi.set(e,(n||0)+1),o.__lexicalEditor=t;let r=Ru(o);for(let i=0;i{Mu(d)||(Lu(d),(t.isEditable()||s==="click")&&l(d,t))}:d=>{if(Mu(d))return;Lu(d);let u=t.isEditable();switch(s){case"cut":return u&&O(t,Eo,d);case"copy":return O(t,xo,d);case"paste":return u&&O(t,go,d);case"dragstart":return u&&O(t,Er,d);case"dragover":return u&&O(t,Tr,d);case"dragend":return u&&O(t,_l,d);case"focus":return u&&O(t,Cr,d);case"blur":return u&&O(t,Ll,d);case"drop":return u&&O(t,Wo,d)}};o.addEventListener(s,a),r.push(()=>{o.removeEventListener(s,a)})}}function $u(o){let t=o.ownerDocument,e=Wi.get(t);T(e!==void 0,"Root element not registered");let n=e-1;T(n>=0,"Root element count less than 0"),Wi.set(t,n),n===0&&t.removeEventListener("selectionchange",ku);let r=Yo(o);$n(r)?(VN(r),o.__lexicalEditor=null):r&&T(!1,"Attempted to remove event handlers from a node that does not belong to this build of Lexical");let i=Ru(o);for(let s=0;si.__key===this.__key);if(L(this))return n;if(_(e)&&e.anchor.type==="element"&&e.focus.type==="element"){if(e.isCollapsed())return!1;let i=this.getParent();if(H(this)&&this.isInline()&&i){let s=e.isBackward()?e.focus:e.anchor,l=s.getNode();if(s.offset===l.getChildrenSize()&&l.is(i)&&l.getLastChildOrThrow().is(this))return!1}}return n}shouldSelectDirectly(){return!1}getKey(){return this.__key}getIndexWithinParent(){let t=this.getParent();if(t===null)return-1;let e=t.getFirstChild(),n=0;for(;e!==null;){if(this.is(e))return n;n++,e=e.getNextSibling()}return-1}getParent(){let t=this.getLatest().__parent;return t===null?null:ee(t)}getParentOrThrow(){let t=this.getParent();return t===null&&T(!1,"Expected node %s to have a parent.",this.__key),t}getTopLevelElement(){let t=this;for(;t!==null;){let e=t.getParent();if(ge(e))return T(E(t)||t===this&&H(t),"Children of root nodes must be elements or decorators"),t;t=e}return null}getTopLevelElementOrThrow(){let t=this.getTopLevelElement();return t===null&&T(!1,"Expected node %s to have a top parent element.",this.__key),t}getParents(){let t=[],e=this.getParent();for(;e!==null;)t.push(e),e=e.getParent();return t}getParentKeys(){let t=[],e=this.getParent();for(;e!==null;)t.push(e.__key),e=e.getParent();return t}getPreviousSibling(){let e=this.getLatest().__prev;return e===null?null:ee(e)}getPreviousSiblings(){let t=[],e=this.getParent();if(e===null)return t;let n=e.getFirstChild();for(;n!==null&&!n.is(this);)t.push(n),n=n.getNextSibling();return t}getNextSibling(){let e=this.getLatest().__next;return e===null?null:ee(e)}getNextSiblings(){let t=[],e=this.getNextSibling();for(;e!==null;)t.push(e),e=e.getNextSibling();return t}getCommonAncestor(t){let e=this.getParents(),n=t.getParents();E(this)&&e.unshift(this),E(t)&&n.unshift(t);let r=e.length,i=n.length;if(r===0||i===0||e[r-1]!==n[i-1])return null;let s=new Set(n);for(let l=0;l{l.append(h)})),_(n)){Y(n);let h=n.anchor,N=n.focus;h.key===i&&aa(h,l),N.key===i&&aa(N,l)}return nt()===i&&le(s),l}insertAfter(t,e=!0){ue(),$i(this,t);let n=this.getWritable(),r=t.getWritable(),i=r.getParent(),s=C(),l=!1,a=!1;if(i!==null){let f=t.getIndexWithinParent();if(to(r),_(s)){let g=i.__key,h=s.anchor,N=s.focus;l=h.type==="element"&&h.key===g&&h.offset===f+1,a=N.type==="element"&&N.key===g&&N.offset===f+1}}let d=this.getNextSibling(),u=this.getParentOrThrow().getWritable(),m=r.__key,c=n.__next;if(d===null)u.__last=m;else{let f=d.getWritable();f.__prev=m}if(u.__size++,n.__next=m,r.__next=c,r.__prev=n.__key,r.__parent=n.__parent,e&&_(s)){let f=this.getIndexWithinParent();Un(s,u,f+1);let g=u.__key;l&&s.anchor.set(g,f+2,"element"),a&&s.focus.set(g,f+2,"element")}return t}insertBefore(t,e=!0){ue(),$i(this,t);let n=this.getWritable(),r=t.getWritable(),i=r.__key;to(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 u=C();if(e&&_(u)){let m=this.getParentOrThrow();Un(u,m,d)}return t}isParentRequired(){return!1}createParentElementNode(){return I()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(t,e){ue();let n=this.getPreviousSibling(),r=this.getParentOrThrow();if(n===null)return r.select(0,0);if(E(n))return n.select();if(!L(n)){let i=n.getIndexWithinParent()+1;return r.select(i,i)}return n.select(t,e)}selectNext(t,e){ue();let n=this.getNextSibling(),r=this.getParentOrThrow();if(n===null)return r.select();if(E(n))return n.select(0,0);if(!L(n)){let i=n.getIndexWithinParent();return r.select(i,i)}return n.select(t,e)}markDirty(){this.getWritable()}insertDOMIntoParent(t,e){return!1}};p(Nt,"importDOM");function XN(o,t){let e=Q()._nodes.get(o);e===void 0&&T(!1,"Create node: Attempted to create node %s that was not configured to be used on the editor.",t.name);let n=e.klass;n!==t&&T(!1,"Create node: Type %s in node %s does not match registered node %s with the same type",o,t.name,n.name)}function Hu(o,t,e){let n=e||t.getParentOrThrow().getLastChild(),r=t,i=[t];for(;r!==n;)r.getNextSibling()||T(!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 Go=class o extends Nt{static getType(){return"linebreak"}static clone(t){return new o(t.__key)}constructor(t){super(t)}getTextContent(){return` +`}createDOM(){return document.createElement("br")}updateDOM(){return!1}static importDOM(){return{br:t=>GN(t)||JN(t)?null:{conversion:jN,priority:0}}}static importJSON(t){return xt()}exportJSON(){return{type:"linebreak",version:1}}};function jN(o){return{node:xt()}}function xt(){return re(new Go)}function Pe(o){return o instanceof Go}function GN(o){let t=o.parentElement;if(t!==null&&So(t)){let e=t.firstChild;if(e===o||e.nextSibling===o&&qi(e)){let n=t.lastChild;if(n===o||n.previousSibling===o&&qi(n))return!0}}return!1}function JN(o){let t=o.parentElement;if(t!==null&&So(t)){let e=t.firstChild;if(e===o||e.nextSibling===o&&qi(e))return!1;let n=t.lastChild;if(n===o||n.previousSibling===o&&qi(n))return!0}return!1}function qi(o){return o.nodeType===Ve&&/^( |\t|\r?\n)+$/.test(o.textContent||"")}function da(o,t){return t&yr?"code":t&Mr?"mark":t&Sr?"sub":t&Lr?"sup":null}function ca(o,t){return t&br?"strong":t&_r?"em":"span"}function zu(o,t,e,n,r){let i=n.classList,s=yo(r,"base");s!==void 0&&i.add(...s),s=yo(r,"underlineStrikethrough");let l=!1,a=t&wn&&t&Mn,d=e&wn&&e&Mn;s!==void 0&&(d?(l=!0,a||i.add(...s)):a&&i.remove(...s));for(let u in $e){let c=$e[u];if(s=yo(r,u),s!==void 0)if(e&c){if(l&&(u==="underline"||u==="strikethrough")){t&c&&i.remove(...s);continue}((t&c)===0||a&&u==="underline"||u==="strikethrough")&&i.add(...s)}else t&c&&i.remove(...s)}}function QN(o,t){let e=o.length,n=t.length,r=0,i=0;for(;r({conversion:rx,priority:0}),b:()=>({conversion:tx,priority:0}),code:()=>({conversion:Mo,priority:0}),em:()=>({conversion:Mo,priority:0}),i:()=>({conversion:Mo,priority:0}),s:()=>({conversion:Mo,priority:0}),span:()=>({conversion:ex,priority:0}),strong:()=>({conversion:Mo,priority:0}),sub:()=>({conversion:Mo,priority:0}),sup:()=>({conversion:Mo,priority:0}),u:()=>({conversion:Mo,priority:0})}}static importJSON(e){let n=z(e.text);return n.setFormat(e.format),n.setDetail(e.detail),n.setMode(e.mode),n.setStyle(e.style),n}exportDOM(e){let{element:n}=super.exportDOM(e),r=(n?.nodeName||"").toLowerCase();T(n!==null&&he(n),"Expected TextNode createDOM to always return a HTMLElement");let i=this.getTextContent();/^\s|\s$/.test(i)&&(n.style.whiteSpace="pre-wrap");for(let s of Array.from(n.classList.values()))s.startsWith("editor-theme-")&&n.classList.remove(s);return n.classList.length===0&&n.removeAttribute("class"),n.nodeName==="SPAN"&&!n.getAttribute("style")&&(n=document.createTextNode(i)),this.hasFormat("bold")&&r!=="strong"&&(n=Yi(n,"strong")),this.hasFormat("italic")&&(n=Yi(n,"em")),this.hasFormat("strikethrough")&&(n=Yi(n,"s")),this.hasFormat("underline")&&(n=Yi(n,"u")),{element:n}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),type:"text",version:1}}selectionTransform(e,n){}setFormat(e){let n=this.getWritable();return n.__format=typeof e=="string"?$e[e]:e,n}setDetail(e){let n=this.getWritable();return n.__detail=typeof e=="string"?hc[e]:e,n}setStyle(e){let n=this.getWritable();return n.__style=e,n}toggleFormat(e){let n=this.getFormat(),r=Dr(n,e,null);return this.setFormat(r)}toggleDirectionless(){let e=this.getWritable();return e.__detail^=Li,e}toggleUnmergeable(){let e=this.getWritable();return e.__detail^=vn,e}setMode(e){let n=Nc[e];if(this.__mode===n)return this;let r=this.getWritable();return r.__mode=n,r}setTextContent(e){if(this.__text===e)return this;let n=this.getWritable();return n.__text=e,n}select(e,n){ue();let r=e,i=n,s=C(),l=this.getTextContent(),a=this.__key;if(typeof l=="string"){let d=l.length;r===void 0&&(r=d),i===void 0&&(i=d)}else r=0,i=0;if(_(s)){let d=nt();(d===s.anchor.key||d===s.focus.key)&&le(a),s.setTextNodeRange(this,r,this,i)}else return Zi(a,r,a,i,"text","text");return s}selectStart(){return this.select(0,0)}selectEnd(){let e=this.getTextContentSize();return this.select(e,e)}spliceText(e,n,r,i){let s=this.getWritable(),l=s.__text,a=r.length,d=e;d<0&&(d=a+d,d<0&&(d=0));let u=C();if(i&&_(u)){let c=e+a;u.setTextNodeRange(s,c,s,c)}let m=l.slice(0,d)+r+l.slice(d+n);return s.__text=m,s}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...e){ue();let n=this.getLatest(),r=n.getTextContent(),i=n.__key,s=nt(),l=new Set(e),a=[],d=r.length,u="";for(let R=0;RM&&se.offset<=Z&&(se.key=k,se.offset-=M,S.dirty=!0),We.key===i&&We.type==="text"&&We.offset>M&&We.offset<=Z&&(We.key=k,We.offset-=M,S.dirty=!0)}s===i&&le(k),M=Z,v.push(B)}if(f!==null){Dc(this);let R=f.getWritable(),A=this.getIndexWithinParent();x?(R.splice(A,0,v),this.remove()):R.splice(A,1,v),_(S)&&Un(S,f,A,m-1)}return v}mergeWithSibling(e){let n=e===this.getPreviousSibling();!n&&e!==this.getNextSibling()&&T(!1,"mergeWithSibling: sibling must be a previous or next sibling");let r=this.__key,i=e.__key,s=this.__text,l=s.length;nt()===i&&le(r);let d=C();if(_(d)){let f=d.anchor,g=d.focus;f!==null&&f.key===i&&(ua(f,n,r,e,l),d.dirty=!0),g!==null&&g.key===i&&(ua(g,n,r,e,l),d.dirty=!0)}let u=e.__text,m=n?u+s:s+u;this.setTextContent(m);let c=this.getWritable();return e.remove(),c}isTextEntity(){return!1}};function ex(o){let e=o.style;return{forChild:fa(e),node:null}}function tx(o){let t=o,e=t.style.fontWeight==="normal";return{forChild:fa(t.style,e?void 0:"bold"),node:null}}var Ku=new WeakMap;function ox(o){return o.nodeName==="PRE"||o.nodeType===_o&&o.style!==void 0&&o.style.whiteSpace!==void 0&&o.style.whiteSpace.startsWith("pre")}function nx(o){let t,e=o.parentNode,n=[o];for(;e!==null&&(t=Ku.get(e))===void 0&&!ox(e);)n.push(e),e=e.parentNode;let r=t===void 0?e:t;for(let i=0;i0){/[ \t\n]$/.test(s)&&(n=n.slice(1)),i=!1;break}}i&&(n=n.slice(1))}if(n[n.length-1]===" "){let r=t,i=!0;for(;r!==null&&(r=Ku(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 Ku(o,t){let e=o;for(;;){let n;for(;(n=t?e.nextSibling:e.previousSibling)===null;){let i=e.parentElement;if(i===null)return null;e=i}if(e=n,e.nodeType===_o){let i=e.style.display;if(i===""&&!Vo(e)||i!==""&&!i.startsWith("inline"))return null}let r=e;for(;(r=t?e.firstChild:e.lastChild)!==null;)e=r;if(e.nodeType===Ve)return e;if(e.nodeName==="BR")return null}}var ix={code:"code",em:"italic",i:"italic",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function Mo(o){let t=ix[o.nodeName.toLowerCase()];return t==="code"&&o.closest("pre")?{node:null}:t===void 0?{node:null}:{forChild:ua(o.style,t),node:null}}function z(o=""){return re(new st(o))}function L(o){return o instanceof st}function ua(o,t){let e=o.fontWeight,n=o.textDecoration.split(" "),r=e==="700"||e==="bold",i=n.includes("line-through"),s=o.fontStyle==="italic",l=n.includes("underline"),a=o.verticalAlign,d=o.color,u=o.backgroundColor;return m=>{if(!L(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};`),u&&u!=="transparent"&&(c+=`background-color: ${u};`),c&&m.setStyle(c),t&&!m.hasFormat(t)&&m.toggleFormat(t),m}}var Jo=class o extends st{static getType(){return"tab"}static clone(t){return new o(t.__key)}afterCloneFrom(t){super.afterCloneFrom(t),this.__text=t.__text}constructor(t){super(" ",t),this.__detail=vn}static importDOM(){return null}static importJSON(t){let e=kt();return e.setFormat(t.format),e.setStyle(t.style),e}exportJSON(){return{...super.exportJSON(),type:"tab",version:1}}setTextContent(t){T(!1,"TabNode does not support setTextContent")}setDetail(t){T(!1,"TabNode does not support setDetail")}setMode(t){T(!1,"TabNode does not support setMode")}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}};function kt(){return re(new Jo)}function fa(o){return o instanceof Jo}function Et(...o){return()=>{for(let t=o.length-1;t>=0;t--)o[t]();o.length=0}}var Wn=new Map;function ma(o){let t={},e=o.split(";");for(let n of e)if(n!==""){let[r,i]=n.split(/:([^]+)/);r&&i&&(t[r.trim()]=i.trim())}return t}function qn(o){let t=Wn.get(o);return t===void 0&&(t=ma(o),Wn.set(o,t)),__DEV__&&Object.freeze(t),t}function Wu(o){let t="";for(let e in o)e&&(t+=`${e}: ${o[e]};`);return t}function zr(o,t){let e=o.getStartEndPoints();if(t.isSelected(o)&&!t.isSegmented()&&!t.isToken()&&e!==null){let[n,r]=e,i=o.isBackward(),s=n.getNode(),l=r.getNode(),a=t.is(s),d=t.is(l);if(a||d){let[u,m]=Wr(o),c=s.is(l),f=t.is(i?l:s),g=t.is(i?s:l),h=0,N;if(c)h=u>m?m:u,N=u>m?u:m;else if(f)h=i?m:u,N=void 0;else if(g){let b=i?u:m;h=0,N=b}return t.__text=t.__text.slice(h,N),t}}return t}function pa(o){let t=o.getStyle(),e=ma(t);Wn.set(t,e)}function Yn(o,t){let e=qn("getStyle"in o?o.getStyle():o.style),n=Object.entries(t).reduce((i,[s,l])=>(typeof l=="function"?i[s]=l(e[s],o):l===null?delete i[s]:i[s]=l,i),{...e}),r=Wu(n);o.setStyle(r),Wn.set(r,n)}function ga(o,t){let e=o.getNodes(),n=e.length,r=o.getStartEndPoints();if(r===null)return;let[i,s]=r,l=n-1,a=e[0],d=e[l];if(o.isCollapsed()&&_(o)){Yn(o,t);return}let m=a.getTextContent().length,c=s.offset,f=i.offset,g=i.isBefore(s),h=g?f:c,N=g?c:f,b=g?i.type:s.type,x=g?s.type:i.type,S=g?s.key:i.key;if(L(a)&&h===m){let v=a.getNextSibling();L(v)&&(f=0,h=0,a=v)}if(e.length===1){if(L(a)&&a.canHaveFormat()){if(h=b==="element"?0:f>c?c:f,N=x==="element"?m:f>c?f:c,h===N)return;if(Xe(a)||h===0&&N===m)Yn(a,t),a.select(h,N);else{let v=a.splitText(h,N),M=h===0?v[0]:v[1];Yn(M,t),M.select(0,N-h)}}}else{if(L(a)&&h0&&o.classList.add(...e)}function Gi(o,...t){let e=Rt(...t);e.length>0&&o.classList.remove(...e)}function Xu(o,t){let e=o;for(;e!=null;){if(e instanceof t)return e;e=e.getParent()}return null}function ju(o){let t=U(o,e=>E(e)&&!e.isInline());return E(t)||T(!1,"Expected node %s to have closest block element node.",o.__key),t}var U=(o,t)=>{let e=o;for(;e!==F()&&e!=null;){if(t(e))return e;e=e.getParent()}return null};function Tt(o,t){return o!==null?Object.getPrototypeOf(o).constructor.name===t.name:!1}function Ji(o,t){let e=t.body?t.body.childNodes:[],n=[],r=[];for(let i=0;i"u"||typeof window>"u"&&typeof global.window>"u")throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");let e=document.createElement("div"),r=F().getChildren();for(let s=0;s{let g=new wo;return e.push(g),g}):c=Gu(o,c,I)),l==null?c.length>0?s=s.concat(c):So(o)&&mx(o)&&(s=s.concat(xt())):E(l)&&l.append(...c),s}function Gu(o,t,e){let n=[],r=[];for(let i=0;i{if(L(t)){let e=I();return e.append(t),e}return t})}function xa(o,t){let e=es(t);return Ji(o,e)}function en(o,t){return px(xa(o,t))}function $t(o,t){for(let e of o.getParents())if(t(e))return e;return null}function Ea(o,t){t||(t=F());let e=[];for(let n of t.getChildren())o(n)&&e.push(n),E(n)&&e.push(...Ea(o,n));return e}function nf(o,t,e){let n=F().getChildren();for(let r of n){let i=o.getElementByKey(r.__key);if(!i)continue;let s=i.getBoundingClientRect();if(e<=s.bottom)return r}return null}function bt(o){let t=e=>(E(e)||H(e))&&!e.isInline()&&!ne(e);return t(o)?o:U(o,t)}function rf(o){let t=[],e=i=>{for(let s of i.getChildren())t.push(s.getKey()),E(s)&&e(s)},n=F();e(n);let r=Array.from(o);return r.sort((i,s)=>{let l=t.indexOf(i.getKey()),a=t.indexOf(s.getKey());return l-a}),r}function qr(o,t){let e=bt(o)||o,n=t?e.getNextSibling():e.getPreviousSibling();return n||(n=I(),t?e.insertAfter(n):e.insertBefore(n)),t?n.selectStart():n.selectEnd()}function Yr(o){return"__alignment"in o}function sf(o){return"__inset"in o}var lf=new WeakMap;function ae(o){return lf.get(o)||null}function af(o,t){lf.set(o,t)}function de(o,t){return V(o,t)!==null}function V(o,t){if(!o)return null;for(let e of o.getNodes()){if(t(e))return e;let n=$t(e,t);if(n)return n}return null}function df(o){return V(o,L)}function cf(o,t){if(!o)return!1;let e=o.getNodes();for(let n of e)if(L(n)&&n.hasFormat(t))return!0;return!!(e.length===1&&Ge(e[0])&&e[0].hasTextFormat(t))}function Vn(o,t){let e=C(),n=e?ju(e.getNodes()[0]):null;e&&o(n)?Vi(e,I):Vi(e,t)}function tn(o,t=!0){Ta([o],t)}function Ta(o,t=!0){let e=C()?.getNodes()||[],n=e.length>0?bt(e[0]):null;if(n)if(t)for(let r=o.length-1;r>=0;r--)n.insertAfter(o[r]);else for(let r of o)n.insertBefore(r);else F().append(...o)}function Be(o){let t=nn();t.add(o.getKey()),Y(t)}function uf(o){for(let t of o){if(L(t))return t;if(E(t)){let e=t.getChildren(),n=uf(e);if(n!==null)return n}}return null}function ff(o){let t=[...o].reverse();for(let e of t){if(L(e))return e;if(E(e)){let n=[...e.getChildren()].reverse(),r=ff(n);if(r!==null)return r}}return null}function mf(o){if(o.length===0)return;let t=on(),e=uf(o),n=ff(o);e&&n&&(t.setTextNodeRange(e,0,n,n.getTextContentSize()||0),Y(t))}function pf(o){let t=ae(o);t&&window.requestAnimationFrame(()=>{o.update(()=>{Y(t.clone())})})}function ts(o,t){if(!o)return!1;let e=t.getKey();for(let n of o.getNodes())if(n.getKey()===e)return!0;return!1}function Zr(o,t){let e=[...o?.getNodes()||[],...Pt(o)];for(let n of e)if(Yr(n)&&n.getAlignment()===t)return!0;return!1}function Ca(o,t){let e=[...o?.getNodes()||[],...Pt(o)];for(let n of e)if(It(n)&&n.getDirection()===t)return!0;return!1}function Pt(o){if(!o)return[];let t=new Map;for(let e of o.getNodes()){let n=bt(e);E(n)&&t.set(n.getKey(),n)}return Array.from(t.values())}var ya=class{constructor(t,e,n){p(this,"key");p(this,"offset");p(this,"type");p(this,"_selection");this._selection=null,this.key=t,this.offset=e,this.type=n}is(t){return this.key===t.key&&this.offset===t.offset&&this.type===t.type}isBefore(t){let e=this.getNode(),n=t.getNode(),r=this.offset,i=t.offset;if(E(e)){let s=e.getDescendantByIndex(r);e=s??e}if(E(n)){let s=n.getDescendantByIndex(i);n=s??n}return e===n?ri&&(n=i)}else if(!E(t)){let i=t.getNextSibling();if(L(i))e=i.__key,n=0,r="text";else{let s=t.getParent();s&&(e=s.__key,n=t.getIndexWithinParent()+1)}}o.set(e,n,r)}function la(o,t){if(E(t)){let e=t.getLastDescendant();E(e)||L(e)?ba(o,e):ba(o,t)}else ba(o,t)}function gx(o,t,e,n){let r=o.getNode(),i=r.getChildAtIndex(o.offset),s=z(),l=ne(r)?I().append(s):s;s.setFormat(e),s.setStyle(n),i===null?r.append(l):i.insertBefore(l),o.is(t)&&t.set(s.__key,0,"text"),o.set(s.__key,0,"text")}function vo(o,t,e,n){o.key=t,o.offset=e,o.type=n}var os=class o{constructor(t){p(this,"_nodes");p(this,"_cachedNodes");p(this,"dirty");this._cachedNodes=null,this._nodes=t,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){if(!Oe(t))return!1;let e=this._nodes,n=t._nodes;return e.size===n.size&&Array.from(e).every(r=>n.has(r))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(t){this.dirty=!0,this._nodes.add(t),this._cachedNodes=null}delete(t){this.dirty=!0,this._nodes.delete(t),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(t){return this._nodes.has(t)}clone(){return new o(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(t){}insertText(){}insertNodes(t){let e=this.getNodes(),n=e.length,r=e[n-1],i;if(L(r))i=r.select();else{let s=r.getIndexWithinParent()+1;i=r.getParentOrThrow().select(s,s)}i.insertNodes(t);for(let s=0;s0&&!l.shouldSelectDirectly()?m=[]:m=[l]:m=l.getNodesBetween(a),pt()||(this._cachedNodes=m),m}setTextNodeRange(t,e,n,r){vo(this.anchor,t.__key,e,"text"),vo(this.focus,n.__key,r,"text"),this._cachedNodes=null,this.dirty=!0}getTextContent(){let t=this.getNodes();if(t.length===0)return"";let e=t[0],n=t[t.length-1],r=this.anchor,i=this.focus,s=r.isBefore(i),[l,a]=Wr(this),d="",u=!0;for(let m=0;m0){/[ \t\n]$/.test(s)&&(n=n.slice(1)),i=!1;break}}i&&(n=n.slice(1))}if(n[n.length-1]===" "){let r=t,i=!0;for(;r!==null&&(r=Uu(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 Uu(o,t){let e=o;for(;;){let n;for(;(n=t?e.nextSibling:e.previousSibling)===null;){let i=e.parentElement;if(i===null)return null;e=i}if(e=n,e.nodeType===_o){let i=e.style.display;if(i===""&&!Vo(e)||i!==""&&!i.startsWith("inline"))return null}let r=e;for(;(r=t?e.firstChild:e.lastChild)!==null;)e=r;if(e.nodeType===Ve)return e;if(e.nodeName==="BR")return null}}var ix={code:"code",em:"italic",i:"italic",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function Mo(o){let t=ix[o.nodeName.toLowerCase()];return t==="code"&&o.closest("pre")?{node:null}:t===void 0?{node:null}:{forChild:fa(o.style,t),node:null}}function z(o=""){return re(new st(o))}function L(o){return o instanceof st}function fa(o,t){let e=o.fontWeight,n=o.textDecoration.split(" "),r=e==="700"||e==="bold",i=n.includes("line-through"),s=o.fontStyle==="italic",l=n.includes("underline"),a=o.verticalAlign,d=o.color,u=o.backgroundColor;return m=>{if(!L(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};`),u&&u!=="transparent"&&(c+=`background-color: ${u};`),c&&m.setStyle(c),t&&!m.hasFormat(t)&&m.toggleFormat(t),m}}var Jo=class o extends st{static getType(){return"tab"}static clone(t){return new o(t.__key)}afterCloneFrom(t){super.afterCloneFrom(t),this.__text=t.__text}constructor(t){super(" ",t),this.__detail=vn}static importDOM(){return null}static importJSON(t){let e=kt();return e.setFormat(t.format),e.setStyle(t.style),e}exportJSON(){return{...super.exportJSON(),type:"tab",version:1}}setTextContent(t){T(!1,"TabNode does not support setTextContent")}setDetail(t){T(!1,"TabNode does not support setDetail")}setMode(t){T(!1,"TabNode does not support setMode")}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}};function kt(){return re(new Jo)}function ma(o){return o instanceof Jo}function Et(...o){return()=>{for(let t=o.length-1;t>=0;t--)o[t]();o.length=0}}var Wn=new Map;function pa(o){let t={},e=o.split(";");for(let n of e)if(n!==""){let[r,i]=n.split(/:([^]+)/);r&&i&&(t[r.trim()]=i.trim())}return t}function qn(o){let t=Wn.get(o);return t===void 0&&(t=pa(o),Wn.set(o,t)),__DEV__&&Object.freeze(t),t}function qu(o){let t="";for(let e in o)e&&(t+=`${e}: ${o[e]};`);return t}function zr(o,t){let e=o.getStartEndPoints();if(t.isSelected(o)&&!t.isSegmented()&&!t.isToken()&&e!==null){let[n,r]=e,i=o.isBackward(),s=n.getNode(),l=r.getNode(),a=t.is(s),d=t.is(l);if(a||d){let[u,m]=Wr(o),c=s.is(l),f=t.is(i?l:s),g=t.is(i?s:l),h=0,N;if(c)h=u>m?m:u,N=u>m?u:m;else if(f)h=i?m:u,N=void 0;else if(g){let b=i?u:m;h=0,N=b}return t.__text=t.__text.slice(h,N),t}}return t}function ga(o){let t=o.getStyle(),e=pa(t);Wn.set(t,e)}function Yn(o,t){let e=qn("getStyle"in o?o.getStyle():o.style),n=Object.entries(t).reduce((i,[s,l])=>(typeof l=="function"?i[s]=l(e[s],o):l===null?delete i[s]:i[s]=l,i),{...e}),r=qu(n);o.setStyle(r),Wn.set(r,n)}function ha(o,t){let e=o.getNodes(),n=e.length,r=o.getStartEndPoints();if(r===null)return;let[i,s]=r,l=n-1,a=e[0],d=e[l];if(o.isCollapsed()&&_(o)){Yn(o,t);return}let m=a.getTextContent().length,c=s.offset,f=i.offset,g=i.isBefore(s),h=g?f:c,N=g?c:f,b=g?i.type:s.type,x=g?s.type:i.type,S=g?s.key:i.key;if(L(a)&&h===m){let v=a.getNextSibling();L(v)&&(f=0,h=0,a=v)}if(e.length===1){if(L(a)&&a.canHaveFormat()){if(h=b==="element"?0:f>c?c:f,N=x==="element"?m:f>c?f:c,h===N)return;if(Xe(a)||h===0&&N===m)Yn(a,t),a.select(h,N);else{let v=a.splitText(h,N),M=h===0?v[0]:v[1];Yn(M,t),M.select(0,N-h)}}}else{if(L(a)&&h0&&o.classList.add(...e)}function Gi(o,...t){let e=Rt(...t);e.length>0&&o.classList.remove(...e)}function ju(o,t){let e=o;for(;e!=null;){if(e instanceof t)return e;e=e.getParent()}return null}function Gu(o){let t=U(o,e=>E(e)&&!e.isInline());return E(t)||T(!1,"Expected node %s to have closest block element node.",o.__key),t}var U=(o,t)=>{let e=o;for(;e!==F()&&e!=null;){if(t(e))return e;e=e.getParent()}return null};function Tt(o,t){return o!==null?Object.getPrototypeOf(o).constructor.name===t.name:!1}function Ji(o,t){let e=t.body?t.body.childNodes:[],n=[],r=[];for(let i=0;i"u"||typeof window>"u"&&typeof global.window>"u")throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");let e=document.createElement("div"),r=F().getChildren();for(let s=0;s{let g=new wo;return e.push(g),g}):c=Ju(o,c,I)),l==null?c.length>0?s=s.concat(c):So(o)&&mx(o)&&(s=s.concat(xt())):E(l)&&l.append(...c),s}function Ju(o,t,e){let n=[],r=[];for(let i=0;i{if(L(t)){let e=I();return e.append(t),e}return t})}function Ea(o,t){let e=es(t);return Ji(o,e)}function en(o,t){return px(Ea(o,t))}function $t(o,t){for(let e of o.getParents())if(t(e))return e;return null}function Ta(o,t){t||(t=F());let e=[];for(let n of t.getChildren())o(n)&&e.push(n),E(n)&&e.push(...Ta(o,n));return e}function rf(o,t,e){let n=F().getChildren();for(let r of n){let i=o.getElementByKey(r.__key);if(!i)continue;let s=i.getBoundingClientRect();if(e<=s.bottom)return r}return null}function bt(o){let t=e=>(E(e)||H(e))&&!e.isInline()&&!ne(e);return t(o)?o:U(o,t)}function sf(o){let t=[],e=i=>{for(let s of i.getChildren())t.push(s.getKey()),E(s)&&e(s)},n=F();e(n);let r=Array.from(o);return r.sort((i,s)=>{let l=t.indexOf(i.getKey()),a=t.indexOf(s.getKey());return l-a}),r}function qr(o,t){let e=bt(o)||o,n=t?e.getNextSibling():e.getPreviousSibling();return n||(n=I(),t?e.insertAfter(n):e.insertBefore(n)),t?n.selectStart():n.selectEnd()}function Yr(o){return"__alignment"in o}function lf(o){return"__inset"in o}var af=new WeakMap;function ae(o){return af.get(o)||null}function df(o,t){af.set(o,t)}function de(o,t){return V(o,t)!==null}function V(o,t){if(!o)return null;for(let e of o.getNodes()){if(t(e))return e;let n=$t(e,t);if(n)return n}return null}function cf(o){return V(o,L)}function uf(o,t){if(!o)return!1;let e=o.getNodes();for(let n of e)if(L(n)&&n.hasFormat(t))return!0;return!!(e.length===1&&Ge(e[0])&&e[0].hasTextFormat(t))}function Vn(o,t){let e=C(),n=e?Gu(e.getNodes()[0]):null;e&&o(n)?Vi(e,I):Vi(e,t)}function tn(o,t=!0){Ca([o],t)}function Ca(o,t=!0){let e=C()?.getNodes()||[],n=e.length>0?bt(e[0]):null;if(n)if(t)for(let r=o.length-1;r>=0;r--)n.insertAfter(o[r]);else for(let r of o)n.insertBefore(r);else F().append(...o)}function Be(o){let t=nn();t.add(o.getKey()),Y(t)}function ff(o){for(let t of o){if(L(t))return t;if(E(t)){let e=t.getChildren(),n=ff(e);if(n!==null)return n}}return null}function mf(o){let t=[...o].reverse();for(let e of t){if(L(e))return e;if(E(e)){let n=[...e.getChildren()].reverse(),r=mf(n);if(r!==null)return r}}return null}function pf(o){if(o.length===0)return;let t=on(),e=ff(o),n=mf(o);e&&n&&(t.setTextNodeRange(e,0,n,n.getTextContentSize()||0),Y(t))}function gf(o){let t=ae(o);t&&window.requestAnimationFrame(()=>{o.update(()=>{Y(t.clone())})})}function ts(o,t){if(!o)return!1;let e=t.getKey();for(let n of o.getNodes())if(n.getKey()===e)return!0;return!1}function Zr(o,t){let e=[...o?.getNodes()||[],...Pt(o)];for(let n of e)if(Yr(n)&&n.getAlignment()===t)return!0;return!1}function ba(o,t){let e=[...o?.getNodes()||[],...Pt(o)];for(let n of e)if(It(n)&&n.getDirection()===t)return!0;return!1}function Pt(o){if(!o)return[];let t=new Map;for(let e of o.getNodes()){let n=bt(e);E(n)&&t.set(n.getKey(),n)}return Array.from(t.values())}var Sa=class{constructor(t,e,n){p(this,"key");p(this,"offset");p(this,"type");p(this,"_selection");this._selection=null,this.key=t,this.offset=e,this.type=n}is(t){return this.key===t.key&&this.offset===t.offset&&this.type===t.type}isBefore(t){let e=this.getNode(),n=t.getNode(),r=this.offset,i=t.offset;if(E(e)){let s=e.getDescendantByIndex(r);e=s??e}if(E(n)){let s=n.getDescendantByIndex(i);n=s??n}return e===n?ri&&(n=i)}else if(!E(t)){let i=t.getNextSibling();if(L(i))e=i.__key,n=0,r="text";else{let s=t.getParent();s&&(e=s.__key,n=t.getIndexWithinParent()+1)}}o.set(e,n,r)}function aa(o,t){if(E(t)){let e=t.getLastDescendant();E(e)||L(e)?_a(o,e):_a(o,t)}else _a(o,t)}function gx(o,t,e,n){let r=o.getNode(),i=r.getChildAtIndex(o.offset),s=z(),l=ne(r)?I().append(s):s;s.setFormat(e),s.setStyle(n),i===null?r.append(l):i.insertBefore(l),o.is(t)&&t.set(s.__key,0,"text"),o.set(s.__key,0,"text")}function vo(o,t,e,n){o.key=t,o.offset=e,o.type=n}var os=class o{constructor(t){p(this,"_nodes");p(this,"_cachedNodes");p(this,"dirty");this._cachedNodes=null,this._nodes=t,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){if(!Oe(t))return!1;let e=this._nodes,n=t._nodes;return e.size===n.size&&Array.from(e).every(r=>n.has(r))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(t){this.dirty=!0,this._nodes.add(t),this._cachedNodes=null}delete(t){this.dirty=!0,this._nodes.delete(t),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(t){return this._nodes.has(t)}clone(){return new o(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(t){}insertText(){}insertNodes(t){let e=this.getNodes(),n=e.length,r=e[n-1],i;if(L(r))i=r.select();else{let s=r.getIndexWithinParent()+1;i=r.getParentOrThrow().select(s,s)}i.insertNodes(t);for(let s=0;s0&&!l.shouldSelectDirectly()?m=[]:m=[l]:m=l.getNodesBetween(a),pt()||(this._cachedNodes=m),m}setTextNodeRange(t,e,n,r){vo(this.anchor,t.__key,e,"text"),vo(this.focus,n.__key,r,"text"),this._cachedNodes=null,this.dirty=!0}getTextContent(){let t=this.getNodes();if(t.length===0)return"";let e=t[0],n=t[t.length-1],r=this.anchor,i=this.focus,s=r.isBefore(i),[l,a]=Wr(this),d="",u=!0;for(let m=0;m=0;k--){let Z=R[k];if(Z.is(c)||E(Z)&&Z.isParentOf(c))break;Z.isAttached()&&(!A.has(Z)||Z.is(M)?P||B.insertAfter(Z,!1):Z.remove())}if(!P){let k=v,Z=null;for(;k!==null;){let se=k.getChildren(),We=se.length;(We===0||se[We-1].is(Z))&&(x.delete(k.__key),Z=k),k=k.getParent()}}if(!c.isToken())c=c.spliceText(a,g-a,t,!0),c.getTextContent()===""?c.remove():c.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=t.length);else if(a===g)c.select();else{let k=z(t);k.select(),c.replace(k)}for(let k=1;k0&&(N!==h.getTextContentSize()&&!Xe(h)&&([h]=h.splitText(N)),h.setFormat(b));for(let x=u+1;x(E(N)||H(N))&&!N.isInline();if(!t.some(i)){T(E(n),"Expected 'firstBlock' to be an ElementNode");let N=_a(this);n.splice(N,0,t),r.selectEnd();return}let s=Cx(t),l=s.getLastDescendant(),a=s.getChildren(),d=N=>E(N)&&Xo(N)&&!N.isEmpty()&&E(n)&&(!n.isEmpty()||n.canMergeWhenEmpty()),m=!E(n)||!n.isEmpty()?this.insertParagraph():null,c=a[a.length-1],f=a[0];d(f)&&(T(E(n),"Expected 'firstBlock' to be an ElementNode"),n.append(...f.getChildren()),f=a[1]),f&&Bu(n,f);let g=Bi(l,Xo);m&&E(g)&&(m.canMergeWhenEmpty()||Xo(c))&&(g.append(...m.getChildren()),m.remove()),E(n)&&n.isEmpty()&&n.remove(),l.selectEnd();let h=E(n)?n.getLastChild():null;Pe(h)&&g!==n&&h.remove()}insertParagraph(){if(this.anchor.key==="root"){let s=I();return F().splice(this.anchor.offset,0,[s]),s.select(),s}let t=_a(this),e=Bi(this.anchor.getNode(),Xo);T(E(e),"Expected ancestor to be an ElementNode");let n=e.getChildAtIndex(t),r=n?[n,...n.getNextSiblings()]:[],i=e.insertNewAfter(this,!1);return i?(i.append(...r),i.selectStart(),i):null}insertLineBreak(t){let e=xt();if(this.insertNodes([e]),t){let n=e.getParentOrThrow(),r=e.getIndexWithinParent();n.select(r,r)}}extract(){let t=this.getNodes(),e=t.length,n=e-1,r=this.anchor,i=this.focus,s=t[0],l=t[n],[a,d]=Wr(this);if(e===0)return[];if(e===1){if(L(s)&&!this.isCollapsed()){let m=a>d?d:a,c=a>d?a:d,f=s.splitText(m,c),g=m===0?f[0]:f[1];return g!=null?[g]:[]}return[s]}let u=r.isBefore(i);if(L(s)){let m=u?a:d;m===s.getTextContentSize()?t.shift():m!==0&&([,s]=s.splitText(m),t[0]=s)}if(L(l)){let c=l.getTextContent().length,f=u?d:a;f===0?t.pop():f!==c&&([l]=l.splitText(f),t[n]=l)}return t}modify(t,e,n){let r=this.focus,i=this.anchor,s=t==="move",l=oo(r,e);if(H(l)&&!l.isIsolated()){if(s&&l.isKeyboardSelectable()){let f=nn();f.add(l.__key),Y(f);return}let c=e?l.getPreviousSibling():l.getNextSibling();if(L(c)){let f=c.__key,g=e?c.getTextContent().length:0;r.set(f,g,"text"),s&&i.set(f,g,"text");return}else{let f=l.getParentOrThrow(),g,h;E(c)?(h=c.__key,g=e?c.getChildrenSize():0):(g=l.getIndexWithinParent(),h=f.__key,e||g++),r.set(h,g,"element"),s&&i.set(h,g,"element");return}}let a=Q(),d=ve(a._window);if(!d)return;let u=a._blockCursorElement,m=a._rootElement;if(m!==null&&u!==null&&E(l)&&!l.isInline()&&!l.canBeEmpty()&&Ir(u,a,m),Nx(d,t,e?"backward":"forward",n),d.rangeCount>0){let c=d.getRangeAt(0),f=this.anchor.getNode(),g=ne(f)?f:Wl(f);if(this.applyDOMRange(c),this.dirty=!0,!s){let h=this.getNodes(),N=[],b=!1;for(let x=0;x0)if(e){let x=N[0];E(x)?x.selectStart():x.getParentOrThrow().selectStart()}else{let x=N[N.length-1];E(x)?x.selectEnd():x.getParentOrThrow().selectEnd()}(d.anchorNode!==c.startContainer||d.anchorOffset!==c.startOffset)&&hx(this)}}}forwardDeletion(t,e,n){if(!n&&(t.type==="element"&&E(e)&&t.offset===e.getChildrenSize()||t.type==="text"&&t.offset===e.getTextContentSize())){let r=e.getParent(),i=e.getNextSibling()||(r===null?null:r.getNextSibling());if(E(i)&&i.isShadowRoot())return!0}return!1}deleteCharacter(t){let e=this.isCollapsed();if(this.isCollapsed()){let n=this.anchor,r=n.getNode();if(this.forwardDeletion(n,r,t))return;let i=this.focus,s=oo(i,t);if(H(s)&&!s.isIsolated()){if(s.isKeyboardSelectable()&&E(r)&&r.getChildrenSize()===0){r.remove();let l=nn();l.add(s.__key),Y(l)}else s.remove(),Q().dispatchCommand(_e,void 0);return}else if(!t&&E(s)&&E(r)&&r.isEmpty()){r.remove(),s.selectStart();return}if(this.modify("extend",t,"character"),this.isCollapsed()){if(t&&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)||t&&a!==d||!t&&a!==0){hf(l,t,a);return}}else if(r!==null&&r.isSegmented()){let a=n.offset,d=r.getTextContentSize();if(r.is(l)||t&&a!==0||!t&&a!==d){hf(r,t,a);return}}xx(this,t)}}if(this.removeText(),t&&!e&&this.isCollapsed()&&this.anchor.type==="element"&&this.anchor.offset===0){let n=this.anchor.getNode();n.isEmpty()&&ne(n.getParent())&&n.getIndexWithinParent()===0&&n.collapseAtStart(this)}}deleteLine(t){if(this.isCollapsed()){let e=this.anchor.type==="element";if(e&&this.insertText(" "),this.modify("extend",t,"lineboundary"),(t?this.focus:this.anchor).offset===0&&this.modify("extend",t,"character"),e){let r=t?this.anchor:this.focus;r.set(r.key,r.offset+1,r.type)}}this.removeText()}deleteWord(t){if(this.isCollapsed()){let e=this.anchor,n=e.getNode();if(this.forwardDeletion(e,n,t))return;this.modify("extend",t,"word")}this.removeText()}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return[this.anchor,this.focus]}};function Oe(o){return o instanceof os}function gf(o){let t=o.offset;if(o.type==="text")return t;let e=o.getNode();return t===e.getChildrenSize()?e.getTextContent().length:0}function Wr(o){let t=o.getStartEndPoints();if(t===null)return[0,0];let[e,n]=t;return e.type==="element"&&n.type==="element"&&e.key===n.key&&e.offset===n.offset?[0,0]:[gf(e),gf(n)]}function hx(o){let t=o.focus,e=o.anchor,n=e.key,r=e.offset,i=e.type;vo(e,t.key,t.offset,t.type),vo(t,n,r,i),o._cachedNodes=null}function Nx(o,t,e,n){o.modify(t,e,n)}function xx(o,t){let e=o.anchor,n=o.focus,r=e.getNode(),i=n.getNode();if(r===i&&e.type==="text"&&n.type==="text"){let s=e.offset,l=n.offset,a=se||c){i.splice(u,1),c&&(a=void 0);break}}let d=i.join("").trim();d===""?n.remove():(n.setTextContent(d),n.select(a,a))}function Ex(o,t,e){let n=o.getParent();return e===null||n===null||!n.canBeEmpty()||n!==e.getNode()}function Nf(o,t,e,n){let r=t,i;if(o.nodeType===_o){let s=!1,l=o.childNodes,a=l.length,d=n._blockCursorElement;r===a&&(s=!0,r=a-1);let u=l[r],m=!1;if(u===d)u=l[r+1],m=!0;else if(d!==null){let c=d.parentNode;if(o===c){let f=Array.prototype.indexOf.call(c.children,d);t>f&&r--}}if(i=Zo(u),L(i))r=Hl(i,s);else{let c=Zo(o);if(c===null)return null;if(E(c)){r=Math.min(c.getChildrenSize(),r);let f=c.getChildAtIndex(r);if(E(f)&&Ex(f,r,e)){let g=s?f.getLastDescendant():f.getFirstDescendant();g===null?c=f:(f=g,c=E(f)?f:f.getParentOrThrow()),r=0}L(f)?(i=f,c=null,r=Hl(f,s)):f!==c&&s&&!m&&r++}else{let f=c.getIndexWithinParent();t===0&&H(c)&&Zo(o)===c?r=f:r=f+1,c=c.getParentOrThrow()}if(E(c))return He(c.__key,r,"element")}}else i=Zo(o);return L(i)?He(i.__key,r,"text"):null}function xf(o,t,e){let n=o.offset,r=o.getNode();if(n===0){let i=r.getPreviousSibling(),s=r.getParent();if(!t)E(i)&&!e&&i.isInline()?(o.key=i.__key,o.offset=i.getChildrenSize(),o.type="element"):L(i)&&(o.key=i.__key,o.offset=i.getTextContent().length);else if((e||!t)&&i===null&&E(s)&&s.isInline()){let l=s.getPreviousSibling();L(l)&&(o.key=l.__key,o.offset=l.getTextContent().length)}}else if(n===r.getTextContent().length){let i=r.getNextSibling(),s=r.getParent();if(t&&E(i)&&i.isInline())o.key=i.__key,o.offset=0,o.type="element";else if((e||t)&&i===null&&E(s)&&s.isInline()&&!s.canInsertTextAfter()){let l=s.getNextSibling();L(l)&&(o.key=l.__key,o.offset=0)}}}function Tf(o,t,e){if(o.type==="text"&&t.type==="text"){let n=o.isBefore(t),r=o.is(t);xf(o,n,r),xf(t,!n,r),r&&(t.key=o.key,t.offset=o.offset,t.type=o.type);let i=Q();if(i.isComposing()&&i._compositionKey!==o.key&&_(e)){let s=e.anchor,l=e.focus;vo(o,s.key,s.offset,s.type),vo(t,l.key,l.offset,l.type)}}}function Cf(o,t,e,n,r,i){if(o===null||e===null||!eo(r,o,e))return null;let s=Nf(o,t,_(i)?i.anchor:null,r);if(s===null)return null;let l=Nf(e,n,_(i)?i.focus:null,r);if(l===null)return null;if(s.type==="element"&&l.type==="element"){let a=Zo(o),d=Zo(e);if(H(a)&&H(d))return null}return Tf(s,l,i),[s,l]}function It(o){return E(o)&&!o.isInline()}function Zi(o,t,e,n,r,i){let s=rt(),l=new Do(He(o,t,r),He(e,n,i),0,"");return l.dirty=!0,s._selection=l,l}function on(){let o=He("root",0,"element"),t=He("root",0,"element");return new Do(o,t,0,"")}function nn(){return new os(new Set)}function bf(o){let e=o.getEditorState()._selection,n=ve(o._window);return _(e)||e==null?Ur(e,n,o,null):e.clone()}function Sa(o,t){return Ur(null,o,t,null)}function Ur(o,t,e,n){let r=e._window;if(r===null)return null;let i=n||r.event,s=i?i.type:void 0,l=s==="selectionchange",a=!xc()&&(l||s==="beforeinput"||s==="compositionstart"||s==="compositionend"||s==="click"&&i&&i.detail===3||s==="drop"||s===void 0),d,u,m,c;if(!_(o)||a){if(t===null)return null;if(d=t.anchorNode,u=t.focusNode,m=t.anchorOffset,c=t.focusOffset,l&&_(o)&&!eo(e,d,u))return o.clone()}else return o.clone();let f=Cf(d,m,u,c,e,o);if(f===null)return null;let[g,h]=f;return new Do(g,h,_(o)?o.format:0,_(o)?o.style:"")}function C(){return rt()._selection}function je(){return Q()._editorState._selection}function Un(o,t,e,n=1){let r=o.anchor,i=o.focus,s=r.getNode(),l=i.getNode();if(!t.is(s)&&!t.is(l))return;let a=t.__key;if(o.isCollapsed()){let d=r.offset;if(e<=d&&n>0||e0||e0||e=l,d=a?i.getChildAtIndex(l-1):i.getChildAtIndex(e);if(L(d)){let u=0;a&&(u=d.getTextContentSize()),t.set(d.__key,u,"text"),n.set(d.__key,u,"text")}return}if(E(i)){let l=i.getChildrenSize(),a=e>=l,d=a?i.getChildAtIndex(l-1):i.getChildAtIndex(e);if(L(d)){let u=0;a&&(u=d.getTextContentSize()),t.set(d.__key,u,"text")}}if(E(s)){let l=s.getChildrenSize(),a=r>=l,d=a?s.getChildAtIndex(l-1):s.getChildAtIndex(r);if(L(d)){let u=0;a&&(u=d.getTextContentSize()),n.set(d.__key,u,"text")}}}function _f(o,t){let n=t.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 zn(o,t,e,n,r){let i=null,s=0,l=null;n!==null?(i=n.__key,L(n)?(s=n.getTextContentSize(),l="text"):E(n)&&(s=n.getChildrenSize(),l="element")):r!==null&&(i=r.__key,L(r)?l="text":E(r)&&(l="element")),i!==null&&l!==null?o.set(i,s,l):(s=t.getIndexWithinParent(),s===-1&&(s=e.getChildrenSize()),o.set(e.__key,s,"element"))}function ca(o,t,e,n,r){o.type==="text"?(o.key=e,t||(o.offset+=r)):o.offset>n.getIndexWithinParent()&&(o.offset-=1)}function yf(o,t,e,n,r,i,s){let l=n.anchorNode,a=n.focusNode,d=n.anchorOffset,u=n.focusOffset,m=document.activeElement;if(r.has("collaboration")&&m!==i||m!==null&&In(m))return;if(!_(t)){if(m!==null&&n.isCollapsed&&a instanceof Node){let k=G(a);if(H(k)){n.removeAllRanges(),Be(k);return}}o!==null&&eo(e,l,a)&&n.removeAllRanges();return}let c=t.anchor,f=t.focus,g=c.key,h=f.key,N=Bn(e,g),b=Bn(e,h),x=c.offset,S=f.offset,v=t.format,M=t.style,R=t.isCollapsed(),A=N,P=b,B=!1;if(c.type==="text"){A=Pn(N);let k=c.getNode();B=k.getFormat()!==v||k.getStyle()!==M}else _(o)&&o.anchor.type==="text"&&(B=!0);if(f.type==="text"&&(P=Pn(b)),!(A===null||P===null)&&(R&&(o===null||B||_(o)&&(o.format!==v||o.style!==M))&&Pu(v,M,x,g,performance.now()),!(d===x&&u===S&&l===A&&a===P&&!(n.type==="Range"&&R)&&((m===null||!i.contains(m))&&i.focus({preventScroll:!0}),c.type!=="element")))){try{n.setBaseAndExtent(A,x,P,S)}catch(k){__DEV__&&console.warn(k)}if(!r.has("skip-scroll-into-view")&&t.isCollapsed()&&i!==null&&i===document.activeElement){let k=t instanceof Do&&t.anchor.type==="element"?A.childNodes[x]||null:n.rangeCount>0?n.getRangeAt(0):null;if(k!==null){let Z;if(k instanceof Text){let se=document.createRange();se.selectNode(k),Z=se.getBoundingClientRect()}else k instanceof Range,Z=k.getBoundingClientRect();du(e,Z,i)}}$u()}}function Ce(o){let t=C()||je();t===null&&(t=F().selectEnd()),t.insertNodes(o)}function _a(o){let t=o;o.isCollapsed()||t.removeText();let e=C();_(e)&&(t=e),T(_(t),"Unexpected dirty selection to be null");let n=t.anchor,r=n.getNode(),i=n.offset;for(;!Xo(r);)[r,i]=Tx(r,i);return i}function Tx(o,t){let e=o.getParent();if(!e){let r=I();return F().append(r),r.select(),[F(),0]}if(L(o)){let r=o.splitText(t);if(r.length===0)return[e,o.getIndexWithinParent()];let i=t===0?0:1,s=r[0].getIndexWithinParent()+i;return[e,s]}if(!E(o)||t===0)return[e,o.getIndexWithinParent()];let n=o.getChildAtIndex(t);if(n){let r=new Do(He(o.__key,t,"element"),He(o.__key,t,"element"),0,""),i=o.insertNewAfter(r);i&&i.append(n,...n.getNextSiblings())}return[e,o.getIndexWithinParent()+1]}function Cx(o){let t=I(),e=null;for(let n=0;n99&&T(!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 rt(){return me===null&&T(!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",vf()),me}function Q(){return Ne===null&&T(!1,"Unable to find an active editor. This method can only be used synchronously during the callback of editor.update() or editor.read().%s",vf()),Ne}function vf(){let o=0,t=new Set,e=ro.version;if(typeof window<"u")for(let r of document.querySelectorAll("[contenteditable]")){let i=Yo(r);if($n(i))o++;else if(i){let s=String(i.constructor.version||"<0.17.1");s===e&&(s+=" (separately built, likely a bundler configuration issue)"),t.add(s)}}let n=` Detected on the page: ${o} compatible editor(s) with version ${e}`;return t.size&&(n+=` and incompatible editors with versions ${Array.from(t).join(", ")}`),n}function Df(){return Ne}function pu(){return me}function Lf(o,t,e){let n=t.__type,r=Sc(o,n),i=e.get(n);i===void 0&&(i=Array.from(r.transforms),e.set(n,i));let s=i.length;for(let l=0;l0||u>0;){if(a>0){t._dirtyLeaves=new Set;for(let m of l){let c=r.get(m);L(c)&&c.isAttached()&&c.isSimpleText()&&!c.isUnmergeable()&&$l(c),c!==void 0&&Mf(c,i)&&Lf(t,c,s),e.add(m)}if(l=t._dirtyLeaves,a=l.size,a>0){ns++;continue}}t._dirtyLeaves=new Set,t._dirtyElements=new Map;for(let m of d){let c=m[0],f=m[1];if(c!=="root"&&!f)continue;let g=r.get(c);g!==void 0&&Mf(g,i)&&Lf(t,g,s),n.set(c,f)}l=t._dirtyLeaves,a=l.size,d=t._dirtyElements,u=d.size,ns++}t._dirtyLeaves=e,t._dirtyElements=n}function Ma(o){return wa(o,Q()._nodes)}function wa(o,t){let e=o.type,n=t.get(e);n===void 0&&T(!1,'parseEditorState: type "%s" + not found',e);let r=n.klass;o.type!==r.getType()&&T(!1,"LexicalNode: Node %s does not implement .importJSON().",r.name);let i=r.importJSON(o),s=o.children;if(E(i)&&Array.isArray(s))for(let l=0;l{throw new Error("Cannot call set() on a frozen Lexical node map")},t.clear=()=>{throw new Error("Cannot call clear() on a frozen Lexical node map")},t.delete=()=>{throw new Error("Cannot call delete() on a frozen Lexical node map")}}function Bt(o,t){let e=o._pendingEditorState,n=o._rootElement,r=o._headless||n===null;if(e===null)return;let i=o._editorState,s=i._selection,l=e._selection,a=o._dirtyType!==At,d=me,u=Fe,m=Ne,c=o._updating,f=o._observer,g=null;if(o._pendingEditorState=null,o._editorState=e,!r&&a&&f!==null){Ne=o,me=e,Fe=!1,o._updating=!0;try{let A=o._dirtyType,P=o._dirtyElements,B=o._dirtyLeaves;f.disconnect(),g=bu(i,e,o,A,P,B)}catch(A){if(A instanceof Error&&o._onError(A),!La)Da(o,null,n,e),wi(o),o._dirtyType=Qt,La=!0,Bt(o,i),La=!1;else throw A;return}finally{f.observe(n,Sf),o._updating=c,me=d,Fe=u,Ne=m}}e._readOnly||(e._readOnly=!0,__DEV__&&(Af(e),_(l)&&(Object.freeze(l.anchor),Object.freeze(l.focus)),Object.freeze(l)));let h=o._dirtyLeaves,N=o._dirtyElements,b=o._normalizedNodes,x=o._updateTags,S=o._deferred,v=e._nodeMap.size;a&&(o._dirtyType=At,o._cloneNotNeeded.clear(),o._dirtyLeaves=new Set,o._dirtyElements=new Map,o._normalizedNodes=new Set,o._updateTags=new Set),gu(o,e);let M=r?null:ve(o._window);if(o._editable&&M!==null&&(a||l===null||l.dirty)){Ne=o,me=e;try{if(f!==null&&f.disconnect(),a||l===null||l.dirty){let A=o._blockCursorElement;A!==null&&Ir(A,o,n),yf(s,l,o,M,x,n,v)}fu(o,n,l),f!==null&&f.observe(n,Sf)}finally{Ne=m,me=d}}g!==null&&Sx(o,g,x,h,i),!_(l)&&l!==null&&(s===null||!s.is(l))&&o.dispatchCommand(_e,void 0);let R=o._pendingDecorators;R!==null&&(o._decorators=R,o._pendingDecorators=null,Xn("decorator",o,!0,R)),yx(o,t||i,e),Xn("update",o,!0,{dirtyElements:N,dirtyLeaves:h,editorState:e,normalizedNodes:b,prevEditorState:t||i,tags:x}),Mx(o,S),Lx(o)}function yx(o,t,e){let n=Bl(t),r=Bl(e);n!==r&&Xn("textcontent",o,!0,r)}function Sx(o,t,e,n,r){let i=Array.from(o._listeners.mutation),s=i.length;for(let l=0;l{r=Zl(o,t,e)}),r}let n=Ar(o);for(let r=4;r>=0;r--)for(let i=0;i{Bt(o)}):(d._flushSync=!1,u&&(n.clear(),o._deferred=[],o._pendingEditorState=null))}function Te(o,t,e){o._updating?o._updates.push([t,e]):Rf(o,t,e)}var X=class extends Nt{constructor(e){super(e);p(this,"__first");p(this,"__last");p(this,"__size");p(this,"__style");p(this,"__dir");this.__first=null,this.__last=null,this.__size=0,this.__style="",this.__dir=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__first=e.__first,this.__last=e.__last,this.__size=e.__size,this.__style=e.__style,this.__dir=e.__dir}getStyle(){return this.getLatest().__style}getChildren(){let e=[],n=this.getFirstChild();for(;n!==null;)e.push(n),n=n.getNextSibling();return e}getChildrenKeys(){let e=[],n=this.getFirstChild();for(;n!==null;)e.push(n.__key),n=n.getNextSibling();return e}getChildrenSize(){return this.getLatest().__size}isEmpty(){return this.getChildrenSize()===0}isDirty(){let n=Q()._dirtyElements;return n!==null&&n.has(this.__key)}isLastChild(){let e=this.getLatest(),n=this.getParentOrThrow().getLastChild();return n!==null&&n.is(e)}getAllTextNodes(){let e=[],n=this.getFirstChild();for(;n!==null;){if(L(n)&&e.push(n),E(n)){let r=n.getAllTextNodes();e.push(...r)}n=n.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;E(e);){let n=e.getFirstChild();if(n===null)break;e=n}return e}getFirstSelectableDescendant(){if(this.shouldSelectDirectly())return null;let e=this.getFirstChild();for(;E(e)&&!e.shouldSelectDirectly();){let n=e.getFirstChild();if(n===null)break;e=n}return e}getLastDescendant(){let e=this.getLastChild();for(;E(e);){let n=e.getLastChild();if(n===null)break;e=n}return e}getLastSelectableDescendant(){if(this.shouldSelectDirectly())return null;let e=this.getLastChild();for(;E(e)&&!e.shouldSelectDirectly();){let n=e.getLastChild();if(n===null)break;e=n}return e}getDescendantByIndex(e){let n=this.getChildren(),r=n.length;if(e>=r){let s=n[r-1];return E(s)&&s.getLastDescendant()||s||null}let i=n[e];return E(i)&&i.getFirstDescendant()||i||null}getFirstChild(){let n=this.getLatest().__first;return n===null?null:ee(n)}getFirstChildOrThrow(){let e=this.getFirstChild();return e===null&&T(!1,"Expected node %s to have a first child.",this.__key),e}getLastChild(){let n=this.getLatest().__last;return n===null?null:ee(n)}getLastChildOrThrow(){let e=this.getLastChild();return e===null&&T(!1,"Expected node %s to have a last child.",this.__key),e}getChildAtIndex(e){let n=this.getChildrenSize(),r,i;if(e=e;){if(i===e)return r;r=r.getPreviousSibling(),i--}return null}getTextContent(){let e="",n=this.getChildren(),r=n.length;for(let i=0;ir.remove()),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){let n=this.getWritable();return n.__dir=e,n}setStyle(e){let n=this.getWritable();return n.__style=e||"",this}splice(e,n,r){let i=r.length,s=this.getChildrenSize(),l=this.getWritable(),a=l.__key,d=[],u=[],m=this.getChildAtIndex(e+n),c=null,f=s-n+i;if(e!==0)if(e===s)c=this.getLastChild();else{let h=this.getChildAtIndex(e);h!==null&&(c=h.getPreviousSibling())}if(n>0){let h=c===null?this.getFirstChild():c.getNextSibling();for(let N=0;N({root:Bf(F())}))}};var wo=class extends X{static getType(){return"artificial"}createDOM(t){return document.createElement("div")}};var Hf=["left","right","center","justify"];function Xr(o){let t=o.style.textAlign||"";return Hf.includes(t)?t: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 wx(o){let t=o.style.paddingLeft||"0";return Qo(t)}function jr(o){let t=(o.dir||"").toLowerCase();return t==="rtl"||t==="ltr"?t:null}function at(o,t){o.id&&t.setId(o.id),t.setAlignment(Xr(o)),t.setInset(wx(o)),t.setDirection(jr(o))}function Oo(o,t){return o.__id!==t.__id||o.__alignment!==t.__alignment||o.__inset!==t.__inset||o.__dir!==t.__dir}function Ff(o,t,e){if(o.__id!==t.__id&&e.setAttribute("id",t.__id),o.__alignment!==t.__alignment){for(let n of Hf)e.classList.remove("align-"+n);t.__alignment&&e.classList.add("align-"+t.__alignment)}o.__inset!==t.__inset&&(t.__inset?e.style.paddingLeft=`${t.__inset}px`:e.style.removeProperty("paddingLeft")),o.__dir!==t.__dir&&(t.__dir?e.dir=t.__dir:e.removeAttribute("dir"))}function dt(o,t){t.__id&&o.setAttribute("id",t.__id),t.__alignment&&o.classList.add("align-"+t.__alignment),t.__inset&&(o.style.paddingLeft=`${t.__inset}px`),t.__dir&&(o.dir=t.__dir)}function ct(o,t){t.setId(o.id),t.setAlignment(o.alignment),t.setInset(o.inset),t.setDirection(o.direction)}var Ht=class extends X{constructor(){super(...arguments);p(this,"__id","");p(this,"__alignment","");p(this,"__inset",0)}setId(e){let n=this.getWritable();n.__id=e}getId(){return this.getLatest().__id}setAlignment(e){let n=this.getWritable();n.__alignment=e}getAlignment(){return this.getLatest().__alignment}setInset(e){let n=this.getWritable();n.__inset=e}getInset(){return this.getLatest().__inset}exportJSON(){return{...super.exportJSON(),id:this.__id,alignment:this.__alignment,inset:this.__inset}}};function Ao(o,t){t.__alignment=o.__alignment,t.__inset=o.__inset}var it=class o extends Ht{constructor(e){super(e);p(this,"__textFormat");p(this,"__textStyle");this.__textFormat=0,this.__textStyle=""}static getType(){return"paragraph"}getTextFormat(){return this.getLatest().__textFormat}setTextFormat(e){let n=this.getWritable();return n.__textFormat=e,n}hasTextFormat(e){let n=$e[e];return(this.getTextFormat()&n)!==0}getTextStyle(){return this.getLatest().__textStyle}setTextStyle(e){let n=this.getWritable();return n.__textStyle=e,n}static clone(e){return new o(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle,Ao(e,this)}createDOM(e){let n=document.createElement("p"),r=yo(e.theme,"paragraph");return r!==void 0&&n.classList.add(...r),dt(n,this),n}updateDOM(e,n,r){return Oo(e,this)}static importDOM(){return{p:e=>({conversion:vx,priority:0})}}exportDOM(e){let{element:n}=super.exportDOM(e);return n&&he(n)&&this.isEmpty()&&n.append(document.createElement("br")),{element:n}}static importJSON(e){let n=I();return ct(e,n),n.setTextFormat(e.textFormat),n}exportJSON(){return{...super.exportJSON(),textFormat:this.getTextFormat(),textStyle:this.getTextStyle(),type:"paragraph",version:1}}insertNewAfter(e,n){let r=I();r.setTextFormat(e.format),r.setTextStyle(e.style);let i=this.getDirection();return r.setDirection(i),r.setStyle(this.getTextStyle()),this.insertAfter(r,n),r}collapseAtStart(){let e=this.getChildren();if(e.length===0||L(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 vx(o){let t=I();return at(o,t),{node:t}}function I(){return re(new it)}function Ge(o){return o instanceof it}var Dx=!0,J=0,Ae=1,lo=2,Je=3,Ke=4;function Da(o,t,e,n){let r=o._keyToDOMMap;r.clear(),o._editorState=Vr(),o._pendingEditorState=n,o._compositionKey=null,o._dirtyType=At,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),t!==null&&(t.textContent=""),e!==null&&(e.textContent="",r.set("root",e))}function Ox(o,t){let e=new Map,n=new Set,r=i=>{Object.keys(i).forEach(s=>{let l=e.get(s);l===void 0&&(l=[],e.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)}),t&&r(t),e}function Gr(o){let t=o||{},e=Df(),n=t.theme||{},r=o===void 0?e:t.parentEditor||null,i=t.disableEvents||!1,s=Vr(),l=t.namespace||(r!==null?r._config.namespace:Fl()),a=t.editorState,d=[rn,st,Go,Jo,it,wo,...t.nodes||[]],{onError:u,html:m}=t,c=t.editable!==void 0?t.editable:!0,f;if(o===void 0&&e!==null)f=e._nodes;else{f=new Map;for(let h=0;h{N.hasOwnProperty(B)||console.warn(`${A} must implement static "${B}" method`)}),!N.hasOwnProperty("importDOM")&&N.hasOwnProperty("exportDOM")&&console.warn(`${A} should implement "importDOM" if using a custom "exportDOM" method to ensure HTML serialization (important for copy & paste) works as expected`),P instanceof lt&&(P.hasOwnProperty("decorate")||console.warn(`${P.constructor.name} must implement "decorate" method`)),N.hasOwnProperty("importJSON")||console.warn(`${A} should implement "importJSON" method to ensure JSON and default HTML serialization works as expected`),P.hasOwnProperty("exportJSON")||console.warn(`${A} should implement "exportJSON" method to ensure JSON and default HTML serialization works as expected`)}}let S=N.getType(),v=N.transform(),M=new Set;v!==null&&M.add(v),f.set(S,{exportDOM:m&&m.export?m.export.get(N):void 0,klass:N,replace:b,replaceWithKlass:x,transforms:M})}}let g=new ro(s,r,f,{disableEvents:i,namespace:l,theme:n},u||console.error,Ox(f,m?m.import:void 0),c);return a!==void 0&&(g._pendingEditorState=a,g._dirtyType=Qt),g}var ro=class{constructor(t,e,n,r,i,s,l){p(this,"constructor");p(this,"_headless");p(this,"_parentEditor");p(this,"_rootElement");p(this,"_editorState");p(this,"_pendingEditorState");p(this,"_compositionKey");p(this,"_deferred");p(this,"_keyToDOMMap");p(this,"_updates");p(this,"_updating");p(this,"_listeners");p(this,"_commands");p(this,"_nodes");p(this,"_decorators");p(this,"_pendingDecorators");p(this,"_config");p(this,"_dirtyType");p(this,"_cloneNotNeeded");p(this,"_dirtyLeaves");p(this,"_dirtyElements");p(this,"_normalizedNodes");p(this,"_updateTags");p(this,"_observer");p(this,"_key");p(this,"_onError");p(this,"_htmlConversions");p(this,"_window");p(this,"_editable");p(this,"_blockCursorElement");this._parentEditor=e,this._rootElement=null,this._editorState=t,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=At,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=Fl(),this._onError=i,this._htmlConversions=s,this._editable=l,this._headless=e!==null&&e._headless,this._window=null,this._blockCursorElement=null}isComposing(){return this._compositionKey!=null}registerUpdateListener(t){let e=this._listeners.update;return e.add(t),()=>{e.delete(t)}}registerEditableListener(t){let e=this._listeners.editable;return e.add(t),()=>{e.delete(t)}}registerDecoratorListener(t){let e=this._listeners.decorator;return e.add(t),()=>{e.delete(t)}}registerTextContentListener(t){let e=this._listeners.textcontent;return e.add(t),()=>{e.delete(t)}}registerRootListener(t){let e=this._listeners.root;return t(this._rootElement,null),e.add(t),()=>{t(null,this._rootElement),e.delete(t)}}registerCommand(t,e,n){n===void 0&&T(!1,'Listener for type "command" requires a "priority".');let r=this._commands;r.has(t)||r.set(t,[new Set,new Set,new Set,new Set,new Set]);let i=r.get(t);i===void 0&&T(!1,"registerCommand: Command %s not found in command map",String(t));let s=i[n];return s.add(e),()=>{s.delete(e),i.every(l=>l.size===0)&&r.delete(t)}}registerMutationListener(t,e,n){let r=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(t)).klass,i=this._listeners.mutation;i.set(e,r);let s=n&&n.skipInitialization;return(s===void 0?Dx:s)||this.initializeMutationListener(e,r),()=>{i.delete(e)}}getRegisteredNode(t){let e=this._nodes.get(t.getType());return e===void 0&&T(!1,"Node %s has not been registered. Ensure node has been passed to createEditor.",t.name),e}resolveRegisteredNodeAfterReplacements(t){for(;t.replaceWithKlass;)t=this.getRegisteredNode(t.replaceWithKlass);return t}initializeMutationListener(t,e){let n=this._editorState,r=mu(n).get(e.getType());if(!r)return;let i=new Map;for(let s of r.keys())i.set(s,"created");i.size>0&&t(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(t,e){let n=this.getRegisteredNode(t);return n.transforms.add(e),n}registerNodeTransform(t,e){let n=this.registerNodeTransformToKlass(t,e),r=[n],i=n.replaceWithKlass;if(i!=null){let s=this.registerNodeTransformToKlass(i,e);r.push(s)}return Dc(this,t.getType()),()=>{r.forEach(s=>s.transforms.delete(e))}}hasNode(t){return this._nodes.has(t.getType())}hasNodes(t){return t.every(this.hasNode.bind(this))}dispatchCommand(t,e){return O(this,t,e)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(t){let e=this._rootElement;if(t!==e){let n=yo(this._config.theme,"root"),r=this._pendingEditorState||this._editorState;if(this._rootElement=t,Da(this,e,t,r),e!==null&&(this._config.disableEvents||Iu(e),n!=null&&e.classList.remove(...n)),t!==null){let i=uu(t),s=t.style;s.userSelect="text",s.whiteSpace="pre-wrap",s.wordBreak="break-word",t.setAttribute("data-lexical-editor","true"),this._window=i,this._dirtyType=Qt,wi(this),this._updateTags.add("history-merge"),Bt(this),this._config.disableEvents||ku(t,this),n!=null&&t.classList.add(...n)}else this._editorState=r,this._pendingEditorState=null,this._window=null;Xn("root",this,!1,t,e)}}getElementByKey(t){return this._keyToDOMMap.get(t)||null}getEditorState(){return this._editorState}setEditorState(t,e){t.isEmpty()&&T(!1,"setEditorState: the editor state is empty. Ensure the editor state's root node never becomes empty."),Mi(this);let n=this._pendingEditorState,r=this._updateTags,i=e!==void 0?e.tag:null;n!==null&&!n.isEmpty()&&(i!=null&&r.add(i),Bt(this)),this._pendingEditorState=t,this._dirtyType=Qt,this._dirtyElements.set("root",!1),this._compositionKey=null,i!=null&&r.add(i),Bt(this)}parseEditorState(t,e){let n=typeof t=="string"?JSON.parse(t):t;return Of(n,this,e)}read(t){return Bt(this),this.getEditorState().read(t,{editor:this})}update(t,e){Te(this,t,e)}updateAndCommit(t,e){this.update(t,e),this.commitUpdates()}focus(t,e={}){let n=this._rootElement;n!==null&&(n.setAttribute("autocapitalize","off"),Te(this,()=>{let r=C(),i=F();r!==null?r.dirty=!0:i.getChildrenSize()!==0&&(e.defaultSelection==="rootStart"?i.selectStart():i.selectEnd())},{onUpdate:()=>{n.removeAttribute("autocapitalize"),t&&t()},tag:"focus"}),this._pendingEditorState===null&&n.removeAttribute("autocapitalize"))}commitUpdates(){Bt(this)}blur(){let t=this._rootElement;t!==null&&t.blur();let e=ve(this._window);e!==null&&e.removeAllRanges()}isEditable(){return this._editable}setEditable(t){this._editable!==t&&(this._editable=t,Xn("editable",this,!0,t))}toJSON(){return{editorState:this._editorState.toJSON()}}};p(ro,"version");ro.version="0.17.1";var is=0,Oa=1,Aa=2,_t=0,Ax=1,Kf=2,Rx=3,kx=4;function Ix(o,t,e){let n=o._nodeMap,r=[];for(let i of t){let s=n.get(i);s!==void 0&&r.push(s)}for(let[i,s]of e){if(!s)continue;let l=n.get(i);l!==void 0&&!ne(l)&&r.push(l)}return r}function $x(o,t,e,n,r){if(o===null||e.size===0&&n.size===0&&!r)return _t;let i=t._selection,s=o._selection;if(r)return Ax;if(!_(i)||!_(s)||!s.isCollapsed()||!i.isCollapsed())return _t;let l=Ix(t,e,n);if(l.length===0)return _t;if(l.length>1){let b=t._nodeMap,x=b.get(i.anchor.key),S=b.get(s.anchor.key);return x&&S&&!o._nodeMap.has(x.__key)&&L(x)&&x.__text.length===1&&i.anchor.offset===1?Kf:_t}let a=l[0],d=o._nodeMap.get(a.__key);if(!L(d)||!L(a)||d.__mode!==a.__mode)return _t;let u=d.__text,m=a.__text;if(u===m)return _t;let c=i.anchor,f=s.anchor;if(c.key!==f.key||c.type!=="text")return _t;let g=c.offset,h=f.offset,N=m.length-u.length;return N===1&&h===g-1?Kf:N===-1&&h===g+1?Rx:N===-1&&h===g?kx:_t}function Px(o,t,e){let n=t._nodeMap.get(o),r=e._nodeMap.get(o),i=t._selection,s=e._selection;return!(_(i)&&_(s)&&i.anchor.type==="element"&&i.focus.type==="element"&&s.anchor.type==="text"&&s.focus.type==="text")&&L(n)&&L(r)&&n.__parent===r.__parent?JSON.stringify(t.read(()=>n.exportJSON()))===JSON.stringify(e.read(()=>r.exportJSON())):!1}function Bx(o,t){let e=Date.now(),n=_t;return(r,i,s,l,a,d)=>{let u=Date.now();if(d.has("historic"))return n=_t,e=u,Aa;let m=$x(r,i,l,a,o.isComposing()),c=(()=>{let f=s===null||s.editor===o,g=d.has("history-push");if(!g&&f&&d.has("history-merge"))return is;if(r===null)return Oa;let N=i._selection;if(!(l.size>0||a.size>0))return N!==null?is:Aa;if(g===!1&&m!==_t&&m===n&&u{let m=t.current,c=t.redoStack,f=t.undoStack,g=m===null?null:m.editorState;if(m!==null&&s===g)return;let h=n(l,s,m,a,d,u);if(h===Oa)c.length!==0&&(t.redoStack=[],o.dispatchCommand(To,!1)),m!==null&&(f.push({...m}),o.dispatchCommand(Co,!0));else if(h===Aa)return;t.current={editor:o,editorState:s}};return Et(o.registerCommand(ho,()=>(Fx(o,t),!0),J),o.registerCommand(No,()=>(Hx(o,t),!0),J),o.registerCommand(_l,()=>(Uf(t),!1),J),o.registerCommand(yl,()=>(Uf(t),o.dispatchCommand(To,!1),o.dispatchCommand(Co,!1),!0),J),o.registerUpdateListener(r))}function ls(){return{current:null,redoStack:[],undoStack:[]}}var Wf=o=>pe?(o||window).getSelection():null;function qf(o,t=C()){return t==null&&T(!1,"Expected valid LexicalSelection"),_(t)&&t.isCollapsed()||t.getNodes().length===0?"":Qi(o,t)}function Yf(o,t=C()){return t==null&&T(!1,"Expected valid LexicalSelection"),_(t)&&t.isCollapsed()||t.getNodes().length===0?null:JSON.stringify(Vf(o,t))}function as(o,t,e){let n=o.getData("application/x-lexical-editor");if(n)try{let s=JSON.parse(n);if(s.namespace===e._config.namespace&&Array.isArray(s.nodes)){let l=Xf(s.nodes);return Ra(e,l,t)}}catch{}let r=o.getData("text/html");if(r)try{let l=new DOMParser().parseFromString(r,"text/html"),a=Ji(e,l);return Ra(e,a,t)}catch{}let i=o.getData("text/plain")||o.getData("text/uri-list");if(i!=null)if(_(t)){let s=i.split(/(\r?\n|\t)/);s[s.length-1]===""&&s.pop();for(let l=0;l=0;k--){let Z=R[k];if(Z.is(c)||E(Z)&&Z.isParentOf(c))break;Z.isAttached()&&(!A.has(Z)||Z.is(M)?P||B.insertAfter(Z,!1):Z.remove())}if(!P){let k=v,Z=null;for(;k!==null;){let se=k.getChildren(),We=se.length;(We===0||se[We-1].is(Z))&&(x.delete(k.__key),Z=k),k=k.getParent()}}if(!c.isToken())c=c.spliceText(a,g-a,t,!0),c.getTextContent()===""?c.remove():c.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=t.length);else if(a===g)c.select();else{let k=z(t);k.select(),c.replace(k)}for(let k=1;k0&&(N!==h.getTextContentSize()&&!Xe(h)&&([h]=h.splitText(N)),h.setFormat(b));for(let x=u+1;x(E(N)||H(N))&&!N.isInline();if(!t.some(i)){T(E(n),"Expected 'firstBlock' to be an ElementNode");let N=ya(this);n.splice(N,0,t),r.selectEnd();return}let s=Cx(t),l=s.getLastDescendant(),a=s.getChildren(),d=N=>E(N)&&Xo(N)&&!N.isEmpty()&&E(n)&&(!n.isEmpty()||n.canMergeWhenEmpty()),m=!E(n)||!n.isEmpty()?this.insertParagraph():null,c=a[a.length-1],f=a[0];d(f)&&(T(E(n),"Expected 'firstBlock' to be an ElementNode"),n.append(...f.getChildren()),f=a[1]),f&&Hu(n,f);let g=Bi(l,Xo);m&&E(g)&&(m.canMergeWhenEmpty()||Xo(c))&&(g.append(...m.getChildren()),m.remove()),E(n)&&n.isEmpty()&&n.remove(),l.selectEnd();let h=E(n)?n.getLastChild():null;Pe(h)&&g!==n&&h.remove()}insertParagraph(){if(this.anchor.key==="root"){let s=I();return F().splice(this.anchor.offset,0,[s]),s.select(),s}let t=ya(this),e=Bi(this.anchor.getNode(),Xo);T(E(e),"Expected ancestor to be an ElementNode");let n=e.getChildAtIndex(t),r=n?[n,...n.getNextSiblings()]:[],i=e.insertNewAfter(this,!1);return i?(i.append(...r),i.selectStart(),i):null}insertLineBreak(t){let e=xt();if(this.insertNodes([e]),t){let n=e.getParentOrThrow(),r=e.getIndexWithinParent();n.select(r,r)}}extract(){let t=this.getNodes(),e=t.length,n=e-1,r=this.anchor,i=this.focus,s=t[0],l=t[n],[a,d]=Wr(this);if(e===0)return[];if(e===1){if(L(s)&&!this.isCollapsed()){let m=a>d?d:a,c=a>d?a:d,f=s.splitText(m,c),g=m===0?f[0]:f[1];return g!=null?[g]:[]}return[s]}let u=r.isBefore(i);if(L(s)){let m=u?a:d;m===s.getTextContentSize()?t.shift():m!==0&&([,s]=s.splitText(m),t[0]=s)}if(L(l)){let c=l.getTextContent().length,f=u?d:a;f===0?t.pop():f!==c&&([l]=l.splitText(f),t[n]=l)}return t}modify(t,e,n){let r=this.focus,i=this.anchor,s=t==="move",l=oo(r,e);if(H(l)&&!l.isIsolated()){if(s&&l.isKeyboardSelectable()){let f=nn();f.add(l.__key),Y(f);return}let c=e?l.getPreviousSibling():l.getNextSibling();if(L(c)){let f=c.__key,g=e?c.getTextContent().length:0;r.set(f,g,"text"),s&&i.set(f,g,"text");return}else{let f=l.getParentOrThrow(),g,h;E(c)?(h=c.__key,g=e?c.getChildrenSize():0):(g=l.getIndexWithinParent(),h=f.__key,e||g++),r.set(h,g,"element"),s&&i.set(h,g,"element");return}}let a=Q(),d=ve(a._window);if(!d)return;let u=a._blockCursorElement,m=a._rootElement;if(m!==null&&u!==null&&E(l)&&!l.isInline()&&!l.canBeEmpty()&&Ir(u,a,m),Nx(d,t,e?"backward":"forward",n),d.rangeCount>0){let c=d.getRangeAt(0),f=this.anchor.getNode(),g=ne(f)?f:ql(f);if(this.applyDOMRange(c),this.dirty=!0,!s){let h=this.getNodes(),N=[],b=!1;for(let x=0;x0)if(e){let x=N[0];E(x)?x.selectStart():x.getParentOrThrow().selectStart()}else{let x=N[N.length-1];E(x)?x.selectEnd():x.getParentOrThrow().selectEnd()}(d.anchorNode!==c.startContainer||d.anchorOffset!==c.startOffset)&&hx(this)}}}forwardDeletion(t,e,n){if(!n&&(t.type==="element"&&E(e)&&t.offset===e.getChildrenSize()||t.type==="text"&&t.offset===e.getTextContentSize())){let r=e.getParent(),i=e.getNextSibling()||(r===null?null:r.getNextSibling());if(E(i)&&i.isShadowRoot())return!0}return!1}deleteCharacter(t){let e=this.isCollapsed();if(this.isCollapsed()){let n=this.anchor,r=n.getNode();if(this.forwardDeletion(n,r,t))return;let i=this.focus,s=oo(i,t);if(H(s)&&!s.isIsolated()){if(s.isKeyboardSelectable()&&E(r)&&r.getChildrenSize()===0){r.remove();let l=nn();l.add(s.__key),Y(l)}else s.remove(),Q().dispatchCommand(_e,void 0);return}else if(!t&&E(s)&&E(r)&&r.isEmpty()){r.remove(),s.selectStart();return}if(this.modify("extend",t,"character"),this.isCollapsed()){if(t&&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)||t&&a!==d||!t&&a!==0){Nf(l,t,a);return}}else if(r!==null&&r.isSegmented()){let a=n.offset,d=r.getTextContentSize();if(r.is(l)||t&&a!==0||!t&&a!==d){Nf(r,t,a);return}}xx(this,t)}}if(this.removeText(),t&&!e&&this.isCollapsed()&&this.anchor.type==="element"&&this.anchor.offset===0){let n=this.anchor.getNode();n.isEmpty()&&ne(n.getParent())&&n.getIndexWithinParent()===0&&n.collapseAtStart(this)}}deleteLine(t){if(this.isCollapsed()){let e=this.anchor.type==="element";if(e&&this.insertText(" "),this.modify("extend",t,"lineboundary"),(t?this.focus:this.anchor).offset===0&&this.modify("extend",t,"character"),e){let r=t?this.anchor:this.focus;r.set(r.key,r.offset+1,r.type)}}this.removeText()}deleteWord(t){if(this.isCollapsed()){let e=this.anchor,n=e.getNode();if(this.forwardDeletion(e,n,t))return;this.modify("extend",t,"word")}this.removeText()}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return[this.anchor,this.focus]}};function Oe(o){return o instanceof os}function hf(o){let t=o.offset;if(o.type==="text")return t;let e=o.getNode();return t===e.getChildrenSize()?e.getTextContent().length:0}function Wr(o){let t=o.getStartEndPoints();if(t===null)return[0,0];let[e,n]=t;return e.type==="element"&&n.type==="element"&&e.key===n.key&&e.offset===n.offset?[0,0]:[hf(e),hf(n)]}function hx(o){let t=o.focus,e=o.anchor,n=e.key,r=e.offset,i=e.type;vo(e,t.key,t.offset,t.type),vo(t,n,r,i),o._cachedNodes=null}function Nx(o,t,e,n){o.modify(t,e,n)}function xx(o,t){let e=o.anchor,n=o.focus,r=e.getNode(),i=n.getNode();if(r===i&&e.type==="text"&&n.type==="text"){let s=e.offset,l=n.offset,a=se||c){i.splice(u,1),c&&(a=void 0);break}}let d=i.join("").trim();d===""?n.remove():(n.setTextContent(d),n.select(a,a))}function Ex(o,t,e){let n=o.getParent();return e===null||n===null||!n.canBeEmpty()||n!==e.getNode()}function xf(o,t,e,n){let r=t,i;if(o.nodeType===_o){let s=!1,l=o.childNodes,a=l.length,d=n._blockCursorElement;r===a&&(s=!0,r=a-1);let u=l[r],m=!1;if(u===d)u=l[r+1],m=!0;else if(d!==null){let c=d.parentNode;if(o===c){let f=Array.prototype.indexOf.call(c.children,d);t>f&&r--}}if(i=Zo(u),L(i))r=Fl(i,s);else{let c=Zo(o);if(c===null)return null;if(E(c)){r=Math.min(c.getChildrenSize(),r);let f=c.getChildAtIndex(r);if(E(f)&&Ex(f,r,e)){let g=s?f.getLastDescendant():f.getFirstDescendant();g===null?c=f:(f=g,c=E(f)?f:f.getParentOrThrow()),r=0}L(f)?(i=f,c=null,r=Fl(f,s)):f!==c&&s&&!m&&r++}else{let f=c.getIndexWithinParent();t===0&&H(c)&&Zo(o)===c?r=f:r=f+1,c=c.getParentOrThrow()}if(E(c))return He(c.__key,r,"element")}}else i=Zo(o);return L(i)?He(i.__key,r,"text"):null}function Ef(o,t,e){let n=o.offset,r=o.getNode();if(n===0){let i=r.getPreviousSibling(),s=r.getParent();if(!t)E(i)&&!e&&i.isInline()?(o.key=i.__key,o.offset=i.getChildrenSize(),o.type="element"):L(i)&&(o.key=i.__key,o.offset=i.getTextContent().length);else if((e||!t)&&i===null&&E(s)&&s.isInline()){let l=s.getPreviousSibling();L(l)&&(o.key=l.__key,o.offset=l.getTextContent().length)}}else if(n===r.getTextContent().length){let i=r.getNextSibling(),s=r.getParent();if(t&&E(i)&&i.isInline())o.key=i.__key,o.offset=0,o.type="element";else if((e||t)&&i===null&&E(s)&&s.isInline()&&!s.canInsertTextAfter()){let l=s.getNextSibling();L(l)&&(o.key=l.__key,o.offset=0)}}}function Cf(o,t,e){if(o.type==="text"&&t.type==="text"){let n=o.isBefore(t),r=o.is(t);Ef(o,n,r),Ef(t,!n,r),r&&(t.key=o.key,t.offset=o.offset,t.type=o.type);let i=Q();if(i.isComposing()&&i._compositionKey!==o.key&&_(e)){let s=e.anchor,l=e.focus;vo(o,s.key,s.offset,s.type),vo(t,l.key,l.offset,l.type)}}}function bf(o,t,e,n,r,i){if(o===null||e===null||!eo(r,o,e))return null;let s=xf(o,t,_(i)?i.anchor:null,r);if(s===null)return null;let l=xf(e,n,_(i)?i.focus:null,r);if(l===null)return null;if(s.type==="element"&&l.type==="element"){let a=Zo(o),d=Zo(e);if(H(a)&&H(d))return null}return Cf(s,l,i),[s,l]}function It(o){return E(o)&&!o.isInline()}function Zi(o,t,e,n,r,i){let s=rt(),l=new Do(He(o,t,r),He(e,n,i),0,"");return l.dirty=!0,s._selection=l,l}function on(){let o=He("root",0,"element"),t=He("root",0,"element");return new Do(o,t,0,"")}function nn(){return new os(new Set)}function _f(o){let e=o.getEditorState()._selection,n=ve(o._window);return _(e)||e==null?Ur(e,n,o,null):e.clone()}function La(o,t){return Ur(null,o,t,null)}function Ur(o,t,e,n){let r=e._window;if(r===null)return null;let i=n||r.event,s=i?i.type:void 0,l=s==="selectionchange",a=!Ec()&&(l||s==="beforeinput"||s==="compositionstart"||s==="compositionend"||s==="click"&&i&&i.detail===3||s==="drop"||s===void 0),d,u,m,c;if(!_(o)||a){if(t===null)return null;if(d=t.anchorNode,u=t.focusNode,m=t.anchorOffset,c=t.focusOffset,l&&_(o)&&!eo(e,d,u))return o.clone()}else return o.clone();let f=bf(d,m,u,c,e,o);if(f===null)return null;let[g,h]=f;return new Do(g,h,_(o)?o.format:0,_(o)?o.style:"")}function C(){return rt()._selection}function je(){return Q()._editorState._selection}function Un(o,t,e,n=1){let r=o.anchor,i=o.focus,s=r.getNode(),l=i.getNode();if(!t.is(s)&&!t.is(l))return;let a=t.__key;if(o.isCollapsed()){let d=r.offset;if(e<=d&&n>0||e0||e0||e=l,d=a?i.getChildAtIndex(l-1):i.getChildAtIndex(e);if(L(d)){let u=0;a&&(u=d.getTextContentSize()),t.set(d.__key,u,"text"),n.set(d.__key,u,"text")}return}if(E(i)){let l=i.getChildrenSize(),a=e>=l,d=a?i.getChildAtIndex(l-1):i.getChildAtIndex(e);if(L(d)){let u=0;a&&(u=d.getTextContentSize()),t.set(d.__key,u,"text")}}if(E(s)){let l=s.getChildrenSize(),a=r>=l,d=a?s.getChildAtIndex(l-1):s.getChildAtIndex(r);if(L(d)){let u=0;a&&(u=d.getTextContentSize()),n.set(d.__key,u,"text")}}}function yf(o,t){let n=t.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 zn(o,t,e,n,r){let i=null,s=0,l=null;n!==null?(i=n.__key,L(n)?(s=n.getTextContentSize(),l="text"):E(n)&&(s=n.getChildrenSize(),l="element")):r!==null&&(i=r.__key,L(r)?l="text":E(r)&&(l="element")),i!==null&&l!==null?o.set(i,s,l):(s=t.getIndexWithinParent(),s===-1&&(s=e.getChildrenSize()),o.set(e.__key,s,"element"))}function ua(o,t,e,n,r){o.type==="text"?(o.key=e,t||(o.offset+=r)):o.offset>n.getIndexWithinParent()&&(o.offset-=1)}function Sf(o,t,e,n,r,i,s){let l=n.anchorNode,a=n.focusNode,d=n.anchorOffset,u=n.focusOffset,m=document.activeElement;if(r.has("collaboration")&&m!==i||m!==null&&In(m))return;if(!_(t)){if(m!==null&&n.isCollapsed&&a instanceof Node){let k=G(a);if(H(k)){n.removeAllRanges(),Be(k);return}}o!==null&&eo(e,l,a)&&n.removeAllRanges();return}let c=t.anchor,f=t.focus,g=c.key,h=f.key,N=Bn(e,g),b=Bn(e,h),x=c.offset,S=f.offset,v=t.format,M=t.style,R=t.isCollapsed(),A=N,P=b,B=!1;if(c.type==="text"){A=Pn(N);let k=c.getNode();B=k.getFormat()!==v||k.getStyle()!==M}else _(o)&&o.anchor.type==="text"&&(B=!0);if(f.type==="text"&&(P=Pn(b)),!(A===null||P===null)&&(R&&(o===null||B||_(o)&&(o.format!==v||o.style!==M))&&Bu(v,M,x,g,performance.now()),!(d===x&&u===S&&l===A&&a===P&&!(n.type==="Range"&&R)&&((m===null||!i.contains(m))&&i.focus({preventScroll:!0}),c.type!=="element")))){try{n.setBaseAndExtent(A,x,P,S)}catch(k){__DEV__&&console.warn(k)}if(!r.has("skip-scroll-into-view")&&t.isCollapsed()&&i!==null&&i===document.activeElement){let k=t instanceof Do&&t.anchor.type==="element"?A.childNodes[x]||null:n.rangeCount>0?n.getRangeAt(0):null;if(k!==null){let Z;if(k instanceof Text){let se=document.createRange();se.selectNode(k),Z=se.getBoundingClientRect()}else k instanceof Range,Z=k.getBoundingClientRect();cu(e,Z,i)}}Pu()}}function Ce(o){let t=C()||je();t===null&&(t=F().selectEnd()),t.insertNodes(o)}function ya(o){let t=o;o.isCollapsed()||t.removeText();let e=C();_(e)&&(t=e),T(_(t),"Unexpected dirty selection to be null");let n=t.anchor,r=n.getNode(),i=n.offset;for(;!Xo(r);)[r,i]=Tx(r,i);return i}function Tx(o,t){let e=o.getParent();if(!e){let r=I();return F().append(r),r.select(),[F(),0]}if(L(o)){let r=o.splitText(t);if(r.length===0)return[e,o.getIndexWithinParent()];let i=t===0?0:1,s=r[0].getIndexWithinParent()+i;return[e,s]}if(!E(o)||t===0)return[e,o.getIndexWithinParent()];let n=o.getChildAtIndex(t);if(n){let r=new Do(He(o.__key,t,"element"),He(o.__key,t,"element"),0,""),i=o.insertNewAfter(r);i&&i.append(n,...n.getNextSiblings())}return[e,o.getIndexWithinParent()+1]}function Cx(o){let t=I(),e=null;for(let n=0;n99&&T(!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 rt(){return me===null&&T(!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",Df()),me}function Q(){return Ne===null&&T(!1,"Unable to find an active editor. This method can only be used synchronously during the callback of editor.update() or editor.read().%s",Df()),Ne}function Df(){let o=0,t=new Set,e=ro.version;if(typeof window<"u")for(let r of document.querySelectorAll("[contenteditable]")){let i=Yo(r);if($n(i))o++;else if(i){let s=String(i.constructor.version||"<0.17.1");s===e&&(s+=" (separately built, likely a bundler configuration issue)"),t.add(s)}}let n=` Detected on the page: ${o} compatible editor(s) with version ${e}`;return t.size&&(n+=` and incompatible editors with versions ${Array.from(t).join(", ")}`),n}function Of(){return Ne}function gu(){return me}function Mf(o,t,e){let n=t.__type,r=Lc(o,n),i=e.get(n);i===void 0&&(i=Array.from(r.transforms),e.set(n,i));let s=i.length;for(let l=0;l0||u>0;){if(a>0){t._dirtyLeaves=new Set;for(let m of l){let c=r.get(m);L(c)&&c.isAttached()&&c.isSimpleText()&&!c.isUnmergeable()&&Pl(c),c!==void 0&&wf(c,i)&&Mf(t,c,s),e.add(m)}if(l=t._dirtyLeaves,a=l.size,a>0){ns++;continue}}t._dirtyLeaves=new Set,t._dirtyElements=new Map;for(let m of d){let c=m[0],f=m[1];if(c!=="root"&&!f)continue;let g=r.get(c);g!==void 0&&wf(g,i)&&Mf(t,g,s),n.set(c,f)}l=t._dirtyLeaves,a=l.size,d=t._dirtyElements,u=d.size,ns++}t._dirtyLeaves=e,t._dirtyElements=n}function wa(o){return va(o,Q()._nodes)}function va(o,t){let e=o.type,n=t.get(e);n===void 0&&T(!1,'parseEditorState: type "%s" + not found',e);let r=n.klass;o.type!==r.getType()&&T(!1,"LexicalNode: Node %s does not implement .importJSON().",r.name);let i=r.importJSON(o),s=o.children;if(E(i)&&Array.isArray(s))for(let l=0;l{throw new Error("Cannot call set() on a frozen Lexical node map")},t.clear=()=>{throw new Error("Cannot call clear() on a frozen Lexical node map")},t.delete=()=>{throw new Error("Cannot call delete() on a frozen Lexical node map")}}function Bt(o,t){let e=o._pendingEditorState,n=o._rootElement,r=o._headless||n===null;if(e===null)return;let i=o._editorState,s=i._selection,l=e._selection,a=o._dirtyType!==At,d=me,u=Fe,m=Ne,c=o._updating,f=o._observer,g=null;if(o._pendingEditorState=null,o._editorState=e,!r&&a&&f!==null){Ne=o,me=e,Fe=!1,o._updating=!0;try{let A=o._dirtyType,P=o._dirtyElements,B=o._dirtyLeaves;f.disconnect(),g=_u(i,e,o,A,P,B)}catch(A){if(A instanceof Error&&o._onError(A),!Ma)Oa(o,null,n,e),wi(o),o._dirtyType=Qt,Ma=!0,Bt(o,i),Ma=!1;else throw A;return}finally{f.observe(n,Lf),o._updating=c,me=d,Fe=u,Ne=m}}e._readOnly||(e._readOnly=!0,__DEV__&&(Rf(e),_(l)&&(Object.freeze(l.anchor),Object.freeze(l.focus)),Object.freeze(l)));let h=o._dirtyLeaves,N=o._dirtyElements,b=o._normalizedNodes,x=o._updateTags,S=o._deferred,v=e._nodeMap.size;a&&(o._dirtyType=At,o._cloneNotNeeded.clear(),o._dirtyLeaves=new Set,o._dirtyElements=new Map,o._normalizedNodes=new Set,o._updateTags=new Set),hu(o,e);let M=r?null:ve(o._window);if(o._editable&&M!==null&&(a||l===null||l.dirty)){Ne=o,me=e;try{if(f!==null&&f.disconnect(),a||l===null||l.dirty){let A=o._blockCursorElement;A!==null&&Ir(A,o,n),Sf(s,l,o,M,x,n,v)}mu(o,n,l),f!==null&&f.observe(n,Lf)}finally{Ne=m,me=d}}g!==null&&Sx(o,g,x,h,i),!_(l)&&l!==null&&(s===null||!s.is(l))&&o.dispatchCommand(_e,void 0);let R=o._pendingDecorators;R!==null&&(o._decorators=R,o._pendingDecorators=null,Xn("decorator",o,!0,R)),yx(o,t||i,e),Xn("update",o,!0,{dirtyElements:N,dirtyLeaves:h,editorState:e,normalizedNodes:b,prevEditorState:t||i,tags:x}),Mx(o,S),Lx(o)}function yx(o,t,e){let n=Hl(t),r=Hl(e);n!==r&&Xn("textcontent",o,!0,r)}function Sx(o,t,e,n,r){let i=Array.from(o._listeners.mutation),s=i.length;for(let l=0;l{r=Vl(o,t,e)}),r}let n=Ar(o);for(let r=4;r>=0;r--)for(let i=0;i{Bt(o)}):(d._flushSync=!1,u&&(n.clear(),o._deferred=[],o._pendingEditorState=null))}function Te(o,t,e){o._updating?o._updates.push([t,e]):kf(o,t,e)}var X=class extends Nt{constructor(e){super(e);p(this,"__first");p(this,"__last");p(this,"__size");p(this,"__style");p(this,"__dir");this.__first=null,this.__last=null,this.__size=0,this.__style="",this.__dir=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__first=e.__first,this.__last=e.__last,this.__size=e.__size,this.__style=e.__style,this.__dir=e.__dir}getStyle(){return this.getLatest().__style}getChildren(){let e=[],n=this.getFirstChild();for(;n!==null;)e.push(n),n=n.getNextSibling();return e}getChildrenKeys(){let e=[],n=this.getFirstChild();for(;n!==null;)e.push(n.__key),n=n.getNextSibling();return e}getChildrenSize(){return this.getLatest().__size}isEmpty(){return this.getChildrenSize()===0}isDirty(){let n=Q()._dirtyElements;return n!==null&&n.has(this.__key)}isLastChild(){let e=this.getLatest(),n=this.getParentOrThrow().getLastChild();return n!==null&&n.is(e)}getAllTextNodes(){let e=[],n=this.getFirstChild();for(;n!==null;){if(L(n)&&e.push(n),E(n)){let r=n.getAllTextNodes();e.push(...r)}n=n.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;E(e);){let n=e.getFirstChild();if(n===null)break;e=n}return e}getFirstSelectableDescendant(){if(this.shouldSelectDirectly())return null;let e=this.getFirstChild();for(;E(e)&&!e.shouldSelectDirectly();){let n=e.getFirstChild();if(n===null)break;e=n}return e}getLastDescendant(){let e=this.getLastChild();for(;E(e);){let n=e.getLastChild();if(n===null)break;e=n}return e}getLastSelectableDescendant(){if(this.shouldSelectDirectly())return null;let e=this.getLastChild();for(;E(e)&&!e.shouldSelectDirectly();){let n=e.getLastChild();if(n===null)break;e=n}return e}getDescendantByIndex(e){let n=this.getChildren(),r=n.length;if(e>=r){let s=n[r-1];return E(s)&&s.getLastDescendant()||s||null}let i=n[e];return E(i)&&i.getFirstDescendant()||i||null}getFirstChild(){let n=this.getLatest().__first;return n===null?null:ee(n)}getFirstChildOrThrow(){let e=this.getFirstChild();return e===null&&T(!1,"Expected node %s to have a first child.",this.__key),e}getLastChild(){let n=this.getLatest().__last;return n===null?null:ee(n)}getLastChildOrThrow(){let e=this.getLastChild();return e===null&&T(!1,"Expected node %s to have a last child.",this.__key),e}getChildAtIndex(e){let n=this.getChildrenSize(),r,i;if(e=e;){if(i===e)return r;r=r.getPreviousSibling(),i--}return null}getTextContent(){let e="",n=this.getChildren(),r=n.length;for(let i=0;ir.remove()),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){let n=this.getWritable();return n.__dir=e,n}setStyle(e){let n=this.getWritable();return n.__style=e||"",this}splice(e,n,r){let i=r.length,s=this.getChildrenSize(),l=this.getWritable(),a=l.__key,d=[],u=[],m=this.getChildAtIndex(e+n),c=null,f=s-n+i;if(e!==0)if(e===s)c=this.getLastChild();else{let h=this.getChildAtIndex(e);h!==null&&(c=h.getPreviousSibling())}if(n>0){let h=c===null?this.getFirstChild():c.getNextSibling();for(let N=0;N({root:Hf(F())}))}};var wo=class extends X{static getType(){return"artificial"}createDOM(t){return document.createElement("div")}};var Ff=["left","right","center","justify"];function Xr(o){let t=o.style.textAlign||"";return Ff.includes(t)?t: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 wx(o){let t=o.style.paddingLeft||"0";return Qo(t)}function jr(o){let t=(o.dir||"").toLowerCase();return t==="rtl"||t==="ltr"?t:null}function at(o,t){o.id&&t.setId(o.id),t.setAlignment(Xr(o)),t.setInset(wx(o)),t.setDirection(jr(o))}function Oo(o,t){return o.__id!==t.__id||o.__alignment!==t.__alignment||o.__inset!==t.__inset||o.__dir!==t.__dir}function Kf(o,t,e){if(o.__id!==t.__id&&e.setAttribute("id",t.__id),o.__alignment!==t.__alignment){for(let n of Ff)e.classList.remove("align-"+n);t.__alignment&&e.classList.add("align-"+t.__alignment)}o.__inset!==t.__inset&&(t.__inset?e.style.paddingLeft=`${t.__inset}px`:e.style.removeProperty("paddingLeft")),o.__dir!==t.__dir&&(t.__dir?e.dir=t.__dir:e.removeAttribute("dir"))}function dt(o,t){t.__id&&o.setAttribute("id",t.__id),t.__alignment&&o.classList.add("align-"+t.__alignment),t.__inset&&(o.style.paddingLeft=`${t.__inset}px`),t.__dir&&(o.dir=t.__dir)}function ct(o,t){t.setId(o.id),t.setAlignment(o.alignment),t.setInset(o.inset),t.setDirection(o.direction)}var Ht=class extends X{constructor(){super(...arguments);p(this,"__id","");p(this,"__alignment","");p(this,"__inset",0)}setId(e){let n=this.getWritable();n.__id=e}getId(){return this.getLatest().__id}setAlignment(e){let n=this.getWritable();n.__alignment=e}getAlignment(){return this.getLatest().__alignment}setInset(e){let n=this.getWritable();n.__inset=e}getInset(){return this.getLatest().__inset}exportJSON(){return{...super.exportJSON(),id:this.__id,alignment:this.__alignment,inset:this.__inset}}};function Ao(o,t){t.__alignment=o.__alignment,t.__inset=o.__inset}var it=class o extends Ht{constructor(e){super(e);p(this,"__textFormat");p(this,"__textStyle");this.__textFormat=0,this.__textStyle=""}static getType(){return"paragraph"}getTextFormat(){return this.getLatest().__textFormat}setTextFormat(e){let n=this.getWritable();return n.__textFormat=e,n}hasTextFormat(e){let n=$e[e];return(this.getTextFormat()&n)!==0}getTextStyle(){return this.getLatest().__textStyle}setTextStyle(e){let n=this.getWritable();return n.__textStyle=e,n}static clone(e){return new o(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle,Ao(e,this)}createDOM(e){let n=document.createElement("p"),r=yo(e.theme,"paragraph");return r!==void 0&&n.classList.add(...r),dt(n,this),n}updateDOM(e,n,r){return Oo(e,this)}static importDOM(){return{p:e=>({conversion:vx,priority:0})}}exportDOM(e){let{element:n}=super.exportDOM(e);return n&&he(n)&&this.isEmpty()&&n.append(document.createElement("br")),{element:n}}static importJSON(e){let n=I();return ct(e,n),n.setTextFormat(e.textFormat),n}exportJSON(){return{...super.exportJSON(),textFormat:this.getTextFormat(),textStyle:this.getTextStyle(),type:"paragraph",version:1}}insertNewAfter(e,n){let r=I();r.setTextFormat(e.format),r.setTextStyle(e.style);let i=this.getDirection();return r.setDirection(i),r.setStyle(this.getTextStyle()),this.insertAfter(r,n),r}collapseAtStart(){let e=this.getChildren();if(e.length===0||L(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 vx(o){let t=I();return at(o,t),{node:t}}function I(){return re(new it)}function Ge(o){return o instanceof it}var Dx=!0,J=0,Ae=1,lo=2,Je=3,Ke=4;function Oa(o,t,e,n){let r=o._keyToDOMMap;r.clear(),o._editorState=Vr(),o._pendingEditorState=n,o._compositionKey=null,o._dirtyType=At,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),t!==null&&(t.textContent=""),e!==null&&(e.textContent="",r.set("root",e))}function Ox(o,t){let e=new Map,n=new Set,r=i=>{Object.keys(i).forEach(s=>{let l=e.get(s);l===void 0&&(l=[],e.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)}),t&&r(t),e}function Gr(o){let t=o||{},e=Of(),n=t.theme||{},r=o===void 0?e:t.parentEditor||null,i=t.disableEvents||!1,s=Vr(),l=t.namespace||(r!==null?r._config.namespace:Kl()),a=t.editorState,d=[rn,st,Go,Jo,it,wo,...t.nodes||[]],{onError:u,html:m}=t,c=t.editable!==void 0?t.editable:!0,f;if(o===void 0&&e!==null)f=e._nodes;else{f=new Map;for(let h=0;h{N.hasOwnProperty(B)||console.warn(`${A} must implement static "${B}" method`)}),!N.hasOwnProperty("importDOM")&&N.hasOwnProperty("exportDOM")&&console.warn(`${A} should implement "importDOM" if using a custom "exportDOM" method to ensure HTML serialization (important for copy & paste) works as expected`),P instanceof lt&&(P.hasOwnProperty("decorate")||console.warn(`${P.constructor.name} must implement "decorate" method`)),N.hasOwnProperty("importJSON")||console.warn(`${A} should implement "importJSON" method to ensure JSON and default HTML serialization works as expected`),P.hasOwnProperty("exportJSON")||console.warn(`${A} should implement "exportJSON" method to ensure JSON and default HTML serialization works as expected`)}}let S=N.getType(),v=N.transform(),M=new Set;v!==null&&M.add(v),f.set(S,{exportDOM:m&&m.export?m.export.get(N):void 0,klass:N,replace:b,replaceWithKlass:x,transforms:M})}}let g=new ro(s,r,f,{disableEvents:i,namespace:l,theme:n},u||console.error,Ox(f,m?m.import:void 0),c);return a!==void 0&&(g._pendingEditorState=a,g._dirtyType=Qt),g}var ro=class{constructor(t,e,n,r,i,s,l){p(this,"constructor");p(this,"_headless");p(this,"_parentEditor");p(this,"_rootElement");p(this,"_editorState");p(this,"_pendingEditorState");p(this,"_compositionKey");p(this,"_deferred");p(this,"_keyToDOMMap");p(this,"_updates");p(this,"_updating");p(this,"_listeners");p(this,"_commands");p(this,"_nodes");p(this,"_decorators");p(this,"_pendingDecorators");p(this,"_config");p(this,"_dirtyType");p(this,"_cloneNotNeeded");p(this,"_dirtyLeaves");p(this,"_dirtyElements");p(this,"_normalizedNodes");p(this,"_updateTags");p(this,"_observer");p(this,"_key");p(this,"_onError");p(this,"_htmlConversions");p(this,"_window");p(this,"_editable");p(this,"_blockCursorElement");p(this,"_context");this._parentEditor=e,this._rootElement=null,this._editorState=t,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=At,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=Kl(),this._onError=i,this._htmlConversions=s,this._editable=l,this._headless=e!==null&&e._headless,this._window=null,this._blockCursorElement=null,this._context=null}isComposing(){return this._compositionKey!=null}registerUpdateListener(t){let e=this._listeners.update;return e.add(t),()=>{e.delete(t)}}registerEditableListener(t){let e=this._listeners.editable;return e.add(t),()=>{e.delete(t)}}registerDecoratorListener(t){let e=this._listeners.decorator;return e.add(t),()=>{e.delete(t)}}registerTextContentListener(t){let e=this._listeners.textcontent;return e.add(t),()=>{e.delete(t)}}registerRootListener(t){let e=this._listeners.root;return t(this._rootElement,null),e.add(t),()=>{t(null,this._rootElement),e.delete(t)}}registerCommand(t,e,n){n===void 0&&T(!1,'Listener for type "command" requires a "priority".');let r=this._commands;r.has(t)||r.set(t,[new Set,new Set,new Set,new Set,new Set]);let i=r.get(t);i===void 0&&T(!1,"registerCommand: Command %s not found in command map",String(t));let s=i[n];return s.add(e),()=>{s.delete(e),i.every(l=>l.size===0)&&r.delete(t)}}registerMutationListener(t,e,n){let r=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(t)).klass,i=this._listeners.mutation;i.set(e,r);let s=n&&n.skipInitialization;return(s===void 0?Dx:s)||this.initializeMutationListener(e,r),()=>{i.delete(e)}}getRegisteredNode(t){let e=this._nodes.get(t.getType());return e===void 0&&T(!1,"Node %s has not been registered. Ensure node has been passed to createEditor.",t.name),e}resolveRegisteredNodeAfterReplacements(t){for(;t.replaceWithKlass;)t=this.getRegisteredNode(t.replaceWithKlass);return t}initializeMutationListener(t,e){let n=this._editorState,r=pu(n).get(e.getType());if(!r)return;let i=new Map;for(let s of r.keys())i.set(s,"created");i.size>0&&t(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(t,e){let n=this.getRegisteredNode(t);return n.transforms.add(e),n}registerNodeTransform(t,e){let n=this.registerNodeTransformToKlass(t,e),r=[n],i=n.replaceWithKlass;if(i!=null){let s=this.registerNodeTransformToKlass(i,e);r.push(s)}return Oc(this,t.getType()),()=>{r.forEach(s=>s.transforms.delete(e))}}hasNode(t){return this._nodes.has(t.getType())}hasNodes(t){return t.every(this.hasNode.bind(this))}dispatchCommand(t,e){return O(this,t,e)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(t){let e=this._rootElement;if(t!==e){let n=yo(this._config.theme,"root"),r=this._pendingEditorState||this._editorState;if(this._rootElement=t,Oa(this,e,t,r),e!==null&&(this._config.disableEvents||$u(e),n!=null&&e.classList.remove(...n)),t!==null){let i=fu(t),s=t.style;s.userSelect="text",s.whiteSpace="pre-wrap",s.wordBreak="break-word",t.setAttribute("data-lexical-editor","true"),this._window=i,this._dirtyType=Qt,wi(this),this._updateTags.add("history-merge"),Bt(this),this._config.disableEvents||Iu(t,this),n!=null&&t.classList.add(...n)}else this._editorState=r,this._pendingEditorState=null,this._window=null;Xn("root",this,!1,t,e)}}getElementByKey(t){return this._keyToDOMMap.get(t)||null}getEditorState(){return this._editorState}setEditorState(t,e){t.isEmpty()&&T(!1,"setEditorState: the editor state is empty. Ensure the editor state's root node never becomes empty."),Mi(this);let n=this._pendingEditorState,r=this._updateTags,i=e!==void 0?e.tag:null;n!==null&&!n.isEmpty()&&(i!=null&&r.add(i),Bt(this)),this._pendingEditorState=t,this._dirtyType=Qt,this._dirtyElements.set("root",!1),this._compositionKey=null,i!=null&&r.add(i),Bt(this)}parseEditorState(t,e){let n=typeof t=="string"?JSON.parse(t):t;return Af(n,this,e)}read(t){return Bt(this),this.getEditorState().read(t,{editor:this})}update(t,e){Te(this,t,e)}updateAndCommit(t,e){this.update(t,e),this.commitUpdates()}focus(t,e={}){let n=this._rootElement;n!==null&&(n.setAttribute("autocapitalize","off"),Te(this,()=>{let r=C(),i=F();r!==null?r.dirty=!0:i.getChildrenSize()!==0&&(e.defaultSelection==="rootStart"?i.selectStart():i.selectEnd())},{onUpdate:()=>{n.removeAttribute("autocapitalize"),t&&t()},tag:"focus"}),this._pendingEditorState===null&&n.removeAttribute("autocapitalize"))}commitUpdates(){Bt(this)}blur(){let t=this._rootElement;t!==null&&t.blur();let e=ve(this._window);e!==null&&e.removeAllRanges()}isEditable(){return this._editable}setEditable(t){this._editable!==t&&(this._editable=t,Xn("editable",this,!0,t))}setUiContext(t){this._context=t}getUiContext(){return this._context}toJSON(){return{editorState:this._editorState.toJSON()}}};p(ro,"version");ro.version="0.17.1";var is=0,Aa=1,Ra=2,_t=0,Ax=1,Uf=2,Rx=3,kx=4;function Ix(o,t,e){let n=o._nodeMap,r=[];for(let i of t){let s=n.get(i);s!==void 0&&r.push(s)}for(let[i,s]of e){if(!s)continue;let l=n.get(i);l!==void 0&&!ne(l)&&r.push(l)}return r}function $x(o,t,e,n,r){if(o===null||e.size===0&&n.size===0&&!r)return _t;let i=t._selection,s=o._selection;if(r)return Ax;if(!_(i)||!_(s)||!s.isCollapsed()||!i.isCollapsed())return _t;let l=Ix(t,e,n);if(l.length===0)return _t;if(l.length>1){let b=t._nodeMap,x=b.get(i.anchor.key),S=b.get(s.anchor.key);return x&&S&&!o._nodeMap.has(x.__key)&&L(x)&&x.__text.length===1&&i.anchor.offset===1?Uf:_t}let a=l[0],d=o._nodeMap.get(a.__key);if(!L(d)||!L(a)||d.__mode!==a.__mode)return _t;let u=d.__text,m=a.__text;if(u===m)return _t;let c=i.anchor,f=s.anchor;if(c.key!==f.key||c.type!=="text")return _t;let g=c.offset,h=f.offset,N=m.length-u.length;return N===1&&h===g-1?Uf:N===-1&&h===g+1?Rx:N===-1&&h===g?kx:_t}function Px(o,t,e){let n=t._nodeMap.get(o),r=e._nodeMap.get(o),i=t._selection,s=e._selection;return!(_(i)&&_(s)&&i.anchor.type==="element"&&i.focus.type==="element"&&s.anchor.type==="text"&&s.focus.type==="text")&&L(n)&&L(r)&&n.__parent===r.__parent?JSON.stringify(t.read(()=>n.exportJSON()))===JSON.stringify(e.read(()=>r.exportJSON())):!1}function Bx(o,t){let e=Date.now(),n=_t;return(r,i,s,l,a,d)=>{let u=Date.now();if(d.has("historic"))return n=_t,e=u,Ra;let m=$x(r,i,l,a,o.isComposing()),c=(()=>{let f=s===null||s.editor===o,g=d.has("history-push");if(!g&&f&&d.has("history-merge"))return is;if(r===null)return Aa;let N=i._selection;if(!(l.size>0||a.size>0))return N!==null?is:Ra;if(g===!1&&m!==_t&&m===n&&u{let m=t.current,c=t.redoStack,f=t.undoStack,g=m===null?null:m.editorState;if(m!==null&&s===g)return;let h=n(l,s,m,a,d,u);if(h===Aa)c.length!==0&&(t.redoStack=[],o.dispatchCommand(To,!1)),m!==null&&(f.push({...m}),o.dispatchCommand(Co,!0));else if(h===Ra)return;t.current={editor:o,editorState:s}};return Et(o.registerCommand(ho,()=>(Fx(o,t),!0),J),o.registerCommand(No,()=>(Hx(o,t),!0),J),o.registerCommand(yl,()=>(zf(t),!1),J),o.registerCommand(Sl,()=>(zf(t),o.dispatchCommand(To,!1),o.dispatchCommand(Co,!1),!0),J),o.registerUpdateListener(r))}function ls(){return{current:null,redoStack:[],undoStack:[]}}var qf=o=>pe?(o||window).getSelection():null;function Yf(o,t=C()){return t==null&&T(!1,"Expected valid LexicalSelection"),_(t)&&t.isCollapsed()||t.getNodes().length===0?"":Qi(o,t)}function Zf(o,t=C()){return t==null&&T(!1,"Expected valid LexicalSelection"),_(t)&&t.isCollapsed()||t.getNodes().length===0?null:JSON.stringify(Xf(o,t))}function as(o,t,e){let n=o.getData("application/x-lexical-editor");if(n)try{let s=JSON.parse(n);if(s.namespace===e._config.namespace&&Array.isArray(s.nodes)){let l=jf(s.nodes);return ka(e,l,t)}}catch{}let r=o.getData("text/html");if(r)try{let l=new DOMParser().parseFromString(r,"text/html"),a=Ji(e,l);return ka(e,a,t)}catch{}let i=o.getData("text/plain")||o.getData("text/uri-list");if(i!=null)if(_(t)){let s=i.split(/(\r?\n|\t)/);s[s.length-1]===""&&s.pop();for(let l=0;l0?a.text=d:r=!1}for(let d=0;d{o.update(()=>{a(zf(o,t,e))})});let n=o.getRootElement(),r=o._window==null?window.document:o._window.document,i=Wf(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 u=o.registerCommand(xo,m=>(Tt(m,ClipboardEvent)&&(u(),jn!==null&&(window.clearTimeout(jn),jn=null),a(zf(o,m,e))),!0),Ke);jn=window.setTimeout(()=>{u(),jn=null,a(!1)},Ux),r.execCommand("copy"),s.remove()})}function zf(o,t,e){if(e===void 0){let r=Wf(o._window);if(!r)return!1;let i=r.anchorNode,s=r.focusNode;if(i!==null&&s!==null&&!eo(o,i,s))return!1;let l=C();if(l===null)return!1;e=ds(l)}t.preventDefault();let n=t.clipboardData;return n===null?!1:(jf(n,e),!0)}var zx=[["text/html",qf],["application/x-lexical-editor",Yf]];function ds(o=C()){let t={"text/plain":o?o.getTextContent():""};if(o){let e=ql();for(let[n,r]of zx){let i=r(e,o);i!==null&&(t[n]=i)}}return t}function jf(o,t){for(let e in t){let n=t[e];n!==void 0&&o.setData(e,n)}}function cs(o,t){if(typeof document.caretRangeFromPoint<"u"){let e=document.caretRangeFromPoint(o,t);return e===null?null:{node:e.startContainer,offset:e.startOffset}}else if(document.caretPositionFromPoint!=="undefined"){let e=document.caretPositionFromPoint(o,t);return e===null?null:{node:e.offsetNode,offset:e.offset}}else return null}var Gf=$("DRAG_DROP_PASTE_FILE");function Wx(o,t){o.preventDefault(),t.update(()=>{let e=C(),n=Tt(o,InputEvent)||Tt(o,KeyboardEvent)?null:o.clipboardData;n!=null&&e!==null&&as(n,e,t)},{tag:"paste"})}async function qx(o,t){await Gn(t,Tt(o,ClipboardEvent)?o:null),t.update(()=>{let e=C();_(e)?e.removeText():Oe(e)&&e.getNodes().forEach(n=>n.remove())})}function us(o){let t=null;if(Tt(o,DragEvent)?t=o.dataTransfer:Tt(o,ClipboardEvent)&&(t=o.clipboardData),t===null)return[!1,[],!1];let e=t.types,n=e.includes("Files"),r=e.includes("text/html")||e.includes("text/plain");return[n,Array.from(t.files),r]}function fs(o){let t=G(o);return H(t)}function Yx(o){let t=o.focus;return t.key==="root"&&t.offset===F().getChildrenSize()}function ms(o){return Et(o.registerCommand(Wt,e=>{let n=C();return Oe(n)?(n.clear(),!0):!1},0),o.registerCommand(tt,e=>{let n=C();return _(n)?(n.deleteCharacter(e),!0):!1},J),o.registerCommand(Dt,e=>{let n=C();return _(n)?(n.deleteWord(e),!0):!1},J),o.registerCommand(mt,e=>{let n=C();return _(n)?(n.deleteLine(e),!0):!1},J),o.registerCommand(ft,e=>{let n=C();if(typeof e=="string")n!==null&&n.insertText(e);else{if(n===null)return!1;let r=e.dataTransfer;if(r!=null)as(r,n,o);else if(_(n)){let i=e.data;return i&&n.insertText(i),!0}}return!0},J),o.registerCommand(Sn,()=>{let e=C();return _(e)?(e.removeText(),!0):!1},J),o.registerCommand(Ee,e=>{let n=C();return _(n)?(n.formatText(e),!0):!1},J),o.registerCommand(qt,e=>{let n=C();return _(n)?(n.insertLineBreak(e),!0):!1},J),o.registerCommand(Yt,()=>{let e=C();return _(e)?(e.insertParagraph(),!0):!1},J),o.registerCommand(Cl,()=>(Ce([kt()]),!0),J),o.registerCommand(Zt,e=>{let n=C();if(Oe(n)&&!fs(e.target)){let r=n.getNodes();if(r.length>0)return r[0].selectPrevious(),!0}else if(_(n)){let r=oo(n.focus,!0);if(!e.shiftKey&&H(r)&&!r.isIsolated()&&!r.isInline())return r.selectPrevious(),e.preventDefault(),!0}return!1},J),o.registerCommand(Vt,e=>{let n=C();if(Oe(n)){let r=n.getNodes();if(r.length>0)return r[0].selectNext(0,0),!0}else if(_(n)){if(Yx(n))return e.preventDefault(),!0;let r=oo(n.focus,!1);if(!e.shiftKey&&H(r)&&!r.isIsolated()&&!r.isInline())return r.selectNext(),e.preventDefault(),!0}return!1},J),o.registerCommand(Ko,e=>{let n=C();if(Oe(n)){let r=n.getNodes();if(r.length>0)return e.preventDefault(),r[0].selectPrevious(),!0}if(!_(n))return!1;if(Xi(n,!0)){let r=e.shiftKey;return e.preventDefault(),ji(n,r,!0),!0}return!1},J),o.registerCommand(Fo,e=>{let n=C();if(Oe(n)&&!fs(e.target)){let i=n.getNodes();if(i.length>0)return e.preventDefault(),i[0].selectNext(0,0),!0}if(!_(n))return!1;let r=e.shiftKey;return Xi(n,!1)?(e.preventDefault(),ji(n,r,!1),!0):!1},J),o.registerCommand(Xt,e=>{if(fs(e.target))return!1;let n=C();return _(n)?(e.preventDefault(),o.dispatchCommand(tt,!0)):!1},J),o.registerCommand(jt,e=>{if(fs(e.target))return!1;let n=C();return _(n)?(e.preventDefault(),o.dispatchCommand(tt,!1)):!1},J),o.registerCommand(we,e=>{let n=C();if(!_(n))return!1;if(e!==null){if((Ot||Gt||Jt)&&bo)return!1;if(e.preventDefault(),e.shiftKey)return o.dispatchCommand(qt,!1)}return o.dispatchCommand(Yt,void 0)},J),o.registerCommand(Uo,()=>{let e=C();return _(e)?(o.blur(),!0):!1},J),o.registerCommand(Wo,e=>{let[,n]=us(e);if(n.length>0){let i=e.clientX,s=e.clientY,l=cs(i,s);if(l!==null){let{offset:a,node:d}=l,u=G(d);if(u!==null){let m=on();if(L(u))m.anchor.set(u.getKey(),a,"text"),m.focus.set(u.getKey(),a,"text");else{let f=u.getParentOrThrow().getKey(),g=u.getIndexWithinParent()+1;m.anchor.set(f,g,"element"),m.focus.set(f,g,"element")}let c=qo(m);Y(c)}o.dispatchCommand(Gf,n)}return e.preventDefault(),!0}let r=C();return!!_(r)},J),o.registerCommand(Er,e=>{let[n]=us(e),r=C();return!(n&&!_(r))},J),o.registerCommand(Tr,e=>{let[n]=us(e),r=C();if(n&&!_(r))return!1;let i=e.clientX,s=e.clientY,l=cs(i,s);if(l!==null){let a=G(l.node);H(a)&&e.preventDefault()}return!0},J),o.registerCommand(Ln,()=>(zl(),!0),J),o.registerCommand(xo,e=>(Gn(o,Tt(e,ClipboardEvent)?e:null),!0),J),o.registerCommand(Eo,e=>(qx(e,o),!0),J),o.registerCommand(go,e=>{let[,n,r]=us(e);return n.length>0&&!r?(o.dispatchCommand(Gf,n),!0):In(e.target)?!1:C()!==null?(Wx(e,o),!0):!1},J))}var sn=class o extends X{constructor(e,n){super(n);p(this,"__id","");p(this,"__category","info");p(this,"__alignment","");p(this,"__inset",0);this.__category=e}static getType(){return"callout"}static clone(e){let n=new o(e.__category,e.__key);return n.__id=e.__id,n.__alignment=e.__alignment,n.__inset=e.__inset,n}setCategory(e){let n=this.getWritable();n.__category=e}getCategory(){return this.getLatest().__category}setId(e){let n=this.getWritable();n.__id=e}getId(){return this.getLatest().__id}setAlignment(e){let n=this.getWritable();n.__alignment=e}getAlignment(){return this.getLatest().__alignment}setInset(e){let n=this.getWritable();n.__inset=e}getInset(){return this.getLatest().__inset}createDOM(e,n){let r=document.createElement("p");return r.classList.add("callout",this.__category||""),dt(r,this),r}updateDOM(e){return e.__category!==this.__category||Oo(e,this)}insertNewAfter(e,n){let r=e?e.anchor.offset:0,i=r===this.getTextContentSize()||!e?I():Jn(this.__category);if(i.setDirection(this.getDirection()),this.insertAfter(i,n),r===0&&!this.isEmpty()&&e){let s=I();s.select(),this.replace(s,!0)}return i}static importDOM(){return{p(e){return e.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 at(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(e){let n=Jn(e.category);return ct(e,n),n}};function Jn(o="info"){return new sn(o)}function ka(o){return o instanceof sn}function Ia(o,t="info"){return o instanceof sn&&o.getCategory()===t}var ln=class o extends X{constructor(e,n={},r){super(r);p(this,"__url");p(this,"__target");p(this,"__rel");p(this,"__title");let{target:i=null,rel:s=null,title:l=null}=n;this.__url=e,this.__target=i,this.__rel=s,this.__title=l}static getType(){return"link"}static clone(e){return new o(e.__url,{rel:e.__rel,target:e.__target,title:e.__title},e.__key)}createDOM(e){let n=document.createElement("a");return n.href=this.__url,this.__target!==null&&(n.target=this.__target),this.__rel!==null&&(n.rel=this.__rel),this.__title!==null&&(n.title=this.__title),ye(n,e.theme.link),n}updateDOM(e,n,r){if(n instanceof HTMLAnchorElement){let i=this.__url,s=this.__target,l=this.__rel,a=this.__title;i!==e.__url&&(n.href=i),s!==e.__target&&(s?n.target=s:n.removeAttribute("target")),l!==e.__rel&&(l?n.rel=l:n.removeAttribute("rel")),a!==e.__title&&(a?n.title=a:n.removeAttribute("title"))}return!1}static importDOM(){return{a:e=>({conversion:Zx,priority:1})}}static importJSON(e){let n=yt(e.url,{rel:e.rel,target:e.target,title:e.title});return n.setDirection(e.direction),n}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 n=this.getWritable();n.__url=e}getTarget(){return this.getLatest().__target}setTarget(e){let n=this.getWritable();n.__target=e}getRel(){return this.getLatest().__rel}setRel(e){let n=this.getWritable();n.__rel=e}getTitle(){return this.getLatest().__title}setTitle(e){let n=this.getWritable();n.__title=e}insertNewAfter(e,n=!0){let r=yt(this.__url,{rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(r,n),r}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,n,r){if(!_(n))return!1;let i=n.anchor.getNode(),s=n.focus.getNode();return this.isParentOf(i)&&this.isParentOf(s)&&n.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}};function Zx(o){let t=null;if(Pi(o)){let e=o.textContent;(e!==null&&e!==""||o.children.length>0)&&(t=yt(o.getAttribute("href")||"",{rel:o.getAttribute("rel"),target:o.getAttribute("target"),title:o.getAttribute("title")}))}return{node:t}}function yt(o,t){return re(new ln(o,t))}function Ft(o){return o instanceof ln}var bL=$("TOGGLE_LINK_COMMAND");var an=class o extends X{constructor(e,n,r){super(r);p(this,"__src","");p(this,"__alt","");p(this,"__width",0);p(this,"__height",0);p(this,"__alignment","");this.__src=e,n.alt&&(this.__alt=n.alt),n.width&&(this.__width=n.width),n.height&&(this.__height=n.height)}static getType(){return"image"}static clone(e){let n=new o(e.__src,{alt:e.__alt,width:e.__width,height:e.__height},e.__key);return n.__alignment=e.__alignment,n}setSrc(e){let n=this.getWritable();n.__src=e}getSrc(){return this.getLatest().__src}setAltText(e){let n=this.getWritable();n.__alt=e}getAltText(){return this.getLatest().__alt}setHeight(e){let n=this.getWritable();n.__height=e}getHeight(){return this.getLatest().__height}setWidth(e){let n=this.getWritable();n.__width=e}getWidth(){return this.getLatest().__width}setAlignment(e){let n=this.getWritable();n.__alignment=e}getAlignment(){return this.getLatest().__alignment}isInline(){return!0}createDOM(e,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(()=>{this.select()})}),r}updateDOM(e,n){return e.__src!==this.__src&&n.setAttribute("src",this.__src),e.__width!==this.__width&&(this.__width?n.setAttribute("width",String(this.__width)):n.removeAttribute("width")),e.__height!==this.__height&&(this.__height?n.setAttribute("height",String(this.__height)):n.removeAttribute("height")),e.__alt!==this.__alt&&(this.__alt?n.setAttribute("alt",String(this.__alt)):n.removeAttribute("alt")),e.__alignment!==this.__alignment&&(e.__alignment&&n.classList.remove("align-"+e.__alignment),this.__alignment&&n.classList.add("align-"+this.__alignment)),!1}static importDOM(){return{img(e){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(Xr(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(e){let n=dn(e.src,{alt:e.alt,width:e.width,height:e.height});return n.setAlignment(e.alignment),n}};function dn(o,t={}){return new an(o,t)}function Qe(o){return o instanceof an}var Qn=class o extends X{constructor(){super(...arguments);p(this,"__id","");p(this,"__summary","");p(this,"__open",!1)}static getType(){return"details"}setId(e){let n=this.getWritable();n.__id=e}getId(){return this.getLatest().__id}setSummary(e){let n=this.getWritable();n.__summary=e}getSummary(){return this.getLatest().__summary}setOpen(e){let n=this.getWritable();n.__open=e}getOpen(){return this.getLatest().__open}static clone(e){let n=new o(e.__key);return n.__id=e.__id,n.__dir=e.__dir,n.__summary=e.__summary,n.__open=e.__open,n}createDOM(e,n){let r=document.createElement("details");this.__id&&r.setAttribute("id",this.__id),this.__dir&&r.setAttribute("dir",this.__dir),this.__open?(r.setAttribute("open","true"),r.removeAttribute("contenteditable")):r.setAttribute("contenteditable","false");let i=document.createElement("summary");return i.textContent=this.__summary,i.setAttribute("contenteditable","false"),i.addEventListener("click",s=>{s.preventDefault(),n.update(()=>{this.select()})}),r.append(i),r}updateDOM(e,n){return e.__open!==this.__open&&(n.toggleAttribute("open",this.__open),this.__open?n.removeAttribute("contenteditable"):n.setAttribute("contenteditable","false")),e.__id!==this.__id||e.__dir!==this.__dir||e.__summary!==this.__summary}static importDOM(){return{details(e){return{conversion:n=>{let r=new o;n.id&&r.setId(n.id),n.dir&&r.setDirection(jr(n));let i=Array.from(n.children).find(s=>s.nodeName==="SUMMARY");return r.setSummary(i?.textContent||""),{node:r}},priority:3}},summary(e){return{conversion:n=>({node:"ignore"}),priority:3}}}}exportDOM(e){let n=this.createDOM(e._config,e),r=n.querySelectorAll("[contenteditable]");for(let i of r)i.removeAttribute("contenteditable");return n.removeAttribute("open"),n.removeAttribute("contenteditable"),{element:n}}exportJSON(){return{...super.exportJSON(),type:"details",version:1,id:this.__id,summary:this.__summary}}static importJSON(e){let n=$a();return n.setId(e.id),n.setDirection(e.direction),n}shouldSelectDirectly(){return!0}canBeEmpty(){return!1}};function $a(){return new Qn}function ce(o){return o instanceof Qn}function Pa(o){let t=1,e=o.getParent();for(;e!=null;){if(j(e)){let n=e.getParent();if(W(n)){t++,e=n.getParent();continue}T(!1,"A ListItemNode must have a ListNode for a parent.")}return t}return t}function Ba(o){let t=o.getParent();W(t)||T(!1,"A ListItemNode must have a ListNode for a parent.");let e=t;for(;e!==null;)e=e.getParent(),W(e)&&(t=e);return t}function Ha(o){let t=[],e=o.getChildren().filter(j);for(let n=0;n{let e=C();if(e!==null){let n=e.getNodes();if(_(e)){let i=e.getStartEndPoints();T(i!==null,"insertList: anchor should be defined");let[s]=i,l=s.getNode(),a=l.getParent();if(em(l,n)){let d=Se(t);if(ge(a)){l.replace(d);let u=Ue();d.append(u)}else if(j(l)){let u=l.getParentOrThrow();Jr(d,u.getChildren()),u.replace(d)}return}}let r=new Set;for(let i=0;i0&&o.append(...r),t.remove()}function Ka(o){o.update(()=>{let t=C();if(_(t)){let e=new Set,n=t.getNodes(),r=t.anchor.getNode();if(em(r,n))e.add(Ba(r));else for(let i=0;i{if(T(j(e),"node is not a ListItemNode"),e.__checked==null)return;let n=e.getParent();W(n)&&n.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:Vx,priority:0})}}static importJSON(e){let n=Ue();return n.setChecked(e.checked),n.setValue(e.value),n.setDirection(e.direction),n}exportDOM(e){let n=this.createDOM(e._config);if(n.classList.contains("task-list-item")){let r=y("input",{type:"checkbox",disabled:"disabled"});n.hasAttribute("checked")&&(r.setAttribute("checked","checked"),n.removeAttribute("checked")),n.prepend(r)}return{element:n}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(),version:1}}append(...e){for(let n=0;n{e.append(i)})),this.remove(),r.getChildrenSize()===0&&r.remove(),e}insertAfter(e,n=!0){let r=this.getParentOrThrow();if(W(r)||T(!1,"insertAfter: list node is not parent of list item node"),j(e))return super.insertAfter(e,n);let i=this.getNextSiblings();if(r.insertAfter(e,n),i.length!==0){let s=Se(r.getListType());i.forEach(l=>s.append(l)),e.insertAfter(s,n)}return e}remove(e){let n=this.getPreviousSibling(),r=this.getNextSibling();super.remove(e),n&&r&&er(n)&&er(r)&&(ps(n.getFirstChild(),r.getFirstChild()),r.remove())}insertNewAfter(e,n=!0){if(this.getTextContent().trim()===""&&this.isLastChild()){let i=this.getParentOrThrow(),s=i.getParent();if(j(s))return s.insertAfter(this),this.selectStart(),null;{let l=I();return i.insertAfter(l,n),this.remove(),l}}let r=Ue(this.__checked==null?void 0:!1);return this.insertAfter(r,n),r}collapseAtStart(e){let n=I();this.getChildren().forEach(a=>n.append(a));let i=this.getParentOrThrow(),s=i.getParentOrThrow(),l=j(s);if(i.getChildrenSize()===1)if(l)i.remove(),s.select();else{i.insertBefore(n),i.remove();let a=e.anchor,d=e.focus,u=n.getKey();a.type==="element"&&a.getNode().is(this)&&a.set(u,a.offset,"element"),d.type==="element"&&d.getNode().is(this)&&d.set(u,d.offset,"element")}else i.insertBefore(n),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){let n=this.getWritable();n.__value=e}getChecked(){let e=this.getLatest(),n,r=this.getParent();return W(r)&&(n=r.getListType()),n==="check"?!!e.__checked:void 0}setChecked(e){let n=this.getWritable();n.__checked=e}toggleChecked(){this.setChecked(!this.__checked)}canInsertAfter(e){return j(e)}canReplaceWith(e){return j(e)}canMergeWith(e){return Ge(e)||j(e)}extractWithChild(e,n){if(!_(n))return!1;let r=n.anchor.getNode(),i=n.focus.getNode();return this.isParentOf(r)&&this.isParentOf(i)&&this.getTextContent().length===n.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return Se("bullet")}canMergeWhenEmpty(){return!0}};function nm(o){let t=o.getChildren(),e=!1,n=!1;for(let r of t)W(r)?n=!0:r.getTextContent().trim().length>0&&(e=!0);return n&&!e}function rm(o,t){let e=!W(t.getFirstChild());o.classList.toggle("task-list-item",e),t.__checked?o.setAttribute("checked","checked"):o.removeAttribute("checked")}function Vx(o){if(o.classList.contains("task-list-item")){for(let r of o.children)if(r.tagName==="INPUT")return Xx(r)}let e=o.getAttribute("aria-checked");return{node:Ue(e==="true"?!0:e==="false"?!1:void 0)}}function Xx(o){if(!(o.getAttribute("type")==="checkbox"))return{node:null};let e=o.hasAttribute("checked");return{node:Ue(e)}}function Ue(o){return re(new Kt(void 0,o))}function j(o){return o instanceof Kt}var Ro=class o extends X{constructor(e,n,r){super(r);p(this,"__tag");p(this,"__start");p(this,"__listType");p(this,"__id","");let i=Jx[e]||e;this.__listType=i,this.__tag=i==="number"?"ol":"ul",this.__start=n}static getType(){return"list"}static clone(e){let n=new o(e.__listType,e.__start,e.__key);return n.__id=e.__id,n.__dir=e.__dir,n}getTag(){return this.__tag}setId(e){let n=this.getWritable();n.__id=e}getId(){return this.getLatest().__id}setListType(e){let n=this.getWritable();n.__listType=e,n.__tag=e==="number"?"ol":"ul"}getListType(){return this.__listType}getStart(){return this.__start}createDOM(e,n){let r=this.__tag,i=document.createElement(r);return this.__start!==1&&i.setAttribute("start",String(this.__start)),i.__lexicalListType=this.__listType,im(i,e.theme,this),this.__id&&i.setAttribute("id",this.__id),this.__dir&&i.setAttribute("dir",this.__dir),i}updateDOM(e,n,r){return e.__tag!==this.__tag||e.__dir!==this.__dir||e.__id!==this.__id?!0:(im(n,r.theme,this),!1)}static transform(){return e=>{T(W(e),"node is not a ListNode"),om(e),tm(e)}}static importDOM(){return{ol:()=>({conversion:sm,priority:0}),ul:()=>({conversion:sm,priority:0})}}static importJSON(e){let n=Se(e.listType,e.start);return n.setId(e.id),n.setDirection(e.direction),n}exportDOM(e){let{element:n}=super.exportDOM(e);return n&&he(n)&&(this.__start!==1&&n.setAttribute("start",String(this.__start)),this.__listType==="check"&&n.setAttribute("__lexicalListType","check")),{element:n}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag(),type:"list",version:1,id:this.__id}}canBeEmpty(){return!1}canIndent(){return!1}append(...e){for(let n=0;n1?n.push(...g):r.push(...g)}}r.length>0&&Gi(o,...r),n.length>0&&ye(o,...n)}function jx(o){let t=[];for(let e of o)j(e)?t.push(e):t.push(Jf(e));return t}function Gx(o){if(o.getAttribute("__lexicallisttype")==="check"||o.classList.contains("contains-task-list"))return!0;for(let t of o.childNodes)if(he(t)&&(t.hasAttribute("aria-checked")||t.classList.contains("task-list-item")||t.firstElementChild&&t.firstElementChild.matches('input[type="checkbox"]')))return!0;return!1}function sm(o){let t=o.nodeName.toLowerCase(),e=null;if(t==="ol"){let n=o.start;e=Se("number",n)}else t==="ul"&&(Gx(o)?e=Se("check"):e=Se("bullet"));return o.id&&e&&e.setId(o.id),o.dir&&e&&e.setDirection(jr(o)),{after:jx,node:e}}var Jx={ol:"number",ul:"bullet"};function Se(o,t=1){return re(new Ro(o,t))}function W(o){return o instanceof Ro}var GM=$("INSERT_UNORDERED_LIST_COMMAND"),JM=$("INSERT_ORDERED_LIST_COMMAND"),QM=$("INSERT_CHECK_LIST_COMMAND"),ew=$("REMOVE_LIST_COMMAND");var ie={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1},ao=class o extends X{constructor(e=ie.NO_STATUS,n=1,r,i){super(i);p(this,"__colSpan");p(this,"__rowSpan");p(this,"__headerState");p(this,"__width");p(this,"__backgroundColor");p(this,"__styles",new Map);p(this,"__alignment","");this.__colSpan=n,this.__rowSpan=1,this.__headerState=e,this.__width=r,this.__backgroundColor=null}static getType(){return"tablecell"}static clone(e){let n=new o(e.__headerState,e.__colSpan,e.__width,e.__key);return n.__rowSpan=e.__rowSpan,n.__backgroundColor=e.__backgroundColor,n.__styles=new Map(e.__styles),n.__alignment=e.__alignment,n}static importDOM(){return{td:e=>({conversion:lm,priority:0}),th:e=>({conversion:lm,priority:0})}}static importJSON(e){let n=ze(e.headerState,e.colSpan,e.width);return e.rowSpan&&n.setRowSpan(e.rowSpan),n.setStyles(new Map(Object.entries(e.styles))),n.setAlignment(e.alignment),n}createDOM(e){let n=document.createElement(this.getTag());this.__width&&(n.style.width=`${this.__width}px`),this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),this.__backgroundColor!==null&&(n.style.backgroundColor=this.__backgroundColor),ye(n,e.theme.tableCell,this.hasHeader()&&e.theme.tableCellHeader);for(let[r,i]of this.__styles.entries())n.style.setProperty(r,i);return this.__alignment&&n.classList.add("align-"+this.__alignment),n}exportDOM(e){let{element:n}=super.exportDOM(e);return{element:n}}exportJSON(){return{...super.exportJSON(),backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,type:"tablecell",width:this.getWidth(),styles:Object.fromEntries(this.__styles),alignment:this.__alignment}}getColSpan(){return this.__colSpan}setColSpan(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 n=this.getWritable();return n.__headerState=e,this.__headerState}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){let n=this.getWritable();return n.__width=e,this.__width}getWidth(){return this.getLatest().__width}clearWidth(){let e=this.getWritable();e.__width=void 0}getStyles(){let e=this.getLatest();return new Map(e.__styles)}setStyles(e){let n=this.getWritable();n.__styles=new Map(e)}setAlignment(e){let n=this.getWritable();n.__alignment=e}getAlignment(){return this.getLatest().__alignment}updateTag(e){let r=e.toLowerCase()==="th"?ie.ROW:ie.NO_STATUS,i=this.getWritable();i.__headerState=r}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){this.getWritable().__backgroundColor=e}toggleHeaderStyle(e){let n=this.getWritable();return(n.__headerState&e)===e?n.__headerState-=e:n.__headerState+=e,n}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==ie.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||e.__styles!==this.__styles||e.__alignment!==this.__alignment}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}};function lm(o){let t=o,e=o.nodeName.toLowerCase(),n;/^(\d+(?:\.\d+)?)px$/.test(t.style.width)&&(n=parseFloat(t.style.width));let i=ze(e==="th"?ie.ROW:ie.NO_STATUS,t.colSpan,n);i.__rowSpan=t.rowSpan;let s=t.style,l=s.textDecoration.split(" "),a=s.fontWeight==="700"||s.fontWeight==="bold",d=l.includes("line-through"),u=s.fontStyle==="italic",m=l.includes("underline");if(o instanceof HTMLElement){let f=Zn(o);f.delete("background-color"),i.setStyles(f),i.setAlignment(Xr(o))}let c=s.backgroundColor||null;return c&&i.setBackgroundColor(c),{after:f=>(f.length===0&&f.push(I()),f),forChild:(f,g)=>{if(D(g)&&!E(f)){let h=I();return Pe(f)&&f.getTextContent()===` -`?null:(L(f)&&(a&&f.toggleFormat("bold"),d&&f.toggleFormat("strikethrough"),u&&f.toggleFormat("italic"),m&&f.toggleFormat("underline")),h.append(f),h)}return f},node:i}}function ze(o=ie.NO_STATUS,t=1,e){return re(new ao(o,t,e))}function D(o){return o instanceof ao}var Qx=$("INSERT_TABLE_COMMAND");var co=class o extends X{constructor(e){super(e);p(this,"__height");p(this,"__styles",new Map)}static getType(){return"tablerow"}static clone(e){let n=new o(e.__key);return n.__styles=new Map(e.__styles),n}static importDOM(){return{tr:e=>({conversion:eE,priority:0})}}static importJSON(e){let n=cn();return n.setStyles(new Map(Object.entries(e.styles))),n}exportJSON(){return{...super.exportJSON(),type:"tablerow",version:1,styles:Object.fromEntries(this.__styles),height:this.__height||0}}createDOM(e){let n=document.createElement("tr");this.__height&&(n.style.height=`${this.__height}px`);for(let[r,i]of this.__styles.entries())n.style.setProperty(r,i);return ye(n,e.theme.tableRow),n}isShadowRoot(){return!0}getStyles(){let e=this.getLatest();return new Map(e.__styles)}setStyles(e){let n=this.getWritable();n.__styles=new Map(e)}setHeight(e){let n=this.getWritable();return n.__height=e,this.__height}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height||e.__styles!==this.__styles}canBeEmpty(){return!1}canIndent(){return!1}};function eE(o){let t=cn(),n=Qo(o.style.height);return t.setHeight(n),o instanceof HTMLElement&&t.setStyles(Zn(o)),{node:t}}function cn(){return re(new co)}function te(o){return o instanceof co}var tr=class o extends X{static getType(){return"caption"}static clone(t){return new o(t.__key)}createDOM(t,e){return document.createElement("caption")}updateDOM(t,e,n){return!1}isParentRequired(){return!0}canBeEmpty(){return!1}exportJSON(){return{...super.exportJSON(),type:"caption",version:1}}insertDOMIntoParent(t,e){return e.insertBefore(t,e.firstChild),!0}static importJSON(t){return Ua()}static importDOM(){return{caption:t=>({conversion(e){return{node:Ua()}},priority:0})}}};function Ua(){return new tr}function Qr(o){return o instanceof tr}function za(o){for(let t of o.getChildren())if(Qr(t))return!0;return!1}function am(o,t=""){let e=Ua(),n=z(t||" ");e.append(n),o.append(e)}function qa(o,t,e=!0){let n=ti();for(let r=0;ro===ie.BOTH||o===t?t:ie.NO_STATUS;function gs(o=!0){let t=C();T(_(t)||q(t),"Expected a RangeSelection or TableSelection");let e=t.focus.getNode(),[n,,r]=Re(e),[i,s]=ut(r,n,n),l=i[0].length,{startRow:a}=s;if(o){let d=a+n.__rowSpan-1,u=i[d],m=cn();for(let f=0;f1;)if(k-=M.__colSpan,k>=0){let{cell:Z,startRow:se}=x[k];P=Z,B=se}else{N.append(h(v));continue e}P.insertAfter(h(v))}else M.setColSpan(M.__colSpan+1)}g!==null&&ei(g)}function Ya(){let o=C();T(_(o)||q(o),"Expected a RangeSelection or TableSelection");let t=o.anchor.getNode(),e=o.focus.getNode(),[n,,r]=Re(t),[i]=Re(e),[s,l,a]=ut(r,n,i),{startRow:d}=l,{startRow:u}=a,m=u+i.__rowSpan-1;if(s.length===m-d+1){r.remove();return}let c=s[0].length,f=s[m+1],g=r.getChildAtIndex(m+1);for(let h=m;h>=d;h--){for(let b=c-1;b>=0;b--){let{cell:x,startRow:S,startColumn:v}=s[h][b];if(v===b&&(h===d&&S=d&&S+x.__rowSpan-1>m))if(x.setRowSpan(x.__rowSpan-(m-S+1)),T(g!==null,"Expected nextRowNode not to be null"),b===0)Va(g,x);else{let{cell:M}=f[b-1];M.insertAfter(x)}}let N=r.getChildAtIndex(h);T(te(N),"Expected GridNode childAtIndex(%s) to be RowNode",String(h)),N.remove()}if(f!==void 0){let{cell:h}=f[0];ei(h)}else{let h=s[d-1],{cell:N}=h[0];ei(N)}}function Za(){let o=C();T(_(o)||q(o),"Expected a RangeSelection or TableSelection");let t=o.anchor.getNode(),e=o.focus.getNode(),[n,,r]=Re(t),[i]=Re(e),[s,l,a]=ut(r,n,i),{startColumn:d}=l,{startRow:u,startColumn:m}=a,c=Math.min(d,m),f=Math.max(d+n.__colSpan-1,m+i.__colSpan-1),g=f-c+1;if(s[0].length===f-c+1){r.selectPrevious(),r.remove();return}let N=s.length;for(let S=0;Sf){if(v===f){let A=f-R+1;M.setColSpan(M.__colSpan-A)}}else M.remove()}let b=s[u],x=d>m?b[d+n.__colSpan]:b[m+i.__colSpan];if(x!==void 0){let{cell:S}=x;ei(S)}else{let S=m1){for(let l=1;l1){let[l,a]=ut(r,e,e),{startColumn:d,startRow:u}=a,m;for(let c=1;c1&&(N+=x.__colSpan-1)}if(h===null)for(let N=0;N!Qr(d));for(let d=0;dx||h>S;){if(cx){let A=S-b,P=x+1;for(let B=0;B<=A;B++)v(d[b+B][P]);x=P}if(h>S){let A=x-N,P=S+1;for(let B=0;B<=A;B++)v(d[P][N+B]);S=P}}let M=[l],R=null;for(let A=f;A<=h;A++)for(let P=c;P<=g;P++){let{cell:B}=d[A][P],k=B.getParent();T(te(k),"Expected TableCellNode parent to be a TableRowNode"),k!==R&&M.push(k),M.push(B,...tE(B)),R=k}return pt()||(this._cachedNodes=M),M}getTextContent(){let t=this.getNodes().filter(n=>D(n)),e="";for(let n=0;n0;){let n=e.pop();T(n!==void 0,"Stack.length > 0; can't be undefined"),E(n)&&e.unshift(...n.getChildren()),n!==o&&t.push(n)}return t}var ni=class{constructor(t,e){p(this,"focusX");p(this,"focusY");p(this,"listenersToRemove");p(this,"table");p(this,"isHighlightingCells");p(this,"anchorX");p(this,"anchorY");p(this,"tableNodeKey");p(this,"anchorCell");p(this,"focusCell");p(this,"anchorCellNodeKey");p(this,"focusCellNodeKey");p(this,"editor");p(this,"tableSelection");p(this,"hasHijackedSelectionStyles");p(this,"isSelecting");this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=e,this.editor=t,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(t=>t())}trackTable(){let t=new MutationObserver(e=>{this.editor.update(()=>{let n=!1;for(let i=0;i{let e=this.editor.getElementByKey(this.tableNodeKey);if(!e)throw new Error("Expected to find TableElement in DOM");this.table=un(e),t.observe(e,{attributes:!0,childList:!0,subtree:!0})})}clearHighlight(){let t=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(),t.update(()=>{let e=ee(this.tableNodeKey);if(!K(e))throw new Error("Expected TableNode.");let n=t.getElementByKey(this.tableNodeKey);if(!n)throw new Error("Expected to find TableElement in DOM");let r=un(n);oi(t,r,null),Y(null),t.dispatchCommand(_e,void 0)})}enableHighlightStyle(){let t=this.editor;t.update(()=>{let e=t.getElementByKey(this.tableNodeKey);if(!e)throw new Error("Expected to find TableElement in DOM");Gi(e,t._config.theme.tableSelection),e.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1})}disableHighlightStyle(){let t=this.editor;t.update(()=>{let e=t.getElementByKey(this.tableNodeKey);if(!e)throw new Error("Expected to find TableElement in DOM");ye(e,t._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0})}updateTableTableSelection(t){if(t!==null&&t.tableKey===this.tableNodeKey){let e=this.editor;this.tableSelection=t,this.isHighlightingCells=!0,this.disableHighlightStyle(),oi(e,this.table,this.tableSelection)}else t==null?this.clearHighlight():(this.tableNodeKey=t.tableKey,this.updateTableTableSelection(t))}setFocusCellForSelection(t,e=!1){let n=this.editor;n.update(()=>{let r=ee(this.tableNodeKey);if(!K(r))throw new Error("Expected TableNode.");if(!n.getElementByKey(this.tableNodeKey))throw new Error("Expected to find TableElement in DOM");let s=t.x,l=t.y;if(this.focusCell=t,this.anchorCell!==null){let a=ja(n._window);a&&a.setBaseAndExtent(this.anchorCell.elem,0,this.focusCell.elem,0)}if(!this.isHighlightingCells&&(this.anchorX!==s||this.anchorY!==l||e))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=G(t.elem);if(this.tableSelection!=null&&this.anchorCellNodeKey!=null&&D(a)&&r.is(ko(a))){let d=a.getKey();this.tableSelection=this.tableSelection.clone()||Es(),this.focusCellNodeKey=d,this.tableSelection.set(this.tableNodeKey,this.anchorCellNodeKey,this.focusCellNodeKey),Y(this.tableSelection),n.dispatchCommand(_e,void 0),oi(n,this.table,this.tableSelection)}}})}setAnchorCellForSelection(t){this.isHighlightingCells=!1,this.anchorCell=t,this.anchorX=t.x,this.anchorY=t.y,this.editor.update(()=>{let e=G(t.elem);if(D(e)){let n=e.getKey();this.tableSelection=this.tableSelection!=null?this.tableSelection.clone():Es(),this.anchorCellNodeKey=n}})}formatCells(t){this.editor.update(()=>{let e=C();q(e)||T(!1,"Expected grid selection");let n=on(),r=n.anchor,i=n.focus;e.getNodes().forEach(s=>{D(s)&&s.getTextContentSize()!==0&&(r.set(s.getKey(),0,"element"),i.set(s.getKey(),s.getChildrenSize(),"element"),n.formatText(t))}),Y(e),this.editor.dispatchCommand(_e,void 0)})}clearText(){let t=this.editor;t.update(()=>{let e=ee(this.tableNodeKey);if(!K(e))throw new Error("Expected TableNode.");let n=C();q(n)||T(!1,"Expected grid selection");let r=n.getNodes().filter(D);if(r.length===this.table.columns*this.table.rows){e.selectPrevious(),e.remove(),F().selectStart();return}r.forEach(i=>{if(E(i)){let s=I(),l=z();s.append(l),i.append(s),i.getChildren().forEach(a=>{a!==s&&a.remove()})}}),oi(t,this.table,null),Y(null),t.dispatchCommand(_e,void 0)})}};var oE="__lexicalTableSelection",ja=o=>pe?(o||window).getSelection():null,nE=o=>(o.buttons&1)===1;function Qa(o,t,e,n){let r=e.getRootElement();if(r===null)throw new Error("No root element.");let i=new ni(e,o.getKey()),s=e._window||window;rE(t,i);let l=()=>{let c=()=>{i.isSelecting=!1,s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",f)},f=g=>{setTimeout(()=>{if(!nE(g)&&i.isSelecting){i.isSelecting=!1,s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",f);return}let h=Ja(g.target);h!==null&&(i.anchorX!==h.x||i.anchorY!==h.y)&&(g.preventDefault(),i.setFocusCellForSelection(h))},0)};return{onMouseMove:f,onMouseUp:c}};t.addEventListener("mousedown",c=>{setTimeout(()=>{if(c.button!==0||!s)return;let f=Ja(c.target);f!==null&&(mn(c),i.setAnchorCellForSelection(f));let{onMouseUp:g,onMouseMove:h}=l();i.isSelecting=!0,s.addEventListener("mouseup",g),s.addEventListener("mousemove",h)},0)});let a=c=>{c.button===0&&e.update(()=>{let f=C(),g=c.target;q(f)&&f.tableKey===i.tableNodeKey&&r.contains(g)&&i.clearHighlight()})};s.addEventListener("mousedown",a),i.listenersToRemove.add(()=>s.removeEventListener("mousedown",a)),i.listenersToRemove.add(e.registerCommand(Vt,c=>ri(e,c,"down",o,i),Je)),i.listenersToRemove.add(e.registerCommand(Zt,c=>ri(e,c,"up",o,i),Je)),i.listenersToRemove.add(e.registerCommand(Ko,c=>ri(e,c,"backward",o,i),Je)),i.listenersToRemove.add(e.registerCommand(Fo,c=>ri(e,c,"forward",o,i),Je)),i.listenersToRemove.add(e.registerCommand(Uo,c=>{let f=C();if(q(f)){let g=U(f.focus.getNode(),D);if(D(g))return mn(c),g.selectEnd(),!0}return!1},Je));let d=c=>()=>{let f=C();if(!fn(f,o))return!1;if(q(f))return i.clearText(),!0;if(_(f)){let g=U(f.anchor.getNode(),R=>D(R));if(!D(g))return!1;let h=f.anchor.getNode(),N=f.focus.getNode(),b=o.isParentOf(h),x=o.isParentOf(N);if(b&&!x||x&&!b)return i.clearText(),!0;let v=U(f.anchor.getNode(),R=>E(R)),M=v&&U(v,R=>E(R)&&D(R.getParent()));if(!E(M)||!E(v))return!1;if(c===mt&&M.getPreviousSibling()===null)return!0}return!1};[Dt,mt,tt].forEach(c=>{i.listenersToRemove.add(e.registerCommand(c,d(c),Ke))});let u=c=>{let f=C();if(!fn(f,o)){let g=f?f.getNodes():null;if(g){let h=g.find(N=>K(N)&&N.getKey()===i.tableNodeKey);if(K(h)){if(!h.getParent())return!1;h.remove()}}return!1}if(q(f))return c&&(c.preventDefault(),c.stopPropagation()),i.clearText(),!0;if(_(f)){let g=U(f.anchor.getNode(),h=>D(h));if(!D(g))return!1}return!1};i.listenersToRemove.add(e.registerCommand(Xt,u,Ke)),i.listenersToRemove.add(e.registerCommand(jt,u,Ke)),i.listenersToRemove.add(e.registerCommand(Eo,c=>{let f=C();if(f){if(!(q(f)||_(f)))return!1;Gn(e,Tt(c,ClipboardEvent)?c:null,ds(f));let g=u(c);return _(f)&&f.removeText(),g}return!1},Ke)),i.listenersToRemove.add(e.registerCommand(Ee,c=>{let f=C();if(!fn(f,o))return!1;if(q(f))return i.formatCells(c),!0;if(_(f)){let g=U(f.anchor.getNode(),h=>D(h));if(!D(g))return!1}return!1},Ke)),i.listenersToRemove.add(e.registerCommand(ft,c=>{let f=C();if(!fn(f,o))return!1;if(q(f))return i.clearHighlight(),!1;if(_(f)){let g=U(f.anchor.getNode(),h=>D(h));if(!D(g))return!1;if(typeof c=="string"){let h=fm(e,f,o);if(h)return um(h,o,[z(c)]),!0}}return!1},Ke)),n&&i.listenersToRemove.add(e.registerCommand(zo,c=>{let f=C();if(!_(f)||!f.isCollapsed()||!fn(f,o))return!1;let g=Cs(f.anchor.getNode());if(g===null)return!1;mn(c);let h=o.getCordsFromCellNode(g,i.table);return mm(i,o,h.x,h.y,c.shiftKey?"backward":"forward"),!0},Ke)),i.listenersToRemove.add(e.registerCommand(Cr,c=>o.isSelected(),Je));function m(c){let f=o.getCordsFromCellNode(c,i.table);return o.getDOMCellFromCordsOrThrow(f.x,f.y,i.table)}return i.listenersToRemove.add(e.registerCommand(Nr,c=>{let{nodes:f,selection:g}=c,h=g.getStartEndPoints(),N=q(g),x=_(g)&&U(g.anchor.getNode(),qe=>D(qe))!==null&&U(g.focus.getNode(),qe=>D(qe))!==null||N;if(f.length!==1||!K(f[0])||!x||h===null)return!1;let[S]=h,v=f[0],M=v.getChildren(),R=v.getFirstChildOrThrow().getChildrenSize(),A=v.getChildrenSize(),P=U(S.getNode(),qe=>D(qe)),B=P&&U(P,qe=>te(qe)),k=B&&U(B,qe=>K(qe));if(!D(P)||!te(B)||!K(k))return!1;let Z=B.getIndexWithinParent(),se=Math.min(k.getChildrenSize()-1,Z+A-1),We=P.getIndexWithinParent(),oc=Math.min(B.getChildrenSize()-1,We+R-1),Qh=Math.min(We,oc),eN=Math.min(Z,se),tN=Math.max(We,oc),oN=Math.max(Z,se),nN=k.getChildren(),nc=0;for(let qe=eN;qe<=oN;qe++){let rc=nN[qe];if(!te(rc))return!1;let ic=M[nc];if(!te(ic))return!1;let rN=rc.getChildren(),iN=ic.getChildren(),sc=0;for(let hl=Qh;hl<=tN;hl++){let bi=rN[hl];if(!D(bi))return!1;let lc=iN[sc];if(!D(lc))return!1;let sN=bi.getChildren();lc.getChildren().forEach(yn=>{L(yn)&&I().append(yn),bi.append(yn)}),sN.forEach(yn=>yn.remove()),sc++}nc++}return!0},Ke)),i.listenersToRemove.add(e.registerCommand(_e,()=>{let c=C(),f=je();if(_(c)){let{anchor:g,focus:h}=c,N=g.getNode(),b=h.getNode(),x=Cs(N),S=Cs(b),v=!!(x&&o.is(ko(x))),M=!!(S&&o.is(ko(S))),R=v!==M,A=v&&M,P=c.isBackward();if(R){let B=c.clone();if(M){let[k]=ut(o,S,S),Z=k[0][0].cell,se=k[k.length-1].at(-1).cell;B.focus.set(P?Z.getKey():se.getKey(),P?Z.getChildrenSize():se.getChildrenSize(),"element")}Y(B),cm(e,i)}else A&&(x.is(S)||(i.setAnchorCellForSelection(m(x)),i.setFocusCellForSelection(m(S),!0),i.isSelecting||setTimeout(()=>{let{onMouseUp:B,onMouseMove:k}=l();i.isSelecting=!0,s.addEventListener("mouseup",B),s.addEventListener("mousemove",k)},0)))}else if(c&&q(c)&&c.is(f)&&c.tableKey===o.getKey()){let g=ja(e._window);if(g&&g.anchorNode&&g.focusNode){let h=G(g.focusNode),N=h&&!o.is(ko(h)),b=G(g.anchorNode),x=b&&o.is(ko(b));if(N&&x&&g.rangeCount>0){let S=Sa(g,e);S&&(S.anchor.set(o.getKey(),c.isBackward()?o.getChildrenSize():0,"element"),g.removeAllRanges(),Y(S))}}}return c&&!c.is(f)&&(q(c)||q(f))&&i.tableSelection&&!i.tableSelection.is(f)?(q(c)&&c.tableKey===i.tableNodeKey?i.updateTableTableSelection(c):!q(c)&&q(f)&&f.tableKey===i.tableNodeKey&&i.updateTableTableSelection(null),!1):(i.hasHijackedSelectionStyles&&!o.isSelected()?iE(e,i):!i.hasHijackedSelectionStyles&&o.isSelected()&&cm(e,i),!1)},Ke)),i.listenersToRemove.add(e.registerCommand(Yt,()=>{let c=C();if(!_(c)||!c.isCollapsed()||!fn(c,o))return!1;let f=fm(e,c,o);return f?(um(f,o),!0):!1},Ke)),i}function rE(o,t){o[oE]=t}function Ja(o){let t=o;for(;t!=null;){let e=t.nodeName;if(e==="TD"||e==="TH"){let n=t._cell;return n===void 0?null:n}t=t.parentNode}return null}function un(o){let t=[],e={columns:0,domRows:t,rows:0},n=o.firstChild,r=0,i=0;for(t.length=0;n!=null;){let s=n.nodeName;if(s==="COLGROUP"||s==="CAPTION"){n=n.nextSibling;continue}if(s==="TD"||s==="TH"){let d=n,u={elem:d,hasBackgroundColor:d.style.backgroundColor!=="",highlighted:!1,x:r,y:i};n._cell=u;let m=t[i];m===void 0&&(m=t[i]=[]),m[r]=u}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 e.columns=r+1,e.rows=i+1,e}function oi(o,t,e){let n=new Set(e?e.getNodes():[]);ed(t,(r,i)=>{let s=r.elem;n.has(i)?(r.highlighted=!0,pm(o,r)):(r.highlighted=!1,gm(o,r),s.getAttribute("style")||s.removeAttribute("style"))})}function ed(o,t){let{domRows:e}=o;for(let n=0;n{e.highlighted=!0,pm(o,e)})}function iE(o,t){t.enableHighlightStyle(),ed(t.table,e=>{let n=e.elem;e.highlighted=!1,gm(o,e),n.getAttribute("style")||n.removeAttribute("style")})}var mm=(o,t,e,n,r)=>{let i=r==="forward";switch(r){case"backward":case"forward":return e!==(i?o.table.columns-1:0)?Ts(t.getCellNodeFromCordsOrThrow(e+(i?1:-1),n,o.table),i):n!==(i?o.table.rows-1:0)?Ts(t.getCellNodeFromCordsOrThrow(i?0:o.table.columns-1,n+(i?1:-1),o.table),i):i?t.selectNext():t.selectPrevious(),!0;case"up":return n!==0?Ts(t.getCellNodeFromCordsOrThrow(e,n-1,o.table),!1):qr(t,!1),!0;case"down":return n!==o.table.rows-1?Ts(t.getCellNodeFromCordsOrThrow(e,n+1,o.table),!0):qr(t,!0),!0;default:return!1}},sE=(o,t,e,n,r)=>{let i=r==="forward";switch(r){case"backward":case"forward":return e!==(i?o.table.columns-1:0)&&o.setFocusCellForSelection(t.getDOMCellFromCordsOrThrow(e+(i?1:-1),n,o.table)),!0;case"up":return n!==0?(o.setFocusCellForSelection(t.getDOMCellFromCordsOrThrow(e,n-1,o.table)),!0):!1;case"down":return n!==o.table.rows-1?(o.setFocusCellForSelection(t.getDOMCellFromCordsOrThrow(e,n+1,o.table)),!0):!1;default:return!1}};function fn(o,t){if(_(o)||q(o)){let e=t.isParentOf(o.anchor.getNode()),n=t.isParentOf(o.focus.getNode());return e&&n}return!1}function Ts(o,t){t?o.selectStart():o.selectEnd()}var Ga="172,206,247";function pm(o,t){let e=t.elem,n=G(e);T(D(n),"Expected to find LexicalNode from Table Cell DOMNode"),n.getBackgroundColor()===null?e.style.setProperty("background-color",`rgb(${Ga})`):e.style.setProperty("background-image",`linear-gradient(to right, rgba(${Ga},0.85), rgba(${Ga},0.85))`),e.style.setProperty("caret-color","transparent")}function gm(o,t){let e=t.elem,n=G(e);T(D(n),"Expected to find LexicalNode from Table Cell DOMNode"),n.getBackgroundColor()===null&&e.style.removeProperty("background-color"),e.style.removeProperty("background-image"),e.style.removeProperty("caret-color")}function Cs(o){let t=U(o,D);return D(t)?t:null}function ko(o){let t=U(o,K);return K(t)?t:null}function ri(o,t,e,n,r){if((e==="up"||e==="down")&&lE(o))return!1;let i=C();if(!fn(i,n)){if(_(i)){if(i.isCollapsed()&&e==="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=U(a,m=>E(m)&&!m.isInline());if(!d)return!1;let u=d.getPreviousSibling();return!u||!K(u)?!1:(mn(t),u.selectEnd(),!0)}else if(t.shiftKey&&(e==="up"||e==="down")){let s=i.focus.getNode();if(ge(s)){let l=i.getNodes()[0];if(l){let a=U(l,D);if(a&&n.isParentOf(a)){let d=n.getFirstDescendant(),u=n.getLastDescendant();if(!d||!u)return!1;let[m]=Re(d),[c]=Re(u),f=n.getCordsFromCellNode(m,r.table),g=n.getCordsFromCellNode(c,r.table),h=n.getDOMCellFromCordsOrThrow(f.x,f.y,r.table),N=n.getDOMCellFromCordsOrThrow(g.x,g.y,r.table);return r.setAnchorCellForSelection(h),r.setFocusCellForSelection(N,!0),!0}}return!1}else{let l=U(s,d=>E(d)&&!d.isInline());if(!l)return!1;let a=e==="down"?l.getNextSibling():l.getPreviousSibling();if(K(a)&&r.tableNodeKey===a.getKey()){let d=a.getFirstDescendant(),u=a.getLastDescendant();if(!d||!u)return!1;let[m]=Re(d),[c]=Re(u),f=i.clone();return f.focus.set((e==="up"?m:c).getKey(),e==="up"?0:c.getChildrenSize(),"element"),Y(f),!0}}}}return!1}if(_(i)&&i.isCollapsed()){let{anchor:s,focus:l}=i,a=U(s.getNode(),D),d=U(l.getNode(),D);if(!D(a)||!a.is(d))return!1;let u=ko(a);if(u!==n&&u!=null){let x=o.getElementByKey(u.getKey());if(x!=null)return r.table=un(x),ri(o,t,e,u,r)}if(e==="backward"||e==="forward"){let x=s.type,S=s.offset,v=s.getNode();if(!v)return!1;let M=i.getNodes();return M.length===1&&H(M[0])?!1:aE(x,S,v,e)?uE(t,v,n,e):!1}let m=o.getElementByKey(a.__key),c=o.getElementByKey(s.key);if(c==null||m==null)return!1;let f;if(s.type==="element")f=c.getBoundingClientRect();else{let x=window.getSelection();if(x===null||x.rangeCount===0)return!1;f=x.getRangeAt(0).getBoundingClientRect()}let g=e==="up"?a.getFirstChild():a.getLastChild();if(g==null)return!1;let h=o.getElementByKey(g.__key);if(h==null)return!1;let N=h.getBoundingClientRect();if(e==="up"?N.top>f.top-f.height:f.bottom+f.height>N.bottom){mn(t);let x=n.getCordsFromCellNode(a,r.table);if(t.shiftKey){let S=n.getDOMCellFromCordsOrThrow(x.x,x.y,r.table);r.setAnchorCellForSelection(S),r.setFocusCellForSelection(S,!0)}else return mm(r,n,x.x,x.y,e);return!0}}else if(q(i)){let{anchor:s,focus:l}=i,a=U(s.getNode(),D),d=U(l.getNode(),D),[u]=i.getNodes(),m=o.getElementByKey(u.getKey());if(!D(a)||!D(d)||!K(u)||m==null)return!1;r.updateTableTableSelection(i);let c=un(m),f=n.getCordsFromCellNode(a,c),g=n.getDOMCellFromCordsOrThrow(f.x,f.y,c);if(r.setAnchorCellForSelection(g),mn(t),t.shiftKey){let h=n.getCordsFromCellNode(d,c);return sE(r,u,h.x,h.y,e)}else d.selectEnd();return!0}return!1}function mn(o){o.preventDefault(),o.stopImmediatePropagation(),o.stopPropagation()}function lE(o){let t=o.getRootElement();return t?t.hasAttribute("aria-controls")&&t.getAttribute("aria-controls")==="typeahead-menu":!1}function aE(o,t,e,n){return dE(o,e,n)||cE(o,t,e,n)}function dE(o,t,e){return o==="element"&&(e==="backward"?t.getPreviousSibling()===null:t.getNextSibling()===null)}function cE(o,t,e,n){let r=U(e,s=>E(s)&&!s.isInline());if(!r)return!1;let i=n==="backward"?t===0:t===e.getTextContentSize();return o==="text"&&i&&(n==="backward"?r.getPreviousSibling()===null:r.getNextSibling()===null)}function uE(o,t,e,n){let r=U(t,D);if(!D(r))return!1;let[i,s]=ut(e,r,r);if(!fE(i,s,n))return!1;let l=mE(t,n,e);return!l||K(l)?!1:(mn(o),n==="backward"?l.selectEnd():l.selectStart(),!0)}function fE(o,t,e){let n=o[0][0],r=o[o.length-1][o[0].length-1],{startColumn:i,startRow:s}=t;return e==="backward"?i===n.startColumn&&s===n.startRow:i===r.startColumn&&s===r.startRow}function mE(o,t,e){let n=U(o,i=>E(i)&&!i.isInline());if(!n)return;let r=t==="backward"?n.getPreviousSibling():n.getNextSibling();return r&&K(r)?r:t==="backward"?e.getPreviousSibling():e.getNextSibling()}function um(o,t,e){let n=I();o==="first"?t.insertBefore(n):t.insertAfter(n),n.append(...e||[]),n.selectEnd()}function fm(o,t,e){let n=e.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=U(t.anchor.getNode(),N=>D(N));if(!s)return;let l=U(s,N=>K(N));if(!K(l)||!l.is(e))return;let[a,d]=ut(e,s,s),u=a[0][0],m=a[a.length-1][a[0].length-1],{startRow:c,startColumn:f}=d,g=c===u.startRow&&f===u.startColumn,h=c===m.startRow&&f===m.startColumn;return g?"first":h?"last":void 0}var Ut=class{constructor(t){p(this,"rowCount",0);p(this,"columnCount",0);p(this,"cells",[]);this.buildCellMap(t)}buildCellMap(t){let e=[],n=(a,d,u)=>{typeof e[d]>"u"&&(e[d]=[]),e[d][a]=u},r=(a,d)=>!!(e[d]&&e[d][a]),i=t.getChildren().filter(a=>te(a));for(let a=0;aD(c)),m=0;for(let c=0;ca.length));let s=[],l=e[0][0];for(let a=0;a=this.cells.length)throw new Error(`TableMap Error: Attempted to get cell ${n+1} of ${this.cells.length}`);return this.cells[n]}getCellsInRange(t){let e=Math.max(Math.min(t.fromX,t.toX),0),n=Math.min(Math.max(t.fromX,t.toX),this.columnCount-1),r=Math.max(Math.min(t.fromY,t.toY),0),i=Math.min(Math.max(t.fromY,t.toY),this.rowCount-1),s=new Set;for(let l=r;l<=i;l++)for(let a=e;a<=n;a++)s.add(this.getCellAtPosition(a,l));return[...s.values()]}getCellsInColumn(t){return this.getCellsInRange({fromX:t,toX:t,fromY:0,toY:this.rowCount-1})}getRangeForCell(t){let e=null,n=t.getKey();for(let r=0;re&&(n=r,e=r.childElementCount);return n}function hm(o){return[...o.children].map(t=>pE(t))}function pE(o){let t=o.style.width||o.getAttribute("width");return t&&!Number.isNaN(Number(t))&&(t=t+"px"),t||""}function od(o,t,e){let n=o.getChildren(),r=0;for(let s of n){let l=s.getChildren().length;l>r&&(r=l)}let i=o.getColWidths();(i.length===0||i.lengthi.length&&console.error(`Attempted to set table column width for column [${t}] but only ${i.length} columns found`),i[t]=Ct(e),o.setColWidths(i)}function Em(o,t,e){let n=t.getColWidths();if(n.length>e&&n[e].endsWith("px"))return Number(n[e].replace("px",""));let r=o.getElementByKey(t.__key);if(r){let i=xm(r);if(i&&i.children.length>e)return i.children[e].clientWidth}return 0}function Tm(o){let t=o.getParent();if(!te(t))return-1;let e=0,n=t.getChildren();for(let r of n){let i=r.getColSpan()||1;if(e+=i,r.getKey()===o.getKey())break}return e-1}function Cm(o,t){let e=td(o),n=Tm(o);e&&n>=0&&od(e,n,t)}function bm(o,t){let e=td(t),n=Tm(t);if(!e)return"";let r=e.getColWidths();return r.length>n?r[n]:""}function nd(o){if(o.length===0)return null;let t=y("colgroup");for(let e of o){let n=y("col");e&&(n.style.width=e),t.append(n)}return t}function pn(o){if(q(o))return o.getNodes().filter(n=>D(n));let t=V(o,D);return t?[t]:[]}function _m(o){let t=o.getShape(),e=pn(o);if(e.length===0)return;let n=td(e[0]);if(!n)return;let r=new Ut(n),i=r.getCellAtPosition(t.toX,t.toY);if(!i)return;let s=t.toX+((i.getColSpan()||1)-1),l=t.toY+((i.getRowSpan()||1)-1),a=r.getCellsInRange({fromX:t.fromX,fromY:t.fromY,toX:s,toY:l});if(a.length===0)return;let d=a[0],u=Math.abs(t.fromX-s)+1,m=Math.abs(t.fromY-l)+1;for(let c=1;cD(r));for(let r of n){let i=r.getStyles();i.delete("height"),i.delete("width"),r.setStyles(i),r.clearWidth()}}}function Sm(o){o.setColWidths([]),o.setStyles(new Map);for(let t of o.getChildren()){if(!te(t))continue;t.setStyles(new Map);let e=t.getChildren().filter(n=>D(n));for(let n of e)n.setStyles(new Map),n.setBackgroundColor(null),n.clearWidth()}}function rd(o,t){e:for(let e of o.getChildren()){if(!te(e))continue;let n=e.getChildren();for(let r of n){if(!D(r))return;if(t(r)===!1)break e}}}function Lm(o){let t=null;return rd(o,e=>{let n=e.getStyles().get("padding")||"";if(t===null&&(t=n),n!==t)return t=null,!1}),t||""}var Lt=class o extends Ht{constructor(e){super(e);p(this,"__colWidths",[]);p(this,"__styles",new Map)}static getType(){return"table"}static clone(e){let n=new o(e.__key);return Ao(e,n),n.__colWidths=[...e.__colWidths],n.__styles=new Map(e.__styles),n}static importDOM(){return{table:e=>({conversion:gE,priority:1})}}static importJSON(e){let n=ti();return ct(e,n),n.setColWidths(e.colWidths),n.setStyles(new Map(Object.entries(e.styles))),n}exportJSON(){return{...super.exportJSON(),type:"table",version:1,colWidths:this.__colWidths,styles:Object.fromEntries(this.__styles)}}createDOM(e,n){let r=document.createElement("table");ye(r,e.theme.table),dt(r,this);let i=this.getColWidths(),s=nd(i);s&&r.append(s);for(let[l,a]of this.__styles.entries())r.style.setProperty(l,a);return r}updateDOM(e,n){if(Ff(e,this,n),this.__colWidths.join(":")!==e.__colWidths.join(":")){let r=Array.from(n.children).find(s=>s.nodeName==="COLGROUP"),i=nd(this.__colWidths);r&&r.remove(),i&&n.prepend(i)}if(Array.from(this.__styles.values()).join(":")!==Array.from(e.__styles.values()).join(":")){n.style.cssText="";for(let[r,i]of this.__styles.entries())n.style.setProperty(r,i)}return!1}exportDOM(e){return{...super.exportDOM(e),after:n=>{if(!n)return;let r=n.cloneNode(),i=document.createElement("tbody");if(he(n))for(let s of Array.from(n.children))s.nodeName==="TR"?i.append(s):s.nodeName==="CAPTION"?r.insertBefore(s,r.firstChild):r.append(s);return r.append(i),r}}}canBeEmpty(){return!1}isShadowRoot(){return!0}setColWidths(e){let n=this.getWritable();n.__colWidths=e}getColWidths(){return[...this.getLatest().__colWidths]}getStyles(){let e=this.getLatest();return new Map(e.__styles)}setStyles(e){let n=this.getWritable();n.__styles=new Map(e)}getCordsFromCellNode(e,n){let{rows:r,domRows:i}=n;for(let s=0;s{if(!d)return;let{elem:u}=d;return G(u)===e});if(a!==-1)return{x:a,y:s}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,n,r){let{domRows:i}=r,s=i[n];if(s==null)return null;let l=e{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(e){let n=id();return n.setId(e.id),n}};function id(){return new or}function Mm(o){return o instanceof or}var wm=o=>(o.split(" ").filter(e=>e.startsWith("language-"))[0]||"").replace("language-",""),gn=class o extends lt{constructor(e="",n="",r){super(r);p(this,"__id","");p(this,"__language","");p(this,"__code","");this.__language=e,this.__code=n}static getType(){return"code-block"}static clone(e){let n=new o(e.__language,e.__code,e.__key);return n.__id=e.__id,n}setLanguage(e){let n=this.getWritable();n.__language=e}getLanguage(){return this.getLatest().__language}setCode(e){let n=this.getWritable();n.__code=e}getCode(){return this.getLatest().__code}setId(e){let n=this.getWritable();n.__id=e}getId(){return this.getLatest().__id}decorate(e,n){return{type:"code",getNode:()=>this}}isInline(){return!1}isIsolated(){return!0}createDOM(e,n){let r=y("pre",{id:this.__id||null},[y("code",{class:this.__language?`language-${this.__language}`:null},[this.__code])]);return y("div",{class:"editor-code-block-wrap"},[r])}updateDOM(e,n){let r=n.querySelector("code");return r&&(e.__language!==this.__language&&(r.className=this.__language?`language-${this.__language}`:""),e.__id!==this.__id&&n.setAttribute("id",this.__id),e.__code!==this.__code&&(r.textContent=this.__code)),!1}exportDOM(e){return{element:this.createDOM(e._config,e).querySelector("pre")}}static importDOM(){return{pre(e){return{conversion:n=>{let r=n.querySelector("code"),i=wm(n.className)||r&&wm(r.className)||"",s=r?(r.textContent||"").trim():(n.textContent||"").trim(),l=bs(i,s);return n.id&&l.setId(n.id),{node:l,after(a){return[]}}},priority:3}}}}exportJSON(){return{type:"code-block",version:1,id:this.__id,language:this.__language,code:this.__code}}static importJSON(e){let n=bs(e.language,e.code);return n.setId(e.id||""),n}};function bs(o="",t=""){return new gn(o,t)}function _s(o){return o instanceof gn}function ii(o,t){let e=t.getCode(),n=t.getLanguage();window.$components.first("code-editor").open(e,n,"ltr",(i,s)=>{o.update(()=>{t.setCode(i),t.setLanguage(s)})},()=>{})}var Io=class o extends lt{constructor(e,n,r){super(r);p(this,"__id","");p(this,"__drawingId","");p(this,"__drawingUrl","");this.__drawingId=e,this.__drawingUrl=n}static getType(){return"diagram"}static clone(e){let n=new o(e.__drawingId,e.__drawingUrl);return n.__id=e.__id,n}setDrawingIdAndUrl(e,n){let r=this.getWritable();r.__drawingUrl=n,r.__drawingId=e}getDrawingIdAndUrl(){let e=this.getLatest();return{id:e.__drawingId,url:e.__drawingUrl}}setId(e){let n=this.getWritable();n.__id=e}getId(){return this.getLatest().__id}decorate(e,n){return{type:"diagram",getNode:()=>this}}isInline(){return!1}isIsolated(){return!0}createDOM(e,n){return y("div",{id:this.__id||null,"drawio-diagram":this.__drawingId},[y("img",{src:this.__drawingUrl})])}updateDOM(e,n){let r=n.querySelector("img");return r&&(e.__id!==this.__id&&n.setAttribute("id",this.__id),e.__drawingUrl!==this.__drawingUrl&&r.setAttribute("src",this.__drawingUrl),e.__drawingId!==this.__drawingId&&n.setAttribute("drawio-diagram",this.__drawingId)),!1}static importDOM(){return{div(e){return e.hasAttribute("drawio-diagram")?{conversion:n=>{let i=n.querySelector("img")?.getAttribute("src")||"",s=n.getAttribute("drawio-diagram")||"",l=nr(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(e){let n=nr(e.drawingId,e.drawingUrl);return n.setId(e.id||""),n}};function nr(o="",t=""){return new Io(o,t)}var hE=["width","height","style","title","name","src","allow","allowfullscreen","loading","sandbox","type","data","controls","autoplay","controlslist","loop","muted","playsinline","poster","preload"];function NE(o){let t={};for(let e of Object.keys(o))hE.includes(e)&&(t[e]=o[e]);return t}function ys(o,t){let e=Object.assign({},o);if(!o.style)return e;let n=Na(o.style);return n.delete(t),e.style=tf(n),e}function vm(o,t){let e=Dm(o),n={};for(let i of t.attributes)n[i.name]=i.value;e.setAttributes(n);let r=[];if(o==="video"||o==="audio"){for(let i of t.children)if(i.tagName==="SOURCE"){let s=i.getAttribute("src"),l=i.getAttribute("type");s&&l&&r.push({src:s,type:l})}e.setSources(r)}return at(t,e),e}var $o=class o extends X{constructor(e,n){super(n);p(this,"__id","");p(this,"__alignment","");p(this,"__tag");p(this,"__attributes",{});p(this,"__sources",[]);p(this,"__inset",0);this.__tag=e}static getType(){return"media"}static clone(e){let n=new o(e.__tag,e.__key);return n.__attributes=Object.assign({},e.__attributes),n.__sources=e.__sources.map(r=>Object.assign({},r)),n.__id=e.__id,n.__alignment=e.__alignment,n.__inset=e.__inset,n}setTag(e){let n=this.getWritable();n.__tag=e}getTag(){return this.getLatest().__tag}setAttributes(e){let n=this.getWritable();n.__attributes=NE(e)}getAttributes(){let e=this.getLatest();return Object.assign({},e.__attributes)}setSources(e){let n=this.getWritable();n.__sources=e}getSources(){return this.getLatest().__sources.map(n=>Object.assign({},n))}setSrc(e){let n=this.getAttributes(),r=this.getSources();this.__tag==="object"&&(n.data=e),this.__tag==="video"&&r.length>0?(r[0].src=e,delete n.src,r.length>1&&r.splice(1,r.length-1),this.setSources(r)):n.src=e,this.setAttributes(n)}setWidthAndHeight(e,n){let r=Object.assign(this.getAttributes(),{width:e,height:n});r=ys(r,"width"),r=ys(r,"height"),this.setAttributes(r)}setId(e){let n=this.getWritable();n.__id=e}getId(){return this.getLatest().__id}setAlignment(e){let n=this.getWritable();n.__alignment=e}getAlignment(){return this.getLatest().__alignment}setInset(e){let n=this.getWritable();n.__inset=e}getInset(){return this.getLatest().__inset}setHeight(e){if(!e)return;let n=Object.assign(this.getAttributes(),{height:e});this.setAttributes(ys(n,"height"))}getHeight(){let e=this.getLatest();return Qo(e.__attributes.height||"0")}setWidth(e){let n=this.getAttributes(),r=Object.assign(n,{width:e});this.setAttributes(ys(r,"width"))}getWidth(){let e=this.getLatest();return Qo(e.__attributes.width||"0")}isInline(){return!0}isParentRequired(){return!0}createInnerDOM(){let n=(this.__tag==="video"||this.__tag==="audio"?this.__sources:[]).map(i=>y("source",i)),r=y(this.__tag,this.__attributes,n);return dt(r,this),r}createDOM(e,n){let r=this.createInnerDOM();return y("span",{class:r.className+" editor-media-wrap"},[r])}updateDOM(e,n){if(e.__tag!==this.__tag||JSON.stringify(e.__sources)!==JSON.stringify(this.__sources)||JSON.stringify(e.__attributes)!==JSON.stringify(this.__attributes))return!0;let r=n.firstElementChild;return e.__id!==this.__id&&of(r,"id",this.__id),e.__alignment!==this.__alignment&&(e.__alignment&&(n.classList.remove(`align-${e.__alignment}`),r.classList.remove(`align-${e.__alignment}`)),this.__alignment&&(n.classList.add(`align-${this.__alignment}`),r.classList.add(`align-${this.__alignment}`))),e.__inset!==this.__inset&&(n.style.paddingLeft=`${this.__inset}px`),!1}static importDOM(){let e=n=>r=>({conversion:i=>({node:vm(n,i)}),priority:3});return{iframe:e("iframe"),embed:e("embed"),object:e("object"),video:e("video"),audio:e("audio")}}exportDOM(e){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(e){let n=Dm(e.tag);return ct(e,n),n}};function Dm(o){return new $o(o)}function Om(o){let n=new DOMParser().parseFromString(`${o}`,"text/html").body.children[0];if(!(n instanceof HTMLElement))return null;let r=n.tagName.toLowerCase();return["embed","iframe","video","audio","object"].includes(r)?vm(r,n):null}var xE=[{regex:/.*?youtu\.be\/([\w\-_\?&=.]+)/i,w:560,h:314,url:"https://www.youtube.com/embed/$1"},{regex:/.*youtube\.com(.+)v=([^&]+)(&([a-z0-9&=\-_]+))?.*/i,w:560,h:314,url:"https://www.youtube.com/embed/$2?$4"},{regex:/.*youtube.com\/embed\/([a-z0-9\?&=\-_]+).*/i,w:560,h:314,url:"https://www.youtube.com/embed/$1"}],EE=["mp4","mpeg","m4v","m4p","mov"],TE=["3gp","aac","flac","mp3","m4a","ogg","wav","webm"],CE=["html","htm","php","asp","aspx",""];function Am(o){for(let s of xE)if(o.match(s.regex)){let a=o.replace(s.regex,s.url),d=new $o("iframe");return d.setSrc(a),d.setHeight(s.h),d.setWidth(s.w),d}let t="iframe",n=(o.split("?")[0].split("/").pop()||"").split("."),r=(n.length>1?n[n.length-1]:"").toLowerCase();EE.includes(r)?t="video":TE.includes(r)?t="audio":r&&!CE.includes(r)&&(t="embed");let i=new $o(t);return i.setSrc(o),i}function Mt(o){return o instanceof $o}var sr=class o extends Ht{constructor(e,n){super(n);p(this,"__tag");this.__tag=e}static getType(){return"heading"}static clone(e){let n=new o(e.__tag,e.__key);return Ao(e,n),n}getTag(){return this.__tag}createDOM(e){let n=this.__tag,r=document.createElement(n),s=e.theme.heading;if(s!==void 0){let l=s[n];ye(r,l)}return dt(r,this),r}updateDOM(e,n){return Oo(e,this)}static importDOM(){return{h1:e=>({conversion:rr,priority:0}),h2:e=>({conversion:rr,priority:0}),h3:e=>({conversion:rr,priority:0}),h4:e=>({conversion:rr,priority:0}),h5:e=>({conversion:rr,priority:0}),h6:e=>({conversion:rr,priority:0})}}exportDOM(e){let{element:n}=super.exportDOM(e);return n&&he(n)&&this.isEmpty()&&n.append(document.createElement("br")),{element:n}}static importJSON(e){let n=ir(e.tag);return ct(e,n),n}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(e,n=!0){let r=e?e.anchor.offset:0,i=this.getLastDescendant(),l=!i||e&&e.anchor.key===i.getKey()&&r===i.getTextContentSize()||!e?I():ir(this.getTag()),a=this.getDirection();if(l.setDirection(a),this.insertAfter(l,n),r===0&&!this.isEmpty()&&e){let d=I();d.select(),this.replace(d,!0)}return l}collapseAtStart(){let e=this.isEmpty()?I():ir(this.getTag());return this.getChildren().forEach(r=>e.append(r)),this.replace(e),!0}extractWithChild(){return!0}};function rr(o){let t=o.nodeName.toLowerCase(),e=null;return(t==="h1"||t==="h2"||t==="h3"||t==="h4"||t==="h5"||t==="h6")&&(e=ir(t),at(o,e)),{node:e}}function ir(o){return re(new sr(o))}function lr(o){return o instanceof sr}var ar=class o extends Ht{static getType(){return"quote"}static clone(t){let e=new o(t.__key);return Ao(t,e),e}constructor(t){super(t)}createDOM(t){let e=document.createElement("blockquote");return ye(e,t.theme.quote),dt(e,this),e}updateDOM(t,e){return Oo(t,this)}static importDOM(){return{blockquote:t=>({conversion:bE,priority:0})}}exportDOM(t){let{element:e}=super.exportDOM(t);return e&&he(e)&&this.isEmpty()&&e.append(document.createElement("br")),{element:e}}static importJSON(t){let e=Ss();return ct(t,e),e}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(t,e){let n=I(),r=this.getDirection();return n.setDirection(r),this.insertAfter(n,e),n}collapseAtStart(){let t=I();return this.getChildren().forEach(n=>t.append(n)),this.replace(t),!0}canMergeWhenEmpty(){return!0}};function Ss(){return re(new ar)}function Ls(o){return o instanceof ar}function bE(o){let t=Ss();return at(o,t),{node:t}}var dr=class o extends lt{constructor(){super(...arguments);p(this,"__user_id",0);p(this,"__user_name","");p(this,"__user_slug","")}static getType(){return"mention"}static clone(e){let n=new o(e.__key);return n.__user_id=e.__user_id,n.__user_name=e.__user_name,n.__user_slug=e.__user_slug,n}setUserDetails(e,n,r){let i=this.getWritable();i.__user_id=e,i.__user_name=n,i.__user_slug=r}hasUserSet(){return this.__user_id>0}isInline(){return!0}isParentRequired(){return!0}decorate(e,n){return{type:"mention",getNode:()=>this}}createDOM(e,n){let r=document.createElement("a");return r.setAttribute("target","_blank"),r.setAttribute("href",window.baseUrl("/user/"+this.__user_slug)),r.setAttribute("data-mention-user-id",String(this.__user_id)),r.setAttribute("title","@"+this.__user_name),r.textContent="@"+this.__user_name,r}updateDOM(e){return e.__user_id!==this.__user_id}static importDOM(){return{a(e){return e.hasAttribute("data-mention-user-id")?{conversion:n=>{let r=new o;return r.setUserDetails(Number(n.getAttribute("data-mention-user-id")||"0"),n.innerText.replace(/^@/,""),n.getAttribute("href")?.split("/user/")[1]||""),{node:r,after(i){return[]}}},priority:4}:null}}}exportJSON(){return{type:"mention",version:1,user_id:this.__user_id,user_name:this.__user_name,user_slug:this.__user_slug}}static importJSON(e){return sd(e.user_id,e.user_name,e.user_slug)}};function sd(o,t,e){let n=new dr;return n.setUserDetails(o,t,e),n}function Rm(o){return o instanceof dr}function km(){return[sn,sr,ar,Ro,Kt,Lt,co,ao,tr,an,or,Qn,gn,Io,$o,it,ln]}function ld(){return[Ro,Kt,it,ln]}function Im(){return[...ld(),dr]}function $m(o){let t=[an,gn,Io],e=n=>{for(let[r,i]of n)if(i==="destroyed"){let s=o.manager.getDecoratorByNodeKey(r);s&&s.teardown()}};for(let n of t)o.editor.registerMutationListener(n,r=>e(r))}function ad(o){return"build"in o}var ke=class{constructor(){p(this,"dom",null);p(this,"context",null);p(this,"abortController",new AbortController)}setContext(t){this.context=t}getContext(){if(this.context===null)throw new Error("Attempted to use EditorUIContext before it has been set");return this.context}getDOMElement(){return this.dom||(this.dom=this.buildDOM()),this.dom}rebuildDOM(){let t=this.buildDOM();return this.dom?.replaceWith(t),this.dom=t,this.dom}trans(t){return this.getContext().translate(t)}updateState(t){}emitEvent(t,e={}){this.dom&&this.dom.dispatchEvent(new CustomEvent("editor::"+t,{detail:e,bubbles:!0}))}onEvent(t,e,n=null){let r=n||this.dom;r&&r.addEventListener("editor::"+t,(i=>{e(i.detail)}),{signal:this.abortController.signal})}teardown(){this.dom&&this.dom.isConnected&&this.dom.remove(),this.abortController.abort("teardown")}},oe=class extends ke{constructor(e){super();p(this,"children",[]);this.children.push(...e)}buildDOM(){return y("div",{},this.getChildren().map(e=>e.getDOMElement()))}getChildren(){return this.children}addChildren(...e){this.children.push(...e)}removeChildren(...e){for(let n of e)this.removeChild(n)}removeChild(e){let n=this.children.indexOf(e);n!==-1&&this.children.splice(n,1)}updateState(e){for(let n of this.children)n.updateState(e)}setContext(e){super.setContext(e);for(let n of this.getChildren())n.setContext(e)}teardown(){for(let e of this.children)e.teardown();super.teardown()}},si=class extends oe{constructor(e,n){super(n);p(this,"className");this.className=e}buildDOM(){return y("div",{class:this.className},this.getChildren().map(e=>e.getDOMElement()))}};function Pm(o,t,e){let n=null;return function(...i){let s=this,l=function(){n=null,e||o.apply(s,i)},a=e&&!n;n&&clearTimeout(n),n=window.setTimeout(l,t),a&&o.apply(s,i)}}function Bm(){let o=()=>((1+Math.random())*65536|0).toString(16).substring(1);return`${o()+o()}-${o()}-${o()}-${o()}-${o()}${o()}${o()}`}function Ms(){return((1+Math.random())*65536|0).toString(16).substring(1)}var zt=class extends ke{constructor(e){super();p(this,"definition");this.definition=e}setValue(e){let n=this.getDOMElement().querySelector("input,select,textarea");this.definition.type==="checkbox"?n.checked=!!e:n.value=e,n.dispatchEvent(new Event("change"))}getName(){return this.definition.name}buildDOM(){let e=`editor-form-field-${this.definition.name}-${Date.now()}`,n;if(this.definition.type==="select"){let r=this.definition.valuesByLabel,s=Object.keys(r).map(l=>y("option",{value:r[l]},[this.trans(l)]));n=y("select",{id:e,name:this.definition.name,class:"editor-form-field-input"},s)}else if(this.definition.type==="textarea")n=y("textarea",{id:e,name:this.definition.name,class:"editor-form-field-input"});else if(this.definition.type==="checkbox")n=y("input",{id:e,name:this.definition.name,type:"checkbox",class:"editor-form-field-input-checkbox",value:"true"});else{if(this.definition.type==="hidden")return n=y("input",{id:e,name:this.definition.name,type:"hidden"}),y("div",{hidden:"true"},[n]);n=y("input",{id:e,name:this.definition.name,class:"editor-form-field-input"})}return y("div",{class:"editor-form-field-wrapper"},[y("label",{class:"editor-form-field-label",for:e},[this.trans(this.definition.label)]),n])}},ws=class extends oe{constructor(e){let n=e.fields.map(r=>ad(r)?r.build():new zt(r));super(n);p(this,"definition");p(this,"onCancel",null);p(this,"onSuccessfulSubmit",null);this.definition=e}focusOnFirst(){let e=this.getDOMElement().querySelector("input,select,textarea");e&&e.focus()}setValues(e){for(let n of Object.keys(e)){let r=this.getFieldByName(n);r&&r.setValue(e[n])}}setOnCancel(e){this.onCancel=e}setOnSuccessfulSubmit(e){this.onSuccessfulSubmit=e}getFieldByName(e){let n=r=>{for(let i of r){if(i instanceof zt&&i.getName()===e)return i;if(i instanceof oe){let s=n(i.getChildren());if(s)return s}}return null};return n(this.getChildren())}buildDOM(){let e=y("button",{type:"button",class:"editor-form-action-secondary"},[this.trans("Cancel")]),n=y("form",{},[...this.children.map(r=>r.getDOMElement()),y("div",{class:"editor-form-actions"},[e,y("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()}),e.addEventListener("click",r=>{this.onCancel&&this.onCancel()}),n}},dd=class extends oe{constructor(e){let n=e.contents.map(r=>ad(r)?r.build():new zt(r));super(n);p(this,"definition");p(this,"fields");p(this,"id");this.definition=e,this.fields=n,this.id=Bm()}getLabel(){return this.getContext().translate(this.definition.label)}getId(){return this.id}buildDOM(){return y("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()))}},hn=class extends oe{constructor(e){let n=e.map(r=>new dd(r));super(n);p(this,"definitions",[]);p(this,"tabs",[]);this.definitions=e,this.tabs=n}buildDOM(){let e=[],n=[],r=i=>{for(let s=0;s{r(e.indexOf(s))})}return r(0),y("div",{class:"editor-form-tab-container"},[y("div",{class:"editor-form-tab-controls"},e),y("div",{class:"editor-form-tab-contents"},n)])}};var Hm='';var vs=class extends oe{constructor(e,n){super([new ws(e.form)]);p(this,"definition");p(this,"key");p(this,"originalFocus",null);this.definition=e,this.key=n}show(e){this.originalFocus=document.activeElement;let n=this.getDOMElement();document.body.append(n);let r=this.getForm();r.setValues(e),r.setOnCancel(this.hide.bind(this)),r.setOnSuccessfulSubmit(this.hide.bind(this)),this.getContext().manager.setModalActive(this.key,this),r.focusOnFirst()}hide(){this.getContext().manager.setModalInactive(this.key),this.teardown(),this.originalFocus instanceof HTMLElement&&this.originalFocus.isConnected&&this.originalFocus.focus()}getForm(){return this.children[0]}buildDOM(){let e=y("button",{class:"editor-modal-close",type:"button",title:this.trans("Close")});e.innerHTML=Hm,e.addEventListener("click",this.hide.bind(this));let n=y("div",{class:"editor-modal editor-form-modal"},[y("div",{class:"editor-modal-header"},[y("div",{class:"editor-modal-title"},[this.trans(this.definition.title)]),e]),y("div",{class:"editor-modal-body"},[this.getForm().getDOMElement()])]),r=y("div",{class:"editor-modal-wrapper"},[n]);return r.addEventListener("click",i=>{i.target&&!n.contains(i.target)&&this.hide()}),r.addEventListener("keydown",i=>{i.key==="Escape"&&this.hide()}),r}};var Ds=class extends oe{constructor(e,n){super(n);p(this,"target");this.target=e}buildDOM(){return y("div",{class:"editor-context-toolbar"},this.getChildren().map(e=>e.getDOMElement()))}updatePosition(){let e=this.getContext().scrollDOM.getBoundingClientRect(),n=this.target.getBoundingClientRect(),r=this.getDOMElement(),i=r.getBoundingClientRect(),s=n.bottom>e.top&&n.tope.bottom;r.classList.toggle("is-above",l);let d=n.left+n.width/2-i.width/2;l?r.style.top=n.top-6-i.height+"px":r.style.top=n.bottom+6+"px",r.style.left=d+"px"}insert(e){this.addChildren(...e),this.getDOMElement().append(...e.map(r=>r.getDOMElement()))}};function yE(o,t,e){let n=t.getBoundingClientRect(),r=o.getBoundingClientRect();if(o.style.position="fixed",e){let i=n.right;n.right+r.width>window.innerWidth&&(i=Math.max(n.left-r.width,0)),o.style.top=n.top+"px",o.style.left=i+"px"}else{let i=n.left+r.width>window.innerWidth,s=n.left;i&&(s=Math.max(n.right-r.width,0)),o.style.top=n.bottom+"px",o.style.left=s+"px"}}var Os=class{constructor(){p(this,"dropdownOptions",new WeakMap);p(this,"openDropdowns",new Set);this.onMenuMouseOver=this.onMenuMouseOver.bind(this),this.onWindowClick=this.onWindowClick.bind(this),window.addEventListener("click",this.onWindowClick)}teardown(){window.removeEventListener("click",this.onWindowClick)}onWindowClick(t){let e=t.target;this.closeAllNotContainingElement(e)}closeAllNotContainingElement(t){for(let e of this.openDropdowns)e.parentElement?.contains(t)||this.closeDropdown(e)}onMenuMouseOver(t){let e=t.target;this.closeAllNotContainingElement(e)}closeAll(){for(let t of this.openDropdowns)this.closeDropdown(t)}closeDropdown(t){t.hidden=!0,t.style.removeProperty("position"),t.style.removeProperty("left"),t.style.removeProperty("top"),this.openDropdowns.delete(t),t.removeEventListener("mouseover",this.onMenuMouseOver);let e=this.getOptions(t).onClose;e&&e()}openDropdown(t){let{toggle:e,showAside:n,onOpen:r}=this.getOptions(t);t.hidden=!1,yE(t,e,!!n),this.openDropdowns.add(t),t.addEventListener("mouseover",this.onMenuMouseOver),r&&r()}getOptions(t){let e=this.dropdownOptions.get(t);if(!e)throw new Error("Can't find options for dropdown menu");return e}handle(t){let{menu:e,toggle:n,showOnHover:r}=t;this.dropdownOptions.set(e,t);let i=s=>{e.hasAttribute("hidden")?this.openDropdown(e):this.closeDropdown(e)};n.addEventListener("click",i),r&&n.addEventListener("mouseenter",()=>{this.openDropdown(e)})}};var As=class{constructor(){p(this,"dropdowns",new Os);p(this,"modalDefinitionsByKey",{});p(this,"activeModalsByKey",{});p(this,"decoratorConstructorsByType",{});p(this,"decoratorInstancesByNodeKey",{});p(this,"context",null);p(this,"toolbar",null);p(this,"contextToolbarDefinitionsByKey",{});p(this,"activeContextToolbars",[]);p(this,"selectionChangeHandlers",new Set);p(this,"domEventAbortController",new AbortController);p(this,"teardownCallbacks",[])}setContext(t){this.context=t,this.setupEventListeners(),this.setupEditor(t.editor)}getContext(){if(this.context===null)throw new Error("Context attempted to be used without being set");return this.context}triggerStateUpdateForElement(t){t.updateState({selection:null,editor:this.getContext().editor})}registerModal(t,e){this.modalDefinitionsByKey[t]=e}createModal(t){let e=this.modalDefinitionsByKey[t];if(!e)throw new Error(`Attempted to show modal of key [${t}] but no modal registered for that key`);let n=new vs(e,t);return n.setContext(this.getContext()),n}setModalActive(t,e){this.activeModalsByKey[t]=e}setModalInactive(t){delete this.activeModalsByKey[t]}getActiveModal(t){return this.activeModalsByKey[t]}registerDecoratorType(t,e){this.decoratorConstructorsByType[t]=e}getDecorator(t,e){if(this.decoratorInstancesByNodeKey[e])return this.decoratorInstancesByNodeKey[e];let n=this.decoratorConstructorsByType[t];if(!n)throw new Error(`Attempted to use decorator of type [${t}] but not decorator registered for that type`);let r=new n(this.getContext());return this.decoratorInstancesByNodeKey[e]=r,r}getDecoratorByNodeKey(t){return this.decoratorInstancesByNodeKey[t]||null}setToolbar(t){this.toolbar&&this.toolbar.teardown(),this.toolbar=t,t.setContext(this.getContext()),this.getContext().containerDOM.prepend(t.getDOMElement())}getToolbar(){return this.toolbar}registerContextToolbar(t,e){this.contextToolbarDefinitionsByKey[t]=e}triggerStateUpdate(t){af(t.editor,t.selection),this.toolbar?.updateState(t),this.updateContextToolbars(t);for(let e of this.activeContextToolbars)e.updateState(t);this.triggerSelectionChange(t.selection)}triggerStateRefresh(){let t=this.getContext().editor,e={editor:t,selection:ae(t)};this.triggerStateUpdate(e),this.updateContextToolbars(e)}triggerFutureStateRefresh(){requestAnimationFrame(()=>{this.getContext().editor.getEditorState().read(()=>{this.triggerStateRefresh()})})}triggerSelectionChange(t){if(t)for(let e of this.selectionChangeHandlers)e(t)}onSelectionChange(t){this.selectionChangeHandlers.add(t)}offSelectionChange(t){this.selectionChangeHandlers.delete(t)}triggerLayoutUpdate(){window.requestAnimationFrame(()=>{for(let t of this.activeContextToolbars)t.updatePosition()})}getDefaultDirection(){return this.getContext().options.textDirection==="rtl"?"rtl":"ltr"}onTeardown(t){this.teardownCallbacks.push(t)}teardown(){this.domEventAbortController.abort("teardown");for(let[t,e]of Object.entries(this.activeModalsByKey))e.teardown();for(let[t,e]of Object.entries(this.decoratorInstancesByNodeKey))e.teardown();this.toolbar&&this.toolbar.teardown();for(let t of this.activeContextToolbars)t.teardown();this.dropdowns.teardown();for(let t of this.teardownCallbacks)t()}focus(){this.getContext().editorDOM.focus(),this.getContext().editor.focus()}updateContextToolbars(t){for(let s=this.activeContextToolbars.length-1;s>=0;s--)this.activeContextToolbars[s].teardown(),this.activeContextToolbars.splice(s,1);let e=(t.selection?.getNodes()||[])[0]||null;if(!e)return;let n=t.editor.getElementByKey(e.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 Ds(s,l);a.setContext(this.getContext()),this.activeContextToolbars.push(a),this.getContext().containerDOM.append(a.getDOMElement()),a.updatePosition()}}setupEditor(t){let e=n=>{t.getEditorState().read(()=>{let r=Object.keys(n);for(let i of r){let s=t.getElementByKey(i);if(!s)continue;let l=n[i],a=this.getDecorator(l.type,i);a.setNode(l.getNode());let d=a.render(s);d&&s.append(d)}})};t.registerDecoratorListener(e),t.registerUpdateListener(({editorState:n,prevEditorState:r})=>{!r._selection?.is(n._selection)&&t.update(()=>{let s=C();this.triggerStateUpdate({editor:t,selection:s})})})}setupEventListeners(){let t=this.triggerLayoutUpdate.bind(this);window.addEventListener("scroll",t,{capture:!0,passive:!0,signal:this.domEventAbortController.signal}),window.addEventListener("resize",t,{passive:!0,signal:this.domEventAbortController.signal})}};function Rs(o,t,e){let n=y("div",{contenteditable:"true",class:`editor-content-area ${e.editorClass||""}`}),r=y("div",{class:"editor-content-wrap"},[n]);o.append(r),o.classList.add("editor-container"),o.setAttribute("dir",e.textDirection),e.darkMode&&o.classList.add("editor-dark");let i=new As,s={editor:t,containerDOM:o,editorDOM:n,scrollDOM:r,manager:i,translate(l){return e.translations[l]||l},error(l){let a=l instanceof Error?l.message:l;window.$events.error(a)},options:e};return i.setContext(s),s}function Po(o,t){o.update(()=>{let e=F();for(let r of e.getChildren())r.remove(!0);let n=en(o,t);e.append(...n)})}function ks(o,t){o.update(()=>{let e=F(),n=en(o,t);e.append(...n)})}function Is(o,t){o.update(()=>{let e=F(),n=en(o,t),r=e.getChildren()[0];for(let i=n.length-1;i>=0;i--)r?r.insertBefore(n[i]):e.append(n[i]),r=n[i]})}function $s(o,t){o.update(()=>{let e=C(),n=xa(o,t),r=e?.getNodes()[0],i=!1,s=r?bt(r):null;for(let l=n.length-1;l>=0;l--){let a=n[l];It(a)&&s?i?s.insertBefore(a):s.insertAfter(a):It(a)?F().append(a):i?r?.insertBefore(a):(Ce([a]),r=a,s=bt(r),i=!0)}})}function Ps(o){return new Promise((t,e)=>{o.getEditorState().read(()=>{let n=Qi(o);t(n)})})}function Bs(o){o.focus(()=>{},{defaultSelection:"rootStart"})}var cr=class{constructor(t,e,n){p(this,"container");p(this,"dragTargetSelector");p(this,"options");p(this,"startX",0);p(this,"startY",0);p(this,"target",null);this.container=t,this.dragTargetSelector=e,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(t){this.target=t.target.closest(this.dragTargetSelector),this.target&&(this.startX=t.screenX,this.startY=t.screenY,window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("mouseup",this.onMouseUp),this.options.down&&this.options.down(t,this.target))}onMouseMove(t){this.options.move&&this.target&&this.options.move(t,this.target,{x:t.screenX-this.startX,y:t.screenY-this.startY})}onMouseUp(t){window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp),this.options.up&&this.target&&this.options.up(t,this.target,{x:t.screenX-this.startX,y:t.screenY-this.startY})}};var cd=class{constructor(t,e){p(this,"editor");p(this,"editScrollContainer");p(this,"markerDom",null);p(this,"mouseTracker",null);p(this,"dragging",!1);p(this,"targetCell",null);p(this,"xMarkerAtStart",!1);p(this,"yMarkerAtStart",!1);p(this,"activeInTable",!1);this.editor=t,this.editScrollContainer=e,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.onTableMouseOver=this.onTableMouseOver.bind(this),this.onCellMouseMove=this.onCellMouseMove.bind(this),this.onScrollOrResize=this.onScrollOrResize.bind(this),this.editScrollContainer.addEventListener("mouseover",this.onTableMouseOver,{passive:!0}),window.addEventListener("scroll",this.onScrollOrResize,{capture:!0,passive:!0}),window.addEventListener("resize",this.onScrollOrResize,{passive:!0})}onScrollOrResize(){this.updateCurrentMarkerTargetPosition()}onTableMouseOver(t){if(this.dragging)return;let e=t.target.closest("table");e&&!this.activeInTable?(this.editScrollContainer.addEventListener("mousemove",this.onCellMouseMove,{passive:!0}),this.onCellMouseMove(t),this.activeInTable=!0):!e&&this.activeInTable&&(this.editScrollContainer.removeEventListener("mousemove",this.onCellMouseMove),this.hideMarkers(),this.activeInTable=!1)}onCellMouseMove(t){let e=t.target.closest("td,th");if(!e||this.dragging)return;let n=e.getBoundingClientRect(),r=n.left+n.width/2,i=n.top+n.height/2;this.targetCell=e,this.xMarkerAtStart=t.clientX<=r,this.yMarkerAtStart=t.clientY<=i;let s=this.xMarkerAtStart?n.left:n.right,l=this.yMarkerAtStart?n.top:n.bottom;this.updateMarkersTo(e,s,l)}updateMarkersTo(t,e,n){let r=this.getMarkers(),i=t.closest("table"),s=i.querySelector("caption"),l=i.getBoundingClientRect(),a=this.editScrollContainer.getBoundingClientRect(),d=l.top;s&&(d=s.getBoundingClientRect().bottom);let u=Math.max(d,a.top),c=Math.min(l.bottom,a.bottom)-u;r.x.style.left=e+"px",r.x.style.top=u+"px",r.x.style.height=c+"px",r.y.style.top=n+"px",r.y.style.left=l.left+"px",r.y.style.width=l.width+"px",r.y.hidden=na.bottom,r.x.hidden=l.top>a.bottom||l.bottom0?d-=1:e.xMarkerAtStart&&d===0&&(u=-u),e.editor.update(()=>{let m=G(a);if(m instanceof Lt){let c=Em(e.editor,m,d),f=Math.max(c+u,10);od(m,d,f)}})}if(r==="top"&&e.targetCell){let d=e.targetCell;e.editor.update(()=>{let m=G(d)?.getParent(),c=m?.getIndexWithinParent()||0,f=l.y;e.yMarkerAtStart&&c>0?c-=1:e.yMarkerAtStart&&c===0&&(f=-f);let g=m?.getParent()?.getChildren()[c];if(g instanceof co){let h=g.getHeight()||0,N=Math.max(h+f,10);g.setHeight(N)}})}}})}getTargetCellColumnIndex(){let t=this.targetCell;if(t===null)return-1;let e=0,n=t.parentElement;for(let r of n?.children||[]){let i=Number(r.getAttribute("colspan"));if((Number.isNaN(i)||i<1)&&(i=1),e+=i,r===t)return e-1}return-1}};function Fm(o,t){let e=new cd(o,t);return()=>{e.teardown()}}function Hs(o){return o.html||""}function Km(o){window.$events.listen("editor::replace",e=>{let n=Hs(e);Po(o,n)}),window.$events.listen("editor::append",e=>{let n=Hs(e);ks(o,n)}),window.$events.listen("editor::prepend",e=>{let n=Hs(e);Is(o,n)}),window.$events.listen("editor::insert",e=>{let n=Hs(e);$s(o,n)}),window.$events.listen("editor::focus",()=>{Bs(o)});let t=!0;o.registerUpdateListener(({dirtyElements:e,dirtyLeaves:n,editorState:r,prevEditorState:i})=>{(e.size>0||n.size>0)&&(t?t=!1:window.$events.emit("editor-html-change",""))})}var Fs=class{constructor(t){p(this,"data");this.data=t}hasItems(){return!!this.data&&!!this.data.types&&this.data.types.length>0}containsTabularData(){let t=this.data.getData("text/rtf");return!!t&&t.includes("\\trowd")}getImages(){return this.getFiles().filter(t=>t.type.includes("image"))}getFiles(){let{files:t}=this.data;return[...t]}};function Ks(o){window.$components.first("image-manager").show(e=>{o(e)},"gallery")}function Um(o){let t=o.thumbs?.display||o.url,e=yt(t,{target:"_blank"}),n=dn(t,{alt:o.name});return e.append(n),e}async function zm(o,t){if(o===null||o.type.indexOf("image")!==0)throw new Error("Not an image file");let e=o.name||`image-${Date.now()}.png`,n=new FormData;return n.append("file",o,e),n.append("uploaded_to",t),(await window.$http.post("/images/gallery",n)).data}function SE(o,t){let e=o.clientX,n=o.clientY;return document.elementFromPoint(e,n)?nf(t,o.clientX,o.clientY):null}function Wm(o,t,e){let n=SE(t,e);n&&Be(n),Ta(o,!0),(!H(n)||!n?.getTextContent())&&n?.remove()}async function LE(o,t,e){let i=((await window.$http.get(`/templates/${t}`)).data||{html:""}).html||"";o.update(()=>{let s=en(o,i);Wm(s,e,o)})}function qm(o,t){let e=new Fs(o),n=!1;if(!e.hasItems()||e.containsTabularData())return n;let r=e.getImages();return r.length>0&&(n=!0),t.editor.update(async()=>{for(let i of r){let s=window.baseUrl("/loading.gif"),l=dn(s),a=I();a.append(l),Ce([a]);try{let d=await zm(i,t.options.pageId),u=d.name.replace(/"/g,"");t.editor.update(()=>{let m=dn(d.thumbs?.display||"",{alt:u}),c=yt(d.url,{target:"_blank"});c.append(m),l.replace(c)})}catch(d){t.editor.update(()=>{l.remove(!1)}),window.$events.error(d?.data?.message||t.options.translations.imageUploadErrorText),console.error(d)}}}),n}function ME(o,t){let e=/https?:\/\/([^?#]*?)\.(png|jpeg|jpg|gif|webp|bmp|avif)/i,n=o.getData("text/plain");return n&&e.test(n)?(t.editor.update(()=>{let r=dn(n);Ce([r]),r.select()}),!0):!1}function wE(o){let t=o.editor;return e=>{let n=e.dataTransfer?.getData("bookstack/template")||"";if(n)return LE(t,n,e),e.preventDefault(),e.stopPropagation(),!0;let r=e.dataTransfer?.getData("text/html")||"";return r?(t.update(()=>{let i=en(t,r);Wm(i,e,t)}),e.preventDefault(),e.stopPropagation(),!0):e.dataTransfer&&qm(e.dataTransfer,o)?(e.preventDefault(),e.stopPropagation(),!0):!1}}function vE(o){return t=>{if(!t.clipboardData)return!1;let e=ME(t.clipboardData,o)||qm(t.clipboardData,o);return e&&t.preventDefault(),e}}function Ym(o){let t=wE(o),e=vE(o),n=o.editor.registerCommand(Wo,t,Je),r=o.editor.registerCommand(go,e,Je);return o.scrollDOM.addEventListener("drop",t),()=>{n(),r(),o.scrollDOM.removeEventListener("drop",t)}}var ud=class{constructor(t,e){p(this,"editorContainer");p(this,"editor");this.editor=t,this.editorContainer=e,this.setupListeners()}setupListeners(){this.handleClick=this.handleClick.bind(this),this.editorContainer.addEventListener("click",this.handleClick)}handleClick(t){let e=t.target;e instanceof HTMLElement&&e.nodeName==="LI"&&e.classList.contains("task-list-item")&&(this.handleTaskListItemClick(e,t),t.preventDefault())}handleTaskListItemClick(t,e){let n=t.getBoundingClientRect();e.clientX<=n.right&&e.clientX>=n.left&&e.clientY>=n.top&&e.clientY<=n.bottom||this.editor.update(()=>{let i=G(t);j(i)&&i.setChecked(!i.getChecked())})}teardown(){this.editorContainer.removeEventListener("click",this.handleClick)}};function Zm(o,t){let e=new ud(o,t);return()=>{e.teardown()}}var fd=class{constructor(t){p(this,"editor");p(this,"tableSelections",new Map);p(this,"unregisterMutationListener",()=>{});this.editor=t,this.init()}init(){this.unregisterMutationListener=this.editor.registerMutationListener(Lt,t=>{for(let[e,n]of t)if(n==="created")this.editor.getEditorState().read(()=>{let r=ee(e);K(r)&&this.initializeTableNode(r)});else if(n==="destroyed"){let r=this.tableSelections.get(e);r!==void 0&&(r.removeListeners(),this.tableSelections.delete(e))}})}initializeTableNode(t){let e=t.getKey(),n=this.editor.getElementByKey(e);if(n&&!this.tableSelections.has(e)){let r=Qa(t,n,this.editor,!0);this.tableSelections.set(e,r)}}teardown(){this.unregisterMutationListener();for(let[,t]of this.tableSelections)t.removeListeners()}};function Vm(o){let t=new fd(o);return()=>{t.teardown()}}var DE=(o,t)=>lr(o)&&o.getTag()===t;function Us(o,t){o.update(()=>{Vn(e=>DE(e,t),()=>ir(t))})}function li(o){o.update(()=>{Vn(Ge,I)})}function ai(o){o.update(()=>{Vn(Ls,Ss)})}function di(o,t){o.getEditorState().read(()=>{let e=C();de(e,r=>W(r)&&r.getListType()===t)?Ka(o):Fa(o,t)})}function ci(o){o.getEditorState().read(()=>{let t=C(),e=ae(o),n=V(e,_s);n===null?o.update(()=>{let r=bs();r.setCode(t?.getTextContent()||"");let i=Pt(t),s=i[0],l=i.slice(1);s?(s.replace(r),l.forEach(a=>a.remove())):tn(r,!0),ii(o,r),Be(r)}):ii(o,n)})}function Xm(o){o.update(()=>{let t=C(),e=Pt(t),n=!1;for(let i of e)ka(i)||(i.replace(Jn("info"),!0),n=!0);if(n)return;let r=["info","warning","danger","success"];for(let i of e)if(ka(i)){let s=i.getCategory(),a=(r.indexOf(s)+1)%r.length,d=r[a];i.setCategory(d)}})}function zs(o,t){o.update(()=>{let e=C(),n=V(e,Ft);if(Ft(n)?(n.setURL(t.url),n.setTarget(t.target),n.setTitle(t.title)):(n=yt(t.url,{title:t.title,target:t.target}),Ce([n])),Ft(n)){for(let r of n.getChildren())r.remove(!0);n.append(z(t.text))}})}var ui=class extends oe{constructor(e,n){super([e,n]);p(this,"input");p(this,"action");this.input=e,this.action=n}buildDOM(){return y("div",{class:"editor-action-input-container"},[this.input.getDOMElement(),this.action.getDOMElement()])}};var w=class extends ke{constructor(e){super();p(this,"definition");p(this,"active",!1);p(this,"completedSetup",!1);p(this,"disabled",!1);e.action!==void 0?this.definition=e:this.definition={...e,action(){return!1},isActive:()=>!1}}setContext(e){super.setContext(e),this.definition.setup&&!this.completedSetup&&(this.definition.setup(e,this),this.completedSetup=!0)}buildDOM(){let e=this.getLabel(),n=this.definition.format||"small",r=[];if(this.definition.icon||n==="long"){let s=y("div",{class:"editor-button-icon"});s.innerHTML=this.definition.icon||"",r.push(s)}if(!this.definition.icon||n==="long"){let s=y("div",{class:"editor-button-text"},[e]);r.push(s)}let i=y("button",{type:"button",class:`editor-button editor-button-${n}`,title:this.definition.icon?e:null,disabled:this.disabled?"true":null},r);return i.addEventListener("click",this.onClick.bind(this)),i}onClick(){let e=this.definition.action(this.getContext(),this);e instanceof Promise?e.then(n=>{n===!1&&this.emitEvent("button-action")}):e!==!1&&this.emitEvent("button-action")}updateActiveState(e){let n=this.definition.isActive(e,this.getContext());this.setActiveState(n)}updateDisabledState(e){if(this.definition.isDisabled){let n=this.definition.isDisabled(e,this.getContext());this.toggleDisabled(n)}}setActiveState(e){this.active=e,this.dom?.classList.toggle("editor-button-active",this.active)}updateState(e){this.updateActiveState(e.selection),this.updateDisabledState(e.selection)}isActive(){return this.active}getLabel(){return this.trans(this.definition.label)}toggleDisabled(e){this.disabled=e,e?this.dom?.setAttribute("disabled","true"):this.dom?.removeAttribute("disabled")}};var jm='';var Ws='';function qs(o,t){window.$components.first("entity-selector-popup").show(n=>o(n),{initialValue:t||"",searchEndpoint:"/search/entity-selector",entityTypes:"page,book,chapter,bookshelf",entityPermission:"view"})}var Ys=class extends oe{constructor(e){super([e]);p(this,"input");p(this,"headerMap",new Map);this.input=e}buildDOM(){let e="editor-form-datalist-"+this.input.getName()+"-"+Date.now(),n=this.input.getDOMElement(),r=n.querySelector("input");r?.setAttribute("list",e),r?.setAttribute("autocomplete","off");let i=y("datalist",{id:e}),s=y("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(e){this.getHeaderIdAndText(e).then(({id:n,text:r})=>{let i=this.getContext().manager.getActiveModal("link");i&&i.getForm().setValues({url:`#${n}`,text:r,title:r})})}getHeaderIdAndText(e){return new Promise(n=>{this.getContext().editor.update(()=>{let r=e.getId();r||(r="header-"+Ms(),e.setId(r));let i=e.getTextContent();n({id:r,text:i})})})}updateDataList(e){this.getContext().editor.getEditorState().read(()=>{let n=Ea(lr);this.headerMap.clear();let r=[];for(let i of n){let s="header-"+i.getKey();this.headerMap.set(s,i),r.push(y("option",{value:s,label:i.getTextContent().substring(0,54)}))}e.innerHTML="",e.append(...r)})}};function Gm(o,t){let e=t.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)};e.show(i)}var Jm={submitText:"Apply",async action(o,t){return t.editor.update(()=>{let e=ae(t.editor),n=V(e,Qe);Qe(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 ui(new zt({label:"Source",name:"src",type:"text"}),new w({label:"Browse files",icon:jm,action(o){Ks(t=>{let e=o.manager.getActiveModal("image");e&&e.getForm().setValues({src:t.thumbs?.display||t.url,alt:t.name})})}}))}},{label:"Alternative description",name:"alt",type:"text"},{label:"Width",name:"width",type:"text"},{label:"Height",name:"height",type:"text"}]};function Zs(o,t){let e=t.manager.createModal("link");if(o){let n={url:o.getURL(),text:o.getTextContent(),title:o.getTitle()||"",target:o.getTarget()||""};t.editor.update(()=>{let r=nn();r.add(o.getKey()),Y(r)}),e.show(n)}else t.editor.getEditorState().read(()=>{let i={text:C()?.getTextContent()||""};e.show(i)})}var Qm={submitText:"Apply",async action(o,t){return zs(t.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 ui(new Ys(new zt({label:"URL",name:"url",type:"text"})),new w({label:"Browse links",icon:Ws,action(o){qs(t=>{let e=o.manager.getActiveModal("link");e&&e.getForm().setValues({url:t.link,text:t.name,title:t.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"}}]};function ep(o,t){let e=t.manager.createModal("media"),n={};if(o){let r=o.getAttributes(),i=o.exportDOM(t.editor).element,s=i instanceof HTMLElement?i.outerHTML:"";n={src:r.src||r.data||o.getSources()[0]?.src||"",width:r.width,height:r.height,embed:s,embed_check:s}}e.show(n)}var tp={submitText:"Save",async action(o,t){let e=await new Promise((i,s)=>{t.editor.getEditorState().read(()=>{let l=V(C(),Mt);i(l)})}),n=(o.get("embed")||"").toString().trim(),r=(o.get("embed_check")||"").toString().trim();return n&&n!==r?(t.editor.update(()=>{let i=Om(n);e&&i?e.replace(i):i&&Ce([i])}),!0):(t.editor.update(()=>{let i=(o.get("src")||"").toString().trim(),s=(o.get("height")||"").toString().trim(),l=(o.get("width")||"").toString().trim();if(e){e.setSrc(i),e.setWidthAndHeight(l,s),t.manager.triggerFutureStateRefresh();return}let a=Am(i);(l||s)&&a.setWidthAndHeight(l,s),Ce([a])}),!0)},fields:[{build(){return new hn([{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"},{label:"",name:"embed_check",type:"hidden"}]}])}}]};function op(o,t){let e=t.manager.createModal("details");o&&e.show({summary:o.getSummary()})}var np={submitText:"Save",async action(o,t){return t.editor.update(()=>{let e=V(C(),ce),n=(o.get("summary")||"").toString().trim();ce(e)&&e.setSummary(n)}),!0},fields:[{label:"Toggle label",name:"summary",type:"text"}]};function Vs(o,t){return Us(o.editor,t),o.manager.triggerFutureStateRefresh(),!0}function fo(o){return(t,e)=>(o(t),e.manager.triggerFutureStateRefresh(),!0)}function rp(o){return o.dispatchCommand(Ee,"code"),!0}var ip={"meta+s":()=>(window.$events.emit("editor-save-draft"),!0),"meta+enter":()=>(window.$events.emit("editor-save-page"),!0),"meta+1":(o,t)=>Vs(t,"h2"),"meta+2":(o,t)=>Vs(t,"h3"),"meta+3":(o,t)=>Vs(t,"h4"),"meta+4":(o,t)=>Vs(t,"h5"),"meta+5":fo(li),"meta+d":fo(li),"meta+6":fo(ai),"meta+q":fo(ai),"meta+7":fo(ci),"meta+e":fo(ci),"meta+8":rp,"meta+shift+e":rp,"meta+9":fo(Xm),"meta+o":fo(o=>di(o,"number")),"meta+p":fo(o=>di(o,"bullet")),"meta+k":(o,t)=>(o.getEditorState().read(()=>{let e=V(C(),Ft);Zs(e,t)}),!0),"meta+shift+k":(o,t)=>(o.getEditorState().read(()=>{let n=C()?.getTextContent()||"";qs(r=>{zs(o,{text:r.name,title:r.link,target:"",url:r.link})},n)}),!0)};function RE(o){return t=>{let e=kE(t);ip[e]&&ip[e](o.editor,o)&&(t.stopPropagation(),t.preventDefault())}}function kE(o){return[(sp()?o.metaKey:o.ctrlKey)?"meta":"",o.shiftKey?"shift":"",o.key].filter(Boolean).join("+").toLowerCase()}function sp(){return window.navigator.userAgent.includes("Mac OS X")}function IE(o){o.registerCommand(we,t=>sp()?t?.metaKey||!1:t?.ctrlKey||!1,Je)}function Xs(o){let t=RE(o);return IE(o.editor),o.editor.registerRootListener((e,n)=>{e?.addEventListener("keydown",t),n?.removeEventListener("keydown",t)})}function $E(o){return Qe(o)||Mt(o)}var md=class{constructor(t){p(this,"context");p(this,"resizerDOM",null);p(this,"targetNode",null);p(this,"scrollContainer");p(this,"mouseTracker",null);p(this,"activeSelection","");p(this,"loadAbortController",new AbortController);this.context=t,this.scrollContainer=t.scrollDOM,this.onSelectionChange=this.onSelectionChange.bind(this),this.onTargetDOMLoad=this.onTargetDOMLoad.bind(this),t.manager.onSelectionChange(this.onSelectionChange)}onSelectionChange(t){let e=t?.getNodes()||[];if(this.activeSelection&&this.hide(),e.length===1&&$E(e[0])){let n=e[0],r=this.getTargetDOM(n);r&&this.showForNode(n,r)}}getTargetDOM(t){if(t==null)return null;let e=this.context.editor.getElementByKey(t.__key);return e&&e.nodeName==="SPAN"&&(e=e.firstElementChild),e}onTargetDOMLoad(){this.updateResizerPosition()}teardown(){this.context.manager.offSelectionChange(this.onSelectionChange),this.hide()}showForNode(t,e){this.resizerDOM=this.buildDOM(),this.targetNode=t;let n=y("span",{class:"editor-node-resizer-ghost"});Qe(t)&&(n=y("img",{src:e.getAttribute("src"),class:"editor-node-resizer-ghost"})),this.resizerDOM.append(n),this.context.scrollDOM.append(this.resizerDOM),this.updateResizerPosition(),this.mouseTracker=this.setupTracker(this.resizerDOM,t,e),this.activeSelection=t.getKey(),e.matches("img, embed, iframe, object")&&(this.loadAbortController=new AbortController,e.addEventListener("load",this.onTargetDOMLoad,{signal:this.loadAbortController.signal}))}updateResizerPosition(){let t=this.getTargetDOM(this.targetNode);if(!this.resizerDOM||!t)return;let e=this.scrollContainer.getBoundingClientRect(),n=t.getBoundingClientRect(),r=n.top-(e.top-this.scrollContainer.scrollTop),i=n.left-e.left;this.resizerDOM.style.top=`${r}px`,this.resizerDOM.style.left=`${i}px`,this.resizerDOM.style.width=n.width+"px",this.resizerDOM.style.height=n.height+"px"}updateDOMSize(t,e){this.resizerDOM&&(this.resizerDOM.style.width=t+"px",this.resizerDOM.style.height=e+"px")}hide(){this.mouseTracker?.teardown(),this.resizerDOM?.remove(),this.targetNode=null,this.activeSelection="",this.loadAbortController.abort()}buildDOM(){let e=["nw","ne","se","sw"].map(n=>y("div",{class:`editor-node-resizer-handle ${n}`}));return y("div",{class:"editor-node-resizer"},e)}setupTracker(t,e,n){let r=0,i=0,s=0,l=!1,a=this,d=!1,u=!1,m=c=>{let f=c.x;d&&(f=0-f);let g=c.y;u&&(g=0-g);let h=Math.sqrt(Math.pow(Math.abs(f),2)+Math.pow(Math.abs(g),2)),b=f+g>0?h:0-h,x=Math.max(5,Math.round(r+b)),S=Math.round(x*s);return{width:x,height:S}};return new cr(t,".editor-node-resizer-handle",{down(c,f){a.resizerDOM?.classList.add("active"),a.context.editor.getEditorState().read(()=>{let g=n.getBoundingClientRect();r=e.getWidth()||g.width,i=e.getHeight()||g.height,e.getHeight()&&(l=!0),s=i/r}),d=f.classList.contains("nw")||f.classList.contains("sw"),u=f.classList.contains("nw")||f.classList.contains("ne")},move(c,f,g){let h=m(g);a.updateDOMSize(h.width,h.height)},up(c,f,g){let h=m(g);a.context.editor.update(()=>{e.setWidth(h.width),e.setHeight(l?h.height:0)},{onUpdate:()=>{requestAnimationFrame(()=>{a.context.manager.triggerLayoutUpdate(),a.updateResizerPosition()})}}),a.resizerDOM?.classList.remove("active")}})}};function lp(o){let t=new md(o);return()=>{t.teardown()}}function PE(o){let t=o.getParent();if(!W(t))return o;let e=o.getChildren().filter(d=>W(d))[0]||null,n=e?.getChildren()||[],r=t.getChildren(),i=r.findIndex(d=>d.getKey()===o.getKey()),s=i===0,l=Ue(),a=Se(t.getListType());if(a.append(l),l.append(...o.getChildren()),s?o.append(a):(r[i-1].append(a),o.remove()),e){for(let d of n)l.insertAfter(d);e.remove()}return l}function BE(o){let t=o.getParent(),e=t?.getParent(),n=e?.getParent();if(!W(t)||!W(n)||!j(e))return o;let r=o.getNextSiblings();if(e.insertAfter(o),t.getChildren().length===0&&t.remove(),r.length>0){let i=Se(t.getListType());i.append(...r),o.append(i)}return t.getChildrenSize()===0&&t.remove(),e.getChildren().length===0&&e.remove(),o}function HE(o){let t=o?.getNodes()||[],[e,n]=o?.getStartEndPoints()||[null,null],r=new Set;if(o&&e){o.isBackward()&&n&&([n,e]=[e,n]);let s=e.getNode().getParents(),l=!1;for(let a of s)j(a)&&(l?r.add(a.getKey()):l=!0)}let i=[];e:for(let s of t){if(j(s)){r.has(s.getKey())||i.push(s);continue}let l=s.getParents();for(let a of l)if(j(a)){r.has(a.getKey())||i.push(a);continue e}i.push(null)}return i}function FE(o){let t={};for(let n of o){if(n===null)continue;let r=n.getKey();typeof t[r]>"u"&&(t[r]=n)}let e=Object.values(t);return rf(e)}function fi(o,t){let e=C(),n=e?.getStartEndPoints(),r=HE(e);if(r.length>0&&!r.includes(null)){let l=[],a=FE(r);if(t>0)for(let d of a)l.push(PE(d));else if(t<0){for(let d of[...a].reverse())l.push(BE(d));l.reverse()}if(l.length===1&&n){let d=l[0],u=d.getChildren()[0];u||(u=z(""),d.append(u)),u.select(n[0].offset,n[1].offset)}else mf(l);return}let s=Pt(e);for(let l of s)if(sf(l)){let a=l.getInset(),d=Math.min(Math.max(a+t,0),500);l.setInset(d)}pf(o)}var ur=class extends Error{constructor(e,n){super(e.statusText);p(this,"data");p(this,"headers");p(this,"original");p(this,"redirected");p(this,"status");p(this,"statusText");p(this,"url");this.data=n,this.headers=e.headers,this.redirected=e.redirected,this.status=e.status,this.statusText=e.statusText,this.url=e.url,this.original=e}};function js(o){return new Promise((t,e)=>{o.oncomplete=o.onsuccess=()=>t(o.result),o.onabort=o.onerror=()=>e(o.error)})}function KE(o,t){let e,n=()=>{if(e)return e;let r=indexedDB.open(o);return r.onupgradeneeded=()=>r.result.createObjectStore(t),e=js(r),e.then(i=>{i.onclose=()=>e=void 0},()=>{}),e};return(r,i)=>n().then(s=>i(s.transaction(t,r).objectStore(t)))}var pd;function gd(){return pd||(pd=KE("keyval-store","keyval")),pd}function hd(o,t=gd()){return t("readonly",e=>js(e.get(o)))}function Nd(o,t,e=gd()){return e("readwrite",n=>(n.put(t,o),js(n.transaction)))}function xd(o,t=gd()){return t("readwrite",e=>(e.delete(o),js(e.transaction)))}var wt=null,Cd,Gs,Ed,Td="last-drawing-save";function bd(o){wt?.contentWindow?.postMessage(JSON.stringify(o),Cd)}function zE(o){Nd(Td,o.data),Ed&&Ed(o.data).then(()=>{xd(Td)})}function WE(o){bd({action:"export",format:"xmlpng",xml:o.xml,spin:"Updating drawing"})}function qE(){Gs&&Gs().then(o=>{bd({action:"load",autosave:1,xml:o})})}function YE(){let o={};wt&&(window.$events.emitPublic(wt,"editor-drawio::configure",{config:o}),bd({action:"configure",config:o}))}function ap(){window.removeEventListener("message",dp),wt&&document.body.removeChild(wt)}function dp(o){if(!o.data||o.data.length<1||o.origin!==Cd)return;let t=JSON.parse(o.data);t.event==="init"?qE():t.event==="exit"?ap():t.event==="save"?WE(t):t.event==="export"?zE(t):t.event==="configure"&&YE()}async function ZE(){let o=await hd(Td),t=document.getElementById("unsaved-drawing-dialog");t||console.error("Missing expected unsaved-drawing dialog"),o&&t&&await window.$components.firstOnElement(t,"confirm-dialog").show()&&(Gs=async()=>o)}async function cp(o,t,e){Gs=t,Ed=e,await ZE(),wt=document.createElement("iframe"),wt.setAttribute("frameborder","0"),window.addEventListener("message",dp),wt.setAttribute("src",o),wt.setAttribute("class","fullscreen"),wt.style.backgroundColor="#FFFFFF",document.body.appendChild(wt),Cd=new URL(o).origin}async function up(o,t){let e={image:o,uploaded_to:t};return(await window.$http.post(window.baseUrl("/images/drawio"),e)).data}function _d(){ap()}async function fp(o){try{return`data:image/png;base64,${(await window.$http.get(window.baseUrl(`/images/drawio/base64/${o}`))).data.content}`}catch(t){throw t instanceof ur&&window.$events.showResponseError(t),_d(),t}}function mo(o){return o instanceof Io}function XE(o,t){o.status===413?window.$events.emit("error",t.options.translations.serverUploadLimitText||""):window.$events.emit("error",t.options.translations.imageUploadErrorText||""),console.error(o)}async function jE(o,t){return await new Promise((n,r)=>{o.getEditorState().read(()=>{let{id:i}=t.getDrawingIdAndUrl();n(i)})})||""}async function GE(o,t,e,n){if(_d(),n){let r=window.baseUrl("/loading.gif");o.editor.update(()=>{t.setDrawingIdAndUrl("",r)})}try{let r=await up(e,o.options.pageId);o.editor.update(()=>{t.setDrawingIdAndUrl(String(r.id),r.url)})}catch(r){throw r instanceof ur&&XE(r,o),n&&o.editor.update(()=>{t.remove()}),new Error(`Failed to save image with error: ${r}`)}}function mi(o,t){let e=!1;cp(o.options.drawioUrl,async()=>{let n=await jE(o.editor,t);return e=!n,e?"":fp(n)},async n=>GE(o,t,n,e))}function JE(o){window.$components.first("image-manager").show(e=>{o(e)},"drawio")}function mp(o){let t=ae(o.editor);JE(e=>{o.editor.update(()=>{let n=nr(e.id,e.url),r=V(t,mo);mo(r)?r.replace(n):Ce([n])})})}function Js(o){let t=o.getChildren();for(let e of t)o.insertBefore(e);o.remove()}function yd(o){if(o.length===1){let t=o[0];if(H(t)||Qe(t)||Mt(t)||mo(t))return!0}return!1}function pp(o){let t=ae(o)?.getNodes()||[];yd(t)&&o.update(()=>{t[0].remove()})}function QE(o,t){let e=ae(o)?.getNodes()||[];if(yd(e)){let n=e[0],r=bt(n)||n,i=t?.shiftKey===!0;if(r)return requestAnimationFrame(()=>{o.update(()=>{let s=I();i?r.insertBefore(s):r.insertAfter(s),s.select()})}),t?.preventDefault(),!0}return!1}function gp(o,t,e=!0){let n=ae(o)?.getNodes()||[];if(!yd(n))return!1;t?.preventDefault();let r=n[0];return o.update(()=>{qr(r,e)}),!0}function eT(o,t){let e=hp(o);return e===null||e.detailsSibling?!1:(o.update(()=>{let n=I();e.parentDetails.insertAfter(n),n.select()}),t?.preventDefault(),!0)}function tT(o,t){let e=hp(o);if(e===null||e.parentBlock.getTextContent()!=="")return!1;t?.preventDefault();let n=e.parentDetails.getNextSibling();return o.update(()=>{if(n)n.selectStart();else{let r=I();e.parentDetails.insertAfter(r),r.select()}e.parentBlock.remove()}),!0}function hp(o){let e=ae(o)?.getNodes()[0];if(!e)return null;let n=bt(e),r=$t(e,ce);if(!ce(r)||n===null||n.getKey()!==r.getLastChild()?.getKey())return null;let i=r.getNextSibling();return{parentDetails:r,parentBlock:n,detailsSibling:i}}function oT(o,t){let e=C(),n=e?.getNodes()||[];if(n.length!==1)return!1;let r=bt(n[0]);if(!r)return!1;let i=r.getParent(),s=e?.getStartEndPoints();return s&&ce(i)&&s[0].offset===0&&r.getIndexWithinParent()===0?(t.preventDefault(),o.editor.update(()=>{Js(i),r.selectStart(),o.manager.triggerLayoutUpdate()}),!0):!1}function nT(o){if(o.length!==1)return!1;let t=o[0];return j(t)||j(t.getParent())}function rT(o,t){let e=t?.shiftKey?-40:40,r=C()?.getNodes()||[];return r.length>1||nT(r)?(o.update(()=>{fi(o,e)}),t?.preventDefault(),!0):!1}function Np(o){let t=o.editor.registerCommand(Xt,l=>(pp(o.editor),oT(o,l)),Ae),e=o.editor.registerCommand(jt,()=>(pp(o.editor),!1),Ae),n=o.editor.registerCommand(we,l=>QE(o.editor,l)||tT(o.editor,l),Ae),r=o.editor.registerCommand(zo,l=>rT(o.editor,l),Ae),i=o.editor.registerCommand(Zt,l=>gp(o.editor,l,!1),Ae),s=o.editor.registerCommand(Vt,l=>eT(o.editor,l)||gp(o.editor,l,!0),Ae);return()=>{t(),e(),n(),r(),i(),s()}}function iT(o){return o.toLowerCase().startsWith("http")?/(http|https):\/\/(\S+)\.\S+$/.test(o):!1}function sT(o,t,e){let n=t.getStartEndPoints();if(!n)return;let r=n[0].offset,i=o.getTextContent(),a=i.slice(0,r).lastIndexOf(" ")+1,d=i.slice(a,r);iT(d)&&e.update(()=>{let u=yt(d);u.append(new st(d));let m=o.splitText(a,r),c=a>0?1:0,f=m[c];f&&f.replace(u)})}function Qs(o){let t=r=>{let i=C(),s=df(i);return s&&i&&sT(s,i,o),!1},e=o.registerCommand(xr,t,lo),n=o.registerCommand(we,t,lo);return()=>{e(),n()}}var el=class extends oe{buildDOM(){let t=this.getChildren().map(i=>i.getDOMElement()),e=y("div",{class:"editor-format-menu-dropdown editor-dropdown-menu editor-dropdown-menu-vertical",hidden:"true"},t),n=y("button",{class:"editor-format-menu-toggle editor-button",type:"button"},[this.trans("Formats")]),r=y("div",{class:"editor-format-menu editor-dropdown-menu-container"},[n,e]);return this.getContext().manager.dropdowns.handle({toggle:n,menu:e}),this.onEvent("button-action",()=>{this.getContext().manager.dropdowns.closeAll()},r),r}updateState(t){super.updateState(t);for(let e of this.children){if(e instanceof w&&e.isActive()){this.updateToggleLabel(e.getLabel());return}if(e instanceof oe){for(let n of e.getChildren())if(n instanceof w&&n.isActive()){this.updateToggleLabel(n.getLabel());return}}}this.updateToggleLabel(this.trans("Formats"))}updateToggleLabel(t){let e=this.getDOMElement().querySelector("button");e&&(e.innerText=t)}};var et=class extends w{constructor(e,n){super(n);p(this,"previewSampleElement");this.previewSampleElement=e}buildDOM(){let e=super.buildDOM();e.innerHTML="";let n=y("span",{class:"editor-button-format-preview"},[this.getLabel()]),r=this.getStylesFromPreview();for(let i of Object.keys(r))n.style.setProperty(i,r[i]);return e.append(n),e}getStylesFromPreview(){let e=y("div",{style:"display: none",hidden:"true",class:"page-content"}),n=this.previewSampleElement.cloneNode();n.textContent=this.getLabel(),e.append(n),document.body.append(e);let r=["color","font-size","background-color","border-inline-start"],i={},s=window.getComputedStyle(n);for(let l of r)i[l]=s.getPropertyValue(l);return e.remove(),i}};var xp='';var tl=class extends w{buildDOM(){let t=super.buildDOM(),e=y("div",{class:"editor-menu-button-icon"});return e.innerHTML=xp,t.append(e),t}};var aT={showOnHover:!1,direction:"horizontal",showAside:void 0,hideOnAction:!0,button:{label:"Menu"}},be=class extends oe{constructor(e,n){super(n);p(this,"button");p(this,"childItems");p(this,"open",!1);p(this,"options");if(this.childItems=n,this.options=Object.assign({},aT,e),e.button instanceof w)this.button=e.button;else{let r=e.button.format==="long"?tl:w;this.button=new r({...e.button,action(){return!1},isActive:()=>this.open})}this.addChildren(this.button)}insertItems(...e){this.addChildren(...e),this.childItems.push(...e)}buildDOM(){let e=this.button.getDOMElement(),n=this.childItems.map(s=>s.getDOMElement()),r=y("div",{class:`editor-dropdown-menu editor-dropdown-menu-${this.options.direction}`,hidden:"true"},n),i=y("div",{class:"editor-dropdown-menu-container"},[e,r]);return this.getContext().manager.dropdowns.handle({toggle:e,menu:r,showOnHover:this.options.showOnHover,showAside:typeof this.options.showAside=="boolean"?this.options.showAside:this.options.direction==="vertical",onOpen:()=>{this.open=!0,this.getContext().manager.triggerStateUpdateForElement(this.button)},onClose:()=>{this.open=!1,this.getContext().manager.triggerStateUpdateForElement(this.button)}}),this.options.hideOnAction&&this.onEvent("button-action",()=>{this.getContext().manager.dropdowns.closeAll()},i),i}};var Ep='';var Tp='';var Cp=["#000000","#ffffff","#BFEDD2","#FBEEB8","#F8CAC6","#ECCAFA","#C2E0F4","#2DC26B","#F1C40F","#E03E2D","#B96AD9","#3598DB","#169179","#E67E23","#BA372A","#843FA1","#236FA1","#ECF0F1","#CED4D9","#95A5A6","#7E8C8D","#34495E"],bp="bs-lexical-custom-colors",Nn=class extends ke{constructor(e){super();p(this,"callback");this.callback=e}buildDOM(){let e=Ms(),r=[...Cp,...this.getCustomColorChoices()].map(u=>y("div",{class:"editor-color-select-option",style:`background-color: ${u}`,"data-color":u,"aria-label":u})),i=y("div",{class:"editor-color-select-option","data-color":"",title:this.getContext().translate("Remove color")},[]);i.innerHTML=Ep,r.push(i);let s=y("label",{class:"editor-color-select-option",for:`color-select-${e}`,"data-color":"",title:this.getContext().translate("Custom color")},[]);s.innerHTML=Tp,r.push(s);let l=y("input",{type:"color",hidden:"true",id:`color-select-${e}`});r.push(l),l.addEventListener("change",u=>{l.value&&(this.storeCustomColorChoice(l.value),this.setColor(l.value),this.rebuildDOM())});let a=[];for(let u=0;u{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)}),y("div",{class:"editor-table-creator"},[i,r])}updateGridSelection(t,e,n,r){for(let i of n){let s=Number(i.dataset.rows)<=t&&Number(i.dataset.columns)<=e;i.classList.toggle("active",s)}r.textContent=`${t} x ${e}`}onCellClick(t){let e=Number(t.dataset.rows||0),n=Number(t.dataset.columns||0);if(e<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=qa(e,n,!1);s.setColWidths(i),tn(s)})}};var pi=class extends w{constructor(e,n){super(e);p(this,"style");this.style=n}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 n=ha(e.selection,this.style);this.getColorBar().setAttribute("fill",n)}}};var _p='';var Ie=class extends oe{constructor(e,n,r){super(r);p(this,"size");p(this,"overflowButton");p(this,"content");p(this,"label");this.label=e,this.size=n,this.content=r,this.overflowButton=new be({button:{label:"More",icon:_p},hideOnAction:!1},[]),this.addChildren(this.overflowButton)}addChild(e,n=-1){this.content.splice(n,0,e),this.addChildren(e)}buildDOM(){let e=this.content.length>this.size?this.size-1:this.size,n=this.content.slice(0,e),r=this.content.slice(e),i=n.map(s=>s.getDOMElement());return r.length>0&&(this.removeChildren(...r),this.overflowButton.insertItems(...r),i.push(this.overflowButton.getDOMElement())),y("div",{class:"editor-overflow-container"},i)}getLabel(){return this.label}};var Sd='';var nl='';var yp='';var Sp='';var Lp='';var Mp='';var wp='';var vp='';var Dp=` +`?a.insertParagraph():d===" "?a.insertNodes([kt()]):a.insertText(d)}}}else t.insertRawText(i)}function ka(o,t,e){o.dispatchCommand(Nr,{nodes:t,selection:e})||e.insertNodes(t)}function Kx(o){let t=o.exportJSON(),e=o.constructor;if(t.type!==e.getType()&&T(!1,"LexicalNode: Node %s does not implement .exportJSON().",e.name),E(o)){let n=t.children;Array.isArray(n)||T(!1,"LexicalNode: Node %s is an element but .exportJSON() does not have a children array.",e.name)}return t}function Vf(o,t,e,n=[]){let r=t!==null?e.isSelected(t):!0,i=E(e)&&e.excludeFromCopy("html"),s=e;if(t!==null){let d=no(e);d=L(d)&&t!==null?zr(t,d):d,s=d}let l=E(s)?s.getChildren():[],a=Kx(s);if(L(s)){let d=s.__text;d.length>0?a.text=d:r=!1}for(let d=0;d{o.update(()=>{a(Wf(o,t,e))})});let n=o.getRootElement(),r=o._window==null?window.document:o._window.document,i=qf(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 u=o.registerCommand(xo,m=>(Tt(m,ClipboardEvent)&&(u(),jn!==null&&(window.clearTimeout(jn),jn=null),a(Wf(o,m,e))),!0),Ke);jn=window.setTimeout(()=>{u(),jn=null,a(!1)},Ux),r.execCommand("copy"),s.remove()})}function Wf(o,t,e){if(e===void 0){let r=qf(o._window);if(!r)return!1;let i=r.anchorNode,s=r.focusNode;if(i!==null&&s!==null&&!eo(o,i,s))return!1;let l=C();if(l===null)return!1;e=ds(l)}t.preventDefault();let n=t.clipboardData;return n===null?!1:(Gf(n,e),!0)}var zx=[["text/html",Yf],["application/x-lexical-editor",Zf]];function ds(o=C()){let t={"text/plain":o?o.getTextContent():""};if(o){let e=Yl();for(let[n,r]of zx){let i=r(e,o);i!==null&&(t[n]=i)}}return t}function Gf(o,t){for(let e in t){let n=t[e];n!==void 0&&o.setData(e,n)}}function cs(o,t){if(typeof document.caretRangeFromPoint<"u"){let e=document.caretRangeFromPoint(o,t);return e===null?null:{node:e.startContainer,offset:e.startOffset}}else if(document.caretPositionFromPoint!=="undefined"){let e=document.caretPositionFromPoint(o,t);return e===null?null:{node:e.offsetNode,offset:e.offset}}else return null}var Jf=$("DRAG_DROP_PASTE_FILE");function Wx(o,t){o.preventDefault(),t.update(()=>{let e=C(),n=Tt(o,InputEvent)||Tt(o,KeyboardEvent)?null:o.clipboardData;n!=null&&e!==null&&as(n,e,t)},{tag:"paste"})}async function qx(o,t){await Gn(t,Tt(o,ClipboardEvent)?o:null),t.update(()=>{let e=C();_(e)?e.removeText():Oe(e)&&e.getNodes().forEach(n=>n.remove())})}function us(o){let t=null;if(Tt(o,DragEvent)?t=o.dataTransfer:Tt(o,ClipboardEvent)&&(t=o.clipboardData),t===null)return[!1,[],!1];let e=t.types,n=e.includes("Files"),r=e.includes("text/html")||e.includes("text/plain");return[n,Array.from(t.files),r]}function fs(o){let t=G(o);return H(t)}function Yx(o){let t=o.focus;return t.key==="root"&&t.offset===F().getChildrenSize()}function ms(o){return Et(o.registerCommand(Wt,e=>{let n=C();return Oe(n)?(n.clear(),!0):!1},0),o.registerCommand(tt,e=>{let n=C();return _(n)?(n.deleteCharacter(e),!0):!1},J),o.registerCommand(Dt,e=>{let n=C();return _(n)?(n.deleteWord(e),!0):!1},J),o.registerCommand(mt,e=>{let n=C();return _(n)?(n.deleteLine(e),!0):!1},J),o.registerCommand(ft,e=>{let n=C();if(typeof e=="string")n!==null&&n.insertText(e);else{if(n===null)return!1;let r=e.dataTransfer;if(r!=null)as(r,n,o);else if(_(n)){let i=e.data;return i&&n.insertText(i),!0}}return!0},J),o.registerCommand(Sn,()=>{let e=C();return _(e)?(e.removeText(),!0):!1},J),o.registerCommand(Ee,e=>{let n=C();return _(n)?(n.formatText(e),!0):!1},J),o.registerCommand(qt,e=>{let n=C();return _(n)?(n.insertLineBreak(e),!0):!1},J),o.registerCommand(Yt,()=>{let e=C();return _(e)?(e.insertParagraph(),!0):!1},J),o.registerCommand(bl,()=>(Ce([kt()]),!0),J),o.registerCommand(Zt,e=>{let n=C();if(Oe(n)&&!fs(e.target)){let r=n.getNodes();if(r.length>0)return r[0].selectPrevious(),!0}else if(_(n)){let r=oo(n.focus,!0);if(!e.shiftKey&&H(r)&&!r.isIsolated()&&!r.isInline())return r.selectPrevious(),e.preventDefault(),!0}return!1},J),o.registerCommand(Vt,e=>{let n=C();if(Oe(n)){let r=n.getNodes();if(r.length>0)return r[0].selectNext(0,0),!0}else if(_(n)){if(Yx(n))return e.preventDefault(),!0;let r=oo(n.focus,!1);if(!e.shiftKey&&H(r)&&!r.isIsolated()&&!r.isInline())return r.selectNext(),e.preventDefault(),!0}return!1},J),o.registerCommand(Ko,e=>{let n=C();if(Oe(n)){let r=n.getNodes();if(r.length>0)return e.preventDefault(),r[0].selectPrevious(),!0}if(!_(n))return!1;if(Xi(n,!0)){let r=e.shiftKey;return e.preventDefault(),ji(n,r,!0),!0}return!1},J),o.registerCommand(Fo,e=>{let n=C();if(Oe(n)&&!fs(e.target)){let i=n.getNodes();if(i.length>0)return e.preventDefault(),i[0].selectNext(0,0),!0}if(!_(n))return!1;let r=e.shiftKey;return Xi(n,!1)?(e.preventDefault(),ji(n,r,!1),!0):!1},J),o.registerCommand(Xt,e=>{if(fs(e.target))return!1;let n=C();return _(n)?(e.preventDefault(),o.dispatchCommand(tt,!0)):!1},J),o.registerCommand(jt,e=>{if(fs(e.target))return!1;let n=C();return _(n)?(e.preventDefault(),o.dispatchCommand(tt,!1)):!1},J),o.registerCommand(we,e=>{let n=C();if(!_(n))return!1;if(e!==null){if((Ot||Gt||Jt)&&bo)return!1;if(e.preventDefault(),e.shiftKey)return o.dispatchCommand(qt,!1)}return o.dispatchCommand(Yt,void 0)},J),o.registerCommand(Uo,()=>{let e=C();return _(e)?(o.blur(),!0):!1},J),o.registerCommand(Wo,e=>{let[,n]=us(e);if(n.length>0){let i=e.clientX,s=e.clientY,l=cs(i,s);if(l!==null){let{offset:a,node:d}=l,u=G(d);if(u!==null){let m=on();if(L(u))m.anchor.set(u.getKey(),a,"text"),m.focus.set(u.getKey(),a,"text");else{let f=u.getParentOrThrow().getKey(),g=u.getIndexWithinParent()+1;m.anchor.set(f,g,"element"),m.focus.set(f,g,"element")}let c=qo(m);Y(c)}o.dispatchCommand(Jf,n)}return e.preventDefault(),!0}let r=C();return!!_(r)},J),o.registerCommand(Er,e=>{let[n]=us(e),r=C();return!(n&&!_(r))},J),o.registerCommand(Tr,e=>{let[n]=us(e),r=C();if(n&&!_(r))return!1;let i=e.clientX,s=e.clientY,l=cs(i,s);if(l!==null){let a=G(l.node);H(a)&&e.preventDefault()}return!0},J),o.registerCommand(Ln,()=>(Wl(),!0),J),o.registerCommand(xo,e=>(Gn(o,Tt(e,ClipboardEvent)?e:null),!0),J),o.registerCommand(Eo,e=>(qx(e,o),!0),J),o.registerCommand(go,e=>{let[,n,r]=us(e);return n.length>0&&!r?(o.dispatchCommand(Jf,n),!0):In(e.target)?!1:C()!==null?(Wx(e,o),!0):!1},J))}var sn=class o extends X{constructor(e,n){super(n);p(this,"__id","");p(this,"__category","info");p(this,"__alignment","");p(this,"__inset",0);this.__category=e}static getType(){return"callout"}static clone(e){let n=new o(e.__category,e.__key);return n.__id=e.__id,n.__alignment=e.__alignment,n.__inset=e.__inset,n}setCategory(e){let n=this.getWritable();n.__category=e}getCategory(){return this.getLatest().__category}setId(e){let n=this.getWritable();n.__id=e}getId(){return this.getLatest().__id}setAlignment(e){let n=this.getWritable();n.__alignment=e}getAlignment(){return this.getLatest().__alignment}setInset(e){let n=this.getWritable();n.__inset=e}getInset(){return this.getLatest().__inset}createDOM(e,n){let r=document.createElement("p");return r.classList.add("callout",this.__category||""),dt(r,this),r}updateDOM(e){return e.__category!==this.__category||Oo(e,this)}insertNewAfter(e,n){let r=e?e.anchor.offset:0,i=r===this.getTextContentSize()||!e?I():Jn(this.__category);if(i.setDirection(this.getDirection()),this.insertAfter(i,n),r===0&&!this.isEmpty()&&e){let s=I();s.select(),this.replace(s,!0)}return i}static importDOM(){return{p(e){return e.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 at(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(e){let n=Jn(e.category);return ct(e,n),n}};function Jn(o="info"){return new sn(o)}function Ia(o){return o instanceof sn}function $a(o,t="info"){return o instanceof sn&&o.getCategory()===t}var ln=class o extends X{constructor(e,n={},r){super(r);p(this,"__url");p(this,"__target");p(this,"__rel");p(this,"__title");let{target:i=null,rel:s=null,title:l=null}=n;this.__url=e,this.__target=i,this.__rel=s,this.__title=l}static getType(){return"link"}static clone(e){return new o(e.__url,{rel:e.__rel,target:e.__target,title:e.__title},e.__key)}createDOM(e){let n=document.createElement("a");return n.href=this.__url,this.__target!==null&&(n.target=this.__target),this.__rel!==null&&(n.rel=this.__rel),this.__title!==null&&(n.title=this.__title),ye(n,e.theme.link),n}updateDOM(e,n,r){if(n instanceof HTMLAnchorElement){let i=this.__url,s=this.__target,l=this.__rel,a=this.__title;i!==e.__url&&(n.href=i),s!==e.__target&&(s?n.target=s:n.removeAttribute("target")),l!==e.__rel&&(l?n.rel=l:n.removeAttribute("rel")),a!==e.__title&&(a?n.title=a:n.removeAttribute("title"))}return!1}static importDOM(){return{a:e=>({conversion:Zx,priority:1})}}static importJSON(e){let n=yt(e.url,{rel:e.rel,target:e.target,title:e.title});return n.setDirection(e.direction),n}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 n=this.getWritable();n.__url=e}getTarget(){return this.getLatest().__target}setTarget(e){let n=this.getWritable();n.__target=e}getRel(){return this.getLatest().__rel}setRel(e){let n=this.getWritable();n.__rel=e}getTitle(){return this.getLatest().__title}setTitle(e){let n=this.getWritable();n.__title=e}insertNewAfter(e,n=!0){let r=yt(this.__url,{rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(r,n),r}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,n,r){if(!_(n))return!1;let i=n.anchor.getNode(),s=n.focus.getNode();return this.isParentOf(i)&&this.isParentOf(s)&&n.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}};function Zx(o){let t=null;if(Pi(o)){let e=o.textContent;(e!==null&&e!==""||o.children.length>0)&&(t=yt(o.getAttribute("href")||"",{rel:o.getAttribute("rel"),target:o.getAttribute("target"),title:o.getAttribute("title")}))}return{node:t}}function yt(o,t){return re(new ln(o,t))}function Ft(o){return o instanceof ln}var bL=$("TOGGLE_LINK_COMMAND");var an=class o extends X{constructor(e,n,r){super(r);p(this,"__src","");p(this,"__alt","");p(this,"__width",0);p(this,"__height",0);p(this,"__alignment","");this.__src=e,n.alt&&(this.__alt=n.alt),n.width&&(this.__width=n.width),n.height&&(this.__height=n.height)}static getType(){return"image"}static clone(e){let n=new o(e.__src,{alt:e.__alt,width:e.__width,height:e.__height},e.__key);return n.__alignment=e.__alignment,n}setSrc(e){let n=this.getWritable();n.__src=e}getSrc(){return this.getLatest().__src}setAltText(e){let n=this.getWritable();n.__alt=e}getAltText(){return this.getLatest().__alt}setHeight(e){let n=this.getWritable();n.__height=e}getHeight(){return this.getLatest().__height}setWidth(e){let n=this.getWritable();n.__width=e}getWidth(){return this.getLatest().__width}setAlignment(e){let n=this.getWritable();n.__alignment=e}getAlignment(){return this.getLatest().__alignment}isInline(){return!0}createDOM(e,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(()=>{this.select()})}),r}updateDOM(e,n){return e.__src!==this.__src&&n.setAttribute("src",this.__src),e.__width!==this.__width&&(this.__width?n.setAttribute("width",String(this.__width)):n.removeAttribute("width")),e.__height!==this.__height&&(this.__height?n.setAttribute("height",String(this.__height)):n.removeAttribute("height")),e.__alt!==this.__alt&&(this.__alt?n.setAttribute("alt",String(this.__alt)):n.removeAttribute("alt")),e.__alignment!==this.__alignment&&(e.__alignment&&n.classList.remove("align-"+e.__alignment),this.__alignment&&n.classList.add("align-"+this.__alignment)),!1}static importDOM(){return{img(e){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(Xr(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(e){let n=dn(e.src,{alt:e.alt,width:e.width,height:e.height});return n.setAlignment(e.alignment),n}};function dn(o,t={}){return new an(o,t)}function Qe(o){return o instanceof an}function Pa(o){return"build"in o}var Re=class{constructor(){p(this,"dom",null);p(this,"context",null);p(this,"abortController",new AbortController)}setContext(t){this.context=t}getContext(){if(this.context===null)throw new Error("Attempted to use EditorUIContext before it has been set");return this.context}getDOMElement(){return this.dom||(this.dom=this.buildDOM()),this.dom}rebuildDOM(){let t=this.buildDOM();return this.dom?.replaceWith(t),this.dom=t,this.dom}trans(t){return this.getContext().translate(t)}updateState(t){}emitEvent(t,e={}){this.dom&&this.dom.dispatchEvent(new CustomEvent("editor::"+t,{detail:e,bubbles:!0}))}onEvent(t,e,n=null){let r=n||this.dom;r&&r.addEventListener("editor::"+t,(i=>{e(i.detail)}),{signal:this.abortController.signal})}teardown(){this.dom&&this.dom.isConnected&&this.dom.remove(),this.abortController.abort("teardown")}},oe=class extends Re{constructor(e){super();p(this,"children",[]);this.children.push(...e)}buildDOM(){return y("div",{},this.getChildren().map(e=>e.getDOMElement()))}getChildren(){return this.children}addChildren(...e){this.children.push(...e)}removeChildren(...e){for(let n of e)this.removeChild(n)}removeChild(e){let n=this.children.indexOf(e);n!==-1&&this.children.splice(n,1)}updateState(e){for(let n of this.children)n.updateState(e)}setContext(e){super.setContext(e);for(let n of this.getChildren())n.setContext(e)}teardown(){for(let e of this.children)e.teardown();super.teardown()}},Jr=class extends oe{constructor(e,n){super(n);p(this,"className");this.className=e}buildDOM(){return y("div",{class:this.className},this.getChildren().map(e=>e.getDOMElement()))}};function Qf(o,t,e){let n=null;return function(...i){let s=this,l=function(){n=null,e||o.apply(s,i)},a=e&&!n;n&&clearTimeout(n),n=window.setTimeout(l,t),a&&o.apply(s,i)}}function em(){let o=()=>((1+Math.random())*65536|0).toString(16).substring(1);return`${o()+o()}-${o()}-${o()}-${o()}-${o()}${o()}${o()}`}function ps(){return((1+Math.random())*65536|0).toString(16).substring(1)}var Kt=class extends Re{constructor(e){super();p(this,"definition");this.definition=e}setValue(e){let n=this.getDOMElement().querySelector("input,select,textarea");this.definition.type==="checkbox"?n.checked=!!e:n.value=e,n.dispatchEvent(new Event("change"))}getName(){return this.definition.name}buildDOM(){let e=`editor-form-field-${this.definition.name}-${Date.now()}`,n;if(this.definition.type==="select"){let r=this.definition.valuesByLabel,s=Object.keys(r).map(l=>y("option",{value:r[l]},[this.trans(l)]));n=y("select",{id:e,name:this.definition.name,class:"editor-form-field-input"},s)}else if(this.definition.type==="textarea")n=y("textarea",{id:e,name:this.definition.name,class:"editor-form-field-input"});else if(this.definition.type==="checkbox")n=y("input",{id:e,name:this.definition.name,type:"checkbox",class:"editor-form-field-input-checkbox",value:"true"});else{if(this.definition.type==="hidden")return n=y("input",{id:e,name:this.definition.name,type:"hidden"}),y("div",{hidden:"true"},[n]);n=y("input",{id:e,name:this.definition.name,class:"editor-form-field-input"})}return y("div",{class:"editor-form-field-wrapper"},[y("label",{class:"editor-form-field-label",for:e},[this.trans(this.definition.label)]),n])}},gs=class extends oe{constructor(e){let n=e.fields.map(r=>Pa(r)?r.build():new Kt(r));super(n);p(this,"definition");p(this,"onCancel",null);p(this,"onSuccessfulSubmit",null);this.definition=e}focusOnFirst(){let e=this.getDOMElement().querySelector("input,select,textarea");e&&e.focus()}setValues(e){for(let n of Object.keys(e)){let r=this.getFieldByName(n);r&&r.setValue(e[n])}}setOnCancel(e){this.onCancel=e}setOnSuccessfulSubmit(e){this.onSuccessfulSubmit=e}getFieldByName(e){let n=r=>{for(let i of r){if(i instanceof Kt&&i.getName()===e)return i;if(i instanceof oe){let s=n(i.getChildren());if(s)return s}}return null};return n(this.getChildren())}buildDOM(){let e=y("button",{type:"button",class:"editor-form-action-secondary"},[this.trans("Cancel")]),n=y("form",{},[...this.children.map(r=>r.getDOMElement()),y("div",{class:"editor-form-actions"},[e,y("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()}),e.addEventListener("click",r=>{this.onCancel&&this.onCancel()}),n}},Ba=class extends oe{constructor(e){let n=e.contents.map(r=>Pa(r)?r.build():new Kt(r));super(n);p(this,"definition");p(this,"fields");p(this,"id");this.definition=e,this.fields=n,this.id=em()}getLabel(){return this.getContext().translate(this.definition.label)}getId(){return this.id}buildDOM(){return y("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()))}},cn=class extends oe{constructor(e){let n=e.map(r=>new Ba(r));super(n);p(this,"definitions",[]);p(this,"tabs",[]);this.definitions=e,this.tabs=n}buildDOM(){let e=[],n=[],r=i=>{for(let s=0;s{r(e.indexOf(s))})}return r(0),y("div",{class:"editor-form-tab-container"},[y("div",{class:"editor-form-tab-controls"},e),y("div",{class:"editor-form-tab-contents"},n)])}};var Vx=["width","height","style","title","name","src","allow","allowfullscreen","loading","sandbox","type","data","controls","autoplay","controlslist","loop","muted","playsinline","poster","preload"];function Xx(o){let t={};for(let e of Object.keys(o))Vx.includes(e)&&(t[e]=o[e]);return t}function hs(o,t){let e=Object.assign({},o);if(!o.style)return e;let n=xa(o.style);return n.delete(t),e.style=of(n),e}function tm(o,t){let e=om(o),n={};for(let i of t.attributes)n[i.name]=i.value;e.setAttributes(n);let r=[];if(o==="video"||o==="audio"){for(let i of t.children)if(i.tagName==="SOURCE"){let s=i.getAttribute("src"),l=i.getAttribute("type");s&&l&&r.push({src:s,type:l})}e.setSources(r)}return at(t,e),e}var Ro=class o extends X{constructor(e,n){super(n);p(this,"__id","");p(this,"__alignment","");p(this,"__tag");p(this,"__attributes",{});p(this,"__sources",[]);p(this,"__inset",0);this.__tag=e}static getType(){return"media"}static clone(e){let n=new o(e.__tag,e.__key);return n.__attributes=Object.assign({},e.__attributes),n.__sources=e.__sources.map(r=>Object.assign({},r)),n.__id=e.__id,n.__alignment=e.__alignment,n.__inset=e.__inset,n}setTag(e){let n=this.getWritable();n.__tag=e}getTag(){return this.getLatest().__tag}setAttributes(e){let n=this.getWritable();n.__attributes=Xx(e)}getAttributes(){let e=this.getLatest();return Object.assign({},e.__attributes)}setSources(e){let n=this.getWritable();n.__sources=e}getSources(){return this.getLatest().__sources.map(n=>Object.assign({},n))}setSrc(e){let n=this.getAttributes(),r=this.getSources();this.__tag==="object"&&(n.data=e),this.__tag==="video"&&r.length>0?(r[0].src=e,delete n.src,r.length>1&&r.splice(1,r.length-1),this.setSources(r)):n.src=e,this.setAttributes(n)}setWidthAndHeight(e,n){let r=Object.assign(this.getAttributes(),{width:e,height:n});r=hs(r,"width"),r=hs(r,"height"),this.setAttributes(r)}setId(e){let n=this.getWritable();n.__id=e}getId(){return this.getLatest().__id}setAlignment(e){let n=this.getWritable();n.__alignment=e}getAlignment(){return this.getLatest().__alignment}setInset(e){let n=this.getWritable();n.__inset=e}getInset(){return this.getLatest().__inset}setHeight(e){if(!e)return;let n=Object.assign(this.getAttributes(),{height:e});this.setAttributes(hs(n,"height"))}getHeight(){let e=this.getLatest();return Qo(e.__attributes.height||"0")}setWidth(e){let n=this.getAttributes(),r=Object.assign(n,{width:e});this.setAttributes(hs(r,"width"))}getWidth(){let e=this.getLatest();return Qo(e.__attributes.width||"0")}isInline(){return!0}isParentRequired(){return!0}createInnerDOM(){let n=(this.__tag==="video"||this.__tag==="audio"?this.__sources:[]).map(i=>y("source",i)),r=y(this.__tag,this.__attributes,n);return dt(r,this),r}createDOM(e,n){let r=this.createInnerDOM();return y("span",{class:r.className+" editor-media-wrap"},[r])}updateDOM(e,n){if(e.__tag!==this.__tag||JSON.stringify(e.__sources)!==JSON.stringify(this.__sources)||JSON.stringify(e.__attributes)!==JSON.stringify(this.__attributes))return!0;let r=n.firstElementChild;return e.__id!==this.__id&&nf(r,"id",this.__id),e.__alignment!==this.__alignment&&(e.__alignment&&(n.classList.remove(`align-${e.__alignment}`),r.classList.remove(`align-${e.__alignment}`)),this.__alignment&&(n.classList.add(`align-${this.__alignment}`),r.classList.add(`align-${this.__alignment}`))),e.__inset!==this.__inset&&(n.style.paddingLeft=`${this.__inset}px`),!1}static importDOM(){let e=n=>r=>({conversion:i=>({node:tm(n,i)}),priority:3});return{iframe:e("iframe"),embed:e("embed"),object:e("object"),video:e("video"),audio:e("audio")}}exportDOM(e){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(e){let n=om(e.tag);return ct(e,n),n}};function om(o){return new Ro(o)}function nm(o){let n=new DOMParser().parseFromString(`${o}`,"text/html").body.children[0];if(!(n instanceof HTMLElement))return null;let r=n.tagName.toLowerCase();return["embed","iframe","video","audio","object"].includes(r)?tm(r,n):null}var jx=[{regex:/.*?youtu\.be\/([\w\-_\?&=.]+)/i,w:560,h:314,url:"https://www.youtube.com/embed/$1"},{regex:/.*youtube\.com(.+)v=([^&]+)(&([a-z0-9&=\-_]+))?.*/i,w:560,h:314,url:"https://www.youtube.com/embed/$2?$4"},{regex:/.*youtube.com\/embed\/([a-z0-9\?&=\-_]+).*/i,w:560,h:314,url:"https://www.youtube.com/embed/$1"}],Gx=["mp4","mpeg","m4v","m4p","mov"],Jx=["3gp","aac","flac","mp3","m4a","ogg","wav","webm"],Qx=["html","htm","php","asp","aspx",""];function rm(o){for(let s of jx)if(o.match(s.regex)){let a=o.replace(s.regex,s.url),d=new Ro("iframe");return d.setSrc(a),d.setHeight(s.h),d.setWidth(s.w),d}let t="iframe",n=(o.split("?")[0].split("/").pop()||"").split("."),r=(n.length>1?n[n.length-1]:"").toLowerCase();Gx.includes(r)?t="video":Jx.includes(r)?t="audio":r&&!Qx.includes(r)&&(t="embed");let i=new Ro(t);return i.setSrc(o),i}function St(o){return o instanceof Ro}var Qr=class extends oe{constructor(e,n){super([e,n]);p(this,"input");p(this,"action");this.input=e,this.action=n}buildDOM(){return y("div",{class:"editor-action-input-container"},[this.input.getDOMElement(),this.action.getDOMElement()])}};var w=class extends Re{constructor(e){super();p(this,"definition");p(this,"active",!1);p(this,"completedSetup",!1);p(this,"disabled",!1);e.action!==void 0?this.definition=e:this.definition={...e,action(){return!1},isActive:()=>!1}}setContext(e){super.setContext(e),this.definition.setup&&!this.completedSetup&&(this.definition.setup(e,this),this.completedSetup=!0)}buildDOM(){let e=this.getLabel(),n=this.definition.format||"small",r=[];if(this.definition.icon||n==="long"){let s=y("div",{class:"editor-button-icon"});s.innerHTML=this.definition.icon||"",r.push(s)}if(!this.definition.icon||n==="long"){let s=y("div",{class:"editor-button-text"},[e]);r.push(s)}let i=y("button",{type:"button",class:`editor-button editor-button-${n}`,title:this.definition.icon?e:null,disabled:this.disabled?"true":null},r);return i.addEventListener("click",this.onClick.bind(this)),i}onClick(){let e=this.definition.action(this.getContext(),this);e instanceof Promise?e.then(n=>{n===!1&&this.emitEvent("button-action")}):e!==!1&&this.emitEvent("button-action")}updateActiveState(e){let n=this.definition.isActive(e,this.getContext());this.setActiveState(n)}updateDisabledState(e){if(this.definition.isDisabled){let n=this.definition.isDisabled(e,this.getContext());this.toggleDisabled(n)}}setActiveState(e){this.active=e,this.dom?.classList.toggle("editor-button-active",this.active)}updateState(e){this.updateActiveState(e.selection),this.updateDisabledState(e.selection)}isActive(){return this.active}getLabel(){return this.trans(this.definition.label)}toggleDisabled(e){this.disabled=e,e?this.dom?.setAttribute("disabled","true"):this.dom?.removeAttribute("disabled")}};function Ns(o){window.$components.first("image-manager").show(e=>{o(e)},"gallery")}function im(o){let t=o.thumbs?.display||o.url,e=yt(t,{target:"_blank"}),n=dn(t,{alt:o.name});return e.append(n),e}async function sm(o,t){if(o===null||o.type.indexOf("image")!==0)throw new Error("Not an image file");let e=o.name||`image-${Date.now()}.png`,n=new FormData;return n.append("file",o,e),n.append("uploaded_to",t),(await window.$http.post("/images/gallery",n)).data}var lm='';var xs='';function Es(o,t){window.$components.first("entity-selector-popup").show(n=>o(n),{initialValue:t||"",searchEndpoint:"/search/entity-selector",entityTypes:"page,book,chapter,bookshelf",entityPermission:"view"})}var tr=class o extends Ht{constructor(e,n){super(n);p(this,"__tag");this.__tag=e}static getType(){return"heading"}static clone(e){let n=new o(e.__tag,e.__key);return Ao(e,n),n}getTag(){return this.__tag}createDOM(e){let n=this.__tag,r=document.createElement(n),s=e.theme.heading;if(s!==void 0){let l=s[n];ye(r,l)}return dt(r,this),r}updateDOM(e,n){return Oo(e,this)}static importDOM(){return{h1:e=>({conversion:Qn,priority:0}),h2:e=>({conversion:Qn,priority:0}),h3:e=>({conversion:Qn,priority:0}),h4:e=>({conversion:Qn,priority:0}),h5:e=>({conversion:Qn,priority:0}),h6:e=>({conversion:Qn,priority:0})}}exportDOM(e){let{element:n}=super.exportDOM(e);return n&&he(n)&&this.isEmpty()&&n.append(document.createElement("br")),{element:n}}static importJSON(e){let n=er(e.tag);return ct(e,n),n}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(e,n=!0){let r=e?e.anchor.offset:0,i=this.getLastDescendant(),l=!i||e&&e.anchor.key===i.getKey()&&r===i.getTextContentSize()||!e?I():er(this.getTag()),a=this.getDirection();if(l.setDirection(a),this.insertAfter(l,n),r===0&&!this.isEmpty()&&e){let d=I();d.select(),this.replace(d,!0)}return l}collapseAtStart(){let e=this.isEmpty()?I():er(this.getTag());return this.getChildren().forEach(r=>e.append(r)),this.replace(e),!0}extractWithChild(){return!0}};function Qn(o){let t=o.nodeName.toLowerCase(),e=null;return(t==="h1"||t==="h2"||t==="h3"||t==="h4"||t==="h5"||t==="h6")&&(e=er(t),at(o,e)),{node:e}}function er(o){return re(new tr(o))}function or(o){return o instanceof tr}var Ts=class extends oe{constructor(e){super([e]);p(this,"input");p(this,"headerMap",new Map);this.input=e}buildDOM(){let e="editor-form-datalist-"+this.input.getName()+"-"+Date.now(),n=this.input.getDOMElement(),r=n.querySelector("input");r?.setAttribute("list",e),r?.setAttribute("autocomplete","off");let i=y("datalist",{id:e}),s=y("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(e){this.getHeaderIdAndText(e).then(({id:n,text:r})=>{let i=this.getContext().manager.getActiveModal("link");i&&i.getForm().setValues({url:`#${n}`,text:r,title:r})})}getHeaderIdAndText(e){return new Promise(n=>{this.getContext().editor.update(()=>{let r=e.getId();r||(r="header-"+ps(),e.setId(r));let i=e.getTextContent();n({id:r,text:i})})})}updateDataList(e){this.getContext().editor.getEditorState().read(()=>{let n=Ta(or);this.headerMap.clear();let r=[];for(let i of n){let s="header-"+i.getKey();this.headerMap.set(s,i),r.push(y("option",{value:s,label:i.getTextContent().substring(0,54)}))}e.innerHTML="",e.append(...r)})}};var am=o=>(o.split(" ").filter(e=>e.startsWith("language-"))[0]||"").replace("language-",""),un=class o extends lt{constructor(e="",n="",r){super(r);p(this,"__id","");p(this,"__language","");p(this,"__code","");this.__language=e,this.__code=n}static getType(){return"code-block"}static clone(e){let n=new o(e.__language,e.__code,e.__key);return n.__id=e.__id,n}setLanguage(e){let n=this.getWritable();n.__language=e}getLanguage(){return this.getLatest().__language}setCode(e){let n=this.getWritable();n.__code=e}getCode(){return this.getLatest().__code}setId(e){let n=this.getWritable();n.__id=e}getId(){return this.getLatest().__id}decorate(e,n){return{type:"code",getNode:()=>this}}isInline(){return!1}isIsolated(){return!0}createDOM(e,n){let r=y("pre",{id:this.__id||null},[y("code",{class:this.__language?`language-${this.__language}`:null},[this.__code])]);return y("div",{class:"editor-code-block-wrap"},[r])}updateDOM(e,n){let r=n.querySelector("code");return r&&(e.__language!==this.__language&&(r.className=this.__language?`language-${this.__language}`:""),e.__id!==this.__id&&n.setAttribute("id",this.__id),e.__code!==this.__code&&(r.textContent=this.__code)),!1}exportDOM(e){return{element:this.createDOM(e._config,e).querySelector("pre")}}static importDOM(){return{pre(e){return{conversion:n=>{let r=n.querySelector("code"),i=am(n.className)||r&&am(r.className)||"",s=r?(r.textContent||"").trim():(n.textContent||"").trim(),l=Cs(i,s);return n.id&&l.setId(n.id),{node:l,after(a){return[]}}},priority:3}}}}exportJSON(){return{type:"code-block",version:1,id:this.__id,language:this.__language,code:this.__code}}static importJSON(e){let n=Cs(e.language,e.code);return n.setId(e.id||""),n}};function Cs(o="",t=""){return new un(o,t)}function bs(o){return o instanceof un}function ei(o,t){let e=t.getCode(),n=t.getLanguage();window.$components.first("code-editor").open(e,n,"ltr",(i,s)=>{o.update(()=>{t.setCode(i),t.setLanguage(s)})},()=>{})}function Ha(o){let t=1,e=o.getParent();for(;e!=null;){if(j(e)){let n=e.getParent();if(W(n)){t++,e=n.getParent();continue}T(!1,"A ListItemNode must have a ListNode for a parent.")}return t}return t}function Fa(o){let t=o.getParent();W(t)||T(!1,"A ListItemNode must have a ListNode for a parent.");let e=t;for(;e!==null;)e=e.getParent(),W(e)&&(t=e);return t}function Ka(o){let t=[],e=o.getChildren().filter(j);for(let n=0;n{let e=C();if(e!==null){let n=e.getNodes();if(_(e)){let i=e.getStartEndPoints();T(i!==null,"insertList: anchor should be defined");let[s]=i,l=s.getNode(),a=l.getParent();if(um(l,n)){let d=Se(t);if(ge(a)){l.replace(d);let u=Ue();d.append(u)}else if(j(l)){let u=l.getParentOrThrow();ti(d,u.getChildren()),u.replace(d)}return}}let r=new Set;for(let i=0;i0&&o.append(...r),t.remove()}function za(o){o.update(()=>{let t=C();if(_(t)){let e=new Set,n=t.getNodes(),r=t.anchor.getNode();if(um(r,n))e.add(Fa(r));else for(let i=0;i{if(T(j(e),"node is not a ListItemNode"),e.__checked==null)return;let n=e.getParent();W(n)&&n.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:oE,priority:0})}}static importJSON(e){let n=Ue();return n.setChecked(e.checked),n.setValue(e.value),n.setDirection(e.direction),n}exportDOM(e){let n=this.createDOM(e._config);if(n.classList.contains("task-list-item")){let r=y("input",{type:"checkbox",disabled:"disabled"});n.hasAttribute("checked")&&(r.setAttribute("checked","checked"),n.removeAttribute("checked")),n.prepend(r)}return{element:n}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(),version:1}}append(...e){for(let n=0;n{e.append(i)})),this.remove(),r.getChildrenSize()===0&&r.remove(),e}insertAfter(e,n=!0){let r=this.getParentOrThrow();if(W(r)||T(!1,"insertAfter: list node is not parent of list item node"),j(e))return super.insertAfter(e,n);let i=this.getNextSiblings();if(r.insertAfter(e,n),i.length!==0){let s=Se(r.getListType());i.forEach(l=>s.append(l)),e.insertAfter(s,n)}return e}remove(e){let n=this.getPreviousSibling(),r=this.getNextSibling();super.remove(e),n&&r&&nr(n)&&nr(r)&&(_s(n.getFirstChild(),r.getFirstChild()),r.remove())}insertNewAfter(e,n=!0){if(this.getTextContent().trim()===""&&this.isLastChild()){let i=this.getParentOrThrow(),s=i.getParent();if(j(s))return s.insertAfter(this),this.selectStart(),null;{let l=I();return i.insertAfter(l,n),this.remove(),l}}let r=Ue(this.__checked==null?void 0:!1);return this.insertAfter(r,n),r}collapseAtStart(e){let n=I();this.getChildren().forEach(a=>n.append(a));let i=this.getParentOrThrow(),s=i.getParentOrThrow(),l=j(s);if(i.getChildrenSize()===1)if(l)i.remove(),s.select();else{i.insertBefore(n),i.remove();let a=e.anchor,d=e.focus,u=n.getKey();a.type==="element"&&a.getNode().is(this)&&a.set(u,a.offset,"element"),d.type==="element"&&d.getNode().is(this)&&d.set(u,d.offset,"element")}else i.insertBefore(n),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){let n=this.getWritable();n.__value=e}getChecked(){let e=this.getLatest(),n,r=this.getParent();return W(r)&&(n=r.getListType()),n==="check"?!!e.__checked:void 0}setChecked(e){let n=this.getWritable();n.__checked=e}toggleChecked(){this.setChecked(!this.__checked)}canInsertAfter(e){return j(e)}canReplaceWith(e){return j(e)}canMergeWith(e){return Ge(e)||j(e)}extractWithChild(e,n){if(!_(n))return!1;let r=n.anchor.getNode(),i=n.focus.getNode();return this.isParentOf(r)&&this.isParentOf(i)&&this.getTextContent().length===n.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return Se("bullet")}canMergeWhenEmpty(){return!0}};function pm(o){let t=o.getChildren(),e=!1,n=!1;for(let r of t)W(r)?n=!0:r.getTextContent().trim().length>0&&(e=!0);return n&&!e}function gm(o,t){let e=!W(t.getFirstChild());o.classList.toggle("task-list-item",e),t.__checked?o.setAttribute("checked","checked"):o.removeAttribute("checked")}function oE(o){if(o.classList.contains("task-list-item")){for(let r of o.children)if(r.tagName==="INPUT")return nE(r)}let e=o.getAttribute("aria-checked");return{node:Ue(e==="true"?!0:e==="false"?!1:void 0)}}function nE(o){if(!(o.getAttribute("type")==="checkbox"))return{node:null};let e=o.hasAttribute("checked");return{node:Ue(e)}}function Ue(o){return re(new Ut(void 0,o))}function j(o){return o instanceof Ut}var ko=class o extends X{constructor(e,n,r){super(r);p(this,"__tag");p(this,"__start");p(this,"__listType");p(this,"__id","");let i=sE[e]||e;this.__listType=i,this.__tag=i==="number"?"ol":"ul",this.__start=n}static getType(){return"list"}static clone(e){let n=new o(e.__listType,e.__start,e.__key);return n.__id=e.__id,n.__dir=e.__dir,n}getTag(){return this.__tag}setId(e){let n=this.getWritable();n.__id=e}getId(){return this.getLatest().__id}setListType(e){let n=this.getWritable();n.__listType=e,n.__tag=e==="number"?"ol":"ul"}getListType(){return this.__listType}getStart(){return this.__start}createDOM(e,n){let r=this.__tag,i=document.createElement(r);return this.__start!==1&&i.setAttribute("start",String(this.__start)),i.__lexicalListType=this.__listType,hm(i,e.theme,this),this.__id&&i.setAttribute("id",this.__id),this.__dir&&i.setAttribute("dir",this.__dir),i}updateDOM(e,n,r){return e.__tag!==this.__tag||e.__dir!==this.__dir||e.__id!==this.__id?!0:(hm(n,r.theme,this),!1)}static transform(){return e=>{T(W(e),"node is not a ListNode"),mm(e),fm(e)}}static importDOM(){return{ol:()=>({conversion:Nm,priority:0}),ul:()=>({conversion:Nm,priority:0})}}static importJSON(e){let n=Se(e.listType,e.start);return n.setId(e.id),n.setDirection(e.direction),n}exportDOM(e){let{element:n}=super.exportDOM(e);return n&&he(n)&&(this.__start!==1&&n.setAttribute("start",String(this.__start)),this.__listType==="check"&&n.setAttribute("__lexicalListType","check")),{element:n}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag(),type:"list",version:1,id:this.__id}}canBeEmpty(){return!1}canIndent(){return!1}append(...e){for(let n=0;n1?n.push(...g):r.push(...g)}}r.length>0&&Gi(o,...r),n.length>0&&ye(o,...n)}function rE(o){let t=[];for(let e of o)j(e)?t.push(e):t.push(dm(e));return t}function iE(o){if(o.getAttribute("__lexicallisttype")==="check"||o.classList.contains("contains-task-list"))return!0;for(let t of o.childNodes)if(he(t)&&(t.hasAttribute("aria-checked")||t.classList.contains("task-list-item")||t.firstElementChild&&t.firstElementChild.matches('input[type="checkbox"]')))return!0;return!1}function Nm(o){let t=o.nodeName.toLowerCase(),e=null;if(t==="ol"){let n=o.start;e=Se("number",n)}else t==="ul"&&(iE(o)?e=Se("check"):e=Se("bullet"));return o.id&&e&&e.setId(o.id),o.dir&&e&&e.setDirection(jr(o)),{after:rE,node:e}}var sE={ol:"number",ul:"bullet"};function Se(o,t=1){return re(new ko(o,t))}function W(o){return o instanceof ko}var ev=$("INSERT_UNORDERED_LIST_COMMAND"),tv=$("INSERT_ORDERED_LIST_COMMAND"),ov=$("INSERT_CHECK_LIST_COMMAND"),nv=$("REMOVE_LIST_COMMAND");var rr=class o extends Ht{static getType(){return"quote"}static clone(t){let e=new o(t.__key);return Ao(t,e),e}constructor(t){super(t)}createDOM(t){let e=document.createElement("blockquote");return ye(e,t.theme.quote),dt(e,this),e}updateDOM(t,e){return Oo(t,this)}static importDOM(){return{blockquote:t=>({conversion:lE,priority:0})}}exportDOM(t){let{element:e}=super.exportDOM(t);return e&&he(e)&&this.isEmpty()&&e.append(document.createElement("br")),{element:e}}static importJSON(t){let e=ys();return ct(t,e),e}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(t,e){let n=I(),r=this.getDirection();return n.setDirection(r),this.insertAfter(n,e),n}collapseAtStart(){let t=I();return this.getChildren().forEach(n=>t.append(n)),this.replace(t),!0}canMergeWhenEmpty(){return!0}};function ys(){return re(new rr)}function Ss(o){return o instanceof rr}function lE(o){let t=ys();return at(o,t),{node:t}}var aE=(o,t)=>or(o)&&o.getTag()===t;function Ls(o,t){o.update(()=>{Vn(e=>aE(e,t),()=>er(t))})}function oi(o){o.update(()=>{Vn(Ge,I)})}function ni(o){o.update(()=>{Vn(Ss,ys)})}function ri(o,t){o.getEditorState().read(()=>{let e=C();de(e,r=>W(r)&&r.getListType()===t)?za(o):Ua(o,t)})}function ii(o){o.getEditorState().read(()=>{let t=C(),e=ae(o),n=V(e,bs);n===null?o.update(()=>{let r=Cs();r.setCode(t?.getTextContent()||"");let i=Pt(t),s=i[0],l=i.slice(1);s?(s.replace(r),l.forEach(a=>a.remove())):tn(r,!0),ei(o,r),Be(r)}):ei(o,n)})}function xm(o){o.update(()=>{let t=C(),e=Pt(t),n=!1;for(let i of e)Ia(i)||(i.replace(Jn("info"),!0),n=!0);if(n)return;let r=["info","warning","danger","success"];for(let i of e)if(Ia(i)){let s=i.getCategory(),a=(r.indexOf(s)+1)%r.length,d=r[a];i.setCategory(d)}})}function Ms(o,t){o.update(()=>{let e=C(),n=V(e,Ft);if(Ft(n)?(n.setURL(t.url),n.setTarget(t.target),n.setTitle(t.title)):(n=yt(t.url,{title:t.title,target:t.target}),Ce([n])),Ft(n)){for(let r of n.getChildren())r.remove(!0);n.append(z(t.text))}})}function Em(o,t){let e=t.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)};e.show(i)}var Tm={submitText:"Apply",async action(o,t){return t.editor.update(()=>{let e=ae(t.editor),n=V(e,Qe);Qe(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 Qr(new Kt({label:"Source",name:"src",type:"text"}),new w({label:"Browse files",icon:lm,action(o){Ns(t=>{let e=o.manager.getActiveModal("image");e&&e.getForm().setValues({src:t.thumbs?.display||t.url,alt:t.name})})}}))}},{label:"Alternative description",name:"alt",type:"text"},{label:"Width",name:"width",type:"text"},{label:"Height",name:"height",type:"text"}]};function ws(o,t){let e=t.manager.createModal("link");if(o){let n={url:o.getURL(),text:o.getTextContent(),title:o.getTitle()||"",target:o.getTarget()||""};t.editor.update(()=>{let r=nn();r.add(o.getKey()),Y(r)}),e.show(n)}else t.editor.getEditorState().read(()=>{let i={text:C()?.getTextContent()||""};e.show(i)})}var Cm={submitText:"Apply",async action(o,t){return Ms(t.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 Qr(new Ts(new Kt({label:"URL",name:"url",type:"text"})),new w({label:"Browse links",icon:xs,action(o){Es(t=>{let e=o.manager.getActiveModal("link");e&&e.getForm().setValues({url:t.link,text:t.name,title:t.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"}}]};function bm(o,t){let e=t.manager.createModal("media"),n={};if(o){let r=o.getAttributes(),i=o.exportDOM(t.editor).element,s=i instanceof HTMLElement?i.outerHTML:"";n={src:r.src||r.data||o.getSources()[0]?.src||"",width:r.width,height:r.height,embed:s,embed_check:s}}e.show(n)}var _m={submitText:"Save",async action(o,t){let e=await new Promise((i,s)=>{t.editor.getEditorState().read(()=>{let l=V(C(),St);i(l)})}),n=(o.get("embed")||"").toString().trim(),r=(o.get("embed_check")||"").toString().trim();return n&&n!==r?(t.editor.update(()=>{let i=nm(n);e&&i?e.replace(i):i&&Ce([i])}),!0):(t.editor.update(()=>{let i=(o.get("src")||"").toString().trim(),s=(o.get("height")||"").toString().trim(),l=(o.get("width")||"").toString().trim();if(e){e.setSrc(i),e.setWidthAndHeight(l,s),t.manager.triggerFutureStateRefresh();return}let a=rm(i);(l||s)&&a.setWidthAndHeight(l,s),Ce([a])}),!0)},fields:[{build(){return new cn([{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"},{label:"",name:"embed_check",type:"hidden"}]}])}}]};function vs(o,t){let e=t.manager.createModal("details");o&&e.show({summary:o.getSummary()})}var ym={submitText:"Save",async action(o,t){return t.editor.update(()=>{let e=V(C(),ce),n=(o.get("summary")||"").toString().trim();ce(e)&&e.setSummary(n)}),!0},fields:[{label:"Toggle label",name:"summary",type:"text"}]};var ir=class o extends X{constructor(){super(...arguments);p(this,"__id","");p(this,"__summary","");p(this,"__open",!1)}static getType(){return"details"}setId(e){let n=this.getWritable();n.__id=e}getId(){return this.getLatest().__id}setSummary(e){let n=this.getWritable();n.__summary=e}getSummary(){return this.getLatest().__summary}setOpen(e){let n=this.getWritable();n.__open=e}getOpen(){return this.getLatest().__open}static clone(e){let n=new o(e.__key);return n.__id=e.__id,n.__dir=e.__dir,n.__summary=e.__summary,n.__open=e.__open,n}createDOM(e,n){let r=document.createElement("details");this.__id&&r.setAttribute("id",this.__id),this.__dir&&r.setAttribute("dir",this.__dir),this.__open?(r.setAttribute("open","true"),r.removeAttribute("contenteditable")):r.setAttribute("contenteditable","false");let i=document.createElement("summary");return i.textContent=this.__summary,i.setAttribute("contenteditable","false"),i.addEventListener("click",s=>{s.preventDefault(),n.update(()=>{this.select()})}),i.addEventListener("dblclick",s=>{s.preventDefault();let l=n.getUiContext();l&&n.read(()=>{vs(this,l)})}),r.append(i),r}updateDOM(e,n){return e.__open!==this.__open&&(n.toggleAttribute("open",this.__open),this.__open?n.removeAttribute("contenteditable"):n.setAttribute("contenteditable","false")),e.__id!==this.__id||e.__dir!==this.__dir||e.__summary!==this.__summary}static importDOM(){return{details(e){return{conversion:n=>{let r=new o;n.id&&r.setId(n.id),n.dir&&r.setDirection(jr(n));let i=Array.from(n.children).find(s=>s.nodeName==="SUMMARY");return r.setSummary(i?.textContent||""),{node:r}},priority:3}},summary(e){return{conversion:n=>({node:"ignore"}),priority:3}}}}exportDOM(e){let n=this.createDOM(e._config,e),r=n.querySelectorAll("[contenteditable]");for(let i of r)i.removeAttribute("contenteditable");return n.removeAttribute("open"),n.removeAttribute("contenteditable"),{element:n}}exportJSON(){return{...super.exportJSON(),type:"details",version:1,id:this.__id,summary:this.__summary}}static importJSON(e){let n=Wa();return n.setId(e.id),n.setDirection(e.direction),n}shouldSelectDirectly(){return!0}canBeEmpty(){return!1}};function Wa(){return new ir}function ce(o){return o instanceof ir}var ie={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1},ao=class o extends X{constructor(e=ie.NO_STATUS,n=1,r,i){super(i);p(this,"__colSpan");p(this,"__rowSpan");p(this,"__headerState");p(this,"__width");p(this,"__backgroundColor");p(this,"__styles",new Map);p(this,"__alignment","");this.__colSpan=n,this.__rowSpan=1,this.__headerState=e,this.__width=r,this.__backgroundColor=null}static getType(){return"tablecell"}static clone(e){let n=new o(e.__headerState,e.__colSpan,e.__width,e.__key);return n.__rowSpan=e.__rowSpan,n.__backgroundColor=e.__backgroundColor,n.__styles=new Map(e.__styles),n.__alignment=e.__alignment,n}static importDOM(){return{td:e=>({conversion:Sm,priority:0}),th:e=>({conversion:Sm,priority:0})}}static importJSON(e){let n=ze(e.headerState,e.colSpan,e.width);return e.rowSpan&&n.setRowSpan(e.rowSpan),n.setStyles(new Map(Object.entries(e.styles))),n.setAlignment(e.alignment),n}createDOM(e){let n=document.createElement(this.getTag());this.__width&&(n.style.width=`${this.__width}px`),this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),this.__backgroundColor!==null&&(n.style.backgroundColor=this.__backgroundColor),ye(n,e.theme.tableCell,this.hasHeader()&&e.theme.tableCellHeader);for(let[r,i]of this.__styles.entries())n.style.setProperty(r,i);return this.__alignment&&n.classList.add("align-"+this.__alignment),n}exportDOM(e){let{element:n}=super.exportDOM(e);return{element:n}}exportJSON(){return{...super.exportJSON(),backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,type:"tablecell",width:this.getWidth(),styles:Object.fromEntries(this.__styles),alignment:this.__alignment}}getColSpan(){return this.__colSpan}setColSpan(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 n=this.getWritable();return n.__headerState=e,this.__headerState}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){let n=this.getWritable();return n.__width=e,this.__width}getWidth(){return this.getLatest().__width}clearWidth(){let e=this.getWritable();e.__width=void 0}getStyles(){let e=this.getLatest();return new Map(e.__styles)}setStyles(e){let n=this.getWritable();n.__styles=new Map(e)}setAlignment(e){let n=this.getWritable();n.__alignment=e}getAlignment(){return this.getLatest().__alignment}updateTag(e){let r=e.toLowerCase()==="th"?ie.ROW:ie.NO_STATUS,i=this.getWritable();i.__headerState=r}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){this.getWritable().__backgroundColor=e}toggleHeaderStyle(e){let n=this.getWritable();return(n.__headerState&e)===e?n.__headerState-=e:n.__headerState+=e,n}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==ie.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||e.__styles!==this.__styles||e.__alignment!==this.__alignment}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}};function Sm(o){let t=o,e=o.nodeName.toLowerCase(),n;/^(\d+(?:\.\d+)?)px$/.test(t.style.width)&&(n=parseFloat(t.style.width));let i=ze(e==="th"?ie.ROW:ie.NO_STATUS,t.colSpan,n);i.__rowSpan=t.rowSpan;let s=t.style,l=s.textDecoration.split(" "),a=s.fontWeight==="700"||s.fontWeight==="bold",d=l.includes("line-through"),u=s.fontStyle==="italic",m=l.includes("underline");if(o instanceof HTMLElement){let f=Zn(o);f.delete("background-color"),i.setStyles(f),i.setAlignment(Xr(o))}let c=s.backgroundColor||null;return c&&i.setBackgroundColor(c),{after:f=>(f.length===0&&f.push(I()),f),forChild:(f,g)=>{if(D(g)&&!E(f)){let h=I();return Pe(f)&&f.getTextContent()===` +`?null:(L(f)&&(a&&f.toggleFormat("bold"),d&&f.toggleFormat("strikethrough"),u&&f.toggleFormat("italic"),m&&f.toggleFormat("underline")),h.append(f),h)}return f},node:i}}function ze(o=ie.NO_STATUS,t=1,e){return re(new ao(o,t,e))}function D(o){return o instanceof ao}var dE=$("INSERT_TABLE_COMMAND");var co=class o extends X{constructor(e){super(e);p(this,"__height");p(this,"__styles",new Map)}static getType(){return"tablerow"}static clone(e){let n=new o(e.__key);return n.__styles=new Map(e.__styles),n}static importDOM(){return{tr:e=>({conversion:cE,priority:0})}}static importJSON(e){let n=fn();return n.setStyles(new Map(Object.entries(e.styles))),n}exportJSON(){return{...super.exportJSON(),type:"tablerow",version:1,styles:Object.fromEntries(this.__styles),height:this.__height||0}}createDOM(e){let n=document.createElement("tr");this.__height&&(n.style.height=`${this.__height}px`);for(let[r,i]of this.__styles.entries())n.style.setProperty(r,i);return ye(n,e.theme.tableRow),n}isShadowRoot(){return!0}getStyles(){let e=this.getLatest();return new Map(e.__styles)}setStyles(e){let n=this.getWritable();n.__styles=new Map(e)}setHeight(e){let n=this.getWritable();return n.__height=e,this.__height}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height||e.__styles!==this.__styles}canBeEmpty(){return!1}canIndent(){return!1}};function cE(o){let t=fn(),n=Qo(o.style.height);return t.setHeight(n),o instanceof HTMLElement&&t.setStyles(Zn(o)),{node:t}}function fn(){return re(new co)}function te(o){return o instanceof co}var sr=class o extends X{static getType(){return"caption"}static clone(t){return new o(t.__key)}createDOM(t,e){return document.createElement("caption")}updateDOM(t,e,n){return!1}isParentRequired(){return!0}canBeEmpty(){return!1}exportJSON(){return{...super.exportJSON(),type:"caption",version:1}}insertDOMIntoParent(t,e){return e.insertBefore(t,e.firstChild),!0}static importJSON(t){return qa()}static importDOM(){return{caption:t=>({conversion(e){return{node:qa()}},priority:0})}}};function qa(){return new sr}function si(o){return o instanceof sr}function Ya(o){for(let t of o.getChildren())if(si(t))return!0;return!1}function Lm(o,t=""){let e=qa(),n=z(t||" ");e.append(n),o.append(e)}function Va(o,t,e=!0){let n=ai();for(let r=0;ro===ie.BOTH||o===t?t:ie.NO_STATUS;function Ds(o=!0){let t=C();T(_(t)||q(t),"Expected a RangeSelection or TableSelection");let e=t.focus.getNode(),[n,,r]=ke(e),[i,s]=ut(r,n,n),l=i[0].length,{startRow:a}=s;if(o){let d=a+n.__rowSpan-1,u=i[d],m=fn();for(let f=0;f1;)if(k-=M.__colSpan,k>=0){let{cell:Z,startRow:se}=x[k];P=Z,B=se}else{N.append(h(v));continue e}P.insertAfter(h(v))}else M.setColSpan(M.__colSpan+1)}g!==null&&li(g)}function Xa(){let o=C();T(_(o)||q(o),"Expected a RangeSelection or TableSelection");let t=o.anchor.getNode(),e=o.focus.getNode(),[n,,r]=ke(t),[i]=ke(e),[s,l,a]=ut(r,n,i),{startRow:d}=l,{startRow:u}=a,m=u+i.__rowSpan-1;if(s.length===m-d+1){r.remove();return}let c=s[0].length,f=s[m+1],g=r.getChildAtIndex(m+1);for(let h=m;h>=d;h--){for(let b=c-1;b>=0;b--){let{cell:x,startRow:S,startColumn:v}=s[h][b];if(v===b&&(h===d&&S=d&&S+x.__rowSpan-1>m))if(x.setRowSpan(x.__rowSpan-(m-S+1)),T(g!==null,"Expected nextRowNode not to be null"),b===0)Ga(g,x);else{let{cell:M}=f[b-1];M.insertAfter(x)}}let N=r.getChildAtIndex(h);T(te(N),"Expected GridNode childAtIndex(%s) to be RowNode",String(h)),N.remove()}if(f!==void 0){let{cell:h}=f[0];li(h)}else{let h=s[d-1],{cell:N}=h[0];li(N)}}function ja(){let o=C();T(_(o)||q(o),"Expected a RangeSelection or TableSelection");let t=o.anchor.getNode(),e=o.focus.getNode(),[n,,r]=ke(t),[i]=ke(e),[s,l,a]=ut(r,n,i),{startColumn:d}=l,{startRow:u,startColumn:m}=a,c=Math.min(d,m),f=Math.max(d+n.__colSpan-1,m+i.__colSpan-1),g=f-c+1;if(s[0].length===f-c+1){r.selectPrevious(),r.remove();return}let N=s.length;for(let S=0;Sf){if(v===f){let A=f-R+1;M.setColSpan(M.__colSpan-A)}}else M.remove()}let b=s[u],x=d>m?b[d+n.__colSpan]:b[m+i.__colSpan];if(x!==void 0){let{cell:S}=x;li(S)}else{let S=m1){for(let l=1;l1){let[l,a]=ut(r,e,e),{startColumn:d,startRow:u}=a,m;for(let c=1;c1&&(N+=x.__colSpan-1)}if(h===null)for(let N=0;N!si(d));for(let d=0;dx||h>S;){if(cx){let A=S-b,P=x+1;for(let B=0;B<=A;B++)v(d[b+B][P]);x=P}if(h>S){let A=x-N,P=S+1;for(let B=0;B<=A;B++)v(d[P][N+B]);S=P}}let M=[l],R=null;for(let A=f;A<=h;A++)for(let P=c;P<=g;P++){let{cell:B}=d[A][P],k=B.getParent();T(te(k),"Expected TableCellNode parent to be a TableRowNode"),k!==R&&M.push(k),M.push(B,...uE(B)),R=k}return pt()||(this._cachedNodes=M),M}getTextContent(){let t=this.getNodes().filter(n=>D(n)),e="";for(let n=0;n0;){let n=e.pop();T(n!==void 0,"Stack.length > 0; can't be undefined"),E(n)&&e.unshift(...n.getChildren()),n!==o&&t.push(n)}return t}var ci=class{constructor(t,e){p(this,"focusX");p(this,"focusY");p(this,"listenersToRemove");p(this,"table");p(this,"isHighlightingCells");p(this,"anchorX");p(this,"anchorY");p(this,"tableNodeKey");p(this,"anchorCell");p(this,"focusCell");p(this,"anchorCellNodeKey");p(this,"focusCellNodeKey");p(this,"editor");p(this,"tableSelection");p(this,"hasHijackedSelectionStyles");p(this,"isSelecting");this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=e,this.editor=t,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(t=>t())}trackTable(){let t=new MutationObserver(e=>{this.editor.update(()=>{let n=!1;for(let i=0;i{let e=this.editor.getElementByKey(this.tableNodeKey);if(!e)throw new Error("Expected to find TableElement in DOM");this.table=mn(e),t.observe(e,{attributes:!0,childList:!0,subtree:!0})})}clearHighlight(){let t=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(),t.update(()=>{let e=ee(this.tableNodeKey);if(!K(e))throw new Error("Expected TableNode.");let n=t.getElementByKey(this.tableNodeKey);if(!n)throw new Error("Expected to find TableElement in DOM");let r=mn(n);di(t,r,null),Y(null),t.dispatchCommand(_e,void 0)})}enableHighlightStyle(){let t=this.editor;t.update(()=>{let e=t.getElementByKey(this.tableNodeKey);if(!e)throw new Error("Expected to find TableElement in DOM");Gi(e,t._config.theme.tableSelection),e.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1})}disableHighlightStyle(){let t=this.editor;t.update(()=>{let e=t.getElementByKey(this.tableNodeKey);if(!e)throw new Error("Expected to find TableElement in DOM");ye(e,t._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0})}updateTableTableSelection(t){if(t!==null&&t.tableKey===this.tableNodeKey){let e=this.editor;this.tableSelection=t,this.isHighlightingCells=!0,this.disableHighlightStyle(),di(e,this.table,this.tableSelection)}else t==null?this.clearHighlight():(this.tableNodeKey=t.tableKey,this.updateTableTableSelection(t))}setFocusCellForSelection(t,e=!1){let n=this.editor;n.update(()=>{let r=ee(this.tableNodeKey);if(!K(r))throw new Error("Expected TableNode.");if(!n.getElementByKey(this.tableNodeKey))throw new Error("Expected to find TableElement in DOM");let s=t.x,l=t.y;if(this.focusCell=t,this.anchorCell!==null){let a=Qa(n._window);a&&a.setBaseAndExtent(this.anchorCell.elem,0,this.focusCell.elem,0)}if(!this.isHighlightingCells&&(this.anchorX!==s||this.anchorY!==l||e))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=G(t.elem);if(this.tableSelection!=null&&this.anchorCellNodeKey!=null&&D(a)&&r.is(Io(a))){let d=a.getKey();this.tableSelection=this.tableSelection.clone()||ks(),this.focusCellNodeKey=d,this.tableSelection.set(this.tableNodeKey,this.anchorCellNodeKey,this.focusCellNodeKey),Y(this.tableSelection),n.dispatchCommand(_e,void 0),di(n,this.table,this.tableSelection)}}})}setAnchorCellForSelection(t){this.isHighlightingCells=!1,this.anchorCell=t,this.anchorX=t.x,this.anchorY=t.y,this.editor.update(()=>{let e=G(t.elem);if(D(e)){let n=e.getKey();this.tableSelection=this.tableSelection!=null?this.tableSelection.clone():ks(),this.anchorCellNodeKey=n}})}formatCells(t){this.editor.update(()=>{let e=C();q(e)||T(!1,"Expected grid selection");let n=on(),r=n.anchor,i=n.focus;e.getNodes().forEach(s=>{D(s)&&s.getTextContentSize()!==0&&(r.set(s.getKey(),0,"element"),i.set(s.getKey(),s.getChildrenSize(),"element"),n.formatText(t))}),Y(e),this.editor.dispatchCommand(_e,void 0)})}clearText(){let t=this.editor;t.update(()=>{let e=ee(this.tableNodeKey);if(!K(e))throw new Error("Expected TableNode.");let n=C();q(n)||T(!1,"Expected grid selection");let r=n.getNodes().filter(D);if(r.length===this.table.columns*this.table.rows){e.selectPrevious(),e.remove(),F().selectStart();return}r.forEach(i=>{if(E(i)){let s=I(),l=z();s.append(l),i.append(s),i.getChildren().forEach(a=>{a!==s&&a.remove()})}}),di(t,this.table,null),Y(null),t.dispatchCommand(_e,void 0)})}};var fE="__lexicalTableSelection",Qa=o=>pe?(o||window).getSelection():null,mE=o=>(o.buttons&1)===1;function od(o,t,e,n){let r=e.getRootElement();if(r===null)throw new Error("No root element.");let i=new ci(e,o.getKey()),s=e._window||window;pE(t,i);let l=()=>{let c=()=>{i.isSelecting=!1,s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",f)},f=g=>{setTimeout(()=>{if(!mE(g)&&i.isSelecting){i.isSelecting=!1,s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",f);return}let h=td(g.target);h!==null&&(i.anchorX!==h.x||i.anchorY!==h.y)&&(g.preventDefault(),i.setFocusCellForSelection(h))},0)};return{onMouseMove:f,onMouseUp:c}};t.addEventListener("mousedown",c=>{setTimeout(()=>{if(c.button!==0||!s)return;let f=td(c.target);f!==null&&(gn(c),i.setAnchorCellForSelection(f));let{onMouseUp:g,onMouseMove:h}=l();i.isSelecting=!0,s.addEventListener("mouseup",g),s.addEventListener("mousemove",h)},0)});let a=c=>{c.button===0&&e.update(()=>{let f=C(),g=c.target;q(f)&&f.tableKey===i.tableNodeKey&&r.contains(g)&&i.clearHighlight()})};s.addEventListener("mousedown",a),i.listenersToRemove.add(()=>s.removeEventListener("mousedown",a)),i.listenersToRemove.add(e.registerCommand(Vt,c=>ui(e,c,"down",o,i),Je)),i.listenersToRemove.add(e.registerCommand(Zt,c=>ui(e,c,"up",o,i),Je)),i.listenersToRemove.add(e.registerCommand(Ko,c=>ui(e,c,"backward",o,i),Je)),i.listenersToRemove.add(e.registerCommand(Fo,c=>ui(e,c,"forward",o,i),Je)),i.listenersToRemove.add(e.registerCommand(Uo,c=>{let f=C();if(q(f)){let g=U(f.focus.getNode(),D);if(D(g))return gn(c),g.selectEnd(),!0}return!1},Je));let d=c=>()=>{let f=C();if(!pn(f,o))return!1;if(q(f))return i.clearText(),!0;if(_(f)){let g=U(f.anchor.getNode(),R=>D(R));if(!D(g))return!1;let h=f.anchor.getNode(),N=f.focus.getNode(),b=o.isParentOf(h),x=o.isParentOf(N);if(b&&!x||x&&!b)return i.clearText(),!0;let v=U(f.anchor.getNode(),R=>E(R)),M=v&&U(v,R=>E(R)&&D(R.getParent()));if(!E(M)||!E(v))return!1;if(c===mt&&M.getPreviousSibling()===null)return!0}return!1};[Dt,mt,tt].forEach(c=>{i.listenersToRemove.add(e.registerCommand(c,d(c),Ke))});let u=c=>{let f=C();if(!pn(f,o)){let g=f?f.getNodes():null;if(g){let h=g.find(N=>K(N)&&N.getKey()===i.tableNodeKey);if(K(h)){if(!h.getParent())return!1;h.remove()}}return!1}if(q(f))return c&&(c.preventDefault(),c.stopPropagation()),i.clearText(),!0;if(_(f)){let g=U(f.anchor.getNode(),h=>D(h));if(!D(g))return!1}return!1};i.listenersToRemove.add(e.registerCommand(Xt,u,Ke)),i.listenersToRemove.add(e.registerCommand(jt,u,Ke)),i.listenersToRemove.add(e.registerCommand(Eo,c=>{let f=C();if(f){if(!(q(f)||_(f)))return!1;Gn(e,Tt(c,ClipboardEvent)?c:null,ds(f));let g=u(c);return _(f)&&f.removeText(),g}return!1},Ke)),i.listenersToRemove.add(e.registerCommand(Ee,c=>{let f=C();if(!pn(f,o))return!1;if(q(f))return i.formatCells(c),!0;if(_(f)){let g=U(f.anchor.getNode(),h=>D(h));if(!D(g))return!1}return!1},Ke)),i.listenersToRemove.add(e.registerCommand(ft,c=>{let f=C();if(!pn(f,o))return!1;if(q(f))return i.clearHighlight(),!1;if(_(f)){let g=U(f.anchor.getNode(),h=>D(h));if(!D(g))return!1;if(typeof c=="string"){let h=Dm(e,f,o);if(h)return vm(h,o,[z(c)]),!0}}return!1},Ke)),n&&i.listenersToRemove.add(e.registerCommand(zo,c=>{let f=C();if(!_(f)||!f.isCollapsed()||!pn(f,o))return!1;let g=$s(f.anchor.getNode());if(g===null)return!1;gn(c);let h=o.getCordsFromCellNode(g,i.table);return Om(i,o,h.x,h.y,c.shiftKey?"backward":"forward"),!0},Ke)),i.listenersToRemove.add(e.registerCommand(Cr,c=>o.isSelected(),Je));function m(c){let f=o.getCordsFromCellNode(c,i.table);return o.getDOMCellFromCordsOrThrow(f.x,f.y,i.table)}return i.listenersToRemove.add(e.registerCommand(Nr,c=>{let{nodes:f,selection:g}=c,h=g.getStartEndPoints(),N=q(g),x=_(g)&&U(g.anchor.getNode(),qe=>D(qe))!==null&&U(g.focus.getNode(),qe=>D(qe))!==null||N;if(f.length!==1||!K(f[0])||!x||h===null)return!1;let[S]=h,v=f[0],M=v.getChildren(),R=v.getFirstChildOrThrow().getChildrenSize(),A=v.getChildrenSize(),P=U(S.getNode(),qe=>D(qe)),B=P&&U(P,qe=>te(qe)),k=B&&U(B,qe=>K(qe));if(!D(P)||!te(B)||!K(k))return!1;let Z=B.getIndexWithinParent(),se=Math.min(k.getChildrenSize()-1,Z+A-1),We=P.getIndexWithinParent(),nc=Math.min(B.getChildrenSize()-1,We+R-1),Qh=Math.min(We,nc),eN=Math.min(Z,se),tN=Math.max(We,nc),oN=Math.max(Z,se),nN=k.getChildren(),rc=0;for(let qe=eN;qe<=oN;qe++){let ic=nN[qe];if(!te(ic))return!1;let sc=M[rc];if(!te(sc))return!1;let rN=ic.getChildren(),iN=sc.getChildren(),lc=0;for(let Nl=Qh;Nl<=tN;Nl++){let bi=rN[Nl];if(!D(bi))return!1;let ac=iN[lc];if(!D(ac))return!1;let sN=bi.getChildren();ac.getChildren().forEach(yn=>{L(yn)&&I().append(yn),bi.append(yn)}),sN.forEach(yn=>yn.remove()),lc++}rc++}return!0},Ke)),i.listenersToRemove.add(e.registerCommand(_e,()=>{let c=C(),f=je();if(_(c)){let{anchor:g,focus:h}=c,N=g.getNode(),b=h.getNode(),x=$s(N),S=$s(b),v=!!(x&&o.is(Io(x))),M=!!(S&&o.is(Io(S))),R=v!==M,A=v&&M,P=c.isBackward();if(R){let B=c.clone();if(M){let[k]=ut(o,S,S),Z=k[0][0].cell,se=k[k.length-1].at(-1).cell;B.focus.set(P?Z.getKey():se.getKey(),P?Z.getChildrenSize():se.getChildrenSize(),"element")}Y(B),wm(e,i)}else A&&(x.is(S)||(i.setAnchorCellForSelection(m(x)),i.setFocusCellForSelection(m(S),!0),i.isSelecting||setTimeout(()=>{let{onMouseUp:B,onMouseMove:k}=l();i.isSelecting=!0,s.addEventListener("mouseup",B),s.addEventListener("mousemove",k)},0)))}else if(c&&q(c)&&c.is(f)&&c.tableKey===o.getKey()){let g=Qa(e._window);if(g&&g.anchorNode&&g.focusNode){let h=G(g.focusNode),N=h&&!o.is(Io(h)),b=G(g.anchorNode),x=b&&o.is(Io(b));if(N&&x&&g.rangeCount>0){let S=La(g,e);S&&(S.anchor.set(o.getKey(),c.isBackward()?o.getChildrenSize():0,"element"),g.removeAllRanges(),Y(S))}}}return c&&!c.is(f)&&(q(c)||q(f))&&i.tableSelection&&!i.tableSelection.is(f)?(q(c)&&c.tableKey===i.tableNodeKey?i.updateTableTableSelection(c):!q(c)&&q(f)&&f.tableKey===i.tableNodeKey&&i.updateTableTableSelection(null),!1):(i.hasHijackedSelectionStyles&&!o.isSelected()?gE(e,i):!i.hasHijackedSelectionStyles&&o.isSelected()&&wm(e,i),!1)},Ke)),i.listenersToRemove.add(e.registerCommand(Yt,()=>{let c=C();if(!_(c)||!c.isCollapsed()||!pn(c,o))return!1;let f=Dm(e,c,o);return f?(vm(f,o),!0):!1},Ke)),i}function pE(o,t){o[fE]=t}function td(o){let t=o;for(;t!=null;){let e=t.nodeName;if(e==="TD"||e==="TH"){let n=t._cell;return n===void 0?null:n}t=t.parentNode}return null}function mn(o){let t=[],e={columns:0,domRows:t,rows:0},n=o.firstChild,r=0,i=0;for(t.length=0;n!=null;){let s=n.nodeName;if(s==="COLGROUP"||s==="CAPTION"){n=n.nextSibling;continue}if(s==="TD"||s==="TH"){let d=n,u={elem:d,hasBackgroundColor:d.style.backgroundColor!=="",highlighted:!1,x:r,y:i};n._cell=u;let m=t[i];m===void 0&&(m=t[i]=[]),m[r]=u}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 e.columns=r+1,e.rows=i+1,e}function di(o,t,e){let n=new Set(e?e.getNodes():[]);nd(t,(r,i)=>{let s=r.elem;n.has(i)?(r.highlighted=!0,Am(o,r)):(r.highlighted=!1,Rm(o,r),s.getAttribute("style")||s.removeAttribute("style"))})}function nd(o,t){let{domRows:e}=o;for(let n=0;n{e.highlighted=!0,Am(o,e)})}function gE(o,t){t.enableHighlightStyle(),nd(t.table,e=>{let n=e.elem;e.highlighted=!1,Rm(o,e),n.getAttribute("style")||n.removeAttribute("style")})}var Om=(o,t,e,n,r)=>{let i=r==="forward";switch(r){case"backward":case"forward":return e!==(i?o.table.columns-1:0)?Is(t.getCellNodeFromCordsOrThrow(e+(i?1:-1),n,o.table),i):n!==(i?o.table.rows-1:0)?Is(t.getCellNodeFromCordsOrThrow(i?0:o.table.columns-1,n+(i?1:-1),o.table),i):i?t.selectNext():t.selectPrevious(),!0;case"up":return n!==0?Is(t.getCellNodeFromCordsOrThrow(e,n-1,o.table),!1):qr(t,!1),!0;case"down":return n!==o.table.rows-1?Is(t.getCellNodeFromCordsOrThrow(e,n+1,o.table),!0):qr(t,!0),!0;default:return!1}},hE=(o,t,e,n,r)=>{let i=r==="forward";switch(r){case"backward":case"forward":return e!==(i?o.table.columns-1:0)&&o.setFocusCellForSelection(t.getDOMCellFromCordsOrThrow(e+(i?1:-1),n,o.table)),!0;case"up":return n!==0?(o.setFocusCellForSelection(t.getDOMCellFromCordsOrThrow(e,n-1,o.table)),!0):!1;case"down":return n!==o.table.rows-1?(o.setFocusCellForSelection(t.getDOMCellFromCordsOrThrow(e,n+1,o.table)),!0):!1;default:return!1}};function pn(o,t){if(_(o)||q(o)){let e=t.isParentOf(o.anchor.getNode()),n=t.isParentOf(o.focus.getNode());return e&&n}return!1}function Is(o,t){t?o.selectStart():o.selectEnd()}var ed="172,206,247";function Am(o,t){let e=t.elem,n=G(e);T(D(n),"Expected to find LexicalNode from Table Cell DOMNode"),n.getBackgroundColor()===null?e.style.setProperty("background-color",`rgb(${ed})`):e.style.setProperty("background-image",`linear-gradient(to right, rgba(${ed},0.85), rgba(${ed},0.85))`),e.style.setProperty("caret-color","transparent")}function Rm(o,t){let e=t.elem,n=G(e);T(D(n),"Expected to find LexicalNode from Table Cell DOMNode"),n.getBackgroundColor()===null&&e.style.removeProperty("background-color"),e.style.removeProperty("background-image"),e.style.removeProperty("caret-color")}function $s(o){let t=U(o,D);return D(t)?t:null}function Io(o){let t=U(o,K);return K(t)?t:null}function ui(o,t,e,n,r){if((e==="up"||e==="down")&&NE(o))return!1;let i=C();if(!pn(i,n)){if(_(i)){if(i.isCollapsed()&&e==="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=U(a,m=>E(m)&&!m.isInline());if(!d)return!1;let u=d.getPreviousSibling();return!u||!K(u)?!1:(gn(t),u.selectEnd(),!0)}else if(t.shiftKey&&(e==="up"||e==="down")){let s=i.focus.getNode();if(ge(s)){let l=i.getNodes()[0];if(l){let a=U(l,D);if(a&&n.isParentOf(a)){let d=n.getFirstDescendant(),u=n.getLastDescendant();if(!d||!u)return!1;let[m]=ke(d),[c]=ke(u),f=n.getCordsFromCellNode(m,r.table),g=n.getCordsFromCellNode(c,r.table),h=n.getDOMCellFromCordsOrThrow(f.x,f.y,r.table),N=n.getDOMCellFromCordsOrThrow(g.x,g.y,r.table);return r.setAnchorCellForSelection(h),r.setFocusCellForSelection(N,!0),!0}}return!1}else{let l=U(s,d=>E(d)&&!d.isInline());if(!l)return!1;let a=e==="down"?l.getNextSibling():l.getPreviousSibling();if(K(a)&&r.tableNodeKey===a.getKey()){let d=a.getFirstDescendant(),u=a.getLastDescendant();if(!d||!u)return!1;let[m]=ke(d),[c]=ke(u),f=i.clone();return f.focus.set((e==="up"?m:c).getKey(),e==="up"?0:c.getChildrenSize(),"element"),Y(f),!0}}}}return!1}if(_(i)&&i.isCollapsed()){let{anchor:s,focus:l}=i,a=U(s.getNode(),D),d=U(l.getNode(),D);if(!D(a)||!a.is(d))return!1;let u=Io(a);if(u!==n&&u!=null){let x=o.getElementByKey(u.getKey());if(x!=null)return r.table=mn(x),ui(o,t,e,u,r)}if(e==="backward"||e==="forward"){let x=s.type,S=s.offset,v=s.getNode();if(!v)return!1;let M=i.getNodes();return M.length===1&&H(M[0])?!1:xE(x,S,v,e)?CE(t,v,n,e):!1}let m=o.getElementByKey(a.__key),c=o.getElementByKey(s.key);if(c==null||m==null)return!1;let f;if(s.type==="element")f=c.getBoundingClientRect();else{let x=window.getSelection();if(x===null||x.rangeCount===0)return!1;f=x.getRangeAt(0).getBoundingClientRect()}let g=e==="up"?a.getFirstChild():a.getLastChild();if(g==null)return!1;let h=o.getElementByKey(g.__key);if(h==null)return!1;let N=h.getBoundingClientRect();if(e==="up"?N.top>f.top-f.height:f.bottom+f.height>N.bottom){gn(t);let x=n.getCordsFromCellNode(a,r.table);if(t.shiftKey){let S=n.getDOMCellFromCordsOrThrow(x.x,x.y,r.table);r.setAnchorCellForSelection(S),r.setFocusCellForSelection(S,!0)}else return Om(r,n,x.x,x.y,e);return!0}}else if(q(i)){let{anchor:s,focus:l}=i,a=U(s.getNode(),D),d=U(l.getNode(),D),[u]=i.getNodes(),m=o.getElementByKey(u.getKey());if(!D(a)||!D(d)||!K(u)||m==null)return!1;r.updateTableTableSelection(i);let c=mn(m),f=n.getCordsFromCellNode(a,c),g=n.getDOMCellFromCordsOrThrow(f.x,f.y,c);if(r.setAnchorCellForSelection(g),gn(t),t.shiftKey){let h=n.getCordsFromCellNode(d,c);return hE(r,u,h.x,h.y,e)}else d.selectEnd();return!0}return!1}function gn(o){o.preventDefault(),o.stopImmediatePropagation(),o.stopPropagation()}function NE(o){let t=o.getRootElement();return t?t.hasAttribute("aria-controls")&&t.getAttribute("aria-controls")==="typeahead-menu":!1}function xE(o,t,e,n){return EE(o,e,n)||TE(o,t,e,n)}function EE(o,t,e){return o==="element"&&(e==="backward"?t.getPreviousSibling()===null:t.getNextSibling()===null)}function TE(o,t,e,n){let r=U(e,s=>E(s)&&!s.isInline());if(!r)return!1;let i=n==="backward"?t===0:t===e.getTextContentSize();return o==="text"&&i&&(n==="backward"?r.getPreviousSibling()===null:r.getNextSibling()===null)}function CE(o,t,e,n){let r=U(t,D);if(!D(r))return!1;let[i,s]=ut(e,r,r);if(!bE(i,s,n))return!1;let l=_E(t,n,e);return!l||K(l)?!1:(gn(o),n==="backward"?l.selectEnd():l.selectStart(),!0)}function bE(o,t,e){let n=o[0][0],r=o[o.length-1][o[0].length-1],{startColumn:i,startRow:s}=t;return e==="backward"?i===n.startColumn&&s===n.startRow:i===r.startColumn&&s===r.startRow}function _E(o,t,e){let n=U(o,i=>E(i)&&!i.isInline());if(!n)return;let r=t==="backward"?n.getPreviousSibling():n.getNextSibling();return r&&K(r)?r:t==="backward"?e.getPreviousSibling():e.getNextSibling()}function vm(o,t,e){let n=I();o==="first"?t.insertBefore(n):t.insertAfter(n),n.append(...e||[]),n.selectEnd()}function Dm(o,t,e){let n=e.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=U(t.anchor.getNode(),N=>D(N));if(!s)return;let l=U(s,N=>K(N));if(!K(l)||!l.is(e))return;let[a,d]=ut(e,s,s),u=a[0][0],m=a[a.length-1][a[0].length-1],{startRow:c,startColumn:f}=d,g=c===u.startRow&&f===u.startColumn,h=c===m.startRow&&f===m.startColumn;return g?"first":h?"last":void 0}var zt=class{constructor(t){p(this,"rowCount",0);p(this,"columnCount",0);p(this,"cells",[]);this.buildCellMap(t)}buildCellMap(t){let e=[],n=(a,d,u)=>{typeof e[d]>"u"&&(e[d]=[]),e[d][a]=u},r=(a,d)=>!!(e[d]&&e[d][a]),i=t.getChildren().filter(a=>te(a));for(let a=0;aD(c)),m=0;for(let c=0;ca.length));let s=[],l=e[0][0];for(let a=0;a=this.cells.length)throw new Error(`TableMap Error: Attempted to get cell ${n+1} of ${this.cells.length}`);return this.cells[n]}getCellsInRange(t){let e=Math.max(Math.min(t.fromX,t.toX),0),n=Math.min(Math.max(t.fromX,t.toX),this.columnCount-1),r=Math.max(Math.min(t.fromY,t.toY),0),i=Math.min(Math.max(t.fromY,t.toY),this.rowCount-1),s=new Set;for(let l=r;l<=i;l++)for(let a=e;a<=n;a++)s.add(this.getCellAtPosition(a,l));return[...s.values()]}getCellsInColumn(t){return this.getCellsInRange({fromX:t,toX:t,fromY:0,toY:this.rowCount-1})}getRangeForCell(t){let e=null,n=t.getKey();for(let r=0;re&&(n=r,e=r.childElementCount);return n}function km(o){return[...o.children].map(t=>yE(t))}function yE(o){let t=o.style.width||o.getAttribute("width");return t&&!Number.isNaN(Number(t))&&(t=t+"px"),t||""}function id(o,t,e){let n=o.getChildren(),r=0;for(let s of n){let l=s.getChildren().length;l>r&&(r=l)}let i=o.getColWidths();(i.length===0||i.lengthi.length&&console.error(`Attempted to set table column width for column [${t}] but only ${i.length} columns found`),i[t]=Ct(e),o.setColWidths(i)}function Pm(o,t,e){let n=t.getColWidths();if(n.length>e&&n[e].endsWith("px"))return Number(n[e].replace("px",""));let r=o.getElementByKey(t.__key);if(r){let i=$m(r);if(i&&i.children.length>e)return i.children[e].clientWidth}return 0}function Bm(o){let t=o.getParent();if(!te(t))return-1;let e=0,n=t.getChildren();for(let r of n){let i=r.getColSpan()||1;if(e+=i,r.getKey()===o.getKey())break}return e-1}function Hm(o,t){let e=rd(o),n=Bm(o);e&&n>=0&&id(e,n,t)}function Fm(o,t){let e=rd(t),n=Bm(t);if(!e)return"";let r=e.getColWidths();return r.length>n?r[n]:""}function sd(o){if(o.length===0)return null;let t=y("colgroup");for(let e of o){let n=y("col");e&&(n.style.width=e),t.append(n)}return t}function hn(o){if(q(o))return o.getNodes().filter(n=>D(n));let t=V(o,D);return t?[t]:[]}function Km(o){let t=o.getShape(),e=hn(o);if(e.length===0)return;let n=rd(e[0]);if(!n)return;let r=new zt(n),i=r.getCellAtPosition(t.toX,t.toY);if(!i)return;let s=t.toX+((i.getColSpan()||1)-1),l=t.toY+((i.getRowSpan()||1)-1),a=r.getCellsInRange({fromX:t.fromX,fromY:t.fromY,toX:s,toY:l});if(a.length===0)return;let d=a[0],u=Math.abs(t.fromX-s)+1,m=Math.abs(t.fromY-l)+1;for(let c=1;cD(r));for(let r of n){let i=r.getStyles();i.delete("height"),i.delete("width"),r.setStyles(i),r.clearWidth()}}}function zm(o){o.setColWidths([]),o.setStyles(new Map);for(let t of o.getChildren()){if(!te(t))continue;t.setStyles(new Map);let e=t.getChildren().filter(n=>D(n));for(let n of e)n.setStyles(new Map),n.setBackgroundColor(null),n.clearWidth()}}function ld(o,t){e:for(let e of o.getChildren()){if(!te(e))continue;let n=e.getChildren();for(let r of n){if(!D(r))return;if(t(r)===!1)break e}}}function Wm(o){let t=null;return ld(o,e=>{let n=e.getStyles().get("padding")||"";if(t===null&&(t=n),n!==t)return t=null,!1}),t||""}var Mt=class o extends Ht{constructor(e){super(e);p(this,"__colWidths",[]);p(this,"__styles",new Map)}static getType(){return"table"}static clone(e){let n=new o(e.__key);return Ao(e,n),n.__colWidths=[...e.__colWidths],n.__styles=new Map(e.__styles),n}static importDOM(){return{table:e=>({conversion:SE,priority:1})}}static importJSON(e){let n=ai();return ct(e,n),n.setColWidths(e.colWidths),n.setStyles(new Map(Object.entries(e.styles))),n}exportJSON(){return{...super.exportJSON(),type:"table",version:1,colWidths:this.__colWidths,styles:Object.fromEntries(this.__styles)}}createDOM(e,n){let r=document.createElement("table");ye(r,e.theme.table),dt(r,this);let i=this.getColWidths(),s=sd(i);s&&r.append(s);for(let[l,a]of this.__styles.entries())r.style.setProperty(l,a);return r}updateDOM(e,n){if(Kf(e,this,n),this.__colWidths.join(":")!==e.__colWidths.join(":")){let r=Array.from(n.children).find(s=>s.nodeName==="COLGROUP"),i=sd(this.__colWidths);r&&r.remove(),i&&n.prepend(i)}if(Array.from(this.__styles.values()).join(":")!==Array.from(e.__styles.values()).join(":")){n.style.cssText="";for(let[r,i]of this.__styles.entries())n.style.setProperty(r,i)}return!1}exportDOM(e){return{...super.exportDOM(e),after:n=>{if(!n)return;let r=n.cloneNode(),i=document.createElement("tbody");if(he(n))for(let s of Array.from(n.children))s.nodeName==="TR"?i.append(s):s.nodeName==="CAPTION"?r.insertBefore(s,r.firstChild):r.append(s);return r.append(i),r}}}canBeEmpty(){return!1}isShadowRoot(){return!0}setColWidths(e){let n=this.getWritable();n.__colWidths=e}getColWidths(){return[...this.getLatest().__colWidths]}getStyles(){let e=this.getLatest();return new Map(e.__styles)}setStyles(e){let n=this.getWritable();n.__styles=new Map(e)}getCordsFromCellNode(e,n){let{rows:r,domRows:i}=n;for(let s=0;s{if(!d)return;let{elem:u}=d;return G(u)===e});if(a!==-1)return{x:a,y:s}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,n,r){let{domRows:i}=r,s=i[n];if(s==null)return null;let l=e{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(e){let n=ad();return n.setId(e.id),n}};function ad(){return new lr}function qm(o){return o instanceof lr}var $o=class o extends lt{constructor(e,n,r){super(r);p(this,"__id","");p(this,"__drawingId","");p(this,"__drawingUrl","");this.__drawingId=e,this.__drawingUrl=n}static getType(){return"diagram"}static clone(e){let n=new o(e.__drawingId,e.__drawingUrl);return n.__id=e.__id,n}setDrawingIdAndUrl(e,n){let r=this.getWritable();r.__drawingUrl=n,r.__drawingId=e}getDrawingIdAndUrl(){let e=this.getLatest();return{id:e.__drawingId,url:e.__drawingUrl}}setId(e){let n=this.getWritable();n.__id=e}getId(){return this.getLatest().__id}decorate(e,n){return{type:"diagram",getNode:()=>this}}isInline(){return!1}isIsolated(){return!0}createDOM(e,n){return y("div",{id:this.__id||null,"drawio-diagram":this.__drawingId},[y("img",{src:this.__drawingUrl})])}updateDOM(e,n){let r=n.querySelector("img");return r&&(e.__id!==this.__id&&n.setAttribute("id",this.__id),e.__drawingUrl!==this.__drawingUrl&&r.setAttribute("src",this.__drawingUrl),e.__drawingId!==this.__drawingId&&n.setAttribute("drawio-diagram",this.__drawingId)),!1}static importDOM(){return{div(e){return e.hasAttribute("drawio-diagram")?{conversion:n=>{let i=n.querySelector("img")?.getAttribute("src")||"",s=n.getAttribute("drawio-diagram")||"",l=ar(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(e){let n=ar(e.drawingId,e.drawingUrl);return n.setId(e.id||""),n}};function ar(o="",t=""){return new $o(o,t)}var dr=class o extends lt{constructor(){super(...arguments);p(this,"__user_id",0);p(this,"__user_name","");p(this,"__user_slug","")}static getType(){return"mention"}static clone(e){let n=new o(e.__key);return n.__user_id=e.__user_id,n.__user_name=e.__user_name,n.__user_slug=e.__user_slug,n}setUserDetails(e,n,r){let i=this.getWritable();i.__user_id=e,i.__user_name=n,i.__user_slug=r}hasUserSet(){return this.__user_id>0}isInline(){return!0}isParentRequired(){return!0}decorate(e,n){return{type:"mention",getNode:()=>this}}createDOM(e,n){let r=document.createElement("a");return r.setAttribute("target","_blank"),r.setAttribute("href",window.baseUrl("/user/"+this.__user_slug)),r.setAttribute("data-mention-user-id",String(this.__user_id)),r.setAttribute("title","@"+this.__user_name),r.textContent="@"+this.__user_name,r}updateDOM(e){return e.__user_id!==this.__user_id}static importDOM(){return{a(e){return e.hasAttribute("data-mention-user-id")?{conversion:n=>{let r=new o;return r.setUserDetails(Number(n.getAttribute("data-mention-user-id")||"0"),n.innerText.replace(/^@/,""),n.getAttribute("href")?.split("/user/")[1]||""),{node:r,after(i){return[]}}},priority:4}:null}}}exportJSON(){return{type:"mention",version:1,user_id:this.__user_id,user_name:this.__user_name,user_slug:this.__user_slug}}static importJSON(e){return dd(e.user_id,e.user_name,e.user_slug)}};function dd(o,t,e){let n=new dr;return n.setUserDetails(o,t,e),n}function Ym(o){return o instanceof dr}function Zm(){return[sn,tr,rr,ko,Ut,Mt,co,ao,sr,an,lr,ir,un,$o,Ro,it,ln]}function cd(){return[ko,Ut,it,ln]}function Vm(){return[...cd(),dr]}function Xm(o){let t=[an,un,$o],e=n=>{for(let[r,i]of n)if(i==="destroyed"){let s=o.manager.getDecoratorByNodeKey(r);s&&s.teardown()}};for(let n of t)o.editor.registerMutationListener(n,r=>e(r))}var jm='';var Ps=class extends oe{constructor(e,n){super([new gs(e.form)]);p(this,"definition");p(this,"key");p(this,"originalFocus",null);this.definition=e,this.key=n}show(e){this.originalFocus=document.activeElement;let n=this.getDOMElement();document.body.append(n);let r=this.getForm();r.setValues(e),r.setOnCancel(this.hide.bind(this)),r.setOnSuccessfulSubmit(this.hide.bind(this)),this.getContext().manager.setModalActive(this.key,this),r.focusOnFirst()}hide(){this.getContext().manager.setModalInactive(this.key),this.teardown(),this.originalFocus instanceof HTMLElement&&this.originalFocus.isConnected&&this.originalFocus.focus()}getForm(){return this.children[0]}buildDOM(){let e=y("button",{class:"editor-modal-close",type:"button",title:this.trans("Close")});e.innerHTML=jm,e.addEventListener("click",this.hide.bind(this));let n=y("div",{class:"editor-modal editor-form-modal"},[y("div",{class:"editor-modal-header"},[y("div",{class:"editor-modal-title"},[this.trans(this.definition.title)]),e]),y("div",{class:"editor-modal-body"},[this.getForm().getDOMElement()])]),r=y("div",{class:"editor-modal-wrapper"},[n]);return r.addEventListener("click",i=>{i.target&&!n.contains(i.target)&&this.hide()}),r.addEventListener("keydown",i=>{i.key==="Escape"&&this.hide()}),r}};var Bs=class extends oe{constructor(e,n){super(n);p(this,"target");this.target=e}buildDOM(){return y("div",{class:"editor-context-toolbar"},this.getChildren().map(e=>e.getDOMElement()))}updatePosition(){let e=this.getContext().scrollDOM.getBoundingClientRect(),n=this.target.getBoundingClientRect(),r=this.getDOMElement(),i=r.getBoundingClientRect(),s=n.bottom>e.top&&n.tope.bottom;r.classList.toggle("is-above",l);let d=n.left+n.width/2-i.width/2;l?r.style.top=n.top-6-i.height+"px":r.style.top=n.bottom+6+"px",r.style.left=d+"px"}insert(e){this.addChildren(...e),this.getDOMElement().append(...e.map(r=>r.getDOMElement()))}};function ME(o,t,e){let n=t.getBoundingClientRect(),r=o.getBoundingClientRect();if(o.style.position="fixed",e){let i=n.right;n.right+r.width>window.innerWidth&&(i=Math.max(n.left-r.width,0)),o.style.top=n.top+"px",o.style.left=i+"px"}else{let i=n.left+r.width>window.innerWidth,s=n.left;i&&(s=Math.max(n.right-r.width,0)),o.style.top=n.bottom+"px",o.style.left=s+"px"}}var Hs=class{constructor(){p(this,"dropdownOptions",new WeakMap);p(this,"openDropdowns",new Set);this.onMenuMouseOver=this.onMenuMouseOver.bind(this),this.onWindowClick=this.onWindowClick.bind(this),window.addEventListener("click",this.onWindowClick)}teardown(){window.removeEventListener("click",this.onWindowClick)}onWindowClick(t){let e=t.target;this.closeAllNotContainingElement(e)}closeAllNotContainingElement(t){for(let e of this.openDropdowns)e.parentElement?.contains(t)||this.closeDropdown(e)}onMenuMouseOver(t){let e=t.target;this.closeAllNotContainingElement(e)}closeAll(){for(let t of this.openDropdowns)this.closeDropdown(t)}closeDropdown(t){t.hidden=!0,t.style.removeProperty("position"),t.style.removeProperty("left"),t.style.removeProperty("top"),this.openDropdowns.delete(t),t.removeEventListener("mouseover",this.onMenuMouseOver);let e=this.getOptions(t).onClose;e&&e()}openDropdown(t){let{toggle:e,showAside:n,onOpen:r}=this.getOptions(t);t.hidden=!1,ME(t,e,!!n),this.openDropdowns.add(t),t.addEventListener("mouseover",this.onMenuMouseOver),r&&r()}getOptions(t){let e=this.dropdownOptions.get(t);if(!e)throw new Error("Can't find options for dropdown menu");return e}handle(t){let{menu:e,toggle:n,showOnHover:r}=t;this.dropdownOptions.set(e,t);let i=s=>{e.hasAttribute("hidden")?this.openDropdown(e):this.closeDropdown(e)};n.addEventListener("click",i),r&&n.addEventListener("mouseenter",()=>{this.openDropdown(e)})}};var Fs=class{constructor(){p(this,"dropdowns",new Hs);p(this,"modalDefinitionsByKey",{});p(this,"activeModalsByKey",{});p(this,"decoratorConstructorsByType",{});p(this,"decoratorInstancesByNodeKey",{});p(this,"context",null);p(this,"toolbar",null);p(this,"contextToolbarDefinitionsByKey",{});p(this,"activeContextToolbars",[]);p(this,"selectionChangeHandlers",new Set);p(this,"domEventAbortController",new AbortController);p(this,"teardownCallbacks",[])}setContext(t){this.context=t,this.setupEventListeners(),this.setupEditor(t.editor,t)}getContext(){if(this.context===null)throw new Error("Context attempted to be used without being set");return this.context}triggerStateUpdateForElement(t){t.updateState({selection:null,editor:this.getContext().editor})}registerModal(t,e){this.modalDefinitionsByKey[t]=e}createModal(t){let e=this.modalDefinitionsByKey[t];if(!e)throw new Error(`Attempted to show modal of key [${t}] but no modal registered for that key`);let n=new Ps(e,t);return n.setContext(this.getContext()),n}setModalActive(t,e){this.activeModalsByKey[t]=e}setModalInactive(t){delete this.activeModalsByKey[t]}getActiveModal(t){return this.activeModalsByKey[t]}registerDecoratorType(t,e){this.decoratorConstructorsByType[t]=e}getDecorator(t,e){if(this.decoratorInstancesByNodeKey[e])return this.decoratorInstancesByNodeKey[e];let n=this.decoratorConstructorsByType[t];if(!n)throw new Error(`Attempted to use decorator of type [${t}] but not decorator registered for that type`);let r=new n(this.getContext());return this.decoratorInstancesByNodeKey[e]=r,r}getDecoratorByNodeKey(t){return this.decoratorInstancesByNodeKey[t]||null}setToolbar(t){this.toolbar&&this.toolbar.teardown(),this.toolbar=t,t.setContext(this.getContext()),this.getContext().containerDOM.prepend(t.getDOMElement())}getToolbar(){return this.toolbar}registerContextToolbar(t,e){this.contextToolbarDefinitionsByKey[t]=e}triggerStateUpdate(t){df(t.editor,t.selection),this.toolbar?.updateState(t),this.updateContextToolbars(t);for(let e of this.activeContextToolbars)e.updateState(t);this.triggerSelectionChange(t.selection)}triggerStateRefresh(){let t=this.getContext().editor,e={editor:t,selection:ae(t)};this.triggerStateUpdate(e),this.updateContextToolbars(e)}triggerFutureStateRefresh(){requestAnimationFrame(()=>{this.getContext().editor.getEditorState().read(()=>{this.triggerStateRefresh()})})}triggerSelectionChange(t){if(t)for(let e of this.selectionChangeHandlers)e(t)}onSelectionChange(t){this.selectionChangeHandlers.add(t)}offSelectionChange(t){this.selectionChangeHandlers.delete(t)}triggerLayoutUpdate(){window.requestAnimationFrame(()=>{for(let t of this.activeContextToolbars)t.updatePosition()})}getDefaultDirection(){return this.getContext().options.textDirection==="rtl"?"rtl":"ltr"}onTeardown(t){this.teardownCallbacks.push(t)}teardown(){this.domEventAbortController.abort("teardown");for(let[t,e]of Object.entries(this.activeModalsByKey))e.teardown();for(let[t,e]of Object.entries(this.decoratorInstancesByNodeKey))e.teardown();this.toolbar&&this.toolbar.teardown();for(let t of this.activeContextToolbars)t.teardown();this.dropdowns.teardown();for(let t of this.teardownCallbacks)t()}focus(){this.getContext().editorDOM.focus(),this.getContext().editor.focus()}updateContextToolbars(t){for(let s=this.activeContextToolbars.length-1;s>=0;s--)this.activeContextToolbars[s].teardown(),this.activeContextToolbars.splice(s,1);let e=(t.selection?.getNodes()||[])[0]||null;if(!e)return;let n=t.editor.getElementByKey(e.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 Bs(s,l);a.setContext(this.getContext()),this.activeContextToolbars.push(a),this.getContext().containerDOM.append(a.getDOMElement()),a.updatePosition()}}setupEditor(t,e){t.setUiContext(e);let n=r=>{t.getEditorState().read(()=>{let i=Object.keys(r);for(let s of i){let l=t.getElementByKey(s);if(!l)continue;let a=r[s],d=this.getDecorator(a.type,s);d.setNode(a.getNode());let u=d.render(l);u&&l.append(u)}})};t.registerDecoratorListener(n),t.registerUpdateListener(({editorState:r,prevEditorState:i})=>{!i._selection?.is(r._selection)&&t.update(()=>{let l=C();this.triggerStateUpdate({editor:t,selection:l})})})}setupEventListeners(){let t=this.triggerLayoutUpdate.bind(this);window.addEventListener("scroll",t,{capture:!0,passive:!0,signal:this.domEventAbortController.signal}),window.addEventListener("resize",t,{passive:!0,signal:this.domEventAbortController.signal})}};function Ks(o,t,e){let n=y("div",{contenteditable:"true",class:`editor-content-area ${e.editorClass||""}`}),r=y("div",{class:"editor-content-wrap"},[n]);o.append(r),o.classList.add("editor-container"),o.setAttribute("dir",e.textDirection),e.darkMode&&o.classList.add("editor-dark");let i=new Fs,s={editor:t,containerDOM:o,editorDOM:n,scrollDOM:r,manager:i,translate(l){return e.translations[l]||l},error(l){let a=l instanceof Error?l.message:l;window.$events.error(a)},options:e};return i.setContext(s),s}function Po(o,t){o.update(()=>{let e=F();for(let r of e.getChildren())r.remove(!0);let n=en(o,t);e.append(...n)})}function Us(o,t){o.update(()=>{let e=F(),n=en(o,t);e.append(...n)})}function zs(o,t){o.update(()=>{let e=F(),n=en(o,t),r=e.getChildren()[0];for(let i=n.length-1;i>=0;i--)r?r.insertBefore(n[i]):e.append(n[i]),r=n[i]})}function Ws(o,t){o.update(()=>{let e=C(),n=Ea(o,t),r=e?.getNodes()[0],i=!1,s=r?bt(r):null;for(let l=n.length-1;l>=0;l--){let a=n[l];It(a)&&s?i?s.insertBefore(a):s.insertAfter(a):It(a)?F().append(a):i?r?.insertBefore(a):(Ce([a]),r=a,s=bt(r),i=!0)}})}function qs(o){return new Promise((t,e)=>{o.getEditorState().read(()=>{let n=Qi(o);t(n)})})}function Ys(o){o.focus(()=>{},{defaultSelection:"rootStart"})}var cr=class{constructor(t,e,n){p(this,"container");p(this,"dragTargetSelector");p(this,"options");p(this,"startX",0);p(this,"startY",0);p(this,"target",null);this.container=t,this.dragTargetSelector=e,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(t){this.target=t.target.closest(this.dragTargetSelector),this.target&&(this.startX=t.screenX,this.startY=t.screenY,window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("mouseup",this.onMouseUp),this.options.down&&this.options.down(t,this.target))}onMouseMove(t){this.options.move&&this.target&&this.options.move(t,this.target,{x:t.screenX-this.startX,y:t.screenY-this.startY})}onMouseUp(t){window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp),this.options.up&&this.target&&this.options.up(t,this.target,{x:t.screenX-this.startX,y:t.screenY-this.startY})}};var ud=class{constructor(t,e){p(this,"editor");p(this,"editScrollContainer");p(this,"markerDom",null);p(this,"mouseTracker",null);p(this,"dragging",!1);p(this,"targetCell",null);p(this,"xMarkerAtStart",!1);p(this,"yMarkerAtStart",!1);p(this,"activeInTable",!1);this.editor=t,this.editScrollContainer=e,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.onTableMouseOver=this.onTableMouseOver.bind(this),this.onCellMouseMove=this.onCellMouseMove.bind(this),this.onScrollOrResize=this.onScrollOrResize.bind(this),this.editScrollContainer.addEventListener("mouseover",this.onTableMouseOver,{passive:!0}),window.addEventListener("scroll",this.onScrollOrResize,{capture:!0,passive:!0}),window.addEventListener("resize",this.onScrollOrResize,{passive:!0})}onScrollOrResize(){this.updateCurrentMarkerTargetPosition()}onTableMouseOver(t){if(this.dragging)return;let e=t.target.closest("table");e&&!this.activeInTable?(this.editScrollContainer.addEventListener("mousemove",this.onCellMouseMove,{passive:!0}),this.onCellMouseMove(t),this.activeInTable=!0):!e&&this.activeInTable&&(this.editScrollContainer.removeEventListener("mousemove",this.onCellMouseMove),this.hideMarkers(),this.activeInTable=!1)}onCellMouseMove(t){let e=t.target.closest("td,th");if(!e||this.dragging)return;let n=e.getBoundingClientRect(),r=n.left+n.width/2,i=n.top+n.height/2;this.targetCell=e,this.xMarkerAtStart=t.clientX<=r,this.yMarkerAtStart=t.clientY<=i;let s=this.xMarkerAtStart?n.left:n.right,l=this.yMarkerAtStart?n.top:n.bottom;this.updateMarkersTo(e,s,l)}updateMarkersTo(t,e,n){let r=this.getMarkers(),i=t.closest("table"),s=i.querySelector("caption"),l=i.getBoundingClientRect(),a=this.editScrollContainer.getBoundingClientRect(),d=l.top;s&&(d=s.getBoundingClientRect().bottom);let u=Math.max(d,a.top),c=Math.min(l.bottom,a.bottom)-u;r.x.style.left=e+"px",r.x.style.top=u+"px",r.x.style.height=c+"px",r.y.style.top=n+"px",r.y.style.left=l.left+"px",r.y.style.width=l.width+"px",r.y.hidden=na.bottom,r.x.hidden=l.top>a.bottom||l.bottom0?d-=1:e.xMarkerAtStart&&d===0&&(u=-u),e.editor.update(()=>{let m=G(a);if(m instanceof Mt){let c=Pm(e.editor,m,d),f=Math.max(c+u,10);id(m,d,f)}})}if(r==="top"&&e.targetCell){let d=e.targetCell;e.editor.update(()=>{let m=G(d)?.getParent(),c=m?.getIndexWithinParent()||0,f=l.y;e.yMarkerAtStart&&c>0?c-=1:e.yMarkerAtStart&&c===0&&(f=-f);let g=m?.getParent()?.getChildren()[c];if(g instanceof co){let h=g.getHeight()||0,N=Math.max(h+f,10);g.setHeight(N)}})}}})}getTargetCellColumnIndex(){let t=this.targetCell;if(t===null)return-1;let e=0,n=t.parentElement;for(let r of n?.children||[]){let i=Number(r.getAttribute("colspan"));if((Number.isNaN(i)||i<1)&&(i=1),e+=i,r===t)return e-1}return-1}};function Gm(o,t){let e=new ud(o,t);return()=>{e.teardown()}}function Zs(o){return o.html||""}function Jm(o){window.$events.listen("editor::replace",e=>{let n=Zs(e);Po(o,n)}),window.$events.listen("editor::append",e=>{let n=Zs(e);Us(o,n)}),window.$events.listen("editor::prepend",e=>{let n=Zs(e);zs(o,n)}),window.$events.listen("editor::insert",e=>{let n=Zs(e);Ws(o,n)}),window.$events.listen("editor::focus",()=>{Ys(o)});let t=!0;o.registerUpdateListener(({dirtyElements:e,dirtyLeaves:n,editorState:r,prevEditorState:i})=>{(e.size>0||n.size>0)&&(t?t=!1:window.$events.emit("editor-html-change",""))})}var Vs=class{constructor(t){p(this,"data");this.data=t}hasItems(){return!!this.data&&!!this.data.types&&this.data.types.length>0}containsTabularData(){let t=this.data.getData("text/rtf");return!!t&&t.includes("\\trowd")}getImages(){return this.getFiles().filter(t=>t.type.includes("image"))}getFiles(){let{files:t}=this.data;return[...t]}};function wE(o,t){let e=o.clientX,n=o.clientY;return document.elementFromPoint(e,n)?rf(t,o.clientX,o.clientY):null}function Qm(o,t,e){let n=wE(t,e);n&&Be(n),Ca(o,!0),(!H(n)||!n?.getTextContent())&&n?.remove()}async function vE(o,t,e){let i=((await window.$http.get(`/templates/${t}`)).data||{html:""}).html||"";o.update(()=>{let s=en(o,i);Qm(s,e,o)})}function ep(o,t){let e=new Vs(o),n=!1;if(!e.hasItems()||e.containsTabularData())return n;let r=e.getImages();return r.length>0&&(n=!0),t.editor.update(async()=>{for(let i of r){let s=window.baseUrl("/loading.gif"),l=dn(s),a=I();a.append(l),Ce([a]);try{let d=await sm(i,t.options.pageId),u=d.name.replace(/"/g,"");t.editor.update(()=>{let m=dn(d.thumbs?.display||"",{alt:u}),c=yt(d.url,{target:"_blank"});c.append(m),l.replace(c)})}catch(d){t.editor.update(()=>{l.remove(!1)}),window.$events.error(d?.data?.message||t.options.translations.imageUploadErrorText),console.error(d)}}}),n}function DE(o,t){let e=/https?:\/\/([^?#]*?)\.(png|jpeg|jpg|gif|webp|bmp|avif)/i,n=o.getData("text/plain");return n&&e.test(n)?(t.editor.update(()=>{let r=dn(n);Ce([r]),r.select()}),!0):!1}function OE(o){let t=o.editor;return e=>{let n=e.dataTransfer?.getData("bookstack/template")||"";if(n)return vE(t,n,e),e.preventDefault(),e.stopPropagation(),!0;let r=e.dataTransfer?.getData("text/html")||"";return r?(t.update(()=>{let i=en(t,r);Qm(i,e,t)}),e.preventDefault(),e.stopPropagation(),!0):e.dataTransfer&&ep(e.dataTransfer,o)?(e.preventDefault(),e.stopPropagation(),!0):!1}}function AE(o){return t=>{if(!t.clipboardData)return!1;let e=DE(t.clipboardData,o)||ep(t.clipboardData,o);return e&&t.preventDefault(),e}}function tp(o){let t=OE(o),e=AE(o),n=o.editor.registerCommand(Wo,t,Je),r=o.editor.registerCommand(go,e,Je);return o.scrollDOM.addEventListener("drop",t),()=>{n(),r(),o.scrollDOM.removeEventListener("drop",t)}}var fd=class{constructor(t,e){p(this,"editorContainer");p(this,"editor");this.editor=t,this.editorContainer=e,this.setupListeners()}setupListeners(){this.handleClick=this.handleClick.bind(this),this.editorContainer.addEventListener("click",this.handleClick)}handleClick(t){let e=t.target;e instanceof HTMLElement&&e.nodeName==="LI"&&e.classList.contains("task-list-item")&&(this.handleTaskListItemClick(e,t),t.preventDefault())}handleTaskListItemClick(t,e){let n=t.getBoundingClientRect();e.clientX<=n.right&&e.clientX>=n.left&&e.clientY>=n.top&&e.clientY<=n.bottom||this.editor.update(()=>{let i=G(t);j(i)&&i.setChecked(!i.getChecked())})}teardown(){this.editorContainer.removeEventListener("click",this.handleClick)}};function op(o,t){let e=new fd(o,t);return()=>{e.teardown()}}var md=class{constructor(t){p(this,"editor");p(this,"tableSelections",new Map);p(this,"unregisterMutationListener",()=>{});this.editor=t,this.init()}init(){this.unregisterMutationListener=this.editor.registerMutationListener(Mt,t=>{for(let[e,n]of t)if(n==="created")this.editor.getEditorState().read(()=>{let r=ee(e);K(r)&&this.initializeTableNode(r)});else if(n==="destroyed"){let r=this.tableSelections.get(e);r!==void 0&&(r.removeListeners(),this.tableSelections.delete(e))}})}initializeTableNode(t){let e=t.getKey(),n=this.editor.getElementByKey(e);if(n&&!this.tableSelections.has(e)){let r=od(t,n,this.editor,!0);this.tableSelections.set(e,r)}}teardown(){this.unregisterMutationListener();for(let[,t]of this.tableSelections)t.removeListeners()}};function np(o){let t=new md(o);return()=>{t.teardown()}}function Xs(o,t){return Ls(o.editor,t),o.manager.triggerFutureStateRefresh(),!0}function fo(o){return(t,e)=>(o(t),e.manager.triggerFutureStateRefresh(),!0)}function rp(o){return o.dispatchCommand(Ee,"code"),!0}var ip={"meta+s":()=>(window.$events.emit("editor-save-draft"),!0),"meta+enter":()=>(window.$events.emit("editor-save-page"),!0),"meta+1":(o,t)=>Xs(t,"h2"),"meta+2":(o,t)=>Xs(t,"h3"),"meta+3":(o,t)=>Xs(t,"h4"),"meta+4":(o,t)=>Xs(t,"h5"),"meta+5":fo(oi),"meta+d":fo(oi),"meta+6":fo(ni),"meta+q":fo(ni),"meta+7":fo(ii),"meta+e":fo(ii),"meta+8":rp,"meta+shift+e":rp,"meta+9":fo(xm),"meta+o":fo(o=>ri(o,"number")),"meta+p":fo(o=>ri(o,"bullet")),"meta+k":(o,t)=>(o.getEditorState().read(()=>{let e=V(C(),Ft);ws(e,t)}),!0),"meta+shift+k":(o,t)=>(o.getEditorState().read(()=>{let n=C()?.getTextContent()||"";Es(r=>{Ms(o,{text:r.name,title:r.link,target:"",url:r.link})},n)}),!0)};function RE(o){return t=>{let e=kE(t);ip[e]&&ip[e](o.editor,o)&&(t.stopPropagation(),t.preventDefault())}}function kE(o){return[(sp()?o.metaKey:o.ctrlKey)?"meta":"",o.shiftKey?"shift":"",o.key].filter(Boolean).join("+").toLowerCase()}function sp(){return window.navigator.userAgent.includes("Mac OS X")}function IE(o){o.registerCommand(we,t=>sp()?t?.metaKey||!1:t?.ctrlKey||!1,Je)}function js(o){let t=RE(o);return IE(o.editor),o.editor.registerRootListener((e,n)=>{e?.addEventListener("keydown",t),n?.removeEventListener("keydown",t)})}function $E(o){return Qe(o)||St(o)}var pd=class{constructor(t){p(this,"context");p(this,"resizerDOM",null);p(this,"targetNode",null);p(this,"scrollContainer");p(this,"mouseTracker",null);p(this,"activeSelection","");p(this,"loadAbortController",new AbortController);this.context=t,this.scrollContainer=t.scrollDOM,this.onSelectionChange=this.onSelectionChange.bind(this),this.onTargetDOMLoad=this.onTargetDOMLoad.bind(this),t.manager.onSelectionChange(this.onSelectionChange)}onSelectionChange(t){let e=t?.getNodes()||[];if(this.activeSelection&&this.hide(),e.length===1&&$E(e[0])){let n=e[0],r=this.getTargetDOM(n);r&&this.showForNode(n,r)}}getTargetDOM(t){if(t==null)return null;let e=this.context.editor.getElementByKey(t.__key);return e&&e.nodeName==="SPAN"&&(e=e.firstElementChild),e}onTargetDOMLoad(){this.updateResizerPosition()}teardown(){this.context.manager.offSelectionChange(this.onSelectionChange),this.hide()}showForNode(t,e){this.resizerDOM=this.buildDOM(),this.targetNode=t;let n=y("span",{class:"editor-node-resizer-ghost"});Qe(t)&&(n=y("img",{src:e.getAttribute("src"),class:"editor-node-resizer-ghost"})),this.resizerDOM.append(n),this.context.scrollDOM.append(this.resizerDOM),this.updateResizerPosition(),this.mouseTracker=this.setupTracker(this.resizerDOM,t,e),this.activeSelection=t.getKey(),e.matches("img, embed, iframe, object")&&(this.loadAbortController=new AbortController,e.addEventListener("load",this.onTargetDOMLoad,{signal:this.loadAbortController.signal}))}updateResizerPosition(){let t=this.getTargetDOM(this.targetNode);if(!this.resizerDOM||!t)return;let e=this.scrollContainer.getBoundingClientRect(),n=t.getBoundingClientRect(),r=n.top-(e.top-this.scrollContainer.scrollTop),i=n.left-e.left;this.resizerDOM.style.top=`${r}px`,this.resizerDOM.style.left=`${i}px`,this.resizerDOM.style.width=n.width+"px",this.resizerDOM.style.height=n.height+"px"}updateDOMSize(t,e){this.resizerDOM&&(this.resizerDOM.style.width=t+"px",this.resizerDOM.style.height=e+"px")}hide(){this.mouseTracker?.teardown(),this.resizerDOM?.remove(),this.targetNode=null,this.activeSelection="",this.loadAbortController.abort()}buildDOM(){let e=["nw","ne","se","sw"].map(n=>y("div",{class:`editor-node-resizer-handle ${n}`}));return y("div",{class:"editor-node-resizer"},e)}setupTracker(t,e,n){let r=0,i=0,s=0,l=!1,a=this,d=!1,u=!1,m=c=>{let f=c.x;d&&(f=0-f);let g=c.y;u&&(g=0-g);let h=Math.sqrt(Math.pow(Math.abs(f),2)+Math.pow(Math.abs(g),2)),b=f+g>0?h:0-h,x=Math.max(5,Math.round(r+b)),S=Math.round(x*s);return{width:x,height:S}};return new cr(t,".editor-node-resizer-handle",{down(c,f){a.resizerDOM?.classList.add("active"),a.context.editor.getEditorState().read(()=>{let g=n.getBoundingClientRect();r=e.getWidth()||g.width,i=e.getHeight()||g.height,e.getHeight()&&(l=!0),s=i/r}),d=f.classList.contains("nw")||f.classList.contains("sw"),u=f.classList.contains("nw")||f.classList.contains("ne")},move(c,f,g){let h=m(g);a.updateDOMSize(h.width,h.height)},up(c,f,g){let h=m(g);a.context.editor.update(()=>{e.setWidth(h.width),e.setHeight(l?h.height:0)},{onUpdate:()=>{requestAnimationFrame(()=>{a.context.manager.triggerLayoutUpdate(),a.updateResizerPosition()})}}),a.resizerDOM?.classList.remove("active")}})}};function lp(o){let t=new pd(o);return()=>{t.teardown()}}function PE(o){let t=o.getParent();if(!W(t))return o;let e=o.getChildren().filter(d=>W(d))[0]||null,n=e?.getChildren()||[],r=t.getChildren(),i=r.findIndex(d=>d.getKey()===o.getKey()),s=i===0,l=Ue(),a=Se(t.getListType());if(a.append(l),l.append(...o.getChildren()),s?o.append(a):(r[i-1].append(a),o.remove()),e){for(let d of n)l.insertAfter(d);e.remove()}return l}function BE(o){let t=o.getParent(),e=t?.getParent(),n=e?.getParent();if(!W(t)||!W(n)||!j(e))return o;let r=o.getNextSiblings();if(e.insertAfter(o),t.getChildren().length===0&&t.remove(),r.length>0){let i=Se(t.getListType());i.append(...r),o.append(i)}return t.getChildrenSize()===0&&t.remove(),e.getChildren().length===0&&e.remove(),o}function HE(o){let t=o?.getNodes()||[],[e,n]=o?.getStartEndPoints()||[null,null],r=new Set;if(o&&e){o.isBackward()&&n&&([n,e]=[e,n]);let s=e.getNode().getParents(),l=!1;for(let a of s)j(a)&&(l?r.add(a.getKey()):l=!0)}let i=[];e:for(let s of t){if(j(s)){r.has(s.getKey())||i.push(s);continue}let l=s.getParents();for(let a of l)if(j(a)){r.has(a.getKey())||i.push(a);continue e}i.push(null)}return i}function FE(o){let t={};for(let n of o){if(n===null)continue;let r=n.getKey();typeof t[r]>"u"&&(t[r]=n)}let e=Object.values(t);return sf(e)}function fi(o,t){let e=C(),n=e?.getStartEndPoints(),r=HE(e);if(r.length>0&&!r.includes(null)){let l=[],a=FE(r);if(t>0)for(let d of a)l.push(PE(d));else if(t<0){for(let d of[...a].reverse())l.push(BE(d));l.reverse()}if(l.length===1&&n){let d=l[0],u=d.getChildren()[0];u||(u=z(""),d.append(u)),u.select(n[0].offset,n[1].offset)}else pf(l);return}let s=Pt(e);for(let l of s)if(lf(l)){let a=l.getInset(),d=Math.min(Math.max(a+t,0),500);l.setInset(d)}gf(o)}var ur=class extends Error{constructor(e,n){super(e.statusText);p(this,"data");p(this,"headers");p(this,"original");p(this,"redirected");p(this,"status");p(this,"statusText");p(this,"url");this.data=n,this.headers=e.headers,this.redirected=e.redirected,this.status=e.status,this.statusText=e.statusText,this.url=e.url,this.original=e}};function Gs(o){return new Promise((t,e)=>{o.oncomplete=o.onsuccess=()=>t(o.result),o.onabort=o.onerror=()=>e(o.error)})}function KE(o,t){let e,n=()=>{if(e)return e;let r=indexedDB.open(o);return r.onupgradeneeded=()=>r.result.createObjectStore(t),e=Gs(r),e.then(i=>{i.onclose=()=>e=void 0},()=>{}),e};return(r,i)=>n().then(s=>i(s.transaction(t,r).objectStore(t)))}var gd;function hd(){return gd||(gd=KE("keyval-store","keyval")),gd}function Nd(o,t=hd()){return t("readonly",e=>Gs(e.get(o)))}function xd(o,t,e=hd()){return e("readwrite",n=>(n.put(t,o),Gs(n.transaction)))}function Ed(o,t=hd()){return t("readwrite",e=>(e.delete(o),Gs(e.transaction)))}var wt=null,bd,Js,Td,Cd="last-drawing-save";function _d(o){wt?.contentWindow?.postMessage(JSON.stringify(o),bd)}function zE(o){xd(Cd,o.data),Td&&Td(o.data).then(()=>{Ed(Cd)})}function WE(o){_d({action:"export",format:"xmlpng",xml:o.xml,spin:"Updating drawing"})}function qE(){Js&&Js().then(o=>{_d({action:"load",autosave:1,xml:o})})}function YE(){let o={};wt&&(window.$events.emitPublic(wt,"editor-drawio::configure",{config:o}),_d({action:"configure",config:o}))}function ap(){window.removeEventListener("message",dp),wt&&document.body.removeChild(wt)}function dp(o){if(!o.data||o.data.length<1||o.origin!==bd)return;let t=JSON.parse(o.data);t.event==="init"?qE():t.event==="exit"?ap():t.event==="save"?WE(t):t.event==="export"?zE(t):t.event==="configure"&&YE()}async function ZE(){let o=await Nd(Cd),t=document.getElementById("unsaved-drawing-dialog");t||console.error("Missing expected unsaved-drawing dialog"),o&&t&&await window.$components.firstOnElement(t,"confirm-dialog").show()&&(Js=async()=>o)}async function cp(o,t,e){Js=t,Td=e,await ZE(),wt=document.createElement("iframe"),wt.setAttribute("frameborder","0"),window.addEventListener("message",dp),wt.setAttribute("src",o),wt.setAttribute("class","fullscreen"),wt.style.backgroundColor="#FFFFFF",document.body.appendChild(wt),bd=new URL(o).origin}async function up(o,t){let e={image:o,uploaded_to:t};return(await window.$http.post(window.baseUrl("/images/drawio"),e)).data}function yd(){ap()}async function fp(o){try{return`data:image/png;base64,${(await window.$http.get(window.baseUrl(`/images/drawio/base64/${o}`))).data.content}`}catch(t){throw t instanceof ur&&window.$events.showResponseError(t),yd(),t}}function mo(o){return o instanceof $o}function XE(o,t){o.status===413?window.$events.emit("error",t.options.translations.serverUploadLimitText||""):window.$events.emit("error",t.options.translations.imageUploadErrorText||""),console.error(o)}async function jE(o,t){return await new Promise((n,r)=>{o.getEditorState().read(()=>{let{id:i}=t.getDrawingIdAndUrl();n(i)})})||""}async function GE(o,t,e,n){if(yd(),n){let r=window.baseUrl("/loading.gif");o.editor.update(()=>{t.setDrawingIdAndUrl("",r)})}try{let r=await up(e,o.options.pageId);o.editor.update(()=>{t.setDrawingIdAndUrl(String(r.id),r.url)})}catch(r){throw r instanceof ur&&XE(r,o),n&&o.editor.update(()=>{t.remove()}),new Error(`Failed to save image with error: ${r}`)}}function mi(o,t){let e=!1;cp(o.options.drawioUrl,async()=>{let n=await jE(o.editor,t);return e=!n,e?"":fp(n)},async n=>GE(o,t,n,e))}function JE(o){window.$components.first("image-manager").show(e=>{o(e)},"drawio")}function mp(o){let t=ae(o.editor);JE(e=>{o.editor.update(()=>{let n=ar(e.id,e.url),r=V(t,mo);mo(r)?r.replace(n):Ce([n])})})}function Qs(o){let t=o.getChildren();for(let e of t)o.insertBefore(e);o.remove()}function Sd(o){if(o.length===1){let t=o[0];if(H(t)||Qe(t)||St(t)||mo(t))return!0}return!1}function pp(o){let t=ae(o)?.getNodes()||[];Sd(t)&&o.update(()=>{t[0].remove()})}function QE(o,t){let e=ae(o)?.getNodes()||[];if(Sd(e)){let n=e[0],r=bt(n)||n,i=t?.shiftKey===!0;if(r)return requestAnimationFrame(()=>{o.update(()=>{let s=I();i?r.insertBefore(s):r.insertAfter(s),s.select()})}),t?.preventDefault(),!0}return!1}function gp(o,t,e=!0){let n=ae(o)?.getNodes()||[];if(!Sd(n))return!1;t?.preventDefault();let r=n[0];return o.update(()=>{qr(r,e)}),!0}function eT(o,t){let e=hp(o);return e===null||e.detailsSibling?!1:(o.update(()=>{let n=I();e.parentDetails.insertAfter(n),n.select()}),t?.preventDefault(),!0)}function tT(o,t){let e=hp(o);if(e===null||e.parentBlock.getTextContent()!=="")return!1;t?.preventDefault();let n=e.parentDetails.getNextSibling();return o.update(()=>{if(n)n.selectStart();else{let r=I();e.parentDetails.insertAfter(r),r.select()}e.parentBlock.remove()}),!0}function hp(o){let e=ae(o)?.getNodes()[0];if(!e)return null;let n=bt(e),r=$t(e,ce);if(!ce(r)||n===null||n.getKey()!==r.getLastChild()?.getKey())return null;let i=r.getNextSibling();return{parentDetails:r,parentBlock:n,detailsSibling:i}}function oT(o,t){let e=C(),n=e?.getNodes()||[];if(n.length!==1)return!1;let r=bt(n[0]);if(!r)return!1;let i=r.getParent(),s=e?.getStartEndPoints();return s&&ce(i)&&s[0].offset===0&&r.getIndexWithinParent()===0?(t.preventDefault(),o.editor.update(()=>{Qs(i),r.selectStart(),o.manager.triggerLayoutUpdate()}),!0):!1}function nT(o){if(o.length!==1)return!1;let t=o[0];return j(t)||j(t.getParent())}function rT(o,t){let e=t?.shiftKey?-40:40,r=C()?.getNodes()||[];return r.length>1||nT(r)?(o.update(()=>{fi(o,e)}),t?.preventDefault(),!0):!1}function Np(o){let t=o.editor.registerCommand(Xt,l=>(pp(o.editor),oT(o,l)),Ae),e=o.editor.registerCommand(jt,()=>(pp(o.editor),!1),Ae),n=o.editor.registerCommand(we,l=>QE(o.editor,l)||tT(o.editor,l),Ae),r=o.editor.registerCommand(zo,l=>rT(o.editor,l),Ae),i=o.editor.registerCommand(Zt,l=>gp(o.editor,l,!1),Ae),s=o.editor.registerCommand(Vt,l=>eT(o.editor,l)||gp(o.editor,l,!0),Ae);return()=>{t(),e(),n(),r(),i(),s()}}function iT(o){return o.toLowerCase().startsWith("http")?/(http|https):\/\/(\S+)\.\S+$/.test(o):!1}function sT(o,t,e){let n=t.getStartEndPoints();if(!n)return;let r=n[0].offset,i=o.getTextContent(),a=i.slice(0,r).lastIndexOf(" ")+1,d=i.slice(a,r);iT(d)&&e.update(()=>{let u=yt(d);u.append(new st(d));let m=o.splitText(a,r),c=a>0?1:0,f=m[c];f&&f.replace(u)})}function el(o){let t=r=>{let i=C(),s=cf(i);return s&&i&&sT(s,i,o),!1},e=o.registerCommand(xr,t,lo),n=o.registerCommand(we,t,lo);return()=>{e(),n()}}var tl=class extends oe{buildDOM(){let t=this.getChildren().map(i=>i.getDOMElement()),e=y("div",{class:"editor-format-menu-dropdown editor-dropdown-menu editor-dropdown-menu-vertical",hidden:"true"},t),n=y("button",{class:"editor-format-menu-toggle editor-button",type:"button"},[this.trans("Formats")]),r=y("div",{class:"editor-format-menu editor-dropdown-menu-container"},[n,e]);return this.getContext().manager.dropdowns.handle({toggle:n,menu:e}),this.onEvent("button-action",()=>{this.getContext().manager.dropdowns.closeAll()},r),r}updateState(t){super.updateState(t);for(let e of this.children){if(e instanceof w&&e.isActive()){this.updateToggleLabel(e.getLabel());return}if(e instanceof oe){for(let n of e.getChildren())if(n instanceof w&&n.isActive()){this.updateToggleLabel(n.getLabel());return}}}this.updateToggleLabel(this.trans("Formats"))}updateToggleLabel(t){let e=this.getDOMElement().querySelector("button");e&&(e.innerText=t)}};var et=class extends w{constructor(e,n){super(n);p(this,"previewSampleElement");this.previewSampleElement=e}buildDOM(){let e=super.buildDOM();e.innerHTML="";let n=y("span",{class:"editor-button-format-preview"},[this.getLabel()]),r=this.getStylesFromPreview();for(let i of Object.keys(r))n.style.setProperty(i,r[i]);return e.append(n),e}getStylesFromPreview(){let e=y("div",{style:"display: none",hidden:"true",class:"page-content"}),n=this.previewSampleElement.cloneNode();n.textContent=this.getLabel(),e.append(n),document.body.append(e);let r=["color","font-size","background-color","border-inline-start"],i={},s=window.getComputedStyle(n);for(let l of r)i[l]=s.getPropertyValue(l);return e.remove(),i}};var xp='';var ol=class extends w{buildDOM(){let t=super.buildDOM(),e=y("div",{class:"editor-menu-button-icon"});return e.innerHTML=xp,t.append(e),t}};var aT={showOnHover:!1,direction:"horizontal",showAside:void 0,hideOnAction:!0,button:{label:"Menu"}},be=class extends oe{constructor(e,n){super(n);p(this,"button");p(this,"childItems");p(this,"open",!1);p(this,"options");if(this.childItems=n,this.options=Object.assign({},aT,e),e.button instanceof w)this.button=e.button;else{let r=e.button.format==="long"?ol:w;this.button=new r({...e.button,action(){return!1},isActive:()=>this.open})}this.addChildren(this.button)}insertItems(...e){this.addChildren(...e),this.childItems.push(...e)}buildDOM(){let e=this.button.getDOMElement(),n=this.childItems.map(s=>s.getDOMElement()),r=y("div",{class:`editor-dropdown-menu editor-dropdown-menu-${this.options.direction}`,hidden:"true"},n),i=y("div",{class:"editor-dropdown-menu-container"},[e,r]);return this.getContext().manager.dropdowns.handle({toggle:e,menu:r,showOnHover:this.options.showOnHover,showAside:typeof this.options.showAside=="boolean"?this.options.showAside:this.options.direction==="vertical",onOpen:()=>{this.open=!0,this.getContext().manager.triggerStateUpdateForElement(this.button)},onClose:()=>{this.open=!1,this.getContext().manager.triggerStateUpdateForElement(this.button)}}),this.options.hideOnAction&&this.onEvent("button-action",()=>{this.getContext().manager.dropdowns.closeAll()},i),i}};var Ep='';var Tp='';var Cp=["#000000","#ffffff","#BFEDD2","#FBEEB8","#F8CAC6","#ECCAFA","#C2E0F4","#2DC26B","#F1C40F","#E03E2D","#B96AD9","#3598DB","#169179","#E67E23","#BA372A","#843FA1","#236FA1","#ECF0F1","#CED4D9","#95A5A6","#7E8C8D","#34495E"],bp="bs-lexical-custom-colors",Nn=class extends Re{constructor(e){super();p(this,"callback");this.callback=e}buildDOM(){let e=ps(),r=[...Cp,...this.getCustomColorChoices()].map(u=>y("div",{class:"editor-color-select-option",style:`background-color: ${u}`,"data-color":u,"aria-label":u})),i=y("div",{class:"editor-color-select-option","data-color":"",title:this.getContext().translate("Remove color")},[]);i.innerHTML=Ep,r.push(i);let s=y("label",{class:"editor-color-select-option",for:`color-select-${e}`,"data-color":"",title:this.getContext().translate("Custom color")},[]);s.innerHTML=Tp,r.push(s);let l=y("input",{type:"color",hidden:"true",id:`color-select-${e}`});r.push(l),l.addEventListener("change",u=>{l.value&&(this.storeCustomColorChoice(l.value),this.setColor(l.value),this.rebuildDOM())});let a=[];for(let u=0;u{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)}),y("div",{class:"editor-table-creator"},[i,r])}updateGridSelection(t,e,n,r){for(let i of n){let s=Number(i.dataset.rows)<=t&&Number(i.dataset.columns)<=e;i.classList.toggle("active",s)}r.textContent=`${t} x ${e}`}onCellClick(t){let e=Number(t.dataset.rows||0),n=Number(t.dataset.columns||0);if(e<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=Va(e,n,!1);s.setColWidths(i),tn(s)})}};var pi=class extends w{constructor(e,n){super(e);p(this,"style");this.style=n}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 n=Na(e.selection,this.style);this.getColorBar().setAttribute("fill",n)}}};var _p='';var Ie=class extends oe{constructor(e,n,r){super(r);p(this,"size");p(this,"overflowButton");p(this,"content");p(this,"label");this.label=e,this.size=n,this.content=r,this.overflowButton=new be({button:{label:"More",icon:_p},hideOnAction:!1},[]),this.addChildren(this.overflowButton)}addChild(e,n=-1){this.content.splice(n,0,e),this.addChildren(e)}buildDOM(){let e=this.content.length>this.size?this.size-1:this.size,n=this.content.slice(0,e),r=this.content.slice(e),i=n.map(s=>s.getDOMElement());return r.length>0&&(this.removeChildren(...r),this.overflowButton.insertItems(...r),i.push(this.overflowButton.getDOMElement())),y("div",{class:"editor-overflow-container"},i)}getLabel(){return this.label}};var Ld='';var rl='';var yp='';var Sp='';var Lp='';var Mp='';var wp='';var vp='';var Dp=` @@ -24,9 +24,9 @@ var lN=Object.defineProperty;var ac=o=>{throw TypeError(o)};var aN=(o,t,e)=>t in -`;var Ld=class extends oe{constructor(e){super([]);p(this,"input");p(this,"pickerButton");this.input=e,this.pickerButton=new be({button:{icon:Dp,label:"Select color"}},[new Nn(this.onColorSelect.bind(this))]),this.addChildren(this.pickerButton,this.input)}buildDOM(){let e=this.input.getDOMElement();e.append(this.pickerButton.getDOMElement()),e.classList.add("editor-color-field-container");let n=e.querySelector("input");return n.addEventListener("change",()=>{this.setIconColor(n.value)}),e}onColorSelect(e,n){this.input.setValue(e)}setIconColor(e){let n=this.getDOMElement().querySelector("svg .editor-icon-color-display");n&&n.setAttribute("fill",e||"url(#pattern2)")}};function xn(o){return{build(){return new Ld(new zt(o))}}}var Md={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"}},wd={label:"Border color",name:"border_color",type:"text"},vd={label:"Background color",name:"background_color",type:"text"},Op={label:"Alignment",name:"align",type:"select",valuesByLabel:{None:"",Left:"left",Center:"center",Right:"right"}};function Ap(o,t){let e=o.getStyles(),n=t.manager.createModal("cell_properties");return n.show({width:bm(t.editor,o),height:e.get("height")||"",type:o.getTag(),h_align:o.getAlignment(),v_align:e.get("vertical-align")||"",border_width:e.get("border-width")||"",border_style:e.get("border-style")||"",border_color:e.get("border-color")||"",background_color:o.getBackgroundColor()||e.get("background-color")||""}),n}var Rp={submitText:"Save",async action(o,t){return t.editor.update(()=>{let e=pn(C());for(let n of e){let r=o.get("width")?.toString()||"";Cm(n,r),n.updateTag(o.get("type")?.toString()||""),n.setAlignment(o.get("h_align")?.toString()||""),n.setBackgroundColor(o.get("background_color")?.toString()||"");let i=n.getStyles();i.set("height",Ct(o.get("height")?.toString()||"")),i.set("vertical-align",o.get("v_align")?.toString()||""),i.set("border-width",Ct(o.get("border_width")?.toString()||"")),i.set("border-style",o.get("border_style")?.toString()||""),i.set("border-color",o.get("border_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"}},{...Op,label:"Horizontal align",name:"h_align"},{label:"Vertical align",name:"v_align",type:"select",valuesByLabel:{None:"",Top:"top",Middle:"middle",Bottom:"bottom"}}],t=[{label:"Border width",name:"border_width",type:"text"},Md,xn(wd),xn(vd)];return new hn([{label:"General",contents:o},{label:"Advanced",contents:t}])}}]};function kp(o,t){let e=o.getStyles(),n=t.manager.createModal("row_properties");return n.show({height:e.get("height")||"",border_style:e.get("border-style")||"",border_color:e.get("border-color")||"",background_color:e.get("background-color")||""}),n}var Ip={submitText:"Save",async action(o,t){return t.editor.update(()=>{let e=uo(C());for(let n of e){let r=n.getStyles();r.set("height",Ct(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"},Md,xn(wd),xn(vd)]};function $p(o,t){let e=o.getStyles(),n=t.manager.createModal("table_properties");return n.show({width:e.get("width")||"",height:e.get("height")||"",cell_spacing:e.get("cell-spacing")||"",cell_padding:Lm(o),border_width:e.get("border-width")||"",border_style:e.get("border-style")||"",border_color:e.get("border-color")||"",background_color:e.get("background-color")||"",caption:za(o)?"true":"",align:o.getAlignment()}),n}var Pp={submitText:"Save",async action(o,t){return t.editor.update(()=>{let e=St(C());if(!e)return;let n=e.getStyles();n.set("width",Ct(o.get("width")?.toString()||"")),n.set("height",Ct(o.get("height")?.toString()||"")),n.set("cell-spacing",Ct(o.get("cell_spacing")?.toString()||"")),n.set("border-width",Ct(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()||""),e.setStyles(n),e.setAlignment(o.get("align"));let r=o.get("cell_padding")?.toString()||"";if(r){let l=Ct(r);rd(e,a=>{let d=a.getStyles();d.set("padding",l),a.setStyles(d)})}let i=!!o.get("caption")?.toString(),s=za(e);if(i&&!s)am(e,t.translate("Caption"));else if(!i&&s)for(let l of e.getChildren())Qr(l)&&l.remove()}),!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:"Show caption",name:"caption",type:"checkbox"},Op],t=[Md,xn(wd),xn(vd)];return new hn([{label:"General",contents:o},{label:"Advanced",contents:t}])}}]};function Bp(o){let t=E(o)?o.getChildren():[];return{node:o.exportJSON(),children:t.map(e=>Bp(e))}}function Hp(o,{node:t,children:e}){let n=o._nodes.get(t.type)?.klass.importJSON(t);if(!n)return null;let r=e.map(i=>Hp(o,i));for(let i of r)i&&E(n)&&n.append(i);return n}var gi=class{constructor(){p(this,"store",[])}set(...t){this.store.splice(0,this.store.length);for(let e of t)this.store.push(Bp(e))}get(t){return this.store.map(e=>Hp(t,e)).filter(e=>e!==null)}size(){return this.store.length}};var hi=new gi;function Dd(){return hi.size()===0}function Fp(o){let t=null;for(let e of o){let n=e.getChildren().filter(i=>D(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(t===null)t=r;else if(t!==r)throw Error("Cannot copy rows with inconsistent sizes")}}function Kp(o,t){let e=new Ut(t).columnCount;for(let n of o){let r=n.getChildren().filter(s=>D(s)),i=0;for(let s of r)i+=s.getColSpan()||1;if(i>e)throw Error("Cannot paste rows that are wider than target table");for(;i{let n=new gi;return n.set(...e),n});rl.splice(0,rl.length,...t)}function Od(){return rl.length===0}function Zp(o){if(q(o)){let i=o.getShape();return{from:i.fromX,to:i.toX}}let t=V(o,D),e=St(o);if(!D(t)||!e)return null;let r=new Ut(e).getRangeForCell(t);return r?{from:r.fromX,to:r.toX}:null}function Vp(o,t){let e=new Ut(t),n=[];for(let r=o.from;r<=o.to;r++){let i=e.getCellsInColumn(r);n.push(i)}return n}function Xp(o){let t=null;for(let e of o){let n=0;for(let r of e)if(n+=r.getRowSpan()||1,r.getColSpan()>1)throw Error("Cannot copy columns with merged cells");if(t===null)t=n;else if(t!==n)throw Error("Cannot copy columns with inconsistent sizes")}}function jp(){let o=C(),t=Zp(o),e=St(o);if(!t||!e)return;let n=e.getColWidths(),r=Vp(t,e);Xp(r),Yp(r);for(let s of r)for(let l of s)l.remove();let i=[...n].splice(t.from,t.to-t.from+1);e.setColWidths(i)}function Gp(){let o=C(),t=Zp(o),e=St(o);if(!t||!e)return;let n=Vp(t,e);Xp(n),Yp(n)}function CT(o,t){let e=new Ut(t).rowCount;for(let n of o){let r=0;for(let i of n)r+=i.getRowSpan()||1;if(r>e)throw Error("Cannot paste columns that are taller than target table");for(;rf.get(o));t||s.reverse(),CT(s,n);let l=new Ut(n),a=l.getRangeForCell(i);if(!a)return;let d=t?a.fromX:a.toX,u=n.getColWidths();for(let f=0;fm);u.splice(t?d:d+1,0,...c)}function Qp(o){Jp(o,!0)}function eg(o){Jp(o,!1)}var xe=()=>!1,Le=o=>!de(o,D),tg={label:"Table",icon:Sd},Ad={label:"Table properties",icon:Sd,action(o){o.editor.getEditorState().read(()=>{let t=St(C());K(t)&&$p(t,o)})},isActive:xe,isDisabled:Le},og={label:"Clear table formatting",format:"long",action(o){o.editor.update(()=>{let t=V(C(),D);if(!D(t))return;let e=$t(t,K);K(e)&&Sm(e)})},isActive:xe,isDisabled:Le},ng={label:"Resize to contents",format:"long",action(o){o.editor.update(()=>{let t=V(C(),D);if(!D(t))return;let e=$t(t,K);K(e)&&ym(e)})},isActive:xe,isDisabled:Le},Rd={label:"Delete table",icon:nl,action(o){o.editor.update(()=>{let t=V(C(),K);t&&t.remove()})},isActive(){return!1}},rg={...Rd,format:"long",isDisabled(o){return!de(o,K)}},kd={label:"Insert row before",icon:wp,action(o){o.editor.update(()=>{gs(!1)})},isActive:xe,isDisabled:Le},Id={label:"Insert row after",icon:vp,action(o){o.editor.update(()=>{gs(!0)})},isActive:xe,isDisabled:Le},$d={label:"Delete row",icon:Sp,action(o){o.editor.update(()=>{Ya()})},isActive:xe,isDisabled:Le},ig={label:"Row properties",format:"long",action(o){o.editor.getEditorState().read(()=>{let t=uo(C());te(t[0])&&kp(t[0],o)})},isActive:xe,isDisabled:Le},sg={label:"Cut row",format:"long",action(o){o.editor.update(()=>{try{Up()}catch(t){o.error(t)}})},isActive:xe,isDisabled:Le},lg={label:"Copy row",format:"long",action(o){o.editor.getEditorState().read(()=>{try{zp()}catch(t){o.error(t)}})},isActive:xe,isDisabled:Le},ag={label:"Paste row before",format:"long",action(o){o.editor.update(()=>{try{Wp(o.editor)}catch(t){o.error(t)}})},isActive:xe,isDisabled:o=>Le(o)||Dd()},dg={label:"Paste row after",format:"long",action(o){o.editor.update(()=>{try{qp(o.editor)}catch(t){o.error(t)}})},isActive:xe,isDisabled:o=>Le(o)||Dd()},cg={label:"Cut column",format:"long",action(o){o.editor.update(()=>{try{jp()}catch(t){o.error(t)}})},isActive:xe,isDisabled:Le},ug={label:"Copy column",format:"long",action(o){o.editor.getEditorState().read(()=>{try{Gp()}catch(t){o.error(t)}})},isActive:xe,isDisabled:Le},fg={label:"Paste column before",format:"long",action(o){o.editor.update(()=>{try{Qp(o.editor)}catch(t){o.error(t)}})},isActive:xe,isDisabled:o=>Le(o)||Od()},mg={label:"Paste column after",format:"long",action(o){o.editor.update(()=>{try{eg(o.editor)}catch(t){o.error(t)}})},isActive:xe,isDisabled:o=>Le(o)||Od()},Pd={label:"Insert column before",icon:Mp,action(o){o.editor.update(()=>{hs(!1)})},isActive(){return!1}},Bd={label:"Insert column after",icon:Lp,action(o){o.editor.update(()=>{hs(!0)})},isActive(){return!1}},Hd={label:"Delete column",icon:yp,action(o){o.editor.update(()=>{Za()})},isActive(){return!1}},pg={label:"Cell properties",format:"long",action(o){o.editor.getEditorState().read(()=>{let t=V(C(),D);D(t)&&Ap(t,o)})},isActive:xe,isDisabled:Le},gg={label:"Merge cells",format:"long",action(o){o.editor.update(()=>{let t=C();q(t)&&_m(t)})},isActive:xe,isDisabled(o){return!q(o)}},hg={label:"Split cell",format:"long",action(o){o.editor.update(()=>{Xa()})},isActive:xe,isDisabled(o){let t=V(o,D);return t?!(t.getRowSpan()>1||t.getColSpan()>1):!0}};var Ng='';var xg='';var Eg='';var Tg='';var Cg='';var bg={label:"Undo",icon:Ng,action(o){o.editor.dispatchCommand(ho,void 0),o.manager.triggerFutureStateRefresh()},isActive(o){return!1},setup(o,t){t.toggleDisabled(!0),o.editor.registerCommand(Co,e=>(t.toggleDisabled(!e),!1),Ae)}},_g={label:"Redo",icon:xg,action(o){o.editor.dispatchCommand(No,void 0),o.manager.triggerFutureStateRefresh()},isActive(o){return!1},setup(o,t){t.toggleDisabled(!0),o.editor.registerCommand(To,e=>(t.toggleDisabled(!e),!1),Ae)}},yg={label:"Source code",icon:Eg,async action(o){let t=o.manager.createModal("source"),e=await Ps(o.editor);t.show({source:e})},isActive(){return!1}},Sg={label:"Fullscreen",icon:Tg,async action(o,t){let e=o.containerDOM.classList.contains("fullscreen");o.containerDOM.classList.toggle("fullscreen",!e),o.containerDOM.closest("body").classList.toggle("editor-is-fullscreen",!e),t.setActiveState(!e)},isActive(o,t){return t.containerDOM.classList.contains("fullscreen")}},Lg={label:"About the editor",icon:Cg,async action(o,t){o.manager.createModal("about").show({})},isActive(o,t){return!1}};function il(o,t){return{label:t,action(e){e.editor.update(()=>{Vn(n=>Ia(n,o),()=>Jn(o))})},isActive(e){return de(e,n=>Ia(n,o))}}}var Mg=il("info","Info"),wg=il("danger","Danger"),vg=il("warning","Warning"),Dg=il("success","Success"),MT=(o,t)=>lr(o)&&o.getTag()===t;function sl(o,t){return{label:t,action(e){Us(e.editor,o)},isActive(e){return de(e,n=>MT(n,o))}}}var Og=sl("h2","Large Header"),Ag=sl("h3","Medium Header"),Rg=sl("h4","Small Header"),kg=sl("h5","Tiny Header"),Ig={label:"Blockquote",action(o){ai(o.editor)},isActive(o){return de(o,Ls)}},$g={label:"Paragraph",action(o){li(o.editor)},isActive(o){return de(o,Ge)}};var Pg='';var Bg='';var Hg='';var Fg=` -`;var Kg='';var Ug='';var zg='';var Wg='';var qg='';var Yg='';function En(o,t,e){return{label:o,icon:e,action(n){n.editor.dispatchCommand(Ee,t)},isActive(n){return cf(n,t)}}}var Fd=En("Bold","bold",Pg),Kd=En("Italic","italic",Bg),Zg=En("Underline","underline",Hg),Vg={label:"Text color",icon:Fg},Xg={label:"Highlight color",icon:Kg};function jg(o,t,e){o.editor.update(()=>{let n=C();n&&ga(n,{[t]:e||null})})}var Gg=(o,t)=>jg(t,"color",o),Jg=(o,t)=>jg(t,"background-color",o),Qg=En("Strikethrough","strikethrough",Ug),eh=En("Superscript","superscript",zg),th=En("Subscript","subscript",Wg),oh=En("Inline code","code",qg),nh={label:"Clear formatting",icon:Yg,action(o){o.editor.update(()=>{let t=C();for(let e of t?.getNodes()||[])L(e)&&(e.setFormat(0),e.setStyle(""))})},isActive(){return!1}};var rh='';var ih='';var sh='';var lh='';var ah='';var dh='';function ll(o,t){let e=ae(o.editor),n=e?.getNodes()||[];if(n.length===1&&E(n[0])&&n[0].isInline()&&Yr(n[0])){n[0].setAlignment(t),Be(n[0]),o.manager.triggerFutureStateRefresh();return}let i=Pt(e).filter(a=>Yr(a)),l=i.every(a=>a.getAlignment()===t)?"":t;for(let a of i)a.setAlignment(l);o.manager.triggerFutureStateRefresh()}function ch(o,t){let e=ae(o.editor),n=Pt(e);for(let r of n)r.setDirection(t);o.manager.triggerFutureStateRefresh()}var uh={label:"Align left",icon:rh,action(o){o.editor.update(()=>ll(o,"left"))},isActive(o){return Zr(o,"left")}},fh={label:"Align center",icon:ih,action(o){o.editor.update(()=>ll(o,"center"))},isActive(o){return Zr(o,"center")}},mh={label:"Align right",icon:sh,action(o){o.editor.update(()=>ll(o,"right"))},isActive(o){return Zr(o,"right")}},ph={label:"Justify",icon:lh,action(o){o.editor.update(()=>ll(o,"justify"))},isActive(o){return Zr(o,"justify")}},gh={label:"Left to right",icon:ah,action(o){o.editor.update(()=>ch(o,"ltr"))},isActive(o){return Ca(o,"ltr")}},hh={label:"Right to left",icon:dh,action(o){o.editor.update(()=>ch(o,"rtl"))},isActive(o){return Ca(o,"rtl")}};var Nh='';var xh='';var Eh='';var Th='';var Ch='';function Ud(o,t,e){return{label:o,icon:e,action(n){di(n.editor,t)},isActive(n){return de(n,r=>W(r)&&r.getListType()===t)}}}var zd=Ud("Bullet list","bullet",Nh),Wd=Ud("Numbered list","number",xh),bh=Ud("Task list","check",Eh),_h={label:"Increase indent",icon:Th,action(o){o.editor.update(()=>{fi(o.editor,40)})},isActive(){return!1}},yh={label:"Decrease indent",icon:Ch,action(o){o.editor.update(()=>{fi(o.editor,-40)})},isActive(){return!1}};var Sh='';var Lh='';var Mh='';var wh='';var vh='';var Dh='';var Oh='';var Ah='';var Rh=` -`;var kh='';var Ih='';var al={label:"Insert/edit link",icon:Sh,action(o){o.editor.getEditorState().read(()=>{let t=V(C(),Ft);Zs(t,o)})},isActive(o){return de(o,Ft)}},$h={label:"Remove link",icon:Lh,action(o){o.editor.update(()=>{let t=ae(o.editor),e=V(t,Ft);if(e){let n=e.getChildren().reverse();for(let r of n)e.insertAfter(r);e.remove(),n[n.length-1].selectStart(),o.manager.triggerFutureStateRefresh()}})},isActive(o){return!1}},qd={label:"Insert/Edit Image",icon:Mh,action(o){o.editor.getEditorState().read(()=>{let t=ae(o.editor),e=V(t,Qe);if(e){Gm(e,o);return}Ks(n=>{o.editor.update(()=>{let r=Um(n);Ce([r]),r.select()})})})},isActive(o){return de(o,Qe)}},Ph={label:"Insert horizontal line",icon:wh,action(o){o.editor.update(()=>{tn(id(),!1)})},isActive(o){return de(o,Mm)}},Yd={label:"Insert code block",icon:vh,action(o){ci(o.editor)},isActive(o){return de(o,_s)}},Bh=Object.assign({},Yd,{label:"Edit code block",icon:Dh}),Hh={label:"Insert/edit drawing",icon:Oh,action(o){o.editor.getEditorState().read(()=>{let t=ae(o.editor),e=V(t,mo);e===null?o.editor.update(()=>{let n=nr();tn(n,!0),mi(o,n),n.selectStart()}):mi(o,e)})},isActive(o){return de(o,mo)}},Fh={label:"Drawing manager",action(o){mp(o)},isActive(){return!1}},Zd={label:"Insert/edit media",icon:Ih,action(o){o.editor.getEditorState().read(()=>{let t=C(),e=V(t,Mt);ep(e,o)})},isActive(o){return de(o,Mt)}},Kh={label:"Insert collapsible block",icon:Ah,action(o){o.editor.update(()=>{let t=C(),e=$a(),r=(t?.getNodes()||[]).map(s=>s.getTopLevelElement()).filter(s=>s!==null),i=[...new Set(r)];e.setOpen(!0),i.length>0?i[0].insertAfter(e):F().append(e);for(let s of i)e.append(s)})},isActive(o){return de(o,ce)}},Uh={label:"Edit label",icon:kh,action(o){o.editor.getEditorState().read(()=>{let t=V(C(),ce);ce(t)&&op(t,o)})},isActive(o){return!1}},zh={label:"Toggle open/closed",icon:Rh,action(o){o.editor.update(()=>{let t=V(C(),ce);ce(t)&&(t.setOpen(!t.getOpen()),o.manager.triggerLayoutUpdate())})},isActive(o){return!1}},Wh={label:"Unwrap",icon:nl,action(o){o.editor.update(()=>{let t=V(C(),ce);ce(t)&&(Js(t),o.manager.triggerLayoutUpdate())})},isActive(o){return!1}};var qh=` -`;var dl=class extends oe{constructor(e,n){super([e]);p(this,"button");p(this,"dropdownButton");this.button=e,this.dropdownButton=new be({button:{label:"Menu",icon:qh},showOnHover:!1,direction:"vertical",showAside:!1},n),this.addChildren(this.dropdownButton)}buildDOM(){return y("div",{class:"editor-button-with-menu-container"},[this.button.getDOMElement(),this.dropdownButton.getDOMElement()])}};var Tn=class extends ke{buildDOM(){return y("div",{class:"editor-separator"})}};function Yh(o){let t=o.manager.getDefaultDirection()==="rtl";return new si("editor-toolbar-main",[new Ie("history",2,[new w(bg),new w(_g)]),new el([new et(y("h2"),Og),new et(y("h3"),Ag),new et(y("h4"),Rg),new et(y("h5"),kg),new et(y("blockquote"),Ig),new et(y("p"),$g),new be({button:{label:"Callouts",format:"long"},showOnHover:!0,direction:"vertical"},[new et(y("p",{class:"callout info"}),Mg),new et(y("p",{class:"callout success"}),Dg),new et(y("p",{class:"callout warning"}),vg),new et(y("p",{class:"callout danger"}),wg)])]),new Ie("inline_formats",6,[new w(Fd),new w(Kd),new w(Zg),new be({button:new pi(Vg,"color")},[new Nn(Gg)]),new be({button:new pi(Xg,"background-color")},[new Nn(Jg)]),new w(Qg),new w(eh),new w(th),new w(oh),new w(nh)]),new Ie("alignment",6,[new w(uh),new w(fh),new w(mh),new w(ph),t?new w(gh):null,t?new w(hh):null].filter(e=>e!==null)),new Ie("lists",3,[new w(zd),new w(Wd),new w(bh),new w(yh),new w(_h)]),new Ie("inserts",4,[new w(al),new be({button:tg,direction:"vertical",showAside:!1},[new be({button:{label:"Insert",format:"long"},showOnHover:!0,showAside:!0},[new ol]),new Tn,new be({button:{label:"Cell",format:"long"},direction:"vertical",showOnHover:!0},[new w(pg),new w(gg),new w(hg)]),new be({button:{label:"Row",format:"long"},direction:"vertical",showOnHover:!0},[new w({...kd,format:"long"}),new w({...Id,format:"long"}),new w({...$d,format:"long"}),new w(ig),new Tn,new w(sg),new w(lg),new w(ag),new w(dg)]),new be({button:{label:"Column",format:"long"},direction:"vertical",showOnHover:!0},[new w({...Pd,format:"long"}),new w({...Bd,format:"long"}),new w({...Hd,format:"long"}),new Tn,new w(cg),new w(ug),new w(fg),new w(mg)]),new Tn,new w({...Ad,format:"long"}),new w(og),new w(ng),new w(rg)]),new w(qd),new w(Ph),new w(Yd),new dl(new w(Hh),[new w(Fh)]),new w(Zd),new w(Kh)]),new Ie("meta",3,[new w(yg),new w(Lg),new w(Sg)])])}function Vd(o){return new si("editor-toolbar-main",[new Ie("formats",7,[new w(Fd),new w(Kd),new w(al),new w(zd),new w(Wd)])])}var Ni={image:{selector:"img:not([drawio-diagram] img)",content:()=>[new w(qd)]},media:{selector:".editor-media-wrap",content:()=>[new w(Zd)]},link:{selector:"a:not([data-mention-user-id])",content(){return[new w(al),new w($h)]},displayTargetLocator(o){return o.querySelector("img")||o}},code:{selector:".editor-code-block-wrap",content:()=>[new w(Bh)]},table:{selector:"td,th",content(){return[new Ie("table",2,[new w(Ad),new w(Rd)]),new Ie("table_row",3,[new w(kd),new w(Id),new w($d)]),new Ie("table_column",3,[new w(Pd),new w(Bd),new w(Hd)])]},displayTargetLocator(o){return o.closest("table")}},details:{selector:"details",content(){return[new w(Uh),new w(zh),new w(Wh)]}}};var cl=class extends ke{constructor(e){super();p(this,"url","");this.url=e}buildDOM(){let e=y("div",{class:"editor-external-content"});return window.$http.get(this.url).then(n=>{typeof n.data=="string"&&(e.innerHTML=n.data)}),e}};var Zh={submitText:"Save",async action(o,t){return Po(t.editor,o.get("source")?.toString()||""),!0},fields:[{label:"Source",name:"source",type:"textarea"}]},Vh={submitText:"Close",async action(){return!0},fields:[{build(){return new cl("/help/wysiwyg")}}]};var xi={link:{title:"Insert/Edit Link",form:Qm},image:{title:"Insert/Edit Image",form:Jm},media:{title:"Insert/Edit Media",form:tp},source:{title:"Source code",form:Zh},cell_properties:{title:"Cell Properties",form:Rp},row_properties:{title:"Row Properties",form:Ip},table_properties:{title:"Table Properties",form:Pp},details:{title:"Edit collapsible block",form:np},about:{title:"About the WYSIWYG Editor",form:Vh}};var Bo=class{constructor(t){p(this,"node",null);p(this,"context");p(this,"onDestroyCallbacks",[]);this.context=t}getNode(){if(!this.node)throw new Error("Attempted to get use node without it being set");return this.node}setNode(t){this.node=t}onDestroy(t){this.onDestroyCallbacks.push(t)}teardown(){for(let t of this.onDestroyCallbacks)t()}};var ul=class extends Bo{constructor(){super(...arguments);p(this,"completedSetup",!1);p(this,"latestCode","");p(this,"latestLanguage","");p(this,"editor",null)}setup(e){let n=this.getNode(),r=e.querySelector("pre");if(!r)return;r&&(r.hidden=!0),this.latestCode=n.__code,this.latestLanguage=n.__language;let s=this.latestCode.split(` -`).length*19.2+18+24;e.style.height=`${s}px`;let l=Date.now();e.addEventListener("click",u=>{requestAnimationFrame(()=>{this.context.editor.update(()=>{Be(this.getNode())})})}),e.addEventListener("dblclick",u=>{this.context.editor.getEditorState().read(()=>{ii(this.context.editor,this.getNode())})});let a=u=>{e.classList.toggle("selected",ts(u,n))};this.context.manager.onSelectionChange(a),this.onDestroy(()=>{this.context.manager.offSelectionChange(a)});let d=u=>{this.editor=u.wysiwygView(e,document,this.latestCode,this.latestLanguage),setTimeout(()=>{e.style.height=""},12)};window.importVersioned("code").then(u=>{let m=Date.now()-l<20?20:0;setTimeout(()=>d(u),m)}),this.completedSetup=!0}update(){let e=this.getNode(),n=e.getCode(),r=e.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(e){this.completedSetup?this.update():this.setup(e)}};var fl=class extends Bo{constructor(){super(...arguments);p(this,"completedSetup",!1)}setup(e){let n=this.getNode();e.classList.add("editor-diagram"),this.context.editor.registerCommand(Wt,i=>e.contains(i.target)?(this.context.editor.update(()=>{Be(this.getNode())}),!0):!1,lo),e.addEventListener("dblclick",i=>{this.context.editor.getEditorState().read(()=>{mi(this.context,this.getNode())})});let r=i=>{e.classList.toggle("selected",ts(i,n))};this.context.manager.onSelectionChange(r),this.onDestroy(()=>{this.context.manager.offSelectionChange(r)}),this.completedSetup=!0}update(){}render(e){this.completedSetup?this.update():this.setup(e)}};function lC(o){return H(o)||Qe(o)||Mt(o)||mo(o)||K(o)||ce(o)}function aC(o){if(o.target instanceof HTMLElement){let t=o.target.closest("details");if(t){let e=G(t);if(ce(e))return e}}return F()}function dC(o,t){let e=aC(t),n=e.getLastChild();if(!n||!lC(n))return!1;let r=o.editor.getElementByKey(n.getKey());if(!r)return!1;let i=r.getBoundingClientRect();return t.clientY>i.bottom?(o.editor.update(()=>{let l=I();e.append(l),l.select()}),!0):!1}function Xh(o){let t=o.editor.registerCommand(Wt,e=>(dC(o,e),!1),Ae);return()=>{t()}}var Xd=new Set;function cC(o){for(let n of Xd)n.classList.remove("selected"),Xd.delete(n);let e=C()?.getNodes()||[];if(e.length===1&&ce(e[0])){let n=o.editor.getElementByKey(e[0].getKey());n&&(n.classList.add("selected"),Xd.add(n))}return!1}function jh(o){let t=o.editor.registerCommand(_e,()=>(cC(o),!1),Ae);return()=>{t()}}var Cn,Ei,jd=class{constructor(t,e){vt(this,Cn);vt(this,Ei,!1);po(this,Cn,new w({label:t.label||"",icon:t.icon||"",action:()=>{t.action()},isActive:()=>Me(this,Ei)})),Me(this,Cn).setContext(e)}setActive(t=!0){po(this,Ei,t),Me(this,Cn).setActiveState(t)}_getOriginalModel(){return Me(this,Cn)}};Cn=new WeakMap,Ei=new WeakMap;var Ti,Gd=class{constructor(t){vt(this,Ti);po(this,Ti,t)}getSections(){return Me(this,Ti).getChildren().filter(e=>e instanceof Ie).map(e=>new Jd(e))}};Ti=new WeakMap;var bn,Jd=class{constructor(t){vt(this,bn);po(this,bn,t)}getLabel(){return Me(this,bn).getLabel()}addButton(t,e=-1){Me(this,bn).addChild(t._getOriginalModel(),e),Me(this,bn).rebuildDOM()}};bn=new WeakMap;var fr,ml=class{constructor(t){vt(this,fr);po(this,fr,t)}createButton(t){return new jd(t,Me(this,fr))}getMainToolbar(){let t=Me(this,fr).manager.getToolbar();return t?new Gd(t):null}};fr=new WeakMap;var _n,pl=class{constructor(t){vt(this,_n);po(this,_n,t)}insertHtml(t,e="selection"){let n=["start","end","selection"];if(!n.includes(e))throw new Error(`Invalid position: ${e}. Valid positions are: ${n.join(", ")}`);e==="start"?Is(Me(this,_n).editor,t):e==="end"?ks(Me(this,_n).editor,t):$s(Me(this,_n).editor,t)}};_n=new WeakMap;var mr=class{constructor(t){p(this,"ui");p(this,"content");this.ui=new ml(t),this.content=new pl(t)}};function pr(o){return o instanceof HTMLElement}function Gh(o){o.innerHTML='
    '}var Ho,Qd,ec,gl=class{constructor(t,e=null,n=null){vt(this,Ho);p(this,"containers");p(this,"onEscape");p(this,"onEnter");this.containers=[t],this.onEscape=e,this.onEnter=n,t.addEventListener("keydown",hr(this,Ho,Qd).bind(this))}shareHandlingToEl(t){this.containers.push(t),t.addEventListener("keydown",hr(this,Ho,Qd).bind(this))}focusNext(){let t=hr(this,Ho,ec).call(this),e=document.activeElement,r=(pr(e)?t.indexOf(e):-1)+1;r>=t.length&&(r=0),t[r].focus()}focusPrevious(){let t=hr(this,Ho,ec).call(this),e=document.activeElement,r=(pr(e)?t.indexOf(e):-1)-1;r<0&&(r=t.length-1),t[r].focus()}};Ho=new WeakSet,Qd=function(t){pr(t.target)&&t.target.matches("input")&&(t.key==="ArrowRight"||t.key==="ArrowLeft")||(t.key==="ArrowDown"||t.key==="ArrowRight"?(this.focusNext(),t.preventDefault()):t.key==="ArrowUp"||t.key==="ArrowLeft"?(this.focusPrevious(),t.preventDefault()):t.key==="Escape"?this.onEscape?this.onEscape(t):pr(document.activeElement)&&document.activeElement.blur():t.key==="Enter"&&this.onEnter&&this.onEnter(t))},ec=function(){let t=[],e='[tabindex]:not([tabindex="-1"]),[href],button:not([tabindex="-1"],[disabled]),input:not([type=hidden])';for(let n of this.containers){let r=[...n.querySelectorAll(e)].filter(i=>pr(i));t.push(...r)}return t};function uC(o){return t=>{let e=t.target.closest("a[data-id]");if(!e)return;let n=Number(e.dataset.id||"0"),r=e.dataset.name||"",i=e.dataset.slug||"";o(n,r,i),t.preventDefault()}}function fC(o,t,e,n){t.addEventListener("keydown",i=>{i.key==="Escape"&&n()},{signal:e.signal});let r=t.querySelector("input");r.addEventListener("keydown",i=>{i.key==="Backspace"&&r.value===""&&(n(),i.preventDefault(),i.stopPropagation())},{signal:e.signal}),o.editorDOM.addEventListener("click",i=>{n()},{signal:e.signal}),o.editorDOM.addEventListener("keydown",i=>{n()},{signal:e.signal})}function mC(o){let t=new Map,e=async i=>{for(let d of[...o.children])d.remove();let s="";if(t.has(i))s=t.get(i)||"";else{let d=y("div",{class:"flex-container-row items-center dropdown-search-item"});Gh(d),o.appendChild(d),s=(await window.$http.get(`/search/users/mention?search=${i}`)).data,t.set(i,s),d.remove()}let a=[...es(s).body.children];for(let d of a){let u=window.document.adoptNode(d);o.appendChild(u)}};e("");let n=o.parentElement?.querySelector("input"),r=Pm(e,200,!1);n.addEventListener("input",()=>{let i=n.value;r(i)})}function pC(o,t){let e=y("input",{type:"text"}),n=y("div",{class:"dropdown-search-list"}),r=y("div");r.innerHTML=Ws;let i=r.children[0];i.classList.add("svg-icon");let s=y("div",{class:"dropdown-search-dropdown compact card"},[y("div",{class:"dropdown-search-search"},[i,e]),n]);o.containerDOM.appendChild(s),s.style.display="block",s.style.top="0",s.style.left="0";let l=t.getBoundingClientRect(),a=s.getBoundingClientRect();return s.style.top=`${l.bottom-a.top+3}px`,s.style.left=`${l.left-a.left}px`,e.focus(),s}var gr=class extends Bo{constructor(){super(...arguments);p(this,"abortController",null);p(this,"dropdownContainer",null);p(this,"mentionElement",null)}setup(e){this.mentionElement=e,e.addEventListener("click",n=>{this.showSelection(),n.preventDefault(),n.stopPropagation()})}showSelection(){!this.mentionElement||this.dropdownContainer||(this.hideSelection(),this.abortController=new AbortController,this.dropdownContainer=pC(this.context,this.mentionElement),mC(this.dropdownContainer.querySelector(".dropdown-search-list")),this.dropdownContainer.addEventListener("click",uC((e,n,r)=>{this.context.editor.update(()=>{let i=this.getNode();this.hideSelection(),i.setUserDetails(e,n,r),i.selectNext()})}),{signal:this.abortController.signal}),fC(this.context,this.dropdownContainer,this.abortController,()=>{this.getNode().hasUserSet()?this.hideSelection():this.revertMention()}),new gl(this.dropdownContainer))}hideSelection(){this.abortController?.abort(),this.dropdownContainer?.remove(),this.abortController=null,this.dropdownContainer=null,this.context.manager.focus()}revertMention(){this.hideSelection(),this.context.editor.update(()=>{let e=z("@"),n=this.getNode().getPreviousSibling();this.getNode().replace(e),requestAnimationFrame(()=>{this.context.editor.update(()=>{e.isAttached()?e.selectEnd():n?.isAttached()&&n?.selectEnd()})})})}render(e){this.setup(e)}};function gC(o,t){let e=t.getNodes()[0],n=t.getStartEndPoints();if(!n)return;let r=n[0].offset,i=r===0,s=e.getTextContent().charAt(r-1)===" ";if(!i&&!s)return;let l=e.splitText(r),a=l[0],d=l[i?0:1],u=sd(0,"","");a.insertAfter(u),d.spliceText(0,1,"",!1),Be(u),requestAnimationFrame(()=>{let m=o.manager.getDecoratorByNodeKey(u.getKey());m instanceof gr&&m.showSelection()})}function hC(o,t){let e=C()?.getNodes()||[];if(e.length===1&&Rm(e[0])){let n=e[0];return o.manager.getDecoratorByNodeKey(n.getKey()).showSelection(),t.preventDefault(),t.stopPropagation(),!0}return!1}function Jh(o){let t=o.editor,e=t.registerCommand(_i,function(r){let i=C();return _(i)&&i.isCollapsed()&&window.setTimeout(()=>{t.update(()=>{gC(o,i)})},1),!1},lo),n=t.registerCommand(we,function(r){return hC(o,r)},lo);return()=>{e(),n()}}var tc={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"}};function jF(o,t,e={}){let n=Gr({namespace:"BookStackPageEditor",nodes:km(),onError:console.error,theme:tc}),r=Rs(o,n,{...e,editorClass:"page-content"});n.setRootElement(r.editorDOM),Et(ms(n),ss(n,ls(),300),Xs(r),Np(r),Xh(r),jh(r),Fm(n,r.scrollDOM),Vm(n),Zm(n,r.editorDOM),Ym(r),lp(r),Qs(n)),r.manager.setToolbar(Yh(r));for(let s of Object.keys(Ni))r.manager.registerContextToolbar(s,Ni[s]);for(let s of Object.keys(xi))r.manager.registerModal(s,xi[s]);r.manager.registerDecoratorType("code",ul),r.manager.registerDecoratorType("diagram",fl),Km(n),Po(n,t);let i=document.getElementById("lexical-debug");return i&&(i.hidden=!0,n.registerUpdateListener(({dirtyElements:s,dirtyLeaves:l,editorState:a,prevEditorState:d})=>{i.textContent=JSON.stringify(a.toJSON(),null,2)})),window.debugEditorState=()=>n.getEditorState().toJSON(),$m(r),window.$events.emitPublic(o,"editor-wysiwyg::post-init",{usage:"page-editor",api:new mr(r)}),new Ci(r)}function GF(o,t,e={}){let n=Gr({namespace:"BookStackBasicEditor",nodes:ld(),onError:console.error,theme:tc}),r=Rs(o,n,e);n.setRootElement(r.editorDOM);let i=Et(ms(n),ss(n,ls(),300),Xs(r),Qs(n));return r.manager.setToolbar(Vd(r)),r.manager.registerContextToolbar("link",Ni.link),r.manager.registerModal("link",xi.link),r.manager.onTeardown(i),Po(n,t),window.$events.emitPublic(o,"editor-wysiwyg::post-init",{usage:"description-editor",api:new mr(r)}),new Ci(r)}function JF(o,t,e={}){let n=Gr({namespace:"BookStackCommentEditor",nodes:Im(),onError:console.error,theme:tc}),r=Rs(o,n,e);n.setRootElement(r.editorDOM);let i=Et(ms(n),ss(n,ls(),300),Xs(r),Qs(n),Jh(r));return r.manager.setToolbar(Vd(r)),r.manager.registerContextToolbar("link",Ni.link),r.manager.registerModal("link",xi.link),r.manager.onTeardown(i),r.manager.registerDecoratorType("mention",gr),Po(n,t),window.$events.emitPublic(o,"editor-wysiwyg::post-init",{usage:"comment-editor",api:new mr(r)}),new Ci(r)}var Ci=class{constructor(t){p(this,"context");p(this,"onChangeListeners",[]);p(this,"editorListenerTeardown",null);this.context=t}async getContentAsHtml(){return await Ps(this.context.editor)}onChange(t){this.onChangeListeners.push(t),this.startListeningToChanges()}focus(){Bs(this.context.editor)}remove(){this.context.manager.teardown(),this.context.containerDOM.remove(),this.editorListenerTeardown&&this.editorListenerTeardown()}startListeningToChanges(){this.editorListenerTeardown||(this.editorListenerTeardown=this.context.editor.registerUpdateListener(()=>{for(let t of this.onChangeListeners)t()}))}};export{Ci as SimpleWysiwygEditorInterface,GF as createBasicEditorInstance,JF as createCommentEditorInstance,jF as createPageEditorInstance}; +`;var Md=class extends oe{constructor(e){super([]);p(this,"input");p(this,"pickerButton");this.input=e,this.pickerButton=new be({button:{icon:Dp,label:"Select color"}},[new Nn(this.onColorSelect.bind(this))]),this.addChildren(this.pickerButton,this.input)}buildDOM(){let e=this.input.getDOMElement();e.append(this.pickerButton.getDOMElement()),e.classList.add("editor-color-field-container");let n=e.querySelector("input");return n.addEventListener("change",()=>{this.setIconColor(n.value)}),e}onColorSelect(e,n){this.input.setValue(e)}setIconColor(e){let n=this.getDOMElement().querySelector("svg .editor-icon-color-display");n&&n.setAttribute("fill",e||"url(#pattern2)")}};function xn(o){return{build(){return new Md(new Kt(o))}}}var wd={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"}},vd={label:"Border color",name:"border_color",type:"text"},Dd={label:"Background color",name:"background_color",type:"text"},Op={label:"Alignment",name:"align",type:"select",valuesByLabel:{None:"",Left:"left",Center:"center",Right:"right"}};function Ap(o,t){let e=o.getStyles(),n=t.manager.createModal("cell_properties");return n.show({width:Fm(t.editor,o),height:e.get("height")||"",type:o.getTag(),h_align:o.getAlignment(),v_align:e.get("vertical-align")||"",border_width:e.get("border-width")||"",border_style:e.get("border-style")||"",border_color:e.get("border-color")||"",background_color:o.getBackgroundColor()||e.get("background-color")||""}),n}var Rp={submitText:"Save",async action(o,t){return t.editor.update(()=>{let e=hn(C());for(let n of e){let r=o.get("width")?.toString()||"";Hm(n,r),n.updateTag(o.get("type")?.toString()||""),n.setAlignment(o.get("h_align")?.toString()||""),n.setBackgroundColor(o.get("background_color")?.toString()||"");let i=n.getStyles();i.set("height",Ct(o.get("height")?.toString()||"")),i.set("vertical-align",o.get("v_align")?.toString()||""),i.set("border-width",Ct(o.get("border_width")?.toString()||"")),i.set("border-style",o.get("border_style")?.toString()||""),i.set("border-color",o.get("border_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"}},{...Op,label:"Horizontal align",name:"h_align"},{label:"Vertical align",name:"v_align",type:"select",valuesByLabel:{None:"",Top:"top",Middle:"middle",Bottom:"bottom"}}],t=[{label:"Border width",name:"border_width",type:"text"},wd,xn(vd),xn(Dd)];return new cn([{label:"General",contents:o},{label:"Advanced",contents:t}])}}]};function kp(o,t){let e=o.getStyles(),n=t.manager.createModal("row_properties");return n.show({height:e.get("height")||"",border_style:e.get("border-style")||"",border_color:e.get("border-color")||"",background_color:e.get("background-color")||""}),n}var Ip={submitText:"Save",async action(o,t){return t.editor.update(()=>{let e=uo(C());for(let n of e){let r=n.getStyles();r.set("height",Ct(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"},wd,xn(vd),xn(Dd)]};function $p(o,t){let e=o.getStyles(),n=t.manager.createModal("table_properties");return n.show({width:e.get("width")||"",height:e.get("height")||"",cell_spacing:e.get("cell-spacing")||"",cell_padding:Wm(o),border_width:e.get("border-width")||"",border_style:e.get("border-style")||"",border_color:e.get("border-color")||"",background_color:e.get("background-color")||"",caption:Ya(o)?"true":"",align:o.getAlignment()}),n}var Pp={submitText:"Save",async action(o,t){return t.editor.update(()=>{let e=Lt(C());if(!e)return;let n=e.getStyles();n.set("width",Ct(o.get("width")?.toString()||"")),n.set("height",Ct(o.get("height")?.toString()||"")),n.set("cell-spacing",Ct(o.get("cell_spacing")?.toString()||"")),n.set("border-width",Ct(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()||""),e.setStyles(n),e.setAlignment(o.get("align"));let r=o.get("cell_padding")?.toString()||"";if(r){let l=Ct(r);ld(e,a=>{let d=a.getStyles();d.set("padding",l),a.setStyles(d)})}let i=!!o.get("caption")?.toString(),s=Ya(e);if(i&&!s)Lm(e,t.translate("Caption"));else if(!i&&s)for(let l of e.getChildren())si(l)&&l.remove()}),!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:"Show caption",name:"caption",type:"checkbox"},Op],t=[wd,xn(vd),xn(Dd)];return new cn([{label:"General",contents:o},{label:"Advanced",contents:t}])}}]};function Bp(o){let t=E(o)?o.getChildren():[];return{node:o.exportJSON(),children:t.map(e=>Bp(e))}}function Hp(o,{node:t,children:e}){let n=o._nodes.get(t.type)?.klass.importJSON(t);if(!n)return null;let r=e.map(i=>Hp(o,i));for(let i of r)i&&E(n)&&n.append(i);return n}var gi=class{constructor(){p(this,"store",[])}set(...t){this.store.splice(0,this.store.length);for(let e of t)this.store.push(Bp(e))}get(t){return this.store.map(e=>Hp(t,e)).filter(e=>e!==null)}size(){return this.store.length}};var hi=new gi;function Od(){return hi.size()===0}function Fp(o){let t=null;for(let e of o){let n=e.getChildren().filter(i=>D(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(t===null)t=r;else if(t!==r)throw Error("Cannot copy rows with inconsistent sizes")}}function Kp(o,t){let e=new zt(t).columnCount;for(let n of o){let r=n.getChildren().filter(s=>D(s)),i=0;for(let s of r)i+=s.getColSpan()||1;if(i>e)throw Error("Cannot paste rows that are wider than target table");for(;i{let n=new gi;return n.set(...e),n});il.splice(0,il.length,...t)}function Ad(){return il.length===0}function Zp(o){if(q(o)){let i=o.getShape();return{from:i.fromX,to:i.toX}}let t=V(o,D),e=Lt(o);if(!D(t)||!e)return null;let r=new zt(e).getRangeForCell(t);return r?{from:r.fromX,to:r.toX}:null}function Vp(o,t){let e=new zt(t),n=[];for(let r=o.from;r<=o.to;r++){let i=e.getCellsInColumn(r);n.push(i)}return n}function Xp(o){let t=null;for(let e of o){let n=0;for(let r of e)if(n+=r.getRowSpan()||1,r.getColSpan()>1)throw Error("Cannot copy columns with merged cells");if(t===null)t=n;else if(t!==n)throw Error("Cannot copy columns with inconsistent sizes")}}function jp(){let o=C(),t=Zp(o),e=Lt(o);if(!t||!e)return;let n=e.getColWidths(),r=Vp(t,e);Xp(r),Yp(r);for(let s of r)for(let l of s)l.remove();let i=[...n].splice(t.from,t.to-t.from+1);e.setColWidths(i)}function Gp(){let o=C(),t=Zp(o),e=Lt(o);if(!t||!e)return;let n=Vp(t,e);Xp(n),Yp(n)}function CT(o,t){let e=new zt(t).rowCount;for(let n of o){let r=0;for(let i of n)r+=i.getRowSpan()||1;if(r>e)throw Error("Cannot paste columns that are taller than target table");for(;rf.get(o));t||s.reverse(),CT(s,n);let l=new zt(n),a=l.getRangeForCell(i);if(!a)return;let d=t?a.fromX:a.toX,u=n.getColWidths();for(let f=0;fm);u.splice(t?d:d+1,0,...c)}function Qp(o){Jp(o,!0)}function eg(o){Jp(o,!1)}var xe=()=>!1,Le=o=>!de(o,D),tg={label:"Table",icon:Ld},Rd={label:"Table properties",icon:Ld,action(o){o.editor.getEditorState().read(()=>{let t=Lt(C());K(t)&&$p(t,o)})},isActive:xe,isDisabled:Le},og={label:"Clear table formatting",format:"long",action(o){o.editor.update(()=>{let t=V(C(),D);if(!D(t))return;let e=$t(t,K);K(e)&&zm(e)})},isActive:xe,isDisabled:Le},ng={label:"Resize to contents",format:"long",action(o){o.editor.update(()=>{let t=V(C(),D);if(!D(t))return;let e=$t(t,K);K(e)&&Um(e)})},isActive:xe,isDisabled:Le},kd={label:"Delete table",icon:rl,action(o){o.editor.update(()=>{let t=V(C(),K);t&&t.remove()})},isActive(){return!1}},rg={...kd,format:"long",isDisabled(o){return!de(o,K)}},Id={label:"Insert row before",icon:wp,action(o){o.editor.update(()=>{Ds(!1)})},isActive:xe,isDisabled:Le},$d={label:"Insert row after",icon:vp,action(o){o.editor.update(()=>{Ds(!0)})},isActive:xe,isDisabled:Le},Pd={label:"Delete row",icon:Sp,action(o){o.editor.update(()=>{Xa()})},isActive:xe,isDisabled:Le},ig={label:"Row properties",format:"long",action(o){o.editor.getEditorState().read(()=>{let t=uo(C());te(t[0])&&kp(t[0],o)})},isActive:xe,isDisabled:Le},sg={label:"Cut row",format:"long",action(o){o.editor.update(()=>{try{Up()}catch(t){o.error(t)}})},isActive:xe,isDisabled:Le},lg={label:"Copy row",format:"long",action(o){o.editor.getEditorState().read(()=>{try{zp()}catch(t){o.error(t)}})},isActive:xe,isDisabled:Le},ag={label:"Paste row before",format:"long",action(o){o.editor.update(()=>{try{Wp(o.editor)}catch(t){o.error(t)}})},isActive:xe,isDisabled:o=>Le(o)||Od()},dg={label:"Paste row after",format:"long",action(o){o.editor.update(()=>{try{qp(o.editor)}catch(t){o.error(t)}})},isActive:xe,isDisabled:o=>Le(o)||Od()},cg={label:"Cut column",format:"long",action(o){o.editor.update(()=>{try{jp()}catch(t){o.error(t)}})},isActive:xe,isDisabled:Le},ug={label:"Copy column",format:"long",action(o){o.editor.getEditorState().read(()=>{try{Gp()}catch(t){o.error(t)}})},isActive:xe,isDisabled:Le},fg={label:"Paste column before",format:"long",action(o){o.editor.update(()=>{try{Qp(o.editor)}catch(t){o.error(t)}})},isActive:xe,isDisabled:o=>Le(o)||Ad()},mg={label:"Paste column after",format:"long",action(o){o.editor.update(()=>{try{eg(o.editor)}catch(t){o.error(t)}})},isActive:xe,isDisabled:o=>Le(o)||Ad()},Bd={label:"Insert column before",icon:Mp,action(o){o.editor.update(()=>{Os(!1)})},isActive(){return!1}},Hd={label:"Insert column after",icon:Lp,action(o){o.editor.update(()=>{Os(!0)})},isActive(){return!1}},Fd={label:"Delete column",icon:yp,action(o){o.editor.update(()=>{ja()})},isActive(){return!1}},pg={label:"Cell properties",format:"long",action(o){o.editor.getEditorState().read(()=>{let t=V(C(),D);D(t)&&Ap(t,o)})},isActive:xe,isDisabled:Le},gg={label:"Merge cells",format:"long",action(o){o.editor.update(()=>{let t=C();q(t)&&Km(t)})},isActive:xe,isDisabled(o){return!q(o)}},hg={label:"Split cell",format:"long",action(o){o.editor.update(()=>{Ja()})},isActive:xe,isDisabled(o){let t=V(o,D);return t?!(t.getRowSpan()>1||t.getColSpan()>1):!0}};var Ng='';var xg='';var Eg='';var Tg='';var Cg='';var bg={label:"Undo",icon:Ng,action(o){o.editor.dispatchCommand(ho,void 0),o.manager.triggerFutureStateRefresh()},isActive(o){return!1},setup(o,t){t.toggleDisabled(!0),o.editor.registerCommand(Co,e=>(t.toggleDisabled(!e),!1),Ae)}},_g={label:"Redo",icon:xg,action(o){o.editor.dispatchCommand(No,void 0),o.manager.triggerFutureStateRefresh()},isActive(o){return!1},setup(o,t){t.toggleDisabled(!0),o.editor.registerCommand(To,e=>(t.toggleDisabled(!e),!1),Ae)}},yg={label:"Source code",icon:Eg,async action(o){let t=o.manager.createModal("source"),e=await qs(o.editor);t.show({source:e})},isActive(){return!1}},Sg={label:"Fullscreen",icon:Tg,async action(o,t){let e=o.containerDOM.classList.contains("fullscreen");o.containerDOM.classList.toggle("fullscreen",!e),o.containerDOM.closest("body").classList.toggle("editor-is-fullscreen",!e),t.setActiveState(!e)},isActive(o,t){return t.containerDOM.classList.contains("fullscreen")}},Lg={label:"About the editor",icon:Cg,async action(o,t){o.manager.createModal("about").show({})},isActive(o,t){return!1}};function sl(o,t){return{label:t,action(e){e.editor.update(()=>{Vn(n=>$a(n,o),()=>Jn(o))})},isActive(e){return de(e,n=>$a(n,o))}}}var Mg=sl("info","Info"),wg=sl("danger","Danger"),vg=sl("warning","Warning"),Dg=sl("success","Success"),MT=(o,t)=>or(o)&&o.getTag()===t;function ll(o,t){return{label:t,action(e){Ls(e.editor,o)},isActive(e){return de(e,n=>MT(n,o))}}}var Og=ll("h2","Large Header"),Ag=ll("h3","Medium Header"),Rg=ll("h4","Small Header"),kg=ll("h5","Tiny Header"),Ig={label:"Blockquote",action(o){ni(o.editor)},isActive(o){return de(o,Ss)}},$g={label:"Paragraph",action(o){oi(o.editor)},isActive(o){return de(o,Ge)}};var Pg='';var Bg='';var Hg='';var Fg=` +`;var Kg='';var Ug='';var zg='';var Wg='';var qg='';var Yg='';function En(o,t,e){return{label:o,icon:e,action(n){n.editor.dispatchCommand(Ee,t)},isActive(n){return uf(n,t)}}}var Kd=En("Bold","bold",Pg),Ud=En("Italic","italic",Bg),Zg=En("Underline","underline",Hg),Vg={label:"Text color",icon:Fg},Xg={label:"Highlight color",icon:Kg};function jg(o,t,e){o.editor.update(()=>{let n=C();n&&ha(n,{[t]:e||null})})}var Gg=(o,t)=>jg(t,"color",o),Jg=(o,t)=>jg(t,"background-color",o),Qg=En("Strikethrough","strikethrough",Ug),eh=En("Superscript","superscript",zg),th=En("Subscript","subscript",Wg),oh=En("Inline code","code",qg),nh={label:"Clear formatting",icon:Yg,action(o){o.editor.update(()=>{let t=C();for(let e of t?.getNodes()||[])L(e)&&(e.setFormat(0),e.setStyle(""))})},isActive(){return!1}};var rh='';var ih='';var sh='';var lh='';var ah='';var dh='';function al(o,t){let e=ae(o.editor),n=e?.getNodes()||[];if(n.length===1&&E(n[0])&&n[0].isInline()&&Yr(n[0])){n[0].setAlignment(t),Be(n[0]),o.manager.triggerFutureStateRefresh();return}let i=Pt(e).filter(a=>Yr(a)),l=i.every(a=>a.getAlignment()===t)?"":t;for(let a of i)a.setAlignment(l);o.manager.triggerFutureStateRefresh()}function ch(o,t){let e=ae(o.editor),n=Pt(e);for(let r of n)r.setDirection(t);o.manager.triggerFutureStateRefresh()}var uh={label:"Align left",icon:rh,action(o){o.editor.update(()=>al(o,"left"))},isActive(o){return Zr(o,"left")}},fh={label:"Align center",icon:ih,action(o){o.editor.update(()=>al(o,"center"))},isActive(o){return Zr(o,"center")}},mh={label:"Align right",icon:sh,action(o){o.editor.update(()=>al(o,"right"))},isActive(o){return Zr(o,"right")}},ph={label:"Justify",icon:lh,action(o){o.editor.update(()=>al(o,"justify"))},isActive(o){return Zr(o,"justify")}},gh={label:"Left to right",icon:ah,action(o){o.editor.update(()=>ch(o,"ltr"))},isActive(o){return ba(o,"ltr")}},hh={label:"Right to left",icon:dh,action(o){o.editor.update(()=>ch(o,"rtl"))},isActive(o){return ba(o,"rtl")}};var Nh='';var xh='';var Eh='';var Th='';var Ch='';function zd(o,t,e){return{label:o,icon:e,action(n){ri(n.editor,t)},isActive(n){return de(n,r=>W(r)&&r.getListType()===t)}}}var Wd=zd("Bullet list","bullet",Nh),qd=zd("Numbered list","number",xh),bh=zd("Task list","check",Eh),_h={label:"Increase indent",icon:Th,action(o){o.editor.update(()=>{fi(o.editor,40)})},isActive(){return!1}},yh={label:"Decrease indent",icon:Ch,action(o){o.editor.update(()=>{fi(o.editor,-40)})},isActive(){return!1}};var Sh='';var Lh='';var Mh='';var wh='';var vh='';var Dh='';var Oh='';var Ah='';var Rh=` +`;var kh='';var Ih='';var dl={label:"Insert/edit link",icon:Sh,action(o){o.editor.getEditorState().read(()=>{let t=V(C(),Ft);ws(t,o)})},isActive(o){return de(o,Ft)}},$h={label:"Remove link",icon:Lh,action(o){o.editor.update(()=>{let t=ae(o.editor),e=V(t,Ft);if(e){let n=e.getChildren().reverse();for(let r of n)e.insertAfter(r);e.remove(),n[n.length-1].selectStart(),o.manager.triggerFutureStateRefresh()}})},isActive(o){return!1}},Yd={label:"Insert/Edit Image",icon:Mh,action(o){o.editor.getEditorState().read(()=>{let t=ae(o.editor),e=V(t,Qe);if(e){Em(e,o);return}Ns(n=>{o.editor.update(()=>{let r=im(n);Ce([r]),r.select()})})})},isActive(o){return de(o,Qe)}},Ph={label:"Insert horizontal line",icon:wh,action(o){o.editor.update(()=>{tn(ad(),!1)})},isActive(o){return de(o,qm)}},Zd={label:"Insert code block",icon:vh,action(o){ii(o.editor)},isActive(o){return de(o,bs)}},Bh=Object.assign({},Zd,{label:"Edit code block",icon:Dh}),Hh={label:"Insert/edit drawing",icon:Oh,action(o){o.editor.getEditorState().read(()=>{let t=ae(o.editor),e=V(t,mo);e===null?o.editor.update(()=>{let n=ar();tn(n,!0),mi(o,n),n.selectStart()}):mi(o,e)})},isActive(o){return de(o,mo)}},Fh={label:"Drawing manager",action(o){mp(o)},isActive(){return!1}},Vd={label:"Insert/edit media",icon:Ih,action(o){o.editor.getEditorState().read(()=>{let t=C(),e=V(t,St);bm(e,o)})},isActive(o){return de(o,St)}},Kh={label:"Insert collapsible block",icon:Ah,action(o){o.editor.update(()=>{let t=C(),e=Wa(),r=(t?.getNodes()||[]).map(s=>s.getTopLevelElement()).filter(s=>s!==null),i=[...new Set(r)];e.setOpen(!0),i.length>0?i[0].insertAfter(e):F().append(e);for(let s of i)e.append(s)})},isActive(o){return de(o,ce)}},Uh={label:"Edit label",icon:kh,action(o){o.editor.getEditorState().read(()=>{let t=V(C(),ce);ce(t)&&vs(t,o)})},isActive(o){return!1}},zh={label:"Toggle open/closed",icon:Rh,action(o){o.editor.update(()=>{let t=V(C(),ce);ce(t)&&(t.setOpen(!t.getOpen()),o.manager.triggerLayoutUpdate())})},isActive(o){return!1}},Wh={label:"Unwrap",icon:rl,action(o){o.editor.update(()=>{let t=V(C(),ce);ce(t)&&(Qs(t),o.manager.triggerLayoutUpdate())})},isActive(o){return!1}};var qh=` +`;var cl=class extends oe{constructor(e,n){super([e]);p(this,"button");p(this,"dropdownButton");this.button=e,this.dropdownButton=new be({button:{label:"Menu",icon:qh},showOnHover:!1,direction:"vertical",showAside:!1},n),this.addChildren(this.dropdownButton)}buildDOM(){return y("div",{class:"editor-button-with-menu-container"},[this.button.getDOMElement(),this.dropdownButton.getDOMElement()])}};var Tn=class extends Re{buildDOM(){return y("div",{class:"editor-separator"})}};function Yh(o){let t=o.manager.getDefaultDirection()==="rtl";return new Jr("editor-toolbar-main",[new Ie("history",2,[new w(bg),new w(_g)]),new tl([new et(y("h2"),Og),new et(y("h3"),Ag),new et(y("h4"),Rg),new et(y("h5"),kg),new et(y("blockquote"),Ig),new et(y("p"),$g),new be({button:{label:"Callouts",format:"long"},showOnHover:!0,direction:"vertical"},[new et(y("p",{class:"callout info"}),Mg),new et(y("p",{class:"callout success"}),Dg),new et(y("p",{class:"callout warning"}),vg),new et(y("p",{class:"callout danger"}),wg)])]),new Ie("inline_formats",6,[new w(Kd),new w(Ud),new w(Zg),new be({button:new pi(Vg,"color")},[new Nn(Gg)]),new be({button:new pi(Xg,"background-color")},[new Nn(Jg)]),new w(Qg),new w(eh),new w(th),new w(oh),new w(nh)]),new Ie("alignment",6,[new w(uh),new w(fh),new w(mh),new w(ph),t?new w(gh):null,t?new w(hh):null].filter(e=>e!==null)),new Ie("lists",3,[new w(Wd),new w(qd),new w(bh),new w(yh),new w(_h)]),new Ie("inserts",4,[new w(dl),new be({button:tg,direction:"vertical",showAside:!1},[new be({button:{label:"Insert",format:"long"},showOnHover:!0,showAside:!0},[new nl]),new Tn,new be({button:{label:"Cell",format:"long"},direction:"vertical",showOnHover:!0},[new w(pg),new w(gg),new w(hg)]),new be({button:{label:"Row",format:"long"},direction:"vertical",showOnHover:!0},[new w({...Id,format:"long"}),new w({...$d,format:"long"}),new w({...Pd,format:"long"}),new w(ig),new Tn,new w(sg),new w(lg),new w(ag),new w(dg)]),new be({button:{label:"Column",format:"long"},direction:"vertical",showOnHover:!0},[new w({...Bd,format:"long"}),new w({...Hd,format:"long"}),new w({...Fd,format:"long"}),new Tn,new w(cg),new w(ug),new w(fg),new w(mg)]),new Tn,new w({...Rd,format:"long"}),new w(og),new w(ng),new w(rg)]),new w(Yd),new w(Ph),new w(Zd),new cl(new w(Hh),[new w(Fh)]),new w(Vd),new w(Kh)]),new Ie("meta",3,[new w(yg),new w(Lg),new w(Sg)])])}function Xd(o){return new Jr("editor-toolbar-main",[new Ie("formats",7,[new w(Kd),new w(Ud),new w(dl),new w(Wd),new w(qd)])])}var Ni={image:{selector:"img:not([drawio-diagram] img)",content:()=>[new w(Yd)]},media:{selector:".editor-media-wrap",content:()=>[new w(Vd)]},link:{selector:"a:not([data-mention-user-id])",content(){return[new w(dl),new w($h)]},displayTargetLocator(o){return o.querySelector("img")||o}},code:{selector:".editor-code-block-wrap",content:()=>[new w(Bh)]},table:{selector:"td,th",content(){return[new Ie("table",2,[new w(Rd),new w(kd)]),new Ie("table_row",3,[new w(Id),new w($d),new w(Pd)]),new Ie("table_column",3,[new w(Bd),new w(Hd),new w(Fd)])]},displayTargetLocator(o){return o.closest("table")}},details:{selector:"details",content(){return[new w(Uh),new w(zh),new w(Wh)]}}};var ul=class extends Re{constructor(e){super();p(this,"url","");this.url=e}buildDOM(){let e=y("div",{class:"editor-external-content"});return window.$http.get(this.url).then(n=>{typeof n.data=="string"&&(e.innerHTML=n.data)}),e}};var Zh={submitText:"Save",async action(o,t){return Po(t.editor,o.get("source")?.toString()||""),!0},fields:[{label:"Source",name:"source",type:"textarea"}]},Vh={submitText:"Close",async action(){return!0},fields:[{build(){return new ul("/help/wysiwyg")}}]};var xi={link:{title:"Insert/Edit Link",form:Cm},image:{title:"Insert/Edit Image",form:Tm},media:{title:"Insert/Edit Media",form:_m},source:{title:"Source code",form:Zh},cell_properties:{title:"Cell Properties",form:Rp},row_properties:{title:"Row Properties",form:Ip},table_properties:{title:"Table Properties",form:Pp},details:{title:"Edit collapsible block",form:ym},about:{title:"About the WYSIWYG Editor",form:Vh}};var Bo=class{constructor(t){p(this,"node",null);p(this,"context");p(this,"onDestroyCallbacks",[]);this.context=t}getNode(){if(!this.node)throw new Error("Attempted to get use node without it being set");return this.node}setNode(t){this.node=t}onDestroy(t){this.onDestroyCallbacks.push(t)}teardown(){for(let t of this.onDestroyCallbacks)t()}};var fl=class extends Bo{constructor(){super(...arguments);p(this,"completedSetup",!1);p(this,"latestCode","");p(this,"latestLanguage","");p(this,"editor",null)}setup(e){let n=this.getNode(),r=e.querySelector("pre");if(!r)return;r&&(r.hidden=!0),this.latestCode=n.__code,this.latestLanguage=n.__language;let s=this.latestCode.split(` +`).length*19.2+18+24;e.style.height=`${s}px`;let l=Date.now();e.addEventListener("click",u=>{requestAnimationFrame(()=>{this.context.editor.update(()=>{Be(this.getNode())})})}),e.addEventListener("dblclick",u=>{this.context.editor.getEditorState().read(()=>{ei(this.context.editor,this.getNode())})});let a=u=>{e.classList.toggle("selected",ts(u,n))};this.context.manager.onSelectionChange(a),this.onDestroy(()=>{this.context.manager.offSelectionChange(a)});let d=u=>{this.editor=u.wysiwygView(e,document,this.latestCode,this.latestLanguage),setTimeout(()=>{e.style.height=""},12)};window.importVersioned("code").then(u=>{let m=Date.now()-l<20?20:0;setTimeout(()=>d(u),m)}),this.completedSetup=!0}update(){let e=this.getNode(),n=e.getCode(),r=e.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(e){this.completedSetup?this.update():this.setup(e)}};var ml=class extends Bo{constructor(){super(...arguments);p(this,"completedSetup",!1)}setup(e){let n=this.getNode();e.classList.add("editor-diagram"),this.context.editor.registerCommand(Wt,i=>e.contains(i.target)?(this.context.editor.update(()=>{Be(this.getNode())}),!0):!1,lo),e.addEventListener("dblclick",i=>{this.context.editor.getEditorState().read(()=>{mi(this.context,this.getNode())})});let r=i=>{e.classList.toggle("selected",ts(i,n))};this.context.manager.onSelectionChange(r),this.onDestroy(()=>{this.context.manager.offSelectionChange(r)}),this.completedSetup=!0}update(){}render(e){this.completedSetup?this.update():this.setup(e)}};function lC(o){return H(o)||Qe(o)||St(o)||mo(o)||K(o)||ce(o)}function aC(o){if(o.target instanceof HTMLElement){let t=o.target.closest("details");if(t){let e=G(t);if(ce(e))return e}}return F()}function dC(o,t){let e=aC(t),n=e.getLastChild();if(!n||!lC(n))return!1;let r=o.editor.getElementByKey(n.getKey());if(!r)return!1;let i=r.getBoundingClientRect();return t.clientY>i.bottom?(o.editor.update(()=>{let l=I();e.append(l),l.select()}),!0):!1}function Xh(o){let t=o.editor.registerCommand(Wt,e=>(dC(o,e),!1),Ae);return()=>{t()}}var jd=new Set;function cC(o){for(let n of jd)n.classList.remove("selected"),jd.delete(n);let e=C()?.getNodes()||[];if(e.length===1&&ce(e[0])){let n=o.editor.getElementByKey(e[0].getKey());n&&(n.classList.add("selected"),jd.add(n))}return!1}function jh(o){let t=o.editor.registerCommand(_e,()=>(cC(o),!1),Ae);return()=>{t()}}var Cn,Ei,Gd=class{constructor(t,e){vt(this,Cn);vt(this,Ei,!1);po(this,Cn,new w({label:t.label||"",icon:t.icon||"",action:()=>{t.action()},isActive:()=>Me(this,Ei)})),Me(this,Cn).setContext(e)}setActive(t=!0){po(this,Ei,t),Me(this,Cn).setActiveState(t)}_getOriginalModel(){return Me(this,Cn)}};Cn=new WeakMap,Ei=new WeakMap;var Ti,Jd=class{constructor(t){vt(this,Ti);po(this,Ti,t)}getSections(){return Me(this,Ti).getChildren().filter(e=>e instanceof Ie).map(e=>new Qd(e))}};Ti=new WeakMap;var bn,Qd=class{constructor(t){vt(this,bn);po(this,bn,t)}getLabel(){return Me(this,bn).getLabel()}addButton(t,e=-1){Me(this,bn).addChild(t._getOriginalModel(),e),Me(this,bn).rebuildDOM()}};bn=new WeakMap;var fr,pl=class{constructor(t){vt(this,fr);po(this,fr,t)}createButton(t){return new Gd(t,Me(this,fr))}getMainToolbar(){let t=Me(this,fr).manager.getToolbar();return t?new Jd(t):null}};fr=new WeakMap;var _n,gl=class{constructor(t){vt(this,_n);po(this,_n,t)}insertHtml(t,e="selection"){let n=["start","end","selection"];if(!n.includes(e))throw new Error(`Invalid position: ${e}. Valid positions are: ${n.join(", ")}`);e==="start"?zs(Me(this,_n).editor,t):e==="end"?Us(Me(this,_n).editor,t):Ws(Me(this,_n).editor,t)}};_n=new WeakMap;var mr=class{constructor(t){p(this,"ui");p(this,"content");this.ui=new pl(t),this.content=new gl(t)}};function pr(o){return o instanceof HTMLElement}function Gh(o){o.innerHTML='
    '}var Ho,ec,tc,hl=class{constructor(t,e=null,n=null){vt(this,Ho);p(this,"containers");p(this,"onEscape");p(this,"onEnter");this.containers=[t],this.onEscape=e,this.onEnter=n,t.addEventListener("keydown",hr(this,Ho,ec).bind(this))}shareHandlingToEl(t){this.containers.push(t),t.addEventListener("keydown",hr(this,Ho,ec).bind(this))}focusNext(){let t=hr(this,Ho,tc).call(this),e=document.activeElement,r=(pr(e)?t.indexOf(e):-1)+1;r>=t.length&&(r=0),t[r].focus()}focusPrevious(){let t=hr(this,Ho,tc).call(this),e=document.activeElement,r=(pr(e)?t.indexOf(e):-1)-1;r<0&&(r=t.length-1),t[r].focus()}};Ho=new WeakSet,ec=function(t){pr(t.target)&&t.target.matches("input")&&(t.key==="ArrowRight"||t.key==="ArrowLeft")||(t.key==="ArrowDown"||t.key==="ArrowRight"?(this.focusNext(),t.preventDefault()):t.key==="ArrowUp"||t.key==="ArrowLeft"?(this.focusPrevious(),t.preventDefault()):t.key==="Escape"?this.onEscape?this.onEscape(t):pr(document.activeElement)&&document.activeElement.blur():t.key==="Enter"&&this.onEnter&&this.onEnter(t))},tc=function(){let t=[],e='[tabindex]:not([tabindex="-1"]),[href],button:not([tabindex="-1"],[disabled]),input:not([type=hidden])';for(let n of this.containers){let r=[...n.querySelectorAll(e)].filter(i=>pr(i));t.push(...r)}return t};function uC(o){return t=>{let e=t.target.closest("a[data-id]");if(!e)return;let n=Number(e.dataset.id||"0"),r=e.dataset.name||"",i=e.dataset.slug||"";o(n,r,i),t.preventDefault()}}function fC(o,t,e,n){t.addEventListener("keydown",i=>{i.key==="Escape"&&n()},{signal:e.signal});let r=t.querySelector("input");r.addEventListener("keydown",i=>{i.key==="Backspace"&&r.value===""&&(n(),i.preventDefault(),i.stopPropagation())},{signal:e.signal}),o.editorDOM.addEventListener("click",i=>{n()},{signal:e.signal}),o.editorDOM.addEventListener("keydown",i=>{n()},{signal:e.signal})}function mC(o){let t=new Map,e=async i=>{for(let d of[...o.children])d.remove();let s="";if(t.has(i))s=t.get(i)||"";else{let d=y("div",{class:"flex-container-row items-center dropdown-search-item"});Gh(d),o.appendChild(d),s=(await window.$http.get(`/search/users/mention?search=${i}`)).data,t.set(i,s),d.remove()}let a=[...es(s).body.children];for(let d of a){let u=window.document.adoptNode(d);o.appendChild(u)}};e("");let n=o.parentElement?.querySelector("input"),r=Qf(e,200,!1);n.addEventListener("input",()=>{let i=n.value;r(i)})}function pC(o,t){let e=y("input",{type:"text"}),n=y("div",{class:"dropdown-search-list"}),r=y("div");r.innerHTML=xs;let i=r.children[0];i.classList.add("svg-icon");let s=y("div",{class:"dropdown-search-dropdown compact card"},[y("div",{class:"dropdown-search-search"},[i,e]),n]);o.containerDOM.appendChild(s),s.style.display="block",s.style.top="0",s.style.left="0";let l=t.getBoundingClientRect(),a=s.getBoundingClientRect();return s.style.top=`${l.bottom-a.top+3}px`,s.style.left=`${l.left-a.left}px`,e.focus(),s}var gr=class extends Bo{constructor(){super(...arguments);p(this,"abortController",null);p(this,"dropdownContainer",null);p(this,"mentionElement",null)}setup(e){this.mentionElement=e,e.addEventListener("click",n=>{this.showSelection(),n.preventDefault(),n.stopPropagation()})}showSelection(){!this.mentionElement||this.dropdownContainer||(this.hideSelection(),this.abortController=new AbortController,this.dropdownContainer=pC(this.context,this.mentionElement),mC(this.dropdownContainer.querySelector(".dropdown-search-list")),this.dropdownContainer.addEventListener("click",uC((e,n,r)=>{this.context.editor.update(()=>{let i=this.getNode();this.hideSelection(),i.setUserDetails(e,n,r),i.selectNext()})}),{signal:this.abortController.signal}),fC(this.context,this.dropdownContainer,this.abortController,()=>{this.getNode().hasUserSet()?this.hideSelection():this.revertMention()}),new hl(this.dropdownContainer))}hideSelection(){this.abortController?.abort(),this.dropdownContainer?.remove(),this.abortController=null,this.dropdownContainer=null,this.context.manager.focus()}revertMention(){this.hideSelection(),this.context.editor.update(()=>{let e=z("@"),n=this.getNode().getPreviousSibling();this.getNode().replace(e),requestAnimationFrame(()=>{this.context.editor.update(()=>{e.isAttached()?e.selectEnd():n?.isAttached()&&n?.selectEnd()})})})}render(e){this.setup(e)}};function gC(o,t){let e=t.getNodes()[0],n=t.getStartEndPoints();if(!n)return;let r=n[0].offset,i=r===0,s=e.getTextContent().charAt(r-1)===" ";if(!i&&!s)return;let l=e.splitText(r),a=l[0],d=l[i?0:1],u=dd(0,"","");a.insertAfter(u),d.spliceText(0,1,"",!1),Be(u),requestAnimationFrame(()=>{let m=o.manager.getDecoratorByNodeKey(u.getKey());m instanceof gr&&m.showSelection()})}function hC(o,t){let e=C()?.getNodes()||[];if(e.length===1&&Ym(e[0])){let n=e[0];return o.manager.getDecoratorByNodeKey(n.getKey()).showSelection(),t.preventDefault(),t.stopPropagation(),!0}return!1}function Jh(o){let t=o.editor,e=t.registerCommand(_i,function(r){let i=C();return _(i)&&i.isCollapsed()&&window.setTimeout(()=>{t.update(()=>{gC(o,i)})},1),!1},lo),n=t.registerCommand(we,function(r){return hC(o,r)},lo);return()=>{e(),n()}}var oc={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"}};function GF(o,t,e={}){let n=Gr({namespace:"BookStackPageEditor",nodes:Zm(),onError:console.error,theme:oc}),r=Ks(o,n,{...e,editorClass:"page-content"});n.setRootElement(r.editorDOM),Et(ms(n),ss(n,ls(),300),js(r),Np(r),Xh(r),jh(r),Gm(n,r.scrollDOM),np(n),op(n,r.editorDOM),tp(r),lp(r),el(n)),r.manager.setToolbar(Yh(r));for(let s of Object.keys(Ni))r.manager.registerContextToolbar(s,Ni[s]);for(let s of Object.keys(xi))r.manager.registerModal(s,xi[s]);r.manager.registerDecoratorType("code",fl),r.manager.registerDecoratorType("diagram",ml),Jm(n),Po(n,t);let i=document.getElementById("lexical-debug");return i&&(i.hidden=!0,n.registerUpdateListener(({dirtyElements:s,dirtyLeaves:l,editorState:a,prevEditorState:d})=>{i.textContent=JSON.stringify(a.toJSON(),null,2)})),window.debugEditorState=()=>n.getEditorState().toJSON(),Xm(r),window.$events.emitPublic(o,"editor-wysiwyg::post-init",{usage:"page-editor",api:new mr(r)}),new Ci(r)}function JF(o,t,e={}){let n=Gr({namespace:"BookStackBasicEditor",nodes:cd(),onError:console.error,theme:oc}),r=Ks(o,n,e);n.setRootElement(r.editorDOM);let i=Et(ms(n),ss(n,ls(),300),js(r),el(n));return r.manager.setToolbar(Xd(r)),r.manager.registerContextToolbar("link",Ni.link),r.manager.registerModal("link",xi.link),r.manager.onTeardown(i),Po(n,t),window.$events.emitPublic(o,"editor-wysiwyg::post-init",{usage:"description-editor",api:new mr(r)}),new Ci(r)}function QF(o,t,e={}){let n=Gr({namespace:"BookStackCommentEditor",nodes:Vm(),onError:console.error,theme:oc}),r=Ks(o,n,e);n.setRootElement(r.editorDOM);let i=Et(ms(n),ss(n,ls(),300),js(r),el(n),Jh(r));return r.manager.setToolbar(Xd(r)),r.manager.registerContextToolbar("link",Ni.link),r.manager.registerModal("link",xi.link),r.manager.onTeardown(i),r.manager.registerDecoratorType("mention",gr),Po(n,t),window.$events.emitPublic(o,"editor-wysiwyg::post-init",{usage:"comment-editor",api:new mr(r)}),new Ci(r)}var Ci=class{constructor(t){p(this,"context");p(this,"onChangeListeners",[]);p(this,"editorListenerTeardown",null);this.context=t}async getContentAsHtml(){return await qs(this.context.editor)}onChange(t){this.onChangeListeners.push(t),this.startListeningToChanges()}focus(){Ys(this.context.editor)}remove(){this.context.manager.teardown(),this.context.containerDOM.remove(),this.editorListenerTeardown&&this.editorListenerTeardown()}startListeningToChanges(){this.editorListenerTeardown||(this.editorListenerTeardown=this.context.editor.registerUpdateListener(()=>{for(let t of this.onChangeListeners)t()}))}};export{Ci as SimpleWysiwygEditorInterface,JF as createBasicEditorInstance,QF as createCommentEditorInstance,GF as createPageEditorInstance}; //# sourceMappingURL=wysiwyg.js.map diff --git a/version b/version index bbbc9d2ce..d9a3208ad 100644 --- a/version +++ b/version @@ -1 +1 @@ -v26.03.1 +v26.03.2