| similarity index 99% |
| rename from internal/docs/static/editor.6029d6f8d990c8a4.js |
| rename to internal/docs/static/editor.0c0322ca56426314.js |
| index 6817228..9f16e28 100644 |
| --- a/internal/docs/static/editor.6029d6f8d990c8a4.js |
| +++ b/internal/docs/static/editor.0c0322ca56426314.js |
| @@ -11,4 +11,4 @@ ${t.toString()}`)},so=class{constructor(e){this.patterns=[],this.$state=e}if(e,t |
| |
| `);return{dom:c,text:u,slice:e}}function Wf(n,e,t,r,i){let s=i.parent.type.spec.code,o,l;if(!t&&!e)return null;let c=!!e&&(r||s||!t);if(c){if(n.someProp("transformPastedText",u=>{e=u(e,s||r,n)}),s)return l=new b(x.from(n.state.schema.text(e.replace(/\r\n?/g,` |
| `))),0,0),n.someProp("transformPasted",u=>{l=u(l,n,!0)}),l;let f=n.someProp("clipboardTextParser",u=>u(e,i,r,n));if(f)l=f;else{let u=i.marks(),{schema:d}=n.state,p=Bt.fromSchema(d);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(d.text(m,u)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),o=jg(t),Pr&&Kg(o);let a=o&&o.querySelector("[data-pm-slice]"),h=a&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(a.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let f=+h[3];f>0;f--){let u=o.firstChild;for(;u&&u.nodeType!=1;)u=u.nextSibling;if(!u)break;o=u}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Sr.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||h),context:i,ruleFromNode(u){return u.nodeName=="BR"&&!u.nextSibling&&u.parentNode&&!qg.test(u.parentNode.nodeName)?{ignore:!0}:null}})),h)l=Yg(xf(l,+h[1],+h[2]),h[4]);else if(l=b.maxOpen(Jg(l.content,i),!0),l.openStart||l.openEnd){let f=0,u=0;for(let d=l.content.firstChild;f<l.openStart&&!d.type.spec.isolating;f++,d=d.firstChild);for(let d=l.content.lastChild;u<l.openEnd&&!d.type.spec.isolating;u++,d=d.lastChild);l=xf(l,f,u)}return n.someProp("transformPasted",f=>{l=f(l,n,c)}),l}var qg=/^(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)$/i;function Jg(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(n.forEach(l=>{if(!o)return;let c=i.findWrapping(l.type),a;if(!c)return o=null;if(a=o.length&&s.length&&Kf(c,s,l,o[o.length-1],0))o[o.length-1]=a;else{o.length&&(o[o.length-1]=Yf(o[o.length-1],s.length));let h=jf(l,c);o.push(h),i=i.matchType(h.type),s=c}}),o)return x.from(o)}return n}function jf(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,x.from(n));return n}function Kf(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=Kf(n,e,t,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(x.from(jf(t,n,i+1))))}}function Yf(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Yf(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(x.empty,!0);return n.copy(t.append(r))}function Al(n,e,t,r,i,s){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(s=0),i<r-1&&(l=Al(l,e,t,r,i+1,s)),i>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(x.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function xf(n,e,t){return e<n.openStart&&(n=new b(Al(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new b(Al(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}var Hf={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function Gf(){return document.implementation.createHTMLDocument("title")}var _r=null;function Wg(n){let e=window.trustedTypes;if(!e)return n;if(!_r){if(_r=e.defaultPolicy)try{return _r.createHTML(n)}catch{}_r=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})}return _r.createHTML(n)}function jg(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Gf(),r=t.body,i=/<([a-z][^>\s]+)/i.exec(n),s;if((s=i&&Hf[i[1].toLowerCase()])&&(n=s.map(o=>"<"+o+">").join("")+n+s.map(o=>"</"+o+">").reverse().join("")),r.innerHTML=Wg(n),s)for(let o=0;o<s.length;o++)r=r.querySelector(s[o])||r;for(let o=0;o<t.styleSheets.length;o++){let l=t.styleSheets[o];for(let c=0;c<l.rules.length;c++){let a=l.rules[c];if(a instanceof CSSStyleRule){let h=r.querySelectorAll(a.selectorText);for(let f=0;f<h.length;f++)h[f].style.cssText+=a.style.cssText}}}return r}function Kg(n){let e=n.querySelectorAll(Q?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Yg(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:i,openStart:s,openEnd:o}=n;for(let l=r.length-2;l>=0;l-=2){let c=t.nodes[r[l]];if(!c||c.hasRequiredAttrs())break;try{c.checkAttrs(r[l+1])}catch{break}i=x.from(c.create(r[l+1],i)),s++,o++}return new b(i,s,o)}var le={},ce={},Hg={touchstart:!0,touchmove:!0},Nl=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Gg(n){for(let e in le){let t=le[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Zg(n,r)&&!zl(n,r)&&(n.editable||!(r.type in ce))&&t(n,r)},Hg[e]?{passive:!0}:void 0)}re&&n.dom.addEventListener("input",()=>null),Il(n)}function Ze(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Xg(n){n.input.mouseDown&&n.input.mouseDown.done(),n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Il(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>zl(n,r))})}function zl(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Zg(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Qg(n,e){!zl(n,e)&&le[e.type]&&(n.editable||!(e.type in ce))&&le[e.type](n,e)}ce.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Qf(n)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Xe&&Q&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),vn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,Ft(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||$g(n,t)?t.preventDefault():Ze(n,"key")};ce.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};ce.keypress=(n,e)=>{let t=e;if(Qf(n)||!t.charCode||t.ctrlKey&&!t.altKey||De&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof I)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode),s=()=>n.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,i,s))&&n.dispatch(s()),t.preventDefault()}};function zr(n){return{left:n.clientX,top:n.clientY}}function ey(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function $l(n,e,t,r,i){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(n.someProp(e,l=>o>s.depth?l(n,t,s.nodeAfter,s.before(o),i,!0):l(n,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function $r(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);t=="pointer"&&r.setMeta("pointer",!0),n.dispatch(r)}function ty(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&S.isSelectable(r)?($r(n,new S(t),"pointer"),!0):!1}function ny(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof S&&(r=t.node);let s=n.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(S.isSelectable(l)){r&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?($r(n,S.create(n.state.doc,i),"pointer"),!0):!1}function ry(n,e,t,r,i){return $l(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?ny(n,t):ty(n,t))}function iy(n,e,t,r){return $l(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function sy(n,e,t,r){return $l(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||oy(n,t,r)}function oy(n,e,t){if(t.button!=0)return!1;let r=Xf(n,e,!0),i=n.state.doc;return r?($r(n,r,"pointer"),r instanceof I&&i.eq(n.state.doc)&&(n.input.mouseDown=new Rl(n,r)),!0):!1}function Xf(n,e,t){let r=n.state.doc;if(e==-1)return r.inlineContent?I.create(r,0,r.content.size):null;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)return I.create(r,l+1,l+1+o.content.size);if(t&&S.isSelectable(o))return S.create(r,l)}return null}function ql(n){return xs(n)}var Zf=De?"metaKey":"ctrlKey";le.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=ql(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&ey(t,n.input.lastClick)&&!t[Zf]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s,button:t.button},n.input.mouseDown&&n.input.mouseDown.done();let o=n.posAtCoords(zr(t));o&&(s=="singleClick"?n.input.mouseDown=new _l(n,o,t,!!r):(s=="doubleClick"?iy:sy)(n,o.pos,o.inside,t)?t.preventDefault():Ze(n,"pointer"))};var ys=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},_l=class extends ys{constructor(e,t,r,i){super(e),this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[Zf],this.allowDefault=r.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let h=e.state.doc.resolve(t.pos);s=h.parent,o=h.depth?h.before():0}let l=i?null:r.target,c=l?e.docView.nearestDesc(l,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:a}=e.state;r.button==0&&(s.type.spec.draggable&&s.type.spec.selectable!==!1||a instanceof S&&a.from<=o&&a.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ee&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),Ze(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||Qe(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(zr(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ze(this.view,"pointer"):ry(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||re&&this.mightDrag&&!this.mightDrag.node.isAtom||Q&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?($r(this.view,E.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Ze(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ze(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},Rl=class extends ys{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),Ze(this.view,"pointer");let t=this.view.posAtCoords(zr(e)),r=t&&Xf(this.view,t.inside,!1);if(!r)return;let{doc:i}=this.view.state,s=this.startSelection,[o,l]=r.from<s.from?[s.to,r.from]:[s.from,r.to];$r(this.view,I.create(i,o,l),"pointer")}};le.touchstart=n=>{n.input.lastTouch=Date.now(),ql(n),Ze(n,"pointer")};le.touchmove=n=>{n.input.lastTouch=Date.now(),Ze(n,"pointer")};le.contextmenu=n=>ql(n);function Qf(n,e){return n.composing?!0:re&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var ly=Xe?5e3:-1;ce.compositionstart=ce.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof I&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Q&&If&&cy(n)))n.markCursor=n.state.storedMarks||t.marks(),xs(n,!0),n.markCursor=null;else if(xs(n,!e.selection.empty),Ee&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}n.input.composing=!0}eu(n,ly)};function cy(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}ce.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now(),n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,eu(n,20))};function eu(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>xs(n),e))}function tu(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function ay(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=og(e.focusNode,e.focusOffset),r=lg(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return r}}return t||r}function xs(n,e=!1){if(!(Xe&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),tu(n),e||n.docView&&n.docView.dirty){let t=Ll(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function hy(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}var Vr=ge&&ut<15||vn&&fg<604;le.copy=ce.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=Vr?null:t.clipboardData,o=r.content(),{dom:l,text:c}=Pl(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",c)):hy(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function fy(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function uy(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Ur(n,r.value,null,i,e):Ur(n,r.textContent,r.innerHTML,i,e)},50)}function Ur(n,e,t,r,i){let s=Wf(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",c=>c(n,i,s||b.empty)))return!0;if(!s)return!1;let o=fy(s),l=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function nu(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}ce.paste=(n,e)=>{let t=e;if(n.composing&&!Xe)return;let r=Vr?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Ur(n,nu(r),r.getData("text/html"),i,t)?t.preventDefault():uy(n,t)};var bs=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},dy=De?"altKey":"ctrlKey";function ru(n,e){let t;return n.someProp("dragCopies",r=>{t=t||r(e)}),t!=null?!t:!e[dy]}le.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,s=i.empty?null:n.posAtCoords(zr(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof S?i.to-1:i.to))){if(r&&r.mightDrag)o=S.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(o=S.create(n.state.doc,f.posBefore))}}let l=(o||n.state.selection).content(),{dom:c,text:a,slice:h}=Pl(n,l);(!t.dataTransfer.files.length||!Q||Nf>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Vr?"Text":"text/html",c.innerHTML),t.dataTransfer.effectAllowed="copyMove",Vr||t.dataTransfer.setData("text/plain",a),n.dragging=new bs(h,ru(n,t),o)};le.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};ce.dragover=ce.dragenter=(n,e)=>e.preventDefault();ce.drop=(n,e)=>{try{py(n,e,n.dragging)}finally{n.dragging=null}};function py(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(zr(e));if(!r)return;let i=n.state.doc.resolve(r.pos),s=t&&t.slice;s?n.someProp("transformPasted",d=>{s=d(s,n,!1)}):s=Wf(n,nu(e.dataTransfer),Vr?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(t&&ru(n,e));if(n.someProp("handleDrop",d=>d(n,e,s||b.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?Fh(n.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let c=n.state.tr;if(o){let{node:d}=t;d?d.replace(c):c.deleteSelection()}let a=c.mapping.map(l),h=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,f=c.doc;if(h?c.replaceRangeWith(a,a,s.content.firstChild):c.replaceRange(a,a,s),c.doc.eq(f))return;let u=c.doc.resolve(a);if(h&&S.isSelectable(s.content.firstChild)&&u.nodeAfter&&u.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new S(u));else{let d=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((p,m,g,y)=>d=y),c.setSelection(Fl(n,u,c.doc.resolve(d)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))}le.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Qe(n)},20))};le.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};le.beforeinput=(n,e)=>{if(Xe&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Ft(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in ce)le[n]=ce[n];function vr(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}var ws=class n{constructor(e,t){this.toDOM=e,this.spec=t||Jt,this.side=this.spec.side||0}map(e,t,r,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new pt(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&vr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},qt=class n{constructor(e,t){this.attrs=e,this.spec=t||Jt}map(e,t,r,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new pt(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof n&&vr(this.attrs,e.attrs)&&vr(this.spec,e.spec)}static is(e){return e.type instanceof n}destroy(){}},Bl=class n{constructor(e,t){this.attrs=e,this.spec=t||Jt}map(e,t,r,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=s.pos?null:new pt(s.pos-r,o.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(r)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof n&&vr(this.attrs,e.attrs)&&vr(this.spec,e.spec)}destroy(){}},pt=class n{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new n(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new n(e,e,new ws(t,r))}static inline(e,t,r,i){return new n(e,t,new qt(r,i))}static node(e,t,r,i){return new n(e,t,new Bl(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof qt}get widget(){return this.type instanceof ws}},Vn=[],Jt={},Ae=class n{constructor(e,t){this.local=e.length?e:Vn,this.children=t.length?t:Vn}static create(e,t){return t.length?Ss(t,e,0,Jt):ne}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,r,i+l,s)}}map(e,t,r){return this==ne||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Jt)}mapInner(e,t,r,i,s){let o;for(let l=0;l<this.local.length;l++){let c=this.local[l].map(e,r,i);c&&c.type.valid(t,c)?(o||(o=[])).push(c):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?my(this.children,o||[],e,t,r,i,s):o?new n(o.sort(Wt),Vn):ne}add(e,t){return t.length?this==ne?n.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,s=0;e.forEach((l,c)=>{let a=c+r,h;if(h=su(t,l,a)){for(i||(i=this.children.slice());s<i.length&&i[s]<c;)s+=3;i[s]==c?i[s+2]=i[s+2].addInner(l,h,a+1):i.splice(s,0,c,c+l.nodeSize,Ss(h,l,a+1,Jt)),s+=3}});let o=iu(s?ou(t):t,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new n(o.length?this.local.concat(o).sort(Wt):this.local,i||this.children)}remove(e){return e.length==0||this==ne?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let o,l=r[s]+t,c=r[s+1]+t;for(let h=0,f;h<e.length;h++)(f=e[h])&&f.from>l&&f.to<c&&(e[h]=null,(o||(o=[])).push(f));if(!o)continue;r==this.children&&(r=this.children.slice());let a=r[s+2].removeInner(o,l+1);a!=ne?r[s+2]=a:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new n(i,r):ne}forChild(e,t){if(this==ne)return this;if(t.isLeaf)return n.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<o&&c.to>s&&c.type instanceof qt){let a=Math.max(s,c.from)-s,h=Math.min(o,c.to)-s;a<h&&(i||(i=[])).push(c.copy(a,h))}}if(i){let l=new n(i.sort(Wt),Vn);return r?new ks([l,r]):l}return r||ne}eq(e){if(this==e)return!0;if(!(e instanceof n)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Jl(this.localsInner(e))}localsInner(e){if(this==ne)return Vn;if(e.inlineContent||!this.local.some(qt.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof qt||t.push(this.local[r]);return t}forEachSet(e){e(this)}};Ae.empty=new Ae([],[]);Ae.removeOverlap=Jl;var ne=Ae.empty,ks=class n{constructor(e){this.members=e}map(e,t){let r=this.members.map(i=>i.map(e,t,Jt));return n.from(r)}forChild(e,t){if(t.isLeaf)return Ae.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=ne&&(s instanceof n?r=r.concat(s.members):r.push(s))}return n.from(r)}eq(e){if(!(e instanceof n)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?Jl(r?t:t.sort(Wt)):Vn}static from(e){switch(e.length){case 0:return ne;case 1:return e[0];default:return new n(e.every(t=>t instanceof Ae)?e:e.reduce((t,r)=>t.concat(r instanceof Ae?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function my(n,e,t,r,i,s,o){let l=n.slice();for(let a=0,h=s;a<t.maps.length;a++){let f=0;t.maps[a].forEach((u,d,p,m)=>{let g=m-p-(d-u);for(let y=0;y<l.length;y+=3){let k=l[y+1];if(k<0||u>k+h-f)continue;let w=l[y]+h-f;d>=w?l[y+1]=u<=w?-2:-1:u>=h&&g&&(l[y]+=g,l[y+1]+=g)}f+=g}),h=t.maps[a].map(h,-1)}let c=!1;for(let a=0;a<l.length;a+=3)if(l[a+1]<0){if(l[a+1]==-2){c=!0,l[a+1]=-1;continue}let h=t.map(n[a]+s),f=h-i;if(f<0||f>=r.content.size){c=!0;continue}let u=t.map(n[a+1]+s,-1),d=u-i,{index:p,offset:m}=r.content.findIndex(f),g=r.maybeChild(p);if(g&&m==f&&m+g.nodeSize==d){let y=l[a+2].mapInner(t,g,h+1,n[a]+s+1,o);y!=ne?(l[a]=f,l[a+1]=d,l[a+2]=y):(l[a+1]=-2,c=!0)}else c=!0}if(c){let a=gy(l,n,e,t,i,s,o),h=Ss(a,r,0,o);e=h.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,u=0;f<h.children.length;f+=3){let d=h.children[f];for(;u<l.length&&l[u]<d;)u+=3;l.splice(u,0,h.children[f],h.children[f+1],h.children[f+2])}}return new Ae(e.sort(Wt),l)}function iu(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let i=n[r];t.push(new pt(i.from+e,i.to+e,i.type))}return t}function gy(n,e,t,r,i,s,o){function l(c,a){for(let h=0;h<c.local.length;h++){let f=c.local[h].map(r,i,a);f?t.push(f):o.onRemove&&o.onRemove(c.local[h].spec)}for(let h=0;h<c.children.length;h+=3)l(c.children[h+2],c.children[h]+a+1)}for(let c=0;c<n.length;c+=3)n[c+1]==-1&&l(n[c+2],e[c]+s+1);return t}function su(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let s=0,o;s<n.length;s++)(o=n[s])&&o.from>t&&o.to<r&&((i||(i=[])).push(o),n[s]=null);return i}function ou(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Ss(n,e,t,r){let i=[],s=!1;e.forEach((l,c)=>{let a=su(n,l,c+t);if(a){s=!0;let h=Ss(a,l,t+c+1,r);h!=ne&&i.push(c,c+l.nodeSize,h)}});let o=iu(s?ou(n):n,-t).sort(Wt);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new Ae(o,i):ne}function Wt(n,e){return n.from-e.from||n.to-e.to}function Jl(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[i]=s.copy(s.from,r.to),bf(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),bf(e,i,r.copy(s.from,r.to)));break}}}return e}function bf(n,e,t){for(;e<n.length&&Wt(t,n[e])>0;)e++;n.splice(e,0,t)}function ml(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=ne&&e.push(r)}),n.cursorWrapper&&e.push(Ae.create(n.state.doc,[n.cursorWrapper.deco])),ks.from(e)}var yy={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},xy=ge&&ut<=11,Vl=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},Ul=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Vl,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);ge&&ut<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():re&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),xy&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,yy)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(uf(this.view)){if(this.suppressingSelectionUpdates)return Qe(this.view);if(ge&&ut<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&jt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let s=e.focusNode;s;s=Un(s))t.add(s);for(let s=e.anchorNode;s;s=Un(s))if(t.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&uf(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,l=!1,c=[];if(e.editable)for(let h=0;h<t.length;h++){let f=this.registerMutation(t[h],c);f&&(s=s<0?f.from:Math.min(f.from,s),o=o<0?f.to:Math.max(f.to,o),f.typeOver&&(l=!0))}if(c.some(h=>h.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||Q&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(h=>h.type=="childList"&&h.removedNodes.length))){for(let h of c)if(h.nodeName=="BR"&&h.parentNode){let f=h.nextSibling;for(;f&&f.nodeType==1;){if(f.contentEditable=="false"){h.parentNode.removeChild(h);break}f=f.firstChild}}}else if(Ee&&c.length){let h=c.filter(f=>f.nodeName=="BR");if(h.length==2){let[f,u]=h;f.parentNode&&f.parentNode.parentNode==u.parentNode?u.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let u of h){let d=u.parentNode;d&&d.nodeName=="LI"&&(!f||ky(e,f)!=d)&&u.remove()}}}let a=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Cs(r)&&(a=Ll(e))&&a.eq(E.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Qe(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),by(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Sy(e,c)),this.handleDOMChange(s,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Qe(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let h=0;h<e.addedNodes.length;h++){let f=e.addedNodes[h];t.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(ge&&ut<=11&&e.addedNodes.length)for(let h=0;h<e.addedNodes.length;h++){let{previousSibling:f,nextSibling:u}=e.addedNodes[h];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u)}let o=i&&i.parentNode==e.target?Z(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),c=s&&s.parentNode==e.target?Z(s):e.target.childNodes.length,a=r.localPosFromDOM(e.target,c,1);return{from:l,to:a}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},wf=new WeakMap,kf=!1;function by(n){if(!wf.has(n)&&(wf.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ee,kf)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),kf=!0}}function Sf(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return jt(o.node,o.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function wy(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return Sf(n,i)}let t;function r(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Sf(n,t):null}function ky(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function Sy(n,e){var t;let{focusNode:r,focusOffset:i}=n.domSelectionRange();for(let s of e)if(((t=s.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let o=s.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let c=l.firstChild;if(!c||c.nodeType!=1||c.contentEditable=="false"||/^(BR|IMG)$/.test(c.nodeName))break;l=c}l.insertBefore(s,l.firstChild),r==s&&n.domSelection().collapse(s,i)}else s.parentNode.removeChild(s)}}function Cy(n,e,t,r){let{node:i,fromOffset:s,toOffset:o,from:l,to:c}=n.docView.parseRange(e,t),a=n.domSelectionRange(),h,f=a.anchorNode;if(f&&n.dom.contains(f.nodeType==1?f:f.parentNode)&&(h=[{node:f,offset:a.anchorOffset}],Cs(a)||h.push({node:a.focusNode,offset:a.focusOffset})),Q&&n.input.lastKeyCode===8)for(let y=o;y>s;y--){let k=i.childNodes[y-1],w=k.pmViewDesc;if(k.nodeName=="BR"&&!w){o=y;break}if(!w||w.size)break}let u=n.state.doc,d=n.someProp("domParser")||Sr.fromSchema(n.state.schema),p=u.resolve(l),m=null,g=d.parse(i,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:s,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:h,ruleFromNode:Ty(r),context:p});if(h&&h[0].pos!=null){let y=h[0].pos,k=h[1]&&h[1].pos;k==null&&(k=y),m={anchor:y+l,head:k+l}}return{doc:g,sel:m,from:l,to:c}}var Ty=n=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(n);if(e.nodeName=="BR"&&e.parentNode){if(re&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||re&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},Dy=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Oy(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let T=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,B=Ll(n,T);if(B&&!n.state.selection.eq(B)){if(Q&&Xe&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",be=>be(n,Ft(13,"Enter"))))return;let $=n.state.tr.setSelection(B);T=="pointer"?$.setMeta("pointer",!0):T=="key"&&$.scrollIntoView(),s&&$.setMeta("composition",s),n.dispatch($)}return}let o=n.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=n.state.doc.resolve(t).after(l+1);let c=n.state.selection,a=Cy(n,e,t,i),h=n.state.doc,f=h.slice(a.from,a.to),u,d;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(u=n.state.selection.to,d="end"):(u=n.state.selection.from,d="start"),n.input.lastKeyCode=null;let p=Ay(f.content,a.doc.content,a.from,u,d);if(p&&n.input.domChangeCount++,(vn&&n.input.lastIOSEnter>Date.now()-225||Xe)&&i.some(T=>T.nodeType==1&&!Dy.test(T.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",T=>T(n,Ft(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&c instanceof I&&!c.empty&&c.$head.sameParent(c.$anchor)&&!n.composing&&!(a.sel&&a.sel.anchor!=a.sel.head))p={start:c.from,endA:c.to,endB:c.to};else{if(a.sel){let T=Cf(n,n.state.doc,a.sel);if(T&&!T.eq(n.state.selection)){let B=n.state.tr.setSelection(T);s&&B.setMeta("composition",s),n.dispatch(B)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof I&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=a.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=a.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),ge&&ut<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>a.from&&a.doc.textBetween(p.start-a.from-1,p.start-a.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let m=a.doc.resolveNoCache(p.start-a.from),g=a.doc.resolveNoCache(p.endB-a.from),y=h.resolve(p.start),k=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((vn&&n.input.lastIOSEnter>Date.now()-225&&(!k||i.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!k&&m.pos<a.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(a.doc.textBetween(m.pos,g.pos,"","")))&&n.someProp("handleKeyDown",T=>T(n,Ft(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&My(h,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",T=>T(n,Ft(8,"Backspace")))){Xe&&Q&&n.domObserver.suppressSelectionUpdates();return}Q&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),Xe&&!k&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&a.sel&&a.sel.anchor==a.sel.head&&a.sel.head==p.endA&&(p.endB-=2,g=a.doc.resolveNoCache(p.endB-a.from),setTimeout(()=>{n.someProp("handleKeyDown",function(T){return T(n,Ft(13,"Enter"))})},20));let w=p.start,D=p.endA,A=T=>{let B=T||n.state.tr.replace(w,D,a.doc.slice(p.start-a.from,p.endB-a.from));if(a.sel){let $=Cf(n,B.doc,a.sel);$&&!(Q&&n.composing&&$.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&($.head==w||$.head==B.mapping.map(D)-1)||ge&&$.empty&&$.head==w)&&B.setSelection($)}return s&&B.setMeta("composition",s),B.scrollIntoView()},R;if(k)if(m.pos==g.pos){ge&&ut<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Qe(n),20));let T=A(n.state.tr.delete(w,D)),B=h.resolve(p.start).marksAcross(h.resolve(p.endA));B&&T.ensureMarks(B),n.dispatch(T)}else if(p.endA==p.endB&&(R=Ey(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let T=A(n.state.tr);R.type=="add"?T.addMark(w,D,R.mark):T.removeMark(w,D,R.mark),n.dispatch(T)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let T=m.parent.textBetween(m.parentOffset,g.parentOffset),B=()=>A(n.state.tr.insertText(T,w,D));n.someProp("handleTextInput",$=>$(n,w,D,T,B))||n.dispatch(B())}else n.dispatch(A());else n.dispatch(A())}function Cf(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Fl(n,e.resolve(t.anchor),e.resolve(t.head))}function Ey(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,s=r,o,l,c;for(let h=0;h<r.length;h++)i=r[h].removeFromSet(i);for(let h=0;h<t.length;h++)s=t[h].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",c=h=>h.mark(l.addToSet(h.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",c=h=>h.mark(l.removeFromSet(h.marks));else return null;let a=[];for(let h=0;h<e.childCount;h++)a.push(c(e.child(h)));if(x.from(a).eq(n))return{mark:l,type:o}}function My(n,e,t,r,i){if(t-e<=i.pos-r.pos||gl(r,!0,!1)<i.pos)return!1;let s=n.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=n.resolve(gl(s,!0,!0));return!o.parent.isTextblock||o.pos>t||gl(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function gl(n,e,t){let r=n.depth,i=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function Ay(n,e,t,r,i){let s=n.findDiffStart(e,t),o=t+n.size,l=t+e.size;if(s==null)return null;let{a:c,b:a}=n.findDiffEnd(e,o,l);if(i=="end"){let h=Math.max(0,s-Math.min(c,a));r-=c+h-s}if(c<s&&o<l){let h=r<=s&&r>=c?s-r:0;s-=h,a=s+(a-c),c=s}else if(a<s){let h=r<=s&&r>=a?s-r:0;s-=h,c=s+(c-a),a=s}return{start:s,endA:c,endB:a}}var Lr=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Nl,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Mf),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Of(this),Df(this),this.nodeViews=Ef(this),this.docView=of(this.state.doc,Tf(this),ml(this),this.dom,this),this.domObserver=new Ul(this,(r,i,s,o)=>Oy(this,r,i,s,o)),this.domObserver.start(),Gg(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Il(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Mf),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(tu(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let d=Ef(this);Iy(d,this.nodeViews)&&(this.nodeViews=d,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Il(this),this.editable=Of(this),Df(this);let c=ml(this),a=Tf(this),h=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=s||!this.docView.matchesNode(e.doc,a,c);(f||!e.selection.eq(i.selection))&&(o=!0);let u=h=="preserve"&&o&&this.dom.style.overflowAnchor==null&&pg(this);if(o){this.domObserver.stop();let d=f&&(ge||Q)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Ny(i.selection,e.selection);if(f){let m=Q?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=ay(this)),(s||!this.docView.update(e.doc,a,c,this))&&(this.docView.updateOuterDeco(a),this.docView.destroy(),this.docView=of(e.doc,a,c,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(d=!0)}let p=this.input.mouseDown;d||!(p&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Vg(this)&&p.delaySelUpdate())?Qe(this,d):($f(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),h=="reset"?this.dom.scrollTop=0:h=="to selection"?this.scrollToSelection():u&&mg(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof S){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&ef(this,t.getBoundingClientRect(),e)}else ef(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,i=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&s<this.state.doc.content.size&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new bs(e.slice,e.move,i<0?void 0:S.create(this.state.doc,i))}someProp(e,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=t?t(l):l))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(i=t?t(l):l))return i}}hasFocus(){if(ge){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&gg(this.dom),Qe(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return kg(this,e)}coordsAtPos(e,t=1){return Uf(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return Og(this,t||this.state,e)}pasteHTML(e,t){return Ur(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Ur(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Pl(this,e)}destroy(){this.docView&&(Xg(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ml(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ig())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Qg(this,e)}domSelectionRange(){let e=this.domSelection();return e?re&&this.root.nodeType===11&&ag(this.dom.ownerDocument)==this.dom&&wy(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Lr.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function Tf(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[pt.node(0,n.state.doc.content.size,e)]}function Df(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:pt.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Of(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Ny(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Ef(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Iy(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function Mf(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var _y=["p",0],Ry=["blockquote",0],By=["hr"],Vy=["pre",["code",0]],Uy=["br"],vy={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return _y}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM(){return Ry}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return By}},heading:{attrs:{level:{default:1,validate:"number"}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(n){return["h"+n.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM(){return Vy}},text:{group:"inline"},image:{inline:!0,attrs:{src:{validate:"string"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs(n){return{src:n.getAttribute("src"),title:n.getAttribute("title"),alt:n.getAttribute("alt")}}}],toDOM(n){let{src:e,alt:t,title:r}=n.attrs;return["img",{src:e,alt:t,title:r}]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM(){return Uy}}},Ly=["em",0],Fy=["strong",0],Py=["code",0],zy={link:{attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs(n){return{href:n.getAttribute("href"),title:n.getAttribute("title")}}}],toDOM(n){let{href:e,title:t}=n.attrs;return["a",{href:e,title:t},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:n=>n.type.name=="em"}],toDOM(){return Ly}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name=="strong"},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}],toDOM(){return Fy}},code:{code:!0,parseDOM:[{tag:"code"}],toDOM(){return Py}}},Wl=new En({nodes:vy,marks:zy});var $y=["ol",0],qy=["ul",0],Jy=["li",0],Wy={attrs:{order:{default:1,validate:"number"}},parseDOM:[{tag:"ol",getAttrs(n){return{order:n.hasAttribute("start")?+n.getAttribute("start"):1}}}],toDOM(n){return n.attrs.order==1?$y:["ol",{start:n.attrs.order},0]}},jy={parseDOM:[{tag:"ul"}],toDOM(){return qy}},Ky={parseDOM:[{tag:"li"}],toDOM(){return Jy},defining:!0};function jl(n,e){let t={};for(let r in n)t[r]=n[r];for(let r in e)t[r]=e[r];return t}function lu(n,e,t){return n.append({ordered_list:jl(Wy,{content:"list_item+",group:t}),bullet_list:jl(jy,{content:"list_item+",group:t}),list_item:jl(Ky,{content:e})})}function cu(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s);if(!o)return!1;let l=r?t.tr:null;return Yy(l,o,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Yy(n,e,t,r=null){let i=!1,s=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let c=o.resolve(e.start-2);s=new _t(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new _t(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=ls(s,t,r,e);return l?(n&&Hy(n,e,l,i,t),!0):!1}function Hy(n,e,t,r,i){let s=x.empty;for(let h=t.length-1;h>=0;h--)s=x.from(t[h].type.create(t[h].attrs,s));n.step(new X(e.start-(r?2:0),e.end,e.start,e.end,new b(s,0,0),t.length,!0));let o=0;for(let h=0;h<t.length;h++)t[h].type==i&&(o=h+1);let l=t.length-o,c=e.start+t.length-(r?2:0),a=e.parent;for(let h=e.startIndex,f=e.endIndex,u=!0;h<f;h++,u=!1)!u&&vt(n.doc,c,l)&&(n.split(c,l),c+=2*l),c+=a.child(h).nodeSize;return n}function au(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?Gy(e,t,n,s):Xy(e,t,s):!0:!1}}function Gy(n,e,t,r){let i=n.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new X(s-1,o,s,o,new b(x.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new _t(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));let l=Ut(r);if(l==null)return!1;i.lift(r,l);let c=i.doc.resolve(i.mapping.map(s,-1)-1);return Ar(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function Xy(n,e,t){let r=n.tr,i=t.parent;for(let d=t.end,p=t.endIndex-1,m=t.startIndex;p>m;p--)d-=i.child(p).nodeSize,r.delete(d-1,d+1);let s=r.doc.resolve(t.start),o=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,c=t.endIndex==i.childCount,a=s.node(-1),h=s.index(-1);if(!a.canReplace(h+(l?0:1),h+1,o.content.append(c?x.empty:x.from(i))))return!1;let f=s.pos,u=f+o.nodeSize;return r.step(new X(f-(l?1:0),u+(c?1:0),f+1,u-1,new b((l?x.empty:x.from(i.copy(x.empty))).append(c?x.empty:x.from(i.copy(x.empty))),l?0:1,c?0:1),l?0:1)),e(r.scrollIntoView()),!0}var et={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Ds={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Zy=typeof navigator<"u"&&/Mac/.test(navigator.platform),Qy=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(z=0;z<10;z++)et[48+z]=et[96+z]=String(z);var z;for(z=1;z<=24;z++)et[z+111]="F"+z;var z;for(z=65;z<=90;z++)et[z]=String.fromCharCode(z+32),Ds[z]=String.fromCharCode(z);var z;for(Ts in et)Ds.hasOwnProperty(Ts)||(Ds[Ts]=et[Ts]);var Ts;function hu(n){var e=Zy&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Qy&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Ds:et)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}var e0=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),t0=typeof navigator<"u"&&/Win/.test(navigator.platform);function n0(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,s,o;for(let l=0;l<e.length-1;l++){let c=e[l];if(/^(cmd|meta|m)$/i.test(c))o=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))e0?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(t="Alt-"+t),i&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function r0(n){let e=Object.create(null);for(let t in n)e[n0(t)]=n[t];return e}function Kl(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Yl(n){return new Le({props:{handleKeyDown:i0(n)}})}function i0(n){let e=r0(n);return function(t,r){let i=hu(r),s,o=e[Kl(i,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Kl(i,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(t0&&r.ctrlKey&&r.altKey)&&(s=et[r.keyCode])&&s!=i){let l=e[Kl(s,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var uu=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function s0(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}var o0=(n,e,t)=>{let r=s0(n,t);if(!r)return!1;let i=du(r);if(!i){let o=r.blockRange(),l=o&&Ut(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(gu(n,i,e,-1))return!0;if(r.parent.content.size==0&&(Ln(s,"end")||S.isSelectable(s)))for(let o=r.depth;;o--){let l=cs(n.doc,r.before(o),r.after(o),b.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=n.tr.step(l);c.setSelection(Ln(s,"end")?E.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):S.create(c.doc,i.pos-s.nodeSize)),e(c.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1};function Ln(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}var l0=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=du(r)}let o=s&&s.nodeBefore;return!o||!S.isSelectable(o)?!1:(e&&e(n.tr.setSelection(S.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function du(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function c0(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}var a0=(n,e,t)=>{let r=c0(n,t);if(!r)return!1;let i=pu(r);if(!i)return!1;let s=i.nodeAfter;if(gu(n,i,e,1))return!0;if(r.parent.content.size==0&&(Ln(s,"start")||S.isSelectable(s))){let o=cs(n.doc,r.before(),r.after(),b.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(Ln(s,"start")?E.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):S.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},h0=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=pu(r)}let o=s&&s.nodeAfter;return!o||!S.isSelectable(o)?!1:(e&&e(n.tr.setSelection(S.create(n.doc,s.pos)).scrollIntoView()),!0)};function pu(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}var mu=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),s=i&&Ut(i);return s==null?!1:(e&&e(n.tr.lift(i,s).scrollIntoView()),!0)},f0=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(` |
| -`).scrollIntoView()),!0)};function Gl(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}var u0=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=Gl(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),c=n.tr.replaceWith(l,l,o.createAndFill());c.setSelection(E.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},d0=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof oe||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=Gl(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=n.tr.insert(o,s.createAndFill());l.setSelection(I.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},p0=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(vt(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&Ut(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function m0(n){return(e,t)=>{if(e.selection instanceof S&&e.selection.node.isBlock){let{$from:d}=e.selection;return!d.parentOffset||!vt(e.doc,d.pos)?!1:(t&&t(e.tr.split(d.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof I||e.selection instanceof oe)&&r.deleteSelection();let{$from:i}=r.selection,s=r.steps.length,o=[],l,c,a=!1,h=!1;for(let d=i.depth;;d--)if(i.node(d).isBlock){a=i.end(d)==i.pos+(i.depth-d),h=i.start(d)==i.pos-(i.depth-d),c=Gl(i.node(d-1).contentMatchAt(i.indexAfter(d-1)));let m=n&&n(i.parent,a,i);o.unshift(m||(a&&c?{type:c}:null)),l=d;break}else{if(d==1)return!1;o.unshift(null)}let f=i.pos,u=vt(r.doc,f,o.length,o);if(u||(o[0]=c?{type:c}:null,u=vt(r.doc,f,o.length,o)),!u)return!1;if(r.split(f,o.length,o),!a&&h&&i.node(l).type!=c){let d=r.mapping.slice(s),p=d.map(i.before(l)),m=r.doc.resolve(p);c&&i.node(l-1).canReplaceWith(m.index(),m.index()+1,c)&&r.setNodeMarkup(d.map(i.before(l)),c)}return t&&t(r.scrollIntoView()),!0}}var g0=m0();var y0=(n,e)=>(e&&e(n.tr.setSelection(new oe(n.doc))),!0);function x0(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||Ar(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function gu(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,c=i.type.spec.isolating||s.type.spec.isolating;if(!c&&x0(n,e,t))return!0;let a=!c&&e.parent.canReplace(e.index(),e.index()+1);if(a&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let d=e.pos+s.nodeSize,p=x.empty;for(let y=o.length-1;y>=0;y--)p=x.from(o[y].create(null,p));p=x.from(i.copy(p));let m=n.tr.step(new X(e.pos-1,d,e.pos,d,new b(p,1,0),o.length,!0)),g=m.doc.resolve(d+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&Ar(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let h=s.type.spec.isolating||r>0&&c?null:E.findFrom(e,1),f=h&&h.$from.blockRange(h.$to),u=f&&Ut(f);if(u!=null&&u>=e.depth)return t&&t(n.tr.lift(f,u).scrollIntoView()),!0;if(a&&Ln(s,"start",!0)&&Ln(i,"end")){let d=i,p=[];for(;p.push(d),!d.isTextblock;)d=d.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(d.canReplace(d.childCount,d.childCount,m.content)){if(t){let y=x.empty;for(let w=p.length-1;w>=0;w--)y=x.from(p[w].copy(y));let k=n.tr.step(new X(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new b(y,p.length,0),0,!0));t(k.scrollIntoView())}return!0}}return!1}function yu(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(I.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}var b0=yu(-1),w0=yu(1);function xu(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&ls(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Xl(n,e=null){return function(t,r){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(c,a)=>{if(i)return!1;if(!(!c.isTextblock||c.hasMarkup(n,e)))if(c.type==n)i=!0;else{let h=t.doc.resolve(a),f=h.index();i=h.parent.canReplaceWith(f,f+1,n)}})}if(!i)return!1;if(r){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:c}}=t.selection.ranges[o];s.setBlockType(l,c,n,e)}r(s.scrollIntoView())}return!0}}function k0(n,e,t,r){for(let i=0;i<e.length;i++){let{$from:s,$to:o}=e[i],l=s.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(s.pos,o.pos,(c,a)=>{if(l||!r&&c.isAtom&&c.isInline&&a>=s.pos&&a+c.nodeSize<=o.pos)return!1;l=c.inlineContent&&c.type.allowsMarkType(t)}),l)return!0}return!1}function S0(n){let e=[];for(let t=0;t<n.length;t++){let{$from:r,$to:i}=n[t];r.doc.nodesBetween(r.pos,i.pos,(s,o)=>{if(s.isAtom&&s.content.size&&s.isInline&&o>=r.pos&&o+s.nodeSize<=i.pos)return o+1>r.pos&&e.push(new In(r,r.doc.resolve(o+1))),r=r.doc.resolve(o+1+s.content.size),!1}),r.pos<i.pos&&e.push(new In(r,i))}return e}function Yt(n,e=null,t){let r=(t&&t.removeWhenPresent)!==!1,i=(t&&t.enterInlineAtoms)!==!1,s=!(t&&t.includeWhitespace);return function(o,l){let{empty:c,$cursor:a,ranges:h}=o.selection;if(c&&!a||!k0(o.doc,h,n,i))return!1;if(l)if(a)n.isInSet(o.storedMarks||a.marks())?l(o.tr.removeStoredMark(n)):l(o.tr.addStoredMark(n.create(e)));else{let f,u=o.tr;i||(h=S0(h)),r?f=!h.some(d=>o.doc.rangeHasMark(d.$from.pos,d.$to.pos,n)):f=!h.every(d=>{let p=!1;return u.doc.nodesBetween(d.$from.pos,d.$to.pos,(m,g,y)=>{if(p)return!1;p=!n.isInSet(m.marks)&&!!y&&y.type.allowsMarkType(n)&&!(m.isText&&/^\s*$/.test(m.textBetween(Math.max(0,d.$from.pos-g),Math.min(m.nodeSize,d.$to.pos-g))))}),!p});for(let d=0;d<h.length;d++){let{$from:p,$to:m}=h[d];if(!f)u.removeMark(p.pos,m.pos,n);else{let g=p.pos,y=m.pos,k=p.nodeAfter,w=m.nodeBefore,D=s&&k&&k.isText?/^\s*/.exec(k.text)[0].length:0,A=s&&w&&w.isText?/\s*$/.exec(w.text)[0].length:0;g+D<y&&(g+=D,y-=A),u.addMark(g,y,n.create(e))}}l(u.scrollIntoView())}return!0}}function Zl(...n){return function(e,t,r){for(let i=0;i<n.length;i++)if(n[i](e,t,r))return!0;return!1}}var Hl=Zl(uu,o0,l0),fu=Zl(uu,a0,h0),tt={Enter:Zl(f0,d0,p0,g0),"Mod-Enter":u0,Backspace:Hl,"Mod-Backspace":Hl,"Shift-Backspace":Hl,Delete:fu,"Mod-Delete":fu,"Mod-a":y0},bu={"Ctrl-h":tt.Backspace,"Alt-Backspace":tt["Mod-Backspace"],"Ctrl-d":tt.Delete,"Ctrl-Alt-Backspace":tt["Mod-Delete"],"Alt-Delete":tt["Mod-Delete"],"Alt-d":tt["Mod-Delete"],"Ctrl-a":b0,"Ctrl-e":w0};for(let n in tt)bu[n]=tt[n];var C0=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,wu=C0?bu:tt;var ku=()=>{let n=!0;return(e,t)=>{if(n){n=!1;try{e()}finally{n=!0}}else t!==void 0&&t()}};var T0=/[\uD800-\uDBFF]/,D0=/[\uDC00-\uDFFF]/,O0=(n,e)=>{let t=0,r=0;for(;t<n.length&&t<e.length&&n[t]===e[t];)t++;for(t>0&&T0.test(n[t-1])&&t--;r+t<n.length&&r+t<e.length&&n[n.length-r-1]===e[e.length-r-1];)r++;return r>0&&D0.test(n[n.length-r])&&r--,{index:t,remove:n.length-t-r,insert:e.slice(t,e.length-r)}},Su=O0;var L=new _n("y-sync"),Pe=new _n("y-undo"),_b=new _n("yjs-cursor");var ze=(n,e)=>n>>>e|n<<32-e,E0=n=>ze(n,2)^ze(n,13)^ze(n,22),M0=n=>ze(n,6)^ze(n,11)^ze(n,25),A0=n=>ze(n,7)^ze(n,18)^n>>>3,N0=n=>ze(n,17)^ze(n,19)^n>>>10,I0=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),_0=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ql=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(_0),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let f=16;f<64;f++)t[f]=N0(t[f-2])+t[f-7]+A0(t[f-15])+t[f-16];let r=e[0],i=e[1],s=e[2],o=e[3],l=e[4],c=e[5],a=e[6],h=e[7];for(let f=0,u,d;f<64;f++)u=h+M0(l)+(l&c^~l&a)+I0[f]+t[f]>>>0,d=E0(r)+(r&i^r&s^i&s)>>>0,h=a,a=c,c=l,l=o+u>>>0,o=s,s=i,i=r,r=u+d>>>0;e[0]+=r,e[1]+=i,e[2]+=s,e[3]+=o,e[4]+=l,e[5]+=c,e[6]+=a,e[7]+=h}digest(e){let t=0;for(;t+56<=e.length;){let o=0;for(;o<16&&t+3<e.length;o++)this._W[o]=e[t++]<<24|e[t++]<<16|e[t++]<<8|e[t++];if(t%64!==0){for(this._W.fill(0,o,16);t<e.length;)this._W[o]|=e[t]<<(3-t%4)*8,t++;this._W[o]|=128<<(3-t%4)*8}this._updateHash()}let r=t%64!==0;this._W.fill(0,0,16);let i=0;for(;t<e.length;i++)for(let o=3;o>=0&&t<e.length;o--)this._W[i]|=e[t++]<<o*8;r||(this._W[i-(t%4===0?0:1)]|=128<<(3-t%4)*8),this._W[14]=e.byteLength/536870912,this._W[15]=e.byteLength*8,this._updateHash();let s=new Uint8Array(32);for(let o=0;o<this._H.length;o++)for(let l=0;l<4;l++)s[o*4+l]=this._H[o]>>>(3-l)*8;return s}},Cu=n=>new Ql().digest(n);var B0=n=>{for(let t=6;t<n.length;t++)n[t%6]=n[t%6]^n[t];return n.slice(0,6)},Tu=n=>Pc(B0(Cu($c(n))));var qr=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&e.sv.get(n.id.client)>n.id.clock&&!At(e.ds,n.id),U0=[{light:"#ecd44433",dark:"#ecd444"}],v0=(n,e,t)=>{if(!n.has(t)){if(n.size<e.length){let r=Ne();n.forEach(i=>r.add(i)),e=e.filter(i=>!r.has(i))}n.set(t,Oc(e))}return n.get(t)},rc=(n,{colors:e=U0,colorMapping:t=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:s}={})=>{let o=!1,l=new Ms(n,s),c=new Le({props:{editable:a=>{let h=L.getState(a);return h.snapshot==null&&h.prevSnapshot==null}},key:L,state:{init:(a,h)=>({type:n,doc:n.doc,binding:l,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:t,permanentUserData:r}),apply:(a,h)=>{let f=a.getMeta(L);if(f!==void 0){h=Object.assign({},h);for(let u in f)h[u]=f[u]}return h.addToHistory=a.getMeta("addToHistory")!==!1,h.isChangeOrigin=f!==void 0&&!!f.isChangeOrigin,h.isUndoRedoOperation=f!==void 0&&!!f.isChangeOrigin&&!!f.isUndoRedoOperation,l.prosemirrorView!==null&&f!==void 0&&(f.snapshot!=null||f.prevSnapshot!=null)&&lo(0,()=>{l.prosemirrorView!=null&&(f.restore==null?l._renderSnapshot(f.snapshot,f.prevSnapshot,h):(l._renderSnapshot(f.snapshot,f.snapshot,h),delete h.restore,delete h.snapshot,delete h.prevSnapshot,l.mux(()=>{l._prosemirrorChanged(l.prosemirrorView.state.doc)})))}),h}},view:a=>(l.initView(a),s==null&&l._forceRerender(),i(),{update:()=>{let h=c.getState(a.state);if(h.snapshot==null&&h.prevSnapshot==null&&(o||a.state.doc.content.findDiffStart(a.state.doc.type.createAndFill().content)!==null)){if(o=!0,h.addToHistory===!1&&!h.isChangeOrigin){let f=Pe.getState(a.state),u=f&&f.undoManager;u&&u.stopCapturing()}l.mux(()=>{h.doc.transact(f=>{f.meta.set("addToHistory",h.addToHistory),l._prosemirrorChanged(a.state.doc)},L)})}},destroy:()=>{l.destroy()}})});return c},L0=(n,e,t)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")n.setSelection(new oe(n.doc));else if(e.type==="node"){let r=Es(t.doc,t.type,e.anchor,t.mapping);n.setSelection(S.create(n.doc,r))}else{let r=Es(t.doc,t.type,e.anchor,t.mapping),i=Es(t.doc,t.type,e.head,t.mapping);if(r!==null&&i!==null){let s=I.between(n.doc.resolve(r),n.doc.resolve(i));n.setSelection(s)}}},Jr=(n,e)=>({type:e.selection.jsonID,anchor:nc(e.selection.anchor,n.type,n.mapping),head:nc(e.selection.head,n.type,n.mapping)}),Ms=class{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=ku(),this.mapping=t,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=Jr(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(er&&this._domSelectionInView===null&&(lo(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){let e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;let t=this.prosemirrorView._root.createRange();t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),t.getClientRects().length===0&&t.startContainer&&t.collapsed&&t.selectNodeContents(t.startContainer);let i=t.getBoundingClientRect(),s=We.documentElement;return i.bottom>=0&&i.right>=0&&i.left<=(window.innerWidth||s.clientWidth||0)&&i.top<=(window.innerHeight||s.clientHeight||0)}renderSnapshot(e,t){t||(t=qi(Pi(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(L,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{let e=this.type.toArray().map(r=>Os(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new b(x.from(e),0,0));t.setMeta(L,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(t)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{let e=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,t=this.type.toArray().map(i=>Os(i,this.prosemirrorView.state.schema,this)).filter(i=>i!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new b(x.from(t),0,0));if(e){let i=Je(Ie(e.anchor,0),r.doc.content.size),s=Je(Ie(e.head,0),r.doc.content.size);r.setSelection(I.create(r.doc,i,s))}this.prosemirrorView.dispatch(r.setMeta(L,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,r){let i=this.doc,s=this.type;if(e||(e=Ji(this.doc)),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&q(),i=new Se({gc:!1}),zi(i,t),t=Ji(i),zi(i,e),e=Ji(i),s._item===null){let o=Array.from(this.doc.share.keys()).find(l=>this.doc.share.get(l)===this.type);s=i.getXmlFragment(o)}else{let o=i.store.clients.get(s._item.id.client)??[],l=Ce(o,s._item.id.clock);s=o[l].content.type}this.mapping.clear(),this.mux(()=>{i.transact(o=>{let l=r.permanentUserData;l&&l.dss.forEach(f=>{je(o,f,u=>{})});let c=(f,u)=>{let d=f==="added"?l.getUserByClientId(u.client):l.getUserByDeletedId(u);return{user:d,type:f,color:v0(r.colorMapping,r.colors,d)}},a=$o(s,new wn(t.ds,e.sv)).map(f=>!f._item.deleted||qr(f._item,e)||qr(f._item,t)?Os(f,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,t,c):null).filter(f=>f!==null),h=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new b(x.from(a),0,0));this.prosemirrorView.dispatch(h.setMeta(L,{isChangeOrigin:!0}))},L)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let r=L.getState(this.prosemirrorView.state);if(e.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}this.mux(()=>{let i=(l,c)=>this.mapping.delete(c);je(t,t.deleteSet,l=>{if(l.constructor===_){let c=l.content.type;c&&this.mapping.delete(c)}}),t.changed.forEach(i),t.changedParentTypes.forEach(i);let s=this.type.toArray().map(l=>Eu(l,this.prosemirrorView.state.schema,this)).filter(l=>l!==null),o=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new b(x.from(s),0,0));L0(o,this.beforeTransactionSelection,this),o=o.setMeta(L,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof kn}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&o.scrollIntoView(),this.prosemirrorView.dispatch(o)})}_prosemirrorChanged(e){this.doc.transact(()=>{Ns(this.doc,this.type,e,this),this.beforeTransactionSelection=Jr(this,this.prosemirrorView.state)},L)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}},Eu=(n,e,t,r,i,s)=>{let o=t.mapping.get(n);if(o===void 0){if(n instanceof H)return Os(n,e,t,r,i,s);throw se()}return o},Os=(n,e,t,r,i,s)=>{let o=[],l=c=>{if(c instanceof H){let a=Eu(c,e,t,r,i,s);a!==null&&o.push(a)}else{let a=c._item.right?.content?.type;a instanceof Ke&&!a._item.deleted&&a._item.id.client===a.doc.clientID&&(c.applyDelta([{retain:c.length},...a.toDelta()]),a.doc.transact(f=>{a._item.delete(f)}));let h=F0(c,e,t,r,i,s);h!==null&&h.forEach(f=>{f!==null&&o.push(f)})}};r===void 0||i===void 0?n.toArray().forEach(l):$o(n,new wn(i.ds,r.sv)).forEach(l);try{let c=n.getAttributes(r);r!==void 0&&(qr(n._item,r)?qr(n._item,i)||(c.ychange=s?s("added",n._item.id):{type:"added"}):c.ychange=s?s("removed",n._item.id):{type:"removed"});let a=e.node(n.nodeName,c,o);return t.mapping.set(n,a),a}catch{return n.doc.transact(a=>{n._item.delete(a)},L),t.mapping.delete(n),null}},F0=(n,e,t,r,i,s)=>{let o=[],l=n.toDelta(r,i,s);try{for(let c=0;c<l.length;c++){let a=l[c];o.push(e.text(a.insert,W0(a.attributes,e)))}}catch{return n.doc.transact(a=>{n._item.delete(a)},L),null}return o},P0=(n,e)=>{let t=new pe,r=n.map(i=>({insert:i.text,attributes:Nu(i.marks,e)}));return t.applyDelta(r),e.mapping.set(t,n),t},z0=(n,e)=>{let t=new H(n.type.name);for(let r in n.attrs){let i=n.attrs[r];i!==null&&r!=="ychange"&&t.setAttribute(r,i)}return t.insert(0,Is(n).map(r=>ec(r,e))),e.mapping.set(t,n),t},ec=(n,e)=>n instanceof Array?P0(n,e):z0(n,e),Du=n=>typeof n=="object"&&n!==null,ic=(n,e)=>{let t=Object.keys(n).filter(i=>n[i]!==null),r=t.length===(e==null?0:Object.keys(e).filter(i=>e[i]!==null).length);for(let i=0;i<t.length&&r;i++){let s=t[i],o=n[s],l=e[s];r=s==="ychange"||o===l||Du(o)&&Du(l)&&ic(o,l)}return r},Is=n=>{let e=n.content.content,t=[];for(let r=0;r<e.length;r++){let i=e[r];if(i.isText){let s=[];for(let o=e[r];r<e.length&&o.isText;o=e[++r])s.push(o);r--,t.push(s)}else t.push(i)}return t},Mu=(n,e)=>{let t=n.toDelta();return t.length===e.length&&t.every((r,i)=>r.insert===e[i].text&&Ws(r.attributes||{}).length===e[i].marks.length&&st(r.attributes,(s,o)=>{let l=Au(o),c=e[i].marks;return ic(s,c.find(a=>a.type.name===l)?.attrs)}))},Wr=(n,e)=>{if(n instanceof H&&!(e instanceof Array)&&tc(n,e)){let t=Is(e);return n._length===t.length&&ic(n.getAttributes(),e.attrs)&&n.toArray().every((r,i)=>Wr(r,t[i]))}return n instanceof pe&&e instanceof Array&&Mu(n,e)},As=(n,e)=>n===e||n instanceof Array&&e instanceof Array&&n.length===e.length&&n.every((t,r)=>e[r]===t),Ou=(n,e,t)=>{let r=n.toArray(),i=Is(e),s=i.length,o=r.length,l=Je(o,s),c=0,a=0,h=!1;for(;c<l;c++){let f=r[c],u=i[c];if(As(t.mapping.get(f),u))h=!0;else if(!Wr(f,u))break}for(;c+a<l;a++){let f=r[o-a-1],u=i[s-a-1];if(As(t.mapping.get(f),u))h=!0;else if(!Wr(f,u))break}return{equalityFactor:c+a,foundMappedChild:h}},$0=n=>{let e="",t=n._start,r={};for(;t!==null;)t.deleted||(t.countable&&t.content instanceof _e?e+=t.content.str:t.content instanceof v&&(r[t.content.key]=null)),t=t.right;return{str:e,nAttrs:r}},q0=(n,e,t)=>{t.mapping.set(n,e);let{nAttrs:r,str:i}=$0(n),s=e.map(a=>({insert:a.text,attributes:Object.assign({},r,Nu(a.marks,t))})),{insert:o,remove:l,index:c}=Su(i,s.map(a=>a.insert).join(""));n.delete(c,l),n.insert(c,o),n.applyDelta(s.map(a=>({retain:a.insert.length,attributes:a.attributes})))},J0=/(.*)(--[a-zA-Z0-9+/=]{8})$/,Au=n=>J0.exec(n)?.[1]??n,W0=(n,e)=>{let t=[];for(let r in n)t.push(e.mark(Au(r),n[r]));return t},Nu=(n,e)=>{let t={};return n.forEach(r=>{if(r.type.name!=="ychange"){let i=we(e.isOMark,r.type,()=>!r.type.excludes(r.type));t[i?`${r.type.name}--${Tu(r.toJSON())}`:r.type.name]=r.attrs}}),t},Ns=(n,e,t,r)=>{if(e instanceof H&&e.nodeName!==t.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,t),e instanceof H){let f=e.getAttributes(),u=t.attrs;for(let d in u)u[d]!==null?f[d]!==u[d]&&d!=="ychange"&&e.setAttribute(d,u[d]):e.removeAttribute(d);for(let d in f)u[d]===void 0&&e.removeAttribute(d)}let i=Is(t),s=i.length,o=e.toArray(),l=o.length,c=Je(s,l),a=0,h=0;for(;a<c;a++){let f=o[a],u=i[a];if(!As(r.mapping.get(f),u))if(Wr(f,u))r.mapping.set(f,u);else break}for(;h+a<c;h++){let f=o[l-h-1],u=i[s-h-1];if(!As(r.mapping.get(f),u))if(Wr(f,u))r.mapping.set(f,u);else break}n.transact(()=>{for(;l-a-h>0&&s-a-h>0;){let u=o[a],d=i[a],p=o[l-h-1],m=i[s-h-1];if(u instanceof pe&&d instanceof Array)Mu(u,d)||q0(u,d,r),a+=1;else{let g=u instanceof H&&tc(u,d),y=p instanceof H&&tc(p,m);if(g&&y){let k=Ou(u,d,r),w=Ou(p,m,r);k.foundMappedChild&&!w.foundMappedChild?y=!1:!k.foundMappedChild&&w.foundMappedChild||k.equalityFactor<w.equalityFactor?g=!1:y=!1}g?(Ns(n,u,d,r),a+=1):y?(Ns(n,p,m,r),h+=1):(r.mapping.delete(e.get(a)),e.delete(a,1),e.insert(a,[ec(d,r)]),a+=1)}}let f=l-a-h;if(l===1&&s===0&&o[0]instanceof pe?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):f>0&&(e.slice(a,a+f).forEach(u=>r.mapping.delete(u)),e.delete(a,f)),a+h<s){let u=[];for(let d=a;d<s-h;d++)u.push(ec(i[d],r));e.insert(a,u)}},L)},tc=(n,e)=>!(e instanceof Array)&&n.nodeName===e.type.name;var nc=(n,e,t)=>{if(n===0)return $i(e,0,e.length===0?-1:0);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof pe){if(r._length>=n)return $i(r,n,e.length===0?-1:0);if(n-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,n--;while(r!==e&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==e&&(r=r._item===null?null:r._item.next.content.type)}}else{let i=(t.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&n<i)r=r._first.content.type,n--;else{if(n===1&&r._length===0&&i>1)return new Ot(r._item===null?null:r._item.id,r._item===null?Tn(r):null,null);if(n-=i,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(n===0)return r=r._item===null?r:r._item.parent,new Ot(r._item===null?null:r._item.id,r._item===null?Tn(r):null,null);do r=r._item.parent,n--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw q();if(n===0&&r.constructor!==pe&&r!==e)return j0(r._item.parent,r._item)}return $i(e,e._length,e.length===0?-1:0)},j0=(n,e)=>{let t=null,r=null;return n._item===null?r=Tn(n):t=C(n._item.id.client,n._item.id.clock),new Ot(t,r,e.id)},Es=(n,e,t,r)=>{let i=Ia(t,n);if(i===null||i.type!==e&&!bn(e,i.type._item))return null;let s=i.type,o=0;if(s.constructor===pe)o=i.index;else if(s._item===null||!s._item.deleted){let l=s._first,c=0;for(;c<s._length&&c<i.index&&l!==null;){if(!l.deleted){let a=l.content.type;c++,a instanceof pe?o+=a._length:o+=r.get(a).nodeSize}l=l.right}o+=1}for(;s!==e&&s._item!==null;){let l=s._item.parent;if(l._item===null||!l._item.deleted){o+=1;let c=l._first;for(;c!==null;){let a=c.content.type;if(a===s)break;c.deleted||(a instanceof pe?o+=a._length:o+=r.get(a).nodeSize),c=c.right}}s=l}return o-1};var sc=n=>Pe.getState(n)?.undoManager?.undo()!=null,_s=n=>Pe.getState(n)?.undoManager?.redo()!=null,Iu=(n,e)=>e==null?Pe.getState(n)?.undoManager?.canUndo():sc(n),_u=(n,e)=>e==null?Pe.getState(n)?.undoManager?.canRedo():_s(n),K0=new Set(["paragraph"]),Y0=(n,e)=>!(n instanceof _)||!(n.content instanceof Te)||!(n.content.type instanceof Ke||n.content.type instanceof H&&e.has(n.content.type.nodeName))||n.content.type._length===0,Ru=({protectedNodes:n=K0,trackedOrigins:e=[],undoManager:t=null}={})=>new Le({key:Pe,state:{init:(r,i)=>{let s=L.getState(i),o=t||new kn(s.type,{trackedOrigins:new Set([L].concat(e)),deleteFilter:l=>Y0(l,n),captureTransaction:l=>l.meta.get("addToHistory")!==!1});return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(r,i,s,o)=>{let l=L.getState(o).binding,c=i.undoManager,a=c.undoStack.length>0,h=c.redoStack.length>0;return l?{undoManager:c,prevSel:Jr(l,s),hasUndoOps:a,hasRedoOps:h}:a!==i.hasUndoOps||h!==i.hasRedoOps?Object.assign({},i,{hasUndoOps:c.undoStack.length>0,hasRedoOps:c.redoStack.length>0}):i}},view:r=>{let i=L.getState(r.state),s=Pe.getState(r.state).undoManager;return s.on("stack-item-added",({stackItem:o})=>{let l=i.binding;l&&o.meta.set(l,Pe.getState(r.state).prevSel)}),s.on("stack-item-popped",({stackItem:o})=>{let l=i.binding;l&&(l.beforeTransactionSelection=o.meta.get(l)||l.beforeTransactionSelection)}),{destroy:()=>{s.destroy()}}}});function Bu({post:n,mergeUpdates:e,onStatus:t,debounceMs:r=2e3,setTimeoutFn:i=setTimeout}){let s=[],o=null,l=null,c="ok";function a(p){c==="failed"&&p!=="failed"||(c=p,t&&t(c))}function h(){l||(l=i(f,r))}async function f(){if(l=null,!s.length)return;let p=e(s);s=[],o=p;let m;try{m=await n(p)}catch{o=null,s.unshift(p),a("retrying"),h();return}if(o=null,m.ok){a("ok");return}if(m.status>=400&&m.status<500){a("failed");return}s.unshift(p),a("retrying"),h()}function u(p){s.push(p),!l&&(l=i(f,r))}function d(){let p=[];return o&&p.push(o),s.length&&p.push(e(s)),p.length?p.length===1?p[0]:e(p):null}return{enqueue:u,flush:f,pendingBytes:d,get status(){return c}}}function Vu({attemptResync:n,onDiverged:e,onRecovered:t,backoffMs:r=l=>Math.min(1e3*2**(l-1),3e4),setTimeoutFn:i=setTimeout,clearTimeoutFn:s=clearTimeout,addOnlineListener:o=l=>addEventListener("online",l)}){let l=!1,c=!1,a=0,h=null;function f(){a++,h&&s(h),h=i(u,r(a))}async function u(){if(h&&(s(h),h=null),!(!l||c)){c=!0;try{await n(),l=!1,a=0,t&&t()}catch{f()}finally{c=!1}}}function d(){l||(l=!0,a=0,e&&e()),u()}return o(()=>{l&&u()}),{reportDivergence:d,get diverged(){return l},get resyncing(){return c}}}function Uu(n,e){if(!n||e.length===0)return{ensureReachable(){}};let t=()=>e.filter(s=>!s.disabled);function r(s){for(let o of e)o.tabIndex=o===s?0:-1}function i(){let s=t();s.length!==0&&(s.some(o=>o.tabIndex===0)||r(s[0]))}return n.addEventListener("keydown",s=>{let o=s.key;if(o!=="ArrowRight"&&o!=="ArrowLeft"&&o!=="Home"&&o!=="End")return;let l=t(),c=l.indexOf(document.activeElement);if(c<0||l.length===0)return;let a;o==="Home"?a=l[0]:o==="End"?a=l[l.length-1]:o==="ArrowRight"?a=l[(c+1)%l.length]:a=l[(c-1+l.length)%l.length],s.preventDefault(),r(a),a.focus()}),n.addEventListener("focusin",s=>{e.includes(s.target)&&r(s.target)}),i(),{ensureReachable:i}}var vu=["font_sans","font_mono"],Lu=["size_sm","size_lg","size_xl"];function $u({root:n,schema:e,getView:t}){if(!n)return{plugin:null};let r=Array.from(n.querySelectorAll("[data-docs-command]")),i=Array.from(n.querySelectorAll("[data-docs-select]")),s=H0(e);for(let a of r)a.addEventListener("mousedown",h=>h.preventDefault()),a.addEventListener("click",()=>{let h=t(),f=s[a.getAttribute("data-docs-command")];!h||!f||(f(h.state,h.dispatch,h),h.focus())});for(let a of i)a.addEventListener("mousedown",h=>h.stopPropagation()),a.addEventListener("change",()=>{let h=t();if(!h)return;let f=a.getAttribute("data-docs-select"),u=a.value;f==="block"&&G0(e,u)(h.state,h.dispatch),f==="font"&&Fu(e,vu,u==="serif"?null:"font_"+u)(h.state,h.dispatch),f==="size"&&Fu(e,Lu,u==="normal"?null:"size_"+u)(h.state,h.dispatch),h.focus()});function o(a){let h=a.state;for(let f of r){let u=f.getAttribute("data-docs-command"),d=s[u];if(!d)continue;let p=d(h,null,a);f.disabled=!p;let m=Z0(h,e,u);f.setAttribute("aria-pressed",m?"true":"false")}for(let f of i){f.disabled=!1;let u=f.getAttribute("data-docs-select");u==="block"&&(f.value=Q0(h)),u==="font"&&(f.value=zu(h,e,vu,"font_","serif")),u==="size"&&(f.value=zu(h,e,Lu,"size_","normal"))}}let l=Uu(n,[...r,...i]);return{plugin:new Le({view:a=>(o(a),l.ensureReachable(),{update:h=>{o(h),l.ensureReachable()}})})}}function H0(n){let e=n.marks,t=n.nodes;return{undo:Iu,redo:_u,strong:Yt(e.strong),em:Yt(e.em),code:Yt(e.code),bullet_list:Pu(t.bullet_list,t.list_item),ordered_list:Pu(t.ordered_list,t.list_item),blockquote:X0(t.blockquote)}}function G0(n,e){if(e==="paragraph")return Xl(n.nodes.paragraph);let t=Number(e.split("-")[1]);return Number.isInteger(t)?Xl(n.nodes.heading,{level:t}):()=>!1}function Fu(n,e,t){return(r,i)=>{let s=e.map(f=>n.marks[f]).filter(Boolean),o=t?n.marks[t]:null;if(t&&!o)return!1;if(!i)return!0;let{from:l,to:c,empty:a}=r.selection;if(a){let f=(r.storedMarks||r.selection.$from.marks()).filter(u=>!s.includes(u.type));return o&&(f=o.create().addToSet(f)),i(r.tr.setStoredMarks(f)),!0}let h=r.tr;for(let f of s)h.removeMark(l,c,f);return o&&h.addMark(l,c,o.create()),i(h),!0}}function Pu(n,e){let t=cu(n),r=au(e);return(i,s,o)=>jr(i,n)?r(i,s,o):t(i,s,o)}function X0(n){let e=xu(n);return(t,r,i)=>jr(t,n)?mu(t,r,i):e(t,r,i)}function jr(n,e){let t=n.selection.$from;for(let r=t.depth;r>0;r--)if(t.node(r).type===e)return!0;return!1}function Z0(n,e,t){if(t==="bullet_list")return jr(n,e.nodes.bullet_list);if(t==="ordered_list")return jr(n,e.nodes.ordered_list);if(t==="blockquote")return jr(n,e.nodes.blockquote);let r=e.marks[t];return r?qu(n,r):!1}function qu(n,e){let{from:t,$from:r,to:i,empty:s}=n.selection;return s?!!e.isInSet(n.storedMarks||r.marks()):n.doc.rangeHasMark(t,i,e)}function Q0(n){let e=n.selection.$from.parent;return e.type.name==="heading"?"heading-"+e.attrs.level:"paragraph"}function zu(n,e,t,r,i){for(let s of t){let o=e.marks[s];if(o&&qu(n,o))return s.slice(r.length)}return i}function oc(n,{since:e,raw:t}={}){let r=[];return e!==void 0&&r.push(`since=${e}`),t&&r.push("raw=1"),r.length?`${n}?${r.join("&")}`:n}function Ju({initialSeq:n=0,openStream:e,fetchSince:t,onUpdates:r,onError:i=()=>{},setTimeoutFn:s=setTimeout,clearTimeoutFn:o=clearTimeout,idleMs:l=12e4}){let c=n,a=null,h=null,f=!1,u=!1,d=!1;function p(){h!==null&&o(h),h=s(()=>{h=null,m()},l)}function m(){h!==null&&(o(h),h=null),a&&(a.close(),a=null)}function g(){f||a||(a=e(k=>{p(),k>c&&y()},k=>{m(),i(k)}),p())}async function y(){if(u){d=!0;return}u=!0;try{let k=c,w=await t(k);if(f)return;try{w&&w.bytes&&w.bytes.length&&r(w.bytes)}catch{if(w=await t(k,{raw:!0}),f)return;w&&w.bytes&&w.bytes.length&&r(w.bytes)}w&&typeof w.seq=="number"&&w.seq>c&&(c=w.seq)}catch(k){i(k)}finally{u=!1,d&&!f&&(d=!1,y())}}return{start(){f=!1,g()},stop(){f=!0,m()},noteOwnSeq(k){typeof k!="number"||!Number.isFinite(k)||k===c+1&&(c=k)},noteActivity(){f||(a?p():g())},noteHidden(){m()},get cursor(){return c},get streaming(){return a!==null}}}function Kr(n,e){return{group:e,excludes:e,parseDOM:[{tag:"span."+n}],toDOM:()=>["span",{class:n},0]}}var ex=Wl.spec.marks.addToStart("size_xl",Kr("docs-size-xl","fontSize")).addToStart("size_lg",Kr("docs-size-lg","fontSize")).addToStart("size_sm",Kr("docs-size-sm","fontSize")).addToStart("font_mono",Kr("docs-font-mono","fontFamily")).addToStart("font_sans",Kr("docs-font-sans","fontFamily")),Rs=new En({nodes:lu(Wl.spec.nodes,"paragraph block*","block"),marks:ex}),tx=2e3;function lc(n,e){if(!e.length)return;let t=ln(e);for(;ii(t);)Aa(t,n,"server")}async function nx(n){let e=n.getAttribute("data-sqid"),t=`/d/${e}/updates`,r=`/d/${e}/stream`,i=document.querySelector("[docs-save-status]"),s=!1,o=null,l=null,c=null,a=$u({root:document.querySelector("[docs-toolbar]"),schema:Rs,getView:()=>l});function h(D){i&&i.setAttribute("data-state",s?"failed":D)}function f(D){return Bu({post:async A=>{let R=await fetch(t,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/octet-stream"},body:A}),T=D();if(R.ok&&T){let B=Number(R.headers.get("Docs-Seq"));Number.isFinite(B)&&T.noteOwnSeq(B)}return R},mergeUpdates:Va,debounceMs:tx,onStatus:A=>{A==="failed"&&(s=!0,g.reportDivergence()),h(A)}})}function u(D){let A=l;if(!A||D.button!==0||A.dom.contains(D.target))return;let R=A.dom.getBoundingClientRect(),T=A.posAtCoords({left:Math.min(Math.max(D.clientX,R.left+1),R.right-1),top:Math.min(Math.max(D.clientY,R.top+1),R.bottom-1)}),B=T?T.pos:A.state.doc.content.size,$=E.near(A.state.doc.resolve(B));D.preventDefault(),A.dispatch(A.state.tr.setSelection($).scrollIntoView()),A.focus()}function d(D,A){let R=[rc(A),Ru(),Yl({"Mod-z":sc,"Mod-y":_s,"Mod-Shift-z":_s,"Mod-b":Yt(Rs.marks.strong),"Mod-i":Yt(Rs.marks.em)}),Yl(wu)];return a.plugin&&R.push(a.plugin),new Lr({mount:D},{state:fs.create({schema:Rs,plugins:R})})}async function p(D){let A=oc(t,{raw:D}),R=await fetch(A,{credentials:"same-origin"});if(!R.ok)throw new Error(`load ${A}: ${R.status}`);return{log:new Uint8Array(await R.arrayBuffer()),startSeq:Number(R.headers.get("Docs-Seq"))}}async function m(){let{log:D,startSeq:A}=await p(!1),R=new Se;try{lc(R,D)}catch{({log:D,startSeq:A}=await p(!0)),R=new Se,lc(R,D)}let T=R.getXmlFragment("prosemirror"),B=null,$=f(()=>B);R.on("update",(be,Fn)=>{Fn!=="server"&&(g.diverged||$.enqueue(be))}),l&&l.destroy(),o=$,l=d(n,T),c&&c.stop(),B=Ju({initialSeq:Number.isFinite(A)?A:0,openStream:(be,Fn)=>{let Ht=new EventSource(r,{withCredentials:!0});return Ht.addEventListener("update",nt=>be(Number(nt.data))),Ht.addEventListener("error",nt=>Fn(nt)),{close:()=>Ht.close()}},fetchSince:async(be,{raw:Fn}={})=>{let Ht=oc(t,{since:be,raw:Fn}),nt=await fetch(Ht,{credentials:"same-origin"});if(!nt.ok)throw new Error(`fetch ${Ht}: ${nt.status}`);return{bytes:new Uint8Array(await nt.arrayBuffer()),seq:Number(nt.headers.get("Docs-Seq"))}},onUpdates:be=>{g.diverged||lc(R,be)},onError:be=>{console.error("live updates:",be)}}),c=B,c.start(),typeof document<"u"&&document.hidden&&c.noteHidden()}let g=Vu({attemptResync:m,onDiverged:()=>h("failed"),onRecovered:()=>h(s?"failed":"ok")});await m(),addEventListener("visibilitychange",()=>{document.hidden?c&&c.noteHidden():c&&c.noteActivity()});for(let D of["pointermove","scroll","keydown","focus"])addEventListener(D,()=>c&&c.noteActivity(),{passive:!0,capture:!0});let y=n.closest("[docs-page]");y&&y.addEventListener("mousedown",u);let k=!1,w=()=>{k=!0,setTimeout(()=>{k=!1},0)};return document.addEventListener("mousedown",w,!0),document.addEventListener("touchstart",w,!0),n.addEventListener("focus",()=>{if(k)return;let D=l;D&&D.dispatch(D.state.tr.scrollIntoView())}),addEventListener("beforeunload",()=>{let D=o&&o.pendingBytes();if(!D)return;let A=new Blob([D],{type:"application/octet-stream"});navigator.sendBeacon(t,A)||(console.error("beforeunload: sendBeacon refused the pending edit, retrying via keepalive fetch"),fetch(t,{method:"POST",credentials:"same-origin",keepalive:!0,headers:{"Content-Type":"application/octet-stream"},body:D}).catch(()=>{}))}),l}var cc=document.querySelector("[docs-editor]");cc&&nx(cc).catch(n=>{cc.setAttribute("data-editor-failed","1"),console.error(n)});export{nx as mountEditor}; |
| +`).scrollIntoView()),!0)};function Gl(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}var u0=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=Gl(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),c=n.tr.replaceWith(l,l,o.createAndFill());c.setSelection(E.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},d0=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof oe||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=Gl(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=n.tr.insert(o,s.createAndFill());l.setSelection(I.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},p0=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(vt(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&Ut(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function m0(n){return(e,t)=>{if(e.selection instanceof S&&e.selection.node.isBlock){let{$from:d}=e.selection;return!d.parentOffset||!vt(e.doc,d.pos)?!1:(t&&t(e.tr.split(d.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof I||e.selection instanceof oe)&&r.deleteSelection();let{$from:i}=r.selection,s=r.steps.length,o=[],l,c,a=!1,h=!1;for(let d=i.depth;;d--)if(i.node(d).isBlock){a=i.end(d)==i.pos+(i.depth-d),h=i.start(d)==i.pos-(i.depth-d),c=Gl(i.node(d-1).contentMatchAt(i.indexAfter(d-1)));let m=n&&n(i.parent,a,i);o.unshift(m||(a&&c?{type:c}:null)),l=d;break}else{if(d==1)return!1;o.unshift(null)}let f=i.pos,u=vt(r.doc,f,o.length,o);if(u||(o[0]=c?{type:c}:null,u=vt(r.doc,f,o.length,o)),!u)return!1;if(r.split(f,o.length,o),!a&&h&&i.node(l).type!=c){let d=r.mapping.slice(s),p=d.map(i.before(l)),m=r.doc.resolve(p);c&&i.node(l-1).canReplaceWith(m.index(),m.index()+1,c)&&r.setNodeMarkup(d.map(i.before(l)),c)}return t&&t(r.scrollIntoView()),!0}}var g0=m0();var y0=(n,e)=>(e&&e(n.tr.setSelection(new oe(n.doc))),!0);function x0(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||Ar(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function gu(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,c=i.type.spec.isolating||s.type.spec.isolating;if(!c&&x0(n,e,t))return!0;let a=!c&&e.parent.canReplace(e.index(),e.index()+1);if(a&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let d=e.pos+s.nodeSize,p=x.empty;for(let y=o.length-1;y>=0;y--)p=x.from(o[y].create(null,p));p=x.from(i.copy(p));let m=n.tr.step(new X(e.pos-1,d,e.pos,d,new b(p,1,0),o.length,!0)),g=m.doc.resolve(d+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&Ar(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let h=s.type.spec.isolating||r>0&&c?null:E.findFrom(e,1),f=h&&h.$from.blockRange(h.$to),u=f&&Ut(f);if(u!=null&&u>=e.depth)return t&&t(n.tr.lift(f,u).scrollIntoView()),!0;if(a&&Ln(s,"start",!0)&&Ln(i,"end")){let d=i,p=[];for(;p.push(d),!d.isTextblock;)d=d.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(d.canReplace(d.childCount,d.childCount,m.content)){if(t){let y=x.empty;for(let w=p.length-1;w>=0;w--)y=x.from(p[w].copy(y));let k=n.tr.step(new X(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new b(y,p.length,0),0,!0));t(k.scrollIntoView())}return!0}}return!1}function yu(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(I.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}var b0=yu(-1),w0=yu(1);function xu(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&ls(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Xl(n,e=null){return function(t,r){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(c,a)=>{if(i)return!1;if(!(!c.isTextblock||c.hasMarkup(n,e)))if(c.type==n)i=!0;else{let h=t.doc.resolve(a),f=h.index();i=h.parent.canReplaceWith(f,f+1,n)}})}if(!i)return!1;if(r){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:c}}=t.selection.ranges[o];s.setBlockType(l,c,n,e)}r(s.scrollIntoView())}return!0}}function k0(n,e,t,r){for(let i=0;i<e.length;i++){let{$from:s,$to:o}=e[i],l=s.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(s.pos,o.pos,(c,a)=>{if(l||!r&&c.isAtom&&c.isInline&&a>=s.pos&&a+c.nodeSize<=o.pos)return!1;l=c.inlineContent&&c.type.allowsMarkType(t)}),l)return!0}return!1}function S0(n){let e=[];for(let t=0;t<n.length;t++){let{$from:r,$to:i}=n[t];r.doc.nodesBetween(r.pos,i.pos,(s,o)=>{if(s.isAtom&&s.content.size&&s.isInline&&o>=r.pos&&o+s.nodeSize<=i.pos)return o+1>r.pos&&e.push(new In(r,r.doc.resolve(o+1))),r=r.doc.resolve(o+1+s.content.size),!1}),r.pos<i.pos&&e.push(new In(r,i))}return e}function Yt(n,e=null,t){let r=(t&&t.removeWhenPresent)!==!1,i=(t&&t.enterInlineAtoms)!==!1,s=!(t&&t.includeWhitespace);return function(o,l){let{empty:c,$cursor:a,ranges:h}=o.selection;if(c&&!a||!k0(o.doc,h,n,i))return!1;if(l)if(a)n.isInSet(o.storedMarks||a.marks())?l(o.tr.removeStoredMark(n)):l(o.tr.addStoredMark(n.create(e)));else{let f,u=o.tr;i||(h=S0(h)),r?f=!h.some(d=>o.doc.rangeHasMark(d.$from.pos,d.$to.pos,n)):f=!h.every(d=>{let p=!1;return u.doc.nodesBetween(d.$from.pos,d.$to.pos,(m,g,y)=>{if(p)return!1;p=!n.isInSet(m.marks)&&!!y&&y.type.allowsMarkType(n)&&!(m.isText&&/^\s*$/.test(m.textBetween(Math.max(0,d.$from.pos-g),Math.min(m.nodeSize,d.$to.pos-g))))}),!p});for(let d=0;d<h.length;d++){let{$from:p,$to:m}=h[d];if(!f)u.removeMark(p.pos,m.pos,n);else{let g=p.pos,y=m.pos,k=p.nodeAfter,w=m.nodeBefore,D=s&&k&&k.isText?/^\s*/.exec(k.text)[0].length:0,A=s&&w&&w.isText?/\s*$/.exec(w.text)[0].length:0;g+D<y&&(g+=D,y-=A),u.addMark(g,y,n.create(e))}}l(u.scrollIntoView())}return!0}}function Zl(...n){return function(e,t,r){for(let i=0;i<n.length;i++)if(n[i](e,t,r))return!0;return!1}}var Hl=Zl(uu,o0,l0),fu=Zl(uu,a0,h0),tt={Enter:Zl(f0,d0,p0,g0),"Mod-Enter":u0,Backspace:Hl,"Mod-Backspace":Hl,"Shift-Backspace":Hl,Delete:fu,"Mod-Delete":fu,"Mod-a":y0},bu={"Ctrl-h":tt.Backspace,"Alt-Backspace":tt["Mod-Backspace"],"Ctrl-d":tt.Delete,"Ctrl-Alt-Backspace":tt["Mod-Delete"],"Alt-Delete":tt["Mod-Delete"],"Alt-d":tt["Mod-Delete"],"Ctrl-a":b0,"Ctrl-e":w0};for(let n in tt)bu[n]=tt[n];var C0=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,wu=C0?bu:tt;var ku=()=>{let n=!0;return(e,t)=>{if(n){n=!1;try{e()}finally{n=!0}}else t!==void 0&&t()}};var T0=/[\uD800-\uDBFF]/,D0=/[\uDC00-\uDFFF]/,O0=(n,e)=>{let t=0,r=0;for(;t<n.length&&t<e.length&&n[t]===e[t];)t++;for(t>0&&T0.test(n[t-1])&&t--;r+t<n.length&&r+t<e.length&&n[n.length-r-1]===e[e.length-r-1];)r++;return r>0&&D0.test(n[n.length-r])&&r--,{index:t,remove:n.length-t-r,insert:e.slice(t,e.length-r)}},Su=O0;var L=new _n("y-sync"),Pe=new _n("y-undo"),_b=new _n("yjs-cursor");var ze=(n,e)=>n>>>e|n<<32-e,E0=n=>ze(n,2)^ze(n,13)^ze(n,22),M0=n=>ze(n,6)^ze(n,11)^ze(n,25),A0=n=>ze(n,7)^ze(n,18)^n>>>3,N0=n=>ze(n,17)^ze(n,19)^n>>>10,I0=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),_0=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ql=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(_0),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let f=16;f<64;f++)t[f]=N0(t[f-2])+t[f-7]+A0(t[f-15])+t[f-16];let r=e[0],i=e[1],s=e[2],o=e[3],l=e[4],c=e[5],a=e[6],h=e[7];for(let f=0,u,d;f<64;f++)u=h+M0(l)+(l&c^~l&a)+I0[f]+t[f]>>>0,d=E0(r)+(r&i^r&s^i&s)>>>0,h=a,a=c,c=l,l=o+u>>>0,o=s,s=i,i=r,r=u+d>>>0;e[0]+=r,e[1]+=i,e[2]+=s,e[3]+=o,e[4]+=l,e[5]+=c,e[6]+=a,e[7]+=h}digest(e){let t=0;for(;t+56<=e.length;){let o=0;for(;o<16&&t+3<e.length;o++)this._W[o]=e[t++]<<24|e[t++]<<16|e[t++]<<8|e[t++];if(t%64!==0){for(this._W.fill(0,o,16);t<e.length;)this._W[o]|=e[t]<<(3-t%4)*8,t++;this._W[o]|=128<<(3-t%4)*8}this._updateHash()}let r=t%64!==0;this._W.fill(0,0,16);let i=0;for(;t<e.length;i++)for(let o=3;o>=0&&t<e.length;o--)this._W[i]|=e[t++]<<o*8;r||(this._W[i-(t%4===0?0:1)]|=128<<(3-t%4)*8),this._W[14]=e.byteLength/536870912,this._W[15]=e.byteLength*8,this._updateHash();let s=new Uint8Array(32);for(let o=0;o<this._H.length;o++)for(let l=0;l<4;l++)s[o*4+l]=this._H[o]>>>(3-l)*8;return s}},Cu=n=>new Ql().digest(n);var B0=n=>{for(let t=6;t<n.length;t++)n[t%6]=n[t%6]^n[t];return n.slice(0,6)},Tu=n=>Pc(B0(Cu($c(n))));var qr=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&e.sv.get(n.id.client)>n.id.clock&&!At(e.ds,n.id),U0=[{light:"#ecd44433",dark:"#ecd444"}],v0=(n,e,t)=>{if(!n.has(t)){if(n.size<e.length){let r=Ne();n.forEach(i=>r.add(i)),e=e.filter(i=>!r.has(i))}n.set(t,Oc(e))}return n.get(t)},rc=(n,{colors:e=U0,colorMapping:t=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:s}={})=>{let o=!1,l=new Ms(n,s),c=new Le({props:{editable:a=>{let h=L.getState(a);return h.snapshot==null&&h.prevSnapshot==null}},key:L,state:{init:(a,h)=>({type:n,doc:n.doc,binding:l,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:t,permanentUserData:r}),apply:(a,h)=>{let f=a.getMeta(L);if(f!==void 0){h=Object.assign({},h);for(let u in f)h[u]=f[u]}return h.addToHistory=a.getMeta("addToHistory")!==!1,h.isChangeOrigin=f!==void 0&&!!f.isChangeOrigin,h.isUndoRedoOperation=f!==void 0&&!!f.isChangeOrigin&&!!f.isUndoRedoOperation,l.prosemirrorView!==null&&f!==void 0&&(f.snapshot!=null||f.prevSnapshot!=null)&&lo(0,()=>{l.prosemirrorView!=null&&(f.restore==null?l._renderSnapshot(f.snapshot,f.prevSnapshot,h):(l._renderSnapshot(f.snapshot,f.snapshot,h),delete h.restore,delete h.snapshot,delete h.prevSnapshot,l.mux(()=>{l._prosemirrorChanged(l.prosemirrorView.state.doc)})))}),h}},view:a=>(l.initView(a),s==null&&l._forceRerender(),i(),{update:()=>{let h=c.getState(a.state);if(h.snapshot==null&&h.prevSnapshot==null&&(o||a.state.doc.content.findDiffStart(a.state.doc.type.createAndFill().content)!==null)){if(o=!0,h.addToHistory===!1&&!h.isChangeOrigin){let f=Pe.getState(a.state),u=f&&f.undoManager;u&&u.stopCapturing()}l.mux(()=>{h.doc.transact(f=>{f.meta.set("addToHistory",h.addToHistory),l._prosemirrorChanged(a.state.doc)},L)})}},destroy:()=>{l.destroy()}})});return c},L0=(n,e,t)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")n.setSelection(new oe(n.doc));else if(e.type==="node"){let r=Es(t.doc,t.type,e.anchor,t.mapping);n.setSelection(S.create(n.doc,r))}else{let r=Es(t.doc,t.type,e.anchor,t.mapping),i=Es(t.doc,t.type,e.head,t.mapping);if(r!==null&&i!==null){let s=I.between(n.doc.resolve(r),n.doc.resolve(i));n.setSelection(s)}}},Jr=(n,e)=>({type:e.selection.jsonID,anchor:nc(e.selection.anchor,n.type,n.mapping),head:nc(e.selection.head,n.type,n.mapping)}),Ms=class{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=ku(),this.mapping=t,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=Jr(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(er&&this._domSelectionInView===null&&(lo(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){let e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;let t=this.prosemirrorView._root.createRange();t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),t.getClientRects().length===0&&t.startContainer&&t.collapsed&&t.selectNodeContents(t.startContainer);let i=t.getBoundingClientRect(),s=We.documentElement;return i.bottom>=0&&i.right>=0&&i.left<=(window.innerWidth||s.clientWidth||0)&&i.top<=(window.innerHeight||s.clientHeight||0)}renderSnapshot(e,t){t||(t=qi(Pi(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(L,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{let e=this.type.toArray().map(r=>Os(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new b(x.from(e),0,0));t.setMeta(L,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(t)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{let e=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,t=this.type.toArray().map(i=>Os(i,this.prosemirrorView.state.schema,this)).filter(i=>i!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new b(x.from(t),0,0));if(e){let i=Je(Ie(e.anchor,0),r.doc.content.size),s=Je(Ie(e.head,0),r.doc.content.size);r.setSelection(I.create(r.doc,i,s))}this.prosemirrorView.dispatch(r.setMeta(L,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,r){let i=this.doc,s=this.type;if(e||(e=Ji(this.doc)),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&q(),i=new Se({gc:!1}),zi(i,t),t=Ji(i),zi(i,e),e=Ji(i),s._item===null){let o=Array.from(this.doc.share.keys()).find(l=>this.doc.share.get(l)===this.type);s=i.getXmlFragment(o)}else{let o=i.store.clients.get(s._item.id.client)??[],l=Ce(o,s._item.id.clock);s=o[l].content.type}this.mapping.clear(),this.mux(()=>{i.transact(o=>{let l=r.permanentUserData;l&&l.dss.forEach(f=>{je(o,f,u=>{})});let c=(f,u)=>{let d=f==="added"?l.getUserByClientId(u.client):l.getUserByDeletedId(u);return{user:d,type:f,color:v0(r.colorMapping,r.colors,d)}},a=$o(s,new wn(t.ds,e.sv)).map(f=>!f._item.deleted||qr(f._item,e)||qr(f._item,t)?Os(f,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,t,c):null).filter(f=>f!==null),h=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new b(x.from(a),0,0));this.prosemirrorView.dispatch(h.setMeta(L,{isChangeOrigin:!0}))},L)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let r=L.getState(this.prosemirrorView.state);if(e.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}this.mux(()=>{let i=(l,c)=>this.mapping.delete(c);je(t,t.deleteSet,l=>{if(l.constructor===_){let c=l.content.type;c&&this.mapping.delete(c)}}),t.changed.forEach(i),t.changedParentTypes.forEach(i);let s=this.type.toArray().map(l=>Eu(l,this.prosemirrorView.state.schema,this)).filter(l=>l!==null),o=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new b(x.from(s),0,0));L0(o,this.beforeTransactionSelection,this),o=o.setMeta(L,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof kn}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&o.scrollIntoView(),this.prosemirrorView.dispatch(o)})}_prosemirrorChanged(e){this.doc.transact(()=>{Ns(this.doc,this.type,e,this),this.beforeTransactionSelection=Jr(this,this.prosemirrorView.state)},L)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}},Eu=(n,e,t,r,i,s)=>{let o=t.mapping.get(n);if(o===void 0){if(n instanceof H)return Os(n,e,t,r,i,s);throw se()}return o},Os=(n,e,t,r,i,s)=>{let o=[],l=c=>{if(c instanceof H){let a=Eu(c,e,t,r,i,s);a!==null&&o.push(a)}else{let a=c._item.right?.content?.type;a instanceof Ke&&!a._item.deleted&&a._item.id.client===a.doc.clientID&&(c.applyDelta([{retain:c.length},...a.toDelta()]),a.doc.transact(f=>{a._item.delete(f)}));let h=F0(c,e,t,r,i,s);h!==null&&h.forEach(f=>{f!==null&&o.push(f)})}};r===void 0||i===void 0?n.toArray().forEach(l):$o(n,new wn(i.ds,r.sv)).forEach(l);try{let c=n.getAttributes(r);r!==void 0&&(qr(n._item,r)?qr(n._item,i)||(c.ychange=s?s("added",n._item.id):{type:"added"}):c.ychange=s?s("removed",n._item.id):{type:"removed"});let a=e.node(n.nodeName,c,o);return t.mapping.set(n,a),a}catch{return n.doc.transact(a=>{n._item.delete(a)},L),t.mapping.delete(n),null}},F0=(n,e,t,r,i,s)=>{let o=[],l=n.toDelta(r,i,s);try{for(let c=0;c<l.length;c++){let a=l[c];o.push(e.text(a.insert,W0(a.attributes,e)))}}catch{return n.doc.transact(a=>{n._item.delete(a)},L),null}return o},P0=(n,e)=>{let t=new pe,r=n.map(i=>({insert:i.text,attributes:Nu(i.marks,e)}));return t.applyDelta(r),e.mapping.set(t,n),t},z0=(n,e)=>{let t=new H(n.type.name);for(let r in n.attrs){let i=n.attrs[r];i!==null&&r!=="ychange"&&t.setAttribute(r,i)}return t.insert(0,Is(n).map(r=>ec(r,e))),e.mapping.set(t,n),t},ec=(n,e)=>n instanceof Array?P0(n,e):z0(n,e),Du=n=>typeof n=="object"&&n!==null,ic=(n,e)=>{let t=Object.keys(n).filter(i=>n[i]!==null),r=t.length===(e==null?0:Object.keys(e).filter(i=>e[i]!==null).length);for(let i=0;i<t.length&&r;i++){let s=t[i],o=n[s],l=e[s];r=s==="ychange"||o===l||Du(o)&&Du(l)&&ic(o,l)}return r},Is=n=>{let e=n.content.content,t=[];for(let r=0;r<e.length;r++){let i=e[r];if(i.isText){let s=[];for(let o=e[r];r<e.length&&o.isText;o=e[++r])s.push(o);r--,t.push(s)}else t.push(i)}return t},Mu=(n,e)=>{let t=n.toDelta();return t.length===e.length&&t.every((r,i)=>r.insert===e[i].text&&Ws(r.attributes||{}).length===e[i].marks.length&&st(r.attributes,(s,o)=>{let l=Au(o),c=e[i].marks;return ic(s,c.find(a=>a.type.name===l)?.attrs)}))},Wr=(n,e)=>{if(n instanceof H&&!(e instanceof Array)&&tc(n,e)){let t=Is(e);return n._length===t.length&&ic(n.getAttributes(),e.attrs)&&n.toArray().every((r,i)=>Wr(r,t[i]))}return n instanceof pe&&e instanceof Array&&Mu(n,e)},As=(n,e)=>n===e||n instanceof Array&&e instanceof Array&&n.length===e.length&&n.every((t,r)=>e[r]===t),Ou=(n,e,t)=>{let r=n.toArray(),i=Is(e),s=i.length,o=r.length,l=Je(o,s),c=0,a=0,h=!1;for(;c<l;c++){let f=r[c],u=i[c];if(As(t.mapping.get(f),u))h=!0;else if(!Wr(f,u))break}for(;c+a<l;a++){let f=r[o-a-1],u=i[s-a-1];if(As(t.mapping.get(f),u))h=!0;else if(!Wr(f,u))break}return{equalityFactor:c+a,foundMappedChild:h}},$0=n=>{let e="",t=n._start,r={};for(;t!==null;)t.deleted||(t.countable&&t.content instanceof _e?e+=t.content.str:t.content instanceof v&&(r[t.content.key]=null)),t=t.right;return{str:e,nAttrs:r}},q0=(n,e,t)=>{t.mapping.set(n,e);let{nAttrs:r,str:i}=$0(n),s=e.map(a=>({insert:a.text,attributes:Object.assign({},r,Nu(a.marks,t))})),{insert:o,remove:l,index:c}=Su(i,s.map(a=>a.insert).join(""));n.delete(c,l),n.insert(c,o),n.applyDelta(s.map(a=>({retain:a.insert.length,attributes:a.attributes})))},J0=/(.*)(--[a-zA-Z0-9+/=]{8})$/,Au=n=>J0.exec(n)?.[1]??n,W0=(n,e)=>{let t=[];for(let r in n)t.push(e.mark(Au(r),n[r]));return t},Nu=(n,e)=>{let t={};return n.forEach(r=>{if(r.type.name!=="ychange"){let i=we(e.isOMark,r.type,()=>!r.type.excludes(r.type));t[i?`${r.type.name}--${Tu(r.toJSON())}`:r.type.name]=r.attrs}}),t},Ns=(n,e,t,r)=>{if(e instanceof H&&e.nodeName!==t.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,t),e instanceof H){let f=e.getAttributes(),u=t.attrs;for(let d in u)u[d]!==null?f[d]!==u[d]&&d!=="ychange"&&e.setAttribute(d,u[d]):e.removeAttribute(d);for(let d in f)u[d]===void 0&&e.removeAttribute(d)}let i=Is(t),s=i.length,o=e.toArray(),l=o.length,c=Je(s,l),a=0,h=0;for(;a<c;a++){let f=o[a],u=i[a];if(!As(r.mapping.get(f),u))if(Wr(f,u))r.mapping.set(f,u);else break}for(;h+a<c;h++){let f=o[l-h-1],u=i[s-h-1];if(!As(r.mapping.get(f),u))if(Wr(f,u))r.mapping.set(f,u);else break}n.transact(()=>{for(;l-a-h>0&&s-a-h>0;){let u=o[a],d=i[a],p=o[l-h-1],m=i[s-h-1];if(u instanceof pe&&d instanceof Array)Mu(u,d)||q0(u,d,r),a+=1;else{let g=u instanceof H&&tc(u,d),y=p instanceof H&&tc(p,m);if(g&&y){let k=Ou(u,d,r),w=Ou(p,m,r);k.foundMappedChild&&!w.foundMappedChild?y=!1:!k.foundMappedChild&&w.foundMappedChild||k.equalityFactor<w.equalityFactor?g=!1:y=!1}g?(Ns(n,u,d,r),a+=1):y?(Ns(n,p,m,r),h+=1):(r.mapping.delete(e.get(a)),e.delete(a,1),e.insert(a,[ec(d,r)]),a+=1)}}let f=l-a-h;if(l===1&&s===0&&o[0]instanceof pe?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):f>0&&(e.slice(a,a+f).forEach(u=>r.mapping.delete(u)),e.delete(a,f)),a+h<s){let u=[];for(let d=a;d<s-h;d++)u.push(ec(i[d],r));e.insert(a,u)}},L)},tc=(n,e)=>!(e instanceof Array)&&n.nodeName===e.type.name;var nc=(n,e,t)=>{if(n===0)return $i(e,0,e.length===0?-1:0);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof pe){if(r._length>=n)return $i(r,n,e.length===0?-1:0);if(n-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,n--;while(r!==e&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==e&&(r=r._item===null?null:r._item.next.content.type)}}else{let i=(t.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&n<i)r=r._first.content.type,n--;else{if(n===1&&r._length===0&&i>1)return new Ot(r._item===null?null:r._item.id,r._item===null?Tn(r):null,null);if(n-=i,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(n===0)return r=r._item===null?r:r._item.parent,new Ot(r._item===null?null:r._item.id,r._item===null?Tn(r):null,null);do r=r._item.parent,n--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw q();if(n===0&&r.constructor!==pe&&r!==e)return j0(r._item.parent,r._item)}return $i(e,e._length,e.length===0?-1:0)},j0=(n,e)=>{let t=null,r=null;return n._item===null?r=Tn(n):t=C(n._item.id.client,n._item.id.clock),new Ot(t,r,e.id)},Es=(n,e,t,r)=>{let i=Ia(t,n);if(i===null||i.type!==e&&!bn(e,i.type._item))return null;let s=i.type,o=0;if(s.constructor===pe)o=i.index;else if(s._item===null||!s._item.deleted){let l=s._first,c=0;for(;c<s._length&&c<i.index&&l!==null;){if(!l.deleted){let a=l.content.type;c++,a instanceof pe?o+=a._length:o+=r.get(a).nodeSize}l=l.right}o+=1}for(;s!==e&&s._item!==null;){let l=s._item.parent;if(l._item===null||!l._item.deleted){o+=1;let c=l._first;for(;c!==null;){let a=c.content.type;if(a===s)break;c.deleted||(a instanceof pe?o+=a._length:o+=r.get(a).nodeSize),c=c.right}}s=l}return o-1};var sc=n=>Pe.getState(n)?.undoManager?.undo()!=null,_s=n=>Pe.getState(n)?.undoManager?.redo()!=null,Iu=(n,e)=>e==null?Pe.getState(n)?.undoManager?.canUndo():sc(n),_u=(n,e)=>e==null?Pe.getState(n)?.undoManager?.canRedo():_s(n),K0=new Set(["paragraph"]),Y0=(n,e)=>!(n instanceof _)||!(n.content instanceof Te)||!(n.content.type instanceof Ke||n.content.type instanceof H&&e.has(n.content.type.nodeName))||n.content.type._length===0,Ru=({protectedNodes:n=K0,trackedOrigins:e=[],undoManager:t=null}={})=>new Le({key:Pe,state:{init:(r,i)=>{let s=L.getState(i),o=t||new kn(s.type,{trackedOrigins:new Set([L].concat(e)),deleteFilter:l=>Y0(l,n),captureTransaction:l=>l.meta.get("addToHistory")!==!1});return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(r,i,s,o)=>{let l=L.getState(o).binding,c=i.undoManager,a=c.undoStack.length>0,h=c.redoStack.length>0;return l?{undoManager:c,prevSel:Jr(l,s),hasUndoOps:a,hasRedoOps:h}:a!==i.hasUndoOps||h!==i.hasRedoOps?Object.assign({},i,{hasUndoOps:c.undoStack.length>0,hasRedoOps:c.redoStack.length>0}):i}},view:r=>{let i=L.getState(r.state),s=Pe.getState(r.state).undoManager;return s.on("stack-item-added",({stackItem:o})=>{let l=i.binding;l&&o.meta.set(l,Pe.getState(r.state).prevSel)}),s.on("stack-item-popped",({stackItem:o})=>{let l=i.binding;l&&(l.beforeTransactionSelection=o.meta.get(l)||l.beforeTransactionSelection)}),{destroy:()=>{s.destroy()}}}});function Bu({post:n,mergeUpdates:e,onStatus:t,debounceMs:r=2e3,setTimeoutFn:i=setTimeout}){let s=[],o=null,l=null,c="ok";function a(p){c==="failed"&&p!=="failed"||(c=p,t&&t(c))}function h(){l||(l=i(f,r))}async function f(){if(l=null,!s.length)return;let p=e(s);s=[],o=p;let m;try{m=await n(p)}catch{o=null,s.unshift(p),a("retrying"),h();return}if(o=null,m.ok){a("ok");return}if(m.status>=400&&m.status<500){a("failed");return}s.unshift(p),a("retrying"),h()}function u(p){s.push(p),!l&&(l=i(f,r))}function d(){let p=[];return o&&p.push(o),s.length&&p.push(e(s)),p.length?p.length===1?p[0]:e(p):null}return{enqueue:u,flush:f,pendingBytes:d,get status(){return c}}}function Vu({attemptResync:n,onDiverged:e,onRecovered:t,backoffMs:r=l=>Math.min(1e3*2**(l-1),3e4),setTimeoutFn:i=setTimeout,clearTimeoutFn:s=clearTimeout,addOnlineListener:o=l=>addEventListener("online",l)}){let l=!1,c=!1,a=0,h=null;function f(){a++,h&&s(h),h=i(u,r(a))}async function u(){if(h&&(s(h),h=null),!(!l||c)){c=!0;try{await n(),l=!1,a=0,t&&t()}catch{f()}finally{c=!1}}}function d(){l||(l=!0,a=0,e&&e()),u()}return o(()=>{l&&u()}),{reportDivergence:d,get diverged(){return l},get resyncing(){return c}}}function Uu(n,e){if(!n||e.length===0)return{ensureReachable(){}};let t=()=>e.filter(s=>!s.disabled);function r(s){for(let o of e)o.tabIndex=o===s?0:-1}function i(){let s=t();s.length!==0&&(s.some(o=>o.tabIndex===0)||r(s[0]))}return n.addEventListener("keydown",s=>{let o=s.key;if(o!=="ArrowRight"&&o!=="ArrowLeft"&&o!=="Home"&&o!=="End")return;let l=t(),c=l.indexOf(document.activeElement);if(c<0||l.length===0)return;let a;o==="Home"?a=l[0]:o==="End"?a=l[l.length-1]:o==="ArrowRight"?a=l[(c+1)%l.length]:a=l[(c-1+l.length)%l.length],s.preventDefault(),r(a),a.focus()}),n.addEventListener("focusin",s=>{e.includes(s.target)&&r(s.target)}),i(),{ensureReachable:i}}var vu=["font_sans","font_mono"],Lu=["size_sm","size_lg","size_xl"];function $u({root:n,schema:e,getView:t}){if(!n)return{plugin:null};let r=Array.from(n.querySelectorAll("[data-docs-command]")),i=Array.from(n.querySelectorAll("[data-docs-select]")),s=H0(e);for(let a of r)a.addEventListener("mousedown",h=>h.preventDefault()),a.addEventListener("click",()=>{let h=t(),f=s[a.getAttribute("data-docs-command")];!h||!f||(f(h.state,h.dispatch,h),h.focus())});for(let a of i)a.addEventListener("mousedown",h=>h.stopPropagation()),a.addEventListener("change",()=>{let h=t();if(!h)return;let f=a.getAttribute("data-docs-select"),u=a.value;f==="block"&&G0(e,u)(h.state,h.dispatch),f==="font"&&Fu(e,vu,u==="serif"?null:"font_"+u)(h.state,h.dispatch),f==="size"&&Fu(e,Lu,u==="normal"?null:"size_"+u)(h.state,h.dispatch),h.focus()});function o(a){let h=a.state;for(let f of r){let u=f.getAttribute("data-docs-command"),d=s[u];if(!d)continue;let p=d(h,null,a);f.disabled=!p;let m=Z0(h,e,u);f.setAttribute("aria-pressed",m?"true":"false")}for(let f of i){f.disabled=!1;let u=f.getAttribute("data-docs-select");u==="block"&&(f.value=Q0(h)),u==="font"&&(f.value=zu(h,e,vu,"font_","serif")),u==="size"&&(f.value=zu(h,e,Lu,"size_","normal"))}}let l=Uu(n,[...r,...i]);return{plugin:new Le({view:a=>(o(a),l.ensureReachable(),{update:h=>{o(h),l.ensureReachable()}})})}}function H0(n){let e=n.marks,t=n.nodes;return{undo:Iu,redo:_u,strong:Yt(e.strong),em:Yt(e.em),code:Yt(e.code),bullet_list:Pu(t.bullet_list,t.list_item),ordered_list:Pu(t.ordered_list,t.list_item),blockquote:X0(t.blockquote)}}function G0(n,e){if(e==="paragraph")return Xl(n.nodes.paragraph);let t=Number(e.split("-")[1]);return Number.isInteger(t)?Xl(n.nodes.heading,{level:t}):()=>!1}function Fu(n,e,t){return(r,i)=>{let s=e.map(f=>n.marks[f]).filter(Boolean),o=t?n.marks[t]:null;if(t&&!o)return!1;if(!i)return!0;let{from:l,to:c,empty:a}=r.selection;if(a){let f=(r.storedMarks||r.selection.$from.marks()).filter(u=>!s.includes(u.type));return o&&(f=o.create().addToSet(f)),i(r.tr.setStoredMarks(f)),!0}let h=r.tr;for(let f of s)h.removeMark(l,c,f);return o&&h.addMark(l,c,o.create()),i(h),!0}}function Pu(n,e){let t=cu(n),r=au(e);return(i,s,o)=>jr(i,n)?r(i,s,o):t(i,s,o)}function X0(n){let e=xu(n);return(t,r,i)=>jr(t,n)?mu(t,r,i):e(t,r,i)}function jr(n,e){let t=n.selection.$from;for(let r=t.depth;r>0;r--)if(t.node(r).type===e)return!0;return!1}function Z0(n,e,t){if(t==="bullet_list")return jr(n,e.nodes.bullet_list);if(t==="ordered_list")return jr(n,e.nodes.ordered_list);if(t==="blockquote")return jr(n,e.nodes.blockquote);let r=e.marks[t];return r?qu(n,r):!1}function qu(n,e){let{from:t,$from:r,to:i,empty:s}=n.selection;return s?!!e.isInSet(n.storedMarks||r.marks()):n.doc.rangeHasMark(t,i,e)}function Q0(n){let e=n.selection.$from.parent;return e.type.name==="heading"?"heading-"+e.attrs.level:"paragraph"}function zu(n,e,t,r,i){for(let s of t){let o=e.marks[s];if(o&&qu(n,o))return s.slice(r.length)}return i}function oc(n,{since:e,raw:t}={}){let r=[];return e!==void 0&&r.push(`since=${e}`),t&&r.push("raw=1"),r.length?`${n}?${r.join("&")}`:n}function Ju({initialSeq:n=0,openStream:e,fetchSince:t,onUpdates:r,onError:i=()=>{},setTimeoutFn:s=setTimeout,clearTimeoutFn:o=clearTimeout,idleMs:l=12e4}){let c=n,a=null,h=null,f=!1,u=!1,d=!1;function p(){h!==null&&o(h),h=s(()=>{h=null,m()},l)}function m(){h!==null&&(o(h),h=null),a&&(a.close(),a=null)}function g(){f||a||(a=e(k=>{p(),k>c&&y()},k=>{m(),i(k)}),p())}async function y(){if(u){d=!0;return}u=!0;try{let k=c,w=await t(k);if(f)return;try{w&&w.bytes&&w.bytes.length&&r(w.bytes)}catch{if(w=await t(k,{raw:!0}),f)return;w&&w.bytes&&w.bytes.length&&r(w.bytes)}w&&typeof w.seq=="number"&&w.seq>c&&(c=w.seq)}catch(k){i(k)}finally{u=!1,d&&!f&&(d=!1,y())}}return{start(){f=!1,g()},stop(){f=!0,m()},noteOwnSeq(k){typeof k!="number"||!Number.isFinite(k)||k===c+1&&(c=k)},noteActivity(){f||(a?p():g())},noteHidden(){m()},get cursor(){return c},get streaming(){return a!==null}}}function Kr(n,e){return{group:e,excludes:e,parseDOM:[{tag:"span."+n}],toDOM:()=>["span",{class:n},0]}}var ex=Wl.spec.marks.addToStart("size_xl",Kr("docs-size-xl","fontSize")).addToStart("size_lg",Kr("docs-size-lg","fontSize")).addToStart("size_sm",Kr("docs-size-sm","fontSize")).addToStart("font_mono",Kr("docs-font-mono","fontFamily")).addToStart("font_sans",Kr("docs-font-sans","fontFamily")),Rs=new En({nodes:lu(Wl.spec.nodes,"paragraph block*","block"),marks:ex}),tx=250;function lc(n,e){if(!e.length)return;let t=ln(e);for(;ii(t);)Aa(t,n,"server")}async function nx(n){let e=n.getAttribute("data-sqid"),t=`/d/${e}/updates`,r=`/d/${e}/stream`,i=document.querySelector("[docs-save-status]"),s=!1,o=null,l=null,c=null,a=$u({root:document.querySelector("[docs-toolbar]"),schema:Rs,getView:()=>l});function h(D){i&&i.setAttribute("data-state",s?"failed":D)}function f(D){return Bu({post:async A=>{let R=await fetch(t,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/octet-stream"},body:A}),T=D();if(R.ok&&T){let B=Number(R.headers.get("Docs-Seq"));Number.isFinite(B)&&T.noteOwnSeq(B)}return R},mergeUpdates:Va,debounceMs:tx,onStatus:A=>{A==="failed"&&(s=!0,g.reportDivergence()),h(A)}})}function u(D){let A=l;if(!A||D.button!==0||A.dom.contains(D.target))return;let R=A.dom.getBoundingClientRect(),T=A.posAtCoords({left:Math.min(Math.max(D.clientX,R.left+1),R.right-1),top:Math.min(Math.max(D.clientY,R.top+1),R.bottom-1)}),B=T?T.pos:A.state.doc.content.size,$=E.near(A.state.doc.resolve(B));D.preventDefault(),A.dispatch(A.state.tr.setSelection($).scrollIntoView()),A.focus()}function d(D,A){let R=[rc(A),Ru(),Yl({"Mod-z":sc,"Mod-y":_s,"Mod-Shift-z":_s,"Mod-b":Yt(Rs.marks.strong),"Mod-i":Yt(Rs.marks.em)}),Yl(wu)];return a.plugin&&R.push(a.plugin),new Lr({mount:D},{state:fs.create({schema:Rs,plugins:R})})}async function p(D){let A=oc(t,{raw:D}),R=await fetch(A,{credentials:"same-origin"});if(!R.ok)throw new Error(`load ${A}: ${R.status}`);return{log:new Uint8Array(await R.arrayBuffer()),startSeq:Number(R.headers.get("Docs-Seq"))}}async function m(){let{log:D,startSeq:A}=await p(!1),R=new Se;try{lc(R,D)}catch{({log:D,startSeq:A}=await p(!0)),R=new Se,lc(R,D)}let T=R.getXmlFragment("prosemirror"),B=null,$=f(()=>B);R.on("update",(be,Fn)=>{Fn!=="server"&&(g.diverged||$.enqueue(be))}),l&&l.destroy(),o=$,l=d(n,T),c&&c.stop(),B=Ju({initialSeq:Number.isFinite(A)?A:0,openStream:(be,Fn)=>{let Ht=new EventSource(r,{withCredentials:!0});return Ht.addEventListener("update",nt=>be(Number(nt.data))),Ht.addEventListener("error",nt=>Fn(nt)),{close:()=>Ht.close()}},fetchSince:async(be,{raw:Fn}={})=>{let Ht=oc(t,{since:be,raw:Fn}),nt=await fetch(Ht,{credentials:"same-origin"});if(!nt.ok)throw new Error(`fetch ${Ht}: ${nt.status}`);return{bytes:new Uint8Array(await nt.arrayBuffer()),seq:Number(nt.headers.get("Docs-Seq"))}},onUpdates:be=>{g.diverged||lc(R,be)},onError:be=>{console.error("live updates:",be)}}),c=B,c.start(),typeof document<"u"&&document.hidden&&c.noteHidden()}let g=Vu({attemptResync:m,onDiverged:()=>h("failed"),onRecovered:()=>h(s?"failed":"ok")});await m(),addEventListener("visibilitychange",()=>{document.hidden?c&&c.noteHidden():c&&c.noteActivity()});for(let D of["pointermove","scroll","keydown","focus"])addEventListener(D,()=>c&&c.noteActivity(),{passive:!0,capture:!0});let y=n.closest("[docs-page]");y&&y.addEventListener("mousedown",u);let k=!1,w=()=>{k=!0,setTimeout(()=>{k=!1},0)};return document.addEventListener("mousedown",w,!0),document.addEventListener("touchstart",w,!0),n.addEventListener("focus",()=>{if(k)return;let D=l;D&&D.dispatch(D.state.tr.scrollIntoView())}),addEventListener("beforeunload",()=>{let D=o&&o.pendingBytes();if(!D)return;let A=new Blob([D],{type:"application/octet-stream"});navigator.sendBeacon(t,A)||(console.error("beforeunload: sendBeacon refused the pending edit, retrying via keepalive fetch"),fetch(t,{method:"POST",credentials:"same-origin",keepalive:!0,headers:{"Content-Type":"application/octet-stream"},body:D}).catch(()=>{}))}),l}var cc=document.querySelector("[docs-editor]");cc&&nx(cc).catch(n=>{cc.setAttribute("data-editor-failed","1"),console.error(n)});export{nx as mountEditor}; |