oficina / docs Public

docs: a document that is left lets go of its connections

The font gate's generative test failed on main 5a951ba in full Chrome
(Playwright's chromium-1234) on every fifth document. Not the gate: the
editor's live-update stream stayed open in pages Chrome kept in its
back/forward cache. Each held one of the six HTTP/1.1 connections to the
host, so the sixth navigation waited about a minute for one; by the time
that page ran, the gate's deadline (from navigation start) had passed and
it rightly committed every family still loading to its fallback. The
test then compared the gate's families with the DOM's, which drew the
committed ones in system faces.

Leaving a page now closes its stream at once (live-updates.mjs
noteLeaving, on pagehide) and stops its font prefetch; a page shown again
from the cache reopens and restarts them. The generative test compares
the DOM's families with the gate's less those it committed, so a family
that legitimately misses the deadline is not reported as over-coverage.

It passed on the branch because the headless shell (chromium_headless_
shell-1243) used there and in review has no back/forward cache: a page
left is destroyed and its connections with it.

Tests, failing first on 5a951ba: live-updates' "leaving the page closes
the stream at once, and coming back reopens it"; and
TestFontLeavingADocumentLetsGoOfItsConnections in full Chrome (six
streams held, the seventh document took 44 s to open).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 220e82eed9aae17fc6fef52945fe7dd9a2dc888c parent a0dd33a
8 files changed, +103 −8
  • fixtures/editor-entry.js +7 −0
  • fixtures/fonts-gate.mjs +16 −5
  • fixtures/live-updates.mjs +13 −0
  • fixtures/live-updates.test.mjs +13 −0
  • internal/docs/fonts_browser_test.go +52 −1
  • internal/docs/static/{editor.c2c7dc07e5705e7c.js => editor.a987940e8957731f.js} +1 −1
  • internal/docs/static/fontsgate.3a8c20da76487d78.js +0 −1
  • internal/docs/static/fontsgate.7161919aa93533b1.js +1 −0
diff --git a/fixtures/editor-entry.js b/fixtures/editor-entry.js
index f79f153..7a48e2d 100644
--- a/fixtures/editor-entry.js
+++ b/fixtures/editor-entry.js
@@ -1024,6 +1024,13 @@ export async function mountEditor(el) {
if (document.hidden) currentLive && currentLive.noteHidden()
else currentLive && currentLive.noteActivity()
})
+ // Leaving the page closes the stream at once (live-updates.mjs's
+ // noteLeaving); coming back to it from the back/forward cache is
+ // activity like any other.
+ addEventListener('pagehide', () => currentLive && currentLive.noteLeaving())
+ addEventListener('pageshow', (e) => {
+ if (e.persisted && currentLive) currentLive.noteActivity()
+ })
for (const name of ['pointermove', 'scroll', 'keydown', 'focus']) {
addEventListener(name, () => currentLive && currentLive.noteActivity(), { passive: true, capture: true })
}
diff --git a/fixtures/fonts-gate.mjs b/fixtures/fonts-gate.mjs
index 08efc10..461c26d 100644
--- a/fixtures/fonts-gate.mjs
+++ b/fixtures/fonts-gate.mjs
@@ -94,14 +94,25 @@ function prefetch() {
new Promise((resolve) =>
typeof requestIdleCallback === 'function' ? requestIdleCallback(() => resolve(), { timeout: 5000 }) : setTimeout(resolve, 200),
)
+ // A page that is left stops prefetching (a fetch still in flight would
+ // hold a connection from the back/forward cache), and starts again if
+ // it is shown from there.
+ const { signal } = (prefetching = new AbortController())
const fetchFn = (url) =>
- fetch(url, { priority: 'low', credentials: 'same-origin' }).then(async (r) => {
- if (!r.ok) return false
- await r.arrayBuffer()
- return true
- })
+ signal.aborted
+ ? Promise.resolve(false)
+ : fetch(url, { priority: 'low', credentials: 'same-origin', signal }).then(async (r) => {
+ if (!r.ok) return false
+ await r.arrayBuffer()
+ return true
+ })
return session.prefetch({ keys: FONTS, urls: faceURLs(document.styleSheets), fetchFn, idle })
}
+let prefetching = null
+addEventListener('pagehide', () => prefetching && prefetching.abort())
+addEventListener('pageshow', (e) => {
+ if (e.persisted && prefetching) prefetch()
+})
async function run() {
let need = []
diff --git a/fixtures/live-updates.mjs b/fixtures/live-updates.mjs
index 989b206..446e142 100644
--- a/fixtures/live-updates.mjs
+++ b/fixtures/live-updates.mjs
@@ -275,6 +275,19 @@ export function createLiveUpdates({
armClose(hiddenMs)
},
+ // noteLeaving is the page being left: navigated away from, or put in
+ // the back/forward cache. The stream closes now, rather than staying
+ // open in a page nobody is looking at; a cached page that comes back
+ // is activity, and noteActivity reopens it. Left open, each cached
+ // page held one of the browser's six HTTP/1.1 connections to this
+ // host, and after five documents the next navigation waited about a
+ // minute for one (found by the font gate's generative test in full
+ // Chrome, whose back/forward cache keeps the pages).
+ noteLeaving() {
+ if (stopped) return
+ closeStream()
+ },
+
get cursor() { return cursor },
get streaming() { return stream !== null },
}
diff --git a/fixtures/live-updates.test.mjs b/fixtures/live-updates.test.mjs
index 705e107..cc544e9 100644
--- a/fixtures/live-updates.test.mjs
+++ b/fixtures/live-updates.test.mjs
@@ -390,3 +390,16 @@ test('an update that waits holds the next one behind it', async () => {
await new Promise((r) => setImmediate(r))
assert.deepEqual(order, [1, 2])
})
+
+test('leaving the page closes the stream at once, and coming back reopens it', async () => {
+ // A page left for another, or put in the back/forward cache, must not
+ // keep its stream: each one held an HTTP/1.1 connection, and after five
+ // the next navigation waited about a minute for one.
+ const { live, stream } = build()
+ live.start()
+ assert.equal(stream.live.length, 1)
+ live.noteLeaving()
+ assert.equal(stream.live.length, 0, 'a page that was left kept its stream open')
+ live.noteActivity()
+ assert.equal(stream.live.length, 1, 'a page shown again from the cache did not reopen its stream')
+})
diff --git a/internal/docs/fonts_browser_test.go b/internal/docs/fonts_browser_test.go
index af4704d..4838b06 100644
--- a/internal/docs/fonts_browser_test.go
+++ b/internal/docs/fonts_browser_test.go
@@ -64,6 +64,8 @@ type fontRig struct {
blocked atomic.Value
// sqid is the document a test is on, for the steps that post to it.
sqid string
+ // streams is how many live-update streams the server is serving now.
+ streams atomic.Int64
}
func newFontRig(t *testing.T) *fontRig {
@@ -90,6 +92,10 @@ func newFontRig(t *testing.T) *fontRig {
http.NotFound(w, r)
return
}
+ if strings.HasSuffix(r.URL.Path, "/stream") {
+ fr.streams.Add(1)
+ defer fr.streams.Add(-1)
+ }
if strings.HasPrefix(r.URL.Path, "/static/editor.") {
time.Sleep(time.Duration(fr.editorDelay.Load()))
}
@@ -1039,8 +1045,20 @@ func TestFontTheGateCoversEveryFaceTheDocumentUses(t *testing.T) {
t.Errorf("%s %s: %s is drawn in %s, which the gate did not wait for", name, where, d.Where, id)
}
}
+ // A family the gate committed to its fallback (it missed the
+ // deadline) is drawn in a system face, so the DOM names no Docs
+ // face for it: the gate's families, less those, are exactly the
+ // DOM's. Any other difference is a family waited for and never
+ // drawn, or drawn and never waited for.
+ var fallback string
+ fr.eval(t, `document.documentElement.getAttribute('data-docs-fonts-fallback') || ''`, &fallback)
+ for _, k := range strings.Fields(fallback) {
+ if f, ok := fonts.ByKey(k); ok {
+ delete(needFamilies, f.CSSName())
+ }
+ }
if fmt.Sprint(sortedSet(needFamilies)) != fmt.Sprint(sortedSet(domFamilies)) {
- t.Errorf("%s %s: the gate waited for %v, the DOM uses %v", name, where, sortedSet(needFamilies), sortedSet(domFamilies))
+ t.Errorf("%s %s: the gate waited for %v (committed: %q), the DOM uses %v", name, where, sortedSet(needFamilies), fallback, sortedSet(domFamilies))
}
}
}
@@ -1846,3 +1864,36 @@ func TestFontACompositionNeverStartsAWait(t *testing.T) {
t.Logf("text %q, Caveat run: %v, fallback %q", text, caveat, fallback)
fr.noViolations(t)
}
+
+// A document that is left lets go of its connections at once: its live
+// stream closes on pagehide, and its prefetch stops. In a browser with a
+// back/forward cache (full Chrome) each document left behind otherwise
+// kept its stream open; with HTTP/1.1's six connections to a host, the
+// sixth navigation waited about a minute for one, and by the time its
+// page ran, the font gate's deadline had passed and it committed every
+// family still loading (the generative gate test on main 5a951ba).
+func TestFontLeavingADocumentLetsGoOfItsConnections(t *testing.T) {
+ fr := newFontRig(t)
+ var sqids []string
+ for i := 0; i < 8; i++ {
+ sqids = append(sqids, fr.document(t, fmt.Sprintf("Leaving %d", i), "simple.bin"))
+ }
+ for i, sqid := range sqids {
+ start := time.Now()
+ fr.open(t, sqid)
+ fr.editable(t)
+ var responseEnd float64
+ fr.eval(t, `performance.getEntriesByType('navigation')[0].responseEnd`, &responseEnd)
+ if took := time.Since(start); took > 5*time.Second || responseEnd > 3000 {
+ t.Errorf("document %d took %v to open (its response ended at %.0fms): a connection was still held by a page left behind", i, took, responseEnd)
+ }
+ // This page's stream, and none left open by the pages before it.
+ deadline := time.Now().Add(3 * time.Second)
+ for fr.streams.Load() > 1 && time.Now().Before(deadline) {
+ time.Sleep(100 * time.Millisecond)
+ }
+ if n := fr.streams.Load(); n > 1 {
+ t.Errorf("after opening document %d the server is serving %d live streams; the pages left behind kept theirs", i, n)
+ }
+ }
+}
diff --git a/internal/docs/static/editor.c2c7dc07e5705e7c.js b/internal/docs/static/editor.a987940e8957731f.js
similarity index 96%
rename from internal/docs/static/editor.c2c7dc07e5705e7c.js
rename to internal/docs/static/editor.a987940e8957731f.js
index ca673b0..29c0128 100644
--- a/internal/docs/static/editor.c2c7dc07e5705e7c.js
+++ b/internal/docs/static/editor.a987940e8957731f.js
@@ -11,4 +11,4 @@ ${t.toString()}`)},Jo=class{constructor(e){this.patterns=[],this.$state=e}if(e,t
`);return{dom:a,text:h,slice:e}}function Xh(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 b(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=Xt.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=U0(t),ai&&V0(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")||Jr.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||f),context:i,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!v0.test(h.parentNode.nodeName)?{ignore:!0}:null}})),f)l=F0(Eh(l,+f[1],+f[2]),f[4]);else if(l=b.maxOpen(B0(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=Eh(l,u,h)}return n.someProp("transformPasted",u=>{l=u(l,n,a)}),l}var v0=/^(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 B0(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&&Qh(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=ed(o[o.length-1],s.length));let f=Zh(l,a);o.push(f),i=i.matchType(f.type),s=a}}),o)return x.from(o)}return n}function Zh(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,x.from(n));return n}function Qh(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=Qh(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(Zh(t,n,i+1))))}}function ed(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,ed(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(x.empty,!0);return n.copy(t.append(r))}function pa(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=pa(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 Eh(n,e,t){return e<n.openStart&&(n=new b(pa(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new b(pa(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}var td={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 nd(){return document.implementation.createHTMLDocument("title")}var ei=null;function L0(n){let e=window.trustedTypes;if(!e)return n;if(!ei){if(ei=e.defaultPolicy)try{return ei.createHTML(n)}catch{}ei=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})}return ei.createHTML(n)}function U0(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=nd(),r=t.body,i=/<([a-z][^>\s]+)/i.exec(n),s;if((s=i&&td[i[1].toLowerCase()])&&(n=s.map(o=>"<"+o+">").join("")+n+s.map(o=>"</"+o+">").reverse().join("")),r.innerHTML=L0(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 V0(n){let e=n.querySelectorAll(re?"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 F0(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 b(i,s,o)}var pe={},me={},P0={touchstart:!0,touchmove:!0},ma=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 z0(n){for(let e in pe){let t=pe[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{q0(n,r)&&!Ma(n,r)&&(n.editable||!(r.type in me))&&t(n,r)},P0[e]?{passive:!0}:void 0)}fe&&n.dom.addEventListener("input",()=>null),ga(n)}function ut(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function $0(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 ga(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Ma(n,r))})}function Ma(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function q0(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 W0(n,e){!Ma(n,e)&&pe[e.type]&&(n.editable||!(e.type in me))&&pe[e.type](n,e)}me.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!sd(n)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(ft&&re&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),rr&&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,nn(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||R0(n,t)?t.preventDefault():ut(n,"key")};me.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};me.keypress=(n,e)=>{let t=e;if(sd(n)||!t.charCode||t.ctrlKey&&!t.altKey||Re&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof R)||!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 ci(n){return{left:n.clientX,top:n.clientY}}function J0(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Aa(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 fi(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 j0(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&T.isSelectable(r)?(fi(n,new T(t),"pointer"),!0):!1}function H0(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?(fi(n,T.create(n.state.doc,i),"pointer"),!0):!1}function K0(n,e,t,r,i){return Aa(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?H0(n,t):j0(n,t))}function Y0(n,e,t,r){return Aa(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function G0(n,e,t,r){return Aa(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||X0(n,t,r)}function X0(n,e,t){if(t.button!=0)return!1;let r=rd(n,e,!0),i=n.state.doc;return r?(fi(n,r,"pointer"),r instanceof R&&i.eq(n.state.doc)&&(n.input.mouseDown=new xa(n,r)),!0):!1}function rd(n,e,t){let r=n.state.doc;if(e==-1)return r.inlineContent?R.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 R.create(r,l+1,l+1+o.content.size);if(t&&T.isSelectable(o))return T.create(r,l)}return null}function Oa(n){return Js(n)}var id=Re?"metaKey":"ctrlKey";pe.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Oa(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&J0(t,n.input.lastClick)&&!t[id]&&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(ci(t));o&&(s=="singleClick"?n.input.mouseDown=new ya(n,o,t,!!r):(s=="doubleClick"?Y0:G0)(n,o.pos,o.inside,t)?t.preventDefault():ut(n,"pointer"))};var Ws=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}},ya=class extends Ws{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[id],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&&Be&&!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()),ut(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||ht(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(ci(e))),this.updateAllowDefault(e),this.allowDefault||!t?ut(this.view,"pointer"):K0(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||fe&&this.mightDrag&&!this.mightDrag.node.isAtom||re&&!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)?(fi(this.view,O.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):ut(this.view,"pointer")}move(e){this.updateAllowDefault(e),ut(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}},xa=class extends Ws{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(),ut(this.view,"pointer");let t=this.view.posAtCoords(ci(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];fi(this.view,R.create(i,o,l),"pointer")}};pe.touchstart=n=>{n.input.lastTouch=Date.now(),Oa(n),ut(n,"pointer")};pe.touchmove=n=>{n.input.lastTouch=Date.now(),ut(n,"pointer")};pe.contextmenu=n=>Oa(n);function sd(n,e){return n.composing?!0:fe&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var Z0=ft?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 R&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||re&&Uh&&Q0(n)))n.markCursor=n.state.storedMarks||t.marks(),Js(n,!0),n.markCursor=null;else if(Js(n,!e.selection.empty),Be&&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}od(n,Z0)};function Q0(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++,od(n,20))};function od(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Js(n),e))}function ld(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function ex(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Xy(e.focusNode,e.focusOffset),r=Zy(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 Js(n,e=!1){if(!(ft&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),ld(n),e||n.docView&&n.docView.dirty){let t=Ca(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 tx(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 ri=Ce&&Ot<15||rr&&n0<604;pe.copy=me.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=ri?null:t.clipboardData,o=r.content(),{dom:l,text:a}=Ta(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):tx(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function nx(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function rx(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?ii(n,r.value,null,i,e):ii(n,r.textContent,r.innerHTML,i,e)},50)}function ii(n,e,t,r,i){let s=Xh(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,s||b.empty)))return!0;if(!s)return!1;let o=nx(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 ad(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&&!ft)return;let r=ri?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&ii(n,ad(r),r.getData("text/html"),i,t)?t.preventDefault():rx(n,t)};var js=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},ix=Re?"altKey":"ctrlKey";function cd(n,e){let t;return n.someProp("dragCopies",r=>{t=t||r(e)}),t!=null?!t:!e[ix]}pe.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(ci(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}=Ta(n,l);(!t.dataTransfer.files.length||!re||Lh>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(ri?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",ri||t.dataTransfer.setData("text/plain",c),n.dragging=new js(f,cd(n,t),o)};pe.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{sx(n,e,n.dragging)}finally{n.dragging=null}};function sx(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(ci(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=Xh(n,ad(e.dataTransfer),ri?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(t&&cd(n,e));if(n.someProp("handleDrop",d=>d(n,e,s||b.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?ju(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(Ea(n,h,a.doc.resolve(d)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}pe.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())&&ht(n)},20))};pe.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)};pe.beforeinput=(n,e)=>{if(ft&&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,nn(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)pe[n]=me[n];function si(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 Hs=class n{constructor(e,t){this.toDOM=e,this.spec=t||an,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 Ye(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&&si(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},ln=class n{constructor(e,t){this.attrs=e,this.spec=t||an}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 Ye(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof n&&si(this.attrs,e.attrs)&&si(this.spec,e.spec)}static is(e){return e.type instanceof n}destroy(){}},ba=class n{constructor(e,t){this.attrs=e,this.spec=t||an}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 Ye(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&&si(this.attrs,e.attrs)&&si(this.spec,e.spec)}destroy(){}},Ye=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 Hs(t,r))}static inline(e,t,r,i){return new n(e,t,new ln(r,i))}static node(e,t,r,i){return new n(e,t,new ba(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof ln}get widget(){return this.type instanceof Hs}},tr=[],an={},ce=class n{constructor(e,t){this.local=e.length?e:tr,this.children=t.length?t:tr}static create(e,t){return t.length?Ys(t,e,0,an):ae}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==ae||e.maps.length==0?this:this.mapInner(e,t,0,0,r||an)}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?ox(this.children,o||[],e,t,r,i,s):o?new n(o.sort(cn),tr):ae}add(e,t){return t.length?this==ae?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=ud(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,Ys(f,l,c+1,an)),s+=3}});let o=fd(s?hd(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(cn):this.local,i||this.children)}remove(e){return e.length==0||this==ae?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!=ae?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):ae}forChild(e,t){if(this==ae)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 ln){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(cn),tr);return r?new Ks([l,r]):l}return r||ae}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 Da(this.localsInner(e))}localsInner(e){if(this==ae)return tr;if(e.inlineContent||!this.local.some(ln.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof ln||t.push(this.local[r]);return t}forEachSet(e){e(this)}};ce.empty=new ce([],[]);ce.removeOverlap=Da;var ae=ce.empty,Ks=class n{constructor(e){this.members=e}map(e,t){let r=this.members.map(i=>i.map(e,t,an));return n.from(r)}forChild(e,t){if(t.isLeaf)return ce.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=ae&&(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?Da(r?t:t.sort(cn)):tr}static from(e){switch(e.length){case 0:return ae;case 1:return e[0];default:return new n(e.every(t=>t instanceof ce)?e:e.reduce((t,r)=>t.concat(r instanceof ce?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function ox(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 k=l[y+1];if(k<0||h>k+f-u)continue;let C=l[y]+f-u;d>=C?l[y+1]=h<=C?-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!=ae?(l[c]=u,l[c+1]=d,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=lx(l,n,e,t,i,s,o),f=Ys(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 ce(e.sort(cn),l)}function fd(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 Ye(i.from+e,i.to+e,i.type))}return t}function lx(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 ud(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 hd(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Ys(n,e,t,r){let i=[],s=!1;e.forEach((l,a)=>{let c=ud(n,l,a+t);if(c){s=!0;let f=Ys(c,l,t+a+1,r);f!=ae&&i.push(a,a+l.nodeSize,f)}});let o=fd(s?hd(n):n,-t).sort(cn);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 ce(o,i):ae}function cn(n,e){return n.from-e.from||n.to-e.to}function Da(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),Th(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),Th(e,i,r.copy(s.from,r.to)));break}}}return e}function Th(n,e,t){for(;e<n.length&&cn(t,n[e])>0;)e++;n.splice(e,0,t)}function ea(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=ae&&e.push(r)}),n.cursorWrapper&&e.push(ce.create(n.state.doc,[n.cursorWrapper.deco])),Ks.from(e)}var ax={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},cx=Ce&&Ot<=11,wa=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}},Sa=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new wa,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]);Ce&&Ot<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():fe&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),cx&&(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,ax)),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(xh(this.view)){if(this.suppressingSelectionUpdates)return ht(this.view);if(Ce&&Ot<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&fn(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=nr(s))t.add(s);for(let s=e.anchorNode;s;s=nr(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)&&xh(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||re&&(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(Be&&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||hx(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&&Gs(r)&&(c=Ca(e))&&c.eq(O.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ht(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),fx(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,dx(e,a)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||ht(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(Ce&&Ot<=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?ne(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?ne(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})}},Mh=new WeakMap,Ah=!1;function fx(n){if(!Mh.has(n)&&(Mh.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Be,Ah)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."),Ah=!0}}function Oh(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return fn(o.node,o.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function ux(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return Oh(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?Oh(n,t):null}function hx(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 dx(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 px(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}],Gs(c)||f.push({node:c.focusNode,offset:c.focusOffset})),re&&n.input.lastKeyCode===8)for(let y=o;y>s;y--){let k=i.childNodes[y-1],C=k.pmViewDesc;if(k.nodeName=="BR"&&!C){o=y;break}if(!C||C.size)break}let h=n.state.doc,d=n.someProp("domParser")||Jr.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:mx(r),context:p});if(f&&f[0].pos!=null){let y=f[0].pos,k=f[1]&&f[1].pos;k==null&&(k=y),m={anchor:y+l,head:k+l}}return{doc:g,sel:m,from:l,to:a}}var mx=n=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(n);if(e.nodeName=="BR"&&e.parentNode){if(fe&&/^(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||fe&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},gx=/^(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 yx(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let A=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,q=Ca(n,A);if(q&&!n.state.selection.eq(q)){if(re&&ft&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",Si=>Si(n,nn(13,"Enter"))))return;let F=n.state.tr.setSelection(q);A=="pointer"?F.setMeta("pointer",!0):A=="key"&&F.scrollIntoView(),s&&F.setMeta("composition",s),n.dispatch(F)}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=px(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=wx(u.content,c.doc.content,c.from,h,d);if(p&&n.input.domChangeCount++,(rr&&n.input.lastIOSEnter>Date.now()-225||ft)&&i.some(A=>A.nodeType==1&&!gx.test(A.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",A=>A(n,nn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof R&&!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 A=Dh(n,n.state.doc,c.sel);if(A&&!A.eq(n.state.selection)){let q=n.state.tr.setSelection(A);s&&q.setMeta("composition",s),n.dispatch(q)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof R&&(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)),Ce&&Ot<=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),k=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((rr&&n.input.lastIOSEnter>Date.now()-225&&(!k||i.some(A=>A.nodeName=="DIV"||A.nodeName=="P"))||!k&&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",A=>A(n,nn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&bx(f,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",A=>A(n,nn(8,"Backspace")))){ft&&re&&n.domObserver.suppressSelectionUpdates();return}re&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),ft&&!k&&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(A){return A(n,nn(13,"Enter"))})},20));let C=p.start,I=p.endA,U=A=>{let q=A||n.state.tr.replace(C,I,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let F=Dh(n,q.doc,c.sel);F&&!(re&&n.composing&&F.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(F.head==C||F.head==q.mapping.map(I)-1)||Ce&&F.empty&&F.head==C)&&q.setSelection(F)}return s&&q.setMeta("composition",s),q.scrollIntoView()},Ue;if(k)if(m.pos==g.pos){Ce&&Ot<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>ht(n),20));let A=U(n.state.tr.delete(C,I)),q=f.resolve(p.start).marksAcross(f.resolve(p.endA));q&&A.ensureMarks(q),n.dispatch(A)}else if(p.endA==p.endB&&(Ue=xx(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let A=U(n.state.tr);Ue.type=="add"?A.addMark(C,I,Ue.mark):A.removeMark(C,I,Ue.mark),n.dispatch(A)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let A=m.parent.textBetween(m.parentOffset,g.parentOffset),q=()=>U(n.state.tr.insertText(A,C,I));n.someProp("handleTextInput",F=>F(n,C,I,A,q))||n.dispatch(q())}else n.dispatch(U());else n.dispatch(U())}function Dh(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Ea(n,e.resolve(t.anchor),e.resolve(t.head))}function xx(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 bx(n,e,t,r,i){if(t-e<=i.pos-r.pos||ta(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(ta(s,!0,!0));return!o.parent.isTextblock||o.pos>t||ta(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function ta(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 wx(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 oi=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 ma,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(vh),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=_h(this),Ih(this),this.nodeViews=Rh(this),this.docView=hh(this.state.doc,Nh(this),ea(this),this.dom,this),this.domObserver=new Sa(this,(r,i,s,o)=>yx(this,r,i,s,o)),this.domObserver.start(),z0(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&&ga(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(vh),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&&(ld(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=Rh(this);kx(d,this.nodeViews)&&(this.nodeViews=d,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&ga(this),this.editable=_h(this),Ih(this);let a=ea(this),c=Nh(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&&s0(this);if(o){this.domObserver.stop();let d=u&&(Ce||re)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Sx(i.selection,e.selection);if(u){let m=re?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=ex(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=hh(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())&&M0(this)&&p.delaySelUpdate())?ht(this,d):(Kh(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&&o0(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&&lh(this,t.getBoundingClientRect(),e)}else lh(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 js(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(Ce){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&&l0(this.dom),ht(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 h0(this,e)}coordsAtPos(e,t=1){return $h(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 y0(this,t||this.state,e)}pasteHTML(e,t){return ii(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return ii(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Ta(this,e)}destroy(){this.docView&&($0(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ea(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Yy())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return W0(this,e)}domSelectionRange(){let e=this.domSelection();return e?fe&&this.root.nodeType===11&&e0(this.dom.ownerDocument)==this.dom&&ux(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};oi.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function Nh(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"),[Ye.node(0,n.state.doc.content.size,e)]}function Ih(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:Ye.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function _h(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Sx(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 Rh(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 kx(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 vh(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 Cx=["ol",0],Ex=["ul",0],Tx=["li",0],Mx={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?Cx:["ol",{start:n.attrs.order},0]}},Ax={parseDOM:[{tag:"ul"}],toDOM(){return Ex}},Ox={parseDOM:[{tag:"li"}],toDOM(){return Tx},defining:!0};function Na(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 dd(n,e,t){return n.append({ordered_list:Na(Mx,{content:"list_item+",group:t}),bullet_list:Na(Ax,{content:"list_item+",group:t}),list_item:Na(Ox,{content:e})})}function pd(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 Dx(l,o,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Dx(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 Yt(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Yt(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=Gn(s,t,r,e);return l?(n&&Nx(n,e,l,i,t),!0):!1}function Nx(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 Q(e.start-(r?2:0),e.end,e.start,e.end,new b(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&&Et(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(f).nodeSize;return n}function md(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 b(u,4-h,0)),g=-1;m.doc.nodesBetween(p,m.doc.content.size,(y,k)=>{if(g>-1)return!1;y.isTextblock&&y.content.size==0&&(g=k+1)}),g>-1&&m.setSelection(O.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 Et(c.doc,i.pos,2,f)?(r&&r(c.split(i.pos,2,f).scrollIntoView()),!0):!1}}function ui(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?Ix(e,t,n,s):_x(e,t,s):!0:!1}}function Ix(n,e,t,r){let i=n.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new Q(s-1,o,s,o,new b(x.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new Yt(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));let l=Qt(r);if(l==null)return!1;i.lift(r,l);let a=i.doc.resolve(i.mapping.map(s,-1)-1);return en(i.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&i.join(a.pos),e(i.scrollIntoView()),!0}function _x(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 Q(u-(l?1:0),h+(a?1:0),u+1,h-1,new b((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 Xs(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 b(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 Q(h-(c?3:1),d,h,d,u,1,!0)).scrollIntoView())}return!0}}var dt={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:"'"},Qs={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Rx=typeof navigator<"u"&&/Mac/.test(navigator.platform),vx=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(j=0;j<10;j++)dt[48+j]=dt[96+j]=String(j);var j;for(j=1;j<=24;j++)dt[j+111]="F"+j;var j;for(j=65;j<=90;j++)dt[j]=String.fromCharCode(j+32),Qs[j]=String.fromCharCode(j);var j;for(Zs in dt)Qs.hasOwnProperty(Zs)||(Qs[Zs]=dt[Zs]);var Zs;function gd(n){var e=Rx&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||vx&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Qs:dt)[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 Bx=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Lx=typeof navigator<"u"&&/Win/.test(navigator.platform);function Ux(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))Bx?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 Vx(n){let e=Object.create(null);for(let t in n)e[Ux(t)]=n[t];return e}function Ia(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 _a(n){return new le({props:{handleKeyDown:Fx(n)}})}function Fx(n){let e=Vx(n);return function(t,r){let i=gd(r),s,o=e[Ia(i,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Ia(i,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Lx&&r.ctrlKey&&r.altKey)&&(s=dt[r.keyCode])&&s!=i){let l=e[Ia(s,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var xd=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Px(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}var zx=(n,e,t)=>{let r=Px(n,t);if(!r)return!1;let i=bd(r);if(!i){let o=r.blockRange(),l=o&&Qt(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(kd(n,i,e,-1))return!0;if(r.parent.content.size==0&&(ir(s,"end")||T.isSelectable(s)))for(let o=r.depth;;o--){let l=Bs(n.doc,r.before(o),r.after(o),b.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(ir(s,"end")?O.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 ir(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 $x=(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=bd(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 bd(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 qx(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}var Wx=(n,e,t)=>{let r=qx(n,t);if(!r)return!1;let i=wd(r);if(!i)return!1;let s=i.nodeAfter;if(kd(n,i,e,1))return!0;if(r.parent.content.size==0&&(ir(s,"start")||T.isSelectable(s))){let o=Bs(n.doc,r.before(),r.after(),b.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(ir(s,"start")?O.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},Jx=(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=wd(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 wd(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 Sd=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),s=i&&Qt(i);return s==null?!1:(e&&e(n.tr.lift(i,s).scrollIntoView()),!0)},jx=(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 va(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 Hx=(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=va(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(O.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Kx=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof de||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=va(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(R.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Yx=(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(Et(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&Qt(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function Gx(n){return(e,t)=>{if(e.selection instanceof T&&e.selection.node.isBlock){let{$from:d}=e.selection;return!d.parentOffset||!Et(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 R||e.selection instanceof de)&&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=va(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=Et(r.doc,u,o.length,o);if(h||(o[0]=a?{type:a}:null,h=Et(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 Xx=Gx();var Ba=(n,e)=>(e&&e(n.tr.setSelection(new de(n.doc))),!0);function Zx(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||en(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function kd(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&Zx(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 Q(e.pos-1,d,e.pos,d,new b(p,1,0),o.length,!0)),g=m.doc.resolve(d+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&en(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let f=s.type.spec.isolating||r>0&&a?null:O.findFrom(e,1),u=f&&f.$from.blockRange(f.$to),h=u&&Qt(u);if(h!=null&&h>=e.depth)return t&&t(n.tr.lift(u,h).scrollIntoView()),!0;if(c&&ir(s,"start",!0)&&ir(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 C=p.length-1;C>=0;C--)y=x.from(p[C].copy(y));let k=n.tr.step(new Q(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new b(y,p.length,0),0,!0));t(k.scrollIntoView())}return!0}}return!1}function Cd(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(R.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}var Qx=Cd(-1),eb=Cd(1);function Ed(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&Gn(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function La(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 tb(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 nb(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 Zn(r,r.doc.resolve(o+1))),r=r.doc.resolve(o+1+s.content.size),!1}),r.pos<i.pos&&e.push(new Zn(r,i))}return e}function hn(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||!tb(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=nb(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,k=p.nodeAfter,C=m.nodeBefore,I=s&&k&&k.isText?/^\s*/.exec(k.text)[0].length:0,U=s&&C&&C.isText?/\s*$/.exec(C.text)[0].length:0;g+I<y&&(g+=I,y-=U),h.addMark(g,y,n.create(e))}}l(h.scrollIntoView())}return!0}}function Ge(...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 Ra=Ge(xd,zx,$x),yd=Ge(xd,Wx,Jx),pt={Enter:Ge(jx,Kx,Yx,Xx),"Mod-Enter":Hx,Backspace:Ra,"Mod-Backspace":Ra,"Shift-Backspace":Ra,Delete:yd,"Mod-Delete":yd,"Mod-a":Ba},Td={"Ctrl-h":pt.Backspace,"Alt-Backspace":pt["Mod-Backspace"],"Ctrl-d":pt.Delete,"Ctrl-Alt-Backspace":pt["Mod-Delete"],"Alt-Delete":pt["Mod-Delete"],"Alt-d":pt["Mod-Delete"],"Ctrl-a":Qx,"Ctrl-e":eb};for(let n in pt)Td[n]=pt[n];var rb=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,Ua=rb?Td:pt;function ib(n){let e=Va(n);return e?"docs-indent-"+e:null}function Va(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 sb(n){for(let e of n){if(!e.startsWith("docs-indent-"))continue;let t=Va(e.slice(12));if(t)return t}return null}function Fa(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:sb(Array.from(i.classList||[]))}}})),toDOM:r=>{let i=n.toDOM?n.toDOM(r):[e,0],s=ib(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 sr(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=Va(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 Xe=class{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?ob(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}};function ob(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 lb=500;function Ad({rules:n}){let e=new le({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 Md(t,r,i,s,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&Md(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function Md(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-lb),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 Od=(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},GS=new Xe(/--$/,"\u2014",{inCodeMark:!1}),XS=new Xe(/\.\.\.$/,"\u2026",{inCodeMark:!1}),ZS=new Xe(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C",{inCodeMark:!1}),QS=new Xe(/"$/,"\u201D",{inCodeMark:!1}),ek=new Xe(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018",{inCodeMark:!1}),tk=new Xe(/'$/,"\u2019",{inCodeMark:!1});function eo(n,e,t=null,r){return new Xe(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&&Gn(u,e,a);if(!h)return null;c.wrap(u,h);let d=c.doc.resolve(o-1).nodeBefore;return d&&d.type==e&&en(c.doc,o-1)&&(!r||r(s,d))&&c.join(o-1),c})}function Dd(n,e,t=null){return new Xe(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 ab=/^\s*([-+*])\s$/,cb=/^(\d+)\.\s$/,fb=/^\s*>\s$/,ub=/^(#{1,3})\s$/;function Nd(n){let e=[],{bullet_list:t,ordered_list:r,blockquote:i,heading:s}=n.nodes;return t&&e.push(eo(ab,t)),r&&e.push(eo(cb,r)),i&&e.push(eo(fb,i)),s&&e.push(Dd(ub,s,o=>({level:o[1].length}))),Ad({rules:e})}var hi=new Tt("docs-pages"),hb=864,dn="paged",di="infinite",db="docs-view";function Id(n){document.cookie=`${db}=${n}; Path=/; Max-Age=31536000; SameSite=Lax`}function pb(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>hb&&(e.push(s),r=l.top)}}),e}function _d({getMode:n,pageLabel:e}){return new le({key:hi,state:{init:()=>({positions:[],deco:ce.empty}),apply(t,r,i,s){let o=t.getMeta(hi);if(!o)return{positions:r.positions,deco:r.deco.map(t.mapping,t.doc)};let l=o.positions.map((a,c)=>Ye.widget(a,()=>mb(c+2,e),{side:-1,ignoreSelection:!0}));return{positions:o.positions,deco:ce.create(s.doc,l)}}},props:{decorations(t){return n()!==dn?ce.empty:hi.getState(t).deco}},view(t){let r=0,i="",s=()=>{if(r=0,n()!==dn){i!==""&&(i="",t.dispatch(t.state.tr.setMeta(hi,{positions:[]})));return}let a=pb(t),c=a.join(",");c!==i&&(i=c,t.dispatch(t.state.tr.setMeta(hi,{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 mb(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 Rd=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null;function vd(n){if(!n)return 0;if(Rd){let t=0;for(let r of Rd.segment(n))r.isWordLike&&t++;return t}let e=n.trim().split(/\s+/);return e.length===1&&e[0]===""?0:e.length}function Bd(n){let e=[];return n.descendants(t=>{t.isText?e.push(t.text):t.isBlock&&e.length&&e.push(" ")}),e.join("")}function gb(n){let e=Bd(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:Bd(n.doc.cut(t,r));return{words:vd(e),characters:e.length,charactersNoSpaces:e.replace(/\s/g,"").length,paragraphs:s,selection:o===null?null:{words:vd(o),characters:o.length}}}function Ld(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=gb(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 yb(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 Ud(n,{menubar:e,extraRows:t}){if(!n||typeof n.showModal!="function")return null;let r=n.querySelector("[docs-shortcuts-body]");return r?()=>{let i=[...yb(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}var Vd=()=>{let n=!0;return(e,t)=>{if(n){n=!1;try{e()}finally{n=!0}}else t!==void 0&&t()}};var xb=/[\uD800-\uDBFF]/,bb=/[\uDC00-\uDFFF]/,wb=(n,e)=>{let t=0,r=0;for(;t<n.length&&t<e.length&&n[t]===e[t];)t++;for(t>0&&xb.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&&bb.test(n[n.length-r])&&r--,{index:t,remove:n.length-t-r,insert:e.slice(t,e.length-r)}},Fd=wb;var V=new Tt("y-sync"),Ze=new Tt("y-undo"),dk=new Tt("yjs-cursor");var Qe=(n,e)=>n>>>e|n<<32-e,Sb=n=>Qe(n,2)^Qe(n,13)^Qe(n,22),kb=n=>Qe(n,6)^Qe(n,11)^Qe(n,25),Cb=n=>Qe(n,7)^Qe(n,18)^n>>>3,Eb=n=>Qe(n,17)^Qe(n,19)^n>>>10,Tb=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]),Mb=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Pa=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(Mb),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let u=16;u<64;u++)t[u]=Eb(t[u-2])+t[u-7]+Cb(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+kb(l)+(l&a^~l&c)+Tb[u]+t[u]>>>0,d=Sb(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}},Pd=n=>new Pa().digest(n);var Ob=n=>{for(let t=6;t<n.length;t++)n[t%6]=n[t%6]^n[t];return n.slice(0,6)},zd=n=>jc(Ob(Pd(Kc(n))));var pi=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&e.sv.get(n.id.client)>n.id.clock&&!jt(e.ds,n.id),Nb=[{light:"#ecd44433",dark:"#ecd444"}],Ib=(n,e,t)=>{if(!n.has(t)){if(n.size<e.length){let r=Pe();n.forEach(i=>r.add(i)),e=e.filter(i=>!r.has(i))}n.set(t,_c(e))}return n.get(t)},Wa=(n,{colors:e=Nb,colorMapping:t=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:s}={})=>{let o=!1,l=new ro(n,s),a=new le({props:{editable:c=>{let f=V.getState(c);return f.snapshot==null&&f.prevSnapshot==null}},key:V,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(V);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)&&Ho(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=Ze.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)},V)})}},destroy:()=>{l.destroy()}})});return a},_b=(n,e,t)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")n.setSelection(new de(n.doc));else if(e.type==="node"){let r=no(t.doc,t.type,e.anchor,t.mapping);n.setSelection(T.create(n.doc,r))}else{let r=no(t.doc,t.type,e.anchor,t.mapping),i=no(t.doc,t.type,e.head,t.mapping);if(r!==null&&i!==null){let s=R.between(n.doc.resolve(r),n.doc.resolve(i));n.setSelection(s)}}},mi=(n,e)=>({type:e.selection.jsonID,anchor:qa(e.selection.anchor,n.type,n.mapping),head:qa(e.selection.head,n.type,n.mapping)}),ro=class{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=Vd(),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=mi(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()?(Cr&&this._domSelectionInView===null&&(Ho(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=it.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=xs(ms(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(V,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{let e=this.type.toArray().map(r=>to(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new b(x.from(e),0,0));t.setMeta(V,{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=>to(i,this.prosemirrorView.state.schema,this)).filter(i=>i!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new b(x.from(t),0,0));if(e){let i=rt(ze(e.anchor,0),r.doc.content.size),s=rt(ze(e.head,0),r.doc.content.size);r.setSelection(R.create(r.doc,i,s))}this.prosemirrorView.dispatch(r.setMeta(V,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,r){let i=this.doc,s=this.type;if(e||(e=bs(this.doc)),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&H(),i=new Ne({gc:!1}),gs(i,t),t=bs(i),gs(i,e),e=bs(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=Ie(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=>{st(o,u,h=>{})});let a=(u,h)=>{let d=u==="added"?l.getUserByClientId(h.client):l.getUserByDeletedId(h);return{user:d,type:u,color:Ib(r.colorMapping,r.colors,d)}},c=Al(s,new Pn(t.ds,e.sv)).map(u=>!u._item.deleted||pi(u._item,e)||pi(u._item,t)?to(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 b(x.from(c),0,0));this.prosemirrorView.dispatch(f.setMeta(V,{isChangeOrigin:!0}))},V)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let r=V.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);st(t,t.deleteSet,l=>{if(l.constructor===v){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=>Wd(l,this.prosemirrorView.state.schema,this)).filter(l=>l!==null),o=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new b(x.from(s),0,0));_b(o,this.beforeTransactionSelection,this),o=o.setMeta(V,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof zn}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&o.scrollIntoView(),this.prosemirrorView.dispatch(o)})}_prosemirrorChanged(e){this.doc.transact(()=>{so(this.doc,this.type,e,this),this.beforeTransactionSelection=mi(this,this.prosemirrorView.state)},V)}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))}},Wd=(n,e,t,r,i,s)=>{let o=t.mapping.get(n);if(o===void 0){if(n instanceof Y)return to(n,e,t,r,i,s);throw he()}return o},to=(n,e,t,r,i,s)=>{let o=[],l=a=>{if(a instanceof Y){let c=Wd(a,e,t,r,i,s);c!==null&&o.push(c)}else{let c=a._item.right?.content?.type;c instanceof ot&&!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=Rb(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):Al(n,new Pn(i.ds,r.sv)).forEach(l);try{let a=n.getAttributes(r);r!==void 0&&(pi(n._item,r)?pi(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)},V),t.mapping.delete(n),null}},Rb=(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,Fb(c.attributes,e)))}}catch{return n.doc.transact(c=>{n._item.delete(c)},V),null}return o},vb=(n,e)=>{let t=new se,r=n.map(i=>({insert:i.text,attributes:Hd(i.marks,e)}));return t.applyDelta(r),e.mapping.set(t,n),t},Bb=(n,e)=>{let t=new Y(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,oo(n).map(r=>za(r,e))),e.mapping.set(t,n),t},za=(n,e)=>n instanceof Array?vb(n,e):Bb(n,e),$d=n=>typeof n=="object"&&n!==null,Ja=(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||$d(o)&&$d(l)&&Ja(o,l)}return r},oo=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},Jd=(n,e)=>{let t=n.toDelta();return t.length===e.length&&t.every((r,i)=>r.insert===e[i].text&&Io(r.attributes||{}).length===e[i].marks.length&&bt(r.attributes,(s,o)=>{let l=jd(o),a=e[i].marks;return Ja(s,a.find(c=>c.type.name===l)?.attrs)}))},gi=(n,e)=>{if(n instanceof Y&&!(e instanceof Array)&&$a(n,e)){let t=oo(e);return n._length===t.length&&Ja(n.getAttributes(),e.attrs)&&n.toArray().every((r,i)=>gi(r,t[i]))}return n instanceof se&&e instanceof Array&&Jd(n,e)},io=(n,e)=>n===e||n instanceof Array&&e instanceof Array&&n.length===e.length&&n.every((t,r)=>e[r]===t),qd=(n,e,t)=>{let r=n.toArray(),i=oo(e),s=i.length,o=r.length,l=rt(o,s),a=0,c=0,f=!1;for(;a<l;a++){let u=r[a],h=i[a];if(io(t.mapping.get(u),h))f=!0;else if(!gi(u,h))break}for(;a+c<l;c++){let u=r[o-c-1],h=i[s-c-1];if(io(t.mapping.get(u),h))f=!0;else if(!gi(u,h))break}return{equalityFactor:a+c,foundMappedChild:f}},Lb=n=>{let e="",t=n._start,r={};for(;t!==null;)t.deleted||(t.countable&&t.content instanceof $e?e+=t.content.str:t.content instanceof $&&(r[t.content.key]=null)),t=t.right;return{str:e,nAttrs:r}},Ub=(n,e,t)=>{t.mapping.set(n,e);let{nAttrs:r,str:i}=Lb(n),s=e.map(c=>({insert:c.text,attributes:Object.assign({},r,Hd(c.marks,t))})),{insert:o,remove:l,index:a}=Fd(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})))},Vb=/(.*)(--[a-zA-Z0-9+/=]{8})$/,jd=n=>Vb.exec(n)?.[1]??n,Fb=(n,e)=>{let t=[];for(let r in n)t.push(e.mark(jd(r),n[r]));return t},Hd=(n,e)=>{let t={};return n.forEach(r=>{if(r.type.name!=="ychange"){let i=Oe(e.isOMark,r.type,()=>!r.type.excludes(r.type));t[i?`${r.type.name}--${zd(r.toJSON())}`:r.type.name]=r.attrs}}),t},so=(n,e,t,r)=>{if(e instanceof Y&&e.nodeName!==t.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,t),e instanceof Y){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=oo(t),s=i.length,o=e.toArray(),l=o.length,a=rt(s,l),c=0,f=0;for(;c<a;c++){let u=o[c],h=i[c];if(!io(r.mapping.get(u),h))if(gi(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(!io(r.mapping.get(u),h))if(gi(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 se&&d instanceof Array)Jd(h,d)||Ub(h,d,r),c+=1;else{let g=h instanceof Y&&$a(h,d),y=p instanceof Y&&$a(p,m);if(g&&y){let k=qd(h,d,r),C=qd(p,m,r);k.foundMappedChild&&!C.foundMappedChild?y=!1:!k.foundMappedChild&&C.foundMappedChild||k.equalityFactor<C.equalityFactor?g=!1:y=!1}g?(so(n,h,d,r),c+=1):y?(so(n,p,m,r),f+=1):(r.mapping.delete(e.get(c)),e.delete(c,1),e.insert(c,[za(d,r)]),c+=1)}}let u=l-c-f;if(l===1&&s===0&&o[0]instanceof se?(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(za(i[d],r));e.insert(c,h)}},V)},$a=(n,e)=>!(e instanceof Array)&&n.nodeName===e.type.name;var qa=(n,e,t)=>{if(n===0)return ys(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 se){if(r._length>=n)return ys(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 qt(r._item===null?null:r._item.id,r._item===null?Wn(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 qt(r._item===null?null:r._item.id,r._item===null?Wn(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 H();if(n===0&&r.constructor!==se&&r!==e)return Pb(r._item.parent,r._item)}return ys(e,e._length,e.length===0?-1:0)},Pb=(n,e)=>{let t=null,r=null;return n._item===null?r=Wn(n):t=M(n._item.id.client,n._item.id.clock),new qt(t,r,e.id)},no=(n,e,t,r)=>{let i=Vf(t,n);if(i===null||i.type!==e&&!Fn(e,i.type._item))return null;let s=i.type,o=0;if(s.constructor===se)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 se?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 se?o+=c._length:o+=r.get(c).nodeSize),a=a.right}}s=l}return o-1};var ja=n=>Ze.getState(n)?.undoManager?.undo()!=null,lo=n=>Ze.getState(n)?.undoManager?.redo()!=null,Kd=(n,e)=>e==null?Ze.getState(n)?.undoManager?.canUndo():ja(n),Yd=(n,e)=>e==null?Ze.getState(n)?.undoManager?.canRedo():lo(n),zb=new Set(["paragraph"]),$b=(n,e)=>!(n instanceof v)||!(n.content instanceof _e)||!(n.content.type instanceof ot||n.content.type instanceof Y&&e.has(n.content.type.nodeName))||n.content.type._length===0,Gd=({protectedNodes:n=zb,trackedOrigins:e=[],undoManager:t=null}={})=>new le({key:Ze,state:{init:(r,i)=>{let s=V.getState(i),o=t||new zn(s.type,{trackedOrigins:new Set([V].concat(e)),deleteFilter:l=>$b(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=V.getState(o).binding,a=i.undoManager,c=a.undoStack.length>0,f=a.redoStack.length>0;return l?{undoManager:a,prevSel:mi(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=V.getState(r.state),s=Ze.getState(r.state).undoManager;return s.on("stack-item-added",({stackItem:o})=>{let l=i.binding;l&&o.meta.set(l,Ze.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 Xd({post:n,mergeUpdates:e,onStatus:t,debounceMs:r=2e3,setTimeoutFn:i=setTimeout}){let s=[],o=null,l=null,a="ok";function c(p){a==="failed"&&p!=="failed"||(a=p,t&&t(a))}function f(){l||(l=i(u,r))}async function u(){if(l=null,!s.length)return;let p=e(s);s=[],o=p;let m;try{m=await n(p)}catch{o=null,s.unshift(p),c("retrying"),f();return}if(o=null,m.ok){c("ok");return}if(m.status>=400&&m.status<500){c("failed");return}s.unshift(p),c("retrying"),f()}function h(p){s.push(p),!l&&(l=i(u,r))}function d(){let p=[];return o&&p.push(o),s.length&&p.push(e(s)),p.length?p.length===1?p[0]:e(p):null}return{enqueue:h,flush:u,pendingBytes:d,get status(){return a}}}function Zd({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 Qd(n){return{...n,parseDOM:[{tag:"br.Apple-interchange-newline",ignore:!0},...n.parseDOM||[]]}}function ep(n){let e=n.nodes.paragraph,t=n.nodes.hard_break;return r=>{let i=tp(r.content,e,t);return i===r.content?r:new b(i,r.openStart,r.openEnd)}}function tp(n,e,t){let r=[],i=!1;return n.forEach(s=>{if(s.type===e&&s.childCount>0&&qb(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=tp(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 qb(n,e){let t=!0;return n.forEach(r=>{r.type!==e&&(t=!1)}),t}function yi(n,e,t){n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Me(n,e,t){n[e]!==t&&(n[e]=t)}function np(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 Ha={center:"docs-align-center",right:"docs-align-right"},rp=["left","center","right"];function ao(n){return Object.prototype.hasOwnProperty.call(Ha,n)?Ha[n]:null}function Wb(n){for(let[e,t]of Object.entries(Ha))if(n.includes(t))return e;return null}function ip(n){return{...n,attrs:{...n.attrs||{},align:{default:null}},parseDOM:[{tag:"p",getAttrs:e=>({align:Wb(Array.from(e.classList||[]))})}],toDOM:e=>{let t=ao(e.attrs.align);return t?["p",{class:t},0]:["p",0]}}}function sp(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 op(n){let e=n.selection.$from.parent,t=e.attrs&&e.attrs.align;return ao(t)?t:"left"}var co={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 jb={regular:{weight:400,style:"normal"},bold:{weight:700,style:"normal"},italic:{weight:400,style:"italic"},boldItalic:{weight:700,style:"italic"}},et=co.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=>jb[t])})),Ka=new Map(et.map(n=>[n.key,n])),Ya=et.map(n=>n.key),Ae=co.default,pn=co.code,fo=Ya.map(n=>"font_"+n).reverse();function lp(n){if(Ka.has(n))return n===Ae?null:"font_"+n}function ap(n){for(let e of fo)if(n.includes(e))return e.slice(5);return Ae}function uo(n){let e=String(n||"").split(",").map(t=>t.trim().replace(/^["']|["']$/g,"").toLowerCase()).filter(Boolean);for(let t of e){let r=et.find(i=>i.cssName.toLowerCase()===t)||et.find(i=>i.docx.toLowerCase()===t)||et.find(i=>i.name.toLowerCase()===t)||et.find(i=>i.fallback.some(s=>s.toLowerCase()===t));if(r)return r.key}return null}function Hb(){if(!Ka.has(Ae))throw new Error(`fonts: the default ${Ae} is not a family`);if(!Ka.has(pn))throw new Error(`fonts: the code face ${pn} is not a family`);if(Ya[0]!==Ae)throw new Error(`fonts: the toolbar lists ${Ya[0]} first but the default is ${Ae}`);for(let n of et)if(!n.faces.some(e=>e.weight===400&&e.style==="normal"))throw new Error(`fonts: ${n.key} has no regular`)}Hb();var mt=[12,8,9,10,11,14,18,24,36,48,72],It=12,_t=[...mt.filter(n=>n!==It).map(n=>"size_"+n),"size_sm","size_lg","size_xl"],ho={size_sm:10,size_lg:14,size_xl:18};function cp(n){let e=Number(n);if(mt.includes(e))return e===It?null:"size_"+e}function fp(n){for(let e of _t)if(n.includes(e))return e in ho?ho[e]:Number(e.slice(5));return It}function Kb(){if(!mt.includes(It))throw new Error(`sizes: the default ${It} is not one of [${mt}]`);if(mt[0]!==It)throw new Error(`sizes: the control lists ${mt[0]} first but the default is ${It} \u2014 with no JavaScript the control would name a size the text is not set in`);for(let[t,r]of Object.entries(ho)){if(!mt.includes(r))throw new Error(`sizes: the legacy mark ${t} maps to ${r}pt, which is not on the ladder [${mt}]`);if(!_t.includes(t))throw new Error(`sizes: the legacy mark ${t} is not in the group the toolbar clears`)}let n=mt.filter(t=>t!==It).map(t=>"size_"+t),e=_t.filter(t=>!(t in ho));if(n.join()!==e.join())throw new Error(`sizes: the marks [${e}] do not match the offered sizes [${n}]`)}Kb();var Xa={align_left:null,align_center:"center",align_right:"right"};function Yb(){let n=Object.keys(Xa);for(let r of n){let i=Xa[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&&!ao(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=[...rp].sort();if(e.join()!==t.join())throw new Error(`toolbar: alignment commands [${e}] do not match align.mjs's [${t}]`)}Yb();function Ga(n){let e=n.previousElementSibling;return!e||!e.hasAttribute("rst-combo")?null:e.querySelector("input")}function Gb(n,e){if(!e)return;let t=n.getAttribute("aria-label");t&&yi(e,"aria-label",t)}var po=!1;function Xb(n,e,t){if(!e||document.activeElement===e)return;if(t&&typeof n.dispatchEvent=="function"){po=!0;try{n.dispatchEvent(new Event("change"))}finally{po=!1}return}let r=n.options[n.selectedIndex],i=r&&r.dataset||{},s=r?i.rstShort||i.rstName||r.text:"";Me(e,"value",s)}function gp({root:n,schema:e,getView:t,onSync:r,fonts:i=null,wrapCommand:s=l=>l,onFontUnavailable:o=null}){if(!n)return{plugin:null,commands:up(e,s),focusStop:()=>!1};let l=Array.from(n.querySelectorAll("[data-docs-command]")),a=Array.from(n.querySelectorAll("[data-docs-select]")),c=up(e,s);for(let p of l)p.addEventListener("mousedown",m=>m.preventDefault()),p.addEventListener("click",()=>{let m=c[p.getAttribute("data-docs-command")],g=t();!g||!m||(m(g.state,g.dispatch,g),g.focus())});for(let p of a)p.addEventListener("mousedown",m=>m.stopPropagation()),p.addEventListener("change",()=>{if(po)return;let m=t();m&&m.focus()}),p.addEventListener("change",()=>{if(po)return;let m=t();if(!m)return;let g=p.getAttribute("data-docs-select"),y=p.value;if(g==="block"&&xi(e,y)(m.state,m.dispatch,m),g==="font"){let k=lp(y);k!==void 0&&hp(e,fo,k)(m.state,m.dispatch)}if(g==="size"){let k=cp(y);k!==void 0&&hp(e,_t,k)(m.state,m.dispatch)}m.focus()});function f(p){let m=p.state;for(let g of l){let y=g.getAttribute("data-docs-command"),k=c[y];if(!k)continue;let C=k(m,null,p);Me(g,"disabled",!C);let I=pp(m,e,y);yi(g,"aria-pressed",I?"true":"false")}for(let g of a){let y=g.getAttribute("data-docs-select")==="font"&&i&&i.previews==="pending";Me(g,"disabled",y);let k=Ga(g);k&&Me(k,"disabled",y),Gb(g,k);let C=g.getAttribute("data-docs-select"),I=g.value;C==="block"&&Me(g,"value",mp(m)),C==="font"&&Me(g,"value",ew(m,e)),C==="size"&&Me(g,"value",String(fp(tw(m,e,_t)))),Xb(g,Ga(g),g.value!==I)}r&&r(p)}let u=np(n,[...l,...a.map(p=>Ga(p)||p)]),h=new le({view:p=>(f(p),u.ensureReachable(),{update:m=>{f(m),u.ensureReachable()}})}),d=(p,m)=>m.startsWith("block_")?mp(p)===m.slice(6):pp(p,e,m);return{plugin:h,commands:c,focusStop:u.focusStop,isPressed:d}}function up(n,e=t=>t){let t=n.marks,r=n.nodes;return{undo:Kd,redo:Yd,strong:e(hn(t.strong)),em:e(hn(t.em)),code:e(hn(t.code),!0),bullet_list:dp(r.bullet_list,r.list_item),ordered_list:dp(r.ordered_list,r.list_item),blockquote:Qb(r.blockquote),select_all:Ba,clear_formatting:Zb,block_paragraph:xi(n,"paragraph"),"block_heading-1":xi(n,"heading-1"),"block_heading-2":xi(n,"heading-2"),"block_heading-3":xi(n,"heading-3"),indent:Ge(Xs(r.list_item),sr(1)),outdent:Ge(ui(r.list_item),sr(-1)),...Object.fromEntries(Object.entries(Xa).map(([i,s])=>[i,sp(s)]))}}function Zb(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 xi(n,e){if(e==="paragraph")return La(n.nodes.paragraph);let t=Number(e.split("-")[1]);return Number.isInteger(t)?La(n.nodes.heading,{level:t}):()=>!1}function hp(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 dp(n,e){let t=pd(n),r=ui(e);return(i,s,o)=>bi(i,n)?r(i,s,o):t(i,s,o)}function Qb(n){let e=Ed(n);return(t,r,i)=>bi(t,n)?Sd(t,r,i):e(t,r,i)}function bi(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 pp(n,e,t){if(t.startsWith("align_"))return op(n)===t.slice(6);if(t==="bullet_list")return bi(n,e.nodes.bullet_list);if(t==="ordered_list")return bi(n,e.nodes.ordered_list);if(t==="blockquote")return bi(n,e.nodes.blockquote);let r=e.marks[t];return r?Za(n,r):!1}function Za(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 mp(n){let e=n.selection.$from.parent;return e.type.name==="heading"?"heading-"+e.attrs.level:"paragraph"}function ew(n,e){let t=fo.filter(r=>{let i=e.marks[r];return i&&Za(n,i)});return ap(t)}function tw(n,e,t){let r=[];for(let i of t){let s=e.marks[i];s&&Za(n,s)&&r.push(i)}return r}var nw={print:()=>(window.print(),!0)};function tc(n){return n.querySelector("[estilo-menubar-menu][open]")}function nc(n){return Array.from(n.querySelectorAll("[estilo-menubar-title]"))}function Qa(n){return Array.from(n.querySelectorAll("[estilo-menu-item]")).filter(e=>!e.disabled)}function ec(n,e){for(let t of nc(n))Me(t,"tabIndex",t===e?0:-1);e.focus()}function mo(n){let e=tc(n);e&&(e.open=!1)}function yp(n,{getView:e,commands:t,extraCommands:r,isPressed:i}){if(!n)return null;let s=nc(n);if(!s.length)return null;for(let[c,f]of s.entries())Me(f,"tabIndex",c===0?0:-1);let o={...nw,...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&&ec(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")){mo(n);return}c.preventDefault(),l(f.getAttribute("data-docs-command"),f),mo(n)}}),n.addEventListener("keydown",c=>{let f=c.target.closest("[estilo-menubar-title]"),u=c.target.closest("[estilo-menu-item]"),h=tc(n);switch(c.key){case"ArrowRight":case"ArrowLeft":{let d=f||h&&h.querySelector("[estilo-menubar-title]");if(!d)return;c.preventDefault();let p=nc(n),m=p[(p.indexOf(d)+(c.key==="ArrowRight"?1:-1)+p.length)%p.length],g=!!h;mo(n),g&&(m.closest("[estilo-menubar-menu]").open=!0),ec(n,m);return}case"ArrowDown":case"ArrowUp":{if(f){c.preventDefault();let d=f.closest("[estilo-menubar-menu]");d.open=!0;let p=Qa(d);p.length&&p[c.key==="ArrowDown"?0:p.length-1].focus();return}if(u&&h){c.preventDefault();let d=Qa(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=Qa(h);d.length&&d[c.key==="Home"?0:d.length-1].focus();return}case"Tab":mo(n)}}),n.addEventListener("pointerover",c=>{if(c.pointerType&&c.pointerType!=="mouse")return;let f=c.target.closest&&c.target.closest("[estilo-menubar-title]"),u=tc(n);if(!f||!u||u.contains(f))return;let h=f.closest("[estilo-menubar-menu]");h&&(h.open=!0,ec(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),yi(f,"aria-pressed",h?"true":"false")),o[u]){Me(f,"disabled",!1);continue}let d=t[u],p=!!(c&&d&&(h||d(c.state,null,c)));Me(f,"disabled",!p)}}return{sync:a}}function rc(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 xp({initialSeq:n=0,openStream:e,fetchSince:t,onUpdates:r,onError:i=()=>{},setTimeoutFn:s=setTimeout,clearTimeoutFn:o=clearTimeout,idleMs:l=12e4,hiddenMs:a=3e4}){let c=n,f=null,u=null,h=!1,d=!1,p=!1;function m(I){u!==null&&o(u),u=s(()=>{u=null,y()},I)}function g(){m(l)}function y(){u!==null&&(o(u),u=null),f&&(f.close(),f=null)}function k(){h||f||(f=e(I=>{g(),I>c&&C()},I=>{y(),i(I)}),g())}async function C(){if(d){p=!0;return}d=!0;try{let I=c,U=await t(I);if(h)return;try{U&&U.bytes&&U.bytes.length&&await r(U.bytes)}catch{if(U=await t(I,{raw:!0}),h)return;U&&U.bytes&&U.bytes.length&&await r(U.bytes)}U&&typeof U.seq=="number"&&U.seq>c&&(c=U.seq)}catch(I){i(I)}finally{d=!1,p&&!h&&(p=!1,C())}}return{start(){h=!1,k()},stop(){h=!0,y()},noteOwnSeq(I){typeof I!="number"||!Number.isFinite(I)||I===c+1&&(c=I)},noteActivity(){h||(f?g():k())},noteHidden(){h||!f||m(a)},get cursor(){return c},get streaming(){return f!==null}}}var wp=3e3;var bp=new Map([["code",pn]]);function Sp(n){bp.clear();for(let[e,t]of n)bp.set(e,t)}function kp(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 Cp(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 rw=["p",0],iw=["blockquote",0],sw=["hr"],ow=["pre",["code",0]],lw=["br"],aw={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return rw}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM(){return iw}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return sw}},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 ow}},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 lw}}},cw=["em",0],fw=["strong",0],uw=["code",0],hw={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 cw}},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 fw}},code:{code:!0,parseDOM:[{tag:"code"}],toDOM(){return uw}}},or=new Hn({nodes:aw,marks:hw});function Ep(n,e){return{group:e,excludes:e,parseDOM:[{tag:"span."+n}],toDOM:()=>["span",{class:n},0]}}var dw=_t.reduce((n,e)=>n.addToStart(e,Ep("docs-"+e.replace("_","-"),"fontSize")),or.spec.marks),pw=[...et].reverse().reduce((n,e)=>{let t=Ep("docs-font-"+e.key,"fontFamily");return e.key!==Ae?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)===Ae||uo(r)===null?null:!1,clearMark:r=>r.type.spec.group==="fontFamily"}],n.addToStart("font_"+e.key,t)},dw),mw=dd(or.spec.nodes.update("paragraph",Fa(ip(or.spec.nodes.get("paragraph")),"p")).update("heading",Fa(or.spec.nodes.get("heading"),"h1")).update("hard_break",Qd(or.spec.nodes.get("hard_break"))),"paragraph block*","block"),ge=new Hn({nodes:mw,marks:pw});function lr(n){let e=n.name||n;if(typeof e=="string"&&e.startsWith("font_"))return e.slice(5);let t=typeof n=="string"?ge.marks[n]:n;return t&&t.spec.code?pn:null}function wi(n){let e=typeof n=="string"?ge.nodes[n]:n;return e&&e.spec.code?pn:null}function Tp(n,e=new Set([Ae])){return n.descendants(t=>{let r=wi(t.type);r&&e.add(r);for(let i of t.marks){let s=lr(i.type);s&&e.add(s)}}),e}Sp([...Object.values(ge.nodes).filter(n=>wi(n)).map(n=>[n.name,wi(n)]),...Object.values(ge.marks).filter(n=>!n.name.startsWith("font_")&&lr(n)).map(n=>[n.name,lr(n)])]);function gw(n,e){return e&&e(n.tr.replaceSelectionWith(ge.nodes.hard_break.create()).scrollIntoView()),!0}var yw=250;function ic(n,e){if(!e.length)return;let t=An(e);for(;_i(t);)Lf(t,n,"server")}function Ap(){return globalThis.docsFonts||kp(document.documentElement)}function xw(){return document.documentElement.getAttribute("data-docs-layout")==="frozen"}function bw(n){let e=new Set([Ae]),t=r=>{if(r instanceof se){for(let i of r.toDelta())for(let s of Object.keys(i.attributes||{})){let o=lr(s);o&&e.add(o)}return}if(r instanceof Y){let i=wi(r.nodeName);i&&e.add(i)}for(let i of r.toArray())t(i)};return t(n),[...e]}function ww(n){let e=new Set,t=r=>{let i=lr(r.type);i&&e.add(i)};for(let r of n.steps)r.slice&&Tp(r.slice.content,e),r.mark&&t(r.mark);return n.storedMarksSet&&n.storedMarks&&n.storedMarks.forEach(t),e.delete(void 0),[...e]}function Mp(){return new Promise(n=>requestAnimationFrame(()=>n()))}async function Sw(n){let e=n.getAttribute("data-sqid"),t=Ap(),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=null,p=document.querySelector("[docs-canvas]"),m=p&&p.getAttribute("data-view")===dn?dn:di,g=p?p.getAttribute("data-page-label"):"",y=!1;t.fontsReady.then(()=>{document.documentElement.getAttribute("data-docs-fonts")!=="pending"&&document.documentElement.setAttribute("data-docs-layout","frozen"),y=!0});let k=()=>y&&!xw()?m:di;function C(w){m=w,document.documentElement.removeAttribute("data-docs-layout"),p&&p.setAttribute("data-view",w),Id(w);let S=u;S&&S.dispatch(S.state.tr)}let I=Ld(document.querySelector("[docs-wordcount]"),{getView:()=>u}),U=Ud(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")||""}))}),Ue=!1,A=[],q=()=>Ue?new Promise(w=>A.push(w)):Promise.resolve(),F=Cp(document.querySelector("[docs-fonts-status]")),Si=[document.querySelector("[docs-toolbar]"),document.querySelector("[estilo-menubar]")].filter(Boolean),oc=document.querySelector("[docs-page]"),lc=8e3,Op=new le({filterTransaction(w){if(w.getMeta(V))return!0;if(Ue)return!w.docChanged&&!w.storedMarksSet?!0:(F.say("refused"),!1);let S=ww(w),E=S.filter(P=>!t.ready(P));if(!E.length)return t.use(S),!0;if(u&&u.composing)return t.commitFallback(E),t.use(S),!0;let L=u;return ac(E,()=>L!==u||L.state.doc!==w.before?!1:(L.dispatch(w),!0)),!1}});async function ac(w,S){Ue=!0,fc(!0);let E=!1;try{E=await t.waitFor(w,wp)&&w.every(L=>t.loaded(L)||t.committed(L))}catch{E=!1}Ue=!1,fc(!1);try{E=E&&S()!==!1}catch(L){console.error("fonts:",L),E=!1}finally{E?F.clear():F.say("unavailable",lc);let L=A;A=[];for(let P of L)P()}}let Dp=new Set(["Backspace"," ","Spacebar","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"]),Np=w=>{if(!Dp.has(w.key))return;let S=w.target;(!S||S===document.body||S===document.documentElement||S.closest&&S.closest("[inert]"))&&w.preventDefault()},Ip=w=>{w.preventDefault(),w.returnValue=""},cc=!1;function fc(w){let S=w?"addEventListener":"removeEventListener";window[S]("keydown",Np),window[S]("beforeunload",Ip);let E=u,L=E&&E.dom;w&&(cc=!!L&&(L.contains(document.activeElement)||Si.some(P=>P.contains(document.activeElement))));for(let P of[...Si,L])P&&(P.inert=w);oc&&oc.setAttribute("aria-busy",w?"true":"false"),w?F.say("loading"):cc&&E&&(!document.activeElement||document.activeElement===document.body)&&E.focus()}let go=w=>(S,E,L)=>{if(!E)return w(S,E,L);if(Ue)return F.say("refused"),!0;let P=t.inUse.filter(Ve=>!t.ready(Ve));return P.length?(ac(P,()=>{let Ve=u;return Ve?(w(Ve.state,Ve.dispatch,Ve),!0):!1}),!0):w(S,E,L)},_p=()=>F.say("unavailable",lc),mn=gp({root:document.querySelector("[docs-toolbar]"),schema:ge,fonts:t,onFontUnavailable:_p,getView:()=>u,onSync:w=>{d&&d.sync(w)}});d=yp(document.querySelector("[estilo-menubar]"),{getView:()=>u,commands:mn.commands,isPressed:(w,S)=>w==="view_paged"?m===dn:w==="view_infinite"?m===di:!!(S&&mn.isPressed&&mn.isPressed(S.state,w)),extraCommands:{view_paged:()=>(C(dn),!0),view_infinite:()=>(C(di),!0),...I?{word_count:I}:{},...U?{shortcuts:U}:{}}});function yo(w){a(c?"failed":w)}function Rp(w){return Xd({post:async S=>{let E=await fetch(r,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/octet-stream"},body:S}),L=w();if(E.ok&&L){let P=Number(E.headers.get("Docs-Seq"));Number.isFinite(P)&&L.noteOwnSeq(P)}return E},mergeUpdates:$f,debounceMs:yw,onStatus:S=>{S==="failed"&&(c=!0,xo.reportDivergence()),yo(S)}})}function vp(w){let S=u;if(!S||w.button!==0||S.dom.contains(w.target))return;let E=S.dom.getBoundingClientRect(),L=S.posAtCoords({left:Math.min(Math.max(w.clientX,E.left+1),E.right-1),top:Math.min(Math.max(w.clientY,E.top+1),E.bottom-1)}),P=L?L.pos:S.state.doc.content.size,Ve=O.near(S.state.doc.resolve(P));w.preventDefault(),S.dispatch(S.state.tr.setSelection(Ve).scrollIntoView()),S.focus()}function Bp(w,S){let E=[Wa(S),Gd(),Nd(ge),_d({getMode:k,pageLabel:g}),Op,_a({"Mod-z":go(ja),"Mod-y":go(lo),"Mod-Shift-z":go(lo),"Mod-b":hn(ge.marks.strong),"Mod-i":hn(ge.marks.em),"Shift-Enter":gw,Tab:Ge(Xs(ge.nodes.list_item),sr(1)),"Shift-Tab":Ge(ui(ge.nodes.list_item),sr(-1)),Backspace:Od,Escape:()=>mn.focusStop(),Enter:Ge(md(ge.nodes.list_item),Ua.Enter)}),_a(Ua)];return mn.plugin&&E.push(mn.plugin),new oi({mount:w},{state:Vs.create({schema:ge,plugins:E}),transformPasted:ep(ge)})}async function uc(w){let S=rc(r,{raw:w}),E=await fetch(S,{credentials:"same-origin"});if(!E.ok)throw new Error(`load ${S}: ${E.status}`);return{log:new Uint8Array(await E.arrayBuffer()),startSeq:Number(E.headers.get("Docs-Seq"))}}async function hc(){let{log:w,startSeq:S}=await uc(!1),E=new Ne;try{ic(E,w)}catch{({log:w,startSeq:S}=await uc(!0)),E=new Ne,ic(E,w)}let L=E.getXmlFragment("prosemirror");await t.prepare(bw(L));let P=null,Ve=Rp(()=>P);E.on("update",(Fe,ar)=>{ar!=="server"&&(xo.diverged||Ve.enqueue(Fe))}),u&&u.destroy(),f=Ve,u=Bp(n,L),h&&h.stop(),P=xp({initialSeq:Number.isFinite(S)?S:0,openStream:(Fe,ar)=>{let gn=new EventSource(i,{withCredentials:!0});return gn.addEventListener("update",gt=>Fe(Number(gt.data))),gn.addEventListener("error",gt=>ar(gt)),{close:()=>gn.close()}},fetchSince:async(Fe,{raw:ar}={})=>{let gn=rc(r,{since:Fe,raw:ar}),gt=await fetch(gn,{credentials:"same-origin"});if(!gt.ok)throw new Error(`fetch ${gn}: ${gt.status}`);return{bytes:new Uint8Array(await gt.arrayBuffer()),seq:Number(gt.headers.get("Docs-Seq"))}},onUpdates:async Fe=>{await t.prepareRemote(Fe),await q(),!(xo.diverged||h!==P)&&ic(E,Fe)},onError:Fe=>{console.error("live updates:",Fe)}}),h=P,h.start(),typeof document<"u"&&document.hidden&&h.noteHidden()}let xo=Zd({attemptResync:hc,onDiverged:()=>yo("failed"),onRecovered:()=>yo(c?"failed":"ok")});await hc(),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 Mp(),await Mp(),t.settled(),addEventListener("visibilitychange",()=>{document.hidden?h&&h.noteHidden():h&&h.noteActivity()});for(let w of["pointermove","scroll","keydown","focus"])addEventListener(w,()=>h&&h.noteActivity(),{passive:!0,capture:!0});let dc=n.closest("[docs-page]");dc&&dc.addEventListener("mousedown",vp);let bo=!1,pc=()=>{bo=!0,setTimeout(()=>{bo=!1},0)};return document.addEventListener("mousedown",pc,!0),document.addEventListener("touchstart",pc,!0),n.addEventListener("focus",()=>{if(bo)return;let w=u;w&&w.dispatch(w.state.tr.scrollIntoView())}),addEventListener("beforeunload",()=>{let w=f&&f.pendingBytes();if(!w)return;let S=new Blob([w],{type:"application/octet-stream"});navigator.sendBeacon(r,S)||(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:w}).catch(()=>{}))}),u}var sc=document.querySelector("[docs-editor]");sc&&Sw(sc).catch(n=>{Ap().settled(),sc.setAttribute("data-editor-failed","1"),console.error(n)});export{Sw as mountEditor};
+`).scrollIntoView()),!0)};function va(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 Hx=(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=va(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(O.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Kx=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof de||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=va(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(R.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Yx=(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(Et(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&Qt(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function Gx(n){return(e,t)=>{if(e.selection instanceof T&&e.selection.node.isBlock){let{$from:d}=e.selection;return!d.parentOffset||!Et(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 R||e.selection instanceof de)&&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=va(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=Et(r.doc,u,o.length,o);if(h||(o[0]=a?{type:a}:null,h=Et(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 Xx=Gx();var Ba=(n,e)=>(e&&e(n.tr.setSelection(new de(n.doc))),!0);function Zx(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||en(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function kd(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&Zx(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 Q(e.pos-1,d,e.pos,d,new b(p,1,0),o.length,!0)),g=m.doc.resolve(d+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&en(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let f=s.type.spec.isolating||r>0&&a?null:O.findFrom(e,1),u=f&&f.$from.blockRange(f.$to),h=u&&Qt(u);if(h!=null&&h>=e.depth)return t&&t(n.tr.lift(u,h).scrollIntoView()),!0;if(c&&ir(s,"start",!0)&&ir(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 C=p.length-1;C>=0;C--)y=x.from(p[C].copy(y));let k=n.tr.step(new Q(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new b(y,p.length,0),0,!0));t(k.scrollIntoView())}return!0}}return!1}function Cd(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(R.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}var Qx=Cd(-1),eb=Cd(1);function Ed(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&Gn(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function La(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 tb(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 nb(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 Zn(r,r.doc.resolve(o+1))),r=r.doc.resolve(o+1+s.content.size),!1}),r.pos<i.pos&&e.push(new Zn(r,i))}return e}function hn(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||!tb(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=nb(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,k=p.nodeAfter,C=m.nodeBefore,I=s&&k&&k.isText?/^\s*/.exec(k.text)[0].length:0,U=s&&C&&C.isText?/\s*$/.exec(C.text)[0].length:0;g+I<y&&(g+=I,y-=U),h.addMark(g,y,n.create(e))}}l(h.scrollIntoView())}return!0}}function Ge(...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 Ra=Ge(xd,zx,$x),yd=Ge(xd,Wx,Jx),pt={Enter:Ge(jx,Kx,Yx,Xx),"Mod-Enter":Hx,Backspace:Ra,"Mod-Backspace":Ra,"Shift-Backspace":Ra,Delete:yd,"Mod-Delete":yd,"Mod-a":Ba},Td={"Ctrl-h":pt.Backspace,"Alt-Backspace":pt["Mod-Backspace"],"Ctrl-d":pt.Delete,"Ctrl-Alt-Backspace":pt["Mod-Delete"],"Alt-Delete":pt["Mod-Delete"],"Alt-d":pt["Mod-Delete"],"Ctrl-a":Qx,"Ctrl-e":eb};for(let n in pt)Td[n]=pt[n];var rb=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,Ua=rb?Td:pt;function ib(n){let e=Va(n);return e?"docs-indent-"+e:null}function Va(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 sb(n){for(let e of n){if(!e.startsWith("docs-indent-"))continue;let t=Va(e.slice(12));if(t)return t}return null}function Fa(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:sb(Array.from(i.classList||[]))}}})),toDOM:r=>{let i=n.toDOM?n.toDOM(r):[e,0],s=ib(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 sr(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=Va(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 Xe=class{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?ob(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}};function ob(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 lb=500;function Ad({rules:n}){let e=new le({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 Md(t,r,i,s,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&Md(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function Md(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-lb),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 Od=(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},GS=new Xe(/--$/,"\u2014",{inCodeMark:!1}),XS=new Xe(/\.\.\.$/,"\u2026",{inCodeMark:!1}),ZS=new Xe(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C",{inCodeMark:!1}),QS=new Xe(/"$/,"\u201D",{inCodeMark:!1}),ek=new Xe(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018",{inCodeMark:!1}),tk=new Xe(/'$/,"\u2019",{inCodeMark:!1});function eo(n,e,t=null,r){return new Xe(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&&Gn(u,e,a);if(!h)return null;c.wrap(u,h);let d=c.doc.resolve(o-1).nodeBefore;return d&&d.type==e&&en(c.doc,o-1)&&(!r||r(s,d))&&c.join(o-1),c})}function Dd(n,e,t=null){return new Xe(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 ab=/^\s*([-+*])\s$/,cb=/^(\d+)\.\s$/,fb=/^\s*>\s$/,ub=/^(#{1,3})\s$/;function Nd(n){let e=[],{bullet_list:t,ordered_list:r,blockquote:i,heading:s}=n.nodes;return t&&e.push(eo(ab,t)),r&&e.push(eo(cb,r)),i&&e.push(eo(fb,i)),s&&e.push(Dd(ub,s,o=>({level:o[1].length}))),Ad({rules:e})}var hi=new Tt("docs-pages"),hb=864,dn="paged",di="infinite",db="docs-view";function Id(n){document.cookie=`${db}=${n}; Path=/; Max-Age=31536000; SameSite=Lax`}function pb(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>hb&&(e.push(s),r=l.top)}}),e}function _d({getMode:n,pageLabel:e}){return new le({key:hi,state:{init:()=>({positions:[],deco:ce.empty}),apply(t,r,i,s){let o=t.getMeta(hi);if(!o)return{positions:r.positions,deco:r.deco.map(t.mapping,t.doc)};let l=o.positions.map((a,c)=>Ye.widget(a,()=>mb(c+2,e),{side:-1,ignoreSelection:!0}));return{positions:o.positions,deco:ce.create(s.doc,l)}}},props:{decorations(t){return n()!==dn?ce.empty:hi.getState(t).deco}},view(t){let r=0,i="",s=()=>{if(r=0,n()!==dn){i!==""&&(i="",t.dispatch(t.state.tr.setMeta(hi,{positions:[]})));return}let a=pb(t),c=a.join(",");c!==i&&(i=c,t.dispatch(t.state.tr.setMeta(hi,{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 mb(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 Rd=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null;function vd(n){if(!n)return 0;if(Rd){let t=0;for(let r of Rd.segment(n))r.isWordLike&&t++;return t}let e=n.trim().split(/\s+/);return e.length===1&&e[0]===""?0:e.length}function Bd(n){let e=[];return n.descendants(t=>{t.isText?e.push(t.text):t.isBlock&&e.length&&e.push(" ")}),e.join("")}function gb(n){let e=Bd(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:Bd(n.doc.cut(t,r));return{words:vd(e),characters:e.length,charactersNoSpaces:e.replace(/\s/g,"").length,paragraphs:s,selection:o===null?null:{words:vd(o),characters:o.length}}}function Ld(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=gb(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 yb(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 Ud(n,{menubar:e,extraRows:t}){if(!n||typeof n.showModal!="function")return null;let r=n.querySelector("[docs-shortcuts-body]");return r?()=>{let i=[...yb(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}var Vd=()=>{let n=!0;return(e,t)=>{if(n){n=!1;try{e()}finally{n=!0}}else t!==void 0&&t()}};var xb=/[\uD800-\uDBFF]/,bb=/[\uDC00-\uDFFF]/,wb=(n,e)=>{let t=0,r=0;for(;t<n.length&&t<e.length&&n[t]===e[t];)t++;for(t>0&&xb.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&&bb.test(n[n.length-r])&&r--,{index:t,remove:n.length-t-r,insert:e.slice(t,e.length-r)}},Fd=wb;var V=new Tt("y-sync"),Ze=new Tt("y-undo"),dk=new Tt("yjs-cursor");var Qe=(n,e)=>n>>>e|n<<32-e,Sb=n=>Qe(n,2)^Qe(n,13)^Qe(n,22),kb=n=>Qe(n,6)^Qe(n,11)^Qe(n,25),Cb=n=>Qe(n,7)^Qe(n,18)^n>>>3,Eb=n=>Qe(n,17)^Qe(n,19)^n>>>10,Tb=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]),Mb=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Pa=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(Mb),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let u=16;u<64;u++)t[u]=Eb(t[u-2])+t[u-7]+Cb(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+kb(l)+(l&a^~l&c)+Tb[u]+t[u]>>>0,d=Sb(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}},Pd=n=>new Pa().digest(n);var Ob=n=>{for(let t=6;t<n.length;t++)n[t%6]=n[t%6]^n[t];return n.slice(0,6)},zd=n=>jc(Ob(Pd(Kc(n))));var pi=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&e.sv.get(n.id.client)>n.id.clock&&!jt(e.ds,n.id),Nb=[{light:"#ecd44433",dark:"#ecd444"}],Ib=(n,e,t)=>{if(!n.has(t)){if(n.size<e.length){let r=Pe();n.forEach(i=>r.add(i)),e=e.filter(i=>!r.has(i))}n.set(t,_c(e))}return n.get(t)},Wa=(n,{colors:e=Nb,colorMapping:t=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:s}={})=>{let o=!1,l=new ro(n,s),a=new le({props:{editable:c=>{let f=V.getState(c);return f.snapshot==null&&f.prevSnapshot==null}},key:V,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(V);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)&&Ho(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=Ze.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)},V)})}},destroy:()=>{l.destroy()}})});return a},_b=(n,e,t)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")n.setSelection(new de(n.doc));else if(e.type==="node"){let r=no(t.doc,t.type,e.anchor,t.mapping);n.setSelection(T.create(n.doc,r))}else{let r=no(t.doc,t.type,e.anchor,t.mapping),i=no(t.doc,t.type,e.head,t.mapping);if(r!==null&&i!==null){let s=R.between(n.doc.resolve(r),n.doc.resolve(i));n.setSelection(s)}}},mi=(n,e)=>({type:e.selection.jsonID,anchor:qa(e.selection.anchor,n.type,n.mapping),head:qa(e.selection.head,n.type,n.mapping)}),ro=class{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=Vd(),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=mi(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()?(Cr&&this._domSelectionInView===null&&(Ho(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=it.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=xs(ms(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(V,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{let e=this.type.toArray().map(r=>to(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new b(x.from(e),0,0));t.setMeta(V,{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=>to(i,this.prosemirrorView.state.schema,this)).filter(i=>i!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new b(x.from(t),0,0));if(e){let i=rt(ze(e.anchor,0),r.doc.content.size),s=rt(ze(e.head,0),r.doc.content.size);r.setSelection(R.create(r.doc,i,s))}this.prosemirrorView.dispatch(r.setMeta(V,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,r){let i=this.doc,s=this.type;if(e||(e=bs(this.doc)),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&H(),i=new Ne({gc:!1}),gs(i,t),t=bs(i),gs(i,e),e=bs(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=Ie(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=>{st(o,u,h=>{})});let a=(u,h)=>{let d=u==="added"?l.getUserByClientId(h.client):l.getUserByDeletedId(h);return{user:d,type:u,color:Ib(r.colorMapping,r.colors,d)}},c=Al(s,new Pn(t.ds,e.sv)).map(u=>!u._item.deleted||pi(u._item,e)||pi(u._item,t)?to(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 b(x.from(c),0,0));this.prosemirrorView.dispatch(f.setMeta(V,{isChangeOrigin:!0}))},V)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let r=V.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);st(t,t.deleteSet,l=>{if(l.constructor===v){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=>Wd(l,this.prosemirrorView.state.schema,this)).filter(l=>l!==null),o=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new b(x.from(s),0,0));_b(o,this.beforeTransactionSelection,this),o=o.setMeta(V,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof zn}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&o.scrollIntoView(),this.prosemirrorView.dispatch(o)})}_prosemirrorChanged(e){this.doc.transact(()=>{so(this.doc,this.type,e,this),this.beforeTransactionSelection=mi(this,this.prosemirrorView.state)},V)}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))}},Wd=(n,e,t,r,i,s)=>{let o=t.mapping.get(n);if(o===void 0){if(n instanceof Y)return to(n,e,t,r,i,s);throw he()}return o},to=(n,e,t,r,i,s)=>{let o=[],l=a=>{if(a instanceof Y){let c=Wd(a,e,t,r,i,s);c!==null&&o.push(c)}else{let c=a._item.right?.content?.type;c instanceof ot&&!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=Rb(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):Al(n,new Pn(i.ds,r.sv)).forEach(l);try{let a=n.getAttributes(r);r!==void 0&&(pi(n._item,r)?pi(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)},V),t.mapping.delete(n),null}},Rb=(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,Fb(c.attributes,e)))}}catch{return n.doc.transact(c=>{n._item.delete(c)},V),null}return o},vb=(n,e)=>{let t=new se,r=n.map(i=>({insert:i.text,attributes:Hd(i.marks,e)}));return t.applyDelta(r),e.mapping.set(t,n),t},Bb=(n,e)=>{let t=new Y(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,oo(n).map(r=>za(r,e))),e.mapping.set(t,n),t},za=(n,e)=>n instanceof Array?vb(n,e):Bb(n,e),$d=n=>typeof n=="object"&&n!==null,Ja=(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||$d(o)&&$d(l)&&Ja(o,l)}return r},oo=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},Jd=(n,e)=>{let t=n.toDelta();return t.length===e.length&&t.every((r,i)=>r.insert===e[i].text&&Io(r.attributes||{}).length===e[i].marks.length&&bt(r.attributes,(s,o)=>{let l=jd(o),a=e[i].marks;return Ja(s,a.find(c=>c.type.name===l)?.attrs)}))},gi=(n,e)=>{if(n instanceof Y&&!(e instanceof Array)&&$a(n,e)){let t=oo(e);return n._length===t.length&&Ja(n.getAttributes(),e.attrs)&&n.toArray().every((r,i)=>gi(r,t[i]))}return n instanceof se&&e instanceof Array&&Jd(n,e)},io=(n,e)=>n===e||n instanceof Array&&e instanceof Array&&n.length===e.length&&n.every((t,r)=>e[r]===t),qd=(n,e,t)=>{let r=n.toArray(),i=oo(e),s=i.length,o=r.length,l=rt(o,s),a=0,c=0,f=!1;for(;a<l;a++){let u=r[a],h=i[a];if(io(t.mapping.get(u),h))f=!0;else if(!gi(u,h))break}for(;a+c<l;c++){let u=r[o-c-1],h=i[s-c-1];if(io(t.mapping.get(u),h))f=!0;else if(!gi(u,h))break}return{equalityFactor:a+c,foundMappedChild:f}},Lb=n=>{let e="",t=n._start,r={};for(;t!==null;)t.deleted||(t.countable&&t.content instanceof $e?e+=t.content.str:t.content instanceof $&&(r[t.content.key]=null)),t=t.right;return{str:e,nAttrs:r}},Ub=(n,e,t)=>{t.mapping.set(n,e);let{nAttrs:r,str:i}=Lb(n),s=e.map(c=>({insert:c.text,attributes:Object.assign({},r,Hd(c.marks,t))})),{insert:o,remove:l,index:a}=Fd(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})))},Vb=/(.*)(--[a-zA-Z0-9+/=]{8})$/,jd=n=>Vb.exec(n)?.[1]??n,Fb=(n,e)=>{let t=[];for(let r in n)t.push(e.mark(jd(r),n[r]));return t},Hd=(n,e)=>{let t={};return n.forEach(r=>{if(r.type.name!=="ychange"){let i=Oe(e.isOMark,r.type,()=>!r.type.excludes(r.type));t[i?`${r.type.name}--${zd(r.toJSON())}`:r.type.name]=r.attrs}}),t},so=(n,e,t,r)=>{if(e instanceof Y&&e.nodeName!==t.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,t),e instanceof Y){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=oo(t),s=i.length,o=e.toArray(),l=o.length,a=rt(s,l),c=0,f=0;for(;c<a;c++){let u=o[c],h=i[c];if(!io(r.mapping.get(u),h))if(gi(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(!io(r.mapping.get(u),h))if(gi(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 se&&d instanceof Array)Jd(h,d)||Ub(h,d,r),c+=1;else{let g=h instanceof Y&&$a(h,d),y=p instanceof Y&&$a(p,m);if(g&&y){let k=qd(h,d,r),C=qd(p,m,r);k.foundMappedChild&&!C.foundMappedChild?y=!1:!k.foundMappedChild&&C.foundMappedChild||k.equalityFactor<C.equalityFactor?g=!1:y=!1}g?(so(n,h,d,r),c+=1):y?(so(n,p,m,r),f+=1):(r.mapping.delete(e.get(c)),e.delete(c,1),e.insert(c,[za(d,r)]),c+=1)}}let u=l-c-f;if(l===1&&s===0&&o[0]instanceof se?(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(za(i[d],r));e.insert(c,h)}},V)},$a=(n,e)=>!(e instanceof Array)&&n.nodeName===e.type.name;var qa=(n,e,t)=>{if(n===0)return ys(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 se){if(r._length>=n)return ys(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 qt(r._item===null?null:r._item.id,r._item===null?Wn(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 qt(r._item===null?null:r._item.id,r._item===null?Wn(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 H();if(n===0&&r.constructor!==se&&r!==e)return Pb(r._item.parent,r._item)}return ys(e,e._length,e.length===0?-1:0)},Pb=(n,e)=>{let t=null,r=null;return n._item===null?r=Wn(n):t=M(n._item.id.client,n._item.id.clock),new qt(t,r,e.id)},no=(n,e,t,r)=>{let i=Vf(t,n);if(i===null||i.type!==e&&!Fn(e,i.type._item))return null;let s=i.type,o=0;if(s.constructor===se)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 se?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 se?o+=c._length:o+=r.get(c).nodeSize),a=a.right}}s=l}return o-1};var ja=n=>Ze.getState(n)?.undoManager?.undo()!=null,lo=n=>Ze.getState(n)?.undoManager?.redo()!=null,Kd=(n,e)=>e==null?Ze.getState(n)?.undoManager?.canUndo():ja(n),Yd=(n,e)=>e==null?Ze.getState(n)?.undoManager?.canRedo():lo(n),zb=new Set(["paragraph"]),$b=(n,e)=>!(n instanceof v)||!(n.content instanceof _e)||!(n.content.type instanceof ot||n.content.type instanceof Y&&e.has(n.content.type.nodeName))||n.content.type._length===0,Gd=({protectedNodes:n=zb,trackedOrigins:e=[],undoManager:t=null}={})=>new le({key:Ze,state:{init:(r,i)=>{let s=V.getState(i),o=t||new zn(s.type,{trackedOrigins:new Set([V].concat(e)),deleteFilter:l=>$b(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=V.getState(o).binding,a=i.undoManager,c=a.undoStack.length>0,f=a.redoStack.length>0;return l?{undoManager:a,prevSel:mi(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=V.getState(r.state),s=Ze.getState(r.state).undoManager;return s.on("stack-item-added",({stackItem:o})=>{let l=i.binding;l&&o.meta.set(l,Ze.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 Xd({post:n,mergeUpdates:e,onStatus:t,debounceMs:r=2e3,setTimeoutFn:i=setTimeout}){let s=[],o=null,l=null,a="ok";function c(p){a==="failed"&&p!=="failed"||(a=p,t&&t(a))}function f(){l||(l=i(u,r))}async function u(){if(l=null,!s.length)return;let p=e(s);s=[],o=p;let m;try{m=await n(p)}catch{o=null,s.unshift(p),c("retrying"),f();return}if(o=null,m.ok){c("ok");return}if(m.status>=400&&m.status<500){c("failed");return}s.unshift(p),c("retrying"),f()}function h(p){s.push(p),!l&&(l=i(u,r))}function d(){let p=[];return o&&p.push(o),s.length&&p.push(e(s)),p.length?p.length===1?p[0]:e(p):null}return{enqueue:h,flush:u,pendingBytes:d,get status(){return a}}}function Zd({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 Qd(n){return{...n,parseDOM:[{tag:"br.Apple-interchange-newline",ignore:!0},...n.parseDOM||[]]}}function ep(n){let e=n.nodes.paragraph,t=n.nodes.hard_break;return r=>{let i=tp(r.content,e,t);return i===r.content?r:new b(i,r.openStart,r.openEnd)}}function tp(n,e,t){let r=[],i=!1;return n.forEach(s=>{if(s.type===e&&s.childCount>0&&qb(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=tp(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 qb(n,e){let t=!0;return n.forEach(r=>{r.type!==e&&(t=!1)}),t}function yi(n,e,t){n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Me(n,e,t){n[e]!==t&&(n[e]=t)}function np(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 Ha={center:"docs-align-center",right:"docs-align-right"},rp=["left","center","right"];function ao(n){return Object.prototype.hasOwnProperty.call(Ha,n)?Ha[n]:null}function Wb(n){for(let[e,t]of Object.entries(Ha))if(n.includes(t))return e;return null}function ip(n){return{...n,attrs:{...n.attrs||{},align:{default:null}},parseDOM:[{tag:"p",getAttrs:e=>({align:Wb(Array.from(e.classList||[]))})}],toDOM:e=>{let t=ao(e.attrs.align);return t?["p",{class:t},0]:["p",0]}}}function sp(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 op(n){let e=n.selection.$from.parent,t=e.attrs&&e.attrs.align;return ao(t)?t:"left"}var co={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 jb={regular:{weight:400,style:"normal"},bold:{weight:700,style:"normal"},italic:{weight:400,style:"italic"},boldItalic:{weight:700,style:"italic"}},et=co.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=>jb[t])})),Ka=new Map(et.map(n=>[n.key,n])),Ya=et.map(n=>n.key),Ae=co.default,pn=co.code,fo=Ya.map(n=>"font_"+n).reverse();function lp(n){if(Ka.has(n))return n===Ae?null:"font_"+n}function ap(n){for(let e of fo)if(n.includes(e))return e.slice(5);return Ae}function uo(n){let e=String(n||"").split(",").map(t=>t.trim().replace(/^["']|["']$/g,"").toLowerCase()).filter(Boolean);for(let t of e){let r=et.find(i=>i.cssName.toLowerCase()===t)||et.find(i=>i.docx.toLowerCase()===t)||et.find(i=>i.name.toLowerCase()===t)||et.find(i=>i.fallback.some(s=>s.toLowerCase()===t));if(r)return r.key}return null}function Hb(){if(!Ka.has(Ae))throw new Error(`fonts: the default ${Ae} is not a family`);if(!Ka.has(pn))throw new Error(`fonts: the code face ${pn} is not a family`);if(Ya[0]!==Ae)throw new Error(`fonts: the toolbar lists ${Ya[0]} first but the default is ${Ae}`);for(let n of et)if(!n.faces.some(e=>e.weight===400&&e.style==="normal"))throw new Error(`fonts: ${n.key} has no regular`)}Hb();var mt=[12,8,9,10,11,14,18,24,36,48,72],It=12,_t=[...mt.filter(n=>n!==It).map(n=>"size_"+n),"size_sm","size_lg","size_xl"],ho={size_sm:10,size_lg:14,size_xl:18};function cp(n){let e=Number(n);if(mt.includes(e))return e===It?null:"size_"+e}function fp(n){for(let e of _t)if(n.includes(e))return e in ho?ho[e]:Number(e.slice(5));return It}function Kb(){if(!mt.includes(It))throw new Error(`sizes: the default ${It} is not one of [${mt}]`);if(mt[0]!==It)throw new Error(`sizes: the control lists ${mt[0]} first but the default is ${It} \u2014 with no JavaScript the control would name a size the text is not set in`);for(let[t,r]of Object.entries(ho)){if(!mt.includes(r))throw new Error(`sizes: the legacy mark ${t} maps to ${r}pt, which is not on the ladder [${mt}]`);if(!_t.includes(t))throw new Error(`sizes: the legacy mark ${t} is not in the group the toolbar clears`)}let n=mt.filter(t=>t!==It).map(t=>"size_"+t),e=_t.filter(t=>!(t in ho));if(n.join()!==e.join())throw new Error(`sizes: the marks [${e}] do not match the offered sizes [${n}]`)}Kb();var Xa={align_left:null,align_center:"center",align_right:"right"};function Yb(){let n=Object.keys(Xa);for(let r of n){let i=Xa[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&&!ao(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=[...rp].sort();if(e.join()!==t.join())throw new Error(`toolbar: alignment commands [${e}] do not match align.mjs's [${t}]`)}Yb();function Ga(n){let e=n.previousElementSibling;return!e||!e.hasAttribute("rst-combo")?null:e.querySelector("input")}function Gb(n,e){if(!e)return;let t=n.getAttribute("aria-label");t&&yi(e,"aria-label",t)}var po=!1;function Xb(n,e,t){if(!e||document.activeElement===e)return;if(t&&typeof n.dispatchEvent=="function"){po=!0;try{n.dispatchEvent(new Event("change"))}finally{po=!1}return}let r=n.options[n.selectedIndex],i=r&&r.dataset||{},s=r?i.rstShort||i.rstName||r.text:"";Me(e,"value",s)}function gp({root:n,schema:e,getView:t,onSync:r,fonts:i=null,wrapCommand:s=l=>l,onFontUnavailable:o=null}){if(!n)return{plugin:null,commands:up(e,s),focusStop:()=>!1};let l=Array.from(n.querySelectorAll("[data-docs-command]")),a=Array.from(n.querySelectorAll("[data-docs-select]")),c=up(e,s);for(let p of l)p.addEventListener("mousedown",m=>m.preventDefault()),p.addEventListener("click",()=>{let m=c[p.getAttribute("data-docs-command")],g=t();!g||!m||(m(g.state,g.dispatch,g),g.focus())});for(let p of a)p.addEventListener("mousedown",m=>m.stopPropagation()),p.addEventListener("change",()=>{if(po)return;let m=t();m&&m.focus()}),p.addEventListener("change",()=>{if(po)return;let m=t();if(!m)return;let g=p.getAttribute("data-docs-select"),y=p.value;if(g==="block"&&xi(e,y)(m.state,m.dispatch,m),g==="font"){let k=lp(y);k!==void 0&&hp(e,fo,k)(m.state,m.dispatch)}if(g==="size"){let k=cp(y);k!==void 0&&hp(e,_t,k)(m.state,m.dispatch)}m.focus()});function f(p){let m=p.state;for(let g of l){let y=g.getAttribute("data-docs-command"),k=c[y];if(!k)continue;let C=k(m,null,p);Me(g,"disabled",!C);let I=pp(m,e,y);yi(g,"aria-pressed",I?"true":"false")}for(let g of a){let y=g.getAttribute("data-docs-select")==="font"&&i&&i.previews==="pending";Me(g,"disabled",y);let k=Ga(g);k&&Me(k,"disabled",y),Gb(g,k);let C=g.getAttribute("data-docs-select"),I=g.value;C==="block"&&Me(g,"value",mp(m)),C==="font"&&Me(g,"value",ew(m,e)),C==="size"&&Me(g,"value",String(fp(tw(m,e,_t)))),Xb(g,Ga(g),g.value!==I)}r&&r(p)}let u=np(n,[...l,...a.map(p=>Ga(p)||p)]),h=new le({view:p=>(f(p),u.ensureReachable(),{update:m=>{f(m),u.ensureReachable()}})}),d=(p,m)=>m.startsWith("block_")?mp(p)===m.slice(6):pp(p,e,m);return{plugin:h,commands:c,focusStop:u.focusStop,isPressed:d}}function up(n,e=t=>t){let t=n.marks,r=n.nodes;return{undo:Kd,redo:Yd,strong:e(hn(t.strong)),em:e(hn(t.em)),code:e(hn(t.code),!0),bullet_list:dp(r.bullet_list,r.list_item),ordered_list:dp(r.ordered_list,r.list_item),blockquote:Qb(r.blockquote),select_all:Ba,clear_formatting:Zb,block_paragraph:xi(n,"paragraph"),"block_heading-1":xi(n,"heading-1"),"block_heading-2":xi(n,"heading-2"),"block_heading-3":xi(n,"heading-3"),indent:Ge(Xs(r.list_item),sr(1)),outdent:Ge(ui(r.list_item),sr(-1)),...Object.fromEntries(Object.entries(Xa).map(([i,s])=>[i,sp(s)]))}}function Zb(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 xi(n,e){if(e==="paragraph")return La(n.nodes.paragraph);let t=Number(e.split("-")[1]);return Number.isInteger(t)?La(n.nodes.heading,{level:t}):()=>!1}function hp(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 dp(n,e){let t=pd(n),r=ui(e);return(i,s,o)=>bi(i,n)?r(i,s,o):t(i,s,o)}function Qb(n){let e=Ed(n);return(t,r,i)=>bi(t,n)?Sd(t,r,i):e(t,r,i)}function bi(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 pp(n,e,t){if(t.startsWith("align_"))return op(n)===t.slice(6);if(t==="bullet_list")return bi(n,e.nodes.bullet_list);if(t==="ordered_list")return bi(n,e.nodes.ordered_list);if(t==="blockquote")return bi(n,e.nodes.blockquote);let r=e.marks[t];return r?Za(n,r):!1}function Za(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 mp(n){let e=n.selection.$from.parent;return e.type.name==="heading"?"heading-"+e.attrs.level:"paragraph"}function ew(n,e){let t=fo.filter(r=>{let i=e.marks[r];return i&&Za(n,i)});return ap(t)}function tw(n,e,t){let r=[];for(let i of t){let s=e.marks[i];s&&Za(n,s)&&r.push(i)}return r}var nw={print:()=>(window.print(),!0)};function tc(n){return n.querySelector("[estilo-menubar-menu][open]")}function nc(n){return Array.from(n.querySelectorAll("[estilo-menubar-title]"))}function Qa(n){return Array.from(n.querySelectorAll("[estilo-menu-item]")).filter(e=>!e.disabled)}function ec(n,e){for(let t of nc(n))Me(t,"tabIndex",t===e?0:-1);e.focus()}function mo(n){let e=tc(n);e&&(e.open=!1)}function yp(n,{getView:e,commands:t,extraCommands:r,isPressed:i}){if(!n)return null;let s=nc(n);if(!s.length)return null;for(let[c,f]of s.entries())Me(f,"tabIndex",c===0?0:-1);let o={...nw,...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&&ec(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")){mo(n);return}c.preventDefault(),l(f.getAttribute("data-docs-command"),f),mo(n)}}),n.addEventListener("keydown",c=>{let f=c.target.closest("[estilo-menubar-title]"),u=c.target.closest("[estilo-menu-item]"),h=tc(n);switch(c.key){case"ArrowRight":case"ArrowLeft":{let d=f||h&&h.querySelector("[estilo-menubar-title]");if(!d)return;c.preventDefault();let p=nc(n),m=p[(p.indexOf(d)+(c.key==="ArrowRight"?1:-1)+p.length)%p.length],g=!!h;mo(n),g&&(m.closest("[estilo-menubar-menu]").open=!0),ec(n,m);return}case"ArrowDown":case"ArrowUp":{if(f){c.preventDefault();let d=f.closest("[estilo-menubar-menu]");d.open=!0;let p=Qa(d);p.length&&p[c.key==="ArrowDown"?0:p.length-1].focus();return}if(u&&h){c.preventDefault();let d=Qa(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=Qa(h);d.length&&d[c.key==="Home"?0:d.length-1].focus();return}case"Tab":mo(n)}}),n.addEventListener("pointerover",c=>{if(c.pointerType&&c.pointerType!=="mouse")return;let f=c.target.closest&&c.target.closest("[estilo-menubar-title]"),u=tc(n);if(!f||!u||u.contains(f))return;let h=f.closest("[estilo-menubar-menu]");h&&(h.open=!0,ec(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),yi(f,"aria-pressed",h?"true":"false")),o[u]){Me(f,"disabled",!1);continue}let d=t[u],p=!!(c&&d&&(h||d(c.state,null,c)));Me(f,"disabled",!p)}}return{sync:a}}function rc(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 xp({initialSeq:n=0,openStream:e,fetchSince:t,onUpdates:r,onError:i=()=>{},setTimeoutFn:s=setTimeout,clearTimeoutFn:o=clearTimeout,idleMs:l=12e4,hiddenMs:a=3e4}){let c=n,f=null,u=null,h=!1,d=!1,p=!1;function m(I){u!==null&&o(u),u=s(()=>{u=null,y()},I)}function g(){m(l)}function y(){u!==null&&(o(u),u=null),f&&(f.close(),f=null)}function k(){h||f||(f=e(I=>{g(),I>c&&C()},I=>{y(),i(I)}),g())}async function C(){if(d){p=!0;return}d=!0;try{let I=c,U=await t(I);if(h)return;try{U&&U.bytes&&U.bytes.length&&await r(U.bytes)}catch{if(U=await t(I,{raw:!0}),h)return;U&&U.bytes&&U.bytes.length&&await r(U.bytes)}U&&typeof U.seq=="number"&&U.seq>c&&(c=U.seq)}catch(I){i(I)}finally{d=!1,p&&!h&&(p=!1,C())}}return{start(){h=!1,k()},stop(){h=!0,y()},noteOwnSeq(I){typeof I!="number"||!Number.isFinite(I)||I===c+1&&(c=I)},noteActivity(){h||(f?g():k())},noteHidden(){h||!f||m(a)},noteLeaving(){h||y()},get cursor(){return c},get streaming(){return f!==null}}}var wp=3e3;var bp=new Map([["code",pn]]);function Sp(n){bp.clear();for(let[e,t]of n)bp.set(e,t)}function kp(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 Cp(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 rw=["p",0],iw=["blockquote",0],sw=["hr"],ow=["pre",["code",0]],lw=["br"],aw={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return rw}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM(){return iw}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return sw}},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 ow}},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 lw}}},cw=["em",0],fw=["strong",0],uw=["code",0],hw={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 cw}},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 fw}},code:{code:!0,parseDOM:[{tag:"code"}],toDOM(){return uw}}},or=new Hn({nodes:aw,marks:hw});function Ep(n,e){return{group:e,excludes:e,parseDOM:[{tag:"span."+n}],toDOM:()=>["span",{class:n},0]}}var dw=_t.reduce((n,e)=>n.addToStart(e,Ep("docs-"+e.replace("_","-"),"fontSize")),or.spec.marks),pw=[...et].reverse().reduce((n,e)=>{let t=Ep("docs-font-"+e.key,"fontFamily");return e.key!==Ae?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)===Ae||uo(r)===null?null:!1,clearMark:r=>r.type.spec.group==="fontFamily"}],n.addToStart("font_"+e.key,t)},dw),mw=dd(or.spec.nodes.update("paragraph",Fa(ip(or.spec.nodes.get("paragraph")),"p")).update("heading",Fa(or.spec.nodes.get("heading"),"h1")).update("hard_break",Qd(or.spec.nodes.get("hard_break"))),"paragraph block*","block"),ge=new Hn({nodes:mw,marks:pw});function lr(n){let e=n.name||n;if(typeof e=="string"&&e.startsWith("font_"))return e.slice(5);let t=typeof n=="string"?ge.marks[n]:n;return t&&t.spec.code?pn:null}function wi(n){let e=typeof n=="string"?ge.nodes[n]:n;return e&&e.spec.code?pn:null}function Tp(n,e=new Set([Ae])){return n.descendants(t=>{let r=wi(t.type);r&&e.add(r);for(let i of t.marks){let s=lr(i.type);s&&e.add(s)}}),e}Sp([...Object.values(ge.nodes).filter(n=>wi(n)).map(n=>[n.name,wi(n)]),...Object.values(ge.marks).filter(n=>!n.name.startsWith("font_")&&lr(n)).map(n=>[n.name,lr(n)])]);function gw(n,e){return e&&e(n.tr.replaceSelectionWith(ge.nodes.hard_break.create()).scrollIntoView()),!0}var yw=250;function ic(n,e){if(!e.length)return;let t=An(e);for(;_i(t);)Lf(t,n,"server")}function Ap(){return globalThis.docsFonts||kp(document.documentElement)}function xw(){return document.documentElement.getAttribute("data-docs-layout")==="frozen"}function bw(n){let e=new Set([Ae]),t=r=>{if(r instanceof se){for(let i of r.toDelta())for(let s of Object.keys(i.attributes||{})){let o=lr(s);o&&e.add(o)}return}if(r instanceof Y){let i=wi(r.nodeName);i&&e.add(i)}for(let i of r.toArray())t(i)};return t(n),[...e]}function ww(n){let e=new Set,t=r=>{let i=lr(r.type);i&&e.add(i)};for(let r of n.steps)r.slice&&Tp(r.slice.content,e),r.mark&&t(r.mark);return n.storedMarksSet&&n.storedMarks&&n.storedMarks.forEach(t),e.delete(void 0),[...e]}function Mp(){return new Promise(n=>requestAnimationFrame(()=>n()))}async function Sw(n){let e=n.getAttribute("data-sqid"),t=Ap(),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=null,p=document.querySelector("[docs-canvas]"),m=p&&p.getAttribute("data-view")===dn?dn:di,g=p?p.getAttribute("data-page-label"):"",y=!1;t.fontsReady.then(()=>{document.documentElement.getAttribute("data-docs-fonts")!=="pending"&&document.documentElement.setAttribute("data-docs-layout","frozen"),y=!0});let k=()=>y&&!xw()?m:di;function C(w){m=w,document.documentElement.removeAttribute("data-docs-layout"),p&&p.setAttribute("data-view",w),Id(w);let S=u;S&&S.dispatch(S.state.tr)}let I=Ld(document.querySelector("[docs-wordcount]"),{getView:()=>u}),U=Ud(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")||""}))}),Ue=!1,A=[],q=()=>Ue?new Promise(w=>A.push(w)):Promise.resolve(),F=Cp(document.querySelector("[docs-fonts-status]")),Si=[document.querySelector("[docs-toolbar]"),document.querySelector("[estilo-menubar]")].filter(Boolean),oc=document.querySelector("[docs-page]"),lc=8e3,Op=new le({filterTransaction(w){if(w.getMeta(V))return!0;if(Ue)return!w.docChanged&&!w.storedMarksSet?!0:(F.say("refused"),!1);let S=ww(w),E=S.filter(P=>!t.ready(P));if(!E.length)return t.use(S),!0;if(u&&u.composing)return t.commitFallback(E),t.use(S),!0;let L=u;return ac(E,()=>L!==u||L.state.doc!==w.before?!1:(L.dispatch(w),!0)),!1}});async function ac(w,S){Ue=!0,fc(!0);let E=!1;try{E=await t.waitFor(w,wp)&&w.every(L=>t.loaded(L)||t.committed(L))}catch{E=!1}Ue=!1,fc(!1);try{E=E&&S()!==!1}catch(L){console.error("fonts:",L),E=!1}finally{E?F.clear():F.say("unavailable",lc);let L=A;A=[];for(let P of L)P()}}let Dp=new Set(["Backspace"," ","Spacebar","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"]),Np=w=>{if(!Dp.has(w.key))return;let S=w.target;(!S||S===document.body||S===document.documentElement||S.closest&&S.closest("[inert]"))&&w.preventDefault()},Ip=w=>{w.preventDefault(),w.returnValue=""},cc=!1;function fc(w){let S=w?"addEventListener":"removeEventListener";window[S]("keydown",Np),window[S]("beforeunload",Ip);let E=u,L=E&&E.dom;w&&(cc=!!L&&(L.contains(document.activeElement)||Si.some(P=>P.contains(document.activeElement))));for(let P of[...Si,L])P&&(P.inert=w);oc&&oc.setAttribute("aria-busy",w?"true":"false"),w?F.say("loading"):cc&&E&&(!document.activeElement||document.activeElement===document.body)&&E.focus()}let go=w=>(S,E,L)=>{if(!E)return w(S,E,L);if(Ue)return F.say("refused"),!0;let P=t.inUse.filter(Ve=>!t.ready(Ve));return P.length?(ac(P,()=>{let Ve=u;return Ve?(w(Ve.state,Ve.dispatch,Ve),!0):!1}),!0):w(S,E,L)},_p=()=>F.say("unavailable",lc),mn=gp({root:document.querySelector("[docs-toolbar]"),schema:ge,fonts:t,onFontUnavailable:_p,getView:()=>u,onSync:w=>{d&&d.sync(w)}});d=yp(document.querySelector("[estilo-menubar]"),{getView:()=>u,commands:mn.commands,isPressed:(w,S)=>w==="view_paged"?m===dn:w==="view_infinite"?m===di:!!(S&&mn.isPressed&&mn.isPressed(S.state,w)),extraCommands:{view_paged:()=>(C(dn),!0),view_infinite:()=>(C(di),!0),...I?{word_count:I}:{},...U?{shortcuts:U}:{}}});function yo(w){a(c?"failed":w)}function Rp(w){return Xd({post:async S=>{let E=await fetch(r,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/octet-stream"},body:S}),L=w();if(E.ok&&L){let P=Number(E.headers.get("Docs-Seq"));Number.isFinite(P)&&L.noteOwnSeq(P)}return E},mergeUpdates:$f,debounceMs:yw,onStatus:S=>{S==="failed"&&(c=!0,xo.reportDivergence()),yo(S)}})}function vp(w){let S=u;if(!S||w.button!==0||S.dom.contains(w.target))return;let E=S.dom.getBoundingClientRect(),L=S.posAtCoords({left:Math.min(Math.max(w.clientX,E.left+1),E.right-1),top:Math.min(Math.max(w.clientY,E.top+1),E.bottom-1)}),P=L?L.pos:S.state.doc.content.size,Ve=O.near(S.state.doc.resolve(P));w.preventDefault(),S.dispatch(S.state.tr.setSelection(Ve).scrollIntoView()),S.focus()}function Bp(w,S){let E=[Wa(S),Gd(),Nd(ge),_d({getMode:k,pageLabel:g}),Op,_a({"Mod-z":go(ja),"Mod-y":go(lo),"Mod-Shift-z":go(lo),"Mod-b":hn(ge.marks.strong),"Mod-i":hn(ge.marks.em),"Shift-Enter":gw,Tab:Ge(Xs(ge.nodes.list_item),sr(1)),"Shift-Tab":Ge(ui(ge.nodes.list_item),sr(-1)),Backspace:Od,Escape:()=>mn.focusStop(),Enter:Ge(md(ge.nodes.list_item),Ua.Enter)}),_a(Ua)];return mn.plugin&&E.push(mn.plugin),new oi({mount:w},{state:Vs.create({schema:ge,plugins:E}),transformPasted:ep(ge)})}async function uc(w){let S=rc(r,{raw:w}),E=await fetch(S,{credentials:"same-origin"});if(!E.ok)throw new Error(`load ${S}: ${E.status}`);return{log:new Uint8Array(await E.arrayBuffer()),startSeq:Number(E.headers.get("Docs-Seq"))}}async function hc(){let{log:w,startSeq:S}=await uc(!1),E=new Ne;try{ic(E,w)}catch{({log:w,startSeq:S}=await uc(!0)),E=new Ne,ic(E,w)}let L=E.getXmlFragment("prosemirror");await t.prepare(bw(L));let P=null,Ve=Rp(()=>P);E.on("update",(Fe,ar)=>{ar!=="server"&&(xo.diverged||Ve.enqueue(Fe))}),u&&u.destroy(),f=Ve,u=Bp(n,L),h&&h.stop(),P=xp({initialSeq:Number.isFinite(S)?S:0,openStream:(Fe,ar)=>{let gn=new EventSource(i,{withCredentials:!0});return gn.addEventListener("update",gt=>Fe(Number(gt.data))),gn.addEventListener("error",gt=>ar(gt)),{close:()=>gn.close()}},fetchSince:async(Fe,{raw:ar}={})=>{let gn=rc(r,{since:Fe,raw:ar}),gt=await fetch(gn,{credentials:"same-origin"});if(!gt.ok)throw new Error(`fetch ${gn}: ${gt.status}`);return{bytes:new Uint8Array(await gt.arrayBuffer()),seq:Number(gt.headers.get("Docs-Seq"))}},onUpdates:async Fe=>{await t.prepareRemote(Fe),await q(),!(xo.diverged||h!==P)&&ic(E,Fe)},onError:Fe=>{console.error("live updates:",Fe)}}),h=P,h.start(),typeof document<"u"&&document.hidden&&h.noteHidden()}let xo=Zd({attemptResync:hc,onDiverged:()=>yo("failed"),onRecovered:()=>yo(c?"failed":"ok")});await hc(),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 Mp(),await Mp(),t.settled(),addEventListener("visibilitychange",()=>{document.hidden?h&&h.noteHidden():h&&h.noteActivity()}),addEventListener("pagehide",()=>h&&h.noteLeaving()),addEventListener("pageshow",w=>{w.persisted&&h&&h.noteActivity()});for(let w of["pointermove","scroll","keydown","focus"])addEventListener(w,()=>h&&h.noteActivity(),{passive:!0,capture:!0});let dc=n.closest("[docs-page]");dc&&dc.addEventListener("mousedown",vp);let bo=!1,pc=()=>{bo=!0,setTimeout(()=>{bo=!1},0)};return document.addEventListener("mousedown",pc,!0),document.addEventListener("touchstart",pc,!0),n.addEventListener("focus",()=>{if(bo)return;let w=u;w&&w.dispatch(w.state.tr.scrollIntoView())}),addEventListener("beforeunload",()=>{let w=f&&f.pendingBytes();if(!w)return;let S=new Blob([w],{type:"application/octet-stream"});navigator.sendBeacon(r,S)||(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:w}).catch(()=>{}))}),u}var sc=document.querySelector("[docs-editor]");sc&&Sw(sc).catch(n=>{Ap().settled(),sc.setAttribute("data-editor-failed","1"),console.error(n)});export{Sw as mountEditor};
diff --git a/internal/docs/static/fontsgate.3a8c20da76487d78.js b/internal/docs/static/fontsgate.3a8c20da76487d78.js
deleted file mode 100644
index 89acd2a..0000000
--- a/internal/docs/static/fontsgate.3a8c20da76487d78.js
+++ /dev/null
@@ -1 +0,0 @@
-var F={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 Y={regular:{weight:400,style:"normal"},bold:{weight:700,style:"normal"},italic:{weight:400,style:"italic"},boldItalic:{weight:700,style:"italic"}},B=F.families.map((e,r)=>({key:e.key,name:e.name,index:r+1,cssName:"Docs "+e.name,docx:e.docx.name,fallback:e.fallback,faces:Object.keys(e.styles).map(s=>Y[s])})),T=new Map(B.map(e=>[e.key,e])),L=B.map(e=>e.key),I=F.default,M=F.code,me=L.map(e=>"font_"+e).reverse();function C(e){return T.get(e)}function K(){if(!T.has(I))throw new Error(`fonts: the default ${I} is not a family`);if(!T.has(M))throw new Error(`fonts: the code face ${M} is not a family`);if(L[0]!==I)throw new Error(`fonts: the toolbar lists ${L[0]} first but the default is ${I}`);for(let e of B)if(!e.faces.some(r=>r.weight===400&&r.style==="normal"))throw new Error(`fonts: ${e.key} has no regular`)}K();var G=2500,V=3e3,W=4e3;function Q(e,{weight:r,style:s}){return`${s==="italic"?"italic ":""}${r} 16px "${e}"`}function X(e){if(!e||!e.length)return[];let r="";for(let i=0;i<e.length;i+=32768)r+=String.fromCharCode.apply(null,e.subarray(i,i+32768));let s=B.filter(i=>r.includes("font_"+i.key)).map(i=>i.key);for(let[i,n]of ee)r.includes(i)&&!s.includes(n)&&s.push(n);return s}var ee=new Map([["code",M]]);function U(e){let r=new Map,s={normal:"400",bold:"700"};for(let i of e){let n;try{n=i.cssRules}catch{continue}for(let c of n||[]){if(!c.style||!String(c.cssText||"").startsWith("@font-face"))continue;let b=c.style.getPropertyValue("font-family").trim().replace(/^["']|["']$/g,""),u=/url\(\s*["']?([^"')]+)["']?\s*\)/.exec(c.style.getPropertyValue("src"));if(!b.startsWith("Docs ")||!u)continue;let y=c.style.getPropertyValue("font-weight").trim()||"400",g=c.style.getPropertyValue("font-style").trim()||"normal";r.set(b+"|"+(s[y]||y)+"|"+g,new URL(u[1],i.href||location.href).href)}}return r}function R(e,r){return new Promise(s=>r(()=>s("late"),e))}function q({fontSet:e,root:r,setTimer:s=setTimeout}={}){let i=new Map,n=new Set,c=new Set([I]),b=!1,u="pending";function y(){if(!r)return;let t=[...n].sort().join(" ");r.getAttribute("data-docs-fonts-fallback")!==t&&r.setAttribute("data-docs-fonts-fallback",t)}function g(t){let a=!1;for(let o of t)n.has(o)||b&&c.has(o)&&!n.has(o)||(n.add(o),a=!0);a&&y()}function N(t){let a=t.family+"|"+t.weight+"|"+t.style,o=i.get(a);return o||(o={state:"pending"},o.promise=Promise.resolve().then(()=>e.load(Q(t.family,t))).then(d=>Array.isArray(d)?d.length>0:!!d,()=>!1).then(d=>(o.state=d?"loaded":"failed",d)),i.set(a,o)),o.promise}function ce(t,a,o){let d=k(t),l=(h,S)=>d.find(w=>w.weight===700===h&&w.style==="italic"===S);return l(a,o)||l(a,!1)||l(!1,!1)||d[0]}function k(t){let a=C(t);return a?a.faces.map(o=>({family:a.cssName,...o})):[]}function A(t){return n.has(t)?Promise.resolve(!1):Promise.all(k(t).map(N)).then(a=>a.every(Boolean))}function _(t){return n.has(t)?!0:k(t).every(a=>{let o=i.get(a.family+"|"+a.weight+"|"+a.style);return o&&o.state!=="pending"})}let E={ready:t=>_(t),loaded(t){return!n.has(t)&&k(t).every(a=>(i.get(a.family+"|"+a.weight+"|"+a.style)||{}).state==="loaded")},committed:t=>n.has(t),get fallback(){return[...n].sort()},get inUse(){return[...c]},use(t){for(let a of t)C(a)&&c.add(a)},required(t=[]){return[...new Set([...c,I,...t])].filter(a=>C(a))},markShown(){b=!0},get shown(){return b},async gate(t,a){let o=t.filter(f=>f.key!=="previews"),d=t.filter(f=>f.key==="previews");for(let f of o)c.add(f.key);let l=new Map,h=Promise.all(o.map(f=>N(f).then(P=>l.set(f,P)))),S=Promise.all(d.map(f=>N(f).then(P=>l.set(f,P)))),w=R(a,s),v=await Promise.race([h.then(()=>"ok"),w]),D=new Set(o.filter(f=>l.get(f)!==!0).map(f=>f.key));return g([...D]),E.previewsDone=Promise.race([S.then(()=>"ok"),w]).then(()=>(u=d.every(f=>l.get(f)===!0)?"web":"system",u)),v==="ok"&&D.size===0?"ok":"late"},previewsDone:Promise.resolve("system"),get previews(){return u},set previews(t){u=t},async prepare(t=[],{timeout:a=V}={}){let o=[...new Set(t)].filter(l=>C(l)&&!c.has(l)),d=E.required().filter(l=>!o.includes(l));await Promise.all([...d.map(A),...o.map(async l=>{await Promise.race([A(l),R(a,s)])==="late"&&g([l])})]);for(let l of o)c.add(l)},prepareRemote(t,a){return E.prepare(X(t),a)},async waitFor(t,a=W){if(t.every(_))return!0;let o=Promise.all(t.map(A)).then(()=>!0);return await Promise.race([o,R(a,s)])===!0},commitFallback(t){return g(t),t.every(a=>n.has(a))},async prefetch({keys:t,urls:a,fetchFn:o,idle:d=()=>Promise.resolve()}){for(let l of t)for(let h of k(l)){let S=h.family+"|"+h.weight+"|"+h.style;if(n.has(l)||i.has(S)||(await d(),n.has(l)||i.has(S)))continue;let w=a.get(S);if(!w)continue;let v=!1;try{v=await o(w)}catch{v=!1}v&&await N(h)}},async load(t){if(n.has(t))return!0;let a=await A(t);return a&&c.add(t),a}};return E}function $(e){let r=()=>!0;return{web:!1,ready:r,loaded:r,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(){!e||e.getAttribute("data-docs-fonts")!=="pending"||(clearTimeout(globalThis.__docsFontsHold),e.setAttribute("data-docs-fonts","shown"),e.getAttribute("data-docs-previews")==="pending"&&e.setAttribute("data-docs-previews","system"))}}}function j(e,{setTimer:r=setTimeout,clearTimer:s=clearTimeout}={}){if(!e)return{say(){},clear(){},state:""};let i=e.querySelector("[docs-fonts-status-text]"),n=e.querySelector("[docs-fonts-status-dismiss]"),c=null,b=()=>e.getAttribute("data-state")||"";function u(y){y&&b()!==y||(s(c),e.removeAttribute("data-state"),i&&(i.textContent=""))}return n&&n.addEventListener("click",()=>u()),{say(y,g=0){s(c),e.setAttribute("data-state",y),i&&(i.textContent=e.getAttribute("data-"+y)||""),g&&(c=r(()=>u(y),g))},clear:u,get state(){return b()}}}var te=3500,m=document.documentElement,x=document.querySelector("[docs-canvas]"),J=m.getAttribute("data-docs-fonts")==="pending";J&&clearTimeout(globalThis.__docsFontsHold);var p=q({fontSet:document.fonts,root:m}),H,ae=new Promise(e=>H=e),O,re=new Promise(e=>O=e);globalThis.docsFonts=Object.assign(p,{web:!1,fontsReady:re,settled:()=>H()});var oe=e=>new Promise(r=>setTimeout(r,Math.max(0,e-performance.now()))),ie=1e4;function Z(){if(p.markShown(),p.fallback.some(e=>e!=="previews")){let e=document.querySelector("[docs-fonts-status]");j(e).say("substitute",ie),se(e)}m.getAttribute("data-docs-fonts")!=="shown"&&m.setAttribute("data-docs-fonts","shown")}function se(e){let r=document.querySelector("[docs-text]");if(!e||!r||!x)return;let s=Math.ceil(e.getBoundingClientRect().bottom+4-r.getBoundingClientRect().top);s>0&&(x.style.paddingBlockStart=parseFloat(getComputedStyle(x).paddingBlockStart)+s+"px")}function ne(){let e=navigator.connection;if(e&&(e.saveData||/(^|-)2g$/.test(e.effectiveType||"")))return;let r=()=>new Promise(i=>typeof requestIdleCallback=="function"?requestIdleCallback(()=>i(),{timeout:5e3}):setTimeout(i,200)),s=i=>fetch(i,{priority:"low",credentials:"same-origin"}).then(async n=>n.ok?(await n.arrayBuffer(),!0):!1);return p.prefetch({keys:L,urls:U(document.styleSheets),fetchFn:s,idle:r})}async function le(){let e=[];try{e=JSON.parse(x&&x.getAttribute("data-docs-fonts-need")||"[]")}catch{e=[]}await p.gate(e,Math.max(0,G-performance.now())),p.web=!0,m.setAttribute("data-docs-faces","web"),p.previewsDone.then(s=>m.setAttribute("data-docs-previews",s)),O();let r=document.querySelector("[docs-editor]");r&&x&&x.getAttribute("data-view")==="paged"&&await Promise.race([ae.then(()=>"paginated"),oe(te).then(()=>"late")])==="late"&&m.setAttribute("data-docs-layout","frozen"),Z(),r&&(await Promise.all(p.required().map(s=>p.load(s))),await ne(),m.setAttribute("data-docs-fonts-prefetch","done"))}J?le().catch(e=>{console.error("fonts:",e),m.getAttribute("data-docs-previews")==="pending"&&m.setAttribute("data-docs-previews","system"),O(),Z()}):(m.setAttribute("data-docs-layout","frozen"),globalThis.docsFonts=$(m));
diff --git a/internal/docs/static/fontsgate.7161919aa93533b1.js b/internal/docs/static/fontsgate.7161919aa93533b1.js
new file mode 100644
index 0000000..8e1d536
--- /dev/null
+++ b/internal/docs/static/fontsgate.7161919aa93533b1.js
@@ -0,0 +1 @@
+var F={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 V={regular:{weight:400,style:"normal"},bold:{weight:700,style:"normal"},italic:{weight:400,style:"italic"},boldItalic:{weight:700,style:"italic"}},B=F.families.map((e,r)=>({key:e.key,name:e.name,index:r+1,cssName:"Docs "+e.name,docx:e.docx.name,fallback:e.fallback,faces:Object.keys(e.styles).map(i=>V[i])})),R=new Map(B.map(e=>[e.key,e])),L=B.map(e=>e.key),I=F.default,M=F.code,ue=L.map(e=>"font_"+e).reverse();function C(e){return R.get(e)}function W(){if(!R.has(I))throw new Error(`fonts: the default ${I} is not a family`);if(!R.has(M))throw new Error(`fonts: the code face ${M} is not a family`);if(L[0]!==I)throw new Error(`fonts: the toolbar lists ${L[0]} first but the default is ${I}`);for(let e of B)if(!e.faces.some(r=>r.weight===400&&r.style==="normal"))throw new Error(`fonts: ${e.key} has no regular`)}W();var U=2500,Q=3e3,X=4e3;function ee(e,{weight:r,style:i}){return`${i==="italic"?"italic ":""}${r} 16px "${e}"`}function te(e){if(!e||!e.length)return[];let r="";for(let s=0;s<e.length;s+=32768)r+=String.fromCharCode.apply(null,e.subarray(s,s+32768));let i=B.filter(s=>r.includes("font_"+s.key)).map(s=>s.key);for(let[s,n]of ae)r.includes(s)&&!i.includes(n)&&i.push(n);return i}var ae=new Map([["code",M]]);function q(e){let r=new Map,i={normal:"400",bold:"700"};for(let s of e){let n;try{n=s.cssRules}catch{continue}for(let l of n||[]){if(!l.style||!String(l.cssText||"").startsWith("@font-face"))continue;let b=l.style.getPropertyValue("font-family").trim().replace(/^["']|["']$/g,""),u=/url\(\s*["']?([^"')]+)["']?\s*\)/.exec(l.style.getPropertyValue("src"));if(!b.startsWith("Docs ")||!u)continue;let y=l.style.getPropertyValue("font-weight").trim()||"400",g=l.style.getPropertyValue("font-style").trim()||"normal";r.set(b+"|"+(i[y]||y)+"|"+g,new URL(u[1],s.href||location.href).href)}}return r}function O(e,r){return new Promise(i=>r(()=>i("late"),e))}function $({fontSet:e,root:r,setTimer:i=setTimeout}={}){let s=new Map,n=new Set,l=new Set([I]),b=!1,u="pending";function y(){if(!r)return;let t=[...n].sort().join(" ");r.getAttribute("data-docs-fonts-fallback")!==t&&r.setAttribute("data-docs-fonts-fallback",t)}function g(t){let a=!1;for(let o of t)n.has(o)||b&&l.has(o)&&!n.has(o)||(n.add(o),a=!0);a&&y()}function N(t){let a=t.family+"|"+t.weight+"|"+t.style,o=s.get(a);return o||(o={state:"pending"},o.promise=Promise.resolve().then(()=>e.load(ee(t.family,t))).then(d=>Array.isArray(d)?d.length>0:!!d,()=>!1).then(d=>(o.state=d?"loaded":"failed",d)),s.set(a,o)),o.promise}function fe(t,a,o){let d=k(t),c=(h,S)=>d.find(w=>w.weight===700===h&&w.style==="italic"===S);return c(a,o)||c(a,!1)||c(!1,!1)||d[0]}function k(t){let a=C(t);return a?a.faces.map(o=>({family:a.cssName,...o})):[]}function A(t){return n.has(t)?Promise.resolve(!1):Promise.all(k(t).map(N)).then(a=>a.every(Boolean))}function D(t){return n.has(t)?!0:k(t).every(a=>{let o=s.get(a.family+"|"+a.weight+"|"+a.style);return o&&o.state!=="pending"})}let E={ready:t=>D(t),loaded(t){return!n.has(t)&&k(t).every(a=>(s.get(a.family+"|"+a.weight+"|"+a.style)||{}).state==="loaded")},committed:t=>n.has(t),get fallback(){return[...n].sort()},get inUse(){return[...l]},use(t){for(let a of t)C(a)&&l.add(a)},required(t=[]){return[...new Set([...l,I,...t])].filter(a=>C(a))},markShown(){b=!0},get shown(){return b},async gate(t,a){let o=t.filter(f=>f.key!=="previews"),d=t.filter(f=>f.key==="previews");for(let f of o)l.add(f.key);let c=new Map,h=Promise.all(o.map(f=>N(f).then(T=>c.set(f,T)))),S=Promise.all(d.map(f=>N(f).then(T=>c.set(f,T)))),w=O(a,i),v=await Promise.race([h.then(()=>"ok"),w]),G=new Set(o.filter(f=>c.get(f)!==!0).map(f=>f.key));return g([...G]),E.previewsDone=Promise.race([S.then(()=>"ok"),w]).then(()=>(u=d.every(f=>c.get(f)===!0)?"web":"system",u)),v==="ok"&&G.size===0?"ok":"late"},previewsDone:Promise.resolve("system"),get previews(){return u},set previews(t){u=t},async prepare(t=[],{timeout:a=Q}={}){let o=[...new Set(t)].filter(c=>C(c)&&!l.has(c)),d=E.required().filter(c=>!o.includes(c));await Promise.all([...d.map(A),...o.map(async c=>{await Promise.race([A(c),O(a,i)])==="late"&&g([c])})]);for(let c of o)l.add(c)},prepareRemote(t,a){return E.prepare(te(t),a)},async waitFor(t,a=X){if(t.every(D))return!0;let o=Promise.all(t.map(A)).then(()=>!0);return await Promise.race([o,O(a,i)])===!0},commitFallback(t){return g(t),t.every(a=>n.has(a))},async prefetch({keys:t,urls:a,fetchFn:o,idle:d=()=>Promise.resolve()}){for(let c of t)for(let h of k(c)){let S=h.family+"|"+h.weight+"|"+h.style;if(n.has(c)||s.has(S)||(await d(),n.has(c)||s.has(S)))continue;let w=a.get(S);if(!w)continue;let v=!1;try{v=await o(w)}catch{v=!1}v&&await N(h)}},async load(t){if(n.has(t))return!0;let a=await A(t);return a&&l.add(t),a}};return E}function j(e){let r=()=>!0;return{web:!1,ready:r,loaded:r,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(){!e||e.getAttribute("data-docs-fonts")!=="pending"||(clearTimeout(globalThis.__docsFontsHold),e.setAttribute("data-docs-fonts","shown"),e.getAttribute("data-docs-previews")==="pending"&&e.setAttribute("data-docs-previews","system"))}}}function J(e,{setTimer:r=setTimeout,clearTimer:i=clearTimeout}={}){if(!e)return{say(){},clear(){},state:""};let s=e.querySelector("[docs-fonts-status-text]"),n=e.querySelector("[docs-fonts-status-dismiss]"),l=null,b=()=>e.getAttribute("data-state")||"";function u(y){y&&b()!==y||(i(l),e.removeAttribute("data-state"),s&&(s.textContent=""))}return n&&n.addEventListener("click",()=>u()),{say(y,g=0){i(l),e.setAttribute("data-state",y),s&&(s.textContent=e.getAttribute("data-"+y)||""),g&&(l=r(()=>u(y),g))},clear:u,get state(){return b()}}}var re=3500,m=document.documentElement,x=document.querySelector("[docs-canvas]"),H=m.getAttribute("data-docs-fonts")==="pending";H&&clearTimeout(globalThis.__docsFontsHold);var p=$({fontSet:document.fonts,root:m}),Z,oe=new Promise(e=>Z=e),_,ie=new Promise(e=>_=e);globalThis.docsFonts=Object.assign(p,{web:!1,fontsReady:ie,settled:()=>Z()});var se=e=>new Promise(r=>setTimeout(r,Math.max(0,e-performance.now()))),ne=1e4;function z(){if(p.markShown(),p.fallback.some(e=>e!=="previews")){let e=document.querySelector("[docs-fonts-status]");J(e).say("substitute",ne),le(e)}m.getAttribute("data-docs-fonts")!=="shown"&&m.setAttribute("data-docs-fonts","shown")}function le(e){let r=document.querySelector("[docs-text]");if(!e||!r||!x)return;let i=Math.ceil(e.getBoundingClientRect().bottom+4-r.getBoundingClientRect().top);i>0&&(x.style.paddingBlockStart=parseFloat(getComputedStyle(x).paddingBlockStart)+i+"px")}function Y(){let e=navigator.connection;if(e&&(e.saveData||/(^|-)2g$/.test(e.effectiveType||"")))return;let r=()=>new Promise(n=>typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(),{timeout:5e3}):setTimeout(n,200)),{signal:i}=P=new AbortController,s=n=>i.aborted?Promise.resolve(!1):fetch(n,{priority:"low",credentials:"same-origin",signal:i}).then(async l=>l.ok?(await l.arrayBuffer(),!0):!1);return p.prefetch({keys:L,urls:q(document.styleSheets),fetchFn:s,idle:r})}var P=null;addEventListener("pagehide",()=>P&&P.abort());addEventListener("pageshow",e=>{e.persisted&&P&&Y()});async function ce(){let e=[];try{e=JSON.parse(x&&x.getAttribute("data-docs-fonts-need")||"[]")}catch{e=[]}await p.gate(e,Math.max(0,U-performance.now())),p.web=!0,m.setAttribute("data-docs-faces","web"),p.previewsDone.then(i=>m.setAttribute("data-docs-previews",i)),_();let r=document.querySelector("[docs-editor]");r&&x&&x.getAttribute("data-view")==="paged"&&await Promise.race([oe.then(()=>"paginated"),se(re).then(()=>"late")])==="late"&&m.setAttribute("data-docs-layout","frozen"),z(),r&&(await Promise.all(p.required().map(i=>p.load(i))),await Y(),m.setAttribute("data-docs-fonts-prefetch","done"))}H?ce().catch(e=>{console.error("fonts:",e),m.getAttribute("data-docs-previews")==="pending"&&m.setAttribute("data-docs-previews","system"),_(),z()}):(m.setAttribute("data-docs-layout","frozen"),globalThis.docsFonts=j(m));