oficina / docs Public

I2 C2: roving reaches only drawn controls; re-checks on resize

A closed inspector hides its controls without disabling them, so a tab
stop or Escape could land on a display:none control. reachable() now
needs the control drawn (checkVisibility), a ResizeObserver re-runs
ensureReachable when the bar's layout changes, and focusStop reports
false when nothing is drawn. The browser test comes with the inspector.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev f208b1628930e3a50f3cc8892376cbd03e730ace parent d107668
2 files changed, +18 −2
  • fixtures/toolbar-roving.mjs +17 −1
  • internal/docs/static/{editor.6798b18f8e565047.js => editor.e0530d6ce60b5b4e.js} +1 −1

CI passed — run details

diff --git a/fixtures/toolbar-roving.mjs b/fixtures/toolbar-roving.mjs
index ecef137..1d9fe8c 100644
--- a/fixtures/toolbar-roving.mjs
+++ b/fixtures/toolbar-roving.mjs
@@ -36,7 +36,18 @@
export function setupRoving(root, controls) {
if (!root || controls.length === 0) return { ensureReachable() {}, focusStop() { return false } }
- const reachable = () => controls.filter((c) => !c.disabled)
+ // Reachable is enabled AND drawn. From 64rem the bar is the
+ // inspector, which the person can close, and a closed inspector's
+ // controls are display: none but still in this list: a tab stop
+ // parked on one, or Escape focusing one, sends focus nowhere (spec
+ // I2, revision 2.1's C2). checkVisibility where the engine has it;
+ // otherwise a control with no boxes is not drawn.
+ const drawn = (c) => {
+ if (typeof c.checkVisibility === 'function') return c.checkVisibility()
+ if (typeof c.getClientRects === 'function') return c.getClientRects().length > 0
+ return true // no layout to ask (the node tests' DOM)
+ }
+ const reachable = () => controls.filter((c) => !c.disabled && drawn(c))
function setStop(target) {
for (const c of controls) c.tabIndex = c === target ? 0 : -1
@@ -82,6 +93,9 @@ export function setupRoving(root, controls) {
})
ensureReachable()
+ // Showing or hiding the inspector, or crossing its breakpoint, changes
+ // what is drawn without enabling or disabling anything.
+ if (typeof ResizeObserver === 'function') new ResizeObserver(() => ensureReachable()).observe(root)
// focusStop moves focus onto the bar's current tab stop, and reports
// whether it managed to.
//
@@ -92,6 +106,8 @@ export function setupRoving(root, controls) {
// the person is told, but "you can only leave backwards" is a poor
// thing to have to tell them, so Escape leaves forwards onto the
// nearest chrome instead.
+ // With nothing drawn (the inspector closed) it reports false, and
+ // Escape in the editor stays where it is (editor-entry.js).
function focusStop() {
const list = reachable()
if (list.length === 0) return false
diff --git a/internal/docs/static/editor.6798b18f8e565047.js b/internal/docs/static/editor.e0530d6ce60b5b4e.js
similarity index 90%
rename from internal/docs/static/editor.6798b18f8e565047.js
rename to internal/docs/static/editor.e0530d6ce60b5b4e.js
index 79646e5..47702ea 100644
--- a/internal/docs/static/editor.6798b18f8e565047.js
+++ b/internal/docs/static/editor.e0530d6ce60b5b4e.js
@@ -11,4 +11,4 @@ ${t.toString()}`)},gl=class{constructor(e){this.patterns=[],this.$state=e}if(e,t
`);return{dom:a,text:h,slice:e}}function Ad(n,e,t,r,i){let s=i.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=!!e&&(r||s||!t);if(a){if(n.someProp("transformPastedText",h=>{e=h(e,s||r,n)}),s)return l=new S(x.from(n.state.schema.text(e.replace(/\r\n?/g,`
`))),0,0),n.someProp("transformPasted",h=>{l=h(l,n,!0)}),l;let u=n.someProp("clipboardTextParser",h=>h(e,i,r,n));if(u)l=u;else{let h=i.marks(),{schema:d}=n.state,p=pn.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,h)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),o=Ox(t),Ri&&Nx(o);let c=o&&o.querySelector("[data-pm-slice]"),f=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let u=+f[3];u>0;u--){let h=o.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;o=h}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||mi.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||f),context:i,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!Tx.test(h.parentNode.nodeName)?{ignore:!0}:null}})),f)l=Ix(ed(l,+f[1],+f[2]),f[4]);else if(l=S.maxOpen(Ax(l.content,i),!0),l.openStart||l.openEnd){let u=0,h=0;for(let d=l.content.firstChild;u<l.openStart&&!d.type.spec.isolating;u++,d=d.firstChild);for(let d=l.content.lastChild;h<l.openEnd&&!d.type.spec.isolating;h++,d=d.lastChild);l=ed(l,u,h)}return n.someProp("transformPasted",u=>{l=u(l,n,a)}),l}var Tx=/^(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 Ax(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 a=i.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&s.length&&Od(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=Nd(o[o.length-1],s.length));let f=Dd(l,a);o.push(f),i=i.matchType(f.type),s=a}}),o)return x.from(o)}return n}function Dd(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,x.from(n));return n}function Od(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=Od(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(Dd(t,n,i+1))))}}function Nd(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Nd(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(x.empty,!0);return n.copy(t.append(r))}function va(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=va(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 ed(n,e,t){return e<n.openStart&&(n=new S(va(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new S(va(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}var Id={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 _d(){return document.implementation.createHTMLDocument("title")}var Mi=null;function Dx(n){let e=window.trustedTypes;if(!e)return n;if(!Mi){if(Mi=e.defaultPolicy)try{return Mi.createHTML(n)}catch{}Mi=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})}return Mi.createHTML(n)}function Ox(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=_d(),r=t.body,i=/<([a-z][^>\s]+)/i.exec(n),s;if((s=i&&Id[i[1].toLowerCase()])&&(n=s.map(o=>"<"+o+">").join("")+n+s.map(o=>"</"+o+">").reverse().join("")),r.innerHTML=Dx(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 a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let f=r.querySelectorAll(c.selectorText);for(let u=0;u<f.length;u++)f[u].style.cssText+=c.style.cssText}}}return r}function Nx(n){let e=n.querySelectorAll(ce?"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 Ix(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 a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;try{a.checkAttrs(r[l+1])}catch{break}i=x.from(a.create(r[l+1],i)),s++,o++}return new S(i,s,o)}var Ee={},Me={},_x={touchstart:!0,touchmove:!0},Ba=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 Rx(n){for(let e in Ee){let t=Ee[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Bx(n,r)&&!ja(n,r)&&(n.editable||!(r.type in Me))&&t(n,r)},_x[e]?{passive:!0}:void 0)}we&&n.dom.addEventListener("input",()=>null),La(n)}function kt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function vx(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 La(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>ja(n,r))})}function ja(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Bx(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 Lx(n,e){!ja(n,e)&&Ee[e.type]&&(n.editable||!(e.type in Me))&&Ee[e.type](n,e)}Me.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Bd(n)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(St&&ce&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),br&&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,bn(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Mx(n,t)?t.preventDefault():kt(n,"key")};Me.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Me.keypress=(n,e)=>{let t=e;if(Bd(n)||!t.charCode||t.ctrlKey&&!t.altKey||$e&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof V)||!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 vi(n){return{left:n.clientX,top:n.clientY}}function Ux(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Ya(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 Bi(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 Vx(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&T.isSelectable(r)?(Bi(n,new T(t),"pointer"),!0):!1}function Fx(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof T&&(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(T.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?(Bi(n,T.create(n.state.doc,i),"pointer"),!0):!1}function Px(n,e,t,r,i){return Ya(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?Fx(n,t):Vx(n,t))}function zx(n,e,t,r){return Ya(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function $x(n,e,t,r){return Ya(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||qx(n,t,r)}function qx(n,e,t){if(t.button!=0)return!1;let r=Rd(n,e,!0),i=n.state.doc;return r?(Bi(n,r,"pointer"),r instanceof V&&i.eq(n.state.doc)&&(n.input.mouseDown=new Va(n,r)),!0):!1}function Rd(n,e,t){let r=n.state.doc;if(e==-1)return r.inlineContent?V.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 V.create(r,l+1,l+1+o.content.size);if(t&&T.isSelectable(o))return T.create(r,l)}return null}function Ka(n){return bo(n)}var vd=$e?"metaKey":"ctrlKey";Ee.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Ka(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&Ux(t,n.input.lastClick)&&!t[vd]&&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(vi(t));o&&(s=="singleClick"?n.input.mouseDown=new Ua(n,o,t,!!r):(s=="doubleClick"?zx:$x)(n,o.pos,o.inside,t)?t.preventDefault():kt(n,"pointer"))};var xo=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}},Ua=class extends xo{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[vd],this.allowDefault=r.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let f=e.state.doc.resolve(t.pos);s=f.parent,o=f.depth?f.before():0}let l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof T&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&We&&!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()),kt(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||Ct(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(vi(e))),this.updateAllowDefault(e),this.allowDefault||!t?kt(this.view,"pointer"):Px(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||we&&this.mightDrag&&!this.mightDrag.node.isAtom||ce&&!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)?(Bi(this.view,B.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):kt(this.view,"pointer")}move(e){this.updateAllowDefault(e),kt(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}},Va=class extends xo{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(),kt(this.view,"pointer");let t=this.view.posAtCoords(vi(e)),r=t&&Rd(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];Bi(this.view,V.create(i,o,l),"pointer")}};Ee.touchstart=n=>{n.input.lastTouch=Date.now(),Ka(n),kt(n,"pointer")};Ee.touchmove=n=>{n.input.lastTouch=Date.now(),kt(n,"pointer")};Ee.contextmenu=n=>Ka(n);function Bd(n,e){return n.composing?!0:we&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var Wx=St?5e3:-1;Me.compositionstart=Me.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof V&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ce&&dd&&Jx(n)))n.markCursor=n.state.storedMarks||t.marks(),bo(n,!0),n.markCursor=null;else if(bo(n,!e.selection.empty),We&&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}Ld(n,Wx)};function Jx(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"}Me.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++,Ld(n,20))};function Ld(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>bo(n),e))}function Ud(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function jx(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=q0(e.focusNode,e.focusOffset),r=W0(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 bo(n,e=!1){if(!(St&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Ud(n),e||n.docView&&n.docView.dirty){let t=qa(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 Yx(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 Di=_e&&Wt<15||br&&K0<604;Ee.copy=Me.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=Di?null:t.clipboardData,o=r.content(),{dom:l,text:a}=Ja(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Yx(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Kx(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Hx(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?Oi(n,r.value,null,i,e):Oi(n,r.textContent,r.innerHTML,i,e)},50)}function Oi(n,e,t,r,i){let s=Ad(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,s||S.empty)))return!0;if(!s)return!1;let o=Kx(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 Vd(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," "):""}Me.paste=(n,e)=>{let t=e;if(n.composing&&!St)return;let r=Di?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Oi(n,Vd(r),r.getData("text/html"),i,t)?t.preventDefault():Hx(n,t)};var wo=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},Gx=$e?"altKey":"ctrlKey";function Fd(n,e){let t;return n.someProp("dragCopies",r=>{t=t||r(e)}),t!=null?!t:!e[Gx]}Ee.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(vi(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof T?i.to-1:i.to))){if(r&&r.mightDrag)o=T.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(o=T.create(n.state.doc,u.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:c,slice:f}=Ja(n,l);(!t.dataTransfer.files.length||!ce||hd>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Di?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Di||t.dataTransfer.setData("text/plain",c),n.dragging=new wo(f,Fd(n,t),o)};Ee.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Me.dragover=Me.dragenter=(n,e)=>e.preventDefault();Me.drop=(n,e)=>{try{Xx(n,e,n.dragging)}finally{n.dragging=null}};function Xx(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(vi(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=Ad(n,Vd(e.dataTransfer),Di?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(t&&Fd(n,e));if(n.someProp("handleDrop",d=>d(n,e,s||S.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?kh(n.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let a=n.state.tr;if(o){let{node:d}=t;d?d.replace(a):a.deleteSelection()}let c=a.mapping.map(l),f=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,u=a.doc;if(f?a.replaceRangeWith(c,c,s.content.firstChild):a.replaceRange(c,c,s),a.doc.eq(u))return;let h=a.doc.resolve(c);if(f&&T.isSelectable(s.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(s.content.firstChild))a.setSelection(new T(h));else{let d=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,g,y)=>d=y),a.setSelection(Wa(n,h,a.doc.resolve(d)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}Ee.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())&&Ct(n)},20))};Ee.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)};Ee.beforeinput=(n,e)=>{if(St&&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,bn(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 Me)Ee[n]=Me[n];function Ni(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 So=class n{constructor(e,t){this.toDOM=e,this.spec=t||En,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 st(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&&Ni(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Cn=class n{constructor(e,t){this.attrs=e,this.spec=t||En}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 st(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof n&&Ni(this.attrs,e.attrs)&&Ni(this.spec,e.spec)}static is(e){return e.type instanceof n}destroy(){}},Fa=class n{constructor(e,t){this.attrs=e,this.spec=t||En}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 st(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&&Ni(this.attrs,e.attrs)&&Ni(this.spec,e.spec)}destroy(){}},st=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 So(t,r))}static inline(e,t,r,i){return new n(e,t,new Cn(r,i))}static node(e,t,r,i){return new n(e,t,new Fa(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Cn}get widget(){return this.type instanceof So}},yr=[],En={},be=class n{constructor(e,t){this.local=e.length?e:yr,this.children=t.length?t:yr}static create(e,t){return t.length?Co(t,e,0,En):xe}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==xe||e.maps.length==0?this:this.mapInner(e,t,0,0,r||En)}mapInner(e,t,r,i,s){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,i);a&&a.type.valid(t,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?Zx(this.children,o||[],e,t,r,i,s):o?new n(o.sort(Mn),yr):xe}add(e,t){return t.length?this==xe?n.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,s=0;e.forEach((l,a)=>{let c=a+r,f;if(f=zd(t,l,c)){for(i||(i=this.children.slice());s<i.length&&i[s]<a;)s+=3;i[s]==a?i[s+2]=i[s+2].addInner(l,f,c+1):i.splice(s,0,a,a+l.nodeSize,Co(f,l,c+1,En)),s+=3}});let o=Pd(s?$d(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(Mn):this.local,i||this.children)}remove(e){return e.length==0||this==xe?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,a=r[s+1]+t;for(let f=0,u;f<e.length;f++)(u=e[f])&&u.from>l&&u.to<a&&(e[f]=null,(o||(o=[])).push(u));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(o,l+1);c!=xe?r[s+2]=c:(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):xe}forChild(e,t){if(this==xe)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 a=this.local[l];if(a.from<o&&a.to>s&&a.type instanceof Cn){let c=Math.max(s,a.from)-s,f=Math.min(o,a.to)-s;c<f&&(i||(i=[])).push(a.copy(c,f))}}if(i){let l=new n(i.sort(Mn),yr);return r?new ko([l,r]):l}return r||xe}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 Ha(this.localsInner(e))}localsInner(e){if(this==xe)return yr;if(e.inlineContent||!this.local.some(Cn.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Cn||t.push(this.local[r]);return t}forEachSet(e){e(this)}};be.empty=new be([],[]);be.removeOverlap=Ha;var xe=be.empty,ko=class n{constructor(e){this.members=e}map(e,t){let r=this.members.map(i=>i.map(e,t,En));return n.from(r)}forChild(e,t){if(t.isLeaf)return be.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=xe&&(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?Ha(r?t:t.sort(Mn)):yr}static from(e){switch(e.length){case 0:return xe;case 1:return e[0];default:return new n(e.every(t=>t instanceof be)?e:e.reduce((t,r)=>t.concat(r instanceof be?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function Zx(n,e,t,r,i,s,o){let l=n.slice();for(let c=0,f=s;c<t.maps.length;c++){let u=0;t.maps[c].forEach((h,d,p,m)=>{let g=m-p-(d-h);for(let y=0;y<l.length;y+=3){let b=l[y+1];if(b<0||h>b+f-u)continue;let k=l[y]+f-u;d>=k?l[y+1]=h<=k?-2:-1:h>=f&&g&&(l[y]+=g,l[y+1]+=g)}u+=g}),f=t.maps[c].map(f,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let f=t.map(n[c]+s),u=f-i;if(u<0||u>=r.content.size){a=!0;continue}let h=t.map(n[c+1]+s,-1),d=h-i,{index:p,offset:m}=r.content.findIndex(u),g=r.maybeChild(p);if(g&&m==u&&m+g.nodeSize==d){let y=l[c+2].mapInner(t,g,f+1,n[c]+s+1,o);y!=xe?(l[c]=u,l[c+1]=d,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Qx(l,n,e,t,i,s,o),f=Co(c,r,0,o);e=f.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,h=0;u<f.children.length;u+=3){let d=f.children[u];for(;h<l.length&&l[h]<d;)h+=3;l.splice(h,0,f.children[u],f.children[u+1],f.children[u+2])}}return new be(e.sort(Mn),l)}function Pd(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 st(i.from+e,i.to+e,i.type))}return t}function Qx(n,e,t,r,i,s,o){function l(a,c){for(let f=0;f<a.local.length;f++){let u=a.local[f].map(r,i,c);u?t.push(u):o.onRemove&&o.onRemove(a.local[f].spec)}for(let f=0;f<a.children.length;f+=3)l(a.children[f+2],a.children[f]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function zd(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 $d(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Co(n,e,t,r){let i=[],s=!1;e.forEach((l,a)=>{let c=zd(n,l,a+t);if(c){s=!0;let f=Co(c,l,t+a+1,r);f!=xe&&i.push(a,a+l.nodeSize,f)}});let o=Pd(s?$d(n):n,-t).sort(Mn);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 be(o,i):xe}function Mn(n,e){return n.from-e.from||n.to-e.to}function Ha(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),td(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),td(e,i,r.copy(s.from,r.to)));break}}}return e}function td(n,e,t){for(;e<n.length&&Mn(t,n[e])>0;)e++;n.splice(e,0,t)}function wa(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=xe&&e.push(r)}),n.cursorWrapper&&e.push(be.create(n.state.doc,[n.cursorWrapper.deco])),ko.from(e)}var eb={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},tb=_e&&Wt<=11,Pa=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}},za=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Pa,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]);_e&&Wt<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():we&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),tb&&(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,eb)),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(Kh(this.view)){if(this.suppressingSelectionUpdates)return Ct(this.view);if(_e&&Wt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Tn(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=xr(s))t.add(s);for(let s=e.anchorNode;s;s=xr(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)&&Kh(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let f=0;f<t.length;f++){let u=this.registerMutation(t[f],a);u&&(s=s<0?u.from:Math.min(u.from,s),o=o<0?u.to:Math.max(u.to,o),u.typeOver&&(l=!0))}if(a.some(f=>f.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||ce&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(f=>f.type=="childList"&&f.removedNodes.length))){for(let f of a)if(f.nodeName=="BR"&&f.parentNode){let u=f.nextSibling;for(;u&&u.nodeType==1;){if(u.contentEditable=="false"){f.parentNode.removeChild(f);break}u=u.firstChild}}}else if(We&&a.length){let f=a.filter(u=>u.nodeName=="BR");if(f.length==2){let[u,h]=f;u.parentNode&&u.parentNode.parentNode==h.parentNode?h.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let h of f){let d=h.parentNode;d&&d.nodeName=="LI"&&(!u||ib(e,u)!=d)&&h.remove()}}}let c=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Eo(r)&&(c=qa(e))&&c.eq(B.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ct(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),nb(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,sb(e,a)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ct(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 f=0;f<e.addedNodes.length;f++){let u=e.addedNodes[f];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}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(_e&&Wt<=11&&e.addedNodes.length)for(let f=0;f<e.addedNodes.length;f++){let{previousSibling:u,nextSibling:h}=e.addedNodes[f];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(i=u),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(s=h)}let o=i&&i.parentNode==e.target?ae(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?ae(s):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}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})}},nd=new WeakMap,rd=!1;function nb(n){if(!nd.has(n)&&(nd.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=We,rd)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."),rd=!0}}function id(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return Tn(o.node,o.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function rb(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return id(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?id(n,t):null}function ib(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 sb(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 a=l.firstChild;if(!a||a.nodeType!=1||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(s,l.firstChild),r==s&&n.domSelection().collapse(s,i)}else s.parentNode.removeChild(s)}}function ob(n,e,t,r){let{node:i,fromOffset:s,toOffset:o,from:l,to:a}=n.docView.parseRange(e,t),c=n.domSelectionRange(),f,u=c.anchorNode;if(u&&n.dom.contains(u.nodeType==1?u:u.parentNode)&&(f=[{node:u,offset:c.anchorOffset}],Eo(c)||f.push({node:c.focusNode,offset:c.focusOffset})),ce&&n.input.lastKeyCode===8)for(let y=o;y>s;y--){let b=i.childNodes[y-1],k=b.pmViewDesc;if(b.nodeName=="BR"&&!k){o=y;break}if(!k||k.size)break}let h=n.state.doc,d=n.someProp("domParser")||mi.fromSchema(n.state.schema),p=h.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:f,ruleFromNode:lb(r),context:p});if(f&&f[0].pos!=null){let y=f[0].pos,b=f[1]&&f[1].pos;b==null&&(b=y),m={anchor:y+l,head:b+l}}return{doc:g,sel:m,from:l,to:a}}var lb=n=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(n);if(e.nodeName=="BR"&&e.parentNode){if(we&&/^(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||we&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},ab=/^(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 cb(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let E=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,_=qa(n,E);if(_&&!n.state.selection.eq(_)){if(ce&&St&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",In=>In(n,bn(13,"Enter"))))return;let K=n.state.tr.setSelection(_);E=="pointer"?K.setMeta("pointer",!0):E=="key"&&K.scrollIntoView(),s&&K.setMeta("composition",s),n.dispatch(K)}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 a=n.state.selection,c=ob(n,e,t,i),f=n.state.doc,u=f.slice(c.from,c.to),h,d;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(h=n.state.selection.to,d="end"):(h=n.state.selection.from,d="start"),n.input.lastKeyCode=null;let p=hb(u.content,c.doc.content,c.from,h,d);if(p&&n.input.domChangeCount++,(br&&n.input.lastIOSEnter>Date.now()-225||St)&&i.some(E=>E.nodeType==1&&!ab.test(E.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",E=>E(n,bn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof V&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let E=sd(n,n.state.doc,c.sel);if(E&&!E.eq(n.state.selection)){let _=n.state.tr.setSelection(E);s&&_.setMeta("composition",s),n.dispatch(_)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof V&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),_e&&Wt<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),y=f.resolve(p.start),b=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((br&&n.input.lastIOSEnter>Date.now()-225&&(!b||i.some(E=>E.nodeName=="DIV"||E.nodeName=="P"))||!b&&m.pos<c.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(c.doc.textBetween(m.pos,g.pos,"","")))&&n.someProp("handleKeyDown",E=>E(n,bn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&ub(f,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",E=>E(n,bn(8,"Backspace")))){St&&ce&&n.domObserver.suppressSelectionUpdates();return}ce&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),St&&!b&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(E){return E(n,bn(13,"Enter"))})},20));let k=p.start,I=p.endA,z=E=>{let _=E||n.state.tr.replace(k,I,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let K=sd(n,_.doc,c.sel);K&&!(ce&&n.composing&&K.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(K.head==k||K.head==_.mapping.map(I)-1)||_e&&K.empty&&K.head==k)&&_.setSelection(K)}return s&&_.setMeta("composition",s),_.scrollIntoView()},ue;if(b)if(m.pos==g.pos){_e&&Wt<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ct(n),20));let E=z(n.state.tr.delete(k,I)),_=f.resolve(p.start).marksAcross(f.resolve(p.endA));_&&E.ensureMarks(_),n.dispatch(E)}else if(p.endA==p.endB&&(ue=fb(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let E=z(n.state.tr);ue.type=="add"?E.addMark(k,I,ue.mark):E.removeMark(k,I,ue.mark),n.dispatch(E)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let E=m.parent.textBetween(m.parentOffset,g.parentOffset),_=()=>z(n.state.tr.insertText(E,k,I));n.someProp("handleTextInput",K=>K(n,k,I,E,_))||n.dispatch(_())}else n.dispatch(z());else n.dispatch(z())}function sd(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Wa(n,e.resolve(t.anchor),e.resolve(t.head))}function fb(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,s=r,o,l,a;for(let f=0;f<r.length;f++)i=r[f].removeFromSet(i);for(let f=0;f<t.length;f++)s=t[f].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",a=f=>f.mark(l.addToSet(f.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",a=f=>f.mark(l.removeFromSet(f.marks));else return null;let c=[];for(let f=0;f<e.childCount;f++)c.push(a(e.child(f)));if(x.from(c).eq(n))return{mark:l,type:o}}function ub(n,e,t,r,i){if(t-e<=i.pos-r.pos||Sa(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(Sa(s,!0,!0));return!o.parent.isTextblock||o.pos>t||Sa(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Sa(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 hb(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,b:c}=n.findDiffEnd(e,o,l);if(i=="end"){let f=Math.max(0,s-Math.min(a,c));r-=a+f-s}if(a<s&&o<l){let f=r<=s&&r>=a?s-r:0;s-=f,c=s+(c-a),a=s}else if(c<s){let f=r<=s&&r>=c?s-r:0;s-=f,a=s+(a-c),c=s}return{start:s,endA:a,endB:c}}var Ii=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 Ba,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(fd),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=ad(this),ld(this),this.nodeViews=cd(this),this.docView=$h(this.state.doc,od(this),wa(this),this.dom,this),this.domObserver=new za(this,(r,i,s,o)=>cb(this,r,i,s,o)),this.domObserver.start(),Rx(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&&La(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(fd),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&&(Ud(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=cd(this);pb(d,this.nodeViews)&&(this.nodeViews=d,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&La(this),this.editable=ad(this),ld(this);let a=wa(this),c=od(this),f=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",u=s||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(i.selection))&&(o=!0);let h=f=="preserve"&&o&&this.dom.style.overflowAnchor==null&&X0(this);if(o){this.domObserver.stop();let d=u&&(_e||ce)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&db(i.selection,e.selection);if(u){let m=ce?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=jx(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=$h(e.doc,c,a,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())&&xx(this)&&p.delaySelUpdate())?Ct(this,d):(Ed(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),f=="reset"?this.dom.scrollTop=0:f=="to selection"?this.scrollToSelection():h&&Z0(h)}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 T){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Uh(this,t.getBoundingClientRect(),e)}else Uh(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 wo(e.slice,e.move,i<0?void 0:T.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(_e){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&&Q0(this.dom),Ct(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 ix(this,e)}coordsAtPos(e,t=1){return xd(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 cx(this,t||this.state,e)}pasteHTML(e,t){return Oi(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Oi(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Ja(this,e)}destroy(){this.docView&&(vx(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],wa(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,z0())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Lx(this,e)}domSelectionRange(){let e=this.domSelection();return e?we&&this.root.nodeType===11&&j0(this.dom.ownerDocument)==this.dom&&rb(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Ii.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function od(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"),[st.node(0,n.state.doc.content.size,e)]}function ld(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:st.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function ad(n){return!n.someProp("editable",e=>e(n.state)===!1)}function db(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 cd(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 pb(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 fd(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 qd=()=>{let n=!0;return(e,t)=>{if(n){n=!1;try{e()}finally{n=!0}}else t!==void 0&&t()}};var mb=/[\uD800-\uDBFF]/,gb=/[\uDC00-\uDFFF]/,yb=(n,e)=>{let t=0,r=0;for(;t<n.length&&t<e.length&&n[t]===e[t];)t++;for(t>0&&mb.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&&gb.test(n[n.length-r])&&r--,{index:t,remove:n.length-t-r,insert:e.slice(t,e.length-r)}},Wd=yb;var q=new zt("y-sync"),je=new zt("y-undo"),Uk=new zt("yjs-cursor");var ot=(n,e)=>n>>>e|n<<32-e,xb=n=>ot(n,2)^ot(n,13)^ot(n,22),bb=n=>ot(n,6)^ot(n,11)^ot(n,25),wb=n=>ot(n,7)^ot(n,18)^n>>>3,Sb=n=>ot(n,17)^ot(n,19)^n>>>10,kb=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]),Cb=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ga=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(Cb),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let u=16;u<64;u++)t[u]=Sb(t[u-2])+t[u-7]+wb(t[u-15])+t[u-16];let r=e[0],i=e[1],s=e[2],o=e[3],l=e[4],a=e[5],c=e[6],f=e[7];for(let u=0,h,d;u<64;u++)h=f+bb(l)+(l&a^~l&c)+kb[u]+t[u]>>>0,d=xb(r)+(r&i^r&s^i&s)>>>0,f=c,c=a,a=l,l=o+h>>>0,o=s,s=i,i=r,r=h+d>>>0;e[0]+=r,e[1]+=i,e[2]+=s,e[3]+=o,e[4]+=l,e[5]+=a,e[6]+=c,e[7]+=f}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}},Jd=n=>new Ga().digest(n);var Mb=n=>{for(let t=6;t<n.length;t++)n[t%6]=n[t%6]^n[t];return n.slice(0,6)},jd=n=>Sf(Mb(Jd(Cf(n))));var Hd=()=>({mapping:new Map,isOMark:new Map}),Ui=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&e.sv.get(n.id.client)>n.id.clock&&!cn(e.ds,n.id),Ab=[{light:"#ecd44433",dark:"#ecd444"}],Db=(n,e,t)=>{if(!n.has(t)){if(n.size<e.length){let r=Ke();n.forEach(i=>r.add(i)),e=e.filter(i=>!r.has(i))}n.set(t,of(e))}return n.get(t)},Qa=(n,{colors:e=Ab,colorMapping:t=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:s}={})=>{let o=!1,l=new Mo(n,s),a=new ye({props:{editable:c=>{let f=q.getState(c);return f.snapshot==null&&f.prevSnapshot==null}},key:q,state:{init:(c,f)=>({type:n,doc:n.doc,binding:l,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:t,permanentUserData:r}),apply:(c,f)=>{let u=c.getMeta(q);if(u!==void 0){f=Object.assign({},f);for(let h in u)f[h]=u[h]}return f.addToHistory=c.getMeta("addToHistory")!==!1,f.isChangeOrigin=u!==void 0&&!!u.isChangeOrigin,f.isUndoRedoOperation=u!==void 0&&!!u.isChangeOrigin&&!!u.isUndoRedoOperation,l.prosemirrorView!==null&&u!==void 0&&(u.snapshot!=null||u.prevSnapshot!=null)&&xl(0,()=>{l.prosemirrorView!=null&&(u.restore==null?l._renderSnapshot(u.snapshot,u.prevSnapshot,f):(l._renderSnapshot(u.snapshot,u.snapshot,f),delete f.restore,delete f.snapshot,delete f.prevSnapshot,l.mux(()=>{l._prosemirrorChanged(l.prosemirrorView.state.doc)})))}),f}},view:c=>(l.initView(c),s==null&&l._forceRerender(),i(),{update:()=>{let f=a.getState(c.state);if(f.snapshot==null&&f.prevSnapshot==null&&(o||c.state.doc.content.findDiffStart(c.state.doc.type.createAndFill().content)!==null)){if(o=!0,f.addToHistory===!1&&!f.isChangeOrigin){let u=je.getState(c.state),h=u&&u.undoManager;h&&h.stopCapturing()}l.mux(()=>{f.doc.transact(u=>{u.meta.set("addToHistory",f.addToHistory),l._prosemirrorChanged(c.state.doc)},q)})}},destroy:()=>{l.destroy()}})});return a},Ob=(n,e,t)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")n.setSelection(new Ce(n.doc));else if(e.type==="node"){let r=Li(t.doc,t.type,e.anchor,t.mapping);n.setSelection(T.create(n.doc,r))}else{let r=Li(t.doc,t.type,e.anchor,t.mapping),i=Li(t.doc,t.type,e.head,t.mapping);if(r!==null&&i!==null){let s=V.between(n.doc.resolve(r),n.doc.resolve(i));n.setSelection(s)}}},Vi=(n,e)=>({type:e.selection.jsonID,anchor:Ao(e.selection.anchor,n.type,n.mapping),head:Ao(e.selection.head,n.type,n.mapping)}),Mo=class{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=qd(),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=Vi(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()?(Wr&&this._domSelectionInView===null&&(xl(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=pt.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=Js($s(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(q,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{let e=this.type.toArray().map(r=>wr(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new S(x.from(e),0,0));t.setMeta(q,{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=>wr(i,this.prosemirrorView.state.schema,this)).filter(i=>i!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new S(x.from(t),0,0));if(e){let i=dt(Ve(e.anchor,0),r.doc.content.size),s=dt(Ve(e.head,0),r.doc.content.size);r.setSelection(V.create(r.doc,i,s))}this.prosemirrorView.dispatch(r.setMeta(q,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,r){let i=this.doc,s=this.type;if(e||(e=js(this.doc)),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&Z(),i=new Ie({gc:!1}),ci(i,t),t=js(i),ci(i,e),e=js(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=Pe(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(u=>{mt(o,u,h=>{})});let a=(u,h)=>{let d=u==="added"?l.getUserByClientId(h.client):l.getUserByDeletedId(h);return{user:d,type:u,color:Db(r.colorMapping,r.colors,d)}},c=Hl(s,new er(t.ds,e.sv)).map(u=>!u._item.deleted||Ui(u._item,e)||Ui(u._item,t)?wr(u,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,t,a):null).filter(u=>u!==null),f=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new S(x.from(c),0,0));this.prosemirrorView.dispatch(f.setMeta(q,{isChangeOrigin:!0}))},q)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let r=q.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,a)=>this.mapping.delete(a);mt(t,t.deleteSet,l=>{if(l.constructor===F){let a=l.content.type;a&&this.mapping.delete(a)}}),t.changed.forEach(i),t.changedParentTypes.forEach(i);let s=this.type.toArray().map(l=>Gd(l,this.prosemirrorView.state.schema,this)).filter(l=>l!==null),o=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new S(x.from(s),0,0));Ob(o,this.beforeTransactionSelection,this),o=o.setMeta(q,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof Ut}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&o.scrollIntoView(),this.prosemirrorView.dispatch(o)})}_prosemirrorChanged(e){this.doc.transact(()=>{Sr(this.doc,this.type,e,this),this.beforeTransactionSelection=Vi(this,this.prosemirrorView.state)},q)}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))}},Gd=(n,e,t,r,i,s)=>{let o=t.mapping.get(n);if(o===void 0){if(n instanceof ee)return wr(n,e,t,r,i,s);throw ke()}return o},wr=(n,e,t,r,i,s)=>{let o=[],l=a=>{if(a instanceof ee){let c=Gd(a,e,t,r,i,s);c!==null&&o.push(c)}else{let c=a._item.right?.content?.type;c instanceof xt&&!c._item.deleted&&c._item.id.client===c.doc.clientID&&(a.applyDelta([{retain:a.length},...c.toDelta()]),c.doc.transact(u=>{c._item.delete(u)}));let f=Nb(a,e,t,r,i,s);f!==null&&f.forEach(u=>{u!==null&&o.push(u)})}};r===void 0||i===void 0?n.toArray().forEach(l):Hl(n,new er(i.ds,r.sv)).forEach(l);try{let a=n.getAttributes(r);r!==void 0&&(Ui(n._item,r)?Ui(n._item,i)||(a.ychange=s?s("added",n._item.id):{type:"added"}):a.ychange=s?s("removed",n._item.id):{type:"removed"});let c=e.node(n.nodeName,a,o);return t.mapping.set(n,c),c}catch{return n.doc.transact(c=>{n._item.delete(c)},q),t.mapping.delete(n),null}},Nb=(n,e,t,r,i,s)=>{let o=[],l=n.toDelta(r,i,s);try{for(let a=0;a<l.length;a++){let c=l[a];o.push(e.text(c.insert,Lb(c.attributes,e)))}}catch{return n.doc.transact(c=>{n._item.delete(c)},q),null}return o},Ib=(n,e)=>{let t=new pe,r=n.map(i=>({insert:i.text,attributes:Zd(i.marks,e)}));return t.applyDelta(r),e.mapping.set(t,n),t},_b=(n,e)=>{let t=new ee(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,Do(n).map(r=>Xa(r,e))),e.mapping.set(t,n),t},Xa=(n,e)=>n instanceof Array?Ib(n,e):_b(n,e),Yd=n=>typeof n=="object"&&n!==null,ec=(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||Yd(o)&&Yd(l)&&ec(o,l)}return r},Do=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},Xd=(n,e)=>{let t=n.toDelta();return t.length===e.length&&t.every((r,i)=>r.insert===e[i].text&&nl(r.attributes||{}).length===e[i].marks.length&&_t(r.attributes,(s,o)=>{let l=tc(o),a=e[i].marks;return ec(s,a.find(c=>c.type.name===l)?.attrs)}))},Fi=(n,e)=>{if(n instanceof ee&&!(e instanceof Array)&&Za(n,e)){let t=Do(e);return n._length===t.length&&ec(n.getAttributes(),e.attrs)&&n.toArray().every((r,i)=>Fi(r,t[i]))}return n instanceof pe&&e instanceof Array&&Xd(n,e)},To=(n,e)=>n===e||n instanceof Array&&e instanceof Array&&n.length===e.length&&n.every((t,r)=>e[r]===t),Kd=(n,e,t)=>{let r=n.toArray(),i=Do(e),s=i.length,o=r.length,l=dt(o,s),a=0,c=0,f=!1;for(;a<l;a++){let u=r[a],h=i[a];if(To(t.mapping.get(u),h))f=!0;else if(!Fi(u,h))break}for(;a+c<l;c++){let u=r[o-c-1],h=i[s-c-1];if(To(t.mapping.get(u),h))f=!0;else if(!Fi(u,h))break}return{equalityFactor:a+c,foundMappedChild:f}},Rb=n=>{let e="",t=n._start,r={};for(;t!==null;)t.deleted||(t.countable&&t.content instanceof He?e+=t.content.str:t.content instanceof Y&&(r[t.content.key]=null)),t=t.right;return{str:e,nAttrs:r}},vb=(n,e,t)=>{t.mapping.set(n,e);let{nAttrs:r,str:i}=Rb(n),s=e.map(c=>({insert:c.text,attributes:Object.assign({},r,Zd(c.marks,t))})),{insert:o,remove:l,index:a}=Wd(i,s.map(c=>c.insert).join(""));n.delete(a,l),n.insert(a,o),n.applyDelta(s.map(c=>({retain:c.insert.length,attributes:c.attributes})))},Bb=/(.*)(--[a-zA-Z0-9+/=]{8})$/,tc=n=>Bb.exec(n)?.[1]??n,Lb=(n,e)=>{let t=[];for(let r in n)t.push(e.mark(tc(r),n[r]));return t},Zd=(n,e)=>{let t={};return n.forEach(r=>{if(r.type.name!=="ychange"){let i=Ue(e.isOMark,r.type,()=>!r.type.excludes(r.type));t[i?`${r.type.name}--${jd(r.toJSON())}`:r.type.name]=r.attrs}}),t},Sr=(n,e,t,r)=>{if(e instanceof ee&&e.nodeName!==t.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,t),e instanceof ee){let u=e.getAttributes(),h=t.attrs;for(let d in h)h[d]!==null?u[d]!==h[d]&&d!=="ychange"&&e.setAttribute(d,h[d]):e.removeAttribute(d);for(let d in u)h[d]===void 0&&e.removeAttribute(d)}let i=Do(t),s=i.length,o=e.toArray(),l=o.length,a=dt(s,l),c=0,f=0;for(;c<a;c++){let u=o[c],h=i[c];if(!To(r.mapping.get(u),h))if(Fi(u,h))r.mapping.set(u,h);else break}for(;f+c<a;f++){let u=o[l-f-1],h=i[s-f-1];if(!To(r.mapping.get(u),h))if(Fi(u,h))r.mapping.set(u,h);else break}n.transact(()=>{for(;l-c-f>0&&s-c-f>0;){let h=o[c],d=i[c],p=o[l-f-1],m=i[s-f-1];if(h instanceof pe&&d instanceof Array)Xd(h,d)||vb(h,d,r),c+=1;else{let g=h instanceof ee&&Za(h,d),y=p instanceof ee&&Za(p,m);if(g&&y){let b=Kd(h,d,r),k=Kd(p,m,r);b.foundMappedChild&&!k.foundMappedChild?y=!1:!b.foundMappedChild&&k.foundMappedChild||b.equalityFactor<k.equalityFactor?g=!1:y=!1}g?(Sr(n,h,d,r),c+=1):y?(Sr(n,p,m,r),f+=1):(r.mapping.delete(e.get(c)),e.delete(c,1),e.insert(c,[Xa(d,r)]),c+=1)}}let u=l-c-f;if(l===1&&s===0&&o[0]instanceof pe?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):u>0&&(e.slice(c,c+u).forEach(h=>r.mapping.delete(h)),e.delete(c,u)),c+f<s){let h=[];for(let d=c;d<s-f;d++)h.push(Xa(i[d],r));e.insert(c,h)}},q)},Za=(n,e)=>!(e instanceof Array)&&n.nodeName===e.type.name;var Ao=(n,e,t)=>{if(n===0)return Ws(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 Ws(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 ln(r._item===null?null:r._item.id,r._item===null?sr(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 ln(r._item===null?null:r._item.id,r._item===null?sr(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 Z();if(n===0&&r.constructor!==pe&&r!==e)return Ub(r._item.parent,r._item)}return Ws(e,e._length,e.length===0?-1:0)},Ub=(n,e)=>{let t=null,r=null;return n._item===null?r=sr(n):t=O(n._item.id.client,n._item.id.clock),new ln(t,r,e.id)},Li=(n,e,t,r)=>{let i=mu(t,n);if(i===null||i.type!==e&&!Qn(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,a=0;for(;a<s._length&&a<i.index&&l!==null;){if(!l.deleted){let c=l.content.type;a++,c instanceof pe?o+=c._length:o+=r.get(c).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 a=l._first;for(;a!==null;){let c=a.content.type;if(c===s)break;a.deleted||(c instanceof pe?o+=c._length:o+=r.get(c).nodeSize),a=a.right}}s=l}return o-1},Qd=(n,e)=>{let t=n.toArray().map(r=>wr(r,e,Hd())).filter(r=>r!==null);return x.fromArray(t)},nc=(n,e)=>e.topNodeType.create(null,Qd(n,e));function rc(n,e){let t=e||new Vt,r=t.doc?t.doc:{transact:i=>i(void 0)};return Sr(r,t,n,{mapping:new Map,isOMark:new Map}),t}var ic=n=>je.getState(n)?.undoManager?.undo()!=null,Oo=n=>je.getState(n)?.undoManager?.redo()!=null,ep=(n,e)=>e==null?je.getState(n)?.undoManager?.canUndo():ic(n),tp=(n,e)=>e==null?je.getState(n)?.undoManager?.canRedo():Oo(n),sc=new Set(["paragraph"]),oc=(n,e)=>!(n instanceof F)||!(n.content instanceof ze)||!(n.content.type instanceof xt||n.content.type instanceof ee&&e.has(n.content.type.nodeName))||n.content.type._length===0,np=({protectedNodes:n=sc,trackedOrigins:e=[],undoManager:t=null}={})=>new ye({key:je,state:{init:(r,i)=>{let s=q.getState(i),o=t||new Ut(s.type,{trackedOrigins:new Set([q].concat(e)),deleteFilter:l=>oc(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=q.getState(o).binding,a=i.undoManager,c=a.undoStack.length>0,f=a.redoStack.length>0;return l?{undoManager:a,prevSel:Vi(l,s),hasUndoOps:c,hasRedoOps:f}:c!==i.hasUndoOps||f!==i.hasRedoOps?Object.assign({},i,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):i}},view:r=>{let i=q.getState(r.state),s=je.getState(r.state).undoManager;return s.on("stack-item-added",({stackItem:o})=>{let l=i.binding;l&&o.meta.set(l,je.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 rp(n,e){let{structs:t,ds:r}=jl(e),i=l=>j(n.store,l),s=0,o=0;for(let l of t)l instanceof oe||(i(l.id.client)>=l.id.clock+l.length?s++:o++);for(let[l,a]of r.clients)for(let c of a){let f=i(l);f>c.clock&&s++,f<c.clock+c.len&&o++}return o?s?"some":"none":"all"}function Vb(n,e){let{pendingStructs:t,pendingDs:r}=n.store;n.store.pendingStructs=null,n.store.pendingDs=null;try{return Jl(n,e)}finally{n.store.pendingStructs=t,n.store.pendingDs=r}}function Fb(n,e){let t=n.before,r=t.content.findDiffStart(e.content),i=[];if(r!=null){let{a:c,b:f}=t.content.findDiffEnd(e.content),u=r-Math.min(c,f);u>0&&(c+=u,f+=u),i=[r,c-r,f-r]}let s=n.steps,o=new wi;for(let c=s.length-1;c>=0;c--)o.appendMap(s[c].getMap().invert());o.appendMap(new Xe(i));let l=pr.create({doc:e,schema:e.type.schema}).tr,a=s.length;for(let c of s){let f=c.map(o.slice(a));if(a--,!f||l.maybeStep(f).failed)return null;o.appendMap(f.getMap()),o.setMirror(a,o.maps.length-1)}return l.doc}function ip(n,e){let t=n.content.findDiffStart(e.content);if(t==null)return null;let{a:r,b:i}=n.content.findDiffEnd(e.content),s=t-Math.min(r,i);return s>0&&(r+=s,i+=s),new ge(t,r,e.slice(t,i))}function Pb(n,{tr:e,locate:t,schema:r},i){let s=null;try{s=t(n)}catch{s=null}if(!s)return null;let o=null;try{o=Fb(e,nc(s,r))}catch{o=null}if(!o)return null;let l=[],a=c=>l.push(c);n.on("update",a);try{n.transact(()=>rc(o,s),i)}finally{n.off("update",a)}return l}function lc(n,e=zb){for(;;){let t=e();if(!n||!n.store.clients.has(t))return t}}function zb(){let n=new Uint32Array(1);return globalThis.crypto.getRandomValues(n),n[0]}function sp({newID:n=lc,now:e=Date.now,window:t=500}={}){let r=[],i=null;return{before(s,o){let l=e();o==="pm"&&i!==null&&l-i<t||(s.clientID=n(s),i=o==="pm"?l:null)},keep(s,o,l){let a=r[r.length-1];l&&a&&a.replay===l?a.updates.push(o):r.push({updates:[o],replay:l||void 0,at:e()})},take(){let s=r;return r=[],s},get entries(){return r}}}function $b(n){return jl(n).structs.some(e=>!(e instanceof oe))}function ac(n,e,t,r=()=>{}){let i=[],s=0,o,l=null;for(let a of e){let c=a.updates;if(!c.length)continue;r(a,o),o=a,l||(l=new Ie({gc:!1}),fi(l,Jl(n)));let f=c.map(u=>(fi(l,u),rp(l,u)));if(f.every(u=>u==="all")){for(let u of c)fi(n,u,t);i.push(...c);continue}if(l=null,a.replay){let u=Pb(n,a.replay,t);if(u){i.push(...u);continue}}if(f.every(u=>u==="none")){c.some($b)&&s++;continue}s++;for(let u of c){let h=du(n);fi(n,u,t);let d=rp(n,u);d==="all"?i.push(u):d==="some"&&i.push(Vb(n,h))}}return{post:i,lost:s}}var qb=["ol",0],Wb=["ul",0],Jb=["li",0],jb={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?qb:["ol",{start:n.attrs.order},0]}},Yb={parseDOM:[{tag:"ul"}],toDOM(){return Wb}},Kb={parseDOM:[{tag:"li"}],toDOM(){return Jb},defining:!0};function cc(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 op(n,e,t){return n.append({ordered_list:cc(jb,{content:"list_item+",group:t}),bullet_list:cc(Yb,{content:"list_item+",group:t}),list_item:cc(Kb,{content:e})})}function lp(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 Hb(l,o,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Hb(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 a=o.resolve(e.start-2);s=new hn(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new hn(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=ur(s,t,r,e);return l?(n&&Gb(n,e,l,i,t),!0):!1}function Gb(n,e,t,r,i){let s=x.empty;for(let f=t.length-1;f>=0;f--)s=x.from(t[f].type.create(t[f].attrs,s));n.step(new ie(e.start-(r?2:0),e.end,e.start,e.end,new S(s,0,0),t.length,!0));let o=0;for(let f=0;f<t.length;f++)t[f].type==i&&(o=f+1);let l=t.length-o,a=e.start+t.length-(r?2:0),c=e.parent;for(let f=e.startIndex,u=e.endIndex,h=!0;f<u;f++,h=!1)!h&&Pt(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(f).nodeSize;return n}function ap(n,e){return function(t,r){let{$from:i,$to:s,node:o}=t.selection;if(o&&o.isBlock||i.depth<2||!i.sameParent(s))return!1;let l=i.node(-1);if(l.type!=n)return!1;if(i.parent.content.size==0&&i.node(-1).childCount==i.indexAfter(-1)){if(i.depth==3||i.node(-3).type!=n||i.index(-2)!=i.node(-2).childCount-1)return!1;if(r){let u=x.empty,h=i.index(-1)?1:i.index(-2)?2:3;for(let y=i.depth-h;y>=i.depth-3;y--)u=x.from(i.node(y).copy(u));let d=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;u=u.append(x.from(n.createAndFill()));let p=i.before(i.depth-(h-1)),m=t.tr.replace(p,i.after(-d),new S(u,4-h,0)),g=-1;m.doc.nodesBetween(p,m.doc.content.size,(y,b)=>{if(g>-1)return!1;y.isTextblock&&y.content.size==0&&(g=b+1)}),g>-1&&m.setSelection(B.near(m.doc.resolve(g))),r(m.scrollIntoView())}return!0}let a=s.pos==i.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(i.pos,s.pos),f=a?[e?{type:n,attrs:e}:null,{type:a}]:void 0;return Pt(c.doc,i.pos,2,f)?(r&&r(c.split(i.pos,2,f).scrollIntoView()),!0):!1}}function Pi(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?Xb(e,t,n,s):Zb(e,t,s):!0:!1}}function Xb(n,e,t,r){let i=n.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new ie(s-1,o,s,o,new S(x.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new hn(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));let l=gn(r);if(l==null)return!1;i.lift(r,l);let a=i.doc.resolve(i.mapping.map(s,-1)-1);return yn(i.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&i.join(a.pos),e(i.scrollIntoView()),!0}function Zb(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,a=t.endIndex==i.childCount,c=s.node(-1),f=s.index(-1);if(!c.canReplace(f+(l?0:1),f+1,o.content.append(a?x.empty:x.from(i))))return!1;let u=s.pos,h=u+o.nodeSize;return r.step(new ie(u-(l?1:0),h+(a?1:0),u+1,h-1,new S((l?x.empty:x.from(i.copy(x.empty))).append(a?x.empty:x.from(i.copy(x.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function No(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,a=l.child(o-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,f=x.from(c?n.create():null),u=new S(x.from(n.create(null,x.from(l.type.create(null,f)))),c?3:1,0),h=s.start,d=s.end;t(e.tr.step(new ie(h-(c?3:1),d,h,d,u,1,!0)).scrollIntoView())}return!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:"'"},_o={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Qb=typeof navigator<"u"&&/Mac/.test(navigator.platform),ew=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(X=0;X<10;X++)Et[48+X]=Et[96+X]=String(X);var X;for(X=1;X<=24;X++)Et[X+111]="F"+X;var X;for(X=65;X<=90;X++)Et[X]=String.fromCharCode(X+32),_o[X]=String.fromCharCode(X);var X;for(Io in Et)_o.hasOwnProperty(Io)||(_o[Io]=Et[Io]);var Io;function cp(n){var e=Qb&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||ew&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?_o: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 tw=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),nw=typeof navigator<"u"&&/Win/.test(navigator.platform);function rw(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 a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))tw?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),i&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function iw(n){let e=Object.create(null);for(let t in n)e[rw(t)]=n[t];return e}function fc(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 uc(n){return new ye({props:{handleKeyDown:sw(n)}})}function sw(n){let e=iw(n);return function(t,r){let i=cp(r),s,o=e[fc(i,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[fc(i,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(nw&&r.ctrlKey&&r.altKey)&&(s=Et[r.keyCode])&&s!=i){let l=e[fc(s,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var up=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function ow(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}var lw=(n,e,t)=>{let r=ow(n,t);if(!r)return!1;let i=hp(r);if(!i){let o=r.blockRange(),l=o&&gn(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(mp(n,i,e,-1))return!0;if(r.parent.content.size==0&&(kr(s,"end")||T.isSelectable(s)))for(let o=r.depth;;o--){let l=co(n.doc,r.before(o),r.after(o),S.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(kr(s,"end")?B.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):T.create(a.doc,i.pos-s.nodeSize)),e(a.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 kr(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 aw=(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=hp(r)}let o=s&&s.nodeBefore;return!o||!T.isSelectable(o)?!1:(e&&e(n.tr.setSelection(T.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function hp(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 cw(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}var fw=(n,e,t)=>{let r=cw(n,t);if(!r)return!1;let i=dp(r);if(!i)return!1;let s=i.nodeAfter;if(mp(n,i,e,1))return!0;if(r.parent.content.size==0&&(kr(s,"start")||T.isSelectable(s))){let o=co(n.doc,r.before(),r.after(),S.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(kr(s,"start")?B.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):T.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},uw=(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=dp(r)}let o=s&&s.nodeAfter;return!o||!T.isSelectable(o)?!1:(e&&e(n.tr.setSelection(T.create(n.doc,s.pos)).scrollIntoView()),!0)};function dp(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 pp=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),s=i&&gn(i);return s==null?!1:(e&&e(n.tr.lift(i,s).scrollIntoView()),!0)},hw=(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 dc(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 dw=(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=dc(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(B.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},pw=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof Ce||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=dc(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(V.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},mw=(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(Pt(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&gn(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function gw(n){return(e,t)=>{if(e.selection instanceof T&&e.selection.node.isBlock){let{$from:d}=e.selection;return!d.parentOffset||!Pt(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 V||e.selection instanceof Ce)&&r.deleteSelection();let{$from:i}=r.selection,s=r.steps.length,o=[],l,a,c=!1,f=!1;for(let d=i.depth;;d--)if(i.node(d).isBlock){c=i.end(d)==i.pos+(i.depth-d),f=i.start(d)==i.pos-(i.depth-d),a=dc(i.node(d-1).contentMatchAt(i.indexAfter(d-1)));let m=n&&n(i.parent,c,i);o.unshift(m||(c&&a?{type:a}:null)),l=d;break}else{if(d==1)return!1;o.unshift(null)}let u=i.pos,h=Pt(r.doc,u,o.length,o);if(h||(o[0]=a?{type:a}:null,h=Pt(r.doc,u,o.length,o)),!h)return!1;if(r.split(u,o.length,o),!c&&f&&i.node(l).type!=a){let d=r.mapping.slice(s),p=d.map(i.before(l)),m=r.doc.resolve(p);a&&i.node(l-1).canReplaceWith(m.index(),m.index()+1,a)&&r.setNodeMarkup(d.map(i.before(l)),a)}return t&&t(r.scrollIntoView()),!0}}var yw=gw();var pc=(n,e)=>(e&&e(n.tr.setSelection(new Ce(n.doc))),!0);function xw(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||yn(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function mp(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&xw(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(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 ie(e.pos-1,d,e.pos,d,new S(p,1,0),o.length,!0)),g=m.doc.resolve(d+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&yn(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let f=s.type.spec.isolating||r>0&&a?null:B.findFrom(e,1),u=f&&f.$from.blockRange(f.$to),h=u&&gn(u);if(h!=null&&h>=e.depth)return t&&t(n.tr.lift(u,h).scrollIntoView()),!0;if(c&&kr(s,"start",!0)&&kr(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 k=p.length-1;k>=0;k--)y=x.from(p[k].copy(y));let b=n.tr.step(new ie(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new S(y,p.length,0),0,!0));t(b.scrollIntoView())}return!0}}return!1}function gp(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(V.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}var bw=gp(-1),ww=gp(1);function yp(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&ur(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function mc(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,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let f=t.doc.resolve(c),u=f.index();i=f.parent.canReplaceWith(u,u+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:a}}=t.selection.ranges[o];s.setBlockType(l,a,n,e)}r(s.scrollIntoView())}return!0}}function Sw(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,(a,c)=>{if(l||!r&&a.isAtom&&a.isInline&&c>=s.pos&&c+a.nodeSize<=o.pos)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function kw(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 dr(r,r.doc.resolve(o+1))),r=r.doc.resolve(o+1+s.content.size),!1}),r.pos<i.pos&&e.push(new dr(r,i))}return e}function Dn(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:a,$cursor:c,ranges:f}=o.selection;if(a&&!c||!Sw(o.doc,f,n,i))return!1;if(l)if(c)n.isInSet(o.storedMarks||c.marks())?l(o.tr.removeStoredMark(n)):l(o.tr.addStoredMark(n.create(e)));else{let u,h=o.tr;i||(f=kw(f)),r?u=!f.some(d=>o.doc.rangeHasMark(d.$from.pos,d.$to.pos,n)):u=!f.every(d=>{let p=!1;return h.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<f.length;d++){let{$from:p,$to:m}=f[d];if(!u)h.removeMark(p.pos,m.pos,n);else{let g=p.pos,y=m.pos,b=p.nodeAfter,k=m.nodeBefore,I=s&&b&&b.isText?/^\s*/.exec(b.text)[0].length:0,z=s&&k&&k.isText?/\s*$/.exec(k.text)[0].length:0;g+I<y&&(g+=I,y-=z),h.addMark(g,y,n.create(e))}}l(h.scrollIntoView())}return!0}}function lt(...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 hc=lt(up,lw,aw),fp=lt(up,fw,uw),Mt={Enter:lt(hw,pw,mw,yw),"Mod-Enter":dw,Backspace:hc,"Mod-Backspace":hc,"Shift-Backspace":hc,Delete:fp,"Mod-Delete":fp,"Mod-a":pc},xp={"Ctrl-h":Mt.Backspace,"Alt-Backspace":Mt["Mod-Backspace"],"Ctrl-d":Mt.Delete,"Ctrl-Alt-Backspace":Mt["Mod-Delete"],"Alt-Delete":Mt["Mod-Delete"],"Alt-d":Mt["Mod-Delete"],"Ctrl-a":bw,"Ctrl-e":ww};for(let n in Mt)xp[n]=Mt[n];var Cw=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,gc=Cw?xp:Mt;function Ew(n){let e=yc(n);return e?"docs-indent-"+e:null}function yc(n){if(typeof n!="number"&&(typeof n!="string"||!/^\d+$/.test(n)))return 0;let e=Number(n);return!Number.isInteger(e)||e<1?0:Math.min(e,8)}function Mw(n){for(let e of n){if(!e.startsWith("docs-indent-"))continue;let t=yc(e.slice(12));if(t)return t}return null}function xc(n,e){let t=n.parseDOM||[{tag:e}];return{...n,attrs:{...n.attrs||{},indent:{default:null}},parseDOM:t.map(r=>({...r,getAttrs:i=>{let s=r.getAttrs?r.getAttrs(i):{};return s===!1?!1:{...s||{},indent:Mw(Array.from(i.classList||[]))}}})),toDOM:r=>{let i=n.toDOM?n.toDOM(r):[e,0],s=Ew(r.attrs.indent);if(!s)return i;let[o,l,...a]=i;if(l&&typeof l=="object"&&!Array.isArray(l)){let c={...l,class:l.class?l.class+" "+s:s};return[o,c,...a]}return[o,{class:s},l,...a]}}}function Cr(n){return(e,t)=>{let{from:r,to:i}=e.selection,s=!1,o=e.tr;return e.doc.nodesBetween(r,i,(l,a)=>{if(!l.type.isTextblock||!l.type.spec.attrs||!l.type.spec.attrs.indent)return;let c=yc(l.attrs.indent),f=Math.max(0,Math.min(8,c+n));f!==c&&(s=!0,t&&o.setNodeMarkup(a,null,{...l.attrs,indent:f===0?null:f}))}),s?(t&&t(o),!0):!1}}var at=class{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Tw(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}};function Tw(n){return function(e,t,r,i){let s=n;if(t[1]){let o=t[0].lastIndexOf(t[1]);s+=t[0].slice(o+t[1].length),r+=o;let l=r-i;l>0&&(s=t[0].slice(o-l,o)+s,r=i)}return e.tr.insertText(s,r,i)}}var Aw=500;function wp({rules:n}){let e=new ye({state:{init(){return null},apply(t,r){let i=t.getMeta(this);return i||(t.selectionSet||t.docChanged?null:r)}},props:{handleTextInput(t,r,i,s){return bp(t,r,i,s,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&bp(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function bp(n,e,t,r,i,s){if(n.composing)return!1;let o=n.state,l=o.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-Aw),l.parentOffset,null,"\uFFFC")+r;for(let c=0;c<i.length;c++){let f=i[c];if(!f.inCodeMark&&l.marks().some(p=>p.type.spec.code))continue;if(l.parent.type.spec.code){if(!f.inCode)continue}else if(f.inCode==="only")continue;let u=f.match.exec(a);if(!u||u[0].length<r.length)continue;let h=e-(u[0].length-r.length);if(!f.inCodeMark){let p=!1;if(o.doc.nodesBetween(h,l.pos,m=>{m.isInline&&m.marks.some(g=>g.type.spec.code)&&(p=!0)}),p)continue}let d=f.handler(o,u,h,t);if(d)return f.undoable&&d.setMeta(s,{transform:d,from:e,to:t,text:r}),n.dispatch(d),!0}return!1}var Sp=(n,e)=>{let t=n.plugins;for(let r=0;r<t.length;r++){let i=t[r],s;if(i.spec.isInputRules&&(s=i.getState(n))){if(e){let o=n.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a--)o.step(l.steps[a].invert(l.docs[a]));if(s.text){let a=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,n.schema.text(s.text,a))}else o.delete(s.from,s.to);e(o)}return!0}}return!1},L1=new at(/--$/,"\u2014",{inCodeMark:!1}),U1=new at(/\.\.\.$/,"\u2026",{inCodeMark:!1}),V1=new at(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C",{inCodeMark:!1}),F1=new at(/"$/,"\u201D",{inCodeMark:!1}),P1=new at(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018",{inCodeMark:!1}),z1=new at(/'$/,"\u2019",{inCodeMark:!1});function Ro(n,e,t=null,r){return new at(n,(i,s,o,l)=>{let a=t instanceof Function?t(s):t,c=i.tr.delete(o,l),f=c.doc.resolve(o),u=f.blockRange(),h=u&&ur(u,e,a);if(!h)return null;c.wrap(u,h);let d=c.doc.resolve(o-1).nodeBefore;return d&&d.type==e&&yn(c.doc,o-1)&&(!r||r(s,d))&&c.join(o-1),c})}function kp(n,e,t=null){return new at(n,(r,i,s,o)=>{let l=r.doc.resolve(s),a=t instanceof Function?t(i):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?r.tr.delete(s,o).setBlockType(s,s,e,a):null})}var Dw=/^\s*([-+*])\s$/,Ow=/^(\d+)\.\s$/,Nw=/^\s*>\s$/,Iw=/^(#{1,3})\s$/;function Cp(n){let e=[],{bullet_list:t,ordered_list:r,blockquote:i,heading:s}=n.nodes;return t&&e.push(Ro(Dw,t)),r&&e.push(Ro(Ow,r)),i&&e.push(Ro(Nw,i)),s&&e.push(kp(Iw,s,o=>({level:o[1].length}))),wp({rules:e})}var zi=new zt("docs-pages"),_w=864,On="paged",$i="infinite",Rw="docs-view";function Ep(n){document.cookie=`${Rw}=${n}; Path=/; Max-Age=31536000; SameSite=Lax`}function vw(n){let e=[],t=n.state.doc,r=null;return t.forEach((i,s)=>{let o=n.nodeDOM(s);if(!o||!o.getBoundingClientRect)return;let l=o.getBoundingClientRect();if(l.height!==0){if(r===null){r=l.top;return}l.bottom-r>_w&&(e.push(s),r=l.top)}}),e}function Mp({getMode:n,pageLabel:e}){return new ye({key:zi,state:{init:()=>({positions:[],deco:be.empty}),apply(t,r,i,s){let o=t.getMeta(zi);if(!o)return{positions:r.positions,deco:r.deco.map(t.mapping,t.doc)};let l=o.positions.map((a,c)=>st.widget(a,()=>Bw(c+2,e),{side:-1,ignoreSelection:!0}));return{positions:o.positions,deco:be.create(s.doc,l)}}},props:{decorations(t){return n()!==On?be.empty:zi.getState(t).deco}},view(t){let r=0,i="",s=()=>{if(r=0,n()!==On){i!==""&&(i="",t.dispatch(t.state.tr.setMeta(zi,{positions:[]})));return}let a=vw(t),c=a.join(",");c!==i&&(i=c,t.dispatch(t.state.tr.setMeta(zi,{positions:a})))},o=()=>{r||(r=requestAnimationFrame(s))},l=typeof ResizeObserver=="function"?new ResizeObserver(o):null;return l&&l.observe(t.dom),o(),{update:o,destroy(){r&&cancelAnimationFrame(r),l&&l.disconnect()}}}})}function Bw(n,e){let t=document.createElement("div");t.setAttribute("docs-page-gap",""),t.setAttribute("contenteditable","false"),t.setAttribute("aria-hidden","true");let r=document.createElement("span");return r.setAttribute("docs-page-number",""),r.textContent=e?e.replace("{n}",String(n)):String(n),t.appendChild(r),t}var Tp=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null;function Ap(n){if(!n)return 0;if(Tp){let t=0;for(let r of Tp.segment(n))r.isWordLike&&t++;return t}let e=n.trim().split(/\s+/);return e.length===1&&e[0]===""?0:e.length}function Dp(n){let e=[];return n.descendants(t=>{t.isText?e.push(t.text):t.isBlock&&e.length&&e.push(" ")}),e.join("")}function Lw(n){let e=Dp(n.doc),{from:t,to:r,empty:i}=n.selection,s=0;n.doc.forEach(l=>{(l.isTextblock||l.type.name.endsWith("_list")||l.type.name==="blockquote")&&s++});let o=i?null:Dp(n.doc.cut(t,r));return{words:Ap(e),characters:e.length,charactersNoSpaces:e.replace(/\s/g,"").length,paragraphs:s,selection:o===null?null:{words:Ap(o),characters:o.length}}}function Op(n,{getView:e}){if(!n||typeof n.showModal!="function")return null;let t={words:n.querySelector("[docs-count-words]"),characters:n.querySelector("[docs-count-characters]"),charactersNoSpaces:n.querySelector("[docs-count-characters-nospaces]"),paragraphs:n.querySelector("[docs-count-paragraphs]"),selection:n.querySelector("[docs-count-selection]"),selectionWords:n.querySelector("[docs-count-selection-words]")};return()=>{let r=e();if(!r)return!1;let i=Lw(r.state);return t.words&&(t.words.textContent=String(i.words)),t.characters&&(t.characters.textContent=String(i.characters)),t.charactersNoSpaces&&(t.charactersNoSpaces.textContent=String(i.charactersNoSpaces)),t.paragraphs&&(t.paragraphs.textContent=String(i.paragraphs)),t.selection&&(t.selection.hidden=i.selection===null),t.selectionWords&&i.selection&&(t.selectionWords.textContent=String(i.selection.words)),n.showModal(),!0}}function Uw(n){let e=[];if(!n)return e;for(let t of n.querySelectorAll("[estilo-menubar-menu]")){let r=t.querySelector("[estilo-menubar-title]"),i=r?r.textContent.trim():"";for(let s of t.querySelectorAll("[estilo-menu-item]")){let o=s.getAttribute("data-docs-shortcut");if(!o)continue;let l=s.querySelector("[estilo-menu-label]"),a=(l?l.textContent:s.textContent).trim().replace(/…$/,"");e.push({group:i,label:a,keys:o})}}return e}function Np(n,{menubar:e,extraRows:t}){if(!n||typeof n.showModal!="function")return null;let r=n.querySelector("[docs-shortcuts-body]");return r?()=>{let i=[...Uw(e),...t||[]];r.textContent="";let s=null;for(let o of i){if(o.group&&o.group!==s){s=o.group;let f=document.createElement("h3");f.setAttribute("docs-shortcuts-group",""),f.textContent=s,r.appendChild(f)}let l=document.createElement("div");l.setAttribute("docs-shortcuts-row","");let a=document.createElement("span");a.textContent=o.label;let c=document.createElement("kbd");c.textContent=o.keys,l.append(a,c),r.appendChild(l)}return n.showModal(),!0}:null}function _p(n){return 3e4+Math.ceil(n.byteLength/8)}function Rp(n){return _p(n)+5e3}var Vw=1024;async function Fw(n){if(typeof CompressionStream!="function")return null;let e=new CompressionStream("gzip"),t=e.writable.getWriter();t.write(n).catch(()=>{}),t.close().catch(()=>{});let r=e.readable.getReader(),i=[],s=0;for(;;){let{done:a,value:c}=await r.read();if(a)break;i.push(c),s+=c.byteLength}let o=new Uint8Array(s),l=0;for(let a of i)o.set(a,l),l+=a.byteLength;return o}async function Ip(n,{timeoutMs:e,compress:t=!0}={}){let r={"Content-Type":"application/octet-stream"},i=n;if(t&&n.byteLength>=Vw){let o=await Fw(n).catch(()=>null);o&&o.byteLength<n.byteLength&&(i=o,r["Content-Encoding"]="gzip")}let s={method:"POST",credentials:"same-origin",headers:r,body:i,keepalive:i.byteLength<=32768};return typeof AbortSignal<"u"&&typeof AbortSignal.timeout=="function"&&(s.signal=AbortSignal.timeout(e??_p(i))),s}var Pw=new Set([400,415,422]);function vp({url:n,fetchFn:e=(...t)=>fetch(...t)}){let t=!1;return async function(i,s=()=>{}){let o=await Ip(i,{compress:!t});s(o.keepalive);let l=await e(n,o);return o.headers["Content-Encoding"]==="gzip"&&Pw.has(l.status)&&(t=!0,o=await Ip(i,{compress:!1}),s(o.keepalive),l=await e(n,o)),l}}async function Bp(n,e=fetch){for(let t of[!0,!1])try{let r={method:"HEAD",cache:"no-store",credentials:"same-origin",keepalive:t};return typeof AbortSignal<"u"&&typeof AbortSignal.timeout=="function"&&(r.signal=AbortSignal.timeout(5e3)),await e(n,r),!0}catch{}return!1}function Lp({post:n,mergeUpdates:e,onStatus:t,debounceMs:r=2e3,maxBatchBytes:i=1/0,answerTimeoutMs:s=1/0,probe:o=null,setTimeoutFn:l=setTimeout,clearTimeoutFn:a=clearTimeout}){let c=[],f=null,u=null,h="ok",d=0,p=0,m=[],g=[],y=0;function b(A){h==="failed"&&A!=="failed"||(h=A,t&&t(h))}function k(){let A=[];for(let L of g){if(p<L.to){A.push(L);continue}L.resolve(!m.some(([W,Le])=>Le>L.from&&W<=L.to))}g=A}function I(A){u||(u=l(()=>{u=null,z()},A))}function z(){if(f||!c.length)return;u&&(a(u),u=null);let A=1,L=c[0].update.byteLength;for(;A<c.length&&L+c[A].update.byteLength<=i;)L+=c[A].update.byteLength,A++;let W=c.slice(0,A);c=c.slice(A);let Le=W.length===1?W[0].update:e(W.map(At=>At.update)),Ye={lo:W[0].id,hi:W[W.length-1].id,bytes:Le,entries:W};f=Ye;let Ar=typeof s=="function"?s(Le):s;Number.isFinite(Ar)&&(Ye.timer=l(()=>ue(Ye,"retrying"),Ar));let zo=At=>{Ye.keepalive=!!At};Promise.resolve().then(()=>n(Le,zo)).then(At=>E(Ye,At),()=>E(Ye,null))}function ue(A,L){f===A&&(f=null,A.timer&&a(A.timer),c=A.entries.concat(c),L?(b(L),I(r)):z())}function E(A,L){if(f===A){if(A.timer&&a(A.timer),f=null,L&&(y=0),L&&L.ok)p=A.hi,b(c.length?"saving":"ok");else if(L&&L.status>=400&&L.status<500)p=A.hi,m.push([A.lo,A.hi]),b("failed");else{if(c=A.entries.concat(c),k(),L||!o){y=0,b("retrying"),I(r);return}Promise.resolve().then(()=>o()).then(W=>W,()=>!1).then(W=>{if(!W){y=0,p<A.hi&&b("retrying"),I(r);return}y++,I(Math.min(r*2**y,4e3))});return}k(),c.length&&z()}}function _(A){c.push({id:++d,update:A}),f||I(r)}function K(){let A=d,L=p,W=p>=A?Promise.resolve(!m.some(([Le,Ye])=>Ye>L&&Le<=A)):new Promise(Le=>g.push({from:L,to:A,resolve:Le}));return z(),W}function In({wire:A="all"}={}){let L=[];f&&(A==="all"||A==="plain"&&!f.keepalive)&&L.push(f.bytes);for(let W of c)L.push(W.update);return L.length?L.length===1?L[0]:e(L):null}function ft(){f?ue(f,null):z()}return{enqueue:_,flush:K,pendingBytes:In,resume:ft,get onWire(){return f?f.keepalive?"keepalive":"plain":null},get status(){return h}}}function Up({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,a=!1,c=0,f=null;function u(){c++,f&&s(f),f=i(h,r(c))}async function h(){if(f&&(s(f),f=null),!(!l||a)){a=!0;try{await n(),l=!1,c=0,t&&t()}catch{u()}finally{a=!1}}}function d(){l||(l=!0,c=0,e&&e()),h()}return o(()=>{l&&h()}),{reportDivergence:d,get diverged(){return l},get resyncing(){return a}}}function Vp(n){return{...n,parseDOM:[{tag:"br.Apple-interchange-newline",ignore:!0},...n.parseDOM||[]]}}function Fp(n){let e=n.nodes.paragraph,t=n.nodes.hard_break;return r=>{let i=Pp(r.content,e,t);return i===r.content?r:new S(i,r.openStart,r.openEnd)}}function Pp(n,e,t){let r=[],i=!1;return n.forEach(s=>{if(s.type===e&&s.childCount>0&&zw(s,t)){for(let l=0;l<s.childCount;l+=1)r.push(e.create(s.attrs));i=!0;return}if(s.isTextblock||s.isLeaf){r.push(s);return}let o=Pp(s.content,e,t);if(o===s.content){r.push(s);return}r.push(s.copy(o)),i=!0}),i?x.fromArray(r):n}function zw(n,e){let t=!0;return n.forEach(r=>{r.type!==e&&(t=!1)}),t}function Er(n,e,t){n.getAttribute(e)!==t&&n.setAttribute(e,t)}function ve(n,e,t){n[e]!==t&&(n[e]=t)}function zp(n,e){if(!n||e.length===0)return{ensureReachable(){},focusStop(){return!1}};let t=()=>e.filter(o=>!o.disabled);function r(o){for(let l of e)l.tabIndex=l===o?0:-1}function i(){let o=t();o.length!==0&&(o.some(l=>l.tabIndex===0)||r(o[0]))}n.addEventListener("keydown",o=>{let l=o.key;if(l!=="ArrowRight"&&l!=="ArrowLeft"&&l!=="Home"&&l!=="End")return;let a=t(),c=a.indexOf(document.activeElement);if(c<0||a.length===0)return;let f;l==="Home"?f=a[0]:l==="End"?f=a[a.length-1]:l==="ArrowRight"?f=a[(c+1)%a.length]:f=a[(c-1+a.length)%a.length],o.preventDefault(),r(f),f.focus()}),n.addEventListener("focusin",o=>{e.includes(o.target)&&r(o.target)}),i();function s(){let o=t();if(o.length===0)return!1;let l=o.find(a=>a.tabIndex===0)||o[0];return r(l),l.focus(),!0}return{ensureReachable:i,focusStop:s}}var bc={center:"docs-align-center",right:"docs-align-right"},$p=["left","center","right"];function vo(n){return Object.prototype.hasOwnProperty.call(bc,n)?bc[n]:null}function $w(n){for(let[e,t]of Object.entries(bc))if(n.includes(t))return e;return null}function qp(n){return{...n,attrs:{...n.attrs||{},align:{default:null}},parseDOM:[{tag:"p",getAttrs:e=>({align:$w(Array.from(e.classList||[]))})}],toDOM:e=>{let t=vo(e.attrs.align);return t?["p",{class:t},0]:["p",0]}}}function Wp(n){return(e,t)=>{let{from:r,to:i}=e.selection,s=!1,o=e.tr;return e.doc.nodesBetween(r,i,(l,a)=>{l.type.isTextblock&&(!l.type.spec.attrs||!l.type.spec.attrs.align||(s=!0,t&&o.setNodeMarkup(a,null,{...l.attrs,align:n})))}),s?(t&&t(o),!0):!1}}function Jp(n){let e=n.selection.$from.parent,t=e.attrs&&e.attrs.align;return vo(t)?t:"left"}var Bo={comment:"The font vocabulary. internal/fonts embeds it, fixtures/fonts.mjs imports it into the editor bundle, core/src/fragment.rs is tested against it, and scripts/vendor-fonts.py builds files/ from it with sources.json. Order is the picker's order. Keys are mark names after font_ and never change: sans, serif and mono are Liberation, as they always were.",default:"carlito",code:"mono",families:[{key:"carlito",name:"Carlito",category:"sans",twin:"Calibri",reserved:"Carlito",docx:{name:"Calibri",family:"swiss",pitch:"variable",panose:"020F0502020204030204"},fallback:["Calibri","Carlito","Segoe UI","Arial","sans-serif"],dir:"carlito",licence:"OFL.txt",styles:{regular:"Carlito-Regular",bold:"Carlito-Bold",italic:"Carlito-Italic",boldItalic:"Carlito-BoldItalic"}},{key:"caladea",name:"Caladea",category:"serif",twin:"Cambria",docx:{name:"Cambria",family:"roman",pitch:"variable",panose:"02040503050406030204"},fallback:["Cambria","Caladea","Georgia","Times New Roman","serif"],dir:"caladea",licence:"OFL.txt",styles:{regular:"Caladea-Regular",bold:"Caladea-Bold",italic:"Caladea-Italic",boldItalic:"Caladea-BoldItalic"}},{key:"inter",name:"Inter",category:"sans",docx:{name:"Inter",family:"swiss",pitch:"variable",altName:"Arial"},fallback:["Helvetica Neue","Arial","sans-serif"],dir:"inter",licence:"LICENSE.txt",styles:{regular:"Inter-Regular",bold:"Inter-Bold",italic:"Inter-Italic",boldItalic:"Inter-BoldItalic"}},{key:"sourcesans",name:"Source Sans 3",category:"sans",reserved:"Source",docx:{name:"Source Sans 3",family:"swiss",pitch:"variable",altName:"Calibri"},fallback:["Segoe UI","Arial","sans-serif"],dir:"sourcesans",licence:"LICENSE.md",styles:{regular:"SourceSans3-Regular",bold:"SourceSans3-Bold",italic:"SourceSans3-It",boldItalic:"SourceSans3-BoldIt"}},{key:"plexsans",name:"IBM Plex Sans",category:"sans",reserved:"Plex",docx:{name:"IBM Plex Sans",family:"swiss",pitch:"variable",altName:"Arial"},fallback:["Helvetica Neue","Arial","sans-serif"],dir:"plexsans",licence:"LICENSE.txt",styles:{regular:"IBMPlexSans-Regular",bold:"IBMPlexSans-Bold",italic:"IBMPlexSans-Italic",boldItalic:"IBMPlexSans-BoldItalic"}},{key:"sourceserif",name:"Source Serif 4",category:"serif",reserved:"Source",docx:{name:"Source Serif 4",family:"roman",pitch:"variable",altName:"Georgia"},fallback:["Georgia","Times New Roman","serif"],dir:"sourceserif",licence:"LICENSE.md",styles:{regular:"SourceSerif4-Regular",bold:"SourceSerif4-Bold",italic:"SourceSerif4-It",boldItalic:"SourceSerif4-BoldIt"}},{key:"literata",name:"Literata",category:"serif",docx:{name:"Literata",family:"roman",pitch:"variable",altName:"Georgia"},fallback:["Georgia","Times New Roman","serif"],dir:"literata",licence:"OFL.txt",styles:{regular:"Literata-Regular",bold:"Literata-Bold",italic:"Literata-Italic",boldItalic:"Literata-BoldItalic"}},{key:"garamond",name:"EB Garamond",category:"serif",docx:{name:"EB Garamond",family:"roman",pitch:"variable",altName:"Garamond"},fallback:["Garamond","Georgia","serif"],dir:"garamond",licence:"OFL.txt",styles:{regular:"EBGaramond-Regular",bold:"EBGaramond-Bold",italic:"EBGaramond-Italic",boldItalic:"EBGaramond-BoldItalic"}},{key:"sans",name:"Liberation Sans",category:"sans",twin:"Arial",reserved:"Liberation",docx:{name:"Arial",family:"swiss",pitch:"variable",panose:"020B0604020202020204"},fallback:["Arial","Helvetica","Liberation Sans","sans-serif"],dir:"liberation",licence:"LICENSE-OFL-1.1.txt",styles:{regular:"LiberationSans-Regular",bold:"LiberationSans-Bold",italic:"LiberationSans-Italic",boldItalic:"LiberationSans-BoldItalic"}},{key:"serif",name:"Liberation Serif",category:"serif",twin:"Times New Roman",reserved:"Liberation",docx:{name:"Times New Roman",family:"roman",pitch:"variable",panose:"02020603050405020304"},fallback:["Times New Roman","Times","Liberation Serif","serif"],dir:"liberation",licence:"LICENSE-OFL-1.1.txt",styles:{regular:"LiberationSerif-Regular",bold:"LiberationSerif-Bold",italic:"LiberationSerif-Italic",boldItalic:"LiberationSerif-BoldItalic"}},{key:"mono",name:"Liberation Mono",category:"mono",twin:"Courier New",reserved:"Liberation",docx:{name:"Courier New",family:"modern",pitch:"fixed",panose:"02070309020205020404"},fallback:["Courier New","Liberation Mono","Consolas","monospace"],dir:"liberation",licence:"LICENSE-OFL-1.1.txt",styles:{regular:"LiberationMono-Regular",bold:"LiberationMono-Bold",italic:"LiberationMono-Italic",boldItalic:"LiberationMono-BoldItalic"}},{key:"notosans",name:"Noto Sans",category:"sans",docx:{name:"Noto Sans",family:"swiss",pitch:"variable",altName:"Arial"},fallback:["Noto Sans","Arial","sans-serif"],dir:"notosans",licence:"OFL.txt",styles:{regular:"NotoSans-Regular",bold:"NotoSans-Bold",italic:"NotoSans-Italic",boldItalic:"NotoSans-BoldItalic"}},{key:"zilla",name:"Zilla Slab",category:"slab",docx:{name:"Zilla Slab",family:"roman",pitch:"variable",altName:"Rockwell"},fallback:["Rockwell","Georgia","serif"],dir:"zilla",licence:"OFL.txt",styles:{regular:"ZillaSlab-Regular",bold:"ZillaSlab-Bold",italic:"ZillaSlab-Italic",boldItalic:"ZillaSlab-BoldItalic"}},{key:"jetbrains",name:"JetBrains Mono",category:"mono",docx:{name:"JetBrains Mono",family:"modern",pitch:"fixed",altName:"Consolas"},fallback:["Consolas","Menlo","Courier New","monospace"],dir:"jetbrains",licence:"OFL.txt",styles:{regular:"JetBrainsMono-Regular",bold:"JetBrainsMono-Bold",italic:"JetBrainsMono-Italic",boldItalic:"JetBrainsMono-BoldItalic"}},{key:"playfair",name:"Playfair Display",category:"display",reserved:"Playfair Display",docx:{name:"Playfair Display",family:"roman",pitch:"variable",altName:"Georgia"},fallback:["Didot","Bodoni MT","Georgia","serif"],dir:"playfair",licence:"OFL.txt",styles:{regular:"PlayfairDisplay-Regular",bold:"PlayfairDisplay-Bold",italic:"PlayfairDisplay-Italic",boldItalic:"PlayfairDisplay-BoldItalic"}},{key:"caveat",name:"Caveat",category:"handwriting",docx:{name:"Caveat",family:"script",pitch:"variable",altName:"Segoe Print"},fallback:["Segoe Print","Bradley Hand","cursive"],dir:"caveat",licence:"OFL.txt",styles:{regular:"Caveat-Regular",bold:"Caveat-Bold"}}]};var Ww={regular:{weight:400,style:"normal"},bold:{weight:700,style:"normal"},italic:{weight:400,style:"italic"},boldItalic:{weight:700,style:"italic"}},ct=Bo.families.map((n,e)=>({key:n.key,name:n.name,index:e+1,cssName:"Docs "+n.name,docx:n.docx.name,fallback:n.fallback,faces:Object.keys(n.styles).map(t=>Ww[t])})),wc=new Map(ct.map(n=>[n.key,n])),Sc=ct.map(n=>n.key),Be=Bo.default,Nn=Bo.code,Lo=Sc.map(n=>"font_"+n).reverse();function jp(n){if(wc.has(n))return n===Be?null:"font_"+n}function Yp(n){for(let e of Lo)if(n.includes(e))return e.slice(5);return Be}function Uo(n){let e=String(n||"").split(",").map(t=>t.trim().replace(/^["']|["']$/g,"").toLowerCase()).filter(Boolean);for(let t of e){let r=ct.find(i=>i.cssName.toLowerCase()===t)||ct.find(i=>i.docx.toLowerCase()===t)||ct.find(i=>i.name.toLowerCase()===t)||ct.find(i=>i.fallback.some(s=>s.toLowerCase()===t));if(r)return r.key}return null}function Jw(){if(!wc.has(Be))throw new Error(`fonts: the default ${Be} is not a family`);if(!wc.has(Nn))throw new Error(`fonts: the code face ${Nn} is not a family`);if(Sc[0]!==Be)throw new Error(`fonts: the toolbar lists ${Sc[0]} first but the default is ${Be}`);for(let n of ct)if(!n.faces.some(e=>e.weight===400&&e.style==="normal"))throw new Error(`fonts: ${n.key} has no regular`)}Jw();var Tt=[12,8,9,10,11,14,18,24,36,48,72],Yt=12,Kt=[...Tt.filter(n=>n!==Yt).map(n=>"size_"+n),"size_sm","size_lg","size_xl"],Vo={size_sm:10,size_lg:14,size_xl:18};function Kp(n){let e=Number(n);if(Tt.includes(e))return e===Yt?null:"size_"+e}function Hp(n){for(let e of Kt)if(n.includes(e))return e in Vo?Vo[e]:Number(e.slice(5));return Yt}function jw(){if(!Tt.includes(Yt))throw new Error(`sizes: the default ${Yt} is not one of [${Tt}]`);if(Tt[0]!==Yt)throw new Error(`sizes: the control lists ${Tt[0]} first but the default is ${Yt} \u2014 with no JavaScript the control would name a size the text is not set in`);for(let[t,r]of Object.entries(Vo)){if(!Tt.includes(r))throw new Error(`sizes: the legacy mark ${t} maps to ${r}pt, which is not on the ladder [${Tt}]`);if(!Kt.includes(t))throw new Error(`sizes: the legacy mark ${t} is not in the group the toolbar clears`)}let n=Tt.filter(t=>t!==Yt).map(t=>"size_"+t),e=Kt.filter(t=>!(t in Vo));if(n.join()!==e.join())throw new Error(`sizes: the marks [${e}] do not match the offered sizes [${n}]`)}jw();var Cc={align_left:null,align_center:"center",align_right:"right"};function Yw(){let n=Object.keys(Cc);for(let r of n){let i=Cc[r],s="align_"+(i===null?"left":i);if(r!==s)throw new Error(`toolbar: ${r} sets the alignment ${JSON.stringify(i)}, which belongs to ${s}`);if(i!==null&&!vo(i))throw new Error(`toolbar: ${r} sets ${JSON.stringify(i)}, which align.mjs does not know`)}let e=n.map(r=>r.slice(6)).sort(),t=[...$p].sort();if(e.join()!==t.join())throw new Error(`toolbar: alignment commands [${e}] do not match align.mjs's [${t}]`)}Yw();function kc(n){let e=n.previousElementSibling;return!e||!e.hasAttribute("rst-combo")?null:e.querySelector("input")}function Kw(n,e){if(!e)return;let t=n.getAttribute("aria-label");t&&Er(e,"aria-label",t)}var Fo=!1;function Hw(n,e,t){if(!e||document.activeElement===e)return;if(t&&typeof n.dispatchEvent=="function"){Fo=!0;try{n.dispatchEvent(new Event("change"))}finally{Fo=!1}return}let r=n.options[n.selectedIndex],i=r&&r.dataset||{},s=r?i.rstShort||i.rstName||r.text:"";ve(e,"value",s)}function tm({root:n,schema:e,getView:t,onSync:r,fonts:i=null,wrapCommand:s=l=>l,onFontUnavailable:o=null}){if(!n)return{plugin:null,commands:Gp(e,s),focusStop:()=>!1};let l=Array.from(n.querySelectorAll("[data-docs-command]")),a=Array.from(n.querySelectorAll("[data-docs-select]")),c=n.ownerDocument,f=c&&c.querySelector&&c.querySelector("[estilo-bar]");f&&Er(f,"data-rst-select-ceiling","");let u=Gp(e,s);n.addEventListener("pointerdown",g=>{let y=g.target;if(!y||!y.hasAttribute||!y.hasAttribute("rst-combo"))return;let b=y.querySelector("input");!b||b.disabled||(g.preventDefault(),c.activeElement===b?b.blur():b.focus())});for(let g of l)g.addEventListener("mousedown",y=>y.preventDefault()),g.addEventListener("click",()=>{let y=u[g.getAttribute("data-docs-command")],b=t();!b||!y||(y(b.state,b.dispatch,b),b.focus())});for(let g of a)g.addEventListener("mousedown",y=>y.stopPropagation()),g.addEventListener("change",()=>{if(Fo)return;let y=t();y&&y.focus()}),g.addEventListener("change",()=>{if(Fo)return;let y=t();if(!y)return;let b=g.getAttribute("data-docs-select"),k=g.value;if(b==="block"&&qi(e,k)(y.state,y.dispatch,y),b==="font"){let I=jp(k);I!==void 0&&Xp(e,Lo,I)(y.state,y.dispatch)}if(b==="size"){let I=Kp(k);I!==void 0&&Xp(e,Kt,I)(y.state,y.dispatch)}y.focus()});function h(g){let y=g.state;for(let b of l){let k=b.getAttribute("data-docs-command"),I=u[k];if(!I)continue;let z=I(y,null,g);ve(b,"disabled",!z);let ue=Qp(y,e,k);Er(b,"aria-pressed",ue?"true":"false")}for(let b of a){let k=b.getAttribute("data-docs-select")==="font"&&i&&i.previews==="pending";ve(b,"disabled",k);let I=kc(b);I&&ve(I,"disabled",k),Kw(b,I);let z=b.getAttribute("data-docs-select"),ue=b.value;z==="block"&&ve(b,"value",em(y)),z==="font"&&ve(b,"value",Zw(y,e)),z==="size"&&ve(b,"value",String(Hp(Qw(y,e,Kt)))),Hw(b,kc(b),b.value!==ue)}r&&r(g)}let d=zp(n,[...l,...a.map(g=>kc(g)||g)]),p=new ye({view:g=>{h(g),d.ensureReachable();let y=je.getState(g.state)?.undoManager,b=()=>{h(g),d.ensureReachable()};return y&&(y.on("stack-item-added",b),y.on("stack-item-popped",b)),{update:k=>{h(k),d.ensureReachable()},destroy:()=>{y&&(y.off("stack-item-added",b),y.off("stack-item-popped",b))}}}}),m=(g,y)=>y.startsWith("block_")?em(g)===y.slice(6):Qp(g,e,y);return{plugin:p,commands:u,focusStop:d.focusStop,isPressed:m}}function Gp(n,e=t=>t){let t=n.marks,r=n.nodes;return{undo:ep,redo:tp,strong:e(Dn(t.strong)),em:e(Dn(t.em)),code:e(Dn(t.code),!0),bullet_list:Zp(r.bullet_list,r.list_item),ordered_list:Zp(r.ordered_list,r.list_item),blockquote:Xw(r.blockquote),select_all:pc,clear_formatting:Gw,block_paragraph:qi(n,"paragraph"),"block_heading-1":qi(n,"heading-1"),"block_heading-2":qi(n,"heading-2"),"block_heading-3":qi(n,"heading-3"),indent:lt(No(r.list_item),Cr(1)),outdent:lt(Pi(r.list_item),Cr(-1)),...Object.fromEntries(Object.entries(Cc).map(([i,s])=>[i,Wp(s)]))}}function Gw(n,e){let{from:t,to:r,empty:i}=n.selection;if(i)return!1;if(e){let s=n.tr.removeMark(t,r,null);s.setBlockType(t,r,n.schema.nodes.paragraph),e(s.scrollIntoView())}return!0}function qi(n,e){if(e==="paragraph")return mc(n.nodes.paragraph);let t=Number(e.split("-")[1]);return Number.isInteger(t)?mc(n.nodes.heading,{level:t}):()=>!1}function Xp(n,e,t){return(r,i)=>{let s=e.map(u=>n.marks[u]).filter(Boolean),o=t?n.marks[t]:null;if(t&&!o)return!1;if(!i)return!0;let{from:l,to:a,empty:c}=r.selection;if(c){let u=(r.storedMarks||r.selection.$from.marks()).filter(h=>!s.includes(h.type));return o&&(u=o.create().addToSet(u)),i(r.tr.setStoredMarks(u)),!0}let f=r.tr;for(let u of s)f.removeMark(l,a,u);return o&&f.addMark(l,a,o.create()),i(f),!0}}function Zp(n,e){let t=lp(n),r=Pi(e);return(i,s,o)=>Wi(i,n)?r(i,s,o):t(i,s,o)}function Xw(n){let e=yp(n);return(t,r,i)=>Wi(t,n)?pp(t,r,i):e(t,r,i)}function Wi(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 Qp(n,e,t){if(t.startsWith("align_"))return Jp(n)===t.slice(6);if(t==="bullet_list")return Wi(n,e.nodes.bullet_list);if(t==="ordered_list")return Wi(n,e.nodes.ordered_list);if(t==="blockquote")return Wi(n,e.nodes.blockquote);let r=e.marks[t];return r?Ec(n,r):!1}function Ec(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 em(n){let e=n.selection.$from.parent;return e.type.name==="heading"?"heading-"+e.attrs.level:"paragraph"}function Zw(n,e){let t=Lo.filter(r=>{let i=e.marks[r];return i&&Ec(n,i)});return Yp(t)}function Qw(n,e,t){let r=[];for(let i of t){let s=e.marks[i];s&&Ec(n,s)&&r.push(i)}return r}var eS={print:()=>(window.print(),!0)};function Ac(n){return n.querySelector("[estilo-menubar-menu][open]")}function Dc(n){return Array.from(n.querySelectorAll("[estilo-menubar-title]"))}function Mc(n){return Array.from(n.querySelectorAll("[estilo-menu-item]")).filter(e=>!e.disabled)}function Tc(n,e){for(let t of Dc(n))ve(t,"tabIndex",t===e?0:-1);e.focus()}function Po(n){let e=Ac(n);e&&(e.open=!1)}function nm(n,{getView:e,commands:t,extraCommands:r,isPressed:i}){if(!n)return null;let s=Dc(n);if(!s.length)return null;for(let[c,f]of s.entries())ve(f,"tabIndex",c===0?0:-1);let o={...eS,...r||{}};function l(c,f){let u=o[c];if(u){if(f){let m=f.closest("[estilo-menubar-menu]");if(m){let g=m.querySelector("[estilo-menubar-title]");g&&Tc(n,g)}}return u()}let h=e();if(!h)return!1;let d=t[c];if(!d)return!1;let p=d(h.state,h.dispatch,h);return h.focus(),p}n.addEventListener("click",c=>{let f=c.target.closest("[estilo-menu-item]");if(!(!f||f.disabled)){if(!f.hasAttribute("data-docs-command")){Po(n);return}c.preventDefault(),l(f.getAttribute("data-docs-command"),f),Po(n)}}),n.addEventListener("keydown",c=>{let f=c.target.closest("[estilo-menubar-title]"),u=c.target.closest("[estilo-menu-item]"),h=Ac(n);switch(c.key){case"ArrowRight":case"ArrowLeft":{let d=f||h&&h.querySelector("[estilo-menubar-title]");if(!d)return;c.preventDefault();let p=Dc(n),m=p[(p.indexOf(d)+(c.key==="ArrowRight"?1:-1)+p.length)%p.length],g=!!h;Po(n),g&&(m.closest("[estilo-menubar-menu]").open=!0),Tc(n,m);return}case"ArrowDown":case"ArrowUp":{if(f){c.preventDefault();let d=f.closest("[estilo-menubar-menu]");d.open=!0;let p=Mc(d);p.length&&p[c.key==="ArrowDown"?0:p.length-1].focus();return}if(u&&h){c.preventDefault();let d=Mc(h),p=d.indexOf(u);if(p<0||!d.length)return;d[(p+(c.key==="ArrowDown"?1:-1)+d.length)%d.length].focus()}return}case"Home":case"End":{if(!u||!h)return;c.preventDefault();let d=Mc(h);d.length&&d[c.key==="Home"?0:d.length-1].focus();return}case"Tab":Po(n)}}),n.addEventListener("pointerover",c=>{if(c.pointerType&&c.pointerType!=="mouse")return;let f=c.target.closest&&c.target.closest("[estilo-menubar-title]"),u=Ac(n);if(!f||!u||u.contains(f))return;let h=f.closest("[estilo-menubar-menu]");h&&(h.open=!0,Tc(n,f))});function a(c){for(let f of n.querySelectorAll("[estilo-menu-item][data-docs-command]")){let u=f.getAttribute("data-docs-command"),h=!1;if(f.hasAttribute("aria-pressed")&&i&&(h=!!i(u,c),Er(f,"aria-pressed",h?"true":"false")),o[u]){ve(f,"disabled",!1);continue}let d=t[u],p=!!(c&&d&&(h||d(c.state,null,c)));ve(f,"disabled",!p)}}return{sync:a}}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 tS(n){let e=new Set,t=!1;return n&&typeof n.addEventListener=="function"&&(n.addEventListener("pagehide",()=>{t=!0;for(let r of[...e])r.leave()}),n.addEventListener("pageshow",r=>{let i=t&&r&&r.persisted;if(t=!1,i)for(let s of[...e])s.back()})),{get left(){return t},subscribe(r){return e.add(r),()=>e.delete(r)}}}var nS=tS(typeof window>"u"?null:window);function rm({initialSeq:n=0,openStream:e,fetchSince:t,onUpdates:r,onError:i=()=>{},setTimeoutFn:s=setTimeout,clearTimeoutFn:o=clearTimeout,idleMs:l=12e4,hiddenMs:a=3e4,page:c=nS}){let f=n,u=null,h=null,d=!1,p=!1,m=!1;function g(E){h!==null&&o(h),h=s(()=>{h=null,b()},E)}function y(){g(l)}function b(){h!==null&&(o(h),h=null),u&&(u.close(),u=null)}function k(){d||u||c.left||(u=e(E=>{y(),E>f&&I()},E=>{b(),i(E)}),y())}async function I(){if(p){m=!0;return}p=!0;try{let E=f,_=await t(E);if(d)return;try{_&&_.bytes&&_.bytes.length&&await r(_.bytes)}catch{if(_=await t(E,{raw:!0}),d)return;_&&_.bytes&&_.bytes.length&&await r(_.bytes)}_&&typeof _.seq=="number"&&_.seq>f&&(f=_.seq)}catch(E){i(E)}finally{p=!1,m&&!d&&(m=!1,I())}}let z=null,ue={leave:()=>b(),back:()=>{s(()=>{d||k()},0)}};return{start(){d=!1,z||(z=c.subscribe(ue)),k()},stop(){d=!0,z&&z(),z=null,b()},noteOwnSeq(E){typeof E!="number"||!Number.isFinite(E)||E===f+1&&(f=E)},noteActivity(){d||(u?y():k())},noteHidden(){d||!u||g(a)},get cursor(){return f},get streaming(){return u!==null}}}var sm=3e3;var im=new Map([["code",Nn]]);function om(n){im.clear();for(let[e,t]of n)im.set(e,t)}function lm(n){let e=()=>!0;return{web:!1,ready:e,loaded:e,committed:()=>!1,fallback:[],inUse:[],use(){},required:()=>[],markShown(){},shown:!0,previews:"system",previewsDone:Promise.resolve("system"),prepare:async()=>{},prepareRemote:async()=>{},waitFor:async()=>!0,load:async()=>!0,commitFallback:()=>!0,prefetch:async()=>{},fontsReady:Promise.resolve(),settled(){!n||n.getAttribute("data-docs-fonts")!=="pending"||(clearTimeout(globalThis.__docsFontsHold),n.setAttribute("data-docs-fonts","shown"),n.getAttribute("data-docs-previews")==="pending"&&n.setAttribute("data-docs-previews","system"))}}}function am(n,{setTimer:e=setTimeout,clearTimer:t=clearTimeout}={}){if(!n)return{say(){},clear(){},state:""};let r=n.querySelector("[docs-fonts-status-text]"),i=n.querySelector("[docs-fonts-status-dismiss]"),s=null,o=()=>n.getAttribute("data-state")||"";function l(a){a&&o()!==a||(t(s),n.removeAttribute("data-state"),r&&(r.textContent=""))}return i&&i.addEventListener("click",()=>l()),{say(a,c=0){t(s),n.setAttribute("data-state",a),r&&(r.textContent=n.getAttribute("data-"+a)||""),c&&(s=e(()=>l(a),c))},clear:l,get state(){return o()}}}var rS=["p",0],iS=["blockquote",0],sS=["hr"],oS=["pre",["code",0]],lS=["br"],aS={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return rS}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM(){return iS}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return sS}},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 oS}},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 lS}}},cS=["em",0],fS=["strong",0],uS=["code",0],hS={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 cS}},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 fS}},code:{code:!0,parseDOM:[{tag:"code"}],toDOM(){return uS}}},Mr=new ar({nodes:aS,marks:hS});function cm(n,e){return{group:e,excludes:e,parseDOM:[{tag:"span."+n}],toDOM:()=>["span",{class:n},0]}}var dS=Kt.reduce((n,e)=>n.addToStart(e,cm("docs-"+e.replace("_","-"),"fontSize")),Mr.spec.marks),pS=[...ct].reverse().reduce((n,e)=>{let t=cm("docs-font-"+e.key,"fontFamily");return e.key!==Be?t.parseDOM=[...t.parseDOM,{style:"font-family",getAttrs:r=>Uo(r)===e.key?null:!1}]:t.parseDOM=[...t.parseDOM,{style:"font-family",getAttrs:r=>Uo(r)===Be||Uo(r)===null?null:!1,clearMark:r=>r.type.spec.group==="fontFamily"}],n.addToStart("font_"+e.key,t)},dS),mS=op(Mr.spec.nodes.update("paragraph",xc(qp(Mr.spec.nodes.get("paragraph")),"p")).update("heading",xc(Mr.spec.nodes.get("heading"),"h1")).update("hard_break",Vp(Mr.spec.nodes.get("hard_break"))),"paragraph block*","block"),fe=new ar({nodes:mS,marks:pS});function Tr(n){let e=n.name||n;if(typeof e=="string"&&e.startsWith("font_"))return e.slice(5);let t=typeof n=="string"?fe.marks[n]:n;return t&&t.spec.code?Nn:null}function Ji(n){let e=typeof n=="string"?fe.nodes[n]:n;return e&&e.spec.code?Nn:null}function fm(n,e=new Set([Be])){return n.descendants(t=>{let r=Ji(t.type);r&&e.add(r);for(let i of t.marks){let s=Tr(i.type);s&&e.add(s)}}),e}om([...Object.values(fe.nodes).filter(n=>Ji(n)).map(n=>[n.name,Ji(n)]),...Object.values(fe.marks).filter(n=>!n.name.startsWith("font_")&&Tr(n)).map(n=>[n.name,Tr(n)])]);function yS(n,e){return e&&e(n.tr.replaceSelectionWith(fe.nodes.hard_break.create()).scrollIntoView()),!0}var xS=250,ji="carried",um=500;function Nc(n,e){if(!e.length)return;let t=et(e);for(;rs(t);)fu(t,n,"server")}function dm(){return globalThis.docsFonts||lm(document.documentElement)}function bS(){return document.documentElement.getAttribute("data-docs-layout")==="frozen"}function wS(n){let e=new Set([Be]),t=r=>{if(r instanceof pe){for(let i of r.toDelta())for(let s of Object.keys(i.attributes||{})){let o=Tr(s);o&&e.add(o)}return}if(r instanceof ee){let i=Ji(r.nodeName);i&&e.add(i)}for(let i of r.toArray())t(i)};return t(n),[...e]}function SS(n){let e=new Set,t=r=>{let i=Tr(r.type);i&&e.add(i)};for(let r of n.steps)r.slice&&fm(r.slice.content,e),r.mark&&t(r.mark);return n.storedMarksSet&&n.storedMarks&&n.storedMarks.forEach(t),e.delete(void 0),[...e]}function hm(){return new Promise(n=>requestAnimationFrame(()=>n()))}async function kS(n){let e=n.getAttribute("data-sqid"),t=dm(),r=`/d/${e}/updates`,i=`/d/${e}/stream`,s=document.querySelector("[estilo-save-status]"),o=new URL(n.getAttribute("data-save-status-module"),location.href);if(!s||o.origin!==location.origin)throw new Error("Invalid save-status module");let{mount:l}=await import(o.href),a=l(s),c=!1,f=null,u=null,h=null,d=sp(),p=null,m=null;function g(w,C,M){if(p||!Dr.diverged||!C.some(D=>D.docChanged))return M();let R=C.map(D=>D.getMeta(q)).filter(Boolean);if(R.length){if(R.some(D=>D.isUndoRedoOperation)){let D=ip(w.before,C[C.length-1].doc);D&&(m={tr:{before:w.before,steps:[D]},schema:fe,locate:P=>P.getXmlFragment("prosemirror")})}return M()}p={tr:{before:w.before,steps:C.flatMap(D=>D.steps)},schema:fe,locate:D=>D.getXmlFragment("prosemirror")};try{M()}finally{p=null}}let y=null,b=null,k=document.querySelector("[docs-canvas]"),I=k&&k.getAttribute("data-view")===On?On:$i,z=k?k.getAttribute("data-page-label"):"",ue=!1;t.fontsReady.then(()=>{document.documentElement.getAttribute("data-docs-fonts")!=="pending"&&document.documentElement.setAttribute("data-docs-layout","frozen"),ue=!0});let E=()=>ue&&!bS()?I:$i;function _(w){I=w,document.documentElement.removeAttribute("data-docs-layout"),k&&k.setAttribute("data-view",w),Ep(w);let C=u;C&&C.dispatch(C.state.tr)}let K=Op(document.querySelector("[docs-wordcount]"),{getView:()=>u}),In=Np(document.querySelector("[docs-shortcuts]"),{menubar:document.querySelector("[estilo-menubar]"),extraRows:Array.from(document.querySelectorAll("[docs-shortcuts-extra] span")).map(w=>({group:w.closest("[docs-shortcuts-extra]").getAttribute("data-group")||"",label:w.getAttribute("data-label")||"",keys:w.getAttribute("data-keys")||""}))}),ft=!1,A=[],L=()=>ft?new Promise(w=>A.push(w)):Promise.resolve(),W=am(document.querySelector("[docs-fonts-status]")),Le=[document.querySelector("[docs-toolbar]"),document.querySelector("[estilo-menubar]")].filter(Boolean),Ye=document.querySelector("[docs-page]"),Ar=8e3,zo=new ye({filterTransaction(w){if(w.getMeta(q))return!0;if(ft)return!w.docChanged&&!w.storedMarksSet?!0:(W.say("refused"),!1);let C=SS(w),M=C.filter(D=>!t.ready(D));if(!M.length)return t.use(C),!0;if(u&&u.composing)return t.commitFallback(M),t.use(C),!0;let R=u;return At(M,()=>R!==u||R.state.doc!==w.before?!1:(R.dispatch(w),!0)),!1}});async function At(w,C){ft=!0,Rc(!0);let M=!1;try{M=await t.waitFor(w,sm)&&w.every(R=>t.loaded(R)||t.committed(R))}catch{M=!1}ft=!1,Rc(!1);try{M=M&&C()!==!1}catch(R){console.error("fonts:",R),M=!1}finally{M?W.clear():W.say("unavailable",Ar);let R=A;A=[];for(let D of R)D()}}let pm=new Set(["Backspace"," ","Spacebar","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"]),mm=w=>{if(!pm.has(w.key))return;let C=w.target;(!C||C===document.body||C===document.documentElement||C.closest&&C.closest("[inert]"))&&w.preventDefault()},gm=w=>{w.preventDefault(),w.returnValue=""},_c=!1;function Rc(w){let C=w?"addEventListener":"removeEventListener";window[C]("keydown",mm),window[C]("beforeunload",gm);let M=u,R=M&&M.dom;w&&(_c=!!R&&(R.contains(document.activeElement)||Le.some(D=>D.contains(document.activeElement))));for(let D of[...Le,R])D&&(D.inert=w);Ye&&Ye.setAttribute("aria-busy",w?"true":"false"),w?W.say("loading"):_c&&M&&(!document.activeElement||document.activeElement===document.body)&&M.focus()}let $o=w=>(C,M,R)=>{if(!M)return w(C,M,R);if(ft)return W.say("refused"),!0;let D=t.inUse.filter(P=>!t.ready(P));return D.length?(At(D,()=>{let P=u;return P?(w(P.state,P.dispatch,P),!0):!1}),!0):w(C,M,R)},ym=()=>W.say("unavailable",Ar),_n=tm({root:document.querySelector("[docs-toolbar]"),schema:fe,fonts:t,onFontUnavailable:ym,getView:()=>u,onSync:w=>{b&&b.sync(w)}});b=nm(document.querySelector("[estilo-menubar]"),{getView:()=>u,commands:_n.commands,isPressed:(w,C)=>w==="view_paged"?I===On:w==="view_infinite"?I===$i:!!(C&&_n.isPressed&&_n.isPressed(C.state,w)),extraCommands:{view_paged:()=>(_(On),!0),view_infinite:()=>(_($i),!0),...K?{word_count:K}:{},...In?{shortcuts:In}:{}}});function qo(w){a(c?"failed":w)}let xm=vp({url:r});function bm(w){return Lp({post:async(C,M)=>{let R=await xm(C,M),D=w();if(R.ok&&D){let P=Number(R.headers.get("Docs-Seq"));Number.isFinite(P)&&D.noteOwnSeq(P)}return R},mergeUpdates:Ys,debounceMs:xS,maxBatchBytes:32768,answerTimeoutMs:Rp,probe:()=>Bp("/healthz"),onStatus:C=>{C==="failed"&&(c=!0,Dr.reportDivergence()),qo(C==="saving"?"ok":C)}})}function wm(w){let C=u;if(!C||w.button!==0||C.dom.contains(w.target))return;let M=C.dom.getBoundingClientRect(),R=C.posAtCoords({left:Math.min(Math.max(w.clientX,M.left+1),M.right-1),top:Math.min(Math.max(w.clientY,M.top+1),M.bottom-1)}),D=R?R.pos:C.state.doc.content.size,P=B.near(C.state.doc.resolve(D));w.preventDefault(),C.dispatch(C.state.tr.setSelection(P).scrollIntoView()),C.focus()}function Sm(w,C,M){let R=[Qa(C),np({undoManager:M}),Cp(fe),Mp({getMode:E,pageLabel:z}),zo,uc({"Mod-z":$o(ic),"Mod-y":$o(Oo),"Mod-Shift-z":$o(Oo),"Mod-b":Dn(fe.marks.strong),"Mod-i":Dn(fe.marks.em),"Shift-Enter":yS,Tab:lt(No(fe.nodes.list_item),Cr(1)),"Shift-Tab":lt(Pi(fe.nodes.list_item),Cr(-1)),Backspace:Sp,Escape:()=>_n.focusStop(),Enter:lt(ap(fe.nodes.list_item),gc.Enter)}),uc(gc)];return _n.plugin&&R.push(_n.plugin),new Ii({mount:w},{state:pr.create({schema:fe,plugins:R}),dispatchTransaction(D){let{state:P,transactions:he}=this.state.applyTransaction(D);g(D,he,()=>this.updateState(P))},transformPasted:Fp(fe)})}async function vc(w){let C=Oc(r,{raw:w}),M=await fetch(C,{credentials:"same-origin"});if(!M.ok)throw new Error(`load ${C}: ${M.status}`);return{log:new Uint8Array(await M.arrayBuffer()),startSeq:Number(M.headers.get("Docs-Seq"))}}async function Bc(){for(;ft;)await L();let{log:w,startSeq:C}=await vc(!1),M=new Ie;try{Nc(M,w)}catch{({log:w,startSeq:C}=await vc(!0)),M=new Ie,Nc(M,w)}let R=M.getXmlFragment("prosemirror");await t.prepare(wS(R));let D=null,P=bm(()=>D),he=M;for(he.on("update",(J,ut)=>{if(ut!=="server"){if(Dr.diverged){if(he===h&&ut!==ji){let Dt=p||m||void 0;m=null,d.keep(he,J,Dt)}return}P.enqueue(J)}}),he.on("beforeTransaction",J=>{he!==h||!Dr.diverged||J.origin==="server"||J.origin===ji||(m=null,d.before(he,J.origin===q?"pm":"other"))});ft;)await L();let Vc=new Ut(R,{trackedOrigins:new Set([q,ji]),captureTimeout:um,deleteFilter:J=>oc(J,sc),captureTransaction:J=>J.meta.get("addToHistory")!==!1}),Fc=(J,ut)=>{(!ut||J.at-ut.at>=um)&&Vc.stopCapturing()},Pc=ac(he,d.take(),ji,Fc);u&&u.destroy(),f=P,h=he,u=Sm(n,R,Vc),y&&y.stop(),D=rm({initialSeq:Number.isFinite(C)?C:0,openStream:(J,ut)=>{let Dt=new EventSource(i,{withCredentials:!0});return Dt.addEventListener("update",Ot=>J(Number(Ot.data))),Dt.addEventListener("error",Ot=>ut(Ot)),{close:()=>Dt.close()}},fetchSince:async(J,{raw:ut}={})=>{let Dt=Oc(r,{since:J,raw:ut}),Ot=await fetch(Dt,{credentials:"same-origin"});if(!Ot.ok)throw new Error(`fetch ${Dt}: ${Ot.status}`);return{bytes:new Uint8Array(await Ot.arrayBuffer()),seq:Number(Ot.headers.get("Docs-Seq"))}},onUpdates:async J=>{await t.prepareRemote(J),await L(),!(Dr.diverged||y!==D)&&Nc(M,J)},onError:J=>{console.error("live updates:",J)}}),y=D,y.start(),typeof document<"u"&&document.hidden&&y.noteHidden();let zc=ac(he,d.take(),ji,Fc);for(let J of Pc.post.concat(zc.post))P.enqueue(J);Pc.lost+zc.lost&&console.warn("resync: a change made on top of a refused one could not be carried over")}let Dr=Up({attemptResync:Bc,onDiverged:()=>{h&&(h.clientID=lc(h)),qo("failed")},onRecovered:()=>qo(c?"failed":"ok")});addEventListener("pageshow",w=>{w.persisted&&f&&f.resume()}),await Bc(),await t.fontsReady,u&&u.dispatch(u.state.tr.setMeta("docs-fonts-ready",!0)),t.previewsDone.then(()=>u&&u.dispatch(u.state.tr.setMeta("docs-previews-ready",!0))),await hm(),await hm(),t.settled();let Or=u;Or&&Or.editable&&Or.state.doc.textContent===""&&Or.state.doc.childCount<=1&&(!document.activeElement||document.activeElement===document.body)&&Or.focus(),addEventListener("visibilitychange",()=>{document.hidden?y&&y.noteHidden():y&&y.noteActivity()});for(let w of["pointermove","scroll","keydown","focus"])addEventListener(w,()=>y&&y.noteActivity(),{passive:!0,capture:!0});let Lc=n.closest("[docs-page]");Lc&&Lc.addEventListener("mousedown",wm);let Wo=!1,Uc=()=>{Wo=!0,setTimeout(()=>{Wo=!1},0)};return document.addEventListener("mousedown",Uc,!0),document.addEventListener("touchstart",Uc,!0),n.addEventListener("focus",()=>{if(Wo)return;let w=u;w&&w.dispatch(w.state.tr.scrollIntoView())}),addEventListener("beforeunload",()=>{let w=[];for(let P of d.entries)w.push(...P.updates);let C=P=>{let he=P?[P,...w]:w;return he.length?he.length===1?he[0]:Ys(he):null},M=f,R=C(M&&M.pendingBytes({wire:"plain"}));if(!R)return;let D=[R];if(M&&M.onWire==="plain"){let P=C(M.pendingBytes({wire:"none"}));P&&D.push(P)}for(let P of D)if(navigator.sendBeacon(r,new Blob([P],{type:"application/octet-stream"})))return;console.error("beforeunload: sendBeacon refused the pending edit, retrying via keepalive fetch"),fetch(r,{method:"POST",credentials:"same-origin",keepalive:!0,headers:{"Content-Type":"application/octet-stream"},body:D[D.length-1]}).catch(()=>{})}),u}var Ic=document.querySelector("[docs-editor]");Ic&&kS(Ic).catch(n=>{dm().settled(),Ic.setAttribute("data-editor-failed","1"),console.error(n)});export{kS as mountEditor};
+`).scrollIntoView()),!0)};function dc(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 dw=(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=dc(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(B.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},pw=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof Ce||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=dc(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(V.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},mw=(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(Pt(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&gn(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function gw(n){return(e,t)=>{if(e.selection instanceof T&&e.selection.node.isBlock){let{$from:d}=e.selection;return!d.parentOffset||!Pt(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 V||e.selection instanceof Ce)&&r.deleteSelection();let{$from:i}=r.selection,s=r.steps.length,o=[],l,a,c=!1,f=!1;for(let d=i.depth;;d--)if(i.node(d).isBlock){c=i.end(d)==i.pos+(i.depth-d),f=i.start(d)==i.pos-(i.depth-d),a=dc(i.node(d-1).contentMatchAt(i.indexAfter(d-1)));let m=n&&n(i.parent,c,i);o.unshift(m||(c&&a?{type:a}:null)),l=d;break}else{if(d==1)return!1;o.unshift(null)}let u=i.pos,h=Pt(r.doc,u,o.length,o);if(h||(o[0]=a?{type:a}:null,h=Pt(r.doc,u,o.length,o)),!h)return!1;if(r.split(u,o.length,o),!c&&f&&i.node(l).type!=a){let d=r.mapping.slice(s),p=d.map(i.before(l)),m=r.doc.resolve(p);a&&i.node(l-1).canReplaceWith(m.index(),m.index()+1,a)&&r.setNodeMarkup(d.map(i.before(l)),a)}return t&&t(r.scrollIntoView()),!0}}var yw=gw();var pc=(n,e)=>(e&&e(n.tr.setSelection(new Ce(n.doc))),!0);function xw(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||yn(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function mp(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&xw(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(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 ie(e.pos-1,d,e.pos,d,new S(p,1,0),o.length,!0)),g=m.doc.resolve(d+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&yn(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let f=s.type.spec.isolating||r>0&&a?null:B.findFrom(e,1),u=f&&f.$from.blockRange(f.$to),h=u&&gn(u);if(h!=null&&h>=e.depth)return t&&t(n.tr.lift(u,h).scrollIntoView()),!0;if(c&&kr(s,"start",!0)&&kr(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 k=p.length-1;k>=0;k--)y=x.from(p[k].copy(y));let b=n.tr.step(new ie(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new S(y,p.length,0),0,!0));t(b.scrollIntoView())}return!0}}return!1}function gp(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(V.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}var bw=gp(-1),ww=gp(1);function yp(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&ur(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function mc(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,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let f=t.doc.resolve(c),u=f.index();i=f.parent.canReplaceWith(u,u+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:a}}=t.selection.ranges[o];s.setBlockType(l,a,n,e)}r(s.scrollIntoView())}return!0}}function Sw(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,(a,c)=>{if(l||!r&&a.isAtom&&a.isInline&&c>=s.pos&&c+a.nodeSize<=o.pos)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function kw(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 dr(r,r.doc.resolve(o+1))),r=r.doc.resolve(o+1+s.content.size),!1}),r.pos<i.pos&&e.push(new dr(r,i))}return e}function Dn(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:a,$cursor:c,ranges:f}=o.selection;if(a&&!c||!Sw(o.doc,f,n,i))return!1;if(l)if(c)n.isInSet(o.storedMarks||c.marks())?l(o.tr.removeStoredMark(n)):l(o.tr.addStoredMark(n.create(e)));else{let u,h=o.tr;i||(f=kw(f)),r?u=!f.some(d=>o.doc.rangeHasMark(d.$from.pos,d.$to.pos,n)):u=!f.every(d=>{let p=!1;return h.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<f.length;d++){let{$from:p,$to:m}=f[d];if(!u)h.removeMark(p.pos,m.pos,n);else{let g=p.pos,y=m.pos,b=p.nodeAfter,k=m.nodeBefore,I=s&&b&&b.isText?/^\s*/.exec(b.text)[0].length:0,z=s&&k&&k.isText?/\s*$/.exec(k.text)[0].length:0;g+I<y&&(g+=I,y-=z),h.addMark(g,y,n.create(e))}}l(h.scrollIntoView())}return!0}}function lt(...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 hc=lt(up,lw,aw),fp=lt(up,fw,uw),Mt={Enter:lt(hw,pw,mw,yw),"Mod-Enter":dw,Backspace:hc,"Mod-Backspace":hc,"Shift-Backspace":hc,Delete:fp,"Mod-Delete":fp,"Mod-a":pc},xp={"Ctrl-h":Mt.Backspace,"Alt-Backspace":Mt["Mod-Backspace"],"Ctrl-d":Mt.Delete,"Ctrl-Alt-Backspace":Mt["Mod-Delete"],"Alt-Delete":Mt["Mod-Delete"],"Alt-d":Mt["Mod-Delete"],"Ctrl-a":bw,"Ctrl-e":ww};for(let n in Mt)xp[n]=Mt[n];var Cw=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,gc=Cw?xp:Mt;function Ew(n){let e=yc(n);return e?"docs-indent-"+e:null}function yc(n){if(typeof n!="number"&&(typeof n!="string"||!/^\d+$/.test(n)))return 0;let e=Number(n);return!Number.isInteger(e)||e<1?0:Math.min(e,8)}function Mw(n){for(let e of n){if(!e.startsWith("docs-indent-"))continue;let t=yc(e.slice(12));if(t)return t}return null}function xc(n,e){let t=n.parseDOM||[{tag:e}];return{...n,attrs:{...n.attrs||{},indent:{default:null}},parseDOM:t.map(r=>({...r,getAttrs:i=>{let s=r.getAttrs?r.getAttrs(i):{};return s===!1?!1:{...s||{},indent:Mw(Array.from(i.classList||[]))}}})),toDOM:r=>{let i=n.toDOM?n.toDOM(r):[e,0],s=Ew(r.attrs.indent);if(!s)return i;let[o,l,...a]=i;if(l&&typeof l=="object"&&!Array.isArray(l)){let c={...l,class:l.class?l.class+" "+s:s};return[o,c,...a]}return[o,{class:s},l,...a]}}}function Cr(n){return(e,t)=>{let{from:r,to:i}=e.selection,s=!1,o=e.tr;return e.doc.nodesBetween(r,i,(l,a)=>{if(!l.type.isTextblock||!l.type.spec.attrs||!l.type.spec.attrs.indent)return;let c=yc(l.attrs.indent),f=Math.max(0,Math.min(8,c+n));f!==c&&(s=!0,t&&o.setNodeMarkup(a,null,{...l.attrs,indent:f===0?null:f}))}),s?(t&&t(o),!0):!1}}var at=class{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Tw(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}};function Tw(n){return function(e,t,r,i){let s=n;if(t[1]){let o=t[0].lastIndexOf(t[1]);s+=t[0].slice(o+t[1].length),r+=o;let l=r-i;l>0&&(s=t[0].slice(o-l,o)+s,r=i)}return e.tr.insertText(s,r,i)}}var Aw=500;function wp({rules:n}){let e=new ye({state:{init(){return null},apply(t,r){let i=t.getMeta(this);return i||(t.selectionSet||t.docChanged?null:r)}},props:{handleTextInput(t,r,i,s){return bp(t,r,i,s,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&bp(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function bp(n,e,t,r,i,s){if(n.composing)return!1;let o=n.state,l=o.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-Aw),l.parentOffset,null,"\uFFFC")+r;for(let c=0;c<i.length;c++){let f=i[c];if(!f.inCodeMark&&l.marks().some(p=>p.type.spec.code))continue;if(l.parent.type.spec.code){if(!f.inCode)continue}else if(f.inCode==="only")continue;let u=f.match.exec(a);if(!u||u[0].length<r.length)continue;let h=e-(u[0].length-r.length);if(!f.inCodeMark){let p=!1;if(o.doc.nodesBetween(h,l.pos,m=>{m.isInline&&m.marks.some(g=>g.type.spec.code)&&(p=!0)}),p)continue}let d=f.handler(o,u,h,t);if(d)return f.undoable&&d.setMeta(s,{transform:d,from:e,to:t,text:r}),n.dispatch(d),!0}return!1}var Sp=(n,e)=>{let t=n.plugins;for(let r=0;r<t.length;r++){let i=t[r],s;if(i.spec.isInputRules&&(s=i.getState(n))){if(e){let o=n.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a--)o.step(l.steps[a].invert(l.docs[a]));if(s.text){let a=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,n.schema.text(s.text,a))}else o.delete(s.from,s.to);e(o)}return!0}}return!1},L1=new at(/--$/,"\u2014",{inCodeMark:!1}),U1=new at(/\.\.\.$/,"\u2026",{inCodeMark:!1}),V1=new at(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C",{inCodeMark:!1}),F1=new at(/"$/,"\u201D",{inCodeMark:!1}),P1=new at(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018",{inCodeMark:!1}),z1=new at(/'$/,"\u2019",{inCodeMark:!1});function Ro(n,e,t=null,r){return new at(n,(i,s,o,l)=>{let a=t instanceof Function?t(s):t,c=i.tr.delete(o,l),f=c.doc.resolve(o),u=f.blockRange(),h=u&&ur(u,e,a);if(!h)return null;c.wrap(u,h);let d=c.doc.resolve(o-1).nodeBefore;return d&&d.type==e&&yn(c.doc,o-1)&&(!r||r(s,d))&&c.join(o-1),c})}function kp(n,e,t=null){return new at(n,(r,i,s,o)=>{let l=r.doc.resolve(s),a=t instanceof Function?t(i):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?r.tr.delete(s,o).setBlockType(s,s,e,a):null})}var Dw=/^\s*([-+*])\s$/,Ow=/^(\d+)\.\s$/,Nw=/^\s*>\s$/,Iw=/^(#{1,3})\s$/;function Cp(n){let e=[],{bullet_list:t,ordered_list:r,blockquote:i,heading:s}=n.nodes;return t&&e.push(Ro(Dw,t)),r&&e.push(Ro(Ow,r)),i&&e.push(Ro(Nw,i)),s&&e.push(kp(Iw,s,o=>({level:o[1].length}))),wp({rules:e})}var zi=new zt("docs-pages"),_w=864,On="paged",$i="infinite",Rw="docs-view";function Ep(n){document.cookie=`${Rw}=${n}; Path=/; Max-Age=31536000; SameSite=Lax`}function vw(n){let e=[],t=n.state.doc,r=null;return t.forEach((i,s)=>{let o=n.nodeDOM(s);if(!o||!o.getBoundingClientRect)return;let l=o.getBoundingClientRect();if(l.height!==0){if(r===null){r=l.top;return}l.bottom-r>_w&&(e.push(s),r=l.top)}}),e}function Mp({getMode:n,pageLabel:e}){return new ye({key:zi,state:{init:()=>({positions:[],deco:be.empty}),apply(t,r,i,s){let o=t.getMeta(zi);if(!o)return{positions:r.positions,deco:r.deco.map(t.mapping,t.doc)};let l=o.positions.map((a,c)=>st.widget(a,()=>Bw(c+2,e),{side:-1,ignoreSelection:!0}));return{positions:o.positions,deco:be.create(s.doc,l)}}},props:{decorations(t){return n()!==On?be.empty:zi.getState(t).deco}},view(t){let r=0,i="",s=()=>{if(r=0,n()!==On){i!==""&&(i="",t.dispatch(t.state.tr.setMeta(zi,{positions:[]})));return}let a=vw(t),c=a.join(",");c!==i&&(i=c,t.dispatch(t.state.tr.setMeta(zi,{positions:a})))},o=()=>{r||(r=requestAnimationFrame(s))},l=typeof ResizeObserver=="function"?new ResizeObserver(o):null;return l&&l.observe(t.dom),o(),{update:o,destroy(){r&&cancelAnimationFrame(r),l&&l.disconnect()}}}})}function Bw(n,e){let t=document.createElement("div");t.setAttribute("docs-page-gap",""),t.setAttribute("contenteditable","false"),t.setAttribute("aria-hidden","true");let r=document.createElement("span");return r.setAttribute("docs-page-number",""),r.textContent=e?e.replace("{n}",String(n)):String(n),t.appendChild(r),t}var Tp=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null;function Ap(n){if(!n)return 0;if(Tp){let t=0;for(let r of Tp.segment(n))r.isWordLike&&t++;return t}let e=n.trim().split(/\s+/);return e.length===1&&e[0]===""?0:e.length}function Dp(n){let e=[];return n.descendants(t=>{t.isText?e.push(t.text):t.isBlock&&e.length&&e.push(" ")}),e.join("")}function Lw(n){let e=Dp(n.doc),{from:t,to:r,empty:i}=n.selection,s=0;n.doc.forEach(l=>{(l.isTextblock||l.type.name.endsWith("_list")||l.type.name==="blockquote")&&s++});let o=i?null:Dp(n.doc.cut(t,r));return{words:Ap(e),characters:e.length,charactersNoSpaces:e.replace(/\s/g,"").length,paragraphs:s,selection:o===null?null:{words:Ap(o),characters:o.length}}}function Op(n,{getView:e}){if(!n||typeof n.showModal!="function")return null;let t={words:n.querySelector("[docs-count-words]"),characters:n.querySelector("[docs-count-characters]"),charactersNoSpaces:n.querySelector("[docs-count-characters-nospaces]"),paragraphs:n.querySelector("[docs-count-paragraphs]"),selection:n.querySelector("[docs-count-selection]"),selectionWords:n.querySelector("[docs-count-selection-words]")};return()=>{let r=e();if(!r)return!1;let i=Lw(r.state);return t.words&&(t.words.textContent=String(i.words)),t.characters&&(t.characters.textContent=String(i.characters)),t.charactersNoSpaces&&(t.charactersNoSpaces.textContent=String(i.charactersNoSpaces)),t.paragraphs&&(t.paragraphs.textContent=String(i.paragraphs)),t.selection&&(t.selection.hidden=i.selection===null),t.selectionWords&&i.selection&&(t.selectionWords.textContent=String(i.selection.words)),n.showModal(),!0}}function Uw(n){let e=[];if(!n)return e;for(let t of n.querySelectorAll("[estilo-menubar-menu]")){let r=t.querySelector("[estilo-menubar-title]"),i=r?r.textContent.trim():"";for(let s of t.querySelectorAll("[estilo-menu-item]")){let o=s.getAttribute("data-docs-shortcut");if(!o)continue;let l=s.querySelector("[estilo-menu-label]"),a=(l?l.textContent:s.textContent).trim().replace(/…$/,"");e.push({group:i,label:a,keys:o})}}return e}function Np(n,{menubar:e,extraRows:t}){if(!n||typeof n.showModal!="function")return null;let r=n.querySelector("[docs-shortcuts-body]");return r?()=>{let i=[...Uw(e),...t||[]];r.textContent="";let s=null;for(let o of i){if(o.group&&o.group!==s){s=o.group;let f=document.createElement("h3");f.setAttribute("docs-shortcuts-group",""),f.textContent=s,r.appendChild(f)}let l=document.createElement("div");l.setAttribute("docs-shortcuts-row","");let a=document.createElement("span");a.textContent=o.label;let c=document.createElement("kbd");c.textContent=o.keys,l.append(a,c),r.appendChild(l)}return n.showModal(),!0}:null}function _p(n){return 3e4+Math.ceil(n.byteLength/8)}function Rp(n){return _p(n)+5e3}var Vw=1024;async function Fw(n){if(typeof CompressionStream!="function")return null;let e=new CompressionStream("gzip"),t=e.writable.getWriter();t.write(n).catch(()=>{}),t.close().catch(()=>{});let r=e.readable.getReader(),i=[],s=0;for(;;){let{done:a,value:c}=await r.read();if(a)break;i.push(c),s+=c.byteLength}let o=new Uint8Array(s),l=0;for(let a of i)o.set(a,l),l+=a.byteLength;return o}async function Ip(n,{timeoutMs:e,compress:t=!0}={}){let r={"Content-Type":"application/octet-stream"},i=n;if(t&&n.byteLength>=Vw){let o=await Fw(n).catch(()=>null);o&&o.byteLength<n.byteLength&&(i=o,r["Content-Encoding"]="gzip")}let s={method:"POST",credentials:"same-origin",headers:r,body:i,keepalive:i.byteLength<=32768};return typeof AbortSignal<"u"&&typeof AbortSignal.timeout=="function"&&(s.signal=AbortSignal.timeout(e??_p(i))),s}var Pw=new Set([400,415,422]);function vp({url:n,fetchFn:e=(...t)=>fetch(...t)}){let t=!1;return async function(i,s=()=>{}){let o=await Ip(i,{compress:!t});s(o.keepalive);let l=await e(n,o);return o.headers["Content-Encoding"]==="gzip"&&Pw.has(l.status)&&(t=!0,o=await Ip(i,{compress:!1}),s(o.keepalive),l=await e(n,o)),l}}async function Bp(n,e=fetch){for(let t of[!0,!1])try{let r={method:"HEAD",cache:"no-store",credentials:"same-origin",keepalive:t};return typeof AbortSignal<"u"&&typeof AbortSignal.timeout=="function"&&(r.signal=AbortSignal.timeout(5e3)),await e(n,r),!0}catch{}return!1}function Lp({post:n,mergeUpdates:e,onStatus:t,debounceMs:r=2e3,maxBatchBytes:i=1/0,answerTimeoutMs:s=1/0,probe:o=null,setTimeoutFn:l=setTimeout,clearTimeoutFn:a=clearTimeout}){let c=[],f=null,u=null,h="ok",d=0,p=0,m=[],g=[],y=0;function b(A){h==="failed"&&A!=="failed"||(h=A,t&&t(h))}function k(){let A=[];for(let L of g){if(p<L.to){A.push(L);continue}L.resolve(!m.some(([W,Le])=>Le>L.from&&W<=L.to))}g=A}function I(A){u||(u=l(()=>{u=null,z()},A))}function z(){if(f||!c.length)return;u&&(a(u),u=null);let A=1,L=c[0].update.byteLength;for(;A<c.length&&L+c[A].update.byteLength<=i;)L+=c[A].update.byteLength,A++;let W=c.slice(0,A);c=c.slice(A);let Le=W.length===1?W[0].update:e(W.map(At=>At.update)),Ye={lo:W[0].id,hi:W[W.length-1].id,bytes:Le,entries:W};f=Ye;let Ar=typeof s=="function"?s(Le):s;Number.isFinite(Ar)&&(Ye.timer=l(()=>ue(Ye,"retrying"),Ar));let zo=At=>{Ye.keepalive=!!At};Promise.resolve().then(()=>n(Le,zo)).then(At=>E(Ye,At),()=>E(Ye,null))}function ue(A,L){f===A&&(f=null,A.timer&&a(A.timer),c=A.entries.concat(c),L?(b(L),I(r)):z())}function E(A,L){if(f===A){if(A.timer&&a(A.timer),f=null,L&&(y=0),L&&L.ok)p=A.hi,b(c.length?"saving":"ok");else if(L&&L.status>=400&&L.status<500)p=A.hi,m.push([A.lo,A.hi]),b("failed");else{if(c=A.entries.concat(c),k(),L||!o){y=0,b("retrying"),I(r);return}Promise.resolve().then(()=>o()).then(W=>W,()=>!1).then(W=>{if(!W){y=0,p<A.hi&&b("retrying"),I(r);return}y++,I(Math.min(r*2**y,4e3))});return}k(),c.length&&z()}}function _(A){c.push({id:++d,update:A}),f||I(r)}function K(){let A=d,L=p,W=p>=A?Promise.resolve(!m.some(([Le,Ye])=>Ye>L&&Le<=A)):new Promise(Le=>g.push({from:L,to:A,resolve:Le}));return z(),W}function In({wire:A="all"}={}){let L=[];f&&(A==="all"||A==="plain"&&!f.keepalive)&&L.push(f.bytes);for(let W of c)L.push(W.update);return L.length?L.length===1?L[0]:e(L):null}function ft(){f?ue(f,null):z()}return{enqueue:_,flush:K,pendingBytes:In,resume:ft,get onWire(){return f?f.keepalive?"keepalive":"plain":null},get status(){return h}}}function Up({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,a=!1,c=0,f=null;function u(){c++,f&&s(f),f=i(h,r(c))}async function h(){if(f&&(s(f),f=null),!(!l||a)){a=!0;try{await n(),l=!1,c=0,t&&t()}catch{u()}finally{a=!1}}}function d(){l||(l=!0,c=0,e&&e()),h()}return o(()=>{l&&h()}),{reportDivergence:d,get diverged(){return l},get resyncing(){return a}}}function Vp(n){return{...n,parseDOM:[{tag:"br.Apple-interchange-newline",ignore:!0},...n.parseDOM||[]]}}function Fp(n){let e=n.nodes.paragraph,t=n.nodes.hard_break;return r=>{let i=Pp(r.content,e,t);return i===r.content?r:new S(i,r.openStart,r.openEnd)}}function Pp(n,e,t){let r=[],i=!1;return n.forEach(s=>{if(s.type===e&&s.childCount>0&&zw(s,t)){for(let l=0;l<s.childCount;l+=1)r.push(e.create(s.attrs));i=!0;return}if(s.isTextblock||s.isLeaf){r.push(s);return}let o=Pp(s.content,e,t);if(o===s.content){r.push(s);return}r.push(s.copy(o)),i=!0}),i?x.fromArray(r):n}function zw(n,e){let t=!0;return n.forEach(r=>{r.type!==e&&(t=!1)}),t}function Er(n,e,t){n.getAttribute(e)!==t&&n.setAttribute(e,t)}function ve(n,e,t){n[e]!==t&&(n[e]=t)}function zp(n,e){if(!n||e.length===0)return{ensureReachable(){},focusStop(){return!1}};let t=l=>typeof l.checkVisibility=="function"?l.checkVisibility():typeof l.getClientRects=="function"?l.getClientRects().length>0:!0,r=()=>e.filter(l=>!l.disabled&&t(l));function i(l){for(let a of e)a.tabIndex=a===l?0:-1}function s(){let l=r();l.length!==0&&(l.some(a=>a.tabIndex===0)||i(l[0]))}n.addEventListener("keydown",l=>{let a=l.key;if(a!=="ArrowRight"&&a!=="ArrowLeft"&&a!=="Home"&&a!=="End")return;let c=r(),f=c.indexOf(document.activeElement);if(f<0||c.length===0)return;let u;a==="Home"?u=c[0]:a==="End"?u=c[c.length-1]:a==="ArrowRight"?u=c[(f+1)%c.length]:u=c[(f-1+c.length)%c.length],l.preventDefault(),i(u),u.focus()}),n.addEventListener("focusin",l=>{e.includes(l.target)&&i(l.target)}),s(),typeof ResizeObserver=="function"&&new ResizeObserver(()=>s()).observe(n);function o(){let l=r();if(l.length===0)return!1;let a=l.find(c=>c.tabIndex===0)||l[0];return i(a),a.focus(),!0}return{ensureReachable:s,focusStop:o}}var bc={center:"docs-align-center",right:"docs-align-right"},$p=["left","center","right"];function vo(n){return Object.prototype.hasOwnProperty.call(bc,n)?bc[n]:null}function $w(n){for(let[e,t]of Object.entries(bc))if(n.includes(t))return e;return null}function qp(n){return{...n,attrs:{...n.attrs||{},align:{default:null}},parseDOM:[{tag:"p",getAttrs:e=>({align:$w(Array.from(e.classList||[]))})}],toDOM:e=>{let t=vo(e.attrs.align);return t?["p",{class:t},0]:["p",0]}}}function Wp(n){return(e,t)=>{let{from:r,to:i}=e.selection,s=!1,o=e.tr;return e.doc.nodesBetween(r,i,(l,a)=>{l.type.isTextblock&&(!l.type.spec.attrs||!l.type.spec.attrs.align||(s=!0,t&&o.setNodeMarkup(a,null,{...l.attrs,align:n})))}),s?(t&&t(o),!0):!1}}function Jp(n){let e=n.selection.$from.parent,t=e.attrs&&e.attrs.align;return vo(t)?t:"left"}var Bo={comment:"The font vocabulary. internal/fonts embeds it, fixtures/fonts.mjs imports it into the editor bundle, core/src/fragment.rs is tested against it, and scripts/vendor-fonts.py builds files/ from it with sources.json. Order is the picker's order. Keys are mark names after font_ and never change: sans, serif and mono are Liberation, as they always were.",default:"carlito",code:"mono",families:[{key:"carlito",name:"Carlito",category:"sans",twin:"Calibri",reserved:"Carlito",docx:{name:"Calibri",family:"swiss",pitch:"variable",panose:"020F0502020204030204"},fallback:["Calibri","Carlito","Segoe UI","Arial","sans-serif"],dir:"carlito",licence:"OFL.txt",styles:{regular:"Carlito-Regular",bold:"Carlito-Bold",italic:"Carlito-Italic",boldItalic:"Carlito-BoldItalic"}},{key:"caladea",name:"Caladea",category:"serif",twin:"Cambria",docx:{name:"Cambria",family:"roman",pitch:"variable",panose:"02040503050406030204"},fallback:["Cambria","Caladea","Georgia","Times New Roman","serif"],dir:"caladea",licence:"OFL.txt",styles:{regular:"Caladea-Regular",bold:"Caladea-Bold",italic:"Caladea-Italic",boldItalic:"Caladea-BoldItalic"}},{key:"inter",name:"Inter",category:"sans",docx:{name:"Inter",family:"swiss",pitch:"variable",altName:"Arial"},fallback:["Helvetica Neue","Arial","sans-serif"],dir:"inter",licence:"LICENSE.txt",styles:{regular:"Inter-Regular",bold:"Inter-Bold",italic:"Inter-Italic",boldItalic:"Inter-BoldItalic"}},{key:"sourcesans",name:"Source Sans 3",category:"sans",reserved:"Source",docx:{name:"Source Sans 3",family:"swiss",pitch:"variable",altName:"Calibri"},fallback:["Segoe UI","Arial","sans-serif"],dir:"sourcesans",licence:"LICENSE.md",styles:{regular:"SourceSans3-Regular",bold:"SourceSans3-Bold",italic:"SourceSans3-It",boldItalic:"SourceSans3-BoldIt"}},{key:"plexsans",name:"IBM Plex Sans",category:"sans",reserved:"Plex",docx:{name:"IBM Plex Sans",family:"swiss",pitch:"variable",altName:"Arial"},fallback:["Helvetica Neue","Arial","sans-serif"],dir:"plexsans",licence:"LICENSE.txt",styles:{regular:"IBMPlexSans-Regular",bold:"IBMPlexSans-Bold",italic:"IBMPlexSans-Italic",boldItalic:"IBMPlexSans-BoldItalic"}},{key:"sourceserif",name:"Source Serif 4",category:"serif",reserved:"Source",docx:{name:"Source Serif 4",family:"roman",pitch:"variable",altName:"Georgia"},fallback:["Georgia","Times New Roman","serif"],dir:"sourceserif",licence:"LICENSE.md",styles:{regular:"SourceSerif4-Regular",bold:"SourceSerif4-Bold",italic:"SourceSerif4-It",boldItalic:"SourceSerif4-BoldIt"}},{key:"literata",name:"Literata",category:"serif",docx:{name:"Literata",family:"roman",pitch:"variable",altName:"Georgia"},fallback:["Georgia","Times New Roman","serif"],dir:"literata",licence:"OFL.txt",styles:{regular:"Literata-Regular",bold:"Literata-Bold",italic:"Literata-Italic",boldItalic:"Literata-BoldItalic"}},{key:"garamond",name:"EB Garamond",category:"serif",docx:{name:"EB Garamond",family:"roman",pitch:"variable",altName:"Garamond"},fallback:["Garamond","Georgia","serif"],dir:"garamond",licence:"OFL.txt",styles:{regular:"EBGaramond-Regular",bold:"EBGaramond-Bold",italic:"EBGaramond-Italic",boldItalic:"EBGaramond-BoldItalic"}},{key:"sans",name:"Liberation Sans",category:"sans",twin:"Arial",reserved:"Liberation",docx:{name:"Arial",family:"swiss",pitch:"variable",panose:"020B0604020202020204"},fallback:["Arial","Helvetica","Liberation Sans","sans-serif"],dir:"liberation",licence:"LICENSE-OFL-1.1.txt",styles:{regular:"LiberationSans-Regular",bold:"LiberationSans-Bold",italic:"LiberationSans-Italic",boldItalic:"LiberationSans-BoldItalic"}},{key:"serif",name:"Liberation Serif",category:"serif",twin:"Times New Roman",reserved:"Liberation",docx:{name:"Times New Roman",family:"roman",pitch:"variable",panose:"02020603050405020304"},fallback:["Times New Roman","Times","Liberation Serif","serif"],dir:"liberation",licence:"LICENSE-OFL-1.1.txt",styles:{regular:"LiberationSerif-Regular",bold:"LiberationSerif-Bold",italic:"LiberationSerif-Italic",boldItalic:"LiberationSerif-BoldItalic"}},{key:"mono",name:"Liberation Mono",category:"mono",twin:"Courier New",reserved:"Liberation",docx:{name:"Courier New",family:"modern",pitch:"fixed",panose:"02070309020205020404"},fallback:["Courier New","Liberation Mono","Consolas","monospace"],dir:"liberation",licence:"LICENSE-OFL-1.1.txt",styles:{regular:"LiberationMono-Regular",bold:"LiberationMono-Bold",italic:"LiberationMono-Italic",boldItalic:"LiberationMono-BoldItalic"}},{key:"notosans",name:"Noto Sans",category:"sans",docx:{name:"Noto Sans",family:"swiss",pitch:"variable",altName:"Arial"},fallback:["Noto Sans","Arial","sans-serif"],dir:"notosans",licence:"OFL.txt",styles:{regular:"NotoSans-Regular",bold:"NotoSans-Bold",italic:"NotoSans-Italic",boldItalic:"NotoSans-BoldItalic"}},{key:"zilla",name:"Zilla Slab",category:"slab",docx:{name:"Zilla Slab",family:"roman",pitch:"variable",altName:"Rockwell"},fallback:["Rockwell","Georgia","serif"],dir:"zilla",licence:"OFL.txt",styles:{regular:"ZillaSlab-Regular",bold:"ZillaSlab-Bold",italic:"ZillaSlab-Italic",boldItalic:"ZillaSlab-BoldItalic"}},{key:"jetbrains",name:"JetBrains Mono",category:"mono",docx:{name:"JetBrains Mono",family:"modern",pitch:"fixed",altName:"Consolas"},fallback:["Consolas","Menlo","Courier New","monospace"],dir:"jetbrains",licence:"OFL.txt",styles:{regular:"JetBrainsMono-Regular",bold:"JetBrainsMono-Bold",italic:"JetBrainsMono-Italic",boldItalic:"JetBrainsMono-BoldItalic"}},{key:"playfair",name:"Playfair Display",category:"display",reserved:"Playfair Display",docx:{name:"Playfair Display",family:"roman",pitch:"variable",altName:"Georgia"},fallback:["Didot","Bodoni MT","Georgia","serif"],dir:"playfair",licence:"OFL.txt",styles:{regular:"PlayfairDisplay-Regular",bold:"PlayfairDisplay-Bold",italic:"PlayfairDisplay-Italic",boldItalic:"PlayfairDisplay-BoldItalic"}},{key:"caveat",name:"Caveat",category:"handwriting",docx:{name:"Caveat",family:"script",pitch:"variable",altName:"Segoe Print"},fallback:["Segoe Print","Bradley Hand","cursive"],dir:"caveat",licence:"OFL.txt",styles:{regular:"Caveat-Regular",bold:"Caveat-Bold"}}]};var Ww={regular:{weight:400,style:"normal"},bold:{weight:700,style:"normal"},italic:{weight:400,style:"italic"},boldItalic:{weight:700,style:"italic"}},ct=Bo.families.map((n,e)=>({key:n.key,name:n.name,index:e+1,cssName:"Docs "+n.name,docx:n.docx.name,fallback:n.fallback,faces:Object.keys(n.styles).map(t=>Ww[t])})),wc=new Map(ct.map(n=>[n.key,n])),Sc=ct.map(n=>n.key),Be=Bo.default,Nn=Bo.code,Lo=Sc.map(n=>"font_"+n).reverse();function jp(n){if(wc.has(n))return n===Be?null:"font_"+n}function Yp(n){for(let e of Lo)if(n.includes(e))return e.slice(5);return Be}function Uo(n){let e=String(n||"").split(",").map(t=>t.trim().replace(/^["']|["']$/g,"").toLowerCase()).filter(Boolean);for(let t of e){let r=ct.find(i=>i.cssName.toLowerCase()===t)||ct.find(i=>i.docx.toLowerCase()===t)||ct.find(i=>i.name.toLowerCase()===t)||ct.find(i=>i.fallback.some(s=>s.toLowerCase()===t));if(r)return r.key}return null}function Jw(){if(!wc.has(Be))throw new Error(`fonts: the default ${Be} is not a family`);if(!wc.has(Nn))throw new Error(`fonts: the code face ${Nn} is not a family`);if(Sc[0]!==Be)throw new Error(`fonts: the toolbar lists ${Sc[0]} first but the default is ${Be}`);for(let n of ct)if(!n.faces.some(e=>e.weight===400&&e.style==="normal"))throw new Error(`fonts: ${n.key} has no regular`)}Jw();var Tt=[12,8,9,10,11,14,18,24,36,48,72],Yt=12,Kt=[...Tt.filter(n=>n!==Yt).map(n=>"size_"+n),"size_sm","size_lg","size_xl"],Vo={size_sm:10,size_lg:14,size_xl:18};function Kp(n){let e=Number(n);if(Tt.includes(e))return e===Yt?null:"size_"+e}function Hp(n){for(let e of Kt)if(n.includes(e))return e in Vo?Vo[e]:Number(e.slice(5));return Yt}function jw(){if(!Tt.includes(Yt))throw new Error(`sizes: the default ${Yt} is not one of [${Tt}]`);if(Tt[0]!==Yt)throw new Error(`sizes: the control lists ${Tt[0]} first but the default is ${Yt} \u2014 with no JavaScript the control would name a size the text is not set in`);for(let[t,r]of Object.entries(Vo)){if(!Tt.includes(r))throw new Error(`sizes: the legacy mark ${t} maps to ${r}pt, which is not on the ladder [${Tt}]`);if(!Kt.includes(t))throw new Error(`sizes: the legacy mark ${t} is not in the group the toolbar clears`)}let n=Tt.filter(t=>t!==Yt).map(t=>"size_"+t),e=Kt.filter(t=>!(t in Vo));if(n.join()!==e.join())throw new Error(`sizes: the marks [${e}] do not match the offered sizes [${n}]`)}jw();var Cc={align_left:null,align_center:"center",align_right:"right"};function Yw(){let n=Object.keys(Cc);for(let r of n){let i=Cc[r],s="align_"+(i===null?"left":i);if(r!==s)throw new Error(`toolbar: ${r} sets the alignment ${JSON.stringify(i)}, which belongs to ${s}`);if(i!==null&&!vo(i))throw new Error(`toolbar: ${r} sets ${JSON.stringify(i)}, which align.mjs does not know`)}let e=n.map(r=>r.slice(6)).sort(),t=[...$p].sort();if(e.join()!==t.join())throw new Error(`toolbar: alignment commands [${e}] do not match align.mjs's [${t}]`)}Yw();function kc(n){let e=n.previousElementSibling;return!e||!e.hasAttribute("rst-combo")?null:e.querySelector("input")}function Kw(n,e){if(!e)return;let t=n.getAttribute("aria-label");t&&Er(e,"aria-label",t)}var Fo=!1;function Hw(n,e,t){if(!e||document.activeElement===e)return;if(t&&typeof n.dispatchEvent=="function"){Fo=!0;try{n.dispatchEvent(new Event("change"))}finally{Fo=!1}return}let r=n.options[n.selectedIndex],i=r&&r.dataset||{},s=r?i.rstShort||i.rstName||r.text:"";ve(e,"value",s)}function tm({root:n,schema:e,getView:t,onSync:r,fonts:i=null,wrapCommand:s=l=>l,onFontUnavailable:o=null}){if(!n)return{plugin:null,commands:Gp(e,s),focusStop:()=>!1};let l=Array.from(n.querySelectorAll("[data-docs-command]")),a=Array.from(n.querySelectorAll("[data-docs-select]")),c=n.ownerDocument,f=c&&c.querySelector&&c.querySelector("[estilo-bar]");f&&Er(f,"data-rst-select-ceiling","");let u=Gp(e,s);n.addEventListener("pointerdown",g=>{let y=g.target;if(!y||!y.hasAttribute||!y.hasAttribute("rst-combo"))return;let b=y.querySelector("input");!b||b.disabled||(g.preventDefault(),c.activeElement===b?b.blur():b.focus())});for(let g of l)g.addEventListener("mousedown",y=>y.preventDefault()),g.addEventListener("click",()=>{let y=u[g.getAttribute("data-docs-command")],b=t();!b||!y||(y(b.state,b.dispatch,b),b.focus())});for(let g of a)g.addEventListener("mousedown",y=>y.stopPropagation()),g.addEventListener("change",()=>{if(Fo)return;let y=t();y&&y.focus()}),g.addEventListener("change",()=>{if(Fo)return;let y=t();if(!y)return;let b=g.getAttribute("data-docs-select"),k=g.value;if(b==="block"&&qi(e,k)(y.state,y.dispatch,y),b==="font"){let I=jp(k);I!==void 0&&Xp(e,Lo,I)(y.state,y.dispatch)}if(b==="size"){let I=Kp(k);I!==void 0&&Xp(e,Kt,I)(y.state,y.dispatch)}y.focus()});function h(g){let y=g.state;for(let b of l){let k=b.getAttribute("data-docs-command"),I=u[k];if(!I)continue;let z=I(y,null,g);ve(b,"disabled",!z);let ue=Qp(y,e,k);Er(b,"aria-pressed",ue?"true":"false")}for(let b of a){let k=b.getAttribute("data-docs-select")==="font"&&i&&i.previews==="pending";ve(b,"disabled",k);let I=kc(b);I&&ve(I,"disabled",k),Kw(b,I);let z=b.getAttribute("data-docs-select"),ue=b.value;z==="block"&&ve(b,"value",em(y)),z==="font"&&ve(b,"value",Zw(y,e)),z==="size"&&ve(b,"value",String(Hp(Qw(y,e,Kt)))),Hw(b,kc(b),b.value!==ue)}r&&r(g)}let d=zp(n,[...l,...a.map(g=>kc(g)||g)]),p=new ye({view:g=>{h(g),d.ensureReachable();let y=je.getState(g.state)?.undoManager,b=()=>{h(g),d.ensureReachable()};return y&&(y.on("stack-item-added",b),y.on("stack-item-popped",b)),{update:k=>{h(k),d.ensureReachable()},destroy:()=>{y&&(y.off("stack-item-added",b),y.off("stack-item-popped",b))}}}}),m=(g,y)=>y.startsWith("block_")?em(g)===y.slice(6):Qp(g,e,y);return{plugin:p,commands:u,focusStop:d.focusStop,isPressed:m}}function Gp(n,e=t=>t){let t=n.marks,r=n.nodes;return{undo:ep,redo:tp,strong:e(Dn(t.strong)),em:e(Dn(t.em)),code:e(Dn(t.code),!0),bullet_list:Zp(r.bullet_list,r.list_item),ordered_list:Zp(r.ordered_list,r.list_item),blockquote:Xw(r.blockquote),select_all:pc,clear_formatting:Gw,block_paragraph:qi(n,"paragraph"),"block_heading-1":qi(n,"heading-1"),"block_heading-2":qi(n,"heading-2"),"block_heading-3":qi(n,"heading-3"),indent:lt(No(r.list_item),Cr(1)),outdent:lt(Pi(r.list_item),Cr(-1)),...Object.fromEntries(Object.entries(Cc).map(([i,s])=>[i,Wp(s)]))}}function Gw(n,e){let{from:t,to:r,empty:i}=n.selection;if(i)return!1;if(e){let s=n.tr.removeMark(t,r,null);s.setBlockType(t,r,n.schema.nodes.paragraph),e(s.scrollIntoView())}return!0}function qi(n,e){if(e==="paragraph")return mc(n.nodes.paragraph);let t=Number(e.split("-")[1]);return Number.isInteger(t)?mc(n.nodes.heading,{level:t}):()=>!1}function Xp(n,e,t){return(r,i)=>{let s=e.map(u=>n.marks[u]).filter(Boolean),o=t?n.marks[t]:null;if(t&&!o)return!1;if(!i)return!0;let{from:l,to:a,empty:c}=r.selection;if(c){let u=(r.storedMarks||r.selection.$from.marks()).filter(h=>!s.includes(h.type));return o&&(u=o.create().addToSet(u)),i(r.tr.setStoredMarks(u)),!0}let f=r.tr;for(let u of s)f.removeMark(l,a,u);return o&&f.addMark(l,a,o.create()),i(f),!0}}function Zp(n,e){let t=lp(n),r=Pi(e);return(i,s,o)=>Wi(i,n)?r(i,s,o):t(i,s,o)}function Xw(n){let e=yp(n);return(t,r,i)=>Wi(t,n)?pp(t,r,i):e(t,r,i)}function Wi(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 Qp(n,e,t){if(t.startsWith("align_"))return Jp(n)===t.slice(6);if(t==="bullet_list")return Wi(n,e.nodes.bullet_list);if(t==="ordered_list")return Wi(n,e.nodes.ordered_list);if(t==="blockquote")return Wi(n,e.nodes.blockquote);let r=e.marks[t];return r?Ec(n,r):!1}function Ec(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 em(n){let e=n.selection.$from.parent;return e.type.name==="heading"?"heading-"+e.attrs.level:"paragraph"}function Zw(n,e){let t=Lo.filter(r=>{let i=e.marks[r];return i&&Ec(n,i)});return Yp(t)}function Qw(n,e,t){let r=[];for(let i of t){let s=e.marks[i];s&&Ec(n,s)&&r.push(i)}return r}var eS={print:()=>(window.print(),!0)};function Ac(n){return n.querySelector("[estilo-menubar-menu][open]")}function Dc(n){return Array.from(n.querySelectorAll("[estilo-menubar-title]"))}function Mc(n){return Array.from(n.querySelectorAll("[estilo-menu-item]")).filter(e=>!e.disabled)}function Tc(n,e){for(let t of Dc(n))ve(t,"tabIndex",t===e?0:-1);e.focus()}function Po(n){let e=Ac(n);e&&(e.open=!1)}function nm(n,{getView:e,commands:t,extraCommands:r,isPressed:i}){if(!n)return null;let s=Dc(n);if(!s.length)return null;for(let[c,f]of s.entries())ve(f,"tabIndex",c===0?0:-1);let o={...eS,...r||{}};function l(c,f){let u=o[c];if(u){if(f){let m=f.closest("[estilo-menubar-menu]");if(m){let g=m.querySelector("[estilo-menubar-title]");g&&Tc(n,g)}}return u()}let h=e();if(!h)return!1;let d=t[c];if(!d)return!1;let p=d(h.state,h.dispatch,h);return h.focus(),p}n.addEventListener("click",c=>{let f=c.target.closest("[estilo-menu-item]");if(!(!f||f.disabled)){if(!f.hasAttribute("data-docs-command")){Po(n);return}c.preventDefault(),l(f.getAttribute("data-docs-command"),f),Po(n)}}),n.addEventListener("keydown",c=>{let f=c.target.closest("[estilo-menubar-title]"),u=c.target.closest("[estilo-menu-item]"),h=Ac(n);switch(c.key){case"ArrowRight":case"ArrowLeft":{let d=f||h&&h.querySelector("[estilo-menubar-title]");if(!d)return;c.preventDefault();let p=Dc(n),m=p[(p.indexOf(d)+(c.key==="ArrowRight"?1:-1)+p.length)%p.length],g=!!h;Po(n),g&&(m.closest("[estilo-menubar-menu]").open=!0),Tc(n,m);return}case"ArrowDown":case"ArrowUp":{if(f){c.preventDefault();let d=f.closest("[estilo-menubar-menu]");d.open=!0;let p=Mc(d);p.length&&p[c.key==="ArrowDown"?0:p.length-1].focus();return}if(u&&h){c.preventDefault();let d=Mc(h),p=d.indexOf(u);if(p<0||!d.length)return;d[(p+(c.key==="ArrowDown"?1:-1)+d.length)%d.length].focus()}return}case"Home":case"End":{if(!u||!h)return;c.preventDefault();let d=Mc(h);d.length&&d[c.key==="Home"?0:d.length-1].focus();return}case"Tab":Po(n)}}),n.addEventListener("pointerover",c=>{if(c.pointerType&&c.pointerType!=="mouse")return;let f=c.target.closest&&c.target.closest("[estilo-menubar-title]"),u=Ac(n);if(!f||!u||u.contains(f))return;let h=f.closest("[estilo-menubar-menu]");h&&(h.open=!0,Tc(n,f))});function a(c){for(let f of n.querySelectorAll("[estilo-menu-item][data-docs-command]")){let u=f.getAttribute("data-docs-command"),h=!1;if(f.hasAttribute("aria-pressed")&&i&&(h=!!i(u,c),Er(f,"aria-pressed",h?"true":"false")),o[u]){ve(f,"disabled",!1);continue}let d=t[u],p=!!(c&&d&&(h||d(c.state,null,c)));ve(f,"disabled",!p)}}return{sync:a}}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 tS(n){let e=new Set,t=!1;return n&&typeof n.addEventListener=="function"&&(n.addEventListener("pagehide",()=>{t=!0;for(let r of[...e])r.leave()}),n.addEventListener("pageshow",r=>{let i=t&&r&&r.persisted;if(t=!1,i)for(let s of[...e])s.back()})),{get left(){return t},subscribe(r){return e.add(r),()=>e.delete(r)}}}var nS=tS(typeof window>"u"?null:window);function rm({initialSeq:n=0,openStream:e,fetchSince:t,onUpdates:r,onError:i=()=>{},setTimeoutFn:s=setTimeout,clearTimeoutFn:o=clearTimeout,idleMs:l=12e4,hiddenMs:a=3e4,page:c=nS}){let f=n,u=null,h=null,d=!1,p=!1,m=!1;function g(E){h!==null&&o(h),h=s(()=>{h=null,b()},E)}function y(){g(l)}function b(){h!==null&&(o(h),h=null),u&&(u.close(),u=null)}function k(){d||u||c.left||(u=e(E=>{y(),E>f&&I()},E=>{b(),i(E)}),y())}async function I(){if(p){m=!0;return}p=!0;try{let E=f,_=await t(E);if(d)return;try{_&&_.bytes&&_.bytes.length&&await r(_.bytes)}catch{if(_=await t(E,{raw:!0}),d)return;_&&_.bytes&&_.bytes.length&&await r(_.bytes)}_&&typeof _.seq=="number"&&_.seq>f&&(f=_.seq)}catch(E){i(E)}finally{p=!1,m&&!d&&(m=!1,I())}}let z=null,ue={leave:()=>b(),back:()=>{s(()=>{d||k()},0)}};return{start(){d=!1,z||(z=c.subscribe(ue)),k()},stop(){d=!0,z&&z(),z=null,b()},noteOwnSeq(E){typeof E!="number"||!Number.isFinite(E)||E===f+1&&(f=E)},noteActivity(){d||(u?y():k())},noteHidden(){d||!u||g(a)},get cursor(){return f},get streaming(){return u!==null}}}var sm=3e3;var im=new Map([["code",Nn]]);function om(n){im.clear();for(let[e,t]of n)im.set(e,t)}function lm(n){let e=()=>!0;return{web:!1,ready:e,loaded:e,committed:()=>!1,fallback:[],inUse:[],use(){},required:()=>[],markShown(){},shown:!0,previews:"system",previewsDone:Promise.resolve("system"),prepare:async()=>{},prepareRemote:async()=>{},waitFor:async()=>!0,load:async()=>!0,commitFallback:()=>!0,prefetch:async()=>{},fontsReady:Promise.resolve(),settled(){!n||n.getAttribute("data-docs-fonts")!=="pending"||(clearTimeout(globalThis.__docsFontsHold),n.setAttribute("data-docs-fonts","shown"),n.getAttribute("data-docs-previews")==="pending"&&n.setAttribute("data-docs-previews","system"))}}}function am(n,{setTimer:e=setTimeout,clearTimer:t=clearTimeout}={}){if(!n)return{say(){},clear(){},state:""};let r=n.querySelector("[docs-fonts-status-text]"),i=n.querySelector("[docs-fonts-status-dismiss]"),s=null,o=()=>n.getAttribute("data-state")||"";function l(a){a&&o()!==a||(t(s),n.removeAttribute("data-state"),r&&(r.textContent=""))}return i&&i.addEventListener("click",()=>l()),{say(a,c=0){t(s),n.setAttribute("data-state",a),r&&(r.textContent=n.getAttribute("data-"+a)||""),c&&(s=e(()=>l(a),c))},clear:l,get state(){return o()}}}var rS=["p",0],iS=["blockquote",0],sS=["hr"],oS=["pre",["code",0]],lS=["br"],aS={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return rS}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM(){return iS}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return sS}},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 oS}},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 lS}}},cS=["em",0],fS=["strong",0],uS=["code",0],hS={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 cS}},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 fS}},code:{code:!0,parseDOM:[{tag:"code"}],toDOM(){return uS}}},Mr=new ar({nodes:aS,marks:hS});function cm(n,e){return{group:e,excludes:e,parseDOM:[{tag:"span."+n}],toDOM:()=>["span",{class:n},0]}}var dS=Kt.reduce((n,e)=>n.addToStart(e,cm("docs-"+e.replace("_","-"),"fontSize")),Mr.spec.marks),pS=[...ct].reverse().reduce((n,e)=>{let t=cm("docs-font-"+e.key,"fontFamily");return e.key!==Be?t.parseDOM=[...t.parseDOM,{style:"font-family",getAttrs:r=>Uo(r)===e.key?null:!1}]:t.parseDOM=[...t.parseDOM,{style:"font-family",getAttrs:r=>Uo(r)===Be||Uo(r)===null?null:!1,clearMark:r=>r.type.spec.group==="fontFamily"}],n.addToStart("font_"+e.key,t)},dS),mS=op(Mr.spec.nodes.update("paragraph",xc(qp(Mr.spec.nodes.get("paragraph")),"p")).update("heading",xc(Mr.spec.nodes.get("heading"),"h1")).update("hard_break",Vp(Mr.spec.nodes.get("hard_break"))),"paragraph block*","block"),fe=new ar({nodes:mS,marks:pS});function Tr(n){let e=n.name||n;if(typeof e=="string"&&e.startsWith("font_"))return e.slice(5);let t=typeof n=="string"?fe.marks[n]:n;return t&&t.spec.code?Nn:null}function Ji(n){let e=typeof n=="string"?fe.nodes[n]:n;return e&&e.spec.code?Nn:null}function fm(n,e=new Set([Be])){return n.descendants(t=>{let r=Ji(t.type);r&&e.add(r);for(let i of t.marks){let s=Tr(i.type);s&&e.add(s)}}),e}om([...Object.values(fe.nodes).filter(n=>Ji(n)).map(n=>[n.name,Ji(n)]),...Object.values(fe.marks).filter(n=>!n.name.startsWith("font_")&&Tr(n)).map(n=>[n.name,Tr(n)])]);function yS(n,e){return e&&e(n.tr.replaceSelectionWith(fe.nodes.hard_break.create()).scrollIntoView()),!0}var xS=250,ji="carried",um=500;function Nc(n,e){if(!e.length)return;let t=et(e);for(;rs(t);)fu(t,n,"server")}function dm(){return globalThis.docsFonts||lm(document.documentElement)}function bS(){return document.documentElement.getAttribute("data-docs-layout")==="frozen"}function wS(n){let e=new Set([Be]),t=r=>{if(r instanceof pe){for(let i of r.toDelta())for(let s of Object.keys(i.attributes||{})){let o=Tr(s);o&&e.add(o)}return}if(r instanceof ee){let i=Ji(r.nodeName);i&&e.add(i)}for(let i of r.toArray())t(i)};return t(n),[...e]}function SS(n){let e=new Set,t=r=>{let i=Tr(r.type);i&&e.add(i)};for(let r of n.steps)r.slice&&fm(r.slice.content,e),r.mark&&t(r.mark);return n.storedMarksSet&&n.storedMarks&&n.storedMarks.forEach(t),e.delete(void 0),[...e]}function hm(){return new Promise(n=>requestAnimationFrame(()=>n()))}async function kS(n){let e=n.getAttribute("data-sqid"),t=dm(),r=`/d/${e}/updates`,i=`/d/${e}/stream`,s=document.querySelector("[estilo-save-status]"),o=new URL(n.getAttribute("data-save-status-module"),location.href);if(!s||o.origin!==location.origin)throw new Error("Invalid save-status module");let{mount:l}=await import(o.href),a=l(s),c=!1,f=null,u=null,h=null,d=sp(),p=null,m=null;function g(w,C,M){if(p||!Dr.diverged||!C.some(D=>D.docChanged))return M();let R=C.map(D=>D.getMeta(q)).filter(Boolean);if(R.length){if(R.some(D=>D.isUndoRedoOperation)){let D=ip(w.before,C[C.length-1].doc);D&&(m={tr:{before:w.before,steps:[D]},schema:fe,locate:P=>P.getXmlFragment("prosemirror")})}return M()}p={tr:{before:w.before,steps:C.flatMap(D=>D.steps)},schema:fe,locate:D=>D.getXmlFragment("prosemirror")};try{M()}finally{p=null}}let y=null,b=null,k=document.querySelector("[docs-canvas]"),I=k&&k.getAttribute("data-view")===On?On:$i,z=k?k.getAttribute("data-page-label"):"",ue=!1;t.fontsReady.then(()=>{document.documentElement.getAttribute("data-docs-fonts")!=="pending"&&document.documentElement.setAttribute("data-docs-layout","frozen"),ue=!0});let E=()=>ue&&!bS()?I:$i;function _(w){I=w,document.documentElement.removeAttribute("data-docs-layout"),k&&k.setAttribute("data-view",w),Ep(w);let C=u;C&&C.dispatch(C.state.tr)}let K=Op(document.querySelector("[docs-wordcount]"),{getView:()=>u}),In=Np(document.querySelector("[docs-shortcuts]"),{menubar:document.querySelector("[estilo-menubar]"),extraRows:Array.from(document.querySelectorAll("[docs-shortcuts-extra] span")).map(w=>({group:w.closest("[docs-shortcuts-extra]").getAttribute("data-group")||"",label:w.getAttribute("data-label")||"",keys:w.getAttribute("data-keys")||""}))}),ft=!1,A=[],L=()=>ft?new Promise(w=>A.push(w)):Promise.resolve(),W=am(document.querySelector("[docs-fonts-status]")),Le=[document.querySelector("[docs-toolbar]"),document.querySelector("[estilo-menubar]")].filter(Boolean),Ye=document.querySelector("[docs-page]"),Ar=8e3,zo=new ye({filterTransaction(w){if(w.getMeta(q))return!0;if(ft)return!w.docChanged&&!w.storedMarksSet?!0:(W.say("refused"),!1);let C=SS(w),M=C.filter(D=>!t.ready(D));if(!M.length)return t.use(C),!0;if(u&&u.composing)return t.commitFallback(M),t.use(C),!0;let R=u;return At(M,()=>R!==u||R.state.doc!==w.before?!1:(R.dispatch(w),!0)),!1}});async function At(w,C){ft=!0,Rc(!0);let M=!1;try{M=await t.waitFor(w,sm)&&w.every(R=>t.loaded(R)||t.committed(R))}catch{M=!1}ft=!1,Rc(!1);try{M=M&&C()!==!1}catch(R){console.error("fonts:",R),M=!1}finally{M?W.clear():W.say("unavailable",Ar);let R=A;A=[];for(let D of R)D()}}let pm=new Set(["Backspace"," ","Spacebar","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"]),mm=w=>{if(!pm.has(w.key))return;let C=w.target;(!C||C===document.body||C===document.documentElement||C.closest&&C.closest("[inert]"))&&w.preventDefault()},gm=w=>{w.preventDefault(),w.returnValue=""},_c=!1;function Rc(w){let C=w?"addEventListener":"removeEventListener";window[C]("keydown",mm),window[C]("beforeunload",gm);let M=u,R=M&&M.dom;w&&(_c=!!R&&(R.contains(document.activeElement)||Le.some(D=>D.contains(document.activeElement))));for(let D of[...Le,R])D&&(D.inert=w);Ye&&Ye.setAttribute("aria-busy",w?"true":"false"),w?W.say("loading"):_c&&M&&(!document.activeElement||document.activeElement===document.body)&&M.focus()}let $o=w=>(C,M,R)=>{if(!M)return w(C,M,R);if(ft)return W.say("refused"),!0;let D=t.inUse.filter(P=>!t.ready(P));return D.length?(At(D,()=>{let P=u;return P?(w(P.state,P.dispatch,P),!0):!1}),!0):w(C,M,R)},ym=()=>W.say("unavailable",Ar),_n=tm({root:document.querySelector("[docs-toolbar]"),schema:fe,fonts:t,onFontUnavailable:ym,getView:()=>u,onSync:w=>{b&&b.sync(w)}});b=nm(document.querySelector("[estilo-menubar]"),{getView:()=>u,commands:_n.commands,isPressed:(w,C)=>w==="view_paged"?I===On:w==="view_infinite"?I===$i:!!(C&&_n.isPressed&&_n.isPressed(C.state,w)),extraCommands:{view_paged:()=>(_(On),!0),view_infinite:()=>(_($i),!0),...K?{word_count:K}:{},...In?{shortcuts:In}:{}}});function qo(w){a(c?"failed":w)}let xm=vp({url:r});function bm(w){return Lp({post:async(C,M)=>{let R=await xm(C,M),D=w();if(R.ok&&D){let P=Number(R.headers.get("Docs-Seq"));Number.isFinite(P)&&D.noteOwnSeq(P)}return R},mergeUpdates:Ys,debounceMs:xS,maxBatchBytes:32768,answerTimeoutMs:Rp,probe:()=>Bp("/healthz"),onStatus:C=>{C==="failed"&&(c=!0,Dr.reportDivergence()),qo(C==="saving"?"ok":C)}})}function wm(w){let C=u;if(!C||w.button!==0||C.dom.contains(w.target))return;let M=C.dom.getBoundingClientRect(),R=C.posAtCoords({left:Math.min(Math.max(w.clientX,M.left+1),M.right-1),top:Math.min(Math.max(w.clientY,M.top+1),M.bottom-1)}),D=R?R.pos:C.state.doc.content.size,P=B.near(C.state.doc.resolve(D));w.preventDefault(),C.dispatch(C.state.tr.setSelection(P).scrollIntoView()),C.focus()}function Sm(w,C,M){let R=[Qa(C),np({undoManager:M}),Cp(fe),Mp({getMode:E,pageLabel:z}),zo,uc({"Mod-z":$o(ic),"Mod-y":$o(Oo),"Mod-Shift-z":$o(Oo),"Mod-b":Dn(fe.marks.strong),"Mod-i":Dn(fe.marks.em),"Shift-Enter":yS,Tab:lt(No(fe.nodes.list_item),Cr(1)),"Shift-Tab":lt(Pi(fe.nodes.list_item),Cr(-1)),Backspace:Sp,Escape:()=>_n.focusStop(),Enter:lt(ap(fe.nodes.list_item),gc.Enter)}),uc(gc)];return _n.plugin&&R.push(_n.plugin),new Ii({mount:w},{state:pr.create({schema:fe,plugins:R}),dispatchTransaction(D){let{state:P,transactions:he}=this.state.applyTransaction(D);g(D,he,()=>this.updateState(P))},transformPasted:Fp(fe)})}async function vc(w){let C=Oc(r,{raw:w}),M=await fetch(C,{credentials:"same-origin"});if(!M.ok)throw new Error(`load ${C}: ${M.status}`);return{log:new Uint8Array(await M.arrayBuffer()),startSeq:Number(M.headers.get("Docs-Seq"))}}async function Bc(){for(;ft;)await L();let{log:w,startSeq:C}=await vc(!1),M=new Ie;try{Nc(M,w)}catch{({log:w,startSeq:C}=await vc(!0)),M=new Ie,Nc(M,w)}let R=M.getXmlFragment("prosemirror");await t.prepare(wS(R));let D=null,P=bm(()=>D),he=M;for(he.on("update",(J,ut)=>{if(ut!=="server"){if(Dr.diverged){if(he===h&&ut!==ji){let Dt=p||m||void 0;m=null,d.keep(he,J,Dt)}return}P.enqueue(J)}}),he.on("beforeTransaction",J=>{he!==h||!Dr.diverged||J.origin==="server"||J.origin===ji||(m=null,d.before(he,J.origin===q?"pm":"other"))});ft;)await L();let Vc=new Ut(R,{trackedOrigins:new Set([q,ji]),captureTimeout:um,deleteFilter:J=>oc(J,sc),captureTransaction:J=>J.meta.get("addToHistory")!==!1}),Fc=(J,ut)=>{(!ut||J.at-ut.at>=um)&&Vc.stopCapturing()},Pc=ac(he,d.take(),ji,Fc);u&&u.destroy(),f=P,h=he,u=Sm(n,R,Vc),y&&y.stop(),D=rm({initialSeq:Number.isFinite(C)?C:0,openStream:(J,ut)=>{let Dt=new EventSource(i,{withCredentials:!0});return Dt.addEventListener("update",Ot=>J(Number(Ot.data))),Dt.addEventListener("error",Ot=>ut(Ot)),{close:()=>Dt.close()}},fetchSince:async(J,{raw:ut}={})=>{let Dt=Oc(r,{since:J,raw:ut}),Ot=await fetch(Dt,{credentials:"same-origin"});if(!Ot.ok)throw new Error(`fetch ${Dt}: ${Ot.status}`);return{bytes:new Uint8Array(await Ot.arrayBuffer()),seq:Number(Ot.headers.get("Docs-Seq"))}},onUpdates:async J=>{await t.prepareRemote(J),await L(),!(Dr.diverged||y!==D)&&Nc(M,J)},onError:J=>{console.error("live updates:",J)}}),y=D,y.start(),typeof document<"u"&&document.hidden&&y.noteHidden();let zc=ac(he,d.take(),ji,Fc);for(let J of Pc.post.concat(zc.post))P.enqueue(J);Pc.lost+zc.lost&&console.warn("resync: a change made on top of a refused one could not be carried over")}let Dr=Up({attemptResync:Bc,onDiverged:()=>{h&&(h.clientID=lc(h)),qo("failed")},onRecovered:()=>qo(c?"failed":"ok")});addEventListener("pageshow",w=>{w.persisted&&f&&f.resume()}),await Bc(),await t.fontsReady,u&&u.dispatch(u.state.tr.setMeta("docs-fonts-ready",!0)),t.previewsDone.then(()=>u&&u.dispatch(u.state.tr.setMeta("docs-previews-ready",!0))),await hm(),await hm(),t.settled();let Or=u;Or&&Or.editable&&Or.state.doc.textContent===""&&Or.state.doc.childCount<=1&&(!document.activeElement||document.activeElement===document.body)&&Or.focus(),addEventListener("visibilitychange",()=>{document.hidden?y&&y.noteHidden():y&&y.noteActivity()});for(let w of["pointermove","scroll","keydown","focus"])addEventListener(w,()=>y&&y.noteActivity(),{passive:!0,capture:!0});let Lc=n.closest("[docs-page]");Lc&&Lc.addEventListener("mousedown",wm);let Wo=!1,Uc=()=>{Wo=!0,setTimeout(()=>{Wo=!1},0)};return document.addEventListener("mousedown",Uc,!0),document.addEventListener("touchstart",Uc,!0),n.addEventListener("focus",()=>{if(Wo)return;let w=u;w&&w.dispatch(w.state.tr.scrollIntoView())}),addEventListener("beforeunload",()=>{let w=[];for(let P of d.entries)w.push(...P.updates);let C=P=>{let he=P?[P,...w]:w;return he.length?he.length===1?he[0]:Ys(he):null},M=f,R=C(M&&M.pendingBytes({wire:"plain"}));if(!R)return;let D=[R];if(M&&M.onWire==="plain"){let P=C(M.pendingBytes({wire:"none"}));P&&D.push(P)}for(let P of D)if(navigator.sendBeacon(r,new Blob([P],{type:"application/octet-stream"})))return;console.error("beforeunload: sendBeacon refused the pending edit, retrying via keepalive fetch"),fetch(r,{method:"POST",credentials:"same-origin",keepalive:!0,headers:{"Content-Type":"application/octet-stream"},body:D[D.length-1]}).catch(()=>{})}),u}var Ic=document.querySelector("[docs-editor]");Ic&&kS(Ic).catch(n=>{dm().settled(),Ic.setAttribute("data-editor-failed","1"),console.error(n)});export{kS as mountEditor};